Skip to content

Commit 65900c5

Browse files
ribaldamchehab
authored andcommitted
media: uvcvideo: Allow entity-defined get_info and get_cur
Allows controls to get their properties and current value from an entity-defined function instead of via a query to the USB device. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent d9c8763 commit 65900c5

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,20 @@ static int __uvc_ctrl_get(struct uvc_video_chain *chain,
980980
return -EACCES;
981981

982982
if (!ctrl->loaded) {
983-
ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id,
984-
chain->dev->intfnum, ctrl->info.selector,
983+
if (ctrl->entity->get_cur) {
984+
ret = ctrl->entity->get_cur(chain->dev,
985+
ctrl->entity,
986+
ctrl->info.selector,
985987
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
986988
ctrl->info.size);
989+
} else {
990+
ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
991+
ctrl->entity->id,
992+
chain->dev->intfnum,
993+
ctrl->info.selector,
994+
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
995+
ctrl->info.size);
996+
}
987997
if (ret < 0)
988998
return ret;
989999

@@ -1692,8 +1702,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
16921702
if (data == NULL)
16931703
return -ENOMEM;
16941704

1695-
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
1696-
info->selector, data, 1);
1705+
if (ctrl->entity->get_info)
1706+
ret = ctrl->entity->get_info(dev, ctrl->entity,
1707+
ctrl->info.selector, data);
1708+
else
1709+
ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
1710+
dev->intfnum, info->selector, data, 1);
16971711
if (!ret)
16981712
info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
16991713
UVC_CTRL_FLAG_GET_CUR : 0)

drivers/media/usb/uvc/uvcvideo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ struct uvc_entity {
358358
u8 bNrInPins;
359359
u8 *baSourceID;
360360

361+
int (*get_info)(struct uvc_device *dev, struct uvc_entity *entity,
362+
u8 cs, u8 *caps);
363+
int (*get_cur)(struct uvc_device *dev, struct uvc_entity *entity,
364+
u8 cs, void *data, u16 size);
365+
361366
unsigned int ncontrols;
362367
struct uvc_control *controls;
363368
};

0 commit comments

Comments
 (0)