libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / exynos_format.h
CommitLineData
5763fb39
T
1/*
2 * Copyright@ Samsung Electronics Co. LTD
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
17#ifndef _EXYNOS_FORMAT_H_
18#define _EXYNOS_FORMAT_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24enum {
25 /* HAL_PIXEL_FORMAT_YCbCr_422_P = 0x100, */
26 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P_M = 0x101, /* HAL_PIXEL_FORMAT_YCbCr_420_P */
27 /* HAL_PIXEL_FORMAT_YCbCr_420_I = 0x102, */
28 HAL_PIXEL_FORMAT_EXYNOS_CbYCrY_422_I = 0x103, /* HAL_PIXEL_FORMAT_CbYCrY_422_I */
29 /* HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x104, */
30 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M = 0x105, /* HAL_PIXEL_FORMAT_YCbCr_420_SP */
31 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_422_SP = 0x106, /* HAL_PIXEL_FORMAT_YCrCb_422_SP */
32 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_TILED= 0x107, /* HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED */
33 HAL_PIXEL_FORMAT_EXYNOS_ARGB_8888 = 0x108, /* HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888 */
34 // support custom format for zero copy
35 /* HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x110 */
36 /* HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x111, */
37 /* HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED = 0x112, */
38 /* HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP = 0x113, */
39 /* HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP = 0x114, */
40 /* HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x115, */
41 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_422_I = 0x116, /* HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I */
42 /* HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117, */
43 HAL_PIXEL_FORMAT_EXYNOS_CrYCbY_422_I = 0x118, /* HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I */
44 /* HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I = 0x11B, */
45
46 HAL_PIXEL_FORMAT_EXYNOS_YV12_M = 0x11C, /* HAL_PIXEL_FORMAT_EXYNOS_YV12 */
47 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M = 0x11D, /* HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP */
48 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_FULL = 0x11E, /* HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_FULL */
49
50 /* newly added formats */
51 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P = 0x11F,
52 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP = 0x120,
53
54 /* Interlace EXYNOS_YCbCr_420_SP_M */
55 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_PRIV = 0x121,
56
57 /* contiguous(single fd) custom formats */
58 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_PN = 0x122,
59 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN = 0x123,
60 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_TILED = 0x124,
61
62 /* 10-bit format (8bit + separated 2bit) */
63 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_S10B = 0x125,
64
65 /* 10-bit contiguous(single fd, 8bit + separated 2bit) custom formats */
66 HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_S10B = 0x126,
67
68 HAL_PIXEL_FORMAT_EXYNOS_MAX
69};
70
71/* for backward compatibility */
72#define HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M
73#define HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M
74
75// Gamut (colorspace range)
76enum {
77 HAL_PIXEL_GAMUT_DEFAULT = 0,
78 // Values range 0-255
79 HAL_PIXEL_GAMUT_WIDE_8,
80 // Values range 16-235
81 HAL_PIXEL_GAMUT_NARROW_8
82};
83
84// Chromaticities (colorspace parameters)
85enum {
86 HAL_PIXEL_CHROMA_DEFAULT = 0,
87 // BT.601 "Standard Definition" color space
88 HAL_PIXEL_CHROMA_BT601_8,
89 // BT.709 "High Definition" color space
90 HAL_PIXEL_CHROMA_BT709_8
91};
92
93struct ADDRS {
94 unsigned int addr_y;
95 unsigned int addr_cbcr;
96 unsigned int buf_idx;
97 unsigned int reserved;
98};
99
100/* 12 Y/CbCr 4:2:0 64x32 macroblocks */
101#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2')
102
103#define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
104#define ALIGN_DOWN(x, a) ((x) - (x % a))
105#ifndef ALIGN
106#define ALIGN(x, a) ALIGN_UP(x, a)
107#endif
108#ifndef ALIGN_TO_32B
109#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
110#endif
111#ifndef ALIGN_TO_128B
112#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
113#endif
114#ifndef ALIGN_TO_8KB
115#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
116#endif
117
118#define GET_32BPP_FRAME_SIZE(w, h) (((w) * (h)) << 2)
119#define GET_24BPP_FRAME_SIZE(w, h) (((w) * (h)) * 3)
120#define GET_16BPP_FRAME_SIZE(w, h) (((w) * (h)) << 1)
121
122/*
123 * Convert hal_pixel_format to v4l2_pixel_format.
124 *
125 * @param hal_pixel_format
126 * hal_pixel_format[in]
127 *
128 * @return
129 * v4l2_pixel_format
130 */
131int HAL_PIXEL_FORMAT_2_V4L2_PIX(
132 int hal_pixel_format);
133
134/*
135 * Convert v4l2_pixel_format to hal_pixel_format.
136 *
137 * @param v4l2_pixel_format
138 * v4l2_pixel_format[in]
139 *
140 * @return
141 * hal_pixel_format
142 */
143int V4L2_PIX_2_HAL_PIXEL_FORMAT(
144 int v4l2_pixel_format);
145
146/*
147 * Get frame_size of hal_pixel_format.
148 *
149 * @param hal_pixel_format
150 * hal_pixel_format[in]
151 *
152 * @param width
153 * width[in]
154 *
155 * @param height
156 * height[in]
157 *
158 * @return
159 * frame_size
160 */
161unsigned int FRAME_SIZE(
162 int hal_pixel_format,
163 int width,
164 int height);
165
166int PLANAR_FRAME_SIZE(
167 int hal_pixel_format,
168 int width,
169 int height,
170 unsigned int *luma_size,
171 unsigned int *chroma_size);
172
173int NUM_PLANES(int hal_pixel_format);
174
175
176/*
177 * Get bpp and plane of v4l2_pixel_format.
178 *
179 * @param v4l2_pixel_format
180 * v4l2_pixel_format[in]
181 *
182 * @param bpp
183 * address of bpp[out]
184 *
185 * @param planes
186 * address of planes[out]
187 *
188 * @return
189 * error code
190 */
191int V4L2_PIX_2_YUV_INFO(
192 unsigned int v4l2_pixel_format,
193 unsigned int *bpp,
194 unsigned int *planes);
195
196/*
197 * Get bpp of v4l2_pixel_format.
198 *
199 * @param v4l2_pixel_format
200 * v4l2_pixel_format[in]
201 *
202 * @return
203 * bpp
204 */
205int get_yuv_bpp(
206 unsigned int v4l2_pixel_format);
207
208/*
209 * Get plane of v4l2_pixel_format.
210 *
211 * @param v4l2_pixel_format
212 * v4l2_pixel_format[in]
213 *
214 * @return
215 * num of plane
216 */
217int get_yuv_planes(
218 unsigned int v4l2_pixel_format);
219
220#ifdef __cplusplus
221}
222#endif
223
224#endif