Skip to contentSkip to conversation

platform/x86: thinkpad_acpi: set keyboard language

PATCH In review Nitin Joshi 4 participants 8 messages Jan 25, 2021 – Jan 27, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: thinkpad_acpi: set keyboard language

From: Nitin Joshi <[email protected]>

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.

---
Changes in v2:
- used sysfs_streq() API instead of strcmp
- used ARRAY_SIZE() API instead of strlen
- addressed typo

---
 .../admin-guide/laptops/thinkpad-acpi.rst     |  24 +++
 drivers/platform/x86/thinkpad_acpi.c          | 182 ++++++++++++++++++
 2 files changed, 206 insertions(+)
Documentation/admin-guide/laptops/thinkpad-acpi.rst +24 -0
index 5fe1ade88c17..b1188f05a99a 100644
@@ -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
 -----------------
 
drivers/platform/x86/thinkpad_acpi.c +182 -0

194 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 8 lines · Nitin Joshi

From: Nitin Joshi <[email protected]>

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.

Quoted 6 lines

---
Changes in v2:
- used sysfs_streq() API instead of strcmp
- used ARRAY_SIZE() API instead of strlen
- addressed typo

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Nitn, I did not notice one small issue while testing this on a X1C8 I will send out a follow-up patch addressing that. If you can test the follow-up patch on one of the affected models (T580 , T590 , T15 Gen 1, etc.) that would be great.

Note this patch will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 248 lines
---
 .../admin-guide/laptops/thinkpad-acpi.rst     |  24 +++
 drivers/platform/x86/thinkpad_acpi.c          | 182 ++++++++++++++++++
 2 files changed, 206 insertions(+)
Documentation/admin-guide/laptops/thinkpad-acpi.rst +24 -0
index 5fe1ade88c17..b1188f05a99a 100644
@@ -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
 -----------------
 
drivers/platform/x86/thinkpad_acpi.c +182 -0
index e03df2881dc6..3cfc4a872c2d 100644
@@ -9982,6 +9982,183 @@ static struct ibm_struct proxsensor_driver_data = {
 	.exit = proxsensor_exit,
 };
 
+/*************************************************************************
+ * Keyboard language interface
+ */
+
+struct keyboard_lang_data {
+	const char *lang_str;
+	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},
+	{"be", 0x080c},
+	{"cz", 0x0405},
+	{"da", 0x0406},
+	{"de", 0x0c07},
+	{"es", 0x2c0a},
+	{"et", 0x0425},
+	{"fr", 0x040c},
+	{"fr-ch", 0x100c},
+	{"hu", 0x040e},
+	{"it", 0x0410},
+	{"jp", 0x0411},
+	{"nl", 0x0413},
+	{"nn", 0x0414},
+	{"pl", 0x0415},
+	{"pt", 0x0816},
+	{"sl", 0x041b},
+	{"sv", 0x081d},
+	{"tr", 0x041f},
+};
+
+static int set_keyboard_lang_command(int command)
+{
+	acpi_handle sskl_handle;
+	int output;
+
+	if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "SSKL", &sskl_handle))) {
+		/* Platform doesn't support SSKL */
+		return -ENODEV;
+	}
+
+	if (!acpi_evalf(sskl_handle, &output, NULL, "dd", command))
+		return -EIO;
+
+	return 0;
+}
+
+static int get_keyboard_lang(int *output)
+{
+	acpi_handle gskl_handle;
+	int kbd_lang;
+
+	if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSKL", &gskl_handle))) {
+		/* Platform doesn't support GSKL */
+		return -ENODEV;
+	}
+
+	if (!acpi_evalf(gskl_handle, &kbd_lang, NULL, "dd", 0x02000000))
+		return -EIO;
+
+	*output = kbd_lang;
+
+	return 0;
+}
+
+/* sysfs keyboard language entry */
+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] = "";
+
+	err = get_keyboard_lang(&output);
+	if (err)
+		return err;
+
+	for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+		if (i)
+			strcat(select_lang, " ");
+
+		if (output == keyboard_lang_data[i].lang_code) {
+			strcat(lang, "[");
+			strcat(lang, keyboard_lang_data[i].lang_str);
+			strcat(lang, "]");
+			strcat(select_lang, lang);
+		} else {
+			strcat(select_lang, keyboard_lang_data[i].lang_str);
+		}
+	}
+
+	return sysfs_emit(buf, "%s\n", select_lang);
+}
+
+static ssize_t keyboard_lang_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	int err, i;
+	bool lang_found = false;
+	int lang_code = 0;
+
+	for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+		if (sysfs_streq(buf, keyboard_lang_data[i].lang_str)) {
+			lang_code = keyboard_lang_data[i].lang_code;
+			lang_found = true;
+			break;
+		}
+	}
+
+	if (lang_found) {
+		lang_code = lang_code | 1 << 24;
+
+		/* Set language code */
+		err = set_keyboard_lang_command(lang_code);
+		if (err)
+			return err;
+	} else {
+		pr_err("Unknown Keyboard language. Ignoring\n");
+		return -EINVAL;
+	}
+
+	tpacpi_disclose_usertask(attr->attr.name,
+			"keyboard language is set to  %s\n", buf);
+
+	sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang");
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(keyboard_lang);
+
+static struct attribute *kbdlang_attributes[] = {
+	&dev_attr_keyboard_lang.attr,
+	NULL
+};
+
+static const struct attribute_group kbdlang_attr_group = {
+	.attrs = kbdlang_attributes,
+};
+
+static int tpacpi_kbdlang_init(struct ibm_init_struct *iibm)
+{
+	int err, output;
+
+	err = get_keyboard_lang(&output);
+	/*
+	 * If support isn't available (ENODEV) then don't return an error
+	 * just don't create the sysfs group
+	 */
+	if (err == -ENODEV)
+		return 0;
+
+	if (err)
+		return err;
+
+	/* Platform supports this feature - create the sysfs file */
+	err = sysfs_create_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group);
+
+	return err;
+}
+
+static void kbdlang_exit(void)
+{
+	sysfs_remove_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group);
+}
+
+static struct ibm_struct kbdlang_driver_data = {
+	.name = "kbdlang",
+	.exit = kbdlang_exit,
+};
+
 /****************************************************************************
  ****************************************************************************
  *
@@ -10474,6 +10651,11 @@ static struct ibm_init_struct ibms_init[] __initdata = {
 		.init = tpacpi_proxsensor_init,
 		.data = &proxsensor_driver_data,
 	},
+	{
+		.init = tpacpi_kbdlang_init,
+		.data = &kbdlang_driver_data,
+	},
+
 };
 
 static int __init set_ibm_param(const char *val, const struct kernel_param *kp)
#2 lore raw

Hello Hans ,

Quoted 33 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Tuesday, January 26, 2021 5:34 AM
To: Nitin Joshi <[email protected]>
Cc: [email protected]; [email protected]; Tomoki Maruichi <[email protected]>; Mark Pearson <[email protected]>; [email protected]; Nitin Joshi1 <[email protected]>
Subject: [External] Re: [PATCH] [v2] platform/x86: thinkpad_acpi: set keyboard language

Hi,

Quoted 8 lines · Nitin Joshi

From: Nitin Joshi <[email protected]>

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.

Quoted 6 lines

---
Changes in v2:
- used sysfs_streq() API instead of strcmp
- used ARRAY_SIZE() API instead of strlen
- addressed typo

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-
x86.git/log/?h=review-hans

Quoted 4 lines

Nitn, I did not notice one small issue while testing this on a X1C8 I will send out a follow-up patch addressing that. If you can test the follow-up patch on one of the affected models
(T580 , T590 , T15 Gen 1, etc.) that would be great.

Yes , sure . I will test it . Thank you

Quoted 4 lines

Note this patch will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Quoted 8 lines

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Thanks & Regards,
Nitin Joshi

Quoted 263 lines
Quoted 25 lines
---
 .../admin-guide/laptops/thinkpad-acpi.rst     |  24 +++
 drivers/platform/x86/thinkpad_acpi.c          | 182 ++++++++++++++++++
 2 files changed, 206 insertions(+)
Documentation/admin-guide/laptops/thinkpad-acpi.rst +1 -0
index 5fe1ade88c17..b1188f05a99a 100644
@@ -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

Documentation/admin-guide/laptops/thinkpad-acpi.rst +2 -0
 	rfkill controller switch "tpacpi_uwb_sw": refer to
 	Documentation/driver-api/rfkill.rst for details.
 
+
+Setting keyboard language

Documentation/admin-guide/laptops/thinkpad-acpi.rst Sysfs notes

Quoted 10 lines
Documentation/admin-guide/laptops/thinkpad-acpi.rst +10 -0
+-------------------
+
+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 .

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data

Quoted 22 lines
Documentation/admin-guide/laptops/thinkpad-acpi.rst +13 -0
+
+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
 -----------------
drivers/platform/x86/thinkpad_acpi.c +0 -0
index e03df2881dc6..3cfc4a872c2d 100644
@@ -9982,6 +9982,183 @@ static struct ibm_struct proxsensor_driver_data

= {

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = {

Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +0 -0
 	.exit = proxsensor_exit,
 };
 
 

+/***************************************************************
*****

Quoted 30 lines
drivers/platform/x86/thinkpad_acpi.c +30 -0
+*****
+ * Keyboard language interface
+ */
+
+struct keyboard_lang_data {
+	const char *lang_str;
+	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},
+	{"be", 0x080c},
+	{"cz", 0x0405},
+	{"da", 0x0406},
+	{"de", 0x0c07},
+	{"es", 0x2c0a},
+	{"et", 0x0425},
+	{"fr", 0x040c},
+	{"fr-ch", 0x100c},
+	{"hu", 0x040e},
+	{"it", 0x0410},
+	{"jp", 0x0411},
+	{"nl", 0x0413},
+	{"nn", 0x0414},
+	{"pl", 0x0415},
+	{"pt", 0x0816},

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = {

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+	{"sl", 0x041b},
+	{"sv", 0x081d},
+	{"tr", 0x041f},
+};
+
+static int set_keyboard_lang_command(int command) {
+	acpi_handle sskl_handle;
+	int output;
+
+	if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "SSKL",

&sskl_handle))) {

Quoted 5 lines
drivers/platform/x86/thinkpad_acpi.c +5 -0
+		/* Platform doesn't support SSKL */
+		return -ENODEV;
+	}
+
+	if (!acpi_evalf(sskl_handle, &output, NULL, "dd", command))

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = {

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+		return -EIO;
+
+	return 0;
+}
+
+static int get_keyboard_lang(int *output) {
+	acpi_handle gskl_handle;
+	int kbd_lang;
+
+	if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSKL",

&gskl_handle))) {

Quoted 102 lines
drivers/platform/x86/thinkpad_acpi.c +102 -0
+		/* Platform doesn't support GSKL */
+		return -ENODEV;
+	}
+
+	if (!acpi_evalf(gskl_handle, &kbd_lang, NULL, "dd", 0x02000000))
+		return -EIO;
+
+	*output = kbd_lang;
+
+	return 0;
+}
+
+/* sysfs keyboard language entry */
+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] = "";
+
+	err = get_keyboard_lang(&output);
+	if (err)
+		return err;
+
+	for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+		if (i)
+			strcat(select_lang, " ");
+
+		if (output == keyboard_lang_data[i].lang_code) {
+			strcat(lang, "[");
+			strcat(lang, keyboard_lang_data[i].lang_str);
+			strcat(lang, "]");
+			strcat(select_lang, lang);
+		} else {
+			strcat(select_lang, keyboard_lang_data[i].lang_str);
+		}
+	}
+
+	return sysfs_emit(buf, "%s\n", select_lang); }
+
+static ssize_t keyboard_lang_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	int err, i;
+	bool lang_found = false;
+	int lang_code = 0;
+
+	for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+		if (sysfs_streq(buf, keyboard_lang_data[i].lang_str)) {
+			lang_code = keyboard_lang_data[i].lang_code;
+			lang_found = true;
+			break;
+		}
+	}
+
+	if (lang_found) {
+		lang_code = lang_code | 1 << 24;
+
+		/* Set language code */
+		err = set_keyboard_lang_command(lang_code);
+		if (err)
+			return err;
+	} else {
+		pr_err("Unknown Keyboard language. Ignoring\n");
+		return -EINVAL;
+	}
+
+	tpacpi_disclose_usertask(attr->attr.name,
+			"keyboard language is set to  %s\n", buf);
+
+	sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang");
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(keyboard_lang);
+
+static struct attribute *kbdlang_attributes[] = {
+	&dev_attr_keyboard_lang.attr,
+	NULL
+};
+
+static const struct attribute_group kbdlang_attr_group = {
+	.attrs = kbdlang_attributes,
+};
+
+static int tpacpi_kbdlang_init(struct ibm_init_struct *iibm) {
+	int err, output;
+
+	err = get_keyboard_lang(&output);
+	/*
+	 * If support isn't available (ENODEV) then don't return an error
+	 * just don't create the sysfs group
+	 */
+	if (err == -ENODEV)
+		return 0;
+
+	if (err)
+		return err;
+

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = {

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+	/* Platform supports this feature - create the sysfs file */
+	err = sysfs_create_group(&tpacpi_pdev->dev.kobj,
+&kbdlang_attr_group);
+
+	return err;
+}
+
+static void kbdlang_exit(void)
+{
+	sysfs_remove_group(&tpacpi_pdev->dev.kobj,

&kbdlang_attr_group); }

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = {

Quoted 7 lines
drivers/platform/x86/thinkpad_acpi.c +6 -0
+
+static struct ibm_struct kbdlang_driver_data = {
+	.name = "kbdlang",
+	.exit = kbdlang_exit,
+};
+
 

/****************************************************************
************

Quoted 1 line

*****************************************************************
***********

drivers/platform/x86/thinkpad_acpi.c static struct ibm_init_struct ibms_init[]

Quoted 2 lines

*

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -10474,6 +10651,11 @@ static struct ibm_init_struct ibms_init[]

__initdata = {

Quoted 13 lines
drivers/platform/x86/thinkpad_acpi.c +5 -0
 		.init = tpacpi_proxsensor_init,
 		.data = &proxsensor_driver_data,
 	},
+	{
+		.init = tpacpi_kbdlang_init,
+		.data = &kbdlang_driver_data,
+	},
+
 };
 
 static int __init set_ibm_param(const char *val, const struct

kernel_param *kp)

#3 lore raw
In reply to Nitin Joshi
Quoted 3 lines · Nitin Joshi

From: Nitin Joshi <[email protected]>

Maybe it's a bit late, but... nevertheless my comments below.

Quoted 1 line

This patch is to create sysfs entry for setting keyboard language

create a sysfs

Documentation/admin-guide/laptops/thinkpad-acpi.rst Sysfs notes · line 1479

Quoted 9 lines

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.

Documentation/admin-guide/laptops/thinkpad-acpi.rst +4 -0
+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

because the default

Quoted 1 line

+is set as "english". Hence using this sysfs, user can set correct keyboard

the user can set the correct

Documentation/admin-guide/laptops/thinkpad-acpi.rst Sysfs notes · line 1490

Quoted 10 lines
Documentation/admin-guide/laptops/thinkpad-acpi.rst +10 -0
+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)

Can we keep this sorted?
Also see below.

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 9999

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+struct keyboard_lang_data keyboard_lang_data[] = {
+       {"en", 0},

0x0000 ?

Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +9 -0
+       {"be", 0x080c},
+       {"cz", 0x0405},
+       {"da", 0x0406},
+       {"de", 0x0c07},
+       {"es", 0x2c0a},
+       {"et", 0x0425},
+       {"fr", 0x040c},
+       {"fr-ch", 0x100c},
+       {"hu", 0x040e},

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10018

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+       {"it", 0x0410},
+       {"jp", 0x0411},
+       {"nl", 0x0413},
+       {"nn", 0x0414},
+       {"pl", 0x0415},
+       {"pt", 0x0816},
+       {"sl", 0x041b},
+       {"sv", 0x081d},
+       {"tr", 0x041f},
+};

So, the above definitely has a meaning of the second byte as bit field. I believe that be is something like be-be and so on. We have 0x04,0x08, 0x0c, 0x2c, and 0x10. 0x04 seems like a basic variant, what about the rest?

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10043

Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c +3 -0
+       if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSKL", &gskl_handle))) {
+               /* Platform doesn't support GSKL */
+               return -ENODEV;

Perhaps EOPNOTSUPP is better?

Quoted 1 line

+ }

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10061

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+       char select_lang[80] = "";
+       char lang[8] = "";

I don't think we need assignments and moreover, we need these variables. See below for the details.

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+
+       err = get_keyboard_lang(&output);
+       if (err)
+               return err;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (i)
+                       strcat(select_lang, " ");
+
+               if (output == keyboard_lang_data[i].lang_code) {

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10081

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+                       strcat(lang, "[");
+                       strcat(lang, keyboard_lang_data[i].lang_str);
+                       strcat(lang, "]");
+                       strcat(select_lang, lang);
+               } else {
+                       strcat(select_lang, keyboard_lang_data[i].lang_str);
+               }
+       }
+
+       return sysfs_emit(buf, "%s\n", select_lang);

