Blame view
include/drm/drm_gem_cma_helper.h
7.18 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
b9d474500 DRM: Add DRM GEM ... |
2 3 |
#ifndef __DRM_GEM_CMA_HELPER_H__ #define __DRM_GEM_CMA_HELPER_H__ |
785cabaae drm: remove drmP.... |
4 5 |
#include <drm/drm_file.h> #include <drm/drm_ioctl.h> |
d9fc9413f drm: Extract <drm... |
6 |
#include <drm/drm_gem.h> |
740c22ae5 drm/cma: include ... |
7 |
|
785cabaae drm: remove drmP.... |
8 |
struct drm_mode_create_dumb; |
d7883f875 drm/doc: Add GEM/... |
9 10 11 12 |
/** * struct drm_gem_cma_object - GEM object backed by CMA memory allocations * @base: base GEM object * @paddr: physical address of the backing memory |
998fb1a0f drm: gem_cma_help... |
13 14 15 |
* @sgt: scatter/gather table for imported PRIME buffers. The table can have * more than one entry but they are guaranteed to have contiguous * DMA addresses. |
d7883f875 drm/doc: Add GEM/... |
16 17 |
* @vaddr: kernel virtual address of the backing memory */ |
b9d474500 DRM: Add DRM GEM ... |
18 19 20 |
struct drm_gem_cma_object { struct drm_gem_object base; dma_addr_t paddr; |
71d7282a0 drm: GEM CMA: Add... |
21 22 23 |
struct sg_table *sgt; /* For objects with DMA memory allocated by GEM CMA */ |
b9d474500 DRM: Add DRM GEM ... |
24 25 |
void *vaddr; }; |
8d25ccebe drm/cma-helper: T... |
26 27 |
#define to_drm_gem_cma_obj(gem_obj) \ container_of(gem_obj, struct drm_gem_cma_object, base) |
b9d474500 DRM: Add DRM GEM ... |
28 |
|
75cccac40 drm/cma: Fix rece... |
29 30 31 32 33 34 |
#ifndef CONFIG_MMU #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \ .get_unmapped_area = drm_gem_cma_get_unmapped_area, #else #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS #endif |
d55f7e5d5 drm: Create DEFIN... |
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
/** * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers * @name: name for the generated structure * * This macro autogenerates a suitable &struct file_operations for CMA based * drivers, which can be assigned to &drm_driver.fops. Note that this structure * cannot be shared between drivers, because it contains a reference to the * current module using THIS_MODULE. * * Note that the declaration is already marked as static - if you need a * non-static version of this you're probably doing it wrong and will break the * THIS_MODULE reference by accident. */ #define DEFINE_DRM_GEM_CMA_FOPS(name) \ static const struct file_operations name = {\ .owner = THIS_MODULE,\ .open = drm_open,\ .release = drm_release,\ .unlocked_ioctl = drm_ioctl,\ .compat_ioctl = drm_compat_ioctl,\ .poll = drm_poll,\ .read = drm_read,\ .llseek = noop_llseek,\ .mmap = drm_gem_cma_mmap,\ |
75cccac40 drm/cma: Fix rece... |
59 |
DRM_GEM_CMA_UNMAPPED_AREA_FOPS \ |
d55f7e5d5 drm: Create DEFIN... |
60 |
} |
d7883f875 drm/doc: Add GEM/... |
61 |
/* free GEM object */ |
b9d474500 DRM: Add DRM GEM ... |
62 |
void drm_gem_cma_free_object(struct drm_gem_object *gem_obj); |
d7883f875 drm/doc: Add GEM/... |
63 |
/* create memory region for DRM framebuffer */ |
6d1782919 drm/cma: Introduc... |
64 65 66 67 68 |
int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, struct drm_device *drm, struct drm_mode_create_dumb *args); /* create memory region for DRM framebuffer */ |
b9d474500 DRM: Add DRM GEM ... |
69 |
int drm_gem_cma_dumb_create(struct drm_file *file_priv, |
d7883f875 drm/doc: Add GEM/... |
70 71 |
struct drm_device *drm, struct drm_mode_create_dumb *args); |
b9d474500 DRM: Add DRM GEM ... |
72 |
|
d7883f875 drm/doc: Add GEM/... |
73 |
/* set vm_flags and we can change the VM attribute to other one at here */ |
b9d474500 DRM: Add DRM GEM ... |
74 |
int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma); |
d7883f875 drm/doc: Add GEM/... |
75 |
/* allocate physical memory */ |
b9d474500 DRM: Add DRM GEM ... |
76 |
struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, |
d7883f875 drm/doc: Add GEM/... |
77 |
size_t size); |
b9d474500 DRM: Add DRM GEM ... |
78 79 |
extern const struct vm_operations_struct drm_gem_cma_vm_ops; |
62a0d98a1 drm: allow to use... |
80 81 82 83 84 85 |
#ifndef CONFIG_MMU unsigned long drm_gem_cma_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); |
62a0d98a1 drm: allow to use... |
86 |
#endif |
d68920120 drm/cma-helper: A... |
87 88 |
void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent, const struct drm_gem_object *obj); |
6f646095e drm/cma: add debu... |
89 |
|
78467dc5f drm/cma: add low-... |
90 91 |
struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj); struct drm_gem_object * |
b5e9c1a25 drm: Pass dma-buf... |
92 93 |
drm_gem_cma_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, |
78467dc5f drm/cma: add low-... |
94 95 96 97 98 |
struct sg_table *sgt); int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj); void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr); |
b9068cde5 drm/cma-helper: A... |
99 |
struct drm_gem_object * |
26eb603b5 drm/cma-helper: R... |
100 |
drm_gem_cma_create_object_default_funcs(struct drm_device *dev, size_t size); |
b9068cde5 drm/cma-helper: A... |
101 102 |
/** |
654bf12ba drm/cma-helper: A... |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
* DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE - CMA GEM driver operations * @dumb_create_func: callback function for .dumb_create * * This macro provides a shortcut for setting the default GEM operations in the * &drm_driver structure. * * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS for drivers that * override the default implementation of &struct rm_driver.dumb_create. Use * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address * on imported buffers should use * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead. */ #define DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(dumb_create_func) \ .gem_create_object = drm_gem_cma_create_object_default_funcs, \ .dumb_create = (dumb_create_func), \ .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, \ .gem_prime_mmap = drm_gem_cma_prime_mmap /** * DRM_GEM_CMA_DRIVER_OPS - CMA GEM driver operations * * This macro provides a shortcut for setting the default GEM operations in the * &drm_driver structure. * * Drivers that come with their own implementation of * &struct drm_driver.dumb_create should use * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead. Use * DRM_GEM_CMA_DRIVER_OPS if possible. Drivers that require a virtual address * on imported buffers should use DRM_GEM_CMA_DRIVER_OPS_VMAP instead. */ #define DRM_GEM_CMA_DRIVER_OPS \ DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(drm_gem_cma_dumb_create) /** |
06d662016 drm/cma-helper: R... |
139 140 141 142 |
* DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE - CMA GEM driver operations * ensuring a virtual address * on the buffer * @dumb_create_func: callback function for .dumb_create |
b9068cde5 drm/cma-helper: A... |
143 144 145 146 |
* * This macro provides a shortcut for setting the default GEM operations in the * &drm_driver structure for drivers that need the virtual address also on * imported buffers. |
06d662016 drm/cma-helper: R... |
147 148 |
* * This macro is a variant of DRM_GEM_CMA_DRIVER_OPS_VMAP for drivers that |
654bf12ba drm/cma-helper: A... |
149 150 151 152 |
* override the default implementation of &struct drm_driver.dumb_create. Use * DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a * virtual address on imported buffers should use * DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE() instead. |
b9068cde5 drm/cma-helper: A... |
153 |
*/ |
06d662016 drm/cma-helper: R... |
154 |
#define DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(dumb_create_func) \ |
26eb603b5 drm/cma-helper: R... |
155 |
.gem_create_object = drm_gem_cma_create_object_default_funcs, \ |
654bf12ba drm/cma-helper: A... |
156 |
.dumb_create = dumb_create_func, \ |
b9068cde5 drm/cma-helper: A... |
157 158 159 160 |
.prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, \ .gem_prime_mmap = drm_gem_prime_mmap |
06d662016 drm/cma-helper: R... |
161 162 163 164 165 166 167 168 169 170 171 |
/** * DRM_GEM_CMA_DRIVER_OPS_VMAP - CMA GEM driver operations ensuring a virtual * address on the buffer * * This macro provides a shortcut for setting the default GEM operations in the * &drm_driver structure for drivers that need the virtual address also on * imported buffers. * * Drivers that come with their own implementation of * &struct drm_driver.dumb_create should use * DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE() instead. Use |
654bf12ba drm/cma-helper: A... |
172 173 174 |
* DRM_GEM_CMA_DRIVER_OPS_VMAP if possible. Drivers that do not require a * virtual address on imported buffers should use DRM_GEM_CMA_DRIVER_OPS * instead. |
06d662016 drm/cma-helper: R... |
175 176 177 |
*/ #define DRM_GEM_CMA_DRIVER_OPS_VMAP \ DRM_GEM_CMA_DRIVER_OPS_VMAP_WITH_DUMB_CREATE(drm_gem_cma_dumb_create) |
b9068cde5 drm/cma-helper: A... |
178 179 180 181 |
struct drm_gem_object * drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *drm, struct dma_buf_attachment *attach, struct sg_table *sgt); |
b9d474500 DRM: Add DRM GEM ... |
182 |
#endif /* __DRM_GEM_CMA_HELPER_H__ */ |