Skip to content

Commit

Permalink
media: rzg2l-cru: Refactor ICnDMR register configuration
Browse files Browse the repository at this point in the history
Refactor the ICnDMR register configuration in
`rzg2l_cru_initialize_image_conv()` by adding a new member `icndmr` in the
`rzg2l_cru_ip_format` structure.

Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
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-21-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 cd559c8 commit c6ed80f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 4 additions & 0 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define RZG2L_CRU_MIN_INPUT_HEIGHT 240
#define RZG2L_CRU_MAX_INPUT_HEIGHT 4095

#define ICnDMR_YCMODE_UYVY (1 << 4)

enum rzg2l_csi2_pads {
RZG2L_CRU_IP_SINK = 0,
RZG2L_CRU_IP_SOURCE,
Expand Down Expand Up @@ -67,12 +69,14 @@ struct rzg2l_cru_ip {
* @code: Media bus code
* @datatype: MIPI CSI2 data type
* @format: 4CC format identifier (V4L2_PIX_FMT_*)
* @icndmr: ICnDMR register value
* @bpp: bytes per pixel
*/
struct rzg2l_cru_ip_format {
u32 code;
u32 datatype;
u32 format;
u32 icndmr;
u8 bpp;
};

Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
.datatype = MIPI_CSI2_DT_YUV422_8B,
.format = V4L2_PIX_FMT_UYVY,
.bpp = 2,
.icndmr = ICnDMR_YCMODE_UYVY,
},
};

Expand Down
12 changes: 4 additions & 8 deletions drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@

/* CRU Data Output Mode Register */
#define ICnDMR 0x26c
#define ICnDMR_YCMODE_UYVY (1 << 4)

#define RZG2L_TIMEOUT_MS 100
#define RZG2L_RETRIES 10
Expand Down Expand Up @@ -279,18 +278,15 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
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;
u32 icndmr;

cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
rzg2l_cru_csi2_setup(cru, cru_ip_fmt, csi_vc);

/* Output format */
switch (cru->format.pixelformat) {
case V4L2_PIX_FMT_UYVY:
icndmr = ICnDMR_YCMODE_UYVY;
break;
default:
cru_video_fmt = rzg2l_cru_ip_format_to_fmt(cru->format.pixelformat);
if (!cru_video_fmt) {
dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
cru->format.pixelformat);
return -EINVAL;
Expand All @@ -308,7 +304,7 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
rzg2l_cru_read(cru, ICnMC) & (~ICnMC_CSCTHR));

/* Set output data format */
rzg2l_cru_write(cru, ICnDMR, icndmr);
rzg2l_cru_write(cru, ICnDMR, cru_video_fmt->icndmr);

return 0;
}
Expand Down

0 comments on commit c6ed80f

Please sign in to comment.