We have sysfs_emit_at(), please use it instead of these ugly str*() calls.

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10089

Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +8 -0
+}
+
+static ssize_t keyboard_lang_store(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       int err, i;
 
+       bool lang_found = false;

Redundant variable.

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10098

Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +9 -0
+       int lang_code = 0;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (sysfs_streq(buf, keyboard_lang_data[i].lang_str)) {
+                       lang_code = keyboard_lang_data[i].lang_code;
+                       lang_found = true;
+                       break;
+               }
+       }

Don't we have sysfs_match_string() ?

Quoted 1 line

+ if (lang_found) {

Use traditional pattern, like

ret = sysfs_match_string(...);
if (ret < 0)
return ret;

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10108

Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +8 -0
+               lang_code = lang_code | 1 << 24;
+
+               /* Set language code */
+               err = set_keyboard_lang_command(lang_code);
+               if (err)
+                       return err;
+       } else {
 
+               pr_err("Unknown Keyboard language. Ignoring\n");

Why not dev_err() ?

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10119

Quoted 12 lines
drivers/platform/x86/thinkpad_acpi.c +11 -0
+               return -EINVAL;
+       }
+
+       tpacpi_disclose_usertask(attr->attr.name,
+                       "keyboard language is set to  %s\n", buf);
+
+       sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang");
+
+       return count;
+}
 
