OSDN Git Service

Merge remote-tracking branch 'origin/master' into oreo-x86 nougat-x86 oreo-x86 android-x86-7.1-r4 android-x86-7.1-r5 android-x86-8.1-r1 android-x86-8.1-r2 android-x86-8.1-r3 android-x86-8.1-r4 android-x86-8.1-r5 android-x86-8.1-r6
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 2 Nov 2018 07:58:42 +0000 (15:58 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 2 Nov 2018 07:58:42 +0000 (15:58 +0800)
Conflicts:
Android.mk
drmconnector.cpp
drmeventlistener.cpp

26 files changed:
Android.mk
CONTRIBUTING [deleted file]
autolock.cpp
drmcompositorworker.cpp
drmconnector.cpp
drmcrtc.cpp
drmdisplaycomposition.cpp
drmdisplaycompositor.cpp
drmdisplaycompositor.h
drmeventlistener.cpp
drmhwctwo.cpp
drmplane.cpp
drmresources.cpp
hwcomposer.cpp
hwcutils.cpp
platform.cpp
platformdrmgeneric.cpp
platformdrmgeneric.h
platformhisi.cpp [new file with mode: 0644]
platformhisi.h [new file with mode: 0644]
platformminigbm.cpp [new file with mode: 0644]
platformminigbm.h [new file with mode: 0644]
platformnv.h [deleted file]
tests/Android.mk
virtualcompositorworker.cpp
vsyncworker.cpp

index 535ba0c..45bb3a2 100644 (file)
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \
        worker.cpp
 
 LOCAL_MODULE := libdrmhwc_utils
+LOCAL_VENDOR_MODULE := true
 
 include $(BUILD_STATIC_LIBRARY)
 
@@ -47,7 +48,6 @@ LOCAL_SHARED_LIBRARIES := \
 LOCAL_STATIC_LIBRARIES := libdrmhwc_utils
 
 LOCAL_C_INCLUDES := \
-       external/gbm_gralloc \
        system/core/libsync
 
 LOCAL_SRC_FILES := \
@@ -82,7 +82,21 @@ else
 LOCAL_SRC_FILES += hwcomposer.cpp
 endif
 
+
+ifeq ($(TARGET_PRODUCT),hikey960)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
+LOCAL_SRC_FILES += platformhisi.cpp
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/
+else ifeq ($(TARGET_PRODUCT),hikey)
+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
+LOCAL_SRC_FILES += platformhisi.cpp
+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/
+else ifeq ($(strip $(BOARD_DRM_HWCOMPOSER_BUFFER_IMPORTER)),minigbm)
+LOCAL_SRC_FILES += platformminigbm.cpp
+LOCAL_C_INCLUDES += external/minigbm/cros_gralloc/
+else
 LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER
+endif
 
 LOCAL_MODULE := hwcomposer.drm
 LOCAL_MODULE_TAGS := optional
diff --git a/CONTRIBUTING b/CONTRIBUTING
deleted file mode 100644 (file)
index 32fb37e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Patches to drm_hwcomposer are very much welcome, we really want this to be the
-universal HW composer implementation for Android and similar platforms
-So please bring on porting patches, bugfixes, improvements for documentation
-and new features.
-
-A short list of contribution guidelines:
-
-- Please submit patches formatted with git send-email/git format-patch or
-  equivalent to
-
-    dri-devel <dri-devel@lists.freedesktop.org>
-
-  Please use --subject-prefix="PATCH hwc" so that drm_hwcomposer patches are easily
-  identified in the massive amount mails on dri-devel. To ensure this is always
-  done, run:
-
-    git config format.subjectprefix "PATCH hwc"
-
-- drm_hwcomposer is Apache 2.0 Licensed and we require contributions to follow the
-  developer's certificate of origin: http://developercertificate.org/
-
-- When submitting new code please follow the naming conventions documented
-  in the generated documentation. Also please make full use of all the helpers and
-  convenience macros provided by drm_hwcomposer. The below command can help you
-  with formatting of your patches:
-  git diff | clang-format-diff-3.5 -p 1 -style=file
-
-- Hardware specific changes should get tested on relevant platforms
-  before committing.
-
-Happy hacking!
index 1a2ded7..795a8c2 100644 (file)
@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <pthread.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 
 namespace android {
 
index a4e7fc9..695876d 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <stdlib.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <hardware/hardware.h>
 
 namespace android {
index 1a536ef..04c81d4 100644 (file)
@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <stdint.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/properties.h>
 #include <xf86drmMode.h>
 
index 1b354fe..4033269 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdint.h>
 #include <xf86drmMode.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 
 namespace android {
 
index 0f8084b..b03bb05 100644 (file)
@@ -27,7 +27,7 @@
 #include <algorithm>
 #include <unordered_set>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <sw_sync.h>
 #include <sync/sync.h>
 #include <xf86drmMode.h>
index 2f6939c..60adbac 100644 (file)
@@ -26,7 +26,7 @@
 #include <sstream>
 #include <vector>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <drm/drm_mode.h>
 #include <sync/sync.h>
 #include <utils/Trace.h>
@@ -292,6 +292,13 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) {
     return ret;
   }
 
+  pre_compositor_.reset(new GLWorkerCompositor());
+  ret = pre_compositor_->Init();
+  if (ret) {
+    ALOGE("Failed to initialize OpenGL compositor %d", ret);
+    pre_compositor_.reset();
+  }
+
   initialized_ = true;
   return 0;
 }
@@ -413,14 +420,16 @@ int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) {
   }
 
   std::vector<DrmCompositionRegion> &regions = display_comp->squash_regions();
-  ret = pre_compositor_->Composite(display_comp->layers().data(),
+  if (pre_compositor_) {
+    ret = pre_compositor_->Composite(display_comp->layers().data(),
                                    regions.data(), regions.size(), fb.buffer(),
                                    display_comp->importer());
-  pre_compositor_->Finish();
+    pre_compositor_->Finish();
 
-  if (ret) {
-    ALOGE("Failed to squash layers");
-    return ret;
+    if (ret) {
+      ALOGE("Failed to squash layers");
+      return ret;
+    }
   }
 
   ret = display_comp->CreateNextTimelineFence();
@@ -447,14 +456,16 @@ int DrmDisplayCompositor::ApplyPreComposite(
   }
 
   std::vector<DrmCompositionRegion> &regions = display_comp->pre_comp_regions();
-  ret = pre_compositor_->Composite(display_comp->layers().data(),
+  if (pre_compositor_) {
+    ret = pre_compositor_->Composite(display_comp->layers().data(),
                                    regions.data(), regions.size(), fb.buffer(),
                                    display_comp->importer());
-  pre_compositor_->Finish();
+    pre_compositor_->Finish();
 
-  if (ret) {
-    ALOGE("Failed to pre-composite layers");
-    return ret;
+    if (ret) {
+      ALOGE("Failed to pre-composite layers");
+      return ret;
+    }
   }
 
   ret = display_comp->CreateNextTimelineFence();
index 9487cac..91753a2 100644 (file)
@@ -102,6 +102,9 @@ class DrmDisplayCompositor {
     return &squash_state_;
   }
 
+  bool uses_GL() {
+    return !!pre_compositor_;
+  }
  private:
   struct FrameState {
     std::unique_ptr<DrmDisplayComposition> composition;
index 29130d5..1526d0f 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/netlink.h>
 #include <sys/socket.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <xf86drm.h>
 #include <assert.h>
 
@@ -44,7 +44,7 @@ int DrmEventListener::Init() {
   struct sockaddr_nl addr;
   memset(&addr, 0, sizeof(addr));
   addr.nl_family = AF_NETLINK;
-  addr.nl_pid = getpid();
+  addr.nl_pid = 0;
   addr.nl_groups = 0xFFFFFFFF;
 
   int ret = bind(uevent_fd_.get(), (struct sockaddr *)&addr, sizeof(addr));
index 9084bdd..7f7ffa8 100644 (file)
@@ -26,7 +26,7 @@
 #include <inttypes.h>
 #include <string>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/properties.h>
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer2.h>
@@ -695,6 +695,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
         layer.set_validated_type(HWC2::Composition::Client);
         ++*num_types;
         break;
+      case HWC2::Composition::Device:
+        if (!compositor_.uses_GL()) {
+          layer.set_validated_type(HWC2::Composition::Client);
+          ++*num_types;
+          break;
+        }
+       /* fall through */
       default:
         layer.set_validated_type(layer.sf_type());
         break;
index 1f739ae..4449256 100644 (file)
@@ -23,7 +23,7 @@
 #include <errno.h>
 #include <stdint.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <xf86drmMode.h>
 
 namespace android {
index a8a633a..e96e6ab 100644 (file)
@@ -30,7 +30,7 @@
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/properties.h>
 
 namespace android {
index ec16dcf..166ff30 100644 (file)
@@ -39,7 +39,7 @@
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <cutils/properties.h>
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer.h>
index 53a7d82..715c93e 100644 (file)
@@ -20,7 +20,7 @@
 #include "drmhwcomposer.h"
 #include "platform.h"
 
-#include <cutils/log.h>
+#include <log/log.h>
 
 namespace android {
 
index 56ab37e..62b03a8 100644 (file)
@@ -19,7 +19,7 @@
 #include "drmresources.h"
 #include "platform.h"
 
-#include <cutils/log.h>
+#include <log/log.h>
 
 namespace android {
 
index 741d42b..8253967 100644 (file)
@@ -24,8 +24,8 @@
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <cutils/log.h>
-#include <gralloc_drm_handle.h>
+#include <log/log.h>
+#include <gralloc_handle.h>
 #include <hardware/gralloc.h>
 #include <EGL/eglext.h>
 
@@ -85,23 +85,23 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) {
 }
 
 EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
-  gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
+  gralloc_handle_t *gr_handle = gralloc_handle(handle);
   if (!gr_handle)
     return NULL;
   EGLint attr[] = {
-    EGL_WIDTH, gr_handle->width,
-    EGL_HEIGHT, gr_handle->height,
+    EGL_WIDTH, (EGLint)gr_handle->width,
+    EGL_HEIGHT, (EGLint)gr_handle->height,
     EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(gr_handle->format),
     EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->prime_fd,
     EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
-    EGL_DMA_BUF_PLANE0_PITCH_EXT, gr_handle->stride,
+    EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)gr_handle->stride,
     EGL_NONE,
   };
   return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
 }
 
 int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
-  gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
+  gralloc_handle_t *gr_handle = gralloc_handle(handle);
   if (!gr_handle)
     return -EINVAL;
 
index 8376580..fbe059b 100644 (file)
@@ -35,8 +35,8 @@ class DrmGenericImporter : public Importer {
   int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
   int ReleaseBuffer(hwc_drm_bo_t *bo) override;
 
- private:
   uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
+ private:
 
   DrmResources *drm_;
 
diff --git a/platformhisi.cpp b/platformhisi.cpp
new file mode 100644 (file)
index 0000000..3f5c319
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "hwc-platform-hisi"
+
+#include "drmresources.h"
+#include "platform.h"
+#include "platformhisi.h"
+
+
+#include <drm/drm_fourcc.h>
+#include <cinttypes>
+#include <stdatomic.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+#include <log/log.h>
+#include <hardware/gralloc.h>
+#include "gralloc_priv.h"
+
+
+namespace android {
+
+Importer *Importer::CreateInstance(DrmResources *drm) {
+  HisiImporter *importer = new HisiImporter(drm);
+  if (!importer)
+    return NULL;
+
+  int ret = importer->Init();
+  if (ret) {
+    ALOGE("Failed to initialize the hisi importer %d", ret);
+    delete importer;
+    return NULL;
+  }
+  return importer;
+}
+
+HisiImporter::HisiImporter(DrmResources *drm) : DrmGenericImporter(drm), drm_(drm) {
+}
+
+HisiImporter::~HisiImporter() {
+}
+
+int HisiImporter::Init() {
+  int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+                          (const hw_module_t **)&gralloc_);
+  if (ret) {
+    ALOGE("Failed to open gralloc module %d", ret);
+    return ret;
+  }
+
+  if (strcasecmp(gralloc_->common.author, "ARM Ltd."))
+    ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name,
+          gralloc_->common.author);
+
+  return 0;
+}
+
+EGLImageKHR HisiImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
+  private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle);
+  if (!hnd)
+    return NULL;
+
+  EGLint fmt = ConvertHalFormatToDrm(hnd->req_format);
+  if (fmt < 0)
+       return NULL;
+
+  EGLint attr[] = {
+    EGL_WIDTH, hnd->width,
+    EGL_HEIGHT, hnd->height,
+    EGL_LINUX_DRM_FOURCC_EXT, fmt,
+    EGL_DMA_BUF_PLANE0_FD_EXT, hnd->share_fd,
+    EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
+    EGL_DMA_BUF_PLANE0_PITCH_EXT, hnd->byte_stride,
+    EGL_NONE,
+  };
+  return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
+}
+
+int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+  private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle);
+  if (!hnd)
+    return -EINVAL;
+
+  uint32_t gem_handle;
+  int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle);
+  if (ret) {
+    ALOGE("failed to import prime fd %d ret=%d", hnd->share_fd, ret);
+    return ret;
+  }
+
+  EGLint fmt = ConvertHalFormatToDrm(hnd->req_format);
+  if (fmt < 0)
+       return fmt;
+
+  memset(bo, 0, sizeof(hwc_drm_bo_t));
+  bo->width = hnd->width;
+  bo->height = hnd->height;
+  bo->format = fmt;
+  bo->usage = hnd->usage;
+  bo->pitches[0] = hnd->byte_stride;
+  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);
+  if (ret) {
+    ALOGE("could not create drm fb %d", ret);
+    return ret;
+  }
+
+  return ret;
+}
+
+std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) {
+  std::unique_ptr<Planner> planner(new Planner);
+  planner->AddStage<PlanStageGreedy>();
+  return planner;
+}
+}
+
+
diff --git a/platformhisi.h b/platformhisi.h
new file mode 100644 (file)
index 0000000..46f4595
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PLATFORM_HISI_H_
+#define ANDROID_PLATFORM_HISI_H_
+
+#include "drmresources.h"
+#include "platform.h"
+#include "platformdrmgeneric.h"
+
+#include <stdatomic.h>
+
+#include <hardware/gralloc.h>
+
+namespace android {
+
+class HisiImporter : public DrmGenericImporter {
+ public:
+  HisiImporter(DrmResources *drm);
+  ~HisiImporter() override;
+
+  int Init();
+
+  EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
+  int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+
+ private:
+
+  DrmResources *drm_;
+
+  const gralloc_module_t *gralloc_;
+};
+}
+
+#endif
diff --git a/platformminigbm.cpp b/platformminigbm.cpp
new file mode 100644 (file)
index 0000000..80e2c0f
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "hwc-platform-drm-minigbm"
+
+#include "drmresources.h"
+#include "platform.h"
+#include "platformminigbm.h"
+
+#include <drm/drm_fourcc.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+#include <log/log.h>
+#include <hardware/gralloc.h>
+
+#include "cros_gralloc_handle.h"
+
+namespace android {
+
+Importer *Importer::CreateInstance(DrmResources *drm) {
+  DrmMinigbmImporter *importer = new DrmMinigbmImporter(drm);
+  if (!importer)
+    return NULL;
+
+  int ret = importer->Init();
+  if (ret) {
+    ALOGE("Failed to initialize the minigbm importer %d", ret);
+    delete importer;
+    return NULL;
+  }
+  return importer;
+}
+
+DrmMinigbmImporter::DrmMinigbmImporter(DrmResources *drm) : DrmGenericImporter(drm), drm_(drm) {
+}
+
+DrmMinigbmImporter::~DrmMinigbmImporter() {
+}
+
+int DrmMinigbmImporter::Init() {
+  int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+                          (const hw_module_t **)&gralloc_);
+  if (ret) {
+    ALOGE("Failed to open gralloc module %d", ret);
+    return ret;
+  }
+
+  if (strcasecmp(gralloc_->common.author, "Chrome OS"))
+    ALOGW("Using non-minigbm gralloc module: %s/%s\n", gralloc_->common.name,
+          gralloc_->common.author);
+
+  return 0;
+}
+
+EGLImageKHR DrmMinigbmImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
+  cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
+  if (!gr_handle)
+    return NULL;
+  EGLint attr[] = {
+    EGL_WIDTH, (EGLint)gr_handle->width,
+    EGL_HEIGHT, (EGLint)gr_handle->height,
+    EGL_LINUX_DRM_FOURCC_EXT, (EGLint)gr_handle->format,
+    EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->fds[0],
+    EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)gr_handle->strides[0],
+    EGL_DMA_BUF_PLANE0_OFFSET_EXT, (EGLint)gr_handle->offsets[0],
+    EGL_NONE,
+  };
+  return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
+}
+
+int DrmMinigbmImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+  cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
+  if (!gr_handle)
+    return -EINVAL;
+
+  uint32_t gem_handle;
+  int ret = drmPrimeFDToHandle(drm_->fd(), gr_handle->fds[0], &gem_handle);
+  if (ret) {
+    ALOGE("failed to import prime fd %d ret=%d", gr_handle->fds[0], ret);
+    return ret;
+  }
+
+  memset(bo, 0, sizeof(hwc_drm_bo_t));
+  bo->width = gr_handle->width;
+  bo->height = gr_handle->height;
+  bo->format = gr_handle->format;
+  bo->usage = gr_handle->usage;
+  bo->pitches[0] = gr_handle->strides[0];
+  bo->offsets[0] = gr_handle->offsets[0];
+  bo->gem_handles[0] = gem_handle;
+
+  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;
+  }
+
+  return ret;
+}
+
+std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) {
+  std::unique_ptr<Planner> planner(new Planner);
+  planner->AddStage<PlanStageGreedy>();
+  return planner;
+}
+
+}
diff --git a/platformminigbm.h b/platformminigbm.h
new file mode 100644 (file)
index 0000000..ded4c07
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_PLATFORM_DRM_MINIGBM_H_
+#define ANDROID_PLATFORM_DRM_MINIGBM_H_
+
+#include "drmresources.h"
+#include "platform.h"
+#include "platformdrmgeneric.h"
+
+#include <hardware/gralloc.h>
+
+namespace android {
+
+class DrmMinigbmImporter : public DrmGenericImporter {
+ public:
+  DrmMinigbmImporter(DrmResources *drm);
+  ~DrmMinigbmImporter() override;
+
+  int Init();
+
+  EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
+  int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+
+ private:
+  DrmResources *drm_;
+
+  const gralloc_module_t *gralloc_;
+};
+
+}
+
+#endif
diff --git a/platformnv.h b/platformnv.h
deleted file mode 100644 (file)
index 7e2784f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_PLATFORM_NV_H_
-#define ANDROID_PLATFORM_NV_H_
-
-#include "drmresources.h"
-#include "platform.h"
-#include "platformdrmgeneric.h"
-
-#include <stdatomic.h>
-
-#include <hardware/gralloc.h>
-
-namespace android {
-
-class NvImporter : public Importer {
- public:
-  NvImporter(DrmResources *drm);
-  ~NvImporter() override;
-
-  int Init();
-
-  EGLImageKHR ImportImage(EGLDisplay egl_display, 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;
-
- private:
-  typedef struct NvBuffer {
-    NvImporter *importer;
-    hwc_drm_bo_t bo;
-    atomic_int ref;
-  } NvBuffer_t;
-
-  static void NvGrallocRelease(void *nv_buffer);
-  void ReleaseBufferImpl(hwc_drm_bo_t *bo);
-
-  NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle);
-  int GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf);
-
-  DrmResources *drm_;
-
-  const gralloc_module_t *gralloc_;
-};
-
-// This stage looks for any layers that contain transformed protected content
-// and puts it in the primary plane since Tegra doesn't support planar rotation
-// on the overlay planes.
-//
-// There are two caveats to this approach: 1- Protected content isn't
-// necessarily planar, but it's usually a safe bet, and 2- This doesn't catch
-// non-protected planar content. If we wanted to fix this, we'd need to import
-// the buffer in this stage and peek at it's format. The overhead of doing this
-// doesn't seem worth it since we'll end up displaying the right thing in both
-// cases anyways.
-class PlanStageProtectedRotated : public Planner::PlanStage {
- public:
-  int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
-                      std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
-                      std::vector<DrmPlane *> *planes);
-};
-
-// This stage looks for layers that would not be supported by Tegra driver due
-// to limitations such as downscaling. If the layer is unprotected it will be
-// punted for precomp to handle, other wise if protected it will be dropped as
-// it cannot be supported by any means.
-class PlanStageNvLimits : public Planner::PlanStage {
- public:
-  int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
-                      std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
-                      std::vector<DrmPlane *> *planes);
- protected:
-  bool CheckLayer(size_t zorder, DrmHwcLayer *layer);
-};
-}
-
-#endif
index 3b9e0a2..c6a0afa 100644 (file)
@@ -7,6 +7,8 @@ LOCAL_SRC_FILES := \
        worker_test.cpp
 
 LOCAL_MODULE := hwc-drm-tests
+LOCAL_VENDOR_MODULE := true
+LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_STATIC_LIBRARIES := libdrmhwc_utils
 LOCAL_SHARED_LIBRARIES := hwcomposer.drm
 LOCAL_C_INCLUDES := external/drm_hwcomposer
index 639dc86..b64b414 100644 (file)
@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer.h>
 #include <sched.h>
index 3ad16fe..d431d2e 100644 (file)
@@ -26,7 +26,7 @@
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <cutils/log.h>
+#include <log/log.h>
 #include <hardware/hardware.h>
 
 namespace android {
@@ -35,6 +35,7 @@ VSyncWorker::VSyncWorker()
     : Worker("vsync", HAL_PRIORITY_URGENT_DISPLAY),
       drm_(NULL),
       display_(-1),
+      enabled_(false),
       last_timestamp_(-1) {
 }