1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef VMWGFX_KMS_H_
29#define VMWGFX_KMS_H_
30
31#include <drm/drmP.h>
32#include <drm/drm_crtc_helper.h>
33#include <drm/drm_encoder.h>
34#include "vmwgfx_drv.h"
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65struct vmw_kms_dirty {
66 void (*fifo_commit)(struct vmw_kms_dirty *);
67 void (*clip)(struct vmw_kms_dirty *);
68 size_t fifo_reserve_size;
69 struct vmw_private *dev_priv;
70 struct vmw_display_unit *unit;
71 void *cmd;
72 u32 num_hits;
73 s32 fb_x;
74 s32 fb_y;
75 s32 unit_x1;
76 s32 unit_y1;
77 s32 unit_x2;
78 s32 unit_y2;
79};
80
81#define VMWGFX_NUM_DISPLAY_UNITS 8
82
83
84#define vmw_framebuffer_to_vfb(x) \
85 container_of(x, struct vmw_framebuffer, base)
86#define vmw_framebuffer_to_vfbs(x) \
87 container_of(x, struct vmw_framebuffer_surface, base.base)
88#define vmw_framebuffer_to_vfbd(x) \
89 container_of(x, struct vmw_framebuffer_dmabuf, base.base)
90
91
92
93
94
95
96
97struct vmw_framebuffer {
98 struct drm_framebuffer base;
99 int (*pin)(struct vmw_framebuffer *fb);
100 int (*unpin)(struct vmw_framebuffer *fb);
101 bool dmabuf;
102 struct ttm_base_object *user_obj;
103 uint32_t user_handle;
104};
105
106
107
108
109struct vmw_clip_rect {
110 int x1, x2, y1, y2;
111};
112
113struct vmw_framebuffer_surface {
114 struct vmw_framebuffer base;
115 struct vmw_surface *surface;
116 struct vmw_dma_buffer *buffer;
117 struct list_head head;
118 bool is_dmabuf_proxy;
119};
120
121
122struct vmw_framebuffer_dmabuf {
123 struct vmw_framebuffer base;
124 struct vmw_dma_buffer *buffer;
125};
126
127
128
129
130
131int vmw_cursor_update_image(struct vmw_private *dev_priv,
132 u32 *image, u32 width, u32 height,
133 u32 hotspotX, u32 hotspotY);
134int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
135 struct vmw_dma_buffer *dmabuf,
136 u32 width, u32 height,
137 u32 hotspotX, u32 hotspotY);
138void vmw_cursor_update_position(struct vmw_private *dev_priv,
139 bool show, int x, int y);
140
141
142
143
144
145
146
147
148
149struct vmw_display_unit {
150 struct drm_crtc crtc;
151 struct drm_encoder encoder;
152 struct drm_connector connector;
153
154 struct vmw_surface *cursor_surface;
155 struct vmw_dma_buffer *cursor_dmabuf;
156 size_t cursor_age;
157
158 int cursor_x;
159 int cursor_y;
160
161 int hotspot_x;
162 int hotspot_y;
163 s32 core_hotspot_x;
164 s32 core_hotspot_y;
165
166 unsigned unit;
167
168
169
170
171 unsigned pref_width;
172 unsigned pref_height;
173 bool pref_active;
174 struct drm_display_mode *pref_mode;
175
176
177
178
179 int gui_x;
180 int gui_y;
181 bool is_implicit;
182 bool active_implicit;
183 int set_gui_x;
184 int set_gui_y;
185};
186
187#define vmw_crtc_to_du(x) \
188 container_of(x, struct vmw_display_unit, crtc)
189#define vmw_connector_to_du(x) \
190 container_of(x, struct vmw_display_unit, connector)
191
192
193
194
195
196void vmw_du_cleanup(struct vmw_display_unit *du);
197void vmw_du_crtc_save(struct drm_crtc *crtc);
198void vmw_du_crtc_restore(struct drm_crtc *crtc);
199int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
200 u16 *r, u16 *g, u16 *b,
201 uint32_t size);
202int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
203 uint32_t handle, uint32_t width, uint32_t height,
204 int32_t hot_x, int32_t hot_y);
205int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
206int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
207void vmw_du_connector_save(struct drm_connector *connector);
208void vmw_du_connector_restore(struct drm_connector *connector);
209enum drm_connector_status
210vmw_du_connector_detect(struct drm_connector *connector, bool force);
211int vmw_du_connector_fill_modes(struct drm_connector *connector,
212 uint32_t max_width, uint32_t max_height);
213int vmw_du_connector_set_property(struct drm_connector *connector,
214 struct drm_property *property,
215 uint64_t val);
216int vmw_kms_helper_dirty(struct vmw_private *dev_priv,
217 struct vmw_framebuffer *framebuffer,
218 const struct drm_clip_rect *clips,
219 const struct drm_vmw_rect *vclips,
220 s32 dest_x, s32 dest_y,
221 int num_clips,
222 int increment,
223 struct vmw_kms_dirty *dirty);
224
225int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv,
226 struct vmw_dma_buffer *buf,
227 bool interruptible,
228 bool validate_as_mob);
229void vmw_kms_helper_buffer_revert(struct vmw_dma_buffer *buf);
230void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv,
231 struct drm_file *file_priv,
232 struct vmw_dma_buffer *buf,
233 struct vmw_fence_obj **out_fence,
234 struct drm_vmw_fence_rep __user *
235 user_fence_rep);
236int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
237 bool interruptible);
238void vmw_kms_helper_resource_revert(struct vmw_resource *res);
239void vmw_kms_helper_resource_finish(struct vmw_resource *res,
240 struct vmw_fence_obj **out_fence);
241int vmw_kms_readback(struct vmw_private *dev_priv,
242 struct drm_file *file_priv,
243 struct vmw_framebuffer *vfb,
244 struct drm_vmw_fence_rep __user *user_fence_rep,
245 struct drm_vmw_rect *vclips,
246 uint32_t num_clips);
247struct vmw_framebuffer *
248vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
249 struct vmw_dma_buffer *dmabuf,
250 struct vmw_surface *surface,
251 bool only_2d,
252 const struct drm_mode_fb_cmd2 *mode_cmd);
253int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
254 unsigned unit,
255 u32 max_width,
256 u32 max_height,
257 struct drm_connector **p_con,
258 struct drm_crtc **p_crtc,
259 struct drm_display_mode **p_mode);
260void vmw_guess_mode_timing(struct drm_display_mode *mode);
261void vmw_kms_del_active(struct vmw_private *dev_priv,
262 struct vmw_display_unit *du);
263void vmw_kms_add_active(struct vmw_private *dev_priv,
264 struct vmw_display_unit *du,
265 struct vmw_framebuffer *vfb);
266bool vmw_kms_crtc_flippable(struct vmw_private *dev_priv,
267 struct drm_crtc *crtc);
268void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv,
269 struct drm_crtc *crtc);
270void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv,
271 bool immutable);
272
273
274
275
276
277int vmw_kms_ldu_init_display(struct vmw_private *dev_priv);
278int vmw_kms_ldu_close_display(struct vmw_private *dev_priv);
279int vmw_kms_ldu_do_dmabuf_dirty(struct vmw_private *dev_priv,
280 struct vmw_framebuffer *framebuffer,
281 unsigned flags, unsigned color,
282 struct drm_clip_rect *clips,
283 unsigned num_clips, int increment);
284int vmw_kms_update_proxy(struct vmw_resource *res,
285 const struct drm_clip_rect *clips,
286 unsigned num_clips,
287 int increment);
288
289
290
291
292int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
293int vmw_kms_sou_close_display(struct vmw_private *dev_priv);
294int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
295 struct vmw_framebuffer *framebuffer,
296 struct drm_clip_rect *clips,
297 struct drm_vmw_rect *vclips,
298 struct vmw_resource *srf,
299 s32 dest_x,
300 s32 dest_y,
301 unsigned num_clips, int inc,
302 struct vmw_fence_obj **out_fence);
303int vmw_kms_sou_do_dmabuf_dirty(struct vmw_private *dev_priv,
304 struct vmw_framebuffer *framebuffer,
305 struct drm_clip_rect *clips,
306 struct drm_vmw_rect *vclips,
307 unsigned num_clips, int increment,
308 bool interruptible,
309 struct vmw_fence_obj **out_fence);
310int vmw_kms_sou_readback(struct vmw_private *dev_priv,
311 struct drm_file *file_priv,
312 struct vmw_framebuffer *vfb,
313 struct drm_vmw_fence_rep __user *user_fence_rep,
314 struct drm_vmw_rect *vclips,
315 uint32_t num_clips);
316
317
318
319
320int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
321int vmw_kms_stdu_close_display(struct vmw_private *dev_priv);
322int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
323 struct vmw_framebuffer *framebuffer,
324 struct drm_clip_rect *clips,
325 struct drm_vmw_rect *vclips,
326 struct vmw_resource *srf,
327 s32 dest_x,
328 s32 dest_y,
329 unsigned num_clips, int inc,
330 struct vmw_fence_obj **out_fence);
331int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
332 struct drm_file *file_priv,
333 struct vmw_framebuffer *vfb,
334 struct drm_vmw_fence_rep __user *user_fence_rep,
335 struct drm_clip_rect *clips,
336 struct drm_vmw_rect *vclips,
337 uint32_t num_clips,
338 int increment,
339 bool to_surface,
340 bool interruptible);
341
342
343#endif
344