+

Redundant blank line.

Quoted 1 line

+static DEVICE_ATTR_RW(keyboard_lang);

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10138

Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c +3 -0
+       /*
+        * If support isn't available (ENODEV) then don't return an error
+        * just don't create the sysfs group

Missed period.

Quoted 1 line

+ */

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10149

Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +4 -0
+       /* 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();

Quoted 1 line

+}

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Nitin Joshi

From: Nitin Joshi <[email protected]>

Maybe it's a bit late, but... nevertheless my comments below.

Nitin, if you are not going to submit a series of fix ups as per my comments I would probably do it myself later on. Just tell what you want on this matter,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Hello Andy ,

Quoted 15 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, January 26, 2021 11:22 PM
To: Nitin Joshi <[email protected]>
Cc: Hans de Goede <[email protected]>; Benjamin Berg <[email protected]>; [email protected]; Tomoki Maruichi <[email protected]>; Mark Pearson <[email protected]>; Platform Driver <[email protected]>; Nitin Joshi1 <[email protected]>
Subject: [External] Re: [PATCH] [v2] platform/x86: thinkpad_acpi: set keyboard language

Quoted 1 line · Andy Shevchenko
Quoted 8 lines
Quoted 5 lines · Nitin Joshi
Quoted 2 lines

From: Nitin Joshi <[email protected]>

Maybe it's a bit late, but... nevertheless my comments below.

Nitin, if you are not going to submit a series of fix ups as per my comments I would probably do it myself later on. Just tell what you want on this matter,

Thank you for your comments and its helpful for me as I have just started pushing patch for upstream. Apologize for not replying today morning as I wanted to check it in detail.

I have just replied on your review comment e-mail and will follow-up on that e-mail chain..

Quoted 4 lines

--
With Best Regards,
Andy Shevchenko

Thanks & Regards,
Nitin Joshi

A message that is not in the archive (sent off-list or not yet received): SG2PR03MB27186C2289B137A914B9F0D28CBC0@SG2PR03MB2718.apcprd03.prod.outlook.com

#7 lore raw

Hi,

Quoted 69 lines · On 1/26/21 4:58 PM, Nitin Joshi1 wrote:

Hello Andy ,

Quoted 12 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, January 26, 2021 6:31 AM
To: Nitin Joshi <[email protected]>
Cc: Hans de Goede <[email protected]>; Benjamin Berg <[email protected]>; [email protected]; Tomoki Maruichi <[email protected]>; Mark Pearson <[email protected]>; Platform Driver <[email protected]>; Nitin Joshi1 <[email protected]>
Subject: [External] Re: [PATCH] [v2] platform/x86: thinkpad_acpi: set keyboard language

Quoted 7 lines
Quoted 3 lines · Nitin Joshi

From: Nitin Joshi <[email protected]>

Maybe it's a bit late, but... nevertheless my comments below.

Thank you for comments . It was my mistake , I should have put mailing list before .

Quoted 9 lines
Quoted 1 line

This patch is to create sysfs entry for setting keyboard language

create a sysfs

Quoted 4 lines

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.

Quoted 7 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+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

because the default

Ack . I will correct it.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+is set as "english". Hence using this sysfs, user can set correct
+keyboard

the user can set the correct

Ack . I will correct it .

Quoted 15 lines

Documentation/admin-guide/laptops/thinkpad-acpi.rst Sysfs notes

Quoted 13 lines
Documentation/admin-guide/laptops/thinkpad-acpi.rst +12 -0
+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)

Can we keep this sorted?

Ack . I will make this sorted.

Quoted 2 lines

Also see below.

Quoted 7 lines
Quoted 6 lines

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 9999

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+struct keyboard_lang_data keyboard_lang_data[] = {
+       {"en", 0},

0x0000 ?

Ack . yes , I will update it.

While at it can you also please mark the table static const ?

Quoted 45 lines
Quoted 22 lines
Quoted 11 lines
drivers/platform/x86/thinkpad_acpi.c +9 -0
+       {"be", 0x080c},
+       {"cz", 0x0405},
+       {"da", 0x0406},
+       {"de", 0x0c07},
+       {"es", 0x2c0a},
+       {"et", 0x0425},
+       {"fr", 0x040c},
+       {"fr-ch", 0x100c},
+       {"hu", 0x040e},

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10018

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+       {"it", 0x0410},
+       {"jp", 0x0411},
+       {"nl", 0x0413},
+       {"nn", 0x0414},
+       {"pl", 0x0415},
+       {"pt", 0x0816},
+       {"sl", 0x041b},
+       {"sv", 0x081d},
+       {"tr", 0x041f},
+};
Quoted 2 lines

So, the above definitely has a meaning of the second byte as bit field. I believe that be is something like be-be and so on.

Language Id is based on Language and Location .
You can refer attached pdf file for example 0x0411 is for Japanese layout but 0x04 is not basic
Currently , Lenovo ECFW can change keyboard layout for only few language id by "SSKL" ASL method to fix
"=", "(', ")" numeric keys issue . hence , I have added only few language id (Actually I have received language id supported list from ECFW team).

Quoted 1 line

We have 0x04,0x08, 0x0c, 0x2c, and 0x10. 0x04 seems like a basic variant,

By seeing the attached pdf , it seems not a basic variant.

Quoted 1 line

what about the rest?

As per my understanding , ECFW is either not supporting rest or keyboard layout of others is similar to "English". If in future , ECFW supports any other keyboard layout then we can add it .

Quoted 8 lines

...

Quoted 1 line

+ if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSKL",

&gskl_handle))) {

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+               /* Platform doesn't support GSKL */
+               return -ENODEV;
Quoted 8 lines
Quoted 1 line

Perhaps EOPNOTSUPP is better?

Ack .
How about keeping ENODEV and changing only text as below :
/* Platform doesn't have GSKL method */
As per my understanding , in this case we will get ACPI failue only when GSKL method doesn’t exists in BIOS . So , I think its better to keep ENODEV.

Please correct me , if I am wrong.

I think we should keep -ENODEV here, since this path is hit on devices which do not have the kbd-lang feature and returning -ENODEV from the getter in this case is how this is handled in most other getters in thinkpad_acpi.

Quoted 46 lines
Quoted 11 lines
Quoted 2 lines

+ }

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10061

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+       char select_lang[80] = "";
+       char lang[8] = "";

I don't think we need assignments and moreover, we need these variables. See below for the details.

Ack .

Quoted 14 lines
Quoted 14 lines
drivers/platform/x86/thinkpad_acpi.c +14 -0
+
+       err = get_keyboard_lang(&output);
+       if (err)
+               return err;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (i)
+                       strcat(select_lang, " ");
+
+               if (output == keyboard_lang_data[i].lang_code) {
+                       strcat(lang, "[");
+                       strcat(lang, keyboard_lang_data[i].lang_str);
+                       strcat(lang, "]");
+                       strcat(select_lang, lang);
Quoted 8 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10081

Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +6 -0
+               } else {
+                       strcat(select_lang, keyboard_lang_data[i].lang_str);
+               }
+       }
+
+       return sysfs_emit(buf, "%s\n", select_lang);

We have sysfs_emit_at(), please use it instead of these ugly str*() calls.

Ack . I will check about sysfs_emit_at() and get back on this . Thanks for suggestion.

Quoted 8 lines
Quoted 7 lines
drivers/platform/x86/thinkpad_acpi.c +6 -0
+}
+
+static ssize_t keyboard_lang_store(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf, size_t count) {
+       int err, i;
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+ bool lang_found = false;

Redundant variable.

Ack . I think if we use sysfs_match_string() then it will be redundant . But , I need to check it .

sysfs_match_string() only works on arrays of strings, in this case we have an array of struct keyboard_lang_data, so using it here will not work.

Quoted 84 lines
Quoted 12 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10098

Quoted 11 lines
drivers/platform/x86/thinkpad_acpi.c +9 -0
+       int lang_code = 0;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (sysfs_streq(buf, keyboard_lang_data[i].lang_str)) {
+                       lang_code = keyboard_lang_data[i].lang_code;
+                       lang_found = true;
+                       break;
+               }
+       }
Quoted 1 line

Don't we have sysfs_match_string() ?

Ack . I will check it and get back .

Quoted 9 lines
Quoted 2 lines

+ if (lang_found) {

Use traditional pattern, like

ret = sysfs_match_string(...);
if (ret < 0)
return ret;

Noted

Quoted 11 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10108

Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +8 -0
+               lang_code = lang_code | 1 << 24;
+
+               /* Set language code */
+               err = set_keyboard_lang_command(lang_code);
+               if (err)
+                       return err;
+       } else {
 
+               pr_err("Unknown Keyboard language. Ignoring\n");

Why not dev_err() ?

Ack . I will change it . The reason for using dev_err will only to provide better message to userspace . is it correct ?

Quoted 12 lines
Quoted 11 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+               return -EINVAL;
+       }
+
+       tpacpi_disclose_usertask(attr->attr.name,
+                       "keyboard language is set to  %s\n", buf);
+
+       sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang");
+
+       return count;
+}
Quoted 4 lines
Quoted 1 line

+

Redundant blank line.

Ack. I will correct it.

Quoted 10 lines
Quoted 1 line

+static DEVICE_ATTR_RW(keyboard_lang);

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10138

Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c +3 -0
+       /*
+        * If support isn't available (ENODEV) then don't return an error
+        * just don't create the sysfs group

Missed period.

Ack . I will correct it.

Quoted 4 lines
Quoted 1 line

+ */

