public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [RFC PATCH 2/3] lib/igt_chamelium: add support for GetLastInfoFrame
Date: Tue, 16 Jul 2019 14:58:13 +0300	[thread overview]
Message-ID: <20190716115814.17676-3-simon.ser@intel.com> (raw)
In-Reply-To: <20190716115814.17676-1-simon.ser@intel.com>

This new call retrieves the last InfoFrame received by the Chamelium board.

TODO: detect GetLastInfoFrame support

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 lib/igt_chamelium.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_chamelium.h | 18 ++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 966d78dce146..cbf9a012bdf8 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -960,6 +960,58 @@ int chamelium_get_captured_frame_count(struct chamelium *chamelium)
 	return ret;
 }
 
+static const char *
+chamelium_infoframe_type_str(enum chamelium_infoframe_type type)
+{
+	switch (type) {
+	case CHAMELIUM_INFOFRAME_AVI:
+		return "avi";
+	case CHAMELIUM_INFOFRAME_AUDIO:
+		return "audio";
+	case CHAMELIUM_INFOFRAME_MPEG:
+		return "mpeg";
+	case CHAMELIUM_INFOFRAME_VENDOR:
+		return "vendor";
+	}
+	assert(0); /* unreachable */
+}
+
+struct chamelium_infoframe *
+chamelium_get_last_infoframe(struct chamelium *chamelium,
+			     struct chamelium_port *port,
+			     enum chamelium_infoframe_type type)
+{
+	xmlrpc_value *res, *res_version, *res_payload;
+	struct chamelium_infoframe *infoframe;
+	const unsigned char *payload;
+
+	res = chamelium_rpc(chamelium, NULL, "GetLastInfoFrame", "(is)",
+			    port->id, chamelium_infoframe_type_str(type));
+	xmlrpc_struct_find_value(&chamelium->env, res, "version", &res_version);
+	xmlrpc_struct_find_value(&chamelium->env, res, "payload", &res_payload);
+	infoframe = calloc(1, sizeof(*infoframe));
+	xmlrpc_read_int(&chamelium->env, res_version, &infoframe->version);
+	xmlrpc_read_base64(&chamelium->env, res_payload,
+			   &infoframe->payload_size, &payload);
+	/* xmlrpc-c's docs say payload is actually not constant */
+	infoframe->payload = (uint8_t *) payload;
+	xmlrpc_DECREF(res_version);
+	xmlrpc_DECREF(res_payload);
+	xmlrpc_DECREF(res);
+
+	if (infoframe->payload_size == 0) {
+		chamelium_infoframe_destroy(infoframe);
+		return NULL;
+	}
+	return infoframe;
+}
+
+void chamelium_infoframe_destroy(struct chamelium_infoframe *infoframe)
+{
+	free(infoframe->payload);
+	free(infoframe);
+}
+
 /**
  * chamelium_supports_get_audio_format: check the Chamelium device supports
  * retrieving the capture audio format.
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index ce9e9ced75d9..1f1cb7cac727 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -59,6 +59,19 @@ struct chamelium_audio_file {
 	int channels;
 };
 
+enum chamelium_infoframe_type {
+	CHAMELIUM_INFOFRAME_AVI,
+	CHAMELIUM_INFOFRAME_AUDIO,
+	CHAMELIUM_INFOFRAME_MPEG,
+	CHAMELIUM_INFOFRAME_VENDOR,
+};
+
+struct chamelium_infoframe {
+	int version;
+	size_t payload_size;
+	uint8_t *payload;
+};
+
 struct chamelium_edid;
 
 /**
@@ -122,6 +135,10 @@ void chamelium_start_capture(struct chamelium *chamelium,
 void chamelium_stop_capture(struct chamelium *chamelium, int frame_count);
 void chamelium_capture(struct chamelium *chamelium, struct chamelium_port *port,
 		       int x, int y, int w, int h, int frame_count);
+struct chamelium_infoframe *
+chamelium_get_last_infoframe(struct chamelium *chamelium,
+			     struct chamelium_port *port,
+			     enum chamelium_infoframe_type type);
 bool chamelium_has_audio_support(struct chamelium *chamelium,
 				 struct chamelium_port *port);
 void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
@@ -166,5 +183,6 @@ void chamelium_crop_analog_frame(struct chamelium_frame_dump *dump, int width,
 				 int height);
 void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
 void chamelium_destroy_audio_file(struct chamelium_audio_file *audio_file);
+void chamelium_infoframe_destroy(struct chamelium_infoframe *infoframe);
 
 #endif /* IGT_CHAMELIUM_H */
-- 
2.22.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-07-16 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 11:58 [igt-dev] [RFC PATCH 0/3] Chamelium audio InfoFrame tests Simon Ser
2019-07-16 11:58 ` [igt-dev] [RFC PATCH 1/3] lib/igt_infoframe: new library Simon Ser
2019-07-16 11:58 ` Simon Ser [this message]
2019-07-16 11:58 ` [igt-dev] [RFC PATCH 3/3] tests/kms_chamelium: add InfoFrame checks to audio tests Simon Ser
2019-07-17 13:36   ` Martin Peres
2019-07-16 13:18 ` [igt-dev] ✓ Fi.CI.BAT: success for Chamelium audio InfoFrame tests Patchwork
2019-07-16 14:26 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20190716115814.17676-3-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.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