linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"Zhang Rui" <rui.zhang@intel.com>, "Len Brown" <lenb@kernel.org>,
	"Darren Hart" <dvhart@infradead.org>,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Henrique de Moraes Holschuh" <ibm-acpi@hmh.eng.br>,
	"Michał Kępień" <kernel@kempniu.pl>,
	linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	acpi4asus-user@lists.sourceforge.net,
	ibm-acpi-devel@lists.sourceforge.net
Subject: Re: [PATCH 3/5] thinkpad_acpi: Use acpi_video_handles_brightness_key_presses()
Date: Tue, 29 Dec 2015 13:27:43 +0100	[thread overview]
Message-ID: <56827C3F.8090509@redhat.com> (raw)
In-Reply-To: <20151227230812.GA8731@khazad-dum.debian.net>

Hi,

On 28-12-15 00:08, Henrique de Moraes Holschuh wrote:
> On Tue, 22 Dec 2015, Hans de Goede wrote:
>> Use the new acpi_video_handles_brightness_key_presses function to check
>> if we should report brightness key-presses.
>>
>> This makes the code both easier to read and makes it properly report
>> key-presses when acpi-video is not reporting them for reasons other
>> then the backlight type being vendor.
>
> If this new function will return false when acpi video is not reporting
> keypresses *BUT* still allowing any sort of brightness changes (e.g. through
> sysfs), I don't think it is safe in thinkpad-acpi's case.

Have you closely looked at the patch? It only applies to this bit of
thinkpad-acpi code:

         /* Do not issue duplicate brightness change events to
          * userspace. tpacpi_detect_brightness_capabilities() must have
          * been called before this point  */
         if (acpi_video_handles_brightness_key_presses()) {
                 pr_info("This ThinkPad has standard ACPI backlight "
                         "brightness control, supported by the ACPI "
                         "video driver\n");
                 pr_notice("Disabling thinkpad-acpi brightness events "
                           "by default...\n");

                 /* Disable brightness up/down on Lenovo thinkpads when
                  * ACPI is handling them, otherwise it is plain impossible
                  * for userspace to do something even remotely sane */
                 hotkey_reserved_mask |=
                         (1 << TP_ACPI_HOTKEYSCAN_FNHOME)
                         | (1 << TP_ACPI_HOTKEYSCAN_FNEND);
                 hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNHOME);
                 hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNEND);
         }

So it only disables hotkey press reporting, not to the thinkpad_acpi
backlight handling code, that still is using acpi_video_get_backlight_type()  :

         if (acpi_video_get_backlight_type() != acpi_backlight_vendor) {
                 if (brightness_enable > 1) {
                         pr_info("Standard ACPI backlight interface "
                                 "available, not loading native one\n");
                         return 1;
                 } else if (brightness_enable == 1) {
                         pr_warn("Cannot enable backlight brightness support, "
                                 "ACPI is already handling it.  Refer to the "
                                 "acpi_backlight kernel parameter.\n");
                         return 1;
                 }
         } else if (tp_features.bright_acpimode && brightness_enable > 1) {
                 pr_notice("Standard ACPI backlight interface not "
                           "available, thinkpad_acpi native "
                           "brightness control enabled\n");
         }

> So, will it return false in any situation whether acpi-video attached to the
> backlight class?

When the new video.report_key_events kernel cmdline option gets manually set to
a non default value then yes it may report false while acpi-video is attached
to the backlight class. By default, no it will never return false when acpi-video
is attached to the backlight class.

This should not matter though, as said this new function is only used to suppress
the reporting of key-presses. I realize that doing so will also cause
tpacpi_driver_event() to get called on brightness hotkey presses, but that has:

         if (ibm_backlight_device) {
                 switch (hkey_event) {
                 case TP_HKEY_EV_BRGHT_UP:
                 case TP_HKEY_EV_BRGHT_DOWN:
                         tpacpi_brightness_notify_change();
                 }
         }

And the creating of ibm_backlight_device is still protected by

if (acpi_video_get_backlight_type() != acpi_backlight_vendor) return 1;

So this new check really does nothing other then NOT suppress the hotkey presses
reported by thinkpad-acpi when for some reason a user has asked acpi-video to
suppress its reporting of hotkey presses, which is exactly what it should do.

IMHO this only shows that having a separate function to detect if acpi-video
is reporting keypresses is the right thing to do.

Regards,

Hans

  reply	other threads:[~2015-12-29 12:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 18:09 [PATCH 0/5] acpi-video and platform/x86 driver fixes Hans de Goede
2015-12-22 18:09 ` [PATCH 1/5] acpi-video: Add a acpi_video_handles_brightness_key_presses() helper Hans de Goede
2015-12-22 18:09 ` [PATCH 2/5] dell-wmi: Use acpi_video_handles_brightness_key_presses() Hans de Goede
2015-12-22 19:53   ` Darren Hart
2015-12-24 10:04     ` Pali Rohár
2015-12-22 18:09 ` [PATCH 3/5] thinkpad_acpi: " Hans de Goede
2015-12-27 23:08   ` Henrique de Moraes Holschuh
2015-12-29 12:27     ` Hans de Goede [this message]
2015-12-30 17:28       ` Henrique de Moraes Holschuh
2015-12-22 18:09 ` [PATCH 4/5] acpi-video: Add a module option to disable the reporting of keypresses Hans de Goede
2015-12-22 20:09   ` Darren Hart
2015-12-22 18:09 ` [PATCH 5/5] acpi-video: Add quirks for the Dell Vostro V131 Hans de Goede
2015-12-22 21:00 ` [PATCH 0/5] acpi-video and platform/x86 driver fixes Darren Hart
2016-01-03  0:37 ` Rafael J. Wysocki

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=56827C3F.8090509@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentin.chary@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ibm-acpi@hmh.eng.br \
    --cc=kernel@kempniu.pl \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).