From 22b69ce5ed1cef147859b18ef2049b0012ced014 Mon Sep 17 00:00:00 2001 From: Julien Valroff Date: Sat, 4 Jul 2009 15:12:59 +0000 Subject: [PATCH] Patch from Azael Avalos - Satellite X205 hotkeys fix --- Makefile | 2 +- acpi.c | 82 +++++++++++++++++++++++++++++++++------------------ compal.c | 9 +++--- doc/ChangeLog | 2 +- hardware.h | 11 ++++--- 5 files changed, 68 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 7aeafa6..b9ad1cc 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ #Module informations MODULE_NAME = omnibook -MODULE_VERSION = 2.20070211 +MODULE_VERSION = 2.20092106 MODULE_BRANCH = trunk # Out-of-tree configuration diff --git a/acpi.c b/acpi.c index 2e21d6f..a38fabe 100644 --- a/acpi.c +++ b/acpi.c @@ -56,6 +56,12 @@ static char ec_dev_list[][20] = { "\\_SB.PCI0.LPC0.EC0", }; +/* Toshiba's Hardware Control Interface method */ +static char hci_dev_list[][20] = { + "\\_SB.VALD", + "\\_SB.VALZ", +}; + #define TOSHIBA_ACPI_BT_CLASS "bluetooth" #define TOSHIBA_ACPI_DEVICE_NAME "bluetooth adapter" @@ -109,6 +115,7 @@ static struct acpi_driver omnibook_bt_driver = { struct acpi_backend_data { acpi_handle ec_handle; /* Handle on ACPI EC device */ acpi_handle bt_handle; /* Handle on ACPI BT device */ + acpi_handle hci_handle; /* Handle on ACPI HCI device */ unsigned has_antr_antw:1; /* Are there ANTR/ANTW methods in the EC device ? */ unsigned has_doss_dosw:1; /* Are there DOSS/DOSW methods in the EC device ? */ struct input_dev *acpi_input_dev; @@ -120,7 +127,7 @@ struct acpi_backend_data { * 1. Fn+Foo pressed * 2. Scancode 0x6e generated by kbd controller * 3. Scancode 0x6e caught by omnibook input handler - * 4. TOHK Got keycode of last actually pressed Fn key + * 4. INFO method has keycode of last actually pressed Fn key * 5. acpi_scan_table used to associate a detected keycode with a generated one * 6. Generated keycode issued using the omnibook input device */ @@ -257,7 +264,7 @@ static const struct { unsigned int scancode; unsigned int keycode; } acpi_scan_table[] = { - { HCI_FN, KEY_RESERVED}, + { HCI_FN_RELEASED, KEY_FN}, { HCI_MUTE, KEY_MUTE}, { HCI_BREAK, KEY_COFFEE}, { HCI_1, KEY_ZOOMOUT}, @@ -266,10 +273,12 @@ static const struct { { HCI_BSM, KEY_PROG1}, { HCI_SUSPEND, KEY_SLEEP}, { HCI_HIBERNATE, KEY_SUSPEND}, + { HCI_VIDEOOUT, KEY_SWITCHVIDEOMODE}, { HCI_BRIGHTNESSDOWN, KEY_BRIGHTNESSDOWN}, { HCI_BRIGHTNESSUP, KEY_BRIGHTNESSUP}, { HCI_WLAN, KEY_WLAN}, { HCI_TOUCHPAD, KEY_PROG2}, + { HCI_FN_PRESSED, KEY_FN}, { 0, 0}, }; @@ -303,7 +312,7 @@ static int register_input_subsystem(struct acpi_backend_data *priv_data) set_bit(acpi_scan_table[i].keycode, acpi_input_dev->keybit); retval = input_register_device(acpi_input_dev); - if(retval) { + if (retval) { input_free_device(acpi_input_dev); goto out; } @@ -335,7 +344,7 @@ static int register_input_subsystem(struct acpi_backend_data *priv_data) static int omnibook_acpi_init(const struct omnibook_operation *io_op) { int retval = 0; - acpi_handle dev_handle, method_handle; + acpi_handle dev_handle, method_handle, hci_handle; int i; struct acpi_backend_data *priv_data; @@ -370,6 +379,20 @@ static int omnibook_acpi_init(const struct omnibook_operation *io_op) goto error1; } + /* Probe for HCI device only on TSX205 models */ + if (omnibook_ectype & TSX205) { + if (acpi_get_handle(NULL, hci_dev_list[1], &hci_handle) == AE_OK) { + dprintk("Toshiba's HCI device found\n"); + priv_data->hci_handle = hci_handle; + } + + if (!hci_handle) { + printk(O_ERR "Couldn't get HCI handle.\n"); + retval = -ENODEV; + goto error1; + } + } + if((acpi_get_handle( dev_handle, GET_WIRELESS_METHOD, &method_handle) == AE_OK) && (acpi_get_handle( dev_handle, SET_WIRELESS_METHOD, &method_handle) == AE_OK)) priv_data->has_antr_antw = 1; @@ -485,6 +508,7 @@ static int omnibook_acpi_execute(acpi_handle dev_handle, char *method, const int /* Function taken from toshiba_acpi */ static acpi_status hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) { + struct acpi_backend_data *priv_data = acpi_backend.data; struct acpi_object_list params; union acpi_object in_objs[HCI_WORDS]; struct acpi_buffer results; @@ -502,7 +526,7 @@ static acpi_status hci_raw(const u32 in[HCI_WORDS], u32 out[HCI_WORDS]) results.length = sizeof(out_objs); results.pointer = out_objs; - status = acpi_evaluate_object(NULL, (char *)METHOD_HCI, ¶ms, + status = acpi_evaluate_object(priv_data->hci_handle, (char *)HCI_METHOD, ¶ms, &results); if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) { for (i = 0; i < out_objs->package.count; ++i) { @@ -520,19 +544,19 @@ static int set_bt_status(const struct acpi_backend_data *priv_data, unsigned int { int retval = 0; - if(state) { + if (state) { retval = omnibook_acpi_execute(priv_data->bt_handle, TOSH_BT_ACTIVATE_USB, NULL, NULL); - if(retval) + if (retval) goto out; retval = omnibook_acpi_execute(priv_data->bt_handle, TOSH_BT_POWER_ON, NULL, NULL); - if(retval) + if (retval) goto out; } else { retval = omnibook_acpi_execute(priv_data->bt_handle, TOSH_BT_DISABLE_USB, NULL, NULL); - if(retval) + if (retval) goto out; retval = omnibook_acpi_execute(priv_data->bt_handle, TOSH_BT_POWER_OFF, NULL, NULL); - if(retval) + if (retval) goto out; } out: @@ -560,7 +584,7 @@ static int omnibook_acpi_bt_add(struct acpi_device *device) static int omnibook_acpi_bt_remove(struct acpi_device *device, int type) { - int retval; + int retval; struct acpi_backend_data *priv_data = acpi_backend.data; mutex_lock(&acpi_backend.mutex); @@ -593,7 +617,7 @@ static int get_bt_status(const struct acpi_backend_data *priv_data, unsigned int /* * Get the Bluetooth + Wireless status using the ANTR method - * FIXME: what if ANTR and BTST disagree ? we trust ANTR for now + * FIXME: what if ANTR and BTST disagree ? we thrust ANTR for now */ static int get_wireless_status(const struct acpi_backend_data *priv_data, unsigned int *state) { @@ -854,24 +878,26 @@ static int omnibook_hci_set_hotkeys(const struct omnibook_operation *io_op, unsi static int omnibook_acpi_get_events(unsigned int *state) { - int i; - struct acpi_buffer results; - union acpi_object out_objs[1]; - acpi_handle handle; acpi_status status; - - for (i = 0; i < ARRAY_SIZE(ec_dev_list); i++) { - status = acpi_get_handle(NULL, ec_dev_list[i], &handle); - if (status == AE_OK) - break; + struct acpi_backend_data *priv_data = acpi_backend.data; + + /* We need to call the NTFY method first so it can activate the TECF variable */ + status = omnibook_acpi_execute(priv_data->ec_handle, TSX205_NOTIFY_METHOD, NULL, NULL); + if (status != AE_OK) { + dprintk(O_ERR "Failed to activate NTFY method.\n"); + return -EIO; } - results.length = sizeof(out_objs); - results.pointer = out_objs; + /* Now we can poll the INFO method to get last pressed hotkey */ + status = omnibook_acpi_execute(priv_data->hci_handle, TSX205_EVENTS_METHOD, NULL, state); + if (status != AE_OK) { + dprintk(O_ERR "Failed to get Hotkey event.\n"); + return -EIO; + } - status = acpi_evaluate_object(handle, (char *)TSX205_EVENTS_METHOD, 0, &results); - *state = out_objs[0].integer.value; - *state &= ~0x80; + /* We only care about a key press, so just report the Fn key Press/Release */ + if ( ((*state & ~0x80) == 0x100) || ((*state & ~0x80) == 0x17f) ) + *state &= ~0x80; return status; } @@ -897,7 +923,7 @@ static int adjust_brighness(int delta) if(( retval = __backend_byte_read(io_op, &brgt))) goto out; - dprintk("Fn-F6/F7 pressed: adjusting britghtnes.\n"); + dprintk("Fn-F6/F7 pressed: adjusting brightness.\n"); if (((int) brgt + delta) < 0) brgt = 0; @@ -942,7 +968,7 @@ static void omnibook_handle_fnkey(void* data) } for (i = 0 ; i < ARRAY_SIZE(acpi_scan_table); i++) { - if ( gen_scan == acpi_scan_table[i].scancode && gen_scan != KEY_RESERVED) { + if (gen_scan == acpi_scan_table[i].scancode) { dprintk("generating keycode %i.\n", acpi_scan_table[i].keycode); #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)) input_dev = container_of(work, struct acpi_backend_data, fnkey_work)->acpi_input_dev; diff --git a/compal.c b/compal.c index 52a52a5..766aec5 100644 --- a/compal.c +++ b/compal.c @@ -134,13 +134,13 @@ static int check_cdimode_flag(unsigned int mode) int i; int retval; - dprintk("Index mode:"); + /*dprintk("Index mode:");*/ for (i = 1; i <= 250; i++) { retval = lowlevel_read(0xfbfc); - dprintk_simple(" [%i]", retval); + /*dprintk_simple(" [%i]", retval);*/ if (retval == mode) { - dprintk_simple(".\n"); - dprintk("Index Mode Ok (%i) after %i iter\n", mode, i); + /*dprintk_simple(".\n"); + dprintk("Index Mode Ok (%i) after %i iter\n", mode, i);*/ return 0; } udelay(100); @@ -473,6 +473,7 @@ static int omnibook_cdimode_write(const struct omnibook_operation *io_op, u8 val static int omnibook_cdimode_hotkeys(const struct omnibook_operation *io_op, unsigned int state) { int retval; + struct omnibook_operation hotkeys_op = { CDI, 0, TSM70_FN_INDEX, 0, TSM70_FN_ENABLE, TSM70_FN_DISABLE}; diff --git a/doc/ChangeLog b/doc/ChangeLog index 2b330cc..22bd15b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -9,7 +9,7 @@ Changelog file for omnibook package: fix compiler warning about use uninitialized variable * Applied patch from Danny Kukawka to fix build the driver on older kernel versions -* Applied patch from Azael Avalos +* Applied patches from Azael Avalos to add support to Satellite X205 and other laptops based on ICH8 diff --git a/hardware.h b/hardware.h index dcf627d..11b8972 100644 --- a/hardware.h +++ b/hardware.h @@ -432,7 +432,7 @@ static inline int omnibook_toggle(const struct omnibook_operation *io_op, int to * Keyboard controller command for some laptop functions */ -#define OMNIBOOK_KBC_CONTROL_CMD 0x59 +#define OMNIBOOK_KBC_CONTROL_CMD 0x59 /* * Keyboard controller command parameters for functions available via kbc @@ -536,7 +536,7 @@ static inline int omnibook_toggle(const struct omnibook_operation *io_op, int to #define SMI_DOCK_SCAN 0x6e /* Dock scancode */ /* Toshiba HCI method and constants */ -#define METHOD_HCI "\\_SB.VALZ.SPFC" +#define HCI_METHOD "SPFC" #define HCI_WORDS 6 #define HCI_GET 0xfe00 @@ -556,14 +556,15 @@ static inline int omnibook_toggle(const struct omnibook_operation *io_op, int to #define HCI_NOT_SUPPORTED 0x8000 /* Toshiba Satellite X205 methods */ -#define TSX205_EVENTS_METHOD "TOHK" +#define TSX205_EVENTS_METHOD "INFO" +#define TSX205_NOTIFY_METHOD "NTFY" #define TSX205_KILLSW_METHOD "KLSW" #define ACPI_FN_MASK 0x01 #define ACPI_FN_SCAN 0x6e /* Fn key scancode */ /* HCI key definitions */ -#define HCI_FN 0x100 +#define HCI_FN_RELEASED 0x100 #define HCI_MUTE 0x101 #define HCI_1 0x102 #define HCI_2 0x103 @@ -572,7 +573,9 @@ static inline int omnibook_toggle(const struct omnibook_operation *io_op, int to #define HCI_BSM 0x13c #define HCI_SUSPEND 0x13d #define HCI_HIBERNATE 0x13e +#define HCI_VIDEOOUT 0x13f #define HCI_BRIGHTNESSDOWN 0x140 #define HCI_BRIGHTNESSUP 0x141 #define HCI_WLAN 0x142 #define HCI_TOUCHPAD 0x143 +#define HCI_FN_PRESSED 0x17f -- 2.43.5