Lines Matching +full:filt +full:- +full:disable
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright 2009-2010 Analog Devices Inc.
33 #define ADP8860_BLMX1 0x09 /* Backlight (Brightness Level 1-daylight) maximum current */
34 #define ADP8860_BLDM1 0x0A /* Backlight (Brightness Level 1-daylight) dim current */
35 #define ADP8860_BLMX2 0x0B /* Backlight (Brightness Level 2-office) maximum current */
36 #define ADP8860_BLDM2 0x0C /* Backlight (Brightness Level 2-office) dim current */
37 #define ADP8860_BLMX3 0x0D /* Backlight (Brightness Level 3-dark) maximum current */
38 #define ADP8860_BLDM3 0x0E /* Backlight (Brightness Level 3-dark) dim current */
57 #define ADP8860_PH1LEVL 0x21 /* First phototransistor ambient light level-low byte register */
58 #define ADP8860_PH1LEVH 0x22 /* First phototransistor ambient light level-high byte register */
59 #define ADP8860_PH2LEVL 0x23 /* Second phototransistor ambient light level-low byte register */
60 #define ADP8860_PH2LEVH 0x24 /* Second phototransistor ambient light level-high byte register */
88 #define ALS_CCFG_VAL(filt) ((0x7 & filt) << 5) argument
125 dev_err(&client->dev, "failed reading at 0x%02x\n", reg); in adp8860_read()
144 mutex_lock(&data->lock); in adp8860_set_bits()
153 mutex_unlock(&data->lock); in adp8860_set_bits()
163 mutex_lock(&data->lock); in adp8860_clr_bits()
172 mutex_unlock(&data->lock); in adp8860_clr_bits()
184 adp8860_write(led->client, ADP8860_ISC1 - led->id + 1, in adp8860_led_work()
185 led->new_brightness >> 1); in adp8860_led_work()
194 led->new_brightness = value; in adp8860_led_set()
195 schedule_work(&led->work); in adp8860_led_set()
200 struct i2c_client *client = led->client; in adp8860_led_setup()
203 ret = adp8860_write(client, ADP8860_ISC1 - led->id + 1, 0); in adp8860_led_setup()
204 ret |= adp8860_set_bits(client, ADP8860_ISCC, 1 << (led->id - 1)); in adp8860_led_setup()
206 if (led->id > 4) in adp8860_led_setup()
208 (led->flags & 0x3) << ((led->id - 5) * 2)); in adp8860_led_setup()
211 (led->flags & 0x3) << ((led->id - 1) * 2)); in adp8860_led_setup()
219 dev_get_platdata(&client->dev); in adp8860_led_probe()
225 led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led), in adp8860_led_probe()
228 return -ENOMEM; in adp8860_led_probe()
230 ret = adp8860_write(client, ADP8860_ISCFR, pdata->led_fade_law); in adp8860_led_probe()
232 (pdata->led_on_time & 0x3) << 6); in adp8860_led_probe()
234 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); in adp8860_led_probe()
237 dev_err(&client->dev, "failed to write\n"); in adp8860_led_probe()
241 for (i = 0; i < pdata->num_leds; ++i) { in adp8860_led_probe()
242 cur_led = &pdata->leds[i]; in adp8860_led_probe()
245 led_dat->id = cur_led->flags & ADP8860_FLAG_LED_MASK; in adp8860_led_probe()
247 if (led_dat->id > 7 || led_dat->id < 1) { in adp8860_led_probe()
248 dev_err(&client->dev, "Invalid LED ID %d\n", in adp8860_led_probe()
249 led_dat->id); in adp8860_led_probe()
250 ret = -EINVAL; in adp8860_led_probe()
254 if (pdata->bl_led_assign & (1 << (led_dat->id - 1))) { in adp8860_led_probe()
255 dev_err(&client->dev, "LED %d used by Backlight\n", in adp8860_led_probe()
256 led_dat->id); in adp8860_led_probe()
257 ret = -EBUSY; in adp8860_led_probe()
261 led_dat->cdev.name = cur_led->name; in adp8860_led_probe()
262 led_dat->cdev.default_trigger = cur_led->default_trigger; in adp8860_led_probe()
263 led_dat->cdev.brightness_set = adp8860_led_set; in adp8860_led_probe()
264 led_dat->cdev.brightness = LED_OFF; in adp8860_led_probe()
265 led_dat->flags = cur_led->flags >> FLAG_OFFT_SHIFT; in adp8860_led_probe()
266 led_dat->client = client; in adp8860_led_probe()
267 led_dat->new_brightness = LED_OFF; in adp8860_led_probe()
268 INIT_WORK(&led_dat->work, adp8860_led_work); in adp8860_led_probe()
270 ret = led_classdev_register(&client->dev, &led_dat->cdev); in adp8860_led_probe()
272 dev_err(&client->dev, "failed to register LED %d\n", in adp8860_led_probe()
273 led_dat->id); in adp8860_led_probe()
279 dev_err(&client->dev, "failed to write\n"); in adp8860_led_probe()
285 data->led = led; in adp8860_led_probe()
290 for (i = i - 1; i >= 0; --i) { in adp8860_led_probe()
301 dev_get_platdata(&client->dev); in adp8860_led_remove()
305 for (i = 0; i < pdata->num_leds; i++) { in adp8860_led_remove()
306 led_classdev_unregister(&data->led[i].cdev); in adp8860_led_remove()
307 cancel_work_sync(&data->led[i].work); in adp8860_led_remove()
327 struct i2c_client *client = data->client; in adp8860_bl_set()
330 if (data->en_ambl_sens) { in adp8860_bl_set()
332 /* Disable Ambient Light auto adjust */ in adp8860_bl_set()
338 * MAX_BRIGHTNESS -> Enable Ambient Light auto adjust in adp8860_bl_set()
342 data->cached_daylight_max); in adp8860_bl_set()
349 if (data->current_brightness && brightness == 0) in adp8860_bl_set()
352 else if (data->current_brightness == 0 && brightness) in adp8860_bl_set()
357 data->current_brightness = brightness; in adp8860_bl_set()
371 return data->current_brightness; in adp8860_bl_get_brightness()
382 struct i2c_client *client = data->client; in adp8860_bl_setup()
383 struct adp8860_backlight_platform_data *pdata = data->pdata; in adp8860_bl_setup()
386 ret |= adp8860_write(client, ADP8860_BLSEN, ~pdata->bl_led_assign); in adp8860_bl_setup()
387 ret |= adp8860_write(client, ADP8860_BLMX1, pdata->l1_daylight_max); in adp8860_bl_setup()
388 ret |= adp8860_write(client, ADP8860_BLDM1, pdata->l1_daylight_dim); in adp8860_bl_setup()
390 if (data->en_ambl_sens) { in adp8860_bl_setup()
391 data->cached_daylight_max = pdata->l1_daylight_max; in adp8860_bl_setup()
393 pdata->l2_office_max); in adp8860_bl_setup()
395 pdata->l2_office_dim); in adp8860_bl_setup()
397 pdata->l3_dark_max); in adp8860_bl_setup()
399 pdata->l3_dark_dim); in adp8860_bl_setup()
401 ret |= adp8860_write(client, ADP8860_L2_TRP, pdata->l2_trip); in adp8860_bl_setup()
402 ret |= adp8860_write(client, ADP8860_L2_HYS, pdata->l2_hyst); in adp8860_bl_setup()
403 ret |= adp8860_write(client, ADP8860_L3_TRP, pdata->l3_trip); in adp8860_bl_setup()
404 ret |= adp8860_write(client, ADP8860_L3_HYS, pdata->l3_hyst); in adp8860_bl_setup()
406 ALS_CCFG_VAL(pdata->abml_filt)); in adp8860_bl_setup()
410 BL_CFGR_VAL(pdata->bl_fade_law, 0)); in adp8860_bl_setup()
412 ret |= adp8860_write(client, ADP8860_BLFR, FADE_VAL(pdata->bl_fade_in, in adp8860_bl_setup()
413 pdata->bl_fade_out)); in adp8860_bl_setup()
416 (data->gdwn_dis ? GDWN_DIS : 0)); in adp8860_bl_setup()
427 mutex_lock(&data->lock); in adp8860_show()
428 error = adp8860_read(data->client, reg, ®_val); in adp8860_show()
429 mutex_unlock(&data->lock); in adp8860_show()
448 mutex_lock(&data->lock); in adp8860_store()
449 adp8860_write(data->client, reg, val); in adp8860_store()
450 mutex_unlock(&data->lock); in adp8860_store()
494 int ret = kstrtoul(buf, 10, &data->cached_daylight_max); in adp8860_bl_l1_daylight_max_store()
558 mutex_lock(&data->lock); in adp8860_bl_ambient_light_level_show()
559 error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val); in adp8860_bl_ambient_light_level_show()
562 error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); in adp8860_bl_ambient_light_level_show()
564 mutex_unlock(&data->lock); in adp8860_bl_ambient_light_level_show()
569 /* Return 13-bit conversion value for the first light sensor */ in adp8860_bl_ambient_light_level_show()
584 mutex_lock(&data->lock); in adp8860_bl_ambient_light_zone_show()
585 error = adp8860_read(data->client, ADP8860_CFGR, ®_val); in adp8860_bl_ambient_light_zone_show()
586 mutex_unlock(&data->lock); in adp8860_bl_ambient_light_zone_show()
610 adp8860_set_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); in adp8860_bl_ambient_light_zone_store()
612 /* Disable automatic ambient light sensing */ in adp8860_bl_ambient_light_zone_store()
613 adp8860_clr_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); in adp8860_bl_ambient_light_zone_store()
616 mutex_lock(&data->lock); in adp8860_bl_ambient_light_zone_store()
617 ret = adp8860_read(data->client, ADP8860_CFGR, ®_val); in adp8860_bl_ambient_light_zone_store()
620 reg_val |= (val - 1) << CFGR_BLV_SHIFT; in adp8860_bl_ambient_light_zone_store()
621 adp8860_write(data->client, ADP8860_CFGR, reg_val); in adp8860_bl_ambient_light_zone_store()
623 mutex_unlock(&data->lock); in adp8860_bl_ambient_light_zone_store()
657 dev_get_platdata(&client->dev); in adp8860_probe()
662 if (!i2c_check_functionality(client->adapter, in adp8860_probe()
664 dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); in adp8860_probe()
665 return -EIO; in adp8860_probe()
669 dev_err(&client->dev, "no platform data?\n"); in adp8860_probe()
670 return -EINVAL; in adp8860_probe()
673 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); in adp8860_probe()
675 return -ENOMEM; in adp8860_probe()
683 data->gdwn_dis = !!pdata->gdwn_dis; in adp8860_probe()
686 data->en_ambl_sens = !!pdata->en_ambl_sens; in adp8860_probe()
689 data->gdwn_dis = !!pdata->gdwn_dis; in adp8860_probe()
692 dev_err(&client->dev, "failed to probe\n"); in adp8860_probe()
693 return -ENODEV; in adp8860_probe()
698 data->revid = ADP8860_DEVID(reg_val); in adp8860_probe()
699 data->client = client; in adp8860_probe()
700 data->pdata = pdata; in adp8860_probe()
701 data->id = id->driver_data; in adp8860_probe()
702 data->current_brightness = 0; in adp8860_probe()
709 mutex_init(&data->lock); in adp8860_probe()
711 bl = devm_backlight_device_register(&client->dev, in adp8860_probe()
712 dev_driver_string(&client->dev), in adp8860_probe()
713 &client->dev, data, &adp8860_bl_ops, &props); in adp8860_probe()
715 dev_err(&client->dev, "failed to register backlight\n"); in adp8860_probe()
719 bl->props.brightness = ADP8860_MAX_BRIGHTNESS; in adp8860_probe()
721 data->bl = bl; in adp8860_probe()
723 if (data->en_ambl_sens) in adp8860_probe()
724 ret = sysfs_create_group(&bl->dev.kobj, in adp8860_probe()
728 dev_err(&client->dev, "failed to register sysfs\n"); in adp8860_probe()
734 ret = -EIO; in adp8860_probe()
740 dev_info(&client->dev, "%s Rev.%d Backlight\n", in adp8860_probe()
741 client->name, data->revid); in adp8860_probe()
743 if (pdata->num_leds) in adp8860_probe()
749 if (data->en_ambl_sens) in adp8860_probe()
750 sysfs_remove_group(&data->bl->dev.kobj, in adp8860_probe()
762 if (data->led) in adp8860_remove()
765 if (data->en_ambl_sens) in adp8860_remove()
766 sysfs_remove_group(&data->bl->dev.kobj, in adp8860_remove()