diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2022-04-26 09:13:31 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-23 16:44:43 +0000 |
commit | 969e24b56003bbd58069fef2dceb7e0dc9b3a0ad (patch) | |
tree | 2daa2f279f1c27528e08b832b5ea89bf0a036d46 /driver/als_tcs3400.c | |
parent | e49e3f22c9c5bc50b6aa9f69fabc3741f514893c (diff) | |
download | chrome-ec-969e24b56003bbd58069fef2dceb7e0dc9b3a0ad.tar.gz |
tcs3400: Use CONFIG_<driver>_INT_ENABLE
Use CONFIG_<driver>_INT_ENABLE to not include interrupt() and
irq_handler() when hardware interrupt are not used.
Disable call to motion_sense_fifo() with IS_ENABLED(CONFIG_ACCEL_FIFO).
BUG=b:230401133
BRANCH=asurada,dedede,brya
TEST=Build all. Check Zephyr with herobrine. Check on bugzzy.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: Ifc158d739f2b8f1664323af635dad5017f0761e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3609127
Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'driver/als_tcs3400.c')
-rw-r--r-- | driver/als_tcs3400.c | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 048e7b6395..4e1fdb9d4f 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -16,29 +16,13 @@ #include "task.h" #include "util.h" -#define CPRINTS(fmt, args...) cprints(CC_ACCEL, "%s "fmt, __func__, ## args) - -#if defined(CONFIG_ZEPHYR) && defined(CONFIG_ACCEL_INTERRUPTS) -/* - * Get the mostion sensor ID of the TCS3400 sensor that - * generates the interrupt. - * The interrupt is converted to the event and transferred to motion - * sense task that actually handles the interrupt. - * - * Here, we use alias to get the motion sensor ID - * - * e.g) als_clear below is the label of a child node in /motionsense-sensors - * aliases { - * tcs3400-int = &als_clear; - * }; - */ -#if DT_NODE_EXISTS(DT_ALIAS(tcs3400_int)) -#define CONFIG_ALS_TCS3400_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(tcs3400_int))) -#endif +#ifdef CONFIG_ALS_TCS3400_INT_EVENT +#define ALS_TCS3400_INT_ENABLE #endif -STATIC_IF(CONFIG_ACCEL_FIFO) volatile uint32_t last_interrupt_timestamp; +#define CPRINTS(fmt, args...) cprints(CC_ACCEL, "%s "fmt, __func__, ## args) + +volatile uint32_t last_interrupt_timestamp; #ifdef CONFIG_TCS_USE_LUX_TABLE /* @@ -103,8 +87,7 @@ static void tcs3400_read_deferred(void) void tcs3400_interrupt(enum gpio_signal signal) #endif { - if (IS_ENABLED(CONFIG_ACCEL_FIFO)) - last_interrupt_timestamp = __hw_clock_source_read(); + last_interrupt_timestamp = __hw_clock_source_read(); task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ALS_TCS3400_INT_EVENT); } @@ -417,7 +400,6 @@ static int tcs3400_post_events(struct motion_sensor_t *s, struct motion_sensor_t *rgb_s = s + 1; const uint8_t is_calibration = TCS3400_RGB_DRV_DATA(rgb_s)->calibration_mode; - struct ec_response_motion_sensor_data vector = { .flags = 0, }; uint8_t buf[TCS_RGBC_DATA_SIZE]; /* holds raw data read from chip */ int32_t xyz_data[3] = { 0, 0, 0 }; uint16_t raw_data[CRGB_COUNT]; /* holds raw CRGB assembled from buf[] */ @@ -470,13 +452,19 @@ static int tcs3400_post_events(struct motion_sensor_t *s, else last_v[X] = is_calibration ? raw_data[CLEAR_CRGB_IDX] : lux; - vector.udata[X] = ec_motion_sensor_clamp_u16(last_v[X]); - vector.udata[Y] = 0; - vector.udata[Z] = 0; - if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + struct ec_response_motion_sensor_data vector = { + .flags = 0, + }; + + vector.udata[X] = ec_motion_sensor_clamp_u16(last_v[X]); + vector.udata[Y] = 0; + vector.udata[Z] = 0; + vector.sensor_num = s - motion_sensors; motion_sense_fifo_stage_data(&vector, s, 3, last_ts); + } else { + motion_sense_push_raw_xyz(s); } } @@ -491,9 +479,6 @@ static int tcs3400_post_events(struct motion_sensor_t *s, ((raw_data[RED_CRGB_IDX] != TCS_SATURATION_LEVEL) && (raw_data[BLUE_CRGB_IDX] != TCS_SATURATION_LEVEL) && (raw_data[GREEN_CRGB_IDX] != TCS_SATURATION_LEVEL)))) { - - void *udata = vector.udata; - if (is_spoof(rgb_s)) { memcpy(last_v, rgb_s->spoof_xyz, sizeof(rgb_s->spoof_xyz)); } else if (is_calibration) { @@ -504,11 +489,18 @@ static int tcs3400_post_events(struct motion_sensor_t *s, memcpy(last_v, xyz_data, sizeof(xyz_data)); } - ec_motion_sensor_clamp_u16s(udata, last_v); - if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { + struct ec_response_motion_sensor_data vector = { + .flags = 0, + }; + void *udata = vector.udata; + + ec_motion_sensor_clamp_u16s(udata, last_v); + vector.sensor_num = rgb_s - motion_sensors; motion_sense_fifo_stage_data(&vector, rgb_s, 3, last_ts); + } else { + motion_sense_push_raw_xyz(rgb_s); } } if (IS_ENABLED(CONFIG_ACCEL_FIFO)) @@ -795,7 +787,7 @@ const struct accelgyro_drv tcs3400_drv = { .set_data_rate = tcs3400_set_data_rate, .get_data_rate = tcs3400_get_data_rate, .perform_calib = tcs3400_perform_calib, -#ifdef CONFIG_ACCEL_INTERRUPTS +#ifdef ALS_TCS3400_INT_ENABLE .irq_handler = tcs3400_irq_handler, #endif }; |