summaryrefslogtreecommitdiff
path: root/hwcomposer_import_drm_gralloc.cpp
diff options
context:
space:
mode:
authorLauri Peltonen <lpeltonen@nvidia.com>2015-02-23 20:44:16 +0200
committerStéphane Marchesin <marcheu@google.com>2015-02-26 06:31:41 +0000
commit77d6d7a907dc23a1de7c5544fc0db79bf462ff6f (patch)
tree54fed14526e21c6fc1baebcea235c8386234e0ae /hwcomposer_import_drm_gralloc.cpp
parente147a2a71f7c7f0b3cc925199fe68951cb311379 (diff)
drm_hwcomposer: Cache FB and gem in gralloc buffer
Move drm fb object creation to the importer. In NV importer, use GRALLOC_MODULE_PERFORM_SET_IMPORTER_PRIVATE and GRALLOC_MODULE_PERFORM_GET_IMPORTER_PRIVATE to cache the hwc_drm_bo in the gralloc buffer. This avoids the need to recreate fb objects again each frame, and also greatly simplifies managing the lifetime of the gem handles. The drm_gralloc importer does not support caching at this point. In an attempt to keep it somewhat working, add hwc_import_bo_release function that hwc calls when it's ok to rm fb. If hwc_import_bo_release returns true, then hwc will clean up gem handles as it did before. We should consider doing a follow-up patch that adds fb/gem caching to drm_gralloc importer also. Then some of the code that is kept in this patch for backwards compatibility can be removed. Change-Id: I92857dcaddf8cea219ebc041e16ef76087a1b696 Reviewed-on: https://chrome-internal-review.googlesource.com/200895 Reviewed-by: Stéphane Marchesin <marcheu@google.com> Commit-Queue: Stéphane Marchesin <marcheu@google.com> Tested-by: Stéphane Marchesin <marcheu@google.com>
Diffstat (limited to 'hwcomposer_import_drm_gralloc.cpp')
-rw-r--r--hwcomposer_import_drm_gralloc.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/hwcomposer_import_drm_gralloc.cpp b/hwcomposer_import_drm_gralloc.cpp
index e2e2e94..b724c83 100644
--- a/hwcomposer_import_drm_gralloc.cpp
+++ b/hwcomposer_import_drm_gralloc.cpp
@@ -85,7 +85,7 @@ static uint32_t hwc_convert_hal_format_to_drm_format(uint32_t hal_format)
}
}
-int hwc_create_bo_from_import(int fd, hwc_import_context *ctx,
+int hwc_import_bo_create(int fd, hwc_import_context *ctx,
buffer_handle_t handle, struct hwc_drm_bo *bo)
{
gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
@@ -116,5 +116,26 @@ int hwc_create_bo_from_import(int fd, hwc_import_context *ctx,
bo->gem_handles[0] = gem_handle;
bo->offsets[0] = 0;
- return 0;
+ ret = drmModeAddFB2(fd, bo->width, bo->height, bo->format,
+ bo->gem_handles, bo->pitches, bo->offsets,
+ &bo->fb_id, 0);
+ if (ret) {
+ ALOGE("could not create drm fb %d", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
+bool hwc_import_bo_release(int fd, hwc_import_context *ctx,
+ struct hwc_drm_bo *bo)
+{
+ (void)ctx;
+
+ if (bo->fb_id)
+ if (drmModeRmFB(fd, bo->fb_id))
+ ALOGE("Failed to rm fb");
+
+ /* hwc may close the gem handles now. */
+ return true;
}