mbox series

[RFC,v1,0/22] backlight: add init macros and accessors

Message ID 20200802110636.1018743-1-sam@ravnborg.org (mailing list archive)
Headers show
Series backlight: add init macros and accessors | expand

Message

Sam Ravnborg Aug. 2, 2020, 11:06 a.m. UTC
The backlight drivers uses several different patterns when registering
a backlight:

- Register backlight and assign properties later
- Define a local backlight_properties variable and use memset
- Define a const backlight_properties and assign relevant properties

On top of this there was differences in what members was assigned in
backlight_properties.

To align how backlight drivers are initialized introduce following helper macros:
- DECLARE_BACKLIGHT_INIT_FIRMWARE()
- DECLARE_BACKLIGHT_INIT_PLATFORM()
- DECLARE_BACKLIGHT_INIT_RAW()

The macros are introduced in patch 2.

The backlight drivers used direct access to backlight_properties.
Encapsulate these in get/set access operations resulting in following benefits:
- The drivers no longer need to be concerned about the confusing power states,
  as there is now only a set_power_on() and set_power_off() operation.
- The access methods can be called with a NULL pointer so logic around the
  access can be made simpler.
- The code is in most cases more readable with the access operations.
- When everyone uses the access methods refactroring in the backlight core is simpler.

The get/set operations are introduced in patch 3.

The first patch trims backlight_update_status() so it can be called with a NULL
backlight_device. Then the called do not need to add this check just to avoid
a NULL reference.

The fourth patch introduce the new macros and get/set operations for the
gpio backlight driver, as an example.

The remaining patches updates most backlight users in drivers/gpu/drm/*
With this patch set applied then:
- Almost all references to FB_BLANK* are gone from drm/*
- All panel drivers uses devm_ variant for registering backlight
- Almost all direct references to backlight properties are gone

The drm/* patches are  used as examples how drivers can benefit from the
new macros and get/set operations.

Individual patches are only sent to the people listed in the patch + a few more.
Please check https://lore.kernel.org/dri-devel/ for the full series.

Feedback welcome!

	Sam

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Konrad Dybcio <konradybcio@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-renesas-soc@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Cc: Philippe CORNU <philippe.cornu@st.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Chiras <robert.chiras@nxp.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: Vinay Simha BN <simhavcs@gmail.com>
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Cc: Zheng Bin <zhengbin13@huawei.com>

Sam Ravnborg (22):
      backlight: Silently fail backlight_update_status() if no device
      backlight: Add DECLARE_* macro for device registration
      backlight: Add get/set operations for brightness/power properties
      backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW and get/setters
      drm/gma500: Backlight support
      drm/panel: asus-z00t-tm5p5-n35596: Backlight update
      drm/panel: jdi-lt070me05000: Backlight update
      drm/panel: novatek-nt35510: Backlight update
      drm/panel: orisetech-otm8009a: Backlight update
      drm/panel: raydium-rm67191: Backlight update
      drm/panel: samsung-s6e63m0: Backlight update
      drm/panel: samsung-s6e63j0x03: Backlight update
      drm/panel: samsung-s6e3ha2: Backlight update
      drm/panel: sony-acx424akp: Backlight update
      drm/panel: sony-acx565akm: Backlight update
      drm/bridge: parade-ps8622: Backlight update
      drm/tilcdc: Backlight update
      drm/radeon: Backlight update
      drm/amdgpu/atom: Backlight update
      drm/i915: Backlight update
      drm/omap: display: Backlight update
      drm/shmobile: Backlight update

 drivers/gpu/drm/amd/amdgpu/atombios_encoders.c     |  15 ++-
 drivers/gpu/drm/bridge/parade-ps8622.c             |  43 ++++----
 drivers/gpu/drm/gma500/backlight.c                 |  35 ++----
 drivers/gpu/drm/gma500/cdv_device.c                |  29 +++--
 drivers/gpu/drm/gma500/mdfld_device.c              |   9 +-
 drivers/gpu/drm/gma500/oaktrail_device.c           |  10 +-
 drivers/gpu/drm/gma500/opregion.c                  |   2 +-
 drivers/gpu/drm/gma500/psb_device.c                |  10 +-
 drivers/gpu/drm/gma500/psb_drv.c                   |   8 +-
 drivers/gpu/drm/i915/display/intel_panel.c         |  88 +++++++--------
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    |  35 ++----
 .../gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c   |  15 +--
 drivers/gpu/drm/panel/panel-jdi-lt070me05000.c     |  17 ++-
 drivers/gpu/drm/panel/panel-novatek-nt35510.c      |   9 +-
 drivers/gpu/drm/panel/panel-orisetech-otm8009a.c   |  14 +--
 drivers/gpu/drm/panel/panel-raydium-rm67191.c      |  11 +-
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c      |  68 ++++++------
 drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c   |  56 +++++-----
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c      |  25 ++---
 drivers/gpu/drm/panel/panel-sony-acx424akp.c       |  49 ++-------
 drivers/gpu/drm/panel/panel-sony-acx565akm.c       |  44 +++-----
 drivers/gpu/drm/radeon/atombios_encoders.c         |  23 ++--
 drivers/gpu/drm/radeon/radeon_legacy_encoders.c    |  15 ++-
 drivers/gpu/drm/shmobile/shmob_drm_backlight.c     |  20 ++--
 drivers/gpu/drm/tilcdc/tilcdc_panel.c              |  11 +-
 drivers/video/backlight/gpio_backlight.c           |  17 ++-
 include/linux/backlight.h                          | 120 +++++++++++++++++++++
 27 files changed, 377 insertions(+), 421 deletions(-)

Comments

Daniel Vetter Aug. 4, 2020, 4:51 p.m. UTC | #1
On Sun, Aug 02, 2020 at 01:06:14PM +0200, Sam Ravnborg wrote:
> The backlight drivers uses several different patterns when registering
> a backlight:
> 
> - Register backlight and assign properties later
> - Define a local backlight_properties variable and use memset
> - Define a const backlight_properties and assign relevant properties
> 
> On top of this there was differences in what members was assigned in
> backlight_properties.
> 
> To align how backlight drivers are initialized introduce following helper macros:
> - DECLARE_BACKLIGHT_INIT_FIRMWARE()
> - DECLARE_BACKLIGHT_INIT_PLATFORM()
> - DECLARE_BACKLIGHT_INIT_RAW()
> 
> The macros are introduced in patch 2.
> 
> The backlight drivers used direct access to backlight_properties.
> Encapsulate these in get/set access operations resulting in following benefits:
> - The drivers no longer need to be concerned about the confusing power states,
>   as there is now only a set_power_on() and set_power_off() operation.
> - The access methods can be called with a NULL pointer so logic around the
>   access can be made simpler.
> - The code is in most cases more readable with the access operations.
> - When everyone uses the access methods refactroring in the backlight core is simpler.
> 
> The get/set operations are introduced in patch 3.
> 
> The first patch trims backlight_update_status() so it can be called with a NULL
> backlight_device. Then the called do not need to add this check just to avoid
> a NULL reference.
> 
> The fourth patch introduce the new macros and get/set operations for the
> gpio backlight driver, as an example.
> 
> The remaining patches updates most backlight users in drivers/gpu/drm/*
> With this patch set applied then:
> - Almost all references to FB_BLANK* are gone from drm/*
> - All panel drivers uses devm_ variant for registering backlight
> - Almost all direct references to backlight properties are gone
> 
> The drm/* patches are  used as examples how drivers can benefit from the
> new macros and get/set operations.
> 
> Individual patches are only sent to the people listed in the patch + a few more.
> Please check https://lore.kernel.org/dri-devel/ for the full series.
> 
> Feedback welcome!

Since this needs backlight patches queued up outside of drm there's two
options:

- merge the backlight stuff through drm-misc (imo simplest, we have all
  the fbdev stuff in there too by now)
- shared topic branch merged in drm-misc and optionally backlight tree

Otherwise this is going to be a pain to merge.
-Daniel

> 
> 	Sam
> 
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Hoegeun Kwon <hoegeun.kwon@samsung.com>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Jernej Skrabec <jernej.skrabec@siol.net>
> Cc: Jingoo Han <jingoohan1@gmail.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Cc: Konrad Dybcio <konradybcio@gmail.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Manasi Navare <manasi.d.navare@intel.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
> Cc: Philippe CORNU <philippe.cornu@st.com>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Robert Chiras <robert.chiras@nxp.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
> Cc: Vinay Simha BN <simhavcs@gmail.com>
> Cc: Wambui Karuga <wambui.karugax@gmail.com>
> Cc: Zheng Bin <zhengbin13@huawei.com>
> 
> Sam Ravnborg (22):
>       backlight: Silently fail backlight_update_status() if no device
>       backlight: Add DECLARE_* macro for device registration
>       backlight: Add get/set operations for brightness/power properties
>       backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW and get/setters
>       drm/gma500: Backlight support
>       drm/panel: asus-z00t-tm5p5-n35596: Backlight update
>       drm/panel: jdi-lt070me05000: Backlight update
>       drm/panel: novatek-nt35510: Backlight update
>       drm/panel: orisetech-otm8009a: Backlight update
>       drm/panel: raydium-rm67191: Backlight update
>       drm/panel: samsung-s6e63m0: Backlight update
>       drm/panel: samsung-s6e63j0x03: Backlight update
>       drm/panel: samsung-s6e3ha2: Backlight update
>       drm/panel: sony-acx424akp: Backlight update
>       drm/panel: sony-acx565akm: Backlight update
>       drm/bridge: parade-ps8622: Backlight update
>       drm/tilcdc: Backlight update
>       drm/radeon: Backlight update
>       drm/amdgpu/atom: Backlight update
>       drm/i915: Backlight update
>       drm/omap: display: Backlight update
>       drm/shmobile: Backlight update
> 
>  drivers/gpu/drm/amd/amdgpu/atombios_encoders.c     |  15 ++-
>  drivers/gpu/drm/bridge/parade-ps8622.c             |  43 ++++----
>  drivers/gpu/drm/gma500/backlight.c                 |  35 ++----
>  drivers/gpu/drm/gma500/cdv_device.c                |  29 +++--
>  drivers/gpu/drm/gma500/mdfld_device.c              |   9 +-
>  drivers/gpu/drm/gma500/oaktrail_device.c           |  10 +-
>  drivers/gpu/drm/gma500/opregion.c                  |   2 +-
>  drivers/gpu/drm/gma500/psb_device.c                |  10 +-
>  drivers/gpu/drm/gma500/psb_drv.c                   |   8 +-
>  drivers/gpu/drm/i915/display/intel_panel.c         |  88 +++++++--------
>  drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c    |  35 ++----
>  .../gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c   |  15 +--
>  drivers/gpu/drm/panel/panel-jdi-lt070me05000.c     |  17 ++-
>  drivers/gpu/drm/panel/panel-novatek-nt35510.c      |   9 +-
>  drivers/gpu/drm/panel/panel-orisetech-otm8009a.c   |  14 +--
>  drivers/gpu/drm/panel/panel-raydium-rm67191.c      |  11 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c      |  68 ++++++------
>  drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c   |  56 +++++-----
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0.c      |  25 ++---
>  drivers/gpu/drm/panel/panel-sony-acx424akp.c       |  49 ++-------
>  drivers/gpu/drm/panel/panel-sony-acx565akm.c       |  44 +++-----
>  drivers/gpu/drm/radeon/atombios_encoders.c         |  23 ++--
>  drivers/gpu/drm/radeon/radeon_legacy_encoders.c    |  15 ++-
>  drivers/gpu/drm/shmobile/shmob_drm_backlight.c     |  20 ++--
>  drivers/gpu/drm/tilcdc/tilcdc_panel.c              |  11 +-
>  drivers/video/backlight/gpio_backlight.c           |  17 ++-
>  include/linux/backlight.h                          | 120 +++++++++++++++++++++
>  27 files changed, 377 insertions(+), 421 deletions(-)
> 
>