aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/wistron_btns.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/wistron_btns.c')
-rw-r--r--drivers/input/misc/wistron_btns.c84
1 files changed, 54 insertions, 30 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 27ee976eb54c..11fd038a078f 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -243,9 +243,9 @@ enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
243#define FE_UNTESTED 0x80 243#define FE_UNTESTED 0x80
244 244
245static struct key_entry *keymap; /* = NULL; Current key map */ 245static struct key_entry *keymap; /* = NULL; Current key map */
246static int have_wifi; 246static bool have_wifi;
247static int have_bluetooth; 247static bool have_bluetooth;
248static int have_leds; 248static int leds_present; /* bitmask of leds present */
249 249
250static int __init dmi_matched(const struct dmi_system_id *dmi) 250static int __init dmi_matched(const struct dmi_system_id *dmi)
251{ 251{
@@ -254,11 +254,11 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
254 keymap = dmi->driver_data; 254 keymap = dmi->driver_data;
255 for (key = keymap; key->type != KE_END; key++) { 255 for (key = keymap; key->type != KE_END; key++) {
256 if (key->type == KE_WIFI) 256 if (key->type == KE_WIFI)
257 have_wifi = 1; 257 have_wifi = true;
258 else if (key->type == KE_BLUETOOTH) 258 else if (key->type == KE_BLUETOOTH)
259 have_bluetooth = 1; 259 have_bluetooth = true;
260 } 260 }
261 have_leds = key->code & (FE_MAIL_LED | FE_WIFI_LED); 261 leds_present = key->code & (FE_MAIL_LED | FE_WIFI_LED);
262 262
263 return 1; 263 return 1;
264} 264}
@@ -611,10 +611,24 @@ static struct key_entry keymap_wistron_generic[] __initdata = {
611 { KE_END, 0 } 611 { KE_END, 0 }
612}; 612};
613 613
614static struct key_entry keymap_aopen_1557[] __initdata = {
615 { KE_KEY, 0x01, {KEY_HELP} },
616 { KE_KEY, 0x11, {KEY_PROG1} },
617 { KE_KEY, 0x12, {KEY_PROG2} },
618 { KE_WIFI, 0x30 },
619 { KE_KEY, 0x22, {KEY_REWIND} },
620 { KE_KEY, 0x23, {KEY_FORWARD} },
621 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
622 { KE_KEY, 0x25, {KEY_STOPCD} },
623 { KE_KEY, 0x31, {KEY_MAIL} },
624 { KE_KEY, 0x36, {KEY_WWW} },
625 { KE_END, 0 }
626};
627
614static struct key_entry keymap_prestigio[] __initdata = { 628static struct key_entry keymap_prestigio[] __initdata = {
615 { KE_KEY, 0x11, {KEY_PROG1} }, 629 { KE_KEY, 0x11, {KEY_PROG1} },
616 { KE_KEY, 0x12, {KEY_PROG2} }, 630 { KE_KEY, 0x12, {KEY_PROG2} },
617 { KE_WIFI, 0x30 }, 631 { KE_WIFI, 0x30 },
618 { KE_KEY, 0x22, {KEY_REWIND} }, 632 { KE_KEY, 0x22, {KEY_REWIND} },
619 { KE_KEY, 0x23, {KEY_FORWARD} }, 633 { KE_KEY, 0x23, {KEY_FORWARD} },
620 { KE_KEY, 0x24, {KEY_PLAYPAUSE} }, 634 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
@@ -985,6 +999,8 @@ static int __init select_keymap(void)
985 if (keymap_name != NULL) { 999 if (keymap_name != NULL) {
986 if (strcmp (keymap_name, "1557/MS2141") == 0) 1000 if (strcmp (keymap_name, "1557/MS2141") == 0)
987 keymap = keymap_wistron_ms2141; 1001 keymap = keymap_wistron_ms2141;
1002 else if (strcmp (keymap_name, "aopen1557") == 0)
1003 keymap = keymap_aopen_1557;
988 else if (strcmp (keymap_name, "prestigio") == 0) 1004 else if (strcmp (keymap_name, "prestigio") == 0)
989 keymap = keymap_prestigio; 1005 keymap = keymap_prestigio;
990 else if (strcmp (keymap_name, "generic") == 0) 1006 else if (strcmp (keymap_name, "generic") == 0)
@@ -1009,8 +1025,8 @@ static int __init select_keymap(void)
1009 1025
1010static struct input_polled_dev *wistron_idev; 1026static struct input_polled_dev *wistron_idev;
1011static unsigned long jiffies_last_press; 1027static unsigned long jiffies_last_press;
1012static int wifi_enabled; 1028static bool wifi_enabled;
1013static int bluetooth_enabled; 1029static bool bluetooth_enabled;
1014 1030
1015static void report_key(struct input_dev *dev, unsigned int keycode) 1031static void report_key(struct input_dev *dev, unsigned int keycode)
1016{ 1032{
@@ -1053,24 +1069,24 @@ static struct led_classdev wistron_wifi_led = {
1053 1069
1054static void __devinit wistron_led_init(struct device *parent) 1070static void __devinit wistron_led_init(struct device *parent)
1055{ 1071{
1056 if (have_leds & FE_WIFI_LED) { 1072 if (leds_present & FE_WIFI_LED) {
1057 u16 wifi = bios_get_default_setting(WIFI); 1073 u16 wifi = bios_get_default_setting(WIFI);
1058 if (wifi & 1) { 1074 if (wifi & 1) {
1059 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF; 1075 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
1060 if (led_classdev_register(parent, &wistron_wifi_led)) 1076 if (led_classdev_register(parent, &wistron_wifi_led))
1061 have_leds &= ~FE_WIFI_LED; 1077 leds_present &= ~FE_WIFI_LED;
1062 else 1078 else
1063 bios_set_state(WIFI, wistron_wifi_led.brightness); 1079 bios_set_state(WIFI, wistron_wifi_led.brightness);
1064 1080
1065 } else 1081 } else
1066 have_leds &= ~FE_WIFI_LED; 1082 leds_present &= ~FE_WIFI_LED;
1067 } 1083 }
1068 1084
1069 if (have_leds & FE_MAIL_LED) { 1085 if (leds_present & FE_MAIL_LED) {
1070 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */ 1086 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
1071 wistron_mail_led.brightness = LED_OFF; 1087 wistron_mail_led.brightness = LED_OFF;
1072 if (led_classdev_register(parent, &wistron_mail_led)) 1088 if (led_classdev_register(parent, &wistron_mail_led))
1073 have_leds &= ~FE_MAIL_LED; 1089 leds_present &= ~FE_MAIL_LED;
1074 else 1090 else
1075 bios_set_state(MAIL_LED, wistron_mail_led.brightness); 1091 bios_set_state(MAIL_LED, wistron_mail_led.brightness);
1076 } 1092 }
@@ -1078,28 +1094,28 @@ static void __devinit wistron_led_init(struct device *parent)
1078 1094
1079static void __devexit wistron_led_remove(void) 1095static void __devexit wistron_led_remove(void)
1080{ 1096{
1081 if (have_leds & FE_MAIL_LED) 1097 if (leds_present & FE_MAIL_LED)
1082 led_classdev_unregister(&wistron_mail_led); 1098 led_classdev_unregister(&wistron_mail_led);
1083 1099
1084 if (have_leds & FE_WIFI_LED) 1100 if (leds_present & FE_WIFI_LED)
1085 led_classdev_unregister(&wistron_wifi_led); 1101 led_classdev_unregister(&wistron_wifi_led);
1086} 1102}
1087 1103
1088static inline void wistron_led_suspend(void) 1104static inline void wistron_led_suspend(void)
1089{ 1105{
1090 if (have_leds & FE_MAIL_LED) 1106 if (leds_present & FE_MAIL_LED)
1091 led_classdev_suspend(&wistron_mail_led); 1107 led_classdev_suspend(&wistron_mail_led);
1092 1108
1093 if (have_leds & FE_WIFI_LED) 1109 if (leds_present & FE_WIFI_LED)
1094 led_classdev_suspend(&wistron_wifi_led); 1110 led_classdev_suspend(&wistron_wifi_led);
1095} 1111}
1096 1112
1097static inline void wistron_led_resume(void) 1113static inline void wistron_led_resume(void)
1098{ 1114{
1099 if (have_leds & FE_MAIL_LED) 1115 if (leds_present & FE_MAIL_LED)
1100 led_classdev_resume(&wistron_mail_led); 1116 led_classdev_resume(&wistron_mail_led);
1101 1117
1102 if (have_leds & FE_WIFI_LED) 1118 if (leds_present & FE_WIFI_LED)
1103 led_classdev_resume(&wistron_wifi_led); 1119 led_classdev_resume(&wistron_wifi_led);
1104} 1120}
1105 1121
@@ -1312,7 +1328,7 @@ static int __devinit wistron_probe(struct platform_device *dev)
1312 if (have_wifi) { 1328 if (have_wifi) {
1313 u16 wifi = bios_get_default_setting(WIFI); 1329 u16 wifi = bios_get_default_setting(WIFI);
1314 if (wifi & 1) 1330 if (wifi & 1)
1315 wifi_enabled = (wifi & 2) ? 1 : 0; 1331 wifi_enabled = wifi & 2;
1316 else 1332 else
1317 have_wifi = 0; 1333 have_wifi = 0;
1318 1334
@@ -1323,15 +1339,16 @@ static int __devinit wistron_probe(struct platform_device *dev)
1323 if (have_bluetooth) { 1339 if (have_bluetooth) {
1324 u16 bt = bios_get_default_setting(BLUETOOTH); 1340 u16 bt = bios_get_default_setting(BLUETOOTH);
1325 if (bt & 1) 1341 if (bt & 1)
1326 bluetooth_enabled = (bt & 2) ? 1 : 0; 1342 bluetooth_enabled = bt & 2;
1327 else 1343 else
1328 have_bluetooth = 0; 1344 have_bluetooth = false;
1329 1345
1330 if (have_bluetooth) 1346 if (have_bluetooth)
1331 bios_set_state(BLUETOOTH, bluetooth_enabled); 1347 bios_set_state(BLUETOOTH, bluetooth_enabled);
1332 } 1348 }
1333 1349
1334 wistron_led_init(&dev->dev); 1350 wistron_led_init(&dev->dev);
1351
1335 err = setup_input_dev(); 1352 err = setup_input_dev();
1336 if (err) { 1353 if (err) {
1337 bios_detach(); 1354 bios_detach();
@@ -1352,7 +1369,7 @@ static int __devexit wistron_remove(struct platform_device *dev)
1352} 1369}
1353 1370
1354#ifdef CONFIG_PM 1371#ifdef CONFIG_PM
1355static int wistron_suspend(struct platform_device *dev, pm_message_t state) 1372static int wistron_suspend(struct device *dev)
1356{ 1373{
1357 if (have_wifi) 1374 if (have_wifi)
1358 bios_set_state(WIFI, 0); 1375 bios_set_state(WIFI, 0);
@@ -1361,10 +1378,11 @@ static int wistron_suspend(struct platform_device *dev, pm_message_t state)
1361 bios_set_state(BLUETOOTH, 0); 1378 bios_set_state(BLUETOOTH, 0);
1362 1379
1363 wistron_led_suspend(); 1380 wistron_led_suspend();
1381
1364 return 0; 1382 return 0;
1365} 1383}
1366 1384
1367static int wistron_resume(struct platform_device *dev) 1385static int wistron_resume(struct device *dev)
1368{ 1386{
1369 if (have_wifi) 1387 if (have_wifi)
1370 bios_set_state(WIFI, wifi_enabled); 1388 bios_set_state(WIFI, wifi_enabled);
@@ -1373,24 +1391,30 @@ static int wistron_resume(struct platform_device *dev)
1373 bios_set_state(BLUETOOTH, bluetooth_enabled); 1391 bios_set_state(BLUETOOTH, bluetooth_enabled);
1374 1392
1375 wistron_led_resume(); 1393 wistron_led_resume();
1394
1376 poll_bios(true); 1395 poll_bios(true);
1377 1396
1378 return 0; 1397 return 0;
1379} 1398}
1380#else 1399
1381#define wistron_suspend NULL 1400static const struct dev_pm_ops wistron_pm_ops = {
1382#define wistron_resume NULL 1401 .suspend = wistron_suspend,
1402 .resume = wistron_resume,
1403 .poweroff = wistron_suspend,
1404 .restore = wistron_resume,
1405};
1383#endif 1406#endif
1384 1407
1385static struct platform_driver wistron_driver = { 1408static struct platform_driver wistron_driver = {
1386 .driver = { 1409 .driver = {
1387 .name = "wistron-bios", 1410 .name = "wistron-bios",
1388 .owner = THIS_MODULE, 1411 .owner = THIS_MODULE,
1412#if CONFIG_PM
1413 .pm = &wistron_pm_ops,
1414#endif
1389 }, 1415 },
1390 .probe = wistron_probe, 1416 .probe = wistron_probe,
1391 .remove = __devexit_p(wistron_remove), 1417 .remove = __devexit_p(wistron_remove),
1392 .suspend = wistron_suspend,
1393 .resume = wistron_resume,
1394}; 1418};
1395 1419
1396static int __init wb_module_init(void) 1420static int __init wb_module_init(void)