From 65e67653f2410b4ffc78d0b8055db92ec95fc146 Mon Sep 17 00:00:00 2001 From: Matthew Anderson Date: Mon, 9 Oct 2023 11:21:11 -0500 Subject: [PATCH] Use sysfs connector_ids for target device selection. --- src/drm.cpp | 14 +++-------- src/drm.hpp | 2 +- src/steamcompmgr.cpp | 60 +------------------------------------------- 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index d53e0ae339..acff5e5378 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -50,7 +50,7 @@ bool g_bDisplayTypeInternal = false; bool g_bUseLayers = true; bool g_bDebugLayers = false; const char *g_sOutputName = nullptr; -char* targetConnector = (char*)"eDP-1"; +uint32_t targetConnector; #ifndef DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP #define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15 @@ -1248,13 +1248,8 @@ static bool setup_best_connector(struct drm_t *drm, bool force, bool initial) for (auto &kv : drm->connectors) { struct connector *conn = &kv.second; - drm_log.debugf("force set adapter"); - drm_log.debugf("conn->name: %s", conn->name); - drm_log.debugf("targetConnector: %s", targetConnector); - if (strcmp(conn->name, targetConnector) == 0) + if ( conn->id == targetConnector) { - drm_log.debugf("target was found!!!"); - drm_log.infof(" %s (%s)", conn->name, targetConnector); best = conn; } } @@ -2912,10 +2907,9 @@ static bool drm_set_crtc( struct drm_t *drm, struct crtc *crtc ) return true; } -void drm_set_prefered_connector( struct drm_t *drm, char* name ) +void drm_set_prefered_connector( struct drm_t *drm, uint32_t connector_type_id ) { - drm_log.infof("selecting prefered connector %s", name); - targetConnector = name; + targetConnector = connector_type_id; } bool drm_set_connector( struct drm_t *drm, struct connector *conn ) diff --git a/src/drm.hpp b/src/drm.hpp index 0da6880f2a..6033eba559 100644 --- a/src/drm.hpp +++ b/src/drm.hpp @@ -378,7 +378,7 @@ uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_buffer *buf, struct void drm_lock_fbid( struct drm_t *drm, uint32_t fbid ); void drm_unlock_fbid( struct drm_t *drm, uint32_t fbid ); void drm_drop_fbid( struct drm_t *drm, uint32_t fbid ); -void drm_set_prefered_connector( struct drm_t *drm, char* name ); +void drm_set_prefered_connector( struct drm_t *drm, uint32_t connector_type_id ); bool drm_set_connector( struct drm_t *drm, struct connector *conn ); bool drm_set_mode( struct drm_t *drm, const drmModeModeInfo *mode ); bool drm_set_refresh( struct drm_t *drm, int refresh ); diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 7f0e4a00dd..a544f27769 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -5723,68 +5723,10 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev) { std::vector< uint32_t > connector_ctl; bool hasConnectorCtrl = get_prop( ctx, ctx->root, ctx->atoms.gamescopeConnectorControl, connector_ctl ); - char* adapter_type; if ( hasConnectorCtrl && connector_ctl.size() == 1 ) { - switch (connector_ctl[0]) - { - case 0: - adapter_type = (char*)"eDP-1"; - break; - case 1: - adapter_type = (char*)"eDP-2"; - break; - case 2: - adapter_type = (char*)"eDP-3"; - break; - case 3: - adapter_type = (char*)"DP-1"; - break; - case 4: - adapter_type = (char*)"DP-2"; - break; - case 5: - adapter_type = (char*)"DP-3"; - break; - case 6: - adapter_type = (char*)"HDMI-A-1"; - break; - case 7: - adapter_type = (char*)"HDMI-A-2"; - break; - case 8: - adapter_type = (char*)"HDMI-A-3"; - break; - case 9: - adapter_type = (char*)"HDMI-B-1"; - break; - case 10: - adapter_type = (char*)"HDMI-B-2"; - break; - case 11: - adapter_type = (char*)"HDMI-B-3"; - break; - case 12: - adapter_type = (char*)"HDMI-C-1"; - break; - case 13: - adapter_type = (char*)"HDMI-C-2"; - break; - case 14: - adapter_type = (char*)"HDMI-C-3"; - break; - case 15: - adapter_type = (char*)"DSI-1"; - break; - case 16: - adapter_type = (char*)"DSI-2"; - break; - case 17: - adapter_type = (char*)"DSI-3"; - break; - } g_DRM.out_of_date = 2; - drm_set_prefered_connector(&g_DRM, adapter_type); + drm_set_prefered_connector(&g_DRM, connector_ctl[0]); } } if ( ev->atom == ctx->atoms.gamescopeFPSLimit )