Skip to content

Commit 5d35aba

Browse files
deepak-rawatthomashvmw
authored andcommitted
drm/vmwgfx: Implement SOU plane update for BO backed fb
Using the new interface implement SOU plane update for BO backed fb. v2: Rebase to new resource validation. Signed-off-by: Deepak Rawat <drawat@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
1 parent 43d1e62 commit 5d35aba

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ struct vmw_kms_sou_dirty_cmd {
7676
SVGA3dCmdBlitSurfaceToScreen body;
7777
};
7878

79+
struct vmw_kms_sou_define_gmrfb {
80+
uint32_t header;
81+
SVGAFifoCmdDefineGMRFB body;
82+
};
83+
7984
/**
8085
* Display unit using screen objects.
8186
*/
@@ -498,6 +503,102 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane,
498503
return vmw_bo_pin_in_vram(dev_priv, vps->bo, true);
499504
}
500505

506+
static uint32_t vmw_sou_bo_fifo_size(struct vmw_du_update_plane *update,
507+
uint32_t num_hits)
508+
{
509+
return sizeof(struct vmw_kms_sou_define_gmrfb) +
510+
sizeof(struct vmw_kms_sou_bo_blit) * num_hits;
511+
}
512+
513+
static uint32_t vmw_sou_bo_define_gmrfb(struct vmw_du_update_plane *update,
514+
void *cmd)
515+
{
516+
struct vmw_framebuffer_bo *vfbbo =
517+
container_of(update->vfb, typeof(*vfbbo), base);
518+
struct vmw_kms_sou_define_gmrfb *gmr = cmd;
519+
int depth = update->vfb->base.format->depth;
520+
521+
/* Emulate RGBA support, contrary to svga_reg.h this is not
522+
* supported by hosts. This is only a problem if we are reading
523+
* this value later and expecting what we uploaded back.
524+
*/
525+
if (depth == 32)
526+
depth = 24;
527+
528+
gmr->header = SVGA_CMD_DEFINE_GMRFB;
529+
530+
gmr->body.format.bitsPerPixel = update->vfb->base.format->cpp[0] * 8;
531+
gmr->body.format.colorDepth = depth;
532+
gmr->body.format.reserved = 0;
533+
gmr->body.bytesPerLine = update->vfb->base.pitches[0];
534+
vmw_bo_get_guest_ptr(&vfbbo->buffer->base, &gmr->body.ptr);
535+
536+
return sizeof(*gmr);
537+
}
538+
539+
static uint32_t vmw_sou_bo_populate_clip(struct vmw_du_update_plane *update,
540+
void *cmd, struct drm_rect *clip,
541+
uint32_t fb_x, uint32_t fb_y)
542+
{
543+
struct vmw_kms_sou_bo_blit *blit = cmd;
544+
545+
blit->header = SVGA_CMD_BLIT_GMRFB_TO_SCREEN;
546+
blit->body.destScreenId = update->du->unit;
547+
blit->body.srcOrigin.x = fb_x;
548+
blit->body.srcOrigin.y = fb_y;
549+
blit->body.destRect.left = clip->x1;
550+
blit->body.destRect.top = clip->y1;
551+
blit->body.destRect.right = clip->x2;
552+
blit->body.destRect.bottom = clip->y2;
553+
554+
return sizeof(*blit);
555+
}
556+
557+
static uint32_t vmw_stud_bo_post_clip(struct vmw_du_update_plane *update,
558+
void *cmd, struct drm_rect *bb)
559+
{
560+
return 0;
561+
}
562+
563+
/**
564+
* vmw_sou_plane_update_bo - Update display unit for bo backed fb.
565+
* @dev_priv: Device private.
566+
* @plane: Plane state.
567+
* @old_state: Old plane state.
568+
* @vfb: Framebuffer which is blitted to display unit.
569+
* @out_fence: If non-NULL, will return a ref-counted pointer to vmw_fence_obj.
570+
* The returned fence pointer may be NULL in which case the device
571+
* has already synchronized.
572+
*
573+
* Return: 0 on success or a negative error code on failure.
574+
*/
575+
static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv,
576+
struct drm_plane *plane,
577+
struct drm_plane_state *old_state,
578+
struct vmw_framebuffer *vfb,
579+
struct vmw_fence_obj **out_fence)
580+
{
581+
struct vmw_du_update_plane_buffer bo_update;
582+
583+
memset(&bo_update, 0, sizeof(struct vmw_du_update_plane_buffer));
584+
bo_update.base.plane = plane;
585+
bo_update.base.old_state = old_state;
586+
bo_update.base.dev_priv = dev_priv;
587+
bo_update.base.du = vmw_crtc_to_du(plane->state->crtc);
588+
bo_update.base.vfb = vfb;
589+
bo_update.base.out_fence = out_fence;
590+
bo_update.base.mutex = NULL;
591+
bo_update.base.cpu_blit = false;
592+
bo_update.base.intr = true;
593+
594+
bo_update.base.calc_fifo_size = vmw_sou_bo_fifo_size;
595+
bo_update.base.post_prepare = vmw_sou_bo_define_gmrfb;
596+
bo_update.base.clip = vmw_sou_bo_populate_clip;
597+
bo_update.base.post_clip = vmw_stud_bo_post_clip;
598+
599+
return vmw_du_helper_plane_update(&bo_update.base);
600+
}
601+
501602
static uint32_t vmw_sou_surface_fifo_size(struct vmw_du_update_plane *update,
502603
uint32_t num_hits)
503604
{

0 commit comments

Comments
 (0)