dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: daniel@ffwll.ch
Cc: Jingoo Han <jingoohan1@gmail.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Lee Jones <lee.jones@linaro.org>,
	dri-devel@lists.freedesktop.org,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH v1 03/22] backlight: Add get/set operations for brightness/power properties
Date: Tue, 4 Aug 2020 21:56:00 +0200	[thread overview]
Message-ID: <20200804195600.GA686651@ravnborg.org> (raw)
In-Reply-To: <20200804164330.GL6419@phenom.ffwll.local>

Hi Daniel et al.
On Tue, Aug 04, 2020 at 06:43:30PM +0200, daniel@ffwll.ch wrote:
> On Sun, Aug 02, 2020 at 01:06:17PM +0200, Sam Ravnborg wrote:
> > Add get and set operations to incapsualte access to backlight properties.
> > 
> > One easy win is that the get/set operatiosn can be used when backlight
> > is not included in the configuration, resulting in simpler code with
> > less ifdef's and thus more readable code.
> > 
> > The set/get methods hides some of the confusing power states, limiting
> > the power state to either ON or OFF for the drivers.
> > 
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Cc: Daniel Thompson <daniel.thompson@linaro.org>
> > Cc: Jingoo Han <jingoohan1@gmail.com>
> > ---
> >  include/linux/backlight.h | 72 +++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 72 insertions(+)
> > 
> > diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> > index d683c053ec09..882ceea45ace 100644
> > --- a/include/linux/backlight.h
> > +++ b/include/linux/backlight.h
> > @@ -474,6 +474,78 @@ static inline int backlight_get_brightness(const struct backlight_device *bd)
> >  		return bd->props.brightness;
> >  }
> >  
> > +/**
> > + * backlight_get_actual_brightness - Returns the actual brightness
> > + *
> > + * On failure a negative error code is returned.
> > + */
> > +static inline int backlight_get_actual_brightness(struct backlight_device *bd)
> > +{
> > +	if (bd && bd->ops && bd->ops->get_brightness)
> > +		return bd->ops->get_brightness(bd);
> > +	else
> > +		return -EINVAL;
> > +}
> > +
> > +/**
> > + * backlight_get_max_brightness - Returns maximum brightness
> > + *
> > + * This helper operation is preferred over direct access to
> > + * &backlight_properties.max_brightness
> > + *
> > + * Returns 0 if backlight_device is NULL
> > + */
> > +
> > +static inline int backlight_get_max_brightness(const struct backlight_device *bd)
> > +{
> > +	if (bd)
> > +		return bd->props.max_brightness;
> > +	else
> > +		return 0;
> > +}
> > +
> > +/**
> > + * backlight_set_brightness - Set the brightness to the specified value
> > + *
> > + * This helper operation is preferred over direct assignment to
> > + * &backlight_properties.brightness.
> > + *
> > + * If backlight_device is NULL then silently exit.
> > + */
> > +static inline void backlight_set_brightness(struct backlight_device *bd, int brightness)
> > +{
> > +	if (bd)
> > +		bd->props.brightness = brightness;
> 
> Looking at the drivers I think including a call to backlight_update_status
> would simplify a lot of code.
> 
> > +}
> > +
> > +/**
> > + * backlight_set_power_on - Set power state to ON.
> > + *
> > + * This helper operation is preferred over direct assignment to
> > + * backlight_properties.power.
> > + *
> > + * If backlight_device is NULL then silently exit.
> > + */
> > +static inline void backlight_set_power_on(struct backlight_device *bd)
> > +{
> > +	if (bd)
> > +		bd->props.power = FB_BLANK_UNBLANK;
> > +}
> > +
> > +/**
> > + * backlight_set_power_off - Set power state to OFF.
> > + *
> > + * This helper operation is preferred over direct assignment to
> > + * backlight_properties.power.
> > + *
> > + * If backlight_device is NULL then silently exit.
> > + */
> > +static inline void backlight_set_power_off(struct backlight_device *bd)
> 
> I'm not clear why we need these two above? I thought the long-term plan is
> only use backlight_enable/disable and then remove the tri-state power
> handling once everyone is converted over?
> 
> Or maybe I'm just confused about the goal here ...

My TODO for v2:
- Check all get_brightness implmentations.
  Using backlight_get_brightness is wrong - find a better way
  Check that they do return the actual brightness and not just the copy
  from the backlight core
- Get rid of all uses of power_on/off - this is just another way to
  disable backlight - so be explicit about it
- Consolidate the backlight_set_brightness(); backlight_update() pattern
  to a helper
- Look into a mipi helper for backlight
- Consider if we can change the backlight core to use an u32 for
  brightness
- Take a look at Daniels rambling about drm_connector and backlight
- Convert some platform backlight drivers to updated interface - to verify
  that they do not add new demends

The above should address feedback from Daniel etc. Thanks!
No promises when I get time to do it - this list was mostly
to help myself so I did not forget.

Note: My ISP blocked my attempt to reply to PATCH 0 - so I replied to
this with the TODO list.

        Sam


> -Daniel
> 
> > +{
> > +	if (bd)
> > +		bd->props.power = FB_BLANK_POWERDOWN;
> > +}
> > +
> >  struct backlight_device *
> >  backlight_device_register(const char *name, struct device *dev, void *devdata,
> >  			  const struct backlight_ops *ops,
> > -- 
> > 2.25.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-08-04 19:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 11:06 [RFC PATCH v1 0/22] backlight: add init macros and accessors Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 01/22] backlight: Silently fail backlight_update_status() if no device Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 02/22] backlight: Add DECLARE_* macro for device registration Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 03/22] backlight: Add get/set operations for brightness/power properties Sam Ravnborg
2020-08-04 16:43   ` daniel
2020-08-04 19:56     ` Sam Ravnborg [this message]
2020-08-05  7:16       ` daniel
2020-08-02 11:06 ` [PATCH v1 04/22] backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW and get/setters Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 05/22] drm/gma500: Backlight support Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 06/22] drm/panel: asus-z00t-tm5p5-n35596: Backlight update Sam Ravnborg
2020-08-04 16:59   ` daniel
2020-08-02 11:06 ` [PATCH v1 07/22] drm/panel: jdi-lt070me05000: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 08/22] drm/panel: novatek-nt35510: " Sam Ravnborg
2020-08-04 21:29   ` Linus Walleij
2020-08-02 11:06 ` [PATCH v1 09/22] drm/panel: orisetech-otm8009a: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 10/22] drm/panel: raydium-rm67191: " Sam Ravnborg
2020-08-04 17:04   ` daniel
2020-08-02 11:06 ` [PATCH v1 11/22] drm/panel: samsung-s6e63m0: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 12/22] drm/panel: samsung-s6e63j0x03: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 13/22] drm/panel: samsung-s6e3ha2: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 14/22] drm/panel: sony-acx424akp: " Sam Ravnborg
2020-08-04 21:31   ` Linus Walleij
2020-08-02 11:06 ` [PATCH v1 15/22] drm/panel: sony-acx565akm: " Sam Ravnborg
2020-08-04 17:09   ` daniel
2020-08-02 11:06 ` [PATCH v1 16/22] drm/bridge: parade-ps8622: " Sam Ravnborg
2020-08-02 14:05   ` kernel test robot
2020-08-02 14:32   ` Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 17/22] drm/tilcdc: " Sam Ravnborg
2020-08-02 13:21   ` kernel test robot
2020-08-02 11:06 ` [PATCH v1 18/22] drm/radeon: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 19/22] drm/amdgpu/atom: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 20/22] drm/i915: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 21/22] drm/omap: display: " Sam Ravnborg
2020-08-02 14:26   ` Sebastian Reichel
2020-08-02 14:32     ` Sam Ravnborg
2020-08-02 22:48       ` Sebastian Reichel
2020-08-02 11:06 ` [PATCH v1 22/22] drm/shmobile: " Sam Ravnborg
2020-08-04 16:51 ` [RFC PATCH v1 0/22] backlight: add init macros and accessors daniel

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=20200804195600.GA686651@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee.jones@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).