OSDN Git Service

gralloc: provide methods for hwc to change handle of a plane
authorTapani Pälli <tapani.palli@intel.com>
Fri, 3 May 2013 07:08:54 +0000 (10:08 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 13 May 2013 12:28:35 +0000 (15:28 +0300)
Patch changes reserve_plane to get id number as additional parameter.
This can be used by hwc to make changes to a particular plane. New
api hwc_set_plane_handle is introduced so that hwc can change the
buffer handle of a plane, this is required because after plane has
been reserved for a particular ui layer, this handle can change as
the layer is typically multibuffered.

Change-Id: I32d711ff3565ae9e8f5b8a6691c22b03a50cefe7
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
gralloc.c
gralloc_drm.h
gralloc_drm_kms.c
gralloc_drm_priv.h

index 873945d..92866ca 100644 (file)
--- a/gralloc.c
+++ b/gralloc.c
@@ -354,6 +354,7 @@ struct drm_module_t HAL_MODULE_INFO_SYM = {
        },
        .hwc_reserve_plane = gralloc_drm_reserve_plane,
        .hwc_disable_planes = gralloc_drm_disable_planes,
+       .hwc_set_plane_handle = gralloc_drm_set_plane_handle,
 
        .mutex = PTHREAD_MUTEX_INITIALIZER,
        .drm = NULL
index 4c57296..904fd96 100644 (file)
@@ -138,10 +138,13 @@ int gralloc_drm_bo_add_fb(struct gralloc_drm_bo_t *bo);
 void gralloc_drm_bo_rm_fb(struct gralloc_drm_bo_t *bo);
 int gralloc_drm_bo_post(struct gralloc_drm_bo_t *bo);
 
-int gralloc_drm_reserve_plane(struct gralloc_drm_t *drm, buffer_handle_t handle,
+int gralloc_drm_reserve_plane(struct gralloc_drm_t *drm,
+       buffer_handle_t handle, uint32_t id,
        uint32_t dst_x, uint32_t dst_y, uint32_t dst_w, uint32_t dst_h,
        uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h);
 void gralloc_drm_disable_planes(struct gralloc_drm_t *mod);
+int gralloc_drm_set_plane_handle(struct gralloc_drm_t *drm,
+       uint32_t id, buffer_handle_t handle);
 
 #ifdef __cplusplus
 }
index 1e64312..952998a 100644 (file)
@@ -287,6 +287,7 @@ static void gralloc_drm_set_planes(struct gralloc_drm_t *drm)
  */
 int gralloc_drm_reserve_plane(struct gralloc_drm_t *drm,
        buffer_handle_t handle,
+       uint32_t id,
        uint32_t dst_x,
        uint32_t dst_y,
        uint32_t dst_w,
@@ -333,6 +334,7 @@ int gralloc_drm_reserve_plane(struct gralloc_drm_t *drm,
                        plane->src_w = src_w;
                        plane->src_h = src_h;
                        plane->handle = handle;
+                       plane->id = id;
                        plane->active = 1;
 
                        return 0;
@@ -344,17 +346,38 @@ int gralloc_drm_reserve_plane(struct gralloc_drm_t *drm,
 }
 
 /*
- * Interface for HWC, used to disable all the overlays.
+ * Interface for HWC, used to disable all the overlays. Plane id
+ * is also set to 0 as it should be mappable to a particular layer only
+ * if it has been reserved with 'reserve_plane'.
  */
 void gralloc_drm_disable_planes(struct gralloc_drm_t *drm)
 {
        struct gralloc_drm_plane_t *plane = drm->planes;
        unsigned int i;
 
-       for (i = 0; i < drm->plane_resources->count_planes; i++, plane++)
+       for (i = 0; i < drm->plane_resources->count_planes; i++, plane++) {
                plane->active = 0;
+               plane->id = 0;
+       }
 }
 
+/*
+ * Interface for HWC, used to change handle of a reserved plane.
+ */
+int gralloc_drm_set_plane_handle(struct gralloc_drm_t *drm,
+       uint32_t id, buffer_handle_t handle)
+{
+       struct gralloc_drm_plane_t *plane = drm->planes;
+       unsigned i;
+
+       for (i = 0; i < drm->plane_resources->count_planes; i++, plane++)
+               if (plane->active && plane->id == id) {
+                       plane->handle = handle;
+                       return 0;
+               }
+
+       return -EINVAL;
+}
 
 /*
  * Schedule a page flip.
index d96702e..1a36cc1 100644 (file)
@@ -56,6 +56,9 @@ struct gralloc_drm_plane_t {
        /* handle to display */
        buffer_handle_t handle;
 
+       /* identifier set by hwc */
+       uint32_t id;
+
        /* position, crop and scale */
        uint32_t src_x;
        uint32_t src_y;
@@ -127,10 +130,13 @@ struct drm_module_t {
        gralloc_module_t base;
 
        /* HWC plane API */
-       int (*hwc_reserve_plane) (struct gralloc_drm_t *mod, buffer_handle_t handle,
+       int (*hwc_reserve_plane) (struct gralloc_drm_t *mod,
+               buffer_handle_t handle, uint32_t id,
                uint32_t dst_x, uint32_t dst_y, uint32_t dst_w, uint32_t dst_h,
                uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h);
        void (*hwc_disable_planes) (struct gralloc_drm_t *mod);
+       int (*hwc_set_plane_handle) (struct gralloc_drm_t *mod,
+               uint32_t id, buffer_handle_t handle);
 
        pthread_mutex_t mutex;
        struct gralloc_drm_t *drm;