Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: renesas: vin: Fix RAW8 (again)

Commit e7376745ad5c ("media: rcar-vin: Fix stride setting for RAW8
formats") removed dividing the stride by two for RAW8 formats. It is
unclear how this was tested, but in any of the recent tests this does
not seem to work and produces quite distorted images.

However, reverting the patch fixes the issues only partially. VNIS_REG
requires alignment to 16 bytes, and when dividing the stride by 2, in
some cases we end up with a non-aligned stride, producing a tilted
image. This issue has to be fixed in rvin_format_bytesperline() where we
do the alignment for bytesperline.

Adding back the stride division and increasing the alignment for RAW8
formats to 0x20 fixes the problems related to RAW8.

Fixes: e7376745ad5c ("media: rcar-vin: Fix stride setting for RAW8 formats")
Cc: stable@vger.kernel.org
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Tomi Valkeinen and committed by
Hans Verkuil
40c6da8a 58b1e966

+34
+22
drivers/media/platform/renesas/rcar-vin/rcar-dma.c
··· 676 676 if (vin->scaler) 677 677 vin->scaler(vin); 678 678 679 + /* 680 + * VNIS_REG has four lowest bits always 0, i.e. the stride has to be 681 + * aligned to 16 bytes. This is done in rvin_format_bytesperline(). 682 + */ 683 + 679 684 fmt = rvin_format_from_pixel(vin, vin->format.pixelformat); 680 685 stride = vin->format.bytesperline / fmt->bpp; 686 + 687 + /* 688 + * RAW8 format bpp is 1, but the hardware process RAW8 format in 2 pixel 689 + * units, so we need to divide the stride by 2. 690 + */ 691 + switch (vin->format.pixelformat) { 692 + case V4L2_PIX_FMT_SBGGR8: 693 + case V4L2_PIX_FMT_SGBRG8: 694 + case V4L2_PIX_FMT_SGRBG8: 695 + case V4L2_PIX_FMT_SRGGB8: 696 + case V4L2_PIX_FMT_GREY: 697 + stride /= 2; 698 + break; 699 + default: 700 + break; 701 + } 702 + 681 703 rvin_write(vin, stride, VNIS_REG); 682 704 } 683 705
+12
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
··· 155 155 case V4L2_PIX_FMT_NV16: 156 156 align = 0x20; 157 157 break; 158 + case V4L2_PIX_FMT_SBGGR8: 159 + case V4L2_PIX_FMT_SGBRG8: 160 + case V4L2_PIX_FMT_SGRBG8: 161 + case V4L2_PIX_FMT_SRGGB8: 162 + case V4L2_PIX_FMT_GREY: 163 + /* 164 + * RAW8 format bpp is 1, but the hardware process RAW8 format in 165 + * 2 pixel units, and we need to align to 32 bytes. See 166 + * rvin_crop_scale_comp(). 167 + */ 168 + align = 0x20; 169 + break; 158 170 default: 159 171 align = 0x10; 160 172 break;