AMD-GFX Archive on lore.kernel.org
 help / color / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: dri-devel@lists.freedesktop.org,
	Jingoo Han <jingoohan1@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Daniel Thompson <daniel.thompson@linaro.org>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Christian König" <christian.koenig@amd.com>,
	amd-gfx@lists.freedesktop.org
Subject: [PATCH v1 18/22] drm/radeon: Backlight update
Date: Sun,  2 Aug 2020 13:06:32 +0200
Message-ID: <20200802110636.1018743-19-sam@ravnborg.org> (raw)
In-Reply-To: <20200802110636.1018743-1-sam@ravnborg.org>

- Use macros for initialization
- Replace direct access to backlight_properties with get and set
  operations

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
 drivers/gpu/drm/radeon/atombios_encoders.c    | 23 ++++++++++---------
 .../gpu/drm/radeon/radeon_legacy_encoders.c   | 15 ++++++------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index cc5ee1b3af84..c9431af12fed 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -145,14 +145,15 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
 static u8 radeon_atom_bl_level(struct backlight_device *bd)
 {
 	u8 level;
+	int brightness = backlight_get_brightness(bd);
 
 	/* Convert brightness to hardware level */
-	if (bd->props.brightness < 0)
+	if (brightness < 0)
 		level = 0;
-	else if (bd->props.brightness > RADEON_MAX_BL_LEVEL)
+	else if (brightness > RADEON_MAX_BL_LEVEL)
 		level = RADEON_MAX_BL_LEVEL;
 	else
-		level = bd->props.brightness;
+		level = brightness;
 
 	return level;
 }
@@ -185,12 +186,13 @@ static const struct backlight_ops radeon_atom_backlight_ops = {
 void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
 				struct drm_connector *drm_connector)
 {
+	DECLARE_BACKLIGHT_INIT_RAW(props, 0, RADEON_MAX_BL_LEVEL);
 	struct drm_device *dev = radeon_encoder->base.dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct backlight_device *bd;
-	struct backlight_properties props;
 	struct radeon_backlight_privdata *pdata;
 	struct radeon_encoder_atom_dig *dig;
+	int brightness;
 	char bl_name[16];
 
 	/* Mac laptops with multiple GPUs use the gmux driver for backlight
@@ -215,9 +217,6 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
 		goto error;
 	}
 
-	memset(&props, 0, sizeof(props));
-	props.max_brightness = RADEON_MAX_BL_LEVEL;
-	props.type = BACKLIGHT_RAW;
 	snprintf(bl_name, sizeof(bl_name),
 		 "radeon_bl%d", dev->primary->index);
 	bd = backlight_device_register(bl_name, drm_connector->kdev,
@@ -232,15 +231,17 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
 	dig = radeon_encoder->enc_priv;
 	dig->bl_dev = bd;
 
-	bd->props.brightness = radeon_atom_backlight_get_brightness(bd);
+	brightness = radeon_atom_backlight_get_brightness(bd);
 	/* Set a reasonable default here if the level is 0 otherwise
 	 * fbdev will attempt to turn the backlight on after console
 	 * unblanking and it will try and restore 0 which turns the backlight
 	 * off again.
 	 */
-	if (bd->props.brightness == 0)
-		bd->props.brightness = RADEON_MAX_BL_LEVEL;
-	bd->props.power = FB_BLANK_UNBLANK;
+
+	if (brightness == 0)
+		brightness = RADEON_MAX_BL_LEVEL;
+	backlight_set_brightness(bd, brightness);
+	backlight_set_power_on(bd);
 	backlight_update_status(bd);
 
 	DRM_INFO("radeon atom DIG backlight initialized\n");
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 44d060f75318..cf2d1776b975 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -323,14 +323,15 @@ static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd)
 {
 	struct radeon_backlight_privdata *pdata = bl_get_data(bd);
 	uint8_t level;
+	int brightness = backlight_get_brightness(bd);
 
 	/* Convert brightness to hardware level */
-	if (bd->props.brightness < 0)
+	if (brightness < 0)
 		level = 0;
-	else if (bd->props.brightness > RADEON_MAX_BL_LEVEL)
+	else if (brightness > RADEON_MAX_BL_LEVEL)
 		level = RADEON_MAX_BL_LEVEL;
 	else
-		level = bd->props.brightness;
+		level = brightness;
 
 	if (pdata->negative)
 		level = RADEON_MAX_BL_LEVEL - level;
@@ -371,6 +372,7 @@ static const struct backlight_ops radeon_backlight_ops = {
 void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
 				  struct drm_connector *drm_connector)
 {
+	DECLARE_BACKLIGHT_INIT_RAW(props, 0, RADEON_MAX_BL_LEVEL);
 	struct drm_device *dev = radeon_encoder->base.dev;
 	struct radeon_device *rdev = dev->dev_private;
 	struct backlight_device *bd;
@@ -394,9 +396,6 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
 		goto error;
 	}
 
-	memset(&props, 0, sizeof(props));
-	props.max_brightness = RADEON_MAX_BL_LEVEL;
-	props.type = BACKLIGHT_RAW;
 	snprintf(bl_name, sizeof(bl_name),
 		 "radeon_bl%d", dev->primary->index);
 	bd = backlight_device_register(bl_name, drm_connector->kdev,
@@ -443,8 +442,8 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
 		lvds->bl_dev = bd;
 	}
 
-	bd->props.brightness = radeon_legacy_backlight_get_brightness(bd);
-	bd->props.power = FB_BLANK_UNBLANK;
+	backlight_set_brightness(bd, radeon_legacy_backlight_get_brightness(bd));
+	backlight_set_power_on(bd);
 	backlight_update_status(bd);
 
 	DRM_INFO("radeon legacy LVDS backlight initialized\n");
-- 
2.25.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply index

Thread overview: 4+ 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 ` Sam Ravnborg [this message]
2020-08-02 11:06 ` [PATCH v1 19/22] drm/amdgpu/atom: Backlight update 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=20200802110636.1018743-19-sam@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@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

AMD-GFX Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/amd-gfx/0 amd-gfx/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 amd-gfx amd-gfx/ https://lore.kernel.org/amd-gfx \
		amd-gfx@lists.freedesktop.org
	public-inbox-index amd-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.amd-gfx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git