root/drivers/gpu/drm/lima/lima_gem_prime.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. lima_gem_prime_import_sg_table
  2. lima_gem_prime_get_sg_table
  3. lima_gem_prime_mmap

   1 // SPDX-License-Identifier: GPL-2.0 OR MIT
   2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
   3 
   4 #include <linux/dma-buf.h>
   5 #include <drm/drm_prime.h>
   6 #include <drm/drm_drv.h>
   7 #include <drm/drm_file.h>
   8 
   9 #include "lima_device.h"
  10 #include "lima_object.h"
  11 #include "lima_gem.h"
  12 #include "lima_gem_prime.h"
  13 
  14 struct drm_gem_object *lima_gem_prime_import_sg_table(
  15         struct drm_device *dev, struct dma_buf_attachment *attach,
  16         struct sg_table *sgt)
  17 {
  18         struct lima_device *ldev = to_lima_dev(dev);
  19         struct lima_bo *bo;
  20 
  21         bo = lima_bo_create(ldev, attach->dmabuf->size, 0, sgt);
  22         if (IS_ERR(bo))
  23                 return ERR_CAST(bo);
  24 
  25         return &bo->gem;
  26 }
  27 
  28 struct sg_table *lima_gem_prime_get_sg_table(struct drm_gem_object *obj)
  29 {
  30         struct lima_bo *bo = to_lima_bo(obj);
  31         int npages = obj->size >> PAGE_SHIFT;
  32 
  33         return drm_prime_pages_to_sg(bo->pages, npages);
  34 }
  35 
  36 int lima_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
  37 {
  38         int ret;
  39 
  40         ret = drm_gem_mmap_obj(obj, obj->size, vma);
  41         if (ret)
  42                 return ret;
  43 
  44         lima_set_vma_flags(vma);
  45         return 0;
  46 }

/* [<][>][^][v][top][bottom][index][help] */