* [PATCH v5 01/22] media: rzg2l-cru: Use RZG2L_CRU_IP_SINK/SOURCE enum entries
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 02/22] media: rzg2l-cru: Mark sink and source pad with MUST_CONNECT flag Prabhakar
` (20 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Use enum values (`RZG2L_CRU_IP_SINK` and `RZG2L_CRU_IP_SOURCE`) instead
of hardcoded array indices.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index ac8ebae4ed07..9f0ea1de50da 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -217,8 +217,8 @@ int rzg2l_cru_ip_subdev_register(struct rzg2l_cru_dev *cru)
ip->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
ip->subdev.entity.ops = &rzg2l_cru_ip_entity_ops;
- ip->pads[0].flags = MEDIA_PAD_FL_SINK;
- ip->pads[1].flags = MEDIA_PAD_FL_SOURCE;
+ ip->pads[RZG2L_CRU_IP_SINK].flags = MEDIA_PAD_FL_SINK;
+ ip->pads[RZG2L_CRU_IP_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
ret = media_entity_pads_init(&ip->subdev.entity, 2, ip->pads);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 02/22] media: rzg2l-cru: Mark sink and source pad with MUST_CONNECT flag
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
2024-10-11 17:30 ` [PATCH v5 01/22] media: rzg2l-cru: Use RZG2L_CRU_IP_SINK/SOURCE enum entries Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 03/22] media: rzg2l-cru: csi2: " Prabhakar
` (19 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Mark the sink and source pad with the MEDIA_PAD_FL_MUST_CONNECT flag to
ensure pipeline validation fails if it is not connected.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c | 2 +-
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
index 19e0ba9596c9..69cd45b26951 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
@@ -209,7 +209,7 @@ static int rzg2l_cru_media_init(struct rzg2l_cru_dev *cru)
const struct of_device_id *match;
int ret;
- cru->pad.flags = MEDIA_PAD_FL_SINK;
+ cru->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT;
ret = media_entity_pads_init(&cru->vdev.entity, 1, &cru->pad);
if (ret)
return ret;
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 9f0ea1de50da..700d8b704689 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -217,8 +217,10 @@ int rzg2l_cru_ip_subdev_register(struct rzg2l_cru_dev *cru)
ip->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
ip->subdev.entity.ops = &rzg2l_cru_ip_entity_ops;
- ip->pads[RZG2L_CRU_IP_SINK].flags = MEDIA_PAD_FL_SINK;
- ip->pads[RZG2L_CRU_IP_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+ ip->pads[RZG2L_CRU_IP_SINK].flags = MEDIA_PAD_FL_SINK |
+ MEDIA_PAD_FL_MUST_CONNECT;
+ ip->pads[RZG2L_CRU_IP_SOURCE].flags = MEDIA_PAD_FL_SOURCE |
+ MEDIA_PAD_FL_MUST_CONNECT;
ret = media_entity_pads_init(&ip->subdev.entity, 2, ip->pads);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 03/22] media: rzg2l-cru: csi2: Mark sink and source pad with MUST_CONNECT flag
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
2024-10-11 17:30 ` [PATCH v5 01/22] media: rzg2l-cru: Use RZG2L_CRU_IP_SINK/SOURCE enum entries Prabhakar
2024-10-11 17:30 ` [PATCH v5 02/22] media: rzg2l-cru: Mark sink and source pad with MUST_CONNECT flag Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 04/22] media: rzg2l-cru: csi2: Use ARRAY_SIZE() in media_entity_pads_init() Prabhakar
` (18 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Mark the sink and source pad with the MEDIA_PAD_FL_MUST_CONNECT flag to
ensure pipeline validation fails if it is not connected.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index c7fdee347ac8..2f4c87ede8bf 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -795,13 +795,15 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
csi2->subdev.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
csi2->subdev.entity.ops = &rzg2l_csi2_entity_ops;
- csi2->pads[RZG2L_CSI2_SINK].flags = MEDIA_PAD_FL_SINK;
+ csi2->pads[RZG2L_CSI2_SINK].flags = MEDIA_PAD_FL_SINK |
+ MEDIA_PAD_FL_MUST_CONNECT;
/*
* TODO: RZ/G2L CSI2 supports 4 virtual channels, as virtual
* channels should be implemented by streams API which is under
* development lets hardcode to VC0 for now.
*/
- csi2->pads[RZG2L_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
+ csi2->pads[RZG2L_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE |
+ MEDIA_PAD_FL_MUST_CONNECT;
ret = media_entity_pads_init(&csi2->subdev.entity, 2, csi2->pads);
if (ret)
goto error_pm;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 04/22] media: rzg2l-cru: csi2: Use ARRAY_SIZE() in media_entity_pads_init()
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (2 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 03/22] media: rzg2l-cru: csi2: " Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 05/22] media: rzg2l-cru: csi2: Implement .get_frame_desc() Prabhakar
` (17 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The media_entity_pads_init() function was previously hardcoded to use a
magic number for the number of pads. Replace the magic number with the
ARRAY_SIZE() macro to determine the number of pads dynamically.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index 2f4c87ede8bf..abacf53b944c 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -804,7 +804,8 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
*/
csi2->pads[RZG2L_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE |
MEDIA_PAD_FL_MUST_CONNECT;
- ret = media_entity_pads_init(&csi2->subdev.entity, 2, csi2->pads);
+ ret = media_entity_pads_init(&csi2->subdev.entity, ARRAY_SIZE(csi2->pads),
+ csi2->pads);
if (ret)
goto error_pm;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 05/22] media: rzg2l-cru: csi2: Implement .get_frame_desc()
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (3 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 04/22] media: rzg2l-cru: csi2: Use ARRAY_SIZE() in media_entity_pads_init() Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 06/22] media: rzg2l-cru: Retrieve virtual channel information Prabhakar
` (16 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar, Laurent Pinchart
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The RZ/G2L CRU requires information about which VCx to process data from,
among the four available VCs. To obtain this information, the
.get_frame_desc() routine is implemented. This routine, in turn, calls
.get_frame_desc() on the remote sensor connected to the CSI2 bridge.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-csi2.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index abacf53b944c..3fd0be6a3b65 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -582,6 +582,25 @@ static int rzg2l_csi2_enum_frame_size(struct v4l2_subdev *sd,
return 0;
}
+static int rzg2l_csi2_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ struct rzg2l_csi2 *csi2 = sd_to_csi2(sd);
+ struct media_pad *remote_pad;
+
+ if (!csi2->remote_source)
+ return -ENODEV;
+
+ remote_pad = media_pad_remote_pad_unique(&csi2->pads[RZG2L_CSI2_SINK]);
+ if (IS_ERR(remote_pad)) {
+ dev_err(csi2->dev, "can't get source pad of %s (%ld)\n",
+ csi2->remote_source->name, PTR_ERR(remote_pad));
+ return PTR_ERR(remote_pad);
+ }
+ return v4l2_subdev_call(csi2->remote_source, pad, get_frame_desc,
+ remote_pad->index, fd);
+}
+
static const struct v4l2_subdev_video_ops rzg2l_csi2_video_ops = {
.s_stream = rzg2l_csi2_s_stream,
.pre_streamon = rzg2l_csi2_pre_streamon,
@@ -593,6 +612,7 @@ static const struct v4l2_subdev_pad_ops rzg2l_csi2_pad_ops = {
.enum_frame_size = rzg2l_csi2_enum_frame_size,
.set_fmt = rzg2l_csi2_set_format,
.get_fmt = v4l2_subdev_get_fmt,
+ .get_frame_desc = rzg2l_csi2_get_frame_desc,
};
static const struct v4l2_subdev_ops rzg2l_csi2_subdev_ops = {
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 06/22] media: rzg2l-cru: Retrieve virtual channel information
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (4 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 05/22] media: rzg2l-cru: csi2: Implement .get_frame_desc() Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 07/22] media: rzg2l-cru: Remove `channel` member from `struct rzg2l_cru_csi` Prabhakar
` (15 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar, Laurent Pinchart
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The RZ/G2L CRU needs to configure the ICnMC.VCSEL bits to specify which
virtual channel should be processed from the four available VCs. To
retrieve this information from the connected subdevice, the
.get_frame_desc() function is called.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-cru.h | 5 +++
.../platform/renesas/rzg2l-cru/rzg2l-ip.c | 5 ---
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 34 +++++++++++++++++++
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 174760239548..8fbd45c43763 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -31,6 +31,11 @@
#define RZG2L_CRU_MIN_INPUT_HEIGHT 240
#define RZG2L_CRU_MAX_INPUT_HEIGHT 4095
+enum rzg2l_csi2_pads {
+ RZG2L_CRU_IP_SINK = 0,
+ RZG2L_CRU_IP_SOURCE,
+};
+
/**
* enum rzg2l_cru_dma_state - DMA states
* @RZG2L_CRU_DMA_STOPPED: No operation in progress
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 700d8b704689..aee7d4ba70b0 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -18,11 +18,6 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
{ .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, .bpp = 16 },
};
-enum rzg2l_csi2_pads {
- RZG2L_CRU_IP_SINK = 0,
- RZG2L_CRU_IP_SOURCE,
-};
-
static const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
{
unsigned int i;
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index bbf4674f888d..7cd33eb1939c 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -433,12 +433,46 @@ void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru)
spin_unlock_irqrestore(&cru->qlock, flags);
}
+static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru)
+{
+ struct v4l2_mbus_frame_desc fd = { };
+ struct media_pad *remote_pad;
+ int ret;
+
+ remote_pad = media_pad_remote_pad_unique(&cru->ip.pads[RZG2L_CRU_IP_SINK]);
+ ret = v4l2_subdev_call(cru->ip.remote, pad, get_frame_desc, remote_pad->index, &fd);
+ if (ret < 0 && ret != -ENOIOCTLCMD) {
+ dev_err(cru->dev, "get_frame_desc failed on IP remote subdev\n");
+ return ret;
+ }
+ /* If remote subdev does not implement .get_frame_desc default to VC0. */
+ if (ret == -ENOIOCTLCMD)
+ return 0;
+
+ if (fd.type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) {
+ dev_err(cru->dev, "get_frame_desc returned invalid bus type %d\n", fd.type);
+ return -EINVAL;
+ }
+
+ if (!fd.num_entries) {
+ dev_err(cru->dev, "get_frame_desc returned zero entries\n");
+ return -EINVAL;
+ }
+
+ return fd.entry[0].bus.csi2.vc;
+}
+
int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
{
struct v4l2_mbus_framefmt *fmt = rzg2l_cru_ip_get_src_fmt(cru);
unsigned long flags;
int ret;
+ ret = rzg2l_cru_get_virtual_channel(cru);
+ if (ret < 0)
+ return ret;
+ cru->csi.channel = ret;
+
spin_lock_irqsave(&cru->qlock, flags);
/* Select a video input */
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 07/22] media: rzg2l-cru: Remove `channel` member from `struct rzg2l_cru_csi`
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (5 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 06/22] media: rzg2l-cru: Retrieve virtual channel information Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 08/22] media: rzg2l-cru: Use MIPI CSI-2 data types for ICnMC_INF definitions Prabhakar
` (14 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Remove the CSI virtual channel number from `struct rzg2l_cru_csi`.
Instead, pass the CSI virtual channel number as an argument to
`rzg2l_cru_csi2_setup()`.
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>
---
.../media/platform/renesas/rzg2l-cru/rzg2l-core.c | 1 -
.../media/platform/renesas/rzg2l-cru/rzg2l-cru.h | 1 -
.../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 14 ++++++++------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
index 69cd45b26951..b21a66e2ce5c 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
@@ -72,7 +72,6 @@ static int rzg2l_cru_group_notify_complete(struct v4l2_async_notifier *notifier)
source->name, sink->name);
return ret;
}
- cru->csi.channel = 0;
cru->ip.remote = cru->csi.subdev;
/* Create media device link between CRU IP <-> CRU OUTPUT */
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 8fbd45c43763..4fe24bdde5b2 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -53,7 +53,6 @@ enum rzg2l_cru_dma_state {
struct rzg2l_cru_csi {
struct v4l2_async_connection *asd;
struct v4l2_subdev *subdev;
- u32 channel;
};
struct rzg2l_cru_ip {
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 7cd33eb1939c..9ab7ef33c9da 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -301,7 +301,7 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
}
static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
- struct v4l2_mbus_framefmt *ip_sd_fmt)
+ struct v4l2_mbus_framefmt *ip_sd_fmt, u8 csi_vc)
{
u32 icnmc;
@@ -319,19 +319,20 @@ static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
/* Set virtual channel CSI2 */
- icnmc |= ICnMC_VCSEL(cru->csi.channel);
+ icnmc |= ICnMC_VCSEL(csi_vc);
rzg2l_cru_write(cru, ICnMC, icnmc);
}
static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
- struct v4l2_mbus_framefmt *ip_sd_fmt)
+ struct v4l2_mbus_framefmt *ip_sd_fmt,
+ u8 csi_vc)
{
bool output_is_yuv = false;
bool input_is_yuv = false;
u32 icndmr;
- rzg2l_cru_csi2_setup(cru, &input_is_yuv, ip_sd_fmt);
+ rzg2l_cru_csi2_setup(cru, &input_is_yuv, ip_sd_fmt, csi_vc);
/* Output format */
switch (cru->format.pixelformat) {
@@ -466,12 +467,13 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
{
struct v4l2_mbus_framefmt *fmt = rzg2l_cru_ip_get_src_fmt(cru);
unsigned long flags;
+ u8 csi_vc;
int ret;
ret = rzg2l_cru_get_virtual_channel(cru);
if (ret < 0)
return ret;
- cru->csi.channel = ret;
+ csi_vc = ret;
spin_lock_irqsave(&cru->qlock, flags);
@@ -489,7 +491,7 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_dev *cru)
rzg2l_cru_initialize_axi(cru);
/* Initialize image convert */
- ret = rzg2l_cru_initialize_image_conv(cru, fmt);
+ ret = rzg2l_cru_initialize_image_conv(cru, fmt, csi_vc);
if (ret) {
spin_unlock_irqrestore(&cru->qlock, flags);
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 08/22] media: rzg2l-cru: Use MIPI CSI-2 data types for ICnMC_INF definitions
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (6 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 07/22] media: rzg2l-cru: Remove `channel` member from `struct rzg2l_cru_csi` Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 09/22] media: rzg2l-cru: Remove unused fields from rzg2l_cru_ip_format struct Prabhakar
` (13 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The INF field in the ICnMC register accepts data type codes as specified
in the MIPI CSI-2 v2.1 specification. This patch introduces the
`ICnMC_INF()` macro to use the MIPI CSI-2 data types, which are available
in the `media/mipi-csi2.h` header.
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>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 9ab7ef33c9da..de88c0fab961 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/pm_runtime.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-dma-contig.h>
@@ -77,8 +78,7 @@
/* CRU Image Processing Main Control Register */
#define ICnMC 0x208
#define ICnMC_CSCTHR BIT(5)
-#define ICnMC_INF_YUV8_422 (0x1e << 16)
-#define ICnMC_INF_USER (0x30 << 16)
+#define ICnMC_INF(x) ((x) << 16)
#define ICnMC_VCSEL(x) ((x) << 22)
#define ICnMC_INF_MASK GENMASK(21, 16)
@@ -307,12 +307,12 @@ static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
switch (ip_sd_fmt->code) {
case MEDIA_BUS_FMT_UYVY8_1X16:
- icnmc = ICnMC_INF_YUV8_422;
+ icnmc = ICnMC_INF(MIPI_CSI2_DT_YUV422_8B);
*input_is_yuv = true;
break;
default:
*input_is_yuv = false;
- icnmc = ICnMC_INF_USER;
+ icnmc = ICnMC_INF(MIPI_CSI2_DT_USER_DEFINED(0));
break;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 09/22] media: rzg2l-cru: Remove unused fields from rzg2l_cru_ip_format struct
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (7 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 08/22] media: rzg2l-cru: Use MIPI CSI-2 data types for ICnMC_INF definitions Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func Prabhakar
` (12 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Simplified the `rzg2l_cru_ip_format` struct by removing the unused
`datatype` and `bpp` fields from the structure in `rzg2l-ip.c`.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index aee7d4ba70b0..7b006a0bfaae 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -10,12 +10,10 @@
struct rzg2l_cru_ip_format {
u32 code;
- unsigned int datatype;
- unsigned int bpp;
};
static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
- { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_UYVY8_1X16, },
};
static const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (8 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 09/22] media: rzg2l-cru: Remove unused fields from rzg2l_cru_ip_format struct Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:22 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 11/22] media: rzg2l-cru: Simplify configuring input format for image processing Prabhakar
` (11 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
`WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
because the `rzg2l_cru_format_align()` function ensures that a valid
`pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
non-NULL value, making the check redundant.
Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
`u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
now resolved by removing the invalid error return path.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index de88c0fab961..401ef7be58ec 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -835,9 +835,6 @@ static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
- if (WARN_ON(!fmt))
- return -EINVAL;
-
return pix->width * fmt->bpp[0];
}
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func
2024-10-11 17:30 ` [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func Prabhakar
@ 2024-10-15 10:22 ` Laurent Pinchart
2024-10-15 17:33 ` Lad, Prabhakar
0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:22 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:40PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> `WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
> because the `rzg2l_cru_format_align()` function ensures that a valid
> `pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
> a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
> non-NULL value, making the check redundant.
>
> Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
> `u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
> now resolved by removing the invalid error return path.
s/now /now /
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index de88c0fab961..401ef7be58ec 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -835,9 +835,6 @@ static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
>
> fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
>
> - if (WARN_ON(!fmt))
> - return -EINVAL;
> -
> return pix->width * fmt->bpp[0];
> }
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func
2024-10-15 10:22 ` Laurent Pinchart
@ 2024-10-15 17:33 ` Lad, Prabhakar
0 siblings, 0 replies; 36+ messages in thread
From: Lad, Prabhakar @ 2024-10-15 17:33 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
Thank you for the review.
On Tue, Oct 15, 2024 at 11:22 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Fri, Oct 11, 2024 at 06:30:40PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > `WARN_ON(!fmt)` check in `rzg2l_cru_format_bytesperline()` is unnecessary
> > because the `rzg2l_cru_format_align()` function ensures that a valid
> > `pixelformat` is set before calling `rzg2l_cru_format_bytesperline()`. As
> > a result, `rzg2l_cru_format_from_pixel()` is guaranteed to return a
> > non-NULL value, making the check redundant.
> >
> > Additionally, the return type of `rzg2l_cru_format_bytesperline()` is
> > `u32`, but the code returned `-EINVAL`, a negative value. This mismatch is
> > now resolved by removing the invalid error return path.
>
> s/now /now /
>
Oops, I will drop the extra space.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 11/22] media: rzg2l-cru: Simplify configuring input format for image processing
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (9 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 10/22] media: rzg2l-cru: Remove unnecessary WARN_ON check in format func Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:22 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size Prabhakar
` (10 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Move the `rzg2l_cru_ip_format` struct to `rzg2l-cru.h` for better
accessibility and add a `datatype` member to it, allowing the
configuration of the ICnMC register based on the MIPI CSI2 data type.
Also, move the `rzg2l_cru_ip_code_to_fmt()` function to `rzg2l-cru.h`
to streamline format lookup and make it more accessible across the
driver.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../media/platform/renesas/rzg2l-cru/rzg2l-cru.h | 12 ++++++++++++
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 13 +++++++------
.../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 13 +++++++------
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 4fe24bdde5b2..9b1ba015df3b 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -62,6 +62,16 @@ struct rzg2l_cru_ip {
struct v4l2_subdev *remote;
};
+/**
+ * struct rzg2l_cru_ip_format - CRU IP format
+ * @code: Media bus code
+ * @datatype: MIPI CSI2 data type
+ */
+struct rzg2l_cru_ip_format {
+ u32 code;
+ u32 datatype;
+};
+
/**
* struct rzg2l_cru_dev - Renesas CRU device structure
* @dev: (OF) device
@@ -150,4 +160,6 @@ int rzg2l_cru_ip_subdev_register(struct rzg2l_cru_dev *cru);
void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
+
#endif
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 7b006a0bfaae..8f9683bf31fa 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -6,17 +6,18 @@
*/
#include <linux/delay.h>
-#include "rzg2l-cru.h"
+#include <media/mipi-csi2.h>
-struct rzg2l_cru_ip_format {
- u32 code;
-};
+#include "rzg2l-cru.h"
static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
- { .code = MEDIA_BUS_FMT_UYVY8_1X16, },
+ {
+ .code = MEDIA_BUS_FMT_UYVY8_1X16,
+ .datatype = MIPI_CSI2_DT_YUV422_8B,
+ },
};
-static const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
{
unsigned int i;
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 401ef7be58ec..37fea2bed00f 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -301,18 +301,17 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
}
static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
- struct v4l2_mbus_framefmt *ip_sd_fmt, u8 csi_vc)
+ const struct rzg2l_cru_ip_format *ip_fmt,
+ u8 csi_vc)
{
- u32 icnmc;
+ u32 icnmc = ICnMC_INF(ip_fmt->datatype);
- switch (ip_sd_fmt->code) {
+ switch (ip_fmt->code) {
case MEDIA_BUS_FMT_UYVY8_1X16:
- icnmc = ICnMC_INF(MIPI_CSI2_DT_YUV422_8B);
*input_is_yuv = true;
break;
default:
*input_is_yuv = false;
- icnmc = ICnMC_INF(MIPI_CSI2_DT_USER_DEFINED(0));
break;
}
@@ -328,11 +327,13 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
struct v4l2_mbus_framefmt *ip_sd_fmt,
u8 csi_vc)
{
+ const struct rzg2l_cru_ip_format *cru_ip_fmt;
bool output_is_yuv = false;
bool input_is_yuv = false;
u32 icndmr;
- rzg2l_cru_csi2_setup(cru, &input_is_yuv, ip_sd_fmt, csi_vc);
+ cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
+ rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
/* Output format */
switch (cru->format.pixelformat) {
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 11/22] media: rzg2l-cru: Simplify configuring input format for image processing
2024-10-11 17:30 ` [PATCH v5 11/22] media: rzg2l-cru: Simplify configuring input format for image processing Prabhakar
@ 2024-10-15 10:22 ` Laurent Pinchart
0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:22 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:41PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Move the `rzg2l_cru_ip_format` struct to `rzg2l-cru.h` for better
> accessibility and add a `datatype` member to it, allowing the
> configuration of the ICnMC register based on the MIPI CSI2 data type.
>
> Also, move the `rzg2l_cru_ip_code_to_fmt()` function to `rzg2l-cru.h`
> to streamline format lookup and make it more accessible across the
> driver.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> .../media/platform/renesas/rzg2l-cru/rzg2l-cru.h | 12 ++++++++++++
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 13 +++++++------
> .../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 13 +++++++------
> 3 files changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> index 4fe24bdde5b2..9b1ba015df3b 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> @@ -62,6 +62,16 @@ struct rzg2l_cru_ip {
> struct v4l2_subdev *remote;
> };
>
> +/**
> + * struct rzg2l_cru_ip_format - CRU IP format
> + * @code: Media bus code
> + * @datatype: MIPI CSI2 data type
> + */
> +struct rzg2l_cru_ip_format {
> + u32 code;
> + u32 datatype;
> +};
> +
> /**
> * struct rzg2l_cru_dev - Renesas CRU device structure
> * @dev: (OF) device
> @@ -150,4 +160,6 @@ int rzg2l_cru_ip_subdev_register(struct rzg2l_cru_dev *cru);
> void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
> struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
>
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
> +
> #endif
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> index 7b006a0bfaae..8f9683bf31fa 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> @@ -6,17 +6,18 @@
> */
>
> #include <linux/delay.h>
> -#include "rzg2l-cru.h"
> +#include <media/mipi-csi2.h>
>
> -struct rzg2l_cru_ip_format {
> - u32 code;
> -};
> +#include "rzg2l-cru.h"
>
> static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
> - { .code = MEDIA_BUS_FMT_UYVY8_1X16, },
> + {
> + .code = MEDIA_BUS_FMT_UYVY8_1X16,
> + .datatype = MIPI_CSI2_DT_YUV422_8B,
> + },
> };
>
> -static const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
> {
> unsigned int i;
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 401ef7be58ec..37fea2bed00f 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -301,18 +301,17 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
> }
>
> static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
> - struct v4l2_mbus_framefmt *ip_sd_fmt, u8 csi_vc)
> + const struct rzg2l_cru_ip_format *ip_fmt,
> + u8 csi_vc)
> {
> - u32 icnmc;
> + u32 icnmc = ICnMC_INF(ip_fmt->datatype);
>
> - switch (ip_sd_fmt->code) {
> + switch (ip_fmt->code) {
> case MEDIA_BUS_FMT_UYVY8_1X16:
> - icnmc = ICnMC_INF(MIPI_CSI2_DT_YUV422_8B);
> *input_is_yuv = true;
> break;
> default:
> *input_is_yuv = false;
> - icnmc = ICnMC_INF(MIPI_CSI2_DT_USER_DEFINED(0));
> break;
> }
>
> @@ -328,11 +327,13 @@ static int rzg2l_cru_initialize_image_conv(struct rzg2l_cru_dev *cru,
> struct v4l2_mbus_framefmt *ip_sd_fmt,
> u8 csi_vc)
> {
> + const struct rzg2l_cru_ip_format *cru_ip_fmt;
> bool output_is_yuv = false;
> bool input_is_yuv = false;
> u32 icndmr;
>
> - rzg2l_cru_csi2_setup(cru, &input_is_yuv, ip_sd_fmt, csi_vc);
> + cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
> + rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
>
> /* Output format */
> switch (cru->format.pixelformat) {
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (10 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 11/22] media: rzg2l-cru: Simplify configuring input format for image processing Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:22 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats Prabhakar
` (9 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The `rzg2l_cru_format_sizeimage()` function has been inlined into the
`rzg2l_cru_format_align()` function as it has a single caller.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 37fea2bed00f..6a4f0455dc9c 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -839,11 +839,6 @@ static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
return pix->width * fmt->bpp[0];
}
-static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
-{
- return pix->bytesperline * pix->height;
-}
-
static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
struct v4l2_pix_format *pix)
{
@@ -868,7 +863,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
&pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
- pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
+ pix->sizeimage = pix->bytesperline * pix->height;
dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
pix->width, pix->height, pix->bytesperline, pix->sizeimage);
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size
2024-10-11 17:30 ` [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size Prabhakar
@ 2024-10-15 10:22 ` Laurent Pinchart
2024-10-15 17:43 ` Lad, Prabhakar
0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:22 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:42PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> The `rzg2l_cru_format_sizeimage()` function has been inlined into the
> `rzg2l_cru_format_align()` function as it has a single caller.
The commit message should use the imperative mood:
Inline the `rzg2l_cru_format_sizeimage()` function into its single
caller as the function is trivial and is not expected to be called
anywhere else.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 37fea2bed00f..6a4f0455dc9c 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -839,11 +839,6 @@ static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
> return pix->width * fmt->bpp[0];
> }
>
> -static u32 rzg2l_cru_format_sizeimage(struct v4l2_pix_format *pix)
> -{
> - return pix->bytesperline * pix->height;
> -}
> -
> static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> struct v4l2_pix_format *pix)
> {
> @@ -868,7 +863,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
>
> pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
> - pix->sizeimage = rzg2l_cru_format_sizeimage(pix);
> + pix->sizeimage = pix->bytesperline * pix->height;
>
> dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
> pix->width, pix->height, pix->bytesperline, pix->sizeimage);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size
2024-10-15 10:22 ` Laurent Pinchart
@ 2024-10-15 17:43 ` Lad, Prabhakar
0 siblings, 0 replies; 36+ messages in thread
From: Lad, Prabhakar @ 2024-10-15 17:43 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
Thank you for the review.
On Tue, Oct 15, 2024 at 11:22 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Fri, Oct 11, 2024 at 06:30:42PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > The `rzg2l_cru_format_sizeimage()` function has been inlined into the
> > `rzg2l_cru_format_align()` function as it has a single caller.
>
> The commit message should use the imperative mood:
>
> Inline the `rzg2l_cru_format_sizeimage()` function into its single
> caller as the function is trivial and is not expected to be called
> anywhere else.
>
I will update the commit message as above.
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (11 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 12/22] media: rzg2l-cru: Inline calculating image size Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:23 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 14/22] media: rzg2l-cru: Inline calculating bytesperline Prabhakar
` (8 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Refactor the handling of supported formats in the RZ/G2L CRU driver by
moving the `rzg2l_cru_ip_format` struct to the common header for reuse
across multiple files and adding `pixelformat` and `bpp` members to it.
This change centralizes format handling, making it easier to manage and
extend.
New helper functions, `rzg2l_cru_ip_format_to_fmt()` and
`rzg2l_cru_ip_index_to_fmt()`, are added to retrieve format information
based on 4CC format and index, respectively. These helpers allow the
removal of the now redundant `rzg2l_cru_format_from_pixel()` function.
The new helpers are used in `rzg2l_cru_format_bytesperline()`,
`rzg2l_cru_format_align()`, and `rzg2l_cru_enum_fmt_vid_cap()`,
streamlining the handling of supported formats and improving code
maintainability.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-cru.h | 6 ++++
.../platform/renesas/rzg2l-cru/rzg2l-ip.c | 22 +++++++++++++
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 33 +++++--------------
3 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 9b1ba015df3b..327516272e53 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -66,10 +66,14 @@ struct rzg2l_cru_ip {
* struct rzg2l_cru_ip_format - CRU IP format
* @code: Media bus code
* @datatype: MIPI CSI2 data type
+ * @format: 4CC format identifier (V4L2_PIX_FMT_*)
+ * @bpp: bytes per pixel
*/
struct rzg2l_cru_ip_format {
u32 code;
u32 datatype;
+ u32 format;
+ u8 bpp;
};
/**
@@ -161,5 +165,7 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_format_to_fmt(u32 format);
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_index_to_fmt(u32 index);
#endif
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 8f9683bf31fa..a40b0184b955 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -14,6 +14,8 @@ 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,
},
};
@@ -28,6 +30,26 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
return NULL;
}
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_format_to_fmt(u32 format)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++) {
+ if (rzg2l_cru_ip_formats[i].format == format)
+ return &rzg2l_cru_ip_formats[i];
+ }
+
+ return NULL;
+}
+
+const struct rzg2l_cru_ip_format *rzg2l_cru_ip_index_to_fmt(u32 index)
+{
+ if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
+ return NULL;
+
+ return &rzg2l_cru_ip_formats[index];
+}
+
struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru)
{
struct v4l2_subdev_state *state;
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 6a4f0455dc9c..a0fa4542ac43 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -812,37 +812,19 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
* V4L2 stuff
*/
-static const struct v4l2_format_info rzg2l_cru_formats[] = {
- {
- .format = V4L2_PIX_FMT_UYVY,
- .bpp[0] = 2,
- },
-};
-
-const struct v4l2_format_info *rzg2l_cru_format_from_pixel(u32 format)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(rzg2l_cru_formats); i++)
- if (rzg2l_cru_formats[i].format == format)
- return rzg2l_cru_formats + i;
-
- return NULL;
-}
-
static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
{
- const struct v4l2_format_info *fmt;
+ const struct rzg2l_cru_ip_format *fmt;
- fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
+ fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
- return pix->width * fmt->bpp[0];
+ return pix->width * fmt->bpp;
}
static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
struct v4l2_pix_format *pix)
{
- if (!rzg2l_cru_format_from_pixel(pix->pixelformat))
+ if (!rzg2l_cru_ip_format_to_fmt(pix->pixelformat))
pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
switch (pix->field) {
@@ -934,10 +916,13 @@ static int rzg2l_cru_g_fmt_vid_cap(struct file *file, void *priv,
static int rzg2l_cru_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- if (f->index >= ARRAY_SIZE(rzg2l_cru_formats))
+ const struct rzg2l_cru_ip_format *fmt;
+
+ fmt = rzg2l_cru_ip_index_to_fmt(f->index);
+ if (!fmt)
return -EINVAL;
- f->pixelformat = rzg2l_cru_formats[f->index].format;
+ f->pixelformat = fmt->format;
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats
2024-10-11 17:30 ` [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats Prabhakar
@ 2024-10-15 10:23 ` Laurent Pinchart
2024-10-15 17:47 ` Lad, Prabhakar
0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:23 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:43PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Refactor the handling of supported formats in the RZ/G2L CRU driver by
> moving the `rzg2l_cru_ip_format` struct to the common header for reuse
> across multiple files and adding `pixelformat` and `bpp` members to it.
The structure is already in a common header. You can write
Refactor the handling of supported formats in the RZ/G2L CRU driver by
adding `pixelformat` and `bpp` members to the `rzg2l_cru_ip_format`
structure.
> This change centralizes format handling, making it easier to manage and
> extend.
>
> New helper functions, `rzg2l_cru_ip_format_to_fmt()` and
> `rzg2l_cru_ip_index_to_fmt()`, are added to retrieve format information
> based on 4CC format and index, respectively. These helpers allow the
> removal of the now redundant `rzg2l_cru_format_from_pixel()` function.
>
> The new helpers are used in `rzg2l_cru_format_bytesperline()`,
> `rzg2l_cru_format_align()`, and `rzg2l_cru_enum_fmt_vid_cap()`,
> streamlining the handling of supported formats and improving code
> maintainability.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> .../platform/renesas/rzg2l-cru/rzg2l-cru.h | 6 ++++
> .../platform/renesas/rzg2l-cru/rzg2l-ip.c | 22 +++++++++++++
> .../platform/renesas/rzg2l-cru/rzg2l-video.c | 33 +++++--------------
> 3 files changed, 37 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> index 9b1ba015df3b..327516272e53 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
> @@ -66,10 +66,14 @@ struct rzg2l_cru_ip {
> * struct rzg2l_cru_ip_format - CRU IP format
> * @code: Media bus code
> * @datatype: MIPI CSI2 data type
> + * @format: 4CC format identifier (V4L2_PIX_FMT_*)
> + * @bpp: bytes per pixel
> */
> struct rzg2l_cru_ip_format {
> u32 code;
> u32 datatype;
> + u32 format;
> + u8 bpp;
> };
>
> /**
> @@ -161,5 +165,7 @@ void rzg2l_cru_ip_subdev_unregister(struct rzg2l_cru_dev *cru);
> struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru);
>
> const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code);
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_format_to_fmt(u32 format);
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_index_to_fmt(u32 index);
>
> #endif
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> index 8f9683bf31fa..a40b0184b955 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
> @@ -14,6 +14,8 @@ 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,
> },
> };
>
> @@ -28,6 +30,26 @@ const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
> return NULL;
> }
>
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_format_to_fmt(u32 format)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(rzg2l_cru_ip_formats); i++) {
> + if (rzg2l_cru_ip_formats[i].format == format)
> + return &rzg2l_cru_ip_formats[i];
> + }
> +
> + return NULL;
> +}
> +
> +const struct rzg2l_cru_ip_format *rzg2l_cru_ip_index_to_fmt(u32 index)
> +{
> + if (index >= ARRAY_SIZE(rzg2l_cru_ip_formats))
> + return NULL;
> +
> + return &rzg2l_cru_ip_formats[index];
> +}
> +
> struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru)
> {
> struct v4l2_subdev_state *state;
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 6a4f0455dc9c..a0fa4542ac43 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -812,37 +812,19 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
> * V4L2 stuff
> */
>
> -static const struct v4l2_format_info rzg2l_cru_formats[] = {
> - {
> - .format = V4L2_PIX_FMT_UYVY,
> - .bpp[0] = 2,
> - },
> -};
> -
> -const struct v4l2_format_info *rzg2l_cru_format_from_pixel(u32 format)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < ARRAY_SIZE(rzg2l_cru_formats); i++)
> - if (rzg2l_cru_formats[i].format == format)
> - return rzg2l_cru_formats + i;
> -
> - return NULL;
> -}
> -
> static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
> {
> - const struct v4l2_format_info *fmt;
> + const struct rzg2l_cru_ip_format *fmt;
>
> - fmt = rzg2l_cru_format_from_pixel(pix->pixelformat);
> + fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
>
> - return pix->width * fmt->bpp[0];
> + return pix->width * fmt->bpp;
> }
>
> static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> struct v4l2_pix_format *pix)
> {
> - if (!rzg2l_cru_format_from_pixel(pix->pixelformat))
> + if (!rzg2l_cru_ip_format_to_fmt(pix->pixelformat))
> pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
>
> switch (pix->field) {
> @@ -934,10 +916,13 @@ static int rzg2l_cru_g_fmt_vid_cap(struct file *file, void *priv,
> static int rzg2l_cru_enum_fmt_vid_cap(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - if (f->index >= ARRAY_SIZE(rzg2l_cru_formats))
> + const struct rzg2l_cru_ip_format *fmt;
> +
> + fmt = rzg2l_cru_ip_index_to_fmt(f->index);
> + if (!fmt)
> return -EINVAL;
>
> - f->pixelformat = rzg2l_cru_formats[f->index].format;
> + f->pixelformat = fmt->format;
>
> return 0;
> }
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats
2024-10-15 10:23 ` Laurent Pinchart
@ 2024-10-15 17:47 ` Lad, Prabhakar
0 siblings, 0 replies; 36+ messages in thread
From: Lad, Prabhakar @ 2024-10-15 17:47 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
Thank you for the review.
On Tue, Oct 15, 2024 at 11:23 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Fri, Oct 11, 2024 at 06:30:43PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Refactor the handling of supported formats in the RZ/G2L CRU driver by
> > moving the `rzg2l_cru_ip_format` struct to the common header for reuse
> > across multiple files and adding `pixelformat` and `bpp` members to it.
>
> The structure is already in a common header. You can write
>
> Refactor the handling of supported formats in the RZ/G2L CRU driver by
> adding `pixelformat` and `bpp` members to the `rzg2l_cru_ip_format`
> structure.
>
I will update the commit message as above.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 14/22] media: rzg2l-cru: Inline calculating bytesperline
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (12 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 13/22] media: rzg2l-cru: Simplify handling of supported formats Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:24 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers Prabhakar
` (7 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Remove the `rzg2l_cru_format_bytesperline()` function and inline the
calculation of `bytesperline` directly in `rzg2l_cru_format_align()`.
This simplifies the code by removing an unnecessary function call and
directly multiplying the image width by the `bpp` (bytes per pixel)
from the format structure.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index a0fa4542ac43..8932fab7c656 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -812,20 +812,16 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
* V4L2 stuff
*/
-static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
+static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
+ struct v4l2_pix_format *pix)
{
const struct rzg2l_cru_ip_format *fmt;
fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
-
- return pix->width * fmt->bpp;
-}
-
-static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
- struct v4l2_pix_format *pix)
-{
- if (!rzg2l_cru_ip_format_to_fmt(pix->pixelformat))
+ if (!fmt) {
pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
+ fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
+ }
switch (pix->field) {
case V4L2_FIELD_TOP:
@@ -844,7 +840,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
&pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
- pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
+ pix->bytesperline = pix->width * fmt->bpp;
pix->sizeimage = pix->bytesperline * pix->height;
dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 14/22] media: rzg2l-cru: Inline calculating bytesperline
2024-10-11 17:30 ` [PATCH v5 14/22] media: rzg2l-cru: Inline calculating bytesperline Prabhakar
@ 2024-10-15 10:24 ` Laurent Pinchart
0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:24 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:44PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Remove the `rzg2l_cru_format_bytesperline()` function and inline the
> calculation of `bytesperline` directly in `rzg2l_cru_format_align()`.
> This simplifies the code by removing an unnecessary function call and
> directly multiplying the image width by the `bpp` (bytes per pixel)
> from the format structure.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> .../platform/renesas/rzg2l-cru/rzg2l-video.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index a0fa4542ac43..8932fab7c656 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -812,20 +812,16 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
> * V4L2 stuff
> */
>
> -static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
> +static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> + struct v4l2_pix_format *pix)
> {
> const struct rzg2l_cru_ip_format *fmt;
>
> fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
> -
> - return pix->width * fmt->bpp;
> -}
> -
> -static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> - struct v4l2_pix_format *pix)
> -{
> - if (!rzg2l_cru_ip_format_to_fmt(pix->pixelformat))
> + if (!fmt) {
> pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
> + fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
> + }
>
> switch (pix->field) {
> case V4L2_FIELD_TOP:
> @@ -844,7 +840,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
> v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
> &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);
>
> - pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
> + pix->bytesperline = pix->width * fmt->bpp;
> pix->sizeimage = pix->bytesperline * pix->height;
>
> dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (13 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 14/22] media: rzg2l-cru: Inline calculating bytesperline Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:33 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 16/22] media: rzg2l-cru: Use `rzg2l_cru_ip_formats` array in enum_frame_size Prabhakar
` (6 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Make use of v4l2_format_info() helpers to determine the input and
output formats.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 22 ++++++-------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 8932fab7c656..0cc69a7440bf 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -300,21 +300,12 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr);
}
-static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
+static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
const struct rzg2l_cru_ip_format *ip_fmt,
u8 csi_vc)
{
u32 icnmc = ICnMC_INF(ip_fmt->datatype);
- switch (ip_fmt->code) {
- case MEDIA_BUS_FMT_UYVY8_1X16:
- *input_is_yuv = true;
- break;
- default:
- *input_is_yuv = false;
- break;
- }
-
icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
/* Set virtual channel CSI2 */
@@ -327,19 +318,17 @@ 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_ip_fmt;
- bool output_is_yuv = false;
- bool input_is_yuv = false;
u32 icndmr;
cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
- rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
+ 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;
- output_is_yuv = true;
break;
default:
dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
@@ -347,8 +336,11 @@ 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 (output_is_yuv == input_is_yuv)
+ if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
rzg2l_cru_write(cru, ICnMC,
rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
else
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers
2024-10-11 17:30 ` [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers Prabhakar
@ 2024-10-15 10:33 ` Laurent Pinchart
2024-10-18 11:45 ` Lad, Prabhakar
0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:33 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:45PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Make use of v4l2_format_info() helpers to determine the input and
> output formats.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> .../platform/renesas/rzg2l-cru/rzg2l-video.c | 22 ++++++-------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 8932fab7c656..0cc69a7440bf 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -300,21 +300,12 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
> rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr);
> }
>
> -static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
> +static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
> const struct rzg2l_cru_ip_format *ip_fmt,
> u8 csi_vc)
> {
> u32 icnmc = ICnMC_INF(ip_fmt->datatype);
>
> - switch (ip_fmt->code) {
> - case MEDIA_BUS_FMT_UYVY8_1X16:
> - *input_is_yuv = true;
> - break;
> - default:
> - *input_is_yuv = false;
> - break;
> - }
> -
> icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
>
> /* Set virtual channel CSI2 */
> @@ -327,19 +318,17 @@ 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_ip_fmt;
> - bool output_is_yuv = false;
> - bool input_is_yuv = false;
> u32 icndmr;
>
> cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
> - rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
> + 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;
> - output_is_yuv = true;
> break;
> default:
> dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
> @@ -347,8 +336,11 @@ 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);
It would be a bit more efficient to add a yuv boolean field to the
rzg2l_cru_ip_format structure, as you already have looked up cru_ip_fmt
for the IP subdev format.
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> +
> /* If input and output use same colorspace, do bypass mode */
> - if (output_is_yuv == input_is_yuv)
> + if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
> rzg2l_cru_write(cru, ICnMC,
> rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
> else
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers
2024-10-15 10:33 ` Laurent Pinchart
@ 2024-10-18 11:45 ` Lad, Prabhakar
2024-10-18 12:26 ` Laurent Pinchart
0 siblings, 1 reply; 36+ messages in thread
From: Lad, Prabhakar @ 2024-10-18 11:45 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
Thank you for the review.
On Tue, Oct 15, 2024 at 11:33 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Fri, Oct 11, 2024 at 06:30:45PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > Make use of v4l2_format_info() helpers to determine the input and
> > output formats.
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> > .../platform/renesas/rzg2l-cru/rzg2l-video.c | 22 ++++++-------------
> > 1 file changed, 7 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > index 8932fab7c656..0cc69a7440bf 100644
> > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > @@ -300,21 +300,12 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
> > rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr);
> > }
> >
> > -static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
> > +static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
> > const struct rzg2l_cru_ip_format *ip_fmt,
> > u8 csi_vc)
> > {
> > u32 icnmc = ICnMC_INF(ip_fmt->datatype);
> >
> > - switch (ip_fmt->code) {
> > - case MEDIA_BUS_FMT_UYVY8_1X16:
> > - *input_is_yuv = true;
> > - break;
> > - default:
> > - *input_is_yuv = false;
> > - break;
> > - }
> > -
> > icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
> >
> > /* Set virtual channel CSI2 */
> > @@ -327,19 +318,17 @@ 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_ip_fmt;
> > - bool output_is_yuv = false;
> > - bool input_is_yuv = false;
> > u32 icndmr;
> >
> > cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
> > - rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
> > + 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;
> > - output_is_yuv = true;
> > break;
> > default:
> > dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
> > @@ -347,8 +336,11 @@ 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);
>
> It would be a bit more efficient to add a yuv boolean field to the
> rzg2l_cru_ip_format structure, as you already have looked up cru_ip_fmt
> for the IP subdev format.
>
I will consider this change, when adding support for the RZ/V2H SoC,
hope that's OK for you.
Cheers,
Prabhakar
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>
> > +
> > /* If input and output use same colorspace, do bypass mode */
> > - if (output_is_yuv == input_is_yuv)
> > + if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
> > rzg2l_cru_write(cru, ICnMC,
> > rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
> > else
>
> --
> Regards,
>
> Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers
2024-10-18 11:45 ` Lad, Prabhakar
@ 2024-10-18 12:26 ` Laurent Pinchart
2024-10-18 12:40 ` Lad, Prabhakar
0 siblings, 1 reply; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-18 12:26 UTC (permalink / raw)
To: Lad, Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
On Fri, Oct 18, 2024 at 12:45:36PM +0100, Lad, Prabhakar wrote:
> On Tue, Oct 15, 2024 at 11:33 AM Laurent Pinchart wrote:
> > On Fri, Oct 11, 2024 at 06:30:45PM +0100, Prabhakar wrote:
> > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > >
> > > Make use of v4l2_format_info() helpers to determine the input and
> > > output formats.
> > >
> > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > ---
> > > .../platform/renesas/rzg2l-cru/rzg2l-video.c | 22 ++++++-------------
> > > 1 file changed, 7 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > index 8932fab7c656..0cc69a7440bf 100644
> > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > @@ -300,21 +300,12 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
> > > rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr);
> > > }
> > >
> > > -static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
> > > +static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
> > > const struct rzg2l_cru_ip_format *ip_fmt,
> > > u8 csi_vc)
> > > {
> > > u32 icnmc = ICnMC_INF(ip_fmt->datatype);
> > >
> > > - switch (ip_fmt->code) {
> > > - case MEDIA_BUS_FMT_UYVY8_1X16:
> > > - *input_is_yuv = true;
> > > - break;
> > > - default:
> > > - *input_is_yuv = false;
> > > - break;
> > > - }
> > > -
> > > icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
> > >
> > > /* Set virtual channel CSI2 */
> > > @@ -327,19 +318,17 @@ 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_ip_fmt;
> > > - bool output_is_yuv = false;
> > > - bool input_is_yuv = false;
> > > u32 icndmr;
> > >
> > > cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
> > > - rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
> > > + 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;
> > > - output_is_yuv = true;
> > > break;
> > > default:
> > > dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
> > > @@ -347,8 +336,11 @@ 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);
> >
> > It would be a bit more efficient to add a yuv boolean field to the
> > rzg2l_cru_ip_format structure, as you already have looked up cru_ip_fmt
> > for the IP subdev format.
>
> I will consider this change, when adding support for the RZ/V2H SoC,
> hope that's OK for you.
It's not a blocker, it can be done on top indeed. If you end up
submitting a v6 you could add a patch on top already, but otherwise
later is fine too.
> > Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> >
> > > +
> > > /* If input and output use same colorspace, do bypass mode */
> > > - if (output_is_yuv == input_is_yuv)
> > > + if (v4l2_is_format_yuv(src_finfo) == v4l2_is_format_yuv(dst_finfo))
> > > rzg2l_cru_write(cru, ICnMC,
> > > rzg2l_cru_read(cru, ICnMC) | ICnMC_CSCTHR);
> > > else
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers
2024-10-18 12:26 ` Laurent Pinchart
@ 2024-10-18 12:40 ` Lad, Prabhakar
0 siblings, 0 replies; 36+ messages in thread
From: Lad, Prabhakar @ 2024-10-18 12:40 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
On Fri, Oct 18, 2024 at 1:26 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Fri, Oct 18, 2024 at 12:45:36PM +0100, Lad, Prabhakar wrote:
> > On Tue, Oct 15, 2024 at 11:33 AM Laurent Pinchart wrote:
> > > On Fri, Oct 11, 2024 at 06:30:45PM +0100, Prabhakar wrote:
> > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > >
> > > > Make use of v4l2_format_info() helpers to determine the input and
> > > > output formats.
> > > >
> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > ---
> > > > .../platform/renesas/rzg2l-cru/rzg2l-video.c | 22 ++++++-------------
> > > > 1 file changed, 7 insertions(+), 15 deletions(-)
> > > >
> > > > diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > index 8932fab7c656..0cc69a7440bf 100644
> > > > --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> > > > @@ -300,21 +300,12 @@ static void rzg2l_cru_initialize_axi(struct rzg2l_cru_dev *cru)
> > > > rzg2l_cru_write(cru, AMnAXIATTR, amnaxiattr);
> > > > }
> > > >
> > > > -static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru, bool *input_is_yuv,
> > > > +static void rzg2l_cru_csi2_setup(struct rzg2l_cru_dev *cru,
> > > > const struct rzg2l_cru_ip_format *ip_fmt,
> > > > u8 csi_vc)
> > > > {
> > > > u32 icnmc = ICnMC_INF(ip_fmt->datatype);
> > > >
> > > > - switch (ip_fmt->code) {
> > > > - case MEDIA_BUS_FMT_UYVY8_1X16:
> > > > - *input_is_yuv = true;
> > > > - break;
> > > > - default:
> > > > - *input_is_yuv = false;
> > > > - break;
> > > > - }
> > > > -
> > > > icnmc |= (rzg2l_cru_read(cru, ICnMC) & ~ICnMC_INF_MASK);
> > > >
> > > > /* Set virtual channel CSI2 */
> > > > @@ -327,19 +318,17 @@ 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_ip_fmt;
> > > > - bool output_is_yuv = false;
> > > > - bool input_is_yuv = false;
> > > > u32 icndmr;
> > > >
> > > > cru_ip_fmt = rzg2l_cru_ip_code_to_fmt(ip_sd_fmt->code);
> > > > - rzg2l_cru_csi2_setup(cru, &input_is_yuv, cru_ip_fmt, csi_vc);
> > > > + 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;
> > > > - output_is_yuv = true;
> > > > break;
> > > > default:
> > > > dev_err(cru->dev, "Invalid pixelformat (0x%x)\n",
> > > > @@ -347,8 +336,11 @@ 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);
> > >
> > > It would be a bit more efficient to add a yuv boolean field to the
> > > rzg2l_cru_ip_format structure, as you already have looked up cru_ip_fmt
> > > for the IP subdev format.
> >
> > I will consider this change, when adding support for the RZ/V2H SoC,
> > hope that's OK for you.
>
> It's not a blocker, it can be done on top indeed. If you end up
> submitting a v6 you could add a patch on top already, but otherwise
> later is fine too.
>
I was intending to send a v6 anyway with the updated commit messages,
so I will add a new patch on top.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 16/22] media: rzg2l-cru: Use `rzg2l_cru_ip_formats` array in enum_frame_size
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (14 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 15/22] media: rzg2l-cru: Make use of v4l2_format_info() helpers Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 17/22] media: rzg2l-cru: csi2: Remove unused field from rzg2l_csi2_format Prabhakar
` (5 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Use the `rzg2l_cru_ip_formats` array in `rzg2l_cru_ip_enum_frame_size()`
to validate the format code.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index a40b0184b955..07859c89be77 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -165,7 +165,7 @@ static int rzg2l_cru_ip_enum_frame_size(struct v4l2_subdev *sd,
if (fse->index != 0)
return -EINVAL;
- if (fse->code != MEDIA_BUS_FMT_UYVY8_1X16)
+ if (!rzg2l_cru_ip_code_to_fmt(fse->code))
return -EINVAL;
fse->min_width = RZG2L_CRU_MIN_INPUT_WIDTH;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 17/22] media: rzg2l-cru: csi2: Remove unused field from rzg2l_csi2_format
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (15 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 16/22] media: rzg2l-cru: Use `rzg2l_cru_ip_formats` array in enum_frame_size Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 18/22] media: rzg2l-cru: video: Implement .link_validate() callback Prabhakar
` (4 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Remove the unused `datatype` field from the `rzg2l_csi2_format` struct and
update the `rzg2l_csi2_formats[]` array to reflect the updated structure.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index 3fd0be6a3b65..7b76d495cfe4 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -183,12 +183,11 @@ static const struct rzg2l_csi2_timings rzg2l_csi2_global_timings[] = {
struct rzg2l_csi2_format {
u32 code;
- unsigned int datatype;
unsigned int bpp;
};
static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = {
- { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_UYVY8_1X16, .bpp = 16 },
};
static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd)
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 18/22] media: rzg2l-cru: video: Implement .link_validate() callback
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (16 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 17/22] media: rzg2l-cru: csi2: Remove unused field from rzg2l_csi2_format Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-15 10:33 ` Laurent Pinchart
2024-10-11 17:30 ` [PATCH v5 19/22] media: rzg2l-cru: csi2: Use rzg2l_csi2_formats array in enum_frame_size Prabhakar
` (3 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Implement the `.link_validate()` callback for the video node and move the
format checking into this function. This change allows the removal of
`rzg2l_cru_mc_validate_format()`.
Suggested-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 82 +++++++++----------
1 file changed, 38 insertions(+), 44 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index 0cc69a7440bf..df6114cbe5c7 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -189,46 +189,6 @@ static void rzg2l_cru_buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(&cru->qlock, flags);
}
-static int rzg2l_cru_mc_validate_format(struct rzg2l_cru_dev *cru,
- struct v4l2_subdev *sd,
- struct media_pad *pad)
-{
- struct v4l2_subdev_format fmt = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- };
-
- fmt.pad = pad->index;
- if (v4l2_subdev_call_state_active(sd, pad, get_fmt, &fmt))
- return -EPIPE;
-
- switch (fmt.format.code) {
- case MEDIA_BUS_FMT_UYVY8_1X16:
- break;
- default:
- return -EPIPE;
- }
-
- switch (fmt.format.field) {
- case V4L2_FIELD_TOP:
- case V4L2_FIELD_BOTTOM:
- case V4L2_FIELD_NONE:
- case V4L2_FIELD_INTERLACED_TB:
- case V4L2_FIELD_INTERLACED_BT:
- case V4L2_FIELD_INTERLACED:
- case V4L2_FIELD_SEQ_TB:
- case V4L2_FIELD_SEQ_BT:
- break;
- default:
- return -EPIPE;
- }
-
- if (fmt.format.width != cru->format.width ||
- fmt.format.height != cru->format.height)
- return -EPIPE;
-
- return 0;
-}
-
static void rzg2l_cru_set_slot_addr(struct rzg2l_cru_dev *cru,
int slot, dma_addr_t addr)
{
@@ -532,10 +492,6 @@ static int rzg2l_cru_set_stream(struct rzg2l_cru_dev *cru, int on)
return stream_off_ret;
}
- ret = rzg2l_cru_mc_validate_format(cru, sd, pad);
- if (ret)
- return ret;
-
pipe = media_entity_pipeline(&sd->entity) ? : &cru->vdev.pipe;
ret = video_device_pipeline_start(&cru->vdev, pipe);
if (ret)
@@ -986,6 +942,43 @@ static const struct v4l2_file_operations rzg2l_cru_fops = {
.read = vb2_fop_read,
};
+/* -----------------------------------------------------------------------------
+ * Media entity operations
+ */
+
+static int rzg2l_cru_video_link_validate(struct media_link *link)
+{
+ struct v4l2_subdev_format fmt = {
+ .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+ };
+ const struct rzg2l_cru_ip_format *video_fmt;
+ struct v4l2_subdev *subdev;
+ struct rzg2l_cru_dev *cru;
+ int ret;
+
+ subdev = media_entity_to_v4l2_subdev(link->source->entity);
+ fmt.pad = link->source->index;
+ ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
+ if (ret < 0)
+ return ret == -ENOIOCTLCMD ? -EINVAL : ret;
+
+ cru = container_of(media_entity_to_video_device(link->sink->entity),
+ struct rzg2l_cru_dev, vdev);
+ video_fmt = rzg2l_cru_ip_format_to_fmt(cru->format.pixelformat);
+
+ if (fmt.format.width != cru->format.width ||
+ fmt.format.height != cru->format.height ||
+ fmt.format.field != cru->format.field ||
+ video_fmt->code != fmt.format.code)
+ return -EPIPE;
+
+ return 0;
+}
+
+static const struct media_entity_operations rzg2l_cru_video_media_ops = {
+ .link_validate = rzg2l_cru_video_link_validate,
+};
+
static void rzg2l_cru_v4l2_init(struct rzg2l_cru_dev *cru)
{
struct video_device *vdev = &cru->vdev;
@@ -997,6 +990,7 @@ static void rzg2l_cru_v4l2_init(struct rzg2l_cru_dev *cru)
vdev->lock = &cru->lock;
vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
vdev->device_caps |= V4L2_CAP_IO_MC;
+ vdev->entity.ops = &rzg2l_cru_video_media_ops;
vdev->fops = &rzg2l_cru_fops;
vdev->ioctl_ops = &rzg2l_cru_ioctl_ops;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* Re: [PATCH v5 18/22] media: rzg2l-cru: video: Implement .link_validate() callback
2024-10-11 17:30 ` [PATCH v5 18/22] media: rzg2l-cru: video: Implement .link_validate() callback Prabhakar
@ 2024-10-15 10:33 ` Laurent Pinchart
0 siblings, 0 replies; 36+ messages in thread
From: Laurent Pinchart @ 2024-10-15 10:33 UTC (permalink / raw)
To: Prabhakar
Cc: Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Fri, Oct 11, 2024 at 06:30:48PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> Implement the `.link_validate()` callback for the video node and move the
> format checking into this function. This change allows the removal of
> `rzg2l_cru_mc_validate_format()`.
I would add here that the fmt.format.code and fmt.format.field checks
can be dropped as the subdev .set_fmt() handler ensures that those
fields always hold valid values.
>
> 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>
> ---
> .../platform/renesas/rzg2l-cru/rzg2l-video.c | 82 +++++++++----------
> 1 file changed, 38 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index 0cc69a7440bf..df6114cbe5c7 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -189,46 +189,6 @@ static void rzg2l_cru_buffer_queue(struct vb2_buffer *vb)
> spin_unlock_irqrestore(&cru->qlock, flags);
> }
>
> -static int rzg2l_cru_mc_validate_format(struct rzg2l_cru_dev *cru,
> - struct v4l2_subdev *sd,
> - struct media_pad *pad)
> -{
> - struct v4l2_subdev_format fmt = {
> - .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> - };
> -
> - fmt.pad = pad->index;
> - if (v4l2_subdev_call_state_active(sd, pad, get_fmt, &fmt))
> - return -EPIPE;
> -
> - switch (fmt.format.code) {
> - case MEDIA_BUS_FMT_UYVY8_1X16:
> - break;
> - default:
> - return -EPIPE;
> - }
> -
> - switch (fmt.format.field) {
> - case V4L2_FIELD_TOP:
> - case V4L2_FIELD_BOTTOM:
> - case V4L2_FIELD_NONE:
> - case V4L2_FIELD_INTERLACED_TB:
> - case V4L2_FIELD_INTERLACED_BT:
> - case V4L2_FIELD_INTERLACED:
> - case V4L2_FIELD_SEQ_TB:
> - case V4L2_FIELD_SEQ_BT:
> - break;
> - default:
> - return -EPIPE;
> - }
> -
> - if (fmt.format.width != cru->format.width ||
> - fmt.format.height != cru->format.height)
> - return -EPIPE;
> -
> - return 0;
> -}
> -
> static void rzg2l_cru_set_slot_addr(struct rzg2l_cru_dev *cru,
> int slot, dma_addr_t addr)
> {
> @@ -532,10 +492,6 @@ static int rzg2l_cru_set_stream(struct rzg2l_cru_dev *cru, int on)
> return stream_off_ret;
> }
>
> - ret = rzg2l_cru_mc_validate_format(cru, sd, pad);
> - if (ret)
> - return ret;
> -
> pipe = media_entity_pipeline(&sd->entity) ? : &cru->vdev.pipe;
> ret = video_device_pipeline_start(&cru->vdev, pipe);
> if (ret)
> @@ -986,6 +942,43 @@ static const struct v4l2_file_operations rzg2l_cru_fops = {
> .read = vb2_fop_read,
> };
>
> +/* -----------------------------------------------------------------------------
> + * Media entity operations
> + */
> +
> +static int rzg2l_cru_video_link_validate(struct media_link *link)
> +{
> + struct v4l2_subdev_format fmt = {
> + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> + };
> + const struct rzg2l_cru_ip_format *video_fmt;
> + struct v4l2_subdev *subdev;
> + struct rzg2l_cru_dev *cru;
> + int ret;
> +
> + subdev = media_entity_to_v4l2_subdev(link->source->entity);
> + fmt.pad = link->source->index;
> + ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
> + if (ret < 0)
> + return ret == -ENOIOCTLCMD ? -EINVAL : ret;
> +
> + cru = container_of(media_entity_to_video_device(link->sink->entity),
> + struct rzg2l_cru_dev, vdev);
> + video_fmt = rzg2l_cru_ip_format_to_fmt(cru->format.pixelformat);
> +
> + if (fmt.format.width != cru->format.width ||
> + fmt.format.height != cru->format.height ||
> + fmt.format.field != cru->format.field ||
> + video_fmt->code != fmt.format.code)
> + return -EPIPE;
> +
> + return 0;
> +}
> +
> +static const struct media_entity_operations rzg2l_cru_video_media_ops = {
> + .link_validate = rzg2l_cru_video_link_validate,
> +};
> +
> static void rzg2l_cru_v4l2_init(struct rzg2l_cru_dev *cru)
> {
> struct video_device *vdev = &cru->vdev;
> @@ -997,6 +990,7 @@ static void rzg2l_cru_v4l2_init(struct rzg2l_cru_dev *cru)
> vdev->lock = &cru->lock;
> vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
> vdev->device_caps |= V4L2_CAP_IO_MC;
> + vdev->entity.ops = &rzg2l_cru_video_media_ops;
> vdev->fops = &rzg2l_cru_fops;
> vdev->ioctl_ops = &rzg2l_cru_ioctl_ops;
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 19/22] media: rzg2l-cru: csi2: Use rzg2l_csi2_formats array in enum_frame_size
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (17 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 18/22] media: rzg2l-cru: video: Implement .link_validate() callback Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 20/22] media: rzg2l-cru: Refactor ICnDMR register configuration Prabhakar
` (2 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Make use of `rzg2l_csi2_formats` array in rzg2l_csi2_enum_frame_size() to
validate if the `fse->code` is supported.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index 7b76d495cfe4..e21142d3b67d 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -573,6 +573,9 @@ static int rzg2l_csi2_enum_frame_size(struct v4l2_subdev *sd,
if (fse->index != 0)
return -EINVAL;
+ if (!rzg2l_csi2_code_to_fmt(fse->code))
+ return -EINVAL;
+
fse->min_width = RZG2L_CSI2_MIN_WIDTH;
fse->min_height = RZG2L_CSI2_MIN_HEIGHT;
fse->max_width = RZG2L_CSI2_MAX_WIDTH;
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 20/22] media: rzg2l-cru: Refactor ICnDMR register configuration
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (18 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 19/22] media: rzg2l-cru: csi2: Use rzg2l_csi2_formats array in enum_frame_size Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 21/22] media: rzg2l-cru: Add support to capture 8bit raw sRGB Prabhakar
2024-10-11 17:30 ` [PATCH v5 22/22] media: rzg2l-cru: Move register definitions to a separate file Prabhakar
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
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>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h | 4 ++++
drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 1 +
.../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 12 ++++--------
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index 327516272e53..c40754732576 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -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,
@@ -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;
};
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 07859c89be77..ad470de440ad 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -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,
},
};
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index df6114cbe5c7..a686a5cd4f59 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -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
@@ -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;
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 21/22] media: rzg2l-cru: Add support to capture 8bit raw sRGB
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (19 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 20/22] media: rzg2l-cru: Refactor ICnDMR register configuration Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
2024-10-11 17:30 ` [PATCH v5 22/22] media: rzg2l-cru: Move register definitions to a separate file Prabhakar
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Add support to capture 8bit Bayer formats.
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
.../platform/renesas/rzg2l-cru/rzg2l-csi2.c | 4 +++
.../platform/renesas/rzg2l-cru/rzg2l-ip.c | 28 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index e21142d3b67d..84230926875a 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -188,6 +188,10 @@ struct rzg2l_csi2_format {
static const struct rzg2l_csi2_format rzg2l_csi2_formats[] = {
{ .code = MEDIA_BUS_FMT_UYVY8_1X16, .bpp = 16 },
+ { .code = MEDIA_BUS_FMT_SBGGR8_1X8, .bpp = 8, },
+ { .code = MEDIA_BUS_FMT_SGBRG8_1X8, .bpp = 8, },
+ { .code = MEDIA_BUS_FMT_SGRBG8_1X8, .bpp = 8, },
+ { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .bpp = 8, },
};
static inline struct rzg2l_csi2 *sd_to_csi2(struct v4l2_subdev *sd)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index ad470de440ad..982c996cc777 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -18,6 +18,34 @@ static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
.bpp = 2,
.icndmr = ICnDMR_YCMODE_UYVY,
},
+ {
+ .code = MEDIA_BUS_FMT_SBGGR8_1X8,
+ .format = V4L2_PIX_FMT_SBGGR8,
+ .datatype = MIPI_CSI2_DT_RAW8,
+ .bpp = 1,
+ .icndmr = 0,
+ },
+ {
+ .code = MEDIA_BUS_FMT_SGBRG8_1X8,
+ .format = V4L2_PIX_FMT_SGBRG8,
+ .datatype = MIPI_CSI2_DT_RAW8,
+ .bpp = 1,
+ .icndmr = 0,
+ },
+ {
+ .code = MEDIA_BUS_FMT_SGRBG8_1X8,
+ .format = V4L2_PIX_FMT_SGRBG8,
+ .datatype = MIPI_CSI2_DT_RAW8,
+ .bpp = 1,
+ .icndmr = 0,
+ },
+ {
+ .code = MEDIA_BUS_FMT_SRGGB8_1X8,
+ .format = V4L2_PIX_FMT_SRGGB8,
+ .datatype = MIPI_CSI2_DT_RAW8,
+ .bpp = 1,
+ .icndmr = 0,
+ },
};
const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int code)
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread* [PATCH v5 22/22] media: rzg2l-cru: Move register definitions to a separate file
2024-10-11 17:30 [PATCH v5 00/22] media: platform: rzg2l-cru: CSI-2 and CRU enhancements Prabhakar
` (20 preceding siblings ...)
2024-10-11 17:30 ` [PATCH v5 21/22] media: rzg2l-cru: Add support to capture 8bit raw sRGB Prabhakar
@ 2024-10-11 17:30 ` Prabhakar
21 siblings, 0 replies; 36+ messages in thread
From: Prabhakar @ 2024-10-11 17:30 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Hans Verkuil,
Sakari Ailus
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Move the RZ/G2L CRU register definitions from `rzg2l-video.c` to a
dedicated header file, `rzg2l-cru-regs.h`. Separating these definitions
into their own file improves the readability of the code.
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>
---
.../renesas/rzg2l-cru/rzg2l-cru-regs.h | 80 +++++++++++++++++++
.../platform/renesas/rzg2l-cru/rzg2l-cru.h | 2 -
.../platform/renesas/rzg2l-cru/rzg2l-ip.c | 1 +
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 69 +---------------
4 files changed, 82 insertions(+), 70 deletions(-)
create mode 100644 drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
new file mode 100644
index 000000000000..1c9f22118a5d
--- /dev/null
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru-regs.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * rzg2l-cru-regs.h--RZ/G2L (and alike SoCs) CRU Registers Definitions
+ *
+ * Copyright (C) 2024 Renesas Electronics Corp.
+ */
+
+#ifndef __RZG2L_CRU_REGS_H__
+#define __RZG2L_CRU_REGS_H__
+
+/* HW CRU Registers Definition */
+
+/* CRU Control Register */
+#define CRUnCTRL 0x0
+#define CRUnCTRL_VINSEL(x) ((x) << 0)
+
+/* CRU Interrupt Enable Register */
+#define CRUnIE 0x4
+#define CRUnIE_EFE BIT(17)
+
+/* CRU Interrupt Status Register */
+#define CRUnINTS 0x8
+#define CRUnINTS_SFS BIT(16)
+
+/* CRU Reset Register */
+#define CRUnRST 0xc
+#define CRUnRST_VRESETN BIT(0)
+
+/* Memory Bank Base Address (Lower) Register for CRU Image Data */
+#define AMnMBxADDRL(x) (0x100 + ((x) * 8))
+
+/* Memory Bank Base Address (Higher) Register for CRU Image Data */
+#define AMnMBxADDRH(x) (0x104 + ((x) * 8))
+
+/* Memory Bank Enable Register for CRU Image Data */
+#define AMnMBVALID 0x148
+#define AMnMBVALID_MBVALID(x) GENMASK(x, 0)
+
+/* Memory Bank Status Register for CRU Image Data */
+#define AMnMBS 0x14c
+#define AMnMBS_MBSTS 0x7
+
+/* AXI Master Transfer Setting Register for CRU Image Data */
+#define AMnAXIATTR 0x158
+#define AMnAXIATTR_AXILEN_MASK GENMASK(3, 0)
+#define AMnAXIATTR_AXILEN (0xf)
+
+/* AXI Master FIFO Pointer Register for CRU Image Data */
+#define AMnFIFOPNTR 0x168
+#define AMnFIFOPNTR_FIFOWPNTR GENMASK(7, 0)
+#define AMnFIFOPNTR_FIFORPNTR_Y GENMASK(23, 16)
+
+/* AXI Master Transfer Stop Register for CRU Image Data */
+#define AMnAXISTP 0x174
+#define AMnAXISTP_AXI_STOP BIT(0)
+
+/* AXI Master Transfer Stop Status Register for CRU Image Data */
+#define AMnAXISTPACK 0x178
+#define AMnAXISTPACK_AXI_STOP_ACK BIT(0)
+
+/* CRU Image Processing Enable Register */
+#define ICnEN 0x200
+#define ICnEN_ICEN BIT(0)
+
+/* CRU Image Processing Main Control Register */
+#define ICnMC 0x208
+#define ICnMC_CSCTHR BIT(5)
+#define ICnMC_INF(x) ((x) << 16)
+#define ICnMC_VCSEL(x) ((x) << 22)
+#define ICnMC_INF_MASK GENMASK(21, 16)
+
+/* CRU Module Status Register */
+#define ICnMS 0x254
+#define ICnMS_IA BIT(2)
+
+/* CRU Data Output Mode Register */
+#define ICnDMR 0x26c
+#define ICnDMR_YCMODE_UYVY (1 << 4)
+
+#endif /* __RZG2L_CRU_REGS_H__ */
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
index c40754732576..a83e78d9b0be 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-cru.h
@@ -31,8 +31,6 @@
#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,
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
index 982c996cc777..d935d981f9d3 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c
@@ -9,6 +9,7 @@
#include <media/mipi-csi2.h>
#include "rzg2l-cru.h"
+#include "rzg2l-cru-regs.h"
static const struct rzg2l_cru_ip_format rzg2l_cru_ip_formats[] = {
{
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index a686a5cd4f59..a4dc3689599c 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -20,74 +20,7 @@
#include <media/videobuf2-dma-contig.h>
#include "rzg2l-cru.h"
-
-/* HW CRU Registers Definition */
-
-/* CRU Control Register */
-#define CRUnCTRL 0x0
-#define CRUnCTRL_VINSEL(x) ((x) << 0)
-
-/* CRU Interrupt Enable Register */
-#define CRUnIE 0x4
-#define CRUnIE_EFE BIT(17)
-
-/* CRU Interrupt Status Register */
-#define CRUnINTS 0x8
-#define CRUnINTS_SFS BIT(16)
-
-/* CRU Reset Register */
-#define CRUnRST 0xc
-#define CRUnRST_VRESETN BIT(0)
-
-/* Memory Bank Base Address (Lower) Register for CRU Image Data */
-#define AMnMBxADDRL(x) (0x100 + ((x) * 8))
-
-/* Memory Bank Base Address (Higher) Register for CRU Image Data */
-#define AMnMBxADDRH(x) (0x104 + ((x) * 8))
-
-/* Memory Bank Enable Register for CRU Image Data */
-#define AMnMBVALID 0x148
-#define AMnMBVALID_MBVALID(x) GENMASK(x, 0)
-
-/* Memory Bank Status Register for CRU Image Data */
-#define AMnMBS 0x14c
-#define AMnMBS_MBSTS 0x7
-
-/* AXI Master Transfer Setting Register for CRU Image Data */
-#define AMnAXIATTR 0x158
-#define AMnAXIATTR_AXILEN_MASK GENMASK(3, 0)
-#define AMnAXIATTR_AXILEN (0xf)
-
-/* AXI Master FIFO Pointer Register for CRU Image Data */
-#define AMnFIFOPNTR 0x168
-#define AMnFIFOPNTR_FIFOWPNTR GENMASK(7, 0)
-#define AMnFIFOPNTR_FIFORPNTR_Y GENMASK(23, 16)
-
-/* AXI Master Transfer Stop Register for CRU Image Data */
-#define AMnAXISTP 0x174
-#define AMnAXISTP_AXI_STOP BIT(0)
-
-/* AXI Master Transfer Stop Status Register for CRU Image Data */
-#define AMnAXISTPACK 0x178
-#define AMnAXISTPACK_AXI_STOP_ACK BIT(0)
-
-/* CRU Image Processing Enable Register */
-#define ICnEN 0x200
-#define ICnEN_ICEN BIT(0)
-
-/* CRU Image Processing Main Control Register */
-#define ICnMC 0x208
-#define ICnMC_CSCTHR BIT(5)
-#define ICnMC_INF(x) ((x) << 16)
-#define ICnMC_VCSEL(x) ((x) << 22)
-#define ICnMC_INF_MASK GENMASK(21, 16)
-
-/* CRU Module Status Register */
-#define ICnMS 0x254
-#define ICnMS_IA BIT(2)
-
-/* CRU Data Output Mode Register */
-#define ICnDMR 0x26c
+#include "rzg2l-cru-regs.h"
#define RZG2L_TIMEOUT_MS 100
#define RZG2L_RETRIES 10
--
2.43.0
^ permalink raw reply related [flat|nested] 36+ messages in thread