]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/omapdrm/omap_drv.h
drm/omap: gem: Fix mm_list locking
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / omapdrm / omap_drv.h
1 /*
2 * drivers/gpu/drm/omapdrm/omap_drv.h
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 __OMAP_DRV_H__
21 #define __OMAP_DRV_H__
22
23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/workqueue.h>
26
27 #include <drm/drmP.h>
28 #include <drm/drm_crtc_helper.h>
29 #include <drm/drm_gem.h>
30 #include <drm/omap_drm.h>
31
32 #include "dss/omapdss.h"
33
34 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
35 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
36
37 #define MODULE_NAME "omapdrm"
38
39 struct omap_drm_usergart;
40
41 /* For KMS code that needs to wait for a certain # of IRQs:
42 */
43 struct omap_irq_wait;
44 struct omap_irq_wait * omap_irq_wait_init(struct drm_device *dev,
45 uint32_t irqmask, int count);
46 int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait,
47 unsigned long timeout);
48
49 struct omap_drm_private {
50 uint32_t omaprev;
51
52 const struct dispc_ops *dispc_ops;
53
54 unsigned int num_crtcs;
55 struct drm_crtc *crtcs[8];
56
57 unsigned int num_planes;
58 struct drm_plane *planes[8];
59
60 unsigned int num_encoders;
61 struct drm_encoder *encoders[8];
62
63 unsigned int num_connectors;
64 struct drm_connector *connectors[8];
65
66 struct drm_fb_helper *fbdev;
67
68 struct workqueue_struct *wq;
69
70 /* lock for obj_list below */
71 struct mutex list_lock;
72
73 /* list of GEM objects: */
74 struct list_head obj_list;
75
76 struct omap_drm_usergart *usergart;
77 bool has_dmm;
78
79 /* properties: */
80 struct drm_property *zorder_prop;
81
82 /* irq handling: */
83 spinlock_t wait_lock; /* protects the wait_list */
84 struct list_head wait_list; /* list of omap_irq_wait */
85 uint32_t irq_mask; /* enabled irqs in addition to wait_list */
86 };
87
88
89 #ifdef CONFIG_DEBUG_FS
90 int omap_debugfs_init(struct drm_minor *minor);
91 void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m);
92 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
93 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
94 #endif
95
96 #ifdef CONFIG_PM
97 int omap_gem_resume(struct device *dev);
98 #endif
99
100 int omap_irq_enable_vblank(struct drm_crtc *crtc);
101 void omap_irq_disable_vblank(struct drm_crtc *crtc);
102 void omap_drm_irq_uninstall(struct drm_device *dev);
103 int omap_drm_irq_install(struct drm_device *dev);
104
105 #ifdef CONFIG_DRM_FBDEV_EMULATION
106 struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
107 void omap_fbdev_free(struct drm_device *dev);
108 #else
109 static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
110 {
111 return NULL;
112 }
113 static inline void omap_fbdev_free(struct drm_device *dev)
114 {
115 }
116 #endif
117
118 struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
119 enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
120 void omap_crtc_pre_init(void);
121 void omap_crtc_pre_uninit(void);
122 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
123 struct drm_plane *plane, struct omap_dss_device *dssdev);
124 int omap_crtc_wait_pending(struct drm_crtc *crtc);
125 void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
126 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
127
128 struct drm_plane *omap_plane_init(struct drm_device *dev,
129 int idx, enum drm_plane_type type,
130 u32 possible_crtcs);
131 void omap_plane_install_properties(struct drm_plane *plane,
132 struct drm_mode_object *obj);
133
134 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
135 struct omap_dss_device *dssdev);
136
137 struct drm_connector *omap_connector_init(struct drm_device *dev,
138 int connector_type, struct omap_dss_device *dssdev,
139 struct drm_encoder *encoder);
140 struct drm_encoder *omap_connector_attached_encoder(
141 struct drm_connector *connector);
142 bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
143
144 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
145 struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
146 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
147 const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
148 int omap_framebuffer_pin(struct drm_framebuffer *fb);
149 void omap_framebuffer_unpin(struct drm_framebuffer *fb);
150 void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
151 struct drm_plane_state *state, struct omap_overlay_info *info);
152 struct drm_connector *omap_framebuffer_get_next_connector(
153 struct drm_framebuffer *fb, struct drm_connector *from);
154 bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
155
156 void omap_gem_init(struct drm_device *dev);
157 void omap_gem_deinit(struct drm_device *dev);
158
159 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
160 union omap_gem_size gsize, uint32_t flags);
161 struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
162 struct sg_table *sgt);
163 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
164 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
165 void omap_gem_free_object(struct drm_gem_object *obj);
166 void *omap_gem_vaddr(struct drm_gem_object *obj);
167 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
168 uint32_t handle, uint64_t *offset);
169 int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
170 struct drm_mode_create_dumb *args);
171 int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
172 int omap_gem_mmap_obj(struct drm_gem_object *obj,
173 struct vm_area_struct *vma);
174 int omap_gem_fault(struct vm_fault *vmf);
175 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
176 void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
177 void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
178 enum dma_data_direction dir);
179 int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
180 void omap_gem_unpin(struct drm_gem_object *obj);
181 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
182 bool remap);
183 int omap_gem_put_pages(struct drm_gem_object *obj);
184 uint32_t omap_gem_flags(struct drm_gem_object *obj);
185 int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
186 int x, int y, dma_addr_t *dma_addr);
187 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
188 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
189 int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
190
191 struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
192 struct drm_gem_object *obj, int flags);
193 struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
194 struct dma_buf *buffer);
195
196 /* map crtc to vblank mask */
197 struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder);
198
199 #endif /* __OMAP_DRV_H__ */