diff options
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/Kconfig | 14 | ||||
-rw-r--r-- | drivers/platform/x86/acer-wmi.c | 2 | ||||
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 1741 | ||||
-rw-r--r-- | drivers/platform/x86/asus_acpi.c | 3 | ||||
-rw-r--r-- | drivers/platform/x86/classmate-laptop.c | 35 | ||||
-rw-r--r-- | drivers/platform/x86/compal-laptop.c | 247 | ||||
-rw-r--r-- | drivers/platform/x86/dell-laptop.c | 257 | ||||
-rw-r--r-- | drivers/platform/x86/eeepc-laptop.c | 21 | ||||
-rw-r--r-- | drivers/platform/x86/hp-wmi.c | 1 | ||||
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 116 | ||||
-rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 208 | ||||
-rw-r--r-- | drivers/platform/x86/toshiba_bluetooth.c | 4 | ||||
-rw-r--r-- | drivers/platform/x86/wmi.c | 4 |
13 files changed, 1579 insertions, 1074 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index f526e735c5ab..cd2ee6fce1b4 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -59,6 +59,8 @@ config ASUS_LAPTOP | |||
59 | select NEW_LEDS | 59 | select NEW_LEDS |
60 | select BACKLIGHT_CLASS_DEVICE | 60 | select BACKLIGHT_CLASS_DEVICE |
61 | depends on INPUT | 61 | depends on INPUT |
62 | depends on RFKILL || RFKILL = n | ||
63 | select INPUT_SPARSEKMAP | ||
62 | ---help--- | 64 | ---help--- |
63 | This is the new Linux driver for Asus laptops. It may also support some | 65 | This is the new Linux driver for Asus laptops. It may also support some |
64 | MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate | 66 | MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate |
@@ -79,6 +81,7 @@ config DELL_LAPTOP | |||
79 | depends on BACKLIGHT_CLASS_DEVICE | 81 | depends on BACKLIGHT_CLASS_DEVICE |
80 | depends on RFKILL || RFKILL = n | 82 | depends on RFKILL || RFKILL = n |
81 | depends on POWER_SUPPLY | 83 | depends on POWER_SUPPLY |
84 | depends on SERIO_I8042 | ||
82 | default n | 85 | default n |
83 | ---help--- | 86 | ---help--- |
84 | This driver adds support for rfkill and backlight control to Dell | 87 | This driver adds support for rfkill and backlight control to Dell |
@@ -176,6 +179,7 @@ config COMPAL_LAPTOP | |||
176 | tristate "Compal Laptop Extras" | 179 | tristate "Compal Laptop Extras" |
177 | depends on ACPI | 180 | depends on ACPI |
178 | depends on BACKLIGHT_CLASS_DEVICE | 181 | depends on BACKLIGHT_CLASS_DEVICE |
182 | depends on RFKILL | ||
179 | ---help--- | 183 | ---help--- |
180 | This is a driver for laptops built by Compal: | 184 | This is a driver for laptops built by Compal: |
181 | 185 | ||
@@ -319,9 +323,15 @@ config THINKPAD_ACPI_VIDEO | |||
319 | server running, phase of the moon, and the current mood of | 323 | server running, phase of the moon, and the current mood of |
320 | Schroedinger's cat. If you can use X.org's RandR to control | 324 | Schroedinger's cat. If you can use X.org's RandR to control |
321 | your ThinkPad's video output ports instead of this feature, | 325 | your ThinkPad's video output ports instead of this feature, |
322 | don't think twice: do it and say N here to save some memory. | 326 | don't think twice: do it and say N here to save memory and avoid |
327 | bad interactions with X.org. | ||
328 | |||
329 | NOTE: access to this feature is limited to processes with the | ||
330 | CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms | ||
331 | where it interacts badly with X.org. | ||
323 | 332 | ||
324 | If you are not sure, say Y here. | 333 | If you are not sure, say Y here but do try to check if you could |
334 | be using X.org RandR instead. | ||
325 | 335 | ||
326 | config THINKPAD_ACPI_HOTKEY_POLL | 336 | config THINKPAD_ACPI_HOTKEY_POLL |
327 | bool "Support NVRAM polling for hot keys" | 337 | bool "Support NVRAM polling for hot keys" |
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 07d14dfdf0b4..226b3e93498c 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c | |||
@@ -934,7 +934,7 @@ static int __devinit acer_backlight_init(struct device *dev) | |||
934 | acer_backlight_device = bd; | 934 | acer_backlight_device = bd; |
935 | 935 | ||
936 | bd->props.power = FB_BLANK_UNBLANK; | 936 | bd->props.power = FB_BLANK_UNBLANK; |
937 | bd->props.brightness = max_brightness; | 937 | bd->props.brightness = read_brightness(bd); |
938 | bd->props.max_brightness = max_brightness; | 938 | bd->props.max_brightness = max_brightness; |
939 | backlight_update_status(bd); | 939 | backlight_update_status(bd); |
940 | return 0; | 940 | return 0; |
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 61a1c7503658..791fcf321506 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -45,58 +45,23 @@ | |||
45 | #include <linux/fb.h> | 45 | #include <linux/fb.h> |
46 | #include <linux/leds.h> | 46 | #include <linux/leds.h> |
47 | #include <linux/platform_device.h> | 47 | #include <linux/platform_device.h> |
48 | #include <linux/uaccess.h> | ||
49 | #include <linux/input.h> | ||
50 | #include <linux/input/sparse-keymap.h> | ||
51 | #include <linux/rfkill.h> | ||
48 | #include <acpi/acpi_drivers.h> | 52 | #include <acpi/acpi_drivers.h> |
49 | #include <acpi/acpi_bus.h> | 53 | #include <acpi/acpi_bus.h> |
50 | #include <asm/uaccess.h> | ||
51 | #include <linux/input.h> | ||
52 | |||
53 | #define ASUS_LAPTOP_VERSION "0.42" | ||
54 | |||
55 | #define ASUS_HOTK_NAME "Asus Laptop Support" | ||
56 | #define ASUS_HOTK_CLASS "hotkey" | ||
57 | #define ASUS_HOTK_DEVICE_NAME "Hotkey" | ||
58 | #define ASUS_HOTK_FILE KBUILD_MODNAME | ||
59 | #define ASUS_HOTK_PREFIX "\\_SB.ATKD." | ||
60 | 54 | ||
55 | #define ASUS_LAPTOP_VERSION "0.42" | ||
61 | 56 | ||
62 | /* | 57 | #define ASUS_LAPTOP_NAME "Asus Laptop Support" |
63 | * Some events we use, same for all Asus | 58 | #define ASUS_LAPTOP_CLASS "hotkey" |
64 | */ | 59 | #define ASUS_LAPTOP_DEVICE_NAME "Hotkey" |
65 | #define ATKD_BR_UP 0x10 | 60 | #define ASUS_LAPTOP_FILE KBUILD_MODNAME |
66 | #define ATKD_BR_DOWN 0x20 | 61 | #define ASUS_LAPTOP_PREFIX "\\_SB.ATKD." |
67 | #define ATKD_LCD_ON 0x33 | ||
68 | #define ATKD_LCD_OFF 0x34 | ||
69 | |||
70 | /* | ||
71 | * Known bits returned by \_SB.ATKD.HWRS | ||
72 | */ | ||
73 | #define WL_HWRS 0x80 | ||
74 | #define BT_HWRS 0x100 | ||
75 | |||
76 | /* | ||
77 | * Flags for hotk status | ||
78 | * WL_ON and BT_ON are also used for wireless_status() | ||
79 | */ | ||
80 | #define WL_ON 0x01 /* internal Wifi */ | ||
81 | #define BT_ON 0x02 /* internal Bluetooth */ | ||
82 | #define MLED_ON 0x04 /* mail LED */ | ||
83 | #define TLED_ON 0x08 /* touchpad LED */ | ||
84 | #define RLED_ON 0x10 /* Record LED */ | ||
85 | #define PLED_ON 0x20 /* Phone LED */ | ||
86 | #define GLED_ON 0x40 /* Gaming LED */ | ||
87 | #define LCD_ON 0x80 /* LCD backlight */ | ||
88 | #define GPS_ON 0x100 /* GPS */ | ||
89 | #define KEY_ON 0x200 /* Keyboard backlight */ | ||
90 | |||
91 | #define ASUS_LOG ASUS_HOTK_FILE ": " | ||
92 | #define ASUS_ERR KERN_ERR ASUS_LOG | ||
93 | #define ASUS_WARNING KERN_WARNING ASUS_LOG | ||
94 | #define ASUS_NOTICE KERN_NOTICE ASUS_LOG | ||
95 | #define ASUS_INFO KERN_INFO ASUS_LOG | ||
96 | #define ASUS_DEBUG KERN_DEBUG ASUS_LOG | ||
97 | 62 | ||
98 | MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary"); | 63 | MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary"); |
99 | MODULE_DESCRIPTION(ASUS_HOTK_NAME); | 64 | MODULE_DESCRIPTION(ASUS_LAPTOP_NAME); |
100 | MODULE_LICENSE("GPL"); | 65 | MODULE_LICENSE("GPL"); |
101 | 66 | ||
102 | /* | 67 | /* |
@@ -113,225 +78,209 @@ static uint wapf = 1; | |||
113 | module_param(wapf, uint, 0644); | 78 | module_param(wapf, uint, 0644); |
114 | MODULE_PARM_DESC(wapf, "WAPF value"); | 79 | MODULE_PARM_DESC(wapf, "WAPF value"); |
115 | 80 | ||
116 | #define ASUS_HANDLE(object, paths...) \ | 81 | static uint wlan_status = 1; |
117 | static acpi_handle object##_handle = NULL; \ | 82 | static uint bluetooth_status = 1; |
118 | static char *object##_paths[] = { paths } | 83 | |
84 | module_param(wlan_status, uint, 0644); | ||
85 | MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot " | ||
86 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " | ||
87 | "default is 1"); | ||
88 | |||
89 | module_param(bluetooth_status, uint, 0644); | ||
90 | MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " | ||
91 | "(0 = disabled, 1 = enabled, -1 = don't do anything). " | ||
92 | "default is 1"); | ||
93 | |||
94 | /* | ||
95 | * Some events we use, same for all Asus | ||
96 | */ | ||
97 | #define ATKD_BR_UP 0x10 /* (event & ~ATKD_BR_UP) = brightness level */ | ||
98 | #define ATKD_BR_DOWN 0x20 /* (event & ~ATKD_BR_DOWN) = britghness level */ | ||
99 | #define ATKD_BR_MIN ATKD_BR_UP | ||
100 | #define ATKD_BR_MAX (ATKD_BR_DOWN | 0xF) /* 0x2f */ | ||
101 | #define ATKD_LCD_ON 0x33 | ||
102 | #define ATKD_LCD_OFF 0x34 | ||
103 | |||
104 | /* | ||
105 | * Known bits returned by \_SB.ATKD.HWRS | ||
106 | */ | ||
107 | #define WL_HWRS 0x80 | ||
108 | #define BT_HWRS 0x100 | ||
109 | |||
110 | /* | ||
111 | * Flags for hotk status | ||
112 | * WL_ON and BT_ON are also used for wireless_status() | ||
113 | */ | ||
114 | #define WL_RSTS 0x01 /* internal Wifi */ | ||
115 | #define BT_RSTS 0x02 /* internal Bluetooth */ | ||
119 | 116 | ||
120 | /* LED */ | 117 | /* LED */ |
121 | ASUS_HANDLE(mled_set, ASUS_HOTK_PREFIX "MLED"); | 118 | #define METHOD_MLED "MLED" |
122 | ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED"); | 119 | #define METHOD_TLED "TLED" |
123 | ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */ | 120 | #define METHOD_RLED "RLED" /* W1JC */ |
124 | ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */ | 121 | #define METHOD_PLED "PLED" /* A7J */ |
125 | ASUS_HANDLE(gled_set, ASUS_HOTK_PREFIX "GLED"); /* G1, G2 (probably) */ | 122 | #define METHOD_GLED "GLED" /* G1, G2 (probably) */ |
126 | 123 | ||
127 | /* LEDD */ | 124 | /* LEDD */ |
128 | ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM"); | 125 | #define METHOD_LEDD "SLCM" |
129 | 126 | ||
130 | /* | 127 | /* |
131 | * Bluetooth and WLAN | 128 | * Bluetooth and WLAN |
132 | * WLED and BLED are not handled like other XLED, because in some dsdt | 129 | * WLED and BLED are not handled like other XLED, because in some dsdt |
133 | * they also control the WLAN/Bluetooth device. | 130 | * they also control the WLAN/Bluetooth device. |
134 | */ | 131 | */ |
135 | ASUS_HANDLE(wl_switch, ASUS_HOTK_PREFIX "WLED"); | 132 | #define METHOD_WLAN "WLED" |
136 | ASUS_HANDLE(bt_switch, ASUS_HOTK_PREFIX "BLED"); | 133 | #define METHOD_BLUETOOTH "BLED" |
137 | ASUS_HANDLE(wireless_status, ASUS_HOTK_PREFIX "RSTS"); /* All new models */ | 134 | #define METHOD_WL_STATUS "RSTS" |
138 | 135 | ||
139 | /* Brightness */ | 136 | /* Brightness */ |
140 | ASUS_HANDLE(brightness_set, ASUS_HOTK_PREFIX "SPLV"); | 137 | #define METHOD_BRIGHTNESS_SET "SPLV" |
141 | ASUS_HANDLE(brightness_get, ASUS_HOTK_PREFIX "GPLV"); | 138 | #define METHOD_BRIGHTNESS_GET "GPLV" |
142 | 139 | ||
143 | /* Backlight */ | 140 | /* Backlight */ |
144 | ASUS_HANDLE(lcd_switch, "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ | 141 | static acpi_handle lcd_switch_handle; |
145 | "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ | 142 | static const char *lcd_switch_paths[] = { |
146 | "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ | 143 | "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ |
147 | "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */ | 144 | "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ |
148 | "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */ | 145 | "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ |
149 | "\\_SB.PCI0.LPCB.EC0._Q0E", /* P30/P35 */ | 146 | "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */ |
150 | "\\_SB.PCI0.PX40.Q10", /* S1x */ | 147 | "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */ |
151 | "\\Q10"); /* A2x, L2D, L3D, M2E */ | 148 | "\\_SB.PCI0.LPCB.EC0._Q0E", /* P30/P35 */ |
149 | "\\_SB.PCI0.PX40.Q10", /* S1x */ | ||
150 | "\\Q10"}; /* A2x, L2D, L3D, M2E */ | ||
152 | 151 | ||
153 | /* Display */ | 152 | /* Display */ |
154 | ASUS_HANDLE(display_set, ASUS_HOTK_PREFIX "SDSP"); | 153 | #define METHOD_SWITCH_DISPLAY "SDSP" |
155 | ASUS_HANDLE(display_get, | 154 | |
156 | /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ | 155 | static acpi_handle display_get_handle; |
157 | "\\_SB.PCI0.P0P1.VGA.GETD", | 156 | static const char *display_get_paths[] = { |
158 | /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */ | 157 | /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ |
159 | "\\_SB.PCI0.P0P2.VGA.GETD", | 158 | "\\_SB.PCI0.P0P1.VGA.GETD", |
160 | /* A6V A6Q */ | 159 | /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */ |
161 | "\\_SB.PCI0.P0P3.VGA.GETD", | 160 | "\\_SB.PCI0.P0P2.VGA.GETD", |
162 | /* A6T, A6M */ | 161 | /* A6V A6Q */ |
163 | "\\_SB.PCI0.P0PA.VGA.GETD", | 162 | "\\_SB.PCI0.P0P3.VGA.GETD", |
164 | /* L3C */ | 163 | /* A6T, A6M */ |
165 | "\\_SB.PCI0.PCI1.VGAC.NMAP", | 164 | "\\_SB.PCI0.P0PA.VGA.GETD", |
166 | /* Z96F */ | 165 | /* L3C */ |
167 | "\\_SB.PCI0.VGA.GETD", | 166 | "\\_SB.PCI0.PCI1.VGAC.NMAP", |
168 | /* A2D */ | 167 | /* Z96F */ |
169 | "\\ACTD", | 168 | "\\_SB.PCI0.VGA.GETD", |
170 | /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */ | 169 | /* A2D */ |
171 | "\\ADVG", | 170 | "\\ACTD", |
172 | /* P30 */ | 171 | /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */ |
173 | "\\DNXT", | 172 | "\\ADVG", |
174 | /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */ | 173 | /* P30 */ |
175 | "\\INFB", | 174 | "\\DNXT", |
176 | /* A3F A6F A3N A3L M6N W3N W6A */ | 175 | /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */ |
177 | "\\SSTE"); | 176 | "\\INFB", |
178 | 177 | /* A3F A6F A3N A3L M6N W3N W6A */ | |
179 | ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ | 178 | "\\SSTE"}; |
180 | ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ | 179 | |
180 | #define METHOD_ALS_CONTROL "ALSC" /* Z71A Z71V */ | ||
181 | #define METHOD_ALS_LEVEL "ALSL" /* Z71A Z71V */ | ||
181 | 182 | ||
182 | /* GPS */ | 183 | /* GPS */ |
183 | /* R2H use different handle for GPS on/off */ | 184 | /* R2H use different handle for GPS on/off */ |
184 | ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */ | 185 | #define METHOD_GPS_ON "SDON" |
185 | ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */ | 186 | #define METHOD_GPS_OFF "SDOF" |
186 | ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST"); | 187 | #define METHOD_GPS_STATUS "GPST" |
187 | 188 | ||
188 | /* Keyboard light */ | 189 | /* Keyboard light */ |
189 | ASUS_HANDLE(kled_set, ASUS_HOTK_PREFIX "SLKB"); | 190 | #define METHOD_KBD_LIGHT_SET "SLKB" |
190 | ASUS_HANDLE(kled_get, ASUS_HOTK_PREFIX "GLKB"); | 191 | #define METHOD_KBD_LIGHT_GET "GLKB" |
191 | 192 | ||
192 | /* | 193 | /* |
193 | * This is the main structure, we can use it to store anything interesting | 194 | * Define a specific led structure to keep the main structure clean |
194 | * about the hotk device | ||
195 | */ | 195 | */ |
196 | struct asus_hotk { | 196 | struct asus_led { |
197 | char *name; /* laptop name */ | 197 | int wk; |
198 | struct acpi_device *device; /* the device we are in */ | 198 | struct work_struct work; |
199 | acpi_handle handle; /* the handle of the hotk device */ | 199 | struct led_classdev led; |
200 | char status; /* status of the hotk, for LEDs, ... */ | 200 | struct asus_laptop *asus; |
201 | u32 ledd_status; /* status of the LED display */ | 201 | const char *method; |
202 | u8 light_level; /* light sensor level */ | ||
203 | u8 light_switch; /* light sensor switch value */ | ||
204 | u16 event_count[128]; /* count for each event TODO make this better */ | ||
205 | struct input_dev *inputdev; | ||
206 | u16 *keycode_map; | ||
207 | }; | 202 | }; |
208 | 203 | ||
209 | /* | 204 | /* |
210 | * This header is made available to allow proper configuration given model, | 205 | * This is the main structure, we can use it to store anything interesting |
211 | * revision number , ... this info cannot go in struct asus_hotk because it is | 206 | * about the hotk device |
212 | * available before the hotk | ||
213 | */ | ||
214 | static struct acpi_table_header *asus_info; | ||
215 | |||
216 | /* The actual device the driver binds to */ | ||
217 | static struct asus_hotk *hotk; | ||
218 | |||
219 | /* | ||
220 | * The hotkey driver declaration | ||
221 | */ | 207 | */ |
222 | static const struct acpi_device_id asus_device_ids[] = { | 208 | struct asus_laptop { |
223 | {"ATK0100", 0}, | 209 | char *name; /* laptop name */ |
224 | {"ATK0101", 0}, | ||
225 | {"", 0}, | ||
226 | }; | ||
227 | MODULE_DEVICE_TABLE(acpi, asus_device_ids); | ||
228 | 210 | ||
229 | static int asus_hotk_add(struct acpi_device *device); | 211 | struct acpi_table_header *dsdt_info; |
230 | static int asus_hotk_remove(struct acpi_device *device, int type); | 212 | struct platform_device *platform_device; |
231 | static void asus_hotk_notify(struct acpi_device *device, u32 event); | 213 | struct acpi_device *device; /* the device we are in */ |
214 | struct backlight_device *backlight_device; | ||
232 | 215 | ||
233 | static struct acpi_driver asus_hotk_driver = { | 216 | struct input_dev *inputdev; |
234 | .name = ASUS_HOTK_NAME, | 217 | struct key_entry *keymap; |
235 | .class = ASUS_HOTK_CLASS, | ||
236 | .owner = THIS_MODULE, | ||
237 | .ids = asus_device_ids, | ||
238 | .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, | ||
239 | .ops = { | ||
240 | .add = asus_hotk_add, | ||
241 | .remove = asus_hotk_remove, | ||
242 | .notify = asus_hotk_notify, | ||
243 | }, | ||
244 | }; | ||
245 | 218 | ||
246 | /* The backlight device /sys/class/backlight */ | 219 | struct asus_led mled; |
247 | static struct backlight_device *asus_backlight_device; | 220 | struct asus_led tled; |
221 | struct asus_led rled; | ||
222 | struct asus_led pled; | ||
223 | struct asus_led gled; | ||
224 | struct asus_led kled; | ||
225 | struct workqueue_struct *led_workqueue; | ||
248 | 226 | ||
249 | /* | 227 | int wireless_status; |
250 | * The backlight class declaration | 228 | bool have_rsts; |
251 | */ | 229 | int lcd_state; |
252 | static int read_brightness(struct backlight_device *bd); | ||
253 | static int update_bl_status(struct backlight_device *bd); | ||
254 | static struct backlight_ops asusbl_ops = { | ||
255 | .get_brightness = read_brightness, | ||
256 | .update_status = update_bl_status, | ||
257 | }; | ||
258 | 230 | ||
259 | /* | 231 | struct rfkill *gps_rfkill; |
260 | * These functions actually update the LED's, and are called from a | ||
261 | * workqueue. By doing this as separate work rather than when the LED | ||
262 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a | ||
263 | * potentially bad time, such as a timer interrupt. | ||
264 | */ | ||
265 | static struct workqueue_struct *led_workqueue; | ||
266 | |||
267 | #define ASUS_LED(object, ledname, max) \ | ||
268 | static void object##_led_set(struct led_classdev *led_cdev, \ | ||
269 | enum led_brightness value); \ | ||
270 | static enum led_brightness object##_led_get( \ | ||
271 | struct led_classdev *led_cdev); \ | ||
272 | static void object##_led_update(struct work_struct *ignored); \ | ||
273 | static int object##_led_wk; \ | ||
274 | static DECLARE_WORK(object##_led_work, object##_led_update); \ | ||
275 | static struct led_classdev object##_led = { \ | ||
276 | .name = "asus::" ledname, \ | ||
277 | .brightness_set = object##_led_set, \ | ||
278 | .brightness_get = object##_led_get, \ | ||
279 | .max_brightness = max \ | ||
280 | } | ||
281 | 232 | ||
282 | ASUS_LED(mled, "mail", 1); | 233 | acpi_handle handle; /* the handle of the hotk device */ |
283 | ASUS_LED(tled, "touchpad", 1); | 234 | u32 ledd_status; /* status of the LED display */ |
284 | ASUS_LED(rled, "record", 1); | 235 | u8 light_level; /* light sensor level */ |
285 | ASUS_LED(pled, "phone", 1); | 236 | u8 light_switch; /* light sensor switch value */ |
286 | ASUS_LED(gled, "gaming", 1); | 237 | u16 event_count[128]; /* count for each event TODO make this better */ |
287 | ASUS_LED(kled, "kbd_backlight", 3); | 238 | u16 *keycode_map; |
288 | |||
289 | struct key_entry { | ||
290 | char type; | ||
291 | u8 code; | ||
292 | u16 keycode; | ||
293 | }; | 239 | }; |
294 | 240 | ||
295 | enum { KE_KEY, KE_END }; | 241 | static const struct key_entry asus_keymap[] = { |
296 | 242 | /* Lenovo SL Specific keycodes */ | |
297 | static struct key_entry asus_keymap[] = { | 243 | {KE_KEY, 0x02, { KEY_SCREENLOCK } }, |
298 | {KE_KEY, 0x02, KEY_SCREENLOCK}, | 244 | {KE_KEY, 0x05, { KEY_WLAN } }, |
299 | {KE_KEY, 0x05, KEY_WLAN}, | 245 | {KE_KEY, 0x08, { KEY_F13 } }, |
300 | {KE_KEY, 0x08, KEY_F13}, | 246 | {KE_KEY, 0x17, { KEY_ZOOM } }, |
301 | {KE_KEY, 0x17, KEY_ZOOM}, | 247 | {KE_KEY, 0x1f, { KEY_BATTERY } }, |
302 | {KE_KEY, 0x1f, KEY_BATTERY}, | 248 | /* End of Lenovo SL Specific keycodes */ |
303 | {KE_KEY, 0x30, KEY_VOLUMEUP}, | 249 | {KE_KEY, 0x30, { KEY_VOLUMEUP } }, |
304 | {KE_KEY, 0x31, KEY_VOLUMEDOWN}, | 250 | {KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, |
305 | {KE_KEY, 0x32, KEY_MUTE}, | 251 | {KE_KEY, 0x32, { KEY_MUTE } }, |
306 | {KE_KEY, 0x33, KEY_SWITCHVIDEOMODE}, | 252 | {KE_KEY, 0x33, { KEY_SWITCHVIDEOMODE } }, |
307 | {KE_KEY, 0x34, KEY_SWITCHVIDEOMODE}, | 253 | {KE_KEY, 0x34, { KEY_SWITCHVIDEOMODE } }, |
308 | {KE_KEY, 0x40, KEY_PREVIOUSSONG}, | 254 | {KE_KEY, 0x40, { KEY_PREVIOUSSONG } }, |
309 | {KE_KEY, 0x41, KEY_NEXTSONG}, | 255 | {KE_KEY, 0x41, { KEY_NEXTSONG } }, |
310 | {KE_KEY, 0x43, KEY_STOPCD}, | 256 | {KE_KEY, 0x43, { KEY_STOPCD } }, |
311 | {KE_KEY, 0x45, KEY_PLAYPAUSE}, | 257 | {KE_KEY, 0x45, { KEY_PLAYPAUSE } }, |
312 | {KE_KEY, 0x4c, KEY_MEDIA}, | 258 | {KE_KEY, 0x4c, { KEY_MEDIA } }, |
313 | {KE_KEY, 0x50, KEY_EMAIL}, | 259 | {KE_KEY, 0x50, { KEY_EMAIL } }, |
314 | {KE_KEY, 0x51, KEY_WWW}, | 260 | {KE_KEY, 0x51, { KEY_WWW } }, |
315 | {KE_KEY, 0x55, KEY_CALC}, | 261 | {KE_KEY, 0x55, { KEY_CALC } }, |
316 | {KE_KEY, 0x5C, KEY_SCREENLOCK}, /* Screenlock */ | 262 | {KE_KEY, 0x5C, { KEY_SCREENLOCK } }, /* Screenlock */ |
317 | {KE_KEY, 0x5D, KEY_WLAN}, | 263 | {KE_KEY, 0x5D, { KEY_WLAN } }, |
318 | {KE_KEY, 0x5E, KEY_WLAN}, | 264 | {KE_KEY, 0x5E, { KEY_WLAN } }, |
319 | {KE_KEY, 0x5F, KEY_WLAN}, | 265 | {KE_KEY, 0x5F, { KEY_WLAN } }, |
320 | {KE_KEY, 0x60, KEY_SWITCHVIDEOMODE}, | 266 | {KE_KEY, 0x60, { KEY_SWITCHVIDEOMODE } }, |
321 | {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE}, | 267 | {KE_KEY, 0x61, { KEY_SWITCHVIDEOMODE } }, |
322 | {KE_KEY, 0x62, KEY_SWITCHVIDEOMODE}, | 268 | {KE_KEY, 0x62, { KEY_SWITCHVIDEOMODE } }, |
323 | {KE_KEY, 0x63, KEY_SWITCHVIDEOMODE}, | 269 | {KE_KEY, 0x63, { KEY_SWITCHVIDEOMODE } }, |
324 | {KE_KEY, 0x6B, KEY_F13}, /* Lock Touchpad */ | 270 | {KE_KEY, 0x6B, { KEY_F13 } }, /* Lock Touchpad */ |
325 | {KE_KEY, 0x82, KEY_CAMERA}, | 271 | {KE_KEY, 0x7E, { KEY_BLUETOOTH } }, |
326 | {KE_KEY, 0x88, KEY_WLAN }, | 272 | {KE_KEY, 0x7D, { KEY_BLUETOOTH } }, |
327 | {KE_KEY, 0x8A, KEY_PROG1}, | 273 | {KE_KEY, 0x82, { KEY_CAMERA } }, |
328 | {KE_KEY, 0x95, KEY_MEDIA}, | 274 | {KE_KEY, 0x88, { KEY_WLAN } }, |
329 | {KE_KEY, 0x99, KEY_PHONE}, | 275 | {KE_KEY, 0x8A, { KEY_PROG1 } }, |
330 | {KE_KEY, 0xc4, KEY_KBDILLUMUP}, | 276 | {KE_KEY, 0x95, { KEY_MEDIA } }, |
331 | {KE_KEY, 0xc5, KEY_KBDILLUMDOWN}, | 277 | {KE_KEY, 0x99, { KEY_PHONE } }, |
278 | {KE_KEY, 0xc4, { KEY_KBDILLUMUP } }, | ||
279 | {KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } }, | ||
332 | {KE_END, 0}, | 280 | {KE_END, 0}, |
333 | }; | 281 | }; |
334 | 282 | ||
283 | |||
335 | /* | 284 | /* |
336 | * This function evaluates an ACPI method, given an int as parameter, the | 285 | * This function evaluates an ACPI method, given an int as parameter, the |
337 | * method is searched within the scope of the handle, can be NULL. The output | 286 | * method is searched within the scope of the handle, can be NULL. The output |
@@ -339,8 +288,8 @@ static struct key_entry asus_keymap[] = { | |||
339 | * | 288 | * |
340 | * returns 0 if write is successful, -1 else. | 289 | * returns 0 if write is successful, -1 else. |
341 | */ | 290 | */ |
342 | static int write_acpi_int(acpi_handle handle, const char *method, int val, | 291 | static int write_acpi_int_ret(acpi_handle handle, const char *method, int val, |
343 | struct acpi_buffer *output) | 292 | struct acpi_buffer *output) |
344 | { | 293 | { |
345 | struct acpi_object_list params; /* list of input parameters (an int) */ | 294 | struct acpi_object_list params; /* list of input parameters (an int) */ |
346 | union acpi_object in_obj; /* the only param we use */ | 295 | union acpi_object in_obj; /* the only param we use */ |
@@ -361,102 +310,82 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, | |||
361 | return -1; | 310 | return -1; |
362 | } | 311 | } |
363 | 312 | ||
364 | static int read_wireless_status(int mask) | 313 | static int write_acpi_int(acpi_handle handle, const char *method, int val) |
365 | { | 314 | { |
366 | unsigned long long status; | 315 | return write_acpi_int_ret(handle, method, val, NULL); |
367 | acpi_status rv = AE_OK; | 316 | } |
317 | |||
318 | static int acpi_check_handle(acpi_handle handle, const char *method, | ||
319 | acpi_handle *ret) | ||
320 | { | ||
321 | acpi_status status; | ||
368 | 322 | ||
369 | if (!wireless_status_handle) | 323 | if (method == NULL) |
370 | return (hotk->status & mask) ? 1 : 0; | 324 | return -ENODEV; |
371 | 325 | ||
372 | rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status); | 326 | if (ret) |
373 | if (ACPI_FAILURE(rv)) | 327 | status = acpi_get_handle(handle, (char *)method, |
374 | pr_warning("Error reading Wireless status\n"); | 328 | ret); |
375 | else | 329 | else { |
376 | return (status & mask) ? 1 : 0; | 330 | acpi_handle dummy; |
377 | 331 | ||
378 | return (hotk->status & mask) ? 1 : 0; | 332 | status = acpi_get_handle(handle, (char *)method, |
333 | &dummy); | ||
334 | } | ||
335 | |||
336 | if (status != AE_OK) { | ||
337 | if (ret) | ||
338 | pr_warning("Error finding %s\n", method); | ||
339 | return -ENODEV; | ||
340 | } | ||
341 | return 0; | ||
379 | } | 342 | } |
380 | 343 | ||
381 | static int read_gps_status(void) | 344 | /* Generic LED function */ |
345 | static int asus_led_set(struct asus_laptop *asus, const char *method, | ||
346 | int value) | ||
382 | { | 347 | { |
383 | unsigned long long status; | 348 | if (!strcmp(method, METHOD_MLED)) |
384 | acpi_status rv = AE_OK; | 349 | value = !value; |
385 | 350 | else if (!strcmp(method, METHOD_GLED)) | |
386 | rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status); | 351 | value = !value + 1; |
387 | if (ACPI_FAILURE(rv)) | ||
388 | pr_warning("Error reading GPS status\n"); | ||
389 | else | 352 | else |
390 | return status ? 1 : 0; | 353 | value = !!value; |
391 | 354 | ||
392 | return (hotk->status & GPS_ON) ? 1 : 0; | 355 | return write_acpi_int(asus->handle, method, value); |
393 | } | 356 | } |
394 | 357 | ||
395 | /* Generic LED functions */ | 358 | /* |
396 | static int read_status(int mask) | 359 | * LEDs |
360 | */ | ||
361 | /* /sys/class/led handlers */ | ||
362 | static void asus_led_cdev_set(struct led_classdev *led_cdev, | ||
363 | enum led_brightness value) | ||
397 | { | 364 | { |
398 | /* There is a special method for both wireless devices */ | 365 | struct asus_led *led = container_of(led_cdev, struct asus_led, led); |
399 | if (mask == BT_ON || mask == WL_ON) | 366 | struct asus_laptop *asus = led->asus; |
400 | return read_wireless_status(mask); | ||
401 | else if (mask == GPS_ON) | ||
402 | return read_gps_status(); | ||
403 | 367 | ||
404 | return (hotk->status & mask) ? 1 : 0; | 368 | led->wk = !!value; |
369 | queue_work(asus->led_workqueue, &led->work); | ||
405 | } | 370 | } |
406 | 371 | ||
407 | static void write_status(acpi_handle handle, int out, int mask) | 372 | static void asus_led_cdev_update(struct work_struct *work) |
408 | { | 373 | { |
409 | hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask); | 374 | struct asus_led *led = container_of(work, struct asus_led, work); |
410 | 375 | struct asus_laptop *asus = led->asus; | |
411 | switch (mask) { | ||
412 | case MLED_ON: | ||
413 | out = !(out & 0x1); | ||
414 | break; | ||
415 | case GLED_ON: | ||
416 | out = (out & 0x1) + 1; | ||
417 | break; | ||
418 | case GPS_ON: | ||
419 | handle = (out) ? gps_on_handle : gps_off_handle; | ||
420 | out = 0x02; | ||
421 | break; | ||
422 | default: | ||
423 | out &= 0x1; | ||
424 | break; | ||
425 | } | ||
426 | 376 | ||
427 | if (write_acpi_int(handle, NULL, out, NULL)) | 377 | asus_led_set(asus, led->method, led->wk); |
428 | pr_warning(" write failed %x\n", mask); | ||
429 | } | 378 | } |
430 | 379 | ||
431 | /* /sys/class/led handlers */ | 380 | static enum led_brightness asus_led_cdev_get(struct led_classdev *led_cdev) |
432 | #define ASUS_LED_HANDLER(object, mask) \ | 381 | { |
433 | static void object##_led_set(struct led_classdev *led_cdev, \ | 382 | return led_cdev->brightness; |
434 | enum led_brightness value) \ | 383 | } |
435 | { \ | ||
436 | object##_led_wk = (value > 0) ? 1 : 0; \ | ||
437 | queue_work(led_workqueue, &object##_led_work); \ | ||
438 | } \ | ||
439 | static void object##_led_update(struct work_struct *ignored) \ | ||
440 | { \ | ||
441 | int value = object##_led_wk; \ | ||
442 | write_status(object##_set_handle, value, (mask)); \ | ||
443 | } \ | ||
444 | static enum led_brightness object##_led_get( \ | ||
445 | struct led_classdev *led_cdev) \ | ||
446 | { \ | ||
447 | return led_cdev->brightness; \ | ||
448 | } | ||
449 | |||
450 | ASUS_LED_HANDLER(mled, MLED_ON); | ||
451 | ASUS_LED_HANDLER(pled, PLED_ON); | ||
452 | ASUS_LED_HANDLER(rled, RLED_ON); | ||
453 | ASUS_LED_HANDLER(tled, TLED_ON); | ||
454 | ASUS_LED_HANDLER(gled, GLED_ON); | ||
455 | 384 | ||
456 | /* | 385 | /* |
457 | * Keyboard backlight | 386 | * Keyboard backlight (also a LED) |
458 | */ | 387 | */ |
459 | static int get_kled_lvl(void) | 388 | static int asus_kled_lvl(struct asus_laptop *asus) |
460 | { | 389 | { |
461 | unsigned long long kblv; | 390 | unsigned long long kblv; |
462 | struct acpi_object_list params; | 391 | struct acpi_object_list params; |
@@ -468,75 +397,183 @@ static int get_kled_lvl(void) | |||
468 | in_obj.type = ACPI_TYPE_INTEGER; | 397 | in_obj.type = ACPI_TYPE_INTEGER; |
469 | in_obj.integer.value = 2; | 398 | in_obj.integer.value = 2; |
470 | 399 | ||
471 | rv = acpi_evaluate_integer(kled_get_handle, NULL, ¶ms, &kblv); | 400 | rv = acpi_evaluate_integer(asus->handle, METHOD_KBD_LIGHT_GET, |
401 | ¶ms, &kblv); | ||
472 | if (ACPI_FAILURE(rv)) { | 402 | if (ACPI_FAILURE(rv)) { |
473 | pr_warning("Error reading kled level\n"); | 403 | pr_warning("Error reading kled level\n"); |
474 | return 0; | 404 | return -ENODEV; |
475 | } | 405 | } |
476 | return kblv; | 406 | return kblv; |
477 | } | 407 | } |
478 | 408 | ||
479 | static int set_kled_lvl(int kblv) | 409 | static int asus_kled_set(struct asus_laptop *asus, int kblv) |
480 | { | 410 | { |
481 | if (kblv > 0) | 411 | if (kblv > 0) |
482 | kblv = (1 << 7) | (kblv & 0x7F); | 412 | kblv = (1 << 7) | (kblv & 0x7F); |
483 | else | 413 | else |
484 | kblv = 0; | 414 | kblv = 0; |
485 | 415 | ||
486 | if (write_acpi_int(kled_set_handle, NULL, kblv, NULL)) { | 416 | if (write_acpi_int(asus->handle, METHOD_KBD_LIGHT_SET, kblv)) { |
487 | pr_warning("Keyboard LED display write failed\n"); | 417 | pr_warning("Keyboard LED display write failed\n"); |
488 | return -EINVAL; | 418 | return -EINVAL; |
489 | } | 419 | } |
490 | return 0; | 420 | return 0; |
491 | } | 421 | } |
492 | 422 | ||
493 | static void kled_led_set(struct led_classdev *led_cdev, | 423 | static void asus_kled_cdev_set(struct led_classdev *led_cdev, |
494 | enum led_brightness value) | 424 | enum led_brightness value) |
495 | { | 425 | { |
496 | kled_led_wk = value; | 426 | struct asus_led *led = container_of(led_cdev, struct asus_led, led); |
497 | queue_work(led_workqueue, &kled_led_work); | 427 | struct asus_laptop *asus = led->asus; |
428 | |||
429 | led->wk = value; | ||
430 | queue_work(asus->led_workqueue, &led->work); | ||
498 | } | 431 | } |
499 | 432 | ||
500 | static void kled_led_update(struct work_struct *ignored) | 433 | static void asus_kled_cdev_update(struct work_struct *work) |
501 | { | 434 | { |
502 | set_kled_lvl(kled_led_wk); | 435 | struct asus_led *led = container_of(work, struct asus_led, work); |
436 | struct asus_laptop *asus = led->asus; | ||
437 | |||
438 | asus_kled_set(asus, led->wk); | ||
503 | } | 439 | } |
504 | 440 | ||
505 | static enum led_brightness kled_led_get(struct led_classdev *led_cdev) | 441 | static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev) |
506 | { | 442 | { |
507 | return get_kled_lvl(); | 443 | struct asus_led *led = container_of(led_cdev, struct asus_led, led); |
444 | struct asus_laptop *asus = led->asus; | ||
445 | |||
446 | return asus_kled_lvl(asus); | ||
508 | } | 447 | } |
509 | 448 | ||
510 | static int get_lcd_state(void) | 449 | static void asus_led_exit(struct asus_laptop *asus) |
511 | { | 450 | { |
512 | return read_status(LCD_ON); | 451 | if (asus->mled.led.dev) |
452 | led_classdev_unregister(&asus->mled.led); | ||
453 | if (asus->tled.led.dev) | ||
454 | led_classdev_unregister(&asus->tled.led); | ||
455 | if (asus->pled.led.dev) | ||
456 | led_classdev_unregister(&asus->pled.led); | ||
457 | if (asus->rled.led.dev) | ||
458 | led_classdev_unregister(&asus->rled.led); | ||
459 | if (asus->gled.led.dev) | ||
460 | led_classdev_unregister(&asus->gled.led); | ||
461 | if (asus->kled.led.dev) | ||
462 | led_classdev_unregister(&asus->kled.led); | ||
463 | if (asus->led_workqueue) { | ||
464 | destroy_workqueue(asus->led_workqueue); | ||
465 | asus->led_workqueue = NULL; | ||
466 | } | ||
513 | } | 467 | } |
514 | 468 | ||
515 | static int set_lcd_state(int value) | 469 | /* Ugly macro, need to fix that later */ |
470 | static int asus_led_register(struct asus_laptop *asus, | ||
471 | struct asus_led *led, | ||
472 | const char *name, const char *method) | ||
473 | { | ||
474 | struct led_classdev *led_cdev = &led->led; | ||
475 | |||
476 | if (!method || acpi_check_handle(asus->handle, method, NULL)) | ||
477 | return 0; /* Led not present */ | ||
478 | |||
479 | led->asus = asus; | ||
480 | led->method = method; | ||
481 | |||
482 | INIT_WORK(&led->work, asus_led_cdev_update); | ||
483 | led_cdev->name = name; | ||
484 | led_cdev->brightness_set = asus_led_cdev_set; | ||
485 | led_cdev->brightness_get = asus_led_cdev_get; | ||
486 | led_cdev->max_brightness = 1; | ||
487 | return led_classdev_register(&asus->platform_device->dev, led_cdev); | ||
488 | } | ||
489 | |||
490 | static int asus_led_init(struct asus_laptop *asus) | ||
491 | { | ||
492 | int r; | ||
493 | |||
494 | /* | ||
495 | * Functions that actually update the LED's are called from a | ||
496 | * workqueue. By doing this as separate work rather than when the LED | ||
497 | * subsystem asks, we avoid messing with the Asus ACPI stuff during a | ||
498 | * potentially bad time, such as a timer interrupt. | ||
499 | */ | ||
500 | asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); | ||
501 | if (!asus->led_workqueue) | ||
502 | return -ENOMEM; | ||
503 | |||
504 | r = asus_led_register(asus, &asus->mled, "asus::mail", METHOD_MLED); | ||
505 | if (r) | ||
506 | goto error; | ||
507 | r = asus_led_register(asus, &asus->tled, "asus::touchpad", METHOD_TLED); | ||
508 | if (r) | ||
509 | goto error; | ||
510 | r = asus_led_register(asus, &asus->rled, "asus::record", METHOD_RLED); | ||
511 | if (r) | ||
512 | goto error; | ||
513 | r = asus_led_register(asus, &asus->pled, "asus::phone", METHOD_PLED); | ||
514 | if (r) | ||
515 | goto error; | ||
516 | r = asus_led_register(asus, &asus->gled, "asus::gaming", METHOD_GLED); | ||
517 | if (r) | ||
518 | goto error; | ||
519 | if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL) && | ||
520 | !acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_GET, NULL)) { | ||
521 | struct asus_led *led = &asus->kled; | ||
522 | struct led_classdev *cdev = &led->led; | ||
523 | |||
524 | led->asus = asus; | ||
525 | |||
526 | INIT_WORK(&led->work, asus_kled_cdev_update); | ||
527 | cdev->name = "asus::kbd_backlight"; | ||
528 | cdev->brightness_set = asus_kled_cdev_set; | ||
529 | cdev->brightness_get = asus_kled_cdev_get; | ||
530 | cdev->max_brightness = 3; | ||
531 | r = led_classdev_register(&asus->platform_device->dev, cdev); | ||
532 | } | ||
533 | error: | ||
534 | if (r) | ||
535 | asus_led_exit(asus); | ||
536 | return r; | ||
537 | } | ||
538 | |||
539 | /* | ||
540 | * Backlight device | ||
541 | */ | ||
542 | static int asus_lcd_status(struct asus_laptop *asus) | ||
543 | { | ||
544 | return asus->lcd_state; | ||
545 | } | ||
546 | |||
547 | static int asus_lcd_set(struct asus_laptop *asus, int value) | ||
516 | { | 548 | { |
517 | int lcd = 0; | 549 | int lcd = 0; |
518 | acpi_status status = 0; | 550 | acpi_status status = 0; |
519 | 551 | ||
520 | lcd = value ? 1 : 0; | 552 | lcd = !!value; |
521 | 553 | ||
522 | if (lcd == get_lcd_state()) | 554 | if (lcd == asus_lcd_status(asus)) |
523 | return 0; | 555 | return 0; |
524 | 556 | ||
525 | if (lcd_switch_handle) { | 557 | if (!lcd_switch_handle) |
526 | status = acpi_evaluate_object(lcd_switch_handle, | 558 | return -ENODEV; |
527 | NULL, NULL, NULL); | 559 | |
560 | status = acpi_evaluate_object(lcd_switch_handle, | ||
561 | NULL, NULL, NULL); | ||
528 | 562 | ||
529 | if (ACPI_FAILURE(status)) | 563 | if (ACPI_FAILURE(status)) { |
530 | pr_warning("Error switching LCD\n"); | 564 | pr_warning("Error switching LCD\n"); |
565 | return -ENODEV; | ||
531 | } | 566 | } |
532 | 567 | ||
533 | write_status(NULL, lcd, LCD_ON); | 568 | asus->lcd_state = lcd; |
534 | return 0; | 569 | return 0; |
535 | } | 570 | } |
536 | 571 | ||
537 | static void lcd_blank(int blank) | 572 | static void lcd_blank(struct asus_laptop *asus, int blank) |
538 | { | 573 | { |
539 | struct backlight_device *bd = asus_backlight_device; | 574 | struct backlight_device *bd = asus->backlight_device; |
575 | |||
576 | asus->lcd_state = (blank == FB_BLANK_UNBLANK); | ||
540 | 577 | ||
541 | if (bd) { | 578 | if (bd) { |
542 | bd->props.power = blank; | 579 | bd->props.power = blank; |
@@ -544,44 +581,91 @@ static void lcd_blank(int blank) | |||
544 | } | 581 | } |
545 | } | 582 | } |
546 | 583 | ||
547 | static int read_brightness(struct backlight_device *bd) | 584 | static int asus_read_brightness(struct backlight_device *bd) |
548 | { | 585 | { |
586 | struct asus_laptop *asus = bl_get_data(bd); | ||
549 | unsigned long long value; | 587 | unsigned long long value; |
550 | acpi_status rv = AE_OK; | 588 | acpi_status rv = AE_OK; |
551 | 589 | ||
552 | rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value); | 590 | rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET, |
591 | NULL, &value); | ||
553 | if (ACPI_FAILURE(rv)) | 592 | if (ACPI_FAILURE(rv)) |
554 | pr_warning("Error reading brightness\n"); | 593 | pr_warning("Error reading brightness\n"); |
555 | 594 | ||
556 | return value; | 595 | return value; |
557 | } | 596 | } |
558 | 597 | ||
559 | static int set_brightness(struct backlight_device *bd, int value) | 598 | static int asus_set_brightness(struct backlight_device *bd, int value) |
560 | { | 599 | { |
561 | int ret = 0; | 600 | struct asus_laptop *asus = bl_get_data(bd); |
562 | |||
563 | value = (0 < value) ? ((15 < value) ? 15 : value) : 0; | ||
564 | /* 0 <= value <= 15 */ | ||
565 | 601 | ||
566 | if (write_acpi_int(brightness_set_handle, NULL, value, NULL)) { | 602 | if (write_acpi_int(asus->handle, METHOD_BRIGHTNESS_SET, value)) { |
567 | pr_warning("Error changing brightness\n"); | 603 | pr_warning("Error changing brightness\n"); |
568 | ret = -EIO; | 604 | return -EIO; |
569 | } | 605 | } |
570 | 606 | return 0; | |
571 | return ret; | ||
572 | } | 607 | } |
573 | 608 | ||
574 | static int update_bl_status(struct backlight_device *bd) | 609 | static int update_bl_status(struct backlight_device *bd) |
575 | { | 610 | { |
611 | struct asus_laptop *asus = bl_get_data(bd); | ||
576 | int rv; | 612 | int rv; |
577 | int value = bd->props.brightness; | 613 | int value = bd->props.brightness; |
578 | 614 | ||
579 | rv = set_brightness(bd, value); | 615 | rv = asus_set_brightness(bd, value); |
580 | if (rv) | 616 | if (rv) |
581 | return rv; | 617 | return rv; |
582 | 618 | ||
583 | value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0; | 619 | value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0; |
584 | return set_lcd_state(value); | 620 | return asus_lcd_set(asus, value); |
621 | } | ||
622 | |||
623 | static struct backlight_ops asusbl_ops = { | ||
624 | .get_brightness = asus_read_brightness, | ||
625 | .update_status = update_bl_status, | ||
626 | }; | ||
627 | |||
628 | static int asus_backlight_notify(struct asus_laptop *asus) | ||
629 | { | ||
630 | struct backlight_device *bd = asus->backlight_device; | ||
631 | int old = bd->props.brightness; | ||
632 | |||
633 | backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY); | ||
634 | |||
635 | return old; | ||
636 | } | ||
637 | |||
638 | static int asus_backlight_init(struct asus_laptop *asus) | ||
639 | { | ||
640 | struct backlight_device *bd; | ||
641 | struct device *dev = &asus->platform_device->dev; | ||
642 | |||
643 | if (!acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) && | ||
644 | !acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL) && | ||
645 | lcd_switch_handle) { | ||
646 | bd = backlight_device_register(ASUS_LAPTOP_FILE, dev, | ||
647 | asus, &asusbl_ops); | ||
648 | if (IS_ERR(bd)) { | ||
649 | pr_err("Could not register asus backlight device\n"); | ||
650 | asus->backlight_device = NULL; | ||
651 | return PTR_ERR(bd); | ||
652 | } | ||
653 | |||
654 | asus->backlight_device = bd; | ||
655 | |||
656 | bd->props.max_brightness = 15; | ||
657 | bd->props.power = FB_BLANK_UNBLANK; | ||
658 | bd->props.brightness = asus_read_brightness(bd); | ||
659 | backlight_update_status(bd); | ||
660 | } | ||
661 | return 0; | ||
662 | } | ||
663 | |||
664 | static void asus_backlight_exit(struct asus_laptop *asus) | ||
665 | { | ||
666 | if (asus->backlight_device) | ||
667 | backlight_device_unregister(asus->backlight_device); | ||
668 | asus->backlight_device = NULL; | ||
585 | } | 669 | } |
586 | 670 | ||
587 | /* | 671 | /* |
@@ -596,25 +680,26 @@ static int update_bl_status(struct backlight_device *bd) | |||
596 | static ssize_t show_infos(struct device *dev, | 680 | static ssize_t show_infos(struct device *dev, |
597 | struct device_attribute *attr, char *page) | 681 | struct device_attribute *attr, char *page) |
598 | { | 682 | { |
683 | struct asus_laptop *asus = dev_get_drvdata(dev); | ||
599 | int len = 0; | 684 | int len = 0; |
600 | unsigned long long temp; | 685 | unsigned long long temp; |
601 | char buf[16]; /* enough for all info */ | 686 | char buf[16]; /* enough for all info */ |
602 | acpi_status rv = AE_OK; | 687 | acpi_status rv = AE_OK; |
603 | 688 | ||
604 | /* | 689 | /* |
605 | * We use the easy way, we don't care of off and count, so we don't set eof | 690 | * We use the easy way, we don't care of off and count, |
606 | * to 1 | 691 | * so we don't set eof to 1 |
607 | */ | 692 | */ |
608 | 693 | ||
609 | len += sprintf(page, ASUS_HOTK_NAME " " ASUS_LAPTOP_VERSION "\n"); | 694 | len += sprintf(page, ASUS_LAPTOP_NAME " " ASUS_LAPTOP_VERSION "\n"); |
610 | len += sprintf(page + len, "Model reference : %s\n", hotk->name); | 695 | len += sprintf(page + len, "Model reference : %s\n", asus->name); |
611 | /* | 696 | /* |
612 | * The SFUN method probably allows the original driver to get the list | 697 | * The SFUN method probably allows the original driver to get the list |
613 | * of features supported by a given model. For now, 0x0100 or 0x0800 | 698 | * of features supported by a given model. For now, 0x0100 or 0x0800 |
614 | * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. | 699 | * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. |
615 | * The significance of others is yet to be found. | 700 | * The significance of others is yet to be found. |
616 | */ | 701 | */ |
617 | rv = acpi_evaluate_integer(hotk->handle, "SFUN", NULL, &temp); | 702 | rv = acpi_evaluate_integer(asus->handle, "SFUN", NULL, &temp); |
618 | if (!ACPI_FAILURE(rv)) | 703 | if (!ACPI_FAILURE(rv)) |
619 | len += sprintf(page + len, "SFUN value : %#x\n", | 704 | len += sprintf(page + len, "SFUN value : %#x\n", |
620 | (uint) temp); | 705 | (uint) temp); |
@@ -624,7 +709,7 @@ static ssize_t show_infos(struct device *dev, | |||
624 | * The significance of others is yet to be found. | 709 | * The significance of others is yet to be found. |
625 | * If we don't find the method, we assume the device are present. | 710 | * If we don't find the method, we assume the device are present. |
626 | */ | 711 | */ |
627 | rv = acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &temp); | 712 | rv = acpi_evaluate_integer(asus->handle, "HRWS", NULL, &temp); |
628 | if (!ACPI_FAILURE(rv)) | 713 | if (!ACPI_FAILURE(rv)) |
629 | len += sprintf(page + len, "HRWS value : %#x\n", | 714 | len += sprintf(page + len, "HRWS value : %#x\n", |
630 | (uint) temp); | 715 | (uint) temp); |
@@ -635,26 +720,26 @@ static ssize_t show_infos(struct device *dev, | |||
635 | * Note: since not all the laptops provide this method, errors are | 720 | * Note: since not all the laptops provide this method, errors are |
636 | * silently ignored. | 721 | * silently ignored. |
637 | */ | 722 | */ |
638 | rv = acpi_evaluate_integer(hotk->handle, "ASYM", NULL, &temp); | 723 | rv = acpi_evaluate_integer(asus->handle, "ASYM", NULL, &temp); |
639 | if (!ACPI_FAILURE(rv)) | 724 | if (!ACPI_FAILURE(rv)) |
640 | len += sprintf(page + len, "ASYM value : %#x\n", | 725 | len += sprintf(page + len, "ASYM value : %#x\n", |
641 | (uint) temp); | 726 | (uint) temp); |
642 | if (asus_info) { | 727 | if (asus->dsdt_info) { |
643 | snprintf(buf, 16, "%d", asus_info->length); | 728 | snprintf(buf, 16, "%d", asus->dsdt_info->length); |
644 | len += sprintf(page + len, "DSDT length : %s\n", buf); | 729 | len += sprintf(page + len, "DSDT length : %s\n", buf); |
645 | snprintf(buf, 16, "%d", asus_info->checksum); | 730 | snprintf(buf, 16, "%d", asus->dsdt_info->checksum); |
646 | len += sprintf(page + len, "DSDT checksum : %s\n", buf); | 731 | len += sprintf(page + len, "DSDT checksum : %s\n", buf); |
647 | snprintf(buf, 16, "%d", asus_info->revision); | 732 | snprintf(buf, 16, "%d", asus->dsdt_info->revision); |
648 | len += sprintf(page + len, "DSDT revision : %s\n", buf); | 733 | len += sprintf(page + len, "DSDT revision : %s\n", buf); |
649 | snprintf(buf, 7, "%s", asus_info->oem_id); | 734 | snprintf(buf, 7, "%s", asus->dsdt_info->oem_id); |
650 | len += sprintf(page + len, "OEM id : %s\n", buf); | 735 | len += sprintf(page + len, "OEM id : %s\n", buf); |
651 | snprintf(buf, 9, "%s", asus_info->oem_table_id); | 736 | snprintf(buf, 9, "%s", asus->dsdt_info->oem_table_id); |
652 | len += sprintf(page + len, "OEM table id : %s\n", buf); | 737 | len += sprintf(page + len, "OEM table id : %s\n", buf); |
653 | snprintf(buf, 16, "%x", asus_info->oem_revision); | 738 | snprintf(buf, 16, "%x", asus->dsdt_info->oem_revision); |
654 | len += sprintf(page + len, "OEM revision : 0x%s\n", buf); | 739 | len += sprintf(page + len, "OEM revision : 0x%s\n", buf); |
655 | snprintf(buf, 5, "%s", asus_info->asl_compiler_id); | 740 | snprintf(buf, 5, "%s", asus->dsdt_info->asl_compiler_id); |
656 | len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); | 741 | len += sprintf(page + len, "ASL comp vendor id : %s\n", buf); |
657 | snprintf(buf, 16, "%x", asus_info->asl_compiler_revision); | 742 | snprintf(buf, 16, "%x", asus->dsdt_info->asl_compiler_revision); |
658 | len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); | 743 | len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf); |
659 | } | 744 | } |
660 | 745 | ||
@@ -672,8 +757,9 @@ static int parse_arg(const char *buf, unsigned long count, int *val) | |||
672 | return count; | 757 | return count; |
673 | } | 758 | } |
674 | 759 | ||
675 | static ssize_t store_status(const char *buf, size_t count, | 760 | static ssize_t sysfs_acpi_set(struct asus_laptop *asus, |
676 | acpi_handle handle, int mask) | 761 | const char *buf, size_t count, |
762 | const char *method) | ||
677 | { | 763 | { |
678 | int rv, value; | 764 | int rv, value; |
679 | int out = 0; | 765 | int out = 0; |
@@ -682,8 +768,8 @@ static ssize_t store_status(const char *buf, size_t count, | |||
682 | if (rv > 0) | 768 | if (rv > 0) |
683 | out = value ? 1 : 0; | 769 | out = value ? 1 : 0; |
684 | 770 | ||
685 | write_status(handle, out, mask); | 771 | if (write_acpi_int(asus->handle, method, value)) |
686 | 772 | return -ENODEV; | |
687 | return rv; | 773 | return rv; |
688 | } | 774 | } |
689 | 775 | ||
@@ -693,67 +779,116 @@ static ssize_t store_status(const char *buf, size_t count, | |||
693 | static ssize_t show_ledd(struct device *dev, | 779 | static ssize_t show_ledd(struct device *dev, |
694 | struct device_attribute *attr, char *buf) | 780 | struct device_attribute *attr, char *buf) |
695 | { | 781 | { |
696 | return sprintf(buf, "0x%08x\n", hotk->ledd_status); | 782 | struct asus_laptop *asus = dev_get_drvdata(dev); |
783 | |||
784 | return sprintf(buf, "0x%08x\n", asus->ledd_status); | ||
697 | } | 785 | } |
698 | 786 | ||
699 | static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, | 787 | static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, |
700 | const char *buf, size_t count) | 788 | const char *buf, size_t count) |
701 | { | 789 | { |
790 | struct asus_laptop *asus = dev_get_drvdata(dev); | ||
702 | int rv, value; | 791 | int rv, value; |
703 | 792 | ||
704 | rv = parse_arg(buf, count, &value); | 793 | rv = parse_arg(buf, count, &value); |
705 | if (rv > 0) { | 794 | if (rv > 0) { |
706 | if (write_acpi_int(ledd_set_handle, NULL, value, NULL)) | 795 | if (write_acpi_int(asus->handle, METHOD_LEDD, value)) |
707 | pr_warning("LED display write failed\n"); | 796 | pr_warning("LED display write failed\n"); |
708 | else | 797 | else |
709 | hotk->ledd_status = (u32) value; | 798 | asus->ledd_status = (u32) value; |
710 | } | 799 | } |
711 | return rv; | 800 | return rv; |
712 | } | 801 | } |
713 | 802 | ||
714 | /* | 803 | /* |
804 | * Wireless | ||
805 | */ | ||
806 | static int asus_wireless_status(struct asus_laptop *asus, int mask) | ||
807 | { | ||
808 | unsigned long long status; | ||
809 | acpi_status rv = AE_OK; | ||
810 | |||
811 | if (!asus->have_rsts) | ||
812 | return (asus->wireless_status & mask) ? 1 : 0; | ||
813 | |||
814 | rv = acpi_evaluate_integer(asus->handle, METHOD_WL_STATUS, | ||
815 | NULL, &status); | ||
816 | if (ACPI_FAILURE(rv)) { | ||
817 | pr_warning("Error reading Wireless status\n"); | ||
818 | return -EINVAL; | ||
819 | } | ||
820 | return !!(status & mask); | ||
821 | } | ||
822 | |||
823 | /* | ||
715 | * WLAN | 824 | * WLAN |
716 | */ | 825 | */ |
826 | static int asus_wlan_set(struct asus_laptop *asus, int status) | ||
827 | { | ||
828 | if (write_acpi_int(asus->handle, METHOD_WLAN, !!status)) { | ||
829 | pr_warning("Error setting wlan status to %d", status); | ||
830 | return -EIO; | ||
831 | } | ||
832 | return 0; | ||
833 | } | ||
834 | |||
717 | static ssize_t show_wlan(struct device *dev, | 835 | static ssize_t show_wlan(struct device *dev, |
718 | struct device_attribute *attr, char *buf) | 836 | struct device_attribute *attr, char *buf) |
719 | { | 837 | { |
720 | return sprintf(buf, "%d\n", read_status(WL_ON)); | 838 | struct asus_laptop *asus = dev_get_drvdata(dev); |
839 | |||
840 | return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS)); | ||
721 | } | 841 | } |
722 | 842 | ||
723 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, | 843 | static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, |
724 | const char *buf, size_t count) | 844 | const char *buf, size_t count) |
725 | { | 845 | { |
726 | return store_status(buf, count, wl_switch_handle, WL_ON); | 846 | struct asus_laptop *asus = dev_get_drvdata(dev); |
847 | |||
848 | return sysfs_acpi_set(asus, buf, count, METHOD_WLAN); | ||
727 | } | 849 | } |
728 | 850 | ||
729 | /* | 851 | /* |
730 | * Bluetooth | 852 | * Bluetooth |
731 | */ | 853 | */ |
854 | static int asus_bluetooth_set(struct asus_laptop *asus, int status) | ||
855 | { | ||
856 | if (write_acpi_int(asus->handle, METHOD_BLUETOOTH, !!status)) { | ||
857 | pr_warning("Error setting bluetooth status to %d", status); | ||
858 | return -EIO; | ||
859 | } | ||
860 | return 0; | ||
861 | } | ||
862 | |||
732 | static ssize_t show_bluetooth(struct device *dev, | 863 | static ssize_t show_bluetooth(struct device *dev, |
733 | struct device_attribute *attr, char *buf) | 864 | struct device_attribute *attr, char *buf) |
734 | { | 865 | { |
735 | return sprintf(buf, "%d\n", read_status(BT_ON)); | 866 | struct asus_laptop *asus = dev_get_drvdata(dev); |
867 | |||
868 | return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS)); | ||
736 | } | 869 | } |
737 | 870 | ||
738 | static ssize_t store_bluetooth(struct device *dev, | 871 | static ssize_t store_bluetooth(struct device *dev, |
739 | struct device_attribute *attr, const char *buf, | 872 | struct device_attribute *attr, const char *buf, |
740 | size_t count) | 873 | size_t count) |
741 | { | 874 | { |
742 | return store_status(buf, count, bt_switch_handle, BT_ON); | 875 | struct asus_laptop *asus = dev_get_drvdata(dev); |
876 | |||
877 | return sysfs_acpi_set(asus, buf, count, METHOD_BLUETOOTH); | ||
743 | } | 878 | } |
744 | 879 | ||
745 | /* | 880 | /* |
746 | * Display | 881 | * Display |
747 | */ | 882 | */ |
748 | static void set_display(int value) | 883 | static void asus_set_display(struct asus_laptop *asus, int value) |
749 | { | 884 | { |
750 | /* no sanity check needed for now */ | 885 | /* no sanity check needed for now */ |
751 | if (write_acpi_int(display_set_handle, NULL, value, NULL)) | 886 | if (write_acpi_int(asus->handle, METHOD_SWITCH_DISPLAY, value)) |
752 | pr_warning("Error setting display\n"); | 887 | pr_warning("Error setting display\n"); |
753 | return; | 888 | return; |
754 | } | 889 | } |
755 | 890 | ||
756 | static int read_display(void) | 891 | static int read_display(struct asus_laptop *asus) |
757 | { | 892 | { |
758 | unsigned long long value = 0; | 893 | unsigned long long value = 0; |
759 | acpi_status rv = AE_OK; | 894 | acpi_status rv = AE_OK; |
@@ -769,7 +904,7 @@ static int read_display(void) | |||
769 | pr_warning("Error reading display status\n"); | 904 | pr_warning("Error reading display status\n"); |
770 | } | 905 | } |
771 | 906 | ||
772 | value &= 0x0F; /* needed for some models, shouldn't hurt others */ | 907 | value &= 0x0F; /* needed for some models, shouldn't hurt others */ |
773 | 908 | ||
774 | return value; | 909 | return value; |
775 | } | 910 | } |
@@ -781,7 +916,11 @@ static int read_display(void) | |||
781 | static ssize_t show_disp(struct device *dev, | 916 | static ssize_t show_disp(struct device *dev, |
782 | struct device_attribute *attr, char *buf) | 917 | struct device_attribute *attr, char *buf) |
783 | { | 918 | { |
784 | return sprintf(buf, "%d\n", read_display()); | 919 | struct asus_laptop *asus = dev_get_drvdata(dev); |
920 | |||
921 | if (!display_get_handle) | ||
922 | return -ENODEV; | ||
923 | return sprintf(buf, "%d\n", read_display(asus)); | ||
785 | } | 924 | } |
786 | 925 | ||
787 | /* | 926 | /* |
@@ -794,65 +933,72 @@ static ssize_t show_disp(struct device *dev, | |||
794 | static ssize_t store_disp(struct device *dev, struct device_attribute *attr, | 933 | static ssize_t store_disp(struct device *dev, struct device_attribute *attr, |
795 | const char *buf, size_t count) | 934 | const char *buf, size_t count) |
796 | { | 935 | { |
936 | struct asus_laptop *asus = dev_get_drvdata(dev); | ||
797 | int rv, value; | 937 | int rv, value; |
798 | 938 | ||
799 | rv = parse_arg(buf, count, &value); | 939 | rv = parse_arg(buf, count, &value); |
800 | if (rv > 0) | 940 | if (rv > 0) |
801 | set_display(value); | 941 | asus_set_display(asus, value); |
802 | return rv; | 942 | return rv; |
803 | } | 943 | } |
804 | 944 | ||
805 | /* | 945 | /* |
806 | * Light Sens | 946 | * Light Sens |
807 | */ | 947 | */ |
808 | static void set_light_sens_switch(int value) | 948 | static void asus_als_switch(struct asus_laptop *asus, int value) |
809 | { | 949 | { |
810 | if (write_acpi_int(ls_switch_handle, NULL, value, NULL)) | 950 | if (write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value)) |
811 | pr_warning("Error setting light sensor switch\n"); | 951 | pr_warning("Error setting light sensor switch\n"); |
812 | hotk->light_switch = value; | 952 | asus->light_switch = value; |
813 | } | 953 | } |
814 | 954 | ||
815 | static ssize_t show_lssw(struct device *dev, | 955 | static ssize_t show_lssw(struct device *dev, |
816 | struct device_attribute *attr, char *buf) | 956 | struct device_attribute *attr, char *buf) |
817 | { | 957 | { |
818 | return sprintf(buf, "%d\n", hotk->light_switch); | 958 | struct asus_laptop *asus = dev_get_drvdata(dev); |
959 | |||
960 | return sprintf(buf, "%d\n", asus->light_switch); | ||
819 | } | 961 | } |
820 | 962 | ||
821 | static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, | 963 | static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, |
822 | const char *buf, size_t count) | 964 | const char *buf, size_t count) |
823 | { | 965 | { |
966 | struct asus_laptop *asus = dev_get_drvdata(dev); | ||
824 | int rv, value; | 967 | int rv, value; |
825 | 968 | ||
826 | rv = parse_arg(buf, count, &value); | 969 | rv = parse_arg(buf, count, &value); |
827 | if (rv > 0) | 970 | if (rv > 0) |
828 | set_light_sens_switch(value ? 1 : 0); | 971 | asus_als_switch(asus, value ? 1 : 0); |
829 | 972 | ||
830 | return rv; | 973 | return rv; |
831 | } | 974 | } |
832 | 975 | ||
833 | static void set_light_sens_level(int value) | 976 | static void asus_als_level(struct asus_laptop *asus, int value) |
834 | { | 977 | { |
835 | if (write_acpi_int(ls_level_handle, NULL, value, NULL)) | 978 | if (write_acpi_int(asus->handle, METHOD_ALS_LEVEL, value)) |
836 | pr_warning("Error setting light sensor level\n"); | 979 | pr_warning("Error setting light sensor level\n"); |
837 | hotk->light_level = value; | 980 | asus->light_level = value; |
838 | } | 981 | } |
839 | 982 | ||
840 | static ssize_t show_lslvl(struct device *dev, | 983 | static ssize_t show_lslvl(struct device *dev, |
841 | struct device_attribute *attr, char *buf) | 984 | struct device_attribute *attr, char *buf) |
842 | { | 985 | { |
843 | return sprintf(buf, "%d\n", hotk->light_level); | 986 | struct asus_laptop *asus = dev_get_drvdata(dev); |
987 | |||
988 | return sprintf(buf, "%d\n", asus->light_level); | ||
844 | } | 989 | } |
845 | 990 | ||
846 | static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | 991 | static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, |
847 | const char *buf, size_t count) | 992 | const char *buf, size_t count) |
848 | { | 993 | { |
994 | struct asus_laptop *asus = dev_get_drvdata(dev); | ||
849 | int rv, value; | 995 | int rv, value; |
850 | 996 | ||
851 | rv = parse_arg(buf, count, &value); | 997 | rv = parse_arg(buf, count, &value); |
852 | if (rv > 0) { | 998 | if (rv > 0) { |
853 | value = (0 < value) ? ((15 < value) ? 15 : value) : 0; | 999 | value = (0 < value) ? ((15 < value) ? 15 : value) : 0; |
854 | /* 0 <= value <= 15 */ | 1000 | /* 0 <= value <= 15 */ |
855 | set_light_sens_level(value); | 1001 | asus_als_level(asus, value); |
856 | } | 1002 | } |
857 | 1003 | ||
858 | return rv; | 1004 | return rv; |
@@ -861,197 +1007,309 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, | |||
861 | /* | 1007 | /* |
862 | * GPS | 1008 | * GPS |
863 | */ | 1009 | */ |
1010 | static int asus_gps_status(struct asus_laptop *asus) | ||
1011 | { | ||
1012 | unsigned long long status; | ||
1013 | acpi_status rv = AE_OK; | ||
1014 | |||
1015 | rv = acpi_evaluate_integer(asus->handle, METHOD_GPS_STATUS, | ||
1016 | NULL, &status); | ||
1017 | if (ACPI_FAILURE(rv)) { | ||
1018 | pr_warning("Error reading GPS status\n"); | ||
1019 | return -ENODEV; | ||
1020 | } | ||
1021 | return !!status; | ||
1022 | } | ||
1023 | |||
1024 | static int asus_gps_switch(struct asus_laptop *asus, int status) | ||
1025 | { | ||
1026 | const char *meth = status ? METHOD_GPS_ON : METHOD_GPS_OFF; | ||
1027 | |||
1028 | if (write_acpi_int(asus->handle, meth, 0x02)) | ||
1029 | return -ENODEV; | ||
1030 | return 0; | ||
1031 | } | ||
1032 | |||
864 | static ssize_t show_gps(struct device *dev, | 1033 | static ssize_t show_gps(struct device *dev, |
865 | struct device_attribute *attr, char *buf) | 1034 | struct device_attribute *attr, char *buf) |
866 | { | 1035 | { |
867 | return sprintf(buf, "%d\n", read_status(GPS_ON)); | 1036 | struct asus_laptop *asus = dev_get_drvdata(dev); |
1037 | |||
1038 | return sprintf(buf, "%d\n", asus_gps_status(asus)); | ||
868 | } | 1039 | } |
869 | 1040 | ||
870 | static ssize_t store_gps(struct device *dev, struct device_attribute *attr, | 1041 | static ssize_t store_gps(struct device *dev, struct device_attribute *attr, |
871 | const char *buf, size_t count) | 1042 | const char *buf, size_t count) |
872 | { | 1043 | { |
873 | return store_status(buf, count, NULL, GPS_ON); | 1044 | struct asus_laptop *asus = dev_get_drvdata(dev); |
1045 | int rv, value; | ||
1046 | int ret; | ||
1047 | |||
1048 | rv = parse_arg(buf, count, &value); | ||
1049 | if (rv <= 0) | ||
1050 | return -EINVAL; | ||
1051 | ret = asus_gps_switch(asus, !!value); | ||
1052 | if (ret) | ||
1053 | return ret; | ||
1054 | rfkill_set_sw_state(asus->gps_rfkill, !value); | ||
1055 | return rv; | ||
874 | } | 1056 | } |
875 | 1057 | ||
876 | /* | 1058 | /* |
877 | * Hotkey functions | 1059 | * rfkill |
878 | */ | 1060 | */ |
879 | static struct key_entry *asus_get_entry_by_scancode(int code) | 1061 | static int asus_gps_rfkill_set(void *data, bool blocked) |
880 | { | 1062 | { |
881 | struct key_entry *key; | 1063 | acpi_handle handle = data; |
882 | |||
883 | for (key = asus_keymap; key->type != KE_END; key++) | ||
884 | if (code == key->code) | ||
885 | return key; | ||
886 | 1064 | ||
887 | return NULL; | 1065 | return asus_gps_switch(handle, !blocked); |
888 | } | 1066 | } |
889 | 1067 | ||
890 | static struct key_entry *asus_get_entry_by_keycode(int code) | 1068 | static const struct rfkill_ops asus_gps_rfkill_ops = { |
891 | { | 1069 | .set_block = asus_gps_rfkill_set, |
892 | struct key_entry *key; | 1070 | }; |
893 | |||
894 | for (key = asus_keymap; key->type != KE_END; key++) | ||
895 | if (code == key->keycode && key->type == KE_KEY) | ||
896 | return key; | ||
897 | 1071 | ||
898 | return NULL; | 1072 | static void asus_rfkill_exit(struct asus_laptop *asus) |
1073 | { | ||
1074 | if (asus->gps_rfkill) { | ||
1075 | rfkill_unregister(asus->gps_rfkill); | ||
1076 | rfkill_destroy(asus->gps_rfkill); | ||
1077 | asus->gps_rfkill = NULL; | ||
1078 | } | ||
899 | } | 1079 | } |
900 | 1080 | ||
901 | static int asus_getkeycode(struct input_dev *dev, int scancode, int *keycode) | 1081 | static int asus_rfkill_init(struct asus_laptop *asus) |
902 | { | 1082 | { |
903 | struct key_entry *key = asus_get_entry_by_scancode(scancode); | 1083 | int result; |
904 | 1084 | ||
905 | if (key && key->type == KE_KEY) { | 1085 | if (acpi_check_handle(asus->handle, METHOD_GPS_ON, NULL) || |
906 | *keycode = key->keycode; | 1086 | acpi_check_handle(asus->handle, METHOD_GPS_OFF, NULL) || |
1087 | acpi_check_handle(asus->handle, METHOD_GPS_STATUS, NULL)) | ||
907 | return 0; | 1088 | return 0; |
1089 | |||
1090 | asus->gps_rfkill = rfkill_alloc("asus-gps", &asus->platform_device->dev, | ||
1091 | RFKILL_TYPE_GPS, | ||
1092 | &asus_gps_rfkill_ops, NULL); | ||
1093 | if (!asus->gps_rfkill) | ||
1094 | return -EINVAL; | ||
1095 | |||
1096 | result = rfkill_register(asus->gps_rfkill); | ||
1097 | if (result) { | ||
1098 | rfkill_destroy(asus->gps_rfkill); | ||
1099 | asus->gps_rfkill = NULL; | ||
908 | } | 1100 | } |
909 | 1101 | ||
910 | return -EINVAL; | 1102 | return result; |
911 | } | 1103 | } |
912 | 1104 | ||
913 | static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode) | 1105 | /* |
1106 | * Input device (i.e. hotkeys) | ||
1107 | */ | ||
1108 | static void asus_input_notify(struct asus_laptop *asus, int event) | ||
914 | { | 1109 | { |
915 | struct key_entry *key; | 1110 | if (asus->inputdev) |
916 | int old_keycode; | 1111 | sparse_keymap_report_event(asus->inputdev, event, 1, true); |
1112 | } | ||
917 | 1113 | ||
918 | if (keycode < 0 || keycode > KEY_MAX) | 1114 | static int asus_input_init(struct asus_laptop *asus) |
919 | return -EINVAL; | 1115 | { |
1116 | struct input_dev *input; | ||
1117 | int error; | ||
920 | 1118 | ||
921 | key = asus_get_entry_by_scancode(scancode); | 1119 | input = input_allocate_device(); |
922 | if (key && key->type == KE_KEY) { | 1120 | if (!input) { |
923 | old_keycode = key->keycode; | 1121 | pr_info("Unable to allocate input device\n"); |
924 | key->keycode = keycode; | ||
925 | set_bit(keycode, dev->keybit); | ||
926 | if (!asus_get_entry_by_keycode(old_keycode)) | ||
927 | clear_bit(old_keycode, dev->keybit); | ||
928 | return 0; | 1122 | return 0; |
929 | } | 1123 | } |
1124 | input->name = "Asus Laptop extra buttons"; | ||
1125 | input->phys = ASUS_LAPTOP_FILE "/input0"; | ||
1126 | input->id.bustype = BUS_HOST; | ||
1127 | input->dev.parent = &asus->platform_device->dev; | ||
1128 | input_set_drvdata(input, asus); | ||
1129 | |||
1130 | error = sparse_keymap_setup(input, asus_keymap, NULL); | ||
1131 | if (error) { | ||
1132 | pr_err("Unable to setup input device keymap\n"); | ||
1133 | goto err_keymap; | ||
1134 | } | ||
1135 | error = input_register_device(input); | ||
1136 | if (error) { | ||
1137 | pr_info("Unable to register input device\n"); | ||
1138 | goto err_device; | ||
1139 | } | ||
1140 | |||
1141 | asus->inputdev = input; | ||
1142 | return 0; | ||
930 | 1143 | ||
931 | return -EINVAL; | 1144 | err_keymap: |
1145 | sparse_keymap_free(input); | ||
1146 | err_device: | ||
1147 | input_free_device(input); | ||
1148 | return error; | ||
932 | } | 1149 | } |
933 | 1150 | ||
934 | static void asus_hotk_notify(struct acpi_device *device, u32 event) | 1151 | static void asus_input_exit(struct asus_laptop *asus) |
935 | { | 1152 | { |
936 | static struct key_entry *key; | 1153 | if (asus->inputdev) { |
937 | u16 count; | 1154 | sparse_keymap_free(asus->inputdev); |
1155 | input_unregister_device(asus->inputdev); | ||
1156 | } | ||
1157 | } | ||
938 | 1158 | ||
939 | /* TODO Find a better way to handle events count. */ | 1159 | /* |
940 | if (!hotk) | 1160 | * ACPI driver |
941 | return; | 1161 | */ |
1162 | static void asus_acpi_notify(struct acpi_device *device, u32 event) | ||
1163 | { | ||
1164 | struct asus_laptop *asus = acpi_driver_data(device); | ||
1165 | u16 count; | ||
942 | 1166 | ||
943 | /* | 1167 | /* |
944 | * We need to tell the backlight device when the backlight power is | 1168 | * We need to tell the backlight device when the backlight power is |
945 | * switched | 1169 | * switched |
946 | */ | 1170 | */ |
947 | if (event == ATKD_LCD_ON) { | 1171 | if (event == ATKD_LCD_ON) |
948 | write_status(NULL, 1, LCD_ON); | 1172 | lcd_blank(asus, FB_BLANK_UNBLANK); |
949 | lcd_blank(FB_BLANK_UNBLANK); | 1173 | else if (event == ATKD_LCD_OFF) |
950 | } else if (event == ATKD_LCD_OFF) { | 1174 | lcd_blank(asus, FB_BLANK_POWERDOWN); |
951 | write_status(NULL, 0, LCD_ON); | ||
952 | lcd_blank(FB_BLANK_POWERDOWN); | ||
953 | } | ||
954 | 1175 | ||
955 | count = hotk->event_count[event % 128]++; | 1176 | /* TODO Find a better way to handle events count. */ |
956 | acpi_bus_generate_proc_event(hotk->device, event, count); | 1177 | count = asus->event_count[event % 128]++; |
957 | acpi_bus_generate_netlink_event(hotk->device->pnp.device_class, | 1178 | acpi_bus_generate_proc_event(asus->device, event, count); |
958 | dev_name(&hotk->device->dev), event, | 1179 | acpi_bus_generate_netlink_event(asus->device->pnp.device_class, |
1180 | dev_name(&asus->device->dev), event, | ||
959 | count); | 1181 | count); |
960 | 1182 | ||
961 | if (hotk->inputdev) { | 1183 | /* Brightness events are special */ |
962 | key = asus_get_entry_by_scancode(event); | 1184 | if (event >= ATKD_BR_MIN && event <= ATKD_BR_MAX) { |
963 | if (!key) | 1185 | |
964 | return ; | 1186 | /* Ignore them completely if the acpi video driver is used */ |
965 | 1187 | if (asus->backlight_device != NULL) { | |
966 | switch (key->type) { | 1188 | /* Update the backlight device. */ |
967 | case KE_KEY: | 1189 | asus_backlight_notify(asus); |
968 | input_report_key(hotk->inputdev, key->keycode, 1); | ||
969 | input_sync(hotk->inputdev); | ||
970 | input_report_key(hotk->inputdev, key->keycode, 0); | ||
971 | input_sync(hotk->inputdev); | ||
972 | break; | ||
973 | } | 1190 | } |
1191 | return ; | ||
974 | } | 1192 | } |
1193 | asus_input_notify(asus, event); | ||
975 | } | 1194 | } |
976 | 1195 | ||
977 | #define ASUS_CREATE_DEVICE_ATTR(_name) \ | 1196 | static DEVICE_ATTR(infos, S_IRUGO, show_infos, NULL); |
978 | struct device_attribute dev_attr_##_name = { \ | 1197 | static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan); |
979 | .attr = { \ | 1198 | static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR, show_bluetooth, |
980 | .name = __stringify(_name), \ | 1199 | store_bluetooth); |
981 | .mode = 0 }, \ | 1200 | static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp); |
982 | .show = NULL, \ | 1201 | static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); |
983 | .store = NULL, \ | 1202 | static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); |
1203 | static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw); | ||
1204 | static DEVICE_ATTR(gps, S_IRUGO | S_IWUSR, show_gps, store_gps); | ||
1205 | |||
1206 | static void asus_sysfs_exit(struct asus_laptop *asus) | ||
1207 | { | ||
1208 | struct platform_device *device = asus->platform_device; | ||
1209 | |||
1210 | device_remove_file(&device->dev, &dev_attr_infos); | ||
1211 | device_remove_file(&device->dev, &dev_attr_wlan); | ||
1212 | device_remove_file(&device->dev, &dev_attr_bluetooth); | ||
1213 | device_remove_file(&device->dev, &dev_attr_display); | ||
1214 | device_remove_file(&device->dev, &dev_attr_ledd); | ||
1215 | device_remove_file(&device->dev, &dev_attr_ls_switch); | ||
1216 | device_remove_file(&device->dev, &dev_attr_ls_level); | ||
1217 | device_remove_file(&device->dev, &dev_attr_gps); | ||
1218 | } | ||
1219 | |||
1220 | static int asus_sysfs_init(struct asus_laptop *asus) | ||
1221 | { | ||
1222 | struct platform_device *device = asus->platform_device; | ||
1223 | int err; | ||
1224 | |||
1225 | err = device_create_file(&device->dev, &dev_attr_infos); | ||
1226 | if (err) | ||
1227 | return err; | ||
1228 | |||
1229 | if (!acpi_check_handle(asus->handle, METHOD_WLAN, NULL)) { | ||
1230 | err = device_create_file(&device->dev, &dev_attr_wlan); | ||
1231 | if (err) | ||
1232 | return err; | ||
984 | } | 1233 | } |
985 | 1234 | ||
986 | #define ASUS_SET_DEVICE_ATTR(_name, _mode, _show, _store) \ | 1235 | if (!acpi_check_handle(asus->handle, METHOD_BLUETOOTH, NULL)) { |
987 | do { \ | 1236 | err = device_create_file(&device->dev, &dev_attr_bluetooth); |
988 | dev_attr_##_name.attr.mode = _mode; \ | 1237 | if (err) |
989 | dev_attr_##_name.show = _show; \ | 1238 | return err; |
990 | dev_attr_##_name.store = _store; \ | 1239 | } |
991 | } while(0) | ||
992 | |||
993 | static ASUS_CREATE_DEVICE_ATTR(infos); | ||
994 | static ASUS_CREATE_DEVICE_ATTR(wlan); | ||
995 | static ASUS_CREATE_DEVICE_ATTR(bluetooth); | ||
996 | static ASUS_CREATE_DEVICE_ATTR(display); | ||
997 | static ASUS_CREATE_DEVICE_ATTR(ledd); | ||
998 | static ASUS_CREATE_DEVICE_ATTR(ls_switch); | ||
999 | static ASUS_CREATE_DEVICE_ATTR(ls_level); | ||
1000 | static ASUS_CREATE_DEVICE_ATTR(gps); | ||
1001 | |||
1002 | static struct attribute *asuspf_attributes[] = { | ||
1003 | &dev_attr_infos.attr, | ||
1004 | &dev_attr_wlan.attr, | ||
1005 | &dev_attr_bluetooth.attr, | ||
1006 | &dev_attr_display.attr, | ||
1007 | &dev_attr_ledd.attr, | ||
1008 | &dev_attr_ls_switch.attr, | ||
1009 | &dev_attr_ls_level.attr, | ||
1010 | &dev_attr_gps.attr, | ||
1011 | NULL | ||
1012 | }; | ||
1013 | 1240 | ||
1014 | static struct attribute_group asuspf_attribute_group = { | 1241 | if (!acpi_check_handle(asus->handle, METHOD_SWITCH_DISPLAY, NULL)) { |
1015 | .attrs = asuspf_attributes | 1242 | err = device_create_file(&device->dev, &dev_attr_display); |
1016 | }; | 1243 | if (err) |
1244 | return err; | ||
1245 | } | ||
1017 | 1246 | ||
1018 | static struct platform_driver asuspf_driver = { | 1247 | if (!acpi_check_handle(asus->handle, METHOD_LEDD, NULL)) { |
1019 | .driver = { | 1248 | err = device_create_file(&device->dev, &dev_attr_ledd); |
1020 | .name = ASUS_HOTK_FILE, | 1249 | if (err) |
1021 | .owner = THIS_MODULE, | 1250 | return err; |
1022 | } | 1251 | } |
1023 | }; | ||
1024 | 1252 | ||
1025 | static struct platform_device *asuspf_device; | 1253 | if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) && |
1254 | !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) { | ||
1255 | err = device_create_file(&device->dev, &dev_attr_ls_switch); | ||
1256 | if (err) | ||
1257 | return err; | ||
1258 | err = device_create_file(&device->dev, &dev_attr_ls_level); | ||
1259 | if (err) | ||
1260 | return err; | ||
1261 | } | ||
1026 | 1262 | ||
1027 | static void asus_hotk_add_fs(void) | 1263 | if (!acpi_check_handle(asus->handle, METHOD_GPS_ON, NULL) && |
1028 | { | 1264 | !acpi_check_handle(asus->handle, METHOD_GPS_OFF, NULL) && |
1029 | ASUS_SET_DEVICE_ATTR(infos, 0444, show_infos, NULL); | 1265 | !acpi_check_handle(asus->handle, METHOD_GPS_STATUS, NULL)) { |
1266 | err = device_create_file(&device->dev, &dev_attr_gps); | ||
1267 | if (err) | ||
1268 | return err; | ||
1269 | } | ||
1030 | 1270 | ||
1031 | if (wl_switch_handle) | 1271 | return err; |
1032 | ASUS_SET_DEVICE_ATTR(wlan, 0644, show_wlan, store_wlan); | 1272 | } |
1273 | |||
1274 | static int asus_platform_init(struct asus_laptop *asus) | ||
1275 | { | ||
1276 | int err; | ||
1033 | 1277 | ||
1034 | if (bt_switch_handle) | 1278 | asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, -1); |
1035 | ASUS_SET_DEVICE_ATTR(bluetooth, 0644, | 1279 | if (!asus->platform_device) |
1036 | show_bluetooth, store_bluetooth); | 1280 | return -ENOMEM; |
1281 | platform_set_drvdata(asus->platform_device, asus); | ||
1037 | 1282 | ||
1038 | if (display_set_handle && display_get_handle) | 1283 | err = platform_device_add(asus->platform_device); |
1039 | ASUS_SET_DEVICE_ATTR(display, 0644, show_disp, store_disp); | 1284 | if (err) |
1040 | else if (display_set_handle) | 1285 | goto fail_platform_device; |
1041 | ASUS_SET_DEVICE_ATTR(display, 0200, NULL, store_disp); | ||
1042 | 1286 | ||
1043 | if (ledd_set_handle) | 1287 | err = asus_sysfs_init(asus); |
1044 | ASUS_SET_DEVICE_ATTR(ledd, 0644, show_ledd, store_ledd); | 1288 | if (err) |
1289 | goto fail_sysfs; | ||
1290 | return 0; | ||
1045 | 1291 | ||
1046 | if (ls_switch_handle && ls_level_handle) { | 1292 | fail_sysfs: |
1047 | ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); | 1293 | asus_sysfs_exit(asus); |
1048 | ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); | 1294 | platform_device_del(asus->platform_device); |
1049 | } | 1295 | fail_platform_device: |
1296 | platform_device_put(asus->platform_device); | ||
1297 | return err; | ||
1298 | } | ||
1050 | 1299 | ||
1051 | if (gps_status_handle && gps_on_handle && gps_off_handle) | 1300 | static void asus_platform_exit(struct asus_laptop *asus) |
1052 | ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps); | 1301 | { |
1302 | asus_sysfs_exit(asus); | ||
1303 | platform_device_unregister(asus->platform_device); | ||
1053 | } | 1304 | } |
1054 | 1305 | ||
1306 | static struct platform_driver platform_driver = { | ||
1307 | .driver = { | ||
1308 | .name = ASUS_LAPTOP_FILE, | ||
1309 | .owner = THIS_MODULE, | ||
1310 | } | ||
1311 | }; | ||
1312 | |||
1055 | static int asus_handle_init(char *name, acpi_handle * handle, | 1313 | static int asus_handle_init(char *name, acpi_handle * handle, |
1056 | char **paths, int num_paths) | 1314 | char **paths, int num_paths) |
1057 | { | 1315 | { |
@@ -1073,10 +1331,11 @@ static int asus_handle_init(char *name, acpi_handle * handle, | |||
1073 | ARRAY_SIZE(object##_paths)) | 1331 | ARRAY_SIZE(object##_paths)) |
1074 | 1332 | ||
1075 | /* | 1333 | /* |
1076 | * This function is used to initialize the hotk with right values. In this | 1334 | * This function is used to initialize the context with right values. In this |
1077 | * method, we can make all the detection we want, and modify the hotk struct | 1335 | * method, we can make all the detection we want, and modify the asus_laptop |
1336 | * struct | ||
1078 | */ | 1337 | */ |
1079 | static int asus_hotk_get_info(void) | 1338 | static int asus_laptop_get_info(struct asus_laptop *asus) |
1080 | { | 1339 | { |
1081 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 1340 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
1082 | union acpi_object *model = NULL; | 1341 | union acpi_object *model = NULL; |
@@ -1089,22 +1348,21 @@ static int asus_hotk_get_info(void) | |||
1089 | * models, but late enough to allow acpi_bus_register_driver() to fail | 1348 | * models, but late enough to allow acpi_bus_register_driver() to fail |
1090 | * before doing anything ACPI-specific. Should we encounter a machine, | 1349 | * before doing anything ACPI-specific. Should we encounter a machine, |
1091 | * which needs special handling (i.e. its hotkey device has a different | 1350 | * which needs special handling (i.e. its hotkey device has a different |
1092 | * HID), this bit will be moved. A global variable asus_info contains | 1351 | * HID), this bit will be moved. |
1093 | * the DSDT header. | ||
1094 | */ | 1352 | */ |
1095 | status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info); | 1353 | status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus->dsdt_info); |
1096 | if (ACPI_FAILURE(status)) | 1354 | if (ACPI_FAILURE(status)) |
1097 | pr_warning("Couldn't get the DSDT table header\n"); | 1355 | pr_warning("Couldn't get the DSDT table header\n"); |
1098 | 1356 | ||
1099 | /* We have to write 0 on init this far for all ASUS models */ | 1357 | /* We have to write 0 on init this far for all ASUS models */ |
1100 | if (write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { | 1358 | if (write_acpi_int_ret(asus->handle, "INIT", 0, &buffer)) { |
1101 | pr_err("Hotkey initialization failed\n"); | 1359 | pr_err("Hotkey initialization failed\n"); |
1102 | return -ENODEV; | 1360 | return -ENODEV; |
1103 | } | 1361 | } |
1104 | 1362 | ||
1105 | /* This needs to be called for some laptops to init properly */ | 1363 | /* This needs to be called for some laptops to init properly */ |
1106 | status = | 1364 | status = |
1107 | acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result); | 1365 | acpi_evaluate_integer(asus->handle, "BSTS", NULL, &bsts_result); |
1108 | if (ACPI_FAILURE(status)) | 1366 | if (ACPI_FAILURE(status)) |
1109 | pr_warning("Error calling BSTS\n"); | 1367 | pr_warning("Error calling BSTS\n"); |
1110 | else if (bsts_result) | 1368 | else if (bsts_result) |
@@ -1112,8 +1370,8 @@ static int asus_hotk_get_info(void) | |||
1112 | (uint) bsts_result); | 1370 | (uint) bsts_result); |
1113 | 1371 | ||
1114 | /* This too ... */ | 1372 | /* This too ... */ |
1115 | write_acpi_int(hotk->handle, "CWAP", wapf, NULL); | 1373 | if (write_acpi_int(asus->handle, "CWAP", wapf)) |
1116 | 1374 | pr_err("Error calling CWAP(%d)\n", wapf); | |
1117 | /* | 1375 | /* |
1118 | * Try to match the object returned by INIT to the specific model. | 1376 | * Try to match the object returned by INIT to the specific model. |
1119 | * Handle every possible object (or the lack of thereof) the DSDT | 1377 | * Handle every possible object (or the lack of thereof) the DSDT |
@@ -1134,397 +1392,210 @@ static int asus_hotk_get_info(void) | |||
1134 | break; | 1392 | break; |
1135 | } | 1393 | } |
1136 | } | 1394 | } |
1137 | hotk->name = kstrdup(string, GFP_KERNEL); | 1395 | asus->name = kstrdup(string, GFP_KERNEL); |
1138 | if (!hotk->name) | 1396 | if (!asus->name) |
1139 | return -ENOMEM; | 1397 | return -ENOMEM; |
1140 | 1398 | ||
1141 | if (*string) | 1399 | if (*string) |
1142 | pr_notice(" %s model detected\n", string); | 1400 | pr_notice(" %s model detected\n", string); |
1143 | 1401 | ||
1144 | ASUS_HANDLE_INIT(mled_set); | ||
1145 | ASUS_HANDLE_INIT(tled_set); | ||
1146 | ASUS_HANDLE_INIT(rled_set); | ||
1147 | ASUS_HANDLE_INIT(pled_set); | ||
1148 | ASUS_HANDLE_INIT(gled_set); | ||
1149 | |||
1150 | ASUS_HANDLE_INIT(ledd_set); | ||
1151 | |||
1152 | ASUS_HANDLE_INIT(kled_set); | ||
1153 | ASUS_HANDLE_INIT(kled_get); | ||
1154 | |||
1155 | /* | 1402 | /* |
1156 | * The HWRS method return informations about the hardware. | 1403 | * The HWRS method return informations about the hardware. |
1157 | * 0x80 bit is for WLAN, 0x100 for Bluetooth. | 1404 | * 0x80 bit is for WLAN, 0x100 for Bluetooth. |
1158 | * The significance of others is yet to be found. | 1405 | * The significance of others is yet to be found. |
1159 | * If we don't find the method, we assume the device are present. | ||
1160 | */ | 1406 | */ |
1161 | status = | 1407 | status = |
1162 | acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &hwrs_result); | 1408 | acpi_evaluate_integer(asus->handle, "HRWS", NULL, &hwrs_result); |
1163 | if (ACPI_FAILURE(status)) | 1409 | if (!ACPI_FAILURE(status)) |
1164 | hwrs_result = WL_HWRS | BT_HWRS; | 1410 | pr_notice(" HRWS returned %x", (int)hwrs_result); |
1165 | |||
1166 | if (hwrs_result & WL_HWRS) | ||
1167 | ASUS_HANDLE_INIT(wl_switch); | ||
1168 | if (hwrs_result & BT_HWRS) | ||
1169 | ASUS_HANDLE_INIT(bt_switch); | ||
1170 | |||
1171 | ASUS_HANDLE_INIT(wireless_status); | ||
1172 | 1411 | ||
1173 | ASUS_HANDLE_INIT(brightness_set); | 1412 | if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL)) |
1174 | ASUS_HANDLE_INIT(brightness_get); | 1413 | asus->have_rsts = true; |
1175 | 1414 | ||
1415 | /* Scheduled for removal */ | ||
1176 | ASUS_HANDLE_INIT(lcd_switch); | 1416 | ASUS_HANDLE_INIT(lcd_switch); |
1177 | |||
1178 | ASUS_HANDLE_INIT(display_set); | ||
1179 | ASUS_HANDLE_INIT(display_get); | 1417 | ASUS_HANDLE_INIT(display_get); |
1180 | 1418 | ||
1181 | /* | ||
1182 | * There is a lot of models with "ALSL", but a few get | ||
1183 | * a real light sens, so we need to check it. | ||
1184 | */ | ||
1185 | if (!ASUS_HANDLE_INIT(ls_switch)) | ||
1186 | ASUS_HANDLE_INIT(ls_level); | ||
1187 | |||
1188 | ASUS_HANDLE_INIT(gps_on); | ||
1189 | ASUS_HANDLE_INIT(gps_off); | ||
1190 | ASUS_HANDLE_INIT(gps_status); | ||
1191 | |||
1192 | kfree(model); | 1419 | kfree(model); |
1193 | 1420 | ||
1194 | return AE_OK; | 1421 | return AE_OK; |
1195 | } | 1422 | } |
1196 | 1423 | ||
1197 | static int asus_input_init(void) | 1424 | static bool asus_device_present; |
1198 | { | ||
1199 | const struct key_entry *key; | ||
1200 | int result; | ||
1201 | 1425 | ||
1202 | hotk->inputdev = input_allocate_device(); | 1426 | static int __devinit asus_acpi_init(struct asus_laptop *asus) |
1203 | if (!hotk->inputdev) { | ||
1204 | pr_info("Unable to allocate input device\n"); | ||
1205 | return 0; | ||
1206 | } | ||
1207 | hotk->inputdev->name = "Asus Laptop extra buttons"; | ||
1208 | hotk->inputdev->phys = ASUS_HOTK_FILE "/input0"; | ||
1209 | hotk->inputdev->id.bustype = BUS_HOST; | ||
1210 | hotk->inputdev->getkeycode = asus_getkeycode; | ||
1211 | hotk->inputdev->setkeycode = asus_setkeycode; | ||
1212 | |||
1213 | for (key = asus_keymap; key->type != KE_END; key++) { | ||
1214 | switch (key->type) { | ||
1215 | case KE_KEY: | ||
1216 | set_bit(EV_KEY, hotk->inputdev->evbit); | ||
1217 | set_bit(key->keycode, hotk->inputdev->keybit); | ||
1218 | break; | ||
1219 | } | ||
1220 | } | ||
1221 | result = input_register_device(hotk->inputdev); | ||
1222 | if (result) { | ||
1223 | pr_info("Unable to register input device\n"); | ||
1224 | input_free_device(hotk->inputdev); | ||
1225 | } | ||
1226 | return result; | ||
1227 | } | ||
1228 | |||
1229 | static int asus_hotk_check(void) | ||
1230 | { | 1427 | { |
1231 | int result = 0; | 1428 | int result = 0; |
1232 | 1429 | ||
1233 | result = acpi_bus_get_status(hotk->device); | 1430 | result = acpi_bus_get_status(asus->device); |
1234 | if (result) | 1431 | if (result) |
1235 | return result; | 1432 | return result; |
1236 | 1433 | if (!asus->device->status.present) { | |
1237 | if (hotk->device->status.present) { | ||
1238 | result = asus_hotk_get_info(); | ||
1239 | } else { | ||
1240 | pr_err("Hotkey device not present, aborting\n"); | 1434 | pr_err("Hotkey device not present, aborting\n"); |
1241 | return -EINVAL; | 1435 | return -ENODEV; |
1242 | } | 1436 | } |
1243 | 1437 | ||
1244 | return result; | 1438 | result = asus_laptop_get_info(asus); |
1245 | } | ||
1246 | |||
1247 | static int asus_hotk_found; | ||
1248 | |||
1249 | static int asus_hotk_add(struct acpi_device *device) | ||
1250 | { | ||
1251 | int result; | ||
1252 | |||
1253 | pr_notice("Asus Laptop Support version %s\n", | ||
1254 | ASUS_LAPTOP_VERSION); | ||
1255 | |||
1256 | hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL); | ||
1257 | if (!hotk) | ||
1258 | return -ENOMEM; | ||
1259 | |||
1260 | hotk->handle = device->handle; | ||
1261 | strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME); | ||
1262 | strcpy(acpi_device_class(device), ASUS_HOTK_CLASS); | ||
1263 | device->driver_data = hotk; | ||
1264 | hotk->device = device; | ||
1265 | |||
1266 | result = asus_hotk_check(); | ||
1267 | if (result) | 1439 | if (result) |
1268 | goto end; | 1440 | return result; |
1269 | |||
1270 | asus_hotk_add_fs(); | ||
1271 | |||
1272 | asus_hotk_found = 1; | ||
1273 | 1441 | ||
1274 | /* WLED and BLED are on by default */ | 1442 | /* WLED and BLED are on by default */ |
1275 | write_status(bt_switch_handle, 1, BT_ON); | 1443 | if (bluetooth_status >= 0) |
1276 | write_status(wl_switch_handle, 1, WL_ON); | 1444 | asus_bluetooth_set(asus, !!bluetooth_status); |
1277 | |||
1278 | /* If the h/w switch is off, we need to check the real status */ | ||
1279 | write_status(NULL, read_status(BT_ON), BT_ON); | ||
1280 | write_status(NULL, read_status(WL_ON), WL_ON); | ||
1281 | 1445 | ||
1282 | /* LCD Backlight is on by default */ | 1446 | if (wlan_status >= 0) |
1283 | write_status(NULL, 1, LCD_ON); | 1447 | asus_wlan_set(asus, !!wlan_status); |
1284 | 1448 | ||
1285 | /* Keyboard Backlight is on by default */ | 1449 | /* Keyboard Backlight is on by default */ |
1286 | if (kled_set_handle) | 1450 | if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL)) |
1287 | set_kled_lvl(1); | 1451 | asus_kled_set(asus, 1); |
1288 | 1452 | ||
1289 | /* LED display is off by default */ | 1453 | /* LED display is off by default */ |
1290 | hotk->ledd_status = 0xFFF; | 1454 | asus->ledd_status = 0xFFF; |
1291 | 1455 | ||
1292 | /* Set initial values of light sensor and level */ | 1456 | /* Set initial values of light sensor and level */ |
1293 | hotk->light_switch = 0; /* Default to light sensor disabled */ | 1457 | asus->light_switch = 0; /* Default to light sensor disabled */ |
1294 | hotk->light_level = 5; /* level 5 for sensor sensitivity */ | 1458 | asus->light_level = 5; /* level 5 for sensor sensitivity */ |
1295 | 1459 | ||
1296 | if (ls_switch_handle) | 1460 | if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) && |
1297 | set_light_sens_switch(hotk->light_switch); | 1461 | !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) { |
1298 | 1462 | asus_als_switch(asus, asus->light_switch); | |
1299 | if (ls_level_handle) | 1463 | asus_als_level(asus, asus->light_level); |
1300 | set_light_sens_level(hotk->light_level); | ||
1301 | |||
1302 | /* GPS is on by default */ | ||
1303 | write_status(NULL, 1, GPS_ON); | ||
1304 | |||
1305 | end: | ||
1306 | if (result) { | ||
1307 | kfree(hotk->name); | ||
1308 | kfree(hotk); | ||
1309 | } | 1464 | } |
1310 | 1465 | ||
1466 | asus->lcd_state = 1; /* LCD should be on when the module load */ | ||
1311 | return result; | 1467 | return result; |
1312 | } | 1468 | } |
1313 | 1469 | ||
1314 | static int asus_hotk_remove(struct acpi_device *device, int type) | 1470 | static int __devinit asus_acpi_add(struct acpi_device *device) |
1315 | { | ||
1316 | kfree(hotk->name); | ||
1317 | kfree(hotk); | ||
1318 | |||
1319 | return 0; | ||
1320 | } | ||
1321 | |||
1322 | static void asus_backlight_exit(void) | ||
1323 | { | 1471 | { |
1324 | if (asus_backlight_device) | 1472 | struct asus_laptop *asus; |
1325 | backlight_device_unregister(asus_backlight_device); | 1473 | int result; |
1326 | } | ||
1327 | |||
1328 | #define ASUS_LED_UNREGISTER(object) \ | ||
1329 | if (object##_led.dev) \ | ||
1330 | led_classdev_unregister(&object##_led) | ||
1331 | 1474 | ||
1332 | static void asus_led_exit(void) | 1475 | pr_notice("Asus Laptop Support version %s\n", |
1333 | { | 1476 | ASUS_LAPTOP_VERSION); |
1334 | destroy_workqueue(led_workqueue); | 1477 | asus = kzalloc(sizeof(struct asus_laptop), GFP_KERNEL); |
1335 | ASUS_LED_UNREGISTER(mled); | 1478 | if (!asus) |
1336 | ASUS_LED_UNREGISTER(tled); | 1479 | return -ENOMEM; |
1337 | ASUS_LED_UNREGISTER(pled); | 1480 | asus->handle = device->handle; |
1338 | ASUS_LED_UNREGISTER(rled); | 1481 | strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME); |
1339 | ASUS_LED_UNREGISTER(gled); | 1482 | strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS); |
1340 | ASUS_LED_UNREGISTER(kled); | 1483 | device->driver_data = asus; |
1341 | } | 1484 | asus->device = device; |
1342 | 1485 | ||
1343 | static void asus_input_exit(void) | 1486 | result = asus_acpi_init(asus); |
1344 | { | 1487 | if (result) |
1345 | if (hotk->inputdev) | 1488 | goto fail_platform; |
1346 | input_unregister_device(hotk->inputdev); | ||
1347 | } | ||
1348 | 1489 | ||
1349 | static void __exit asus_laptop_exit(void) | 1490 | /* |
1350 | { | 1491 | * Register the platform device first. It is used as a parent for the |
1351 | asus_backlight_exit(); | 1492 | * sub-devices below. |
1352 | asus_led_exit(); | 1493 | */ |
1353 | asus_input_exit(); | 1494 | result = asus_platform_init(asus); |
1495 | if (result) | ||
1496 | goto fail_platform; | ||
1354 | 1497 | ||
1355 | acpi_bus_unregister_driver(&asus_hotk_driver); | 1498 | if (!acpi_video_backlight_support()) { |
1356 | sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group); | 1499 | result = asus_backlight_init(asus); |
1357 | platform_device_unregister(asuspf_device); | 1500 | if (result) |
1358 | platform_driver_unregister(&asuspf_driver); | 1501 | goto fail_backlight; |
1359 | } | 1502 | } else |
1503 | pr_info("Backlight controlled by ACPI video driver\n"); | ||
1360 | 1504 | ||
1361 | static int asus_backlight_init(struct device *dev) | 1505 | result = asus_input_init(asus); |
1362 | { | 1506 | if (result) |
1363 | struct backlight_device *bd; | 1507 | goto fail_input; |
1364 | 1508 | ||
1365 | if (brightness_set_handle && lcd_switch_handle) { | 1509 | result = asus_led_init(asus); |
1366 | bd = backlight_device_register(ASUS_HOTK_FILE, dev, | 1510 | if (result) |
1367 | NULL, &asusbl_ops); | 1511 | goto fail_led; |
1368 | if (IS_ERR(bd)) { | ||
1369 | pr_err("Could not register asus backlight device\n"); | ||
1370 | asus_backlight_device = NULL; | ||
1371 | return PTR_ERR(bd); | ||
1372 | } | ||
1373 | 1512 | ||
1374 | asus_backlight_device = bd; | 1513 | result = asus_rfkill_init(asus); |
1514 | if (result) | ||
1515 | goto fail_rfkill; | ||
1375 | 1516 | ||
1376 | bd->props.max_brightness = 15; | 1517 | asus_device_present = true; |
1377 | bd->props.brightness = read_brightness(NULL); | ||
1378 | bd->props.power = FB_BLANK_UNBLANK; | ||
1379 | backlight_update_status(bd); | ||
1380 | } | ||
1381 | return 0; | 1518 | return 0; |
1382 | } | ||
1383 | 1519 | ||
1384 | static int asus_led_register(acpi_handle handle, | 1520 | fail_rfkill: |
1385 | struct led_classdev *ldev, struct device *dev) | 1521 | asus_led_exit(asus); |
1386 | { | 1522 | fail_led: |
1387 | if (!handle) | 1523 | asus_input_exit(asus); |
1388 | return 0; | 1524 | fail_input: |
1525 | asus_backlight_exit(asus); | ||
1526 | fail_backlight: | ||
1527 | asus_platform_exit(asus); | ||
1528 | fail_platform: | ||
1529 | kfree(asus->name); | ||
1530 | kfree(asus); | ||
1389 | 1531 | ||
1390 | return led_classdev_register(dev, ldev); | 1532 | return result; |
1391 | } | 1533 | } |
1392 | 1534 | ||
1393 | #define ASUS_LED_REGISTER(object, device) \ | 1535 | static int asus_acpi_remove(struct acpi_device *device, int type) |
1394 | asus_led_register(object##_set_handle, &object##_led, device) | ||
1395 | |||
1396 | static int asus_led_init(struct device *dev) | ||
1397 | { | 1536 | { |
1398 | int rv; | 1537 | struct asus_laptop *asus = acpi_driver_data(device); |
1399 | |||
1400 | rv = ASUS_LED_REGISTER(mled, dev); | ||
1401 | if (rv) | ||
1402 | goto out; | ||
1403 | |||
1404 | rv = ASUS_LED_REGISTER(tled, dev); | ||
1405 | if (rv) | ||
1406 | goto out1; | ||
1407 | |||
1408 | rv = ASUS_LED_REGISTER(rled, dev); | ||
1409 | if (rv) | ||
1410 | goto out2; | ||
1411 | |||
1412 | rv = ASUS_LED_REGISTER(pled, dev); | ||
1413 | if (rv) | ||
1414 | goto out3; | ||
1415 | |||
1416 | rv = ASUS_LED_REGISTER(gled, dev); | ||
1417 | if (rv) | ||
1418 | goto out4; | ||
1419 | 1538 | ||
1420 | if (kled_set_handle && kled_get_handle) | 1539 | asus_backlight_exit(asus); |
1421 | rv = ASUS_LED_REGISTER(kled, dev); | 1540 | asus_rfkill_exit(asus); |
1422 | if (rv) | 1541 | asus_led_exit(asus); |
1423 | goto out5; | 1542 | asus_input_exit(asus); |
1424 | 1543 | asus_platform_exit(asus); | |
1425 | led_workqueue = create_singlethread_workqueue("led_workqueue"); | ||
1426 | if (!led_workqueue) | ||
1427 | goto out6; | ||
1428 | 1544 | ||
1545 | kfree(asus->name); | ||
1546 | kfree(asus); | ||
1429 | return 0; | 1547 | return 0; |
1430 | out6: | ||
1431 | rv = -ENOMEM; | ||
1432 | ASUS_LED_UNREGISTER(kled); | ||
1433 | out5: | ||
1434 | ASUS_LED_UNREGISTER(gled); | ||
1435 | out4: | ||
1436 | ASUS_LED_UNREGISTER(pled); | ||
1437 | out3: | ||
1438 | ASUS_LED_UNREGISTER(rled); | ||
1439 | out2: | ||
1440 | ASUS_LED_UNREGISTER(tled); | ||
1441 | out1: | ||
1442 | ASUS_LED_UNREGISTER(mled); | ||
1443 | out: | ||
1444 | return rv; | ||
1445 | } | 1548 | } |
1446 | 1549 | ||
1550 | static const struct acpi_device_id asus_device_ids[] = { | ||
1551 | {"ATK0100", 0}, | ||
1552 | {"ATK0101", 0}, | ||
1553 | {"", 0}, | ||
1554 | }; | ||
1555 | MODULE_DEVICE_TABLE(acpi, asus_device_ids); | ||
1556 | |||
1557 | static struct acpi_driver asus_acpi_driver = { | ||
1558 | .name = ASUS_LAPTOP_NAME, | ||
1559 | .class = ASUS_LAPTOP_CLASS, | ||
1560 | .owner = THIS_MODULE, | ||
1561 | .ids = asus_device_ids, | ||
1562 | .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, | ||
1563 | .ops = { | ||
1564 | .add = asus_acpi_add, | ||
1565 | .remove = asus_acpi_remove, | ||
1566 | .notify = asus_acpi_notify, | ||
1567 | }, | ||
1568 | }; | ||
1569 | |||
1447 | static int __init asus_laptop_init(void) | 1570 | static int __init asus_laptop_init(void) |
1448 | { | 1571 | { |
1449 | int result; | 1572 | int result; |
1450 | 1573 | ||
1451 | result = acpi_bus_register_driver(&asus_hotk_driver); | 1574 | result = platform_driver_register(&platform_driver); |
1452 | if (result < 0) | 1575 | if (result < 0) |
1453 | return result; | 1576 | return result; |
1454 | 1577 | ||
1455 | /* | 1578 | result = acpi_bus_register_driver(&asus_acpi_driver); |
1456 | * This is a bit of a kludge. We only want this module loaded | 1579 | if (result < 0) |
1457 | * for ASUS systems, but there's currently no way to probe the | 1580 | goto fail_acpi_driver; |
1458 | * ACPI namespace for ASUS HIDs. So we just return failure if | 1581 | if (!asus_device_present) { |
1459 | * we didn't find one, which will cause the module to be | 1582 | result = -ENODEV; |
1460 | * unloaded. | 1583 | goto fail_no_device; |
1461 | */ | ||
1462 | if (!asus_hotk_found) { | ||
1463 | acpi_bus_unregister_driver(&asus_hotk_driver); | ||
1464 | return -ENODEV; | ||
1465 | } | ||
1466 | |||
1467 | result = asus_input_init(); | ||
1468 | if (result) | ||
1469 | goto fail_input; | ||
1470 | |||
1471 | /* Register platform stuff */ | ||
1472 | result = platform_driver_register(&asuspf_driver); | ||
1473 | if (result) | ||
1474 | goto fail_platform_driver; | ||
1475 | |||
1476 | asuspf_device = platform_device_alloc(ASUS_HOTK_FILE, -1); | ||
1477 | if (!asuspf_device) { | ||
1478 | result = -ENOMEM; | ||
1479 | goto fail_platform_device1; | ||
1480 | } | 1584 | } |
1481 | |||
1482 | result = platform_device_add(asuspf_device); | ||
1483 | if (result) | ||
1484 | goto fail_platform_device2; | ||
1485 | |||
1486 | result = sysfs_create_group(&asuspf_device->dev.kobj, | ||
1487 | &asuspf_attribute_group); | ||
1488 | if (result) | ||
1489 | goto fail_sysfs; | ||
1490 | |||
1491 | result = asus_led_init(&asuspf_device->dev); | ||
1492 | if (result) | ||
1493 | goto fail_led; | ||
1494 | |||
1495 | if (!acpi_video_backlight_support()) { | ||
1496 | result = asus_backlight_init(&asuspf_device->dev); | ||
1497 | if (result) | ||
1498 | goto fail_backlight; | ||
1499 | } else | ||
1500 | pr_info("Brightness ignored, must be controlled by " | ||
1501 | "ACPI video driver\n"); | ||
1502 | |||
1503 | return 0; | 1585 | return 0; |
1504 | 1586 | ||
1505 | fail_backlight: | 1587 | fail_no_device: |
1506 | asus_led_exit(); | 1588 | acpi_bus_unregister_driver(&asus_acpi_driver); |
1507 | 1589 | fail_acpi_driver: | |
1508 | fail_led: | 1590 | platform_driver_unregister(&platform_driver); |
1509 | sysfs_remove_group(&asuspf_device->dev.kobj, | ||
1510 | &asuspf_attribute_group); | ||
1511 | |||
1512 | fail_sysfs: | ||
1513 | platform_device_del(asuspf_device); | ||
1514 | |||
1515 | fail_platform_device2: | ||
1516 | platform_device_put(asuspf_device); | ||
1517 | |||
1518 | fail_platform_device1: | ||
1519 | platform_driver_unregister(&asuspf_driver); | ||
1520 | |||
1521 | fail_platform_driver: | ||
1522 | asus_input_exit(); | ||
1523 | |||
1524 | fail_input: | ||
1525 | |||
1526 | return result; | 1591 | return result; |
1527 | } | 1592 | } |
1528 | 1593 | ||
1594 | static void __exit asus_laptop_exit(void) | ||
1595 | { | ||
1596 | acpi_bus_unregister_driver(&asus_acpi_driver); | ||
1597 | platform_driver_unregister(&platform_driver); | ||
1598 | } | ||
1599 | |||
1529 | module_init(asus_laptop_init); | 1600 | module_init(asus_laptop_init); |
1530 | module_exit(asus_laptop_exit); | 1601 | module_exit(asus_laptop_exit); |
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c index c1d2aeeea948..1381430e1105 100644 --- a/drivers/platform/x86/asus_acpi.c +++ b/drivers/platform/x86/asus_acpi.c | |||
@@ -1225,9 +1225,8 @@ static int asus_model_match(char *model) | |||
1225 | else if (strncmp(model, "M2N", 3) == 0 || | 1225 | else if (strncmp(model, "M2N", 3) == 0 || |
1226 | strncmp(model, "M3N", 3) == 0 || | 1226 | strncmp(model, "M3N", 3) == 0 || |
1227 | strncmp(model, "M5N", 3) == 0 || | 1227 | strncmp(model, "M5N", 3) == 0 || |
1228 | strncmp(model, "M6N", 3) == 0 || | ||
1229 | strncmp(model, "S1N", 3) == 0 || | 1228 | strncmp(model, "S1N", 3) == 0 || |
1230 | strncmp(model, "S5N", 3) == 0 || strncmp(model, "W1N", 3) == 0) | 1229 | strncmp(model, "S5N", 3) == 0) |
1231 | return xxN; | 1230 | return xxN; |
1232 | else if (strncmp(model, "M1", 2) == 0) | 1231 | else if (strncmp(model, "M1", 2) == 0) |
1233 | return M1A; | 1232 | return M1A; |
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c index ed90082cdf1d..035a7dd65a3f 100644 --- a/drivers/platform/x86/classmate-laptop.c +++ b/drivers/platform/x86/classmate-laptop.c | |||
@@ -34,6 +34,11 @@ struct cmpc_accel { | |||
34 | #define CMPC_ACCEL_SENSITIVITY_DEFAULT 5 | 34 | #define CMPC_ACCEL_SENSITIVITY_DEFAULT 5 |
35 | 35 | ||
36 | 36 | ||
37 | #define CMPC_ACCEL_HID "ACCE0000" | ||
38 | #define CMPC_TABLET_HID "TBLT0000" | ||
39 | #define CMPC_BL_HID "IPML200" | ||
40 | #define CMPC_KEYS_HID "FnBT0000" | ||
41 | |||
37 | /* | 42 | /* |
38 | * Generic input device code. | 43 | * Generic input device code. |
39 | */ | 44 | */ |
@@ -282,10 +287,9 @@ static int cmpc_accel_remove(struct acpi_device *acpi, int type) | |||
282 | } | 287 | } |
283 | 288 | ||
284 | static const struct acpi_device_id cmpc_accel_device_ids[] = { | 289 | static const struct acpi_device_id cmpc_accel_device_ids[] = { |
285 | {"ACCE0000", 0}, | 290 | {CMPC_ACCEL_HID, 0}, |
286 | {"", 0} | 291 | {"", 0} |
287 | }; | 292 | }; |
288 | MODULE_DEVICE_TABLE(acpi, cmpc_accel_device_ids); | ||
289 | 293 | ||
290 | static struct acpi_driver cmpc_accel_acpi_driver = { | 294 | static struct acpi_driver cmpc_accel_acpi_driver = { |
291 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
@@ -366,10 +370,9 @@ static int cmpc_tablet_resume(struct acpi_device *acpi) | |||
366 | } | 370 | } |
367 | 371 | ||
368 | static const struct acpi_device_id cmpc_tablet_device_ids[] = { | 372 | static const struct acpi_device_id cmpc_tablet_device_ids[] = { |
369 | {"TBLT0000", 0}, | 373 | {CMPC_TABLET_HID, 0}, |
370 | {"", 0} | 374 | {"", 0} |
371 | }; | 375 | }; |
372 | MODULE_DEVICE_TABLE(acpi, cmpc_tablet_device_ids); | ||
373 | 376 | ||
374 | static struct acpi_driver cmpc_tablet_acpi_driver = { | 377 | static struct acpi_driver cmpc_tablet_acpi_driver = { |
375 | .owner = THIS_MODULE, | 378 | .owner = THIS_MODULE, |
@@ -477,17 +480,16 @@ static int cmpc_bl_remove(struct acpi_device *acpi, int type) | |||
477 | return 0; | 480 | return 0; |
478 | } | 481 | } |
479 | 482 | ||
480 | static const struct acpi_device_id cmpc_device_ids[] = { | 483 | static const struct acpi_device_id cmpc_bl_device_ids[] = { |
481 | {"IPML200", 0}, | 484 | {CMPC_BL_HID, 0}, |
482 | {"", 0} | 485 | {"", 0} |
483 | }; | 486 | }; |
484 | MODULE_DEVICE_TABLE(acpi, cmpc_device_ids); | ||
485 | 487 | ||
486 | static struct acpi_driver cmpc_bl_acpi_driver = { | 488 | static struct acpi_driver cmpc_bl_acpi_driver = { |
487 | .owner = THIS_MODULE, | 489 | .owner = THIS_MODULE, |
488 | .name = "cmpc", | 490 | .name = "cmpc", |
489 | .class = "cmpc", | 491 | .class = "cmpc", |
490 | .ids = cmpc_device_ids, | 492 | .ids = cmpc_bl_device_ids, |
491 | .ops = { | 493 | .ops = { |
492 | .add = cmpc_bl_add, | 494 | .add = cmpc_bl_add, |
493 | .remove = cmpc_bl_remove | 495 | .remove = cmpc_bl_remove |
@@ -505,6 +507,10 @@ static int cmpc_keys_codes[] = { | |||
505 | KEY_BRIGHTNESSDOWN, | 507 | KEY_BRIGHTNESSDOWN, |
506 | KEY_BRIGHTNESSUP, | 508 | KEY_BRIGHTNESSUP, |
507 | KEY_VENDOR, | 509 | KEY_VENDOR, |
510 | KEY_UNKNOWN, | ||
511 | KEY_CAMERA, | ||
512 | KEY_BACK, | ||
513 | KEY_FORWARD, | ||
508 | KEY_MAX | 514 | KEY_MAX |
509 | }; | 515 | }; |
510 | 516 | ||
@@ -540,10 +546,9 @@ static int cmpc_keys_remove(struct acpi_device *acpi, int type) | |||
540 | } | 546 | } |
541 | 547 | ||
542 | static const struct acpi_device_id cmpc_keys_device_ids[] = { | 548 | static const struct acpi_device_id cmpc_keys_device_ids[] = { |
543 | {"FnBT0000", 0}, | 549 | {CMPC_KEYS_HID, 0}, |
544 | {"", 0} | 550 | {"", 0} |
545 | }; | 551 | }; |
546 | MODULE_DEVICE_TABLE(acpi, cmpc_keys_device_ids); | ||
547 | 552 | ||
548 | static struct acpi_driver cmpc_keys_acpi_driver = { | 553 | static struct acpi_driver cmpc_keys_acpi_driver = { |
549 | .owner = THIS_MODULE, | 554 | .owner = THIS_MODULE, |
@@ -607,3 +612,13 @@ static void cmpc_exit(void) | |||
607 | 612 | ||
608 | module_init(cmpc_init); | 613 | module_init(cmpc_init); |
609 | module_exit(cmpc_exit); | 614 | module_exit(cmpc_exit); |
615 | |||
616 | static const struct acpi_device_id cmpc_device_ids[] = { | ||
617 | {CMPC_ACCEL_HID, 0}, | ||
618 | {CMPC_TABLET_HID, 0}, | ||
619 | {CMPC_BL_HID, 0}, | ||
620 | {CMPC_KEYS_HID, 0}, | ||
621 | {"", 0} | ||
622 | }; | ||
623 | |||
624 | MODULE_DEVICE_TABLE(acpi, cmpc_device_ids); | ||
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c index 1a387e79f719..2740b40aad9b 100644 --- a/drivers/platform/x86/compal-laptop.c +++ b/drivers/platform/x86/compal-laptop.c | |||
@@ -26,17 +26,8 @@ | |||
26 | /* | 26 | /* |
27 | * comapl-laptop.c - Compal laptop support. | 27 | * comapl-laptop.c - Compal laptop support. |
28 | * | 28 | * |
29 | * This driver exports a few files in /sys/devices/platform/compal-laptop/: | 29 | * The driver registers itself with the rfkill subsystem and |
30 | * | 30 | * the Linux backlight control subsystem. |
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 | * | 31 | * |
41 | * This driver might work on other laptops produced by Compal. If you | 32 | * 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 | 33 | * want to try it you can pass force=1 as argument to the module which |
@@ -51,6 +42,7 @@ | |||
51 | #include <linux/dmi.h> | 42 | #include <linux/dmi.h> |
52 | #include <linux/backlight.h> | 43 | #include <linux/backlight.h> |
53 | #include <linux/platform_device.h> | 44 | #include <linux/platform_device.h> |
45 | #include <linux/rfkill.h> | ||
54 | 46 | ||
55 | #define COMPAL_DRIVER_VERSION "0.2.6" | 47 | #define COMPAL_DRIVER_VERSION "0.2.6" |
56 | 48 | ||
@@ -63,6 +55,10 @@ | |||
63 | #define WLAN_MASK 0x01 | 55 | #define WLAN_MASK 0x01 |
64 | #define BT_MASK 0x02 | 56 | #define BT_MASK 0x02 |
65 | 57 | ||
58 | static struct rfkill *wifi_rfkill; | ||
59 | static struct rfkill *bt_rfkill; | ||
60 | static struct platform_device *compal_device; | ||
61 | |||
66 | static int force; | 62 | static int force; |
67 | module_param(force, bool, 0); | 63 | module_param(force, bool, 0); |
68 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); | 64 | MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); |
@@ -88,65 +84,75 @@ static int get_lcd_level(void) | |||
88 | return (int) result; | 84 | return (int) result; |
89 | } | 85 | } |
90 | 86 | ||
91 | static int set_wlan_state(int state) | 87 | static int compal_rfkill_set(void *data, bool blocked) |
92 | { | 88 | { |
89 | unsigned long radio = (unsigned long) data; | ||
93 | u8 result, value; | 90 | u8 result, value; |
94 | 91 | ||
95 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | 92 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); |
96 | 93 | ||
97 | if ((result & KILLSWITCH_MASK) == 0) | 94 | if (!blocked) |
98 | return -EINVAL; | 95 | value = (u8) (result | radio); |
99 | else { | 96 | else |
100 | if (state) | 97 | value = (u8) (result & ~radio); |
101 | value = (u8) (result | WLAN_MASK); | 98 | ec_write(COMPAL_EC_COMMAND_WIRELESS, value); |
102 | else | ||
103 | value = (u8) (result & ~WLAN_MASK); | ||
104 | ec_write(COMPAL_EC_COMMAND_WIRELESS, value); | ||
105 | } | ||
106 | 99 | ||
107 | return 0; | 100 | return 0; |
108 | } | 101 | } |
109 | 102 | ||
110 | static int set_bluetooth_state(int state) | 103 | static void compal_rfkill_poll(struct rfkill *rfkill, void *data) |
111 | { | 104 | { |
112 | u8 result, value; | 105 | u8 result; |
106 | bool hw_blocked; | ||
113 | 107 | ||
114 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | 108 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); |
115 | 109 | ||
116 | if ((result & KILLSWITCH_MASK) == 0) | 110 | hw_blocked = !(result & KILLSWITCH_MASK); |
117 | return -EINVAL; | 111 | rfkill_set_hw_state(rfkill, hw_blocked); |
118 | else { | ||
119 | if (state) | ||
120 | value = (u8) (result | BT_MASK); | ||
121 | else | ||
122 | value = (u8) (result & ~BT_MASK); | ||
123 | ec_write(COMPAL_EC_COMMAND_WIRELESS, value); | ||
124 | } | ||
125 | |||
126 | return 0; | ||
127 | } | 112 | } |
128 | 113 | ||
129 | static int get_wireless_state(int *wlan, int *bluetooth) | 114 | static const struct rfkill_ops compal_rfkill_ops = { |
115 | .poll = compal_rfkill_poll, | ||
116 | .set_block = compal_rfkill_set, | ||
117 | }; | ||
118 | |||
119 | static int setup_rfkill(void) | ||
130 | { | 120 | { |
131 | u8 result; | 121 | int ret; |
132 | 122 | ||
133 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | 123 | wifi_rfkill = rfkill_alloc("compal-wifi", &compal_device->dev, |
124 | RFKILL_TYPE_WLAN, &compal_rfkill_ops, | ||
125 | (void *) WLAN_MASK); | ||
126 | if (!wifi_rfkill) | ||
127 | return -ENOMEM; | ||
134 | 128 | ||
135 | if (wlan) { | 129 | ret = rfkill_register(wifi_rfkill); |
136 | if ((result & KILLSWITCH_MASK) == 0) | 130 | if (ret) |
137 | *wlan = 0; | 131 | goto err_wifi; |
138 | else | ||
139 | *wlan = result & WLAN_MASK; | ||
140 | } | ||
141 | 132 | ||
142 | if (bluetooth) { | 133 | bt_rfkill = rfkill_alloc("compal-bluetooth", &compal_device->dev, |
143 | if ((result & KILLSWITCH_MASK) == 0) | 134 | RFKILL_TYPE_BLUETOOTH, &compal_rfkill_ops, |
144 | *bluetooth = 0; | 135 | (void *) BT_MASK); |
145 | else | 136 | if (!bt_rfkill) { |
146 | *bluetooth = (result & BT_MASK) >> 1; | 137 | ret = -ENOMEM; |
138 | goto err_allocate_bt; | ||
147 | } | 139 | } |
140 | ret = rfkill_register(bt_rfkill); | ||
141 | if (ret) | ||
142 | goto err_register_bt; | ||
148 | 143 | ||
149 | return 0; | 144 | return 0; |
145 | |||
146 | err_register_bt: | ||
147 | rfkill_destroy(bt_rfkill); | ||
148 | |||
149 | err_allocate_bt: | ||
150 | rfkill_unregister(wifi_rfkill); | ||
151 | |||
152 | err_wifi: | ||
153 | rfkill_destroy(wifi_rfkill); | ||
154 | |||
155 | return ret; | ||
150 | } | 156 | } |
151 | 157 | ||
152 | /* Backlight device stuff */ | 158 | /* Backlight device stuff */ |
@@ -169,86 +175,6 @@ static struct backlight_ops compalbl_ops = { | |||
169 | 175 | ||
170 | static struct backlight_device *compalbl_device; | 176 | static struct backlight_device *compalbl_device; |
171 | 177 | ||
172 | /* Platform device */ | ||
173 | |||
174 | static ssize_t show_wlan(struct device *dev, | ||
175 | struct device_attribute *attr, char *buf) | ||
176 | { | ||
177 | int ret, enabled; | ||
178 | |||
179 | ret = get_wireless_state(&enabled, NULL); | ||
180 | if (ret < 0) | ||
181 | return ret; | ||
182 | |||
183 | return sprintf(buf, "%i\n", enabled); | ||
184 | } | ||
185 | |||
186 | static ssize_t show_raw(struct device *dev, | ||
187 | struct device_attribute *attr, char *buf) | ||
188 | { | ||
189 | u8 result; | ||
190 | |||
191 | ec_read(COMPAL_EC_COMMAND_WIRELESS, &result); | ||
192 | |||
193 | return sprintf(buf, "%i\n", result); | ||
194 | } | ||
195 | |||
196 | static ssize_t show_bluetooth(struct device *dev, | ||
197 | struct device_attribute *attr, char *buf) | ||
198 | { | ||
199 | int ret, enabled; | ||
200 | |||
201 | ret = get_wireless_state(NULL, &enabled); | ||
202 | if (ret < 0) | ||
203 | return ret; | ||
204 | |||
205 | return sprintf(buf, "%i\n", enabled); | ||
206 | } | ||
207 | |||
208 | static ssize_t store_wlan_state(struct device *dev, | ||
209 | struct device_attribute *attr, const char *buf, size_t count) | ||
210 | { | ||
211 | int state, ret; | ||
212 | |||
213 | if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) | ||
214 | return -EINVAL; | ||
215 | |||
216 | ret = set_wlan_state(state); | ||
217 | if (ret < 0) | ||
218 | return ret; | ||
219 | |||
220 | return count; | ||
221 | } | ||
222 | |||
223 | static ssize_t store_bluetooth_state(struct device *dev, | ||
224 | struct device_attribute *attr, const char *buf, size_t count) | ||
225 | { | ||
226 | int state, ret; | ||
227 | |||
228 | if (sscanf(buf, "%i", &state) != 1 || (state < 0 || state > 1)) | ||
229 | return -EINVAL; | ||
230 | |||
231 | ret = set_bluetooth_state(state); | ||
232 | if (ret < 0) | ||
233 | return ret; | ||
234 | |||
235 | return count; | ||
236 | } | ||
237 | |||
238 | static DEVICE_ATTR(bluetooth, 0644, show_bluetooth, store_bluetooth_state); | ||
239 | static DEVICE_ATTR(wlan, 0644, show_wlan, store_wlan_state); | ||
240 | static DEVICE_ATTR(raw, 0444, show_raw, NULL); | ||
241 | |||
242 | static struct attribute *compal_attributes[] = { | ||
243 | &dev_attr_bluetooth.attr, | ||
244 | &dev_attr_wlan.attr, | ||
245 | &dev_attr_raw.attr, | ||
246 | NULL | ||
247 | }; | ||
248 | |||
249 | static struct attribute_group compal_attribute_group = { | ||
250 | .attrs = compal_attributes | ||
251 | }; | ||
252 | 178 | ||
253 | static struct platform_driver compal_driver = { | 179 | static struct platform_driver compal_driver = { |
254 | .driver = { | 180 | .driver = { |
@@ -257,8 +183,6 @@ static struct platform_driver compal_driver = { | |||
257 | } | 183 | } |
258 | }; | 184 | }; |
259 | 185 | ||
260 | static struct platform_device *compal_device; | ||
261 | |||
262 | /* Initialization */ | 186 | /* Initialization */ |
263 | 187 | ||
264 | static int dmi_check_cb(const struct dmi_system_id *id) | 188 | static int dmi_check_cb(const struct dmi_system_id *id) |
@@ -310,6 +234,47 @@ static struct dmi_system_id __initdata compal_dmi_table[] = { | |||
310 | }, | 234 | }, |
311 | .callback = dmi_check_cb | 235 | .callback = dmi_check_cb |
312 | }, | 236 | }, |
237 | { | ||
238 | .ident = "Dell Mini 9", | ||
239 | .matches = { | ||
240 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
241 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 910"), | ||
242 | }, | ||
243 | .callback = dmi_check_cb | ||
244 | }, | ||
245 | { | ||
246 | .ident = "Dell Mini 10", | ||
247 | .matches = { | ||
248 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
249 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1010"), | ||
250 | }, | ||
251 | .callback = dmi_check_cb | ||
252 | }, | ||
253 | { | ||
254 | .ident = "Dell Mini 10v", | ||
255 | .matches = { | ||
256 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
257 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1011"), | ||
258 | }, | ||
259 | .callback = dmi_check_cb | ||
260 | }, | ||
261 | { | ||
262 | .ident = "Dell Inspiron 11z", | ||
263 | .matches = { | ||
264 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
265 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1110"), | ||
266 | }, | ||
267 | .callback = dmi_check_cb | ||
268 | }, | ||
269 | { | ||
270 | .ident = "Dell Mini 12", | ||
271 | .matches = { | ||
272 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
273 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1210"), | ||
274 | }, | ||
275 | .callback = dmi_check_cb | ||
276 | }, | ||
277 | |||
313 | { } | 278 | { } |
314 | }; | 279 | }; |
315 | 280 | ||
@@ -348,23 +313,21 @@ static int __init compal_init(void) | |||
348 | 313 | ||
349 | ret = platform_device_add(compal_device); | 314 | ret = platform_device_add(compal_device); |
350 | if (ret) | 315 | if (ret) |
351 | goto fail_platform_device1; | 316 | goto fail_platform_device; |
352 | 317 | ||
353 | ret = sysfs_create_group(&compal_device->dev.kobj, | 318 | ret = setup_rfkill(); |
354 | &compal_attribute_group); | ||
355 | if (ret) | 319 | if (ret) |
356 | goto fail_platform_device2; | 320 | goto fail_rfkill; |
357 | 321 | ||
358 | printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION | 322 | printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION |
359 | " successfully loaded.\n"); | 323 | " successfully loaded.\n"); |
360 | 324 | ||
361 | return 0; | 325 | return 0; |
362 | 326 | ||
363 | fail_platform_device2: | 327 | fail_rfkill: |
364 | |||
365 | platform_device_del(compal_device); | 328 | platform_device_del(compal_device); |
366 | 329 | ||
367 | fail_platform_device1: | 330 | fail_platform_device: |
368 | 331 | ||
369 | platform_device_put(compal_device); | 332 | platform_device_put(compal_device); |
370 | 333 | ||
@@ -382,10 +345,13 @@ fail_backlight: | |||
382 | static void __exit compal_cleanup(void) | 345 | static void __exit compal_cleanup(void) |
383 | { | 346 | { |
384 | 347 | ||
385 | sysfs_remove_group(&compal_device->dev.kobj, &compal_attribute_group); | ||
386 | platform_device_unregister(compal_device); | 348 | platform_device_unregister(compal_device); |
387 | platform_driver_unregister(&compal_driver); | 349 | platform_driver_unregister(&compal_driver); |
388 | backlight_device_unregister(compalbl_device); | 350 | backlight_device_unregister(compalbl_device); |
351 | rfkill_unregister(wifi_rfkill); | ||
352 | rfkill_destroy(wifi_rfkill); | ||
353 | rfkill_unregister(bt_rfkill); | ||
354 | rfkill_destroy(bt_rfkill); | ||
389 | 355 | ||
390 | printk(KERN_INFO "compal-laptop: driver unloaded.\n"); | 356 | printk(KERN_INFO "compal-laptop: driver unloaded.\n"); |
391 | } | 357 | } |
@@ -403,3 +369,8 @@ MODULE_ALIAS("dmi:*:rnIFL90:rvrREFERENCE:*"); | |||
403 | MODULE_ALIAS("dmi:*:rnIFL91:rvrIFT00:*"); | 369 | MODULE_ALIAS("dmi:*:rnIFL91:rvrIFT00:*"); |
404 | MODULE_ALIAS("dmi:*:rnJFL92:rvrIFT00:*"); | 370 | MODULE_ALIAS("dmi:*:rnJFL92:rvrIFT00:*"); |
405 | MODULE_ALIAS("dmi:*:rnIFT00:rvrIFT00:*"); | 371 | MODULE_ALIAS("dmi:*:rnIFT00:rvrIFT00:*"); |
372 | MODULE_ALIAS("dmi:*:svnDellInc.:pnInspiron910:*"); | ||
373 | MODULE_ALIAS("dmi:*:svnDellInc.:pnInspiron1010:*"); | ||
374 | MODULE_ALIAS("dmi:*:svnDellInc.:pnInspiron1011:*"); | ||
375 | MODULE_ALIAS("dmi:*:svnDellInc.:pnInspiron1110:*"); | ||
376 | MODULE_ALIAS("dmi:*:svnDellInc.:pnInspiron1210:*"); | ||
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 3780994dc8f2..ef614979afe9 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/rfkill.h> | 22 | #include <linux/rfkill.h> |
23 | #include <linux/power_supply.h> | 23 | #include <linux/power_supply.h> |
24 | #include <linux/acpi.h> | 24 | #include <linux/acpi.h> |
25 | #include <linux/mm.h> | ||
26 | #include <linux/i8042.h> | ||
25 | #include "../../firmware/dcdbas.h" | 27 | #include "../../firmware/dcdbas.h" |
26 | 28 | ||
27 | #define BRIGHTNESS_TOKEN 0x7d | 29 | #define BRIGHTNESS_TOKEN 0x7d |
@@ -79,9 +81,73 @@ static const struct dmi_system_id __initdata dell_device_table[] = { | |||
79 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), | 81 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), |
80 | }, | 82 | }, |
81 | }, | 83 | }, |
84 | { | ||
85 | .ident = "Dell Computer Corporation", | ||
86 | .matches = { | ||
87 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), | ||
88 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), | ||
89 | }, | ||
90 | }, | ||
82 | { } | 91 | { } |
83 | }; | 92 | }; |
84 | 93 | ||
94 | static struct dmi_system_id __devinitdata dell_blacklist[] = { | ||
95 | /* Supported by compal-laptop */ | ||
96 | { | ||
97 | .ident = "Dell Mini 9", | ||
98 | .matches = { | ||
99 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
100 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 910"), | ||
101 | }, | ||
102 | }, | ||
103 | { | ||
104 | .ident = "Dell Mini 10", | ||
105 | .matches = { | ||
106 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
107 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1010"), | ||
108 | }, | ||
109 | }, | ||
110 | { | ||
111 | .ident = "Dell Mini 10v", | ||
112 | .matches = { | ||
113 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
114 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1011"), | ||
115 | }, | ||
116 | }, | ||
117 | { | ||
118 | .ident = "Dell Inspiron 11z", | ||
119 | .matches = { | ||
120 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
121 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1110"), | ||
122 | }, | ||
123 | }, | ||
124 | { | ||
125 | .ident = "Dell Mini 12", | ||
126 | .matches = { | ||
127 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
128 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1210"), | ||
129 | }, | ||
130 | }, | ||
131 | {} | ||
132 | }; | ||
133 | |||
134 | static struct calling_interface_buffer *buffer; | ||
135 | static struct page *bufferpage; | ||
136 | static DEFINE_MUTEX(buffer_mutex); | ||
137 | |||
138 | static int hwswitch_state; | ||
139 | |||
140 | static void get_buffer(void) | ||
141 | { | ||
142 | mutex_lock(&buffer_mutex); | ||
143 | memset(buffer, 0, sizeof(struct calling_interface_buffer)); | ||
144 | } | ||
145 | |||
146 | static void release_buffer(void) | ||
147 | { | ||
148 | mutex_unlock(&buffer_mutex); | ||
149 | } | ||
150 | |||
85 | static void __init parse_da_table(const struct dmi_header *dm) | 151 | static void __init parse_da_table(const struct dmi_header *dm) |
86 | { | 152 | { |
87 | /* Final token is a terminator, so we don't want to copy it */ | 153 | /* Final token is a terminator, so we don't want to copy it */ |
@@ -160,6 +226,8 @@ dell_send_request(struct calling_interface_buffer *buffer, int class, | |||
160 | /* Derived from information in DellWirelessCtl.cpp: | 226 | /* Derived from information in DellWirelessCtl.cpp: |
161 | Class 17, select 11 is radio control. It returns an array of 32-bit values. | 227 | Class 17, select 11 is radio control. It returns an array of 32-bit values. |
162 | 228 | ||
229 | Input byte 0 = 0: Wireless information | ||
230 | |||
163 | result[0]: return code | 231 | result[0]: return code |
164 | result[1]: | 232 | result[1]: |
165 | Bit 0: Hardware switch supported | 233 | Bit 0: Hardware switch supported |
@@ -180,33 +248,62 @@ dell_send_request(struct calling_interface_buffer *buffer, int class, | |||
180 | Bits 20-31: Reserved | 248 | Bits 20-31: Reserved |
181 | result[2]: NVRAM size in bytes | 249 | result[2]: NVRAM size in bytes |
182 | result[3]: NVRAM format version number | 250 | result[3]: NVRAM format version number |
251 | |||
252 | Input byte 0 = 2: Wireless switch configuration | ||
253 | result[0]: return code | ||
254 | result[1]: | ||
255 | Bit 0: Wifi controlled by switch | ||
256 | Bit 1: Bluetooth controlled by switch | ||
257 | Bit 2: WWAN controlled by switch | ||
258 | Bits 3-6: Reserved | ||
259 | Bit 7: Wireless switch config locked | ||
260 | Bit 8: Wifi locator enabled | ||
261 | Bits 9-14: Reserved | ||
262 | Bit 15: Wifi locator setting locked | ||
263 | Bits 16-31: Reserved | ||
183 | */ | 264 | */ |
184 | 265 | ||
185 | static int dell_rfkill_set(void *data, bool blocked) | 266 | static int dell_rfkill_set(void *data, bool blocked) |
186 | { | 267 | { |
187 | struct calling_interface_buffer buffer; | ||
188 | int disable = blocked ? 1 : 0; | 268 | int disable = blocked ? 1 : 0; |
189 | unsigned long radio = (unsigned long)data; | 269 | unsigned long radio = (unsigned long)data; |
270 | int hwswitch_bit = (unsigned long)data - 1; | ||
271 | int ret = 0; | ||
272 | |||
273 | get_buffer(); | ||
274 | dell_send_request(buffer, 17, 11); | ||
275 | |||
276 | /* If the hardware switch controls this radio, and the hardware | ||
277 | switch is disabled, don't allow changing the software state */ | ||
278 | if ((hwswitch_state & BIT(hwswitch_bit)) && | ||
279 | !(buffer->output[1] & BIT(16))) { | ||
280 | ret = -EINVAL; | ||
281 | goto out; | ||
282 | } | ||
190 | 283 | ||
191 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 284 | buffer->input[0] = (1 | (radio<<8) | (disable << 16)); |
192 | buffer.input[0] = (1 | (radio<<8) | (disable << 16)); | 285 | dell_send_request(buffer, 17, 11); |
193 | dell_send_request(&buffer, 17, 11); | ||
194 | 286 | ||
195 | return 0; | 287 | out: |
288 | release_buffer(); | ||
289 | return ret; | ||
196 | } | 290 | } |
197 | 291 | ||
198 | static void dell_rfkill_query(struct rfkill *rfkill, void *data) | 292 | static void dell_rfkill_query(struct rfkill *rfkill, void *data) |
199 | { | 293 | { |
200 | struct calling_interface_buffer buffer; | ||
201 | int status; | 294 | int status; |
202 | int bit = (unsigned long)data + 16; | 295 | int bit = (unsigned long)data + 16; |
296 | int hwswitch_bit = (unsigned long)data - 1; | ||
203 | 297 | ||
204 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 298 | get_buffer(); |
205 | dell_send_request(&buffer, 17, 11); | 299 | dell_send_request(buffer, 17, 11); |
206 | status = buffer.output[1]; | 300 | status = buffer->output[1]; |
301 | release_buffer(); | ||
207 | 302 | ||
208 | rfkill_set_sw_state(rfkill, !!(status & BIT(bit))); | 303 | rfkill_set_sw_state(rfkill, !!(status & BIT(bit))); |
209 | rfkill_set_hw_state(rfkill, !(status & BIT(16))); | 304 | |
305 | if (hwswitch_state & (BIT(hwswitch_bit))) | ||
306 | rfkill_set_hw_state(rfkill, !(status & BIT(16))); | ||
210 | } | 307 | } |
211 | 308 | ||
212 | static const struct rfkill_ops dell_rfkill_ops = { | 309 | static const struct rfkill_ops dell_rfkill_ops = { |
@@ -214,15 +311,36 @@ static const struct rfkill_ops dell_rfkill_ops = { | |||
214 | .query = dell_rfkill_query, | 311 | .query = dell_rfkill_query, |
215 | }; | 312 | }; |
216 | 313 | ||
314 | static void dell_update_rfkill(struct work_struct *ignored) | ||
315 | { | ||
316 | if (wifi_rfkill) | ||
317 | dell_rfkill_query(wifi_rfkill, (void *)1); | ||
318 | if (bluetooth_rfkill) | ||
319 | dell_rfkill_query(bluetooth_rfkill, (void *)2); | ||
320 | if (wwan_rfkill) | ||
321 | dell_rfkill_query(wwan_rfkill, (void *)3); | ||
322 | } | ||
323 | static DECLARE_DELAYED_WORK(dell_rfkill_work, dell_update_rfkill); | ||
324 | |||
325 | |||
217 | static int __init dell_setup_rfkill(void) | 326 | static int __init dell_setup_rfkill(void) |
218 | { | 327 | { |
219 | struct calling_interface_buffer buffer; | ||
220 | int status; | 328 | int status; |
221 | int ret; | 329 | int ret; |
222 | 330 | ||
223 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 331 | if (dmi_check_system(dell_blacklist)) { |
224 | dell_send_request(&buffer, 17, 11); | 332 | printk(KERN_INFO "dell-laptop: Blacklisted hardware detected - " |
225 | status = buffer.output[1]; | 333 | "not enabling rfkill\n"); |
334 | return 0; | ||
335 | } | ||
336 | |||
337 | get_buffer(); | ||
338 | dell_send_request(buffer, 17, 11); | ||
339 | status = buffer->output[1]; | ||
340 | buffer->input[0] = 0x2; | ||
341 | dell_send_request(buffer, 17, 11); | ||
342 | hwswitch_state = buffer->output[1]; | ||
343 | release_buffer(); | ||
226 | 344 | ||
227 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { | 345 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { |
228 | wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, | 346 | wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, |
@@ -298,39 +416,49 @@ static void dell_cleanup_rfkill(void) | |||
298 | 416 | ||
299 | static int dell_send_intensity(struct backlight_device *bd) | 417 | static int dell_send_intensity(struct backlight_device *bd) |
300 | { | 418 | { |
301 | struct calling_interface_buffer buffer; | 419 | int ret = 0; |
302 | 420 | ||
303 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 421 | get_buffer(); |
304 | buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN); | 422 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
305 | buffer.input[1] = bd->props.brightness; | 423 | buffer->input[1] = bd->props.brightness; |
306 | 424 | ||
307 | if (buffer.input[0] == -1) | 425 | if (buffer->input[0] == -1) { |
308 | return -ENODEV; | 426 | ret = -ENODEV; |
427 | goto out; | ||
428 | } | ||
309 | 429 | ||
310 | if (power_supply_is_system_supplied() > 0) | 430 | if (power_supply_is_system_supplied() > 0) |
311 | dell_send_request(&buffer, 1, 2); | 431 | dell_send_request(buffer, 1, 2); |
312 | else | 432 | else |
313 | dell_send_request(&buffer, 1, 1); | 433 | dell_send_request(buffer, 1, 1); |
314 | 434 | ||
435 | out: | ||
436 | release_buffer(); | ||
315 | return 0; | 437 | return 0; |
316 | } | 438 | } |
317 | 439 | ||
318 | static int dell_get_intensity(struct backlight_device *bd) | 440 | static int dell_get_intensity(struct backlight_device *bd) |
319 | { | 441 | { |
320 | struct calling_interface_buffer buffer; | 442 | int ret = 0; |
321 | 443 | ||
322 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 444 | get_buffer(); |
323 | buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN); | 445 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
324 | 446 | ||
325 | if (buffer.input[0] == -1) | 447 | if (buffer->input[0] == -1) { |
326 | return -ENODEV; | 448 | ret = -ENODEV; |
449 | goto out; | ||
450 | } | ||
327 | 451 | ||
328 | if (power_supply_is_system_supplied() > 0) | 452 | if (power_supply_is_system_supplied() > 0) |
329 | dell_send_request(&buffer, 0, 2); | 453 | dell_send_request(buffer, 0, 2); |
330 | else | 454 | else |
331 | dell_send_request(&buffer, 0, 1); | 455 | dell_send_request(buffer, 0, 1); |
332 | 456 | ||
333 | return buffer.output[1]; | 457 | out: |
458 | release_buffer(); | ||
459 | if (ret) | ||
460 | return ret; | ||
461 | return buffer->output[1]; | ||
334 | } | 462 | } |
335 | 463 | ||
336 | static struct backlight_ops dell_ops = { | 464 | static struct backlight_ops dell_ops = { |
@@ -338,9 +466,32 @@ static struct backlight_ops dell_ops = { | |||
338 | .update_status = dell_send_intensity, | 466 | .update_status = dell_send_intensity, |
339 | }; | 467 | }; |
340 | 468 | ||
469 | bool dell_laptop_i8042_filter(unsigned char data, unsigned char str, | ||
470 | struct serio *port) | ||
471 | { | ||
472 | static bool extended; | ||
473 | |||
474 | if (str & 0x20) | ||
475 | return false; | ||
476 | |||
477 | if (unlikely(data == 0xe0)) { | ||
478 | extended = true; | ||
479 | return false; | ||
480 | } else if (unlikely(extended)) { | ||
481 | switch (data) { | ||
482 | case 0x8: | ||
483 | schedule_delayed_work(&dell_rfkill_work, | ||
484 | round_jiffies_relative(HZ)); | ||
485 | break; | ||
486 | } | ||
487 | extended = false; | ||
488 | } | ||
489 | |||
490 | return false; | ||
491 | } | ||
492 | |||
341 | static int __init dell_init(void) | 493 | static int __init dell_init(void) |
342 | { | 494 | { |
343 | struct calling_interface_buffer buffer; | ||
344 | int max_intensity = 0; | 495 | int max_intensity = 0; |
345 | int ret; | 496 | int ret; |
346 | 497 | ||
@@ -366,6 +517,17 @@ static int __init dell_init(void) | |||
366 | if (ret) | 517 | if (ret) |
367 | goto fail_platform_device2; | 518 | goto fail_platform_device2; |
368 | 519 | ||
520 | /* | ||
521 | * Allocate buffer below 4GB for SMI data--only 32-bit physical addr | ||
522 | * is passed to SMI handler. | ||
523 | */ | ||
524 | bufferpage = alloc_page(GFP_KERNEL | GFP_DMA32); | ||
525 | |||
526 | if (!bufferpage) | ||
527 | goto fail_buffer; | ||
528 | buffer = page_address(bufferpage); | ||
529 | mutex_init(&buffer_mutex); | ||
530 | |||
369 | ret = dell_setup_rfkill(); | 531 | ret = dell_setup_rfkill(); |
370 | 532 | ||
371 | if (ret) { | 533 | if (ret) { |
@@ -373,6 +535,13 @@ static int __init dell_init(void) | |||
373 | goto fail_rfkill; | 535 | goto fail_rfkill; |
374 | } | 536 | } |
375 | 537 | ||
538 | ret = i8042_install_filter(dell_laptop_i8042_filter); | ||
539 | if (ret) { | ||
540 | printk(KERN_WARNING | ||
541 | "dell-laptop: Unable to install key filter\n"); | ||
542 | goto fail_filter; | ||
543 | } | ||
544 | |||
376 | #ifdef CONFIG_ACPI | 545 | #ifdef CONFIG_ACPI |
377 | /* In the event of an ACPI backlight being available, don't | 546 | /* In the event of an ACPI backlight being available, don't |
378 | * register the platform controller. | 547 | * register the platform controller. |
@@ -381,13 +550,13 @@ static int __init dell_init(void) | |||
381 | return 0; | 550 | return 0; |
382 | #endif | 551 | #endif |
383 | 552 | ||
384 | memset(&buffer, 0, sizeof(struct calling_interface_buffer)); | 553 | get_buffer(); |
385 | buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN); | 554 | buffer->input[0] = find_token_location(BRIGHTNESS_TOKEN); |
386 | 555 | if (buffer->input[0] != -1) { | |
387 | if (buffer.input[0] != -1) { | 556 | dell_send_request(buffer, 0, 2); |
388 | dell_send_request(&buffer, 0, 2); | 557 | max_intensity = buffer->output[3]; |
389 | max_intensity = buffer.output[3]; | ||
390 | } | 558 | } |
559 | release_buffer(); | ||
391 | 560 | ||
392 | if (max_intensity) { | 561 | if (max_intensity) { |
393 | dell_backlight_device = backlight_device_register( | 562 | dell_backlight_device = backlight_device_register( |
@@ -410,8 +579,13 @@ static int __init dell_init(void) | |||
410 | return 0; | 579 | return 0; |
411 | 580 | ||
412 | fail_backlight: | 581 | fail_backlight: |
582 | i8042_remove_filter(dell_laptop_i8042_filter); | ||
583 | cancel_delayed_work_sync(&dell_rfkill_work); | ||
584 | fail_filter: | ||
413 | dell_cleanup_rfkill(); | 585 | dell_cleanup_rfkill(); |
414 | fail_rfkill: | 586 | fail_rfkill: |
587 | free_page((unsigned long)bufferpage); | ||
588 | fail_buffer: | ||
415 | platform_device_del(platform_device); | 589 | platform_device_del(platform_device); |
416 | fail_platform_device2: | 590 | fail_platform_device2: |
417 | platform_device_put(platform_device); | 591 | platform_device_put(platform_device); |
@@ -424,8 +598,16 @@ fail_platform_driver: | |||
424 | 598 | ||
425 | static void __exit dell_exit(void) | 599 | static void __exit dell_exit(void) |
426 | { | 600 | { |
601 | i8042_remove_filter(dell_laptop_i8042_filter); | ||
602 | cancel_delayed_work_sync(&dell_rfkill_work); | ||
427 | backlight_device_unregister(dell_backlight_device); | 603 | backlight_device_unregister(dell_backlight_device); |
428 | dell_cleanup_rfkill(); | 604 | dell_cleanup_rfkill(); |
605 | if (platform_device) { | ||
606 | platform_device_unregister(platform_device); | ||
607 | platform_driver_unregister(&platform_driver); | ||
608 | } | ||
609 | kfree(da_tokens); | ||
610 | free_page((unsigned long)buffer); | ||
429 | } | 611 | } |
430 | 612 | ||
431 | module_init(dell_init); | 613 | module_init(dell_init); |
@@ -435,3 +617,4 @@ MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>"); | |||
435 | MODULE_DESCRIPTION("Dell laptop driver"); | 617 | MODULE_DESCRIPTION("Dell laptop driver"); |
436 | MODULE_LICENSE("GPL"); | 618 | MODULE_LICENSE("GPL"); |
437 | MODULE_ALIAS("dmi:*svnDellInc.:*:ct8:*"); | 619 | MODULE_ALIAS("dmi:*svnDellInc.:*:ct8:*"); |
620 | MODULE_ALIAS("dmi:*svnDellComputerCorporation.:*:ct8:*"); | ||
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index e2be6bb33d92..9a844caa3756 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -578,6 +578,8 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) | |||
578 | struct pci_dev *dev; | 578 | struct pci_dev *dev; |
579 | struct pci_bus *bus; | 579 | struct pci_bus *bus; |
580 | bool blocked = eeepc_wlan_rfkill_blocked(eeepc); | 580 | bool blocked = eeepc_wlan_rfkill_blocked(eeepc); |
581 | bool absent; | ||
582 | u32 l; | ||
581 | 583 | ||
582 | if (eeepc->wlan_rfkill) | 584 | if (eeepc->wlan_rfkill) |
583 | rfkill_set_sw_state(eeepc->wlan_rfkill, blocked); | 585 | rfkill_set_sw_state(eeepc->wlan_rfkill, blocked); |
@@ -591,6 +593,22 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) | |||
591 | goto out_unlock; | 593 | goto out_unlock; |
592 | } | 594 | } |
593 | 595 | ||
596 | if (pci_bus_read_config_dword(bus, 0, PCI_VENDOR_ID, &l)) { | ||
597 | pr_err("Unable to read PCI config space?\n"); | ||
598 | goto out_unlock; | ||
599 | } | ||
600 | absent = (l == 0xffffffff); | ||
601 | |||
602 | if (blocked != absent) { | ||
603 | pr_warning("BIOS says wireless lan is %s, " | ||
604 | "but the pci device is %s\n", | ||
605 | blocked ? "blocked" : "unblocked", | ||
606 | absent ? "absent" : "present"); | ||
607 | pr_warning("skipped wireless hotplug as probably " | ||
608 | "inappropriate for this model\n"); | ||
609 | goto out_unlock; | ||
610 | } | ||
611 | |||
594 | if (!blocked) { | 612 | if (!blocked) { |
595 | dev = pci_get_slot(bus, 0); | 613 | dev = pci_get_slot(bus, 0); |
596 | if (dev) { | 614 | if (dev) { |
@@ -1277,7 +1295,8 @@ static void eeepc_dmi_check(struct eeepc_laptop *eeepc) | |||
1277 | * hotplug code. In fact, current hotplug code seems to unplug another | 1295 | * hotplug code. In fact, current hotplug code seems to unplug another |
1278 | * device... | 1296 | * device... |
1279 | */ | 1297 | */ |
1280 | if (strcmp(model, "1005HA") == 0 || strcmp(model, "1201N") == 0) { | 1298 | if (strcmp(model, "1005HA") == 0 || strcmp(model, "1201N") == 0 || |
1299 | strcmp(model, "1005PE") == 0) { | ||
1281 | eeepc->hotplug_disabled = true; | 1300 | eeepc->hotplug_disabled = true; |
1282 | pr_info("wlan hotplug disabled\n"); | 1301 | pr_info("wlan hotplug disabled\n"); |
1283 | } | 1302 | } |
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index ad4c414dbfbc..3aa57da8b43b 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c | |||
@@ -89,6 +89,7 @@ static struct key_entry hp_wmi_keymap[] = { | |||
89 | {KE_KEY, 0x20e6, KEY_PROG1}, | 89 | {KE_KEY, 0x20e6, KEY_PROG1}, |
90 | {KE_KEY, 0x2142, KEY_MEDIA}, | 90 | {KE_KEY, 0x2142, KEY_MEDIA}, |
91 | {KE_KEY, 0x213b, KEY_INFO}, | 91 | {KE_KEY, 0x213b, KEY_INFO}, |
92 | {KE_KEY, 0x2169, KEY_DIRECTION}, | ||
92 | {KE_KEY, 0x231b, KEY_HELP}, | 93 | {KE_KEY, 0x231b, KEY_HELP}, |
93 | {KE_END, 0} | 94 | {KE_END, 0} |
94 | }; | 95 | }; |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index eb603f1d55ca..e7b0c3bcef89 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -286,6 +286,7 @@ struct ibm_init_struct { | |||
286 | char param[32]; | 286 | char param[32]; |
287 | 287 | ||
288 | int (*init) (struct ibm_init_struct *); | 288 | int (*init) (struct ibm_init_struct *); |
289 | mode_t base_procfs_mode; | ||
289 | struct ibm_struct *data; | 290 | struct ibm_struct *data; |
290 | }; | 291 | }; |
291 | 292 | ||
@@ -2082,6 +2083,7 @@ static struct attribute_set *hotkey_dev_attributes; | |||
2082 | 2083 | ||
2083 | static void tpacpi_driver_event(const unsigned int hkey_event); | 2084 | static void tpacpi_driver_event(const unsigned int hkey_event); |
2084 | static void hotkey_driver_event(const unsigned int scancode); | 2085 | static void hotkey_driver_event(const unsigned int scancode); |
2086 | static void hotkey_poll_setup(const bool may_warn); | ||
2085 | 2087 | ||
2086 | /* HKEY.MHKG() return bits */ | 2088 | /* HKEY.MHKG() return bits */ |
2087 | #define TP_HOTKEY_TABLET_MASK (1 << 3) | 2089 | #define TP_HOTKEY_TABLET_MASK (1 << 3) |
@@ -2264,6 +2266,8 @@ static int tpacpi_hotkey_driver_mask_set(const u32 mask) | |||
2264 | 2266 | ||
2265 | rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) & | 2267 | rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) & |
2266 | ~hotkey_source_mask); | 2268 | ~hotkey_source_mask); |
2269 | hotkey_poll_setup(true); | ||
2270 | |||
2267 | mutex_unlock(&hotkey_mutex); | 2271 | mutex_unlock(&hotkey_mutex); |
2268 | 2272 | ||
2269 | return rc; | 2273 | return rc; |
@@ -2548,7 +2552,7 @@ static void hotkey_poll_stop_sync(void) | |||
2548 | } | 2552 | } |
2549 | 2553 | ||
2550 | /* call with hotkey_mutex held */ | 2554 | /* call with hotkey_mutex held */ |
2551 | static void hotkey_poll_setup(bool may_warn) | 2555 | static void hotkey_poll_setup(const bool may_warn) |
2552 | { | 2556 | { |
2553 | const u32 poll_driver_mask = hotkey_driver_mask & hotkey_source_mask; | 2557 | const u32 poll_driver_mask = hotkey_driver_mask & hotkey_source_mask; |
2554 | const u32 poll_user_mask = hotkey_user_mask & hotkey_source_mask; | 2558 | const u32 poll_user_mask = hotkey_user_mask & hotkey_source_mask; |
@@ -2579,7 +2583,7 @@ static void hotkey_poll_setup(bool may_warn) | |||
2579 | } | 2583 | } |
2580 | } | 2584 | } |
2581 | 2585 | ||
2582 | static void hotkey_poll_setup_safe(bool may_warn) | 2586 | static void hotkey_poll_setup_safe(const bool may_warn) |
2583 | { | 2587 | { |
2584 | mutex_lock(&hotkey_mutex); | 2588 | mutex_lock(&hotkey_mutex); |
2585 | hotkey_poll_setup(may_warn); | 2589 | hotkey_poll_setup(may_warn); |
@@ -2597,7 +2601,11 @@ static void hotkey_poll_set_freq(unsigned int freq) | |||
2597 | 2601 | ||
2598 | #else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ | 2602 | #else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ |
2599 | 2603 | ||
2600 | static void hotkey_poll_setup_safe(bool __unused) | 2604 | static void hotkey_poll_setup(const bool __unused) |
2605 | { | ||
2606 | } | ||
2607 | |||
2608 | static void hotkey_poll_setup_safe(const bool __unused) | ||
2601 | { | 2609 | { |
2602 | } | 2610 | } |
2603 | 2611 | ||
@@ -2607,16 +2615,11 @@ static int hotkey_inputdev_open(struct input_dev *dev) | |||
2607 | { | 2615 | { |
2608 | switch (tpacpi_lifecycle) { | 2616 | switch (tpacpi_lifecycle) { |
2609 | case TPACPI_LIFE_INIT: | 2617 | case TPACPI_LIFE_INIT: |
2610 | /* | ||
2611 | * hotkey_init will call hotkey_poll_setup_safe | ||
2612 | * at the appropriate moment | ||
2613 | */ | ||
2614 | return 0; | ||
2615 | case TPACPI_LIFE_EXITING: | ||
2616 | return -EBUSY; | ||
2617 | case TPACPI_LIFE_RUNNING: | 2618 | case TPACPI_LIFE_RUNNING: |
2618 | hotkey_poll_setup_safe(false); | 2619 | hotkey_poll_setup_safe(false); |
2619 | return 0; | 2620 | return 0; |
2621 | case TPACPI_LIFE_EXITING: | ||
2622 | return -EBUSY; | ||
2620 | } | 2623 | } |
2621 | 2624 | ||
2622 | /* Should only happen if tpacpi_lifecycle is corrupt */ | 2625 | /* Should only happen if tpacpi_lifecycle is corrupt */ |
@@ -2627,7 +2630,7 @@ static int hotkey_inputdev_open(struct input_dev *dev) | |||
2627 | static void hotkey_inputdev_close(struct input_dev *dev) | 2630 | static void hotkey_inputdev_close(struct input_dev *dev) |
2628 | { | 2631 | { |
2629 | /* disable hotkey polling when possible */ | 2632 | /* disable hotkey polling when possible */ |
2630 | if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING && | 2633 | if (tpacpi_lifecycle != TPACPI_LIFE_EXITING && |
2631 | !(hotkey_source_mask & hotkey_driver_mask)) | 2634 | !(hotkey_source_mask & hotkey_driver_mask)) |
2632 | hotkey_poll_setup_safe(false); | 2635 | hotkey_poll_setup_safe(false); |
2633 | } | 2636 | } |
@@ -3655,13 +3658,19 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
3655 | break; | 3658 | break; |
3656 | case 3: | 3659 | case 3: |
3657 | /* 0x3000-0x3FFF: bay-related wakeups */ | 3660 | /* 0x3000-0x3FFF: bay-related wakeups */ |
3658 | if (hkey == TP_HKEY_EV_BAYEJ_ACK) { | 3661 | switch (hkey) { |
3662 | case TP_HKEY_EV_BAYEJ_ACK: | ||
3659 | hotkey_autosleep_ack = 1; | 3663 | hotkey_autosleep_ack = 1; |
3660 | printk(TPACPI_INFO | 3664 | printk(TPACPI_INFO |
3661 | "bay ejected\n"); | 3665 | "bay ejected\n"); |
3662 | hotkey_wakeup_hotunplug_complete_notify_change(); | 3666 | hotkey_wakeup_hotunplug_complete_notify_change(); |
3663 | known_ev = true; | 3667 | known_ev = true; |
3664 | } else { | 3668 | break; |
3669 | case TP_HKEY_EV_OPTDRV_EJ: | ||
3670 | /* FIXME: kick libata if SATA link offline */ | ||
3671 | known_ev = true; | ||
3672 | break; | ||
3673 | default: | ||
3665 | known_ev = false; | 3674 | known_ev = false; |
3666 | } | 3675 | } |
3667 | break; | 3676 | break; |
@@ -3870,7 +3879,7 @@ enum { | |||
3870 | TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */ | 3879 | TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */ |
3871 | TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */ | 3880 | TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */ |
3872 | TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume: | 3881 | TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume: |
3873 | off / last state */ | 3882 | 0 = disable, 1 = enable */ |
3874 | }; | 3883 | }; |
3875 | 3884 | ||
3876 | enum { | 3885 | enum { |
@@ -3916,10 +3925,11 @@ static int bluetooth_set_status(enum tpacpi_rfkill_state state) | |||
3916 | } | 3925 | } |
3917 | #endif | 3926 | #endif |
3918 | 3927 | ||
3919 | /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */ | ||
3920 | status = TP_ACPI_BLUETOOTH_RESUMECTRL; | ||
3921 | if (state == TPACPI_RFK_RADIO_ON) | 3928 | if (state == TPACPI_RFK_RADIO_ON) |
3922 | status |= TP_ACPI_BLUETOOTH_RADIOSSW; | 3929 | status = TP_ACPI_BLUETOOTH_RADIOSSW |
3930 | | TP_ACPI_BLUETOOTH_RESUMECTRL; | ||
3931 | else | ||
3932 | status = 0; | ||
3923 | 3933 | ||
3924 | if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) | 3934 | if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) |
3925 | return -EIO; | 3935 | return -EIO; |
@@ -4070,7 +4080,7 @@ enum { | |||
4070 | TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */ | 4080 | TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */ |
4071 | TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */ | 4081 | TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */ |
4072 | TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume: | 4082 | TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume: |
4073 | off / last state */ | 4083 | 0 = disable, 1 = enable */ |
4074 | }; | 4084 | }; |
4075 | 4085 | ||
4076 | #define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw" | 4086 | #define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw" |
@@ -4107,10 +4117,11 @@ static int wan_set_status(enum tpacpi_rfkill_state state) | |||
4107 | } | 4117 | } |
4108 | #endif | 4118 | #endif |
4109 | 4119 | ||
4110 | /* We make sure to set TP_ACPI_WANCARD_RESUMECTRL */ | ||
4111 | status = TP_ACPI_WANCARD_RESUMECTRL; | ||
4112 | if (state == TPACPI_RFK_RADIO_ON) | 4120 | if (state == TPACPI_RFK_RADIO_ON) |
4113 | status |= TP_ACPI_WANCARD_RADIOSSW; | 4121 | status = TP_ACPI_WANCARD_RADIOSSW |
4122 | | TP_ACPI_WANCARD_RESUMECTRL; | ||
4123 | else | ||
4124 | status = 0; | ||
4114 | 4125 | ||
4115 | if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) | 4126 | if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) |
4116 | return -EIO; | 4127 | return -EIO; |
@@ -4619,6 +4630,10 @@ static int video_read(struct seq_file *m) | |||
4619 | return 0; | 4630 | return 0; |
4620 | } | 4631 | } |
4621 | 4632 | ||
4633 | /* Even reads can crash X.org, so... */ | ||
4634 | if (!capable(CAP_SYS_ADMIN)) | ||
4635 | return -EPERM; | ||
4636 | |||
4622 | status = video_outputsw_get(); | 4637 | status = video_outputsw_get(); |
4623 | if (status < 0) | 4638 | if (status < 0) |
4624 | return status; | 4639 | return status; |
@@ -4652,6 +4667,10 @@ static int video_write(char *buf) | |||
4652 | if (video_supported == TPACPI_VIDEO_NONE) | 4667 | if (video_supported == TPACPI_VIDEO_NONE) |
4653 | return -ENODEV; | 4668 | return -ENODEV; |
4654 | 4669 | ||
4670 | /* Even reads can crash X.org, let alone writes... */ | ||
4671 | if (!capable(CAP_SYS_ADMIN)) | ||
4672 | return -EPERM; | ||
4673 | |||
4655 | enable = 0; | 4674 | enable = 0; |
4656 | disable = 0; | 4675 | disable = 0; |
4657 | 4676 | ||
@@ -6133,13 +6152,13 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = { | |||
6133 | TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */ | 6152 | TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */ |
6134 | 6153 | ||
6135 | /* Models with ATI GPUs that can use ECNVRAM */ | 6154 | /* Models with ATI GPUs that can use ECNVRAM */ |
6136 | TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), | 6155 | TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */ |
6137 | TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), | 6156 | TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
6138 | TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), | 6157 | TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_EC), /* R52 */ |
6139 | TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), | 6158 | TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
6140 | 6159 | ||
6141 | /* Models with Intel Extreme Graphics 2 */ | 6160 | /* Models with Intel Extreme Graphics 2 */ |
6142 | TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC), | 6161 | TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC), /* X40 */ |
6143 | TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), | 6162 | TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
6144 | TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), | 6163 | TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC), |
6145 | 6164 | ||
@@ -6522,7 +6541,8 @@ static int volume_set_status(const u8 status) | |||
6522 | return volume_set_status_ec(status); | 6541 | return volume_set_status_ec(status); |
6523 | } | 6542 | } |
6524 | 6543 | ||
6525 | static int volume_set_mute_ec(const bool mute) | 6544 | /* returns < 0 on error, 0 on no change, 1 on change */ |
6545 | static int __volume_set_mute_ec(const bool mute) | ||
6526 | { | 6546 | { |
6527 | int rc; | 6547 | int rc; |
6528 | u8 s, n; | 6548 | u8 s, n; |
@@ -6537,22 +6557,37 @@ static int volume_set_mute_ec(const bool mute) | |||
6537 | n = (mute) ? s | TP_EC_AUDIO_MUTESW_MSK : | 6557 | n = (mute) ? s | TP_EC_AUDIO_MUTESW_MSK : |
6538 | s & ~TP_EC_AUDIO_MUTESW_MSK; | 6558 | s & ~TP_EC_AUDIO_MUTESW_MSK; |
6539 | 6559 | ||
6540 | if (n != s) | 6560 | if (n != s) { |
6541 | rc = volume_set_status_ec(n); | 6561 | rc = volume_set_status_ec(n); |
6562 | if (!rc) | ||
6563 | rc = 1; | ||
6564 | } | ||
6542 | 6565 | ||
6543 | unlock: | 6566 | unlock: |
6544 | mutex_unlock(&volume_mutex); | 6567 | mutex_unlock(&volume_mutex); |
6545 | return rc; | 6568 | return rc; |
6546 | } | 6569 | } |
6547 | 6570 | ||
6571 | static int volume_alsa_set_mute(const bool mute) | ||
6572 | { | ||
6573 | dbg_printk(TPACPI_DBG_MIXER, "ALSA: trying to %smute\n", | ||
6574 | (mute) ? "" : "un"); | ||
6575 | return __volume_set_mute_ec(mute); | ||
6576 | } | ||
6577 | |||
6548 | static int volume_set_mute(const bool mute) | 6578 | static int volume_set_mute(const bool mute) |
6549 | { | 6579 | { |
6580 | int rc; | ||
6581 | |||
6550 | dbg_printk(TPACPI_DBG_MIXER, "trying to %smute\n", | 6582 | dbg_printk(TPACPI_DBG_MIXER, "trying to %smute\n", |
6551 | (mute) ? "" : "un"); | 6583 | (mute) ? "" : "un"); |
6552 | return volume_set_mute_ec(mute); | 6584 | |
6585 | rc = __volume_set_mute_ec(mute); | ||
6586 | return (rc < 0) ? rc : 0; | ||
6553 | } | 6587 | } |
6554 | 6588 | ||
6555 | static int volume_set_volume_ec(const u8 vol) | 6589 | /* returns < 0 on error, 0 on no change, 1 on change */ |
6590 | static int __volume_set_volume_ec(const u8 vol) | ||
6556 | { | 6591 | { |
6557 | int rc; | 6592 | int rc; |
6558 | u8 s, n; | 6593 | u8 s, n; |
@@ -6569,19 +6604,22 @@ static int volume_set_volume_ec(const u8 vol) | |||
6569 | 6604 | ||
6570 | n = (s & ~TP_EC_AUDIO_LVL_MSK) | vol; | 6605 | n = (s & ~TP_EC_AUDIO_LVL_MSK) | vol; |
6571 | 6606 | ||
6572 | if (n != s) | 6607 | if (n != s) { |
6573 | rc = volume_set_status_ec(n); | 6608 | rc = volume_set_status_ec(n); |
6609 | if (!rc) | ||
6610 | rc = 1; | ||
6611 | } | ||
6574 | 6612 | ||
6575 | unlock: | 6613 | unlock: |
6576 | mutex_unlock(&volume_mutex); | 6614 | mutex_unlock(&volume_mutex); |
6577 | return rc; | 6615 | return rc; |
6578 | } | 6616 | } |
6579 | 6617 | ||
6580 | static int volume_set_volume(const u8 vol) | 6618 | static int volume_alsa_set_volume(const u8 vol) |
6581 | { | 6619 | { |
6582 | dbg_printk(TPACPI_DBG_MIXER, | 6620 | dbg_printk(TPACPI_DBG_MIXER, |
6583 | "trying to set volume level to %hu\n", vol); | 6621 | "ALSA: trying to set volume level to %hu\n", vol); |
6584 | return volume_set_volume_ec(vol); | 6622 | return __volume_set_volume_ec(vol); |
6585 | } | 6623 | } |
6586 | 6624 | ||
6587 | static void volume_alsa_notify_change(void) | 6625 | static void volume_alsa_notify_change(void) |
@@ -6628,7 +6666,7 @@ static int volume_alsa_vol_get(struct snd_kcontrol *kcontrol, | |||
6628 | static int volume_alsa_vol_put(struct snd_kcontrol *kcontrol, | 6666 | static int volume_alsa_vol_put(struct snd_kcontrol *kcontrol, |
6629 | struct snd_ctl_elem_value *ucontrol) | 6667 | struct snd_ctl_elem_value *ucontrol) |
6630 | { | 6668 | { |
6631 | return volume_set_volume(ucontrol->value.integer.value[0]); | 6669 | return volume_alsa_set_volume(ucontrol->value.integer.value[0]); |
6632 | } | 6670 | } |
6633 | 6671 | ||
6634 | #define volume_alsa_mute_info snd_ctl_boolean_mono_info | 6672 | #define volume_alsa_mute_info snd_ctl_boolean_mono_info |
@@ -6651,7 +6689,7 @@ static int volume_alsa_mute_get(struct snd_kcontrol *kcontrol, | |||
6651 | static int volume_alsa_mute_put(struct snd_kcontrol *kcontrol, | 6689 | static int volume_alsa_mute_put(struct snd_kcontrol *kcontrol, |
6652 | struct snd_ctl_elem_value *ucontrol) | 6690 | struct snd_ctl_elem_value *ucontrol) |
6653 | { | 6691 | { |
6654 | return volume_set_mute(!ucontrol->value.integer.value[0]); | 6692 | return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); |
6655 | } | 6693 | } |
6656 | 6694 | ||
6657 | static struct snd_kcontrol_new volume_alsa_control_vol __devinitdata = { | 6695 | static struct snd_kcontrol_new volume_alsa_control_vol __devinitdata = { |
@@ -8477,9 +8515,10 @@ static int __init ibm_init(struct ibm_init_struct *iibm) | |||
8477 | "%s installed\n", ibm->name); | 8515 | "%s installed\n", ibm->name); |
8478 | 8516 | ||
8479 | if (ibm->read) { | 8517 | if (ibm->read) { |
8480 | mode_t mode; | 8518 | mode_t mode = iibm->base_procfs_mode; |
8481 | 8519 | ||
8482 | mode = S_IRUGO; | 8520 | if (!mode) |
8521 | mode = S_IRUGO; | ||
8483 | if (ibm->write) | 8522 | if (ibm->write) |
8484 | mode |= S_IWUSR; | 8523 | mode |= S_IWUSR; |
8485 | entry = proc_create_data(ibm->name, mode, proc_dir, | 8524 | entry = proc_create_data(ibm->name, mode, proc_dir, |
@@ -8670,6 +8709,7 @@ static struct ibm_init_struct ibms_init[] __initdata = { | |||
8670 | #ifdef CONFIG_THINKPAD_ACPI_VIDEO | 8709 | #ifdef CONFIG_THINKPAD_ACPI_VIDEO |
8671 | { | 8710 | { |
8672 | .init = video_init, | 8711 | .init = video_init, |
8712 | .base_procfs_mode = S_IRUSR, | ||
8673 | .data = &video_driver_data, | 8713 | .data = &video_driver_data, |
8674 | }, | 8714 | }, |
8675 | #endif | 8715 | #endif |
@@ -9032,6 +9072,9 @@ static int __init thinkpad_acpi_module_init(void) | |||
9032 | return ret; | 9072 | return ret; |
9033 | } | 9073 | } |
9034 | } | 9074 | } |
9075 | |||
9076 | tpacpi_lifecycle = TPACPI_LIFE_RUNNING; | ||
9077 | |||
9035 | ret = input_register_device(tpacpi_inputdev); | 9078 | ret = input_register_device(tpacpi_inputdev); |
9036 | if (ret < 0) { | 9079 | if (ret < 0) { |
9037 | printk(TPACPI_ERR "unable to register input device\n"); | 9080 | printk(TPACPI_ERR "unable to register input device\n"); |
@@ -9041,7 +9084,6 @@ static int __init thinkpad_acpi_module_init(void) | |||
9041 | tp_features.input_device_registered = 1; | 9084 | tp_features.input_device_registered = 1; |
9042 | } | 9085 | } |
9043 | 9086 | ||
9044 | tpacpi_lifecycle = TPACPI_LIFE_RUNNING; | ||
9045 | return 0; | 9087 | return 0; |
9046 | } | 9088 | } |
9047 | 9089 | ||
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 77bf5d8f893a..405b969734d6 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/backlight.h> | 46 | #include <linux/backlight.h> |
47 | #include <linux/platform_device.h> | 47 | #include <linux/platform_device.h> |
48 | #include <linux/rfkill.h> | 48 | #include <linux/rfkill.h> |
49 | #include <linux/input.h> | ||
49 | 50 | ||
50 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
51 | 52 | ||
@@ -62,9 +63,10 @@ MODULE_LICENSE("GPL"); | |||
62 | 63 | ||
63 | /* Toshiba ACPI method paths */ | 64 | /* Toshiba ACPI method paths */ |
64 | #define METHOD_LCD_BRIGHTNESS "\\_SB_.PCI0.VGA_.LCD_._BCM" | 65 | #define METHOD_LCD_BRIGHTNESS "\\_SB_.PCI0.VGA_.LCD_._BCM" |
65 | #define METHOD_HCI_1 "\\_SB_.VALD.GHCI" | 66 | #define TOSH_INTERFACE_1 "\\_SB_.VALD" |
66 | #define METHOD_HCI_2 "\\_SB_.VALZ.GHCI" | 67 | #define TOSH_INTERFACE_2 "\\_SB_.VALZ" |
67 | #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX" | 68 | #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX" |
69 | #define GHCI_METHOD ".GHCI" | ||
68 | 70 | ||
69 | /* Toshiba HCI interface definitions | 71 | /* Toshiba HCI interface definitions |
70 | * | 72 | * |
@@ -116,6 +118,36 @@ static const struct acpi_device_id toshiba_device_ids[] = { | |||
116 | }; | 118 | }; |
117 | MODULE_DEVICE_TABLE(acpi, toshiba_device_ids); | 119 | MODULE_DEVICE_TABLE(acpi, toshiba_device_ids); |
118 | 120 | ||
121 | struct key_entry { | ||
122 | char type; | ||
123 | u16 code; | ||
124 | u16 keycode; | ||
125 | }; | ||
126 | |||
127 | enum {KE_KEY, KE_END}; | ||
128 | |||
129 | static struct key_entry toshiba_acpi_keymap[] = { | ||
130 | {KE_KEY, 0x101, KEY_MUTE}, | ||
131 | {KE_KEY, 0x13b, KEY_COFFEE}, | ||
132 | {KE_KEY, 0x13c, KEY_BATTERY}, | ||
133 | {KE_KEY, 0x13d, KEY_SLEEP}, | ||
134 | {KE_KEY, 0x13e, KEY_SUSPEND}, | ||
135 | {KE_KEY, 0x13f, KEY_SWITCHVIDEOMODE}, | ||
136 | {KE_KEY, 0x140, KEY_BRIGHTNESSDOWN}, | ||
137 | {KE_KEY, 0x141, KEY_BRIGHTNESSUP}, | ||
138 | {KE_KEY, 0x142, KEY_WLAN}, | ||
139 | {KE_KEY, 0x143, KEY_PROG1}, | ||
140 | {KE_KEY, 0xb05, KEY_PROG2}, | ||
141 | {KE_KEY, 0xb06, KEY_WWW}, | ||
142 | {KE_KEY, 0xb07, KEY_MAIL}, | ||
143 | {KE_KEY, 0xb30, KEY_STOP}, | ||
144 | {KE_KEY, 0xb31, KEY_PREVIOUSSONG}, | ||
145 | {KE_KEY, 0xb32, KEY_NEXTSONG}, | ||
146 | {KE_KEY, 0xb33, KEY_PLAYPAUSE}, | ||
147 | {KE_KEY, 0xb5a, KEY_MEDIA}, | ||
148 | {KE_END, 0, 0}, | ||
149 | }; | ||
150 | |||
119 | /* utility | 151 | /* utility |
120 | */ | 152 | */ |
121 | 153 | ||
@@ -251,6 +283,8 @@ static acpi_status hci_read2(u32 reg, u32 *out1, u32 *out2, u32 *result) | |||
251 | struct toshiba_acpi_dev { | 283 | struct toshiba_acpi_dev { |
252 | struct platform_device *p_dev; | 284 | struct platform_device *p_dev; |
253 | struct rfkill *bt_rfk; | 285 | struct rfkill *bt_rfk; |
286 | struct input_dev *hotkey_dev; | ||
287 | acpi_handle handle; | ||
254 | 288 | ||
255 | const char *bt_name; | 289 | const char *bt_name; |
256 | 290 | ||
@@ -711,8 +745,161 @@ static struct backlight_ops toshiba_backlight_data = { | |||
711 | .update_status = set_lcd_status, | 745 | .update_status = set_lcd_status, |
712 | }; | 746 | }; |
713 | 747 | ||
748 | static struct key_entry *toshiba_acpi_get_entry_by_scancode(int code) | ||
749 | { | ||
750 | struct key_entry *key; | ||
751 | |||
752 | for (key = toshiba_acpi_keymap; key->type != KE_END; key++) | ||
753 | if (code == key->code) | ||
754 | return key; | ||
755 | |||
756 | return NULL; | ||
757 | } | ||
758 | |||
759 | static struct key_entry *toshiba_acpi_get_entry_by_keycode(int code) | ||
760 | { | ||
761 | struct key_entry *key; | ||
762 | |||
763 | for (key = toshiba_acpi_keymap; key->type != KE_END; key++) | ||
764 | if (code == key->keycode && key->type == KE_KEY) | ||
765 | return key; | ||
766 | |||
767 | return NULL; | ||
768 | } | ||
769 | |||
770 | static int toshiba_acpi_getkeycode(struct input_dev *dev, int scancode, | ||
771 | int *keycode) | ||
772 | { | ||
773 | struct key_entry *key = toshiba_acpi_get_entry_by_scancode(scancode); | ||
774 | |||
775 | if (key && key->type == KE_KEY) { | ||
776 | *keycode = key->keycode; | ||
777 | return 0; | ||
778 | } | ||
779 | |||
780 | return -EINVAL; | ||
781 | } | ||
782 | |||
783 | static int toshiba_acpi_setkeycode(struct input_dev *dev, int scancode, | ||
784 | int keycode) | ||
785 | { | ||
786 | struct key_entry *key; | ||
787 | int old_keycode; | ||
788 | |||
789 | if (keycode < 0 || keycode > KEY_MAX) | ||
790 | return -EINVAL; | ||
791 | |||
792 | key = toshiba_acpi_get_entry_by_scancode(scancode); | ||
793 | if (key && key->type == KE_KEY) { | ||
794 | old_keycode = key->keycode; | ||
795 | key->keycode = keycode; | ||
796 | set_bit(keycode, dev->keybit); | ||
797 | if (!toshiba_acpi_get_entry_by_keycode(old_keycode)) | ||
798 | clear_bit(old_keycode, dev->keybit); | ||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | return -EINVAL; | ||
803 | } | ||
804 | |||
805 | static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *context) | ||
806 | { | ||
807 | u32 hci_result, value; | ||
808 | struct key_entry *key; | ||
809 | |||
810 | if (event != 0x80) | ||
811 | return; | ||
812 | do { | ||
813 | hci_read1(HCI_SYSTEM_EVENT, &value, &hci_result); | ||
814 | if (hci_result == HCI_SUCCESS) { | ||
815 | if (value == 0x100) | ||
816 | continue; | ||
817 | /* act on key press; ignore key release */ | ||
818 | if (value & 0x80) | ||
819 | continue; | ||
820 | |||
821 | key = toshiba_acpi_get_entry_by_scancode | ||
822 | (value); | ||
823 | if (!key) { | ||
824 | printk(MY_INFO "Unknown key %x\n", | ||
825 | value); | ||
826 | continue; | ||
827 | } | ||
828 | input_report_key(toshiba_acpi.hotkey_dev, | ||
829 | key->keycode, 1); | ||
830 | input_sync(toshiba_acpi.hotkey_dev); | ||
831 | input_report_key(toshiba_acpi.hotkey_dev, | ||
832 | key->keycode, 0); | ||
833 | input_sync(toshiba_acpi.hotkey_dev); | ||
834 | } else if (hci_result == HCI_NOT_SUPPORTED) { | ||
835 | /* This is a workaround for an unresolved issue on | ||
836 | * some machines where system events sporadically | ||
837 | * become disabled. */ | ||
838 | hci_write1(HCI_SYSTEM_EVENT, 1, &hci_result); | ||
839 | printk(MY_NOTICE "Re-enabled hotkeys\n"); | ||
840 | } | ||
841 | } while (hci_result != HCI_EMPTY); | ||
842 | } | ||
843 | |||
844 | static int toshiba_acpi_setup_keyboard(char *device) | ||
845 | { | ||
846 | acpi_status status; | ||
847 | acpi_handle handle; | ||
848 | int result; | ||
849 | const struct key_entry *key; | ||
850 | |||
851 | status = acpi_get_handle(NULL, device, &handle); | ||
852 | if (ACPI_FAILURE(status)) { | ||
853 | printk(MY_INFO "Unable to get notification device\n"); | ||
854 | return -ENODEV; | ||
855 | } | ||
856 | |||
857 | toshiba_acpi.handle = handle; | ||
858 | |||
859 | status = acpi_evaluate_object(handle, "ENAB", NULL, NULL); | ||
860 | if (ACPI_FAILURE(status)) { | ||
861 | printk(MY_INFO "Unable to enable hotkeys\n"); | ||
862 | return -ENODEV; | ||
863 | } | ||
864 | |||
865 | status = acpi_install_notify_handler(handle, ACPI_DEVICE_NOTIFY, | ||
866 | toshiba_acpi_notify, NULL); | ||
867 | if (ACPI_FAILURE(status)) { | ||
868 | printk(MY_INFO "Unable to install hotkey notification\n"); | ||
869 | return -ENODEV; | ||
870 | } | ||
871 | |||
872 | toshiba_acpi.hotkey_dev = input_allocate_device(); | ||
873 | if (!toshiba_acpi.hotkey_dev) { | ||
874 | printk(MY_INFO "Unable to register input device\n"); | ||
875 | return -ENOMEM; | ||
876 | } | ||
877 | |||
878 | toshiba_acpi.hotkey_dev->name = "Toshiba input device"; | ||
879 | toshiba_acpi.hotkey_dev->phys = device; | ||
880 | toshiba_acpi.hotkey_dev->id.bustype = BUS_HOST; | ||
881 | toshiba_acpi.hotkey_dev->getkeycode = toshiba_acpi_getkeycode; | ||
882 | toshiba_acpi.hotkey_dev->setkeycode = toshiba_acpi_setkeycode; | ||
883 | |||
884 | for (key = toshiba_acpi_keymap; key->type != KE_END; key++) { | ||
885 | set_bit(EV_KEY, toshiba_acpi.hotkey_dev->evbit); | ||
886 | set_bit(key->keycode, toshiba_acpi.hotkey_dev->keybit); | ||
887 | } | ||
888 | |||
889 | result = input_register_device(toshiba_acpi.hotkey_dev); | ||
890 | if (result) { | ||
891 | printk(MY_INFO "Unable to register input device\n"); | ||
892 | return result; | ||
893 | } | ||
894 | |||
895 | return 0; | ||
896 | } | ||
897 | |||
714 | static void toshiba_acpi_exit(void) | 898 | static void toshiba_acpi_exit(void) |
715 | { | 899 | { |
900 | if (toshiba_acpi.hotkey_dev) | ||
901 | input_unregister_device(toshiba_acpi.hotkey_dev); | ||
902 | |||
716 | if (toshiba_acpi.bt_rfk) { | 903 | if (toshiba_acpi.bt_rfk) { |
717 | rfkill_unregister(toshiba_acpi.bt_rfk); | 904 | rfkill_unregister(toshiba_acpi.bt_rfk); |
718 | rfkill_destroy(toshiba_acpi.bt_rfk); | 905 | rfkill_destroy(toshiba_acpi.bt_rfk); |
@@ -726,6 +913,9 @@ static void toshiba_acpi_exit(void) | |||
726 | if (toshiba_proc_dir) | 913 | if (toshiba_proc_dir) |
727 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); | 914 | remove_proc_entry(PROC_TOSHIBA, acpi_root_dir); |
728 | 915 | ||
916 | acpi_remove_notify_handler(toshiba_acpi.handle, ACPI_DEVICE_NOTIFY, | ||
917 | toshiba_acpi_notify); | ||
918 | |||
729 | platform_device_unregister(toshiba_acpi.p_dev); | 919 | platform_device_unregister(toshiba_acpi.p_dev); |
730 | 920 | ||
731 | return; | 921 | return; |
@@ -742,11 +932,15 @@ static int __init toshiba_acpi_init(void) | |||
742 | return -ENODEV; | 932 | return -ENODEV; |
743 | 933 | ||
744 | /* simple device detection: look for HCI method */ | 934 | /* simple device detection: look for HCI method */ |
745 | if (is_valid_acpi_path(METHOD_HCI_1)) | 935 | if (is_valid_acpi_path(TOSH_INTERFACE_1 GHCI_METHOD)) { |
746 | method_hci = METHOD_HCI_1; | 936 | method_hci = TOSH_INTERFACE_1 GHCI_METHOD; |
747 | else if (is_valid_acpi_path(METHOD_HCI_2)) | 937 | if (toshiba_acpi_setup_keyboard(TOSH_INTERFACE_1)) |
748 | method_hci = METHOD_HCI_2; | 938 | printk(MY_INFO "Unable to activate hotkeys\n"); |
749 | else | 939 | } else if (is_valid_acpi_path(TOSH_INTERFACE_2 GHCI_METHOD)) { |
940 | method_hci = TOSH_INTERFACE_2 GHCI_METHOD; | ||
941 | if (toshiba_acpi_setup_keyboard(TOSH_INTERFACE_2)) | ||
942 | printk(MY_INFO "Unable to activate hotkeys\n"); | ||
943 | } else | ||
750 | return -ENODEV; | 944 | return -ENODEV; |
751 | 945 | ||
752 | printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n", | 946 | printk(MY_INFO "Toshiba Laptop ACPI Extras version %s\n", |
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c index a350418e87ea..944068611919 100644 --- a/drivers/platform/x86/toshiba_bluetooth.c +++ b/drivers/platform/x86/toshiba_bluetooth.c | |||
@@ -57,7 +57,7 @@ static struct acpi_driver toshiba_bt_rfkill_driver = { | |||
57 | static int toshiba_bluetooth_enable(acpi_handle handle) | 57 | static int toshiba_bluetooth_enable(acpi_handle handle) |
58 | { | 58 | { |
59 | acpi_status res1, res2; | 59 | acpi_status res1, res2; |
60 | acpi_integer result; | 60 | u64 result; |
61 | 61 | ||
62 | /* | 62 | /* |
63 | * Query ACPI to verify RFKill switch is set to 'on'. | 63 | * Query ACPI to verify RFKill switch is set to 'on'. |
@@ -95,7 +95,7 @@ static int toshiba_bt_resume(struct acpi_device *device) | |||
95 | static int toshiba_bt_rfkill_add(struct acpi_device *device) | 95 | static int toshiba_bt_rfkill_add(struct acpi_device *device) |
96 | { | 96 | { |
97 | acpi_status status; | 97 | acpi_status status; |
98 | acpi_integer bt_present; | 98 | u64 bt_present; |
99 | int result = -ENODEV; | 99 | int result = -ENODEV; |
100 | 100 | ||
101 | /* | 101 | /* |
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index b104302fea0a..09e9918c69c1 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c | |||
@@ -796,7 +796,7 @@ static __init acpi_status parse_wdg(acpi_handle handle) | |||
796 | */ | 796 | */ |
797 | static acpi_status | 797 | static acpi_status |
798 | acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, | 798 | acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, |
799 | u32 bits, acpi_integer * value, | 799 | u32 bits, u64 *value, |
800 | void *handler_context, void *region_context) | 800 | void *handler_context, void *region_context) |
801 | { | 801 | { |
802 | int result = 0, i = 0; | 802 | int result = 0, i = 0; |
@@ -813,7 +813,7 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, | |||
813 | 813 | ||
814 | if (function == ACPI_READ) { | 814 | if (function == ACPI_READ) { |
815 | result = ec_read(address, &temp); | 815 | result = ec_read(address, &temp); |
816 | (*value) |= ((acpi_integer)temp) << i; | 816 | (*value) |= ((u64)temp) << i; |
817 | } else { | 817 | } else { |
818 | temp = 0xff & ((*value) >> i); | 818 | temp = 0xff & ((*value) >> i); |
819 | result = ec_write(address, temp); | 819 | result = ec_write(address, temp); |