Lines Matching +full:idle +full:- +full:wait +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Partially based on Atsushi Nemoto's ledtrig-heartbeat.c.
37 struct led_classdev *led_cdev = activity_data->led_cdev; in led_activity_function()
40 int delay; in led_activity_function() local
48 if (test_and_clear_bit(LED_BLINK_BRIGHTNESS_CHANGE, &led_cdev->work_flags)) in led_activity_function()
49 led_cdev->blink_brightness = led_cdev->new_blink_brightness; in led_activity_function()
53 led_set_brightness_nosleep(led_cdev, led_cdev->blink_brightness); in led_activity_function()
75 * down to 16us, ensuring we won't overflow 32-bit computations below in led_activity_function()
79 diff_boot = (curr_boot - activity_data->last_boot) >> 16; in led_activity_function()
80 diff_used = (curr_used - activity_data->last_used) >> 16; in led_activity_function()
81 activity_data->last_boot = curr_boot; in led_activity_function()
82 activity_data->last_used = curr_used; in led_activity_function()
93 * the total idle+wait time for all CPUs. We'll compare how they evolved in led_activity_function()
96 * 1 - delta_idle / delta_boot in led_activity_function()
102 * enough to saturate one core in multi-core systems or 50% in single in led_activity_function()
108 * a steady state so that it's easy to distinguish an idle or saturated in led_activity_function()
112 * - a target CPU usage of min(50%, 100%/#CPU) for a 10% duty cycle in led_activity_function()
114 * - below target : in led_activity_function()
116 * OFF_ms = 90 + (1 - usage/target) * 900 in led_activity_function()
117 * - above target : in led_activity_function()
118 * ON_ms = 10 + (usage-target)/(100%-target) * 80 in led_activity_function()
119 * OFF_ms = 90 - (usage-target)/(100%-target) * 80 in led_activity_function()
126 activity_data->time_left -= 100; in led_activity_function()
127 if (activity_data->time_left <= 0) { in led_activity_function()
128 activity_data->time_left = 0; in led_activity_function()
129 activity_data->state = !activity_data->state; in led_activity_function()
131 (activity_data->state ^ activity_data->invert) ? in led_activity_function()
132 led_cdev->blink_brightness : LED_OFF); in led_activity_function()
138 delay = activity_data->state ? in led_activity_function()
140 990 - 900 * usage / target; /* OFF */ in led_activity_function()
142 delay = activity_data->state ? in led_activity_function()
143 10 + 80 * (usage - target) / (100 - target) : /* ON */ in led_activity_function()
144 90 - 80 * (usage - target) / (100 - target); /* OFF */ in led_activity_function()
147 if (!activity_data->time_left || delay <= activity_data->time_left) in led_activity_function()
148 activity_data->time_left = delay; in led_activity_function()
150 delay = min_t(int, activity_data->time_left, 100); in led_activity_function()
151 mod_timer(&activity_data->timer, jiffies + msecs_to_jiffies(delay)); in led_activity_function()
159 return sprintf(buf, "%u\n", activity_data->invert); in led_invert_show()
174 activity_data->invert = !!state; in led_invert_store()
193 return -ENOMEM; in activity_activate()
197 activity_data->led_cdev = led_cdev; in activity_activate()
198 timer_setup(&activity_data->timer, led_activity_function, 0); in activity_activate()
199 if (!led_cdev->blink_brightness) in activity_activate()
200 led_cdev->blink_brightness = led_cdev->max_brightness; in activity_activate()
201 led_activity_function(&activity_data->timer); in activity_activate()
202 set_bit(LED_BLINK_SW, &led_cdev->work_flags); in activity_activate()
211 del_timer_sync(&activity_data->timer); in activity_deactivate()
213 clear_bit(LED_BLINK_SW, &led_cdev->work_flags); in activity_deactivate()