* [PATCH] rcar-vin: Report correct image stride
@ 2019-08-08 5:10 Niklas Söderlund
2019-08-08 8:15 ` Laurent Pinchart
0 siblings, 1 reply; 2+ messages in thread
From: Niklas Söderlund @ 2019-08-08 5:10 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: linux-renesas-soc, Niklas Söderlund
The image stride was adjusted when it was written to hardware and not
when configuring the format. Calculate the correct stride value and
report it to userspace.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-dma.c | 10 ++++++----
drivers/media/platform/rcar-vin/rcar-v4l2.c | 5 ++++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index f16f2966f9628b72..3cb29b2e0b2b18a9 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -577,6 +577,9 @@ static void rvin_crop_scale_comp_gen2(struct rvin_dev *vin)
void rvin_crop_scale_comp(struct rvin_dev *vin)
{
+ const struct rvin_video_format *fmt;
+ u32 stride;
+
/* Set Start/End Pixel/Line Pre-Clip */
rvin_write(vin, vin->crop.left, VNSPPRC_REG);
rvin_write(vin, vin->crop.left + vin->crop.width - 1, VNEPPRC_REG);
@@ -600,10 +603,9 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
if (vin->info->model != RCAR_GEN3)
rvin_crop_scale_comp_gen2(vin);
- if (vin->format.pixelformat == V4L2_PIX_FMT_NV16)
- rvin_write(vin, ALIGN(vin->format.width, 0x20), VNIS_REG);
- else
- rvin_write(vin, ALIGN(vin->format.width, 0x10), VNIS_REG);
+ fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
+ stride = vin->format.bytesperline / fmt->bpp;
+ rvin_write(vin, stride, VNIS_REG);
}
/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index cfed0a2604133849..cbc1c07f0a9631a4 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -83,13 +83,16 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin,
struct v4l2_pix_format *pix)
{
const struct rvin_video_format *fmt;
+ u32 align;
fmt = rvin_format_from_pixel(vin, pix->pixelformat);
if (WARN_ON(!fmt))
return -EINVAL;
- return pix->width * fmt->bpp;
+ align = pix->pixelformat == V4L2_PIX_FMT_NV16 ? 0x20 : 0x10;
+
+ return ALIGN(pix->width, align) * fmt->bpp;
}
static u32 rvin_format_sizeimage(struct v4l2_pix_format *pix)
--
2.22.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rcar-vin: Report correct image stride
2019-08-08 5:10 [PATCH] rcar-vin: Report correct image stride Niklas Söderlund
@ 2019-08-08 8:15 ` Laurent Pinchart
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2019-08-08 8:15 UTC (permalink / raw)
To: Niklas Söderlund; +Cc: linux-media, linux-renesas-soc
Hi Niklas,
Thank you for the patch.
On Thu, Aug 08, 2019 at 07:10:58AM +0200, Niklas Söderlund wrote:
> The image stride was adjusted when it was written to hardware and not
> when configuring the format. Calculate the correct stride value and
> report it to userspace.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/rcar-vin/rcar-dma.c | 10 ++++++----
> drivers/media/platform/rcar-vin/rcar-v4l2.c | 5 ++++-
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> index f16f2966f9628b72..3cb29b2e0b2b18a9 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -577,6 +577,9 @@ static void rvin_crop_scale_comp_gen2(struct rvin_dev *vin)
>
> void rvin_crop_scale_comp(struct rvin_dev *vin)
> {
> + const struct rvin_video_format *fmt;
> + u32 stride;
> +
> /* Set Start/End Pixel/Line Pre-Clip */
> rvin_write(vin, vin->crop.left, VNSPPRC_REG);
> rvin_write(vin, vin->crop.left + vin->crop.width - 1, VNEPPRC_REG);
> @@ -600,10 +603,9 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
> if (vin->info->model != RCAR_GEN3)
> rvin_crop_scale_comp_gen2(vin);
>
> - if (vin->format.pixelformat == V4L2_PIX_FMT_NV16)
> - rvin_write(vin, ALIGN(vin->format.width, 0x20), VNIS_REG);
> - else
> - rvin_write(vin, ALIGN(vin->format.width, 0x10), VNIS_REG);
> + fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
You may want as an optimisation to cache the active rvin_video_format
pointer in rvin_dev, but that can be done in a separate patch.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + stride = vin->format.bytesperline / fmt->bpp;
> + rvin_write(vin, stride, VNIS_REG);
> }
>
> /* -----------------------------------------------------------------------------
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index cfed0a2604133849..cbc1c07f0a9631a4 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -83,13 +83,16 @@ static u32 rvin_format_bytesperline(struct rvin_dev *vin,
> struct v4l2_pix_format *pix)
> {
> const struct rvin_video_format *fmt;
> + u32 align;
>
> fmt = rvin_format_from_pixel(vin, pix->pixelformat);
>
> if (WARN_ON(!fmt))
> return -EINVAL;
>
> - return pix->width * fmt->bpp;
> + align = pix->pixelformat == V4L2_PIX_FMT_NV16 ? 0x20 : 0x10;
> +
> + return ALIGN(pix->width, align) * fmt->bpp;
> }
>
> static u32 rvin_format_sizeimage(struct v4l2_pix_format *pix)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-08 8:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 5:10 [PATCH] rcar-vin: Report correct image stride Niklas Söderlund
2019-08-08 8:15 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).