All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Aditya Garg <gargaditya08@live.com>,
	Mark Gross <mgross@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Lukas Wunner <lukas@wunner.de>,
	linux-acpi@vger.kernel.org, Andy Shevchenko <andy@infradead.org>,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH 3/3] ACPI: video: Fix apple gmux detection
Date: Mon, 23 Jan 2023 12:37:50 +0100	[thread overview]
Message-ID: <20230123113750.462144-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20230123113750.462144-1-hdegoede@redhat.com>

Some apple laptop models have an ACPI device with a HID of APP000B
and that device has an IO resource (so it does not describe the new
unsupported MMIO based gmux type), but there actually is no gmux
in the laptop at all.

The gmux_probe() function of the actual apple-gmux driver has code
to detect this, this code has been factored out into a new
apple_gmux_detect() helper in apple-gmux.h.

Use this new function to fix acpi_video_get_backlight_type() wrongly
returning apple_gmux as type on these new laptops.

Fixes: 21245df307cb ("ACPI: video: Add Apple GMUX brightness control detection")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/video_detect.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 64eab35037c3..a8c02608dde4 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -110,26 +110,6 @@ static bool nvidia_wmi_ec_supported(void)
 }
 #endif
 
-static bool apple_gmux_backlight_present(void)
-{
-	struct acpi_device *adev;
-	struct device *dev;
-
-	adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1);
-	if (!adev)
-		return false;
-
-	dev = acpi_get_first_physical_node(adev);
-	if (!dev)
-		return false;
-
-	/*
-	 * drivers/platform/x86/apple-gmux.c only supports old style
-	 * Apple GMUX with an IO-resource.
-	 */
-	return pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL;
-}
-
 /* Force to use vendor driver when the ACPI device is known to be
  * buggy */
 static int video_detect_force_vendor(const struct dmi_system_id *d)
@@ -791,6 +771,7 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 {
 	static DEFINE_MUTEX(init_mutex);
 	static bool nvidia_wmi_ec_present;
+	static bool apple_gmux_present;
 	static bool native_available;
 	static bool init_done;
 	static long video_caps;
@@ -804,6 +785,7 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 				    ACPI_UINT32_MAX, find_video, NULL,
 				    &video_caps, NULL);
 		nvidia_wmi_ec_present = nvidia_wmi_ec_supported();
+		apple_gmux_present = apple_gmux_detect(NULL, NULL);
 		init_done = true;
 	}
 	if (native)
@@ -825,7 +807,7 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
 	if (nvidia_wmi_ec_present)
 		return acpi_backlight_nvidia_wmi_ec;
 
-	if (apple_gmux_backlight_present())
+	if (apple_gmux_present)
 		return acpi_backlight_apple_gmux;
 
 	/* Use ACPI video if available, except when native should be preferred. */
-- 
2.39.0


  parent reply	other threads:[~2023-01-23 11:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23 11:37 [PATCH 0/3] ACPI: video/apple-gmux: Improve apple-gmux backlight detection Hans de Goede
2023-01-23 11:37 ` [PATCH 1/3] platform/x86: apple-gmux: Move port defines to apple-gmux.h Hans de Goede
2023-01-23 11:37 ` [PATCH 2/3] platform/x86: apple-gmux: Add apple_gmux_detect() helper Hans de Goede
2023-01-23 13:49   ` Lukas Wunner
2023-01-23 14:13     ` Hans de Goede
2023-01-23 14:23       ` Lukas Wunner
2023-01-23 15:05         ` Hans de Goede
2023-01-23 15:10           ` Hans de Goede
2023-01-23 16:35   ` Andy Shevchenko
2023-01-23 11:37 ` Hans de Goede [this message]
2023-01-23 16:37   ` [PATCH 3/3] ACPI: video: Fix apple gmux detection Andy Shevchenko
2023-01-23 17:25     ` Hans de Goede
2023-01-23 19:20   ` Rafael J. Wysocki
2023-01-23 12:09 ` [PATCH 0/3] ACPI: video/apple-gmux: Improve apple-gmux backlight detection Lukas Wunner
2023-01-23 12:38   ` Hans de Goede
2023-01-23 13:58     ` Lukas Wunner
2023-01-23 15:05       ` Hans de Goede
2023-01-23 14:53 ` Aditya Garg
2023-01-24  8:21   ` Orlando Chamberlain
2023-01-24 10:26     ` Aditya Garg

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=20230123113750.462144-4-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@infradead.org \
    --cc=gargaditya08@live.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.