Cpufreq: Added input event hook to ramp up cpu frequency

This will cause switch to maximum opp immediately when user
interaction occurs, i.e. touchscreen input or keypad activity.

Change-Id: I0cfe32479ef62a967f359c1bf57f97eefde7e8f7
Signed-off-by: Tero Kristo <tero.kristo@nokia.com>
Signed-off-by: Jouni Hogander <jouni.hogander@nokia.com>
[bsteuer@quicinc.com: fixed cpu_dbs_info naming, added header]
Signed-off-by: Brian Steuer <bsteuer@codeaurora.org>
This commit is contained in:
Tero Kristo
2009-08-18 17:40:29 -07:00
committed by Stephen Boyd
parent e7bbb10673
commit 0e29c3a27e
3 changed files with 89 additions and 2 deletions

View File

@@ -72,7 +72,7 @@ static DEFINE_PER_CPU(int, cpufreq_policy_cpu);
static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem);
#define lock_policy_rwsem(mode, cpu) \
static int lock_policy_rwsem_##mode \
int lock_policy_rwsem_##mode \
(int cpu) \
{ \
int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \
@@ -97,7 +97,7 @@ static void unlock_policy_rwsem_read(int cpu)
up_read(&per_cpu(cpu_policy_rwsem, policy_cpu));
}
static void unlock_policy_rwsem_write(int cpu)
void unlock_policy_rwsem_write(int cpu)
{
int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu);
BUG_ON(policy_cpu == -1);

View File

@@ -22,6 +22,9 @@
#include <linux/tick.h>
#include <linux/ktime.h>
#include <linux/sched.h>
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/slab.h>
/*
* dbs is used in this file as a shortform for demandbased switching
@@ -705,6 +708,86 @@ static int should_io_be_busy(void)
return 0;
}
static void dbs_refresh_callback(struct work_struct *unused)
{
struct cpufreq_policy *policy;
struct cpu_dbs_info_s *this_dbs_info;
if (lock_policy_rwsem_write(0) < 0)
return;
this_dbs_info = &per_cpu(od_cpu_dbs_info, 0);
policy = this_dbs_info->cur_policy;
if (policy->cur < policy->max) {
policy->cur = policy->max;
__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);
}
unlock_policy_rwsem_write(0);
}
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)
{
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 err2;
error = input_open_device(handle);
if (error)
goto err1;
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)
{
@@ -763,6 +846,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
latency * LATENCY_MULTIPLIER);
dbs_tuners_ins.io_is_busy = should_io_be_busy();
}
rc = input_register_handler(&dbs_input_handler);
mutex_unlock(&dbs_mutex);
mutex_init(&this_dbs_info->timer_mutex);
@@ -775,6 +859,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
mutex_lock(&dbs_mutex);
mutex_destroy(&this_dbs_info->timer_mutex);
dbs_enable--;
input_unregister_handler(&dbs_input_handler);
mutex_unlock(&dbs_mutex);
if (!dbs_enable)
sysfs_remove_group(cpufreq_global_kobject,

View File

@@ -205,6 +205,8 @@ extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy,
int cpufreq_register_governor(struct cpufreq_governor *governor);
void cpufreq_unregister_governor(struct cpufreq_governor *governor);
int lock_policy_rwsem_write(int cpu);
void unlock_policy_rwsem_write(int cpu);
/*********************************************************************
* CPUFREQ DRIVER INTERFACE *