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

From: Sven Püschel

Date: Fri Jun 05 2026 - 18:09:34 EST


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@xxxxxxxxxxxxxx>
---
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;


--
2.54.0