viafbdev.c 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150
  1. /*
  2. * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
  3. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License as published by the Free Software Foundation;
  7. * either version 2, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
  10. * the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. * A PARTICULAR PURPOSE.See the GNU General Public License
  12. * for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/slab.h>
  21. #include <linux/stat.h>
  22. #include <linux/via-core.h>
  23. #include <asm/olpc.h>
  24. #define _MASTER_FILE
  25. #include "global.h"
  26. static char *viafb_name = "Via";
  27. static u32 pseudo_pal[17];
  28. /* video mode */
  29. static char *viafb_mode;
  30. static char *viafb_mode1;
  31. static int viafb_bpp = 32;
  32. static int viafb_bpp1 = 32;
  33. static unsigned int viafb_second_xres = 640;
  34. static unsigned int viafb_second_yres = 480;
  35. static unsigned int viafb_second_offset;
  36. static int viafb_second_size;
  37. static int viafb_accel = 1;
  38. /* Added for specifying active devices.*/
  39. static char *viafb_active_dev;
  40. /*Added for specify lcd output port*/
  41. static char *viafb_lcd_port = "";
  42. static char *viafb_dvi_port = "";
  43. static void retrieve_device_setting(struct viafb_ioctl_setting
  44. *setting_info);
  45. static int viafb_pan_display(struct fb_var_screeninfo *var,
  46. struct fb_info *info);
  47. static struct fb_ops viafb_ops;
  48. /* supported output devices on each IGP
  49. * only CX700, VX800, VX855, VX900 were documented
  50. * VIA_CRT should be everywhere
  51. * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL
  52. * source selection on CX700 and later
  53. * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c
  54. */
  55. static const u32 supported_odev_map[] = {
  56. [UNICHROME_CLE266] = VIA_CRT | VIA_LDVP0 | VIA_LDVP1,
  57. [UNICHROME_K400] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
  58. | VIA_LVDS2,
  59. [UNICHROME_K800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
  60. | VIA_LVDS2,
  61. [UNICHROME_PM800] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
  62. | VIA_LVDS2,
  63. [UNICHROME_CN700] = VIA_CRT | VIA_DVP0 | VIA_DVP1 | VIA_LVDS1
  64. | VIA_LVDS2,
  65. [UNICHROME_CX700] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  66. [UNICHROME_CN750] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  67. [UNICHROME_K8M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  68. [UNICHROME_P4M890] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  69. [UNICHROME_P4M900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  70. [UNICHROME_VX800] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  71. [UNICHROME_VX855] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  72. [UNICHROME_VX900] = VIA_CRT | VIA_DVP1 | VIA_LVDS1 | VIA_LVDS2,
  73. };
  74. static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth)
  75. {
  76. var->grayscale = 0;
  77. var->red.msb_right = 0;
  78. var->green.msb_right = 0;
  79. var->blue.msb_right = 0;
  80. var->transp.offset = 0;
  81. var->transp.length = 0;
  82. var->transp.msb_right = 0;
  83. var->nonstd = 0;
  84. switch (depth) {
  85. case 8:
  86. var->bits_per_pixel = 8;
  87. var->red.offset = 0;
  88. var->green.offset = 0;
  89. var->blue.offset = 0;
  90. var->red.length = 8;
  91. var->green.length = 8;
  92. var->blue.length = 8;
  93. break;
  94. case 15:
  95. var->bits_per_pixel = 16;
  96. var->red.offset = 10;
  97. var->green.offset = 5;
  98. var->blue.offset = 0;
  99. var->red.length = 5;
  100. var->green.length = 5;
  101. var->blue.length = 5;
  102. break;
  103. case 16:
  104. var->bits_per_pixel = 16;
  105. var->red.offset = 11;
  106. var->green.offset = 5;
  107. var->blue.offset = 0;
  108. var->red.length = 5;
  109. var->green.length = 6;
  110. var->blue.length = 5;
  111. break;
  112. case 24:
  113. var->bits_per_pixel = 32;
  114. var->red.offset = 16;
  115. var->green.offset = 8;
  116. var->blue.offset = 0;
  117. var->red.length = 8;
  118. var->green.length = 8;
  119. var->blue.length = 8;
  120. break;
  121. case 30:
  122. var->bits_per_pixel = 32;
  123. var->red.offset = 20;
  124. var->green.offset = 10;
  125. var->blue.offset = 0;
  126. var->red.length = 10;
  127. var->green.length = 10;
  128. var->blue.length = 10;
  129. break;
  130. }
  131. }
  132. static void viafb_update_fix(struct fb_info *info)
  133. {
  134. u32 bpp = info->var.bits_per_pixel;
  135. info->fix.visual =
  136. bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
  137. info->fix.line_length = ALIGN(info->var.xres_virtual * bpp / 8,
  138. VIA_PITCH_SIZE);
  139. }
  140. static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
  141. struct viafb_par *viaparinfo)
  142. {
  143. memset(fix, 0, sizeof(struct fb_fix_screeninfo));
  144. strcpy(fix->id, viafb_name);
  145. fix->smem_start = viaparinfo->fbmem;
  146. fix->smem_len = viaparinfo->fbmem_free;
  147. fix->type = FB_TYPE_PACKED_PIXELS;
  148. fix->type_aux = 0;
  149. fix->visual = FB_VISUAL_TRUECOLOR;
  150. fix->xpanstep = fix->ywrapstep = 0;
  151. fix->ypanstep = 1;
  152. /* Just tell the accel name */
  153. viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
  154. }
  155. static int viafb_open(struct fb_info *info, int user)
  156. {
  157. DEBUG_MSG(KERN_INFO "viafb_open!\n");
  158. return 0;
  159. }
  160. static int viafb_release(struct fb_info *info, int user)
  161. {
  162. DEBUG_MSG(KERN_INFO "viafb_release!\n");
  163. return 0;
  164. }
  165. static inline int get_var_refresh(struct fb_var_screeninfo *var)
  166. {
  167. u32 htotal, vtotal;
  168. htotal = var->left_margin + var->xres + var->right_margin
  169. + var->hsync_len;
  170. vtotal = var->upper_margin + var->yres + var->lower_margin
  171. + var->vsync_len;
  172. return PICOS2KHZ(var->pixclock) * 1000 / (htotal * vtotal);
  173. }
  174. static int viafb_check_var(struct fb_var_screeninfo *var,
  175. struct fb_info *info)
  176. {
  177. int depth, refresh;
  178. struct VideoModeTable *vmode_entry;
  179. struct viafb_par *ppar = info->par;
  180. u32 line;
  181. DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
  182. /* Sanity check */
  183. /* HW neither support interlacte nor double-scaned mode */
  184. if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
  185. return -EINVAL;
  186. vmode_entry = viafb_get_mode(var->xres, var->yres);
  187. if (!vmode_entry) {
  188. DEBUG_MSG(KERN_INFO
  189. "viafb: Mode %dx%dx%d not supported!!\n",
  190. var->xres, var->yres, var->bits_per_pixel);
  191. return -EINVAL;
  192. }
  193. depth = fb_get_color_depth(var, &info->fix);
  194. if (!depth)
  195. depth = var->bits_per_pixel;
  196. if (depth < 0 || depth > 32)
  197. return -EINVAL;
  198. else if (!depth)
  199. depth = 24;
  200. else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1)
  201. depth = 15;
  202. else if (depth == 30)
  203. depth = 30;
  204. else if (depth <= 8)
  205. depth = 8;
  206. else if (depth <= 16)
  207. depth = 16;
  208. else
  209. depth = 24;
  210. viafb_fill_var_color_info(var, depth);
  211. if (var->xres_virtual < var->xres)
  212. var->xres_virtual = var->xres;
  213. line = ALIGN(var->xres_virtual * var->bits_per_pixel / 8,
  214. VIA_PITCH_SIZE);
  215. if (line > VIA_PITCH_MAX || line * var->yres_virtual > ppar->memsize)
  216. return -EINVAL;
  217. /* Based on var passed in to calculate the refresh,
  218. * because our driver use some modes special.
  219. */
  220. refresh = viafb_get_refresh(var->xres, var->yres,
  221. get_var_refresh(var));
  222. /* Adjust var according to our driver's own table */
  223. viafb_fill_var_timing_info(var, refresh, vmode_entry);
  224. if (var->accel_flags & FB_ACCELF_TEXT &&
  225. !ppar->shared->vdev->engine_mmio)
  226. var->accel_flags = 0;
  227. return 0;
  228. }
  229. static int viafb_set_par(struct fb_info *info)
  230. {
  231. struct viafb_par *viapar = info->par;
  232. struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
  233. int refresh;
  234. DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
  235. viafb_update_fix(info);
  236. viapar->depth = fb_get_color_depth(&info->var, &info->fix);
  237. viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres,
  238. viafbinfo->var.bits_per_pixel, 0);
  239. vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres);
  240. if (viafb_dual_fb) {
  241. vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres,
  242. viafbinfo1->var.yres);
  243. viafb_update_device_setting(viafbinfo1->var.xres,
  244. viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel,
  245. 1);
  246. } else if (viafb_SAMM_ON == 1) {
  247. DEBUG_MSG(KERN_INFO
  248. "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
  249. viafb_second_xres, viafb_second_yres, viafb_bpp1);
  250. vmode_entry1 = viafb_get_mode(viafb_second_xres,
  251. viafb_second_yres);
  252. viafb_update_device_setting(viafb_second_xres,
  253. viafb_second_yres, viafb_bpp1, 1);
  254. }
  255. refresh = viafb_get_refresh(info->var.xres, info->var.yres,
  256. get_var_refresh(&info->var));
  257. if (vmode_entry) {
  258. if (viafb_dual_fb && viapar->iga_path == IGA2) {
  259. viafb_bpp1 = info->var.bits_per_pixel;
  260. viafb_refresh1 = refresh;
  261. } else {
  262. viafb_bpp = info->var.bits_per_pixel;
  263. viafb_refresh = refresh;
  264. }
  265. if (info->var.accel_flags & FB_ACCELF_TEXT)
  266. info->flags &= ~FBINFO_HWACCEL_DISABLED;
  267. else
  268. info->flags |= FBINFO_HWACCEL_DISABLED;
  269. viafb_setmode(vmode_entry, info->var.bits_per_pixel,
  270. vmode_entry1, viafb_bpp1);
  271. viafb_pan_display(&info->var, info);
  272. }
  273. return 0;
  274. }
  275. /* Set one color register */
  276. static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
  277. unsigned blue, unsigned transp, struct fb_info *info)
  278. {
  279. struct viafb_par *viapar = info->par;
  280. u32 r, g, b;
  281. if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
  282. if (regno > 255)
  283. return -EINVAL;
  284. if (!viafb_dual_fb || viapar->iga_path == IGA1)
  285. viafb_set_primary_color_register(regno, red >> 8,
  286. green >> 8, blue >> 8);
  287. if (!viafb_dual_fb || viapar->iga_path == IGA2)
  288. viafb_set_secondary_color_register(regno, red >> 8,
  289. green >> 8, blue >> 8);
  290. } else {
  291. if (regno > 15)
  292. return -EINVAL;
  293. r = (red >> (16 - info->var.red.length))
  294. << info->var.red.offset;
  295. b = (blue >> (16 - info->var.blue.length))
  296. << info->var.blue.offset;
  297. g = (green >> (16 - info->var.green.length))
  298. << info->var.green.offset;
  299. ((u32 *) info->pseudo_palette)[regno] = r | g | b;
  300. }
  301. return 0;
  302. }
  303. static int viafb_pan_display(struct fb_var_screeninfo *var,
  304. struct fb_info *info)
  305. {
  306. struct viafb_par *viapar = info->par;
  307. u32 vram_addr = viapar->vram_addr
  308. + var->yoffset * info->fix.line_length
  309. + var->xoffset * info->var.bits_per_pixel / 8;
  310. DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr);
  311. if (!viafb_dual_fb) {
  312. via_set_primary_address(vram_addr);
  313. via_set_secondary_address(vram_addr);
  314. } else if (viapar->iga_path == IGA1)
  315. via_set_primary_address(vram_addr);
  316. else
  317. via_set_secondary_address(vram_addr);
  318. return 0;
  319. }
  320. static int viafb_blank(int blank_mode, struct fb_info *info)
  321. {
  322. DEBUG_MSG(KERN_INFO "viafb_blank!\n");
  323. /* clear DPMS setting */
  324. switch (blank_mode) {
  325. case FB_BLANK_UNBLANK:
  326. /* Screen: On, HSync: On, VSync: On */
  327. /* control CRT monitor power management */
  328. via_set_state(VIA_CRT, VIA_STATE_ON);
  329. break;
  330. case FB_BLANK_HSYNC_SUSPEND:
  331. /* Screen: Off, HSync: Off, VSync: On */
  332. /* control CRT monitor power management */
  333. via_set_state(VIA_CRT, VIA_STATE_STANDBY);
  334. break;
  335. case FB_BLANK_VSYNC_SUSPEND:
  336. /* Screen: Off, HSync: On, VSync: Off */
  337. /* control CRT monitor power management */
  338. via_set_state(VIA_CRT, VIA_STATE_SUSPEND);
  339. break;
  340. case FB_BLANK_POWERDOWN:
  341. /* Screen: Off, HSync: Off, VSync: Off */
  342. /* control CRT monitor power management */
  343. via_set_state(VIA_CRT, VIA_STATE_OFF);
  344. break;
  345. }
  346. return 0;
  347. }
  348. static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
  349. {
  350. union {
  351. struct viafb_ioctl_mode viamode;
  352. struct viafb_ioctl_samm viasamm;
  353. struct viafb_driver_version driver_version;
  354. struct fb_var_screeninfo sec_var;
  355. struct _panel_size_pos_info panel_pos_size_para;
  356. struct viafb_ioctl_setting viafb_setting;
  357. struct device_t active_dev;
  358. } u;
  359. u32 state_info = 0;
  360. u32 *viafb_gamma_table;
  361. char driver_name[] = "viafb";
  362. u32 __user *argp = (u32 __user *) arg;
  363. u32 gpu32;
  364. DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
  365. printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
  366. memset(&u, 0, sizeof(u));
  367. switch (cmd) {
  368. case VIAFB_GET_CHIP_INFO:
  369. if (copy_to_user(argp, viaparinfo->chip_info,
  370. sizeof(struct chip_information)))
  371. return -EFAULT;
  372. break;
  373. case VIAFB_GET_INFO_SIZE:
  374. return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
  375. case VIAFB_GET_INFO:
  376. return viafb_ioctl_get_viafb_info(arg);
  377. case VIAFB_HOTPLUG:
  378. return put_user(viafb_ioctl_hotplug(info->var.xres,
  379. info->var.yres,
  380. info->var.bits_per_pixel), argp);
  381. case VIAFB_SET_HOTPLUG_FLAG:
  382. if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
  383. return -EFAULT;
  384. viafb_hotplug = (gpu32) ? 1 : 0;
  385. break;
  386. case VIAFB_GET_RESOLUTION:
  387. u.viamode.xres = (u32) viafb_hotplug_Xres;
  388. u.viamode.yres = (u32) viafb_hotplug_Yres;
  389. u.viamode.refresh = (u32) viafb_hotplug_refresh;
  390. u.viamode.bpp = (u32) viafb_hotplug_bpp;
  391. if (viafb_SAMM_ON == 1) {
  392. u.viamode.xres_sec = viafb_second_xres;
  393. u.viamode.yres_sec = viafb_second_yres;
  394. u.viamode.virtual_xres_sec = viafb_dual_fb ? viafbinfo1->var.xres_virtual : viafbinfo->var.xres_virtual;
  395. u.viamode.virtual_yres_sec = viafb_dual_fb ? viafbinfo1->var.yres_virtual : viafbinfo->var.yres_virtual;
  396. u.viamode.refresh_sec = viafb_refresh1;
  397. u.viamode.bpp_sec = viafb_bpp1;
  398. } else {
  399. u.viamode.xres_sec = 0;
  400. u.viamode.yres_sec = 0;
  401. u.viamode.virtual_xres_sec = 0;
  402. u.viamode.virtual_yres_sec = 0;
  403. u.viamode.refresh_sec = 0;
  404. u.viamode.bpp_sec = 0;
  405. }
  406. if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
  407. return -EFAULT;
  408. break;
  409. case VIAFB_GET_SAMM_INFO:
  410. u.viasamm.samm_status = viafb_SAMM_ON;
  411. if (viafb_SAMM_ON == 1) {
  412. if (viafb_dual_fb) {
  413. u.viasamm.size_prim = viaparinfo->fbmem_free;
  414. u.viasamm.size_sec = viaparinfo1->fbmem_free;
  415. } else {
  416. if (viafb_second_size) {
  417. u.viasamm.size_prim =
  418. viaparinfo->fbmem_free -
  419. viafb_second_size * 1024 * 1024;
  420. u.viasamm.size_sec =
  421. viafb_second_size * 1024 * 1024;
  422. } else {
  423. u.viasamm.size_prim =
  424. viaparinfo->fbmem_free >> 1;
  425. u.viasamm.size_sec =
  426. (viaparinfo->fbmem_free >> 1);
  427. }
  428. }
  429. u.viasamm.mem_base = viaparinfo->fbmem;
  430. u.viasamm.offset_sec = viafb_second_offset;
  431. } else {
  432. u.viasamm.size_prim =
  433. viaparinfo->memsize - viaparinfo->fbmem_used;
  434. u.viasamm.size_sec = 0;
  435. u.viasamm.mem_base = viaparinfo->fbmem;
  436. u.viasamm.offset_sec = 0;
  437. }
  438. if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
  439. return -EFAULT;
  440. break;
  441. case VIAFB_TURN_ON_OUTPUT_DEVICE:
  442. if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
  443. return -EFAULT;
  444. if (gpu32 & CRT_Device)
  445. via_set_state(VIA_CRT, VIA_STATE_ON);
  446. if (gpu32 & DVI_Device)
  447. viafb_dvi_enable();
  448. if (gpu32 & LCD_Device)
  449. viafb_lcd_enable();
  450. break;
  451. case VIAFB_TURN_OFF_OUTPUT_DEVICE:
  452. if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
  453. return -EFAULT;
  454. if (gpu32 & CRT_Device)
  455. via_set_state(VIA_CRT, VIA_STATE_OFF);
  456. if (gpu32 & DVI_Device)
  457. viafb_dvi_disable();
  458. if (gpu32 & LCD_Device)
  459. viafb_lcd_disable();
  460. break;
  461. case VIAFB_GET_DEVICE:
  462. u.active_dev.crt = viafb_CRT_ON;
  463. u.active_dev.dvi = viafb_DVI_ON;
  464. u.active_dev.lcd = viafb_LCD_ON;
  465. u.active_dev.samm = viafb_SAMM_ON;
  466. u.active_dev.primary_dev = viafb_primary_dev;
  467. u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
  468. u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
  469. u.active_dev.lcd_mode = viafb_lcd_mode;
  470. u.active_dev.xres = viafb_hotplug_Xres;
  471. u.active_dev.yres = viafb_hotplug_Yres;
  472. u.active_dev.xres1 = viafb_second_xres;
  473. u.active_dev.yres1 = viafb_second_yres;
  474. u.active_dev.bpp = viafb_bpp;
  475. u.active_dev.bpp1 = viafb_bpp1;
  476. u.active_dev.refresh = viafb_refresh;
  477. u.active_dev.refresh1 = viafb_refresh1;
  478. u.active_dev.epia_dvi = viafb_platform_epia_dvi;
  479. u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
  480. u.active_dev.bus_width = viafb_bus_width;
  481. if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
  482. return -EFAULT;
  483. break;
  484. case VIAFB_GET_DRIVER_VERSION:
  485. u.driver_version.iMajorNum = VERSION_MAJOR;
  486. u.driver_version.iKernelNum = VERSION_KERNEL;
  487. u.driver_version.iOSNum = VERSION_OS;
  488. u.driver_version.iMinorNum = VERSION_MINOR;
  489. if (copy_to_user(argp, &u.driver_version,
  490. sizeof(u.driver_version)))
  491. return -EFAULT;
  492. break;
  493. case VIAFB_GET_DEVICE_INFO:
  494. retrieve_device_setting(&u.viafb_setting);
  495. if (copy_to_user(argp, &u.viafb_setting,
  496. sizeof(u.viafb_setting)))
  497. return -EFAULT;
  498. break;
  499. case VIAFB_GET_DEVICE_SUPPORT:
  500. viafb_get_device_support_state(&state_info);
  501. if (put_user(state_info, argp))
  502. return -EFAULT;
  503. break;
  504. case VIAFB_GET_DEVICE_CONNECT:
  505. viafb_get_device_connect_state(&state_info);
  506. if (put_user(state_info, argp))
  507. return -EFAULT;
  508. break;
  509. case VIAFB_GET_PANEL_SUPPORT_EXPAND:
  510. state_info =
  511. viafb_lcd_get_support_expand_state(info->var.xres,
  512. info->var.yres);
  513. if (put_user(state_info, argp))
  514. return -EFAULT;
  515. break;
  516. case VIAFB_GET_DRIVER_NAME:
  517. if (copy_to_user(argp, driver_name, sizeof(driver_name)))
  518. return -EFAULT;
  519. break;
  520. case VIAFB_SET_GAMMA_LUT:
  521. viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32));
  522. if (IS_ERR(viafb_gamma_table))
  523. return PTR_ERR(viafb_gamma_table);
  524. viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
  525. kfree(viafb_gamma_table);
  526. break;
  527. case VIAFB_GET_GAMMA_LUT:
  528. viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
  529. if (!viafb_gamma_table)
  530. return -ENOMEM;
  531. viafb_get_gamma_table(viafb_gamma_table);
  532. if (copy_to_user(argp, viafb_gamma_table,
  533. 256 * sizeof(u32))) {
  534. kfree(viafb_gamma_table);
  535. return -EFAULT;
  536. }
  537. kfree(viafb_gamma_table);
  538. break;
  539. case VIAFB_GET_GAMMA_SUPPORT_STATE:
  540. viafb_get_gamma_support_state(viafb_bpp, &state_info);
  541. if (put_user(state_info, argp))
  542. return -EFAULT;
  543. break;
  544. case VIAFB_SYNC_SURFACE:
  545. DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
  546. break;
  547. case VIAFB_GET_DRIVER_CAPS:
  548. break;
  549. case VIAFB_GET_PANEL_MAX_SIZE:
  550. if (copy_from_user(&u.panel_pos_size_para, argp,
  551. sizeof(u.panel_pos_size_para)))
  552. return -EFAULT;
  553. u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
  554. if (copy_to_user(argp, &u.panel_pos_size_para,
  555. sizeof(u.panel_pos_size_para)))
  556. return -EFAULT;
  557. break;
  558. case VIAFB_GET_PANEL_MAX_POSITION:
  559. if (copy_from_user(&u.panel_pos_size_para, argp,
  560. sizeof(u.panel_pos_size_para)))
  561. return -EFAULT;
  562. u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
  563. if (copy_to_user(argp, &u.panel_pos_size_para,
  564. sizeof(u.panel_pos_size_para)))
  565. return -EFAULT;
  566. break;
  567. case VIAFB_GET_PANEL_POSITION:
  568. if (copy_from_user(&u.panel_pos_size_para, argp,
  569. sizeof(u.panel_pos_size_para)))
  570. return -EFAULT;
  571. u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
  572. if (copy_to_user(argp, &u.panel_pos_size_para,
  573. sizeof(u.panel_pos_size_para)))
  574. return -EFAULT;
  575. break;
  576. case VIAFB_GET_PANEL_SIZE:
  577. if (copy_from_user(&u.panel_pos_size_para, argp,
  578. sizeof(u.panel_pos_size_para)))
  579. return -EFAULT;
  580. u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
  581. if (copy_to_user(argp, &u.panel_pos_size_para,
  582. sizeof(u.panel_pos_size_para)))
  583. return -EFAULT;
  584. break;
  585. case VIAFB_SET_PANEL_POSITION:
  586. if (copy_from_user(&u.panel_pos_size_para, argp,
  587. sizeof(u.panel_pos_size_para)))
  588. return -EFAULT;
  589. break;
  590. case VIAFB_SET_PANEL_SIZE:
  591. if (copy_from_user(&u.panel_pos_size_para, argp,
  592. sizeof(u.panel_pos_size_para)))
  593. return -EFAULT;
  594. break;
  595. default:
  596. return -EINVAL;
  597. }
  598. return 0;
  599. }
  600. static void viafb_fillrect(struct fb_info *info,
  601. const struct fb_fillrect *rect)
  602. {
  603. struct viafb_par *viapar = info->par;
  604. struct viafb_shared *shared = viapar->shared;
  605. u32 fg_color;
  606. u8 rop;
  607. if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
  608. cfb_fillrect(info, rect);
  609. return;
  610. }
  611. if (!rect->width || !rect->height)
  612. return;
  613. if (info->fix.visual == FB_VISUAL_TRUECOLOR)
  614. fg_color = ((u32 *)info->pseudo_palette)[rect->color];
  615. else
  616. fg_color = rect->color;
  617. if (rect->rop == ROP_XOR)
  618. rop = 0x5A;
  619. else
  620. rop = 0xF0;
  621. DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
  622. if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_FILL,
  623. rect->width, rect->height, info->var.bits_per_pixel,
  624. viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
  625. NULL, 0, 0, 0, 0, fg_color, 0, rop))
  626. cfb_fillrect(info, rect);
  627. }
  628. static void viafb_copyarea(struct fb_info *info,
  629. const struct fb_copyarea *area)
  630. {
  631. struct viafb_par *viapar = info->par;
  632. struct viafb_shared *shared = viapar->shared;
  633. if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
  634. cfb_copyarea(info, area);
  635. return;
  636. }
  637. if (!area->width || !area->height)
  638. return;
  639. DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
  640. if (shared->hw_bitblt(shared->vdev->engine_mmio, VIA_BITBLT_COLOR,
  641. area->width, area->height, info->var.bits_per_pixel,
  642. viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
  643. NULL, viapar->vram_addr, info->fix.line_length,
  644. area->sx, area->sy, 0, 0, 0))
  645. cfb_copyarea(info, area);
  646. }
  647. static void viafb_imageblit(struct fb_info *info,
  648. const struct fb_image *image)
  649. {
  650. struct viafb_par *viapar = info->par;
  651. struct viafb_shared *shared = viapar->shared;
  652. u32 fg_color = 0, bg_color = 0;
  653. u8 op;
  654. if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt ||
  655. (image->depth != 1 && image->depth != viapar->depth)) {
  656. cfb_imageblit(info, image);
  657. return;
  658. }
  659. if (image->depth == 1) {
  660. op = VIA_BITBLT_MONO;
  661. if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
  662. fg_color =
  663. ((u32 *)info->pseudo_palette)[image->fg_color];
  664. bg_color =
  665. ((u32 *)info->pseudo_palette)[image->bg_color];
  666. } else {
  667. fg_color = image->fg_color;
  668. bg_color = image->bg_color;
  669. }
  670. } else
  671. op = VIA_BITBLT_COLOR;
  672. DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
  673. if (shared->hw_bitblt(shared->vdev->engine_mmio, op,
  674. image->width, image->height, info->var.bits_per_pixel,
  675. viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
  676. (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
  677. cfb_imageblit(info, image);
  678. }
  679. static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
  680. {
  681. struct viafb_par *viapar = info->par;
  682. void __iomem *engine = viapar->shared->vdev->engine_mmio;
  683. u32 temp, xx, yy, bg_color = 0, fg_color = 0,
  684. chip_name = viapar->shared->chip_info.gfx_chip_name;
  685. int i, j = 0, cur_size = 64;
  686. if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
  687. return -ENODEV;
  688. /* LCD ouput does not support hw cursors (at least on VN896) */
  689. if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
  690. viafb_LCD_ON)
  691. return -ENODEV;
  692. viafb_show_hw_cursor(info, HW_Cursor_OFF);
  693. if (cursor->set & FB_CUR_SETHOT) {
  694. temp = (cursor->hot.x << 16) + cursor->hot.y;
  695. writel(temp, engine + VIA_REG_CURSOR_ORG);
  696. }
  697. if (cursor->set & FB_CUR_SETPOS) {
  698. yy = cursor->image.dy - info->var.yoffset;
  699. xx = cursor->image.dx - info->var.xoffset;
  700. temp = yy & 0xFFFF;
  701. temp |= (xx << 16);
  702. writel(temp, engine + VIA_REG_CURSOR_POS);
  703. }
  704. if (cursor->image.width <= 32 && cursor->image.height <= 32)
  705. cur_size = 32;
  706. else if (cursor->image.width <= 64 && cursor->image.height <= 64)
  707. cur_size = 64;
  708. else {
  709. printk(KERN_WARNING "viafb_cursor: The cursor is too large "
  710. "%dx%d", cursor->image.width, cursor->image.height);
  711. return -ENXIO;
  712. }
  713. if (cursor->set & FB_CUR_SETSIZE) {
  714. temp = readl(engine + VIA_REG_CURSOR_MODE);
  715. if (cur_size == 32)
  716. temp |= 0x2;
  717. else
  718. temp &= ~0x2;
  719. writel(temp, engine + VIA_REG_CURSOR_MODE);
  720. }
  721. if (cursor->set & FB_CUR_SETCMAP) {
  722. fg_color = cursor->image.fg_color;
  723. bg_color = cursor->image.bg_color;
  724. if (chip_name == UNICHROME_CX700 ||
  725. chip_name == UNICHROME_VX800 ||
  726. chip_name == UNICHROME_VX855 ||
  727. chip_name == UNICHROME_VX900) {
  728. fg_color =
  729. ((info->cmap.red[fg_color] & 0xFFC0) << 14) |
  730. ((info->cmap.green[fg_color] & 0xFFC0) << 4) |
  731. ((info->cmap.blue[fg_color] & 0xFFC0) >> 6);
  732. bg_color =
  733. ((info->cmap.red[bg_color] & 0xFFC0) << 14) |
  734. ((info->cmap.green[bg_color] & 0xFFC0) << 4) |
  735. ((info->cmap.blue[bg_color] & 0xFFC0) >> 6);
  736. } else {
  737. fg_color =
  738. ((info->cmap.red[fg_color] & 0xFF00) << 8) |
  739. (info->cmap.green[fg_color] & 0xFF00) |
  740. ((info->cmap.blue[fg_color] & 0xFF00) >> 8);
  741. bg_color =
  742. ((info->cmap.red[bg_color] & 0xFF00) << 8) |
  743. (info->cmap.green[bg_color] & 0xFF00) |
  744. ((info->cmap.blue[bg_color] & 0xFF00) >> 8);
  745. }
  746. writel(bg_color, engine + VIA_REG_CURSOR_BG);
  747. writel(fg_color, engine + VIA_REG_CURSOR_FG);
  748. }
  749. if (cursor->set & FB_CUR_SETSHAPE) {
  750. struct {
  751. u8 data[CURSOR_SIZE];
  752. u32 bak[CURSOR_SIZE / 4];
  753. } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
  754. int size = ((cursor->image.width + 7) >> 3) *
  755. cursor->image.height;
  756. if (!cr_data)
  757. return -ENOMEM;
  758. if (cur_size == 32) {
  759. for (i = 0; i < (CURSOR_SIZE / 4); i++) {
  760. cr_data->bak[i] = 0x0;
  761. cr_data->bak[i + 1] = 0xFFFFFFFF;
  762. i += 1;
  763. }
  764. } else {
  765. for (i = 0; i < (CURSOR_SIZE / 4); i++) {
  766. cr_data->bak[i] = 0x0;
  767. cr_data->bak[i + 1] = 0x0;
  768. cr_data->bak[i + 2] = 0xFFFFFFFF;
  769. cr_data->bak[i + 3] = 0xFFFFFFFF;
  770. i += 3;
  771. }
  772. }
  773. switch (cursor->rop) {
  774. case ROP_XOR:
  775. for (i = 0; i < size; i++)
  776. cr_data->data[i] = cursor->mask[i];
  777. break;
  778. case ROP_COPY:
  779. for (i = 0; i < size; i++)
  780. cr_data->data[i] = cursor->mask[i];
  781. break;
  782. default:
  783. break;
  784. }
  785. if (cur_size == 32) {
  786. for (i = 0; i < size; i++) {
  787. cr_data->bak[j] = (u32) cr_data->data[i];
  788. cr_data->bak[j + 1] = ~cr_data->bak[j];
  789. j += 2;
  790. }
  791. } else {
  792. for (i = 0; i < size; i++) {
  793. cr_data->bak[j] = (u32) cr_data->data[i];
  794. cr_data->bak[j + 1] = 0x0;
  795. cr_data->bak[j + 2] = ~cr_data->bak[j];
  796. cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
  797. j += 4;
  798. }
  799. }
  800. memcpy_toio(viafbinfo->screen_base + viapar->shared->
  801. cursor_vram_addr, cr_data->bak, CURSOR_SIZE);
  802. kfree(cr_data);
  803. }
  804. if (cursor->enable)
  805. viafb_show_hw_cursor(info, HW_Cursor_ON);
  806. return 0;
  807. }
  808. static int viafb_sync(struct fb_info *info)
  809. {
  810. if (!(info->flags & FBINFO_HWACCEL_DISABLED))
  811. viafb_wait_engine_idle(info);
  812. return 0;
  813. }
  814. static int get_primary_device(void)
  815. {
  816. int primary_device = 0;
  817. /* Rule: device on iga1 path are the primary device. */
  818. if (viafb_SAMM_ON) {
  819. if (viafb_CRT_ON) {
  820. if (viaparinfo->shared->iga1_devices & VIA_CRT) {
  821. DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n", IGA1);
  822. primary_device = CRT_Device;
  823. }
  824. }
  825. if (viafb_DVI_ON) {
  826. if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
  827. DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
  828. viaparinfo->
  829. tmds_setting_info->iga_path);
  830. primary_device = DVI_Device;
  831. }
  832. }
  833. if (viafb_LCD_ON) {
  834. if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
  835. DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
  836. viaparinfo->
  837. lvds_setting_info->iga_path);
  838. primary_device = LCD_Device;
  839. }
  840. }
  841. if (viafb_LCD2_ON) {
  842. if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
  843. DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
  844. viaparinfo->
  845. lvds_setting_info2->iga_path);
  846. primary_device = LCD2_Device;
  847. }
  848. }
  849. }
  850. return primary_device;
  851. }
  852. static void retrieve_device_setting(struct viafb_ioctl_setting
  853. *setting_info)
  854. {
  855. /* get device status */
  856. if (viafb_CRT_ON == 1)
  857. setting_info->device_status = CRT_Device;
  858. if (viafb_DVI_ON == 1)
  859. setting_info->device_status |= DVI_Device;
  860. if (viafb_LCD_ON == 1)
  861. setting_info->device_status |= LCD_Device;
  862. if (viafb_LCD2_ON == 1)
  863. setting_info->device_status |= LCD2_Device;
  864. setting_info->samm_status = viafb_SAMM_ON;
  865. setting_info->primary_device = get_primary_device();
  866. setting_info->first_dev_bpp = viafb_bpp;
  867. setting_info->second_dev_bpp = viafb_bpp1;
  868. setting_info->first_dev_refresh = viafb_refresh;
  869. setting_info->second_dev_refresh = viafb_refresh1;
  870. setting_info->first_dev_hor_res = viafb_hotplug_Xres;
  871. setting_info->first_dev_ver_res = viafb_hotplug_Yres;
  872. setting_info->second_dev_hor_res = viafb_second_xres;
  873. setting_info->second_dev_ver_res = viafb_second_yres;
  874. /* Get lcd attributes */
  875. setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
  876. setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
  877. setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
  878. }
  879. static int __init parse_active_dev(void)
  880. {
  881. viafb_CRT_ON = STATE_OFF;
  882. viafb_DVI_ON = STATE_OFF;
  883. viafb_LCD_ON = STATE_OFF;
  884. viafb_LCD2_ON = STATE_OFF;
  885. /* 1. Modify the active status of devices. */
  886. /* 2. Keep the order of devices, so we can set corresponding
  887. IGA path to devices in SAMM case. */
  888. /* Note: The previous of active_dev is primary device,
  889. and the following is secondary device. */
  890. if (!viafb_active_dev) {
  891. if (machine_is_olpc()) { /* LCD only */
  892. viafb_LCD_ON = STATE_ON;
  893. viafb_SAMM_ON = STATE_OFF;
  894. } else {
  895. viafb_CRT_ON = STATE_ON;
  896. viafb_SAMM_ON = STATE_OFF;
  897. }
  898. } else if (!strcmp(viafb_active_dev, "CRT+DVI")) {
  899. /* CRT+DVI */
  900. viafb_CRT_ON = STATE_ON;
  901. viafb_DVI_ON = STATE_ON;
  902. viafb_primary_dev = CRT_Device;
  903. } else if (!strcmp(viafb_active_dev, "DVI+CRT")) {
  904. /* DVI+CRT */
  905. viafb_CRT_ON = STATE_ON;
  906. viafb_DVI_ON = STATE_ON;
  907. viafb_primary_dev = DVI_Device;
  908. } else if (!strcmp(viafb_active_dev, "CRT+LCD")) {
  909. /* CRT+LCD */
  910. viafb_CRT_ON = STATE_ON;
  911. viafb_LCD_ON = STATE_ON;
  912. viafb_primary_dev = CRT_Device;
  913. } else if (!strcmp(viafb_active_dev, "LCD+CRT")) {
  914. /* LCD+CRT */
  915. viafb_CRT_ON = STATE_ON;
  916. viafb_LCD_ON = STATE_ON;
  917. viafb_primary_dev = LCD_Device;
  918. } else if (!strcmp(viafb_active_dev, "DVI+LCD")) {
  919. /* DVI+LCD */
  920. viafb_DVI_ON = STATE_ON;
  921. viafb_LCD_ON = STATE_ON;
  922. viafb_primary_dev = DVI_Device;
  923. } else if (!strcmp(viafb_active_dev, "LCD+DVI")) {
  924. /* LCD+DVI */
  925. viafb_DVI_ON = STATE_ON;
  926. viafb_LCD_ON = STATE_ON;
  927. viafb_primary_dev = LCD_Device;
  928. } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) {
  929. viafb_LCD_ON = STATE_ON;
  930. viafb_LCD2_ON = STATE_ON;
  931. viafb_primary_dev = LCD_Device;
  932. } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) {
  933. viafb_LCD_ON = STATE_ON;
  934. viafb_LCD2_ON = STATE_ON;
  935. viafb_primary_dev = LCD2_Device;
  936. } else if (!strcmp(viafb_active_dev, "CRT")) {
  937. /* CRT only */
  938. viafb_CRT_ON = STATE_ON;
  939. viafb_SAMM_ON = STATE_OFF;
  940. } else if (!strcmp(viafb_active_dev, "DVI")) {
  941. /* DVI only */
  942. viafb_DVI_ON = STATE_ON;
  943. viafb_SAMM_ON = STATE_OFF;
  944. } else if (!strcmp(viafb_active_dev, "LCD")) {
  945. /* LCD only */
  946. viafb_LCD_ON = STATE_ON;
  947. viafb_SAMM_ON = STATE_OFF;
  948. } else
  949. return -EINVAL;
  950. return 0;
  951. }
  952. static int __devinit parse_port(char *opt_str, int *output_interface)
  953. {
  954. if (!strncmp(opt_str, "DVP0", 4))
  955. *output_interface = INTERFACE_DVP0;
  956. else if (!strncmp(opt_str, "DVP1", 4))
  957. *output_interface = INTERFACE_DVP1;
  958. else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
  959. *output_interface = INTERFACE_DFP;
  960. else if (!strncmp(opt_str, "DFP_HIGH", 8))
  961. *output_interface = INTERFACE_DFP_HIGH;
  962. else if (!strncmp(opt_str, "DFP_LOW", 7))
  963. *output_interface = INTERFACE_DFP_LOW;
  964. else
  965. *output_interface = INTERFACE_NONE;
  966. return 0;
  967. }
  968. static void __devinit parse_lcd_port(void)
  969. {
  970. parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
  971. output_interface);
  972. /*Initialize to avoid unexpected behavior */
  973. viaparinfo->chip_info->lvds_chip_info2.output_interface =
  974. INTERFACE_NONE;
  975. DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
  976. viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
  977. output_interface);
  978. }
  979. static void __devinit parse_dvi_port(void)
  980. {
  981. parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
  982. output_interface);
  983. DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
  984. viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
  985. output_interface);
  986. }
  987. #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
  988. /*
  989. * The proc filesystem read/write function, a simple proc implement to
  990. * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
  991. * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
  992. * CR9B, SR65, CR97, CR99
  993. */
  994. static int viafb_dvp0_proc_show(struct seq_file *m, void *v)
  995. {
  996. u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
  997. dvp0_data_dri =
  998. (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
  999. (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
  1000. dvp0_clk_dri =
  1001. (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
  1002. (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
  1003. dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
  1004. seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
  1005. return 0;
  1006. }
  1007. static int viafb_dvp0_proc_open(struct inode *inode, struct file *file)
  1008. {
  1009. return single_open(file, viafb_dvp0_proc_show, NULL);
  1010. }
  1011. static ssize_t viafb_dvp0_proc_write(struct file *file,
  1012. const char __user *buffer, size_t count, loff_t *pos)
  1013. {
  1014. char buf[20], *value, *pbuf;
  1015. u8 reg_val = 0;
  1016. unsigned long length, i;
  1017. if (count < 1)
  1018. return -EINVAL;
  1019. length = count > 20 ? 20 : count;
  1020. if (copy_from_user(&buf[0], buffer, length))
  1021. return -EFAULT;
  1022. buf[length - 1] = '\0'; /*Ensure end string */
  1023. pbuf = &buf[0];
  1024. for (i = 0; i < 3; i++) {
  1025. value = strsep(&pbuf, " ");
  1026. if (value != NULL) {
  1027. strict_strtoul(value, 0, (unsigned long *)&reg_val);
  1028. DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
  1029. reg_val);
  1030. switch (i) {
  1031. case 0:
  1032. viafb_write_reg_mask(CR96, VIACR,
  1033. reg_val, 0x0f);
  1034. break;
  1035. case 1:
  1036. viafb_write_reg_mask(SR2A, VIASR,
  1037. reg_val << 4, BIT5);
  1038. viafb_write_reg_mask(SR1B, VIASR,
  1039. reg_val << 1, BIT1);
  1040. break;
  1041. case 2:
  1042. viafb_write_reg_mask(SR2A, VIASR,
  1043. reg_val << 3, BIT4);
  1044. viafb_write_reg_mask(SR1E, VIASR,
  1045. reg_val << 2, BIT2);
  1046. break;
  1047. default:
  1048. break;
  1049. }
  1050. } else {
  1051. break;
  1052. }
  1053. }
  1054. return count;
  1055. }
  1056. static const struct file_operations viafb_dvp0_proc_fops = {
  1057. .owner = THIS_MODULE,
  1058. .open = viafb_dvp0_proc_open,
  1059. .read = seq_read,
  1060. .llseek = seq_lseek,
  1061. .release = single_release,
  1062. .write = viafb_dvp0_proc_write,
  1063. };
  1064. static int viafb_dvp1_proc_show(struct seq_file *m, void *v)
  1065. {
  1066. u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
  1067. dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
  1068. dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
  1069. dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
  1070. seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
  1071. return 0;
  1072. }
  1073. static int viafb_dvp1_proc_open(struct inode *inode, struct file *file)
  1074. {
  1075. return single_open(file, viafb_dvp1_proc_show, NULL);
  1076. }
  1077. static ssize_t viafb_dvp1_proc_write(struct file *file,
  1078. const char __user *buffer, size_t count, loff_t *pos)
  1079. {
  1080. char buf[20], *value, *pbuf;
  1081. u8 reg_val = 0;
  1082. unsigned long length, i;
  1083. if (count < 1)
  1084. return -EINVAL;
  1085. length = count > 20 ? 20 : count;
  1086. if (copy_from_user(&buf[0], buffer, length))
  1087. return -EFAULT;
  1088. buf[length - 1] = '\0'; /*Ensure end string */
  1089. pbuf = &buf[0];
  1090. for (i = 0; i < 3; i++) {
  1091. value = strsep(&pbuf, " ");
  1092. if (value != NULL) {
  1093. strict_strtoul(value, 0, (unsigned long *)&reg_val);
  1094. switch (i) {
  1095. case 0:
  1096. viafb_write_reg_mask(CR9B, VIACR,
  1097. reg_val, 0x0f);
  1098. break;
  1099. case 1:
  1100. viafb_write_reg_mask(SR65, VIASR,
  1101. reg_val << 2, 0x0c);
  1102. break;
  1103. case 2:
  1104. viafb_write_reg_mask(SR65, VIASR,
  1105. reg_val, 0x03);
  1106. break;
  1107. default:
  1108. break;
  1109. }
  1110. } else {
  1111. break;
  1112. }
  1113. }
  1114. return count;
  1115. }
  1116. static const struct file_operations viafb_dvp1_proc_fops = {
  1117. .owner = THIS_MODULE,
  1118. .open = viafb_dvp1_proc_open,
  1119. .read = seq_read,
  1120. .llseek = seq_lseek,
  1121. .release = single_release,
  1122. .write = viafb_dvp1_proc_write,
  1123. };
  1124. static int viafb_dfph_proc_show(struct seq_file *m, void *v)
  1125. {
  1126. u8 dfp_high = 0;
  1127. dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
  1128. seq_printf(m, "%x\n", dfp_high);
  1129. return 0;
  1130. }
  1131. static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
  1132. {
  1133. return single_open(file, viafb_dfph_proc_show, NULL);
  1134. }
  1135. static ssize_t viafb_dfph_proc_write(struct file *file,
  1136. const char __user *buffer, size_t count, loff_t *pos)
  1137. {
  1138. char buf[20];
  1139. u8 reg_val = 0;
  1140. unsigned long length;
  1141. if (count < 1)
  1142. return -EINVAL;
  1143. length = count > 20 ? 20 : count;
  1144. if (copy_from_user(&buf[0], buffer, length))
  1145. return -EFAULT;
  1146. buf[length - 1] = '\0'; /*Ensure end string */
  1147. strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
  1148. viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
  1149. return count;
  1150. }
  1151. static const struct file_operations viafb_dfph_proc_fops = {
  1152. .owner = THIS_MODULE,
  1153. .open = viafb_dfph_proc_open,
  1154. .read = seq_read,
  1155. .llseek = seq_lseek,
  1156. .release = single_release,
  1157. .write = viafb_dfph_proc_write,
  1158. };
  1159. static int viafb_dfpl_proc_show(struct seq_file *m, void *v)
  1160. {
  1161. u8 dfp_low = 0;
  1162. dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
  1163. seq_printf(m, "%x\n", dfp_low);
  1164. return 0;
  1165. }
  1166. static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
  1167. {
  1168. return single_open(file, viafb_dfpl_proc_show, NULL);
  1169. }
  1170. static ssize_t viafb_dfpl_proc_write(struct file *file,
  1171. const char __user *buffer, size_t count, loff_t *pos)
  1172. {
  1173. char buf[20];
  1174. u8 reg_val = 0;
  1175. unsigned long length;
  1176. if (count < 1)
  1177. return -EINVAL;
  1178. length = count > 20 ? 20 : count;
  1179. if (copy_from_user(&buf[0], buffer, length))
  1180. return -EFAULT;
  1181. buf[length - 1] = '\0'; /*Ensure end string */
  1182. strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
  1183. viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
  1184. return count;
  1185. }
  1186. static const struct file_operations viafb_dfpl_proc_fops = {
  1187. .owner = THIS_MODULE,
  1188. .open = viafb_dfpl_proc_open,
  1189. .read = seq_read,
  1190. .llseek = seq_lseek,
  1191. .release = single_release,
  1192. .write = viafb_dfpl_proc_write,
  1193. };
  1194. static int viafb_vt1636_proc_show(struct seq_file *m, void *v)
  1195. {
  1196. u8 vt1636_08 = 0, vt1636_09 = 0;
  1197. switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
  1198. case VT1636_LVDS:
  1199. vt1636_08 =
  1200. viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
  1201. &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
  1202. vt1636_09 =
  1203. viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
  1204. &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
  1205. seq_printf(m, "%x %x\n", vt1636_08, vt1636_09);
  1206. break;
  1207. default:
  1208. break;
  1209. }
  1210. switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
  1211. case VT1636_LVDS:
  1212. vt1636_08 =
  1213. viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
  1214. &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
  1215. vt1636_09 =
  1216. viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
  1217. &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
  1218. seq_printf(m, " %x %x\n", vt1636_08, vt1636_09);
  1219. break;
  1220. default:
  1221. break;
  1222. }
  1223. return 0;
  1224. }
  1225. static int viafb_vt1636_proc_open(struct inode *inode, struct file *file)
  1226. {
  1227. return single_open(file, viafb_vt1636_proc_show, NULL);
  1228. }
  1229. static ssize_t viafb_vt1636_proc_write(struct file *file,
  1230. const char __user *buffer, size_t count, loff_t *pos)
  1231. {
  1232. char buf[30], *value, *pbuf;
  1233. struct IODATA reg_val;
  1234. unsigned long length, i;
  1235. if (count < 1)
  1236. return -EINVAL;
  1237. length = count > 30 ? 30 : count;
  1238. if (copy_from_user(&buf[0], buffer, length))
  1239. return -EFAULT;
  1240. buf[length - 1] = '\0'; /*Ensure end string */
  1241. pbuf = &buf[0];
  1242. switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
  1243. case VT1636_LVDS:
  1244. for (i = 0; i < 2; i++) {
  1245. value = strsep(&pbuf, " ");
  1246. if (value != NULL) {
  1247. strict_strtoul(value, 0,
  1248. (unsigned long *)&reg_val.Data);
  1249. switch (i) {
  1250. case 0:
  1251. reg_val.Index = 0x08;
  1252. reg_val.Mask = 0x0f;
  1253. viafb_gpio_i2c_write_mask_lvds
  1254. (viaparinfo->lvds_setting_info,
  1255. &viaparinfo->
  1256. chip_info->lvds_chip_info,
  1257. reg_val);
  1258. break;
  1259. case 1:
  1260. reg_val.Index = 0x09;
  1261. reg_val.Mask = 0x1f;
  1262. viafb_gpio_i2c_write_mask_lvds
  1263. (viaparinfo->lvds_setting_info,
  1264. &viaparinfo->
  1265. chip_info->lvds_chip_info,
  1266. reg_val);
  1267. break;
  1268. default:
  1269. break;
  1270. }
  1271. } else {
  1272. break;
  1273. }
  1274. }
  1275. break;
  1276. default:
  1277. break;
  1278. }
  1279. switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
  1280. case VT1636_LVDS:
  1281. for (i = 0; i < 2; i++) {
  1282. value = strsep(&pbuf, " ");
  1283. if (value != NULL) {
  1284. strict_strtoul(value, 0,
  1285. (unsigned long *)&reg_val.Data);
  1286. switch (i) {
  1287. case 0:
  1288. reg_val.Index = 0x08;
  1289. reg_val.Mask = 0x0f;
  1290. viafb_gpio_i2c_write_mask_lvds
  1291. (viaparinfo->lvds_setting_info2,
  1292. &viaparinfo->
  1293. chip_info->lvds_chip_info2,
  1294. reg_val);
  1295. break;
  1296. case 1:
  1297. reg_val.Index = 0x09;
  1298. reg_val.Mask = 0x1f;
  1299. viafb_gpio_i2c_write_mask_lvds
  1300. (viaparinfo->lvds_setting_info2,
  1301. &viaparinfo->
  1302. chip_info->lvds_chip_info2,
  1303. reg_val);
  1304. break;
  1305. default:
  1306. break;
  1307. }
  1308. } else {
  1309. break;
  1310. }
  1311. }
  1312. break;
  1313. default:
  1314. break;
  1315. }
  1316. return count;
  1317. }
  1318. static const struct file_operations viafb_vt1636_proc_fops = {
  1319. .owner = THIS_MODULE,
  1320. .open = viafb_vt1636_proc_open,
  1321. .read = seq_read,
  1322. .llseek = seq_lseek,
  1323. .release = single_release,
  1324. .write = viafb_vt1636_proc_write,
  1325. };
  1326. #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
  1327. static int viafb_sup_odev_proc_show(struct seq_file *m, void *v)
  1328. {
  1329. via_odev_to_seq(m, supported_odev_map[
  1330. viaparinfo->shared->chip_info.gfx_chip_name]);
  1331. return 0;
  1332. }
  1333. static int viafb_sup_odev_proc_open(struct inode *inode, struct file *file)
  1334. {
  1335. return single_open(file, viafb_sup_odev_proc_show, NULL);
  1336. }
  1337. static const struct file_operations viafb_sup_odev_proc_fops = {
  1338. .owner = THIS_MODULE,
  1339. .open = viafb_sup_odev_proc_open,
  1340. .read = seq_read,
  1341. .llseek = seq_lseek,
  1342. .release = single_release,
  1343. };
  1344. static ssize_t odev_update(const char __user *buffer, size_t count, u32 *odev)
  1345. {
  1346. char buf[64], *ptr = buf;
  1347. u32 devices;
  1348. bool add, sub;
  1349. if (count < 1 || count > 63)
  1350. return -EINVAL;
  1351. if (copy_from_user(&buf[0], buffer, count))
  1352. return -EFAULT;
  1353. buf[count] = '\0';
  1354. add = buf[0] == '+';
  1355. sub = buf[0] == '-';
  1356. if (add || sub)
  1357. ptr++;
  1358. devices = via_parse_odev(ptr, &ptr);
  1359. if (*ptr == '\n')
  1360. ptr++;
  1361. if (*ptr != 0)
  1362. return -EINVAL;
  1363. if (add)
  1364. *odev |= devices;
  1365. else if (sub)
  1366. *odev &= ~devices;
  1367. else
  1368. *odev = devices;
  1369. return count;
  1370. }
  1371. static int viafb_iga1_odev_proc_show(struct seq_file *m, void *v)
  1372. {
  1373. via_odev_to_seq(m, viaparinfo->shared->iga1_devices);
  1374. return 0;
  1375. }
  1376. static int viafb_iga1_odev_proc_open(struct inode *inode, struct file *file)
  1377. {
  1378. return single_open(file, viafb_iga1_odev_proc_show, NULL);
  1379. }
  1380. static ssize_t viafb_iga1_odev_proc_write(struct file *file,
  1381. const char __user *buffer, size_t count, loff_t *pos)
  1382. {
  1383. u32 dev_on, dev_off, dev_old, dev_new;
  1384. ssize_t res;
  1385. dev_old = dev_new = viaparinfo->shared->iga1_devices;
  1386. res = odev_update(buffer, count, &dev_new);
  1387. if (res != count)
  1388. return res;
  1389. dev_off = dev_old & ~dev_new;
  1390. dev_on = dev_new & ~dev_old;
  1391. viaparinfo->shared->iga1_devices = dev_new;
  1392. viaparinfo->shared->iga2_devices &= ~dev_new;
  1393. via_set_state(dev_off, VIA_STATE_OFF);
  1394. via_set_source(dev_new, IGA1);
  1395. via_set_state(dev_on, VIA_STATE_ON);
  1396. return res;
  1397. }
  1398. static const struct file_operations viafb_iga1_odev_proc_fops = {
  1399. .owner = THIS_MODULE,
  1400. .open = viafb_iga1_odev_proc_open,
  1401. .read = seq_read,
  1402. .llseek = seq_lseek,
  1403. .release = single_release,
  1404. .write = viafb_iga1_odev_proc_write,
  1405. };
  1406. static int viafb_iga2_odev_proc_show(struct seq_file *m, void *v)
  1407. {
  1408. via_odev_to_seq(m, viaparinfo->shared->iga2_devices);
  1409. return 0;
  1410. }
  1411. static int viafb_iga2_odev_proc_open(struct inode *inode, struct file *file)
  1412. {
  1413. return single_open(file, viafb_iga2_odev_proc_show, NULL);
  1414. }
  1415. static ssize_t viafb_iga2_odev_proc_write(struct file *file,
  1416. const char __user *buffer, size_t count, loff_t *pos)
  1417. {
  1418. u32 dev_on, dev_off, dev_old, dev_new;
  1419. ssize_t res;
  1420. dev_old = dev_new = viaparinfo->shared->iga2_devices;
  1421. res = odev_update(buffer, count, &dev_new);
  1422. if (res != count)
  1423. return res;
  1424. dev_off = dev_old & ~dev_new;
  1425. dev_on = dev_new & ~dev_old;
  1426. viaparinfo->shared->iga2_devices = dev_new;
  1427. viaparinfo->shared->iga1_devices &= ~dev_new;
  1428. via_set_state(dev_off, VIA_STATE_OFF);
  1429. via_set_source(dev_new, IGA2);
  1430. via_set_state(dev_on, VIA_STATE_ON);
  1431. return res;
  1432. }
  1433. static const struct file_operations viafb_iga2_odev_proc_fops = {
  1434. .owner = THIS_MODULE,
  1435. .open = viafb_iga2_odev_proc_open,
  1436. .read = seq_read,
  1437. .llseek = seq_lseek,
  1438. .release = single_release,
  1439. .write = viafb_iga2_odev_proc_write,
  1440. };
  1441. #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS)
  1442. static void viafb_init_proc(struct viafb_shared *shared)
  1443. {
  1444. struct proc_dir_entry *iga1_entry, *iga2_entry,
  1445. *viafb_entry = proc_mkdir("viafb", NULL);
  1446. shared->proc_entry = viafb_entry;
  1447. if (viafb_entry) {
  1448. #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
  1449. proc_create("dvp0", 0, viafb_entry, &viafb_dvp0_proc_fops);
  1450. proc_create("dvp1", 0, viafb_entry, &viafb_dvp1_proc_fops);
  1451. proc_create("dfph", 0, viafb_entry, &viafb_dfph_proc_fops);
  1452. proc_create("dfpl", 0, viafb_entry, &viafb_dfpl_proc_fops);
  1453. if (IS_VT1636(shared->chip_info.lvds_chip_info)
  1454. || IS_VT1636(shared->chip_info.lvds_chip_info2))
  1455. proc_create("vt1636", 0, viafb_entry,
  1456. &viafb_vt1636_proc_fops);
  1457. #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
  1458. proc_create("supported_output_devices", 0, viafb_entry,
  1459. &viafb_sup_odev_proc_fops);
  1460. iga1_entry = proc_mkdir("iga1", viafb_entry);
  1461. shared->iga1_proc_entry = iga1_entry;
  1462. proc_create("output_devices", 0, iga1_entry,
  1463. &viafb_iga1_odev_proc_fops);
  1464. iga2_entry = proc_mkdir("iga2", viafb_entry);
  1465. shared->iga2_proc_entry = iga2_entry;
  1466. proc_create("output_devices", 0, iga2_entry,
  1467. &viafb_iga2_odev_proc_fops);
  1468. }
  1469. }
  1470. static void viafb_remove_proc(struct viafb_shared *shared)
  1471. {
  1472. struct proc_dir_entry *viafb_entry = shared->proc_entry,
  1473. *iga1_entry = shared->iga1_proc_entry,
  1474. *iga2_entry = shared->iga2_proc_entry;
  1475. if (!viafb_entry)
  1476. return;
  1477. remove_proc_entry("output_devices", iga2_entry);
  1478. remove_proc_entry("iga2", viafb_entry);
  1479. remove_proc_entry("output_devices", iga1_entry);
  1480. remove_proc_entry("iga1", viafb_entry);
  1481. remove_proc_entry("supported_output_devices", viafb_entry);
  1482. #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
  1483. remove_proc_entry("dvp0", viafb_entry);/* parent dir */
  1484. remove_proc_entry("dvp1", viafb_entry);
  1485. remove_proc_entry("dfph", viafb_entry);
  1486. remove_proc_entry("dfpl", viafb_entry);
  1487. if (IS_VT1636(shared->chip_info.lvds_chip_info)
  1488. || IS_VT1636(shared->chip_info.lvds_chip_info2))
  1489. remove_proc_entry("vt1636", viafb_entry);
  1490. #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
  1491. remove_proc_entry("viafb", NULL);
  1492. }
  1493. #undef IS_VT1636
  1494. static int parse_mode(const char *str, u32 *xres, u32 *yres)
  1495. {
  1496. char *ptr;
  1497. if (!str) {
  1498. if (machine_is_olpc()) {
  1499. *xres = 1200;
  1500. *yres = 900;
  1501. } else {
  1502. *xres = 640;
  1503. *yres = 480;
  1504. }
  1505. return 0;
  1506. }
  1507. *xres = simple_strtoul(str, &ptr, 10);
  1508. if (ptr[0] != 'x')
  1509. return -EINVAL;
  1510. *yres = simple_strtoul(&ptr[1], &ptr, 10);
  1511. if (ptr[0])
  1512. return -EINVAL;
  1513. return 0;
  1514. }
  1515. #ifdef CONFIG_PM
  1516. static int viafb_suspend(void *unused)
  1517. {
  1518. console_lock();
  1519. fb_set_suspend(viafbinfo, 1);
  1520. viafb_sync(viafbinfo);
  1521. console_unlock();
  1522. return 0;
  1523. }
  1524. static int viafb_resume(void *unused)
  1525. {
  1526. console_lock();
  1527. if (viaparinfo->shared->vdev->engine_mmio)
  1528. viafb_reset_engine(viaparinfo);
  1529. viafb_set_par(viafbinfo);
  1530. if (viafb_dual_fb)
  1531. viafb_set_par(viafbinfo1);
  1532. fb_set_suspend(viafbinfo, 0);
  1533. console_unlock();
  1534. return 0;
  1535. }
  1536. static struct viafb_pm_hooks viafb_fb_pm_hooks = {
  1537. .suspend = viafb_suspend,
  1538. .resume = viafb_resume
  1539. };
  1540. #endif
  1541. int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
  1542. {
  1543. u32 default_xres, default_yres;
  1544. struct VideoModeTable *vmode_entry;
  1545. struct fb_var_screeninfo default_var;
  1546. int rc;
  1547. u32 viafb_par_length;
  1548. DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
  1549. memset(&default_var, 0, sizeof(default_var));
  1550. viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
  1551. /* Allocate fb_info and ***_par here, also including some other needed
  1552. * variables
  1553. */
  1554. viafbinfo = framebuffer_alloc(viafb_par_length +
  1555. ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
  1556. &vdev->pdev->dev);
  1557. if (!viafbinfo) {
  1558. printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
  1559. return -ENOMEM;
  1560. }
  1561. viaparinfo = (struct viafb_par *)viafbinfo->par;
  1562. viaparinfo->shared = viafbinfo->par + viafb_par_length;
  1563. viaparinfo->shared->vdev = vdev;
  1564. viaparinfo->vram_addr = 0;
  1565. viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
  1566. viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
  1567. viaparinfo->lvds_setting_info2 =
  1568. &viaparinfo->shared->lvds_setting_info2;
  1569. viaparinfo->chip_info = &viaparinfo->shared->chip_info;
  1570. if (viafb_dual_fb)
  1571. viafb_SAMM_ON = 1;
  1572. parse_lcd_port();
  1573. parse_dvi_port();
  1574. viafb_init_chip_info(vdev->chip_type);
  1575. /*
  1576. * The framebuffer will have been successfully mapped by
  1577. * the core (or we'd not be here), but we still need to
  1578. * set up our own accounting.
  1579. */
  1580. viaparinfo->fbmem = vdev->fbmem_start;
  1581. viaparinfo->memsize = vdev->fbmem_len;
  1582. viaparinfo->fbmem_free = viaparinfo->memsize;
  1583. viaparinfo->fbmem_used = 0;
  1584. viafbinfo->screen_base = vdev->fbmem;
  1585. viafbinfo->fix.mmio_start = vdev->engine_start;
  1586. viafbinfo->fix.mmio_len = vdev->engine_len;
  1587. viafbinfo->node = 0;
  1588. viafbinfo->fbops = &viafb_ops;
  1589. viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
  1590. viafbinfo->pseudo_palette = pseudo_pal;
  1591. if (viafb_accel && !viafb_setup_engine(viafbinfo)) {
  1592. viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
  1593. FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
  1594. default_var.accel_flags = FB_ACCELF_TEXT;
  1595. } else {
  1596. viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
  1597. default_var.accel_flags = 0;
  1598. }
  1599. if (viafb_second_size && (viafb_second_size < 8)) {
  1600. viafb_second_offset = viaparinfo->fbmem_free -
  1601. viafb_second_size * 1024 * 1024;
  1602. } else {
  1603. viafb_second_size = 8;
  1604. viafb_second_offset = viaparinfo->fbmem_free -
  1605. viafb_second_size * 1024 * 1024;
  1606. }
  1607. parse_mode(viafb_mode, &default_xres, &default_yres);
  1608. vmode_entry = viafb_get_mode(default_xres, default_yres);
  1609. if (viafb_SAMM_ON == 1)
  1610. parse_mode(viafb_mode1, &viafb_second_xres,
  1611. &viafb_second_yres);
  1612. default_var.xres = default_xres;
  1613. default_var.yres = default_yres;
  1614. default_var.xres_virtual = default_xres;
  1615. default_var.yres_virtual = default_yres;
  1616. default_var.bits_per_pixel = viafb_bpp;
  1617. viafb_fill_var_timing_info(&default_var, viafb_get_refresh(
  1618. default_var.xres, default_var.yres, viafb_refresh),
  1619. viafb_get_mode(default_var.xres, default_var.yres));
  1620. viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
  1621. viafbinfo->var = default_var;
  1622. if (viafb_dual_fb) {
  1623. viafbinfo1 = framebuffer_alloc(viafb_par_length,
  1624. &vdev->pdev->dev);
  1625. if (!viafbinfo1) {
  1626. printk(KERN_ERR
  1627. "allocate the second framebuffer struct error\n");
  1628. rc = -ENOMEM;
  1629. goto out_fb_release;
  1630. }
  1631. viaparinfo1 = viafbinfo1->par;
  1632. memcpy(viaparinfo1, viaparinfo, viafb_par_length);
  1633. viaparinfo1->vram_addr = viafb_second_offset;
  1634. viaparinfo1->memsize = viaparinfo->memsize -
  1635. viafb_second_offset;
  1636. viaparinfo->memsize = viafb_second_offset;
  1637. viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
  1638. viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
  1639. viaparinfo1->fbmem_free = viaparinfo1->memsize -
  1640. viaparinfo1->fbmem_used;
  1641. viaparinfo->fbmem_free = viaparinfo->memsize;
  1642. viaparinfo->fbmem_used = 0;
  1643. viaparinfo->iga_path = IGA1;
  1644. viaparinfo1->iga_path = IGA2;
  1645. memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
  1646. viafbinfo1->par = viaparinfo1;
  1647. viafbinfo1->screen_base = viafbinfo->screen_base +
  1648. viafb_second_offset;
  1649. default_var.xres = viafb_second_xres;
  1650. default_var.yres = viafb_second_yres;
  1651. default_var.xres_virtual = viafb_second_xres;
  1652. default_var.yres_virtual = viafb_second_yres;
  1653. default_var.bits_per_pixel = viafb_bpp1;
  1654. viafb_fill_var_timing_info(&default_var, viafb_get_refresh(
  1655. default_var.xres, default_var.yres, viafb_refresh1),
  1656. viafb_get_mode(default_var.xres, default_var.yres));
  1657. viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
  1658. viafb_check_var(&default_var, viafbinfo1);
  1659. viafbinfo1->var = default_var;
  1660. viafb_update_fix(viafbinfo1);
  1661. viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
  1662. &viafbinfo1->fix);
  1663. }
  1664. viafb_check_var(&viafbinfo->var, viafbinfo);
  1665. viafb_update_fix(viafbinfo);
  1666. viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
  1667. &viafbinfo->fix);
  1668. default_var.activate = FB_ACTIVATE_NOW;
  1669. rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
  1670. if (rc)
  1671. goto out_fb1_release;
  1672. if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
  1673. && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
  1674. rc = register_framebuffer(viafbinfo1);
  1675. if (rc)
  1676. goto out_dealloc_cmap;
  1677. }
  1678. rc = register_framebuffer(viafbinfo);
  1679. if (rc)
  1680. goto out_fb1_unreg_lcd_cle266;
  1681. if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
  1682. || (viaparinfo->chip_info->gfx_chip_name !=
  1683. UNICHROME_CLE266))) {
  1684. rc = register_framebuffer(viafbinfo1);
  1685. if (rc)
  1686. goto out_fb_unreg;
  1687. }
  1688. DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
  1689. viafbinfo->node, viafbinfo->fix.id, default_var.xres,
  1690. default_var.yres, default_var.bits_per_pixel);
  1691. viafb_init_proc(viaparinfo->shared);
  1692. viafb_init_dac(IGA2);
  1693. #ifdef CONFIG_PM
  1694. viafb_pm_register(&viafb_fb_pm_hooks);
  1695. #endif
  1696. return 0;
  1697. out_fb_unreg:
  1698. unregister_framebuffer(viafbinfo);
  1699. out_fb1_unreg_lcd_cle266:
  1700. if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
  1701. && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
  1702. unregister_framebuffer(viafbinfo1);
  1703. out_dealloc_cmap:
  1704. fb_dealloc_cmap(&viafbinfo->cmap);
  1705. out_fb1_release:
  1706. if (viafbinfo1)
  1707. framebuffer_release(viafbinfo1);
  1708. out_fb_release:
  1709. framebuffer_release(viafbinfo);
  1710. return rc;
  1711. }
  1712. void __devexit via_fb_pci_remove(struct pci_dev *pdev)
  1713. {
  1714. DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
  1715. fb_dealloc_cmap(&viafbinfo->cmap);
  1716. unregister_framebuffer(viafbinfo);
  1717. if (viafb_dual_fb)
  1718. unregister_framebuffer(viafbinfo1);
  1719. viafb_remove_proc(viaparinfo->shared);
  1720. framebuffer_release(viafbinfo);
  1721. if (viafb_dual_fb)
  1722. framebuffer_release(viafbinfo1);
  1723. }
  1724. #ifndef MODULE
  1725. static int __init viafb_setup(void)
  1726. {
  1727. char *this_opt;
  1728. char *options;
  1729. DEBUG_MSG(KERN_INFO "viafb_setup!\n");
  1730. if (fb_get_options("viafb", &options))
  1731. return -ENODEV;
  1732. if (!options || !*options)
  1733. return 0;
  1734. while ((this_opt = strsep(&options, ",")) != NULL) {
  1735. if (!*this_opt)
  1736. continue;
  1737. if (!strncmp(this_opt, "viafb_mode1=", 12))
  1738. viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
  1739. else if (!strncmp(this_opt, "viafb_mode=", 11))
  1740. viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
  1741. else if (!strncmp(this_opt, "viafb_bpp1=", 11))
  1742. strict_strtoul(this_opt + 11, 0,
  1743. (unsigned long *)&viafb_bpp1);
  1744. else if (!strncmp(this_opt, "viafb_bpp=", 10))
  1745. strict_strtoul(this_opt + 10, 0,
  1746. (unsigned long *)&viafb_bpp);
  1747. else if (!strncmp(this_opt, "viafb_refresh1=", 15))
  1748. strict_strtoul(this_opt + 15, 0,
  1749. (unsigned long *)&viafb_refresh1);
  1750. else if (!strncmp(this_opt, "viafb_refresh=", 14))
  1751. strict_strtoul(this_opt + 14, 0,
  1752. (unsigned long *)&viafb_refresh);
  1753. else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
  1754. strict_strtoul(this_opt + 21, 0,
  1755. (unsigned long *)&viafb_lcd_dsp_method);
  1756. else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
  1757. strict_strtoul(this_opt + 19, 0,
  1758. (unsigned long *)&viafb_lcd_panel_id);
  1759. else if (!strncmp(this_opt, "viafb_accel=", 12))
  1760. strict_strtoul(this_opt + 12, 0,
  1761. (unsigned long *)&viafb_accel);
  1762. else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
  1763. strict_strtoul(this_opt + 14, 0,
  1764. (unsigned long *)&viafb_SAMM_ON);
  1765. else if (!strncmp(this_opt, "viafb_active_dev=", 17))
  1766. viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
  1767. else if (!strncmp(this_opt,
  1768. "viafb_display_hardware_layout=", 30))
  1769. strict_strtoul(this_opt + 30, 0,
  1770. (unsigned long *)&viafb_display_hardware_layout);
  1771. else if (!strncmp(this_opt, "viafb_second_size=", 18))
  1772. strict_strtoul(this_opt + 18, 0,
  1773. (unsigned long *)&viafb_second_size);
  1774. else if (!strncmp(this_opt,
  1775. "viafb_platform_epia_dvi=", 24))
  1776. strict_strtoul(this_opt + 24, 0,
  1777. (unsigned long *)&viafb_platform_epia_dvi);
  1778. else if (!strncmp(this_opt,
  1779. "viafb_device_lcd_dualedge=", 26))
  1780. strict_strtoul(this_opt + 26, 0,
  1781. (unsigned long *)&viafb_device_lcd_dualedge);
  1782. else if (!strncmp(this_opt, "viafb_bus_width=", 16))
  1783. strict_strtoul(this_opt + 16, 0,
  1784. (unsigned long *)&viafb_bus_width);
  1785. else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
  1786. strict_strtoul(this_opt + 15, 0,
  1787. (unsigned long *)&viafb_lcd_mode);
  1788. else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
  1789. viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
  1790. else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
  1791. viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
  1792. }
  1793. return 0;
  1794. }
  1795. #endif
  1796. /*
  1797. * These are called out of via-core for now.
  1798. */
  1799. int __init viafb_init(void)
  1800. {
  1801. u32 dummy_x, dummy_y;
  1802. int r;
  1803. if (machine_is_olpc())
  1804. /* Apply XO-1.5-specific configuration. */
  1805. viafb_lcd_panel_id = 23;
  1806. #ifndef MODULE
  1807. r = viafb_setup();
  1808. if (r < 0)
  1809. return r;
  1810. #endif
  1811. if (parse_mode(viafb_mode, &dummy_x, &dummy_y)
  1812. || !viafb_get_mode(dummy_x, dummy_y)
  1813. || parse_mode(viafb_mode1, &dummy_x, &dummy_y)
  1814. || !viafb_get_mode(dummy_x, dummy_y)
  1815. || viafb_bpp < 0 || viafb_bpp > 32
  1816. || viafb_bpp1 < 0 || viafb_bpp1 > 32
  1817. || parse_active_dev())
  1818. return -EINVAL;
  1819. printk(KERN_INFO
  1820. "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n",
  1821. VERSION_MAJOR, VERSION_MINOR);
  1822. return 0;
  1823. }
  1824. void __exit viafb_exit(void)
  1825. {
  1826. DEBUG_MSG(KERN_INFO "viafb_exit!\n");
  1827. }
  1828. static struct fb_ops viafb_ops = {
  1829. .owner = THIS_MODULE,
  1830. .fb_open = viafb_open,
  1831. .fb_release = viafb_release,
  1832. .fb_check_var = viafb_check_var,
  1833. .fb_set_par = viafb_set_par,
  1834. .fb_setcolreg = viafb_setcolreg,
  1835. .fb_pan_display = viafb_pan_display,
  1836. .fb_blank = viafb_blank,
  1837. .fb_fillrect = viafb_fillrect,
  1838. .fb_copyarea = viafb_copyarea,
  1839. .fb_imageblit = viafb_imageblit,
  1840. .fb_cursor = viafb_cursor,
  1841. .fb_ioctl = viafb_ioctl,
  1842. .fb_sync = viafb_sync,
  1843. };
  1844. #ifdef MODULE
  1845. module_param(viafb_mode, charp, S_IRUSR);
  1846. MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
  1847. module_param(viafb_mode1, charp, S_IRUSR);
  1848. MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
  1849. module_param(viafb_bpp, int, S_IRUSR);
  1850. MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
  1851. module_param(viafb_bpp1, int, S_IRUSR);
  1852. MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
  1853. module_param(viafb_refresh, int, S_IRUSR);
  1854. MODULE_PARM_DESC(viafb_refresh,
  1855. "Set CRT viafb_refresh rate (default = 60)");
  1856. module_param(viafb_refresh1, int, S_IRUSR);
  1857. MODULE_PARM_DESC(viafb_refresh1,
  1858. "Set CRT refresh rate (default = 60)");
  1859. module_param(viafb_lcd_panel_id, int, S_IRUSR);
  1860. MODULE_PARM_DESC(viafb_lcd_panel_id,
  1861. "Set Flat Panel type(Default=1024x768)");
  1862. module_param(viafb_lcd_dsp_method, int, S_IRUSR);
  1863. MODULE_PARM_DESC(viafb_lcd_dsp_method,
  1864. "Set Flat Panel display scaling method.(Default=Expandsion)");
  1865. module_param(viafb_SAMM_ON, int, S_IRUSR);
  1866. MODULE_PARM_DESC(viafb_SAMM_ON,
  1867. "Turn on/off flag of SAMM(Default=OFF)");
  1868. module_param(viafb_accel, int, S_IRUSR);
  1869. MODULE_PARM_DESC(viafb_accel,
  1870. "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
  1871. module_param(viafb_active_dev, charp, S_IRUSR);
  1872. MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
  1873. module_param(viafb_display_hardware_layout, int, S_IRUSR);
  1874. MODULE_PARM_DESC(viafb_display_hardware_layout,
  1875. "Display Hardware Layout (LCD Only, DVI Only...,etc)");
  1876. module_param(viafb_second_size, int, S_IRUSR);
  1877. MODULE_PARM_DESC(viafb_second_size,
  1878. "Set secondary device memory size");
  1879. module_param(viafb_dual_fb, int, S_IRUSR);
  1880. MODULE_PARM_DESC(viafb_dual_fb,
  1881. "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
  1882. module_param(viafb_platform_epia_dvi, int, S_IRUSR);
  1883. MODULE_PARM_DESC(viafb_platform_epia_dvi,
  1884. "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
  1885. module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
  1886. MODULE_PARM_DESC(viafb_device_lcd_dualedge,
  1887. "Turn on/off flag of dual edge panel.(Default = OFF)");
  1888. module_param(viafb_bus_width, int, S_IRUSR);
  1889. MODULE_PARM_DESC(viafb_bus_width,
  1890. "Set bus width of panel.(Default = 12)");
  1891. module_param(viafb_lcd_mode, int, S_IRUSR);
  1892. MODULE_PARM_DESC(viafb_lcd_mode,
  1893. "Set Flat Panel mode(Default=OPENLDI)");
  1894. module_param(viafb_lcd_port, charp, S_IRUSR);
  1895. MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
  1896. module_param(viafb_dvi_port, charp, S_IRUSR);
  1897. MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
  1898. MODULE_LICENSE("GPL");
  1899. #endif