Skip to content

Commit 2269e39

Browse files
prabhakarladhverkuil
authored andcommitted
media: renesas: rzg2l-cru: Add 'yuv' flag to IP format structure
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>
1 parent c0fc8dd commit 2269e39

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ struct rzg2l_cru_ip {
6969
* @format: 4CC format identifier (V4L2_PIX_FMT_*)
7070
* @icndmr: ICnDMR register value
7171
* @bpp: bytes per pixel
72+
* @yuv: Flag to indicate whether the format is YUV-based.
7273
*/
7374
struct rzg2l_cru_ip_format {
7475
u32 code;
7576
u32 datatype;
7677
u32 format;
7778
u32 icndmr;
7879
u8 bpp;
80+
bool yuv;
7981
};
8082

8183
/**

drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,39 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
1818
.format = V4L2_PIX_FMT_UYVY,
1919
.bpp = 2,
2020
.icndmr = ICnDMR_YCMODE_UYVY,
21+
.yuv = true,
2122
},
2223
{
2324
.code = MEDIA_BUS_FMT_SBGGR8_1X8,
2425
.format = V4L2_PIX_FMT_SBGGR8,
2526
.datatype = MIPI_CSI2_DT_RAW8,
2627
.bpp = 1,
2728
.icndmr = 0,
29+
.yuv = false,
2830
},
2931
{
3032
.code = MEDIA_BUS_FMT_SGBRG8_1X8,
3133
.format = V4L2_PIX_FMT_SGBRG8,
3234
.datatype = MIPI_CSI2_DT_RAW8,
3335
.bpp = 1,
3436
.icndmr = 0,
37+
.yuv = false,
3538
},
3639
{
3740
.code = MEDIA_BUS_FMT_SGRBG8_1X8,
3841
.format = V4L2_PIX_FMT_SGRBG8,
3942
.datatype = MIPI_CSI2_DT_RAW8,
4043
.bpp = 1,
4144
.icndmr = 0,
45+
.yuv = false,
4246
},
4347
{
4448
.code = MEDIA_BUS_FMT_SRGGB8_1X8,
4549
.format = V4L2_PIX_FMT_SRGGB8,
4650
.datatype = MIPI_CSI2_DT_RAW8,
4751
.bpp = 1,
4852
.icndmr = 0,
53+
.yuv = false,
4954
},
5055
};
5156

drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
210210
struct v4l2_mbus_framefmt *ip_sd_fmt,
211211
u8 csi_vc)
212212
{
213-
const struct v4l2_format_info *src_finfo, *dst_finfo;
214213
const struct rzg2l_cru_ip_format *cru_video_fmt;
215214
const struct rzg2l_cru_ip_format *cru_ip_fmt;
216215

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

228-
src_finfo = v4l2_format_info(cru_ip_fmt->format);
229-
dst_finfo = v4l2_format_info(cru->format.pixelformat);
230-
231227
/* If input and output use same colorspace, do bypass mode */
232-
if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
228+
if (cru_ip_fmt->yuv == cru_video_fmt->yuv)
233229
rzg2l_cru_write(cru, ICnMC,
234230
rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
235231
else

0 commit comments

Comments
 (0)