diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-06-17 02:31:28 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-06-09 22:51:47 +0300 |
commit | 74d60e252839a03a2f179d82126d1e0db1b4184e (patch) | |
tree | b16af81cd62b007518d6440e92987e38a5072d63 | |
parent | 2236a8ccacdfed5ff5f6873ed6618eccf570193d (diff) |
card: Add support for writeback connectors
Enable enumeration of writeback connectors if both libdrm and the device
support it. The new Card::has_writeback() method report if the card
support writeback connectors.
Existing code that expect all connectors to model an output may be
confused by the sudden availability of new connectors. To handle this
issue,
- add a KMSXX_DISABLE_WRITEBACK_CONNECTORS environment variable to
disable enumeration of writeback connectors, similarly to universal
planes ; and
- ignore writeback connectors where no specific connector is requested
(Card::get_first_connected_connector(),
ResourceManager::reserve_connector() if no connector name is
specified, and applications that use all connected outputs).
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | kms++/inc/kms++/card.h | 2 | ||||
-rw-r--r-- | kms++/src/card.cpp | 13 | ||||
-rw-r--r-- | kms++/src/connector.cpp | 1 | ||||
-rw-r--r-- | kms++util/meson.build | 2 | ||||
-rw-r--r-- | kms++util/src/resourcemanager.cpp | 5 | ||||
-rw-r--r-- | py/pykms/pykmsbase.cpp | 1 | ||||
-rw-r--r-- | utils/kmsblank.cpp | 5 | ||||
-rw-r--r-- | utils/kmstest.cpp | 4 | ||||
-rw-r--r-- | utils/meson.build | 2 |
9 files changed, 33 insertions, 2 deletions
diff --git a/kms++/inc/kms++/card.h b/kms++/inc/kms++/card.h index bf6f9bf..fc11e92 100644 --- a/kms++/inc/kms++/card.h +++ b/kms++/inc/kms++/card.h @@ -54,6 +54,7 @@ public: bool has_universal_planes() const { return m_has_universal_planes; } bool has_dumb_buffers() const { return m_has_dumb; } bool has_kms() const; + bool has_writeback() const { return m_has_writeback; } std::vector<Connector*> get_connectors() const { return m_connectors; } std::vector<Encoder*> get_encoders() const { return m_encoders; } @@ -92,6 +93,7 @@ private: bool m_has_atomic; bool m_has_universal_planes; bool m_has_dumb; + bool m_has_writeback; CardVersion m_version; }; diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp index 935969d..6ad922a 100644 --- a/kms++/src/card.cpp +++ b/kms++/src/card.cpp @@ -216,6 +216,17 @@ void Card::setup() m_has_atomic = false; #endif +#ifdef DRM_CLIENT_CAP_WRITEBACK_CONNECTORS + if (getenv("KMSXX_DISABLE_WRITEBACK_CONNECTORS") == 0) { + r = drmSetClientCap(m_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + m_has_writeback = r == 0; + } else { + m_has_writeback = false; + } +#else + m_has_writeback = false; +#endif + uint64_t has_dumb; r = drmGetCap(m_fd, DRM_CAP_DUMB_BUFFER, &has_dumb); m_has_dumb = r == 0 && has_dumb; @@ -315,6 +326,8 @@ void Card::restore_modes() Connector* Card::get_first_connected_connector() const { for (auto c : m_connectors) { + if (c->connector_type() == DRM_MODE_CONNECTOR_WRITEBACK) + continue; if (c->connected()) return c; } diff --git a/kms++/src/connector.cpp b/kms++/src/connector.cpp index 92bab80..522851a 100644 --- a/kms++/src/connector.cpp +++ b/kms++/src/connector.cpp @@ -35,6 +35,7 @@ static const map<int, string> connector_names = { { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, { DRM_MODE_CONNECTOR_DPI, "DPI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "writeback" }, }; static const map<int, string> connection_str = { diff --git a/kms++util/meson.build b/kms++util/meson.build index 1b226f3..94718d6 100644 --- a/kms++util/meson.build +++ b/kms++util/meson.build @@ -32,7 +32,7 @@ if thread_dep.found() libkmsxxutil_args += [ '-DHAS_PTHREAD' ] endif -libkmsxxutil_deps = [ libkmsxx_dep, libfmt_dep, thread_dep ] +libkmsxxutil_deps = [ libkmsxx_dep, libdrm_dep, libfmt_dep, thread_dep ] libkmsxxutil = library('kms++util', libkmsxxutil_sources, diff --git a/kms++util/src/resourcemanager.cpp b/kms++util/src/resourcemanager.cpp index 5a9f016..01edaf3 100644 --- a/kms++util/src/resourcemanager.cpp +++ b/kms++util/src/resourcemanager.cpp @@ -2,6 +2,8 @@ #include <algorithm> #include <kms++util/strhelpers.h> +#include <xf86drmMode.h> + using namespace kms; using namespace std; @@ -20,6 +22,9 @@ void ResourceManager::reset() static Connector* find_connector(Card& card, const set<Connector*> reserved) { for (Connector* conn : card.get_connectors()) { + if (conn->connector_type() == DRM_MODE_CONNECTOR_WRITEBACK) + continue; + if (!conn->connected()) continue; diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 088d267..5df6fb3 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -51,6 +51,7 @@ void init_pykmsbase(py::module& m) }) .def_property_readonly("has_atomic", &Card::has_atomic) + .def_property_readonly("has_writeback", &Card::has_writeback) .def("get_prop", (Property * (Card::*)(uint32_t) const) & Card::get_prop) .def_property_readonly("version_name", &Card::version_name); diff --git a/utils/kmsblank.cpp b/utils/kmsblank.cpp index d9a3460..207d807 100644 --- a/utils/kmsblank.cpp +++ b/utils/kmsblank.cpp @@ -5,6 +5,8 @@ #include <kms++/kms++.h> #include <kms++util/kms++util.h> +#include <xf86drmMode.h> + using namespace std; using namespace kms; @@ -74,6 +76,9 @@ int main(int argc, char** argv) while (true) { for (Connector* conn : conns) { + if (conn->connector_type() == DRM_MODE_CONNECTOR_WRITEBACK) + continue; + if (!conn->connected()) { printf("Connector %u not connected\n", conn->idx()); continue; diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp index 3f1716f..15db072 100644 --- a/utils/kmstest.cpp +++ b/utils/kmstest.cpp @@ -17,6 +17,8 @@ #include <kms++util/kms++util.h> +#include <xf86drmMode.h> + using namespace std; using namespace kms; @@ -618,6 +620,8 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman, if (outputs.empty()) { // no outputs defined, show a pattern on all connected screens for (Connector* conn : card.get_connectors()) { + if (conn->connector_type() == DRM_MODE_CONNECTOR_WRITEBACK) + continue; if (!conn->connected()) continue; diff --git a/utils/meson.build b/utils/meson.build index ac73b5b..39ee7db 100644 --- a/utils/meson.build +++ b/utils/meson.build @@ -1,4 +1,4 @@ -common_deps = [ libkmsxx_dep, libkmsxxutil_dep, libfmt_dep ] +common_deps = [ libkmsxx_dep, libkmsxxutil_dep, libdrm_dep, libfmt_dep ] libevdev_dep = dependency('libevdev', required : false) |