]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: platform: rzg2l-cru: Use v4l2_fill_pixfmt()
authorDaniel Scally <dan.scally+renesas@ideasonboard.com>
Wed, 25 Jun 2025 09:20:30 +0000 (10:20 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 3 Jul 2025 07:04:14 +0000 (09:04 +0200)
Rather than open-code a calculation of the format's bytesperline
and sizeimage, use the v4l2_fill_pixfmt() helper. This makes it
easier to support the CRU packed pixel formats without over
complicating the driver.

This change makes the .bpp member of struct rzg2l_cru_ip_format
superfluous - remove them.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Daniel Scally <dan.scally+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20250625-rzg2l-cru-v6-4-a9099ed26c14@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c

index 56feda6e6207a17ca747566eb7f535d13da9b0df..bba174973ac34aa13cded0bde6a4e522abef6873 100644 (file)
@@ -68,7 +68,6 @@ struct rzg2l_cru_ip {
  * @datatype: MIPI CSI2 data type
  * @format: 4CC format identifier (V4L2_PIX_FMT_*)
  * @icndmr: ICnDMR register value
- * @bpp: bytes per pixel
  * @yuv: Flag to indicate whether the format is YUV-based.
  */
 struct rzg2l_cru_ip_format {
@@ -76,7 +75,6 @@ struct rzg2l_cru_ip_format {
        u32 datatype;
        u32 format;
        u32 icndmr;
-       u8 bpp;
        bool yuv;
 };
 
index 7836c7cd53dc3ff9a2c8c5e53be0265a20956e30..15fc1028082add27ad3d6fa9e1314b6240ff0d4e 100644 (file)
@@ -16,7 +16,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
                .code = MEDIA_BUS_FMT_UYVY8_1X16,
                .datatype = MIPI_CSI2_DT_YUV422_8B,
                .format = V4L2_PIX_FMT_UYVY,
-               .bpp = 2,
                .icndmr = ICnDMR_YCMODE_UYVY,
                .yuv = true,
        },
@@ -24,7 +23,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
                .code = MEDIA_BUS_FMT_SBGGR8_1X8,
                .format = V4L2_PIX_FMT_SBGGR8,
                .datatype = MIPI_CSI2_DT_RAW8,
-               .bpp = 1,
                .icndmr = 0,
                .yuv = false,
        },
@@ -32,7 +30,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
                .code = MEDIA_BUS_FMT_SGBRG8_1X8,
                .format = V4L2_PIX_FMT_SGBRG8,
                .datatype = MIPI_CSI2_DT_RAW8,
-               .bpp = 1,
                .icndmr = 0,
                .yuv = false,
        },
@@ -40,7 +37,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
                .code = MEDIA_BUS_FMT_SGRBG8_1X8,
                .format = V4L2_PIX_FMT_SGRBG8,
                .datatype = MIPI_CSI2_DT_RAW8,
-               .bpp = 1,
                .icndmr = 0,
                .yuv = false,
        },
@@ -48,7 +44,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
                .code = MEDIA_BUS_FMT_SRGGB8_1X8,
                .format = V4L2_PIX_FMT_SRGGB8,
                .datatype = MIPI_CSI2_DT_RAW8,
-               .bpp = 1,
                .icndmr = 0,
                .yuv = false,
        },
index 042a6bd4469794d2137755da012febfe7e2a8fa8..e151e659760997aee04984c88dfc32ecfba2164c 100644 (file)
@@ -939,15 +939,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
        v4l_bound_align_image(&pix->width, 320, info->max_width, 1,
                              &pix->height, 240, info->max_height, 2, 0);
 
-       if (info->has_stride) {
-               u32 stride = clamp(pix->bytesperline, pix->width * fmt->bpp,
-                                  RZG2L_CRU_STRIDE_MAX);
-               pix->bytesperline = round_up(stride, RZG2L_CRU_STRIDE_ALIGN);
-       } else {
-               pix->bytesperline = pix->width * fmt->bpp;
-       }
-
-       pix->sizeimage = pix->bytesperline * pix->height;
+       v4l2_fill_pixfmt(pix, pix->pixelformat, pix->width, pix->height);
 
        dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
                pix->width, pix->height, pix->bytesperline, pix->sizeimage);