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 <drm/drm_atomic.h>
29 #include <drm/drm_atomic_helper.h>
30 #include <drm/drm_damage_helper.h>
31 #include <drm/drm_fourcc.h>
32 #include <drm/drm_plane_helper.h>
33 #include <drm/drm_vblank.h>
35 #include "vmwgfx_kms.h"
37 #define vmw_crtc_to_sou(x) \
38 container_of(x, struct vmw_screen_object_unit, base.crtc)
39 #define vmw_encoder_to_sou(x) \
40 container_of(x, struct vmw_screen_object_unit, base.encoder)
41 #define vmw_connector_to_sou(x) \
42 container_of(x, struct vmw_screen_object_unit, base.connector)
45 * struct vmw_kms_sou_surface_dirty - Closure structure for
46 * blit surface to screen command.
47 * @base: The base type we derive from. Used by vmw_kms_helper_dirty().
48 * @left: Left side of bounding box.
49 * @right: Right side of bounding box.
50 * @top: Top side of bounding box.
51 * @bottom: Bottom side of bounding box.
52 * @dst_x: Difference between source clip rects and framebuffer coordinates.
53 * @dst_y: Difference between source clip rects and framebuffer coordinates.
54 * @sid: Surface id of surface to copy from.
56 struct vmw_kms_sou_surface_dirty
{
57 struct vmw_kms_dirty base
;
58 s32 left
, right
, top
, bottom
;
64 * SVGA commands that are used by this code. Please see the device headers
67 struct vmw_kms_sou_readback_blit
{
69 SVGAFifoCmdBlitScreenToGMRFB body
;
72 struct vmw_kms_sou_bo_blit
{
74 SVGAFifoCmdBlitGMRFBToScreen body
;
77 struct vmw_kms_sou_dirty_cmd
{
78 SVGA3dCmdHeader header
;
79 SVGA3dCmdBlitSurfaceToScreen body
;
82 struct vmw_kms_sou_define_gmrfb
{
84 SVGAFifoCmdDefineGMRFB body
;
88 * Display unit using screen objects.
90 struct vmw_screen_object_unit
{
91 struct vmw_display_unit base
;
93 unsigned long buffer_size
; /**< Size of allocated buffer */
94 struct vmw_buffer_object
*buffer
; /**< Backing store buffer */
99 static void vmw_sou_destroy(struct vmw_screen_object_unit
*sou
)
101 vmw_du_cleanup(&sou
->base
);
107 * Screen Object Display Unit CRTC functions
110 static void vmw_sou_crtc_destroy(struct drm_crtc
*crtc
)
112 vmw_sou_destroy(vmw_crtc_to_sou(crtc
));
116 * Send the fifo command to create a screen.
118 static int vmw_sou_fifo_create(struct vmw_private
*dev_priv
,
119 struct vmw_screen_object_unit
*sou
,
121 struct drm_display_mode
*mode
)
129 SVGAScreenObject obj
;
132 BUG_ON(!sou
->buffer
);
134 fifo_size
= sizeof(*cmd
);
135 cmd
= VMW_FIFO_RESERVE(dev_priv
, fifo_size
);
136 if (unlikely(cmd
== NULL
))
139 memset(cmd
, 0, fifo_size
);
140 cmd
->header
.cmdType
= SVGA_CMD_DEFINE_SCREEN
;
141 cmd
->obj
.structSize
= sizeof(SVGAScreenObject
);
142 cmd
->obj
.id
= sou
->base
.unit
;
143 cmd
->obj
.flags
= SVGA_SCREEN_HAS_ROOT
|
144 (sou
->base
.unit
== 0 ? SVGA_SCREEN_IS_PRIMARY
: 0);
145 cmd
->obj
.size
.width
= mode
->hdisplay
;
146 cmd
->obj
.size
.height
= mode
->vdisplay
;
149 sou
->base
.set_gui_x
= cmd
->obj
.root
.x
;
150 sou
->base
.set_gui_y
= cmd
->obj
.root
.y
;
152 /* Ok to assume that buffer is pinned in vram */
153 vmw_bo_get_guest_ptr(&sou
->buffer
->base
, &cmd
->obj
.backingStore
.ptr
);
154 cmd
->obj
.backingStore
.pitch
= mode
->hdisplay
* 4;
156 vmw_fifo_commit(dev_priv
, fifo_size
);
164 * Send the fifo command to destroy a screen.
166 static int vmw_sou_fifo_destroy(struct vmw_private
*dev_priv
,
167 struct vmw_screen_object_unit
*sou
)
176 SVGAFifoCmdDestroyScreen body
;
179 /* no need to do anything */
180 if (unlikely(!sou
->defined
))
183 fifo_size
= sizeof(*cmd
);
184 cmd
= VMW_FIFO_RESERVE(dev_priv
, fifo_size
);
185 if (unlikely(cmd
== NULL
))
188 memset(cmd
, 0, fifo_size
);
189 cmd
->header
.cmdType
= SVGA_CMD_DESTROY_SCREEN
;
190 cmd
->body
.screenId
= sou
->base
.unit
;
192 vmw_fifo_commit(dev_priv
, fifo_size
);
195 ret
= vmw_fallback_wait(dev_priv
, false, true, 0, false, 3*HZ
);
196 if (unlikely(ret
!= 0))
197 DRM_ERROR("Failed to sync with HW");
199 sou
->defined
= false;
205 * vmw_sou_crtc_mode_set_nofb - Create new screen
207 * @crtc: CRTC associated with the new screen
209 * This function creates/destroys a screen. This function cannot fail, so if
210 * somehow we run into a failure, just do the best we can to get out.
212 static void vmw_sou_crtc_mode_set_nofb(struct drm_crtc
*crtc
)
214 struct vmw_private
*dev_priv
;
215 struct vmw_screen_object_unit
*sou
;
216 struct vmw_framebuffer
*vfb
;
217 struct drm_framebuffer
*fb
;
218 struct drm_plane_state
*ps
;
219 struct vmw_plane_state
*vps
;
222 sou
= vmw_crtc_to_sou(crtc
);
223 dev_priv
= vmw_priv(crtc
->dev
);
224 ps
= crtc
->primary
->state
;
226 vps
= vmw_plane_state_to_vps(ps
);
228 vfb
= (fb
) ? vmw_framebuffer_to_vfb(fb
) : NULL
;
231 ret
= vmw_sou_fifo_destroy(dev_priv
, sou
);
233 DRM_ERROR("Failed to destroy Screen Object\n");
239 struct drm_connector_state
*conn_state
;
240 struct vmw_connector_state
*vmw_conn_state
;
243 sou
->buffer
= vps
->bo
;
244 sou
->buffer_size
= vps
->bo_size
;
246 conn_state
= sou
->base
.connector
.state
;
247 vmw_conn_state
= vmw_connector_state_to_vcs(conn_state
);
249 x
= vmw_conn_state
->gui_x
;
250 y
= vmw_conn_state
->gui_y
;
252 ret
= vmw_sou_fifo_create(dev_priv
, sou
, x
, y
, &crtc
->mode
);
254 DRM_ERROR("Failed to define Screen Object %dx%d\n",
259 sou
->buffer_size
= 0;
264 * vmw_sou_crtc_helper_prepare - Noop
266 * @crtc: CRTC associated with the new screen
268 * Prepares the CRTC for a mode set, but we don't need to do anything here.
270 static void vmw_sou_crtc_helper_prepare(struct drm_crtc
*crtc
)
275 * vmw_sou_crtc_atomic_enable - Noop
277 * @crtc: CRTC associated with the new screen
279 * This is called after a mode set has been completed.
281 static void vmw_sou_crtc_atomic_enable(struct drm_crtc
*crtc
,
282 struct drm_crtc_state
*old_state
)
287 * vmw_sou_crtc_atomic_disable - Turns off CRTC
289 * @crtc: CRTC to be turned off
291 static void vmw_sou_crtc_atomic_disable(struct drm_crtc
*crtc
,
292 struct drm_crtc_state
*old_state
)
294 struct vmw_private
*dev_priv
;
295 struct vmw_screen_object_unit
*sou
;
300 DRM_ERROR("CRTC is NULL\n");
304 sou
= vmw_crtc_to_sou(crtc
);
305 dev_priv
= vmw_priv(crtc
->dev
);
308 ret
= vmw_sou_fifo_destroy(dev_priv
, sou
);
310 DRM_ERROR("Failed to destroy Screen Object\n");
314 static const struct drm_crtc_funcs vmw_screen_object_crtc_funcs
= {
315 .gamma_set
= vmw_du_crtc_gamma_set
,
316 .destroy
= vmw_sou_crtc_destroy
,
317 .reset
= vmw_du_crtc_reset
,
318 .atomic_duplicate_state
= vmw_du_crtc_duplicate_state
,
319 .atomic_destroy_state
= vmw_du_crtc_destroy_state
,
320 .set_config
= drm_atomic_helper_set_config
,
321 .page_flip
= drm_atomic_helper_page_flip
,
325 * Screen Object Display Unit encoder functions
328 static void vmw_sou_encoder_destroy(struct drm_encoder
*encoder
)
330 vmw_sou_destroy(vmw_encoder_to_sou(encoder
));
333 static const struct drm_encoder_funcs vmw_screen_object_encoder_funcs
= {
334 .destroy
= vmw_sou_encoder_destroy
,
338 * Screen Object Display Unit connector functions
341 static void vmw_sou_connector_destroy(struct drm_connector
*connector
)
343 vmw_sou_destroy(vmw_connector_to_sou(connector
));
346 static const struct drm_connector_funcs vmw_sou_connector_funcs
= {
347 .dpms
= vmw_du_connector_dpms
,
348 .detect
= vmw_du_connector_detect
,
349 .fill_modes
= vmw_du_connector_fill_modes
,
350 .destroy
= vmw_sou_connector_destroy
,
351 .reset
= vmw_du_connector_reset
,
352 .atomic_duplicate_state
= vmw_du_connector_duplicate_state
,
353 .atomic_destroy_state
= vmw_du_connector_destroy_state
,
358 drm_connector_helper_funcs vmw_sou_connector_helper_funcs
= {
364 * Screen Object Display Plane Functions
368 * vmw_sou_primary_plane_cleanup_fb - Frees sou backing buffer
370 * @plane: display plane
371 * @old_state: Contains the FB to clean up
373 * Unpins the display surface
375 * Returns 0 on success
378 vmw_sou_primary_plane_cleanup_fb(struct drm_plane
*plane
,
379 struct drm_plane_state
*old_state
)
381 struct vmw_plane_state
*vps
= vmw_plane_state_to_vps(old_state
);
382 struct drm_crtc
*crtc
= plane
->state
->crtc
?
383 plane
->state
->crtc
: old_state
->crtc
;
386 vmw_bo_unpin(vmw_priv(crtc
->dev
), vps
->bo
, false);
387 vmw_bo_unreference(&vps
->bo
);
390 vmw_du_plane_cleanup_fb(plane
, old_state
);
395 * vmw_sou_primary_plane_prepare_fb - allocate backing buffer
397 * @plane: display plane
398 * @new_state: info on the new plane state, including the FB
400 * The SOU backing buffer is our equivalent of the display plane.
402 * Returns 0 on success
405 vmw_sou_primary_plane_prepare_fb(struct drm_plane
*plane
,
406 struct drm_plane_state
*new_state
)
408 struct drm_framebuffer
*new_fb
= new_state
->fb
;
409 struct drm_crtc
*crtc
= plane
->state
->crtc
?: new_state
->crtc
;
410 struct vmw_plane_state
*vps
= vmw_plane_state_to_vps(new_state
);
411 struct vmw_private
*dev_priv
;
417 vmw_bo_unreference(&vps
->bo
);
423 size
= new_state
->crtc_w
* new_state
->crtc_h
* 4;
424 dev_priv
= vmw_priv(crtc
->dev
);
427 if (vps
->bo_size
== size
) {
429 * Note that this might temporarily up the pin-count
430 * to 2, until cleanup_fb() is called.
432 return vmw_bo_pin_in_vram(dev_priv
, vps
->bo
,
436 vmw_bo_unreference(&vps
->bo
);
440 vps
->bo
= kzalloc(sizeof(*vps
->bo
), GFP_KERNEL
);
444 vmw_svga_enable(dev_priv
);
446 /* After we have alloced the backing store might not be able to
447 * resume the overlays, this is preferred to failing to alloc.
449 vmw_overlay_pause_all(dev_priv
);
450 ret
= vmw_bo_init(dev_priv
, vps
->bo
, size
,
451 &vmw_vram_ne_placement
,
452 false, &vmw_bo_bo_free
);
453 vmw_overlay_resume_all(dev_priv
);
455 vps
->bo
= NULL
; /* vmw_bo_init frees on error */
462 * TTM already thinks the buffer is pinned, but make sure the
463 * pin_count is upped.
465 return vmw_bo_pin_in_vram(dev_priv
, vps
->bo
, true);
468 static uint32_t vmw_sou_bo_fifo_size(struct vmw_du_update_plane
*update
,
471 return sizeof(struct vmw_kms_sou_define_gmrfb
) +
472 sizeof(struct vmw_kms_sou_bo_blit
) * num_hits
;
475 static uint32_t vmw_sou_bo_define_gmrfb(struct vmw_du_update_plane
*update
,
478 struct vmw_framebuffer_bo
*vfbbo
=
479 container_of(update
->vfb
, typeof(*vfbbo
), base
);
480 struct vmw_kms_sou_define_gmrfb
*gmr
= cmd
;
481 int depth
= update
->vfb
->base
.format
->depth
;
483 /* Emulate RGBA support, contrary to svga_reg.h this is not
484 * supported by hosts. This is only a problem if we are reading
485 * this value later and expecting what we uploaded back.
490 gmr
->header
= SVGA_CMD_DEFINE_GMRFB
;
492 gmr
->body
.format
.bitsPerPixel
= update
->vfb
->base
.format
->cpp
[0] * 8;
493 gmr
->body
.format
.colorDepth
= depth
;
494 gmr
->body
.format
.reserved
= 0;
495 gmr
->body
.bytesPerLine
= update
->vfb
->base
.pitches
[0];
496 vmw_bo_get_guest_ptr(&vfbbo
->buffer
->base
, &gmr
->body
.ptr
);
501 static uint32_t vmw_sou_bo_populate_clip(struct vmw_du_update_plane
*update
,
502 void *cmd
, struct drm_rect
*clip
,
503 uint32_t fb_x
, uint32_t fb_y
)
505 struct vmw_kms_sou_bo_blit
*blit
= cmd
;
507 blit
->header
= SVGA_CMD_BLIT_GMRFB_TO_SCREEN
;
508 blit
->body
.destScreenId
= update
->du
->unit
;
509 blit
->body
.srcOrigin
.x
= fb_x
;
510 blit
->body
.srcOrigin
.y
= fb_y
;
511 blit
->body
.destRect
.left
= clip
->x1
;
512 blit
->body
.destRect
.top
= clip
->y1
;
513 blit
->body
.destRect
.right
= clip
->x2
;
514 blit
->body
.destRect
.bottom
= clip
->y2
;
516 return sizeof(*blit
);
519 static uint32_t vmw_stud_bo_post_clip(struct vmw_du_update_plane
*update
,
520 void *cmd
, struct drm_rect
*bb
)
526 * vmw_sou_plane_update_bo - Update display unit for bo backed fb.
527 * @dev_priv: Device private.
528 * @plane: Plane state.
529 * @old_state: Old plane state.
530 * @vfb: Framebuffer which is blitted to display unit.
531 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
532 * The returned fence pointer may be NULL in which case the device
533 * has already synchronized.
535 * Return: 0 on success or a negative error code on failure.
537 static int vmw_sou_plane_update_bo(struct vmw_private
*dev_priv
,
538 struct drm_plane
*plane
,
539 struct drm_plane_state
*old_state
,
540 struct vmw_framebuffer
*vfb
,
541 struct vmw_fence_obj
**out_fence
)
543 struct vmw_du_update_plane_buffer bo_update
;
545 memset(&bo_update
, 0, sizeof(struct vmw_du_update_plane_buffer
));
546 bo_update
.base
.plane
= plane
;
547 bo_update
.base
.old_state
= old_state
;
548 bo_update
.base
.dev_priv
= dev_priv
;
549 bo_update
.base
.du
= vmw_crtc_to_du(plane
->state
->crtc
);
550 bo_update
.base
.vfb
= vfb
;
551 bo_update
.base
.out_fence
= out_fence
;
552 bo_update
.base
.mutex
= NULL
;
553 bo_update
.base
.cpu_blit
= false;
554 bo_update
.base
.intr
= true;
556 bo_update
.base
.calc_fifo_size
= vmw_sou_bo_fifo_size
;
557 bo_update
.base
.post_prepare
= vmw_sou_bo_define_gmrfb
;
558 bo_update
.base
.clip
= vmw_sou_bo_populate_clip
;
559 bo_update
.base
.post_clip
= vmw_stud_bo_post_clip
;
561 return vmw_du_helper_plane_update(&bo_update
.base
);
564 static uint32_t vmw_sou_surface_fifo_size(struct vmw_du_update_plane
*update
,
567 return sizeof(struct vmw_kms_sou_dirty_cmd
) + sizeof(SVGASignedRect
) *
571 static uint32_t vmw_sou_surface_post_prepare(struct vmw_du_update_plane
*update
,
574 struct vmw_du_update_plane_surface
*srf_update
;
576 srf_update
= container_of(update
, typeof(*srf_update
), base
);
579 * SOU SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN is special in the sense that
580 * its bounding box is filled before iterating over all the clips. So
581 * store the FIFO start address and revisit to fill the details.
583 srf_update
->cmd_start
= cmd
;
588 static uint32_t vmw_sou_surface_pre_clip(struct vmw_du_update_plane
*update
,
589 void *cmd
, uint32_t num_hits
)
591 struct vmw_kms_sou_dirty_cmd
*blit
= cmd
;
592 struct vmw_framebuffer_surface
*vfbs
;
594 vfbs
= container_of(update
->vfb
, typeof(*vfbs
), base
);
596 blit
->header
.id
= SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN
;
597 blit
->header
.size
= sizeof(blit
->body
) + sizeof(SVGASignedRect
) *
600 blit
->body
.srcImage
.sid
= vfbs
->surface
->res
.id
;
601 blit
->body
.destScreenId
= update
->du
->unit
;
603 /* Update the source and destination bounding box later in post_clip */
604 blit
->body
.srcRect
.left
= 0;
605 blit
->body
.srcRect
.top
= 0;
606 blit
->body
.srcRect
.right
= 0;
607 blit
->body
.srcRect
.bottom
= 0;
609 blit
->body
.destRect
.left
= 0;
610 blit
->body
.destRect
.top
= 0;
611 blit
->body
.destRect
.right
= 0;
612 blit
->body
.destRect
.bottom
= 0;
614 return sizeof(*blit
);
617 static uint32_t vmw_sou_surface_clip_rect(struct vmw_du_update_plane
*update
,
618 void *cmd
, struct drm_rect
*clip
,
619 uint32_t src_x
, uint32_t src_y
)
621 SVGASignedRect
*rect
= cmd
;
624 * rects are relative to dest bounding box rect on screen object, so
625 * translate to it later in post_clip
627 rect
->left
= clip
->x1
;
628 rect
->top
= clip
->y1
;
629 rect
->right
= clip
->x2
;
630 rect
->bottom
= clip
->y2
;
632 return sizeof(*rect
);
635 static uint32_t vmw_sou_surface_post_clip(struct vmw_du_update_plane
*update
,
636 void *cmd
, struct drm_rect
*bb
)
638 struct vmw_du_update_plane_surface
*srf_update
;
639 struct drm_plane_state
*state
= update
->plane
->state
;
640 struct drm_rect src_bb
;
641 struct vmw_kms_sou_dirty_cmd
*blit
;
642 SVGASignedRect
*rect
;
648 srf_update
= container_of(update
, typeof(*srf_update
), base
);
650 blit
= srf_update
->cmd_start
;
651 rect
= (SVGASignedRect
*)&blit
[1];
653 num_hits
= (blit
->header
.size
- sizeof(blit
->body
))/
654 sizeof(SVGASignedRect
);
658 /* To translate bb back to fb src coord */
659 translate_src_x
= (state
->src_x
>> 16) - state
->crtc_x
;
660 translate_src_y
= (state
->src_y
>> 16) - state
->crtc_y
;
662 drm_rect_translate(&src_bb
, translate_src_x
, translate_src_y
);
664 blit
->body
.srcRect
.left
= src_bb
.x1
;
665 blit
->body
.srcRect
.top
= src_bb
.y1
;
666 blit
->body
.srcRect
.right
= src_bb
.x2
;
667 blit
->body
.srcRect
.bottom
= src_bb
.y2
;
669 blit
->body
.destRect
.left
= bb
->x1
;
670 blit
->body
.destRect
.top
= bb
->y1
;
671 blit
->body
.destRect
.right
= bb
->x2
;
672 blit
->body
.destRect
.bottom
= bb
->y2
;
674 /* rects are relative to dest bb rect */
675 for (i
= 0; i
< num_hits
; i
++) {
676 rect
->left
-= bb
->x1
;
678 rect
->right
-= bb
->x1
;
679 rect
->bottom
-= bb
->y1
;
687 * vmw_sou_plane_update_surface - Update display unit for surface backed fb.
688 * @dev_priv: Device private.
689 * @plane: Plane state.
690 * @old_state: Old plane state.
691 * @vfb: Framebuffer which is blitted to display unit
692 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
693 * The returned fence pointer may be NULL in which case the device
694 * has already synchronized.
696 * Return: 0 on success or a negative error code on failure.
698 static int vmw_sou_plane_update_surface(struct vmw_private
*dev_priv
,
699 struct drm_plane
*plane
,
700 struct drm_plane_state
*old_state
,
701 struct vmw_framebuffer
*vfb
,
702 struct vmw_fence_obj
**out_fence
)
704 struct vmw_du_update_plane_surface srf_update
;
706 memset(&srf_update
, 0, sizeof(struct vmw_du_update_plane_surface
));
707 srf_update
.base
.plane
= plane
;
708 srf_update
.base
.old_state
= old_state
;
709 srf_update
.base
.dev_priv
= dev_priv
;
710 srf_update
.base
.du
= vmw_crtc_to_du(plane
->state
->crtc
);
711 srf_update
.base
.vfb
= vfb
;
712 srf_update
.base
.out_fence
= out_fence
;
713 srf_update
.base
.mutex
= &dev_priv
->cmdbuf_mutex
;
714 srf_update
.base
.cpu_blit
= false;
715 srf_update
.base
.intr
= true;
717 srf_update
.base
.calc_fifo_size
= vmw_sou_surface_fifo_size
;
718 srf_update
.base
.post_prepare
= vmw_sou_surface_post_prepare
;
719 srf_update
.base
.pre_clip
= vmw_sou_surface_pre_clip
;
720 srf_update
.base
.clip
= vmw_sou_surface_clip_rect
;
721 srf_update
.base
.post_clip
= vmw_sou_surface_post_clip
;
723 return vmw_du_helper_plane_update(&srf_update
.base
);
727 vmw_sou_primary_plane_atomic_update(struct drm_plane
*plane
,
728 struct drm_plane_state
*old_state
)
730 struct drm_crtc
*crtc
= plane
->state
->crtc
;
731 struct drm_pending_vblank_event
*event
= NULL
;
732 struct vmw_fence_obj
*fence
= NULL
;
735 /* In case of device error, maintain consistent atomic state */
736 if (crtc
&& plane
->state
->fb
) {
737 struct vmw_private
*dev_priv
= vmw_priv(crtc
->dev
);
738 struct vmw_framebuffer
*vfb
=
739 vmw_framebuffer_to_vfb(plane
->state
->fb
);
742 ret
= vmw_sou_plane_update_bo(dev_priv
, plane
,
743 old_state
, vfb
, &fence
);
745 ret
= vmw_sou_plane_update_surface(dev_priv
, plane
,
749 DRM_ERROR("Failed to update screen.\n");
751 /* Do nothing when fb and crtc is NULL (blank crtc) */
755 /* For error case vblank event is send from vmw_du_crtc_atomic_flush */
756 event
= crtc
->state
->event
;
757 if (event
&& fence
) {
758 struct drm_file
*file_priv
= event
->base
.file_priv
;
760 ret
= vmw_event_fence_action_queue(file_priv
,
763 &event
->event
.vbl
.tv_sec
,
764 &event
->event
.vbl
.tv_usec
,
767 if (unlikely(ret
!= 0))
768 DRM_ERROR("Failed to queue event on fence.\n");
770 crtc
->state
->event
= NULL
;
774 vmw_fence_obj_unreference(&fence
);
778 static const struct drm_plane_funcs vmw_sou_plane_funcs
= {
779 .update_plane
= drm_atomic_helper_update_plane
,
780 .disable_plane
= drm_atomic_helper_disable_plane
,
781 .destroy
= vmw_du_primary_plane_destroy
,
782 .reset
= vmw_du_plane_reset
,
783 .atomic_duplicate_state
= vmw_du_plane_duplicate_state
,
784 .atomic_destroy_state
= vmw_du_plane_destroy_state
,
787 static const struct drm_plane_funcs vmw_sou_cursor_funcs
= {
788 .update_plane
= drm_atomic_helper_update_plane
,
789 .disable_plane
= drm_atomic_helper_disable_plane
,
790 .destroy
= vmw_du_cursor_plane_destroy
,
791 .reset
= vmw_du_plane_reset
,
792 .atomic_duplicate_state
= vmw_du_plane_duplicate_state
,
793 .atomic_destroy_state
= vmw_du_plane_destroy_state
,
800 drm_plane_helper_funcs vmw_sou_cursor_plane_helper_funcs
= {
801 .atomic_check
= vmw_du_cursor_plane_atomic_check
,
802 .atomic_update
= vmw_du_cursor_plane_atomic_update
,
803 .prepare_fb
= vmw_du_cursor_plane_prepare_fb
,
804 .cleanup_fb
= vmw_du_plane_cleanup_fb
,
808 drm_plane_helper_funcs vmw_sou_primary_plane_helper_funcs
= {
809 .atomic_check
= vmw_du_primary_plane_atomic_check
,
810 .atomic_update
= vmw_sou_primary_plane_atomic_update
,
811 .prepare_fb
= vmw_sou_primary_plane_prepare_fb
,
812 .cleanup_fb
= vmw_sou_primary_plane_cleanup_fb
,
815 static const struct drm_crtc_helper_funcs vmw_sou_crtc_helper_funcs
= {
816 .prepare
= vmw_sou_crtc_helper_prepare
,
817 .mode_set_nofb
= vmw_sou_crtc_mode_set_nofb
,
818 .atomic_check
= vmw_du_crtc_atomic_check
,
819 .atomic_begin
= vmw_du_crtc_atomic_begin
,
820 .atomic_flush
= vmw_du_crtc_atomic_flush
,
821 .atomic_enable
= vmw_sou_crtc_atomic_enable
,
822 .atomic_disable
= vmw_sou_crtc_atomic_disable
,
826 static int vmw_sou_init(struct vmw_private
*dev_priv
, unsigned unit
)
828 struct vmw_screen_object_unit
*sou
;
829 struct drm_device
*dev
= dev_priv
->dev
;
830 struct drm_connector
*connector
;
831 struct drm_encoder
*encoder
;
832 struct drm_plane
*primary
, *cursor
;
833 struct drm_crtc
*crtc
;
836 sou
= kzalloc(sizeof(*sou
), GFP_KERNEL
);
840 sou
->base
.unit
= unit
;
841 crtc
= &sou
->base
.crtc
;
842 encoder
= &sou
->base
.encoder
;
843 connector
= &sou
->base
.connector
;
844 primary
= &sou
->base
.primary
;
845 cursor
= &sou
->base
.cursor
;
847 sou
->base
.pref_active
= (unit
== 0);
848 sou
->base
.pref_width
= dev_priv
->initial_width
;
849 sou
->base
.pref_height
= dev_priv
->initial_height
;
850 sou
->base
.pref_mode
= NULL
;
853 * Remove this after enabling atomic because property values can
854 * only exist in a state object
856 sou
->base
.is_implicit
= false;
858 /* Initialize primary plane */
859 vmw_du_plane_reset(primary
);
861 ret
= drm_universal_plane_init(dev
, &sou
->base
.primary
,
862 0, &vmw_sou_plane_funcs
,
863 vmw_primary_plane_formats
,
864 ARRAY_SIZE(vmw_primary_plane_formats
),
865 NULL
, DRM_PLANE_TYPE_PRIMARY
, NULL
);
867 DRM_ERROR("Failed to initialize primary plane");
871 drm_plane_helper_add(primary
, &vmw_sou_primary_plane_helper_funcs
);
872 drm_plane_enable_fb_damage_clips(primary
);
874 /* Initialize cursor plane */
875 vmw_du_plane_reset(cursor
);
877 ret
= drm_universal_plane_init(dev
, &sou
->base
.cursor
,
878 0, &vmw_sou_cursor_funcs
,
879 vmw_cursor_plane_formats
,
880 ARRAY_SIZE(vmw_cursor_plane_formats
),
881 NULL
, DRM_PLANE_TYPE_CURSOR
, NULL
);
883 DRM_ERROR("Failed to initialize cursor plane");
884 drm_plane_cleanup(&sou
->base
.primary
);
888 drm_plane_helper_add(cursor
, &vmw_sou_cursor_plane_helper_funcs
);
890 vmw_du_connector_reset(connector
);
891 ret
= drm_connector_init(dev
, connector
, &vmw_sou_connector_funcs
,
892 DRM_MODE_CONNECTOR_VIRTUAL
);
894 DRM_ERROR("Failed to initialize connector\n");
898 drm_connector_helper_add(connector
, &vmw_sou_connector_helper_funcs
);
899 connector
->status
= vmw_du_connector_detect(connector
, true);
901 ret
= drm_encoder_init(dev
, encoder
, &vmw_screen_object_encoder_funcs
,
902 DRM_MODE_ENCODER_VIRTUAL
, NULL
);
904 DRM_ERROR("Failed to initialize encoder\n");
905 goto err_free_connector
;
908 (void) drm_connector_attach_encoder(connector
, encoder
);
909 encoder
->possible_crtcs
= (1 << unit
);
910 encoder
->possible_clones
= 0;
912 ret
= drm_connector_register(connector
);
914 DRM_ERROR("Failed to register connector\n");
915 goto err_free_encoder
;
919 vmw_du_crtc_reset(crtc
);
920 ret
= drm_crtc_init_with_planes(dev
, crtc
, &sou
->base
.primary
,
922 &vmw_screen_object_crtc_funcs
, NULL
);
924 DRM_ERROR("Failed to initialize CRTC\n");
925 goto err_free_unregister
;
928 drm_crtc_helper_add(crtc
, &vmw_sou_crtc_helper_funcs
);
930 drm_mode_crtc_set_gamma_size(crtc
, 256);
932 drm_object_attach_property(&connector
->base
,
933 dev_priv
->hotplug_mode_update_property
, 1);
934 drm_object_attach_property(&connector
->base
,
935 dev
->mode_config
.suggested_x_property
, 0);
936 drm_object_attach_property(&connector
->base
,
937 dev
->mode_config
.suggested_y_property
, 0);
941 drm_connector_unregister(connector
);
943 drm_encoder_cleanup(encoder
);
945 drm_connector_cleanup(connector
);
951 int vmw_kms_sou_init_display(struct vmw_private
*dev_priv
)
953 struct drm_device
*dev
= dev_priv
->dev
;
956 if (!(dev_priv
->capabilities
& SVGA_CAP_SCREEN_OBJECT_2
)) {
957 DRM_INFO("Not using screen objects,"
958 " missing cap SCREEN_OBJECT_2\n");
964 ret
= drm_vblank_init(dev
, VMWGFX_NUM_DISPLAY_UNITS
);
965 if (unlikely(ret
!= 0))
968 for (i
= 0; i
< VMWGFX_NUM_DISPLAY_UNITS
; ++i
)
969 vmw_sou_init(dev_priv
, i
);
971 dev_priv
->active_display_unit
= vmw_du_screen_object
;
973 DRM_INFO("Screen Objects Display Unit initialized\n");
978 static int do_bo_define_gmrfb(struct vmw_private
*dev_priv
,
979 struct vmw_framebuffer
*framebuffer
)
981 struct vmw_buffer_object
*buf
=
982 container_of(framebuffer
, struct vmw_framebuffer_bo
,
984 int depth
= framebuffer
->base
.format
->depth
;
987 SVGAFifoCmdDefineGMRFB body
;
990 /* Emulate RGBA support, contrary to svga_reg.h this is not
991 * supported by hosts. This is only a problem if we are reading
992 * this value later and expecting what we uploaded back.
997 cmd
= VMW_FIFO_RESERVE(dev_priv
, sizeof(*cmd
));
1001 cmd
->header
= SVGA_CMD_DEFINE_GMRFB
;
1002 cmd
->body
.format
.bitsPerPixel
= framebuffer
->base
.format
->cpp
[0] * 8;
1003 cmd
->body
.format
.colorDepth
= depth
;
1004 cmd
->body
.format
.reserved
= 0;
1005 cmd
->body
.bytesPerLine
= framebuffer
->base
.pitches
[0];
1006 /* Buffer is reserved in vram or GMR */
1007 vmw_bo_get_guest_ptr(&buf
->base
, &cmd
->body
.ptr
);
1008 vmw_fifo_commit(dev_priv
, sizeof(*cmd
));
1014 * vmw_sou_surface_fifo_commit - Callback to fill in and submit a
1015 * blit surface to screen command.
1017 * @dirty: The closure structure.
1019 * Fills in the missing fields in the command, and translates the cliprects
1020 * to match the destination bounding box encoded.
1022 static void vmw_sou_surface_fifo_commit(struct vmw_kms_dirty
*dirty
)
1024 struct vmw_kms_sou_surface_dirty
*sdirty
=
1025 container_of(dirty
, typeof(*sdirty
), base
);
1026 struct vmw_kms_sou_dirty_cmd
*cmd
= dirty
->cmd
;
1027 s32 trans_x
= dirty
->unit
->crtc
.x
- sdirty
->dst_x
;
1028 s32 trans_y
= dirty
->unit
->crtc
.y
- sdirty
->dst_y
;
1029 size_t region_size
= dirty
->num_hits
* sizeof(SVGASignedRect
);
1030 SVGASignedRect
*blit
= (SVGASignedRect
*) &cmd
[1];
1033 if (!dirty
->num_hits
) {
1034 vmw_fifo_commit(dirty
->dev_priv
, 0);
1038 cmd
->header
.id
= SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN
;
1039 cmd
->header
.size
= sizeof(cmd
->body
) + region_size
;
1042 * Use the destination bounding box to specify destination - and
1043 * source bounding regions.
1045 cmd
->body
.destRect
.left
= sdirty
->left
;
1046 cmd
->body
.destRect
.right
= sdirty
->right
;
1047 cmd
->body
.destRect
.top
= sdirty
->top
;
1048 cmd
->body
.destRect
.bottom
= sdirty
->bottom
;
1050 cmd
->body
.srcRect
.left
= sdirty
->left
+ trans_x
;
1051 cmd
->body
.srcRect
.right
= sdirty
->right
+ trans_x
;
1052 cmd
->body
.srcRect
.top
= sdirty
->top
+ trans_y
;
1053 cmd
->body
.srcRect
.bottom
= sdirty
->bottom
+ trans_y
;
1055 cmd
->body
.srcImage
.sid
= sdirty
->sid
;
1056 cmd
->body
.destScreenId
= dirty
->unit
->unit
;
1058 /* Blits are relative to the destination rect. Translate. */
1059 for (i
= 0; i
< dirty
->num_hits
; ++i
, ++blit
) {
1060 blit
->left
-= sdirty
->left
;
1061 blit
->right
-= sdirty
->left
;
1062 blit
->top
-= sdirty
->top
;
1063 blit
->bottom
-= sdirty
->top
;
1066 vmw_fifo_commit(dirty
->dev_priv
, region_size
+ sizeof(*cmd
));
1068 sdirty
->left
= sdirty
->top
= S32_MAX
;
1069 sdirty
->right
= sdirty
->bottom
= S32_MIN
;
1073 * vmw_sou_surface_clip - Callback to encode a blit surface to screen cliprect.
1075 * @dirty: The closure structure
1077 * Encodes a SVGASignedRect cliprect and updates the bounding box of the
1078 * BLIT_SURFACE_TO_SCREEN command.
1080 static void vmw_sou_surface_clip(struct vmw_kms_dirty
*dirty
)
1082 struct vmw_kms_sou_surface_dirty
*sdirty
=
1083 container_of(dirty
, typeof(*sdirty
), base
);
1084 struct vmw_kms_sou_dirty_cmd
*cmd
= dirty
->cmd
;
1085 SVGASignedRect
*blit
= (SVGASignedRect
*) &cmd
[1];
1087 /* Destination rect. */
1088 blit
+= dirty
->num_hits
;
1089 blit
->left
= dirty
->unit_x1
;
1090 blit
->top
= dirty
->unit_y1
;
1091 blit
->right
= dirty
->unit_x2
;
1092 blit
->bottom
= dirty
->unit_y2
;
1094 /* Destination bounding box */
1095 sdirty
->left
= min_t(s32
, sdirty
->left
, dirty
->unit_x1
);
1096 sdirty
->top
= min_t(s32
, sdirty
->top
, dirty
->unit_y1
);
1097 sdirty
->right
= max_t(s32
, sdirty
->right
, dirty
->unit_x2
);
1098 sdirty
->bottom
= max_t(s32
, sdirty
->bottom
, dirty
->unit_y2
);
1104 * vmw_kms_sou_do_surface_dirty - Dirty part of a surface backed framebuffer
1106 * @dev_priv: Pointer to the device private structure.
1107 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
1108 * @clips: Array of clip rects. Either @clips or @vclips must be NULL.
1109 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
1111 * @srf: Pointer to surface to blit from. If NULL, the surface attached
1112 * to @framebuffer will be used.
1113 * @dest_x: X coordinate offset to align @srf with framebuffer coordinates.
1114 * @dest_y: Y coordinate offset to align @srf with framebuffer coordinates.
1115 * @num_clips: Number of clip rects in @clips.
1116 * @inc: Increment to use when looping over @clips.
1117 * @out_fence: If non-NULL, will return a ref-counted pointer to a
1118 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
1119 * case the device has already synchronized.
1120 * @crtc: If crtc is passed, perform surface dirty on that crtc only.
1122 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1125 int vmw_kms_sou_do_surface_dirty(struct vmw_private
*dev_priv
,
1126 struct vmw_framebuffer
*framebuffer
,
1127 struct drm_clip_rect
*clips
,
1128 struct drm_vmw_rect
*vclips
,
1129 struct vmw_resource
*srf
,
1132 unsigned num_clips
, int inc
,
1133 struct vmw_fence_obj
**out_fence
,
1134 struct drm_crtc
*crtc
)
1136 struct vmw_framebuffer_surface
*vfbs
=
1137 container_of(framebuffer
, typeof(*vfbs
), base
);
1138 struct vmw_kms_sou_surface_dirty sdirty
;
1139 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1143 srf
= &vfbs
->surface
->res
;
1145 ret
= vmw_validation_add_resource(&val_ctx
, srf
, 0, VMW_RES_DIRTY_NONE
,
1150 ret
= vmw_validation_prepare(&val_ctx
, &dev_priv
->cmdbuf_mutex
, true);
1154 sdirty
.base
.fifo_commit
= vmw_sou_surface_fifo_commit
;
1155 sdirty
.base
.clip
= vmw_sou_surface_clip
;
1156 sdirty
.base
.dev_priv
= dev_priv
;
1157 sdirty
.base
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_dirty_cmd
) +
1158 sizeof(SVGASignedRect
) * num_clips
;
1159 sdirty
.base
.crtc
= crtc
;
1161 sdirty
.sid
= srf
->id
;
1162 sdirty
.left
= sdirty
.top
= S32_MAX
;
1163 sdirty
.right
= sdirty
.bottom
= S32_MIN
;
1164 sdirty
.dst_x
= dest_x
;
1165 sdirty
.dst_y
= dest_y
;
1167 ret
= vmw_kms_helper_dirty(dev_priv
, framebuffer
, clips
, vclips
,
1168 dest_x
, dest_y
, num_clips
, inc
,
1170 vmw_kms_helper_validation_finish(dev_priv
, NULL
, &val_ctx
, out_fence
,
1176 vmw_validation_unref_lists(&val_ctx
);
1181 * vmw_sou_bo_fifo_commit - Callback to submit a set of readback clips.
1183 * @dirty: The closure structure.
1185 * Commits a previously built command buffer of readback clips.
1187 static void vmw_sou_bo_fifo_commit(struct vmw_kms_dirty
*dirty
)
1189 if (!dirty
->num_hits
) {
1190 vmw_fifo_commit(dirty
->dev_priv
, 0);
1194 vmw_fifo_commit(dirty
->dev_priv
,
1195 sizeof(struct vmw_kms_sou_bo_blit
) *
1200 * vmw_sou_bo_clip - Callback to encode a readback cliprect.
1202 * @dirty: The closure structure
1204 * Encodes a BLIT_GMRFB_TO_SCREEN cliprect.
1206 static void vmw_sou_bo_clip(struct vmw_kms_dirty
*dirty
)
1208 struct vmw_kms_sou_bo_blit
*blit
= dirty
->cmd
;
1210 blit
+= dirty
->num_hits
;
1211 blit
->header
= SVGA_CMD_BLIT_GMRFB_TO_SCREEN
;
1212 blit
->body
.destScreenId
= dirty
->unit
->unit
;
1213 blit
->body
.srcOrigin
.x
= dirty
->fb_x
;
1214 blit
->body
.srcOrigin
.y
= dirty
->fb_y
;
1215 blit
->body
.destRect
.left
= dirty
->unit_x1
;
1216 blit
->body
.destRect
.top
= dirty
->unit_y1
;
1217 blit
->body
.destRect
.right
= dirty
->unit_x2
;
1218 blit
->body
.destRect
.bottom
= dirty
->unit_y2
;
1223 * vmw_kms_do_bo_dirty - Dirty part of a buffer-object backed framebuffer
1225 * @dev_priv: Pointer to the device private structure.
1226 * @framebuffer: Pointer to the buffer-object backed framebuffer.
1227 * @clips: Array of clip rects.
1228 * @vclips: Alternate array of clip rects. Either @clips or @vclips must
1230 * @num_clips: Number of clip rects in @clips.
1231 * @increment: Increment to use when looping over @clips.
1232 * @interruptible: Whether to perform waits interruptible if possible.
1233 * @out_fence: If non-NULL, will return a ref-counted pointer to a
1234 * struct vmw_fence_obj. The returned fence pointer may be NULL in which
1235 * case the device has already synchronized.
1236 * @crtc: If crtc is passed, perform bo dirty on that crtc only.
1238 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1241 int vmw_kms_sou_do_bo_dirty(struct vmw_private
*dev_priv
,
1242 struct vmw_framebuffer
*framebuffer
,
1243 struct drm_clip_rect
*clips
,
1244 struct drm_vmw_rect
*vclips
,
1245 unsigned num_clips
, int increment
,
1247 struct vmw_fence_obj
**out_fence
,
1248 struct drm_crtc
*crtc
)
1250 struct vmw_buffer_object
*buf
=
1251 container_of(framebuffer
, struct vmw_framebuffer_bo
,
1253 struct vmw_kms_dirty dirty
;
1254 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1257 ret
= vmw_validation_add_bo(&val_ctx
, buf
, false, false);
1261 ret
= vmw_validation_prepare(&val_ctx
, NULL
, interruptible
);
1265 ret
= do_bo_define_gmrfb(dev_priv
, framebuffer
);
1266 if (unlikely(ret
!= 0))
1270 dirty
.fifo_commit
= vmw_sou_bo_fifo_commit
;
1271 dirty
.clip
= vmw_sou_bo_clip
;
1272 dirty
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_bo_blit
) *
1274 ret
= vmw_kms_helper_dirty(dev_priv
, framebuffer
, clips
, vclips
,
1275 0, 0, num_clips
, increment
, &dirty
);
1276 vmw_kms_helper_validation_finish(dev_priv
, NULL
, &val_ctx
, out_fence
,
1282 vmw_validation_revert(&val_ctx
);
1284 vmw_validation_unref_lists(&val_ctx
);
1291 * vmw_sou_readback_fifo_commit - Callback to submit a set of readback clips.
1293 * @dirty: The closure structure.
1295 * Commits a previously built command buffer of readback clips.
1297 static void vmw_sou_readback_fifo_commit(struct vmw_kms_dirty
*dirty
)
1299 if (!dirty
->num_hits
) {
1300 vmw_fifo_commit(dirty
->dev_priv
, 0);
1304 vmw_fifo_commit(dirty
->dev_priv
,
1305 sizeof(struct vmw_kms_sou_readback_blit
) *
1310 * vmw_sou_readback_clip - Callback to encode a readback cliprect.
1312 * @dirty: The closure structure
1314 * Encodes a BLIT_SCREEN_TO_GMRFB cliprect.
1316 static void vmw_sou_readback_clip(struct vmw_kms_dirty
*dirty
)
1318 struct vmw_kms_sou_readback_blit
*blit
= dirty
->cmd
;
1320 blit
+= dirty
->num_hits
;
1321 blit
->header
= SVGA_CMD_BLIT_SCREEN_TO_GMRFB
;
1322 blit
->body
.srcScreenId
= dirty
->unit
->unit
;
1323 blit
->body
.destOrigin
.x
= dirty
->fb_x
;
1324 blit
->body
.destOrigin
.y
= dirty
->fb_y
;
1325 blit
->body
.srcRect
.left
= dirty
->unit_x1
;
1326 blit
->body
.srcRect
.top
= dirty
->unit_y1
;
1327 blit
->body
.srcRect
.right
= dirty
->unit_x2
;
1328 blit
->body
.srcRect
.bottom
= dirty
->unit_y2
;
1333 * vmw_kms_sou_readback - Perform a readback from the screen object system to
1334 * a buffer-object backed framebuffer.
1336 * @dev_priv: Pointer to the device private structure.
1337 * @file_priv: Pointer to a struct drm_file identifying the caller.
1338 * Must be set to NULL if @user_fence_rep is NULL.
1339 * @vfb: Pointer to the buffer-object backed framebuffer.
1340 * @user_fence_rep: User-space provided structure for fence information.
1341 * Must be set to non-NULL if @file_priv is non-NULL.
1342 * @vclips: Array of clip rects.
1343 * @num_clips: Number of clip rects in @vclips.
1344 * @crtc: If crtc is passed, readback on that crtc only.
1346 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
1349 int vmw_kms_sou_readback(struct vmw_private
*dev_priv
,
1350 struct drm_file
*file_priv
,
1351 struct vmw_framebuffer
*vfb
,
1352 struct drm_vmw_fence_rep __user
*user_fence_rep
,
1353 struct drm_vmw_rect
*vclips
,
1355 struct drm_crtc
*crtc
)
1357 struct vmw_buffer_object
*buf
=
1358 container_of(vfb
, struct vmw_framebuffer_bo
, base
)->buffer
;
1359 struct vmw_kms_dirty dirty
;
1360 DECLARE_VAL_CONTEXT(val_ctx
, NULL
, 0);
1363 ret
= vmw_validation_add_bo(&val_ctx
, buf
, false, false);
1367 ret
= vmw_validation_prepare(&val_ctx
, NULL
, true);
1371 ret
= do_bo_define_gmrfb(dev_priv
, vfb
);
1372 if (unlikely(ret
!= 0))
1376 dirty
.fifo_commit
= vmw_sou_readback_fifo_commit
;
1377 dirty
.clip
= vmw_sou_readback_clip
;
1378 dirty
.fifo_reserve_size
= sizeof(struct vmw_kms_sou_readback_blit
) *
1380 ret
= vmw_kms_helper_dirty(dev_priv
, vfb
, NULL
, vclips
,
1381 0, 0, num_clips
, 1, &dirty
);
1382 vmw_kms_helper_validation_finish(dev_priv
, file_priv
, &val_ctx
, NULL
,
1388 vmw_validation_revert(&val_ctx
);
1390 vmw_validation_unref_lists(&val_ctx
);