summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-11-26 11:26:10 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-12-20 15:01:56 +1000
commit9caf26360367a8b28ca7c6961887052509d61fbd (patch)
treec2c179a38dcd54692b992e399a5af87f7ae3e008
parent493ccdc8f2d1e94dde7f45b2062ac7f91b9a3cf4 (diff)
downloadxf86-input-wacom-9caf26360367a8b28ca7c6961887052509d61fbd.tar.gz
Allow building the driver without serial ISDV4 support
If configured with -Disdv4=false, the ISDV4 serial bits will not be built, including the udev rules and the inputattach helper and service files. This is meson only. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--meson.build68
-rw-r--r--meson_options.txt6
-rw-r--r--src/wcmConfig.c22
-rw-r--r--src/wcmISDV4-stub.c2
-rw-r--r--src/wcmISDV4.c3
-rw-r--r--src/wcmUSB.c3
-rw-r--r--src/xf86WacomDefs.h12
7 files changed, 70 insertions, 46 deletions
diff --git a/meson.build b/meson.build
index 70b5d26..5ff7022 100644
--- a/meson.build
+++ b/meson.build
@@ -119,7 +119,6 @@ src_wacom = [
'src/wcmConfig.c',
'src/wcmFilter.c',
'src/wcmFilter.h',
- 'src/wcmISDV4.c',
'src/wcmTouchFilter.c',
'src/wcmTouchFilter.h',
'src/wcmUSB.c',
@@ -128,7 +127,15 @@ src_wacom = [
'src/xf86Wacom.c',
'src/xf86WacomDefs.h',
'src/xf86Wacom.h',
+ 'src/wcmUSB.c',
]
+
+if get_option('serial-device-support')
+ src_wacom += ['src/wcmISDV4.c']
+else
+ src_wacom += ['src/wcmISDV4-stub.c']
+endif
+
deps_wacom = [
dep_xserver,
dep_libudev,
@@ -156,25 +163,27 @@ configure_file(
)
# Tools
-src_shared = [
- 'tools/tools-shared.h',
- 'tools/tools-shared.c',
-]
+if get_option('serial-device-support')
+ src_shared = [
+ 'tools/tools-shared.h',
+ 'tools/tools-shared.c',
+ ]
-executable(
- 'isdv4-serial-debugger',
- 'tools/isdv4-serial-debugger.c', src_shared,
- dependencies: [dep_libudev],
- include_directories: [dir_include],
- install: true,
-)
-executable(
- 'isdv4-serial-inputattach',
- 'tools/isdv4-serial-inputattach.c', src_shared,
- dependencies: [dep_libudev],
- include_directories: [dir_include],
- install: true,
-)
+ executable(
+ 'isdv4-serial-debugger',
+ 'tools/isdv4-serial-debugger.c', src_shared,
+ dependencies: [dep_libudev],
+ include_directories: [dir_include],
+ install: true,
+ )
+ executable(
+ 'isdv4-serial-inputattach',
+ 'tools/isdv4-serial-inputattach.c', src_shared,
+ dependencies: [dep_libudev],
+ include_directories: [dir_include],
+ install: true,
+ )
+endif
xsetwacom_deps = [dep_xlibs, dep_protos, dep_m]
src_xsetwacom = [
@@ -208,16 +217,17 @@ configure_file(
# Config files
install_data('conf/70-wacom.conf', install_dir: dir_xorg_conf)
-install_data('conf/wacom.rules', install_dir: dir_udev_rules)
-conf_service = configuration_data()
-conf_service.set('BIN_PREFIX', dir_bin)
-configure_file(
- input: 'conf/wacom-inputattach@.service.in',
- output: 'wacom-inputattach@.service',
- configuration: conf_service,
- install_dir: dir_systemd_unit,
-)
-
+if get_option('serial-device-support')
+ install_data('conf/wacom.rules', install_dir: dir_udev_rules)
+ conf_service = configuration_data()
+ conf_service.set('BIN_PREFIX', dir_bin)
+ configure_file(
+ input: 'conf/wacom-inputattach@.service.in',
+ output: 'wacom-inputattach@.service',
+ configuration: conf_service,
+ install_dir: dir_systemd_unit,
+ )
+endif
# Tests
have_wrap = cc.links('''
diff --git a/meson_options.txt b/meson_options.txt
index c2d38b7..5a503cc 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -38,4 +38,8 @@ option('fuzzinterface',
value: false,
description: 'Enable xsetwacom to take NUL-separated commands from stdin [default=no]'
)
-
+option('serial-device-support',
+ type: 'boolean',
+ value: true,
+ description: 'Build with ISDV4 serial support'
+)
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 7f83c9a..0bbbda5 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -423,19 +423,25 @@ static Bool
wcmDetectDeviceClass(WacomDevicePtr priv)
{
WacomCommonPtr common = priv->common;
+ WacomHWClass *classes[] = {
+ WacomGetClassISDV4(),
+ WacomGetClassUSB(),
+ };
if (common->wcmDevCls)
return TRUE;
- /* Bluetooth is also considered as USB */
- if (gWacomISDV4Device.Detect(priv))
- common->wcmDevCls = &gWacomISDV4Device;
- else if (gWacomUSBDevice.Detect(priv))
- common->wcmDevCls = &gWacomUSBDevice;
- else
- wcmLog(priv, W_ERROR, "cannot identify device class.\n");
+ for (size_t i = 0; i < ARRAY_SIZE(classes); i++) {
+ WacomHWClass *cls = classes[i];
+ if (cls && cls->Detect(priv)) {
+ common->wcmDevCls = cls;
+ return TRUE;
+ }
+ }
+
+ wcmLog(priv, W_ERROR, "cannot identify device class.\n");
- return (common->wcmDevCls != NULL);
+ return FALSE;
}
static Bool
diff --git a/src/wcmISDV4-stub.c b/src/wcmISDV4-stub.c
new file mode 100644
index 0000000..f537448
--- /dev/null
+++ b/src/wcmISDV4-stub.c
@@ -0,0 +1,2 @@
+extern void* WacomGetClassISDV4(void);
+void* WacomGetClassISDV4(void) { return (void*)0; }
diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c
index 8a07493..30dde6d 100644
--- a/src/wcmISDV4.c
+++ b/src/wcmISDV4.c
@@ -79,13 +79,14 @@ static int wcmSerialValidate(WacomDevicePtr priv, const unsigned char* data);
static int wcmWaitForTablet(WacomDevicePtr priv, char * data, int size);
static int wcmWriteWait(WacomDevicePtr priv, const char* request);
-WacomDeviceClass gWacomISDV4Device =
+static WacomHWClass gWacomISDV4Device =
{
.Detect = isdv4Detect,
.ProbeKeys = isdv4ProbeKeys,
.ParseOptions = isdv4ParseOptions,
.Init = isdv4Init,
};
+WacomHWClass *WacomGetClassISDV4(void) { return &gWacomISDV4Device; }
static WacomModel isdv4General =
{
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 9125dbd..dd9b619 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -64,13 +64,14 @@ static void usbParseMscEvent(WacomDevicePtr priv,
static void usbDispatchEvents(WacomDevicePtr priv);
static int usbChooseChannel(WacomCommonPtr common, int device_type, unsigned int serial);
-WacomDeviceClass gWacomUSBDevice =
+static WacomHWClass gWacomUSBDevice =
{
.Detect = usbDetect,
.ProbeKeys = usbProbeKeys,
.ParseOptions = usbParseOptions,
.Init = usbWcmInit,
};
+WacomHWClass *WacomGetClassUSB(void) { return &gWacomUSBDevice; }
#define DEFINE_MODEL(mname, identifier, protocol) \
static struct _WacomModel mname = \
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 6e2aff9..c4ec4d4 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -76,7 +76,7 @@ typedef struct _WacomDeviceState WacomDeviceState, *WacomDeviceStatePtr;
typedef struct _WacomChannel WacomChannel, *WacomChannelPtr;
typedef struct _WacomCommonRec WacomCommonRec, *WacomCommonPtr;
typedef struct _WacomFilterState WacomFilterState, *WacomFilterStatePtr;
-typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr;
+typedef struct _WacomHWClass WacomHWClass, *WacomHWClassPtr;
typedef struct _WacomTool WacomTool, *WacomToolPtr;
/******************************************************************************
@@ -336,11 +336,11 @@ struct _WacomChannel
};
/******************************************************************************
- * WacomDeviceClass
+ * WacomHWClass
*****************************************************************************/
/* Functions are called in the order as listed in the struct */
-struct _WacomDeviceClass
+struct _WacomHWClass
{
Bool (*Detect)(WacomDevicePtr priv); /* detect device */
int (*ProbeKeys)(WacomDevicePtr priv); /* set the bits for the keys supported */
@@ -348,8 +348,8 @@ struct _WacomDeviceClass
Bool (*Init)(WacomDevicePtr priv); /* initialize device */
};
-extern WacomDeviceClass gWacomUSBDevice;
-extern WacomDeviceClass gWacomISDV4Device;
+extern WacomHWClass *WacomGetClassISDV4(void);
+extern WacomHWClass *WacomGetClassUSB(void);
/******************************************************************************
* WacomCommonRec
@@ -438,7 +438,7 @@ struct _WacomCommonRec
int wcmThreshold; /* Threshold for button pressure */
WacomChannel wcmChannel[MAX_CHANNELS]; /* channel device state */
- WacomDeviceClassPtr wcmDevCls; /* device class functions */
+ WacomHWClassPtr wcmDevCls; /* device class functions */
WacomModelPtr wcmModel; /* model-specific functions */
int wcmTPCButton; /* set Tablet PC button on/off */
int wcmTouch; /* disable/enable touch event */