Skip to content

Commit f2fa353

Browse files
committed
drm/imx: ipuv3-plane: let drm_plane_state_to_ubo/vbo handle chroma subsampling other than 4:2:0
To support 4:2:2 or 4:4:4 chroma subsampling, divide the x/y offsets in drm_plane_state_to_ubo/vbo only if necessary for the given pixel format. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Liu Ying <gnuiyl@gmail.com>
1 parent 3fd8b29 commit f2fa353

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

‎drivers/gpu/drm/imx/ipuv3-plane.c‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ drm_plane_state_to_eba(struct drm_plane_state *state)
6464
{
6565
struct drm_framebuffer *fb = state->fb;
6666
struct drm_gem_cma_object *cma_obj;
67+
int x = state->src_x >> 16;
68+
int y = state->src_y >> 16;
6769

6870
cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
6971
BUG_ON(!cma_obj);
7072

71-
return cma_obj->paddr + fb->offsets[0] +
72-
fb->pitches[0] * (state->src_y >> 16) +
73-
(fb->bits_per_pixel >> 3) * (state->src_x >> 16);
73+
return cma_obj->paddr + fb->offsets[0] + fb->pitches[0] * y +
74+
drm_format_plane_cpp(fb->pixel_format, 0) * x;
7475
}
7576

7677
static inline unsigned long
@@ -79,13 +80,17 @@ drm_plane_state_to_ubo(struct drm_plane_state *state)
7980
struct drm_framebuffer *fb = state->fb;
8081
struct drm_gem_cma_object *cma_obj;
8182
unsigned long eba = drm_plane_state_to_eba(state);
83+
int x = state->src_x >> 16;
84+
int y = state->src_y >> 16;
8285

8386
cma_obj = drm_fb_cma_get_gem_obj(fb, 1);
8487
BUG_ON(!cma_obj);
8588

86-
return cma_obj->paddr + fb->offsets[1] +
87-
fb->pitches[1] * (state->src_y >> 16) / 2 +
88-
(state->src_x >> 16) / 2 - eba;
89+
x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
90+
y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
91+
92+
return cma_obj->paddr + fb->offsets[1] + fb->pitches[1] * y +
93+
drm_format_plane_cpp(fb->pixel_format, 1) * x - eba;
8994
}
9095

9196
static inline unsigned long
@@ -94,13 +99,17 @@ drm_plane_state_to_vbo(struct drm_plane_state *state)
9499
struct drm_framebuffer *fb = state->fb;
95100
struct drm_gem_cma_object *cma_obj;
96101
unsigned long eba = drm_plane_state_to_eba(state);
102+
int x = state->src_x >> 16;
103+
int y = state->src_y >> 16;
97104

98105
cma_obj = drm_fb_cma_get_gem_obj(fb, 2);
99106
BUG_ON(!cma_obj);
100107

101-
return cma_obj->paddr + fb->offsets[2] +
102-
fb->pitches[2] * (state->src_y >> 16) / 2 +
103-
(state->src_x >> 16) / 2 - eba;
108+
x /= drm_format_horz_chroma_subsampling(fb->pixel_format);
109+
y /= drm_format_vert_chroma_subsampling(fb->pixel_format);
110+
111+
return cma_obj->paddr + fb->offsets[2] + fb->pitches[2] * y +
112+
drm_format_plane_cpp(fb->pixel_format, 2) * x - eba;
104113
}
105114

106115
void ipu_plane_put_resources(struct ipu_plane *ipu_plane)

0 commit comments

Comments
 (0)