btrfs: Do chunk level check for degraded rw mount
[linux/fpc-iii.git] / include / drm / drm_gem_cma_helper.h
blobb42529e0fae0c68d96fb8d947f53bc383236b351
1 #ifndef __DRM_GEM_CMA_HELPER_H__
2 #define __DRM_GEM_CMA_HELPER_H__
4 #include <drm/drmP.h>
5 #include <drm/drm_gem.h>
7 /**
8 * struct drm_gem_cma_object - GEM object backed by CMA memory allocations
9 * @base: base GEM object
10 * @paddr: physical address of the backing memory
11 * @sgt: scatter/gather table for imported PRIME buffers
12 * @vaddr: kernel virtual address of the backing memory
14 struct drm_gem_cma_object {
15 struct drm_gem_object base;
16 dma_addr_t paddr;
17 struct sg_table *sgt;
19 /* For objects with DMA memory allocated by GEM CMA */
20 void *vaddr;
23 static inline struct drm_gem_cma_object *
24 to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
26 return container_of(gem_obj, struct drm_gem_cma_object, base);
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
36 /**
37 * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
38 * @name: name for the generated structure
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.
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.
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 \
63 /* free GEM object */
64 void drm_gem_cma_free_object(struct drm_gem_object *gem_obj);
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);
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);
76 /* map memory region for DRM framebuffer to user space */
77 int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv,
78 struct drm_device *drm, u32 handle,
79 u64 *offset);
81 /* set vm_flags and we can change the VM attribute to other one at here */
82 int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma);
84 /* allocate physical memory */
85 struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
86 size_t size);
88 extern const struct vm_operations_struct drm_gem_cma_vm_ops;
90 #ifndef CONFIG_MMU
91 unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
92 unsigned long addr,
93 unsigned long len,
94 unsigned long pgoff,
95 unsigned long flags);
96 #endif
98 #ifdef CONFIG_DEBUG_FS
99 void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m);
100 #endif
102 struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
103 struct drm_gem_object *
104 drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
105 struct dma_buf_attachment *attach,
106 struct sg_table *sgt);
107 int drm_gem_cma_prime_mmap(struct drm_gem_object *obj,
108 struct vm_area_struct *vma);
109 void *drm_gem_cma_prime_vmap(struct drm_gem_object *obj);
110 void drm_gem_cma_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
112 #endif /* __DRM_GEM_CMA_HELPER_H__ */