mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 07:15:59 +01:00
drm: minor improvements to crtc rechecks
This commit is contained in:
parent
c97e83ece1
commit
9d7c69cde2
1 changed files with 19 additions and 3 deletions
|
@ -533,17 +533,23 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool assigned = false;
|
bool assigned = false;
|
||||||
|
|
||||||
|
// try to use a connected connector
|
||||||
for (auto& c : recheck) {
|
for (auto& c : recheck) {
|
||||||
if (!(c->possibleCrtcs & (1 << i)))
|
if (!(c->possibleCrtcs & (1 << i)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (c->status != DRM_MODE_CONNECTED)
|
||||||
|
continue;
|
||||||
|
|
||||||
// deactivate old output
|
// deactivate old output
|
||||||
if (c->output && c->output->state && c->output->state->state().enabled) {
|
if (c->output && c->output->state && c->output->state->state().enabled) {
|
||||||
c->output->state->setEnabled(false);
|
c->output->state->setEnabled(false);
|
||||||
c->output->commit();
|
c->output->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: slot {} crtc {} assigned to {} (old {})", i, crtcs.at(i)->id, c->szName, c->crtc ? (int)c->crtc->id : -1));
|
backend->log(AQ_LOG_DEBUG,
|
||||||
|
std::format("drm: connected slot {} crtc {} assigned to {}{}", i, crtcs.at(i)->id, c->szName, c->crtc ? std::format(" (old {})", c->crtc->id) : ""));
|
||||||
c->crtc = crtcs.at(i);
|
c->crtc = crtcs.at(i);
|
||||||
assigned = true;
|
assigned = true;
|
||||||
changed.emplace_back(c);
|
changed.emplace_back(c);
|
||||||
|
@ -555,6 +561,13 @@ void Aquamarine::CDRMBackend::recheckCRTCs() {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: slot {} crtc {} unassigned", i, crtcs.at(i)->id));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: slot {} crtc {} unassigned", i, crtcs.at(i)->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& c : connectors) {
|
||||||
|
if (c->status == DRM_MODE_CONNECTED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} is not connected{}", c->szName, c->crtc ? std::format(", removing old crtc {}", c->crtc->id) : ""));
|
||||||
|
}
|
||||||
|
|
||||||
// if any connectors get a crtc and are connected, we need to rescan to assign them outputs.
|
// if any connectors get a crtc and are connected, we need to rescan to assign them outputs.
|
||||||
bool rescan = false;
|
bool rescan = false;
|
||||||
for (auto& c : changed) {
|
for (auto& c : changed) {
|
||||||
|
@ -597,6 +610,7 @@ bool Aquamarine::CDRMBackend::registerGPU(SP<CSessionDevice> gpu_, SP<CDRMBacken
|
||||||
if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_HOTPLUG) {
|
if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_HOTPLUG) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a hotplug event for {}", gpuName));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a hotplug event for {}", gpuName));
|
||||||
scanConnectors();
|
scanConnectors();
|
||||||
|
recheckCRTCs();
|
||||||
} else if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_LEASE) {
|
} else if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_LEASE) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a lease event for {}", gpuName));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a lease event for {}", gpuName));
|
||||||
scanLeases();
|
scanLeases();
|
||||||
|
@ -652,6 +666,8 @@ void Aquamarine::CDRMBackend::scanConnectors() {
|
||||||
conn = *it;
|
conn = *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn->status = drmConn->connection;
|
||||||
|
|
||||||
if (!conn->crtc) {
|
if (!conn->crtc) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Ignoring connector {} because it has no CRTC", connectorID));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Ignoring connector {} because it has no CRTC", connectorID));
|
||||||
continue;
|
continue;
|
||||||
|
@ -659,10 +675,10 @@ void Aquamarine::CDRMBackend::scanConnectors() {
|
||||||
|
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} connection state: {}", connectorID, (int)drmConn->connection));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} connection state: {}", connectorID, (int)drmConn->connection));
|
||||||
|
|
||||||
if (conn->status == DRM_MODE_DISCONNECTED && drmConn->connection == DRM_MODE_CONNECTED) {
|
if (conn->status == DRM_MODE_CONNECTED && !conn->output) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} connected", conn->szName));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} connected", conn->szName));
|
||||||
conn->connect(drmConn);
|
conn->connect(drmConn);
|
||||||
} else if (conn->status == DRM_MODE_CONNECTED && drmConn->connection == DRM_MODE_DISCONNECTED) {
|
} else if (conn->status != DRM_MODE_CONNECTED && conn->output) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} disconnected", conn->szName));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Connector {} disconnected", conn->szName));
|
||||||
conn->disconnect();
|
conn->disconnect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue