diff options
-rw-r--r-- | Documentation/video4linux/v4l2-controls.txt | 6 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88-blackbird.c | 2 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88-video.c | 2 | ||||
-rw-r--r-- | drivers/media/platform/s5p-fimc/fimc-capture.c | 2 | ||||
-rw-r--r-- | drivers/media/platform/soc_camera/soc_camera.c | 2 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 25 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-device.c | 2 | ||||
-rw-r--r-- | include/media/v4l2-ctrls.h | 18 |
8 files changed, 50 insertions, 9 deletions
diff --git a/Documentation/video4linux/v4l2-controls.txt b/Documentation/video4linux/v4l2-controls.txt index 43da22b89728..54270df99d5c 100644 --- a/Documentation/video4linux/v4l2-controls.txt +++ b/Documentation/video4linux/v4l2-controls.txt | |||
@@ -594,7 +594,11 @@ handler and finally add the first handler to the second. For example: | |||
594 | v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...); | 594 | v4l2_ctrl_new_std(&radio_ctrl_handler, &radio_ops, V4L2_CID_AUDIO_MUTE, ...); |
595 | v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...); | 595 | v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_BRIGHTNESS, ...); |
596 | v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_CONTRAST, ...); | 596 | v4l2_ctrl_new_std(&video_ctrl_handler, &video_ops, V4L2_CID_CONTRAST, ...); |
597 | v4l2_ctrl_add_handler(&video_ctrl_handler, &radio_ctrl_handler); | 597 | v4l2_ctrl_add_handler(&video_ctrl_handler, &radio_ctrl_handler, NULL); |
598 | |||
599 | The last argument to v4l2_ctrl_add_handler() is a filter function that allows | ||
600 | you to filter which controls will be added. Set it to NULL if you want to add | ||
601 | all controls. | ||
598 | 602 | ||
599 | Or you can add specific controls to a handler: | 603 | Or you can add specific controls to a handler: |
600 | 604 | ||
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c index 843ffd9e533b..def363fb71c0 100644 --- a/drivers/media/pci/cx88/cx88-blackbird.c +++ b/drivers/media/pci/cx88/cx88-blackbird.c | |||
@@ -1236,7 +1236,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1236 | err = cx2341x_handler_init(&dev->cxhdl, 36); | 1236 | err = cx2341x_handler_init(&dev->cxhdl, 36); |
1237 | if (err) | 1237 | if (err) |
1238 | goto fail_core; | 1238 | goto fail_core; |
1239 | v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl); | 1239 | v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl, NULL); |
1240 | 1240 | ||
1241 | /* blackbird stuff */ | 1241 | /* blackbird stuff */ |
1242 | printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", | 1242 | printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", |
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index f6fcc7e763ab..a146d50d7795 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c | |||
@@ -1795,7 +1795,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1795 | if (vc->id == V4L2_CID_CHROMA_AGC) | 1795 | if (vc->id == V4L2_CID_CHROMA_AGC) |
1796 | core->chroma_agc = vc; | 1796 | core->chroma_agc = vc; |
1797 | } | 1797 | } |
1798 | v4l2_ctrl_add_handler(&core->video_hdl, &core->audio_hdl); | 1798 | v4l2_ctrl_add_handler(&core->video_hdl, &core->audio_hdl, NULL); |
1799 | 1799 | ||
1800 | /* load and configure helper modules */ | 1800 | /* load and configure helper modules */ |
1801 | 1801 | ||
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c index 40923885977a..ac2ca36039e4 100644 --- a/drivers/media/platform/s5p-fimc/fimc-capture.c +++ b/drivers/media/platform/s5p-fimc/fimc-capture.c | |||
@@ -472,7 +472,7 @@ int fimc_capture_ctrls_create(struct fimc_dev *fimc) | |||
472 | return ret; | 472 | return ret; |
473 | 473 | ||
474 | return v4l2_ctrl_add_handler(&vid_cap->ctx->ctrls.handler, | 474 | return v4l2_ctrl_add_handler(&vid_cap->ctx->ctrls.handler, |
475 | fimc->pipeline.subdevs[IDX_SENSOR]->ctrl_handler); | 475 | fimc->pipeline.subdevs[IDX_SENSOR]->ctrl_handler, NULL); |
476 | } | 476 | } |
477 | 477 | ||
478 | static int fimc_capture_set_default_format(struct fimc_dev *fimc); | 478 | static int fimc_capture_set_default_format(struct fimc_dev *fimc); |
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index f6b1c1f87761..3be92944f8e7 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c | |||
@@ -1184,7 +1184,7 @@ static int soc_camera_probe(struct soc_camera_device *icd) | |||
1184 | sd->grp_id = soc_camera_grp_id(icd); | 1184 | sd->grp_id = soc_camera_grp_id(icd); |
1185 | v4l2_set_subdev_hostdata(sd, icd); | 1185 | v4l2_set_subdev_hostdata(sd, icd); |
1186 | 1186 | ||
1187 | if (v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler)) | 1187 | if (v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler, NULL)) |
1188 | goto ectrl; | 1188 | goto ectrl; |
1189 | 1189 | ||
1190 | /* At this point client .probe() should have run already */ | 1190 | /* At this point client .probe() should have run already */ |
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index f40003550b60..631cdc0e0bda 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
@@ -1687,7 +1687,8 @@ EXPORT_SYMBOL(v4l2_ctrl_add_ctrl); | |||
1687 | 1687 | ||
1688 | /* Add the controls from another handler to our own. */ | 1688 | /* Add the controls from another handler to our own. */ |
1689 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, | 1689 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, |
1690 | struct v4l2_ctrl_handler *add) | 1690 | struct v4l2_ctrl_handler *add, |
1691 | bool (*filter)(const struct v4l2_ctrl *ctrl)) | ||
1691 | { | 1692 | { |
1692 | struct v4l2_ctrl_ref *ref; | 1693 | struct v4l2_ctrl_ref *ref; |
1693 | int ret = 0; | 1694 | int ret = 0; |
@@ -1707,6 +1708,9 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, | |||
1707 | /* And control classes */ | 1708 | /* And control classes */ |
1708 | if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) | 1709 | if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) |
1709 | continue; | 1710 | continue; |
1711 | /* Filter any unwanted controls */ | ||
1712 | if (filter && !filter(ctrl)) | ||
1713 | continue; | ||
1710 | ret = handler_new_ref(hdl, ctrl); | 1714 | ret = handler_new_ref(hdl, ctrl); |
1711 | if (ret) | 1715 | if (ret) |
1712 | break; | 1716 | break; |
@@ -1716,6 +1720,25 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, | |||
1716 | } | 1720 | } |
1717 | EXPORT_SYMBOL(v4l2_ctrl_add_handler); | 1721 | EXPORT_SYMBOL(v4l2_ctrl_add_handler); |
1718 | 1722 | ||
1723 | bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl) | ||
1724 | { | ||
1725 | if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) | ||
1726 | return true; | ||
1727 | switch (ctrl->id) { | ||
1728 | case V4L2_CID_AUDIO_MUTE: | ||
1729 | case V4L2_CID_AUDIO_VOLUME: | ||
1730 | case V4L2_CID_AUDIO_BALANCE: | ||
1731 | case V4L2_CID_AUDIO_BASS: | ||
1732 | case V4L2_CID_AUDIO_TREBLE: | ||
1733 | case V4L2_CID_AUDIO_LOUDNESS: | ||
1734 | return true; | ||
1735 | default: | ||
1736 | break; | ||
1737 | } | ||
1738 | return false; | ||
1739 | } | ||
1740 | EXPORT_SYMBOL(v4l2_ctrl_radio_filter); | ||
1741 | |||
1719 | /* Cluster controls */ | 1742 | /* Cluster controls */ |
1720 | void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls) | 1743 | void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls) |
1721 | { | 1744 | { |
diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 1f203b85a637..513969fa695d 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c | |||
@@ -166,7 +166,7 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
166 | } | 166 | } |
167 | 167 | ||
168 | /* This just returns 0 if either of the two args is NULL */ | 168 | /* This just returns 0 if either of the two args is NULL */ |
169 | err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler); | 169 | err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL); |
170 | if (err) { | 170 | if (err) { |
171 | if (sd->internal_ops && sd->internal_ops->unregistered) | 171 | if (sd->internal_ops && sd->internal_ops->unregistered) |
172 | sd->internal_ops->unregistered(sd); | 172 | sd->internal_ops->unregistered(sd); |
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 6890f5e11ad0..801adb466bd2 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
@@ -384,14 +384,28 @@ struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl, | |||
384 | * @hdl: The control handler. | 384 | * @hdl: The control handler. |
385 | * @add: The control handler whose controls you want to add to | 385 | * @add: The control handler whose controls you want to add to |
386 | * the @hdl control handler. | 386 | * the @hdl control handler. |
387 | * @filter: This function will filter which controls should be added. | ||
387 | * | 388 | * |
388 | * Does nothing if either of the two is a NULL pointer. | 389 | * Does nothing if either of the two handlers is a NULL pointer. |
390 | * If @filter is NULL, then all controls are added. Otherwise only those | ||
391 | * controls for which @filter returns true will be added. | ||
389 | * In case of an error @hdl->error will be set to the error code (if it | 392 | * In case of an error @hdl->error will be set to the error code (if it |
390 | * wasn't set already). | 393 | * wasn't set already). |
391 | */ | 394 | */ |
392 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, | 395 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, |
393 | struct v4l2_ctrl_handler *add); | 396 | struct v4l2_ctrl_handler *add, |
397 | bool (*filter)(const struct v4l2_ctrl *ctrl)); | ||
394 | 398 | ||
399 | /** v4l2_ctrl_radio_filter() - Standard filter for radio controls. | ||
400 | * @ctrl: The control that is filtered. | ||
401 | * | ||
402 | * This will return true for any controls that are valid for radio device | ||
403 | * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM | ||
404 | * transmitter class controls. | ||
405 | * | ||
406 | * This function is to be used with v4l2_ctrl_add_handler(). | ||
407 | */ | ||
408 | bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl); | ||
395 | 409 | ||
396 | /** v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster. | 410 | /** v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging to that cluster. |
397 | * @ncontrols: The number of controls in this cluster. | 411 | * @ncontrols: The number of controls in this cluster. |