From 587499bbf55b7eb0e1848822a792d535a8a3db1b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 5 Sep 2012 10:56:18 +0100 Subject: [PATCH] sna/video: Use the scanout flag and FB id for sprite framebuffers So that we can use the same teardown path as normal scanouts. Signed-off-by: Chris Wilson --- src/sna/kgem.c | 1 + src/sna/sna_display.c | 1 + src/sna/sna_video.c | 5 ----- src/sna/sna_video_sprite.c | 13 +++++++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 7f687f74..de38f0ab 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1331,6 +1331,7 @@ static void kgem_bo_clear_scanout(struct kgem *kgem, struct kgem_bo *bo) DBG(("%s: handle=%d, fb=%d (reusable=%d)\n", __FUNCTION__, bo->handle, bo->delta, bo->reusable)); if (bo->delta) { + /* XXX will leak if we are not DRM_MASTER. *shrug* */ drmModeRmFB(kgem->fd, bo->delta); bo->delta = 0; } diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 4c260cd2..59e128bc 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -153,6 +153,7 @@ static unsigned get_fb(struct sna *sna, struct kgem_bo *bo, arg.depth = scrn->depth; arg.handle = bo->handle; + assert(sna->scrn->vtSema); /* must be master */ if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_ADDFB, &arg)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "%s: failed to add fb: %dx%d depth=%d, bpp=%d, pitch=%d: %d\n", diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index b8690ece..e7b335a9 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -80,17 +80,12 @@ void sna_video_free_buffers(struct sna *sna, struct sna_video *video) for (i = 0; i < ARRAY_SIZE(video->old_buf); i++) { if (video->old_buf[i]) { - if (video->old_buf[i]->unique_id) - drmModeRmFB(sna->kgem.fd, - video->old_buf[i]->unique_id); kgem_bo_destroy(&sna->kgem, video->old_buf[i]); video->old_buf[i] = NULL; } } if (video->buf) { - if (video->buf->unique_id) - drmModeRmFB(sna->kgem.fd, video->buf->unique_id); kgem_bo_destroy(&sna->kgem, video->buf); video->buf = NULL; } diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 87c5845a..a912590f 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -203,7 +203,7 @@ sna_video_sprite_show(struct sna *sna, } #endif - if (frame->bo->unique_id == 0) { + if (frame->bo->delta == 0) { uint32_t offsets[4], pitches[4], handles[4]; uint32_t pixel_format; @@ -227,19 +227,24 @@ sna_video_sprite_show(struct sna *sna, if (drmModeAddFB2(sna->kgem.fd, frame->width, frame->height, pixel_format, handles, pitches, offsets, - &frame->bo->unique_id, 0)) { + &frame->bo->delta, 0)) { xf86DrvMsg(sna->scrn->scrnIndex, X_ERROR, "failed to add fb\n"); return false; } + + frame->bo->scanout = true; } DBG(("%s: updating plane=%d, handle=%d [fb %d], dst=(%d,%d)x(%d,%d)\n", - __FUNCTION__, plane, frame->bo->handle, frame->bo->unique_id, + __FUNCTION__, plane, frame->bo->handle, frame->bo->delta, dstBox->x1, dstBox->y1, dstBox->x2 - dstBox->x1, dstBox->y2 - dstBox->y1)); + assert(frame->bo->scanout); + assert(frame->bo->delta); + if (drmModeSetPlane(sna->kgem.fd, - plane, sna_crtc_id(crtc), frame->bo->unique_id, 0, + plane, sna_crtc_id(crtc), frame->bo->delta, 0, dstBox->x1, dstBox->y1, dstBox->x2 - dstBox->x1, dstBox->y2 - dstBox->y1, 0, 0, frame->width << 16, frame->height << 16))