public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: add chamelium_port_get_video_params
@ 2019-07-03  7:57 Simon Ser
  2019-07-03  7:57 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: add chamelium_supports_get_video_params Simon Ser
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Simon Ser @ 2019-07-03  7:57 UTC (permalink / raw)
  To: igt-dev; +Cc: martin.peres

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.

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

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 966d78dce146..c332291ef305 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)
 {
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index ce9e9ced75d9..cd5813821fb4 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -53,6 +53,12 @@ enum chamelium_check {
 	CHAMELIUM_CHECK_CRC,
 };
 
+struct chamelium_video_params {
+	double clock;
+	int htotal, hactive, hsync_offset, hsync_width, hsync_polarity;
+	int vtotal, vactive, vsync_offset, vsync_width, vsync_polarity;
+};
+
 struct chamelium_audio_file {
 	char *path;
 	int rate; /* Hz */
@@ -113,6 +119,9 @@ void chamelium_port_set_ddc_state(struct chamelium *chamelium,
 void chamelium_port_get_resolution(struct chamelium *chamelium,
 				   struct chamelium_port *port,
 				   int *x, int *y);
+void chamelium_port_get_video_params(struct chamelium *chamelium,
+				     struct chamelium_port *port,
+				     struct chamelium_video_params *params);
 igt_crc_t *chamelium_get_crc_for_area(struct chamelium *chamelium,
 				      struct chamelium_port *port,
 				      int x, int y, int w, int h);
-- 
2.22.0

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-17 14:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03  7:57 [igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: add chamelium_port_get_video_params Simon Ser
2019-07-03  7:57 ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: add chamelium_supports_get_video_params Simon Ser
2019-07-03  7:57 ` [igt-dev] [PATCH i-g-t 3/3] tests/kms_chamelium: add a test checking modes Simon Ser
2019-07-03 14:14   ` Peres, Martin
2019-07-04  7:25     ` Ser, Simon
2019-07-17 13:26       ` Martin Peres
2019-07-17 14:36         ` Ser, Simon
2019-07-03  8:32 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] lib/igt_chamelium: add chamelium_port_get_video_params Patchwork
2019-07-04  1:36 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox