コード例 #1
0
ファイル: leds-bd2802.c プロジェクト: kapoloclubs/diana
static ssize_t bd2802_store_led_sync(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));
	int value;
	
	if (!count)
		return -EINVAL;

	value = simple_strtoul(buf, NULL, 10);

	if(led->led_state == BD2802_TEST_ON)
		return -EBUSY;
	if(led->led_state == BD2802_SEQ)
		return -EBUSY;

	if(value == 1) {
		if(led->led_state != BD2802_SYNC) {
			hrtimer_cancel(&led->ledmin_timer);
			flush_workqueue(led->ledmin_wq);
			led->blue_current = BD2802_CURRENT_000;
			bd2802_turn_white(led, HIDDEN1);
			bd2802_turn_white(led, HIDDEN2);
			led->led_state = BD2802_SYNC;
		}
	} else if(value == 0) {
		if(led->led_state == BD2802_SYNC) {
			led->white_current = BD2802_CURRENT_WHITE_MAX;
			led->blue_current = BD2802_CURRENT_000;
			bd2802_on(led);
			led->led_state = BD2802_ON;
			hrtimer_start(&led->ledmin_timer, ktime_set(5, 0), HRTIMER_MODE_REL);
		}
	} else {
		return -EINVAL;
	}

	return count;
}
コード例 #2
0
void touchkey_pressed(enum key_leds id)
{
	struct bd2802_led *led = i2c_get_clientdata(bd2802_i2c_client);
	DBG("led->led_state=%d\n",led->led_state);
	if (led->led_state==BD2802_SEQ ||
			led->led_state==BD2802_SYNC)
		return;

	hrtimer_cancel(&led->touchkey_timer);
	hrtimer_cancel(&led->ledmin_timer);

	if (led->led_state == BD2802_DIMMING) {
		led->white_current = max_current;
		led->blue_current = BD2802_CURRENT_000;	
		bd2802_on(led);
		led->led_state = BD2802_ON;
	}
/*	else if (led->led_state == BD2802_OFF) {
		led->white_current = max_current;
		led->blue_current = BD2802_CURRENT_000;	
		led->led_state = BD2802_ON;
		bd2802_on(led);
		bd2802_enable(led);
	} */

	if (led->key_led != id)
		bd2802_turn_white(led,led->key_led);

	led->key_led=id;
	DBG("led->key_led =%d\n",led->key_led);

	led->blue_current = max_current;
	bd2802_turn_blue(led, led->key_led);
	bd2802_turn_blue(led, HIDDEN1);
	bd2802_turn_blue(led, HIDDEN2);

	hrtimer_start(&led->touchkey_timer, ktime_set(0, 500000000), HRTIMER_MODE_REL); /*5 sec */
}
コード例 #3
0
static int bd2802_bl_resume(struct i2c_client *client)
{
	struct bd2802_led *led = i2c_get_clientdata(client);
	DBG("\n");

	if (led->led_resumed==1)
		return 0;
	
	led->led_state = BD2802_ON;
	led->white_current = BD2802_CURRENT_WHITE_MAX;
	led->blue_current = BD2802_CURRENT_000;
/*	if (system_rev >=4) //OVER REV.D
	{
		bd2802_write_byte(led->client, BD2812_DCDCDRIVER, 0x00);
		bd2802_write_byte(led->client, BD2812_PIN_FUNC_SETUP, 0x0F);
	}*/
	bd2802_on(led);
	bd2802_enable(led);

	//hrtimer_start(&led->touchkey_timer, ktime_set(0, 500000000), HRTIMER_MODE_REL); /*5 sec */
	hrtimer_start(&led->ledmin_timer, ktime_set(5, 0), HRTIMER_MODE_REL);
	led->led_resumed=1;
	return 0;
}
コード例 #4
0
ファイル: leds-bd2802.c プロジェクト: kapoloclubs/diana
static int __devinit bd2802_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct bd2802_led *led;
	int ret, i;

	pr_warning("%s() -- start\n", __func__);

	led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL);
	if (!led) {
		dev_err(&client->dev, "failed to allocate driver data\n");
		return -ENOMEM;
	}

	led->client = client;
	i2c_set_clientdata(client, led);

	INIT_WORK(&led->work, bd2802_work_func);
	INIT_WORK(&led->touchkey_work, bd2802_touchkey_work_func);
	INIT_WORK(&led->ledmin_work, bd2802_ledmin_work_func);
	
	led->bd2802_wq = create_singlethread_workqueue("bd2802_wq");
	if (!led->bd2802_wq)
		return -ENOMEM;

	led->touchkey_wq = create_singlethread_workqueue("touchkey_wq");
	if (!led->touchkey_wq)
		return -ENOMEM;

	led->ledmin_wq = create_singlethread_workqueue("ledmin_wq");
	if (!led->ledmin_wq)
		return -ENOMEM;

	bd2802_i2c_client = led->client;
	/* Default attributes */
	led->wave_pattern = BD2802_PATTERN_FULL;
	led->blink_enable =0;
	led->led_state = BD2802_SEQ;
	led->key_led = ALL;
	led->key_direction= FORWARD;
	led->led_counter=0;
#if defined(BLINK_ON_BOOTING)
	led->white_current = BD2802_CURRENT_WHITE_MAX;
	led->blue_current = BD2802_CURRENT_000;
#else
	led->white_current = BD2802_CURRENT_WHITE_MAX;
	led->blue_current = BD2802_CURRENT_BLUE_MAX;
#endif

	init_rwsem(&led->rwsem);

	for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++) {
		ret = device_create_file(&led->client->dev,
						bd2802_attributes[i]);
		if (ret) {
			dev_err(&led->client->dev, "failed: sysfs file %s\n",
					bd2802_attributes[i]->attr.name);
			goto failed_unregister_dev_file;
		}
	}

	hrtimer_init(&led->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->timer.function = bd2802_timer_func;
#if defined(BLINK_ON_BOOTING)
#else
	hrtimer_start(&led->timer, ktime_set(4, 0), HRTIMER_MODE_REL);
#endif
	
	hrtimer_init(&led->touchkey_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->touchkey_timer.function = bd2802_touchkey_timer_func;
	
	hrtimer_init(&led->ledmin_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->ledmin_timer.function = bd2802_ledmin_timer_func;
	

#ifdef CONFIG_HAS_EARLYSUSPEND
	led->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
	led->early_suspend.suspend = bd2802_early_suspend;
	led->early_suspend.resume = bd2802_late_resume;
	register_early_suspend(&led->early_suspend);
#endif

	bd2802_configure(led);
#if defined(BLINK_ON_BOOTING)
	led->blink_enable =1;
#endif
	bd2802_on(led);
	bd2802_enable(led);

//LGE_UPDATE
	led->led_state=BD2802_ON;
//LGE_UPDATE
	return 0;

failed_unregister_dev_file:
	for (i--; i >= 0; i--)
		device_remove_file(&led->client->dev, bd2802_attributes[i]);

	return ret;
}