video.h 8.6 KB

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