...

Quoted 8 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10149

Quoted 5 lines
drivers/platform/x86/thinkpad_acpi.c +5 -0
+       /* 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();

Ack . I will correct it .

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+}

--
With Best Regards,
Andy Shevchenko

I will update patch on top of my last patch and send it for review by next week . Please correct me , if I am missing something as I have just started pushing patch for upstream.

Sounds good, thank you.

Regards,

Hans

#8 lore raw

Hello Hans ,

Quoted 84 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Subject: Re: [External] Re: [PATCH] [v2] platform/x86: thinkpad_acpi: set keyboard language

Hi,

Quoted 9 lines · On 1/26/21 4:58 PM, Nitin Joshi1 wrote:

Hello Andy ,

Quoted 7 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, January 26, 2021 6:31 AM
To: Nitin Joshi <[email protected]>
Cc: Hans de Goede <[email protected]>; Benjamin Berg <[email protected]>; [email protected]; Tomoki Maruichi <[email protected]>; Mark Pearson <[email protected]>;

Platform

Quoted 5 lines
Quoted 5 lines

Driver <[email protected]>; Nitin Joshi1 <[email protected]>
Subject: [External] Re: [PATCH] [v2] platform/x86: thinkpad_acpi: set keyboard language

Quoted 8 lines
Quoted 7 lines · Nitin Joshi
Quoted 3 lines

From: Nitin Joshi <[email protected]>

Maybe it's a bit late, but... nevertheless my comments below.

Thank you for comments . It was my mistake , I should have put mailing list

before .

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

This patch is to create sysfs entry for setting keyboard language

create a sysfs

Quoted 6 lines

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.

+This feature is used to set keyboard language to ECFW using ASL

interface.

Quoted 40 lines
Quoted 6 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+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

because the default

Ack . I will correct it.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+is set as "english". Hence using this sysfs, user can set correct
+keyboard

the user can set the correct

Ack . I will correct it .

Quoted 17 lines
Quoted 5 lines
(quoted diff) +4 -0
+language to ECFW and then these key's will work correctly .
+
+Example of command to set keyboard language is mentioned below::
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+        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)

Can we keep this sorted?

Ack . I will make this sorted.

Quoted 4 lines

Also see below.

...

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 9999

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+struct keyboard_lang_data keyboard_lang_data[] = {
+       {"en", 0},

0x0000 ?

Ack . yes , I will update it.

While at it can you also please mark the table static const ?

Yes , I will modify it .

Quoted 55 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
drivers/platform/x86/thinkpad_acpi.c +19 -0
+       {"be", 0x080c},
+       {"cz", 0x0405},
+       {"da", 0x0406},
+       {"de", 0x0c07},
+       {"es", 0x2c0a},
+       {"et", 0x0425},
+       {"fr", 0x040c},
+       {"fr-ch", 0x100c},
+       {"hu", 0x040e},
+       {"it", 0x0410},
+       {"jp", 0x0411},
+       {"nl", 0x0413},
+       {"nn", 0x0414},
+       {"pl", 0x0415},
+       {"pt", 0x0816},
+       {"sl", 0x041b},
+       {"sv", 0x081d},
+       {"tr", 0x041f},
+};
Quoted 7 lines
Quoted 2 lines

So, the above definitely has a meaning of the second byte as bit field. I believe that be is something like be-be and so on.

Language Id is based on Language and Location .
You can refer attached pdf file for example 0x0411 is for Japanese layout but 0x04 is not basic Currently , Lenovo ECFW can change keyboard layout for only few language id by "SSKL" ASL method to fix "=", "(',

")" numeric keys issue . hence , I have added only few language id (Actually I have received language id supported list from ECFW team).

Quoted 7 lines
Quoted 3 lines

We have 0x04,0x08, 0x0c, 0x2c, and 0x10. 0x04 seems like a basic variant,

By seeing the attached pdf , it seems not a basic variant.

Quoted 1 line

what about the rest?

As per my understanding , ECFW is either not supporting rest or keyboard

layout of others is similar to "English".

Quoted 7 lines

If in future , ECFW supports any other keyboard layout then we can add it .

Quoted 5 lines

...

Quoted 1 line

+ if (ACPI_FAILURE(acpi_get_handle(hkey_handle, "GSKL",

&gskl_handle))) {

Quoted 8 lines
Quoted 4 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10043

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+               /* Platform doesn't support GSKL */
+               return -ENODEV;

Perhaps EOPNOTSUPP is better?

Ack .
How about keeping ENODEV and changing only text as below :
/* Platform doesn't have GSKL method */ As per my understanding , in this case we will get ACPI failue only when GSKL method doesn’t exists in

Quoted 9 lines

BIOS .

Quoted 3 lines

So , I think its better to keep ENODEV.

Please correct me , if I am wrong.

I think we should keep -ENODEV here, since this path is hit on devices which do not have the kbd-lang feature and returning -ENODEV from the getter in this case is how this is handled in most other getters in thinkpad_acpi.

Noted .

Quoted 48 lines
Quoted 48 lines
Quoted 11 lines
Quoted 2 lines

+ }

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10061

Quoted 2 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+       char select_lang[80] = "";
+       char lang[8] = "";

I don't think we need assignments and moreover, we need these variables. See below for the details.

Ack .

Quoted 14 lines
Quoted 14 lines
drivers/platform/x86/thinkpad_acpi.c +14 -0
+
+       err = get_keyboard_lang(&output);
+       if (err)
+               return err;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (i)
+                       strcat(select_lang, " ");
+
+               if (output == keyboard_lang_data[i].lang_code) {
+                       strcat(lang, "[");
+                       strcat(lang, keyboard_lang_data[i].lang_str);
+                       strcat(lang, "]");
+                       strcat(select_lang, lang);
Quoted 8 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10081

Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +6 -0
+               } else {
+                       strcat(select_lang, keyboard_lang_data[i].lang_str);
+               }
+       }
+
+       return sysfs_emit(buf, "%s\n", select_lang);

We have sysfs_emit_at(), please use it instead of these ugly str*() calls.

Ack . I will check about sysfs_emit_at() and get back on this . Thanks for suggestion.

Quoted 10 lines
Quoted 9 lines
drivers/platform/x86/thinkpad_acpi.c +7 -0
+}
+
+static ssize_t keyboard_lang_store(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf, size_t count) {
+       int err, i;
 
+       bool lang_found = false;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Redundant variable.

Ack . I think if we use sysfs_match_string() then it will be redundant . But , I need to check it .

sysfs_match_string() only works on arrays of strings, in this case we have an array of struct keyboard_lang_data, so using it here will not work.

Noted with thanks .

Quoted 94 lines
Quoted 35 lines
Quoted 13 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10098

Quoted 12 lines
drivers/platform/x86/thinkpad_acpi.c +9 -0
+       int lang_code = 0;
+
+       for (i = 0; i < ARRAY_SIZE(keyboard_lang_data); i++) {
+               if (sysfs_streq(buf, keyboard_lang_data[i].lang_str)) {
+                       lang_code = keyboard_lang_data[i].lang_code;
+                       lang_found = true;
+                       break;
+               }
+       }
Quoted 1 line

Don't we have sysfs_match_string() ?

Ack . I will check it and get back .

Quoted 9 lines
Quoted 2 lines

+ if (lang_found) {

Use traditional pattern, like

ret = sysfs_match_string(...);
if (ret < 0)
return ret;

Noted

Quoted 8 lines
Quoted 7 lines
drivers/platform/x86/thinkpad_acpi.c +7 -0
+               lang_code = lang_code | 1 << 24;
+
+               /* Set language code */
+               err = set_keyboard_lang_command(lang_code);
+               if (err)
+                       return err;
+       } else {
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+ pr_err("Unknown Keyboard language. Ignoring\n");

Why not dev_err() ?

Ack . I will change it . The reason for using dev_err will only to provide better

message to userspace . is it correct ?

Quoted 45 lines
Quoted 12 lines
Quoted 11 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+               return -EINVAL;
+       }
+
+       tpacpi_disclose_usertask(attr->attr.name,
+                       "keyboard language is set to  %s\n", buf);
+
+       sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang");
+
+       return count;
+}
Quoted 4 lines
Quoted 1 line

+

Redundant blank line.

Ack. I will correct it.

Quoted 10 lines
Quoted 1 line

+static DEVICE_ATTR_RW(keyboard_lang);

...

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10138

Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c +3 -0
+       /*
+        * If support isn't available (ENODEV) then don't return an error
+        * just don't create the sysfs group

Missed period.

Ack . I will correct it.

Quoted 4 lines
Quoted 1 line

+ */

...

Quoted 8 lines

drivers/platform/x86/thinkpad_acpi.c static struct ibm_struct proxsensor_driver_data = { · line 10149

Quoted 5 lines
drivers/platform/x86/thinkpad_acpi.c +5 -0
+       /* 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();

Ack . I will correct it .

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

+}

--
With Best Regards,
Andy Shevchenko

I will update patch on top of my last patch and send it for review by next

week .

Quoted 8 lines
Quoted 1 line

Please correct me , if I am missing something as I have just started pushing

patch for upstream.

Sounds good, thank you.

Regards,

Hans

Thanks & Regards,
Nitin Joshi