[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: udev: Add the ability to query the current framebuffer.
From:       Martin_Flöser <null () kde ! org>
Date:       2018-04-05 17:46:33
Message-ID: E1f48y1-0001aB-Vx () code ! kde ! org
[Download RAW message or body]

Git commit 7801afdd4c3d092c73cb40f9007803b8a704e826 by Martin Flöser, on behalf of Nerdopolis Turfwalker.
Committed on 05/04/2018 at 17:46.
Pushed by graesslin into branch 'master'.

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

M  +22   -0    udev.cpp
M  +1    -0    udev.h

https://commits.kde.org/kwin/7801afdd4c3d092c73cb40f9007803b8a704e826

diff --git a/udev.cpp b/udev.cpp
index f65724a9d..e3b2406c3 100644
--- a/udev.cpp
+++ b/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)
 {
     return UdevDevice::Ptr(new UdevDevice(udev_device_new_from_syspath(m_udev, syspath)));
diff --git a/udev.h b/udev.h
index 5dad01e56..88a87e869 100644
--- a/udev.h
+++ b/udev.h
@@ -82,6 +82,7 @@ public:
         return m_udev != nullptr;
     }
     UdevDevice::Ptr primaryGpu();
+    UdevDevice::Ptr primaryFramebuffer();
     UdevDevice::Ptr virtualGpu();
     UdevDevice::Ptr renderNode();
     UdevDevice::Ptr deviceFromSyspath(const char *syspath);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic