2 * Copyright (C) 2014 Intel Corporation.
9 #include <hardware/sensors.h>
10 #include "enumeration.h"
11 #include "description.h"
13 #include "transform.h"
14 #include "description.h"
16 #include "calibration.h"
17 #include "filtering.h"
20 * This table maps syfs entries in scan_elements directories to sensor types,
21 * and will also be used to determine other sysfs names as well as the iio
22 * device number associated to a specific sensor.
26 * We duplicate entries for the uncalibrated types after their respective base
27 * sensor. This is because all sensor entries must have an associated catalog entry
28 * and also because when only the uncal sensor is active it needs to take it's data
29 * from the same iio device as the base one.
32 struct sensor_catalog_entry_t sensor_catalog[] = {
33 DECLARE_SENSOR3("accel", SENSOR_TYPE_ACCELEROMETER, "x", "y", "z")
34 DECLARE_SENSOR3("anglvel", SENSOR_TYPE_GYROSCOPE, "x", "y", "z")
35 DECLARE_SENSOR3("magn", SENSOR_TYPE_MAGNETIC_FIELD, "x", "y", "z")
36 DECLARE_SENSOR1("intensity", SENSOR_TYPE_LIGHT, "both" )
37 DECLARE_SENSOR0("illuminance",SENSOR_TYPE_LIGHT )
38 DECLARE_SENSOR3("incli", SENSOR_TYPE_ORIENTATION, "x", "y", "z")
39 DECLARE_SENSOR4("rot", SENSOR_TYPE_ROTATION_VECTOR,
40 "quat_x", "quat_y", "quat_z", "quat_w")
41 DECLARE_SENSOR0("temp", SENSOR_TYPE_AMBIENT_TEMPERATURE )
42 DECLARE_SENSOR0("proximity", SENSOR_TYPE_PROXIMITY )
43 DECLARE_SENSOR3("anglvel", SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, "x", "y", "z")
46 #define CATALOG_SIZE ARRAY_SIZE(sensor_catalog)
48 /* ACPI PLD (physical location of device) definitions, as used with sensors */
53 /* We equate sensor handles to indices in these tables */
55 struct sensor_t sensor_desc[MAX_SENSORS]; /* Android-level descriptors */
56 struct sensor_info_t sensor_info[MAX_SENSORS]; /* Internal descriptors */
57 int sensor_count; /* Detected sensors */
60 static void setup_properties_from_pld(int s, int panel, int rotation,
64 * Generate suitable order and opt_scale directives from the PLD panel
65 * and rotation codes we got. This can later be superseded by the usual
66 * properties if necessary. Eventually we'll need to replace these
67 * mechanisms by a less convoluted one, such as a 3x3 placement matrix.
74 int angle = rotation * 45;
76 /* Only deal with 3 axis chips for now */
80 if (panel == PANEL_BACK) {
81 /* Chip placed on the back panel ; negate x and z */
87 case 90: /* 90° clockwise: negate y then swap x,y */
92 case 180: /* Upside down: negate x and y */
97 case 270: /* 90° counter clockwise: negate x then swap x,y */
104 sensor_info[s].order[0] = 1;
105 sensor_info[s].order[1] = 0;
106 sensor_info[s].order[2] = 2;
107 sensor_info[s].quirks |= QUIRK_FIELD_ORDERING;
110 sensor_info[s].channel[0].opt_scale = x;
111 sensor_info[s].channel[1].opt_scale = y;
112 sensor_info[s].channel[2].opt_scale = z;
116 static int is_valid_pld (int panel, int rotation)
118 if (panel != PANEL_FRONT && panel != PANEL_BACK) {
119 ALOGW("Unhandled PLD panel spec: %d\n", panel);
123 /* Only deal with 90° rotations for now */
124 if (rotation < 0 || rotation > 7 || (rotation & 1)) {
125 ALOGW("Unhandled PLD rotation spec: %d\n", rotation);
133 static int read_pld_from_properties (int s, int* panel, int* rotation)
137 if (sensor_get_prop(s, "panel", &p))
140 if (sensor_get_prop(s, "rotation", &r))
143 if (!is_valid_pld(p, r))
149 ALOGI("S%d PLD from properties: panel=%d, rotation=%d\n", s, p, r);
155 static int read_pld_from_sysfs (int s, int dev_num, int* panel, int* rotation)
157 char sysfs_path[PATH_MAX];
160 sprintf(sysfs_path, BASE_PATH "../firmware_node/pld/panel", dev_num);
162 if (sysfs_read_int(sysfs_path, &p))
165 sprintf(sysfs_path, BASE_PATH "../firmware_node/pld/rotation", dev_num);
167 if (sysfs_read_int(sysfs_path, &r))
170 if (!is_valid_pld(p, r))
176 ALOGI("S%d PLD from sysfs: panel=%d, rotation=%d\n", s, p, r);
182 static void decode_placement_information (int dev_num, int num_channels, int s)
185 * See if we have optional "physical location of device" ACPI tags.
186 * We're only interested in panel and rotation specifiers. Use the
187 * .panel and .rotation properties in priority, and the actual ACPI
188 * values as a second source.
194 if (read_pld_from_properties(s, &panel, &rotation) &&
195 read_pld_from_sysfs(s, dev_num, &panel, &rotation))
196 return; /* No PLD data available */
198 /* Map that to field ordering and scaling mechanisms */
199 setup_properties_from_pld(s, panel, rotation, num_channels);
203 static void add_sensor (int dev_num, int catalog_index, int use_polling)
208 char sysfs_path[PATH_MAX];
215 char suffix[MAX_NAME_SIZE + 8];
217 if (sensor_count == MAX_SENSORS) {
218 ALOGE("Too many sensors!\n");
222 sensor_type = sensor_catalog[catalog_index].type;
225 * At this point we could check that the expected sysfs attributes are
226 * present ; that would enable having multiple catalog entries with the
227 * same sensor type, accomodating different sets of sysfs attributes.
232 sensor_info[s].dev_num = dev_num;
233 sensor_info[s].catalog_index = catalog_index;
235 num_channels = sensor_catalog[catalog_index].num_channels;
238 sensor_info[s].num_channels = 0;
240 sensor_info[s].num_channels = num_channels;
242 prefix = sensor_catalog[catalog_index].tag;
245 * receiving the illumination sensor calibration inputs from
246 * the Android properties and setting it within sysfs
248 if (sensor_catalog[catalog_index].type == SENSOR_TYPE_LIGHT) {
249 retval = sensor_get_illumincalib(s);
251 sprintf(sysfs_path, ILLUMINATION_CALIBPATH, dev_num);
252 sysfs_write_int(sysfs_path, retval);
256 /* Read name attribute, if available */
257 sprintf(sysfs_path, NAME_PATH, dev_num);
258 sysfs_read_str(sysfs_path, sensor_info[s].internal_name, MAX_NAME_SIZE);
260 /* See if we have general offsets and scale values for this sensor */
262 sprintf(sysfs_path, SENSOR_OFFSET_PATH, dev_num, prefix);
263 sysfs_read_float(sysfs_path, &sensor_info[s].offset);
265 sprintf(sysfs_path, SENSOR_SCALE_PATH, dev_num, prefix);
266 if (!sysfs_read_float(sysfs_path, &scale)) {
267 sensor_info[s].scale = scale;
268 ALOGI("Scale path:%s scale:%f dev_num:%d\n",
269 sysfs_path, scale, dev_num);
271 sensor_info[s].scale = 1;
273 /* Read channel specific scale if any*/
274 for (c = 0; c < num_channels; c++)
276 sprintf(sysfs_path, BASE_PATH "%s", dev_num,
277 sensor_catalog[catalog_index].channel[c].scale_path);
279 if (!sysfs_read_float(sysfs_path, &scale)) {
280 sensor_info[s].channel[c].scale = scale;
281 sensor_info[s].scale = 0;
283 ALOGI( "Scale path:%s "
284 "channel scale:%f dev_num:%d\n",
285 sysfs_path, scale, dev_num);
290 /* Set default scaling - if num_channels is zero, we have one channel */
292 sensor_info[s].channel[0].opt_scale = 1;
294 for (c = 1; c < num_channels; c++)
295 sensor_info[s].channel[c].opt_scale = 1;
297 /* Read ACPI _PLD attributes for this sensor, if there are any */
298 decode_placement_information(dev_num, num_channels, s);
301 * See if we have optional correction scaling factors for each of the
302 * channels of this sensor. These would be expressed using properties
303 * like iio.accel.y.opt_scale = -1. In case of a single channel we also
304 * support things such as iio.temp.opt_scale = -1. Note that this works
305 * for all types of sensors, and whatever transform is selected, on top
306 * of any previous conversions.
310 for (c = 0; c < num_channels; c++) {
311 ch_name = sensor_catalog[catalog_index].channel[c].name;
312 sprintf(suffix, "%s.opt_scale", ch_name);
313 if (!sensor_get_fl_prop(s, suffix, &opt_scale))
314 sensor_info[s].channel[c].opt_scale = opt_scale;
317 if (!sensor_get_fl_prop(s, "opt_scale", &opt_scale))
318 sensor_info[s].channel[0].opt_scale = opt_scale;
320 /* Initialize Android-visible descriptor */
321 sensor_desc[s].name = sensor_get_name(s);
322 sensor_desc[s].vendor = sensor_get_vendor(s);
323 sensor_desc[s].version = sensor_get_version(s);
324 sensor_desc[s].handle = s;
325 sensor_desc[s].type = sensor_type;
326 sensor_desc[s].maxRange = sensor_get_max_range(s);
327 sensor_desc[s].resolution = sensor_get_resolution(s);
328 sensor_desc[s].power = sensor_get_power(s);
329 sensor_desc[s].stringType = sensor_get_string_type(s);
331 /* None of our supported sensors requires a special permission.
332 * If this will be the case we should implement a sensor_get_perm
334 sensor_desc[s].requiredPermission = "";
335 sensor_desc[s].flags = sensor_get_flags(s);
336 sensor_desc[s].minDelay = sensor_get_min_delay(s);
337 sensor_desc[s].maxDelay = sensor_get_max_delay(s);
338 ALOGI("Sensor %d (%s) type(%d) minD(%ld) maxD(%ld) flags(%2.2x)\n",
339 s, sensor_info[s].friendly_name, sensor_desc[s].type,
340 sensor_desc[s].minDelay, sensor_desc[s].maxDelay, sensor_desc[s].flags);
342 /* We currently do not implement batching when we'll so
343 * these should be overriden appropriately
345 sensor_desc[s].fifoReservedEventCount = 0;
346 sensor_desc[s].fifoMaxEventCount = 0;
348 if (sensor_info[s].internal_name[0] == '\0') {
350 * In case the kernel-mode driver doesn't expose a name for
351 * the iio device, use (null)-dev%d as the trigger name...
352 * This can be considered a kernel-mode iio driver bug.
354 ALOGW("Using null trigger on sensor %d (dev %d)\n", s, dev_num);
355 strcpy(sensor_info[s].internal_name, "(null)");
358 if (sensor_type == SENSOR_TYPE_GYROSCOPE ||
359 sensor_type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) {
360 struct gyro_cal* calibration_data = calloc(1, sizeof(struct gyro_cal));
361 sensor_info[s].cal_data = calibration_data;
362 struct filter* f_data = (struct filter*) calloc(1, sizeof(struct filter));
363 f_data->x_buff = (struct circ_buff*) calloc(1, sizeof (struct circ_buff));
364 f_data->y_buff = (struct circ_buff*) calloc(1, sizeof (struct circ_buff));
365 f_data->z_buff = (struct circ_buff*) calloc(1, sizeof (struct circ_buff));
366 f_data->x_buff->buff = (float*)calloc(SAMPLE_SIZE, sizeof(float));
367 f_data->y_buff->buff = (float*)calloc(SAMPLE_SIZE, sizeof(float));
368 f_data->z_buff->buff = (float*)calloc(SAMPLE_SIZE, sizeof(float));
369 f_data->x_buff->size = SAMPLE_SIZE;
370 f_data->y_buff->size = SAMPLE_SIZE;
371 f_data->z_buff->size = SAMPLE_SIZE;
372 sensor_info[s].filter = f_data;
375 if (sensor_type == SENSOR_TYPE_MAGNETIC_FIELD) {
376 struct compass_cal* calibration_data = calloc(1, sizeof(struct compass_cal));
377 sensor_info[s].cal_data = calibration_data;
380 /* Select one of the available sensor sample processing styles */
383 /* Initialize fields related to sysfs reads offloading */
384 sensor_info[s].thread_data_fd[0] = -1;
385 sensor_info[s].thread_data_fd[1] = -1;
386 sensor_info[s].acquisition_thread = -1;
388 sensor_info[s].meta_data_pending = 0;
390 /* Check if we have a special ordering property on this sensor */
391 if (sensor_get_order(s, sensor_info[s].order))
392 sensor_info[s].quirks |= QUIRK_FIELD_ORDERING;
398 static void discover_poll_sensors (int dev_num, char map[CATALOG_SIZE])
400 char base_dir[PATH_MAX];
406 memset(map, 0, CATALOG_SIZE);
408 snprintf(base_dir, sizeof(base_dir), BASE_PATH, dev_num);
410 dir = opendir(base_dir);
415 /* Enumerate entries in this iio device's base folder */
417 while ((d = readdir(dir))) {
418 if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
421 /* If the name matches a catalog entry, flag it */
422 for (i = 0; i<CATALOG_SIZE; i++) {
423 /* This will be added separately later */
424 if (sensor_catalog[i].type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED)
426 for (c=0; c<sensor_catalog[i].num_channels; c++)
427 if (!strcmp(d->d_name,sensor_catalog[i].channel[c].raw_path) ||
428 !strcmp(d->d_name, sensor_catalog[i].channel[c].input_path)) {
439 static void discover_trig_sensors (int dev_num, char map[CATALOG_SIZE])
441 char scan_elem_dir[PATH_MAX];
446 memset(map, 0, CATALOG_SIZE);
448 /* Enumerate entries in this iio device's scan_elements folder */
450 snprintf(scan_elem_dir, sizeof(scan_elem_dir), CHANNEL_PATH, dev_num);
452 dir = opendir(scan_elem_dir);
457 while ((d = readdir(dir))) {
458 if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
461 /* Compare en entry to known ones and create matching sensors */
463 for (i = 0; i<CATALOG_SIZE; i++) {
464 if (sensor_catalog[i].type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED)
466 if (!strcmp(d->d_name,
467 sensor_catalog[i].channel[0].en_path)) {
478 static void orientation_sensor_check(void)
481 * If we have accel + gyro + magn but no rotation vector sensor,
482 * SensorService replaces the HAL provided orientation sensor by the
483 * AOSP version... provided we report one. So initialize a virtual
484 * orientation sensor with zero values, which will get replaced. See:
485 * frameworks/native/services/sensorservice/SensorService.cpp, looking
486 * for SENSOR_TYPE_ROTATION_VECTOR; that code should presumably fall
487 * back to mUserSensorList.add instead of replaceAt, but accommodate it.
496 int catalog_size = CATALOG_SIZE;
498 for (i=0; i<sensor_count; i++)
499 switch (sensor_catalog[sensor_info[i].catalog_index].type) {
500 case SENSOR_TYPE_ACCELEROMETER:
503 case SENSOR_TYPE_GYROSCOPE:
506 case SENSOR_TYPE_MAGNETIC_FIELD:
509 case SENSOR_TYPE_ORIENTATION:
512 case SENSOR_TYPE_ROTATION_VECTOR:
517 if (has_acc && has_gyr && has_mag && !has_rot && !has_ori)
518 for (i=0; i<catalog_size; i++)
519 if (sensor_catalog[i].type == SENSOR_TYPE_ORIENTATION) {
520 ALOGI("Adding placeholder orientation sensor");
526 static int is_continuous (int s)
528 /* Is sensor s of the continous trigger type kind? */
530 int catalog_index = sensor_info[s].catalog_index;
531 int sensor_type = sensor_catalog[catalog_index].type;
533 switch (sensor_type) {
534 case SENSOR_TYPE_ACCELEROMETER:
535 case SENSOR_TYPE_MAGNETIC_FIELD:
536 case SENSOR_TYPE_ORIENTATION:
537 case SENSOR_TYPE_GYROSCOPE:
538 case SENSOR_TYPE_PRESSURE:
539 case SENSOR_TYPE_GRAVITY:
540 case SENSOR_TYPE_LINEAR_ACCELERATION:
541 case SENSOR_TYPE_ROTATION_VECTOR:
542 case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
543 case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
544 case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
553 static void propose_new_trigger (int s, char trigger_name[MAX_NAME_SIZE],
557 * A new trigger has been enumerated for this sensor. Check if it makes
558 * sense to use it over the currently selected one, and select it if it
559 * is so. The format is something like sensor_name-dev0.
562 const char *suffix = trigger_name + sensor_name_len + 1;
564 /* dev is the default, and lowest priority; no need to update */
565 if (!memcmp(suffix, "dev", 3))
569 * If we found any-motion trigger, record it and force the sensor to
570 * automatic intermediate event generation mode, at least if it is of a
571 * continuously firing sensor type.
574 if (!memcmp(suffix, "any-motion-", 11) && is_continuous(s)) {
575 /* Update the any-motion trigger name to use for this sensor */
576 strcpy(sensor_info[s].motion_trigger_name, trigger_name);
580 /* Update the initial trigger name to use for this sensor */
581 strcpy(sensor_info[s].init_trigger_name, trigger_name);
585 static void update_sensor_matching_trigger_name (char name[MAX_NAME_SIZE])
588 * Check if we have a sensor matching the specified trigger name,
589 * which should then begin with the sensor name, and end with a number
590 * equal to the iio device number the sensor is associated to. If so,
591 * update the string we're going to write to trigger/current_trigger
592 * when enabling this sensor.
602 * First determine the iio device number this trigger refers to. We
603 * expect the last few characters (typically one) of the trigger name
604 * to be this number, so perform a few checks.
606 len = strnlen(name, MAX_NAME_SIZE);
611 cursor = name + len - 1;
613 if (!isdigit(*cursor))
616 while (len && isdigit(*cursor)) {
621 dev_num = atoi(cursor+1);
623 /* See if that matches a sensor */
624 for (s=0; s<sensor_count; s++)
625 if (sensor_info[s].dev_num == dev_num) {
627 sensor_name_len = strlen(sensor_info[s].internal_name);
630 sensor_info[s].internal_name,
632 /* Switch to new trigger if appropriate */
633 propose_new_trigger(s, name, sensor_name_len);
638 static void setup_trigger_names (void)
640 char filename[PATH_MAX];
641 char buf[MAX_NAME_SIZE];
647 /* By default, use the name-dev convention that most drivers use */
648 for (s=0; s<sensor_count; s++)
649 snprintf(sensor_info[s].init_trigger_name,
650 MAX_NAME_SIZE, "%s-dev%d",
651 sensor_info[s].internal_name, sensor_info[s].dev_num);
653 /* Now have a look to /sys/bus/iio/devices/triggerX entries */
655 for (trigger=0; trigger<MAX_TRIGGERS; trigger++) {
657 snprintf(filename, sizeof(filename), TRIGGER_FILE_PATH,trigger);
659 ret = sysfs_read_str(filename, buf, sizeof(buf));
664 /* Record initial and any-motion triggers names */
665 update_sensor_matching_trigger_name(buf);
668 for (s=0; s<sensor_count; s++)
669 if (sensor_info[s].num_channels) {
670 ALOGI( "Sensor %d (%s) default trigger: %s\n", s,
671 sensor_info[s].friendly_name,
672 sensor_info[s].init_trigger_name);
673 if (sensor_info[s].motion_trigger_name[0])
674 ALOGI( "Sensor %d (%s) motion trigger: %s\n",
675 s, sensor_info[s].friendly_name,
676 sensor_info[s].motion_trigger_name);
680 static void uncalibrated_gyro_check (void)
682 unsigned int has_gyr = 0;
683 unsigned int dev_num;
685 unsigned int is_poll_sensor;
686 char buf[MAX_NAME_SIZE];
690 int catalog_size = CATALOG_SIZE; /* Avoid GCC sign comparison warning */
692 /* Checking to see if we have a gyroscope - we can only have uncal if we have the base sensor */
693 for (i=0; i < sensor_count; i++)
694 if(sensor_catalog[sensor_info[i].catalog_index].type == SENSOR_TYPE_GYROSCOPE)
697 dev_num = sensor_info[i].dev_num;
698 is_poll_sensor = !sensor_info[i].num_channels;
704 * If we have a gyro we can add the uncalibrated sensor of the same type and
705 * on the same dev_num. We will save indexes for easy finding and also save the
706 * channel specific information.
709 for (i=0; i<catalog_size; i++)
710 if (sensor_catalog[i].type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) {
711 add_sensor(dev_num, i, is_poll_sensor);
713 uncal_idx = sensor_count - 1; /* Just added uncalibrated sensor */
715 /* Similar to build_sensor_report_maps */
716 for (c = 0; c < sensor_info[uncal_idx].num_channels; c++)
718 memcpy( &(sensor_info[uncal_idx].channel[c].type_spec),
719 &(sensor_info[cal_idx].channel[c].type_spec),
720 sizeof(sensor_info[uncal_idx].channel[c].type_spec));
721 sensor_info[uncal_idx].channel[c].type_info = sensor_info[cal_idx].channel[c].type_info;
722 sensor_info[uncal_idx].channel[c].offset = sensor_info[cal_idx].channel[c].offset;
723 sensor_info[uncal_idx].channel[c].size = sensor_info[cal_idx].channel[c].size;
725 sensor_info[uncal_idx].pair_idx = cal_idx;
726 sensor_info[cal_idx].pair_idx = uncal_idx;
727 strncpy(sensor_info[uncal_idx].init_trigger_name,
728 sensor_info[cal_idx].init_trigger_name,
730 strncpy(sensor_info[uncal_idx].motion_trigger_name,
731 sensor_info[cal_idx].motion_trigger_name,
734 /* Add "Uncalibrated " prefix to sensor name */
735 strcpy(buf, sensor_info[cal_idx].friendly_name);
736 snprintf(sensor_info[uncal_idx].friendly_name,
738 "%s %s", "Uncalibrated", buf);
743 void enumerate_sensors (void)
746 * Discover supported sensors and allocate control structures for them.
747 * Multiple sensors can potentially rely on a single iio device (each
748 * using their own channels). We can't have multiple sensors of the same
749 * type on the same device. In case of detection as both a poll-mode
750 * and trigger-based sensor, use the trigger usage mode.
752 char poll_sensors[CATALOG_SIZE];
753 char trig_sensors[CATALOG_SIZE];
758 for (dev_num=0; dev_num<MAX_DEVICES; dev_num++) {
761 discover_poll_sensors(dev_num, poll_sensors);
762 discover_trig_sensors(dev_num, trig_sensors);
764 for (i=0; i<CATALOG_SIZE; i++)
765 if (trig_sensors[i]) {
766 add_sensor(dev_num, i, 0);
771 add_sensor(dev_num, i, 1);
774 build_sensor_report_maps(dev_num);
778 ALOGI("Discovered %d sensors\n", sensor_count);
780 /* Set up default - as well as custom - trigger names */
781 setup_trigger_names();
783 /* Make sure Android fall backs to its own orientation sensor */
784 orientation_sensor_check();
787 * Create the uncalibrated counterpart to the compensated gyroscope.
788 * This is is a new sensor type in Android 4.4.
790 uncalibrated_gyro_check();
794 void delete_enumeration_data (void)
798 for (i = 0; i < sensor_count; i++)
799 switch (sensor_catalog[sensor_info[i].catalog_index].type) {
800 case SENSOR_TYPE_MAGNETIC_FIELD:
801 if (sensor_info[i].cal_data != NULL) {
802 free(sensor_info[i].cal_data);
803 sensor_info[i].cal_data = NULL;
804 sensor_info[i].cal_level = 0;
807 case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
808 case SENSOR_TYPE_GYROSCOPE:
809 if (sensor_info[i].cal_data != NULL) {
810 free(sensor_info[i].cal_data);
811 sensor_info[i].cal_data = NULL;
812 sensor_info[i].cal_level = 0;
815 if (sensor_info[i].filter != NULL) {
816 free(((struct filter*)sensor_info[i].filter)->x_buff->buff);
817 free(((struct filter*)sensor_info[i].filter)->y_buff->buff);
818 free(((struct filter*)sensor_info[i].filter)->z_buff->buff);
819 free(((struct filter*)sensor_info[i].filter)->x_buff);
820 free(((struct filter*)sensor_info[i].filter)->y_buff);
821 free(((struct filter*)sensor_info[i].filter)->z_buff);
822 free(sensor_info[i].filter);
823 sensor_info[i].filter = NULL;
828 /* Reset sensor count */
833 int get_sensors_list( struct sensors_module_t* module,
834 struct sensor_t const** list)