From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Michael Tretter <m.tretter@pengutronix.de>
Cc: Daniel Scally <dan.scally@ideasonboard.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Grzeschik <m.grzeschik@pengutronix.de>,
linux-usb@vger.kernel.org, linux-media@vger.kernel.org,
kernel@pengutronix.de
Subject: Re: [PATCH 7/8] usb: gadget: uvc: add colorspace handling
Date: Fri, 24 Mar 2023 11:33:46 +0200 [thread overview]
Message-ID: <20230324093346.GH18895@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230323-uvc-gadget-cleanup-v1-7-e41f0c5d9d8e@pengutronix.de>
Hi Michael,
Thank you for the patch.
On Thu, Mar 23, 2023 at 12:41:15PM +0100, Michael Tretter wrote:
> Store the values of the configured color space in the driver. This
> allows the user space to set the color space and re-read the set values
> later.
>
> UVC allows to announce the colorspace in the USB descriptors. The values
> of the descriptors are not evaluated by the driver, yet. Thus, the
> default is always the default specified by UVC and not the configured
> default.
As with format handling and frame interval handling, I don't like this.
It's useless code that userspace won't exercise.
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> drivers/usb/gadget/function/uvc.h | 4 ++++
> drivers/usb/gadget/function/uvc_v4l2.c | 32 ++++++++++++++++++++++++++++++--
> 2 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
> index 100475b1363e..6b4ab3e07173 100644
> --- a/drivers/usb/gadget/function/uvc.h
> +++ b/drivers/usb/gadget/function/uvc.h
> @@ -96,6 +96,10 @@ struct uvc_video {
> unsigned int width;
> unsigned int height;
> unsigned int imagesize;
> + enum v4l2_colorspace colorspace;
> + enum v4l2_ycbcr_encoding ycbcr_enc;
> + enum v4l2_quantization quantization;
> + enum v4l2_xfer_func xfer_func;
> struct mutex mutex; /* protects frame parameters */
>
> unsigned int uvc_num_requests;
> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
> index c5983bb0a8d1..673532ff0faa 100644
> --- a/drivers/usb/gadget/function/uvc_v4l2.c
> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
> @@ -180,6 +180,11 @@ void uvc_init_default_format(struct uvc_device *uvc)
> video->height = 240;
> video->imagesize = 320 * 240 * 2;
>
> + video->colorspace = V4L2_COLORSPACE_SRGB;
> + video->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> + video->xfer_func = V4L2_XFER_FUNC_SRGB;
> + video->ycbcr_enc = V4L2_YCBCR_ENC_601;
> +
> return;
> }
>
> @@ -196,6 +201,14 @@ void uvc_init_default_format(struct uvc_device *uvc)
> video->width = uframe->frame.w_width;
> video->height = uframe->frame.w_height;
> video->imagesize = uvc_get_frame_size(uformat, uframe);
> +
> + if (uformat->type == UVCG_UNCOMPRESSED)
> + video->colorspace = V4L2_COLORSPACE_SRGB;
> + else
> + video->colorspace = V4L2_COLORSPACE_JPEG;
> + video->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> + video->xfer_func = V4L2_XFER_FUNC_SRGB;
> + video->ycbcr_enc = V4L2_YCBCR_ENC_601;
> }
>
> static struct uvcg_frame *find_closest_frame_by_size(struct uvc_device *uvc,
> @@ -294,7 +307,12 @@ uvc_v4l2_get_format(struct file *file, void *fh, struct v4l2_format *fmt)
> fmt->fmt.pix.field = V4L2_FIELD_NONE;
> fmt->fmt.pix.bytesperline = video->bpp * video->width / 8;
> fmt->fmt.pix.sizeimage = video->imagesize;
> - fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
> +
> + fmt->fmt.pix.colorspace = video->colorspace;
> + fmt->fmt.pix.ycbcr_enc = video->ycbcr_enc;
> + fmt->fmt.pix.quantization = video->quantization;
> + fmt->fmt.pix.xfer_func = video->xfer_func;
> +
> fmt->fmt.pix.priv = 0;
>
> return 0;
> @@ -335,7 +353,12 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
> fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(uformat, uframe);
> fmt->fmt.pix.sizeimage = uvc_get_frame_size(uformat, uframe);
> fmt->fmt.pix.pixelformat = to_uvc_format(uformat)->fcc;
> - fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
> +
> + fmt->fmt.pix.colorspace = video->colorspace;
> + fmt->fmt.pix.ycbcr_enc = video->ycbcr_enc;
> + fmt->fmt.pix.quantization = video->quantization;
> + fmt->fmt.pix.xfer_func = video->xfer_func;
> +
> fmt->fmt.pix.priv = 0;
>
> return 0;
> @@ -359,6 +382,11 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
> video->height = fmt->fmt.pix.height;
> video->imagesize = fmt->fmt.pix.sizeimage;
>
> + video->colorspace = fmt->fmt.pix.colorspace;
> + video->ycbcr_enc = fmt->fmt.pix.ycbcr_enc;
> + video->quantization = fmt->fmt.pix.quantization;
> + video->xfer_func = fmt->fmt.pix.xfer_func;
> +
> return ret;
> }
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-03-24 9:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 11:41 [PATCH 0/8] usb: gadget: uvc: fix errors reported by v4l2-compliance Michael Tretter
2023-03-23 11:41 ` [PATCH 1/8] usb: gadget: uvc: use fourcc printk helper Michael Tretter
2023-03-24 7:44 ` Dan Scally
2023-03-24 9:21 ` Laurent Pinchart
2023-03-23 11:41 ` [PATCH 2/8] usb: gadget: uvc: fix return code of REQBUFS Michael Tretter
2023-03-24 7:50 ` Dan Scally
2023-03-24 9:25 ` Laurent Pinchart
2023-03-23 11:41 ` [PATCH 3/8] usb: gadget: uvc: implement s/g_output ioctl Michael Tretter
2023-03-24 9:20 ` Laurent Pinchart
2023-03-24 9:21 ` Dan Scally
2023-03-24 9:39 ` Hans Verkuil
2023-03-24 9:49 ` Laurent Pinchart
2023-03-23 11:41 ` [PATCH 4/8] usb: gadget: uvc: move video format initialization to uvc_v4l2 Michael Tretter
2023-03-24 9:31 ` Laurent Pinchart
2023-03-23 11:41 ` [PATCH 5/8] usb: gadget: uvc: initialize video format using configfs Michael Tretter
2023-03-23 11:41 ` [PATCH 6/8] usb: gadget: uvc: try harder to find a valid format Michael Tretter
2023-03-24 9:35 ` Laurent Pinchart
2023-03-23 11:41 ` [PATCH 7/8] usb: gadget: uvc: add colorspace handling Michael Tretter
2023-03-24 9:33 ` Laurent Pinchart [this message]
2023-03-23 11:41 ` [PATCH 8/8] usb: gadget: uvc: implement s/g_parm Michael Tretter
2023-03-23 18:02 ` kernel test robot
2023-03-24 9:32 ` Laurent Pinchart
2023-03-24 9:38 ` [PATCH 0/8] usb: gadget: uvc: fix errors reported by v4l2-compliance Laurent Pinchart
2023-03-27 12:26 ` Michael Tretter
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=20230324093346.GH18895@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=m.tretter@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