2021-09-24 08:23:11

by Nikita Yushchenko

[permalink] [raw]
Subject: [PATCH] media: rcar-vin: add support for GREY format

From: Vladimir Barinov <[email protected]>

This adds support for MEDIA_BUS_FMT_Y8_1X8 input and V4L2_PIX_FMT_GREY
output format.

Signed-off-by: Vladimir Barinov <[email protected]>
Signed-off-by: Nikita Yushchenko <[email protected]>
---
drivers/media/platform/rcar-vin/rcar-dma.c | 14 ++++++++++++++
drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++++
2 files changed, 18 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index f5f722ab1d4e..d2bfd3e575fa 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -114,6 +114,7 @@
/* Video n Data Mode Register bits */
#define VNDMR_A8BIT(n) (((n) & 0xff) << 24)
#define VNDMR_A8BIT_MASK (0xff << 24)
+#define VNDMR_YMODE_Y8 (1 << 12)
#define VNDMR_EXRGB (1 << 8)
#define VNDMR_BPSM (1 << 4)
#define VNDMR_ABIT (1 << 2)
@@ -603,6 +604,7 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SRGGB8:
+ case V4L2_PIX_FMT_GREY:
stride /= 2;
break;
default:
@@ -695,6 +697,7 @@ static int rvin_setup(struct rvin_dev *vin)
case MEDIA_BUS_FMT_SGBRG8_1X8:
case MEDIA_BUS_FMT_SGRBG8_1X8:
case MEDIA_BUS_FMT_SRGGB8_1X8:
+ case MEDIA_BUS_FMT_Y8_1X8:
vnmc |= VNMC_INF_RAW8;
break;
default:
@@ -774,6 +777,13 @@ static int rvin_setup(struct rvin_dev *vin)
case V4L2_PIX_FMT_SRGGB8:
dmr = 0;
break;
+ case V4L2_PIX_FMT_GREY:
+ if (input_is_yuv) {
+ dmr = VNDMR_DTMD_YCSEP | VNDMR_YMODE_Y8;
+ output_is_yuv = true;
+ } else
+ dmr = 0;
+ break;
default:
vin_err(vin, "Invalid pixelformat (0x%x)\n",
vin->format.pixelformat);
@@ -1145,6 +1155,10 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
return -EPIPE;
break;
+ case MEDIA_BUS_FMT_Y8_1X8:
+ if (vin->format.pixelformat != V4L2_PIX_FMT_GREY)
+ return -EPIPE;
+ break;
default:
return -EPIPE;
}
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 0d141155f0e3..bdeff51bf768 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -82,6 +82,10 @@ static const struct rvin_video_format rvin_formats[] = {
.fourcc = V4L2_PIX_FMT_SRGGB8,
.bpp = 1,
},
+ {
+ .fourcc = V4L2_PIX_FMT_GREY,
+ .bpp = 1,
+ },
};

const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
--
2.30.2


2021-09-24 10:02:56

by Niklas Söderlund

[permalink] [raw]
Subject: Re: [PATCH] media: rcar-vin: add support for GREY format

Hi Nikita and Vladimir,

Thanks for your work.

On 2021-09-24 11:19:39 +0300, Nikita Yushchenko wrote:
> From: Vladimir Barinov <[email protected]>
>
> This adds support for MEDIA_BUS_FMT_Y8_1X8 input and V4L2_PIX_FMT_GREY
> output format.

Thanks for this, I'm happy to see this code!

I been wrestling a while with this as I have no sensor where I could
test it with I always put it off. May I ask what sensor and platform was
used to test this?

The code looks good and I truest that it's tested and produce a good
image, one small nit below.

