Skip to content

Commit a45de1e

Browse files
GongHeng2017deepin-bot[bot]
authored andcommitted
Fix: The monitor's screen size is incorrect.
-- For some monitors, detailed size information is not recorded in the EDID file; in such cases, obtaining the basic size information is sufficient. -- Therefore, remove the logic that retrieves the detailed size information again. Log: fix issue Bug: https://pms.uniontech.com/bug-view-354275.html
1 parent 0769ab6 commit a45de1e

2 files changed

Lines changed: 22 additions & 30 deletions

File tree

deepin-devicemanager/src/Tool/EDIDParser.cpp

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -55,20 +55,16 @@ EDIDParser::EDIDParser()
5555

5656
bool EDIDParser::setEdid(const QString &edid, QString &errorMsg, const QString &ch, bool littleEndianMode)
5757
{
58-
qCDebug(appLog) << "Setting EDID data. Little endian mode:" << littleEndianMode;
59-
6058
m_LittleEndianMode = littleEndianMode;
6159
// 判断是否是合理的edid
6260
if (m_LittleEndianMode) {
6361
if (!edid.startsWith("00ffffffffffff00")) {
64-
errorMsg = "Error edid info";
65-
qCWarning(appLog) << "Invalid EDID header in little endian mode";
62+
errorMsg = "Error edid info in little endian mode!";
6663
return false;
6764
}
6865
} else {
6966
if (!edid.startsWith("ff00ffffffff00ff")) {
70-
errorMsg = "Error edid info";
71-
qCWarning(appLog) << "Invalid EDID header in big endian mode";
67+
errorMsg = "Error edid info in big endian mode!";
7268
return false;
7369
}
7470
}
@@ -208,14 +204,21 @@ void EDIDParser::parseScreenSize()
208204
{
209205
qCDebug(appLog) << "Parsing screen size from EDID";
210206

211-
//Detailed Timing
212-
if(m_LittleEndianMode){
213-
QString tmpw = getBytes(4,2);
214-
QString tmph = getBytes(4,3);
215-
QString tmpshl = getBytes(4,4);
216-
m_Width = hexToDec(tmpshl.mid(0,1) + tmpw).toInt();
217-
m_Height = hexToDec(tmpshl.mid(1,1) + tmph).toInt();
218-
qCDebug(appLog) << "Parsed width and height from detailed timing:" << m_Width << "x" << m_Height;
207+
//Detailed Timing: 字节66-68 (第4行字节2-4)包含详细屏幕尺寸信息
208+
// 字节66: Active Image Width低8位
209+
// 字节67: Active Image Height低8位
210+
// 字节68: 高4位(0xF0)=宽度高4位, 低4位(0x0F)=高度高4位
211+
// 注意:大端模式下,字节位置会交换:byte 2<->3, byte 4->5
212+
QString s66 = getBytes(4, m_LittleEndianMode ? 2 : 3), // 宽度低8位
213+
s67 = getBytes(4, m_LittleEndianMode ? 3 : 2), // 高度低8位
214+
s68 = getBytes(4, m_LittleEndianMode ? 4 : 5); // [宽度高4位|高度高4位]
215+
216+
if (!s66.isEmpty() && !s67.isEmpty() && !s68.isEmpty()) {
217+
int byte68_val = hexToDec(s68).toInt();
218+
// 宽度 = (byte68高4位 << 8) + s66
219+
m_Width = ((byte68_val & 0xF0) << 4) + hexToDec(s66).toInt();
220+
// 高度 = (byte68低4位 << 8) + s67
221+
m_Height = ((byte68_val & 0x0F) << 8) + hexToDec(s67).toInt();
219222
}
220223

221224
// edid中的 15H和16H就是屏幕大小 , 与Detailed Timing相差超10mm 则用15H和16H的。
@@ -228,20 +231,6 @@ void EDIDParser::parseScreenSize()
228231
m_Height = height16;
229232
}
230233

231-
QString s66 = getBytes(4, m_LittleEndianMode ? 2 : 3),
232-
s67 = getBytes(4, m_LittleEndianMode ? 3 : 2),
233-
s68 = getBytes(4, m_LittleEndianMode ? 4 : 5);
234-
235-
if (!s66.isEmpty() && !s67.isEmpty() && !s68.isEmpty()) {
236-
int width_mm = hexToDec(s66).toInt() + ((hexToDec(s68).toInt() & 0xF0) << 4);
237-
int height_mm = hexToDec(s67).toInt() + ((hexToDec(s68).toInt() & 0x0F) << 8);
238-
239-
if (width_mm > 0 && height_mm > 0) {
240-
m_Width = width_mm;
241-
m_Height = height_mm;
242-
}
243-
}
244-
245234
if (Common::specialComType == Common::kSpecialType7){ // sepcial task:378963
246235
m_Width = 296;
247236
m_Height = 197;

deepin-devicemanager/src/Tool/commontools.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ void CommonTools::parseEDID(const QStringList &allEDIDS, const QString &input, b
263263
if (lines.size() > 3){
264264
EDIDParser edidParser;
265265
QString errorMsg;
266-
edidParser.setEdid(edidStr,errorMsg,"\n", isHW ? false : true);
266+
if (!edidParser.setEdid(edidStr,errorMsg,"\n", isHW ? false : true)) {
267+
qCWarning(appLog) << errorMsg;
268+
continue;
269+
}
267270

268271
QMap<QString, QString> mapInfo;
269272
mapInfo.insert("Vendor",edidParser.vendor());

0 commit comments

Comments
 (0)