Skip to content

Commit

Permalink
Use sysfs connector_ids for target device selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruineka authored and BoukeHaarsma23 committed Jan 11, 2024
1 parent f8a54ae commit 65e6765
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 70 deletions.
14 changes: 4 additions & 10 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/drm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
60 changes: 1 addition & 59 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit 65e6765

Please sign in to comment.