Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1579697 > unrolled thread

[Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride

Started byBenoit Parrot <bparrot@ti.com>
First post2017-02-13 14:10 +0100
Last post2017-02-15 15:40 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride Benoit Parrot <bparrot@ti.com> - 2017-02-13 14:10 +0100
    Re: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified  stride Tomi Valkeinen <tomi.valkeinen@ti.com> - 2017-02-15 12:30 +0100
      Re: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified  stride Benoit Parrot <bparrot@ti.com> - 2017-02-15 15:40 +0100

#1579697 — [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride

FromBenoit Parrot <bparrot@ti.com>
Date2017-02-13 14:10 +0100
Subject[Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride
Message-ID<taoye-47y-21@gated-at.bofh.it>
Bytesperline/stride was always overwritten by VPE to the most
adequate value based on needed alignment.

However in order to make use of arbitrary size DMA buffer it
is better to use the user space provide stride instead.

The driver will still calculate an appropriate stride but will
use the provided one when it is larger than the calculated one.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/vpe.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 2dd67232b3bc..c47151495b6f 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1597,6 +1597,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
 	struct v4l2_plane_pix_format *plane_fmt;
 	unsigned int w_align;
 	int i, depth, depth_bytes, height;
+	unsigned int stride = 0;
 
 	if (!fmt || !(fmt->types & type)) {
 		vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
@@ -1683,16 +1684,27 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
 		plane_fmt = &pix->plane_fmt[i];
 		depth = fmt->vpdma_fmt[i]->depth;
 
-		if (i == VPE_LUMA)
-			plane_fmt->bytesperline = (pix->width * depth) >> 3;
-		else
-			plane_fmt->bytesperline = pix->width;
+		stride = (pix->width * fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3;
+		if (stride > plane_fmt->bytesperline)
+			plane_fmt->bytesperline = stride;
+
+		plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline,
+						VPDMA_STRIDE_ALIGN);
 
-		if (pix->num_planes == 1 && fmt->coplanar)
-			depth += fmt->vpdma_fmt[VPE_CHROMA]->depth;
-		plane_fmt->sizeimage =
-				(pix->height * pix->width * depth) >> 3;
+		if (i == VPE_LUMA) {
+			plane_fmt->sizeimage = pix->height *
+					       plane_fmt->bytesperline;
 
+			if (pix->num_planes == 1 && fmt->coplanar)
+				plane_fmt->sizeimage += pix->height *
+					plane_fmt->bytesperline *
+					fmt->vpdma_fmt[VPE_CHROMA]->depth >> 3;
+
+		} else { /* i == VIP_CHROMA */
+			plane_fmt->sizeimage = (pix->height *
+					       plane_fmt->bytesperline *
+					       depth) >> 3;
+		}
 		memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved));
 	}
 
-- 
2.9.0

[toc] | [next] | [standalone]


#1581231 — Re: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride

FromTomi Valkeinen <tomi.valkeinen@ti.com>
Date2017-02-15 12:30 +0100
SubjectRe: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride
Message-ID<tb5Wy-7HU-11@gated-at.bofh.it>
In reply to#1579697

[Multipart message — attachments visible in raw view] — view raw

Hi,

On 13/02/17 15:06, Benoit Parrot wrote:
> Bytesperline/stride was always overwritten by VPE to the most
> adequate value based on needed alignment.
> 
> However in order to make use of arbitrary size DMA buffer it
> is better to use the user space provide stride instead.
> 
> The driver will still calculate an appropriate stride but will
> use the provided one when it is larger than the calculated one.
> 
> Signed-off-by: Benoit Parrot <bparrot@ti.com>
> ---
>  drivers/media/platform/ti-vpe/vpe.c | 28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
> index 2dd67232b3bc..c47151495b6f 100644
> --- a/drivers/media/platform/ti-vpe/vpe.c
> +++ b/drivers/media/platform/ti-vpe/vpe.c
> @@ -1597,6 +1597,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
>  	struct v4l2_plane_pix_format *plane_fmt;
>  	unsigned int w_align;
>  	int i, depth, depth_bytes, height;
> +	unsigned int stride = 0;
>  
>  	if (!fmt || !(fmt->types & type)) {
>  		vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
> @@ -1683,16 +1684,27 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
>  		plane_fmt = &pix->plane_fmt[i];
>  		depth = fmt->vpdma_fmt[i]->depth;
>  
> -		if (i == VPE_LUMA)
> -			plane_fmt->bytesperline = (pix->width * depth) >> 3;
> -		else
> -			plane_fmt->bytesperline = pix->width;
> +		stride = (pix->width * fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3;
> +		if (stride > plane_fmt->bytesperline)
> +			plane_fmt->bytesperline = stride;

The old code calculates different bytes per line for luma and chroma,
but the new one calculates only for luma. Is that correct?

 Tomi

[toc] | [prev] | [next] | [standalone]


#1581361 — Re: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride

FromBenoit Parrot <bparrot@ti.com>
Date2017-02-15 15:40 +0100
SubjectRe: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride
Message-ID<tb8Uq-1ae-25@gated-at.bofh.it>
In reply to#1581231
Tomi Valkeinen <tomi.valkeinen@ti.com> wrote on Wed [2017-Feb-15 13:22:42 +0200]:
> Hi,
> 
> On 13/02/17 15:06, Benoit Parrot wrote:
> > Bytesperline/stride was always overwritten by VPE to the most
> > adequate value based on needed alignment.
> > 
> > However in order to make use of arbitrary size DMA buffer it
> > is better to use the user space provide stride instead.
> > 
> > The driver will still calculate an appropriate stride but will
> > use the provided one when it is larger than the calculated one.
> > 
> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> > ---
> >  drivers/media/platform/ti-vpe/vpe.c | 28 ++++++++++++++++++++--------
> >  1 file changed, 20 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
> > index 2dd67232b3bc..c47151495b6f 100644
> > --- a/drivers/media/platform/ti-vpe/vpe.c
> > +++ b/drivers/media/platform/ti-vpe/vpe.c
> > @@ -1597,6 +1597,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
> >  	struct v4l2_plane_pix_format *plane_fmt;
> >  	unsigned int w_align;
> >  	int i, depth, depth_bytes, height;
> > +	unsigned int stride = 0;
> >  
> >  	if (!fmt || !(fmt->types & type)) {
> >  		vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n",
> > @@ -1683,16 +1684,27 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
> >  		plane_fmt = &pix->plane_fmt[i];
> >  		depth = fmt->vpdma_fmt[i]->depth;
> >  
> > -		if (i == VPE_LUMA)
> > -			plane_fmt->bytesperline = (pix->width * depth) >> 3;
> > -		else
> > -			plane_fmt->bytesperline = pix->width;
> > +		stride = (pix->width * fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3;
> > +		if (stride > plane_fmt->bytesperline)
> > +			plane_fmt->bytesperline = stride;
> 
> The old code calculates different bytes per line for luma and chroma,
> but the new one calculates only for luma. Is that correct?

The previous method which happened to produce the correct value was
not proper as the spec for NV12/NV16 states that the chroma bytes per
line/stride should be the same as the LUMA stride only the number of
lines might differ which affect how the sizeimage component is
calculated. This patch takes that into account.

Benoit

> 
>  Tomi
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web