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
5656bool 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 ;
0 commit comments