Commit e5e30dfc authored by Douglas Anderson's avatar Douglas Anderson Committed by Sam Ravnborg

drm: panel: simple: Defer unprepare delay till next prepare to shorten it

It is believed that all of the current users of the "unprepare" delay
don't actually need to wait the amount of time specified directly in
the unprepare phase.  The purpose of the delay that's specified is to
allow the panel to fully power off so that we don't try to power it
back on before it's managed to full power down.

Let's use this observation to avoid the fixed delay that we currently
have.  Instead of delaying, we'll note the current time when the
unprepare happens.  If someone then tries to prepare the panel later
and not enough time has passed, we'll do the delay before starting the
prepare phase.
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20201109170018.v4.2.I06a95d83e7fa1bd919c8edd63dacacb5436e495a@changeid
parent 131f909a
...@@ -115,6 +115,11 @@ struct panel_desc { ...@@ -115,6 +115,11 @@ struct panel_desc {
* *
* The time (in milliseconds) that it takes for the panel * The time (in milliseconds) that it takes for the panel
* to power itself down completely. * to power itself down completely.
*
* This time is used to prevent a future "prepare" from
* starting until at least this many milliseconds has passed.
* If at prepare time less time has passed since unprepare
* finished, the driver waits for the remaining time.
*/ */
unsigned int unprepare; unsigned int unprepare;
} delay; } delay;
...@@ -130,6 +135,8 @@ struct panel_simple { ...@@ -130,6 +135,8 @@ struct panel_simple {
bool enabled; bool enabled;
bool no_hpd; bool no_hpd;
ktime_t unprepared_time;
const struct panel_desc *desc; const struct panel_desc *desc;
struct regulator *supply; struct regulator *supply;
...@@ -257,6 +264,20 @@ static int panel_simple_get_non_edid_modes(struct panel_simple *panel, ...@@ -257,6 +264,20 @@ static int panel_simple_get_non_edid_modes(struct panel_simple *panel,
return num; return num;
} }
static void panel_simple_wait(ktime_t start_ktime, unsigned int min_ms)
{
ktime_t now_ktime, min_ktime;
if (!min_ms)
return;
min_ktime = ktime_add(start_ktime, ms_to_ktime(min_ms));
now_ktime = ktime_get();
if (ktime_before(now_ktime, min_ktime))
msleep(ktime_to_ms(ktime_sub(min_ktime, now_ktime)) + 1);
}
static int panel_simple_disable(struct drm_panel *panel) static int panel_simple_disable(struct drm_panel *panel)
{ {
struct panel_simple *p = to_panel_simple(panel); struct panel_simple *p = to_panel_simple(panel);
...@@ -283,10 +304,8 @@ static int panel_simple_unprepare(struct drm_panel *panel) ...@@ -283,10 +304,8 @@ static int panel_simple_unprepare(struct drm_panel *panel)
regulator_disable(p->supply); regulator_disable(p->supply);
if (p->desc->delay.unprepare)
msleep(p->desc->delay.unprepare);
p->prepared = false; p->prepared = false;
p->unprepared_time = ktime_get();
return 0; return 0;
} }
...@@ -326,6 +345,8 @@ static int panel_simple_prepare(struct drm_panel *panel) ...@@ -326,6 +345,8 @@ static int panel_simple_prepare(struct drm_panel *panel)
if (p->prepared) if (p->prepared)
return 0; return 0;
panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare);
err = regulator_enable(p->supply); err = regulator_enable(p->supply);
if (err < 0) { if (err < 0) {
dev_err(panel->dev, "failed to enable supply: %d\n", err); dev_err(panel->dev, "failed to enable supply: %d\n", err);
......
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