Lines Matching +full:top +full:- +full:left
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * COPYRIGHT (C) 2014-2022 VMware, Inc., Palo Alto, CA., USA
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
53 * struct vmw_stdu_dirty - closure structure for the update functions
57 * @left: Left side of bounding box.
59 * @top: Top side of bounding box.
61 * @fb_left: Left side of the framebuffer/content bounding box
62 * @fb_top: Top of the framebuffer/content bounding box
64 * @buf: buffer object when DMA-ing between buffer and screen targets.
70 s32 left, right, top, bottom; member
142 return !(vmw->capabilities & SVGA_CAP_3D) || vmw->vram_size < (32 * 1024 * 1024); in vmw_stdu_use_cpu_blit()
147 * vmw_stdu_crtc_destroy - cleans up the STDU
157 * vmw_stdu_define_st - Defines a Screen Target
183 return -ENOMEM; in vmw_stdu_define_st()
185 cmd->header.id = SVGA_3D_CMD_DEFINE_GB_SCREENTARGET; in vmw_stdu_define_st()
186 cmd->header.size = sizeof(cmd->body); in vmw_stdu_define_st()
188 cmd->body.stid = stdu->base.unit; in vmw_stdu_define_st()
189 cmd->body.width = mode->hdisplay; in vmw_stdu_define_st()
190 cmd->body.height = mode->vdisplay; in vmw_stdu_define_st()
191 cmd->body.flags = (0 == cmd->body.stid) ? SVGA_STFLAG_PRIMARY : 0; in vmw_stdu_define_st()
192 cmd->body.dpi = 0; in vmw_stdu_define_st()
193 cmd->body.xRoot = crtc_x; in vmw_stdu_define_st()
194 cmd->body.yRoot = crtc_y; in vmw_stdu_define_st()
196 stdu->base.set_gui_x = cmd->body.xRoot; in vmw_stdu_define_st()
197 stdu->base.set_gui_y = cmd->body.yRoot; in vmw_stdu_define_st()
201 stdu->defined = true; in vmw_stdu_define_st()
202 stdu->display_width = mode->hdisplay; in vmw_stdu_define_st()
203 stdu->display_height = mode->vdisplay; in vmw_stdu_define_st()
211 * vmw_stdu_bind_st - Binds a surface to a Screen Target
231 if (!stdu->defined) { in vmw_stdu_bind_st()
233 return -EINVAL; in vmw_stdu_bind_st()
238 image.sid = res ? res->id : SVGA3D_INVALID_ID; in vmw_stdu_bind_st()
242 return -ENOMEM; in vmw_stdu_bind_st()
244 cmd->header.id = SVGA_3D_CMD_BIND_GB_SCREENTARGET; in vmw_stdu_bind_st()
245 cmd->header.size = sizeof(cmd->body); in vmw_stdu_bind_st()
247 cmd->body.stid = stdu->base.unit; in vmw_stdu_bind_st()
248 cmd->body.image = image; in vmw_stdu_bind_st()
256 * vmw_stdu_populate_update - populate an UPDATE_GB_SCREENTARGET command with a
261 * @left: Left side of bounding box.
263 * @top: Top side of bounding box.
267 s32 left, s32 right, s32 top, s32 bottom) in vmw_stdu_populate_update() argument
271 update->header.id = SVGA_3D_CMD_UPDATE_GB_SCREENTARGET; in vmw_stdu_populate_update()
272 update->header.size = sizeof(update->body); in vmw_stdu_populate_update()
274 update->body.stid = unit; in vmw_stdu_populate_update()
275 update->body.rect.x = left; in vmw_stdu_populate_update()
276 update->body.rect.y = top; in vmw_stdu_populate_update()
277 update->body.rect.w = right - left; in vmw_stdu_populate_update()
278 update->body.rect.h = bottom - top; in vmw_stdu_populate_update()
282 * vmw_stdu_update_st - Full update of a Screen Target
299 if (!stdu->defined) { in vmw_stdu_update_st()
301 return -EINVAL; in vmw_stdu_update_st()
306 return -ENOMEM; in vmw_stdu_update_st()
308 vmw_stdu_populate_update(cmd, stdu->base.unit, in vmw_stdu_update_st()
309 0, stdu->display_width, in vmw_stdu_update_st()
310 0, stdu->display_height); in vmw_stdu_update_st()
320 * vmw_stdu_destroy_st - Destroy a Screen Target
337 if (unlikely(!stdu->defined)) in vmw_stdu_destroy_st()
342 return -ENOMEM; in vmw_stdu_destroy_st()
344 cmd->header.id = SVGA_3D_CMD_DESTROY_GB_SCREENTARGET; in vmw_stdu_destroy_st()
345 cmd->header.size = sizeof(cmd->body); in vmw_stdu_destroy_st()
347 cmd->body.stid = stdu->base.unit; in vmw_stdu_destroy_st()
356 stdu->defined = false; in vmw_stdu_destroy_st()
357 stdu->display_width = 0; in vmw_stdu_destroy_st()
358 stdu->display_height = 0; in vmw_stdu_destroy_st()
365 * vmw_stdu_crtc_mode_set_nofb - Updates screen target size
381 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_crtc_mode_set_nofb()
382 conn_state = stdu->base.connector.state; in vmw_stdu_crtc_mode_set_nofb()
385 if (stdu->defined) { in vmw_stdu_crtc_mode_set_nofb()
396 stdu->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_crtc_mode_set_nofb()
399 if (!crtc->state->enable) in vmw_stdu_crtc_mode_set_nofb()
402 x = vmw_conn_state->gui_x; in vmw_stdu_crtc_mode_set_nofb()
403 y = vmw_conn_state->gui_y; in vmw_stdu_crtc_mode_set_nofb()
406 ret = vmw_stdu_define_st(dev_priv, stdu, &crtc->mode, x, y); in vmw_stdu_crtc_mode_set_nofb()
410 crtc->x, crtc->y); in vmw_stdu_crtc_mode_set_nofb()
437 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_crtc_atomic_disable()
439 if (stdu->defined) { in vmw_stdu_crtc_atomic_disable()
450 stdu->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_crtc_atomic_disable()
455 * vmw_stdu_bo_clip - Callback to encode a suface DMA command cliprect
466 struct vmw_stdu_dma *cmd = dirty->cmd; in vmw_stdu_bo_clip()
469 blit += dirty->num_hits; in vmw_stdu_bo_clip()
470 blit->srcx = dirty->fb_x; in vmw_stdu_bo_clip()
471 blit->srcy = dirty->fb_y; in vmw_stdu_bo_clip()
472 blit->x = dirty->unit_x1; in vmw_stdu_bo_clip()
473 blit->y = dirty->unit_y1; in vmw_stdu_bo_clip()
474 blit->d = 1; in vmw_stdu_bo_clip()
475 blit->w = dirty->unit_x2 - dirty->unit_x1; in vmw_stdu_bo_clip()
476 blit->h = dirty->unit_y2 - dirty->unit_y1; in vmw_stdu_bo_clip()
477 dirty->num_hits++; in vmw_stdu_bo_clip()
479 if (ddirty->transfer != SVGA3D_WRITE_HOST_VRAM) in vmw_stdu_bo_clip()
483 ddirty->left = min_t(s32, ddirty->left, dirty->unit_x1); in vmw_stdu_bo_clip()
484 ddirty->top = min_t(s32, ddirty->top, dirty->unit_y1); in vmw_stdu_bo_clip()
485 ddirty->right = max_t(s32, ddirty->right, dirty->unit_x2); in vmw_stdu_bo_clip()
486 ddirty->bottom = max_t(s32, ddirty->bottom, dirty->unit_y2); in vmw_stdu_bo_clip()
490 * vmw_stdu_bo_fifo_commit - Callback to fill in and submit a DMA command.
502 container_of(dirty->unit, typeof(*stdu), base); in vmw_stdu_bo_fifo_commit()
503 struct vmw_stdu_dma *cmd = dirty->cmd; in vmw_stdu_bo_fifo_commit()
506 (SVGA3dCmdSurfaceDMASuffix *) &blit[dirty->num_hits]; in vmw_stdu_bo_fifo_commit()
507 size_t blit_size = sizeof(*blit) * dirty->num_hits + sizeof(*suffix); in vmw_stdu_bo_fifo_commit()
509 if (!dirty->num_hits) { in vmw_stdu_bo_fifo_commit()
510 vmw_cmd_commit(dirty->dev_priv, 0); in vmw_stdu_bo_fifo_commit()
514 cmd->header.id = SVGA_3D_CMD_SURFACE_DMA; in vmw_stdu_bo_fifo_commit()
515 cmd->header.size = sizeof(cmd->body) + blit_size; in vmw_stdu_bo_fifo_commit()
516 vmw_bo_get_guest_ptr(&ddirty->buf->base, &cmd->body.guest.ptr); in vmw_stdu_bo_fifo_commit()
517 cmd->body.guest.pitch = ddirty->pitch; in vmw_stdu_bo_fifo_commit()
518 cmd->body.host.sid = stdu->display_srf->res.id; in vmw_stdu_bo_fifo_commit()
519 cmd->body.host.face = 0; in vmw_stdu_bo_fifo_commit()
520 cmd->body.host.mipmap = 0; in vmw_stdu_bo_fifo_commit()
521 cmd->body.transfer = ddirty->transfer; in vmw_stdu_bo_fifo_commit()
522 suffix->suffixSize = sizeof(*suffix); in vmw_stdu_bo_fifo_commit()
523 suffix->maximumOffset = ddirty->buf->base.base.size; in vmw_stdu_bo_fifo_commit()
525 if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM) { in vmw_stdu_bo_fifo_commit()
528 vmw_stdu_populate_update(&suffix[1], stdu->base.unit, in vmw_stdu_bo_fifo_commit()
529 ddirty->left, ddirty->right, in vmw_stdu_bo_fifo_commit()
530 ddirty->top, ddirty->bottom); in vmw_stdu_bo_fifo_commit()
533 vmw_cmd_commit(dirty->dev_priv, sizeof(*cmd) + blit_size); in vmw_stdu_bo_fifo_commit()
535 stdu->display_srf->res.res_dirty = true; in vmw_stdu_bo_fifo_commit()
536 ddirty->left = ddirty->top = S32_MAX; in vmw_stdu_bo_fifo_commit()
537 ddirty->right = ddirty->bottom = S32_MIN; in vmw_stdu_bo_fifo_commit()
542 * vmw_stdu_bo_cpu_clip - Callback to encode a CPU blit
553 dirty->num_hits = 1; in vmw_stdu_bo_cpu_clip()
556 ddirty->left = min_t(s32, ddirty->left, dirty->unit_x1); in vmw_stdu_bo_cpu_clip()
557 ddirty->top = min_t(s32, ddirty->top, dirty->unit_y1); in vmw_stdu_bo_cpu_clip()
558 ddirty->right = max_t(s32, ddirty->right, dirty->unit_x2); in vmw_stdu_bo_cpu_clip()
559 ddirty->bottom = max_t(s32, ddirty->bottom, dirty->unit_y2); in vmw_stdu_bo_cpu_clip()
562 * Calculate content bounding box. We only need the top-left in vmw_stdu_bo_cpu_clip()
566 ddirty->fb_left = min_t(s32, ddirty->fb_left, dirty->fb_x); in vmw_stdu_bo_cpu_clip()
567 ddirty->fb_top = min_t(s32, ddirty->fb_top, dirty->fb_y); in vmw_stdu_bo_cpu_clip()
572 * vmw_stdu_bo_cpu_commit - Callback to do a CPU blit from buffer object
584 container_of(dirty->unit, typeof(*stdu), base); in vmw_stdu_bo_cpu_commit()
589 struct vmw_diff_cpy diff = VMW_CPU_BLIT_DIFF_INITIALIZER(stdu->cpp); in vmw_stdu_bo_cpu_commit()
591 if (!dirty->num_hits) in vmw_stdu_bo_cpu_commit()
594 width = ddirty->right - ddirty->left; in vmw_stdu_bo_cpu_commit()
595 height = ddirty->bottom - ddirty->top; in vmw_stdu_bo_cpu_commit()
601 dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; in vmw_stdu_bo_cpu_commit()
602 dst_bo = &stdu->display_srf->res.backup->base; in vmw_stdu_bo_cpu_commit()
603 dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; in vmw_stdu_bo_cpu_commit()
605 src_pitch = ddirty->pitch; in vmw_stdu_bo_cpu_commit()
606 src_bo = &ddirty->buf->base; in vmw_stdu_bo_cpu_commit()
607 src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; in vmw_stdu_bo_cpu_commit()
610 if (ddirty->transfer != SVGA3D_WRITE_HOST_VRAM) { in vmw_stdu_bo_cpu_commit()
618 width * stdu->cpp, height, &diff); in vmw_stdu_bo_cpu_commit()
620 if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM && in vmw_stdu_bo_cpu_commit()
632 ret = vmw_kms_update_proxy(&stdu->display_srf->res, ®ion, in vmw_stdu_bo_cpu_commit()
638 dev_priv = vmw_priv(stdu->base.crtc.dev); in vmw_stdu_bo_cpu_commit()
643 vmw_stdu_populate_update(cmd, stdu->base.unit, in vmw_stdu_bo_cpu_commit()
651 ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top = S32_MAX; in vmw_stdu_bo_cpu_commit()
652 ddirty->right = ddirty->bottom = S32_MIN; in vmw_stdu_bo_cpu_commit()
656 * vmw_kms_stdu_dma - Perform a DMA transfer between a buffer-object backed
660 * @file_priv: Pointer to a struct drm-file identifying the caller. May be
662 * @vfb: Pointer to the buffer-object backed framebuffer.
663 * @user_fence_rep: User-space provided structure for fence information.
674 * If DMA-ing till the screen target system, the function will also notify
677 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
693 container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; in vmw_kms_stdu_dma()
714 ddirty.left = ddirty.top = S32_MAX; in vmw_kms_stdu_dma()
717 ddirty.pitch = vfb->base.pitches[0]; in vmw_kms_stdu_dma()
749 * vmw_kms_stdu_surface_clip - Callback to encode a surface copy command cliprect
760 struct vmw_stdu_surface_copy *cmd = dirty->cmd; in vmw_kms_stdu_surface_clip()
762 container_of(dirty->unit, typeof(*stdu), base); in vmw_kms_stdu_surface_clip()
764 if (sdirty->sid != stdu->display_srf->res.id) { in vmw_kms_stdu_surface_clip()
767 blit += dirty->num_hits; in vmw_kms_stdu_surface_clip()
768 blit->srcx = dirty->fb_x; in vmw_kms_stdu_surface_clip()
769 blit->srcy = dirty->fb_y; in vmw_kms_stdu_surface_clip()
770 blit->x = dirty->unit_x1; in vmw_kms_stdu_surface_clip()
771 blit->y = dirty->unit_y1; in vmw_kms_stdu_surface_clip()
772 blit->d = 1; in vmw_kms_stdu_surface_clip()
773 blit->w = dirty->unit_x2 - dirty->unit_x1; in vmw_kms_stdu_surface_clip()
774 blit->h = dirty->unit_y2 - dirty->unit_y1; in vmw_kms_stdu_surface_clip()
777 dirty->num_hits++; in vmw_kms_stdu_surface_clip()
780 sdirty->left = min_t(s32, sdirty->left, dirty->unit_x1); in vmw_kms_stdu_surface_clip()
781 sdirty->top = min_t(s32, sdirty->top, dirty->unit_y1); in vmw_kms_stdu_surface_clip()
782 sdirty->right = max_t(s32, sdirty->right, dirty->unit_x2); in vmw_kms_stdu_surface_clip()
783 sdirty->bottom = max_t(s32, sdirty->bottom, dirty->unit_y2); in vmw_kms_stdu_surface_clip()
787 * vmw_kms_stdu_surface_fifo_commit - Callback to fill in and submit a surface
800 container_of(dirty->unit, typeof(*stdu), base); in vmw_kms_stdu_surface_fifo_commit()
801 struct vmw_stdu_surface_copy *cmd = dirty->cmd; in vmw_kms_stdu_surface_fifo_commit()
803 size_t blit_size = sizeof(SVGA3dCopyBox) * dirty->num_hits; in vmw_kms_stdu_surface_fifo_commit()
806 if (!dirty->num_hits) { in vmw_kms_stdu_surface_fifo_commit()
807 vmw_cmd_commit(dirty->dev_priv, 0); in vmw_kms_stdu_surface_fifo_commit()
811 if (sdirty->sid != stdu->display_srf->res.id) { in vmw_kms_stdu_surface_fifo_commit()
814 cmd->header.id = SVGA_3D_CMD_SURFACE_COPY; in vmw_kms_stdu_surface_fifo_commit()
815 cmd->header.size = sizeof(cmd->body) + blit_size; in vmw_kms_stdu_surface_fifo_commit()
816 cmd->body.src.sid = sdirty->sid; in vmw_kms_stdu_surface_fifo_commit()
817 cmd->body.dest.sid = stdu->display_srf->res.id; in vmw_kms_stdu_surface_fifo_commit()
818 update = (struct vmw_stdu_update *) &blit[dirty->num_hits]; in vmw_kms_stdu_surface_fifo_commit()
820 stdu->display_srf->res.res_dirty = true; in vmw_kms_stdu_surface_fifo_commit()
822 update = dirty->cmd; in vmw_kms_stdu_surface_fifo_commit()
826 vmw_stdu_populate_update(update, stdu->base.unit, sdirty->left, in vmw_kms_stdu_surface_fifo_commit()
827 sdirty->right, sdirty->top, sdirty->bottom); in vmw_kms_stdu_surface_fifo_commit()
829 vmw_cmd_commit(dirty->dev_priv, commit_size); in vmw_kms_stdu_surface_fifo_commit()
831 sdirty->left = sdirty->top = S32_MAX; in vmw_kms_stdu_surface_fifo_commit()
832 sdirty->right = sdirty->bottom = S32_MIN; in vmw_kms_stdu_surface_fifo_commit()
836 * vmw_kms_stdu_surface_dirty - Dirty part of a surface backed framebuffer
839 * @framebuffer: Pointer to the surface-buffer backed framebuffer.
849 * @out_fence: If non-NULL, will return a ref-counted pointer to a
854 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
875 srf = &vfbs->surface->res; in vmw_kms_stdu_surface_dirty()
882 ret = vmw_validation_prepare(&val_ctx, &dev_priv->cmdbuf_mutex, true); in vmw_kms_stdu_surface_dirty()
886 if (vfbs->is_bo_proxy) { in vmw_kms_stdu_surface_dirty()
898 sdirty.sid = srf->id; in vmw_kms_stdu_surface_dirty()
899 sdirty.left = sdirty.top = S32_MAX; in vmw_kms_stdu_surface_dirty()
940 * vmw_stdu_encoder_destroy - cleans up the STDU
945 * this can be a no-op. Nevertheless, it doesn't hurt of have this in case
965 * vmw_stdu_connector_destroy - cleans up the STDU
970 * this can be a no-op. Nevertheless, it doesn't hurt of have this in case
1005 * vmw_stdu_primary_plane_cleanup_fb - Unpins the display surface
1020 if (vps->surf) in vmw_stdu_primary_plane_cleanup_fb()
1021 WARN_ON(!vps->pinned); in vmw_stdu_primary_plane_cleanup_fb()
1025 vps->content_fb_type = SAME_AS_DISPLAY; in vmw_stdu_primary_plane_cleanup_fb()
1026 vps->cpp = 0; in vmw_stdu_primary_plane_cleanup_fb()
1032 * vmw_stdu_primary_plane_prepare_fb - Readies the display surface
1047 struct vmw_private *dev_priv = vmw_priv(plane->dev); in vmw_stdu_primary_plane_prepare_fb()
1048 struct drm_framebuffer *new_fb = new_state->fb; in vmw_stdu_primary_plane_prepare_fb()
1053 uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h; in vmw_stdu_primary_plane_prepare_fb()
1058 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1059 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1060 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1067 new_vfbs = (vfb->bo) ? NULL : vmw_framebuffer_to_vfbs(new_fb); in vmw_stdu_primary_plane_prepare_fb()
1070 new_vfbs->surface->metadata.base_size.width == hdisplay && in vmw_stdu_primary_plane_prepare_fb()
1071 new_vfbs->surface->metadata.base_size.height == vdisplay) in vmw_stdu_primary_plane_prepare_fb()
1073 else if (vfb->bo) in vmw_stdu_primary_plane_prepare_fb()
1087 switch (new_fb->format->cpp[0]*8) { in vmw_stdu_primary_plane_prepare_fb()
1102 return -EINVAL; in vmw_stdu_primary_plane_prepare_fb()
1109 metadata = new_vfbs->surface->metadata; in vmw_stdu_primary_plane_prepare_fb()
1116 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1118 vps->surf->metadata.base_size; in vmw_stdu_primary_plane_prepare_fb()
1122 vps->surf->metadata.format != metadata.format) { in vmw_stdu_primary_plane_prepare_fb()
1123 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1124 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1129 if (!vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1131 &vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1144 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1145 WARN_ON(vps->pinned != 0); in vmw_stdu_primary_plane_prepare_fb()
1146 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1149 vps->surf = vmw_surface_reference(new_vfbs->surface); in vmw_stdu_primary_plane_prepare_fb()
1152 if (vps->surf) { in vmw_stdu_primary_plane_prepare_fb()
1155 ret = vmw_resource_pin(&vps->surf->res, false); in vmw_stdu_primary_plane_prepare_fb()
1159 vps->pinned++; in vmw_stdu_primary_plane_prepare_fb()
1162 vps->content_fb_type = new_content_type; in vmw_stdu_primary_plane_prepare_fb()
1170 if (vps->content_fb_type == SEPARATE_BO && in vmw_stdu_primary_plane_prepare_fb()
1172 vps->cpp = new_fb->pitches[0] / new_fb->width; in vmw_stdu_primary_plane_prepare_fb()
1177 vmw_surface_unreference(&vps->surf); in vmw_stdu_primary_plane_prepare_fb()
1203 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_dma()
1204 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_dma()
1206 cmd_dma->header.id = SVGA_3D_CMD_SURFACE_DMA; in vmw_stdu_bo_populate_dma()
1207 cmd_dma->header.size = sizeof(cmd_dma->body) + in vmw_stdu_bo_populate_dma()
1210 vmw_bo_get_guest_ptr(&vfbbo->buffer->base, &cmd_dma->body.guest.ptr); in vmw_stdu_bo_populate_dma()
1211 cmd_dma->body.guest.pitch = update->vfb->base.pitches[0]; in vmw_stdu_bo_populate_dma()
1212 cmd_dma->body.host.sid = stdu->display_srf->res.id; in vmw_stdu_bo_populate_dma()
1213 cmd_dma->body.host.face = 0; in vmw_stdu_bo_populate_dma()
1214 cmd_dma->body.host.mipmap = 0; in vmw_stdu_bo_populate_dma()
1215 cmd_dma->body.transfer = SVGA3D_WRITE_HOST_VRAM; in vmw_stdu_bo_populate_dma()
1226 box->srcx = fb_x; in vmw_stdu_bo_populate_clip()
1227 box->srcy = fb_y; in vmw_stdu_bo_populate_clip()
1228 box->srcz = 0; in vmw_stdu_bo_populate_clip()
1229 box->x = clip->x1; in vmw_stdu_bo_populate_clip()
1230 box->y = clip->y1; in vmw_stdu_bo_populate_clip()
1231 box->z = 0; in vmw_stdu_bo_populate_clip()
1232 box->w = drm_rect_width(clip); in vmw_stdu_bo_populate_clip()
1233 box->h = drm_rect_height(clip); in vmw_stdu_bo_populate_clip()
1234 box->d = 1; in vmw_stdu_bo_populate_clip()
1246 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_update()
1247 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_update()
1249 suffix->suffixSize = sizeof(*suffix); in vmw_stdu_bo_populate_update()
1250 suffix->maximumOffset = vfbbo->buffer->base.base.size; in vmw_stdu_bo_populate_update()
1252 vmw_stdu_populate_update(&suffix[1], stdu->base.unit, bb->x1, bb->x2, in vmw_stdu_bo_populate_update()
1253 bb->y1, bb->y2); in vmw_stdu_bo_populate_update()
1264 bo_update->fb_left = INT_MAX; in vmw_stdu_bo_pre_clip_cpu()
1265 bo_update->fb_top = INT_MAX; in vmw_stdu_bo_pre_clip_cpu()
1277 bo_update->fb_left = min_t(int, bo_update->fb_left, fb_x); in vmw_stdu_bo_clip_cpu()
1278 bo_update->fb_top = min_t(int, bo_update->fb_top, fb_y); in vmw_stdu_bo_clip_cpu()
1299 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_bo_populate_update_cpu()
1300 vfbbo = container_of(update->vfb, typeof(*vfbbo), base); in vmw_stdu_bo_populate_update_cpu()
1302 width = bb->x2 - bb->x1; in vmw_stdu_bo_populate_update_cpu()
1303 height = bb->y2 - bb->y1; in vmw_stdu_bo_populate_update_cpu()
1305 diff.cpp = stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1307 dst_bo = &stdu->display_srf->res.backup->base; in vmw_stdu_bo_populate_update_cpu()
1308 dst_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1309 dst_offset = bb->y1 * dst_pitch + bb->x1 * stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1311 src_bo = &vfbbo->buffer->base; in vmw_stdu_bo_populate_update_cpu()
1312 src_pitch = update->vfb->base.pitches[0]; in vmw_stdu_bo_populate_update_cpu()
1313 src_offset = bo_update->fb_top * src_pitch + bo_update->fb_left * in vmw_stdu_bo_populate_update_cpu()
1314 stdu->cpp; in vmw_stdu_bo_populate_update_cpu()
1317 src_offset, src_pitch, width * stdu->cpp, height, in vmw_stdu_bo_populate_update_cpu()
1321 SVGA3dBox *box = &cmd_img->body.box; in vmw_stdu_bo_populate_update_cpu()
1323 cmd_img->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; in vmw_stdu_bo_populate_update_cpu()
1324 cmd_img->header.size = sizeof(cmd_img->body); in vmw_stdu_bo_populate_update_cpu()
1325 cmd_img->body.image.sid = stdu->display_srf->res.id; in vmw_stdu_bo_populate_update_cpu()
1326 cmd_img->body.image.face = 0; in vmw_stdu_bo_populate_update_cpu()
1327 cmd_img->body.image.mipmap = 0; in vmw_stdu_bo_populate_update_cpu()
1329 box->x = diff.rect.x1; in vmw_stdu_bo_populate_update_cpu()
1330 box->y = diff.rect.y1; in vmw_stdu_bo_populate_update_cpu()
1331 box->z = 0; in vmw_stdu_bo_populate_update_cpu()
1332 box->w = drm_rect_width(&diff.rect); in vmw_stdu_bo_populate_update_cpu()
1333 box->h = drm_rect_height(&diff.rect); in vmw_stdu_bo_populate_update_cpu()
1334 box->d = 1; in vmw_stdu_bo_populate_update_cpu()
1337 vmw_stdu_populate_update(cmd_update, stdu->base.unit, in vmw_stdu_bo_populate_update_cpu()
1348 * vmw_stdu_plane_update_bo - Update display unit for bo backed fb.
1353 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
1371 bo_update.base.du = vmw_crtc_to_du(plane->state->crtc); in vmw_stdu_plane_update_bo()
1404 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_fifo_size_same_display()
1406 if (vfbs->is_bo_proxy) in vmw_stdu_surface_fifo_size_same_display()
1420 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_fifo_size()
1422 if (vfbs->is_bo_proxy) in vmw_stdu_surface_fifo_size()
1435 struct drm_plane_state *state = update->plane->state; in vmw_stdu_surface_update_proxy()
1436 struct drm_plane_state *old_state = update->old_state; in vmw_stdu_surface_update_proxy()
1442 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_update_proxy()
1450 SVGA3dBox *box = &cmd_update->body.box; in vmw_stdu_surface_update_proxy()
1452 cmd_update->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; in vmw_stdu_surface_update_proxy()
1453 cmd_update->header.size = sizeof(cmd_update->body); in vmw_stdu_surface_update_proxy()
1454 cmd_update->body.image.sid = vfbs->surface->res.id; in vmw_stdu_surface_update_proxy()
1455 cmd_update->body.image.face = 0; in vmw_stdu_surface_update_proxy()
1456 cmd_update->body.image.mipmap = 0; in vmw_stdu_surface_update_proxy()
1458 box->x = clip.x1; in vmw_stdu_surface_update_proxy()
1459 box->y = clip.y1; in vmw_stdu_surface_update_proxy()
1460 box->z = 0; in vmw_stdu_surface_update_proxy()
1461 box->w = drm_rect_width(&clip); in vmw_stdu_surface_update_proxy()
1462 box->h = drm_rect_height(&clip); in vmw_stdu_surface_update_proxy()
1463 box->d = 1; in vmw_stdu_surface_update_proxy()
1480 stdu = container_of(update->du, typeof(*stdu), base); in vmw_stdu_surface_populate_copy()
1481 vfbs = container_of(update->vfb, typeof(*vfbs), base); in vmw_stdu_surface_populate_copy()
1483 cmd_copy->header.id = SVGA_3D_CMD_SURFACE_COPY; in vmw_stdu_surface_populate_copy()
1484 cmd_copy->header.size = sizeof(cmd_copy->body) + sizeof(SVGA3dCopyBox) * in vmw_stdu_surface_populate_copy()
1486 cmd_copy->body.src.sid = vfbs->surface->res.id; in vmw_stdu_surface_populate_copy()
1487 cmd_copy->body.dest.sid = stdu->display_srf->res.id; in vmw_stdu_surface_populate_copy()
1499 box->srcx = fb_x; in vmw_stdu_surface_populate_clip()
1500 box->srcy = fb_y; in vmw_stdu_surface_populate_clip()
1501 box->srcz = 0; in vmw_stdu_surface_populate_clip()
1502 box->x = clip->x1; in vmw_stdu_surface_populate_clip()
1503 box->y = clip->y1; in vmw_stdu_surface_populate_clip()
1504 box->z = 0; in vmw_stdu_surface_populate_clip()
1505 box->w = drm_rect_width(clip); in vmw_stdu_surface_populate_clip()
1506 box->h = drm_rect_height(clip); in vmw_stdu_surface_populate_clip()
1507 box->d = 1; in vmw_stdu_surface_populate_clip()
1516 vmw_stdu_populate_update(cmd, update->du->unit, bb->x1, bb->x2, bb->y1, in vmw_stdu_surface_populate_update()
1517 bb->y2); in vmw_stdu_surface_populate_update()
1523 * vmw_stdu_plane_update_surface - Update display unit for surface backed fb
1528 * @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
1544 stdu = vmw_crtc_to_stdu(plane->state->crtc); in vmw_stdu_plane_update_surface()
1551 srf_update.du = vmw_crtc_to_du(plane->state->crtc); in vmw_stdu_plane_update_surface()
1554 srf_update.mutex = &dev_priv->cmdbuf_mutex; in vmw_stdu_plane_update_surface()
1558 if (vfbs->is_bo_proxy) in vmw_stdu_plane_update_surface()
1561 if (vfbs->surface->res.id != stdu->display_srf->res.id) { in vmw_stdu_plane_update_surface()
1576 * vmw_stdu_primary_plane_atomic_update - formally switches STDU to new plane
1580 * Formally update stdu->display_srf to the new plane, and bind the new
1592 struct drm_crtc *crtc = new_state->crtc; in vmw_stdu_primary_plane_atomic_update()
1600 if (crtc && new_state->fb) { in vmw_stdu_primary_plane_atomic_update()
1602 vmw_framebuffer_to_vfb(new_state->fb); in vmw_stdu_primary_plane_atomic_update()
1604 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_primary_plane_atomic_update()
1606 stdu->display_srf = vps->surf; in vmw_stdu_primary_plane_atomic_update()
1607 stdu->content_fb_type = vps->content_fb_type; in vmw_stdu_primary_plane_atomic_update()
1608 stdu->cpp = vps->cpp; in vmw_stdu_primary_plane_atomic_update()
1610 ret = vmw_stdu_bind_st(dev_priv, stdu, &stdu->display_srf->res); in vmw_stdu_primary_plane_atomic_update()
1614 if (vfb->bo) in vmw_stdu_primary_plane_atomic_update()
1624 crtc = old_state->crtc; in vmw_stdu_primary_plane_atomic_update()
1626 dev_priv = vmw_priv(crtc->dev); in vmw_stdu_primary_plane_atomic_update()
1629 if (!stdu->defined) in vmw_stdu_primary_plane_atomic_update()
1644 event = crtc->state->event; in vmw_stdu_primary_plane_atomic_update()
1646 struct drm_file *file_priv = event->base.file_priv; in vmw_stdu_primary_plane_atomic_update()
1650 &event->base, in vmw_stdu_primary_plane_atomic_update()
1651 &event->event.vbl.tv_sec, in vmw_stdu_primary_plane_atomic_update()
1652 &event->event.vbl.tv_usec, in vmw_stdu_primary_plane_atomic_update()
1657 crtc->state->event = NULL; in vmw_stdu_primary_plane_atomic_update()
1715 * vmw_stdu_init - Sets up a Screen Target Display Unit
1727 struct drm_device *dev = &dev_priv->drm; in vmw_stdu_init()
1737 return -ENOMEM; in vmw_stdu_init()
1739 stdu->base.unit = unit; in vmw_stdu_init()
1740 crtc = &stdu->base.crtc; in vmw_stdu_init()
1741 encoder = &stdu->base.encoder; in vmw_stdu_init()
1742 connector = &stdu->base.connector; in vmw_stdu_init()
1743 primary = &stdu->base.primary; in vmw_stdu_init()
1744 cursor = &stdu->base.cursor; in vmw_stdu_init()
1746 stdu->base.pref_active = (unit == 0); in vmw_stdu_init()
1747 stdu->base.pref_width = dev_priv->initial_width; in vmw_stdu_init()
1748 stdu->base.pref_height = dev_priv->initial_height; in vmw_stdu_init()
1749 stdu->base.is_implicit = false; in vmw_stdu_init()
1766 ret = drm_universal_plane_init(dev, &cursor->base, in vmw_stdu_init()
1773 drm_plane_cleanup(&stdu->base.primary); in vmw_stdu_init()
1777 drm_plane_helper_add(&cursor->base, &vmw_stdu_cursor_plane_helper_funcs); in vmw_stdu_init()
1787 connector->status = vmw_du_connector_detect(connector, false); in vmw_stdu_init()
1797 encoder->possible_crtcs = (1 << unit); in vmw_stdu_init()
1798 encoder->possible_clones = 0; in vmw_stdu_init()
1807 &cursor->base, in vmw_stdu_init()
1818 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1819 dev_priv->hotplug_mode_update_property, 1); in vmw_stdu_init()
1820 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1821 dev->mode_config.suggested_x_property, 0); in vmw_stdu_init()
1822 drm_object_attach_property(&connector->base, in vmw_stdu_init()
1823 dev->mode_config.suggested_y_property, 0); in vmw_stdu_init()
1840 * vmw_stdu_destroy - Cleans up a vmw_screen_target_display_unit
1848 vmw_du_cleanup(&stdu->base); in vmw_stdu_destroy()
1861 * vmw_kms_stdu_init_display - Initializes a Screen Target based display
1875 struct drm_device *dev = &dev_priv->drm; in vmw_kms_stdu_init_display()
1880 if (!dev_priv->has_mob) in vmw_kms_stdu_init_display()
1881 return -ENOSYS; in vmw_kms_stdu_init_display()
1883 if (!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS)) in vmw_kms_stdu_init_display()
1884 return -ENOSYS; in vmw_kms_stdu_init_display()
1890 dev_priv->active_display_unit = vmw_du_screen_target; in vmw_kms_stdu_init_display()
1896 drm_err(&dev_priv->drm, in vmw_kms_stdu_init_display()