xref: /linux/drivers/gpu/drm/omapdrm/omap_gem.h (revision e9f0878c4b2004ac19581274c1ae4c61ae3ca70e)
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 #include <linux/mm_types.h>
25 
26 enum dma_data_direction;
27 
28 struct dma_buf;
29 struct drm_device;
30 struct drm_file;
31 struct drm_gem_object;
32 struct drm_mode_create_dumb;
33 struct file;
34 struct list_head;
35 struct page;
36 struct seq_file;
37 struct vm_area_struct;
38 struct vm_fault;
39 
40 union omap_gem_size;
41 
42 /* Initialization and Cleanup */
43 void omap_gem_init(struct drm_device *dev);
44 void omap_gem_deinit(struct drm_device *dev);
45 
46 #ifdef CONFIG_PM
47 int omap_gem_resume(struct drm_device *dev);
48 #endif
49 
50 #ifdef CONFIG_DEBUG_FS
51 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
52 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
53 #endif
54 
55 /* GEM Object Creation and Deletion */
56 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
57 		union omap_gem_size gsize, u32 flags);
58 struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
59 		struct sg_table *sgt);
60 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
61 		union omap_gem_size gsize, u32 flags, u32 *handle);
62 void omap_gem_free_object(struct drm_gem_object *obj);
63 void *omap_gem_vaddr(struct drm_gem_object *obj);
64 
65 /* Dumb Buffers Interface */
66 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
67 		u32 handle, u64 *offset);
68 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
69 		struct drm_mode_create_dumb *args);
70 
71 /* mmap() Interface */
72 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
73 int omap_gem_mmap_obj(struct drm_gem_object *obj,
74 		struct vm_area_struct *vma);
75 u64 omap_gem_mmap_offset(struct drm_gem_object *obj);
76 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
77 
78 /* PRIME Interface */
79 struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
80 		struct drm_gem_object *obj, int flags);
81 struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
82 		struct dma_buf *buffer);
83 
84 vm_fault_t omap_gem_fault(struct vm_fault *vmf);
85 int omap_gem_roll(struct drm_gem_object *obj, u32 roll);
86 void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
87 void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
88 		enum dma_data_direction dir);
89 int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
90 void omap_gem_unpin(struct drm_gem_object *obj);
91 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
92 		bool remap);
93 int omap_gem_put_pages(struct drm_gem_object *obj);
94 
95 u32 omap_gem_flags(struct drm_gem_object *obj);
96 int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, u32 orient,
97 		int x, int y, dma_addr_t *dma_addr);
98 int omap_gem_tiled_stride(struct drm_gem_object *obj, u32 orient);
99 
100 #endif /* __OMAPDRM_GEM_H__ */
101