Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

// 项目自身文件
#include "DeviceGpu.h"
#include "commonfunction.h"

Check warning on line 7 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.

// Qt库文件
#include<QLoggingCategory>
#include <QLoggingCategory>

Check warning on line 10 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDir>

Check warning on line 11 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDir> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DeviceGpu::DeviceGpu()
: DeviceBaseInfo()
Expand Down Expand Up @@ -187,6 +188,36 @@
}
}
}

// 砺算显卡显存适配
if (m_GraphicsMemory.isEmpty()) {
QString pciBdf = m_SysPath.section('/', -1);
if (!pciBdf.isEmpty()) {
QDir drmDir("/sys/class/drm");
QStringList cards = drmDir.entryList(QStringList() << "card[0-9]*", QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QString &card, cards) {
if (card.contains('-'))
continue;
QString devicePath = QFile::symLinkTarget(QString("/sys/class/drm/%1/device").arg(card));
if (!devicePath.contains(pciBdf))
continue;
QFile memFile(QString("/sys/class/drm/%1/device/vram_size").arg(card));
if (memFile.open(QIODevice::ReadOnly)) {
QString memStr = memFile.readAll().trimmed();
memFile.close();
bool ok;
quint64 vramMB = memStr.toULongLong(&ok);
if (ok && vramMB >= 1024) {
m_GraphicsMemory = QString::number(vramMB / 1024) + "GB";
} else {
m_GraphicsMemory = QString::number(vramMB) + "MB";
Comment thread
GongHeng2017 marked this conversation as resolved.
Resolved
}
break;
}
}
}
}

QString jjwFile = "/proc/gpuinfo_0";
if (m_VID_PID.contains("0731") && QFile::exists(jjwFile)) {
QFile file(jjwFile);
Expand Down
Loading