summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kms++/inc/kms++/videomode.h2
-rw-r--r--kms++/src/connector.cpp3
-rw-r--r--kms++/src/videomode.cpp5
-rw-r--r--kms++util/inc/kms++util/resourcemanager.h3
-rw-r--r--kms++util/src/resourcemanager.cpp15
-rw-r--r--utils/kmstest.cpp8
6 files changed, 31 insertions, 5 deletions
diff --git a/kms++/inc/kms++/videomode.h b/kms++/inc/kms++/videomode.h
index 74aa8f1..3aacd57 100644
--- a/kms++/inc/kms++/videomode.h
+++ b/kms++/inc/kms++/videomode.h
@@ -52,6 +52,8 @@ struct Videomode
std::string to_string_short() const;
std::string to_string_long() const;
std::string to_string_long_padded() const;
+
+ bool valid() const;
};
struct Videomode videomode_from_timings(uint32_t clock_khz,
diff --git a/kms++/src/connector.cpp b/kms++/src/connector.cpp
index 72f8777..a408619 100644
--- a/kms++/src/connector.cpp
+++ b/kms++/src/connector.cpp
@@ -120,7 +120,8 @@ void Connector::restore_mode()
Videomode Connector::get_default_mode() const
{
if (m_priv->drm_connector->count_modes == 0)
- throw invalid_argument("no modes available\n");
+ return Videomode();
+
drmModeModeInfo drmmode = m_priv->drm_connector->modes[0];
return drm_mode_to_video_mode(drmmode);
diff --git a/kms++/src/videomode.cpp b/kms++/src/videomode.cpp
index b53f0c0..066896f 100644
--- a/kms++/src/videomode.cpp
+++ b/kms++/src/videomode.cpp
@@ -12,6 +12,11 @@ using namespace std;
namespace kms
{
+bool Videomode::valid() const
+{
+ return !!clock;
+}
+
unique_ptr<Blob> Videomode::to_blob(Card& card) const
{
drmModeModeInfo drm_mode = video_mode_to_drm_mode(*this);
diff --git a/kms++util/inc/kms++util/resourcemanager.h b/kms++util/inc/kms++util/resourcemanager.h
index 1b5cf21..3301da2 100644
--- a/kms++util/inc/kms++util/resourcemanager.h
+++ b/kms++util/inc/kms++util/resourcemanager.h
@@ -14,13 +14,16 @@ public:
Card& card() const { return m_card; }
Connector* reserve_connector(const std::string& name = "");
Connector* reserve_connector(Connector* conn);
+ void release_connector(Connector* conn);
Crtc* reserve_crtc(Connector* conn);
Crtc* reserve_crtc(Crtc* crtc);
+ void release_crtc(Crtc* crtc);
Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined);
Plane* reserve_plane(Plane* plane);
Plane* reserve_generic_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
+ void release_plane(Plane* plane);
private:
Card& m_card;
diff --git a/kms++util/src/resourcemanager.cpp b/kms++util/src/resourcemanager.cpp
index 9a8a66b..5a9f016 100644
--- a/kms++util/src/resourcemanager.cpp
+++ b/kms++util/src/resourcemanager.cpp
@@ -104,6 +104,11 @@ Connector* ResourceManager::reserve_connector(Connector* conn)
return conn;
}
+void ResourceManager::release_connector(Connector* conn)
+{
+ m_reserved_connectors.erase(conn);
+}
+
Crtc* ResourceManager::reserve_crtc(Connector* conn)
{
if (!conn)
@@ -138,6 +143,11 @@ Crtc* ResourceManager::reserve_crtc(Crtc* crtc)
return crtc;
}
+void ResourceManager::release_crtc(Crtc* crtc)
+{
+ m_reserved_crtcs.erase(crtc);
+}
+
Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format)
{
if (!crtc)
@@ -204,3 +214,8 @@ Plane* ResourceManager::reserve_overlay_plane(Crtc* crtc, PixelFormat format)
{
return reserve_plane(crtc, PlaneType::Overlay, format);
}
+
+void ResourceManager::release_plane(Plane* plane)
+{
+ m_reserved_planes.erase(plane);
+}
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index b6092cb..b4bf24b 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -88,9 +88,6 @@ static void get_connector(ResourceManager& resman, OutputInfo& output, const str
if (!conn)
EXIT("No connector '%s'", str.c_str());
- if (!conn->connected())
- EXIT("Connector '%s' not connected", conn->fullname().c_str());
-
output.connector = conn;
output.mode = output.connector->get_default_mode();
}
@@ -646,7 +643,7 @@ 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_status() != ConnectorStatus::Connected)
+ if (!conn->connected())
continue;
OutputInfo output = { };
@@ -668,6 +665,9 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
get_props(card, o.crtc_props, o.crtc);
+ if (!o.mode.valid())
+ EXIT("Mode not valid for %s", o.connector->fullname().c_str());
+
if (card.has_atomic()) {
if (o.planes.empty())
add_default_planeinfo(&o);