From d7cbe2773aed0b636d48bb6795637eb486ecba6d Mon Sep 17 00:00:00 2001 From: Nitin Joshi Date: Mon, 25 Jan 2021 11:59:16 +0900 Subject: platform/x86: thinkpad_acpi: set keyboard language This patch is to create sysfs entry for setting keyboard language using ASL method. Some thinkpads models like T580 , T590 , T15 Gen 1 etc. has "=", "(',")" numeric keys, which are not displaying correctly, when keyboard language is other than "english". This patch fixes this issue by setting keyboard language to ECFW. Signed-off-by: Nitin Joshi Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20210125025916.180831-1-nitjoshi@gmail.com Signed-off-by: Hans de Goede --- .../admin-guide/laptops/thinkpad-acpi.rst | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Documentation/admin-guide') diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst index 5fe1ade88c17..b1188f05a99a 100644 --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst @@ -51,6 +51,7 @@ detailed description): - UWB enable and disable - LCD Shadow (PrivacyGuard) enable and disable - Lap mode sensor + - Setting keyboard language A compatibility table by model and feature is maintained on the web site, http://ibm-acpi.sf.net/. I appreciate any success or failure @@ -1466,6 +1467,29 @@ Sysfs notes rfkill controller switch "tpacpi_uwb_sw": refer to Documentation/driver-api/rfkill.rst for details. + +Setting keyboard language +------------------- + +sysfs: keyboard_lang + +This feature is used to set keyboard language to ECFW using ASL interface. +Fewer thinkpads models like T580 , T590 , T15 Gen 1 etc.. has "=", "(', +")" numeric keys, which are not displaying correctly, when keyboard language +is other than "english". This is because of default keyboard language in ECFW +is set as "english". Hence using this sysfs, user can set correct keyboard +language to ECFW and then these key's will work correctly . + +Example of command to set keyboard language is mentioned below:: + + echo jp > /sys/devices/platform/thinkpad_acpi/keyboard_lang + +Text corresponding to keyboard layout to be set in sysfs are : jp (Japan), be(Belgian), +cz(Czech), en(English), da(Danish), de(German), es(Spain) , et(Estonian), +fr(French) , fr-ch (French(Switzerland)), pl(Polish), sl(Slovenian), hu +(Hungarian), nl(Dutch), tr(Turkey), it(Italy), sv(Sweden), pt(portugese) + + Adaptive keyboard ----------------- -- cgit v1.2.3 From a78b96fe95019d5e21f39ac1f2bb764e9c130bfc Mon Sep 17 00:00:00 2001 From: Lukas Bulwahn Date: Fri, 29 Jan 2021 05:08:49 +0100 Subject: platform/x86: thinkpad_acpi: rectify length of title underline Commit d7cbe2773aed ("platform/x86: thinkpad_acpi: set keyboard language") adds information on keyboard setting to the thinkpad documentation, but made the subsection title underline too short. Hence, make htmldocs warns: Documentation/admin-guide/laptops/thinkpad-acpi.rst:1472: \ WARNING: Title underline too short. Rectify length of subsection title underline. Signed-off-by: Lukas Bulwahn Link: https://lore.kernel.org/r/20210129040849.26740-1-lukas.bulwahn@gmail.com Signed-off-by: Hans de Goede --- Documentation/admin-guide/laptops/thinkpad-acpi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Documentation/admin-guide') diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst index b1188f05a99a..0e4c5bb7fb70 100644 --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst @@ -1469,7 +1469,7 @@ Sysfs notes Setting keyboard language -------------------- +------------------------- sysfs: keyboard_lang -- cgit v1.2.3 From cfa75cca618ef35cbbc05ff74ca9af6c7ff274ea Mon Sep 17 00:00:00 2001 From: Nitin Joshi Date: Tue, 2 Feb 2021 09:32:10 +0900 Subject: platform/x86: thinkpad_acpi: fixed warning and incorporated review comments The previous commit adding new sysfs for keyboard language has warning and few code correction has to be done as per new review comments. Below changes has been addressed in this version: - corrected warning. Many thanks to kernel test robot for reporting and determining this warning. - used sysfs_emit_at() API instead of strcat. - sorted keyboard language array. - removed unwanted space and corrected sentences. Reported-by: kernel test robot Signed-off-by: Nitin Joshi Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20210202003210.91773-1-njoshi1@lenovo.com Signed-off-by: Hans de Goede --- .../admin-guide/laptops/thinkpad-acpi.rst | 15 +++++----- drivers/platform/x86/thinkpad_acpi.c | 33 ++++++++-------------- 2 files changed, 19 insertions(+), 29 deletions(-) (limited to 'Documentation/admin-guide') diff --git a/Documentation/admin-guide/laptops/thinkpad-acpi.rst b/Documentation/admin-guide/laptops/thinkpad-acpi.rst index 0e4c5bb7fb70..91fd6846ce17 100644 --- a/Documentation/admin-guide/laptops/thinkpad-acpi.rst +++ b/Documentation/admin-guide/laptops/thinkpad-acpi.rst @@ -1476,18 +1476,19 @@ sysfs: keyboard_lang This feature is used to set keyboard language to ECFW using ASL interface. Fewer thinkpads models like T580 , T590 , T15 Gen 1 etc.. has "=", "(', ")" numeric keys, which are not displaying correctly, when keyboard language -is other than "english". This is because of default keyboard language in ECFW -is set as "english". Hence using this sysfs, user can set correct keyboard -language to ECFW and then these key's will work correctly . +is other than "english". This is because the default keyboard language in ECFW +is set as "english". Hence using this sysfs, user can set the correct keyboard +language to ECFW and then these key's will work correctly. Example of command to set keyboard language is mentioned below:: echo jp > /sys/devices/platform/thinkpad_acpi/keyboard_lang -Text corresponding to keyboard layout to be set in sysfs are : jp (Japan), be(Belgian), -cz(Czech), en(English), da(Danish), de(German), es(Spain) , et(Estonian), -fr(French) , fr-ch (French(Switzerland)), pl(Polish), sl(Slovenian), hu -(Hungarian), nl(Dutch), tr(Turkey), it(Italy), sv(Sweden), pt(portugese) +Text corresponding to keyboard layout to be set in sysfs are: be(Belgian), +cz(Czech), da(Danish), de(German), en(English), es(Spain), et(Estonian), +fr(French), fr-ch(French(Switzerland)), hu(Hungarian), it(Italy), jp (Japan), +nl(Dutch), nn(Norway), pl(Polish), pt(portugese), sl(Slovenian), sv(Sweden), +tr(Turkey) Adaptive keyboard diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 4a1dba3099a6..48575efb5ae8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -9992,16 +9992,12 @@ struct keyboard_lang_data { int lang_code; }; -/* - * When adding new entries to keyboard_lang_data, please check that - * the select_lang[] buffer in keyboard_lang_show() is still large enough. - */ -struct keyboard_lang_data keyboard_lang_data[] = { - {"en", 0}, +static const struct keyboard_lang_data keyboard_lang_data[] = { {"be", 0x080c}, {"cz", 0x0405}, {"da", 0x0406}, {"de", 0x0c07}, + {"en", 0x0000}, {"es", 0x2c0a}, {"et", 0x0425}, {"fr", 0x040c}, @@ -10064,9 +10060,7 @@ static ssize_t keyboard_lang_show(struct device *dev, struct device_attribute *attr, char *buf) { - int output, err, i; - char select_lang[80] = ""; - char lang[8] = ""; + int output, err, i, len = 0; err = get_keyboard_lang(&output); if (err) @@ -10074,19 +10068,17 @@ static ssize_t keyboard_lang_show(struct device *dev, for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) { if (i) - strcat(select_lang, " "); + len += sysfs_emit_at(buf, len, "%s", " "); if (output == keyboard_lang_data[i].lang_code) { - strcat(lang, "["); - strcat(lang, keyboard_lang_data[i].lang_str); - strcat(lang, "]"); - strcat(select_lang, lang); + len += sysfs_emit_at(buf, len, "[%s]", keyboard_lang_data[i].lang_str); } else { - strcat(select_lang, keyboard_lang_data[i].lang_str); + len += sysfs_emit_at(buf, len, "%s", keyboard_lang_data[i].lang_str); } } + len += sysfs_emit_at(buf, len, "\n"); - return sysfs_emit(buf, "%s\n", select_lang); + return len; } static ssize_t keyboard_lang_store(struct device *dev, @@ -10113,7 +10105,7 @@ static ssize_t keyboard_lang_store(struct device *dev, if (err) return err; } else { - pr_err("Unknown Keyboard language. Ignoring\n"); + dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); return -EINVAL; } @@ -10124,7 +10116,6 @@ static ssize_t keyboard_lang_store(struct device *dev, return count; } - static DEVICE_ATTR_RW(keyboard_lang); static struct attribute *kbdlang_attributes[] = { @@ -10143,7 +10134,7 @@ static int tpacpi_kbdlang_init(struct ibm_init_struct *iibm) err = get_keyboard_lang(&output); /* * If support isn't available (ENODEV) then don't return an error - * just don't create the sysfs group + * just don't create the sysfs group. */ if (err == -ENODEV) return 0; @@ -10152,9 +10143,7 @@ static int tpacpi_kbdlang_init(struct ibm_init_struct *iibm) return err; /* Platform supports this feature - create the sysfs file */ - err = sysfs_create_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group); - - return err; + return sysfs_create_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group); } static void kbdlang_exit(void) -- cgit v1.2.3