diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2009-09-20 13:09:27 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-20 13:49:04 -0400 |
commit | 67bcae6ee8e111f3343bc89345883024ba230a3b (patch) | |
tree | 72df93da829505d1c5687f628fb105dcb49a5223 /drivers/platform | |
parent | 8b468c0c85f41c4c55227c17271b4187d8911fb0 (diff) |
thinkpad-acpi: name event constants
Reduce the number of magic numbers in the driver... note that they
were all explained and documented already.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 92 |
1 files changed, 69 insertions, 23 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index ffd584c35808..3910f2f3eada 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -145,6 +145,51 @@ enum { | |||
145 | TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */ | 145 | TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */ |
146 | }; | 146 | }; |
147 | 147 | ||
148 | /* HKEY events */ | ||
149 | enum tpacpi_hkey_event_t { | ||
150 | /* Hotkey-related */ | ||
151 | TP_HKEY_EV_HOTKEY_BASE = 0x1001, /* first hotkey (FN+F1) */ | ||
152 | TP_HKEY_EV_BRGHT_UP = 0x1010, /* Brightness up */ | ||
153 | TP_HKEY_EV_BRGHT_DOWN = 0x1011, /* Brightness down */ | ||
154 | TP_HKEY_EV_VOL_UP = 0x1015, /* Volume up or unmute */ | ||
155 | TP_HKEY_EV_VOL_DOWN = 0x1016, /* Volume down or unmute */ | ||
156 | TP_HKEY_EV_VOL_MUTE = 0x1017, /* Mixer output mute */ | ||
157 | |||
158 | /* Reasons for waking up from S3/S4 */ | ||
159 | TP_HKEY_EV_WKUP_S3_UNDOCK = 0x2304, /* undock requested, S3 */ | ||
160 | TP_HKEY_EV_WKUP_S4_UNDOCK = 0x2404, /* undock requested, S4 */ | ||
161 | TP_HKEY_EV_WKUP_S3_BAYEJ = 0x2305, /* bay ejection req, S3 */ | ||
162 | TP_HKEY_EV_WKUP_S4_BAYEJ = 0x2405, /* bay ejection req, S4 */ | ||
163 | TP_HKEY_EV_WKUP_S3_BATLOW = 0x2313, /* battery empty, S3 */ | ||
164 | TP_HKEY_EV_WKUP_S4_BATLOW = 0x2413, /* battery empty, S4 */ | ||
165 | |||
166 | /* Auto-sleep after eject request */ | ||
167 | TP_HKEY_EV_BAYEJ_ACK = 0x3003, /* bay ejection complete */ | ||
168 | TP_HKEY_EV_UNDOCK_ACK = 0x4003, /* undock complete */ | ||
169 | |||
170 | /* Misc bay events */ | ||
171 | TP_HKEY_EV_OPTDRV_EJ = 0x3006, /* opt. drive tray ejected */ | ||
172 | |||
173 | /* User-interface events */ | ||
174 | TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */ | ||
175 | TP_HKEY_EV_LID_OPEN = 0x5002, /* laptop lid opened */ | ||
176 | TP_HKEY_EV_TABLET_TABLET = 0x5009, /* tablet swivel up */ | ||
177 | TP_HKEY_EV_TABLET_NOTEBOOK = 0x500a, /* tablet swivel down */ | ||
178 | TP_HKEY_EV_PEN_INSERTED = 0x500b, /* tablet pen inserted */ | ||
179 | TP_HKEY_EV_PEN_REMOVED = 0x500c, /* tablet pen removed */ | ||
180 | TP_HKEY_EV_BRGHT_CHANGED = 0x5010, /* backlight control event */ | ||
181 | |||
182 | /* Thermal events */ | ||
183 | TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */ | ||
184 | TP_HKEY_EV_ALARM_BAT_XHOT = 0x6012, /* battery critically hot */ | ||
185 | TP_HKEY_EV_ALARM_SENSOR_HOT = 0x6021, /* sensor too hot */ | ||
186 | TP_HKEY_EV_ALARM_SENSOR_XHOT = 0x6022, /* sensor critically hot */ | ||
187 | TP_HKEY_EV_THM_TABLE_CHANGED = 0x6030, /* thermal table changed */ | ||
188 | |||
189 | /* Misc */ | ||
190 | TP_HKEY_EV_RFKILL_CHANGED = 0x7000, /* rfkill switch changed */ | ||
191 | }; | ||
192 | |||
148 | /**************************************************************************** | 193 | /**************************************************************************** |
149 | * Main driver | 194 | * Main driver |
150 | */ | 195 | */ |
@@ -2273,7 +2318,7 @@ static void tpacpi_hotkey_send_key(unsigned int scancode) | |||
2273 | tpacpi_input_send_key_masked(scancode); | 2318 | tpacpi_input_send_key_masked(scancode); |
2274 | if (hotkey_report_mode < 2) { | 2319 | if (hotkey_report_mode < 2) { |
2275 | acpi_bus_generate_proc_event(ibm_hotkey_acpidriver.device, | 2320 | acpi_bus_generate_proc_event(ibm_hotkey_acpidriver.device, |
2276 | 0x80, 0x1001 + scancode); | 2321 | 0x80, TP_HKEY_EV_HOTKEY_BASE + scancode); |
2277 | } | 2322 | } |
2278 | } | 2323 | } |
2279 | 2324 | ||
@@ -3420,20 +3465,20 @@ static bool hotkey_notify_wakeup(const u32 hkey, | |||
3420 | *ignore_acpi_ev = false; | 3465 | *ignore_acpi_ev = false; |
3421 | 3466 | ||
3422 | switch (hkey) { | 3467 | switch (hkey) { |
3423 | case 0x2304: /* suspend, undock */ | 3468 | case TP_HKEY_EV_WKUP_S3_UNDOCK: /* suspend, undock */ |
3424 | case 0x2404: /* hibernation, undock */ | 3469 | case TP_HKEY_EV_WKUP_S4_UNDOCK: /* hibernation, undock */ |
3425 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK; | 3470 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK; |
3426 | *ignore_acpi_ev = true; | 3471 | *ignore_acpi_ev = true; |
3427 | break; | 3472 | break; |
3428 | 3473 | ||
3429 | case 0x2305: /* suspend, bay eject */ | 3474 | case TP_HKEY_EV_WKUP_S3_BAYEJ: /* suspend, bay eject */ |
3430 | case 0x2405: /* hibernation, bay eject */ | 3475 | case TP_HKEY_EV_WKUP_S4_BAYEJ: /* hibernation, bay eject */ |
3431 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ; | 3476 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ; |
3432 | *ignore_acpi_ev = true; | 3477 | *ignore_acpi_ev = true; |
3433 | break; | 3478 | break; |
3434 | 3479 | ||
3435 | case 0x2313: /* Battery on critical low level (S3) */ | 3480 | case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ |
3436 | case 0x2413: /* Battery on critical low level (S4) */ | 3481 | case TP_HKEY_EV_WKUP_S4_BATLOW: /* Battery on critical low level/S4 */ |
3437 | printk(TPACPI_ALERT | 3482 | printk(TPACPI_ALERT |
3438 | "EMERGENCY WAKEUP: battery almost empty\n"); | 3483 | "EMERGENCY WAKEUP: battery almost empty\n"); |
3439 | /* how to auto-heal: */ | 3484 | /* how to auto-heal: */ |
@@ -3463,20 +3508,20 @@ static bool hotkey_notify_usrevent(const u32 hkey, | |||
3463 | *ignore_acpi_ev = false; | 3508 | *ignore_acpi_ev = false; |
3464 | 3509 | ||
3465 | switch (hkey) { | 3510 | switch (hkey) { |
3466 | case 0x500b: /* X61t: tablet pen inserted into bay */ | 3511 | case TP_HKEY_EV_PEN_INSERTED: /* X61t: tablet pen inserted into bay */ |
3467 | case 0x500c: /* X61t: tablet pen removed from bay */ | 3512 | case TP_HKEY_EV_PEN_REMOVED: /* X61t: tablet pen removed from bay */ |
3468 | return true; | 3513 | return true; |
3469 | 3514 | ||
3470 | case 0x5009: /* X41t-X61t: swivel up (tablet mode) */ | 3515 | case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ |
3471 | case 0x500a: /* X41t-X61t: swivel down (normal mode) */ | 3516 | case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ |
3472 | tpacpi_input_send_tabletsw(); | 3517 | tpacpi_input_send_tabletsw(); |
3473 | hotkey_tablet_mode_notify_change(); | 3518 | hotkey_tablet_mode_notify_change(); |
3474 | *send_acpi_ev = false; | 3519 | *send_acpi_ev = false; |
3475 | return true; | 3520 | return true; |
3476 | 3521 | ||
3477 | case 0x5001: /* Lid close */ | 3522 | case TP_HKEY_EV_LID_CLOSE: /* Lid closed */ |
3478 | case 0x5002: /* Lid open */ | 3523 | case TP_HKEY_EV_LID_OPEN: /* Lid opened */ |
3479 | case 0x5010: /* brightness control */ | 3524 | case TP_HKEY_EV_BRGHT_CHANGED: /* brightness changed */ |
3480 | /* do not propagate these events */ | 3525 | /* do not propagate these events */ |
3481 | *ignore_acpi_ev = true; | 3526 | *ignore_acpi_ev = true; |
3482 | return true; | 3527 | return true; |
@@ -3495,30 +3540,30 @@ static bool hotkey_notify_thermal(const u32 hkey, | |||
3495 | *ignore_acpi_ev = false; | 3540 | *ignore_acpi_ev = false; |
3496 | 3541 | ||
3497 | switch (hkey) { | 3542 | switch (hkey) { |
3498 | case 0x6011: | 3543 | case TP_HKEY_EV_ALARM_BAT_HOT: |
3499 | printk(TPACPI_CRIT | 3544 | printk(TPACPI_CRIT |
3500 | "THERMAL ALARM: battery is too hot!\n"); | 3545 | "THERMAL ALARM: battery is too hot!\n"); |
3501 | /* recommended action: warn user through gui */ | 3546 | /* recommended action: warn user through gui */ |
3502 | return true; | 3547 | return true; |
3503 | case 0x6012: | 3548 | case TP_HKEY_EV_ALARM_BAT_XHOT: |
3504 | printk(TPACPI_ALERT | 3549 | printk(TPACPI_ALERT |
3505 | "THERMAL EMERGENCY: battery is extremely hot!\n"); | 3550 | "THERMAL EMERGENCY: battery is extremely hot!\n"); |
3506 | /* recommended action: immediate sleep/hibernate */ | 3551 | /* recommended action: immediate sleep/hibernate */ |
3507 | return true; | 3552 | return true; |
3508 | case 0x6021: | 3553 | case TP_HKEY_EV_ALARM_SENSOR_HOT: |
3509 | printk(TPACPI_CRIT | 3554 | printk(TPACPI_CRIT |
3510 | "THERMAL ALARM: " | 3555 | "THERMAL ALARM: " |
3511 | "a sensor reports something is too hot!\n"); | 3556 | "a sensor reports something is too hot!\n"); |
3512 | /* recommended action: warn user through gui, that */ | 3557 | /* recommended action: warn user through gui, that */ |
3513 | /* some internal component is too hot */ | 3558 | /* some internal component is too hot */ |
3514 | return true; | 3559 | return true; |
3515 | case 0x6022: | 3560 | case TP_HKEY_EV_ALARM_SENSOR_XHOT: |
3516 | printk(TPACPI_ALERT | 3561 | printk(TPACPI_ALERT |
3517 | "THERMAL EMERGENCY: " | 3562 | "THERMAL EMERGENCY: " |
3518 | "a sensor reports something is extremely hot!\n"); | 3563 | "a sensor reports something is extremely hot!\n"); |
3519 | /* recommended action: immediate sleep/hibernate */ | 3564 | /* recommended action: immediate sleep/hibernate */ |
3520 | return true; | 3565 | return true; |
3521 | case 0x6030: | 3566 | case TP_HKEY_EV_THM_TABLE_CHANGED: |
3522 | printk(TPACPI_INFO | 3567 | printk(TPACPI_INFO |
3523 | "EC reports that Thermal Table has changed\n"); | 3568 | "EC reports that Thermal Table has changed\n"); |
3524 | /* recommended action: do nothing, we don't have | 3569 | /* recommended action: do nothing, we don't have |
@@ -3576,7 +3621,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
3576 | break; | 3621 | break; |
3577 | case 3: | 3622 | case 3: |
3578 | /* 0x3000-0x3FFF: bay-related wakeups */ | 3623 | /* 0x3000-0x3FFF: bay-related wakeups */ |
3579 | if (hkey == 0x3003) { | 3624 | if (hkey == TP_HKEY_EV_BAYEJ_ACK) { |
3580 | hotkey_autosleep_ack = 1; | 3625 | hotkey_autosleep_ack = 1; |
3581 | printk(TPACPI_INFO | 3626 | printk(TPACPI_INFO |
3582 | "bay ejected\n"); | 3627 | "bay ejected\n"); |
@@ -3588,7 +3633,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
3588 | break; | 3633 | break; |
3589 | case 4: | 3634 | case 4: |
3590 | /* 0x4000-0x4FFF: dock-related wakeups */ | 3635 | /* 0x4000-0x4FFF: dock-related wakeups */ |
3591 | if (hkey == 0x4003) { | 3636 | if (hkey == TP_HKEY_EV_UNDOCK_ACK) { |
3592 | hotkey_autosleep_ack = 1; | 3637 | hotkey_autosleep_ack = 1; |
3593 | printk(TPACPI_INFO | 3638 | printk(TPACPI_INFO |
3594 | "undocked\n"); | 3639 | "undocked\n"); |
@@ -3610,7 +3655,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
3610 | break; | 3655 | break; |
3611 | case 7: | 3656 | case 7: |
3612 | /* 0x7000-0x7FFF: misc */ | 3657 | /* 0x7000-0x7FFF: misc */ |
3613 | if (tp_features.hotkey_wlsw && hkey == 0x7000) { | 3658 | if (tp_features.hotkey_wlsw && |
3659 | hkey == TP_HKEY_EV_RFKILL_CHANGED) { | ||
3614 | tpacpi_send_radiosw_update(); | 3660 | tpacpi_send_radiosw_update(); |
3615 | send_acpi_ev = 0; | 3661 | send_acpi_ev = 0; |
3616 | known_ev = true; | 3662 | known_ev = true; |
@@ -7670,7 +7716,7 @@ static void tpacpi_driver_event(const unsigned int hkey_event) | |||
7670 | 7716 | ||
7671 | static void hotkey_driver_event(const unsigned int scancode) | 7717 | static void hotkey_driver_event(const unsigned int scancode) |
7672 | { | 7718 | { |
7673 | tpacpi_driver_event(0x1001 + scancode); | 7719 | tpacpi_driver_event(TP_HKEY_EV_HOTKEY_BASE + scancode); |
7674 | } | 7720 | } |
7675 | 7721 | ||
7676 | /* sysfs name ---------------------------------------------------------- */ | 7722 | /* sysfs name ---------------------------------------------------------- */ |