Re: [PATCH] asus-wmi: control backlight power through WMI, not ACPI

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

 



On Wed, May 16, 2012 at 11:39 AM, AceLan Kao <acelan.kao@xxxxxxxxxxxxx> wrote:
> BugLink: https://bugs.launchpad.net/bugs/1000146
>
> Some h/w that can adjust screen brightness through ACPI functions, but
> can't turn on/off the backlight power correctly. So, we list those h/w in
> quirks and try to turn on/off the backlight power through WMI.
> Signed-off-by: AceLan Kao <acelan.kao@xxxxxxxxxxxxx>
> ---
>  drivers/platform/x86/asus-wmi.c  |    9 ++++++++-
>  drivers/platform/x86/asus-wmi.h  |    1 +
>  drivers/platform/x86/eeepc-wmi.c |   23 +++++++++++++++++++++++
>  3 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 77aadde..beda7fc 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
>  #define NOTIFY_BRNDOWN_MAX             0x2e
>  #define NOTIFY_KBD_BRTUP               0xc4
>  #define NOTIFY_KBD_BRTDWN              0xc5
> +#define NOTIFY_BACKLIGHT_POWER         0xe9
>
>  /* WMI Methods */
>  #define ASUS_WMI_METHODID_SPEC         0x43455053 /* BIOS SPECification */
> @@ -1288,6 +1289,11 @@ 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 (asus->driver->quirks->wmi_backlight_power &&
> +                  code == NOTIFY_BACKLIGHT_POWER) {
> +               struct backlight_device *bd = asus->backlight_device;
> +               bd->props.power = !bd->props.power;
> +               backlight_update_status(bd);
>        } else if (!sparse_keymap_report_event(asus->inputdev, code,
>                                               key_value, autorelease))
>                pr_info("Unknown key %x pressed\n", code);
> @@ -1681,7 +1687,8 @@ static int asus_wmi_add(struct platform_device *pdev)
>        if (err)
>                goto fail_rfkill;
>
> -       if (!acpi_video_backlight_support()) {
> +       if (!acpi_video_backlight_support() ||
> +           asus->driver->quirks->wmi_backlight_power) {

So you override any acpi_backlight=[vendor|video] settings ? That
doesn't looks right.
Can't you just send KEY_DISPLAYTOGGLE when the key is pressed, and let
userspace adjust the proper /sys/class/backlight file ?

What does the key do exactly without driver ? Does it just send a
notification or does it also poke the hardware ?


>                err = asus_wmi_backlight_init(asus);
>                if (err && err != -ENODEV)
>                        goto fail_backlight;
> diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
> index d43b667..9c1da8b 100644
> --- a/drivers/platform/x86/asus-wmi.h
> +++ b/drivers/platform/x86/asus-wmi.h
> @@ -39,6 +39,7 @@ struct quirk_entry {
>        bool hotplug_wireless;
>        bool scalar_panel_brightness;
>        bool store_backlight_power;
> +       bool wmi_backlight_power;
>        int wapf;
>  };
>
> diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
> index 6567613..8d31f4e 100644
> --- a/drivers/platform/x86/eeepc-wmi.c
> +++ b/drivers/platform/x86/eeepc-wmi.c
> @@ -107,6 +107,11 @@ static struct quirk_entry quirk_asus_et2012_type3 = {
>        .store_backlight_power = true,
>  };
>
> +static struct quirk_entry quirk_asus_x101ch = {
> +       /* We need this when ACPI function doesn't do this well */
> +       .wmi_backlight_power = true,
> +};
> +
>  static struct quirk_entry *quirks;
>
>  static void et2012_quirks(void)
> @@ -157,6 +162,24 @@ static struct dmi_system_id asus_quirks[] = {
>                },
>                .driver_data = &quirk_asus_unknown,
>        },
> +       {
> +               .callback = dmi_matched,
> +               .ident = "ASUSTeK Computer INC. X101CH",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
> +               },
> +               .driver_data = &quirk_asus_x101ch,
> +       },
> +       {
> +               .callback = dmi_matched,
> +               .ident = "ASUSTeK Computer INC. 1015CX",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
> +               },
> +               .driver_data = &quirk_asus_x101ch,
> +       },
>        {},
>  };
>
> --
> 1.7.9.5
>
> --
> 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