fujitsu-laptop.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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_supported;
  146. int rfkill_state;
  147. int logolamp_registered;
  148. int kblamps_registered;
  149. };
  150. static struct fujitsu_hotkey_t *fujitsu_hotkey;
  151. static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
  152. #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(struct acpi_device *device, u32 event);
  174. /* Fujitsu ACPI interface function */
  175. static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
  176. {
  177. acpi_status status = AE_OK;
  178. union acpi_object params[4] = {
  179. { .type = ACPI_TYPE_INTEGER },
  180. { .type = ACPI_TYPE_INTEGER },
  181. { .type = ACPI_TYPE_INTEGER },
  182. { .type = ACPI_TYPE_INTEGER }
  183. };
  184. struct acpi_object_list arg_list = { 4, &params[0] };
  185. struct acpi_buffer output;
  186. union acpi_object out_obj;
  187. acpi_handle handle = NULL;
  188. status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
  189. if (ACPI_FAILURE(status)) {
  190. vdbg_printk(FUJLAPTOP_DBG_ERROR,
  191. "FUNC interface is not present\n");
  192. return -ENODEV;
  193. }
  194. params[0].integer.value = cmd;
  195. params[1].integer.value = arg0;
  196. params[2].integer.value = arg1;
  197. params[3].integer.value = arg2;
  198. output.length = sizeof(out_obj);
  199. output.pointer = &out_obj;
  200. status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
  201. if (ACPI_FAILURE(status)) {
  202. vdbg_printk(FUJLAPTOP_DBG_WARN,
  203. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
  204. cmd, arg0, arg1, arg2);
  205. return -ENODEV;
  206. }
  207. if (out_obj.type != ACPI_TYPE_INTEGER) {
  208. vdbg_printk(FUJLAPTOP_DBG_WARN,
  209. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
  210. "return an integer\n",
  211. cmd, arg0, arg1, arg2);
  212. return -ENODEV;
  213. }
  214. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  215. "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
  216. cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
  217. return out_obj.integer.value;
  218. }
  219. #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_supported & 0x100))
  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_supported & 0x200))
  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_supported & 0x20))
  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_handle handle;
  546. int result = 0;
  547. int state = 0;
  548. struct input_dev *input;
  549. int error;
  550. if (!device)
  551. return -EINVAL;
  552. fujitsu->acpi_handle = device->handle;
  553. sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME);
  554. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  555. device->driver_data = fujitsu;
  556. fujitsu->input = input = input_allocate_device();
  557. if (!input) {
  558. error = -ENOMEM;
  559. goto err_stop;
  560. }
  561. snprintf(fujitsu->phys, sizeof(fujitsu->phys),
  562. "%s/video/input0", acpi_device_hid(device));
  563. input->name = acpi_device_name(device);
  564. input->phys = fujitsu->phys;
  565. input->id.bustype = BUS_HOST;
  566. input->id.product = 0x06;
  567. input->dev.parent = &device->dev;
  568. input->evbit[0] = BIT(EV_KEY);
  569. set_bit(KEY_BRIGHTNESSUP, input->keybit);
  570. set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
  571. set_bit(KEY_UNKNOWN, input->keybit);
  572. error = input_register_device(input);
  573. if (error)
  574. goto err_free_input_dev;
  575. result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
  576. if (result) {
  577. printk(KERN_ERR "Error reading power state\n");
  578. goto end;
  579. }
  580. printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
  581. acpi_device_name(device), acpi_device_bid(device),
  582. !device->power.state ? "on" : "off");
  583. fujitsu->dev = device;
  584. if (ACPI_SUCCESS
  585. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  586. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  587. if (ACPI_FAILURE
  588. (acpi_evaluate_object
  589. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  590. printk(KERN_ERR "_INI Method failed\n");
  591. }
  592. /* do config (detect defaults) */
  593. use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
  594. disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
  595. vdbg_printk(FUJLAPTOP_DBG_INFO,
  596. "config: [alt interface: %d], [adjust disable: %d]\n",
  597. use_alt_lcd_levels, disable_brightness_adjust);
  598. if (get_max_brightness() <= 0)
  599. fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
  600. get_lcd_level();
  601. return result;
  602. end:
  603. err_free_input_dev:
  604. input_free_device(input);
  605. err_stop:
  606. return result;
  607. }
  608. static int acpi_fujitsu_remove(struct acpi_device *device, int type)
  609. {
  610. struct fujitsu_t *fujitsu = NULL;
  611. if (!device || !acpi_driver_data(device))
  612. return -EINVAL;
  613. fujitsu = acpi_driver_data(device);
  614. if (!device || !acpi_driver_data(device))
  615. return -EINVAL;
  616. fujitsu->acpi_handle = NULL;
  617. return 0;
  618. }
  619. /* Brightness notify */
  620. static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
  621. {
  622. struct input_dev *input;
  623. int keycode;
  624. int oldb, newb;
  625. input = fujitsu->input;
  626. switch (event) {
  627. case ACPI_FUJITSU_NOTIFY_CODE1:
  628. keycode = 0;
  629. oldb = fujitsu->brightness_level;
  630. get_lcd_level();
  631. newb = fujitsu->brightness_level;
  632. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  633. "brightness button event [%i -> %i (%i)]\n",
  634. oldb, newb, fujitsu->brightness_changed);
  635. if (oldb < newb) {
  636. if (disable_brightness_adjust != 1) {
  637. if (use_alt_lcd_levels)
  638. set_lcd_level_alt(newb);
  639. else
  640. set_lcd_level(newb);
  641. }
  642. acpi_bus_generate_proc_event(fujitsu->dev,
  643. ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
  644. keycode = KEY_BRIGHTNESSUP;
  645. } else if (oldb > newb) {
  646. if (disable_brightness_adjust != 1) {
  647. if (use_alt_lcd_levels)
  648. set_lcd_level_alt(newb);
  649. else
  650. set_lcd_level(newb);
  651. }
  652. acpi_bus_generate_proc_event(fujitsu->dev,
  653. ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
  654. keycode = KEY_BRIGHTNESSDOWN;
  655. }
  656. break;
  657. default:
  658. keycode = KEY_UNKNOWN;
  659. vdbg_printk(FUJLAPTOP_DBG_WARN,
  660. "unsupported event [0x%x]\n", event);
  661. break;
  662. }
  663. if (keycode != 0) {
  664. input_report_key(input, keycode, 1);
  665. input_sync(input);
  666. input_report_key(input, keycode, 0);
  667. input_sync(input);
  668. }
  669. }
  670. /* ACPI device for hotkey handling */
  671. static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
  672. {
  673. acpi_handle handle;
  674. int result = 0;
  675. int state = 0;
  676. struct input_dev *input;
  677. int error;
  678. int i;
  679. if (!device)
  680. return -EINVAL;
  681. fujitsu_hotkey->acpi_handle = device->handle;
  682. sprintf(acpi_device_name(device), "%s",
  683. ACPI_FUJITSU_HOTKEY_DEVICE_NAME);
  684. sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
  685. device->driver_data = fujitsu_hotkey;
  686. /* kfifo */
  687. spin_lock_init(&fujitsu_hotkey->fifo_lock);
  688. fujitsu_hotkey->fifo =
  689. kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL,
  690. &fujitsu_hotkey->fifo_lock);
  691. if (IS_ERR(fujitsu_hotkey->fifo)) {
  692. printk(KERN_ERR "kfifo_alloc failed\n");
  693. error = PTR_ERR(fujitsu_hotkey->fifo);
  694. goto err_stop;
  695. }
  696. fujitsu_hotkey->input = input = input_allocate_device();
  697. if (!input) {
  698. error = -ENOMEM;
  699. goto err_free_fifo;
  700. }
  701. snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys),
  702. "%s/video/input0", acpi_device_hid(device));
  703. input->name = acpi_device_name(device);
  704. input->phys = fujitsu_hotkey->phys;
  705. input->id.bustype = BUS_HOST;
  706. input->id.product = 0x06;
  707. input->dev.parent = &device->dev;
  708. set_bit(EV_KEY, input->evbit);
  709. set_bit(fujitsu->keycode1, input->keybit);
  710. set_bit(fujitsu->keycode2, input->keybit);
  711. set_bit(fujitsu->keycode3, input->keybit);
  712. set_bit(fujitsu->keycode4, input->keybit);
  713. set_bit(KEY_UNKNOWN, input->keybit);
  714. error = input_register_device(input);
  715. if (error)
  716. goto err_free_input_dev;
  717. result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
  718. if (result) {
  719. printk(KERN_ERR "Error reading power state\n");
  720. goto end;
  721. }
  722. printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
  723. acpi_device_name(device), acpi_device_bid(device),
  724. !device->power.state ? "on" : "off");
  725. fujitsu_hotkey->dev = device;
  726. if (ACPI_SUCCESS
  727. (acpi_get_handle(device->handle, METHOD_NAME__INI, &handle))) {
  728. vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n");
  729. if (ACPI_FAILURE
  730. (acpi_evaluate_object
  731. (device->handle, METHOD_NAME__INI, NULL, NULL)))
  732. printk(KERN_ERR "_INI Method failed\n");
  733. }
  734. i = 0;
  735. while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0
  736. && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE)
  737. ; /* No action, result is discarded */
  738. vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
  739. fujitsu_hotkey->rfkill_supported =
  740. call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0);
  741. /* Make sure our bitmask of supported functions is cleared if the
  742. RFKILL function block is not implemented, like on the S7020. */
  743. if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD)
  744. fujitsu_hotkey->rfkill_supported = 0;
  745. if (fujitsu_hotkey->rfkill_supported)
  746. fujitsu_hotkey->rfkill_state =
  747. call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
  748. /* Suspect this is a keymap of the application panel, print it */
  749. printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
  750. call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
  751. #ifdef CONFIG_LEDS_CLASS
  752. if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
  753. result = led_classdev_register(&fujitsu->pf_device->dev,
  754. &logolamp_led);
  755. if (result == 0) {
  756. fujitsu_hotkey->logolamp_registered = 1;
  757. } else {
  758. printk(KERN_ERR "fujitsu-laptop: Could not register "
  759. "LED handler for logo lamp, error %i\n", result);
  760. }
  761. }
  762. if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
  763. (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
  764. result = led_classdev_register(&fujitsu->pf_device->dev,
  765. &kblamps_led);
  766. if (result == 0) {
  767. fujitsu_hotkey->kblamps_registered = 1;
  768. } else {
  769. printk(KERN_ERR "fujitsu-laptop: Could not register "
  770. "LED handler for keyboard lamps, error %i\n", result);
  771. }
  772. }
  773. #endif
  774. return result;
  775. end:
  776. err_free_input_dev:
  777. input_free_device(input);
  778. err_free_fifo:
  779. kfifo_free(fujitsu_hotkey->fifo);
  780. err_stop:
  781. return result;
  782. }
  783. static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
  784. {
  785. struct fujitsu_hotkey_t *fujitsu_hotkey = NULL;
  786. if (!device || !acpi_driver_data(device))
  787. return -EINVAL;
  788. fujitsu_hotkey = acpi_driver_data(device);
  789. fujitsu_hotkey->acpi_handle = NULL;
  790. kfifo_free(fujitsu_hotkey->fifo);
  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_put(fujitsu_hotkey->fifo,
  836. (unsigned char *)&keycode,
  837. sizeof(keycode));
  838. if (status != sizeof(keycode)) {
  839. vdbg_printk(FUJLAPTOP_DBG_WARN,
  840. "Could not push keycode [0x%x]\n",
  841. keycode);
  842. } else {
  843. input_report_key(input, keycode, 1);
  844. input_sync(input);
  845. }
  846. } else if (keycode == 0) {
  847. while ((status =
  848. kfifo_get
  849. (fujitsu_hotkey->fifo, (unsigned char *)
  850. &keycode_r,
  851. sizeof
  852. (keycode_r))) == sizeof(keycode_r)) {
  853. input_report_key(input, keycode_r, 0);
  854. input_sync(input);
  855. vdbg_printk(FUJLAPTOP_DBG_TRACE,
  856. "Pop keycode from ringbuffer [%d]\n",
  857. keycode_r);
  858. }
  859. }
  860. }
  861. break;
  862. default:
  863. keycode = KEY_UNKNOWN;
  864. vdbg_printk(FUJLAPTOP_DBG_WARN,
  865. "Unsupported event [0x%x]\n", event);
  866. input_report_key(input, keycode, 1);
  867. input_sync(input);
  868. input_report_key(input, keycode, 0);
  869. input_sync(input);
  870. break;
  871. }
  872. }
  873. /* Initialization */
  874. static const struct acpi_device_id fujitsu_device_ids[] = {
  875. {ACPI_FUJITSU_HID, 0},
  876. {"", 0},
  877. };
  878. static struct acpi_driver acpi_fujitsu_driver = {
  879. .name = ACPI_FUJITSU_DRIVER_NAME,
  880. .class = ACPI_FUJITSU_CLASS,
  881. .ids = fujitsu_device_ids,
  882. .ops = {
  883. .add = acpi_fujitsu_add,
  884. .remove = acpi_fujitsu_remove,
  885. .notify = acpi_fujitsu_notify,
  886. },
  887. };
  888. static const struct acpi_device_id fujitsu_hotkey_device_ids[] = {
  889. {ACPI_FUJITSU_HOTKEY_HID, 0},
  890. {"", 0},
  891. };
  892. static struct acpi_driver acpi_fujitsu_hotkey_driver = {
  893. .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME,
  894. .class = ACPI_FUJITSU_CLASS,
  895. .ids = fujitsu_hotkey_device_ids,
  896. .ops = {
  897. .add = acpi_fujitsu_hotkey_add,
  898. .remove = acpi_fujitsu_hotkey_remove,
  899. .notify = acpi_fujitsu_hotkey_notify,
  900. },
  901. };
  902. static int __init fujitsu_init(void)
  903. {
  904. int ret, result, max_brightness;
  905. if (acpi_disabled)
  906. return -ENODEV;
  907. fujitsu = kmalloc(sizeof(struct fujitsu_t), GFP_KERNEL);
  908. if (!fujitsu)
  909. return -ENOMEM;
  910. memset(fujitsu, 0, sizeof(struct fujitsu_t));
  911. fujitsu->keycode1 = KEY_PROG1;
  912. fujitsu->keycode2 = KEY_PROG2;
  913. fujitsu->keycode3 = KEY_PROG3;
  914. fujitsu->keycode4 = KEY_PROG4;
  915. dmi_check_system(fujitsu_dmi_table);
  916. result = acpi_bus_register_driver(&acpi_fujitsu_driver);
  917. if (result < 0) {
  918. ret = -ENODEV;
  919. goto fail_acpi;
  920. }
  921. /* Register platform stuff */
  922. fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1);
  923. if (!fujitsu->pf_device) {
  924. ret = -ENOMEM;
  925. goto fail_platform_driver;
  926. }
  927. ret = platform_device_add(fujitsu->pf_device);
  928. if (ret)
  929. goto fail_platform_device1;
  930. ret =
  931. sysfs_create_group(&fujitsu->pf_device->dev.kobj,
  932. &fujitsupf_attribute_group);
  933. if (ret)
  934. goto fail_platform_device2;
  935. /* Register backlight stuff */
  936. if (!acpi_video_backlight_support()) {
  937. fujitsu->bl_device =
  938. backlight_device_register("fujitsu-laptop", NULL, NULL,
  939. &fujitsubl_ops);
  940. if (IS_ERR(fujitsu->bl_device))
  941. return PTR_ERR(fujitsu->bl_device);
  942. max_brightness = fujitsu->max_brightness;
  943. fujitsu->bl_device->props.max_brightness = max_brightness - 1;
  944. fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
  945. }
  946. ret = platform_driver_register(&fujitsupf_driver);
  947. if (ret)
  948. goto fail_backlight;
  949. /* Register hotkey driver */
  950. fujitsu_hotkey = kmalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL);
  951. if (!fujitsu_hotkey) {
  952. ret = -ENOMEM;
  953. goto fail_hotkey;
  954. }
  955. memset(fujitsu_hotkey, 0, sizeof(struct fujitsu_hotkey_t));
  956. result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver);
  957. if (result < 0) {
  958. ret = -ENODEV;
  959. goto fail_hotkey1;
  960. }
  961. /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
  962. if (!acpi_video_backlight_support()) {
  963. if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
  964. fujitsu->bl_device->props.power = 4;
  965. else
  966. fujitsu->bl_device->props.power = 0;
  967. }
  968. printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION
  969. " successfully loaded.\n");
  970. return 0;
  971. fail_hotkey1:
  972. kfree(fujitsu_hotkey);
  973. fail_hotkey:
  974. platform_driver_unregister(&fujitsupf_driver);
  975. fail_backlight:
  976. if (fujitsu->bl_device)
  977. backlight_device_unregister(fujitsu->bl_device);
  978. fail_platform_device2:
  979. platform_device_del(fujitsu->pf_device);
  980. fail_platform_device1:
  981. platform_device_put(fujitsu->pf_device);
  982. fail_platform_driver:
  983. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  984. fail_acpi:
  985. kfree(fujitsu);
  986. return ret;
  987. }
  988. static void __exit fujitsu_cleanup(void)
  989. {
  990. #ifdef CONFIG_LEDS_CLASS
  991. if (fujitsu_hotkey->logolamp_registered != 0)
  992. led_classdev_unregister(&logolamp_led);
  993. if (fujitsu_hotkey->kblamps_registered != 0)
  994. led_classdev_unregister(&kblamps_led);
  995. #endif
  996. sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
  997. &fujitsupf_attribute_group);
  998. platform_device_unregister(fujitsu->pf_device);
  999. platform_driver_unregister(&fujitsupf_driver);
  1000. if (fujitsu->bl_device)
  1001. backlight_device_unregister(fujitsu->bl_device);
  1002. acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  1003. kfree(fujitsu);
  1004. acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
  1005. kfree(fujitsu_hotkey);
  1006. printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
  1007. }
  1008. module_init(fujitsu_init);
  1009. module_exit(fujitsu_cleanup);
  1010. module_param(use_alt_lcd_levels, uint, 0644);
  1011. MODULE_PARM_DESC(use_alt_lcd_levels,
  1012. "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
  1013. module_param(disable_brightness_adjust, uint, 0644);
  1014. MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
  1015. #ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
  1016. module_param_named(debug, dbg_level, uint, 0644);
  1017. MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
  1018. #endif
  1019. MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
  1020. MODULE_DESCRIPTION("Fujitsu laptop extras support");
  1021. MODULE_VERSION(FUJITSU_DRIVER_VERSION);
  1022. MODULE_LICENSE("GPL");
  1023. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
  1024. MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
  1025. MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
  1026. static struct pnp_device_id pnp_ids[] = {
  1027. {.id = "FUJ02bf"},
  1028. {.id = "FUJ02B1"},
  1029. {.id = "FUJ02E3"},
  1030. {.id = ""}
  1031. };
  1032. MODULE_DEVICE_TABLE(pnp, pnp_ids);