gm12u320.c (0454bc59be9e988422793f55a089ee4e86f11f25) | gm12u320.c (49a3f51dfeeecb52c5aa28c5cb9592fe5e39bf95) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright 2019 Hans de Goede <hdegoede@redhat.com> 4 */ 5 6#include <linux/dma-buf.h> 7#include <linux/module.h> 8#include <linux/usb.h> --- 236 unchanged lines hidden (view full) --- 245 src++; 246 } 247} 248 249static void gm12u320_copy_fb_to_blocks(struct gm12u320_device *gm12u320) 250{ 251 int block, dst_offset, len, remain, ret, x1, x2, y1, y2; 252 struct drm_framebuffer *fb; | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright 2019 Hans de Goede <hdegoede@redhat.com> 4 */ 5 6#include <linux/dma-buf.h> 7#include <linux/module.h> 8#include <linux/usb.h> --- 236 unchanged lines hidden (view full) --- 245 src++; 246 } 247} 248 249static void gm12u320_copy_fb_to_blocks(struct gm12u320_device *gm12u320) 250{ 251 int block, dst_offset, len, remain, ret, x1, x2, y1, y2; 252 struct drm_framebuffer *fb; |
253 struct dma_buf_map map; |
|
253 void *vaddr; 254 u8 *src; 255 256 mutex_lock(&gm12u320->fb_update.lock); 257 258 if (!gm12u320->fb_update.fb) 259 goto unlock; 260 261 fb = gm12u320->fb_update.fb; 262 x1 = gm12u320->fb_update.rect.x1; 263 x2 = gm12u320->fb_update.rect.x2; 264 y1 = gm12u320->fb_update.rect.y1; 265 y2 = gm12u320->fb_update.rect.y2; 266 | 254 void *vaddr; 255 u8 *src; 256 257 mutex_lock(&gm12u320->fb_update.lock); 258 259 if (!gm12u320->fb_update.fb) 260 goto unlock; 261 262 fb = gm12u320->fb_update.fb; 263 x1 = gm12u320->fb_update.rect.x1; 264 x2 = gm12u320->fb_update.rect.x2; 265 y1 = gm12u320->fb_update.rect.y1; 266 y2 = gm12u320->fb_update.rect.y2; 267 |
267 vaddr = drm_gem_shmem_vmap(fb->obj[0]); 268 if (IS_ERR(vaddr)) { 269 GM12U320_ERR("failed to vmap fb: %ld\n", PTR_ERR(vaddr)); | 268 ret = drm_gem_shmem_vmap(fb->obj[0], &map); 269 if (ret) { 270 GM12U320_ERR("failed to vmap fb: %d\n", ret); |
270 goto put_fb; 271 } | 271 goto put_fb; 272 } |
273 vaddr = map.vaddr; /* TODO: Use mapping abstraction properly */ |
|
272 273 if (fb->obj[0]->import_attach) { 274 ret = dma_buf_begin_cpu_access( 275 fb->obj[0]->import_attach->dmabuf, DMA_FROM_DEVICE); 276 if (ret) { 277 GM12U320_ERR("dma_buf_begin_cpu_access err: %d\n", ret); 278 goto vunmap; 279 } --- 35 unchanged lines hidden (view full) --- 315 316 if (fb->obj[0]->import_attach) { 317 ret = dma_buf_end_cpu_access(fb->obj[0]->import_attach->dmabuf, 318 DMA_FROM_DEVICE); 319 if (ret) 320 GM12U320_ERR("dma_buf_end_cpu_access err: %d\n", ret); 321 } 322vunmap: | 274 275 if (fb->obj[0]->import_attach) { 276 ret = dma_buf_begin_cpu_access( 277 fb->obj[0]->import_attach->dmabuf, DMA_FROM_DEVICE); 278 if (ret) { 279 GM12U320_ERR("dma_buf_begin_cpu_access err: %d\n", ret); 280 goto vunmap; 281 } --- 35 unchanged lines hidden (view full) --- 317 318 if (fb->obj[0]->import_attach) { 319 ret = dma_buf_end_cpu_access(fb->obj[0]->import_attach->dmabuf, 320 DMA_FROM_DEVICE); 321 if (ret) 322 GM12U320_ERR("dma_buf_end_cpu_access err: %d\n", ret); 323 } 324vunmap: |
323 drm_gem_shmem_vunmap(fb->obj[0], vaddr); | 325 drm_gem_shmem_vunmap(fb->obj[0], &map); |
324put_fb: 325 drm_framebuffer_put(fb); 326 gm12u320->fb_update.fb = NULL; 327unlock: 328 mutex_unlock(&gm12u320->fb_update.lock); 329} 330 331static void gm12u320_fb_update_work(struct work_struct *work) --- 406 unchanged lines hidden --- | 326put_fb: 327 drm_framebuffer_put(fb); 328 gm12u320->fb_update.fb = NULL; 329unlock: 330 mutex_unlock(&gm12u320->fb_update.lock); 331} 332 333static void gm12u320_fb_update_work(struct work_struct *work) --- 406 unchanged lines hidden --- |