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 <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-09-05 10:56:18 +01:00
parent 913adacc54
commit 587499bbf5
4 changed files with 11 additions and 9 deletions

View File

@ -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;
}

View File

@ -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",

View File

@ -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;
}

View File

@ -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))