linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] edid-decode: add function to enable usage as a library
@ 2020-02-13 11:39 Ilia Mirkin
  2020-02-13 11:39 ` [PATCH v2 2/2] edid-decode: add build rule for emscripten output Ilia Mirkin
  0 siblings, 1 reply; 2+ messages in thread
From: Ilia Mirkin @ 2020-02-13 11:39 UTC (permalink / raw)
  To: linux-media, hverkuil-cisco; +Cc: Ilia Mirkin

This is helpful for an emscripten setup, as there's no great way to
reinitialize the object from scratch.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---

v2: rebase, move opening brace to new line

 edid-decode.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/edid-decode.cpp b/edid-decode.cpp
index 47135a9..0473bbf 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -1214,3 +1214,22 @@ int main(int argc, char **argv)
 
 	return ret ? ret : state.parse_edid();
 }
+
+#ifdef __EMSCRIPTEN__
+/*
+ * The surrounding JavaScript implementation will call this function
+ * 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)
+{
+	for (unsigned i = 0; i < EDID_MAX_BLOCKS + 1; i++) {
+		s_msgs[i][0].clear();
+		s_msgs[i][1].clear();
+	}
+	options[OptCheck] = 1;
+	state = edid_state();
+	int ret = edid_from_file(input);
+	return ret ? ret : state.parse_edid();
+}
+#endif
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-13 11:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 11:39 [PATCH v2 1/2] edid-decode: add function to enable usage as a library Ilia Mirkin
2020-02-13 11:39 ` [PATCH v2 2/2] edid-decode: add build rule for emscripten output Ilia Mirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).