kms/connector: Allow to force connectors for lease

Add an environment variable (MUTTER_DEBUG_LEASE_CONNECTORS) that allows
set a ":" separated list of connector names as available for lease.

The names of the connectors can be found in "/sys/class/drm".

To illustrate it with an example, the names of the connectors and its
status can be fetched with this command:

  $ for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done
  DP-1: disconnected
  DP-2: disconnected
  DP-3: disconnected
  DP-4: disconnected
  DP-5: connected
  DP-6: connected
  DP-7: disconnected
  eDP-1: connected
  HDMI-A-1: disconnected

And, to set "DP-5" and "DP-6" available for lease, the environment
variable can be set like:

  MUTTER_DEBUG_LEASE_CONNECTORS=DP-5:DP-6

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3746>
This commit is contained in:
José Expósito 2024-05-09 11:06:38 +02:00 committed by Marge Bot
parent 9da43a3420
commit 7784c0d0aa

View File

@ -167,7 +167,26 @@ meta_kms_connector_get_current_state (MetaKmsConnector *connector)
gboolean
meta_kms_connector_is_for_lease (MetaKmsConnector *connector)
{
return connector->current_state && connector->current_state->non_desktop;
const char *lease_connectors_str;
if (!connector->current_state)
return FALSE;
lease_connectors_str = getenv ("MUTTER_DEBUG_LEASE_CONNECTORS");
if (lease_connectors_str && *lease_connectors_str != '\0')
{
int n;
g_auto (GStrv) names;
names = g_strsplit (lease_connectors_str, ":", -1);
for (n = 0; n < g_strv_length (names); n++)
{
if (g_str_equal (meta_kms_connector_get_name (connector), names[n]))
return TRUE;
}
}
return connector->current_state->non_desktop;
}
static gboolean