From 05009c91478ca2a8790a758ed0bd218e5f4dffb8 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 7 Feb 2017 13:39:15 +0200 Subject: use reserve_connector from ResourceManager --- kms++util/inc/kms++util/kms++util.h | 2 -- kms++util/inc/kms++util/resourcemanager.h | 1 + kms++util/src/helpers.cpp | 43 ------------------------------- kms++util/src/resourcemanager.cpp | 9 +++++++ 4 files changed, 10 insertions(+), 45 deletions(-) delete mode 100644 kms++util/src/helpers.cpp (limited to 'kms++util') 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 - -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()) { -- cgit v1.2.3