Skip to contentSkip to conversation

toshiba_acpi: Qosmio backlight and keymap fixes

PATCH In review Azael Avalos 2 participants 6 messages Aug 4, 2014

Subsystems (2)
lore
Share & tools
lore

Azael Avalos

author maintainer
#0 lore raw

cover toshiba_acpi: Qosmio backlight and keymap fixes

The following two patches fixes some issues regarding the backlight method on Qosmios series X500/X505 and X75-A (and probably others too), as well as adding the latter to the new alternate keymap list.

Azael Avalos (2):
toshiba_acpi: Add extra check to backlight code
toshiba_acpi: Add Qosmio X75-A to the alt keymap dmi list

 drivers/platform/x86/toshiba_acpi.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
Signature · 1 line
2.0.0
author maintainer
#1 lore raw

PATCH 1/2 toshiba_acpi: Add extra check to backlight code

Some Toshiba models (most notably Qosmios) come with an incomplete backlight method where the AML code doesn't check for write or read commands and always returns HCI_SUCCESS and the actual brightness (and in some cases the max brightness), thus allowing the backlight interface to be registered without write support.

This patch changes the set_lcd_brightness function, checking the returned values for values greater than zero to avoid registering a broken backlight interface.

---
 drivers/platform/x86/toshiba_acpi.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/platform/x86/toshiba_acpi.c +17 -4
index 76441dc..1ed2ffc 100644
@@ -872,7 +872,9 @@ static int lcd_proc_open(struct inode *inode, struct file *file)
 
 static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
 {
-	u32 hci_result;
+	u32 in[HCI_WORDS] = { HCI_SET, HCI_LCD_BRIGHTNESS, 0, 0, 0, 0 };
+	u32 out[HCI_WORDS];
+	acpi_status status;
 
 	if (dev->tr_backlight_supported) {
 		bool enable = !value;
@@ -883,9 +885,20 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
 			value--;
 	}
 
-	value = value << HCI_LCD_BRIGHTNESS_SHIFT;
-	hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result);
-	return hci_result == HCI_SUCCESS ? 0 : -EIO;
+	in[2] = value << HCI_LCD_BRIGHTNESS_SHIFT;
+	status = hci_raw(dev, in, out);
+	if (ACPI_FAILURE(status) || out[0] == HCI_FAILURE) {
+		pr_err("ACPI call to set brightness failed");
+		return -EIO;
+	}
+	/* Extra check for "incomplete" backlight method, where the AML code
+	 * doesn't check for HCI_SET or HCI_GET and returns HCI_SUCCESS,
+	 * the actual brightness, and in some cases the max brightness.
+	 */
+	if (out[2] > 0  || out[3] == 0xE000)
+		return -ENODEV;
+
+	return out[0] == HCI_SUCCESS ? 0 : -EIO;
 }
 
 static int set_lcd_status(struct backlight_device *bd)
Signature · 1 line
2.0.0
#2 lore raw

Re: [PATCH 1/2] toshiba_acpi: Add extra check to backlight code

Quoted 7 lines · Azael Avalos

Some Toshiba models (most notably Qosmios) come with an incomplete backlight method where the AML code doesn't check for write or read commands and always returns HCI_SUCCESS and the actual brightness (and in some cases the max brightness), thus allowing the backlight interface to be registered without write support.

Quoted 8 lines

This patch changes the set_lcd_brightness function, checking the returned values for values greater than zero to avoid registering a broken backlight interface.

---
 drivers/platform/x86/toshiba_acpi.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

author maintainer
#3 lore raw

PATCH 2/2 toshiba_acpi: Add Qosmio X75-A to the alt keymap dmi list

In reply to Azael Avalos

The Toshiba Qosmio X75-A series models also come with the new keymap layout.

This patch adds this model to the alt_keymap_dmi list, along with an extra key found on these models.

---
 drivers/platform/x86/toshiba_acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/platform/x86/toshiba_acpi.c +7 -0
index 1ed2ffc..34b7303 100644
@@ -222,6 +222,12 @@ static const struct dmi_system_id toshiba_alt_keymap_dmi[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "Satellite M840"),
 		},
 	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Qosmio X75-A"),
+		},
+	},
 	{}
 };
 
@@ -229,6 +235,7 @@ static const struct key_entry toshiba_acpi_alt_keymap[] = {
 	{ KE_KEY, 0x157, { KEY_MUTE } },
 	{ KE_KEY, 0x102, { KEY_ZOOMOUT } },
 	{ KE_KEY, 0x103, { KEY_ZOOMIN } },
+	{ KE_KEY, 0x12c, { KEY_KBDILLUMTOGGLE } },
 	{ KE_KEY, 0x139, { KEY_ZOOMRESET } },
 	{ KE_KEY, 0x13e, { KEY_SWITCHVIDEOMODE } },
 	{ KE_KEY, 0x13c, { KEY_BRIGHTNESSDOWN } },
Signature · 1 line
2.0.0
#4 lore raw

Re: [PATCH 2/2] toshiba_acpi: Add Qosmio X75-A to the alt keymap dmi list

Quoted 10 lines · Azael Avalos

The Toshiba Qosmio X75-A series models also come with the new keymap layout.

This patch adds this model to the alt_keymap_dmi list, along with an extra key found on these models.

---
 drivers/platform/x86/toshiba_acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>

#5 lore raw
In reply to Azael Avalos
Quoted 5 lines · Azael Avalos

The following two patches fixes some issues regarding the backlight method on Qosmios series X500/X505 and X75-A (and probably others too), as well as adding the latter to the new alternate keymap list.

Quoted 7 lines

Azael Avalos (2):
toshiba_acpi: Add extra check to backlight code
toshiba_acpi: Add Qosmio X75-A to the alt keymap dmi list

 drivers/platform/x86/toshiba_acpi.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.

</formletter>