• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5  *     * Redistributions of source code must retain the above copyright
6  *       notice, this list of conditions and the following disclaimer.
7  *     * Redistributions in binary form must reproduce the above copyright
8  *       notice, this list of conditions and the following disclaimer in the
9  *       documentation and/or other materials provided with the distribution.
10  *     * Neither the name of Code Aurora nor
11  *       the names of its contributors may be used to endorse or promote
12  *       products derived from this software without specific prior written
13  *       permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _MSM_VENC_H_
30 #define _MSM_VENC_H_
31 
32 #include <linux/types.h>
33 
34 #define VENC_MAX_RECON_BUFFERS 2
35 
36 #define VENC_FLAG_EOS                   0x00000001
37 #define VENC_FLAG_END_OF_FRAME          0x00000010
38 #define VENC_FLAG_SYNC_FRAME            0x00000020
39 #define VENC_FLAG_EXTRA_DATA            0x00000040
40 #define VENC_FLAG_CODEC_CONFIG          0x00000080
41 
42 enum venc_flush_type {
43 	VENC_FLUSH_INPUT,
44 	VENC_FLUSH_OUTPUT,
45 	VENC_FLUSH_ALL
46 };
47 
48 enum venc_state_type {
49 	VENC_STATE_PAUSE = 0x1,
50 	VENC_STATE_START = 0x2,
51 	VENC_STATE_STOP = 0x4
52 };
53 
54 enum venc_event_type_enum {
55 	VENC_EVENT_START_STATUS,
56 	VENC_EVENT_STOP_STATUS,
57 	VENC_EVENT_SUSPEND_STATUS,
58 	VENC_EVENT_RESUME_STATUS,
59 	VENC_EVENT_FLUSH_STATUS,
60 	VENC_EVENT_RELEASE_INPUT,
61 	VENC_EVENT_DELIVER_OUTPUT,
62 	VENC_EVENT_UNKNOWN_STATUS
63 };
64 
65 enum venc_status_code {
66 	VENC_STATUS_SUCCESS,
67 	VENC_STATUS_ERROR,
68 	VENC_STATUS_INVALID_STATE,
69 	VENC_STATUS_FLUSHING,
70 	VENC_STATUS_INVALID_PARAM,
71 	VENC_STATUS_CMD_QUEUE_FULL,
72 	VENC_STATUS_CRITICAL,
73 	VENC_STATUS_INSUFFICIENT_RESOURCES,
74 	VENC_STATUS_TIMEOUT
75 };
76 
77 enum venc_msg_code {
78 	VENC_MSG_INDICATION,
79 	VENC_MSG_INPUT_BUFFER_DONE,
80 	VENC_MSG_OUTPUT_BUFFER_DONE,
81 	VENC_MSG_NEED_OUTPUT_BUFFER,
82 	VENC_MSG_FLUSH,
83 	VENC_MSG_START,
84 	VENC_MSG_STOP,
85 	VENC_MSG_PAUSE,
86 	VENC_MSG_RESUME,
87 	VENC_MSG_STOP_READING_MSG
88 };
89 
90 enum venc_error_code {
91 	VENC_S_SUCCESS,
92 	VENC_S_EFAIL,
93 	VENC_S_EFATAL,
94 	VENC_S_EBADPARAM,
95 	VENC_S_EINVALSTATE,
96 	VENC_S_ENOSWRES,
97 	VENC_S_ENOHWRES,
98 	VENC_S_EBUFFREQ,
99 	VENC_S_EINVALCMD,
100 	VENC_S_ETIMEOUT,
101 	VENC_S_ENOREATMPT,
102 	VENC_S_ENOPREREQ,
103 	VENC_S_ECMDQFULL,
104 	VENC_S_ENOTSUPP,
105 	VENC_S_ENOTIMPL,
106 	VENC_S_ENOTPMEM,
107 	VENC_S_EFLUSHED,
108 	VENC_S_EINSUFBUF,
109 	VENC_S_ESAMESTATE,
110 	VENC_S_EINVALTRANS
111 };
112 
113 enum venc_mem_region_enum {
114 	VENC_PMEM_EBI1,
115 	VENC_PMEM_SMI
116 };
117 
118 struct venc_buf_type {
119 	unsigned int region;
120 	unsigned int phys;
121 	unsigned int size;
122 	int offset;
123 };
124 
125 struct venc_qp_range {
126 	unsigned int min_qp;
127 	unsigned int max_qp;
128 };
129 
130 struct venc_frame_rate {
131 	unsigned int frame_rate_num;
132 	unsigned int frame_rate_den;
133 };
134 
135 struct venc_slice_info {
136 	unsigned int slice_mode;
137 	unsigned int units_per_slice;
138 };
139 
140 struct venc_extra_data {
141 	unsigned int slice_extra_data_flag;
142 	unsigned int slice_client_data1;
143 	unsigned int slice_client_data2;
144 	unsigned int slice_client_data3;
145 	unsigned int none_extra_data_flag;
146 	unsigned int none_client_data1;
147 	unsigned int none_client_data2;
148 	unsigned int none_client_data3;
149 };
150 
151 struct venc_common_config {
152 	unsigned int standard;
153 	unsigned int input_frame_height;
154 	unsigned int input_frame_width;
155 	unsigned int output_frame_height;
156 	unsigned int output_frame_width;
157 	unsigned int rotation_angle;
158 	unsigned int intra_period;
159 	unsigned int rate_control;
160 	struct venc_frame_rate frame_rate;
161 	unsigned int bitrate;
162 	struct venc_qp_range qp_range;
163 	unsigned int iframe_qp;
164 	unsigned int pframe_qp;
165 	struct venc_slice_info slice_config;
166 	struct venc_extra_data extra_data;
167 };
168 
169 struct venc_nonio_buf_config {
170 	struct venc_buf_type recon_buf1;
171 	struct venc_buf_type recon_buf2;
172 	struct venc_buf_type wb_buf;
173 	struct venc_buf_type cmd_buf;
174 	struct venc_buf_type vlc_buf;
175 };
176 
177 struct venc_mpeg4_config {
178 	unsigned int profile;
179 	unsigned int level;
180 	unsigned int time_resolution;
181 	unsigned int ac_prediction;
182 	unsigned int hec_interval;
183 	unsigned int data_partition;
184 	unsigned int short_header;
185 	unsigned int rvlc_enable;
186 };
187 
188 struct venc_h263_config {
189 	unsigned int profile;
190 	unsigned int level;
191 };
192 
193 struct venc_h264_config {
194 	unsigned int profile;
195 	unsigned int level;
196 	unsigned int max_nal;
197 	unsigned int idr_period;
198 };
199 
200 struct venc_pmem {
201 	int src;
202 	int fd;
203 	unsigned int offset;
204 	void *virt;
205 	void *phys;
206 	unsigned int size;
207 };
208 
209 struct venc_buffer {
210 	unsigned char *ptr_buffer;
211 	unsigned int size;
212 	unsigned int len;
213 	unsigned int offset;
214 	long long time_stamp;
215 	unsigned int flags;
216 	unsigned int client_data;
217 };
218 
219 struct venc_buffers {
220 	struct venc_pmem recon_buf[VENC_MAX_RECON_BUFFERS];
221 	struct venc_pmem wb_buf;
222 	struct venc_pmem cmd_buf;
223 	struct venc_pmem vlc_buf;
224 };
225 
226 struct venc_buffer_flush {
227 	unsigned int flush_mode;
228 };
229 
230 union venc_msg_data {
231 	struct venc_buffer buf;
232 	struct venc_buffer_flush flush_ret;
233 };
234 
235 struct venc_msg {
236 	unsigned int status_code;
237 	unsigned int msg_code;
238 	union venc_msg_data msg_data;
239 	unsigned int msg_data_size;
240 };
241 
242 union venc_codec_config {
243 	struct venc_mpeg4_config mpeg4_params;
244 	struct venc_h263_config h263_params;
245 	struct venc_h264_config h264_params;
246 };
247 
248 struct venc_q6_config {
249 	struct venc_common_config config_params;
250 	union venc_codec_config codec_params;
251 	struct venc_nonio_buf_config buf_params;
252 	void *callback_event;
253 };
254 
255 struct venc_hdr_config {
256 	struct venc_common_config config_params;
257 	union venc_codec_config codec_params;
258 };
259 
260 struct venc_init_config {
261 	struct venc_q6_config q6_config;
262 	struct venc_buffers q6_bufs;
263 };
264 
265 struct venc_seq_config {
266 	int size;
267 	struct venc_pmem buf;
268 	struct venc_q6_config q6_config;
269 };
270 
271 #define VENC_IOCTL_MAGIC 'V'
272 
273 #define VENC_IOCTL_CMD_READ_NEXT_MSG \
274 	_IOWR(VENC_IOCTL_MAGIC, 1, struct venc_msg)
275 
276 #define VENC_IOCTL_CMD_STOP_READ_MSG  _IO(VENC_IOCTL_MAGIC, 2)
277 
278 #define VENC_IOCTL_SET_INPUT_BUFFER \
279 	_IOW(VENC_IOCTL_MAGIC, 3, struct venc_pmem)
280 
281 #define VENC_IOCTL_SET_OUTPUT_BUFFER \
282 	_IOW(VENC_IOCTL_MAGIC, 4, struct venc_pmem)
283 
284 #define VENC_IOCTL_CMD_START _IOW(VENC_IOCTL_MAGIC, 5, struct venc_init_config)
285 
286 #define VENC_IOCTL_CMD_ENCODE_FRAME \
287 	_IOW(VENC_IOCTL_MAGIC, 6, struct venc_buffer)
288 
289 #define VENC_IOCTL_CMD_FILL_OUTPUT_BUFFER \
290 	_IOW(VENC_IOCTL_MAGIC, 7, struct venc_buffer)
291 
292 #define VENC_IOCTL_CMD_FLUSH \
293 	_IOW(VENC_IOCTL_MAGIC, 8, struct venc_buffer_flush)
294 
295 #define VENC_IOCTL_CMD_PAUSE _IO(VENC_IOCTL_MAGIC, 9)
296 
297 #define VENC_IOCTL_CMD_RESUME _IO(VENC_IOCTL_MAGIC, 10)
298 
299 #define VENC_IOCTL_CMD_STOP _IO(VENC_IOCTL_MAGIC, 11)
300 
301 #define VENC_IOCTL_SET_INTRA_PERIOD \
302 	_IOW(VENC_IOCTL_MAGIC, 12, int)
303 
304 #define VENC_IOCTL_CMD_REQUEST_IFRAME _IO(VENC_IOCTL_MAGIC, 13)
305 
306 #define VENC_IOCTL_GET_SEQUENCE_HDR \
307 	_IOWR(VENC_IOCTL_MAGIC, 14, struct venc_seq_config)
308 
309 #define VENC_IOCTL_SET_INTRA_REFRESH \
310 	_IOW(VENC_IOCTL_MAGIC, 15, int)
311 
312 #define VENC_IOCTL_SET_FRAME_RATE \
313 	_IOW(VENC_IOCTL_MAGIC, 16, struct venc_frame_rate)
314 
315 #define VENC_IOCTL_SET_TARGET_BITRATE \
316 	_IOW(VENC_IOCTL_MAGIC, 17, int)
317 
318 #define VENC_IOCTL_SET_QP_RANGE \
319 	_IOW(VENC_IOCTL_MAGIC, 18, struct venc_qp_range)
320 
321 #endif
322