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