Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ideapad: add Lenovo IdeaPad Z570 support (part 1)

The patch adds support for Lenovo IdeaPad Z570 laptop. It makes all special
keys working, adds possibility to control fan like Windows does, controls
Touchpad Disabled LED, toggles touchpad state via keyboard controller and
corrects touchpad behavior on resume from suspend. It is new, modified
version of patch. Now it does not depend on psmouse and does not need patching
of input subsystem.

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>

This is part 1 for special button handling.

Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>

authored by

Maxim Mikityanskiy and committed by
Matthew Garrett
296f9fe0 ad20c73b

+32
+32
drivers/platform/x86/ideapad-laptop.c
··· 65 65 VPCCMD_R_ODD, /* 0x21 */ 66 66 VPCCMD_R_RF = 0x23, 67 67 VPCCMD_W_RF, 68 + VPCCMD_R_SPECIAL_BUTTONS = 0x31, 68 69 VPCCMD_W_BL_POWER = 0x33, 69 70 }; 70 71 ··· 519 518 */ 520 519 static const struct key_entry ideapad_keymap[] = { 521 520 { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, 521 + { KE_KEY, 7, { KEY_CAMERA } }, 522 + { KE_KEY, 11, { KEY_F16 } }, 522 523 { KE_KEY, 13, { KEY_WLAN } }, 523 524 { KE_KEY, 16, { KEY_PROG1 } }, 524 525 { KE_KEY, 17, { KEY_PROG2 } }, 526 + { KE_KEY, 64, { KEY_PROG3 } }, 527 + { KE_KEY, 65, { KEY_PROG4 } }, 525 528 { KE_END, 0 }, 526 529 }; 527 530 ··· 590 585 ideapad_input_report(priv, 17); 591 586 else 592 587 ideapad_input_report(priv, 16); 588 + } 589 + 590 + static void ideapad_check_special_buttons(struct ideapad_private *priv) 591 + { 592 + unsigned long bit, value; 593 + 594 + read_ec_data(ideapad_handle, VPCCMD_R_SPECIAL_BUTTONS, &value); 595 + 596 + for (bit = 0; bit < 16; bit++) { 597 + if (test_bit(bit, &value)) { 598 + switch (bit) { 599 + case 6: 600 + /* Thermal Management button */ 601 + ideapad_input_report(priv, 65); 602 + break; 603 + case 1: 604 + /* OneKey Theater button */ 605 + ideapad_input_report(priv, 64); 606 + break; 607 + } 608 + } 609 + } 593 610 } 594 611 595 612 /* ··· 812 785 ideapad_sync_rfk_state(priv); 813 786 break; 814 787 case 13: 788 + case 11: 789 + case 7: 815 790 case 6: 816 791 ideapad_input_report(priv, vpc_bit); 817 792 break; ··· 825 796 break; 826 797 case 2: 827 798 ideapad_backlight_notify_power(priv); 799 + break; 800 + case 0: 801 + ideapad_check_special_buttons(priv); 828 802 break; 829 803 default: 830 804 pr_info("Unknown event: %lu\n", vpc_bit);