From: kibak.yoon Date: Wed, 13 Sep 2017 07:40:28 +0000 (+0900) Subject: sensor: hal: tw2: sync gyroscope HAL with sensor kernel driver X-Git-Tag: submit/tizen/20170921.103936^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e37331f5d171730cc849ade34c65302da79bd2d0;p=platform%2Fadaptation%2Ftw2%2Fsensor-hal-tw2.git sensor: hal: tw2: sync gyroscope HAL with sensor kernel driver - 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 --- diff --git a/src/gyro/gyro_device.cpp b/src/gyro/gyro_device.cpp index c5ee459..c1d9de2 100644 --- a/src/gyro/gyro_device.cpp +++ b/src/gyro/gyro_device.cpp @@ -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); diff --git a/src/sensor_common.h b/src/sensor_common.h index 9a0565a..1db6a8c 100644 --- a/src/sensor_common.h +++ b/src/sensor_common.h @@ -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"