From: Sam Ravnborg <sam@ravnborg•org>
To: dri-devel@lists•freedesktop.org,
Thierry Reding <thierry.reding@gmail•com>,
Laurent Pinchart <laurent.pinchart@ideasonboard•com>
Cc: Neil Armstrong <narmstrong@baylibre•com>,
David Airlie <airlied@linux•ie>,
Linus Walleij <linus.walleij@linaro•org>,
Stefan Agner <stefan@agner•ch>,
Andrzej Hajda <a.hajda@samsung•com>,
Benjamin Gaignard <benjamin.gaignard@linaro•org>,
Sam Ravnborg <sam@ravnborg•org>,
Maxime Ripard <maxime.ripard@bootlin•com>,
linux-samsung-soc@vger•kernel.org,
linux-rockchip@lists•infradead.org,
Tomi Valkeinen <tomi.valkeinen@ti•com>,
Jagan Teki <jagan@amarulasolutions•com>,
NXP Linux Team <linux-imx@nxp•com>,
Jitao Shi <jitao.shi@mediatek•com>,
Pengutronix Kernel Team <kernel@pengutronix•de>,
Maarten Lankhorst <maarten.lankhorst@linux•intel.com>,
Maxime Ripard <mripard@kernel•org>,
linux-mediatek@lists•infradead.org,
Abhinav Kumar <abhinavk@codeaurora•org>,
linux-tegra@vger•kernel.org, Sean Paul <sean@poorly•run>,
linux-arm-kernel@lists•infradead.org,
Purism Kernel Team <kernel@puri•sm>,
linux-renesas-soc@vger•kernel.org,
Boris Brezillon <boris.brezillon@collabora•com>,
Daniel Vetter <daniel@ffwll•ch>
Subject: [PATCH v1 02/26] drm/panel: add backlight support
Date: Mon, 2 Dec 2019 20:32:06 +0100 [thread overview]
Message-ID: <20191202193230.21310-3-sam@ravnborg.org> (raw)
In-Reply-To: <20191202193230.21310-1-sam@ravnborg.org>
Panels often supports backlight as specified in a device tree.
Update the drm_panel infrastructure to support this to
simplify the drivers.
With this the panel driver just needs to add the following to the
probe() function:
err = drm_panel_of_backlight(panel);
if (err)
return err;
Then drm_panel will handle all the rest.
v2:
- Drop test of CONFIG_DRM_PANEL in header-file (Laurent)
- do not enable backlight if ->enable() returns an error
Signed-off-by: Sam Ravnborg <sam@ravnborg•org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux•intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin•com>
Cc: Sean Paul <sean@poorly•run>
Cc: Thierry Reding <thierry.reding@gmail•com>
Cc: Sam Ravnborg <sam@ravnborg•org>
Cc: David Airlie <airlied@linux•ie>
Cc: Daniel Vetter <daniel@ffwll•ch>
---
drivers/gpu/drm/drm_panel.c | 49 +++++++++++++++++++++++++++++++++++--
include/drm/drm_panel.h | 23 +++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index 2d59cdd05e50..35609c90e467 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/module.h>
@@ -196,13 +197,18 @@ EXPORT_SYMBOL(drm_panel_unprepare);
*/
int drm_panel_enable(struct drm_panel *panel)
{
+ int ret = 0;
+
if (!panel)
return -EINVAL;
if (panel->funcs && panel->funcs->enable)
- return panel->funcs->enable(panel);
+ ret = panel->funcs->enable(panel);
- return 0;
+ if (ret >= 0)
+ backlight_enable(panel->backlight);
+
+ return ret;
}
EXPORT_SYMBOL(drm_panel_enable);
@@ -221,6 +227,8 @@ int drm_panel_disable(struct drm_panel *panel)
if (!panel)
return -EINVAL;
+ backlight_disable(panel->backlight);
+
if (panel->funcs && panel->funcs->disable)
return panel->funcs->disable(panel);
@@ -289,6 +297,43 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np)
EXPORT_SYMBOL(of_drm_find_panel);
#endif
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
+/**
+ * drm_panel_of_backlight - use backlight device node for backlight
+ * @panel: DRM panel
+ *
+ * Use this function to enable backlight handling if your panel
+ * uses device tree and has a backlight handle.
+ *
+ * When panel is enabled backlight will be enabled after a
+ * successfull call to &drm_panel_funcs.enable()
+ *
+ * When panel is disabled backlight will be disabled before the
+ * call to &drm_panel_funcs.disable().
+ *
+ * A typical implementation for a panel driver supporting device tree
+ * will call this function and then backlight just works.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+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;
+}
+EXPORT_SYMBOL(drm_panel_of_backlight);
+#endif
+
MODULE_AUTHOR("Thierry Reding <treding@nvidia•com>");
MODULE_DESCRIPTION("DRM panel infrastructure");
MODULE_LICENSE("GPL and additional rights");
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index ce8da64022b4..d30c98567384 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -28,6 +28,7 @@
#include <linux/errno.h>
#include <linux/list.h>
+struct backlight_device;
struct device_node;
struct drm_connector;
struct drm_device;
@@ -59,6 +60,10 @@ struct display_timing;
*
* To save power when no video data is transmitted, a driver can power down
* the panel. This is the job of the .unprepare() function.
+ *
+ * Backlight can be handled automatically if configured using
+ * drm_panel_of_backlight(). Then the driver do not need to implement the
+ * functionality to enable/disable backlight.
*/
struct drm_panel_funcs {
/**
@@ -132,6 +137,15 @@ struct drm_panel {
*/
struct device *dev;
+ /**
+ * @backlight:
+ *
+ * Backlight device, used to turn on backlight after
+ * the call to enable(), and to turn off
+ * backlight before call to disable().
+ */
+ struct backlight_device *backlight;
+
/**
* @funcs:
*
@@ -183,4 +197,13 @@ static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
}
#endif
+#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
+int drm_panel_of_backlight(struct drm_panel *panel);
+#else
+static inline int drm_panel_of_backlight(struct drm_panel *panel)
+{
+ return -EINVAL;
+}
+#endif
+
#endif
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-12-02 19:33 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-02 19:32 [PATCH v1 0/26] drm/panel infrastructure + backlight update Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 01/26] drm/drm_panel: no error when no callback Sam Ravnborg
2019-12-03 6:24 ` Laurent Pinchart
2019-12-02 19:32 ` Sam Ravnborg [this message]
2019-12-03 6:32 ` [PATCH v1 02/26] drm/panel: add backlight support Laurent Pinchart
2019-12-02 19:32 ` [PATCH v1 03/26] drm/panel: simple: use drm_panel " Sam Ravnborg
2019-12-03 6:39 ` Laurent Pinchart
2019-12-02 19:32 ` [PATCH v1 04/26] drm: get drm_bridge_panel connector via helper Sam Ravnborg
2019-12-03 6:44 ` Laurent Pinchart
2019-12-03 13:22 ` Linus Walleij
2019-12-02 19:32 ` [PATCH v1 05/26] drm/panel: add drm_connector argument to get_modes() Sam Ravnborg
2019-12-03 6:50 ` Laurent Pinchart
2019-12-03 13:25 ` Linus Walleij
2019-12-04 12:08 ` Guido Günther
2019-12-04 13:11 ` Laurent Pinchart
2019-12-02 19:32 ` [PATCH v1 07/26] drm/panel: remove get_timings Sam Ravnborg
2019-12-03 7:02 ` Laurent Pinchart
2019-12-03 7:46 ` Maxime Ripard
2019-12-03 8:18 ` Laurent Pinchart
2019-12-03 8:39 ` Sam Ravnborg
2019-12-04 8:05 ` Maxime Ripard
2019-12-03 15:20 ` Linus Walleij
2019-12-04 8:16 ` Maxime Ripard
2019-12-04 8:23 ` Laurent Pinchart
2019-12-10 21:33 ` Linus Walleij
2019-12-02 19:32 ` [PATCH v1 08/26] drm/panel: drop drm_device from drm_panel Sam Ravnborg
2019-12-03 7:15 ` Laurent Pinchart
2019-12-03 13:27 ` Linus Walleij
2019-12-02 19:32 ` [PATCH v1 09/26] drm/panel: feiyang-fy07024di26a30d: use drm_panel backlight support Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 10/26] drm/panel: ilitek-ili9881c: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 11/26] drm/panel: innolux-p079zca: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 12/26] drm/panel: kingdisplay-kd097d04: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 13/26] drm/panel: lvds: " Sam Ravnborg
2019-12-03 7:16 ` Laurent Pinchart
2019-12-02 19:32 ` [PATCH v1 14/26] drm/panel: olimex-lcd-olinuxino: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 15/26] drm/panel: osd-osd101t2587-53ts: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 16/26] drm/panel: panasonic-vvx10f034n00: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 17/26] drm/panel: raydium-rm68200: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 18/26] drm/panel: rocktech-jh057n00900: " Sam Ravnborg
2019-12-04 12:04 ` Guido Günther
2019-12-02 19:32 ` [PATCH v1 19/26] drm/panel: ronbo-rb070d30: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 20/26] drm/panel: seiko-43wvf1g: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 21/26] drm/panel: sharp-lq101r1sx01: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 22/26] drm/panel: sharp-ls043t1le01: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 23/26] drm/panel: sitronix-st7701: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 24/26] drm/panel: sitronix-st7789v: " Sam Ravnborg
2019-12-02 19:32 ` [PATCH v1 25/26] drm/panel: tpo-td028ttec1: " Sam Ravnborg
2019-12-03 7:16 ` Laurent Pinchart
2019-12-02 19:32 ` [PATCH v1 26/26] drm/panel: tpo-tpg110: " Sam Ravnborg
2019-12-03 13:20 ` Linus Walleij
2019-12-02 19:59 ` [PATCH v1 0/26] drm/panel infrastructure + backlight update Jeffrey Hugo
2019-12-02 20:48 ` Sam Ravnborg
2019-12-02 20:51 ` Jeffrey Hugo
2019-12-03 7:24 ` Laurent Pinchart
2019-12-03 8:33 ` Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191202193230.21310-3-sam@ravnborg.org \
--to=sam@ravnborg$(echo .)org \
--cc=a.hajda@samsung$(echo .)com \
--cc=abhinavk@codeaurora$(echo .)org \
--cc=airlied@linux$(echo .)ie \
--cc=benjamin.gaignard@linaro$(echo .)org \
--cc=boris.brezillon@collabora$(echo .)com \
--cc=daniel@ffwll$(echo .)ch \
--cc=dri-devel@lists$(echo .)freedesktop.org \
--cc=jagan@amarulasolutions$(echo .)com \
--cc=jitao.shi@mediatek$(echo .)com \
--cc=kernel@pengutronix$(echo .)de \
--cc=kernel@puri$(echo .)sm \
--cc=laurent.pinchart@ideasonboard$(echo .)com \
--cc=linus.walleij@linaro$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-imx@nxp$(echo .)com \
--cc=linux-mediatek@lists$(echo .)infradead.org \
--cc=linux-renesas-soc@vger$(echo .)kernel.org \
--cc=linux-rockchip@lists$(echo .)infradead.org \
--cc=linux-samsung-soc@vger$(echo .)kernel.org \
--cc=linux-tegra@vger$(echo .)kernel.org \
--cc=maarten.lankhorst@linux$(echo .)intel.com \
--cc=maxime.ripard@bootlin$(echo .)com \
--cc=mripard@kernel$(echo .)org \
--cc=narmstrong@baylibre$(echo .)com \
--cc=sean@poorly$(echo .)run \
--cc=stefan@agner$(echo .)ch \
--cc=thierry.reding@gmail$(echo .)com \
--cc=tomi.valkeinen@ti$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox