aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus-wmi.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 17:20:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 17:20:23 -0400
commit61e5191c9d96268746bd57ed55d035678a1a2cf9 (patch)
tree5ee75dc9aa9eab9cfc41c9fe0042d15f000ef2e6 /drivers/platform/x86/asus-wmi.c
parentd2a2fc18d98d8ee2dec1542efc7f47beec256144 (diff)
parent86924de2a612b275a45e92ba80d6f47d4e97d620 (diff)
Merge branch 'for_linus' of git://cavan.codon.org.uk/platform-drivers-x86
Pull x86 platform driver updates from Matthew Garrett: "Some significant updates to samsung-laptop, additional hardware support for Toshibas, misc updates to various hardware and a new backlight driver for some Apple machines." Fix up trivial conflicts: geode Geos update happening next to net5501 support, and MSIC thermal platform support added twice. * 'for_linus' of git://cavan.codon.org.uk/platform-drivers-x86: (77 commits) acer-wmi: add quirk table for video backlight vendor mode drivers/platform/x86/amilo-rfkill.c::amilo_rfkill_probe() avoid NULL deref samsung-laptop: unregister ACPI video module for some well known laptops acer-wmi: No wifi rfkill on Sony machines thinkpad-acpi: recognize Lenovo as version string in newer V-series BIOS asus-wmi: don't update power and brightness when using scalar eeepc-wmi: split et2012 specific hacks eeepc-wmi: refine quirks handling asus-nb-wmi: set panel_power correctly asus-wmi: move WAPF variable into quirks_entry asus-wmi: store backlight power status for AIO machine asus-wmi: add scalar board brightness adj. support samsung-laptop: cleanup return type: mode_t vs umode_t drivers, samsung-laptop: fix usage of isalnum drivers, samsung-laptop: fix initialization of sabi_data in sabi_set_commandb asus-wmi: on/off bit is not set when reading the value eeepc-wmi: add extra keymaps for EP121 asus-nb-wmi: ignore useless keys acer-wmi: support Lenovo ideapad S205 Brazos wifi switch acer-wmi: fix out of input parameter size when set ...
Diffstat (limited to 'drivers/platform/x86/asus-wmi.c')
-rw-r--r--drivers/platform/x86/asus-wmi.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 9929246895de..77aadde5281c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -411,7 +411,7 @@ static int kbd_led_read(struct asus_wmi *asus, int *level, int *env)
411 411
412 if (retval >= 0) { 412 if (retval >= 0) {
413 if (level) 413 if (level)
414 *level = retval & 0x80 ? retval & 0x7F : 0; 414 *level = retval & 0x7F;
415 if (env) 415 if (env)
416 *env = (retval >> 8) & 0x7F; 416 *env = (retval >> 8) & 0x7F;
417 retval = 0; 417 retval = 0;
@@ -784,7 +784,8 @@ static int asus_new_rfkill(struct asus_wmi *asus,
784 arfkill->dev_id = dev_id; 784 arfkill->dev_id = dev_id;
785 arfkill->asus = asus; 785 arfkill->asus = asus;
786 786
787 if (dev_id == ASUS_WMI_DEVID_WLAN && asus->driver->hotplug_wireless) 787 if (dev_id == ASUS_WMI_DEVID_WLAN &&
788 asus->driver->quirks->hotplug_wireless)
788 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, 789 *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type,
789 &asus_rfkill_wlan_ops, arfkill); 790 &asus_rfkill_wlan_ops, arfkill);
790 else 791 else
@@ -895,7 +896,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus)
895 if (result && result != -ENODEV) 896 if (result && result != -ENODEV)
896 goto exit; 897 goto exit;
897 898
898 if (!asus->driver->hotplug_wireless) 899 if (!asus->driver->quirks->hotplug_wireless)
899 goto exit; 900 goto exit;
900 901
901 result = asus_setup_pci_hotplug(asus); 902 result = asus_setup_pci_hotplug(asus);
@@ -1075,7 +1076,12 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
1075 */ 1076 */
1076static int read_backlight_power(struct asus_wmi *asus) 1077static int read_backlight_power(struct asus_wmi *asus)
1077{ 1078{
1078 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);
1079 1085
1080 if (ret < 0) 1086 if (ret < 0)
1081 return ret; 1087 return ret;
@@ -1116,26 +1122,51 @@ static int read_brightness(struct backlight_device *bd)
1116 return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK; 1122 return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
1117} 1123}
1118 1124
1119static int update_bl_status(struct backlight_device *bd) 1125static u32 get_scalar_command(struct backlight_device *bd)
1120{ 1126{
1121 struct asus_wmi *asus = bl_get_data(bd); 1127 struct asus_wmi *asus = bl_get_data(bd);
1122 u32 ctrl_param; 1128 u32 ctrl_param = 0;
1123 int power, err;
1124 1129
1125 ctrl_param = bd->props.brightness; 1130 if ((asus->driver->brightness < bd->props.brightness) ||
1131 bd->props.brightness == bd->props.max_brightness)
1132 ctrl_param = 0x00008001;
1133 else if ((asus->driver->brightness > bd->props.brightness) ||
1134 bd->props.brightness == 0)
1135 ctrl_param = 0x00008000;
1126 1136
1127 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS, 1137 asus->driver->brightness = bd->props.brightness;
1128 ctrl_param, NULL);
1129 1138
1130 if (err < 0) 1139 return ctrl_param;
1131 return err; 1140}
1141
1142static int update_bl_status(struct backlight_device *bd)
1143{
1144 struct asus_wmi *asus = bl_get_data(bd);
1145 u32 ctrl_param;
1146 int power, err = 0;
1132 1147
1133 power = read_backlight_power(asus); 1148 power = read_backlight_power(asus);
1134 if (power != -ENODEV && bd->props.power != power) { 1149 if (power != -ENODEV && bd->props.power != power) {
1135 ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK); 1150 ctrl_param = !!(bd->props.power == FB_BLANK_UNBLANK);
1136 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 1151 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT,
1137 ctrl_param, NULL); 1152 ctrl_param, NULL);
1153 if (asus->driver->quirks->store_backlight_power)
1154 asus->driver->panel_power = bd->props.power;
1155
1156 /* When using scalar brightness, updating the brightness
1157 * will mess with the backlight power */
1158 if (asus->driver->quirks->scalar_panel_brightness)
1159 return err;
1138 } 1160 }
1161
1162 if (asus->driver->quirks->scalar_panel_brightness)
1163 ctrl_param = get_scalar_command(bd);
1164 else
1165 ctrl_param = bd->props.brightness;
1166
1167 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS,
1168 ctrl_param, NULL);
1169
1139 return err; 1170 return err;
1140} 1171}
1141 1172
@@ -1196,10 +1227,15 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus)
1196 1227
1197 asus->backlight_device = bd; 1228 asus->backlight_device = bd;
1198 1229
1230 if (asus->driver->quirks->store_backlight_power)
1231 asus->driver->panel_power = power;
1232
1199 bd->props.brightness = read_brightness(bd); 1233 bd->props.brightness = read_brightness(bd);
1200 bd->props.power = power; 1234 bd->props.power = power;
1201 backlight_update_status(bd); 1235 backlight_update_status(bd);
1202 1236
1237 asus->driver->brightness = bd->props.brightness;
1238
1203 return 0; 1239 return 0;
1204} 1240}
1205 1241
@@ -1441,9 +1477,9 @@ static int asus_wmi_platform_init(struct asus_wmi *asus)
1441 1477
1442 /* CWAP allow to define the behavior of the Fn+F2 key, 1478 /* CWAP allow to define the behavior of the Fn+F2 key,
1443 * this method doesn't seems to be present on Eee PCs */ 1479 * this method doesn't seems to be present on Eee PCs */
1444 if (asus->driver->wapf >= 0) 1480 if (asus->driver->quirks->wapf >= 0)
1445 asus_wmi_set_devstate(ASUS_WMI_DEVID_CWAP, 1481 asus_wmi_set_devstate(ASUS_WMI_DEVID_CWAP,
1446 asus->driver->wapf, NULL); 1482 asus->driver->quirks->wapf, NULL);
1447 1483
1448 return asus_wmi_sysfs_init(asus->platform_device); 1484 return asus_wmi_sysfs_init(asus->platform_device);
1449} 1485}
@@ -1622,8 +1658,8 @@ static int asus_wmi_add(struct platform_device *pdev)
1622 wdrv->platform_device = pdev; 1658 wdrv->platform_device = pdev;
1623 platform_set_drvdata(asus->platform_device, asus); 1659 platform_set_drvdata(asus->platform_device, asus);
1624 1660
1625 if (wdrv->quirks) 1661 if (wdrv->detect_quirks)
1626 wdrv->quirks(asus->driver); 1662 wdrv->detect_quirks(asus->driver);
1627 1663
1628 err = asus_wmi_platform_init(asus); 1664 err = asus_wmi_platform_init(asus);
1629 if (err) 1665 if (err)