Beispiel #1
0
static ssize_t bd2802_store_led_start(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);

	DBG("led_start value=%d\n",value);
	hrtimer_cancel(&led->ledmin_timer); //+DEJA

	if (value==1)
	{
		led->led_state = BD2802_SEQ;

#if defined(BLINK_ON_BOOTING)
		led->white_current = BD2802_CURRENT_WHITE_MAX;
	    led->blue_current = BD2802_CURRENT_000;
	    led->blink_enable = 1;
	    bd2802_configure(led);
	    bd2802_on(led);
#else
		led->blue_current = BD2802_CURRENT_BLUE_MAX;
		hrtimer_start(&led->timer, ktime_set(0, 800000000), HRTIMER_MODE_REL); /* 0.8 sec */
#endif	// BLINK_ON_BOOTING
	}
	else if (value==0)
	{
            #if defined(BLINK_ON_BOOTING)
	    led->led_state=BD2802_ON;
	    led->white_current = BD2802_CURRENT_WHITE_MAX;
	    led->blue_current = BD2802_CURRENT_000;
	    led->blink_enable=0;
	    bd2802_sw_reset(led);
	    bd2802_reset_cancel(led);
	    bd2802_on(led);
	    bd2802_enable(led);
		hrtimer_start(&led->ledmin_timer, ktime_set(5, 0), HRTIMER_MODE_REL); //+DEJA
            #else 
	    led->led_state=BD2802_SEQ_END;
	    led->blue_current = BD2802_CURRENT_000;
	    hrtimer_start(&led->ledmin_timer, ktime_set(10, 0), HRTIMER_MODE_REL);
            #endif
	}
	else
	{
		DBG("Value is not valid\n");
		return -EINVAL;
	}

	return count;
}
Beispiel #2
0
static void bd2802_reset_cancel(struct bd2802_led *led)
{
    gpio_set_value(led->pdata->reset_gpio, 1);
    udelay(100);
    bd2802_configure(led);
}
Beispiel #3
0
static void bd2802_reset_cancel(struct bd2802_led *led)
{
	gpio_set_value(RGB_LED_CNTL, 1);
	udelay(100);
	bd2802_configure(led);
}
Beispiel #4
0
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;
}