[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#599768: patch



found 599768 3.1.0-1
tags 599768 +patch

Bug still found in latest kernel (3.1.0), quite annoying, you can find
attached a hack that goes out into making it work, for some reason, the
keys still don't work on resume.

patch: http://core.evilgiggle.com/~xaiki/hacks/toshiba_acpi/0002-toshiba_acpi-implement-and-use-HCI_BACKLIGHT.patch

>From 16cdcbb36dafb4c01cb040284f6424d13e94cce3 Mon Sep 17 00:00:00 2001
From: Niv Sardi <xaiki@evilgiggle.com>
Date: Sun, 13 Nov 2011 19:28:05 -0430
Subject: [PATCH 2/2] toshiba_acpi: implement and use HCI_BACKLIGHT,

this is mostly taken from the old toshset code, it seems to partially
fix the bug where toshiba backlight is broken after suspend. (getting:
ACPI: can't set backlight, in dmesg.)

this makes /sys/class/backlight/toshiba/brightness work but for some
reason after suspend the events are still recieved (they get printed
out on the .notify handler), but they don't trigger backlight
code. (result beeing that the backlight keys DO NOT work but, setting
/sys/class/backlight/toshiba/brightness DOES).

this is hackish and needs clean up, but does solve part of the issue.

Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
---
 drivers/platform/x86/toshiba_acpi.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 00e9e91..45a94b9 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -94,7 +94,10 @@ MODULE_LICENSE("GPL");
 #define HCI_EMPTY			0x8c00
 
 /* registers */
+#define	HCI_BACKLIGHT       		0x0002
+#define	HCI_AC_ADAPTOR      		0x0003
 #define HCI_FAN				0x0004
+#define	HCI_TR_BACKLIGHT       		0x0005
 #define HCI_SYSTEM_EVENT		0x0016
 #define HCI_VIDEO_OUT			0x001c
 #define HCI_HOTKEY_EVENT		0x001e
@@ -548,11 +551,17 @@ static int lcd_proc_open(struct inode *inode, struct file *file)
 
 static int set_lcd(struct toshiba_acpi_dev *dev, int value)
 {
-	u32 hci_result;
+	u32 r1, r2, val;
 
 	value = value << HCI_LCD_BRIGHTNESS_SHIFT;
-	hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result);
-	return hci_result == HCI_SUCCESS ? 0 : -EIO;
+	hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &r1);
+	if (ACPI_FAILURE(hci_read1(dev, HCI_BACKLIGHT, &val, &r2)))
+		pr_warn("Failed to enable backlight\n");
+	pr_debug("restoring backlight, state: %d\n", val);
+	if (ACPI_FAILURE(hci_write1(dev, HCI_BACKLIGHT, 0x1, &r2)))
+		pr_warn("Failed to enable backlight\n");
+
+	return ((r1 == r2) && (r1  == HCI_SUCCESS)) ? 0 : -EIO;
 }
 
 static int set_lcd_status(struct backlight_device *bd)
@@ -1105,6 +1114,13 @@ static int __devinit toshiba_acpi_add(struct acpi_device *acpi_dev)
 
 	/* enable event fifo */
 	hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result);
+	hci_write1(dev, HCI_HOTKEY_EVENT, 0x9, &hci_result);
+
+	if (ACPI_FAILURE(hci_read1(dev, HCI_BACKLIGHT, &dummy, &hci_result)))
+		pr_warn("Failed to enable backlight\n");
+	pr_debug("restoring backlight, state: %d\n", dummy);
+	if (ACPI_FAILURE(hci_write1(dev, HCI_BACKLIGHT, 1, &hci_result)))
+		pr_warn("Failed to enable backlight\n");
 
 	props.type = BACKLIGHT_PLATFORM;
 	props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
@@ -1208,6 +1224,12 @@ static int toshiba_acpi_resume(struct acpi_device *acpi_dev)
 	if (ACPI_FAILURE(hci_write1(dev, HCI_HOTKEY_EVENT, 0x9, &result)))
 		pr_warn("Failed to enable hotkey events\n");
 
+	if (ACPI_FAILURE(hci_read1(dev, HCI_BACKLIGHT, &val, &result)))
+		pr_warn("Failed to enable backlight\n");
+	pr_debug("restoring backlight, state: %d\n", val);
+	if (ACPI_FAILURE(hci_write1(dev, HCI_BACKLIGHT, 0x1, &result)))
+		pr_warn("Failed to enable backlight\n");
+
 	return 0;
 }
 
-- 
1.7.8.rc0

cheers,
-- 
Niv Sardi

Reply to: