summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-07-15 17:49:08 +0300
committerSimon Ser <simon.ser@intel.com>2019-08-14 13:20:32 +0300
commit789fc28fd46d1cc6d3b4abf9b74b77a5b3f34a71 (patch)
tree4cfdf5c726a3090d8b05f7d1edca494569c22ba2 /lib
parente9c94e6955e1aa1af61ec66a2298e60a7e6b20fb (diff)
lib/igt_chamelium: add support for GetLastInfoFrame
This new call retrieves the last InfoFrame received by the Chamelium board. Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_chamelium.c57
-rw-r--r--lib/igt_chamelium.h19
2 files changed, 76 insertions, 0 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 301e9d21..a09473d0 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1124,6 +1124,63 @@ int chamelium_get_captured_frame_count(struct chamelium *chamelium)
return ret;
}
+bool chamelium_supports_get_last_infoframe(struct chamelium *chamelium)
+{
+ return chamelium_supports_method(chamelium, "GetLastInfoFrame");
+}
+
+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);
+}
+
bool chamelium_has_audio_support(struct chamelium *chamelium,
struct chamelium_port *port)
{
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index b6b7eb44..8e3e3320 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -65,6 +65,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;
/**
@@ -141,6 +154,11 @@ 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);
+bool chamelium_supports_get_last_infoframe(struct chamelium *chamelium);
+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,
@@ -185,5 +203,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 */