Commit 3aa8628e authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Laurent Pinchart
Browse files

media: uvcvideo: Refactor power_line_frequency_controls_limited



Move the control mapping to uvc_ctrl.c. This way we do not have
references to UVC controls or V4L2 controls in uvc_driver.c.

This also fixes a bug introduced in commit 38207560 ("media:
uvcvideo: Limit power line control for Quanta UVC Webcam"). The
offending commit caused the power line control menu entries to have
incorrect indices compared to the V4L2_CID_POWER_LINE_FREQUENCY_*
enumeration. Now that the limited mapping reuses the correct menu_info
array, the indices correctly map to the V4L2 control specification.

Fixes: 38207560 ("media: uvcvideo: Limit power line control for Quanta UVC Webcam")
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 96a160b0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -723,6 +723,19 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
	},
};

const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
	.entity		= UVC_GUID_UVC_PROCESSING,
	.selector	= UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
	.size		= 2,
	.offset		= 0,
	.v4l2_type	= V4L2_CTRL_TYPE_MENU,
	.data_type	= UVC_CTRL_DATA_TYPE_ENUM,
	.menu_info	= power_line_frequency_controls,
	.menu_mask	= GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
				  V4L2_CID_POWER_LINE_FREQUENCY_50HZ),
};

static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = {
	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
	.entity		= UVC_GUID_UVC_PROCESSING,
+0 −18
Original line number Diff line number Diff line
@@ -2358,24 +2358,6 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
 * Driver initialization and cleanup
 */

static const struct uvc_menu_info power_line_frequency_controls_limited[] = {
	{ 1, "50 Hz" },
	{ 2, "60 Hz" },
};

static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
	.id		= V4L2_CID_POWER_LINE_FREQUENCY,
	.entity		= UVC_GUID_UVC_PROCESSING,
	.selector	= UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
	.size		= 2,
	.offset		= 0,
	.v4l2_type	= V4L2_CTRL_TYPE_MENU,
	.data_type	= UVC_CTRL_DATA_TYPE_ENUM,
	.menu_info	= power_line_frequency_controls_limited,
	.menu_mask	=
		GENMASK(ARRAY_SIZE(power_line_frequency_controls_limited) - 1, 0),
};

static const struct uvc_device_info uvc_ctrl_power_line_limited = {
	.mappings = (const struct uvc_control_mapping *[]) {
		&uvc_ctrl_power_line_mapping_limited,
+1 −0
Original line number Diff line number Diff line
@@ -745,6 +745,7 @@ int uvc_status_start(struct uvc_device *dev, gfp_t flags);
void uvc_status_stop(struct uvc_device *dev);

/* Controls */
extern const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited;
extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;

int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,