mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
Patch 5/5 modesetting: try to get gpu device fd from seatd arbiter
The device node opening with seatd, like with systemd-logind can done 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 enchanes open_hw function to try use seatd arbiter for opening device node in as last resort manner. To make it functional seatd_libseat_open_graphics needs to have _X_EXPORT Signed-off-by: tautvis <gtautvis gmail com>
This commit is contained in:
@@ -31,6 +31,18 @@
|
||||
#include <xf86Xinput.h>
|
||||
extern int seatd_libseat_init(Bool KeepTty_state);
|
||||
extern void seatd_libseat_fini(void);
|
||||
|
||||
/**
|
||||
* @brief seatd_libseat_open_graphics returns opened fd via rpc call through seatd
|
||||
* @param path node path
|
||||
* @warning this function returns <0 in case of error (for example -2)
|
||||
* @return file descriptior or <0
|
||||
*
|
||||
* @warning _X_EXPORT is only for internal consuption (currently for modesetting only, because its `open_hw` function calls open directly)
|
||||
*
|
||||
* @note XXX: maybe in future Xlibre public api could gain function for opening device nodes by path?
|
||||
**/
|
||||
_X_EXPORT
|
||||
extern int seatd_libseat_open_graphics(const char *path);
|
||||
extern void seatd_libseat_open_device(InputInfoPtr p,int *fd,Bool *paus);
|
||||
extern void seatd_libseat_close_device(InputInfoPtr p);
|
||||
|
||||
@@ -70,6 +70,11 @@
|
||||
#ifdef XSERVER_LIBPCIACCESS
|
||||
#include <pciaccess.h>
|
||||
#endif
|
||||
|
||||
#ifdef SEATD_LIBSEAT
|
||||
#include "seatd-libseat.h"
|
||||
#endif
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
|
||||
@@ -240,17 +245,32 @@ open_hw(const char *dev)
|
||||
if ((fd = get_passed_fd()) != -1)
|
||||
return fd;
|
||||
|
||||
if (dev)
|
||||
if (dev){
|
||||
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
|
||||
else {
|
||||
#ifdef SEATD_LIBSEAT
|
||||
/* try to open dev node via libseat */
|
||||
if (fd == -1) {
|
||||
fd = seatd_libseat_open_graphics(dev);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
dev = getenv("KMSDEVICE");
|
||||
if ((NULL == dev) || ((fd = open(dev, O_RDWR | O_CLOEXEC, 0)) == -1)) {
|
||||
dev = "/dev/dri/card0";
|
||||
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
|
||||
#ifdef SEATD_LIBSEAT
|
||||
if (fd == -1){
|
||||
fd = seatd_libseat_open_graphics(dev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (fd == -1)
|
||||
if (fd == -1) {
|
||||
xf86DrvMsg(-1, X_ERROR, "open %s: %s\n", dev, strerror(errno));
|
||||
} else if (fd < -1) {
|
||||
xf86DrvMsg(-1, X_ERROR, "open %s: failed to open, tried seatd_libseat_open_graphics and opening node directly",dev);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user