aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-09-14 06:15:03 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-01 16:07:07 -0400
commit34a6b7d093d8fe738ada191b36648d00bc18b7eb (patch)
tree854584731068996a381af03b95884911c07074b5 /drivers
parenta4f64407b9b33122a58cb78afd73f86d4bb022c4 (diff)
[media] v4l2-ctrls: add a filter function to v4l2_ctrl_add_handler
With a filter function you can control more precisely which controls are added. This is useful in particular for radio device nodes for combined TV/Radio cards where you want to show just the radio-specific controls and not controls like brightness. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/pci/cx88/cx88-video.c2
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c2
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c25
-rw-r--r--drivers/media/v4l2-core/v4l2-device.c2
6 files changed, 29 insertions, 6 deletions
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
478static int fimc_capture_set_default_format(struct fimc_dev *fimc); 478static 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. */
1689int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, 1689int 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}
1717EXPORT_SYMBOL(v4l2_ctrl_add_handler); 1721EXPORT_SYMBOL(v4l2_ctrl_add_handler);
1718 1722
1723bool 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}
1740EXPORT_SYMBOL(v4l2_ctrl_radio_filter);
1741
1719/* Cluster controls */ 1742/* Cluster controls */
1720void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls) 1743void 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);