diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2019-11-14 17:10:24 +0300 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2019-11-26 14:34:47 +0300 |
commit | 8344603534e17f9926253a65088f59b787222bc5 (patch) | |
tree | 96d06691c5f5f78151c4b21da309fe09a4f4d60c /drivers/gpu/drm/udl | |
parent | ba59b015a0145330e2bf7ab20d504bc624fd618a (diff) | |
download | linux-8344603534e17f9926253a65088f59b787222bc5.tar.xz |
drm/udl: Call udl_handle_damage() with DRM framebuffer
Simplifying the udl code before replacing struct udl_framebuffer.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191114141025.32198-5-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/udl')
-rw-r--r-- | drivers/gpu/drm/udl/udl_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/udl/udl_fb.c | 35 | ||||
-rw-r--r-- | drivers/gpu/drm/udl/udl_modeset.c | 15 |
3 files changed, 26 insertions, 26 deletions
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index a0946b955739..c5e3160392cb 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -110,7 +110,7 @@ int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev, size_t size); -int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, +int udl_handle_damage(struct drm_framebuffer *fb, int x, int y, int width, int height); int udl_drop_usb(struct drm_device *dev); diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index e9a4bbd5b195..ad7bf165b59b 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -60,10 +60,10 @@ static uint16_t rgb16(uint32_t col) } #endif -int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, +int udl_handle_damage(struct drm_framebuffer *fb, int x, int y, int width, int height) { - struct drm_device *dev = fb->base.dev; + struct drm_device *dev = fb->dev; struct udl_device *udl = to_udl(dev); int i, ret; char *cmd; @@ -75,17 +75,19 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, int log_bpp; void *vaddr; - BUG_ON(!is_power_of_2(fb->base.format->cpp[0])); - log_bpp = __ffs(fb->base.format->cpp[0]); + if (WARN_ON(!is_power_of_2(fb->format->cpp[0]))) + return -EINVAL; + + log_bpp = __ffs(fb->format->cpp[0]); spin_lock(&udl->active_fb_16_lock); - if (udl->active_fb_16 != &fb->base) { + if (udl->active_fb_16 != fb) { spin_unlock(&udl->active_fb_16_lock); return 0; } spin_unlock(&udl->active_fb_16_lock); - vaddr = drm_gem_shmem_vmap(&fb->shmem->base); + vaddr = drm_gem_shmem_vmap(fb->obj[0]); if (IS_ERR(vaddr)) { DRM_ERROR("failed to vmap fb\n"); return 0; @@ -96,8 +98,8 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, x = aligned_x; if ((width <= 0) || - (x + width > fb->base.width) || - (y + height > fb->base.height)) { + (x + width > fb->width) || + (y + height > fb->height)) { ret = -EINVAL; goto err_drm_gem_shmem_vunmap; } @@ -110,9 +112,9 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, cmd = urb->transfer_buffer; for (i = y; i < y + height ; i++) { - const int line_offset = fb->base.pitches[0] * i; + const int line_offset = fb->pitches[0] * i; const int byte_offset = line_offset + (x << log_bpp); - const int dev_byte_offset = (fb->base.width * i + x) << log_bpp; + const int dev_byte_offset = (fb->width * i + x) << log_bpp; if (udl_render_hline(dev, log_bpp, &urb, (char *)vaddr, &cmd, byte_offset, dev_byte_offset, width << log_bpp, @@ -141,12 +143,12 @@ error: &udl->cpu_kcycles_used); out: - drm_gem_shmem_vunmap(&fb->shmem->base, vaddr); + drm_gem_shmem_vunmap(fb->obj[0], vaddr); return 0; err_drm_gem_shmem_vunmap: - drm_gem_shmem_vunmap(&fb->shmem->base, vaddr); + drm_gem_shmem_vunmap(fb->obj[0], vaddr); return ret; } @@ -156,7 +158,6 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb, struct drm_clip_rect *clips, unsigned num_clips) { - struct udl_framebuffer *ufb = to_udl_fb(fb); struct udl_device *udl = fb->dev->dev_private; struct dma_buf_attachment *import_attach; int i; @@ -171,7 +172,7 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb, } spin_unlock(&udl->active_fb_16_lock); - import_attach = ufb->shmem->base.import_attach; + import_attach = fb->obj[0]->import_attach; if (import_attach) { ret = dma_buf_begin_cpu_access(import_attach->dmabuf, @@ -181,9 +182,9 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb, } for (i = 0; i < num_clips; i++) { - ret = udl_handle_damage(ufb, clips[i].x1, clips[i].y1, - clips[i].x2 - clips[i].x1, - clips[i].y2 - clips[i].y1); + ret = udl_handle_damage(fb, clips[i].x1, clips[i].y1, + clips[i].x2 - clips[i].x1, + clips[i].y2 - clips[i].y1); if (ret) break; } diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 44a741f463c9..91af25caed64 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -301,7 +301,7 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc, { struct drm_device *dev = crtc->dev; - struct udl_framebuffer *ufb = to_udl_fb(crtc->primary->fb); + struct drm_framebuffer *fb = crtc->primary->fb; struct udl_device *udl = dev->dev_private; char *buf; char *wrptr; @@ -333,12 +333,12 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc, wrptr = udl_dummy_render(wrptr); spin_lock(&udl->active_fb_16_lock); - udl->active_fb_16 = &ufb->base; + udl->active_fb_16 = fb; spin_unlock(&udl->active_fb_16_lock); udl->mode_buf_len = wrptr - buf; /* damage all of it */ - udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height); + udl_handle_damage(fb, 0, 0, fb->width, fb->height); return 0; } @@ -360,7 +360,6 @@ static int udl_crtc_page_flip(struct drm_crtc *crtc, uint32_t page_flip_flags, struct drm_modeset_acquire_ctx *ctx) { - struct udl_framebuffer *ufb = to_udl_fb(fb); struct drm_device *dev = crtc->dev; struct udl_device *udl = dev->dev_private; @@ -368,7 +367,7 @@ static int udl_crtc_page_flip(struct drm_crtc *crtc, udl->active_fb_16 = fb; spin_unlock(&udl->active_fb_16_lock); - udl_handle_damage(ufb, 0, 0, fb->width, fb->height); + udl_handle_damage(fb, 0, 0, fb->width, fb->height); spin_lock_irq(&dev->event_lock); if (event) @@ -448,13 +447,13 @@ int udl_modeset_init(struct drm_device *dev) void udl_modeset_restore(struct drm_device *dev) { struct udl_device *udl = dev->dev_private; - struct udl_framebuffer *ufb; + struct drm_framebuffer *fb; if (!udl->crtc || !udl->crtc->primary->fb) return; udl_crtc_commit(udl->crtc); - ufb = to_udl_fb(udl->crtc->primary->fb); - udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height); + fb = udl->crtc->primary->fb; + udl_handle_damage(fb, 0, 0, fb->width, fb->height); } void udl_modeset_cleanup(struct drm_device *dev) |