This patch adds ENUM_FMT as possible ioctl to the uvc v4l2 device. That makes userspace applications with a generic IOCTL calling convention make also use of it. Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> --- v1 -> v2: - changed first switch case to simple if - added separate function - added description field - bail out on array boundaries drivers/usb/gadget/uvc_v4l2.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c index ad48e81..58633bf 100644 --- a/drivers/usb/gadget/uvc_v4l2.c +++ b/drivers/usb/gadget/uvc_v4l2.c @@ -55,14 +55,30 @@ struct uvc_format { u8 bpp; u32 fcc; + char *description; }; static struct uvc_format uvc_formats[] = { - { 16, V4L2_PIX_FMT_YUYV }, - { 0, V4L2_PIX_FMT_MJPEG }, + { 16, V4L2_PIX_FMT_YUYV, "YUV 4:2:2" }, + { 0, V4L2_PIX_FMT_MJPEG, "MJPEG" }, }; static int +uvc_v4l2_enum_format(struct uvc_video *video, struct v4l2_fmtdesc *fmt) +{ + + int index = fmt->index; + + if (index >= ARRAY_SIZE(uvc_formats)) + return -EINVAL; + + strcpy(fmt->description, uvc_formats[index].description); + fmt->pixelformat = uvc_formats[index].fcc; + + return 0; +} + +static int uvc_v4l2_get_format(struct uvc_video *video, struct v4l2_format *fmt) { fmt->fmt.pix.pixelformat = video->fcc; @@ -183,6 +199,16 @@ uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) break; } + case VIDIOC_ENUM_FMT: + { + struct v4l2_fmtdesc *fmt = arg; + + if (fmt->type != video->queue.queue.type) + return -EINVAL; + + return uvc_v4l2_enum_format(video, fmt); + } + /* Get & Set format */ case VIDIOC_G_FMT: { -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html