blob: 2a2a53db4b917f4ea14ce1317dfaaad2e145037e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * video.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _DVBVIDEO_H_
25#define _DVBVIDEO_H_
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/types.h>
Jaswinder Singh Rajputb852d362009-01-30 19:59:53 +053028#ifdef __KERNEL__
29#include <linux/compiler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#else
31#include <stdint.h>
32#include <time.h>
33#endif
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035typedef enum {
36 VIDEO_FORMAT_4_3, /* Select 4:3 format */
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080037 VIDEO_FORMAT_16_9, /* Select 16:9 format. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 VIDEO_FORMAT_221_1 /* 2.21:1 */
39} video_format_t;
40
41
42typedef enum {
43 VIDEO_SYSTEM_PAL,
44 VIDEO_SYSTEM_NTSC,
45 VIDEO_SYSTEM_PALN,
46 VIDEO_SYSTEM_PALNc,
47 VIDEO_SYSTEM_PALM,
48 VIDEO_SYSTEM_NTSC60,
49 VIDEO_SYSTEM_PAL60,
50 VIDEO_SYSTEM_PALM60
51} video_system_t;
52
53
54typedef enum {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080055 VIDEO_PAN_SCAN, /* use pan and scan format */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 VIDEO_LETTER_BOX, /* use letterbox format */
57 VIDEO_CENTER_CUT_OUT /* use center cut out format */
58} video_displayformat_t;
59
Ananda Kishore9d84f1d2012-06-13 14:34:49 +053060enum video_codec_t {
61 VIDEO_CODECTYPE_NONE,
62 VIDEO_CODECTYPE_MPEG2,
63 VIDEO_CODECTYPE_MPEG4,
64 VIDEO_CODECTYPE_H264,
65 VIDEO_CODECTYPE_VC1
66};
67
68enum video_out_format_t {
69 VIDEO_YUV_FORMAT_NV12,
70 VIDEO_YUV_FORMAT_TILE_4x2
71};
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073typedef struct {
74 int w;
75 int h;
76 video_format_t aspect_ratio;
77} video_size_t;
78
79typedef enum {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080080 VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 VIDEO_SOURCE_MEMORY /* If this source is selected, the stream
82 comes from the user through the write
83 system call */
84} video_stream_source_t;
85
86
87typedef enum {
88 VIDEO_STOPPED, /* Video is stopped */
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080089 VIDEO_PLAYING, /* Video is currently playing */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 VIDEO_FREEZED /* Video is freezed */
91} video_play_state_t;
92
93
Hans Verkuil2435be12007-04-27 12:31:09 -030094/* Decoder commands */
95#define VIDEO_CMD_PLAY (0)
96#define VIDEO_CMD_STOP (1)
97#define VIDEO_CMD_FREEZE (2)
98#define VIDEO_CMD_CONTINUE (3)
99
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530100#define VIDEO_CMD_SET_CODEC (4)
101#define VIDEO_CMD_GET_CODEC (5)
102#define VIDEO_CMD_SET_OUTPUT_FORMAT (6)
103#define VIDEO_CMD_GET_OUTPUT_FORMAT (7)
104#define VIDEO_CMD_GET_BUFFER_REQ (8)
105#define VIDEO_CMD_SET_INPUT_BUFFERS (9)
106#define VIDEO_CMD_SET_OUTPUT_BUFFERS (10)
107#define VIDEO_CMD_READ_RAW_OUTPUT (11)
108#define VIDEO_CMD_GET_PIC_RES (12)
109#define VIDEO_CMD_FREE_INPUT_BUFFERS (13)
110#define VIDEO_CMD_FREE_OUTPUT_BUFFERS (14)
111#define VIDEO_CMD_GET_H264_MV_BUFFER (15)
112#define VIDEO_CMD_SET_H264_MV_BUFFER (16)
113#define VIDEO_CMD_FREE_H264_MV_BUFFER (17)
114#define VIDEO_CMD_CLEAR_INPUT_BUFFER (18)
115#define VIDEO_CMD_CLEAR_OUTPUT_BUFFER (19)
Ananda Kishoree67e2632012-10-19 12:12:20 +0530116#define VIDEO_CMD_SET_BUFFER_COUNT (20)
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530117
Hans Verkuil2435be12007-04-27 12:31:09 -0300118/* Flags for VIDEO_CMD_FREEZE */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530119#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
Hans Verkuil2435be12007-04-27 12:31:09 -0300120
121/* Flags for VIDEO_CMD_STOP */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530122#define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
123#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
Hans Verkuil2435be12007-04-27 12:31:09 -0300124
125/* Play input formats: */
126/* The decoder has no special format requirements */
127#define VIDEO_PLAY_FMT_NONE (0)
128/* The decoder requires full GOPs */
129#define VIDEO_PLAY_FMT_GOP (1)
130
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530131/* Picture Resolution for Video Data */
132struct video_pic_res {
133 unsigned int width;
134 unsigned int height;
135 unsigned int stride;
136 unsigned int scan_lines;
137};
138
139/* Video Buffer Properties */
140struct video_buffer_prop {
141 unsigned int alignment;
142 unsigned int buf_poolid;
143 size_t buf_size;
144};
145
146/* Buffer Requirements from Video Decoder */
147struct video_buffer_req {
148 unsigned int num_input_buffers; /* Number of Input Buffers */
149 unsigned int num_output_buffers; /* Number of Output Buffers */
150 struct video_buffer_prop input_buf_prop; /* Input Buffer Properties */
151 struct video_buffer_prop output_buf_prop; /* Output Buffer Prop */
152};
153
154/* Video Data Buffer Structure for Input and Output */
155struct video_data_buffer {
156 void __user *bufferaddr; /* Pointer to Buffer */
157 size_t buffer_len; /* Length of Buffer */
158 int ion_fd; /* file Descriptor */
159 size_t offset;
160 size_t mmaped_size;
161 void *client_data;
162 void *ip_buffer_tag;
163 __u64 pts;
164};
165
166struct video_h264_mv {
167 size_t size;
168 int count;
169 int ion_fd;
170 int offset;
171};
172
173struct video_mv_buff_size {
174 int width;
175 int height;
176 int size;
177 int alignment;
178};
179
180
Hans Verkuil2435be12007-04-27 12:31:09 -0300181/* The structure must be zeroed before use by the application
182 This ensures it can be extended safely in the future. */
183struct video_command {
184 __u32 cmd;
185 __u32 flags;
186 union {
187 struct {
188 __u64 pts;
189 } stop;
190
191 struct {
Hans Verkuil6816b192007-03-11 10:54:11 -0300192 /* 0 or 1000 specifies normal speed,
193 1 specifies forward single stepping,
194 -1 specifies backward single stepping,
195 >1: playback at speed/1000 of the normal speed,
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530196 <-1: reverse playback at (-speed/1000) of
197 the normal speed. */
Hans Verkuil3700a902007-03-11 10:50:03 -0300198 __s32 speed;
Hans Verkuil2435be12007-04-27 12:31:09 -0300199 __u32 format;
200 } play;
201
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530202 union {
203 enum video_codec_t codec; /* Video Codec Type */
204 enum video_out_format_t format; /* YUV Format */
205 struct video_pic_res frame_res; /* Frame Resolution */
206 /* Buffer Requirements for Video Decoder */
207 struct video_buffer_req buf_req;
208 struct video_data_buffer buffer; /* Buffer Details */
209 struct video_mv_buff_size mv_buffer_req;
210 struct video_h264_mv mv_buffer_prop;
211 };
212
Hans Verkuil2435be12007-04-27 12:31:09 -0300213 struct {
214 __u32 data[16];
215 } raw;
216 };
217};
218
Hans Verkuil43d0dfc2007-03-10 06:24:30 -0300219/* FIELD_UNKNOWN can be used if the hardware does not know whether
220 the Vsync is for an odd, even or progressive (i.e. non-interlaced)
221 field. */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530222#define VIDEO_VSYNC_FIELD_UNKNOWN (0)
223#define VIDEO_VSYNC_FIELD_ODD (1)
Hans Verkuil43d0dfc2007-03-10 06:24:30 -0300224#define VIDEO_VSYNC_FIELD_EVEN (2)
225#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
Hans Verkuil2435be12007-04-27 12:31:09 -0300226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227struct video_event {
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100228 __s32 type;
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530229#define VIDEO_EVENT_SIZE_CHANGED (1)
230#define VIDEO_EVENT_FRAME_RATE_CHANGED (2)
231#define VIDEO_EVENT_DECODER_STOPPED (3)
232#define VIDEO_EVENT_VSYNC (4)
233#define VIDEO_EVENT_DECODER_PLAYING (5)
234#define VIDEO_EVENT_DECODER_FREEZED (6)
235#define VIDEO_EVENT_DECODER_RESUMED (7)
236#define VIDEO_EVENT_INPUT_BUFFER_DONE (8)
237#define VIDEO_EVENT_SEQ_HDR_FOUND (9)
238#define VIDEO_EVENT_OUTPUT_BUFFER_DONE (10)
239#define VIDEO_EVENT_OUTPUT_FLUSH_DONE (11)
240#define VIDEO_EVENT_INPUT_FLUSH_DONE (12)
241#define VIDEO_EVENT_INPUT_FLUSHED (13)
242#define VIDEO_EVENT_OUTPUT_FLUSHED (14)
243
244
245 unsigned int status;
246#define VIDEO_STATUS_SUCESS 0
247#define VIDEO_STATUS_BITSTREAM_ERROR 1
248#define VIDEO_STATUS_FAILED 2
249#define VIDEO_STATUS_NORESOURCE 3
250#define VIDEO_STATUS_INVALID_CMD 4
251#define VIDEO_STATUS_INVALID_PARAM 5
252#define VIDEO_STATUS_INVALID_STATE 6
253#define VIDEO_STATUS_BUSY 7
254#define VIDEO_STATUS_INVALID_HANDLE 8
255#define VIDEO_STATUS_NO_SUPPORT 9
Arnd Bergmann85efde62009-02-26 00:51:39 +0100256 __kernel_time_t timestamp;
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 union {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800259 video_size_t size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 unsigned int frame_rate; /* in frames per 1000sec */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530261 unsigned char vsync_field; /* unknown/odd/even/progressive */
262 struct video_data_buffer buffer; /* Output Buffer Details */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 } u;
264};
265
266
267struct video_status {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800268 int video_blank; /* blank video on freeze? */
269 video_play_state_t play_state; /* current state of playback */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530270 video_stream_source_t stream_source;/* current source (demux/memory) */
271 video_format_t video_format; /* current aspect ratio of stream*/
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800272 video_displayformat_t display_format;/* selected cropping mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273};
274
275
276struct video_still_picture {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800277 char __user *iFrame; /* pointer to a single iframe in memory */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100278 __s32 size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279};
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281typedef
282struct video_highlight {
283 int active; /* 1=show highlight, 0=hide highlight */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100284 __u8 contrast1; /* 7- 4 Pattern pixel contrast */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800285 /* 3- 0 Background pixel contrast */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100286 __u8 contrast2; /* 7- 4 Emphasis pixel-2 contrast */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800287 /* 3- 0 Emphasis pixel-1 contrast */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100288 __u8 color1; /* 7- 4 Pattern pixel color */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800289 /* 3- 0 Background pixel color */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100290 __u8 color2; /* 7- 4 Emphasis pixel-2 color */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800291 /* 3- 0 Emphasis pixel-1 color */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100292 __u32 ypos; /* 23-22 auto action mode */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800293 /* 21-12 start y */
294 /* 9- 0 end y */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100295 __u32 xpos; /* 23-22 button color number */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800296 /* 21-12 start x */
297 /* 9- 0 end x */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298} video_highlight_t;
299
300
301typedef struct video_spu {
302 int active;
303 int stream_id;
304} video_spu_t;
305
306
307typedef struct video_spu_palette { /* SPU Palette information */
308 int length;
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100309 __u8 __user *palette;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310} video_spu_palette_t;
311
312
313typedef struct video_navi_pack {
314 int length; /* 0 ... 1024 */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100315 __u8 data[1024];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316} video_navi_pack_t;
317
318
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100319typedef __u16 video_attributes_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320/* bits: descr. */
321/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
322/* 13-12 TV system (0=525/60, 1=625/50) */
323/* 11-10 Aspect ratio (0=4:3, 3=16:9) */
324/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
325/* 7 line 21-1 data present in GOP (1=yes, 0=no) */
326/* 6 line 21-2 data present in GOP (1=yes, 0=no) */
327/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
328/* 2 source letterboxed (1=yes, 0=no) */
329/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */
330
331
332/* bit definitions for capabilities: */
333/* can the hardware decode MPEG1 and/or MPEG2? */
334#define VIDEO_CAP_MPEG1 1
335#define VIDEO_CAP_MPEG2 2
336/* can you send a system and/or program stream to video device?
337 (you still have to open the video and the audio device but only
338 send the stream to the video device) */
339#define VIDEO_CAP_SYS 4
340#define VIDEO_CAP_PROG 8
341/* can the driver also handle SPU, NAVI and CSS encoded data?
342 (CSS API is not present yet) */
343#define VIDEO_CAP_SPU 16
344#define VIDEO_CAP_NAVI 32
345#define VIDEO_CAP_CSS 64
346
347
348#define VIDEO_STOP _IO('o', 21)
349#define VIDEO_PLAY _IO('o', 22)
350#define VIDEO_FREEZE _IO('o', 23)
351#define VIDEO_CONTINUE _IO('o', 24)
352#define VIDEO_SELECT_SOURCE _IO('o', 25)
353#define VIDEO_SET_BLANK _IO('o', 26)
354#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
355#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
356#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
357#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
358#define VIDEO_FAST_FORWARD _IO('o', 31)
359#define VIDEO_SLOWMOTION _IO('o', 32)
360#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
361#define VIDEO_CLEAR_BUFFER _IO('o', 34)
362#define VIDEO_SET_ID _IO('o', 35)
363#define VIDEO_SET_STREAMTYPE _IO('o', 36)
364#define VIDEO_SET_FORMAT _IO('o', 37)
365#define VIDEO_SET_SYSTEM _IO('o', 38)
366#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
367#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
368#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
369#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
370#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
371#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
372#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
373
Andreas Oberritterf05cce82006-02-27 00:09:00 -0300374/**
375 * VIDEO_GET_PTS
376 *
377 * Read the 33 bit presentation time stamp as defined
378 * in ITU T-REC-H.222.0 / ISO/IEC 13818-1.
379 *
380 * The PTS should belong to the currently played
381 * frame if possible, but may also be a value close to it
382 * like the PTS of the last decoded frame or the last PTS
383 * extracted by the PES parser.
384 */
385#define VIDEO_GET_PTS _IOR('o', 57, __u64)
386
Hans Verkuil2435be12007-04-27 12:31:09 -0300387/* Read the number of displayed frames since the decoder was started */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530388#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
Hans Verkuil2435be12007-04-27 12:31:09 -0300389
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530390#define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
391#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
Hans Verkuil2435be12007-04-27 12:31:09 -0300392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393#endif /*_DVBVIDEO_H_*/