This source file includes following definitions.
- vmw_du_translate_to_crtc
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/drm_encoder.h>
32 #include <drm/drm_probe_helper.h>
33
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 struct vmw_du_update_plane {
55
56
57
58
59
60
61
62
63
64 uint32_t (*calc_fifo_size)(struct vmw_du_update_plane *update,
65 uint32_t num_hits);
66
67
68
69
70
71
72
73
74
75
76
77
78
79 uint32_t (*post_prepare)(struct vmw_du_update_plane *update, void *cmd);
80
81
82
83
84
85
86
87
88
89
90
91 uint32_t (*pre_clip)(struct vmw_du_update_plane *update, void *cmd,
92 uint32_t num_hits);
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107 uint32_t (*clip)(struct vmw_du_update_plane *update, void *cmd,
108 struct drm_rect *clip, uint32_t src_x, uint32_t src_y);
109
110
111
112
113
114
115
116
117
118 uint32_t (*post_clip)(struct vmw_du_update_plane *update, void *cmd,
119 struct drm_rect *bb);
120
121 struct drm_plane *plane;
122 struct drm_plane_state *old_state;
123 struct vmw_private *dev_priv;
124 struct vmw_display_unit *du;
125 struct vmw_framebuffer *vfb;
126 struct vmw_fence_obj **out_fence;
127 struct mutex *mutex;
128 bool cpu_blit;
129 bool intr;
130 };
131
132
133
134
135
136
137 struct vmw_du_update_plane_surface {
138 struct vmw_du_update_plane base;
139
140 void *cmd_start;
141 };
142
143
144
145
146
147
148
149 struct vmw_du_update_plane_buffer {
150 struct vmw_du_update_plane base;
151 int fb_left, fb_top;
152 };
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 struct vmw_kms_dirty {
185 void (*fifo_commit)(struct vmw_kms_dirty *);
186 void (*clip)(struct vmw_kms_dirty *);
187 size_t fifo_reserve_size;
188 struct vmw_private *dev_priv;
189 struct vmw_display_unit *unit;
190 void *cmd;
191 struct drm_crtc *crtc;
192 u32 num_hits;
193 s32 fb_x;
194 s32 fb_y;
195 s32 unit_x1;
196 s32 unit_y1;
197 s32 unit_x2;
198 s32 unit_y2;
199 };
200
201 #define VMWGFX_NUM_DISPLAY_UNITS 8
202
203
204 #define vmw_framebuffer_to_vfb(x) \
205 container_of(x, struct vmw_framebuffer, base)
206 #define vmw_framebuffer_to_vfbs(x) \
207 container_of(x, struct vmw_framebuffer_surface, base.base)
208 #define vmw_framebuffer_to_vfbd(x) \
209 container_of(x, struct vmw_framebuffer_bo, base.base)
210
211
212
213
214
215
216
217 struct vmw_framebuffer {
218 struct drm_framebuffer base;
219 int (*pin)(struct vmw_framebuffer *fb);
220 int (*unpin)(struct vmw_framebuffer *fb);
221 bool bo;
222 struct ttm_base_object *user_obj;
223 uint32_t user_handle;
224 };
225
226
227
228
229 struct vmw_clip_rect {
230 int x1, x2, y1, y2;
231 };
232
233 struct vmw_framebuffer_surface {
234 struct vmw_framebuffer base;
235 struct vmw_surface *surface;
236 struct vmw_buffer_object *buffer;
237 struct list_head head;
238 bool is_bo_proxy;
239 };
240
241
242 struct vmw_framebuffer_bo {
243 struct vmw_framebuffer base;
244 struct vmw_buffer_object *buffer;
245 };
246
247
248 static const uint32_t vmw_primary_plane_formats[] = {
249 DRM_FORMAT_XRGB1555,
250 DRM_FORMAT_RGB565,
251 DRM_FORMAT_RGB888,
252 DRM_FORMAT_XRGB8888,
253 DRM_FORMAT_ARGB8888,
254 };
255
256 static const uint32_t vmw_cursor_plane_formats[] = {
257 DRM_FORMAT_ARGB8888,
258 };
259
260
261 #define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
262 #define vmw_plane_state_to_vps(x) container_of(x, struct vmw_plane_state, base)
263 #define vmw_connector_state_to_vcs(x) \
264 container_of(x, struct vmw_connector_state, base)
265
266
267
268
269
270
271 struct vmw_crtc_state {
272 struct drm_crtc_state base;
273 };
274
275
276
277
278
279
280
281
282
283
284
285 struct vmw_plane_state {
286 struct drm_plane_state base;
287 struct vmw_surface *surf;
288 struct vmw_buffer_object *bo;
289
290 int content_fb_type;
291 unsigned long bo_size;
292
293 int pinned;
294
295
296 unsigned int cpp;
297 };
298
299
300
301
302
303
304
305
306
307 struct vmw_connector_state {
308 struct drm_connector_state base;
309
310
311
312
313
314
315
316
317 int gui_x;
318
319
320
321
322
323
324
325
326 int gui_y;
327 };
328
329
330
331
332
333
334
335
336 struct vmw_display_unit {
337 struct drm_crtc crtc;
338 struct drm_encoder encoder;
339 struct drm_connector connector;
340 struct drm_plane primary;
341 struct drm_plane cursor;
342
343 struct vmw_surface *cursor_surface;
344 struct vmw_buffer_object *cursor_bo;
345 size_t cursor_age;
346
347 int cursor_x;
348 int cursor_y;
349
350 int hotspot_x;
351 int hotspot_y;
352 s32 core_hotspot_x;
353 s32 core_hotspot_y;
354
355 unsigned unit;
356
357
358
359
360 unsigned pref_width;
361 unsigned pref_height;
362 bool pref_active;
363 struct drm_display_mode *pref_mode;
364
365
366
367
368 int gui_x;
369 int gui_y;
370 bool is_implicit;
371 int set_gui_x;
372 int set_gui_y;
373 };
374
375 struct vmw_validation_ctx {
376 struct vmw_resource *res;
377 struct vmw_buffer_object *buf;
378 };
379
380 #define vmw_crtc_to_du(x) \
381 container_of(x, struct vmw_display_unit, crtc)
382 #define vmw_connector_to_du(x) \
383 container_of(x, struct vmw_display_unit, connector)
384
385
386
387
388
389 void vmw_du_cleanup(struct vmw_display_unit *du);
390 void vmw_du_crtc_save(struct drm_crtc *crtc);
391 void vmw_du_crtc_restore(struct drm_crtc *crtc);
392 int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
393 u16 *r, u16 *g, u16 *b,
394 uint32_t size,
395 struct drm_modeset_acquire_ctx *ctx);
396 int vmw_du_connector_set_property(struct drm_connector *connector,
397 struct drm_property *property,
398 uint64_t val);
399 int vmw_du_connector_atomic_set_property(struct drm_connector *connector,
400 struct drm_connector_state *state,
401 struct drm_property *property,
402 uint64_t val);
403 int
404 vmw_du_connector_atomic_get_property(struct drm_connector *connector,
405 const struct drm_connector_state *state,
406 struct drm_property *property,
407 uint64_t *val);
408 int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
409 void vmw_du_connector_save(struct drm_connector *connector);
410 void vmw_du_connector_restore(struct drm_connector *connector);
411 enum drm_connector_status
412 vmw_du_connector_detect(struct drm_connector *connector, bool force);
413 int vmw_du_connector_fill_modes(struct drm_connector *connector,
414 uint32_t max_width, uint32_t max_height);
415 int vmw_kms_helper_dirty(struct vmw_private *dev_priv,
416 struct vmw_framebuffer *framebuffer,
417 const struct drm_clip_rect *clips,
418 const struct drm_vmw_rect *vclips,
419 s32 dest_x, s32 dest_y,
420 int num_clips,
421 int increment,
422 struct vmw_kms_dirty *dirty);
423
424 void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv,
425 struct drm_file *file_priv,
426 struct vmw_validation_context *ctx,
427 struct vmw_fence_obj **out_fence,
428 struct drm_vmw_fence_rep __user *
429 user_fence_rep);
430 int vmw_kms_readback(struct vmw_private *dev_priv,
431 struct drm_file *file_priv,
432 struct vmw_framebuffer *vfb,
433 struct drm_vmw_fence_rep __user *user_fence_rep,
434 struct drm_vmw_rect *vclips,
435 uint32_t num_clips);
436 struct vmw_framebuffer *
437 vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
438 struct vmw_buffer_object *bo,
439 struct vmw_surface *surface,
440 bool only_2d,
441 const struct drm_mode_fb_cmd2 *mode_cmd);
442 int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
443 unsigned unit,
444 u32 max_width,
445 u32 max_height,
446 struct drm_connector **p_con,
447 struct drm_crtc **p_crtc,
448 struct drm_display_mode **p_mode);
449 void vmw_guess_mode_timing(struct drm_display_mode *mode);
450 void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv);
451 void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv);
452
453
454 void vmw_du_primary_plane_destroy(struct drm_plane *plane);
455 void vmw_du_cursor_plane_destroy(struct drm_plane *plane);
456
457
458 int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
459 struct drm_plane_state *state);
460 int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane,
461 struct drm_plane_state *state);
462 void vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
463 struct drm_plane_state *old_state);
464 int vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,
465 struct drm_plane_state *new_state);
466 void vmw_du_plane_cleanup_fb(struct drm_plane *plane,
467 struct drm_plane_state *old_state);
468 void vmw_du_plane_reset(struct drm_plane *plane);
469 struct drm_plane_state *vmw_du_plane_duplicate_state(struct drm_plane *plane);
470 void vmw_du_plane_destroy_state(struct drm_plane *plane,
471 struct drm_plane_state *state);
472 void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps,
473 bool unreference);
474
475 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
476 struct drm_crtc_state *state);
477 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
478 struct drm_crtc_state *old_crtc_state);
479 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
480 struct drm_crtc_state *old_crtc_state);
481 void vmw_du_crtc_reset(struct drm_crtc *crtc);
482 struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
483 void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
484 struct drm_crtc_state *state);
485 void vmw_du_connector_reset(struct drm_connector *connector);
486 struct drm_connector_state *
487 vmw_du_connector_duplicate_state(struct drm_connector *connector);
488
489 void vmw_du_connector_destroy_state(struct drm_connector *connector,
490 struct drm_connector_state *state);
491
492
493
494
495 int vmw_kms_ldu_init_display(struct vmw_private *dev_priv);
496 int vmw_kms_ldu_close_display(struct vmw_private *dev_priv);
497 int vmw_kms_ldu_do_bo_dirty(struct vmw_private *dev_priv,
498 struct vmw_framebuffer *framebuffer,
499 unsigned int flags, unsigned int color,
500 struct drm_clip_rect *clips,
501 unsigned int num_clips, int increment);
502 int vmw_kms_update_proxy(struct vmw_resource *res,
503 const struct drm_clip_rect *clips,
504 unsigned num_clips,
505 int increment);
506
507
508
509
510 int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
511 int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
512 struct vmw_framebuffer *framebuffer,
513 struct drm_clip_rect *clips,
514 struct drm_vmw_rect *vclips,
515 struct vmw_resource *srf,
516 s32 dest_x,
517 s32 dest_y,
518 unsigned num_clips, int inc,
519 struct vmw_fence_obj **out_fence,
520 struct drm_crtc *crtc);
521 int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,
522 struct vmw_framebuffer *framebuffer,
523 struct drm_clip_rect *clips,
524 struct drm_vmw_rect *vclips,
525 unsigned int num_clips, int increment,
526 bool interruptible,
527 struct vmw_fence_obj **out_fence,
528 struct drm_crtc *crtc);
529 int vmw_kms_sou_readback(struct vmw_private *dev_priv,
530 struct drm_file *file_priv,
531 struct vmw_framebuffer *vfb,
532 struct drm_vmw_fence_rep __user *user_fence_rep,
533 struct drm_vmw_rect *vclips,
534 uint32_t num_clips,
535 struct drm_crtc *crtc);
536
537
538
539
540 int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
541 int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
542 struct vmw_framebuffer *framebuffer,
543 struct drm_clip_rect *clips,
544 struct drm_vmw_rect *vclips,
545 struct vmw_resource *srf,
546 s32 dest_x,
547 s32 dest_y,
548 unsigned num_clips, int inc,
549 struct vmw_fence_obj **out_fence,
550 struct drm_crtc *crtc);
551 int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
552 struct drm_file *file_priv,
553 struct vmw_framebuffer *vfb,
554 struct drm_vmw_fence_rep __user *user_fence_rep,
555 struct drm_clip_rect *clips,
556 struct drm_vmw_rect *vclips,
557 uint32_t num_clips,
558 int increment,
559 bool to_surface,
560 bool interruptible,
561 struct drm_crtc *crtc);
562
563 int vmw_du_helper_plane_update(struct vmw_du_update_plane *update);
564
565
566
567
568
569
570 static inline void vmw_du_translate_to_crtc(struct drm_plane_state *state,
571 struct drm_rect *r)
572 {
573 int translate_crtc_x = -((state->src_x >> 16) - state->crtc_x);
574 int translate_crtc_y = -((state->src_y >> 16) - state->crtc_y);
575
576 drm_rect_translate(r, translate_crtc_x, translate_crtc_y);
577 }
578
579 #endif