fujitsu-laptop.c 32 KB

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