From f85b484bcdcf23d89150af14cf487cfbb29e0a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Sandstr=C3=B6m?= Date: Mon, 22 Apr 2024 20:41:34 +0200 Subject: [PATCH] last try?? changed the const to a byte pointer, then on start laod a edid into a vectro and point to it. --- IddSampleDriver/Driver.cpp | 116 +++++++++++++++---------------------- IddSampleDriver/Driver.h | 5 +- 2 files changed, 51 insertions(+), 70 deletions(-) diff --git a/IddSampleDriver/Driver.cpp b/IddSampleDriver/Driver.cpp index 2171bf7..224626c 100644 --- a/IddSampleDriver/Driver.cpp +++ b/IddSampleDriver/Driver.cpp @@ -24,8 +24,6 @@ Environment: #include // jocke added for comming dynamic edid loading #include -#include -#include using namespace std; using namespace Microsoft::IndirectDisp; @@ -118,62 +116,7 @@ vector split(string& input, char delimiter) } return result; } -// jocke added for comming dynamix edid loading -using BYTE = uint8_t; // Alias for uint8_t -std::vector loadedid(const std::string& filename) { - std::ifstream file(filename, std::ios::binary); - if (file.is_open()) { - // Read file into vector - std::vector bytes(std::istreambuf_iterator(file), {}); - - // Modify bytes at positions 8, 9, 10, and 11 - bytes[8] = 0x36; - bytes[9] = 0x94; - bytes[10] = 0x37; - bytes[11] = 0x13; - - // Calculate checksum - int checksum = 0; - for (int i = 0; i < 128; ++i) { - checksum += bytes[i]; - } - checksum %= 256; - uint8_t bytesum = static_cast(checksum); - bytes[128] = bytesum; // Store checksum as a byte, all byte number might be off by 1 (don't knwo how c++ handles array/vector position 0, if it's resereved or filed with data - - return bytes; - } - else { - std::ifstream filedef("default.bin", std::ios::binary); - if (filedef.is_open()) { - // Read file into vector this is our pre patched default edid - std::vector bytes(std::istreambuf_iterator(filedef), {}); - return bytes; - } - else { // if all fiels are gone from install folder then use our minimal hardcoded edid - string incode = " {\ - 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x36,0x94,0x37,0x13,0x00,0x00,0x00,0x00,\ - 0x05,0x16,0x01,0x03,0x6D,0x32,0x1C,0x78,0xEA,0x5E,0xC0,0xA4,0x59,0x4A,0x98,0x25,\ - 0x20,0x50,0x54,0x00,0x00,0x00,0xD1,0xC0,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\ - 0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,0x58,0x2C,\ - 0x45,0x00,0xF4,0x19,0x11,0x00,0x00,0x1E,0x00,0x00,0x00,0xFF,0x00,0x4D,0x54,0x54,\ - 0x31,0x33,0x33,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFD,0x00,0x3B,\ - 0x3D,0x42,0x44,0x0F,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,\ - 0x00,0x4D,0x54,0x54,0x31,0x33,0x33,0x37,0x0A,0x20,0x20,0x20,0x20,0x20,0x00,0x83}"; - - std::vector bytes(incode.begin(), incode.end()); - return (bytes); - } - } -} - -void dynedidmem(const std::vector&fileBytes, BYTE * array) { - // Assuming 'fileBytes' contains the binary data - for (std::size_t i = 0; i < fileBytes.size(); ++i) { - array[i] = fileBytes[i]; - } -} void loadOptions(string filepath) { ifstream ifs(filepath); @@ -488,17 +431,54 @@ constexpr DISPLAYCONFIG_VIDEO_SIGNAL_INFO dispinfo(UINT32 h, UINT32 v, UINT32 r) DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE }; } +std::vector s_knownMonitorEdidData = {}; + +// Jocke, createing a 512 byte array filled with 0 values (largest edid bin without breaking standards) + +static void edidLoad(const std::string& filename) { + std::ifstream file(filename, std::ios::binary); + if (file.is_open()) { + // Read file into vector + std::vector s_knownMonitorEdidData(std::istreambuf_iterator(file), {}); + + // Modify bytes at positions 8, 9, 10, and 11 + s_knownMonitorEdidData[8] = 0x36; + s_knownMonitorEdidData[9] = 0x94; + s_knownMonitorEdidData[10] = 0x37; + s_knownMonitorEdidData[11] = 0x13; + + // Calculate checksum + int checksum = 0; + for (int i = 0; i < 128; ++i) { + checksum += s_knownMonitorEdidData[i]; + } + checksum %= 256; + uint8_t bytesum = static_cast(checksum); + s_knownMonitorEdidData[127] = bytesum; // Store checksum as a byte, all byte number might be off by 1 (don't knwo how c++ handles array/vector position 0, if it's resereved or filed with data + } + else { + std::ifstream filedef("default.bin", std::ios::binary); + if (filedef.is_open()) { + // Read file into vector this is our pre patched default edid + std::vector s_knownMonitorEdidData(std::istreambuf_iterator(filedef), {}); + } + else { // if all fiels are gone from install folder then use our minimal hardcoded edid + string incode = " {\ + 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x36,0x94,0x37,0x13,0x00,0x00,0x00,0x00,\ + 0x05,0x16,0x01,0x03,0x6D,0x32,0x1C,0x78,0xEA,0x5E,0xC0,0xA4,0x59,0x4A,0x98,0x25,\ + 0x20,0x50,0x54,0x00,0x00,0x00,0xD1,0xC0,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\ + 0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,0x58,0x2C,\ + 0x45,0x00,0xF4,0x19,0x11,0x00,0x00,0x1E,0x00,0x00,0x00,0xFF,0x00,0x4D,0x54,0x54,\ + 0x31,0x33,0x33,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFD,0x00,0x3B,\ + 0x3D,0x42,0x44,0x0F,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,\ + 0x00,0x4D,0x54,0x54,0x31,0x33,0x33,0x37,0x0A,0x20,0x20,0x20,0x20,0x20,0x00,0x83}"; + + std::vector s_knownMonitorEdidData(incode.begin(), incode.end()); + } + } +}; -// Jocke, the plan was away with [] and = loadedid(private.edid) -//const BYTE IndirectDeviceContext::s_KnownMonitorEdid = loadedid("user_edid.bin"); didn't work, something about const dec�ared in driver.h - -std::vector loade(loadedid("user_edid.bin")); - -std::array tempArray; -dynedidmem(loade, tempArray.data()); - -std::copy(tempArray.begin(), tempArray.end(), const_cast(IndirectDeviceContext::s_KnownMonitorEdid)); // This is a sample monitor EDID - FOR SAMPLE PURPOSES ONLY /* const BYTE IndirectDeviceContext::s_KnownMonitorEdid[] = { @@ -626,8 +606,8 @@ void IndirectDeviceContext::CreateMonitor(unsigned int index) { MonitorInfo.ConnectorIndex = index; MonitorInfo.MonitorDescription.Size = sizeof(MonitorInfo.MonitorDescription); MonitorInfo.MonitorDescription.Type = IDDCX_MONITOR_DESCRIPTION_TYPE_EDID; - MonitorInfo.MonitorDescription.DataSize = sizeof(s_KnownMonitorEdid); - MonitorInfo.MonitorDescription.pData = const_cast(s_KnownMonitorEdid); + MonitorInfo.MonitorDescription.DataSize = sizeof(s_knownMonitorEdidData); + MonitorInfo.MonitorDescription.pData = s_knownMonitorEdidData.data(); // ============================== // TODO: The monitor's container ID should be distinct from "this" device's container ID if the monitor is not diff --git a/IddSampleDriver/Driver.h b/IddSampleDriver/Driver.h index 2502155..5bb76b0 100644 --- a/IddSampleDriver/Driver.h +++ b/IddSampleDriver/Driver.h @@ -100,7 +100,8 @@ namespace Microsoft public: static const DISPLAYCONFIG_VIDEO_SIGNAL_INFO s_KnownMonitorModes[]; - static const BYTE s_KnownMonitorEdid[]; + static BYTE* s_KnownMonitorEdid(); + static std::vector s_knownMonitorEdidData; }; - } + }; } \ No newline at end of file