diff --git a/deepin-devicemanager/assets/org.deepin.devicemanager.json b/deepin-devicemanager/assets/org.deepin.devicemanager.json index 423f32cb..0b7b67ff 100644 --- a/deepin-devicemanager/assets/org.deepin.devicemanager.json +++ b/deepin-devicemanager/assets/org.deepin.devicemanager.json @@ -35,6 +35,16 @@ "permissions": "readwrite", "visibility": "private" }, + "specialVRAMType": { + "value": 0, + "serial": 0, + "flags": ["global"], + "name": "Special VRAM Type", + "name[zh_CN]": "定制VRAM类型", + "description": "Special VRAM Type: VRAM type(value:0)", + "permissions": "readwrite", + "visibility": "private" + }, "TomlFilesName": { "value": "tomlFilesName", "serial": 0, diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp index e4d7d160..f200338b 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -425,7 +425,21 @@ void CmdTool::loadDmesgInfo(const QString &debugfile) // 获取显存大小信息 QMap mapInfo; QStringList lines = deviceInfo.split("\n"); + const bool isSpecialVRAM = Common::curVRAMType == Common::kSpecialVRAMType1; + bool hasCustomVRAMSize = false; + QRegExp regCustom(".*([0-9a-z]{4}:[0-9a-z]{2}:[0-9a-z]{2}\\.[0-9]{1}):.*Video RAM[^0-9]*([0-9]+)[\\s]{0,1}M.*"); foreach (const QString &line, lines) { + if (isSpecialVRAM && regCustom.exactMatch(line)) { + double size = regCustom.cap(2).toDouble(); + QString sizeS = QString("%1GB").arg(size / 1024); + mapInfo["Size"] = regCustom.cap(1) + "=" + sizeS; + hasCustomVRAMSize = true; + continue; + } + + if (hasCustomVRAMSize) + continue; + // DeviceCdrom m_HwinfoToLshw 值为0000:01:00.0 此处同步修改,否则显存大小无法显示 QRegExp reg(".*([0-9a-z]{4}:[0-9a-z]{2}:[0-9a-z]{2}.[0-9]{1}):.*VRAM([=:]{1}) ([0-9]*)[\\s]{0,1}M.*"); if (reg.exactMatch(line)) { diff --git a/deepin-devicemanager/src/commonfunction.cpp b/deepin-devicemanager/src/commonfunction.cpp index fde58a34..fe3da582 100644 --- a/deepin-devicemanager/src/commonfunction.cpp +++ b/deepin-devicemanager/src/commonfunction.cpp @@ -37,6 +37,7 @@ static bool initBoardVendorFlag = false; static QString boardVendorKey = ""; int Common::specialComType = -1; Common::SpecialCpuType Common::curCpuType = Common::SpecialCpuType::kUnknowCpuType; +Common::SpecialVRAMType Common::curVRAMType = Common::SpecialVRAMType::kNormalVRAMType; static QString tomlFilesName = "tomlFilesName"; QString Common::getArch() { diff --git a/deepin-devicemanager/src/commonfunction.h b/deepin-devicemanager/src/commonfunction.h index fb82adea..0f89b37c 100644 --- a/deepin-devicemanager/src/commonfunction.h +++ b/deepin-devicemanager/src/commonfunction.h @@ -34,6 +34,12 @@ class Common kSpecialCpuType1 }; + enum SpecialVRAMType { + kNormalVRAMType = 0, + kSpecialVRAMType1, + kSpecialVRAMTypeMax + }; + static QString getArch(); static QString getArchStore(); @@ -53,6 +59,7 @@ class Common */ static int specialComType; static SpecialCpuType curCpuType; + static SpecialVRAMType curVRAMType; static QByteArray executeClientCmd(const QString& cmd, const QStringList& args = QStringList(), const QString& workPath = QString(), int msecsWaiting = 30000); diff --git a/deepin-devicemanager/src/main.cpp b/deepin-devicemanager/src/main.cpp index 38cd50f0..be361317 100644 --- a/deepin-devicemanager/src/main.cpp +++ b/deepin-devicemanager/src/main.cpp @@ -124,6 +124,13 @@ int main(int argc, char *argv[]) } if (dconfig->keyList().contains("specialCpuType")) Common::curCpuType = static_cast(dconfig->value("specialCpuType").toInt()); + if (dconfig->keyList().contains("specialVRAMType")) { + const int vramTypeValue = dconfig->value("specialVRAMType").toInt(); + if (vramTypeValue >= Common::kNormalVRAMType && vramTypeValue < Common::kSpecialVRAMTypeMax) + Common::curVRAMType = static_cast(vramTypeValue); + else + Common::curVRAMType = Common::kNormalVRAMType; + } } // 特殊机型,提前缓存GPU信息