Skip to contentSkip to conversation

ACPI: video: Prefer native over vendor + quirk updates

PATCH In review Hans de Goede 2 participants 11 messages Nov 14, 2022 – Nov 16, 2022 ACPI

lore
Share & tools
lore
#0 lore raw

cover ACPI: video: Prefer native over vendor + quirk updates

Hi Rafael, et. al.,

As mentioned already in the RFC:

"""
Here is a second attempt at always registering only a single /sys/class/backlight device per panel.

This first round of testing has shown that native works well even on systems so old that the don't have acpi_video backlight control support.

This patch series makes native be preferred over vendor, which should avoid the problems seen with the 6.1 changes before the fixes. """

The 2 base patches (last 2 patches of the series now) are unchanged from the RFC. New is a bunch of video_detect DMI quirk updates, 3 small fixes to existing quirks + 2 new quirks. 1 of the new quirks is necessary to avoid a known regression with preferring native over vendor on 1 model, the other DMI quirk is unrelated to the other changes.

This series applies on top of the platform-drivers-x86-v6.1-3 tag from:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/

So either you will need to merge that tag (or merge v6.1-rc5 from Linus) before applying these patches, or I can merge this through my for-next branch which already has these changes. Either way works for me.

Regards,

Hans

Hans de Goede (7):
ACPI: video: Add a few bugtracker links to DMI quirks
ACPI: video: Change GIGABYTE GB-BXBT-2807 quirk to force_none
ACPI: video: Change Sony Vaio VPCEH3U1E quirk to force_native
ACPI: video: Add force_vendor quirk for Sony Vaio PCG-FRV35
ACPI: video: Add force_native quirk for Sony Vaio VPCY11S1E
ACPI: video: Simplify __acpi_video_get_backlight_type()
ACPI: video: Prefer native over vendor

 drivers/acpi/video_detect.c | 110 ++++++++++++++++++++----------------
 1 file changed, 62 insertions(+), 48 deletions(-)
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/7 ACPI: video: Add a few bugtracker links to DMI quirks

Add a couple of missing bugtracker links to DMI quirks

---
 drivers/acpi/video_detect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/video_detect.c +4 -1
index b2a616287638..bb8052fc3fee 100644
@@ -166,6 +166,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		},
 	},
 	{
+	 /* https://bugs.launchpad.net/bugs/1000146 */
 	 .callback = video_detect_force_vendor,
 	 /* Asus X101CH */
 	 .matches = {
@@ -190,6 +191,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		},
 	},
 	{
+	 /* https://bugs.launchpad.net/bugs/1000146 */
 	 .callback = video_detect_force_vendor,
 	 /* Asus 1015CX */
 	 .matches = {
@@ -233,6 +235,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		},
 	},
 	{
+	 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
 	 .callback = video_detect_force_vendor,
 	 /* Sony VPCEH3U1E */
 	 .matches = {
@@ -400,8 +403,8 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "530U4E/540U4E"),
 		},
 	},
-	/* https://bugs.launchpad.net/bugs/1894667 */
 	{
+	 /* https://bugs.launchpad.net/bugs/1894667 */
 	 .callback = video_detect_force_video,
 	 /* HP 635 Notebook */
 	 .matches = {
Signature · 1 line
2.37.3
#2 lore raw

PATCH 2/7 ACPI: video: Change GIGABYTE GB-BXBT-2807 quirk to force_none

In reply to Hans de Goede

The GIGABYTE GB-BXBT-2807 DMI quirk was added by commit 25417185e9b5 ("ACPI: video: Add DMI quirk for GIGABYTE GB-BXBT-2807") which says the following in its commit message:

"The GIGABYTE GB-BXBT-2807 is a mini-PC which uses off the shelf components, like an Intel GPU which is meant for mobile systems. As such, it, by default, has a backlight controller exposed.

Unfortunately, the backlight controller only confuses userspace, which sees the existence of a backlight device node and has the unrealistic belief that there is actually a backlight there!

Add a DMI quirk to force the backlight off on this system."

So in essence this quirk was using a video_detect_force_vendor quirk to disable backlight control. Now a days we have a specific "none" backlight type for this. Change the quirk to video_detect_force_none and group it together with the other force_none quirks.

Cc Jasper St. Pierre <[email protected]>
---
 drivers/acpi/video_detect.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/acpi/video_detect.c +8 -8
index bb8052fc3fee..a1ac7de186be 100644
@@ -199,14 +199,6 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
 		},
 	},
-	{
-	 .callback = video_detect_force_vendor,
-	 /* GIGABYTE GB-BXBT-2807 */
-	 .matches = {
-		DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
-		DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"),
-		},
-	},
 	{
 	 .callback = video_detect_force_vendor,
 	 /* Samsung N150/N210/N220 */
@@ -674,6 +666,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"),
 		},
 	},
+	{
+	 .callback = video_detect_force_none,
+	 /* GIGABYTE GB-BXBT-2807 */
+	 .matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"),
+		},
+	},
 	{
 	 .callback = video_detect_force_none,
 	 /* MSI MS-7721 */
Signature · 1 line
2.37.3
#3 lore raw

PATCH 3/7 ACPI: video: Change Sony Vaio VPCEH3U1E quirk to force_native

In reply to Hans de Goede

According to: https://bugzilla.kernel.org/show_bug.cgi?id=202401
the Sony Vaio VPCEH3U1E quirk was added to disable the acpi_video0 backlight interface because that was not working, so that userspace will pick the actually working native nv_backlight interface instead.

With the new kernel behavior of hiding native interfaces unless acpi_video_get_backlight_type() returns native, the current video_detect_force_vendor quirk will cause the working nv_backlight interface will be disabled too.

Change the quirk to video_detect_force_native to get the desired result of only registering the nv_backlight interface.

After this all currently remaining force_vendor quirks in video_detect_dmi_table[] are there to prefer a vendor interface over a non working ACPI video interface, add a comment to document this.

---
 drivers/acpi/video_detect.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/acpi/video_detect.c +13 -9
index a1ac7de186be..327e0967ba54 100644
@@ -132,6 +132,10 @@ static int video_detect_force_none(const struct dmi_system_id *d)
 }
 
 static const struct dmi_system_id video_detect_dmi_table[] = {
+	/*
+	 * Models which should use the vendor backlight interface,
+	 * because of broken ACPI video backlight control.
+	 */
 	{
 	 /* https://bugzilla.redhat.com/show_bug.cgi?id=1128309 */
 	 .callback = video_detect_force_vendor,
@@ -226,15 +230,6 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
 		},
 	},
-	{
-	 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
-	 .callback = video_detect_force_vendor,
-	 /* Sony VPCEH3U1E */
-	 .matches = {
-		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
-		DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
-		},
-	},
 	{
 	 .callback = video_detect_force_vendor,
 	 /* Xiaomi Mi Pad 2 */
@@ -604,6 +599,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_BOARD_NAME, "N250P"),
 		},
 	},
+	{
+	 /* https://bugzilla.kernel.org/show_bug.cgi?id=202401 */
+	 .callback = video_detect_force_native,
+	 /* Sony Vaio VPCEH3U1E */
+	 .matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
+		},
+	},
 
 	/*
 	 * These Toshibas have a broken acpi-video interface for brightness
Signature · 1 line
2.37.3
#4 lore raw

PATCH 4/7 ACPI: video: Add force_vendor quirk for Sony Vaio PCG-FRV35

In reply to Hans de Goede

The Sony Vaio PCG-FRV35 advertises both native and vendor backlight control interfaces. With the upcoming changes to prefer native over vendor acpi_video_get_backlight_type() will start returning native on these laptops.

But the native radeon_bl0 interface does not work, where as the sony vendor interface does work. Add a quirk to force use of the vendor interface.

---
 drivers/acpi/video_detect.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/acpi/video_detect.c +13 -0
index 327e0967ba54..43f667523ab0 100644
@@ -239,6 +239,19 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		},
 	},
 
+	/*
+	 * Models which should use the vendor backlight interface,
+	 * because of broken native backlight control.
+	 */
+	{
+	 .callback = video_detect_force_vendor,
+	 /* Sony Vaio PCG-FRV35 */
+	 .matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "PCG-FRV35"),
+		},
+	},
+
 	/*
 	 * Toshiba models with Transflective display, these need to use
 	 * the toshiba_acpi vendor driver for proper Transflective handling.
Signature · 1 line
2.37.3
#5 lore raw

PATCH 5/7 ACPI: video: Add force_native quirk for Sony Vaio VPCY11S1E

In reply to Hans de Goede

The Sony Vaio VPCY11S1E advertises both native and ACPI video backlight control interfaces, but only the native interface works and the default heuristics end up picking ACPI video on this model.

Add a video_detect_force_native DMI quirk for this.

---
 drivers/acpi/video_detect.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/acpi/video_detect.c +8 -0
index 43f667523ab0..0e217bf79f17 100644
@@ -621,6 +621,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "VPCEH3U1E"),
 		},
 	},
+	{
+	 .callback = video_detect_force_native,
+	 /* Sony Vaio VPCY11S1E */
+	 .matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "VPCY11S1E"),
+		},
+	},
 
 	/*
 	 * These Toshibas have a broken acpi-video interface for brightness
Signature · 1 line
2.37.3
#6 lore raw

PATCH 6/7 ACPI: video: Simplify __acpi_video_get_backlight_type()

In reply to Hans de Goede

Simplify __acpi_video_get_backlight_type() removing a nested if which makes the flow harder to follow.

This also results in having only 1 exit point with return acpi_backlight_native instead of 2.

Note this drops the (video_caps & ACPI_VIDEO_BACKLIGHT) check from the if (acpi_osi_is_win8() && native_available) return native path. Windows 8's hardware certification requirements include that there must be ACPI video bus backlight control, so the ACPI_VIDEO_BACKLIGHT check is redundant.

---
 drivers/acpi/video_detect.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)
drivers/acpi/video_detect.c +17 -19
index 0e217bf79f17..5da6b1b449d5 100644
@@ -715,6 +715,16 @@ static bool google_cros_ec_present(void)
 	return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
 }
 
+/*
+ * Windows 8 and newer no longer use the ACPI video interface, so it often
+ * does not work. So on win8+ systems prefer native brightness control.
+ * Chromebooks should always prefer native backlight control.
+ */
+static bool prefer_native_over_acpi_video(void)
+{
+	return acpi_osi_is_win8() || google_cros_ec_present();
+}
+
 /*
  * Determine which type of backlight interface to use on this system,
  * First check cmdline, then dmi quirks, then do autodetect.
@@ -760,26 +770,14 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 	if (apple_gmux_present())
 		return acpi_backlight_apple_gmux;
 
-	/* Chromebooks should always prefer native backlight control. */
-	if (google_cros_ec_present() && native_available)
-		return acpi_backlight_native;
+	/* Use ACPI video if available, except when native should be preferred. */
+	if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
+	     !(native_available && prefer_native_over_acpi_video()))
+		return acpi_backlight_video;
 
-	/* On systems with ACPI video use either native or ACPI video. */
-	if (video_caps & ACPI_VIDEO_BACKLIGHT) {
-		/*
-		 * Windows 8 and newer no longer use the ACPI video interface,
-		 * so it often does not work. If the ACPI tables are written
-		 * for win8 and native brightness ctl is available, use that.
-		 *
-		 * The native check deliberately is inside the if acpi-video
-		 * block on older devices without acpi-video support native
-		 * is usually not the best choice.
-		 */
-		if (acpi_osi_is_win8() && native_available)
-			return acpi_backlight_native;
-		else
-			return acpi_backlight_video;
-	}
+	/* Use native if available */
+	if (native_available && prefer_native_over_acpi_video())
+		return acpi_backlight_native;
 
 	/* No ACPI video (old hw), use vendor specific fw methods. */
 	return acpi_backlight_vendor;
Signature · 1 line
2.37.3
#7 lore raw

PATCH 7/7 ACPI: video: Prefer native over vendor

In reply to Hans de Goede

When available prefer native backlight control over vendor backlight control.

Testing has shown that there are quite a few laptop models which rely on native backlight control (they don't have ACPI video bus backlight control) and on which acpi_osi_is_win8() returns false.

Currently __acpi_video_get_backlight_type() returns vendor on these laptops, leading to an empty /sys/class/backlight.

As a workaround for this acpi_video_backlight_use_native() has been temporarily changed to always return true.

This re-introduces the problem of having multiple backlight devices under /sys/class/backlight for a single panel.

Change __acpi_video_get_backlight_type() to prefer native over vendor when available. So that it returns native on these models.

And change acpi_video_backlight_use_native() back to only return true when __acpi_video_get_backlight_type() returns native.

---
 drivers/acpi/video_detect.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/acpi/video_detect.c +3 -15
index 5da6b1b449d5..a934bbc9dd37 100644
@@ -776,10 +776,10 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 		return acpi_backlight_video;
 
 	/* Use native if available */
-	if (native_available && prefer_native_over_acpi_video())
+	if (native_available)
 		return acpi_backlight_native;
 
-	/* No ACPI video (old hw), use vendor specific fw methods. */
+	/* No ACPI video/native (old hw), use vendor specific fw methods. */
 	return acpi_backlight_vendor;
 }
 
@@ -791,18 +791,6 @@ EXPORT_SYMBOL(acpi_video_get_backlight_type);
 
 bool acpi_video_backlight_use_native(void)
 {
-	/*
-	 * Call __acpi_video_get_backlight_type() to let it know that
-	 * a native backlight is available.
-	 */
-	__acpi_video_get_backlight_type(true);
-
-	/*
-	 * For now just always return true. There is a whole bunch of laptop
-	 * models where (video_caps & ACPI_VIDEO_BACKLIGHT) is false causing
-	 * __acpi_video_get_backlight_type() to return vendor, while these
-	 * models only have a native backlight control.
-	 */
-	return true;
+	return __acpi_video_get_backlight_type(true) == acpi_backlight_native;
 }
 EXPORT_SYMBOL(acpi_video_backlight_use_native);
Signature · 1 line
2.37.3
#8 lore raw
In reply to Hans de Goede
Quoted 22 lines · Hans de Goede

Hi Rafael, et. al.,

As mentioned already in the RFC:

"""
Here is a second attempt at always registering only a single /sys/class/backlight device per panel.

This first round of testing has shown that native works well even on systems so old that the don't have acpi_video backlight control support.

This patch series makes native be preferred over vendor, which should avoid the problems seen with the 6.1 changes before the fixes. """

The 2 base patches (last 2 patches of the series now) are unchanged from the RFC. New is a bunch of video_detect DMI quirk updates, 3 small fixes to existing quirks + 2 new quirks. 1 of the new quirks is necessary to avoid a known regression with preferring native over vendor on 1 model, the other DMI quirk is unrelated to the other changes.

Quoted 6 lines

This series applies on top of the platform-drivers-x86-v6.1-3 tag from:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/

So either you will need to merge that tag (or merge v6.1-rc5 from Linus) before applying these patches, or I can merge this through my for-next branch which already has these changes. Either way works for me.

I'll apply them on top of the -rc5.

Quoted 9 lines

Hans de Goede (7):
ACPI: video: Add a few bugtracker links to DMI quirks
ACPI: video: Change GIGABYTE GB-BXBT-2807 quirk to force_none
ACPI: video: Change Sony Vaio VPCEH3U1E quirk to force_native
ACPI: video: Add force_vendor quirk for Sony Vaio PCG-FRV35
ACPI: video: Add force_native quirk for Sony Vaio VPCY11S1E
ACPI: video: Simplify __acpi_video_get_backlight_type()
ACPI: video: Prefer native over vendor

Quoted 4 lines
 drivers/acpi/video_detect.c | 110 ++++++++++++++++++++----------------
 1 file changed, 62 insertions(+), 48 deletions(-)

--

Thanks!

#9 lore raw

Hi,

Quoted 23 lines · Rafael J. Wysocki
Quoted 22 lines · Hans de Goede

Hi Rafael, et. al.,

As mentioned already in the RFC:

"""
Here is a second attempt at always registering only a single /sys/class/backlight device per panel.

This first round of testing has shown that native works well even on systems so old that the don't have acpi_video backlight control support.

This patch series makes native be preferred over vendor, which should avoid the problems seen with the 6.1 changes before the fixes. """

The 2 base patches (last 2 patches of the series now) are unchanged from the RFC. New is a bunch of video_detect DMI quirk updates, 3 small fixes to existing quirks + 2 new quirks. 1 of the new quirks is necessary to avoid a known regression with preferring native over vendor on 1 model, the other DMI quirk is unrelated to the other changes.

Quoted 8 lines
Quoted 6 lines

This series applies on top of the platform-drivers-x86-v6.1-3 tag from:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/

So either you will need to merge that tag (or merge v6.1-rc5 from Linus) before applying these patches, or I can merge this through my for-next branch which already has these changes. Either way works for me.

I'll apply them on top of the -rc5.

Great, thank you.

Regards,

Hans

#10 lore raw
Quoted 30 lines · Hans de Goede

Hi,

Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · Hans de Goede

Hi Rafael, et. al.,

As mentioned already in the RFC:

"""
Here is a second attempt at always registering only a single /sys/class/backlight device per panel.

This first round of testing has shown that native works well even on systems so old that the don't have acpi_video backlight control support.

This patch series makes native be preferred over vendor, which should avoid the problems seen with the 6.1 changes before the fixes. """

The 2 base patches (last 2 patches of the series now) are unchanged from the RFC. New is a bunch of video_detect DMI quirk updates, 3 small fixes to existing quirks + 2 new quirks. 1 of the new quirks is necessary to avoid a known regression with preferring native over vendor on 1 model, the other DMI quirk is unrelated to the other changes.

This series applies on top of the platform-drivers-x86-v6.1-3 tag from:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

So either you will need to merge that tag (or merge v6.1-rc5 from Linus) before applying these patches, or I can merge this through my for-next branch which already has these changes. Either way works for me.

I'll apply them on top of the -rc5.

Great, thank you.

Applied now, thanks!