Skip to content

Commit 409243e

Browse files
committed
Patch 5/5 modesetting: try to get gpu device fd from seatd arbiter
seatd like systemd-logind can gpu open device for us (open_hw function in driver.c). Aditionally there are atleast two implications: 1. During console switch the passed gpu device will receive DROP_MASTER ioctl from seatd 2. XServer user doesn't need to have rigts to /dev/dri/card* file nodes Signed-off-By: Tautvis <[email protected]>
1 parent 46dca91 commit 409243e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

hw/xfree86/common/seatd-libseat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
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);

hw/xfree86/drivers/modesetting/driver.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
#ifdef XSERVER_LIBPCIACCESS
6767
#include <pciaccess.h>
6868
#endif
69+
70+
#ifdef SEATD_LIBSEAT
71+
#include "seatd-libseat.h"
72+
#endif
73+
6974
#include "driver.h"
7075

7176
static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
@@ -226,6 +231,28 @@ open_hw(const char *dev)
226231
if ((fd = get_passed_fd()) != -1)
227232
return fd;
228233

234+
#ifdef SEATD_LIBSEAT
235+
// try get device from seatd arbiter
236+
if (dev){
237+
fd = seatd_libseat_open_graphics(dev);
238+
if (fd != -1){
239+
return fd;
240+
}
241+
242+
} else {
243+
const char *dev_env = getenv("KMSDEVICE");
244+
if (dev_env == NULL){
245+
dev_env = "/dev/dri/card0";
246+
}
247+
248+
fd = seatd_libseat_open_graphics(dev_env);
249+
250+
if (fd != -1) {
251+
return fd;
252+
}
253+
}
254+
#endif
255+
229256
if (dev)
230257
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
231258
else {

0 commit comments

Comments
 (0)