mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] amdgpu: add a filter condition when set brightness
@ 2023-02-27  7:39 Yuanzhi Wang
  2023-02-27 10:12 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yuanzhi Wang @ 2023-02-27  7:39 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel,
	mario.limonciello, Bokun.Zhang, tzimmermann, hdegoede,
	jingyuwang_vip, rafael.j.wysocki, amd-gfx, dri-devel,
	linux-kernel
  Cc: Yuanzhi Wang

When the laptop is plugged into AC or DC power supply,
the brightness obtained ACPI may be smaller than current
brightness.As a result the screen becomes dark,this is
not what people want.

Signed-off-by: Yuanzhi Wang <wangyuanzhi@uniontech.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index d4196fcb85a0..93f1567028c5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -406,6 +406,7 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
 {
 	struct amdgpu_atif *atif = &amdgpu_acpi_priv.atif;
 	int count;
+	int old_brightness;
 
 	DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
 			event->device_class, event->type);
@@ -443,7 +444,13 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
 				 * hardwired to post BACKLIGHT_UPDATE_SYSFS.
 				 * It probably should accept 'reason' parameter.
 				 */
-				backlight_device_set_brightness(atif->bd, req.backlight_level);
+				old_brightness = backlight_get_brightness(atif->bd);
+				if (old_brightness > req.backlight_level)
+					DRM_WARN("old brightness %d is greater than ACPI brightness
+						%d\n", old_brightness, req.backlight_level);
+				else
+					backlight_device_set_brightness(atif->bd,
+						req.backlight_level);
 			}
 		}
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-28  3:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27  7:39 [PATCH] amdgpu: add a filter condition when set brightness Yuanzhi Wang
2023-02-27 10:12 ` kernel test robot
2023-02-27 12:18 ` kernel test robot
2023-02-27 13:44 ` kernel test robot
2023-02-27 14:20 ` Mario Limonciello
2023-02-28  3:50   ` wangyuanzhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®