From: Matthew Garrett <mjg59@srcf.ucam.org>
To: john@neggie.net
Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: [PATCH] Add generic backlight support to toshiba_acpi driver
Date: Tue, 7 Feb 2006 13:34:56 +0000 [thread overview]
Message-ID: <20060207133456.GA2452@srcf.ucam.org> (raw)
The included patch adds support for interacting with the toshiba_acpi
backlight control through the generic backlight interface
(/sys/class/backlight).
ACPI folk: this gives us the benefit of a consistent interface to LCD
brightness. Is it worth me converting the other drivers over?
Signed-Off-By: Matthew Garrett <mjg59@srcf.ucam.org>
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 5243f0c..69ed5c2 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -215,7 +215,7 @@ config ACPI_IBM
config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras"
- depends on X86
+ depends on X86 && BACKLIGHT_DEVICE
default y
---help---
This driver adds support for access to certain system settings
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index b2fa688..f263f62 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -60,6 +60,7 @@
#include <linux/suspend.h>
#include <linux/miscdevice.h>
#include <linux/toshiba.h>
+#include <linux/backlight.h>
#include <asm/io.h>
#include <asm/uaccess.h>
@@ -117,6 +118,8 @@ MODULE_LICENSE("GPL");
#define HCI_VIDEO_OUT_CRT 0x2
#define HCI_VIDEO_OUT_TV 0x4
+static struct backlight_device *tosh_backlight_device;
+
/* utility
*/
@@ -315,6 +318,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;
@@ -333,6 +349,22 @@ 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 char *read_video(char *p)
{
u32 hci_result;
@@ -588,6 +620,13 @@ static struct miscdevice tosh_device = {
&tosh_fops
};
+static struct backlight_properties toshbl_data = {
+ .owner = THIS_MODULE,
+ .get_brightness = tosh_get_brightness,
+ .set_brightness = tosh_set_brightness,
+ .max_brightness = HCI_LCD_BRIGHTNESS_LEVELS,
+};
+
static void
setup_tosh_info(void)
{
@@ -891,6 +930,12 @@ static int __init toshiba_acpi_init(void
}
}
+ 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;
}
@@ -909,6 +954,8 @@ static void __exit toshiba_acpi_exit(voi
old_driver_emulation_exit();
+ backlight_device_unregister(tosh_backlight_device);
+
printk(MY_INFO "Toshiba Laptop ACPI Extras unloaded\n");
return;
--
Matthew Garrett | mjg59@srcf.ucam.org
next reply other threads:[~2006-02-07 13:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-07 13:34 Matthew Garrett [this message]
2006-02-08 9:07 ` [PATCH] Add generic backlight support to toshiba_acpi driver Pavel Machek
2006-02-09 16:47 ` Jan Engelhardt
2006-02-09 16:54 ` Matthew Garrett
2006-02-09 17:17 ` Jan Engelhardt
2006-02-09 17:51 ` Ben Slusky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060207133456.GA2452@srcf.ucam.org \
--to=mjg59@srcf.ucam.org \
--cc=john@neggie.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox