sensor: hal: tw2: sync gyroscope HAL with sensor kernel driver 48/149848/2 accepted/tizen/unified/20170922.065602 submit/tizen/20170921.103936
authorkibak.yoon <kibak.yoon@samsung.com>
Wed, 13 Sep 2017 07:40:28 +0000 (16:40 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Wed, 13 Sep 2017 08:36:33 +0000 (17:36 +0900)
- Gyroscope sensor driver provides boottime-based timestamp with sensor
  event. Since the kernel sensor driver has been modified, the HAL needs to be
  modified accordingly.

Change-Id: I982e77739737d106066894db26db1347c0f4b042
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/gyro/gyro_device.cpp
src/sensor_common.h

index c5ee4592a23b9a360458a32a41defbcca33e6939..c1d9de2ac3efe33878e677c8a3c26b5d4bb96c02 100644 (file)
@@ -193,6 +193,18 @@ bool gyro_device::update_value_input_event(void)
                                gyro_raw[2] = (int)gyro_input.value;
                                z = true;
                                break;
+                       case REL_RZ+1:
+                               fired_time |= SHORT_TO_UINT64(gyro_input.value, 48);
+                               break;
+                       case REL_RZ+2:
+                               fired_time |= SHORT_TO_UINT64(gyro_input.value, 32);
+                               break;
+                       case REL_RZ+3:
+                               fired_time |= SHORT_TO_UINT64(gyro_input.value, 16);
+                               break;
+                       case REL_RZ+4:
+                               fired_time |= SHORT_TO_UINT64(gyro_input.value, 0);
+                               break;
                        default:
                                _E("gyro_input event[type = %d, code = %d] is unknown.", gyro_input.type, gyro_input.code);
                                return false;
@@ -200,7 +212,6 @@ bool gyro_device::update_value_input_event(void)
                        }
                } else if (gyro_input.type == EV_SYN) {
                        syn = true;
-                       fired_time = util::get_timestamp(&gyro_input.time);
                } else {
                        _E("gyro_input event[type = %d, code = %d] is unknown.", gyro_input.type, gyro_input.code);
                        return false;
@@ -219,7 +230,7 @@ bool gyro_device::update_value_input_event(void)
        if (z)
                m_z =  gyro_raw[2];
 
-       m_fired_time = fired_time;
+       m_fired_time = NS_TO_US(fired_time);
 
        _D("m_x = %d, m_y = %d, m_z = %d, time = %lluus", m_x, m_y, m_z, m_fired_time);
 
index 9a0565a6c0b756aa25f341db47e3ccb1a6a4dcf8..1db6a8c4fe257a34cc0cd353cfe42656a59860f8 100644 (file)
@@ -22,6 +22,7 @@
 #define RAW_DATA_EVENT 0x0001
 
 #define SHORT_TO_UINT64(value, shift) (((unsigned long long)(value & 0xFFFF)) << shift)
+#define NS_TO_US(x) ((x) / 1000)
 
 #define UNKNOWN_NAME "UNKNOWN"