public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg59@srcf.ucam.org>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Pavel Machek <pavel@ucw.cz>,
	john@neggie.net, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org
Subject: Re: [PATCH] Add generic backlight support to toshiba_acpi driver
Date: Thu, 9 Feb 2006 16:54:07 +0000	[thread overview]
Message-ID: <20060209165407.GA20754@srcf.ucam.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0602091747070.30108@yvahk01.tjqt.qr>

On Thu, Feb 09, 2006 at 05:47:49PM +0100, Jan Engelhardt wrote:

> Note to self: Don't forget to change 2.6-sony-acpi?.diff from -mm to use 
> this /sys/class/backlight instead of /proc/acpi/sony/brightness when it's 
> ready.

Ah, you're maintaining that now. Here you go (Stelian took a look and 
seemed happy with it - the /sys/class/backlight stuff is in mainstream)

diff --git a/drivers/acpi/sony_acpi.c b/drivers/acpi/sony_acpi.c
index 7636bba..6505b24 100644
--- a/drivers/acpi/sony_acpi.c
+++ b/drivers/acpi/sony_acpi.c
@@ -27,6 +27,8 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
@@ -62,6 +64,8 @@ static struct acpi_driver sony_acpi_driv
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
+static struct backlight_device *sony_backlight_device;
+
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
 	struct proc_dir_entry 	*proc;	 /* /proc entry */
@@ -258,6 +262,31 @@ static acpi_status sony_walk_callback(ac
 	return AE_OK;
 }
 
+static int sony_brightness_get(struct backlight_device *bd) 
+{
+	int value;
+
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+
+	return value-1;
+}
+	
+
+static int sony_brightness_set(struct backlight_device *bd, int value) {
+	value &= 0x7;
+	value++;
+
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT", value, NULL);
+}
+
+static struct backlight_properties sonybl_data = {
+	.owner          = THIS_MODULE,
+	.get_brightness = sony_brightness_get,
+	.set_brightness = sony_brightness_set,
+	.max_brightness = 7,
+};
+
 static int __init sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
@@ -378,12 +407,24 @@ static int __init sony_acpi_init(void)
 		remove_proc_entry("sony", acpi_root_dir);
 		return -ENODEV;
 	}
+
+	sony_backlight_device = backlight_device_register ("sony_bl", NULL,
+							   &sonybl_data);
+
+	if (IS_ERR (sony_backlight_device)) {
+		printk("Unable to register backlight\n");
+		acpi_bus_unregister_driver(&sony_acpi_driver);
+		remove_proc_entry("sony", acpi_root_dir);
+		return -ENODEV;
+	}
+
 	return 0;
 }
 
 
 static void __exit sony_acpi_exit(void)
 {
+	backlight_device_unregister(sony_backlight_device);
 	acpi_bus_unregister_driver(&sony_acpi_driver);
 	remove_proc_entry("sony", acpi_root_dir);
 }

-- 
Matthew Garrett | mjg59@srcf.ucam.org

  reply	other threads:[~2006-02-09 16:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-07 13:34 [PATCH] Add generic backlight support to toshiba_acpi driver Matthew Garrett
2006-02-08  9:07 ` Pavel Machek
2006-02-09 16:47   ` Jan Engelhardt
2006-02-09 16:54     ` Matthew Garrett [this message]
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=20060209165407.GA20754@srcf.ucam.org \
    --to=mjg59@srcf.ucam.org \
    --cc=jengelh@linux01.gwdg.de \
    --cc=john@neggie.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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