video.c 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989
  1. /*
  2. * video.c - ACPI Video Driver ($Revision:$)
  3. *
  4. * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
  5. * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/types.h>
  29. #include <linux/list.h>
  30. #include <linux/proc_fs.h>
  31. #include <linux/seq_file.h>
  32. #include <asm/uaccess.h>
  33. #include <acpi/acpi_bus.h>
  34. #include <acpi/acpi_drivers.h>
  35. #define ACPI_VIDEO_COMPONENT 0x08000000
  36. #define ACPI_VIDEO_CLASS "video"
  37. #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver"
  38. #define ACPI_VIDEO_BUS_NAME "Video Bus"
  39. #define ACPI_VIDEO_DEVICE_NAME "Video Device"
  40. #define ACPI_VIDEO_NOTIFY_SWITCH 0x80
  41. #define ACPI_VIDEO_NOTIFY_PROBE 0x81
  42. #define ACPI_VIDEO_NOTIFY_CYCLE 0x82
  43. #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
  44. #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
  45. #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
  46. #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
  47. #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
  48. #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
  49. #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
  50. #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
  51. #define ACPI_VIDEO_HEAD_END (~0u)
  52. #define _COMPONENT ACPI_VIDEO_COMPONENT
  53. ACPI_MODULE_NAME ("acpi_video")
  54. MODULE_AUTHOR("Bruno Ducrot");
  55. MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME);
  56. MODULE_LICENSE("GPL");
  57. static int acpi_video_bus_add (struct acpi_device *device);
  58. static int acpi_video_bus_remove (struct acpi_device *device, int type);
  59. static int acpi_video_bus_match (struct acpi_device *device, struct acpi_driver *driver);
  60. static struct acpi_driver acpi_video_bus = {
  61. .name = ACPI_VIDEO_DRIVER_NAME,
  62. .class = ACPI_VIDEO_CLASS,
  63. .ops = {
  64. .add = acpi_video_bus_add,
  65. .remove = acpi_video_bus_remove,
  66. .match = acpi_video_bus_match,
  67. },
  68. };
  69. struct acpi_video_bus_flags {
  70. u8 multihead:1; /* can switch video heads */
  71. u8 rom:1; /* can retrieve a video rom */
  72. u8 post:1; /* can configure the head to */
  73. u8 reserved:5;
  74. };
  75. struct acpi_video_bus_cap {
  76. u8 _DOS:1; /*Enable/Disable output switching*/
  77. u8 _DOD:1; /*Enumerate all devices attached to display adapter*/
  78. u8 _ROM:1; /*Get ROM Data*/
  79. u8 _GPD:1; /*Get POST Device*/
  80. u8 _SPD:1; /*Set POST Device*/
  81. u8 _VPO:1; /*Video POST Options*/
  82. u8 reserved:2;
  83. };
  84. struct acpi_video_device_attrib{
  85. u32 display_index:4; /* A zero-based instance of the Display*/
  86. u32 display_port_attachment:4; /*This field differenates displays type*/
  87. u32 display_type:4; /*Describe the specific type in use*/
  88. u32 vendor_specific:4; /*Chipset Vendor Specifi*/
  89. u32 bios_can_detect:1; /*BIOS can detect the device*/
  90. u32 depend_on_vga:1; /*Non-VGA output device whose power is related to
  91. the VGA device.*/
  92. u32 pipe_id:3; /*For VGA multiple-head devices.*/
  93. u32 reserved:10; /*Must be 0*/
  94. u32 device_id_scheme:1; /*Device ID Scheme*/
  95. };
  96. struct acpi_video_enumerated_device {
  97. union {
  98. u32 int_val;
  99. struct acpi_video_device_attrib attrib;
  100. } value;
  101. struct acpi_video_device *bind_info;
  102. };
  103. struct acpi_video_bus {
  104. acpi_handle handle;
  105. u8 dos_setting;
  106. struct acpi_video_enumerated_device *attached_array;
  107. u8 attached_count;
  108. struct acpi_video_bus_cap cap;
  109. struct acpi_video_bus_flags flags;
  110. struct semaphore sem;
  111. struct list_head video_device_list;
  112. struct proc_dir_entry *dir;
  113. };
  114. struct acpi_video_device_flags {
  115. u8 crt:1;
  116. u8 lcd:1;
  117. u8 tvout:1;
  118. u8 bios:1;
  119. u8 unknown:1;
  120. u8 reserved:3;
  121. };
  122. struct acpi_video_device_cap {
  123. u8 _ADR:1; /*Return the unique ID */
  124. u8 _BCL:1; /*Query list of brightness control levels supported*/
  125. u8 _BCM:1; /*Set the brightness level*/
  126. u8 _DDC:1; /*Return the EDID for this device*/
  127. u8 _DCS:1; /*Return status of output device*/
  128. u8 _DGS:1; /*Query graphics state*/
  129. u8 _DSS:1; /*Device state set*/
  130. u8 _reserved:1;
  131. };
  132. struct acpi_video_device_brightness {
  133. int curr;
  134. int count;
  135. int *levels;
  136. };
  137. struct acpi_video_device {
  138. acpi_handle handle;
  139. unsigned long device_id;
  140. struct acpi_video_device_flags flags;
  141. struct acpi_video_device_cap cap;
  142. struct list_head entry;
  143. struct acpi_video_bus *video;
  144. struct acpi_device *dev;
  145. struct acpi_video_device_brightness *brightness;
  146. };
  147. /* bus */
  148. static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
  149. static struct file_operations acpi_video_bus_info_fops = {
  150. .open = acpi_video_bus_info_open_fs,
  151. .read = seq_read,
  152. .llseek = seq_lseek,
  153. .release = single_release,
  154. };
  155. static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
  156. static struct file_operations acpi_video_bus_ROM_fops = {
  157. .open = acpi_video_bus_ROM_open_fs,
  158. .read = seq_read,
  159. .llseek = seq_lseek,
  160. .release = single_release,
  161. };
  162. static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file);
  163. static struct file_operations acpi_video_bus_POST_info_fops = {
  164. .open = acpi_video_bus_POST_info_open_fs,
  165. .read = seq_read,
  166. .llseek = seq_lseek,
  167. .release = single_release,
  168. };
  169. static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
  170. static struct file_operations acpi_video_bus_POST_fops = {
  171. .open = acpi_video_bus_POST_open_fs,
  172. .read = seq_read,
  173. .llseek = seq_lseek,
  174. .release = single_release,
  175. };
  176. static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
  177. static struct file_operations acpi_video_bus_DOS_fops = {
  178. .open = acpi_video_bus_DOS_open_fs,
  179. .read = seq_read,
  180. .llseek = seq_lseek,
  181. .release = single_release,
  182. };
  183. /* device */
  184. static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file);
  185. static struct file_operations acpi_video_device_info_fops = {
  186. .open = acpi_video_device_info_open_fs,
  187. .read = seq_read,
  188. .llseek = seq_lseek,
  189. .release = single_release,
  190. };
  191. static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file);
  192. static struct file_operations acpi_video_device_state_fops = {
  193. .open = acpi_video_device_state_open_fs,
  194. .read = seq_read,
  195. .llseek = seq_lseek,
  196. .release = single_release,
  197. };
  198. static int acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file);
  199. static struct file_operations acpi_video_device_brightness_fops = {
  200. .open = acpi_video_device_brightness_open_fs,
  201. .read = seq_read,
  202. .llseek = seq_lseek,
  203. .release = single_release,
  204. };
  205. static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file);
  206. static struct file_operations acpi_video_device_EDID_fops = {
  207. .open = acpi_video_device_EDID_open_fs,
  208. .read = seq_read,
  209. .llseek = seq_lseek,
  210. .release = single_release,
  211. };
  212. static char device_decode[][30] = {
  213. "motherboard VGA device",
  214. "PCI VGA device",
  215. "AGP VGA device",
  216. "UNKNOWN",
  217. };
  218. static void acpi_video_device_notify ( acpi_handle handle, u32 event, void *data);
  219. static void acpi_video_device_rebind( struct acpi_video_bus *video);
  220. static void acpi_video_device_bind( struct acpi_video_bus *video, struct acpi_video_device *device);
  221. static int acpi_video_device_enumerate(struct acpi_video_bus *video);
  222. static int acpi_video_switch_output( struct acpi_video_bus *video, int event);
  223. static int acpi_video_get_next_level( struct acpi_video_device *device, u32 level_current,u32 event);
  224. static void acpi_video_switch_brightness ( struct acpi_video_device *device, int event);
  225. /* --------------------------------------------------------------------------
  226. Video Management
  227. -------------------------------------------------------------------------- */
  228. /* device */
  229. static int
  230. acpi_video_device_query (
  231. struct acpi_video_device *device,
  232. unsigned long *state)
  233. {
  234. int status;
  235. ACPI_FUNCTION_TRACE("acpi_video_device_query");
  236. status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
  237. return_VALUE(status);
  238. }
  239. static int
  240. acpi_video_device_get_state (
  241. struct acpi_video_device *device,
  242. unsigned long *state)
  243. {
  244. int status;
  245. ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
  246. status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
  247. return_VALUE(status);
  248. }
  249. static int
  250. acpi_video_device_set_state (
  251. struct acpi_video_device *device,
  252. int state)
  253. {
  254. int status;
  255. union acpi_object arg0 = {ACPI_TYPE_INTEGER};
  256. struct acpi_object_list args = {1, &arg0};
  257. ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
  258. arg0.integer.value = state;
  259. status = acpi_evaluate_integer(device->handle, "_DSS", &args, NULL);
  260. return_VALUE(status);
  261. }
  262. static int
  263. acpi_video_device_lcd_query_levels (
  264. struct acpi_video_device *device,
  265. union acpi_object **levels)
  266. {
  267. int status;
  268. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  269. union acpi_object *obj;
  270. ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
  271. *levels = NULL;
  272. status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
  273. if (!ACPI_SUCCESS(status))
  274. return_VALUE(status);
  275. obj = (union acpi_object *) buffer.pointer;
  276. if (!obj && (obj->type != ACPI_TYPE_PACKAGE)) {
  277. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n"));
  278. status = -EFAULT;
  279. goto err;
  280. }
  281. *levels = obj;
  282. return_VALUE(0);
  283. err:
  284. if (buffer.pointer)
  285. kfree(buffer.pointer);
  286. return_VALUE(status);
  287. }
  288. static int
  289. acpi_video_device_lcd_set_level (
  290. struct acpi_video_device *device,
  291. int level)
  292. {
  293. int status;
  294. union acpi_object arg0 = {ACPI_TYPE_INTEGER};
  295. struct acpi_object_list args = {1, &arg0};
  296. ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
  297. arg0.integer.value = level;
  298. status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
  299. printk(KERN_DEBUG "set_level status: %x\n", status);
  300. return_VALUE(status);
  301. }
  302. static int
  303. acpi_video_device_lcd_get_level_current (
  304. struct acpi_video_device *device,
  305. unsigned long *level)
  306. {
  307. int status;
  308. ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
  309. status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
  310. return_VALUE(status);
  311. }
  312. static int
  313. acpi_video_device_EDID (
  314. struct acpi_video_device *device,
  315. union acpi_object **edid,
  316. ssize_t length)
  317. {
  318. int status;
  319. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  320. union acpi_object *obj;
  321. union acpi_object arg0 = {ACPI_TYPE_INTEGER};
  322. struct acpi_object_list args = {1, &arg0};
  323. ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
  324. *edid = NULL;
  325. if (!device)
  326. return_VALUE(-ENODEV);
  327. if (length == 128)
  328. arg0.integer.value = 1;
  329. else if (length == 256)
  330. arg0.integer.value = 2;
  331. else
  332. return_VALUE(-EINVAL);
  333. status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
  334. if (ACPI_FAILURE(status))
  335. return_VALUE(-ENODEV);
  336. obj = (union acpi_object *) buffer.pointer;
  337. if (obj && obj->type == ACPI_TYPE_BUFFER)
  338. *edid = obj;
  339. else {
  340. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n"));
  341. status = -EFAULT;
  342. kfree(obj);
  343. }
  344. return_VALUE(status);
  345. }
  346. /* bus */
  347. static int
  348. acpi_video_bus_set_POST (
  349. struct acpi_video_bus *video,
  350. unsigned long option)
  351. {
  352. int status;
  353. unsigned long tmp;
  354. union acpi_object arg0 = {ACPI_TYPE_INTEGER};
  355. struct acpi_object_list args = {1, &arg0};
  356. ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
  357. arg0.integer.value = option;
  358. status = acpi_evaluate_integer(video->handle, "_SPD", &args, &tmp);
  359. if (ACPI_SUCCESS(status))
  360. status = tmp ? (-EINVAL):(AE_OK);
  361. return_VALUE(status);
  362. }
  363. static int
  364. acpi_video_bus_get_POST (
  365. struct acpi_video_bus *video,
  366. unsigned long *id)
  367. {
  368. int status;
  369. ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
  370. status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
  371. return_VALUE(status);
  372. }
  373. static int
  374. acpi_video_bus_POST_options (
  375. struct acpi_video_bus *video,
  376. unsigned long *options)
  377. {
  378. int status;
  379. ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
  380. status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
  381. *options &= 3;
  382. return_VALUE(status);
  383. }
  384. /*
  385. * Arg:
  386. * video : video bus device pointer
  387. * bios_flag :
  388. * 0. The system BIOS should NOT automatically switch(toggle)
  389. * the active display output.
  390. * 1. The system BIOS should automatically switch (toggle) the
  391. * active display output. No swich event.
  392. * 2. The _DGS value should be locked.
  393. * 3. The system BIOS should not automatically switch (toggle) the
  394. * active display output, but instead generate the display switch
  395. * event notify code.
  396. * lcd_flag :
  397. * 0. The system BIOS should automatically control the brightness level
  398. * of the LCD, when the power changes from AC to DC
  399. * 1. The system BIOS should NOT automatically control the brightness
  400. * level of the LCD, when the power changes from AC to DC.
  401. * Return Value:
  402. * -1 wrong arg.
  403. */
  404. static int
  405. acpi_video_bus_DOS(
  406. struct acpi_video_bus *video,
  407. int bios_flag,
  408. int lcd_flag)
  409. {
  410. acpi_integer status = 0;
  411. union acpi_object arg0 = {ACPI_TYPE_INTEGER};
  412. struct acpi_object_list args = {1, &arg0};
  413. ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
  414. if (bios_flag < 0 || bios_flag >3 || lcd_flag < 0 || lcd_flag > 1){
  415. status = -1;
  416. goto Failed;
  417. }
  418. arg0.integer.value = (lcd_flag << 2) | bios_flag;
  419. video->dos_setting = arg0.integer.value;
  420. acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
  421. Failed:
  422. return_VALUE(status);
  423. }
  424. /*
  425. * Arg:
  426. * device : video output device (LCD, CRT, ..)
  427. *
  428. * Return Value:
  429. * None
  430. *
  431. * Find out all required AML method defined under the output
  432. * device.
  433. */
  434. static void
  435. acpi_video_device_find_cap (struct acpi_video_device *device)
  436. {
  437. acpi_integer status;
  438. acpi_handle h_dummy1;
  439. int i;
  440. union acpi_object *obj = NULL;
  441. struct acpi_video_device_brightness *br = NULL;
  442. ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
  443. memset( &device->cap, 0, 4);
  444. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_ADR", &h_dummy1))) {
  445. device->cap._ADR = 1;
  446. }
  447. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCL", &h_dummy1))) {
  448. device->cap._BCL= 1;
  449. }
  450. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_BCM", &h_dummy1))) {
  451. device->cap._BCM= 1;
  452. }
  453. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DDC", &h_dummy1))) {
  454. device->cap._DDC= 1;
  455. }
  456. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DCS", &h_dummy1))) {
  457. device->cap._DCS = 1;
  458. }
  459. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DGS", &h_dummy1))) {
  460. device->cap._DGS = 1;
  461. }
  462. if( ACPI_SUCCESS(acpi_get_handle(device->handle, "_DSS", &h_dummy1))) {
  463. device->cap._DSS = 1;
  464. }
  465. status = acpi_video_device_lcd_query_levels(device, &obj);
  466. if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
  467. int count = 0;
  468. union acpi_object *o;
  469. br = kmalloc(sizeof &br, GFP_KERNEL);
  470. if (!br) {
  471. printk(KERN_ERR "can't allocate memory\n");
  472. } else {
  473. memset(br, 0, sizeof &br);
  474. br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
  475. if (!br->levels)
  476. goto out;
  477. for (i = 0; i < obj->package.count; i++) {
  478. o = (union acpi_object *) &obj->package.elements[i];
  479. if (o->type != ACPI_TYPE_INTEGER) {
  480. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
  481. continue;
  482. }
  483. br->levels[count] = (u32) o->integer.value;
  484. count++;
  485. }
  486. out:
  487. if (count < 2) {
  488. if (br->levels)
  489. kfree(br->levels);
  490. kfree(br);
  491. } else {
  492. br->count = count;
  493. device->brightness = br;
  494. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "found %d brightness levels\n", count));
  495. }
  496. }
  497. }
  498. if (obj)
  499. kfree(obj);
  500. return_VOID;
  501. }
  502. /*
  503. * Arg:
  504. * device : video output device (VGA)
  505. *
  506. * Return Value:
  507. * None
  508. *
  509. * Find out all required AML method defined under the video bus device.
  510. */
  511. static void
  512. acpi_video_bus_find_cap (struct acpi_video_bus *video)
  513. {
  514. acpi_handle h_dummy1;
  515. memset(&video->cap ,0, 4);
  516. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOS", &h_dummy1))) {
  517. video->cap._DOS = 1;
  518. }
  519. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_DOD", &h_dummy1))) {
  520. video->cap._DOD = 1;
  521. }
  522. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_ROM", &h_dummy1))) {
  523. video->cap._ROM = 1;
  524. }
  525. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_GPD", &h_dummy1))) {
  526. video->cap._GPD = 1;
  527. }
  528. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_SPD", &h_dummy1))) {
  529. video->cap._SPD = 1;
  530. }
  531. if( ACPI_SUCCESS(acpi_get_handle(video->handle, "_VPO", &h_dummy1))) {
  532. video->cap._VPO = 1;
  533. }
  534. }
  535. /*
  536. * Check whether the video bus device has required AML method to
  537. * support the desired features
  538. */
  539. static int
  540. acpi_video_bus_check (
  541. struct acpi_video_bus *video)
  542. {
  543. acpi_status status = -ENOENT;
  544. ACPI_FUNCTION_TRACE("acpi_video_bus_check");
  545. if (!video)
  546. return_VALUE(-EINVAL);
  547. /* Since there is no HID, CID and so on for VGA driver, we have
  548. * to check well known required nodes.
  549. */
  550. /* Does this device able to support video switching ? */
  551. if(video->cap._DOS){
  552. video->flags.multihead = 1;
  553. status = 0;
  554. }
  555. /* Does this device able to retrieve a retrieve a video ROM ? */
  556. if(video->cap._ROM){
  557. video->flags.rom = 1;
  558. status = 0;
  559. }
  560. /* Does this device able to configure which video device to POST ? */
  561. if(video->cap._GPD && video->cap._SPD && video->cap._VPO){
  562. video->flags.post = 1;
  563. status = 0;
  564. }
  565. return_VALUE(status);
  566. }
  567. /* --------------------------------------------------------------------------
  568. FS Interface (/proc)
  569. -------------------------------------------------------------------------- */
  570. static struct proc_dir_entry *acpi_video_dir;
  571. /* video devices */
  572. static int
  573. acpi_video_device_info_seq_show (
  574. struct seq_file *seq,
  575. void *offset)
  576. {
  577. struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
  578. ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
  579. if (!dev)
  580. goto end;
  581. seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
  582. seq_printf(seq, "type: ");
  583. if (dev->flags.crt)
  584. seq_printf(seq, "CRT\n");
  585. else if (dev->flags.lcd)
  586. seq_printf(seq, "LCD\n");
  587. else if (dev->flags.tvout)
  588. seq_printf(seq, "TVOUT\n");
  589. else
  590. seq_printf(seq, "UNKNOWN\n");
  591. seq_printf(seq,"known by bios: %s\n",
  592. dev->flags.bios ? "yes":"no");
  593. end:
  594. return_VALUE(0);
  595. }
  596. static int
  597. acpi_video_device_info_open_fs (
  598. struct inode *inode,
  599. struct file *file)
  600. {
  601. return single_open(file, acpi_video_device_info_seq_show,
  602. PDE(inode)->data);
  603. }
  604. static int
  605. acpi_video_device_state_seq_show (
  606. struct seq_file *seq,
  607. void *offset)
  608. {
  609. int status;
  610. struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
  611. unsigned long state;
  612. ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
  613. if (!dev)
  614. goto end;
  615. status = acpi_video_device_get_state(dev, &state);
  616. seq_printf(seq, "state: ");
  617. if (ACPI_SUCCESS(status))
  618. seq_printf(seq, "0x%02lx\n", state);
  619. else
  620. seq_printf(seq, "<not supported>\n");
  621. status = acpi_video_device_query(dev, &state);
  622. seq_printf(seq, "query: ");
  623. if (ACPI_SUCCESS(status))
  624. seq_printf(seq, "0x%02lx\n", state);
  625. else
  626. seq_printf(seq, "<not supported>\n");
  627. end:
  628. return_VALUE(0);
  629. }
  630. static int
  631. acpi_video_device_state_open_fs (
  632. struct inode *inode,
  633. struct file *file)
  634. {
  635. return single_open(file, acpi_video_device_state_seq_show,
  636. PDE(inode)->data);
  637. }
  638. static ssize_t
  639. acpi_video_device_write_state (
  640. struct file *file,
  641. const char __user *buffer,
  642. size_t count,
  643. loff_t *data)
  644. {
  645. int status;
  646. struct seq_file *m = (struct seq_file *) file->private_data;
  647. struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
  648. char str[12] = {0};
  649. u32 state = 0;
  650. ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
  651. if (!dev || count + 1 > sizeof str)
  652. return_VALUE(-EINVAL);
  653. if (copy_from_user(str, buffer, count))
  654. return_VALUE(-EFAULT);
  655. str[count] = 0;
  656. state = simple_strtoul(str, NULL, 0);
  657. state &= ((1ul<<31) | (1ul<<30) | (1ul<<0));
  658. status = acpi_video_device_set_state(dev, state);
  659. if (status)
  660. return_VALUE(-EFAULT);
  661. return_VALUE(count);
  662. }
  663. static int
  664. acpi_video_device_brightness_seq_show (
  665. struct seq_file *seq,
  666. void *offset)
  667. {
  668. struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
  669. int i;
  670. ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
  671. if (!dev || !dev->brightness) {
  672. seq_printf(seq, "<not supported>\n");
  673. return_VALUE(0);
  674. }
  675. seq_printf(seq, "levels: ");
  676. for (i = 0; i < dev->brightness->count; i++)
  677. seq_printf(seq, " %d", dev->brightness->levels[i]);
  678. seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
  679. return_VALUE(0);
  680. }
  681. static int
  682. acpi_video_device_brightness_open_fs (
  683. struct inode *inode,
  684. struct file *file)
  685. {
  686. return single_open(file, acpi_video_device_brightness_seq_show,
  687. PDE(inode)->data);
  688. }
  689. static ssize_t
  690. acpi_video_device_write_brightness (
  691. struct file *file,
  692. const char __user *buffer,
  693. size_t count,
  694. loff_t *data)
  695. {
  696. struct seq_file *m = (struct seq_file *) file->private_data;
  697. struct acpi_video_device *dev = (struct acpi_video_device *) m->private;
  698. char str[4] = {0};
  699. unsigned int level = 0;
  700. int i;
  701. ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
  702. if (!dev || count + 1 > sizeof str)
  703. return_VALUE(-EINVAL);
  704. if (copy_from_user(str, buffer, count))
  705. return_VALUE(-EFAULT);
  706. str[count] = 0;
  707. level = simple_strtoul(str, NULL, 0);
  708. if (level > 100)
  709. return_VALUE(-EFAULT);
  710. /* validate though the list of available levels */
  711. for (i = 0; i < dev->brightness->count; i++)
  712. if (level == dev->brightness->levels[i]) {
  713. if (ACPI_SUCCESS(acpi_video_device_lcd_set_level(dev, level)))
  714. dev->brightness->curr = level;
  715. break;
  716. }
  717. return_VALUE(count);
  718. }
  719. static int
  720. acpi_video_device_EDID_seq_show (
  721. struct seq_file *seq,
  722. void *offset)
  723. {
  724. struct acpi_video_device *dev = (struct acpi_video_device *) seq->private;
  725. int status;
  726. int i;
  727. union acpi_object *edid = NULL;
  728. ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
  729. if (!dev)
  730. goto out;
  731. status = acpi_video_device_EDID (dev, &edid, 128);
  732. if (ACPI_FAILURE(status)) {
  733. status = acpi_video_device_EDID (dev, &edid, 256);
  734. }
  735. if (ACPI_FAILURE(status)) {
  736. goto out;
  737. }
  738. if (edid && edid->type == ACPI_TYPE_BUFFER) {
  739. for (i = 0; i < edid->buffer.length; i++)
  740. seq_putc(seq, edid->buffer.pointer[i]);
  741. }
  742. out:
  743. if (!edid)
  744. seq_printf(seq, "<not supported>\n");
  745. else
  746. kfree(edid);
  747. return_VALUE(0);
  748. }
  749. static int
  750. acpi_video_device_EDID_open_fs (
  751. struct inode *inode,
  752. struct file *file)
  753. {
  754. return single_open(file, acpi_video_device_EDID_seq_show,
  755. PDE(inode)->data);
  756. }
  757. static int
  758. acpi_video_device_add_fs (
  759. struct acpi_device *device)
  760. {
  761. struct proc_dir_entry *entry = NULL;
  762. struct acpi_video_device *vid_dev;
  763. ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
  764. if (!device)
  765. return_VALUE(-ENODEV);
  766. vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
  767. if (!vid_dev)
  768. return_VALUE(-ENODEV);
  769. if (!acpi_device_dir(device)) {
  770. acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
  771. vid_dev->video->dir);
  772. if (!acpi_device_dir(device))
  773. return_VALUE(-ENODEV);
  774. acpi_device_dir(device)->owner = THIS_MODULE;
  775. }
  776. /* 'info' [R] */
  777. entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
  778. if (!entry)
  779. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  780. "Unable to create 'info' fs entry\n"));
  781. else {
  782. entry->proc_fops = &acpi_video_device_info_fops;
  783. entry->data = acpi_driver_data(device);
  784. entry->owner = THIS_MODULE;
  785. }
  786. /* 'state' [R/W] */
  787. entry = create_proc_entry("state", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
  788. if (!entry)
  789. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  790. "Unable to create 'state' fs entry\n"));
  791. else {
  792. entry->proc_fops = &acpi_video_device_state_fops;
  793. entry->proc_fops->write = acpi_video_device_write_state;
  794. entry->data = acpi_driver_data(device);
  795. entry->owner = THIS_MODULE;
  796. }
  797. /* 'brightness' [R/W] */
  798. entry = create_proc_entry("brightness", S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device));
  799. if (!entry)
  800. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  801. "Unable to create 'brightness' fs entry\n"));
  802. else {
  803. entry->proc_fops = &acpi_video_device_brightness_fops;
  804. entry->proc_fops->write = acpi_video_device_write_brightness;
  805. entry->data = acpi_driver_data(device);
  806. entry->owner = THIS_MODULE;
  807. }
  808. /* 'EDID' [R] */
  809. entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
  810. if (!entry)
  811. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  812. "Unable to create 'brightness' fs entry\n"));
  813. else {
  814. entry->proc_fops = &acpi_video_device_EDID_fops;
  815. entry->data = acpi_driver_data(device);
  816. entry->owner = THIS_MODULE;
  817. }
  818. return_VALUE(0);
  819. }
  820. static int
  821. acpi_video_device_remove_fs (
  822. struct acpi_device *device)
  823. {
  824. struct acpi_video_device *vid_dev;
  825. ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
  826. vid_dev = (struct acpi_video_device *) acpi_driver_data(device);
  827. if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
  828. return_VALUE(-ENODEV);
  829. if (acpi_device_dir(device)) {
  830. remove_proc_entry("info", acpi_device_dir(device));
  831. remove_proc_entry("state", acpi_device_dir(device));
  832. remove_proc_entry("brightness", acpi_device_dir(device));
  833. remove_proc_entry("EDID", acpi_device_dir(device));
  834. remove_proc_entry(acpi_device_bid(device),
  835. vid_dev->video->dir);
  836. acpi_device_dir(device) = NULL;
  837. }
  838. return_VALUE(0);
  839. }
  840. /* video bus */
  841. static int
  842. acpi_video_bus_info_seq_show (
  843. struct seq_file *seq,
  844. void *offset)
  845. {
  846. struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
  847. ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
  848. if (!video)
  849. goto end;
  850. seq_printf(seq, "Switching heads: %s\n",
  851. video->flags.multihead ? "yes":"no");
  852. seq_printf(seq, "Video ROM: %s\n",
  853. video->flags.rom ? "yes":"no");
  854. seq_printf(seq, "Device to be POSTed on boot: %s\n",
  855. video->flags.post ? "yes":"no");
  856. end:
  857. return_VALUE(0);
  858. }
  859. static int
  860. acpi_video_bus_info_open_fs (
  861. struct inode *inode,
  862. struct file *file)
  863. {
  864. return single_open(file, acpi_video_bus_info_seq_show, PDE(inode)->data);
  865. }
  866. static int
  867. acpi_video_bus_ROM_seq_show (
  868. struct seq_file *seq,
  869. void *offset)
  870. {
  871. struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
  872. ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
  873. if (!video)
  874. goto end;
  875. printk(KERN_INFO PREFIX "Please implement %s\n", __FUNCTION__);
  876. seq_printf(seq, "<TODO>\n");
  877. end:
  878. return_VALUE(0);
  879. }
  880. static int
  881. acpi_video_bus_ROM_open_fs (
  882. struct inode *inode,
  883. struct file *file)
  884. {
  885. return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
  886. }
  887. static int
  888. acpi_video_bus_POST_info_seq_show (
  889. struct seq_file *seq,
  890. void *offset)
  891. {
  892. struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
  893. unsigned long options;
  894. int status;
  895. ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
  896. if (!video)
  897. goto end;
  898. status = acpi_video_bus_POST_options(video, &options);
  899. if (ACPI_SUCCESS(status)) {
  900. if (!(options & 1)) {
  901. printk(KERN_WARNING PREFIX "The motherboard VGA device is not listed as a possible POST device.\n");
  902. printk(KERN_WARNING PREFIX "This indicate a BIOS bug. Please contact the manufacturer.\n");
  903. }
  904. printk("%lx\n", options);
  905. seq_printf(seq, "can POST: <intgrated video>");
  906. if (options & 2)
  907. seq_printf(seq, " <PCI video>");
  908. if (options & 4)
  909. seq_printf(seq, " <AGP video>");
  910. seq_putc(seq, '\n');
  911. } else
  912. seq_printf(seq, "<not supported>\n");
  913. end:
  914. return_VALUE(0);
  915. }
  916. static int
  917. acpi_video_bus_POST_info_open_fs (
  918. struct inode *inode,
  919. struct file *file)
  920. {
  921. return single_open(file, acpi_video_bus_POST_info_seq_show, PDE(inode)->data);
  922. }
  923. static int
  924. acpi_video_bus_POST_seq_show (
  925. struct seq_file *seq,
  926. void *offset)
  927. {
  928. struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
  929. int status;
  930. unsigned long id;
  931. ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
  932. if (!video)
  933. goto end;
  934. status = acpi_video_bus_get_POST (video, &id);
  935. if (!ACPI_SUCCESS(status)) {
  936. seq_printf(seq, "<not supported>\n");
  937. goto end;
  938. }
  939. seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
  940. end:
  941. return_VALUE(0);
  942. }
  943. static int
  944. acpi_video_bus_DOS_seq_show (
  945. struct seq_file *seq,
  946. void *offset)
  947. {
  948. struct acpi_video_bus *video = (struct acpi_video_bus *) seq->private;
  949. ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
  950. seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting );
  951. return_VALUE(0);
  952. }
  953. static int
  954. acpi_video_bus_POST_open_fs (
  955. struct inode *inode,
  956. struct file *file)
  957. {
  958. return single_open(file, acpi_video_bus_POST_seq_show, PDE(inode)->data);
  959. }
  960. static int
  961. acpi_video_bus_DOS_open_fs (
  962. struct inode *inode,
  963. struct file *file)
  964. {
  965. return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
  966. }
  967. static ssize_t
  968. acpi_video_bus_write_POST (
  969. struct file *file,
  970. const char __user *buffer,
  971. size_t count,
  972. loff_t *data)
  973. {
  974. int status;
  975. struct seq_file *m = (struct seq_file *) file->private_data;
  976. struct acpi_video_bus *video = (struct acpi_video_bus *) m->private;
  977. char str[12] = {0};
  978. unsigned long opt, options;
  979. ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
  980. if (!video || count + 1 > sizeof str)
  981. return_VALUE(-EINVAL);
  982. status = acpi_video_bus_POST_options(video, &options);
  983. if (!ACPI_SUCCESS(status))
  984. return_VALUE(-EINVAL);
  985. if (copy_from_user(str, buffer, count))
  986. return_VALUE(-EFAULT);
  987. str[count] = 0;
  988. opt = strtoul(str, NULL, 0);
  989. if (opt > 3)
  990. return_VALUE(-EFAULT);
  991. /* just in case an OEM 'forget' the motherboard... */
  992. options |= 1;
  993. if (options & (1ul << opt)) {
  994. status = acpi_video_bus_set_POST (video, opt);
  995. if (!ACPI_SUCCESS(status))
  996. return_VALUE(-EFAULT);
  997. }
  998. return_VALUE(count);
  999. }
  1000. static ssize_t
  1001. acpi_video_bus_write_DOS (
  1002. struct file *file,
  1003. const char __user *buffer,
  1004. size_t count,
  1005. loff_t *data)
  1006. {
  1007. int status;
  1008. struct seq_file *m = (struct seq_file *) file->private_data;
  1009. struct acpi_video_bus *video = (struct acpi_video_bus *) m->private;
  1010. char str[12] = {0};
  1011. unsigned long opt;
  1012. ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
  1013. if (!video || count + 1 > sizeof str)
  1014. return_VALUE(-EINVAL);
  1015. if (copy_from_user(str, buffer, count))
  1016. return_VALUE(-EFAULT);
  1017. str[count] = 0;
  1018. opt = strtoul(str, NULL, 0);
  1019. if (opt > 7)
  1020. return_VALUE(-EFAULT);
  1021. status = acpi_video_bus_DOS (video, opt & 0x3, (opt & 0x4)>>2);
  1022. if (!ACPI_SUCCESS(status))
  1023. return_VALUE(-EFAULT);
  1024. return_VALUE(count);
  1025. }
  1026. static int
  1027. acpi_video_bus_add_fs (
  1028. struct acpi_device *device)
  1029. {
  1030. struct proc_dir_entry *entry = NULL;
  1031. struct acpi_video_bus *video;
  1032. ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
  1033. video = (struct acpi_video_bus *) acpi_driver_data(device);
  1034. if (!acpi_device_dir(device)) {
  1035. acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
  1036. acpi_video_dir);
  1037. if (!acpi_device_dir(device))
  1038. return_VALUE(-ENODEV);
  1039. video->dir = acpi_device_dir(device);
  1040. acpi_device_dir(device)->owner = THIS_MODULE;
  1041. }
  1042. /* 'info' [R] */
  1043. entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
  1044. if (!entry)
  1045. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'info' fs entry\n"));
  1046. else {
  1047. entry->proc_fops = &acpi_video_bus_info_fops;
  1048. entry->data = acpi_driver_data(device);
  1049. entry->owner = THIS_MODULE;
  1050. }
  1051. /* 'ROM' [R] */
  1052. entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
  1053. if (!entry)
  1054. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'ROM' fs entry\n"));
  1055. else {
  1056. entry->proc_fops = &acpi_video_bus_ROM_fops;
  1057. entry->data = acpi_driver_data(device);
  1058. entry->owner = THIS_MODULE;
  1059. }
  1060. /* 'POST_info' [R] */
  1061. entry = create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
  1062. if (!entry)
  1063. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST_info' fs entry\n"));
  1064. else {
  1065. entry->proc_fops = &acpi_video_bus_POST_info_fops;
  1066. entry->data = acpi_driver_data(device);
  1067. entry->owner = THIS_MODULE;
  1068. }
  1069. /* 'POST' [R/W] */
  1070. entry = create_proc_entry("POST", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
  1071. if (!entry)
  1072. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'POST' fs entry\n"));
  1073. else {
  1074. entry->proc_fops = &acpi_video_bus_POST_fops;
  1075. entry->proc_fops->write = acpi_video_bus_write_POST;
  1076. entry->data = acpi_driver_data(device);
  1077. entry->owner = THIS_MODULE;
  1078. }
  1079. /* 'DOS' [R/W] */
  1080. entry = create_proc_entry("DOS", S_IFREG|S_IRUGO|S_IRUSR, acpi_device_dir(device));
  1081. if (!entry)
  1082. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to create 'DOS' fs entry\n"));
  1083. else {
  1084. entry->proc_fops = &acpi_video_bus_DOS_fops;
  1085. entry->proc_fops->write = acpi_video_bus_write_DOS;
  1086. entry->data = acpi_driver_data(device);
  1087. entry->owner = THIS_MODULE;
  1088. }
  1089. return_VALUE(0);
  1090. }
  1091. static int
  1092. acpi_video_bus_remove_fs (
  1093. struct acpi_device *device)
  1094. {
  1095. struct acpi_video_bus *video;
  1096. ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
  1097. video = (struct acpi_video_bus *) acpi_driver_data(device);
  1098. if (acpi_device_dir(device)) {
  1099. remove_proc_entry("info", acpi_device_dir(device));
  1100. remove_proc_entry("ROM", acpi_device_dir(device));
  1101. remove_proc_entry("POST_info", acpi_device_dir(device));
  1102. remove_proc_entry("POST", acpi_device_dir(device));
  1103. remove_proc_entry("DOS", acpi_device_dir(device));
  1104. remove_proc_entry(acpi_device_bid(device),
  1105. acpi_video_dir);
  1106. acpi_device_dir(device) = NULL;
  1107. }
  1108. return_VALUE(0);
  1109. }
  1110. /* --------------------------------------------------------------------------
  1111. Driver Interface
  1112. -------------------------------------------------------------------------- */
  1113. /* device interface */
  1114. static int
  1115. acpi_video_bus_get_one_device (
  1116. struct acpi_device *device,
  1117. struct acpi_video_bus *video)
  1118. {
  1119. unsigned long device_id;
  1120. int status, result;
  1121. struct acpi_video_device *data;
  1122. ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
  1123. if (!device || !video)
  1124. return_VALUE(-EINVAL);
  1125. status = acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
  1126. if (ACPI_SUCCESS(status)) {
  1127. data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
  1128. if (!data)
  1129. return_VALUE(-ENOMEM);
  1130. memset(data, 0, sizeof(struct acpi_video_device));
  1131. data->handle = device->handle;
  1132. strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
  1133. strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
  1134. acpi_driver_data(device) = data;
  1135. data->device_id = device_id;
  1136. data->video = video;
  1137. data->dev = device;
  1138. switch (device_id & 0xffff) {
  1139. case 0x0100:
  1140. data->flags.crt = 1;
  1141. break;
  1142. case 0x0400:
  1143. data->flags.lcd = 1;
  1144. break;
  1145. case 0x0200:
  1146. data->flags.tvout = 1;
  1147. break;
  1148. default:
  1149. data->flags.unknown = 1;
  1150. break;
  1151. }
  1152. acpi_video_device_bind(video, data);
  1153. acpi_video_device_find_cap(data);
  1154. status = acpi_install_notify_handler(data->handle,
  1155. ACPI_DEVICE_NOTIFY, acpi_video_device_notify, data);
  1156. if (ACPI_FAILURE(status)) {
  1157. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  1158. "Error installing notify handler\n"));
  1159. result = -ENODEV;
  1160. goto end;
  1161. }
  1162. down(&video->sem);
  1163. list_add_tail(&data->entry, &video->video_device_list);
  1164. up(&video->sem);
  1165. acpi_video_device_add_fs(device);
  1166. return_VALUE(0);
  1167. }
  1168. end:
  1169. return_VALUE(-ENOENT);
  1170. }
  1171. /*
  1172. * Arg:
  1173. * video : video bus device
  1174. *
  1175. * Return:
  1176. * none
  1177. *
  1178. * Enumerate the video device list of the video bus,
  1179. * bind the ids with the corresponding video devices
  1180. * under the video bus.
  1181. */
  1182. static void
  1183. acpi_video_device_rebind( struct acpi_video_bus *video)
  1184. {
  1185. struct list_head * node, * next;
  1186. list_for_each_safe(node, next, &video->video_device_list) {
  1187. struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
  1188. acpi_video_device_bind( video, dev);
  1189. }
  1190. }
  1191. /*
  1192. * Arg:
  1193. * video : video bus device
  1194. * device : video output device under the video
  1195. * bus
  1196. *
  1197. * Return:
  1198. * none
  1199. *
  1200. * Bind the ids with the corresponding video devices
  1201. * under the video bus.
  1202. */
  1203. static void
  1204. acpi_video_device_bind( struct acpi_video_bus *video,
  1205. struct acpi_video_device *device)
  1206. {
  1207. int i;
  1208. ACPI_FUNCTION_TRACE("acpi_video_device_bind");
  1209. #define IDS_VAL(i) video->attached_array[i].value.int_val
  1210. #define IDS_BIND(i) video->attached_array[i].bind_info
  1211. for (i = 0; IDS_VAL(i) != ACPI_VIDEO_HEAD_INVALID &&
  1212. i < video->attached_count; i++) {
  1213. if (device->device_id == (IDS_VAL(i)& 0xffff)) {
  1214. IDS_BIND(i) = device;
  1215. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "device_bind %d\n", i));
  1216. }
  1217. }
  1218. #undef IDS_VAL
  1219. #undef IDS_BIND
  1220. }
  1221. /*
  1222. * Arg:
  1223. * video : video bus device
  1224. *
  1225. * Return:
  1226. * < 0 : error
  1227. *
  1228. * Call _DOD to enumerate all devices attached to display adapter
  1229. *
  1230. */
  1231. static int acpi_video_device_enumerate(struct acpi_video_bus *video)
  1232. {
  1233. int status;
  1234. int count;
  1235. int i;
  1236. struct acpi_video_enumerated_device *active_device_list;
  1237. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  1238. union acpi_object *dod = NULL;
  1239. union acpi_object *obj;
  1240. ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
  1241. status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
  1242. if (!ACPI_SUCCESS(status)) {
  1243. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n"));
  1244. return_VALUE(status);
  1245. }
  1246. dod = (union acpi_object *) buffer.pointer;
  1247. if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
  1248. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
  1249. status = -EFAULT;
  1250. goto out;
  1251. }
  1252. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
  1253. dod->package.count));
  1254. active_device_list= kmalloc(
  1255. (1+dod->package.count)*sizeof(struct acpi_video_enumerated_device),
  1256. GFP_KERNEL);
  1257. if (!active_device_list) {
  1258. status = -ENOMEM;
  1259. goto out;
  1260. }
  1261. count = 0;
  1262. for (i = 0; i < dod->package.count; i++) {
  1263. obj = (union acpi_object *) &dod->package.elements[i];
  1264. if (obj->type != ACPI_TYPE_INTEGER) {
  1265. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n"));
  1266. active_device_list[i].value.int_val = ACPI_VIDEO_HEAD_INVALID;
  1267. }
  1268. active_device_list[i].value.int_val = obj->integer.value;
  1269. active_device_list[i].bind_info = NULL;
  1270. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "dod element[%d] = %d\n", i, (int) obj->integer.value));
  1271. count++;
  1272. }
  1273. active_device_list[count].value.int_val = ACPI_VIDEO_HEAD_END;
  1274. if(video->attached_array)
  1275. kfree(video->attached_array);
  1276. video->attached_array = active_device_list;
  1277. video->attached_count = count;
  1278. out:
  1279. acpi_os_free(buffer.pointer);
  1280. return_VALUE(status);
  1281. }
  1282. /*
  1283. * Arg:
  1284. * video : video bus device
  1285. * event : Nontify Event
  1286. *
  1287. * Return:
  1288. * < 0 : error
  1289. *
  1290. * 1. Find out the current active output device.
  1291. * 2. Identify the next output device to switch
  1292. * 3. call _DSS to do actual switch.
  1293. */
  1294. static int
  1295. acpi_video_switch_output(
  1296. struct acpi_video_bus *video,
  1297. int event)
  1298. {
  1299. struct list_head * node, * next;
  1300. struct acpi_video_device *dev=NULL;
  1301. struct acpi_video_device *dev_next=NULL;
  1302. struct acpi_video_device *dev_prev=NULL;
  1303. unsigned long state;
  1304. int status = 0;
  1305. ACPI_FUNCTION_TRACE("acpi_video_switch_output");
  1306. list_for_each_safe(node, next, &video->video_device_list) {
  1307. struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
  1308. status = acpi_video_device_get_state(dev, &state);
  1309. if (state & 0x2){
  1310. dev_next = container_of(node->next, struct acpi_video_device, entry);
  1311. dev_prev = container_of(node->prev, struct acpi_video_device, entry);
  1312. goto out;
  1313. }
  1314. }
  1315. dev_next = container_of(node->next, struct acpi_video_device, entry);
  1316. dev_prev = container_of(node->prev, struct acpi_video_device, entry);
  1317. out:
  1318. switch (event) {
  1319. case ACPI_VIDEO_NOTIFY_CYCLE:
  1320. case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:
  1321. acpi_video_device_set_state(dev, 0);
  1322. acpi_video_device_set_state(dev_next, 0x80000001);
  1323. break;
  1324. case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:
  1325. acpi_video_device_set_state(dev, 0);
  1326. acpi_video_device_set_state(dev_prev, 0x80000001);
  1327. default:
  1328. break;
  1329. }
  1330. return_VALUE(status);
  1331. }
  1332. static int
  1333. acpi_video_get_next_level(
  1334. struct acpi_video_device *device,
  1335. u32 level_current,
  1336. u32 event)
  1337. {
  1338. /*Fix me*/
  1339. return level_current;
  1340. }
  1341. static void
  1342. acpi_video_switch_brightness (
  1343. struct acpi_video_device *device,
  1344. int event)
  1345. {
  1346. unsigned long level_current, level_next;
  1347. acpi_video_device_lcd_get_level_current(device, &level_current);
  1348. level_next = acpi_video_get_next_level(device, level_current, event);
  1349. acpi_video_device_lcd_set_level(device, level_next);
  1350. }
  1351. static int
  1352. acpi_video_bus_get_devices (
  1353. struct acpi_video_bus *video,
  1354. struct acpi_device *device)
  1355. {
  1356. int status = 0;
  1357. struct list_head *node, *next;
  1358. ACPI_FUNCTION_TRACE("acpi_video_get_devices");
  1359. acpi_video_device_enumerate(video);
  1360. list_for_each_safe(node, next, &device->children) {
  1361. struct acpi_device *dev = list_entry(node, struct acpi_device, node);
  1362. if (!dev)
  1363. continue;
  1364. status = acpi_video_bus_get_one_device(dev, video);
  1365. if (ACPI_FAILURE(status)) {
  1366. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Cant attach device\n"));
  1367. continue;
  1368. }
  1369. }
  1370. return_VALUE(status);
  1371. }
  1372. static int
  1373. acpi_video_bus_put_one_device(
  1374. struct acpi_video_device *device)
  1375. {
  1376. struct acpi_video_bus *video;
  1377. ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
  1378. if (!device || !device->video)
  1379. return_VALUE(-ENOENT);
  1380. video = device->video;
  1381. down(&video->sem);
  1382. list_del(&device->entry);
  1383. up(&video->sem);
  1384. acpi_video_device_remove_fs(device->dev);
  1385. return_VALUE(0);
  1386. }
  1387. static int
  1388. acpi_video_bus_put_devices (
  1389. struct acpi_video_bus *video)
  1390. {
  1391. int status;
  1392. struct list_head *node, *next;
  1393. ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
  1394. list_for_each_safe(node, next, &video->video_device_list) {
  1395. struct acpi_video_device *data = list_entry(node, struct acpi_video_device, entry);
  1396. if (!data)
  1397. continue;
  1398. status = acpi_video_bus_put_one_device(data);
  1399. if(ACPI_FAILURE(status))
  1400. printk(KERN_WARNING PREFIX "hhuuhhuu bug in acpi video driver.\n");
  1401. if (data->brightness)
  1402. kfree(data->brightness);
  1403. kfree(data);
  1404. }
  1405. return_VALUE(0);
  1406. }
  1407. /* acpi_video interface */
  1408. static int
  1409. acpi_video_bus_start_devices(
  1410. struct acpi_video_bus *video)
  1411. {
  1412. return acpi_video_bus_DOS(video, 1, 0);
  1413. }
  1414. static int
  1415. acpi_video_bus_stop_devices(
  1416. struct acpi_video_bus *video)
  1417. {
  1418. return acpi_video_bus_DOS(video, 0, 1);
  1419. }
  1420. static void
  1421. acpi_video_bus_notify (
  1422. acpi_handle handle,
  1423. u32 event,
  1424. void *data)
  1425. {
  1426. struct acpi_video_bus *video = (struct acpi_video_bus *) data;
  1427. struct acpi_device *device = NULL;
  1428. ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
  1429. printk("video bus notify\n");
  1430. if (!video)
  1431. return_VOID;
  1432. if (acpi_bus_get_device(handle, &device))
  1433. return_VOID;
  1434. switch (event) {
  1435. case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
  1436. * most likely via hotkey. */
  1437. acpi_bus_generate_event(device, event, 0);
  1438. break;
  1439. case ACPI_VIDEO_NOTIFY_PROBE: /* User plug or remove a video
  1440. * connector. */
  1441. acpi_video_device_enumerate(video);
  1442. acpi_video_device_rebind(video);
  1443. acpi_video_switch_output(video, event);
  1444. acpi_bus_generate_event(device, event, 0);
  1445. break;
  1446. case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed.*/
  1447. case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
  1448. case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
  1449. acpi_video_switch_output(video, event);
  1450. acpi_bus_generate_event(device, event, 0);
  1451. break;
  1452. default:
  1453. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  1454. "Unsupported event [0x%x]\n", event));
  1455. break;
  1456. }
  1457. return_VOID;
  1458. }
  1459. static void
  1460. acpi_video_device_notify (
  1461. acpi_handle handle,
  1462. u32 event,
  1463. void *data)
  1464. {
  1465. struct acpi_video_device *video_device = (struct acpi_video_device *) data;
  1466. struct acpi_device *device = NULL;
  1467. ACPI_FUNCTION_TRACE("acpi_video_device_notify");
  1468. printk("video device notify\n");
  1469. if (!video_device)
  1470. return_VOID;
  1471. if (acpi_bus_get_device(handle, &device))
  1472. return_VOID;
  1473. switch (event) {
  1474. case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
  1475. case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
  1476. acpi_bus_generate_event(device, event, 0);
  1477. break;
  1478. case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
  1479. case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
  1480. case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
  1481. case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
  1482. case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
  1483. acpi_video_switch_brightness (video_device, event);
  1484. acpi_bus_generate_event(device, event, 0);
  1485. break;
  1486. default:
  1487. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  1488. "Unsupported event [0x%x]\n", event));
  1489. break;
  1490. }
  1491. return_VOID;
  1492. }
  1493. static int
  1494. acpi_video_bus_add (
  1495. struct acpi_device *device)
  1496. {
  1497. int result = 0;
  1498. acpi_status status = 0;
  1499. struct acpi_video_bus *video = NULL;
  1500. ACPI_FUNCTION_TRACE("acpi_video_bus_add");
  1501. if (!device)
  1502. return_VALUE(-EINVAL);
  1503. video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
  1504. if (!video)
  1505. return_VALUE(-ENOMEM);
  1506. memset(video, 0, sizeof(struct acpi_video_bus));
  1507. video->handle = device->handle;
  1508. strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
  1509. strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
  1510. acpi_driver_data(device) = video;
  1511. acpi_video_bus_find_cap(video);
  1512. result = acpi_video_bus_check(video);
  1513. if (result)
  1514. goto end;
  1515. result = acpi_video_bus_add_fs(device);
  1516. if (result)
  1517. goto end;
  1518. init_MUTEX(&video->sem);
  1519. INIT_LIST_HEAD(&video->video_device_list);
  1520. acpi_video_bus_get_devices(video, device);
  1521. acpi_video_bus_start_devices(video);
  1522. status = acpi_install_notify_handler(video->handle,
  1523. ACPI_DEVICE_NOTIFY, acpi_video_bus_notify, video);
  1524. if (ACPI_FAILURE(status)) {
  1525. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  1526. "Error installing notify handler\n"));
  1527. result = -ENODEV;
  1528. goto end;
  1529. }
  1530. printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
  1531. ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
  1532. video->flags.multihead ? "yes":"no",
  1533. video->flags.rom ? "yes":"no",
  1534. video->flags.post ? "yes":"no");
  1535. end:
  1536. if (result) {
  1537. acpi_video_bus_remove_fs(device);
  1538. kfree(video);
  1539. }
  1540. return_VALUE(result);
  1541. }
  1542. static int
  1543. acpi_video_bus_remove (
  1544. struct acpi_device *device,
  1545. int type)
  1546. {
  1547. acpi_status status = 0;
  1548. struct acpi_video_bus *video = NULL;
  1549. ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
  1550. if (!device || !acpi_driver_data(device))
  1551. return_VALUE(-EINVAL);
  1552. video = (struct acpi_video_bus *) acpi_driver_data(device);
  1553. acpi_video_bus_stop_devices(video);
  1554. status = acpi_remove_notify_handler(video->handle,
  1555. ACPI_DEVICE_NOTIFY, acpi_video_bus_notify);
  1556. if (ACPI_FAILURE(status))
  1557. ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
  1558. "Error removing notify handler\n"));
  1559. acpi_video_bus_put_devices(video);
  1560. acpi_video_bus_remove_fs(device);
  1561. if (video->attached_array)
  1562. kfree(video->attached_array);
  1563. kfree(video);
  1564. return_VALUE(0);
  1565. }
  1566. static int
  1567. acpi_video_bus_match (
  1568. struct acpi_device *device,
  1569. struct acpi_driver *driver)
  1570. {
  1571. acpi_handle h_dummy1;
  1572. acpi_handle h_dummy2;
  1573. acpi_handle h_dummy3;
  1574. ACPI_FUNCTION_TRACE("acpi_video_bus_match");
  1575. if (!device || !driver)
  1576. return_VALUE(-EINVAL);
  1577. /* Since there is no HID, CID for ACPI Video drivers, we have
  1578. * to check well known required nodes for each feature we support.
  1579. */
  1580. /* Does this device able to support video switching ? */
  1581. if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
  1582. ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
  1583. return_VALUE(0);
  1584. /* Does this device able to retrieve a video ROM ? */
  1585. if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
  1586. return_VALUE(0);
  1587. /* Does this device able to configure which video head to be POSTed ? */
  1588. if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
  1589. ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
  1590. ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
  1591. return_VALUE(0);
  1592. return_VALUE(-ENODEV);
  1593. }
  1594. static int __init
  1595. acpi_video_init (void)
  1596. {
  1597. int result = 0;
  1598. ACPI_FUNCTION_TRACE("acpi_video_init");
  1599. /*
  1600. acpi_dbg_level = 0xFFFFFFFF;
  1601. acpi_dbg_layer = 0x08000000;
  1602. */
  1603. acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
  1604. if (!acpi_video_dir)
  1605. return_VALUE(-ENODEV);
  1606. acpi_video_dir->owner = THIS_MODULE;
  1607. result = acpi_bus_register_driver(&acpi_video_bus);
  1608. if (result < 0) {
  1609. remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
  1610. return_VALUE(-ENODEV);
  1611. }
  1612. return_VALUE(0);
  1613. }
  1614. static void __exit
  1615. acpi_video_exit (void)
  1616. {
  1617. ACPI_FUNCTION_TRACE("acpi_video_exit");
  1618. acpi_bus_unregister_driver(&acpi_video_bus);
  1619. remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
  1620. return_VOID;
  1621. }
  1622. module_init(acpi_video_init);
  1623. module_exit(acpi_video_exit);