viafbdev.c 60 KB

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