OSDN Git Service

STPK-1429 Enable known channels once at boot time
authorPatrick Porlan <patrick.porlan@intel.com>
Wed, 28 May 2014 08:29:44 +0000 (10:29 +0200)
committersuyyala <sridhar.uyyala@intel.com>
Sat, 7 Jun 2014 16:37:04 +0000 (09:37 -0700)
That solves the problem with gyro not working on T100 if the
accelerometer hasn't been enabled. We have a combination of
two factors at play: data for disabled channels is not
reported through the character device, but it also seems that
once a channel has been enabled, we can't disable it anymore.

As sampling is not active before a trigger is selected and
the buffer is enabled (with an additional open on the iio
character device being necessary for this data to be read)
that should not do any harm.

If we could reliably disable channels then we could go back
to dynamic maps updated when a sensor gets enabled or disabled,
but this comes with additional complexity such as synchronization
between reads and enable/disable operations... better have a
static structure for iio device reports.

Issue: STPK-1429

Change-Id: Ic3b5a0e6e39c09e9533b35b1f6dac279a41b96a5
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
control.c

index 45c8858..b1a1126 100644 (file)
--- a/control.c
+++ b/control.c
@@ -146,6 +146,15 @@ void build_sensor_report_maps(int dev_num)
 
                        known_channels++;
                }
+
+               /* Turn on channels we're aware of */
+               for (c=0;c<sensor_info[s].num_channels; c++) {
+                       sprintf(sysfs_path, CHANNEL_PATH "%s",
+                               sensor_info[s].dev_num,
+                               sensor_catalog[i].channel[c].en_path);
+
+                       sysfs_write_int(sysfs_path, 1);
+               }
        }
 
        ALOGI("Found %d channels on iio device %d\n", known_channels, dev_num);
@@ -252,7 +261,6 @@ int adjust_counters (int s, int enabled)
 
 int sensor_activate(int s, int enabled)
 {
-       char sysfs_path[PATH_MAX];
        char device_name[PATH_MAX];
        char trigger_name[MAX_NAME_SIZE + 16];
        int c;
@@ -275,15 +283,6 @@ int sensor_activate(int s, int enabled)
                enable_buffer(dev_num, 0);
                setup_trigger(dev_num, "\n");
 
-               /* Turn channels associated to this sensor on or off */
-                for (c=0;c<sensor_info[s].num_channels; c++) {
-                       sprintf(sysfs_path, CHANNEL_PATH "%s",
-                               sensor_info[s].dev_num,
-                               sensor_catalog[i].channel[c].en_path);
-
-                       sysfs_write_int(sysfs_path, enabled);
-               }
-
                /* If there's at least one sensor enabled on this iio device */
                if (trig_sensors_per_dev[dev_num]) {
                        sprintf(trigger_name, "%s-dev%d",