udev: Add the ability to query the current framebuffer.
Summary: This adds the ability for kwin's udev handler to detect a usable framebuffer device. This is very similar to the function that queries the primary GPU. Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: rkflx, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D9554
This commit is contained in:
parent
d318cb3bd4
commit
7801afdd4c
2 changed files with 23 additions and 0 deletions
22
udev.cpp
22
udev.cpp
|
@ -178,6 +178,28 @@ UdevDevice::Ptr Udev::renderNode()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UdevDevice::Ptr Udev::primaryFramebuffer()
|
||||||
|
{
|
||||||
|
if (!m_udev) {
|
||||||
|
return UdevDevice::Ptr();
|
||||||
|
}
|
||||||
|
UdevEnumerate enumerate(this);
|
||||||
|
enumerate.addMatch(UdevEnumerate::Match::SubSystem, "graphics");
|
||||||
|
enumerate.addMatch(UdevEnumerate::Match::SysName, "fb[0-9]*");
|
||||||
|
enumerate.scan();
|
||||||
|
return enumerate.find([](const UdevDevice::Ptr &device) {
|
||||||
|
auto pci = device->getParentWithSubsystemDevType("pci");
|
||||||
|
if (!pci) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const char *systAttrValue = udev_device_get_sysattr_value(pci, "boot_vga");
|
||||||
|
if (systAttrValue && qstrcmp(systAttrValue, "1") == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
UdevDevice::Ptr Udev::deviceFromSyspath(const char *syspath)
|
UdevDevice::Ptr Udev::deviceFromSyspath(const char *syspath)
|
||||||
{
|
{
|
||||||
return UdevDevice::Ptr(new UdevDevice(udev_device_new_from_syspath(m_udev, syspath)));
|
return UdevDevice::Ptr(new UdevDevice(udev_device_new_from_syspath(m_udev, syspath)));
|
||||||
|
|
1
udev.h
1
udev.h
|
@ -82,6 +82,7 @@ public:
|
||||||
return m_udev != nullptr;
|
return m_udev != nullptr;
|
||||||
}
|
}
|
||||||
UdevDevice::Ptr primaryGpu();
|
UdevDevice::Ptr primaryGpu();
|
||||||
|
UdevDevice::Ptr primaryFramebuffer();
|
||||||
UdevDevice::Ptr virtualGpu();
|
UdevDevice::Ptr virtualGpu();
|
||||||
UdevDevice::Ptr renderNode();
|
UdevDevice::Ptr renderNode();
|
||||||
UdevDevice::Ptr deviceFromSyspath(const char *syspath);
|
UdevDevice::Ptr deviceFromSyspath(const char *syspath);
|
||||||
|
|
Loading…
Reference in a new issue