diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 15:16:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 15:16:40 -0400 |
commit | ac9f80ad16e6e934b6c1f12f82d27889c0f9abcc (patch) | |
tree | 5739a96e5e71e9863e332085e4368d0b99501bdb /drivers/video/backlight | |
parent | c54554d388369f7f88ddcbe285ca96f7fb8a2d4b (diff) | |
parent | f6ec2d96796d0accda6c325890206f3629130729 (diff) |
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight:
backlight: Fix missing kernel doc entry
backlight: Add Nvidia-based Apple Macbook Pro backlight driver
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r-- | drivers/video/backlight/Kconfig | 9 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 2 | ||||
-rw-r--r-- | drivers/video/backlight/backlight.c | 1 | ||||
-rw-r--r-- | drivers/video/backlight/mbp_nvidia_bl.c | 116 |
4 files changed, 128 insertions, 0 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 98d9faf4970d..452b770d8cc9 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -155,3 +155,12 @@ config BACKLIGHT_PWM | |||
155 | help | 155 | help |
156 | If you have a LCD backlight adjustable by PWM, say Y to enable | 156 | If you have a LCD backlight adjustable by PWM, say Y to enable |
157 | this driver. | 157 | this driver. |
158 | |||
159 | config BACKLIGHT_MBP_NVIDIA | ||
160 | tristate "MacBook Pro Nvidia Backlight Driver" | ||
161 | depends on BACKLIGHT_CLASS_DEVICE && X86 | ||
162 | default n | ||
163 | help | ||
164 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y | ||
165 | to enable a driver for its backlight | ||
166 | |||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index d8a08e468cc7..b405aace803f 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -15,3 +15,5 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | |||
15 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o | 15 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o |
16 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o | 16 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o |
17 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 17 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
18 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | ||
19 | |||
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 39394757679c..fab0bc874b58 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -191,6 +191,7 @@ static struct device_attribute bl_device_attributes[] = { | |||
191 | * backlight_device class. | 191 | * backlight_device class. |
192 | * @name: the name of the new object(must be the same as the name of the | 192 | * @name: the name of the new object(must be the same as the name of the |
193 | * respective framebuffer device). | 193 | * respective framebuffer device). |
194 | * @parent: a pointer to the parent device | ||
194 | * @devdata: an optional pointer to be stored for private driver use. The | 195 | * @devdata: an optional pointer to be stored for private driver use. The |
195 | * methods may retrieve it by using bl_get_data(bd). | 196 | * methods may retrieve it by using bl_get_data(bd). |
196 | * @ops: the backlight operations structure. | 197 | * @ops: the backlight operations structure. |
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c new file mode 100644 index 000000000000..385cba40ea87 --- /dev/null +++ b/drivers/video/backlight/mbp_nvidia_bl.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Backlight Driver for Nvidia 8600 in Macbook Pro | ||
3 | * | ||
4 | * Copyright (c) Red Hat <mjg@redhat.com> | ||
5 | * Based on code from Pommed: | ||
6 | * Copyright (C) 2006 Nicolas Boichat <nicolas @boichat.ch> | ||
7 | * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro @linuxmail.org> | ||
8 | * Copyright (C) 2007 Julien BLACHE <jb@jblache.org> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This driver triggers SMIs which cause the firmware to change the | ||
15 | * backlight brightness. This is icky in many ways, but it's impractical to | ||
16 | * get at the firmware code in order to figure out what it's actually doing. | ||
17 | */ | ||
18 | |||
19 | #include <linux/module.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/backlight.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/dmi.h> | ||
26 | #include <linux/io.h> | ||
27 | |||
28 | static struct backlight_device *mbp_backlight_device; | ||
29 | |||
30 | static struct dmi_system_id __initdata mbp_device_table[] = { | ||
31 | { | ||
32 | .ident = "3,1", | ||
33 | .matches = { | ||
34 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
35 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,1"), | ||
36 | }, | ||
37 | }, | ||
38 | { | ||
39 | .ident = "3,2", | ||
40 | .matches = { | ||
41 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
42 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3,2"), | ||
43 | }, | ||
44 | }, | ||
45 | { | ||
46 | .ident = "4,1", | ||
47 | .matches = { | ||
48 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
49 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro4,1"), | ||
50 | }, | ||
51 | }, | ||
52 | { } | ||
53 | }; | ||
54 | |||
55 | static int mbp_send_intensity(struct backlight_device *bd) | ||
56 | { | ||
57 | int intensity = bd->props.brightness; | ||
58 | |||
59 | outb(0x04 | (intensity << 4), 0xb3); | ||
60 | outb(0xbf, 0xb2); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int mbp_get_intensity(struct backlight_device *bd) | ||
66 | { | ||
67 | outb(0x03, 0xb3); | ||
68 | outb(0xbf, 0xb2); | ||
69 | return inb(0xb3) >> 4; | ||
70 | } | ||
71 | |||
72 | static struct backlight_ops mbp_ops = { | ||
73 | .get_brightness = mbp_get_intensity, | ||
74 | .update_status = mbp_send_intensity, | ||
75 | }; | ||
76 | |||
77 | static int __init mbp_init(void) | ||
78 | { | ||
79 | if (!dmi_check_system(mbp_device_table)) | ||
80 | return -ENODEV; | ||
81 | |||
82 | if (!request_region(0xb2, 2, "Macbook Pro backlight")) | ||
83 | return -ENXIO; | ||
84 | |||
85 | mbp_backlight_device = backlight_device_register("mbp_backlight", | ||
86 | NULL, NULL, | ||
87 | &mbp_ops); | ||
88 | if (IS_ERR(mbp_backlight_device)) { | ||
89 | release_region(0xb2, 2); | ||
90 | return PTR_ERR(mbp_backlight_device); | ||
91 | } | ||
92 | |||
93 | mbp_backlight_device->props.max_brightness = 15; | ||
94 | mbp_backlight_device->props.brightness = | ||
95 | mbp_get_intensity(mbp_backlight_device); | ||
96 | backlight_update_status(mbp_backlight_device); | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static void __exit mbp_exit(void) | ||
102 | { | ||
103 | backlight_device_unregister(mbp_backlight_device); | ||
104 | |||
105 | release_region(0xb2, 2); | ||
106 | } | ||
107 | |||
108 | module_init(mbp_init); | ||
109 | module_exit(mbp_exit); | ||
110 | |||
111 | MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); | ||
112 | MODULE_DESCRIPTION("Nvidia-based Macbook Pro Backlight Driver"); | ||
113 | MODULE_LICENSE("GPL"); | ||
114 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,1"); | ||
115 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro3,2"); | ||
116 | MODULE_ALIAS("svnAppleInc.:pnMacBookPro4,1"); | ||