Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Louis Chauvet" <louis.chauvet@bootlin.com>,
	<igt-dev@lists.freedesktop.org>
Cc: <thomas.petazzoni@bootlin.com>, <markyacoub@google.com>,
	<khaled.almahallawy@intel.com>,
	"igt-dev" <igt-dev-bounces@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t v4 18/46] lib/unigraf: Add TSI.h
Date: Wed, 21 Jan 2026 18:49:45 +0100	[thread overview]
Message-ID: <DFUGGVHPISTJ.ZSMBM3NR3UBZ@bootlin.com> (raw)
In-Reply-To: <20251110-unigraf-integration-v4-18-0fc7bb1b4101@bootlin.com>

On Mon Nov 10, 2025 at 2:39 PM CET, Louis Chauvet wrote:
> Unigraf does not provide header for the libTSI.so file, only dynamic
> library loading helpers for windows.
>
> In order to link against this library and use unigraf devices, add the
> function declaration used in the dynamic library loading wrappers.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
>  lib/unigraf/TSI.h | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 234 insertions(+)
>
> diff --git a/lib/unigraf/TSI.h b/lib/unigraf/TSI.h
> new file mode 100644
> index 000000000000..62daaab6300e
> --- /dev/null
> +++ b/lib/unigraf/TSI.h
> @@ -0,0 +1,234 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +/*
> + * tsi.h - Header for libTSI.so
> + * Documentation here is taken from official documentation and developer observation.
> + */
> +
> +#ifndef TSI_H
> +#define TSI_H
> +
> +#define TSI_CURRENT_VERSION	12
> +#define MAX_EDID_SIZE		4096
> +
> +#define TSI_SUCCESS		0
> +
> +typedef unsigned int		TSI_VERSION_ID;
> +typedef unsigned int		TSI_SEARCH_OPTIONS;
> +typedef unsigned int		TSI_DEVICE_CAPS;
> +typedef unsigned int		TSI_CONFIG_ID;
> +typedef unsigned int		TSI_DEVICE_ID;
> +typedef unsigned int		TSI_INPUT_ID;
> +typedef int			TSI_RESULT;
> +typedef void			*TSI_HANDLE;
> +typedef int			TSI_FLAGS;
> +
> +/**
> + * TSI_Init() - Initialize the TSI library
> + * @ClientVersion: Indicates the version used to call the libTSI.so functions.
> + *
> + * Initialize libTSI for use and sets up internal state. It can be called
> + * multiple times, but TSI_Clean must be called the exact same number of time.
                                                                            times
> + *
> + * Returns:
> + * - In case of success: Reference count to the API (number of times to call TSI_Clean)
> + * - TSI_ERROR_NOT_COMPATIBLE if the requested client version is not supported
> + *   by the library
> + * - TSI_ERROR_COMPATIBILITY_MISMATCH if TSI_Init is called twice with
> + *   different client version
> + */
> +TSI_RESULT TSI_Init(TSI_VERSION_ID ClientVersion);
> +
> +/**
> + * TSI_Clean() - Cleans and closes the TSI library
> + *
> + * When TSI_Clean is called for the last time, cleanup the internal state. It
> + * should be called exactly the same number of time as TSI_Init
                                                  times

> + */
> +TSI_RESULT TSI_Clean(void);
> +
> +/**
> + * TSI_MISC_GetErrorDescription() - Get a human readable error message
> + * @ErrorCode: Error code for which you want the message
> + * @ErrorString: Pointer where to copy the message
> + * @StringMaxLen: Size of the allocated string @ErrorString
> + *
> + * The official documentation states: If the function succeeds, the
> + * return value is the number of characters required for the complete
> + * error description string.
> + * In reality, this function always returns 0 or error, so there is no way to

On error it returns 0...

> + * tell if the allocated memory was big enough
> + *
> + * Returns:
> + * - >= 0 on success, theorically the required string len to store the message
> + * - < 0 on failure

...or <0?

> + */
> +TSI_RESULT TSI_MISC_GetErrorDescription(TSI_RESULT ErrorCode,
> +					char *ErrorString,
> +					unsigned int StringMaxLen);
> +
> +/**
> + * TSIX_TS_GetConfigItem() - Read a configuration item from the UCD device
> + * @Device: Device handle to read config from. Can be NULL for certain configuration items.

For which items it can be NULL? I can guess some global config items, not
device-specific. Is it the case?

> + * @ConfigItemID: Identifier of the requested configuration item.
> + * @ConfigItemData: Pointer to store the read value.
> + * @ItemMaxSize: Size of the allocated memory for @ConfigItemData.
> + *
> + * Returns: The size of the raw data. If the return value is larger than ItemMaxSize, no data
> + *          is copied to ConfigItemData.
> + * Note:
> + * - Some configurations require specific size and alignment for the allocated buffer. Refer to
> + *   the specific item configuration documentation for details.
> + * - Data may still be written to @ConfigItemData even if the return value is larger than
> + *   @ItemMaxSize, potentially causing buffer overflow.

Oh, amazing!

> + */
> +TSI_RESULT TSIX_TS_GetConfigItem(TSI_HANDLE Device, TSI_CONFIG_ID ConfigItemID,
> +				 void *ConfigItemData,
> +				 unsigned int ItemMaxSize);
> +
> +/**
> + * TSIX_DEV_RescanDevices() - Refresh the internal list of devices for libTSI
> + * @SearchOptions: Options to filter the list of devices (e.g.,
> + *                 TSI_SEARCHOPTIONS_SHOW_DEVICES_IN_USE to include
> + *                 devices already in use).
> + * @RequiredCaps: Filter to list only devices with specific capabilities.
> + * @UnallowedCaps: Filter to list only devices without specific capabilities.
> + *
> + * Returns: >=0 in case of success.

The returned value is not the amount of devices found? It's just some
arbitrary non-negative number?

Being a closed source blob I can well understand a "don't know" answer of
course.

Also, maybe add "<0 on error"?

> + *
> + * This function should be called every time you need to update the list of connected devices,
> + * and it must be called at least once before calling TSI_DEV_GetDeviceCount.
> + */
> +TSI_RESULT TSIX_DEV_RescanDevices(TSI_SEARCH_OPTIONS SearchOptions,
> +				  TSI_DEVICE_CAPS RequiredCaps,
> +				  TSI_DEVICE_CAPS UnallowedCaps);
> +/**
> + * TSIX_DEV_GetDeviceCount() - Get the count of scanned devices
> + * Returns: the number of devices that the previous call to TSIX_DEV_RescanDevices() detected
> + *
> + * Must be called after a TSIX_DEV_RescanDevices.
> + */
> +TSI_RESULT TSIX_DEV_GetDeviceCount(void);
> +
> +/**
> + * TSIX_DEV_OpenDevice() - Open a device from the scanned list
> + * @DeviceID: index in the TSI_DEV_RescanDevices list
> + * @Result: Pointer to store the error code returned while opening the device
> + * Returns: if the device is found, an opaque pointer that can be used for other
> + * API calls. If some error occurred during the detection, the status code is
> + * written in the pointer @Result.

Not in the pointer, I believe! :-)

Maybe "is written in *@Result."? But the sentence is actually redundant,
it's implicit in the @Result parameter description. I'd rather add what is
returned on error. Just guessing that's NULL:

 * Returns: if the device is found, an opaque pointer that can be used for other
 * API calls, or NULL on error.


> + */
> +TSI_HANDLE TSIX_DEV_OpenDevice(TSI_DEVICE_ID DeviceID, TSI_RESULT *Result);
> +
> +/**
> + * TSIX_DEV_CloseDevice() - Close the device handle when finished
> + * @Device: Device handle to close
> + * Returns: >=0 in case of success
> + */
> +TSI_RESULT TSIX_DEV_CloseDevice(TSI_HANDLE Device);

Why not moving TSIX_TS_GetConfigItem() and TSIX_TS_SetConfigItem() here,
alsop keeping them nearby? It looks to me logical: first the init/open
functions, then the get/set config, then the various video operations.

> +
> +/**
> + * TSIX_VIN_Disable() - Disable video input on the specified device
> + * @Device: Device handle to disable video input on
> + * Returns: >=0 in case of success
> + */
> +TSI_RESULT TSIX_VIN_Disable(TSI_HANDLE Device);
> +
> +/**
> + * TSIX_VIN_Select() - Select a specific video input on the specified device
> + * @Device: Device handle on which to select the input
> + * @InputID: Identifier of the input to select
> + * Returns: >=0 in case of success
> + */
> +TSI_RESULT TSIX_VIN_Select(TSI_HANDLE Device, TSI_INPUT_ID InputID);
> +
> +/**
> + * TSIX_DEV_SelectRole() - Select a specific role for the specified device
> + * @Device: Device handle on which to assign the role
> + * @RoleIndex: Index of the role to assign

Is there an enum telling us which values mean what?

PS: I see you can get a list and the names from
TSIX_DEV_GetDeviceRoleCount/Name(), below. One more reason to keep related
functions together...

> +/**
> + * TSIX_DEV_GetDeviceRoleName() - Get the name of a specific role for a device
> + * @Device: Device handle to query
> + * @RoleIndex: Index of the role to get the name for
> + * @RoleNameString: Pointer to store the role name
> + * @RoleStringMaxLength: Size of the allocated memory for @RoleNameString
> + *
> + * Returns: >=0 in case of success, the length of the role name string
> + * Note: If the return value is larger than RoleStringMaxLength, the string may be truncated
> + */
> +TSI_RESULT TSIX_DEV_GetDeviceRoleName(TSI_HANDLE Device, int RoleIndex,
> +				      char *RoleNameString, unsigned int RoleStringMaxLength);
> +

...as said above, TSIX_DEV_SelectRole() should probably be here.

> +TSI_RESULT TSIX_VIN_GetInputName(TSI_HANDLE Device, TSI_INPUT_ID InputID,
> +				 char *InputNameString, unsigned int NameStringMaxLen);
> +
> +#endif

As for patch 17, I'd add:

   #endif /* TSI_H */



--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2026-01-21 17:49 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 13:39 [PATCH i-g-t v4 00/46] Unigraf integration Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 01/46] lib/igt_kms: Add a detect timeout value Louis Chauvet
2026-01-20 21:09   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 02/46] lib/igt_kms: Add helper to wait for a specific status on a connector Louis Chauvet
2026-01-20 21:09   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 03/46] lib/igt_kms: Add function to list connected connectors Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 04/46] lib/igt_kms: Add helper to obtain a connector by its name or MST path Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 05/46] lib/igt_kms: Add helper to wait for new connectors Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 06/46] lib/igt_kms: Add helper to get a pipe from a connector Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2026-01-22 15:50     ` Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 07/46] lib/igt_kms: Expose dump_connector_attrs Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 08/46] lib/igt_kms: Expose reset_connectors_at_exit Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 09/46] lib/igt_kms: Expose connector_attr_set and igt_connector_attr_set Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 10/46] lib/igt_debugfs: Move debugfs helpers to the proper location Louis Chauvet
2026-01-20 21:10   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 11/46] lib/igt_debugfs: Add const when make sense Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 12/46] lib/igt_amd: " Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 13/46] lib/igt_kms: " Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 14/46] lib/monitor_edids: Add helper functions for using monitor_edid objects Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 15/46] lib/monitor_edids: Add helper to get an EDID by its name Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 16/46] lib/monitor_edids: Add helper to print all available EDID names Louis Chauvet
2026-01-20 21:11   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 17/46] lib/unigraf: Add used defines for TSI_Types Louis Chauvet
2026-01-21 17:49   ` Luca Ceresoli
2026-01-22 16:40     ` Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 18/46] lib/unigraf: Add TSI.h Louis Chauvet
2026-01-21 17:49   ` Luca Ceresoli [this message]
2026-01-22 16:53     ` Louis Chauvet
2026-01-23 14:04       ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 19/46] lib/unigraf: Initial Unigraf support Louis Chauvet
2026-01-21 18:23   ` Luca Ceresoli
2026-01-21 18:30   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 20/46] lib/igt_kms: Automatically connect unigraf on display require Louis Chauvet
2026-01-22 20:26   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 21/46] lib/unigraf: Introduce device configuration Louis Chauvet
2026-01-23 17:38   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 22/46] lib/unigraf: Introduce role configuration Louis Chauvet
2026-01-26 11:28   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 23/46] lib/unigraf: Introduce input configuration Louis Chauvet
2026-01-23 17:38   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 24/46] lib/unigraf: Add reset function Louis Chauvet
2026-01-23 17:39   ` Luca Ceresoli
2026-01-26 10:45     ` Louis Chauvet
2026-01-26 11:28       ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 25/46] lib/unigraf: Add unigraf assert and deassert helpers Louis Chauvet
2026-01-23 17:40   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 26/46] lib/unigraf: Add plug/unplug helpers Louis Chauvet
2026-01-23 17:40   ` Luca Ceresoli
2026-01-26 11:28     ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 27/46] lib/unigraf: Allows sst/mst configuration Louis Chauvet
2026-01-23 17:40   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 28/46] lib/unigraf: Add helpers to read and write edid Louis Chauvet
2026-01-23 17:40   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 29/46] lib/unigraf: Add connector configuration Louis Chauvet
2026-01-26 11:40   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 30/46] tests/unigraf: Add basic unigraf tests Louis Chauvet
2026-01-26 12:00   ` Luca Ceresoli
2025-11-10 13:39 ` [PATCH i-g-t v4 31/46] lib/unigraf: Add unigraf CRC capture Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 32/46] lib/unigraf: Add configuration for CRC usage Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 33/46] lib/unigraf: add unigraf_get_connector_by_stream Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 34/46] lib/unigraf: Add helper to check timings received by unigraf Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 35/46] lib/igt_pipe_crc: Add ungiraf crc calculation Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 36/46] lib/unigraf: Add lane count configuration Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 37/46] docs/unigraf: Add unigraf documentation Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 38/46] lib/unigraf: Add helpers to set maximum link rate Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 39/46] lib/i915/dp: Move DP-related function for i915 to proper folder Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 40/46] lib/i915/dp: Rename functions to avoid confusion Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 41/46] lib/i915/dp: Add helper to get maximum supported rate Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 42/46] lib/igt_dp: Create generic helpers for DP information Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 43/46] lib/igt_kms: Add asserts to avoid null pointer dereference Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 44/46] lib/igt_kms: Add helper to get a pipe from an output Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 45/46] lib/unigraf: Add helpers to get the current LT status Louis Chauvet
2025-11-10 13:39 ` [PATCH i-g-t v4 46/46] tests/unigraf/unigraf_lt: Add test for link training Louis Chauvet
2025-11-10 22:34 ` ✓ Xe.CI.BAT: success for Unigraf integration (rev3) Patchwork
2025-11-10 22:44 ` ✓ i915.CI.BAT: " Patchwork
2025-11-11  5:34 ` ✓ i915.CI.Full: " Patchwork
2025-11-11  5:49 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-18 14:50 ` [PATCH i-g-t v4 00/46] Unigraf integration Louis Chauvet
2025-12-18 15:59   ` Mark Yacoub
2026-01-20 21:09 ` Luca Ceresoli

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=DFUGGVHPISTJ.ZSMBM3NR3UBZ@bootlin.com \
    --to=luca.ceresoli@bootlin.com \
    --cc=igt-dev-bounces@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=khaled.almahallawy@intel.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=markyacoub@google.com \
    --cc=thomas.petazzoni@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox