Re: [PATCH 6/8] usb: gadget: uvc: try harder to find a valid format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

Thank you for the patch.

On Thu, Mar 23, 2023 at 12:41:14PM +0100, Michael Tretter wrote:
> The TRY_FMT call should try to avoid returning EINVAL. If the requested
> pixelformat is not supported by the driver, the driver should fall back
> to it's own default and only then fail the request.

It should actually never fail.

You may recall that I didn't like the TRY_FMT implementation, and I
still stand by the arguments I provided by then. If you want to handle
this properly, revert the commits that added format handling to the
driver.

> Signed-off-by: Michael Tretter <m.tretter@xxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/uvc_v4l2.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
> index 3f728f451ed5..c5983bb0a8d1 100644
> --- a/drivers/usb/gadget/function/uvc_v4l2.c
> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
> @@ -317,11 +317,15 @@ uvc_v4l2_try_format(struct file *file, void *fh, struct v4l2_format *fmt)
>  		 fmt->fmt.pix.width, fmt->fmt.pix.height);
>  
>  	uformat = find_format_by_pix(uvc, fmt->fmt.pix.pixelformat);
> +	if (!uformat)
> +		uformat = get_default_format(uvc);
>  	if (!uformat)
>  		return -EINVAL;
>  
>  	uframe = find_closest_frame_by_size(uvc, uformat,
>  				fmt->fmt.pix.width, fmt->fmt.pix.height);
> +	if (!uframe)
> +		uframe = get_default_frame(uvc, uformat);
>  	if (!uframe)
>  		return -EINVAL;
>  

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux