viafbdev.c 60 KB

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