diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-16 17:52:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-16 17:52:12 -0400 |
commit | 4314652bb41df08ad65bd25176ba1dfd24b14a51 (patch) | |
tree | 1632ae5936422bb36f2c43948bf079b7ca17e76f /drivers/misc | |
parent | d442cc44c0db56e84ef6aa244a88427d2efe06cd (diff) | |
parent | 01a5bba576b9364b33f61f0cd9fa70c2cf5535e2 (diff) |
Merge branch 'release-2.6.27' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-acpi-merge-2.6
* 'release-2.6.27' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-acpi-merge-2.6: (87 commits)
Fix FADT parsing
Add the ability to reset the machine using the RESET_REG in ACPI's FADT table.
ACPI: use dev_printk when possible
PNPACPI: add support for HP vendor-specific CCSR descriptors
PNP: avoid legacy IDE IRQs
PNP: convert resource options to single linked list
ISAPNP: handle independent options following dependent ones
PNP: remove extra 0x100 bit from option priority
PNP: support optional IRQ resources
PNP: rename pnp_register_*_resource() local variables
PNPACPI: ignore _PRS interrupt numbers larger than PNP_IRQ_NR
PNP: centralize resource option allocations
PNP: remove redundant pnp_can_configure() check
PNP: make resource assignment functions return 0 (success) or -EBUSY (failure)
PNP: in debug resource dump, make empty list obvious
PNP: improve resource assignment debug
PNP: increase I/O port & memory option address sizes
PNP: introduce pnp_irq_mask_t typedef
PNP: make resource option structures private to PNP subsystem
PNP: define PNP-specific IORESOURCE_IO_* flags alongside IRQ, DMA, MEM
...
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/Kconfig | 31 | ||||
-rw-r--r-- | drivers/misc/Makefile | 5 | ||||
-rw-r--r-- | drivers/misc/acer-wmi.c | 145 | ||||
-rw-r--r-- | drivers/misc/compal-laptop.c | 404 | ||||
-rw-r--r-- | drivers/misc/eeepc-laptop.c | 4 | ||||
-rw-r--r-- | drivers/misc/fujitsu-laptop.c | 825 |
6 files changed, 1348 insertions, 66 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 636af2862308..1921b8dbb242 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -179,17 +179,29 @@ config FUJITSU_LAPTOP | |||
179 | tristate "Fujitsu Laptop Extras" | 179 | tristate "Fujitsu Laptop Extras" |
180 | depends on X86 | 180 | depends on X86 |
181 | depends on ACPI | 181 | depends on ACPI |
182 | depends on INPUT | ||
182 | depends on BACKLIGHT_CLASS_DEVICE | 183 | depends on BACKLIGHT_CLASS_DEVICE |
183 | ---help--- | 184 | ---help--- |
184 | This is a driver for laptops built by Fujitsu: | 185 | This is a driver for laptops built by Fujitsu: |
185 | 186 | ||
186 | * P2xxx/P5xxx/S6xxx/S7xxx series Lifebooks | 187 | * P2xxx/P5xxx/S6xxx/S7xxx series Lifebooks |
187 | * Possibly other Fujitsu laptop models | 188 | * Possibly other Fujitsu laptop models |
189 | * Tested with S6410 and S7020 | ||
188 | 190 | ||
189 | It adds support for LCD brightness control. | 191 | It adds support for LCD brightness control and some hotkeys. |
190 | 192 | ||
191 | If you have a Fujitsu laptop, say Y or M here. | 193 | If you have a Fujitsu laptop, say Y or M here. |
192 | 194 | ||
195 | config FUJITSU_LAPTOP_DEBUG | ||
196 | bool "Verbose debug mode for Fujitsu Laptop Extras" | ||
197 | depends on FUJITSU_LAPTOP | ||
198 | default n | ||
199 | ---help--- | ||
200 | Enables extra debug output from the fujitsu extras driver, at the | ||
201 | expense of a slight increase in driver size. | ||
202 | |||
203 | If you are not sure, say N here. | ||
204 | |||
193 | config TC1100_WMI | 205 | config TC1100_WMI |
194 | tristate "HP Compaq TC1100 Tablet WMI Extras (EXPERIMENTAL)" | 206 | tristate "HP Compaq TC1100 Tablet WMI Extras (EXPERIMENTAL)" |
195 | depends on X86 && !X86_64 | 207 | depends on X86 && !X86_64 |
@@ -219,6 +231,23 @@ config MSI_LAPTOP | |||
219 | 231 | ||
220 | If you have an MSI S270 laptop, say Y or M here. | 232 | If you have an MSI S270 laptop, say Y or M here. |
221 | 233 | ||
234 | config COMPAL_LAPTOP | ||
235 | tristate "Compal Laptop Extras" | ||
236 | depends on X86 | ||
237 | depends on ACPI_EC | ||
238 | depends on BACKLIGHT_CLASS_DEVICE | ||
239 | ---help--- | ||
240 | This is a driver for laptops built by Compal: | ||
241 | |||
242 | Compal FL90/IFL90 | ||
243 | Compal FL91/IFL91 | ||
244 | Compal FL92/JFL92 | ||
245 | Compal FT00/IFT00 | ||
246 | |||
247 | It adds support for Bluetooth, WLAN and LCD brightness control. | ||
248 | |||
249 | If you have an Compal FL9x/IFL9x/FT00 laptop, say Y or M here. | ||
250 | |||
222 | config SONY_LAPTOP | 251 | config SONY_LAPTOP |
223 | tristate "Sony Laptop Extras" | 252 | tristate "Sony Laptop Extras" |
224 | depends on X86 && ACPI | 253 | depends on X86 && ACPI |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 1952875a272e..a6dac6a2e7e5 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -5,10 +5,11 @@ obj- := misc.o # Dummy rule to force built-in.o to be made | |||
5 | 5 | ||
6 | obj-$(CONFIG_IBM_ASM) += ibmasm/ | 6 | obj-$(CONFIG_IBM_ASM) += ibmasm/ |
7 | obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ | 7 | obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ |
8 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o | ||
9 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o | ||
10 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o | 8 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o |
11 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o | 9 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o |
10 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o | ||
11 | obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o | ||
12 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o | ||
12 | obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o | 13 | obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o |
13 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o | 14 | obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o |
14 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o | 15 | obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o |
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c index dd13a3749927..e7a3fe508dff 100644 --- a/drivers/misc/acer-wmi.c +++ b/drivers/misc/acer-wmi.c | |||
@@ -22,18 +22,18 @@ | |||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define ACER_WMI_VERSION "0.1" | ||
26 | |||
27 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
28 | #include <linux/module.h> | 26 | #include <linux/module.h> |
29 | #include <linux/init.h> | 27 | #include <linux/init.h> |
30 | #include <linux/types.h> | 28 | #include <linux/types.h> |
31 | #include <linux/dmi.h> | 29 | #include <linux/dmi.h> |
30 | #include <linux/fb.h> | ||
32 | #include <linux/backlight.h> | 31 | #include <linux/backlight.h> |
33 | #include <linux/leds.h> | 32 | #include <linux/leds.h> |
34 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
35 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
36 | #include <linux/i8042.h> | 35 | #include <linux/i8042.h> |
36 | #include <linux/debugfs.h> | ||
37 | 37 | ||
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | 39 | ||
@@ -87,6 +87,7 @@ struct acer_quirks { | |||
87 | * Acer ACPI method GUIDs | 87 | * Acer ACPI method GUIDs |
88 | */ | 88 | */ |
89 | #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB" | 89 | #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB" |
90 | #define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C" | ||
90 | #define WMID_GUID1 "6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3" | 91 | #define WMID_GUID1 "6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3" |
91 | #define WMID_GUID2 "95764E09-FB56-4e83-B31A-37761F60994A" | 92 | #define WMID_GUID2 "95764E09-FB56-4e83-B31A-37761F60994A" |
92 | 93 | ||
@@ -150,6 +151,12 @@ struct acer_data { | |||
150 | int brightness; | 151 | int brightness; |
151 | }; | 152 | }; |
152 | 153 | ||
154 | struct acer_debug { | ||
155 | struct dentry *root; | ||
156 | struct dentry *devices; | ||
157 | u32 wmid_devices; | ||
158 | }; | ||
159 | |||
153 | /* Each low-level interface must define at least some of the following */ | 160 | /* Each low-level interface must define at least some of the following */ |
154 | struct wmi_interface { | 161 | struct wmi_interface { |
155 | /* The WMI device type */ | 162 | /* The WMI device type */ |
@@ -160,6 +167,9 @@ struct wmi_interface { | |||
160 | 167 | ||
161 | /* Private data for the current interface */ | 168 | /* Private data for the current interface */ |
162 | struct acer_data data; | 169 | struct acer_data data; |
170 | |||
171 | /* debugfs entries associated with this interface */ | ||
172 | struct acer_debug debug; | ||
163 | }; | 173 | }; |
164 | 174 | ||
165 | /* The static interface pointer, points to the currently detected interface */ | 175 | /* The static interface pointer, points to the currently detected interface */ |
@@ -174,7 +184,7 @@ static struct wmi_interface *interface; | |||
174 | struct quirk_entry { | 184 | struct quirk_entry { |
175 | u8 wireless; | 185 | u8 wireless; |
176 | u8 mailled; | 186 | u8 mailled; |
177 | u8 brightness; | 187 | s8 brightness; |
178 | u8 bluetooth; | 188 | u8 bluetooth; |
179 | }; | 189 | }; |
180 | 190 | ||
@@ -198,6 +208,10 @@ static int dmi_matched(const struct dmi_system_id *dmi) | |||
198 | static struct quirk_entry quirk_unknown = { | 208 | static struct quirk_entry quirk_unknown = { |
199 | }; | 209 | }; |
200 | 210 | ||
211 | static struct quirk_entry quirk_acer_aspire_1520 = { | ||
212 | .brightness = -1, | ||
213 | }; | ||
214 | |||
201 | static struct quirk_entry quirk_acer_travelmate_2490 = { | 215 | static struct quirk_entry quirk_acer_travelmate_2490 = { |
202 | .mailled = 1, | 216 | .mailled = 1, |
203 | }; | 217 | }; |
@@ -207,9 +221,31 @@ static struct quirk_entry quirk_medion_md_98300 = { | |||
207 | .wireless = 1, | 221 | .wireless = 1, |
208 | }; | 222 | }; |
209 | 223 | ||
224 | static struct quirk_entry quirk_fujitsu_amilo_li_1718 = { | ||
225 | .wireless = 2, | ||
226 | }; | ||
227 | |||
210 | static struct dmi_system_id acer_quirks[] = { | 228 | static struct dmi_system_id acer_quirks[] = { |
211 | { | 229 | { |
212 | .callback = dmi_matched, | 230 | .callback = dmi_matched, |
231 | .ident = "Acer Aspire 1360", | ||
232 | .matches = { | ||
233 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
234 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"), | ||
235 | }, | ||
236 | .driver_data = &quirk_acer_aspire_1520, | ||
237 | }, | ||
238 | { | ||
239 | .callback = dmi_matched, | ||
240 | .ident = "Acer Aspire 1520", | ||
241 | .matches = { | ||
242 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
243 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1520"), | ||
244 | }, | ||
245 | .driver_data = &quirk_acer_aspire_1520, | ||
246 | }, | ||
247 | { | ||
248 | .callback = dmi_matched, | ||
213 | .ident = "Acer Aspire 3100", | 249 | .ident = "Acer Aspire 3100", |
214 | .matches = { | 250 | .matches = { |
215 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | 251 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
@@ -300,6 +336,15 @@ static struct dmi_system_id acer_quirks[] = { | |||
300 | }, | 336 | }, |
301 | { | 337 | { |
302 | .callback = dmi_matched, | 338 | .callback = dmi_matched, |
339 | .ident = "Fujitsu Siemens Amilo Li 1718", | ||
340 | .matches = { | ||
341 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
342 | DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Li 1718"), | ||
343 | }, | ||
344 | .driver_data = &quirk_fujitsu_amilo_li_1718, | ||
345 | }, | ||
346 | { | ||
347 | .callback = dmi_matched, | ||
303 | .ident = "Medion MD 98300", | 348 | .ident = "Medion MD 98300", |
304 | .matches = { | 349 | .matches = { |
305 | DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), | 350 | DMI_MATCH(DMI_SYS_VENDOR, "MEDION"), |
@@ -393,6 +438,12 @@ struct wmi_interface *iface) | |||
393 | return AE_ERROR; | 438 | return AE_ERROR; |
394 | *value = result & 0x1; | 439 | *value = result & 0x1; |
395 | return AE_OK; | 440 | return AE_OK; |
441 | case 2: | ||
442 | err = ec_read(0x71, &result); | ||
443 | if (err) | ||
444 | return AE_ERROR; | ||
445 | *value = result & 0x1; | ||
446 | return AE_OK; | ||
396 | default: | 447 | default: |
397 | err = ec_read(0xA, &result); | 448 | err = ec_read(0xA, &result); |
398 | if (err) | 449 | if (err) |
@@ -506,6 +557,15 @@ static acpi_status AMW0_set_capabilities(void) | |||
506 | struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; | 557 | struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; |
507 | union acpi_object *obj; | 558 | union acpi_object *obj; |
508 | 559 | ||
560 | /* | ||
561 | * On laptops with this strange GUID (non Acer), normal probing doesn't | ||
562 | * work. | ||
563 | */ | ||
564 | if (wmi_has_guid(AMW0_GUID2)) { | ||
565 | interface->capability |= ACER_CAP_WIRELESS; | ||
566 | return AE_OK; | ||
567 | } | ||
568 | |||
509 | args.eax = ACER_AMW0_WRITE; | 569 | args.eax = ACER_AMW0_WRITE; |
510 | args.ecx = args.edx = 0; | 570 | args.ecx = args.edx = 0; |
511 | 571 | ||
@@ -552,7 +612,8 @@ static acpi_status AMW0_set_capabilities(void) | |||
552 | * appear to use the same EC register for brightness, even if they | 612 | * appear to use the same EC register for brightness, even if they |
553 | * differ for wireless, etc | 613 | * differ for wireless, etc |
554 | */ | 614 | */ |
555 | interface->capability |= ACER_CAP_BRIGHTNESS; | 615 | if (quirks->brightness >= 0) |
616 | interface->capability |= ACER_CAP_BRIGHTNESS; | ||
556 | 617 | ||
557 | return AE_OK; | 618 | return AE_OK; |
558 | } | 619 | } |
@@ -807,7 +868,15 @@ static int read_brightness(struct backlight_device *bd) | |||
807 | 868 | ||
808 | static int update_bl_status(struct backlight_device *bd) | 869 | static int update_bl_status(struct backlight_device *bd) |
809 | { | 870 | { |
810 | set_u32(bd->props.brightness, ACER_CAP_BRIGHTNESS); | 871 | int intensity = bd->props.brightness; |
872 | |||
873 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
874 | intensity = 0; | ||
875 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
876 | intensity = 0; | ||
877 | |||
878 | set_u32(intensity, ACER_CAP_BRIGHTNESS); | ||
879 | |||
811 | return 0; | 880 | return 0; |
812 | } | 881 | } |
813 | 882 | ||
@@ -829,8 +898,9 @@ static int __devinit acer_backlight_init(struct device *dev) | |||
829 | 898 | ||
830 | acer_backlight_device = bd; | 899 | acer_backlight_device = bd; |
831 | 900 | ||
901 | bd->props.power = FB_BLANK_UNBLANK; | ||
902 | bd->props.brightness = max_brightness; | ||
832 | bd->props.max_brightness = max_brightness; | 903 | bd->props.max_brightness = max_brightness; |
833 | bd->props.brightness = read_brightness(NULL); | ||
834 | backlight_update_status(bd); | 904 | backlight_update_status(bd); |
835 | return 0; | 905 | return 0; |
836 | } | 906 | } |
@@ -894,6 +964,28 @@ static DEVICE_ATTR(interface, S_IWUGO | S_IRUGO | S_IWUSR, | |||
894 | show_interface, NULL); | 964 | show_interface, NULL); |
895 | 965 | ||
896 | /* | 966 | /* |
967 | * debugfs functions | ||
968 | */ | ||
969 | static u32 get_wmid_devices(void) | ||
970 | { | ||
971 | struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
972 | union acpi_object *obj; | ||
973 | acpi_status status; | ||
974 | |||
975 | status = wmi_query_block(WMID_GUID2, 1, &out); | ||
976 | if (ACPI_FAILURE(status)) | ||
977 | return 0; | ||
978 | |||
979 | obj = (union acpi_object *) out.pointer; | ||
980 | if (obj && obj->type == ACPI_TYPE_BUFFER && | ||
981 | obj->buffer.length == sizeof(u32)) { | ||
982 | return *((u32 *) obj->buffer.pointer); | ||
983 | } else { | ||
984 | return 0; | ||
985 | } | ||
986 | } | ||
987 | |||
988 | /* | ||
897 | * Platform device | 989 | * Platform device |
898 | */ | 990 | */ |
899 | static int __devinit acer_platform_probe(struct platform_device *device) | 991 | static int __devinit acer_platform_probe(struct platform_device *device) |
@@ -1052,12 +1144,40 @@ error_sysfs: | |||
1052 | return retval; | 1144 | return retval; |
1053 | } | 1145 | } |
1054 | 1146 | ||
1147 | static void remove_debugfs(void) | ||
1148 | { | ||
1149 | debugfs_remove(interface->debug.devices); | ||
1150 | debugfs_remove(interface->debug.root); | ||
1151 | } | ||
1152 | |||
1153 | static int create_debugfs(void) | ||
1154 | { | ||
1155 | interface->debug.root = debugfs_create_dir("acer-wmi", NULL); | ||
1156 | if (!interface->debug.root) { | ||
1157 | printk(ACER_ERR "Failed to create debugfs directory"); | ||
1158 | return -ENOMEM; | ||
1159 | } | ||
1160 | |||
1161 | interface->debug.devices = debugfs_create_u32("devices", S_IRUGO, | ||
1162 | interface->debug.root, | ||
1163 | &interface->debug.wmid_devices); | ||
1164 | if (!interface->debug.devices) | ||
1165 | goto error_debugfs; | ||
1166 | |||
1167 | return 0; | ||
1168 | |||
1169 | error_debugfs: | ||
1170 | remove_debugfs(); | ||
1171 | return -ENOMEM; | ||
1172 | } | ||
1173 | |||
1055 | static int __init acer_wmi_init(void) | 1174 | static int __init acer_wmi_init(void) |
1056 | { | 1175 | { |
1057 | int err; | 1176 | int err; |
1058 | 1177 | ||
1059 | printk(ACER_INFO "Acer Laptop ACPI-WMI Extras version %s\n", | 1178 | printk(ACER_INFO "Acer Laptop ACPI-WMI Extras\n"); |
1060 | ACER_WMI_VERSION); | 1179 | |
1180 | find_quirks(); | ||
1061 | 1181 | ||
1062 | /* | 1182 | /* |
1063 | * Detect which ACPI-WMI interface we're using. | 1183 | * Detect which ACPI-WMI interface we're using. |
@@ -1092,8 +1212,6 @@ static int __init acer_wmi_init(void) | |||
1092 | if (wmi_has_guid(AMW0_GUID1)) | 1212 | if (wmi_has_guid(AMW0_GUID1)) |
1093 | AMW0_find_mailled(); | 1213 | AMW0_find_mailled(); |
1094 | 1214 | ||
1095 | find_quirks(); | ||
1096 | |||
1097 | if (!interface) { | 1215 | if (!interface) { |
1098 | printk(ACER_ERR "No or unsupported WMI interface, unable to " | 1216 | printk(ACER_ERR "No or unsupported WMI interface, unable to " |
1099 | "load\n"); | 1217 | "load\n"); |
@@ -1111,6 +1229,13 @@ static int __init acer_wmi_init(void) | |||
1111 | if (err) | 1229 | if (err) |
1112 | return err; | 1230 | return err; |
1113 | 1231 | ||
1232 | if (wmi_has_guid(WMID_GUID2)) { | ||
1233 | interface->debug.wmid_devices = get_wmid_devices(); | ||
1234 | err = create_debugfs(); | ||
1235 | if (err) | ||
1236 | return err; | ||
1237 | } | ||
1238 | |||
1114 | /* Override any initial settings with values from the commandline */ | 1239 | /* Override any initial settings with values from the commandline */ |
1115 | acer_commandline_init(); | 1240 | acer_commandline_init(); |
1116 | 1241 | ||
diff --git a/drivers/misc/compal-laptop.c b/drivers/misc/compal-laptop.c new file mode 100644 index 000000000000..344b790a6253 --- /dev/null +++ b/drivers/misc/compal-laptop.c | |||
@@ -0,0 +1,404 @@ | |||
1 | /*-*-linux-c-*-*/ | ||
2 | |||
3 | /* | ||
4 | Copyright (C) 2008 Cezary Jackiewicz <cezary.jackiewicz (at) gmail.com> | ||
5 | |||
6 | based on MSI driver | ||
7 | |||
8 | Copyright (C) 2006 Lennart Poettering <mzxreary (at) 0pointer (dot) de> | ||
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 as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, but | ||
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
23 | 02110-1301, USA. | ||
24 | */ | ||
25 | |||
26 | /* | ||
27 | * comapl-laptop.c - Compal laptop support. | ||
28 | * | ||
29 | * This driver exports a few files in /sys/devices/platform/compal-laptop/: | ||
30 | * | ||
31 | * wlan - wlan subsystem state: contains 0 or 1 (rw) | ||
32 | * | ||
33 | * bluetooth - Bluetooth subsystem state: contains 0 or 1 (rw) | ||
34 | * | ||
35 | * raw - raw value taken from embedded controller register (ro) | ||
36 | * | ||
37 | * In addition to these platform device attributes the driver | ||
38 | * registers itself in the Linux backlight control subsystem and is | ||
39 | * available to userspace under /sys/class/backlight/compal-laptop/. | ||
40 | * | ||
41 | * This driver might work on other laptops produced by Compal. If you | ||
42 | * want to try it you can pass force=1 as argument to the module which | ||
43 | * will force it to load even when the DMI data doesn't identify the | ||
44 | * laptop as FL9x. | ||
45 | */ | ||
46 | |||
47 | #include <linux/module.h> | ||
48 | #include <linux/kernel.h> | ||
49 | #include <linux/init.h> | ||
50 | #include <linux/acpi.h> | ||
51 | #include <linux/dmi.h> | ||
52 | #include <linux/backlight.h> | ||
53 | #include <linux/platform_device.h> | ||
54 | #include <linux/autoconf.h> | ||
55 | |||
56 | #define COMPAL_DRIVER_VERSION "0.2.6" | ||
57 | |||
58 | #define COMPAL_LCD_LEVEL_MAX 8 | ||
59 | |||
60 | #define COMPAL_EC_COMMAND_WIRELESS 0xBB | ||
61 | #define COMPAL_EC_COMMAND_LCD_LEVEL 0xB9 | ||
62 | |||
63 | #define KILLSWITCH_MASK 0x10 | ||
64 | #define WLAN_MASK 0x01 | ||
65 | #define BT_MASK 0x02 | ||
66 | |||
67 | static int force; | ||
68 | module_param(force, bool, 0); | ||
69 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); | ||
70 | |||
71 | /* Hardware access */ | ||
72 | |||
73 | static int set_lcd_level(int level) | ||
74 | { | ||
75 | if (level < 0 || level >= COMPAL_LCD_LEVEL_MAX) | ||
76 | return -EINVAL; | ||
77 | |||
78 | ec_write(COMPAL_EC_COMMAND_LCD_LEVEL, level); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static int get_lcd_level(void) | ||
84 | { | ||
85 | u8 result; | ||
86 | |||
87 | ec_read(COMPAL_EC_COMMAND_LCD_LEVEL, &result); | ||
88 | |||
89 | return (int) result; | ||
90 | } | ||
91 | |||
92 | static int set_wlan_state(int state) | ||
93 | { | ||
94 | u8 result, value; | ||
95 | |||
96 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | ||
97 | |||
98 | if ((result & KILLSWITCH_MASK) == 0) | ||
99 | return -EINVAL; | ||
100 | else { | ||
101 | if (state) | ||
102 | value = (u8) (result | WLAN_MASK); | ||
103 | else | ||
104 | value = (u8) (result & ~WLAN_MASK); | ||
105 | ec_write(COMPAL_EC_COMMAND_WIRELESS, value); | ||
106 | } | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static int set_bluetooth_state(int state) | ||
112 | { | ||
113 | u8 result, value; | ||
114 | |||
115 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | ||
116 | |||
117 | if ((result & KILLSWITCH_MASK) == 0) | ||
118 | return -EINVAL; | ||
119 | else { | ||
120 | if (state) | ||
121 | value = (u8) (result | BT_MASK); | ||
122 | else | ||
123 | value = (u8) (result & ~BT_MASK); | ||
124 | ec_write(COMPAL_EC_COMMAND_WIRELESS, value); | ||
125 | } | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static int get_wireless_state(int *wlan, int *bluetooth) | ||
131 | { | ||
132 | u8 result; | ||
133 | |||
134 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | ||
135 | |||
136 | if (wlan) { | ||
137 | if ((result & KILLSWITCH_MASK) == 0) | ||
138 | *wlan = 0; | ||
139 | else | ||
140 | *wlan = result & WLAN_MASK; | ||
141 | } | ||
142 | |||
143 | if (bluetooth) { | ||
144 | if ((result & KILLSWITCH_MASK) == 0) | ||
145 | *bluetooth = 0; | ||
146 | else | ||
147 | *bluetooth = (result & BT_MASK) >> 1; | ||
148 | } | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | /* Backlight device stuff */ | ||
154 | |||
155 | static int bl_get_brightness(struct backlight_device *b) | ||
156 | { | ||
157 | return get_lcd_level(); | ||
158 | } | ||
159 | |||
160 | |||
161 | static int bl_update_status(struct backlight_device *b) | ||
162 | { | ||
163 | return set_lcd_level(b->props.brightness); | ||
164 | } | ||
165 | |||
166 | static struct backlight_ops compalbl_ops = { | ||
167 | .get_brightness = bl_get_brightness, | ||
168 | .update_status = bl_update_status, | ||
169 | }; | ||
170 | |||
171 | static struct backlight_device *compalbl_device; | ||
172 | |||
173 | /* Platform device */ | ||
174 | |||
175 | static ssize_t show_wlan(struct device *dev, | ||
176 | struct device_attribute *attr, char *buf) | ||
177 | { | ||
178 | int ret, enabled; | ||
179 | |||
180 | ret = get_wireless_state(&enabled, NULL); | ||
181 | if (ret < 0) | ||
182 | return ret; | ||
183 | |||
184 | return sprintf(buf, "%i\n", enabled); | ||
185 | } | ||
186 | |||
187 | static ssize_t show_raw(struct device *dev, | ||
188 | struct device_attribute *attr, char *buf) | ||
189 | { | ||
190 | u8 result; | ||
191 | |||
192 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | ||
193 | |||
194 | return sprintf(buf, "%i\n", result); | ||
195 | } | ||
196 | |||
197 | static ssize_t show_bluetooth(struct device *dev, | ||
198 | struct device_attribute *attr, char *buf) | ||
199 | { | ||
200 | int ret, enabled; | ||
201 | |||
202 | ret = get_wireless_state(NULL, &enabled); | ||
203 | if (ret < 0) | ||
204 | return ret; | ||
205 | |||
206 | return sprintf(buf, "%i\n", enabled); | ||
207 | } | ||
208 | |||
209 | static ssize_t store_wlan_state(struct device *dev, | ||
210 | struct device_attribute *attr, const char *buf, size_t count) | ||
211 | { | ||
212 | int state, ret; | ||
213 | |||
214 | if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) | ||
215 | return -EINVAL; | ||
216 | |||
217 | ret = set_wlan_state(state); | ||
218 | if (ret < 0) | ||
219 | return ret; | ||
220 | |||
221 | return count; | ||
222 | } | ||
223 | |||
224 | static ssize_t store_bluetooth_state(struct device *dev, | ||
225 | struct device_attribute *attr, const char *buf, size_t count) | ||
226 | { | ||
227 | int state, ret; | ||
228 | |||
229 | if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) | ||
230 | return -EINVAL; | ||
231 | |||
232 | ret = set_bluetooth_state(state); | ||
233 | if (ret < 0) | ||
234 | return ret; | ||
235 | |||
236 | return count; | ||
237 | } | ||
238 | |||
239 | static DEVICE_ATTR(bluetooth, 0644, show_bluetooth, store_bluetooth_state); | ||
240 | static DEVICE_ATTR(wlan, 0644, show_wlan, store_wlan_state); | ||
241 | static DEVICE_ATTR(raw, 0444, show_raw, NULL); | ||
242 | |||
243 | static struct attribute *compal_attributes[] = { | ||
244 | &dev_attr_bluetooth.attr, | ||
245 | &dev_attr_wlan.attr, | ||
246 | &dev_attr_raw.attr, | ||
247 | NULL | ||
248 | }; | ||
249 | |||
250 | static struct attribute_group compal_attribute_group = { | ||
251 | .attrs = compal_attributes | ||
252 | }; | ||
253 | |||
254 | static struct platform_driver compal_driver = { | ||
255 | .driver = { | ||
256 | .name = "compal-laptop", | ||
257 | .owner = THIS_MODULE, | ||
258 | } | ||
259 | }; | ||
260 | |||
261 | static struct platform_device *compal_device; | ||
262 | |||
263 | /* Initialization */ | ||
264 | |||
265 | static int dmi_check_cb(const struct dmi_system_id *id) | ||
266 | { | ||
267 | printk(KERN_INFO "compal-laptop: Identified laptop model '%s'.\n", | ||
268 | id->ident); | ||
269 | |||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static struct dmi_system_id __initdata compal_dmi_table[] = { | ||
274 | { | ||
275 | .ident = "FL90/IFL90", | ||
276 | .matches = { | ||
277 | DMI_MATCH(DMI_BOARD_NAME, "IFL90"), | ||
278 | DMI_MATCH(DMI_BOARD_VERSION, "IFT00"), | ||
279 | }, | ||
280 | .callback = dmi_check_cb | ||
281 | }, | ||
282 | { | ||
283 | .ident = "FL90/IFL90", | ||
284 | .matches = { | ||
285 | DMI_MATCH(DMI_BOARD_NAME, "IFL90"), | ||
286 | DMI_MATCH(DMI_BOARD_VERSION, "REFERENCE"), | ||
287 | }, | ||
288 | .callback = dmi_check_cb | ||
289 | }, | ||
290 | { | ||
291 | .ident = "FL91/IFL91", | ||
292 | .matches = { | ||
293 | DMI_MATCH(DMI_BOARD_NAME, "IFL91"), | ||
294 | DMI_MATCH(DMI_BOARD_VERSION, "IFT00"), | ||
295 | }, | ||
296 | .callback = dmi_check_cb | ||
297 | }, | ||
298 | { | ||
299 | .ident = "FL92/JFL92", | ||
300 | .matches = { | ||
301 | DMI_MATCH(DMI_BOARD_NAME, "JFL92"), | ||
302 | DMI_MATCH(DMI_BOARD_VERSION, "IFT00"), | ||
303 | }, | ||
304 | .callback = dmi_check_cb | ||
305 | }, | ||
306 | { | ||
307 | .ident = "FT00/IFT00", | ||
308 | .matches = { | ||
309 | DMI_MATCH(DMI_BOARD_NAME, "IFT00"), | ||
310 | DMI_MATCH(DMI_BOARD_VERSION, "IFT00"), | ||
311 | }, | ||
312 | .callback = dmi_check_cb | ||
313 | }, | ||
314 | { } | ||
315 | }; | ||
316 | |||
317 | static int __init compal_init(void) | ||
318 | { | ||
319 | int ret; | ||
320 | |||
321 | if (acpi_disabled) | ||
322 | return -ENODEV; | ||
323 | |||
324 | if (!force && !dmi_check_system(compal_dmi_table)) | ||
325 | return -ENODEV; | ||
326 | |||
327 | /* Register backlight stuff */ | ||
328 | |||
329 | compalbl_device = backlight_device_register("compal-laptop", NULL, NULL, | ||
330 | &compalbl_ops); | ||
331 | if (IS_ERR(compalbl_device)) | ||
332 | return PTR_ERR(compalbl_device); | ||
333 | |||
334 | compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1; | ||
335 | |||
336 | ret = platform_driver_register(&compal_driver); | ||
337 | if (ret) | ||
338 | goto fail_backlight; | ||
339 | |||
340 | /* Register platform stuff */ | ||
341 | |||
342 | compal_device = platform_device_alloc("compal-laptop", -1); | ||
343 | if (!compal_device) { | ||
344 | ret = -ENOMEM; | ||
345 | goto fail_platform_driver; | ||
346 | } | ||
347 | |||
348 | ret = platform_device_add(compal_device); | ||
349 | if (ret) | ||
350 | goto fail_platform_device1; | ||
351 | |||
352 | ret = sysfs_create_group(&compal_device->dev.kobj, | ||
353 | &compal_attribute_group); | ||
354 | if (ret) | ||
355 | goto fail_platform_device2; | ||
356 | |||
357 | printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION | ||
358 | " successfully loaded.\n"); | ||
359 | |||
360 | return 0; | ||
361 | |||
362 | fail_platform_device2: | ||
363 | |||
364 | platform_device_del(compal_device); | ||
365 | |||
366 | fail_platform_device1: | ||
367 | |||
368 | platform_device_put(compal_device); | ||
369 | |||
370 | fail_platform_driver: | ||
371 | |||
372 | platform_driver_unregister(&compal_driver); | ||
373 | |||
374 | fail_backlight: | ||
375 | |||
376 | backlight_device_unregister(compalbl_device); | ||
377 | |||
378 | return ret; | ||
379 | } | ||
380 | |||
381 | static void __exit compal_cleanup(void) | ||
382 | { | ||
383 | |||
384 | sysfs_remove_group(&compal_device->dev.kobj, &compal_attribute_group); | ||
385 | platform_device_unregister(compal_device); | ||
386 | platform_driver_unregister(&compal_driver); | ||
387 | backlight_device_unregister(compalbl_device); | ||
388 | |||
389 | printk(KERN_INFO "compal-laptop: driver unloaded.\n"); | ||
390 | } | ||
391 | |||
392 | module_init(compal_init); | ||
393 | module_exit(compal_cleanup); | ||
394 | |||
395 | MODULE_AUTHOR("Cezary Jackiewicz"); | ||
396 | MODULE_DESCRIPTION("Compal Laptop Support"); | ||
397 | MODULE_VERSION(COMPAL_DRIVER_VERSION); | ||
398 | MODULE_LICENSE("GPL"); | ||
399 | |||
400 | MODULE_ALIAS("dmi:*:rnIFL90:rvrIFT00:*"); | ||
401 | MODULE_ALIAS("dmi:*:rnIFL90:rvrREFERENCE:*"); | ||
402 | MODULE_ALIAS("dmi:*:rnIFL91:rvrIFT00:*"); | ||
403 | MODULE_ALIAS("dmi:*:rnJFL92:rvrIFT00:*"); | ||
404 | MODULE_ALIAS("dmi:*:rnIFT00:rvrIFT00:*"); | ||
diff --git a/drivers/misc/eeepc-laptop.c b/drivers/misc/eeepc-laptop.c index 6d727609097f..9e8d79e7e9f4 100644 --- a/drivers/misc/eeepc-laptop.c +++ b/drivers/misc/eeepc-laptop.c | |||
@@ -87,7 +87,7 @@ enum { | |||
87 | CM_ASL_LID | 87 | CM_ASL_LID |
88 | }; | 88 | }; |
89 | 89 | ||
90 | const char *cm_getv[] = { | 90 | static const char *cm_getv[] = { |
91 | "WLDG", NULL, NULL, NULL, | 91 | "WLDG", NULL, NULL, NULL, |
92 | "CAMG", NULL, NULL, NULL, | 92 | "CAMG", NULL, NULL, NULL, |
93 | NULL, "PBLG", NULL, NULL, | 93 | NULL, "PBLG", NULL, NULL, |
@@ -96,7 +96,7 @@ const char *cm_getv[] = { | |||
96 | "CRDG", "LIDG" | 96 | "CRDG", "LIDG" |
97 | }; | 97 | }; |
98 | 98 | ||
99 | const char *cm_setv[] = { | 99 | static const char *cm_setv[] = { |
100 | "WLDS", NULL, NULL, NULL, | 100 | "WLDS", NULL, NULL, NULL, |
101 | "CAMS", NULL, NULL, NULL, | 101 | "CAMS", NULL, NULL, NULL, |
102 | "SDSP", "PBLS", "HDPS", NULL, | 102 | "SDSP", "PBLS", "HDPS", NULL, |
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c index 6d14e8fe1537..7a1ef6c262de 100644 --- a/drivers/misc/fujitsu-laptop.c +++ b/drivers/misc/fujitsu-laptop.c | |||
@@ -1,12 +1,14 @@ | |||
1 | /*-*-linux-c-*-*/ | 1 | /*-*-linux-c-*-*/ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | Copyright (C) 2007 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> | 4 | Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
5 | Copyright (C) 2008 Peter Gruber <nokos@gmx.net> | ||
5 | Based on earlier work: | 6 | Based on earlier work: |
6 | Copyright (C) 2003 Shane Spencer <shane@bogomip.com> | 7 | Copyright (C) 2003 Shane Spencer <shane@bogomip.com> |
7 | Adrian Yee <brewt-fujitsu@brewt.org> | 8 | Adrian Yee <brewt-fujitsu@brewt.org> |
8 | 9 | ||
9 | Templated from msi-laptop.c which is copyright by its respective authors. | 10 | Templated from msi-laptop.c and thinkpad_acpi.c which is copyright |
11 | by its respective authors. | ||
10 | 12 | ||
11 | This program is free software; you can redistribute it and/or modify | 13 | This program is free software; you can redistribute it and/or modify |
12 | it under the terms of the GNU General Public License as published by | 14 | it under the terms of the GNU General Public License as published by |
@@ -39,8 +41,17 @@ | |||
39 | * registers itself in the Linux backlight control subsystem and is | 41 | * registers itself in the Linux backlight control subsystem and is |
40 | * available to userspace under /sys/class/backlight/fujitsu-laptop/. | 42 | * available to userspace under /sys/class/backlight/fujitsu-laptop/. |
41 | * | 43 | * |
42 | * This driver has been tested on a Fujitsu Lifebook S7020. It should | 44 | * Hotkeys present on certain Fujitsu laptops (eg: the S6xxx series) are |
43 | * work on most P-series and S-series Lifebooks, but YMMV. | 45 | * also supported by this driver. |
46 | * | ||
47 | * This driver has been tested on a Fujitsu Lifebook S6410 and S7020. It | ||
48 | * should work on most P-series and S-series Lifebooks, but YMMV. | ||
49 | * | ||
50 | * The module parameter use_alt_lcd_levels switches between different ACPI | ||
51 | * brightness controls which are used by different Fujitsu laptops. In most | ||
52 | * cases the correct method is automatically detected. "use_alt_lcd_levels=1" | ||
53 | * is applicable for a Fujitsu Lifebook S6410 if autodetection fails. | ||
54 | * | ||
44 | */ | 55 | */ |
45 | 56 | ||
46 | #include <linux/module.h> | 57 | #include <linux/module.h> |
@@ -49,30 +60,105 @@ | |||
49 | #include <linux/acpi.h> | 60 | #include <linux/acpi.h> |
50 | #include <linux/dmi.h> | 61 | #include <linux/dmi.h> |
51 | #include <linux/backlight.h> | 62 | #include <linux/backlight.h> |
63 | #include <linux/input.h> | ||
64 | #include <linux/kfifo.h> | ||
65 | #include <linux/video_output.h> | ||
52 | #include <linux/platform_device.h> | 66 | #include <linux/platform_device.h> |
53 | 67 | ||
54 | #define FUJITSU_DRIVER_VERSION "0.3" | 68 | #define FUJITSU_DRIVER_VERSION "0.4.2" |
55 | 69 | ||
56 | #define FUJITSU_LCD_N_LEVELS 8 | 70 | #define FUJITSU_LCD_N_LEVELS 8 |
57 | 71 | ||
58 | #define ACPI_FUJITSU_CLASS "fujitsu" | 72 | #define ACPI_FUJITSU_CLASS "fujitsu" |
59 | #define ACPI_FUJITSU_HID "FUJ02B1" | 73 | #define ACPI_FUJITSU_HID "FUJ02B1" |
60 | #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI extras driver" | 74 | #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" |
61 | #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" | 75 | #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" |
62 | 76 | #define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3" | |
77 | #define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" | ||
78 | #define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3" | ||
79 | |||
80 | #define ACPI_FUJITSU_NOTIFY_CODE1 0x80 | ||
81 | |||
82 | #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 | ||
83 | #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 | ||
84 | |||
85 | /* Hotkey details */ | ||
86 | #define LOCK_KEY 0x410 /* codes for the keys in the GIRB register */ | ||
87 | #define DISPLAY_KEY 0x411 /* keys are mapped to KEY_SCREENLOCK (the key with the key symbol) */ | ||
88 | #define ENERGY_KEY 0x412 /* KEY_MEDIA (the key with the laptop symbol, KEY_EMAIL (E key)) */ | ||
89 | #define REST_KEY 0x413 /* KEY_SUSPEND (R key) */ | ||
90 | |||
91 | #define MAX_HOTKEY_RINGBUFFER_SIZE 100 | ||
92 | #define RINGBUFFERSIZE 40 | ||
93 | |||
94 | /* Debugging */ | ||
95 | #define FUJLAPTOP_LOG ACPI_FUJITSU_HID ": " | ||
96 | #define FUJLAPTOP_ERR KERN_ERR FUJLAPTOP_LOG | ||
97 | #define FUJLAPTOP_NOTICE KERN_NOTICE FUJLAPTOP_LOG | ||
98 | #define FUJLAPTOP_INFO KERN_INFO FUJLAPTOP_LOG | ||
99 | #define FUJLAPTOP_DEBUG KERN_DEBUG FUJLAPTOP_LOG | ||
100 | |||
101 | #define FUJLAPTOP_DBG_ALL 0xffff | ||
102 | #define FUJLAPTOP_DBG_ERROR 0x0001 | ||
103 | #define FUJLAPTOP_DBG_WARN 0x0002 | ||
104 | #define FUJLAPTOP_DBG_INFO 0x0004 | ||
105 | #define FUJLAPTOP_DBG_TRACE 0x0008 | ||
106 | |||
107 | #define dbg_printk(a_dbg_level, format, arg...) \ | ||
108 | do { if (dbg_level & a_dbg_level) \ | ||
109 | printk(FUJLAPTOP_DEBUG "%s: " format, __func__ , ## arg); \ | ||
110 | } while (0) | ||
111 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG | ||
112 | #define vdbg_printk(a_dbg_level, format, arg...) \ | ||
113 | dbg_printk(a_dbg_level, format, ## arg) | ||
114 | #else | ||
115 | #define vdbg_printk(a_dbg_level, format, arg...) | ||
116 | #endif | ||
117 | |||
118 | /* Device controlling the backlight and associated keys */ | ||
63 | struct fujitsu_t { | 119 | struct fujitsu_t { |
64 | acpi_handle acpi_handle; | 120 | acpi_handle acpi_handle; |
121 | struct acpi_device *dev; | ||
122 | struct input_dev *input; | ||
123 | char phys[32]; | ||
65 | struct backlight_device *bl_device; | 124 | struct backlight_device *bl_device; |
66 | struct platform_device *pf_device; | 125 | struct platform_device *pf_device; |
67 | 126 | ||
68 | unsigned long fuj02b1_state; | 127 | unsigned int max_brightness; |
69 | unsigned int brightness_changed; | 128 | unsigned int brightness_changed; |
70 | unsigned int brightness_level; | 129 | unsigned int brightness_level; |
71 | }; | 130 | }; |
72 | 131 | ||
73 | static struct fujitsu_t *fujitsu; | 132 | static struct fujitsu_t *fujitsu; |
133 | static int use_alt_lcd_levels = -1; | ||
134 | static int disable_brightness_keys = -1; | ||
135 | static int disable_brightness_adjust = -1; | ||
136 | |||
137 | /* Device used to access other hotkeys on the laptop */ | ||
138 | struct fujitsu_hotkey_t { | ||
139 | acpi_handle acpi_handle; | ||
140 | struct acpi_device *dev; | ||
141 | struct input_dev *input; | ||
142 | char phys[32]; | ||
143 | struct platform_device *pf_device; | ||
144 | struct kfifo *fifo; | ||
145 | spinlock_t fifo_lock; | ||
146 | |||
147 | unsigned int irb; /* info about the pressed buttons */ | ||
148 | }; | ||
74 | 149 | ||
75 | /* Hardware access */ | 150 | static struct fujitsu_hotkey_t *fujitsu_hotkey; |
151 | |||
152 | static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event, | ||
153 | void *data); | ||
154 | |||
155 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG | ||
156 | static u32 dbg_level = 0x03; | ||
157 | #endif | ||
158 | |||
159 | static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data); | ||
160 | |||
161 | /* Hardware access for LCD brightness control */ | ||
76 | 162 | ||
77 | static int set_lcd_level(int level) | 163 | static int set_lcd_level(int level) |
78 | { | 164 | { |
@@ -81,7 +167,10 @@ static int set_lcd_level(int level) | |||
81 | struct acpi_object_list arg_list = { 1, &arg0 }; | 167 | struct acpi_object_list arg_list = { 1, &arg0 }; |
82 | acpi_handle handle = NULL; | 168 | acpi_handle handle = NULL; |
83 | 169 | ||
84 | if (level < 0 || level >= FUJITSU_LCD_N_LEVELS) | 170 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", |
171 | level); | ||
172 | |||
173 | if (level < 0 || level >= fujitsu->max_brightness) | ||
85 | return -EINVAL; | 174 | return -EINVAL; |
86 | 175 | ||
87 | if (!fujitsu) | 176 | if (!fujitsu) |
@@ -89,7 +178,38 @@ static int set_lcd_level(int level) | |||
89 | 178 | ||
90 | status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); | 179 | status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); |
91 | if (ACPI_FAILURE(status)) { | 180 | if (ACPI_FAILURE(status)) { |
92 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "SBLL not present\n")); | 181 | vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); |
182 | return -ENODEV; | ||
183 | } | ||
184 | |||
185 | arg0.integer.value = level; | ||
186 | |||
187 | status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); | ||
188 | if (ACPI_FAILURE(status)) | ||
189 | return -ENODEV; | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int set_lcd_level_alt(int level) | ||
195 | { | ||
196 | acpi_status status = AE_OK; | ||
197 | union acpi_object arg0 = { ACPI_TYPE_INTEGER }; | ||
198 | struct acpi_object_list arg_list = { 1, &arg0 }; | ||
199 | acpi_handle handle = NULL; | ||
200 | |||
201 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", | ||
202 | level); | ||
203 | |||
204 | if (level < 0 || level >= fujitsu->max_brightness) | ||
205 | return -EINVAL; | ||
206 | |||
207 | if (!fujitsu) | ||
208 | return -EINVAL; | ||
209 | |||
210 | status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle); | ||
211 | if (ACPI_FAILURE(status)) { | ||
212 | vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); | ||
93 | return -ENODEV; | 213 | return -ENODEV; |
94 | } | 214 | } |
95 | 215 | ||
@@ -107,13 +227,52 @@ static int get_lcd_level(void) | |||
107 | unsigned long state = 0; | 227 | unsigned long state = 0; |
108 | acpi_status status = AE_OK; | 228 | acpi_status status = AE_OK; |
109 | 229 | ||
110 | // Get the Brightness | 230 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n"); |
231 | |||
111 | status = | 232 | status = |
112 | acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); | 233 | acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); |
113 | if (status < 0) | 234 | if (status < 0) |
114 | return status; | 235 | return status; |
115 | 236 | ||
116 | fujitsu->fuj02b1_state = state; | 237 | fujitsu->brightness_level = state & 0x0fffffff; |
238 | |||
239 | if (state & 0x80000000) | ||
240 | fujitsu->brightness_changed = 1; | ||
241 | else | ||
242 | fujitsu->brightness_changed = 0; | ||
243 | |||
244 | return fujitsu->brightness_level; | ||
245 | } | ||
246 | |||
247 | static int get_max_brightness(void) | ||
248 | { | ||
249 | unsigned long state = 0; | ||
250 | acpi_status status = AE_OK; | ||
251 | |||
252 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n"); | ||
253 | |||
254 | status = | ||
255 | acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state); | ||
256 | if (status < 0) | ||
257 | return status; | ||
258 | |||
259 | fujitsu->max_brightness = state; | ||
260 | |||
261 | return fujitsu->max_brightness; | ||
262 | } | ||
263 | |||
264 | static int get_lcd_level_alt(void) | ||
265 | { | ||
266 | unsigned long state = 0; | ||
267 | acpi_status status = AE_OK; | ||
268 | |||
269 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLS\n"); | ||
270 | |||
271 | status = | ||
272 | acpi_evaluate_integer(fujitsu->acpi_handle, "GBLS", NULL, &state); | ||
273 | if (status < 0) | ||
274 | return status; | ||
275 | |||
117 | fujitsu->brightness_level = state & 0x0fffffff; | 276 | fujitsu->brightness_level = state & 0x0fffffff; |
118 | 277 | ||
119 | if (state & 0x80000000) | 278 | if (state & 0x80000000) |
@@ -128,12 +287,18 @@ static int get_lcd_level(void) | |||
128 | 287 | ||
129 | static int bl_get_brightness(struct backlight_device *b) | 288 | static int bl_get_brightness(struct backlight_device *b) |
130 | { | 289 | { |
131 | return get_lcd_level(); | 290 | if (use_alt_lcd_levels) |
291 | return get_lcd_level_alt(); | ||
292 | else | ||
293 | return get_lcd_level(); | ||
132 | } | 294 | } |
133 | 295 | ||
134 | static int bl_update_status(struct backlight_device *b) | 296 | static int bl_update_status(struct backlight_device *b) |
135 | { | 297 | { |
136 | return set_lcd_level(b->props.brightness); | 298 | if (use_alt_lcd_levels) |
299 | return set_lcd_level_alt(b->props.brightness); | ||
300 | else | ||
301 | return set_lcd_level(b->props.brightness); | ||
137 | } | 302 | } |
138 | 303 | ||
139 | static struct backlight_ops fujitsubl_ops = { | 304 | static struct backlight_ops fujitsubl_ops = { |
@@ -141,7 +306,35 @@ static struct backlight_ops fujitsubl_ops = { | |||
141 | .update_status = bl_update_status, | 306 | .update_status = bl_update_status, |
142 | }; | 307 | }; |
143 | 308 | ||
144 | /* Platform device */ | 309 | /* Platform LCD brightness device */ |
310 | |||
311 | static ssize_t | ||
312 | show_max_brightness(struct device *dev, | ||
313 | struct device_attribute *attr, char *buf) | ||
314 | { | ||
315 | |||
316 | int ret; | ||
317 | |||
318 | ret = get_max_brightness(); | ||
319 | if (ret < 0) | ||
320 | return ret; | ||
321 | |||
322 | return sprintf(buf, "%i\n", ret); | ||
323 | } | ||
324 | |||
325 | static ssize_t | ||
326 | show_brightness_changed(struct device *dev, | ||
327 | struct device_attribute *attr, char *buf) | ||
328 | { | ||
329 | |||
330 | int ret; | ||
331 | |||
332 | ret = fujitsu->brightness_changed; | ||
333 | if (ret < 0) | ||
334 | return ret; | ||
335 | |||
336 | return sprintf(buf, "%i\n", ret); | ||
337 | } | ||
145 | 338 | ||
146 | static ssize_t show_lcd_level(struct device *dev, | 339 | static ssize_t show_lcd_level(struct device *dev, |
147 | struct device_attribute *attr, char *buf) | 340 | struct device_attribute *attr, char *buf) |
@@ -149,7 +342,10 @@ static ssize_t show_lcd_level(struct device *dev, | |||
149 | 342 | ||
150 | int ret; | 343 | int ret; |
151 | 344 | ||
152 | ret = get_lcd_level(); | 345 | if (use_alt_lcd_levels) |
346 | ret = get_lcd_level_alt(); | ||
347 | else | ||
348 | ret = get_lcd_level(); | ||
153 | if (ret < 0) | 349 | if (ret < 0) |
154 | return ret; | 350 | return ret; |
155 | 351 | ||
@@ -164,19 +360,61 @@ static ssize_t store_lcd_level(struct device *dev, | |||
164 | int level, ret; | 360 | int level, ret; |
165 | 361 | ||
166 | if (sscanf(buf, "%i", &level) != 1 | 362 | if (sscanf(buf, "%i", &level) != 1 |
167 | || (level < 0 || level >= FUJITSU_LCD_N_LEVELS)) | 363 | || (level < 0 || level >= fujitsu->max_brightness)) |
168 | return -EINVAL; | 364 | return -EINVAL; |
169 | 365 | ||
170 | ret = set_lcd_level(level); | 366 | if (use_alt_lcd_levels) |
367 | ret = set_lcd_level_alt(level); | ||
368 | else | ||
369 | ret = set_lcd_level(level); | ||
370 | if (ret < 0) | ||
371 | return ret; | ||
372 | |||
373 | if (use_alt_lcd_levels) | ||
374 | ret = get_lcd_level_alt(); | ||
375 | else | ||
376 | ret = get_lcd_level(); | ||
171 | if (ret < 0) | 377 | if (ret < 0) |
172 | return ret; | 378 | return ret; |
173 | 379 | ||
174 | return count; | 380 | return count; |
175 | } | 381 | } |
176 | 382 | ||
383 | /* Hardware access for hotkey device */ | ||
384 | |||
385 | static int get_irb(void) | ||
386 | { | ||
387 | unsigned long state = 0; | ||
388 | acpi_status status = AE_OK; | ||
389 | |||
390 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "Get irb\n"); | ||
391 | |||
392 | status = | ||
393 | acpi_evaluate_integer(fujitsu_hotkey->acpi_handle, "GIRB", NULL, | ||
394 | &state); | ||
395 | if (status < 0) | ||
396 | return status; | ||
397 | |||
398 | fujitsu_hotkey->irb = state; | ||
399 | |||
400 | return fujitsu_hotkey->irb; | ||
401 | } | ||
402 | |||
403 | static ssize_t | ||
404 | ignore_store(struct device *dev, | ||
405 | struct device_attribute *attr, const char *buf, size_t count) | ||
406 | { | ||
407 | return count; | ||
408 | } | ||
409 | |||
410 | static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store); | ||
411 | static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed, | ||
412 | ignore_store); | ||
177 | static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); | 413 | static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); |
178 | 414 | ||
179 | static struct attribute *fujitsupf_attributes[] = { | 415 | static struct attribute *fujitsupf_attributes[] = { |
416 | &dev_attr_brightness_changed.attr, | ||
417 | &dev_attr_max_brightness.attr, | ||
180 | &dev_attr_lcd_level.attr, | 418 | &dev_attr_lcd_level.attr, |
181 | NULL | 419 | NULL |
182 | }; | 420 | }; |
@@ -192,14 +430,52 @@ static struct platform_driver fujitsupf_driver = { | |||
192 | } | 430 | } |
193 | }; | 431 | }; |
194 | 432 | ||
195 | /* ACPI device */ | 433 | static int dmi_check_cb_s6410(const struct dmi_system_id *id) |
434 | { | ||
435 | acpi_handle handle; | ||
436 | int have_blnf; | ||
437 | printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n", | ||
438 | id->ident); | ||
439 | have_blnf = ACPI_SUCCESS | ||
440 | (acpi_get_handle(NULL, "\\_SB.PCI0.GFX0.LCD.BLNF", &handle)); | ||
441 | if (use_alt_lcd_levels == -1) { | ||
442 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detecting usealt\n"); | ||
443 | use_alt_lcd_levels = 1; | ||
444 | } | ||
445 | if (disable_brightness_keys == -1) { | ||
446 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | ||
447 | "auto-detecting disable_keys\n"); | ||
448 | disable_brightness_keys = have_blnf ? 1 : 0; | ||
449 | } | ||
450 | if (disable_brightness_adjust == -1) { | ||
451 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | ||
452 | "auto-detecting disable_adjust\n"); | ||
453 | disable_brightness_adjust = have_blnf ? 0 : 1; | ||
454 | } | ||
455 | return 0; | ||
456 | } | ||
457 | |||
458 | static struct dmi_system_id __initdata fujitsu_dmi_table[] = { | ||
459 | { | ||
460 | .ident = "Fujitsu Siemens", | ||
461 | .matches = { | ||
462 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
463 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"), | ||
464 | }, | ||
465 | .callback = dmi_check_cb_s6410}, | ||
466 | {} | ||
467 | }; | ||
468 | |||
469 | /* ACPI device for LCD brightness control */ | ||
196 | 470 | ||
197 | static int acpi_fujitsu_add(struct acpi_device *device) | 471 | static int acpi_fujitsu_add(struct acpi_device *device) |
198 | { | 472 | { |
473 | acpi_status status; | ||
474 | acpi_handle handle; | ||
199 | int result = 0; | 475 | int result = 0; |
200 | int state = 0; | 476 | int state = 0; |
201 | 477 | struct input_dev *input; | |
202 | ACPI_FUNCTION_TRACE("acpi_fujitsu_add"); | 478 | int error; |
203 | 479 | ||
204 | if (!device) | 480 | if (!device) |
205 | return -EINVAL; | 481 | return -EINVAL; |
@@ -209,10 +485,42 @@ static int acpi_fujitsu_add(struct acpi_device *device) | |||
209 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); | 485 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); |
210 | acpi_driver_data(device) = fujitsu; | 486 | acpi_driver_data(device) = fujitsu; |
211 | 487 | ||
488 | status = acpi_install_notify_handler(device->handle, | ||
489 | ACPI_DEVICE_NOTIFY, | ||
490 | acpi_fujitsu_notify, fujitsu); | ||
491 | |||
492 | if (ACPI_FAILURE(status)) { | ||
493 | printk(KERN_ERR "Error installing notify handler\n"); | ||
494 | error = -ENODEV; | ||
495 | goto err_stop; | ||
496 | } | ||
497 | |||
498 | fujitsu->input = input = input_allocate_device(); | ||
499 | if (!input) { | ||
500 | error = -ENOMEM; | ||
501 | goto err_uninstall_notify; | ||
502 | } | ||
503 | |||
504 | snprintf(fujitsu->phys, sizeof(fujitsu->phys), | ||
505 | "%s/video/input0", acpi_device_hid(device)); | ||
506 | |||
507 | input->name = acpi_device_name(device); | ||
508 | input->phys = fujitsu->phys; | ||
509 | input->id.bustype = BUS_HOST; | ||
510 | input->id.product = 0x06; | ||
511 | input->dev.parent = &device->dev; | ||
512 | input->evbit[0] = BIT(EV_KEY); | ||
513 | set_bit(KEY_BRIGHTNESSUP, input->keybit); | ||
514 | set_bit(KEY_BRIGHTNESSDOWN, input->keybit); | ||
515 | set_bit(KEY_UNKNOWN, input->keybit); | ||
516 | |||
517 | error = input_register_device(input); | ||
518 | if (error) | ||
519 | goto err_free_input_dev; | ||
520 | |||
212 | result = acpi_bus_get_power(fujitsu->acpi_handle, &state); | 521 | result = acpi_bus_get_power(fujitsu->acpi_handle, &state); |
213 | if (result) { | 522 | if (result) { |
214 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 523 | printk(KERN_ERR "Error reading power state\n"); |
215 | "Error reading power state\n")); | ||
216 | goto end; | 524 | goto end; |
217 | } | 525 | } |
218 | 526 | ||
@@ -220,22 +528,373 @@ static int acpi_fujitsu_add(struct acpi_device *device) | |||
220 | acpi_device_name(device), acpi_device_bid(device), | 528 | acpi_device_name(device), acpi_device_bid(device), |
221 | !device->power.state ? "on" : "off"); | 529 | !device->power.state ? "on" : "off"); |
222 | 530 | ||
223 | end: | 531 | fujitsu->dev = device; |
532 | |||
533 | if (ACPI_SUCCESS | ||
534 | (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) { | ||
535 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); | ||
536 | if (ACPI_FAILURE | ||
537 | (acpi_evaluate_object | ||
538 | (device->handle, METHOD_NAME__INI, NULL, NULL))) | ||
539 | printk(KERN_ERR "_INI Method failed\n"); | ||
540 | } | ||
541 | |||
542 | /* do config (detect defaults) */ | ||
543 | dmi_check_system(fujitsu_dmi_table); | ||
544 | use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; | ||
545 | disable_brightness_keys = disable_brightness_keys == 1 ? 1 : 0; | ||
546 | disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; | ||
547 | vdbg_printk(FUJLAPTOP_DBG_INFO, | ||
548 | "config: [alt interface: %d], [key disable: %d], [adjust disable: %d]\n", | ||
549 | use_alt_lcd_levels, disable_brightness_keys, | ||
550 | disable_brightness_adjust); | ||
551 | |||
552 | if (get_max_brightness() <= 0) | ||
553 | fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; | ||
554 | if (use_alt_lcd_levels) | ||
555 | get_lcd_level_alt(); | ||
556 | else | ||
557 | get_lcd_level(); | ||
558 | |||
559 | return result; | ||
560 | |||
561 | end: | ||
562 | err_free_input_dev: | ||
563 | input_free_device(input); | ||
564 | err_uninstall_notify: | ||
565 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | ||
566 | acpi_fujitsu_notify); | ||
567 | err_stop: | ||
224 | 568 | ||
225 | return result; | 569 | return result; |
226 | } | 570 | } |
227 | 571 | ||
228 | static int acpi_fujitsu_remove(struct acpi_device *device, int type) | 572 | static int acpi_fujitsu_remove(struct acpi_device *device, int type) |
229 | { | 573 | { |
230 | ACPI_FUNCTION_TRACE("acpi_fujitsu_remove"); | 574 | acpi_status status; |
575 | struct fujitsu_t *fujitsu = NULL; | ||
231 | 576 | ||
232 | if (!device || !acpi_driver_data(device)) | 577 | if (!device || !acpi_driver_data(device)) |
233 | return -EINVAL; | 578 | return -EINVAL; |
579 | |||
580 | fujitsu = acpi_driver_data(device); | ||
581 | |||
582 | status = acpi_remove_notify_handler(fujitsu->acpi_handle, | ||
583 | ACPI_DEVICE_NOTIFY, | ||
584 | acpi_fujitsu_notify); | ||
585 | |||
586 | if (!device || !acpi_driver_data(device)) | ||
587 | return -EINVAL; | ||
588 | |||
234 | fujitsu->acpi_handle = NULL; | 589 | fujitsu->acpi_handle = NULL; |
235 | 590 | ||
236 | return 0; | 591 | return 0; |
237 | } | 592 | } |
238 | 593 | ||
594 | /* Brightness notify */ | ||
595 | |||
596 | static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data) | ||
597 | { | ||
598 | struct input_dev *input; | ||
599 | int keycode; | ||
600 | int oldb, newb; | ||
601 | |||
602 | input = fujitsu->input; | ||
603 | |||
604 | switch (event) { | ||
605 | case ACPI_FUJITSU_NOTIFY_CODE1: | ||
606 | keycode = 0; | ||
607 | oldb = fujitsu->brightness_level; | ||
608 | get_lcd_level(); /* the alt version always yields changed */ | ||
609 | newb = fujitsu->brightness_level; | ||
610 | |||
611 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | ||
612 | "brightness button event [%i -> %i (%i)]\n", | ||
613 | oldb, newb, fujitsu->brightness_changed); | ||
614 | |||
615 | if (oldb == newb && fujitsu->brightness_changed) { | ||
616 | keycode = 0; | ||
617 | if (disable_brightness_keys != 1) { | ||
618 | if (oldb == 0) { | ||
619 | acpi_bus_generate_proc_event(fujitsu-> | ||
620 | dev, | ||
621 | ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, | ||
622 | 0); | ||
623 | keycode = KEY_BRIGHTNESSDOWN; | ||
624 | } else if (oldb == | ||
625 | (fujitsu->max_brightness) - 1) { | ||
626 | acpi_bus_generate_proc_event(fujitsu-> | ||
627 | dev, | ||
628 | ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, | ||
629 | 0); | ||
630 | keycode = KEY_BRIGHTNESSUP; | ||
631 | } | ||
632 | } | ||
633 | } else if (oldb < newb) { | ||
634 | if (disable_brightness_adjust != 1) { | ||
635 | if (use_alt_lcd_levels) | ||
636 | set_lcd_level_alt(newb); | ||
637 | else | ||
638 | set_lcd_level(newb); | ||
639 | } | ||
640 | if (disable_brightness_keys != 1) { | ||
641 | acpi_bus_generate_proc_event(fujitsu->dev, | ||
642 | ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, | ||
643 | 0); | ||
644 | keycode = KEY_BRIGHTNESSUP; | ||
645 | } | ||
646 | } else if (oldb > newb) { | ||
647 | if (disable_brightness_adjust != 1) { | ||
648 | if (use_alt_lcd_levels) | ||
649 | set_lcd_level_alt(newb); | ||
650 | else | ||
651 | set_lcd_level(newb); | ||
652 | } | ||
653 | if (disable_brightness_keys != 1) { | ||
654 | acpi_bus_generate_proc_event(fujitsu->dev, | ||
655 | ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, | ||
656 | 0); | ||
657 | keycode = KEY_BRIGHTNESSDOWN; | ||
658 | } | ||
659 | } else { | ||
660 | keycode = KEY_UNKNOWN; | ||
661 | } | ||
662 | break; | ||
663 | default: | ||
664 | keycode = KEY_UNKNOWN; | ||
665 | vdbg_printk(FUJLAPTOP_DBG_WARN, | ||
666 | "unsupported event [0x%x]\n", event); | ||
667 | break; | ||
668 | } | ||
669 | |||
670 | if (keycode != 0) { | ||
671 | input_report_key(input, keycode, 1); | ||
672 | input_sync(input); | ||
673 | input_report_key(input, keycode, 0); | ||
674 | input_sync(input); | ||
675 | } | ||
676 | |||
677 | return; | ||
678 | } | ||
679 | |||
680 | /* ACPI device for hotkey handling */ | ||
681 | |||
682 | static int acpi_fujitsu_hotkey_add(struct acpi_device *device) | ||
683 | { | ||
684 | acpi_status status; | ||
685 | acpi_handle handle; | ||
686 | int result = 0; | ||
687 | int state = 0; | ||
688 | struct input_dev *input; | ||
689 | int error; | ||
690 | int i; | ||
691 | |||
692 | if (!device) | ||
693 | return -EINVAL; | ||
694 | |||
695 | fujitsu_hotkey->acpi_handle = device->handle; | ||
696 | sprintf(acpi_device_name(device), "%s", | ||
697 | ACPI_FUJITSU_HOTKEY_DEVICE_NAME); | ||
698 | sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); | ||
699 | acpi_driver_data(device) = fujitsu_hotkey; | ||
700 | |||
701 | status = acpi_install_notify_handler(device->handle, | ||
702 | ACPI_DEVICE_NOTIFY, | ||
703 | acpi_fujitsu_hotkey_notify, | ||
704 | fujitsu_hotkey); | ||
705 | |||
706 | if (ACPI_FAILURE(status)) { | ||
707 | printk(KERN_ERR "Error installing notify handler\n"); | ||
708 | error = -ENODEV; | ||
709 | goto err_stop; | ||
710 | } | ||
711 | |||
712 | /* kfifo */ | ||
713 | spin_lock_init(&fujitsu_hotkey->fifo_lock); | ||
714 | fujitsu_hotkey->fifo = | ||
715 | kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL, | ||
716 | &fujitsu_hotkey->fifo_lock); | ||
717 | if (IS_ERR(fujitsu_hotkey->fifo)) { | ||
718 | printk(KERN_ERR "kfifo_alloc failed\n"); | ||
719 | error = PTR_ERR(fujitsu_hotkey->fifo); | ||
720 | goto err_stop; | ||
721 | } | ||
722 | |||
723 | fujitsu_hotkey->input = input = input_allocate_device(); | ||
724 | if (!input) { | ||
725 | error = -ENOMEM; | ||
726 | goto err_uninstall_notify; | ||
727 | } | ||
728 | |||
729 | snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys), | ||
730 | "%s/video/input0", acpi_device_hid(device)); | ||
731 | |||
732 | input->name = acpi_device_name(device); | ||
733 | input->phys = fujitsu_hotkey->phys; | ||
734 | input->id.bustype = BUS_HOST; | ||
735 | input->id.product = 0x06; | ||
736 | input->dev.parent = &device->dev; | ||
737 | input->evbit[0] = BIT(EV_KEY); | ||
738 | set_bit(KEY_SCREENLOCK, input->keybit); | ||
739 | set_bit(KEY_MEDIA, input->keybit); | ||
740 | set_bit(KEY_EMAIL, input->keybit); | ||
741 | set_bit(KEY_SUSPEND, input->keybit); | ||
742 | set_bit(KEY_UNKNOWN, input->keybit); | ||
743 | |||
744 | error = input_register_device(input); | ||
745 | if (error) | ||
746 | goto err_free_input_dev; | ||
747 | |||
748 | result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state); | ||
749 | if (result) { | ||
750 | printk(KERN_ERR "Error reading power state\n"); | ||
751 | goto end; | ||
752 | } | ||
753 | |||
754 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", | ||
755 | acpi_device_name(device), acpi_device_bid(device), | ||
756 | !device->power.state ? "on" : "off"); | ||
757 | |||
758 | fujitsu_hotkey->dev = device; | ||
759 | |||
760 | if (ACPI_SUCCESS | ||
761 | (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) { | ||
762 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); | ||
763 | if (ACPI_FAILURE | ||
764 | (acpi_evaluate_object | ||
765 | (device->handle, METHOD_NAME__INI, NULL, NULL))) | ||
766 | printk(KERN_ERR "_INI Method failed\n"); | ||
767 | } | ||
768 | |||
769 | i = 0; /* Discard hotkey ringbuffer */ | ||
770 | while (get_irb() != 0 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) ; | ||
771 | vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); | ||
772 | |||
773 | return result; | ||
774 | |||
775 | end: | ||
776 | err_free_input_dev: | ||
777 | input_free_device(input); | ||
778 | err_uninstall_notify: | ||
779 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | ||
780 | acpi_fujitsu_hotkey_notify); | ||
781 | kfifo_free(fujitsu_hotkey->fifo); | ||
782 | err_stop: | ||
783 | |||
784 | return result; | ||
785 | } | ||
786 | |||
787 | static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type) | ||
788 | { | ||
789 | acpi_status status; | ||
790 | struct fujitsu_hotkey_t *fujitsu_hotkey = NULL; | ||
791 | |||
792 | if (!device || !acpi_driver_data(device)) | ||
793 | return -EINVAL; | ||
794 | |||
795 | fujitsu_hotkey = acpi_driver_data(device); | ||
796 | |||
797 | status = acpi_remove_notify_handler(fujitsu_hotkey->acpi_handle, | ||
798 | ACPI_DEVICE_NOTIFY, | ||
799 | acpi_fujitsu_hotkey_notify); | ||
800 | |||
801 | fujitsu_hotkey->acpi_handle = NULL; | ||
802 | |||
803 | kfifo_free(fujitsu_hotkey->fifo); | ||
804 | |||
805 | return 0; | ||
806 | } | ||
807 | |||
808 | static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event, | ||
809 | void *data) | ||
810 | { | ||
811 | struct input_dev *input; | ||
812 | int keycode, keycode_r; | ||
813 | unsigned int irb = 1; | ||
814 | int i, status; | ||
815 | |||
816 | input = fujitsu_hotkey->input; | ||
817 | |||
818 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "Hotkey event\n"); | ||
819 | |||
820 | switch (event) { | ||
821 | case ACPI_FUJITSU_NOTIFY_CODE1: | ||
822 | i = 0; | ||
823 | while ((irb = get_irb()) != 0 | ||
824 | && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { | ||
825 | vdbg_printk(FUJLAPTOP_DBG_TRACE, "GIRB result [%x]\n", | ||
826 | irb); | ||
827 | |||
828 | switch (irb & 0x4ff) { | ||
829 | case LOCK_KEY: | ||
830 | keycode = KEY_SCREENLOCK; | ||
831 | break; | ||
832 | case DISPLAY_KEY: | ||
833 | keycode = KEY_MEDIA; | ||
834 | break; | ||
835 | case ENERGY_KEY: | ||
836 | keycode = KEY_EMAIL; | ||
837 | break; | ||
838 | case REST_KEY: | ||
839 | keycode = KEY_SUSPEND; | ||
840 | break; | ||
841 | case 0: | ||
842 | keycode = 0; | ||
843 | break; | ||
844 | default: | ||
845 | vdbg_printk(FUJLAPTOP_DBG_WARN, | ||
846 | "Unknown GIRB result [%x]\n", irb); | ||
847 | keycode = -1; | ||
848 | break; | ||
849 | } | ||
850 | if (keycode > 0) { | ||
851 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | ||
852 | "Push keycode into ringbuffer [%d]\n", | ||
853 | keycode); | ||
854 | status = kfifo_put(fujitsu_hotkey->fifo, | ||
855 | (unsigned char *)&keycode, | ||
856 | sizeof(keycode)); | ||
857 | if (status != sizeof(keycode)) { | ||
858 | vdbg_printk(FUJLAPTOP_DBG_WARN, | ||
859 | "Could not push keycode [0x%x]\n", | ||
860 | keycode); | ||
861 | } else { | ||
862 | input_report_key(input, keycode, 1); | ||
863 | input_sync(input); | ||
864 | } | ||
865 | } else if (keycode == 0) { | ||
866 | while ((status = | ||
867 | kfifo_get | ||
868 | (fujitsu_hotkey->fifo, (unsigned char *) | ||
869 | &keycode_r, | ||
870 | sizeof | ||
871 | (keycode_r))) == sizeof(keycode_r)) { | ||
872 | input_report_key(input, keycode_r, 0); | ||
873 | input_sync(input); | ||
874 | vdbg_printk(FUJLAPTOP_DBG_TRACE, | ||
875 | "Pop keycode from ringbuffer [%d]\n", | ||
876 | keycode_r); | ||
877 | } | ||
878 | } | ||
879 | } | ||
880 | |||
881 | break; | ||
882 | default: | ||
883 | keycode = KEY_UNKNOWN; | ||
884 | vdbg_printk(FUJLAPTOP_DBG_WARN, | ||
885 | "Unsupported event [0x%x]\n", event); | ||
886 | input_report_key(input, keycode, 1); | ||
887 | input_sync(input); | ||
888 | input_report_key(input, keycode, 0); | ||
889 | input_sync(input); | ||
890 | break; | ||
891 | } | ||
892 | |||
893 | return; | ||
894 | } | ||
895 | |||
896 | /* Initialization */ | ||
897 | |||
239 | static const struct acpi_device_id fujitsu_device_ids[] = { | 898 | static const struct acpi_device_id fujitsu_device_ids[] = { |
240 | {ACPI_FUJITSU_HID, 0}, | 899 | {ACPI_FUJITSU_HID, 0}, |
241 | {"", 0}, | 900 | {"", 0}, |
@@ -251,11 +910,24 @@ static struct acpi_driver acpi_fujitsu_driver = { | |||
251 | }, | 910 | }, |
252 | }; | 911 | }; |
253 | 912 | ||
254 | /* Initialization */ | 913 | static const struct acpi_device_id fujitsu_hotkey_device_ids[] = { |
914 | {ACPI_FUJITSU_HOTKEY_HID, 0}, | ||
915 | {"", 0}, | ||
916 | }; | ||
917 | |||
918 | static struct acpi_driver acpi_fujitsu_hotkey_driver = { | ||
919 | .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME, | ||
920 | .class = ACPI_FUJITSU_CLASS, | ||
921 | .ids = fujitsu_hotkey_device_ids, | ||
922 | .ops = { | ||
923 | .add = acpi_fujitsu_hotkey_add, | ||
924 | .remove = acpi_fujitsu_hotkey_remove, | ||
925 | }, | ||
926 | }; | ||
255 | 927 | ||
256 | static int __init fujitsu_init(void) | 928 | static int __init fujitsu_init(void) |
257 | { | 929 | { |
258 | int ret, result; | 930 | int ret, result, max_brightness; |
259 | 931 | ||
260 | if (acpi_disabled) | 932 | if (acpi_disabled) |
261 | return -ENODEV; | 933 | return -ENODEV; |
@@ -271,19 +943,6 @@ static int __init fujitsu_init(void) | |||
271 | goto fail_acpi; | 943 | goto fail_acpi; |
272 | } | 944 | } |
273 | 945 | ||
274 | /* Register backlight stuff */ | ||
275 | |||
276 | fujitsu->bl_device = | ||
277 | backlight_device_register("fujitsu-laptop", NULL, NULL, | ||
278 | &fujitsubl_ops); | ||
279 | if (IS_ERR(fujitsu->bl_device)) | ||
280 | return PTR_ERR(fujitsu->bl_device); | ||
281 | |||
282 | fujitsu->bl_device->props.max_brightness = FUJITSU_LCD_N_LEVELS - 1; | ||
283 | ret = platform_driver_register(&fujitsupf_driver); | ||
284 | if (ret) | ||
285 | goto fail_backlight; | ||
286 | |||
287 | /* Register platform stuff */ | 946 | /* Register platform stuff */ |
288 | 947 | ||
289 | fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); | 948 | fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); |
@@ -302,28 +961,68 @@ static int __init fujitsu_init(void) | |||
302 | if (ret) | 961 | if (ret) |
303 | goto fail_platform_device2; | 962 | goto fail_platform_device2; |
304 | 963 | ||
964 | /* Register backlight stuff */ | ||
965 | |||
966 | fujitsu->bl_device = | ||
967 | backlight_device_register("fujitsu-laptop", NULL, NULL, | ||
968 | &fujitsubl_ops); | ||
969 | if (IS_ERR(fujitsu->bl_device)) | ||
970 | return PTR_ERR(fujitsu->bl_device); | ||
971 | |||
972 | max_brightness = fujitsu->max_brightness; | ||
973 | |||
974 | fujitsu->bl_device->props.max_brightness = max_brightness - 1; | ||
975 | fujitsu->bl_device->props.brightness = fujitsu->brightness_level; | ||
976 | |||
977 | ret = platform_driver_register(&fujitsupf_driver); | ||
978 | if (ret) | ||
979 | goto fail_backlight; | ||
980 | |||
981 | /* Register hotkey driver */ | ||
982 | |||
983 | fujitsu_hotkey = kmalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL); | ||
984 | if (!fujitsu_hotkey) { | ||
985 | ret = -ENOMEM; | ||
986 | goto fail_hotkey; | ||
987 | } | ||
988 | memset(fujitsu_hotkey, 0, sizeof(struct fujitsu_hotkey_t)); | ||
989 | |||
990 | result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver); | ||
991 | if (result < 0) { | ||
992 | ret = -ENODEV; | ||
993 | goto fail_hotkey1; | ||
994 | } | ||
995 | |||
305 | printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION | 996 | printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION |
306 | " successfully loaded.\n"); | 997 | " successfully loaded.\n"); |
307 | 998 | ||
308 | return 0; | 999 | return 0; |
309 | 1000 | ||
310 | fail_platform_device2: | 1001 | fail_hotkey1: |
311 | 1002 | ||
312 | platform_device_del(fujitsu->pf_device); | 1003 | kfree(fujitsu_hotkey); |
313 | |||
314 | fail_platform_device1: | ||
315 | |||
316 | platform_device_put(fujitsu->pf_device); | ||
317 | 1004 | ||
318 | fail_platform_driver: | 1005 | fail_hotkey: |
319 | 1006 | ||
320 | platform_driver_unregister(&fujitsupf_driver); | 1007 | platform_driver_unregister(&fujitsupf_driver); |
321 | 1008 | ||
322 | fail_backlight: | 1009 | fail_backlight: |
323 | 1010 | ||
324 | backlight_device_unregister(fujitsu->bl_device); | 1011 | backlight_device_unregister(fujitsu->bl_device); |
325 | 1012 | ||
326 | fail_acpi: | 1013 | fail_platform_device2: |
1014 | |||
1015 | platform_device_del(fujitsu->pf_device); | ||
1016 | |||
1017 | fail_platform_device1: | ||
1018 | |||
1019 | platform_device_put(fujitsu->pf_device); | ||
1020 | |||
1021 | fail_platform_driver: | ||
1022 | |||
1023 | acpi_bus_unregister_driver(&acpi_fujitsu_driver); | ||
1024 | |||
1025 | fail_acpi: | ||
327 | 1026 | ||
328 | kfree(fujitsu); | 1027 | kfree(fujitsu); |
329 | 1028 | ||
@@ -342,19 +1041,43 @@ static void __exit fujitsu_cleanup(void) | |||
342 | 1041 | ||
343 | kfree(fujitsu); | 1042 | kfree(fujitsu); |
344 | 1043 | ||
1044 | acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver); | ||
1045 | |||
1046 | kfree(fujitsu_hotkey); | ||
1047 | |||
345 | printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n"); | 1048 | printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n"); |
346 | } | 1049 | } |
347 | 1050 | ||
348 | module_init(fujitsu_init); | 1051 | module_init(fujitsu_init); |
349 | module_exit(fujitsu_cleanup); | 1052 | module_exit(fujitsu_cleanup); |
350 | 1053 | ||
351 | MODULE_AUTHOR("Jonathan Woithe"); | 1054 | module_param(use_alt_lcd_levels, uint, 0644); |
1055 | MODULE_PARM_DESC(use_alt_lcd_levels, | ||
1056 | "Use alternative interface for lcd_levels (needed for Lifebook s6410)."); | ||
1057 | module_param(disable_brightness_keys, uint, 0644); | ||
1058 | MODULE_PARM_DESC(disable_brightness_keys, | ||
1059 | "Disable brightness keys (eg. if they are already handled by the generic ACPI_VIDEO device)."); | ||
1060 | module_param(disable_brightness_adjust, uint, 0644); | ||
1061 | MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); | ||
1062 | #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG | ||
1063 | module_param_named(debug, dbg_level, uint, 0644); | ||
1064 | MODULE_PARM_DESC(debug, "Sets debug level bit-mask"); | ||
1065 | #endif | ||
1066 | |||
1067 | MODULE_AUTHOR("Jonathan Woithe, Peter Gruber"); | ||
352 | MODULE_DESCRIPTION("Fujitsu laptop extras support"); | 1068 | MODULE_DESCRIPTION("Fujitsu laptop extras support"); |
353 | MODULE_VERSION(FUJITSU_DRIVER_VERSION); | 1069 | MODULE_VERSION(FUJITSU_DRIVER_VERSION); |
354 | MODULE_LICENSE("GPL"); | 1070 | MODULE_LICENSE("GPL"); |
355 | 1071 | ||
1072 | MODULE_ALIAS | ||
1073 | ("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*"); | ||
1074 | MODULE_ALIAS | ||
1075 | ("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*"); | ||
1076 | |||
356 | static struct pnp_device_id pnp_ids[] = { | 1077 | static struct pnp_device_id pnp_ids[] = { |
357 | { .id = "FUJ02bf" }, | 1078 | { .id = "FUJ02bf" }, |
1079 | { .id = "FUJ02B1" }, | ||
1080 | { .id = "FUJ02E3" }, | ||
358 | { .id = "" } | 1081 | { .id = "" } |
359 | }; | 1082 | }; |
360 | MODULE_DEVICE_TABLE(pnp, pnp_ids); | 1083 | MODULE_DEVICE_TABLE(pnp, pnp_ids); |