/* * We only represent one entry for light or proximity. EC is merging different * light sensors to return the what the eye would see. For proximity, we * currently support only one light source.
*/ #define CROS_EC_LIGHT_PROX_MAX_CHANNELS (1 + 1)
/* State data for ec_sensors iio driver. */ struct cros_ec_light_prox_state { /* Shared by all sensors */ struct cros_ec_sensors_core_state core;
staticint cros_ec_light_prox_read(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask)
{ struct cros_ec_light_prox_state *st = iio_priv(indio_dev);
u16 data = 0;
s64 val64; int ret; int idx = chan->scan_index;
mutex_lock(&st->core.cmd_lock);
switch (mask) { case IIO_CHAN_INFO_RAW: if (chan->type == IIO_PROXIMITY) {
ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
(s16 *)&data); if (ret) break;
*val = data;
ret = IIO_VAL_INT;
} else {
ret = -EINVAL;
} break; case IIO_CHAN_INFO_PROCESSED: if (chan->type == IIO_LIGHT) {
ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
(s16 *)&data); if (ret) break; /* * The data coming from the light sensor is * pre-processed and represents the ambient light * illuminance reading expressed in lux.
*/
*val = data;
ret = IIO_VAL_INT;
} else {
ret = -EINVAL;
} break; case IIO_CHAN_INFO_CALIBBIAS:
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_OFFSET;
st->core.param.sensor_offset.flags = 0;
ret = cros_ec_motion_send_host_cmd(&st->core, 0); if (ret) break;
/* Save values */
st->core.calib[0].offset =
st->core.resp->sensor_offset.offset[0];
*val = st->core.calib[idx].offset;
ret = IIO_VAL_INT; break; case IIO_CHAN_INFO_CALIBSCALE: /* * RANGE is used for calibration * scale is a number x.y, where x is coded on 16 bits, * y coded on 16 bits, between 0 and 9999.
*/
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE;
st->core.param.sensor_range.data = EC_MOTION_SENSE_NO_VALUE;
ret = cros_ec_motion_send_host_cmd(&st->core, 0); if (ret) break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.