temp/iio-sensor-proxy: fork from Alpine (MR 4050)
Fork temporarily iio-sensor-proxy from Alpine to add support for Qualcomm Snapdragon Sensor Core (SSC) sensors through libssc.
This commit is contained in:
parent
a21e95e7e0
commit
0a25713ceb
9 changed files with 1108 additions and 0 deletions
|
@ -0,0 +1,274 @@
|
|||
From 4fd3611f93b0a35e8311c6a6e3fe03545154d8bb 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
|
||||
|
||||
---
|
||||
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
|
||||
|
||||
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
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -46,6 +46,9 @@ gio_dep = dependency('gio-2.0')
|
||||
gudev_dep = dependency('gudev-1.0', version: '>= 237')
|
||||
polkit_gobject_dep = dependency('polkit-gobject-1', version: '>= 0.91')
|
||||
polkit_policy_directory = polkit_gobject_dep.get_pkgconfig_variable('policydir')
|
||||
+if get_option('ssc-support')
|
||||
+ libssc_dep = dependency('libssc-glib')
|
||||
+endif
|
||||
|
||||
xmllint = find_program('xmllint', required: false)
|
||||
|
||||
diff --git a/meson_options.txt b/meson_options.txt
|
||||
index de5fbf4..2b60f82 100644
|
||||
--- a/meson_options.txt
|
||||
+++ b/meson_options.txt
|
||||
@@ -18,6 +18,10 @@ option('geoclue-user',
|
||||
description: 'The USER (existing) as which geoclue service is running',
|
||||
type: 'string',
|
||||
value: 'geoclue')
|
||||
+option('ssc-support',
|
||||
+ description: 'Enable Qualcomm SSC support',
|
||||
+ type: 'boolean',
|
||||
+ value: false)
|
||||
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
|
||||
--- 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,
|
||||
platform = g_udev_client_query_by_subsystem (client, "platform");
|
||||
devices = g_list_concat (devices, input);
|
||||
devices = g_list_concat (devices, platform);
|
||||
+#ifdef HAS_LIBSSC
|
||||
+ GList *fastrpc;
|
||||
+ fastrpc = g_udev_client_query_by_subsystem (client, "misc");
|
||||
+ devices = g_list_concat (devices, fastrpc);
|
||||
+#endif
|
||||
|
||||
/* Find the devices */
|
||||
for (l = devices; l != NULL; l = l->next) {
|
||||
@@ -684,7 +695,15 @@ name_acquired_handler (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
SensorData *data = user_data;
|
||||
- const gchar * const subsystems[] = { "iio", "input", "platform", NULL };
|
||||
+ const gchar * const subsystems[] = {
|
||||
+ "iio",
|
||||
+ "input",
|
||||
+ "platform",
|
||||
+#ifdef HAS_LIBSSC
|
||||
+ "misc",
|
||||
+#endif
|
||||
+ NULL
|
||||
+ };
|
||||
guint i;
|
||||
|
||||
data->client = g_udev_client_new (subsystems);
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 8ddd37b..90d550d 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -1,5 +1,8 @@
|
||||
config_h = configuration_data()
|
||||
config_h.set_quoted('VERSION', meson.project_version())
|
||||
+if get_option('ssc-support')
|
||||
+ config_h.set_quoted('HAS_LIBSSC', '1')
|
||||
+endif
|
||||
config_h_files = configure_file(
|
||||
output: 'config.h',
|
||||
configuration: config_h
|
||||
@@ -7,6 +10,10 @@ config_h_files = configure_file(
|
||||
|
||||
deps = [ gio_dep, gudev_dep, mathlib_dep, polkit_gobject_dep ]
|
||||
|
||||
+if get_option('ssc-support')
|
||||
+ deps = deps + [ libssc_dep ]
|
||||
+endif
|
||||
+
|
||||
resources = gnome.compile_resources(
|
||||
'iio-sensor-proxy-resources', 'iio-sensor-proxy.gresource.xml',
|
||||
c_name: 'iio_sensor_proxy',
|
||||
--
|
||||
2.40.0
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
From 0f9327f15d1d76bc6b7772929e302930d428f167 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
|
||||
|
||||
---
|
||||
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(-)
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index 895cb55..5dcac8a 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -160,10 +160,7 @@ 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;
|
||||
+#ifdef HAS_LIBSSC
|
||||
extern SensorDriver ssc_proximity;
|
||||
#endif
|
||||
|
||||
diff --git a/src/drv-ssc-proximity.c b/src/drv-ssc-proximity.c
|
||||
index 5e06967..c87a796 100644
|
||||
--- a/src/drv-ssc-proximity.c
|
||||
+++ 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))
|
||||
+ 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;
|
||||
+ 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);
|
||||
+ 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;
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index 17debbb..dbd3f6e 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -74,9 +74,6 @@ static const SensorDriver * const drivers[] = {
|
||||
&iio_buffer_compass,
|
||||
&iio_poll_proximity,
|
||||
#ifdef HAS_LIBSSC
|
||||
- &ssc_accel,
|
||||
- &ssc_light,
|
||||
- &ssc_compass,
|
||||
&ssc_proximity,
|
||||
#endif
|
||||
};
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 90d550d..7019b1c 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',
|
||||
--
|
||||
2.40.0
|
||||
|
170
temp/iio-sensor-proxy/0003-light-support-SSC-light-sensor.patch
Normal file
170
temp/iio-sensor-proxy/0003-light-support-SSC-light-sensor.patch
Normal file
|
@ -0,0 +1,170 @@
|
|||
From 59f184ccecf212196c0d76b1cb705eab59c51826 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
|
||||
|
||||
---
|
||||
src/drivers.h | 1 +
|
||||
src/drv-ssc-light.c | 112 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
4 files changed, 115 insertions(+)
|
||||
create mode 100644 src/drv-ssc-light.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index 5dcac8a..a97528b 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -162,6 +162,7 @@ extern SensorDriver iio_poll_proximity;
|
||||
|
||||
#ifdef HAS_LIBSSC
|
||||
extern SensorDriver ssc_proximity;
|
||||
+extern SensorDriver ssc_light;
|
||||
#endif
|
||||
|
||||
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
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-light.c
|
||||
@@ -0,0 +1,112 @@
|
||||
+/*
|
||||
+ * 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-light.h>
|
||||
+
|
||||
+#define UDEV_DEVICE_NAME "fastrpc-"
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorLight *sensor;
|
||||
+ guint measurement_id;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_light_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-light", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_debug ("Found SSC light at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+measurement_cb (SSCSensorLight *sensor, gfloat intensity, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ LightReadings readings;
|
||||
+
|
||||
+ readings.level = intensity;
|
||||
+ readings.uses_lux = TRUE;
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
+
|
||||
+static SensorDevice *
|
||||
+ssc_light_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_light_new_sync (NULL, &error);
|
||||
+ if (!drv_data->sensor) {
|
||||
+ g_warning ("Creating SSC light 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_light_open_sync (drv_data->sensor, NULL, &error)) {
|
||||
+ g_warning ("Opening SSC light sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ g_object_unref (sensor_device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sensor_device;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+ssc_light_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_light_close_sync (drv_data->sensor, NULL, &error))
|
||||
+ g_warning ("Closing SSC light 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_light = {
|
||||
+ .driver_name = "SSC light sensor",
|
||||
+ .type = DRIVER_TYPE_LIGHT,
|
||||
+
|
||||
+ .discover = ssc_light_discover,
|
||||
+ .open = ssc_light_open,
|
||||
+ .close = ssc_light_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index dbd3f6e..f70e996 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,
|
||||
#ifdef HAS_LIBSSC
|
||||
&ssc_proximity,
|
||||
+ &ssc_light,
|
||||
#endif
|
||||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 7019b1c..104143c 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',
|
||||
--
|
||||
2.40.0
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
From fe8b7e42a7f813842ff51f4d8f194a7c20534bcb 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
|
||||
|
||||
---
|
||||
src/drivers.h | 2 +
|
||||
src/drv-ssc-accel.c | 113 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
4 files changed, 117 insertions(+)
|
||||
create mode 100644 src/drv-ssc-accel.c
|
||||
|
||||
diff --git a/src/drivers.h b/src/drivers.h
|
||||
index a97528b..a68fcbb 100644
|
||||
--- a/src/drivers.h
|
||||
+++ b/src/drivers.h
|
||||
@@ -163,6 +163,8 @@ extern SensorDriver iio_poll_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
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-accel.c
|
||||
@@ -0,0 +1,113 @@
|
||||
+/*
|
||||
+ * 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-accelerometer.h>
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorAccelerometer *sensor;
|
||||
+ guint measurement_id;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_accelerometer_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-accel", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_debug ("Found SSC accelerometer at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+measurement_cb (SSCSensorAccelerometer *sensor, gfloat accel_x, gfloat accel_y, gfloat accel_z, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ AccelReadings readings;
|
||||
+
|
||||
+ readings.accel_x = accel_x;
|
||||
+ readings.accel_y = accel_y;
|
||||
+ readings.accel_z = accel_z;
|
||||
+ set_accel_scale (&readings.scale, 1.0);
|
||||
+
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
+
|
||||
+static SensorDevice *
|
||||
+ssc_accelerometer_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_accelerometer_new_sync (NULL, &error);
|
||||
+ if (!drv_data->sensor) {
|
||||
+ g_warning ("Creating SSC accelerometer 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_accelerometer_open_sync (drv_data->sensor, NULL, &error)) {
|
||||
+ g_warning ("Opening SSC accelerometer sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ g_object_unref (sensor_device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sensor_device;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+ssc_accelerometer_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_accelerometer_close_sync (drv_data->sensor, NULL, &error))
|
||||
+ g_warning ("Closing SSC accelerometer 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_accel = {
|
||||
+ .driver_name = "SSC accelerometer sensor",
|
||||
+ .type = DRIVER_TYPE_ACCEL,
|
||||
+
|
||||
+ .discover = ssc_accelerometer_discover,
|
||||
+ .open = ssc_accelerometer_open,
|
||||
+ .close = ssc_accelerometer_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index f70e996..644e835 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -76,6 +76,7 @@ static const SensorDriver * const drivers[] = {
|
||||
#ifdef HAS_LIBSSC
|
||||
&ssc_proximity,
|
||||
&ssc_light,
|
||||
+ &ssc_accel,
|
||||
#endif
|
||||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 104143c..e44338b 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',
|
||||
--
|
||||
2.40.0
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
From 20ab71eb279869eec770c497aed6832b64c7df15 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
|
||||
|
||||
---
|
||||
src/drv-ssc-compass.c | 112 +++++++++++++++++++++++++++++++++++++++++
|
||||
src/iio-sensor-proxy.c | 1 +
|
||||
src/meson.build | 1 +
|
||||
3 files changed, 114 insertions(+)
|
||||
create mode 100644 src/drv-ssc-compass.c
|
||||
|
||||
diff --git a/src/drv-ssc-compass.c b/src/drv-ssc-compass.c
|
||||
new file mode 100644
|
||||
index 0000000..7a367b3
|
||||
--- /dev/null
|
||||
+++ b/src/drv-ssc-compass.c
|
||||
@@ -0,0 +1,112 @@
|
||||
+/*
|
||||
+ * 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-compass.h>
|
||||
+
|
||||
+#define UDEV_DEVICE_NAME "fastrpc-"
|
||||
+
|
||||
+typedef struct DrvData {
|
||||
+ SSCSensorCompass *sensor;
|
||||
+ guint measurement_id;
|
||||
+} DrvData;
|
||||
+
|
||||
+static gboolean
|
||||
+ssc_compass_discover (GUdevDevice *device)
|
||||
+{
|
||||
+ if (!drv_check_udev_sensor_type (device, "ssc-compass", NULL))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ g_debug ("Found SSC compass at %s", g_udev_device_get_sysfs_path (device));
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+measurement_cb (SSCSensorCompass *sensor, gfloat azimuth, gpointer user_data)
|
||||
+{
|
||||
+ SensorDevice *sensor_device = user_data;
|
||||
+ CompassReadings readings;
|
||||
+
|
||||
+ readings.heading = azimuth;
|
||||
+
|
||||
+ sensor_device->callback_func (sensor_device, (gpointer) &readings, sensor_device->user_data);
|
||||
+}
|
||||
+
|
||||
+static SensorDevice *
|
||||
+ssc_compass_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_compass_new_sync (NULL, &error);
|
||||
+ if (!drv_data->sensor) {
|
||||
+ g_warning ("Creating SSC compass 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_compass_open_sync (drv_data->sensor, NULL, &error)) {
|
||||
+ g_warning ("Opening SSC compass sensor failed: %s", error ? error->message : "UNKNOWN");
|
||||
+ g_object_unref (sensor_device);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sensor_device;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+ssc_compass_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_compass_close_sync (drv_data->sensor, NULL, &error))
|
||||
+ g_warning ("Closing SSC compass 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_compass = {
|
||||
+ .driver_name = "SSC compass sensor",
|
||||
+ .type = DRIVER_TYPE_COMPASS,
|
||||
+
|
||||
+ .discover = ssc_compass_discover,
|
||||
+ .open = ssc_compass_open,
|
||||
+ .close = ssc_compass_close,
|
||||
+};
|
||||
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
|
||||
index 644e835..5414677 100644
|
||||
--- a/src/iio-sensor-proxy.c
|
||||
+++ b/src/iio-sensor-proxy.c
|
||||
@@ -77,6 +77,7 @@ static const SensorDriver * const drivers[] = {
|
||||
&ssc_proximity,
|
||||
&ssc_light,
|
||||
&ssc_accel,
|
||||
+ &ssc_compass,
|
||||
#endif
|
||||
};
|
||||
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index e44338b..08b25e6 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',
|
||||
--
|
||||
2.40.0
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
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
|
||||
|
64
temp/iio-sensor-proxy/0007-data-add-libssc-udev-rules.patch
Normal file
64
temp/iio-sensor-proxy/0007-data-add-libssc-udev-rules.patch
Normal file
|
@ -0,0 +1,64 @@
|
|||
From 6a8c37f8f180ed3d0589948d28b1d9322a0cae3c 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
|
||||
|
||||
---
|
||||
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(-)
|
||||
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
|
||||
new file mode 100644
|
||||
index 0000000..c4fad16
|
||||
--- /dev/null
|
||||
+++ b/data/80-iio-sensor-proxy-libssc.rules
|
||||
@@ -0,0 +1,11 @@
|
||||
+# iio-sensor-proxy: libssc
|
||||
+# IIO sensor to D-Bus proxy with libssc support
|
||||
+
|
||||
+ACTION=="remove", GOTO="iio_sensor_proxy_libssc_end"
|
||||
+
|
||||
+# Set the sensor type for all the types we recognise for SDSP/ADSP.
|
||||
+# Some devices expose the sensors via a separate SDSP while others re-use ADSP.
|
||||
+# These DSPs expose itself as /dev/fastrpc-* in the misc subsystem.
|
||||
+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
|
||||
+++ b/data/meson.build
|
||||
@@ -1,5 +1,13 @@
|
||||
+rules = files(
|
||||
+ '80-iio-sensor-proxy.rules'
|
||||
+)
|
||||
+
|
||||
+if get_option('ssc-support')
|
||||
+ rules += files('80-iio-sensor-proxy-libssc.rules')
|
||||
+endif
|
||||
+
|
||||
install_data(
|
||||
- '80-iio-sensor-proxy.rules',
|
||||
+ rules,
|
||||
install_dir: udev_rules_dir
|
||||
)
|
||||
|
||||
--
|
||||
2.40.0
|
||||
|
66
temp/iio-sensor-proxy/APKBUILD
Normal file
66
temp/iio-sensor-proxy/APKBUILD
Normal file
|
@ -0,0 +1,66 @@
|
|||
# Forked from Alpine to add Qualcomm SSC support with libssc
|
||||
|
||||
pkgname=iio-sensor-proxy
|
||||
pkgver=9999
|
||||
pkgrel=0
|
||||
pkgdesc="IIO sensors to D-Bus proxy"
|
||||
url="https://gitlab.freedesktop.org/hadess/iio-sensor-proxy"
|
||||
arch="all"
|
||||
license="GPL-2.0-or-later"
|
||||
depends="dbus"
|
||||
makedepends="
|
||||
eudev-dev
|
||||
glib-dev
|
||||
libgudev-dev
|
||||
meson
|
||||
polkit-dev
|
||||
libssc-dev
|
||||
"
|
||||
subpackages="$pkgname-openrc"
|
||||
_commit="48cb957c41b8d51d882219866e1366c45e21c352"
|
||||
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
|
||||
0001-iio-sensor-proxy-depend-on-libssc.patch
|
||||
0002-proximity-support-SSC-proximity-sensor.patch
|
||||
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
|
||||
"
|
||||
# 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
|
||||
# armv7`)
|
||||
options="!check"
|
||||
build() {
|
||||
abuild-meson \
|
||||
-Db_lto=true \
|
||||
-Dssc-support=true \
|
||||
-Dsystemdsystemunitdir=/no \
|
||||
. output
|
||||
meson compile -C output
|
||||
}
|
||||
|
||||
check() {
|
||||
meson test --no-rebuild --print-errorlogs -C output
|
||||
}
|
||||
|
||||
package() {
|
||||
DESTDIR="$pkgdir" meson install --no-rebuild -C output
|
||||
rm -r "$pkgdir"/no
|
||||
|
||||
install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
f899058ba346b272c5174de0f2c0870bf6a13782f0c0c248163bc6cec7fbebca689ed97a0fbebd770a8857212cfc760849ad97034eaaec7fef40b7e58d811f31 iio-sensor-proxy-48cb957c41b8d51d882219866e1366c45e21c352.tar.gz
|
||||
b25df94e249ca46fe96926e5a866c20dc913fa52a2d9259fb7a3594861c6b2f246fc7fef8a21f5b021f3a71401f734ae27210137b0b1917a7daaffb5e3221f2e 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
|
||||
"
|
8
temp/iio-sensor-proxy/iio-sensor-proxy.initd
Normal file
8
temp/iio-sensor-proxy/iio-sensor-proxy.initd
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
supervisor=supervise-daemon
|
||||
command="/usr/libexec/iio-sensor-proxy"
|
||||
|
||||
depend() {
|
||||
need dbus
|
||||
}
|
Loading…
Reference in a new issue