cx2341x.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. cx23415/6/8 header containing common defines.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. #ifndef CX2341X_H
  16. #define CX2341X_H
  17. #include <media/v4l2-ctrls.h>
  18. enum cx2341x_port {
  19. CX2341X_PORT_MEMORY = 0,
  20. CX2341X_PORT_STREAMING = 1,
  21. CX2341X_PORT_SERIAL = 2
  22. };
  23. enum cx2341x_cap {
  24. CX2341X_CAP_HAS_SLICED_VBI = 1 << 0,
  25. CX2341X_CAP_HAS_TS = 1 << 1,
  26. CX2341X_CAP_HAS_AC3 = 1 << 2,
  27. };
  28. struct cx2341x_mpeg_params {
  29. /* misc */
  30. u32 capabilities;
  31. enum cx2341x_port port;
  32. u16 width;
  33. u16 height;
  34. u16 is_50hz;
  35. /* stream */
  36. enum v4l2_mpeg_stream_type stream_type;
  37. enum v4l2_mpeg_stream_vbi_fmt stream_vbi_fmt;
  38. u16 stream_insert_nav_packets;
  39. /* audio */
  40. enum v4l2_mpeg_audio_sampling_freq audio_sampling_freq;
  41. enum v4l2_mpeg_audio_encoding audio_encoding;
  42. enum v4l2_mpeg_audio_l2_bitrate audio_l2_bitrate;
  43. enum v4l2_mpeg_audio_ac3_bitrate audio_ac3_bitrate;
  44. enum v4l2_mpeg_audio_mode audio_mode;
  45. enum v4l2_mpeg_audio_mode_extension audio_mode_extension;
  46. enum v4l2_mpeg_audio_emphasis audio_emphasis;
  47. enum v4l2_mpeg_audio_crc audio_crc;
  48. u32 audio_properties;
  49. u16 audio_mute;
  50. /* video */
  51. enum v4l2_mpeg_video_encoding video_encoding;
  52. enum v4l2_mpeg_video_aspect video_aspect;
  53. u16 video_b_frames;
  54. u16 video_gop_size;
  55. u16 video_gop_closure;
  56. enum v4l2_mpeg_video_bitrate_mode video_bitrate_mode;
  57. u32 video_bitrate;
  58. u32 video_bitrate_peak;
  59. u16 video_temporal_decimation;
  60. u16 video_mute;
  61. u32 video_mute_yuv;
  62. /* encoding filters */
  63. enum v4l2_mpeg_cx2341x_video_spatial_filter_mode video_spatial_filter_mode;
  64. u16 video_spatial_filter;
  65. enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type video_luma_spatial_filter_type;
  66. enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type video_chroma_spatial_filter_type;
  67. enum v4l2_mpeg_cx2341x_video_temporal_filter_mode video_temporal_filter_mode;
  68. u16 video_temporal_filter;
  69. enum v4l2_mpeg_cx2341x_video_median_filter_type video_median_filter_type;
  70. u16 video_luma_median_filter_top;
  71. u16 video_luma_median_filter_bottom;
  72. u16 video_chroma_median_filter_top;
  73. u16 video_chroma_median_filter_bottom;
  74. };
  75. #define CX2341X_MBOX_MAX_DATA 16
  76. extern const u32 cx2341x_mpeg_ctrls[];
  77. typedef int (*cx2341x_mbox_func)(void *priv, u32 cmd, int in, int out,
  78. u32 data[CX2341X_MBOX_MAX_DATA]);
  79. int cx2341x_update(void *priv, cx2341x_mbox_func func,
  80. const struct cx2341x_mpeg_params *old,
  81. const struct cx2341x_mpeg_params *new);
  82. int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params,
  83. struct v4l2_queryctrl *qctrl);
  84. const char * const *cx2341x_ctrl_get_menu(const struct cx2341x_mpeg_params *p, u32 id);
  85. int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
  86. struct v4l2_ext_controls *ctrls, unsigned int cmd);
  87. void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p);
  88. void cx2341x_log_status(const struct cx2341x_mpeg_params *p, const char *prefix);
  89. struct cx2341x_handler;
  90. struct cx2341x_handler_ops {
  91. /* needed for the video clock freq */
  92. int (*s_audio_sampling_freq)(struct cx2341x_handler *hdl, u32 val);
  93. /* needed for dualwatch */
  94. int (*s_audio_mode)(struct cx2341x_handler *hdl, u32 val);
  95. /* needed for setting up the video resolution */
  96. int (*s_video_encoding)(struct cx2341x_handler *hdl, u32 val);
  97. /* needed for setting up the sliced vbi insertion data structures */
  98. int (*s_stream_vbi_fmt)(struct cx2341x_handler *hdl, u32 val);
  99. };
  100. struct cx2341x_handler {
  101. u32 capabilities;
  102. enum cx2341x_port port;
  103. u16 width;
  104. u16 height;
  105. u16 is_50hz;
  106. u32 audio_properties;
  107. struct v4l2_ctrl_handler hdl;
  108. void *priv;
  109. cx2341x_mbox_func func;
  110. const struct cx2341x_handler_ops *ops;
  111. struct v4l2_ctrl *stream_vbi_fmt;
  112. struct {
  113. /* audio cluster */
  114. struct v4l2_ctrl *audio_sampling_freq;
  115. struct v4l2_ctrl *audio_encoding;
  116. struct v4l2_ctrl *audio_l2_bitrate;
  117. struct v4l2_ctrl *audio_mode;
  118. struct v4l2_ctrl *audio_mode_extension;
  119. struct v4l2_ctrl *audio_emphasis;
  120. struct v4l2_ctrl *audio_crc;
  121. struct v4l2_ctrl *audio_ac3_bitrate;
  122. };
  123. struct {
  124. /* video gop cluster */
  125. struct v4l2_ctrl *video_b_frames;
  126. struct v4l2_ctrl *video_gop_size;
  127. };
  128. struct {
  129. /* stream type cluster */
  130. struct v4l2_ctrl *stream_type;
  131. struct v4l2_ctrl *video_encoding;
  132. struct v4l2_ctrl *video_bitrate_mode;
  133. struct v4l2_ctrl *video_bitrate;
  134. struct v4l2_ctrl *video_bitrate_peak;
  135. };
  136. struct {
  137. /* video mute cluster */
  138. struct v4l2_ctrl *video_mute;
  139. struct v4l2_ctrl *video_mute_yuv;
  140. };
  141. struct {
  142. /* video filter mode cluster */
  143. struct v4l2_ctrl *video_spatial_filter_mode;
  144. struct v4l2_ctrl *video_temporal_filter_mode;
  145. struct v4l2_ctrl *video_median_filter_type;
  146. };
  147. struct {
  148. /* video filter type cluster */
  149. struct v4l2_ctrl *video_luma_spatial_filter_type;
  150. struct v4l2_ctrl *video_chroma_spatial_filter_type;
  151. };
  152. struct {
  153. /* video filter cluster */
  154. struct v4l2_ctrl *video_spatial_filter;
  155. struct v4l2_ctrl *video_temporal_filter;
  156. };
  157. struct {
  158. /* video median cluster */
  159. struct v4l2_ctrl *video_luma_median_filter_top;
  160. struct v4l2_ctrl *video_luma_median_filter_bottom;
  161. struct v4l2_ctrl *video_chroma_median_filter_top;
  162. struct v4l2_ctrl *video_chroma_median_filter_bottom;
  163. };
  164. };
  165. int cx2341x_handler_init(struct cx2341x_handler *cxhdl,
  166. unsigned nr_of_controls_hint);
  167. void cx2341x_handler_set_50hz(struct cx2341x_handler *cxhdl, int is_50hz);
  168. int cx2341x_handler_setup(struct cx2341x_handler *cxhdl);
  169. void cx2341x_handler_set_busy(struct cx2341x_handler *cxhdl, int busy);
  170. /* Firmware names */
  171. #define CX2341X_FIRM_ENC_FILENAME "/*(DEBLOBBED)*/"
  172. /* Decoder firmware for the cx23415 only */
  173. #define CX2341X_FIRM_DEC_FILENAME "/*(DEBLOBBED)*/"
  174. /* Firmware API commands */
  175. /* MPEG decoder API, specific to the cx23415 */
  176. #define CX2341X_DEC_PING_FW 0x00
  177. #define CX2341X_DEC_START_PLAYBACK 0x01
  178. #define CX2341X_DEC_STOP_PLAYBACK 0x02
  179. #define CX2341X_DEC_SET_PLAYBACK_SPEED 0x03
  180. #define CX2341X_DEC_STEP_VIDEO 0x05
  181. #define CX2341X_DEC_SET_DMA_BLOCK_SIZE 0x08
  182. #define CX2341X_DEC_GET_XFER_INFO 0x09
  183. #define CX2341X_DEC_GET_DMA_STATUS 0x0a
  184. #define CX2341X_DEC_SCHED_DMA_FROM_HOST 0x0b
  185. #define CX2341X_DEC_PAUSE_PLAYBACK 0x0d
  186. #define CX2341X_DEC_HALT_FW 0x0e
  187. #define CX2341X_DEC_SET_STANDARD 0x10
  188. #define CX2341X_DEC_GET_VERSION 0x11
  189. #define CX2341X_DEC_SET_STREAM_INPUT 0x14
  190. #define CX2341X_DEC_GET_TIMING_INFO 0x15
  191. #define CX2341X_DEC_SET_AUDIO_MODE 0x16
  192. #define CX2341X_DEC_SET_EVENT_NOTIFICATION 0x17
  193. #define CX2341X_DEC_SET_DISPLAY_BUFFERS 0x18
  194. #define CX2341X_DEC_EXTRACT_VBI 0x19
  195. #define CX2341X_DEC_SET_DECODER_SOURCE 0x1a
  196. #define CX2341X_DEC_SET_PREBUFFERING 0x1e
  197. /* MPEG encoder API */
  198. #define CX2341X_ENC_PING_FW 0x80
  199. #define CX2341X_ENC_START_CAPTURE 0x81
  200. #define CX2341X_ENC_STOP_CAPTURE 0x82
  201. #define CX2341X_ENC_SET_AUDIO_ID 0x89
  202. #define CX2341X_ENC_SET_VIDEO_ID 0x8b
  203. #define CX2341X_ENC_SET_PCR_ID 0x8d
  204. #define CX2341X_ENC_SET_FRAME_RATE 0x8f
  205. #define CX2341X_ENC_SET_FRAME_SIZE 0x91
  206. #define CX2341X_ENC_SET_BIT_RATE 0x95
  207. #define CX2341X_ENC_SET_GOP_PROPERTIES 0x97
  208. #define CX2341X_ENC_SET_ASPECT_RATIO 0x99
  209. #define CX2341X_ENC_SET_DNR_FILTER_MODE 0x9b
  210. #define CX2341X_ENC_SET_DNR_FILTER_PROPS 0x9d
  211. #define CX2341X_ENC_SET_CORING_LEVELS 0x9f
  212. #define CX2341X_ENC_SET_SPATIAL_FILTER_TYPE 0xa1
  213. #define CX2341X_ENC_SET_VBI_LINE 0xb7
  214. #define CX2341X_ENC_SET_STREAM_TYPE 0xb9
  215. #define CX2341X_ENC_SET_OUTPUT_PORT 0xbb
  216. #define CX2341X_ENC_SET_AUDIO_PROPERTIES 0xbd
  217. #define CX2341X_ENC_HALT_FW 0xc3
  218. #define CX2341X_ENC_GET_VERSION 0xc4
  219. #define CX2341X_ENC_SET_GOP_CLOSURE 0xc5
  220. #define CX2341X_ENC_GET_SEQ_END 0xc6
  221. #define CX2341X_ENC_SET_PGM_INDEX_INFO 0xc7
  222. #define CX2341X_ENC_SET_VBI_CONFIG 0xc8
  223. #define CX2341X_ENC_SET_DMA_BLOCK_SIZE 0xc9
  224. #define CX2341X_ENC_GET_PREV_DMA_INFO_MB_10 0xca
  225. #define CX2341X_ENC_GET_PREV_DMA_INFO_MB_9 0xcb
  226. #define CX2341X_ENC_SCHED_DMA_TO_HOST 0xcc
  227. #define CX2341X_ENC_INITIALIZE_INPUT 0xcd
  228. #define CX2341X_ENC_SET_FRAME_DROP_RATE 0xd0
  229. #define CX2341X_ENC_PAUSE_ENCODER 0xd2
  230. #define CX2341X_ENC_REFRESH_INPUT 0xd3
  231. #define CX2341X_ENC_SET_COPYRIGHT 0xd4
  232. #define CX2341X_ENC_SET_EVENT_NOTIFICATION 0xd5
  233. #define CX2341X_ENC_SET_NUM_VSYNC_LINES 0xd6
  234. #define CX2341X_ENC_SET_PLACEHOLDER 0xd7
  235. #define CX2341X_ENC_MUTE_VIDEO 0xd9
  236. #define CX2341X_ENC_MUTE_AUDIO 0xda
  237. #define CX2341X_ENC_SET_VERT_CROP_LINE 0xdb
  238. #define CX2341X_ENC_MISC 0xdc
  239. /* OSD API, specific to the cx23415 */
  240. #define CX2341X_OSD_GET_FRAMEBUFFER 0x41
  241. #define CX2341X_OSD_GET_PIXEL_FORMAT 0x42
  242. #define CX2341X_OSD_SET_PIXEL_FORMAT 0x43
  243. #define CX2341X_OSD_GET_STATE 0x44
  244. #define CX2341X_OSD_SET_STATE 0x45
  245. #define CX2341X_OSD_GET_OSD_COORDS 0x46
  246. #define CX2341X_OSD_SET_OSD_COORDS 0x47
  247. #define CX2341X_OSD_GET_SCREEN_COORDS 0x48
  248. #define CX2341X_OSD_SET_SCREEN_COORDS 0x49
  249. #define CX2341X_OSD_GET_GLOBAL_ALPHA 0x4a
  250. #define CX2341X_OSD_SET_GLOBAL_ALPHA 0x4b
  251. #define CX2341X_OSD_SET_BLEND_COORDS 0x4c
  252. #define CX2341X_OSD_GET_FLICKER_STATE 0x4f
  253. #define CX2341X_OSD_SET_FLICKER_STATE 0x50
  254. #define CX2341X_OSD_BLT_COPY 0x52
  255. #define CX2341X_OSD_BLT_FILL 0x53
  256. #define CX2341X_OSD_BLT_TEXT 0x54
  257. #define CX2341X_OSD_SET_FRAMEBUFFER_WINDOW 0x56
  258. #define CX2341X_OSD_SET_CHROMA_KEY 0x60
  259. #define CX2341X_OSD_GET_ALPHA_CONTENT_INDEX 0x61
  260. #define CX2341X_OSD_SET_ALPHA_CONTENT_INDEX 0x62
  261. #endif /* CX2341X_H */