Skip to contentSkip to conversation

No backlight since linux-4.2.4 - drivers/gpu/drm/radeon/atombios_encoders.c

DISCUSSION Michel Dänzer 3 participants 14 messages Oct 26, 2015 – Oct 29, 2015 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 31 lines · Michael Burian

hi,

after updating the kernel from linux-stable[0] v4.2.3 to v4.2.4 on my hp compaq nx9420 laptop (Debian Jessie, amd64), the backlight is turned off within the first couple of seconds during boot.

The situation persists (Xorg seems to be running fine, icons can be recognized by illuminating the screen with a flashlight) until reboot using an earlier kernel.

current mainline[1] as of now (4.3.0-rc6-00277-g01815536) is also affected

Workaround: use earlier kernel (v4.2.3) or (see below)

Hardware:

lspci | grep adeo
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV530/M56-P [Mobility Radeon X1600]

git bisect log
# bad: [190bd21bba09ed476d9359d3e8be20e8d9dcd8a4] Linux 4.2.4
# good: [fcba09f2b0bf27eeaa1d4d439edb649585f35040] Linux 4.2.3
git bisect start 'v4.2.4' 'v4.2.3' 'drivers/gpu/'
# good: [885838eef785ff810dac945be8132856f2113cf1] drm/amdgpu: make UVD handle checking more strict git bisect good 885838eef785ff810dac945be8132856f2113cf1
# good: [230f6fd628c83fcb44ea364d69a9ad88826ef8c4] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully git bisect good 230f6fd628c83fcb44ea364d69a9ad88826ef8c4
# bad: [5a633828b4b2bef343826afcb0a70770c4911c55] drm/radeon: Restore LCD backlight level on resume (>= R5xx) git bisect bad 5a633828b4b2bef343826afcb0a70770c4911c55
# good: [60a09aef456ef590762d47da9c25650e230e2f85] drm: Reject DRI1 hw lock ioctl functions for kms drivers git bisect good 60a09aef456ef590762d47da9c25650e230e2f85

Quoted 6 lines
# first bad commit: [5a633828b4b2bef343826afcb0a70770c4911c55] drm/radeon: Restore LCD backlight level on resume (>= R5xx)

Workaround 2:

reverting this single commit 5a633828b4b2bef343826afcb0a70770c4911c55 fixes the problem in linux-stable[0] as well as mainline[1] 4.3.0-rc6-00277-g01815536

Please provide the dmesg output from running with the attached debugging patch.

Alex, any other ideas what might go wrong?

Signature · 2 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
drivers/gpu/drm/radeon/atombios_encoders.c +8 -3
index 65adb9c..31be81e 100644
@@ -77,9 +77,12 @@ atombios_get_backlight_level(struct radeon_encoder *radeon_encoder)
 	struct drm_device *dev = radeon_encoder->base.dev;
 	struct radeon_device *rdev = dev->dev_private;
 
-	if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
+	if (WARN_ON(!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)))
 		return 0;
 
+	DRM_INFO("Backlight controlled by GPU, current level %u\n",
+		 radeon_atom_get_backlight_level_from_reg(rdev));
+
 	return radeon_atom_get_backlight_level_from_reg(rdev);
 }
 
@@ -93,7 +96,7 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
 	DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args;
 	int index;
 
-	if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
+	if (WARN_ON(!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)))
 		return;
 
 	if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
@@ -105,6 +108,7 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
 		switch (radeon_encoder->encoder_id) {
 		case ENCODER_OBJECT_ID_INTERNAL_LVDS:
 		case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+			DRM_INFO("Setting LVDS backlight level to %u\n", level);
 			index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl);
 			if (dig->backlight_level == 0) {
 				args.ucAction = ATOM_LCD_BLOFF;
@@ -120,6 +124,7 @@ atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
 		case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
 		case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
 		case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
+			DRM_INFO("Setting UNIPHY backlight level to %u\n", level);
 			if (dig->backlight_level == 0)
 				atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_LCD_BLOFF, 0, 0);
 			else {
@@ -199,7 +204,7 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
 	if (!rdev->is_atom_bios)
 		return;
 
-	if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
+	if (WARN_ON(!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)))
 		return;
 
 	pdata = kmalloc(sizeof(struct radeon_backlight_privdata), GFP_KERNEL);

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 36 lines · Michel Dänzer
Quoted 35 lines · Michael Burian

hi,

after updating the kernel from linux-stable[0] v4.2.3 to v4.2.4 on my hp compaq nx9420 laptop (Debian Jessie, amd64), the backlight is turned off within the first couple of seconds during boot.

The situation persists (Xorg seems to be running fine, icons can be recognized by illuminating the screen with a flashlight) until reboot using an earlier kernel.

current mainline[1] as of now (4.3.0-rc6-00277-g01815536) is also affected

Workaround: use earlier kernel (v4.2.3) or (see below)

Hardware:

lspci | grep adeo
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV530/M56-P [Mobility Radeon X1600]

git bisect log
# bad: [190bd21bba09ed476d9359d3e8be20e8d9dcd8a4] Linux 4.2.4
# good: [fcba09f2b0bf27eeaa1d4d439edb649585f35040] Linux 4.2.3
git bisect start 'v4.2.4' 'v4.2.3' 'drivers/gpu/'
# good: [885838eef785ff810dac945be8132856f2113cf1] drm/amdgpu: make UVD handle checking more strict git bisect good 885838eef785ff810dac945be8132856f2113cf1
# good: [230f6fd628c83fcb44ea364d69a9ad88826ef8c4] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully git bisect good 230f6fd628c83fcb44ea364d69a9ad88826ef8c4
# bad: [5a633828b4b2bef343826afcb0a70770c4911c55] drm/radeon: Restore LCD backlight level on resume (>= R5xx) git bisect bad 5a633828b4b2bef343826afcb0a70770c4911c55
# good: [60a09aef456ef590762d47da9c25650e230e2f85] drm: Reject DRI1 hw lock ioctl functions for kms drivers git bisect good 60a09aef456ef590762d47da9c25650e230e2f85

# first bad commit: [5a633828b4b2bef343826afcb0a70770c4911c55] drm/radeon: Restore LCD backlight level on resume (>= R5xx)

Workaround 2:

Quoted 8 lines
Quoted 2 lines

reverting this single commit 5a633828b4b2bef343826afcb0a70770c4911c55 fixes the problem in linux-stable[0] as well as mainline[1] 4.3.0-rc6-00277-g01815536

Please provide the dmesg output from running with the attached debugging patch.

Alex, any other ideas what might go wrong?

Not off hand. Does the driver exposed backlight control work on your system? Backlight control in the r5xx days was mostly handled by platform specific ACPI methods or the standard ACPI backlight method under other OSes (depending on the OSI string).

Alex
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to a message not in the archive

Michael, please keep the Cc: list intact.

Quoted 7 lines · Michael Burian
Quoted 6 lines · Michel Dänzer
Quoted 5 lines · Michael Burian
# first bad commit: [5a633828b4b2bef343826afcb0a70770c4911c55] drm/radeon: Restore LCD backlight level on resume (>= R5xx)

Workaround 2:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

reverting this single commit 5a633828b4b2bef343826afcb0a70770c4911c55 fixes the problem in linux-stable[0] as well as mainline[1] 4.3.0-rc6-00277-g01815536

Please provide the dmesg output from running with the attached debugging patch.

[0] contains dmesg output with your patch applied (which fixes the backlight issue)

This is very surprising: The patch just adds some debugging output, it's not supposed to have any functional effect. Also, I don't see any of the debugging output added by the patch in dmesg-4.3.0-rc7-00003-g85051e2-dirty-2015-10-26-11-00-41-radeon-bl-debug.

Are you sure that my patch was actually applied to the radeon driver when generating that file? Did you update the initrd with the patched radeon.ko?

Quoted 10 lines

[1] contains dmesg output without your patch for comparison (resulting in a permanent black screen as before in rc6)

[0] dmesg-4.3.0-rc7-00003-g85051e2-dirty-2015-10-26-11-00-41-radeon-bl-debug

[1] dmesg-4.3.0-rc7-00003-g85051e2-2015-10-26-11-22-09

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
Quoted 9 lines · Michel Dänzer
Quoted 2 lines

[0] contains dmesg output with your patch applied (which fixes the backlight issue)

This is very surprising: The patch just adds some debugging output, it's not supposed to have any functional effect. Also, I don't see any of the debugging output added by the patch in dmesg-4.3.0-rc7-00003-g85051e2-dirty-2015-10-26-11-00-41-radeon-bl-debug.

Quoted 4 lines

Are you sure that my patch was actually applied to the radeon driver when generating that file? Did you update the initrd with the patched radeon.ko?

the build was done using "make -j4 deb-pkg" on a better equipped machine, .deb packages were copied over and installed - maybe something interesting happened

AFAICT the patch should have been applied, at least it was shown with git diff and the -dirty suffix was added by the build system, not me. All graphics related drivers are compiled in (=y) rather than as modules (=m) in .config.

Another thing I tried yesterday was to add the old way right below the new one (this fixes the backlight issue) enclosed by some debug statements that indicate start / stop of the old / new method. (see atomdebug.diff - should be applied against mainline)

radeon_start_backlight_new_way

Quoted 1 line
Quoted 1 line

execute D2AA (len 348, WS 4, PS 4)

SET_ATI_PORT @ 0xD2B0

      port: 0 (MM)
   COMPARE_PS @ 0xD2B3
      src1: 
PS[0x00,0xFFFF8802]
.[7:0] -> 0x02
      src2: 
IMM 0x04
      result: NE LE
   JUMP_EQUAL @ 0xD2B7
      taken: no
      target: 0x0128
   COMPARE_PS @ 0xD2BA
      src1: 
PS[0x00,0xFFFF8802]
.[7:0] -> 0x02
      src2: 
IMM 0x05
      result: NE LE
   JUMP_EQUAL @ 0xD2BE
      taken: no
      target: 0x0113
   COMPARE_PS @ 0xD2C1
      src1: 
PS[0x00,0xFFFF8802]
.[7:0] -> 0x02
      src2: 
IMM 0x00
      result: NE GT
   JUMP_EQUAL @ 0xD2C5
      taken: no
      target: 0x00D8
   COMPARE_PS @ 0xD2C8
      src1: 
PS[0x00,0xFFFF8802]
.[7:0] -> 0x02
      src2: 
IMM 0x01
      result: NE GT
   JUMP_NOT_EQUAL @ 0xD2CC
      taken: yes
      target: 0x013D
   COMPARE_PS @ 0xD3E7
      src1: 
PS[0x00,0xFFFF8802]
.[7:0] -> 0x02
      src2: 
IMM 0x03
      result: NE LE
   JUMP_NOT_EQUAL @ 0xD3EB
      taken: yes
      target: 0x0151

OR_REG @ 0xD3FB
dst:
REG[0x1EBC]
.[31:24] -> 0x00
src:
IMM 0x02
dst:
REG[0x1EBC]
.[31:24] <- 0x02
AND_REG @ 0xD400
dst:
REG[0x1EBC]
.[31:24] -> 0x02
src:
IMM 0xFE
dst:
REG[0x1EBC]
.[31:24] <- 0x02
EOT @ 0xD405
<< radeon_stop_backlight_new_wayradeon_start_backlight_old_way

radeon_stop_backlight_new_wayradeon_start_backlight_old_way

Quoted 1 line
Quoted 1 line

execute D2AA (len 348, WS 4, PS 4)

SET_ATI_PORT @ 0xD2B0

      port: 0 (MM)
   COMPARE_PS @ 0xD2B3
      src1: 
PS[0x00,0x0003]
.[7:0] -> 0x03
      src2: 
IMM 0x04
      result: NE LE
   JUMP_EQUAL @ 0xD2B7
      taken: no
      target: 0x0128
   COMPARE_PS @ 0xD2BA
      src1: 
PS[0x00,0x0003]
.[7:0] -> 0x03
      src2: 
IMM 0x05
      result: NE LE
   JUMP_EQUAL @ 0xD2BE
      taken: no
      target: 0x0113
   COMPARE_PS @ 0xD2C1
      src1: 
PS[0x00,0x0003]
.[7:0] -> 0x03
      src2: 
IMM 0x00
      result: NE GT
   JUMP_EQUAL @ 0xD2C5
      taken: no
      target: 0x00D8
   COMPARE_PS @ 0xD2C8
      src1: 
PS[0x00,0x0003]
.[7:0] -> 0x03
      src2: 
IMM 0x01
      result: NE GT
   JUMP_NOT_EQUAL @ 0xD2CC
      taken: yes
      target: 0x013D
   COMPARE_PS @ 0xD3E7
      src1: 
PS[0x00,0x0003]
.[7:0] -> 0x03
      src2: 
IMM 0x03
      result: EQ LE
   JUMP_NOT_EQUAL @ 0xD3EB
      taken: no
      target: 0x0151

OR_REG @ 0xD3EE
dst:
REG[0x1EBC]
.[31:24] -> 0x02
src:
IMM 0x02
dst:
REG[0x1EBC]
.[31:24] <- 0x02
OR_REG @ 0xD3F3
dst:
REG[0x1EBC]
.[31:24] -> 0x02
src:
IMM 0x01
dst:
REG[0x1EBC]
.[31:24] <- 0x03
JUMP @ 0xD3F8

      target: 0x015B

EOT @ 0xD405
<<
radeon_stop_backlight_old_way

drivers/gpu/drm/radeon/atom.c +1 -1
index ec1593a..a626bd6 100644
@@ -62,7 +62,7 @@ typedef struct {
 	bool abort;
 } atom_exec_context;
 
-int atom_debug = 0;
+int atom_debug = 1;
 static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
 int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);
 
drivers/gpu/drm/radeon/atombios_encoders.c +7 -1
index 65adb9c..c0d874f 100644
@@ -1624,9 +1624,15 @@ radeon_atom_encoder_dpms_avivo(struct drm_encoder *encoder, int mode)
 		} else
 			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+			printk("radeon_start_backlight_new_way");
 			struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
-
 			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			printk("radeon_stop_backlight_new_way");
+
+			printk("radeon_start_backlight_old_way");
+			args.ucAction = ATOM_LCD_BLON;
+			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+			printk("radeon_stop_backlight_old_way");
 		}
 		break;
 	case DRM_MODE_DPMS_STANDBY:

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 24 lines · Michael Burian
Quoted 9 lines · Michel Dänzer
Quoted 2 lines

[0] contains dmesg output with your patch applied (which fixes the backlight issue)

This is very surprising: The patch just adds some debugging output, it's not supposed to have any functional effect. Also, I don't see any of the debugging output added by the patch in dmesg-4.3.0-rc7-00003-g85051e2-dirty-2015-10-26-11-00-41-radeon-bl-debug.

Quoted 4 lines

Are you sure that my patch was actually applied to the radeon driver when generating that file? Did you update the initrd with the patched radeon.ko?

the build was done using "make -j4 deb-pkg" on a better equipped machine, .deb packages were copied over and installed - maybe something interesting happened

AFAICT the patch should have been applied, at least it was shown with git diff and the -dirty suffix was added by the build system, not me. All graphics related drivers are compiled in (=y) rather than as modules (=m) in .config.

Quoted 4 lines

Another thing I tried yesterday was to add the old way right below the new one (this fixes the backlight issue) enclosed by some debug statements that indicate start / stop of the old / new method. (see atomdebug.diff - should be applied against mainline)

I'm not familiar with the ATOM bytecode, but since the number of bytecode instructions executed seems the same in both cases, I suspect that dig->backlight_level == 0 => ATOM_LCD_BLOFF is executed. (The debugging output in my patch would have provided all of this information and more, but there wasn't any of it in the dmesg you provided)

I guess the question then becomes how dig->backlight_level is (supposed to be) initialized.

What values do the following files contain in the broken and working cases?

/sys/class/backlight/radeon_bl0/bl_power
/sys/class/backlight/radeon_bl0/brightness
/sys/class/backlight/radeon_bl0/actual_brightness
/sys/class/backlight/radeon_bl0/max_brightness

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw
Quoted 10 lines · Michel Dänzer

I'm not familiar with the ATOM bytecode, but since the number of bytecode instructions executed seems the same in both cases, I suspect that dig->backlight_level == 0 => ATOM_LCD_BLOFF is executed. (The debugging output in my patch would have provided all of this information and more, but there wasn't any of it in the dmesg you provided)

I guess the question then becomes how dig->backlight_level is (supposed to be) initialized.

Quoted 8 lines

What values do the following files contain in the broken and working cases?

/sys/class/backlight/radeon_bl0/bl_power
/sys/class/backlight/radeon_bl0/brightness
/sys/class/backlight/radeon_bl0/actual_brightness
/sys/class/backlight/radeon_bl0/max_brightness

These files do not exist on my system,
I can offer /sys/class/backlight/acpi_video0/

content is identical in both cases

bl_power 0
brightness 10
actual_brightness 10
max_brightness 10

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 23 lines · Michael Burian
Quoted 10 lines · Michel Dänzer

I'm not familiar with the ATOM bytecode, but since the number of bytecode instructions executed seems the same in both cases, I suspect that dig->backlight_level == 0 => ATOM_LCD_BLOFF is executed. (The debugging output in my patch would have provided all of this information and more, but there wasn't any of it in the dmesg you provided)

I guess the question then becomes how dig->backlight_level is (supposed to be) initialized.

Quoted 8 lines

What values do the following files contain in the broken and working cases?

/sys/class/backlight/radeon_bl0/bl_power
/sys/class/backlight/radeon_bl0/brightness
/sys/class/backlight/radeon_bl0/actual_brightness
/sys/class/backlight/radeon_bl0/max_brightness

These files do not exist on my system,
I can offer /sys/class/backlight/acpi_video0/

Quoted 8 lines

content is identical in both cases

bl_power 0
brightness 10
actual_brightness 10
max_brightness 10

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

Alex

From 0b04a9688f83505a6dedea9266b7e9d173ff8306 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 27 Oct 2015 11:04:39 -0400
Subject: [PATCH 2/2] drm/amdgpu: fix backlight handling when not controlled by
GPU

Some systems claim the backlight is not controlled by the GPU but it seems to either actually be controlled by the GPU, or messing with the GPU backlight controls causes some other problem. If the system indicates the GPU does not control the backlight, revert back to the old behavior.

Fixes a possible regression in:
74b3112e95073b351e3b0b9799795bc76f8415fa

---
 drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +10 -2
index 1e0bba2..a7cfe75 100644
@@ -1234,6 +1234,8 @@ amdgpu_atombios_encoder_setup_external_encoder(struct drm_encoder *encoder,
 static void
 amdgpu_atombios_encoder_setup_dig(struct drm_encoder *encoder, int action)
 {
+	struct drm_device *dev = encoder->dev;
+	struct amdgpu_device *adev = dev->dev_private;
 	struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
 	struct drm_encoder *ext_encoder = amdgpu_get_external_encoder(encoder);
 	struct amdgpu_encoder_atom_dig *dig = amdgpu_encoder->enc_priv;
@@ -1278,8 +1280,14 @@ amdgpu_atombios_encoder_setup_dig(struct drm_encoder *encoder, int action)
 			amdgpu_atombios_dp_link_train(encoder, connector);
 			amdgpu_atombios_encoder_setup_dig_encoder(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
 		}
-		if (amdgpu_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
-			amdgpu_atombios_encoder_set_backlight_level(amdgpu_encoder, dig->backlight_level);
+		if (amdgpu_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+			if (adev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)
+				amdgpu_atombios_encoder_set_backlight_level(amdgpu_encoder,
+									    dig->backlight_level);
+			else
+				amdgpu_atombios_encoder_setup_dig_transmitter(encoder,
+									      ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
+		}
 		if (ext_encoder)
 			amdgpu_atombios_encoder_setup_external_encoder(encoder, ext_encoder, ATOM_ENABLE);
 	} else {
Signature · 1 line
1.8.3.1

From e464cc8304fae331537b86f53f49c26854cdff59 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 27 Oct 2015 10:56:44 -0400
Subject: [PATCH 1/2] drm/radeon: fix backlight handling when not controlled by
GPU

Some systems claim the backlight is not controlled by the GPU but it seems to either actually be controlled by the GPU, or messing with the GPU backlight controls causes some other problem. If the system indicates the GPU does not control the backlight, revert back to the old behavior.

Fixes a regression in commit:
4281f46ef839050d2ef60348f661eb463c21cc2e

---
 drivers/gpu/drm/radeon/atombios_encoders.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +14 -4
index 65adb9c..8ce32f9 100644
@@ -1624,9 +1624,14 @@ radeon_atom_encoder_dpms_avivo(struct drm_encoder *encoder, int mode)
 		} else
 			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-			struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+			if (rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU) {
+				struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			} else {
+				args.ucAction = ATOM_LCD_BLON;
+				atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+			}
 		}
 		break;
 	case DRM_MODE_DPMS_STANDBY:
@@ -1706,8 +1711,13 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
 			if (ASIC_IS_DCE4(rdev))
 				atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
 		}
-		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+			if (rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			else
+				atombios_dig_transmitter_setup(encoder,
+							       ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
+		}
 		if (ext_encoder)
 			atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
 		break;
Signature · 1 line
1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 7 lines · Alex Deucher

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

no, still no backlight when applied against current current mainline

858e904bd71dd0057a548d6785d94ce5ec4aeabd (Merge tag 'iommu-fixes-v4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu)

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw
Quoted 10 lines · Michael Burian
Quoted 7 lines · Alex Deucher

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

Quoted 4 lines

no, still no backlight when applied against current current mainline

858e904bd71dd0057a548d6785d94ce5ec4aeabd (Merge tag 'iommu-fixes-v4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu)

I see the problem. We don't enable native backlight control on older asics like yours by default. Does the attached patch help?

Alex

From 8940e9553ae9097a22c2c46a0d33a6ce7fd6d9b2 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 27 Oct 2015 10:56:44 -0400
Subject: [PATCH] drm/radeon: fix dpms when driver backlight control is
disabled

If driver backlight control is disabled, either by driver parameter or default per-asic setting, revert to the old behavior.

Fixes a regression in commit:
4281f46ef839050d2ef60348f661eb463c21cc2e

---
 drivers/gpu/drm/radeon/atombios_encoders.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +14 -4
index 65adb9c..ec0f5f6 100644
@@ -1624,9 +1624,14 @@ radeon_atom_encoder_dpms_avivo(struct drm_encoder *encoder, int mode)
 		} else
 			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-			struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+			if (rdev->mode_info.bl_encoder) {
+				struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			} else {
+				args.ucAction = ATOM_LCD_BLON;
+				atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+			}
 		}
 		break;
 	case DRM_MODE_DPMS_STANDBY:
@@ -1706,8 +1711,13 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
 			if (ASIC_IS_DCE4(rdev))
 				atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
 		}
-		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+			if (rdev->mode_info.bl_encoder)
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			else
+				atombios_dig_transmitter_setup(encoder,
+							       ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
+		}
 		if (ext_encoder)
 			atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
 		break;
Signature · 1 line
1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#12 lore raw
In reply to Alex Deucher
Quoted 11 lines · Alex Deucher
Quoted 10 lines · Michael Burian
Quoted 7 lines · Alex Deucher

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

Quoted 7 lines
Quoted 4 lines

no, still no backlight when applied against current current mainline

858e904bd71dd0057a548d6785d94ce5ec4aeabd (Merge tag 'iommu-fixes-v4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu)

I see the problem. We don't enable native backlight control on older asics like yours by default. Does the attached patch help?

My only doubt about this patch is: Should we also fall back to the old beahviour in the !(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU) case?

Signature · 7 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Alex Deucher
Quoted 14 lines · Michael Burian
Quoted 7 lines · Alex Deucher

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

no, still no backlight when applied against current current mainline

858e904bd71dd0057a548d6785d94ce5ec4aeabd (Merge tag 'iommu-fixes-v4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu)

Quoted 6 lines
Quoted 2 lines

I see the problem. We don't enable native backlight control on older asics like yours by default. Does the attached patch help?

My only doubt about this patch is: Should we also fall back to the old beahviour in the !(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU) case?

Theoretically, it's not necessary, but I guess better safe than sorry. Updated patches attached.

Alex

From 7e2650330f9bc5e2b5304b563d4136fd99efaf2e Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Wed, 28 Oct 2015 14:26:32 -0400
Subject: [PATCH 1/2] drm/radeon: move bl encoder assignment into bl init

So that the bl encoder will be null if the GPU does not control the backlight.

---
 drivers/gpu/drm/radeon/atombios_encoders.c      | 1 +
 drivers/gpu/drm/radeon/radeon_encoders.c        | 1 -
 drivers/gpu/drm/radeon/radeon_legacy_encoders.c | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/atombios_encoders.c +1 -0
index 65adb9c..933fd1b 100644
@@ -237,6 +237,7 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
 	backlight_update_status(bd);
 
 	DRM_INFO("radeon atom DIG backlight initialized\n");
+	rdev->mode_info.bl_encoder = radeon_encoder;
 
 	return;
 
drivers/gpu/drm/radeon/radeon_encoders.c +0 -1
index ef99917..c6ee802 100644
@@ -194,7 +194,6 @@ static void radeon_encoder_add_backlight(struct radeon_encoder *radeon_encoder,
 			radeon_atom_backlight_init(radeon_encoder, connector);
 		else
 			radeon_legacy_backlight_init(radeon_encoder, connector);
-		rdev->mode_info.bl_encoder = radeon_encoder;
 	}
 }
 
drivers/gpu/drm/radeon/radeon_legacy_encoders.c +1 -0
index 4571530..30de433 100644
@@ -441,6 +441,7 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
 	backlight_update_status(bd);
 
 	DRM_INFO("radeon legacy LVDS backlight initialized\n");
+	rdev->mode_info.bl_encoder = radeon_encoder;
 
 	return;
 
Signature · 1 line
1.8.3.1

From 618bc51b0931376786d5da8a0c600b4c73416b1c Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Tue, 27 Oct 2015 10:56:44 -0400
Subject: [PATCH 2/2] drm/radeon: fix dpms when driver backlight control is
disabled

If driver backlight control is disabled, either by driver parameter or default per-asic setting, revert to the old behavior.

Fixes a regression in commit:
4281f46ef839050d2ef60348f661eb463c21cc2e

---
 drivers/gpu/drm/radeon/atombios_encoders.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +14 -4
index 933fd1b..bb29214 100644
@@ -1625,9 +1625,14 @@ radeon_atom_encoder_dpms_avivo(struct drm_encoder *encoder, int mode)
 		} else
 			atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-			struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+			if (rdev->mode_info.bl_encoder) {
+				struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			} else {
+				args.ucAction = ATOM_LCD_BLON;
+				atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+			}
 		}
 		break;
 	case DRM_MODE_DPMS_STANDBY:
@@ -1707,8 +1712,13 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
 			if (ASIC_IS_DCE4(rdev))
 				atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0);
 		}
-		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
-			atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+		if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+			if (rdev->mode_info.bl_encoder)
+				atombios_set_backlight_level(radeon_encoder, dig->backlight_level);
+			else
+				atombios_dig_transmitter_setup(encoder,
+							       ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
+		}
 		if (ext_encoder)
 			atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
 		break;
Signature · 1 line
1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw
Quoted 8 lines · Alex Deucher
Quoted 4 lines

My only doubt about this patch is: Should we also fall back to the old beahviour in the !(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU) case?

Theoretically, it's not necessary, but I guess better safe than sorry. Updated patches attached.

applied both patches on top of mainline[1], backlight works fine

[1]
8a28d67457b613258aa0578ccece206d166f2b9f "Merge tag 'powerpc-4.3-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux"

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

author Reviewed-by
#15 lore raw
In reply to Alex Deucher
Quoted 21 lines · Alex Deucher
Quoted 20 lines · Michel Dänzer
Quoted 18 lines · Alex Deucher
Quoted 10 lines · Michael Burian
Quoted 7 lines · Alex Deucher

It would appear that your system does not use the gpu backlight controller. Either it's lying or messing with the GPU backlight controller causes some bad interaction with whatever does control it. Does the attached radeon patch help? I'm also attaching an amdgpu patch for reference in case the same problem appears on amdgpu.

Quoted 4 lines

no, still no backlight when applied against current current mainline

858e904bd71dd0057a548d6785d94ce5ec4aeabd (Merge tag 'iommu-fixes-v4.3-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu)

I see the problem. We don't enable native backlight control on older asics like yours by default. Does the attached patch help?

Quoted 6 lines
Quoted 3 lines

My only doubt about this patch is: Should we also fall back to the old beahviour in the !(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU) case?

Theoretically, it's not necessary, but I guess better safe than sorry. Updated patches attached.

Both patches are

Apologies for the regression, and thanks for the fixes Alex!

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel