linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer
@ 2018-08-17 17:33 Ayan Kumar Halder
  2018-08-20 11:03 ` Liviu Dudau
  0 siblings, 1 reply; 4+ messages in thread
From: Ayan Kumar Halder @ 2018-08-17 17:33 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, gustavo,
	maarten.lankhorst, seanpaul, airlied, dri-devel, linux-kernel
  Cc: nd

For multi-planar formats, while calculating offsets in planes with index greater than 0
(ie second plane, third plane, etc), one needs to divide (src_x * cpp) with horizontal
chroma subsampling factor and (src_y * pitch) with vertical chroma subsampling factor.

The reason being that the planes contain subsampled (ie reduced) data (by a factor of 2) and thus the
while calculating the byte position coresponding to the x and y co-ordinates, one needs to be
divide it with the sampling factor.

Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>
---
 drivers/gpu/drm/drm_fb_cma_helper.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index b127061..47e0e2f 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -86,14 +86,21 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
 {
 	struct drm_gem_cma_object *obj;
 	dma_addr_t paddr;
+	u8 h_div = 1, v_div = 1;
 
 	obj = drm_fb_cma_get_gem_obj(fb, plane);
 	if (!obj)
 		return 0;
 
 	paddr = obj->paddr + fb->offsets[plane];
-	paddr += fb->format->cpp[plane] * (state->src_x >> 16);
-	paddr += fb->pitches[plane] * (state->src_y >> 16);
+
+	if (plane > 0) {
+		h_div = fb->format->hsub;
+		v_div = fb->format->vsub;
+	}
+
+	paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
+	paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
 
 	return paddr;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer
  2018-08-17 17:33 [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer Ayan Kumar Halder
@ 2018-08-20 11:03 ` Liviu Dudau
  2018-08-20 12:38   ` Ayan Halder
  0 siblings, 1 reply; 4+ messages in thread
From: Liviu Dudau @ 2018-08-20 11:03 UTC (permalink / raw)
  To: Ayan Kumar Halder
  Cc: brian.starkey, gustavo, maarten.lankhorst, seanpaul, airlied,
	dri-devel, linux-kernel, nd

On Fri, Aug 17, 2018 at 06:33:04PM +0100, Ayan Kumar Halder wrote:
> For multi-planar formats, while calculating offsets in planes with index greater than 0
> (ie second plane, third plane, etc), one needs to divide (src_x * cpp) with horizontal
> chroma subsampling factor and (src_y * pitch) with vertical chroma subsampling factor.
> 
> The reason being that the planes contain subsampled (ie reduced) data (by a factor of 2) and thus the

drop the extraneous "the" at the end of the line.

> while calculating the byte position coresponding to the x and y co-ordinates, one needs to be

and drop the extraneous "be" at the end of this line.

> divide it with the sampling factor.
> 
> Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>

Otherwise, it looks good to me!

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/drm_fb_cma_helper.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> index b127061..47e0e2f 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -86,14 +86,21 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
>  {
>  	struct drm_gem_cma_object *obj;
>  	dma_addr_t paddr;
> +	u8 h_div = 1, v_div = 1;
>  
>  	obj = drm_fb_cma_get_gem_obj(fb, plane);
>  	if (!obj)
>  		return 0;
>  
>  	paddr = obj->paddr + fb->offsets[plane];
> -	paddr += fb->format->cpp[plane] * (state->src_x >> 16);
> -	paddr += fb->pitches[plane] * (state->src_y >> 16);
> +
> +	if (plane > 0) {
> +		h_div = fb->format->hsub;
> +		v_div = fb->format->vsub;
> +	}
> +
> +	paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
> +	paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
>  
>  	return paddr;
>  }
> -- 
> 2.7.4
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer
  2018-08-20 11:03 ` Liviu Dudau
@ 2018-08-20 12:38   ` Ayan Halder
  2018-08-20 13:24     ` Liviu Dudau
  0 siblings, 1 reply; 4+ messages in thread
From: Ayan Halder @ 2018-08-20 12:38 UTC (permalink / raw)
  To: Liviu Dudau; +Cc: airlied, linux-kernel, dri-devel, seanpaul, nd

On Mon, Aug 20, 2018 at 12:03:19PM +0100, Liviu Dudau wrote:
> On Fri, Aug 17, 2018 at 06:33:04PM +0100, Ayan Kumar Halder wrote:
> > For multi-planar formats, while calculating offsets in planes with index greater than 0
> > (ie second plane, third plane, etc), one needs to divide (src_x * cpp) with horizontal
> > chroma subsampling factor and (src_y * pitch) with vertical chroma subsampling factor.
> > 
> > The reason being that the planes contain subsampled (ie reduced) data (by a factor of 2) and thus the
> 
> drop the extraneous "the" at the end of the line.
> 
> > while calculating the byte position coresponding to the x and y co-ordinates, one needs to be
> 
> and drop the extraneous "be" at the end of this line.
> 
> > divide it with the sampling factor.
> > 
> > Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>
> 
> Otherwise, it looks good to me!
> 
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
>
Thanks Liviu. I will update the commit message and push this in
drm-misc-next.

