diff options
Diffstat (limited to 'driver/als_tcs3400.c')
-rw-r--r-- | driver/als_tcs3400.c | 236 |
1 files changed, 114 insertions, 122 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 4e1fdb9d4f..002e269ada 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -1,4 +1,4 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. +/* Copyright 2019 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -20,7 +20,7 @@ #define ALS_TCS3400_INT_ENABLE #endif -#define CPRINTS(fmt, args...) cprints(CC_ACCEL, "%s "fmt, __func__, ## args) +#define CPRINTS(fmt, args...) cprints(CC_ACCEL, "%s " fmt, __func__, ##args) volatile uint32_t last_interrupt_timestamp; @@ -32,32 +32,34 @@ volatile uint32_t last_interrupt_timestamp; * Values in array are TCS_ATIME_GAIN_FACTOR (100x) times actual value to allow * for fractions using integers. */ -static const uint16_t -range_atime[TCS_MAX_AGAIN - TCS_MIN_AGAIN + 1][TCS_MAX_ATIME_RANGES] = { -{11200, 5600, 5600, 7200, 5500, 4500, 3800, 3800, 3300, 2900, 2575, 2275, 2075}, -{11200, 5100, 2700, 1840, 1400, 1133, 981, 963, 833, 728, 650, 577, 525}, -{250, 1225, 643, 441, 337, 276, 253, 235, 203, 176, 150, 0, 0}, -{790, 261, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; +static const uint16_t range_atime[TCS_MAX_AGAIN - TCS_MIN_AGAIN + + 1][TCS_MAX_ATIME_RANGES] = { + { 11200, 5600, 5600, 7200, 5500, 4500, 3800, 3800, 3300, 2900, 2575, + 2275, 2075 }, + { 11200, 5100, 2700, 1840, 1400, 1133, 981, 963, 833, 728, 650, 577, + 525 }, + { 250, 1225, 643, 441, 337, 276, 253, 235, 203, 176, 150, 0, 0 }, + { 790, 261, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; -static void -decrement_atime(struct tcs_saturation_t *sat_p, uint16_t cur_lux, int percent) +static void decrement_atime(struct tcs_saturation_t *sat_p, uint16_t cur_lux, + int percent) { int atime; uint16_t steps; int lux = MIN(cur_lux, TCS_GAIN_TABLE_MAX_LUX); steps = percent * range_atime[sat_p->again][lux / 1000] / - TCS_ATIME_GAIN_FACTOR; + TCS_ATIME_GAIN_FACTOR; atime = MAX(sat_p->atime - steps, TCS_MIN_ATIME); sat_p->atime = MIN(atime, TCS_MAX_ATIME); } #else -static void -decrement_atime(struct tcs_saturation_t *sat_p, - uint16_t __attribute__((unused)) cur_lux, - int __attribute__((unused)) percent) +static void decrement_atime(struct tcs_saturation_t *sat_p, + uint16_t __attribute__((unused)) cur_lux, + int __attribute__((unused)) percent) { sat_p->atime = MAX(sat_p->atime - TCS_ATIME_DEC_STEP, TCS_MIN_ATIME); } @@ -69,14 +71,14 @@ static void increment_atime(struct tcs_saturation_t *sat_p) sat_p->atime = MIN(sat_p->atime + TCS_ATIME_INC_STEP, TCS_MAX_ATIME); } -static inline int tcs3400_i2c_read8(const struct motion_sensor_t *s, - int reg, int *data) +static inline int tcs3400_i2c_read8(const struct motion_sensor_t *s, int reg, + int *data) { return i2c_read8(s->port, s->i2c_spi_addr_flags, reg, data); } -static inline int tcs3400_i2c_write8(const struct motion_sensor_t *s, - int reg, int data) +static inline int tcs3400_i2c_write8(const struct motion_sensor_t *s, int reg, + int data) { return i2c_write8(s->port, s->i2c_spi_addr_flags, reg, data); } @@ -107,12 +109,12 @@ static int tcs3400_read(const struct motion_sensor_t *s, intv3_t v) int ret; /* Chip may have been off, make sure to setup important registers */ - if (TCS3400_RGB_DRV_DATA(s+1)->calibration_mode) { + if (TCS3400_RGB_DRV_DATA(s + 1)->calibration_mode) { atime = TCS_CALIBRATION_ATIME; again = TCS_CALIBRATION_AGAIN; } else { - atime = TCS3400_RGB_DRV_DATA(s+1)->saturation.atime; - again = TCS3400_RGB_DRV_DATA(s+1)->saturation.again; + atime = TCS3400_RGB_DRV_DATA(s + 1)->saturation.atime; + again = TCS3400_RGB_DRV_DATA(s + 1)->saturation.again; } ret = tcs3400_i2c_write8(s, TCS_I2C_ATIME, atime); if (ret) @@ -159,17 +161,16 @@ static int tcs3400_rgb_read(const struct motion_sensor_t *s, intv3_t v) * AGAIN if it is not already at its maximum, or if it is, decrease * ATIME if it is not at it's minimum already. */ -static int -tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, - uint16_t cur_lux, - uint16_t *crgb_data, - uint32_t status) +static int tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, + uint16_t cur_lux, + uint16_t *crgb_data, + uint32_t status) { struct tcs_saturation_t *sat_p = - &TCS3400_RGB_DRV_DATA(s+1)->saturation; + &TCS3400_RGB_DRV_DATA(s + 1)->saturation; const uint8_t save_again = sat_p->again; const uint8_t save_atime = sat_p->atime; - uint16_t max_val = 0; + uint16_t max_val = 0; int ret; int percent_left = 0; @@ -182,7 +183,7 @@ tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, /* Don't process if status isn't valid yet */ if ((status & TCS_I2C_STATUS_ALS_SATURATED) || - (max_val >= TCS_SATURATION_LEVEL)) { + (max_val >= TCS_SATURATION_LEVEL)) { /* Saturation occurred, decrease AGAIN if we can */ if (sat_p->again > TCS_MIN_AGAIN) sat_p->again--; @@ -199,14 +200,15 @@ tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, * increase accumulation time by decrementing * ATIME register */ - percent_left = TSC_SATURATION_LOW_BAND_PERCENT - + percent_left = + TSC_SATURATION_LOW_BAND_PERCENT - (max_val * 100 / TCS_SATURATION_LEVEL); decrement_atime(sat_p, cur_lux, percent_left); } } else if (sat_p->atime > TCS_MIN_ATIME) { /* calculate percentage between current and desired */ percent_left = TSC_SATURATION_LOW_BAND_PERCENT - - (max_val * 100 / TCS_SATURATION_LEVEL); + (max_val * 100 / TCS_SATURATION_LEVEL); /* increase accumulation time by decrementing ATIME */ decrement_atime(sat_p, cur_lux, percent_left); @@ -233,7 +235,7 @@ tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, /* If atime or gain setting changed, update atime and gain registers */ if (save_again != sat_p->again) { ret = tcs3400_i2c_write8(s, TCS_I2C_CONTROL, - (sat_p->again & TCS_I2C_CONTROL_MASK)); + (sat_p->again & TCS_I2C_CONTROL_MASK)); if (ret) return ret; } @@ -252,24 +254,25 @@ tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s, * different atime and again settings from the sample. */ static uint32_t normalize_channel_data(struct motion_sensor_t *s, - uint32_t sample) + uint32_t sample) { struct tcs_saturation_t *sat_p = - &(TCS3400_RGB_DRV_DATA(s+1)->saturation); + &(TCS3400_RGB_DRV_DATA(s + 1)->saturation); const uint16_t cur_gain = (1 << (2 * sat_p->again)); const uint16_t cal_again = (1 << (2 * TCS_CALIBRATION_AGAIN)); - return DIV_ROUND_NEAREST(sample * (TCS_ATIME_GRANULARITY - - TCS_CALIBRATION_ATIME) * cal_again, - (TCS_ATIME_GRANULARITY - sat_p->atime) * - cur_gain); + return DIV_ROUND_NEAREST( + sample * (TCS_ATIME_GRANULARITY - TCS_CALIBRATION_ATIME) * + cal_again, + (TCS_ATIME_GRANULARITY - sat_p->atime) * cur_gain); } - __overridable void tcs3400_translate_to_xyz(struct motion_sensor_t *s, - int32_t *crgb_data, int32_t *xyz_data) + int32_t *crgb_data, + int32_t *xyz_data) { - struct tcs3400_rgb_drv_data_t *rgb_drv_data = TCS3400_RGB_DRV_DATA(s+1); + struct tcs3400_rgb_drv_data_t *rgb_drv_data = + TCS3400_RGB_DRV_DATA(s + 1); int32_t crgb_prime[CRGB_COUNT]; int32_t ir; int i; @@ -280,8 +283,9 @@ __overridable void tcs3400_translate_to_xyz(struct motion_sensor_t *s, /* IR removal */ ir = FP_TO_INT(fp_mul(INT_TO_FP(crgb_data[1] + crgb_data[2] + - crgb_data[3] - crgb_data[0]), - rgb_drv_data->calibration.irt) / 2); + crgb_data[3] - crgb_data[0]), + rgb_drv_data->calibration.irt) / + 2); for (i = 0; i < ARRAY_SIZE(crgb_prime); i++) { if (crgb_data[i] < ir) @@ -297,17 +301,17 @@ __overridable void tcs3400_translate_to_xyz(struct motion_sensor_t *s, /* regression fit to XYZ space */ for (i = 0; i < 3; i++) { const struct rgb_channel_calibration_t *p = - &rgb_drv_data->calibration.rgb_cal[i]; - - xyz_data[i] = p->offset + FP_TO_INT( - (fp_inter_t)p->coeff[RED_CRGB_IDX] * - crgb_prime[RED_CRGB_IDX] + - (fp_inter_t)p->coeff[GREEN_CRGB_IDX] * - crgb_prime[GREEN_CRGB_IDX] + - (fp_inter_t)p->coeff[BLUE_CRGB_IDX] * - crgb_prime[BLUE_CRGB_IDX] + - (fp_inter_t)p->coeff[CLEAR_CRGB_IDX] * - crgb_prime[CLEAR_CRGB_IDX]); + &rgb_drv_data->calibration.rgb_cal[i]; + + xyz_data[i] = p->offset + + FP_TO_INT((fp_inter_t)p->coeff[RED_CRGB_IDX] * + crgb_prime[RED_CRGB_IDX] + + (fp_inter_t)p->coeff[GREEN_CRGB_IDX] * + crgb_prime[GREEN_CRGB_IDX] + + (fp_inter_t)p->coeff[BLUE_CRGB_IDX] * + crgb_prime[BLUE_CRGB_IDX] + + (fp_inter_t)p->coeff[CLEAR_CRGB_IDX] * + crgb_prime[CLEAR_CRGB_IDX]); if (xyz_data[i] < 0) xyz_data[i] = 0; @@ -315,14 +319,16 @@ __overridable void tcs3400_translate_to_xyz(struct motion_sensor_t *s, } static void tcs3400_process_raw_data(struct motion_sensor_t *s, - uint8_t *raw_data_buf, - uint16_t *raw_light_data, int32_t *xyz_data) + uint8_t *raw_data_buf, + uint16_t *raw_light_data, + int32_t *xyz_data) { struct als_drv_data_t *als_drv_data = TCS3400_DRV_DATA(s); - struct tcs3400_rgb_drv_data_t *rgb_drv_data = TCS3400_RGB_DRV_DATA(s+1); + struct tcs3400_rgb_drv_data_t *rgb_drv_data = + TCS3400_RGB_DRV_DATA(s + 1); const uint8_t calibration_mode = rgb_drv_data->calibration_mode; - uint16_t k_channel_scale = - als_drv_data->als_cal.channel_scale.k_channel_scale; + uint16_t k_channel_scale = + als_drv_data->als_cal.channel_scale.k_channel_scale; uint16_t cover_scale = als_drv_data->als_cal.channel_scale.cover_scale; int32_t crgb_data[CRGB_COUNT]; int i; @@ -333,7 +339,7 @@ static void tcs3400_process_raw_data(struct motion_sensor_t *s, /* assemble the light value for this channel */ crgb_data[i] = raw_light_data[i] = - ((raw_data_buf[index+1] << 8) | raw_data_buf[index]); + ((raw_data_buf[index + 1] << 8) | raw_data_buf[index]); /* in calibration mode, we only assemble the raw data */ if (calibration_mode) @@ -342,14 +348,14 @@ static void tcs3400_process_raw_data(struct motion_sensor_t *s, /* rgb data at index 1, 2, and 3 owned by rgb driver, not ALS */ if (i > 0) { struct als_channel_scale_t *csp = - &rgb_drv_data->calibration.rgb_cal[i-1].scale; + &rgb_drv_data->calibration.rgb_cal[i - 1].scale; k_channel_scale = csp->k_channel_scale; cover_scale = csp->cover_scale; } /* Step 1: divide by individual channel scale value */ - crgb_data[i] = SENSOR_APPLY_DIV_SCALE(crgb_data[i], - k_channel_scale); + crgb_data[i] = + SENSOR_APPLY_DIV_SCALE(crgb_data[i], k_channel_scale); /* compensate for the light cover */ crgb_data[i] = SENSOR_APPLY_SCALE(crgb_data[i], cover_scale); @@ -365,7 +371,7 @@ static void tcs3400_process_raw_data(struct motion_sensor_t *s, /* calibration mode returns raw data */ for (i = 0; i < 3; i++) - xyz_data[i] = crgb_data[i+1]; + xyz_data[i] = crgb_data[i + 1]; } } @@ -373,7 +379,7 @@ static int32_t get_lux_from_xyz(struct motion_sensor_t *s, int32_t *xyz_data) { int32_t lux = xyz_data[Y]; const int32_t offset = - TCS3400_RGB_DRV_DATA(s+1)->calibration.rgb_cal[Y].offset; + TCS3400_RGB_DRV_DATA(s + 1)->calibration.rgb_cal[Y].offset; /* * Do not include the offset when determining LUX from XYZ. @@ -389,8 +395,7 @@ static bool is_spoof(struct motion_sensor_t *s) (s->flags & MOTIONSENSE_FLAG_IN_SPOOF_MODE); } -static int tcs3400_post_events(struct motion_sensor_t *s, - uint32_t last_ts, +static int tcs3400_post_events(struct motion_sensor_t *s, uint32_t last_ts, uint32_t status) { /* @@ -399,7 +404,7 @@ 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; + TCS3400_RGB_DRV_DATA(rgb_s)->calibration_mode; 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[] */ @@ -408,7 +413,7 @@ static int tcs3400_post_events(struct motion_sensor_t *s, int ret; if (IS_ENABLED(CONFIG_ALS_TCS3400_EMULATED_IRQ_EVENT)) { - int i = 5; /* 100ms max */ + int i = 5; /* 100ms max */ while (i--) { /* Make sure data is valid */ @@ -431,8 +436,7 @@ static int tcs3400_post_events(struct motion_sensor_t *s, /* Read the light registers */ ret = i2c_read_block(s->port, s->i2c_spi_addr_flags, - TCS_DATA_START_LOCATION, - buf, sizeof(buf)); + TCS_DATA_START_LOCATION, buf, sizeof(buf)); if (ret) return ret; @@ -450,7 +454,8 @@ static int tcs3400_post_events(struct motion_sensor_t *s, if (is_spoof(s)) last_v[X] = s->spoof_xyz[X]; else - last_v[X] = is_calibration ? raw_data[CLEAR_CRGB_IDX] : lux; + last_v[X] = is_calibration ? raw_data[CLEAR_CRGB_IDX] : + lux; if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { struct ec_response_motion_sensor_data vector = { @@ -475,12 +480,13 @@ static int tcs3400_post_events(struct motion_sensor_t *s, last_v = rgb_s->raw_xyz; if (is_calibration || (((last_v[X] != xyz_data[X]) || (last_v[Y] != xyz_data[Y]) || - (last_v[Z] != xyz_data[Z])) && + (last_v[Z] != xyz_data[Z])) && ((raw_data[RED_CRGB_IDX] != TCS_SATURATION_LEVEL) && (raw_data[BLUE_CRGB_IDX] != TCS_SATURATION_LEVEL) && (raw_data[GREEN_CRGB_IDX] != TCS_SATURATION_LEVEL)))) { if (is_spoof(rgb_s)) { - memcpy(last_v, rgb_s->spoof_xyz, sizeof(rgb_s->spoof_xyz)); + memcpy(last_v, rgb_s->spoof_xyz, + sizeof(rgb_s->spoof_xyz)); } else if (is_calibration) { last_v[0] = raw_data[RED_CRGB_IDX]; last_v[1] = raw_data[GREEN_CRGB_IDX]; @@ -498,7 +504,8 @@ static int tcs3400_post_events(struct motion_sensor_t *s, 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); + motion_sense_fifo_stage_data(&vector, rgb_s, 3, + last_ts); } else { motion_sense_push_raw_xyz(rgb_s); } @@ -558,11 +565,10 @@ static int tcs3400_irq_handler(struct motion_sensor_t *s, uint32_t *event) } static int tcs3400_rgb_get_scale(const struct motion_sensor_t *s, - uint16_t *scale, - int16_t *temp) + uint16_t *scale, int16_t *temp) { struct rgb_channel_calibration_t *rgb_cal = - TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; + TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; scale[X] = rgb_cal[RED_RGB_IDX].scale.k_channel_scale; scale[Y] = rgb_cal[GREEN_RGB_IDX].scale.k_channel_scale; @@ -572,11 +578,10 @@ static int tcs3400_rgb_get_scale(const struct motion_sensor_t *s, } static int tcs3400_rgb_set_scale(const struct motion_sensor_t *s, - const uint16_t *scale, - int16_t temp) + const uint16_t *scale, int16_t temp) { struct rgb_channel_calibration_t *rgb_cal = - TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; + TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; if (scale[X] == 0 || scale[Y] == 0 || scale[Z] == 0) return EC_ERROR_INVAL; @@ -587,8 +592,7 @@ static int tcs3400_rgb_set_scale(const struct motion_sensor_t *s, } static int tcs3400_rgb_get_offset(const struct motion_sensor_t *s, - int16_t *offset, - int16_t *temp) + int16_t *offset, int16_t *temp) { offset[X] = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal[X].offset; offset[Y] = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal[Y].offset; @@ -598,15 +602,13 @@ static int tcs3400_rgb_get_offset(const struct motion_sensor_t *s, } static int tcs3400_rgb_set_offset(const struct motion_sensor_t *s, - const int16_t *offset, - int16_t temp) + const int16_t *offset, int16_t temp) { /* do not allow offset to be changed, it's predetermined */ return EC_SUCCESS; } -static int tcs3400_rgb_set_data_rate(const struct motion_sensor_t *s, - int rate, +static int tcs3400_rgb_set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) { return EC_SUCCESS; @@ -615,20 +617,16 @@ static int tcs3400_rgb_set_data_rate(const struct motion_sensor_t *s, /* Enable/disable special factory calibration mode */ static int tcs3400_perform_calib(struct motion_sensor_t *s, int enable) { - TCS3400_RGB_DRV_DATA(s+1)->calibration_mode = enable; + TCS3400_RGB_DRV_DATA(s + 1)->calibration_mode = enable; return EC_SUCCESS; } -static int tcs3400_rgb_set_range(struct motion_sensor_t *s, - int range, - int rnd) +static int tcs3400_rgb_set_range(struct motion_sensor_t *s, int range, int rnd) { return EC_SUCCESS; } -static int tcs3400_set_range(struct motion_sensor_t *s, - int range, - int rnd) +static int tcs3400_set_range(struct motion_sensor_t *s, int range, int rnd) { TCS3400_DRV_DATA(s)->als_cal.scale = range >> 16; TCS3400_DRV_DATA(s)->als_cal.uscale = range & 0xffff; @@ -636,9 +634,8 @@ static int tcs3400_set_range(struct motion_sensor_t *s, return EC_SUCCESS; } -static int tcs3400_get_scale(const struct motion_sensor_t *s, - uint16_t *scale, - int16_t *temp) +static int tcs3400_get_scale(const struct motion_sensor_t *s, uint16_t *scale, + int16_t *temp) { scale[X] = TCS3400_DRV_DATA(s)->als_cal.channel_scale.k_channel_scale; scale[Y] = 0; @@ -648,8 +645,7 @@ static int tcs3400_get_scale(const struct motion_sensor_t *s, } static int tcs3400_set_scale(const struct motion_sensor_t *s, - const uint16_t *scale, - int16_t temp) + const uint16_t *scale, int16_t temp) { if (scale[X] == 0) return EC_ERROR_INVAL; @@ -657,8 +653,7 @@ static int tcs3400_set_scale(const struct motion_sensor_t *s, return EC_SUCCESS; } -static int tcs3400_get_offset(const struct motion_sensor_t *s, - int16_t *offset, +static int tcs3400_get_offset(const struct motion_sensor_t *s, int16_t *offset, int16_t *temp) { offset[X] = TCS3400_DRV_DATA(s)->als_cal.offset; @@ -669,8 +664,7 @@ static int tcs3400_get_offset(const struct motion_sensor_t *s, } static int tcs3400_set_offset(const struct motion_sensor_t *s, - const int16_t *offset, - int16_t temp) + const int16_t *offset, int16_t temp) { /* do not allow offset to be changed, it's predetermined */ return EC_SUCCESS; @@ -686,8 +680,7 @@ static int tcs3400_rgb_get_data_rate(const struct motion_sensor_t *s) return tcs3400_get_data_rate(s - 1); } -static int tcs3400_set_data_rate(const struct motion_sensor_t *s, - int rate, +static int tcs3400_set_data_rate(const struct motion_sensor_t *s, int rate, int rnd) { enum tcs3400_mode mode; @@ -737,22 +730,21 @@ static int tcs3400_init(struct motion_sensor_t *s) const struct reg_data { uint8_t reg; uint8_t data; - } defaults[] = { - { TCS_I2C_ENABLE, 0 }, - { TCS_I2C_ATIME, TCS_DEFAULT_ATIME }, - { TCS_I2C_WTIME, 0xFF }, - { TCS_I2C_AILTL, 0 }, - { TCS_I2C_AILTH, 0 }, - { TCS_I2C_AIHTL, 0 }, - { TCS_I2C_AIHTH, 0 }, - { TCS_I2C_PERS, 0 }, - { TCS_I2C_CONFIG, 0x40 }, - { TCS_I2C_CONTROL, (TCS_DEFAULT_AGAIN & TCS_I2C_CONTROL_MASK) }, - { TCS_I2C_AUX, 0 }, - { TCS_I2C_IR, 0 }, - { TCS_I2C_CICLEAR, 0 }, - { TCS_I2C_AICLEAR, 0 } - }; + } defaults[] = { { TCS_I2C_ENABLE, 0 }, + { TCS_I2C_ATIME, TCS_DEFAULT_ATIME }, + { TCS_I2C_WTIME, 0xFF }, + { TCS_I2C_AILTL, 0 }, + { TCS_I2C_AILTH, 0 }, + { TCS_I2C_AIHTL, 0 }, + { TCS_I2C_AIHTH, 0 }, + { TCS_I2C_PERS, 0 }, + { TCS_I2C_CONFIG, 0x40 }, + { TCS_I2C_CONTROL, + (TCS_DEFAULT_AGAIN & TCS_I2C_CONTROL_MASK) }, + { TCS_I2C_AUX, 0 }, + { TCS_I2C_IR, 0 }, + { TCS_I2C_CICLEAR, 0 }, + { TCS_I2C_AICLEAR, 0 } }; int data = 0; int ret; |