* [PATCH 0/3] media: rcar: Fix RAW formats
@ 2025-03-24 11:48 Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value Tomi Valkeinen
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2025-03-24 11:48 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Sakari Ailus
Cc: linux-media, linux-renesas-soc, linux-kernel,
Niklas Söderlund, Mauro Carvalho Chehab, Tomi Valkeinen
Fix RAW8 and RAW10 formats. These are taken from the previously sent
"[PATCH 00/18] media: rcar: Streams support" series.
I can only test these with multi-stream setup, which requires a big pile
of patches on top, so these are not really tested in upstream.
Tomi
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
Tomi Valkeinen (3):
media: rcar-vin: Add RCAR_GEN4 model value
media: rcar-vin: Fix RAW8
media: rcar-vin: Fix RAW10
drivers/media/platform/renesas/rcar-vin/rcar-core.c | 2 +-
drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 20 ++++++++++++++------
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
drivers/media/platform/renesas/rcar-vin/rcar-vin.h | 1 +
4 files changed, 20 insertions(+), 11 deletions(-)
---
base-commit: f2151613e040973c868d28c8b00885dfab69eb75
change-id: 20250324-rcar-fix-raw-c7967ff85d3e
Best regards,
--
Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value
2025-03-24 11:48 [PATCH 0/3] media: rcar: Fix RAW formats Tomi Valkeinen
@ 2025-03-24 11:48 ` Tomi Valkeinen
2025-03-31 21:13 ` Niklas Söderlund
2025-03-24 11:48 ` [PATCH 2/3] media: rcar-vin: Fix RAW8 Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 3/3] media: rcar-vin: Fix RAW10 Tomi Valkeinen
2 siblings, 1 reply; 12+ messages in thread
From: Tomi Valkeinen @ 2025-03-24 11:48 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Sakari Ailus
Cc: linux-media, linux-renesas-soc, linux-kernel,
Niklas Söderlund, Mauro Carvalho Chehab, Tomi Valkeinen
Currently Gen4 VINs are marked as RCAN_GEN3 models. Add a new enum
value, RCAR_GEN4, and use it for Gen4 VINs. No functional changes in
this patch.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-vin/rcar-core.c | 2 +-
drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 8 ++++----
drivers/media/platform/renesas/rcar-vin/rcar-vin.h | 1 +
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
index ddfb18e6e7a4..88989c5fe636 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
@@ -1275,7 +1275,7 @@ static const struct rvin_info rcar_info_r8a77995 = {
};
static const struct rvin_info rcar_info_gen4 = {
- .model = RCAR_GEN3,
+ .model = RCAR_GEN4,
.use_mc = true,
.use_isp = true,
.nv12 = true,
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
index 8de871240440..972ae2cb3314 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
@@ -803,7 +803,7 @@ static int rvin_setup(struct rvin_dev *vin)
}
/* Make sure input interface and input format is valid. */
- if (vin->info->model == RCAR_GEN3) {
+ if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) {
switch (vnmc & VNMC_INF_MASK) {
case VNMC_INF_YUV8_BT656:
case VNMC_INF_YUV10_BT656:
@@ -826,7 +826,7 @@ static int rvin_setup(struct rvin_dev *vin)
}
/* Enable VSYNC Field Toggle mode after one VSYNC input */
- if (vin->info->model == RCAR_GEN3)
+ if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4)
dmr2 = VNDMR2_FTEV;
else
dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
@@ -926,7 +926,7 @@ static int rvin_setup(struct rvin_dev *vin)
if (input_is_yuv == output_is_yuv)
vnmc |= VNMC_BPS;
- if (vin->info->model == RCAR_GEN3) {
+ if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) {
/* Select between CSI-2 and parallel input */
if (vin->is_csi)
vnmc &= ~VNMC_DPINE;
@@ -1351,7 +1351,7 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
if (rvin_scaler_needed(vin)) {
/* Gen3 can't scale NV12 */
- if (vin->info->model == RCAR_GEN3 &&
+ if ((vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) &&
vin->format.pixelformat == V4L2_PIX_FMT_NV12)
return -EPIPE;
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
index f87d4bc9e53e..34bbd1343bf6 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
@@ -39,6 +39,7 @@ enum model_id {
RCAR_M1,
RCAR_GEN2,
RCAR_GEN3,
+ RCAR_GEN4,
};
enum rvin_csi_id {
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] media: rcar-vin: Fix RAW8
2025-03-24 11:48 [PATCH 0/3] media: rcar: Fix RAW formats Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value Tomi Valkeinen
@ 2025-03-24 11:48 ` Tomi Valkeinen
2025-03-31 21:16 ` Niklas Söderlund
2025-03-24 11:48 ` [PATCH 3/3] media: rcar-vin: Fix RAW10 Tomi Valkeinen
2 siblings, 1 reply; 12+ messages in thread
From: Tomi Valkeinen @ 2025-03-24 11:48 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Sakari Ailus
Cc: linux-media, linux-renesas-soc, linux-kernel,
Niklas Söderlund, Mauro Carvalho Chehab, Tomi Valkeinen
On Gen4 we need to set VNMC's EXINF to a different value (1) than in
Gen3 (0). Add a define for this, and set the bit for Gen4.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
index 972ae2cb3314..53046614f7a1 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
@@ -94,6 +94,7 @@
#define VNMC_INF_YUV16 (5 << 16)
#define VNMC_INF_RGB888 (6 << 16)
#define VNMC_INF_RGB666 (7 << 16)
+#define VNMC_EXINF_RAW8 (1 << 12) /* Gen4 specific */
#define VNMC_VUP (1 << 10)
#define VNMC_IM_ODD (0 << 3)
#define VNMC_IM_ODD_EVEN (1 << 3)
@@ -791,6 +792,8 @@ static int rvin_setup(struct rvin_dev *vin)
case MEDIA_BUS_FMT_SRGGB8_1X8:
case MEDIA_BUS_FMT_Y8_1X8:
vnmc |= VNMC_INF_RAW8;
+ if (vin->info->model == RCAR_GEN4)
+ vnmc |= VNMC_EXINF_RAW8;
break;
case MEDIA_BUS_FMT_SBGGR10_1X10:
case MEDIA_BUS_FMT_SGBRG10_1X10:
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-03-24 11:48 [PATCH 0/3] media: rcar: Fix RAW formats Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 2/3] media: rcar-vin: Fix RAW8 Tomi Valkeinen
@ 2025-03-24 11:48 ` Tomi Valkeinen
2025-03-31 21:11 ` Niklas Söderlund
2 siblings, 1 reply; 12+ messages in thread
From: Tomi Valkeinen @ 2025-03-24 11:48 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Sakari Ailus
Cc: linux-media, linux-renesas-soc, linux-kernel,
Niklas Söderlund, Mauro Carvalho Chehab, Tomi Valkeinen
Fix the following to get RAW10 formats working:
In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
16-bit containers, the bpp should be 2.
Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
Through Mode", used for YUV formats and should not be set for RAW10.
Fix the check related to the RGB666 format and CSI-2 mode. The
VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
This feels a bit hacky, though, and the formats should really have been
verified already earlier.
Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
index 53046614f7a1..f8394be8a922 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
@@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
case VNMC_INF_YUV8_BT656:
case VNMC_INF_YUV10_BT656:
case VNMC_INF_YUV16:
- case VNMC_INF_RGB666:
if (vin->is_csi) {
vin_err(vin, "Invalid setting in MIPI CSI2\n");
return -EINVAL;
}
break;
+ case VNMC_INF_RGB666:
+ if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
+ vin_err(vin, "Invalid setting in MIPI CSI2\n");
+ return -EINVAL;
+ }
+ break;
case VNMC_INF_RAW8:
if (!vin->is_csi) {
vin_err(vin, "Invalid setting in Digital Pins\n");
@@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
case V4L2_PIX_FMT_SGBRG10:
case V4L2_PIX_FMT_SGRBG10:
case V4L2_PIX_FMT_SRGGB10:
- dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
+ dmr = VNDMR_RMODE_RAW10;
break;
default:
vin_err(vin, "Invalid pixelformat (0x%x)\n",
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
index 756fdfdbce61..65da8d513b52 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
@@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
},
{
.fourcc = V4L2_PIX_FMT_SBGGR10,
- .bpp = 4,
+ .bpp = 2,
},
{
.fourcc = V4L2_PIX_FMT_SGBRG10,
- .bpp = 4,
+ .bpp = 2,
},
{
.fourcc = V4L2_PIX_FMT_SGRBG10,
- .bpp = 4,
+ .bpp = 2,
},
{
.fourcc = V4L2_PIX_FMT_SRGGB10,
- .bpp = 4,
+ .bpp = 2,
},
};
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-03-24 11:48 ` [PATCH 3/3] media: rcar-vin: Fix RAW10 Tomi Valkeinen
@ 2025-03-31 21:11 ` Niklas Söderlund
2025-04-03 8:15 ` Tomi Valkeinen
2025-04-03 8:18 ` Tomi Valkeinen
0 siblings, 2 replies; 12+ messages in thread
From: Niklas Söderlund @ 2025-03-31 21:11 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi Tomi,
Thanks for your work.
On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
> Fix the following to get RAW10 formats working:
>
> In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
> 16-bit containers, the bpp should be 2.
>
> Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
> Through Mode", used for YUV formats and should not be set for RAW10.
>
> Fix the check related to the RGB666 format and CSI-2 mode. The
> VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
> is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
> This feels a bit hacky, though, and the formats should really have been
> verified already earlier.
I agree, it feels hacky. I would rather just remove the while switch
then try to "fix" it by extending it more. When testing this series I
needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
Gen4.
>
> Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 53046614f7a1..f8394be8a922 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
> case VNMC_INF_YUV8_BT656:
> case VNMC_INF_YUV10_BT656:
> case VNMC_INF_YUV16:
> - case VNMC_INF_RGB666:
> if (vin->is_csi) {
> vin_err(vin, "Invalid setting in MIPI CSI2\n");
> return -EINVAL;
> }
> break;
> + case VNMC_INF_RGB666:
> + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
> + vin_err(vin, "Invalid setting in MIPI CSI2\n");
> + return -EINVAL;
> + }
> + break;
> case VNMC_INF_RAW8:
> if (!vin->is_csi) {
> vin_err(vin, "Invalid setting in Digital Pins\n");
> @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
> case V4L2_PIX_FMT_SGBRG10:
> case V4L2_PIX_FMT_SGRBG10:
> case V4L2_PIX_FMT_SRGGB10:
> - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
> + dmr = VNDMR_RMODE_RAW10;
> break;
> default:
> vin_err(vin, "Invalid pixelformat (0x%x)\n",
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> index 756fdfdbce61..65da8d513b52 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
> },
> {
> .fourcc = V4L2_PIX_FMT_SBGGR10,
> - .bpp = 4,
> + .bpp = 2,
> },
> {
> .fourcc = V4L2_PIX_FMT_SGBRG10,
> - .bpp = 4,
> + .bpp = 2,
> },
> {
> .fourcc = V4L2_PIX_FMT_SGRBG10,
> - .bpp = 4,
> + .bpp = 2,
> },
> {
> .fourcc = V4L2_PIX_FMT_SRGGB10,
> - .bpp = 4,
> + .bpp = 2,
> },
> };
>
>
> --
> 2.43.0
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value
2025-03-24 11:48 ` [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value Tomi Valkeinen
@ 2025-03-31 21:13 ` Niklas Söderlund
0 siblings, 0 replies; 12+ messages in thread
From: Niklas Söderlund @ 2025-03-31 21:13 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi Tomi,
Thanks for your work.
On 2025-03-24 13:48:52 +0200, Tomi Valkeinen wrote:
> Currently Gen4 VINs are marked as RCAN_GEN3 models. Add a new enum
> value, RCAR_GEN4, and use it for Gen4 VINs. No functional changes in
> this patch.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-core.c | 2 +-
> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 8 ++++----
> drivers/media/platform/renesas/rcar-vin/rcar-vin.h | 1 +
> 3 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> index ddfb18e6e7a4..88989c5fe636 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
> @@ -1275,7 +1275,7 @@ static const struct rvin_info rcar_info_r8a77995 = {
> };
>
> static const struct rvin_info rcar_info_gen4 = {
> - .model = RCAR_GEN3,
> + .model = RCAR_GEN4,
> .use_mc = true,
> .use_isp = true,
> .nv12 = true,
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 8de871240440..972ae2cb3314 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -803,7 +803,7 @@ static int rvin_setup(struct rvin_dev *vin)
> }
>
> /* Make sure input interface and input format is valid. */
> - if (vin->info->model == RCAR_GEN3) {
> + if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) {
> switch (vnmc & VNMC_INF_MASK) {
> case VNMC_INF_YUV8_BT656:
> case VNMC_INF_YUV10_BT656:
> @@ -826,7 +826,7 @@ static int rvin_setup(struct rvin_dev *vin)
> }
>
> /* Enable VSYNC Field Toggle mode after one VSYNC input */
> - if (vin->info->model == RCAR_GEN3)
> + if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4)
> dmr2 = VNDMR2_FTEV;
> else
> dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
> @@ -926,7 +926,7 @@ static int rvin_setup(struct rvin_dev *vin)
> if (input_is_yuv == output_is_yuv)
> vnmc |= VNMC_BPS;
>
> - if (vin->info->model == RCAR_GEN3) {
> + if (vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) {
> /* Select between CSI-2 and parallel input */
> if (vin->is_csi)
> vnmc &= ~VNMC_DPINE;
> @@ -1351,7 +1351,7 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
>
> if (rvin_scaler_needed(vin)) {
> /* Gen3 can't scale NV12 */
> - if (vin->info->model == RCAR_GEN3 &&
> + if ((vin->info->model == RCAR_GEN3 || vin->info->model == RCAR_GEN4) &&
> vin->format.pixelformat == V4L2_PIX_FMT_NV12)
> return -EPIPE;
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
> index f87d4bc9e53e..34bbd1343bf6 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-vin.h
> @@ -39,6 +39,7 @@ enum model_id {
> RCAR_M1,
> RCAR_GEN2,
> RCAR_GEN3,
> + RCAR_GEN4,
> };
>
> enum rvin_csi_id {
>
> --
> 2.43.0
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] media: rcar-vin: Fix RAW8
2025-03-24 11:48 ` [PATCH 2/3] media: rcar-vin: Fix RAW8 Tomi Valkeinen
@ 2025-03-31 21:16 ` Niklas Söderlund
0 siblings, 0 replies; 12+ messages in thread
From: Niklas Söderlund @ 2025-03-31 21:16 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi Tomi,
Thanks for your patch.
On 2025-03-24 13:48:53 +0200, Tomi Valkeinen wrote:
> On Gen4 we need to set VNMC's EXINF to a different value (1) than in
> Gen3 (0). Add a define for this, and set the bit for Gen4.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 972ae2cb3314..53046614f7a1 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -94,6 +94,7 @@
> #define VNMC_INF_YUV16 (5 << 16)
> #define VNMC_INF_RGB888 (6 << 16)
> #define VNMC_INF_RGB666 (7 << 16)
> +#define VNMC_EXINF_RAW8 (1 << 12) /* Gen4 specific */
> #define VNMC_VUP (1 << 10)
> #define VNMC_IM_ODD (0 << 3)
> #define VNMC_IM_ODD_EVEN (1 << 3)
> @@ -791,6 +792,8 @@ static int rvin_setup(struct rvin_dev *vin)
> case MEDIA_BUS_FMT_SRGGB8_1X8:
> case MEDIA_BUS_FMT_Y8_1X8:
> vnmc |= VNMC_INF_RAW8;
> + if (vin->info->model == RCAR_GEN4)
> + vnmc |= VNMC_EXINF_RAW8;
This is a partial fix for RAW8, but more was needed to capture it
correctly. But that issue covers more then just RAW8, I will send a
proper patch to fix that. For this patch,
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> break;
> case MEDIA_BUS_FMT_SBGGR10_1X10:
> case MEDIA_BUS_FMT_SGBRG10_1X10:
>
> --
> 2.43.0
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-03-31 21:11 ` Niklas Söderlund
@ 2025-04-03 8:15 ` Tomi Valkeinen
2025-04-03 8:57 ` Niklas Söderlund
2025-04-03 8:18 ` Tomi Valkeinen
1 sibling, 1 reply; 12+ messages in thread
From: Tomi Valkeinen @ 2025-04-03 8:15 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi,
On 01/04/2025 00:11, Niklas Söderlund wrote:
> Hi Tomi,
>
> Thanks for your work.
>
> On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
>> Fix the following to get RAW10 formats working:
>>
>> In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
>> 16-bit containers, the bpp should be 2.
>>
>> Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
>> Through Mode", used for YUV formats and should not be set for RAW10.
>>
>> Fix the check related to the RGB666 format and CSI-2 mode. The
>> VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
>> is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
>> This feels a bit hacky, though, and the formats should really have been
>> verified already earlier.
>
> I agree, it feels hacky. I would rather just remove the while switch
> then try to "fix" it by extending it more. When testing this series I
> needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
> Gen4.
Why is that? What is VNMC_INF_RAW8 overlapping with?
Tomi
>>
>> Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>> ---
>> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
>> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
>> 2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> index 53046614f7a1..f8394be8a922 100644
>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
>> case VNMC_INF_YUV8_BT656:
>> case VNMC_INF_YUV10_BT656:
>> case VNMC_INF_YUV16:
>> - case VNMC_INF_RGB666:
>> if (vin->is_csi) {
>> vin_err(vin, "Invalid setting in MIPI CSI2\n");
>> return -EINVAL;
>> }
>> break;
>> + case VNMC_INF_RGB666:
>> + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
>> + vin_err(vin, "Invalid setting in MIPI CSI2\n");
>> + return -EINVAL;
>> + }
>> + break;
>> case VNMC_INF_RAW8:
>> if (!vin->is_csi) {
>> vin_err(vin, "Invalid setting in Digital Pins\n");
>> @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
>> case V4L2_PIX_FMT_SGBRG10:
>> case V4L2_PIX_FMT_SGRBG10:
>> case V4L2_PIX_FMT_SRGGB10:
>> - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
>> + dmr = VNDMR_RMODE_RAW10;
>> break;
>> default:
>> vin_err(vin, "Invalid pixelformat (0x%x)\n",
>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> index 756fdfdbce61..65da8d513b52 100644
>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SBGGR10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SGBRG10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SGRBG10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SRGGB10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> };
>>
>>
>> --
>> 2.43.0
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-03-31 21:11 ` Niklas Söderlund
2025-04-03 8:15 ` Tomi Valkeinen
@ 2025-04-03 8:18 ` Tomi Valkeinen
1 sibling, 0 replies; 12+ messages in thread
From: Tomi Valkeinen @ 2025-04-03 8:18 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi,
On 01/04/2025 00:11, Niklas Söderlund wrote:
> Hi Tomi,
>
> Thanks for your work.
>
> On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
>> Fix the following to get RAW10 formats working:
>>
>> In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
>> 16-bit containers, the bpp should be 2.
>>
>> Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
>> Through Mode", used for YUV formats and should not be set for RAW10.
>>
>> Fix the check related to the RGB666 format and CSI-2 mode. The
>> VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
>> is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
>> This feels a bit hacky, though, and the formats should really have been
>> verified already earlier.
>
> I agree, it feels hacky. I would rather just remove the while switch
> then try to "fix" it by extending it more. When testing this series I
> needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
> Gen4.
Also, I think it's fine to be a bit hacky to have a small fix for a
feature already in upstream, instead of doing a bigger restructuring to
fix it.
All this should be cleaned up, but in my opinion it's better to do that
on top of a working upstream.
Tomi
>>
>> Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>> ---
>> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
>> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
>> 2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> index 53046614f7a1..f8394be8a922 100644
>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>> @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
>> case VNMC_INF_YUV8_BT656:
>> case VNMC_INF_YUV10_BT656:
>> case VNMC_INF_YUV16:
>> - case VNMC_INF_RGB666:
>> if (vin->is_csi) {
>> vin_err(vin, "Invalid setting in MIPI CSI2\n");
>> return -EINVAL;
>> }
>> break;
>> + case VNMC_INF_RGB666:
>> + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
>> + vin_err(vin, "Invalid setting in MIPI CSI2\n");
>> + return -EINVAL;
>> + }
>> + break;
>> case VNMC_INF_RAW8:
>> if (!vin->is_csi) {
>> vin_err(vin, "Invalid setting in Digital Pins\n");
>> @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
>> case V4L2_PIX_FMT_SGBRG10:
>> case V4L2_PIX_FMT_SGRBG10:
>> case V4L2_PIX_FMT_SRGGB10:
>> - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
>> + dmr = VNDMR_RMODE_RAW10;
>> break;
>> default:
>> vin_err(vin, "Invalid pixelformat (0x%x)\n",
>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> index 756fdfdbce61..65da8d513b52 100644
>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>> @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SBGGR10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SGBRG10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SGRBG10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> {
>> .fourcc = V4L2_PIX_FMT_SRGGB10,
>> - .bpp = 4,
>> + .bpp = 2,
>> },
>> };
>>
>>
>> --
>> 2.43.0
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-04-03 8:15 ` Tomi Valkeinen
@ 2025-04-03 8:57 ` Niklas Söderlund
2025-04-03 9:12 ` Tomi Valkeinen
0 siblings, 1 reply; 12+ messages in thread
From: Niklas Söderlund @ 2025-04-03 8:57 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi Tomi,
On 2025-04-03 11:15:04 +0300, Tomi Valkeinen wrote:
> Hi,
>
> On 01/04/2025 00:11, Niklas Söderlund wrote:
> > Hi Tomi,
> >
> > Thanks for your work.
> >
> > On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
> > > Fix the following to get RAW10 formats working:
> > >
> > > In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
> > > 16-bit containers, the bpp should be 2.
> > >
> > > Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
> > > Through Mode", used for YUV formats and should not be set for RAW10.
> > >
> > > Fix the check related to the RGB666 format and CSI-2 mode. The
> > > VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
> > > is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
> > > This feels a bit hacky, though, and the formats should really have been
> > > verified already earlier.
> >
> > I agree, it feels hacky. I would rather just remove the while switch
> > then try to "fix" it by extending it more. When testing this series I
> > needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
> > Gen4.
>
> Why is that? What is VNMC_INF_RAW8 overlapping with?
VNMC_INF_RAW8 is not overlapping the issue is the "if (!vin->is_csi)"
check. On Gen3 RAW8 was supposedly only supported on the CSI-2 input,
and not on the parallel bus available on some VIN instances.
On Gen4 the checks around vin->is_csi becomes skewed and as you point
out should be cloned up. The effect at the moment however is that o Gen4
when trying to capture RAW8 is_csi is not set (as this is a gen3 thing)
and the "Invalid setting in Digital Pins" error path is hit.
Locally I have now removed this whole swtich, as you point out the
formats should already be checked, and as far as I can tell they are.
This check is a relic from early Gen3 support. And really proves after
the Gen2 media graph clenups are done we should split rcar-dma.c ->
rcar-dma-gen{2,3,4}.c to get rid of this mess ;-)
I would change this patch to just remove the whole switch. If you want
to keep this fix as is I'm ok with that. I can submit a patch removing
the switch if you like on top.
>
> Tomi
>
> > >
> > > Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
> > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> > > ---
> > > drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
> > > drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
> > > 2 files changed, 11 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > index 53046614f7a1..f8394be8a922 100644
> > > --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
> > > case VNMC_INF_YUV8_BT656:
> > > case VNMC_INF_YUV10_BT656:
> > > case VNMC_INF_YUV16:
> > > - case VNMC_INF_RGB666:
> > > if (vin->is_csi) {
> > > vin_err(vin, "Invalid setting in MIPI CSI2\n");
> > > return -EINVAL;
> > > }
> > > break;
> > > + case VNMC_INF_RGB666:
> > > + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
> > > + vin_err(vin, "Invalid setting in MIPI CSI2\n");
> > > + return -EINVAL;
> > > + }
> > > + break;
> > > case VNMC_INF_RAW8:
> > > if (!vin->is_csi) {
> > > vin_err(vin, "Invalid setting in Digital Pins\n");
> > > @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
> > > case V4L2_PIX_FMT_SGBRG10:
> > > case V4L2_PIX_FMT_SGRBG10:
> > > case V4L2_PIX_FMT_SRGGB10:
> > > - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
> > > + dmr = VNDMR_RMODE_RAW10;
> > > break;
> > > default:
> > > vin_err(vin, "Invalid pixelformat (0x%x)\n",
> > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > index 756fdfdbce61..65da8d513b52 100644
> > > --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
> > > },
> > > {
> > > .fourcc = V4L2_PIX_FMT_SBGGR10,
> > > - .bpp = 4,
> > > + .bpp = 2,
> > > },
> > > {
> > > .fourcc = V4L2_PIX_FMT_SGBRG10,
> > > - .bpp = 4,
> > > + .bpp = 2,
> > > },
> > > {
> > > .fourcc = V4L2_PIX_FMT_SGRBG10,
> > > - .bpp = 4,
> > > + .bpp = 2,
> > > },
> > > {
> > > .fourcc = V4L2_PIX_FMT_SRGGB10,
> > > - .bpp = 4,
> > > + .bpp = 2,
> > > },
> > > };
> > >
> > > --
> > > 2.43.0
> > >
> >
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-04-03 8:57 ` Niklas Söderlund
@ 2025-04-03 9:12 ` Tomi Valkeinen
2025-04-03 9:36 ` Niklas Söderlund
0 siblings, 1 reply; 12+ messages in thread
From: Tomi Valkeinen @ 2025-04-03 9:12 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi,
On 03/04/2025 11:57, Niklas Söderlund wrote:
> Hi Tomi,
>
> On 2025-04-03 11:15:04 +0300, Tomi Valkeinen wrote:
>> Hi,
>>
>> On 01/04/2025 00:11, Niklas Söderlund wrote:
>>> Hi Tomi,
>>>
>>> Thanks for your work.
>>>
>>> On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
>>>> Fix the following to get RAW10 formats working:
>>>>
>>>> In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
>>>> 16-bit containers, the bpp should be 2.
>>>>
>>>> Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
>>>> Through Mode", used for YUV formats and should not be set for RAW10.
>>>>
>>>> Fix the check related to the RGB666 format and CSI-2 mode. The
>>>> VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
>>>> is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
>>>> This feels a bit hacky, though, and the formats should really have been
>>>> verified already earlier.
>>>
>>> I agree, it feels hacky. I would rather just remove the while switch
>>> then try to "fix" it by extending it more. When testing this series I
>>> needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
>>> Gen4.
>>
>> Why is that? What is VNMC_INF_RAW8 overlapping with?
>
> VNMC_INF_RAW8 is not overlapping the issue is the "if (!vin->is_csi)"
> check. On Gen3 RAW8 was supposedly only supported on the CSI-2 input,
> and not on the parallel bus available on some VIN instances.
>
> On Gen4 the checks around vin->is_csi becomes skewed and as you point
> out should be cloned up. The effect at the moment however is that o Gen4
> when trying to capture RAW8 is_csi is not set (as this is a gen3 thing)
> and the "Invalid setting in Digital Pins" error path is hit.
Ok. I was wondering why it worked for me. But maybe the reason it worked
for me was the extra series from you, which also changed these checks to
rvin_remote_is_parallel(). And perhaps that function works fine, while
the older vin->is_csi didn't.
> Locally I have now removed this whole swtich, as you point out the
> formats should already be checked, and as far as I can tell they are.
> This check is a relic from early Gen3 support. And really proves after
> the Gen2 media graph clenups are done we should split rcar-dma.c ->
> rcar-dma-gen{2,3,4}.c to get rid of this mess ;-)
>
> I would change this patch to just remove the whole switch. If you want
> to keep this fix as is I'm ok with that. I can submit a patch removing
> the switch if you like on top.
Ok, if you think removing the switch is fine, we can do that. I wasn't
sure of the flow in the driver so I wasn't confident I could just drop
it (especially considering pre-gen4, with which I have no experience).
Thus this patch.
Tomi
>
>>
>> Tomi
>>
>>>>
>>>> Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
>>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
>>>> ---
>>>> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
>>>> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
>>>> 2 files changed, 11 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>>>> index 53046614f7a1..f8394be8a922 100644
>>>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>>>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
>>>> @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
>>>> case VNMC_INF_YUV8_BT656:
>>>> case VNMC_INF_YUV10_BT656:
>>>> case VNMC_INF_YUV16:
>>>> - case VNMC_INF_RGB666:
>>>> if (vin->is_csi) {
>>>> vin_err(vin, "Invalid setting in MIPI CSI2\n");
>>>> return -EINVAL;
>>>> }
>>>> break;
>>>> + case VNMC_INF_RGB666:
>>>> + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
>>>> + vin_err(vin, "Invalid setting in MIPI CSI2\n");
>>>> + return -EINVAL;
>>>> + }
>>>> + break;
>>>> case VNMC_INF_RAW8:
>>>> if (!vin->is_csi) {
>>>> vin_err(vin, "Invalid setting in Digital Pins\n");
>>>> @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
>>>> case V4L2_PIX_FMT_SGBRG10:
>>>> case V4L2_PIX_FMT_SGRBG10:
>>>> case V4L2_PIX_FMT_SRGGB10:
>>>> - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
>>>> + dmr = VNDMR_RMODE_RAW10;
>>>> break;
>>>> default:
>>>> vin_err(vin, "Invalid pixelformat (0x%x)\n",
>>>> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>>>> index 756fdfdbce61..65da8d513b52 100644
>>>> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>>>> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
>>>> @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
>>>> },
>>>> {
>>>> .fourcc = V4L2_PIX_FMT_SBGGR10,
>>>> - .bpp = 4,
>>>> + .bpp = 2,
>>>> },
>>>> {
>>>> .fourcc = V4L2_PIX_FMT_SGBRG10,
>>>> - .bpp = 4,
>>>> + .bpp = 2,
>>>> },
>>>> {
>>>> .fourcc = V4L2_PIX_FMT_SGRBG10,
>>>> - .bpp = 4,
>>>> + .bpp = 2,
>>>> },
>>>> {
>>>> .fourcc = V4L2_PIX_FMT_SRGGB10,
>>>> - .bpp = 4,
>>>> + .bpp = 2,
>>>> },
>>>> };
>>>>
>>>> --
>>>> 2.43.0
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] media: rcar-vin: Fix RAW10
2025-04-03 9:12 ` Tomi Valkeinen
@ 2025-04-03 9:36 ` Niklas Söderlund
0 siblings, 0 replies; 12+ messages in thread
From: Niklas Söderlund @ 2025-04-03 9:36 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Sakari Ailus, linux-media,
linux-renesas-soc, linux-kernel, Mauro Carvalho Chehab
Hi Tomi,
On 2025-04-03 12:12:06 +0300, Tomi Valkeinen wrote:
> Hi,
>
> On 03/04/2025 11:57, Niklas Söderlund wrote:
> > Hi Tomi,
> >
> > On 2025-04-03 11:15:04 +0300, Tomi Valkeinen wrote:
> > > Hi,
> > >
> > > On 01/04/2025 00:11, Niklas Söderlund wrote:
> > > > Hi Tomi,
> > > >
> > > > Thanks for your work.
> > > >
> > > > On 2025-03-24 13:48:54 +0200, Tomi Valkeinen wrote:
> > > > > Fix the following to get RAW10 formats working:
> > > > >
> > > > > In rvin_formats, the bpp is set to 4 for RAW10. As VIN unpacks RAW10 to
> > > > > 16-bit containers, the bpp should be 2.
> > > > >
> > > > > Don't set VNDMR_YC_THR to the VNDMR register. The YC_THR is "YC Data
> > > > > Through Mode", used for YUV formats and should not be set for RAW10.
> > > > >
> > > > > Fix the check related to the RGB666 format and CSI-2 mode. The
> > > > > VNMC_INF_RGB666 define is the same as used for RAW10 on Gen4, and RAW10
> > > > > is allowed on CSI-2 (whereas RGB666 is not allowed on Gen3 on CSI-2).
> > > > > This feels a bit hacky, though, and the formats should really have been
> > > > > verified already earlier.
> > > >
> > > > I agree, it feels hacky. I would rather just remove the while switch
> > > > then try to "fix" it by extending it more. When testing this series I
> > > > needed a similar fix for VNMC_INF_RAW8 check below to get it to work on
> > > > Gen4.
> > >
> > > Why is that? What is VNMC_INF_RAW8 overlapping with?
> >
> > VNMC_INF_RAW8 is not overlapping the issue is the "if (!vin->is_csi)"
> > check. On Gen3 RAW8 was supposedly only supported on the CSI-2 input,
> > and not on the parallel bus available on some VIN instances.
> >
> > On Gen4 the checks around vin->is_csi becomes skewed and as you point
> > out should be cloned up. The effect at the moment however is that o Gen4
> > when trying to capture RAW8 is_csi is not set (as this is a gen3 thing)
> > and the "Invalid setting in Digital Pins" error path is hit.
>
> Ok. I was wondering why it worked for me. But maybe the reason it worked for
> me was the extra series from you, which also changed these checks to
> rvin_remote_is_parallel(). And perhaps that function works fine, while the
> older vin->is_csi didn't.
Ahh yes that might be it. There are so many VIN series floating around
:-)
>
> > Locally I have now removed this whole swtich, as you point out the
> > formats should already be checked, and as far as I can tell they are.
> > This check is a relic from early Gen3 support. And really proves after
> > the Gen2 media graph clenups are done we should split rcar-dma.c ->
> > rcar-dma-gen{2,3,4}.c to get rid of this mess ;-)
> >
> > I would change this patch to just remove the whole switch. If you want
> > to keep this fix as is I'm ok with that. I can submit a patch removing
> > the switch if you like on top.
>
> Ok, if you think removing the switch is fine, we can do that. I wasn't sure
> of the flow in the driver so I wasn't confident I could just drop it
> (especially considering pre-gen4, with which I have no experience). Thus
> this patch.
>
> Tomi
>
> >
> > >
> > > Tomi
> > >
> > > > >
> > > > > Fixes: 1b7e7240eaf3 ("media: rcar-vin: Add support for RAW10")
> > > > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> > > > > ---
> > > > > drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 9 +++++++--
> > > > > drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 8 ++++----
> > > > > 2 files changed, 11 insertions(+), 6 deletions(-)
> > > > >
> > > > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > > > index 53046614f7a1..f8394be8a922 100644
> > > > > --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > > > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > > > @@ -811,12 +811,17 @@ static int rvin_setup(struct rvin_dev *vin)
> > > > > case VNMC_INF_YUV8_BT656:
> > > > > case VNMC_INF_YUV10_BT656:
> > > > > case VNMC_INF_YUV16:
> > > > > - case VNMC_INF_RGB666:
> > > > > if (vin->is_csi) {
> > > > > vin_err(vin, "Invalid setting in MIPI CSI2\n");
> > > > > return -EINVAL;
> > > > > }
> > > > > break;
> > > > > + case VNMC_INF_RGB666:
> > > > > + if (vin->info->model == RCAR_GEN3 && vin->is_csi) {
> > > > > + vin_err(vin, "Invalid setting in MIPI CSI2\n");
> > > > > + return -EINVAL;
> > > > > + }
> > > > > + break;
> > > > > case VNMC_INF_RAW8:
> > > > > if (!vin->is_csi) {
> > > > > vin_err(vin, "Invalid setting in Digital Pins\n");
> > > > > @@ -913,7 +918,7 @@ static int rvin_setup(struct rvin_dev *vin)
> > > > > case V4L2_PIX_FMT_SGBRG10:
> > > > > case V4L2_PIX_FMT_SGRBG10:
> > > > > case V4L2_PIX_FMT_SRGGB10:
> > > > > - dmr = VNDMR_RMODE_RAW10 | VNDMR_YC_THR;
> > > > > + dmr = VNDMR_RMODE_RAW10;
> > > > > break;
> > > > > default:
> > > > > vin_err(vin, "Invalid pixelformat (0x%x)\n",
> > > > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > > > index 756fdfdbce61..65da8d513b52 100644
> > > > > --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > > > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> > > > > @@ -88,19 +88,19 @@ static const struct rvin_video_format rvin_formats[] = {
> > > > > },
> > > > > {
> > > > > .fourcc = V4L2_PIX_FMT_SBGGR10,
> > > > > - .bpp = 4,
> > > > > + .bpp = 2,
> > > > > },
> > > > > {
> > > > > .fourcc = V4L2_PIX_FMT_SGBRG10,
> > > > > - .bpp = 4,
> > > > > + .bpp = 2,
> > > > > },
> > > > > {
> > > > > .fourcc = V4L2_PIX_FMT_SGRBG10,
> > > > > - .bpp = 4,
> > > > > + .bpp = 2,
> > > > > },
> > > > > {
> > > > > .fourcc = V4L2_PIX_FMT_SRGGB10,
> > > > > - .bpp = 4,
> > > > > + .bpp = 2,
> > > > > },
> > > > > };
> > > > >
> > > > > --
> > > > > 2.43.0
> > > > >
> > > >
> > >
> >
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-04-03 9:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24 11:48 [PATCH 0/3] media: rcar: Fix RAW formats Tomi Valkeinen
2025-03-24 11:48 ` [PATCH 1/3] media: rcar-vin: Add RCAR_GEN4 model value Tomi Valkeinen
2025-03-31 21:13 ` Niklas Söderlund
2025-03-24 11:48 ` [PATCH 2/3] media: rcar-vin: Fix RAW8 Tomi Valkeinen
2025-03-31 21:16 ` Niklas Söderlund
2025-03-24 11:48 ` [PATCH 3/3] media: rcar-vin: Fix RAW10 Tomi Valkeinen
2025-03-31 21:11 ` Niklas Söderlund
2025-04-03 8:15 ` Tomi Valkeinen
2025-04-03 8:57 ` Niklas Söderlund
2025-04-03 9:12 ` Tomi Valkeinen
2025-04-03 9:36 ` Niklas Söderlund
2025-04-03 8:18 ` Tomi Valkeinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox