[PATCH i-g-t v3 16/29] lib/unigraf: Introduce input configuration
Louis Chauvet
louis.chauvet at bootlin.com
Sat Aug 23 02:11:36 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
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
lib/unigraf/unigraf.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 0b8fe11a957b0ebaf7e9c4c4fc23b5f52c4632df..59a85e1b84c9df47a56f0273dac37d2dcba175c3 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 "DP RX"
+
static void unigraf_close_device(void)
{
unigraf_debug("Closing...\n");
@@ -124,6 +134,24 @@ static int unigraf_find_role(const char *request)
return chosen_role;
}
+static int unigraf_find_input(const 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(int drm_fd)
{
TSI_RESULT r;
@@ -131,10 +159,11 @@ bool unigraf_open_device(int drm_fd)
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());
@@ -158,6 +187,7 @@ bool unigraf_open_device(int drm_fd)
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,
@@ -174,6 +204,14 @@ bool unigraf_open_device(int drm_fd)
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));
@@ -218,6 +256,25 @@ bool unigraf_open_device(int drm_fd)
}
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.1
More information about the igt-dev
mailing list