fujitsu-laptop.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. /*-*-linux-c-*-*/
  2. /*
  3. Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  4. Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
  5. Copyright (C) 2008 Tony Vroon <tony@linx.net>
  6. Based on earlier work:
  7. Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
  8. Adrian Yee <brewt-fujitsu@brewt.org>
  9. Templated from msi-laptop.c and thinkpad_acpi.c which is copyright
  10. by its respective authors.
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15. This program is distributed in the hope that it will be useful, but
  16. WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  22. 02110-1301, USA.
  23. */
  24. /*
  25. * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional
  26. * features made available on a range of Fujitsu laptops including the
  27. * P2xxx/P5xxx/S6xxx/S7xxx series.
  28. *
  29. * This driver exports a few files in /sys/devices/platform/fujitsu-laptop/;
  30. * others may be added at a later date.
  31. *
  32. * lcd_level - Screen brightness: contains a single integer in the
  33. * range 0..7. (rw)
  34. *
  35. * In addition to these platform device attributes the driver
  36. * registers itself in the Linux backlight control subsystem and is
  37. * available to userspace under /sys/class/backlight/fujitsu-laptop/.
  38. *
  39. * Hotkeys present on certain Fujitsu laptops (eg: the S6xxx series) are
  40. * also supported by this driver.
  41. *
  42. * This driver has been tested on a Fujitsu Lifebook S6410, S7020 and
  43. * P8010. It should work on most P-series and S-series Lifebooks, but
  44. * YMMV.
  45. *
  46. * The module parameter use_alt_lcd_levels switches between different ACPI
  47. * brightness controls which are used by different Fujitsu laptops. In most
  48. * cases the correct method is automatically detected. "use_alt_lcd_levels=1"
  49. * is applicable for a Fujitsu Lifebook S6410 if autodetection fails.
  50. *
  51. */
  52. #include <linux/module.h>
  53. #include <linux/kernel.h>
  54. #include <linux/init.h>
  55. #include <linux/acpi.h>
  56. #include <linux/dmi.h>
  57. #include <linux/backlight.h>
  58. #include <linux/input.h>
  59. #include <linux/kfifo.h>
  60. #include <linux/video_output.h>
  61. #include <linux/platform_device.h>
  62. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  63. #include <linux/leds.h>
  64. #endif
  65. #define FUJITSU_DRIVER_VERSION "0.6.0"
  66. #define FUJITSU_LCD_N_LEVELS 8
  67. #define ACPI_FUJITSU_CLASS "fujitsu"
  68. #define ACPI_FUJITSU_HID "FUJ02B1"
  69. #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver"
  70. #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1"
  71. #define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3"
  72. #define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver"
  73. #define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3"
  74. #define ACPI_FUJITSU_NOTIFY_CODE1 0x80
  75. #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
  76. #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
  77. /* FUNC interface - command values */
  78. #define FUNC_RFKILL 0x1000
  79. #define FUNC_LEDS 0x1001
  80. #define FUNC_BUTTONS 0x1002
  81. #define FUNC_BACKLIGHT 0x1004
  82. /* FUNC interface - responses */
  83. #define UNSUPPORTED_CMD 0x80000000
  84. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  85. /* FUNC interface - LED control */
  86. #define FUNC_LED_OFF 0x1
  87. #define FUNC_LED_ON 0x30001
  88. #define KEYBOARD_LAMPS 0x100
  89. #define LOGOLAMP_POWERON 0x2000
  90. #define LOGOLAMP_ALWAYS 0x4000
  91. #endif
  92. /* Hotkey details */
  93. #define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */
  94. #define KEY2_CODE 0x411
  95. #define KEY3_CODE 0x412
  96. #define KEY4_CODE 0x413
  97. #define MAX_HOTKEY_RINGBUFFER_SIZE 100
  98. #define RINGBUFFERSIZE 40
  99. /* Debugging */
  100. #define FUJLAPTOP_LOG ACPI_FUJITSU_HID ": "
  101. #define FUJLAPTOP_ERR KERN_ERR FUJLAPTOP_LOG
  102. #define FUJLAPTOP_NOTICE KERN_NOTICE FUJLAPTOP_LOG
  103. #define FUJLAPTOP_INFO KERN_INFO FUJLAPTOP_LOG
  104. #define FUJLAPTOP_DEBUG KERN_DEBUG FUJLAPTOP_LOG
  105. #define FUJLAPTOP_DBG_ALL 0xffff
  106. #define FUJLAPTOP_DBG_ERROR 0x0001
  107. #define FUJLAPTOP_DBG_WARN 0x0002
  108. #define FUJLAPTOP_DBG_INFO 0x0004
  109. #define FUJLAPTOP_DBG_TRACE 0x0008
  110. #define dbg_printk(a_dbg_level, format, arg...) \
  111. do { if (dbg_level & a_dbg_level) \
  112. printk(FUJLAPTOP_DEBUG "%s: " format, __func__ , ## arg); \
  113. } while (0)
  114. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  115. #define vdbg_printk(a_dbg_level, format, arg...) \
  116. dbg_printk(a_dbg_level, format, ## arg)
  117. #else
  118. #define vdbg_printk(a_dbg_level, format, arg...)
  119. #endif
  120. /* Device controlling the backlight and associated keys */
  121. struct fujitsu_t {
  122. acpi_handle acpi_handle;
  123. struct acpi_device *dev;
  124. struct input_dev *input;
  125. char phys[32];
  126. struct backlight_device *bl_device;
  127. struct platform_device *pf_device;
  128. int keycode1, keycode2, keycode3, keycode4;
  129. unsigned int max_brightness;
  130. unsigned int brightness_changed;
  131. unsigned int brightness_level;
  132. };
  133. static struct fujitsu_t *fujitsu;
  134. static int use_alt_lcd_levels = -1;
  135. static int disable_brightness_adjust = -1;
  136. /* Device used to access other hotkeys on the laptop */
  137. struct fujitsu_hotkey_t {
  138. acpi_handle acpi_handle;
  139. struct acpi_device *dev;
  140. struct input_dev *input;
  141. char phys[32];
  142. struct platform_device *pf_device;
  143. struct kfifo fifo;
  144. spinlock_t fifo_lock;
  145. int rfkill_supported;
  146. int rfkill_state;
  147. int logolamp_registered;
  148. int kblamps_registered;
  149. };
  150. static struct fujitsu_hotkey_t *fujitsu_hotkey;
  151. static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
  152. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  153. static enum led_brightness logolamp_get(struct led_classdev *cdev);
  154. static void logolamp_set(struct led_classdev *cdev,
  155. enum led_brightness brightness);
  156. struct led_classdev logolamp_led = {
  157. .name = "fujitsu::logolamp",
  158. .brightness_get = logolamp_get,
  159. .brightness_set = logolamp_set
  160. };
  161. static enum led_brightness kblamps_get(struct led_classdev *cdev);
  162. static void kblamps_set(struct led_classdev *cdev,
  163. enum led_brightness brightness);
  164. struct led_classdev kblamps_led = {
  165. .name = "fujitsu::kblamps",
  166. .brightness_get = kblamps_get,
  167. .brightness_set = kblamps_set
  168. };
  169. #endif
  170. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  171. static u32 dbg_level = 0x03;
  172. #endif
  173. static void acpi_fujitsu_notify(struct acpi_device *device, u32 event);
  174. /* Fujitsu ACPI interface function */
  175. static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
  176. {
  177. acpi_status status = AE_OK;
  178. union acpi_object params[4] = {
  179. { .type = ACPI_TYPE_INTEGER },
  180. { .type = ACPI_TYPE_INTEGER },
  181. { .type = ACPI_TYPE_INTEGER },
  182. { .type = ACPI_TYPE_INTEGER }
  183. };
  184. struct acpi_object_list arg_list = { 4, &params[0] };
  185. struct acpi_buffer output;
  186. union acpi_object out_obj;
  187. acpi_handle handle = NULL;
  188. status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
  189. if (ACPI_FAILURE(status)) {
  190. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  191. "FUNC interface is not present\n");
  192. return -ENODEV;
  193. }
  194. params[0].integer.value = cmd;
  195. params[1].integer.value = arg0;
  196. params[2].integer.value = arg1;
  197. params[3].integer.value = arg2;
  198. output.length = sizeof(out_obj);
  199. output.pointer = &out_obj;
  200. status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
  201. if (ACPI_FAILURE(status)) {
  202. vdbg_printk(FUJLAPTOP_DBG_WARN,
  203. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
  204. cmd, arg0, arg1, arg2);
  205. return -ENODEV;
  206. }
  207. if (out_obj.type != ACPI_TYPE_INTEGER) {
  208. vdbg_printk(FUJLAPTOP_DBG_WARN,
  209. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
  210. "return an integer\n",
  211. cmd, arg0, arg1, arg2);
  212. return -ENODEV;
  213. }
  214. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  215. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
  216. cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
  217. return out_obj.integer.value;
  218. }
  219. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  220. /* LED class callbacks */
  221. static void logolamp_set(struct led_classdev *cdev,
  222. enum led_brightness brightness)
  223. {
  224. if (brightness >= LED_FULL) {
  225. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
  226. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
  227. } else if (brightness >= LED_HALF) {
  228. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
  229. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
  230. } else {
  231. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
  232. }
  233. }
  234. static void kblamps_set(struct led_classdev *cdev,
  235. enum led_brightness brightness)
  236. {
  237. if (brightness >= LED_FULL)
  238. call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
  239. else
  240. call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
  241. }
  242. static enum led_brightness logolamp_get(struct led_classdev *cdev)
  243. {
  244. enum led_brightness brightness = LED_OFF;
  245. int poweron, always;
  246. poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
  247. if (poweron == FUNC_LED_ON) {
  248. brightness = LED_HALF;
  249. always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
  250. if (always == FUNC_LED_ON)
  251. brightness = LED_FULL;
  252. }
  253. return brightness;
  254. }
  255. static enum led_brightness kblamps_get(struct led_classdev *cdev)
  256. {
  257. enum led_brightness brightness = LED_OFF;
  258. if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
  259. brightness = LED_FULL;
  260. return brightness;
  261. }
  262. #endif
  263. /* Hardware access for LCD brightness control */
  264. static int set_lcd_level(int level)
  265. {
  266. acpi_status status = AE_OK;
  267. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  268. struct acpi_object_list arg_list = { 1, &arg0 };
  269. acpi_handle handle = NULL;
  270. vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
  271. level);
  272. if (level < 0 || level >= fujitsu->max_brightness)
  273. return -EINVAL;
  274. status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle);
  275. if (ACPI_FAILURE(status)) {
  276. vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n");
  277. return -ENODEV;
  278. }
  279. arg0.integer.value = level;
  280. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  281. if (ACPI_FAILURE(status))
  282. return -ENODEV;
  283. return 0;
  284. }
  285. static int set_lcd_level_alt(int level)
  286. {
  287. acpi_status status = AE_OK;
  288. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  289. struct acpi_object_list arg_list = { 1, &arg0 };
  290. acpi_handle handle = NULL;
  291. vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
  292. level);
  293. if (level < 0 || level >= fujitsu->max_brightness)
  294. return -EINVAL;
  295. status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle);
  296. if (ACPI_FAILURE(status)) {
  297. vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
  298. return -ENODEV;
  299. }
  300. arg0.integer.value = level;
  301. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  302. if (ACPI_FAILURE(status))
  303. return -ENODEV;
  304. return 0;
  305. }
  306. static int get_lcd_level(void)
  307. {
  308. unsigned long long state = 0;
  309. acpi_status status = AE_OK;
  310. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n");
  311. status =
  312. acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
  313. if (ACPI_FAILURE(status))
  314. return 0;
  315. fujitsu->brightness_level = state & 0x0fffffff;
  316. if (state & 0x80000000)
  317. fujitsu->brightness_changed = 1;
  318. else
  319. fujitsu->brightness_changed = 0;
  320. return fujitsu->brightness_level;
  321. }
  322. static int get_max_brightness(void)
  323. {
  324. unsigned long long state = 0;
  325. acpi_status status = AE_OK;
  326. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n");
  327. status =
  328. acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
  329. if (ACPI_FAILURE(status))
  330. return -1;
  331. fujitsu->max_brightness = state;
  332. return fujitsu->max_brightness;
  333. }
  334. /* Backlight device stuff */
  335. static int bl_get_brightness(struct backlight_device *b)
  336. {
  337. return get_lcd_level();
  338. }
  339. static int bl_update_status(struct backlight_device *b)
  340. {
  341. int ret;
  342. if (b->props.power == 4)
  343. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3);
  344. else
  345. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0);
  346. if (ret != 0)
  347. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  348. "Unable to adjust backlight power, error code %i\n",
  349. ret);
  350. if (use_alt_lcd_levels)
  351. ret = set_lcd_level_alt(b->props.brightness);
  352. else
  353. ret = set_lcd_level(b->props.brightness);
  354. if (ret != 0)
  355. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  356. "Unable to adjust LCD brightness, error code %i\n",
  357. ret);
  358. return ret;
  359. }
  360. static struct backlight_ops fujitsubl_ops = {
  361. .get_brightness = bl_get_brightness,
  362. .update_status = bl_update_status,
  363. };
  364. /* Platform LCD brightness device */
  365. static ssize_t
  366. show_max_brightness(struct device *dev,
  367. struct device_attribute *attr, char *buf)
  368. {
  369. int ret;
  370. ret = get_max_brightness();
  371. if (ret < 0)
  372. return ret;
  373. return sprintf(buf, "%i\n", ret);
  374. }
  375. static ssize_t
  376. show_brightness_changed(struct device *dev,
  377. struct device_attribute *attr, char *buf)
  378. {
  379. int ret;
  380. ret = fujitsu->brightness_changed;
  381. if (ret < 0)
  382. return ret;
  383. return sprintf(buf, "%i\n", ret);
  384. }
  385. static ssize_t show_lcd_level(struct device *dev,
  386. struct device_attribute *attr, char *buf)
  387. {
  388. int ret;
  389. ret = get_lcd_level();
  390. if (ret < 0)
  391. return ret;
  392. return sprintf(buf, "%i\n", ret);
  393. }
  394. static ssize_t store_lcd_level(struct device *dev,
  395. struct device_attribute *attr, const char *buf,
  396. size_t count)
  397. {
  398. int level, ret;
  399. if (sscanf(buf, "%i", &level) != 1
  400. || (level < 0 || level >= fujitsu->max_brightness))
  401. return -EINVAL;
  402. if (use_alt_lcd_levels)
  403. ret = set_lcd_level_alt(level);
  404. else
  405. ret = set_lcd_level(level);
  406. if (ret < 0)
  407. return ret;
  408. ret = get_lcd_level();
  409. if (ret < 0)
  410. return ret;
  411. return count;
  412. }
  413. static ssize_t
  414. ignore_store(struct device *dev,
  415. struct device_attribute *attr, const char *buf, size_t count)
  416. {
  417. return count;
  418. }
  419. static ssize_t
  420. show_lid_state(struct device *dev,
  421. struct device_attribute *attr, char *buf)
  422. {
  423. if (!(fujitsu_hotkey->rfkill_supported & 0x100))
  424. return sprintf(buf, "unknown\n");
  425. if (fujitsu_hotkey->rfkill_state & 0x100)
  426. return sprintf(buf, "open\n");
  427. else
  428. return sprintf(buf, "closed\n");
  429. }
  430. static ssize_t
  431. show_dock_state(struct device *dev,
  432. struct device_attribute *attr, char *buf)
  433. {
  434. if (!(fujitsu_hotkey->rfkill_supported & 0x200))
  435. return sprintf(buf, "unknown\n");
  436. if (fujitsu_hotkey->rfkill_state & 0x200)
  437. return sprintf(buf, "docked\n");
  438. else
  439. return sprintf(buf, "undocked\n");
  440. }
  441. static ssize_t
  442. show_radios_state(struct device *dev,
  443. struct device_attribute *attr, char *buf)
  444. {
  445. if (!(fujitsu_hotkey->rfkill_supported & 0x20))
  446. return sprintf(buf, "unknown\n");
  447. if (fujitsu_hotkey->rfkill_state & 0x20)
  448. return sprintf(buf, "on\n");
  449. else
  450. return sprintf(buf, "killed\n");
  451. }
  452. static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store);
  453. static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed,
  454. ignore_store);
  455. static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
  456. static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
  457. static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
  458. static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
  459. static struct attribute *fujitsupf_attributes[] = {
  460. &dev_attr_brightness_changed.attr,
  461. &dev_attr_max_brightness.attr,
  462. &dev_attr_lcd_level.attr,
  463. &dev_attr_lid.attr,
  464. &dev_attr_dock.attr,
  465. &dev_attr_radios.attr,
  466. NULL
  467. };
  468. static struct attribute_group fujitsupf_attribute_group = {
  469. .attrs = fujitsupf_attributes
  470. };
  471. static struct platform_driver fujitsupf_driver = {
  472. .driver = {
  473. .name = "fujitsu-laptop",
  474. .owner = THIS_MODULE,
  475. }
  476. };
  477. static void dmi_check_cb_common(const struct dmi_system_id *id)
  478. {
  479. acpi_handle handle;
  480. printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
  481. id->ident);
  482. if (use_alt_lcd_levels == -1) {
  483. if (ACPI_SUCCESS(acpi_get_handle(NULL,
  484. "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
  485. use_alt_lcd_levels = 1;
  486. else
  487. use_alt_lcd_levels = 0;
  488. vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
  489. "%i\n", use_alt_lcd_levels);
  490. }
  491. }
  492. static int dmi_check_cb_s6410(const struct dmi_system_id *id)
  493. {
  494. dmi_check_cb_common(id);
  495. fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */
  496. fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */
  497. return 0;
  498. }
  499. static int dmi_check_cb_s6420(const struct dmi_system_id *id)
  500. {
  501. dmi_check_cb_common(id);
  502. fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */
  503. fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */
  504. return 0;
  505. }
  506. static int dmi_check_cb_p8010(const struct dmi_system_id *id)
  507. {
  508. dmi_check_cb_common(id);
  509. fujitsu->keycode1 = KEY_HELP; /* "Support" */
  510. fujitsu->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */
  511. fujitsu->keycode4 = KEY_WWW; /* "Internet" */
  512. return 0;
  513. }
  514. static struct dmi_system_id fujitsu_dmi_table[] = {
  515. {
  516. .ident = "Fujitsu Siemens S6410",
  517. .matches = {
  518. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  519. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"),
  520. },
  521. .callback = dmi_check_cb_s6410},
  522. {
  523. .ident = "Fujitsu Siemens S6420",
  524. .matches = {
  525. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  526. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"),
  527. },
  528. .callback = dmi_check_cb_s6420},
  529. {
  530. .ident = "Fujitsu LifeBook P8010",
  531. .matches = {
  532. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  533. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"),
  534. },
  535. .callback = dmi_check_cb_p8010},
  536. {}
  537. };
  538. /* ACPI device for LCD brightness control */
  539. static int acpi_fujitsu_add(struct acpi_device *device)
  540. {
  541. acpi_handle handle;
  542. int result = 0;
  543. int state = 0;
  544. struct input_dev *input;
  545. int error;
  546. if (!device)
  547. return -EINVAL;
  548. fujitsu->acpi_handle = device->handle;
  549. sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME);
  550. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  551. device->driver_data = fujitsu;
  552. fujitsu->input = input = input_allocate_device();
  553. if (!input) {
  554. error = -ENOMEM;
  555. goto err_stop;
  556. }
  557. snprintf(fujitsu->phys, sizeof(fujitsu->phys),
  558. "%s/video/input0", acpi_device_hid(device));
  559. input->name = acpi_device_name(device);
  560. input->phys = fujitsu->phys;
  561. input->id.bustype = BUS_HOST;
  562. input->id.product = 0x06;
  563. input->dev.parent = &device->dev;
  564. input->evbit[0] = BIT(EV_KEY);
  565. set_bit(KEY_BRIGHTNESSUP, input->keybit);
  566. set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
  567. set_bit(KEY_UNKNOWN, input->keybit);
  568. error = input_register_device(input);
  569. if (error)
  570. goto err_free_input_dev;
  571. result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
  572. if (result) {
  573. printk(KERN_ERR "Error reading power state\n");
  574. goto err_unregister_input_dev;
  575. }
  576. printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
  577. acpi_device_name(device), acpi_device_bid(device),
  578. !device->power.state ? "on" : "off");
  579. fujitsu->dev = device;
  580. if (ACPI_SUCCESS
  581. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  582. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  583. if (ACPI_FAILURE
  584. (acpi_evaluate_object
  585. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  586. printk(KERN_ERR "_INI Method failed\n");
  587. }
  588. /* do config (detect defaults) */
  589. use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
  590. disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
  591. vdbg_printk(FUJLAPTOP_DBG_INFO,
  592. "config: [alt interface: %d], [adjust disable: %d]\n",
  593. use_alt_lcd_levels, disable_brightness_adjust);
  594. if (get_max_brightness() <= 0)
  595. fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
  596. get_lcd_level();
  597. return result;
  598. err_unregister_input_dev:
  599. input_unregister_device(input);
  600. err_free_input_dev:
  601. input_free_device(input);
  602. err_stop:
  603. return result;
  604. }
  605. static int acpi_fujitsu_remove(struct acpi_device *device, int type)
  606. {
  607. struct fujitsu_t *fujitsu = acpi_driver_data(device);
  608. struct input_dev *input = fujitsu->input;
  609. input_unregister_device(input);
  610. input_free_device(input);
  611. fujitsu->acpi_handle = NULL;
  612. return 0;
  613. }
  614. /* Brightness notify */
  615. static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
  616. {
  617. struct input_dev *input;
  618. int keycode;
  619. int oldb, newb;
  620. input = fujitsu->input;
  621. switch (event) {
  622. case ACPI_FUJITSU_NOTIFY_CODE1:
  623. keycode = 0;
  624. oldb = fujitsu->brightness_level;
  625. get_lcd_level();
  626. newb = fujitsu->brightness_level;
  627. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  628. "brightness button event [%i -> %i (%i)]\n",
  629. oldb, newb, fujitsu->brightness_changed);
  630. if (oldb < newb) {
  631. if (disable_brightness_adjust != 1) {
  632. if (use_alt_lcd_levels)
  633. set_lcd_level_alt(newb);
  634. else
  635. set_lcd_level(newb);
  636. }
  637. acpi_bus_generate_proc_event(fujitsu->dev,
  638. ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
  639. keycode = KEY_BRIGHTNESSUP;
  640. } else if (oldb > newb) {
  641. if (disable_brightness_adjust != 1) {
  642. if (use_alt_lcd_levels)
  643. set_lcd_level_alt(newb);
  644. else
  645. set_lcd_level(newb);
  646. }
  647. acpi_bus_generate_proc_event(fujitsu->dev,
  648. ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
  649. keycode = KEY_BRIGHTNESSDOWN;
  650. }
  651. break;
  652. default:
  653. keycode = KEY_UNKNOWN;
  654. vdbg_printk(FUJLAPTOP_DBG_WARN,
  655. "unsupported event [0x%x]\n", event);
  656. break;
  657. }
  658. if (keycode != 0) {
  659. input_report_key(input, keycode, 1);
  660. input_sync(input);
  661. input_report_key(input, keycode, 0);
  662. input_sync(input);
  663. }
  664. }
  665. /* ACPI device for hotkey handling */
  666. static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
  667. {
  668. acpi_handle handle;
  669. int result = 0;
  670. int state = 0;
  671. struct input_dev *input;
  672. int error;
  673. int i;
  674. if (!device)
  675. return -EINVAL;
  676. fujitsu_hotkey->acpi_handle = device->handle;
  677. sprintf(acpi_device_name(device), "%s",
  678. ACPI_FUJITSU_HOTKEY_DEVICE_NAME);
  679. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  680. device->driver_data = fujitsu_hotkey;
  681. /* kfifo */
  682. spin_lock_init(&fujitsu_hotkey->fifo_lock);
  683. error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int),
  684. GFP_KERNEL);
  685. if (error) {
  686. printk(KERN_ERR "kfifo_alloc failed\n");
  687. goto err_stop;
  688. }
  689. fujitsu_hotkey->input = input = input_allocate_device();
  690. if (!input) {
  691. error = -ENOMEM;
  692. goto err_free_fifo;
  693. }
  694. snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys),
  695. "%s/video/input0", acpi_device_hid(device));
  696. input->name = acpi_device_name(device);
  697. input->phys = fujitsu_hotkey->phys;
  698. input->id.bustype = BUS_HOST;
  699. input->id.product = 0x06;
  700. input->dev.parent = &device->dev;
  701. set_bit(EV_KEY, input->evbit);
  702. set_bit(fujitsu->keycode1, input->keybit);
  703. set_bit(fujitsu->keycode2, input->keybit);
  704. set_bit(fujitsu->keycode3, input->keybit);
  705. set_bit(fujitsu->keycode4, input->keybit);
  706. set_bit(KEY_UNKNOWN, input->keybit);
  707. error = input_register_device(input);
  708. if (error)
  709. goto err_free_input_dev;
  710. result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
  711. if (result) {
  712. printk(KERN_ERR "Error reading power state\n");
  713. goto err_unregister_input_dev;
  714. }
  715. printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
  716. acpi_device_name(device), acpi_device_bid(device),
  717. !device->power.state ? "on" : "off");
  718. fujitsu_hotkey->dev = device;
  719. if (ACPI_SUCCESS
  720. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  721. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  722. if (ACPI_FAILURE
  723. (acpi_evaluate_object
  724. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  725. printk(KERN_ERR "_INI Method failed\n");
  726. }
  727. i = 0;
  728. while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0
  729. && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE)
  730. ; /* No action, result is discarded */
  731. vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
  732. fujitsu_hotkey->rfkill_supported =
  733. call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0);
  734. /* Make sure our bitmask of supported functions is cleared if the
  735. RFKILL function block is not implemented, like on the S7020. */
  736. if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD)
  737. fujitsu_hotkey->rfkill_supported = 0;
  738. if (fujitsu_hotkey->rfkill_supported)
  739. fujitsu_hotkey->rfkill_state =
  740. call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
  741. /* Suspect this is a keymap of the application panel, print it */
  742. printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
  743. call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
  744. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  745. if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
  746. result = led_classdev_register(&fujitsu->pf_device->dev,
  747. &logolamp_led);
  748. if (result == 0) {
  749. fujitsu_hotkey->logolamp_registered = 1;
  750. } else {
  751. printk(KERN_ERR "fujitsu-laptop: Could not register "
  752. "LED handler for logo lamp, error %i\n", result);
  753. }
  754. }
  755. if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
  756. (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
  757. result = led_classdev_register(&fujitsu->pf_device->dev,
  758. &kblamps_led);
  759. if (result == 0) {
  760. fujitsu_hotkey->kblamps_registered = 1;
  761. } else {
  762. printk(KERN_ERR "fujitsu-laptop: Could not register "
  763. "LED handler for keyboard lamps, error %i\n", result);
  764. }
  765. }
  766. #endif
  767. return result;
  768. err_unregister_input_dev:
  769. input_unregister_device(input);
  770. err_free_input_dev:
  771. input_free_device(input);
  772. err_free_fifo:
  773. kfifo_free(&fujitsu_hotkey->fifo);
  774. err_stop:
  775. return result;
  776. }
  777. static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
  778. {
  779. struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device);
  780. struct input_dev *input = fujitsu_hotkey->input;
  781. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  782. if (fujitsu_hotkey->logolamp_registered)
  783. led_classdev_unregister(&logolamp_led);
  784. if (fujitsu_hotkey->kblamps_registered)
  785. led_classdev_unregister(&kblamps_led);
  786. #endif
  787. input_unregister_device(input);
  788. input_free_device(input);
  789. kfifo_free(&fujitsu_hotkey->fifo);
  790. fujitsu_hotkey->acpi_handle = NULL;
  791. return 0;
  792. }
  793. static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
  794. {
  795. struct input_dev *input;
  796. int keycode, keycode_r;
  797. unsigned int irb = 1;
  798. int i, status;
  799. input = fujitsu_hotkey->input;
  800. if (fujitsu_hotkey->rfkill_supported)
  801. fujitsu_hotkey->rfkill_state =
  802. call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
  803. switch (event) {
  804. case ACPI_FUJITSU_NOTIFY_CODE1:
  805. i = 0;
  806. while ((irb =
  807. call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0
  808. && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
  809. switch (irb & 0x4ff) {
  810. case KEY1_CODE:
  811. keycode = fujitsu->keycode1;
  812. break;
  813. case KEY2_CODE:
  814. keycode = fujitsu->keycode2;
  815. break;
  816. case KEY3_CODE:
  817. keycode = fujitsu->keycode3;
  818. break;
  819. case KEY4_CODE:
  820. keycode = fujitsu->keycode4;
  821. break;
  822. case 0:
  823. keycode = 0;
  824. break;
  825. default:
  826. vdbg_printk(FUJLAPTOP_DBG_WARN,
  827. "Unknown GIRB result [%x]\n", irb);
  828. keycode = -1;
  829. break;
  830. }
  831. if (keycode > 0) {
  832. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  833. "Push keycode into ringbuffer [%d]\n",
  834. keycode);
  835. status = kfifo_in_locked(&fujitsu_hotkey->fifo,
  836. (unsigned char *)&keycode,
  837. sizeof(keycode),
  838. &fujitsu_hotkey->fifo_lock);
  839. if (status != sizeof(keycode)) {
  840. vdbg_printk(FUJLAPTOP_DBG_WARN,
  841. "Could not push keycode [0x%x]\n",
  842. keycode);
  843. } else {
  844. input_report_key(input, keycode, 1);
  845. input_sync(input);
  846. }
  847. } else if (keycode == 0) {
  848. while ((status =
  849. kfifo_out_locked(
  850. &fujitsu_hotkey->fifo,
  851. (unsigned char *) &keycode_r,
  852. sizeof(keycode_r),
  853. &fujitsu_hotkey->fifo_lock))
  854. == sizeof(keycode_r)) {
  855. input_report_key(input, keycode_r, 0);
  856. input_sync(input);
  857. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  858. "Pop keycode from ringbuffer [%d]\n",
  859. keycode_r);
  860. }
  861. }
  862. }
  863. break;
  864. default:
  865. keycode = KEY_UNKNOWN;
  866. vdbg_printk(FUJLAPTOP_DBG_WARN,
  867. "Unsupported event [0x%x]\n", event);
  868. input_report_key(input, keycode, 1);
  869. input_sync(input);
  870. input_report_key(input, keycode, 0);
  871. input_sync(input);
  872. break;
  873. }
  874. }
  875. /* Initialization */
  876. static const struct acpi_device_id fujitsu_device_ids[] = {
  877. {ACPI_FUJITSU_HID, 0},
  878. {"", 0},
  879. };
  880. static struct acpi_driver acpi_fujitsu_driver = {
  881. .name = ACPI_FUJITSU_DRIVER_NAME,
  882. .class = ACPI_FUJITSU_CLASS,
  883. .ids = fujitsu_device_ids,
  884. .ops = {
  885. .add = acpi_fujitsu_add,
  886. .remove = acpi_fujitsu_remove,
  887. .notify = acpi_fujitsu_notify,
  888. },
  889. };
  890. static const struct acpi_device_id fujitsu_hotkey_device_ids[] = {
  891. {ACPI_FUJITSU_HOTKEY_HID, 0},
  892. {"", 0},
  893. };
  894. static struct acpi_driver acpi_fujitsu_hotkey_driver = {
  895. .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME,
  896. .class = ACPI_FUJITSU_CLASS,
  897. .ids = fujitsu_hotkey_device_ids,
  898. .ops = {
  899. .add = acpi_fujitsu_hotkey_add,
  900. .remove = acpi_fujitsu_hotkey_remove,
  901. .notify = acpi_fujitsu_hotkey_notify,
  902. },
  903. };
  904. static int __init fujitsu_init(void)
  905. {
  906. int ret, result, max_brightness;
  907. if (acpi_disabled)
  908. return -ENODEV;
  909. fujitsu = kmalloc(sizeof(struct fujitsu_t), GFP_KERNEL);
  910. if (!fujitsu)
  911. return -ENOMEM;
  912. memset(fujitsu, 0, sizeof(struct fujitsu_t));
  913. fujitsu->keycode1 = KEY_PROG1;
  914. fujitsu->keycode2 = KEY_PROG2;
  915. fujitsu->keycode3 = KEY_PROG3;
  916. fujitsu->keycode4 = KEY_PROG4;
  917. dmi_check_system(fujitsu_dmi_table);
  918. result = acpi_bus_register_driver(&acpi_fujitsu_driver);
  919. if (result < 0) {
  920. ret = -ENODEV;
  921. goto fail_acpi;
  922. }
  923. /* Register platform stuff */
  924. fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1);
  925. if (!fujitsu->pf_device) {
  926. ret = -ENOMEM;
  927. goto fail_platform_driver;
  928. }
  929. ret = platform_device_add(fujitsu->pf_device);
  930. if (ret)
  931. goto fail_platform_device1;
  932. ret =
  933. sysfs_create_group(&fujitsu->pf_device->dev.kobj,
  934. &fujitsupf_attribute_group);
  935. if (ret)
  936. goto fail_platform_device2;
  937. /* Register backlight stuff */
  938. if (!acpi_video_backlight_support()) {
  939. struct backlight_properties props;
  940. memset(&props, 0, sizeof(struct backlight_properties));
  941. max_brightness = fujitsu->max_brightness;
  942. props.max_brightness = max_brightness - 1;
  943. fujitsu->bl_device = backlight_device_register("fujitsu-laptop",
  944. NULL, NULL,
  945. &fujitsubl_ops,
  946. &props);
  947. if (IS_ERR(fujitsu->bl_device)) {
  948. ret = PTR_ERR(fujitsu->bl_device);
  949. fujitsu->bl_device = NULL;
  950. goto fail_sysfs_group;
  951. }
  952. fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
  953. }
  954. ret = platform_driver_register(&fujitsupf_driver);
  955. if (ret)
  956. goto fail_backlight;
  957. /* Register hotkey driver */
  958. fujitsu_hotkey = kmalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL);
  959. if (!fujitsu_hotkey) {
  960. ret = -ENOMEM;
  961. goto fail_hotkey;
  962. }
  963. memset(fujitsu_hotkey, 0, sizeof(struct fujitsu_hotkey_t));
  964. result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver);
  965. if (result < 0) {
  966. ret = -ENODEV;
  967. goto fail_hotkey1;
  968. }
  969. /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
  970. if (!acpi_video_backlight_support()) {
  971. if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
  972. fujitsu->bl_device->props.power = 4;
  973. else
  974. fujitsu->bl_device->props.power = 0;
  975. }
  976. printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION
  977. " successfully loaded.\n");
  978. return 0;
  979. fail_hotkey1:
  980. kfree(fujitsu_hotkey);
  981. fail_hotkey:
  982. platform_driver_unregister(&fujitsupf_driver);
  983. fail_backlight:
  984. if (fujitsu->bl_device)
  985. backlight_device_unregister(fujitsu->bl_device);
  986. fail_sysfs_group:
  987. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  988. &fujitsupf_attribute_group);
  989. fail_platform_device2:
  990. platform_device_del(fujitsu->pf_device);
  991. fail_platform_device1:
  992. platform_device_put(fujitsu->pf_device);
  993. fail_platform_driver:
  994. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  995. fail_acpi:
  996. kfree(fujitsu);
  997. return ret;
  998. }
  999. static void __exit fujitsu_cleanup(void)
  1000. {
  1001. acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
  1002. kfree(fujitsu_hotkey);
  1003. platform_driver_unregister(&fujitsupf_driver);
  1004. if (fujitsu->bl_device)
  1005. backlight_device_unregister(fujitsu->bl_device);
  1006. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  1007. &fujitsupf_attribute_group);
  1008. platform_device_unregister(fujitsu->pf_device);
  1009. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  1010. kfree(fujitsu);
  1011. printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
  1012. }
  1013. module_init(fujitsu_init);
  1014. module_exit(fujitsu_cleanup);
  1015. module_param(use_alt_lcd_levels, uint, 0644);
  1016. MODULE_PARM_DESC(use_alt_lcd_levels,
  1017. "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
  1018. module_param(disable_brightness_adjust, uint, 0644);
  1019. MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
  1020. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  1021. module_param_named(debug, dbg_level, uint, 0644);
  1022. MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
  1023. #endif
  1024. MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
  1025. MODULE_DESCRIPTION("Fujitsu laptop extras support");
  1026. MODULE_VERSION(FUJITSU_DRIVER_VERSION);
  1027. MODULE_LICENSE("GPL");
  1028. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
  1029. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
  1030. MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
  1031. static struct pnp_device_id pnp_ids[] = {
  1032. {.id = "FUJ02bf"},
  1033. {.id = "FUJ02B1"},
  1034. {.id = "FUJ02E3"},
  1035. {.id = ""}
  1036. };
  1037. MODULE_DEVICE_TABLE(pnp, pnp_ids);