From: Tero Kristo <tero.kristo@xxxxxxxxx> This will cause switch to maximum opp immediately when user interaction occurs, i.e. touchscreen input or keypad activity. Signed-off-by: Tero Kristo <tero.kristo@xxxxxxxxx> Signed-off-by: Jouni Hogander <jouni.hogander@xxxxxxxxx> --- drivers/cpufreq/cpufreq_ondemand.c | 86 +++++++++++++++++++++++++++++++++++- 1 files changed, 85 insertions(+), 1 deletions(-) diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 6f45b16..e39f0b4 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -21,6 +21,8 @@ #include <linux/hrtimer.h> #include <linux/tick.h> #include <linux/ktime.h> +#include <linux/input.h> +#include <linux/workqueue.h> /* * dbs is used in this file as a shortform for demandbased switching @@ -539,6 +541,87 @@ static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) cancel_delayed_work(&dbs_info->work); } +static void dbs_refresh_callback(struct work_struct *unused) +{ + struct cpufreq_policy *policy; + struct cpu_dbs_info_s *this_dbs_info; + + this_dbs_info = &per_cpu(cpu_dbs_info, 0); + policy = this_dbs_info->cur_policy; + + __cpufreq_driver_target(policy, policy->max, + CPUFREQ_RELATION_L); + this_dbs_info->prev_cpu_idle = get_cpu_idle_time(0, + &this_dbs_info->prev_cpu_wall); +} + +static DECLARE_WORK(dbs_refresh_work, dbs_refresh_callback); + +static void dbs_input_event(struct input_handle *handle, unsigned int type, + unsigned int code, int value) +{ + struct cpufreq_policy *policy; + struct cpu_dbs_info_s *this_dbs_info; + + this_dbs_info = &per_cpu(cpu_dbs_info, 0); + policy = this_dbs_info->cur_policy; + + if (policy->cur < policy->max) { + policy->cur = policy->max; + schedule_work(&dbs_refresh_work); + } +} + +static int dbs_input_connect(struct input_handler *handler, + struct input_dev *dev, const struct input_device_id *id) +{ + struct input_handle *handle; + int error; + + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); + if (!handle) + return -ENOMEM; + + handle->dev = dev; + handle->handler = handler; + handle->name = "cpufreq"; + + error = input_register_handle(handle); + if (error) + goto err1; + + error = input_open_device(handle); + if (error) + goto err2; + + return 0; +err1: + input_unregister_handle(handle); +err2: + kfree(handle); + return error; +} + +static void dbs_input_disconnect(struct input_handle *handle) +{ + input_close_device(handle); + input_unregister_handle(handle); + kfree(handle); +} + +static const struct input_device_id dbs_ids[] = { + { .driver_info = 1 }, + { }, +}; + +static struct input_handler dbs_input_handler = { + .event = dbs_input_event, + .connect = dbs_input_connect, + .disconnect = dbs_input_disconnect, + .name = "cpufreq_ond", + .id_table = dbs_ids, +}; + static int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event) { @@ -600,7 +683,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, dbs_tuners_ins.sampling_rate = def_sampling_rate; } dbs_timer_init(this_dbs_info); - + rc = input_register_handler(&dbs_input_handler); mutex_unlock(&dbs_mutex); break; @@ -609,6 +692,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, dbs_timer_exit(this_dbs_info); sysfs_remove_group(&policy->kobj, &dbs_attr_group); dbs_enable--; + input_unregister_handler(&dbs_input_handler); mutex_unlock(&dbs_mutex); break; -- 1.5.4.3 -- To unsubscribe from this list: send the line "unsubscribe cpufreq" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html