summaryrefslogtreecommitdiff
path: root/include/exynos_format.h
blob: aca11031793aafcaf0cb4ed5b5d9da8ba90604b5 (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 * Copyright@ Samsung Electronics Co. LTD
 *
 * 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.
*/

#ifndef _EXYNOS_FORMAT_H_
#define _EXYNOS_FORMAT_H_

#ifdef __cplusplus
extern "C" {
#endif

enum {
    HAL_PIXEL_FORMAT_YCbCr_422_P                = 0x100,
    HAL_PIXEL_FORMAT_YCbCr_420_P                = 0x101,
    HAL_PIXEL_FORMAT_YCbCr_420_I                = 0x102,
    HAL_PIXEL_FORMAT_CbYCrY_422_I               = 0x103,
    HAL_PIXEL_FORMAT_CbYCrY_420_I               = 0x104,
    HAL_PIXEL_FORMAT_YCbCr_420_SP               = 0x105,
    HAL_PIXEL_FORMAT_YCrCb_422_SP               = 0x106,
    HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED         = 0x107,
    HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888           = 0x108,
    // support custom format for zero copy
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP        = 0x110,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP        = 0x111,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED  = 0x112,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP        = 0x113,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP        = 0x114,
    HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I         = 0x115,
    HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I         = 0x116,
    HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I        = 0x117,
    HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I        = 0x118,
    HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I         = 0x11B,

    HAL_PIXEL_FORMAT_EXYNOS_YV12                = 0x11C,
    HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP        = 0x11D,
    HAL_PIXEL_FORMAT_CUSTOM_MAX
};

// Gamut (colorspace range)
enum {
    HAL_PIXEL_GAMUT_DEFAULT = 0,
    // Values range 0-255
    HAL_PIXEL_GAMUT_WIDE_8,
    // Values range 16-235
    HAL_PIXEL_GAMUT_NARROW_8
};

// Chromaticities (colorspace parameters)
enum {
    HAL_PIXEL_CHROMA_DEFAULT = 0,
    // BT.601 "Standard Definition" color space
    HAL_PIXEL_CHROMA_BT601_8,
    // BT.709 "High Definition" color space
    HAL_PIXEL_CHROMA_BT709_8
};

struct ADDRS {
    unsigned int addr_y;
    unsigned int addr_cbcr;
    unsigned int buf_idx;
    unsigned int reserved;
};

/* 12  Y/CbCr 4:2:0 64x32 macroblocks */
#define V4L2_PIX_FMT_NV12T    v4l2_fourcc('T', 'V', '1', '2')

#define ALIGN(x, a)       (((x) + (a) - 1) & ~((a) - 1))
#define ALIGN_TO_32B(x)   ((((x) + (1 <<  5) - 1) >>  5) <<  5)
#define ALIGN_TO_128B(x)  ((((x) + (1 <<  7) - 1) >>  7) <<  7)
#define ALIGN_TO_8KB(x)   ((((x) + (1 << 13) - 1) >> 13) << 13)

#define GET_32BPP_FRAME_SIZE(w, h)  (((w) * (h)) << 2)
#define GET_24BPP_FRAME_SIZE(w, h)  (((w) * (h)) * 3)
#define GET_16BPP_FRAME_SIZE(w, h)  (((w) * (h)) << 1)

/*
 * Convert hal_pixel_format to v4l2_pixel_format.
 *
 * @param hal_pixel_format
 *   hal_pixel_format[in]
 *
 * @return
 *   v4l2_pixel_format
 */
int HAL_PIXEL_FORMAT_2_V4L2_PIX(
    int hal_pixel_format);

/*
 * Convert v4l2_pixel_format to hal_pixel_format.
 *
 * @param v4l2_pixel_format
 *   v4l2_pixel_format[in]
 *
 * @return
 *   hal_pixel_format
 */
int V4L2_PIX_2_HAL_PIXEL_FORMAT(
    int v4l2_pixel_format);

/*
 * Get frame_size of hal_pixel_format.
 *
 * @param hal_pixel_format
 *   hal_pixel_format[in]
 *
 * @param width
 *   width[in]
 *
 * @param height
 *   height[in]
 *
 * @return
 *   frame_size
 */
unsigned int FRAME_SIZE(
    int hal_pixel_format,
    int width,
    int height);

int PLANAR_FRAME_SIZE(
    int hal_pixel_format,
    int width,
    int height, 
    unsigned int *luma_size,
    unsigned int *chroma_size);

int NUM_PLANES(int hal_pixel_format);


/*
 * Get bpp and plane of v4l2_pixel_format.
 *
 * @param v4l2_pixel_format
 *   v4l2_pixel_format[in]
 *
 * @param bpp
 *   address of bpp[out]
 *
 * @param planes
 *   address of planes[out]
 *
 * @return
 *   error code
 */
int V4L2_PIX_2_YUV_INFO(
    unsigned int  v4l2_pixel_format,
    unsigned int *bpp,
    unsigned int *planes);

/*
 * Get bpp of v4l2_pixel_format.
 *
 * @param v4l2_pixel_format
 *   v4l2_pixel_format[in]
 *
 * @return
 *   bpp
 */
unsigned int get_yuv_bpp(
    unsigned int v4l2_pixel_format);

/*
 * Get plane of v4l2_pixel_format.
 *
 * @param v4l2_pixel_format
 *   v4l2_pixel_format[in]
 *
 * @return
 *   num of plane
 */
unsigned int get_yuv_planes(
    unsigned int v4l2_pixel_format);

#ifdef __cplusplus
}
#endif

#endif