Message ID | 20220418101725.v3.2.Icea616f57331fbaa3d48c529f300c9a8ebd37fb5@changeid (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/dp: Introduce wait_hpd_asserted() for the DP AUX bus | expand |
On 18/04/2022 20:17, Douglas Anderson wrote: > Let's add support for being able to read the HPD pin even if it's > hooked directly to the controller. This will allow us to get more > accurate delays also lets us take away the waiting in the AUX transfer > functions of the eDP controller drivers. > > Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > > (no changes since v2) > > Changes in v2: > - Change is_hpd_asserted() to wait_hpd_asserted() > > drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- > 1 file changed, 23 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c > index 1732b4f56e38..086e0bf52fb9 100644 > --- a/drivers/gpu/drm/panel/panel-edp.c > +++ b/drivers/gpu/drm/panel/panel-edp.c > @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) > return 0; > } > > +static bool panel_edp_can_read_hpd(struct panel_edp *p) > +{ > + return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); > +} > + > static int panel_edp_prepare_once(struct panel_edp *p) > { > struct device *dev = p->base.dev; > @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) > if (delay) > msleep(delay); > > - if (p->hpd_gpio) { > + if (panel_edp_can_read_hpd(p)) { > if (p->desc->delay.hpd_absent) > hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; > else > hpd_wait_us = 2000000; > > - err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, > - hpd_asserted, hpd_asserted, > - 1000, hpd_wait_us); > - if (hpd_asserted < 0) > - err = hpd_asserted; > + if (p->hpd_gpio) { > + err = readx_poll_timeout(gpiod_get_value_cansleep, > + p->hpd_gpio, hpd_asserted, > + hpd_asserted, 1000, hpd_wait_us); > + if (hpd_asserted < 0) > + err = hpd_asserted; > + } else { > + err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); > + } I'm close to thinking that this construct deserves a separate helper. > > if (err) { > if (err != -ETIMEDOUT) > @@ -532,18 +541,22 @@ static int panel_edp_enable(struct drm_panel *panel) > /* > * If there is a "prepare_to_enable" delay then that's supposed to be > * the delay from HPD going high until we can turn the backlight on. > - * However, we can only count this if HPD is handled by the panel > - * driver, not if it goes to a dedicated pin on the controller. > + * However, we can only count this if HPD is readable by the panel > + * driver. > + * > * If we aren't handling the HPD pin ourselves then the best we > * can do is assume that HPD went high immediately before we were > - * called (and link training took zero time). > + * called (and link training took zero time). Note that "no-hpd" > + * actually counts as handling HPD ourselves since we're doing the > + * worst case delay (in prepare) ourselves. > * > * NOTE: if we ever end up in this "if" statement then we're > * guaranteed that the panel_edp_wait() call below will do no delay. > * It already handles that case, though, so we don't need any special > * code for it. > */ > - if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) > + if (p->desc->delay.prepare_to_enable && > + !panel_edp_can_read_hpd(p) && !p->no_hpd) > delay = max(delay, p->desc->delay.prepare_to_enable); > > if (delay)
Hi, On Thu, Jun 2, 2022 at 8:12 AM Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote: > > On 18/04/2022 20:17, Douglas Anderson wrote: > > Let's add support for being able to read the HPD pin even if it's > > hooked directly to the controller. This will allow us to get more > > accurate delays also lets us take away the waiting in the AUX transfer > > functions of the eDP controller drivers. > > > > Signed-off-by: Douglas Anderson <dianders@chromium.org> > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > --- > > > > (no changes since v2) > > > > Changes in v2: > > - Change is_hpd_asserted() to wait_hpd_asserted() > > > > drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- > > 1 file changed, 23 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c > > index 1732b4f56e38..086e0bf52fb9 100644 > > --- a/drivers/gpu/drm/panel/panel-edp.c > > +++ b/drivers/gpu/drm/panel/panel-edp.c > > @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) > > return 0; > > } > > > > +static bool panel_edp_can_read_hpd(struct panel_edp *p) > > +{ > > + return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); > > +} > > + > > static int panel_edp_prepare_once(struct panel_edp *p) > > { > > struct device *dev = p->base.dev; > > @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) > > if (delay) > > msleep(delay); > > > > - if (p->hpd_gpio) { > > + if (panel_edp_can_read_hpd(p)) { > > if (p->desc->delay.hpd_absent) > > hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; > > else > > hpd_wait_us = 2000000; > > > > - err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, > > - hpd_asserted, hpd_asserted, > > - 1000, hpd_wait_us); > > - if (hpd_asserted < 0) > > - err = hpd_asserted; > > + if (p->hpd_gpio) { > > + err = readx_poll_timeout(gpiod_get_value_cansleep, > > + p->hpd_gpio, hpd_asserted, > > + hpd_asserted, 1000, hpd_wait_us); > > + if (hpd_asserted < 0) > > + err = hpd_asserted; > > + } else { > > + err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); > > + } > > I'm close to thinking that this construct deserves a separate helper. Just to close the loop: I didn't try to create a helper for v5. I'm not completely convinced that this will be common. I would tend to expect that having HPD handled by a GPIO is somewhat rare. It's also fairly rare to have a panel that's not handled by the generic panel-edp. We ended up with the GPIO on trogdor because of the weird debouncing on sn85dsi86 and we ended up with one case of not using edp-panel on trogdor because of the weird power sequencing of the Samsung OLED panel that's on homestar. I'd also note that the generic eDP panel has a special case for "timeout" which we don't have on the Samsung panel to handle at least one panel I found that sometimes simply didn't come up but then _would_ come up on a retry... That doesn't mean we couldn't abstract it out later, of course. ;-) -Doug -Doug
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 1732b4f56e38..086e0bf52fb9 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) return 0; } +static bool panel_edp_can_read_hpd(struct panel_edp *p) +{ + return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); +} + static int panel_edp_prepare_once(struct panel_edp *p) { struct device *dev = p->base.dev; @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay); - if (p->hpd_gpio) { + if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us = 2000000; - err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, hpd_wait_us); - if (hpd_asserted < 0) - err = hpd_asserted; + if (p->hpd_gpio) { + err = readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, hpd_wait_us); + if (hpd_asserted < 0) + err = hpd_asserted; + } else { + err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); + } if (err) { if (err != -ETIMEDOUT) @@ -532,18 +541,22 @@ static int panel_edp_enable(struct drm_panel *panel) /* * If there is a "prepare_to_enable" delay then that's supposed to be * the delay from HPD going high until we can turn the backlight on. - * However, we can only count this if HPD is handled by the panel - * driver, not if it goes to a dedicated pin on the controller. + * However, we can only count this if HPD is readable by the panel + * driver. + * * If we aren't handling the HPD pin ourselves then the best we * can do is assume that HPD went high immediately before we were - * called (and link training took zero time). + * called (and link training took zero time). Note that "no-hpd" + * actually counts as handling HPD ourselves since we're doing the + * worst case delay (in prepare) ourselves. * * NOTE: if we ever end up in this "if" statement then we're * guaranteed that the panel_edp_wait() call below will do no delay. * It already handles that case, though, so we don't need any special * code for it. */ - if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) + if (p->desc->delay.prepare_to_enable && + !panel_edp_can_read_hpd(p) && !p->no_hpd) delay = max(delay, p->desc->delay.prepare_to_enable); if (delay)
Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will allow us to get more accurate delays also lets us take away the waiting in the AUX transfer functions of the eDP controller drivers. Signed-off-by: Douglas Anderson <dianders@chromium.org> --- (no changes since v2) Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)