summaryrefslogtreecommitdiff
path: root/include/video/sprd_img.h
blob: 28bf963d9c7dfec0211885f58c6d11b2d4f70995 (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
 * Copyright (C) 2012 Spreadtrum Communications Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef _SPRD_IMG_H_
#define _SPRD_IMG_H_

/*  Four-character-code (FOURCC) */
#define img_fourcc(a, b, c, d)\
	((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))

/* RGB formats */
#define IMG_PIX_FMT_RGB565  img_fourcc('R', 'G', 'B', 'P') /* 16  RGB-5-6-5     */
#define IMG_PIX_FMT_RGB565X img_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 BE  */

/* Grey formats */
#define IMG_PIX_FMT_GREY    img_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale     */

/* Luminance+Chrominance formats */
#define IMG_PIX_FMT_YVU420  img_fourcc('Y', 'V', '1', '2') /* 12  YVU 4:2:0     */
#define IMG_PIX_FMT_YUYV    img_fourcc('Y', 'U', 'Y', 'V') /* 16  YUV 4:2:2     */
#define IMG_PIX_FMT_YVYU    img_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
#define IMG_PIX_FMT_UYVY    img_fourcc('U', 'Y', 'V', 'Y') /* 16  YUV 4:2:2     */
#define IMG_PIX_FMT_VYUY    img_fourcc('V', 'Y', 'U', 'Y') /* 16  YUV 4:2:2     */
#define IMG_PIX_FMT_YUV422P img_fourcc('4', '2', '2', 'P') /* 16  YVU422 planar */
#define IMG_PIX_FMT_YUV420  img_fourcc('Y', 'U', '1', '2') /* 12  YUV 4:2:0     */

/* two planes -- one Y, one Cr + Cb interleaved  */
#define IMG_PIX_FMT_NV12    img_fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 4:2:0  */
#define IMG_PIX_FMT_NV21    img_fourcc('N', 'V', '2', '1') /* 12  Y/CrCb 4:2:0  */

/* compressed formats */
#define IMG_PIX_FMT_JPEG     img_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG     */

#define SPRD_IMG_PATH_MAX    6

enum {
	IMG_TX_DONE       = 0x00,
	IMG_NO_MEM        = 0x01,
	IMG_TX_ERR        = 0x02,
	IMG_CSI2_ERR      = 0x03,
	IMG_SYS_BUSY      = 0x04,
	IMG_CANCELED_BUF  = 0x05,
	IMG_TIMEOUT       = 0x10,
	IMG_TX_STOP       = 0xFF
};

enum {
	IMG_ENDIAN_BIG = 0,
	IMG_ENDIAN_LITTLE,
	IMG_ENDIAN_HALFBIG,
	IMG_ENDIAN_HALFLITTLE,
	IMG_ENDIAN_MAX
};

enum if_status {
	IF_OPEN = 0,
	IF_CLOSE
};

enum {
	SPRD_IMG_GET_SCALE_CAP = 0,
	SPRD_IMG_GET_FRM_BUFFER,
	SPRD_IMG_STOP_DCAM,
	SPRD_IMG_FREE_FRAME,
	SPRD_IMG_GET_PATH_CAP
};

struct sprd_img_size {
	uint32_t w;
	uint32_t h;
};

struct sprd_img_rect {
	uint32_t x;
	uint32_t y;
	uint32_t w;
	uint32_t h;
};

struct sprd_img_frm_addr {
	uint32_t y;
	uint32_t u;
	uint32_t v;
};

struct sprd_img_parm {
	uint32_t                  channel_id;
	uint32_t                  frame_base_id;
	uint32_t                  pixel_fmt;
	uint32_t                  need_isp_tool;
	uint32_t                  deci;
	uint32_t                  shrink;
	uint32_t                  index;
	uint32_t                  need_isp;
	uint32_t                  is_reserved_buf;
	struct sprd_img_rect      crop_rect;
	struct sprd_img_size      dst_size;
	struct sprd_img_frm_addr  frame_addr;
	struct sprd_img_frm_addr  frame_addr_vir;
	uint32_t                  reserved[4];
};

struct sprd_img_ccir_if {
	uint32_t v_sync_pol;
	uint32_t h_sync_pol;
	uint32_t pclk_pol;
	uint32_t res1;
	uint32_t padding;
};

struct sprd_img_mipi_if {
	uint32_t use_href;
	uint32_t bits_per_pxl;
	uint32_t is_loose;
	uint32_t lane_num;
	uint32_t pclk;
};

struct sprd_img_sensor_if {
	uint32_t if_type;
	uint32_t img_fmt;
	uint32_t img_ptn;
	uint32_t frm_deci;
	uint32_t res[4];
	union {
		struct sprd_img_ccir_if ccir;
		struct sprd_img_mipi_if mipi;
	} if_spec;
};

struct sprd_img_frm_info {
	uint32_t channel_id;
	uint32_t height;
	uint32_t length;
	uint32_t sec;
	uint32_t usec;
	uint32_t frm_base_id;
	uint32_t index;
	uint32_t real_index;
	uint32_t img_fmt;
	uint32_t yaddr;
	uint32_t uaddr;
	uint32_t vaddr;
	uint32_t yaddr_vir;
	uint32_t uaddr_vir;
	uint32_t vaddr_vir;
	uint32_t reserved[4];
};

struct sprd_img_path_info {
	uint32_t               line_buf;
	uint32_t               support_yuv;
	uint32_t               support_raw;
	uint32_t               support_jpeg;
	uint32_t               support_scaling;
	uint32_t               support_trim;
	uint32_t               is_scaleing_path;;
};

struct sprd_img_path_capability {
	uint32_t               count;
	struct sprd_img_path_info  path_info[SPRD_IMG_PATH_MAX];
};


struct sprd_img_write_op {
	uint32_t cmd;
	uint32_t channel_id;
	uint32_t index;
};

struct sprd_img_read_op {
	uint32_t cmd;
	uint32_t evt;
	union {
		struct sprd_img_frm_info frame;
		struct sprd_img_path_capability capability;
		uint32_t reserved[20];
	} parm;
};

struct sprd_img_get_fmt {
	uint32_t index;
	uint32_t fmt;
};

struct sprd_img_time {
	uint32_t sec;
	uint32_t usec;
};

struct sprd_img_format {
	uint32_t channel_id;
	uint32_t width;
	uint32_t height;
	uint32_t fourcc;
	uint32_t need_isp;
	uint32_t need_binning;
	uint32_t bytesperline;
	uint32_t is_lightly;
	uint32_t reserved[4];
};

#define SPRD_IMG_IO_MAGIC            'Z'
#define SPRD_IMG_IO_SET_MODE          _IOW(SPRD_IMG_IO_MAGIC, 0, uint32_t)
#define SPRD_IMG_IO_SET_SKIP_NUM      _IOW(SPRD_IMG_IO_MAGIC, 1, uint32_t)
#define SPRD_IMG_IO_SET_SENSOR_SIZE   _IOW(SPRD_IMG_IO_MAGIC, 2, struct sprd_img_size)
#define SPRD_IMG_IO_SET_SENSOR_TRIM   _IOW(SPRD_IMG_IO_MAGIC, 3, struct sprd_img_rect)
#define SPRD_IMG_IO_SET_FRM_ID_BASE   _IOW(SPRD_IMG_IO_MAGIC, 4, struct sprd_img_parm)
#define SPRD_IMG_IO_SET_CROP          _IOW(SPRD_IMG_IO_MAGIC, 5, struct sprd_img_parm)
#define SPRD_IMG_IO_SET_FLASH         _IOW(SPRD_IMG_IO_MAGIC, 6, uint32_t)
#define SPRD_IMG_IO_SET_OUTPUT_SIZE   _IOW(SPRD_IMG_IO_MAGIC, 7, struct sprd_img_parm)
#define SPRD_IMG_IO_SET_ZOOM_MODE     _IOW(SPRD_IMG_IO_MAGIC, 8, uint32_t)
#define SPRD_IMG_IO_SET_SENSOR_IF     _IOW(SPRD_IMG_IO_MAGIC, 9, struct sprd_img_sensor_if)
#define SPRD_IMG_IO_SET_FRAME_ADDR    _IOW(SPRD_IMG_IO_MAGIC, 10, struct sprd_img_parm)
#define SPRD_IMG_IO_PATH_FRM_DECI     _IOW(SPRD_IMG_IO_MAGIC, 11, struct sprd_img_parm)
#define SPRD_IMG_IO_PATH_PAUSE        _IOW(SPRD_IMG_IO_MAGIC, 12, struct sprd_img_parm)
#define SPRD_IMG_IO_PATH_RESUME       _IOW(SPRD_IMG_IO_MAGIC, 13, uint32_t)
#define SPRD_IMG_IO_STREAM_ON         _IOW(SPRD_IMG_IO_MAGIC, 14, uint32_t)
#define SPRD_IMG_IO_STREAM_OFF        _IOW(SPRD_IMG_IO_MAGIC, 15, uint32_t)
#define SPRD_IMG_IO_GET_FMT           _IOR(SPRD_IMG_IO_MAGIC, 16, struct sprd_img_get_fmt)
#define SPRD_IMG_IO_GET_CH_ID         _IOR(SPRD_IMG_IO_MAGIC, 17, uint32_t)
#define SPRD_IMG_IO_GET_TIME          _IOR(SPRD_IMG_IO_MAGIC, 18, struct sprd_img_time)
#define SPRD_IMG_IO_CHECK_FMT         _IOWR(SPRD_IMG_IO_MAGIC, 19, struct sprd_img_format)
#define SPRD_IMG_IO_SET_SHRINK        _IOW(SPRD_IMG_IO_MAGIC, 20, uint32_t)
#define SPRD_IMG_IO_SET_FREQ_FLAG     _IOW(SPRD_IMG_IO_MAGIC, 21, uint32_t)

/*
Dump dcam register.
buf:      input dump buffer addr
buf_len:  input dump buffer size(>=0x400), and buf_len=0x400 is ok
return    real dump size
*/
int32_t sprd_dcam_registers_dump(void *buf, uint32_t buf_len);
#endif //_SPRD_V4L2_H_