Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-drm_hwcomposer: Commit

external/drm_hwcomposer


Commit MetaInfo

Revisionc1281eaa0b40f257ce3f99c06129f9251edeb2ec (tree)
Zeit2018-11-02 16:58:42
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Merge remote-tracking branch 'origin/master' into oreo-x86

Conflicts:
Android.mk
drmconnector.cpp
drmeventlistener.cpp

Ändern Zusammenfassung

Diff

--- a/Android.mk
+++ b/Android.mk
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \
2525 worker.cpp
2626
2727 LOCAL_MODULE := libdrmhwc_utils
28+LOCAL_VENDOR_MODULE := true
2829
2930 include $(BUILD_STATIC_LIBRARY)
3031
@@ -47,7 +48,6 @@ LOCAL_SHARED_LIBRARIES := \
4748 LOCAL_STATIC_LIBRARIES := libdrmhwc_utils
4849
4950 LOCAL_C_INCLUDES := \
50- external/gbm_gralloc \
5151 system/core/libsync
5252
5353 LOCAL_SRC_FILES := \
@@ -82,7 +82,21 @@ else
8282 LOCAL_SRC_FILES += hwcomposer.cpp
8383 endif
8484
85+
86+ifeq ($(TARGET_PRODUCT),hikey960)
87+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
88+LOCAL_SRC_FILES += platformhisi.cpp
89+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/
90+else ifeq ($(TARGET_PRODUCT),hikey)
91+LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
92+LOCAL_SRC_FILES += platformhisi.cpp
93+LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/
94+else ifeq ($(strip $(BOARD_DRM_HWCOMPOSER_BUFFER_IMPORTER)),minigbm)
95+LOCAL_SRC_FILES += platformminigbm.cpp
96+LOCAL_C_INCLUDES += external/minigbm/cros_gralloc/
97+else
8598 LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER
99+endif
86100
87101 LOCAL_MODULE := hwcomposer.drm
88102 LOCAL_MODULE_TAGS := optional
--- a/CONTRIBUTING
+++ /dev/null
@@ -1,31 +0,0 @@
1-Patches to drm_hwcomposer are very much welcome, we really want this to be the
2-universal HW composer implementation for Android and similar platforms
3-So please bring on porting patches, bugfixes, improvements for documentation
4-and new features.
5-
6-A short list of contribution guidelines:
7-
8-- Please submit patches formatted with git send-email/git format-patch or
9- equivalent to
10-
11- dri-devel <dri-devel@lists.freedesktop.org>
12-
13- Please use --subject-prefix="PATCH hwc" so that drm_hwcomposer patches are easily
14- identified in the massive amount mails on dri-devel. To ensure this is always
15- done, run:
16-
17- git config format.subjectprefix "PATCH hwc"
18-
19-- drm_hwcomposer is Apache 2.0 Licensed and we require contributions to follow the
20- developer's certificate of origin: http://developercertificate.org/
21-
22-- When submitting new code please follow the naming conventions documented
23- in the generated documentation. Also please make full use of all the helpers and
24- convenience macros provided by drm_hwcomposer. The below command can help you
25- with formatting of your patches:
26- git diff | clang-format-diff-3.5 -p 1 -style=file
27-
28-- Hardware specific changes should get tested on relevant platforms
29- before committing.
30-
31-Happy hacking!
--- a/autolock.cpp
+++ b/autolock.cpp
@@ -22,7 +22,7 @@
2222 #include <errno.h>
2323 #include <pthread.h>
2424
25-#include <cutils/log.h>
25+#include <log/log.h>
2626
2727 namespace android {
2828
--- a/drmcompositorworker.cpp
+++ b/drmcompositorworker.cpp
@@ -22,7 +22,7 @@
2222
2323 #include <stdlib.h>
2424
25-#include <cutils/log.h>
25+#include <log/log.h>
2626 #include <hardware/hardware.h>
2727
2828 namespace android {
--- a/drmconnector.cpp
+++ b/drmconnector.cpp
@@ -22,7 +22,7 @@
2222 #include <errno.h>
2323 #include <stdint.h>
2424
25-#include <cutils/log.h>
25+#include <log/log.h>
2626 #include <cutils/properties.h>
2727 #include <xf86drmMode.h>
2828
--- a/drmcrtc.cpp
+++ b/drmcrtc.cpp
@@ -22,7 +22,7 @@
2222 #include <stdint.h>
2323 #include <xf86drmMode.h>
2424
25-#include <cutils/log.h>
25+#include <log/log.h>
2626
2727 namespace android {
2828
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -27,7 +27,7 @@
2727 #include <algorithm>
2828 #include <unordered_set>
2929
30-#include <cutils/log.h>
30+#include <log/log.h>
3131 #include <sw_sync.h>
3232 #include <sync/sync.h>
3333 #include <xf86drmMode.h>
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -26,7 +26,7 @@
2626 #include <sstream>
2727 #include <vector>
2828
29-#include <cutils/log.h>
29+#include <log/log.h>
3030 #include <drm/drm_mode.h>
3131 #include <sync/sync.h>
3232 #include <utils/Trace.h>
@@ -292,6 +292,13 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) {
292292 return ret;
293293 }
294294
295+ pre_compositor_.reset(new GLWorkerCompositor());
296+ ret = pre_compositor_->Init();
297+ if (ret) {
298+ ALOGE("Failed to initialize OpenGL compositor %d", ret);
299+ pre_compositor_.reset();
300+ }
301+
295302 initialized_ = true;
296303 return 0;
297304 }
@@ -413,14 +420,16 @@ int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) {
413420 }
414421
415422 std::vector<DrmCompositionRegion> &regions = display_comp->squash_regions();
416- ret = pre_compositor_->Composite(display_comp->layers().data(),
423+ if (pre_compositor_) {
424+ ret = pre_compositor_->Composite(display_comp->layers().data(),
417425 regions.data(), regions.size(), fb.buffer(),
418426 display_comp->importer());
419- pre_compositor_->Finish();
427+ pre_compositor_->Finish();
420428
421- if (ret) {
422- ALOGE("Failed to squash layers");
423- return ret;
429+ if (ret) {
430+ ALOGE("Failed to squash layers");
431+ return ret;
432+ }
424433 }
425434
426435 ret = display_comp->CreateNextTimelineFence();
@@ -447,14 +456,16 @@ int DrmDisplayCompositor::ApplyPreComposite(
447456 }
448457
449458 std::vector<DrmCompositionRegion> &regions = display_comp->pre_comp_regions();
450- ret = pre_compositor_->Composite(display_comp->layers().data(),
459+ if (pre_compositor_) {
460+ ret = pre_compositor_->Composite(display_comp->layers().data(),
451461 regions.data(), regions.size(), fb.buffer(),
452462 display_comp->importer());
453- pre_compositor_->Finish();
463+ pre_compositor_->Finish();
454464
455- if (ret) {
456- ALOGE("Failed to pre-composite layers");
457- return ret;
465+ if (ret) {
466+ ALOGE("Failed to pre-composite layers");
467+ return ret;
468+ }
458469 }
459470
460471 ret = display_comp->CreateNextTimelineFence();
--- a/drmdisplaycompositor.h
+++ b/drmdisplaycompositor.h
@@ -102,6 +102,9 @@ class DrmDisplayCompositor {
102102 return &squash_state_;
103103 }
104104
105+ bool uses_GL() {
106+ return !!pre_compositor_;
107+ }
105108 private:
106109 struct FrameState {
107110 std::unique_ptr<DrmDisplayComposition> composition;
--- a/drmeventlistener.cpp
+++ b/drmeventlistener.cpp
@@ -23,7 +23,7 @@
2323 #include <linux/netlink.h>
2424 #include <sys/socket.h>
2525
26-#include <cutils/log.h>
26+#include <log/log.h>
2727 #include <xf86drm.h>
2828 #include <assert.h>
2929
@@ -44,7 +44,7 @@ int DrmEventListener::Init() {
4444 struct sockaddr_nl addr;
4545 memset(&addr, 0, sizeof(addr));
4646 addr.nl_family = AF_NETLINK;
47- addr.nl_pid = getpid();
47+ addr.nl_pid = 0;
4848 addr.nl_groups = 0xFFFFFFFF;
4949
5050 int ret = bind(uevent_fd_.get(), (struct sockaddr *)&addr, sizeof(addr));
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -26,7 +26,7 @@
2626 #include <inttypes.h>
2727 #include <string>
2828
29-#include <cutils/log.h>
29+#include <log/log.h>
3030 #include <cutils/properties.h>
3131 #include <hardware/hardware.h>
3232 #include <hardware/hwcomposer2.h>
@@ -695,6 +695,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
695695 layer.set_validated_type(HWC2::Composition::Client);
696696 ++*num_types;
697697 break;
698+ case HWC2::Composition::Device:
699+ if (!compositor_.uses_GL()) {
700+ layer.set_validated_type(HWC2::Composition::Client);
701+ ++*num_types;
702+ break;
703+ }
704+ /* fall through */
698705 default:
699706 layer.set_validated_type(layer.sf_type());
700707 break;
--- a/drmplane.cpp
+++ b/drmplane.cpp
@@ -23,7 +23,7 @@
2323 #include <errno.h>
2424 #include <stdint.h>
2525
26-#include <cutils/log.h>
26+#include <log/log.h>
2727 #include <xf86drmMode.h>
2828
2929 namespace android {
--- a/drmresources.cpp
+++ b/drmresources.cpp
@@ -30,7 +30,7 @@
3030 #include <xf86drm.h>
3131 #include <xf86drmMode.h>
3232
33-#include <cutils/log.h>
33+#include <log/log.h>
3434 #include <cutils/properties.h>
3535
3636 namespace android {
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -39,7 +39,7 @@
3939 #include <xf86drm.h>
4040 #include <xf86drmMode.h>
4141
42-#include <cutils/log.h>
42+#include <log/log.h>
4343 #include <cutils/properties.h>
4444 #include <hardware/hardware.h>
4545 #include <hardware/hwcomposer.h>
--- a/hwcutils.cpp
+++ b/hwcutils.cpp
@@ -20,7 +20,7 @@
2020 #include "drmhwcomposer.h"
2121 #include "platform.h"
2222
23-#include <cutils/log.h>
23+#include <log/log.h>
2424
2525 namespace android {
2626
--- a/platform.cpp
+++ b/platform.cpp
@@ -19,7 +19,7 @@
1919 #include "drmresources.h"
2020 #include "platform.h"
2121
22-#include <cutils/log.h>
22+#include <log/log.h>
2323
2424 namespace android {
2525
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -24,8 +24,8 @@
2424 #include <xf86drm.h>
2525 #include <xf86drmMode.h>
2626
27-#include <cutils/log.h>
28-#include <gralloc_drm_handle.h>
27+#include <log/log.h>
28+#include <gralloc_handle.h>
2929 #include <hardware/gralloc.h>
3030 #include <EGL/eglext.h>
3131
@@ -85,23 +85,23 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) {
8585 }
8686
8787 EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
88- gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
88+ gralloc_handle_t *gr_handle = gralloc_handle(handle);
8989 if (!gr_handle)
9090 return NULL;
9191 EGLint attr[] = {
92- EGL_WIDTH, gr_handle->width,
93- EGL_HEIGHT, gr_handle->height,
92+ EGL_WIDTH, (EGLint)gr_handle->width,
93+ EGL_HEIGHT, (EGLint)gr_handle->height,
9494 EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(gr_handle->format),
9595 EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->prime_fd,
9696 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
97- EGL_DMA_BUF_PLANE0_PITCH_EXT, gr_handle->stride,
97+ EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)gr_handle->stride,
9898 EGL_NONE,
9999 };
100100 return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
101101 }
102102
103103 int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
104- gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle);
104+ gralloc_handle_t *gr_handle = gralloc_handle(handle);
105105 if (!gr_handle)
106106 return -EINVAL;
107107
--- a/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -35,8 +35,8 @@ class DrmGenericImporter : public Importer {
3535 int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
3636 int ReleaseBuffer(hwc_drm_bo_t *bo) override;
3737
38- private:
3938 uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
39+ private:
4040
4141 DrmResources *drm_;
4242
--- /dev/null
+++ b/platformhisi.cpp
@@ -0,0 +1,135 @@
1+/*
2+ * Copyright (C) 2015 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#define LOG_TAG "hwc-platform-hisi"
18+
19+#include "drmresources.h"
20+#include "platform.h"
21+#include "platformhisi.h"
22+
23+
24+#include <drm/drm_fourcc.h>
25+#include <cinttypes>
26+#include <stdatomic.h>
27+#include <xf86drm.h>
28+#include <xf86drmMode.h>
29+
30+#include <log/log.h>
31+#include <hardware/gralloc.h>
32+#include "gralloc_priv.h"
33+
34+
35+namespace android {
36+
37+Importer *Importer::CreateInstance(DrmResources *drm) {
38+ HisiImporter *importer = new HisiImporter(drm);
39+ if (!importer)
40+ return NULL;
41+
42+ int ret = importer->Init();
43+ if (ret) {
44+ ALOGE("Failed to initialize the hisi importer %d", ret);
45+ delete importer;
46+ return NULL;
47+ }
48+ return importer;
49+}
50+
51+HisiImporter::HisiImporter(DrmResources *drm) : DrmGenericImporter(drm), drm_(drm) {
52+}
53+
54+HisiImporter::~HisiImporter() {
55+}
56+
57+int HisiImporter::Init() {
58+ int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
59+ (const hw_module_t **)&gralloc_);
60+ if (ret) {
61+ ALOGE("Failed to open gralloc module %d", ret);
62+ return ret;
63+ }
64+
65+ if (strcasecmp(gralloc_->common.author, "ARM Ltd."))
66+ ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name,
67+ gralloc_->common.author);
68+
69+ return 0;
70+}
71+
72+EGLImageKHR HisiImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
73+ private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle);
74+ if (!hnd)
75+ return NULL;
76+
77+ EGLint fmt = ConvertHalFormatToDrm(hnd->req_format);
78+ if (fmt < 0)
79+ return NULL;
80+
81+ EGLint attr[] = {
82+ EGL_WIDTH, hnd->width,
83+ EGL_HEIGHT, hnd->height,
84+ EGL_LINUX_DRM_FOURCC_EXT, fmt,
85+ EGL_DMA_BUF_PLANE0_FD_EXT, hnd->share_fd,
86+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
87+ EGL_DMA_BUF_PLANE0_PITCH_EXT, hnd->byte_stride,
88+ EGL_NONE,
89+ };
90+ return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
91+}
92+
93+int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
94+ private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle);
95+ if (!hnd)
96+ return -EINVAL;
97+
98+ uint32_t gem_handle;
99+ int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle);
100+ if (ret) {
101+ ALOGE("failed to import prime fd %d ret=%d", hnd->share_fd, ret);
102+ return ret;
103+ }
104+
105+ EGLint fmt = ConvertHalFormatToDrm(hnd->req_format);
106+ if (fmt < 0)
107+ return fmt;
108+
109+ memset(bo, 0, sizeof(hwc_drm_bo_t));
110+ bo->width = hnd->width;
111+ bo->height = hnd->height;
112+ bo->format = fmt;
113+ bo->usage = hnd->usage;
114+ bo->pitches[0] = hnd->byte_stride;
115+ bo->gem_handles[0] = gem_handle;
116+ bo->offsets[0] = 0;
117+
118+ ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
119+ bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id, 0);
120+ if (ret) {
121+ ALOGE("could not create drm fb %d", ret);
122+ return ret;
123+ }
124+
125+ return ret;
126+}
127+
128+std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) {
129+ std::unique_ptr<Planner> planner(new Planner);
130+ planner->AddStage<PlanStageGreedy>();
131+ return planner;
132+}
133+}
134+
135+
--- /dev/null
+++ b/platformhisi.h
@@ -0,0 +1,48 @@
1+/*
2+ * Copyright (C) 2015 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef ANDROID_PLATFORM_HISI_H_
18+#define ANDROID_PLATFORM_HISI_H_
19+
20+#include "drmresources.h"
21+#include "platform.h"
22+#include "platformdrmgeneric.h"
23+
24+#include <stdatomic.h>
25+
26+#include <hardware/gralloc.h>
27+
28+namespace android {
29+
30+class HisiImporter : public DrmGenericImporter {
31+ public:
32+ HisiImporter(DrmResources *drm);
33+ ~HisiImporter() override;
34+
35+ int Init();
36+
37+ EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
38+ int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
39+
40+ private:
41+
42+ DrmResources *drm_;
43+
44+ const gralloc_module_t *gralloc_;
45+};
46+}
47+
48+#endif
--- /dev/null
+++ b/platformminigbm.cpp
@@ -0,0 +1,122 @@
1+/*
2+ * Copyright (C) 2018 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#define LOG_TAG "hwc-platform-drm-minigbm"
18+
19+#include "drmresources.h"
20+#include "platform.h"
21+#include "platformminigbm.h"
22+
23+#include <drm/drm_fourcc.h>
24+#include <xf86drm.h>
25+#include <xf86drmMode.h>
26+
27+#include <log/log.h>
28+#include <hardware/gralloc.h>
29+
30+#include "cros_gralloc_handle.h"
31+
32+namespace android {
33+
34+Importer *Importer::CreateInstance(DrmResources *drm) {
35+ DrmMinigbmImporter *importer = new DrmMinigbmImporter(drm);
36+ if (!importer)
37+ return NULL;
38+
39+ int ret = importer->Init();
40+ if (ret) {
41+ ALOGE("Failed to initialize the minigbm importer %d", ret);
42+ delete importer;
43+ return NULL;
44+ }
45+ return importer;
46+}
47+
48+DrmMinigbmImporter::DrmMinigbmImporter(DrmResources *drm) : DrmGenericImporter(drm), drm_(drm) {
49+}
50+
51+DrmMinigbmImporter::~DrmMinigbmImporter() {
52+}
53+
54+int DrmMinigbmImporter::Init() {
55+ int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
56+ (const hw_module_t **)&gralloc_);
57+ if (ret) {
58+ ALOGE("Failed to open gralloc module %d", ret);
59+ return ret;
60+ }
61+
62+ if (strcasecmp(gralloc_->common.author, "Chrome OS"))
63+ ALOGW("Using non-minigbm gralloc module: %s/%s\n", gralloc_->common.name,
64+ gralloc_->common.author);
65+
66+ return 0;
67+}
68+
69+EGLImageKHR DrmMinigbmImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) {
70+ cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
71+ if (!gr_handle)
72+ return NULL;
73+ EGLint attr[] = {
74+ EGL_WIDTH, (EGLint)gr_handle->width,
75+ EGL_HEIGHT, (EGLint)gr_handle->height,
76+ EGL_LINUX_DRM_FOURCC_EXT, (EGLint)gr_handle->format,
77+ EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->fds[0],
78+ EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)gr_handle->strides[0],
79+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, (EGLint)gr_handle->offsets[0],
80+ EGL_NONE,
81+ };
82+ return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr);
83+}
84+
85+int DrmMinigbmImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
86+ cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
87+ if (!gr_handle)
88+ return -EINVAL;
89+
90+ uint32_t gem_handle;
91+ int ret = drmPrimeFDToHandle(drm_->fd(), gr_handle->fds[0], &gem_handle);
92+ if (ret) {
93+ ALOGE("failed to import prime fd %d ret=%d", gr_handle->fds[0], ret);
94+ return ret;
95+ }
96+
97+ memset(bo, 0, sizeof(hwc_drm_bo_t));
98+ bo->width = gr_handle->width;
99+ bo->height = gr_handle->height;
100+ bo->format = gr_handle->format;
101+ bo->usage = gr_handle->usage;
102+ bo->pitches[0] = gr_handle->strides[0];
103+ bo->offsets[0] = gr_handle->offsets[0];
104+ bo->gem_handles[0] = gem_handle;
105+
106+ ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
107+ bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id, 0);
108+ if (ret) {
109+ ALOGE("could not create drm fb %d", ret);
110+ return ret;
111+ }
112+
113+ return ret;
114+}
115+
116+std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) {
117+ std::unique_ptr<Planner> planner(new Planner);
118+ planner->AddStage<PlanStageGreedy>();
119+ return planner;
120+}
121+
122+}
--- /dev/null
+++ b/platformminigbm.h
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (C) 2018 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef ANDROID_PLATFORM_DRM_MINIGBM_H_
18+#define ANDROID_PLATFORM_DRM_MINIGBM_H_
19+
20+#include "drmresources.h"
21+#include "platform.h"
22+#include "platformdrmgeneric.h"
23+
24+#include <hardware/gralloc.h>
25+
26+namespace android {
27+
28+class DrmMinigbmImporter : public DrmGenericImporter {
29+ public:
30+ DrmMinigbmImporter(DrmResources *drm);
31+ ~DrmMinigbmImporter() override;
32+
33+ int Init();
34+
35+ EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
36+ int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
37+
38+ private:
39+ DrmResources *drm_;
40+
41+ const gralloc_module_t *gralloc_;
42+};
43+
44+}
45+
46+#endif
--- a/platformnv.h
+++ /dev/null
@@ -1,90 +0,0 @@
1-/*
2- * Copyright (C) 2015 The Android Open Source Project
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-
17-#ifndef ANDROID_PLATFORM_NV_H_
18-#define ANDROID_PLATFORM_NV_H_
19-
20-#include "drmresources.h"
21-#include "platform.h"
22-#include "platformdrmgeneric.h"
23-
24-#include <stdatomic.h>
25-
26-#include <hardware/gralloc.h>
27-
28-namespace android {
29-
30-class NvImporter : public Importer {
31- public:
32- NvImporter(DrmResources *drm);
33- ~NvImporter() override;
34-
35- int Init();
36-
37- EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
38- int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
39- int ReleaseBuffer(hwc_drm_bo_t *bo) override;
40-
41- private:
42- typedef struct NvBuffer {
43- NvImporter *importer;
44- hwc_drm_bo_t bo;
45- atomic_int ref;
46- } NvBuffer_t;
47-
48- static void NvGrallocRelease(void *nv_buffer);
49- void ReleaseBufferImpl(hwc_drm_bo_t *bo);
50-
51- NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle);
52- int GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf);
53-
54- DrmResources *drm_;
55-
56- const gralloc_module_t *gralloc_;
57-};
58-
59-// This stage looks for any layers that contain transformed protected content
60-// and puts it in the primary plane since Tegra doesn't support planar rotation
61-// on the overlay planes.
62-//
63-// There are two caveats to this approach: 1- Protected content isn't
64-// necessarily planar, but it's usually a safe bet, and 2- This doesn't catch
65-// non-protected planar content. If we wanted to fix this, we'd need to import
66-// the buffer in this stage and peek at it's format. The overhead of doing this
67-// doesn't seem worth it since we'll end up displaying the right thing in both
68-// cases anyways.
69-class PlanStageProtectedRotated : public Planner::PlanStage {
70- public:
71- int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
72- std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
73- std::vector<DrmPlane *> *planes);
74-};
75-
76-// This stage looks for layers that would not be supported by Tegra driver due
77-// to limitations such as downscaling. If the layer is unprotected it will be
78-// punted for precomp to handle, other wise if protected it will be dropped as
79-// it cannot be supported by any means.
80-class PlanStageNvLimits : public Planner::PlanStage {
81- public:
82- int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
83- std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
84- std::vector<DrmPlane *> *planes);
85- protected:
86- bool CheckLayer(size_t zorder, DrmHwcLayer *layer);
87-};
88-}
89-
90-#endif
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -7,6 +7,8 @@ LOCAL_SRC_FILES := \
77 worker_test.cpp
88
99 LOCAL_MODULE := hwc-drm-tests
10+LOCAL_VENDOR_MODULE := true
11+LOCAL_HEADER_LIBRARIES := libhardware_headers
1012 LOCAL_STATIC_LIBRARIES := libdrmhwc_utils
1113 LOCAL_SHARED_LIBRARIES := hwcomposer.drm
1214 LOCAL_C_INCLUDES := external/drm_hwcomposer
--- a/virtualcompositorworker.cpp
+++ b/virtualcompositorworker.cpp
@@ -22,7 +22,7 @@
2222 #include <errno.h>
2323 #include <stdlib.h>
2424
25-#include <cutils/log.h>
25+#include <log/log.h>
2626 #include <hardware/hardware.h>
2727 #include <hardware/hwcomposer.h>
2828 #include <sched.h>
--- a/vsyncworker.cpp
+++ b/vsyncworker.cpp
@@ -26,7 +26,7 @@
2626 #include <xf86drm.h>
2727 #include <xf86drmMode.h>
2828
29-#include <cutils/log.h>
29+#include <log/log.h>
3030 #include <hardware/hardware.h>
3131
3232 namespace android {
@@ -35,6 +35,7 @@ VSyncWorker::VSyncWorker()
3535 : Worker("vsync", HAL_PRIORITY_URGENT_DISPLAY),
3636 drm_(NULL),
3737 display_(-1),
38+ enabled_(false),
3839 last_timestamp_(-1) {
3940 }
4041
Show on old repository browser