viafbdev.c 59 KB

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