asus_acpi.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. /*
  2. * asus_acpi.c - Asus Laptop ACPI Extras
  3. *
  4. *
  5. * Copyright (C) 2002, 2003, 2004 Julien Lerouge, Karol Kozimor
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. *
  22. * The development page for this driver is located at
  23. * http://sourceforge.net/projects/acpi4asus/
  24. *
  25. * Credits:
  26. * Pontus Fuchs - Helper functions, cleanup
  27. * Johann Wiesner - Small compile fixes
  28. * John Belmonte - ACPI code for Toshiba laptop was a good starting point.
  29. *
  30. * TODO:
  31. * add Fn key status
  32. * Add mode selection on module loading (parameter) -> still necessary?
  33. * Complete display switching -- may require dirty hacks or calling _DOS?
  34. */
  35. #include <linux/kernel.h>
  36. #include <linux/module.h>
  37. #include <linux/init.h>
  38. #include <linux/types.h>
  39. #include <linux/proc_fs.h>
  40. #include <acpi/acpi_drivers.h>
  41. #include <acpi/acpi_bus.h>
  42. #include <asm/uaccess.h>
  43. #define ASUS_ACPI_VERSION "0.29"
  44. #define PROC_ASUS "asus" //the directory
  45. #define PROC_MLED "mled"
  46. #define PROC_WLED "wled"
  47. #define PROC_TLED "tled"
  48. #define PROC_INFO "info"
  49. #define PROC_LCD "lcd"
  50. #define PROC_BRN "brn"
  51. #define PROC_DISP "disp"
  52. #define ACPI_HOTK_NAME "Asus Laptop ACPI Extras Driver"
  53. #define ACPI_HOTK_CLASS "hotkey"
  54. #define ACPI_HOTK_DEVICE_NAME "Hotkey"
  55. #define ACPI_HOTK_HID "ATK0100"
  56. /*
  57. * Some events we use, same for all Asus
  58. */
  59. #define BR_UP 0x10
  60. #define BR_DOWN 0x20
  61. /*
  62. * Flags for hotk status
  63. */
  64. #define MLED_ON 0x01 //is MLED ON ?
  65. #define WLED_ON 0x02
  66. #define TLED_ON 0x04
  67. MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
  68. MODULE_DESCRIPTION(ACPI_HOTK_NAME);
  69. MODULE_LICENSE("GPL");
  70. static uid_t asus_uid;
  71. static gid_t asus_gid;
  72. module_param(asus_uid, uint, 0);
  73. MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus.\n");
  74. module_param(asus_gid, uint, 0);
  75. MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus.\n");
  76. /* For each model, all features implemented,
  77. * those marked with R are relative to HOTK, A for absolute */
  78. struct model_data {
  79. char *name; //name of the laptop________________A
  80. char *mt_mled; //method to handle mled_____________R
  81. char *mled_status; //node to handle mled reading_______A
  82. char *mt_wled; //method to handle wled_____________R
  83. char *wled_status; //node to handle wled reading_______A
  84. char *mt_tled; //method to handle tled_____________R
  85. char *tled_status; //node to handle tled reading_______A
  86. char *mt_lcd_switch; //method to turn LCD ON/OFF_________A
  87. char *lcd_status; //node to read LCD panel state______A
  88. char *brightness_up; //method to set brightness up_______A
  89. char *brightness_down; //guess what ?______________________A
  90. char *brightness_set; //method to set absolute brightness_R
  91. char *brightness_get; //method to get absolute brightness_R
  92. char *brightness_status; //node to get brightness____________A
  93. char *display_set; //method to set video output________R
  94. char *display_get; //method to get video output________R
  95. };
  96. /*
  97. * This is the main structure, we can use it to store anything interesting
  98. * about the hotk device
  99. */
  100. struct asus_hotk {
  101. struct acpi_device *device; //the device we are in
  102. acpi_handle handle; //the handle of the hotk device
  103. char status; //status of the hotk, for LEDs, ...
  104. struct model_data *methods; //methods available on the laptop
  105. u8 brightness; //brightness level
  106. enum {
  107. A1x = 0, //A1340D, A1300F
  108. A2x, //A2500H
  109. D1x, //D1
  110. L2D, //L2000D
  111. L3C, //L3800C
  112. L3D, //L3400D
  113. L3H, //L3H, but also L2000E
  114. L4R, //L4500R
  115. L5x, //L5800C
  116. L8L, //L8400L
  117. M1A, //M1300A
  118. M2E, //M2400E, L4400L
  119. M6N, //M6800N
  120. M6R, //M6700R
  121. P30, //Samsung P30
  122. S1x, //S1300A, but also L1400B and M2400A (L84F)
  123. S2x, //S200 (J1 reported), Victor MP-XP7210
  124. xxN, //M2400N, M3700N, M5200N, S1300N, S5200N, W1OOON
  125. //(Centrino)
  126. END_MODEL
  127. } model; //Models currently supported
  128. u16 event_count[128]; //count for each event TODO make this better
  129. };
  130. /* Here we go */
  131. #define A1x_PREFIX "\\_SB.PCI0.ISA.EC0."
  132. #define L3C_PREFIX "\\_SB.PCI0.PX40.ECD0."
  133. #define M1A_PREFIX "\\_SB.PCI0.PX40.EC0."
  134. #define P30_PREFIX "\\_SB.PCI0.LPCB.EC0."
  135. #define S1x_PREFIX "\\_SB.PCI0.PX40."
  136. #define S2x_PREFIX A1x_PREFIX
  137. #define xxN_PREFIX "\\_SB.PCI0.SBRG.EC0."
  138. static struct model_data model_conf[END_MODEL] = {
  139. /*
  140. * Those pathnames are relative to the HOTK / ATKD device :
  141. * - mt_mled
  142. * - mt_wled
  143. * - brightness_set
  144. * - brightness_get
  145. * - display_set
  146. * - display_get
  147. *
  148. * TODO I have seen a SWBX and AIBX method on some models, like L1400B,
  149. * it seems to be a kind of switch, but what for ?
  150. *
  151. */
  152. {
  153. .name = "A1x",
  154. .mt_mled = "MLED",
  155. .mled_status = "\\MAIL",
  156. .mt_lcd_switch = A1x_PREFIX "_Q10",
  157. .lcd_status = "\\BKLI",
  158. .brightness_up = A1x_PREFIX "_Q0E",
  159. .brightness_down = A1x_PREFIX "_Q0F"},
  160. {
  161. .name = "A2x",
  162. .mt_mled = "MLED",
  163. .mt_wled = "WLED",
  164. .wled_status = "\\SG66",
  165. .mt_lcd_switch = "\\Q10",
  166. .lcd_status = "\\BAOF",
  167. .brightness_set = "SPLV",
  168. .brightness_get = "GPLV",
  169. .display_set = "SDSP",
  170. .display_get = "\\INFB"},
  171. {
  172. .name = "D1x",
  173. .mt_mled = "MLED",
  174. .mt_lcd_switch = "\\Q0D",
  175. .lcd_status = "\\GP11",
  176. .brightness_up = "\\Q0C",
  177. .brightness_down = "\\Q0B",
  178. .brightness_status = "\\BLVL",
  179. .display_set = "SDSP",
  180. .display_get = "\\INFB"},
  181. {
  182. .name = "L2D",
  183. .mt_mled = "MLED",
  184. .mled_status = "\\SGP6",
  185. .mt_wled = "WLED",
  186. .wled_status = "\\RCP3",
  187. .mt_lcd_switch = "\\Q10",
  188. .lcd_status = "\\SGP0",
  189. .brightness_up = "\\Q0E",
  190. .brightness_down = "\\Q0F",
  191. .display_set = "SDSP",
  192. .display_get = "\\INFB"},
  193. {
  194. .name = "L3C",
  195. .mt_mled = "MLED",
  196. .mt_wled = "WLED",
  197. .mt_lcd_switch = L3C_PREFIX "_Q10",
  198. .lcd_status = "\\GL32",
  199. .brightness_set = "SPLV",
  200. .brightness_get = "GPLV",
  201. .display_set = "SDSP",
  202. .display_get = "\\_SB.PCI0.PCI1.VGAC.NMAP"},
  203. {
  204. .name = "L3D",
  205. .mt_mled = "MLED",
  206. .mled_status = "\\MALD",
  207. .mt_wled = "WLED",
  208. .mt_lcd_switch = "\\Q10",
  209. .lcd_status = "\\BKLG",
  210. .brightness_set = "SPLV",
  211. .brightness_get = "GPLV",
  212. .display_set = "SDSP",
  213. .display_get = "\\INFB"},
  214. {
  215. .name = "L3H",
  216. .mt_mled = "MLED",
  217. .mt_wled = "WLED",
  218. .mt_lcd_switch = "EHK",
  219. .lcd_status = "\\_SB.PCI0.PM.PBC",
  220. .brightness_set = "SPLV",
  221. .brightness_get = "GPLV",
  222. .display_set = "SDSP",
  223. .display_get = "\\INFB"},
  224. {
  225. .name = "L4R",
  226. .mt_mled = "MLED",
  227. .mt_wled = "WLED",
  228. .wled_status = "\\_SB.PCI0.SBRG.SG13",
  229. .mt_lcd_switch = xxN_PREFIX "_Q10",
  230. .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
  231. .brightness_set = "SPLV",
  232. .brightness_get = "GPLV",
  233. .display_set = "SDSP",
  234. .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
  235. {
  236. .name = "L5x",
  237. .mt_mled = "MLED",
  238. /* WLED present, but not controlled by ACPI */
  239. .mt_tled = "TLED",
  240. .mt_lcd_switch = "\\Q0D",
  241. .lcd_status = "\\BAOF",
  242. .brightness_set = "SPLV",
  243. .brightness_get = "GPLV",
  244. .display_set = "SDSP",
  245. .display_get = "\\INFB"},
  246. {
  247. .name = "L8L"
  248. /* No features, but at least support the hotkeys */
  249. },
  250. {
  251. .name = "M1A",
  252. .mt_mled = "MLED",
  253. .mt_lcd_switch = M1A_PREFIX "Q10",
  254. .lcd_status = "\\PNOF",
  255. .brightness_up = M1A_PREFIX "Q0E",
  256. .brightness_down = M1A_PREFIX "Q0F",
  257. .brightness_status = "\\BRIT",
  258. .display_set = "SDSP",
  259. .display_get = "\\INFB"},
  260. {
  261. .name = "M2E",
  262. .mt_mled = "MLED",
  263. .mt_wled = "WLED",
  264. .mt_lcd_switch = "\\Q10",
  265. .lcd_status = "\\GP06",
  266. .brightness_set = "SPLV",
  267. .brightness_get = "GPLV",
  268. .display_set = "SDSP",
  269. .display_get = "\\INFB"},
  270. {
  271. .name = "M6N",
  272. .mt_mled = "MLED",
  273. .mt_wled = "WLED",
  274. .wled_status = "\\_SB.PCI0.SBRG.SG13",
  275. .mt_lcd_switch = xxN_PREFIX "_Q10",
  276. .lcd_status = "\\_SB.BKLT",
  277. .brightness_set = "SPLV",
  278. .brightness_get = "GPLV",
  279. .display_set = "SDSP",
  280. .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
  281. {
  282. .name = "M6R",
  283. .mt_mled = "MLED",
  284. .mt_wled = "WLED",
  285. .mt_lcd_switch = xxN_PREFIX "_Q10",
  286. .lcd_status = "\\_SB.PCI0.SBSM.SEO4",
  287. .brightness_set = "SPLV",
  288. .brightness_get = "GPLV",
  289. .display_set = "SDSP",
  290. .display_get = "\\SSTE"},
  291. {
  292. .name = "P30",
  293. .mt_wled = "WLED",
  294. .mt_lcd_switch = P30_PREFIX "_Q0E",
  295. .lcd_status = "\\BKLT",
  296. .brightness_up = P30_PREFIX "_Q68",
  297. .brightness_down = P30_PREFIX "_Q69",
  298. .brightness_get = "GPLV",
  299. .display_set = "SDSP",
  300. .display_get = "\\DNXT"},
  301. {
  302. .name = "S1x",
  303. .mt_mled = "MLED",
  304. .mled_status = "\\EMLE",
  305. .mt_wled = "WLED",
  306. .mt_lcd_switch = S1x_PREFIX "Q10",
  307. .lcd_status = "\\PNOF",
  308. .brightness_set = "SPLV",
  309. .brightness_get = "GPLV"},
  310. {
  311. .name = "S2x",
  312. .mt_mled = "MLED",
  313. .mled_status = "\\MAIL",
  314. .mt_lcd_switch = S2x_PREFIX "_Q10",
  315. .lcd_status = "\\BKLI",
  316. .brightness_up = S2x_PREFIX "_Q0B",
  317. .brightness_down = S2x_PREFIX "_Q0A"},
  318. {
  319. .name = "xxN",
  320. .mt_mled = "MLED",
  321. /* WLED present, but not controlled by ACPI */
  322. .mt_lcd_switch = xxN_PREFIX "_Q10",
  323. .lcd_status = "\\BKLT",
  324. .brightness_set = "SPLV",
  325. .brightness_get = "GPLV",
  326. .display_set = "SDSP",
  327. .display_get = "\\ADVG"}
  328. };
  329. /* procdir we use */
  330. static struct proc_dir_entry *asus_proc_dir;
  331. /*
  332. * This header is made available to allow proper configuration given model,
  333. * revision number , ... this info cannot go in struct asus_hotk because it is
  334. * available before the hotk
  335. */
  336. static struct acpi_table_header *asus_info;
  337. /* The actual device the driver binds to */
  338. static struct asus_hotk *hotk;
  339. /*
  340. * The hotkey driver declaration
  341. */
  342. static int asus_hotk_add(struct acpi_device *device);
  343. static int asus_hotk_remove(struct acpi_device *device, int type);
  344. static struct acpi_driver asus_hotk_driver = {
  345. .name = ACPI_HOTK_NAME,
  346. .class = ACPI_HOTK_CLASS,
  347. .ids = ACPI_HOTK_HID,
  348. .ops = {
  349. .add = asus_hotk_add,
  350. .remove = asus_hotk_remove,
  351. },
  352. };
  353. /*
  354. * This function evaluates an ACPI method, given an int as parameter, the
  355. * method is searched within the scope of the handle, can be NULL. The output
  356. * of the method is written is output, which can also be NULL
  357. *
  358. * returns 1 if write is successful, 0 else.
  359. */
  360. static int write_acpi_int(acpi_handle handle, const char *method, int val,
  361. struct acpi_buffer *output)
  362. {
  363. struct acpi_object_list params; //list of input parameters (an int here)
  364. union acpi_object in_obj; //the only param we use
  365. acpi_status status;
  366. params.count = 1;
  367. params.pointer = &in_obj;
  368. in_obj.type = ACPI_TYPE_INTEGER;
  369. in_obj.integer.value = val;
  370. status = acpi_evaluate_object(handle, (char *)method, &params, output);
  371. return (status == AE_OK);
  372. }
  373. static int read_acpi_int(acpi_handle handle, const char *method, int *val)
  374. {
  375. struct acpi_buffer output;
  376. union acpi_object out_obj;
  377. acpi_status status;
  378. output.length = sizeof(out_obj);
  379. output.pointer = &out_obj;
  380. status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
  381. *val = out_obj.integer.value;
  382. return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
  383. }
  384. /*
  385. * We write our info in page, we begin at offset off and cannot write more
  386. * than count bytes. We set eof to 1 if we handle those 2 values. We return the
  387. * number of bytes written in page
  388. */
  389. static int
  390. proc_read_info(char *page, char **start, off_t off, int count, int *eof,
  391. void *data)
  392. {
  393. int len = 0;
  394. int temp;
  395. char buf[16]; //enough for all info
  396. /*
  397. * We use the easy way, we don't care of off and count, so we don't set eof
  398. * to 1
  399. */
  400. len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
  401. len += sprintf(page + len, "Model reference : %s\n",
  402. hotk->methods->name);
  403. /*
  404. * The SFUN method probably allows the original driver to get the list
  405. * of features supported by a given model. For now, 0x0100 or 0x0800
  406. * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
  407. * The significance of others is yet to be found.
  408. */
  409. if (read_acpi_int(hotk->handle, "SFUN", &temp))
  410. len +=
  411. sprintf(page + len, "SFUN value : 0x%04x\n", temp);
  412. /*
  413. * Another value for userspace: the ASYM method returns 0x02 for
  414. * battery low and 0x04 for battery critical, its readings tend to be
  415. * more accurate than those provided by _BST.
  416. * Note: since not all the laptops provide this method, errors are
  417. * silently ignored.
  418. */
  419. if (read_acpi_int(hotk->handle, "ASYM", &temp))
  420. len +=
  421. sprintf(page + len, "ASYM value : 0x%04x\n", temp);
  422. if (asus_info) {
  423. snprintf(buf, 16, "%d", asus_info->length);
  424. len += sprintf(page + len, "DSDT length : %s\n", buf);
  425. snprintf(buf, 16, "%d", asus_info->checksum);
  426. len += sprintf(page + len, "DSDT checksum : %s\n", buf);
  427. snprintf(buf, 16, "%d", asus_info->revision);
  428. len += sprintf(page + len, "DSDT revision : %s\n", buf);
  429. snprintf(buf, 7, "%s", asus_info->oem_id);
  430. len += sprintf(page + len, "OEM id : %s\n", buf);
  431. snprintf(buf, 9, "%s", asus_info->oem_table_id);
  432. len += sprintf(page + len, "OEM table id : %s\n", buf);
  433. snprintf(buf, 16, "%x", asus_info->oem_revision);
  434. len += sprintf(page + len, "OEM revision : 0x%s\n", buf);
  435. snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
  436. len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
  437. snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
  438. len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf);
  439. }
  440. return len;
  441. }
  442. /*
  443. * /proc handlers
  444. * We write our info in page, we begin at offset off and cannot write more
  445. * than count bytes. We set eof to 1 if we handle those 2 values. We return the
  446. * number of bytes written in page
  447. */
  448. /* Generic LED functions */
  449. static int read_led(const char *ledname, int ledmask)
  450. {
  451. if (ledname) {
  452. int led_status;
  453. if (read_acpi_int(NULL, ledname, &led_status))
  454. return led_status;
  455. else
  456. printk(KERN_WARNING "Asus ACPI: Error reading LED "
  457. "status\n");
  458. }
  459. return (hotk->status & ledmask) ? 1 : 0;
  460. }
  461. static int parse_arg(const char __user * buf, unsigned long count, int *val)
  462. {
  463. char s[32];
  464. if (!count)
  465. return 0;
  466. if (count > 31)
  467. return -EINVAL;
  468. if (copy_from_user(s, buf, count))
  469. return -EFAULT;
  470. s[count] = 0;
  471. if (sscanf(s, "%i", val) != 1)
  472. return -EINVAL;
  473. return count;
  474. }
  475. /* FIXME: kill extraneous args so it can be called independently */
  476. static int
  477. write_led(const char __user * buffer, unsigned long count,
  478. char *ledname, int ledmask, int invert)
  479. {
  480. int value;
  481. int led_out = 0;
  482. count = parse_arg(buffer, count, &value);
  483. if (count > 0)
  484. led_out = value ? 1 : 0;
  485. hotk->status =
  486. (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
  487. if (invert) /* invert target value */
  488. led_out = !led_out & 0x1;
  489. if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
  490. printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
  491. ledname);
  492. return count;
  493. }
  494. /*
  495. * Proc handlers for MLED
  496. */
  497. static int
  498. proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
  499. void *data)
  500. {
  501. return sprintf(page, "%d\n",
  502. read_led(hotk->methods->mled_status, MLED_ON));
  503. }
  504. static int
  505. proc_write_mled(struct file *file, const char __user * buffer,
  506. unsigned long count, void *data)
  507. {
  508. return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
  509. }
  510. /*
  511. * Proc handlers for WLED
  512. */
  513. static int
  514. proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
  515. void *data)
  516. {
  517. return sprintf(page, "%d\n",
  518. read_led(hotk->methods->wled_status, WLED_ON));
  519. }
  520. static int
  521. proc_write_wled(struct file *file, const char __user * buffer,
  522. unsigned long count, void *data)
  523. {
  524. return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
  525. }
  526. /*
  527. * Proc handlers for TLED
  528. */
  529. static int
  530. proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
  531. void *data)
  532. {
  533. return sprintf(page, "%d\n",
  534. read_led(hotk->methods->tled_status, TLED_ON));
  535. }
  536. static int
  537. proc_write_tled(struct file *file, const char __user * buffer,
  538. unsigned long count, void *data)
  539. {
  540. return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
  541. }
  542. static int get_lcd_state(void)
  543. {
  544. int lcd = 0;
  545. if (hotk->model != L3H) {
  546. /* We don't have to check anything if we are here */
  547. if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
  548. printk(KERN_WARNING
  549. "Asus ACPI: Error reading LCD status\n");
  550. if (hotk->model == L2D)
  551. lcd = ~lcd;
  552. } else { /* L3H and the like have to be handled differently */
  553. acpi_status status = 0;
  554. struct acpi_object_list input;
  555. union acpi_object mt_params[2];
  556. struct acpi_buffer output;
  557. union acpi_object out_obj;
  558. input.count = 2;
  559. input.pointer = mt_params;
  560. /* Note: the following values are partly guessed up, but
  561. otherwise they seem to work */
  562. mt_params[0].type = ACPI_TYPE_INTEGER;
  563. mt_params[0].integer.value = 0x02;
  564. mt_params[1].type = ACPI_TYPE_INTEGER;
  565. mt_params[1].integer.value = 0x02;
  566. output.length = sizeof(out_obj);
  567. output.pointer = &out_obj;
  568. status =
  569. acpi_evaluate_object(NULL, hotk->methods->lcd_status,
  570. &input, &output);
  571. if (status != AE_OK)
  572. return -1;
  573. if (out_obj.type == ACPI_TYPE_INTEGER)
  574. /* That's what the AML code does */
  575. lcd = out_obj.integer.value >> 8;
  576. }
  577. return (lcd & 1);
  578. }
  579. static int set_lcd_state(int value)
  580. {
  581. int lcd = 0;
  582. acpi_status status = 0;
  583. lcd = value ? 1 : 0;
  584. if (lcd != get_lcd_state()) {
  585. /* switch */
  586. if (hotk->model != L3H) {
  587. status =
  588. acpi_evaluate_object(NULL,
  589. hotk->methods->mt_lcd_switch,
  590. NULL, NULL);
  591. } else { /* L3H and the like have to be handled differently */
  592. if (!write_acpi_int
  593. (hotk->handle, hotk->methods->mt_lcd_switch, 0x07,
  594. NULL))
  595. status = AE_ERROR;
  596. /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress,
  597. the exact behaviour is simulated here */
  598. }
  599. if (ACPI_FAILURE(status))
  600. printk(KERN_WARNING "Asus ACPI: Error switching LCD\n");
  601. }
  602. return 0;
  603. }
  604. static int
  605. proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
  606. void *data)
  607. {
  608. return sprintf(page, "%d\n", get_lcd_state());
  609. }
  610. static int
  611. proc_write_lcd(struct file *file, const char __user * buffer,
  612. unsigned long count, void *data)
  613. {
  614. int value;
  615. count = parse_arg(buffer, count, &value);
  616. if (count > 0)
  617. set_lcd_state(value);
  618. return count;
  619. }
  620. static int read_brightness(void)
  621. {
  622. int value;
  623. if (hotk->methods->brightness_get) { /* SPLV/GPLV laptop */
  624. if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get,
  625. &value))
  626. printk(KERN_WARNING
  627. "Asus ACPI: Error reading brightness\n");
  628. } else if (hotk->methods->brightness_status) { /* For D1 for example */
  629. if (!read_acpi_int(NULL, hotk->methods->brightness_status,
  630. &value))
  631. printk(KERN_WARNING
  632. "Asus ACPI: Error reading brightness\n");
  633. } else /* No GPLV method */
  634. value = hotk->brightness;
  635. return value;
  636. }
  637. /*
  638. * Change the brightness level
  639. */
  640. static void set_brightness(int value)
  641. {
  642. acpi_status status = 0;
  643. /* SPLV laptop */
  644. if (hotk->methods->brightness_set) {
  645. if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set,
  646. value, NULL))
  647. printk(KERN_WARNING
  648. "Asus ACPI: Error changing brightness\n");
  649. return;
  650. }
  651. /* No SPLV method if we are here, act as appropriate */
  652. value -= read_brightness();
  653. while (value != 0) {
  654. status = acpi_evaluate_object(NULL, (value > 0) ?
  655. hotk->methods->brightness_up :
  656. hotk->methods->brightness_down,
  657. NULL, NULL);
  658. (value > 0) ? value-- : value++;
  659. if (ACPI_FAILURE(status))
  660. printk(KERN_WARNING
  661. "Asus ACPI: Error changing brightness\n");
  662. }
  663. return;
  664. }
  665. static int
  666. proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
  667. void *data)
  668. {
  669. return sprintf(page, "%d\n", read_brightness());
  670. }
  671. static int
  672. proc_write_brn(struct file *file, const char __user * buffer,
  673. unsigned long count, void *data)
  674. {
  675. int value;
  676. count = parse_arg(buffer, count, &value);
  677. if (count > 0) {
  678. value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
  679. /* 0 <= value <= 15 */
  680. set_brightness(value);
  681. } else if (count < 0) {
  682. printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
  683. }
  684. return count;
  685. }
  686. static void set_display(int value)
  687. {
  688. /* no sanity check needed for now */
  689. if (!write_acpi_int(hotk->handle, hotk->methods->display_set,
  690. value, NULL))
  691. printk(KERN_WARNING "Asus ACPI: Error setting display\n");
  692. return;
  693. }
  694. /*
  695. * Now, *this* one could be more user-friendly, but so far, no-one has
  696. * complained. The significance of bits is the same as in proc_write_disp()
  697. */
  698. static int
  699. proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
  700. void *data)
  701. {
  702. int value = 0;
  703. if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
  704. printk(KERN_WARNING
  705. "Asus ACPI: Error reading display status\n");
  706. value &= 0x07; /* needed for some models, shouldn't hurt others */
  707. return sprintf(page, "%d\n", value);
  708. }
  709. /*
  710. * Experimental support for display switching. As of now: 1 should activate
  711. * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination
  712. * (bitwise) of these will suffice. I never actually tested 3 displays hooked up
  713. * simultaneously, so be warned. See the acpi4asus README for more info.
  714. */
  715. static int
  716. proc_write_disp(struct file *file, const char __user * buffer,
  717. unsigned long count, void *data)
  718. {
  719. int value;
  720. count = parse_arg(buffer, count, &value);
  721. if (count > 0)
  722. set_display(value);
  723. else if (count < 0)
  724. printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
  725. return count;
  726. }
  727. typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
  728. int *eof, void *data);
  729. typedef int (proc_writefunc) (struct file * file, const char __user * buffer,
  730. unsigned long count, void *data);
  731. static int
  732. __init asus_proc_add(char *name, proc_writefunc * writefunc,
  733. proc_readfunc * readfunc, mode_t mode,
  734. struct acpi_device *device)
  735. {
  736. struct proc_dir_entry *proc =
  737. create_proc_entry(name, mode, acpi_device_dir(device));
  738. if (!proc) {
  739. printk(KERN_WARNING " Unable to create %s fs entry\n", name);
  740. return -1;
  741. }
  742. proc->write_proc = writefunc;
  743. proc->read_proc = readfunc;
  744. proc->data = acpi_driver_data(device);
  745. proc->owner = THIS_MODULE;
  746. proc->uid = asus_uid;
  747. proc->gid = asus_gid;
  748. return 0;
  749. }
  750. static int __init asus_hotk_add_fs(struct acpi_device *device)
  751. {
  752. struct proc_dir_entry *proc;
  753. mode_t mode;
  754. /*
  755. * If parameter uid or gid is not changed, keep the default setting for
  756. * our proc entries (-rw-rw-rw-) else, it means we care about security,
  757. * and then set to -rw-rw----
  758. */
  759. if ((asus_uid == 0) && (asus_gid == 0)) {
  760. mode = S_IFREG | S_IRUGO | S_IWUGO;
  761. } else {
  762. mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
  763. printk(KERN_WARNING " asus_uid and asus_gid parameters are "
  764. "deprecated, use chown and chmod instead!\n");
  765. }
  766. acpi_device_dir(device) = asus_proc_dir;
  767. if (!acpi_device_dir(device))
  768. return -ENODEV;
  769. proc = create_proc_entry(PROC_INFO, mode, acpi_device_dir(device));
  770. if (proc) {
  771. proc->read_proc = proc_read_info;
  772. proc->data = acpi_driver_data(device);
  773. proc->owner = THIS_MODULE;
  774. proc->uid = asus_uid;
  775. proc->gid = asus_gid;
  776. } else {
  777. printk(KERN_WARNING " Unable to create " PROC_INFO
  778. " fs entry\n");
  779. }
  780. if (hotk->methods->mt_wled) {
  781. asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled,
  782. mode, device);
  783. }
  784. if (hotk->methods->mt_mled) {
  785. asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled,
  786. mode, device);
  787. }
  788. if (hotk->methods->mt_tled) {
  789. asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled,
  790. mode, device);
  791. }
  792. /*
  793. * We need both read node and write method as LCD switch is also accessible
  794. * from keyboard
  795. */
  796. if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
  797. asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode,
  798. device);
  799. }
  800. if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
  801. (hotk->methods->brightness_get && hotk->methods->brightness_set)) {
  802. asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode,
  803. device);
  804. }
  805. if (hotk->methods->display_set) {
  806. asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp,
  807. mode, device);
  808. }
  809. return 0;
  810. }
  811. static int asus_hotk_remove_fs(struct acpi_device *device)
  812. {
  813. if (acpi_device_dir(device)) {
  814. remove_proc_entry(PROC_INFO, acpi_device_dir(device));
  815. if (hotk->methods->mt_wled)
  816. remove_proc_entry(PROC_WLED, acpi_device_dir(device));
  817. if (hotk->methods->mt_mled)
  818. remove_proc_entry(PROC_MLED, acpi_device_dir(device));
  819. if (hotk->methods->mt_tled)
  820. remove_proc_entry(PROC_TLED, acpi_device_dir(device));
  821. if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status)
  822. remove_proc_entry(PROC_LCD, acpi_device_dir(device));
  823. if ((hotk->methods->brightness_up
  824. && hotk->methods->brightness_down)
  825. || (hotk->methods->brightness_get
  826. && hotk->methods->brightness_set))
  827. remove_proc_entry(PROC_BRN, acpi_device_dir(device));
  828. if (hotk->methods->display_set)
  829. remove_proc_entry(PROC_DISP, acpi_device_dir(device));
  830. }
  831. return 0;
  832. }
  833. static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
  834. {
  835. /* TODO Find a better way to handle events count. */
  836. if (!hotk)
  837. return;
  838. if ((event & ~((u32) BR_UP)) < 16) {
  839. hotk->brightness = (event & ~((u32) BR_UP));
  840. } else if ((event & ~((u32) BR_DOWN)) < 16) {
  841. hotk->brightness = (event & ~((u32) BR_DOWN));
  842. }
  843. acpi_bus_generate_event(hotk->device, event,
  844. hotk->event_count[event % 128]++);
  845. return;
  846. }
  847. /*
  848. * This function is used to initialize the hotk with right values. In this
  849. * method, we can make all the detection we want, and modify the hotk struct
  850. */
  851. static int __init asus_hotk_get_info(void)
  852. {
  853. struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  854. struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
  855. union acpi_object *model = NULL;
  856. int bsts_result;
  857. acpi_status status;
  858. /*
  859. * Get DSDT headers early enough to allow for differentiating between
  860. * models, but late enough to allow acpi_bus_register_driver() to fail
  861. * before doing anything ACPI-specific. Should we encounter a machine,
  862. * which needs special handling (i.e. its hotkey device has a different
  863. * HID), this bit will be moved. A global variable asus_info contains
  864. * the DSDT header.
  865. */
  866. status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt);
  867. if (ACPI_FAILURE(status))
  868. printk(KERN_WARNING " Couldn't get the DSDT table header\n");
  869. else
  870. asus_info = (struct acpi_table_header *)dsdt.pointer;
  871. /* We have to write 0 on init this far for all ASUS models */
  872. if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
  873. printk(KERN_ERR " Hotkey initialization failed\n");
  874. return -ENODEV;
  875. }
  876. /* This needs to be called for some laptops to init properly */
  877. if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result))
  878. printk(KERN_WARNING " Error calling BSTS\n");
  879. else if (bsts_result)
  880. printk(KERN_NOTICE " BSTS called, 0x%02x returned\n",
  881. bsts_result);
  882. /* This is unlikely with implicit return */
  883. if (buffer.pointer == NULL)
  884. return -EINVAL;
  885. model = (union acpi_object *) buffer.pointer;
  886. /*
  887. * Samsung P30 has a device with a valid _HID whose INIT does not
  888. * return anything. It used to be possible to catch this exception,
  889. * but the implicit return code will now happily confuse the
  890. * driver. We assume that every ACPI_TYPE_STRING is a valid model
  891. * identifier but it's still possible to get completely bogus data.
  892. */
  893. if (model->type == ACPI_TYPE_STRING) {
  894. printk(KERN_NOTICE " %s model detected, ", model->string.pointer);
  895. } else {
  896. if (asus_info && /* Samsung P30 */
  897. strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
  898. hotk->model = P30;
  899. printk(KERN_NOTICE
  900. " Samsung P30 detected, supported\n");
  901. } else {
  902. hotk->model = M2E;
  903. printk(KERN_WARNING " no string returned by INIT\n");
  904. printk(KERN_WARNING " trying default values, supply "
  905. "the developers with your DSDT\n");
  906. }
  907. hotk->methods = &model_conf[hotk->model];
  908. acpi_os_free(model);
  909. return AE_OK;
  910. }
  911. hotk->model = END_MODEL;
  912. if (strncmp(model->string.pointer, "L3D", 3) == 0)
  913. hotk->model = L3D;
  914. else if (strncmp(model->string.pointer, "L3H", 3) == 0 ||
  915. strncmp(model->string.pointer, "L2E", 3) == 0)
  916. hotk->model = L3H;
  917. else if (strncmp(model->string.pointer, "L3", 2) == 0 ||
  918. strncmp(model->string.pointer, "L2B", 3) == 0)
  919. hotk->model = L3C;
  920. else if (strncmp(model->string.pointer, "L8L", 3) == 0)
  921. hotk->model = L8L;
  922. else if (strncmp(model->string.pointer, "L4R", 3) == 0)
  923. hotk->model = L4R;
  924. else if (strncmp(model->string.pointer, "M6N", 3) == 0)
  925. hotk->model = M6N;
  926. else if (strncmp(model->string.pointer, "M6R", 3) == 0)
  927. hotk->model = M6R;
  928. else if (strncmp(model->string.pointer, "M2N", 3) == 0 ||
  929. strncmp(model->string.pointer, "M3N", 3) == 0 ||
  930. strncmp(model->string.pointer, "M5N", 3) == 0 ||
  931. strncmp(model->string.pointer, "M6N", 3) == 0 ||
  932. strncmp(model->string.pointer, "S1N", 3) == 0 ||
  933. strncmp(model->string.pointer, "S5N", 3) == 0 ||
  934. strncmp(model->string.pointer, "W1N", 3) == 0)
  935. hotk->model = xxN;
  936. else if (strncmp(model->string.pointer, "M1", 2) == 0)
  937. hotk->model = M1A;
  938. else if (strncmp(model->string.pointer, "M2", 2) == 0 ||
  939. strncmp(model->string.pointer, "L4E", 3) == 0)
  940. hotk->model = M2E;
  941. else if (strncmp(model->string.pointer, "L2", 2) == 0)
  942. hotk->model = L2D;
  943. else if (strncmp(model->string.pointer, "L8", 2) == 0)
  944. hotk->model = S1x;
  945. else if (strncmp(model->string.pointer, "D1", 2) == 0)
  946. hotk->model = D1x;
  947. else if (strncmp(model->string.pointer, "A1", 2) == 0)
  948. hotk->model = A1x;
  949. else if (strncmp(model->string.pointer, "A2", 2) == 0)
  950. hotk->model = A2x;
  951. else if (strncmp(model->string.pointer, "J1", 2) == 0)
  952. hotk->model = S2x;
  953. else if (strncmp(model->string.pointer, "L5", 2) == 0)
  954. hotk->model = L5x;
  955. if (hotk->model == END_MODEL) {
  956. printk("unsupported, trying default values, supply the "
  957. "developers with your DSDT\n");
  958. hotk->model = M2E;
  959. } else {
  960. printk("supported\n");
  961. }
  962. hotk->methods = &model_conf[hotk->model];
  963. /* Sort of per-model blacklist */
  964. if (strncmp(model->string.pointer, "L2B", 3) == 0)
  965. hotk->methods->lcd_status = NULL;
  966. /* L2B is similar enough to L3C to use its settings, with this only
  967. exception */
  968. else if (strncmp(model->string.pointer, "S5N", 3) == 0 ||
  969. strncmp(model->string.pointer, "M5N", 3) == 0)
  970. hotk->methods->mt_mled = NULL;
  971. /* S5N and M5N have no MLED */
  972. else if (strncmp(model->string.pointer, "M2N", 3) == 0 ||
  973. strncmp(model->string.pointer, "W1N", 3) == 0)
  974. hotk->methods->mt_wled = "WLED";
  975. /* M2N and W1N have a usable WLED */
  976. else if (asus_info) {
  977. if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
  978. hotk->methods->mled_status = NULL;
  979. /* S1300A reports L84F, but L1400B too, account for that */
  980. }
  981. acpi_os_free(model);
  982. return AE_OK;
  983. }
  984. static int __init asus_hotk_check(void)
  985. {
  986. int result = 0;
  987. result = acpi_bus_get_status(hotk->device);
  988. if (result)
  989. return result;
  990. if (hotk->device->status.present) {
  991. result = asus_hotk_get_info();
  992. } else {
  993. printk(KERN_ERR " Hotkey device not present, aborting\n");
  994. return -EINVAL;
  995. }
  996. return result;
  997. }
  998. static int __init asus_hotk_add(struct acpi_device *device)
  999. {
  1000. acpi_status status = AE_OK;
  1001. int result;
  1002. if (!device)
  1003. return -EINVAL;
  1004. printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
  1005. ASUS_ACPI_VERSION);
  1006. hotk =
  1007. (struct asus_hotk *)kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
  1008. if (!hotk)
  1009. return -ENOMEM;
  1010. memset(hotk, 0, sizeof(struct asus_hotk));
  1011. hotk->handle = device->handle;
  1012. strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
  1013. strcpy(acpi_device_class(device), ACPI_HOTK_CLASS);
  1014. acpi_driver_data(device) = hotk;
  1015. hotk->device = device;
  1016. result = asus_hotk_check();
  1017. if (result)
  1018. goto end;
  1019. result = asus_hotk_add_fs(device);
  1020. if (result)
  1021. goto end;
  1022. /*
  1023. * We install the handler, it will receive the hotk in parameter, so, we
  1024. * could add other data to the hotk struct
  1025. */
  1026. status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
  1027. asus_hotk_notify, hotk);
  1028. if (ACPI_FAILURE(status))
  1029. printk(KERN_ERR " Error installing notify handler\n");
  1030. /* For laptops without GPLV: init the hotk->brightness value */
  1031. if ((!hotk->methods->brightness_get)
  1032. && (!hotk->methods->brightness_status)
  1033. && (hotk->methods->brightness_up
  1034. && hotk->methods->brightness_down)) {
  1035. status =
  1036. acpi_evaluate_object(NULL, hotk->methods->brightness_down,
  1037. NULL, NULL);
  1038. if (ACPI_FAILURE(status))
  1039. printk(KERN_WARNING " Error changing brightness\n");
  1040. else {
  1041. status =
  1042. acpi_evaluate_object(NULL,
  1043. hotk->methods->brightness_up,
  1044. NULL, NULL);
  1045. if (ACPI_FAILURE(status))
  1046. printk(KERN_WARNING " Strange, error changing"
  1047. " brightness\n");
  1048. }
  1049. }
  1050. end:
  1051. if (result) {
  1052. kfree(hotk);
  1053. }
  1054. return result;
  1055. }
  1056. static int asus_hotk_remove(struct acpi_device *device, int type)
  1057. {
  1058. acpi_status status = 0;
  1059. if (!device || !acpi_driver_data(device))
  1060. return -EINVAL;
  1061. status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
  1062. asus_hotk_notify);
  1063. if (ACPI_FAILURE(status))
  1064. printk(KERN_ERR "Asus ACPI: Error removing notify handler\n");
  1065. asus_hotk_remove_fs(device);
  1066. kfree(hotk);
  1067. return 0;
  1068. }
  1069. static int __init asus_acpi_init(void)
  1070. {
  1071. int result;
  1072. if (acpi_disabled)
  1073. return -ENODEV;
  1074. if (!acpi_specific_hotkey_enabled) {
  1075. printk(KERN_ERR "Using generic hotkey driver\n");
  1076. return -ENODEV;
  1077. }
  1078. asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
  1079. if (!asus_proc_dir) {
  1080. printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
  1081. return -ENODEV;
  1082. }
  1083. asus_proc_dir->owner = THIS_MODULE;
  1084. result = acpi_bus_register_driver(&asus_hotk_driver);
  1085. if (result < 1) {
  1086. acpi_bus_unregister_driver(&asus_hotk_driver);
  1087. remove_proc_entry(PROC_ASUS, acpi_root_dir);
  1088. return -ENODEV;
  1089. }
  1090. return 0;
  1091. }
  1092. static void __exit asus_acpi_exit(void)
  1093. {
  1094. acpi_bus_unregister_driver(&asus_hotk_driver);
  1095. remove_proc_entry(PROC_ASUS, acpi_root_dir);
  1096. acpi_os_free(asus_info);
  1097. return;
  1098. }
  1099. module_init(asus_acpi_init);
  1100. module_exit(asus_acpi_exit);