aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_fb_cma_helper.c
diff options
context:
space:
mode:
authorAyan Kumar Halder <ayan.halder@arm.com>2018-08-17 17:54:00 +0100
committerAyan Kumar Halder <ayan.halder@arm.com>2018-08-20 14:13:43 +0100
commitc76abab59b3cb34a0bc819595614844ed28be721 (patch)
tree5fa0799b2ad42b42c9a9bd5604375160a176ff52 /drivers/gpu/drm/drm_fb_cma_helper.c
parentdrm/vgem: Remove unecessary dma_fence_ops (diff)
downloadlinux-dev-c76abab59b3cb34a0bc819595614844ed28be721.tar.xz
linux-dev-c76abab59b3cb34a0bc819595614844ed28be721.zip
drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer
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 while calculating the byte position coresponding to the x and y co-ordinates, one needs to divide it with the sampling factor. Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Link: https://patchwork.kernel.org/patch/10569263/
Diffstat (limited to 'drivers/gpu/drm/drm_fb_cma_helper.c')
-rw-r--r--drivers/gpu/drm/drm_fb_cma_helper.c11
1 files 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 b127061b4cf3..47e0e2f6642d 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;
}