History

[media] media/core: Replace ctrl_class with which

Replace the obsolete field ctrl_class with "which". Make sure it not used in future modules by commenting out the field with ifndef __KERNEL_ . The field cannot be simply removed because that would be change on the kenel API to the userspace (and we don't like that).

Ricardo Ribalda committed 11 years ago

Commit 0f8017b1 parent 35ec2a27 files · +32 −27Browse files

Unified · Split

7 files
  1. Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +3 −3
  2. drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +1 −1
  3. drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +1 −1
  4. drivers/media/v4l2-core/v4l2-compat-ioctl32.c +3 −3
  5. drivers/media/v4l2-core/v4l2-ctrls.c +12 −12
  6. drivers/media/v4l2-core/v4l2-ioctl.c +7 −7
  7. include/uapi/linux/videodev2.h +5 −0
Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml+3−3
@@ -61,7 +61,7 @@ must belong to the same control class.</para> · 60 unmodified lines
61 61
62 <para>Applications must always fill in the62 <para>Applications must always fill in the
63<structfield>count</structfield>,63<structfield>count</structfield>,
64<structfield>ctrl_class</structfield>,64<structfield>which</structfield>,
65<structfield>controls</structfield> and65<structfield>controls</structfield> and
66<structfield>reserved</structfield> fields of &v4l2-ext-controls;, and66<structfield>reserved</structfield> fields of &v4l2-ext-controls;, and
67initialize the &v4l2-ext-control; array pointed to by the67initialize the &v4l2-ext-control; array pointed to by the
@@ -109,7 +109,7 @@ the driver whether wrong values are automatically adjusted to a valid · 41 unmodified lines
109value or if an error is returned.</para>109value or if an error is returned.</para>
110 110
111 <para>When the <structfield>id</structfield> or111 <para>When the <structfield>id</structfield> or
112<structfield>ctrl_class</structfield> is invalid drivers return an112<structfield>which</structfield> is invalid drivers return an
113&EINVAL;. When the value is out of bounds drivers can choose to take113&EINVAL;. When the value is out of bounds drivers can choose to take
114the closest valid value or return an &ERANGE;, whatever seems more114the closest valid value or return an &ERANGE;, whatever seems more
115appropriate. In the first case the new value is set in115appropriate. In the first case the new value is set in
@@ -390,7 +390,7 @@ These controls are described in <xref linkend="rf-tuner-controls" />.</entry> · 274 unmodified lines
390 <listitem>390 <listitem>
391 <para>The &v4l2-ext-control; <structfield>id</structfield>391 <para>The &v4l2-ext-control; <structfield>id</structfield>
392is invalid, the &v4l2-ext-controls;392is invalid, the &v4l2-ext-controls;
393<structfield>ctrl_class</structfield> is invalid, or the &v4l2-ext-control;393<structfield>which</structfield> is invalid, or the &v4l2-ext-control;
394<structfield>value</structfield> was inappropriate (e.g. the given menu394<structfield>value</structfield> was inappropriate (e.g. the given menu
395index is not supported by the driver). This error code is395index is not supported by the driver). This error code is
396also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and396also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c+1−1
@@ -1119,7 +1119,7 @@ const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void) · 1118 unmodified lines
1119 return &s5p_mfc_dec_ioctl_ops;1119 return &s5p_mfc_dec_ioctl_ops;
1120}1120}
1121 1121
1122#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \1122#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \
1123 && V4L2_CTRL_DRIVER_PRIV(x))1123 && V4L2_CTRL_DRIVER_PRIV(x))
1124 1124
1125int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx)1125int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx)
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c+1−1
@@ -2067,7 +2067,7 @@ const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void) · 2066 unmodified lines
2067 return &s5p_mfc_enc_ioctl_ops;2067 return &s5p_mfc_enc_ioctl_ops;
2068}2068}
2069 2069
2070#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2CLASS(x) == V4L2_CTRL_CLASS_MPEG) \2070#define IS_MFC51_PRIV(x) ((V4L2_CTRL_ID2WHICH(x) == V4L2_CTRL_CLASS_MPEG) \
2071 && V4L2_CTRL_DRIVER_PRIV(x))2071 && V4L2_CTRL_DRIVER_PRIV(x))
2072 2072
2073int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)2073int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c+3−3
@@ -630,7 +630,7 @@ static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __ · 629 unmodified lines
630}630}
631 631
632struct v4l2_ext_controls32 {632struct v4l2_ext_controls32 {
633 __u32 ctrl_class;633 __u32 which;
634 __u32 count;634 __u32 count;
635 __u32 error_idx;635 __u32 error_idx;
636 __u32 reserved[2];636 __u32 reserved[2];
@@ -673,7 +673,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext · 36 unmodified lines
673 compat_caddr_t p;673 compat_caddr_t p;
674 674
675 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) ||675 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) ||
676 get_user(kp->ctrl_class, &up->ctrl_class) ||676 get_user(kp->which, &up->which) ||
677 get_user(kp->count, &up->count) ||677 get_user(kp->count, &up->count) ||
678 get_user(kp->error_idx, &up->error_idx) ||678 get_user(kp->error_idx, &up->error_idx) ||
679 copy_from_user(kp->reserved, up->reserved,679 copy_from_user(kp->reserved, up->reserved,
@@ -723,7 +723,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext · 43 unmodified lines
723 compat_caddr_t p;723 compat_caddr_t p;
724 724
725 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) ||725 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) ||
726 put_user(kp->ctrl_class, &up->ctrl_class) ||726 put_user(kp->which, &up->which) ||
727 put_user(kp->count, &up->count) ||727 put_user(kp->count, &up->count) ||
728 put_user(kp->error_idx, &up->error_idx) ||728 put_user(kp->error_idx, &up->error_idx) ||
729 copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved)))729 copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved)))
drivers/media/v4l2-core/v4l2-ctrls.c+12−12
@@ -1762,7 +1762,7 @@ static struct v4l2_ctrl_ref *find_private_ref( · 1761 unmodified lines
1762 list_for_each_entry(ref, &hdl->ctrl_refs, node) {1762 list_for_each_entry(ref, &hdl->ctrl_refs, node) {
1763 /* Search for private user controls that are compatible with1763 /* Search for private user controls that are compatible with
1764 VIDIOC_G/S_CTRL. */1764 VIDIOC_G/S_CTRL. */
1765 if (V4L2_CTRL_ID2CLASS(ref->ctrl->id) == V4L2_CTRL_CLASS_USER &&1765 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER &&
1766 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) {1766 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) {
1767 if (!ref->ctrl->is_int)1767 if (!ref->ctrl->is_int)
1768 continue;1768 continue;
@@ -1831,7 +1831,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl, · 62 unmodified lines
1831 struct v4l2_ctrl_ref *ref;1831 struct v4l2_ctrl_ref *ref;
1832 struct v4l2_ctrl_ref *new_ref;1832 struct v4l2_ctrl_ref *new_ref;
1833 u32 id = ctrl->id;1833 u32 id = ctrl->id;
1834 u32 class_ctrl = V4L2_CTRL_ID2CLASS(id) | 1;1834 u32 class_ctrl = V4L2_CTRL_ID2WHICH(id) | 1;
1835 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */1835 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */
1836 1836
1837 /*1837 /*
@@ -2253,9 +2253,9 @@ EXPORT_SYMBOL(v4l2_ctrl_add_handler); · 415 unmodified lines
2253 2253
2254bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl)2254bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl)
2255{2255{
2256 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)2256 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)
2257 return true;2257 return true;
2258 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_RX)2258 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX)
2259 return true;2259 return true;
2260 switch (ctrl->id) {2260 switch (ctrl->id) {
2261 case V4L2_CID_AUDIO_MUTE:2261 case V4L2_CID_AUDIO_MUTE:
@@ -2710,7 +2710,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, · 448 unmodified lines
2710 2710
2711 cs->error_idx = i;2711 cs->error_idx = i;
2712 2712
2713 if (cs->ctrl_class && V4L2_CTRL_ID2CLASS(id) != cs->ctrl_class)2713 if (cs->which && V4L2_CTRL_ID2WHICH(id) != cs->which)
2714 return -EINVAL;2714 return -EINVAL;
2715 2715
2716 /* Old-style private controls are not allowed for2716 /* Old-style private controls are not allowed for
@@ -2787,11 +2787,11 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, · 70 unmodified lines
2787/* Handles the corner case where cs->count == 0. It checks whether the2787/* Handles the corner case where cs->count == 0. It checks whether the
2788 specified control class exists. If that class ID is 0, then it checks2788 specified control class exists. If that class ID is 0, then it checks
2789 whether there are any controls at all. */2789 whether there are any controls at all. */
2790static int class_check(struct v4l2_ctrl_handler *hdl, u32 ctrl_class)2790static int class_check(struct v4l2_ctrl_handler *hdl, u32 which)
2791{2791{
2792 if (ctrl_class == 0)2792 if (!which)
2793 return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0;2793 return list_empty(&hdl->ctrl_refs) ? -EINVAL : 0;
2794 return find_ref_lock(hdl, ctrl_class | 1) ? 0 : -EINVAL;2794 return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL;
2795}2795}
2796 2796
2797 2797
@@ -2805,13 +2805,13 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs · 7 unmodified lines
2805 int i, j;2805 int i, j;
2806 2806
2807 cs->error_idx = cs->count;2807 cs->error_idx = cs->count;
2808 cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class);2808 cs->which = V4L2_CTRL_ID2WHICH(cs->which);
2809 2809
2810 if (hdl == NULL)2810 if (hdl == NULL)
2811 return -EINVAL;2811 return -EINVAL;
2812 2812
2813 if (cs->count == 0)2813 if (cs->count == 0)
2814 return class_check(hdl, cs->ctrl_class);2814 return class_check(hdl, cs->which);
2815 2815
2816 if (cs->count > ARRAY_SIZE(helper)) {2816 if (cs->count > ARRAY_SIZE(helper)) {
2817 helpers = kmalloc_array(cs->count, sizeof(helper[0]),2817 helpers = kmalloc_array(cs->count, sizeof(helper[0]),
@@ -3064,13 +3064,13 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, · 246 unmodified lines
3064 int ret;3064 int ret;
3065 3065
3066 cs->error_idx = cs->count;3066 cs->error_idx = cs->count;
3067 cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class);3067 cs->which = V4L2_CTRL_ID2WHICH(cs->which);
3068 3068
3069 if (hdl == NULL)3069 if (hdl == NULL)
3070 return -EINVAL;3070 return -EINVAL;
3071 3071
3072 if (cs->count == 0)3072 if (cs->count == 0)
3073 return class_check(hdl, cs->ctrl_class);3073 return class_check(hdl, cs->which);
3074 3074
3075 if (cs->count > ARRAY_SIZE(helper)) {3075 if (cs->count > ARRAY_SIZE(helper)) {
3076 helpers = kmalloc_array(cs->count, sizeof(helper[0]),3076 helpers = kmalloc_array(cs->count, sizeof(helper[0]),
drivers/media/v4l2-core/v4l2-ioctl.c+7−7
@@ -565,8 +565,8 @@ static void v4l_print_ext_controls(const void *arg, bool write_only) · 564 unmodified lines
565 const struct v4l2_ext_controls *p = arg;565 const struct v4l2_ext_controls *p = arg;
566 int i;566 int i;
567 567
568 pr_cont("class=0x%x, count=%d, error_idx=%d",568 pr_cont("which=0x%x, count=%d, error_idx=%d",
569 p->ctrl_class, p->count, p->error_idx);569 p->which, p->count, p->error_idx);
570 for (i = 0; i < p->count; i++) {570 for (i = 0; i < p->count; i++) {
571 if (!p->controls[i].size)571 if (!p->controls[i].size)
572 pr_cont(", id/val=0x%x/0x%x",572 pr_cont(", id/val=0x%x/0x%x",
@@ -902,13 +902,13 @@ static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) · 329 unmodified lines
902 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL902 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
903 is it allowed for backwards compatibility.903 is it allowed for backwards compatibility.
904 */904 */
905 if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)905 if (!allow_priv && c->which == V4L2_CID_PRIVATE_BASE)
906 return 0;906 return 0;
907 if (c->ctrl_class == 0)907 if (!c->which)
908 return 1;908 return 1;
909 /* Check that all controls are from the same control class. */909 /* Check that all controls are from the same control class. */
910 for (i = 0; i < c->count; i++) {910 for (i = 0; i < c->count; i++) {
911 if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) {911 if (V4L2_CTRL_ID2WHICH(c->controls[i].id) != c->which) {
912 c->error_idx = i;912 c->error_idx = i;
913 return 0;913 return 0;
914 }914 }
@@ -1969,7 +1969,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, · 1054 unmodified lines
1969 if (ops->vidioc_g_ext_ctrls == NULL)1969 if (ops->vidioc_g_ext_ctrls == NULL)
1970 return -ENOTTY;1970 return -ENOTTY;
1971 1971
1972 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);1972 ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
1973 ctrls.count = 1;1973 ctrls.count = 1;
1974 ctrls.controls = &ctrl;1974 ctrls.controls = &ctrl;
1975 ctrl.id = p->id;1975 ctrl.id = p->id;
@@ -2003,7 +2003,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, · 27 unmodified lines
2003 if (ops->vidioc_s_ext_ctrls == NULL)2003 if (ops->vidioc_s_ext_ctrls == NULL)
2004 return -ENOTTY;2004 return -ENOTTY;
2005 2005
2006 ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);2006 ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
2007 ctrls.count = 1;2007 ctrls.count = 1;
2008 ctrls.controls = &ctrl;2008 ctrls.controls = &ctrl;
2009 ctrl.id = p->id;2009 ctrl.id = p->id;
include/uapi/linux/videodev2.h+5−0
@@ -1477,7 +1477,9 @@ struct v4l2_ext_control { · 1476 unmodified lines
1477 1477
1478struct v4l2_ext_controls {1478struct v4l2_ext_controls {
1479 union {1479 union {
1480#ifndef __KERNEL__
1480 __u32 ctrl_class;1481 __u32 ctrl_class;
1482#endif
1481 __u32 which;1483 __u32 which;
1482 };1484 };
1483 __u32 count;1485 __u32 count;
@@ -1487,7 +1489,10 @@ struct v4l2_ext_controls { · 3 unmodified lines
1487};1489};
1488 1490
1489#define V4L2_CTRL_ID_MASK (0x0fffffff)1491#define V4L2_CTRL_ID_MASK (0x0fffffff)
1492#ifndef __KERNEL__
1490#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)1493#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
1494#endif
1495#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL)
1491#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)1496#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
1492#define V4L2_CTRL_MAX_DIMS (4)1497#define V4L2_CTRL_MAX_DIMS (4)
1493#define V4L2_CTRL_WHICH_CUR_VAL 01498#define V4L2_CTRL_WHICH_CUR_VAL 0

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t