aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2012-04-02 17:17:14 -0700
committerKalimochoAz <calimochoazucarado@gmail.com>2012-05-22 09:37:24 +0200
commit6ac7ce900f9750d766a405c95172fa8fcb11f97e (patch)
tree0c160422d33a4f1be6cf8b86e2b4ebefee01a7f4
parentec72e6fa86fc57bceba312b2acd42d6ffa429a79 (diff)
downloadkernel_samsung_crespo-6ac7ce900f9750d766a405c95172fa8fcb11f97e.zip
kernel_samsung_crespo-6ac7ce900f9750d766a405c95172fa8fcb11f97e.tar.gz
kernel_samsung_crespo-6ac7ce900f9750d766a405c95172fa8fcb11f97e.tar.bz2
cpufreq: interactive: Boost frequency on touchscreen input
Based on previous patches by Tero Kristo <tero.kristo@nokia.com>, Brian Steuer <bsteuer@codeaurora.org>, David Ng <dave@codeaurora.org>, Antti P Miettinen <amiettinen@nvidia.com>, and Thomas Renninger <trenn@suse.de> Change-Id: Ic55fedcf6f9310f43a7022fb88e23b0392122769 Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--Documentation/cpu-freq/governors.txt3
-rw-r--r--drivers/cpufreq/cpufreq_interactive.c164
-rw-r--r--include/trace/events/cpufreq_interactive.h12
3 files changed, 178 insertions, 1 deletions
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt
index 837a14d..e41be22 100644
--- a/Documentation/cpu-freq/governors.txt
+++ b/Documentation/cpu-freq/governors.txt
@@ -240,6 +240,9 @@ Default is 20000 uS.
timer_rate: Sample rate for reevaluating cpu load when the system is
not idle. Default is 20000 uS.
+input_boost: If non-zero, boost speed of all CPUs to hispeed_freq on
+touchscreen activity. Default is 0.
+
3. The Governor Interface in the CPUfreq Core
=============================================
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index a57669a..92de710 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -27,6 +27,8 @@
#include <linux/workqueue.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/input.h>
#define CREATE_TRACE_POINTS
#include <trace/events/cpufreq_interactive.h>
@@ -90,6 +92,19 @@ static unsigned long timer_rate;
#define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
static unsigned long above_hispeed_delay_val;
+/*
+ * Boost to hispeed on touchscreen input.
+ */
+
+static int input_boost_val;
+
+struct cpufreq_interactive_inputopen {
+ struct input_handle *handle;
+ struct work_struct inputopen_work;
+};
+
+static struct cpufreq_interactive_inputopen inputopen;
+
static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
unsigned int event);
@@ -470,6 +485,125 @@ static void cpufreq_interactive_freq_down(struct work_struct *work)
}
}
+static void cpufreq_interactive_boost(void)
+{
+ int i;
+ int anyboost = 0;
+ unsigned long flags;
+ struct cpufreq_interactive_cpuinfo *pcpu;
+
+ trace_cpufreq_interactive_boost(hispeed_freq);
+ spin_lock_irqsave(&up_cpumask_lock, flags);
+
+ for_each_online_cpu(i) {
+ pcpu = &per_cpu(cpuinfo, i);
+
+ if (pcpu->target_freq < hispeed_freq) {
+ pcpu->target_freq = hispeed_freq;
+ cpumask_set_cpu(i, &up_cpumask);
+ pcpu->target_set_time_in_idle =
+ get_cpu_idle_time_us(i, &pcpu->target_set_time);
+ anyboost = 1;
+ }
+
+ /*
+ * Refresh time at which current (possibly being
+ * boosted) speed last validated (reset timer for
+ * allowing speed to drop).
+ */
+
+ pcpu->target_validate_time_in_idle =
+ get_cpu_idle_time_us(i, &pcpu->target_validate_time);
+ }
+
+ spin_unlock_irqrestore(&up_cpumask_lock, flags);
+
+ if (anyboost)
+ wake_up_process(up_task);
+}
+
+static void cpufreq_interactive_input_event(struct input_handle *handle,
+ unsigned int type,
+ unsigned int code, int value)
+{
+ if (input_boost_val && type == EV_SYN && code == SYN_REPORT)
+ cpufreq_interactive_boost();
+}
+
+static void cpufreq_interactive_input_open(struct work_struct *w)
+{
+ struct cpufreq_interactive_inputopen *io =
+ container_of(w, struct cpufreq_interactive_inputopen,
+ inputopen_work);
+ int error;
+
+ error = input_open_device(io->handle);
+ if (error)
+ input_unregister_handle(io->handle);
+}
+
+static int cpufreq_interactive_input_connect(struct input_handler *handler,
+ struct input_dev *dev,
+ const struct input_device_id *id)
+{
+ struct input_handle *handle;
+ int error;
+
+ pr_info("%s: connect to %s\n", __func__, dev->name);
+ handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
+ if (!handle)
+ return -ENOMEM;
+
+ handle->dev = dev;
+ handle->handler = handler;
+ handle->name = "cpufreq_interactive";
+
+ error = input_register_handle(handle);
+ if (error)
+ goto err;
+
+ inputopen.handle = handle;
+ queue_work(down_wq, &inputopen.inputopen_work);
+ return 0;
+err:
+ kfree(handle);
+ return error;
+}
+
+static void cpufreq_interactive_input_disconnect(struct input_handle *handle)
+{
+ input_close_device(handle);
+ input_unregister_handle(handle);
+ kfree(handle);
+}
+
+static const struct input_device_id cpufreq_interactive_ids[] = {
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .evbit = { BIT_MASK(EV_ABS) },
+ .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
+ BIT_MASK(ABS_MT_POSITION_X) |
+ BIT_MASK(ABS_MT_POSITION_Y) },
+ }, /* multi-touch touchscreen */
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
+ .absbit = { [BIT_WORD(ABS_X)] =
+ BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
+ }, /* touchpad */
+ { },
+};
+
+static struct input_handler cpufreq_interactive_input_handler = {
+ .event = cpufreq_interactive_input_event,
+ .connect = cpufreq_interactive_input_connect,
+ .disconnect = cpufreq_interactive_input_disconnect,
+ .name = "cpufreq_interactive",
+ .id_table = cpufreq_interactive_ids,
+};
+
static ssize_t show_hispeed_freq(struct kobject *kobj,
struct attribute *attr, char *buf)
{
@@ -582,12 +716,34 @@ static ssize_t store_timer_rate(struct kobject *kobj,
static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
show_timer_rate, store_timer_rate);
+static ssize_t show_input_boost(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%u\n", input_boost_val);
+}
+
+static ssize_t store_input_boost(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned long val;
+
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+ input_boost_val = val;
+ return count;
+}
+
+define_one_global_rw(input_boost);
+
static struct attribute *interactive_attributes[] = {
&hispeed_freq_attr.attr,
&go_hispeed_load_attr.attr,
&above_hispeed_delay.attr,
&min_sample_time_attr.attr,
&timer_rate_attr.attr,
+ &input_boost.attr,
NULL,
};
@@ -643,6 +799,11 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
if (rc)
return rc;
+ rc = input_register_handler(&cpufreq_interactive_input_handler);
+ if (rc)
+ pr_warn("%s: failed to register input handler\n",
+ __func__);
+
break;
case CPUFREQ_GOV_STOP:
@@ -665,6 +826,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
if (atomic_dec_return(&active_count) > 0)
return 0;
+ input_unregister_handler(&cpufreq_interactive_input_handler);
sysfs_remove_group(cpufreq_global_kobject,
&interactive_attr_group);
@@ -744,7 +906,7 @@ static int __init cpufreq_interactive_init(void)
mutex_init(&set_speed_lock);
idle_notifier_register(&cpufreq_interactive_idle_nb);
-
+ INIT_WORK(&inputopen.inputopen_work, cpufreq_interactive_input_open);
return cpufreq_register_governor(&cpufreq_gov_interactive);
err_freeuptask:
diff --git a/include/trace/events/cpufreq_interactive.h b/include/trace/events/cpufreq_interactive.h
index 3a90d3d..19e070b 100644
--- a/include/trace/events/cpufreq_interactive.h
+++ b/include/trace/events/cpufreq_interactive.h
@@ -81,6 +81,18 @@ DEFINE_EVENT(loadeval, cpufreq_interactive_notyet,
unsigned long curfreq, unsigned long targfreq),
TP_ARGS(cpu_id, load, curfreq, targfreq)
);
+
+TRACE_EVENT(cpufreq_interactive_boost,
+ TP_PROTO(unsigned long freq),
+ TP_ARGS(freq),
+ TP_STRUCT__entry(
+ __field(unsigned long, freq)
+ ),
+ TP_fast_assign(
+ __entry->freq = freq;
+ ),
+ TP_printk("freq=%lu", __entry->freq)
+);
#endif /* _TRACE_CPUFREQ_INTERACTIVE_H */
/* This part must be outside protection */