Commit aa7c8865 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Remove cursor double buffering

Update the cursor image via damage handling in-place. The cursor's
double buffering has no visible effect on the output, so remove it.

Done in preparation of switching ast to GEM SHMEM helpers. Removing
double buffering will allow us to use the same data structure for
primary and cursor plane.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Tested-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221013112923.769-5-tzimmermann@suse.de
parent 963a2ba2
...@@ -96,8 +96,6 @@ enum ast_tx_chip { ...@@ -96,8 +96,6 @@ enum ast_tx_chip {
#define AST_HWC_SIZE (AST_MAX_HWC_WIDTH * AST_MAX_HWC_HEIGHT * 2) #define AST_HWC_SIZE (AST_MAX_HWC_WIDTH * AST_MAX_HWC_HEIGHT * 2)
#define AST_HWC_SIGNATURE_SIZE 32 #define AST_HWC_SIGNATURE_SIZE 32
#define AST_DEFAULT_HWC_NUM 2
/* define for signature structure */ /* define for signature structure */
#define AST_HWC_SIGNATURE_CHECKSUM 0x00 #define AST_HWC_SIGNATURE_CHECKSUM 0x00
#define AST_HWC_SIGNATURE_SizeX 0x04 #define AST_HWC_SIGNATURE_SizeX 0x04
...@@ -110,13 +108,9 @@ enum ast_tx_chip { ...@@ -110,13 +108,9 @@ 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;
struct drm_gem_vram_object *gbo; struct iosys_map map;
struct iosys_map map; u64 off;
u64 off;
} hwc[AST_DEFAULT_HWC_NUM];
unsigned int next_hwc_index;
}; };
static inline struct ast_cursor_plane * static inline struct ast_cursor_plane *
......
...@@ -837,10 +837,8 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ...@@ -837,10 +837,8 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state); struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
struct drm_framebuffer *fb = new_state->fb; struct drm_framebuffer *fb = new_state->fb;
struct ast_private *ast = to_ast_private(plane->dev); struct ast_private *ast = to_ast_private(plane->dev);
struct iosys_map dst_map = struct iosys_map dst_map = ast_cursor_plane->map;
ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map; u64 dst_off = ast_cursor_plane->off;
u64 dst_off =
ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].off;
struct iosys_map src_map = shadow_plane_state->data[0]; struct iosys_map src_map = shadow_plane_state->data[0];
unsigned int offset_x, offset_y; unsigned int offset_x, offset_y;
u16 x, y; u16 x, y;
...@@ -860,13 +858,9 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ...@@ -860,13 +858,9 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
ast_update_cursor_image(dst, src, fb->width, fb->height); ast_update_cursor_image(dst, src, fb->width, fb->height);
if (new_state->fb != old_state->fb) { if (new_state->fb != old_state->fb)
ast_set_cursor_base(ast, dst_off); ast_set_cursor_base(ast, dst_off);
++ast_cursor_plane->next_hwc_index;
ast_cursor_plane->next_hwc_index %= ARRAY_SIZE(ast_cursor_plane->hwc);
}
/* /*
* Update location in HWC signature and registers. * Update location in HWC signature and registers.
*/ */
...@@ -917,17 +911,12 @@ static const struct drm_plane_helper_funcs ast_cursor_plane_helper_funcs = { ...@@ -917,17 +911,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_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane); struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
size_t i; struct drm_gem_vram_object *gbo = ast_cursor_plane->gbo;
struct drm_gem_vram_object *gbo; struct iosys_map map = ast_cursor_plane->map;
struct iosys_map map;
for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) { drm_gem_vram_vunmap(gbo, &map);
gbo = ast_cursor_plane->hwc[i].gbo; drm_gem_vram_unpin(gbo);
map = ast_cursor_plane->hwc[i].map; drm_gem_vram_put(gbo);
drm_gem_vram_vunmap(gbo, &map);
drm_gem_vram_unpin(gbo);
drm_gem_vram_put(gbo);
}
drm_plane_cleanup(plane); drm_plane_cleanup(plane);
} }
...@@ -944,7 +933,7 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -944,7 +933,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
struct drm_device *dev = &ast->base; struct drm_device *dev = &ast->base;
struct ast_cursor_plane *ast_cursor_plane = &ast->cursor_plane; struct ast_cursor_plane *ast_cursor_plane = &ast->cursor_plane;
struct drm_plane *cursor_plane = &ast_cursor_plane->base; struct drm_plane *cursor_plane = &ast_cursor_plane->base;
size_t size, i; size_t size;
struct drm_gem_vram_object *gbo; struct drm_gem_vram_object *gbo;
struct iosys_map map; struct iosys_map map;
int ret; int ret;
...@@ -957,29 +946,27 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -957,29 +946,27 @@ 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_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)) { return PTR_ERR(gbo);
ret = PTR_ERR(gbo);
goto err_hwc; ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM |
} DRM_GEM_VRAM_PL_FLAG_TOPDOWN);
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM | if (ret)
DRM_GEM_VRAM_PL_FLAG_TOPDOWN); goto err_drm_gem_vram_put;
if (ret) ret = drm_gem_vram_vmap(gbo, &map);
goto err_drm_gem_vram_put; if (ret)
ret = drm_gem_vram_vmap(gbo, &map); goto err_drm_gem_vram_unpin;
if (ret) off = drm_gem_vram_offset(gbo);
goto err_drm_gem_vram_unpin; if (off < 0) {
off = drm_gem_vram_offset(gbo); ret = off;
if (off < 0) { goto err_drm_gem_vram_vunmap;
ret = off;
goto err_drm_gem_vram_vunmap;
}
ast_cursor_plane->hwc[i].gbo = gbo;
ast_cursor_plane->hwc[i].map = map;
ast_cursor_plane->hwc[i].off = off;
} }
ast_cursor_plane->gbo = gbo;
ast_cursor_plane->map = map;
ast_cursor_plane->off = off;
/* /*
* Create the cursor plane. The plane's destroy callback will release * Create the cursor plane. The plane's destroy callback will release
* the backing storages' BO memory. * the backing storages' BO memory.
...@@ -992,24 +979,18 @@ static int ast_cursor_plane_init(struct ast_private *ast) ...@@ -992,24 +979,18 @@ static int ast_cursor_plane_init(struct ast_private *ast)
NULL, DRM_PLANE_TYPE_CURSOR, NULL); NULL, DRM_PLANE_TYPE_CURSOR, NULL);
if (ret) { if (ret) {
drm_err(dev, "drm_universal_plane failed(): %d\n", ret); drm_err(dev, "drm_universal_plane failed(): %d\n", ret);
goto err_hwc; goto err_drm_gem_vram_vunmap;
} }
drm_plane_helper_add(cursor_plane, &ast_cursor_plane_helper_funcs); drm_plane_helper_add(cursor_plane, &ast_cursor_plane_helper_funcs);
return 0; return 0;
err_hwc:
while (i) {
--i;
gbo = ast_cursor_plane->hwc[i].gbo;
map = ast_cursor_plane->hwc[i].map;
err_drm_gem_vram_vunmap: err_drm_gem_vram_vunmap:
drm_gem_vram_vunmap(gbo, &map); drm_gem_vram_vunmap(gbo, &map);
err_drm_gem_vram_unpin: err_drm_gem_vram_unpin:
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);
}
return ret; return ret;
} }
......
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