Commit 96a160b0 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Laurent Pinchart

media: uvcvideo: Refactor uvc_ctrl_mappings_uvcXX

Convert the array of structs into an array of pointers, that way the
mappings can be reused.
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 40140eda
...@@ -723,34 +723,40 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -723,34 +723,40 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
}; };
static const struct uvc_control_mapping uvc_ctrl_mappings_uvc11[] = { static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc11 = {
{ .id = V4L2_CID_POWER_LINE_FREQUENCY,
.id = V4L2_CID_POWER_LINE_FREQUENCY, .entity = UVC_GUID_UVC_PROCESSING,
.entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
.selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, .size = 2,
.size = 2, .offset = 0,
.offset = 0, .v4l2_type = V4L2_CTRL_TYPE_MENU,
.v4l2_type = V4L2_CTRL_TYPE_MENU, .data_type = UVC_CTRL_DATA_TYPE_ENUM,
.data_type = UVC_CTRL_DATA_TYPE_ENUM, .menu_info = power_line_frequency_controls,
.menu_info = power_line_frequency_controls, .menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
.menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_60HZ, V4L2_CID_POWER_LINE_FREQUENCY_DISABLED),
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED),
},
}; };
static const struct uvc_control_mapping uvc_ctrl_mappings_uvc15[] = { static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc11[] = {
{ &uvc_ctrl_power_line_mapping_uvc11,
.id = V4L2_CID_POWER_LINE_FREQUENCY, NULL, /* Sentinel */
.entity = UVC_GUID_UVC_PROCESSING, };
.selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
.size = 2, static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_uvc15 = {
.offset = 0, .id = V4L2_CID_POWER_LINE_FREQUENCY,
.v4l2_type = V4L2_CTRL_TYPE_MENU, .entity = UVC_GUID_UVC_PROCESSING,
.data_type = UVC_CTRL_DATA_TYPE_ENUM, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
.menu_info = power_line_frequency_controls, .size = 2,
.menu_mask = GENMASK(V4L2_CID_POWER_LINE_FREQUENCY_AUTO, .offset = 0,
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED), .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_AUTO,
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED),
};
static const struct uvc_control_mapping *uvc_ctrl_mappings_uvc15[] = {
&uvc_ctrl_power_line_mapping_uvc15,
NULL, /* Sentinel */
}; };
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
...@@ -2506,8 +2512,7 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev, ...@@ -2506,8 +2512,7 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev,
static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
struct uvc_control *ctrl) struct uvc_control *ctrl)
{ {
const struct uvc_control_mapping *mappings; const struct uvc_control_mapping **mappings;
unsigned int num_mappings;
unsigned int i; unsigned int i;
/* /*
...@@ -2574,16 +2579,11 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain, ...@@ -2574,16 +2579,11 @@ static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
} }
/* Finally process version-specific mappings. */ /* Finally process version-specific mappings. */
if (chain->dev->uvc_version < 0x0150) { mappings = chain->dev->uvc_version < 0x0150
mappings = uvc_ctrl_mappings_uvc11; ? uvc_ctrl_mappings_uvc11 : uvc_ctrl_mappings_uvc15;
num_mappings = ARRAY_SIZE(uvc_ctrl_mappings_uvc11);
} else {
mappings = uvc_ctrl_mappings_uvc15;
num_mappings = ARRAY_SIZE(uvc_ctrl_mappings_uvc15);
}
for (i = 0; i < num_mappings; ++i) { for (i = 0; mappings[i]; ++i) {
const struct uvc_control_mapping *mapping = &mappings[i]; const struct uvc_control_mapping *mapping = mappings[i];
if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
ctrl->info.selector == mapping->selector) ctrl->info.selector == mapping->selector)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment