Skip to contentSkip to conversation

platformdrmgeneric: get the gralloc usage directly from the handle

PATCH In review Rob Herring 2 participants 2 messages Oct 6, 2017 – Oct 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platformdrmgeneric: get the gralloc usage directly from the handle

There's no point in using a gralloc perform() op to retrieve the usage as it is already stored in the handle like width, height, format, etc. So just copy it to the hwc_drm_bo_t and get it directly.

---
I was a bit quick on the trigger with the previous patch. This one is a dependency for it.

 drmhwcgralloc.h        | 1 +
 hwcutils.cpp           | 8 ++------
 platformdrmgeneric.cpp | 1 +
 3 files changed, 4 insertions(+), 6 deletions(-)
drmhwcgralloc.h +1 -0
index 765c8979d2df..c4a42eaf1c54 100644
@@ -56,6 +56,7 @@ typedef struct hwc_drm_bo {
   uint32_t width;
   uint32_t height;
   uint32_t format; /* DRM_FORMAT_* from drm_fourcc.h */
+  uint32_t usage;
   uint32_t pitches[4];
   uint32_t offsets[4];
   uint32_t gem_handles[4];
hwcutils.cpp +2 -6
index 00915757469e..53a7d82889b8 100644
@@ -159,12 +159,8 @@ int DrmHwcLayer::ImportBuffer(Importer *importer,
   if (ret)
     return ret;
 
-  ret = gralloc->perform(gralloc, GRALLOC_MODULE_PERFORM_GET_USAGE,
-                         handle.get(), &gralloc_buffer_usage);
-  if (ret) {
-    ALOGE("Failed to get usage for buffer %p (%d)", handle.get(), ret);
-    return ret;
-  }
+  gralloc_buffer_usage = buffer.operator->()->usage;
+
   return 0;
 }
 
platformdrmgeneric.cpp +1 -0
index aa3d0faee7c0..741d42b6ac33 100644
@@ -116,6 +116,7 @@ int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
   bo->width = gr_handle->width;
   bo->height = gr_handle->height;
   bo->format = ConvertHalFormatToDrm(gr_handle->format);
+  bo->usage = gr_handle->usage;
   bo->pitches[0] = gr_handle->stride;
   bo->gem_handles[0] = gem_handle;
   bo->offsets[0] = 0;
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hey Rob,

I tested the patch on the imx6/etnaviv platform, and it all works. So I pushed the patch with t-b && r-b tags attached.

Rob.

Quoted 56 lines · Rob Herring

There's no point in using a gralloc perform() op to retrieve the usage as
it is already stored in the handle like width, height, format, etc. So just
copy it to the hwc_drm_bo_t and get it directly.

---
I was a bit quick on the trigger with the previous patch. This one is a
dependency for it.

 drmhwcgralloc.h        | 1 +
 hwcutils.cpp           | 8 ++------
 platformdrmgeneric.cpp | 1 +

 3 files changed, 4 insertions(+), 6 deletions(-)
drmhwcgralloc.h +0 -0
index 765c8979d2df..c4a42eaf1c54 100644
@@ -56,6 +56,7 @@ typedef struct hwc_drm_bo {
    uint32_t width;
    uint32_t height;

   uint32_t format; /* DRM_FORMAT_* from drm_fourcc.h */ +  uint32_t usage;
   uint32_t pitches[4];
   uint32_t offsets[4];
   uint32_t gem_handles[4];

hwcutils.cpp +0 -0
index 00915757469e..53a7d82889b8 100644
@@ -159,12 +159,8 @@ int DrmHwcLayer::ImportBuffer(Importer
 *importer,
    if (ret)
      return ret;


-  ret = gralloc->perform(gralloc, GRALLOC_MODULE_PERFORM_GET_USAGE, -                         handle.get(), &gralloc_buffer_usage); -  if (ret) {
-    ALOGE("Failed to get usage for buffer %p (%d)", handle.get(), ret);
-    return ret;
-  }
+  gralloc_buffer_usage = buffer.operator->()->usage;
+
   return 0;
 }

platformdrmgeneric.cpp +0 -0
index aa3d0faee7c0..741d42b6ac33 100644
@@ -116,6 +116,7 @@ int

DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t

Quoted 8 lines

*bo) {
   bo->width = gr_handle->width;
   bo->height = gr_handle->height;
   bo->format = ConvertHalFormatToDrm(gr_handle->format); +  bo->usage = gr_handle->usage;
   bo->pitches[0] = gr_handle->stride; bo->gem_handles[0] = gem_handle; bo->offsets[0] = 0;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel