blob: 6c42099ab87c6c3240d9a2dfdf399dba43cbbce0 [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
Ananda Kishore73e27722012-10-23 16:19:44 +0530154enum scan_format {
155 INTERLACE_FRAME_PROGRESSIVE,
156 INTERLACE_INTERLEAVE_FRAME_TOP_FIELD_FIRST,
157 INTERLACE_INTERLEAVE_FRAME_BOTTOM_FIELD_FIRST
158};
159
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530160/* Video Data Buffer Structure for Input and Output */
161struct video_data_buffer {
162 void __user *bufferaddr; /* Pointer to Buffer */
163 size_t buffer_len; /* Length of Buffer */
164 int ion_fd; /* file Descriptor */
165 size_t offset;
166 size_t mmaped_size;
167 void *client_data;
168 void *ip_buffer_tag;
169 __u64 pts;
Ananda Kishore73e27722012-10-23 16:19:44 +0530170 enum scan_format interlaced_format;
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530171};
172
173struct video_h264_mv {
174 size_t size;
175 int count;
176 int ion_fd;
177 int offset;
178};
179
180struct video_mv_buff_size {
181 int width;
182 int height;
183 int size;
184 int alignment;
185};
186
187
Hans Verkuil2435be12007-04-27 12:31:09 -0300188/* The structure must be zeroed before use by the application
189 This ensures it can be extended safely in the future. */
190struct video_command {
191 __u32 cmd;
192 __u32 flags;
193 union {
194 struct {
195 __u64 pts;
196 } stop;
197
198 struct {
Hans Verkuil6816b192007-03-11 10:54:11 -0300199 /* 0 or 1000 specifies normal speed,
200 1 specifies forward single stepping,
201 -1 specifies backward single stepping,
202 >1: playback at speed/1000 of the normal speed,
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530203 <-1: reverse playback at (-speed/1000) of
204 the normal speed. */
Hans Verkuil3700a902007-03-11 10:50:03 -0300205 __s32 speed;
Hans Verkuil2435be12007-04-27 12:31:09 -0300206 __u32 format;
207 } play;
208
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530209 union {
210 enum video_codec_t codec; /* Video Codec Type */
211 enum video_out_format_t format; /* YUV Format */
212 struct video_pic_res frame_res; /* Frame Resolution */
213 /* Buffer Requirements for Video Decoder */
214 struct video_buffer_req buf_req;
215 struct video_data_buffer buffer; /* Buffer Details */
216 struct video_mv_buff_size mv_buffer_req;
217 struct video_h264_mv mv_buffer_prop;
218 };
219
Hans Verkuil2435be12007-04-27 12:31:09 -0300220 struct {
221 __u32 data[16];
222 } raw;
223 };
224};
225
Hans Verkuil43d0dfc2007-03-10 06:24:30 -0300226/* FIELD_UNKNOWN can be used if the hardware does not know whether
227 the Vsync is for an odd, even or progressive (i.e. non-interlaced)
228 field. */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530229#define VIDEO_VSYNC_FIELD_UNKNOWN (0)
230#define VIDEO_VSYNC_FIELD_ODD (1)
Hans Verkuil43d0dfc2007-03-10 06:24:30 -0300231#define VIDEO_VSYNC_FIELD_EVEN (2)
232#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
Hans Verkuil2435be12007-04-27 12:31:09 -0300233
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234struct video_event {
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100235 __s32 type;
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530236#define VIDEO_EVENT_SIZE_CHANGED (1)
237#define VIDEO_EVENT_FRAME_RATE_CHANGED (2)
238#define VIDEO_EVENT_DECODER_STOPPED (3)
239#define VIDEO_EVENT_VSYNC (4)
240#define VIDEO_EVENT_DECODER_PLAYING (5)
241#define VIDEO_EVENT_DECODER_FREEZED (6)
242#define VIDEO_EVENT_DECODER_RESUMED (7)
243#define VIDEO_EVENT_INPUT_BUFFER_DONE (8)
244#define VIDEO_EVENT_SEQ_HDR_FOUND (9)
245#define VIDEO_EVENT_OUTPUT_BUFFER_DONE (10)
246#define VIDEO_EVENT_OUTPUT_FLUSH_DONE (11)
247#define VIDEO_EVENT_INPUT_FLUSH_DONE (12)
248#define VIDEO_EVENT_INPUT_FLUSHED (13)
249#define VIDEO_EVENT_OUTPUT_FLUSHED (14)
250
251
252 unsigned int status;
253#define VIDEO_STATUS_SUCESS 0
254#define VIDEO_STATUS_BITSTREAM_ERROR 1
255#define VIDEO_STATUS_FAILED 2
256#define VIDEO_STATUS_NORESOURCE 3
257#define VIDEO_STATUS_INVALID_CMD 4
258#define VIDEO_STATUS_INVALID_PARAM 5
259#define VIDEO_STATUS_INVALID_STATE 6
260#define VIDEO_STATUS_BUSY 7
261#define VIDEO_STATUS_INVALID_HANDLE 8
262#define VIDEO_STATUS_NO_SUPPORT 9
Arnd Bergmann85efde62009-02-26 00:51:39 +0100263 __kernel_time_t timestamp;
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 union {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800266 video_size_t size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 unsigned int frame_rate; /* in frames per 1000sec */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530268 unsigned char vsync_field; /* unknown/odd/even/progressive */
269 struct video_data_buffer buffer; /* Output Buffer Details */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 } u;
271};
272
273
274struct video_status {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800275 int video_blank; /* blank video on freeze? */
276 video_play_state_t play_state; /* current state of playback */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530277 video_stream_source_t stream_source;/* current source (demux/memory) */
278 video_format_t video_format; /* current aspect ratio of stream*/
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800279 video_displayformat_t display_format;/* selected cropping mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280};
281
282
283struct video_still_picture {
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -0800284 char __user *iFrame; /* pointer to a single iframe in memory */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100285 __s32 size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286};
287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288typedef
289struct video_highlight {
290 int active; /* 1=show highlight, 0=hide highlight */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100291 __u8 contrast1; /* 7- 4 Pattern pixel contrast */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800292 /* 3- 0 Background pixel contrast */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100293 __u8 contrast2; /* 7- 4 Emphasis pixel-2 contrast */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800294 /* 3- 0 Emphasis pixel-1 contrast */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100295 __u8 color1; /* 7- 4 Pattern pixel color */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800296 /* 3- 0 Background pixel color */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100297 __u8 color2; /* 7- 4 Emphasis pixel-2 color */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800298 /* 3- 0 Emphasis pixel-1 color */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100299 __u32 ypos; /* 23-22 auto action mode */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800300 /* 21-12 start y */
301 /* 9- 0 end y */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100302 __u32 xpos; /* 23-22 button color number */
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800303 /* 21-12 start x */
304 /* 9- 0 end x */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305} video_highlight_t;
306
307
308typedef struct video_spu {
309 int active;
310 int stream_id;
311} video_spu_t;
312
313
314typedef struct video_spu_palette { /* SPU Palette information */
315 int length;
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100316 __u8 __user *palette;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317} video_spu_palette_t;
318
319
320typedef struct video_navi_pack {
321 int length; /* 0 ... 1024 */
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100322 __u8 data[1024];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323} video_navi_pack_t;
324
325
Arnd Bergmann9adfbfb2009-02-26 00:51:40 +0100326typedef __u16 video_attributes_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327/* bits: descr. */
328/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
329/* 13-12 TV system (0=525/60, 1=625/50) */
330/* 11-10 Aspect ratio (0=4:3, 3=16:9) */
331/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
332/* 7 line 21-1 data present in GOP (1=yes, 0=no) */
333/* 6 line 21-2 data present in GOP (1=yes, 0=no) */
334/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
335/* 2 source letterboxed (1=yes, 0=no) */
336/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */
337
338
339/* bit definitions for capabilities: */
340/* can the hardware decode MPEG1 and/or MPEG2? */
341#define VIDEO_CAP_MPEG1 1
342#define VIDEO_CAP_MPEG2 2
343/* can you send a system and/or program stream to video device?
344 (you still have to open the video and the audio device but only
345 send the stream to the video device) */
346#define VIDEO_CAP_SYS 4
347#define VIDEO_CAP_PROG 8
348/* can the driver also handle SPU, NAVI and CSS encoded data?
349 (CSS API is not present yet) */
350#define VIDEO_CAP_SPU 16
351#define VIDEO_CAP_NAVI 32
352#define VIDEO_CAP_CSS 64
353
354
355#define VIDEO_STOP _IO('o', 21)
356#define VIDEO_PLAY _IO('o', 22)
357#define VIDEO_FREEZE _IO('o', 23)
358#define VIDEO_CONTINUE _IO('o', 24)
359#define VIDEO_SELECT_SOURCE _IO('o', 25)
360#define VIDEO_SET_BLANK _IO('o', 26)
361#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
362#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
363#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
364#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
365#define VIDEO_FAST_FORWARD _IO('o', 31)
366#define VIDEO_SLOWMOTION _IO('o', 32)
367#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
368#define VIDEO_CLEAR_BUFFER _IO('o', 34)
369#define VIDEO_SET_ID _IO('o', 35)
370#define VIDEO_SET_STREAMTYPE _IO('o', 36)
371#define VIDEO_SET_FORMAT _IO('o', 37)
372#define VIDEO_SET_SYSTEM _IO('o', 38)
373#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
374#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
375#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
376#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
377#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
378#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
379#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
380
Andreas Oberritterf05cce82006-02-27 00:09:00 -0300381/**
382 * VIDEO_GET_PTS
383 *
384 * Read the 33 bit presentation time stamp as defined
385 * in ITU T-REC-H.222.0 / ISO/IEC 13818-1.
386 *
387 * The PTS should belong to the currently played
388 * frame if possible, but may also be a value close to it
389 * like the PTS of the last decoded frame or the last PTS
390 * extracted by the PES parser.
391 */
392#define VIDEO_GET_PTS _IOR('o', 57, __u64)
393
Hans Verkuil2435be12007-04-27 12:31:09 -0300394/* Read the number of displayed frames since the decoder was started */
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530395#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
Hans Verkuil2435be12007-04-27 12:31:09 -0300396
Ananda Kishore9d84f1d2012-06-13 14:34:49 +0530397#define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
398#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
Hans Verkuil2435be12007-04-27 12:31:09 -0300399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400#endif /*_DVBVIDEO_H_*/