• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2012 Samsung Electronics S.LSI Co. LTD
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #define LOG_TAG "libcsc_helper"
19 #include <cutils/log.h>
20 
21 #include <system/graphics.h>
22 
23 #include "Exynos_OMX_Def.h"
24 
25 #include "csc.h"
26 #include "exynos_format.h"
27 #include "fimg2d.h"
28 
hal_2_omx_pixel_format(unsigned int hal_format)29 OMX_COLOR_FORMATTYPE hal_2_omx_pixel_format(
30     unsigned int hal_format)
31 {
32     OMX_COLOR_FORMATTYPE omx_format;
33     switch (hal_format) {
34     case HAL_PIXEL_FORMAT_YCbCr_422_I:
35         omx_format = OMX_COLOR_FormatYCbYCr;
36         break;
37     case HAL_PIXEL_FORMAT_YCbCr_420_P:
38         omx_format = OMX_COLOR_FormatYUV420Planar;
39         break;
40     case HAL_PIXEL_FORMAT_YCbCr_420_SP:
41         omx_format = OMX_COLOR_FormatYUV420SemiPlanar;
42         break;
43     case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
44         omx_format = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
45         break;
46     case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
47         omx_format = OMX_SEC_COLOR_FormatNV12Tiled;
48         break;
49     case HAL_PIXEL_FORMAT_BGRA_8888:
50     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
51         omx_format = OMX_COLOR_Format32bitARGB8888;
52         break;
53     default:
54         omx_format = OMX_COLOR_FormatYUV420Planar;
55         break;
56     }
57     return omx_format;
58 }
59 
omx_2_hal_pixel_format(OMX_COLOR_FORMATTYPE omx_format)60 unsigned int omx_2_hal_pixel_format(
61     OMX_COLOR_FORMATTYPE omx_format)
62 {
63     unsigned int hal_format;
64     switch (omx_format) {
65     case OMX_COLOR_FormatYCbYCr:
66         hal_format = HAL_PIXEL_FORMAT_YCbCr_422_I;
67         break;
68     case OMX_COLOR_FormatYUV420Planar:
69         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
70         break;
71     case OMX_COLOR_FormatYUV420SemiPlanar:
72         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP;
73         break;
74     case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
75         hal_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
76         break;
77     case OMX_SEC_COLOR_FormatNV12Tiled:
78         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
79         break;
80     case OMX_COLOR_Format32bitARGB8888:
81         hal_format = HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888;
82         break;
83     default:
84         hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
85         break;
86     }
87     return hal_format;
88 }
89 
hal_2_g2d_color_format(unsigned int hal_format)90 unsigned int hal_2_g2d_color_format(unsigned int hal_format)
91 {
92     switch (hal_format) {
93     case HAL_PIXEL_FORMAT_RGBA_8888:
94     case HAL_PIXEL_FORMAT_BGRA_8888:
95     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
96         return CF_ARGB_8888;
97 
98     case HAL_PIXEL_FORMAT_RGBX_8888:
99         return CF_XRGB_8888;
100 
101     case HAL_PIXEL_FORMAT_RGB_888:
102         return CF_RGB_888;
103 
104     case HAL_PIXEL_FORMAT_RGB_565:
105         return CF_RGB_565;
106 
107     case HAL_PIXEL_FORMAT_YCbCr_422_I:
108         return CF_YCBCR_422;
109 
110     case HAL_PIXEL_FORMAT_YCbCr_420_SP:
111         return CF_YCBCR_420;
112 
113     default:
114         return SRC_DST_FORMAT_END;
115     }
116 }
117 
hal_2_g2d_pixel_order(unsigned int hal_format)118 unsigned int hal_2_g2d_pixel_order(unsigned int hal_format)
119 {
120     switch (hal_format) {
121     case HAL_PIXEL_FORMAT_BGRA_8888:
122     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
123         return AX_RGB;
124 
125     case HAL_PIXEL_FORMAT_RGBA_8888:
126     case HAL_PIXEL_FORMAT_RGBX_8888:
127     case HAL_PIXEL_FORMAT_RGB_888:
128     case HAL_PIXEL_FORMAT_RGB_565:
129         return RGB_AX;
130 
131     case HAL_PIXEL_FORMAT_YCbCr_422_I:
132         return P1_Y1CBY0CR;
133 
134     case HAL_PIXEL_FORMAT_YCbCr_420_SP:
135         return P2_CRCB;
136 
137     default:
138         return ARGB_ORDER_END;
139     }
140 }
141 
hal_2_g2d_bpp(unsigned int hal_format)142 size_t hal_2_g2d_bpp(unsigned int hal_format)
143 {
144     switch (hal_format) {
145         case HAL_PIXEL_FORMAT_BGRA_8888:
146         case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
147         case HAL_PIXEL_FORMAT_RGBA_8888:
148         case HAL_PIXEL_FORMAT_RGBX_8888:
149             return 32;
150 
151         case HAL_PIXEL_FORMAT_RGB_888:
152             return 24;
153 
154         case HAL_PIXEL_FORMAT_RGB_565:
155             return 16;
156 
157         case HAL_PIXEL_FORMAT_YCbCr_422_I:
158         case HAL_PIXEL_FORMAT_YCbCr_420_SP:
159             return 8;
160 
161         default:
162             return 0;
163         }
164 }
165