Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Thierry Reding <thierry.reding@gmail.com>,
	Marek Vasut <marex@denx.de>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Vincent Abriou <vincent.abriou@st.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Kukjin Kim <kgene@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	NXP Linux Team <linux-imx@nxp.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Jonas Karlman <jonas@kwiboo.se>,
	Alison Wang <alison.wang@nxp.com>,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
	Alexios Zavras <alexios.zavras@intel.com>,
	linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>, Sean Paul <sean@poorly.run>,
	Allison Randal <allison@lohutok.net>
Subject: Re: [PATCH v1 15/16] drm/panel: add backlight support
Date: Mon, 5 Aug 2019 14:04:32 +0300	[thread overview]
Message-ID: <20190805110432.GJ29747@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190804201637.1240-16-sam@ravnborg.org>

Hi Sam,

Thank you for the patch.

On Sun, Aug 04, 2019 at 10:16:36PM +0200, Sam Ravnborg wrote:
> 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.

Do you have an example on how this will simplify drivers ? How many
existing panel drivers would benefit from this, and do you plan to
convert them ?

> 
> 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 | 41 +++++++++++++++++++++++++++++++++++++
>  include/drm/drm_panel.h     | 23 +++++++++++++++++++++
>  2 files changed, 64 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
> index 0853764040de..d8139674b883 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>
>  
> @@ -110,6 +111,7 @@ int drm_panel_enable(struct drm_panel *panel)
>  	if (ret >= 0)
>  		panel->enabled = true;
>  
> +	backlight_enable(panel->backlight);
>  	return ret;
>  }
>  EXPORT_SYMBOL(drm_panel_enable);
> @@ -134,6 +136,8 @@ int drm_panel_disable(struct drm_panel *panel)
>  	if (!panel->enabled)
>  		return 0;
>  
> +	backlight_disable(panel->backlight);
> +
>  	if (panel->funcs && panel->funcs->disable)
>  		ret = panel->funcs->disable(panel);
>  
> @@ -308,6 +312,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 7493500fc9bd..31349c2393b7 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 {
>  	/**
> @@ -139,6 +144,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:
>  	 *
> @@ -193,4 +207,13 @@ static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
>  }
>  #endif
>  
> +#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) && defined(CONFIG_DRM_PANEL)
> +int drm_panel_of_backlight(struct drm_panel *panel);

I would expect callers of this function to depend on (or select)
CONFIG_DRM_PANEL, so I would drop it from here.

> +#else
> +static inline int drm_panel_of_backlight(struct drm_panel *panel)
> +{
> +	return -EINVAL;

Maybe -ENOSYS ?

> +}
> +#endif
> +
>  #endif

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-08-05 11:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-04 20:16 [PATCH v1 0/16] drm: panel related updates Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 01/16] drm/bridge: tc358767: fix opencoded use of drm_panel_* Sam Ravnborg
2019-08-05  9:35   ` Philipp Zabel
2019-08-05 11:53     ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 02/16] drm/exynos: " Sam Ravnborg
2019-12-01 11:32   ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 03/16] " Sam Ravnborg
2019-12-01 11:32   ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 04/16] drm/imx: " Sam Ravnborg
2019-08-05  9:34   ` Philipp Zabel
2019-08-04 20:16 ` [PATCH v1 05/16] drm/fsl-dcu: " Sam Ravnborg
2019-08-05  9:16   ` Stefan Agner
2019-08-05 11:54     ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 06/16] drm/msm: " Sam Ravnborg
2019-12-01 11:33   ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 07/16] drm/mxsfb: " Sam Ravnborg
2019-08-05  9:20   ` Stefan Agner
2019-08-04 20:16 ` [PATCH v1 08/16] drm/sti: " Sam Ravnborg
2019-08-07 11:55   ` Benjamin Gaignard
2019-08-04 20:16 ` [PATCH v1 09/16] drm/tegra: " Sam Ravnborg
2019-12-01 11:33   ` Sam Ravnborg
2019-08-04 20:16 ` [PATCH v1 10/16] drm/panel: ili9322: move bus_flags to get_modes() Sam Ravnborg
2019-08-06 12:56   ` Linus Walleij
2019-08-04 20:16 ` [PATCH v1 11/16] drm/panel: move drm_panel functions to .c file Sam Ravnborg
2019-08-05 10:45   ` Laurent Pinchart
2019-08-04 20:16 ` [PATCH v1 12/16] drm/panel: use inline comments in drm_panel.h Sam Ravnborg
2019-08-05 10:54   ` Laurent Pinchart
2019-08-04 20:16 ` [PATCH v1 13/16] drm/panel: drop return code from drm_panel_detach() Sam Ravnborg
2019-08-05 10:56   ` Laurent Pinchart
2019-08-04 20:16 ` [PATCH v1 14/16] drm/panel: call prepare/enable only once Sam Ravnborg
2019-08-05 10:59   ` Laurent Pinchart
2019-08-05 13:15     ` Emil Velikov
2019-08-05 16:51     ` Sam Ravnborg
2019-12-02 15:22       ` Laurent Pinchart
2019-08-05 17:01   ` Sean Paul
2019-12-02 15:15     ` Laurent Pinchart
2019-08-04 20:16 ` [PATCH v1 15/16] drm/panel: add backlight support Sam Ravnborg
2019-08-05 11:04   ` Laurent Pinchart [this message]
2019-08-04 20:16 ` [PATCH v1 16/16] drm/panel: simple: use drm_panel infrastructure Sam Ravnborg
2019-08-05 11:12   ` Laurent Pinchart
2019-08-05 13:18 ` [PATCH v1 0/16] drm: panel related updates Emil Velikov

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=20190805110432.GJ29747@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=alexios.zavras@intel.com \
    --cc=alison.wang@nxp.com \
    --cc=allison@lohutok.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=jonas@kwiboo.se \
    --cc=jonathanh@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=maxime.ripard@bootlin.com \
    --cc=narmstrong@baylibre.com \
    --cc=sam@ravnborg.org \
    --cc=sean@poorly.run \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=vincent.abriou@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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