diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs index 4fb1282..75184f9 100644 --- a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/FormISP_MSI.cs @@ -42,6 +42,10 @@ namespace WinISP private string _chipName = String.Empty; private string _u8ChipName = String.Empty; private string _u8BoardName = String.Empty; + private string _monitorModelName = String.Empty; + private string _monitorChipName = String.Empty; + private string _monitorPanelName = String.Empty; + private string _monitorBoardName = String.Empty; private bool _IsRunISP = false; ISimI2CCtrl _simI2cCtrl; private bool _IsHDMIConnect = false; @@ -51,6 +55,15 @@ namespace WinISP private Byte _clientType = 0; private const int WM_DEVICECHANGE = 0x219; private const int DBT_DEVNODES_CHANGED = 0x07; + private const byte MStarCommand = 0xCC; + private const byte CmdGetModelName = 0x36; + private const byte CmdGetChipName = 0x41; + private const byte CmdGetPanelName = 0x42; + private const byte CmdGetBoardName = 0x45; + private const int MonitorModelNameLength = 20; + private const int MonitorChipNameLength = 20; + private const int MonitorPanelNameLength = 30; + private const int MonitorBoardNameLength = 20; object _lockObj = new object(); int _numberOfMonitors; int _lastNumOfMonitors = 0; @@ -257,30 +270,47 @@ namespace WinISP } } - // 判断u8ModelName和MODEL_NAME_STRING是否一致 + private static string NormalizeMonitorInfo(string value) + { + return String.IsNullOrWhiteSpace(value) ? String.Empty : value.Trim(); + } + private bool IsModelNameMatch(string u8Model_Name) { - const string MODEL_NAME_STRING = "MAG 321UPD E14"; - return string.Equals(MODEL_NAME_STRING, u8Model_Name, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorModelName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Model_Name), StringComparison.Ordinal); } private bool IsChipNameMatch(string u8Chi_pName) { - const string ChipName_STRING = "MST9U"; - return string.Equals(ChipName_STRING, u8Chi_pName, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorChipName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Chi_pName), StringComparison.Ordinal); } private bool IsPanelNameMatch(string u8Panel_Name) { - const string PanelName_STRING = "Panel_SG315GD01_2_eDP"; - return string.Equals(PanelName_STRING, u8Panel_Name, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorPanelName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Panel_Name), StringComparison.Ordinal); } private bool IsBoardNameMatch(string u8Board_Name) { - const string BoardName_STRING = "FW.010"; - if (u8Board_Name[0] == 'F' && u8Board_Name[1] == 'W' && u8Board_Name[2] == '.' && u8Board_Name[3] == '0') - { - return true; - } - return false; + string monitorValue = NormalizeMonitorInfo(_monitorBoardName); + string binValue = NormalizeMonitorInfo(u8Board_Name); + + if (!String.IsNullOrEmpty(monitorValue)) + return string.Equals(monitorValue, binValue, StringComparison.Ordinal); + + if (binValue.Length < 4) + return false; + + return binValue[0] == 'F' && binValue[1] == 'W' && binValue[2] == '.' && binValue[3] == '0'; } private void btnLoadFile_Click(object sender, EventArgs e) @@ -331,6 +361,69 @@ namespace WinISP } } + private void QueryConnectedMonitorInfo() + { + // 读取显示器端信息(芯片名、面板名、板卡名、型号名) + try + { + // 型号名 + { + Byte[] cmd = { MStarCommand, CmdGetModelName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorModelNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorModelNameLength + 2) + _monitorModelName = Encoding.ASCII.GetString(recv, 2, MonitorModelNameLength).TrimEnd('\0'); + else + _monitorModelName = string.Empty; + } + + // 芯片名 + { + Byte[] cmd = { MStarCommand, CmdGetChipName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorChipNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorChipNameLength + 2) + _monitorChipName = Encoding.ASCII.GetString(recv, 2, MonitorChipNameLength).TrimEnd('\0'); + else + _monitorChipName = string.Empty; + } + // 面板名 + { + Byte[] cmd = { MStarCommand, CmdGetPanelName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorPanelNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorPanelNameLength + 2) + _monitorPanelName = Encoding.ASCII.GetString(recv, 2, MonitorPanelNameLength).TrimEnd('\0'); + else + _monitorPanelName = string.Empty; + } + // 板卡名 + { + Byte[] cmd = { MStarCommand, CmdGetBoardName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorBoardNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorBoardNameLength + 2) + _monitorBoardName = Encoding.ASCII.GetString(recv, 2, MonitorBoardNameLength).TrimEnd('\0'); + else + _monitorBoardName = string.Empty; + } + + // 日志打印 + frmISP.WriteLog($"MonitorModelName={_monitorModelName}", "debug"); + frmISP.WriteLog($"MonitorChipName={_monitorChipName}", "debug"); + frmISP.WriteLog($"MonitorPanelName={_monitorPanelName}", "debug"); + frmISP.WriteLog($"MonitorBoardName={_monitorBoardName}", "debug"); + } + catch (Exception ex) + { + frmISP.WriteLog("QueryConnectedMonitorInfo Exception: " + ex.Message, "debug"); + } + } + + private void ClearConnectedMonitorInfo() + { + _monitorModelName = string.Empty; + _monitorChipName = string.Empty; + _monitorPanelName = string.Empty; + _monitorBoardName = string.Empty; + } + void Connect(int delayTime = 0) { SetStatusMsg("Connect MTK Monitor..."); @@ -395,12 +488,15 @@ namespace WinISP break; } } + // 自动读取显示器信息 + QueryConnectedMonitorInfo(); } if (IsConnect == false) { frmISP.WriteLog("IsConnect = false", "debug"); btnAuto.Enabled = false; + ClearConnectedMonitorInfo(); SetStatusMsg("Current F/W version is not compatible with this tool.", true); } _chipType = chipType; @@ -1153,6 +1249,8 @@ namespace WinISP } } + QueryConnectedMonitorInfo(); + prbProgress.Maximum = flashSectorInfo.Count; prbProgress.Value = 0; int imgNum = 0; diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs index 88fdb80..01a1832 100644 --- a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs @@ -39,6 +39,10 @@ namespace WinISP private string _chipName = String.Empty; private string _u8ChipName = String.Empty; private string _u8BoardName = String.Empty; + private string _monitorModelName = String.Empty; + private string _monitorChipName = String.Empty; + private string _monitorPanelName = String.Empty; + private string _monitorBoardName = String.Empty; private bool _IsRunISP = false; ISimI2CCtrl _simI2cCtrl; private bool _IsHDMIConnect = false; @@ -48,6 +52,15 @@ namespace WinISP private Byte _clientType = 0; private const int WM_DEVICECHANGE = 0x219; private const int DBT_DEVNODES_CHANGED = 0x07; + private const byte MStarCommand = 0xCC; + private const byte CmdGetModelName = 0x36; + private const byte CmdGetChipName = 0x41; + private const byte CmdGetPanelName = 0x42; + private const byte CmdGetBoardName = 0x45; + private const int MonitorModelNameLength = 20; + private const int MonitorChipNameLength = 20; + private const int MonitorPanelNameLength = 30; + private const int MonitorBoardNameLength = 20; object _lockObj = new object(); int _numberOfMonitors; int _lastNumOfMonitors = 0; @@ -243,30 +256,47 @@ namespace WinISP } } - // 判断u8ModelName和MODEL_NAME_STRING是否一致 + private static string NormalizeMonitorInfo(string value) + { + return String.IsNullOrWhiteSpace(value) ? String.Empty : value.Trim(); + } + private bool IsModelNameMatch(string u8Model_Name) { - const string MODEL_NAME_STRING = "MAG 321UPD E14"; - return string.Equals(MODEL_NAME_STRING, u8Model_Name, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorModelName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Model_Name), StringComparison.Ordinal); } private bool IsChipNameMatch(string u8Chi_pName) { - const string ChipName_STRING = "MST9U"; - return string.Equals(ChipName_STRING, u8Chi_pName, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorChipName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Chi_pName), StringComparison.Ordinal); } private bool IsPanelNameMatch(string u8Panel_Name) { - const string PanelName_STRING = "Panel_SG315GD01_2_eDP"; - return string.Equals(PanelName_STRING, u8Panel_Name, StringComparison.Ordinal); + string monitorValue = NormalizeMonitorInfo(_monitorPanelName); + if (String.IsNullOrEmpty(monitorValue)) + return true; + + return string.Equals(monitorValue, NormalizeMonitorInfo(u8Panel_Name), StringComparison.Ordinal); } private bool IsBoardNameMatch(string u8Board_Name) { - const string BoardName_STRING = "FW.010"; - if (u8Board_Name[0] == 'F' && u8Board_Name[1] == 'W'&& u8Board_Name[2] == '.' && u8Board_Name[3] == '0') - { - return true; - } - return false; + string monitorValue = NormalizeMonitorInfo(_monitorBoardName); + string binValue = NormalizeMonitorInfo(u8Board_Name); + + if (!String.IsNullOrEmpty(monitorValue)) + return string.Equals(monitorValue, binValue, StringComparison.Ordinal); + + if (binValue.Length < 4) + return false; + + return binValue[0] == 'F' && binValue[1] == 'W' && binValue[2] == '.' && binValue[3] == '0'; } private void btnOpenBin_Click(object sender, EventArgs e) { @@ -320,6 +350,69 @@ namespace WinISP WinIOLib._dftI2CDlyTime = Convert.ToInt16(txtDelayUnit.Text); } + private void QueryConnectedMonitorInfo() + { + // 读取显示器端信息(芯片名、面板名、板卡名、型号名) + try + { + // 型号名 + { + Byte[] cmd = { MStarCommand, CmdGetModelName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorModelNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorModelNameLength + 2) + _monitorModelName = Encoding.ASCII.GetString(recv, 2, MonitorModelNameLength).TrimEnd('\0'); + else + _monitorModelName = string.Empty; + } + + // 芯片名 + { + Byte[] cmd = { MStarCommand, CmdGetChipName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorChipNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorChipNameLength + 2) + _monitorChipName = Encoding.ASCII.GetString(recv, 2, MonitorChipNameLength).TrimEnd('\0'); + else + _monitorChipName = string.Empty; + } + // 面板名 + { + Byte[] cmd = { MStarCommand, CmdGetPanelName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorPanelNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorPanelNameLength + 2) + _monitorPanelName = Encoding.ASCII.GetString(recv, 2, MonitorPanelNameLength).TrimEnd('\0'); + else + _monitorPanelName = string.Empty; + } + // 板卡名 + { + Byte[] cmd = { MStarCommand, CmdGetBoardName }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd, MonitorBoardNameLength + 2, 500); + if (recv != null && recv.Length >= MonitorBoardNameLength + 2) + _monitorBoardName = Encoding.ASCII.GetString(recv, 2, MonitorBoardNameLength).TrimEnd('\0'); + else + _monitorBoardName = string.Empty; + } + + // 日志打印 + WriteLog($"MonitorModelName={_monitorModelName}", "debug"); + WriteLog($"MonitorChipName={_monitorChipName}", "debug"); + WriteLog($"MonitorPanelName={_monitorPanelName}", "debug"); + WriteLog($"MonitorBoardName={_monitorBoardName}", "debug"); + } + catch (Exception ex) + { + WriteLog("QueryConnectedMonitorInfo Exception: " + ex.Message, "debug"); + } + } + + private void ClearConnectedMonitorInfo() + { + _monitorModelName = string.Empty; + _monitorChipName = string.Empty; + _monitorPanelName = string.Empty; + _monitorBoardName = string.Empty; + } + void Connect(int delayTime = 0) { SetStatusMsg("Connect MTK Monitor..."); @@ -397,6 +490,8 @@ namespace WinISP break; } } + // 自动读取显示器信息 + QueryConnectedMonitorInfo(); cboConnectedMonitor.SelectedIndexChanged += cboConnectedMonitor_SelectedIndexChanged; cboConnectedMonitor.Enabled = true; } @@ -407,6 +502,7 @@ namespace WinISP cboConnectedMonitor.Enabled = false; btnRunDPISP.Enabled = false; pnlConnState.BackColor = Color.Red; + ClearConnectedMonitorInfo(); SetStatusMsg("Current F/W version is not compatible with this tool.", true); } _chipType = chipType; @@ -1167,6 +1263,8 @@ namespace WinISP } } + QueryConnectedMonitorInfo(); + toolStripProgressBar1.Maximum = flashSectorInfo.Count; toolStripProgressBar1.Value = 0; int imgNum = 0; @@ -1623,11 +1721,13 @@ namespace WinISP if (IsConnect == true) { pnlConnState.BackColor = Color.LightGreen; + QueryConnectedMonitorInfo(); } else { pnlConnState.BackColor = Color.Red; _chipType = 0; + ClearConnectedMonitorInfo(); } _chipType = chipType;