summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gralloc_drm.c3
-rw-r--r--gralloc_drm.h1
-rw-r--r--gralloc_drm_handle.h4
-rw-r--r--gralloc_drm_kms.c23
4 files changed, 30 insertions, 1 deletions
diff --git a/gralloc_drm.c b/gralloc_drm.c
index 53d764a..3006a9f 100644
--- a/gralloc_drm.c
+++ b/gralloc_drm.c
@@ -262,6 +262,7 @@ static struct gralloc_drm_handle_t *create_bo_handle(int width,
handle->height = height;
handle->format = format;
handle->usage = usage;
+ handle->plane_mask = 0;
return handle;
}
@@ -279,6 +280,8 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_create(struct gralloc_drm_t *drm,
if (!handle)
return NULL;
+ handle->plane_mask = planes_for_format(drm, format);
+
bo = drm->drv->alloc(drm->drv, handle);
if (!bo) {
free(handle);
diff --git a/gralloc_drm.h b/gralloc_drm.h
index b06e438..8059907 100644
--- a/gralloc_drm.h
+++ b/gralloc_drm.h
@@ -122,6 +122,7 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_from_handle(buffer_handle_t handle);
buffer_handle_t gralloc_drm_bo_get_handle(struct gralloc_drm_bo_t *bo, int *stride);
int gralloc_drm_get_gem_handle(buffer_handle_t handle);
void gralloc_drm_resolve_format(buffer_handle_t _handle, uint32_t *pitches, uint32_t *offsets, uint32_t *handles);
+unsigned int planes_for_format(struct gralloc_drm_t *drm, int hal_format);
int gralloc_drm_bo_lock(struct gralloc_drm_bo_t *bo, int x, int y, int w, int h, int enable_write, void **addr);
void gralloc_drm_bo_unlock(struct gralloc_drm_bo_t *bo);
diff --git a/gralloc_drm_handle.h b/gralloc_drm_handle.h
index 430b480..70a1ae8 100644
--- a/gralloc_drm_handle.h
+++ b/gralloc_drm_handle.h
@@ -31,7 +31,7 @@ struct gralloc_drm_handle_t {
native_handle_t base;
#define GRALLOC_DRM_HANDLE_MAGIC 0x12345678
-#define GRALLOC_DRM_HANDLE_NUM_INTS 9
+#define GRALLOC_DRM_HANDLE_NUM_INTS 10
#define GRALLOC_DRM_HANDLE_NUM_FDS 0
int magic;
@@ -40,6 +40,8 @@ struct gralloc_drm_handle_t {
int format;
int usage;
+ unsigned int plane_mask; /* planes that support handle */
+
int name; /* the name of the bo */
int stride; /* the stride in bytes */
diff --git a/gralloc_drm_kms.c b/gralloc_drm_kms.c
index a921e6c..91e7e63 100644
--- a/gralloc_drm_kms.c
+++ b/gralloc_drm_kms.c
@@ -87,6 +87,29 @@ static int resolve_drm_format(struct gralloc_drm_bo_t *bo,
}
/*
+ * Returns planes that are supported for a particular format
+ */
+unsigned int planes_for_format(struct gralloc_drm_t *drm,
+ int hal_format)
+{
+ unsigned int i, j, mask = 0;
+ unsigned int drm_format = drm_format_from_hal(hal_format);
+ struct gralloc_drm_plane_t *plane = drm->planes;
+
+ /* no planes available */
+ if (!plane)
+ return 0;
+
+ /* iterate through planes, mark those that match format */
+ for (i=0; i<drm->plane_resources->count_planes; i++, plane++)
+ for (j=0; j<plane->drm_plane->count_formats; j++)
+ if (plane->drm_plane->formats[j] == drm_format)
+ mask |= (2 << plane->drm_plane->plane_id);
+
+ return mask;
+}
+
+/*
* Add a fb object for a bo.
*/
int gralloc_drm_bo_add_fb(struct gralloc_drm_bo_t *bo)