summaryrefslogtreecommitdiff
path: root/src/gralloc/gralloc_gem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gralloc/gralloc_gem.h')
-rw-r--r--src/gralloc/gralloc_gem.h51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/gralloc/gralloc_gem.h b/src/gralloc/gralloc_gem.h
index e6ef176efa..c82ea2b720 100644
--- a/src/gralloc/gralloc_gem.h
+++ b/src/gralloc/gralloc_gem.h
@@ -56,22 +56,55 @@ drm_gem_validate(buffer_handle_t handle);
struct drm_bo_t *
drm_gem_create_bo(int width, int height, int format, int usage);
-
int
drm_gem_drv_init(struct drm_module_t *drm);
-struct drm_bo_t *
+
+struct drm_gem_drv {
+ int (*init)(struct drm_module_t *drm);
+
+ struct drm_bo_t *(*alloc)(struct drm_module_t *drm, int width, int height,
+ int format, int usage, int *stride);
+
+ void (*free)(struct drm_module_t *drm, struct drm_bo_t *bo);
+
+ int (*map)(struct drm_module_t *drm, struct drm_bo_t *bo,
+ int x, int y, int w, int h, int enable_write, void **addr);
+
+ void (*unmap)(struct drm_module_t *drm, struct drm_bo_t *bo);
+};
+
+extern const struct drm_gem_drv drm_gem_drv_intel;
+extern const struct drm_gem_drv drm_gem_drv_pipe;
+
+static inline struct drm_bo_t *
drm_gem_drv_alloc(struct drm_module_t *drm, int width, int height,
- int format, int usage, int *stride);
+ int format, int usage, int *stride)
+{
+ const struct drm_gem_drv *drv = (const struct drm_gem_drv *) drm->drv;
+ return drv->alloc(drm, width, height, format, usage, stride);
+}
-void
-drm_gem_drv_free(struct drm_module_t *drm, struct drm_bo_t *bo);
+static inline void
+drm_gem_drv_free(struct drm_module_t *drm, struct drm_bo_t *bo)
+{
+ const struct drm_gem_drv *drv = (const struct drm_gem_drv *) drm->drv;
+ drv->free(drm, bo);
+}
-int
+static inline 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);
+ int x, int y, int w, int h, int enable_write, void **addr)
+{
+ const struct drm_gem_drv *drv = (const struct drm_gem_drv *) drm->drv;
+ return drv->map(drm, bo, x, y, w, h, enable_write, addr);
+}
-void
-drm_gem_drv_unmap(struct drm_module_t *drm, struct drm_bo_t *bo);
+static inline void
+drm_gem_drv_unmap(struct drm_module_t *drm, struct drm_bo_t *bo)
+{
+ const struct drm_gem_drv *drv = (const struct drm_gem_drv *) drm->drv;
+ drv->unmap(drm, bo);
+}
#endif /* _GRALLOC_GEM_H_ */