Exemple #1
0
static void led_timer_function(unsigned long data)
{
    struct led_classdev *led_cdev = (struct led_classdev *) data;
    struct timer_trig_data *timer_data = led_cdev->trigger_data;
    unsigned long brightness;
    unsigned long delay;

    if (!timer_data->delay_on || !timer_data->delay_off) {
        led_set_brightness(led_cdev, LED_OFF);
        return;
    }

    brightness = led_get_brightness(led_cdev);
    if (!brightness) {
        /* Time to switch the LED on. */
        brightness = timer_data->brightness_on;
        delay = timer_data->delay_on;
    } else {
        /* Store the current brightness value to be able
         * to restore it when the delay_off period is over.
         */
        timer_data->brightness_on = brightness;
        brightness = LED_OFF;
        delay = timer_data->delay_off;
    }

    led_set_brightness(led_cdev, brightness);
#if (CONFIG_RTC_LEDTRIG_TIMER==1)
    led_rtc_set_alarm(led_cdev, delay);
#elif (CONFIG_RTC_LEDTRIG_TIMER==2)
    hrtimer_start(&timer_data->hrtimer, ns_to_ktime((u64)delay*1000*1000), HRTIMER_MODE_REL);
#else
    mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay));
#endif
}
Exemple #2
0
static void led_timer_function(unsigned long data)
{
	struct led_classdev *led_cdev = (struct led_classdev *) data;
	struct notification_trig_data *timer_data = led_cdev->trigger_data;
	unsigned long brightness;
	unsigned long delay;

	if (!timer_data->delay_on || !timer_data->delay_off || !timer_data->blink_cnt) {
		led_set_brightness(led_cdev, LED_OFF);
		return;
	}

	brightness = led_get_brightness(led_cdev);
	if (!brightness) {
		/* Time to switch the LED on. */
		brightness = timer_data->brightness_on;
		delay = timer_data->delay_on;
	} else {
		/* Store the current brightness value to be able
		 * to restore it when the delay_off period is over.
		 */
		timer_data->brightness_on = brightness;
		brightness = LED_OFF;
		delay = timer_data->delay_off;

		if(timer_data->blink_cnt <= ++timer_data->current_blink_cnt) {
			timer_data->current_blink_cnt = 0;
			delay+=timer_data->off_duration;
		}
	}

	led_set_brightness(led_cdev, brightness);
	
	led_rtc_set_alarm(led_cdev, delay);
}
Exemple #3
0
static void led_set_software_blink(struct led_classdev *led_cdev,
				   unsigned long delay_on,
				   unsigned long delay_off)
{
	int current_brightness;

	current_brightness = led_get_brightness(led_cdev);
	if (current_brightness)
		led_cdev->blink_brightness = current_brightness;
	if (!led_cdev->blink_brightness)
		led_cdev->blink_brightness = led_cdev->max_brightness;

	led_cdev->blink_delay_on = delay_on;
	led_cdev->blink_delay_off = delay_off;

	/* never on - just set to off */
	if (!delay_on) {
		led_set_brightness_nosleep(led_cdev, LED_OFF);
		return;
	}

	/* never off - just set to brightness */
	if (!delay_off) {
		led_set_brightness_nosleep(led_cdev,
					   led_cdev->blink_brightness);
		return;
	}

	led_cdev->flags |= LED_BLINK_SW;
	mod_timer(&led_cdev->blink_timer, jiffies + 1);
}
static void led_timer_function(unsigned long data)
{
	struct led_classdev *led_cdev = (void *)data;
	unsigned long brightness;
	unsigned long delay;

	if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
		led_set_brightness(led_cdev, LED_OFF);
		return;
	}

	brightness = led_get_brightness(led_cdev);
	if (!brightness) {
		/*                            */
		brightness = led_cdev->blink_brightness;
		delay = led_cdev->blink_delay_on;
	} else {
		/*                                              
                                                     
   */
		led_cdev->blink_brightness = brightness;
		brightness = LED_OFF;
		delay = led_cdev->blink_delay_off;
	}

	led_set_brightness(led_cdev, brightness);

	mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}
Exemple #5
0
static void led_set_software_blink(struct led_classdev *led_cdev,
				   unsigned long delay_on,
				   unsigned long delay_off)
{
	int current_brightness;

	current_brightness = led_get_brightness(led_cdev);
	if (current_brightness)
		led_cdev->blink_brightness = current_brightness;
	if (!led_cdev->blink_brightness)
		led_cdev->blink_brightness = led_cdev->max_brightness;

	if (led_get_trigger_data(led_cdev) &&
	    delay_on == led_cdev->blink_delay_on &&
	    delay_off == led_cdev->blink_delay_off)
		return;

	led_stop_software_blink(led_cdev);

	led_cdev->blink_delay_on = delay_on;
	led_cdev->blink_delay_off = delay_off;

	/* never on - don't blink */
	if (!delay_on)
		return;

	/* never off - just set to brightness */
	if (!delay_off) {
		led_set_brightness(led_cdev, led_cdev->blink_brightness);
		return;
	}

	mod_timer(&led_cdev->blink_timer, jiffies + 1);
}
static void led_timer_function(unsigned long data)
{
	struct led_classdev *led_cdev = (struct led_classdev *) data;
	struct timer_trig_data *timer_data = led_cdev->trigger_data;
	unsigned long brightness;
	unsigned long delay;

	if (!timer_data->delay_on || !timer_data->delay_off) {
		led_set_brightness(led_cdev, LED_OFF);
		return;
	}

	brightness = led_get_brightness(led_cdev);
	if (!brightness) {
		/* Time to switch the LED on. */
		brightness = timer_data->brightness_on;
		delay = timer_data->delay_on;
	} else {
		/* Store the current brightness value to be able
		 * to restore it when the delay_off period is over.
		 */
		timer_data->brightness_on = brightness;
		brightness = LED_OFF;
		delay = timer_data->delay_off;
	}

	led_set_brightness(led_cdev, brightness);

	mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay));
}
Exemple #7
0
static void fb_f1c500s_suspend(struct device_t * dev)
{
	struct framebuffer_t * fb = (struct framebuffer_t *)dev->priv;
	struct fb_f1c500s_pdata_t * pdat = (struct fb_f1c500s_pdata_t *)fb->priv;

	pdat->brightness = led_get_brightness(pdat->backlight);
	led_set_brightness(pdat->backlight, 0);
}
Exemple #8
0
static void fb_rk3288_suspend(struct device_t * dev)
{
	struct fb_t * fb = (struct fb_t *)dev->priv;
	struct fb_rk3288_pdata_t * pdat = (struct fb_rk3288_pdata_t *)fb->priv;

	pdat->brightness = led_get_brightness(pdat->backlight);
	led_set_brightness(pdat->backlight, 0);
}
Exemple #9
0
static ssize_t led_read_brightness(struct kobj_t * kobj, void * buf, size_t size)
{
	struct led_t * led = (struct led_t *)kobj->priv;
	int brightness;

	brightness = led_get_brightness(led);
	return sprintf(buf, "%d", brightness);
}
Exemple #10
0
static void led_timer_function(struct timer_list *t)
{
	struct led_classdev *led_cdev = from_timer(led_cdev, t, blink_timer);
	unsigned long brightness;
	unsigned long delay;

	if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
		led_set_brightness_nosleep(led_cdev, LED_OFF);
		clear_bit(LED_BLINK_SW, &led_cdev->work_flags);
		return;
	}

	if (test_and_clear_bit(LED_BLINK_ONESHOT_STOP,
			       &led_cdev->work_flags)) {
		clear_bit(LED_BLINK_SW, &led_cdev->work_flags);
		return;
	}

	brightness = led_get_brightness(led_cdev);
	if (!brightness) {
		/* Time to switch the LED on. */
		if (test_and_clear_bit(LED_BLINK_BRIGHTNESS_CHANGE,
					&led_cdev->work_flags))
			brightness = led_cdev->new_blink_brightness;
		else
			brightness = led_cdev->blink_brightness;
		delay = led_cdev->blink_delay_on;
	} else {
		/* Store the current brightness value to be able
		 * to restore it when the delay_off period is over.
		 */
		led_cdev->blink_brightness = brightness;
		brightness = LED_OFF;
		delay = led_cdev->blink_delay_off;
	}

	led_set_brightness_nosleep(led_cdev, brightness);

	/* Return in next iteration if led is in one-shot mode and we are in
	 * the final blink state so that the led is toggled each delay_on +
	 * delay_off milliseconds in worst case.
	 */
	if (test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags)) {
		if (test_bit(LED_BLINK_INVERT, &led_cdev->work_flags)) {
			if (brightness)
				set_bit(LED_BLINK_ONESHOT_STOP,
					&led_cdev->work_flags);
		} else {
			if (!brightness)
				set_bit(LED_BLINK_ONESHOT_STOP,
					&led_cdev->work_flags);
		}
	}

	mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}
Exemple #11
0
static void led_timer_function(unsigned long data)
{
	struct led_classdev *led_cdev = (void *)data;
	unsigned long brightness;
	unsigned long delay;

	if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
		led_set_brightness_nosleep(led_cdev, LED_OFF);
		led_cdev->flags &= ~LED_BLINK_SW;
		return;
	}

	if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) {
		led_cdev->flags &=  ~(LED_BLINK_ONESHOT_STOP | LED_BLINK_SW);
		return;
	}

	brightness = led_get_brightness(led_cdev);
	if (!brightness) {
		/* Time to switch the LED on. */
		brightness = led_cdev->blink_brightness;
		delay = led_cdev->blink_delay_on;
	} else {
		/* Store the current brightness value to be able
		 * to restore it when the delay_off period is over.
		 * Do it only if there is no pending blink brightness
		 * change, to avoid overwriting the new value.
		 */
		if (!(led_cdev->flags & LED_BLINK_BRIGHTNESS_CHANGE))
			led_cdev->blink_brightness = brightness;
		else
			led_cdev->flags &= ~LED_BLINK_BRIGHTNESS_CHANGE;
		brightness = LED_OFF;
		delay = led_cdev->blink_delay_off;
	}

	led_set_brightness_nosleep(led_cdev, brightness);

	/* Return in next iteration if led is in one-shot mode and we are in
	 * the final blink state so that the led is toggled each delay_on +
	 * delay_off milliseconds in worst case.
	 */
	if (led_cdev->flags & LED_BLINK_ONESHOT) {
		if (led_cdev->flags & LED_BLINK_INVERT) {
			if (brightness)
				led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
		} else {
			if (!brightness)
				led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
		}
	}

	mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}
Exemple #12
0
static void notification_trig_activate(struct led_classdev *led_cdev)
{
	struct notification_trig_data *timer_data;
	int rc;

	timer_data = kzalloc(sizeof(struct notification_trig_data), GFP_KERNEL);
	if (!timer_data)
		return;

	timer_data->brightness_on = led_get_brightness(led_cdev);
	if (timer_data->brightness_on == LED_OFF)
		timer_data->brightness_on = led_cdev->max_brightness;
	led_cdev->trigger_data = timer_data;

	init_timer(&timer_data->timer);
	timer_data->timer.function = led_timer_function;
	timer_data->timer.data = (unsigned long) led_cdev;
	
	alarm_init(&timer_data->alarm, ANDROID_ALARM_RTC_WAKEUP,
			led_rtc_timer_function);
	wake_lock_init(&timer_data->wakelock, WAKE_LOCK_SUSPEND, "ledtrig_rtc_timer");

	rc = device_create_file(led_cdev->dev, &dev_attr_delay_on);
	if (rc)
		goto err_out;
	rc = device_create_file(led_cdev->dev, &dev_attr_delay_off);
	if (rc)
		goto err_out_delayon;
	rc = device_create_file(led_cdev->dev, &dev_attr_blink_count);
	if (rc)
		goto err_attr_delay_off;
	rc = device_create_file(led_cdev->dev, &dev_attr_off_duration);
	if (rc)
		goto err_attr_blink_count;

	/* If there is hardware support for blinking, start one
	 * user friendly blink rate chosen by the driver.
	 */
	if (led_cdev->blink_set)
		led_cdev->blink_set(led_cdev,
			&timer_data->delay_on, &timer_data->delay_off);

	return;
err_attr_blink_count:
	device_remove_file(led_cdev->dev, &dev_attr_blink_count);
err_attr_delay_off:
	device_remove_file(led_cdev->dev, &dev_attr_delay_off);
err_out_delayon:
	device_remove_file(led_cdev->dev, &dev_attr_delay_on);
err_out:
	led_cdev->trigger_data = NULL;
	kfree(timer_data);
}
Exemple #13
0
static void timer_trig_activate(struct led_classdev *led_cdev)
{
    struct timer_trig_data *timer_data;
    int rc;

    timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
    if (!timer_data)
        return;

    timer_data->brightness_on = led_get_brightness(led_cdev);
    if (timer_data->brightness_on == LED_OFF)
        timer_data->brightness_on = led_cdev->max_brightness;;
    led_cdev->trigger_data = timer_data;

    init_timer(&timer_data->timer);
    timer_data->timer.function = led_timer_function;
    timer_data->timer.data = (unsigned long) led_cdev;
#if (CONFIG_RTC_LEDTRIG_TIMER==1)
    alarm_init(&timer_data->alarm, ANDROID_ALARM_RTC_WAKEUP,
               led_rtc_timer_function);
    wake_lock_init(&timer_data->wakelock, WAKE_LOCK_SUSPEND, "ledtrig_rtc_timer");
#elif (CONFIG_RTC_LEDTRIG_TIMER==2)
    hrtimer_init(&timer_data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    timer_data->hrtimer.function = ledtrig_hrtimer_function;
    msm_pm_request_wakeup(&timer_data->hrtimer);
#endif

#if 1	//0 // hanapark_DF22
    rc = device_create_file(led_cdev->dev, &dev_attr_delay_on);
    if (rc)
        goto err_out;
    rc = device_create_file(led_cdev->dev, &dev_attr_delay_off);
    if (rc)
        goto err_out_delayon;
#endif	// hanapark_DF22

    /* If there is hardware support for blinking, start one
     * user friendly blink rate chosen by the driver.
     */
    if (led_cdev->blink_set)
        led_cdev->blink_set(led_cdev,
                            &timer_data->delay_on, &timer_data->delay_off);

    return;

err_out_delayon:
    device_remove_file(led_cdev->dev, &dev_attr_delay_on);
err_out:
    led_cdev->trigger_data = NULL;
    kfree(timer_data);
}
static void timer_trig_activate(struct led_classdev *led_cdev)
{
	struct timer_trig_data *timer_data;
	int rc;

	timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
	if (!timer_data)
		return;

	timer_data->brightness_on = led_get_brightness(led_cdev);
	if (timer_data->brightness_on == LED_OFF)
		timer_data->brightness_on = led_cdev->max_brightness;
	led_cdev->trigger_data = timer_data;

	init_timer(&timer_data->timer);
	timer_data->timer.function = led_timer_function;
	timer_data->timer.data = (unsigned long) led_cdev;

	rc = device_create_file(led_cdev->dev, &dev_attr_delay_on);
	if (rc)
		goto err_out;
	rc = device_create_file(led_cdev->dev, &dev_attr_delay_off);
	if (rc)
		goto err_out_delayon;

	kobject_uevent(&led_cdev->dev->kobj, KOBJ_ADD);

	/* If there is hardware support for blinking, start one
	 * user friendly blink rate chosen by the driver.
	 */
	if (led_cdev->blink_set)
		led_cdev->blink_set(led_cdev,
			&timer_data->delay_on, &timer_data->delay_off);

	return;

err_out_delayon:
	device_remove_file(led_cdev->dev, &dev_attr_delay_on);
err_out:
	led_cdev->trigger_data = NULL;
	kfree(timer_data);
}
static void led_set_software_blink(struct led_classdev *led_cdev,
				   unsigned long delay_on,
				   unsigned long delay_off)
{
	int current_brightness;

	current_brightness = led_get_brightness(led_cdev);
	if (current_brightness)
		led_cdev->blink_brightness = current_brightness;
	if (!led_cdev->blink_brightness)
		led_cdev->blink_brightness = led_cdev->max_brightness;

//<2012/10/04-Sherman Wei,Removed for bug that missed call->plug USB->unplug USB, LED will not flash/light
//printk("[LED]+led_set_software_blink:cur_bri=%d, de_on=%d, de_off=%d;dev_on=%d, dev_off=%d \n",current_brightness,delay_on,delay_off,led_cdev->blink_delay_on, led_cdev->blink_delay_off);
#if defined(HAWK35_EP0) || defined(ARIMA_PROJECT_HAWK35) || defined(HAWK35_DTV_EP1)
/// Don't return while (delay_on == led_cdev->blink_delay_on) && (delay_off == led_cdev->blink_delay_off)
#else
	if (led_get_trigger_data(led_cdev) &&
	    delay_on == led_cdev->blink_delay_on &&
	    delay_off == led_cdev->blink_delay_off)
		return;
#endif
//printk("[LED]-led_set_software_blink\n");
//>2012/10/04-Sherman Wei

	led_stop_software_blink(led_cdev);

	led_cdev->blink_delay_on = delay_on;
	led_cdev->blink_delay_off = delay_off;

	/* never on - don't blink */
	if (!delay_on)
		return;

	/* never off - just set to brightness */
	if (!delay_off) {
		led_set_brightness(led_cdev, led_cdev->blink_brightness);
		return;
	}

	mod_timer(&led_cdev->blink_timer, jiffies + 1);
}
Exemple #16
0
static int fb_getbl(struct framebuffer_t * fb)
{
	struct fb_f1c500s_pdata_t * pdat = (struct fb_f1c500s_pdata_t *)fb->priv;
	return led_get_brightness(pdat->backlight);
}
Exemple #17
0
static int fb_getbl(struct fb_t * fb)
{
	struct fb_rk3288_pdata_t * pdat = (struct fb_rk3288_pdata_t *)fb->priv;
	return led_get_brightness(pdat->backlight);
}