summaryrefslogtreecommitdiff
path: root/kms++util
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-02-07 13:39:15 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-02-10 07:04:02 +0200
commit05009c91478ca2a8790a758ed0bd218e5f4dffb8 (patch)
treedc7813a92e7cf3adaf90b2c3c02a95c496e87acf /kms++util
parent05bc0a0c4fe88031e72f17b342476d5f7d6775d0 (diff)
use reserve_connector from ResourceManager
Diffstat (limited to 'kms++util')
-rw-r--r--kms++util/inc/kms++util/kms++util.h2
-rw-r--r--kms++util/inc/kms++util/resourcemanager.h1
-rw-r--r--kms++util/src/helpers.cpp43
-rw-r--r--kms++util/src/resourcemanager.cpp9
4 files changed, 10 insertions, 45 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()) {