summaryrefslogtreecommitdiff
path: root/lib/igt_chamelium.c
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-06-11 13:25:07 +0300
committerSimon Ser <simon.ser@intel.com>2019-07-17 17:41:23 +0300
commitce3cf9b933eeb361a58e3d850320c6119f07217f (patch)
tree9254461d3f50cef212e63007885f673ebefa11d2 /lib/igt_chamelium.c
parentb7e0177300606b70b23f379138d0df1fb0ba3cb5 (diff)
lib/igt_chamelium: add chamelium_port_get_video_params
This new XML-RPC call allows to retrieve mode information from the Chamelium. We can use it to check the mode we've chosen has been applied correctly. The method has been added to the Chameleon API in commit [1]. [1]: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/1df012d6ac9429a58a5e0f9362a1ff98f1bff8a7 Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib/igt_chamelium.c')
-rw-r--r--lib/igt_chamelium.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 966d78dc..c332291e 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <errno.h>
+#include <math.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>
#include <pthread.h>
@@ -657,6 +658,63 @@ void chamelium_port_get_resolution(struct chamelium *chamelium,
xmlrpc_DECREF(res);
}
+static void read_int_from_xml_struct(struct chamelium *chamelium,
+ xmlrpc_value *struct_val, const char *key,
+ int *dst)
+{
+ xmlrpc_value *val = NULL;
+
+ xmlrpc_struct_find_value(&chamelium->env, struct_val, key, &val);
+ if (val) {
+ xmlrpc_read_int(&chamelium->env, val, dst);
+ xmlrpc_DECREF(val);
+ } else
+ *dst = -1;
+}
+
+static void video_params_from_xml(struct chamelium *chamelium,
+ xmlrpc_value *res,
+ struct chamelium_video_params *params)
+{
+ xmlrpc_value *val = NULL;
+
+ xmlrpc_struct_find_value(&chamelium->env, res, "clock", &val);
+ if (val) {
+ xmlrpc_read_double(&chamelium->env, val, &params->clock);
+ xmlrpc_DECREF(val);
+ } else
+ params->clock = NAN;
+
+ read_int_from_xml_struct(chamelium, res, "htotal", &params->htotal);
+ read_int_from_xml_struct(chamelium, res, "hactive", &params->hactive);
+ read_int_from_xml_struct(chamelium, res, "hsync_offset",
+ &params->hsync_offset);
+ read_int_from_xml_struct(chamelium, res, "hsync_width",
+ &params->hsync_width);
+ read_int_from_xml_struct(chamelium, res, "hsync_polarity",
+ &params->hsync_polarity);
+ read_int_from_xml_struct(chamelium, res, "vtotal", &params->vtotal);
+ read_int_from_xml_struct(chamelium, res, "vactive", &params->vactive);
+ read_int_from_xml_struct(chamelium, res, "vsync_offset",
+ &params->vsync_offset);
+ read_int_from_xml_struct(chamelium, res, "vsync_width",
+ &params->vsync_width);
+ read_int_from_xml_struct(chamelium, res, "vsync_polarity",
+ &params->vsync_polarity);
+}
+
+void chamelium_port_get_video_params(struct chamelium *chamelium,
+ struct chamelium_port *port,
+ struct chamelium_video_params *params)
+{
+ xmlrpc_value *res;
+
+ res = chamelium_rpc(chamelium, NULL, "GetVideoParams", "(i)", port->id);
+ video_params_from_xml(chamelium, res, params);
+
+ xmlrpc_DECREF(res);
+}
+
static void chamelium_get_captured_resolution(struct chamelium *chamelium,
int *w, int *h)
{