xref: /openbmc/linux/drivers/gpu/drm/omapdrm/omap_gem.h (revision f87deada)
1 /*
2  * omap_gem.h -- OMAP DRM GEM Object Management
3  *
4  * Copyright (C) 2011 Texas Instruments
5  * Author: Rob Clark <rob@ti.com>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __OMAPDRM_GEM_H__
21 #define __OMAPDRM_GEM_H__
22 
23 #include <linux/types.h>
24 
25 enum dma_data_direction;
26 
27 struct dma_buf;
28 struct drm_device;
29 struct drm_file;
30 struct drm_gem_object;
31 struct drm_mode_create_dumb;
32 struct file;
33 struct list_head;
34 struct page;
35 struct seq_file;
36 struct vm_area_struct;
37 struct vm_fault;
38 
39 union omap_gem_size;
40 
41 /* Initialization and Cleanup */
42 void omap_gem_init(struct drm_device *dev);
43 void omap_gem_deinit(struct drm_device *dev);
44 
45 #ifdef CONFIG_PM
46 int omap_gem_resume(struct drm_device *dev);
47 #endif
48 
49 #ifdef CONFIG_DEBUG_FS
50 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
51 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
52 #endif
53 
54 /* GEM Object Creation and Deletion */
55 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
56 		union omap_gem_size gsize, uint32_t flags);
57 struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
58 		struct sg_table *sgt);
59 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
60 		union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
61 void omap_gem_free_object(struct drm_gem_object *obj);
62 void *omap_gem_vaddr(struct drm_gem_object *obj);
63 
64 /* Dumb Buffers Interface */
65 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
66 		uint32_t handle, uint64_t *offset);
67 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
68 		struct drm_mode_create_dumb *args);
69 
70 /* mmap() Interface */
71 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
72 int omap_gem_mmap_obj(struct drm_gem_object *obj,
73 		struct vm_area_struct *vma);
74 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
75 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
76 
77 /* PRIME Interface */
78 struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
79 		struct drm_gem_object *obj, int flags);
80 struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
81 		struct dma_buf *buffer);
82 
83 int omap_gem_fault(struct vm_fault *vmf);
84 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
85 void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
86 void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
87 		enum dma_data_direction dir);
88 int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
89 void omap_gem_unpin(struct drm_gem_object *obj);
90 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
91 		bool remap);
92 int omap_gem_put_pages(struct drm_gem_object *obj);
93 
94 uint32_t omap_gem_flags(struct drm_gem_object *obj);
95 int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
96 		int x, int y, dma_addr_t *dma_addr);
97 int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
98 
99 #endif /* __OMAPDRM_GEM_H__ */
100