Commit 4beb04be authored by Douglas Anderson's avatar Douglas Anderson Committed by Sam Ravnborg

drm: panel: simple: Allow specifying the delay from prepare to enable

On the panel I'm looking at, there's an 80 ms minimum time between HPD
being asserted by the panel and setting the backlight enable GPIO.
While we could just add an 80 ms "enable" delay, this is not ideal.
Link training is allowed to happen in parallel with this delay so the
fixed 80 ms delay over-delays.

We'll support this by logging the time at the end of prepare and then
delaying in enable if enough time hasn't passed.
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.3.Ib9ce3c6482f464bf594161581521ced46bbd54ed@changeid
parent e5e30dfc
...@@ -93,6 +93,36 @@ struct panel_desc { ...@@ -93,6 +93,36 @@ struct panel_desc {
*/ */
unsigned int hpd_absent_delay; unsigned int hpd_absent_delay;
/**
* @delay.prepare_to_enable: Time between prepare and enable.
*
* The minimum time, in milliseconds, that needs to have passed
* between when prepare finished and enable may begin. If at
* enable time less time has passed since prepare finished,
* the driver waits for the remaining time.
*
* If a fixed enable delay is also specified, we'll start
* counting before delaying for the fixed delay.
*
* If a fixed prepare delay is also specified, we won't start
* counting until after the fixed delay. We can't overlap this
* fixed delay with the min time because the fixed delay
* doesn't happen at the end of the function if a HPD GPIO was
* specified.
*
* In other words:
* prepare()
* ...
* // do fixed prepare delay
* // wait for HPD GPIO if applicable
* // start counting for prepare_to_enable
*
* enable()
* // do fixed enable delay
* // enforce prepare_to_enable min time
*/
unsigned int prepare_to_enable;
/** /**
* @delay.enable: Time for the panel to display a valid frame. * @delay.enable: Time for the panel to display a valid frame.
* *
...@@ -131,10 +161,10 @@ struct panel_desc { ...@@ -131,10 +161,10 @@ struct panel_desc {
struct panel_simple { struct panel_simple {
struct drm_panel base; struct drm_panel base;
bool prepared;
bool enabled; bool enabled;
bool no_hpd; bool no_hpd;
ktime_t prepared_time;
ktime_t unprepared_time; ktime_t unprepared_time;
const struct panel_desc *desc; const struct panel_desc *desc;
...@@ -297,14 +327,14 @@ static int panel_simple_unprepare(struct drm_panel *panel) ...@@ -297,14 +327,14 @@ static int panel_simple_unprepare(struct drm_panel *panel)
{ {
struct panel_simple *p = to_panel_simple(panel); struct panel_simple *p = to_panel_simple(panel);
if (!p->prepared) if (p->prepared_time == 0)
return 0; return 0;
gpiod_set_value_cansleep(p->enable_gpio, 0); gpiod_set_value_cansleep(p->enable_gpio, 0);
regulator_disable(p->supply); regulator_disable(p->supply);
p->prepared = false; p->prepared_time = 0;
p->unprepared_time = ktime_get(); p->unprepared_time = ktime_get();
return 0; return 0;
...@@ -342,7 +372,7 @@ static int panel_simple_prepare(struct drm_panel *panel) ...@@ -342,7 +372,7 @@ static int panel_simple_prepare(struct drm_panel *panel)
int err; int err;
int hpd_asserted; int hpd_asserted;
if (p->prepared) if (p->prepared_time != 0)
return 0; return 0;
panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare); panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare);
...@@ -381,7 +411,7 @@ static int panel_simple_prepare(struct drm_panel *panel) ...@@ -381,7 +411,7 @@ static int panel_simple_prepare(struct drm_panel *panel)
} }
} }
p->prepared = true; p->prepared_time = ktime_get();
return 0; return 0;
} }
...@@ -396,6 +426,8 @@ static int panel_simple_enable(struct drm_panel *panel) ...@@ -396,6 +426,8 @@ static int panel_simple_enable(struct drm_panel *panel)
if (p->desc->delay.enable) if (p->desc->delay.enable)
msleep(p->desc->delay.enable); msleep(p->desc->delay.enable);
panel_simple_wait(p->prepared_time, p->desc->delay.prepare_to_enable);
p->enabled = true; p->enabled = true;
return 0; return 0;
...@@ -562,7 +594,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) ...@@ -562,7 +594,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
return -ENOMEM; return -ENOMEM;
panel->enabled = false; panel->enabled = false;
panel->prepared = false; panel->prepared_time = 0;
panel->desc = desc; panel->desc = desc;
panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
......
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