Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb74d48

Browse files
jwrdegoedeMauro Carvalho Chehab
authored andcommitted
[media] uvcvideo: Move __uvc_ctrl_get() up
This avoids the need for doing a forward declaration of __uvc_ctrl_get (which is a static function) in later patches in this series. Note to reviewers this patch does not change a single line of code, it just moves the function up in uvc_ctrl.c a bit. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 35f1674 commit cb74d48

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

drivers/media/video/uvc/uvc_ctrl.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,44 @@ static int uvc_ctrl_populate_cache(struct uvc_video_chain *chain,
899899
return 0;
900900
}
901901

902+
static int __uvc_ctrl_get(struct uvc_video_chain *chain,
903+
struct uvc_control *ctrl, struct uvc_control_mapping *mapping,
904+
s32 *value)
905+
{
906+
struct uvc_menu_info *menu;
907+
unsigned int i;
908+
int ret;
909+
910+
if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
911+
return -EINVAL;
912+
913+
if (!ctrl->loaded) {
914+
ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id,
915+
chain->dev->intfnum, ctrl->info.selector,
916+
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
917+
ctrl->info.size);
918+
if (ret < 0)
919+
return ret;
920+
921+
ctrl->loaded = 1;
922+
}
923+
924+
*value = mapping->get(mapping, UVC_GET_CUR,
925+
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
926+
927+
if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
928+
menu = mapping->menu_info;
929+
for (i = 0; i < mapping->menu_count; ++i, ++menu) {
930+
if (menu->value == *value) {
931+
*value = i;
932+
break;
933+
}
934+
}
935+
}
936+
937+
return 0;
938+
}
939+
902940
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
903941
struct uvc_control *ctrl,
904942
struct uvc_control_mapping *mapping,
@@ -1158,44 +1196,6 @@ int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback)
11581196
return ret;
11591197
}
11601198

1161-
static int __uvc_ctrl_get(struct uvc_video_chain *chain,
1162-
struct uvc_control *ctrl, struct uvc_control_mapping *mapping,
1163-
s32 *value)
1164-
{
1165-
struct uvc_menu_info *menu;
1166-
unsigned int i;
1167-
int ret;
1168-
1169-
if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
1170-
return -EINVAL;
1171-
1172-
if (!ctrl->loaded) {
1173-
ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id,
1174-
chain->dev->intfnum, ctrl->info.selector,
1175-
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
1176-
ctrl->info.size);
1177-
if (ret < 0)
1178-
return ret;
1179-
1180-
ctrl->loaded = 1;
1181-
}
1182-
1183-
*value = mapping->get(mapping, UVC_GET_CUR,
1184-
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
1185-
1186-
if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
1187-
menu = mapping->menu_info;
1188-
for (i = 0; i < mapping->menu_count; ++i, ++menu) {
1189-
if (menu->value == *value) {
1190-
*value = i;
1191-
break;
1192-
}
1193-
}
1194-
}
1195-
1196-
return 0;
1197-
}
1198-
11991199
int uvc_ctrl_get(struct uvc_video_chain *chain,
12001200
struct v4l2_ext_control *xctrl)
12011201
{

0 commit comments

Comments
 (0)