Re: [PATCH] asus-wmi: add display toggle quirk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, Sep 18, 2012 at 2:48 AM, AceLan Kao <acelan.kao@xxxxxxxxxxxxx> wrote:
> For machines with AMD graphic chips, it will send out WMI event and ACPI
> interrupt at the same time while hitting the hotkey. BIOS will notify the
> system the next display output mode throught WMI event code, so that
> windows' application can show an OSD to tell the user which mode will be
> taken effect. User can hit the display toggle key many times within 2
> seconds to choose the mode they want. After 2 seconds, WMI dirver should
> send a WMIMethod(SDSP) command to tell the BIOS which mode the user chose.
> And then BIOS will raise another ACPI interrupt to tell the system to
> really switch the display mode.
>
> In Linux desktop, we don't have this kind of OSD to let users to choose
> the mode they want, so we don't need to call WMIMethod(SDSP) to have
> another ACPI interrupt. To simplify the problem, we just have to ignore
> the WMI event, and let the first ACPI interrupt to send out the key event.
>
> For the need, here comes another quirk to add machines with this kind of
> behavior. When the WMI driver receives the display toggle WMI event, and
> found the machin is in the list, it will do nothing and let ACPI video
> driver to report the key event.

Could you add part of this explanation as a comment in the code ?
By the way, maybe we should have done the same for other quirks...

(ps: I collected all the previous patch, will send them before next
merge windows as a single series)

> Signed-off-by: AceLan Kao <acelan.kao@xxxxxxxxxxxxx>
> ---
>  drivers/platform/x86/asus-nb-wmi.c |   26 +++++++++++++++++++++++++-
>  drivers/platform/x86/asus-wmi.c    |   19 +++++++++++++++++++
>  drivers/platform/x86/asus-wmi.h    |    2 ++
>  3 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
> index 6b0ebde..09ac9e4 100644
> --- a/drivers/platform/x86/asus-nb-wmi.c
> +++ b/drivers/platform/x86/asus-nb-wmi.c
> @@ -59,6 +59,12 @@ static struct quirk_entry quirk_asus_unknown = {
>         .wapf = 0,
>  };
>
> +static struct quirk_entry quirk_asus_x55u = {
> +       .wapf = 4,
> +       .wmi_backlight_power = true,
> +       .no_display_toggle = true,
> +};
> +
>  static struct quirk_entry quirk_asus_x401u = {
>         .wapf = 4,
>  };
> @@ -77,6 +83,15 @@ static struct dmi_system_id asus_quirks[] = {
>                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>                         DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
>                 },
> +               .driver_data = &quirk_asus_x55u,
> +       },
> +       {
> +               .callback = dmi_matched,
> +               .ident = "ASUSTeK COMPUTER INC. X401A",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "X401A"),
> +               },
>                 .driver_data = &quirk_asus_x401u,
>         },
>         {
> @@ -95,6 +110,15 @@ static struct dmi_system_id asus_quirks[] = {
>                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>                         DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
>                 },
> +               .driver_data = &quirk_asus_x55u,
> +       },
> +       {
> +               .callback = dmi_matched,
> +               .ident = "ASUSTeK COMPUTER INC. X501A",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "X501A"),
> +               },
>                 .driver_data = &quirk_asus_x401u,
>         },
>         {
> @@ -131,7 +155,7 @@ static struct dmi_system_id asus_quirks[] = {
>                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>                         DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
>                 },
> -               .driver_data = &quirk_asus_x401u,
> +               .driver_data = &quirk_asus_x55u,
>         },
>         {
>                 .callback = dmi_matched,
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 18f5169..526d713 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -1341,6 +1341,22 @@ static void asus_wmi_backlight_exit(struct asus_wmi *asus)
>         asus->backlight_device = NULL;
>  }
>
> +static int is_display_toggle(int code)
> +{
> +       if ((code >= 0x61 && code <= 0x67) ||
> +           (code >= 0x8c && code <= 0x93) ||
> +           (code >= 0xa0 && code <= 0xa7) ||
> +           (code >= 0xd0 && code <= 0xd5))
> +               return 1;
> +
> +       return 0;
> +}
> +
> +static void do_nothing(void)
> +{
> +       return;
> +}
> +
>  static void asus_wmi_notify(u32 value, void *context)
>  {
>         struct asus_wmi *asus = context;
> @@ -1382,6 +1398,9 @@ static void asus_wmi_notify(u32 value, void *context)
>         if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) {
>                 if (!acpi_video_backlight_support())
>                         asus_wmi_backlight_notify(asus, orig_code);
> +       } else if (is_display_toggle(code) &&
> +                  asus->driver->quirks->no_display_toggle) {
> +               do_nothing();
>         } else if (!sparse_keymap_report_event(asus->inputdev, code,
>                                                key_value, autorelease))
>                 pr_info("Unknown key %x pressed\n", code);
> diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
> index 4c9bd38..10b9758 100644
> --- a/drivers/platform/x86/asus-wmi.h
> +++ b/drivers/platform/x86/asus-wmi.h
> @@ -41,12 +41,14 @@ struct quirk_entry {
>         bool store_backlight_power;
>         bool wmi_backlight_power;
>         int wapf;
> +       int no_display_toggle;
>  };
>
>  struct asus_wmi_driver {
>         int                     brightness;
>         int                     panel_power;
>         int                     wlan_ctrl_by_user;
> +       int                     no_display_toggle;
>
>         const char              *name;
>         struct module           *owner;
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux