All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Kenneth Chan <kenneth.t.chan@gmail.com>
Cc: Stefan Seyfried <stefan.seyfried@googlemail.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Platform Driver <platform-driver-x86@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Stefan Seyfried <seife+kernel@b1-systems.com>
Subject: Re: [PATCH 2/2] platform/x86: panasonic-laptop: allow to use all hotkeys
Date: Tue, 21 Jun 2022 11:34:42 +0200	[thread overview]
Message-ID: <e5701e68-1b15-97b7-51e4-8d3c8a7c3c86@redhat.com> (raw)
In-Reply-To: <CAPqSeKtqORkhW4dAMsd2b6e3OwhHZ107znwJtoBADE1h2-dsVA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

Hi,

On 6/20/22 17:21, Kenneth Chan wrote:
> It took quite a while to do a full compile, just to be safe.

<snip backlight stuff, which looks as expected>

> The mute, volume up/down keys are still duplicated by atkbd after
> applying 0005-platform-x86-panasonic-laptop-filter-out-duplicate-v.patch.

Hmm, can you add a couple of:

 pr_info("data 0x%02x\n", data);

at the top of the new panasonic_i8042_filter() function
and then check in dmesg what is output for the volume keys.

The patch should filter out those duplicate keys, unless
I got the codes wrong somehow.

Also can you please try the attached 2 patches on top of my
last series, this should hide the broken panasonic backlight
device and otherwise it should make no difference (but maybe
double check the duplicate brightness keys are not back.

Regards,

Hans

[-- Attachment #2: 0001-platform-x86-panasonic-laptop-Use-acpi_video_get_bac.patch --]
[-- Type: text/x-patch, Size: 1938 bytes --]

From f9afd65564e1f4e8e41b0cdbc754b11fc0e2edf6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 21 Jun 2022 11:20:42 +0200
Subject: [PATCH 1/2] platform/x86: panasonic-laptop: Use
 acpi_video_get_backlight_type()

Use acpi_video_get_backlight_type() to determine if we should register
the panasonic specific backlight interface. To avoid registering this
on systems where the ACPI or GPU native backlight control methods
should be used instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/panasonic-laptop.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index a4c82b3a81cf..0fa7695089e2 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -998,15 +998,19 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
 		pr_err("Couldn't retrieve BIOS data\n");
 		goto out_input;
 	}
-	/* initialize backlight */
-	memset(&props, 0, sizeof(struct backlight_properties));
-	props.type = BACKLIGHT_PLATFORM;
-	props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
-	pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
-						   &pcc_backlight_ops, &props);
-	if (IS_ERR(pcc->backlight)) {
-		result = PTR_ERR(pcc->backlight);
-		goto out_input;
+
+	if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
+		/* initialize backlight */
+		memset(&props, 0, sizeof(struct backlight_properties));
+		props.type = BACKLIGHT_PLATFORM;
+		props.max_brightness = pcc->sinf[SINF_AC_MAX_BRIGHT];
+		
+		pcc->backlight = backlight_device_register("panasonic", NULL, pcc,
+							   &pcc_backlight_ops, &props);
+		if (IS_ERR(pcc->backlight)) {
+			result = PTR_ERR(pcc->backlight);
+			goto out_input;
+		}
 	}
 
 	/* read the initial brightness setting from the hardware */
-- 
2.36.0


[-- Attachment #3: 0002-ACPI-video-Change-how-we-determine-if-brightness-key.patch --]
[-- Type: text/x-patch, Size: 2465 bytes --]

From 70d07e9157bb2813726986d068fb0c99e1a619d9 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 21 Jun 2022 11:12:51 +0200
Subject: [PATCH 2/2] ACPI: video: Change how we determine if brightness
 key-presses are handled

Some systems have an ACPI video bus but not ACPI video devices with
backlight capability. On these devices brightness key-presses are
(logically) not reported through the ACPI video bus.

Change how acpi_video_handles_brightness_key_presses() determines if
brightness key-presses are handled by the ACPI video driver to avoid
vendor specific drivers/platform/x86 drivers filtering out their
brightness key-presses even though they are the only ones reporting
these presses.

Reported-by: Stefan Seyfried <seife+kernel@b1-systems.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/acpi_video.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 01c3f62295c3..be7f4d1912de 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -79,6 +79,7 @@ module_param(device_id_scheme, bool, 0444);
 static int only_lcd = -1;
 module_param(only_lcd, int, 0444);
 
+static bool has_backlight;
 static int register_count;
 static DEFINE_MUTEX(register_count_mutex);
 static DEFINE_MUTEX(video_list_lock);
@@ -1230,6 +1231,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 	acpi_video_device_bind(video, data);
 	acpi_video_device_find_cap(data);
 
+	if (data->cap._BCM && data->cap._BCL)
+		has_backlight = true;
+
 	mutex_lock(&video->device_list_lock);
 	list_add_tail(&data->entry, &video->video_device_list);
 	mutex_unlock(&video->device_list_lock);
@@ -2276,6 +2280,7 @@ void acpi_video_unregister(void)
 		cancel_delayed_work_sync(&video_bus_register_backlight_work);
 		acpi_bus_unregister_driver(&acpi_video_bus);
 		register_count = 0;
+		has_backlight = false;
 	}
 	mutex_unlock(&register_count_mutex);
 }
