Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ You may override the defaults. In most cases, though, you won't need to do so:
TSLIB_PLUGINDIR Plugin directory.
Default: ${datadir}/plugins

TSLIB_CONSOLEDEVICE Console device. (not needed when using --with-sdl2)
TSLIB_CONSOLEDEVICE Console device. (not needed when using --with-sdl2
or --with-drm)
Default: /dev/tty

TSLIB_FBDEVICE Framebuffer device.
TSLIB_FBDEVICE Framebuffer device. (not needed when using --with-drm)
Default: /dev/fb0

TSLIB_DRMDEVICE DRM device. (only when built with --with-drm)
Default: /dev/dri/card0

### use the filtered result in your system (X.org method)
If you're using X.org graphical X server, things should be very easy. Install
tslib and [xf86-input-tslib](https://github.com/merge/xf86-input-tslib),
Expand Down Expand Up @@ -648,6 +652,7 @@ compatibility.

* libc (with libdl only when building dynamically linked)
* libsdl2-dev (only when using `--with-sdl2` for [SDL2](https://www.libsdl.org/) graphical applications)
* libdrm-dev (only when using `--with-drm` for DRM/KMS graphical applications)

### related libraries

Expand Down Expand Up @@ -773,6 +778,15 @@ implementation of the necessary graphical tools using SDL2. They are more portab
but require more resources to run. To use them, make sure you have SDL2 and the
development headers installed and use `./configure --with-sdl2`.

### DRM/KMS support for graphical tools

On systems without a framebuffer device (`/dev/fb0`), graphical tools like
`ts_calibrate`, `ts_test`, and `ts_test_mt` can be built to use DRM/KMS
instead. This uses libdrm with dumb buffers for direct rendering. To use this,
make sure you have libdrm and the development headers installed and use
`./configure --with-drm`. The DRM device can be configured via the
`TSLIB_DRMDEVICE` environment variable (default: `/dev/dri/card0`).

### portability

tslib is cross-platform; you should be able to build it on a large variety of
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ AS_IF([test "x$with_sdl2" = "xyes"], [
AC_CHECK_LIB([SDL2], [SDL_Init], [], [exit 1])
])

AC_ARG_WITH(drm,
[AS_HELP_STRING([--with-drm], [build graphical tools using DRM/KMS instead of fbdev])],
[with_drm=$withval],
[with_drm=no])

AM_CONDITIONAL(DRM, test x"$with_drm" = "xyes")
AS_IF([test "x$with_drm" = "xyes"], [
AC_DEFINE(HAVE_LIBDRM, 1, [Use libdrm for graphical tools.])
PKG_CHECK_MODULES([LIBDRM], [libdrm], [], [AC_MSG_ERROR([libdrm not found])])
])

# libts Library versioning
# increment if the interface changed
LT_CURRENT=10
Expand Down
11 changes: 11 additions & 0 deletions doc/ts.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ We try to open /dev/input/ts, /dev/input/touchscreen and /dev/touchscreen/ucb1x0
\fBTSLIB_CONSOLEDEVICE\fR
.RS 4
Tslib default console device\&.
Not needed when using \-\-with\-sdl2 or \-\-with\-drm\&.
.sp
Default:
/dev/tty
Expand Down Expand Up @@ -92,11 +93,21 @@ Default;
\fBTSLIB_FBDEVICE\fR
.RS 4
Framebuffer device to use for the touchscreen support\&.
Not used when built with \-\-with\-drm\&.
.sp
Default:
/dev/fb0\&.
.RE
.PP
\fBTSLIB_DRMDEVICE\fR
.RS 4
DRM device to use for the touchscreen support\&.
Only used when built with \-\-with\-drm\&.
.sp
Default:
/dev/dri/card0\&.
.RE
.PP
\fBTSLIB_PLUGINDIR\fR
.RS 4
Plugin directory for tslib\&.
Expand Down
18 changes: 16 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@


option(with-sdl "build graphical tools like ts_calibrate using SDL" OFF)
option(with-drm "build graphical tools using DRM/KMS instead of fbdev" OFF)

if (${with-sdl})
find_package(SDL2 REQUIRED)
endif()

if (${with-drm})
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBDRM REQUIRED libdrm)
endif()

function(TSLIB_ADD_TEST_ON_PLATFORMS test_name)
foreach(condition IN LISTS ARGN)
if (${condition})
Expand All @@ -23,15 +29,23 @@ function(TSLIB_ADD_TEST_ON_PLATFORMS test_name)
if (${with-sdl})
target_link_libraries(${test_name} PUBLIC SDL2)
endif()
if (${with-drm})
target_include_directories(${test_name} PRIVATE ${LIBDRM_INCLUDE_DIRS})
target_link_libraries(${test_name} PUBLIC ${LIBDRM_LIBRARIES})
endif()
set(tslib_tests ${tslib_tests} ${test_name} PARENT_SCOPE)
break()
endif()
endforeach()
endfunction(TSLIB_ADD_TEST_ON_PLATFORMS)


set(fbutils $<$<PLATFORM_ID:FreeBSD>:fbutils-bsd.c>
$<$<PLATFORM_ID:Linux>:fbutils-linux.c>)
if (${with-drm})
set(fbutils fbutils-drm.c)
else()
set(fbutils $<$<PLATFORM_ID:FreeBSD>:fbutils-bsd.c>
$<$<PLATFORM_ID:Linux>:fbutils-linux.c>)
endif()


if(${with-sdl})
Expand Down
24 changes: 24 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,36 @@ endif

ts_test_SOURCES = ts_test.c testutils.c testutils.h fbutils.h font_8x8.c font_8x16.c font.h
ts_test_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
if DRM
ts_test_SOURCES += fbutils-drm.c
ts_test_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS)
ts_test_LDADD += $(LIBDRM_LIBS)
else
if FREEBSD
ts_test_SOURCES += fbutils-bsd.c
else
ts_test_SOURCES += fbutils-linux.c
endif
endif

if SDL
ts_test_mt_SOURCES = ts_test_mt_sdl.c sdlutils.c sdlutils.h
ts_test_mt_LDADD = $(top_builddir)/src/libts.la -lSDL2 $(LIBEVDEV_LIBS)
else
ts_test_mt_SOURCES = ts_test_mt.c testutils.c testutils.h fbutils.h font_8x8.c font_8x16.c font.h
ts_test_mt_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
if DRM
ts_test_mt_SOURCES += fbutils-drm.c
ts_test_mt_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS)
ts_test_mt_LDADD += $(LIBDRM_LIBS)
else
if FREEBSD
ts_test_mt_SOURCES += fbutils-bsd.c
else
ts_test_mt_SOURCES += fbutils-linux.c
endif
endif
endif

