mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-12-22 17:09:48 +01:00
drm: fixes for hotplugging monitors and vt
This commit is contained in:
parent
d44aaec26f
commit
917d48153a
3 changed files with 45 additions and 4 deletions
|
@ -227,7 +227,7 @@ namespace Aquamarine {
|
||||||
class IDRMImplementation {
|
class IDRMImplementation {
|
||||||
public:
|
public:
|
||||||
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, const SDRMConnectorCommitData& data) = 0;
|
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, const SDRMConnectorCommitData& data) = 0;
|
||||||
virtual bool reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) = 0;
|
virtual bool reset(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDRMBackend : public IBackendImplementation {
|
class CDRMBackend : public IBackendImplementation {
|
||||||
|
@ -265,6 +265,7 @@ namespace Aquamarine {
|
||||||
Hyprutils::Memory::CSharedPointer<CSessionDevice> gpu;
|
Hyprutils::Memory::CSharedPointer<CSessionDevice> gpu;
|
||||||
Hyprutils::Memory::CSharedPointer<IDRMImplementation> impl;
|
Hyprutils::Memory::CSharedPointer<IDRMImplementation> impl;
|
||||||
Hyprutils::Memory::CWeakPointer<CDRMBackend> primary;
|
Hyprutils::Memory::CWeakPointer<CDRMBackend> primary;
|
||||||
|
std::string gpuName;
|
||||||
|
|
||||||
Hyprutils::Memory::CWeakPointer<CBackend> backend;
|
Hyprutils::Memory::CWeakPointer<CBackend> backend;
|
||||||
|
|
||||||
|
@ -281,6 +282,8 @@ namespace Aquamarine {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Hyprutils::Signal::CHyprSignalListener sessionActivate;
|
Hyprutils::Signal::CHyprSignalListener sessionActivate;
|
||||||
|
Hyprutils::Signal::CHyprSignalListener gpuChange;
|
||||||
|
Hyprutils::Signal::CHyprSignalListener gpuRemove;
|
||||||
} listeners;
|
} listeners;
|
||||||
|
|
||||||
friend class CBackend;
|
friend class CBackend;
|
||||||
|
|
|
@ -208,11 +208,34 @@ void Aquamarine::CSession::dispatchUdevEvents() {
|
||||||
|
|
||||||
if (action == std::string{"change"}) {
|
if (action == std::string{"change"}) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("udev: DRM device {} changed", sysname ? sysname : "unknown"));
|
backend->log(AQ_LOG_DEBUG, std::format("udev: DRM device {} changed", sysname ? sysname : "unknown"));
|
||||||
backend->log(AQ_LOG_ERROR, "udev: FIXME: change event is a STUB");
|
|
||||||
|
CSessionDevice::SChangeEvent event;
|
||||||
|
|
||||||
|
auto prop = udev_device_get_property_value(device, "HOTPLUG");
|
||||||
|
if (prop && prop == std::string{"1"}) {
|
||||||
|
event.type = CSessionDevice::AQ_SESSION_EVENT_CHANGE_HOTPLUG;
|
||||||
|
|
||||||
|
prop = udev_device_get_property_value(device, "CONNECTOR");
|
||||||
|
if (prop)
|
||||||
|
event.hotplug.connectorID = std::stoull(prop);
|
||||||
|
|
||||||
|
prop = udev_device_get_property_value(device, "PROPERTY");
|
||||||
|
if (prop)
|
||||||
|
event.hotplug.propID = std::stoull(prop);
|
||||||
|
} else if (prop = udev_device_get_property_value(device, "LEASE"); prop && prop == std::string{"1"}) {
|
||||||
|
event.type = CSessionDevice::AQ_SESSION_EVENT_CHANGE_LEASE;
|
||||||
|
} else {
|
||||||
|
backend->log(AQ_LOG_DEBUG, std::format("udev: DRM device {} change event unrecognized", sysname ? sysname : "unknown"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->events.change.emit(event);
|
||||||
} else if (action == std::string{"remove"}) {
|
} else if (action == std::string{"remove"}) {
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("udev: DRM device {} removed", sysname ? sysname : "unknown"));
|
backend->log(AQ_LOG_DEBUG, std::format("udev: DRM device {} removed", sysname ? sysname : "unknown"));
|
||||||
backend->log(AQ_LOG_ERROR, "udev: FIXME: remove event is a STUB");
|
d->events.remove.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,10 @@ bool Aquamarine::CDRMBackend::sessionActive() {
|
||||||
void Aquamarine::CDRMBackend::restoreAfterVT() {
|
void Aquamarine::CDRMBackend::restoreAfterVT() {
|
||||||
backend->log(AQ_LOG_DEBUG, "drm: Restoring after VT switch");
|
backend->log(AQ_LOG_DEBUG, "drm: Restoring after VT switch");
|
||||||
|
|
||||||
|
scanConnectors();
|
||||||
|
|
||||||
|
backend->log(AQ_LOG_DEBUG, "drm: Rescanned connectors");
|
||||||
|
|
||||||
for (auto& c : connectors) {
|
for (auto& c : connectors) {
|
||||||
if (!c->crtc)
|
if (!c->crtc)
|
||||||
continue;
|
continue;
|
||||||
|
@ -387,11 +391,22 @@ bool Aquamarine::CDRMBackend::registerGPU(SP<CSessionDevice> gpu_, SP<CDRMBacken
|
||||||
auto drmName = drmGetDeviceNameFromFd2(gpu->fd);
|
auto drmName = drmGetDeviceNameFromFd2(gpu->fd);
|
||||||
auto drmVer = drmGetVersion(gpu->fd);
|
auto drmVer = drmGetVersion(gpu->fd);
|
||||||
|
|
||||||
|
gpuName = drmName;
|
||||||
|
|
||||||
backend->log(AQ_LOG_DEBUG, std::format("drm: Starting backend for {}, with driver {}", drmName ? drmName : "unknown", drmVer->name ? drmVer->name : "unknown"));
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Starting backend for {}, with driver {}", drmName ? drmName : "unknown", drmVer->name ? drmVer->name : "unknown"));
|
||||||
|
|
||||||
drmFreeVersion(drmVer);
|
drmFreeVersion(drmVer);
|
||||||
|
|
||||||
// FIXME: listen to change and remove events from session
|
listeners.gpuChange = gpu->events.change.registerListener([this](std::any d) {
|
||||||
|
auto E = std::any_cast<CSessionDevice::SChangeEvent>(d);
|
||||||
|
if (E.type == CSessionDevice::AQ_SESSION_EVENT_CHANGE_HOTPLUG) {
|
||||||
|
backend->log(AQ_LOG_DEBUG, std::format("drm: Got a hotplug event for {}", gpuName));
|
||||||
|
scanConnectors();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
listeners.gpuRemove = gpu->events.remove.registerListener(
|
||||||
|
[this](std::any d) { backend->log(AQ_LOG_ERROR, std::format("drm: !!!!FIXME: Got a remove event for {}, this is not handled properly!!!!!", gpuName)); });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue