aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
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/media/v4l2-core
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/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c25
-rw-r--r--drivers/media/v4l2-core/v4l2-device.c2
2 files changed, 25 insertions, 2 deletions
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);