[PATCH i-g-t v2 15/26] lib/unigraf: Introduce input configuration
Louis Chauvet
louis.chauvet at bootlin.com
Thu Jul 17 18:46:35 UTC 2025
As multiple input can be present on unigraf devices, add a configuration
field to select the proper input. By default it will take the first
available.
The configuration can look like:
[Unigraf]
Device=UCD-500 [2434C620]
Role=DisplayPort Source and Sink
Input=DP RX
---
lib/unigraf/unigraf.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index b4401daaac5a69ef02a15ead1b8edf3f2cac3833..d9e9d80a4cf19c6be67977050ef2a17f2cb489d7 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -39,11 +39,21 @@ static char *unigraf_connector_name;
*/
#define UNIGRAF_CONFIG_DEVICE_ROLE "Role"
+/**
+ * UNIGRAF_CONFIG_INPUT_NAME - Key of the input name in the configuration file
+ */
+#define UNIGRAF_CONFIG_INPUT_NAME "Input"
+
/**
* UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
*/
#define UNIGRAF_DEFAULT_ROLE_NAME "USB-C, DP Alt Mode Source and Sink"
+/**
+ * UNIGRAF_DEFAULT_INPUT_NAME - Default input name to search on the unigraf device
+ */
+#define UNIGRAF_DEFAULT_INPUT_NAME "USB-C, DP Alt Mode Source and Sink"
+
static void unigraf_close_device(void)
{
unigraf_debug("Closing...\n");
@@ -116,6 +126,20 @@ static int unigraf_find_role(char *request) {
return chosen_role;
}
+static int unigraf_find_input(char *request) {
+ int chosen_input = -1;
+ int role_count = unigraf_assert(TSIX_VIN_GetInputCount(unigraf_device));
+ for (int i = 0; i < role_count; i++) {
+ char input_name[UNIGRAF_NAME_MAX];
+ memset(input_name, 0, UNIGRAF_NAME_MAX);
+ unigraf_assert(TSIX_VIN_GetInputName(unigraf_device, i, input_name, UNIGRAF_NAME_MAX));
+ unigraf_debug("Input %d: %s\n", i, input_name);
+ if(!strncmp(input_name, request, UNIGRAF_NAME_MAX))
+ chosen_input = i;
+ }
+ return chosen_input;
+}
+
bool unigraf_open_device(void)
{
TSI_RESULT r;
@@ -123,10 +147,11 @@ bool unigraf_open_device(void)
GError *cfg_error = NULL;
char *cfg_device = NULL;
char *cfg_role = NULL;
+ char *cfg_input = NULL;
int device_count;
int chosen_device;
int chosen_role;
- int chosen_input = 0;
+ int chosen_input;
assert(igt_can_fail());
@@ -149,6 +174,7 @@ bool unigraf_open_device(void)
unigraf_debug("No device configured, will try to find the first available.\n");
cfg_device = NULL;
cfg_role = NULL;
+ cfg_input = NULL;
unigraf_connector_name = NULL;
} else {
cfg_device = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_NAME, &cfg_error);
@@ -163,6 +189,13 @@ bool unigraf_open_device(void)
unigraf_debug("No device role configured.\n");
cfg_role = NULL;
}
+
+ cfg_error = NULL;
+ cfg_input = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_INPUT_NAME, &cfg_error);
+ if (cfg_error) {
+ unigraf_debug("No input name configured.\n");
+ cfg_input = NULL;
+ }
}
unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -203,6 +236,21 @@ bool unigraf_open_device(void)
}
unigraf_assert(TSIX_DEV_SelectRole(unigraf_device, chosen_role));
+
+ if (!cfg_input) {
+ unigraf_debug("No input configured, trying " UNIGRAF_DEFAULT_INPUT_NAME "\n");
+ chosen_input = unigraf_find_input(UNIGRAF_DEFAULT_INPUT_NAME);
+ if (chosen_input < 0) {
+ char input_name[UNIGRAF_NAME_MAX];
+ chosen_input = 0;
+ unigraf_assert(TSIX_VIN_GetInputName(unigraf_device, chosen_input, input_name, UNIGRAF_NAME_MAX));
+ unigraf_debug("Input " UNIGRAF_DEFAULT_INPUT_NAME " not found, using input 0 (%s).\n", input_name);
+ }
+ } else {
+ chosen_input = unigraf_find_input(cfg_input);
+ igt_assert_f(chosen_input >= 0, "TSI:%p: Input %s not found.", unigraf_device, cfg_input);
+ }
+
unigraf_assert(TSIX_VIN_Select(unigraf_device, chosen_input));
unigraf_assert(TSIX_VIN_Enable(unigraf_device, chosen_input));
--
2.50.0
More information about the igt-dev
mailing list