fujitsu-laptop.c 33 KB

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