fujitsu-laptop.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  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. #ifdef CONFIG_LEDS_CLASS
  63. #include <linux/leds.h>
  64. #endif
  65. #define FUJITSU_DRIVER_VERSION "0.5.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. #ifdef CONFIG_LEDS_CLASS
  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_state;
  146. int logolamp_registered;
  147. int kblamps_registered;
  148. };
  149. static struct fujitsu_hotkey_t *fujitsu_hotkey;
  150. static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
  151. void *data);
  152. #ifdef CONFIG_LEDS_CLASS
  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(acpi_handle handle, u32 event, void *data);
  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. #ifdef CONFIG_LEDS_CLASS
  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. if (!fujitsu)
  275. return -EINVAL;
  276. status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle);
  277. if (ACPI_FAILURE(status)) {
  278. vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n");
  279. return -ENODEV;
  280. }
  281. arg0.integer.value = level;
  282. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  283. if (ACPI_FAILURE(status))
  284. return -ENODEV;
  285. return 0;
  286. }
  287. static int set_lcd_level_alt(int level)
  288. {
  289. acpi_status status = AE_OK;
  290. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  291. struct acpi_object_list arg_list = { 1, &arg0 };
  292. acpi_handle handle = NULL;
  293. vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n",
  294. level);
  295. if (level < 0 || level >= fujitsu->max_brightness)
  296. return -EINVAL;
  297. if (!fujitsu)
  298. return -EINVAL;
  299. status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle);
  300. if (ACPI_FAILURE(status)) {
  301. vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
  302. return -ENODEV;
  303. }
  304. arg0.integer.value = level;
  305. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  306. if (ACPI_FAILURE(status))
  307. return -ENODEV;
  308. return 0;
  309. }
  310. static int get_lcd_level(void)
  311. {
  312. unsigned long long state = 0;
  313. acpi_status status = AE_OK;
  314. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n");
  315. status =
  316. acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
  317. if (status < 0)
  318. return status;
  319. fujitsu->brightness_level = state & 0x0fffffff;
  320. if (state & 0x80000000)
  321. fujitsu->brightness_changed = 1;
  322. else
  323. fujitsu->brightness_changed = 0;
  324. return fujitsu->brightness_level;
  325. }
  326. static int get_max_brightness(void)
  327. {
  328. unsigned long long state = 0;
  329. acpi_status status = AE_OK;
  330. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n");
  331. status =
  332. acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
  333. if (status < 0)
  334. return status;
  335. fujitsu->max_brightness = state;
  336. return fujitsu->max_brightness;
  337. }
  338. /* Backlight device stuff */
  339. static int bl_get_brightness(struct backlight_device *b)
  340. {
  341. return get_lcd_level();
  342. }
  343. static int bl_update_status(struct backlight_device *b)
  344. {
  345. int ret;
  346. if (b->props.power == 4)
  347. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3);
  348. else
  349. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0);
  350. if (ret != 0)
  351. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  352. "Unable to adjust backlight power, error code %i\n",
  353. ret);
  354. if (use_alt_lcd_levels)
  355. ret = set_lcd_level_alt(b->props.brightness);
  356. else
  357. ret = set_lcd_level(b->props.brightness);
  358. if (ret != 0)
  359. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  360. "Unable to adjust LCD brightness, error code %i\n",
  361. ret);
  362. return ret;
  363. }
  364. static struct backlight_ops fujitsubl_ops = {
  365. .get_brightness = bl_get_brightness,
  366. .update_status = bl_update_status,
  367. };
  368. /* Platform LCD brightness device */
  369. static ssize_t
  370. show_max_brightness(struct device *dev,
  371. struct device_attribute *attr, char *buf)
  372. {
  373. int ret;
  374. ret = get_max_brightness();
  375. if (ret < 0)
  376. return ret;
  377. return sprintf(buf, "%i\n", ret);
  378. }
  379. static ssize_t
  380. show_brightness_changed(struct device *dev,
  381. struct device_attribute *attr, char *buf)
  382. {
  383. int ret;
  384. ret = fujitsu->brightness_changed;
  385. if (ret < 0)
  386. return ret;
  387. return sprintf(buf, "%i\n", ret);
  388. }
  389. static ssize_t show_lcd_level(struct device *dev,
  390. struct device_attribute *attr, char *buf)
  391. {
  392. int ret;
  393. ret = get_lcd_level();
  394. if (ret < 0)
  395. return ret;
  396. return sprintf(buf, "%i\n", ret);
  397. }
  398. static ssize_t store_lcd_level(struct device *dev,
  399. struct device_attribute *attr, const char *buf,
  400. size_t count)
  401. {
  402. int level, ret;
  403. if (sscanf(buf, "%i", &level) != 1
  404. || (level < 0 || level >= fujitsu->max_brightness))
  405. return -EINVAL;
  406. if (use_alt_lcd_levels)
  407. ret = set_lcd_level_alt(level);
  408. else
  409. ret = set_lcd_level(level);
  410. if (ret < 0)
  411. return ret;
  412. ret = get_lcd_level();
  413. if (ret < 0)
  414. return ret;
  415. return count;
  416. }
  417. static ssize_t
  418. ignore_store(struct device *dev,
  419. struct device_attribute *attr, const char *buf, size_t count)
  420. {
  421. return count;
  422. }
  423. static ssize_t
  424. show_lid_state(struct device *dev,
  425. struct device_attribute *attr, char *buf)
  426. {
  427. if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
  428. return sprintf(buf, "unknown\n");
  429. if (fujitsu_hotkey->rfkill_state & 0x100)
  430. return sprintf(buf, "open\n");
  431. else
  432. return sprintf(buf, "closed\n");
  433. }
  434. static ssize_t
  435. show_dock_state(struct device *dev,
  436. struct device_attribute *attr, char *buf)
  437. {
  438. if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
  439. return sprintf(buf, "unknown\n");
  440. if (fujitsu_hotkey->rfkill_state & 0x200)
  441. return sprintf(buf, "docked\n");
  442. else
  443. return sprintf(buf, "undocked\n");
  444. }
  445. static ssize_t
  446. show_radios_state(struct device *dev,
  447. struct device_attribute *attr, char *buf)
  448. {
  449. if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
  450. return sprintf(buf, "unknown\n");
  451. if (fujitsu_hotkey->rfkill_state & 0x20)
  452. return sprintf(buf, "on\n");
  453. else
  454. return sprintf(buf, "killed\n");
  455. }
  456. static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store);
  457. static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed,
  458. ignore_store);
  459. static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
  460. static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
  461. static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
  462. static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
  463. static struct attribute *fujitsupf_attributes[] = {
  464. &dev_attr_brightness_changed.attr,
  465. &dev_attr_max_brightness.attr,
  466. &dev_attr_lcd_level.attr,
  467. &dev_attr_lid.attr,
  468. &dev_attr_dock.attr,
  469. &dev_attr_radios.attr,
  470. NULL
  471. };
  472. static struct attribute_group fujitsupf_attribute_group = {
  473. .attrs = fujitsupf_attributes
  474. };
  475. static struct platform_driver fujitsupf_driver = {
  476. .driver = {
  477. .name = "fujitsu-laptop",
  478. .owner = THIS_MODULE,
  479. }
  480. };
  481. static void dmi_check_cb_common(const struct dmi_system_id *id)
  482. {
  483. acpi_handle handle;
  484. printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
  485. id->ident);
  486. if (use_alt_lcd_levels == -1) {
  487. if (ACPI_SUCCESS(acpi_get_handle(NULL,
  488. "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
  489. use_alt_lcd_levels = 1;
  490. else
  491. use_alt_lcd_levels = 0;
  492. vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
  493. "%i\n", use_alt_lcd_levels);
  494. }
  495. }
  496. static int dmi_check_cb_s6410(const struct dmi_system_id *id)
  497. {
  498. dmi_check_cb_common(id);
  499. fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */
  500. fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */
  501. return 0;
  502. }
  503. static int dmi_check_cb_s6420(const struct dmi_system_id *id)
  504. {
  505. dmi_check_cb_common(id);
  506. fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */
  507. fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */
  508. return 0;
  509. }
  510. static int dmi_check_cb_p8010(const struct dmi_system_id *id)
  511. {
  512. dmi_check_cb_common(id);
  513. fujitsu->keycode1 = KEY_HELP; /* "Support" */
  514. fujitsu->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */
  515. fujitsu->keycode4 = KEY_WWW; /* "Internet" */
  516. return 0;
  517. }
  518. static struct dmi_system_id fujitsu_dmi_table[] = {
  519. {
  520. .ident = "Fujitsu Siemens S6410",
  521. .matches = {
  522. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  523. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"),
  524. },
  525. .callback = dmi_check_cb_s6410},
  526. {
  527. .ident = "Fujitsu Siemens S6420",
  528. .matches = {
  529. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  530. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6420"),
  531. },
  532. .callback = dmi_check_cb_s6420},
  533. {
  534. .ident = "Fujitsu LifeBook P8010",
  535. .matches = {
  536. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  537. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"),
  538. },
  539. .callback = dmi_check_cb_p8010},
  540. {}
  541. };
  542. /* ACPI device for LCD brightness control */
  543. static int acpi_fujitsu_add(struct acpi_device *device)
  544. {
  545. acpi_status status;
  546. acpi_handle handle;
  547. int result = 0;
  548. int state = 0;
  549. struct input_dev *input;
  550. int error;
  551. if (!device)
  552. return -EINVAL;
  553. fujitsu->acpi_handle = device->handle;
  554. sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME);
  555. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  556. device->driver_data = fujitsu;
  557. status = acpi_install_notify_handler(device->handle,
  558. ACPI_DEVICE_NOTIFY,
  559. acpi_fujitsu_notify, fujitsu);
  560. if (ACPI_FAILURE(status)) {
  561. printk(KERN_ERR "Error installing notify handler\n");
  562. error = -ENODEV;
  563. goto err_stop;
  564. }
  565. fujitsu->input = input = input_allocate_device();
  566. if (!input) {
  567. error = -ENOMEM;
  568. goto err_uninstall_notify;
  569. }
  570. snprintf(fujitsu->phys, sizeof(fujitsu->phys),
  571. "%s/video/input0", acpi_device_hid(device));
  572. input->name = acpi_device_name(device);
  573. input->phys = fujitsu->phys;
  574. input->id.bustype = BUS_HOST;
  575. input->id.product = 0x06;
  576. input->dev.parent = &device->dev;
  577. input->evbit[0] = BIT(EV_KEY);
  578. set_bit(KEY_BRIGHTNESSUP, input->keybit);
  579. set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
  580. set_bit(KEY_UNKNOWN, input->keybit);
  581. error = input_register_device(input);
  582. if (error)
  583. goto err_free_input_dev;
  584. result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
  585. if (result) {
  586. printk(KERN_ERR "Error reading power state\n");
  587. goto end;
  588. }
  589. printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
  590. acpi_device_name(device), acpi_device_bid(device),
  591. !device->power.state ? "on" : "off");
  592. fujitsu->dev = device;
  593. if (ACPI_SUCCESS
  594. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  595. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  596. if (ACPI_FAILURE
  597. (acpi_evaluate_object
  598. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  599. printk(KERN_ERR "_INI Method failed\n");
  600. }
  601. /* do config (detect defaults) */
  602. use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
  603. disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
  604. vdbg_printk(FUJLAPTOP_DBG_INFO,
  605. "config: [alt interface: %d], [adjust disable: %d]\n",
  606. use_alt_lcd_levels, disable_brightness_adjust);
  607. if (get_max_brightness() <= 0)
  608. fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
  609. get_lcd_level();
  610. return result;
  611. end:
  612. err_free_input_dev:
  613. input_free_device(input);
  614. err_uninstall_notify:
  615. acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
  616. acpi_fujitsu_notify);
  617. err_stop:
  618. return result;
  619. }
  620. static int acpi_fujitsu_remove(struct acpi_device *device, int type)
  621. {
  622. acpi_status status;
  623. struct fujitsu_t *fujitsu = NULL;
  624. if (!device || !acpi_driver_data(device))
  625. return -EINVAL;
  626. fujitsu = acpi_driver_data(device);
  627. status = acpi_remove_notify_handler(fujitsu->acpi_handle,
  628. ACPI_DEVICE_NOTIFY,
  629. acpi_fujitsu_notify);
  630. if (!device || !acpi_driver_data(device))
  631. return -EINVAL;
  632. fujitsu->acpi_handle = NULL;
  633. return 0;
  634. }
  635. /* Brightness notify */
  636. static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
  637. {
  638. struct input_dev *input;
  639. int keycode;
  640. int oldb, newb;
  641. input = fujitsu->input;
  642. switch (event) {
  643. case ACPI_FUJITSU_NOTIFY_CODE1:
  644. keycode = 0;
  645. oldb = fujitsu->brightness_level;
  646. get_lcd_level();
  647. newb = fujitsu->brightness_level;
  648. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  649. "brightness button event [%i -> %i (%i)]\n",
  650. oldb, newb, fujitsu->brightness_changed);
  651. if (oldb < newb) {
  652. if (disable_brightness_adjust != 1) {
  653. if (use_alt_lcd_levels)
  654. set_lcd_level_alt(newb);
  655. else
  656. set_lcd_level(newb);
  657. }
  658. acpi_bus_generate_proc_event(fujitsu->dev,
  659. ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
  660. keycode = KEY_BRIGHTNESSUP;
  661. } else if (oldb > newb) {
  662. if (disable_brightness_adjust != 1) {
  663. if (use_alt_lcd_levels)
  664. set_lcd_level_alt(newb);
  665. else
  666. set_lcd_level(newb);
  667. }
  668. acpi_bus_generate_proc_event(fujitsu->dev,
  669. ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
  670. keycode = KEY_BRIGHTNESSDOWN;
  671. }
  672. break;
  673. default:
  674. keycode = KEY_UNKNOWN;
  675. vdbg_printk(FUJLAPTOP_DBG_WARN,
  676. "unsupported event [0x%x]\n", event);
  677. break;
  678. }
  679. if (keycode != 0) {
  680. input_report_key(input, keycode, 1);
  681. input_sync(input);
  682. input_report_key(input, keycode, 0);
  683. input_sync(input);
  684. }
  685. return;
  686. }
  687. /* ACPI device for hotkey handling */
  688. static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
  689. {
  690. acpi_status status;
  691. acpi_handle handle;
  692. int result = 0;
  693. int state = 0;
  694. struct input_dev *input;
  695. int error;
  696. int i;
  697. if (!device)
  698. return -EINVAL;
  699. fujitsu_hotkey->acpi_handle = device->handle;
  700. sprintf(acpi_device_name(device), "%s",
  701. ACPI_FUJITSU_HOTKEY_DEVICE_NAME);
  702. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  703. device->driver_data = fujitsu_hotkey;
  704. status = acpi_install_notify_handler(device->handle,
  705. ACPI_DEVICE_NOTIFY,
  706. acpi_fujitsu_hotkey_notify,
  707. fujitsu_hotkey);
  708. if (ACPI_FAILURE(status)) {
  709. printk(KERN_ERR "Error installing notify handler\n");
  710. error = -ENODEV;
  711. goto err_stop;
  712. }
  713. /* kfifo */
  714. spin_lock_init(&fujitsu_hotkey->fifo_lock);
  715. fujitsu_hotkey->fifo =
  716. kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL,
  717. &fujitsu_hotkey->fifo_lock);
  718. if (IS_ERR(fujitsu_hotkey->fifo)) {
  719. printk(KERN_ERR "kfifo_alloc failed\n");
  720. error = PTR_ERR(fujitsu_hotkey->fifo);
  721. goto err_stop;
  722. }
  723. fujitsu_hotkey->input = input = input_allocate_device();
  724. if (!input) {
  725. error = -ENOMEM;
  726. goto err_uninstall_notify;
  727. }
  728. snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys),
  729. "%s/video/input0", acpi_device_hid(device));
  730. input->name = acpi_device_name(device);
  731. input->phys = fujitsu_hotkey->phys;
  732. input->id.bustype = BUS_HOST;
  733. input->id.product = 0x06;
  734. input->dev.parent = &device->dev;
  735. set_bit(EV_KEY, input->evbit);
  736. set_bit(fujitsu->keycode1, input->keybit);
  737. set_bit(fujitsu->keycode2, input->keybit);
  738. set_bit(fujitsu->keycode3, input->keybit);
  739. set_bit(fujitsu->keycode4, input->keybit);
  740. set_bit(KEY_UNKNOWN, input->keybit);
  741. error = input_register_device(input);
  742. if (error)
  743. goto err_free_input_dev;
  744. result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
  745. if (result) {
  746. printk(KERN_ERR "Error reading power state\n");
  747. goto end;
  748. }
  749. printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
  750. acpi_device_name(device), acpi_device_bid(device),
  751. !device->power.state ? "on" : "off");
  752. fujitsu_hotkey->dev = device;
  753. if (ACPI_SUCCESS
  754. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  755. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  756. if (ACPI_FAILURE
  757. (acpi_evaluate_object
  758. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  759. printk(KERN_ERR "_INI Method failed\n");
  760. }
  761. i = 0;
  762. while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0
  763. && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE)
  764. ; /* No action, result is discarded */
  765. vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
  766. fujitsu_hotkey->rfkill_state =
  767. call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
  768. /* Suspect this is a keymap of the application panel, print it */
  769. printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
  770. call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
  771. #ifdef CONFIG_LEDS_CLASS
  772. if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
  773. result = led_classdev_register(&fujitsu->pf_device->dev,
  774. &logolamp_led);
  775. if (result == 0) {
  776. fujitsu_hotkey->logolamp_registered = 1;
  777. } else {
  778. printk(KERN_ERR "fujitsu-laptop: Could not register "
  779. "LED handler for logo lamp, error %i\n", result);
  780. }
  781. }
  782. if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
  783. (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
  784. result = led_classdev_register(&fujitsu->pf_device->dev,
  785. &kblamps_led);
  786. if (result == 0) {
  787. fujitsu_hotkey->kblamps_registered = 1;
  788. } else {
  789. printk(KERN_ERR "fujitsu-laptop: Could not register "
  790. "LED handler for keyboard lamps, error %i\n", result);
  791. }
  792. }
  793. #endif
  794. return result;
  795. end:
  796. err_free_input_dev:
  797. input_free_device(input);
  798. err_uninstall_notify:
  799. acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
  800. acpi_fujitsu_hotkey_notify);
  801. kfifo_free(fujitsu_hotkey->fifo);
  802. err_stop:
  803. return result;
  804. }
  805. static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
  806. {
  807. acpi_status status;
  808. struct fujitsu_hotkey_t *fujitsu_hotkey = NULL;
  809. if (!device || !acpi_driver_data(device))
  810. return -EINVAL;
  811. fujitsu_hotkey = acpi_driver_data(device);
  812. status = acpi_remove_notify_handler(fujitsu_hotkey->acpi_handle,
  813. ACPI_DEVICE_NOTIFY,
  814. acpi_fujitsu_hotkey_notify);
  815. fujitsu_hotkey->acpi_handle = NULL;
  816. kfifo_free(fujitsu_hotkey->fifo);
  817. return 0;
  818. }
  819. static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
  820. void *data)
  821. {
  822. struct input_dev *input;
  823. int keycode, keycode_r;
  824. unsigned int irb = 1;
  825. int i, status;
  826. input = fujitsu_hotkey->input;
  827. fujitsu_hotkey->rfkill_state =
  828. call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
  829. switch (event) {
  830. case ACPI_FUJITSU_NOTIFY_CODE1:
  831. i = 0;
  832. while ((irb =
  833. call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0
  834. && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
  835. switch (irb & 0x4ff) {
  836. case KEY1_CODE:
  837. keycode = fujitsu->keycode1;
  838. break;
  839. case KEY2_CODE:
  840. keycode = fujitsu->keycode2;
  841. break;
  842. case KEY3_CODE:
  843. keycode = fujitsu->keycode3;
  844. break;
  845. case KEY4_CODE:
  846. keycode = fujitsu->keycode4;
  847. break;
  848. case 0:
  849. keycode = 0;
  850. break;
  851. default:
  852. vdbg_printk(FUJLAPTOP_DBG_WARN,
  853. "Unknown GIRB result [%x]\n", irb);
  854. keycode = -1;
  855. break;
  856. }
  857. if (keycode > 0) {
  858. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  859. "Push keycode into ringbuffer [%d]\n",
  860. keycode);
  861. status = kfifo_put(fujitsu_hotkey->fifo,
  862. (unsigned char *)&keycode,
  863. sizeof(keycode));
  864. if (status != sizeof(keycode)) {
  865. vdbg_printk(FUJLAPTOP_DBG_WARN,
  866. "Could not push keycode [0x%x]\n",
  867. keycode);
  868. } else {
  869. input_report_key(input, keycode, 1);
  870. input_sync(input);
  871. }
  872. } else if (keycode == 0) {
  873. while ((status =
  874. kfifo_get
  875. (fujitsu_hotkey->fifo, (unsigned char *)
  876. &keycode_r,
  877. sizeof
  878. (keycode_r))) == sizeof(keycode_r)) {
  879. input_report_key(input, keycode_r, 0);
  880. input_sync(input);
  881. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  882. "Pop keycode from ringbuffer [%d]\n",
  883. keycode_r);
  884. }
  885. }
  886. }
  887. break;
  888. default:
  889. keycode = KEY_UNKNOWN;
  890. vdbg_printk(FUJLAPTOP_DBG_WARN,
  891. "Unsupported event [0x%x]\n", event);
  892. input_report_key(input, keycode, 1);
  893. input_sync(input);
  894. input_report_key(input, keycode, 0);
  895. input_sync(input);
  896. break;
  897. }
  898. return;
  899. }
  900. /* Initialization */
  901. static const struct acpi_device_id fujitsu_device_ids[] = {
  902. {ACPI_FUJITSU_HID, 0},
  903. {"", 0},
  904. };
  905. static struct acpi_driver acpi_fujitsu_driver = {
  906. .name = ACPI_FUJITSU_DRIVER_NAME,
  907. .class = ACPI_FUJITSU_CLASS,
  908. .ids = fujitsu_device_ids,
  909. .ops = {
  910. .add = acpi_fujitsu_add,
  911. .remove = acpi_fujitsu_remove,
  912. },
  913. };
  914. static const struct acpi_device_id fujitsu_hotkey_device_ids[] = {
  915. {ACPI_FUJITSU_HOTKEY_HID, 0},
  916. {"", 0},
  917. };
  918. static struct acpi_driver acpi_fujitsu_hotkey_driver = {
  919. .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME,
  920. .class = ACPI_FUJITSU_CLASS,
  921. .ids = fujitsu_hotkey_device_ids,
  922. .ops = {
  923. .add = acpi_fujitsu_hotkey_add,
  924. .remove = acpi_fujitsu_hotkey_remove,
  925. },
  926. };
  927. static int __init fujitsu_init(void)
  928. {
  929. int ret, result, max_brightness;
  930. if (acpi_disabled)
  931. return -ENODEV;
  932. fujitsu = kmalloc(sizeof(struct fujitsu_t), GFP_KERNEL);
  933. if (!fujitsu)
  934. return -ENOMEM;
  935. memset(fujitsu, 0, sizeof(struct fujitsu_t));
  936. fujitsu->keycode1 = KEY_PROG1;
  937. fujitsu->keycode2 = KEY_PROG2;
  938. fujitsu->keycode3 = KEY_PROG3;
  939. fujitsu->keycode4 = KEY_PROG4;
  940. dmi_check_system(fujitsu_dmi_table);
  941. result = acpi_bus_register_driver(&acpi_fujitsu_driver);
  942. if (result < 0) {
  943. ret = -ENODEV;
  944. goto fail_acpi;
  945. }
  946. /* Register platform stuff */
  947. fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1);
  948. if (!fujitsu->pf_device) {
  949. ret = -ENOMEM;
  950. goto fail_platform_driver;
  951. }
  952. ret = platform_device_add(fujitsu->pf_device);
  953. if (ret)
  954. goto fail_platform_device1;
  955. ret =
  956. sysfs_create_group(&fujitsu->pf_device->dev.kobj,
  957. &fujitsupf_attribute_group);
  958. if (ret)
  959. goto fail_platform_device2;
  960. /* Register backlight stuff */
  961. if (!acpi_video_backlight_support()) {
  962. fujitsu->bl_device =
  963. backlight_device_register("fujitsu-laptop", NULL, NULL,
  964. &fujitsubl_ops);
  965. if (IS_ERR(fujitsu->bl_device))
  966. return PTR_ERR(fujitsu->bl_device);
  967. max_brightness = fujitsu->max_brightness;
  968. fujitsu->bl_device->props.max_brightness = max_brightness - 1;
  969. fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
  970. }
  971. ret = platform_driver_register(&fujitsupf_driver);
  972. if (ret)
  973. goto fail_backlight;
  974. /* Register hotkey driver */
  975. fujitsu_hotkey = kmalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL);
  976. if (!fujitsu_hotkey) {
  977. ret = -ENOMEM;
  978. goto fail_hotkey;
  979. }
  980. memset(fujitsu_hotkey, 0, sizeof(struct fujitsu_hotkey_t));
  981. result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver);
  982. if (result < 0) {
  983. ret = -ENODEV;
  984. goto fail_hotkey1;
  985. }
  986. /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
  987. if (!acpi_video_backlight_support()) {
  988. if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
  989. fujitsu->bl_device->props.power = 4;
  990. else
  991. fujitsu->bl_device->props.power = 0;
  992. }
  993. printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION
  994. " successfully loaded.\n");
  995. return 0;
  996. fail_hotkey1:
  997. kfree(fujitsu_hotkey);
  998. fail_hotkey:
  999. platform_driver_unregister(&fujitsupf_driver);
  1000. fail_backlight:
  1001. if (fujitsu->bl_device)
  1002. backlight_device_unregister(fujitsu->bl_device);
  1003. fail_platform_device2:
  1004. platform_device_del(fujitsu->pf_device);
  1005. fail_platform_device1:
  1006. platform_device_put(fujitsu->pf_device);
  1007. fail_platform_driver:
  1008. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  1009. fail_acpi:
  1010. kfree(fujitsu);
  1011. return ret;
  1012. }
  1013. static void __exit fujitsu_cleanup(void)
  1014. {
  1015. #ifdef CONFIG_LEDS_CLASS
  1016. if (fujitsu_hotkey->logolamp_registered != 0)
  1017. led_classdev_unregister(&logolamp_led);
  1018. if (fujitsu_hotkey->kblamps_registered != 0)
  1019. led_classdev_unregister(&kblamps_led);
  1020. #endif
  1021. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  1022. &fujitsupf_attribute_group);
  1023. platform_device_unregister(fujitsu->pf_device);
  1024. platform_driver_unregister(&fujitsupf_driver);
  1025. if (fujitsu->bl_device)
  1026. backlight_device_unregister(fujitsu->bl_device);
  1027. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  1028. kfree(fujitsu);
  1029. acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
  1030. kfree(fujitsu_hotkey);
  1031. printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
  1032. }
  1033. module_init(fujitsu_init);
  1034. module_exit(fujitsu_cleanup);
  1035. module_param(use_alt_lcd_levels, uint, 0644);
  1036. MODULE_PARM_DESC(use_alt_lcd_levels,
  1037. "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
  1038. module_param(disable_brightness_adjust, uint, 0644);
  1039. MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
  1040. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  1041. module_param_named(debug, dbg_level, uint, 0644);
  1042. MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
  1043. #endif
  1044. MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
  1045. MODULE_DESCRIPTION("Fujitsu laptop extras support");
  1046. MODULE_VERSION(FUJITSU_DRIVER_VERSION);
  1047. MODULE_LICENSE("GPL");
  1048. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
  1049. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
  1050. MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
  1051. static struct pnp_device_id pnp_ids[] = {
  1052. {.id = "FUJ02bf"},
  1053. {.id = "FUJ02B1"},
  1054. {.id = "FUJ02E3"},
  1055. {.id = ""}
  1056. };
  1057. MODULE_DEVICE_TABLE(pnp, pnp_ids);