On Wed Jun 25 10:20:30 2025 +0100, Daniel Scally wrote:
> 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.mo...@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+rene...@ideasonboard.com>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad...@bp.renesas.com>
> Tested-by: Lad Prabhakar <prabhakar.mahadev-lad...@bp.renesas.com>
> Signed-off-by: Daniel Scally <dan.scally+rene...@ideasonboard.com>
> Link: 
> https://lore.kernel.org/r/20250625-rzg2l-cru-v6-4-a9099ed26...@ideasonboard.com
> Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h   |  2 --
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c    |  5 -----
 drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 10 +---------
 3 files changed, 1 insertion(+), 16 deletions(-)

---

diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 56feda6e6207..bba174973ac3 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -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;
 };
 
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 7836c7cd53dc..15fc1028082a 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -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,
        },
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c 
b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 042a6bd44697..e151e6597609 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -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);

Reply via email to