diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2016-12-27 16:19:05 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-02-16 18:03:59 -0800 |
commit | 484ef121193865225ddbc3a0b848db7f5384f836 (patch) | |
tree | 804173045dad81b2a2839df75c412e874e8d9154 /common | |
parent | 69c3fc2378ee9026277c1cbaf6e8aff0b99ecf46 (diff) | |
download | chrome-ec-484ef121193865225ddbc3a0b848db7f5384f836.tar.gz |
motion: Add opt3001 as a motion sensor
Use the motion sensor to manage ALS as well.
The current interface (via memmap) is preserved, but
we can also access the sensor via cros ec sensor stack and
send the ALS information to ARC++.
BUG=chrome-os-partner:59423
BRANCH=reef
CQ-DEPEND=CL:424217
TEST=Check the sensor is working via ACPI sensor and
cros ec sensor. Check ARC++ sees the sensors.
Change-Id: Iaf608370454ad582691b72b471ea87b511863a78
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424323
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/motion_sense.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 442e957540..2b9d715343 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -575,10 +575,13 @@ static inline void set_present(uint8_t *lpc_status) #ifdef UPDATE_HOST_MEM_MAP /* Update/Write LPC data */ -static inline void update_sense_data(uint8_t *lpc_status, - uint16_t *lpc_data, int *psample_id) +static inline void update_sense_data(uint8_t *lpc_status, int *psample_id) { int i; + uint16_t *lpc_data = (uint16_t *)host_get_memmap(EC_MEMMAP_ACC_DATA); +#if (!defined HAS_TASK_ALS) && (defined CONFIG_ALS) + uint16_t *lpc_als = (uint16_t *)host_get_memmap(EC_MEMMAP_ALS); +#endif struct motion_sensor_t *sensor; /* * Set the busy bit before writing the sensor data. Increment @@ -610,6 +613,11 @@ static inline void update_sense_data(uint8_t *lpc_status, lpc_data[3+3*i] = sensor->xyz[Z]; } +#if (!defined HAS_TASK_ALS) && (defined CONFIG_ALS) + for (i = 0; i < EC_ALS_ENTRIES && i < ALS_COUNT; i++) + lpc_als[i] = motion_als_sensors[i]->xyz[X]; +#endif + /* * Increment sample id and clear busy bit to signal we finished * updating data. @@ -727,10 +735,8 @@ void motion_sense_task(void) #ifdef UPDATE_HOST_MEM_MAP int sample_id = 0; uint8_t *lpc_status; - uint16_t *lpc_data; lpc_status = host_get_memmap(EC_MEMMAP_ACC_STATUS); - lpc_data = (uint16_t *)host_get_memmap(EC_MEMMAP_ACC_DATA); set_present(lpc_status); #endif @@ -832,7 +838,7 @@ void motion_sense_task(void) } #endif #ifdef UPDATE_HOST_MEM_MAP - update_sense_data(lpc_status, lpc_data, &sample_id); + update_sense_data(lpc_status, &sample_id); #endif ts_end_task = get_time(); |