summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalyan Kondapally <kalyan.kondapally@intel.com>2017-03-02 20:40:42 -0800
committerRobert Foss <robert.foss@collabora.com>2017-03-22 14:38:43 -0400
commit26dcb6d8b8657911a4c8bb16d7bfb19b733b2255 (patch)
tree6a9523dc36b5221529f0f55f9f45d3b0097e07d1
parent6f365e1e57bb1209d8c2a3be6d0c264c297e6295 (diff)
downloaddrm_hwcomposer-26dcb6d8b8657911a4c8bb16d7bfb19b733b2255.tar.gz
drm_hwcomposer-26dcb6d8b8657911a4c8bb16d7bfb19b733b2255.tar.xz
drm_hwcomposer: Split FB creation and buffer import
We currently import buffer for a given gralloc handle and also immediately create an FB for it. We may or may not end up using this buffer on a separate plane (layers could be squashed or need to fallback to GL composition). Hence, split this up and create FB for buffer only when we know that this is going to be used for scanout. We pass in plane_type which will be taken into use in future patches to determine the framebuffer formats to be used for Primary on IA. BUG=None TEST=No Graphics regressions observed on Skylake platform. Change-Id: I522b055ce6c989bdc04d48f2ad9b1791b31bceab Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
-rw-r--r--drmdisplaycompositor.cpp8
-rw-r--r--drmhwcomposer.h2
-rw-r--r--hwcutils.cpp10
-rw-r--r--platform.h6
-rw-r--r--platformdrmgeneric.cpp16
-rw-r--r--platformdrmgeneric.h1
-rw-r--r--platformnv.cpp5
-rw-r--r--platformnv.h1
8 files changed, 45 insertions, 4 deletions
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index 251cdb5..6060688 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -564,6 +564,14 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
break;
}
fb_id = layer.buffer->fb_id;
+ if (fb_id == 0) {
+ ret = layer.buffer.CreateFrameBuffer(plane->type());
+ if (ret) {
+ ALOGE("Failed to Create Framebuffer.");
+ break;
+ }
+ fb_id = layer.buffer->fb_id;
+ }
fence_fd = layer.acquire_fence.get();
display_frame = layer.display_frame;
source_crop = layer.source_crop;
diff --git a/drmhwcomposer.h b/drmhwcomposer.h
index f8440fb..c36fc31 100644
--- a/drmhwcomposer.h
+++ b/drmhwcomposer.h
@@ -70,6 +70,8 @@ class DrmHwcBuffer {
void Clear();
+ int CreateFrameBuffer(uint32_t plane_type);
+
int ImportBuffer(buffer_handle_t handle, Importer *importer);
private:
diff --git a/hwcutils.cpp b/hwcutils.cpp
index 0091575..e752192 100644
--- a/hwcutils.cpp
+++ b/hwcutils.cpp
@@ -58,6 +58,16 @@ int DrmHwcBuffer::ImportBuffer(buffer_handle_t handle, Importer *importer) {
return 0;
}
+int DrmHwcBuffer::CreateFrameBuffer(uint32_t plane_type) {
+ if (importer_ == NULL) {
+ ALOGE("Access of non-existent BO");
+ exit(1);
+ return -1;
+ }
+
+ return importer_->CreateFrameBuffer(&bo_, plane_type);
+}
+
static native_handle_t *dup_buffer_handle(buffer_handle_t handle) {
native_handle_t *new_handle =
native_handle_create(handle->numFds, handle->numInts);
diff --git a/platform.h b/platform.h
index ad3d905..2122f67 100644
--- a/platform.h
+++ b/platform.h
@@ -54,6 +54,12 @@ class Importer {
// Note: This can be called from a different thread than ImportBuffer. The
// implementation is responsible for ensuring thread safety.
virtual int ReleaseBuffer(hwc_drm_bo_t *bo) = 0;
+
+ // Creates a new framebuffer with bo as it's scanout buffer.
+ //
+ // Note: This can be called from a different thread than ImportBuffer. The
+ // implementation is responsible for ensuring thread safety.
+ virtual int CreateFrameBuffer(hwc_drm_bo_t *bo, uint32_t plane_type) = 0;
};
class Planner {
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index 29bfa4c..90337f0 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -172,11 +172,19 @@ int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
bo->gem_handles[0] = gem_handle;
bo->offsets[0] = 0;
- ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
- bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id, 0);
+ return 0;
+}
+
+int DrmGenericImporter::CreateFrameBuffer(hwc_drm_bo_t *bo,
+ uint32_t /*plane_type*/) {
+ int ret =
+ drmModeAddFB2(drm_->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;
+ ALOGE("drmModeAddFB2 error (%dx%d, %c%c%c%c, handle %d pitch %d) (%s)",
+ bo->width, bo->height, bo->format, bo->format >> 8, bo->format >> 16,
+ bo->format >> 24, bo->gem_handles[0], bo->pitches[0], strerror(-ret));
}
return ret;
diff --git a/platformdrmgeneric.h b/platformdrmgeneric.h
index 14137cf..7852855 100644
--- a/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -35,6 +35,7 @@ class DrmGenericImporter : public Importer {
buffer_handle_t handle) override;
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
int ReleaseBuffer(hwc_drm_bo_t *bo) override;
+ int CreateFrameBuffer(hwc_drm_bo_t *bo, uint32_t plane_type) override;
private:
uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
diff --git a/platformnv.cpp b/platformnv.cpp
index a704191..2acda84 100644
--- a/platformnv.cpp
+++ b/platformnv.cpp
@@ -135,6 +135,11 @@ int NvImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return 0;
}
+int NvImporter::CreateFrameBuffer(hwc_drm_bo_t * /*bo*/,
+ uint32_t /*plane_type*/) {
+ return 0;
+}
+
int NvImporter::ReleaseBuffer(hwc_drm_bo_t *bo) {
NvBuffer_t *buf = (NvBuffer_t *)bo->priv;
if (!buf) {
diff --git a/platformnv.h b/platformnv.h
index 8524f21..bf9209b 100644
--- a/platformnv.h
+++ b/platformnv.h
@@ -38,6 +38,7 @@ class NvImporter : public Importer {
buffer_handle_t handle) override;
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
int ReleaseBuffer(hwc_drm_bo_t *bo) override;
+ int CreateFrameBuffer(hwc_drm_bo_t *bo, uint32_t plane_type) override;
private:
typedef struct NvBuffer {