summaryrefslogtreecommitdiff
path: root/drmresources.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drmresources.cpp')
-rw-r--r--drmresources.cpp27
1 files changed, 21 insertions, 6 deletions
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;
}