- There is no transform ops defined yet for Raw sysfs values
- Use this function to perform transformation as well.
- */
- if (sensor_type == SENSOR_TYPE_MAGNETIC_FIELD)
- return CONVERT_GAUSS_TO_MICROTESLA ((val + offset) * scale) *
- correction;
+ * There is no transform ops defined yet for raw sysfs values.
+ * Use this function to perform transformation as well.
+ */
+ if (sensor[s].type == SENSOR_TYPE_MAGNETIC_FIELD)
+ return CONVERT_GAUSS_TO_MICROTESLA ((val + offset) * scale) * correction;
+
+ return (val + offset) * scale * correction;
+}
+
+uint64_t acquire_immediate_uint64_value (int s, int c)
+{
+ char sysfs_path[PATH_MAX];
+ uint64_t val;
+ int ret;
+ int dev_num = sensor[s].dev_num;
+ int i = sensor[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[s].scale ? sensor[s].scale : sensor[s].channel[c].scale;
+ float offset = sensor[s].offset;
+ int sensor_type = sensor_catalog[i].type;
+ float correction;
+
+ /* In case correction has been requested using properties, apply it */
+ correction = sensor[s].channel[c].opt_scale;
+
+ /* Acquire a sample value for sensor s / channel c through sysfs */
+
+ if (sensor[s].channel[c].input_path_present) {
+ sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
+ ret = sysfs_read_uint64(sysfs_path, &val);
+
+ if (!ret)
+ return val * correction;
+ };
+
+ if (!sensor[s].channel[c].raw_path_present)
+ return 0;
+
+ sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);
+ ret = sysfs_read_uint64(sysfs_path, &val);
+
+ if (ret == -1)
+ return 0;