video.c 49 KB

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