8630265
From patchwork Tue Apr 17 16:23:50 2018
8630265
Content-Type: text/plain; charset="utf-8"
8630265
MIME-Version: 1.0
8630265
Content-Transfer-Encoding: 7bit
8630265
Subject: ACPI / video: Only default only_lcd to true on Win8-ready _desktops_
8630265
From: Hans de Goede <hdegoede@redhat.com>
8630265
X-Patchwork-Id: 10345845
8630265
Message-Id: <20180417162350.12227-1-hdegoede@redhat.com>
8630265
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>, Len Brown <lenb@kernel.org>
8630265
Cc: Hans de Goede <hdegoede@redhat.com>,
8630265
 Zhang Rui <rui.zhang@intel.com>, linux-acpi@vger.kernel.org,
8630265
 James Hogan <jhogan@kernel.org>
8630265
Date: Tue, 17 Apr 2018 18:23:50 +0200
8630265
8630265
Commit 5928c281524f ("ACPI / video: Default lcd_only to true on Win8-ready
8630265
and newer machines") made only_lcd default to true on all machines where
8630265
acpi_osi_is_win8() returns true, including laptops.
8630265
8630265
The purpose of this is to avoid the bogus / non-working acpi backlight
8630265
interface which many newer BIOS-es define on desktop machines.
8630265
8630265
But this is causing a regression on some laptops, specifically on the
8630265
Dell XPS 13 2013 model, which does not have the LCD flag set for its
8630265
fully functional ACPI backlight interface.
8630265
8630265
Rather then DMI quirking our way out of this, this commits changes the
8630265
logic for setting only_lcd to true, to only do this on machines with
8630265
a desktop (or server) dmi chassis-type.
8630265
8630265
Note that we cannot simply only check the chassis-type and not register
8630265
the backlight interface based on that as there are some laptops and
8630265
tablets which have their chassis-type set to "3" aka desktop. Hopefully
8630265
the combination of checking the LCD flag, but only on devices with
8630265
a desktop(ish) chassis-type will avoid the needs for DMI quirks for this,
8630265
or at least limit the amount of DMI quirks which we need to a minimum.
8630265
8630265
Cc: James Hogan <jhogan@kernel.org>
8630265
Reported-and-tested-by: James Hogan <jhogan@kernel.org>
8630265
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
8630265
---
8630265
 drivers/acpi/acpi_video.c | 27 +++++++++++++++++++++++++--
8630265
 1 file changed, 25 insertions(+), 2 deletions(-)
8630265
8630265
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
8630265
index 76fb96966f7b..2f2e737be0f8 100644
8630265
--- a/drivers/acpi/acpi_video.c
8630265
+++ b/drivers/acpi/acpi_video.c
8630265
@@ -2123,6 +2123,25 @@ static int __init intel_opregion_present(void)
8630265
 	return opregion;
8630265
 }
8630265
 
8630265
+static bool dmi_is_desktop(void)
8630265
+{
8630265
+	const char *chassis_type;
8630265
+
8630265
+	chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
8630265
+	if (!chassis_type)
8630265
+		return false;
8630265
+
8630265
+	if (!strcmp(chassis_type, "3") || /*  3: Desktop */
8630265
+	    !strcmp(chassis_type, "4") || /*  4: Low Profile Desktop */
8630265
+	    !strcmp(chassis_type, "5") || /*  5: Pizza Box */
8630265
+	    !strcmp(chassis_type, "6") || /*  6: Mini Tower */
8630265
+	    !strcmp(chassis_type, "7") || /*  7: Tower */
8630265
+	    !strcmp(chassis_type, "11"))  /* 11: Main Server Chassis */
8630265
+		return true;
8630265
+
8630265
+	return false;
8630265
+}
8630265
+
8630265
 int acpi_video_register(void)
8630265
 {
8630265
 	int ret = 0;
8630265
@@ -2143,8 +2162,12 @@ int acpi_video_register(void)
8630265
 	 * win8 ready (where we also prefer the native backlight driver, so
8630265
 	 * normally the acpi_video code should not register there anyways).
8630265
 	 */
8630265
-	if (only_lcd == -1)
8630265
-		only_lcd = acpi_osi_is_win8();
8630265
+	if (only_lcd == -1) {
8630265
+		if (dmi_is_desktop() && acpi_osi_is_win8())
8630265
+			only_lcd = true;
8630265
+		else
8630265
+			only_lcd = false;
8630265
+	}
8630265
 
8630265
 	dmi_check_system(video_dmi_table);
8630265