summaryrefslogtreecommitdiff
path: root/driver/stm_mems_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/stm_mems_common.c')
-rw-r--r--driver/stm_mems_common.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/driver/stm_mems_common.c b/driver/stm_mems_common.c
index d3088521d9..93a0b4dc2f 100644
--- a/driver/stm_mems_common.c
+++ b/driver/stm_mems_common.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -11,28 +11,24 @@
/**
* st_raw_read_n - Read n bytes for read
*/
-int st_raw_read_n(const int port,
- const uint16_t i2c_addr_flags,
+int st_raw_read_n(const int port, const uint16_t i2c_addr_flags,
const uint8_t reg, uint8_t *data_ptr, const int len)
{
/* TODO: Implement SPI interface support */
- return i2c_read_block(port, i2c_addr_flags,
- reg | 0x80, data_ptr, len);
+ return i2c_read_block(port, i2c_addr_flags, reg | 0x80, data_ptr, len);
}
/**
* st_raw_read_n_noinc - Read n bytes for read (no auto inc address)
*/
-int st_raw_read_n_noinc(const int port,
- const uint16_t i2c_addr_flags,
+int st_raw_read_n_noinc(const int port, const uint16_t i2c_addr_flags,
const uint8_t reg, uint8_t *data_ptr, const int len)
{
/* TODO: Implement SPI interface support */
- return i2c_read_block(port, i2c_addr_flags,
- reg, data_ptr, len);
+ return i2c_read_block(port, i2c_addr_flags, reg, data_ptr, len);
}
- /**
+/**
* st_write_data_with_mask - Write register with mask
* @s: Motion sensor pointer
* @reg: Device register
@@ -40,24 +36,22 @@ int st_raw_read_n_noinc(const int port,
* @data: Data pointer
*/
int st_write_data_with_mask(const struct motion_sensor_t *s, int reg,
- uint8_t mask, uint8_t data)
+ uint8_t mask, uint8_t data)
{
int err;
int new_data = 0x00, old_data = 0x00;
- err = st_raw_read8(s->port, s->i2c_spi_addr_flags,
- reg, &old_data);
+ err = st_raw_read8(s->port, s->i2c_spi_addr_flags, reg, &old_data);
if (err != EC_SUCCESS)
return err;
- new_data = ((old_data & (~mask)) |
- ((data << __builtin_ctz(mask)) & mask));
+ new_data =
+ ((old_data & (~mask)) | ((data << __builtin_ctz(mask)) & mask));
if (new_data == old_data)
return EC_SUCCESS;
- return st_raw_write8(s->port, s->i2c_spi_addr_flags,
- reg, new_data);
+ return st_raw_write8(s->port, s->i2c_spi_addr_flags, reg, new_data);
}
/**
@@ -77,8 +71,8 @@ int st_get_resolution(const struct motion_sensor_t *s)
* @offset: offset vector
* @temp: Temp
*/
-int st_set_offset(const struct motion_sensor_t *s,
- const int16_t *offset, int16_t temp)
+int st_set_offset(const struct motion_sensor_t *s, const int16_t *offset,
+ int16_t temp)
{
struct stprivate_data *data = s->drv_data;
@@ -94,8 +88,8 @@ int st_set_offset(const struct motion_sensor_t *s,
* @offset: offset vector
* @temp: Temp
*/
-int st_get_offset(const struct motion_sensor_t *s,
- int16_t *offset, int16_t *temp)
+int st_get_offset(const struct motion_sensor_t *s, int16_t *offset,
+ int16_t *temp)
{
struct stprivate_data *data = s->drv_data;
@@ -142,3 +136,20 @@ void st_normalize(const struct motion_sensor_t *s, intv3_t v, uint8_t *data)
for (i = X; i <= Z; i++)
v[i] += (drvdata->offset[i] << 5) / s->current_range;
}
+
+#ifdef CONFIG_GESTURE_HOST_DETECTION
+/**
+ * st_list_activities - Apply to LSB data sensitivity and rotation
+ * @s: Motion sensor pointer
+ * @enabled: Activities that are enabled (bitmap)
+ * @disabled: Activities that are disabled (bitmap)
+ */
+int st_list_activities(const struct motion_sensor_t *s, uint32_t *enabled,
+ uint32_t *disabled)
+{
+ struct stprivate_data *data = s->drv_data;
+ *enabled = data->enabled_activities;
+ *disabled = data->disabled_activities;
+ return EC_RES_SUCCESS;
+}
+#endif /* CONFIG_GESTURE_HOST_DETECTION */