X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=transform.c;h=9738f71e4aaf43ba804bb3981c80f8dd3dd8a3de;hb=6bfb9a85df3f3ffa0170325f3c4c11d8f1a8e75f;hp=fd356fc7e106ab50c8702c16c95d297262273f1f;hpb=cd36e6b893d0bdfac32f2c0913d3b30f5aafc0ca;p=android-x86%2Fhardware-intel-libsensors.git diff --git a/transform.c b/transform.c index fd356fc..9738f71 100644 --- a/transform.c +++ b/transform.c @@ -404,10 +404,14 @@ static float transform_sample_default (int s, int c, unsigned char* sample_data) float scale = sensor[s].scale ? sensor[s].scale : sensor[s].channel[c].scale; /* In case correction has been requested using properties, apply it */ - scale *= sensor[s].channel[c].opt_scale; + float correction = sensor[s].channel[c].opt_scale; + + /* Correlated with "acquire_immediate_value" method */ + if (sensor[s].type == SENSOR_TYPE_MAGNETIC_FIELD) + return CONVERT_GAUSS_TO_MICROTESLA((sensor[s].offset + s64) * scale) * correction; /* Apply default scaling rules */ - return (sensor[s].offset + s64) * scale; + return (sensor[s].offset + s64) * scale * correction; } @@ -536,7 +540,6 @@ float acquire_immediate_float_value (int s, int c) 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 */ @@ -548,8 +551,11 @@ float acquire_immediate_float_value (int s, int c) sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path); ret = sysfs_read_float(sysfs_path, &val); - if (!ret) + if (!ret) { + if (sensor[s].type == SENSOR_TYPE_MAGNETIC_FIELD) + return CONVERT_GAUSS_TO_MICROTESLA (val * correction); return val * correction; + } } if (!sensor[s].channel[c].raw_path_present) @@ -565,7 +571,7 @@ float acquire_immediate_float_value (int s, int c) * 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) + if (sensor[s].type == SENSOR_TYPE_MAGNETIC_FIELD) return CONVERT_GAUSS_TO_MICROTESLA ((val + offset) * scale) * correction; return (val + offset) * scale * correction;