Exemplo n.º 1
0
static int evdi_user_framebuffer_create_handle(struct drm_framebuffer *fb,
					       struct drm_file *file_priv,
					       unsigned int *handle)
{
	struct evdi_framebuffer *efb = to_evdi_fb(fb);

	return drm_gem_handle_create(file_priv, &efb->obj->base, handle);
}
Exemplo n.º 2
0
static void evdi_user_framebuffer_destroy(struct drm_framebuffer *fb)
{
	struct evdi_framebuffer *ufb = to_evdi_fb(fb);

	EVDI_CHECKPT();
	if (ufb->obj->vmapping)
		evdi_gem_vunmap(ufb->obj);

	if (ufb->obj)
		drm_gem_object_unreference_unlocked(&ufb->obj->base);

	drm_framebuffer_cleanup(fb);
	kfree(ufb);
}
Exemplo n.º 3
0
static int evdi_user_framebuffer_dirty(struct drm_framebuffer *fb,
				       __always_unused struct drm_file *file,
				       __always_unused unsigned int flags,
				       __always_unused unsigned int color,
				       struct drm_clip_rect *clips,
				       unsigned int num_clips)
{
	struct evdi_framebuffer *ufb = to_evdi_fb(fb);
	struct drm_device *dev = ufb->base.dev;
	struct evdi_device *evdi = dev->dev_private;
	int i;
	int ret = 0;

	EVDI_CHECKPT();
	drm_modeset_lock_all(fb->dev);

	if (!ufb->active)
		goto unlock;

	if (ufb->obj->base.import_attach) {
		ret =
			dma_buf_begin_cpu_access(
					ufb->obj->base.import_attach->dmabuf,
#if KERNEL_VERSION(4, 6, 0) > LINUX_VERSION_CODE
					0, ufb->obj->base.size,
#endif
					DMA_FROM_DEVICE);
		if (ret)
			goto unlock;
	}

	for (i = 0; i < num_clips; i++) {
		ret = evdi_handle_damage(ufb, clips[i].x1, clips[i].y1,
					 clips[i].x2 - clips[i].x1,
					 clips[i].y2 - clips[i].y1);
		if (ret)
			goto unlock;
	}

	if (ufb->obj->base.import_attach)
		dma_buf_end_cpu_access(ufb->obj->base.import_attach->dmabuf,
#if KERNEL_VERSION(4, 6, 0) > LINUX_VERSION_CODE
				       0, ufb->obj->base.size,
#endif
				       DMA_FROM_DEVICE);
	atomic_add(1, &evdi->frame_count);
 unlock:
	drm_modeset_unlock_all(fb->dev);
	return ret;
}
Exemplo n.º 4
0
static int evdi_user_framebuffer_dirty(struct drm_framebuffer *fb,
                                       struct drm_file *file,
                                       unsigned flags,
                                       unsigned color,
                                       struct drm_clip_rect *clips,
                                       unsigned num_clips)
{
  struct evdi_framebuffer *ufb = to_evdi_fb(fb);
  struct drm_device *dev = ufb->base.dev;
  struct evdi_device *evdi = dev->dev_private;
  int i;
  int ret = 0;

  EVDI_CHECKPT();
  drm_modeset_lock_all(fb->dev);

  if (ufb->obj->base.import_attach) {
    ret = dma_buf_begin_cpu_access(ufb->obj->base.import_attach->dmabuf,
                                   0, ufb->obj->base.size,
                                   DMA_FROM_DEVICE);
    if (ret) {
      goto unlock;
    }
  }

  for (i = 0; i < num_clips; i++) {
    ret = evdi_handle_damage(ufb, clips[i].x1, clips[i].y1,
                             clips[i].x2 - clips[i].x1,
                             clips[i].y2 - clips[i].y1);
    if (ret) {
      goto unlock;
    }
  }

  if (ufb->obj->base.import_attach) {
    dma_buf_end_cpu_access(ufb->obj->base.import_attach->dmabuf,
                           0,
                           ufb->obj->base.size,
                           DMA_FROM_DEVICE);
  }
  atomic_add(1, &evdi->frame_count);
unlock:
  drm_modeset_unlock_all(fb->dev);
  return ret;
}