[PATCH 1/2] edid-decode: add function to enable usage as a library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 edid-decode.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/edid-decode.cpp b/edid-decode.cpp
index ef50da2..fd17bc6 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -1005,3 +1005,21 @@ int main(int argc, char **argv)
 		return edid_from_file(argv[optind], argv[optind + 1], out_fmt);
 	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, NULL, OUT_FMT_DEFAULT);
+	return ret ? ret : state.parse_edid();
+}
+#endif
-- 
2.24.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux