1/*
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 _UAPI_DVBVIDEO_H_
25#define _UAPI_DVBVIDEO_H_
26
27#include <linux/types.h>
28#ifndef __KERNEL__
29#include <time.h>
30#endif
31
32typedef enum {
33	VIDEO_FORMAT_4_3,     /* Select 4:3 format */
34	VIDEO_FORMAT_16_9,    /* Select 16:9 format. */
35	VIDEO_FORMAT_221_1    /* 2.21:1 */
36} video_format_t;
37
38
39typedef enum {
40	 VIDEO_SYSTEM_PAL,
41	 VIDEO_SYSTEM_NTSC,
42	 VIDEO_SYSTEM_PALN,
43	 VIDEO_SYSTEM_PALNc,
44	 VIDEO_SYSTEM_PALM,
45	 VIDEO_SYSTEM_NTSC60,
46	 VIDEO_SYSTEM_PAL60,
47	 VIDEO_SYSTEM_PALM60
48} video_system_t;
49
50
51typedef enum {
52	VIDEO_PAN_SCAN,       /* use pan and scan format */
53	VIDEO_LETTER_BOX,     /* use letterbox format */
54	VIDEO_CENTER_CUT_OUT  /* use center cut out format */
55} video_displayformat_t;
56
57typedef struct {
58	int w;
59	int h;
60	video_format_t aspect_ratio;
61} video_size_t;
62
63typedef enum {
64	VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
65	VIDEO_SOURCE_MEMORY /* If this source is selected, the stream
66			       comes from the user through the write
67			       system call */
68} video_stream_source_t;
69
70
71typedef enum {
72	VIDEO_STOPPED, /* Video is stopped */
73	VIDEO_PLAYING, /* Video is currently playing */
74	VIDEO_FREEZED  /* Video is freezed */
75} video_play_state_t;
76
77
78/* Decoder commands */
79#define VIDEO_CMD_PLAY        (0)
80#define VIDEO_CMD_STOP        (1)
81#define VIDEO_CMD_FREEZE      (2)
82#define VIDEO_CMD_CONTINUE    (3)
83
84/* Flags for VIDEO_CMD_FREEZE */
85#define VIDEO_CMD_FREEZE_TO_BLACK     	(1 << 0)
86
87/* Flags for VIDEO_CMD_STOP */
88#define VIDEO_CMD_STOP_TO_BLACK      	(1 << 0)
89#define VIDEO_CMD_STOP_IMMEDIATELY     	(1 << 1)
90
91/* Play input formats: */
92/* The decoder has no special format requirements */
93#define VIDEO_PLAY_FMT_NONE         (0)
94/* The decoder requires full GOPs */
95#define VIDEO_PLAY_FMT_GOP          (1)
96
97/* The structure must be zeroed before use by the application
98   This ensures it can be extended safely in the future. */
99struct video_command {
100	__u32 cmd;
101	__u32 flags;
102	union {
103		struct {
104			__u64 pts;
105		} stop;
106
107		struct {
108			/* 0 or 1000 specifies normal speed,
109			   1 specifies forward single stepping,
110			   -1 specifies backward single stepping,
111			   >1: playback at speed/1000 of the normal speed,
112			   <-1: reverse playback at (-speed/1000) of the normal speed. */
113			__s32 speed;
114			__u32 format;
115		} play;
116
117		struct {
118			__u32 data[16];
119		} raw;
120	};
121};
122
123/* FIELD_UNKNOWN can be used if the hardware does not know whether
124   the Vsync is for an odd, even or progressive (i.e. non-interlaced)
125   field. */
126#define VIDEO_VSYNC_FIELD_UNKNOWN  	(0)
127#define VIDEO_VSYNC_FIELD_ODD 		(1)
128#define VIDEO_VSYNC_FIELD_EVEN		(2)
129#define VIDEO_VSYNC_FIELD_PROGRESSIVE	(3)
130
131struct video_event {
132	__s32 type;
133#define VIDEO_EVENT_SIZE_CHANGED	1
134#define VIDEO_EVENT_FRAME_RATE_CHANGED	2
135#define VIDEO_EVENT_DECODER_STOPPED 	3
136#define VIDEO_EVENT_VSYNC 		4
137	__kernel_time_t timestamp;
138	union {
139		video_size_t size;
140		unsigned int frame_rate;	/* in frames per 1000sec */
141		unsigned char vsync_field;	/* unknown/odd/even/progressive */
142	} u;
143};
144
145
146struct video_status {
147	int                   video_blank;   /* blank video on freeze? */
148	video_play_state_t    play_state;    /* current state of playback */
149	video_stream_source_t stream_source; /* current source (demux/memory) */
150	video_format_t        video_format;  /* current aspect ratio of stream*/
151	video_displayformat_t display_format;/* selected cropping mode */
152};
153
154
155struct video_still_picture {
156	char __user *iFrame;        /* pointer to a single iframe in memory */
157	__s32 size;
158};
159
160
161typedef
162struct video_highlight {
163	int     active;      /*    1=show highlight, 0=hide highlight */
164	__u8    contrast1;   /*    7- 4  Pattern pixel contrast */
165			     /*    3- 0  Background pixel contrast */
166	__u8    contrast2;   /*    7- 4  Emphasis pixel-2 contrast */
167			     /*    3- 0  Emphasis pixel-1 contrast */
168	__u8    color1;      /*    7- 4  Pattern pixel color */
169			     /*    3- 0  Background pixel color */
170	__u8    color2;      /*    7- 4  Emphasis pixel-2 color */
171			     /*    3- 0  Emphasis pixel-1 color */
172	__u32    ypos;       /*   23-22  auto action mode */
173			     /*   21-12  start y */
174			     /*    9- 0  end y */
175	__u32    xpos;       /*   23-22  button color number */
176			     /*   21-12  start x */
177			     /*    9- 0  end x */
178} video_highlight_t;
179
180
181typedef struct video_spu {
182	int active;
183	int stream_id;
184} video_spu_t;
185
186
187typedef struct video_spu_palette {      /* SPU Palette information */
188	int length;
189	__u8 __user *palette;
190} video_spu_palette_t;
191
192
193typedef struct video_navi_pack {
194	int length;          /* 0 ... 1024 */
195	__u8 data[1024];
196} video_navi_pack_t;
197
198
199typedef __u16 video_attributes_t;
200/*   bits: descr. */
201/*   15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
202/*   13-12 TV system (0=525/60, 1=625/50) */
203/*   11-10 Aspect ratio (0=4:3, 3=16:9) */
204/*    9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
205/*    7    line 21-1 data present in GOP (1=yes, 0=no) */
206/*    6    line 21-2 data present in GOP (1=yes, 0=no) */
207/*    5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
208/*    2    source letterboxed (1=yes, 0=no) */
209/*    0    film/camera mode (0=
210 *camera, 1=film (625/50 only)) */
211
212
213/* bit definitions for capabilities: */
214/* can the hardware decode MPEG1 and/or MPEG2? */
215#define VIDEO_CAP_MPEG1   1
216#define VIDEO_CAP_MPEG2   2
217/* can you send a system and/or program stream to video device?
218   (you still have to open the video and the audio device but only
219    send the stream to the video device) */
220#define VIDEO_CAP_SYS     4
221#define VIDEO_CAP_PROG    8
222/* can the driver also handle SPU, NAVI and CSS encoded data?
223   (CSS API is not present yet) */
224#define VIDEO_CAP_SPU    16
225#define VIDEO_CAP_NAVI   32
226#define VIDEO_CAP_CSS    64
227
228
229#define VIDEO_STOP                 _IO('o', 21)
230#define VIDEO_PLAY                 _IO('o', 22)
231#define VIDEO_FREEZE               _IO('o', 23)
232#define VIDEO_CONTINUE             _IO('o', 24)
233#define VIDEO_SELECT_SOURCE        _IO('o', 25)
234#define VIDEO_SET_BLANK            _IO('o', 26)
235#define VIDEO_GET_STATUS           _IOR('o', 27, struct video_status)
236#define VIDEO_GET_EVENT            _IOR('o', 28, struct video_event)
237#define VIDEO_SET_DISPLAY_FORMAT   _IO('o', 29)
238#define VIDEO_STILLPICTURE         _IOW('o', 30, struct video_still_picture)
239#define VIDEO_FAST_FORWARD         _IO('o', 31)
240#define VIDEO_SLOWMOTION           _IO('o', 32)
241#define VIDEO_GET_CAPABILITIES     _IOR('o', 33, unsigned int)
242#define VIDEO_CLEAR_BUFFER         _IO('o',  34)
243#define VIDEO_SET_ID               _IO('o', 35)
244#define VIDEO_SET_STREAMTYPE       _IO('o', 36)
245#define VIDEO_SET_FORMAT           _IO('o', 37)
246#define VIDEO_SET_SYSTEM           _IO('o', 38)
247#define VIDEO_SET_HIGHLIGHT        _IOW('o', 39, video_highlight_t)
248#define VIDEO_SET_SPU              _IOW('o', 50, video_spu_t)
249#define VIDEO_SET_SPU_PALETTE      _IOW('o', 51, video_spu_palette_t)
250#define VIDEO_GET_NAVI             _IOR('o', 52, video_navi_pack_t)
251#define VIDEO_SET_ATTRIBUTES       _IO('o', 53)
252#define VIDEO_GET_SIZE             _IOR('o', 55, video_size_t)
253#define VIDEO_GET_FRAME_RATE       _IOR('o', 56, unsigned int)
254
255/**
256 * VIDEO_GET_PTS
257 *
258 * Read the 33 bit presentation time stamp as defined
259 * in ITU T-REC-H.222.0 / ISO/IEC 13818-1.
260 *
261 * The PTS should belong to the currently played
262 * frame if possible, but may also be a value close to it
263 * like the PTS of the last decoded frame or the last PTS
264 * extracted by the PES parser.
265 */
266#define VIDEO_GET_PTS              _IOR('o', 57, __u64)
267
268/* Read the number of displayed frames since the decoder was started */
269#define VIDEO_GET_FRAME_COUNT  	   _IOR('o', 58, __u64)
270
271#define VIDEO_COMMAND     	   _IOWR('o', 59, struct video_command)
272#define VIDEO_TRY_COMMAND 	   _IOWR('o', 60, struct video_command)
273
274#endif /* _UAPI_DVBVIDEO_H_ */
275