public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
@ 2006-09-30 17:08 Alessandro Guido
  2006-09-30 17:14 ` Alessandro Guido
  2006-10-02  0:19 ` Andrew Morton
  0 siblings, 2 replies; 36+ messages in thread
From: Alessandro Guido @ 2006-09-30 17:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-acpi, len.brown, jengelh, gelma, ismail

Make the sony_acpi use the backlight subsystem to adjust brightness value
instead of using the /proc/sony/brightness file.
(Other settings will still have a /proc/sony/... entry)

Signed-off-by: Alessandro Guido <alessandro.guido@gmail.com>
---
 drivers/acpi/Kconfig     |    1 
 drivers/acpi/sony_acpi.c |   59 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 48 insertions(+), 12 deletions(-)

Index: linux-2.6.18/drivers/acpi/Kconfig
===================================================================
--- linux-2.6.18.orig/drivers/acpi/Kconfig
+++ linux-2.6.18/drivers/acpi/Kconfig
@@ -258,6 +258,7 @@ config ACPI_TOSHIBA
 config ACPI_SONY
 	tristate "Sony Laptop Extras"
 	depends on X86 && ACPI
+	select BACKLIGHT_CLASS_DEVICE
 	default m
 	  ---help---
 	  This mini-driver drives the ACPI SNC device present in the
Index: linux-2.6.18/drivers/acpi/sony_acpi.c
===================================================================
--- linux-2.6.18.orig/drivers/acpi/sony_acpi.c
+++ linux-2.6.18/drivers/acpi/sony_acpi.c
@@ -27,13 +27,19 @@
 #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>
 
 #define ACPI_SNC_CLASS		"sony"
 #define ACPI_SNC_HID		"SNY5001"
-#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.2"
+#define ACPI_SNC_DRIVER_NAME	"ACPI Sony Notebook Control Driver v0.3"
+
+/* the device uses 1-based values, while the backlight subsystem uses
+   0-based values */
+#define SONY_MAX_BRIGHTNESS	8
 
 #define LOG_PFX			KERN_WARNING "sony_acpi: "
 
@@ -49,6 +55,16 @@ MODULE_PARM_DESC(debug, "set this to 1 (
 static acpi_handle sony_acpi_handle;
 static struct proc_dir_entry *sony_acpi_dir;
 
+static int sony_backlight_update_status(struct backlight_device *bd);
+static int sony_backlight_get_brightness(struct backlight_device *bd);
+static struct backlight_device *sony_backlight_device;
+static struct backlight_properties sony_backlight_properties = {
+	.owner		= THIS_MODULE,
+	.update_status	= sony_backlight_update_status,
+	.get_brightness	= sony_backlight_get_brightness,
+	.max_brightness	= SONY_MAX_BRIGHTNESS - 1,
+};
+
 static struct sony_acpi_value {
 	char			*name;	 /* name of the entry */
 	struct proc_dir_entry 	*proc;	 /* /proc entry */
@@ -61,19 +77,11 @@ static struct sony_acpi_value {
 	int			debug;	 /* active only in debug mode ? */
 } sony_acpi_values[] = {
 	{
-		.name		= "brightness",
-		.acpiget	= "GBRT",
-		.acpiset	= "SBRT",
-		.min		= 1,
-		.max		= 8,
-		.debug		= 0,
-	},
-	{
 		.name		= "brightness_default",
 		.acpiget	= "GPBR",
 		.acpiset	= "SPBR",
 		.min		= 1,
-		.max		= 8,
+		.max		= SONY_MAX_BRIGHTNESS,
 		.debug		= 0,
 	},
 	{
@@ -276,6 +284,7 @@ static int sony_acpi_add(struct acpi_dev
 {
 	acpi_status status;
 	int result;
+	acpi_handle handle;
 	struct sony_acpi_value *item;
 
 	sony_acpi_handle = device->handle;
@@ -303,9 +312,15 @@ static int sony_acpi_add(struct acpi_dev
 		}
 	}
 
-	for (item = sony_acpi_values; item->name; ++item) {
-		acpi_handle handle;
+	if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
+		sony_backlight_device = backlight_device_register("sony", NULL,
+					&sony_backlight_properties);
+	        if (IS_ERR(sony_backlight_device)) {
+        	        printk(LOG_PFX "unable to register backlight device\n");
+		}
+	}
 
+	for (item = sony_acpi_values; item->name; ++item) {
 		if (!debug && item->debug)
 			continue;
 
@@ -358,6 +373,9 @@ static int sony_acpi_remove(struct acpi_
 	acpi_status status;
 	struct sony_acpi_value *item;
 
+	if (sony_backlight_device)
+		backlight_device_unregister(sony_backlight_device);
+
 	if (debug) {
 		status = acpi_remove_notify_handler(sony_acpi_handle,
 						    ACPI_DEVICE_NOTIFY,
@@ -375,6 +393,23 @@ static int sony_acpi_remove(struct acpi_
 	return 0;
 }
 
+static int sony_backlight_update_status(struct backlight_device *bd)
+{
+	return acpi_callsetfunc(sony_acpi_handle, "SBRT",
+				bd->props->brightness + 1,
+				NULL);
+}
+
+static int sony_backlight_get_brightness(struct backlight_device *bd)
+{
+	int value;
+
+	if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value))
+		return 0;
+	/* brightness levels are 1-based, while backlight ones are 0-based */
+	return value - 1;
+}
+
 static struct acpi_driver sony_acpi_driver = {
 	.name	= ACPI_SNC_DRIVER_NAME,
 	.class	= ACPI_SNC_CLASS,

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-09-30 17:08 [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver Alessandro Guido
@ 2006-09-30 17:14 ` Alessandro Guido
  2006-09-30 17:31   ` Jan Engelhardt
  2006-10-02  0:19 ` Andrew Morton
  1 sibling, 1 reply; 36+ messages in thread
From: Alessandro Guido @ 2006-09-30 17:14 UTC (permalink / raw)
  To: Alessandro Guido
  Cc: linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Sat, 30 Sep 2006 19:08:10 +0200
Alessandro Guido <alessandro.guido@gmail.com> wrote:

> Make the sony_acpi use the backlight subsystem to adjust brightness value
> instead of using the /proc/sony/brightness file.
> (Other settings will still have a /proc/sony/... entry)

I meant /proc/acpi/sony/brightness and /proc/acpi/sony/...

sorry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-09-30 17:14 ` Alessandro Guido
@ 2006-09-30 17:31   ` Jan Engelhardt
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Engelhardt @ 2006-09-30 17:31 UTC (permalink / raw)
  To: Alessandro Guido; +Cc: linux-kernel, linux-acpi, len.brown, gelma, ismail


>> Make the sony_acpi use the backlight subsystem to adjust brightness value
>> instead of using the /proc/sony/brightness file.
>> (Other settings will still have a /proc/sony/... entry)
>
>I meant /proc/acpi/sony/brightness and /proc/acpi/sony/...

Hm spicctrl needs to be updated then. (Or maybe not if it does not use 
/proc)


Jan Engelhardt
-- 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-09-30 17:08 [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver Alessandro Guido
  2006-09-30 17:14 ` Alessandro Guido
@ 2006-10-02  0:19 ` Andrew Morton
  2006-10-02  0:39   ` Matt Domsch
                     ` (2 more replies)
  1 sibling, 3 replies; 36+ messages in thread
From: Andrew Morton @ 2006-10-02  0:19 UTC (permalink / raw)
  To: Alessandro Guido
  Cc: linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Sat, 30 Sep 2006 19:08:10 +0200
Alessandro Guido <alessandro.guido@gmail.com> wrote:

> Make the sony_acpi use the backlight subsystem to adjust brightness value
> instead of using the /proc/sony/brightness file.
> (Other settings will still have a /proc/sony/... entry)

umm, OK, but now how do I adjust my screen brightness? ;)

I assume that cute userspace applications for controlling backlight
brightness via the generic backlight driver either exist or are in
progress?  What is the status of that?

Thanks.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02  0:19 ` Andrew Morton
@ 2006-10-02  0:39   ` Matt Domsch
  2006-10-02  0:48     ` Matt Domsch
  2006-10-05 10:36     ` Pavel Machek
  2006-10-02 10:29   ` Holger Macht
  2006-10-02 11:25   ` Alessandro Guido
  2 siblings, 2 replies; 36+ messages in thread
From: Matt Domsch @ 2006-10-02  0:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alessandro Guido, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

On Sun, Oct 01, 2006 at 05:19:12PM -0700, Andrew Morton wrote:
> On Sat, 30 Sep 2006 19:08:10 +0200
> Alessandro Guido <alessandro.guido@gmail.com> wrote:
> 
> > Make the sony_acpi use the backlight subsystem to adjust brightness value
> > instead of using the /proc/sony/brightness file.
> > (Other settings will still have a /proc/sony/... entry)
> 
> umm, OK, but now how do I adjust my screen brightness? ;)
> 
> I assume that cute userspace applications for controlling backlight
> brightness via the generic backlight driver either exist or are in
> progress?  What is the status of that?

For Dell laptops, the dellLcdBrightness app is included in the
libsmbios-bin package (http://linux.dell.com/libsmbios/main/ and
http://linux.dell.com/libsmbios/main/yum.html for the yum repo).  It's
entirely userspace.

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02  0:39   ` Matt Domsch
@ 2006-10-02  0:48     ` Matt Domsch
  2006-10-05 10:36     ` Pavel Machek
  1 sibling, 0 replies; 36+ messages in thread
From: Matt Domsch @ 2006-10-02  0:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alessandro Guido, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

On Sun, Oct 01, 2006 at 07:39:08PM -0500, Matt Domsch wrote:
> On Sun, Oct 01, 2006 at 05:19:12PM -0700, Andrew Morton wrote:
> > umm, OK, but now how do I adjust my screen brightness? ;)
> > 
> > I assume that cute userspace applications for controlling backlight
> > brightness via the generic backlight driver either exist or are in
> > progress?  What is the status of that?
> 
> For Dell laptops, the dellLcdBrightness app is included in the
> libsmbios-bin package (http://linux.dell.com/libsmbios/main/ and
> http://linux.dell.com/libsmbios/main/yum.html for the yum repo).  It's
> entirely userspace.

Which is to say, if a system-agnostic userspace app exists, please
advise, as we'd like to incorporate dellLcdBrightness functionality
into it.

Thanks,
Matt

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02  0:19 ` Andrew Morton
  2006-10-02  0:39   ` Matt Domsch
@ 2006-10-02 10:29   ` Holger Macht
  2006-10-02 11:25   ` Alessandro Guido
  2 siblings, 0 replies; 36+ messages in thread
From: Holger Macht @ 2006-10-02 10:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alessandro Guido, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

On Sun 01. Oct - 17:19:12, Andrew Morton wrote:
> On Sat, 30 Sep 2006 19:08:10 +0200
> Alessandro Guido <alessandro.guido@gmail.com> wrote:
> 
> > Make the sony_acpi use the backlight subsystem to adjust brightness value
> > instead of using the /proc/sony/brightness file.
> > (Other settings will still have a /proc/sony/... entry)
> 
> umm, OK, but now how do I adjust my screen brightness? ;)
> 
> I assume that cute userspace applications for controlling backlight
> brightness via the generic backlight driver either exist or are in
> progress?  What is the status of that?

Most applications use HAL as a backend for display brightness these
days. HAL still supports the old interface in /proc for the different
brightness drivers, though, but the conversion to the new interface is on
my TODO and I will do it this week. So userspace should have fixed this
soon, so go ahead ;-)

Btw, there's a patchset from Matthew Garrett [1] sent some time ago which
also converts the asus_acpi, ibm_acpi and the toshiba_acpi drivers.

Regards,
	Holger

[1] http://lkml.org/lkml/2006/4/18/28

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02  0:19 ` Andrew Morton
  2006-10-02  0:39   ` Matt Domsch
  2006-10-02 10:29   ` Holger Macht
@ 2006-10-02 11:25   ` Alessandro Guido
  2006-10-10 15:17     ` Yu Luming
  2 siblings, 1 reply; 36+ messages in thread
From: Alessandro Guido @ 2006-10-02 11:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Sun, 1 Oct 2006 17:19:12 -0700
Andrew Morton <akpm@osdl.org> wrote:
> 
> umm, OK, but now how do I adjust my screen brightness? ;)
> 
> I assume that cute userspace applications for controlling backlight
> brightness via the generic backlight driver either exist or are in
> progress?  What is the status of that?
> 

I use this tool: http://www.xs4all.nl/~bsamwel/laptop_mode/tools/
that automagically fires up whenever needed

$ cat /etc/laptop-mode/batt-start/brightness 
#!/bin/sh
echo -n CHOOSE_A_LOW_VALUE > /sys/class/backlight/sony/brightness

and

$ cat /etc/laptop-mode/batt-stop/brightness 
#!/bin/sh
let val="`</proc/acpi/sony/brightness_default` - 1"
echo -n "$val" > /sys/class/backlight/sony/brightness

But I seldom use my laptop in battery mode.

> I assume that cute userspace applications for controlling backlight
> brightness via the generic backlight driver either exist or are in
> progress?  What is the status of that?
> 

I think the new gnome-power-manager does it, but I'm not sure since I use Xfce.

> Thanks.

Thank you.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02  0:39   ` Matt Domsch
  2006-10-02  0:48     ` Matt Domsch
@ 2006-10-05 10:36     ` Pavel Machek
  2006-10-06 21:17       ` Matt Domsch
  1 sibling, 1 reply; 36+ messages in thread
From: Pavel Machek @ 2006-10-05 10:36 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma, ismail

Hi!

> > I assume that cute userspace applications for controlling backlight
> > brightness via the generic backlight driver either exist or are in
> > progress?  What is the status of that?
> 
> For Dell laptops, the dellLcdBrightness app is included in the
> libsmbios-bin package (http://linux.dell.com/libsmbios/main/ and
> http://linux.dell.com/libsmbios/main/yum.html for the yum repo).  It's
> entirely userspace.

Please move it into the kernel where it belongs, and use lcd
brightness subsystem like everyone else.
							Pavel
-- 
Thanks for all the (sleeping) penguins.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-05 10:36     ` Pavel Machek
@ 2006-10-06 21:17       ` Matt Domsch
  2006-10-06 22:44         ` Pavel Machek
  2006-10-10 14:32         ` Yu Luming
  0 siblings, 2 replies; 36+ messages in thread
From: Matt Domsch @ 2006-10-06 21:17 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma, ismail

On Thu, Oct 05, 2006 at 10:36:57AM +0000, Pavel Machek wrote:
> Hi!
> 
> > > I assume that cute userspace applications for controlling backlight
> > > brightness via the generic backlight driver either exist or are in
> > > progress?  What is the status of that?
> > 
> > For Dell laptops, the dellLcdBrightness app is included in the
> > libsmbios-bin package (http://linux.dell.com/libsmbios/main/ and
> > http://linux.dell.com/libsmbios/main/yum.html for the yum repo).  It's
> > entirely userspace.
> 
> Please move it into the kernel where it belongs, and use lcd
> brightness subsystem like everyone else.

We've been through this before.
http://marc.theaimsgroup.com/?l=linux-kernel&m=114067198323596&w=2

In addition, the SMI call used to change the backlight level *may*
require (if configured by the sysadmin in BIOS), a password be
entered.

This begs for a common userspace app that can grok libsmbios and
kernel interfaces both, and use the appropriate method on each, rather
than just putting it all in the kernel.

Thanks,
Matt

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-06 21:17       ` Matt Domsch
@ 2006-10-06 22:44         ` Pavel Machek
  2006-10-10 14:32         ` Yu Luming
  1 sibling, 0 replies; 36+ messages in thread
From: Pavel Machek @ 2006-10-06 22:44 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma, ismail

Hi!

> > Please move it into the kernel where it belongs, and use lcd
> > brightness subsystem like everyone else.
> 
> We've been through this before.
> http://marc.theaimsgroup.com/?l=linux-kernel&m=114067198323596&w=2
> 
> In addition, the SMI call used to change the backlight level *may*
> require (if configured by the sysadmin in BIOS), a password be
> entered.

This is crazy, password-protected backlight level?

Can you make sure this crazyness does not infect newer models?

> This begs for a common userspace app that can grok libsmbios and
> kernel interfaces both, and use the appropriate method on each, rather
> than just putting it all in the kernel.

Kernel is expected to provide hardware abstraction. libsmbios will
mean person able to change backlight will be able to do lots of
strange stuff...
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-06 21:17       ` Matt Domsch
  2006-10-06 22:44         ` Pavel Machek
@ 2006-10-10 14:32         ` Yu Luming
  2006-10-10 14:47           ` Richard Hughes
  2006-10-10 21:26           ` Matthew Garrett
  1 sibling, 2 replies; 36+ messages in thread
From: Yu Luming @ 2006-10-10 14:32 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Pavel Machek, Andrew Morton, Alessandro Guido, linux-kernel,
	linux-acpi, len.brown, jengelh, gelma, ismail

> > Please move it into the kernel where it belongs, and use lcd
> > brightness subsystem like everyone else.
>
> We've been through this before.
> http://marc.theaimsgroup.com/?l=linux-kernel&m=114067198323596&w=2
>
> In addition, the SMI call used to change the backlight level *may*
> require (if configured by the sysadmin in BIOS), a password be
> entered.
>
> This begs for a common userspace app that can grok libsmbios and
> kernel interfaces both, and use the appropriate method on each, rather
> than just putting it all in the kernel

>From my understanding, a cute userspace App shouldn't have this kind
of logic:
	if (is  DELL )
		invoke libsmbios
	if (is  foo)
		invoke libfoo,
	if (is bar)
		invoke libbar,
	....
	else
		operate on /sys/class/backlight/ ,.,..

It should be:
	just write/read  file in  /sys/class/backlight ,....

Right?

Thanks,
Luming




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 14:32         ` Yu Luming
@ 2006-10-10 14:47           ` Richard Hughes
  2006-10-10 16:10             ` Matt Domsch
  2006-10-10 21:26           ` Matthew Garrett
  1 sibling, 1 reply; 36+ messages in thread
From: Richard Hughes @ 2006-10-10 14:47 UTC (permalink / raw)
  To: Yu Luming
  Cc: Matt Domsch, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Tue, 2006-10-10 at 22:32 +0800, Yu Luming wrote:
> >From my understanding, a cute userspace App shouldn't have this kind
> of logic:
>         if (is  DELL )
>                 invoke libsmbios
>         if (is  foo)
>                 invoke libfoo,
>         if (is bar)
>                 invoke libbar,
>         ....
>         else
>                 operate on /sys/class/backlight/ ,.,..

This is what HAL has at the moment[1]. And it's hell to maintain, but
works for a lot of users.

> It should be:
>         just write/read  file in  /sys/class/backlight ,....

That would make things much easier IMO.

Richard.

[1]
http://gitweb.freedesktop.org/?p=hal.git;a=blob;h=3ff9284be440a7197b0de9b5f0234761c3397cb1;hb=dbffafacbf7b9143d82547b9eabe61d1a5b8fffc;f=tools/linux/hal-system-lcd-get-brightness-linux


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-02 11:25   ` Alessandro Guido
@ 2006-10-10 15:17     ` Yu Luming
  2006-10-10 15:22       ` Richard Hughes
  2006-10-10 21:23       ` Matthew Garrett
  0 siblings, 2 replies; 36+ messages in thread
From: Yu Luming @ 2006-10-10 15:17 UTC (permalink / raw)
  To: Alessandro Guido
  Cc: Andrew Morton, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

> I use this tool: http://www.xs4all.nl/~bsamwel/laptop_mode/tools/
> that automagically fires up whenever needed
>
> $ cat /etc/laptop-mode/batt-start/brightness
> #!/bin/sh
> echo -n CHOOSE_A_LOW_VALUE > /sys/class/backlight/sony/brightness

Also, we need to make hot-key events  have similar handling code .
For example, Fn+F5 and Fn+F6 are brightness down and up key on my sony laptop.  
There is a driver called sonypi.c can map Fn+F5/F6 to KEY_FN_F5/F6. But I 
think It should be mapped to KEY_BRIGHTNESSDOWN/UP (linux/input.h)
Although, sonypi.c is NOT so clean, but , if it can report right event to 
input layer for all sony laptop(it works for me), and all related functions 
can be controlled through generic sysfs interface, then I would say sony has 
the best hot-key solution I have even seen so far for linux.

Thanks,
Luming.




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 15:17     ` Yu Luming
@ 2006-10-10 15:22       ` Richard Hughes
  2006-10-10 21:23       ` Matthew Garrett
  1 sibling, 0 replies; 36+ messages in thread
From: Richard Hughes @ 2006-10-10 15:22 UTC (permalink / raw)
  To: Yu Luming
  Cc: Alessandro Guido, Andrew Morton, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma, ismail

On Tue, 2006-10-10 at 23:17 +0800, Yu Luming wrote:
> It should be mapped to KEY_BRIGHTNESSDOWN/UP (linux/input.h)

Completely agree. Then userspace (like gnome-power-manager or
powersaved) can change the brightness based on policy and user-lockdown.

Richard.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 14:47           ` Richard Hughes
@ 2006-10-10 16:10             ` Matt Domsch
  2006-10-11 16:28               ` Yu Luming
  0 siblings, 1 reply; 36+ messages in thread
From: Matt Domsch @ 2006-10-10 16:10 UTC (permalink / raw)
  To: Richard Hughes
  Cc: Yu Luming, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Tue, Oct 10, 2006 at 03:47:26PM +0100, Richard Hughes wrote:
> On Tue, 2006-10-10 at 22:32 +0800, Yu Luming wrote:
> > >From my understanding, a cute userspace App shouldn't have this kind
> > of logic:
> >         if (is  DELL )
> >                 invoke libsmbios
> >         if (is  foo)
> >                 invoke libfoo,
> >         if (is bar)
> >                 invoke libbar,
> >         ....
> >         else
> >                 operate on /sys/class/backlight/ ,.,..
> 
> This is what HAL has at the moment[1]. And it's hell to maintain, but
> works for a lot of users.

This is slightly different.  This shows that there are a number of
slightly different kernel implementations:

/proc/acpi/toshiba/lcd
/proc/acpi/asus/brn
/proc/acpi/pcc/brightness
/proc/acpi/ibm/brightness
/proc/acpi/sony/brightness
/proc/omnibook/lcd

which is indeed nasty. I'd agree all in-kernel solutions should use
the same kernel<->user interface.  I'd also expect the kernel to have
a generic ACPI driver that exports the _BCL and _BCM method
implementations via that same interface, so that systems providing
that will "just work".  drivers/acpi/video.c currently exports this
via /proc/acpi/video/$DEVICE/brightness, which isn't the same as
/sys/class/backlight. :-(

There's also at least one more userspace option for the sonypi using
spiictrl.  This is where I expected libsmbios to plug in also, as a
fallback to the ACPI _BCL/_BCM methods above.

Thanks,
Matt

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 15:17     ` Yu Luming
  2006-10-10 15:22       ` Richard Hughes
@ 2006-10-10 21:23       ` Matthew Garrett
  2006-10-11  3:20         ` Dmitry Torokhov
  1 sibling, 1 reply; 36+ messages in thread
From: Matthew Garrett @ 2006-10-10 21:23 UTC (permalink / raw)
  To: Yu Luming
  Cc: Alessandro Guido, Andrew Morton, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma, ismail

On Tue, Oct 10, 2006 at 11:17:23PM +0800, Yu Luming wrote:

> Also, we need to make hot-key events  have similar handling code .
> For example, Fn+F5 and Fn+F6 are brightness down and up key on my sony laptop.  
> There is a driver called sonypi.c can map Fn+F5/F6 to KEY_FN_F5/F6. But I 
> think It should be mapped to KEY_BRIGHTNESSDOWN/UP (linux/input.h)
> Although, sonypi.c is NOT so clean, but , if it can report right event to 
> input layer for all sony laptop(it works for me), and all related functions 
> can be controlled through generic sysfs interface, then I would say sony has 
> the best hot-key solution I have even seen so far for linux.

It would have to be DMI-based to some extent - not all Sonys use the 
same keys for the same purpose. Misery ensues.

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

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 14:32         ` Yu Luming
  2006-10-10 14:47           ` Richard Hughes
@ 2006-10-10 21:26           ` Matthew Garrett
  2006-10-11  3:02             ` Matt Domsch
  2006-10-11  6:59             ` Arjan van de Ven
  1 sibling, 2 replies; 36+ messages in thread
From: Matthew Garrett @ 2006-10-10 21:26 UTC (permalink / raw)
  To: Yu Luming
  Cc: Matt Domsch, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Tue, Oct 10, 2006 at 10:32:46PM +0800, Yu Luming wrote:

> >From my understanding, a cute userspace App shouldn't have this kind
> of logic:

(snip switching on hardware type)

> It should be:
> 	just write/read  file in  /sys/class/backlight ,....

Yup, but to do that on Dell hardware is basically impossible. It'd be 
nice if they implemented the ACPI video extension properly for future 
hardware.

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

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 21:26           ` Matthew Garrett
@ 2006-10-11  3:02             ` Matt Domsch
  2006-10-11  3:16               ` Matthew Garrett
  2006-10-11 16:37               ` Yu Luming
  2006-10-11  6:59             ` Arjan van de Ven
  1 sibling, 2 replies; 36+ messages in thread
From: Matt Domsch @ 2006-10-11  3:02 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Yu Luming, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Tue, Oct 10, 2006 at 10:26:15PM +0100, Matthew Garrett wrote:
> On Tue, Oct 10, 2006 at 10:32:46PM +0800, Yu Luming wrote:
> 
> > >From my understanding, a cute userspace App shouldn't have this kind
> > of logic:
> 
> (snip switching on hardware type)
> 
> > It should be:
> > 	just write/read  file in  /sys/class/backlight ,....
> 
> Yup, but to do that on Dell hardware is basically impossible. It'd be 
> nice if they implemented the ACPI video extension properly for future 
> hardware.

Yes, our BIOS teams are looking to do exactly that.  I wouldn't expect
such a change to be propogated back to earlier released systems though.

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  3:02             ` Matt Domsch
@ 2006-10-11  3:16               ` Matthew Garrett
  2006-10-11 16:37               ` Yu Luming
  1 sibling, 0 replies; 36+ messages in thread
From: Matthew Garrett @ 2006-10-11  3:16 UTC (permalink / raw)
  To: Matt Domsch; +Cc: linux-kernel, linux-acpi

On Tue, Oct 10, 2006 at 10:02:32PM -0500, Matt Domsch wrote:

> Yes, our BIOS teams are looking to do exactly that.  I wouldn't expect
> such a change to be propogated back to earlier released systems though.

That's great news. I accept that it's impractical to port back to 
earlier hardware, but it means it'll stop being a problem eventually.

(Entirely unrelatedly, have you got any idea why several D-series 
Latitudes with Intel graphics switch off the backlight on lid close and 
never switch it back on again? It happens under Windows if you boot in 
safe mode, so it's not Linux specific...)
-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 21:23       ` Matthew Garrett
@ 2006-10-11  3:20         ` Dmitry Torokhov
  2006-10-11 16:48           ` Yu Luming
  0 siblings, 1 reply; 36+ messages in thread
From: Dmitry Torokhov @ 2006-10-11  3:20 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Yu Luming, Alessandro Guido, Andrew Morton, linux-kernel,
	linux-acpi, len.brown, jengelh, gelma, ismail

On Tuesday 10 October 2006 17:23, Matthew Garrett wrote:
> On Tue, Oct 10, 2006 at 11:17:23PM +0800, Yu Luming wrote:
> 
> > Also, we need to make hot-key events  have similar handling code .
> > For example, Fn+F5 and Fn+F6 are brightness down and up key on my sony laptop.  
> > There is a driver called sonypi.c can map Fn+F5/F6 to KEY_FN_F5/F6. But I 
> > think It should be mapped to KEY_BRIGHTNESSDOWN/UP (linux/input.h)
> > Although, sonypi.c is NOT so clean, but , if it can report right event to 
> > input layer for all sony laptop(it works for me), and all related functions 
> > can be controlled through generic sysfs interface, then I would say sony has 
> > the best hot-key solution I have even seen so far for linux.
> 
> It would have to be DMI-based to some extent - not all Sonys use the 
> same keys for the same purpose. Misery ensues.
> 

Then we need to add keymap table to the sonypi's input device so that
keymap can be changed from userspace.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 21:26           ` Matthew Garrett
  2006-10-11  3:02             ` Matt Domsch
@ 2006-10-11  6:59             ` Arjan van de Ven
  2006-10-11  7:04               ` Matthew Garrett
  1 sibling, 1 reply; 36+ messages in thread
From: Arjan van de Ven @ 2006-10-11  6:59 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Yu Luming, Matt Domsch, Pavel Machek, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

On Tue, 2006-10-10 at 22:26 +0100, Matthew Garrett wrote:
> On Tue, Oct 10, 2006 at 10:32:46PM +0800, Yu Luming wrote:
> 
> > >From my understanding, a cute userspace App shouldn't have this kind
> > of logic:
> 
> (snip switching on hardware type)
> 
> > It should be:
> > 	just write/read  file in  /sys/class/backlight ,....
> 
> Yup, but to do that on Dell hardware is basically impossible. It'd be 
> nice if they implemented the ACPI video extension properly for future 
> hardware.

it'd also be nice if the linux-ready firmware developer kit had a test
for this, so that we can offer 1) a way to test this to the bios guys
and 2) encourage adding/note the lack easily


> 
-- 
if you want to mail me at work (you don't), use arjan (at) linux.intel.com


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  6:59             ` Arjan van de Ven
@ 2006-10-11  7:04               ` Matthew Garrett
  2006-10-11  8:04                 ` Ismail Donmez
  0 siblings, 1 reply; 36+ messages in thread
From: Matthew Garrett @ 2006-10-11  7:04 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Yu Luming, Matt Domsch, Pavel Machek, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, len.brown, jengelh,
	gelma, ismail

On Wed, Oct 11, 2006 at 08:59:04AM +0200, Arjan van de Ven wrote:

> it'd also be nice if the linux-ready firmware developer kit had a test
> for this, so that we can offer 1) a way to test this to the bios guys
> and 2) encourage adding/note the lack easily

Sure. Reading /proc/acpi/video/*/*/info should tell you whether a device 
is an LCD or not. The brightness file should then contain a list of 
available brightnesses, and writing one into there should change the 
screen value. There's a patch somewhere that ports this to the 
/sys/class/backlight infrastructure, but I don't think it's applied yet.

I'd write a test up for you, but I don't actually seem to have any 
hardware that implements this properly. Tch.
-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  7:04               ` Matthew Garrett
@ 2006-10-11  8:04                 ` Ismail Donmez
  2006-10-11  8:12                   ` Matthew Garrett
  2006-10-11 16:31                   ` Yu Luming
  0 siblings, 2 replies; 36+ messages in thread
From: Ismail Donmez @ 2006-10-11  8:04 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Arjan van de Ven, Yu Luming, Matt Domsch, Pavel Machek,
	Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma

11 Eki 2006 Çar 10:04 tarihinde, Matthew Garrett şunları yazmıştı: 
> On Wed, Oct 11, 2006 at 08:59:04AM +0200, Arjan van de Ven wrote:
> > it'd also be nice if the linux-ready firmware developer kit had a test
> > for this, so that we can offer 1) a way to test this to the bios guys
> > and 2) encourage adding/note the lack easily
>
> Sure. Reading /proc/acpi/video/*/*/info should tell you whether a device
> is an LCD or not. 

On my Sony Vaio with latest linux-2.6 git kernel it says its a CRT :

[~]> cat  /proc/acpi/video/*/*/info
device_id:    0x0100
type:         CRT
known by bios: no
device_id:    0x0320
type:         UNKNOWN
known by bios: no
device_id:    0x0410
type:         UNKNOWN
known by bios: no
device_id:    0x0240
type:         UNKNOWN
known by bios: no
device_id:    0x0100
type:         CRT
known by bios: no
device_id:    0x0111
type:         UNKNOWN
known by bios: no
device_id:    0x0118
type:         UNKNOWN
known by bios: no
device_id:    0x0200
type:         TVOUT
known by bios: no

So I don't think its reliable.

Regards,
ismail

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  8:04                 ` Ismail Donmez
@ 2006-10-11  8:12                   ` Matthew Garrett
  2006-10-11 16:31                   ` Yu Luming
  1 sibling, 0 replies; 36+ messages in thread
From: Matthew Garrett @ 2006-10-11  8:12 UTC (permalink / raw)
  To: Ismail Donmez
  Cc: Arjan van de Ven, Yu Luming, Matt Domsch, Pavel Machek,
	Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma

On Wed, Oct 11, 2006 at 11:04:48AM +0300, Ismail Donmez wrote:

> device_id:    0x0410
> type:         UNKNOWN
> known by bios: no

This one's an LCD, according to the spec. The id spec was changed 
slightly in 3.0 of the acpi spec (in a backwards compatible way) - I'd 
guess that the acpi video driver just hasn't been updated.

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

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-10 16:10             ` Matt Domsch
@ 2006-10-11 16:28               ` Yu Luming
  2006-10-16 17:45                 ` Yu Luming
  0 siblings, 1 reply; 36+ messages in thread
From: Yu Luming @ 2006-10-11 16:28 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Richard Hughes, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

On Wednesday 11 October 2006 00:10, Matt Domsch wrote:
> On Tue, Oct 10, 2006 at 03:47:26PM +0100, Richard Hughes wrote:
> > On Tue, 2006-10-10 at 22:32 +0800, Yu Luming wrote:
> > > >From my understanding, a cute userspace App shouldn't have this kind
> > >
> > > of logic:
> > >         if (is  DELL )
> > >                 invoke libsmbios
> > >         if (is  foo)
> > >                 invoke libfoo,
> > >         if (is bar)
> > >                 invoke libbar,
> > >         ....
> > >         else
> > >                 operate on /sys/class/backlight/ ,.,..
> >
> > This is what HAL has at the moment[1]. And it's hell to maintain, but
> > works for a lot of users.
>
> This is slightly different.  This shows that there are a number of
> slightly different kernel implementations:
>
> /proc/acpi/toshiba/lcd
> /proc/acpi/asus/brn
> /proc/acpi/pcc/brightness
> /proc/acpi/ibm/brightness
> /proc/acpi/sony/brightness
> /proc/omnibook/lcd
>
> which is indeed nasty. I'd agree all in-kernel solutions should use
> the same kernel<->user interface.  I'd also expect the kernel to have

Yes, we all seem to agree we need to throw away /proc/acpi just after we 
have solid sysfs interface for acpi.

> a generic ACPI driver that exports the _BCL and _BCM method
> implementations via that same interface, so that systems providing
> that will "just work".  drivers/acpi/video.c currently exports this
> via /proc/acpi/video/$DEVICE/brightness, which isn't the same as
> /sys/class/backlight. :-(

Yes, I'm working on acpi video driver transition , and have posted a patch to
user backlight for acpi video driver.
http://marc.theaimsgroup.com/?l=linux-acpi&m=115574087203605&w=2

>
> There's also at least one more userspace option for the sonypi using
> spiictrl.  This is where I expected libsmbios to plug in also, as a
> fallback to the ACPI _BCL/_BCM methods above.

I think spiictrl would be thrown away just after we have solid sysfs support.

Thanks,
Luming

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  8:04                 ` Ismail Donmez
  2006-10-11  8:12                   ` Matthew Garrett
@ 2006-10-11 16:31                   ` Yu Luming
  2006-10-11 16:45                     ` Ismail Donmez
  1 sibling, 1 reply; 36+ messages in thread
From: Yu Luming @ 2006-10-11 16:31 UTC (permalink / raw)
  To: Ismail Donmez
  Cc: Matthew Garrett, Arjan van de Ven, Matt Domsch, Pavel Machek,
	Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma

On Wednesday 11 October 2006 16:04, Ismail Donmez wrote:
> 11 Eki 2006 Çar 10:04 tarihinde, Matthew Garrett şunları yazmıştı:
> > On Wed, Oct 11, 2006 at 08:59:04AM +0200, Arjan van de Ven wrote:
> > > it'd also be nice if the linux-ready firmware developer kit had a test
> > > for this, so that we can offer 1) a way to test this to the bios guys
> > > and 2) encourage adding/note the lack easily
> >
> > Sure. Reading /proc/acpi/video/*/*/info should tell you whether a device
> > is an LCD or not.
>
> On my Sony Vaio with latest linux-2.6 git kernel it says its a CRT :
>
> [~]> cat  /proc/acpi/video/*/*/info
> device_id:    0x0100
> type:         CRT
> known by bios: no
> device_id:    0x0320
> type:         UNKNOWN
> known by bios: no
> device_id:    0x0410
> type:         UNKNOWN
> known by bios: no
> device_id:    0x0240
> type:         UNKNOWN
> known by bios: no
> device_id:    0x0100
> type:         CRT
> known by bios: no
> device_id:    0x0111
> type:         UNKNOWN
> known by bios: no
> device_id:    0x0118
> type:         UNKNOWN
> known by bios: no
> device_id:    0x0200
> type:         TVOUT
> known by bios: no
>
> So I don't think its reliable.
Please open a bug on bugzilla.kernel.org,
and post acpidump output. 

Thanks,
Luming


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  3:02             ` Matt Domsch
  2006-10-11  3:16               ` Matthew Garrett
@ 2006-10-11 16:37               ` Yu Luming
  1 sibling, 0 replies; 36+ messages in thread
From: Yu Luming @ 2006-10-11 16:37 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Matthew Garrett, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, len.brown, jengelh, gelma, ismail

> Yes, our BIOS teams are looking to do exactly that.  I wouldn't expect
> such a change to be propogated back to earlier released systems though.
Wow!  This is a really good news! Please just notify me when it ready.
Because, I'd like to have one. :-)

Thanks,
Luming

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11 16:31                   ` Yu Luming
@ 2006-10-11 16:45                     ` Ismail Donmez
  0 siblings, 0 replies; 36+ messages in thread
From: Ismail Donmez @ 2006-10-11 16:45 UTC (permalink / raw)
  To: Yu Luming
  Cc: Matthew Garrett, Arjan van de Ven, Matt Domsch, Pavel Machek,
	Andrew Morton, Alessandro Guido, linux-kernel, linux-acpi,
	len.brown, jengelh, gelma

11 Eki 2006 Çar 19:31 tarihinde, Yu Luming şunları yazmıştı: 
[...]
> Please open a bug on bugzilla.kernel.org,
> and post acpidump output.

Done, http://bugzilla.kernel.org/show_bug.cgi?id=7349

Regards,
ismail

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11  3:20         ` Dmitry Torokhov
@ 2006-10-11 16:48           ` Yu Luming
  2006-10-11 19:08             ` Dmitry Torokhov
  0 siblings, 1 reply; 36+ messages in thread
From: Yu Luming @ 2006-10-11 16:48 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Matthew Garrett, Alessandro Guido, Andrew Morton, linux-kernel,
	linux-acpi, len.brown, jengelh, gelma, ismail

> > It would have to be DMI-based to some extent - not all Sonys use the
> > same keys for the same purpose. Misery ensues.
>
> Then we need to add keymap table to the sonypi's input device so that
> keymap can be changed from userspace.
If some key is physically broken, I agree configurable keymap is the only 
solution. But, I don't see any other benefit of doing so, if we expect 
platform specific driver report meaningful key code to input layer.

Thanks,
Luming

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11 16:48           ` Yu Luming
@ 2006-10-11 19:08             ` Dmitry Torokhov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2006-10-11 19:08 UTC (permalink / raw)
  To: Yu Luming
  Cc: Matthew Garrett, Alessandro Guido, Andrew Morton, linux-kernel,
	linux-acpi, len.brown, jengelh, gelma, ismail

On 10/11/06, Yu Luming <luming.yu@gmail.com> wrote:
> > > It would have to be DMI-based to some extent - not all Sonys use the
> > > same keys for the same purpose. Misery ensues.
> >
> > Then we need to add keymap table to the sonypi's input device so that
> > keymap can be changed from userspace.
> If some key is physically broken, I agree configurable keymap is the only
> solution. But, I don't see any other benefit of doing so, if we expect
> platform specific driver report meaningful key code to input layer.
>

As Matthew said different Sony models use different mapping. DMI-based
keymap solution requires kernel upgrade every time new model is out
whereas configurable keymap can be loaded easily form userspace. Also
user might want to remap keys to do different stuff. For example I
never change brigtness on my laptop now that I found settings that I
like. So I could map one key to start kmail and another one to build
kernel for example ;)

-- 
Dmitry

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-11 16:28               ` Yu Luming
@ 2006-10-16 17:45                 ` Yu Luming
  2006-10-25  7:07                   ` Pavel Machek
  0 siblings, 1 reply; 36+ messages in thread
From: Yu Luming @ 2006-10-16 17:45 UTC (permalink / raw)
  To: Matt Domsch, len.brown
  Cc: Richard Hughes, Pavel Machek, Andrew Morton, Alessandro Guido,
	linux-kernel, linux-acpi, jengelh, gelma, ismail

> > a generic ACPI driver that exports the _BCL and _BCM method
> > implementations via that same interface, so that systems providing
> > that will "just work".  drivers/acpi/video.c currently exports this
> > via /proc/acpi/video/$DEVICE/brightness, which isn't the same as
> > /sys/class/backlight. :-(
>
> Yes, I'm working on acpi video driver transition , and have posted a patch
> to user backlight for acpi video driver.
> http://marc.theaimsgroup.com/?l=linux-acpi&m=115574087203605&w=2

Just updated the backlight and output sysfs support for ACPI Video driver on
bugzilla. If you are interested this, please take a look at
http://bugzilla.kernel.org/show_bug.cgi?id=5749#c18

signed-off-by 	Luming.yu@gmail.com

[patch 1/3] vidoe sysfs support: Add dev argument for baclight sys dev
[patch 2/3] Add display output class support
[patch 3/3] backlight and output sysfs support for acpi video driver

Thanks,
Luming

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-16 17:45                 ` Yu Luming
@ 2006-10-25  7:07                   ` Pavel Machek
  2006-10-27 17:24                     ` Luming Yu
  0 siblings, 1 reply; 36+ messages in thread
From: Pavel Machek @ 2006-10-25  7:07 UTC (permalink / raw)
  To: Yu Luming
  Cc: Matt Domsch, len.brown, Richard Hughes, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, jengelh, gelma,
	ismail

Hi!

> > > a generic ACPI driver that exports the _BCL and _BCM method
> > > implementations via that same interface, so that systems providing
> > > that will "just work".  drivers/acpi/video.c currently exports this
> > > via /proc/acpi/video/$DEVICE/brightness, which isn't the same as
> > > /sys/class/backlight. :-(
> >
> > Yes, I'm working on acpi video driver transition , and have posted a patch
> > to user backlight for acpi video driver.
> > http://marc.theaimsgroup.com/?l=linux-acpi&m=115574087203605&w=2
> 
> Just updated the backlight and output sysfs support for ACPI Video driver on
> bugzilla. If you are interested this, please take a look at
> http://bugzilla.kernel.org/show_bug.cgi?id=5749#c18

> [patch 1/3] vidoe sysfs support: Add dev argument for baclight sys dev

Two typos in one line :-).

> [patch 2/3] Add display output class support

I guess this needs Documentation/ so we can tell if user<->kernel
interface is sane..

> [patch 3/3] backlight and output sysfs support for acpi video driver

Some whitespace is not okay there...
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-25  7:07                   ` Pavel Machek
@ 2006-10-27 17:24                     ` Luming Yu
  2006-10-29 17:50                       ` Pavel Machek
  0 siblings, 1 reply; 36+ messages in thread
From: Luming Yu @ 2006-10-27 17:24 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Matt Domsch, len.brown, Richard Hughes, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, jengelh, gelma,
	ismail

[-- Attachment #1: Type: text/plain, Size: 2046 bytes --]

On Wednesday 25 October 2006 15:07, Pavel Machek wrote:
> Hi!
>
> > > > a generic ACPI driver that exports the _BCL and _BCM method
> > > > implementations via that same interface, so that systems providing
> > > > that will "just work".  drivers/acpi/video.c currently exports this
> > > > via /proc/acpi/video/$DEVICE/brightness, which isn't the same as
> > > > /sys/class/backlight. :-(
> > >
> > > Yes, I'm working on acpi video driver transition , and have posted a
> > > patch to user backlight for acpi video driver.
> > > http://marc.theaimsgroup.com/?l=linux-acpi&m=115574087203605&w=2
> >
> > Just updated the backlight and output sysfs support for ACPI Video driver
> > on bugzilla. If you are interested this, please take a look at
> > http://bugzilla.kernel.org/show_bug.cgi?id=5749#c18
> >
> > [patch 1/3] vidoe sysfs support: Add dev argument for baclight sys dev
>
> Two typos in one line :-).
>
> > [patch 2/3] Add display output class support
>
> I guess this needs Documentation/ so we can tell if user<->kernel
> interface is sane..
>
> > [patch 3/3] backlight and output sysfs support for acpi video driver
>
> Some whitespace is not okay there...
> 									Pavel

updated version.
[patch 1/4] video sysfs support: Add dev argument for backlight sys dev
 drivers/video/backlight/backlight.c |    3 ++-
 include/linux/backlight.h           |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

[patch 2/4] Add display output class support
 drivers/video/output.c |  110 
+++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/output.h |   23 ++++++++++
 2 files changed, 133 insertions(+)

[patch 3/4] backlight and output sysfs support for acpi video driver
 acpi/Kconfig   |    2
 acpi/video.c   |  257 
+++++++++++++++++++++++++++++++++++++++++++++++++++++----
 video/Kconfig  |    8 +
 video/Makefile |    1
 4 files changed, 252 insertions(+), 16 deletions(-)

[patch 4/4] Add output class document
 video-output.txt |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Thanks,
Luming


[-- Attachment #2: 1-fix.patch --]
[-- Type: text/x-diff, Size: 1549 bytes --]

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 27597c5..1a18cdb 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -190,7 +190,7 @@ static int fb_notifier_callback(struct n
  * Creates and registers new backlight class_device. Returns either an
  * ERR_PTR() or a pointer to the newly allocated device.
  */
-struct backlight_device *backlight_device_register(const char *name, void *devdata,
+struct backlight_device *backlight_device_register(const char *name,struct device *dev,  void *devdata,
 						   struct backlight_properties *bp)
 {
 	int i, rc;
@@ -206,6 +206,7 @@ struct backlight_device *backlight_devic
 	new_bd->props = bp;
 	memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
 	new_bd->class_dev.class = &backlight_class;
+	new_bd->class_dev.dev = dev;
 	strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
 	class_set_devdata(&new_bd->class_dev, devdata);
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 75e91f5..de8e056 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -54,7 +54,7 @@ struct backlight_device {
 };
 
 extern struct backlight_device *backlight_device_register(const char *name,
-	void *devdata, struct backlight_properties *bp);
+	struct device *dev, void *devdata, struct backlight_properties *bp);
 extern void backlight_device_unregister(struct backlight_device *bd);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)

[-- Attachment #3: 2-fix.patch --]
[-- Type: text/x-diff, Size: 3711 bytes --]

diff --git a/drivers/video/output.c b/drivers/video/output.c
new file mode 100644
index 0000000..bcb2c53
--- /dev/null
+++ b/drivers/video/output.c
@@ -0,0 +1,110 @@
+/*
+ * Video output switch support
+ */
+
+#include <linux/module.h>
+#include <linux/output.h>
+#include <linux/err.h>
+#include <linux/ctype.h>
+
+
+MODULE_DESCRIPTION("Output Lowlevel Control Abstraction");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>");
+
+static ssize_t video_output_show_state (struct class_device *dev, char *buf)
+{
+	ssize_t ret_size = 0;
+	struct output_device *od = to_output_device(dev);
+
+	if(od->props)
+		ret_size = sprintf(buf, "%.8x\n", od->props->get_status(od));
+
+	return ret_size;
+}
+
+static ssize_t video_output_store_state (struct class_device *dev, const char *buf, size_t count)
+{
+	char *endp;
+	struct output_device *od = to_output_device(dev);
+	int request_state = simple_strtoul(buf, &endp, 0);
+	size_t size = endp -buf;
+
+        if (*endp && isspace(*endp))
+                size++;
+        if (size != count)
+                return -EINVAL;
+
+	if(od->props){
+		od->request_state = request_state;
+		od->props->set_state(od);
+	}
+	return count;
+}
+
+static void video_output_class_release(struct class_device *dev)
+{
+        struct output_device *od = to_output_device(dev);
+        kfree(od);
+}
+
+static struct class_device_attribute video_output_attributes[] = {
+	__ATTR(state, 0644, video_output_show_state, video_output_store_state),
+	__ATTR_NULL,
+};
+
+static struct class video_output_class = {
+	.name = "video_output",
+	.release = video_output_class_release,
+	.class_dev_attrs = video_output_attributes,
+};
+
+
+struct output_device *video_output_register(const char *name,struct device *dev,
+				void *devdata, struct output_properties *op)
+{
+	struct output_device *new_dev;
+	int	ret_code = 0;
+
+	new_dev = (struct output_device *) kzalloc( sizeof(struct output_device), GFP_KERNEL);
+	if (!new_dev) {
+		ret_code = -ENOMEM;
+		goto error_return;
+	}
+	new_dev->props = op;
+	new_dev->class_dev.class = &video_output_class;
+	new_dev->class_dev.dev = dev;
+	strlcpy(new_dev->class_dev.class_id, name, KOBJ_NAME_LEN);
+	class_set_devdata(&new_dev->class_dev, devdata);
+	ret_code = class_device_register(&new_dev->class_dev);
+	if (ret_code){
+		kfree (new_dev);
+		goto error_return;
+	}
+	return new_dev;
+
+error_return:
+	return ERR_PTR(ret_code);
+}
+EXPORT_SYMBOL(video_output_register);
+
+void video_output_unregister(struct output_device *dev)
+{
+	if (!dev)
+		return;
+	class_device_unregister(&dev->class_dev);
+}
+EXPORT_SYMBOL(video_output_unregister);
+
+static void __exit video_output_class_exit(void)
+{
+	class_unregister(&video_output_class);
+}
+
+static int __init video_output_class_init(void)
+{
+	return class_register(&video_output_class);
+}
+
+postcore_initcall(video_output_class_init);
+module_exit(video_output_class_exit);
diff --git a/include/linux/output.h b/include/linux/output.h
new file mode 100644
index 0000000..f4eb12c
--- /dev/null
+++ b/include/linux/output.h
@@ -0,0 +1,23 @@
+#ifndef _LINUX_OUTPUT_H
+#define _LINUX_OUTPUT_H
+
+#include <linux/device.h>
+
+struct output_device;
+
+struct output_properties {
+	int (*set_state)(struct output_device *);
+	int (*get_status)(struct output_device *);
+};
+
+struct output_device {
+	int request_state;
+	struct output_properties *props;
+	struct class_device class_dev;
+};
+
+#define to_output_device(obj) container_of(obj, struct output_device, class_dev)
+
+struct output_device *video_output_register(const char *, struct device *dev, void *, struct output_properties *);
+void video_output_unregister(struct output_device *);
+#endif

[-- Attachment #4: 4-fix.patch --]
[-- Type: text/x-diff, Size: 1217 bytes --]

diff --git a/Documentation/video-output.txt b/Documentation/video-output.txt
new file mode 100644
index 0000000..43cc0e2
--- /dev/null
+++ b/Documentation/video-output.txt
@@ -0,0 +1,27 @@
+The output sysfs class driver is to provide video output abstract layer that can be used to hook platform specific methods to enable/disable video output device through common sysfs interface.
+
+For example, on my IBM Thinkpad T42 laptop, acpi video driver registered its output devices and read/write method for state with output sysfs class. The user interface under sysfs is :
+
+linux:/sys/class/video_output # tree .
+.
+|-- CRT0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+|-- DVI0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+|-- LCD0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+`-- TV0
+   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+   |-- state
+   |-- subsystem -> ../../../class/video_output
+   `-- uevent
+

[-- Attachment #5: 3-fix.patch --]
[-- Type: text/x-diff, Size: 14999 bytes --]

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 0f9d4be..a7671f7 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -106,7 +106,7 @@ config ACPI_BUTTON
 
 config ACPI_VIDEO
 	tristate "Video"
-	depends on X86
+	depends on X86 && (BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL)
 	help
 	  This driver implement the ACPI Extensions For Display Adapters
 	  for integrated graphics devices on motherboard, as specified in
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 56666a9..0fcc68c 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -30,6 +30,9 @@ #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/pci.h>
+#include <linux/backlight.h>
+#include <linux/output.h>
 
 #include <asm/uaccess.h>
 
@@ -141,11 +144,11 @@ struct acpi_video_device_cap {
 	u8 _ADR:1;		/*Return the unique ID */
 	u8 _BCL:1;		/*Query list of brightness control levels supported */
 	u8 _BCM:1;		/*Set the brightness level */
+	u8 _BQC:1;		/*Get current brightness level */
 	u8 _DDC:1;		/*Return the EDID for this device */
 	u8 _DCS:1;		/*Return status of output device */
 	u8 _DGS:1;		/*Query graphics state */
 	u8 _DSS:1;		/*Device state set */
-	u8 _reserved:1;
 };
 
 struct acpi_video_device_brightness {
@@ -162,6 +165,7 @@ struct acpi_video_device {
 	struct acpi_video_bus *video;
 	struct acpi_device *dev;
 	struct acpi_video_device_brightness *brightness;
+	struct output_device *output_dev;
 };
 
 /* bus */
@@ -260,6 +264,56 @@ static int acpi_video_get_next_level(str
 				     u32 level_current, u32 event);
 static void acpi_video_switch_brightness(struct acpi_video_device *device,
 					 int event);
+static int acpi_video_device_lcd_set_level(struct acpi_video_device *, int);
+static int acpi_video_device_lcd_get_level_current(struct acpi_video_device *,unsigned long *);
+/*backlight device sysfs support*/
+static int acpi_video_get_brightness(struct backlight_device *bd);
+static int acpi_video_set_brightness(struct backlight_device *bd);
+static int acpi_video_output_get(struct output_device *);
+static int acpi_video_output_set(struct output_device *);
+static int acpi_video_device_get_state(struct acpi_video_device *, unsigned long *);
+static int acpi_video_device_set_state(struct acpi_video_device *, int);
+
+static struct backlight_device *acpi_video_backlight;
+static struct acpi_video_device *backlight_acpi_device;
+static struct backlight_properties acpi_video_data = {
+	.owner		= THIS_MODULE,
+	.max_brightness = 0,
+	.get_brightness = acpi_video_get_brightness,
+	.update_status  = acpi_video_set_brightness,
+};
+static struct output_properties acpi_output_properties = {
+	.set_state = acpi_video_output_set,
+	.get_status = acpi_video_output_get,
+};
+static int acpi_video_get_brightness(struct backlight_device *bd)
+{
+	unsigned long cur_level;
+	acpi_video_device_lcd_get_level_current(backlight_acpi_device, &cur_level);
+	return (int) cur_level;
+}
+
+static int acpi_video_set_brightness(struct backlight_device *bd)
+{
+	int request_level = bd->props->brightness;
+	acpi_video_device_lcd_set_level(backlight_acpi_device, request_level);
+	return 0;
+}
+
+static int acpi_video_output_get(struct output_device *od)
+{
+	unsigned long state;
+	struct acpi_video_device *vd = (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+	acpi_video_device_get_state(vd, &state);
+	return (int)state;
+}
+
+static int acpi_video_output_set(struct output_device *od)
+{
+	unsigned long state = od->request_state;
+	struct acpi_video_device *vd = (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+	return acpi_video_device_set_state(vd, state);
+}
 
 /* --------------------------------------------------------------------------
                                Video Management
@@ -345,7 +399,7 @@ acpi_video_device_lcd_set_level(struct a
 	arg0.integer.value = level;
 	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
 
-	printk(KERN_DEBUG "set_level status: %x\n", status);
+	printk(KERN_DEBUG PREFIX "set_level status: %x\n", status);
 	return status;
 }
 
@@ -482,6 +536,134 @@ acpi_video_bus_DOS(struct acpi_video_bus
 	return status;
 }
 
+
+/*
+ * copy & paste some code for acpi_pci_data, acpi_pci_data_handler,acpi_pci_data
+ * from pci_bind.c
+ * To-do: write a new API: acpi_pci_get.
+ */
+
+struct acpi_pci_data {
+        struct acpi_pci_id id;
+        struct pci_bus *bus;
+        struct pci_dev *dev;
+};
+
+static void acpi_pci_data_handler(acpi_handle handle, u32 function,
+				  void *context)
+{
+
+	/* TBD: Anything we need to do here? */
+
+	return;
+}
+
+static struct acpi_pci_data * acpi_pci_get (struct acpi_device *device)
+{
+	int result = 0;
+	acpi_status status = AE_OK;
+	struct acpi_pci_data *data = NULL;
+	struct acpi_pci_data *pdata = NULL;
+	char *pathname = NULL;
+	struct acpi_buffer buffer = { 0, NULL };
+	acpi_handle handle = NULL;
+	struct pci_dev *dev;
+	struct pci_bus *bus;
+
+
+	if (!device || !device->parent)
+		return NULL;
+
+	pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	if (!pathname)
+		return -ENOMEM;
+	memset(pathname, 0, ACPI_PATHNAME_MAX);
+	buffer.length = ACPI_PATHNAME_MAX;
+	buffer.pointer = pathname;
+
+	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	if (!data) {
+		kfree(pathname);
+		return NULL;
+	}
+	memset(data, 0, sizeof(struct acpi_pci_data));
+
+	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
+	printk(KERN_INFO PREFIX "finding PCI device [%s]...\n", pathname);
+
+	/*
+	 * Segment & Bus
+	 * -------------
+	 * These are obtained via the parent device's ACPI-PCI context.
+	 */
+go_up:
+	status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
+			       (void **)&pdata);
+	if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
+		struct acpi_device *tmp_dev;
+
+		tmp_dev = device->parent;
+		if (tmp_dev->parent && (tmp_dev->parent->handle != ACPI_ROOT_OBJECT)) {
+			device = tmp_dev;
+			goto go_up;
+		}
+
+		ACPI_EXCEPTION((AE_INFO, status,
+				"Invalid ACPI-PCI context for parent device %s",
+				acpi_device_bid(device->parent)));
+		return NULL;
+	}
+	data->id.segment = pdata->id.segment;
+	data->id.bus = pdata->bus->number;
+
+	/*
+	 * Device & Function
+	 * -----------------
+	 * These are simply obtained from the device's _ADR method.  Note
+	 * that a value of zero is valid.
+	 */
+	data->id.device = device->pnp.bus_address >> 16;
+	data->id.function = device->pnp.bus_address & 0xFFFF;
+
+	printk(KERN_INFO PREFIX "...to %02x:%02x:%02x.%02x\n",
+			  data->id.segment, data->id.bus, data->id.device,
+			  data->id.function);
+
+	/*
+	 * TBD: Support slot devices (e.g. function=0xFFFF).
+	 */
+
+	/*
+	 * Locate PCI Device
+	 * -----------------
+	 * Locate matching device in PCI namespace.  If it doesn't exist
+	 * this typically means that the device isn't currently inserted
+	 * (e.g. docking station, port replicator, etc.).
+	 * We cannot simply search the global pci device list, since
+	 * PCI devices are added to the global pci list when the root
+	 * bridge start ops are run, which may not have happened yet.
+	 */
+	bus = pci_find_bus(data->id.segment, data->id.bus);
+	if (bus) {
+		list_for_each_entry(dev, &bus->devices, bus_list) {
+			if (dev->devfn == PCI_DEVFN(data->id.device,
+						    data->id.function)) {
+				data->dev = dev;
+				break;
+			}
+		}
+	}
+	printk(KERN_INFO PREFIX "data->dev =%p", &data->dev);
+	printk(KERN_INFO PREFIX "data->dev->dev =%p\n", &data->dev->dev);
+	if (!data->dev) {
+		printk(KERN_ERR PREFIX "Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
+				  data->id.segment, data->id.bus,
+				  data->id.device, data->id.function);
+		return NULL;
+	}
+	return data;
+}
+
 /*
  *  Arg:	
  *  	device	: video output device (LCD, CRT, ..)
@@ -498,12 +680,18 @@ static void acpi_video_device_find_cap(s
 	acpi_integer status;
 	acpi_handle h_dummy1;
 	int i;
+	u32 max_level = 0;
 	union acpi_object *obj = NULL;
 	struct acpi_video_device_brightness *br = NULL;
+	struct acpi_pci_data *data;
 
 
+	data = acpi_pci_get (device->video->device);
+        if (!data || !(data->dev)) {
+		printk(KERN_ERR PREFIX "acpi_video_device:no valid data from acpi_pci_get\n");
+		return ;
+	}
 	memset(&device->cap, 0, 4);
-
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
 		device->cap._ADR = 1;
 	}
@@ -513,6 +701,9 @@ static void acpi_video_device_find_cap(s
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
 		device->cap._BCM = 1;
 	}
+	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BQC", &h_dummy1))) {
+		device->cap._BQC = 1;
+	}
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
 		device->cap._DDC = 1;
 	}
@@ -526,6 +717,7 @@ static void acpi_video_device_find_cap(s
 		device->cap._DSS = 1;
 	}
 
+
 	status = acpi_video_device_lcd_query_levels(device, &obj);
 
 	if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
@@ -534,7 +726,7 @@ static void acpi_video_device_find_cap(s
 
 		br = kmalloc(sizeof(*br), GFP_KERNEL);
 		if (!br) {
-			printk(KERN_ERR "can't allocate memory\n");
+			printk(KERN_ERR PREFIX "can't allocate memory\n");
 		} else {
 			memset(br, 0, sizeof(*br));
 			br->levels = kmalloc(obj->package.count *
@@ -550,6 +742,8 @@ static void acpi_video_device_find_cap(s
 					continue;
 				}
 				br->levels[count] = (u32) o->integer.value;
+				if (br->levels[count] > max_level)
+					max_level = br->levels[count];
 				count++;
 			}
 		      out:
@@ -568,6 +762,26 @@ static void acpi_video_device_find_cap(s
 
 	kfree(obj);
 
+	if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
+		unsigned long tmp;
+		acpi_video_data.max_brightness = max_level;
+		acpi_video_device_lcd_get_level_current(device, &tmp);
+		acpi_video_data.brightness = tmp;
+		acpi_video_backlight = backlight_device_register("acpi-video",
+			&(data->dev->dev), NULL, &acpi_video_data);
+		backlight_acpi_device = device;
+	}
+
+	if (device->cap._DCS && device->cap._DSS){
+		char name[16];
+		memset(name, 0, 16);
+		strcat(name, acpi_device_bid(device->dev->parent));
+		strcat(name, "_");
+		strcpy(name, acpi_device_bid(device->dev));
+		device->output_dev = video_output_register(name,
+					 &(data->dev->dev),
+						device, &acpi_output_properties);
+	}
 	return;
 }
 
@@ -1011,7 +1225,6 @@ static int acpi_video_bus_POST_info_seq_
 			printk(KERN_WARNING PREFIX
 			       "This indicate a BIOS bug.  Please contact the manufacturer.\n");
 		}
-		printk("%lx\n", options);
 		seq_printf(seq, "can POST: <intgrated video>");
 		if (options & 2)
 			seq_printf(seq, " <PCI video>");
@@ -1148,11 +1361,15 @@ static int acpi_video_bus_add_fs(struct 
 {
 	struct proc_dir_entry *entry = NULL;
 	struct acpi_video_bus *video;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	video = (struct acpi_video_bus *)acpi_driver_data(device);
 
 	if (!acpi_device_dir(device)) {
+              	strcpy(proc_dir_name, acpi_device_bid(device));
+               	strcat(proc_dir_name, "_");
+               	strcat(proc_dir_name, acpi_device_bid(device->parent));
 		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
 						     acpi_video_dir);
 		if (!acpi_device_dir(device))
@@ -1224,17 +1441,21 @@ static int acpi_video_bus_add_fs(struct 
 static int acpi_video_bus_remove_fs(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	video = (struct acpi_video_bus *)acpi_driver_data(device);
-
 	if (acpi_device_dir(device)) {
 		remove_proc_entry("info", acpi_device_dir(device));
 		remove_proc_entry("ROM", acpi_device_dir(device));
 		remove_proc_entry("POST_info", acpi_device_dir(device));
 		remove_proc_entry("POST", acpi_device_dir(device));
 		remove_proc_entry("DOS", acpi_device_dir(device));
-		remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
+
+                strcpy(proc_dir_name, acpi_device_bid(device));
+                strcat(proc_dir_name, "_");
+                strcat(proc_dir_name, acpi_device_bid(device->parent));
+                remove_proc_entry(proc_dir_name, acpi_video_dir);
 		acpi_device_dir(device) = NULL;
 	}
 
@@ -1268,7 +1489,6 @@ acpi_video_bus_get_one_device(struct acp
 			return -ENOMEM;
 
 		memset(data, 0, sizeof(struct acpi_video_device));
-
 		strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
 		strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
 		acpi_driver_data(device) = data;
@@ -1568,6 +1788,10 @@ static int acpi_video_bus_put_one_device
 	status = acpi_remove_notify_handler(device->dev->handle,
 					    ACPI_DEVICE_NOTIFY,
 					    acpi_video_device_notify);
+	if (device == backlight_acpi_device)
+		backlight_device_unregister(acpi_video_backlight);
+
+	video_output_unregister(device->output_dev);
 
 	return 0;
 }
@@ -1615,7 +1839,7 @@ static void acpi_video_bus_notify(acpi_h
 	struct acpi_video_bus *video = (struct acpi_video_bus *)data;
 	struct acpi_device *device = NULL;
 
-	printk("video bus notify\n");
+	printk(KERN_INFO PREFIX "video bus notify\n");
 
 	if (!video)
 		return;
@@ -1658,8 +1882,6 @@ static void acpi_video_device_notify(acp
 	    (struct acpi_video_device *)data;
 	struct acpi_device *device = NULL;
 
-
-	printk("video device notify\n");
 	if (!video_device)
 		return;
 
@@ -1691,8 +1913,9 @@ static int acpi_video_bus_add(struct acp
 	int result = 0;
 	acpi_status status = 0;
 	struct acpi_video_bus *video = NULL;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	if (!device)
 		return -EINVAL;
 
@@ -1735,8 +1958,12 @@ static int acpi_video_bus_add(struct acp
 		goto end;
 	}
 
+        strcpy(proc_dir_name, acpi_device_bid(device));
+        strcat(proc_dir_name, "_");
+        strcat(proc_dir_name, acpi_device_bid(device->parent));
+
 	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
-	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
+               ACPI_VIDEO_DEVICE_NAME, proc_dir_name,
 	       video->flags.multihead ? "yes" : "no",
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7a43020..3b51742 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1644,5 +1644,13 @@ if SYSFS
 	source "drivers/video/backlight/Kconfig"
 endif
 
+
+config VIDEO_OUTPUT_CONTROL
+	tristate "video output device switch control"
+	depends on SYSFS
+	---help---
+	  sysfs support for video output device switching.
+
+
 endmenu
 
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index a6980e9..0f82eed 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -108,3 +108,4 @@ obj-$(CONFIG_FB_OF)               += off
 
 # the test framebuffer is last
 obj-$(CONFIG_FB_VIRTUAL)          += vfb.o
+obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-27 17:24                     ` Luming Yu
@ 2006-10-29 17:50                       ` Pavel Machek
  2006-10-30 15:49                         ` Luming Yu
  0 siblings, 1 reply; 36+ messages in thread
From: Pavel Machek @ 2006-10-29 17:50 UTC (permalink / raw)
  To: Luming Yu
  Cc: Matt Domsch, len.brown, Richard Hughes, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, jengelh, gelma,
	ismail

Hi!

> > Some whitespace is not okay there...
> > 									Pavel
> 
> updated version.

> index 27597c5..1a18cdb 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -190,7 +190,7 @@ static int fb_notifier_callback(struct n
>   * Creates and registers new backlight class_device. Returns either an
>   * ERR_PTR() or a pointer to the newly allocated device.
>   */
> -struct backlight_device *backlight_device_register(const char *name, void *devdata,
> +struct backlight_device *backlight_device_register(const char *name,struct device *dev,  void *devdata,
>  						   struct

80-columns, and fix the whitespace, please.

> --- /dev/null
> +++ b/drivers/video/output.c
> @@ -0,0 +1,110 @@
> +/*
> + * Video output switch support
> + */

I guess this one needs copyright/GPL.

> +	struct output_device *new_dev;
> +	int	ret_code = 0;

Indentation is wrong where... 

> +	new_dev = (struct output_device *) kzalloc( sizeof(struct
output_device), GFP_KERNEL);

Cast should not be needed.

> +	strlcpy(new_dev->class_dev.class_id, name, KOBJ_NAME_LEN);
> +	class_set_devdata(&new_dev->class_dev, devdata);
> +	ret_code = class_device_register(&new_dev->class_dev);
> +	if (ret_code){

") {", please.

> +		kfree (new_dev);

..and no space between kfree and its arguments.


> @@ -0,0 +1,27 @@
> +The output sysfs class driver is to provide video output abstract layer that can be used to hook platform specific methods to enable/disable video output device through common sysfs interface.
> +

80-columns, please. And some title would be nice.

> @@ -141,11 +144,11 @@ struct acpi_video_device_cap {
>  	u8 _ADR:1;		/*Return the unique ID */
>  	u8 _BCL:1;		/*Query list of brightness control levels supported */
>  	u8 _BCM:1;		/*Set the brightness level */
> +	u8 _BQC:1;		/*Get current brightness level */
>  	u8 _DDC:1;		/*Return the EDID for this device */
>  	u8 _DCS:1;		/*Return status of output device */
>  	u8 _DGS:1;		/*Query graphics state */
>  	u8 _DSS:1;		/*Device state set */

It is nicer to have space between /* and comment.
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver
  2006-10-29 17:50                       ` Pavel Machek
@ 2006-10-30 15:49                         ` Luming Yu
  0 siblings, 0 replies; 36+ messages in thread
From: Luming Yu @ 2006-10-30 15:49 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Matt Domsch, len.brown, Richard Hughes, Andrew Morton,
	Alessandro Guido, linux-kernel, linux-acpi, jengelh, gelma,
	ismail

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

updated version attached.

signed-off-by   Luming.yu@gmail.com

[patch 1/6] video sysfs support: Add dev argument for backlight sys dev
 drivers/video/backlight/backlight.c |    7 +++++--
 include/linux/backlight.h           |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

patch 2/6] Add display output class support
 drivers/video/output.c |  129 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/output.h |   42 +++++++++++++++
 2 files changed, 171 insertions(+)

[patch 3/6] backlight and output sysfs support for acpi video driver
 acpi/Kconfig   |    2
 acpi/video.c   |  257 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 video/Kconfig  |    9 +
 video/Makefile |    1
 4 files changed, 253 insertions(+), 16 deletions(-)

[patch 4/6] Add output class document
 video-output.txt |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

[patch 5/6] fix comments style
 video.c |   44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

[patch 6/6] fix compile time warning
 video.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)


On 10/30/06, Pavel Machek <pavel@ucw.cz> wrote:
> Hi!
>
> > > Some whitespace is not okay there...
> > >                                                                     Pavel
> >
> > updated version.
>
> > index 27597c5..1a18cdb 100644
> > --- a/drivers/video/backlight/backlight.c
> > +++ b/drivers/video/backlight/backlight.c
> > @@ -190,7 +190,7 @@ static int fb_notifier_callback(struct n
> >   * Creates and registers new backlight class_device. Returns either an
> >   * ERR_PTR() or a pointer to the newly allocated device.
> >   */
> > -struct backlight_device *backlight_device_register(const char *name, void *devdata,
> > +struct backlight_device *backlight_device_register(const char *name,struct device *dev,  void *devdata,
> >                                                  struct
>
> 80-columns, and fix the whitespace, please.
>
> > --- /dev/null
> > +++ b/drivers/video/output.c
> > @@ -0,0 +1,110 @@
> > +/*
> > + * Video output switch support
> > + */
>
> I guess this one needs copyright/GPL.
>
> > +     struct output_device *new_dev;
> > +     int     ret_code = 0;
>
> Indentation is wrong where...
>
> > +     new_dev = (struct output_device *) kzalloc( sizeof(struct
> output_device), GFP_KERNEL);
>
> Cast should not be needed.
>
> > +     strlcpy(new_dev->class_dev.class_id, name, KOBJ_NAME_LEN);
> > +     class_set_devdata(&new_dev->class_dev, devdata);
> > +     ret_code = class_device_register(&new_dev->class_dev);
> > +     if (ret_code){
>
> ") {", please.
>
> > +             kfree (new_dev);
>
> ..and no space between kfree and its arguments.
>
>
> > @@ -0,0 +1,27 @@
> > +The output sysfs class driver is to provide video output abstract layer that can be used to hook platform specific methods to enable/disable video output device through common sysfs interface.
> > +
>
> 80-columns, please. And some title would be nice.
>
> > @@ -141,11 +144,11 @@ struct acpi_video_device_cap {
> >       u8 _ADR:1;              /*Return the unique ID */
> >       u8 _BCL:1;              /*Query list of brightness control levels supported */
> >       u8 _BCM:1;              /*Set the brightness level */
> > +     u8 _BQC:1;              /*Get current brightness level */
> >       u8 _DDC:1;              /*Return the EDID for this device */
> >       u8 _DCS:1;              /*Return status of output device */
> >       u8 _DGS:1;              /*Query graphics state */
> >       u8 _DSS:1;              /*Device state set */
>
> It is nicer to have space between /* and comment.
>                                                                 Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>

[-- Attachment #2: 1-fix.patch --]
[-- Type: text/x-patch, Size: 1622 bytes --]

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 27597c5..1d97cdf 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -190,8 +190,10 @@ static int fb_notifier_callback(struct n
  * Creates and registers new backlight class_device. Returns either an
  * ERR_PTR() or a pointer to the newly allocated device.
  */
-struct backlight_device *backlight_device_register(const char *name, void *devdata,
-						   struct backlight_properties *bp)
+struct backlight_device *backlight_device_register(const char *name,
+	struct device *dev,
+	void *devdata,
+	struct backlight_properties *bp)
 {
 	int i, rc;
 	struct backlight_device *new_bd;
@@ -206,6 +208,7 @@ struct backlight_device *backlight_devic
 	new_bd->props = bp;
 	memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev));
 	new_bd->class_dev.class = &backlight_class;
+	new_bd->class_dev.dev = dev;
 	strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
 	class_set_devdata(&new_bd->class_dev, devdata);
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 75e91f5..a5cf1be 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -54,7 +54,7 @@ struct backlight_device {
 };
 
 extern struct backlight_device *backlight_device_register(const char *name,
-	void *devdata, struct backlight_properties *bp);
+	struct device *dev,void *devdata,struct backlight_properties *bp);
 extern void backlight_device_unregister(struct backlight_device *bd);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev)

[-- Attachment #3: 2-fix.patch --]
[-- Type: text/x-patch, Size: 5655 bytes --]

diff --git a/drivers/video/output.c b/drivers/video/output.c
new file mode 100644
index 0000000..4142662
--- /dev/null
+++ b/drivers/video/output.c
@@ -0,0 +1,129 @@
+/*
+ *  output.c - Display output swither driver
+ *
+ *  Copyright (C) 2006 Luming Yu <luming.yu@gmail.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#include <linux/module.h>
+#include <linux/output.h>
+#include <linux/err.h>
+#include <linux/ctype.h>
+
+
+MODULE_DESCRIPTION("Display Output Switcher Lowlevel Control Abstraction");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>");
+
+static ssize_t video_output_show_state(struct class_device *dev,char *buf)
+{
+	ssize_t ret_size = 0;
+	struct output_device *od = to_output_device(dev);
+	if (od->props)
+		ret_size = sprintf(buf,"%.8x\n",od->props->get_status(od));
+	return ret_size;
+}
+
+static ssize_t video_output_store_state(struct class_device *dev,
+	const char *buf,size_t count)
+{
+	char *endp;
+	struct output_device *od = to_output_device(dev);
+	int request_state = simple_strtoul(buf,&endp,0);
+	size_t size = endp - buf;
+
+        if (*endp && isspace(*endp))
+                size++;
+        if (size != count)
+                return -EINVAL;
+
+	if (od->props) {
+		od->request_state = request_state;
+		od->props->set_state(od);
+	}
+	return count;
+}
+
+static void video_output_class_release(struct class_device *dev)
+{
+        struct output_device *od = to_output_device(dev);
+        kfree(od);
+}
+
+static struct class_device_attribute video_output_attributes[] = {
+	__ATTR(state, 0644, video_output_show_state, video_output_store_state),
+	__ATTR_NULL,
+};
+
+static struct class video_output_class = {
+	.name = "video_output",
+	.release = video_output_class_release,
+	.class_dev_attrs = video_output_attributes,
+};
+
+struct output_device *video_output_register(const char *name,
+	struct device *dev,
+	void *devdata,
+	struct output_properties *op)
+{
+	struct output_device *new_dev;
+	int ret_code = 0;
+
+	new_dev = kzalloc(sizeof(struct output_device),GFP_KERNEL);
+	if (!new_dev) {
+		ret_code = -ENOMEM;
+		goto error_return;
+	}
+	new_dev->props = op;
+	new_dev->class_dev.class = &video_output_class;
+	new_dev->class_dev.dev = dev;
+	strlcpy(new_dev->class_dev.class_id,name,KOBJ_NAME_LEN);
+	class_set_devdata(&new_dev->class_dev,devdata);
+	ret_code = class_device_register(&new_dev->class_dev);
+	if (ret_code) {
+		kfree(new_dev);
+		goto error_return;
+	}
+	return new_dev;
+
+error_return:
+	return ERR_PTR(ret_code);
+}
+EXPORT_SYMBOL(video_output_register);
+
+void video_output_unregister(struct output_device *dev)
+{
+	if (!dev)
+		return;
+	class_device_unregister(&dev->class_dev);
+}
+EXPORT_SYMBOL(video_output_unregister);
+
+static void __exit video_output_class_exit(void)
+{
+	class_unregister(&video_output_class);
+}
+
+static int __init video_output_class_init(void)
+{
+	return class_register(&video_output_class);
+}
+
+postcore_initcall(video_output_class_init);
+module_exit(video_output_class_exit);
diff --git a/include/linux/output.h b/include/linux/output.h
new file mode 100644
index 0000000..6fc47f5
--- /dev/null
+++ b/include/linux/output.h
@@ -0,0 +1,42 @@
+/*
+ *
+ *  Copyright (C) 2006 Luming Yu <luming.yu@gmail.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#ifndef _LINUX_OUTPUT_H
+#define _LINUX_OUTPUT_H
+#include <linux/device.h>
+struct output_device;
+struct output_properties {
+	int (*set_state)(struct output_device *);
+	int (*get_status)(struct output_device *);
+};
+struct output_device {
+	int request_state;
+	struct output_properties *props;
+	struct class_device class_dev;
+};
+#define to_output_device(obj) container_of(obj, struct output_device, class_dev)
+struct output_device *video_output_register(const char *name,
+	struct device *dev,
+	void *devdata,
+	struct output_properties *op);
+void video_output_unregister(struct output_device *dev);
+#endif

[-- Attachment #4: 3-fix.patch --]
[-- Type: text/x-patch, Size: 15159 bytes --]

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 0f9d4be..a7671f7 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -106,7 +106,7 @@ config ACPI_BUTTON
 
 config ACPI_VIDEO
 	tristate "Video"
-	depends on X86
+	depends on X86 && (BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL)
 	help
 	  This driver implement the ACPI Extensions For Display Adapters
 	  for integrated graphics devices on motherboard, as specified in
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 56666a9..ace21e2 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -30,6 +30,9 @@ #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/pci.h>
+#include <linux/backlight.h>
+#include <linux/output.h>
 
 #include <asm/uaccess.h>
 
@@ -141,11 +144,11 @@ struct acpi_video_device_cap {
 	u8 _ADR:1;		/*Return the unique ID */
 	u8 _BCL:1;		/*Query list of brightness control levels supported */
 	u8 _BCM:1;		/*Set the brightness level */
+	u8 _BQC:1;		/* Get current brightness level */
 	u8 _DDC:1;		/*Return the EDID for this device */
 	u8 _DCS:1;		/*Return status of output device */
 	u8 _DGS:1;		/*Query graphics state */
 	u8 _DSS:1;		/*Device state set */
-	u8 _reserved:1;
 };
 
 struct acpi_video_device_brightness {
@@ -162,6 +165,7 @@ struct acpi_video_device {
 	struct acpi_video_bus *video;
 	struct acpi_device *dev;
 	struct acpi_video_device_brightness *brightness;
+	struct output_device *output_dev;
 };
 
 /* bus */
@@ -260,6 +264,56 @@ static int acpi_video_get_next_level(str
 				     u32 level_current, u32 event);
 static void acpi_video_switch_brightness(struct acpi_video_device *device,
 					 int event);
+static int acpi_video_device_lcd_set_level(struct acpi_video_device *, int);
+static int acpi_video_device_lcd_get_level_current(struct acpi_video_device *,unsigned long *);
+/*backlight device sysfs support*/
+static int acpi_video_get_brightness(struct backlight_device *bd);
+static int acpi_video_set_brightness(struct backlight_device *bd);
+static int acpi_video_output_get(struct output_device *);
+static int acpi_video_output_set(struct output_device *);
+static int acpi_video_device_get_state(struct acpi_video_device *, unsigned long *);
+static int acpi_video_device_set_state(struct acpi_video_device *, int);
+
+static struct backlight_device *acpi_video_backlight;
+static struct acpi_video_device *backlight_acpi_device;
+static struct backlight_properties acpi_video_data = {
+	.owner		= THIS_MODULE,
+	.max_brightness = 0,
+	.get_brightness = acpi_video_get_brightness,
+	.update_status  = acpi_video_set_brightness,
+};
+static struct output_properties acpi_output_properties = {
+	.set_state = acpi_video_output_set,
+	.get_status = acpi_video_output_get,
+};
+static int acpi_video_get_brightness(struct backlight_device *bd)
+{
+	unsigned long cur_level;
+	acpi_video_device_lcd_get_level_current(backlight_acpi_device, &cur_level);
+	return (int) cur_level;
+}
+
+static int acpi_video_set_brightness(struct backlight_device *bd)
+{
+	int request_level = bd->props->brightness;
+	acpi_video_device_lcd_set_level(backlight_acpi_device, request_level);
+	return 0;
+}
+
+static int acpi_video_output_get(struct output_device *od)
+{
+	unsigned long state;
+	struct acpi_video_device *vd = (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+	acpi_video_device_get_state(vd, &state);
+	return (int)state;
+}
+
+static int acpi_video_output_set(struct output_device *od)
+{
+	unsigned long state = od->request_state;
+	struct acpi_video_device *vd = (struct acpi_video_device *)class_get_devdata(&od->class_dev);
+	return acpi_video_device_set_state(vd, state);
+}
 
 /* --------------------------------------------------------------------------
                                Video Management
@@ -345,7 +399,7 @@ acpi_video_device_lcd_set_level(struct a
 	arg0.integer.value = level;
 	status = acpi_evaluate_object(device->dev->handle, "_BCM", &args, NULL);
 
-	printk(KERN_DEBUG "set_level status: %x\n", status);
+	printk(KERN_DEBUG PREFIX "set_level status: %x\n", status);
 	return status;
 }
 
@@ -482,6 +536,134 @@ acpi_video_bus_DOS(struct acpi_video_bus
 	return status;
 }
 
+
+/*
+ * copy & paste some code for acpi_pci_data, acpi_pci_data_handler,acpi_pci_data
+ * from pci_bind.c
+ * To-do: write a new API: acpi_pci_get.
+ */
+
+struct acpi_pci_data {
+        struct acpi_pci_id id;
+        struct pci_bus *bus;
+        struct pci_dev *dev;
+};
+
+static void acpi_pci_data_handler(acpi_handle handle, u32 function,
+				  void *context)
+{
+
+	/* TBD: Anything we need to do here? */
+
+	return;
+}
+
+static struct acpi_pci_data * acpi_pci_get (struct acpi_device *device)
+{
+	int result = 0;
+	acpi_status status = AE_OK;
+	struct acpi_pci_data *data = NULL;
+	struct acpi_pci_data *pdata = NULL;
+	char *pathname = NULL;
+	struct acpi_buffer buffer = { 0, NULL };
+	acpi_handle handle = NULL;
+	struct pci_dev *dev;
+	struct pci_bus *bus;
+
+
+	if (!device || !device->parent)
+		return NULL;
+
+	pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
+	if (!pathname)
+		return -ENOMEM;
+	memset(pathname, 0, ACPI_PATHNAME_MAX);
+	buffer.length = ACPI_PATHNAME_MAX;
+	buffer.pointer = pathname;
+
+	data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
+	if (!data) {
+		kfree(pathname);
+		return NULL;
+	}
+	memset(data, 0, sizeof(struct acpi_pci_data));
+
+	acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
+	printk(KERN_INFO PREFIX "finding PCI device [%s]...\n", pathname);
+
+	/*
+	 * Segment & Bus
+	 * -------------
+	 * These are obtained via the parent device's ACPI-PCI context.
+	 */
+go_up:
+	status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
+			       (void **)&pdata);
+	if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
+		struct acpi_device *tmp_dev;
+
+		tmp_dev = device->parent;
+		if (tmp_dev->parent && (tmp_dev->parent->handle != ACPI_ROOT_OBJECT)) {
+			device = tmp_dev;
+			goto go_up;
+		}
+
+		ACPI_EXCEPTION((AE_INFO, status,
+				"Invalid ACPI-PCI context for parent device %s",
+				acpi_device_bid(device->parent)));
+		return NULL;
+	}
+	data->id.segment = pdata->id.segment;
+	data->id.bus = pdata->bus->number;
+
+	/*
+	 * Device & Function
+	 * -----------------
+	 * These are simply obtained from the device's _ADR method.  Note
+	 * that a value of zero is valid.
+	 */
+	data->id.device = device->pnp.bus_address >> 16;
+	data->id.function = device->pnp.bus_address & 0xFFFF;
+
+	printk(KERN_INFO PREFIX "...to %02x:%02x:%02x.%02x\n",
+			  data->id.segment, data->id.bus, data->id.device,
+			  data->id.function);
+
+	/*
+	 * TBD: Support slot devices (e.g. function=0xFFFF).
+	 */
+
+	/*
+	 * Locate PCI Device
+	 * -----------------
+	 * Locate matching device in PCI namespace.  If it doesn't exist
+	 * this typically means that the device isn't currently inserted
+	 * (e.g. docking station, port replicator, etc.).
+	 * We cannot simply search the global pci device list, since
+	 * PCI devices are added to the global pci list when the root
+	 * bridge start ops are run, which may not have happened yet.
+	 */
+	bus = pci_find_bus(data->id.segment, data->id.bus);
+	if (bus) {
+		list_for_each_entry(dev, &bus->devices, bus_list) {
+			if (dev->devfn == PCI_DEVFN(data->id.device,
+						    data->id.function)) {
+				data->dev = dev;
+				break;
+			}
+		}
+	}
+	printk(KERN_INFO PREFIX "data->dev =%p", &data->dev);
+	printk(KERN_INFO PREFIX "data->dev->dev =%p\n", &data->dev->dev);
+	if (!data->dev) {
+		printk(KERN_ERR PREFIX "Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
+				  data->id.segment, data->id.bus,
+				  data->id.device, data->id.function);
+		return NULL;
+	}
+	return data;
+}
+
 /*
  *  Arg:	
  *  	device	: video output device (LCD, CRT, ..)
@@ -498,12 +680,18 @@ static void acpi_video_device_find_cap(s
 	acpi_integer status;
 	acpi_handle h_dummy1;
 	int i;
+	u32 max_level = 0;
 	union acpi_object *obj = NULL;
 	struct acpi_video_device_brightness *br = NULL;
+	struct acpi_pci_data *data;
 
 
+	data = acpi_pci_get (device->video->device);
+        if (!data || !(data->dev)) {
+		printk(KERN_ERR PREFIX "acpi_video_device:no valid data from acpi_pci_get\n");
+		return ;
+	}
 	memset(&device->cap, 0, 4);
-
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
 		device->cap._ADR = 1;
 	}
@@ -513,6 +701,9 @@ static void acpi_video_device_find_cap(s
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
 		device->cap._BCM = 1;
 	}
+	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BQC", &h_dummy1))) {
+		device->cap._BQC = 1;
+	}
 	if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) {
 		device->cap._DDC = 1;
 	}
@@ -526,6 +717,7 @@ static void acpi_video_device_find_cap(s
 		device->cap._DSS = 1;
 	}
 
+
 	status = acpi_video_device_lcd_query_levels(device, &obj);
 
 	if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
@@ -534,7 +726,7 @@ static void acpi_video_device_find_cap(s
 
 		br = kmalloc(sizeof(*br), GFP_KERNEL);
 		if (!br) {
-			printk(KERN_ERR "can't allocate memory\n");
+			printk(KERN_ERR PREFIX "can't allocate memory\n");
 		} else {
 			memset(br, 0, sizeof(*br));
 			br->levels = kmalloc(obj->package.count *
@@ -550,6 +742,8 @@ static void acpi_video_device_find_cap(s
 					continue;
 				}
 				br->levels[count] = (u32) o->integer.value;
+				if (br->levels[count] > max_level)
+					max_level = br->levels[count];
 				count++;
 			}
 		      out:
@@ -568,6 +762,26 @@ static void acpi_video_device_find_cap(s
 
 	kfree(obj);
 
+	if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
+		unsigned long tmp;
+		acpi_video_data.max_brightness = max_level;
+		acpi_video_device_lcd_get_level_current(device, &tmp);
+		acpi_video_data.brightness = tmp;
+		acpi_video_backlight = backlight_device_register("acpi-video",
+			&(data->dev->dev), NULL, &acpi_video_data);
+		backlight_acpi_device = device;
+	}
+
+	if (device->cap._DCS && device->cap._DSS){
+		char name[16];
+		memset(name, 0, 16);
+		strcat(name, acpi_device_bid(device->dev->parent));
+		strcat(name, "_");
+		strcpy(name, acpi_device_bid(device->dev));
+		device->output_dev = video_output_register(name,
+					 &(data->dev->dev),
+						device, &acpi_output_properties);
+	}
 	return;
 }
 
@@ -1011,7 +1225,6 @@ static int acpi_video_bus_POST_info_seq_
 			printk(KERN_WARNING PREFIX
 			       "This indicate a BIOS bug.  Please contact the manufacturer.\n");
 		}
-		printk("%lx\n", options);
 		seq_printf(seq, "can POST: <intgrated video>");
 		if (options & 2)
 			seq_printf(seq, " <PCI video>");
@@ -1148,11 +1361,15 @@ static int acpi_video_bus_add_fs(struct 
 {
 	struct proc_dir_entry *entry = NULL;
 	struct acpi_video_bus *video;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	video = (struct acpi_video_bus *)acpi_driver_data(device);
 
 	if (!acpi_device_dir(device)) {
+              	strcpy(proc_dir_name, acpi_device_bid(device));
+               	strcat(proc_dir_name, "_");
+               	strcat(proc_dir_name, acpi_device_bid(device->parent));
 		acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
 						     acpi_video_dir);
 		if (!acpi_device_dir(device))
@@ -1224,17 +1441,21 @@ static int acpi_video_bus_add_fs(struct 
 static int acpi_video_bus_remove_fs(struct acpi_device *device)
 {
 	struct acpi_video_bus *video;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	video = (struct acpi_video_bus *)acpi_driver_data(device);
-
 	if (acpi_device_dir(device)) {
 		remove_proc_entry("info", acpi_device_dir(device));
 		remove_proc_entry("ROM", acpi_device_dir(device));
 		remove_proc_entry("POST_info", acpi_device_dir(device));
 		remove_proc_entry("POST", acpi_device_dir(device));
 		remove_proc_entry("DOS", acpi_device_dir(device));
-		remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
+
+                strcpy(proc_dir_name, acpi_device_bid(device));
+                strcat(proc_dir_name, "_");
+                strcat(proc_dir_name, acpi_device_bid(device->parent));
+                remove_proc_entry(proc_dir_name, acpi_video_dir);
 		acpi_device_dir(device) = NULL;
 	}
 
@@ -1268,7 +1489,6 @@ acpi_video_bus_get_one_device(struct acp
 			return -ENOMEM;
 
 		memset(data, 0, sizeof(struct acpi_video_device));
-
 		strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
 		strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
 		acpi_driver_data(device) = data;
@@ -1568,6 +1788,10 @@ static int acpi_video_bus_put_one_device
 	status = acpi_remove_notify_handler(device->dev->handle,
 					    ACPI_DEVICE_NOTIFY,
 					    acpi_video_device_notify);
+	if (device == backlight_acpi_device)
+		backlight_device_unregister(acpi_video_backlight);
+
+	video_output_unregister(device->output_dev);
 
 	return 0;
 }
@@ -1615,7 +1839,7 @@ static void acpi_video_bus_notify(acpi_h
 	struct acpi_video_bus *video = (struct acpi_video_bus *)data;
 	struct acpi_device *device = NULL;
 
-	printk("video bus notify\n");
+	printk(KERN_INFO PREFIX "video bus notify\n");
 
 	if (!video)
 		return;
@@ -1658,8 +1882,6 @@ static void acpi_video_device_notify(acp
 	    (struct acpi_video_device *)data;
 	struct acpi_device *device = NULL;
 
-
-	printk("video device notify\n");
 	if (!video_device)
 		return;
 
@@ -1691,8 +1913,9 @@ static int acpi_video_bus_add(struct acp
 	int result = 0;
 	acpi_status status = 0;
 	struct acpi_video_bus *video = NULL;
+        char proc_dir_name[32];
 
-
+	memset(proc_dir_name, 0, 32);
 	if (!device)
 		return -EINVAL;
 
@@ -1735,8 +1958,12 @@ static int acpi_video_bus_add(struct acp
 		goto end;
 	}
 
+        strcpy(proc_dir_name, acpi_device_bid(device));
+        strcat(proc_dir_name, "_");
+        strcat(proc_dir_name, acpi_device_bid(device->parent));
+
 	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
-	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
+               ACPI_VIDEO_DEVICE_NAME, proc_dir_name,
 	       video->flags.multihead ? "yes" : "no",
 	       video->flags.rom ? "yes" : "no",
 	       video->flags.post ? "yes" : "no");
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7a43020..effcb23 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1644,5 +1644,14 @@ if SYSFS
 	source "drivers/video/backlight/Kconfig"
 endif
 
+
+config VIDEO_OUTPUT_CONTROL
+	tristate "Video Output Switcher control"
+	depends on SYSFS
+	---help---
+	  The output sysfs class driver is to provide video output abstract
+	  layer that can be used to hook platform specific driver methods
+	  to enable/disable display output device through common sysfs
+	  interface.	  
 endmenu
 
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index a6980e9..0f82eed 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -108,3 +108,4 @@ obj-$(CONFIG_FB_OF)               += off
 
 # the test framebuffer is last
 obj-$(CONFIG_FB_VIRTUAL)          += vfb.o
+obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o

[-- Attachment #5: 4-fix.patch --]
[-- Type: text/x-patch, Size: 1317 bytes --]

diff --git a/Documentation/video-output.txt b/Documentation/video-output.txt
new file mode 100644
index 0000000..71b1dba
--- /dev/null
+++ b/Documentation/video-output.txt
@@ -0,0 +1,34 @@
+
+		Video Output Switcher Control
+		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		2006 luming.yu@gmail.com
+
+The output sysfs class driver is to provide video output abstract layer that 
+can be used to hook platform specific methods to enable/disable video output
+device through common sysfs interface. For example, on my IBM Thinkpad T42 
+aptop, acpi video driver registered its output devices and read/write method
+for state with output sysfs class. The user interface under sysfs is :
+
+linux:/sys/class/video_output # tree .
+.
+|-- CRT0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+|-- DVI0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+|-- LCD0
+|   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+|   |-- state
+|   |-- subsystem -> ../../../class/video_output
+|   `-- uevent
+`-- TV0
+   |-- device -> ../../../devices/pci0000:00/0000:00:01.0
+   |-- state
+   |-- subsystem -> ../../../class/video_output
+   `-- uevent
+

[-- Attachment #6: 5-fix.patch --]
[-- Type: text/x-patch, Size: 2734 bytes --]

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index ace21e2..4ad109f 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -89,26 +89,26 @@ struct acpi_video_bus_flags {
 };
 
 struct acpi_video_bus_cap {
-	u8 _DOS:1;		/*Enable/Disable output switching */
-	u8 _DOD:1;		/*Enumerate all devices attached to display adapter */
-	u8 _ROM:1;		/*Get ROM Data */
-	u8 _GPD:1;		/*Get POST Device */
-	u8 _SPD:1;		/*Set POST Device */
-	u8 _VPO:1;		/*Video POST Options */
+	u8 _DOS:1;		/* Enable/Disable output switching */
+	u8 _DOD:1;		/* Enumerate all devices attached to display adapter */
+	u8 _ROM:1;		/* Get ROM Data */
+	u8 _GPD:1;		/* Get POST Device */
+	u8 _SPD:1;		/* Set POST Device */
+	u8 _VPO:1;		/* Video POST Options */
 	u8 reserved:2;
 };
 
 struct acpi_video_device_attrib {
 	u32 display_index:4;	/* A zero-based instance of the Display */
-	u32 display_port_attachment:4;	/*This field differenates displays type */
-	u32 display_type:4;	/*Describe the specific type in use */
-	u32 vendor_specific:4;	/*Chipset Vendor Specifi */
-	u32 bios_can_detect:1;	/*BIOS can detect the device */
-	u32 depend_on_vga:1;	/*Non-VGA output device whose power is related to 
-				   the VGA device. */
-	u32 pipe_id:3;		/*For VGA multiple-head devices. */
-	u32 reserved:10;	/*Must be 0 */
-	u32 device_id_scheme:1;	/*Device ID Scheme */
+	u32 display_port_attachment:4;	/* differenates displays type */
+	u32 display_type:4;	/* Describe the specific type in use */
+	u32 vendor_specific:4;	/* Chipset Vendor Specifi */
+	u32 bios_can_detect:1;	/* BIOS can detect the device */
+	u32 depend_on_vga:1;	/* Non-VGA output device whose power */
+				/* is related to the VGA device. */
+	u32 pipe_id:3;		/* For VGA multiple-head devices. */
+	u32 reserved:10;	/* Must be 0 */
+	u32 device_id_scheme:1;	/* Device ID Scheme */
 };
 
 struct acpi_video_enumerated_device {
@@ -141,14 +141,14 @@ struct acpi_video_device_flags {
 };
 
 struct acpi_video_device_cap {
-	u8 _ADR:1;		/*Return the unique ID */
-	u8 _BCL:1;		/*Query list of brightness control levels supported */
-	u8 _BCM:1;		/*Set the brightness level */
+	u8 _ADR:1;		/* Return the unique ID */
+	u8 _BCL:1;		/* Query brightness control levels supported */
+	u8 _BCM:1;		/* Set the brightness level */
 	u8 _BQC:1;		/* Get current brightness level */
-	u8 _DDC:1;		/*Return the EDID for this device */
-	u8 _DCS:1;		/*Return status of output device */
-	u8 _DGS:1;		/*Query graphics state */
-	u8 _DSS:1;		/*Device state set */
+	u8 _DDC:1;		/* Return the EDID for this device */
+	u8 _DCS:1;		/* Return status of output device */
+	u8 _DGS:1;		/* Query graphics state */
+	u8 _DSS:1;		/* Device state set */
 };
 
 struct acpi_video_device_brightness {

[-- Attachment #7: 6-fix.patch --]
[-- Type: text/x-patch, Size: 826 bytes --]

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 4ad109f..4a2520b 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -560,13 +560,11 @@ static void acpi_pci_data_handler(acpi_h
 
 static struct acpi_pci_data * acpi_pci_get (struct acpi_device *device)
 {
-	int result = 0;
 	acpi_status status = AE_OK;
 	struct acpi_pci_data *data = NULL;
 	struct acpi_pci_data *pdata = NULL;
 	char *pathname = NULL;
 	struct acpi_buffer buffer = { 0, NULL };
-	acpi_handle handle = NULL;
 	struct pci_dev *dev;
 	struct pci_bus *bus;
 
@@ -576,7 +574,7 @@ static struct acpi_pci_data * acpi_pci_g
 
 	pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
 	if (!pathname)
-		return -ENOMEM;
+		return NULL;
 	memset(pathname, 0, ACPI_PATHNAME_MAX);
 	buffer.length = ACPI_PATHNAME_MAX;
 	buffer.pointer = pathname;

^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2006-10-30 15:49 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-30 17:08 [PATCH 2.6.18-mm2] acpi: add backlight support to the sony_acpi driver Alessandro Guido
2006-09-30 17:14 ` Alessandro Guido
2006-09-30 17:31   ` Jan Engelhardt
2006-10-02  0:19 ` Andrew Morton
2006-10-02  0:39   ` Matt Domsch
2006-10-02  0:48     ` Matt Domsch
2006-10-05 10:36     ` Pavel Machek
2006-10-06 21:17       ` Matt Domsch
2006-10-06 22:44         ` Pavel Machek
2006-10-10 14:32         ` Yu Luming
2006-10-10 14:47           ` Richard Hughes
2006-10-10 16:10             ` Matt Domsch
2006-10-11 16:28               ` Yu Luming
2006-10-16 17:45                 ` Yu Luming
2006-10-25  7:07                   ` Pavel Machek
2006-10-27 17:24                     ` Luming Yu
2006-10-29 17:50                       ` Pavel Machek
2006-10-30 15:49                         ` Luming Yu
2006-10-10 21:26           ` Matthew Garrett
2006-10-11  3:02             ` Matt Domsch
2006-10-11  3:16               ` Matthew Garrett
2006-10-11 16:37               ` Yu Luming
2006-10-11  6:59             ` Arjan van de Ven
2006-10-11  7:04               ` Matthew Garrett
2006-10-11  8:04                 ` Ismail Donmez
2006-10-11  8:12                   ` Matthew Garrett
2006-10-11 16:31                   ` Yu Luming
2006-10-11 16:45                     ` Ismail Donmez
2006-10-02 10:29   ` Holger Macht
2006-10-02 11:25   ` Alessandro Guido
2006-10-10 15:17     ` Yu Luming
2006-10-10 15:22       ` Richard Hughes
2006-10-10 21:23       ` Matthew Garrett
2006-10-11  3:20         ` Dmitry Torokhov
2006-10-11 16:48           ` Yu Luming
2006-10-11 19:08             ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox