configure.ac: Make libdrm optional in weston-launch
If libdrm is available, weston-launch and launcer-util.c will support getting the drm device and setting and dropping drm master, otherwise we'll only support getting input devices.
This commit is contained in:
+4
-6
@@ -102,6 +102,8 @@ if test x$enable_xwayland = xyes; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(LIBDRM, [libdrm],
|
||||||
|
[AC_DEFINE(HAVE_LIBDRM, 1, [Define if libdrm is available]) have_libdrm=yes], have_libdrm=no)
|
||||||
|
|
||||||
AC_ARG_ENABLE(x11-compositor, [ --enable-x11-compositor],,
|
AC_ARG_ENABLE(x11-compositor, [ --enable-x11-compositor],,
|
||||||
enable_x11_compositor=yes)
|
enable_x11_compositor=yes)
|
||||||
@@ -145,9 +147,6 @@ AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes -a x$e
|
|||||||
if test x$enable_drm_compositor = xyes -a x$enable_egl = xyes; then
|
if test x$enable_drm_compositor = xyes -a x$enable_egl = xyes; then
|
||||||
AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
|
AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
|
||||||
PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm mtdev >= 1.1.0])
|
PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm mtdev >= 1.1.0])
|
||||||
|
|
||||||
# For libdrm usage in launcher-util.c
|
|
||||||
COMPOSITOR_MODULES="$COMPOSITOR_MODULES libdrm"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES])
|
PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES])
|
||||||
@@ -332,13 +331,12 @@ AS_IF([test "x$have_systemd_login_209" = "xyes"],
|
|||||||
AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes)
|
AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes)
|
||||||
AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
|
AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
|
||||||
if test x$enable_weston_launch == xyes; then
|
if test x$enable_weston_launch == xyes; then
|
||||||
PKG_CHECK_MODULES(WESTON_LAUNCH, [libdrm])
|
|
||||||
|
|
||||||
AC_CHECK_LIB([pam], [pam_open_session], [have_pam=yes], [have_pam=no])
|
AC_CHECK_LIB([pam], [pam_open_session], [have_pam=yes], [have_pam=no])
|
||||||
if test x$have_pam == xno; then
|
if test x$have_pam == xno; then
|
||||||
AC_ERROR([weston-launch requires pam])
|
AC_ERROR([weston-launch requires pam])
|
||||||
fi
|
fi
|
||||||
WESTON_LAUNCH_LIBS="$WESTON_LAUNCH_LIBS -lpam"
|
PAM_LIBS=-lpam
|
||||||
|
AC_SUBST(PAM_LIBS)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$enable_egl = xyes; then
|
if test x$enable_egl = xyes; then
|
||||||
|
|||||||
+11
-4
@@ -80,10 +80,13 @@ DIST_SUBDIRS = xwayland
|
|||||||
if BUILD_WESTON_LAUNCH
|
if BUILD_WESTON_LAUNCH
|
||||||
weston_launch = weston-launch
|
weston_launch = weston-launch
|
||||||
weston_launch_SOURCES = weston-launch.c weston-launch.h
|
weston_launch_SOURCES = weston-launch.c weston-launch.h
|
||||||
weston_launch_CFLAGS= $(GCC_CFLAGS)
|
weston_launch_CPPFLAGS = -DBINDIR='"$(bindir)"'
|
||||||
weston_launch_CPPFLAGS = $(WESTON_LAUNCH_CFLAGS) $(SYSTEMD_LOGIN_CFLAGS) \
|
weston_launch_CFLAGS= \
|
||||||
-DBINDIR='"$(bindir)"'
|
$(GCC_CFLAGS) \
|
||||||
weston_launch_LDADD = $(WESTON_LAUNCH_LIBS) $(SYSTEMD_LOGIN_LIBS)
|
$(PAM_CFLAGS) \
|
||||||
|
$(SYSTEMD_LOGIN_CFLAGS) \
|
||||||
|
$(LIBDRM_CFLAGS)
|
||||||
|
weston_launch_LDADD = $(PAM_LIBS) $(SYSTEMD_LOGIN_LIBS) $(LIBDRM_LIBS)
|
||||||
|
|
||||||
if ENABLE_SETUID_INSTALL
|
if ENABLE_SETUID_INSTALL
|
||||||
install-exec-hook:
|
install-exec-hook:
|
||||||
@@ -206,11 +209,13 @@ rpi_backend_la_LDFLAGS = -module -avoid-version
|
|||||||
rpi_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
|
rpi_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
|
||||||
$(RPI_COMPOSITOR_LIBS) \
|
$(RPI_COMPOSITOR_LIBS) \
|
||||||
$(RPI_BCM_HOST_LIBS) \
|
$(RPI_BCM_HOST_LIBS) \
|
||||||
|
$(LIBDRM_LIBS) \
|
||||||
../shared/libshared.la
|
../shared/libshared.la
|
||||||
rpi_backend_la_CFLAGS = \
|
rpi_backend_la_CFLAGS = \
|
||||||
$(GCC_CFLAGS) \
|
$(GCC_CFLAGS) \
|
||||||
$(COMPOSITOR_CFLAGS) \
|
$(COMPOSITOR_CFLAGS) \
|
||||||
$(RPI_COMPOSITOR_CFLAGS) \
|
$(RPI_COMPOSITOR_CFLAGS) \
|
||||||
|
$(LIBDRM_CFLAGS) \
|
||||||
$(RPI_BCM_HOST_CFLAGS)
|
$(RPI_BCM_HOST_CFLAGS)
|
||||||
rpi_backend_la_SOURCES = \
|
rpi_backend_la_SOURCES = \
|
||||||
compositor-rpi.c \
|
compositor-rpi.c \
|
||||||
@@ -247,11 +252,13 @@ fbdev_backend_la_LDFLAGS = -module -avoid-version
|
|||||||
fbdev_backend_la_LIBADD = \
|
fbdev_backend_la_LIBADD = \
|
||||||
$(COMPOSITOR_LIBS) \
|
$(COMPOSITOR_LIBS) \
|
||||||
$(FBDEV_COMPOSITOR_LIBS) \
|
$(FBDEV_COMPOSITOR_LIBS) \
|
||||||
|
$(LIBDRM_LIBS) \
|
||||||
../shared/libshared.la
|
../shared/libshared.la
|
||||||
fbdev_backend_la_CFLAGS = \
|
fbdev_backend_la_CFLAGS = \
|
||||||
$(COMPOSITOR_CFLAGS) \
|
$(COMPOSITOR_CFLAGS) \
|
||||||
$(EGL_CFLAGS) \
|
$(EGL_CFLAGS) \
|
||||||
$(FBDEV_COMPOSITOR_CFLAGS) \
|
$(FBDEV_COMPOSITOR_CFLAGS) \
|
||||||
|
$(LIBDRM_CFLAGS) \
|
||||||
$(PIXMAN_CFLAGS) \
|
$(PIXMAN_CFLAGS) \
|
||||||
$(GCC_CFLAGS)
|
$(GCC_CFLAGS)
|
||||||
fbdev_backend_la_SOURCES = \
|
fbdev_backend_la_SOURCES = \
|
||||||
|
|||||||
+42
-34
@@ -40,10 +40,6 @@
|
|||||||
#include <linux/kd.h>
|
#include <linux/kd.h>
|
||||||
#include <linux/major.h>
|
#include <linux/major.h>
|
||||||
|
|
||||||
#ifdef BUILD_DRM_COMPOSITOR
|
|
||||||
#include <xf86drm.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "compositor.h"
|
#include "compositor.h"
|
||||||
#include "launcher-util.h"
|
#include "launcher-util.h"
|
||||||
#include "logind-util.h"
|
#include "logind-util.h"
|
||||||
@@ -55,43 +51,55 @@
|
|||||||
#define KDSKBMUTE 0x4B51
|
#define KDSKBMUTE 0x4B51
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
union cmsg_data { unsigned char b[4]; int fd; };
|
#ifdef HAVE_LIBDRM
|
||||||
|
|
||||||
struct weston_launcher {
|
#include <xf86drm.h>
|
||||||
struct weston_logind *logind;
|
|
||||||
struct weston_compositor *compositor;
|
|
||||||
int fd;
|
|
||||||
struct wl_event_source *source;
|
|
||||||
|
|
||||||
int kb_mode, tty, drm_fd;
|
static inline int
|
||||||
struct wl_event_source *vt_source;
|
is_drm_master(int drm_fd)
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef BUILD_DRM_COMPOSITOR
|
|
||||||
static int
|
|
||||||
drm_drop_master(int drm_fd)
|
|
||||||
{
|
|
||||||
return drmDropMaster(drm_fd);
|
|
||||||
}
|
|
||||||
static int
|
|
||||||
drm_set_master(int drm_fd)
|
|
||||||
{
|
|
||||||
return drmSetMaster(drm_fd);
|
|
||||||
}
|
|
||||||
static int
|
|
||||||
drm_is_master(int drm_fd)
|
|
||||||
{
|
{
|
||||||
drm_magic_t magic;
|
drm_magic_t magic;
|
||||||
|
|
||||||
return drmGetMagic(drm_fd, &magic) == 0 &&
|
return drmGetMagic(drm_fd, &magic) == 0 &&
|
||||||
drmAuthMagic(drm_fd, magic) == 0;
|
drmAuthMagic(drm_fd, magic) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static int drm_drop_master(int drm_fd) {return 0;}
|
|
||||||
static int drm_set_master(int drm_fd) {return 0;}
|
static inline int
|
||||||
static int drm_is_master(int drm_fd) {return 1;}
|
drmDropMaster(int drm_fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
drmSetMaster(int drm_fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
is_drm_master(int drm_fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
union cmsg_data { unsigned char b[4]; int fd; };
|
||||||
|
|
||||||
|
struct weston_launcher {
|
||||||
|
struct weston_compositor *compositor;
|
||||||
|
struct weston_logind *logind;
|
||||||
|
struct wl_event_loop *loop;
|
||||||
|
int fd;
|
||||||
|
struct wl_event_source *source;
|
||||||
|
|
||||||
|
int kb_mode, tty, drm_fd;
|
||||||
|
struct wl_event_source *vt_source;
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
weston_launcher_open(struct weston_launcher *launcher,
|
weston_launcher_open(struct weston_launcher *launcher,
|
||||||
const char *path, int flags)
|
const char *path, int flags)
|
||||||
@@ -121,7 +129,7 @@ weston_launcher_open(struct weston_launcher *launcher,
|
|||||||
|
|
||||||
if (major(s.st_rdev) == DRM_MAJOR) {
|
if (major(s.st_rdev) == DRM_MAJOR) {
|
||||||
launcher->drm_fd = fd;
|
launcher->drm_fd = fd;
|
||||||
if (!drm_is_master(fd)) {
|
if (!is_drm_master(fd)) {
|
||||||
weston_log("drm fd not master\n");
|
weston_log("drm fd not master\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -205,7 +213,7 @@ weston_launcher_restore(struct weston_launcher *launcher)
|
|||||||
/* We have to drop master before we switch the VT back in
|
/* We have to drop master before we switch the VT back in
|
||||||
* VT_AUTO, so we don't risk switching to a VT with another
|
* VT_AUTO, so we don't risk switching to a VT with another
|
||||||
* display server, that will then fail to set drm master. */
|
* display server, that will then fail to set drm master. */
|
||||||
drm_drop_master(launcher->drm_fd);
|
drmDropMaster(launcher->drm_fd);
|
||||||
|
|
||||||
mode.mode = VT_AUTO;
|
mode.mode = VT_AUTO;
|
||||||
if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
|
if (ioctl(launcher->tty, VT_SETMODE, &mode) < 0)
|
||||||
@@ -259,11 +267,11 @@ vt_handler(int signal_number, void *data)
|
|||||||
if (compositor->session_active) {
|
if (compositor->session_active) {
|
||||||
compositor->session_active = 0;
|
compositor->session_active = 0;
|
||||||
wl_signal_emit(&compositor->session_signal, compositor);
|
wl_signal_emit(&compositor->session_signal, compositor);
|
||||||
drm_drop_master(launcher->drm_fd);
|
drmDropMaster(launcher->drm_fd);
|
||||||
ioctl(launcher->tty, VT_RELDISP, 1);
|
ioctl(launcher->tty, VT_RELDISP, 1);
|
||||||
} else {
|
} else {
|
||||||
ioctl(launcher->tty, VT_RELDISP, VT_ACKACQ);
|
ioctl(launcher->tty, VT_RELDISP, VT_ACKACQ);
|
||||||
drm_set_master(launcher->drm_fd);
|
drmSetMaster(launcher->drm_fd);
|
||||||
compositor->session_active = 1;
|
compositor->session_active = 1;
|
||||||
wl_signal_emit(&compositor->session_signal, compositor);
|
wl_signal_emit(&compositor->session_signal, compositor);
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-2
@@ -50,8 +50,6 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
|
||||||
#include <xf86drm.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYSTEMD_LOGIN
|
#ifdef HAVE_SYSTEMD_LOGIN
|
||||||
#include <systemd/sd-login.h>
|
#include <systemd/sd-login.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -70,6 +68,26 @@
|
|||||||
|
|
||||||
#define MAX_ARGV_SIZE 256
|
#define MAX_ARGV_SIZE 256
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBDRM
|
||||||
|
|
||||||
|
#include <xf86drm.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
drmDropMaster(int drm_fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
drmSetMaster(int drm_fd)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
struct weston_launch {
|
struct weston_launch {
|
||||||
struct pam_conv pc;
|
struct pam_conv pc;
|
||||||
pam_handle_t *ph;
|
pam_handle_t *ph;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ subsurface_weston_SOURCES = subsurface-test.c
|
|||||||
subsurface_weston_LDADD = libtest-client.la
|
subsurface_weston_LDADD = libtest-client.la
|
||||||
|
|
||||||
xwayland_weston_SOURCES = xwayland-test.c
|
xwayland_weston_SOURCES = xwayland-test.c
|
||||||
|
xwayland_weston_CFLAGS = $(GCC_CFLAGS) $(XWAYLAND_TEST_CFLAGS)
|
||||||
xwayland_weston_LDADD = libtest-client.la $(XWAYLAND_TEST_LIBS)
|
xwayland_weston_LDADD = libtest-client.la $(XWAYLAND_TEST_LIBS)
|
||||||
|
|
||||||
if ENABLE_XWAYLAND_TEST
|
if ENABLE_XWAYLAND_TEST
|
||||||
|
|||||||
Reference in New Issue
Block a user