1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /**************************************************************************
4 * Copyright 2011-2015 VMware, Inc., Palo Alto, CA., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "vmwgfx_kms.h"
29 #include <drm/drm_plane_helper.h>
30 #include <drm/drm_atomic.h>
31 #include <drm/drm_atomic_helper.h>
32 #include <drm/drm_damage_helper.h>
35 #define vmw_crtc_to_sou(x) \
36 container_of(x, struct vmw_screen_object_unit, base.crtc)
37 #define vmw_encoder_to_sou(x) \
38 container_of(x, struct vmw_screen_object_unit, base.encoder)
39 #define vmw_connector_to_sou(x) \
40 container_of(x, struct vmw_screen_object_unit, base.connector)
43 * struct vmw_kms_sou_surface_dirty - Closure structure for
44 * blit surface to screen command.
45 * @base: The base type we derive from. Used by vmw_kms_helper_dirty().
46 * @left: Left side of bounding box.
47 * @right: Right side of bounding box.
48 * @top: Top side of bounding box.
49 * @bottom: Bottom side of bounding box.
50 * @dst_x: Difference between source clip rects and framebuffer coordinates.
51 * @dst_y: Difference between source clip rects and framebuffer coordinates.
52 * @sid: Surface id of surface to copy from.
54 struct vmw_kms_sou_surface_dirty
{
55 struct vmw_kms_dirty base
;
56 s32 left
, right
, top
, bottom
;
62 * SVGA commands that are used by this code. Please see the device headers
65 struct vmw_kms_sou_readback_blit
{
67 SVGAFifoCmdBlitScreenToGMRFB body
;
70 struct vmw_kms_sou_bo_blit
{
72 SVGAFifoCmdBlitGMRFBToScreen body
;
75 struct vmw_kms_sou_dirty_cmd
{
76 SVGA3dCmdHeader header
;
77 SVGA3dCmdBlitSurfaceToScreen body
;
80 struct vmw_kms_sou_define_gmrfb
{
82 SVGAFifoCmdDefineGMRFB body
;
86 * Display unit using screen objects.
88 struct vmw_screen_object_unit
{
89 struct vmw_display_unit base
;
91 unsigned long buffer_size
; /**< Size of allocated buffer */
92 struct vmw_buffer_object
*buffer
; /**< Backing store buffer */
97 static void vmw_sou_destroy(struct vmw_screen_object_unit
*sou
)
99 vmw_du_cleanup(&sou
->base
);
105 * Screen Object Display Unit CRTC functions
108 static void vmw_sou_crtc_destroy(struct drm_crtc
*crtc
)
110 vmw_sou_destroy(vmw_crtc_to_sou(crtc
));
114 * Send the fifo command to create a screen.
116 static int vmw_sou_fifo_create(struct vmw_private
*dev_priv
,
117 struct vmw_screen_object_unit
*sou
,
119 struct drm_display_mode
*mode
)
127 SVGAScreenObject obj
;
130 BUG_ON(!sou
->buffer
);
132 fifo_size
= sizeof(*cmd
);
133 cmd
= vmw_fifo_reserve(dev_priv
, fifo_size
);
134 /* The hardware has hung, nothing we can do about it here. */
135 if (unlikely(cmd
== NULL
)) {
136 DRM_ERROR("Fifo reserve failed.\n");
140 memset(cmd
, 0, fifo_size
);
141 cmd
->header
.cmdType
= SVGA_CMD_DEFINE_SCREEN
;
142 cmd
->obj
.structSize
= sizeof(SVGAScreenObject
);
143 cmd
->obj
.id
= sou
->base
.unit
;
144 cmd
->obj
.flags
= SVGA_SCREEN_HAS_ROOT
|
145 (sou
->base
.unit
== 0 ? SVGA_SCREEN_IS_PRIMARY
: 0);
146 cmd
->obj
.size
.width
= mode
->hdisplay
;
147 cmd
->obj
.size
.height
= mode
->vdisplay
;
150 sou
->base
.set_gui_x
= cmd
->obj
.root
.x
;
151 sou
->base
.set_gui_y
= cmd
->obj
.root
.y
;
153 /* Ok to assume that buffer is pinned in vram */
154 vmw_bo_get_guest_ptr(&sou
->buffer
->base
, &cmd
->obj
.backingStore
.ptr
);
155 cmd
->obj
.backingStore
.pitch
= mode
->hdisplay
* 4;
157 vmw_fifo_commit(dev_priv
, fifo_size
);
165 * Send the fifo command to destroy a screen.
167 static int vmw_sou_fifo_destroy(struct vmw_private
*dev_priv
,
168 struct vmw_screen_object_unit
*sou
)
177 SVGAFifoCmdDestroyScreen body
;
180 /* no need to do anything */
181 if (unlikely(!sou
->defined
))
184 fifo_size
= sizeof(*cmd
);
185 cmd
= vmw_fifo_reserve(dev_priv
, fifo_size
);
186 /* the hardware has hung, nothing we can do about it here */
187 if (unlikely(cmd
== NULL
)) {
188 DRM_ERROR("Fifo reserve failed.\n");
192 memset(cmd
, 0, fifo_size
);
193 cmd
->header
.cmdType
= SVGA_CMD_DESTROY_SCREEN
;
194 cmd
->body
.screenId
= sou
->base
.unit
;
196 vmw_fifo_commit(dev_priv
, fifo_size
);
199 ret
= vmw_fallback_wait(dev_priv
, false, true, 0, false, 3*HZ
);
200 if (unlikely(ret
!= 0))
201 DRM_ERROR("Failed to sync with HW");
203 sou
->defined
= false;
209 * vmw_sou_crtc_mode_set_nofb - Create new screen
211 * @crtc: CRTC associated with the new screen
213 * This function creates/destroys a screen. This function cannot fail, so if
214 * somehow we run into a failure, just do the best we can to get out.
216 static void vmw_sou_crtc_mode_set_nofb(struct drm_crtc
*crtc
)
218 struct vmw_private
*dev_priv
;
219 struct vmw_screen_object_unit
*sou
;
220 struct vmw_framebuffer
*vfb
;
221 struct drm_framebuffer
*fb
;
222 struct drm_plane_state
*ps
;
223 struct vmw_plane_state
*vps
;
226 sou
= vmw_crtc_to_sou(crtc
);
227 dev_priv
= vmw_priv(crtc
->dev
);
228 ps
= crtc
->primary
->state
;
230 vps
= vmw_plane_state_to_vps(ps
);
232 vfb
= (fb
) ? vmw_framebuffer_to_vfb(fb
) : NULL
;
235 ret
= vmw_sou_fifo_destroy(dev_priv
, sou
);
237 DRM_ERROR("Failed to destroy Screen Object\n");
243 struct drm_connector_state
*conn_state
;
244 struct vmw_connector_state
*vmw_conn_state
;
247 sou
->buffer
= vps
->bo
;
248 sou
->buffer_size
= vps
->bo_size
;
250 conn_state
= sou
->base
.connector
.state
;
251 vmw_conn_state
= vmw_connector_state_to_vcs(conn_state
);
253 x
= vmw_conn_state
->gui_x
;
254 y
= vmw_conn_state
->gui_y
;
256 ret
= vmw_sou_fifo_create(dev_priv
, sou
, x
, y
, &crtc
->mode
);
258 DRM_ERROR("Failed to define Screen Object %dx%d\n",
263 sou
->buffer_size
= 0;
268 * vmw_sou_crtc_helper_prepare - Noop
270 * @crtc: CRTC associated with the new screen
272 * Prepares the CRTC for a mode set, but we don't need to do anything here.
274 static void vmw_sou_crtc_helper_prepare(struct drm_crtc
*crtc
)
279 * vmw_sou_crtc_atomic_enable - Noop
281 * @crtc: CRTC associated with the new screen
283 * This is called after a mode set has been completed.
285 static void vmw_sou_crtc_atomic_enable(struct drm_crtc
*crtc
,
286 struct drm_crtc_state
*old_state
)
291 * vmw_sou_crtc_atomic_disable - Turns off CRTC
293 * @crtc: CRTC to be turned off
295 static void vmw_sou_crtc_atomic_disable(struct drm_crtc
*crtc
,
296 struct drm_crtc_state
*old_state
)
298 struct vmw_private
*dev_priv
;
299 struct vmw_screen_object_unit
*sou
;
304 DRM_ERROR("CRTC is NULL\n");
308 sou
= vmw_crtc_to_sou(crtc
);
309 dev_priv
= vmw_priv(crtc
->dev
);
312 ret
= vmw_sou_fifo_destroy(dev_priv
, sou
);
314 DRM_ERROR("Failed to destroy Screen Object\n");
318 static const struct drm_crtc_funcs vmw_screen_object_crtc_funcs
= {
319 .gamma_set
= vmw_du_crtc_gamma_set
,
320 .destroy
= vmw_sou_crtc_destroy
,
321 .reset
= vmw_du_crtc_reset
,
322 .atomic_duplicate_state
= vmw_du_crtc_duplicate_state
,
323 .atomic_destroy_state
= vmw_du_crtc_destroy_state
,
324 .set_config
= drm_atomic_helper_set_config
,
325 .page_flip
= drm_atomic_helper_page_flip
,
329 * Screen Object Display Unit encoder functions
332 static void vmw_sou_encoder_destroy(struct drm_encoder
*encoder
)
334 vmw_sou_destroy(vmw_encoder_to_sou(encoder
));
337 static const struct drm_encoder_funcs vmw_screen_object_encoder_funcs
= {
338 .destroy
= vmw_sou_encoder_destroy
,
342 * Screen Object Display Unit connector functions
345 static void vmw_sou_connector_destroy(struct drm_connector
*connector
)
347 vmw_sou_destroy(vmw_connector_to_sou(connector
));
350 static const struct drm_connector_funcs vmw_sou_connector_funcs
= {
351 .dpms
= vmw_du_connector_dpms
,
352 .detect
= vmw_du_connector_detect
,
353 .fill_modes
= vmw_du_connector_fill_modes
,
354 .destroy
= vmw_sou_connector_destroy
,
355 .reset
= vmw_du_connector_reset
,
356 .atomic_duplicate_state
= vmw_du_connector_duplicate_state
,
357 .atomic_destroy_state
= vmw_du_connector_destroy_state
,
362 drm_connector_helper_funcs vmw_sou_connector_helper_funcs
= {
368 * Screen Object Display Plane Functions
372 * vmw_sou_primary_plane_cleanup_fb - Frees sou backing buffer
374 * @plane: display plane
375 * @old_state: Contains the FB to clean up
377 * Unpins the display surface
379 * Returns 0 on success
382 vmw_sou_primary_plane_cleanup_fb(struct drm_plane
*plane
,
383 struct drm_plane_state
*old_state
)
385 struct vmw_plane_state
*vps
= vmw_plane_state_to_vps(old_state
);
386 struct drm_crtc
*crtc
= plane
->state
->crtc
?
387 plane
->state
->crtc
: old_state
->crtc
;
390 vmw_bo_unpin(vmw_priv(crtc
->dev
), vps
->bo
, false);
391 vmw_bo_unreference(&vps
->bo
);
394 vmw_du_plane_cleanup_fb(plane
, old_state
);
399 * vmw_sou_primary_plane_prepare_fb - allocate backing buffer
401 * @plane: display plane
402 * @new_state: info on the new plane state, including the FB
404 * The SOU backing buffer is our equivalent of the display plane.
406 * Returns 0 on success
409 vmw_sou_primary_plane_prepare_fb(struct drm_plane
*plane
,
410 struct drm_plane_state
*new_state
)
412 struct drm_framebuffer
*new_fb
= new_state
->fb
;
413 struct drm_crtc
*crtc
= plane
->state
->crtc
?: new_state
->crtc
;
414 struct vmw_plane_state
*vps
= vmw_plane_state_to_vps(new_state
);
415 struct vmw_private
*dev_priv
;
421 vmw_bo_unreference(&vps
->bo
);
427 size
= new_state
->crtc_w
* new_state
->crtc_h
* 4;
428 dev_priv
= vmw_priv(crtc
->dev
);
431 if (vps
->bo_size
== size
) {
433 * Note that this might temporarily up the pin-count
434 * to 2, until cleanup_fb() is called.
436 return vmw_bo_pin_in_vram(dev_priv
, vps
->bo
,
440 vmw_bo_unreference(&vps
->bo
);
444 vps
->bo
= kzalloc(sizeof(*vps
->bo
), GFP_KERNEL
);
448 vmw_svga_enable(dev_priv
);
450 /* After we have alloced the backing store might not be able to
451 * resume the overlays, this is preferred to failing to alloc.
453 vmw_overlay_pause_all(dev_priv
);
454 ret
= vmw_bo_init(dev_priv
, vps
->bo
, size
,
455 &vmw_vram_ne_placement
,
456 false, &vmw_bo_bo_free
);
457 vmw_overlay_resume_all(dev_priv
);
459 vps
->bo
= NULL
; /* vmw_bo_init frees on error */
466 * TTM already thinks the buffer is pinned, but make sure the
467 * pin_count is upped.
469 return vmw_bo_pin_in_vram(dev_priv
, vps
->bo
, true);
472 static uint32_t vmw_sou_bo_fifo_size(struct vmw_du_update_plane
*update
,
475 return sizeof(struct vmw_kms_sou_define_gmrfb
) +
476 sizeof(struct vmw_kms_sou_bo_blit
) * num_hits
;
479 static uint32_t vmw_sou_bo_define_gmrfb(struct vmw_du_update_plane
*update
,
482 struct vmw_framebuffer_bo
*vfbbo
=
483 container_of(update
->vfb
, typeof(*vfbbo
), base
);
484 struct vmw_kms_sou_define_gmrfb
*gmr
= cmd
;
485 int depth
= update
->vfb
->base
.format
->depth
;
487 /* Emulate RGBA support, contrary to svga_reg.h this is not
488 * supported by hosts. This is only a problem if we are reading
489 * this value later and expecting what we uploaded back.
494 gmr
->header
= SVGA_CMD_DEFINE_GMRFB
;
496 gmr
->body
.format
.bitsPerPixel
= update
->vfb
->base
.format
->cpp
[0] * 8;
497 gmr
->body
.format
.colorDepth
= depth
;
498 gmr
->body
.format
.reserved
= 0;
499 gmr
->body
.bytesPerLine
= update
->vfb
->base
.pitches
[0];
500 vmw_bo_get_guest_ptr(&vfbbo
->buffer
->base
, &gmr
->body
.ptr
);
505 static uint32_t vmw_sou_bo_populate_clip(struct vmw_du_update_plane
*update
,
506 void *cmd
, struct drm_rect
*clip
,
507 uint32_t fb_x
, uint32_t fb_y
)
509 struct vmw_kms_sou_bo_blit
*blit
= cmd
;
511 blit
->header
= SVGA_CMD_BLIT_GMRFB_TO_SCREEN
;
512 blit
->body
.destScreenId
= update
->du
->unit
;
513 blit
->body
.srcOrigin
.x
= fb_x
;
514 blit
->body
.srcOrigin
.y
= fb_y
;
515 blit
->body
.destRect
.left
= clip
->x1
;
516 blit
->body
.destRect
.top
= clip
->y1
;
517 blit
->body
.destRect
.right
= clip
->x2
;
518 blit
->body
.destRect
.bottom
= clip
->y2
;
520 return sizeof(*blit
);
523 static uint32_t vmw_stud_bo_post_clip(struct vmw_du_update_plane
*update
,
524 void *cmd
, struct drm_rect
*bb
)
530 * vmw_sou_plane_update_bo - Update display unit for bo backed fb.
531 * @dev_priv: Device private.
532 * @plane: Plane state.
533 * @old_state: Old plane state.
534 * @vfb: Framebuffer which is blitted to display unit.
535 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
536 * The returned fence pointer may be NULL in which case the device
537 * has already synchronized.
539 * Return: 0 on success or a negative error code on failure.
541 static int vmw_sou_plane_update_bo(struct vmw_private
*dev_priv
,
542 struct drm_plane
*plane
,
543 struct drm_plane_state
*old_state
,
544 struct vmw_framebuffer
*vfb
,
545 struct vmw_fence_obj
**out_fence
)
547 struct vmw_du_update_plane_buffer bo_update
;
549 memset(&bo_update
, 0, sizeof(struct vmw_du_update_plane_buffer
));
550 bo_update
.base
.plane
= plane
;
551 bo_update
.base
.old_state
= old_state
;
552 bo_update
.base
.dev_priv
= dev_priv
;
553 bo_update
.base
.du
= vmw_crtc_to_du(plane
->state
->crtc
);
554 bo_update
.base
.vfb
= vfb
;
555 bo_update
.base
.out_fence
= out_fence
;
556 bo_update
.base
.mutex
= NULL
;
557 bo_update
.base
.cpu_blit
= false;
558 bo_update
.base
.intr
= true;
560 bo_update
.base
.calc_fifo_size
= vmw_sou_bo_fifo_size
;
561 bo_update
.base
.post_prepare
= vmw_sou_bo_define_gmrfb
;
562 bo_update
.base
.clip
= vmw_sou_bo_populate_clip
;
563 bo_update
.base
.post_clip
= vmw_stud_bo_post_clip
;
565 return vmw_du_helper_plane_update(&bo_update
.base
);
568 static uint32_t vmw_sou_surface_fifo_size(struct vmw_du_update_plane
*update
,
571 return sizeof(struct vmw_kms_sou_dirty_cmd
) + sizeof(SVGASignedRect
) *
575 static uint32_t vmw_sou_surface_post_prepare(struct vmw_du_update_plane
*update
,
578 struct vmw_du_update_plane_surface
*srf_update
;
580 srf_update
= container_of(update
, typeof(*srf_update
), base
);
583 * SOU SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN is special in the sense that
584 * its bounding box is filled before iterating over all the clips. So
585 * store the FIFO start address and revisit to fill the details.
587 srf_update
->cmd_start
= cmd
;
592 static uint32_t vmw_sou_surface_pre_clip(struct vmw_du_update_plane
*update
,
593 void *cmd
, uint32_t num_hits
)
595 struct vmw_kms_sou_dirty_cmd
*blit
= cmd
;
596 struct vmw_framebuffer_surface
*vfbs
;
598 vfbs
= container_of(update
->vfb
, typeof(*vfbs
), base
);
600 blit
->header
.id
= SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN
;
601 blit
->header
.size
= sizeof(blit
->body
) + sizeof(SVGASignedRect
) *
604 blit
->body
.srcImage
.sid
= vfbs
->surface
->res
.id
;
605 blit
->body
.destScreenId
= update
->du
->unit
;
607 /* Update the source and destination bounding box later in post_clip */
608 blit
->body
.srcRect
.left
= 0;
609 blit
->body
.srcRect
.top
= 0;
610 blit
->body
.srcRect
.right
= 0;
611 blit
->body
.srcRect
.bottom
= 0;
613 blit
->body
.destRect
.left
= 0;
614 blit
->body
.destRect
.top
= 0;
615 blit
->body
.destRect
.right
= 0;
616 blit
->body
.destRect
.bottom
= 0;
618 return sizeof(*blit
);
621 static uint32_t vmw_sou_surface_clip_rect(struct vmw_du_update_plane
*update
,
622 void *cmd
, struct drm_rect
*clip
,
623 uint32_t src_x
, uint32_t src_y
)
625 SVGASignedRect
*rect
= cmd
;
628 * rects are relative to dest bounding box rect on screen object, so
629 * translate to it later in post_clip
631 rect
->left
= clip
->x1
;
632 rect
->top
= clip
->y1
;
633 rect
->right
= clip
->x2
;
634 rect
->bottom
= clip
->y2
;
636 return sizeof(*rect
);
639 static uint32_t vmw_sou_surface_post_clip(struct vmw_du_update_plane
*update
,
640 void *cmd
, struct drm_rect
*bb
)
642 struct vmw_du_update_plane_surface
*srf_update
;
643 struct drm_plane_state
*state
= update
->plane
->state
;
644 struct drm_rect src_bb
;
645 struct vmw_kms_sou_dirty_cmd
*blit
;
646 SVGASignedRect
*rect
;
652 srf_update
= container_of(update
, typeof(*srf_update
), base
);
654 blit
= srf_update
->cmd_start
;
655 rect
= (SVGASignedRect
*)&blit
[1];
657 num_hits
= (blit
->header
.size
- sizeof(blit
->body
))/
658 sizeof(SVGASignedRect
);
662 /* To translate bb back to fb src coord */
663 translate_src_x
= (state
->src_x
>> 16) - state
->crtc_x
;
664 translate_src_y
= (state
->src_y
>> 16) - state
->crtc_y
;
666 drm_rect_translate(&src_bb
, translate_src_x
, translate_src_y
);
668 blit
->body
.srcRect
.left
= src_bb
.x1
;
669 blit
->body
.srcRect
.top
= src_bb
.y1
;
670 blit
->body
.srcRect
.right
= src_bb
.x2
;
671 blit
->body
.srcRect
.bottom
= src_bb
.y2
;
673 blit
->body
.destRect
.left
= bb
->x1
;
674 blit
->body
.destRect
.top
= bb
->y1
;
675 blit
->body
.destRect
.right
= bb
->x2
;
676 blit
->body
.destRect
.bottom
= bb
->y2
;
678 /* rects are relative to dest bb rect */
679 for (i
= 0; i
< num_hits
; i
++) {
680 rect
->left
-= bb
->x1
;
682 rect
->right
-= bb
->x1
;
683 rect
->bottom
-= bb
->y1
;
691 * vmw_sou_plane_update_surface - Update display unit for surface backed fb.
692 * @dev_priv: Device private.
693 * @plane: Plane state.
694 * @old_state: Old plane state.
695 * @vfb: Framebuffer which is blitted to display unit
696 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
697 * The returned fence pointer may be NULL in which case the device
698 * has already synchronized.
700 * Return: 0 on success or a negative error code on failure.
702 static int vmw_sou_plane_update_surface(struct vmw_private
*dev_priv
,
703 struct drm_plane
*plane
,
704 struct drm_plane_state
*old_state
,
705 struct vmw_framebuffer
*vfb
,
706 struct vmw_fence_obj
**out_fence
)
708 struct vmw_du_update_plane_surface srf_update
;
710 memset(&srf_update
, 0, sizeof(struct vmw_du_update_plane_surface
));
711 srf_update
.base
.plane
= plane
;
712 srf_update
.base
.old_state
= old_state
;
713 srf_update
.base
.dev_priv
= dev_priv
;
714 srf_update
.base
.du
= vmw_crtc_to_du(plane
->state
->crtc
);
715 srf_update
.base
.vfb
= vfb
;
716 srf_update
.base
.out_fence
= out_fence
;
717 srf_update
.base
.mutex
= &dev_priv
->cmdbuf_mutex
;
718 srf_update
.base
.cpu_blit
= false;
719 srf_update
.base
.intr
= true;
721 srf_update
.base
.calc_fifo_size
= vmw_sou_surface_fifo_size
;
722 srf_update
.base
.post_prepare
= vmw_sou_surface_post_prepare
;
723 srf_update
.base
.pre_clip
= vmw_sou_surface_pre_clip
;
724 srf_update
.base
.clip
= vmw_sou_surface_clip_rect
;
725 srf_update
.base
.post_clip
= vmw_sou_surface_post_clip
;
727 return vmw_du_helper_plane_update(&srf_update
.base
);
731 vmw_sou_primary_plane_atomic_update(struct drm_plane
*plane
,
732 struct drm_plane_state
*old_state
)
734 struct drm_crtc
*crtc
= plane
->state
->crtc
;
735 struct drm_pending_vblank_event
*event
= NULL
;
736 struct vmw_fence_obj
*fence
= NULL
;
739 /* In case of device error, maintain consistent atomic state */
740 if (crtc
&& plane
->state
->fb
) {
741 struct vmw_private
*dev_priv
= vmw_priv(crtc
->dev
);
742 struct vmw_framebuffer
*vfb
=
743 vmw_framebuffer_to_vfb(plane
->state
->fb
);
746 ret
= vmw_sou_plane_update_bo(dev_priv
, plane
,
747 old_state
, vfb
, &fence
);
749 ret
= vmw_sou_plane_update_surface(dev_priv
, plane
,
753 DRM_ERROR("Failed to update screen.\n");
755 /* Do nothing when fb and crtc is NULL (blank crtc) */
759 /* For error case vblank event is send from vmw_du_crtc_atomic_flush */
760 event
= crtc
->state
->event
;
761 if (event
&& fence
) {
762 struct drm_file
*file_priv
= event
->base
.file_priv
;
764 ret
= vmw_event_fence_action_queue(file_priv
,
767 &event
->event
.vbl
.tv_sec
,
768 &event
->event
.vbl
.tv_usec
,
771 if (unlikely(ret
!= 0))
772 DRM_ERROR("Failed to queue event on fence.\n");
774 crtc
->state
->event
= NULL
;
778 vmw_fence_obj_unreference(&fence
);
782 static const struct drm_plane_funcs vmw_sou_plane_funcs
= {
783 .update_plane
= drm_atomic_helper_update_plane
,
784 .disable_plane
= drm_atomic_helper_disable_plane
,
785 .destroy
= vmw_du_primary_plane_destroy
,
786 .reset
= vmw_du_plane_reset
,
787 .atomic_duplicate_state
= vmw_du_plane_duplicate_state
,
788 .atomic_destroy_state
= vmw_du_plane_destroy_state
,
791 static const struct drm_plane_funcs vmw_sou_cursor_funcs
= {
792 .update_plane
= drm_atomic_helper_update_plane
,
793 .disable_plane
= drm_atomic_helper_disable_plane
,
794 .destroy
= vmw_du_cursor_plane_destroy
,
795 .reset
= vmw_du_plane_reset
,
796 .atomic_duplicate_state
= vmw_du_plane_duplicate_state
,
797 .atomic_destroy_state
= vmw_du_plane_destroy_state
,
804 drm_plane_helper_funcs vmw_sou_cursor_plane_helper_funcs
= {
805 .atomic_check
= vmw_du_cursor_plane_atomic_check
,
806 .atomic_update
= vmw_du_cursor_plane_atomic_update
,
807 .prepare_fb
= vmw_du_cursor_plane_prepare_fb
,
808 .cleanup_fb
= vmw_du_plane_cleanup_fb
,
812 drm_plane_helper_funcs vmw_sou_primary_plane_helper_funcs
= {
813 .atomic_check
= vmw_du_primary_plane_atomic_check
,
814 .atomic_update
= vmw_sou_primary_plane_atomic_update
,
815 .prepare_fb
= vmw_sou_primary_plane_prepare_fb
,
816 .cleanup_fb
= vmw_sou_primary_plane_cleanup_fb
,
819 static const struct drm_crtc_helper_funcs vmw_sou_crtc_helper_funcs
= {
820 .prepare
= vmw_sou_crtc_helper_prepare
,
821 .mode_set_nofb
= vmw_sou_crtc_mode_set_nofb
,
822 .atomic_check
= vmw_du_crtc_atomic_check
,
823 .atomic_begin
= vmw_du_crtc_atomic_begin
,
824 .atomic_flush
= vmw_du_crtc_atomic_flush
,
825 .atomic_enable
= vmw_sou_crtc_atomic_enable
,
826 .atomic_disable
= vmw_sou_crtc_atomic_disable
,
830 static int vmw_sou_init(struct vmw_private
*dev_priv
, unsigned unit
)
832 struct vmw_screen_object_unit
*sou
;
833 struct drm_device
*dev
= dev_priv
->dev
;
834 struct drm_connector
*connector
;
835 struct drm_encoder
*encoder
;
836 struct drm_plane
*primary
, *cursor
;
837 struct drm_crtc
*crtc
;
840 sou
= kzalloc(sizeof(*sou
), GFP_KERNEL
);
844 sou
->base
.unit
= unit
;
845 crtc
= &sou
->base
.crtc
;
846 encoder
= &sou
->base
.encoder
;
847 connector
= &sou
->base
.connector
;
848 primary
= &sou
->base
.primary
;
849 cursor
= &sou
->base
.cursor
;
851 sou
->base
.pref_active
= (unit
== 0);
852 sou
->base
.pref_width
= dev_priv
->initial_width
;
853 sou
->base
.pref_height
= dev_priv
->initial_height
;
854 sou
->base
.pref_mode
= NULL
;
857 * Remove this after enabling atomic because property values can
858 * only exist in a state object
860 sou
->base
.is_implicit
= false;
862 /* Initialize primary plane */
863 vmw_du_plane_reset(primary
);
865 ret
= drm_universal_plane_init(dev
, &sou
->base
.primary
,
866 0, &vmw_sou_plane_funcs
,
867 vmw_primary_plane_formats
,
868 ARRAY_SIZE(vmw_primary_plane_formats
),
869 NULL
, DRM_PLANE_TYPE_PRIMARY
, NULL
);
871 DRM_ERROR("Failed to initialize primary plane");
875 drm_plane_helper_add(primary
, &vmw_sou_primary_plane_helper_funcs
);
876 drm_plane_enable_fb_damage_clips(primary
);
878 /* Initialize cursor plane */
879 vmw_du_plane_reset(cursor
);
881 ret
= drm_universal_plane_init(dev
, &sou
->base
.cursor
,
882 0, &vmw_sou_cursor_funcs
,
883 vmw_cursor_plane_formats
,
884 ARRAY_SIZE(vmw_cursor_plane_formats
),
885 NULL
, DRM_PLANE_TYPE_CURSOR
, NULL
);
887 DRM_ERROR("Failed to initialize cursor plane");
888 drm_plane_cleanup(&sou
->base
.primary
);
892 drm_plane_helper_add(cursor
, &vmw_sou_cursor_plane_helper_funcs
);
894 vmw_du_connector_reset(connector
);
895 ret
= drm_connector_init(dev
, connector
, &vmw_sou_connector_funcs
,
896 DRM_MODE_CONNECTOR_VIRTUAL
);
898 DRM_ERROR("Failed to initialize connector\n");
902 drm_connector_helper_add(connector
, &vmw_sou_connector_helper_funcs
);
903 connector
->status
= vmw_du_connector_detect(connector
, true);
905 ret
= drm_encoder_init(dev
, encoder
, &vmw_screen_object_encoder_funcs
,
906 DRM_MODE_ENCODER_VIRTUAL
, NULL
);
908 DRM_ERROR("Failed to initialize encoder\n");
909 goto err_free_connector
;
912 (void) drm_connector_attach_encoder(connector
, encoder
);
913 encoder
->possible_crtcs
= (1 << unit
);
914 encoder
->possible_clones
= 0;
916 ret
= drm_connector_register(connector
);
918 DRM_ERROR("Failed to register connector\n");
919 goto err_free_encoder
;
923 vmw_du_crtc_reset(crtc
);
924 ret
= drm_crtc_init_with_planes(dev
, crtc
, &sou
->base
.primary
,
926 &vmw_screen_object_crtc_funcs
, NULL
);
928 DRM_ERROR("Failed to initialize CRTC\n");
929 goto err_free_unregister
;
932 drm_crtc_helper_add(crtc
, &vmw_sou_crtc_helper_funcs
);
934 drm_mode_crtc_set_gamma_size(crtc
, 256);
936 drm_object_attach_property(&connector
->base
,
937 dev_priv
->hotplug_mode_update_property
, 1);
938 drm_object_attach_property(&connector
->base
,
939 dev
->mode_config
.suggested_x_property
, 0);
940 drm_object_attach_property(&connector
->base
,
941 dev
->mode_config
.suggested_y_property
, 0);
945 drm_connector_unregister(connector
);
947 drm_encoder_cleanup(encoder
);
949 drm_connector_cleanup(connector
);
955 int vmw_kms_sou_init_display(struct vmw_private
*dev_priv
)
957 struct drm_device
*dev
= dev_priv
->dev
;
960 if (!(dev_priv
->capabilities
& SVGA_CAP_SCREEN_OBJECT_2
)) {
961 DRM_INFO("Not using screen objects,"
962 " missing cap SCREEN_OBJECT_2\n");
968 ret
= drm_vblank_init(dev
, VMWGFX_NUM_DISPLAY_UNITS
);
969 if (unlikely(ret
!= 0))
972 for (i
= 0; i
< VMWGFX_NUM_DISPLAY_UNITS
; ++i
)
973 vmw_sou_init(dev_priv
, i
);
975 dev_priv
->active_display_unit
= vmw_du_screen_object
;
977 DRM_INFO("Screen Objects Display Unit initialized\n");
982 static int do_bo_define_gmrfb(struct vmw_private
*dev_priv
,
983 struct vmw_framebuffer
*framebuffer
)
985 struct vmw_buffer_object
*buf
=
986 container_of(framebuffer
, struct vmw_framebuffer_bo
,
988 int depth
= framebuffer
->base
.format
->depth
;
991 SVGAFifoCmdDefineGMRFB body
;
994 /* Emulate RGBA support, contrary to svga_reg.h this is not
995 * supported by hosts. This is only a problem if we are reading
996 * this value later and expecting what we uploaded back.
1001 cmd
= vmw_fifo_reserve(dev_priv
, sizeof(*cmd
));
1003 DRM_ERROR("Out of fifo space for dirty framebuffer command.\n");
1007 cmd
->header
= SVGA_CMD_DEFINE_GMRFB
;
1008 cmd
->body
.format
.bitsPerPixel
= framebuffer
->base
.format
->cpp
[0] * 8;
1009 cmd
->body
.format
.colorDepth
= depth
;
1010 cmd
->body
.format
.reserved
= 0;
1011 cmd
->body
.bytesPerLine
= framebuffer
->base
.pitches
[0];
1012 /* Buffer is reserved in vram or GMR */
1013 vmw_bo_get_guest_ptr(&buf
->base
, &cmd
->body
.ptr
);
1014 vmw_fifo_commit(dev_priv
, sizeof(*cmd
));
1020 * vmw_sou_surface_fifo_commit - Callback to fill in and submit a
1021 * blit surface to screen command.
1023 * @dirty: The closure structure.
1025 * Fills in the missing fields in the command, and translates the cliprects
1026 * to match the destination bounding box encoded.
1028 static void vmw_sou_surface_fifo_commit(struct vmw_kms_dirty
*dirty
)
1030 struct vmw_kms_sou_surface_dirty
*sdirty
=
1031 container_of(dirty
, typeof(*sdirty
), base
);
1032 struct vmw_kms_sou_dirty_cmd
*cmd
= dirty
->cmd
;
1033 s32 trans_x
= dirty
->unit
->crtc
.x
- sdirty
->dst_x
;
1034 s32 trans_y
= dirty
->unit
->crtc
.y
- sdirty
->dst_y
;
1035 size_t region_size
= dirty
->num_hits
* sizeof(SVGASignedRect
);
1036 SVGASignedRect
*blit
= (SVGASignedRect
*) &cmd
[1];
1039 if (!dirty
->num_hits
) {
1040 vmw_fifo_commit(dirty
->dev_priv
, 0);
1044 cmd
->header
.id
= SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN
;
1045 cmd
->header
.size
= sizeof(cmd
->body
) + region_size
;
1048 * Use the destination bounding box to specify destination - and
1049 * source bounding regions.
1051 cmd
->body
.destRect
.left
= sdirty
->left
;
1052 cmd
->body
.destRect
.right
= sdirty
->right
;
1053 cmd
->body
.destRect
.top
= sdirty
->top
;
1054 cmd
->body
.destRect
.bottom
= sdirty
->bottom
;
1056 cmd
->body
.srcRect
.left
= sdirty
->left
+ trans_x
;
1057 cmd
->body
.srcRect
.right
= sdirty
->right
+ trans_x
;
1058 cmd
->body
.srcRect
.top
= sdirty
->top
+ trans_y
;
1059 cmd
->body
.srcRect
.bottom
= sdirty
->bottom
+ trans_y
;
1061 cmd
->body
.srcImage
.sid
= sdirty
->sid
;
1062 cmd
->body
.destScreenId
= dirty
->unit
->unit
;
1064 /* Blits are relative to the destination rect. Translate. */
1065 for (i
= 0; i
< dirty
->num_hits
; ++i
, ++blit
) {
1066 blit
->left
-= sdirty
->left
;
1067 blit
->right
-= sdirty
->left
;
1068 blit
->top
-= sdirty
->top
;
1069 blit
->bottom
-= sdirty
->top
;
1072 vmw_fifo_commit(dirty
->dev_priv
, region_size
+ sizeof(*cmd
));
1074 sdirty
->left
= sdirty
->top
= S32_MAX
;
1075 sdirty
->right
= sdirty
->bottom
= S32_MIN
;
1079 * vmw_sou_surface_clip - Callback to encode a blit surface to screen cliprect.
1081 * @dirty: The closure structure
1083 * Encodes a SVGASignedRect cliprect and updates the bounding box of the
1084 * BLIT_SURFACE_TO_SCREEN command.
1086 static void vmw_sou_surface_clip(struct vmw_kms_dirty
*dirty
)
1088 struct vmw_kms_sou_surface_dirty
*sdirty
=
1089 container_of(dirty
, typeof(*sdirty
), base
);
1090 struct vmw_kms_sou_dirty_cmd
*cmd
= dirty
->cmd
;
1091 SVGASignedRect
*blit
= (SVGASignedRect
*) &cmd
[1];
1093 /* Destination rect. */
1094 blit
+= dirty
->num_hits
;
1095 blit
->left
= dirty
->unit_x1
;
1096 blit
->top
= dirty
->unit_y1
;
1097 blit
->right
= dirty
->unit_x2
;
1098 blit
->bottom
= dirty
->unit_y2
;
1100 /* Destination bounding box */
1101 sdirty
->left
= min_t(s32
, sdirty
->left
, dirty
->unit_x1
);
1102 sdirty
->top
= min_t(s32
, sdirty
->top
, dirty
->unit_y1
);
1103 sdirty
->right
= max_t(s32
, sdirty
->right
, dirty
->unit_x2
);
1104 sdirty
->bottom
= max_t(s32
, sdirty
->bottom
, dirty
->unit_y2
);
1110 * vmw_kms_sou_do_surface_dirty - Dirty part of a surface backed framebuffer
1112 * @dev_priv: Pointer to the device private structure.
1113 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
1114 * @clips: Array of clip rects. Either @clips or @vclips must be NULL.
1115 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
1117 * @srf: Pointer to surface to blit from. If NULL, the surface attached
1118 * to @framebuffer will be used.
1119 * @dest_x: X coordinate offset to align @srf with framebuffer coordinates.
1120 * @dest_y: Y coordinate offset to align @srf with framebuffer coordinates.
1121 * @num_clips: Number of clip rects in @clips.
1122 * @inc: Increment to use when looping over @clips.
1123 * @out_fence: If non-NULL, will return a ref-counted pointer to a
1124 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
1125 * case the device has already synchronized.
1126 * @crtc: If crtc is passed, perform surface dirty on that crtc only.
1128 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1131 int vmw_kms_sou_do_surface_dirty(struct vmw_private
*dev_priv
,
1132 struct vmw_framebuffer
*framebuffer
,
1133 struct drm_clip_rect
*clips
,
1134 struct drm_vmw_rect
*vclips
,
1135 struct vmw_resource
*srf
,
1138 unsigned num_clips
, int inc
,
1139 struct vmw_fence_obj
**out_fence
,
1140 struct drm_crtc
*crtc
)
1142 struct vmw_framebuffer_surface
*vfbs
=
1143 container_of(framebuffer
, typeof(*vfbs
), base
);
1144 struct vmw_kms_sou_surface_dirty sdirty
;
1145 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1149 srf
= &vfbs
->surface
->res
;
1151 ret
= vmw_validation_add_resource(&val_ctx
, srf
, 0, NULL
, NULL
);
1155 ret
= vmw_validation_prepare(&val_ctx
, &dev_priv
->cmdbuf_mutex
, true);
1159 sdirty
.base
.fifo_commit
= vmw_sou_surface_fifo_commit
;
1160 sdirty
.base
.clip
= vmw_sou_surface_clip
;
1161 sdirty
.base
.dev_priv
= dev_priv
;
1162 sdirty
.base
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_dirty_cmd
) +
1163 sizeof(SVGASignedRect
) * num_clips
;
1164 sdirty
.base
.crtc
= crtc
;
1166 sdirty
.sid
= srf
->id
;
1167 sdirty
.left
= sdirty
.top
= S32_MAX
;
1168 sdirty
.right
= sdirty
.bottom
= S32_MIN
;
1169 sdirty
.dst_x
= dest_x
;
1170 sdirty
.dst_y
= dest_y
;
1172 ret
= vmw_kms_helper_dirty(dev_priv
, framebuffer
, clips
, vclips
,
1173 dest_x
, dest_y
, num_clips
, inc
,
1175 vmw_kms_helper_validation_finish(dev_priv
, NULL
, &val_ctx
, out_fence
,
1181 vmw_validation_unref_lists(&val_ctx
);
1186 * vmw_sou_bo_fifo_commit - Callback to submit a set of readback clips.
1188 * @dirty: The closure structure.
1190 * Commits a previously built command buffer of readback clips.
1192 static void vmw_sou_bo_fifo_commit(struct vmw_kms_dirty
*dirty
)
1194 if (!dirty
->num_hits
) {
1195 vmw_fifo_commit(dirty
->dev_priv
, 0);
1199 vmw_fifo_commit(dirty
->dev_priv
,
1200 sizeof(struct vmw_kms_sou_bo_blit
) *
1205 * vmw_sou_bo_clip - Callback to encode a readback cliprect.
1207 * @dirty: The closure structure
1209 * Encodes a BLIT_GMRFB_TO_SCREEN cliprect.
1211 static void vmw_sou_bo_clip(struct vmw_kms_dirty
*dirty
)
1213 struct vmw_kms_sou_bo_blit
*blit
= dirty
->cmd
;
1215 blit
+= dirty
->num_hits
;
1216 blit
->header
= SVGA_CMD_BLIT_GMRFB_TO_SCREEN
;
1217 blit
->body
.destScreenId
= dirty
->unit
->unit
;
1218 blit
->body
.srcOrigin
.x
= dirty
->fb_x
;
1219 blit
->body
.srcOrigin
.y
= dirty
->fb_y
;
1220 blit
->body
.destRect
.left
= dirty
->unit_x1
;
1221 blit
->body
.destRect
.top
= dirty
->unit_y1
;
1222 blit
->body
.destRect
.right
= dirty
->unit_x2
;
1223 blit
->body
.destRect
.bottom
= dirty
->unit_y2
;
1228 * vmw_kms_do_bo_dirty - Dirty part of a buffer-object backed framebuffer
1230 * @dev_priv: Pointer to the device private structure.
1231 * @framebuffer: Pointer to the buffer-object backed framebuffer.
1232 * @clips: Array of clip rects.
1233 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
1235 * @num_clips: Number of clip rects in @clips.
1236 * @increment: Increment to use when looping over @clips.
1237 * @interruptible: Whether to perform waits interruptible if possible.
1238 * @out_fence: If non-NULL, will return a ref-counted pointer to a
1239 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
1240 * case the device has already synchronized.
1241 * @crtc: If crtc is passed, perform bo dirty on that crtc only.
1243 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1246 int vmw_kms_sou_do_bo_dirty(struct vmw_private
*dev_priv
,
1247 struct vmw_framebuffer
*framebuffer
,
1248 struct drm_clip_rect
*clips
,
1249 struct drm_vmw_rect
*vclips
,
1250 unsigned num_clips
, int increment
,
1252 struct vmw_fence_obj
**out_fence
,
1253 struct drm_crtc
*crtc
)
1255 struct vmw_buffer_object
*buf
=
1256 container_of(framebuffer
, struct vmw_framebuffer_bo
,
1258 struct vmw_kms_dirty dirty
;
1259 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1262 ret
= vmw_validation_add_bo(&val_ctx
, buf
, false, false);
1266 ret
= vmw_validation_prepare(&val_ctx
, NULL
, interruptible
);
1270 ret
= do_bo_define_gmrfb(dev_priv
, framebuffer
);
1271 if (unlikely(ret
!= 0))
1275 dirty
.fifo_commit
= vmw_sou_bo_fifo_commit
;
1276 dirty
.clip
= vmw_sou_bo_clip
;
1277 dirty
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_bo_blit
) *
1279 ret
= vmw_kms_helper_dirty(dev_priv
, framebuffer
, clips
, vclips
,
1280 0, 0, num_clips
, increment
, &dirty
);
1281 vmw_kms_helper_validation_finish(dev_priv
, NULL
, &val_ctx
, out_fence
,
1287 vmw_validation_revert(&val_ctx
);
1289 vmw_validation_unref_lists(&val_ctx
);
1296 * vmw_sou_readback_fifo_commit - Callback to submit a set of readback clips.
1298 * @dirty: The closure structure.
1300 * Commits a previously built command buffer of readback clips.
1302 static void vmw_sou_readback_fifo_commit(struct vmw_kms_dirty
*dirty
)
1304 if (!dirty
->num_hits
) {
1305 vmw_fifo_commit(dirty
->dev_priv
, 0);
1309 vmw_fifo_commit(dirty
->dev_priv
,
1310 sizeof(struct vmw_kms_sou_readback_blit
) *
1315 * vmw_sou_readback_clip - Callback to encode a readback cliprect.
1317 * @dirty: The closure structure
1319 * Encodes a BLIT_SCREEN_TO_GMRFB cliprect.
1321 static void vmw_sou_readback_clip(struct vmw_kms_dirty
*dirty
)
1323 struct vmw_kms_sou_readback_blit
*blit
= dirty
->cmd
;
1325 blit
+= dirty
->num_hits
;
1326 blit
->header
= SVGA_CMD_BLIT_SCREEN_TO_GMRFB
;
1327 blit
->body
.srcScreenId
= dirty
->unit
->unit
;
1328 blit
->body
.destOrigin
.x
= dirty
->fb_x
;
1329 blit
->body
.destOrigin
.y
= dirty
->fb_y
;
1330 blit
->body
.srcRect
.left
= dirty
->unit_x1
;
1331 blit
->body
.srcRect
.top
= dirty
->unit_y1
;
1332 blit
->body
.srcRect
.right
= dirty
->unit_x2
;
1333 blit
->body
.srcRect
.bottom
= dirty
->unit_y2
;
1338 * vmw_kms_sou_readback - Perform a readback from the screen object system to
1339 * a buffer-object backed framebuffer.
1341 * @dev_priv: Pointer to the device private structure.
1342 * @file_priv: Pointer to a struct drm_file identifying the caller.
1343 * Must be set to NULL if @user_fence_rep is NULL.
1344 * @vfb: Pointer to the buffer-object backed framebuffer.
1345 * @user_fence_rep: User-space provided structure for fence information.
1346 * Must be set to non-NULL if @file_priv is non-NULL.
1347 * @vclips: Array of clip rects.
1348 * @num_clips: Number of clip rects in @vclips.
1349 * @crtc: If crtc is passed, readback on that crtc only.
1351 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1354 int vmw_kms_sou_readback(struct vmw_private
*dev_priv
,
1355 struct drm_file
*file_priv
,
1356 struct vmw_framebuffer
*vfb
,
1357 struct drm_vmw_fence_rep __user
*user_fence_rep
,
1358 struct drm_vmw_rect
*vclips
,
1360 struct drm_crtc
*crtc
)
1362 struct vmw_buffer_object
*buf
=
1363 container_of(vfb
, struct vmw_framebuffer_bo
, base
)->buffer
;
1364 struct vmw_kms_dirty dirty
;
1365 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1368 ret
= vmw_validation_add_bo(&val_ctx
, buf
, false, false);
1372 ret
= vmw_validation_prepare(&val_ctx
, NULL
, true);
1376 ret
= do_bo_define_gmrfb(dev_priv
, vfb
);
1377 if (unlikely(ret
!= 0))
1381 dirty
.fifo_commit
= vmw_sou_readback_fifo_commit
;
1382 dirty
.clip
= vmw_sou_readback_clip
;
1383 dirty
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_readback_blit
) *
1385 ret
= vmw_kms_helper_dirty(dev_priv
, vfb
, NULL
, vclips
,
1386 0, 0, num_clips
, 1, &dirty
);
1387 vmw_kms_helper_validation_finish(dev_priv
, file_priv
, &val_ctx
, NULL
,
1393 vmw_validation_revert(&val_ctx
);
1395 vmw_validation_unref_lists(&val_ctx
);