summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2017-05-17 18:08:14 -0400
committerRobert Foss <robert.foss@collabora.com>2017-05-17 18:58:18 -0400
commit4f4cb902517f5caacea075fb9724e4ce0c435e3d (patch)
tree60b89804edc54eeaff16d5f35f090789a1a7b8d2
parent1c39384d90c40539e2b4b54a7562c36df5b0625a (diff)
downloaddrm_hwcomposer-android-etnaviv.tar.gz
drm_hwcomposer-android-etnaviv.tar.xz
drm_hwcomposer: Get KMS FD from gbm_grallocandroid-etnaviv
Signed-off-by: Robert Foss <robert.foss@collabora.com>
-rw-r--r--drmhwctwo.cpp18
-rw-r--r--drmresources.cpp27
-rw-r--r--drmresources.h5
3 files changed, 35 insertions, 15 deletions
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index f381862..8979b84 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -63,7 +63,16 @@ DrmHwcTwo::DrmHwcTwo() {
}
HWC2::Error DrmHwcTwo::Init() {
- int ret = drm_.Init();
+ int ret;
+
+ ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+ (const hw_module_t **)&gralloc_);
+ if (ret) {
+ ALOGE("Failed to open gralloc module %d", ret);
+ return HWC2::Error::NoResources;
+ }
+
+ ret = drm_.Init(gralloc_);
if (ret) {
ALOGE("Can't initialize drm object %d", ret);
return HWC2::Error::NoResources;
@@ -75,13 +84,6 @@ HWC2::Error DrmHwcTwo::Init() {
return HWC2::Error::NoResources;
}
- ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
- (const hw_module_t **)&gralloc_);
- if (ret) {
- ALOGE("Failed to open gralloc module %d", ret);
- return HWC2::Error::NoResources;
- }
-
displays_.emplace(std::piecewise_construct,
std::forward_as_tuple(HWC_DISPLAY_PRIMARY),
std::forward_as_tuple(&drm_, importer_, gralloc_,
diff --git a/drmresources.cpp b/drmresources.cpp
index 17c912a..9370e63 100644
--- a/drmresources.cpp
+++ b/drmresources.cpp
@@ -42,14 +42,29 @@ DrmResources::~DrmResources() {
event_listener_.Exit();
}
-int DrmResources::Init() {
- char path[PROPERTY_VALUE_MAX];
- property_get("hwc.drm.device", path, "/dev/dri/card0");
+int DrmResources::Init(const gralloc_module_t *gralloc) {
+ int err;
+ int kms_fd;
- /* TODO: Use drmOpenControl here instead */
- fd_.Set(open(path, O_RDWR));
+ if (!gralloc) {
+ ALOGE("gralloc is not provided");
+ return -EINVAL;
+ }
+
+ if (!gralloc->perform) {
+ ALOGE("gralloc does not provide the perform call");
+ return -EINVAL;
+ }
+
+ err = gralloc->perform(gralloc, GRALLOC_MODULE_PERFORM_GET_DRM_FD, &kms_fd);
+ if (err) {
+ ALOGE("Failed to get KMS fd. Error (%d): %s", err, strerror(err));
+ return -ENODEV;
+ }
+
+ fd_.Set(kms_fd);
if (fd() < 0) {
- ALOGE("Failed to open dri- %s", strerror(-errno));
+ ALOGE("Failed to get valid DRM fd: (%d)", fd());
return -ENODEV;
}
diff --git a/drmresources.h b/drmresources.h
index 0cc2456..2058dbc 100644
--- a/drmresources.h
+++ b/drmresources.h
@@ -21,10 +21,13 @@
#include "drmcrtc.h"
#include "drmencoder.h"
#include "drmeventlistener.h"
+#include "drmhwcgralloc.h"
#include "drmplane.h"
#include <stdint.h>
+#include <hardware/hwcomposer.h>
+
namespace android {
class DrmResources {
@@ -32,7 +35,7 @@ class DrmResources {
DrmResources();
~DrmResources();
- int Init();
+ int Init(const gralloc_module_t *gralloc);
int fd() const {
return fd_.get();