@@ -2294,13 +2299,7 @@ EXPORT_SYMBOL(acpi_video_register_backlight);
 
 bool acpi_video_handles_brightness_key_presses(void)
 {
-	bool have_video_busses;
-
-	mutex_lock(&video_list_lock);
-	have_video_busses = !list_empty(&video_bus_head);
-	mutex_unlock(&video_list_lock);
-
-	return have_video_busses &&
+	return has_backlight &&
 	       (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS);
 }
 EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses);
-- 
2.36.0


  reply	other threads:[~2022-06-21  9:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 18:14 [PATCH 0/9] platform/x86: panasonic-laptop: add optical drive, brightness and battery charging threshold Kenneth Chan
2020-08-21 18:14 ` [PATCH 1/9] add support for optical driver power in Y and W series Kenneth Chan
2020-11-10 14:00   ` Hans de Goede
2020-08-21 18:14 ` [PATCH 2/9] replace ACPI prints with pr_*() macros Kenneth Chan
2020-08-21 18:14 ` [PATCH 3/9] split MODULE_AUTHOR() by one author per macro call Kenneth Chan
2020-08-21 18:14 ` [PATCH 4/9] fix naming of platform files for consistency with other modules Kenneth Chan
2020-08-21 18:14 ` [PATCH 5/9] fix sticky key init bug Kenneth Chan
2020-08-21 18:14 ` [PATCH 6/9] add write support to mute Kenneth Chan
2020-08-21 18:14 ` [PATCH 7/9] resolve hotkey double trigger bug Kenneth Chan
2022-06-12  9:05   ` [PATCH 0/2] fix panasonic-laptop hotkey regression stefan.seyfried
2022-06-12  9:05     ` [PATCH 1/2] platform/x86: panasonic-laptop: de-obfuscate button codes stefan.seyfried
2022-06-12  9:05     ` [PATCH 2/2] platform/x86: panasonic-laptop: allow to use all hotkeys stefan.seyfried
2022-06-15 10:53       ` Kenneth Chan
2022-06-15 11:21       ` Andy Shevchenko
2022-06-15 11:24         ` Andy Shevchenko
2022-06-15 17:10           ` Stefan Seyfried
2022-06-15 19:28             ` Hans de Goede
2022-06-16 18:38               ` Kenneth Chan
2022-06-16 19:03               ` Andy Shevchenko
2022-06-17  7:51               ` Kenneth Chan
2022-06-17 11:07                 ` Hans de Goede
2022-06-17 13:07                   ` Stefan Seyfried
2022-06-20 15:08                     ` Hans de Goede
2022-06-20 18:10                       ` Stefan Seyfried
2022-06-21  9:26                         ` Hans de Goede
2022-06-21 10:23                           ` Stefan Seyfried
2022-06-21 17:54                             ` Stefan Seyfried
2022-06-22 10:57                               ` Hans de Goede
2022-06-20 15:21                   ` Kenneth Chan
2022-06-21  9:34                     ` Hans de Goede [this message]
2022-06-24  5:14                       ` Kenneth Chan
2022-06-24  9:24                         ` Hans de Goede
2020-08-21 18:14 ` [PATCH 8/9] add support for battery charging threshold (eco mode) Kenneth Chan
2020-08-21 18:14 ` [PATCH 9/9] add platform devices for firmware brightness registers Kenneth Chan
2020-08-22  7:29 ` [PATCH 0/9] platform/x86: panasonic-laptop: add optical drive, brightness and battery charging threshold Harald Welte
2020-08-22  8:20   ` Andy Shevchenko

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=e5701e68-1b15-97b7-51e4-8d3c8a7c3c86@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=kenneth.t.chan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=seife+kernel@b1-systems.com \
    --cc=stefan.seyfried@googlemail.com \
    /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.