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