viafbdev.c 58 KB

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