>
> Signed-off-by: Vladimir Barinov <[email protected]>
> Signed-off-by: Nikita Yushchenko <[email protected]>
> ---
> drivers/media/platform/rcar-vin/rcar-dma.c | 14 ++++++++++++++
> drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> index f5f722ab1d4e..d2bfd3e575fa 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -114,6 +114,7 @@
> /* Video n Data Mode Register bits */
> #define VNDMR_A8BIT(n) (((n) & 0xff) << 24)
> #define VNDMR_A8BIT_MASK (0xff << 24)
> +#define VNDMR_YMODE_Y8 (1 << 12)
> #define VNDMR_EXRGB (1 << 8)
> #define VNDMR_BPSM (1 << 4)
> #define VNDMR_ABIT (1 << 2)
> @@ -603,6 +604,7 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
> case V4L2_PIX_FMT_SGBRG8:
> case V4L2_PIX_FMT_SGRBG8:
> case V4L2_PIX_FMT_SRGGB8:
> + case V4L2_PIX_FMT_GREY:
> stride /= 2;
> break;
> default:
> @@ -695,6 +697,7 @@ static int rvin_setup(struct rvin_dev *vin)
> case MEDIA_BUS_FMT_SGBRG8_1X8:
> case MEDIA_BUS_FMT_SGRBG8_1X8:
> case MEDIA_BUS_FMT_SRGGB8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> vnmc |= VNMC_INF_RAW8;
> break;
> default:
> @@ -774,6 +777,13 @@ static int rvin_setup(struct rvin_dev *vin)
> case V4L2_PIX_FMT_SRGGB8:
> dmr = 0;
> break;
> + case V4L2_PIX_FMT_GREY:
> + if (input_is_yuv) {
> + dmr = VNDMR_DTMD_YCSEP | VNDMR_YMODE_Y8;
> + output_is_yuv = true;
> + } else
> + dmr = 0;

Please encapsulate the else clause in { } if the corresponding if clause
body uses { }.

> + break;
> default:
> vin_err(vin, "Invalid pixelformat (0x%x)\n",
> vin->format.pixelformat);
> @@ -1145,6 +1155,10 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
> if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
> return -EPIPE;
> break;
> + case MEDIA_BUS_FMT_Y8_1X8:
> + if (vin->format.pixelformat != V4L2_PIX_FMT_GREY)
> + return -EPIPE;
> + break;
> default:
> return -EPIPE;
> }
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 0d141155f0e3..bdeff51bf768 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -82,6 +82,10 @@ static const struct rvin_video_format rvin_formats[] = {
> .fourcc = V4L2_PIX_FMT_SRGGB8,
> .bpp = 1,
> },
> + {
> + .fourcc = V4L2_PIX_FMT_GREY,
> + .bpp = 1,
> + },
> };
>
> const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
> --
> 2.30.2
>

--
Regards,
Niklas S?derlund

2021-09-24 16:32:54

by Nikita Yushchenko

[permalink] [raw]
Subject: Re: [PATCH] media: rcar-vin: add support for GREY format

Hello Niklas

> I been wrestling a while with this as I have no sensor where I could
> test it with I always put it off. May I ask what sensor and platform was
> used to test this?

We have used this with ov2311 (LI-OV2311-UB953, LI-OV2311-MAX9295) on:

H3ULCB+KF+FPDLINK3/GMSL2 camera boards
V3HSK+Cogent VideoBoxes (FPDLINK3, GMSL2).

Also this code was included into Renesas BSP for a long time.

> The code looks good and I truest that it's tested and produce a good
> image, one small nit below.

Will submit v2 in a moment.

Nikita

2021-09-24 17:07:47

by Nikita Yushchenko

[permalink] [raw]
Subject: [PATCH v2] media: rcar-vin: add GREY format

From: Vladimir Barinov <[email protected]>

This adds support for MEDIA_BUS_FMT_Y8_1X8 input and V4L2_PIX_FMT_GREY
output format.

Signed-off-by: Vladimir Barinov <[email protected]>
Signed-off-by: Nikita Yushchenko <[email protected]>
---
Changes from v1:
- fix coding style issue

drivers/media/platform/rcar-vin/rcar-dma.c | 15 +++++++++++++++
drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++++
2 files changed, 19 insertions(+)

diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index f5f722ab1d4e..4d0d95cf4c5f 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -114,6 +114,7 @@
/* Video n Data Mode Register bits */
#define VNDMR_A8BIT(n) (((n) & 0xff) << 24)
#define VNDMR_A8BIT_MASK (0xff << 24)
+#define VNDMR_YMODE_Y8 (1 << 12)
#define VNDMR_EXRGB (1 << 8)
#define VNDMR_BPSM (1 << 4)
#define VNDMR_ABIT (1 << 2)
@@ -603,6 +604,7 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SRGGB8:
+ case V4L2_PIX_FMT_GREY:
stride /= 2;
break;
default:
@@ -695,6 +697,7 @@ static int rvin_setup(struct rvin_dev *vin)
case MEDIA_BUS_FMT_SGBRG8_1X8:
case MEDIA_BUS_FMT_SGRBG8_1X8:
case MEDIA_BUS_FMT_SRGGB8_1X8:
+ case MEDIA_BUS_FMT_Y8_1X8:
vnmc |= VNMC_INF_RAW8;
break;
default:
@@ -774,6 +777,14 @@ static int rvin_setup(struct rvin_dev *vin)
case V4L2_PIX_FMT_SRGGB8:
dmr = 0;
break;
+ case V4L2_PIX_FMT_GREY:
+ if (input_is_yuv) {
+ dmr = VNDMR_DTMD_YCSEP | VNDMR_YMODE_Y8;
+ output_is_yuv = true;
+ } else {
+ dmr = 0;
+ }
+ break;
default:
vin_err(vin, "Invalid pixelformat (0x%x)\n",
vin->format.pixelformat);
@@ -1145,6 +1156,10 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
return -EPIPE;
break;
+ case MEDIA_BUS_FMT_Y8_1X8:
+ if (vin->format.pixelformat != V4L2_PIX_FMT_GREY)
+ return -EPIPE;
+ break;
default:
return -EPIPE;
}
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 0d141155f0e3..bdeff51bf768 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -82,6 +82,10 @@ static const struct rvin_video_format rvin_formats[] = {
.fourcc = V4L2_PIX_FMT_SRGGB8,
.bpp = 1,
},
+ {
+ .fourcc = V4L2_PIX_FMT_GREY,
+ .bpp = 1,
+ },
};

const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
--
2.30.2

2021-09-29 14:56:01

by Niklas Söderlund

[permalink] [raw]
Subject: Re: [PATCH v2] media: rcar-vin: add GREY format

Hi Vladimir,

Thanks for your work.

On 2021-09-24 15:43:17 +0300, Nikita Yushchenko wrote:
> From: Vladimir Barinov <[email protected]>
>
> This adds support for MEDIA_BUS_FMT_Y8_1X8 input and V4L2_PIX_FMT_GREY
> output format.
>
> Signed-off-by: Vladimir Barinov <[email protected]>
> Signed-off-by: Nikita Yushchenko <[email protected]>

Reviewed-by: Niklas S?derlund <[email protected]>

> ---
> Changes from v1:
> - fix coding style issue
>
> drivers/media/platform/rcar-vin/rcar-dma.c | 15 +++++++++++++++
> drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> index f5f722ab1d4e..4d0d95cf4c5f 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -114,6 +114,7 @@
> /* Video n Data Mode Register bits */
> #define VNDMR_A8BIT(n) (((n) & 0xff) << 24)
> #define VNDMR_A8BIT_MASK (0xff << 24)
> +#define VNDMR_YMODE_Y8 (1 << 12)
> #define VNDMR_EXRGB (1 << 8)
> #define VNDMR_BPSM (1 << 4)
> #define VNDMR_ABIT (1 << 2)
> @@ -603,6 +604,7 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
> case V4L2_PIX_FMT_SGBRG8:
> case V4L2_PIX_FMT_SGRBG8:
> case V4L2_PIX_FMT_SRGGB8:
> + case V4L2_PIX_FMT_GREY:
> stride /= 2;
> break;
> default:
> @@ -695,6 +697,7 @@ static int rvin_setup(struct rvin_dev *vin)
> case MEDIA_BUS_FMT_SGBRG8_1X8:
> case MEDIA_BUS_FMT_SGRBG8_1X8:
> case MEDIA_BUS_FMT_SRGGB8_1X8:
> + case MEDIA_BUS_FMT_Y8_1X8:
> vnmc |= VNMC_INF_RAW8;
> break;
> default:
> @@ -774,6 +777,14 @@ static int rvin_setup(struct rvin_dev *vin)
> case V4L2_PIX_FMT_SRGGB8:
> dmr = 0;
> break;
> + case V4L2_PIX_FMT_GREY:
> + if (input_is_yuv) {
> + dmr = VNDMR_DTMD_YCSEP | VNDMR_YMODE_Y8;
> + output_is_yuv = true;
> + } else {
> + dmr = 0;
> + }
> + break;
> default:
> vin_err(vin, "Invalid pixelformat (0x%x)\n",
> vin->format.pixelformat);
> @@ -1145,6 +1156,10 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
> if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
> return -EPIPE;
> break;
> + case MEDIA_BUS_FMT_Y8_1X8:
> + if (vin->format.pixelformat != V4L2_PIX_FMT_GREY)
> + return -EPIPE;
> + break;
> default:
> return -EPIPE;
> }
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 0d141155f0e3..bdeff51bf768 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -82,6 +82,10 @@ static const struct rvin_video_format rvin_formats[] = {
> .fourcc = V4L2_PIX_FMT_SRGGB8,
> .bpp = 1,
> },
> + {
> + .fourcc = V4L2_PIX_FMT_GREY,
> + .bpp = 1,
> + },
> };
>
> const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
> --
> 2.30.2
>

--
Regards,
Niklas S?derlund