SHA256
1
0
forked from pool/kinfocenter5

Accepting request 605392 from home:wolfi323:test

- Add kcm_opengl-Fix-retrieval-of-DRI-information.patch to fix
  displaying 3D acceleration info and kernel module in "OpenGL"
  with kernels >= 3.12

OBS-URL: https://build.opensuse.org/request/show/605392
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/kinfocenter5?expand=0&rev=191
This commit is contained in:
Fabian Vogt 2018-05-08 15:34:16 +00:00 committed by Git OBS Bridge
parent 23e7e5dae3
commit 78da231f7a
3 changed files with 193 additions and 1 deletions

View File

@ -0,0 +1,183 @@
From e38d60fb23f7894631fa1225101e6b26ebd19f0e Mon Sep 17 00:00:00 2001
From: Lindsay Roberts <m@lindsayr.com>
Date: Thu, 3 May 2018 21:29:42 +0300
Subject: kcm_opengl: Fix retrieval of DRI information
Summary:
Currently DRI information retrieval is attempted via /proc/dri, which
was removed from the linux kernel in v3.12 (2013). This information
includes the kernel driver in use as well as card identification sourced
from pci.ids database.
This adds support for retrieving this information in the same vein via
/dev and /sys for modern kernels.
Test Plan: kcmshell5 opengl should correctly display kernel driver.
Reviewers: #plasma, alexeymin
Reviewed By: alexeymin
Subscribers: alexeymin, wbauer, plasma-devel, #plasma
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D12476
---
Modules/opengl/opengl.cpp | 117 ++++++++++++++++++++++++++++++++--------------
1 file changed, 81 insertions(+), 36 deletions(-)
diff --git a/Modules/opengl/opengl.cpp b/Modules/opengl/opengl.cpp
index 90b7d5b..795636b 100644
--- a/Modules/opengl/opengl.cpp
+++ b/Modules/opengl/opengl.cpp
@@ -63,6 +63,12 @@
#include <GL/glx.h>
#endif
+#if defined(Q_OS_LINUX)
+#include <QFileInfo>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#endif
+
K_PLUGIN_FACTORY(KCMOpenGLFactory,
registerPlugin<KCMOpenGL>();
)
@@ -178,51 +184,89 @@ static int ReadPipe(const QString &FileName, QStringList &list)
#if defined(Q_OS_LINUX)
+static QString get_sysfs_link_name(const QString& path)
+{
+ const QString target = QFileInfo(path).symLinkTarget();
+
+ const int index = target.lastIndexOf(QChar('/'));
+ if (index == -1)
+ return QString();
+
+ return target.mid(index + 1);
+}
+
+static bool get_drm_device_sysfs()
+{
+ struct stat fileInfo;
+ if (::stat("/dev/dri/card0", &fileInfo) != 0)
+ return false;
+ if ((fileInfo.st_mode & S_IFCHR) != S_IFCHR)
+ return false;
+
+ const uint16_t devMajor = major(fileInfo.st_rdev);
+ const uint16_t devMinor = minor(fileInfo.st_rdev);
+ QString sysPath = QStringLiteral("/sys/dev/char/%1:%2/device").arg(devMajor).arg(devMinor);
+
+ dri_info.pci = get_sysfs_link_name(sysPath);
+ dri_info.module = get_sysfs_link_name(sysPath + QStringLiteral("/driver"));
+
+ return (dri_info.pci.size() && dri_info.module.size());
+}
+
#define INFO_DRI QStringLiteral("/proc/dri/0/name")
-static bool get_dri_device()
+static bool get_dri_device_proc()
{
QFile file;
file.setFileName(INFO_DRI);
if (!file.exists() || !file.open(QIODevice::ReadOnly))
- return false;
+ return false;
QTextStream stream(&file);
QString line = stream.readLine();
- if (!line.isEmpty()) {
- dri_info.module = line.mid(0, line.indexOf(0x20));
-
- // possible formats, for regression testing
- // line = " PCI:01:00:0";
- // line = " pci:0000:01:00.0"
- QRegExp rx = QRegExp("\\b[Pp][Cc][Ii][:]([0-9a-fA-F]+[:])?([0-9a-fA-F]+[:][0-9a-fA-F]+[:.][0-9a-fA-F]+)\\b");
- if (rx.indexIn(line)>0) {
- dri_info.pci = rx.cap(2);
- int end = dri_info.pci.lastIndexOf(':');
- int end2 = dri_info.pci.lastIndexOf('.');
- if (end2>end) end=end2;
- dri_info.pci[end]='.';
-
- QString cmd = QStringLiteral("lspci -m -v -s ") + dri_info.pci;
- QStringList pci_info;
- int num;
- if (((num = ReadPipe(cmd, pci_info)) ||
- (num = ReadPipe("/sbin/"+cmd, pci_info)) ||
- (num = ReadPipe("/usr/sbin/"+cmd, pci_info)) ||
- (num = ReadPipe("/usr/local/sbin/"+cmd, pci_info))) && num>=7) {
- for (int i=2; i<=6; i++) {
- line = pci_info[i];
- line.remove(QRegExp("[^:]*:[ ]*"));
- switch (i){
- case 2: dri_info.vendor = line; break;
- case 3: dri_info.device = line; break;
- case 4: dri_info.subvendor = line; break;
- case 6: dri_info.rev = line; break;
- }
- }
- return true;
- }
- }
+ if (line.isEmpty())
+ return false;
+ dri_info.module = line.mid(0, line.indexOf(0x20));
+
+ // possible formats, for regression testing
+ // line = " PCI:01:00:0";
+ // line = " pci:0000:01:00.0"
+ QRegExp rx = QRegExp("\\b[Pp][Cc][Ii][:]([0-9a-fA-F]+[:])?([0-9a-fA-F]+[:][0-9a-fA-F]+[:.][0-9a-fA-F]+)\\b");
+ if (rx.indexIn(line)>0) {
+ dri_info.pci = rx.cap(2);
+ int end = dri_info.pci.lastIndexOf(':');
+ int end2 = dri_info.pci.lastIndexOf('.');
+ if (end2>end) end=end2;
+ dri_info.pci[end]='.';
+ return true;
+ }
+ return false;
+}
+
+static bool get_dri_device()
+{
+ if (!get_drm_device_sysfs() && !get_dri_device_proc())
+ return false;
+
+ QString cmd = QStringLiteral("lspci -m -v -s ") + dri_info.pci;
+ QStringList pci_info;
+ int num;
+ if (((num = ReadPipe(cmd, pci_info)) ||
+ (num = ReadPipe("/sbin/"+cmd, pci_info)) ||
+ (num = ReadPipe("/usr/sbin/"+cmd, pci_info)) ||
+ (num = ReadPipe("/usr/local/sbin/"+cmd, pci_info))) && num>=7) {
+ QString line;
+ for (int i=2; i<=6; i++) {
+ line = pci_info[i];
+ line.remove(QRegExp("[^:]*:[ ]*"));
+ switch (i){
+ case 2: dri_info.vendor = line; break;
+ case 3: dri_info.device = line; break;
+ case 4: dri_info.subvendor = line; break;
+ case 6: dri_info.rev = line; break;
+ }
+ }
+ return true;
}
return false;
@@ -958,6 +1002,7 @@ bool GetInfo_OpenGL(QTreeWidget *treeWidget)
}
if (isWayland) {
+ IsDirect = true;
l1->setText(0, i18n("Name of the Display"));
l1->setText(1, qgetenv("WAYLAND_DISPLAY"));
l1->setExpanded(true);
--
cgit v0.11.2

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue May 8 15:09:52 UTC 2018 - wbauer@tmo.at
- Add kcm_opengl-Fix-retrieval-of-DRI-information.patch to fix
displaying 3D acceleration info and kernel module in "OpenGL"
with kernels >= 3.12
------------------------------------------------------------------- -------------------------------------------------------------------
Wed May 2 09:06:46 CEST 2018 - fabian@ritter-vogt.de Wed May 2 09:06:46 CEST 2018 - fabian@ritter-vogt.de

View File

@ -33,6 +33,8 @@ Url: http://www.kde.org/
Source: http://download.kde.org/stable/plasma/%{version}/kinfocenter-%{version}.tar.xz Source: http://download.kde.org/stable/plasma/%{version}/kinfocenter-%{version}.tar.xz
# PATCH-FIX-OPENSUSE plasma-session-name.patch # PATCH-FIX-OPENSUSE plasma-session-name.patch
Patch0: plasma-session-name.patch Patch0: plasma-session-name.patch
# PATCH-FIX-UPSTREAM
Patch1: kcm_opengl-Fix-retrieval-of-DRI-information.patch
BuildRequires: extra-cmake-modules >= 1.2.0 BuildRequires: extra-cmake-modules >= 1.2.0
BuildRequires: kf5-filesystem BuildRequires: kf5-filesystem
BuildRequires: libraw1394-devel BuildRequires: libraw1394-devel
@ -83,7 +85,7 @@ KDE Utility that provides information about a computer system.
%lang_package %lang_package
%prep %prep
%setup -q -n kinfocenter-%{version} %setup -q -n kinfocenter-%{version}
%patch0 -p1 %autopatch -p1
%build %build
%cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=%{_kf5_localedir} %cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=%{_kf5_localedir}