This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: edid-decode: improved diagonal handling Author: Hans Verkuil <hverk...@xs4all.nl> Date: Thu Apr 24 13:52:47 2025 +0200 The diagonal (if specified) is output right after the hex dump and the EDID parser can detect it. The --diagonal option will always override it, if present. Do a sanity check of the diagonal. Add a field in edid-decode.html to allow entering the diagonal in the webpage. Signed-off-by: Hans Verkuil <hverk...@xs4all.nl> utils/edid-decode/edid-decode.cpp | 43 +++++++++++++++++++++++---- utils/edid-decode/emscripten/edid-decode.html | 20 ++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=7ea2ea87e06115774350cba5f8114c4c7614ef04 diff --git a/utils/edid-decode/edid-decode.cpp b/utils/edid-decode/edid-decode.cpp index 64d3efcbda7d..3442893775b6 100644 --- a/utils/edid-decode/edid-decode.cpp +++ b/utils/edid-decode/edid-decode.cpp @@ -1083,8 +1083,21 @@ static bool extract_edid(int fd, FILE *error) start = strstr(data, "edid-decode (hex):"); if (!start) start = strstr(data, "EDID (hex):"); - if (start) - return extract_edid_hex(strchr(start, ':')); + if (start) { + bool ok = extract_edid_hex(strchr(start, ':')); + float diag; + + if (state.diagonal) + return ok; + + start = strstr(start, "Diagonal: "); + if (start) + start = strchr(start, ' ') + 1; + if (ok && start && sscanf(start, "%f\"", &diag) == 1) { + state.diagonal = diag; + } + return ok; + } /* Look for C-array */ start = strstr(data, "unsigned char edid[] = {"); @@ -1558,6 +1571,10 @@ int edid_state::parse_edid() printf("\n"); } printf("----------------\n\n"); + if (diagonal) { + printf("Diagonal: %.1f\"\n\n", diagonal); + printf("----------------\n\n"); + } } block = block_name(0x00); @@ -2655,9 +2672,18 @@ int main(int argc, char **argv) std::exit(EXIT_FAILURE); } break; - case OptDiag: - state.diagonal = strtod(optarg, NULL); + case OptDiag: { + double diag; + + diag = strtod(optarg, NULL); + if (isnormal(diag)) { + if (diag == 0 || (diag >= 10 && diag <= 2559)) + state.diagonal = diag; + else + fprintf(stderr, "Ignored diagonal, expected to be between 10 and 2559 inches.\n"); + } break; + } #ifdef __HAS_I2C_DEV__ case OptI2CAdapter: { std::string device = optarg; @@ -2887,7 +2913,7 @@ int main(int argc, char **argv) * each time it wants to decode an EDID. So this should reset all the * state and start over. */ -extern "C" int parse_edid(const char *input) +extern "C" int parse_edid(const char *input, float diag) { for (unsigned i = 0; i < EDID_MAX_BLOCKS + 1; i++) { s_msgs[i][0].clear(); @@ -2899,6 +2925,13 @@ extern "C" int parse_edid(const char *input) options[OptSkipSHA] = 0; options[OptUTF8] = 1; state = edid_state(); + // Accept values + if (isnormal(diag) && diag) { + if (diag >= 10 && diag <= 2559) + state.diagonal = diag; + else + fprintf(stderr, "Ignored diagonal, expected to be between 10 and 2559 inches.\n"); + } int ret = edid_from_file(input, stderr); return ret ? ret : state.parse_edid(); } diff --git a/utils/edid-decode/emscripten/edid-decode.html b/utils/edid-decode/emscripten/edid-decode.html index 49d91cf7b552..5d437cff2e65 100644 --- a/utils/edid-decode/emscripten/edid-decode.html +++ b/utils/edid-decode/emscripten/edid-decode.html @@ -22,6 +22,16 @@ outline: none; } + input { + margin-top: 10px; + border: 0; + display: block; + background-color: black; + color: white; + font-family: 'Lucida Console', Monaco, monospace; + outline: none; + } + #error { background-color: white; color: red; @@ -41,6 +51,8 @@ <input type="file" id="upload" style="float:left; margin-left: 10px;"> <div style="clear:both"></div> <textarea id="input" style="width:40vw; height: 300px;" placeholder="Paste EDID hex here"></textarea> + <div style="clear:both"></div> + <input type="number" id="diagonal" min="10" max="2559" step="0.1" style="width:40vw; height: 14px;" placeholder="Diagonal of the display in inches (optional)"></input> <button id="process">Process</button> <div><a href="https://git.linuxtv.org/v4l-utils.git/">v4l-utils.git</a></div> <br> @@ -64,7 +76,7 @@ document.getElementById("upload").addEventListener("change", function(e) { if (!file) return; var fr = new FileReader(); fr.onload = function(e) { - process(new Uint8Array(e.target.result)); + process(new Uint8Array(e.target.result), document.getElementById("diagonal").value); } fr.readAsArrayBuffer(file); }); @@ -73,12 +85,12 @@ document.getElementById("process").addEventListener("click", function(e) { if (typeof WebAssembly === 'undefined') return; document.getElementById("output").value = ""; document.getElementById("error").value = ""; - process(document.getElementById("input").value); + process(document.getElementById("input").value, document.getElementById("diagonal").value); }); -function process(input) { +function process(input, diag) { FS.writeFile("input-file", input); - Module.ccall('parse_edid', 'number', ['string'], ['input-file']); + Module.ccall('parse_edid', 'number', ['string', 'number'], ['input-file', diag]); /* // Look for the hex in the EDID output var output = document.getElementById("output").value;