-
Notifications
You must be signed in to change notification settings - Fork 0
/
mali_gralloc_formats.cpp
executable file
·92 lines (82 loc) · 2.69 KB
/
mali_gralloc_formats.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* Copyright (C) 2016-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "gralloc"
// #define ENABLE_DEBUG_LOG
#include <log/custom_log.h>
#include <string.h>
#include <dlfcn.h>
#include <inttypes.h>
#include <cutils/log.h>
#if GRALLOC_USE_GRALLOC1_API == 1
#include <hardware/gralloc1.h>
#else
#include <hardware/gralloc.h>
#endif
// #include "mali_gralloc_module.h"
// #include "gralloc_priv.h"
#include "gralloc_helper.h"
#include "mali_gralloc_formats.h"
#include "mali_gralloc_usages.h"
static int map_flex_formats(uint64_t req_format)
{
/* Map Android flexible formats to internal base formats */
if (req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED || req_format == HAL_PIXEL_FORMAT_YCbCr_420_888)
{
req_format = MALI_GRALLOC_FORMAT_INTERNAL_NV12;
}
else if (req_format == HAL_PIXEL_FORMAT_YCbCr_422_888)
{
/* To be determined */
}
else if (req_format == HAL_PIXEL_FORMAT_YCbCr_444_888)
{
/* To be determined */
}
return req_format;
}
uint64_t mali_gralloc_select_format(uint64_t req_format, mali_gralloc_format_type type, uint64_t usage, int buffer_size)
{
uint64_t internal_format;
GRALLOC_UNUSED(type);
GRALLOC_UNUSED(usage);
GRALLOC_UNUSED(buffer_size);
if ( req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED )
{
if ( GRALLOC_USAGE_HW_VIDEO_ENCODER == (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) )
{
I("(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER treat as NV12");
internal_format = HAL_PIXEL_FORMAT_YCrCb_NV12;
}
else
{
I("treat as NV12 888");
internal_format = HAL_PIXEL_FORMAT_RGBX_8888;
}
}
else if ( req_format == HAL_PIXEL_FORMAT_YCrCb_NV12_10
&& USAGE_CONTAIN_VALUE(GRALLOC_USAGE_TO_USE_ARM_P010, GRALLOC_USAGE_ROT_MASK) )
{
ALOGV("rk_debug force MALI_GRALLOC_FORMAT_INTERNAL_P010 usage=0x%" PRIx64, usage);
internal_format = MALI_GRALLOC_FORMAT_INTERNAL_P010; // base_format of internal_format, no modifiers.
}
else
{
internal_format = map_flex_formats(req_format);
}
return internal_format;
}