mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 03:46:00 +01:00
drm: avoid crashes on connecting a null crtc
This commit is contained in:
parent
e947af7894
commit
4f6642808b
2 changed files with 27 additions and 19 deletions
|
@ -265,6 +265,7 @@ namespace Aquamarine {
|
||||||
void applyCommit(const SDRMConnectorCommitData& data);
|
void applyCommit(const SDRMConnectorCommitData& data);
|
||||||
void rollbackCommit(const SDRMConnectorCommitData& data);
|
void rollbackCommit(const SDRMConnectorCommitData& data);
|
||||||
void onPresent();
|
void onPresent();
|
||||||
|
void recheckCRTCProps();
|
||||||
|
|
||||||
Hyprutils::Memory::CSharedPointer<CDRMOutput> output;
|
Hyprutils::Memory::CSharedPointer<CDRMOutput> output;
|
||||||
Hyprutils::Memory::CWeakPointer<CDRMBackend> backend;
|
Hyprutils::Memory::CWeakPointer<CDRMBackend> backend;
|
||||||
|
|
|
@ -713,10 +713,8 @@ void Aquamarine::CDRMBackend::scanConnectors() {
|
||||||
|
|
||||||
conn->status = drmConn->connection;
|
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));
|
conn->recheckCRTCProps();
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1157,6 +1155,23 @@ void Aquamarine::SDRMConnector::parseEDID(std::vector<uint8_t> data) {
|
||||||
di_info_destroy(info);
|
di_info_destroy(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Aquamarine::SDRMConnector::recheckCRTCProps() {
|
||||||
|
if (!crtc || !output)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint64_t prop = 0;
|
||||||
|
canDoVrr = props.vrr_capable && crtc->props.vrr_enabled && getDRMProp(backend->gpu->fd, id, props.vrr_capable, &prop) && prop;
|
||||||
|
output->vrrCapable = canDoVrr;
|
||||||
|
|
||||||
|
backend->backend->log(AQ_LOG_DEBUG,
|
||||||
|
std::format("drm: connector {} crtc is {} of vrr: props.vrr_capable -> {}, crtc->props.vrr_enabled -> {}", szName, (canDoVrr ? "capable" : "incapable"),
|
||||||
|
props.vrr_capable, crtc->props.vrr_enabled));
|
||||||
|
|
||||||
|
output->supportsExplicit = backend->drmProps.supportsTimelines && crtc->props.out_fence_ptr && crtc->primary->props.in_fence_fd;
|
||||||
|
|
||||||
|
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Explicit sync {}", output->supportsExplicit ? "supported" : "unsupported"));
|
||||||
|
}
|
||||||
|
|
||||||
void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
|
void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
|
||||||
if (output) {
|
if (output) {
|
||||||
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Not connecting connector {} because it's already connected", szName));
|
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Not connecting connector {} because it's already connected", szName));
|
||||||
|
@ -1228,13 +1243,6 @@ void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
|
||||||
output->nonDesktop = prop;
|
output->nonDesktop = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
canDoVrr = props.vrr_capable && crtc->props.vrr_enabled && getDRMProp(backend->gpu->fd, id, props.vrr_capable, &prop) && prop;
|
|
||||||
output->vrrCapable = canDoVrr;
|
|
||||||
|
|
||||||
backend->backend->log(AQ_LOG_DEBUG,
|
|
||||||
std::format("drm: crtc is {} of vrr: props.vrr_capable -> {}, crtc->props.vrr_enabled -> {}", (canDoVrr ? "capable" : "incapable"), props.vrr_capable,
|
|
||||||
crtc->props.vrr_enabled));
|
|
||||||
|
|
||||||
maxBpcBounds.fill(0);
|
maxBpcBounds.fill(0);
|
||||||
|
|
||||||
if (props.max_bpc && !introspectDRMPropRange(backend->gpu->fd, props.max_bpc, maxBpcBounds.data(), &maxBpcBounds[1]))
|
if (props.max_bpc && !introspectDRMPropRange(backend->gpu->fd, props.max_bpc, maxBpcBounds.data(), &maxBpcBounds[1]))
|
||||||
|
@ -1256,14 +1264,13 @@ void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {
|
||||||
output->serial = serial;
|
output->serial = serial;
|
||||||
output->description = std::format("{} {} {} ({})", make, model, serial, szName);
|
output->description = std::format("{} {} {} ({})", make, model, serial, szName);
|
||||||
output->needsFrame = true;
|
output->needsFrame = true;
|
||||||
output->supportsExplicit = backend->drmProps.supportsTimelines && crtc->props.out_fence_ptr && crtc->primary->props.in_fence_fd;
|
|
||||||
|
|
||||||
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Explicit sync {}", output->supportsExplicit ? "supported" : "unsupported"));
|
|
||||||
|
|
||||||
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Description {}", output->description));
|
backend->backend->log(AQ_LOG_DEBUG, std::format("drm: Description {}", output->description));
|
||||||
|
|
||||||
status = DRM_MODE_CONNECTED;
|
status = DRM_MODE_CONNECTED;
|
||||||
|
|
||||||
|
recheckCRTCProps();
|
||||||
|
|
||||||
if (!backend->backend->ready)
|
if (!backend->backend->ready)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue