summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsbrissen <sbrissen@hotmail.com>2014-02-25 14:34:07 -0500
committertilaksidduram <tilaksidduram@gmail.com>2014-06-05 10:08:19 +0530
commitcd5145640187472147f77a2e9be8e7055097b581 (patch)
tree68114a70c3cb53652dc0169441f4bd18658c3a26
parent562847a690e18c40459713eb9b0c0b9bcebb900d (diff)
downloaddevice_samsung_n7100-cd5145640187472147f77a2e9be8e7055097b581.zip
device_samsung_n7100-cd5145640187472147f77a2e9be8e7055097b581.tar.gz
device_samsung_n7100-cd5145640187472147f77a2e9be8e7055097b581.tar.bz2
n7100: fix up sensors
-dibable all sensors when screen is off. port from t0: http://review.cyanogenmod.org/#/c/60292/ Change-Id: I66566f5a17acdc7c6dda84eef81af928567cfa37 Conflicts: libsensors/sensors.h
-rw-r--r--libsensors/ProximitySensor.cpp1
-rw-r--r--libsensors/SensorBase.cpp36
-rw-r--r--libsensors/SensorBase.h1
-rw-r--r--libsensors/sensors.h20
4 files changed, 42 insertions, 16 deletions
diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp
index 404bdbc..f9579fa 100644
--- a/libsensors/ProximitySensor.cpp
+++ b/libsensors/ProximitySensor.cpp
@@ -88,6 +88,7 @@ int ProximitySensor::enable(int32_t handle, int en) {
int flags = en ? 1 : 0;
int err;
+ //ALOGD("%s: Enable: %i", __func__, en);
if (flags != mEnabled) {
err = sspEnable(LOGTAG, SSP_PROX, en);
if(err >= 0){
diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp
index 389edd7..2de3923 100644
--- a/libsensors/SensorBase.cpp
+++ b/libsensors/SensorBase.cpp
@@ -144,35 +144,49 @@ int SensorBase::sspEnable(const char* sensorname, int sensorvalue, int en)
int oldvalue = 0;
int reset = 0;
int newvalue;
- int fd, err;
- char buf[10];
+ int fd;
sspfile = fopen(SSP_DEVICE_ENABLE, "r+");
fscanf(sspfile, "%d", &oldvalue);
fclose(sspfile);
//Accel sensor is first on and last off, if we are disabling it
-// assume the screen is off and zero everything out.
+// assume the screen is off, disable all sensors and zero everything out
+// to keep enable file in sync.
if(sensorvalue == SSP_ACCEL && !en) {
- newvalue = '\0';
//ALOGD("SensorBase: Resetting sensors");
+ for(int i; i < 6; i++){
+ newvalue = oldvalue - ssp_sensors[i];
+ //ALOGD("SensorBase: newvalue: %i ",newvalue);
+ sspWrite(newvalue);
+ }
+ sspWrite('\0');
+ return 0;
} else if(en) {
newvalue = oldvalue + sensorvalue;
} else {
newvalue = oldvalue - sensorvalue;
}
+ //ALOGI("%s: name: %s sensor: %i old value: %i new value: %i ", __func__, sensorname, sensorvalue, oldvalue, newvalue);
+ sspWrite(newvalue);
+ return 0;
+}
- sprintf(buf, "%d", newvalue);
+int SensorBase::sspWrite(int sensorvalue)
+{
+ char buf[10];
+ int fd, ret, err;
+ sprintf(buf, "%d", sensorvalue);
fd = open(SSP_DEVICE_ENABLE, O_RDWR);
if (fd >= 0) {
err = write(fd, buf, sizeof(buf));
- //ALOGI("%s: sensor: %i old value: %i new value: %i ", sensorname, sensorvalue, oldvalue, newvalue);
- close(fd);
- return 0;
+ ret = 0;
} else {
- ALOGI("%s: error writing to file", sensorname);
- close(fd);
- return -1;
+ ALOGI("%s: error writing to file", __func__);
+ ret = -1;
}
+
+ close(fd);
+ return ret;
}
diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h
index d9e4b47..aeac510 100644
--- a/libsensors/SensorBase.h
+++ b/libsensors/SensorBase.h
@@ -61,6 +61,7 @@ public:
virtual int setDelay(int32_t handle, int64_t ns);
virtual int enable(int32_t handle, int enabled) = 0;
int sspEnable(const char* sensorname, int sensorvalue, int en);
+ int sspWrite(int sensorvalue);
virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout);
virtual int flush(int handle);
diff --git a/libsensors/sensors.h b/libsensors/sensors.h
index a4fe794..713395b 100644
--- a/libsensors/sensors.h
+++ b/libsensors/sensors.h
@@ -52,6 +52,16 @@ __BEGIN_DECLS
#define SSP_DEVICE_ENABLE "/sys/class/sensors/ssp_sensor/enable"
+const int ssp_sensors[] = {
+ SSP_ACCEL,
+ SSP_GYRO,
+ SSP_MAG,
+ SSP_PRESS,
+ SSP_PROX,
+ SSP_LIGHT
+};
+
+
/*****************************************************************************/
/*
@@ -105,7 +115,7 @@ __BEGIN_DECLS
// conversion of magnetic data to uT units
#define CONVERT_M (1.0f/16.0f)
-#define CONVERT_M_X (-CONVERT_M)
+#define CONVERT_M_X (CONVERT_M)
#define CONVERT_M_Y (CONVERT_M)
#define CONVERT_M_Z (CONVERT_M)
@@ -116,11 +126,11 @@ __BEGIN_DECLS
#define CONVERT_O_R (CONVERT_O)
// conversion of gyro data to SI units (radian/sec)
-#define RANGE_GYRO (500.0f*(float)M_PI/180.0f)
+#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f)
#define CONVERT_GYRO ((70.0f / 4000.0f) * ((float)M_PI / 180.0f))
-#define CONVERT_GYRO_X (-CONVERT_GYRO)
-#define CONVERT_GYRO_Y (-CONVERT_GYRO)
-#define CONVERT_GYRO_Z (-CONVERT_GYRO)
+#define CONVERT_GYRO_X (CONVERT_GYRO)
+#define CONVERT_GYRO_Y (CONVERT_GYRO)
+#define CONVERT_GYRO_Z (CONVERT_GYRO)
#define SENSOR_STATE_MASK (0x7FFF)