Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: uvcvideo: Handle uvc menu translation inside uvc_set_le_value

Be consistent with uvc_get_le_value() and do the menu translation there.

Note that in this case, the refactor does not provide much... but
consistency is a nice feature.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Yunke Cao <yunkec@google.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20250203-uvc-roi-v17-5-5900a9fed613@chromium.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Ricardo Ribalda and committed by
Hans Verkuil
7f1556a5 9109a0b4

+19 -11
+19 -11
drivers/media/usb/uvc/uvc_ctrl.c
··· 939 939 int offset = mapping->offset; 940 940 u8 mask; 941 941 942 - /* 943 - * According to the v4l2 spec, writing any value to a button control 944 - * should result in the action belonging to the button control being 945 - * triggered. UVC devices however want to see a 1 written -> override 946 - * value. 947 - */ 948 - if (mapping->v4l2_type == V4L2_CTRL_TYPE_BUTTON) 942 + switch (mapping->v4l2_type) { 943 + case V4L2_CTRL_TYPE_MENU: 944 + value = uvc_mapping_get_menu_value(mapping, value); 945 + break; 946 + case V4L2_CTRL_TYPE_BUTTON: 947 + /* 948 + * According to the v4l2 spec, writing any value to a button 949 + * control should result in the action belonging to the button 950 + * control being triggered. UVC devices however want to see a 1 951 + * written -> override value. 952 + */ 949 953 value = -1; 954 + break; 955 + default: 956 + break; 957 + } 950 958 951 959 data += offset / 8; 952 960 offset &= 7; ··· 2041 2033 if (!test_bit(xctrl->value, &mapping->menu_mask)) 2042 2034 return -EINVAL; 2043 2035 2044 - value = uvc_mapping_get_menu_value(mapping, xctrl->value); 2045 - 2046 2036 /* 2047 2037 * Valid menu indices are reported by the GET_RES request for 2048 2038 * UVC controls that support it. 2049 2039 */ 2050 2040 if (mapping->data_type == UVC_CTRL_DATA_TYPE_BITMASK) { 2041 + int val = uvc_mapping_get_menu_value(mapping, 2042 + xctrl->value); 2051 2043 if (!ctrl->cached) { 2052 2044 ret = uvc_ctrl_populate_cache(chain, ctrl); 2053 2045 if (ret < 0) 2054 2046 return ret; 2055 2047 } 2056 2048 2057 - if (!(uvc_get_ctrl_bitmap(ctrl, mapping) & value)) 2049 + if (!(uvc_get_ctrl_bitmap(ctrl, mapping) & val)) 2058 2050 return -EINVAL; 2059 2051 } 2060 - 2052 + value = xctrl->value; 2061 2053 break; 2062 2054 2063 2055 default: