/** * Called at vt leave */ void xorg_crtc_cursor_destroy(xf86CrtcPtr crtc) { struct crtc_private *crtcp = crtc->driver_private; if (crtcp->cursor_tex) pipe_resource_reference(&crtcp->cursor_tex, NULL); #ifdef HAVE_LIBKMS if (crtcp->cursor_bo) kms_bo_destroy(&crtcp->cursor_bo); #endif }
static void fb_free_buffer(struct private_module_t *module, struct private_buffer_t *buffer) { if (buffer->fb) { drmModeRmFB(module->fd, buffer->fb); buffer->fb = 0; } if (buffer->vaddr) { kms_bo_unmap(buffer->bo); buffer->vaddr = 0; } if (buffer->bo) kms_bo_destroy(&buffer->bo); }
static void gbm_kms_bo_destroy(struct gbm_bo *_bo) { struct gbm_kms_bo *bo = (struct gbm_kms_bo*)_bo; if (!bo) return; if (bo->addr) kms_bo_unmap(bo->bo); if (bo->bo) kms_bo_destroy(&bo->bo); free(bo); return; }
int test_bo(struct kms_driver *kms) { struct kms_bo *bo; int ret; unsigned attrs[7] = { KMS_WIDTH, 1024, KMS_HEIGHT, 768, KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8, KMS_TERMINATE_PROP_LIST, }; ret = kms_bo_create(kms, attrs, &bo); CHECK_RET_RETURN(ret, "Could not create bo"); kms_bo_destroy(&bo); return 0; }
static void crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; unsigned char *ptr; if (!crtcp->cursor_bo) { unsigned attr[8]; attr[0] = KMS_BO_TYPE; #ifdef KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 attr[1] = KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8; #else attr[1] = KMS_BO_TYPE_CURSOR; #endif attr[2] = KMS_WIDTH; attr[3] = 64; attr[4] = KMS_HEIGHT; attr[5] = 64; attr[6] = 0; if (kms_bo_create(ms->kms, attr, &crtcp->cursor_bo)) return; if (kms_bo_get_prop(crtcp->cursor_bo, KMS_HANDLE, &crtcp->cursor_handle)) goto err_bo_destroy; } kms_bo_map(crtcp->cursor_bo, (void**)&ptr); memcpy(ptr, image, 64*64*4); kms_bo_unmap(crtcp->cursor_bo); if (crtc->cursor_shown) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); return; err_bo_destroy: kms_bo_destroy(&crtcp->cursor_bo); }
static int intel_bo_create(struct kms_driver *kms, const unsigned width, const unsigned height, const enum kms_bo_type type, const unsigned *attr, struct kms_bo **out) { struct drm_i915_gem_create arg; unsigned size, pitch; struct intel_bo *bo; int i, ret; for (i = 0; attr[i]; i += 2) { switch (attr[i]) { case KMS_WIDTH: case KMS_HEIGHT: case KMS_BO_TYPE: break; default: return -EINVAL; } } bo = calloc(1, sizeof(*bo)); if (!bo) return -ENOMEM; if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) { pitch = 64 * 4; size = 64 * 64 * 4; } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) { pitch = width * 4; pitch = (pitch + 512 - 1) & ~(512 - 1); size = pitch * ((height + 4 - 1) & ~(4 - 1)); } else { free(bo); return -EINVAL; } memset(&arg, 0, sizeof(arg)); arg.size = size; ret = drmCommandWriteRead(kms->fd, DRM_I915_GEM_CREATE, &arg, sizeof(arg)); if (ret) goto err_free; bo->base.kms = kms; bo->base.handle = arg.handle; bo->base.size = size; bo->base.pitch = pitch; *out = &bo->base; if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8 && pitch > 512) { struct drm_i915_gem_set_tiling tile; memset(&tile, 0, sizeof(tile)); tile.handle = bo->base.handle; tile.tiling_mode = I915_TILING_X; tile.stride = bo->base.pitch; ret = drmCommandWriteRead(kms->fd, DRM_I915_GEM_SET_TILING, &tile, sizeof(tile)); #if 0 if (ret) { kms_bo_destroy(out); return ret; } #endif } return 0; err_free: free(bo); return ret; }
static void bo_rockchip_destroy(struct omap_bo *bo) { kms_bo_destroy((struct kms_bo **)&bo->priv_bo); }