* [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
@ 2008-06-07 2:54 Matthew Garrett
2008-06-07 5:04 ` Andrey Panin
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Matthew Garrett @ 2008-06-07 2:54 UTC (permalink / raw)
To: rpurdie; +Cc: linux-kernel, mzxreary
Nvidia-based Apple Macbook Pros don't appear to handle backlight control
through the graphics card registers or ACPI, but instead trigger changes
via SMI calls. This driver registers a generic backlight device that
lets existing userspace deal with it. Code derived from Julien Blache's
Pommed application.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
Lennart - as far as I could tell from your description, the DMI
autoloading code for this should be correct. However, it's not working
for me on F9. Have I missed something, or does it just not work there?
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index dcd8073..56f4572 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -112,3 +112,11 @@ config BACKLIGHT_CARILLO_RANCH
help
If you have a Intel LE80578 (Carillo Ranch) say Y to enable the
backlight driver.
+
+config BACKLIGHT_MBP_NVIDIA
+ tristate "Macbook Pro Nvidia Backlight Driver"
+ depends on BACKLIGHT_CLASS_DEVICE && X86
+ default n
+ help
+ If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
+ to enable a driver for its backlight
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 33f6c7c..5b91515 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
+obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
new file mode 100644
index 0000000..c622d22
--- /dev/null
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -0,0 +1,114 @@
+/*
+ * Backlight Driver for Nvidia 8600 in Macbook Pro
+ *
+ * Copyright (c) Red Hat <mjg@redhat.com>
+ * Based on code from Pommed:
+ * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
+ * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
+ * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This driver triggers SMIs which cause the firmware to change the
+ * backlight brightness. This is icky in many ways, but it's impractical to
+ * get at the firmware code in order to figure out what it's actually doing.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/dmi.h>
+#include <linux/io.h>
+
+struct backlight_device *mbp_backlight_device;
+
+static struct dmi_system_id __initdata mbp_device_table[] = {
+ {
+ .ident = "3,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
+ },
+ },
+ {
+ .ident = "3,2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"),
+ },
+ },
+ {
+ .ident = "4,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"),
+ },
+ },
+ { }
+};
+
+static int mbp_send_intensity(struct backlight_device *bd)
+{
+ int intensity = bd->props.brightness;
+
+ outb(0x04 | (intensity << 4), 0xb3);
+ outb(0xbf, 0xb2);
+
+ return 0;
+}
+
+static int mbp_get_intensity(struct backlight_device *bd)
+{
+ outb(0x03, 0xb3);
+ outb(0xbf, 0xb2);
+ return inb(0xb3) >> 4;
+}
+
+static struct backlight_ops mbp_ops = {
+ .get_brightness = mbp_get_intensity,
+ .update_status = mbp_send_intensity,
+};
+
+static int __init mbp_init(void)
+{
+ if (!dmi_check_system(mbp_device_table))
+ return -ENODEV;
+
+ if (!request_region(0xb2, 2, "Macbook Pro backlight"))
+ return -ENXIO;
+
+ mbp_backlight_device = backlight_device_register("mbp_backlight",
+ NULL, NULL,
+ &mbp_ops);
+ if (IS_ERR(mbp_backlight_device))
+ return PTR_ERR(mbp_backlight_device);
+
+ mbp_backlight_device->props.max_brightness = 15;
+ mbp_backlight_device->props.brightness =
+ mbp_get_intensity(mbp_backlight_device);
+ backlight_update_status(mbp_backlight_device);
+
+ return 0;
+}
+
+static void __exit mbp_exit(void)
+{
+ backlight_device_unregister(mbp_backlight_device);
+
+ release_region(0xb2, 2);
+}
+
+module_init(mbp_init);
+module_exit(mbp_exit);
+
+MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
+MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,1:*");
+MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,2:*");
+MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro4,1:*");
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 2:54 [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros Matthew Garrett
@ 2008-06-07 5:04 ` Andrey Panin
2008-06-07 6:07 ` Andrew Morton
2008-06-08 18:32 ` [PATCH] " Lennart Poettering
2 siblings, 0 replies; 14+ messages in thread
From: Andrey Panin @ 2008-06-07 5:04 UTC (permalink / raw)
To: Matthew Garrett; +Cc: rpurdie, linux-kernel, mzxreary
[-- Attachment #1: Type: text/plain, Size: 5706 bytes --]
On 159, 06 07, 2008 at 03:54:36 +0100, Matthew Garrett wrote:
> Nvidia-based Apple Macbook Pros don't appear to handle backlight control
> through the graphics card registers or ACPI, but instead trigger changes
> via SMI calls. This driver registers a generic backlight device that
> lets existing userspace deal with it. Code derived from Julien Blache's
> Pommed application.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
>
> ---
>
> Lennart - as far as I could tell from your description, the DMI
> autoloading code for this should be correct. However, it's not working
> for me on F9. Have I missed something, or does it just not work there?
BTW do we have any documentation to help ordinary human understand and generate
these aliases ?
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index dcd8073..56f4572 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -112,3 +112,11 @@ config BACKLIGHT_CARILLO_RANCH
> help
> If you have a Intel LE80578 (Carillo Ranch) say Y to enable the
> backlight driver.
> +
> +config BACKLIGHT_MBP_NVIDIA
> + tristate "Macbook Pro Nvidia Backlight Driver"
> + depends on BACKLIGHT_CLASS_DEVICE && X86
> + default n
> + help
> + If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
> + to enable a driver for its backlight
> diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> index 33f6c7c..5b91515 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
> obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
> obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
> obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
> +obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
> diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
> new file mode 100644
> index 0000000..c622d22
> --- /dev/null
> +++ b/drivers/video/backlight/mbp_nvidia_bl.c
> @@ -0,0 +1,114 @@
> +/*
> + * Backlight Driver for Nvidia 8600 in Macbook Pro
> + *
> + * Copyright (c) Red Hat <mjg@redhat.com>
> + * Based on code from Pommed:
> + * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
> + * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
> + * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This driver triggers SMIs which cause the firmware to change the
> + * backlight brightness. This is icky in many ways, but it's impractical to
> + * get at the firmware code in order to figure out what it's actually doing.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/backlight.h>
> +#include <linux/err.h>
> +#include <linux/dmi.h>
> +#include <linux/io.h>
> +
> +struct backlight_device *mbp_backlight_device;
Missing static ?
> +
> +static struct dmi_system_id __initdata mbp_device_table[] = {
> + {
> + .ident = "3,1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
> + },
> + },
> + {
> + .ident = "3,2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"),
> + },
> + },
> + {
> + .ident = "4,1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"),
> + },
> + },
> + { }
> +};
> +
> +static int mbp_send_intensity(struct backlight_device *bd)
> +{
> + int intensity = bd->props.brightness;
> +
> + outb(0x04 | (intensity << 4), 0xb3);
> + outb(0xbf, 0xb2);
> +
> + return 0;
> +}
> +
> +static int mbp_get_intensity(struct backlight_device *bd)
> +{
> + outb(0x03, 0xb3);
> + outb(0xbf, 0xb2);
> + return inb(0xb3) >> 4;
> +}
> +
> +static struct backlight_ops mbp_ops = {
> + .get_brightness = mbp_get_intensity,
> + .update_status = mbp_send_intensity,
> +};
> +
> +static int __init mbp_init(void)
> +{
> + if (!dmi_check_system(mbp_device_table))
> + return -ENODEV;
> +
> + if (!request_region(0xb2, 2, "Macbook Pro backlight"))
> + return -ENXIO;
> +
> + mbp_backlight_device = backlight_device_register("mbp_backlight",
> + NULL, NULL,
> + &mbp_ops);
> + if (IS_ERR(mbp_backlight_device))
> + return PTR_ERR(mbp_backlight_device);
You leak ioport region here.
> +
> + mbp_backlight_device->props.max_brightness = 15;
> + mbp_backlight_device->props.brightness =
> + mbp_get_intensity(mbp_backlight_device);
> + backlight_update_status(mbp_backlight_device);
> +
> + return 0;
> +}
> +
> +static void __exit mbp_exit(void)
> +{
> + backlight_device_unregister(mbp_backlight_device);
> +
> + release_region(0xb2, 2);
> +}
> +
> +module_init(mbp_init);
> +module_exit(mbp_exit);
> +
> +MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
> +MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,1:*");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,2:*");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro4,1:*");
--
Andrey Panin | Linux and UNIX system administrator
pazke@donpac.ru | PGP key: wwwkeys.pgp.net
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 2:54 [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros Matthew Garrett
2008-06-07 5:04 ` Andrey Panin
@ 2008-06-07 6:07 ` Andrew Morton
2008-06-07 9:58 ` Matthew Garrett
2008-06-07 10:01 ` [PATCH v2] " Matthew Garrett
2008-06-08 18:32 ` [PATCH] " Lennart Poettering
2 siblings, 2 replies; 14+ messages in thread
From: Andrew Morton @ 2008-06-07 6:07 UTC (permalink / raw)
To: Matthew Garrett; +Cc: rpurdie, linux-kernel, mzxreary
On Sat, 7 Jun 2008 03:54:36 +0100 Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> Nvidia-based Apple Macbook Pros don't appear to handle backlight control
> through the graphics card registers or ACPI, but instead trigger changes
> via SMI calls. This driver registers a generic backlight device that
> lets existing userspace deal with it. Code derived from Julien Blache's
> Pommed application.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
>
> ...
>
> --- /dev/null
> +++ b/drivers/video/backlight/mbp_nvidia_bl.c
> @@ -0,0 +1,114 @@
> +/*
> + * Backlight Driver for Nvidia 8600 in Macbook Pro
> + *
> + * Copyright (c) Red Hat <mjg@redhat.com>
> + * Based on code from Pommed:
> + * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
> + * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
> + * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
Did this patch have appropriate attribution and signoffs?
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This driver triggers SMIs which cause the firmware to change the
> + * backlight brightness. This is icky in many ways, but it's impractical to
> + * get at the firmware code in order to figure out what it's actually doing.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/backlight.h>
> +#include <linux/err.h>
> +#include <linux/dmi.h>
> +#include <linux/io.h>
> +
> +struct backlight_device *mbp_backlight_device;
> +
> +static struct dmi_system_id __initdata mbp_device_table[] = {
> + {
> + .ident = "3,1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
> + },
> + },
> + {
> + .ident = "3,2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"),
> + },
> + },
> + {
> + .ident = "4,1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"),
> + },
> + },
> + { }
> +};
> +
> +static int mbp_send_intensity(struct backlight_device *bd)
> +{
> + int intensity = bd->props.brightness;
> +
> + outb(0x04 | (intensity << 4), 0xb3);
> + outb(0xbf, 0xb2);
> +
> + return 0;
> +}
> +
> +static int mbp_get_intensity(struct backlight_device *bd)
> +{
> + outb(0x03, 0xb3);
> + outb(0xbf, 0xb2);
> + return inb(0xb3) >> 4;
> +}
> +
> +static struct backlight_ops mbp_ops = {
> + .get_brightness = mbp_get_intensity,
> + .update_status = mbp_send_intensity,
> +};
> +
> +static int __init mbp_init(void)
> +{
> + if (!dmi_check_system(mbp_device_table))
> + return -ENODEV;
> +
> + if (!request_region(0xb2, 2, "Macbook Pro backlight"))
> + return -ENXIO;
> +
> + mbp_backlight_device = backlight_device_register("mbp_backlight",
> + NULL, NULL,
> + &mbp_ops);
> + if (IS_ERR(mbp_backlight_device))
> + return PTR_ERR(mbp_backlight_device);
Missing release_region()?
> + mbp_backlight_device->props.max_brightness = 15;
> + mbp_backlight_device->props.brightness =
> + mbp_get_intensity(mbp_backlight_device);
> + backlight_update_status(mbp_backlight_device);
> +
> + return 0;
> +}
> +
> +static void __exit mbp_exit(void)
> +{
> + backlight_device_unregister(mbp_backlight_device);
> +
> + release_region(0xb2, 2);
> +}
> +
> +module_init(mbp_init);
> +module_exit(mbp_exit);
> +
> +MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
> +MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,1:*");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro3,2:*");
> +MODULE_ALIAS("dmi:*:svnApple Inc.:pnMacBookPro4,1:*");
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 6:07 ` Andrew Morton
@ 2008-06-07 9:58 ` Matthew Garrett
2008-06-07 10:05 ` Pekka Enberg
2008-06-07 10:01 ` [PATCH v2] " Matthew Garrett
1 sibling, 1 reply; 14+ messages in thread
From: Matthew Garrett @ 2008-06-07 9:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: rpurdie, linux-kernel, mzxreary
On Fri, Jun 06, 2008 at 11:07:45PM -0700, Andrew Morton wrote:
> On Sat, 7 Jun 2008 03:54:36 +0100 Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> > + * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
> > + * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
> > + * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
>
> Did this patch have appropriate attribution and signoffs?
Pommed is GPLv2.
> Missing release_region()?
Yup.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 9:58 ` Matthew Garrett
@ 2008-06-07 10:05 ` Pekka Enberg
2008-06-07 10:14 ` Matthew Garrett
2008-06-07 18:59 ` Andrew Morton
0 siblings, 2 replies; 14+ messages in thread
From: Pekka Enberg @ 2008-06-07 10:05 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Andrew Morton, rpurdie, linux-kernel, mzxreary
Hi Matthew,
On Fri, Jun 06, 2008 at 11:07:45PM -0700, Andrew Morton wrote:
>> Did this patch have appropriate attribution and signoffs?
On Sat, Jun 7, 2008 at 12:58 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> Pommed is GPLv2.
Andrew has required signoffs from all copyright holders of a patch in
the past regardless of that.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 10:05 ` Pekka Enberg
@ 2008-06-07 10:14 ` Matthew Garrett
2008-06-07 10:50 ` Pekka Enberg
2008-06-07 18:59 ` Andrew Morton
1 sibling, 1 reply; 14+ messages in thread
From: Matthew Garrett @ 2008-06-07 10:14 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Andrew Morton, rpurdie, linux-kernel, mzxreary
On Sat, Jun 07, 2008 at 01:05:23PM +0300, Pekka Enberg wrote:
> Hi Matthew,
>
> On Fri, Jun 06, 2008 at 11:07:45PM -0700, Andrew Morton wrote:
> >> Did this patch have appropriate attribution and signoffs?
>
> On Sat, Jun 7, 2008 at 12:58 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> > Pommed is GPLv2.
>
> Andrew has required signoffs from all copyright holders of a patch in
> the past regardless of that.
SubmittingPatches says (in part):
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
If that's not sufficient, then the documentation needs fixing. It's also
not current practice, as far as I can tell - did ath5k have sign-offs
from the BSD people?
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 10:14 ` Matthew Garrett
@ 2008-06-07 10:50 ` Pekka Enberg
0 siblings, 0 replies; 14+ messages in thread
From: Pekka Enberg @ 2008-06-07 10:50 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Andrew Morton, rpurdie, linux-kernel, mzxreary
On Sat, Jun 7, 2008 at 1:14 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> If that's not sufficient, then the documentation needs fixing. It's also
> not current practice, as far as I can tell - did ath5k have sign-offs
> from the BSD people?
I don't know about ath5k. But when we submitted the IP1000 driver, we
had to contact the copyright holder (a company) and get proper
signoffs before Andrew acked the merge.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 10:05 ` Pekka Enberg
2008-06-07 10:14 ` Matthew Garrett
@ 2008-06-07 18:59 ` Andrew Morton
1 sibling, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2008-06-07 18:59 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Matthew Garrett, rpurdie, linux-kernel, mzxreary
On Sat, 7 Jun 2008 13:05:23 +0300 "Pekka Enberg" <penberg@cs.helsinki.fi> wrote:
> Hi Matthew,
>
> On Fri, Jun 06, 2008 at 11:07:45PM -0700, Andrew Morton wrote:
> >> Did this patch have appropriate attribution and signoffs?
>
> On Sat, Jun 7, 2008 at 12:58 PM, Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> > Pommed is GPLv2.
>
> Andrew has required signoffs from all copyright holders of a patch in
> the past regardless of that.
More like "asked for". It's best to gather those signoffs if the
people are around.
Getting the From: correct is (IMO) more important.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 6:07 ` Andrew Morton
2008-06-07 9:58 ` Matthew Garrett
@ 2008-06-07 10:01 ` Matthew Garrett
2008-06-07 14:45 ` Julien BLACHE
1 sibling, 1 reply; 14+ messages in thread
From: Matthew Garrett @ 2008-06-07 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: rpurdie, linux-kernel, mzxreary
Nvidia-based Apple Macbook Pros don't appear to handle backlight control
through the graphics card registers or ACPI, but instead trigger changes
via SMI calls. This driver registers a generic backlight device that
lets existing userspace deal with it. Code derived from Julien Blache's
Pommed application.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
Added a missing static and a release_region() in the error path pointed
out by Andrey Panin and Andrew Morton
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index dcd8073..56f4572 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -112,3 +112,11 @@ config BACKLIGHT_CARILLO_RANCH
help
If you have a Intel LE80578 (Carillo Ranch) say Y to enable the
backlight driver.
+
+config BACKLIGHT_MBP_NVIDIA
+ tristate "Macbook Pro Nvidia Backlight Driver"
+ depends on BACKLIGHT_CLASS_DEVICE && X86
+ default n
+ help
+ If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
+ to enable a driver for its backlight
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 33f6c7c..5b91515 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
+obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
new file mode 100644
index 0000000..ebe6be5
--- /dev/null
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -0,0 +1,116 @@
+/*
+ * Backlight Driver for Nvidia 8600 in Macbook Pro
+ *
+ * Copyright (c) Red Hat <mjg@redhat.com>
+ * Based on code from Pommed:
+ * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
+ * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
+ * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This driver triggers SMIs which cause the firmware to change the
+ * backlight brightness. This is icky in many ways, but it's impractical to
+ * get at the firmware code in order to figure out what it's actually doing.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/dmi.h>
+#include <linux/io.h>
+
+static struct backlight_device *mbp_backlight_device;
+
+static struct dmi_system_id __initdata mbp_device_table[] = {
+ {
+ .ident = "3,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
+ },
+ },
+ {
+ .ident = "3,2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"),
+ },
+ },
+ {
+ .ident = "4,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"),
+ },
+ },
+ { }
+};
+
+static int mbp_send_intensity(struct backlight_device *bd)
+{
+ int intensity = bd->props.brightness;
+
+ outb(0x04 | (intensity << 4), 0xb3);
+ outb(0xbf, 0xb2);
+
+ return 0;
+}
+
+static int mbp_get_intensity(struct backlight_device *bd)
+{
+ outb(0x03, 0xb3);
+ outb(0xbf, 0xb2);
+ return inb(0xb3) >> 4;
+}
+
+static struct backlight_ops mbp_ops = {
+ .get_brightness = mbp_get_intensity,
+ .update_status = mbp_send_intensity,
+};
+
+static int __init mbp_init(void)
+{
+ if (!dmi_check_system(mbp_device_table))
+ return -ENODEV;
+
+ if (!request_region(0xb2, 2, "Macbook Pro backlight"))
+ return -ENXIO;
+
+ mbp_backlight_device = backlight_device_register("mbp_backlight",
+ NULL, NULL,
+ &mbp_ops);
+ if (IS_ERR(mbp_backlight_device)) {
+ release_region(0xb2, 2);
+ return PTR_ERR(mbp_backlight_device);
+ }
+
+ mbp_backlight_device->props.max_brightness = 15;
+ mbp_backlight_device->props.brightness =
+ mbp_get_intensity(mbp_backlight_device);
+ backlight_update_status(mbp_backlight_device);
+
+ return 0;
+}
+
+static void __exit mbp_exit(void)
+{
+ backlight_device_unregister(mbp_backlight_device);
+
+ release_region(0xb2, 2);
+}
+
+module_init(mbp_init);
+module_exit(mbp_exit);
+
+MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
+MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("svnApple Inc.:pnMacBookPro3,1");
+MODULE_ALIAS("svnApple Inc.:pnMacBookPro3,2");
+MODULE_ALIAS("svnApple Inc.:pnMacBookPro4,1");
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 10:01 ` [PATCH v2] " Matthew Garrett
@ 2008-06-07 14:45 ` Julien BLACHE
0 siblings, 0 replies; 14+ messages in thread
From: Julien BLACHE @ 2008-06-07 14:45 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Andrew Morton, rpurdie, linux-kernel, mzxreary
Matthew Garrett <mjg59@srcf.ucam.org> wrote:
Hi,
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
If you need it, here you have it:
Signed-off-by: Julien Blache <jb@jblache.org>
Minor nitpicks follow:
> +config BACKLIGHT_MBP_NVIDIA
> + tristate "Macbook Pro Nvidia Backlight Driver"
^^^^^^^
Proper capitalization is "MacBook", also to be consistent with other
help texts in the kernel (I hope).
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
This particular file in pommed is GPL v2 or later; it's external
code I included in pommed and the original license was GPL v2 or
later.
JB.
--
Julien BLACHE <http://www.jblache.org>
<jb@jblache.org> GPG KeyID 0xF5D65169
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-07 2:54 [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros Matthew Garrett
2008-06-07 5:04 ` Andrey Panin
2008-06-07 6:07 ` Andrew Morton
@ 2008-06-08 18:32 ` Lennart Poettering
2008-06-09 0:03 ` Matthew Garrett
2008-06-09 0:05 ` [PATCH v2] " Matthew Garrett
2 siblings, 2 replies; 14+ messages in thread
From: Lennart Poettering @ 2008-06-08 18:32 UTC (permalink / raw)
To: Matthew Garrett; +Cc: rpurdie, linux-kernel
On Sat, 07.06.08 03:54, Matthew Garrett (mjg59@srcf.ucam.org) wrote:
> Lennart - as far as I could tell from your description, the DMI
> autoloading code for this should be correct. However, it's not working
> for me on F9. Have I missed something, or does it just not work there?
It should be pretty easy to figure out the right string for
DMI autoloading. Just do a cat /sys/class/dmi/id/modalias and replace the
part of the string you consider not very useful for identifying the
machine with (dates, version numbers, empty strings, 0123456
rubbish data, ...) with an asterisk.
Looking at those strings included in your patch they look pretty much
correct, but since I don't have access to a Mac I cannot really check
this.
It's udev's job to match the modalias strings of your driver module
with the modalias string from /sys/class/dmi/id/modalias. You can
retrigger this matching by doing something like "echo 1 >
/sys/class/dmi/id/uevent" or suchlike, but I don't remember the
details.
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net ICQ# 11060553
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-08 18:32 ` [PATCH] " Lennart Poettering
@ 2008-06-09 0:03 ` Matthew Garrett
2008-06-09 0:05 ` [PATCH v2] " Matthew Garrett
1 sibling, 0 replies; 14+ messages in thread
From: Matthew Garrett @ 2008-06-09 0:03 UTC (permalink / raw)
To: Lennart Poettering; +Cc: rpurdie, linux-kernel
On Sun, Jun 08, 2008 at 08:32:55PM +0200, Lennart Poettering wrote:
> It should be pretty easy to figure out the right string for
> DMI autoloading. Just do a cat /sys/class/dmi/id/modalias and replace the
> part of the string you consider not very useful for identifying the
> machine with (dates, version numbers, empty strings, 0123456
> rubbish data, ...) with an asterisk.
Ah! Spaces are removed in the sysfs interface. That would explain the
problem. I'll send a new version.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-08 18:32 ` [PATCH] " Lennart Poettering
2008-06-09 0:03 ` Matthew Garrett
@ 2008-06-09 0:05 ` Matthew Garrett
2008-06-09 20:59 ` Richard Purdie
1 sibling, 1 reply; 14+ messages in thread
From: Matthew Garrett @ 2008-06-09 0:05 UTC (permalink / raw)
To: Lennart Poettering; +Cc: rpurdie, linux-kernel
Nvidia-based Apple Macbook Pros don't appear to handle backlight control
through the graphics card registers or ACPI, but instead trigger changes
via SMI calls. This driver registers a generic backlight device that
lets existing userspace deal with it. Code derived from Julien Blache's
Pommed application.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
Fixed the DMI strings and changed the capitalisation of "MacBook" in the
Kconfig text.
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index dcd8073..56f4572 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -112,3 +112,11 @@ config BACKLIGHT_CARILLO_RANCH
help
If you have a Intel LE80578 (Carillo Ranch) say Y to enable the
backlight driver.
+
+config BACKLIGHT_MBP_NVIDIA
+ tristate "MacBook Pro Nvidia Backlight Driver"
+ depends on BACKLIGHT_CLASS_DEVICE && X86
+ default n
+ help
+ If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
+ to enable a driver for its backlight
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 33f6c7c..5b91515 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
+obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
new file mode 100644
index 0000000..ebe6be5
--- /dev/null
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -0,0 +1,116 @@
+/*
+ * Backlight Driver for Nvidia 8600 in Macbook Pro
+ *
+ * Copyright (c) Red Hat <mjg@redhat.com>
+ * Based on code from Pommed:
+ * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch>
+ * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org>
+ * Copyright (C) 2007 Julien BLACHE <jb@jblache.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This driver triggers SMIs which cause the firmware to change the
+ * backlight brightness. This is icky in many ways, but it's impractical to
+ * get at the firmware code in order to figure out what it's actually doing.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/dmi.h>
+#include <linux/io.h>
+
+static struct backlight_device *mbp_backlight_device;
+
+static struct dmi_system_id __initdata mbp_device_table[] = {
+ {
+ .ident = "3,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"),
+ },
+ },
+ {
+ .ident = "3,2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"),
+ },
+ },
+ {
+ .ident = "4,1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"),
+ },
+ },
+ { }
+};
+
+static int mbp_send_intensity(struct backlight_device *bd)
+{
+ int intensity = bd->props.brightness;
+
+ outb(0x04 | (intensity << 4), 0xb3);
+ outb(0xbf, 0xb2);
+
+ return 0;
+}
+
+static int mbp_get_intensity(struct backlight_device *bd)
+{
+ outb(0x03, 0xb3);
+ outb(0xbf, 0xb2);
+ return inb(0xb3) >> 4;
+}
+
+static struct backlight_ops mbp_ops = {
+ .get_brightness = mbp_get_intensity,
+ .update_status = mbp_send_intensity,
+};
+
+static int __init mbp_init(void)
+{
+ if (!dmi_check_system(mbp_device_table))
+ return -ENODEV;
+
+ if (!request_region(0xb2, 2, "Macbook Pro backlight"))
+ return -ENXIO;
+
+ mbp_backlight_device = backlight_device_register("mbp_backlight",
+ NULL, NULL,
+ &mbp_ops);
+ if (IS_ERR(mbp_backlight_device)) {
+ release_region(0xb2, 2);
+ return PTR_ERR(mbp_backlight_device);
+ }
+
+ mbp_backlight_device->props.max_brightness = 15;
+ mbp_backlight_device->props.brightness =
+ mbp_get_intensity(mbp_backlight_device);
+ backlight_update_status(mbp_backlight_device);
+
+ return 0;
+}
+
+static void __exit mbp_exit(void)
+{
+ backlight_device_unregister(mbp_backlight_device);
+
+ release_region(0xb2, 2);
+}
+
+module_init(mbp_init);
+module_exit(mbp_exit);
+
+MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
+MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,1");
+MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,2");
+MODULE_ALIAS("svnAppleInc.:pnMacBookPro4,1");
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2] Add backlight driver for Nvidia-based Apple Macbook Pros
2008-06-09 0:05 ` [PATCH v2] " Matthew Garrett
@ 2008-06-09 20:59 ` Richard Purdie
0 siblings, 0 replies; 14+ messages in thread
From: Richard Purdie @ 2008-06-09 20:59 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Lennart Poettering, linux-kernel
On Mon, 2008-06-09 at 01:05 +0100, Matthew Garrett wrote:
> Nvidia-based Apple Macbook Pros don't appear to handle backlight control
> through the graphics card registers or ACPI, but instead trigger changes
> via SMI calls. This driver registers a generic backlight device that
> lets existing userspace deal with it. Code derived from Julien Blache's
> Pommed application.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Queued in the backlight tree, thanks.
Richard
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-06-09 21:24 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-07 2:54 [PATCH] Add backlight driver for Nvidia-based Apple Macbook Pros Matthew Garrett
2008-06-07 5:04 ` Andrey Panin
2008-06-07 6:07 ` Andrew Morton
2008-06-07 9:58 ` Matthew Garrett
2008-06-07 10:05 ` Pekka Enberg
2008-06-07 10:14 ` Matthew Garrett
2008-06-07 10:50 ` Pekka Enberg
2008-06-07 18:59 ` Andrew Morton
2008-06-07 10:01 ` [PATCH v2] " Matthew Garrett
2008-06-07 14:45 ` Julien BLACHE
2008-06-08 18:32 ` [PATCH] " Lennart Poettering
2008-06-09 0:03 ` Matthew Garrett
2008-06-09 0:05 ` [PATCH v2] " Matthew Garrett
2008-06-09 20:59 ` Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox