mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 03:11:11 -04:00
media: renesas: vin: Fix RAW8 (again)
Commite7376745ad("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:e7376745ad("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>
This commit is contained in:
committed by
Hans Verkuil
parent
58b1e9664d
commit
40c6da8a9c
@@ -676,8 +676,30 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
|
||||
if (vin->scaler)
|
||||
vin->scaler(vin);
|
||||
|
||||
/*
|
||||
* VNIS_REG has four lowest bits always 0, i.e. the stride has to be
|
||||
* aligned to 16 bytes. This is done in rvin_format_bytesperline().
|
||||
*/
|
||||
|
||||
fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
|
||||
stride = vin->format.bytesperline / fmt->bpp;
|
||||
|
||||
/*
|
||||
* RAW8 format bpp is 1, but the hardware process RAW8 format in 2 pixel
|
||||
* units, so we need to divide the stride by 2.
|
||||
*/
|
||||
switch (vin->format.pixelformat) {
|
||||
case V4L2_PIX_FMT_SBGGR8:
|
||||
case V4L2_PIX_FMT_SGBRG8:
|
||||
case V4L2_PIX_FMT_SGRBG8:
|
||||
case V4L2_PIX_FMT_SRGGB8:
|
||||
case V4L2_PIX_FMT_GREY:
|
||||
stride /= 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
rvin_write(vin, stride, VNIS_REG);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +155,18 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin,
|
||||
case V4L2_PIX_FMT_NV16:
|
||||
align = 0x20;
|
||||
break;
|
||||
case V4L2_PIX_FMT_SBGGR8:
|
||||
case V4L2_PIX_FMT_SGBRG8:
|
||||
case V4L2_PIX_FMT_SGRBG8:
|
||||
case V4L2_PIX_FMT_SRGGB8:
|
||||
case V4L2_PIX_FMT_GREY:
|
||||
/*
|
||||
* RAW8 format bpp is 1, but the hardware process RAW8 format in
|
||||
* 2 pixel units, and we need to align to 32 bytes. See
|
||||
* rvin_crop_scale_comp().
|
||||
*/
|
||||
align = 0x20;
|
||||
break;
|
||||
default:
|
||||
align = 0x10;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user