All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: martin.peres@intel.com
Subject: [igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: add chamelium_port_get_video_params
Date: Wed,  3 Jul 2019 10:57:29 +0300	[thread overview]
Message-ID: <20190703075731.7785-1-simon.ser@intel.com> (raw)

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

             reply	other threads:[~2019-07-03  7:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  7:57 Simon Ser [this message]
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

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=20190703075731.7785-1-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=martin.peres@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.