Lines Matching +full:ch0 +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * tsl2550.c - Linux kernel modules for ambient light sensor
44 static const u8 TSL2550_MODE_RANGE[2] = {
58 data->operating_mode = mode; in tsl2550_set_operating_mode()
74 tsl2550_set_operating_mode(client, data->operating_mode); in tsl2550_set_power_state()
77 data->power_state = state; in tsl2550_set_power_state()
90 return -EAGAIN; in tsl2550_get_adc_value()
121 0, 1, 2, 3, 4, 5, 6, 7,
141 * pages 2, 3.
143 static int tsl2550_calculate_lux(u8 ch0, u8 ch1) in tsl2550_calculate_lux() argument
148 u16 c0 = count_lut[ch0]; in tsl2550_calculate_lux()
161 lux = ((c0 - c1) * ratio_lut[r]) / 256; in tsl2550_calculate_lux()
180 return sprintf(buf, "%u\n", data->power_state); in tsl2550_show_power_state()
192 return -EINVAL; in tsl2550_store_power_state()
194 mutex_lock(&data->update_lock); in tsl2550_store_power_state()
196 mutex_unlock(&data->update_lock); in tsl2550_store_power_state()
212 return sprintf(buf, "%u\n", data->operating_mode); in tsl2550_show_operating_mode()
224 return -EINVAL; in tsl2550_store_operating_mode()
226 if (data->power_state == 0) in tsl2550_store_operating_mode()
227 return -EBUSY; in tsl2550_store_operating_mode()
229 mutex_lock(&data->update_lock); in tsl2550_store_operating_mode()
231 mutex_unlock(&data->update_lock); in tsl2550_store_operating_mode()
245 u8 ch0, ch1; in __tsl2550_show_lux() local
251 ch0 = ret; in __tsl2550_show_lux()
259 ret = tsl2550_calculate_lux(ch0, ch1); in __tsl2550_show_lux()
262 if (data->operating_mode == 1) in __tsl2550_show_lux()
276 if (!data->power_state) in tsl2550_show_lux1_input()
277 return -EBUSY; in tsl2550_show_lux1_input()
279 mutex_lock(&data->update_lock); in tsl2550_show_lux1_input()
281 mutex_unlock(&data->update_lock); in tsl2550_show_lux1_input()
317 return -ENODEV; in tsl2550_init_client()
318 data->power_state = 1; in tsl2550_init_client()
322 TSL2550_MODE_RANGE[data->operating_mode]); in tsl2550_init_client()
336 struct i2c_adapter *adapter = client->adapter; in tsl2550_probe()
342 err = -EIO; in tsl2550_probe()
348 err = -ENOMEM; in tsl2550_probe()
351 data->client = client; in tsl2550_probe()
355 opmode = client->dev.platform_data; in tsl2550_probe()
358 dev_err(&client->dev, "invalid operating_mode (%d)\n", in tsl2550_probe()
360 err = -EINVAL; in tsl2550_probe()
363 data->operating_mode = *opmode; in tsl2550_probe()
365 data->operating_mode = 0; /* default mode is standard */ in tsl2550_probe()
366 dev_info(&client->dev, "%s operating mode\n", in tsl2550_probe()
367 data->operating_mode ? "extended" : "standard"); in tsl2550_probe()
369 mutex_init(&data->update_lock); in tsl2550_probe()
377 err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group); in tsl2550_probe()
381 dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION); in tsl2550_probe()
393 sysfs_remove_group(&client->dev.kobj, &tsl2550_attr_group); in tsl2550_remove()