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 { class IDRMImplementation {
public: public:
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data) = 0; 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. // 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; virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) = 0;

View file

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

View file

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

View file

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

View file

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

View file

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