linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilia Mirkin <imirkin@alum.mit.edu>
To: linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Subject: [PATCH v2 1/2] edid-decode: add function to enable usage as a library
Date: Thu, 13 Feb 2020 06:39:02 -0500	[thread overview]
Message-ID: <20200213113903.23994-1-imirkin@alum.mit.edu> (raw)

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


             reply	other threads:[~2020-02-13 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 11:39 Ilia Mirkin [this message]
2020-02-13 11:39 ` [PATCH v2 2/2] edid-decode: add build rule for emscripten output Ilia Mirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213113903.23994-1-imirkin@alum.mit.edu \
    --to=imirkin@alum.mit.edu \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).