aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus-wmi.c
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/x86/asus-wmi.c
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/x86/asus-wmi.c')
-rw-r--r--drivers/platform/x86/asus-wmi.c33
1 files changed, 20 insertions, 13 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);