* Re: PATCH [3/3]: Provide generic backlight support in Toshiba ACPI driver
@ 2006-04-18 16:49 Andrey Borzenkov
0 siblings, 0 replies; 3+ messages in thread
From: Andrey Borzenkov @ 2006-04-18 16:49 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-kernel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> @@ -546,6 +591,12 @@ static int __init toshiba_acpi_init(void
> remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
> }
>
> + tosh_backlight_device = backlight_device_register ("tosh-bl", NULL,
> + &toshbl_data);
> +
> + if (IS_ERR (tosh_backlight_device))
> + printk("Failed to register Toshiba backlight device\n");
> +
> return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
> }
>
Should not this be
if (IS_ERR (tosh_backlight_device)) {
printk("Failed to register Toshiba backlight device\n");
tosh_backlight_device = NULL;
}
> @@ -556,6 +607,8 @@ static void __exit toshiba_acpi_exit(voi
> if (toshiba_proc_dir)
> remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
>
> + backlight_device_unregister(tosh_backlight_device);
> +
> return;
> }
What if it failed register before?
- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFERRiyR6LMutpd94wRAgldAJ4mK7HeL0UUY29XewfrCODvfa3t7wCgqLN8
dPbb6SKWJrMdmO3s/o7Gnns=
=JhuH
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH [3/3]: Provide generic backlight support in Toshiba ACPI driver
2006-04-19 18:49 ` PATCH [2/3]: Provide generic backlight support in IBM " Matthew Garrett
@ 2006-04-19 18:50 ` Matthew Garrett
0 siblings, 0 replies; 3+ messages in thread
From: Matthew Garrett @ 2006-04-19 18:50 UTC (permalink / raw)
To: Patrick Mochel; +Cc: linux-kernel, linux-acpi
Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
diff -ur drivers/acpi.bak/Kconfig drivers/acpi/Kconfig
--- drivers/acpi.bak/Kconfig 2006-04-18 08:51:49 +0100
+++ a/drivers/acpi/Kconfig 2006-04-19 19:37:08 +0100
@@ -220,6 +220,7 @@
config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras"
depends on X86
+ select BACKLIGHT_DEVICE
---help---
This driver adds support for access to certain system settings
on "legacy free" Toshiba laptops. These laptops can be recognized by
diff -ur drivers/acpi.bak/toshiba_acpi.c drivers/acpi/toshiba_acpi.c
--- drivers/acpi.bak/toshiba_acpi.c 2006-04-03 04:22:10 +0100
+++ a/drivers/acpi/toshiba_acpi.c 2006-04-19 19:37:48 +0100
@@ -41,6 +41,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
+#include <linux/backlight.h>
#include <asm/uaccess.h>
#include <acpi/acpi_drivers.h>
@@ -97,6 +98,8 @@
#define HCI_VIDEO_OUT_CRT 0x2
#define HCI_VIDEO_OUT_TV 0x4
+static struct backlight_device *tosh_backlight_device;
+
/* utility
*/
@@ -289,6 +292,19 @@
return p;
}
+static int tosh_get_brightness(struct backlight_device *bd)
+{
+ int brightness;
+ u32 hci_result;
+
+ hci_read1(HCI_LCD_BRIGHTNESS, &brightness, &hci_result);
+ if (hci_result == HCI_SUCCESS) {
+ brightness = brightness >> HCI_LCD_BRIGHTNESS_SHIFT;
+ return brightness;
+ } else
+ return 0;
+}
+
static unsigned long write_lcd(const char *buffer, unsigned long count)
{
int value;
@@ -307,6 +323,28 @@
return count;
}
+static int tosh_set_brightness(int brightness)
+{
+ u32 hci_result;
+
+ if (brightness >= 0 && brightness < HCI_LCD_BRIGHTNESS_LEVELS) {
+ brightness= brightness << HCI_LCD_BRIGHTNESS_SHIFT;
+ hci_write1(HCI_LCD_BRIGHTNESS, brightness, &hci_result);
+ if (hci_result != HCI_SUCCESS)
+ return -EFAULT;
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int tosh_update_brightness(struct backlight_device *bd)
+{
+ int value = bd->props->brightness;
+ return tosh_set_brightness(value);
+}
+
static char *read_video(char *p)
{
u32 hci_result;
@@ -477,6 +515,13 @@
{NULL}
};
+static struct backlight_properties toshbl_data = {
+ .owner = THIS_MODULE,
+ .get_brightness = tosh_get_brightness,
+ .update_status = tosh_update_brightness,
+ .max_brightness = HCI_LCD_BRIGHTNESS_LEVELS,
+};
+
static acpi_status __init add_device(void)
{
struct proc_dir_entry *proc;
@@ -546,6 +591,14 @@
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
}
+ tosh_backlight_device = backlight_device_register ("tosh-bl", NULL,
+ &toshbl_data);
+
+ if (IS_ERR (tosh_backlight_device)) {
+ printk("Failed to register Toshiba backlight device\n");
+ tosh_backlight_device = NULL;
+ }
+
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
@@ -556,6 +609,9 @@
if (toshiba_proc_dir)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
+ if (tosh_backlight_device)
+ backlight_device_unregister(tosh_backlight_device);
+
return;
}
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH [3/3]: Provide generic backlight support in Toshiba ACPI driver
2006-04-18 8:30 ` PATCH [2/3]: Provide generic backlight support in IBM " Matthew Garrett
@ 2006-04-18 8:32 ` Matthew Garrett
0 siblings, 0 replies; 3+ messages in thread
From: Matthew Garrett @ 2006-04-18 8:32 UTC (permalink / raw)
To: linux-kernel, linux-acpi
This patch provides support for altering Toshiba backlight brightness
via /sys/class/backlight. It does not remove the legacy /proc interface.
Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>
diff -urp drivers/acpi.bak/Kconfig drivers/acpi/Kconfig
--- drivers/acpi.bak/Kconfig 2006-04-18 08:51:49 +0100
+++ a/drivers/acpi/Kconfig 2006-04-18 09:24:45 +0100
@@ -219,7 +219,7 @@ config ACPI_IBM_DOCK
config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras"
- depends on X86
+ depends on X86 && BACKLIGHT_DEVICE
---help---
This driver adds support for access to certain system settings
on "legacy free" Toshiba laptops. These laptops can be recognized by
diff -urp drivers/acpi.bak/toshiba_acpi.c drivers/acpi/toshiba_acpi.c
--- drivers/acpi.bak/toshiba_acpi.c 2006-04-03 04:22:10 +0100
+++ a/drivers/acpi/toshiba_acpi.c 2006-04-18 09:26:41 +0100
@@ -41,6 +41,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
+#include <linux/backlight.h>
#include <asm/uaccess.h>
#include <acpi/acpi_drivers.h>
@@ -97,6 +98,8 @@ MODULE_LICENSE("GPL");
#define HCI_VIDEO_OUT_CRT 0x2
#define HCI_VIDEO_OUT_TV 0x4
+static struct backlight_device *tosh_backlight_device;
+
/* utility
*/
@@ -289,6 +292,19 @@ static char *read_lcd(char *p)
return p;
}
+static int tosh_get_brightness(struct backlight_device *bd)
+{
+ int brightness;
+ u32 hci_result;
+
+ hci_read1(HCI_LCD_BRIGHTNESS, &brightness, &hci_result);
+ if (hci_result == HCI_SUCCESS) {
+ brightness = brightness >> HCI_LCD_BRIGHTNESS_SHIFT;
+ return brightness;
+ } else
+ return 0;
+}
+
static unsigned long write_lcd(const char *buffer, unsigned long count)
{
int value;
@@ -307,6 +323,28 @@ static unsigned long write_lcd(const cha
return count;
}
+static int tosh_set_brightness(struct backlight_device *bd, int brightness)
+{
+ u32 hci_result;
+
+ if (brightness >= 0 && brightness < HCI_LCD_BRIGHTNESS_LEVELS) {
+ brightness= brightness << HCI_LCD_BRIGHTNESS_SHIFT;
+ hci_write1(HCI_LCD_BRIGHTNESS, brightness, &hci_result);
+ if (hci_result != HCI_SUCCESS)
+ return -EFAULT;
+ } else {
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int tosh_update_brightness(struct backlight_device *bd)
+{
+ int value = bd->props->brightness;
+ return tosh_set_brightness(bd, value);
+}
+
static char *read_video(char *p)
{
u32 hci_result;
@@ -477,6 +515,13 @@ static ProcItem proc_items[] = {
{NULL}
};
+static struct backlight_properties toshbl_data = {
+ .owner = THIS_MODULE,
+ .get_brightness = tosh_get_brightness,
+ .update_status = tosh_update_brightness,
+ .max_brightness = HCI_LCD_BRIGHTNESS_LEVELS,
+};
+
static acpi_status __init add_device(void)
{
struct proc_dir_entry *proc;
@@ -546,6 +591,12 @@ static int __init toshiba_acpi_init(void
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
}
+ tosh_backlight_device = backlight_device_register ("tosh-bl", NULL,
+ &toshbl_data);
+
+ if (IS_ERR (tosh_backlight_device))
+ printk("Failed to register Toshiba backlight device\n");
+
return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
}
@@ -556,6 +607,8 @@ static void __exit toshiba_acpi_exit(voi
if (toshiba_proc_dir)
remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
+ backlight_device_unregister(tosh_backlight_device);
+
return;
}
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-19 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18 16:49 PATCH [3/3]: Provide generic backlight support in Toshiba ACPI driver Andrey Borzenkov
-- strict thread matches above, loose matches on Subject: below --
2006-04-18 8:29 PATCH [1/3]: Provide generic backlight support in Asus " Matthew Garrett
2006-04-18 8:30 ` PATCH [2/3]: Provide generic backlight support in IBM " Matthew Garrett
2006-04-18 8:32 ` PATCH [3/3]: Provide generic backlight support in Toshiba " Matthew Garrett
2006-04-18 16:11 ` PATCH [1/3]: Provide generic backlight support in Asus " Patrick Mochel
2006-04-19 18:49 ` Matthew Garrett
2006-04-19 18:49 ` PATCH [2/3]: Provide generic backlight support in IBM " Matthew Garrett
2006-04-19 18:50 ` PATCH [3/3]: Provide generic backlight support in Toshiba " Matthew Garrett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®