Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i915/drm: add property to support primary display #1536

Open
wants to merge 1 commit into
base: celadon/r/mr0/stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
From e64630f2050a2b933b6c216aa5cb1b8ec59b8eb7 Mon Sep 17 00:00:00 2001
From: kanlihu <[email protected]>
Date: Thu, 4 Aug 2022 23:25:53 +0800
Subject: [PATCH] i915/drm: add property to support primary display

vendor.hwcomposer.primary_display_order=327
write this property to /vendor/default.prop
surfaceflinger will know that connector id 327 is the primary display

Tracked-On: OAM-103459
Signed-off-by: Kanli, Hu <[email protected]>
---
DrmHwcTwo.cpp | 19 ++++++++++++++++++-
drm/DrmDevice.cpp | 6 ++----
2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp
index db4c528..461fd2a 100644
--- a/DrmHwcTwo.cpp
+++ b/DrmHwcTwo.cpp
@@ -1194,8 +1194,25 @@ void DrmHwcTwo::HandleDisplayHotplug(hwc2_display_t displayid, int state) {
: HWC2_CONNECTION_DISCONNECTED);
}

+static std::vector<DrmConnector *> make_sorted_connectors(
+ const std::vector<std::unique_ptr<DrmConnector>> &connectors) {
+ std::vector<DrmConnector *> sorted_connectors;
+ std::transform(std::begin(connectors), std::end(connectors),
+ std::back_inserter(sorted_connectors),
+ [](const std::unique_ptr<DrmConnector> &conn) {
+ return conn.get();
+ });
+ std::sort(std::begin(sorted_connectors), std::end(sorted_connectors),
+ [](DrmConnector *a1, DrmConnector *a2) {
+ return a1->display() < a2->display();
+ });
+ return sorted_connectors;
+}
+
void DrmHwcTwo::HandleInitialHotplugState(DrmDevice *drmDevice) {
- for (const auto &conn : drmDevice->connectors()) {
+ std::vector<DrmConnector *>
+ sorted_conns = make_sorted_connectors(drmDevice->connectors());
+ for (const auto &conn : sorted_conns) {
if (conn->state() != DRM_MODE_CONNECTED)
continue;
HandleDisplayHotplug(conn->display(), conn->state());
diff --git a/drm/DrmDevice.cpp b/drm/DrmDevice.cpp
index d7bc13a..b4e4066 100644
--- a/drm/DrmDevice.cpp
+++ b/drm/DrmDevice.cpp
@@ -55,7 +55,7 @@ namespace android {

static std::vector<std::string> read_primary_display_order_prop() {
std::array<char, PROPERTY_VALUE_MAX> display_order_buf{};
- property_get("vendor.hwc.drm.primary_display_order", display_order_buf.data(),
+ property_get("vendor.hwcomposer.primary_display_order", display_order_buf.data(),
"...");

std::vector<std::string> display_order;
@@ -92,7 +92,7 @@ static std::vector<DrmConnector *> make_primary_display_candidates(
auto it = std::find_if(std::begin(primary_candidates),
std::end(primary_candidates),
[&display_name](const DrmConnector *conn) {
- return conn->name() == display_name;
+ return std::to_string(conn->id()) == display_name;
});
if (it != std::end(primary_candidates)) {
std::iter_swap(it, curr_connector);
@@ -104,8 +104,6 @@ static std::vector<DrmConnector *> make_primary_display_candidates(
// then putting internal connectors second, everything else afterwards
std::partition(curr_connector, std::end(primary_candidates),
[](const DrmConnector *conn) { return conn->internal(); });
- } else {
- primary_candidates.erase(curr_connector, std::end(primary_candidates));
}

return primary_candidates;
--
2.31.0

Loading