c/main: introduce XRT_COMPOSITOR_WAYLAND_CONNECTOR env var to request connector

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2295>
This commit is contained in:
Simon Zeni 2024-07-30 10:17:05 -04:00 committed by Marge Bot
parent dfc602288a
commit 570c956341
2 changed files with 12 additions and 7 deletions

View file

@ -0,0 +1 @@
wayland: introduce the environment variable 'WAYLAND_CONNECTOR' to request a specific connector

View file

@ -22,11 +22,14 @@
#include "xrt/xrt_compiler.h"
#include "main/comp_window.h"
#include "main/comp_window_direct.h"
#include "util/u_debug.h"
#ifndef VK_EXT_acquire_drm_display
#error "Wayland direct requires the Vulkan extension VK_EXT_acquire_drm_display"
#endif
DEBUG_GET_ONCE_OPTION(requested_connector, "XRT_COMPOSITOR_WAYLAND_CONNECTOR", NULL)
struct direct_wayland_lease
{
struct comp_window_direct_wayland *w;
@ -430,14 +433,14 @@ comp_window_direct_wayland_init(struct comp_target *w)
return false;
}
// Replace this with the value of an env variable
const char *connector_name = NULL;
if (!connector_name) {
const char *requested_connector = debug_get_option_requested_connector();
if (requested_connector) {
COMP_INFO(w->c, "Requesting connector %s", requested_connector);
} else {
COMP_INFO(w->c, "No connector was chosen, will use first available connector");
}
bool found = get_named_connector_or_first(w_wayland, connector_name);
bool found = get_named_connector_or_first(w_wayland, requested_connector);
if (!w_wayland->selected_connector) {
COMP_INFO(w->c, "Found no connectors available for direct mode");
@ -445,8 +448,9 @@ comp_window_direct_wayland_init(struct comp_target *w)
}
// Inform when chosen connector was not found
if (connector_name && !found) {
COMP_INFO(w->c, "Could not find requested connector, selected first available connector");
if (requested_connector && !found) {
COMP_WARN(w->c, "Could not find requested connector %s, selected first available connector %s",
requested_connector, w_wayland->selected_connector->name);
}
COMP_INFO(w->c, "Using DRM node %s", w_wayland->selected_device->path);