OSDN Git Service

Merge remote-tracking branch 'origin/android/master'
[android-x86/hardware-intel-libsensors.git] / transform.c
index 7aee50d..38c24d2 100644 (file)
@@ -1,6 +1,18 @@
 /*
- * Copyright (C) 2014-2015 Intel Corporation.
- */
+// Copyright (c) 2015 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
 
 #include <stdlib.h>
 #include <math.h>
@@ -41,8 +53,6 @@
 #define CONVERT_M_Y    (-CONVERT_M)
 #define CONVERT_M_Z    (CONVERT_M)
 
-#define CONVERT_GAUSS_TO_MICROTESLA(x) ((x) * 100)
-
 /* Conversion of orientation data to degree units */
 #define CONVERT_O      (1.0 / 64)
 #define CONVERT_O_A    (CONVERT_O)
@@ -551,8 +561,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)