[PATCH v2 03/17] media: rockchip: rga: move early return into if condition in vidioc_enum_fmt

Nicolas Dufresne nicolas at ndufresne.ca
Tue Nov 24 12:46:21 PST 2026


Le mercredi 16 septembre 2026 à 17:09 +0200, Sven Püschel a écrit :
> Instead of a doing an early return when we don't have a capture device,
> merge the condition with the following if condition. This improves
> readability, as the condition now explicitly contains a check for a
> capture device instead of returning when we don't have a capture device.
> 
> Also use the V4L2_TYPE_IS_CAPTURE helper and improve the comment.
> 
> The early return if was copied from the vivid drivers
> vivid_enum_fmt_vid function.
> 
> Signed-off-by: Sven Püschel <s.pueschel at pengutronix.de>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

> ---
>  drivers/media/platform/rockchip/rga/rga.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index efe5541078214..8c03422d669cf 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -372,12 +372,14 @@ static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f
>  	if (ret != 0)
>  		return ret;
>  
> -	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
> -	    f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> -		return 0;
> -
> -	/* allow changing the quantization and xfer func for YUV formats */
> -	if (v4l2_is_format_yuv(v4l2_format_info(f->pixelformat)))
> +	/*
> +	 * Allow changing the quantization and ycbcr_enc func for YUV formats
> +	 * on the capture side for RGB -> YUV conversions.
> +	 *
> +	 * These flags are only relevant for capture devices.
> +	 */
> +	if (V4L2_TYPE_IS_CAPTURE(f->type) &&
> +	    v4l2_is_format_yuv(v4l2_format_info(f->pixelformat)))
>  		f->flags |= V4L2_FMT_FLAG_CSC_QUANTIZATION |
>  			    V4L2_FMT_FLAG_CSC_YCBCR_ENC;
>  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20261124/243411e1/attachment-0001.sig>


More information about the Linux-rockchip mailing list