aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx2341x.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-08-21 17:32:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:06:42 -0400
commit01f1e44fe8455b6c6c557a62119b8622fb99f5f2 (patch)
treee1bf62f369561d52aa913a60a75302dff3beb9a6 /drivers/media/video/cx2341x.c
parentea115d54bc963eb2eb0dc223795f3bd6c689ff99 (diff)
V4L/DVB (6088): cx2341x: some controls can't be changed while the device is busy
The driver should now pass the 'busy' state of the device to the cx2341x module whenever controls are set or tried. -EBUSY will be returned if the device is busy and the user attempts to modify certain 'dangerous' controls. It concerns controls that change the audio or video compression mode and bitrates. The cx88-blackbird and pvrusb2 drivers currently always pass '0' (not busy) to the cx2341x, effectively keeping the old behavior for now. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx2341x.c')
-rw-r--r--drivers/media/video/cx2341x.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 904bba0dbc4d..62304255dcae 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -190,17 +190,21 @@ static int cx2341x_get_ctrl(struct cx2341x_mpeg_params *params,
190 190
191/* Map the control ID to the correct field in the cx2341x_mpeg_params 191/* Map the control ID to the correct field in the cx2341x_mpeg_params
192 struct. Return -EINVAL if the ID is unknown, else return 0. */ 192 struct. Return -EINVAL if the ID is unknown, else return 0. */
193static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, 193static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
194 struct v4l2_ext_control *ctrl) 194 struct v4l2_ext_control *ctrl)
195{ 195{
196 switch (ctrl->id) { 196 switch (ctrl->id) {
197 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: 197 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
198 if (busy)
199 return -EBUSY;
198 params->audio_sampling_freq = ctrl->value; 200 params->audio_sampling_freq = ctrl->value;
199 break; 201 break;
200 case V4L2_CID_MPEG_AUDIO_ENCODING: 202 case V4L2_CID_MPEG_AUDIO_ENCODING:
201 params->audio_encoding = ctrl->value; 203 params->audio_encoding = ctrl->value;
202 break; 204 break;
203 case V4L2_CID_MPEG_AUDIO_L2_BITRATE: 205 case V4L2_CID_MPEG_AUDIO_L2_BITRATE:
206 if (busy)
207 return -EBUSY;
204 params->audio_l2_bitrate = ctrl->value; 208 params->audio_l2_bitrate = ctrl->value;
205 break; 209 break;
206 case V4L2_CID_MPEG_AUDIO_MODE: 210 case V4L2_CID_MPEG_AUDIO_MODE:
@@ -245,6 +249,8 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
245 params->video_gop_closure = ctrl->value; 249 params->video_gop_closure = ctrl->value;
246 break; 250 break;
247 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: 251 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
252 if (busy)
253 return -EBUSY;
248 /* MPEG-1 only allows CBR */ 254 /* MPEG-1 only allows CBR */
249 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1 && 255 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1 &&
250 ctrl->value != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 256 ctrl->value != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
@@ -252,9 +258,13 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
252 params->video_bitrate_mode = ctrl->value; 258 params->video_bitrate_mode = ctrl->value;
253 break; 259 break;
254 case V4L2_CID_MPEG_VIDEO_BITRATE: 260 case V4L2_CID_MPEG_VIDEO_BITRATE:
261 if (busy)
262 return -EBUSY;
255 params->video_bitrate = ctrl->value; 263 params->video_bitrate = ctrl->value;
256 break; 264 break;
257 case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: 265 case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:
266 if (busy)
267 return -EBUSY;
258 params->video_bitrate_peak = ctrl->value; 268 params->video_bitrate_peak = ctrl->value;
259 break; 269 break;
260 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: 270 case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION:
@@ -267,6 +277,8 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params,
267 params->video_mute_yuv = ctrl->value; 277 params->video_mute_yuv = ctrl->value;
268 break; 278 break;
269 case V4L2_CID_MPEG_STREAM_TYPE: 279 case V4L2_CID_MPEG_STREAM_TYPE:
280 if (busy)
281 return -EBUSY;
270 params->stream_type = ctrl->value; 282 params->stream_type = ctrl->value;
271 params->video_encoding = 283 params->video_encoding =
272 (params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_SS || 284 (params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_SS ||
@@ -631,7 +643,7 @@ static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params)
631 (params->audio_crc << 14); 643 (params->audio_crc << 14);
632} 644}
633 645
634int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, 646int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
635 struct v4l2_ext_controls *ctrls, unsigned int cmd) 647 struct v4l2_ext_controls *ctrls, unsigned int cmd)
636{ 648{
637 int err = 0; 649 int err = 0;
@@ -663,7 +675,7 @@ int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params,
663 err = v4l2_ctrl_check(ctrl, &qctrl, menu_items); 675 err = v4l2_ctrl_check(ctrl, &qctrl, menu_items);
664 if (err) 676 if (err)
665 break; 677 break;
666 err = cx2341x_set_ctrl(params, ctrl); 678 err = cx2341x_set_ctrl(params, busy, ctrl);
667 if (err) 679 if (err)
668 break; 680 break;
669 } 681 }