Skip to content

Commit

Permalink
wlserver: Remove dependency on drm_include.h
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Feb 5, 2024
1 parent 1c31291 commit 5f6fab9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,13 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh)
return false;
}

if ( !drmIsKMS( drm->fd ) )
{
drm_log.errorf( "'%s' is not a KMS device", drm->device_name );
wlsession_close_kms();
return -1;
}

if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) {
drm_log.errorf("drmSetClientCap(ATOMIC) failed");
return false;
Expand Down
24 changes: 11 additions & 13 deletions src/wlserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "presentation-time-protocol.h"

#include "wlserver.hpp"
#include "drm_include.h"
#include "hdmi.h"
#include "main.hpp"
#include "steamcompmgr.hpp"
#include "log.hpp"
Expand Down Expand Up @@ -1398,22 +1398,15 @@ static void kms_device_handle_change( struct wl_listener *listener, void *data )
}

int wlsession_open_kms( const char *device_name ) {
struct wlr_device *device = nullptr;
if ( device_name != nullptr )
{
device = wlr_session_open_file( wlserver.wlr.session, device_name );
if ( device == nullptr )
wlserver.wlr.device = wlr_session_open_file( wlserver.wlr.session, device_name );
if ( wlserver.wlr.device == nullptr )
return -1;
if ( !drmIsKMS( device->fd ) )
{
wl_log.errorf( "'%s' is not a KMS device", device_name );
wlr_session_close_file( wlserver.wlr.session, device );
return -1;
}
}
else
{
ssize_t n = wlr_session_find_gpus( wlserver.wlr.session, 1, &device );
ssize_t n = wlr_session_find_gpus( wlserver.wlr.session, 1, &wlserver.wlr.device );
if ( n < 0 )
{
wl_log.errorf( "Failed to list GPUs" );
Expand All @@ -1428,9 +1421,14 @@ int wlsession_open_kms( const char *device_name ) {

struct wl_listener *listener = new wl_listener();
listener->notify = kms_device_handle_change;
wl_signal_add( &device->events.change, listener );
wl_signal_add( &wlserver.wlr.device->events.change, listener );

return device->fd;
return wlserver.wlr.device->fd;
}

void wlsession_close_kms()
{
wlr_session_close_file( wlserver.wlr.session, wlserver.wlr.device );
}

gamescope_xwayland_server_t::gamescope_xwayland_server_t(wl_display *display)
Expand Down
3 changes: 3 additions & 0 deletions src/wlserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ struct wlserver_t {
// Used to simulate key events and set the keymap
struct wlr_keyboard *virtual_keyboard_device;

struct wlr_device *device;

std::vector<std::unique_ptr<gamescope_xwayland_server_t>> xwayland_servers;
} wlr;

Expand Down Expand Up @@ -185,6 +187,7 @@ void xwayland_surface_commit(struct wlr_surface *wlr_surface);

bool wlsession_init( void );
int wlsession_open_kms( const char *device_name );
void wlsession_close_kms();

bool wlserver_init( void );

Expand Down

0 comments on commit 5f6fab9

Please sign in to comment.