From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: linux-usb@vger.kernel.org, balbi@ti.com, kernel@pengutronix.de,
linux-media@vger.kernel.org, hans.verkuil@cisco.com
Subject: Re: [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT
Date: Tue, 19 Aug 2014 19:01:06 +0200 [thread overview]
Message-ID: <2635639.TQ5HekBxN8@avalon> (raw)
In-Reply-To: <1407512339-8433-3-git-send-email-m.grzeschik@pengutronix.de>
Hi Michael,
Thank you for the patch.
(CC'ing Hans Verkuil and the linux-media mailing list)
On Friday 08 August 2014 17:38:58 Michael Grzeschik wrote:
> 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@pengutronix.de>
> ---
> 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" },
Format descriptions are currently duplicated in every driver, causing higher
memory usage and different descriptions for the same format depending on the
driver. Hans, should we try to fix this ?
> };
>
> static int
> +uvc_v4l2_enum_format(struct uvc_video *video, struct v4l2_fmtdesc *fmt)
> +{
> +
There's an extra blank line here.
> + int index = fmt->index;
You can use fmt->index directly below, there's no need for a local variable.
> + if (index >= ARRAY_SIZE(uvc_formats))
> + return -EINVAL;
> +
> + strcpy(fmt->description, uvc_formats[index].description);
How about strlcpy to make sure we don't overflow the buffer ?
> + 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:
--
Regards,
Laurent Pinchart
next parent reply other threads:[~2014-08-19 17:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1407512339-8433-1-git-send-email-m.grzeschik@pengutronix.de>
[not found] ` <1407512339-8433-3-git-send-email-m.grzeschik@pengutronix.de>
2014-08-19 17:01 ` Laurent Pinchart [this message]
2014-08-20 2:06 ` [PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT Hans Verkuil
2014-08-20 17:05 ` Laurent Pinchart
2014-08-25 13:59 ` Michael Grzeschik
2014-08-25 14:48 ` Laurent Pinchart
2014-08-25 15:13 ` Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2635639.TQ5HekBxN8@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=balbi@ti.com \
--cc=hans.verkuil@cisco.com \
--cc=kernel@pengutronix.de \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).