Skip to content

Commit

Permalink
media: renesas: rzg2l-cru: Add 'yuv' flag to IP format structure
Browse files Browse the repository at this point in the history
Add a 'yuv' flag to the `rzg2l_cru_ip_format` structure to indicate
whether a given format is YUV-based and update the `rzg2l_cru_ip_formats`
array with this flag appropriately. This change enables a more efficient
way to check if the input and output formats use the same colorspace.

With this change, we can eliminate the use of `v4l2_format_info()` in
`rzg2l_cru_initialize_image_conv()` as the necessary details for the source
and destination formats are already available through the `yuv` flag.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-24-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
  • Loading branch information
Lad Prabhakar authored and Hans Verkuil committed Oct 22, 2024
1 parent c0fc8dd commit 2269e39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ struct rzg2l_cru_ip {
* @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 {
u32 code;
u32 datatype;
u32 format;
u32 icndmr;
u8 bpp;
bool yuv;
};

/**
Expand Down
5 changes: 5 additions & 0 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,39 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
.format = V4L2_PIX_FMT_UYVY,
.bpp = 2,
.icndmr = ICnDMR_YCMODE_UYVY,
.yuv = true,
},
{
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
.format = V4L2_PIX_FMT_SBGGR8,
.datatype = MIPI_CSI2_DT_RAW8,
.bpp = 1,
.icndmr = 0,
.yuv = false,
},
{
.code = MEDIA_BUS_FMT_SGBRG8_1X8,
.format = V4L2_PIX_FMT_SGBRG8,
.datatype = MIPI_CSI2_DT_RAW8,
.bpp = 1,
.icndmr = 0,
.yuv = false,
},
{
.code = MEDIA_BUS_FMT_SGRBG8_1X8,
.format = V4L2_PIX_FMT_SGRBG8,
.datatype = MIPI_CSI2_DT_RAW8,
.bpp = 1,
.icndmr = 0,
.yuv = false,
},
{
.code = MEDIA_BUS_FMT_SRGGB8_1X8,
.format = V4L2_PIX_FMT_SRGGB8,
.datatype = MIPI_CSI2_DT_RAW8,
.bpp = 1,
.icndmr = 0,
.yuv = false,
},
};

Expand Down
6 changes: 1 addition & 5 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
struct v4l2_mbus_framefmt *ip_sd_fmt,
u8 csi_vc)
{
const struct v4l2_format_info *src_finfo, *dst_finfo;
const struct rzg2l_cru_ip_format *cru_video_fmt;
const struct rzg2l_cru_ip_format *cru_ip_fmt;

Expand All @@ -225,11 +224,8 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
return -EINVAL;
}

src_finfo = v4l2_format_info(cru_ip_fmt->format);
dst_finfo = v4l2_format_info(cru->format.pixelformat);

/* If input and output use same colorspace, do bypass mode */
if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
if (cru_ip_fmt->yuv == cru_video_fmt->yuv)
rzg2l_cru_write(cru, ICnMC,
rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
else
Expand Down

0 comments on commit 2269e39

Please sign in to comment.