OSDN Git Service

STPK-1429 Move immediate values acquisition to transform.c
authorPatrick Porlan <patrick.porlan@intel.com>
Mon, 14 Apr 2014 08:50:53 +0000 (10:50 +0200)
committersuyyala <sridhar.uyyala@intel.com>
Sat, 10 May 2014 15:31:14 +0000 (08:31 -0700)
This routine is in charge of reading and processing sensor
values for poll-mode sensors. It makes more sense to have
it within transform.c than control.c, as it applies offsets
and scales. So far we don't need Intel Sensor Hub -style
processing for these, because none of the ISH sensors uses
a polling interface.

Issue: STPK-1429

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

index cb091ed..fc1f27c 100644 (file)
--- a/control.c
+++ b/control.c
@@ -10,6 +10,7 @@
 #include "control.h"
 #include "enumeration.h"
 #include "utils.h"
+#include "transform.h"
 
 /* Currently active sensors count, per device */
 static int poll_sensors_per_dev[MAX_DEVICES];  /* poll-mode sensors */
@@ -451,42 +452,6 @@ static int integrate_device_report(int dev_num)
 }
 
 
-static float acquire_immediate_value(int s, int c)
-{
-       char sysfs_path[PATH_MAX];
-       float val;
-       int ret;
-       int dev_num = sensor_info[s].dev_num;
-       int i = sensor_info[s].catalog_index;
-       const char* raw_path = sensor_catalog[i].channel[c].raw_path;
-       const char* input_path = sensor_catalog[i].channel[c].input_path;
-       float scale = sensor_info[s].scale;
-       float offset = sensor_info[s].offset;
-
-       /* Acquire a sample value for sensor s / channel c through sysfs */
-
-       if (input_path[0]) {
-               sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
-               ret = sysfs_read_float(sysfs_path, &val);
-
-               if (!ret) {
-                       return val;
-               }
-       };
-
-       if (!raw_path[0])
-               return 0;
-
-       sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);
-       ret = sysfs_read_float(sysfs_path, &val);
-
-       if (ret == -1)
-               return 0;
-
-       return (val + offset) * scale;
-}
-
-
 static void propagate_sensor_report(int s, struct sensors_event_t* data)
 {
        /* There's a sensor report pending for this sensor ; transmit it */
index dd554c1..ba4e85f 100644 (file)
@@ -9,7 +9,7 @@
 #include <hardware/sensors.h>
 #include "common.h"
 #include "transform.h"
-
+#include "utils.h"
 
 /*----------------------------------------------------------------------------*/
 
@@ -328,3 +328,39 @@ void select_transform (int s)
        sensor_info[s].ops.transform = transform_sample_default;
        sensor_info[s].ops.finalize = finalize_sample_default;
 }
+
+
+float acquire_immediate_value(int s, int c)
+{
+       char sysfs_path[PATH_MAX];
+       float val;
+       int ret;
+       int dev_num = sensor_info[s].dev_num;
+       int i = sensor_info[s].catalog_index;
+       const char* raw_path = sensor_catalog[i].channel[c].raw_path;
+       const char* input_path = sensor_catalog[i].channel[c].input_path;
+       float scale = sensor_info[s].scale;
+       float offset = sensor_info[s].offset;
+
+       /* Acquire a sample value for sensor s / channel c through sysfs */
+
+       if (input_path[0]) {
+               sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
+               ret = sysfs_read_float(sysfs_path, &val);
+
+               if (!ret) {
+                       return val;
+               }
+       };
+
+       if (!raw_path[0])
+               return 0;
+
+       sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);
+       ret = sysfs_read_float(sysfs_path, &val);
+
+       if (ret == -1)
+               return 0;
+
+       return (val + offset) * scale;
+}
index bea9f2a..d11c33c 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "common.h"
 
-void select_transform (int s);
+void   select_transform        (int s);
+float  acquire_immediate_value (int s, int c);
 
 #endif