OSDN Git Service

gralloc: set supported planes for buffers on allocation
authorTapani Pälli <tapani.palli@intel.com>
Mon, 21 Jan 2013 12:58:33 +0000 (14:58 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 21 Jan 2013 12:59:04 +0000 (14:59 +0200)
This is done so that we should not have to do it dynamically during
composition. This information will be used later with hwcomposer module
when using planes for composition.

Change-Id: I2b6716fe9a8da81050645900c6c0955385946991
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
gralloc_drm.c
gralloc_drm.h
gralloc_drm_handle.h
gralloc_drm_kms.c

index 53d764a..3006a9f 100644 (file)
@@ -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);
index b06e438..8059907 100644 (file)
@@ -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);
index 430b480..70a1ae8 100644 (file)
@@ -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 */
 
index a921e6c..91e7e63 100644 (file)
@@ -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)