drm: reset on beginning of DRM

We do not set atomic props for everything, so all else should be reset
This commit is contained in:
Vaxry 2024-06-30 20:54:11 +02:00
parent c19bf35c02
commit 25836ee88e
6 changed files with 14 additions and 21 deletions

View file

@ -270,7 +270,7 @@ namespace Aquamarine {
class IDRMImplementation {
public:
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data) = 0;
virtual bool reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) = 0;
virtual bool reset() = 0;
// moving a cursor IIRC is almost instant on most hardware so we don't have to wait for a commit.
virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) = 0;

View file

@ -7,7 +7,7 @@ namespace Aquamarine {
public:
CDRMAtomicImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_);
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
virtual bool reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector);
virtual bool reset();
virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector);
private:

View file

@ -7,7 +7,7 @@ namespace Aquamarine {
public:
CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_);
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
virtual bool reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector);
virtual bool reset();
virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector);
private:

View file

@ -253,15 +253,8 @@ void Aquamarine::CDRMBackend::restoreAfterVT() {
backend->log(AQ_LOG_DEBUG, "drm: Rescanned connectors");
for (auto& c : connectors) {
if (!c->crtc)
continue;
backend->log(AQ_LOG_DEBUG, std::format("drm: Resetting crtc {}", c->crtc->id));
if (!impl->reset(c))
backend->log(AQ_LOG_ERROR, std::format("drm: crtc {} failed reset", c->crtc->id));
}
if (!impl->reset())
backend->log(AQ_LOG_ERROR, "drm: failed reset");
for (auto& c : connectors) {
if (!c->crtc)
@ -524,6 +517,7 @@ void Aquamarine::CDRMBackend::scanConnectors() {
}
bool Aquamarine::CDRMBackend::start() {
impl->reset();
return true;
}

View file

@ -272,7 +272,7 @@ bool Aquamarine::CDRMAtomicImpl::commit(Hyprutils::Memory::CSharedPointer<SDRMCo
return ok;
}
bool Aquamarine::CDRMAtomicImpl::reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) {
bool Aquamarine::CDRMAtomicImpl::reset() {
CDRMAtomicRequest request(backend);
for (auto& crtc : backend->crtcs) {
@ -291,7 +291,7 @@ bool Aquamarine::CDRMAtomicImpl::reset(Hyprutils::Memory::CSharedPointer<SDRMCon
return request.commit(DRM_MODE_ATOMIC_ALLOW_MODESET);
}
bool Aquamarine::CDRMAtomicImpl::moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) {
bool Aquamarine::CDRMAtomicImpl::moveCursor(SP<SDRMConnector> connector) {
if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor)
return true;

View file

@ -150,13 +150,12 @@ bool Aquamarine::CDRMLegacyImpl::commit(Hyprutils::Memory::CSharedPointer<SDRMCo
return commitInternal(connector, data);
}
bool Aquamarine::CDRMLegacyImpl::reset(SP<SDRMConnector> connector) {
if (!connector->crtc)
return true;
if (int ret = drmModeSetCrtc(backend->gpu->fd, connector->crtc->id, 0, 0, 0, nullptr, 0, nullptr); ret) {
connector->backend->backend->log(AQ_LOG_ERROR, std::format("legacy drm: reset failed: {}", strerror(-ret)));
return false;
bool Aquamarine::CDRMLegacyImpl::reset() {
for (auto& connector : backend->connectors) {
if (int ret = drmModeSetCrtc(backend->gpu->fd, connector->crtc->id, 0, 0, 0, nullptr, 0, nullptr); ret) {
connector->backend->backend->log(AQ_LOG_ERROR, std::format("legacy drm: reset failed: {}", strerror(-ret)));
return false;
}
}
return true;