Commit ce724470 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/udl: Use framebuffer dma-buf helpers

Replace dma_buf_begin_cpu_access() with drm_gem_fb_begin_cpu_access();
same for _end_cpu_access(). Remove some boiler-plate code. No functional
changes.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716140801.1215-3-tzimmermann@suse.de
parent 37408cd8
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
* Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it> * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
* Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com> * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
* Copyright (C) 2009 Bernie Thompson <bernie@plugable.com> * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
*/ */
#include <linux/dma-buf.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_damage_helper.h> #include <drm/drm_damage_helper.h>
...@@ -271,9 +268,8 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma ...@@ -271,9 +268,8 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma
int x, int y, int width, int height) int x, int y, int width, int height)
{ {
struct drm_device *dev = fb->dev; struct drm_device *dev = fb->dev;
struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */ void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */
int i, ret, tmp_ret; int i, ret;
char *cmd; char *cmd;
struct urb *urb; struct urb *urb;
struct drm_rect clip; struct drm_rect clip;
...@@ -290,17 +286,14 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma ...@@ -290,17 +286,14 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma
else if ((clip.x2 > fb->width) || (clip.y2 > fb->height)) else if ((clip.x2 > fb->width) || (clip.y2 > fb->height))
return -EINVAL; return -EINVAL;
if (import_attach) { ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
ret = dma_buf_begin_cpu_access(import_attach->dmabuf, if (ret)
DMA_FROM_DEVICE); return ret;
if (ret)
return ret;
}
urb = udl_get_urb(dev); urb = udl_get_urb(dev);
if (!urb) { if (!urb) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_dma_buf_end_cpu_access; goto out_drm_gem_fb_end_cpu_access;
} }
cmd = urb->transfer_buffer; cmd = urb->transfer_buffer;
...@@ -313,7 +306,7 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma ...@@ -313,7 +306,7 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma
&cmd, byte_offset, dev_byte_offset, &cmd, byte_offset, dev_byte_offset,
byte_width); byte_width);
if (ret) if (ret)
goto out_dma_buf_end_cpu_access; goto out_drm_gem_fb_end_cpu_access;
} }
if (cmd > (char *)urb->transfer_buffer) { if (cmd > (char *)urb->transfer_buffer) {
...@@ -329,14 +322,8 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma ...@@ -329,14 +322,8 @@ static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_ma
ret = 0; ret = 0;
out_dma_buf_end_cpu_access: out_drm_gem_fb_end_cpu_access:
if (import_attach) { drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
tmp_ret = dma_buf_end_cpu_access(import_attach->dmabuf,
DMA_FROM_DEVICE);
if (tmp_ret && !ret)
ret = tmp_ret; /* only update ret if not set yet */
}
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