static int adp8860_bl_set(struct backlight_device *bl, int brightness)
{
	struct adp8860_bl *data = bl_get_data(bl);
	struct i2c_client *client = data->client;
	int ret = 0;

	if (data->en_ambl_sens) {
		if ((brightness > 0) && (brightness < ADP8860_MAX_BRIGHTNESS)) {
			
			ret |= adp8860_clr_bits(client, ADP8860_MDCR,
					CMP_AUTOEN);
			ret |= adp8860_write(client, ADP8860_BLMX1, brightness);
		} else {
			ret |= adp8860_write(client, ADP8860_BLMX1,
					 data->cached_daylight_max);
			ret |= adp8860_set_bits(client, ADP8860_MDCR,
					 CMP_AUTOEN);
		}
	} else
		ret |= adp8860_write(client, ADP8860_BLMX1, brightness);

	if (data->current_brightness && brightness == 0)
		ret |= adp8860_set_bits(client,
				ADP8860_MDCR, DIM_EN);
	else if (data->current_brightness == 0 && brightness)
		ret |= adp8860_clr_bits(client,
				ADP8860_MDCR, DIM_EN);

	if (!ret)
		data->current_brightness = brightness;

	return ret;
}
static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct adp8860_bl *data = dev_get_drvdata(dev);
	unsigned long val;
	uint8_t reg_val;
	int ret;

	ret = strict_strtoul(buf, 10, &val);
	if (ret)
		return ret;

	if (val == 0) {
		
		adp8860_set_bits(data->client, ADP8860_MDCR, CMP_AUTOEN);
	} else if ((val > 0) && (val <= 3)) {
		
		adp8860_clr_bits(data->client, ADP8860_MDCR, CMP_AUTOEN);

		
		mutex_lock(&data->lock);
		adp8860_read(data->client, ADP8860_CFGR, &reg_val);
		reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
		reg_val |= (val - 1) << CFGR_BLV_SHIFT;
		adp8860_write(data->client, ADP8860_CFGR, reg_val);
		mutex_unlock(&data->lock);
	}

	return count;
}
Exemplo n.º 3
0
static int adp8860_i2c_suspend(struct device *dev)
{
	struct i2c_client *client = to_i2c_client(dev);

	adp8860_clr_bits(client, ADP8860_MDCR, NSTBY);

	return 0;
}
Exemplo n.º 4
0
static int adp8860_remove(struct i2c_client *client)
{
	struct adp8860_bl *data = i2c_get_clientdata(client);

	adp8860_clr_bits(client, ADP8860_MDCR, NSTBY);

	if (data->led)
		adp8860_led_remove(client);

	if (data->en_ambl_sens)
		sysfs_remove_group(&data->bl->dev.kobj,
			&adp8860_bl_attr_group);

	return 0;
}
static int __devexit adp8860_remove(struct i2c_client *client)
{
	struct adp8860_bl *data = i2c_get_clientdata(client);

	adp8860_clr_bits(client, ADP8860_MDCR, NSTBY);

	if (data->led)
		adp8860_led_remove(client);

	if (data->en_ambl_sens)
		sysfs_remove_group(&data->bl->dev.kobj,
			&adp8860_bl_attr_group);

	backlight_device_unregister(data->bl);
	kfree(data);

	return 0;
}
static int adp8860_i2c_suspend(struct i2c_client *client, pm_message_t message)
{
	adp8860_clr_bits(client, ADP8860_MDCR, NSTBY);

	return 0;
}