~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/drm_gem_cma_helper.h

Version: ~ [ linux-6.1-rc7 ] ~ [ linux-6.0.10 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.80 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.156 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.225 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.267 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.300 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.334 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __DRM_GEM_CMA_HELPER_H__
  3 #define __DRM_GEM_CMA_HELPER_H__
  4 
  5 #include <drm/drmP.h>
  6 #include <drm/drm_gem.h>
  7 
  8 /**
  9  * struct drm_gem_cma_object - GEM object backed by CMA memory allocations
 10  * @base: base GEM object
 11  * @paddr: physical address of the backing memory
 12  * @sgt: scatter/gather table for imported PRIME buffers. The table can have
 13  *       more than one entry but they are guaranteed to have contiguous
 14  *       DMA addresses.
 15  * @vaddr: kernel virtual address of the backing memory
 16  */
 17 struct drm_gem_cma_object {
 18         struct drm_gem_object base;
 19         dma_addr_t paddr;
 20         struct sg_table *sgt;
 21 
 22         /* For objects with DMA memory allocated by GEM CMA */
 23         void *vaddr;
 24 };
 25 
 26 #define to_drm_gem_cma_obj(gem_obj) \
 27         container_of(gem_obj, struct drm_gem_cma_object, base)
 28 
 29 #ifndef CONFIG_MMU
 30 #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
 31         .get_unmapped_area      = drm_gem_cma_get_unmapped_area,
 32 #else
 33 #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS
 34 #endif
 35 
 36 /**
 37  * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
 38  * @name: name for the generated structure
 39  *
 40  * This macro autogenerates a suitable &struct file_operations for CMA based
 41  * drivers, which can be assigned to &drm_driver.fops. Note that this structure
 42  * cannot be shared between drivers, because it contains a reference to the
 43  * current module using THIS_MODULE.
 44  *
 45  * Note that the declaration is already marked as static - if you need a
 46  * non-static version of this you're probably doing it wrong and will break the
 47  * THIS_MODULE reference by accident.
 48  */
 49 #define DEFINE_DRM_GEM_CMA_FOPS(name) \
 50         static const struct file_operations name = {\
 51                 .owner          = THIS_MODULE,\
 52                 .open           = drm_open,\
 53                 .release        = drm_release,\
 54                 .unlocked_ioctl = drm_ioctl,\
 55                 .compat_ioctl   = drm_compat_ioctl,\
 56                 .poll           = drm_poll,\
 57                 .read           = drm_read,\
 58                 .llseek         = noop_llseek,\
 59                 .mmap           = drm_gem_cma_mmap,\
 60                 DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
 61         }
 62 
 63 /* free GEM object */
 64 void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
 65 
 66 /* create memory region for DRM framebuffer */
 67 int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv,
 68                                      struct drm_device *drm,
 69                                      struct drm_mode_create_dumb *args);
 70 
 71 /* create memory region for DRM framebuffer */
 72 int drm_gem_cma_dumb_create(struct drm_file *file_priv,
 73                             struct drm_device *drm,
 74                             struct drm_mode_create_dumb *args);
 75 
 76 /* set vm_flags and we can change the VM attribute to other one at here */
 77 int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);
 78 
 79 /* allocate physical memory */
 80 struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
 81                                               size_t size);
 82 
 83 extern const struct vm_operations_struct drm_gem_cma_vm_ops;
 84 
 85 #ifndef CONFIG_MMU
 86 unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
 87                                             unsigned long addr,
 88                                             unsigned long len,
 89                                             unsigned long pgoff,
 90                                             unsigned long flags);
 91 #endif
 92 
 93 void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
 94                             const struct drm_gem_object *obj);
 95 
 96 struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
 97 struct drm_gem_object *
 98 drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
 99                                   struct dma_buf_attachment *attach,
100                                   struct sg_table *sgt);
101 int drm_gem_cma_prime_mmap(struct drm_gem_object *obj,
102                            struct vm_area_struct *vma);
103 void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj);
104 void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
105 
106 struct drm_gem_object *
107 drm_cma_gem_create_object_default_funcs(struct drm_device *dev, size_t size);
108 
109 /**
110  * DRM_GEM_CMA_VMAP_DRIVER_OPS - CMA GEM driver operations ensuring a virtual
111  *                               address on the buffer
112  *
113  * This macro provides a shortcut for setting the default GEM operations in the
114  * &drm_driver structure for drivers that need the virtual address also on
115  * imported buffers.
116  */
117 #define DRM_GEM_CMA_VMAP_DRIVER_OPS \
118         .gem_create_object      = drm_cma_gem_create_object_default_funcs, \
119         .dumb_create            = drm_gem_cma_dumb_create, \
120         .prime_handle_to_fd     = drm_gem_prime_handle_to_fd, \
121         .prime_fd_to_handle     = drm_gem_prime_fd_to_handle, \
122         .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, \
123         .gem_prime_mmap         = drm_gem_prime_mmap
124 
125 struct drm_gem_object *
126 drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *drm,
127                                        struct dma_buf_attachment *attach,
128                                        struct sg_table *sgt);
129 
130 #endif /* __DRM_GEM_CMA_HELPER_H__ */
131 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp