viafbdev.c 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176
  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. *iga1_entry = shared->iga1_proc_entry,
  1457. *iga2_entry = shared->iga2_proc_entry;
  1458. if (!viafb_entry)
  1459. return;
  1460. remove_proc_entry("output_devices", iga2_entry);
  1461. remove_proc_entry("iga2", viafb_entry);
  1462. remove_proc_entry("output_devices", iga1_entry);
  1463. remove_proc_entry("iga1", viafb_entry);
  1464. remove_proc_entry("supported_output_devices", viafb_entry);
  1465. #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
  1466. remove_proc_entry("dvp0", viafb_entry);/* parent dir */
  1467. remove_proc_entry("dvp1", viafb_entry);
  1468. remove_proc_entry("dfph", viafb_entry);
  1469. remove_proc_entry("dfpl", viafb_entry);
  1470. if (IS_VT1636(shared->chip_info.lvds_chip_info)
  1471. || IS_VT1636(shared->chip_info.lvds_chip_info2))
  1472. remove_proc_entry("vt1636", viafb_entry);
  1473. #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
  1474. remove_proc_entry("viafb", NULL);
  1475. }
  1476. #undef IS_VT1636
  1477. static int parse_mode(const char *str, u32 devices, u32 *xres, u32 *yres)
  1478. {
  1479. const struct fb_videomode *mode = NULL;
  1480. char *ptr;
  1481. if (!str) {
  1482. if (devices == VIA_CRT)
  1483. mode = via_aux_get_preferred_mode(
  1484. viaparinfo->shared->i2c_26);
  1485. else if (devices == VIA_DVP1)
  1486. mode = via_aux_get_preferred_mode(
  1487. viaparinfo->shared->i2c_31);
  1488. if (mode) {
  1489. *xres = mode->xres;
  1490. *yres = mode->yres;
  1491. } else if (machine_is_olpc()) {
  1492. *xres = 1200;
  1493. *yres = 900;
  1494. } else {
  1495. *xres = 640;
  1496. *yres = 480;
  1497. }
  1498. return 0;
  1499. }
  1500. *xres = simple_strtoul(str, &ptr, 10);
  1501. if (ptr[0] != 'x')
  1502. return -EINVAL;
  1503. *yres = simple_strtoul(&ptr[1], &ptr, 10);
  1504. if (ptr[0])
  1505. return -EINVAL;
  1506. return 0;
  1507. }
  1508. #ifdef CONFIG_PM
  1509. static int viafb_suspend(void *unused)
  1510. {
  1511. console_lock();
  1512. fb_set_suspend(viafbinfo, 1);
  1513. viafb_sync(viafbinfo);
  1514. console_unlock();
  1515. return 0;
  1516. }
  1517. static int viafb_resume(void *unused)
  1518. {
  1519. console_lock();
  1520. if (viaparinfo->shared->vdev->engine_mmio)
  1521. viafb_reset_engine(viaparinfo);
  1522. viafb_set_par(viafbinfo);
  1523. if (viafb_dual_fb)
  1524. viafb_set_par(viafbinfo1);
  1525. fb_set_suspend(viafbinfo, 0);
  1526. console_unlock();
  1527. return 0;
  1528. }
  1529. static struct viafb_pm_hooks viafb_fb_pm_hooks = {
  1530. .suspend = viafb_suspend,
  1531. .resume = viafb_resume
  1532. };
  1533. #endif
  1534. static void i2c_bus_probe(struct viafb_shared *shared)
  1535. {
  1536. /* should be always CRT */
  1537. printk(KERN_INFO "viafb: Probing I2C bus 0x26\n");
  1538. shared->i2c_26 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_26));
  1539. /* seems to be usually DVP1 */
  1540. printk(KERN_INFO "viafb: Probing I2C bus 0x31\n");
  1541. shared->i2c_31 = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_31));
  1542. /* FIXME: what is this? */
  1543. if (!machine_is_olpc()) {
  1544. printk(KERN_INFO "viafb: Probing I2C bus 0x2C\n");
  1545. shared->i2c_2C = via_aux_probe(viafb_find_i2c_adapter(VIA_PORT_2C));
  1546. }
  1547. printk(KERN_INFO "viafb: Finished I2C bus probing");
  1548. }
  1549. static void i2c_bus_free(struct viafb_shared *shared)
  1550. {
  1551. via_aux_free(shared->i2c_26);
  1552. via_aux_free(shared->i2c_31);
  1553. via_aux_free(shared->i2c_2C);
  1554. }
  1555. int via_fb_pci_probe(struct viafb_dev *vdev)
  1556. {
  1557. u32 default_xres, default_yres;
  1558. struct fb_var_screeninfo default_var;
  1559. int rc;
  1560. u32 viafb_par_length;
  1561. DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
  1562. memset(&default_var, 0, sizeof(default_var));
  1563. viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
  1564. /* Allocate fb_info and ***_par here, also including some other needed
  1565. * variables
  1566. */
  1567. viafbinfo = framebuffer_alloc(viafb_par_length +
  1568. ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
  1569. &vdev->pdev->dev);
  1570. if (!viafbinfo) {
  1571. printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
  1572. return -ENOMEM;
  1573. }
  1574. viaparinfo = (struct viafb_par *)viafbinfo->par;
  1575. viaparinfo->shared = viafbinfo->par + viafb_par_length;
  1576. viaparinfo->shared->vdev = vdev;
  1577. viaparinfo->vram_addr = 0;
  1578. viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
  1579. viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
  1580. viaparinfo->lvds_setting_info2 =
  1581. &viaparinfo->shared->lvds_setting_info2;
  1582. viaparinfo->chip_info = &viaparinfo->shared->chip_info;
  1583. i2c_bus_probe(viaparinfo->shared);
  1584. if (viafb_dual_fb)
  1585. viafb_SAMM_ON = 1;
  1586. parse_lcd_port();
  1587. parse_dvi_port();
  1588. viafb_init_chip_info(vdev->chip_type);
  1589. /*
  1590. * The framebuffer will have been successfully mapped by
  1591. * the core (or we'd not be here), but we still need to
  1592. * set up our own accounting.
  1593. */
  1594. viaparinfo->fbmem = vdev->fbmem_start;
  1595. viaparinfo->memsize = vdev->fbmem_len;
  1596. viaparinfo->fbmem_free = viaparinfo->memsize;
  1597. viaparinfo->fbmem_used = 0;
  1598. viafbinfo->screen_base = vdev->fbmem;
  1599. viafbinfo->fix.mmio_start = vdev->engine_start;
  1600. viafbinfo->fix.mmio_len = vdev->engine_len;
  1601. viafbinfo->node = 0;
  1602. viafbinfo->fbops = &viafb_ops;
  1603. viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
  1604. viafbinfo->pseudo_palette = pseudo_pal;
  1605. if (viafb_accel && !viafb_setup_engine(viafbinfo)) {
  1606. viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
  1607. FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
  1608. default_var.accel_flags = FB_ACCELF_TEXT;
  1609. } else {
  1610. viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
  1611. default_var.accel_flags = 0;
  1612. }
  1613. if (viafb_second_size && (viafb_second_size < 8)) {
  1614. viafb_second_offset = viaparinfo->fbmem_free -
  1615. viafb_second_size * 1024 * 1024;
  1616. } else {
  1617. viafb_second_size = 8;
  1618. viafb_second_offset = viaparinfo->fbmem_free -
  1619. viafb_second_size * 1024 * 1024;
  1620. }
  1621. parse_mode(viafb_mode, viaparinfo->shared->iga1_devices,
  1622. &default_xres, &default_yres);
  1623. if (viafb_SAMM_ON == 1)
  1624. parse_mode(viafb_mode1, viaparinfo->shared->iga2_devices,
  1625. &viafb_second_xres, &viafb_second_yres);
  1626. default_var.xres = default_xres;
  1627. default_var.yres = default_yres;
  1628. default_var.xres_virtual = default_xres;
  1629. default_var.yres_virtual = default_yres;
  1630. default_var.bits_per_pixel = viafb_bpp;
  1631. viafb_fill_var_timing_info(&default_var, viafb_get_best_mode(
  1632. default_var.xres, default_var.yres, viafb_refresh));
  1633. viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
  1634. viafbinfo->var = default_var;
  1635. if (viafb_dual_fb) {
  1636. viafbinfo1 = framebuffer_alloc(viafb_par_length,
  1637. &vdev->pdev->dev);
  1638. if (!viafbinfo1) {
  1639. printk(KERN_ERR
  1640. "allocate the second framebuffer struct error\n");
  1641. rc = -ENOMEM;
  1642. goto out_fb_release;
  1643. }
  1644. viaparinfo1 = viafbinfo1->par;
  1645. memcpy(viaparinfo1, viaparinfo, viafb_par_length);
  1646. viaparinfo1->vram_addr = viafb_second_offset;
  1647. viaparinfo1->memsize = viaparinfo->memsize -
  1648. viafb_second_offset;
  1649. viaparinfo->memsize = viafb_second_offset;
  1650. viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
  1651. viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
  1652. viaparinfo1->fbmem_free = viaparinfo1->memsize -
  1653. viaparinfo1->fbmem_used;
  1654. viaparinfo->fbmem_free = viaparinfo->memsize;
  1655. viaparinfo->fbmem_used = 0;
  1656. viaparinfo->iga_path = IGA1;
  1657. viaparinfo1->iga_path = IGA2;
  1658. memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
  1659. viafbinfo1->par = viaparinfo1;
  1660. viafbinfo1->screen_base = viafbinfo->screen_base +
  1661. viafb_second_offset;
  1662. default_var.xres = viafb_second_xres;
  1663. default_var.yres = viafb_second_yres;
  1664. default_var.xres_virtual = viafb_second_xres;
  1665. default_var.yres_virtual = viafb_second_yres;
  1666. default_var.bits_per_pixel = viafb_bpp1;
  1667. viafb_fill_var_timing_info(&default_var, viafb_get_best_mode(
  1668. default_var.xres, default_var.yres, viafb_refresh1));
  1669. viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
  1670. viafb_check_var(&default_var, viafbinfo1);
  1671. viafbinfo1->var = default_var;
  1672. viafb_update_fix(viafbinfo1);
  1673. viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
  1674. &viafbinfo1->fix);
  1675. }
  1676. viafb_check_var(&viafbinfo->var, viafbinfo);
  1677. viafb_update_fix(viafbinfo);
  1678. viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
  1679. &viafbinfo->fix);
  1680. default_var.activate = FB_ACTIVATE_NOW;
  1681. rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
  1682. if (rc)
  1683. goto out_fb1_release;
  1684. if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
  1685. && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
  1686. rc = register_framebuffer(viafbinfo1);
  1687. if (rc)
  1688. goto out_dealloc_cmap;
  1689. }
  1690. rc = register_framebuffer(viafbinfo);
  1691. if (rc)
  1692. goto out_fb1_unreg_lcd_cle266;
  1693. if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
  1694. || (viaparinfo->chip_info->gfx_chip_name !=
  1695. UNICHROME_CLE266))) {
  1696. rc = register_framebuffer(viafbinfo1);
  1697. if (rc)
  1698. goto out_fb_unreg;
  1699. }
  1700. DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
  1701. viafbinfo->node, viafbinfo->fix.id, default_var.xres,
  1702. default_var.yres, default_var.bits_per_pixel);
  1703. viafb_init_proc(viaparinfo->shared);
  1704. viafb_init_dac(IGA2);
  1705. #ifdef CONFIG_PM
  1706. viafb_pm_register(&viafb_fb_pm_hooks);
  1707. #endif
  1708. return 0;
  1709. out_fb_unreg:
  1710. unregister_framebuffer(viafbinfo);
  1711. out_fb1_unreg_lcd_cle266:
  1712. if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
  1713. && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
  1714. unregister_framebuffer(viafbinfo1);
  1715. out_dealloc_cmap:
  1716. fb_dealloc_cmap(&viafbinfo->cmap);
  1717. out_fb1_release:
  1718. framebuffer_release(viafbinfo1);
  1719. out_fb_release:
  1720. i2c_bus_free(viaparinfo->shared);
  1721. framebuffer_release(viafbinfo);
  1722. return rc;
  1723. }
  1724. void via_fb_pci_remove(struct pci_dev *pdev)
  1725. {
  1726. DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
  1727. fb_dealloc_cmap(&viafbinfo->cmap);
  1728. unregister_framebuffer(viafbinfo);
  1729. if (viafb_dual_fb)
  1730. unregister_framebuffer(viafbinfo1);
  1731. viafb_remove_proc(viaparinfo->shared);
  1732. i2c_bus_free(viaparinfo->shared);
  1733. framebuffer_release(viafbinfo);
  1734. if (viafb_dual_fb)
  1735. framebuffer_release(viafbinfo1);
  1736. }
  1737. #ifndef MODULE
  1738. static int __init viafb_setup(void)
  1739. {
  1740. char *this_opt;
  1741. char *options;
  1742. DEBUG_MSG(KERN_INFO "viafb_setup!\n");
  1743. if (fb_get_options("viafb", &options))
  1744. return -ENODEV;
  1745. if (!options || !*options)
  1746. return 0;
  1747. while ((this_opt = strsep(&options, ",")) != NULL) {
  1748. if (!*this_opt)
  1749. continue;
  1750. if (!strncmp(this_opt, "viafb_mode1=", 12)) {
  1751. viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
  1752. } else if (!strncmp(this_opt, "viafb_mode=", 11)) {
  1753. viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
  1754. } else if (!strncmp(this_opt, "viafb_bpp1=", 11)) {
  1755. if (kstrtouint(this_opt + 11, 0, &viafb_bpp1) < 0)
  1756. return -EINVAL;
  1757. } else if (!strncmp(this_opt, "viafb_bpp=", 10)) {
  1758. if (kstrtouint(this_opt + 10, 0, &viafb_bpp) < 0)
  1759. return -EINVAL;
  1760. } else if (!strncmp(this_opt, "viafb_refresh1=", 15)) {
  1761. if (kstrtoint(this_opt + 15, 0, &viafb_refresh1) < 0)
  1762. return -EINVAL;
  1763. } else if (!strncmp(this_opt, "viafb_refresh=", 14)) {
  1764. if (kstrtoint(this_opt + 14, 0, &viafb_refresh) < 0)
  1765. return -EINVAL;
  1766. } else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) {
  1767. if (kstrtoint(this_opt + 21, 0,
  1768. &viafb_lcd_dsp_method) < 0)
  1769. return -EINVAL;
  1770. } else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) {
  1771. if (kstrtoint(this_opt + 19, 0,
  1772. &viafb_lcd_panel_id) < 0)
  1773. return -EINVAL;
  1774. } else if (!strncmp(this_opt, "viafb_accel=", 12)) {
  1775. if (kstrtoint(this_opt + 12, 0, &viafb_accel) < 0)
  1776. return -EINVAL;
  1777. } else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) {
  1778. if (kstrtoint(this_opt + 14, 0, &viafb_SAMM_ON) < 0)
  1779. return -EINVAL;
  1780. } else if (!strncmp(this_opt, "viafb_active_dev=", 17)) {
  1781. viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
  1782. } else if (!strncmp(this_opt,
  1783. "viafb_display_hardware_layout=", 30)) {
  1784. if (kstrtoint(this_opt + 30, 0,
  1785. &viafb_display_hardware_layout) < 0)
  1786. return -EINVAL;
  1787. } else if (!strncmp(this_opt, "viafb_second_size=", 18)) {
  1788. if (kstrtoint(this_opt + 18, 0, &viafb_second_size) < 0)
  1789. return -EINVAL;
  1790. } else if (!strncmp(this_opt,
  1791. "viafb_platform_epia_dvi=", 24)) {
  1792. if (kstrtoint(this_opt + 24, 0,
  1793. &viafb_platform_epia_dvi) < 0)
  1794. return -EINVAL;
  1795. } else if (!strncmp(this_opt,
  1796. "viafb_device_lcd_dualedge=", 26)) {
  1797. if (kstrtoint(this_opt + 26, 0,
  1798. &viafb_device_lcd_dualedge) < 0)
  1799. return -EINVAL;
  1800. } else if (!strncmp(this_opt, "viafb_bus_width=", 16)) {
  1801. if (kstrtoint(this_opt + 16, 0, &viafb_bus_width) < 0)
  1802. return -EINVAL;
  1803. } else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) {
  1804. if (kstrtoint(this_opt + 15, 0, &viafb_lcd_mode) < 0)
  1805. return -EINVAL;
  1806. } else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) {
  1807. viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
  1808. } else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) {
  1809. viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
  1810. }
  1811. }
  1812. return 0;
  1813. }
  1814. #endif
  1815. /*
  1816. * These are called out of via-core for now.
  1817. */
  1818. int __init viafb_init(void)
  1819. {
  1820. u32 dummy_x, dummy_y;
  1821. int r = 0;
  1822. if (machine_is_olpc())
  1823. /* Apply XO-1.5-specific configuration. */
  1824. viafb_lcd_panel_id = 23;
  1825. #ifndef MODULE
  1826. r = viafb_setup();
  1827. if (r < 0)
  1828. return r;
  1829. #endif
  1830. if (parse_mode(viafb_mode, 0, &dummy_x, &dummy_y)
  1831. || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh)
  1832. || parse_mode(viafb_mode1, 0, &dummy_x, &dummy_y)
  1833. || !viafb_get_best_mode(dummy_x, dummy_y, viafb_refresh1)
  1834. || viafb_bpp < 0 || viafb_bpp > 32
  1835. || viafb_bpp1 < 0 || viafb_bpp1 > 32
  1836. || parse_active_dev())
  1837. return -EINVAL;
  1838. printk(KERN_INFO
  1839. "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n",
  1840. VERSION_MAJOR, VERSION_MINOR);
  1841. return r;
  1842. }
  1843. void __exit viafb_exit(void)
  1844. {
  1845. DEBUG_MSG(KERN_INFO "viafb_exit!\n");
  1846. }
  1847. static struct fb_ops viafb_ops = {
  1848. .owner = THIS_MODULE,
  1849. .fb_open = viafb_open,
  1850. .fb_release = viafb_release,
  1851. .fb_check_var = viafb_check_var,
  1852. .fb_set_par = viafb_set_par,
  1853. .fb_setcolreg = viafb_setcolreg,
  1854. .fb_pan_display = viafb_pan_display,
  1855. .fb_blank = viafb_blank,
  1856. .fb_fillrect = viafb_fillrect,
  1857. .fb_copyarea = viafb_copyarea,
  1858. .fb_imageblit = viafb_imageblit,
  1859. .fb_cursor = viafb_cursor,
  1860. .fb_ioctl = viafb_ioctl,
  1861. .fb_sync = viafb_sync,
  1862. };
  1863. #ifdef MODULE
  1864. module_param(viafb_mode, charp, S_IRUSR);
  1865. MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
  1866. module_param(viafb_mode1, charp, S_IRUSR);
  1867. MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
  1868. module_param(viafb_bpp, int, S_IRUSR);
  1869. MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
  1870. module_param(viafb_bpp1, int, S_IRUSR);
  1871. MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
  1872. module_param(viafb_refresh, int, S_IRUSR);
  1873. MODULE_PARM_DESC(viafb_refresh,
  1874. "Set CRT viafb_refresh rate (default = 60)");
  1875. module_param(viafb_refresh1, int, S_IRUSR);
  1876. MODULE_PARM_DESC(viafb_refresh1,
  1877. "Set CRT refresh rate (default = 60)");
  1878. module_param(viafb_lcd_panel_id, int, S_IRUSR);
  1879. MODULE_PARM_DESC(viafb_lcd_panel_id,
  1880. "Set Flat Panel type(Default=1024x768)");
  1881. module_param(viafb_lcd_dsp_method, int, S_IRUSR);
  1882. MODULE_PARM_DESC(viafb_lcd_dsp_method,
  1883. "Set Flat Panel display scaling method.(Default=Expandsion)");
  1884. module_param(viafb_SAMM_ON, int, S_IRUSR);
  1885. MODULE_PARM_DESC(viafb_SAMM_ON,
  1886. "Turn on/off flag of SAMM(Default=OFF)");
  1887. module_param(viafb_accel, int, S_IRUSR);
  1888. MODULE_PARM_DESC(viafb_accel,
  1889. "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
  1890. module_param(viafb_active_dev, charp, S_IRUSR);
  1891. MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
  1892. module_param(viafb_display_hardware_layout, int, S_IRUSR);
  1893. MODULE_PARM_DESC(viafb_display_hardware_layout,
  1894. "Display Hardware Layout (LCD Only, DVI Only...,etc)");
  1895. module_param(viafb_second_size, int, S_IRUSR);
  1896. MODULE_PARM_DESC(viafb_second_size,
  1897. "Set secondary device memory size");
  1898. module_param(viafb_dual_fb, int, S_IRUSR);
  1899. MODULE_PARM_DESC(viafb_dual_fb,
  1900. "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
  1901. module_param(viafb_platform_epia_dvi, int, S_IRUSR);
  1902. MODULE_PARM_DESC(viafb_platform_epia_dvi,
  1903. "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
  1904. module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
  1905. MODULE_PARM_DESC(viafb_device_lcd_dualedge,
  1906. "Turn on/off flag of dual edge panel.(Default = OFF)");
  1907. module_param(viafb_bus_width, int, S_IRUSR);
  1908. MODULE_PARM_DESC(viafb_bus_width,
  1909. "Set bus width of panel.(Default = 12)");
  1910. module_param(viafb_lcd_mode, int, S_IRUSR);
  1911. MODULE_PARM_DESC(viafb_lcd_mode,
  1912. "Set Flat Panel mode(Default=OPENLDI)");
  1913. module_param(viafb_lcd_port, charp, S_IRUSR);
  1914. MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
  1915. module_param(viafb_dvi_port, charp, S_IRUSR);
  1916. MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
  1917. MODULE_LICENSE("GPL");
  1918. #endif