[Mesa-dev] [PATCH 2/5] gbm: add shared_handle(drm buffer region name)
Zhao Halley
halley.zhao at intel.com
Tue Jul 17 00:14:33 PDT 2012
---
src/gbm/backends/dri/gbm_dri.c | 13 +++++++++++++
src/gbm/main/gbm.c | 18 ++++++++++++++++++
src/gbm/main/gbm.h | 3 +++
src/gbm/main/gbmint.h | 2 ++
4 files changed, 36 insertions(+), 0 deletions(-)
mode change 100644 => 100755 src/gbm/backends/dri/gbm_dri.c
mode change 100644 => 100755 src/gbm/main/gbm.c
mode change 100644 => 100755 src/gbm/main/gbm.h
mode change 100644 => 100755 src/gbm/main/gbmint.h
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
old mode 100644
new mode 100755
index f09f6ef..fef9d47
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -344,6 +344,18 @@ gbm_dri_to_gbm_format(uint32_t dri_format)
return ret;
}
+static union gbm_bo_handle
+gbm_dri_bo_get_shared_handle(struct gbm_bo *_bo)
+{
+ struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
+ struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+
+ dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME,
+ (uint32_t *) &bo->base.base.shared_handle.u32);
+
+ return bo->base.base.shared_handle;
+}
+
static struct gbm_bo *
gbm_dri_bo_import(struct gbm_device *gbm,
uint32_t type, void *buffer, uint32_t usage)
@@ -557,6 +569,7 @@ dri_device_create(int fd)
dri->base.base.destroy = dri_destroy;
dri->base.base.surface_create = gbm_dri_surface_create;
dri->base.base.surface_destroy = gbm_dri_surface_destroy;
+ dri->base.base.bo_get_shared_handle = gbm_dri_bo_get_shared_handle;
dri->base.type = GBM_DRM_DRIVER_TYPE_DRI;
dri->base.base.name = "drm";
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
old mode 100644
new mode 100755
index c58576d..317962b
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -231,6 +231,24 @@ gbm_bo_get_handle(struct gbm_bo *bo)
return bo->handle;
}
+/** Get shared handle(global buffer region name) of the buffer object,
+ * this handle can be shared among processes
+ *
+ * This is stored in the platform generic union gbm_bo_handle type. However
+ * the format of this handle is platform specific.
+ *
+ * \param bo The buffer object
+ * \return Returns the handle of the allocated buffer object
+ */
+GBM_EXPORT union gbm_bo_handle
+gbm_bo_get_shared_handle(struct gbm_bo *bo)
+{
+ if (bo->shared_handle.u32) return bo->shared_handle;
+
+ return bo->gbm->bo_get_shared_handle(bo);
+
+}
+
/** Write data into the buffer object
*
* If the buffer object was created with the GBM_BO_USE_WRITE flag,
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
old mode 100644
new mode 100755
index 9d2a030..55f012a
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -255,6 +255,9 @@ gbm_bo_get_device(struct gbm_bo *bo);
union gbm_bo_handle
gbm_bo_get_handle(struct gbm_bo *bo);
+union gbm_bo_handle
+gbm_bo_get_shared_handle(struct gbm_bo *bo);
+
int
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
old mode 100644
new mode 100755
index a467bea..01c55ec
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -68,6 +68,7 @@ struct gbm_device {
uint32_t usage);
struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type,
void *buffer, uint32_t usage);
+ union gbm_bo_handle (*bo_get_shared_handle)(struct gbm_bo *bo);
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
void (*bo_destroy)(struct gbm_bo *bo);
@@ -93,6 +94,7 @@ struct gbm_bo {
uint32_t stride;
uint32_t format;
union gbm_bo_handle handle;
+ union gbm_bo_handle shared_handle; // global handle can be shared among processes
void *user_data;
void (*destroy_user_data)(struct gbm_bo *, void *);
};
--
1.7.5.4
More information about the mesa-dev
mailing list