SHA256
1
0
forked from pool/kinfocenter5
Luca Beltrame 2018-05-21 09:07:10 +00:00 committed by Git OBS Bridge
parent 78da231f7a
commit ada9ed13db
5 changed files with 31 additions and 195 deletions

View File

@ -1,183 +0,0 @@
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 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65190f1ca25960c08367c4be52608b43d98a26d4f016bfdfcee44997c88482bc
size 1270224

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:30d696eafecf513bd3e260198e0d34e2733e83a7e3834deee1b3ca57307070b4
size 1277604

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Sat May 19 14:16:35 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.12.90
* New feature release
* For more details please see:
* https://www.kde.org/announcements/plasma-5.12.90.php
- Changes since 5.12.5:
* kcm_opengl: Fix retrieval of DRI information
* kcm_opengl: Fix EGL info retrieval.
* Fix displaying OpenGL info on wayland: do not require OpenGL 3.2
* Update kinfocenter docbook to 5.12
* [Device Viewer] Add battery percentage bar
* [Device Viewer] Add missing Solid battery types
* Remove unused X-Plasma-RemoteLocation entries
* Remove not necessary QtCore and co
* Remove long-time deprecated Encoding=UTF-8 from desktop format files
* Show high-resolution and vector logos properly in HighDPI mode (kde#388633)
* Don't use const'ref for int element
* Remove unused definition
- Remove patches, now upstream:
* kcm_opengl-Fix-retrieval-of-DRI-information.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Tue May 8 15:09:52 UTC 2018 - wbauer@tmo.at Tue May 8 15:09:52 UTC 2018 - wbauer@tmo.at

View File

@ -16,11 +16,11 @@
# #
%global kf5_version 5.9.0 %global kf5_version 5.45.0
%bcond_without lang %bcond_without lang
Name: kinfocenter5 Name: kinfocenter5
Version: 5.12.5 Version: 5.12.90
Release: 0 Release: 0
# Full Plasma 5 version (e.g. 5.8.95) # Full Plasma 5 version (e.g. 5.8.95)
%{!?_plasma5_bugfix: %global _plasma5_bugfix %{version}} %{!?_plasma5_bugfix: %global _plasma5_bugfix %{version}}
@ -30,11 +30,9 @@ Summary: Utility that provides information about a computer system
License: GPL-2.0+ License: GPL-2.0+
Group: System/GUI/KDE Group: System/GUI/KDE
Url: http://www.kde.org/ Url: http://www.kde.org/
Source: http://download.kde.org/stable/plasma/%{version}/kinfocenter-%{version}.tar.xz Source: http://download.kde.org/unstable/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
@ -77,7 +75,6 @@ Recommends: %{name}-lang
%endif %endif
# needed for the fileindexermonitor # needed for the fileindexermonitor
Requires: baloo5-imports Requires: baloo5-imports
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description %description
KDE Utility that provides information about a computer system. KDE Utility that provides information about a computer system.
@ -85,7 +82,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}
%autopatch -p1 %patch0 -p1
%build %build
%cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=%{_kf5_localedir} %cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=%{_kf5_localedir}
@ -99,8 +96,7 @@ KDE Utility that provides information about a computer system.
%endif %endif
%files %files
%defattr(-,root,root) %license COPYING*
%doc COPYING*
%{_kf5_bindir}/kinfocenter %{_kf5_bindir}/kinfocenter
%{_kf5_plugindir}/ %{_kf5_plugindir}/
%{_kf5_applicationsdir}/org.kde.kinfocenter.desktop %{_kf5_applicationsdir}/org.kde.kinfocenter.desktop