Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223391
b: refs/heads/master
c: 23d9f3e
h: refs/heads/master
i:
  223389: 96c61f1
  223387: 5d24fd1
  223383: 2144455
  223375: beefce2
  223359: 02f68c9
v: v3
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Dec 1, 2010
1 parent 5e84d02 commit bd6ba77
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca9afe6f87b569cdf8e797395381f18ae23a2905
refs/heads/master: 23d9f3ef23f0dc4bb20ccd5540b9a91ff08da08f
48 changes: 47 additions & 1 deletion trunk/drivers/media/video/uvc/uvc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static void __uvc_find_control(struct uvc_entity *entity, __u32 v4l2_id,
}
}

struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
static struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
__u32 v4l2_id, struct uvc_control_mapping **mapping)
{
struct uvc_control *ctrl = NULL;
Expand Down Expand Up @@ -944,6 +944,52 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
return ret;
}

/*
* Mapping V4L2 controls to UVC controls can be straighforward if done well.
* Most of the UVC controls exist in V4L2, and can be mapped directly. Some
* must be grouped (for instance the Red Balance, Blue Balance and Do White
* Balance V4L2 controls use the White Balance Component UVC control) or
* otherwise translated. The approach we take here is to use a translation
* table for the controls that can be mapped directly, and handle the others
* manually.
*/
int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
struct v4l2_querymenu *query_menu)
{
struct uvc_menu_info *menu_info;
struct uvc_control_mapping *mapping;
struct uvc_control *ctrl;
u32 index = query_menu->index;
u32 id = query_menu->id;
int ret;

memset(query_menu, 0, sizeof(*query_menu));
query_menu->id = id;
query_menu->index = index;

ret = mutex_lock_interruptible(&chain->ctrl_mutex);
if (ret < 0)
return -ERESTARTSYS;

ctrl = uvc_find_control(chain, query_menu->id, &mapping);
if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) {
ret = -EINVAL;
goto done;
}

if (query_menu->index >= mapping->menu_count) {
ret = -EINVAL;
goto done;
}

menu_info = &mapping->menu_info[query_menu->index];
strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);

done:
mutex_unlock(&chain->ctrl_mutex);
return ret;
}


/* --------------------------------------------------------------------------
* Control transactions
Expand Down
36 changes: 1 addition & 35 deletions trunk/drivers/media/video/uvc/uvc_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,6 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
* V4L2 interface
*/

/*
* Mapping V4L2 controls to UVC controls can be straighforward if done well.
* Most of the UVC controls exist in V4L2, and can be mapped directly. Some
* must be grouped (for instance the Red Balance, Blue Balance and Do White
* Balance V4L2 controls use the White Balance Component UVC control) or
* otherwise translated. The approach we take here is to use a translation
* table for the controls that can be mapped directly, and handle the others
* manually.
*/
static int uvc_v4l2_query_menu(struct uvc_video_chain *chain,
struct v4l2_querymenu *query_menu)
{
struct uvc_menu_info *menu_info;
struct uvc_control_mapping *mapping;
struct uvc_control *ctrl;
u32 index = query_menu->index;
u32 id = query_menu->id;

ctrl = uvc_find_control(chain, query_menu->id, &mapping);
if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)
return -EINVAL;

if (query_menu->index >= mapping->menu_count)
return -EINVAL;

memset(query_menu, 0, sizeof(*query_menu));
query_menu->id = id;
query_menu->index = index;

menu_info = &mapping->menu_info[query_menu->index];
strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);
return 0;
}

/*
* Find the frame interval closest to the requested frame interval for the
* given frame format and size. This should be done by the device as part of
Expand Down Expand Up @@ -624,7 +590,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
}

case VIDIOC_QUERYMENU:
return uvc_v4l2_query_menu(chain, arg);
return uvc_query_v4l2_menu(chain, arg);

case VIDIOC_G_EXT_CTRLS:
{
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/media/video/uvc/uvcvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,10 @@ extern int uvc_status_suspend(struct uvc_device *dev);
extern int uvc_status_resume(struct uvc_device *dev);

/* Controls */
extern struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
__u32 v4l2_id, struct uvc_control_mapping **mapping);
extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
struct v4l2_queryctrl *v4l2_ctrl);
extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
struct v4l2_querymenu *query_menu);

extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
const struct uvc_control_mapping *mapping);
Expand Down

0 comments on commit bd6ba77

Please sign in to comment.