tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / video / sprd_img.h
1 /*
2  * Copyright (C) 2012 Spreadtrum Communications Inc.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13 #ifndef _SPRD_IMG_H_
14 #define _SPRD_IMG_H_
15
16 /*  Four-character-code (FOURCC) */
17 #define img_fourcc(a, b, c, d)\
18         ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
19
20 /* RGB formats */
21 #define IMG_PIX_FMT_RGB565  img_fourcc('R', 'G', 'B', 'P') /* 16  RGB-5-6-5     */
22 #define IMG_PIX_FMT_RGB565X img_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 BE  */
23
24 /* Grey formats */
25 #define IMG_PIX_FMT_GREY    img_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale     */
26
27 /* Luminance+Chrominance formats */
28 #define IMG_PIX_FMT_YVU420  img_fourcc('Y', 'V', '1', '2') /* 12  YVU 4:2:0     */
29 #define IMG_PIX_FMT_YUYV    img_fourcc('Y', 'U', 'Y', 'V') /* 16  YUV 4:2:2     */
30 #define IMG_PIX_FMT_YVYU    img_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
31 #define IMG_PIX_FMT_UYVY    img_fourcc('U', 'Y', 'V', 'Y') /* 16  YUV 4:2:2     */
32 #define IMG_PIX_FMT_VYUY    img_fourcc('V', 'Y', 'U', 'Y') /* 16  YUV 4:2:2     */
33 #define IMG_PIX_FMT_YUV422P img_fourcc('4', '2', '2', 'P') /* 16  YVU422 planar */
34 #define IMG_PIX_FMT_YUV420  img_fourcc('Y', 'U', '1', '2') /* 12  YUV 4:2:0     */
35
36 /* two planes -- one Y, one Cr + Cb interleaved  */
37 #define IMG_PIX_FMT_NV12    img_fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 4:2:0  */
38 #define IMG_PIX_FMT_NV21    img_fourcc('N', 'V', '2', '1') /* 12  Y/CrCb 4:2:0  */
39
40 /* compressed formats */
41 #define IMG_PIX_FMT_JPEG     img_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG     */
42
43 #define SPRD_IMG_PATH_MAX    6
44
45 enum {
46         IMG_TX_DONE       = 0x00,
47         IMG_NO_MEM        = 0x01,
48         IMG_TX_ERR        = 0x02,
49         IMG_CSI2_ERR      = 0x03,
50         IMG_SYS_BUSY      = 0x04,
51         IMG_CANCELED_BUF  = 0x05,
52         IMG_TIMEOUT       = 0x10,
53         IMG_TX_STOP       = 0xFF
54 };
55
56 enum {
57         IMG_ENDIAN_BIG = 0,
58         IMG_ENDIAN_LITTLE,
59         IMG_ENDIAN_HALFBIG,
60         IMG_ENDIAN_HALFLITTLE,
61         IMG_ENDIAN_MAX
62 };
63
64 enum if_status {
65         IF_OPEN = 0,
66         IF_CLOSE
67 };
68
69 enum {
70         SPRD_IMG_GET_SCALE_CAP = 0,
71         SPRD_IMG_GET_FRM_BUFFER,
72         SPRD_IMG_STOP_DCAM,
73         SPRD_IMG_FREE_FRAME,
74         SPRD_IMG_GET_PATH_CAP
75 };
76
77 struct sprd_img_size {
78         uint32_t w;
79         uint32_t h;
80 };
81
82 struct sprd_img_rect {
83         uint32_t x;
84         uint32_t y;
85         uint32_t w;
86         uint32_t h;
87 };
88
89 struct sprd_img_frm_addr {
90         uint32_t y;
91         uint32_t u;
92         uint32_t v;
93 };
94
95 struct sprd_img_parm {
96         uint32_t                  channel_id;
97         uint32_t                  frame_base_id;
98         uint32_t                  pixel_fmt;
99         uint32_t                  need_isp_tool;
100         uint32_t                  deci;
101         uint32_t                  shrink;
102         uint32_t                  camera_id;
103         uint32_t                  index;
104         uint32_t                  need_isp;
105         uint32_t                  is_reserved_buf;
106         struct sprd_img_rect      crop_rect;
107         struct sprd_img_size      dst_size;
108         struct sprd_img_frm_addr  frame_addr;
109         struct sprd_img_frm_addr  frame_addr_vir;
110         uint32_t                  reserved[4];
111 };
112
113 struct sprd_img_ccir_if {
114         uint32_t v_sync_pol;
115         uint32_t h_sync_pol;
116         uint32_t pclk_pol;
117         uint32_t res1;
118         uint32_t padding;
119 };
120
121 struct sprd_img_mipi_if {
122         uint32_t use_href;
123         uint32_t bits_per_pxl;
124         uint32_t is_loose;
125         uint32_t lane_num;
126         uint32_t pclk;
127 };
128
129 struct sprd_img_sensor_if {
130         uint32_t if_type;
131         uint32_t img_fmt;
132         uint32_t img_ptn;
133         uint32_t frm_deci;
134         uint32_t res[4];
135         union {
136                 struct sprd_img_ccir_if ccir;
137                 struct sprd_img_mipi_if mipi;
138         } if_spec;
139 };
140
141 struct sprd_img_frm_info {
142         uint32_t channel_id;
143         uint32_t height;
144         uint32_t length;
145         uint32_t sec;
146         uint32_t usec;
147         uint32_t frm_base_id;
148         uint32_t index;
149         uint32_t real_index;
150         uint32_t img_fmt;
151         uint32_t yaddr;
152         uint32_t uaddr;
153         uint32_t vaddr;
154         uint32_t yaddr_vir;
155         uint32_t uaddr_vir;
156         uint32_t vaddr_vir;
157         uint32_t reserved[4];
158 };
159
160 struct sprd_img_path_info {
161         uint32_t               line_buf;
162         uint32_t               support_yuv;
163         uint32_t               support_raw;
164         uint32_t               support_jpeg;
165         uint32_t               support_scaling;
166         uint32_t               support_trim;
167         uint32_t               is_scaleing_path;;
168 };
169
170 struct sprd_img_path_capability {
171         uint32_t               count;
172         struct sprd_img_path_info  path_info[SPRD_IMG_PATH_MAX];
173 };
174
175
176 struct sprd_img_write_op {
177         uint32_t cmd;
178         uint32_t channel_id;
179         uint32_t index;
180 };
181
182 struct sprd_img_read_op {
183         uint32_t cmd;
184         uint32_t evt;
185         union {
186                 struct sprd_img_frm_info frame;
187                 struct sprd_img_path_capability capability;
188                 uint32_t reserved[20];
189         } parm;
190 };
191
192 struct sprd_img_get_fmt {
193         uint32_t index;
194         uint32_t fmt;
195 };
196
197 struct sprd_img_time {
198         uint32_t sec;
199         uint32_t usec;
200 };
201
202 struct sprd_img_format {
203         uint32_t channel_id;
204         uint32_t width;
205         uint32_t height;
206         uint32_t fourcc;
207         uint32_t need_isp;
208         uint32_t need_binning;
209         uint32_t bytesperline;
210         uint32_t is_lightly;
211         uint32_t reserved[4];
212 };
213
214 #define SPRD_IMG_IO_MAGIC            'Z'
215 #define SPRD_IMG_IO_SET_MODE          _IOW(SPRD_IMG_IO_MAGIC, 0, uint32_t)
216 #define SPRD_IMG_IO_SET_SKIP_NUM      _IOW(SPRD_IMG_IO_MAGIC, 1, uint32_t)
217 #define SPRD_IMG_IO_SET_SENSOR_SIZE   _IOW(SPRD_IMG_IO_MAGIC, 2, struct sprd_img_size)
218 #define SPRD_IMG_IO_SET_SENSOR_TRIM   _IOW(SPRD_IMG_IO_MAGIC, 3, struct sprd_img_rect)
219 #define SPRD_IMG_IO_SET_FRM_ID_BASE   _IOW(SPRD_IMG_IO_MAGIC, 4, struct sprd_img_parm)
220 #define SPRD_IMG_IO_SET_CROP          _IOW(SPRD_IMG_IO_MAGIC, 5, struct sprd_img_parm)
221 #define SPRD_IMG_IO_SET_FLASH         _IOW(SPRD_IMG_IO_MAGIC, 6, uint32_t)
222 #define SPRD_IMG_IO_SET_OUTPUT_SIZE   _IOW(SPRD_IMG_IO_MAGIC, 7, struct sprd_img_parm)
223 #define SPRD_IMG_IO_SET_ZOOM_MODE     _IOW(SPRD_IMG_IO_MAGIC, 8, uint32_t)
224 #define SPRD_IMG_IO_SET_SENSOR_IF     _IOW(SPRD_IMG_IO_MAGIC, 9, struct sprd_img_sensor_if)
225 #define SPRD_IMG_IO_SET_FRAME_ADDR    _IOW(SPRD_IMG_IO_MAGIC, 10, struct sprd_img_parm)
226 #define SPRD_IMG_IO_PATH_FRM_DECI     _IOW(SPRD_IMG_IO_MAGIC, 11, struct sprd_img_parm)
227 #define SPRD_IMG_IO_PATH_PAUSE        _IOW(SPRD_IMG_IO_MAGIC, 12, struct sprd_img_parm)
228 #define SPRD_IMG_IO_PATH_RESUME       _IOW(SPRD_IMG_IO_MAGIC, 13, uint32_t)
229 #define SPRD_IMG_IO_STREAM_ON         _IOW(SPRD_IMG_IO_MAGIC, 14, uint32_t)
230 #define SPRD_IMG_IO_STREAM_OFF        _IOW(SPRD_IMG_IO_MAGIC, 15, uint32_t)
231 #define SPRD_IMG_IO_GET_FMT           _IOR(SPRD_IMG_IO_MAGIC, 16, struct sprd_img_get_fmt)
232 #define SPRD_IMG_IO_GET_CH_ID         _IOR(SPRD_IMG_IO_MAGIC, 17, uint32_t)
233 #define SPRD_IMG_IO_GET_TIME          _IOR(SPRD_IMG_IO_MAGIC, 18, struct sprd_img_time)
234 #define SPRD_IMG_IO_CHECK_FMT         _IOWR(SPRD_IMG_IO_MAGIC, 19, struct sprd_img_format)
235 #define SPRD_IMG_IO_SET_SHRINK        _IOW(SPRD_IMG_IO_MAGIC, 20, uint32_t)
236
237 #endif //_SPRD_V4L2_H_