diff options
-rw-r--r-- | kms++util/inc/kms++util/kms++util.h | 2 | ||||
-rw-r--r-- | kms++util/inc/kms++util/resourcemanager.h | 1 | ||||
-rw-r--r-- | kms++util/src/helpers.cpp | 43 | ||||
-rw-r--r-- | kms++util/src/resourcemanager.cpp | 9 | ||||
-rw-r--r-- | py/pykms/pykmsutil.cpp | 2 | ||||
-rw-r--r-- | utils/kmsblank.cpp | 3 | ||||
-rw-r--r-- | utils/kmstest.cpp | 21 |
7 files changed, 25 insertions, 56 deletions
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h index 5a688f6..3745a31 100644 --- a/kms++util/inc/kms++util/kms++util.h +++ b/kms++util/inc/kms++util/kms++util.h @@ -27,8 +27,6 @@ void draw_text(IMappedFramebuffer& buf, uint32_t x, uint32_t y, const std::strin void draw_color_bar(IMappedFramebuffer& buf, int old_xpos, int xpos, int width); void draw_test_pattern(IMappedFramebuffer &fb); - -Connector* resolve_connector(Card& card, const std::string& str); } #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/kms++util/inc/kms++util/resourcemanager.h b/kms++util/inc/kms++util/resourcemanager.h index 42e5000..dac6c9e 100644 --- a/kms++util/inc/kms++util/resourcemanager.h +++ b/kms++util/inc/kms++util/resourcemanager.h @@ -13,6 +13,7 @@ public: Card& card() const { return m_card; } Connector* reserve_connector(const std::string& name = ""); + Connector* reserve_connector(Connector* conn); Crtc* reserve_crtc(Connector* conn); Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined); Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); diff --git a/kms++util/src/helpers.cpp b/kms++util/src/helpers.cpp deleted file mode 100644 index 2bf3a4f..0000000 --- a/kms++util/src/helpers.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include <kms++util/kms++util.h> - -using namespace std; - -namespace kms { - -Connector* resolve_connector(Card& card, const string& str) -{ - if (str.length() == 0) - return nullptr; - - auto connectors = card.get_connectors(); - - if (str[0] == '@') { - char* endptr; - unsigned id = strtoul(str.c_str() + 1, &endptr, 10); - if (*endptr == 0) { - Connector* c = card.get_connector(id); - if (!c) - return nullptr; - else - return c; - } - } else { - char* endptr; - unsigned idx = strtoul(str.c_str(), &endptr, 10); - if (*endptr == 0) { - if (idx >= connectors.size()) - return nullptr; - else - return connectors[idx]; - } - } - - for (Connector* conn : connectors) { - if (to_lower(conn->fullname()).find(to_lower(str)) != string::npos) - return conn; - } - - return nullptr; -} - -} diff --git a/kms++util/src/resourcemanager.cpp b/kms++util/src/resourcemanager.cpp index cdd3e40..5c83ad7 100644 --- a/kms++util/src/resourcemanager.cpp +++ b/kms++util/src/resourcemanager.cpp @@ -99,6 +99,15 @@ Connector* ResourceManager::reserve_connector(const string& name) return conn; } +Connector* ResourceManager::reserve_connector(Connector* conn) +{ + if (contains(m_reserved_connectors, conn)) + return nullptr; + + m_reserved_connectors.push_back(conn); + return conn; +} + Crtc* ResourceManager::reserve_crtc(Connector* conn) { if (Crtc* crtc = conn->get_current_crtc()) { diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp index b3b7594..8421cc5 100644 --- a/py/pykms/pykmsutil.cpp +++ b/py/pykms/pykmsutil.cpp @@ -23,7 +23,7 @@ void init_pykmstest(py::module &m) py::class_<ResourceManager>(m, "ResourceManager") .def(py::init<Card&>()) .def("reset", &ResourceManager::reset) - .def("reserve_connector", &ResourceManager::reserve_connector, + .def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector, py::arg("name") = string()) .def("reserve_crtc", &ResourceManager::reserve_crtc) .def("reserve_plane", &ResourceManager::reserve_plane, diff --git a/utils/kmsblank.cpp b/utils/kmsblank.cpp index 4909826..0b51810 100644 --- a/utils/kmsblank.cpp +++ b/utils/kmsblank.cpp @@ -60,12 +60,13 @@ int main(int argc, char **argv) } Card card(dev_path); + ResourceManager resman(card); vector<Connector*> conns; if (conn_strs.size() > 0) { for (string s : conn_strs) { - auto c = resolve_connector(card, s); + auto c = resman.reserve_connector(s); if (!c) EXIT("Failed to resolve connector '%s'", s.c_str()); conns.push_back(c); diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp index 733523e..3fb4b28 100644 --- a/utils/kmstest.cpp +++ b/utils/kmstest.cpp @@ -73,9 +73,9 @@ static void get_default_connector(Card& card, OutputInfo& output) output.mode = output.connector->get_default_mode(); } -static void parse_connector(Card& card, const string& str, OutputInfo& output) +static void parse_connector(Card& card, ResourceManager& resman, const string& str, OutputInfo& output) { - Connector* conn = resolve_connector(card, str); + Connector* conn = resman.reserve_connector(str); if (!conn) EXIT("No connector '%s'", str.c_str()); @@ -488,16 +488,19 @@ static vector<Arg> parse_cmdline(int argc, char **argv) return args; } -static vector<OutputInfo> setups_to_outputs(Card& card, const vector<Arg>& output_args) +static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman, const vector<Arg>& output_args) { vector<OutputInfo> outputs; if (output_args.size() == 0) { // no output args, show a pattern on all screens - for (auto& pipe : card.get_connected_pipelines()) { + for (Connector* conn : card.get_connectors()) { + if (!conn->connected()) + continue; + OutputInfo output = { }; - output.connector = pipe.connector; - output.crtc = pipe.crtc; + output.connector = resman.reserve_connector(conn); + output.crtc = resman.reserve_crtc(conn); output.mode = output.connector->get_default_mode(); output.fbs = get_default_fb(card, output.mode.hdisplay, output.mode.vdisplay); @@ -518,7 +521,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, const vector<Arg>& outpu outputs.push_back(OutputInfo { }); current_output = &outputs.back(); - parse_connector(card, arg.arg, *current_output); + parse_connector(card, resman, arg.arg, *current_output); current_plane = 0; break; @@ -1019,10 +1022,10 @@ int main(int argc, char **argv) if (!card.has_atomic() && s_flip_sync) EXIT("Synchronized flipping requires atomic modesetting"); - vector<OutputInfo> outputs = setups_to_outputs(card, output_args); - ResourceManager resman(card); + vector<OutputInfo> outputs = setups_to_outputs(card, resman, output_args); + if (card.has_atomic()) { for (OutputInfo& o : outputs) { if (o.fbs.empty()) |