summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKrishna Yarlagadda <kyarlagadda@nvidia.com>2011-07-01 15:16:34 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-07-11 13:39:58 -0700
commit85f6bcb9497b52a1f1b58e6d30ac0387fbfdeaee (patch)
tree3bbd07315c6becf4c9e3d92ac1064cfb05d5f525 /drivers
parent20911272cb6d0a9a3e4c1c9d4ad7e50e28258901 (diff)
isl29028: Convert als data to lux units
Convert als data units from count to lux before reporting Bug 845207 Change-Id: I52292b509536b128339a103ce5afe2405c39cea0 Reviewed-on: http://git-master/r/39501 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Tested-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Diffstat (limited to 'drivers')
-rwxr-xr-xdrivers/staging/iio/light/isl29028.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index 49caa612482a..ea7c284b219b 100755
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -51,6 +51,8 @@
#define CONFIGURE_ALS_RANGE_LOW_LUX 0
#define CONFIGURE_ALS_RANGE_HIGH_LUX 1
+#define CONFIGURE_ALS_RANGE_SH 1
+#define CONFIGURE_ALS_RANGE_MASK (1 << CONFIGURE_ALS_RANGE_SH)
#define CONFIGURE_ALS_IR_MODE_MASK 1
#define CONFIGURE_ALS_IR_MODE_SH 0
@@ -311,6 +313,12 @@ static bool isl29018_set_als_ir_mode(struct i2c_client *client, bool is_enable,
CONFIGURE_ALS_IR_MODE_MASK,
CONFIGURE_ALS_IR_MODE_SH);
if (st)
+ st = isl29028_write_data(client,
+ ISL29028_REG_ADD_CONFIGURE,
+ CONFIGURE_ALS_RANGE_HIGH_LUX,
+ CONFIGURE_ALS_RANGE_MASK,
+ CONFIGURE_ALS_RANGE_SH);
+ if (st)
st = isl29018_set_irals_high_threshold(client,
chip->als_high_thres);
if (st)
@@ -878,6 +886,14 @@ static ssize_t show_als_data(struct device *dev,
if (chip->als_ir_mode == MODE_ALS) {
st = isl29028_read_als_ir(chip->client, &als_ir_data);
if (st) {
+ /* convert als data count to lux */
+ /* if als_range = 0, lux = count * 0.0326 */
+ /* if als_range = 1, lux = count * 0.522 */
+ if (!chip->als_range)
+ als_ir_data = (als_ir_data * 326) / 10000;
+ else
+ als_ir_data = (als_ir_data * 522) / 1000;
+
buf_count = sprintf(buf, "%d\n", als_ir_data);
chip->als_reading = als_ir_data;
}
@@ -1071,7 +1087,7 @@ static int isl29028_chip_init(struct i2c_client *client)
chip->als_low_thres = 0;
chip->als_high_thres = 0xFFF;
- chip->als_range = 0;
+ chip->als_range = 1;
chip->als_reading = 0;
chip->als_ir_mode = 0;