external/drm_hwcomposer
Revision | c1281eaa0b40f257ce3f99c06129f9251edeb2ec (tree) |
---|---|
Zeit | 2018-11-02 16:58:42 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge remote-tracking branch 'origin/master' into oreo-x86
Conflicts:
Android.mk
drmconnector.cpp
drmeventlistener.cpp
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \ | ||
25 | 25 | worker.cpp |
26 | 26 | |
27 | 27 | LOCAL_MODULE := libdrmhwc_utils |
28 | +LOCAL_VENDOR_MODULE := true | |
28 | 29 | |
29 | 30 | include $(BUILD_STATIC_LIBRARY) |
30 | 31 |
@@ -47,7 +48,6 @@ LOCAL_SHARED_LIBRARIES := \ | ||
47 | 48 | LOCAL_STATIC_LIBRARIES := libdrmhwc_utils |
48 | 49 | |
49 | 50 | LOCAL_C_INCLUDES := \ |
50 | - external/gbm_gralloc \ | |
51 | 51 | system/core/libsync |
52 | 52 | |
53 | 53 | LOCAL_SRC_FILES := \ |
@@ -82,7 +82,21 @@ else | ||
82 | 82 | LOCAL_SRC_FILES += hwcomposer.cpp |
83 | 83 | endif |
84 | 84 | |
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 | |
85 | 98 | LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER |
99 | +endif | |
86 | 100 | |
87 | 101 | LOCAL_MODULE := hwcomposer.drm |
88 | 102 | LOCAL_MODULE_TAGS := optional |
@@ -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! |
@@ -22,7 +22,7 @@ | ||
22 | 22 | #include <errno.h> |
23 | 23 | #include <pthread.h> |
24 | 24 | |
25 | -#include <cutils/log.h> | |
25 | +#include <log/log.h> | |
26 | 26 | |
27 | 27 | namespace android { |
28 | 28 |
@@ -22,7 +22,7 @@ | ||
22 | 22 | |
23 | 23 | #include <stdlib.h> |
24 | 24 | |
25 | -#include <cutils/log.h> | |
25 | +#include <log/log.h> | |
26 | 26 | #include <hardware/hardware.h> |
27 | 27 | |
28 | 28 | namespace android { |
@@ -22,7 +22,7 @@ | ||
22 | 22 | #include <errno.h> |
23 | 23 | #include <stdint.h> |
24 | 24 | |
25 | -#include <cutils/log.h> | |
25 | +#include <log/log.h> | |
26 | 26 | #include <cutils/properties.h> |
27 | 27 | #include <xf86drmMode.h> |
28 | 28 |
@@ -22,7 +22,7 @@ | ||
22 | 22 | #include <stdint.h> |
23 | 23 | #include <xf86drmMode.h> |
24 | 24 | |
25 | -#include <cutils/log.h> | |
25 | +#include <log/log.h> | |
26 | 26 | |
27 | 27 | namespace android { |
28 | 28 |
@@ -27,7 +27,7 @@ | ||
27 | 27 | #include <algorithm> |
28 | 28 | #include <unordered_set> |
29 | 29 | |
30 | -#include <cutils/log.h> | |
30 | +#include <log/log.h> | |
31 | 31 | #include <sw_sync.h> |
32 | 32 | #include <sync/sync.h> |
33 | 33 | #include <xf86drmMode.h> |
@@ -26,7 +26,7 @@ | ||
26 | 26 | #include <sstream> |
27 | 27 | #include <vector> |
28 | 28 | |
29 | -#include <cutils/log.h> | |
29 | +#include <log/log.h> | |
30 | 30 | #include <drm/drm_mode.h> |
31 | 31 | #include <sync/sync.h> |
32 | 32 | #include <utils/Trace.h> |
@@ -292,6 +292,13 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) { | ||
292 | 292 | return ret; |
293 | 293 | } |
294 | 294 | |
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 | + | |
295 | 302 | initialized_ = true; |
296 | 303 | return 0; |
297 | 304 | } |
@@ -413,14 +420,16 @@ int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) { | ||
413 | 420 | } |
414 | 421 | |
415 | 422 | std::vector<DrmCompositionRegion> ®ions = 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(), | |
417 | 425 | regions.data(), regions.size(), fb.buffer(), |
418 | 426 | display_comp->importer()); |
419 | - pre_compositor_->Finish(); | |
427 | + pre_compositor_->Finish(); | |
420 | 428 | |
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 | + } | |
424 | 433 | } |
425 | 434 | |
426 | 435 | ret = display_comp->CreateNextTimelineFence(); |
@@ -447,14 +456,16 @@ int DrmDisplayCompositor::ApplyPreComposite( | ||
447 | 456 | } |
448 | 457 | |
449 | 458 | std::vector<DrmCompositionRegion> ®ions = 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(), | |
451 | 461 | regions.data(), regions.size(), fb.buffer(), |
452 | 462 | display_comp->importer()); |
453 | - pre_compositor_->Finish(); | |
463 | + pre_compositor_->Finish(); | |
454 | 464 | |
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 | + } | |
458 | 469 | } |
459 | 470 | |
460 | 471 | ret = display_comp->CreateNextTimelineFence(); |
@@ -102,6 +102,9 @@ class DrmDisplayCompositor { | ||
102 | 102 | return &squash_state_; |
103 | 103 | } |
104 | 104 | |
105 | + bool uses_GL() { | |
106 | + return !!pre_compositor_; | |
107 | + } | |
105 | 108 | private: |
106 | 109 | struct FrameState { |
107 | 110 | std::unique_ptr<DrmDisplayComposition> composition; |
@@ -23,7 +23,7 @@ | ||
23 | 23 | #include <linux/netlink.h> |
24 | 24 | #include <sys/socket.h> |
25 | 25 | |
26 | -#include <cutils/log.h> | |
26 | +#include <log/log.h> | |
27 | 27 | #include <xf86drm.h> |
28 | 28 | #include <assert.h> |
29 | 29 |
@@ -44,7 +44,7 @@ int DrmEventListener::Init() { | ||
44 | 44 | struct sockaddr_nl addr; |
45 | 45 | memset(&addr, 0, sizeof(addr)); |
46 | 46 | addr.nl_family = AF_NETLINK; |
47 | - addr.nl_pid = getpid(); | |
47 | + addr.nl_pid = 0; | |
48 | 48 | addr.nl_groups = 0xFFFFFFFF; |
49 | 49 | |
50 | 50 | int ret = bind(uevent_fd_.get(), (struct sockaddr *)&addr, sizeof(addr)); |
@@ -26,7 +26,7 @@ | ||
26 | 26 | #include <inttypes.h> |
27 | 27 | #include <string> |
28 | 28 | |
29 | -#include <cutils/log.h> | |
29 | +#include <log/log.h> | |
30 | 30 | #include <cutils/properties.h> |
31 | 31 | #include <hardware/hardware.h> |
32 | 32 | #include <hardware/hwcomposer2.h> |
@@ -695,6 +695,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, | ||
695 | 695 | layer.set_validated_type(HWC2::Composition::Client); |
696 | 696 | ++*num_types; |
697 | 697 | 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 */ | |
698 | 705 | default: |
699 | 706 | layer.set_validated_type(layer.sf_type()); |
700 | 707 | break; |
@@ -23,7 +23,7 @@ | ||
23 | 23 | #include <errno.h> |
24 | 24 | #include <stdint.h> |
25 | 25 | |
26 | -#include <cutils/log.h> | |
26 | +#include <log/log.h> | |
27 | 27 | #include <xf86drmMode.h> |
28 | 28 | |
29 | 29 | namespace android { |
@@ -30,7 +30,7 @@ | ||
30 | 30 | #include <xf86drm.h> |
31 | 31 | #include <xf86drmMode.h> |
32 | 32 | |
33 | -#include <cutils/log.h> | |
33 | +#include <log/log.h> | |
34 | 34 | #include <cutils/properties.h> |
35 | 35 | |
36 | 36 | namespace android { |
@@ -39,7 +39,7 @@ | ||
39 | 39 | #include <xf86drm.h> |
40 | 40 | #include <xf86drmMode.h> |
41 | 41 | |
42 | -#include <cutils/log.h> | |
42 | +#include <log/log.h> | |
43 | 43 | #include <cutils/properties.h> |
44 | 44 | #include <hardware/hardware.h> |
45 | 45 | #include <hardware/hwcomposer.h> |
@@ -20,7 +20,7 @@ | ||
20 | 20 | #include "drmhwcomposer.h" |
21 | 21 | #include "platform.h" |
22 | 22 | |
23 | -#include <cutils/log.h> | |
23 | +#include <log/log.h> | |
24 | 24 | |
25 | 25 | namespace android { |
26 | 26 |
@@ -19,7 +19,7 @@ | ||
19 | 19 | #include "drmresources.h" |
20 | 20 | #include "platform.h" |
21 | 21 | |
22 | -#include <cutils/log.h> | |
22 | +#include <log/log.h> | |
23 | 23 | |
24 | 24 | namespace android { |
25 | 25 |
@@ -24,8 +24,8 @@ | ||
24 | 24 | #include <xf86drm.h> |
25 | 25 | #include <xf86drmMode.h> |
26 | 26 | |
27 | -#include <cutils/log.h> | |
28 | -#include <gralloc_drm_handle.h> | |
27 | +#include <log/log.h> | |
28 | +#include <gralloc_handle.h> | |
29 | 29 | #include <hardware/gralloc.h> |
30 | 30 | #include <EGL/eglext.h> |
31 | 31 |
@@ -85,23 +85,23 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) { | ||
85 | 85 | } |
86 | 86 | |
87 | 87 | 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); | |
89 | 89 | if (!gr_handle) |
90 | 90 | return NULL; |
91 | 91 | 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, | |
94 | 94 | EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(gr_handle->format), |
95 | 95 | EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->prime_fd, |
96 | 96 | 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, | |
98 | 98 | EGL_NONE, |
99 | 99 | }; |
100 | 100 | return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr); |
101 | 101 | } |
102 | 102 | |
103 | 103 | 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); | |
105 | 105 | if (!gr_handle) |
106 | 106 | return -EINVAL; |
107 | 107 |
@@ -35,8 +35,8 @@ class DrmGenericImporter : public Importer { | ||
35 | 35 | int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; |
36 | 36 | int ReleaseBuffer(hwc_drm_bo_t *bo) override; |
37 | 37 | |
38 | - private: | |
39 | 38 | uint32_t ConvertHalFormatToDrm(uint32_t hal_format); |
39 | + private: | |
40 | 40 | |
41 | 41 | DrmResources *drm_; |
42 | 42 |
@@ -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 | + |
@@ -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 |
@@ -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 | +} |
@@ -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 |
@@ -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 |
@@ -7,6 +7,8 @@ LOCAL_SRC_FILES := \ | ||
7 | 7 | worker_test.cpp |
8 | 8 | |
9 | 9 | LOCAL_MODULE := hwc-drm-tests |
10 | +LOCAL_VENDOR_MODULE := true | |
11 | +LOCAL_HEADER_LIBRARIES := libhardware_headers | |
10 | 12 | LOCAL_STATIC_LIBRARIES := libdrmhwc_utils |
11 | 13 | LOCAL_SHARED_LIBRARIES := hwcomposer.drm |
12 | 14 | LOCAL_C_INCLUDES := external/drm_hwcomposer |
@@ -22,7 +22,7 @@ | ||
22 | 22 | #include <errno.h> |
23 | 23 | #include <stdlib.h> |
24 | 24 | |
25 | -#include <cutils/log.h> | |
25 | +#include <log/log.h> | |
26 | 26 | #include <hardware/hardware.h> |
27 | 27 | #include <hardware/hwcomposer.h> |
28 | 28 | #include <sched.h> |
@@ -26,7 +26,7 @@ | ||
26 | 26 | #include <xf86drm.h> |
27 | 27 | #include <xf86drmMode.h> |
28 | 28 | |
29 | -#include <cutils/log.h> | |
29 | +#include <log/log.h> | |
30 | 30 | #include <hardware/hardware.h> |
31 | 31 | |
32 | 32 | namespace android { |
@@ -35,6 +35,7 @@ VSyncWorker::VSyncWorker() | ||
35 | 35 | : Worker("vsync", HAL_PRIORITY_URGENT_DISPLAY), |
36 | 36 | drm_(NULL), |
37 | 37 | display_(-1), |
38 | + enabled_(false), | |
38 | 39 | last_timestamp_(-1) { |
39 | 40 | } |
40 | 41 |