0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef VMWGFX_KMS_H_
0029 #define VMWGFX_KMS_H_
0030
0031 #include <drm/drm_encoder.h>
0032 #include <drm/drm_framebuffer.h>
0033 #include <drm/drm_probe_helper.h>
0034
0035 #include "vmwgfx_drv.h"
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 struct vmw_du_update_plane {
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 uint32_t (*calc_fifo_size)(struct vmw_du_update_plane *update,
0066 uint32_t num_hits);
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 uint32_t (*post_prepare)(struct vmw_du_update_plane *update, void *cmd);
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 uint32_t (*pre_clip)(struct vmw_du_update_plane *update, void *cmd,
0093 uint32_t num_hits);
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108 uint32_t (*clip)(struct vmw_du_update_plane *update, void *cmd,
0109 struct drm_rect *clip, uint32_t src_x, uint32_t src_y);
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 uint32_t (*post_clip)(struct vmw_du_update_plane *update, void *cmd,
0120 struct drm_rect *bb);
0121
0122 struct drm_plane *plane;
0123 struct drm_plane_state *old_state;
0124 struct vmw_private *dev_priv;
0125 struct vmw_display_unit *du;
0126 struct vmw_framebuffer *vfb;
0127 struct vmw_fence_obj **out_fence;
0128 struct mutex *mutex;
0129 bool cpu_blit;
0130 bool intr;
0131 };
0132
0133
0134
0135
0136
0137
0138 struct vmw_du_update_plane_surface {
0139 struct vmw_du_update_plane base;
0140
0141 void *cmd_start;
0142 };
0143
0144
0145
0146
0147
0148
0149
0150 struct vmw_du_update_plane_buffer {
0151 struct vmw_du_update_plane base;
0152 int fb_left, fb_top;
0153 };
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185 struct vmw_kms_dirty {
0186 void (*fifo_commit)(struct vmw_kms_dirty *);
0187 void (*clip)(struct vmw_kms_dirty *);
0188 size_t fifo_reserve_size;
0189 struct vmw_private *dev_priv;
0190 struct vmw_display_unit *unit;
0191 void *cmd;
0192 struct drm_crtc *crtc;
0193 u32 num_hits;
0194 s32 fb_x;
0195 s32 fb_y;
0196 s32 unit_x1;
0197 s32 unit_y1;
0198 s32 unit_x2;
0199 s32 unit_y2;
0200 };
0201
0202 #define VMWGFX_NUM_DISPLAY_UNITS 8
0203
0204
0205 #define vmw_framebuffer_to_vfb(x) \
0206 container_of(x, struct vmw_framebuffer, base)
0207 #define vmw_framebuffer_to_vfbs(x) \
0208 container_of(x, struct vmw_framebuffer_surface, base.base)
0209 #define vmw_framebuffer_to_vfbd(x) \
0210 container_of(x, struct vmw_framebuffer_bo, base.base)
0211
0212
0213
0214
0215
0216
0217
0218 struct vmw_framebuffer {
0219 struct drm_framebuffer base;
0220 int (*pin)(struct vmw_framebuffer *fb);
0221 int (*unpin)(struct vmw_framebuffer *fb);
0222 bool bo;
0223 uint32_t user_handle;
0224 };
0225
0226
0227
0228
0229 struct vmw_clip_rect {
0230 int x1, x2, y1, y2;
0231 };
0232
0233 struct vmw_framebuffer_surface {
0234 struct vmw_framebuffer base;
0235 struct vmw_surface *surface;
0236 struct vmw_buffer_object *buffer;
0237 struct list_head head;
0238 bool is_bo_proxy;
0239 };
0240
0241
0242 struct vmw_framebuffer_bo {
0243 struct vmw_framebuffer base;
0244 struct vmw_buffer_object *buffer;
0245 };
0246
0247
0248 static const uint32_t __maybe_unused vmw_primary_plane_formats[] = {
0249 DRM_FORMAT_XRGB1555,
0250 DRM_FORMAT_RGB565,
0251 DRM_FORMAT_XRGB8888,
0252 DRM_FORMAT_ARGB8888,
0253 };
0254
0255 static const uint32_t __maybe_unused vmw_cursor_plane_formats[] = {
0256 DRM_FORMAT_ARGB8888,
0257 };
0258
0259
0260 #define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
0261 #define vmw_plane_state_to_vps(x) container_of(x, struct vmw_plane_state, base)
0262 #define vmw_connector_state_to_vcs(x) \
0263 container_of(x, struct vmw_connector_state, base)
0264 #define vmw_plane_to_vcp(x) container_of(x, struct vmw_cursor_plane, base)
0265
0266
0267
0268
0269
0270
0271 struct vmw_crtc_state {
0272 struct drm_crtc_state base;
0273 };
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285 struct vmw_plane_state {
0286 struct drm_plane_state base;
0287 struct vmw_surface *surf;
0288 struct vmw_buffer_object *bo;
0289
0290 int content_fb_type;
0291 unsigned long bo_size;
0292
0293 int pinned;
0294
0295
0296 unsigned int cpp;
0297
0298
0299 unsigned int cursor_mob_idx;
0300
0301 struct ttm_buffer_object *cm_bo;
0302
0303
0304 struct ttm_bo_kmap_obj cm_map;
0305 };
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 struct vmw_connector_state {
0316 struct drm_connector_state base;
0317
0318
0319
0320
0321
0322
0323
0324
0325 int gui_x;
0326
0327
0328
0329
0330
0331
0332
0333
0334 int gui_y;
0335 };
0336
0337
0338
0339
0340
0341
0342
0343 struct vmw_cursor_plane {
0344 struct drm_plane base;
0345 struct ttm_buffer_object *cursor_mob[2];
0346 };
0347
0348
0349
0350
0351
0352
0353
0354
0355 struct vmw_display_unit {
0356 struct drm_crtc crtc;
0357 struct drm_encoder encoder;
0358 struct drm_connector connector;
0359 struct drm_plane primary;
0360 struct vmw_cursor_plane cursor;
0361
0362 struct vmw_surface *cursor_surface;
0363 struct vmw_buffer_object *cursor_bo;
0364 size_t cursor_age;
0365
0366 int cursor_x;
0367 int cursor_y;
0368
0369 int hotspot_x;
0370 int hotspot_y;
0371 s32 core_hotspot_x;
0372 s32 core_hotspot_y;
0373
0374 unsigned unit;
0375
0376
0377
0378
0379 unsigned pref_width;
0380 unsigned pref_height;
0381 bool pref_active;
0382 struct drm_display_mode *pref_mode;
0383
0384
0385
0386
0387 int gui_x;
0388 int gui_y;
0389 bool is_implicit;
0390 int set_gui_x;
0391 int set_gui_y;
0392 };
0393
0394 struct vmw_validation_ctx {
0395 struct vmw_resource *res;
0396 struct vmw_buffer_object *buf;
0397 };
0398
0399 #define vmw_crtc_to_du(x) \
0400 container_of(x, struct vmw_display_unit, crtc)
0401 #define vmw_connector_to_du(x) \
0402 container_of(x, struct vmw_display_unit, connector)
0403
0404
0405
0406
0407
0408 void vmw_du_cleanup(struct vmw_display_unit *du);
0409 void vmw_du_crtc_save(struct drm_crtc *crtc);
0410 void vmw_du_crtc_restore(struct drm_crtc *crtc);
0411 int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
0412 u16 *r, u16 *g, u16 *b,
0413 uint32_t size,
0414 struct drm_modeset_acquire_ctx *ctx);
0415 int vmw_du_connector_set_property(struct drm_connector *connector,
0416 struct drm_property *property,
0417 uint64_t val);
0418 int vmw_du_connector_atomic_set_property(struct drm_connector *connector,
0419 struct drm_connector_state *state,
0420 struct drm_property *property,
0421 uint64_t val);
0422 int
0423 vmw_du_connector_atomic_get_property(struct drm_connector *connector,
0424 const struct drm_connector_state *state,
0425 struct drm_property *property,
0426 uint64_t *val);
0427 int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
0428 void vmw_du_connector_save(struct drm_connector *connector);
0429 void vmw_du_connector_restore(struct drm_connector *connector);
0430 enum drm_connector_status
0431 vmw_du_connector_detect(struct drm_connector *connector, bool force);
0432 int vmw_du_connector_fill_modes(struct drm_connector *connector,
0433 uint32_t max_width, uint32_t max_height);
0434 int vmw_kms_helper_dirty(struct vmw_private *dev_priv,
0435 struct vmw_framebuffer *framebuffer,
0436 const struct drm_clip_rect *clips,
0437 const struct drm_vmw_rect *vclips,
0438 s32 dest_x, s32 dest_y,
0439 int num_clips,
0440 int increment,
0441 struct vmw_kms_dirty *dirty);
0442
0443 void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv,
0444 struct drm_file *file_priv,
0445 struct vmw_validation_context *ctx,
0446 struct vmw_fence_obj **out_fence,
0447 struct drm_vmw_fence_rep __user *
0448 user_fence_rep);
0449 int vmw_kms_readback(struct vmw_private *dev_priv,
0450 struct drm_file *file_priv,
0451 struct vmw_framebuffer *vfb,
0452 struct drm_vmw_fence_rep __user *user_fence_rep,
0453 struct drm_vmw_rect *vclips,
0454 uint32_t num_clips);
0455 struct vmw_framebuffer *
0456 vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
0457 struct vmw_buffer_object *bo,
0458 struct vmw_surface *surface,
0459 bool only_2d,
0460 const struct drm_mode_fb_cmd2 *mode_cmd);
0461 int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
0462 unsigned unit,
0463 u32 max_width,
0464 u32 max_height,
0465 struct drm_connector **p_con,
0466 struct drm_crtc **p_crtc,
0467 struct drm_display_mode **p_mode);
0468 void vmw_guess_mode_timing(struct drm_display_mode *mode);
0469 void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv);
0470 void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv);
0471
0472
0473 void vmw_du_primary_plane_destroy(struct drm_plane *plane);
0474 void vmw_du_cursor_plane_destroy(struct drm_plane *plane);
0475 int vmw_du_create_cursor_mob_array(struct vmw_cursor_plane *vcp);
0476 void vmw_du_destroy_cursor_mob_array(struct vmw_cursor_plane *vcp);
0477
0478
0479 int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
0480 struct drm_atomic_state *state);
0481 int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane,
0482 struct drm_atomic_state *state);
0483 void vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
0484 struct drm_atomic_state *state);
0485 int vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,
0486 struct drm_plane_state *new_state);
0487 void vmw_du_cursor_plane_cleanup_fb(struct drm_plane *plane,
0488 struct drm_plane_state *old_state);
0489 void vmw_du_plane_cleanup_fb(struct drm_plane *plane,
0490 struct drm_plane_state *old_state);
0491 void vmw_du_plane_reset(struct drm_plane *plane);
0492 struct drm_plane_state *vmw_du_plane_duplicate_state(struct drm_plane *plane);
0493 void vmw_du_plane_destroy_state(struct drm_plane *plane,
0494 struct drm_plane_state *state);
0495 void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps,
0496 bool unreference);
0497
0498 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
0499 struct drm_atomic_state *state);
0500 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
0501 struct drm_atomic_state *state);
0502 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
0503 struct drm_atomic_state *state);
0504 void vmw_du_crtc_reset(struct drm_crtc *crtc);
0505 struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
0506 void vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
0507 struct drm_crtc_state *state);
0508 void vmw_du_connector_reset(struct drm_connector *connector);
0509 struct drm_connector_state *
0510 vmw_du_connector_duplicate_state(struct drm_connector *connector);
0511
0512 void vmw_du_connector_destroy_state(struct drm_connector *connector,
0513 struct drm_connector_state *state);
0514
0515
0516
0517
0518 int vmw_kms_ldu_init_display(struct vmw_private *dev_priv);
0519 int vmw_kms_ldu_close_display(struct vmw_private *dev_priv);
0520 int vmw_kms_ldu_do_bo_dirty(struct vmw_private *dev_priv,
0521 struct vmw_framebuffer *framebuffer,
0522 unsigned int flags, unsigned int color,
0523 struct drm_clip_rect *clips,
0524 unsigned int num_clips, int increment);
0525 int vmw_kms_update_proxy(struct vmw_resource *res,
0526 const struct drm_clip_rect *clips,
0527 unsigned num_clips,
0528 int increment);
0529
0530
0531
0532
0533 int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
0534 int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
0535 struct vmw_framebuffer *framebuffer,
0536 struct drm_clip_rect *clips,
0537 struct drm_vmw_rect *vclips,
0538 struct vmw_resource *srf,
0539 s32 dest_x,
0540 s32 dest_y,
0541 unsigned num_clips, int inc,
0542 struct vmw_fence_obj **out_fence,
0543 struct drm_crtc *crtc);
0544 int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv,
0545 struct vmw_framebuffer *framebuffer,
0546 struct drm_clip_rect *clips,
0547 struct drm_vmw_rect *vclips,
0548 unsigned int num_clips, int increment,
0549 bool interruptible,
0550 struct vmw_fence_obj **out_fence,
0551 struct drm_crtc *crtc);
0552 int vmw_kms_sou_readback(struct vmw_private *dev_priv,
0553 struct drm_file *file_priv,
0554 struct vmw_framebuffer *vfb,
0555 struct drm_vmw_fence_rep __user *user_fence_rep,
0556 struct drm_vmw_rect *vclips,
0557 uint32_t num_clips,
0558 struct drm_crtc *crtc);
0559
0560
0561
0562
0563 int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
0564 int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
0565 struct vmw_framebuffer *framebuffer,
0566 struct drm_clip_rect *clips,
0567 struct drm_vmw_rect *vclips,
0568 struct vmw_resource *srf,
0569 s32 dest_x,
0570 s32 dest_y,
0571 unsigned num_clips, int inc,
0572 struct vmw_fence_obj **out_fence,
0573 struct drm_crtc *crtc);
0574 int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
0575 struct drm_file *file_priv,
0576 struct vmw_framebuffer *vfb,
0577 struct drm_vmw_fence_rep __user *user_fence_rep,
0578 struct drm_clip_rect *clips,
0579 struct drm_vmw_rect *vclips,
0580 uint32_t num_clips,
0581 int increment,
0582 bool to_surface,
0583 bool interruptible,
0584 struct drm_crtc *crtc);
0585
0586 int vmw_du_helper_plane_update(struct vmw_du_update_plane *update);
0587
0588
0589
0590
0591
0592
0593 static inline void vmw_du_translate_to_crtc(struct drm_plane_state *state,
0594 struct drm_rect *r)
0595 {
0596 int translate_crtc_x = -((state->src_x >> 16) - state->crtc_x);
0597 int translate_crtc_y = -((state->src_y >> 16) - state->crtc_y);
0598
0599 drm_rect_translate(r, translate_crtc_x, translate_crtc_y);
0600 }
0601
0602 #endif