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
6161
6262 <para>Applications must always fill in the
6363 <structfield>count</structfield>,
64−<structfield>ctrl_class</structfield>,
64+<structfield>which</structfield>,
6565 <structfield>controls</structfield> and
6666 <structfield>reserved</structfield> fields of &v4l2-ext-controls;, and
6767 initialize 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
109109 value or if an error is returned.</para>
110110
111111 <para>When the <structfield>id</structfield> or
112−<structfield>ctrl_class</structfield> is invalid drivers return an
112+<structfield>which</structfield> is invalid drivers return an
113113 &EINVAL;. When the value is out of bounds drivers can choose to take
114114 the closest valid value or return an &ERANGE;, whatever seems more
115115 appropriate. 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
390390 <listitem>
391391 <para>The &v4l2-ext-control; <structfield>id</structfield>
392392 is 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;
394394 <structfield>value</structfield> was inappropriate (e.g. the given menu
395395 index is not supported by the driver). This error code is
396396 also 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
11191119 return &s5p_mfc_dec_ioctl_ops;
11201120 }
11211121
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) \
11231123 && V4L2_CTRL_DRIVER_PRIV(x))
11241124
11251125 int 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
20672067 return &s5p_mfc_enc_ioctl_ops;
20682068 }
20692069
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) \
20712071 && V4L2_CTRL_DRIVER_PRIV(x))
20722072
20732073 int 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
630630 }
631631
632632 struct v4l2_ext_controls32 {
633− __u32 ctrl_class;
633+ __u32 which;
634634 __u32 count;
635635 __u32 error_idx;
636636 __u32 reserved[2];
@@ -673,7 +673,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext · 36 unmodified lines
673673 compat_caddr_t p;
674674
675675 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) ||
677677 get_user(kp->count, &up->count) ||
678678 get_user(kp->error_idx, &up->error_idx) ||
679679 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
723723 compat_caddr_t p;
724724
725725 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) ||
727727 put_user(kp->count, &up->count) ||
728728 put_user(kp->error_idx, &up->error_idx) ||
729729 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
17621762 list_for_each_entry(ref, &hdl->ctrl_refs, node) {
17631763 /* Search for private user controls that are compatible with
17641764 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 &&
17661766 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) {
17671767 if (!ref->ctrl->is_int)
17681768 continue;
@@ -1831,7 +1831,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl, · 62 unmodified lines
18311831 struct v4l2_ctrl_ref *ref;
18321832 struct v4l2_ctrl_ref *new_ref;
18331833 u32 id = ctrl->id;
1834− u32 class_ctrl = V4L2_CTRL_ID2CLASS(id) | 1;
1834+ u32 class_ctrl = V4L2_CTRL_ID2WHICH(id) | 1;
18351835 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */
18361836
18371837 /*
@@ -2253,9 +2253,9 @@ EXPORT_SYMBOL(v4l2_ctrl_add_handler); · 415 unmodified lines
22532253
22542254 bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl)
22552255 {
2256− if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)
2256+ if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX)
22572257 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)
22592259 return true;
22602260 switch (ctrl->id) {
22612261 case V4L2_CID_AUDIO_MUTE:
@@ -2710,7 +2710,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, · 448 unmodified lines
27102710
27112711 cs->error_idx = i;
27122712
2713− if (cs->ctrl_class && V4L2_CTRL_ID2CLASS(id) != cs->ctrl_class)
2713+ if (cs->which && V4L2_CTRL_ID2WHICH(id) != cs->which)
27142714 return -EINVAL;
27152715
27162716 /* 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
27872787 /* Handles the corner case where cs->count == 0. It checks whether the
27882788 specified control class exists. If that class ID is 0, then it checks
27892789 whether there are any controls at all. */
2790−static int class_check(struct v4l2_ctrl_handler *hdl, u32 ctrl_class)
2790+static int class_check(struct v4l2_ctrl_handler *hdl, u32 which)
27912791 {
2792− if (ctrl_class == 0)
2792+ if (!which)
27932793 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;
27952795 }
27962796
27972797
@@ -2805,13 +2805,13 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs · 7 unmodified lines
28052805 int i, j;
28062806
28072807 cs->error_idx = cs->count;
2808− cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class);
2808+ cs->which = V4L2_CTRL_ID2WHICH(cs->which);
28092809
28102810 if (hdl == NULL)
28112811 return -EINVAL;
28122812
28132813 if (cs->count == 0)
2814− return class_check(hdl, cs->ctrl_class);
2814+ return class_check(hdl, cs->which);
28152815
28162816 if (cs->count > ARRAY_SIZE(helper)) {
28172817 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
30643064 int ret;
30653065
30663066 cs->error_idx = cs->count;
3067− cs->ctrl_class = V4L2_CTRL_ID2CLASS(cs->ctrl_class);
3067+ cs->which = V4L2_CTRL_ID2WHICH(cs->which);
30683068
30693069 if (hdl == NULL)
30703070 return -EINVAL;
30713071
30723072 if (cs->count == 0)
3073− return class_check(hdl, cs->ctrl_class);
3073+ return class_check(hdl, cs->which);
30743074
30753075 if (cs->count > ARRAY_SIZE(helper)) {
30763076 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
565565 const struct v4l2_ext_controls *p = arg;
566566 int i;
567567
568− pr_cont("class=0x%x, count=%d, error_idx=%d",
569− p->ctrl_class, p->count, p->error_idx);
568+ pr_cont("which=0x%x, count=%d, error_idx=%d",
569+ p->which, p->count, p->error_idx);
570570 for (i = 0; i < p->count; i++) {
571571 if (!p->controls[i].size)
572572 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
902902 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
903903 is it allowed for backwards compatibility.
904904 */
905− if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE)
905+ if (!allow_priv && c->which == V4L2_CID_PRIVATE_BASE)
906906 return 0;
907− if (c->ctrl_class == 0)
907+ if (!c->which)
908908 return 1;
909909 /* Check that all controls are from the same control class. */
910910 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) {
912912 c->error_idx = i;
913913 return 0;
914914 }
@@ -1969,7 +1969,7 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, · 1054 unmodified lines
19691969 if (ops->vidioc_g_ext_ctrls == NULL)
19701970 return -ENOTTY;
19711971
1972− ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
1972+ ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
19731973 ctrls.count = 1;
19741974 ctrls.controls = &ctrl;
19751975 ctrl.id = p->id;
@@ -2003,7 +2003,7 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, · 27 unmodified lines
20032003 if (ops->vidioc_s_ext_ctrls == NULL)
20042004 return -ENOTTY;
20052005
2006− ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id);
2006+ ctrls.which = V4L2_CTRL_ID2WHICH(p->id);
20072007 ctrls.count = 1;
20082008 ctrls.controls = &ctrl;
20092009 ctrl.id = p->id;
include/uapi/linux/videodev2.h+5−0
@@ -1477,7 +1477,9 @@ struct v4l2_ext_control { · 1476 unmodified lines
14771477
14781478 struct v4l2_ext_controls {
14791479 union {
1480+#ifndef __KERNEL__
14801481 __u32 ctrl_class;
1482+#endif
14811483 __u32 which;
14821484 };
14831485 __u32 count;
@@ -1487,7 +1489,10 @@ struct v4l2_ext_controls { · 3 unmodified lines
14871489 };
14881490
14891491 #define V4L2_CTRL_ID_MASK (0x0fffffff)
1492+#ifndef __KERNEL__
14901493 #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
1494+#endif
1495+#define V4L2_CTRL_ID2WHICH(id) ((id) & 0x0fff0000UL)
14911496 #define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
14921497 #define V4L2_CTRL_MAX_DIMS (4)
14931498 #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