Skip to content

Commit

Permalink
check presence of drmSetClientCap()
Browse files Browse the repository at this point in the history
Old libdrm doesn't have drmSetClientCap() and libhost1x fails to compile
in this case. The drmSetClientCap() is optional and needed only by modern
kernels, hence we could compile it conditionally.
  • Loading branch information
digetx committed May 14, 2021
1 parent cb8797c commit d859f9f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ AC_CHECK_HEADER([envytools/rnn.h],
[AC_CHECK_LIB([rnn], [rnn_init], [enable_rnn=yes], [enable_rnn=no], [-lenvyutil -lxml2])])
AM_CONDITIONAL([ENABLE_RNN], [test "x$enable_rnn" = "xyes"])

SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $DRM_CFLAGS"

AC_CHECK_DECL(drmSetClientCap,
[AC_DEFINE(HAVE_LIBDRM_CLIENT_CAP, 1,
[Have drmSetClientCap API])], [],
[#include <xf86drm.h>])

CPPFLAGS="$SAVE_CPPFLAGS"

AC_CONFIG_FILES([
src/libgrate/libgrate.pc
])
Expand Down
6 changes: 6 additions & 0 deletions src/libhost1x/host1x-drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
Expand Down Expand Up @@ -550,6 +554,7 @@ static int drm_display_create(struct drm_display **displayp, struct drm *drm)
if (err < 0)
goto try_x11;

#ifdef HAVE_LIBDRM_CLIENT_CAP
err = drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1);
if (err)
host1x_error("drmSetClientCap(ATOMIC) failed: %d\n", err);
Expand All @@ -558,6 +563,7 @@ static int drm_display_create(struct drm_display **displayp, struct drm *drm)
if (err)
host1x_error("drmSetClientCap(UNIVERSAL_PLANES) failed: %d\n",
err);
#endif

err = drm_display_setup(display, drm->base.options->display_id);
if (err < 0)
Expand Down
8 changes: 8 additions & 0 deletions src/libhost1x/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ if x11.found() and \
libhost1x_deps += dependency('xcb-icccm')
endif

cc = meson.get_compiler('c')

if cc.has_function('drmSetClientCap',
prefix: '#include <xf86drm.h>',
dependencies : [libdrm])
libhost1x_c_args += '-DHAVE_LIBDRM_CLIENT_CAP'
endif

libhost1x = shared_library('host1x',
libhost1x_sources,
include_directories : include_directories('../../include'),
Expand Down

0 comments on commit d859f9f

Please sign in to comment.