mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 05:31:15 +00:00
drm/ast: Replace mapping code with drm_gem_vram_{kmap/kunmap}()
The AST driver establishes several memory mappings for frame buffers and cursors. This patch converts the driver to use the equivalent drm_gem_vram_kmap() functions. It removes the dependencies on TTM and cleans up the code. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: http://patchwork.freedesktop.org/patch/msgid/20190508082630.15116-12-tzimmermann@suse.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
969562b2cd
commit
3f87330e50
3 changed files with 54 additions and 26 deletions
|
@ -256,7 +256,6 @@ struct ast_fbdev {
|
||||||
struct ast_framebuffer afb;
|
struct ast_framebuffer afb;
|
||||||
void *sysram;
|
void *sysram;
|
||||||
int size;
|
int size;
|
||||||
struct ttm_bo_kmap_obj mapping;
|
|
||||||
int x1, y1, x2, y2; /* dirty rect */
|
int x1, y1, x2, y2; /* dirty rect */
|
||||||
spinlock_t dirty_lock;
|
spinlock_t dirty_lock;
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,7 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
|
||||||
int src_offset, dst_offset;
|
int src_offset, dst_offset;
|
||||||
int bpp = afbdev->afb.base.format->cpp[0];
|
int bpp = afbdev->afb.base.format->cpp[0];
|
||||||
int ret = -EBUSY;
|
int ret = -EBUSY;
|
||||||
|
u8 *dst;
|
||||||
bool unmap = false;
|
bool unmap = false;
|
||||||
bool store_for_later = false;
|
bool store_for_later = false;
|
||||||
int x2, y2;
|
int x2, y2;
|
||||||
|
@ -101,27 +102,31 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
|
||||||
afbdev->x2 = afbdev->y2 = 0;
|
afbdev->x2 = afbdev->y2 = 0;
|
||||||
spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
|
spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
|
||||||
|
|
||||||
if (!gbo->kmap.virtual) {
|
dst = drm_gem_vram_kmap(gbo, false, NULL);
|
||||||
ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, &gbo->kmap);
|
if (IS_ERR(dst)) {
|
||||||
if (ret) {
|
DRM_ERROR("failed to kmap fb updates\n");
|
||||||
|
goto out;
|
||||||
|
} else if (!dst) {
|
||||||
|
dst = drm_gem_vram_kmap(gbo, true, NULL);
|
||||||
|
if (IS_ERR(dst)) {
|
||||||
DRM_ERROR("failed to kmap fb updates\n");
|
DRM_ERROR("failed to kmap fb updates\n");
|
||||||
drm_gem_vram_unreserve(gbo);
|
goto out;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
unmap = true;
|
unmap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = y; i <= y2; i++) {
|
for (i = y; i <= y2; i++) {
|
||||||
/* assume equal stride for now */
|
/* assume equal stride for now */
|
||||||
src_offset = dst_offset =
|
src_offset = dst_offset =
|
||||||
i * afbdev->afb.base.pitches[0] + (x * bpp);
|
i * afbdev->afb.base.pitches[0] + (x * bpp);
|
||||||
memcpy_toio(gbo->kmap.virtual + src_offset,
|
memcpy_toio(dst + dst_offset, afbdev->sysram + src_offset,
|
||||||
afbdev->sysram + dst_offset,
|
|
||||||
(x2 - x + 1) * bpp);
|
(x2 - x + 1) * bpp);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (unmap)
|
|
||||||
ttm_bo_kunmap(&gbo->kmap);
|
|
||||||
|
|
||||||
|
if (unmap)
|
||||||
|
drm_gem_vram_kunmap(gbo);
|
||||||
|
|
||||||
|
out:
|
||||||
drm_gem_vram_unreserve(gbo);
|
drm_gem_vram_unreserve(gbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -532,6 +532,7 @@ static int ast_crtc_do_set_base(struct drm_crtc *crtc,
|
||||||
struct drm_gem_vram_object *gbo;
|
struct drm_gem_vram_object *gbo;
|
||||||
int ret;
|
int ret;
|
||||||
s64 gpu_addr;
|
s64 gpu_addr;
|
||||||
|
void *base;
|
||||||
|
|
||||||
/* push the previous fb to system ram */
|
/* push the previous fb to system ram */
|
||||||
if (!atomic && fb) {
|
if (!atomic && fb) {
|
||||||
|
@ -564,11 +565,13 @@ static int ast_crtc_do_set_base(struct drm_crtc *crtc,
|
||||||
|
|
||||||
if (&ast->fbdev->afb == ast_fb) {
|
if (&ast->fbdev->afb == ast_fb) {
|
||||||
/* if pushing console in kmap it */
|
/* if pushing console in kmap it */
|
||||||
ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, &gbo->kmap);
|
base = drm_gem_vram_kmap(gbo, true, NULL);
|
||||||
if (ret)
|
if (IS_ERR(base)) {
|
||||||
|
ret = PTR_ERR(base);
|
||||||
DRM_ERROR("failed to kmap fbcon\n");
|
DRM_ERROR("failed to kmap fbcon\n");
|
||||||
else
|
} else {
|
||||||
ast_fbdev_set_base(ast, gpu_addr);
|
ast_fbdev_set_base(ast, gpu_addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
drm_gem_vram_unreserve(gbo);
|
drm_gem_vram_unreserve(gbo);
|
||||||
|
|
||||||
|
@ -928,6 +931,7 @@ static int ast_cursor_init(struct drm_device *dev)
|
||||||
struct drm_gem_object *obj;
|
struct drm_gem_object *obj;
|
||||||
struct drm_gem_vram_object *gbo;
|
struct drm_gem_vram_object *gbo;
|
||||||
s64 gpu_addr;
|
s64 gpu_addr;
|
||||||
|
void *base;
|
||||||
|
|
||||||
size = (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE) * AST_DEFAULT_HWC_NUM;
|
size = (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE) * AST_DEFAULT_HWC_NUM;
|
||||||
|
|
||||||
|
@ -951,9 +955,11 @@ static int ast_cursor_init(struct drm_device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kmap the object */
|
/* kmap the object */
|
||||||
ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, &ast->cache_kmap);
|
base = drm_gem_vram_kmap_at(gbo, true, NULL, &ast->cache_kmap);
|
||||||
if (ret)
|
if (IS_ERR(base)) {
|
||||||
|
ret = PTR_ERR(base);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
ast->cursor_cache = obj;
|
ast->cursor_cache = obj;
|
||||||
ast->cursor_cache_gpu_addr = gpu_addr;
|
ast->cursor_cache_gpu_addr = gpu_addr;
|
||||||
|
@ -966,7 +972,9 @@ fail:
|
||||||
static void ast_cursor_fini(struct drm_device *dev)
|
static void ast_cursor_fini(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
struct ast_private *ast = dev->dev_private;
|
struct ast_private *ast = dev->dev_private;
|
||||||
ttm_bo_kunmap(&ast->cache_kmap);
|
struct drm_gem_vram_object *gbo =
|
||||||
|
drm_gem_vram_of_gem(ast->cursor_cache);
|
||||||
|
drm_gem_vram_kunmap_at(gbo, &ast->cache_kmap);
|
||||||
drm_gem_object_put_unlocked(ast->cursor_cache);
|
drm_gem_object_put_unlocked(ast->cursor_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,13 +1221,21 @@ static int ast_cursor_set(struct drm_crtc *crtc,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ret = ttm_bo_kmap(&gbo->bo, 0, gbo->bo.num_pages, &uobj_map);
|
memset(&uobj_map, 0, sizeof(uobj_map));
|
||||||
|
src = drm_gem_vram_kmap_at(gbo, true, &src_isiomem, &uobj_map);
|
||||||
src = ttm_kmap_obj_virtual(&uobj_map, &src_isiomem);
|
if (IS_ERR(src)) {
|
||||||
dst = ttm_kmap_obj_virtual(&ast->cache_kmap, &dst_isiomem);
|
ret = PTR_ERR(src);
|
||||||
|
goto fail_unreserve;
|
||||||
|
}
|
||||||
if (src_isiomem == true)
|
if (src_isiomem == true)
|
||||||
DRM_ERROR("src cursor bo should be in main memory\n");
|
DRM_ERROR("src cursor bo should be in main memory\n");
|
||||||
|
|
||||||
|
dst = drm_gem_vram_kmap_at(drm_gem_vram_of_gem(ast->cursor_cache),
|
||||||
|
false, &dst_isiomem, &ast->cache_kmap);
|
||||||
|
if (IS_ERR(dst)) {
|
||||||
|
ret = PTR_ERR(dst);
|
||||||
|
goto fail_unreserve;
|
||||||
|
}
|
||||||
if (dst_isiomem == false)
|
if (dst_isiomem == false)
|
||||||
DRM_ERROR("dst bo should be in VRAM\n");
|
DRM_ERROR("dst bo should be in VRAM\n");
|
||||||
|
|
||||||
|
@ -1228,11 +1244,14 @@ static int ast_cursor_set(struct drm_crtc *crtc,
|
||||||
/* do data transfer to cursor cache */
|
/* do data transfer to cursor cache */
|
||||||
csum = copy_cursor_image(src, dst, width, height);
|
csum = copy_cursor_image(src, dst, width, height);
|
||||||
|
|
||||||
/* write checksum + signature */
|
drm_gem_vram_kunmap_at(gbo, &uobj_map);
|
||||||
ttm_bo_kunmap(&uobj_map);
|
|
||||||
drm_gem_vram_unreserve(gbo);
|
drm_gem_vram_unreserve(gbo);
|
||||||
|
|
||||||
|
/* write checksum + signature */
|
||||||
{
|
{
|
||||||
u8 *dst = (u8 *)ast->cache_kmap.virtual + (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor + AST_HWC_SIZE;
|
u8 *dst = drm_gem_vram_kmap_at(drm_gem_vram_of_gem(ast->cursor_cache),
|
||||||
|
false, NULL, &ast->cache_kmap);
|
||||||
|
dst += (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor + AST_HWC_SIZE;
|
||||||
writel(csum, dst);
|
writel(csum, dst);
|
||||||
writel(width, dst + AST_HWC_SIGNATURE_SizeX);
|
writel(width, dst + AST_HWC_SIGNATURE_SizeX);
|
||||||
writel(height, dst + AST_HWC_SIGNATURE_SizeY);
|
writel(height, dst + AST_HWC_SIGNATURE_SizeY);
|
||||||
|
@ -1258,6 +1277,9 @@ static int ast_cursor_set(struct drm_crtc *crtc,
|
||||||
|
|
||||||
drm_gem_object_put_unlocked(obj);
|
drm_gem_object_put_unlocked(obj);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail_unreserve:
|
||||||
|
drm_gem_vram_unreserve(gbo);
|
||||||
fail:
|
fail:
|
||||||
drm_gem_object_put_unlocked(obj);
|
drm_gem_object_put_unlocked(obj);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1271,7 +1293,9 @@ static int ast_cursor_move(struct drm_crtc *crtc,
|
||||||
int x_offset, y_offset;
|
int x_offset, y_offset;
|
||||||
u8 *sig;
|
u8 *sig;
|
||||||
|
|
||||||
sig = (u8 *)ast->cache_kmap.virtual + (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor + AST_HWC_SIZE;
|
sig = drm_gem_vram_kmap_at(drm_gem_vram_of_gem(ast->cursor_cache),
|
||||||
|
false, NULL, &ast->cache_kmap);
|
||||||
|
sig += (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor + AST_HWC_SIZE;
|
||||||
writel(x, sig + AST_HWC_SIGNATURE_X);
|
writel(x, sig + AST_HWC_SIGNATURE_X);
|
||||||
writel(y, sig + AST_HWC_SIGNATURE_Y);
|
writel(y, sig + AST_HWC_SIGNATURE_Y);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue