Commit dfb6e47d authored by Sultan Alsawaf's avatar Sultan Alsawaf Committed by arnavpuranik
Browse files

devfreq_boost: Simplify screen-awake check



A single global boolean is enough to say that we don't want to boost
anything while the screen is turned off.
Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: default avatarFrancisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: ronax's avatarronaxdevil <pratabidya.007@gmail.com>
Signed-off-by: rohan69's avatarreaPeR1010 <rohan10102002@gmail.com>
parent 8c5c7925
......@@ -28,13 +28,13 @@ struct boost_dev {
unsigned long boost_freq;
unsigned long max_boost_expires;
unsigned long max_boost_jiffies;
bool disable;
spinlock_t lock;
};
struct df_boost_drv {
struct boost_dev devices[DEVFREQ_MAX];
struct notifier_block fb_notif;
bool screen_awake;
};
static struct df_boost_drv *df_boost_drv_g __read_mostly;
......@@ -44,7 +44,7 @@ static void __devfreq_boost_kick(struct boost_dev *b)
unsigned long flags;
spin_lock_irqsave(&b->lock, flags);
if (!b->df || b->disable) {
if (!b->df) {
spin_unlock_irqrestore(&b->lock, flags);
return;
}
......@@ -60,6 +60,9 @@ void devfreq_boost_kick(enum df_device device)
if (!d)
return;
if (!d->screen_awake)
return;
__devfreq_boost_kick(d->devices + device);
}
......@@ -69,7 +72,7 @@ static void __devfreq_boost_kick_max(struct boost_dev *b,
unsigned long flags, new_expires;
spin_lock_irqsave(&b->lock, flags);
if (!b->df || b->disable) {
if (!b->df) {
spin_unlock_irqrestore(&b->lock, flags);
return;
}
......@@ -93,6 +96,9 @@ void devfreq_boost_kick_max(enum df_device device, unsigned int duration_ms)
if (!d)
return;
if (!d->screen_awake)
return;
__devfreq_boost_kick_max(d->devices + device, duration_ms);
}
......@@ -140,20 +146,6 @@ static unsigned long devfreq_abs_min_freq(struct boost_dev *b)
return b->abs_min_freq;
}
static void devfreq_disable_boosting(struct df_boost_drv *d, bool disable)
{
int i;
for (i = 0; i < DEVFREQ_MAX; i++) {
struct boost_dev *b = d->devices + i;
unsigned long flags;
spin_lock_irqsave(&b->lock, flags);
b->disable = disable;
spin_unlock_irqrestore(&b->lock, flags);
}
}
static void devfreq_unboost_all(struct df_boost_drv *d)
{
int i;
......@@ -259,16 +251,14 @@ static int fb_notifier_cb(struct notifier_block *nb,
struct df_boost_drv *d = container_of(nb, typeof(*d), fb_notif);
struct fb_event *evdata = data;
int *blank = evdata->data;
bool screen_awake;
/* Parse framebuffer blank events as soon as they occur */
if (action != FB_EARLY_EVENT_BLANK)
return NOTIFY_OK;
/* Boost when the screen turns on and unboost when it turns off */
screen_awake = *blank == FB_BLANK_UNBLANK;
devfreq_disable_boosting(d, !screen_awake);
if (screen_awake) {
d->screen_awake = *blank == FB_BLANK_UNBLANK;
if (d->screen_awake) {
int i;
for (i = 0; i < DEVFREQ_MAX; i++)
......@@ -288,6 +278,9 @@ static void devfreq_boost_input_event(struct input_handle *handle,
struct df_boost_drv *d = handle->handler->private;
int i;
if (!d->screen_awake)
return;
for (i = 0; i < DEVFREQ_MAX; i++)
__devfreq_boost_kick(d->devices + i);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment