aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAceLan Kao <acelan.kao@canonical.com>2012-03-20 04:53:09 -0400
committerMatthew Garrett <mjg@redhat.com>2012-03-26 15:05:43 -0400
commit6e0044bedc1fc94a61cc32fa25dcab9a4e4a9218 (patch)
treec3f6c0ee73a93f7ae8bb9fdfd448c189d0250511 /drivers/platform
parentc87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17 (diff)
asus-wmi: store backlight power status for AIO machine
Due to some implementation reasons, ASUS ET2012 All-in-One machines can't report the correct backlight power status, it will always return 1. To track the backlight power status correctly, we have to store the status by ourselves. BTW, by the BIOS design, the backlight power will be turn on/off sequently, no matter what the value of the parameter will be. More over, the brightness adjustment command will turn on the backlight power. Those behaviors will make us fail to track the backlight power status. For example, While we are trying to turn on the backlight power, we will send out the brightness adjustment command and then trying to figure out if we have to turn on the backlight power, then send out the command. But, the real case is that, the backlight power turns on while sending the brightness adjustment command, and then we send out the command to turn on the backlight power, it actually will turn off the backlight power and the backlight power status we recorded becomes wrong. So, we have to seperate these two commands by a if statement. Signed-off-by: AceLan Kao <acelan.kao@canonical.com> Signed-off-by: Corentin Chary <corentin.chary@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/asus-wmi.c33
-rw-r--r--drivers/platform/x86/asus-wmi.h2
-rw-r--r--drivers/platform/x86/eeepc-wmi.c15
3 files changed, 34 insertions, 16 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index eb114f8d39e7..c4ad76ee7b5f 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1076,7 +1076,12 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
1076 */ 1076 */
1077static int read_backlight_power(struct asus_wmi *asus) 1077static int read_backlight_power(struct asus_wmi *asus)
1078{ 1078{
1079 int ret = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_BACKLIGHT); 1079 int ret;
1080 if (asus->driver->quirks->store_backlight_power)
1081 ret = !asus->driver->panel_power;
1082 else
1083 ret = asus_wmi_get_devstate_simple(asus,
1084 ASUS_WMI_DEVID_BACKLIGHT);
1080 1085
1081 if (ret < 0) 1086 if (ret < 0)
1082 return ret; 1087 return ret;
@@ -1138,24 +1143,23 @@ static int update_bl_status(struct backlight_device *bd)
1138{ 1143{
1139 struct asus_wmi *asus = bl_get_data(bd); 1144 struct asus_wmi *asus = bl_get_data(bd);
1140 u32 ctrl_param; 1145 u32 ctrl_param;
1141 int power, err; 1146 int power, err = 0;
1142
1143 if (asus->driver->quirks->scalar_panel_brightness)
1144 ctrl_param = get_scalar_command(bd);
1145 else
1146 ctrl_param = bd->props.brightness;
1147
1148 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS,
1149 ctrl_param, NULL);
1150
1151 if (err < 0)
1152 return err;
1153 1147
1154 power = read_backlight_power(asus); 1148 power = read_backlight_power(asus);
1155 if (power != -ENODEV && bd->props.power != power) { 1149 if (power != -ENODEV && bd->props.power != power) {
1156 ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK); 1150 ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK);
1157 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 1151 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT,
1158 ctrl_param, NULL); 1152 ctrl_param, NULL);
1153 if (asus->driver->quirks->store_backlight_power)
1154 asus->driver->panel_power = bd->props.power;
1155 } else {
1156 if (asus->driver->quirks->scalar_panel_brightness)
1157 ctrl_param = get_scalar_command(bd);
1158 else
1159 ctrl_param = bd->props.brightness;
1160
1161 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS,
1162 ctrl_param, NULL);
1159 } 1163 }
1160 return err; 1164 return err;
1161} 1165}
@@ -1217,6 +1221,9 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
1217 1221
1218 asus->backlight_device = bd; 1222 asus->backlight_device = bd;
1219 1223
1224 if (asus->driver->quirks->store_backlight_power)
1225 asus->driver->panel_power = power;
1226
1220 bd->props.brightness = read_brightness(bd); 1227 bd->props.brightness = read_brightness(bd);
1221 bd->props.power = power; 1228 bd->props.power = power;
1222 backlight_update_status(bd); 1229 backlight_update_status(bd);
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index ac7dd4eaebd0..35003e4f1316 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -38,11 +38,13 @@ struct asus_wmi;
38struct quirk_entry { 38struct quirk_entry {
39 bool hotplug_wireless; 39 bool hotplug_wireless;
40 bool scalar_panel_brightness; 40 bool scalar_panel_brightness;
41 bool store_backlight_power;
41}; 42};
42 43
43struct asus_wmi_driver { 44struct asus_wmi_driver {
44 int wapf; 45 int wapf;
45 int brightness; 46 int brightness;
47 int panel_power;
46 48
47 const char *name; 49 const char *name;
48 struct module *owner; 50 struct module *owner;
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 67186e6ca28d..9f8ccf9f590d 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -32,6 +32,7 @@
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/input/sparse-keymap.h> 33#include <linux/input/sparse-keymap.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/fb.h>
35#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
36 37
37#include "asus-wmi.h" 38#include "asus-wmi.h"
@@ -98,8 +99,13 @@ static struct quirk_entry quirk_asus_1000h = {
98 .hotplug_wireless = true, 99 .hotplug_wireless = true,
99}; 100};
100 101
102static struct quirk_entry quirk_asus_et2012_type1 = {
103 .store_backlight_power = true,
104};
105
101static struct quirk_entry quirk_asus_et2012_type3 = { 106static struct quirk_entry quirk_asus_et2012_type3 = {
102 .scalar_panel_brightness = true, 107 .scalar_panel_brightness = true,
108 .store_backlight_power = true,
103}; 109};
104 110
105static int dmi_matched(const struct dmi_system_id *dmi) 111static int dmi_matched(const struct dmi_system_id *dmi)
@@ -111,10 +117,12 @@ static int dmi_matched(const struct dmi_system_id *dmi)
111 if (unlikely(strncmp(model, "ET2012", 6) == 0)) { 117 if (unlikely(strncmp(model, "ET2012", 6) == 0)) {
112 const struct dmi_device *dev = NULL; 118 const struct dmi_device *dev = NULL;
113 char oemstring[30]; 119 char oemstring[30];
114 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, 120 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
115 dev))) { 121 NULL, dev))) {
116 if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) { 122 if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
117 if (oemstring[18] == '3') 123 if (oemstring[18] == '1')
124 quirks = &quirk_asus_et2012_type1;
125 else if (oemstring[18] == '3')
118 quirks = &quirk_asus_et2012_type3; 126 quirks = &quirk_asus_et2012_type3;
119 break; 127 break;
120 } 128 }
@@ -202,6 +210,7 @@ static int eeepc_wmi_probe(struct platform_device *pdev)
202static void eeepc_wmi_quirks(struct asus_wmi_driver *driver) 210static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
203{ 211{
204 driver->wapf = -1; 212 driver->wapf = -1;
213 driver->panel_power = FB_BLANK_UNBLANK;
205 driver->quirks = &quirk_asus_unknown; 214 driver->quirks = &quirk_asus_unknown;
206 driver->quirks->hotplug_wireless = hotplug_wireless; 215 driver->quirks->hotplug_wireless = hotplug_wireless;
207 dmi_check_system(asus_quirks); 216 dmi_check_system(asus_quirks);