mbox series

[0/2] rcar-{csi2,vin}: Extend RAW8 support to all RGB layouts

Message ID 20200915230140.1201187-1-niklas.soderlund+renesas@ragnatech.se
Headers show
Series rcar-{csi2,vin}: Extend RAW8 support to all RGB layouts | expand

Message

Niklas Söderlund Sept. 15, 2020, 11:01 p.m. UTC
Hello,

When adding support for V4L2_PIX_FMT_SRGGB8 it was overlooked that the 
same solution could be used to support all RAW8 RGB layouts (SBGGR8, 
SGBRG8, SGRBG8 and SRGGB8).

This series extends the R-Car VIN and CSI-2 drivers to support all RAW8
RGB layouts. The VIN driver changes are applicable to both Gen2 and Gen3 
while the changes to the CSI-2 driver only effects Gen3.

Niklas Söderlund (2):
  rcar-csi2: Extend RAW8 support to all RGB layouts
  rcar-vin: Extend RAW8 support to all RGB layouts

 drivers/media/platform/rcar-vin/rcar-csi2.c |  3 +++
 drivers/media/platform/rcar-vin/rcar-dma.c  | 28 ++++++++++++++++++++-
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 27 ++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

Comments

Ulrich Hecht Sept. 19, 2020, 10:17 a.m. UTC | #1
> On 09/16/2020 1:01 AM Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> wrote:
> 
>  
> Extend the list of supported formats to include all RGB layouts of RAW8.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c  | 28 ++++++++++++++++++++-
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 27 ++++++++++++++++++++
>  2 files changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> index a5dbb90c5210bae7..7f8997536aba6f0b 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -598,8 +598,16 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
>  	/* For RAW8 format bpp is 1, but the hardware process RAW8
>  	 * format in 2 pixel unit hence configure VNIS_REG as stride / 2.
>  	 */
> -	if (vin->format.pixelformat == V4L2_PIX_FMT_SRGGB8)
> +	switch (vin->format.pixelformat) {
> +	case MEDIA_BUS_FMT_SBGGR8_1X8:
> +	case MEDIA_BUS_FMT_SGBRG8_1X8:
> +	case MEDIA_BUS_FMT_SGRBG8_1X8:
> +	case MEDIA_BUS_FMT_SRGGB8_1X8:
>  		stride /= 2;
> +		break;
> +	default:
> +		break;
> +	}
>  
>  	rvin_write(vin, stride, VNIS_REG);
>  }
> @@ -683,6 +691,9 @@ static int rvin_setup(struct rvin_dev *vin)
>  
>  		input_is_yuv = true;
>  		break;
> +	case MEDIA_BUS_FMT_SBGGR8_1X8:
> +	case MEDIA_BUS_FMT_SGBRG8_1X8:
> +	case MEDIA_BUS_FMT_SGRBG8_1X8:
>  	case MEDIA_BUS_FMT_SRGGB8_1X8:
>  		vnmc |= VNMC_INF_RAW8;
>  		break;
> @@ -747,6 +758,9 @@ static int rvin_setup(struct rvin_dev *vin)
>  	case V4L2_PIX_FMT_ABGR32:
>  		dmr = VNDMR_A8BIT(vin->alpha) | VNDMR_EXRGB | VNDMR_DTMD_ARGB;
>  		break;
> +	case V4L2_PIX_FMT_SBGGR8:
> +	case V4L2_PIX_FMT_SGBRG8:
> +	case V4L2_PIX_FMT_SGRBG8:
>  	case V4L2_PIX_FMT_SRGGB8:
>  		dmr = 0;
>  		break;
> @@ -1124,6 +1138,18 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd,
>  	case MEDIA_BUS_FMT_UYVY10_2X10:
>  	case MEDIA_BUS_FMT_RGB888_1X24:
>  		break;
> +	case MEDIA_BUS_FMT_SBGGR8_1X8:
> +		if (vin->format.pixelformat != V4L2_PIX_FMT_SBGGR8)
> +			return -EPIPE;
> +		break;
> +	case MEDIA_BUS_FMT_SGBRG8_1X8:
> +		if (vin->format.pixelformat != V4L2_PIX_FMT_SGBRG8)
> +			return -EPIPE;
> +		break;
> +	case MEDIA_BUS_FMT_SGRBG8_1X8:
> +		if (vin->format.pixelformat != V4L2_PIX_FMT_SGRBG8)
> +			return -EPIPE;
> +		break;
>  	case MEDIA_BUS_FMT_SRGGB8_1X8:
>  		if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8)
>  			return -EPIPE;
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 0e066bba747e0b73..4071d9bd554ab88f 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -66,6 +66,18 @@ static const struct rvin_video_format rvin_formats[] = {
>  		.fourcc			= V4L2_PIX_FMT_ABGR32,
>  		.bpp			= 4,
>  	},
> +	{
> +		.fourcc			= V4L2_PIX_FMT_SBGGR8,
> +		.bpp			= 1,
> +	},
> +	{
> +		.fourcc			= V4L2_PIX_FMT_SGBRG8,
> +		.bpp			= 1,
> +	},
> +	{
> +		.fourcc			= V4L2_PIX_FMT_SGRBG8,
> +		.bpp			= 1,
> +	},
>  	{
>  		.fourcc			= V4L2_PIX_FMT_SRGGB8,
>  		.bpp			= 1,
> @@ -366,6 +378,21 @@ static int rvin_enum_fmt_vid_cap(struct file *file, void *priv,
>  	case MEDIA_BUS_FMT_UYVY10_2X10:
>  	case MEDIA_BUS_FMT_RGB888_1X24:
>  		break;
> +	case MEDIA_BUS_FMT_SBGGR8_1X8:
> +		if (f->index)
> +			return -EINVAL;
> +		f->pixelformat = V4L2_PIX_FMT_SBGGR8;
> +		return 0;
> +	case MEDIA_BUS_FMT_SGBRG8_1X8:
> +		if (f->index)
> +			return -EINVAL;
> +		f->pixelformat = V4L2_PIX_FMT_SGBRG8;
> +		return 0;
> +	case MEDIA_BUS_FMT_SGRBG8_1X8:
> +		if (f->index)
> +			return -EINVAL;
> +		f->pixelformat = V4L2_PIX_FMT_SGRBG8;
> +		return 0;
>  	case MEDIA_BUS_FMT_SRGGB8_1X8:
>  		if (f->index)
>  			return -EINVAL;
> -- 
> 2.28.0

Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>

CU
Uli