temp/iio-sensor-proxy: upgrade SSC patches (MR 5215)
Include latest fixes for SSC support and require building against libssc 0.1.6 or higher. [ci:skip-build]: already built successfully in CI
This commit is contained in:
parent
bcc52c36bb
commit
372ccb3cf2
10 changed files with 419 additions and 455 deletions
|
@ -1,34 +1,21 @@
|
|||
From 4fd3611f93b0a35e8311c6a6e3fe03545154d8bb Mon Sep 17 00:00:00 2001
|
||||
From e651b07633f5a9a3bd499a2e3aaf2f8b7e4f8cef Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Sun, 23 Apr 2023 16:54:10 +0200
|
||||
Subject: [PATCH 1/7] iio-sensor-proxy: depend on libssc
|
||||
Subject: [PATCH 1/8] iio-sensor-proxy: depend on libssc
|
||||
|
||||
Add libssc library to iio-sensor-proxy and discover FastRPC
|
||||
devices as possible subsystems for sensors. The presence of
|
||||
FastRPC devices indicate the support for Qualcomm Snapdragon Sensor
|
||||
Core (SSC).
|
||||
---
|
||||
data/80-iio-sensor-proxy.rules | 2 +
|
||||
meson.build | 3 +
|
||||
meson_options.txt | 4 ++
|
||||
src/drivers.h | 7 ++
|
||||
src/drv-ssc-proximity.c | 121 +++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 21 +++++-
|
||||
src/meson.build | 7 ++
|
||||
7 files changed, 164 insertions(+), 1 deletion(-)
|
||||
create mode 100644 src/drv-ssc-proximity.c
|
||||
meson.build | 3 +++
|
||||
meson_options.txt | 4 ++++
|
||||
src/iio-sensor-proxy.c | 15 ++++++++++++++-
|
||||
src/meson.build | 7 +++++++
|
||||
4 files changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/data/80-iio-sensor-proxy.rules b/data/80-iio-sensor-proxy.rules
|
||||
index 85d93f9..bd917b2 100644
|
||||
--- a/data/80-iio-sensor-proxy.rules
|
||||
+++ b/data/80-iio-sensor-proxy.rules
|
||||
@@ -16,6 +16,8 @@ SUBSYSTEM=="iio", TEST=="scan_elements/in_intensity_both_en", ENV{IIO_SENSOR_PRO
|
||||
SUBSYSTEM=="iio", TEST=="in_proximity_raw", ENV{IIO_SENSOR_PROXY_TYPE}+="iio-poll-proximity"
|
||||
SUBSYSTEM=="input", ENV{ID_INPUT_ACCELEROMETER}=="1", ENV{IIO_SENSOR_PROXY_TYPE}+="input-accel"
|
||||
|
||||
+SUBSYSTEM=="misc", KERNEL=="fastrpc-sdsp", ENV{IIO_SENSOR_PROXY_TYPE}+="ssc-accel"
|
||||
+
|
||||
ENV{IIO_SENSOR_PROXY_TYPE}=="", GOTO="iio_sensor_proxy_end"
|
||||
|
||||
# We got here because we have a sensor type, which means we need the service
|
||||
diff --git a/meson.build b/meson.build
|
||||
index b45493f..bef4209 100644
|
||||
index 767e539..fe97a27 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -46,6 +46,9 @@ gio_dep = dependency('gio-2.0')
|
||||
|
@ -56,167 +43,11 @@ index de5fbf4..2b60f82 100644
|
|||
option('gtk_doc',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index b760faa..895cb55 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -160,4 +160,11 @@ extern SensorDriver iio_buffer_light;
|
||||
extern SensorDriver iio_buffer_compass;
|
||||
extern SensorDriver iio_poll_proximity;
|
||||
|
||||
+#ifdef LIBSSC
|
||||
+extern SensorDriver ssc_accel;
|
||||
+extern SensorDriver ssc_light;
|
||||
+extern SensorDriver ssc_compass;
|
||||
+extern SensorDriver ssc_proximity;
|
||||
+#endif
|
||||
+
|
||||
gboolean drv_check_udev_sensor_type (GUdevDevice *device, const gchar *match, const char *name);
|
||||
diff --git a/src/drv-ssc-proximity.c b/src/drv-ssc-proximity.c
|
||||
new file mode 100644
|
||||
index 0000000..5e06967
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-proximity.c
|
||||
@@ -0,0 +1,121 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2023 Dylan Van Assche
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 3 as published by
|
||||
+ * the Free Software Foundation.
|
||||
+ */
|
||||
+
|
||||
+#include "drivers.h"
|
||||
+
|
||||
+#include <fcntl.h>
|
||||
+#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <errno.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <gio/gio.h>
|
||||
+#include <libssc-sensor.h>
|
||||
+#include <libssc-sensor-proximity.h>
|
||||
+
|
||||
+#define QRTR_DEVICE_URI "qrtr://9"
|
||||
+#define UDEV_DEVICE_NAME "fastrpc-sdsp"
|
||||
+#define PROXIMITY_NEAR_LEVEL "PROXIMITY_NEAR_LEVEL"
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorProximity *sensor;
|
||||
+ guint measurement_id;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_proximity_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ g_autoptr (SSCSensorProximity) sensor = NULL;
|
||||
+ g_autoptr (GFile) file = g_file_new_for_uri (QRTR_DEVICE_URI);
|
||||
+ g_autoptr (GError) error = NULL;
|
||||
+
|
||||
+ g_debug ("SUBSYSTEM: %s | NAME: %s", g_udev_device_get_subsystem (device), g_udev_device_get_name (device));
|
||||
+ if (g_strcmp0 (g_udev_device_get_name (device), UDEV_DEVICE_NAME))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ sensor = ssc_sensor_proximity_new_sync (file, NULL, &error);
|
||||
+
|
||||
+ return sensor ? TRUE : FALSE;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+measurement_cb (SSCSensorProximity *sensor, gboolean near, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ ProximityReadings readings;
|
||||
+
|
||||
+ readings.is_near = near ? PROXIMITY_NEAR_TRUE : PROXIMITY_NEAR_FALSE;
|
||||
+ g_debug ("SSC Proximity sensor '%s': near: %s", sensor_device->name, readings.is_near ? "NEAR" : "FAR");
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
+
|
||||
+static SensorDevice *
|
||||
+ssc_proximity_open (GUdevDevice *device)
|
||||
+{
|
||||
+ SensorDevice *sensor_device;
|
||||
+ DrvData *drv_data;
|
||||
+ g_autoptr (GFile) file = g_file_new_for_uri (QRTR_DEVICE_URI);
|
||||
+ g_autoptr (GError) error = NULL;
|
||||
+
|
||||
+ sensor_device = g_new0 (SensorDevice, 1);
|
||||
+ sensor_device->priv = g_new0 (DrvData, 1);
|
||||
+ drv_data = (DrvData *) sensor_device->priv;
|
||||
+
|
||||
+ /* Create sensor */
|
||||
+ drv_data->sensor = ssc_sensor_proximity_new_sync (file, NULL, &error);
|
||||
+ if (!drv_data->sensor) {
|
||||
+ g_warning ("Creating SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ g_object_get (drv_data->sensor,
|
||||
+ SSC_SENSOR_NAME, &sensor_device->name,
|
||||
+ NULL);
|
||||
+
|
||||
+ /* Start listening for measurements */
|
||||
+ drv_data->measurement_id = g_signal_connect (drv_data->sensor,
|
||||
+ "measurement",
|
||||
+ G_CALLBACK (measurement_cb),
|
||||
+ sensor_device);
|
||||
+
|
||||
+ /* Enable sensor */
|
||||
+ if (!ssc_sensor_proximity_open_sync (drv_data->sensor, NULL, &error)) {
|
||||
+ g_warning ("Opening SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ g_object_unref (sensor_device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sensor_device;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+ssc_proximity_close (SensorDevice *sensor_device)
|
||||
+{
|
||||
+ g_autoptr (GError) error = NULL;
|
||||
+ DrvData *drv_data = (DrvData *) sensor_device->priv;
|
||||
+
|
||||
+ /* Stop listening for measurements */
|
||||
+ g_warn_if_fail (drv_data->measurement_id > 0);
|
||||
+ g_signal_handler_disconnect (drv_data->sensor, drv_data->measurement_id);
|
||||
+
|
||||
+ /* Disable sensor */
|
||||
+ if (!ssc_sensor_proximity_close_sync (drv_data->sensor, NULL, &error))
|
||||
+ g_warning ("Closing SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+
|
||||
+ g_clear_object (&drv_data->sensor);
|
||||
+ g_clear_pointer (&sensor_device->priv, g_free);
|
||||
+ g_free (sensor_device);
|
||||
+}
|
||||
+
|
||||
+SensorDriver ssc_proximity = {
|
||||
+ .driver_name = "SSC proximity sensor",
|
||||
+ .type = DRIVER_TYPE_PROXIMITY,
|
||||
+
|
||||
+ .discover = ssc_proximity_discover,
|
||||
+ .open = ssc_proximity_open,
|
||||
+ .close = ssc_proximity_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index 836e742..17debbb 100644
|
||||
index 1884839..220dc71 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -73,6 +73,12 @@ static const SensorDriver * const drivers[] = {
|
||||
&fake_light,
|
||||
&iio_buffer_compass,
|
||||
&iio_poll_proximity,
|
||||
+#ifdef HAS_LIBSSC
|
||||
+ &ssc_accel,
|
||||
+ &ssc_light,
|
||||
+ &ssc_compass,
|
||||
+ &ssc_proximity,
|
||||
+#endif
|
||||
};
|
||||
|
||||
static ReadingsUpdateFunc driver_type_to_callback_func (DriverType type);
|
||||
@@ -122,6 +128,11 @@ find_sensors (GUdevClient *client,
|
||||
@@ -124,6 +124,11 @@ find_sensors (GUdevClient *client,
|
||||
platform = g_udev_client_query_by_subsystem (client, "platform");
|
||||
devices = g_list_concat (devices, input);
|
||||
devices = g_list_concat (devices, platform);
|
||||
|
@ -228,7 +59,7 @@ index 836e742..17debbb 100644
|
|||
|
||||
/* Find the devices */
|
||||
for (l = devices; l != NULL; l = l->next) {
|
||||
@@ -684,7 +695,15 @@ name_acquired_handler (GDBusConnection *connection,
|
||||
@@ -686,7 +691,15 @@ name_acquired_handler (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
SensorData *data = user_data;
|
||||
|
@ -246,7 +77,7 @@ index 836e742..17debbb 100644
|
|||
|
||||
data->client = g_udev_client_new (subsystems);
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 8ddd37b..90d550d 100644
|
||||
index 4b822fc..3e503de 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -1,5 +1,8 @@
|
||||
|
@ -270,5 +101,5 @@ index 8ddd37b..90d550d 100644
|
|||
'iio-sensor-proxy-resources', 'iio-sensor-proxy.gresource.xml',
|
||||
c_name: 'iio_sensor_proxy',
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
||||
|
|
|
@ -1,116 +1,189 @@
|
|||
From 0f9327f15d1d76bc6b7772929e302930d428f167 Mon Sep 17 00:00:00 2001
|
||||
From 27b5c9e0dba5601447b21816e8ee7063c6154268 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Sun, 23 Apr 2023 17:54:46 +0200
|
||||
Subject: [PATCH 2/7] proximity: support SSC proximity sensor
|
||||
Subject: [PATCH 2/8] proximity: support SSC proximity sensor
|
||||
|
||||
Add driver for the proximity sensor exposed by libssc.
|
||||
---
|
||||
src/drivers.h | 5 +----
|
||||
src/drv-ssc-proximity.c | 18 ++++--------------
|
||||
src/iio-sensor-proxy.c | 3 ---
|
||||
src/meson.build | 1 +
|
||||
4 files changed, 6 insertions(+), 21 deletions(-)
|
||||
src/drivers.h | 4 ++
|
||||
src/drv-ssc-proximity.c | 122 ++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 3 +
|
||||
src/meson.build | 6 ++
|
||||
4 files changed, 135 insertions(+)
|
||||
create mode 100644 src/drv-ssc-proximity.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index 895cb55..5dcac8a 100644
|
||||
index 33ad667..464e801 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -160,10 +160,7 @@ extern SensorDriver iio_buffer_light;
|
||||
extern SensorDriver iio_buffer_compass;
|
||||
@@ -161,4 +161,8 @@ extern SensorDriver iio_buffer_compass;
|
||||
extern SensorDriver iio_poll_proximity;
|
||||
extern SensorDriver input_proximity;
|
||||
|
||||
-#ifdef LIBSSC
|
||||
-extern SensorDriver ssc_accel;
|
||||
-extern SensorDriver ssc_light;
|
||||
-extern SensorDriver ssc_compass;
|
||||
+#ifdef HAS_LIBSSC
|
||||
extern SensorDriver ssc_proximity;
|
||||
#endif
|
||||
|
||||
+extern SensorDriver ssc_proximity;
|
||||
+#endif
|
||||
+
|
||||
gboolean drv_check_udev_sensor_type (GUdevDevice *device, const gchar *match, const char *name);
|
||||
diff --git a/src/drv-ssc-proximity.c b/src/drv-ssc-proximity.c
|
||||
index 5e06967..c87a796 100644
|
||||
--- a/src/drv-ssc-proximity.c
|
||||
new file mode 100644
|
||||
index 0000000..0ec8b08
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-proximity.c
|
||||
@@ -18,8 +18,6 @@
|
||||
#include <libssc-sensor.h>
|
||||
#include <libssc-sensor-proximity.h>
|
||||
|
||||
-#define QRTR_DEVICE_URI "qrtr://9"
|
||||
-#define UDEV_DEVICE_NAME "fastrpc-sdsp"
|
||||
#define PROXIMITY_NEAR_LEVEL "PROXIMITY_NEAR_LEVEL"
|
||||
|
||||
typedef struct DrvData {
|
||||
@@ -30,17 +28,11 @@ typedef struct DrvData {
|
||||
static gboolean
|
||||
ssc_proximity_discover (GUdevDevice *device)
|
||||
{
|
||||
- g_autoptr (SSCSensorProximity) sensor = NULL;
|
||||
- g_autoptr (GFile) file = g_file_new_for_uri (QRTR_DEVICE_URI);
|
||||
- g_autoptr (GError) error = NULL;
|
||||
-
|
||||
- g_debug ("SUBSYSTEM: %s | NAME: %s", g_udev_device_get_subsystem (device), g_udev_device_get_name (device));
|
||||
- if (g_strcmp0 (g_udev_device_get_name (device), UDEV_DEVICE_NAME))
|
||||
@@ -0,0 +1,122 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2023 Dylan Van Assche
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 3 as published by
|
||||
+ * the Free Software Foundation.
|
||||
+ */
|
||||
+
|
||||
+#include "drivers.h"
|
||||
+
|
||||
+#include <fcntl.h>
|
||||
+#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <errno.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <gio/gio.h>
|
||||
+#include <libssc-sensor.h>
|
||||
+#include <libssc-sensor-proximity.h>
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorProximity *sensor;
|
||||
+ guint measurement_id;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_proximity_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ SSCSensorProximity *sensor = NULL;
|
||||
+
|
||||
+ /* Verify presence of FastRPC device */
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-proximity", NULL))
|
||||
return FALSE;
|
||||
|
||||
- sensor = ssc_sensor_proximity_new_sync (file, NULL, &error);
|
||||
-
|
||||
- return sensor ? TRUE : FALSE;
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* Open and close SSC proximity sensor for discovering */
|
||||
+ sensor = ssc_sensor_proximity_new_sync (NULL, NULL);
|
||||
+ if (!sensor)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (!ssc_sensor_proximity_close_sync (sensor, NULL, NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_clear_object (&sensor);
|
||||
+
|
||||
+ g_debug ("Found SSC proximity at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -50,7 +42,6 @@ measurement_cb (SSCSensorProximity *sensor, gboolean near, gpointer user_data)
|
||||
ProximityReadings readings;
|
||||
|
||||
readings.is_near = near ? PROXIMITY_NEAR_TRUE : PROXIMITY_NEAR_FALSE;
|
||||
- g_debug ("SSC Proximity sensor '%s': near: %s", sensor_device->name, readings.is_near ? "NEAR" : "FAR");
|
||||
sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
}
|
||||
|
||||
@@ -59,7 +50,6 @@ ssc_proximity_open (GUdevDevice *device)
|
||||
{
|
||||
SensorDevice *sensor_device;
|
||||
DrvData *drv_data;
|
||||
- g_autoptr (GFile) file = g_file_new_for_uri (QRTR_DEVICE_URI);
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
sensor_device = g_new0 (SensorDevice, 1);
|
||||
@@ -67,7 +57,7 @@ ssc_proximity_open (GUdevDevice *device)
|
||||
drv_data = (DrvData *) sensor_device->priv;
|
||||
|
||||
/* Create sensor */
|
||||
- drv_data->sensor = ssc_sensor_proximity_new_sync (file, NULL, &error);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+measurement_cb (SSCSensorProximity *sensor, gboolean near, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ ProximityReadings readings;
|
||||
+
|
||||
+ readings.is_near = near ? PROXIMITY_NEAR_TRUE : PROXIMITY_NEAR_FALSE;
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
+
|
||||
+static SensorDevice *
|
||||
+ssc_proximity_open (GUdevDevice *device)
|
||||
+{
|
||||
+ SensorDevice *sensor_device;
|
||||
+ DrvData *drv_data;
|
||||
+ g_autoptr (GError) error = NULL;
|
||||
+
|
||||
+ sensor_device = g_new0 (SensorDevice, 1);
|
||||
+ sensor_device->priv = g_new0 (DrvData, 1);
|
||||
+ drv_data = (DrvData *) sensor_device->priv;
|
||||
+
|
||||
+ /* Create sensor */
|
||||
+ drv_data->sensor = ssc_sensor_proximity_new_sync (NULL, &error);
|
||||
if (!drv_data->sensor) {
|
||||
g_warning ("Creating SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
return NULL;
|
||||
+ if (!drv_data->sensor) {
|
||||
+ g_warning ("Creating SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ g_object_get (drv_data->sensor,
|
||||
+ SSC_SENSOR_NAME, &sensor_device->name,
|
||||
+ NULL);
|
||||
+
|
||||
+ /* Start listening for measurements */
|
||||
+ drv_data->measurement_id = g_signal_connect (drv_data->sensor,
|
||||
+ "measurement",
|
||||
+ G_CALLBACK (measurement_cb),
|
||||
+ sensor_device);
|
||||
+
|
||||
+ /* Enable sensor */
|
||||
+ if (!ssc_sensor_proximity_open_sync (drv_data->sensor, NULL, &error)) {
|
||||
+ g_warning ("Opening SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ g_object_unref (sensor_device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sensor_device;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+ssc_proximity_close (SensorDevice *sensor_device)
|
||||
+{
|
||||
+ g_autoptr (GError) error = NULL;
|
||||
+ DrvData *drv_data = (DrvData *) sensor_device->priv;
|
||||
+
|
||||
+ /* Stop listening for measurements */
|
||||
+ g_warn_if_fail (drv_data->measurement_id > 0);
|
||||
+ g_signal_handler_disconnect (drv_data->sensor, drv_data->measurement_id);
|
||||
+
|
||||
+ /* Disable sensor */
|
||||
+ if (!ssc_sensor_proximity_close_sync (drv_data->sensor, NULL, &error))
|
||||
+ g_warning ("Closing SSC proximity sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+
|
||||
+ g_clear_object (&drv_data->sensor);
|
||||
+ g_clear_pointer (&sensor_device->priv, g_free);
|
||||
+ g_free (sensor_device);
|
||||
+}
|
||||
+
|
||||
+SensorDriver ssc_proximity = {
|
||||
+ .driver_name = "SSC proximity sensor",
|
||||
+ .type = DRIVER_TYPE_PROXIMITY,
|
||||
+
|
||||
+ .discover = ssc_proximity_discover,
|
||||
+ .open = ssc_proximity_open,
|
||||
+ .close = ssc_proximity_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index 17debbb..dbd3f6e 100644
|
||||
index 220dc71..257c822 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -74,9 +74,6 @@ static const SensorDriver * const drivers[] = {
|
||||
@@ -75,6 +75,9 @@ static const SensorDriver * const drivers[] = {
|
||||
&iio_buffer_compass,
|
||||
&iio_poll_proximity,
|
||||
#ifdef HAS_LIBSSC
|
||||
- &ssc_accel,
|
||||
- &ssc_light,
|
||||
- &ssc_compass,
|
||||
&ssc_proximity,
|
||||
#endif
|
||||
&input_proximity,
|
||||
+#ifdef HAS_LIBSSC
|
||||
+ &ssc_proximity,
|
||||
+#endif
|
||||
};
|
||||
|
||||
static ReadingsUpdateFunc driver_type_to_callback_func (DriverType type);
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 90d550d..7019b1c 100644
|
||||
index 3e503de..9a74481 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -35,6 +35,7 @@ sources = [
|
||||
'drv-iio-buffer-light.c',
|
||||
'drv-iio-buffer-compass.c',
|
||||
'drv-iio-poll-proximity.c',
|
||||
+ 'drv-ssc-proximity.c',
|
||||
'iio-buffer-utils.c',
|
||||
'accel-mount-matrix.c',
|
||||
'accel-scale.c',
|
||||
@@ -45,6 +45,12 @@ sources = [
|
||||
config_h_files,
|
||||
]
|
||||
|
||||
+if get_option('ssc-support')
|
||||
+ sources = sources + [
|
||||
+ 'drv-ssc-proximity.c',
|
||||
+ ]
|
||||
+endif
|
||||
+
|
||||
executable('iio-sensor-proxy',
|
||||
sources,
|
||||
dependencies: deps,
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
From 59f184ccecf212196c0d76b1cb705eab59c51826 Mon Sep 17 00:00:00 2001
|
||||
From cfd4f19473145c3adfba06e2e44c2e6e773f30cc Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Mon, 24 Apr 2023 16:56:20 +0200
|
||||
Subject: [PATCH 3/7] light: support SSC light sensor
|
||||
Subject: [PATCH 3/8] light: support SSC light sensor
|
||||
|
||||
Add driver for the light sensor exposed by libssc.
|
||||
---
|
||||
src/drivers.h | 1 +
|
||||
src/drv-ssc-light.c | 112 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/drv-ssc-light.c | 123 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
4 files changed, 115 insertions(+)
|
||||
4 files changed, 126 insertions(+)
|
||||
create mode 100644 src/drv-ssc-light.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index 5dcac8a..a97528b 100644
|
||||
index 464e801..46df2fd 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -162,6 +162,7 @@ extern SensorDriver iio_poll_proximity;
|
||||
@@ -163,6 +163,7 @@ extern SensorDriver input_proximity;
|
||||
|
||||
#ifdef HAS_LIBSSC
|
||||
extern SensorDriver ssc_proximity;
|
||||
|
@ -25,10 +26,10 @@ index 5dcac8a..a97528b 100644
|
|||
gboolean drv_check_udev_sensor_type (GUdevDevice *device, const gchar *match, const char *name);
|
||||
diff --git a/src/drv-ssc-light.c b/src/drv-ssc-light.c
|
||||
new file mode 100644
|
||||
index 0000000..689eca5
|
||||
index 0000000..e5ad8dd
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-light.c
|
||||
@@ -0,0 +1,112 @@
|
||||
@@ -0,0 +1,123 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2023 Dylan Van Assche
|
||||
+ *
|
||||
|
@ -49,8 +50,6 @@ index 0000000..689eca5
|
|||
+#include <libssc-sensor.h>
|
||||
+#include <libssc-sensor-light.h>
|
||||
+
|
||||
+#define UDEV_DEVICE_NAME "fastrpc-"
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorLight *sensor;
|
||||
+ guint measurement_id;
|
||||
|
@ -59,9 +58,22 @@ index 0000000..689eca5
|
|||
+static gboolean
|
||||
+ssc_light_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ SSCSensorLight *sensor;
|
||||
+
|
||||
+ /* Verify presence of FastRPC device */
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-light", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* Open and close SSC light sensor for discovering */
|
||||
+ sensor = ssc_sensor_light_new_sync (NULL, NULL);
|
||||
+ if (!sensor)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (!ssc_sensor_light_close_sync (sensor, NULL, NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_clear_object (&sensor);
|
||||
+
|
||||
+ g_debug ("Found SSC light at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
|
@ -142,11 +154,11 @@ index 0000000..689eca5
|
|||
+ .close = ssc_light_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index dbd3f6e..f70e996 100644
|
||||
index 257c822..77a75ab 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -75,6 +75,7 @@ static const SensorDriver * const drivers[] = {
|
||||
&iio_poll_proximity,
|
||||
@@ -77,6 +77,7 @@ static const SensorDriver * const drivers[] = {
|
||||
&input_proximity,
|
||||
#ifdef HAS_LIBSSC
|
||||
&ssc_proximity,
|
||||
+ &ssc_light,
|
||||
|
@ -154,17 +166,17 @@ index dbd3f6e..f70e996 100644
|
|||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 7019b1c..104143c 100644
|
||||
index 9a74481..2f3c1e6 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -36,6 +36,7 @@ sources = [
|
||||
'drv-iio-buffer-compass.c',
|
||||
'drv-iio-poll-proximity.c',
|
||||
'drv-ssc-proximity.c',
|
||||
+ 'drv-ssc-light.c',
|
||||
'iio-buffer-utils.c',
|
||||
'accel-mount-matrix.c',
|
||||
'accel-scale.c',
|
||||
@@ -48,6 +48,7 @@ sources = [
|
||||
if get_option('ssc-support')
|
||||
sources = sources + [
|
||||
'drv-ssc-proximity.c',
|
||||
+ 'drv-ssc-light.c',
|
||||
]
|
||||
endif
|
||||
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
||||
|
|
|
@ -1,35 +1,38 @@
|
|||
From fe8b7e42a7f813842ff51f4d8f194a7c20534bcb Mon Sep 17 00:00:00 2001
|
||||
From cdc8a661bdeb7f0ada6b08beb6ceee40188d8843 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Mon, 24 Apr 2023 17:01:10 +0200
|
||||
Subject: [PATCH 4/7] accelerometer: support SSC accelerometer sensor
|
||||
Subject: [PATCH 4/8] accelerometer: support SSC accelerometer sensor
|
||||
|
||||
Add driver for the accelerometer sensor exposed by libssc.
|
||||
Mount matrix is supported through environment variables set
|
||||
by udev rules because extracting the mount matrix from the
|
||||
Qualcomm Snapdragon Sensor Core (SSC) firmware is not possible yet.
|
||||
---
|
||||
src/drivers.h | 2 +
|
||||
src/drv-ssc-accel.c | 113 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/drivers.h | 1 +
|
||||
src/drv-ssc-accel.c | 145 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
4 files changed, 117 insertions(+)
|
||||
4 files changed, 148 insertions(+)
|
||||
create mode 100644 src/drv-ssc-accel.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index a97528b..a68fcbb 100644
|
||||
index 46df2fd..40707ec 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -163,6 +163,8 @@ extern SensorDriver iio_poll_proximity;
|
||||
@@ -164,6 +164,7 @@ extern SensorDriver input_proximity;
|
||||
#ifdef HAS_LIBSSC
|
||||
extern SensorDriver ssc_proximity;
|
||||
extern SensorDriver ssc_light;
|
||||
+extern SensorDriver ssc_accel;
|
||||
+extern SensorDriver ssc_compass;
|
||||
#endif
|
||||
|
||||
gboolean drv_check_udev_sensor_type (GUdevDevice *device, const gchar *match, const char *name);
|
||||
diff --git a/src/drv-ssc-accel.c b/src/drv-ssc-accel.c
|
||||
new file mode 100644
|
||||
index 0000000..a9b5eec
|
||||
index 0000000..26364db
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-accel.c
|
||||
@@ -0,0 +1,113 @@
|
||||
@@ -0,0 +1,145 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2023 Dylan Van Assche
|
||||
+ *
|
||||
|
@ -39,6 +42,7 @@ index 0000000..a9b5eec
|
|||
+ */
|
||||
+
|
||||
+#include "drivers.h"
|
||||
+#include "accel-mount-matrix.h"
|
||||
+
|
||||
+#include <fcntl.h>
|
||||
+#include <unistd.h>
|
||||
|
@ -53,14 +57,30 @@ index 0000000..a9b5eec
|
|||
+typedef struct DrvData {
|
||||
+ SSCSensorAccelerometer *sensor;
|
||||
+ guint measurement_id;
|
||||
+ AccelVec3 *mount_matrix;
|
||||
+ AccelLocation location;
|
||||
+ AccelScale scale;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_accelerometer_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ SSCSensorAccelerometer *sensor = NULL;
|
||||
+
|
||||
+ /* Verify presence of FastRPC device */
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-accel", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* Open and close SSC accelerometer for discovering */
|
||||
+ sensor = ssc_sensor_accelerometer_new_sync (NULL, NULL);
|
||||
+ if (!sensor)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (!ssc_sensor_accelerometer_close_sync (sensor, NULL, NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_clear_object (&sensor);
|
||||
+
|
||||
+ g_debug ("Found SSC accelerometer at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
|
@ -69,12 +89,21 @@ index 0000000..a9b5eec
|
|||
+measurement_cb (SSCSensorAccelerometer *sensor, gfloat accel_x, gfloat accel_y, gfloat accel_z, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ DrvData *drv_data = (DrvData *) sensor_device->priv;
|
||||
+ AccelReadings readings;
|
||||
+ AccelVec3 tmp;
|
||||
+
|
||||
+ readings.accel_x = accel_x;
|
||||
+ readings.accel_y = accel_y;
|
||||
+ readings.accel_z = accel_z;
|
||||
+ set_accel_scale (&readings.scale, 1.0);
|
||||
+ tmp.x = accel_x;
|
||||
+ tmp.y = accel_y;
|
||||
+ tmp.z = accel_z;
|
||||
+
|
||||
+ if (!apply_mount_matrix (drv_data->mount_matrix, &tmp))
|
||||
+ g_warning ("Could not apply mount matrix");
|
||||
+
|
||||
+ readings.accel_x = tmp.x;
|
||||
+ readings.accel_y = tmp.y;
|
||||
+ readings.accel_z = tmp.z;
|
||||
+ copy_accel_scale (&readings.scale, drv_data->scale);
|
||||
+
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
|
@ -90,6 +119,11 @@ index 0000000..a9b5eec
|
|||
+ sensor_device->priv = g_new0 (DrvData, 1);
|
||||
+ drv_data = (DrvData *) sensor_device->priv;
|
||||
+
|
||||
+ /* Setup accel attributes */
|
||||
+ drv_data->mount_matrix = setup_mount_matrix (device);
|
||||
+ drv_data->location = setup_accel_location (device);
|
||||
+ set_accel_scale (&drv_data->scale, 1.0);
|
||||
+
|
||||
+ /* Create sensor */
|
||||
+ drv_data->sensor = ssc_sensor_accelerometer_new_sync (NULL, &error);
|
||||
+ if (!drv_data->sensor) {
|
||||
|
@ -131,6 +165,7 @@ index 0000000..a9b5eec
|
|||
+ g_warning ("Closing SSC accelerometer sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+
|
||||
+ g_clear_object (&drv_data->sensor);
|
||||
+ g_clear_pointer (&drv_data->mount_matrix, g_free);
|
||||
+ g_clear_pointer (&sensor_device->priv, g_free);
|
||||
+ g_free (sensor_device);
|
||||
+}
|
||||
|
@ -144,10 +179,10 @@ index 0000000..a9b5eec
|
|||
+ .close = ssc_accelerometer_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index f70e996..644e835 100644
|
||||
index 77a75ab..6c0e96f 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -76,6 +76,7 @@ static const SensorDriver * const drivers[] = {
|
||||
@@ -78,6 +78,7 @@ static const SensorDriver * const drivers[] = {
|
||||
#ifdef HAS_LIBSSC
|
||||
&ssc_proximity,
|
||||
&ssc_light,
|
||||
|
@ -156,17 +191,17 @@ index f70e996..644e835 100644
|
|||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 104143c..e44338b 100644
|
||||
index 2f3c1e6..d59cfdd 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -37,6 +37,7 @@ sources = [
|
||||
'drv-iio-poll-proximity.c',
|
||||
'drv-ssc-proximity.c',
|
||||
'drv-ssc-light.c',
|
||||
+ 'drv-ssc-accel.c',
|
||||
'iio-buffer-utils.c',
|
||||
'accel-mount-matrix.c',
|
||||
'accel-scale.c',
|
||||
@@ -49,6 +49,7 @@ if get_option('ssc-support')
|
||||
sources = sources + [
|
||||
'drv-ssc-proximity.c',
|
||||
'drv-ssc-light.c',
|
||||
+ 'drv-ssc-accel.c',
|
||||
]
|
||||
endif
|
||||
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
||||
|
|
|
@ -1,21 +1,35 @@
|
|||
From 20ab71eb279869eec770c497aed6832b64c7df15 Mon Sep 17 00:00:00 2001
|
||||
From 9f394846ebcd1cb0f052b239d16ceb9b9742c823 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Mon, 24 Apr 2023 18:29:15 +0200
|
||||
Subject: [PATCH 5/7] compass: support SSC compass sensor
|
||||
Subject: [PATCH 5/8] compass: support SSC compass sensor
|
||||
|
||||
Add driver for the compass sensor exposed by libssc.
|
||||
---
|
||||
src/drv-ssc-compass.c | 112 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/drivers.h | 1 +
|
||||
src/drv-ssc-compass.c | 123 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
3 files changed, 114 insertions(+)
|
||||
4 files changed, 126 insertions(+)
|
||||
create mode 100644 src/drv-ssc-compass.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index 40707ec..5e0347c 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -165,6 +165,7 @@ extern SensorDriver input_proximity;
|
||||
extern SensorDriver ssc_proximity;
|
||||
extern SensorDriver ssc_light;
|
||||
extern SensorDriver ssc_accel;
|
||||
+extern SensorDriver ssc_compass;
|
||||
#endif
|
||||
|
||||
gboolean drv_check_udev_sensor_type (GUdevDevice *device, const gchar *match, const char *name);
|
||||
diff --git a/src/drv-ssc-compass.c b/src/drv-ssc-compass.c
|
||||
new file mode 100644
|
||||
index 0000000..7a367b3
|
||||
index 0000000..5e65c15
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-compass.c
|
||||
@@ -0,0 +1,112 @@
|
||||
@@ -0,0 +1,123 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2023 Dylan Van Assche
|
||||
+ *
|
||||
|
@ -36,8 +50,6 @@ index 0000000..7a367b3
|
|||
+#include <libssc-sensor.h>
|
||||
+#include <libssc-sensor-compass.h>
|
||||
+
|
||||
+#define UDEV_DEVICE_NAME "fastrpc-"
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorCompass *sensor;
|
||||
+ guint measurement_id;
|
||||
|
@ -46,9 +58,22 @@ index 0000000..7a367b3
|
|||
+static gboolean
|
||||
+ssc_compass_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ SSCSensorCompass *sensor = NULL;
|
||||
+
|
||||
+ /* Verify presence of FastRPC device */
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-compass", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* Open and close SSC compass for discovering */
|
||||
+ sensor = ssc_sensor_compass_new_sync (NULL, NULL);
|
||||
+ if (!sensor)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (!ssc_sensor_compass_close_sync (sensor, NULL, NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_clear_object(&sensor);
|
||||
+
|
||||
+ g_debug ("Found SSC compass at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
|
@ -129,10 +154,10 @@ index 0000000..7a367b3
|
|||
+ .close = ssc_compass_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index 644e835..5414677 100644
|
||||
index 6c0e96f..17858da 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -77,6 +77,7 @@ static const SensorDriver * const drivers[] = {
|
||||
@@ -79,6 +79,7 @@ static const SensorDriver * const drivers[] = {
|
||||
&ssc_proximity,
|
||||
&ssc_light,
|
||||
&ssc_accel,
|
||||
|
@ -141,17 +166,17 @@ index 644e835..5414677 100644
|
|||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index e44338b..08b25e6 100644
|
||||
index d59cfdd..1e753cc 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -38,6 +38,7 @@ sources = [
|
||||
'drv-ssc-proximity.c',
|
||||
'drv-ssc-light.c',
|
||||
'drv-ssc-accel.c',
|
||||
+ 'drv-ssc-compass.c',
|
||||
'iio-buffer-utils.c',
|
||||
'accel-mount-matrix.c',
|
||||
'accel-scale.c',
|
||||
@@ -50,6 +50,7 @@ if get_option('ssc-support')
|
||||
'drv-ssc-proximity.c',
|
||||
'drv-ssc-light.c',
|
||||
'drv-ssc-accel.c',
|
||||
+ 'drv-ssc-compass.c',
|
||||
]
|
||||
endif
|
||||
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
From 8c15df3b56af5a5414b90abd746f824990a3441c Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Tue, 25 Apr 2023 18:34:45 +0200
|
||||
Subject: [PATCH 6/7] accelerometer: apply accel attributes
|
||||
|
||||
Mount matrix, location, and scaling
|
||||
---
|
||||
src/drv-ssc-accel.c | 27 +++++++++++++++++++++++----
|
||||
1 file changed, 23 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/drv-ssc-accel.c b/src/drv-ssc-accel.c
|
||||
index a9b5eec..a64f28e 100644
|
||||
--- a/src/drv-ssc-accel.c
|
||||
+++ b/src/drv-ssc-accel.c
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "drivers.h"
|
||||
+#include "accel-mount-matrix.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
@@ -21,6 +22,9 @@
|
||||
typedef struct DrvData {
|
||||
SSCSensorAccelerometer *sensor;
|
||||
guint measurement_id;
|
||||
+ AccelVec3 *mount_matrix;
|
||||
+ AccelLocation location;
|
||||
+ AccelScale scale;
|
||||
} DrvData;
|
||||
|
||||
static gboolean
|
||||
@@ -37,12 +41,21 @@ static void
|
||||
measurement_cb (SSCSensorAccelerometer *sensor, gfloat accel_x, gfloat accel_y, gfloat accel_z, gpointer user_data)
|
||||
{
|
||||
SensorDevice *sensor_device = user_data;
|
||||
+ DrvData *drv_data = (DrvData *) sensor_device->priv;
|
||||
AccelReadings readings;
|
||||
+ AccelVec3 tmp;
|
||||
+
|
||||
+ tmp.x = accel_x;
|
||||
+ tmp.y = accel_y;
|
||||
+ tmp.z = accel_z;
|
||||
|
||||
- readings.accel_x = accel_x;
|
||||
- readings.accel_y = accel_y;
|
||||
- readings.accel_z = accel_z;
|
||||
- set_accel_scale (&readings.scale, 1.0);
|
||||
+ if (!apply_mount_matrix (drv_data->mount_matrix, &tmp))
|
||||
+ g_warning ("Could not apply mount matrix");
|
||||
+
|
||||
+ readings.accel_x = tmp.x;
|
||||
+ readings.accel_y = tmp.y;
|
||||
+ readings.accel_z = tmp.z;
|
||||
+ copy_accel_scale (&readings.scale, drv_data->scale);
|
||||
|
||||
sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
}
|
||||
@@ -58,6 +71,11 @@ ssc_accelerometer_open (GUdevDevice *device)
|
||||
sensor_device->priv = g_new0 (DrvData, 1);
|
||||
drv_data = (DrvData *) sensor_device->priv;
|
||||
|
||||
+ /* Setup accel attributes */
|
||||
+ drv_data->mount_matrix = setup_mount_matrix (device);
|
||||
+ drv_data->location = setup_accel_location (device);
|
||||
+ set_accel_scale (&drv_data->scale, 1.0);
|
||||
+
|
||||
/* Create sensor */
|
||||
drv_data->sensor = ssc_sensor_accelerometer_new_sync (NULL, &error);
|
||||
if (!drv_data->sensor) {
|
||||
@@ -99,6 +117,7 @@ ssc_accelerometer_close (SensorDevice *sensor_device)
|
||||
g_warning ("Closing SSC accelerometer sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
|
||||
g_clear_object (&drv_data->sensor);
|
||||
+ g_clear_pointer (&drv_data->mount_matrix, g_free);
|
||||
g_clear_pointer (&sensor_device->priv, g_free);
|
||||
g_free (sensor_device);
|
||||
}
|
||||
--
|
||||
2.40.0
|
||||
|
|
@ -1,13 +1,17 @@
|
|||
From 6a8c37f8f180ed3d0589948d28b1d9322a0cae3c Mon Sep 17 00:00:00 2001
|
||||
From 313d84bd57ba0bd240e6ac2d75ed3184212c9911 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Wed, 26 Apr 2023 18:54:07 +0200
|
||||
Subject: [PATCH 7/7] data: add libssc udev rules
|
||||
Subject: [PATCH 6/8] data: add libssc udev rules
|
||||
|
||||
Add udev rules to indicate possible sensor types like
|
||||
ssc-accel, ssc-light, ssc-proximity, and ssc-compass
|
||||
when a FastRPC node is present. This commit enables
|
||||
the usage of the libssc sensor drivers in iio-sensor-proxy
|
||||
which are introduced in the previous commits.
|
||||
---
|
||||
data/80-iio-sensor-proxy-libssc.rules | 11 +++++++++++
|
||||
data/80-iio-sensor-proxy.rules | 2 --
|
||||
data/meson.build | 10 +++++++++-
|
||||
3 files changed, 20 insertions(+), 3 deletions(-)
|
||||
2 files changed, 20 insertions(+), 1 deletion(-)
|
||||
create mode 100644 data/80-iio-sensor-proxy-libssc.rules
|
||||
|
||||
diff --git a/data/80-iio-sensor-proxy-libssc.rules b/data/80-iio-sensor-proxy-libssc.rules
|
||||
|
@ -27,19 +31,6 @@ index 0000000..c4fad16
|
|||
+SUBSYSTEM=="misc", KERNEL=="fastrpc-*", ENV{IIO_SENSOR_PROXY_TYPE}+="ssc-accel ssc-light ssc-proximity ssc-compass"
|
||||
+
|
||||
+LABEL="iio_sensor_proxy_libssc_end"
|
||||
diff --git a/data/80-iio-sensor-proxy.rules b/data/80-iio-sensor-proxy.rules
|
||||
index bd917b2..85d93f9 100644
|
||||
--- a/data/80-iio-sensor-proxy.rules
|
||||
+++ b/data/80-iio-sensor-proxy.rules
|
||||
@@ -16,8 +16,6 @@ SUBSYSTEM=="iio", TEST=="scan_elements/in_intensity_both_en", ENV{IIO_SENSOR_PRO
|
||||
SUBSYSTEM=="iio", TEST=="in_proximity_raw", ENV{IIO_SENSOR_PROXY_TYPE}+="iio-poll-proximity"
|
||||
SUBSYSTEM=="input", ENV{ID_INPUT_ACCELEROMETER}=="1", ENV{IIO_SENSOR_PROXY_TYPE}+="input-accel"
|
||||
|
||||
-SUBSYSTEM=="misc", KERNEL=="fastrpc-sdsp", ENV{IIO_SENSOR_PROXY_TYPE}+="ssc-accel"
|
||||
-
|
||||
ENV{IIO_SENSOR_PROXY_TYPE}=="", GOTO="iio_sensor_proxy_end"
|
||||
|
||||
# We got here because we have a sensor type, which means we need the service
|
||||
diff --git a/data/meson.build b/data/meson.build
|
||||
index 97dbc07..8b78125 100644
|
||||
--- a/data/meson.build
|
||||
|
@ -60,5 +51,5 @@ index 97dbc07..8b78125 100644
|
|||
)
|
||||
|
||||
--
|
||||
2.40.0
|
||||
2.45.1
|
||||
|
47
temp/iio-sensor-proxy/0007-CI-add-libssc-build.patch
Normal file
47
temp/iio-sensor-proxy/0007-CI-add-libssc-build.patch
Normal file
|
@ -0,0 +1,47 @@
|
|||
From cd0d6b7d9be8f256cef9acd502447619e751034c Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Fri, 24 May 2024 21:00:25 +0200
|
||||
Subject: [PATCH 7/8] CI: add libssc build
|
||||
|
||||
libssc support is behind a meson build flag which is disabled by default,
|
||||
add a separate build to CI.
|
||||
---
|
||||
.gitlab-ci.yml | 22 ++++++++++++++++++++++
|
||||
1 file changed, 22 insertions(+)
|
||||
|
||||
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
|
||||
index 8e691b6..5efeb7c 100644
|
||||
--- a/.gitlab-ci.yml
|
||||
+++ b/.gitlab-ci.yml
|
||||
@@ -45,6 +45,28 @@ build_stable:
|
||||
- "${CI_PROJECT_DIR}/_build/meson-dist"
|
||||
- "${CI_PROJECT_DIR}/_build/docs/html/"
|
||||
|
||||
+build_libssc:
|
||||
+ before_script:
|
||||
+ # Undo delangification present in the Fedora Docker images
|
||||
+ - rm -f /etc/rpm/macros.image-language-conf
|
||||
+ - if [ -x /bin/dnf ]; then dnf update -y; else dnf5 update -y; fi
|
||||
+ - if [ -x /bin/dnf ]; then dnf install -y $DEPENDENCIES; else dnf5 install -y $DEPENDENCIES; fi
|
||||
+ - if [ -x /bin/dnf ]; then dnf install -y libqmi-devel protobuf-c-devel; else dnf5 install -y libqmi-devel protobuf-c-devel; fi
|
||||
+ - if [ -x /bin/dnf ]; then dnf reinstall -y glib2; else dnf5 reinstall -y glib2; fi
|
||||
+ - git clone "https://codeberg.org/DylanVanAssche/libssc.git"
|
||||
+ - cd libssc
|
||||
+ - mkdir _build
|
||||
+ - meson _build
|
||||
+ - meson compile -C _build
|
||||
+ - meson install --no-rebuild -C _build
|
||||
+ - cd ..
|
||||
+ script:
|
||||
+ - meson -Dssc-support=true _build
|
||||
+ - ninja -v -C _build
|
||||
+ - ninja -v -C _build install
|
||||
+ - ninja -v -C _build uninstall
|
||||
+ - ninja -v -C _build dist
|
||||
+
|
||||
pages:
|
||||
needs:
|
||||
- build_stable
|
||||
--
|
||||
2.45.1
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
From c70950f1e33aba5c58c337e8dfb73d40efed5b5d Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Van Assche <me@dylanvanassche.be>
|
||||
Date: Sat, 1 Jun 2024 21:15:15 +0200
|
||||
Subject: [PATCH 8/8] data: iio-sensor-proxy.service.in: add AF_QIPCRTR
|
||||
|
||||
Allow AF_QIPCRTR in lockdown for libssc.
|
||||
Libssc uses the QMI protocol over QRTR in the kernel.
|
||||
Systemd limits the address families to UNIX, LOCAL, and NETLINK.
|
||||
However, QRTR uses its own address family: AF_QIPCRTR.
|
||||
Add it to the allowed families.
|
||||
---
|
||||
data/iio-sensor-proxy.service.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/data/iio-sensor-proxy.service.in b/data/iio-sensor-proxy.service.in
|
||||
index 4bc921b..29ea3c0 100644
|
||||
--- a/data/iio-sensor-proxy.service.in
|
||||
+++ b/data/iio-sensor-proxy.service.in
|
||||
@@ -14,6 +14,6 @@ ProtectControlGroups=true
|
||||
ProtectHome=true
|
||||
ProtectKernelModules=true
|
||||
PrivateTmp=true
|
||||
-RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_NETLINK
|
||||
+RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_NETLINK AF_QIPCRTR
|
||||
MemoryDenyWriteExecute=true
|
||||
RestrictRealtime=true
|
||||
--
|
||||
2.45.1
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pkgname=iio-sensor-proxy
|
||||
pkgver=9999
|
||||
pkgrel=3
|
||||
pkgrel=4
|
||||
pkgdesc="IIO sensors to D-Bus proxy"
|
||||
url="https://gitlab.freedesktop.org/hadess/iio-sensor-proxy"
|
||||
arch="aarch64"
|
||||
|
@ -14,10 +14,10 @@ makedepends="
|
|||
libgudev-dev
|
||||
meson
|
||||
polkit-dev
|
||||
libssc-dev
|
||||
libssc-dev>=0.1.6
|
||||
"
|
||||
subpackages="$pkgname-openrc"
|
||||
_commit="48cb957c41b8d51d882219866e1366c45e21c352"
|
||||
_commit="fe56bdba1243cc5f6a652eb75d11ae1d1957ff7e"
|
||||
builddir="$srcdir/$pkgname-$_commit"
|
||||
source="https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/archive/$_commit/iio-sensor-proxy-$_commit.tar.gz
|
||||
iio-sensor-proxy.initd
|
||||
|
@ -26,8 +26,9 @@ source="https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/archive/$_commi
|
|||
0003-light-support-SSC-light-sensor.patch
|
||||
0004-accelerometer-support-SSC-accelerometer-sensor.patch
|
||||
0005-compass-support-SSC-compass-sensor.patch
|
||||
0006-accelerometer-apply-accel-attributes.patch
|
||||
0007-data-add-libssc-udev-rules.patch
|
||||
0006-data-add-libssc-udev-rules.patch
|
||||
0007-CI-add-libssc-build.patch
|
||||
0008-data-iio-sensor-proxy.service.in-add-AF_QIPCRTR.patch
|
||||
"
|
||||
# tests fail on armv7 and armhf, and it seems to be due to some weird issue
|
||||
# with pmaports qemu CI (not reproducible locally with `pmb build --arch
|
||||
|
@ -54,13 +55,14 @@ package() {
|
|||
}
|
||||
|
||||
sha512sums="
|
||||
f899058ba346b272c5174de0f2c0870bf6a13782f0c0c248163bc6cec7fbebca689ed97a0fbebd770a8857212cfc760849ad97034eaaec7fef40b7e58d811f31 iio-sensor-proxy-48cb957c41b8d51d882219866e1366c45e21c352.tar.gz
|
||||
49b96fefbcfabb706fc6189d3f40e6e1a1e847ec6e4101398bf639db9e844c5c5057f2267f3e541d302d002d0042a84fdd56191207ed0e911f80342cd1d416c4 iio-sensor-proxy-fe56bdba1243cc5f6a652eb75d11ae1d1957ff7e.tar.gz
|
||||
f695c3f6c7cad50a5da8b8df28172b4a8c0be750e3bfc93a1b80a7fe1e5a05f24fd0e5af3e0af727c05dfe3a98b3067a6ebd7617c13243b60e1e495b2b3d6987 iio-sensor-proxy.initd
|
||||
43bf2ce5928c996ef56939a5ff232160f6af5a40cc673753763facbcb18511b1f551fa1a91f55ac9d0d4cbe544de7326208617ffc032cfeb9e39a5ab6538e825 0001-iio-sensor-proxy-depend-on-libssc.patch
|
||||
c6eb40824d5f4fe8b46d26f3ed4773502c9ff3ed58ec82df4a4f570bdcba81c39ff41f6d400bcece13fc46486272d13238d58afc34982b0972894b4d01a81309 0002-proximity-support-SSC-proximity-sensor.patch
|
||||
2e909a9a2a8c95d5255e14f6e0280f329e83e02dce8c16555df77c818a3cda658a7ebfb4c27d3e251e6830de2374f5f1bf2735be09af09ff0255c902125601ea 0003-light-support-SSC-light-sensor.patch
|
||||
cb627cb4fc40e195683dcf1a7837f2fc902851310f3cee42ab18e42d6243b8fafc92accf699b5805670f9a8c76cf0cc422a201be64836efe9e5b943f6d151d70 0004-accelerometer-support-SSC-accelerometer-sensor.patch
|
||||
045d76e0399ea2a5e99955d56a77f4fab9b5bc7d50512c60ae1a6dfd8e56e209690743545582bef35451fbd1a03f67d58e7143c2c91811d402a0e8e908f22bbc 0005-compass-support-SSC-compass-sensor.patch
|
||||
17eab0005d6d4989e57ef6f37a7bfbd7541c19c129c9dc481000635884b981a8da0b9f264bc61059ac27882cd653eff7a78ec231ecbd158773f71d55e6ab8e9b 0006-accelerometer-apply-accel-attributes.patch
|
||||
5495aa9d9ba3b83c0845556bcc1ef66d72a76d9685b791c15080dece62c00d93c76a2dce0e146ba0f3027ed2c34957d0019def9cee0fd133ec72c554ccfeb2d3 0007-data-add-libssc-udev-rules.patch
|
||||
3d1be8e5a932ca6ca0b908caaa7f16dcdbbc6e48a75183c1b7c225689f309203f7008f53ed4276c93790dc7dc0b2cb3c9b3f00cef84305657f279369f1307d89 0001-iio-sensor-proxy-depend-on-libssc.patch
|
||||
bb8e1496411c030062eeb1bb919c9680c32d9571587540368c663b6739e3c506d21ab90836a4e83be526019e654af393dc849031ab81bb8aadff623873232d58 0002-proximity-support-SSC-proximity-sensor.patch
|
||||
465f4296778b3c0269b00badd11f841c2ea9dbc14b7489b21f2e4d8e45a628fa59327c91692f8e350c926776de05173e2abc9bef54e51bf0378866ace3891152 0003-light-support-SSC-light-sensor.patch
|
||||
4f6a3b76fc10eb42a4824cc49b063acc1c54a762637f7ff37a1ac42adb1410fbfe5e17b5277bb8fcb4d232b94971cf96c61925f4c207c9b4b56c78321b1b7d69 0004-accelerometer-support-SSC-accelerometer-sensor.patch
|
||||
80d59825dde8ff8bcc92b3d6d659968f88f82c8198e9576e1a77b2d38be074781926c45115e213e4c557a3dc7ba1c1391d67cb6f0c49d23aff2e0cdbfedefc87 0005-compass-support-SSC-compass-sensor.patch
|
||||
651d3281fe64fb72780bdfc4f3416af6f221c5c0aebf8b9a87d2cf6b5a31ebd0816199b45c97f24810807286a4a8839b6304a12cfc23b4191261a30efd3fbe2b 0006-data-add-libssc-udev-rules.patch
|
||||
bdb8831d89f389badd5de0eb52d9eca5dbdf045dbcfab18165d43798c9e329c3e68e3209b8ad1053916cfac6c54984dd47aa379c419d46f1c25ad6a57c2bd771 0007-CI-add-libssc-build.patch
|
||||
c778168de17f86e3d50b62a4905d3940e9d69bb919fe3b9b5fc8962d8fe9b7cdb48a57dd8128ded93ff08493f65a7f602e6e7ad295e6736c74c273a2c6399c35 0008-data-iio-sensor-proxy.service.in-add-AF_QIPCRTR.patch
|
||||
"
|
||||
|
|
Loading…
Reference in a new issue