[igt-dev] [PATCH i-g-t v2 3/4] lib: Add new chamelium method: UnplugHPD
José Roberto de Souza
jose.souza at intel.com
Fri Jun 28 21:40:08 UTC 2019
This is a recently added method that will just unplug the hotplug
detection pin in chamelium, the regular Unplug also unplug the
DDC and EDID.
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
lib/igt_chamelium.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
lib/igt_chamelium.h | 2 ++
2 files changed, 53 insertions(+)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index d3ddba6a..f407e395 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -326,6 +326,31 @@ static xmlrpc_value *__chamelium_rpc(struct chamelium *chamelium,
return res;
}
+/*
+ * Same as chamelium_rpc() but it returns 0 when successfully executed
+ * otherwise it return the error code instead of fail the test.
+ */
+static int chamelium_try_rpc(struct chamelium *chamelium,
+ struct chamelium_port *fsm_port,
+ xmlrpc_value **res,
+ const char *method_name,
+ const char *format_str,
+ ...)
+{
+ va_list va_args;
+
+ va_start(va_args, format_str);
+ *res = __chamelium_rpc_va(chamelium, fsm_port, method_name,
+ format_str, va_args);
+ va_end(va_args);
+
+ if (chamelium->env.fault_occurred)
+ igt_debug("Chamelium RPC call failed: %s\n",
+ chamelium->env.fault_string);
+
+ return chamelium->env.fault_code;
+}
+
static xmlrpc_value *chamelium_rpc(struct chamelium *chamelium,
struct chamelium_port *fsm_port,
const char *method_name,
@@ -376,6 +401,32 @@ void chamelium_unplug(struct chamelium *chamelium, struct chamelium_port *port)
port->id));
}
+/*
+ * Unplug only the hotplug detection pin, leaving the data lanes intact.
+ */
+void chamelium_unplug_hpd(struct chamelium *chamelium,
+ struct chamelium_port *port)
+{
+ xmlrpc_value *res;
+ int ret;
+
+ igt_debug("Unplugging hpd port %s\n", port->name);
+ ret = chamelium_try_rpc(chamelium, NULL, &res, "UnplugHPD", "(i)",
+ port->id);
+ if (ret) {
+ /*
+ * This is a new method so if chamelium daemon still do not
+ * support it, skip the test otherwise fail the test.
+ */
+ igt_require(ret != XMLRPC_NO_SUCH_METHOD_ERROR);
+ igt_assert_f(ret == XMLRPC_NO_SUCH_METHOD_ERROR,
+ "Chamelium RPC call failed: %s\n",
+ chamelium->env.fault_string);
+ } else {
+ xmlrpc_DECREF(res);
+ }
+}
+
/**
* chamelium_is_plugged:
* @chamelium: The Chamelium instance to use
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index ce9e9ced..61efca20 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -87,6 +87,8 @@ const char *chamelium_port_get_name(struct chamelium_port *port);
void chamelium_plug(struct chamelium *chamelium, struct chamelium_port *port);
void chamelium_unplug(struct chamelium *chamelium, struct chamelium_port *port);
+void chamelium_unplug_hpd(struct chamelium *chamelium,
+ struct chamelium_port *port);
bool chamelium_is_plugged(struct chamelium *chamelium,
struct chamelium_port *port);
bool chamelium_port_wait_video_input_stable(struct chamelium *chamelium,
--
2.22.0
More information about the igt-dev
mailing list