viafbdev.c 60 KB

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