public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi <linux-acpi@vger.kernel.org>,
	Jonathan Woithe <jwoithe@physics.adelaide.edu.au>,
	Carlos Corbacho <carlos@strangeworlds.co.uk>,
	Corentin CHARY <corentincj@iksaif.net>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Mattia Dongili <malattia@linux.it>
Subject: [PATCH 7/7] Who controls brightness functionality: vendor specific or generic video driver
Date: Wed, 16 Apr 2008 21:02:52 +0200	[thread overview]
Message-ID: <1208372572.1784.352.camel@queen.suse.de> (raw)

Who controls brightness functionality: vendor specific or generic video driver

Depending on the capablity of ACPI graphics devices and whether they implement
all necessary functions so that the generic ACPI video driver can control
them, decide at driver load time whether a vendor specific device driver or
the ACPI video driver should control the brighntess functionality.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/misc/acer-wmi.c       |   15 +++++++++++----
 drivers/misc/asus-laptop.c    |    6 ++++++
 drivers/misc/fujitsu-laptop.c |   27 +++++++++++++++++++--------
 drivers/misc/msi-laptop.c     |   16 +++++++++++-----
 drivers/misc/sony-laptop.c    |   14 +++++++++-----
 drivers/misc/thinkpad_acpi.c  |    7 +++++++
 6 files changed, 63 insertions(+), 22 deletions(-)

Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/asus-laptop.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/asus-laptop.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/asus-laptop.c
@@ -1105,6 +1105,12 @@ static int asus_backlight_init(struct de
 {
 	struct backlight_device *bd;
 
+	if (acpi_video_support & ACPI_VIDEO_BRIGHTNESS &&
+	    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC)) {
+		printk(ASUS_INFO "Brightness ignored, must be controlled by "
+		       "ACPI video driver\n");
+		return -ENODEV;
+	}
 	if (brightness_set_handle && lcd_switch_handle) {
 		bd = backlight_device_register(ASUS_HOTK_FILE, dev,
 					       NULL, &asusbl_ops);
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/thinkpad_acpi.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/thinkpad_acpi.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/thinkpad_acpi.c
@@ -4381,6 +4381,13 @@ static int __init brightness_init(struct
 			   "module parameter\n");
 		return 1;
 	} else if (brightness_enable > 1) {
+		if ((acpi_video_support & ACPI_VIDEO_BRIGHTNESS) &&
+		    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC)) {
+			printk(TPACPI_INFO "Brightness ignored, must be "
+			       "controlled by ACPI video driver\n");
+			return 1;
+		}
+		/* Above, generic approach should make this check obsolete */
 		if (brightness_check_std_acpi_support()) {
 			printk(TPACPI_NOTICE
 			       "standard ACPI backlight interface "
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/fujitsu-laptop.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/fujitsu-laptop.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/fujitsu-laptop.c
@@ -273,13 +273,21 @@ static int __init fujitsu_init(void)
 
 	/* Register backlight stuff */
 
-	fujitsu->bl_device =
-	    backlight_device_register("fujitsu-laptop", NULL, NULL,
-				      &fujitsubl_ops);
-	if (IS_ERR(fujitsu->bl_device))
-		return PTR_ERR(fujitsu->bl_device);
+	if (acpi_video_support & ACPI_VIDEO_BRIGHTNESS &&
+	    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC)) {
+		printk(KERN_INFO "Brightness ignored, must be controlled by "
+		       "ACPI video driver\n");
+	} else {
+		fujitsu->bl_device =
+			backlight_device_register("fujitsu-laptop", NULL, NULL,
+						  &fujitsubl_ops);
+		if (IS_ERR(fujitsu->bl_device))
+			return PTR_ERR(fujitsu->bl_device);
+
+		fujitsu->bl_device->props.max_brightness =
+			FUJITSU_LCD_N_LEVELS - 1;
+	}
 
-	fujitsu->bl_device->props.max_brightness = FUJITSU_LCD_N_LEVELS - 1;
 	ret = platform_driver_register(&fujitsupf_driver);
 	if (ret)
 		goto fail_backlight;
@@ -321,7 +329,8 @@ static int __init fujitsu_init(void)
 
       fail_backlight:
 
-	backlight_device_unregister(fujitsu->bl_device);
+	if (fujitsu->bl_device)
+		backlight_device_unregister(fujitsu->bl_device);
 
       fail_acpi:
 
@@ -336,9 +345,11 @@ static void __exit fujitsu_cleanup(void)
 			   &fujitsupf_attribute_group);
 	platform_device_unregister(fujitsu->pf_device);
 	platform_driver_unregister(&fujitsupf_driver);
+
 	backlight_device_unregister(fujitsu->bl_device);
 
-	acpi_bus_unregister_driver(&acpi_fujitsu_driver);
+	if (fujitsu->bl_device)
+		acpi_bus_unregister_driver(&acpi_fujitsu_driver);
 
 	kfree(fujitsu);
 
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/acer-wmi.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/acer-wmi.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/acer-wmi.c
@@ -837,7 +837,8 @@ static int __devinit acer_backlight_init
 
 static void acer_backlight_exit(void)
 {
-	backlight_device_unregister(acer_backlight_device);
+	if (acer_backlight_device)
+		backlight_device_unregister(acer_backlight_device);
 }
 
 /*
@@ -907,9 +908,15 @@ static int __devinit acer_platform_probe
 	}
 
 	if (has_cap(ACER_CAP_BRIGHTNESS)) {
-		err = acer_backlight_init(&device->dev);
-		if (err)
-			goto error_brightness;
+		if (acpi_video_support & ACPI_VIDEO_BRIGHTNESS &&
+		    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC))
+			printk(ACER_INFO "Brightness must be controlled by "
+			       "generic video driver\n");
+		else {
+			err = acer_backlight_init(&device->dev);
+			if (err)
+				goto error_brightness;
+		}
 	}
 
 	return 0;
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/sony-laptop.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/sony-laptop.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/sony-laptop.c
@@ -1037,7 +1037,12 @@ static int sony_nc_add(struct acpi_devic
 		goto outinput;
 	}
 
-	if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", &handle))) {
+	if (acpi_video_support & ACPI_VIDEO_BRIGHTNESS &&
+	    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC)) {
+		printk(KERN_INFO DRV_PFX "Sony: Brightness ignored, must be "
+		       "controlled by ACPI video driver\n");
+	} else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
+						&handle))) {
 		sony_backlight_device = backlight_device_register("sony", NULL,
 								  NULL,
 								  &sony_backlight_ops);
@@ -1047,12 +1052,11 @@ static int sony_nc_add(struct acpi_devic
 			sony_backlight_device = NULL;
 		} else {
 			sony_backlight_device->props.brightness =
-			    sony_backlight_get_brightness
-			    (sony_backlight_device);
+				sony_backlight_get_brightness
+				(sony_backlight_device);
 			sony_backlight_device->props.max_brightness =
-			    SONY_MAX_BRIGHTNESS - 1;
+				SONY_MAX_BRIGHTNESS - 1;
 		}
-
 	}
 
 	/* initialize models with specific requirements */
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/misc/msi-laptop.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/misc/msi-laptop.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/misc/msi-laptop.c
@@ -347,12 +347,18 @@ static int __init msi_init(void)
 
 	/* Register backlight stuff */
 
-	msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL,
-						&msibl_ops);
-	if (IS_ERR(msibl_device))
-		return PTR_ERR(msibl_device);
+	if ((acpi_video_support & ACPI_VIDEO_BRIGHTNESS) &&
+	    !(acpi_video_support & ACPI_VIDEO_FORCE_VENDOR_SPECIFIC)) {
+		printk(KERN_INFO "MSI: Brightness ignored, must be controlled "
+		       "by ACPI video driver\n");
+	} else {
+		msibl_device = backlight_device_register("msi-laptop-bl", NULL,
+							 NULL, &msibl_ops);
+		if (IS_ERR(msibl_device))
+			return PTR_ERR(msibl_device);
 
-	msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1;
+		msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1;
+	}
 
 	ret = platform_driver_register(&msipf_driver);
 	if (ret)



             reply	other threads:[~2008-04-16 19:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-16 19:02 Thomas Renninger [this message]
2008-04-16 19:08 ` [PATCH 7/7] Who controls brightness functionality: vendor specific or generic video driver Thomas Renninger
2008-04-16 21:01 ` Henrique de Moraes Holschuh
2008-04-17 19:32   ` Thomas Renninger
2008-04-19 11:03 ` Carlos Corbacho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208372572.1784.352.camel@queen.suse.de \
    --to=trenn@suse.de \
    --cc=carlos@strangeworlds.co.uk \
    --cc=corentincj@iksaif.net \
    --cc=hmh@hmh.eng.br \
    --cc=jwoithe@physics.adelaide.edu.au \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=malattia@linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox