blob: 610c89d9ab144b5b774fde364dd814c15c2db3ee [file] [log] [blame]
Dima Zavinbbcf7862012-04-03 00:08:58 -07001/*
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_YCbCr_420_P = 0x101,
27 HAL_PIXEL_FORMAT_YCbCr_420_I = 0x102,
28 HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x103,
29 HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x104,
30 HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x105,
31 HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x106,
32 HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x107,
Greg Hackmannae570c52013-01-03 11:22:37 -080033 HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888 = 0x108,
Dima Zavinbbcf7862012-04-03 00:08:58 -070034 // 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_CUSTOM_YCrCb_422_I = 0x116,
42 HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117,
43 HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I = 0x118,
44 HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I = 0x11B,
Rebecca Schultz Zavinc853be72012-08-23 00:03:05 -070045
46 HAL_PIXEL_FORMAT_EXYNOS_YV12 = 0x11C,
47 HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP = 0x11D,
Dima Zavinbbcf7862012-04-03 00:08:58 -070048 HAL_PIXEL_FORMAT_CUSTOM_MAX
49};
50
51struct ADDRS {
52 unsigned int addr_y;
53 unsigned int addr_cbcr;
54 unsigned int buf_idx;
55 unsigned int reserved;
56};
57
58/* 12 Y/CbCr 4:2:0 64x32 macroblocks */
59#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2')
60
61#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
62#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
63#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
64#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
65
66#define GET_32BPP_FRAME_SIZE(w, h) (((w) * (h)) << 2)
67#define GET_24BPP_FRAME_SIZE(w, h) (((w) * (h)) * 3)
68#define GET_16BPP_FRAME_SIZE(w, h) (((w) * (h)) << 1)
69
70/*
71 * Convert hal_pixel_format to v4l2_pixel_format.
72 *
73 * @param hal_pixel_format
74 * hal_pixel_format[in]
75 *
76 * @return
77 * v4l2_pixel_format
78 */
79int HAL_PIXEL_FORMAT_2_V4L2_PIX(
80 int hal_pixel_format);
81
82/*
83 * Convert v4l2_pixel_format to hal_pixel_format.
84 *
85 * @param v4l2_pixel_format
86 * v4l2_pixel_format[in]
87 *
88 * @return
89 * hal_pixel_format
90 */
91int V4L2_PIX_2_HAL_PIXEL_FORMAT(
92 int v4l2_pixel_format);
93
94/*
95 * Get frame_size of hal_pixel_format.
96 *
97 * @param hal_pixel_format
98 * hal_pixel_format[in]
99 *
100 * @param width
101 * width[in]
102 *
103 * @param height
104 * height[in]
105 *
106 * @return
107 * frame_size
108 */
109unsigned int FRAME_SIZE(
110 int hal_pixel_format,
111 int width,
112 int height);
113
Rebecca Schultz Zavin471812b2012-05-15 16:49:56 -0700114int PLANAR_FRAME_SIZE(
115 int hal_pixel_format,
116 int width,
117 int height,
118 unsigned int *luma_size,
119 unsigned int *chroma_size);
120
121int NUM_PLANES(int hal_pixel_format);
122
123
Dima Zavinbbcf7862012-04-03 00:08:58 -0700124/*
125 * Get bpp and plane of v4l2_pixel_format.
126 *
127 * @param v4l2_pixel_format
128 * v4l2_pixel_format[in]
129 *
130 * @param bpp
131 * address of bpp[out]
132 *
133 * @param planes
134 * address of planes[out]
135 *
136 * @return
137 * error code
138 */
139int V4L2_PIX_2_YUV_INFO(
140 unsigned int v4l2_pixel_format,
141 unsigned int *bpp,
142 unsigned int *planes);
143
144/*
145 * Get bpp of v4l2_pixel_format.
146 *
147 * @param v4l2_pixel_format
148 * v4l2_pixel_format[in]
149 *
150 * @return
151 * bpp
152 */
153unsigned int get_yuv_bpp(
154 unsigned int v4l2_pixel_format);
155
156/*
157 * Get plane of v4l2_pixel_format.
158 *
159 * @param v4l2_pixel_format
160 * v4l2_pixel_format[in]
161 *
162 * @return
163 * num of plane
164 */
165unsigned int get_yuv_planes(
166 unsigned int v4l2_pixel_format);
167
168#ifdef __cplusplus
169}
170#endif
171
172#endif