| .. | .. |
|---|
| 28 | 28 | #ifndef VMWGFX_KMS_H_ |
|---|
| 29 | 29 | #define VMWGFX_KMS_H_ |
|---|
| 30 | 30 | |
|---|
| 31 | | -#include <drm/drmP.h> |
|---|
| 32 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 33 | 31 | #include <drm/drm_encoder.h> |
|---|
| 32 | +#include <drm/drm_probe_helper.h> |
|---|
| 33 | + |
|---|
| 34 | 34 | #include "vmwgfx_drv.h" |
|---|
| 35 | 35 | |
|---|
| 36 | +/** |
|---|
| 37 | + * struct vmw_du_update_plane - Closure structure for vmw_du_helper_plane_update |
|---|
| 38 | + * @plane: Plane which is being updated. |
|---|
| 39 | + * @old_state: Old state of plane. |
|---|
| 40 | + * @dev_priv: Device private. |
|---|
| 41 | + * @du: Display unit on which to update the plane. |
|---|
| 42 | + * @vfb: Framebuffer which is blitted to display unit. |
|---|
| 43 | + * @out_fence: Out fence for resource finish. |
|---|
| 44 | + * @mutex: The mutex used to protect resource reservation. |
|---|
| 45 | + * @cpu_blit: True if need cpu blit. |
|---|
| 46 | + * @intr: Whether to perform waits interruptible if possible. |
|---|
| 47 | + * |
|---|
| 48 | + * This structure loosely represent the set of operations needed to perform a |
|---|
| 49 | + * plane update on a display unit. Implementer will define that functionality |
|---|
| 50 | + * according to the function callbacks for this structure. In brief it involves |
|---|
| 51 | + * surface/buffer object validation, populate FIFO commands and command |
|---|
| 52 | + * submission to the device. |
|---|
| 53 | + */ |
|---|
| 54 | +struct vmw_du_update_plane { |
|---|
| 55 | + /** |
|---|
| 56 | + * @calc_fifo_size: Calculate fifo size. |
|---|
| 57 | + * |
|---|
| 58 | + * Determine fifo size for the commands needed for update. The number of |
|---|
| 59 | + * damage clips on display unit @num_hits will be passed to allocate |
|---|
| 60 | + * sufficient fifo space. |
|---|
| 61 | + * |
|---|
| 62 | + * Return: Fifo size needed |
|---|
| 63 | + */ |
|---|
| 64 | + uint32_t (*calc_fifo_size)(struct vmw_du_update_plane *update, |
|---|
| 65 | + uint32_t num_hits); |
|---|
| 36 | 66 | |
|---|
| 67 | + /** |
|---|
| 68 | + * @post_prepare: Populate fifo for resource preparation. |
|---|
| 69 | + * |
|---|
| 70 | + * Some surface resource or buffer object need some extra cmd submission |
|---|
| 71 | + * like update GB image for proxy surface and define a GMRFB for screen |
|---|
| 72 | + * object. That should should be done here as this callback will be |
|---|
| 73 | + * called after FIFO allocation with the address of command buufer. |
|---|
| 74 | + * |
|---|
| 75 | + * This callback is optional. |
|---|
| 76 | + * |
|---|
| 77 | + * Return: Size of commands populated to command buffer. |
|---|
| 78 | + */ |
|---|
| 79 | + uint32_t (*post_prepare)(struct vmw_du_update_plane *update, void *cmd); |
|---|
| 80 | + |
|---|
| 81 | + /** |
|---|
| 82 | + * @pre_clip: Populate fifo before clip. |
|---|
| 83 | + * |
|---|
| 84 | + * This is where pre clip related command should be populated like |
|---|
| 85 | + * surface copy/DMA, etc. |
|---|
| 86 | + * |
|---|
| 87 | + * This callback is optional. |
|---|
| 88 | + * |
|---|
| 89 | + * Return: Size of commands populated to command buffer. |
|---|
| 90 | + */ |
|---|
| 91 | + uint32_t (*pre_clip)(struct vmw_du_update_plane *update, void *cmd, |
|---|
| 92 | + uint32_t num_hits); |
|---|
| 93 | + |
|---|
| 94 | + /** |
|---|
| 95 | + * @clip: Populate fifo for clip. |
|---|
| 96 | + * |
|---|
| 97 | + * This is where to populate clips for surface copy/dma or blit commands |
|---|
| 98 | + * if needed. This will be called times have damage in display unit, |
|---|
| 99 | + * which is one if doing full update. @clip is the damage in destination |
|---|
| 100 | + * coordinates which is crtc/DU and @src_x, @src_y is damage clip src in |
|---|
| 101 | + * framebuffer coordinate. |
|---|
| 102 | + * |
|---|
| 103 | + * This callback is optional. |
|---|
| 104 | + * |
|---|
| 105 | + * Return: Size of commands populated to command buffer. |
|---|
| 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 | + * @post_clip: Populate fifo after clip. |
|---|
| 112 | + * |
|---|
| 113 | + * This is where to populate display unit update commands or blit |
|---|
| 114 | + * commands. |
|---|
| 115 | + * |
|---|
| 116 | + * Return: Size of commands populated to command buffer. |
|---|
| 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 | + * struct vmw_du_update_plane_surface - closure structure for surface |
|---|
| 134 | + * @base: base closure structure. |
|---|
| 135 | + * @cmd_start: FIFO command start address (used by SOU only). |
|---|
| 136 | + */ |
|---|
| 137 | +struct vmw_du_update_plane_surface { |
|---|
| 138 | + struct vmw_du_update_plane base; |
|---|
| 139 | + /* This member is to handle special case SOU surface update */ |
|---|
| 140 | + void *cmd_start; |
|---|
| 141 | +}; |
|---|
| 142 | + |
|---|
| 143 | +/** |
|---|
| 144 | + * struct vmw_du_update_plane_buffer - Closure structure for buffer object |
|---|
| 145 | + * @base: Base closure structure. |
|---|
| 146 | + * @fb_left: x1 for fb damage bounding box. |
|---|
| 147 | + * @fb_top: y1 for fb damage bounding box. |
|---|
| 148 | + */ |
|---|
| 149 | +struct vmw_du_update_plane_buffer { |
|---|
| 150 | + struct vmw_du_update_plane base; |
|---|
| 151 | + int fb_left, fb_top; |
|---|
| 152 | +}; |
|---|
| 37 | 153 | |
|---|
| 38 | 154 | /** |
|---|
| 39 | 155 | * struct vmw_kms_dirty - closure structure for the vmw_kms_helper_dirty |
|---|
| .. | .. |
|---|
| 191 | 307 | struct vmw_connector_state { |
|---|
| 192 | 308 | struct drm_connector_state base; |
|---|
| 193 | 309 | |
|---|
| 194 | | - bool is_implicit; |
|---|
| 195 | | - |
|---|
| 196 | 310 | /** |
|---|
| 197 | 311 | * @gui_x: |
|---|
| 198 | 312 | * |
|---|
| .. | .. |
|---|
| 254 | 368 | int gui_x; |
|---|
| 255 | 369 | int gui_y; |
|---|
| 256 | 370 | bool is_implicit; |
|---|
| 257 | | - bool active_implicit; |
|---|
| 258 | 371 | int set_gui_x; |
|---|
| 259 | 372 | int set_gui_y; |
|---|
| 260 | 373 | }; |
|---|
| .. | .. |
|---|
| 308 | 421 | int increment, |
|---|
| 309 | 422 | struct vmw_kms_dirty *dirty); |
|---|
| 310 | 423 | |
|---|
| 311 | | -int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv, |
|---|
| 312 | | - struct vmw_buffer_object *buf, |
|---|
| 313 | | - bool interruptible, |
|---|
| 314 | | - bool validate_as_mob, |
|---|
| 315 | | - bool for_cpu_blit); |
|---|
| 316 | | -void vmw_kms_helper_buffer_revert(struct vmw_buffer_object *buf); |
|---|
| 317 | | -void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, |
|---|
| 318 | | - struct drm_file *file_priv, |
|---|
| 319 | | - struct vmw_buffer_object *buf, |
|---|
| 320 | | - struct vmw_fence_obj **out_fence, |
|---|
| 321 | | - struct drm_vmw_fence_rep __user * |
|---|
| 322 | | - user_fence_rep); |
|---|
| 323 | | -int vmw_kms_helper_resource_prepare(struct vmw_resource *res, |
|---|
| 324 | | - bool interruptible, |
|---|
| 325 | | - struct vmw_validation_ctx *ctx); |
|---|
| 326 | | -void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx); |
|---|
| 327 | | -void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx, |
|---|
| 328 | | - struct vmw_fence_obj **out_fence); |
|---|
| 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); |
|---|
| 329 | 430 | int vmw_kms_readback(struct vmw_private *dev_priv, |
|---|
| 330 | 431 | struct drm_file *file_priv, |
|---|
| 331 | 432 | struct vmw_framebuffer *vfb, |
|---|
| .. | .. |
|---|
| 346 | 447 | struct drm_crtc **p_crtc, |
|---|
| 347 | 448 | struct drm_display_mode **p_mode); |
|---|
| 348 | 449 | void vmw_guess_mode_timing(struct drm_display_mode *mode); |
|---|
| 349 | | -void vmw_kms_del_active(struct vmw_private *dev_priv, |
|---|
| 350 | | - struct vmw_display_unit *du); |
|---|
| 351 | | -void vmw_kms_add_active(struct vmw_private *dev_priv, |
|---|
| 352 | | - struct vmw_display_unit *du, |
|---|
| 353 | | - struct vmw_framebuffer *vfb); |
|---|
| 354 | | -bool vmw_kms_crtc_flippable(struct vmw_private *dev_priv, |
|---|
| 355 | | - struct drm_crtc *crtc); |
|---|
| 356 | | -void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv, |
|---|
| 357 | | - struct drm_crtc *crtc); |
|---|
| 358 | | -void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv, |
|---|
| 359 | | - bool immutable); |
|---|
| 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); |
|---|
| 360 | 452 | |
|---|
| 361 | 453 | /* Universal Plane Helpers */ |
|---|
| 362 | 454 | void vmw_du_primary_plane_destroy(struct drm_plane *plane); |
|---|
| .. | .. |
|---|
| 468 | 560 | bool interruptible, |
|---|
| 469 | 561 | struct drm_crtc *crtc); |
|---|
| 470 | 562 | |
|---|
| 471 | | -int vmw_kms_set_config(struct drm_mode_set *set, |
|---|
| 472 | | - struct drm_modeset_acquire_ctx *ctx); |
|---|
| 563 | +int vmw_du_helper_plane_update(struct vmw_du_update_plane *update); |
|---|
| 564 | + |
|---|
| 565 | +/** |
|---|
| 566 | + * vmw_du_translate_to_crtc - Translate a rect from framebuffer to crtc |
|---|
| 567 | + * @state: Plane state. |
|---|
| 568 | + * @r: Rectangle to translate. |
|---|
| 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 | + |
|---|
| 473 | 579 | #endif |
|---|