accel: Use udev tags to know which driver to use

This means that the buffer driver can now handle more than the
bog-standard HID sensor hub, and that the polling driver can handle any
IIO polling device.

Closes: #39
This commit is contained in:
Bastien Nocera
2016-11-23 14:59:17 +01:00
parent c1bc67339b
commit ccaf37e00a
2 changed files with 4 additions and 11 deletions

View File

@@ -156,13 +156,10 @@ read_orientation (gpointer user_data)
static gboolean static gboolean
iio_buffer_accel_discover (GUdevDevice *device) iio_buffer_accel_discover (GUdevDevice *device)
{ {
if (g_strcmp0 (g_udev_device_get_subsystem (device), "iio") != 0) if (g_strcmp0 (g_udev_device_get_property (device, "IIO_SENSOR_PROXY_TYPE"), "iio-buffer-accel") != 0)
return FALSE; return FALSE;
if (g_strcmp0 ("accel_3d", g_udev_device_get_sysfs_attr (device, "name")) != 0) g_debug ("Found IIO buffer accelerometer at %s", g_udev_device_get_sysfs_path (device));
return FALSE;
g_debug ("Found accel_3d at %s", g_udev_device_get_sysfs_path (device));
return TRUE; return TRUE;
} }

View File

@@ -88,14 +88,10 @@ poll_orientation (gpointer user_data)
static gboolean static gboolean
iio_poll_accel_discover (GUdevDevice *device) iio_poll_accel_discover (GUdevDevice *device)
{ {
if (g_strcmp0 (g_udev_device_get_subsystem (device), "iio") != 0) if (g_strcmp0 (g_udev_device_get_property (device, "IIO_SENSOR_PROXY_TYPE"), "iio-poll-accel") != 0)
return FALSE; return FALSE;
if (g_strcmp0 ("i2c-SMO8500:00", g_udev_device_get_sysfs_attr (device, "name")) != 0 && g_debug ("Found IIO poll accelerometer at %s", g_udev_device_get_sysfs_path (device));
g_strcmp0 ("i2c-KIOX000A:00", g_udev_device_get_sysfs_attr (device, "name")) != 0)
return FALSE;
g_debug ("Found polling accelerometer at %s", g_udev_device_get_sysfs_path (device));
return TRUE; return TRUE;
} }