From 21c405c34e20bd5e385483adfc9443d9fd6a4511 Mon Sep 17 00:00:00 2001 From: Carlos Corbacho Date: Thu, 27 Sep 2007 15:09:29 +0000 Subject: [PATCH] Merge rewrite branch, prepare for 0.9 release --- ChangeLog | 8 ++++ NEWS | 5 +++ README | 30 +++++++-------- acer_acpi.c | 124 +++++++++++++++++++++++++++--------------------------------- 4 files changed, 82 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc3006a..8a3d859 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-27 Version 0.9.0 + +* Fix compiling on older (pre 2.6.20) kernels + +* Add Acer Aspire 5560, TravelMate 2420 and TravelMate 5720 EC quirks + +* Cleanup of interface code + 2007-09-03 Version 0.8.2 * Really fix backlight code on older kernels diff --git a/NEWS b/NEWS index 256c58c..1270895 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +2007-09-27 Version 0.9.0 + Fix compiling on older (pre 2.6.20) kernels + Add Acer Aspire 5560, TravelMate 2420 and TravelMate 5720 EC quirks + Cleanup of interface code + 2007-09-03 Version 0.8.2 Really fix backlight code on older kernels Fix write errors with /proc/acpi/acer/brightness diff --git a/README b/README index ba9057d..2741858 100644 --- a/README +++ b/README @@ -1,20 +1,17 @@ -This is acer_acpi version 0.8.2 +This is acer_acpi version 0.9.0 ### THIS IS VERY MUCH A WORK IN PROGRESS. NO WARRANTY GIVEN. IF YOU ### BREAK YOUR LAPTOP USING THIS DRIVER, YOU GET TO KEEP THE PIECES AND ### I WILL ACCEPT ABSOLUTELY NO RESPONSIBILITY. acer_acpi is a driver to allow you to control various aspects of your Acer -laptop hardware using the proc filesystem. It was originally developed in -order to activate the wireless LAN card under a 64-bit version of Linux, -as acerhk[1] (the previous fine solution to the problem) relied on making BIOS -calls which are not allowed from a 64-bit OS. +laptop hardware using the proc filesystem. It was originally developed by Mark +Smith, in order to activate the wireless LAN card under a 64-bit version of +Linux, as acerhk[1] (the previous fine solution to the problem) relied on making +BIOS calls which are not allowed from a 64-bit OS. Please read the INSTALL file for installation instructions. -PLEASE NOTE: I (Mark Smith) AM NO LONGER ACTIVELY DEVELOPING ACER_ACPI. -(many would note that I never actively developed it! :-) - acer_acpi is now being maintained by Carlos Corbacho [1] acerhk: http://www.cakey.de/acerhk/ @@ -26,9 +23,10 @@ As root, modprobe acer_acpi (To enable debugging, add debug=X, where X is between 0 and 2). -acer_acpi creates entries under /proc/acpi/acer and -/sys/devices/platform/acer_acpi, which enables you to control some of the -following (varies between models): +acer_acpi creates entries under /proc/acpi/acer (deprecated), +/sys/devices/platform/acer_acpi, /sys/class/backlight (2.6.20 and above only) +and /sys/class/led, which enables you to control some of the following (varies +between models): * the wireless LAN card * inbuilt Bluetooth adapter @@ -53,7 +51,7 @@ To disable a feature: echo 0 > /proc/acpi/acer/{feature} echo 0 > /sys/devices/platform/acer_acpi/{device} -(brightness and mail LED are not visible in sysfs/ platform device - these are +(brightness and mail LED are not visible in /sys/devices/platform - these are properly registered with the relevant kernel subsystem). To enable a feature on loading the module: @@ -77,13 +75,11 @@ combination. e.g. With the BCM4318 on the 5020 series: ndiswrapper: Light blinks on when transmitting -bcm43xx/ -bcm43xx_mac80211: Solid light, blinks off when transmitting +bcm43xx/b43: Solid light, blinks off when transmitting Also, acer_acpi does not yet have any means of deciding whether to -enable or disable entries in /proc/acpi/acer - this means that for -hardware that isn't there, you can still read/ write the corresponding proc -file. +enable or disable entries in proc or sysfs - this means that for +hardware that isn't there, you can still read/ write the corresponding file. So: Just because it _says_ "bluetooth" in /proc/acpi/acer, doesn't mean you now actually have a Bluetooth device. diff --git a/acer_acpi.c b/acer_acpi.c index fca0278..d9ccd7c 100644 --- a/acer_acpi.c +++ b/acer_acpi.c @@ -39,7 +39,7 @@ * */ -#define ACER_ACPI_VERSION "0.8.2" +#define ACER_ACPI_VERSION "0.9.0" /* * Comment the following line out to remove /proc support @@ -47,7 +47,6 @@ #define CONFIG_PROC #ifdef CONFIG_PROC -#define PROC_INTERFACE_VERSION 1 #define PROC_ACER "acer" #endif @@ -74,7 +73,12 @@ #include -MODULE_AUTHOR("Mark Smith"); +/* Workaround needed for older kernels */ +#ifndef bool +#define bool int +#endif + +MODULE_AUTHOR("Mark Smith, Carlos Corbacho"); MODULE_DESCRIPTION("Acer Laptop ACPI Extras Driver"); MODULE_LICENSE("GPL"); @@ -296,17 +300,6 @@ struct Interface { void (*free) (struct Interface*); /* - * Gets and sets various data types. - * First paramater: Value to set, or pointer to place got value into - * Second parameter: Specific capability being requested - * Third paramater: Pointer to this interface - */ - acpi_status (*get_bool) (bool*, u32, struct Interface*); - acpi_status (*set_bool) (bool, u32, struct Interface*); - acpi_status (*get_u8) (u8*, u32, struct Interface*); - acpi_status (*set_u8) (u8, u32, struct Interface*); - - /* * Interface-specific private data member. Must *not* be touched by * anyone outside of this struct */ @@ -562,25 +555,6 @@ static void interface_free(struct Interface *iface) kfree(iface->data); } -/* These *_via_u8 use the interface's *_u8 methods to emulate other gets/sets */ -static acpi_status get_bool_via_u8(bool *value, u32 cap, struct Interface *iface) { - acpi_status status; - u8 result; - - status = iface->get_u8(&result, cap, iface); - - if (ACPI_SUCCESS(status)) - *value = (result != 0); - - return status; -} - -static acpi_status set_bool_via_u8(bool value, u32 cap, struct Interface *iface) { - u8 v = value ? 1 : 0; - - return iface->set_u8(v, cap, iface); -} - /* General wrapper around the ACPI call */ static acpi_status WMI_execute(char *methodPath, u32 methodId, const struct acpi_buffer *in, struct acpi_buffer *out) { @@ -848,10 +822,6 @@ static struct Interface AMW0_interface = { ), .init = AMW0_init, .free = interface_free, - .get_bool = AMW0_get_bool, - .set_bool = AMW0_set_bool, - .get_u8 = AMW0_get_u8, - .set_u8 = AMW0_set_u8, }; /* @@ -1002,10 +972,6 @@ static struct Interface WMID_interface = { ), .init = WMID_init, .free = interface_free, - .get_bool = get_bool_via_u8, - .set_bool = set_bool_via_u8, - .get_u8 = WMID_get_u8, - .set_u8 = WMID_set_u8, .data = NULL, }; @@ -1065,44 +1031,62 @@ dispatch_write(struct file *file, const char __user * buffer, static acpi_status get_bool(bool *value, u32 cap) { acpi_status status = AE_BAD_ADDRESS; - if (interface->get_bool) - status = interface->get_bool(value, cap, interface); + u8 *tmp = 0; + + switch (interface->type) { + case ACER_AMW0: + status = AMW0_get_bool(value, cap, interface); + break; + case ACER_WMID: + status = WMID_get_u8(tmp, cap, interface); + *value = (*tmp == 1) ? 1 : 0; + break; + } return status; } static acpi_status set_bool(int value, u32 cap) { acpi_status status = AE_BAD_PARAMETER; - if ((value == 0 || value == 1) && - (interface->capability & cap)) { - if (interface->set_bool) - status = interface->set_bool(value == 1, cap, interface); + + if ((value == 0 || value == 1) && (interface->capability & cap)) { + switch (interface->type) { + case ACER_AMW0: + status = AMW0_set_bool(value == 1, cap, interface); + break; + case ACER_WMID: + status = AMW0_set_u8(value == 1, cap, interface); + break; + } } return status; } static acpi_status get_u8(u8 *value, u32 cap) { - acpi_status status = AE_BAD_ADDRESS; - if (interface->get_u8) - status = interface->get_u8(value, cap, interface); - return status; + switch (interface->type) { + case ACER_AMW0: + return AMW0_get_u8(value, cap, interface); + break; + case ACER_WMID: + return WMID_get_u8(value, cap, interface); + break; + default: + return AE_BAD_ADDRESS; + } } static acpi_status set_u8(u8 value, u8 min, u8 max, u32 cap) { - acpi_status status = AE_BAD_PARAMETER; - if ((value >= min && value <= max) && - (interface->capability & cap) ) { - if (interface->get_u8) { - /* If possible, only set if the value has changed */ - u8 actual; - status = interface->get_u8(&actual, cap, interface); - if (ACPI_SUCCESS(status) && actual == value) - return status; + if ((value >= min && value <= max) && (interface->capability & cap) ) { + switch (interface->type) { + case ACER_AMW0: + return AMW0_set_u8(value, cap, interface); + case ACER_WMID: + return WMID_set_u8(value, cap, interface); + default: + return AE_BAD_PARAMETER; } - if (interface->set_u8) - status = interface->set_u8(value, cap, interface); } - return status; + return AE_BAD_PARAMETER; } /* Each _u8 needs a small wrapper that sets the boundary values */ @@ -1192,8 +1176,8 @@ static unsigned long write_u8(const char *buffer, unsigned long count, u32 cap) if (sscanf(buffer, "%i", &value) == 1) { acpi_status status = (*set_method)(value); - /*if (ACPI_FAILURE(status)) - return -EINVAL;*/ + if (ACPI_FAILURE(status)) + return -EINVAL; } else { return -EINVAL; } @@ -1202,9 +1186,7 @@ static unsigned long write_u8(const char *buffer, unsigned long count, u32 cap) static char *read_version(char *p, u32 cap) { - p += sprintf(p, "driver: %s\n", ACER_ACPI_VERSION); - p += sprintf(p, "proc_interface: %d\n", - PROC_INTERFACE_VERSION); + p += sprintf(p, "%s\n", ACER_ACPI_VERSION); return p; } @@ -1287,6 +1269,7 @@ static void acer_led_exit(void) led_classdev_unregister(&mail_led); } +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) /* * Backlight device */ @@ -1365,6 +1348,7 @@ static void __exit acer_backlight_exit(void) { backlight_device_unregister(acer_backlight_device); } +#endif /* * Platform device @@ -1570,8 +1554,10 @@ static int acer_acpi_add(struct acpi_device *device) struct device *dev = acpi_get_physical_device(device->handle); if (has_cap(ACER_CAP_MAILLED)) acer_led_init(dev); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) if (has_cap(ACER_CAP_BRIGHTNESS)) acer_backlight_init(dev); +#endif acer_platform_add(); return 0; @@ -1581,8 +1567,10 @@ static int acer_acpi_remove(struct acpi_device *device, int type) { if (has_cap(ACER_CAP_MAILLED)) acer_led_exit(); +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) if (has_cap(ACER_CAP_BRIGHTNESS)) acer_backlight_exit(); +#endif acer_platform_remove(); return 0; -- 2.11.4.GIT