Lines Matching +full:top +full:- +full:left
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * COPYRIGHT (C) 2014-2015 VMware, Inc., Palo Alto, CA., USA
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
54 * struct vmw_stdu_dirty - closure structure for the update functions
58 * @left: Left side of bounding box.
60 * @top: Top side of bounding box.
62 * @fb_left: Left side of the framebuffer/content bounding box
63 * @fb_top: Top of the framebuffer/content bounding box
65 * @buf: buffer object when DMA-ing between buffer and screen targets.
71 s32 left, right, top, bottom; member
143 * vmw_stdu_crtc_destroy - cleans up the STDU
153 * vmw_stdu_define_st - Defines a Screen Target
179 return -ENOMEM; in vmw_stdu_define_st()
181 cmd->header.id = SVGA_3D_CMD_DEFINE_GB_SCREENTARGET; in vmw_stdu_define_st()
182 cmd->header.size = sizeof(cmd->body); in vmw_stdu_define_st()
184 cmd->body.stid = stdu->base.unit; in vmw_stdu_define_st()
185 cmd->body.width = mode->hdisplay; in vmw_stdu_define_st()
186 cmd->body.height = mode->vdisplay; in vmw_stdu_define_st()
187 cmd->body.flags = (0 == cmd->body.stid) ? SVGA_STFLAG_PRIMARY : 0; in vmw_stdu_define_st()
188 cmd->body.dpi = 0; in vmw_stdu_define_st()
189 cmd->body.xRoot = crtc_x; in vmw_stdu_define_st()
190 cmd->body.yRoot = crtc_y; in vmw_stdu_define_st()
192 stdu->base.set_gui_x = cmd->body.xRoot; in vmw_stdu_define_st()
193 stdu->base.set_gui_y = cmd->body.yRoot; in vmw_stdu_define_st()
197 stdu->defined = true; in vmw_stdu_define_st()
198 stdu->display_width = mode->hdisplay; in vmw_stdu_define_st()
199 stdu->display_height = mode->vdisplay; in vmw_stdu_define_st()
207 * vmw_stdu_bind_st - Binds a surface to a Screen Target
227 if (!stdu->defined) { in vmw_stdu_bind_st()
229 return -EINVAL; in vmw_stdu_bind_st()
234 image.sid = res ? res->id : SVGA3D_INVALID_ID; in vmw_stdu_bind_st()
238 return -ENOMEM; in vmw_stdu_bind_st()
240 cmd->header.id = SVGA_3D_CMD_BIND_GB_SCREENTARGET; in vmw_stdu_bind_st()
241 cmd->header.size = sizeof(cmd->body); in vmw_stdu_bind_st()
243 cmd->body.stid = stdu->base.unit; in vmw_stdu_bind_st()
244 cmd->body.image = image; in vmw_stdu_bind_st()
252 * vmw_stdu_populate_update - populate an UPDATE_GB_SCREENTARGET command with a
257 * @left: Left side of bounding box.
259 * @top: Top side of bounding box.
263 s32 left, s32 right, s32 top, s32 bottom) in vmw_stdu_populate_update() argument
267 update->header.id = SVGA_3D_CMD_UPDATE_GB_SCREENTARGET; in vmw_stdu_populate_update()
268 update->header.size = sizeof(update->body); in vmw_stdu_populate_update()
270 update->body.stid = unit; in vmw_stdu_populate_update()
271 update->body.rect.x = left; in vmw_stdu_populate_update()
272 update->body.rect.y = top; in vmw_stdu_populate_update()
273 update->body.rect.w = right - left; in vmw_stdu_populate_update()
274 update->body.rect.h = bottom - top; in vmw_stdu_populate_update()
278 * vmw_stdu_update_st - Full update of a Screen Target
295 if (!stdu->defined) { in vmw_stdu_update_st()
297 return -EINVAL; in vmw_stdu_update_st()
302 return -ENOMEM; in vmw_stdu_update_st()
304 vmw_stdu_populate_update(cmd, stdu->base.unit, in vmw_stdu_update_st()
305 0, stdu->display_width, in vmw_stdu_update_st()
306 0, stdu->display_height); in vmw_stdu_update_st()
316 * vmw_stdu_destroy_st - Destroy a Screen Target
333 if (unlikely(!stdu->defined)) in vmw_stdu_destroy_st()
338 return -ENOMEM; in vmw_stdu_destroy_st()
340 cmd->header.id = SVGA_3D_CMD_DESTROY_GB_SCREENTARGET; in vmw_stdu_destroy_st()
341 cmd->header.size = sizeof(cmd->body); in vmw_stdu_destroy_st()
343 cmd->body.stid = stdu->base.unit; in vmw_stdu_destroy_st()
352 stdu->defined = false; in vmw_stdu_destroy_st()
353 stdu->display_width = 0; in vmw_stdu_destroy_st()
354 stdu->display_height = 0; in vmw_stdu_destroy_st()
361 * vmw_stdu_crtc_mode_set_nofb - Updates screen target size
377 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_crtc_mode_set_nofb()
378 conn_state = stdu->base.connector.state; in vmw_stdu_crtc_mode_set_nofb()
381 if (stdu->defined) { in vmw_stdu_crtc_mode_set_nofb()
392 stdu->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_crtc_mode_set_nofb()
395 if (!crtc->state->enable) in vmw_stdu_crtc_mode_set_nofb()
398 x = vmw_conn_state->gui_x; in vmw_stdu_crtc_mode_set_nofb()
399 y = vmw_conn_state->gui_y; in vmw_stdu_crtc_mode_set_nofb()
402 ret = vmw_stdu_define_st(dev_priv, stdu, &crtc->mode, x, y); in vmw_stdu_crtc_mode_set_nofb()
406 crtc->x, crtc->y); in vmw_stdu_crtc_mode_set_nofb()
433 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_crtc_atomic_disable()
435 if (stdu->defined) { in vmw_stdu_crtc_atomic_disable()
446 stdu->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_crtc_atomic_disable()
451 * vmw_stdu_bo_clip - Callback to encode a suface DMA command cliprect
462 struct vmw_stdu_dma *cmd = dirty->cmd; in vmw_stdu_bo_clip()
465 blit += dirty->num_hits; in vmw_stdu_bo_clip()
466 blit->srcx = dirty->fb_x; in vmw_stdu_bo_clip()
467 blit->srcy = dirty->fb_y; in vmw_stdu_bo_clip()
468 blit->x = dirty->unit_x1; in vmw_stdu_bo_clip()
469 blit->y = dirty->unit_y1; in vmw_stdu_bo_clip()
470 blit->d = 1; in vmw_stdu_bo_clip()
471 blit->w = dirty->unit_x2 - dirty->unit_x1; in vmw_stdu_bo_clip()
472 blit->h = dirty->unit_y2 - dirty->unit_y1; in vmw_stdu_bo_clip()
473 dirty->num_hits++; in vmw_stdu_bo_clip()
475 if (ddirty->transfer != SVGA3D_WRITE_HOST_VRAM) in vmw_stdu_bo_clip()
479 ddirty->left = min_t(s32, ddirty->left, dirty->unit_x1); in vmw_stdu_bo_clip()
480 ddirty->top = min_t(s32, ddirty->top, dirty->unit_y1); in vmw_stdu_bo_clip()
481 ddirty->right = max_t(s32, ddirty->right, dirty->unit_x2); in vmw_stdu_bo_clip()
482 ddirty->bottom = max_t(s32, ddirty->bottom, dirty->unit_y2); in vmw_stdu_bo_clip()
486 * vmw_stdu_bo_fifo_commit - Callback to fill in and submit a DMA command.
498 container_of(dirty->unit, typeof(*stdu), base); in vmw_stdu_bo_fifo_commit()
499 struct vmw_stdu_dma *cmd = dirty->cmd; in vmw_stdu_bo_fifo_commit()
502 (SVGA3dCmdSurfaceDMASuffix *) &blit[dirty->num_hits]; in vmw_stdu_bo_fifo_commit()
503 size_t blit_size = sizeof(*blit) * dirty->num_hits + sizeof(*suffix); in vmw_stdu_bo_fifo_commit()
505 if (!dirty->num_hits) { in vmw_stdu_bo_fifo_commit()
506 vmw_cmd_commit(dirty->dev_priv, 0); in vmw_stdu_bo_fifo_commit()
510 cmd->header.id = SVGA_3D_CMD_SURFACE_DMA; in vmw_stdu_bo_fifo_commit()
511 cmd->header.size = sizeof(cmd->body) + blit_size; in vmw_stdu_bo_fifo_commit()
512 vmw_bo_get_guest_ptr(&ddirty->buf->base, &cmd->body.guest.ptr); in vmw_stdu_bo_fifo_commit()
513 cmd->body.guest.pitch = ddirty->pitch; in vmw_stdu_bo_fifo_commit()
514 cmd->body.host.sid = stdu->display_srf->res.id; in vmw_stdu_bo_fifo_commit()
515 cmd->body.host.face = 0; in vmw_stdu_bo_fifo_commit()
516 cmd->body.host.mipmap = 0; in vmw_stdu_bo_fifo_commit()
517 cmd->body.transfer = ddirty->transfer; in vmw_stdu_bo_fifo_commit()
518 suffix->suffixSize = sizeof(*suffix); in vmw_stdu_bo_fifo_commit()
519 suffix->maximumOffset = ddirty->buf->base.base.size; in vmw_stdu_bo_fifo_commit()
521 if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM) { in vmw_stdu_bo_fifo_commit()
524 vmw_stdu_populate_update(&suffix[1], stdu->base.unit, in vmw_stdu_bo_fifo_commit()
525 ddirty->left, ddirty->right, in vmw_stdu_bo_fifo_commit()
526 ddirty->top, ddirty->bottom); in vmw_stdu_bo_fifo_commit()
529 vmw_cmd_commit(dirty->dev_priv, sizeof(*cmd) + blit_size); in vmw_stdu_bo_fifo_commit()
531 stdu->display_srf->res.res_dirty = true; in vmw_stdu_bo_fifo_commit()
532 ddirty->left = ddirty->top = S32_MAX; in vmw_stdu_bo_fifo_commit()
533 ddirty->right = ddirty->bottom = S32_MIN; in vmw_stdu_bo_fifo_commit()
538 * vmw_stdu_bo_cpu_clip - Callback to encode a CPU blit
549 dirty->num_hits = 1; in vmw_stdu_bo_cpu_clip()
552 ddirty->left = min_t(s32, ddirty->left, dirty->unit_x1); in vmw_stdu_bo_cpu_clip()
553 ddirty->top = min_t(s32, ddirty->top, dirty->unit_y1); in vmw_stdu_bo_cpu_clip()
554 ddirty->right = max_t(s32, ddirty->right, dirty->unit_x2); in vmw_stdu_bo_cpu_clip()
555 ddirty->bottom = max_t(s32, ddirty->bottom, dirty->unit_y2); in vmw_stdu_bo_cpu_clip()
558 * Calculate content bounding box. We only need the top-left in vmw_stdu_bo_cpu_clip()
562 ddirty->fb_left = min_t(s32, ddirty->fb_left, dirty->fb_x); in vmw_stdu_bo_cpu_clip()
563 ddirty->fb_top = min_t(s32, ddirty->fb_top, dirty->fb_y); in vmw_stdu_bo_cpu_clip()
568 * vmw_stdu_bo_cpu_commit - Callback to do a CPU blit from buffer object
580 container_of(dirty->unit, typeof(*stdu), base); in vmw_stdu_bo_cpu_commit()
585 struct vmw_diff_cpy diff = VMW_CPU_BLIT_DIFF_INITIALIZER(stdu->cpp); in vmw_stdu_bo_cpu_commit()
587 if (!dirty->num_hits) in vmw_stdu_bo_cpu_commit()
590 width = ddirty->right - ddirty->left; in vmw_stdu_bo_cpu_commit()
591 height = ddirty->bottom - ddirty->top; in vmw_stdu_bo_cpu_commit()
597 dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; in vmw_stdu_bo_cpu_commit()
598 dst_bo = &stdu->display_srf->res.backup->base; in vmw_stdu_bo_cpu_commit()
599 dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; in vmw_stdu_bo_cpu_commit()
601 src_pitch = ddirty->pitch; in vmw_stdu_bo_cpu_commit()
602 src_bo = &ddirty->buf->base; in vmw_stdu_bo_cpu_commit()
603 src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; in vmw_stdu_bo_cpu_commit()
606 if (ddirty->transfer != SVGA3D_WRITE_HOST_VRAM) { in vmw_stdu_bo_cpu_commit()
614 width * stdu->cpp, height, &diff); in vmw_stdu_bo_cpu_commit()
616 if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM && in vmw_stdu_bo_cpu_commit()
628 ret = vmw_kms_update_proxy(&stdu->display_srf->res, ®ion, in vmw_stdu_bo_cpu_commit()
634 dev_priv = vmw_priv(stdu->base.crtc.dev); in vmw_stdu_bo_cpu_commit()
639 vmw_stdu_populate_update(cmd, stdu->base.unit, in vmw_stdu_bo_cpu_commit()
647 ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top = S32_MAX; in vmw_stdu_bo_cpu_commit()
648 ddirty->right = ddirty->bottom = S32_MIN; in vmw_stdu_bo_cpu_commit()
652 * vmw_kms_stdu_dma - Perform a DMA transfer between a buffer-object backed
656 * @file_priv: Pointer to a struct drm-file identifying the caller. May be
658 * @vfb: Pointer to the buffer-object backed framebuffer.
659 * @user_fence_rep: User-space provided structure for fence information.
670 * If DMA-ing till the screen target system, the function will also notify
673 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
689 container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; in vmw_kms_stdu_dma()
692 bool cpu_blit = !(dev_priv->capabilities & SVGA_CAP_3D); in vmw_kms_stdu_dma()
710 ddirty.left = ddirty.top = S32_MAX; in vmw_kms_stdu_dma()
713 ddirty.pitch = vfb->base.pitches[0]; in vmw_kms_stdu_dma()
745 * vmw_kms_stdu_surface_clip - Callback to encode a surface copy command cliprect
756 struct vmw_stdu_surface_copy *cmd = dirty->cmd; in vmw_kms_stdu_surface_clip()
758 container_of(dirty->unit, typeof(*stdu), base); in vmw_kms_stdu_surface_clip()
760 if (sdirty->sid != stdu->display_srf->res.id) { in vmw_kms_stdu_surface_clip()
763 blit += dirty->num_hits; in vmw_kms_stdu_surface_clip()
764 blit->srcx = dirty->fb_x; in vmw_kms_stdu_surface_clip()
765 blit->srcy = dirty->fb_y; in vmw_kms_stdu_surface_clip()
766 blit->x = dirty->unit_x1; in vmw_kms_stdu_surface_clip()
767 blit->y = dirty->unit_y1; in vmw_kms_stdu_surface_clip()
768 blit->d = 1; in vmw_kms_stdu_surface_clip()
769 blit->w = dirty->unit_x2 - dirty->unit_x1; in vmw_kms_stdu_surface_clip()
770 blit->h = dirty->unit_y2 - dirty->unit_y1; in vmw_kms_stdu_surface_clip()
773 dirty->num_hits++; in vmw_kms_stdu_surface_clip()
776 sdirty->left = min_t(s32, sdirty->left, dirty->unit_x1); in vmw_kms_stdu_surface_clip()
777 sdirty->top = min_t(s32, sdirty->top, dirty->unit_y1); in vmw_kms_stdu_surface_clip()
778 sdirty->right = max_t(s32, sdirty->right, dirty->unit_x2); in vmw_kms_stdu_surface_clip()
779 sdirty->bottom = max_t(s32, sdirty->bottom, dirty->unit_y2); in vmw_kms_stdu_surface_clip()
783 * vmw_kms_stdu_surface_fifo_commit - Callback to fill in and submit a surface
796 container_of(dirty->unit, typeof(*stdu), base); in vmw_kms_stdu_surface_fifo_commit()
797 struct vmw_stdu_surface_copy *cmd = dirty->cmd; in vmw_kms_stdu_surface_fifo_commit()
799 size_t blit_size = sizeof(SVGA3dCopyBox) * dirty->num_hits; in vmw_kms_stdu_surface_fifo_commit()
802 if (!dirty->num_hits) { in vmw_kms_stdu_surface_fifo_commit()
803 vmw_cmd_commit(dirty->dev_priv, 0); in vmw_kms_stdu_surface_fifo_commit()
807 if (sdirty->sid != stdu->display_srf->res.id) { in vmw_kms_stdu_surface_fifo_commit()
810 cmd->header.id = SVGA_3D_CMD_SURFACE_COPY; in vmw_kms_stdu_surface_fifo_commit()
811 cmd->header.size = sizeof(cmd->body) + blit_size; in vmw_kms_stdu_surface_fifo_commit()
812 cmd->body.src.sid = sdirty->sid; in vmw_kms_stdu_surface_fifo_commit()
813 cmd->body.dest.sid = stdu->display_srf->res.id; in vmw_kms_stdu_surface_fifo_commit()
814 update = (struct vmw_stdu_update *) &blit[dirty->num_hits]; in vmw_kms_stdu_surface_fifo_commit()
816 stdu->display_srf->res.res_dirty = true; in vmw_kms_stdu_surface_fifo_commit()
818 update = dirty->cmd; in vmw_kms_stdu_surface_fifo_commit()
822 vmw_stdu_populate_update(update, stdu->base.unit, sdirty->left, in vmw_kms_stdu_surface_fifo_commit()
823 sdirty->right, sdirty->top, sdirty->bottom); in vmw_kms_stdu_surface_fifo_commit()
825 vmw_cmd_commit(dirty->dev_priv, commit_size); in vmw_kms_stdu_surface_fifo_commit()
827 sdirty->left = sdirty->top = S32_MAX; in vmw_kms_stdu_surface_fifo_commit()
828 sdirty->right = sdirty->bottom = S32_MIN; in vmw_kms_stdu_surface_fifo_commit()
832 * vmw_kms_stdu_surface_dirty - Dirty part of a surface backed framebuffer
835 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
845 * @out_fence: If non-NULL, will return a ref-counted pointer to a
850 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
871 srf = &vfbs->surface->res; in vmw_kms_stdu_surface_dirty()
878 ret = vmw_validation_prepare(&val_ctx, &dev_priv->cmdbuf_mutex, true); in vmw_kms_stdu_surface_dirty()
882 if (vfbs->is_bo_proxy) { in vmw_kms_stdu_surface_dirty()
894 sdirty.sid = srf->id; in vmw_kms_stdu_surface_dirty()
895 sdirty.left = sdirty.top = S32_MAX; in vmw_kms_stdu_surface_dirty()
936 * vmw_stdu_encoder_destroy - cleans up the STDU
941 * this can be a no-op. Nevertheless, it doesn't hurt of have this in case
961 * vmw_stdu_connector_destroy - cleans up the STDU
966 * this can be a no-op. Nevertheless, it doesn't hurt of have this in case
1001 * vmw_stdu_primary_plane_cleanup_fb - Unpins the display surface
1016 if (vps->surf) in vmw_stdu_primary_plane_cleanup_fb()
1017 WARN_ON(!vps->pinned); in vmw_stdu_primary_plane_cleanup_fb()
1021 vps->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_primary_plane_cleanup_fb()
1022 vps->cpp = 0; in vmw_stdu_primary_plane_cleanup_fb()
1028 * vmw_stdu_primary_plane_prepare_fb - Readies the display surface
1043 struct vmw_private *dev_priv = vmw_priv(plane->dev); in vmw_stdu_primary_plane_prepare_fb()
1044 struct drm_framebuffer *new_fb = new_state->fb; in vmw_stdu_primary_plane_prepare_fb()
1049 uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h; in vmw_stdu_primary_plane_prepare_fb()
1054 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1055 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1056 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1063 new_vfbs = (vfb->bo) ? NULL : vmw_framebuffer_to_vfbs(new_fb); in vmw_stdu_primary_plane_prepare_fb()
1066 new_vfbs->surface->metadata.base_size.width == hdisplay && in vmw_stdu_primary_plane_prepare_fb()
1067 new_vfbs->surface->metadata.base_size.height == vdisplay) in vmw_stdu_primary_plane_prepare_fb()
1069 else if (vfb->bo) in vmw_stdu_primary_plane_prepare_fb()
1083 switch (new_fb->format->cpp[0]*8) { in vmw_stdu_primary_plane_prepare_fb()
1098 return -EINVAL; in vmw_stdu_primary_plane_prepare_fb()
1105 metadata = new_vfbs->surface->metadata; in vmw_stdu_primary_plane_prepare_fb()
1112 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1114 vps->surf->metadata.base_size; in vmw_stdu_primary_plane_prepare_fb()
1118 vps->surf->metadata.format != metadata.format) { in vmw_stdu_primary_plane_prepare_fb()
1119 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1120 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1125 if (!vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1127 &vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1140 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1141 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1142 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1145 vps->surf = vmw_surface_reference(new_vfbs->surface); in vmw_stdu_primary_plane_prepare_fb()
1148 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1151 ret = vmw_resource_pin(&vps->surf->res, false); in vmw_stdu_primary_plane_prepare_fb()
1155 vps->pinned++; in vmw_stdu_primary_plane_prepare_fb()
1158 vps->content_fb_type = new_content_type; in vmw_stdu_primary_plane_prepare_fb()
1166 if (vps->content_fb_type == SEPARATE_BO && in vmw_stdu_primary_plane_prepare_fb()
1167 !(dev_priv->capabilities & SVGA_CAP_3D)) in vmw_stdu_primary_plane_prepare_fb()
1168 vps->cpp = new_fb->pitches[0] / new_fb->width; in vmw_stdu_primary_plane_prepare_fb()
1173 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1199 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_dma()
1200 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_dma()
1202 cmd_dma->header.id = SVGA_3D_CMD_SURFACE_DMA; in vmw_stdu_bo_populate_dma()
1203 cmd_dma->header.size = sizeof(cmd_dma->body) + in vmw_stdu_bo_populate_dma()
1206 vmw_bo_get_guest_ptr(&vfbbo->buffer->base, &cmd_dma->body.guest.ptr); in vmw_stdu_bo_populate_dma()
1207 cmd_dma->body.guest.pitch = update->vfb->base.pitches[0]; in vmw_stdu_bo_populate_dma()
1208 cmd_dma->body.host.sid = stdu->display_srf->res.id; in vmw_stdu_bo_populate_dma()
1209 cmd_dma->body.host.face = 0; in vmw_stdu_bo_populate_dma()
1210 cmd_dma->body.host.mipmap = 0; in vmw_stdu_bo_populate_dma()
1211 cmd_dma->body.transfer = SVGA3D_WRITE_HOST_VRAM; in vmw_stdu_bo_populate_dma()
1222 box->srcx = fb_x; in vmw_stdu_bo_populate_clip()
1223 box->srcy = fb_y; in vmw_stdu_bo_populate_clip()
1224 box->srcz = 0; in vmw_stdu_bo_populate_clip()
1225 box->x = clip->x1; in vmw_stdu_bo_populate_clip()
1226 box->y = clip->y1; in vmw_stdu_bo_populate_clip()
1227 box->z = 0; in vmw_stdu_bo_populate_clip()
1228 box->w = drm_rect_width(clip); in vmw_stdu_bo_populate_clip()
1229 box->h = drm_rect_height(clip); in vmw_stdu_bo_populate_clip()
1230 box->d = 1; in vmw_stdu_bo_populate_clip()
1242 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_update()
1243 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_update()
1245 suffix->suffixSize = sizeof(*suffix); in vmw_stdu_bo_populate_update()
1246 suffix->maximumOffset = vfbbo->buffer->base.base.size; in vmw_stdu_bo_populate_update()
1248 vmw_stdu_populate_update(&suffix[1], stdu->base.unit, bb->x1, bb->x2, in vmw_stdu_bo_populate_update()
1249 bb->y1, bb->y2); in vmw_stdu_bo_populate_update()
1260 bo_update->fb_left = INT_MAX; in vmw_stdu_bo_pre_clip_cpu()
1261 bo_update->fb_top = INT_MAX; in vmw_stdu_bo_pre_clip_cpu()
1273 bo_update->fb_left = min_t(int, bo_update->fb_left, fb_x); in vmw_stdu_bo_clip_cpu()
1274 bo_update->fb_top = min_t(int, bo_update->fb_top, fb_y); in vmw_stdu_bo_clip_cpu()
1295 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_update_cpu()
1296 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_update_cpu()
1298 width = bb->x2 - bb->x1; in vmw_stdu_bo_populate_update_cpu()
1299 height = bb->y2 - bb->y1; in vmw_stdu_bo_populate_update_cpu()
1301 diff.cpp = stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1303 dst_bo = &stdu->display_srf->res.backup->base; in vmw_stdu_bo_populate_update_cpu()
1304 dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1305 dst_offset = bb->y1 * dst_pitch + bb->x1 * stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1307 src_bo = &vfbbo->buffer->base; in vmw_stdu_bo_populate_update_cpu()
1308 src_pitch = update->vfb->base.pitches[0]; in vmw_stdu_bo_populate_update_cpu()
1309 src_offset = bo_update->fb_top * src_pitch + bo_update->fb_left * in vmw_stdu_bo_populate_update_cpu()
1310 stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1313 src_offset, src_pitch, width * stdu->cpp, height, in vmw_stdu_bo_populate_update_cpu()
1317 SVGA3dBox *box = &cmd_img->body.box; in vmw_stdu_bo_populate_update_cpu()
1319 cmd_img->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; in vmw_stdu_bo_populate_update_cpu()
1320 cmd_img->header.size = sizeof(cmd_img->body); in vmw_stdu_bo_populate_update_cpu()
1321 cmd_img->body.image.sid = stdu->display_srf->res.id; in vmw_stdu_bo_populate_update_cpu()
1322 cmd_img->body.image.face = 0; in vmw_stdu_bo_populate_update_cpu()
1323 cmd_img->body.image.mipmap = 0; in vmw_stdu_bo_populate_update_cpu()
1325 box->x = diff.rect.x1; in vmw_stdu_bo_populate_update_cpu()
1326 box->y = diff.rect.y1; in vmw_stdu_bo_populate_update_cpu()
1327 box->z = 0; in vmw_stdu_bo_populate_update_cpu()
1328 box->w = drm_rect_width(&diff.rect); in vmw_stdu_bo_populate_update_cpu()
1329 box->h = drm_rect_height(&diff.rect); in vmw_stdu_bo_populate_update_cpu()
1330 box->d = 1; in vmw_stdu_bo_populate_update_cpu()
1333 vmw_stdu_populate_update(cmd_update, stdu->base.unit, in vmw_stdu_bo_populate_update_cpu()
1344 * vmw_stdu_plane_update_bo - Update display unit for bo backed fb.
1349 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
1367 bo_update.base.du = vmw_crtc_to_du(plane->state->crtc); in vmw_stdu_plane_update_bo()
1371 bo_update.base.cpu_blit = !(dev_priv->capabilities & SVGA_CAP_3D); in vmw_stdu_plane_update_bo()
1400 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_fifo_size_same_display()
1402 if (vfbs->is_bo_proxy) in vmw_stdu_surface_fifo_size_same_display()
1416 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_fifo_size()
1418 if (vfbs->is_bo_proxy) in vmw_stdu_surface_fifo_size()
1431 struct drm_plane_state *state = update->plane->state; in vmw_stdu_surface_update_proxy()
1432 struct drm_plane_state *old_state = update->old_state; in vmw_stdu_surface_update_proxy()
1438 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_update_proxy()
1446 SVGA3dBox *box = &cmd_update->body.box; in vmw_stdu_surface_update_proxy()
1448 cmd_update->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; in vmw_stdu_surface_update_proxy()
1449 cmd_update->header.size = sizeof(cmd_update->body); in vmw_stdu_surface_update_proxy()
1450 cmd_update->body.image.sid = vfbs->surface->res.id; in vmw_stdu_surface_update_proxy()
1451 cmd_update->body.image.face = 0; in vmw_stdu_surface_update_proxy()
1452 cmd_update->body.image.mipmap = 0; in vmw_stdu_surface_update_proxy()
1454 box->x = clip.x1; in vmw_stdu_surface_update_proxy()
1455 box->y = clip.y1; in vmw_stdu_surface_update_proxy()
1456 box->z = 0; in vmw_stdu_surface_update_proxy()
1457 box->w = drm_rect_width(&clip); in vmw_stdu_surface_update_proxy()
1458 box->h = drm_rect_height(&clip); in vmw_stdu_surface_update_proxy()
1459 box->d = 1; in vmw_stdu_surface_update_proxy()
1476 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_surface_populate_copy()
1477 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_populate_copy()
1479 cmd_copy->header.id = SVGA_3D_CMD_SURFACE_COPY; in vmw_stdu_surface_populate_copy()
1480 cmd_copy->header.size = sizeof(cmd_copy->body) + sizeof(SVGA3dCopyBox) * in vmw_stdu_surface_populate_copy()
1482 cmd_copy->body.src.sid = vfbs->surface->res.id; in vmw_stdu_surface_populate_copy()
1483 cmd_copy->body.dest.sid = stdu->display_srf->res.id; in vmw_stdu_surface_populate_copy()
1495 box->srcx = fb_x; in vmw_stdu_surface_populate_clip()
1496 box->srcy = fb_y; in vmw_stdu_surface_populate_clip()
1497 box->srcz = 0; in vmw_stdu_surface_populate_clip()
1498 box->x = clip->x1; in vmw_stdu_surface_populate_clip()
1499 box->y = clip->y1; in vmw_stdu_surface_populate_clip()
1500 box->z = 0; in vmw_stdu_surface_populate_clip()
1501 box->w = drm_rect_width(clip); in vmw_stdu_surface_populate_clip()
1502 box->h = drm_rect_height(clip); in vmw_stdu_surface_populate_clip()
1503 box->d = 1; in vmw_stdu_surface_populate_clip()
1512 vmw_stdu_populate_update(cmd, update->du->unit, bb->x1, bb->x2, bb->y1, in vmw_stdu_surface_populate_update()
1513 bb->y2); in vmw_stdu_surface_populate_update()
1519 * vmw_stdu_plane_update_surface - Update display unit for surface backed fb
1524 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
1540 stdu = vmw_crtc_to_stdu(plane->state->crtc); in vmw_stdu_plane_update_surface()
1547 srf_update.du = vmw_crtc_to_du(plane->state->crtc); in vmw_stdu_plane_update_surface()
1550 srf_update.mutex = &dev_priv->cmdbuf_mutex; in vmw_stdu_plane_update_surface()
1554 if (vfbs->is_bo_proxy) in vmw_stdu_plane_update_surface()
1557 if (vfbs->surface->res.id != stdu->display_srf->res.id) { in vmw_stdu_plane_update_surface()
1572 * vmw_stdu_primary_plane_atomic_update - formally switches STDU to new plane
1576 * Formally update stdu->display_srf to the new plane, and bind the new
1588 struct drm_crtc *crtc = new_state->crtc; in vmw_stdu_primary_plane_atomic_update()
1596 if (crtc && new_state->fb) { in vmw_stdu_primary_plane_atomic_update()
1598 vmw_framebuffer_to_vfb(new_state->fb); in vmw_stdu_primary_plane_atomic_update()
1600 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_primary_plane_atomic_update()
1602 stdu->display_srf = vps->surf; in vmw_stdu_primary_plane_atomic_update()
1603 stdu->content_fb_type = vps->content_fb_type; in vmw_stdu_primary_plane_atomic_update()
1604 stdu->cpp = vps->cpp; in vmw_stdu_primary_plane_atomic_update()
1606 ret = vmw_stdu_bind_st(dev_priv, stdu, &stdu->display_srf->res); in vmw_stdu_primary_plane_atomic_update()
1610 if (vfb->bo) in vmw_stdu_primary_plane_atomic_update()
1620 crtc = old_state->crtc; in vmw_stdu_primary_plane_atomic_update()
1622 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_primary_plane_atomic_update()
1625 if (!stdu->defined) in vmw_stdu_primary_plane_atomic_update()
1640 event = crtc->state->event; in vmw_stdu_primary_plane_atomic_update()
1642 struct drm_file *file_priv = event->base.file_priv; in vmw_stdu_primary_plane_atomic_update()
1646 &event->base, in vmw_stdu_primary_plane_atomic_update()
1647 &event->event.vbl.tv_sec, in vmw_stdu_primary_plane_atomic_update()
1648 &event->event.vbl.tv_usec, in vmw_stdu_primary_plane_atomic_update()
1653 crtc->state->event = NULL; in vmw_stdu_primary_plane_atomic_update()
1711 * vmw_stdu_init - Sets up a Screen Target Display Unit
1723 struct drm_device *dev = &dev_priv->drm; in vmw_stdu_init()
1733 return -ENOMEM; in vmw_stdu_init()
1735 stdu->base.unit = unit; in vmw_stdu_init()
1736 crtc = &stdu->base.crtc; in vmw_stdu_init()
1737 encoder = &stdu->base.encoder; in vmw_stdu_init()
1738 connector = &stdu->base.connector; in vmw_stdu_init()
1739 primary = &stdu->base.primary; in vmw_stdu_init()
1740 cursor = &stdu->base.cursor; in vmw_stdu_init()
1742 stdu->base.pref_active = (unit == 0); in vmw_stdu_init()
1743 stdu->base.pref_width = dev_priv->initial_width; in vmw_stdu_init()
1744 stdu->base.pref_height = dev_priv->initial_height; in vmw_stdu_init()
1745 stdu->base.is_implicit = false; in vmw_stdu_init()
1769 drm_plane_cleanup(&stdu->base.primary); in vmw_stdu_init()
1783 connector->status = vmw_du_connector_detect(connector, false); in vmw_stdu_init()
1793 encoder->possible_crtcs = (1 << unit); in vmw_stdu_init()
1794 encoder->possible_clones = 0; in vmw_stdu_init()
1802 ret = drm_crtc_init_with_planes(dev, crtc, &stdu->base.primary, in vmw_stdu_init()
1803 &stdu->base.cursor, in vmw_stdu_init()
1814 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1815 dev_priv->hotplug_mode_update_property, 1); in vmw_stdu_init()
1816 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1817 dev->mode_config.suggested_x_property, 0); in vmw_stdu_init()
1818 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1819 dev->mode_config.suggested_y_property, 0); in vmw_stdu_init()
1836 * vmw_stdu_destroy - Cleans up a vmw_screen_target_display_unit
1844 vmw_du_cleanup(&stdu->base); in vmw_stdu_destroy()
1857 * vmw_kms_stdu_init_display - Initializes a Screen Target based display
1871 struct drm_device *dev = &dev_priv->drm; in vmw_kms_stdu_init_display()
1876 if (!VMWGFX_ENABLE_SCREEN_TARGET_OTABLE || !dev_priv->has_mob) in vmw_kms_stdu_init_display()
1877 return -ENOSYS; in vmw_kms_stdu_init_display()
1879 if (!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS)) in vmw_kms_stdu_init_display()
1880 return -ENOSYS; in vmw_kms_stdu_init_display()
1886 dev_priv->active_display_unit = vmw_du_screen_target; in vmw_kms_stdu_init_display()
1892 drm_err(&dev_priv->drm, in vmw_kms_stdu_init_display()