ts_print_SOURCES = ts_print.c
ts_print_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
Expand All @@ -84,20 +96,32 @@ ts_calibrate_LDADD = $(top_builddir)/src/libts.la -lSDL2 $(LIBEVDEV_LIBS)
else
ts_calibrate_SOURCES = ts_calibrate.c ts_calibrate.h ts_calibrate_common.c fbutils.h testutils.c testutils.h font_8x8.c font_8x16.c font.h
ts_calibrate_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
if DRM
ts_calibrate_SOURCES += fbutils-drm.c
ts_calibrate_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS)
ts_calibrate_LDADD += $(LIBDRM_LIBS)
else
if FREEBSD
ts_calibrate_SOURCES += fbutils-bsd.c
else
ts_calibrate_SOURCES += fbutils-linux.c
endif
endif
endif

ts_harvest_SOURCES = ts_harvest.c fbutils.h testutils.c testutils.h font_8x8.c font_8x16.c font.h
ts_harvest_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
if DRM
ts_harvest_SOURCES += fbutils-drm.c
ts_harvest_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS)
ts_harvest_LDADD += $(LIBDRM_LIBS)
else
if FREEBSD
ts_harvest_SOURCES += fbutils-bsd.c
else
ts_harvest_SOURCES += fbutils-linux.c
endif
endif

ts_finddev_SOURCES = ts_finddev.c
ts_finddev_LDADD = $(top_builddir)/src/libts.la $(LIBEVDEV_LIBS)
Expand Down
Loading