> Best regards,
> Liviu
> 
> > ---
> >  drivers/gpu/drm/drm_fb_cma_helper.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> > index b127061..47e0e2f 100644
> > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > @@ -86,14 +86,21 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
> >  {
> >  	struct drm_gem_cma_object *obj;
> >  	dma_addr_t paddr;
> > +	u8 h_div = 1, v_div = 1;
> >  
> >  	obj = drm_fb_cma_get_gem_obj(fb, plane);
> >  	if (!obj)
> >  		return 0;
> >  
> >  	paddr = obj->paddr + fb->offsets[plane];
> > -	paddr += fb->format->cpp[plane] * (state->src_x >> 16);
> > -	paddr += fb->pitches[plane] * (state->src_y >> 16);
> > +
> > +	if (plane > 0) {
> > +		h_div = fb->format->hsub;
> > +		v_div = fb->format->vsub;
> > +	}
> > +
> > +	paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
> > +	paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
> >  
> >  	return paddr;
> >  }
> > -- 
> > 2.7.4
> > 
> 
> -- 
> ====================
> | I would like to |
> | fix the world,  |
> | but they're not |
> | giving me the   |
>  \ source code!  /
>   ---------------
>     ??\_(???)_/??
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer
  2018-08-20 12:38   ` Ayan Halder
@ 2018-08-20 13:24     ` Liviu Dudau
  0 siblings, 0 replies; 4+ messages in thread
From: Liviu Dudau @ 2018-08-20 13:24 UTC (permalink / raw)
  To: Ayan Halder; +Cc: airlied, linux-kernel, dri-devel, seanpaul, nd

On Mon, Aug 20, 2018 at 01:38:59PM +0100, Ayan Halder wrote:
> On Mon, Aug 20, 2018 at 12:03:19PM +0100, Liviu Dudau wrote:
> > On Fri, Aug 17, 2018 at 06:33:04PM +0100, Ayan Kumar Halder wrote:
> > > For multi-planar formats, while calculating offsets in planes with index greater than 0
> > > (ie second plane, third plane, etc), one needs to divide (src_x * cpp) with horizontal
> > > chroma subsampling factor and (src_y * pitch) with vertical chroma subsampling factor.
> > > 
> > > The reason being that the planes contain subsampled (ie reduced) data (by a factor of 2) and thus the
> > 
> > drop the extraneous "the" at the end of the line.
> > 
> > > while calculating the byte position coresponding to the x and y co-ordinates, one needs to be
> > 
> > and drop the extraneous "be" at the end of this line.
> > 
> > > divide it with the sampling factor.
> > > 
> > > Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>
> > 
> > Otherwise, it looks good to me!
> > 
> > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> >
> Thanks Liviu. I will update the commit message and push this in
> drm-misc-next.

Worth waiting for another review before pushing.

Best regards,
Liviu

> 
> > Best regards,
> > Liviu
> > 
> > > ---
> > >  drivers/gpu/drm/drm_fb_cma_helper.c | 11 +++++++++--
> > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> > > index b127061..47e0e2f 100644
> > > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > > @@ -86,14 +86,21 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
> > >  {
> > >  	struct drm_gem_cma_object *obj;
> > >  	dma_addr_t paddr;
> > > +	u8 h_div = 1, v_div = 1;
> > >  
> > >  	obj = drm_fb_cma_get_gem_obj(fb, plane);
> > >  	if (!obj)
> > >  		return 0;
> > >  
> > >  	paddr = obj->paddr + fb->offsets[plane];
> > > -	paddr += fb->format->cpp[plane] * (state->src_x >> 16);
> > > -	paddr += fb->pitches[plane] * (state->src_y >> 16);
> > > +
> > > +	if (plane > 0) {
> > > +		h_div = fb->format->hsub;
> > > +		v_div = fb->format->vsub;
> > > +	}
> > > +
> > > +	paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div;
> > > +	paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div;
> > >  
> > >  	return paddr;
> > >  }
> > > -- 
> > > 2.7.4
> > > 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-20 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17 17:33 [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer Ayan Kumar Halder
2018-08-20 11:03 ` Liviu Dudau
2018-08-20 12:38   ` Ayan Halder
2018-08-20 13:24     ` Liviu Dudau

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).