diff --git a/MSI DP升级工具开发文档.docx b/MSI DP升级工具开发文档.docx new file mode 100644 index 0000000..c549cb1 Binary files /dev/null and b/MSI DP升级工具开发文档.docx differ diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/CodeChunks.db b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/CodeChunks.db new file mode 100644 index 0000000..56a03b1 Binary files /dev/null and b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/CodeChunks.db differ diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/SemanticSymbols.db b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/SemanticSymbols.db new file mode 100644 index 0000000..0e22912 Binary files /dev/null and b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/CopilotIndices/17.14.1641.39856/SemanticSymbols.db differ diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/FileContentIndex/ea43bdbe-c220-4cc9-8d92-cecafd5f111b.vsidx b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/FileContentIndex/ea43bdbe-c220-4cc9-8d92-cecafd5f111b.vsidx new file mode 100644 index 0000000..acfef2c Binary files /dev/null and b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/FileContentIndex/ea43bdbe-c220-4cc9-8d92-cecafd5f111b.vsidx differ diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.backup.json b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.backup.json new file mode 100644 index 0000000..acba1b3 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.backup.json @@ -0,0 +1,94 @@ +{ + "Version": 1, + "WorkspaceRootPath": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|d:\\code\\c#\\msi\\dp\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\win10_winisp_srccode_for_moka_20250416_1\\winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form" + }, + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\winisp\\baseclass\\graphiccardi2cctrl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\baseclass\\graphiccardi2cctrl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 7, + "Children": [ + { + "$type": "Bookmark", + "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + }, + { + "$type": "Bookmark", + "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + }, + { + "$type": "Bookmark", + "Name": "ST:129:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:130:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + }, + { + "$type": "Bookmark", + "Name": "ST:0:0:{6324226f-61b6-4f28-92ee-18d4b5fe1e48}" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "GraphicCardI2CCtrl.cs", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "RelativeDocumentMoniker": "WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "RelativeToolTip": "WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "ViewState": "AgIAAEIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:59:00.721Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "frmISP.cs [\u8BBE\u8BA1]", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs", + "RelativeDocumentMoniker": "WinISP\\frmISP.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs [\u8BBE\u8BA1]*", + "RelativeToolTip": "WinISP\\frmISP.cs [\u8BBE\u8BA1]*", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:57:00.325Z", + "EditorCaption": " [\u8BBE\u8BA1]" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "frmISP.cs", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs", + "RelativeDocumentMoniker": "WinISP\\frmISP.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs*", + "RelativeToolTip": "WinISP\\frmISP.cs*", + "ViewState": "AgIAAKIGAAAAAAAAAAAswKwGAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:52:33.123Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.json b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.json new file mode 100644 index 0000000..23d5806 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vs/WinISP/v17/DocumentLayout.json @@ -0,0 +1,94 @@ +{ + "Version": 1, + "WorkspaceRootPath": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|d:\\code\\c#\\msi\\dp\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\win10_winisp_srccode_for_moka_20250416_1\\winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form" + }, + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\frmisp.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\winisp\\baseclass\\graphiccardi2cctrl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}|WinISP\\WinISP.csproj|solutionrelative:winisp\\baseclass\\graphiccardi2cctrl.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 7, + "Children": [ + { + "$type": "Bookmark", + "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + }, + { + "$type": "Bookmark", + "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + }, + { + "$type": "Bookmark", + "Name": "ST:129:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:130:0:{1fc202d4-d401-403c-9834-5b218574bb67}" + }, + { + "$type": "Bookmark", + "Name": "ST:130:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" + }, + { + "$type": "Bookmark", + "Name": "ST:0:0:{6324226f-61b6-4f28-92ee-18d4b5fe1e48}" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "GraphicCardI2CCtrl.cs", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "RelativeDocumentMoniker": "WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "RelativeToolTip": "WinISP\\BaseClass\\GraphicCardI2CCtrl.cs", + "ViewState": "AgIAAEIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:59:00.721Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "frmISP.cs [\u8BBE\u8BA1]", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs", + "RelativeDocumentMoniker": "WinISP\\frmISP.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs [\u8BBE\u8BA1]", + "RelativeToolTip": "WinISP\\frmISP.cs [\u8BBE\u8BA1]", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:57:00.325Z", + "EditorCaption": " [\u8BBE\u8BA1]" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "frmISP.cs", + "DocumentMoniker": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs", + "RelativeDocumentMoniker": "WinISP\\frmISP.cs", + "ToolTip": "D:\\Code\\C#\\MSI\\DP\u5347\u7EA7\u5F00\u53D1\u8D44\u6599\\WIN10_WinISP_SrcCode_For_MOKA_20250416_1\\WinISP\\frmISP.cs", + "RelativeToolTip": "WinISP\\frmISP.cs", + "ViewState": "AgIAAKIGAAAAAAAAAAAswKwGAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2026-04-10T03:52:33.123Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/launch.json b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/launch.json new file mode 100644 index 0000000..c7b50b1 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch WinISP (.NET Framework)", + "type": "clr", + "request": "launch", + "program": "${workspaceFolder}/WinISP/bin/Debug/WinISP.exe", + "cwd": "${workspaceFolder}/WinISP", + "preLaunchTask": "build WinISP" + } + ] +} \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/settings.json b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/settings.json new file mode 100644 index 0000000..013007b --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.preferCSharpExtension": true +} \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/tasks.json b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/tasks.json new file mode 100644 index 0000000..38815cc --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/.vscode/tasks.json @@ -0,0 +1,26 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build WinISP", + "type": "shell", + "command": "dotnet", + "args": [ + "build", + "${workspaceFolder}/WinISP/WinISP.csproj" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "run WinISP exe", + "type": "shell", + "command": "${workspaceFolder}/WinISP/bin/Debug/WinISP.exe", + "dependsOn": "build WinISP", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP.sln b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP.sln new file mode 100644 index 0000000..4fb6caf --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP.sln @@ -0,0 +1,56 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinISP", "WinISP\WinISP.csproj", "{033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_x64|Any CPU = Debug_x64|Any CPU + Debug_x64|Mixed Platforms = Debug_x64|Mixed Platforms + Debug_x64|Win32 = Debug_x64|Win32 + Debug_x64|x64 = Debug_x64|x64 + Debug_x64|x86 = Debug_x64|x86 + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Any CPU.ActiveCfg = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Any CPU.Build.0 = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Mixed Platforms.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Mixed Platforms.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Win32.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|Win32.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|x64.ActiveCfg = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|x86.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug_x64|x86.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Win32.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|Win32.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|x64.ActiveCfg = Debug|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|x86.ActiveCfg = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Debug|x86.Build.0 = Debug|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Any CPU.Build.0 = Release|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Win32.ActiveCfg = Release|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|Win32.Build.0 = Release|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|x64.ActiveCfg = Release|Any CPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|x86.ActiveCfg = Release|x86 + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/GraphicCardI2CCtrl.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/GraphicCardI2CCtrl.cs new file mode 100644 index 0000000..053a1a0 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/GraphicCardI2CCtrl.cs @@ -0,0 +1,322 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using MTK; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace WinISP.BaseClass +{ + + public class GraphicCardI2CCtrl : ISimI2CCtrl + { + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate string PCallBack(string strParam); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern void SetCallBack([MarshalAs(UnmanagedType.FunctionPtr)] PCallBack pCallBack); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static public extern IntPtr CreateGraphicCardCtrl(); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static public extern IntPtr CreateGraphicCardCtrl(int GraphicCardType); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static public extern void DisposeGraphicCardCtrl(); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern bool InitGraphicCardCtrl(IntPtr pGraphicCardCtrlObj); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static private extern int DllGetGraphicCardType(IntPtr pGraphicCardCtrlObj); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static public extern int GetPortType(IntPtr pGraphicCardCtrlObj); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + static public extern int GetPortType(IntPtr pGraphicCardCtrlObj, byte idx); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern bool DllGetMonitorName(IntPtr pGraphicCardCtrlObj, byte[] name); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern bool DDCRead(IntPtr pGraphicCardCtrlObj, byte slaveAddr, uint rdLen, byte[] rdBuf); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern bool DDCWrite(IntPtr pGraphicCardCtrlObj, byte slaveAddr, uint wrLen, byte[] wrBuf); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern byte InitConnectedMTKMonitor(IntPtr pGraphicCardCtrlObj); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern void SetConnectedMonitorIndex(IntPtr pGraphicCardCtrlObj, byte idx); + [DllImport("GraphicsCardCtrl.dll", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static public extern void GetMonitorNameByIndex(IntPtr pGraphicCardCtrlObj, byte idx, byte[] pName); + public enum GRAPHIC_CARD + { + INTEL = 0, + AMD = 1, + NVIDIA = 2, + INTEL_IGCL = 3, + NA = 4 + } + public enum PortTypes + { + NA = 0, + HDMI = 1, + DISPALYPORT = 2, + VGA = 3, + DVI = 4 + } + public GRAPHIC_CARD GraphicCardType; + public PortTypes PortType; + private static byte[] MonitorName = new byte[13]; + public enum GPUTypes { AUTO_Search, AMD, NVIDIA, INTEL }; + private GCHandle gch; + private static bool _IsInit = false; + private static IntPtr _hMod; + private static IntPtr pGraphicCardCtrl; + static string CallBackFunction(string strParam) + { + WinISP.frmISP.WriteLog("GraphicCard Msg = " + strParam, "debug"); + return strParam; + } + public void ReCreateGraphicCardCtrl() + { + FreeGraphicsCardCtrl(); + CreateGraphicsCardCtrl(); + } + + private void CreateGraphicsCardCtrl() + { + // Declare an instance of the CallBack delegate. + PCallBack callback_delegate = new PCallBack(CallBackFunction); + // Use GCHandle to hold the delegate object in memory. + gch = GCHandle.Alloc(callback_delegate); + // Invoke the managed callback from unmanaged code. + try + { + SetCallBack(callback_delegate); + } + catch (Exception e) + { + frmISP.WriteLog("Exception: " + e.Message, "debug"); + } + try + { + pGraphicCardCtrl = CreateGraphicCardCtrl(); + if (pGraphicCardCtrl != IntPtr.Zero) + _IsInit = true; + } + catch (Exception e) + { + System.Windows.Forms.MessageBox.Show(e.Message); + } + } + + private void FreeGraphicsCardCtrl() + { + // Free the GCHandle. + frmISP.WriteLog("Free the GCHandle.", "debug"); + if (gch.IsAllocated) + gch.Free(); + DisposeGraphicCardCtrl(); + pGraphicCardCtrl = IntPtr.Zero; + _IsInit = false; + } + + public GraphicCardI2CCtrl() + { + if (_IsInit == true) + return; + CreateGraphicsCardCtrl(); + return; + } + ~GraphicCardI2CCtrl() + { + FreeGraphicsCardCtrl(); + } + public GraphicCardI2CCtrl(GPUTypes type) + { + switch (type) + { + case GPUTypes.AUTO_Search: + pGraphicCardCtrl = CreateGraphicCardCtrl(); + break; + + case GPUTypes.AMD: + pGraphicCardCtrl = CreateGraphicCardCtrl((int)GPUTypes.AMD); + break; + + case GPUTypes.NVIDIA: + pGraphicCardCtrl = CreateGraphicCardCtrl((int)GPUTypes.NVIDIA); + break; + + case GPUTypes.INTEL: + pGraphicCardCtrl = CreateGraphicCardCtrl((int)GPUTypes.INTEL); + break; + } + } + + public Levels SDA + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public Levels SCL + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public bool I2C_Start() + { + return true; + } + + public void I2C_Stop() + { + return; + } + + public byte I2C_RecvByte(bool IsAck) + { + throw new NotImplementedException(); + } + + public bool I2C_SendByte(byte data) + { + throw new NotImplementedException(); + } + + public bool WriteData(byte slvAddr, byte[] arr) + { + + unsafe + { + fixed (Byte* pArr = arr) + { + return DDCWrite(pGraphicCardCtrl, slvAddr, (uint)(arr.Length), arr); + } + } + } + + public byte ReadData(byte slvAddr, byte[] arr) + { + throw new NotImplementedException(); + } + + public bool WriteData(byte[] data) + { + Byte slvAddr = data[0]; + Byte[] wrBuf = new Byte[data.Length - 1]; + Array.Copy(data, 1, wrBuf, 0, wrBuf.Length); + const Byte maxWrLen = 16; + int idx = 0; + unsafe + { + fixed (Byte* pArr = wrBuf) + { + return DDCWrite(pGraphicCardCtrl, slvAddr, (uint)(wrBuf.Length), wrBuf); + } + } + } + + public bool ReadData(byte[] data, byte[] wrCmds = null) + { + uint revlen = (uint)data.Length; + unsafe + { + fixed (Byte* pArr = data) + { + return DDCRead(pGraphicCardCtrl, wrCmds[0], revlen, data); + } + } + } + + public bool Init() + { + if (_IsInit == true) + return true; + else + return InitGraphicCardCtrl(pGraphicCardCtrl); + } + + public GRAPHIC_CARD GetGraphicCardType + { + get + { + GraphicCardType = (GRAPHIC_CARD)DllGetGraphicCardType(pGraphicCardCtrl); + return GraphicCardType; + } + } + + public PortTypes GetConnectedPortType + { + get + { + return PortType; + } + } + + public PortTypes GetConnectedPortTypeByIdx(Byte idx) + { + return (PortTypes)GetPortType(pGraphicCardCtrl, idx); + } + + public String GetMonitorName + { + get + { + return ASCIIEncoding.ASCII.GetString(MonitorName); + } + } + + public List InitConnectedMonitor + { + get + { + //if (Program.isManagedDll) + { + List list = new List(); + Byte[] buf = new Byte[13]; + char[] charsToTrim = { ',', '/', ' ' }; + String mntName; + Byte numOfMnt; + numOfMnt = InitConnectedMTKMonitor(pGraphicCardCtrl); + for (Byte idx = 0; idx < numOfMnt; idx++) + { + unsafe + { + fixed (byte* pBuf = buf) + { + GetMonitorNameByIndex(pGraphicCardCtrl, idx, buf); + } + } + + mntName = ASCIIEncoding.ASCII.GetString(buf); + mntName.Replace("\n", "").Replace("\r", "").Replace("\0", ""); + list.Add(mntName); + } + return list; + } + //else //TBD + // return null; + } + } + + public void SetConnectedMonitorIndex(Byte index) + { + SetConnectedMonitorIndex(pGraphicCardCtrl, index); + } + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/MTKDebugCmd.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/MTKDebugCmd.cs new file mode 100644 index 0000000..835538c --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/MTKDebugCmd.cs @@ -0,0 +1,224 @@ +using System; + +namespace MTK +{ + public static class MTKDebugCmd + { + private const Byte _BIT0 = 0x01; + private const Byte _BIT1 = 0x02; + private const Byte _BIT2 = 0x04; + private const Byte _BIT3 = 0x08; + private const Byte _BIT4 = 0x10; + private const Byte _BIT5 = 0x20; + private const Byte _BIT6 = 0x40; + private const Byte _BIT7 = 0x80; + + private static ISimI2CCtrl _i2cCtrl; + + public static void InitI2CCtrl(ISimI2CCtrl i2cCtrl) + { + _i2cCtrl = i2cCtrl; + } + + public static bool DDC_Write(Byte[] data) + { + //6E-51-Len-Data-chkSum + const Byte dest = 0x6E; + const Byte src = 0x51; + Byte len = (Byte)(data.Length | _BIT7); + Byte chkSum = 0; + Byte[] wrBuf = new Byte[data.Length + 4]; + wrBuf[0] = dest; + wrBuf[1] = src; + wrBuf[2] = len; + Array.Copy(data, 0, wrBuf, 3, data.Length); + + for (int idx = 0; idx < (wrBuf.Length - 1); idx++) + { + chkSum ^= wrBuf[idx]; + } + wrBuf[wrBuf.Length - 1] = chkSum; + + + bool ret = false; + ret = _i2cCtrl.WriteData(wrBuf); + + string strData = ""; + for (int i = 3; i < wrBuf.Length; ++i) + strData += wrBuf[i].ToString("X2") + " "; + + if (ret) + WinISP.frmISP.WriteLog("[Write DDC]" + strData, "debug"); + else + WinISP.frmISP.WriteLog("[Write DDC Fail]" + strData, "debug"); + + return ret; + } + + public static Byte[] DDC_Read(Byte[] data, int recvLen, int delayTime = 1000) + { + string strData = ""; + for (int i = 0; i < data.Length; ++i) + strData += data[i].ToString("X2") + " "; + if (!DDC_Write(data)) + return null; + + WinIOLib.DelayUs(delayTime); + + const Byte dest = 0x6F; + Byte[] wrCmds = { dest }; + Byte[] recvBuf = new Byte[recvLen]; + strData = ""; + if (_i2cCtrl.ReadData(recvBuf, wrCmds) == true) + { + for (int i = 0; i < recvBuf.Length; ++i) + strData += recvBuf[i].ToString("X2") + " "; + + if ((recvBuf[0] != 0x6E) || (recvBuf[1] <= 0x80)) + { + WinISP.frmISP.WriteLog("[Read DDC Fail]" + strData + " I2C Format Error!", "debug"); + return null; + } + else + { + WinISP.frmISP.WriteLog("[Read DDC]" + strData, "debug"); + return recvBuf; + } + } + else + { + for (int i = 0; i < recvBuf.Length; ++i) + strData += recvBuf[i].ToString("X2") + " "; + WinISP.frmISP.WriteLog("[Read DDC Fail]", "debug"); + return null; + } + } + + private static Byte CalCheckSum(Byte[] data, int startIdx = 0) + { + Byte chkSum = 0; + for (int idx = startIdx; idx < data.Length; idx++) + { + chkSum ^= data[idx]; + } + return chkSum; + } + + //Write EDID 128 bytes + public static bool DDC_WriteEDID(Byte[] data) + { + //DDC Wr EDID Cmd : CC-20-Idx-data + const int maxWrLen = 32; + const int maxRetryCnt = 5; + int retryCnt = 0; + int wrCnt = 0; + Byte wrChkSum = 0, rdChkSum = 0; + Byte[] cmds = new Byte[maxWrLen + 3]; + const Byte MTKCmd = 0xCC; + const Byte wrEdidCmd = 0x20; + cmds[0] = MTKCmd; + cmds[1] = wrEdidCmd; + + while ((wrCnt < data.Length) && (retryCnt < maxRetryCnt)) + { + cmds[2] = (Byte)wrCnt; + Array.Copy(data, wrCnt, cmds, 3, maxWrLen); + wrChkSum = CalCheckSum(cmds, 3); + DDC_Write(cmds); + WinIOLib.DelayMs(100); + rdChkSum = DDC_ReadChkSum(); + if (wrChkSum != rdChkSum) + { + retryCnt++; + continue; + }else{ + retryCnt = 0; + wrCnt += maxWrLen; + } + } + + if ((retryCnt == 0) && (wrCnt == data.Length)) + return true; + else + return false; + } + + public static Byte DDC_ReadChkSum() + { + Byte[] cmds = new Byte[2]; + const Byte MTKCmd = 0xCC; + const Byte wrRdChkSumCmd = 0x8E; + cmds[0] = MTKCmd; + cmds[1] = wrRdChkSumCmd; + + //Recv procedure : 6E-Len-Data0-Data1-ChkSum + const int recvLen = 5; + Byte[] recvBuf = DDC_Read(cmds, recvLen); + + if (recvBuf == null) + return 0; + + if ((recvBuf[1] & 0x7F) == (recvLen - 3)) + return recvBuf[2]; + else + return 0; + } + + public static bool IsDDCFormatOK(byte[] ddc, ref int slaveAddrIndex, ref int lengthIndex, ref int checkSumIndex) + { + int _slaveAddrIndex = -1, _lengthIndex = -1, _checkSumIndex = -1; + for (int i = 0; i < ddc.Length; ++i) + { + if (ddc[i] == 0x6E) + { + _slaveAddrIndex = i; + if (_slaveAddrIndex + 1 < ddc.Length) + if (ddc[_slaveAddrIndex + 1] > 0x80) + { + _lengthIndex = _slaveAddrIndex + 1; + if ((_lengthIndex + (ddc[_slaveAddrIndex + 1] - 0x80) + 1) < ddc.Length) + { + _checkSumIndex = _lengthIndex + (ddc[_slaveAddrIndex + 1] - 0x80) + 1; + break; + } + } + } + } + WinISP.frmISP.WriteLog("DDCFormat check - _slaveAddrIndex: " + _slaveAddrIndex.ToString(), "debug"); + WinISP.frmISP.WriteLog("DDCFormat check - _lengthIndex: " + _lengthIndex.ToString(), "debug"); + WinISP.frmISP.WriteLog("DDCFormat check - _checkSumIndex: " + _checkSumIndex.ToString(), "debug"); + if ((_slaveAddrIndex == -1) || (_lengthIndex == -1) || (_checkSumIndex == -1)) + { + WinISP.frmISP.WriteLog("DDCFormat check fail - Index: -1", "debug"); + return false; + } + if ((_checkSumIndex - _lengthIndex <= 0) || (_lengthIndex - _slaveAddrIndex <= 0) || (_checkSumIndex - _slaveAddrIndex <= 0)) + { + WinISP.frmISP.WriteLog("DDCFormat check fail - Index fail", "debug"); + return false; + } + byte checkSum = 0; + + for (int i = _slaveAddrIndex; i < _checkSumIndex; ++i) + checkSum = (byte)(checkSum ^ ddc[i]); + + checkSum = (byte)(checkSum ^ 0x50); + + WinISP.frmISP.WriteLog("DDCFormat check - Calculated Checksum: " + checkSum.ToString("X2"), "debug"); + WinISP.frmISP.WriteLog("DDCFormat check - Received Checksum: " + ddc[_checkSumIndex].ToString("X2"), "debug"); + + if (checkSum == ddc[_checkSumIndex]) + { + slaveAddrIndex = _slaveAddrIndex; + lengthIndex = _lengthIndex; + checkSumIndex = _checkSumIndex; + return true; + } + else + { + WinISP.frmISP.WriteLog("DDCFormat check fail - Checksum fail", "debug"); + return false; + } + } + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/SimI2CCtrl.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/SimI2CCtrl.cs new file mode 100644 index 0000000..c86a026 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/SimI2CCtrl.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +//using System.Linq; +using System.Text; + +namespace MTK +{ + public enum Levels {Low, High}; + public interface ISimI2CCtrl + { + Levels SDA { get; set; } + Levels SCL { get; set; } + + bool I2C_Start(); + void I2C_Stop(); + byte I2C_RecvByte(bool IsAck); + bool I2C_SendByte(byte data); + + bool WriteData(Byte slvAddr, Byte[] arr); + byte ReadData(Byte slvAddr, Byte[] arr); + + bool WriteData(Byte[] data); + bool ReadData(Byte[] data, byte[] wrCmds = null); + bool Init(); + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/WinIOLib.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/WinIOLib.cs new file mode 100644 index 0000000..6679090 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/WinIOLib.cs @@ -0,0 +1,75 @@ +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; +using System.Windows.Forms; + +namespace MTK +{ + public unsafe class WinIOLib + { + [DllImport("kernel32.dll")] + extern static short QueryPerformanceCounter(ref long x); + + [DllImport("kernel32.dll")] + extern static short QueryPerformanceFrequency(ref long x); + + static double _baseCnt = 0; + static long _cpuCnt = 0; + static long _dlyCnt = 0; + public static int _dftI2CDlyTime = 10; + public static void Delaytime(long dtime) + { + int tick = Environment.TickCount; + while (Environment.TickCount - tick < dtime) + { + System.Windows.Forms.Application.DoEvents(); + } + } + public static void DelayUs(int us = -1) + { + if (us == -1) + us = _dftI2CDlyTime; + + if (us == 0) + return; + + if (_baseCnt == 0) + { + long cpuFreq = 0; + QueryPerformanceFrequency(ref cpuFreq); + _baseCnt = (cpuFreq) / 1000000; + } + + QueryPerformanceCounter(ref _cpuCnt); + _dlyCnt = _cpuCnt + (long)(_baseCnt * us); + + while (true) + { + QueryPerformanceCounter(ref _cpuCnt); + if (_cpuCnt > _dlyCnt) + break; + } + } + + public static void DelayMs(int ms) + { + DelayUs(ms * 1000); + } + + private static int GetTickCount() + { + return Environment.TickCount & Int32.MaxValue; + } + + public static void ExDelayMs(int ms) + { + int endCnt = GetTickCount() + ms; + while (endCnt > GetTickCount()) + { + System.Windows.Forms.Application.DoEvents(); + } + + } + + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/ini/AccessIni.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/ini/AccessIni.cs new file mode 100644 index 0000000..5df03a2 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/BaseClass/ini/AccessIni.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace WinISP +{ + + public class AccessIni + { + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + public static extern long WritePrivateProfileString(string section, string key, string val, string filePath); + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + + public static bool IsShowErrorMsg = true; + + public AccessIni() { } + + public static StringBuilder GetProfileString(string section, string key, string filePath) + { + StringBuilder retStr = new StringBuilder(255); + try + { + int retError = GetPrivateProfileString(section, key, "", retStr, retStr.Capacity, filePath); + + if (retError == 0) + { + if (IsShowErrorMsg) + System.Windows.Forms.MessageBox.Show("section = [ " + section.ToString() + " ] key = [ " + key.ToString() + " ] \n format error !!"); + } + } + catch (Exception ex) + { + if (IsShowErrorMsg) + System.Windows.Forms.MessageBox.Show("section = [ " + section.ToString() + " ] key = [ " + key.ToString() + " ] \n" + ex.Message); + } + return retStr; + } + + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MERGE__BD_MT9802_QDQTBG_MOKA__DebugON.bin b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MERGE__BD_MT9802_QDQTBG_MOKA__DebugON.bin new file mode 100644 index 0000000..57e4cab Binary files /dev/null and b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MERGE__BD_MT9802_QDQTBG_MOKA__DebugON.bin differ diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/MyApp.csproj b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/MyApp.csproj new file mode 100644 index 0000000..d1fec1a --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/MyApp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0.201 + enable + enable + + + diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/Program.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/Program.cs new file mode 100644 index 0000000..1bc52a6 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/MyApp/Program.cs @@ -0,0 +1 @@ +Console.WriteLine("Hello, World!"); diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Program.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Program.cs new file mode 100644 index 0000000..0a1e8be --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Program.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; + +namespace WinISP +{ + static class Program + { + public static bool isManagedDll = false; + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.ApplicationExit += Application_ApplicationExit; + { + Application.Run(new frmISP()); + } + } + public static bool IsManagedAssembly(string fileName) + { + if (!System.IO.Directory.Exists(fileName)) + return true; + using (Stream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) + using (BinaryReader binaryReader = new BinaryReader(fileStream)) + { + if (fileStream.Length < 64) + { + return false; + } + + //PE Header starts @ 0x3C (60). Its a 4 byte header. + fileStream.Position = 0x3C; + uint peHeaderPointer = binaryReader.ReadUInt32(); + if (peHeaderPointer == 0) + { + peHeaderPointer = 0x80; + } + + // Ensure there is at least enough room for the following structures: + // 24 byte PE Signature & Header + // 28 byte Standard Fields (24 bytes for PE32+) + // 68 byte NT Fields (88 bytes for PE32+) + // >= 128 byte Data Dictionary Table + if (peHeaderPointer > fileStream.Length - 256) + { + return false; + } + + // Check the PE signature. Should equal 'PE\0\0'. + fileStream.Position = peHeaderPointer; + uint peHeaderSignature = binaryReader.ReadUInt32(); + if (peHeaderSignature != 0x00004550) + { + return false; + } + + // skip over the PEHeader fields + fileStream.Position += 20; + + const ushort PE32 = 0x10b; + const ushort PE32Plus = 0x20b; + + // Read PE magic number from Standard Fields to determine format. + var peFormat = binaryReader.ReadUInt16(); + if (peFormat != PE32 && peFormat != PE32Plus) + { + return false; + } + + // Read the 15th Data Dictionary RVA field which contains the CLI header RVA. + // When this is non-zero then the file contains CLI data otherwise not. + ushort dataDictionaryStart = (ushort)(peHeaderPointer + (peFormat == PE32 ? 232 : 248)); + fileStream.Position = dataDictionaryStart; + + uint cliHeaderRva = binaryReader.ReadUInt32(); + if (cliHeaderRva == 0) + { + return false; + } + + return true; + } + } + static void Application_ApplicationExit(object sender, EventArgs e) + { + } + + static void deleteFile(string path) + { + try + { + if (File.Exists(path)) + File.Delete(path); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } + + static void SetFileAttrHiden(string path) + { + if (File.Exists(path)) + { + FileInfo fileInfo = new FileInfo(path); + fileInfo.Attributes = FileAttributes.Hidden; + } + } + + static void WriteFile(string path, byte[] binary) + { + try + { + System.IO.File.WriteAllBytes(path, binary); + SetFileAttrHiden(path); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + + } + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/AssemblyInfo.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..69f4cd4 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Display firmware update tool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("www.mediatek.com")] +[assembly: AssemblyProduct("ISP Tool")] +[assembly: AssemblyCopyright("Copyright © Mediatek Inc 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("497598ab-acf1-47e2-bf34-9ea38c9d82fb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.2.0.1")] +[assembly: AssemblyFileVersion("1.2.0.1")] diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.Designer.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.Designer.cs new file mode 100644 index 0000000..53a8476 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinISP.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinISP.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.resx b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.resx new file mode 100644 index 0000000..2f96abe --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Resources.resx @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.Designer.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.Designer.cs new file mode 100644 index 0000000..cd1d617 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WinISP.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.settings b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/app.manifest b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/app.manifest new file mode 100644 index 0000000..cafc289 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/Properties/app.manifest @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.csproj b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.csproj new file mode 100644 index 0000000..6b53117 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.csproj @@ -0,0 +1,169 @@ + + + + + Debug + AnyCPU + {033DCDDE-510B-46E8-8F6E-6BBEB8681D7E} + WinExe + Properties + WinISP + WinISP + v4.8 + 512 + + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + AnyCPU + true + full + false + bin\Debug\ + TRACE;DEBUG;UNMANAGED_DLL; + prompt + 4 + false + true + + + x86 + pdbonly + true + bin\Release\ + TRACE;UNMANAGED_DLL; + prompt + 4 + true + false + + + LocalIntranet + + + false + + + + Properties\app.manifest + + + false + + + true + bin\x86\Debug\ + TRACE;DEBUG;UNMANAGED_DLL; + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE;UNMANAGED_DLL; + true + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + + Form + + + frmISP.cs + + + + + frmISP.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + Designer + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 4.5 + true + + + + + + \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.sln b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.sln new file mode 100644 index 0000000..04ae509 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/WinISP.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinISP", "WinISP.csproj", "{BB96FAE8-5F8F-9378-6248-D5D92CB77471}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BB96FAE8-5F8F-9378-6248-D5D92CB77471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB96FAE8-5F8F-9378-6248-D5D92CB77471}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB96FAE8-5F8F-9378-6248-D5D92CB77471}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB96FAE8-5F8F-9378-6248-D5D92CB77471}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4580AF4B-5D5E-4C98-8BC6-4A05FF27BCB4} + EndGlobalSection +EndGlobal diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/app.config b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/app.config new file mode 100644 index 0000000..e365603 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/app.config @@ -0,0 +1,3 @@ + + + diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.Designer.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.Designer.cs new file mode 100644 index 0000000..92e2205 --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.Designer.cs @@ -0,0 +1,548 @@ +namespace WinISP +{ + partial class frmISP + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnRunISP = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.lblBinName = new System.Windows.Forms.Label(); + this.txtPktDelayTime = new System.Windows.Forms.TextBox(); + this.label16 = new System.Windows.Forms.Label(); + this.lblVer = new System.Windows.Forms.Label(); + this.btnRunDPISP = new System.Windows.Forms.Button(); + this.pnlConnState = new System.Windows.Forms.Panel(); + this.btnConnect = new System.Windows.Forms.Button(); + this.btnOpenBin = new System.Windows.Forms.Button(); + this.labelFile = new System.Windows.Forms.Label(); + this.lblGraphicCardTitle = new System.Windows.Forms.Label(); + this.lblFileSize = new System.Windows.Forms.Label(); + this.lblGraphicCard = new System.Windows.Forms.Label(); + this.lblConnectedPort = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.lblTransferTime = new System.Windows.Forms.Label(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.label14 = new System.Windows.Forms.Label(); + this.label19 = new System.Windows.Forms.Label(); + this.lblDisplayName = new System.Windows.Forms.Label(); + this.label20 = new System.Windows.Forms.Label(); + this.lblMTKChipType = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.lblPktDelayTime = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.lblPgsPercentage = new System.Windows.Forms.Label(); + this.lblUpdatingFWmsg = new System.Windows.Forms.Label(); + this.label22 = new System.Windows.Forms.Label(); + this.label23 = new System.Windows.Forms.Label(); + this.cboConnectedMonitor = new System.Windows.Forms.ComboBox(); + this.label24 = new System.Windows.Forms.Label(); + this.lblDisplayNumber = new System.Windows.Forms.Label(); + this.txtDelayUnit = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.statusStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // btnRunISP + // + this.btnRunISP.Location = new System.Drawing.Point(940, 109); + this.btnRunISP.Name = "btnRunISP"; + this.btnRunISP.Size = new System.Drawing.Size(75, 23); + this.btnRunISP.TabIndex = 119; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Calibri", 12F); + this.label1.Location = new System.Drawing.Point(6, 13); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(114, 19); + this.label1.TabIndex = 56; + this.label1.Text = "Binary file name"; + // + // lblBinName + // + this.lblBinName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblBinName.Font = new System.Drawing.Font("Calibri", 12F); + this.lblBinName.Location = new System.Drawing.Point(125, 8); + this.lblBinName.Name = "lblBinName"; + this.lblBinName.Size = new System.Drawing.Size(584, 28); + this.lblBinName.TabIndex = 57; + // + // txtPktDelayTime + // + this.txtPktDelayTime.Font = new System.Drawing.Font("Calibri", 12F); + this.txtPktDelayTime.Location = new System.Drawing.Point(439, 111); + this.txtPktDelayTime.Name = "txtPktDelayTime"; + this.txtPktDelayTime.Size = new System.Drawing.Size(153, 27); + this.txtPktDelayTime.TabIndex = 118; + this.txtPktDelayTime.Visible = false; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label16.Location = new System.Drawing.Point(302, 82); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(90, 19); + this.label16.TabIndex = 82; + this.label16.Text = "Com Version"; + this.label16.Visible = false; + // + // lblVer + // + this.lblVer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblVer.Font = new System.Drawing.Font("Calibri", 12F); + this.lblVer.Location = new System.Drawing.Point(439, 76); + this.lblVer.Name = "lblVer"; + this.lblVer.Size = new System.Drawing.Size(153, 28); + this.lblVer.TabIndex = 83; + this.lblVer.Visible = false; + // + // btnRunDPISP + // + this.btnRunDPISP.Font = new System.Drawing.Font("Calibri", 12F); + this.btnRunDPISP.Location = new System.Drawing.Point(664, 42); + this.btnRunDPISP.Name = "btnRunDPISP"; + this.btnRunDPISP.Size = new System.Drawing.Size(97, 31); + this.btnRunDPISP.TabIndex = 65; + this.btnRunDPISP.Text = "Update"; + this.btnRunDPISP.UseVisualStyleBackColor = true; + this.btnRunDPISP.Click += new System.EventHandler(this.btnRunDPISP_Click); + // + // pnlConnState + // + this.pnlConnState.BackColor = System.Drawing.Color.Red; + this.pnlConnState.Location = new System.Drawing.Point(636, 42); + this.pnlConnState.Name = "pnlConnState"; + this.pnlConnState.Size = new System.Drawing.Size(23, 31); + this.pnlConnState.TabIndex = 32; + // + // btnConnect + // + this.btnConnect.Font = new System.Drawing.Font("Calibri", 12F); + this.btnConnect.Location = new System.Drawing.Point(664, 106); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(97, 31); + this.btnConnect.TabIndex = 31; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + this.btnConnect.Visible = false; + this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); + // + // btnOpenBin + // + this.btnOpenBin.Font = new System.Drawing.Font("Calibri", 12F); + this.btnOpenBin.Location = new System.Drawing.Point(713, 8); + this.btnOpenBin.Name = "btnOpenBin"; + this.btnOpenBin.Size = new System.Drawing.Size(48, 28); + this.btnOpenBin.TabIndex = 73; + this.btnOpenBin.Text = "..."; + this.btnOpenBin.UseVisualStyleBackColor = true; + this.btnOpenBin.Click += new System.EventHandler(this.btnOpenBin_Click); + // + // labelFile + // + this.labelFile.AutoSize = true; + this.labelFile.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelFile.Location = new System.Drawing.Point(7, 46); + this.labelFile.Name = "labelFile"; + this.labelFile.Size = new System.Drawing.Size(103, 19); + this.labelFile.TabIndex = 78; + this.labelFile.Text = "Binary file size"; + this.labelFile.Visible = false; + // + // lblGraphicCardTitle + // + this.lblGraphicCardTitle.AutoSize = true; + this.lblGraphicCardTitle.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblGraphicCardTitle.Location = new System.Drawing.Point(7, 80); + this.lblGraphicCardTitle.Name = "lblGraphicCardTitle"; + this.lblGraphicCardTitle.Size = new System.Drawing.Size(91, 19); + this.lblGraphicCardTitle.TabIndex = 79; + this.lblGraphicCardTitle.Text = "Graphic card"; + this.lblGraphicCardTitle.Visible = false; + // + // lblFileSize + // + this.lblFileSize.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblFileSize.Font = new System.Drawing.Font("Calibri", 12F); + this.lblFileSize.Location = new System.Drawing.Point(125, 42); + this.lblFileSize.Name = "lblFileSize"; + this.lblFileSize.Size = new System.Drawing.Size(171, 28); + this.lblFileSize.TabIndex = 80; + this.lblFileSize.Visible = false; + // + // lblGraphicCard + // + this.lblGraphicCard.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblGraphicCard.Font = new System.Drawing.Font("Calibri", 12F); + this.lblGraphicCard.Location = new System.Drawing.Point(125, 77); + this.lblGraphicCard.Name = "lblGraphicCard"; + this.lblGraphicCard.Size = new System.Drawing.Size(171, 28); + this.lblGraphicCard.TabIndex = 81; + this.lblGraphicCard.Visible = false; + // + // lblConnectedPort + // + this.lblConnectedPort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblConnectedPort.Font = new System.Drawing.Font("Calibri", 12F); + this.lblConnectedPort.Location = new System.Drawing.Point(125, 110); + this.lblConnectedPort.Name = "lblConnectedPort"; + this.lblConnectedPort.Size = new System.Drawing.Size(171, 28); + this.lblConnectedPort.TabIndex = 89; + this.lblConnectedPort.Text = "Unknow"; + this.lblConnectedPort.Visible = false; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label17.Location = new System.Drawing.Point(7, 113); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(108, 19); + this.label17.TabIndex = 88; + this.label17.Text = "Connected port"; + this.label17.Visible = false; + // + // lblTransferTime + // + this.lblTransferTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblTransferTime.Font = new System.Drawing.Font("Calibri", 12F); + this.lblTransferTime.Location = new System.Drawing.Point(439, 144); + this.lblTransferTime.Name = "lblTransferTime"; + this.lblTransferTime.Size = new System.Drawing.Size(153, 28); + this.lblTransferTime.TabIndex = 92; + this.lblTransferTime.Visible = false; + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripProgressBar1, + this.toolStripStatusLabel1}); + this.statusStrip1.Location = new System.Drawing.Point(0, 240); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(1055, 22); + this.statusStrip1.TabIndex = 94; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripProgressBar1 + // + this.toolStripProgressBar1.Name = "toolStripProgressBar1"; + this.toolStripProgressBar1.Size = new System.Drawing.Size(167, 16); + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(131, 17); + this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label14.Location = new System.Drawing.Point(302, 149); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(127, 19); + this.label14.TabIndex = 96; + this.label14.Text = "Transfer Time(ms)"; + this.label14.Visible = false; + // + // label19 + // + this.label19.AutoSize = true; + this.label19.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label19.Location = new System.Drawing.Point(310, 183); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(99, 19); + this.label19.TabIndex = 106; + this.label19.Text = "Dispaly Name"; + this.label19.Visible = false; + // + // lblDisplayName + // + this.lblDisplayName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblDisplayName.Font = new System.Drawing.Font("Calibri", 12F); + this.lblDisplayName.Location = new System.Drawing.Point(439, 178); + this.lblDisplayName.Name = "lblDisplayName"; + this.lblDisplayName.Size = new System.Drawing.Size(153, 28); + this.lblDisplayName.TabIndex = 105; + this.lblDisplayName.Visible = false; + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label20.Location = new System.Drawing.Point(302, 46); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(72, 19); + this.label20.TabIndex = 109; + this.label20.Text = "Chip Type"; + this.label20.Visible = false; + // + // lblMTKChipType + // + this.lblMTKChipType.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblMTKChipType.Font = new System.Drawing.Font("Calibri", 12F); + this.lblMTKChipType.Location = new System.Drawing.Point(439, 41); + this.lblMTKChipType.Name = "lblMTKChipType"; + this.lblMTKChipType.Size = new System.Drawing.Size(153, 28); + this.lblMTKChipType.TabIndex = 110; + this.lblMTKChipType.Visible = false; + // + // label21 + // + this.label21.AutoSize = true; + this.label21.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label21.Location = new System.Drawing.Point(302, 116); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(107, 19); + this.label21.TabIndex = 112; + this.label21.Text = "Delay Time(us)"; + this.label21.Visible = false; + // + // lblPktDelayTime + // + this.lblPktDelayTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblPktDelayTime.Font = new System.Drawing.Font("Calibri", 12F); + this.lblPktDelayTime.Location = new System.Drawing.Point(439, 111); + this.lblPktDelayTime.Name = "lblPktDelayTime"; + this.lblPktDelayTime.Size = new System.Drawing.Size(153, 28); + this.lblPktDelayTime.TabIndex = 111; + this.lblPktDelayTime.Visible = false; + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(9, 41); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(621, 34); + this.progressBar1.TabIndex = 115; + this.progressBar1.Visible = false; + // + // lblPgsPercentage + // + this.lblPgsPercentage.AutoSize = true; + this.lblPgsPercentage.BackColor = System.Drawing.SystemColors.Control; + this.lblPgsPercentage.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblPgsPercentage.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblPgsPercentage.Location = new System.Drawing.Point(645, 38); + this.lblPgsPercentage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblPgsPercentage.Name = "lblPgsPercentage"; + this.lblPgsPercentage.Size = new System.Drawing.Size(28, 19); + this.lblPgsPercentage.TabIndex = 116; + this.lblPgsPercentage.Text = "0%"; + this.lblPgsPercentage.Visible = false; + // + // lblUpdatingFWmsg + // + this.lblUpdatingFWmsg.AutoSize = true; + this.lblUpdatingFWmsg.BackColor = System.Drawing.SystemColors.Control; + this.lblUpdatingFWmsg.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblUpdatingFWmsg.ForeColor = System.Drawing.SystemColors.ControlText; + this.lblUpdatingFWmsg.Location = new System.Drawing.Point(7, 85); + this.lblUpdatingFWmsg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblUpdatingFWmsg.Name = "lblUpdatingFWmsg"; + this.lblUpdatingFWmsg.Size = new System.Drawing.Size(141, 19); + this.lblUpdatingFWmsg.TabIndex = 117; + this.lblUpdatingFWmsg.Text = "Updating firmware..."; + this.lblUpdatingFWmsg.Visible = false; + // + // label22 + // + this.label22.AutoSize = true; + this.label22.BackColor = System.Drawing.Color.White; + this.label22.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label22.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(136))); + this.label22.ForeColor = System.Drawing.Color.Red; + this.label22.Location = new System.Drawing.Point(10, 210); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(569, 28); + this.label22.TabIndex = 113; + this.label22.Text = "Do not power off or disconnect cable while updating!"; + this.label22.Visible = false; + // + // label23 + // + this.label23.AutoSize = true; + this.label23.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label23.Location = new System.Drawing.Point(7, 181); + this.label23.Name = "label23"; + this.label23.Size = new System.Drawing.Size(117, 19); + this.label23.TabIndex = 115; + this.label23.Text = "MTK Display List"; + this.label23.Visible = false; + // + // cboConnectedMonitor + // + this.cboConnectedMonitor.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cboConnectedMonitor.FormattingEnabled = true; + this.cboConnectedMonitor.Location = new System.Drawing.Point(125, 178); + this.cboConnectedMonitor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cboConnectedMonitor.Name = "cboConnectedMonitor"; + this.cboConnectedMonitor.Size = new System.Drawing.Size(171, 27); + this.cboConnectedMonitor.TabIndex = 114; + this.cboConnectedMonitor.Visible = false; + this.cboConnectedMonitor.SelectedIndexChanged += new System.EventHandler(this.cboConnectedMonitor_SelectedIndexChanged); + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label24.Location = new System.Drawing.Point(7, 149); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(112, 19); + this.label24.TabIndex = 116; + this.label24.Text = "Display Number"; + this.label24.Visible = false; + // + // lblDisplayNumber + // + this.lblDisplayNumber.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lblDisplayNumber.Font = new System.Drawing.Font("Calibri", 12F); + this.lblDisplayNumber.Location = new System.Drawing.Point(125, 144); + this.lblDisplayNumber.Name = "lblDisplayNumber"; + this.lblDisplayNumber.Size = new System.Drawing.Size(171, 28); + this.lblDisplayNumber.TabIndex = 117; + this.lblDisplayNumber.Text = "0"; + this.lblDisplayNumber.Visible = false; + // + // txtDelayUnit + // + this.txtDelayUnit.Location = new System.Drawing.Point(940, 210); + this.txtDelayUnit.MaxLength = 8; + this.txtDelayUnit.Name = "txtDelayUnit"; + this.txtDelayUnit.Size = new System.Drawing.Size(100, 21); + this.txtDelayUnit.TabIndex = 121; + this.txtDelayUnit.Text = "5"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(939, 194); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(65, 12); + this.label10.TabIndex = 120; + this.label10.Text = "Delay Unit"; + // + // frmISP + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1055, 262); + this.Controls.Add(this.txtDelayUnit); + this.Controls.Add(this.label10); + this.Controls.Add(this.lblUpdatingFWmsg); + this.Controls.Add(this.lblPgsPercentage); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.txtPktDelayTime); + this.Controls.Add(this.lblDisplayNumber); + this.Controls.Add(this.label24); + this.Controls.Add(this.label23); + this.Controls.Add(this.cboConnectedMonitor); + this.Controls.Add(this.label22); + this.Controls.Add(this.label21); + this.Controls.Add(this.lblPktDelayTime); + this.Controls.Add(this.label20); + this.Controls.Add(this.lblMTKChipType); + this.Controls.Add(this.label19); + this.Controls.Add(this.lblDisplayName); + this.Controls.Add(this.label14); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.lblTransferTime); + this.Controls.Add(this.lblConnectedPort); + this.Controls.Add(this.label16); + this.Controls.Add(this.label17); + this.Controls.Add(this.lblVer); + this.Controls.Add(this.lblGraphicCard); + this.Controls.Add(this.lblFileSize); + this.Controls.Add(this.lblGraphicCardTitle); + this.Controls.Add(this.labelFile); + this.Controls.Add(this.btnOpenBin); + this.Controls.Add(this.btnRunDPISP); + this.Controls.Add(this.lblBinName); + this.Controls.Add(this.pnlConnState); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnRunISP); + this.Controls.Add(this.btnConnect); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmISP"; + this.Text = "Dispaly firmware update tool"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmISP_FormClosing); + this.Load += new System.EventHandler(this.frmISP_Load); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnRunISP; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lblBinName; + private System.Windows.Forms.Panel pnlConnState; + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.Button btnRunDPISP; + private System.Windows.Forms.Button btnOpenBin; + private System.Windows.Forms.Label labelFile; + private System.Windows.Forms.Label lblGraphicCardTitle; + private System.Windows.Forms.Label lblFileSize; + private System.Windows.Forms.Label lblGraphicCard; + private System.Windows.Forms.Label lblVer; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label lblConnectedPort; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.Label lblTransferTime; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label19; + private System.Windows.Forms.Label lblDisplayName; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.Label lblMTKChipType; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.Label lblPktDelayTime; + private System.Windows.Forms.TextBox txtPktDelayTime; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label lblPgsPercentage; + private System.Windows.Forms.Label lblUpdatingFWmsg; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.Label label23; + private System.Windows.Forms.ComboBox cboConnectedMonitor; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.Label lblDisplayNumber; + private System.Windows.Forms.TextBox txtDelayUnit; + private System.Windows.Forms.Label label10; + } +} + diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs new file mode 100644 index 0000000..2f0763c --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.cs @@ -0,0 +1,1712 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using System.IO; +using MTK; +using System.Diagnostics; +using WinISP.BaseClass; +using System.Management; + +namespace WinISP +{ + public partial class frmISP : Form + { + public int ErrorCode = 0; + string _DirExeStarUp = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\"; + bool IsConnect = false; +#if AUTO_SEARCH + int StressTest_Count = 1; +#endif + int Transfer_Time = 0; + ulong Total_Transfer_Time = 0; + ulong Total_UpdateFW_Time = 0; + GraphicCardI2CCtrl gci2cCtrl = null; + public frmISP() + { + InitializeComponent(); + } + + private String _binFilePath = String.Empty; + private String _eddFilePath = String.Empty; + private string _u8ModelName = String.Empty; + private string _u8PanelName = String.Empty; + private string _panelTypeName = String.Empty; + private string _chipName = String.Empty; + private string _u8ChipName = String.Empty; + private string _u8BoardName = String.Empty; + private bool _IsRunISP = false; + ISimI2CCtrl _simI2cCtrl; + private bool _IsHDMIConnect = false; + const int _flashSectorSize = 0x1000; + private Byte _chipType = 0; + private Byte _panelType = 0; + private Byte _clientType = 0; + private const int WM_DEVICECHANGE = 0x219; + private const int DBT_DEVNODES_CHANGED = 0x07; + object _lockObj = new object(); + int _numberOfMonitors; + int _lastNumOfMonitors = 0; + int defaultPktLen = 59; + public void UpdateNumofConnectedMonitor() + { + lock (_lockObj) + { + string strQuery = "SELECT * FROM Win32_PnPEntity WHERE Service = \"monitor\""; + ManagementObjectSearcher searcher = new ManagementObjectSearcher("\\root\\CIMV2", strQuery); + _numberOfMonitors = searcher.Get().Count; + } + } + + protected override void WndProc(ref Message m) + { + base.WndProc(ref m); + + switch (m.Msg) + { + case WM_DEVICECHANGE: + switch ((int)m.WParam) + { + case DBT_DEVNODES_CHANGED: + BackgroundWorker bw = new BackgroundWorker(); + bw.DoWork += (s, args) => + { + this.Invoke(new MethodInvoker(() => UpdateNumofConnectedMonitor())); + Application.DoEvents(); + }; + bw.RunWorkerAsync(); + break; + } + break; + } + + } + + public void CheckSingleInstance() + { + Process[] thisnameprocesslist; + string modulename, processname; + Process p = Process.GetCurrentProcess(); + modulename = p.MainModule.ModuleName.ToString(); + processname = System.IO.Path.GetFileNameWithoutExtension(modulename); + thisnameprocesslist = Process.GetProcessesByName(processname); + if (thisnameprocesslist.Length > 1) + { + Application.Exit(); + } + } + +#if DEBUG + string debugversion = "[Debug Version]"; +#else + string debugversion = ""; +#endif + private void frmISP_Load(object sender, EventArgs e) + { + UpdateNumofConnectedMonitor(); + lblDisplayNumber.Text = _numberOfMonitors.ToString(); + + CenterToScreen(); + if (_simI2cCtrl == null) + _simI2cCtrl = new GraphicCardI2CCtrl(); + MTKDebugCmd.InitI2CCtrl(_simI2cCtrl); + + CheckSingleInstance(); + + SetStatusMsg("Ready"); + + string betaString = ""; + System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); + this.Text += " [Program Version] : " + fvi.ProductVersion + " " + betaString /*+ " (FW ver : " + ver + ") "*/ + debugversion; + WriteLog("Program version: " + fvi.ProductVersion, "debug"); +#if DEBUG + { + this.label21.Visible = true; + this.lblPktDelayTime.Visible = true; + this.txtPktDelayTime.Visible = true; + this.label20.Visible = true; + this.lblMTKChipType.Visible = true; + } +#endif + Width = 800; + TopMost = true; + Connect(); + _lastNumOfMonitors = _numberOfMonitors; + Application.Idle += Application_Idle; + + } + + bool _IsAutoRunISP = true; + + private void Application_Idle(object sender, EventArgs e) + { + if (_numberOfMonitors != _lastNumOfMonitors) + _lastNumOfMonitors = _numberOfMonitors; + //_cf = AccessIni.ReadFwConfig(); +#if AUTO_SEARCH + //search bin file from current folder + FileInfo fi = SearchFile("*.bin"); + if (fi != null) + { + _binFilePath = fi.FullName; + lblBinName.Text = fi.Name; + } + else + { + WriteLog("No bin file in current folder.", "debug"); + Application.Idle -= Application_Idle; + this.Close(); + } + Application.Idle -= Application_Idle; + btnRunDPISP_Click(this, EventArgs.Empty); +#else +#endif + } + + private FileInfo SearchFile(String extName) + { + string currentDirName = Directory.GetCurrentDirectory(); + string[] files = Directory.GetFiles(currentDirName, extName); + foreach (string s in files) + { + FileInfo fi = null; + try + { + fi = new FileInfo(s); + WriteLog("FileInfo=" + fi.Name, "debug"); + return fi; + } + catch (FileNotFoundException e) + { + continue; + } + } + + return null; + } + + private int GetTickCount() + { + return Environment.TickCount & Int32.MaxValue; + } + + private void OnUpdateProgress(int total, int done, String msg) + { + if (msg != String.Empty) + { + SetStatusMsg(msg); + } + + if (toolStripProgressBar1.Maximum != total) + { + toolStripProgressBar1.Maximum = (int)total; + } + + if (toolStripProgressBar1.Value != done) + { + toolStripProgressBar1.Value = done; + } + Application.DoEvents(); + } + + private void SetISPStatus(bool isRunning) + { + _IsRunISP = isRunning; + btnRunISP.Enabled = !isRunning; + btnOpenBin.Enabled = !isRunning; + btnRunDPISP.Enabled = !isRunning; + cboConnectedMonitor.Enabled = !isRunning; + } + + private void SetStatusMsg(String msg) + { + toolStripStatusLabel1.Text = msg; + Application.DoEvents(); + } + + private void frmISP_FormClosing(object sender, FormClosingEventArgs e) + { + if (_IsRunISP) + { + SetStatusMsg("Firmware is updating, please do not turn off application."); + e.Cancel = true; + } + } + + // 判断u8ModelName和MODEL_NAME_STRING是否一致 + private bool IsModelNameMatch(string u8Model_Name) + { + const string MODEL_NAME_STRING = "MAG 321UPD E14"; + return string.Equals(MODEL_NAME_STRING, u8Model_Name, StringComparison.Ordinal); + } + private bool IsChipNameMatch(string u8Chi_pName) + { + const string ChipName_STRING = "MST9U"; + return string.Equals(ChipName_STRING, 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); + } + 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; + } + private void btnOpenBin_Click(object sender, EventArgs e) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.InitialDirectory = "c:\\"; + dlg.Filter = "bin files (*.bin)|*.bin"; + dlg.FilterIndex = 1; + dlg.RestoreDirectory = true; + + if (dlg.ShowDialog() == DialogResult.OK) + { + try + { + FileInfo fi = new FileInfo(dlg.FileName); + _binFilePath = fi.FullName; + lblBinName.Text = fi.Name; + lblFileSize.Text = InitBinaryFile(_binFilePath).Length.ToString(); + + // 解析bin文件中的u8ModelName、u8PanelName、u8BoardName、u8ChipName + const long infoAddr=0x0041380; + const int modenameLen = 20; // 每个名字最大长度 + const int chipnameLen = 20; + const int panelnameLen = 30; + const int boardnameLen = 20; + const int totalLen = modenameLen + chipnameLen + panelnameLen + boardnameLen; + byte[] infoBytes = ReadBinSection(_binFilePath, infoAddr, totalLen); + if (infoBytes.Length < totalLen) + throw new InvalidDataException("Bin metadata section is shorter than expected."); + _u8ModelName = Encoding.ASCII.GetString(infoBytes, 0, modenameLen).TrimEnd('\0'); + _u8ChipName = Encoding.ASCII.GetString(infoBytes, modenameLen, chipnameLen).TrimEnd('\0'); + _u8PanelName = Encoding.ASCII.GetString(infoBytes, modenameLen + chipnameLen, panelnameLen).TrimEnd('\0'); + _u8BoardName = Encoding.ASCII.GetString(infoBytes, modenameLen + chipnameLen + panelnameLen, boardnameLen).TrimEnd('\0'); + SetStatusMsg("Read Bin OK. Model: " + _u8ModelName + ", Chip: " + _u8ChipName + ", Panel: " + _u8PanelName + ", Board: " + _u8BoardName); + } + catch (Exception ex) + { + SetStatusMsg("Could not read file from disk."); + } + + if (_binFilePath == String.Empty) + return; + + if (flashSectorInfo != null && flashSectorInfo.Count > 0) + flashSectorInfo.Clear(); + btnConnect.PerformClick(); + } + } + + private void txtDelayUnit_TextChanged(object sender, EventArgs e) + { + WinIOLib._dftI2CDlyTime = Convert.ToInt16(txtDelayUnit.Text); + } + + void Connect(int delayTime = 0) + { + SetStatusMsg("Connect MTK Monitor..."); + //Application.DoEvents(); + Byte[] buf = { 0xCC, 0x90, 0x00 ,0x00}; + + WinIOLib.DelayMs(delayTime); + + if (_simI2cCtrl.Init() == true) + { + WriteLog("simI2cCtrl.Init() = true", "debug"); + switch (((GraphicCardI2CCtrl)_simI2cCtrl).GetGraphicCardType) + { + case GraphicCardI2CCtrl.GRAPHIC_CARD.AMD: { lblGraphicCard.Text = "AMD"; } break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.INTEL: { lblGraphicCard.Text = "INTEL"; } break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.NVIDIA: { lblGraphicCard.Text = "NVIDIA"; } break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.INTEL_IGCL: { lblGraphicCard.Text = "INTEL-IGCL"; } break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.NA: { lblGraphicCard.Text = "UNKNOWN"; } break; + } + + if (((GraphicCardI2CCtrl)_simI2cCtrl).GetConnectedPortType == GraphicCardI2CCtrl.PortTypes.HDMI) + { + WriteLog("_IsHDMIConnect = true;", "debug"); + _IsHDMIConnect = true; + } + else + { + WriteLog("_IsHDMIConnect = false;", "debug"); + _IsHDMIConnect = false; + } + + MTKDebugCmd.InitI2CCtrl(_simI2cCtrl); + DDC_SetToolFlag(true); + WinIOLib.DelayMs(10); + // DDC2CI_SetR2Reset51Flag(0x01); + Byte chipType = 0; + IsConnect = false; + int retry = 0; + MTKDebugCmd.DDC_Write(buf); + //if (IsConnect) + { + //WriteLog("IsConnect = true", "debug"); + btnRunDPISP.Enabled = true; + pnlConnState.BackColor = Color.LightGreen; + lblDisplayName.Text = ((GraphicCardI2CCtrl)_simI2cCtrl).GetMonitorName; + SetStatusMsg("Please select a F/W file."); + + cboConnectedMonitor.Items.Clear(); + String nameFromGPU = ""; + List list = ((GraphicCardI2CCtrl)_simI2cCtrl).InitConnectedMonitor; + lblDisplayNumber.Text = list.Count.ToString(); + if (list.Count > 0) + { + for (int idx = 0; idx < list.Count; idx++) + { + cboConnectedMonitor.Items.Add(list[idx].ToUpper()); + } + } + + for (int idxDisp = 0; idxDisp < list.Count; idxDisp++) + { + nameFromGPU = list[idxDisp].ToUpper(); + WriteLog("nameFromGPU = " + nameFromGPU, "debug"); + cboConnectedMonitor.SelectedIndex = idxDisp; + + ((GraphicCardI2CCtrl)_simI2cCtrl).SetConnectedMonitorIndex((Byte)idxDisp); + while ((IsConnect == false) && (retry++ < 30)) + { + IsConnect = DDC_CheckMTKDevice(ref chipType); + } + if (IsConnect == true) + { + pnlConnState.BackColor = Color.LightGreen; + lblConnectedPort.Text = ((GraphicCardI2CCtrl)_simI2cCtrl).GetConnectedPortTypeByIdx((Byte)idxDisp).ToString(); + break; + } + } + cboConnectedMonitor.SelectedIndexChanged += cboConnectedMonitor_SelectedIndexChanged; + cboConnectedMonitor.Enabled = true; + } + + if (IsConnect == false) + { + WriteLog("IsConnect = false", "debug"); + cboConnectedMonitor.Enabled = false; + btnRunDPISP.Enabled = false; + pnlConnState.BackColor = Color.Red; + SetStatusMsg("Current F/W version is not compatible with this tool."); + } + _chipType = chipType; + switch (chipType) + { + case 0: { lblMTKChipType.Text = "Not Defined"; } break; + case 1: { lblMTKChipType.Text = "TSUM"; } break; + case 2: { lblMTKChipType.Text = "MST9U"; } break; + } + Application.DoEvents(); + DDC_GetVersion(); + DDC_SetToolFlag(false); + + int pktDelayTime = 0; + switch (((GraphicCardI2CCtrl)_simI2cCtrl).GetGraphicCardType) + { + case GraphicCardI2CCtrl.GRAPHIC_CARD.AMD: + { + if (_chipType == 2) + { + //MST9U + pktDelayTime = 200; + } + else + { + //TSUMxxG : 當maxPktLen=59時,低於1000時SendDataToDram會失敗。 + pktDelayTime = 1500; + } + WriteLog("GRAPHIC_CARD.AMD", "debug"); + } + break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.NVIDIA: + { + if (_chipType == 2) + { + //MST9U + pktDelayTime = 200; + } + else + { + //TSUMxxG : 當maxPktLen=59時,低於1000時SendDataToDram會失敗。 + pktDelayTime = 1000; + } + WriteLog("GRAPHIC_CARD.NVIDIA", "debug"); + } + break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.INTEL: + case GraphicCardI2CCtrl.GRAPHIC_CARD.INTEL_IGCL: + { + //defaultPktLen = 10; + if (_IsHDMIConnect) + { + //INTEL HDMI 的DDC大部分只有量到10KHz, Bus已經很慢了 所以不需要delay time. + pktDelayTime = 0; + } + else + { + //INTEL DP + if (_chipType == 2) + if (_chipType == 2) + { + //MST9U + pktDelayTime = 0; + } + else + { + //TSUMxxG + pktDelayTime = 0; + } + } + WriteLog("GRAPHIC_CARD.INTEL/INTEL_IGCL", "debug"); + } + break; + } + lblPktDelayTime.Text = pktDelayTime.ToString(); + txtPktDelayTime.Text = pktDelayTime.ToString(); + } + else + pnlConnState.BackColor = Color.Red; + + SetStatusMsg("Ready"); + } + + private void btnConnect_Click(object sender, EventArgs e) + { + Connect(); + } + + private Byte _ver0 = 0; + private Byte _ver1 = 0; + private Byte _ver2 = 0; + + private void DDC_GetVersion() + { + Byte[] cmd1 = { 0xCC, 0x3A }; + Byte[] recv = MTKDebugCmd.DDC_Read(cmd1, 7); + if (recv != null) + { + Byte[] verData = new Byte[5]; + Array.Copy(recv, 2, verData, 0, 5); + var str = System.Text.Encoding.Default.GetString(verData); + lblVer.Text = str; + if ((0x2E == verData[1]) && (0x2E == verData[3])) + { + _ver0 = verData[0]; + _ver1 = verData[2]; + _ver2 = verData[4]; + } + } + } + public static byte DDC2CI_GetToolFlag() + { + Byte[] buf = { 0xCC, 0xA9 }; + + byte flag = 0; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 3); + if (recv != null) + flag = recv[2]; + return flag; + } + private void DDC_SetToolFlag(bool en) + { + Byte[] buf = { 0xCC, 0x90, 0x00 }; + if (en) + buf[2] = 0x01; + + MTKDebugCmd.DDC_Write(buf); + WinIOLib.DelayMs(10); + + int RetryCnt = 0; + while (RetryCnt <= 3) + { + if (Convert.ToBoolean(DDC2CI_GetToolFlag()) == en) + { + RetryCnt = 0; + break; + } + + WinIOLib.DelayMs(30); + RetryCnt++; + + if ((RetryCnt % 3) == 0) + MTKDebugCmd.DDC_Write(buf); + } + if (RetryCnt > 0) + WriteLog("DDC_SetToolFlag fail.", "debug"); + } + public static byte DDC2CI_GetR2Reset51Flag() + { + Byte[] buf = { 0xCC, 0x89, 0x00 }; + + byte flag = 0; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 3); + if (recv != null) + flag = recv[2]; + return flag; + } + public static void DDC2CI_SetR2Reset51Flag(byte en) + { + Byte[] buf = { 0xCC, 0x89, 0x01, 0x00 }; + + if (en == 1) + buf[3] = en; + + MTKDebugCmd.DDC_Write(buf); + WinIOLib.DelayMs(10); + + int RetryCnt = 0; + while ((DDC2CI_GetR2Reset51Flag() != en) && (RetryCnt <= 3)) + { + WinIOLib.DelayMs(30); + RetryCnt++; + + if ((RetryCnt % 3) == 0) + MTKDebugCmd.DDC_Write(buf); + } + } + private void DDC_GetCRC(ref UInt32 checkSum) + { + Byte[] buf = { 0xCC, 0xF1 }; + + //check point + //NV HDMI 1000 + //NV DP 3000 + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 6); + if (recv != null) + { + checkSum = (UInt32)recv[2] + (((UInt32)recv[3]) << 8) + +(((UInt32)recv[4]) << 16) + (((UInt32)recv[5]) << 24); + } + } + + private void DDC_SetRecvInfo(int recvSize) + { + Byte[] buf = { 0xCC, 0xF2, 0x00, 0x00, 0x00, 0x00 }; + buf[2] = (byte)(recvSize & 0xFF); + buf[3] = (byte)((recvSize >> 8) & 0xFF); + buf[4] = (byte)((recvSize >> 16) & 0xFF); + buf[5] = (byte)((recvSize >> 24) & 0xFF); + MTKDebugCmd.DDC_Write(buf); + } + + private void DDC_GetRecvInfo(ref int recvSize) + { + Byte[] buf = { 0xCC, 0xF3 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 6); + recvSize = 0; + if (recv != null) + { + recvSize = (int)recv[2] + (((int)recv[3]) << 8) + +(((int)recv[4]) << 16) + (((int)recv[5]) << 24); + } + } + + UInt32 errDDCWr = 0; + private void DDC_SetData(Byte[] data) + { + + Byte[] buf = new Byte[data.Length + 2]; + buf[0] = 0xCC; + buf[1] = 0xF4; + Array.Copy(data, 0, buf, 2, data.Length); + if (MTKDebugCmd.DDC_Write(buf)) + { + } + else + { + errDDCWr++; + } + } + + private void DDC_GetSentInfo(ref int checkSum, ref int pktCnt, int delayTime) + { + Byte[] buf = { 0xCC, 0xF5 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 8, delayTime); + checkSum = 0; + pktCnt = 0; + if (recv != null) + { + checkSum = (int)recv[2] + (((int)recv[3]) << 8); + pktCnt = (int)recv[4] + (((int)recv[5]) << 8) + +(((int)recv[6]) << 16) + (((int)recv[7]) << 24); + } + } + + private void DDC_GetISPStatus(ref int status, int delayTime = 1000) + { + Byte[] buf = { 0xCC, 0xF8 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 3, delayTime); + status = 0; + if (recv != null) + { + status = (int)recv[2];// +(((int)recv[3]) << 8); + //pktCnt = (int)recv[4] + (((int)recv[5]) << 8) + +(((int)recv[6]) << 16) + (((int)recv[7]) << 24); + } + } + + private void DDC_GetImgOneCheckSum(ref int checkSum) + { + Byte[] buf = { 0xCC, 0xFD }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 4, 500); + if (recv != null) + { + checkSum = (int)recv[2] + (((int)recv[3]) << 8); + } + } + + private void DDC_SetISPImgShadow(UInt16 checkSum) + { + Byte[] buf = { 0xCC, 0xFC, (Byte)(checkSum & 0xFF), (Byte)(checkSum >> 8) }; + MTKDebugCmd.DDC_Write(buf); + } + + private void DDC_GetISPImgNum(ref int imgNum) + { + Byte[] buf = { 0xCC, 0xF9 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 3); + imgNum = 0; + if (recv != null) + { + imgNum = (int)recv[2];// +(((int)recv[3]) << 8); + //pktCnt = (int)recv[4] + (((int)recv[5]) << 8) + +(((int)recv[6]) << 16) + (((int)recv[7]) << 24); + } + } + + private void DDC_SetISPImgOne() + { + Byte[] buf = { 0xCC, 0xFA }; + MTKDebugCmd.DDC_Write(buf); + } + + private void DDC_SetISPReboot() + { + Byte[] buf = { 0xCC, 0xFB }; + MTKDebugCmd.DDC_Write(buf); + } + + private void DDC_SetSentInfo(int pktCnt) + { + Byte[] buf = { 0xCC, 0xF6, 0x00, 0x00, 0x00, 0x00 }; + buf[2] = (byte)(pktCnt & 0xFF); + buf[3] = (byte)((pktCnt >> 8) & 0xFF); + buf[4] = (byte)((pktCnt >> 16) & 0xFF); + buf[5] = (byte)((pktCnt >> 24) & 0xFF); + MTKDebugCmd.DDC_Write(buf); + } + + private bool DDC_CheckMTKDevice(ref Byte chipType, int delayTime = 1000) + { + Random rdn = new Random(); + Byte value1 = (Byte)rdn.Next(); + Byte value2 = (Byte)rdn.Next(); + Byte sum = (Byte)(value1 + value2); + Byte[] buf = { 0xCC, 0xFE, value1, value2 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 4, delayTime); + + if ((recv != null) && (sum == recv[3])) + { + //chipType ==> 0 : Not Define, 1: TSUM, 2:MST9U + chipType = recv[2]; + if(chipType==2) + { + return true; + } + else + { + return false; + } + } + return false; + } + private bool DDC_CheckClientInfo(ref Byte ClientInfo, int delayTime = 1000) + { + Random rdn = new Random(); + Byte value1 = (Byte)rdn.Next(); + Byte value2 = (Byte)rdn.Next(); + Byte sum = (Byte)(value1 + value2); + Byte[] buf = { 0xCC, 0xE0, value1, value2 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 4, delayTime); + + if ((recv != null) && (sum == recv[3])) + { + //Client info ==> 0: MSI, 1 : ACER + ClientInfo = recv[2]; + if(ClientInfo==0) + { + return true; + } + else if(ClientInfo==1) + { + return false; + } + } + return false; + } + private bool DDC_CheckPanelInfo(ref Byte PanelInfo, int delayTime = 1000) + { + Random rdn = new Random(); + Byte value1 = (Byte)rdn.Next(); + Byte value2 = (Byte)rdn.Next(); + Byte sum = (Byte)(value1 + value2); + Byte[] buf = { 0xCC, 0xE1, value1, value2 }; + Byte[] recv = MTKDebugCmd.DDC_Read(buf, 4, delayTime); + + if ((recv != null) && (sum == recv[3])) + { + //Panel info ==> 118: Panel_SG2701D02_1_eDP, 1 : ACER + PanelInfo = recv[2]; + if(PanelInfo==118) + { + return true; + } + else + { + return false; + } + } + return false; + } + private void DDC_RunISP(UInt16 checkSum) + { + Byte[] buf = { 0xCC, 0xF7, (Byte)(checkSum & 0xFF), (Byte)(checkSum >> 8) }; + MTKDebugCmd.DDC_Write(buf); + } + + class FlashSectorInfo + { + public byte[] data; + public bool IsEmpty; + + public FlashSectorInfo() + { + data = new byte[_flashSectorSize]; + Array.Clear(data, 0, data.Length); + IsEmpty = false; + } + + public void Clear() + { + for (int idx = 0; idx < _flashSectorSize; idx++) + { + data[idx] = 0xFF; + } + } + + public void CheckEmpty() + { + IsEmpty = true; + for (int idx = 0; idx < _flashSectorSize; idx++) + { + if (data[idx] != 0xFF) + { + IsEmpty = false; + break; + } + } + } + + public int CheckSum() + { + int checkSum = 0; + for (int idx = 0; idx < _flashSectorSize; idx++) + { + checkSum += data[idx]; + } + return checkSum & 0xFFFF; + } + } + + private bool SetSentInfo(int sentLen) + { + const int MaxRetryCnt = 10; + int retryCnt = 0; + int rdCheckSum = 0; + int rdPktCnt = 0; + while (retryCnt++ < MaxRetryCnt) + { + DDC_SetSentInfo(sentLen); + WinIOLib.DelayMs(1); + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + if (sentLen == rdPktCnt) + { + return true; + } + } + return false; + } + + private void AdjustPacketParam(int defaultPktLen, ref int PktLen, int defaultPktDelayTime, ref int pktDelayTime, bool bOnlyAdjustDelaytime = false) //Decide PktLen first as it's limitation of GraphicsCard + { + Random rdn = new Random(); + int checkSum = 0; + int rdCheckSum = 0, rdPktCnt = 0; + int prePktLen = 0, maxPktLen = defaultPktLen, minPktLen = 10; + int prePktDelayTime = defaultPktDelayTime, maxPktDelayTime = defaultPktDelayTime, minPktDelayTime = 0; + PktLen = defaultPktLen; + + try + { + if (!bOnlyAdjustDelaytime) + { + while (prePktLen != PktLen) + { + WriteLog("Adaptive PktLen: " + PktLen.ToString(), "debug"); + prePktLen = PktLen; + checkSum = 0; + byte[] data = new byte[PktLen]; + for (int i = 0; i < PktLen; i++) + { + data[i] = (Byte)rdn.Next(); + checkSum += data[i]; + } + DDC_SetData(data); + WinIOLib.DelayUs(maxPktDelayTime); + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + if ((PktLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((PktLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((PktLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + //reset sent info + if (SetSentInfo(0) == false) + { + SetStatusMsg("Adaptive PktLen fail."); + SetISPStatus(false); + return; + } + + if ((PktLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + maxPktLen = PktLen; + PktLen = (PktLen + minPktLen) / 2; + } + else if (PktLen == defaultPktLen) + break; + else + { + minPktLen = PktLen; + PktLen = (PktLen + maxPktLen) / 2; + } + } + if ((PktLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + PktLen = 10; + } + } + + int adjustCount = 10; + pktDelayTime = 0; + while (pktDelayTime < defaultPktDelayTime && (prePktDelayTime != pktDelayTime)) + { + prePktDelayTime = pktDelayTime; + checkSum = 0; + + byte[] data = new byte[PktLen]; + for (int i = 0; i < PktLen; i++) + { + data[i] = (Byte)rdn.Next(); + checkSum += data[i]; + } + for (int i = 0; i < adjustCount; i++) + { + DDC_SetData(data); + WinIOLib.DelayUs(pktDelayTime); + } + checkSum *= adjustCount; + checkSum = checkSum & 0xFFFF; + + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + if ((PktLen * adjustCount != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((PktLen * adjustCount != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((PktLen * adjustCount != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((PktLen * adjustCount != rdPktCnt) || (checkSum != rdCheckSum)) + { + minPktDelayTime = pktDelayTime; + pktDelayTime = (pktDelayTime + maxPktDelayTime) / 2; + } + else + { + maxPktDelayTime = pktDelayTime; + pktDelayTime = (pktDelayTime + minPktDelayTime) / 2; + } + //reset sent info + if (SetSentInfo(0) == false) + { + SetStatusMsg("Adaptive pktDelayTime fail."); + SetISPStatus(false); + return; + } + WriteLog("Adaptive pktDelayTime: " + pktDelayTime.ToString() + "us.", "debug"); + } + } + catch (Exception e) + { + frmISP.WriteLog("Exception: " + e.Message, "debug"); + ((GraphicCardI2CCtrl)_simI2cCtrl).ReCreateGraphicCardCtrl(); + defaultPktLen = 10; + AdjustPacketParam(defaultPktLen, ref maxPktLen, 10000, ref pktDelayTime, true); + } + } + + private int SendSectorData(FlashSectorInfo si, int failCnt) //leave it for debug + { + int maxPktLen = 59; + int pktDelayTime = 1000; + bool canCheckIdleStatus = false; + switch (((GraphicCardI2CCtrl)_simI2cCtrl).GetGraphicCardType) + { + case GraphicCardI2CCtrl.GRAPHIC_CARD.AMD: + { + if (_IsHDMIConnect) + { + } + else + { + maxPktLen = 11; //Need to check + } + + if (_chipType == 2) + { + pktDelayTime = 200; + } + else + { + //當maxPktLen=59時,低於1000時SendDataToDram會失敗。 + pktDelayTime = 1500; + } + } + break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.NVIDIA: + { + if (_chipType == 2) + { + pktDelayTime = 200; + } + else + { + //當maxPktLen=59時,低於1000時SendDataToDram會失敗。 + pktDelayTime = 1000; + } + } + break; + case GraphicCardI2CCtrl.GRAPHIC_CARD.INTEL: + if (_IsHDMIConnect) + { + //INTEL HDMI 的DDC大部分只有量到10KHz, Bus已經很慢了 所以不需要delay time. + pktDelayTime = 0; + maxPktLen = 11; + } + else + { + maxPktLen = 11; //Need to check + //INTEL DP + if (_chipType == 2) + { + pktDelayTime = 0; + } + else + { + pktDelayTime = 0; + } + } + break; + } + + //Adaptive packet lenght adjustment for different OS/GPU. + if (failCnt > 0) + { + maxPktLen = maxPktLen - failCnt * 5; + } + + if (maxPktLen < 10) //6E 51 Length CC F4 Data Chksum + { + maxPktLen = 10; + } + + int pktLen = 0; + int sentLen = 0; + while (sentLen < si.data.Length) + { + if ((si.data.Length - sentLen) > maxPktLen) + pktLen = maxPktLen; + else + pktLen = si.data.Length - sentLen; + + byte[] data = new byte[pktLen]; + + Array.Copy(si.data, sentLen, data, 0, pktLen); + DDC_SetData(data); + if (canCheckIdleStatus) + { + CheckISPIdleStatus(); + } + else + { + WinIOLib.DelayUs(pktDelayTime); + } + + sentLen += pktLen; + } + return si.CheckSum(); + } + private int SendSectorData(FlashSectorInfo si, int failCnt, int maxPktLen, int pktDelayTime) + { + bool canCheckIdleStatus = false; + + //Adaptive packet lenght adjustment for different OS/GPU. + if (failCnt > 0) + { + if (pktDelayTime == 0) + pktDelayTime = 200; + + pktDelayTime = pktDelayTime + 100 * failCnt; + } + + int pktLen = 0; + int sentLen = 0; + while (sentLen < si.data.Length) + { + if ((si.data.Length - sentLen) > maxPktLen) + pktLen = maxPktLen; + else + pktLen = si.data.Length - sentLen; + + byte[] data = new byte[pktLen]; + + Array.Copy(si.data, sentLen, data, 0, pktLen); + DDC_SetData(data); + if (canCheckIdleStatus) + { + CheckISPIdleStatus(); + } + else + { + WinIOLib.DelayUs(pktDelayTime); + } + + sentLen += pktLen; + } + return si.CheckSum(); + } + + List flashSectorInfo = new List(); + private void btnRunDPISP_Click(object sender, EventArgs e) + { + WriteLog("pktDelayTime: " + txtPktDelayTime.Text, "debug"); + DDC_SetToolFlag(true); + if (_binFilePath == String.Empty) + { + WriteLog("binFilePath is NULL", "debug"); + return; + } + WriteLog("Start ISP", "debug"); + //int totalFailCnt1 = 0; + int failCnt = 0; + int checkSumFailCnt = 0; + int lenFailCnt = 0; + + SetISPStatus(true); + const int MaxRetryCnt = 30; + MTKDebugCmd.InitI2CCtrl(_simI2cCtrl); + Byte[] bin = InitBinaryFile(_binFilePath); + int retryCnt = 0; + int rdCheckSum = 0, rdPktCnt = 0; + int checkSum = 0, sentLen = 0, pktLen = 0; + int totalBytes = bin.Length; + + int start = GetTickCount(); + int end = 0; + + if (flashSectorInfo.Count == 0) + { + for (int idx = 0; idx < bin.Length; idx += _flashSectorSize) + { + if ((bin.Length - idx) >= _flashSectorSize) + pktLen = _flashSectorSize; + else + pktLen = bin.Length - idx; + + FlashSectorInfo sector = new FlashSectorInfo(); + sector.Clear(); + Array.Copy(bin, idx, sector.data, 0, pktLen); + sector.CheckEmpty(); + flashSectorInfo.Add(sector); + } + } + + toolStripProgressBar1.Maximum = flashSectorInfo.Count; + toolStripProgressBar1.Value = 0; + int imgNum = 0; + retryCnt = 0; + DDC_GetISPImgNum(ref imgNum); + if (imgNum == 1) + { + MessageBox.Show(this, "Update firmware will continue without reboot at startup. Display will reboot after update success.", this.Text); + } + + IsConnect = false; + Byte chipType = 0; + while ((IsConnect == false) && (retryCnt++ < MaxRetryCnt)) + { + IsConnect = DDC_CheckMTKDevice(ref chipType); + if (IsConnect) + { + break; + } + IsConnect = DDC_CheckClientInfo(ref chipType); + if (IsConnect) + { + break; + } + IsConnect = DDC_CheckPanelInfo(ref chipType); + if (IsConnect) + { + break; + } + WinIOLib.DelayMs(1000); + } + + if (IsConnect == false) + { + SetStatusMsg("Initialize ISP connection fail."); + SetISPStatus(false); + return; + } + + _chipType = chipType; + switch (chipType) + { + case 0: { lblMTKChipType.Text = "Not Defined"; } break; + case 1: { lblMTKChipType.Text = "TSUM"; } break; + case 2: { lblMTKChipType.Text = "MST9U"; } break; + } + + // private bool DDC_CheckClientInfo(ref Byte ClientInfo, int delayTime = 1000) + + if (!IsModelNameMatch(_u8ModelName)) + { + SetStatusMsg("modelname错误"); + SetISPStatus(false); + return; + } + if (!IsChipNameMatch(_u8ChipName)) + { + SetStatusMsg("芯片型号错误"); + SetISPStatus(false); + return; + } + if (!IsPanelNameMatch(_u8PanelName)) + { + SetStatusMsg("屏型号错误"); + SetISPStatus(false); + return; + } + if (!IsBoardNameMatch(_u8BoardName)) + { + SetStatusMsg("版本号错误"); + SetISPStatus(false); + return; + } + + Application.DoEvents(); + //init file info + int rdSize = 0; + retryCnt = 0; + while (retryCnt++ < MaxRetryCnt) + { + DDC_SetRecvInfo(bin.Length); + WinIOLib.DelayMs(500); + DDC_GetRecvInfo(ref rdSize); + if (rdSize == bin.Length) + break; + } + + if (rdSize != bin.Length) + { + SetStatusMsg("Initialize file Information fail."); + SetISPStatus(false); + return; + } + + ///////Compare ISP////////////////// + List rootFlash = new List(); + Boolean canExecuteCompareISP = false; + UInt16 imgCheckSum = 0; + String path = Directory.GetCurrentDirectory(); + path += "\\rootimage.bin"; + if (System.IO.File.Exists(path)) + { + Byte[] rootBin = InitBinaryFile(path); + for (int idx = 0; idx < rootBin.Length; idx += _flashSectorSize) + { + if ((rootBin.Length - idx) >= _flashSectorSize) + pktLen = _flashSectorSize; + else + pktLen = rootBin.Length - idx; + + for (int sidx = 0; sidx < pktLen; sidx++) + { + imgCheckSum += rootBin[idx + sidx]; + } + FlashSectorInfo sector = new FlashSectorInfo(); + sector.Clear(); + Array.Copy(rootBin, idx, sector.data, 0, pktLen); + sector.CheckEmpty(); + rootFlash.Add(sector); + } + + + UInt32 crc = 0, rdCrc = 0; + int rdImgOneCheckSum = 0; + for (int idx = 0; idx < 21; idx++) + { + crc += rootFlash[255].data[0xFE0 + idx]; + } + for (int retry = 0; retry < 4; retry++) + { + DDC_GetCRC(ref rdCrc); + WinIOLib.DelayMs(500); + if (crc == rdCrc) + { + canExecuteCompareISP = true; + break; + } + } + + if (canExecuteCompareISP) + { + DDC_SetISPImgShadow(imgCheckSum); + SetStatusMsg("Initalize Fast ISP procedure..."); + WinIOLib.DelayMs(17000); + for (int retry = 0; retry < 20; retry++) + { + DDC_GetImgOneCheckSum(ref rdImgOneCheckSum); + if (imgCheckSum == rdImgOneCheckSum) + { + canExecuteCompareISP = true; + break; + } + else + { + canExecuteCompareISP = false; + WinIOLib.DelayMs(1000); + } + } + } + } + + // SetStatusMsg("Transfer Parameter adjusting ..."); + int maxPktLen = 0, pktDelayTime = 0; + AdjustPacketParam(defaultPktLen, ref maxPktLen, 10000, ref pktDelayTime); + WriteLog("maxPktLen = " + Convert.ToString(maxPktLen) + ", pktDelayTime = " + Convert.ToString(pktDelayTime) + "", "debug"); +#if DEBUG + if (Convert.ToInt32(txtPktDelayTime.Text) > 0) + pktDelayTime = Convert.ToInt32(txtPktDelayTime.Text); +#endif + retryCnt = 0; + while (retryCnt++ < MaxRetryCnt) + { + DDC_SetRecvInfo(bin.Length); + WinIOLib.DelayMs(500); + DDC_GetRecvInfo(ref rdSize); + if (rdSize == bin.Length) + break; + } + //Send data + FlashSectorInfo si; + FlashSectorInfo rootSi; + Boolean IsDiffSector = false; + start = GetTickCount(); + int wroteSectorCnt = 0; + retryCnt = 0; + for (int cnt = 0; cnt < flashSectorInfo.Count; cnt++) + { + IsDiffSector = false; + si = flashSectorInfo[cnt]; + + if (canExecuteCompareISP) + { + rootSi = rootFlash[cnt]; + for (int sIdx = 0; sIdx < 4096; sIdx++) + { + if (si.data[sIdx] != rootSi.data[sIdx]) + { + IsDiffSector = true; + break; + } + } + + if (IsDiffSector) + { + checkSum += SendSectorData(si, failCnt, maxPktLen, pktDelayTime); + checkSum &= 0xFFFF; + wroteSectorCnt++; + } + else + { + //bypass empty sector + if (SetSentInfo(sentLen + _flashSectorSize) == false) + { + SetStatusMsg("Send file fail."); + SetISPStatus(false); + return; + } + checkSum = 0; + //WinIOLib.DelayMs(50); + } + } + else + { + if (si.IsEmpty) + { + //bypass empty sector + if (SetSentInfo(sentLen + _flashSectorSize) == false) + { + SetStatusMsg("Send file fail."); + SetISPStatus(false); + return; + } + checkSum = 0; + } + else + { + checkSum += SendSectorData(si, failCnt, maxPktLen, pktDelayTime); + checkSum &= 0xFFFF; + } + } + + sentLen += _flashSectorSize; + + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + if ((sentLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((sentLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if ((sentLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt, 500); + } + if (sentLen != rdPktCnt) + { + lenFailCnt++; + } + if (checkSum != rdCheckSum) + { + checkSumFailCnt++; + } + if ((sentLen != rdPktCnt) || (checkSum != rdCheckSum)) + { + retryCnt++; + failCnt++; + sentLen -= _flashSectorSize; + checkSum = 0; + + if (sentLen < 0) + sentLen = 0; + + if (cnt >= 0) + cnt -= 1; + + //reset sent info + if (SetSentInfo(sentLen) == false) + { + SetStatusMsg("Send file fail."); + SetISPStatus(false); + return; + } + + if (retryCnt > MaxRetryCnt) + { + SetStatusMsg("Send file fail."); + SetISPStatus(false); + return; + } + } + else + { + retryCnt = 0; + } + + if (cnt < 0) + toolStripProgressBar1.Value = 0; + else + toolStripProgressBar1.Value = cnt; + end = GetTickCount() - start; + + if (sentLen >= bin.Length) + sentLen = bin.Length; + + + if ((cnt == 0) && (end > 4000)) //terminate ISP when 4K bytes per sec large than 4 sec + { + //SetStatusMsg("Procedure is terminated, because data transfer speed is abnormal."); + //btnUploadFlash.Enabled = true; + //SetISPStatus(false); + //return; + } + + // SetStatusMsg("Sent Bytes : " + sentLen.ToString() + ", " + "Elapsed Time : " + end.ToString() + " ms"); + // _u8ModelName = "mmmmmmmmmmmmm"; + // SetStatusMsg("Sent Bytes : " + sentLen.ToString() + ", " + "Elapsed Time : " + end.ToString() + " ms. Model: " + _u8ModelName); + Application.DoEvents(); + } + + UInt16 fileCheckSum = 0; + lblTransferTime.Text = end.ToString(); +#if AUTO_SEARCH + Transfer_Time = end; + Total_Transfer_Time += (ulong)end; +#endif + for (int idx = 0; idx < bin.Length; idx++) + { + fileCheckSum += bin[idx]; + } + + + //Execute ISP + DDC_RunISP(fileCheckSum); + WinIOLib.DelayMs(1000); + + toolStripProgressBar1.Value = flashSectorInfo.Count; + Application.DoEvents(); + end = GetTickCount() - start; + // SetStatusMsg("Sent Bytes : " + sentLen.ToString() + ", " + "Elapsed Time : " + end.ToString() + " ms"); + //SetStatusMsg("Sent Bytes : " + sentLen.ToString() + ", " + "Elapsed Time : " + end.ToString() + " ms"); + // SetStatusMsg("Read Bin OK. Model: " + _u8ModelName); + Application.DoEvents(); + + //check ddc is alive until system update flash finish + retryCnt = 0; + UInt32 tmpCRC = 0x89ABCDEF; + int status = 0; + int binLen = bin.Length / 1024; + int waitUpdateFWCnt = 120; + if (binLen <= 512) + { + waitUpdateFWCnt = 120; + } + else if (binLen <= 1024) + { + waitUpdateFWCnt = 240; + } + else if (binLen <= 2048) + { + waitUpdateFWCnt = 480; + } + else if (binLen <= 4096) + { + waitUpdateFWCnt = 960; + } + + while (retryCnt++ < waitUpdateFWCnt) + { + WinIOLib.DelayMs(1000); + + SetStatusMsg("Updating firmware..., " + "Elapsed Time : " + end.ToString() + " ms"); + Application.DoEvents(); + //int pktDelayTime = Convert.ToInt32(txtPktDelayTime.Text); + IsConnect = DDC_CheckMTKDevice(ref chipType/*, pktDelayTime*/); + if (IsConnect == false) + continue; + //DDC_GetSentInfo(ref rdCheckSum, ref rdPktCnt); + DDC_GetISPStatus(ref status/*, pktDelayTime*/); + if ((status == 2) || (status == 1))//0:Init, 1: fail, 2: success + break; + } + + //how to check fw is update success? + end = GetTickCount() - start; + if (status == 2) + { + Connect(); + SetStatusMsg("Update firmware success, " + "Elapsed Time : " + end.ToString() + " ms"); + //MessageBox.Show(this, "Update firmware success. Please reset the power of display.", this.Text); + } + else + { + SetStatusMsg("Update firmware fail, " + "Elapsed Time : " + end.ToString() + " ms"); + } + + SetISPStatus(false); + + if (status == 2) + { + MessageBox.Show(this, "Update fimware is success, Display will reboot. .", this.Text); + lblUpdatingFWmsg.Visible = false; + DDC_SetISPReboot(); + } + } + + Boolean CheckISPIdleStatus() + { + int status = 0; + int cnt = 0; + while ((status != 0x99) && (cnt++ < 10)) + { + DDC_GetISPStatus(ref status, 100); + } + + if (status == 0x99) + return true; + else + return false; + } + + private static string resultFolder = System.IO.Directory.GetCurrentDirectory() + "\\"; + [Conditional("DEBUG")] + public static void WriteLog(string str, string fileName) + { + System.IO.StreamWriter file = null; + + if (!System.IO.Directory.Exists(resultFolder)) + System.IO.Directory.CreateDirectory(resultFolder); + + if (fileName == "") + file = new System.IO.StreamWriter(resultFolder + DateTime.Now.ToString("yyyy-MM-dd") + ".log", true); + else + file = new System.IO.StreamWriter(resultFolder + fileName + "_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log", true); + + file.WriteLine(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss.fff: ") + str); + file.Close(); + file = null; + } + + private void cboConnectedMonitor_SelectedIndexChanged(object sender, EventArgs e) + { + WriteLog("[cboConnectedMonitor_SelectedIndexChanged] cboConnectedMonitor.SelectedIndex = " + cboConnectedMonitor.SelectedIndex, "debug"); + ((GraphicCardI2CCtrl)_simI2cCtrl).SetConnectedMonitorIndex((Byte)cboConnectedMonitor.SelectedIndex); + DDC_SetToolFlag(true); + Byte chipType = 0; + IsConnect = DDC_CheckMTKDevice(ref chipType); + int retry = 0; + while ((IsConnect == false) && (retry++ < 30)) + { + IsConnect = DDC_CheckMTKDevice(ref chipType); + } + if (IsConnect == true) + { + pnlConnState.BackColor = Color.LightGreen; + } + else + { + pnlConnState.BackColor = Color.Red; + _chipType = 0; + } + + _chipType = chipType; + switch (chipType) + { + case 0: { lblMTKChipType.Text = "Not Defined"; } break; + case 1: { lblMTKChipType.Text = "TSUM"; } break; + case 2: { lblMTKChipType.Text = "MST9U"; } break; + } + Application.DoEvents(); + DDC_GetVersion(); + Application.DoEvents(); + DDC_SetToolFlag(false); + lblConnectedPort.Text = ((GraphicCardI2CCtrl)_simI2cCtrl).GetConnectedPortTypeByIdx((Byte)cboConnectedMonitor.SelectedIndex).ToString(); + Application.DoEvents(); + } + public static Byte[] InitBinaryFile(String filepath) + { + Byte[] rdBuf = null; + + if (File.Exists(filepath) == false) + return null; + + UInt32 lastDataPosition = 0; + using (BinaryReader reader = new BinaryReader(File.Open(filepath, FileMode.Open))) + { + rdBuf = reader.ReadBytes((int)reader.BaseStream.Length); + } + + UInt32 cnt = 0; + UInt16 checkSum = 0; + Byte data = 0; + while (cnt < rdBuf.Length) + { + data = rdBuf[cnt]; + checkSum += data; + if (data != 0xFF) + { + lastDataPosition = cnt; + } + cnt++; + } + + if ((lastDataPosition & 0xFFF) > 0) + lastDataPosition = (lastDataPosition + 0x1000) & 0xFFF000; + UInt32 _progSize = 0; + _progSize = lastDataPosition; + Byte[] wrBuf = new Byte[_progSize]; + for (int idx = 0; idx < wrBuf.Length; idx++) + { + wrBuf[idx] = 0xFF; + } + int copyLen = rdBuf.Length; + if (wrBuf.Length < rdBuf.Length) + { + copyLen = wrBuf.Length; + System.Windows.Forms.MessageBox.Show("rd len : " + rdBuf.Length.ToString() + ", wr len" + wrBuf.Length.ToString()); + } + Array.Copy(rdBuf, wrBuf, copyLen); + return wrBuf; + } + + public static byte[] ReadBinSection(string filePath, long offset, int length) + { + if (!File.Exists(filePath)) + throw new FileNotFoundException("Bin file not found.", filePath); + + + byte[] buffer = new byte[length]; + using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + if (offset > fs.Length - 1) + throw new ArgumentOutOfRangeException(nameof(offset), "Offset is beyond file length."); + + fs.Seek(offset, SeekOrigin.Begin); + int bytesRead = fs.Read(buffer, 0, length); + if (bytesRead < length) + { + // If file is shorter than expected, resize buffer + Array.Resize(ref buffer, bytesRead); + } + } + return buffer; + } + } + +} + diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.resx b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.resx new file mode 100644 index 0000000..fde7c5e --- /dev/null +++ b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/frmISP.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 14 + + + 57 + + \ No newline at end of file diff --git a/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/icon/MTKLogo.bmp b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/icon/MTKLogo.bmp new file mode 100644 index 0000000..8561939 Binary files /dev/null and b/WIN10_WinISP_SrcCode_For_MOKA_20250416_1/WinISP/icon/MTKLogo.bmp differ