[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201208044446.973238-1-bjorn.andersson@linaro.org>
Date: Mon, 7 Dec 2020 22:44:46 -0600
From: Bjorn Andersson <bjorn.andersson@...aro.org>
To: Thierry Reding <thierry.reding@...il.com>,
Sam Ravnborg <sam@...nborg.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH] drm/panel: Make backlight attachment lazy
Some bridge chips, such as the TI SN65DSI86 DSI/eDP bridge, provides
means of generating a PWM signal for backlight control of the attached
panel. The provided PWM chip is typically controlled by the
pwm-backlight driver, which if tied to the panel will provide DPMS.
But with the current implementation the panel will refuse to probe
because the bridge driver has yet to probe and register the PWM chip,
and the bridge driver will refuse to probe because it's unable to find
the panel.
Mitigate this catch-22 situation by allowing the panel driver to probe
and retry the attachment of the backlight as the panel is turned on or
off.
Signed-off-by: Bjorn Andersson <bjorn.andersson@...aro.org>
---
drivers/gpu/drm/drm_panel.c | 47 +++++++++++++++++++++++++++----------
include/drm/drm_panel.h | 8 +++++++
2 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index f634371c717a..7487329bd22d 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -43,6 +43,34 @@ static LIST_HEAD(panel_list);
* take look at drm_panel_bridge_add() and devm_drm_panel_bridge_add().
*/
+#if IS_REACHABLE(CONFIG_BACKLIGHT_CLASS_DEVICE)
+static int drm_panel_of_backlight_lazy(struct drm_panel *panel)
+{
+ struct backlight_device *backlight;
+
+ if (!panel || !panel->dev)
+ return -EINVAL;
+
+ backlight = devm_of_find_backlight(panel->dev);
+
+ if (IS_ERR(backlight)) {
+ if (PTR_ERR(backlight) == -EPROBE_DEFER) {
+ panel->backlight_init_pending = true;
+ return 0;
+ }
+
+ return PTR_ERR(backlight);
+ }
+
+ panel->backlight = backlight;
+ panel->backlight_init_pending = false;
+
+ return 0;
+}
+#else
+static int drm_panel_of_backlight_lazy(struct drm_panel *panel) { return 0; }
+#endif
+
/**
* drm_panel_init - initialize a panel
* @panel: DRM panel
@@ -161,6 +189,9 @@ int drm_panel_enable(struct drm_panel *panel)
return ret;
}
+ if (panel->backlight_init_pending)
+ drm_panel_of_backlight_lazy(panel);
+
ret = backlight_enable(panel->backlight);
if (ret < 0)
DRM_DEV_INFO(panel->dev, "failed to enable backlight: %d\n",
@@ -187,6 +218,9 @@ int drm_panel_disable(struct drm_panel *panel)
if (!panel)
return -EINVAL;
+ if (panel->backlight_init_pending)
+ drm_panel_of_backlight_lazy(panel);
+
ret = backlight_disable(panel->backlight);
if (ret < 0)
DRM_DEV_INFO(panel->dev, "failed to disable backlight: %d\n",
@@ -328,18 +362,7 @@ EXPORT_SYMBOL(of_drm_get_panel_orientation);
*/
int drm_panel_of_backlight(struct drm_panel *panel)
{
- struct backlight_device *backlight;
-
- if (!panel || !panel->dev)
- return -EINVAL;
-
- backlight = devm_of_find_backlight(panel->dev);
-
- if (IS_ERR(backlight))
- return PTR_ERR(backlight);
-
- panel->backlight = backlight;
- return 0;
+ return drm_panel_of_backlight_lazy(panel);
}
EXPORT_SYMBOL(drm_panel_of_backlight);
#endif
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 33605c3f0eba..b126abebb2f3 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -149,6 +149,14 @@ struct drm_panel {
*/
struct backlight_device *backlight;
+ /**
+ * @backlight_init_pending
+ *
+ * Backlight driver is not yet available so further attempts to
+ * initialize @backlight is necessary.
+ */
+ bool backlight_init_pending;
+
/**
* @funcs:
*
--
2.29.2
Powered by blists - more mailing lists