diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-08-21 17:32:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-09 21:06:42 -0400 |
commit | 01f1e44fe8455b6c6c557a62119b8622fb99f5f2 (patch) | |
tree | e1bf62f369561d52aa913a60a75302dff3beb9a6 | |
parent | ea115d54bc963eb2eb0dc223795f3bd6c689ff99 (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>
-rw-r--r-- | drivers/media/video/cx2341x.c | 18 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-blackbird.c | 6 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-controls.c | 6 | ||||
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 6 | ||||
-rw-r--r-- | drivers/media/video/v4l2-common.c | 1 | ||||
-rw-r--r-- | include/media/cx2341x.h | 2 |
6 files changed, 26 insertions, 13 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. */ |
193 | static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, | 193 | static 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 | ||
634 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, | 646 | int 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 | } |
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 206af419aea7..47007380a98a 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -876,7 +876,7 @@ static int vidioc_g_ext_ctrls (struct file *file, void *priv, | |||
876 | 876 | ||
877 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 877 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
878 | return -EINVAL; | 878 | return -EINVAL; |
879 | return cx2341x_ext_ctrls(&dev->params, f, VIDIOC_G_EXT_CTRLS); | 879 | return cx2341x_ext_ctrls(&dev->params, 0, f, VIDIOC_G_EXT_CTRLS); |
880 | } | 880 | } |
881 | 881 | ||
882 | static int vidioc_s_ext_ctrls (struct file *file, void *priv, | 882 | static int vidioc_s_ext_ctrls (struct file *file, void *priv, |
@@ -889,7 +889,7 @@ static int vidioc_s_ext_ctrls (struct file *file, void *priv, | |||
889 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 889 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
890 | return -EINVAL; | 890 | return -EINVAL; |
891 | p = dev->params; | 891 | p = dev->params; |
892 | err = cx2341x_ext_ctrls(&p, f, VIDIOC_S_EXT_CTRLS); | 892 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS); |
893 | if (!err) { | 893 | if (!err) { |
894 | err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p); | 894 | err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p); |
895 | dev->params = p; | 895 | dev->params = p; |
@@ -907,7 +907,7 @@ static int vidioc_try_ext_ctrls (struct file *file, void *priv, | |||
907 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 907 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
908 | return -EINVAL; | 908 | return -EINVAL; |
909 | p = dev->params; | 909 | p = dev->params; |
910 | err = cx2341x_ext_ctrls(&p, f, VIDIOC_TRY_EXT_CTRLS); | 910 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS); |
911 | 911 | ||
912 | return err; | 912 | return err; |
913 | } | 913 | } |
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c index 7a876c3e5b19..0005ea46f208 100644 --- a/drivers/media/video/ivtv/ivtv-controls.c +++ b/drivers/media/video/ivtv/ivtv-controls.c | |||
@@ -232,7 +232,7 @@ int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg) | |||
232 | IVTV_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); | 232 | IVTV_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); |
233 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { | 233 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { |
234 | struct cx2341x_mpeg_params p = itv->params; | 234 | struct cx2341x_mpeg_params p = itv->params; |
235 | int err = cx2341x_ext_ctrls(&p, arg, cmd); | 235 | int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), arg, cmd); |
236 | 236 | ||
237 | if (err) | 237 | if (err) |
238 | return err; | 238 | return err; |
@@ -282,7 +282,7 @@ int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg) | |||
282 | } | 282 | } |
283 | IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n"); | 283 | IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n"); |
284 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | 284 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
285 | return cx2341x_ext_ctrls(&itv->params, arg, cmd); | 285 | return cx2341x_ext_ctrls(&itv->params, 0, arg, cmd); |
286 | return -EINVAL; | 286 | return -EINVAL; |
287 | } | 287 | } |
288 | 288 | ||
@@ -292,7 +292,7 @@ int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg) | |||
292 | 292 | ||
293 | IVTV_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); | 293 | IVTV_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); |
294 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | 294 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
295 | return cx2341x_ext_ctrls(&itv->params, arg, cmd); | 295 | return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), arg, cmd); |
296 | return -EINVAL; | 296 | return -EINVAL; |
297 | } | 297 | } |
298 | 298 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 1311891e7ee3..2d5be5cfbccf 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -492,7 +492,7 @@ static int ctrl_cx2341x_get(struct pvr2_ctrl *cptr,int *vp) | |||
492 | cs.controls = &c1; | 492 | cs.controls = &c1; |
493 | cs.count = 1; | 493 | cs.count = 1; |
494 | c1.id = cptr->info->v4l_id; | 494 | c1.id = cptr->info->v4l_id; |
495 | ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state,&cs, | 495 | ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state, 0, &cs, |
496 | VIDIOC_G_EXT_CTRLS); | 496 | VIDIOC_G_EXT_CTRLS); |
497 | if (ret) return ret; | 497 | if (ret) return ret; |
498 | *vp = c1.value; | 498 | *vp = c1.value; |
@@ -510,7 +510,7 @@ static int ctrl_cx2341x_set(struct pvr2_ctrl *cptr,int m,int v) | |||
510 | cs.count = 1; | 510 | cs.count = 1; |
511 | c1.id = cptr->info->v4l_id; | 511 | c1.id = cptr->info->v4l_id; |
512 | c1.value = v; | 512 | c1.value = v; |
513 | ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state,&cs, | 513 | ret = cx2341x_ext_ctrls(&cptr->hdw->enc_ctl_state, 0, &cs, |
514 | VIDIOC_S_EXT_CTRLS); | 514 | VIDIOC_S_EXT_CTRLS); |
515 | if (ret) return ret; | 515 | if (ret) return ret; |
516 | cptr->hdw->enc_stale = !0; | 516 | cptr->hdw->enc_stale = !0; |
@@ -2478,7 +2478,7 @@ static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw) | |||
2478 | cs.count = 1; | 2478 | cs.count = 1; |
2479 | c1.id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ; | 2479 | c1.id = V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ; |
2480 | c1.value = hdw->srate_val; | 2480 | c1.value = hdw->srate_val; |
2481 | cx2341x_ext_ctrls(&hdw->enc_ctl_state,&cs,VIDIOC_S_EXT_CTRLS); | 2481 | cx2341x_ext_ctrls(&hdw->enc_ctl_state, 0, &cs,VIDIOC_S_EXT_CTRLS); |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | /* Scan i2c core at this point - before we clear all the dirty | 2484 | /* Scan i2c core at this point - before we clear all the dirty |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index d2915d3530ea..0689a041d777 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -716,6 +716,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste | |||
716 | case V4L2_CID_AUDIO_MUTE: | 716 | case V4L2_CID_AUDIO_MUTE: |
717 | case V4L2_CID_AUDIO_LOUDNESS: | 717 | case V4L2_CID_AUDIO_LOUDNESS: |
718 | case V4L2_CID_MPEG_AUDIO_MUTE: | 718 | case V4L2_CID_MPEG_AUDIO_MUTE: |
719 | case V4L2_CID_MPEG_VIDEO_MUTE: | ||
719 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: | 720 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: |
720 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: | 721 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: |
721 | qctrl->type = V4L2_CTRL_TYPE_BOOLEAN; | 722 | qctrl->type = V4L2_CTRL_TYPE_BOOLEAN; |
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h index 38c12fed7535..af8071d7620d 100644 --- a/include/media/cx2341x.h +++ b/include/media/cx2341x.h | |||
@@ -91,7 +91,7 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func, | |||
91 | int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, | 91 | int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, |
92 | struct v4l2_queryctrl *qctrl); | 92 | struct v4l2_queryctrl *qctrl); |
93 | const char **cx2341x_ctrl_get_menu(u32 id); | 93 | const char **cx2341x_ctrl_get_menu(u32 id); |
94 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, | 94 | int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, |
95 | struct v4l2_ext_controls *ctrls, unsigned int cmd); | 95 | struct v4l2_ext_controls *ctrls, unsigned int cmd); |
96 | void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); | 96 | void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p); |
97 | void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix); | 97 | void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix); |