From 5dddfa859139597d6751f0d982ef84901d1298e0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 19 Mar 2011 22:07:51 +0800 Subject: gralloc: add multiple driver support --- src/gralloc/gralloc_gem_i915.c | 50 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'src/gralloc/gralloc_gem_i915.c') diff --git a/src/gralloc/gralloc_gem_i915.c b/src/gralloc/gralloc_gem_i915.c index 2822fe5c12..9159df68c5 100644 --- a/src/gralloc/gralloc_gem_i915.c +++ b/src/gralloc/gralloc_gem_i915.c @@ -11,7 +11,7 @@ #include "gralloc_gem.h" static void -drm_gem_drv_init_features_locked(struct drm_module_t *drm) +drm_gem_intel_init_features(struct drm_module_t *drm) { struct drm_i915_getparam gp; @@ -40,38 +40,22 @@ drm_gem_drv_init_features_locked(struct drm_module_t *drm) /* XXX there is a bug in the kernel module */ drm->mode_page_flip = 0; - } static int -drm_gem_drv_init_locked(struct drm_module_t *drm) +drm_gem_intel_init(struct drm_module_t *drm) { - if (drm->gem) - return 0; - drm->gem = (void *) drm_intel_bufmgr_gem_init(drm->fd, 16 * 1024); if (!drm->gem) { LOGE("failed to create buffer manager"); return -ENOMEM; } - drm_gem_drv_init_features_locked(drm); + drm_gem_intel_init_features(drm); return 0; } -int -drm_gem_drv_init(struct drm_module_t *drm) -{ - int ret; - - pthread_mutex_lock(&drm->mutex); - ret = drm_gem_drv_init_locked(drm); - pthread_mutex_unlock(&drm->mutex); - - return ret; -} - static uint32_t drm_gem_get_tiling(struct drm_bo_t *bo) { @@ -89,9 +73,9 @@ drm_gem_get_tiling(struct drm_bo_t *bo) return tiling; } -struct drm_bo_t * -drm_gem_drv_alloc(struct drm_module_t *drm, int width, int height, - int format, int usage, int *stride) +static struct drm_bo_t * +drm_gem_intel_alloc(struct drm_module_t *drm, int width, int height, + int format, int usage, int *stride) { drm_intel_bufmgr *bufmgr = (drm_intel_bufmgr *) drm->gem; struct drm_bo_t *bo; @@ -161,16 +145,16 @@ drm_gem_drv_alloc(struct drm_module_t *drm, int width, int height, return bo; } -void -drm_gem_drv_free(struct drm_module_t *drm, struct drm_bo_t *bo) +static void +drm_gem_intel_free(struct drm_module_t *drm, struct drm_bo_t *bo) { drm_intel_bo_unreference((drm_intel_bo *) bo->data); free(bo); } -int -drm_gem_drv_map(struct drm_module_t *drm, struct drm_bo_t *bo, - int x, int y, int w, int h, int enable_write, void **addr) +static int +drm_gem_intel_map(struct drm_module_t *drm, struct drm_bo_t *bo, + int x, int y, int w, int h, int enable_write, void **addr) { drm_intel_bo *ibo = (drm_intel_bo *) bo->data; int err; @@ -198,8 +182,8 @@ drm_gem_drv_map(struct drm_module_t *drm, struct drm_bo_t *bo, return err; } -void -drm_gem_drv_unmap(struct drm_module_t *drm, struct drm_bo_t *bo) +static void +drm_gem_intel_unmap(struct drm_module_t *drm, struct drm_bo_t *bo) { drm_intel_bo *ibo = (drm_intel_bo *) bo->data; @@ -209,3 +193,11 @@ drm_gem_drv_unmap(struct drm_module_t *drm, struct drm_bo_t *bo) else drm_intel_bo_unmap(ibo); } + +const struct drm_gem_drv drm_gem_drv_intel = { + .init = drm_gem_intel_init, + .alloc = drm_gem_intel_alloc, + .free = drm_gem_intel_free, + .map = drm_gem_intel_map, + .unmap = drm_gem_intel_unmap, +}; -- cgit v1.2.3