Commit afee7e95 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Store cursor BOs in cursor plane

The cursor uses two BOs in video RAM to implement double buffering. Store
both in struct ast_cursor_plane.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210209134632.12157-8-tzimmermann@suse.de
parent a0ba992d
...@@ -104,6 +104,12 @@ enum ast_tx_chip { ...@@ -104,6 +104,12 @@ enum ast_tx_chip {
struct ast_cursor_plane { struct ast_cursor_plane {
struct drm_plane base; struct drm_plane base;
struct {
struct drm_gem_vram_object *gbo;
} hwc[AST_DEFAULT_HWC_NUM];
unsigned int next_hwc_index;
}; };
static inline struct ast_cursor_plane * static inline struct ast_cursor_plane *
...@@ -151,11 +157,6 @@ struct ast_private { ...@@ -151,11 +157,6 @@ struct ast_private {
int fb_mtrr; int fb_mtrr;
struct {
struct drm_gem_vram_object *gbo[AST_DEFAULT_HWC_NUM];
unsigned int next_index;
} cursor;
struct drm_plane primary_plane; struct drm_plane primary_plane;
struct ast_cursor_plane cursor_plane; struct ast_cursor_plane cursor_plane;
struct drm_crtc crtc; struct drm_crtc crtc;
......
...@@ -757,9 +757,10 @@ static int ...@@ -757,9 +757,10 @@ static int
ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane, ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state) struct drm_plane_state *new_state)
{ {
struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
struct drm_framebuffer *fb = new_state->fb; struct drm_framebuffer *fb = new_state->fb;
struct ast_private *ast = to_ast_private(plane->dev); struct drm_gem_vram_object *dst_gbo =
struct drm_gem_vram_object *dst_gbo = ast->cursor.gbo[ast->cursor.next_index]; ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].gbo;
struct drm_gem_vram_object *src_gbo; struct drm_gem_vram_object *src_gbo;
struct dma_buf_map src_map, dst_map; struct dma_buf_map src_map, dst_map;
void __iomem *dst; void __iomem *dst;
...@@ -826,11 +827,13 @@ static void ...@@ -826,11 +827,13 @@ static void
ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state) struct drm_plane_state *old_state)
{ {
struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
struct drm_plane_state *state = plane->state; struct drm_plane_state *state = plane->state;
struct drm_framebuffer *fb = state->fb; struct drm_framebuffer *fb = state->fb;
struct ast_private *ast = to_ast_private(plane->dev); struct ast_private *ast = to_ast_private(plane->dev);
struct drm_device *dev = &ast->base; struct drm_device *dev = &ast->base;
struct drm_gem_vram_object *gbo = ast->cursor.gbo[ast->cursor.next_index]; struct drm_gem_vram_object *gbo =
ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].gbo;
unsigned int offset_x, offset_y; unsigned int offset_x, offset_y;
s64 off; s64 off;
struct dma_buf_map map; struct dma_buf_map map;
...@@ -840,7 +843,7 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ...@@ -840,7 +843,7 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
u8 __iomem *sig; u8 __iomem *sig;
int ret; int ret;
gbo = ast->cursor.gbo[ast->cursor.next_index]; gbo = ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].gbo;
if (state->fb != old_state->fb) { if (state->fb != old_state->fb) {
/* A new cursor image was installed. */ /* A new cursor image was installed. */
...@@ -849,8 +852,8 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ...@@ -849,8 +852,8 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
return; /* Bug: we didn't pin the cursor HW BO to VRAM. */ return; /* Bug: we didn't pin the cursor HW BO to VRAM. */
ast_set_cursor_base(ast, off); ast_set_cursor_base(ast, off);
++ast->cursor.next_index; ++ast_cursor_plane->next_hwc_index;
ast->cursor.next_index %= ARRAY_SIZE(ast->cursor.gbo); ast_cursor_plane->next_hwc_index %= ARRAY_SIZE(ast_cursor_plane->hwc);
} }
ret = drm_gem_vram_vmap(gbo, &map); ret = drm_gem_vram_vmap(gbo, &map);
...@@ -907,12 +910,12 @@ static const struct drm_plane_helper_funcs ast_cursor_plane_helper_funcs = { ...@@ -907,12 +910,12 @@ static const struct drm_plane_helper_funcs ast_cursor_plane_helper_funcs = {
static void ast_cursor_plane_destroy(struct drm_plane *plane) static void ast_cursor_plane_destroy(struct drm_plane *plane)
{ {
struct ast_private *ast = to_ast_private(plane->dev); struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
size_t i; size_t i;
struct drm_gem_vram_object *gbo; struct drm_gem_vram_object *gbo;
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) { for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) {
gbo = ast->cursor.gbo[i]; gbo = ast_cursor_plane->hwc[i].gbo;
drm_gem_vram_unpin(gbo); drm_gem_vram_unpin(gbo);
drm_gem_vram_put(gbo); drm_gem_vram_put(gbo);
} }
...@@ -945,7 +948,7 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -945,7 +948,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE); size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) { for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) {
gbo = drm_gem_vram_create(dev, size, 0); gbo = drm_gem_vram_create(dev, size, 0);
if (IS_ERR(gbo)) { if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo); ret = PTR_ERR(gbo);
...@@ -955,7 +958,7 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -955,7 +958,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
DRM_GEM_VRAM_PL_FLAG_TOPDOWN); DRM_GEM_VRAM_PL_FLAG_TOPDOWN);
if (ret) if (ret)
goto err_drm_gem_vram_put; goto err_drm_gem_vram_put;
ast->cursor.gbo[i] = gbo; ast_cursor_plane->hwc[i].gbo = gbo;
} }
/* /*
...@@ -979,7 +982,7 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -979,7 +982,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
err_hwc: err_hwc:
while (i) { while (i) {
--i; --i;
gbo = ast->cursor.gbo[i]; gbo = ast_cursor_plane->hwc[i].gbo;
drm_gem_vram_unpin(gbo); drm_gem_vram_unpin(gbo);
err_drm_gem_vram_put: err_drm_gem_vram_put:
drm_gem_vram_put(gbo); drm_gem_vram_put(gbo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment