[PATCH xserver 3/3] kdrive: Remove now-unused linux backend

Laércio de Sousa laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Aug 18 15:57:51 UTC 2017


This removal breaks my Xephyr-based single-GPU multi-seat setup :-(

Anyway, Xephyr never was my preferred options for such a setup, but I
simply have no other choice (at least until xf86-video-nested gets
revived). I'm currently working on a xf86-video-nested fork at GitHub and I
would like to submit a patch series upstream (if someone could review/apply
it).

When/If I can get xf86-video-nested working properly, then you could even
revert that input hot-plugging suport I've introduced in kdrive/Xephyr
(without kdrive-evdev, it's completely useless).

2017-02-16 15:46 GMT-02:00 Adam Jackson <ajax at redhat.com>:

> With Xfbdev gone this has no consumers.
>
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  configure.ac                |  44 ----
>  hw/kdrive/Makefile.am       |   7 +-
>  hw/kdrive/linux/Makefile.am |  19 --
>  hw/kdrive/linux/evdev.c     | 530 ------------------------------
> --------------
>  hw/kdrive/linux/linux.c     | 347 -----------------------------
>  hw/kdrive/linux/tslib.c     | 194 ----------------
>  6 files changed, 1 insertion(+), 1140 deletions(-)
>  delete mode 100644 hw/kdrive/linux/Makefile.am
>  delete mode 100644 hw/kdrive/linux/evdev.c
>  delete mode 100644 hw/kdrive/linux/linux.c
>  delete mode 100644 hw/kdrive/linux/tslib.c
>
> diff --git a/configure.ac b/configure.ac
> index da00d88..d652c86 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -656,7 +656,6 @@ dnl kdrive and its subsystems
>  AC_ARG_ENABLE(kdrive,         AS_HELP_STRING([--enable-kdrive], [Build
> kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
>  AC_ARG_ENABLE(xephyr,         AS_HELP_STRING([--enable-xephyr], [Build
> the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval],
> [XEPHYR=auto])
>  dnl kdrive options
> -AC_ARG_ENABLE(kdrive-evdev,   AS_HELP_STRING([--enable-kdrive-evdev],
> [Build evdev driver for kdrive (default: auto)]),
> [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
>  AC_ARG_ENABLE(libunwind,      AS_HELP_STRING([--enable-libunwind], [Use
> libunwind for backtracing (default: auto)]), [LIBUNWIND="$enableval"],
> [LIBUNWIND="auto"])
>  AC_ARG_ENABLE(xshmfence,      AS_HELP_STRING([--disable-xshmfence],
> [Disable xshmfence (default: auto)]), [XSHMFENCE="$enableval"],
> [XSHMFENCE="auto"])
>
> @@ -2366,45 +2365,6 @@ if test "$KDRIVE" = yes; then
>      AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
>      AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
>
> -    PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"],
> [HAVE_TSLIB="no"])
> -    if test "x$HAVE_TSLIB" = xno; then
> -        AC_CHECK_LIB(ts, ts_open, [
> -                       HAVE_TSLIB="yes"
> -                       TSLIB_LIBS="-lts"
> -               ])
> -    fi
> -
> -    if test "xTSLIB" = xauto; then
> -        TSLIB="$HAVE_TSLIB"
> -    fi
> -
> -    if test "x$TSLIB" = xyes; then
> -        if ! test "x$HAVE_TSLIB" = xyes; then
> -            AC_MSG_ERROR([tslib must be installed to build the tslib
> driver. See http://tslib.berlios.de/])
> -        else
> -            AC_DEFINE(TSLIB, 1, [Have tslib support])
> -        fi
> -    fi
> -
> -    case $host_os in
> -       *linux*)
> -           KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.la'
> -            KDRIVELINUX=yes
> -           if test "x$KDRIVE_EVDEV" = xauto; then
> -               KDRIVE_EVDEV=yes
> -           fi
> -           ;;
> -       *)
> -           if test "x$KDRIVE_EVDEV" = xauto; then
> -               KDRIVE_EVDEV=no
> -           fi
> -           ;;
> -    esac
> -
> -    if test "x$KDRIVE_EVDEV" = xyes; then
> -       AC_DEFINE(KDRIVE_EVDEV, 1, [Enable KDrive evdev driver])
> -    fi
> -
>      XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render
> xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr
> xcb-xkb"
>      if test "x$XV" = xyes; then
>          XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv"
> @@ -2452,9 +2412,6 @@ AC_SUBST([KDRIVE_PURE_LIBS])
>  AC_SUBST([KDRIVE_MAIN_LIB])
>  AC_SUBST([KDRIVE_LOCAL_LIBS])
>  AC_SUBST([KDRIVE_LIBS])
> -AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
> -AM_CONDITIONAL(KDRIVE_EVDEV, [test "x$KDRIVE_EVDEV" = xyes])
> -AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
>  AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
>
>  dnl Xwayland DDX
> @@ -2636,7 +2593,6 @@ hw/xquartz/xpr/Makefile
>  hw/kdrive/Makefile
>  hw/kdrive/ephyr/Makefile
>  hw/kdrive/ephyr/man/Makefile
> -hw/kdrive/linux/Makefile
>  hw/kdrive/src/Makefile
>  hw/xwayland/Makefile
>  test/Makefile
> diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
> index de30e51..dc71dbd 100644
> --- a/hw/kdrive/Makefile.am
> +++ b/hw/kdrive/Makefile.am
> @@ -2,19 +2,14 @@ if XEPHYR
>  XEPHYR_SUBDIRS = ephyr
>  endif
>
> -if KDRIVELINUX
> -LINUX_SUBDIRS = linux
> -endif
> -
>  SERVER_SUBDIRS =               \
>         $(XEPHYR_SUBDIRS)
>
>  SUBDIRS =                      \
>         src                     \
> -       $(LINUX_SUBDIRS)        \
>         $(SERVER_SUBDIRS)
>
> -DIST_SUBDIRS = ephyr src linux
> +DIST_SUBDIRS = ephyr src
>
>  relink:
>         $(AM_V_at)for i in $(SERVER_SUBDIRS) ; do $(MAKE) -C $$i relink ||
> exit 1 ; done
> diff --git a/hw/kdrive/linux/Makefile.am b/hw/kdrive/linux/Makefile.am
> deleted file mode 100644
> index 97c600c..0000000
> --- a/hw/kdrive/linux/Makefile.am
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -AM_CPPFLAGS =                                  \
> -       @KDRIVE_INCS@                           \
> -       @KDRIVE_CFLAGS@
> -
> -AM_CFLAGS = -DHAVE_DIX_CONFIG_H
> -
> -noinst_LTLIBRARIES = liblinux.la
> -
> -liblinux_la_SOURCES =
> -
> -liblinux_la_SOURCES += linux.c
> -
> -if KDRIVE_EVDEV
> -liblinux_la_SOURCES += evdev.c
> -endif
> -
> -if TSLIB
> -liblinux_la_SOURCES += tslib.c
> -endif
> diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
> deleted file mode 100644
> index 9590413..0000000
> --- a/hw/kdrive/linux/evdev.c
> +++ /dev/null
> @@ -1,530 +0,0 @@
> -/*
> - * Copyright © 2004 Keith Packard
> - *
> - * Permission to use, copy, modify, distribute, and sell this software
> and its
> - * documentation for any purpose is hereby granted without fee, provided
> that
> - * the above copyright notice appear in all copies and that both that
> - * copyright notice and this permission notice appear in supporting
> - * documentation, and that the name of Keith Packard not be used in
> - * advertising or publicity pertaining to distribution of the software
> without
> - * specific, written prior permission.  Keith Packard makes no
> - * representations about the suitability of this software for any
> purpose.  It
> - * is provided "as is" without express or implied warranty.
> - *
> - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
> USE,
> - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
> - * PERFORMANCE OF THIS SOFTWARE.
> - */
> -
> -#ifdef HAVE_CONFIG_H
> -#include <kdrive-config.h>
> -#endif
> -#include <errno.h>
> -#include <linux/input.h>
> -#include <X11/X.h>
> -#include <X11/Xproto.h>
> -#include "inputstr.h"
> -#include "scrnintstr.h"
> -#include "kdrive.h"
> -
> -#define NUM_EVENTS  128
> -#define ABS_UNSET   -65535
> -
> -#define BITS_PER_LONG (sizeof(long) * 8)
> -#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
> -#define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
> -#define OFF(x)   ((x)%BITS_PER_LONG)
> -#define LONG(x)  ((x)/BITS_PER_LONG)
> -#define BIT(x)         (1 << OFF(x))
> -
> -typedef struct _kevdev {
> -    /* current device state */
> -    int rel[REL_MAX + 1];
> -    int abs[ABS_MAX + 1];
> -    int prevabs[ABS_MAX + 1];
> -    long key[NBITS(KEY_MAX + 1)];
> -
> -    /* supported device info */
> -    long relbits[NBITS(REL_MAX + 1)];
> -    long absbits[NBITS(ABS_MAX + 1)];
> -    long keybits[NBITS(KEY_MAX + 1)];
> -    struct input_absinfo absinfo[ABS_MAX + 1];
> -    int max_rel;
> -    int max_abs;
> -
> -    int fd;
> -} Kevdev;
> -
> -static void
> -EvdevPtrBtn(KdPointerInfo * pi, struct input_event *ev)
> -{
> -    int flags = KD_MOUSE_DELTA | pi->buttonState;
> -
> -    if (ev->code >= BTN_MOUSE && ev->code < BTN_JOYSTICK) {
> -        switch (ev->code) {
> -        case BTN_LEFT:
> -            if (ev->value == 1)
> -                flags |= KD_BUTTON_1;
> -            else
> -                flags &= ~KD_BUTTON_1;
> -            break;
> -        case BTN_MIDDLE:
> -            if (ev->value == 1)
> -                flags |= KD_BUTTON_2;
> -            else
> -                flags &= ~KD_BUTTON_2;
> -            break;
> -        case BTN_RIGHT:
> -            if (ev->value == 1)
> -                flags |= KD_BUTTON_3;
> -            else
> -                flags &= ~KD_BUTTON_3;
> -            break;
> -        default:
> -            /* Unknow button */
> -            break;
> -        }
> -
> -        KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
> -    }
> -}
> -
> -static void
> -EvdevPtrMotion(KdPointerInfo * pi, struct input_event *ev)
> -{
> -    Kevdev *ke = pi->driverPrivate;
> -    int i;
> -    int flags = KD_MOUSE_DELTA | pi->buttonState;
> -
> -    for (i = 0; i <= ke->max_rel; i++)
> -        if (ke->rel[i]) {
> -            int a;
> -
> -            for (a = 0; a <= ke->max_rel; a++) {
> -                if (ISBITSET(ke->relbits, a)) {
> -                    if (a == 0)
> -                        KdEnqueuePointerEvent(pi, flags, ke->rel[a], 0,
> 0);
> -                    else if (a == 1)
> -                        KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a],
> 0);
> -                }
> -                ke->rel[a] = 0;
> -            }
> -            break;
> -        }
> -    for (i = 0; i < ke->max_abs; i++)
> -        if (ke->abs[i] != ke->prevabs[i]) {
> -            int a;
> -
> -            ErrorF("abs");
> -            for (a = 0; a <= ke->max_abs; a++) {
> -                if (ISBITSET(ke->absbits, a))
> -                    ErrorF(" %d=%d", a, ke->abs[a]);
> -                ke->prevabs[a] = ke->abs[a];
> -            }
> -            ErrorF("\n");
> -            break;
> -        }
> -
> -    if (ev->code == REL_WHEEL) {
> -        for (i = 0; i < abs(ev->value); i++) {
> -            if (ev->value > 0)
> -                flags |= KD_BUTTON_4;
> -            else
> -                flags |= KD_BUTTON_5;
> -
> -            KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
> -
> -            if (ev->value > 0)
> -                flags &= ~KD_BUTTON_4;
> -            else
> -                flags &= ~KD_BUTTON_5;
> -
> -            KdEnqueuePointerEvent(pi, flags, 0, 0, 0);
> -        }
> -    }
> -
> -}
> -
> -static void
> -EvdevPtrRead(int evdevPort, void *closure)
> -{
> -    KdPointerInfo *pi = closure;
> -    Kevdev *ke = pi->driverPrivate;
> -    int i;
> -    struct input_event events[NUM_EVENTS];
> -    int n;
> -
> -    n = read(evdevPort, &events, NUM_EVENTS * sizeof(struct input_event));
> -    if (n <= 0) {
> -        if (errno == ENODEV)
> -            DeleteInputDeviceRequest(pi->dixdev);
> -        return;
> -    }
> -
> -    n /= sizeof(struct input_event);
> -    for (i = 0; i < n; i++) {
> -        switch (events[i].type) {
> -        case EV_SYN:
> -            break;
> -        case EV_KEY:
> -            EvdevPtrBtn(pi, &events[i]);
> -            break;
> -        case EV_REL:
> -            ke->rel[events[i].code] += events[i].value;
> -            EvdevPtrMotion(pi, &events[i]);
> -            break;
> -        case EV_ABS:
> -            ke->abs[events[i].code] = events[i].value;
> -            EvdevPtrMotion(pi, &events[i]);
> -            break;
> -        }
> -    }
> -}
> -
> -const char *kdefaultEvdev[] = {
> -    "/dev/input/event0",
> -    "/dev/input/event1",
> -    "/dev/input/event2",
> -    "/dev/input/event3",
> -};
> -
> -#define NUM_DEFAULT_EVDEV    (sizeof (kdefaultEvdev) / sizeof
> (kdefaultEvdev[0]))
> -
> -static Status
> -EvdevPtrInit(KdPointerInfo * pi)
> -{
> -    int i;
> -    int fd;
> -
> -    if (!pi->path) {
> -        for (i = 0; i < NUM_DEFAULT_EVDEV; i++) {
> -            fd = open(kdefaultEvdev[i], 2);
> -            if (fd >= 0) {
> -                pi->path = strdup(kdefaultEvdev[i]);
> -                break;
> -            }
> -        }
> -    }
> -    else {
> -        fd = open(pi->path, O_RDWR);
> -        if (fd < 0) {
> -            ErrorF("Failed to open evdev device %s\n", pi->path);
> -            return BadMatch;
> -        }
> -    }
> -
> -    close(fd);
> -
> -    if (!pi->name)
> -        pi->name = strdup("Evdev mouse");
> -
> -    return Success;
> -}
> -
> -static Status
> -EvdevPtrEnable(KdPointerInfo * pi)
> -{
> -    int fd;
> -    unsigned long ev[NBITS(EV_MAX)];
> -    Kevdev *ke;
> -
> -    if (!pi || !pi->path)
> -        return BadImplementation;
> -
> -    fd = open(pi->path, 2);
> -    if (fd < 0)
> -        return BadMatch;
> -
> -    if (ioctl(fd, EVIOCGRAB, 1) < 0)
> -        perror("Grabbing evdev mouse device failed");
> -
> -    if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
> -        perror("EVIOCGBIT 0");
> -        close(fd);
> -        return BadMatch;
> -    }
> -    ke = calloc(1, sizeof(Kevdev));
> -    if (!ke) {
> -        close(fd);
> -        return BadAlloc;
> -    }
> -    if (ISBITSET(ev, EV_KEY)) {
> -        if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(ke->keybits)),
> ke->keybits) < 0) {
> -            perror("EVIOCGBIT EV_KEY");
> -            free(ke);
> -            close(fd);
> -            return BadMatch;
> -        }
> -    }
> -    if (ISBITSET(ev, EV_REL)) {
> -        if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(ke->relbits)),
> ke->relbits) < 0) {
> -            perror("EVIOCGBIT EV_REL");
> -            free(ke);
> -            close(fd);
> -            return BadMatch;
> -        }
> -        for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
> -            if (ISBITSET(ke->relbits, ke->max_rel))
> -                break;
> -    }
> -    if (ISBITSET(ev, EV_ABS)) {
> -        int i;
> -
> -        if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ke->absbits)),
> ke->absbits) < 0) {
> -            perror("EVIOCGBIT EV_ABS");
> -            free(ke);
> -            close(fd);
> -            return BadMatch;
> -        }
> -        for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
> -            if (ISBITSET(ke->absbits, ke->max_abs))
> -                break;
> -        for (i = 0; i <= ke->max_abs; i++) {
> -            if (ISBITSET(ke->absbits, i))
> -                if (ioctl(fd, EVIOCGABS(i), &ke->absinfo[i]) < 0) {
> -                    perror("EVIOCGABS");
> -                    break;
> -                }
> -            ke->prevabs[i] = ABS_UNSET;
> -        }
> -        if (i <= ke->max_abs) {
> -            free(ke);
> -            close(fd);
> -            return BadValue;
> -        }
> -    }
> -    if (!KdRegisterFd(fd, EvdevPtrRead, pi)) {
> -        free(ke);
> -        close(fd);
> -        return BadAlloc;
> -    }
> -    pi->driverPrivate = ke;
> -    ke->fd = fd;
> -
> -    return Success;
> -}
> -
> -static void
> -EvdevPtrDisable(KdPointerInfo * pi)
> -{
> -    Kevdev *ke;
> -
> -    ke = pi->driverPrivate;
> -
> -    if (!pi || !pi->driverPrivate)
> -        return;
> -
> -    KdUnregisterFd(pi, ke->fd, TRUE);
> -
> -    if (ioctl(ke->fd, EVIOCGRAB, 0) < 0)
> -        perror("Ungrabbing evdev mouse device failed");
> -
> -    free(ke);
> -    pi->driverPrivate = 0;
> -}
> -
> -static void
> -EvdevPtrFini(KdPointerInfo * pi)
> -{
> -}
> -
> -/*
> - * Evdev keyboard functions
> - */
> -
> -static void
> -readMapping(KdKeyboardInfo * ki)
> -{
> -    if (!ki)
> -        return;
> -
> -    ki->minScanCode = 0;
> -    ki->maxScanCode = 247;
> -}
> -
> -static void
> -EvdevKbdRead(int evdevPort, void *closure)
> -{
> -    KdKeyboardInfo *ki = closure;
> -    struct input_event events[NUM_EVENTS];
> -    int i, n;
> -
> -    n = read(evdevPort, &events, NUM_EVENTS * sizeof(struct input_event));
> -    if (n <= 0) {
> -        if (errno == ENODEV)
> -            DeleteInputDeviceRequest(ki->dixdev);
> -        return;
> -    }
> -
> -    n /= sizeof(struct input_event);
> -    for (i = 0; i < n; i++) {
> -        if (events[i].type == EV_KEY)
> -            KdEnqueueKeyboardEvent(ki, events[i].code, !events[i].value);
> -/* FIXME: must implement other types of events
> -        else
> -            ErrorF("Event type (%d) not delivered\n", events[i].type);
> -*/
> -    }
> -}
> -
> -static Status
> -EvdevKbdInit(KdKeyboardInfo * ki)
> -{
> -    int fd;
> -
> -    if (!ki->path) {
> -        ErrorF("Couldn't find evdev device path\n");
> -        return BadValue;
> -    }
> -    else {
> -        fd = open(ki->path, O_RDWR);
> -        if (fd < 0) {
> -            ErrorF("Failed to open evdev device %s\n", ki->path);
> -            return BadMatch;
> -        }
> -    }
> -
> -    close(fd);
> -
> -    if (!ki->name)
> -        ki->name = strdup("Evdev keyboard");
> -
> -    readMapping(ki);
> -
> -    return Success;
> -}
> -
> -static Status
> -EvdevKbdEnable(KdKeyboardInfo * ki)
> -{
> -    unsigned long ev[NBITS(EV_MAX)];
> -    Kevdev *ke;
> -    int fd;
> -
> -    if (!ki || !ki->path)
> -        return BadImplementation;
> -
> -    fd = open(ki->path, O_RDWR);
> -    if (fd < 0)
> -        return BadMatch;
> -
> -    if (ioctl(fd, EVIOCGRAB, 1) < 0)
> -        perror("Grabbing evdev keyboard device failed");
> -
> -    if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
> -        perror("EVIOCGBIT 0");
> -        close(fd);
> -        return BadMatch;
> -    }
> -
> -    ke = calloc(1, sizeof(Kevdev));
> -    if (!ke) {
> -        close(fd);
> -        return BadAlloc;
> -    }
> -
> -    if (!KdRegisterFd(fd, EvdevKbdRead, ki)) {
> -        free(ke);
> -        close(fd);
> -        return BadAlloc;
> -    }
> -    ki->driverPrivate = ke;
> -    ke->fd = fd;
> -
> -    return Success;
> -}
> -
> -static void
> -EvdevKbdLeds(KdKeyboardInfo * ki, int leds)
> -{
> -    struct input_event event;
> -    Kevdev             *ke;
> -    int                i;
> -
> -    if (!ki)
> -        return;
> -
> -    ke = ki->driverPrivate;
> -
> -    if (!ke)
> -        return;
> -
> -    memset(&event, 0, sizeof(event));
> -
> -    event.type = EV_LED;
> -    event.code = LED_CAPSL;
> -    event.value = leds & (1 << 0) ? 1 : 0;
> -    i = write(ke->fd, (char *) &event, sizeof(event));
> -    (void) i;
> -
> -    event.type = EV_LED;
> -    event.code = LED_NUML;
> -    event.value = leds & (1 << 1) ? 1 : 0;
> -    i = write(ke->fd, (char *) &event, sizeof(event));
> -    (void) i;
> -
> -    event.type = EV_LED;
> -    event.code = LED_SCROLLL;
> -    event.value = leds & (1 << 2) ? 1 : 0;
> -    i = write(ke->fd, (char *) &event, sizeof(event));
> -    (void) i;
> -
> -    event.type = EV_LED;
> -    event.code = LED_COMPOSE;
> -    event.value = leds & (1 << 3) ? 1 : 0;
> -    i = write(ke->fd, (char *) &event, sizeof(event));
> -    (void) i;
> -}
> -
> -static void
> -EvdevKbdBell(KdKeyboardInfo * ki, int volume, int frequency, int duration)
> -{
> -}
> -
> -static void
> -EvdevKbdDisable(KdKeyboardInfo * ki)
> -{
> -    Kevdev *ke;
> -
> -    ke = ki->driverPrivate;
> -
> -    if (!ki || !ki->driverPrivate)
> -        return;
> -
> -    KdUnregisterFd(ki, ke->fd, TRUE);
> -
> -    if (ioctl(ke->fd, EVIOCGRAB, 0) < 0)
> -        perror("Ungrabbing evdev keyboard device failed");
> -
> -    free(ke);
> -    ki->driverPrivate = 0;
> -}
> -
> -static void
> -EvdevKbdFini(KdKeyboardInfo * ki)
> -{
> -}
> -
> -KdPointerDriver LinuxEvdevMouseDriver = {
> -    "evdev",
> -    EvdevPtrInit,
> -    EvdevPtrEnable,
> -    EvdevPtrDisable,
> -    EvdevPtrFini,
> -    NULL,
> -};
> -
> -KdKeyboardDriver LinuxEvdevKeyboardDriver = {
> -    "evdev",
> -    EvdevKbdInit,
> -    EvdevKbdEnable,
> -    EvdevKbdLeds,
> -    EvdevKbdBell,
> -    EvdevKbdDisable,
> -    EvdevKbdFini,
> -    NULL,
> -};
> diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
> deleted file mode 100644
> index 20f1fce..0000000
> --- a/hw/kdrive/linux/linux.c
> +++ /dev/null
> @@ -1,347 +0,0 @@
> -/*
> - * Copyright © 1999 Keith Packard
> - *
> - * Permission to use, copy, modify, distribute, and sell this software
> and its
> - * documentation for any purpose is hereby granted without fee, provided
> that
> - * the above copyright notice appear in all copies and that both that
> - * copyright notice and this permission notice appear in supporting
> - * documentation, and that the name of Keith Packard not be used in
> - * advertising or publicity pertaining to distribution of the software
> without
> - * specific, written prior permission.  Keith Packard makes no
> - * representations about the suitability of this software for any
> purpose.  It
> - * is provided "as is" without express or implied warranty.
> - *
> - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
> USE,
> - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
> - * PERFORMANCE OF THIS SOFTWARE.
> - */
> -
> -#ifdef HAVE_CONFIG_H
> -#include <kdrive-config.h>
> -#endif
> -#include "kdrive.h"
> -#include <errno.h>
> -#include <linux/vt.h>
> -#include <linux/kd.h>
> -#include <sys/stat.h>
> -#include <sys/ioctl.h>
> -#include <X11/keysym.h>
> -#include <linux/apm_bios.h>
> -
> -#ifdef TSLIB
> -extern KdPointerDriver TsDriver;
> -#endif
> -#ifdef KDRIVE_EVDEV
> -extern KdPointerDriver LinuxEvdevMouseDriver;
> -extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
> -#endif
> -
> -static int vtno;
> -int LinuxConsoleFd;
> -int LinuxApmFd = -1;
> -static int activeVT;
> -static Bool enabled;
> -
> -static void
> -LinuxVTRequest(int sig)
> -{
> -    kdSwitchPending = TRUE;
> -}
> -
> -/* Check before chowning -- this avoids touching the file system */
> -static void
> -LinuxCheckChown(const char *file)
> -{
> -    struct stat st;
> -    __uid_t u;
> -    __gid_t g;
> -    int r;
> -
> -    if (stat(file, &st) < 0)
> -        return;
> -    u = getuid();
> -    g = getgid();
> -    if (st.st_uid != u || st.st_gid != g) {
> -        r = chown(file, u, g);
> -        (void) r;
> -    }
> -}
> -
> -static int
> -LinuxInit(void)
> -{
> -    int fd = -1;
> -    char vtname[11];
> -    struct vt_stat vts;
> -
> -    LinuxConsoleFd = -1;
> -    /* check if we're run with euid==0 */
> -    if (geteuid() != 0) {
> -        FatalError("LinuxInit: Server must be suid root\n");
> -    }
> -
> -    if (kdVirtualTerminal >= 0)
> -        vtno = kdVirtualTerminal;
> -    else {
> -        if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) {
> -            FatalError("LinuxInit: Cannot open /dev/tty0 (%s)\n",
> -                       strerror(errno));
> -        }
> -        if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) {
> -            FatalError("xf86OpenConsole: Cannot find a free VT\n");
> -        }
> -        close(fd);
> -    }
> -
> -    snprintf(vtname, sizeof(vtname), "/dev/tty%d", vtno);       /*
> /dev/tty1-64 */
> -
> -    if ((LinuxConsoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) < 0) {
> -        FatalError("LinuxInit: Cannot open %s (%s)\n", vtname,
> strerror(errno));
> -    }
> -
> -    /* change ownership of the vt */
> -    LinuxCheckChown(vtname);
> -
> -    /*
> -     * the current VT device we're running on is not "console", we want
> -     * to grab all consoles too
> -     *
> -     * Why is this needed?
> -     */
> -    LinuxCheckChown("/dev/tty0");
> -    /*
> -     * Linux doesn't switch to an active vt after the last close of a vt,
> -     * so we do this ourselves by remembering which is active now.
> -     */
> -    memset(&vts, '\0', sizeof(vts));    /* valgrind */
> -    if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0) {
> -        activeVT = vts.v_active;
> -    }
> -
> -    return 1;
> -}
> -
> -static void
> -LinuxSetSwitchMode(int mode)
> -{
> -    struct sigaction act;
> -    struct vt_mode VT;
> -
> -    if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) {
> -        FatalError("LinuxInit: VT_GETMODE failed\n");
> -    }
> -
> -    if (mode == VT_PROCESS) {
> -        act.sa_handler = LinuxVTRequest;
> -        sigemptyset(&act.sa_mask);
> -        act.sa_flags = 0;
> -        sigaction(SIGUSR1, &act, 0);
> -
> -        VT.mode = mode;
> -        VT.relsig = SIGUSR1;
> -        VT.acqsig = SIGUSR1;
> -    }
> -    else {
> -        act.sa_handler = SIG_IGN;
> -        sigemptyset(&act.sa_mask);
> -        act.sa_flags = 0;
> -        sigaction(SIGUSR1, &act, 0);
> -
> -        VT.mode = mode;
> -        VT.relsig = 0;
> -        VT.acqsig = 0;
> -    }
> -    if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) {
> -        FatalError("LinuxInit: VT_SETMODE failed\n");
> -    }
> -}
> -
> -static Bool LinuxApmRunning;
> -
> -static void
> -LinuxApmNotify(int fd, int mask, void *blockData)
> -{
> -    apm_event_t event;
> -    Bool running = LinuxApmRunning;
> -    int cmd = APM_IOC_SUSPEND;
> -
> -    while (read(fd, &event, sizeof(event)) == sizeof(event)) {
> -        switch (event) {
> -        case APM_SYS_STANDBY:
> -        case APM_USER_STANDBY:
> -            running = FALSE;
> -            cmd = APM_IOC_STANDBY;
> -            break;
> -        case APM_SYS_SUSPEND:
> -        case APM_USER_SUSPEND:
> -        case APM_CRITICAL_SUSPEND:
> -            running = FALSE;
> -            cmd = APM_IOC_SUSPEND;
> -            break;
> -        case APM_NORMAL_RESUME:
> -        case APM_CRITICAL_RESUME:
> -        case APM_STANDBY_RESUME:
> -            running = TRUE;
> -            break;
> -        }
> -    }
> -    if (running && !LinuxApmRunning) {
> -        KdResume();
> -        LinuxApmRunning = TRUE;
> -    }
> -    else if (!running && LinuxApmRunning) {
> -        KdSuspend();
> -        LinuxApmRunning = FALSE;
> -        ioctl(fd, cmd, 0);
> -    }
> -}
> -
> -#ifdef FNONBLOCK
> -#define NOBLOCK FNONBLOCK
> -#else
> -#define NOBLOCK FNDELAY
> -#endif
> -
> -static void
> -LinuxEnable(void)
> -{
> -    if (enabled)
> -        return;
> -    if (kdSwitchPending) {
> -        kdSwitchPending = FALSE;
> -        ioctl(LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
> -    }
> -    /*
> -     * Open the APM driver
> -     */
> -    LinuxApmFd = open("/dev/apm_bios", 2);
> -    if (LinuxApmFd < 0 && errno == ENOENT)
> -        LinuxApmFd = open("/dev/misc/apm_bios", 2);
> -    if (LinuxApmFd >= 0) {
> -        LinuxApmRunning = TRUE;
> -        fcntl(LinuxApmFd, F_SETFL, fcntl(LinuxApmFd, F_GETFL) | NOBLOCK);
> -        SetNotifyFd(LinuxApmFd, LinuxApmNotify, X_NOTIFY_READ, NULL);
> -    }
> -
> -    /*
> -     * now get the VT
> -     */
> -    LinuxSetSwitchMode(VT_AUTO);
> -    if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0) {
> -        FatalError("LinuxInit: VT_ACTIVATE failed\n");
> -    }
> -    if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0) {
> -        FatalError("LinuxInit: VT_WAITACTIVE failed\n");
> -    }
> -    LinuxSetSwitchMode(VT_PROCESS);
> -    if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
> -        FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
> -    }
> -    enabled = TRUE;
> -}
> -
> -static void
> -LinuxDisable(void)
> -{
> -    ioctl(LinuxConsoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ...
> */
> -    if (kdSwitchPending) {
> -        kdSwitchPending = FALSE;
> -        ioctl(LinuxConsoleFd, VT_RELDISP, 1);
> -    }
> -    enabled = FALSE;
> -    if (LinuxApmFd >= 0) {
> -        RemoveNotifyFd(LinuxApmFd);
> -        close(LinuxApmFd);
> -        LinuxApmFd = -1;
> -    }
> -}
> -
> -static void
> -LinuxFini(void)
> -{
> -    struct vt_mode VT;
> -    struct vt_stat vts;
> -    int fd;
> -
> -    if (LinuxConsoleFd < 0)
> -        return;
> -
> -    if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) != -1) {
> -        VT.mode = VT_AUTO;
> -        ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
> -    }
> -    memset(&vts, '\0', sizeof(vts));    /* valgrind */
> -    ioctl(LinuxConsoleFd, VT_GETSTATE, &vts);
> -    if (vtno == vts.v_active) {
> -        /*
> -         * Find a legal VT to switch to, either the one we started from
> -         * or the lowest active one that isn't ours
> -         */
> -        if (activeVT < 0 ||
> -            activeVT == vts.v_active || !(vts.v_state & (1 << activeVT)))
> {
> -            for (activeVT = 1; activeVT < 16; activeVT++)
> -                if (activeVT != vtno && (vts.v_state & (1 << activeVT)))
> -                    break;
> -            if (activeVT == 16)
> -                activeVT = -1;
> -        }
> -        /*
> -         * Perform a switch back to the active VT when we were started
> -         */
> -        if (activeVT >= -1) {
> -            ioctl(LinuxConsoleFd, VT_ACTIVATE, activeVT);
> -            ioctl(LinuxConsoleFd, VT_WAITACTIVE, activeVT);
> -            activeVT = -1;
> -        }
> -    }
> -    close(LinuxConsoleFd);      /* make the vt-manager happy */
> -    LinuxConsoleFd = -1;
> -    fd = open("/dev/tty0", O_RDWR | O_NDELAY, 0);
> -    if (fd >= 0) {
> -        memset(&vts, '\0', sizeof(vts));        /* valgrind */
> -        ioctl(fd, VT_GETSTATE, &vts);
> -        if (ioctl(fd, VT_DISALLOCATE, vtno) < 0)
> -            fprintf(stderr, "Can't deallocate console %d %s\n", vtno,
> -                    strerror(errno));
> -        close(fd);
> -    }
> -    return;
> -}
> -
> -void
> -KdOsAddInputDrivers(void)
> -{
> -#ifdef TSLIB
> -    KdAddPointerDriver(&TsDriver);
> -#endif
> -#ifdef KDRIVE_EVDEV
> -    KdAddPointerDriver(&LinuxEvdevMouseDriver);
> -    KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
> -#endif
> -}
> -
> -static void
> -LinuxBell(int volume, int pitch, int duration)
> -{
> -    if (volume && pitch)
> -        ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
> -              (((unsigned long) duration * volume / 50) << 16));
> -}
> -
> -KdOsFuncs LinuxFuncs = {
> -    .Init = LinuxInit,
> -    .Enable = LinuxEnable,
> -    .Disable = LinuxDisable,
> -    .Fini = LinuxFini,
> -    .Bell = LinuxBell,
> -};
> -
> -void
> -OsVendorInit(void)
> -{
> -    KdOsInit(&LinuxFuncs);
> -}
> diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
> deleted file mode 100644
> index 0cdb4ea..0000000
> --- a/hw/kdrive/linux/tslib.c
> +++ /dev/null
> @@ -1,194 +0,0 @@
> -/*
> - * TSLIB based touchscreen driver for KDrive
> - * Porting to new input API and event queueing by Daniel Stone.
> - * Derived from ts.c by Keith Packard
> - * Derived from ps2.c by Jim Gettys
> - *
> - * Copyright © 1999 Keith Packard
> - * Copyright © 2000 Compaq Computer Corporation
> - * Copyright © 2002 MontaVista Software Inc.
> - * Copyright © 2005 OpenedHand Ltd.
> - * Copyright © 2006 Nokia Corporation
> - *
> - * Permission to use, copy, modify, distribute, and sell this software
> and its
> - * documentation for any purpose is hereby granted without fee, provided
> that
> - * the above copyright notice appear in all copies and that both that
> - * copyright notice and this permission notice appear in supporting
> - * documentation, and that the name of the authors and/or copyright
> holders
> - * not be used in advertising or publicity pertaining to distribution of
> the
> - * software without specific, written prior permission.  The authors
> and/or
> - * copyright holders make no representations about the suitability of this
> - * software for any purpose.  It is provided "as is" without express or
> - * implied warranty.
> - *
> - * THE AUTHORS AND/OR COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH
> REGARD
> - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
> - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS AND/OR COPYRIGHT HOLDERS BE
> - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
> DAMAGES
> - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> - */
> -
> -#ifdef HAVE_KDRIVE_CONFIG_H
> -#include <kdrive-config.h>
> -#endif
> -
> -#include <X11/X.h>
> -#include <X11/Xproto.h>
> -#include "inputstr.h"
> -#include "scrnintstr.h"
> -#include "kdrive.h"
> -#include <sys/ioctl.h>
> -#include <tslib.h>
> -#include <dirent.h>
> -#include <linux/input.h>
> -
> -struct TslibPrivate {
> -    int fd;
> -    int lastx, lasty;
> -    struct tsdev *tsDev;
> -    void (*raw_event_hook) (int x, int y, int pressure, void *closure);
> -    void *raw_event_closure;
> -    int phys_screen;
> -};
> -
> -static void
> -TsRead(int fd, void *closure)
> -{
> -    KdPointerInfo *pi = closure;
> -    struct TslibPrivate *private = pi->driverPrivate;
> -    struct ts_sample event;
> -    long x = 0, y = 0;
> -    unsigned long flags;
> -
> -    if (private->raw_event_hook) {
> -        while (ts_read_raw(private->tsDev, &event, 1) == 1)
> -            private->raw_event_hook(event.x, event.y, event.pressure,
> -                                    private->raw_event_closure);
> -        return;
> -    }
> -
> -    while (ts_read(private->tsDev, &event, 1) == 1) {
> -        if (event.pressure) {
> -            flags = KD_BUTTON_1;
> -
> -            /*
> -             * Here we test for the touch screen driver actually being on
> the
> -             * touch screen, if it is we send absolute coordinates. If
> not,
> -             * then we send delta's so that we can track the entire vga
> screen.
> -             */
> -            if (KdCurScreen == private->phys_screen) {
> -                x = event.x;
> -                y = event.y;
> -            }
> -            else {
> -                flags |= KD_MOUSE_DELTA;
> -                if ((private->lastx == 0) || (private->lasty == 0)) {
> -                    x = event.x;
> -                    y = event.y;
> -                }
> -                else {
> -                    x = event.x - private->lastx;
> -                    y = event.y - private->lasty;
> -                }
> -            }
> -            private->lastx = event.x;
> -            private->lasty = event.y;
> -        }
> -        else {
> -            flags = 0;
> -            x = private->lastx;
> -            y = private->lasty;
> -        }
> -
> -        KdEnqueuePointerEvent(pi, flags, x, y, event.pressure);
> -    }
> -}
> -
> -static Status
> -TslibEnable(KdPointerInfo * pi)
> -{
> -    struct TslibPrivate *private = pi->driverPrivate;
> -
> -    private->raw_event_hook = NULL;
> -    private->raw_event_closure = NULL;
> -    if (!pi->path) {
> -        pi->path = strdup("/dev/input/touchscreen0");
> -        ErrorF("[tslib/TslibEnable] no device path given, trying %s\n",
> -               pi->path);
> -    }
> -
> -    private->tsDev = ts_open(pi->path, 0);
> -    if (!private->tsDev) {
> -        ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path);
> -        return BadAlloc;
> -    }
> -
> -    if (ts_config(private->tsDev)) {
> -        ErrorF("[tslib/TslibEnable] failed to load configuration\n");
> -        ts_close(private->tsDev);
> -        private->tsDev = NULL;
> -        return BadValue;
> -    }
> -
> -    private->fd = ts_fd(private->tsDev);
> -
> -    KdRegisterFd(private->fd, TsRead, pi);
> -
> -    return Success;
> -}
> -
> -static void
> -TslibDisable(KdPointerInfo * pi)
> -{
> -    struct TslibPrivate *private = pi->driverPrivate;
> -
> -    if (private->fd)
> -        KdUnregisterFd(pi, private->fd, TRUE);
> -
> -    if (private->tsDev)
> -        ts_close(private->tsDev);
> -
> -    private->fd = 0;
> -    private->tsDev = NULL;
> -}
> -
> -static Status
> -TslibInit(KdPointerInfo * pi)
> -{
> -    struct TslibPrivate *private = NULL;
> -
> -    if (!pi || !pi->dixdev)
> -        return !Success;
> -
> -    pi->driverPrivate = (struct TslibPrivate *)
> -        calloc(sizeof(struct TslibPrivate), 1);
> -    if (!pi->driverPrivate)
> -        return !Success;
> -
> -    private = pi->driverPrivate;
> -    /* hacktastic */
> -    private->phys_screen = 0;
> -    pi->nAxes = 3;
> -    pi->name = strdup("Touchscreen");
> -    pi->inputClass = KD_TOUCHSCREEN;
> -
> -    return Success;
> -}
> -
> -static void
> -TslibFini(KdPointerInfo * pi)
> -{
> -    free(pi->driverPrivate);
> -    pi->driverPrivate = NULL;
> -}
> -
> -KdPointerDriver TsDriver = {
> -    "tslib",
> -    TslibInit,
> -    TslibEnable,
> -    TslibDisable,
> -    TslibFini,
> -    NULL,
> -};
> --
> 2.9.3
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel




-- 
*Laércio de Sousa*

*Orientador de Informática*

*Rua Ismael da Silva Mello, 559, Mogi Moderno, **Mogi das Cruzes - SP*
*CEP 08717-390*
Telefone: (11) 4726-8313 / 4796-5656
Facebook: https://www.facebook.com/egruppi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170818/17bde062/attachment-0001.html>


More information about the xorg-devel mailing list