summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2016-09-05 14:39:28 -0400
committerRobert Foss <robert.foss@collabora.com>2016-09-05 14:39:28 -0400
commitb5c46dec71fe12ca6493ba23eb52c8e07909037b (patch)
tree6e5f22ac40d89b2ab0b85d28e72f90c6e27ec272
parentb9d32a8d5be4a43b5b753a9c4460a7420be4fa3a (diff)
downloaddrm_hwcomposer-patch_libsync_rework_v1.tar.gz
drm_hwcomposer-patch_libsync_rework_v1.tar.xz
WIP: Removed code outlined for removalpatch_libsync_rework_v1
-rw-r--r--Android.mk3
-rw-r--r--drmcomposition.cpp166
-rw-r--r--drmcomposition.h79
-rw-r--r--drmcompositor.cpp106
-rw-r--r--drmcompositor.h56
-rw-r--r--drmcompositorworker.cpp87
-rw-r--r--drmcompositorworker.h41
-rw-r--r--drmdisplaycomposition.cpp1
-rw-r--r--drmdisplaycompositor.cpp78
-rw-r--r--drmdisplaycompositor.h23
-rw-r--r--drmeventlistener.cpp2
-rw-r--r--drmresources.cpp41
-rw-r--r--drmresources.h3
-rw-r--r--hwcomposer.cpp31
14 files changed, 7 insertions, 710 deletions
diff --git a/Android.mk b/Android.mk
index 5308225..9657493 100644
--- a/Android.mk
+++ b/Android.mk
@@ -40,9 +40,6 @@ LOCAL_C_INCLUDES := \
LOCAL_SRC_FILES := \
autolock.cpp \
drmresources.cpp \
- drmcomposition.cpp \
- drmcompositor.cpp \
- drmcompositorworker.cpp \
drmconnector.cpp \
drmcrtc.cpp \
drmdisplaycomposition.cpp \
diff --git a/drmcomposition.cpp b/drmcomposition.cpp
deleted file mode 100644
index 1aaf920..0000000
--- a/drmcomposition.cpp
+++ /dev/null
@@ -1,166 +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.
- */
-
-#define LOG_TAG "hwc-drm-composition"
-
-#include "drmcomposition.h"
-#include "drmcrtc.h"
-#include "drmplane.h"
-#include "drmresources.h"
-#include "platform.h"
-
-#include <stdlib.h>
-
-#include <cutils/log.h>
-#include <cutils/properties.h>
-#include <sw_sync.h>
-#include <sync/sync.h>
-
-namespace android {
-
-DrmComposition::DrmComposition(DrmResources *drm, Importer *importer,
- Planner *planner)
- : drm_(drm), importer_(importer), planner_(planner) {
- char use_overlay_planes_prop[PROPERTY_VALUE_MAX];
- property_get("hwc.drm.use_overlay_planes", use_overlay_planes_prop, "1");
- bool use_overlay_planes = atoi(use_overlay_planes_prop);
-
- for (auto &plane : drm->planes()) {
- if (plane->type() == DRM_PLANE_TYPE_PRIMARY)
- primary_planes_.push_back(plane.get());
- else if (use_overlay_planes && plane->type() == DRM_PLANE_TYPE_OVERLAY)
- overlay_planes_.push_back(plane.get());
- }
-}
-
-int DrmComposition::Init(uint64_t frame_no) {
- for (auto &conn : drm_->connectors()) {
- int display = conn->display();
- composition_map_[display].reset(new DrmDisplayComposition());
- if (!composition_map_[display]) {
- ALOGE("Failed to allocate new display composition\n");
- return -ENOMEM;
- }
-
- // If the display hasn't been modeset yet, this will be NULL
- DrmCrtc *crtc = drm_->GetCrtcForDisplay(display);
-
- int ret = composition_map_[display]->Init(drm_, crtc, importer_, planner_,
- frame_no);
- if (ret) {
- ALOGE("Failed to init display composition for %d", display);
- return ret;
- }
- }
- return 0;
-}
-
-int DrmComposition::SetLayers(size_t num_displays,
- DrmCompositionDisplayLayersMap *maps) {
- int ret = 0;
- for (size_t display_index = 0; display_index < num_displays;
- display_index++) {
- DrmCompositionDisplayLayersMap &map = maps[display_index];
- int display = map.display;
-
- if (!drm_->GetConnectorForDisplay(display)) {
- ALOGE("Invalid display given to SetLayers %d", display);
- continue;
- }
-
- ret = composition_map_[display]->SetLayers(
- map.layers.data(), map.layers.size(), map.geometry_changed);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-int DrmComposition::SetDpmsMode(int display, uint32_t dpms_mode) {
- return composition_map_[display]->SetDpmsMode(dpms_mode);
-}
-
-int DrmComposition::SetDisplayMode(int display, const DrmMode &display_mode) {
- return composition_map_[display]->SetDisplayMode(display_mode);
-}
-
-std::unique_ptr<DrmDisplayComposition> DrmComposition::TakeDisplayComposition(
- int display) {
- return std::move(composition_map_[display]);
-}
-
-int DrmComposition::Plan(std::map<int, DrmDisplayCompositor> &compositor_map) {
- int ret = 0;
- for (auto &conn : drm_->connectors()) {
- int display = conn->display();
- DrmDisplayComposition *comp = GetDisplayComposition(display);
- ret = comp->Plan(compositor_map[display].squash_state(), &primary_planes_,
- &overlay_planes_);
- if (ret) {
- ALOGE("Failed to plan composition for dislay %d", display);
- return ret;
- }
- }
-
- return 0;
-}
-
-int DrmComposition::DisableUnusedPlanes() {
- for (auto &conn : drm_->connectors()) {
- int display = conn->display();
- DrmDisplayComposition *comp = GetDisplayComposition(display);
-
- /*
- * Leave empty compositions alone
- * TODO: re-visit this and potentially disable leftover planes after the
- * active compositions have gobbled up all they can
- */
- if (comp->type() == DRM_COMPOSITION_TYPE_EMPTY ||
- comp->type() == DRM_COMPOSITION_TYPE_MODESET)
- continue;
-
- DrmCrtc *crtc = drm_->GetCrtcForDisplay(display);
- if (!crtc) {
- ALOGE("Failed to find crtc for display %d", display);
- continue;
- }
-
- for (std::vector<DrmPlane *>::iterator iter = primary_planes_.begin();
- iter != primary_planes_.end(); ++iter) {
- if ((*iter)->GetCrtcSupported(*crtc)) {
- comp->AddPlaneDisable(*iter);
- primary_planes_.erase(iter);
- break;
- }
- }
- for (std::vector<DrmPlane *>::iterator iter = overlay_planes_.begin();
- iter != overlay_planes_.end();) {
- if ((*iter)->GetCrtcSupported(*crtc)) {
- comp->AddPlaneDisable(*iter);
- iter = overlay_planes_.erase(iter);
- } else {
- iter++;
- }
- }
- }
- return 0;
-}
-
-DrmDisplayComposition *DrmComposition::GetDisplayComposition(int display) {
- return composition_map_[display].get();
-}
-}
diff --git a/drmcomposition.h b/drmcomposition.h
deleted file mode 100644
index eae8cde..0000000
--- a/drmcomposition.h
+++ /dev/null
@@ -1,79 +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_DRM_COMPOSITION_H_
-#define ANDROID_DRM_COMPOSITION_H_
-
-#include "drmhwcomposer.h"
-#include "drmdisplaycomposition.h"
-#include "drmplane.h"
-#include "platform.h"
-
-#include <map>
-#include <vector>
-
-#include <hardware/hardware.h>
-#include <hardware/hwcomposer.h>
-
-namespace android {
-
-class DrmDisplayCompositor;
-
-struct DrmCompositionDisplayLayersMap {
- int display;
- bool geometry_changed = true;
- std::vector<DrmHwcLayer> layers;
-
- DrmCompositionDisplayLayersMap() = default;
- DrmCompositionDisplayLayersMap(DrmCompositionDisplayLayersMap &&rhs) =
- default;
-};
-
-class DrmComposition {
- public:
- DrmComposition(DrmResources *drm, Importer *importer, Planner *planner);
-
- int Init(uint64_t frame_no);
-
- int SetLayers(size_t num_displays, DrmCompositionDisplayLayersMap *maps);
- int SetDpmsMode(int display, uint32_t dpms_mode);
- int SetDisplayMode(int display, const DrmMode &display_mode);
-
- std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
- DrmDisplayComposition *GetDisplayComposition(int display);
-
- int Plan(std::map<int, DrmDisplayCompositor> &compositor_map);
- int DisableUnusedPlanes();
-
- private:
- DrmComposition(const DrmComposition &) = delete;
-
- DrmResources *drm_;
- Importer *importer_;
- Planner *planner_;
-
- std::vector<DrmPlane *> primary_planes_;
- std::vector<DrmPlane *> overlay_planes_;
-
- /*
- * This _must_ be read-only after it's passed to QueueComposition. Otherwise
- * locking is required to maintain consistency across the compositor threads.
- */
- std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
-};
-}
-
-#endif // ANDROID_DRM_COMPOSITION_H_
diff --git a/drmcompositor.cpp b/drmcompositor.cpp
deleted file mode 100644
index c1f3ed8..0000000
--- a/drmcompositor.cpp
+++ /dev/null
@@ -1,106 +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.
- */
-
-#define LOG_TAG "hwc-drm-compositor"
-
-#include "drmcompositor.h"
-#include "drmdisplaycompositor.h"
-#include "drmresources.h"
-#include "platform.h"
-
-#include <sstream>
-#include <stdlib.h>
-
-#include <cutils/log.h>
-
-namespace android {
-
-DrmCompositor::DrmCompositor(DrmResources *drm) : drm_(drm), frame_no_(0) {
-}
-
-DrmCompositor::~DrmCompositor() {
-}
-
-int DrmCompositor::Init() {
- for (auto &conn : drm_->connectors()) {
- int display = conn->display();
- int ret = compositor_map_[display].Init(drm_, display);
- if (ret) {
- ALOGE("Failed to initialize display compositor for %d", display);
- return ret;
- }
- }
- planner_ = Planner::CreateInstance(drm_);
- if (!planner_) {
- ALOGE("Failed to create planner instance for composition");
- return -ENOMEM;
- }
-
- return 0;
-}
-
-std::unique_ptr<DrmComposition> DrmCompositor::CreateComposition(
- Importer *importer) {
- std::unique_ptr<DrmComposition> composition(
- new DrmComposition(drm_, importer, planner_.get()));
- int ret = composition->Init(++frame_no_);
- if (ret) {
- ALOGE("Failed to initialize drm composition %d", ret);
- return nullptr;
- }
- return composition;
-}
-
-int DrmCompositor::QueueComposition(
- std::unique_ptr<DrmComposition> composition) {
- int ret;
-
- ret = composition->Plan(compositor_map_);
- if (ret)
- return ret;
-
- ret = composition->DisableUnusedPlanes();
- if (ret)
- return ret;
-
- for (auto &conn : drm_->connectors()) {
- int display = conn->display();
- int ret = compositor_map_[display].QueueComposition(
- composition->TakeDisplayComposition(display));
- if (ret) {
- ALOGE("Failed to queue composition for display %d (%d)", display, ret);
- return ret;
- }
- }
-
- return 0;
-}
-
-int DrmCompositor::Composite() {
- /*
- * This shouldn't be called, we should be calling Composite() on the display
- * compositors directly.
- */
- ALOGE("Calling base drm compositor Composite() function");
- return -EINVAL;
-}
-
-void DrmCompositor::Dump(std::ostringstream *out) const {
- *out << "DrmCompositor stats:\n";
- for (auto &conn : drm_->connectors())
- compositor_map_[conn->display()].Dump(out);
-}
-}
diff --git a/drmcompositor.h b/drmcompositor.h
deleted file mode 100644
index 19271b5..0000000
--- a/drmcompositor.h
+++ /dev/null
@@ -1,56 +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_DRM_COMPOSITOR_H_
-#define ANDROID_DRM_COMPOSITOR_H_
-
-#include "drmcomposition.h"
-#include "drmdisplaycompositor.h"
-#include "platform.h"
-
-#include <map>
-#include <memory>
-#include <sstream>
-
-namespace android {
-
-class DrmCompositor {
- public:
- DrmCompositor(DrmResources *drm);
- ~DrmCompositor();
-
- int Init();
-
- std::unique_ptr<DrmComposition> CreateComposition(Importer *importer);
-
- int QueueComposition(std::unique_ptr<DrmComposition> composition);
- int Composite();
- void Dump(std::ostringstream *out) const;
-
- private:
- DrmCompositor(const DrmCompositor &) = delete;
-
- DrmResources *drm_;
- std::unique_ptr<Planner> planner_;
-
- uint64_t frame_no_;
-
- // mutable for Dump() propagation
- mutable std::map<int, DrmDisplayCompositor> compositor_map_;
-};
-}
-
-#endif // ANDROID_DRM_COMPOSITOR_H_
diff --git a/drmcompositorworker.cpp b/drmcompositorworker.cpp
deleted file mode 100644
index 9804322..0000000
--- a/drmcompositorworker.cpp
+++ /dev/null
@@ -1,87 +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.
- */
-
-#define LOG_TAG "hwc-drm-compositor-worker"
-
-#include "drmdisplaycompositor.h"
-#include "drmcompositorworker.h"
-#include "worker.h"
-
-#include <stdlib.h>
-
-#include <cutils/log.h>
-#include <hardware/hardware.h>
-
-namespace android {
-
-static const int64_t kSquashWait = 500000000LL;
-
-DrmCompositorWorker::DrmCompositorWorker(DrmDisplayCompositor *compositor)
- : Worker("drm-compositor", HAL_PRIORITY_URGENT_DISPLAY),
- compositor_(compositor) {
-}
-
-DrmCompositorWorker::~DrmCompositorWorker() {
-}
-
-int DrmCompositorWorker::Init() {
- return InitWorker();
-}
-
-void DrmCompositorWorker::Routine() {
- int ret;
- if (!compositor_->HaveQueuedComposites()) {
- ret = Lock();
- if (ret) {
- ALOGE("Failed to lock worker, %d", ret);
- return;
- }
-
- // Only use a timeout if we didn't do a SquashAll last time. This will
- // prevent wait_ret == -ETIMEDOUT which would trigger a SquashAll and be a
- // pointless drain on resources.
- int wait_ret = did_squash_all_ ? WaitForSignalOrExitLocked()
- : WaitForSignalOrExitLocked(kSquashWait);
-
- ret = Unlock();
- if (ret) {
- ALOGE("Failed to unlock worker, %d", ret);
- return;
- }
-
- switch (wait_ret) {
- case 0:
- break;
- case -EINTR:
- return;
- case -ETIMEDOUT:
- ret = compositor_->SquashAll();
- if (ret)
- ALOGE("Failed to squash all %d", ret);
- did_squash_all_ = true;
- return;
- default:
- ALOGE("Failed to wait for signal, %d", wait_ret);
- return;
- }
- }
-
- ret = compositor_->Composite();
- if (ret)
- ALOGE("Failed to composite! %d", ret);
- did_squash_all_ = false;
-}
-}
diff --git a/drmcompositorworker.h b/drmcompositorworker.h
deleted file mode 100644
index 731bc65..0000000
--- a/drmcompositorworker.h
+++ /dev/null
@@ -1,41 +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_DRM_COMPOSITOR_WORKER_H_
-#define ANDROID_DRM_COMPOSITOR_WORKER_H_
-
-#include "worker.h"
-
-namespace android {
-
-class DrmDisplayCompositor;
-
-class DrmCompositorWorker : public Worker {
- public:
- DrmCompositorWorker(DrmDisplayCompositor *compositor);
- ~DrmCompositorWorker() override;
-
- int Init();
-
- protected:
- void Routine() override;
-
- DrmDisplayCompositor *compositor_;
- bool did_squash_all_ = false;
-};
-}
-
-#endif
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 949f4a3..ff7b971 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "hwc-drm-display-composition"
#include "drmdisplaycomposition.h"
+#include "drmdisplaycompositor.h"
#include "drmcrtc.h"
#include "drmplane.h"
#include "drmresources.h"
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index 1ca1212..cb65b10 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -17,6 +17,8 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define LOG_TAG "hwc-drm-display-compositor"
+#include "drmhwcomposer.h"
+#include "drmdisplaycomposition.h"
#include "drmdisplaycompositor.h"
#include <pthread.h>
@@ -176,68 +178,9 @@ static bool UsesSquash(const std::vector<DrmCompositionPlane> &comp_planes) {
});
}
-DrmDisplayCompositor::FrameWorker::FrameWorker(DrmDisplayCompositor *compositor)
- : Worker("frame-worker", HAL_PRIORITY_URGENT_DISPLAY),
- compositor_(compositor) {
-}
-
-DrmDisplayCompositor::FrameWorker::~FrameWorker() {
-}
-
-int DrmDisplayCompositor::FrameWorker::Init() {
- return InitWorker();
-}
-
-void DrmDisplayCompositor::FrameWorker::QueueFrame(
- std::unique_ptr<DrmDisplayComposition> composition, int status) {
- Lock();
- FrameState frame;
- frame.composition = std::move(composition);
- frame.status = status;
- frame_queue_.push(std::move(frame));
- SignalLocked();
- Unlock();
-}
-
-void DrmDisplayCompositor::FrameWorker::Routine() {
- int ret = Lock();
- if (ret) {
- ALOGE("Failed to lock worker, %d", ret);
- return;
- }
-
- int wait_ret = 0;
- if (frame_queue_.empty()) {
- wait_ret = WaitForSignalOrExitLocked();
- }
-
- FrameState frame;
- if (!frame_queue_.empty()) {
- frame = std::move(frame_queue_.front());
- frame_queue_.pop();
- }
-
- ret = Unlock();
- if (ret) {
- ALOGE("Failed to unlock worker, %d", ret);
- return;
- }
-
- if (wait_ret == -EINTR) {
- return;
- } else if (wait_ret) {
- ALOGE("Failed to wait for signal, %d", wait_ret);
- return;
- }
-
- compositor_->ApplyFrame(std::move(frame.composition), frame.status);
-}
-
DrmDisplayCompositor::DrmDisplayCompositor()
: drm_(NULL),
display_(-1),
- worker_(this),
- frame_worker_(this),
initialized_(false),
active_(false),
use_hw_overlays_(true),
@@ -255,9 +198,6 @@ DrmDisplayCompositor::~DrmDisplayCompositor() {
if (!initialized_)
return;
- worker_.Exit();
- frame_worker_.Exit();
-
int ret = pthread_mutex_lock(&lock_);
if (ret)
ALOGE("Failed to acquire compositor lock %d", ret);
@@ -289,18 +229,6 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) {
ALOGE("Failed to initialize drm compositor lock %d\n", ret);
return ret;
}
- ret = worker_.Init();
- if (ret) {
- pthread_mutex_destroy(&lock_);
- ALOGE("Failed to initialize compositor worker %d\n", ret);
- return ret;
- }
- ret = frame_worker_.Init();
- if (ret) {
- pthread_mutex_destroy(&lock_);
- ALOGE("Failed to initialize frame worker %d\n", ret);
- return ret;
- }
initialized_ = true;
return 0;
@@ -356,7 +284,6 @@ int DrmDisplayCompositor::QueueComposition(
return ret;
}
- worker_.Signal();
return 0;
}
@@ -991,7 +918,6 @@ int DrmDisplayCompositor::Composite() {
return ret;
}
}
- frame_worker_.QueueFrame(std::move(composition), ret);
break;
case DRM_COMPOSITION_TYPE_DPMS:
ret = ApplyDpms(composition.get());
diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h
index 9487cac..8e478eb 100644
--- a/drmdisplaycompositor.h
+++ b/drmdisplaycompositor.h
@@ -17,9 +17,6 @@
#ifndef ANDROID_DRM_DISPLAY_COMPOSITOR_H_
#define ANDROID_DRM_DISPLAY_COMPOSITOR_H_
-#include "drmhwcomposer.h"
-#include "drmcomposition.h"
-#include "drmcompositorworker.h"
#include "drmframebuffer.h"
#include "separate_rects.h"
@@ -108,23 +105,6 @@ class DrmDisplayCompositor {
int status = 0;
};
- class FrameWorker : public Worker {
- public:
- FrameWorker(DrmDisplayCompositor *compositor);
- ~FrameWorker() override;
-
- int Init();
- void QueueFrame(std::unique_ptr<DrmDisplayComposition> composition,
- int status);
-
- protected:
- void Routine() override;
-
- private:
- DrmDisplayCompositor *compositor_;
- std::queue<FrameState> frame_queue_;
- };
-
struct ModeState {
bool needs_modeset = false;
DrmMode mode;
@@ -158,9 +138,6 @@ class DrmDisplayCompositor {
DrmResources *drm_;
int display_;
- DrmCompositorWorker worker_;
- FrameWorker frame_worker_;
-
std::queue<std::unique_ptr<DrmDisplayComposition>> composite_queue_;
std::unique_ptr<DrmDisplayComposition> active_composition_;
diff --git a/drmeventlistener.cpp b/drmeventlistener.cpp
index b3e2328..d8c0b7d 100644
--- a/drmeventlistener.cpp
+++ b/drmeventlistener.cpp
@@ -18,10 +18,12 @@
#include "drmeventlistener.h"
#include "drmresources.h"
+#include "worker.h"
#include <linux/netlink.h>
#include <sys/socket.h>
+#include <system/graphics.h>
#include <cutils/log.h>
#include <xf86drm.h>
diff --git a/drmresources.cpp b/drmresources.cpp
index e433239..806941f 100644
--- a/drmresources.cpp
+++ b/drmresources.cpp
@@ -35,7 +35,7 @@
namespace android {
-DrmResources::DrmResources() : compositor_(this), event_listener_(this) {
+DrmResources::DrmResources() : event_listener_(this) {
}
DrmResources::~DrmResources() {
@@ -196,10 +196,6 @@ int DrmResources::Init() {
if (ret)
return ret;
- ret = compositor_.Init();
- if (ret)
- return ret;
-
ret = event_listener_.Init();
if (ret) {
ALOGE("Can't initialize event listener %d", ret);
@@ -329,21 +325,6 @@ int DrmResources::DestroyPropertyBlob(uint32_t blob_id) {
}
int DrmResources::SetDisplayActiveMode(int display, const DrmMode &mode) {
- std::unique_ptr<DrmComposition> comp(compositor_.CreateComposition(NULL));
- if (!comp) {
- ALOGE("Failed to create composition for dpms on %d", display);
- return -ENOMEM;
- }
- int ret = comp->SetDisplayMode(display, mode);
- if (ret) {
- ALOGE("Failed to add mode to composition on %d %d", display, ret);
- return ret;
- }
- ret = compositor_.QueueComposition(std::move(comp));
- if (ret) {
- ALOGE("Failed to queue dpms composition on %d %d", display, ret);
- return ret;
- }
return 0;
}
@@ -353,29 +334,9 @@ int DrmResources::SetDpmsMode(int display, uint64_t mode) {
return -EINVAL;
}
- std::unique_ptr<DrmComposition> comp(compositor_.CreateComposition(NULL));
- if (!comp) {
- ALOGE("Failed to create composition for dpms on %d", display);
- return -ENOMEM;
- }
- int ret = comp->SetDpmsMode(display, mode);
- if (ret) {
- ALOGE("Failed to add dpms %" PRIu64 " to composition on %d %d", mode,
- display, ret);
- return ret;
- }
- ret = compositor_.QueueComposition(std::move(comp));
- if (ret) {
- ALOGE("Failed to queue dpms composition on %d %d", display, ret);
- return ret;
- }
return 0;
}
-DrmCompositor *DrmResources::compositor() {
- return &compositor_;
-}
-
DrmEventListener *DrmResources::event_listener() {
return &event_listener_;
}
diff --git a/drmresources.h b/drmresources.h
index 64e6b57..3261e73 100644
--- a/drmresources.h
+++ b/drmresources.h
@@ -17,7 +17,6 @@
#ifndef ANDROID_DRM_H_
#define ANDROID_DRM_H_
-#include "drmcompositor.h"
#include "drmconnector.h"
#include "drmcrtc.h"
#include "drmencoder.h"
@@ -50,7 +49,6 @@ class DrmResources {
DrmConnector *GetConnectorForDisplay(int display) const;
DrmCrtc *GetCrtcForDisplay(int display) const;
DrmPlane *GetPlane(uint32_t id) const;
- DrmCompositor *compositor();
DrmEventListener *event_listener();
int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
@@ -81,7 +79,6 @@ class DrmResources {
std::vector<std::unique_ptr<DrmEncoder>> encoders_;
std::vector<std::unique_ptr<DrmCrtc>> crtcs_;
std::vector<std::unique_ptr<DrmPlane>> planes_;
- DrmCompositor compositor_;
DrmEventListener event_listener_;
};
}
diff --git a/hwcomposer.cpp b/hwcomposer.cpp
index 4b0ff2e..1baccb8 100644
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -363,11 +363,9 @@ int DrmHwcLayer::InitFromHwcLayer(hwc_layer_1_t *sf_layer, Importer *importer,
}
static void hwc_dump(struct hwc_composer_device_1 *dev, char *buff,
- int buff_len) {
- struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common;
+ int buff_len) {
std::ostringstream out;
- ctx->drm.compositor()->Dump(&out);
std::string out_str = out.str();
strncpy(buff, out_str.c_str(),
std::min((size_t)buff_len, out_str.length() + 1));
@@ -470,10 +468,8 @@ static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays,
std::vector<CheckedOutputFd> checked_output_fences;
std::vector<DrmHwcDisplayContents> displays_contents;
- std::vector<DrmCompositionDisplayLayersMap> layers_map;
std::vector<std::vector<size_t>> layers_indices;
displays_contents.reserve(num_displays);
- // layers_map.reserve(num_displays);
layers_indices.reserve(num_displays);
// Phase one does nothing that would cause errors. Only take ownership of FDs.
@@ -573,11 +569,6 @@ static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays,
if (!sf_display_contents[i] || i == HWC_DISPLAY_VIRTUAL)
continue;
- layers_map.emplace_back();
- DrmCompositionDisplayLayersMap &map = layers_map.back();
- map.display = i;
- map.geometry_changed =
- (dc->flags & HWC_GEOMETRY_CHANGED) == HWC_GEOMETRY_CHANGED;
std::vector<size_t> &indices_to_composite = layers_indices[i];
for (size_t j : indices_to_composite) {
hwc_layer_1_t *sf_layer = &dc->hwLayers[j];
@@ -589,27 +580,9 @@ static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays,
ALOGE("Failed to init composition from layer %d", ret);
return ret;
}
- map.layers.emplace_back(std::move(layer));
}
}
- std::unique_ptr<DrmComposition> composition(
- ctx->drm.compositor()->CreateComposition(ctx->importer.get()));
- if (!composition) {
- ALOGE("Drm composition init failed");
- return -EINVAL;
- }
-
- ret = composition->SetLayers(layers_map.size(), layers_map.data());
- if (ret) {
- return -EINVAL;
- }
-
- ret = ctx->drm.compositor()->QueueComposition(std::move(composition));
- if (ret) {
- return -EINVAL;
- }
-
for (size_t i = 0; i < num_displays; ++i) {
hwc_display_contents_1_t *dc = sf_display_contents[i];
if (!dc)
@@ -624,8 +597,6 @@ static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays,
}
}
- composition.reset(NULL);
-
return ret;
}