This is an automatic generated email to let you know that the following patch were queued:
Subject: edid-decode: add emscripten directory Author: Hans Verkuil <hverkuil-ci...@xs4all.nl> Date: Thu Jun 16 10:26:20 2022 +0200 Drop the _build directory from the Makefile, it's overkill. To build edid-decode.js add an emscripten directory and place the edid-decode.html and edid-decode.ico files there. Copied with permission from Ilia Mirkin's website https://people.freedesktop.org/~imirkin/edid-decode/. Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl> .gitignore | 6 +- Makefile | 23 ++++--- emscripten/edid-decode.html | 150 ++++++++++++++++++++++++++++++++++++++++++++ emscripten/edid-decode.ico | Bin 0 -> 14190 bytes 4 files changed, 167 insertions(+), 12 deletions(-) --- diff --git a/.gitignore b/.gitignore index e041bdaf0fb3..a4ab473135af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ edid-decode -edid-decode.wasm -edid-decode.js *.dSYM +*.o +emscripten/*.o +emscripten/edid-decode.wasm +emscripten/edid-decode.js diff --git a/Makefile b/Makefile index dc597f024f28..375fedb8fe25 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ endif EMXX ?= em++ SOURCES = $(wildcard *.cpp) -OBJECTS := $(patsubst %.cpp, _build/%.o, $(SOURCES)) +OBJECTS := $(patsubst %.cpp, %.o, $(SOURCES)) +EMOBJECTS := $(patsubst %.cpp, emscripten/%.o, $(SOURCES)) WARN_FLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wimplicit-fallthrough @@ -24,21 +25,23 @@ all: edid-decode sha = -DSHA=$(shell if test -d .git ; then git rev-parse --short=12 HEAD ; fi) date = -DDATE=$(shell if test -d .git ; then TZ=UTC git show --quiet --date='format-local:"%F %T"' --format='%cd'; fi) -edid-decode: makebuilddir $(OBJECTS) edid-decode.h oui.h Makefile - $(CXX) $(LDFLAGS) $(WARN_FLAGS) -g $(sha) $(date) -o $@ $(OBJECTS) -lm +edid-decode: $(OBJECTS) + $(CXX) $(LDFLAGS) -g -o $@ $(OBJECTS) -lm -edid-decode.js: $(SOURCES) edid-decode.h oui.h Makefile - $(EMXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(WARN_FLAGS) $(sha) $(date) -s EXPORTED_FUNCTIONS='["_parse_edid"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o $@ $(SOURCES) -lm +edid-decode.js: emscripten/edid-decode.js -_build/%.o: %.cpp +emscripten/edid-decode.js: $(EMOBJECTS) + $(EMXX) $(LDFLAGS) -s EXPORTED_FUNCTIONS='["_parse_edid"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o $@ $(EMOBJECTS) -lm + +%.o: %.cpp edid-decode.h oui.h Makefile $(CXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(WARN_FLAGS) -g $(sha) $(date) -o $@ -c $< -makebuilddir: - mkdir -p _build +emscripten/%.o: %.cpp edid-decode.h oui.h Makefile + $(EMXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(WARN_FLAGS) $(sha) $(date) -o $@ -c $< clean: - rm -rf _build - rm -f edid-decode edid-decode.js edid-decode.wasm + rm -f *.o emscripten/*.o + rm -f edid-decode emscripten/edid-decode.js emscripten/edid-decode.wasm install: mkdir -p $(DESTDIR)$(bindir) diff --git a/emscripten/edid-decode.html b/emscripten/edid-decode.html new file mode 100644 index 000000000000..143a3a62058f --- /dev/null +++ b/emscripten/edid-decode.html @@ -0,0 +1,150 @@ +<!DOCTYPE html> +<html lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style id="stndz-style"></style> + + + <link rel="icon" type="image/x-icon" href="./edid-decode.ico"> + + <title>EDID Decode</title> + <style> + body { + font-family: arial; + margin: 0; + padding: none; + } + + textarea { + 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; + } + + button { + margin: 10px; + } + + h3 { margin: 0px; } + </style> + </head> + <body> + <div style="display:flex"> + <div style="margin:10px"> + <h3 style="float:left">EDID</h3> + <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> + <button id="process">Process</button> + <div><a href="https://git.linuxtv.org/edid-decode.git/">edid-decode.git</a></div> + <br> + Credits: copied from Ilia Mirkin's website https://people.freedesktop.org/~imirkin/edid-decode/ + <textarea readonly="" id="error" style="width: 40vw; height: 100px; resize: none;"></textarea> + </div> + <div style="margin:10px"> + <h3>Parsed</h3> + <textarea readonly="" id="output" rows="8" style="width:55vw; height: calc(100vh - 80px)"></textarea> + </div> + + <script type="text/javascript"> + +document.getElementById("upload").addEventListener("change", function(e) { + if (typeof WebAssembly === 'undefined') return; + document.getElementById("output").value = ""; + document.getElementById("error").value = ""; + + var input = e.target; + var file = input.files[0]; + if (!file) return; + var fr = new FileReader(); + fr.onload = function(e) { + process(new Uint8Array(e.target.result)); + } + fr.readAsArrayBuffer(file); +}); + +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); +}); + +function process(input) { + FS.writeFile("input-file", input); + Module.ccall('parse_edid', 'number', ['string'], ['input-file']); +/* + // Look for the hex in the EDID output + var output = document.getElementById("output").value; + var m = output.match(/^edid-decode \(hex\):\n([0-9a-f \n]*)\n/ms); + if (m) { + var hex = m[1].replace(/\s/g, ''); + console.log(hex); + } +*/ +} + + var Module = { + noInitialRun: true, + preRun: [ + ], + postRun: [], + print: (function() { + var element = document.getElementById('output'); + if (element) element.value = ''; // clear browser cache + return function(text) { + if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); + // These replacements are necessary if you render to raw HTML + //text = text.replace(/&/g, "&"); + //text = text.replace(/</g, "<"); + //text = text.replace(/>/g, ">"); + //text = text.replace('\n', '<br>', 'g'); + console.log(text); + if (element) { + element.value += text + "\n"; + element.scrollTop = element.scrollHeight; // focus on bottom + } + }; + })(), + printErr: (function() { + var element = document.getElementById('error'); + if (element) element.value = ''; // clear browser cache + return function(text) { + if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); + console.error(text); + if (element) { + element.value += text + "\n"; + element.scrollTop = element.scrollHeight; + } + }; + })(), + setStatus: function(text) { + if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; + if (text === Module.setStatus.last.text) return; + console.log(text); + }, + totalDependencies: 0, + monitorRunDependencies: function(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); + } + }; + Module.setStatus('Downloading...'); + window.onerror = function(event) { + // TODO: do not warn on ok events like simulating an infinite loop or exitStatus + Module.setStatus('Exception thrown, see JavaScript console'); + Module.setStatus = function(text) { + if (text) Module.printErr('[post-exception status] ' + text); + }; + }; + </script> + <script async="" type="text/javascript" src="./edid-decode.js"></script> + + +</div></body></html> diff --git a/emscripten/edid-decode.ico b/emscripten/edid-decode.ico new file mode 100644 index 000000000000..274f6f810de8 Binary files /dev/null and b/emscripten/edid-decode.ico differ _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits