fujitsu-laptop.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  53. #include <linux/module.h>
  54. #include <linux/kernel.h>
  55. #include <linux/init.h>
  56. #include <linux/acpi.h>
  57. #include <linux/dmi.h>
  58. #include <linux/backlight.h>
  59. #include <linux/input.h>
  60. #include <linux/kfifo.h>
  61. #include <linux/video_output.h>
  62. #include <linux/platform_device.h>
  63. #include <linux/slab.h>
  64. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  65. #include <linux/leds.h>
  66. #endif
  67. #define FUJITSU_DRIVER_VERSION "0.6.0"
  68. #define FUJITSU_LCD_N_LEVELS 8
  69. #define ACPI_FUJITSU_CLASS "fujitsu"
  70. #define ACPI_FUJITSU_HID "FUJ02B1"
  71. #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver"
  72. #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1"
  73. #define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3"
  74. #define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver"
  75. #define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3"
  76. #define ACPI_FUJITSU_NOTIFY_CODE1 0x80
  77. #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
  78. #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
  79. /* FUNC interface - command values */
  80. #define FUNC_RFKILL 0x1000
  81. #define FUNC_LEDS 0x1001
  82. #define FUNC_BUTTONS 0x1002
  83. #define FUNC_BACKLIGHT 0x1004
  84. /* FUNC interface - responses */
  85. #define UNSUPPORTED_CMD 0x80000000
  86. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  87. /* FUNC interface - LED control */
  88. #define FUNC_LED_OFF 0x1
  89. #define FUNC_LED_ON 0x30001
  90. #define KEYBOARD_LAMPS 0x100
  91. #define LOGOLAMP_POWERON 0x2000
  92. #define LOGOLAMP_ALWAYS 0x4000
  93. #endif
  94. /* Hotkey details */
  95. #define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */
  96. #define KEY2_CODE 0x411
  97. #define KEY3_CODE 0x412
  98. #define KEY4_CODE 0x413
  99. #define MAX_HOTKEY_RINGBUFFER_SIZE 100
  100. #define RINGBUFFERSIZE 40
  101. /* Debugging */
  102. #define FUJLAPTOP_LOG ACPI_FUJITSU_HID ": "
  103. #define FUJLAPTOP_ERR KERN_ERR FUJLAPTOP_LOG
  104. #define FUJLAPTOP_NOTICE KERN_NOTICE FUJLAPTOP_LOG
  105. #define FUJLAPTOP_INFO KERN_INFO FUJLAPTOP_LOG
  106. #define FUJLAPTOP_DEBUG KERN_DEBUG FUJLAPTOP_LOG
  107. #define FUJLAPTOP_DBG_ALL 0xffff
  108. #define FUJLAPTOP_DBG_ERROR 0x0001
  109. #define FUJLAPTOP_DBG_WARN 0x0002
  110. #define FUJLAPTOP_DBG_INFO 0x0004
  111. #define FUJLAPTOP_DBG_TRACE 0x0008
  112. #define dbg_printk(a_dbg_level, format, arg...) \
  113. do { if (dbg_level & a_dbg_level) \
  114. printk(FUJLAPTOP_DEBUG "%s: " format, __func__ , ## arg); \
  115. } while (0)
  116. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  117. #define vdbg_printk(a_dbg_level, format, arg...) \
  118. dbg_printk(a_dbg_level, format, ## arg)
  119. #else
  120. #define vdbg_printk(a_dbg_level, format, arg...)
  121. #endif
  122. /* Device controlling the backlight and associated keys */
  123. struct fujitsu_t {
  124. acpi_handle acpi_handle;
  125. struct acpi_device *dev;
  126. struct input_dev *input;
  127. char phys[32];
  128. struct backlight_device *bl_device;
  129. struct platform_device *pf_device;
  130. int keycode1, keycode2, keycode3, keycode4;
  131. unsigned int max_brightness;
  132. unsigned int brightness_changed;
  133. unsigned int brightness_level;
  134. };
  135. static struct fujitsu_t *fujitsu;
  136. static int use_alt_lcd_levels = -1;
  137. static int disable_brightness_adjust = -1;
  138. /* Device used to access other hotkeys on the laptop */
  139. struct fujitsu_hotkey_t {
  140. acpi_handle acpi_handle;
  141. struct acpi_device *dev;
  142. struct input_dev *input;
  143. char phys[32];
  144. struct platform_device *pf_device;
  145. struct kfifo fifo;
  146. spinlock_t fifo_lock;
  147. int rfkill_supported;
  148. int rfkill_state;
  149. int logolamp_registered;
  150. int kblamps_registered;
  151. };
  152. static struct fujitsu_hotkey_t *fujitsu_hotkey;
  153. static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
  154. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  155. static enum led_brightness logolamp_get(struct led_classdev *cdev);
  156. static void logolamp_set(struct led_classdev *cdev,
  157. enum led_brightness brightness);
  158. static struct led_classdev logolamp_led = {
  159. .name = "fujitsu::logolamp",
  160. .brightness_get = logolamp_get,
  161. .brightness_set = logolamp_set
  162. };
  163. static enum led_brightness kblamps_get(struct led_classdev *cdev);
  164. static void kblamps_set(struct led_classdev *cdev,
  165. enum led_brightness brightness);
  166. static struct led_classdev kblamps_led = {
  167. .name = "fujitsu::kblamps",
  168. .brightness_get = kblamps_get,
  169. .brightness_set = kblamps_set
  170. };
  171. #endif
  172. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  173. static u32 dbg_level = 0x03;
  174. #endif
  175. static void acpi_fujitsu_notify(struct acpi_device *device, u32 event);
  176. /* Fujitsu ACPI interface function */
  177. static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
  178. {
  179. acpi_status status = AE_OK;
  180. union acpi_object params[4] = {
  181. { .type = ACPI_TYPE_INTEGER },
  182. { .type = ACPI_TYPE_INTEGER },
  183. { .type = ACPI_TYPE_INTEGER },
  184. { .type = ACPI_TYPE_INTEGER }
  185. };
  186. struct acpi_object_list arg_list = { 4, &params[0] };
  187. struct acpi_buffer output;
  188. union acpi_object out_obj;
  189. acpi_handle handle = NULL;
  190. status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
  191. if (ACPI_FAILURE(status)) {
  192. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  193. "FUNC interface is not present\n");
  194. return -ENODEV;
  195. }
  196. params[0].integer.value = cmd;
  197. params[1].integer.value = arg0;
  198. params[2].integer.value = arg1;
  199. params[3].integer.value = arg2;
  200. output.length = sizeof(out_obj);
  201. output.pointer = &out_obj;
  202. status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
  203. if (ACPI_FAILURE(status)) {
  204. vdbg_printk(FUJLAPTOP_DBG_WARN,
  205. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
  206. cmd, arg0, arg1, arg2);
  207. return -ENODEV;
  208. }
  209. if (out_obj.type != ACPI_TYPE_INTEGER) {
  210. vdbg_printk(FUJLAPTOP_DBG_WARN,
  211. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
  212. "return an integer\n",
  213. cmd, arg0, arg1, arg2);
  214. return -ENODEV;
  215. }
  216. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  217. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
  218. cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
  219. return out_obj.integer.value;
  220. }
  221. #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  222. /* LED class callbacks */
  223. static void logolamp_set(struct led_classdev *cdev,
  224. enum led_brightness brightness)
  225. {
  226. if (brightness >= LED_FULL) {
  227. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
  228. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
  229. } else if (brightness >= LED_HALF) {
  230. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
  231. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
  232. } else {
  233. call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
  234. }
  235. }
  236. static void kblamps_set(struct led_classdev *cdev,
  237. enum led_brightness brightness)
  238. {
  239. if (brightness >= LED_FULL)
  240. call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
  241. else
  242. call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
  243. }
  244. static enum led_brightness logolamp_get(struct led_classdev *cdev)
  245. {
  246. enum led_brightness brightness = LED_OFF;
  247. int poweron, always;
  248. poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
  249. if (poweron == FUNC_LED_ON) {
  250. brightness = LED_HALF;
  251. always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
  252. if (always == FUNC_LED_ON)
  253. brightness = LED_FULL;
  254. }
  255. return brightness;
  256. }
  257. static enum led_brightness kblamps_get(struct led_classdev *cdev)
  258. {
  259. enum led_brightness brightness = LED_OFF;
  260. if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
  261. brightness = LED_FULL;
  262. return brightness;
  263. }
  264. #endif
  265. /* Hardware access for LCD brightness control */
  266. static int set_lcd_level(int level)
  267. {
  268. acpi_status status = AE_OK;
  269. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  270. struct acpi_object_list arg_list = { 1, &arg0 };
  271. acpi_handle handle = NULL;
  272. vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n",
  273. level);
  274. if (level < 0 || level >= fujitsu->max_brightness)
  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. status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle);
  298. if (ACPI_FAILURE(status)) {
  299. vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
  300. return -ENODEV;
  301. }
  302. arg0.integer.value = level;
  303. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  304. if (ACPI_FAILURE(status))
  305. return -ENODEV;
  306. return 0;
  307. }
  308. static int get_lcd_level(void)
  309. {
  310. unsigned long long state = 0;
  311. acpi_status status = AE_OK;
  312. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n");
  313. status =
  314. acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
  315. if (ACPI_FAILURE(status))
  316. return 0;
  317. fujitsu->brightness_level = state & 0x0fffffff;
  318. if (state & 0x80000000)
  319. fujitsu->brightness_changed = 1;
  320. else
  321. fujitsu->brightness_changed = 0;
  322. return fujitsu->brightness_level;
  323. }
  324. static int get_max_brightness(void)
  325. {
  326. unsigned long long state = 0;
  327. acpi_status status = AE_OK;
  328. vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n");
  329. status =
  330. acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
  331. if (ACPI_FAILURE(status))
  332. return -1;
  333. fujitsu->max_brightness = state;
  334. return fujitsu->max_brightness;
  335. }
  336. /* Backlight device stuff */
  337. static int bl_get_brightness(struct backlight_device *b)
  338. {
  339. return get_lcd_level();
  340. }
  341. static int bl_update_status(struct backlight_device *b)
  342. {
  343. int ret;
  344. if (b->props.power == 4)
  345. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3);
  346. else
  347. ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0);
  348. if (ret != 0)
  349. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  350. "Unable to adjust backlight power, error code %i\n",
  351. ret);
  352. if (use_alt_lcd_levels)
  353. ret = set_lcd_level_alt(b->props.brightness);
  354. else
  355. ret = set_lcd_level(b->props.brightness);
  356. if (ret != 0)
  357. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  358. "Unable to adjust LCD brightness, error code %i\n",
  359. ret);
  360. return ret;
  361. }
  362. static const struct backlight_ops fujitsubl_ops = {
  363. .get_brightness = bl_get_brightness,
  364. .update_status = bl_update_status,
  365. };
  366. /* Platform LCD brightness device */
  367. static ssize_t
  368. show_max_brightness(struct device *dev,
  369. struct device_attribute *attr, char *buf)
  370. {
  371. int ret;
  372. ret = get_max_brightness();
  373. if (ret < 0)
  374. return ret;
  375. return sprintf(buf, "%i\n", ret);
  376. }
  377. static ssize_t
  378. show_brightness_changed(struct device *dev,
  379. struct device_attribute *attr, char *buf)
  380. {
  381. int ret;
  382. ret = fujitsu->brightness_changed;
  383. if (ret < 0)
  384. return ret;
  385. return sprintf(buf, "%i\n", ret);
  386. }
  387. static ssize_t show_lcd_level(struct device *dev,
  388. struct device_attribute *attr, char *buf)
  389. {
  390. int ret;
  391. ret = get_lcd_level();
  392. if (ret < 0)
  393. return ret;
  394. return sprintf(buf, "%i\n", ret);
  395. }
  396. static ssize_t store_lcd_level(struct device *dev,
  397. struct device_attribute *attr, const char *buf,
  398. size_t count)
  399. {
  400. int level, ret;
  401. if (sscanf(buf, "%i", &level) != 1
  402. || (level < 0 || level >= fujitsu->max_brightness))
  403. return -EINVAL;
  404. if (use_alt_lcd_levels)
  405. ret = set_lcd_level_alt(level);
  406. else
  407. ret = set_lcd_level(level);
  408. if (ret < 0)
  409. return ret;
  410. ret = get_lcd_level();
  411. if (ret < 0)
  412. return ret;
  413. return count;
  414. }
  415. static ssize_t
  416. ignore_store(struct device *dev,
  417. struct device_attribute *attr, const char *buf, size_t count)
  418. {
  419. return count;
  420. }
  421. static ssize_t
  422. show_lid_state(struct device *dev,
  423. struct device_attribute *attr, char *buf)
  424. {
  425. if (!(fujitsu_hotkey->rfkill_supported & 0x100))
  426. return sprintf(buf, "unknown\n");
  427. if (fujitsu_hotkey->rfkill_state & 0x100)
  428. return sprintf(buf, "open\n");
  429. else
  430. return sprintf(buf, "closed\n");
  431. }
  432. static ssize_t
  433. show_dock_state(struct device *dev,
  434. struct device_attribute *attr, char *buf)
  435. {
  436. if (!(fujitsu_hotkey->rfkill_supported & 0x200))
  437. return sprintf(buf, "unknown\n");
  438. if (fujitsu_hotkey->rfkill_state & 0x200)
  439. return sprintf(buf, "docked\n");
  440. else
  441. return sprintf(buf, "undocked\n");
  442. }
  443. static ssize_t
  444. show_radios_state(struct device *dev,
  445. struct device_attribute *attr, char *buf)
  446. {
  447. if (!(fujitsu_hotkey->rfkill_supported & 0x20))
  448. return sprintf(buf, "unknown\n");
  449. if (fujitsu_hotkey->rfkill_state & 0x20)
  450. return sprintf(buf, "on\n");
  451. else
  452. return sprintf(buf, "killed\n");
  453. }
  454. static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store);
  455. static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed,
  456. ignore_store);
  457. static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
  458. static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
  459. static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
  460. static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
  461. static struct attribute *fujitsupf_attributes[] = {
  462. &dev_attr_brightness_changed.attr,
  463. &dev_attr_max_brightness.attr,
  464. &dev_attr_lcd_level.attr,
  465. &dev_attr_lid.attr,
  466. &dev_attr_dock.attr,
  467. &dev_attr_radios.attr,
  468. NULL
  469. };
  470. static struct attribute_group fujitsupf_attribute_group = {
  471. .attrs = fujitsupf_attributes
  472. };
  473. static struct platform_driver fujitsupf_driver = {
  474. .driver = {
  475. .name = "fujitsu-laptop",
  476. .owner = THIS_MODULE,
  477. }
  478. };
  479. static void dmi_check_cb_common(const struct dmi_system_id *id)
  480. {
  481. acpi_handle handle;
  482. pr_info("Identified laptop model '%s'\n", 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 1;
  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 1;
  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 1;
  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_update_power(fujitsu->acpi_handle, &state);
  573. if (result) {
  574. pr_err("Error reading power state\n");
  575. goto err_unregister_input_dev;
  576. }
  577. pr_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. pr_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. input = NULL;
  602. err_free_input_dev:
  603. input_free_device(input);
  604. err_stop:
  605. return result;
  606. }
  607. static int acpi_fujitsu_remove(struct acpi_device *device, int type)
  608. {
  609. struct fujitsu_t *fujitsu = acpi_driver_data(device);
  610. struct input_dev *input = fujitsu->input;
  611. input_unregister_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. pr_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_update_power(fujitsu_hotkey->acpi_handle, &state);
  712. if (result) {
  713. pr_err("Error reading power state\n");
  714. goto err_unregister_input_dev;
  715. }
  716. pr_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. pr_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. pr_info("BTNI: [0x%x]\n", 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. pr_err("Could not register LED handler for logo lamp, error %i\n",
  752. 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. pr_err("Could not register LED handler for keyboard lamps, error %i\n",
  763. result);
  764. }
  765. }
  766. #endif
  767. return result;
  768. err_unregister_input_dev:
  769. input_unregister_device(input);
  770. input = NULL;
  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. 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 = kzalloc(sizeof(struct fujitsu_t), GFP_KERNEL);
  910. if (!fujitsu)
  911. return -ENOMEM;
  912. fujitsu->keycode1 = KEY_PROG1;
  913. fujitsu->keycode2 = KEY_PROG2;
  914. fujitsu->keycode3 = KEY_PROG3;
  915. fujitsu->keycode4 = KEY_PROG4;
  916. dmi_check_system(fujitsu_dmi_table);
  917. result = acpi_bus_register_driver(&acpi_fujitsu_driver);
  918. if (result < 0) {
  919. ret = -ENODEV;
  920. goto fail_acpi;
  921. }
  922. /* Register platform stuff */
  923. fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1);
  924. if (!fujitsu->pf_device) {
  925. ret = -ENOMEM;
  926. goto fail_platform_driver;
  927. }
  928. ret = platform_device_add(fujitsu->pf_device);
  929. if (ret)
  930. goto fail_platform_device1;
  931. ret =
  932. sysfs_create_group(&fujitsu->pf_device->dev.kobj,
  933. &fujitsupf_attribute_group);
  934. if (ret)
  935. goto fail_platform_device2;
  936. /* Register backlight stuff */
  937. if (!acpi_video_backlight_support()) {
  938. struct backlight_properties props;
  939. memset(&props, 0, sizeof(struct backlight_properties));
  940. max_brightness = fujitsu->max_brightness;
  941. props.type = BACKLIGHT_PLATFORM;
  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. pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n");
  976. return 0;
  977. fail_hotkey1:
  978. kfree(fujitsu_hotkey);
  979. fail_hotkey:
  980. platform_driver_unregister(&fujitsupf_driver);
  981. fail_backlight:
  982. if (fujitsu->bl_device)
  983. backlight_device_unregister(fujitsu->bl_device);
  984. fail_sysfs_group:
  985. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  986. &fujitsupf_attribute_group);
  987. fail_platform_device2:
  988. platform_device_del(fujitsu->pf_device);
  989. fail_platform_device1:
  990. platform_device_put(fujitsu->pf_device);
  991. fail_platform_driver:
  992. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  993. fail_acpi:
  994. kfree(fujitsu);
  995. return ret;
  996. }
  997. static void __exit fujitsu_cleanup(void)
  998. {
  999. acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
  1000. kfree(fujitsu_hotkey);
  1001. platform_driver_unregister(&fujitsupf_driver);
  1002. if (fujitsu->bl_device)
  1003. backlight_device_unregister(fujitsu->bl_device);
  1004. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  1005. &fujitsupf_attribute_group);
  1006. platform_device_unregister(fujitsu->pf_device);
  1007. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  1008. kfree(fujitsu);
  1009. pr_info("driver unloaded\n");
  1010. }
  1011. module_init(fujitsu_init);
  1012. module_exit(fujitsu_cleanup);
  1013. module_param(use_alt_lcd_levels, uint, 0644);
  1014. MODULE_PARM_DESC(use_alt_lcd_levels,
  1015. "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
  1016. module_param(disable_brightness_adjust, uint, 0644);
  1017. MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
  1018. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  1019. module_param_named(debug, dbg_level, uint, 0644);
  1020. MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
  1021. #endif
  1022. MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
  1023. MODULE_DESCRIPTION("Fujitsu laptop extras support");
  1024. MODULE_VERSION(FUJITSU_DRIVER_VERSION);
  1025. MODULE_LICENSE("GPL");
  1026. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
  1027. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
  1028. MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
  1029. static struct pnp_device_id pnp_ids[] __used = {
  1030. {.id = "FUJ02bf"},
  1031. {.id = "FUJ02B1"},
  1032. {.id = "FUJ02E3"},
  1033. {.id = ""}
  1034. };
  1035. MODULE_DEVICE_TABLE(pnp, pnp_ids);