Skip to content

Commit 727dc53

Browse files
cepelinas9000tautvis
authored andcommitted
Patch 6/6 modesetting: try to get gpu device fd from seatd arbiter
The device node with seatd like with systemd-logind are opened during probe (see get_drm_info in hw/xfree86/os-support/shared/drm_platform.c), but in case of failure, the modesetting driver tries to open device node directly (open_hw function in modesetting/driver.c). This patch aligns functionality and as last resort ask's seatd arbiter to open device for us. To make it functional seatd_libseat_controls_session, seatd_libseat_open_graphics needs _X_EXPORT Signed-off-By: Tautvis <[email protected]>
1 parent 6482cd9 commit 727dc53

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

hw/xfree86/common/seatd-libseat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
#include <xf86Xinput.h>
3232
extern int seatd_libseat_init(BOOL KeepTty_state);
3333
extern void seatd_libseat_fini(void);
34-
extern int seatd_libseat_open_graphics(const char *path);
34+
extern _X_EXPORT int seatd_libseat_open_graphics(const char *path);
3535
extern void seatd_libseat_open_device(InputInfoPtr p,int *fd,Bool *paus);
3636
extern void seatd_libseat_close_device(InputInfoPtr p);
3737
extern int seatd_libseat_switch_session(int session);
38-
extern Bool seatd_libseat_controls_session(void);
38+
extern _X_EXPORT Bool seatd_libseat_controls_session(void);
3939
#else
4040

4141
static inline int seatd_libseat_init(BOOL KeepTty_state) {(void)KeepTty_state; return -1; };

hw/xfree86/drivers/video/modesetting/driver.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
#ifdef XSERVER_LIBPCIACCESS
7171
#include <pciaccess.h>
7272
#endif
73+
74+
#ifdef SEATD_LIBSEAT
75+
#include "seatd-libseat.h"
76+
#endif
77+
7378
#include "driver.h"
7479

7580
static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
@@ -238,6 +243,8 @@ open_hw(const char *dev)
238243
if ((fd = get_passed_fd()) != -1)
239244
return fd;
240245

246+
247+
241248
if (dev)
242249
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
243250
else {
@@ -247,6 +254,31 @@ open_hw(const char *dev)
247254
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
248255
}
249256
}
257+
258+
#ifdef SEATD_LIBSEAT
259+
/* try get device from seatd arbiter */
260+
if (fd == -1 && seatd_libseat_controls_session()){
261+
if (dev){
262+
fd = seatd_libseat_open_graphics(dev);
263+
if (fd != -1){
264+
return fd;
265+
}
266+
267+
} else {
268+
const char *dev_env = getenv("KMSDEVICE");
269+
if (dev_env == NULL){
270+
dev_env = "/dev/dri/card0";
271+
}
272+
273+
fd = seatd_libseat_open_graphics(dev_env);
274+
275+
if (fd != -1) {
276+
return fd;
277+
}
278+
}
279+
}
280+
#endif
281+
250282
if (fd == -1)
251283
xf86DrvMsg(-1, X_ERROR, "open %s: %s\n", dev, strerror(errno));
252284

0 commit comments

Comments
 (0)