pm3fb.c 109 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642
  1. /*
  2. * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
  3. *
  4. * Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr>
  5. * Based on code written by:
  6. * Sven Luther, <luther@dpt-info.u-strasbg.fr>
  7. * Alan Hourihane, <alanh@fairlite.demon.co.uk>
  8. * Russell King, <rmk@arm.linux.org.uk>
  9. * Based on linux/drivers/video/skeletonfb.c:
  10. * Copyright (C) 1997 Geert Uytterhoeven
  11. * Based on linux/driver/video/pm2fb.c:
  12. * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
  13. * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file COPYING in the main directory of this archive for
  17. * more details.
  18. *
  19. * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $
  20. *
  21. * CHANGELOG:
  22. * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update.
  23. * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2.
  24. * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16.
  25. * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings.
  26. * Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes.
  27. * Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix.
  28. * Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG.
  29. * Wed Jun 20 11:13:08 MET DST 2001, v 1.4.5: Fixed missing blinking cursor in 8bpp, code cleaning, memory erase IOCTL.
  30. * Mon Jun 18 16:00:27 CEST 2001, v 1.4.4: Depth 12 (RGBA 4444) support, code cleaning.
  31. * Fri Jun 15 13:53:01 CEST 2001, v 1.4.3: Removed warnings, depth 15 support, add 'depth' option.
  32. * Thu Jun 14 10:13:52 MET DST 2001, v 1.4.2: Fixed depth switching bug, preliminary 15bpp (RGB5551) support.
  33. * Thu Apr 12 11:16:45 MET DST 2001, v 1.4.1B: Doc updates.
  34. * Fri Apr 6 11:12:53 MET DST 2001, v 1.4.1: Configure.help, minor cleanup
  35. * Thu Mar 29 10:56:50 MET DST 2001, v 1.4.0: Module & module options support (note: linux patch changed, 2.2.19 added).
  36. * Thu Mar 15 15:30:31 MET 2001, v 1.3.2: Fixed mirroring bug on little-endian.
  37. * Wed Mar 14 21:25:54 CET 2001, v 1.3.1: Fixed bug in BlockMove (_bmov).
  38. * Tue Mar 13 10:53:19 MET 2001, v 1.3.0: Character drawing hardware support (in all width between 1 and 16), fixes.
  39. * Thu Mar 8 10:20:16 MET 2001, v 1.2.2: Better J2000 support, "font:" option.
  40. * Tue Mar 6 21:25:04 CET 2001, v 1.2.1: Better acceleration support.
  41. * Mon Mar 5 21:54:17 CET 2001, v 1.2.0: Partial acceleration support (clear & bmove)
  42. * Mon Mar 5 12:52:15 CET 2001, v 1.1.3: Big pan_display fix.
  43. * Sun Mar 4 22:21:50 CET 2001, v 1.1.2: (numerous) bug fixes.
  44. * Fri Mar 2 15:54:07 CET 2001, v 1.1.1: Might have Appian J2000 support, resource mangement in 2.4
  45. * Wed Feb 28 18:21:35 CET 2001, v 1.1.0: Might have multiple boards support (added, but not yest tested)
  46. * Tue Feb 27 17:31:12 CET 2001, v 1.0.6: fixes boot-time mode select, add more default mode
  47. * Tue Feb 27 14:01:36 CET 2001, v 1.0.5: fixes (1.0.4 was broken for 2.2), cleaning up
  48. * Mon Feb 26 23:17:36 CET 2001, v 1.0.4: preliminary 2.4.x support, dropped (useless on pm3) partial product, more OF fix
  49. * Mon Feb 26 20:59:05 CET 2001, v 1.0.3: No more shadow register (and wasted memory), endianess fix, use OF-preset resolution by default
  50. * Wed Feb 21 22:09:30 CET 2001, v 1.0.2: Code cleaning for future multiboard support, better OF support, bugs fix
  51. * Wed Feb 21 19:58:56 CET 2001, v 1.0.1: OpenFirmware support, fixed memory detection, better debug support, code cleaning
  52. * Wed Feb 21 14:47:06 CET 2001, v 1.0.0: First working version
  53. */
  54. #include <linux/module.h>
  55. #include <linux/kernel.h>
  56. #include <linux/errno.h>
  57. #include <linux/string.h>
  58. #include <linux/mm.h>
  59. #include <linux/tty.h>
  60. #include <linux/slab.h>
  61. #include <linux/vmalloc.h>
  62. #include <linux/delay.h>
  63. #include <linux/interrupt.h>
  64. #include <linux/fb.h>
  65. #include <linux/init.h>
  66. #include <linux/pci.h>
  67. #include <linux/ioport.h>
  68. #include <linux/ctype.h>
  69. #include <video/fbcon.h>
  70. #include <video/fbcon-mfb.h>
  71. #include <video/fbcon-cfb2.h>
  72. #include <video/fbcon-cfb4.h>
  73. #include <video/fbcon-cfb8.h>
  74. #include <video/fbcon-cfb16.h>
  75. #include <video/fbcon-cfb24.h>
  76. #include <video/fbcon-cfb32.h>
  77. #include <video/pm3fb.h>
  78. #include <asm/io.h>
  79. #include <asm/uaccess.h>
  80. #ifdef CONFIG_FB_OF
  81. #include <asm/prom.h>
  82. #endif
  83. /* ************************************* */
  84. /* ***** The various "global" data ***** */
  85. /* ************************************* */
  86. /* those will need a rework for multiple board support */
  87. /* Driver name */
  88. static const char permedia3_name[16] = "Permedia3";
  89. /* the fb_par struct, mandatory */
  90. struct pm3fb_par {
  91. u32 pixclock; /* pixclock in KHz */
  92. u32 width; /* width of virtual screen */
  93. u32 height; /* height of virtual screen */
  94. u32 hsstart; /* horiz. sync start */
  95. u32 hsend; /* horiz. sync end */
  96. u32 hbend; /* horiz. blank end (also gate end) */
  97. u32 htotal; /* total width (w/ sync & blank) */
  98. u32 vsstart; /* vert. sync start */
  99. u32 vsend; /* vert. sync end */
  100. u32 vbend; /* vert. blank end */
  101. u32 vtotal; /* total height (w/ sync & blank) */
  102. u32 stride; /* screen stride */
  103. u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
  104. /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */
  105. u32 depth; /* screen depth (8, 12, 15, 16 or 32) */
  106. u32 video; /* video control (hsync,vsync) */
  107. };
  108. /* memory timings */
  109. struct pm3fb_timings
  110. {
  111. unsigned long caps;
  112. unsigned long timings;
  113. unsigned long control;
  114. unsigned long refresh;
  115. unsigned long powerdown;
  116. };
  117. typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result;
  118. #define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1)
  119. #define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE }
  120. /* the fb_info struct, mandatory */
  121. struct pm3fb_info {
  122. struct fb_info_gen gen;
  123. unsigned long board_num; /* internal board number */
  124. unsigned long use_current;
  125. struct pm3fb_par *current_par;
  126. struct pci_dev *dev; /* PCI device */
  127. unsigned long board_type; /* index in the cardbase */
  128. unsigned char *fb_base; /* framebuffer memory base */
  129. u32 fb_size; /* framebuffer memory size */
  130. unsigned char *p_fb; /* physical address of frame buffer */
  131. unsigned char *v_fb; /* virtual address of frame buffer */
  132. unsigned char *pIOBase; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */
  133. unsigned char *vIOBase; /* address of registers after ioremap() */
  134. struct {
  135. u8 transp;
  136. u8 red;
  137. u8 green;
  138. u8 blue;
  139. } palette[256];
  140. union {
  141. #ifdef FBCON_HAS_CFB16
  142. u16 cmap12[16]; /* RGBA 4444 */
  143. u16 cmap15[16]; /* RGBA 5551 */
  144. u16 cmap16[16]; /* RGBA 5650 */
  145. #endif
  146. #ifdef FBCON_HAS_CFB32
  147. u32 cmap32[16];
  148. #endif
  149. } cmap;
  150. struct pm3fb_timings memt;
  151. };
  152. /* regular resolution database*/
  153. static struct {
  154. char name[16];
  155. struct pm3fb_par user_mode;
  156. } mode_base[] __initdata = {
  157. {
  158. "default-800x600", {
  159. 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
  160. 800, 0, 8,
  161. PM3VideoControl_ENABLE |
  162. PM3VideoControl_HSYNC_ACTIVE_HIGH
  163. |
  164. PM3VideoControl_VSYNC_ACTIVE_HIGH
  165. | PM3VideoControl_PIXELSIZE_8BIT}}, {
  166. "1024x768-74", {
  167. 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
  168. 806, 1024, 0, 8,
  169. PM3VideoControl_ENABLE |
  170. PM3VideoControl_HSYNC_ACTIVE_HIGH
  171. |
  172. PM3VideoControl_VSYNC_ACTIVE_HIGH
  173. | PM3VideoControl_PIXELSIZE_8BIT}}, {
  174. "1024x768-74-32", {
  175. 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
  176. 806, 1024, 0, 32,
  177. PM3VideoControl_ENABLE |
  178. PM3VideoControl_HSYNC_ACTIVE_HIGH
  179. |
  180. PM3VideoControl_VSYNC_ACTIVE_HIGH
  181. | PM3VideoControl_PIXELSIZE_32BIT}},
  182. /* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/
  183. {
  184. "SGI1600SW", {
  185. 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32,
  186. 1056, 1600, 0, 8,
  187. PM3VideoControl_ENABLE|
  188. PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW|
  189. PM3VideoControl_PIXELSIZE_32BIT}},
  190. /* ##### auto-generated mode, by fbtimings2pm3 */
  191. /* Generated mode : "640x480-60" */
  192. {
  193. "640x480-60", {
  194. 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45,
  195. 525, 640, 0, 8,
  196. PM3VideoControl_ENABLE |
  197. PM3VideoControl_HSYNC_ACTIVE_LOW
  198. |
  199. PM3VideoControl_VSYNC_ACTIVE_LOW
  200. | PM3VideoControl_PIXELSIZE_8BIT}},
  201. /* Generated mode : "640x480-72" */
  202. {
  203. "640x480-72", {
  204. 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520,
  205. 640, 0, 8,
  206. PM3VideoControl_ENABLE |
  207. PM3VideoControl_HSYNC_ACTIVE_LOW
  208. |
  209. PM3VideoControl_VSYNC_ACTIVE_LOW
  210. | PM3VideoControl_PIXELSIZE_8BIT}},
  211. /* Generated mode : "640x480-75" */
  212. {
  213. "640x480-75", {
  214. 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500,
  215. 640, 0, 8,
  216. PM3VideoControl_ENABLE |
  217. PM3VideoControl_HSYNC_ACTIVE_LOW
  218. |
  219. PM3VideoControl_VSYNC_ACTIVE_LOW
  220. | PM3VideoControl_PIXELSIZE_8BIT}},
  221. /* Generated mode : "640x480-90" */
  222. {
  223. "640x480-90", {
  224. 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533,
  225. 640, 0, 8,
  226. PM3VideoControl_ENABLE |
  227. PM3VideoControl_HSYNC_ACTIVE_LOW
  228. |
  229. PM3VideoControl_VSYNC_ACTIVE_LOW
  230. | PM3VideoControl_PIXELSIZE_8BIT}},
  231. /* Generated mode : "640x480-100" */
  232. {
  233. "640x480-100", {
  234. 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51,
  235. 531, 640, 0, 8,
  236. PM3VideoControl_ENABLE |
  237. PM3VideoControl_HSYNC_ACTIVE_LOW
  238. |
  239. PM3VideoControl_VSYNC_ACTIVE_LOW
  240. | PM3VideoControl_PIXELSIZE_8BIT}},
  241. /* Generated mode : "800x600-48-lace" */
  242. /* INTERLACED NOT SUPPORTED
  243. {"800x600-48-lace", {35999, 800, 600, 80, 208, 264, 1064, 11, 23, 102, 702, 800, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  244. INTERLACED NOT SUPPORTED */
  245. /* Generated mode : "800x600-56" */
  246. {
  247. "800x600-56", {
  248. 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625,
  249. 800, 0, 8,
  250. PM3VideoControl_ENABLE |
  251. PM3VideoControl_HSYNC_ACTIVE_HIGH
  252. |
  253. PM3VideoControl_VSYNC_ACTIVE_HIGH
  254. | PM3VideoControl_PIXELSIZE_8BIT}},
  255. /* Generated mode : "800x600-60" */
  256. {
  257. "800x600-60", {
  258. 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628,
  259. 800, 0, 8,
  260. PM3VideoControl_ENABLE |
  261. PM3VideoControl_HSYNC_ACTIVE_HIGH
  262. |
  263. PM3VideoControl_VSYNC_ACTIVE_HIGH
  264. | PM3VideoControl_PIXELSIZE_8BIT}},
  265. /* Generated mode : "800x600-70" */
  266. {
  267. "800x600-70", {
  268. 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36,
  269. 636, 800, 0, 8,
  270. PM3VideoControl_ENABLE |
  271. PM3VideoControl_HSYNC_ACTIVE_HIGH
  272. |
  273. PM3VideoControl_VSYNC_ACTIVE_LOW
  274. | PM3VideoControl_PIXELSIZE_8BIT}},
  275. /* Generated mode : "800x600-72" */
  276. {
  277. "800x600-72", {
  278. 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66,
  279. 666, 800, 0, 8,
  280. PM3VideoControl_ENABLE |
  281. PM3VideoControl_HSYNC_ACTIVE_HIGH
  282. |
  283. PM3VideoControl_VSYNC_ACTIVE_HIGH
  284. | PM3VideoControl_PIXELSIZE_8BIT}},
  285. /* Generated mode : "800x600-75" */
  286. {
  287. "800x600-75", {
  288. 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
  289. 800, 0, 8,
  290. PM3VideoControl_ENABLE |
  291. PM3VideoControl_HSYNC_ACTIVE_HIGH
  292. |
  293. PM3VideoControl_VSYNC_ACTIVE_HIGH
  294. | PM3VideoControl_PIXELSIZE_8BIT}},
  295. /* Generated mode : "800x600-90" */
  296. {
  297. "800x600-90", {
  298. 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635,
  299. 800, 0, 8,
  300. PM3VideoControl_ENABLE |
  301. PM3VideoControl_HSYNC_ACTIVE_HIGH
  302. |
  303. PM3VideoControl_VSYNC_ACTIVE_HIGH
  304. | PM3VideoControl_PIXELSIZE_8BIT}},
  305. /* Generated mode : "800x600-100", from /etc/fb.modes */
  306. /* DISABLED, hsstart == 0
  307. {
  308. "800x600-100", {
  309. 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625,
  310. 800, 0, 8,
  311. PM3VideoControl_ENABLE |
  312. PM3VideoControl_HSYNC_ACTIVE_HIGH
  313. |
  314. PM3VideoControl_VSYNC_ACTIVE_HIGH
  315. | PM3VideoControl_PIXELSIZE_8BIT}},
  316. */
  317. /* Generated mode : "800x600-100", from ??? */
  318. {
  319. "800x600-100", {
  320. 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8,
  321. PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
  322. PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
  323. /* Generated mode : "1024x768-43-lace" */
  324. /* INTERLACED NOT SUPPORTED
  325. {"1024x768-43-lace", {44899, 1024, 768, 8, 184, 240, 1264, 1, 9, 49, 817, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  326. INTERLACED NOT SUPPORTED */
  327. /* Generated mode : "1024x768-60" */
  328. {
  329. "1024x768-60", {
  330. 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38,
  331. 806, 1024, 0, 8,
  332. PM3VideoControl_ENABLE |
  333. PM3VideoControl_HSYNC_ACTIVE_LOW
  334. |
  335. PM3VideoControl_VSYNC_ACTIVE_LOW
  336. | PM3VideoControl_PIXELSIZE_8BIT}},
  337. /* Generated mode : "1024x768-70" */
  338. {
  339. "1024x768-70", {
  340. 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38,
  341. 806, 1024, 0, 8,
  342. PM3VideoControl_ENABLE |
  343. PM3VideoControl_HSYNC_ACTIVE_LOW
  344. |
  345. PM3VideoControl_VSYNC_ACTIVE_LOW
  346. | PM3VideoControl_PIXELSIZE_8BIT}},
  347. /* Generated mode : "1024x768-72" */
  348. {
  349. "1024x768-72", {
  350. 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38,
  351. 806, 10224, 0, 8,
  352. PM3VideoControl_ENABLE |
  353. PM3VideoControl_HSYNC_ACTIVE_LOW
  354. |
  355. PM3VideoControl_VSYNC_ACTIVE_LOW
  356. | PM3VideoControl_PIXELSIZE_8BIT}},
  357. /* Generated mode : "1024x768-75" */
  358. {
  359. "1024x768-75", {
  360. 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32,
  361. 800, 1024, 0, 8,
  362. PM3VideoControl_ENABLE |
  363. PM3VideoControl_HSYNC_ACTIVE_HIGH
  364. |
  365. PM3VideoControl_VSYNC_ACTIVE_HIGH
  366. | PM3VideoControl_PIXELSIZE_8BIT}},
  367. /* Generated mode : "1024x768-90" */
  368. {
  369. "1024x768-90", {
  370. 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77,
  371. 845, 1024, 0, 8,
  372. PM3VideoControl_ENABLE |
  373. PM3VideoControl_HSYNC_ACTIVE_LOW
  374. |
  375. PM3VideoControl_VSYNC_ACTIVE_LOW
  376. | PM3VideoControl_PIXELSIZE_8BIT}},
  377. /* Generated mode : "1024x768-100", from /etc/fb.modes */
  378. /* DISABLED, vsstart == 0
  379. {
  380. "1024x768-100", {
  381. 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792,
  382. 1024, 0, 8,
  383. PM3VideoControl_ENABLE |
  384. PM3VideoControl_HSYNC_ACTIVE_LOW
  385. |
  386. PM3VideoControl_VSYNC_ACTIVE_LOW
  387. | PM3VideoControl_PIXELSIZE_8BIT}},
  388. */
  389. /* Generated mode : "1024x768-100", from ??? */
  390. {
  391. "1024x768-100", {
  392. 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8,
  393. PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
  394. PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
  395. /* Generated mode : "1152x864-43-lace" */
  396. /* INTERLACED NOT SUPPORTED
  397. {"1152x864-43-lace", {64998, 1152, 864, 72, 200, 264, 1416, 78, 87, 191, 1055, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  398. INTERLACED NOT SUPPORTED */
  399. /* Generated mode : "1152x864-47-lace" */
  400. /* INTERLACED NOT SUPPORTED
  401. {"1152x864-47-lace", {64998, 1152, 864, 88, 216, 296, 1448, 30, 39, 83, 947, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  402. INTERLACED NOT SUPPORTED */
  403. /* Generated mode : "1152x864-60" */
  404. {
  405. "1152x864-60", {
  406. 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52,
  407. 916, 1152, 0, 8,
  408. PM3VideoControl_ENABLE |
  409. PM3VideoControl_HSYNC_ACTIVE_HIGH
  410. |
  411. PM3VideoControl_VSYNC_ACTIVE_HIGH
  412. | PM3VideoControl_PIXELSIZE_8BIT}},
  413. /* Generated mode : "1152x864-70" */
  414. {
  415. "1152x864-70", {
  416. 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81,
  417. 945, 1152, 0, 8,
  418. PM3VideoControl_ENABLE |
  419. PM3VideoControl_HSYNC_ACTIVE_HIGH
  420. |
  421. PM3VideoControl_VSYNC_ACTIVE_HIGH
  422. | PM3VideoControl_PIXELSIZE_8BIT}},
  423. /* Generated mode : "1152x864-75" */
  424. {
  425. "1152x864-75", {
  426. 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138,
  427. 1002, 1152, 0, 8,
  428. PM3VideoControl_ENABLE |
  429. PM3VideoControl_HSYNC_ACTIVE_HIGH
  430. |
  431. PM3VideoControl_VSYNC_ACTIVE_HIGH
  432. | PM3VideoControl_PIXELSIZE_8BIT}},
  433. /* Generated mode : "1152x864-80" */
  434. {
  435. "1152x864-80", {
  436. 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94,
  437. 958, 1152, 0, 8,
  438. PM3VideoControl_ENABLE |
  439. PM3VideoControl_HSYNC_ACTIVE_HIGH
  440. |
  441. PM3VideoControl_VSYNC_ACTIVE_HIGH
  442. | PM3VideoControl_PIXELSIZE_8BIT}},
  443. /* Generated mode : "1280x1024-43-lace" */
  444. /* INTERLACED NOT SUPPORTED
  445. {"1280x1024-43-lace", {80000, 1024, 1024, 80, 160, 320, 1344, 50, 60, 125, 1149, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  446. INTERLACED NOT SUPPORTED */
  447. /* Generated mode : "1280x1024-47-lace" */
  448. /* INTERLACED NOT SUPPORTED
  449. {"1280x1024-47-lace", {80000, 1280, 1024, 80, 160, 320, 1600, 1, 11, 29, 1053, 1280, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
  450. INTERLACED NOT SUPPORTED */
  451. /* Generated mode : "1280x1024-60" */
  452. {
  453. "1280x1024-60", {
  454. 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42,
  455. 1066, 1280, 0, 8,
  456. PM3VideoControl_ENABLE |
  457. PM3VideoControl_HSYNC_ACTIVE_HIGH
  458. |
  459. PM3VideoControl_VSYNC_ACTIVE_HIGH
  460. | PM3VideoControl_PIXELSIZE_8BIT}},
  461. /* Generated mode : "1280x1024-70" */
  462. {
  463. "1280x1024-70", {
  464. 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42,
  465. 1066, 1280, 0, 8,
  466. PM3VideoControl_ENABLE |
  467. PM3VideoControl_HSYNC_ACTIVE_HIGH
  468. |
  469. PM3VideoControl_VSYNC_ACTIVE_HIGH
  470. | PM3VideoControl_PIXELSIZE_8BIT}},
  471. /* Generated mode : "1280x1024-74" */
  472. {
  473. "1280x1024-74", {
  474. 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40,
  475. 1064, 1280, 0, 8,
  476. PM3VideoControl_ENABLE |
  477. PM3VideoControl_HSYNC_ACTIVE_HIGH
  478. |
  479. PM3VideoControl_VSYNC_ACTIVE_HIGH
  480. | PM3VideoControl_PIXELSIZE_8BIT}},
  481. /* Generated mode : "1280x1024-75" */
  482. {
  483. "1280x1024-75", {
  484. 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42,
  485. 1066, 1280, 0, 8,
  486. PM3VideoControl_ENABLE |
  487. PM3VideoControl_HSYNC_ACTIVE_HIGH
  488. |
  489. PM3VideoControl_VSYNC_ACTIVE_HIGH
  490. | PM3VideoControl_PIXELSIZE_8BIT}},
  491. /* Generated mode : "1600x1200-60" */
  492. {
  493. "1600x1200-60", {
  494. 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70,
  495. 1270, 1600, 0, 8,
  496. PM3VideoControl_ENABLE |
  497. PM3VideoControl_HSYNC_ACTIVE_LOW
  498. |
  499. PM3VideoControl_VSYNC_ACTIVE_LOW
  500. | PM3VideoControl_PIXELSIZE_8BIT}},
  501. /* Generated mode : "1600x1200-66" */
  502. {
  503. "1600x1200-66", {
  504. 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53,
  505. 1253, 1600, 0, 8,
  506. PM3VideoControl_ENABLE |
  507. PM3VideoControl_HSYNC_ACTIVE_LOW
  508. |
  509. PM3VideoControl_VSYNC_ACTIVE_LOW
  510. | PM3VideoControl_PIXELSIZE_8BIT}},
  511. /* Generated mode : "1600x1200-76" */
  512. {
  513. "1600x1200-76", {
  514. 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50,
  515. 1250, 1600, 0, 8,
  516. PM3VideoControl_ENABLE |
  517. PM3VideoControl_HSYNC_ACTIVE_LOW
  518. |
  519. PM3VideoControl_VSYNC_ACTIVE_LOW
  520. | PM3VideoControl_PIXELSIZE_8BIT}},
  521. /* ##### end of auto-generated mode */
  522. {
  523. "\0",}
  524. };
  525. /* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */
  526. static struct pm3fb_info fb_info[PM3_MAX_BOARD];
  527. static struct pm3fb_par current_par[PM3_MAX_BOARD];
  528. static int current_par_valid[PM3_MAX_BOARD];
  529. /* to allow explicit filtering of board */
  530. short bus[PM3_MAX_BOARD];
  531. short slot[PM3_MAX_BOARD];
  532. short func[PM3_MAX_BOARD];
  533. short disable[PM3_MAX_BOARD];
  534. short noaccel[PM3_MAX_BOARD];
  535. char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE];
  536. short depth[PM3_MAX_BOARD];
  537. short flatpanel[PM3_MAX_BOARD];
  538. static struct display disp[PM3_MAX_BOARD];
  539. static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy";
  540. short printtimings = 0;
  541. short forcesize[PM3_MAX_BOARD];
  542. /* ********************* */
  543. /* ***** prototype ***** */
  544. /* ********************* */
  545. /* card-specific */
  546. static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info);
  547. /* permedia3-specific */
  548. static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info);
  549. static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info);
  550. static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info);
  551. static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
  552. unsigned long r);
  553. static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */
  554. unsigned long refclock, /* In kHz units */
  555. unsigned char *prescale, /* ClkPreScale */
  556. unsigned char *feedback, /* ClkFeedBackScale */
  557. unsigned char *postscale
  558. /* ClkPostScale */ );
  559. static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc);
  560. static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b);
  561. static void pm3fb_common_init(struct pm3fb_info *l_fb_info);
  562. static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
  563. unsigned long depth, int v);
  564. static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
  565. unsigned long depth, int v);
  566. static void pm3fb_mapIO(struct pm3fb_info *l_fb_info);
  567. static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info);
  568. #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
  569. static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info);
  570. #endif
  571. static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info);
  572. static void pm3fb_write_mode(struct pm3fb_info *l_fb_info);
  573. static void pm3fb_read_mode(struct pm3fb_info *l_fb_info,
  574. struct pm3fb_par *curpar);
  575. static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info);
  576. /* accelerated permedia3-specific */
  577. #ifdef PM3FB_USE_ACCEL
  578. static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info);
  579. static void pm3fb_init_engine(struct pm3fb_info *l_fb_info);
  580. #ifdef FBCON_HAS_CFB32
  581. static void pm3fb_cfb32_clear(struct vc_data *conp,
  582. struct display *p,
  583. int sy, int sx, int height, int width);
  584. static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
  585. struct display *p, int bottom_only);
  586. #endif /* FBCON_HAS_CFB32 */
  587. #ifdef FBCON_HAS_CFB16
  588. static void pm3fb_cfb16_clear(struct vc_data *conp,
  589. struct display *p,
  590. int sy, int sx, int height, int width);
  591. static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
  592. struct display *p, int bottom_only);
  593. #endif /* FBCON_HAS_CFB16 */
  594. #ifdef FBCON_HAS_CFB8
  595. static void pm3fb_cfb8_clear(struct vc_data *conp,
  596. struct display *p,
  597. int sy, int sx, int height, int width);
  598. static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
  599. struct display *p, int bottom_only);
  600. #endif /* FBCON_HAS_CFB8 */
  601. #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
  602. static void pm3fb_cfbX_bmove(struct display *p,
  603. int sy, int sx,
  604. int dy, int dx, int height, int width);
  605. static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
  606. int c, int yy, int xx);
  607. static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
  608. const unsigned short *s, int count, int yy,
  609. int xx);
  610. static void pm3fb_cfbX_revc(struct display *p, int xx, int yy);
  611. #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
  612. #endif /* PM3FB_USE_ACCEL */
  613. /* pre-init */
  614. static void pm3fb_mode_setup(char *mode, unsigned long board_num);
  615. static void pm3fb_pciid_setup(char *pciid, unsigned long board_num);
  616. static char *pm3fb_boardnum_setup(char *options, unsigned long *bn);
  617. static void pm3fb_real_setup(char *options);
  618. /* fbdev */
  619. static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
  620. const void *par, struct fb_info_gen *info);
  621. static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
  622. void *par, struct fb_info_gen *info);
  623. static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d);
  624. static int pm3fb_encode_var(struct fb_var_screeninfo *var,
  625. const void *par, struct fb_info_gen *info);
  626. static void pm3fb_get_par(void *par, struct fb_info_gen *info);
  627. static void pm3fb_set_par(const void *par, struct fb_info_gen *info);
  628. static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
  629. unsigned char regno, unsigned char r,
  630. unsigned char g, unsigned char b);
  631. static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
  632. unsigned *blue, unsigned *transp,
  633. struct fb_info *info);
  634. static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
  635. unsigned blue, unsigned transp,
  636. struct fb_info *info);
  637. static int pm3fb_blank(int blank_mode, struct fb_info_gen *info);
  638. static void pm3fb_set_disp(const void *par, struct display *disp,
  639. struct fb_info_gen *info);
  640. static void pm3fb_detect(void);
  641. static int pm3fb_pan_display(const struct fb_var_screeninfo *var,
  642. struct fb_info_gen *info);
  643. static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg);
  644. /* the struct that hold them together */
  645. struct fbgen_hwswitch pm3fb_switch = {
  646. pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var,
  647. pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg,
  648. pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp
  649. };
  650. static struct fb_ops pm3fb_ops = {
  651. .owner = THIS_MODULE,
  652. .fb_get_fix = fbgen_get_fix,
  653. .fb_get_var = fbgen_get_var,
  654. .fb_set_var = fbgen_set_var,
  655. .fb_get_cmap = fbgen_get_cmap,
  656. .fb_set_cmap = fbgen_set_cmap,
  657. .fb_setcolreg = pm3fb_setcolreg,
  658. .fb_pan_display =fbgen_pan_display,
  659. .fb_blank = fbgen_blank,
  660. .fb_ioctl = pm3fb_ioctl,
  661. };
  662. #ifdef PM3FB_USE_ACCEL
  663. #ifdef FBCON_HAS_CFB32
  664. static struct display_switch pm3fb_cfb32 = {
  665. fbcon_cfb32_setup, pm3fb_cfbX_bmove, pm3fb_cfb32_clear,
  666. pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
  667. NULL /* cursor() */ , NULL /* set_font() */ ,
  668. pm3fb_cfb32_clear_margins,
  669. FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
  670. };
  671. #endif /* FBCON_HAS_CFB32 */
  672. #ifdef FBCON_HAS_CFB16
  673. static struct display_switch pm3fb_cfb16 = {
  674. fbcon_cfb16_setup, pm3fb_cfbX_bmove, pm3fb_cfb16_clear,
  675. pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
  676. NULL /* cursor() */ , NULL /* set_font() */ ,
  677. pm3fb_cfb16_clear_margins,
  678. FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
  679. };
  680. #endif /* FBCON_HAS_CFB16 */
  681. #ifdef FBCON_HAS_CFB8
  682. static struct display_switch pm3fb_cfb8 = {
  683. fbcon_cfb8_setup, pm3fb_cfbX_bmove, pm3fb_cfb8_clear,
  684. pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
  685. NULL /* cursor() */ , NULL /* set_font() */ ,
  686. pm3fb_cfb8_clear_margins,
  687. FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
  688. };
  689. #endif /* FBCON_HAS_CFB8 */
  690. #endif /* PM3FB_USE_ACCEL */
  691. /* ****************************** */
  692. /* ***** card-specific data ***** */
  693. /* ****************************** */
  694. struct pm3fb_card_timings {
  695. unsigned long memsize; /* 0 for last value (i.e. default) */
  696. struct pm3fb_timings memt;
  697. };
  698. static struct pm3fb_card_timings t_FormacProFormance3[] = {
  699. { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} },
  700. { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */
  701. };
  702. static struct pm3fb_card_timings t_AppianJeronimo2000[] = {
  703. { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} },
  704. { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */
  705. };
  706. static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = {
  707. { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} },
  708. { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */
  709. };
  710. static struct {
  711. char cardname[32]; /* recognized card name */
  712. u16 subvendor; /* subvendor of the card */
  713. u16 subdevice; /* subdevice of the card */
  714. u8 func; /* function of the card to which the extra init apply */
  715. void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */
  716. struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */
  717. } cardbase[] = {
  718. { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL },
  719. { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL,
  720. t_AppianJeronimo2000
  721. },
  722. { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup,
  723. t_AppianJeronimo2000
  724. },
  725. { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */
  726. t_FormacProFormance3
  727. },
  728. { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL },
  729. { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL,
  730. t_3DLabsOxygenVX1
  731. },
  732. { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL },
  733. { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL },
  734. { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL },
  735. { "\0", 0x0, 0x0, 0, NULL, NULL }
  736. };
  737. /* ********************************** */
  738. /* ***** card-specific function ***** */
  739. /* ********************************** */
  740. static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info)
  741. { /* the appian j2000 require more initialization of the second head */
  742. /* l_fb_info must point to the _second_ head of the J2000 */
  743. DTRACE;
  744. l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */
  745. pm3fb_write_memory_timings(l_fb_info);
  746. }
  747. /* *************************************** */
  748. /* ***** permedia3-specific function ***** */
  749. /* *************************************** */
  750. static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info)
  751. {
  752. l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps);
  753. l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings);
  754. l_fb_info->memt.control = PM3_READ_REG(PM3LocalMemControl);
  755. l_fb_info->memt.refresh = PM3_READ_REG(PM3LocalMemRefresh);
  756. l_fb_info->memt.powerdown = PM3_READ_REG(PM3LocalMemPowerDown);
  757. if ((l_fb_info->memt.caps == PM3FB_UNKNOWN_TIMING_VALUE) ||
  758. (l_fb_info->memt.timings == PM3FB_UNKNOWN_TIMING_VALUE) ||
  759. (l_fb_info->memt.control == PM3FB_UNKNOWN_TIMING_VALUE) ||
  760. (l_fb_info->memt.refresh == PM3FB_UNKNOWN_TIMING_VALUE) ||
  761. (l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE))
  762. {
  763. printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num);
  764. return(pm3fb_try_memory_timings(l_fb_info));
  765. }
  766. return(pm3fb_timing_ok);
  767. }
  768. static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info)
  769. {
  770. if (cardbase[l_fb_info->board_type].c_memt)
  771. {
  772. int i = 0, done = 0;
  773. while (!done)
  774. {
  775. if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size)
  776. || !(cardbase[l_fb_info->board_type].c_memt[i].memsize))
  777. { /* will use the 0-sized timings by default */
  778. done = 1;
  779. l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt;
  780. printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n",
  781. l_fb_info->board_num,
  782. cardbase[l_fb_info->board_type].cardname,
  783. cardbase[l_fb_info->board_type].c_memt[i].memsize);
  784. pm3fb_write_memory_timings(l_fb_info);
  785. return(pm3fb_timing_retry);
  786. }
  787. i++;
  788. }
  789. } else
  790. return(pm3fb_timing_problem);
  791. return(pm3fb_timing_ok);
  792. }
  793. static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info)
  794. {
  795. unsigned char m, n, p;
  796. unsigned long clockused;
  797. PM3_SLOW_WRITE_REG(PM3LocalMemCaps, l_fb_info->memt.caps);
  798. PM3_SLOW_WRITE_REG(PM3LocalMemTimings, l_fb_info->memt.timings);
  799. PM3_SLOW_WRITE_REG(PM3LocalMemControl, l_fb_info->memt.control);
  800. PM3_SLOW_WRITE_REG(PM3LocalMemRefresh, l_fb_info->memt.refresh);
  801. PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown, l_fb_info->memt.powerdown);
  802. clockused =
  803. pm3fb_CalculateClock(l_fb_info, 2 * 105000, PM3_REF_CLOCK, &m,
  804. &n, &p);
  805. PM3_WRITE_DAC_REG(PM3RD_KClkPreScale, m);
  806. PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale, n);
  807. PM3_WRITE_DAC_REG(PM3RD_KClkPostScale, p);
  808. PM3_WRITE_DAC_REG(PM3RD_KClkControl,
  809. PM3RD_KClkControl_STATE_RUN |
  810. PM3RD_KClkControl_SOURCE_PLL |
  811. PM3RD_KClkControl_ENABLE);
  812. PM3_WRITE_DAC_REG(PM3RD_MClkControl,
  813. PM3RD_MClkControl_STATE_RUN |
  814. PM3RD_MClkControl_SOURCE_KCLK |
  815. PM3RD_MClkControl_ENABLE);
  816. PM3_WRITE_DAC_REG(PM3RD_SClkControl,
  817. PM3RD_SClkControl_STATE_RUN |
  818. PM3RD_SClkControl_SOURCE_PCLK |
  819. PM3RD_SClkControl_ENABLE);
  820. }
  821. static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
  822. unsigned long r)
  823. {
  824. DASSERT((l_fb_info->vIOBase != (unsigned char *) (-1)),
  825. "l_fb_info->vIOBase mapped in read dac reg\n");
  826. PM3_SET_INDEX(r);
  827. mb();
  828. return (PM3_READ_REG(PM3RD_IndexedData));
  829. }
  830. /* Calculating various clock parameter */
  831. static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */
  832. unsigned long refclock, /* In kHz units */
  833. unsigned char *prescale, /* ClkPreScale */
  834. unsigned char *feedback, /* ClkFeedBackScale */
  835. unsigned char *postscale
  836. /* ClkPostScale */ )
  837. {
  838. int f, pre, post;
  839. unsigned long freq;
  840. long freqerr = 1000;
  841. unsigned long actualclock = 0;
  842. DTRACE;
  843. for (f = 1; f < 256; f++) {
  844. for (pre = 1; pre < 256; pre++) {
  845. for (post = 0; post < 5; post++) {
  846. freq =
  847. ((2 * refclock * f) /
  848. (pre * (1 << post)));
  849. if ((reqclock > freq - freqerr)
  850. && (reqclock < freq + freqerr)) {
  851. freqerr =
  852. (reqclock >
  853. freq) ? reqclock -
  854. freq : freq - reqclock;
  855. *feedback = f;
  856. *prescale = pre;
  857. *postscale = post;
  858. actualclock = freq;
  859. }
  860. }
  861. }
  862. }
  863. return (actualclock);
  864. }
  865. static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
  866. unsigned long depth, int v)
  867. {
  868. DTRACE;
  869. switch (depth) {
  870. case 8:
  871. return (v >> 4);
  872. case 12:
  873. case 15:
  874. case 16:
  875. return (v >> 3);
  876. case 32:
  877. return (v >> 2);
  878. }
  879. DPRINTK(1, "Unsupported depth %ld\n", depth);
  880. return (0);
  881. }
  882. static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
  883. unsigned long depth, int v)
  884. {
  885. DTRACE;
  886. switch (depth) {
  887. case 8:
  888. return (v << 4);
  889. case 12:
  890. case 15:
  891. case 16:
  892. return (v << 3);
  893. case 32:
  894. return (v << 2);
  895. }
  896. DPRINTK(1, "Unsupported depth %ld\n", depth);
  897. return (0);
  898. }
  899. static void pm3fb_mapIO(struct pm3fb_info *l_fb_info)
  900. {
  901. DTRACE;
  902. l_fb_info->vIOBase =
  903. ioremap((unsigned long) l_fb_info->pIOBase, PM3_REGS_SIZE);
  904. l_fb_info->v_fb =
  905. ioremap((unsigned long) l_fb_info->p_fb, l_fb_info->fb_size);
  906. DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n",
  907. (unsigned long) l_fb_info->pIOBase,
  908. (unsigned long) l_fb_info->vIOBase,
  909. (unsigned long) l_fb_info->p_fb,
  910. (unsigned long) l_fb_info->v_fb);
  911. }
  912. static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info)
  913. {
  914. DTRACE;
  915. iounmap(l_fb_info->vIOBase);
  916. iounmap(l_fb_info->v_fb);
  917. l_fb_info->vIOBase = (unsigned char *) -1;
  918. l_fb_info->v_fb = (unsigned char *) -1;
  919. }
  920. #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
  921. static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info)
  922. {
  923. DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0));
  924. DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1));
  925. DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n",
  926. PM3_READ_REG(PM3ByAperture1Mode));
  927. DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n",
  928. PM3_READ_REG(PM3ByAperture2Mode));
  929. DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig));
  930. DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis));
  931. DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal));
  932. DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd));
  933. DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd));
  934. DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd));
  935. DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart));
  936. DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n",
  937. PM3_READ_REG(PM3MemBypassWriteMask));
  938. DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n",
  939. PM3_READ_REG(PM3RD_IndexControl));
  940. DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase));
  941. DPRINTK(2, "PM3ScreenStride: 0x%08x\n",
  942. PM3_READ_REG(PM3ScreenStride));
  943. DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl));
  944. DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal));
  945. DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd));
  946. DPRINTK(2, "PM3VideoControl: 0x%08x\n",
  947. PM3_READ_REG(PM3VideoControl));
  948. DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd));
  949. DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart));
  950. DPRINTK(2, "PM3RD_ColorFormat: %ld\n",
  951. PM3_READ_DAC_REG(PM3RD_ColorFormat));
  952. DPRINTK(2, "PM3RD_DACControl: %ld\n",
  953. PM3_READ_DAC_REG(PM3RD_DACControl));
  954. DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n",
  955. PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale));
  956. DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n",
  957. PM3_READ_DAC_REG(PM3RD_DClk0PostScale));
  958. DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n",
  959. PM3_READ_DAC_REG(PM3RD_DClk0PreScale));
  960. DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n",
  961. PM3_READ_DAC_REG(PM3RD_IndexControl));
  962. DPRINTK(2, "PM3RD_MiscControl: %ld\n",
  963. PM3_READ_DAC_REG(PM3RD_MiscControl));
  964. DPRINTK(2, "PM3RD_PixelSize: %ld\n",
  965. PM3_READ_DAC_REG(PM3RD_PixelSize));
  966. DPRINTK(2, "PM3RD_SyncControl: %ld\n",
  967. PM3_READ_DAC_REG(PM3RD_SyncControl));
  968. }
  969. #endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */
  970. static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info)
  971. {
  972. u16 subvendor, subdevice;
  973. if ((!pci_read_config_word
  974. (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
  975. &&
  976. (!pci_read_config_word
  977. (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
  978. /* well, nothing... */
  979. } else {
  980. subvendor = subdevice = (u16)-1;
  981. }
  982. printk(KERN_INFO "pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info->board_num, subvendor, subdevice);
  983. printk(KERN_INFO " PM3LocalMemCaps: 0x%08x\n",
  984. PM3_READ_REG(PM3LocalMemCaps));
  985. printk(KERN_INFO " PM3LocalMemTimings: 0x%08x\n",
  986. PM3_READ_REG(PM3LocalMemTimings));
  987. printk(KERN_INFO " PM3LocalMemControl: 0x%08x\n",
  988. PM3_READ_REG(PM3LocalMemControl));
  989. printk(KERN_INFO " PM3LocalMemRefresh: 0x%08x\n",
  990. PM3_READ_REG(PM3LocalMemRefresh));
  991. printk(KERN_INFO " PM3LocalMemPowerDown: 0x%08x\n",
  992. PM3_READ_REG(PM3LocalMemPowerDown));
  993. }
  994. /* write the mode to registers */
  995. static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
  996. {
  997. char tempsync = 0x00, tempmisc = 0x00;
  998. DTRACE;
  999. PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff);
  1000. PM3_SLOW_WRITE_REG(PM3Aperture0, 0x00000000);
  1001. PM3_SLOW_WRITE_REG(PM3Aperture1, 0x00000000);
  1002. PM3_SLOW_WRITE_REG(PM3FIFODis, 0x00000007);
  1003. PM3_SLOW_WRITE_REG(PM3HTotal,
  1004. pm3fb_Shiftbpp(l_fb_info,
  1005. l_fb_info->current_par->depth,
  1006. l_fb_info->current_par->htotal -
  1007. 1));
  1008. PM3_SLOW_WRITE_REG(PM3HsEnd,
  1009. pm3fb_Shiftbpp(l_fb_info,
  1010. l_fb_info->current_par->depth,
  1011. l_fb_info->current_par->hsend));
  1012. PM3_SLOW_WRITE_REG(PM3HsStart,
  1013. pm3fb_Shiftbpp(l_fb_info,
  1014. l_fb_info->current_par->depth,
  1015. l_fb_info->current_par->
  1016. hsstart));
  1017. PM3_SLOW_WRITE_REG(PM3HbEnd,
  1018. pm3fb_Shiftbpp(l_fb_info,
  1019. l_fb_info->current_par->depth,
  1020. l_fb_info->current_par->hbend));
  1021. PM3_SLOW_WRITE_REG(PM3HgEnd,
  1022. pm3fb_Shiftbpp(l_fb_info,
  1023. l_fb_info->current_par->depth,
  1024. l_fb_info->current_par->hbend));
  1025. PM3_SLOW_WRITE_REG(PM3ScreenStride,
  1026. pm3fb_Shiftbpp(l_fb_info,
  1027. l_fb_info->current_par->depth,
  1028. l_fb_info->current_par->stride));
  1029. PM3_SLOW_WRITE_REG(PM3VTotal, l_fb_info->current_par->vtotal - 1);
  1030. PM3_SLOW_WRITE_REG(PM3VsEnd, l_fb_info->current_par->vsend - 1);
  1031. PM3_SLOW_WRITE_REG(PM3VsStart,
  1032. l_fb_info->current_par->vsstart - 1);
  1033. PM3_SLOW_WRITE_REG(PM3VbEnd, l_fb_info->current_par->vbend);
  1034. switch (l_fb_info->current_par->depth) {
  1035. case 8:
  1036. PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
  1037. PM3ByApertureMode_PIXELSIZE_8BIT);
  1038. PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
  1039. PM3ByApertureMode_PIXELSIZE_8BIT);
  1040. break;
  1041. case 12:
  1042. case 15:
  1043. case 16:
  1044. #ifndef __BIG_ENDIAN
  1045. PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
  1046. PM3ByApertureMode_PIXELSIZE_16BIT);
  1047. PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
  1048. PM3ByApertureMode_PIXELSIZE_16BIT);
  1049. #else
  1050. PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
  1051. PM3ByApertureMode_PIXELSIZE_16BIT |
  1052. PM3ByApertureMode_BYTESWAP_BADC);
  1053. PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
  1054. PM3ByApertureMode_PIXELSIZE_16BIT |
  1055. PM3ByApertureMode_BYTESWAP_BADC);
  1056. #endif /* ! __BIG_ENDIAN */
  1057. break;
  1058. case 32:
  1059. #ifndef __BIG_ENDIAN
  1060. PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
  1061. PM3ByApertureMode_PIXELSIZE_32BIT);
  1062. PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
  1063. PM3ByApertureMode_PIXELSIZE_32BIT);
  1064. #else
  1065. PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
  1066. PM3ByApertureMode_PIXELSIZE_32BIT |
  1067. PM3ByApertureMode_BYTESWAP_DCBA);
  1068. PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
  1069. PM3ByApertureMode_PIXELSIZE_32BIT |
  1070. PM3ByApertureMode_BYTESWAP_DCBA);
  1071. #endif /* ! __BIG_ENDIAN */
  1072. break;
  1073. default:
  1074. DPRINTK(1, "Unsupported depth %d\n",
  1075. l_fb_info->current_par->depth);
  1076. break;
  1077. }
  1078. /*
  1079. * Oxygen VX1 - it appears that setting PM3VideoControl and
  1080. * then PM3RD_SyncControl to the same SYNC settings undoes
  1081. * any net change - they seem to xor together. Only set the
  1082. * sync options in PM3RD_SyncControl. --rmk
  1083. */
  1084. {
  1085. unsigned int video = l_fb_info->current_par->video;
  1086. video &= ~(PM3VideoControl_HSYNC_MASK |
  1087. PM3VideoControl_VSYNC_MASK);
  1088. video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
  1089. PM3VideoControl_VSYNC_ACTIVE_HIGH;
  1090. PM3_SLOW_WRITE_REG(PM3VideoControl, video);
  1091. }
  1092. PM3_SLOW_WRITE_REG(PM3VClkCtl,
  1093. (PM3_READ_REG(PM3VClkCtl) & 0xFFFFFFFC));
  1094. PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base);
  1095. PM3_SLOW_WRITE_REG(PM3ChipConfig,
  1096. (PM3_READ_REG(PM3ChipConfig) & 0xFFFFFFFD));
  1097. {
  1098. unsigned char m; /* ClkPreScale */
  1099. unsigned char n; /* ClkFeedBackScale */
  1100. unsigned char p; /* ClkPostScale */
  1101. (void)pm3fb_CalculateClock(l_fb_info, l_fb_info->current_par->pixclock, PM3_REF_CLOCK, &m, &n, &p);
  1102. DPRINTK(2,
  1103. "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n",
  1104. l_fb_info->current_par->pixclock, (int) m, (int) n,
  1105. (int) p);
  1106. PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale, m);
  1107. PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale, n);
  1108. PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale, p);
  1109. }
  1110. /*
  1111. PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00);
  1112. */
  1113. /*
  1114. PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00);
  1115. */
  1116. if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) ==
  1117. PM3VideoControl_HSYNC_ACTIVE_HIGH)
  1118. tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
  1119. if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) ==
  1120. PM3VideoControl_VSYNC_ACTIVE_HIGH)
  1121. tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
  1122. PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync);
  1123. DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync);
  1124. if (flatpanel[l_fb_info->board_num])
  1125. {
  1126. PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE);
  1127. PM3_WAIT(2);
  1128. PM3_WRITE_REG(PM3VSConfiguration, 0x06);
  1129. PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */
  1130. tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE;
  1131. }
  1132. else
  1133. PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00);
  1134. switch (l_fb_info->current_par->depth) {
  1135. case 8:
  1136. PM3_WRITE_DAC_REG(PM3RD_PixelSize,
  1137. PM3RD_PixelSize_8_BIT_PIXELS);
  1138. PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
  1139. PM3RD_ColorFormat_CI8_COLOR |
  1140. PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
  1141. tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
  1142. break;
  1143. case 12:
  1144. PM3_WRITE_DAC_REG(PM3RD_PixelSize,
  1145. PM3RD_PixelSize_16_BIT_PIXELS);
  1146. PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
  1147. PM3RD_ColorFormat_4444_COLOR |
  1148. PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
  1149. PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
  1150. tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
  1151. PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
  1152. break;
  1153. case 15:
  1154. PM3_WRITE_DAC_REG(PM3RD_PixelSize,
  1155. PM3RD_PixelSize_16_BIT_PIXELS);
  1156. PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
  1157. PM3RD_ColorFormat_5551_FRONT_COLOR |
  1158. PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
  1159. PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
  1160. tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
  1161. PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
  1162. break;
  1163. case 16:
  1164. PM3_WRITE_DAC_REG(PM3RD_PixelSize,
  1165. PM3RD_PixelSize_16_BIT_PIXELS);
  1166. PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
  1167. PM3RD_ColorFormat_565_FRONT_COLOR |
  1168. PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
  1169. PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
  1170. tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
  1171. PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
  1172. break;
  1173. case 32:
  1174. PM3_WRITE_DAC_REG(PM3RD_PixelSize,
  1175. PM3RD_PixelSize_32_BIT_PIXELS);
  1176. PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
  1177. PM3RD_ColorFormat_8888_COLOR |
  1178. PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
  1179. tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
  1180. PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
  1181. break;
  1182. }
  1183. PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc);
  1184. PM3_SHOW_CUR_MODE;
  1185. }
  1186. static void pm3fb_read_mode(struct pm3fb_info *l_fb_info,
  1187. struct pm3fb_par *curpar)
  1188. {
  1189. unsigned long pixsize1, pixsize2, clockused;
  1190. unsigned long pre, feedback, post;
  1191. DTRACE;
  1192. clockused = PM3_READ_REG(PM3VClkCtl);
  1193. switch (clockused) {
  1194. case 3:
  1195. pre = PM3_READ_DAC_REG(PM3RD_DClk3PreScale);
  1196. feedback = PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale);
  1197. post = PM3_READ_DAC_REG(PM3RD_DClk3PostScale);
  1198. DPRINTK(2,
  1199. "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
  1200. pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
  1201. feedback,
  1202. post));
  1203. break;
  1204. case 2:
  1205. pre = PM3_READ_DAC_REG(PM3RD_DClk2PreScale);
  1206. feedback = PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale);
  1207. post = PM3_READ_DAC_REG(PM3RD_DClk2PostScale);
  1208. DPRINTK(2,
  1209. "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
  1210. pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
  1211. feedback,
  1212. post));
  1213. break;
  1214. case 1:
  1215. pre = PM3_READ_DAC_REG(PM3RD_DClk1PreScale);
  1216. feedback = PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale);
  1217. post = PM3_READ_DAC_REG(PM3RD_DClk1PostScale);
  1218. DPRINTK(2,
  1219. "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
  1220. pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
  1221. feedback,
  1222. post));
  1223. break;
  1224. case 0:
  1225. pre = PM3_READ_DAC_REG(PM3RD_DClk0PreScale);
  1226. feedback = PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale);
  1227. post = PM3_READ_DAC_REG(PM3RD_DClk0PostScale);
  1228. DPRINTK(2,
  1229. "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
  1230. pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
  1231. feedback,
  1232. post));
  1233. break;
  1234. default:
  1235. pre = feedback = post = 0;
  1236. DPRINTK(1, "Unknowk D clock used : %ld\n", clockused);
  1237. break;
  1238. }
  1239. curpar->pixclock = PM3_SCALE_TO_CLOCK(pre, feedback, post);
  1240. pixsize1 =
  1241. PM3ByApertureMode_PIXELSIZE_MASK &
  1242. (PM3_READ_REG(PM3ByAperture1Mode));
  1243. pixsize2 =
  1244. PM3ByApertureMode_PIXELSIZE_MASK &
  1245. (PM3_READ_REG(PM3ByAperture2Mode));
  1246. DASSERT((pixsize1 == pixsize2),
  1247. "pixsize the same in both aperture\n");
  1248. if (pixsize1 & PM3ByApertureMode_PIXELSIZE_32BIT)
  1249. curpar->depth = 32;
  1250. else if (pixsize1 & PM3ByApertureMode_PIXELSIZE_16BIT)
  1251. {
  1252. curpar->depth = 16;
  1253. }
  1254. else
  1255. curpar->depth = 8;
  1256. /* not sure if I need to add one on the next ; it give better result with */
  1257. curpar->htotal =
  1258. pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
  1259. 1 + PM3_READ_REG(PM3HTotal));
  1260. curpar->hsend =
  1261. pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
  1262. PM3_READ_REG(PM3HsEnd));
  1263. curpar->hsstart =
  1264. pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
  1265. PM3_READ_REG(PM3HsStart));
  1266. curpar->hbend =
  1267. pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
  1268. PM3_READ_REG(PM3HbEnd));
  1269. curpar->stride =
  1270. pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
  1271. PM3_READ_REG(PM3ScreenStride));
  1272. curpar->vtotal = 1 + PM3_READ_REG(PM3VTotal);
  1273. curpar->vsend = 1 + PM3_READ_REG(PM3VsEnd);
  1274. curpar->vsstart = 1 + PM3_READ_REG(PM3VsStart);
  1275. curpar->vbend = PM3_READ_REG(PM3VbEnd);
  1276. curpar->video = PM3_READ_REG(PM3VideoControl);
  1277. curpar->base = PM3_READ_REG(PM3ScreenBase);
  1278. curpar->width = curpar->htotal - curpar->hbend; /* make virtual == displayed resolution */
  1279. curpar->height = curpar->vtotal - curpar->vbend;
  1280. DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n",
  1281. curpar->width, curpar->height, curpar->pixclock,
  1282. curpar->stride);
  1283. }
  1284. static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info)
  1285. {
  1286. unsigned long memsize = 0, tempBypass, i, temp1, temp2;
  1287. u16 subvendor, subdevice;
  1288. pm3fb_timing_result ptr;
  1289. DTRACE;
  1290. l_fb_info->fb_size = 64 * 1024 * 1024; /* pm3 aperture always 64 MB */
  1291. pm3fb_mapIO(l_fb_info); /* temporary map IO */
  1292. DASSERT((l_fb_info->vIOBase != NULL),
  1293. "IO successfully mapped before mem detect\n");
  1294. DASSERT((l_fb_info->v_fb != NULL),
  1295. "FB successfully mapped before mem detect\n");
  1296. /* card-specific stuff, *before* accessing *any* FB memory */
  1297. if ((!pci_read_config_word
  1298. (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
  1299. &&
  1300. (!pci_read_config_word
  1301. (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
  1302. i = 0; l_fb_info->board_type = 0;
  1303. while ((cardbase[i].cardname[0]) && !(l_fb_info->board_type)) {
  1304. if ((cardbase[i].subvendor == subvendor) &&
  1305. (cardbase[i].subdevice == subdevice) &&
  1306. (cardbase[i].func == PCI_FUNC(l_fb_info->dev->devfn))) {
  1307. DPRINTK(2, "Card #%ld is an %s\n",
  1308. l_fb_info->board_num,
  1309. cardbase[i].cardname);
  1310. if (cardbase[i].specific_setup)
  1311. cardbase[i].specific_setup(l_fb_info);
  1312. l_fb_info->board_type = i;
  1313. }
  1314. i++;
  1315. }
  1316. if (!l_fb_info->board_type) {
  1317. DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n",
  1318. l_fb_info->board_num, subvendor, subdevice);
  1319. }
  1320. } else {
  1321. printk(KERN_ERR "pm3fb: Error: pci_read_config_word failed, board #%ld\n",
  1322. l_fb_info->board_num);
  1323. }
  1324. if (printtimings)
  1325. pm3fb_show_cur_timing(l_fb_info);
  1326. /* card-specific setup is done, we preserve the final
  1327. memory timing for future reference */
  1328. if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */
  1329. return(0);
  1330. }
  1331. tempBypass = PM3_READ_REG(PM3MemBypassWriteMask);
  1332. DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
  1333. PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xFFFFFFFF);
  1334. /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
  1335. for (i = 0; i < 32; i++) {
  1336. fb_writel(i * 0x00345678,
  1337. (l_fb_info->v_fb + (i * 1048576)));
  1338. mb();
  1339. temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576)));
  1340. /* Let's check for wrapover, write will fail at 16MB boundary */
  1341. if (temp1 == (i * 0x00345678))
  1342. memsize = i;
  1343. else
  1344. break;
  1345. }
  1346. DPRINTK(2, "First detect pass already got %ld MB\n", memsize + 1);
  1347. if (memsize == i) {
  1348. for (i = 0; i < 32; i++) {
  1349. /* Clear first 32MB ; 0 is 0, no need to byteswap */
  1350. writel(0x0000000,
  1351. (l_fb_info->v_fb + (i * 1048576)));
  1352. mb();
  1353. }
  1354. for (i = 32; i < 64; i++) {
  1355. fb_writel(i * 0x00345678,
  1356. (l_fb_info->v_fb + (i * 1048576)));
  1357. mb();
  1358. temp1 =
  1359. fb_readl((l_fb_info->v_fb + (i * 1048576)));
  1360. temp2 =
  1361. fb_readl((l_fb_info->v_fb +
  1362. ((i - 32) * 1048576)));
  1363. if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */
  1364. memsize = i;
  1365. else
  1366. break;
  1367. }
  1368. }
  1369. DPRINTK(2, "Second detect pass got %ld MB\n", memsize + 1);
  1370. PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, tempBypass);
  1371. pm3fb_unmapIO(l_fb_info);
  1372. memsize = 1048576 * (memsize + 1);
  1373. DPRINTK(2, "Returning 0x%08lx bytes\n", memsize);
  1374. if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize))
  1375. {
  1376. printk(KERN_WARNING "pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize, forcesize[l_fb_info->board_num]);
  1377. memsize = 1048576 * forcesize[l_fb_info->board_num];
  1378. }
  1379. l_fb_info->fb_size = memsize;
  1380. if (ptr == pm3fb_timing_retry)
  1381. {
  1382. printk(KERN_WARNING "pm3fb: retrying memory timings check");
  1383. if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem)
  1384. return(0);
  1385. }
  1386. return (memsize);
  1387. }
  1388. static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc)
  1389. {
  1390. int i;
  1391. DTRACE;
  1392. for (i = 0; i < (l_fb_info->fb_size / sizeof(u32)) ; i++) /* clear entire FB memory to black */
  1393. {
  1394. fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
  1395. }
  1396. }
  1397. static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b)
  1398. {
  1399. int i;
  1400. DTRACE;
  1401. for (i = 0; i < 256 ; i++) /* fill color map with white */
  1402. pm3fb_set_color(l_fb_info, i, r, g, b);
  1403. }
  1404. /* common initialisation */
  1405. static void pm3fb_common_init(struct pm3fb_info *l_fb_info)
  1406. {
  1407. DTRACE;
  1408. DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info->board_num,
  1409. (unsigned long) l_fb_info);
  1410. strcpy(l_fb_info->gen.info.modename, permedia3_name);
  1411. disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
  1412. l_fb_info->gen.parsize = sizeof(struct pm3fb_par);
  1413. l_fb_info->gen.info.changevar = NULL;
  1414. l_fb_info->gen.info.fbops = &pm3fb_ops;
  1415. l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]);
  1416. if (fontn[l_fb_info->board_num][0])
  1417. strcpy(l_fb_info->gen.info.fontname,
  1418. fontn[l_fb_info->board_num]);
  1419. l_fb_info->gen.info.switch_con = &fbgen_switch;
  1420. l_fb_info->gen.info.updatevar = &fbgen_update_var; /* */
  1421. l_fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT;
  1422. pm3fb_mapIO(l_fb_info);
  1423. pm3fb_clear_memory(l_fb_info, 0);
  1424. pm3fb_clear_colormap(l_fb_info, 0, 0, 0);
  1425. (void) fbgen_get_var(&(disp[l_fb_info->board_num]).var, -1,
  1426. &l_fb_info->gen.info);
  1427. if (depth[l_fb_info->board_num]) /* override mode-defined depth */
  1428. {
  1429. pm3fb_encode_depth(&(disp[l_fb_info->board_num]).var, depth[l_fb_info->board_num]);
  1430. (disp[l_fb_info->board_num]).var.bits_per_pixel = depth2bpp(depth[l_fb_info->board_num]);
  1431. }
  1432. (void) fbgen_do_set_var(&(disp[l_fb_info->board_num]).var, 1,
  1433. &l_fb_info->gen);
  1434. fbgen_set_disp(-1, &l_fb_info->gen);
  1435. do_install_cmap(0, &l_fb_info->gen.info);
  1436. if (register_framebuffer(&l_fb_info->gen.info) < 0) {
  1437. DPRINTK(1, "Couldn't register framebuffer\n");
  1438. return;
  1439. }
  1440. PM3_WRITE_DAC_REG(PM3RD_CursorMode,
  1441. PM3RD_CursorMode_CURSOR_DISABLE);
  1442. PM3_SHOW_CUR_MODE;
  1443. pm3fb_write_mode(l_fb_info);
  1444. printk("fb%d: %s, using %uK of video memory (%s)\n",
  1445. l_fb_info->gen.info.node,
  1446. permedia3_name, (u32) (l_fb_info->fb_size >> 10),
  1447. cardbase[l_fb_info->board_type].cardname);
  1448. }
  1449. /* **************************************************** */
  1450. /* ***** accelerated permedia3-specific functions ***** */
  1451. /* **************************************************** */
  1452. #ifdef PM3FB_USE_ACCEL
  1453. static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info)
  1454. {
  1455. DTRACE;
  1456. PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
  1457. PM3_SLOW_WRITE_REG(PM3Sync, 0);
  1458. mb();
  1459. do {
  1460. while ((PM3_READ_REG(PM3OutFIFOWords)) == 0);
  1461. rmb();
  1462. } while ((PM3_READ_REG(PM3OutputFifo)) != PM3Sync_Tag);
  1463. }
  1464. static void pm3fb_init_engine(struct pm3fb_info *l_fb_info)
  1465. {
  1466. PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
  1467. PM3_SLOW_WRITE_REG(PM3StatisticMode, 0x0);
  1468. PM3_SLOW_WRITE_REG(PM3DeltaMode, 0x0);
  1469. PM3_SLOW_WRITE_REG(PM3RasterizerMode, 0x0);
  1470. PM3_SLOW_WRITE_REG(PM3ScissorMode, 0x0);
  1471. PM3_SLOW_WRITE_REG(PM3LineStippleMode, 0x0);
  1472. PM3_SLOW_WRITE_REG(PM3AreaStippleMode, 0x0);
  1473. PM3_SLOW_WRITE_REG(PM3GIDMode, 0x0);
  1474. PM3_SLOW_WRITE_REG(PM3DepthMode, 0x0);
  1475. PM3_SLOW_WRITE_REG(PM3StencilMode, 0x0);
  1476. PM3_SLOW_WRITE_REG(PM3StencilData, 0x0);
  1477. PM3_SLOW_WRITE_REG(PM3ColorDDAMode, 0x0);
  1478. PM3_SLOW_WRITE_REG(PM3TextureCoordMode, 0x0);
  1479. PM3_SLOW_WRITE_REG(PM3TextureIndexMode0, 0x0);
  1480. PM3_SLOW_WRITE_REG(PM3TextureIndexMode1, 0x0);
  1481. PM3_SLOW_WRITE_REG(PM3TextureReadMode, 0x0);
  1482. PM3_SLOW_WRITE_REG(PM3LUTMode, 0x0);
  1483. PM3_SLOW_WRITE_REG(PM3TextureFilterMode, 0x0);
  1484. PM3_SLOW_WRITE_REG(PM3TextureCompositeMode, 0x0);
  1485. PM3_SLOW_WRITE_REG(PM3TextureApplicationMode, 0x0);
  1486. PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1, 0x0);
  1487. PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1, 0x0);
  1488. PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0, 0x0);
  1489. PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0, 0x0);
  1490. PM3_SLOW_WRITE_REG(PM3FogMode, 0x0);
  1491. PM3_SLOW_WRITE_REG(PM3ChromaTestMode, 0x0);
  1492. PM3_SLOW_WRITE_REG(PM3AlphaTestMode, 0x0);
  1493. PM3_SLOW_WRITE_REG(PM3AntialiasMode, 0x0);
  1494. PM3_SLOW_WRITE_REG(PM3YUVMode, 0x0);
  1495. PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode, 0x0);
  1496. PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode, 0x0);
  1497. PM3_SLOW_WRITE_REG(PM3DitherMode, 0x0);
  1498. PM3_SLOW_WRITE_REG(PM3LogicalOpMode, 0x0);
  1499. PM3_SLOW_WRITE_REG(PM3RouterMode, 0x0);
  1500. PM3_SLOW_WRITE_REG(PM3Window, 0x0);
  1501. PM3_SLOW_WRITE_REG(PM3Config2D, 0x0);
  1502. PM3_SLOW_WRITE_REG(PM3SpanColorMask, 0xffffffff);
  1503. PM3_SLOW_WRITE_REG(PM3XBias, 0x0);
  1504. PM3_SLOW_WRITE_REG(PM3YBias, 0x0);
  1505. PM3_SLOW_WRITE_REG(PM3DeltaControl, 0x0);
  1506. PM3_SLOW_WRITE_REG(PM3BitMaskPattern, 0xffffffff);
  1507. PM3_SLOW_WRITE_REG(PM3FBDestReadEnables,
  1508. PM3FBDestReadEnables_E(0xff) |
  1509. PM3FBDestReadEnables_R(0xff) |
  1510. PM3FBDestReadEnables_ReferenceAlpha(0xff));
  1511. PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0, 0x0);
  1512. PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0, 0x0);
  1513. PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0,
  1514. PM3FBDestReadBufferWidth_Width(l_fb_info->
  1515. current_par->
  1516. width));
  1517. PM3_SLOW_WRITE_REG(PM3FBDestReadMode,
  1518. PM3FBDestReadMode_ReadEnable |
  1519. PM3FBDestReadMode_Enable0);
  1520. PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr, 0x0);
  1521. PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset, 0x0);
  1522. PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth,
  1523. PM3FBSourceReadBufferWidth_Width(l_fb_info->
  1524. current_par->
  1525. width));
  1526. PM3_SLOW_WRITE_REG(PM3FBSourceReadMode,
  1527. PM3FBSourceReadMode_Blocking |
  1528. PM3FBSourceReadMode_ReadEnable);
  1529. {
  1530. unsigned long rm = 1;
  1531. switch (l_fb_info->current_par->depth) {
  1532. case 8:
  1533. PM3_SLOW_WRITE_REG(PM3PixelSize,
  1534. PM3PixelSize_GLOBAL_8BIT);
  1535. break;
  1536. case 12:
  1537. case 15:
  1538. case 16:
  1539. PM3_SLOW_WRITE_REG(PM3PixelSize,
  1540. PM3PixelSize_GLOBAL_16BIT);
  1541. break;
  1542. case 32:
  1543. PM3_SLOW_WRITE_REG(PM3PixelSize,
  1544. PM3PixelSize_GLOBAL_32BIT);
  1545. break;
  1546. default:
  1547. DPRINTK(1, "Unsupported depth %d\n",
  1548. l_fb_info->current_par->depth);
  1549. break;
  1550. }
  1551. PM3_SLOW_WRITE_REG(PM3RasterizerMode, rm);
  1552. }
  1553. PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff);
  1554. PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff);
  1555. PM3_SLOW_WRITE_REG(PM3FBWriteMode,
  1556. PM3FBWriteMode_WriteEnable |
  1557. PM3FBWriteMode_OpaqueSpan |
  1558. PM3FBWriteMode_Enable0);
  1559. PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0, 0x0);
  1560. PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0, 0x0);
  1561. PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0,
  1562. PM3FBWriteBufferWidth_Width(l_fb_info->
  1563. current_par->
  1564. width));
  1565. PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 0x0);
  1566. {
  1567. unsigned long sofb = (8UL * l_fb_info->fb_size) /
  1568. ((depth2bpp(l_fb_info->current_par->depth))
  1569. * l_fb_info->current_par->width); /* size in lines of FB */
  1570. if (sofb > 4095)
  1571. PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095);
  1572. else
  1573. PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb);
  1574. switch (l_fb_info->current_par->depth) {
  1575. case 8:
  1576. PM3_SLOW_WRITE_REG(PM3DitherMode,
  1577. (1 << 10) | (2 << 3));
  1578. break;
  1579. case 12:
  1580. case 15:
  1581. case 16:
  1582. PM3_SLOW_WRITE_REG(PM3DitherMode,
  1583. (1 << 10) | (1 << 3));
  1584. break;
  1585. case 32:
  1586. PM3_SLOW_WRITE_REG(PM3DitherMode,
  1587. (1 << 10) | (0 << 3));
  1588. break;
  1589. default:
  1590. DPRINTK(1, "Unsupported depth %d\n",
  1591. l_fb_info->current_par->depth);
  1592. break;
  1593. }
  1594. }
  1595. PM3_SLOW_WRITE_REG(PM3dXDom, 0x0);
  1596. PM3_SLOW_WRITE_REG(PM3dXSub, 0x0);
  1597. PM3_SLOW_WRITE_REG(PM3dY, (1 << 16));
  1598. PM3_SLOW_WRITE_REG(PM3StartXDom, 0x0);
  1599. PM3_SLOW_WRITE_REG(PM3StartXSub, 0x0);
  1600. PM3_SLOW_WRITE_REG(PM3StartY, 0x0);
  1601. PM3_SLOW_WRITE_REG(PM3Count, 0x0);
  1602. /* Disable LocalBuffer. better safe than sorry */
  1603. PM3_SLOW_WRITE_REG(PM3LBDestReadMode, 0x0);
  1604. PM3_SLOW_WRITE_REG(PM3LBDestReadEnables, 0x0);
  1605. PM3_SLOW_WRITE_REG(PM3LBSourceReadMode, 0x0);
  1606. PM3_SLOW_WRITE_REG(PM3LBWriteMode, 0x0);
  1607. pm3fb_wait_pm3(l_fb_info);
  1608. }
  1609. #ifdef FBCON_HAS_CFB32
  1610. static void pm3fb_cfb32_clear(struct vc_data *conp,
  1611. struct display *p,
  1612. int sy, int sx, int height, int width)
  1613. {
  1614. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1615. u32 c;
  1616. DTRACE;
  1617. sx = sx * fontwidth(p);
  1618. width = width * fontwidth(p);
  1619. sy = sy * fontheight(p);
  1620. height = height * fontheight(p);
  1621. c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
  1622. /* block fills in 32bpp are hard, but in low res (width <= 1600 :-)
  1623. we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */
  1624. if ((l_fb_info->current_par->width > 1600) ||
  1625. (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) {
  1626. PM3_WAIT(4);
  1627. PM3_WRITE_REG(PM3Config2D,
  1628. PM3Config2D_UseConstantSource |
  1629. PM3Config2D_ForegroundROPEnable |
  1630. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1631. PM3Config2D_FBWriteEnable);
  1632. PM3_WRITE_REG(PM3ForegroundColor, c);
  1633. PM3_WRITE_REG(PM3RectanglePosition,
  1634. (PM3RectanglePosition_XOffset(sx)) |
  1635. (PM3RectanglePosition_YOffset(sy)));
  1636. PM3_WRITE_REG(PM3Render2D,
  1637. PM3Render2D_XPositive |
  1638. PM3Render2D_YPositive |
  1639. PM3Render2D_Operation_Normal |
  1640. PM3Render2D_SpanOperation |
  1641. (PM3Render2D_Width(width)) |
  1642. (PM3Render2D_Height(height)));
  1643. } else {
  1644. PM3_WAIT(8);
  1645. PM3_WRITE_REG(PM3FBBlockColor, c);
  1646. PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_16BIT);
  1647. PM3_WRITE_REG(PM3FBWriteBufferWidth0,
  1648. PM3FBWriteBufferWidth_Width(l_fb_info->
  1649. current_par->
  1650. width << 1));
  1651. PM3_WRITE_REG(PM3Config2D,
  1652. PM3Config2D_UseConstantSource |
  1653. PM3Config2D_ForegroundROPEnable |
  1654. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1655. PM3Config2D_FBWriteEnable);
  1656. PM3_WRITE_REG(PM3RectanglePosition,
  1657. (PM3RectanglePosition_XOffset(sx << 1)) |
  1658. (PM3RectanglePosition_YOffset(sy)));
  1659. PM3_WRITE_REG(PM3Render2D,
  1660. PM3Render2D_XPositive |
  1661. PM3Render2D_YPositive |
  1662. PM3Render2D_Operation_Normal |
  1663. (PM3Render2D_Width(width << 1)) |
  1664. (PM3Render2D_Height(height)));
  1665. PM3_WRITE_REG(PM3FBWriteBufferWidth0,
  1666. PM3FBWriteBufferWidth_Width(l_fb_info->
  1667. current_par->
  1668. width));
  1669. PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_32BIT);
  1670. }
  1671. pm3fb_wait_pm3(l_fb_info);
  1672. }
  1673. static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
  1674. struct display *p, int bottom_only)
  1675. {
  1676. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1677. int sx, sy;
  1678. u32 c;
  1679. DTRACE;
  1680. sx = conp->vc_cols * fontwidth(p); /* right margin */
  1681. sy = conp->vc_rows * fontheight(p); /* bottom margin */
  1682. c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
  1683. if (!bottom_only) { /* right margin top->bottom */
  1684. PM3_WAIT(4);
  1685. PM3_WRITE_REG(PM3Config2D,
  1686. PM3Config2D_UseConstantSource |
  1687. PM3Config2D_ForegroundROPEnable |
  1688. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1689. PM3Config2D_FBWriteEnable);
  1690. PM3_WRITE_REG(PM3ForegroundColor, c);
  1691. PM3_WRITE_REG(PM3RectanglePosition,
  1692. (PM3RectanglePosition_XOffset
  1693. (p->var.xoffset +
  1694. sx)) | (PM3RectanglePosition_YOffset(p->
  1695. var.
  1696. yoffset)));
  1697. PM3_WRITE_REG(PM3Render2D,
  1698. PM3Render2D_XPositive |
  1699. PM3Render2D_YPositive |
  1700. PM3Render2D_Operation_Normal |
  1701. PM3Render2D_SpanOperation |
  1702. (PM3Render2D_Width(p->var.xres - sx)) |
  1703. (PM3Render2D_Height(p->var.yres)));
  1704. }
  1705. /* bottom margin left -> right */
  1706. PM3_WAIT(4);
  1707. PM3_WRITE_REG(PM3Config2D,
  1708. PM3Config2D_UseConstantSource |
  1709. PM3Config2D_ForegroundROPEnable |
  1710. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1711. PM3Config2D_FBWriteEnable);
  1712. PM3_WRITE_REG(PM3ForegroundColor, c);
  1713. PM3_WRITE_REG(PM3RectanglePosition,
  1714. (PM3RectanglePosition_XOffset(p->var.xoffset)) |
  1715. (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
  1716. PM3_WRITE_REG(PM3Render2D,
  1717. PM3Render2D_XPositive |
  1718. PM3Render2D_YPositive |
  1719. PM3Render2D_Operation_Normal |
  1720. PM3Render2D_SpanOperation |
  1721. (PM3Render2D_Width(p->var.xres)) |
  1722. (PM3Render2D_Height(p->var.yres - sy)));
  1723. pm3fb_wait_pm3(l_fb_info);
  1724. }
  1725. #endif /* FBCON_HAS_CFB32 */
  1726. #ifdef FBCON_HAS_CFB16
  1727. static void pm3fb_cfb16_clear(struct vc_data *conp,
  1728. struct display *p,
  1729. int sy, int sx, int height, int width)
  1730. {
  1731. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1732. u32 c;
  1733. DTRACE;
  1734. sx = sx * fontwidth(p);
  1735. width = width * fontwidth(p);
  1736. sy = sy * fontheight(p);
  1737. height = height * fontheight(p);
  1738. c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
  1739. c = c | (c << 16);
  1740. PM3_WAIT(4);
  1741. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1742. PM3_WRITE_REG(PM3ForegroundColor, c);
  1743. else
  1744. PM3_WRITE_REG(PM3FBBlockColor, c);
  1745. PM3_WRITE_REG(PM3Config2D,
  1746. PM3Config2D_UseConstantSource |
  1747. PM3Config2D_ForegroundROPEnable |
  1748. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1749. PM3Config2D_FBWriteEnable);
  1750. PM3_WRITE_REG(PM3RectanglePosition,
  1751. (PM3RectanglePosition_XOffset(sx)) |
  1752. (PM3RectanglePosition_YOffset(sy)));
  1753. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1754. PM3_WRITE_REG(PM3Render2D,
  1755. PM3Render2D_XPositive |
  1756. PM3Render2D_YPositive |
  1757. PM3Render2D_Operation_Normal |
  1758. PM3Render2D_SpanOperation |
  1759. (PM3Render2D_Width(width)) |
  1760. (PM3Render2D_Height(height)));
  1761. else
  1762. PM3_WRITE_REG(PM3Render2D,
  1763. PM3Render2D_XPositive |
  1764. PM3Render2D_YPositive |
  1765. PM3Render2D_Operation_Normal |
  1766. (PM3Render2D_Width(width)) |
  1767. (PM3Render2D_Height(height)));
  1768. pm3fb_wait_pm3(l_fb_info);
  1769. }
  1770. static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
  1771. struct display *p, int bottom_only)
  1772. {
  1773. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1774. int sx, sy;
  1775. u32 c;
  1776. DTRACE;
  1777. sx = conp->vc_cols * fontwidth(p); /* right margin */
  1778. sy = conp->vc_rows * fontheight(p); /* bottom margin */
  1779. c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
  1780. c = c | (c << 16);
  1781. if (!bottom_only) { /* right margin top->bottom */
  1782. PM3_WAIT(4);
  1783. PM3_WRITE_REG(PM3Config2D,
  1784. PM3Config2D_UseConstantSource |
  1785. PM3Config2D_ForegroundROPEnable |
  1786. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1787. PM3Config2D_FBWriteEnable);
  1788. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1789. PM3_WRITE_REG(PM3ForegroundColor, c);
  1790. else
  1791. PM3_WRITE_REG(PM3FBBlockColor, c);
  1792. PM3_WRITE_REG(PM3RectanglePosition,
  1793. (PM3RectanglePosition_XOffset
  1794. (p->var.xoffset +
  1795. sx)) | (PM3RectanglePosition_YOffset(p->
  1796. var.
  1797. yoffset)));
  1798. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1799. PM3_WRITE_REG(PM3Render2D,
  1800. PM3Render2D_XPositive |
  1801. PM3Render2D_YPositive |
  1802. PM3Render2D_Operation_Normal |
  1803. PM3Render2D_SpanOperation |
  1804. (PM3Render2D_Width(p->var.xres - sx)) |
  1805. (PM3Render2D_Height(p->var.yres)));
  1806. else
  1807. PM3_WRITE_REG(PM3Render2D,
  1808. PM3Render2D_XPositive |
  1809. PM3Render2D_YPositive |
  1810. PM3Render2D_Operation_Normal |
  1811. (PM3Render2D_Width(p->var.xres - sx)) |
  1812. (PM3Render2D_Height(p->var.yres)));
  1813. }
  1814. /* bottom margin left -> right */
  1815. PM3_WAIT(4);
  1816. PM3_WRITE_REG(PM3Config2D,
  1817. PM3Config2D_UseConstantSource |
  1818. PM3Config2D_ForegroundROPEnable |
  1819. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1820. PM3Config2D_FBWriteEnable);
  1821. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1822. PM3_WRITE_REG(PM3ForegroundColor, c);
  1823. else
  1824. PM3_WRITE_REG(PM3FBBlockColor, c);
  1825. PM3_WRITE_REG(PM3RectanglePosition,
  1826. (PM3RectanglePosition_XOffset(p->var.xoffset)) |
  1827. (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
  1828. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  1829. PM3_WRITE_REG(PM3Render2D,
  1830. PM3Render2D_XPositive |
  1831. PM3Render2D_YPositive |
  1832. PM3Render2D_Operation_Normal |
  1833. PM3Render2D_SpanOperation |
  1834. (PM3Render2D_Width(p->var.xres)) |
  1835. (PM3Render2D_Height(p->var.yres - sy)));
  1836. else
  1837. PM3_WRITE_REG(PM3Render2D,
  1838. PM3Render2D_XPositive |
  1839. PM3Render2D_YPositive |
  1840. PM3Render2D_Operation_Normal |
  1841. (PM3Render2D_Width(p->var.xres)) |
  1842. (PM3Render2D_Height(p->var.yres - sy)));
  1843. pm3fb_wait_pm3(l_fb_info);
  1844. }
  1845. #endif /* FBCON_HAS_CFB16 */
  1846. #ifdef FBCON_HAS_CFB8
  1847. static void pm3fb_cfb8_clear(struct vc_data *conp,
  1848. struct display *p,
  1849. int sy, int sx, int height, int width)
  1850. {
  1851. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1852. u32 c;
  1853. DTRACE;
  1854. sx = sx * fontwidth(p);
  1855. width = width * fontwidth(p);
  1856. sy = sy * fontheight(p);
  1857. height = height * fontheight(p);
  1858. c = attr_bgcol_ec(p, conp);
  1859. c |= c << 8;
  1860. c |= c << 16;
  1861. PM3_WAIT(4);
  1862. PM3_WRITE_REG(PM3Config2D,
  1863. PM3Config2D_UseConstantSource |
  1864. PM3Config2D_ForegroundROPEnable |
  1865. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1866. PM3Config2D_FBWriteEnable);
  1867. PM3_WRITE_REG(PM3ForegroundColor, c);
  1868. PM3_WRITE_REG(PM3RectanglePosition,
  1869. (PM3RectanglePosition_XOffset(sx)) |
  1870. (PM3RectanglePosition_YOffset(sy)));
  1871. PM3_WRITE_REG(PM3Render2D,
  1872. PM3Render2D_XPositive |
  1873. PM3Render2D_YPositive |
  1874. PM3Render2D_Operation_Normal |
  1875. PM3Render2D_SpanOperation |
  1876. (PM3Render2D_Width(width)) |
  1877. (PM3Render2D_Height(height)));
  1878. pm3fb_wait_pm3(l_fb_info);
  1879. }
  1880. static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
  1881. struct display *p, int bottom_only)
  1882. {
  1883. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1884. int sx, sy;
  1885. u32 c;
  1886. DTRACE;
  1887. sx = conp->vc_cols * fontwidth(p); /* right margin */
  1888. sy = conp->vc_rows * fontheight(p); /* bottom margin */
  1889. c = attr_bgcol_ec(p, conp);
  1890. c |= c << 8;
  1891. c |= c << 16;
  1892. if (!bottom_only) { /* right margin top->bottom */
  1893. PM3_WAIT(4);
  1894. PM3_WRITE_REG(PM3Config2D,
  1895. PM3Config2D_UseConstantSource |
  1896. PM3Config2D_ForegroundROPEnable |
  1897. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1898. PM3Config2D_FBWriteEnable);
  1899. PM3_WRITE_REG(PM3ForegroundColor, c);
  1900. PM3_WRITE_REG(PM3RectanglePosition,
  1901. (PM3RectanglePosition_XOffset
  1902. (p->var.xoffset +
  1903. sx)) | (PM3RectanglePosition_YOffset(p->
  1904. var.
  1905. yoffset)));
  1906. PM3_WRITE_REG(PM3Render2D,
  1907. PM3Render2D_XPositive |
  1908. PM3Render2D_YPositive |
  1909. PM3Render2D_Operation_Normal |
  1910. PM3Render2D_SpanOperation |
  1911. (PM3Render2D_Width(p->var.xres - sx)) |
  1912. (PM3Render2D_Height(p->var.yres)));
  1913. }
  1914. /* bottom margin left -> right */
  1915. PM3_WAIT(4);
  1916. PM3_WRITE_REG(PM3Config2D,
  1917. PM3Config2D_UseConstantSource |
  1918. PM3Config2D_ForegroundROPEnable |
  1919. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1920. PM3Config2D_FBWriteEnable);
  1921. PM3_WRITE_REG(PM3ForegroundColor, c);
  1922. PM3_WRITE_REG(PM3RectanglePosition,
  1923. (PM3RectanglePosition_XOffset(p->var.xoffset)) |
  1924. (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
  1925. PM3_WRITE_REG(PM3Render2D,
  1926. PM3Render2D_XPositive |
  1927. PM3Render2D_YPositive |
  1928. PM3Render2D_Operation_Normal |
  1929. PM3Render2D_SpanOperation |
  1930. (PM3Render2D_Width(p->var.xres)) |
  1931. (PM3Render2D_Height(p->var.yres - sy)));
  1932. pm3fb_wait_pm3(l_fb_info);
  1933. }
  1934. #endif /* FBCON_HAS_CFB8 */
  1935. #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
  1936. static void pm3fb_cfbX_bmove(struct display *p,
  1937. int sy, int sx,
  1938. int dy, int dx, int height, int width)
  1939. {
  1940. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1941. int x_align, o_x, o_y;
  1942. DTRACE;
  1943. sx = sx * fontwidth(p);
  1944. dx = dx * fontwidth(p);
  1945. width = width * fontwidth(p);
  1946. sy = sy * fontheight(p);
  1947. dy = dy * fontheight(p);
  1948. height = height * fontheight(p);
  1949. o_x = sx - dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */
  1950. o_y = sy - dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */
  1951. x_align = (sx & 0x1f);
  1952. PM3_WAIT(6);
  1953. PM3_WRITE_REG(PM3Config2D,
  1954. PM3Config2D_UserScissorEnable |
  1955. PM3Config2D_ForegroundROPEnable |
  1956. PM3Config2D_Blocking |
  1957. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  1958. PM3Config2D_FBWriteEnable);
  1959. PM3_WRITE_REG(PM3ScissorMinXY,
  1960. ((dy & 0x0fff) << 16) | (dx & 0x0fff));
  1961. PM3_WRITE_REG(PM3ScissorMaxXY,
  1962. (((dy + height) & 0x0fff) << 16) |
  1963. ((dx + width) & 0x0fff));
  1964. PM3_WRITE_REG(PM3FBSourceReadBufferOffset,
  1965. PM3FBSourceReadBufferOffset_XOffset(o_x) |
  1966. PM3FBSourceReadBufferOffset_YOffset(o_y));
  1967. PM3_WRITE_REG(PM3RectanglePosition,
  1968. (PM3RectanglePosition_XOffset(dx - x_align)) |
  1969. (PM3RectanglePosition_YOffset(dy)));
  1970. PM3_WRITE_REG(PM3Render2D,
  1971. ((sx > dx) ? PM3Render2D_XPositive : 0) |
  1972. ((sy > dy) ? PM3Render2D_YPositive : 0) |
  1973. PM3Render2D_Operation_Normal |
  1974. PM3Render2D_SpanOperation |
  1975. PM3Render2D_FBSourceReadEnable |
  1976. (PM3Render2D_Width(width + x_align)) |
  1977. (PM3Render2D_Height(height)));
  1978. pm3fb_wait_pm3(l_fb_info);
  1979. }
  1980. static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
  1981. int c, int yy, int xx)
  1982. {
  1983. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  1984. u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
  1985. u32 fgx, bgx, ldat;
  1986. int sx, sy, i;
  1987. DTRACE;
  1988. if (l_fb_info->current_par->depth == 8)
  1989. fgx = attr_fgcol(p, c);
  1990. else if (depth2bpp(l_fb_info->current_par->depth) == 16)
  1991. fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)];
  1992. else
  1993. fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)];
  1994. PM3_COLOR(fgx);
  1995. if (l_fb_info->current_par->depth == 8)
  1996. bgx = attr_bgcol(p, c);
  1997. else if (depth2bpp(l_fb_info->current_par->depth) == 16)
  1998. bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)];
  1999. else
  2000. bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)];
  2001. PM3_COLOR(bgx);
  2002. PM3_WAIT(4);
  2003. PM3_WRITE_REG(PM3Config2D,
  2004. PM3Config2D_UseConstantSource |
  2005. PM3Config2D_ForegroundROPEnable |
  2006. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  2007. PM3Config2D_FBWriteEnable | PM3Config2D_OpaqueSpan);
  2008. PM3_WRITE_REG(PM3ForegroundColor, fgx);
  2009. PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
  2010. /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
  2011. /* and 16 bits for fontwidth <= 16 */
  2012. /* same in _putcs, same for Y and fontheight */
  2013. if (fontwidth(p) <= 8)
  2014. asx = 2;
  2015. else if (fontwidth(p) <= 16)
  2016. asx = 3; /* look OK */
  2017. if (fontheight(p) <= 8)
  2018. asy = 2;
  2019. else if (fontheight(p) <= 16)
  2020. asy = 3; /* look OK */
  2021. else if (fontheight(p) <= 32)
  2022. asy = 4; /* look OK */
  2023. sx = xx * fontwidth(p);
  2024. sy = yy * fontheight(p);
  2025. if (fontwidth(p) <= 8)
  2026. o_x = (8 - (sx & 0x7)) & 0x7;
  2027. else if (fontwidth(p) <= 16)
  2028. o_x = (16 - (sx & 0xF)) & 0xF;
  2029. if (fontheight(p) <= 8)
  2030. o_y = (8 - (sy & 0x7)) & 0x7;
  2031. else if (fontheight(p) <= 16)
  2032. o_y = (16 - (sy & 0xF)) & 0xF;
  2033. else if (fontheight(p) <= 32)
  2034. o_y = (32 - (sy & 0x1F)) & 0x1F;
  2035. PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
  2036. (1 << 18) | /* BE */
  2037. 1 | (asx << 1) | (asy << 4) | /* address select x/y */
  2038. (1 << 20)); /* OpaqueSpan */
  2039. if (fontwidth(p) <= 8) {
  2040. cdat = p->fontdata + (c & p->charmask) * fontheight(p);
  2041. } else {
  2042. cdat =
  2043. p->fontdata +
  2044. ((c & p->charmask) * (fontheight(p) << 1));
  2045. }
  2046. PM3_WAIT(2 + fontheight(p));
  2047. for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
  2048. if (fontwidth(p) <= 8) {
  2049. ldat = *cdat++;
  2050. } else { /* assume fontwidth <= 16 ATM */
  2051. ldat = ((*cdat++) << 8);
  2052. ldat |= *cdat++;
  2053. }
  2054. PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
  2055. }
  2056. PM3_WRITE_REG(PM3RectanglePosition,
  2057. (PM3RectanglePosition_XOffset(sx)) |
  2058. (PM3RectanglePosition_YOffset(sy)));
  2059. PM3_WRITE_REG(PM3Render2D,
  2060. PM3Render2D_AreaStippleEnable |
  2061. PM3Render2D_XPositive |
  2062. PM3Render2D_YPositive |
  2063. PM3Render2D_Operation_Normal |
  2064. PM3Render2D_SpanOperation |
  2065. (PM3Render2D_Width(fontwidth(p))) |
  2066. (PM3Render2D_Height(fontheight(p))));
  2067. pm3fb_wait_pm3(l_fb_info);
  2068. }
  2069. static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
  2070. const unsigned short *s, int count, int yy,
  2071. int xx)
  2072. {
  2073. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  2074. u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
  2075. u32 fgx, bgx, ldat;
  2076. int sx, sy, i, j;
  2077. u16 sc;
  2078. DTRACE;
  2079. sc = scr_readw(s);
  2080. if (l_fb_info->current_par->depth == 8)
  2081. fgx = attr_fgcol(p, sc);
  2082. else if (depth2bpp(l_fb_info->current_par->depth) == 16)
  2083. fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, sc)];
  2084. else
  2085. fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, sc)];
  2086. PM3_COLOR(fgx);
  2087. if (l_fb_info->current_par->depth == 8)
  2088. bgx = attr_bgcol(p, sc);
  2089. else if (depth2bpp(l_fb_info->current_par->depth) == 16)
  2090. bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, sc)];
  2091. else
  2092. bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, sc)];
  2093. PM3_COLOR(bgx);
  2094. PM3_WAIT(4);
  2095. PM3_WRITE_REG(PM3Config2D,
  2096. PM3Config2D_UseConstantSource |
  2097. PM3Config2D_ForegroundROPEnable |
  2098. (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
  2099. PM3Config2D_FBWriteEnable |
  2100. PM3Config2D_OpaqueSpan);
  2101. PM3_WRITE_REG(PM3ForegroundColor, fgx);
  2102. PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
  2103. /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
  2104. /* and 16 bits for fontwidth <= 16 */
  2105. /* same in _putc, same for Y and fontheight */
  2106. if (fontwidth(p) <= 8)
  2107. asx = 2;
  2108. else if (fontwidth(p) <= 16)
  2109. asx = 3; /* look OK */
  2110. if (fontheight(p) <= 8)
  2111. asy = 2;
  2112. else if (fontheight(p) <= 16)
  2113. asy = 3; /* look OK */
  2114. else if (fontheight(p) <= 32)
  2115. asy = 4; /* look OK */
  2116. sy = yy * fontheight(p);
  2117. if (fontheight(p) <= 8)
  2118. o_y = (8 - (sy & 0x7)) & 0x7;
  2119. else if (fontheight(p) <= 16)
  2120. o_y = (16 - (sy & 0xF)) & 0xF;
  2121. else if (fontheight(p) <= 32)
  2122. o_y = (32 - (sy & 0x1F)) & 0x1F;
  2123. for (j = 0; j < count; j++) {
  2124. sc = scr_readw(s + j);
  2125. if (fontwidth(p) <= 8)
  2126. cdat = p->fontdata +
  2127. (sc & p->charmask) * fontheight(p);
  2128. else
  2129. cdat = p->fontdata +
  2130. ((sc & p->charmask) * fontheight(p) << 1);
  2131. sx = (xx + j) * fontwidth(p);
  2132. if (fontwidth(p) <= 8)
  2133. o_x = (8 - (sx & 0x7)) & 0x7;
  2134. else if (fontwidth(p) <= 16)
  2135. o_x = (16 - (sx & 0xF)) & 0xF;
  2136. PM3_WAIT(3 + fontheight(p));
  2137. PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
  2138. (1 << 18) | /* BE */
  2139. 1 | (asx << 1) | (asy << 4) | /* address select x/y */
  2140. (1 << 20)); /* OpaqueSpan */
  2141. for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
  2142. if (fontwidth(p) <= 8) {
  2143. ldat = *cdat++;
  2144. } else { /* assume fontwidth <= 16 ATM */
  2145. ldat = ((*cdat++) << 8);
  2146. ldat |= *cdat++;
  2147. }
  2148. PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
  2149. }
  2150. PM3_WRITE_REG(PM3RectanglePosition,
  2151. (PM3RectanglePosition_XOffset(sx)) |
  2152. (PM3RectanglePosition_YOffset(sy)));
  2153. PM3_WRITE_REG(PM3Render2D,
  2154. PM3Render2D_AreaStippleEnable |
  2155. PM3Render2D_XPositive |
  2156. PM3Render2D_YPositive |
  2157. PM3Render2D_Operation_Normal |
  2158. PM3Render2D_SpanOperation |
  2159. (PM3Render2D_Width(fontwidth(p))) |
  2160. (PM3Render2D_Height(fontheight(p))));
  2161. }
  2162. pm3fb_wait_pm3(l_fb_info);
  2163. }
  2164. static void pm3fb_cfbX_revc(struct display *p, int xx, int yy)
  2165. {
  2166. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
  2167. xx = xx * fontwidth(p);
  2168. yy = yy * fontheight(p);
  2169. if (l_fb_info->current_par->depth == 8)
  2170. {
  2171. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  2172. PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F);
  2173. else
  2174. PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F);
  2175. }
  2176. PM3_WAIT(3);
  2177. PM3_WRITE_REG(PM3Config2D,
  2178. PM3Config2D_UseConstantSource |
  2179. PM3Config2D_ForegroundROPEnable |
  2180. (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */
  2181. PM3Config2D_FBDestReadEnable |
  2182. PM3Config2D_FBWriteEnable);
  2183. PM3_WRITE_REG(PM3RectanglePosition,
  2184. (PM3RectanglePosition_XOffset(xx)) |
  2185. (PM3RectanglePosition_YOffset(yy)));
  2186. PM3_WRITE_REG(PM3Render2D,
  2187. PM3Render2D_XPositive |
  2188. PM3Render2D_YPositive |
  2189. PM3Render2D_Operation_Normal |
  2190. PM3Render2D_SpanOperation |
  2191. (PM3Render2D_Width(fontwidth(p))) |
  2192. (PM3Render2D_Height(fontheight(p))));
  2193. pm3fb_wait_pm3(l_fb_info);
  2194. if (l_fb_info->current_par->depth == 8)
  2195. {
  2196. if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
  2197. PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF);
  2198. else
  2199. PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF);
  2200. }
  2201. }
  2202. #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
  2203. #endif /* PM3FB_USE_ACCEL */
  2204. /* *********************************** */
  2205. /* ***** pre-init board(s) setup ***** */
  2206. /* *********************************** */
  2207. static void pm3fb_mode_setup(char *mode, unsigned long board_num)
  2208. {
  2209. struct pm3fb_info *l_fb_info = &(fb_info[board_num]);
  2210. struct pm3fb_par *l_fb_par = &(current_par[board_num]);
  2211. unsigned long i = 0;
  2212. current_par_valid[board_num] = 0;
  2213. if (!strncmp(mode, "current", 7)) {
  2214. l_fb_info->use_current = 1; /* default w/ OpenFirmware */
  2215. } else {
  2216. while ((mode_base[i].name[0])
  2217. && (!current_par_valid[board_num])) {
  2218. if (!
  2219. (strncmp
  2220. (mode, mode_base[i].name,
  2221. strlen(mode_base[i].name)))) {
  2222. memcpy(l_fb_par, &(mode_base[i].user_mode),
  2223. sizeof(struct pm3fb_par));
  2224. current_par_valid[board_num] = 1;
  2225. DPRINTK(2, "Mode set to %s\n",
  2226. mode_base[i].name);
  2227. }
  2228. i++;
  2229. }
  2230. DASSERT(current_par_valid[board_num],
  2231. "Valid mode on command line\n");
  2232. }
  2233. }
  2234. static void pm3fb_pciid_setup(char *pciid, unsigned long board_num)
  2235. {
  2236. short l_bus = -1, l_slot = -1, l_func = -1;
  2237. char *next;
  2238. if (pciid) {
  2239. l_bus = simple_strtoul(pciid, &next, 10);
  2240. if (next && (next[0] == ':')) {
  2241. pciid = next + 1;
  2242. l_slot = simple_strtoul(pciid, &next, 10);
  2243. if (next && (next[0] == ':')) {
  2244. pciid = next + 1;
  2245. l_func =
  2246. simple_strtoul(pciid, (char **) NULL,
  2247. 10);
  2248. }
  2249. }
  2250. } else
  2251. return;
  2252. if ((l_bus >= 0) && (l_slot >= 0) && (l_func >= 0)) {
  2253. bus[board_num] = l_bus;
  2254. slot[board_num] = l_slot;
  2255. func[board_num] = l_func;
  2256. DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n",
  2257. board_num, l_bus, l_slot, l_func);
  2258. } else {
  2259. DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n",
  2260. l_bus, l_slot, l_func, board_num);
  2261. }
  2262. }
  2263. static void pm3fb_font_setup(char *lf, unsigned long board_num)
  2264. {
  2265. unsigned long lfs = strlen(lf);
  2266. if (lfs > (PM3_FONTNAME_SIZE - 1)) {
  2267. DPRINTK(1, "Fontname %s too long\n", lf);
  2268. return;
  2269. }
  2270. strlcpy(fontn[board_num], lf, lfs + 1);
  2271. }
  2272. static void pm3fb_bootdepth_setup(char *bds, unsigned long board_num)
  2273. {
  2274. unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
  2275. if (!(depth_supported(bd))) {
  2276. printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n",
  2277. bds, board_num);
  2278. return;
  2279. }
  2280. depth[board_num] = bd;
  2281. }
  2282. static void pm3fb_forcesize_setup(char *bds, unsigned long board_num)
  2283. {
  2284. unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
  2285. if (bd > 64) {
  2286. printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n",
  2287. bds, board_num);
  2288. return;
  2289. }
  2290. forcesize[board_num] = bd;
  2291. }
  2292. static char *pm3fb_boardnum_setup(char *options, unsigned long *bn)
  2293. {
  2294. char *next;
  2295. if (!(isdigit(options[0]))) {
  2296. (*bn) = 0;
  2297. return (options);
  2298. }
  2299. (*bn) = simple_strtoul(options, &next, 10);
  2300. if (next && (next[0] == ':') && ((*bn) >= 0)
  2301. && ((*bn) <= PM3_MAX_BOARD)) {
  2302. DPRINTK(2, "Board_num seen as %ld\n", (*bn));
  2303. return (next + 1);
  2304. } else {
  2305. (*bn) = 0;
  2306. DPRINTK(2, "Board_num default to %ld\n", (*bn));
  2307. return (options);
  2308. }
  2309. }
  2310. static void pm3fb_real_setup(char *options)
  2311. {
  2312. char *next;
  2313. unsigned long i, bn;
  2314. struct pm3fb_info *l_fb_info;
  2315. DTRACE;
  2316. DPRINTK(2, "Options : %s\n", options);
  2317. for (i = 0; i < PM3_MAX_BOARD; i++) {
  2318. l_fb_info = &(fb_info[i]);
  2319. memset(l_fb_info, 0, sizeof(struct pm3fb_info));
  2320. l_fb_info->gen.fbhw = &pm3fb_switch;
  2321. l_fb_info->board_num = i;
  2322. current_par_valid[i] = 0;
  2323. slot[i] = -1;
  2324. func[i] = -1;
  2325. bus[i] = -1;
  2326. disable[i] = 0;
  2327. noaccel[i] = 0;
  2328. fontn[i][0] = '\0';
  2329. depth[i] = 0;
  2330. l_fb_info->current_par = &(current_par[i]);
  2331. }
  2332. /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */
  2333. if (!strncmp(options, "pm3fb", 5)) {
  2334. options += 5;
  2335. while (((*options) == ',') || ((*options) == ':')
  2336. || ((*options) == '='))
  2337. options++;
  2338. }
  2339. while (options) {
  2340. bn = 0;
  2341. if ((next = strchr(options, ','))) {
  2342. (*next) = '\0';
  2343. next++;
  2344. }
  2345. if (!strncmp(options, "mode:", 5)) {
  2346. options = pm3fb_boardnum_setup(options + 5, &bn);
  2347. DPRINTK(2, "Setting mode for board #%ld\n", bn);
  2348. pm3fb_mode_setup(options, bn);
  2349. } else if (!strncmp(options, "off:", 4)) {
  2350. options = pm3fb_boardnum_setup(options + 4, &bn);
  2351. DPRINTK(2, "Disabling board #%ld\n", bn);
  2352. disable[bn] = 1;
  2353. } else if (!strncmp(options, "off", 3)) { /* disable everything */
  2354. for (i = 0; i < PM3_MAX_BOARD; i++)
  2355. disable[i] = 1;
  2356. } else if (!strncmp(options, "disable:", 8)) {
  2357. options = pm3fb_boardnum_setup(options + 8, &bn);
  2358. DPRINTK(2, "Disabling board #%ld\n", bn);
  2359. disable[bn] = 1;
  2360. } else if (!strncmp(options, "pciid:", 6)) {
  2361. options = pm3fb_boardnum_setup(options + 6, &bn);
  2362. DPRINTK(2, "Setting PciID for board #%ld\n", bn);
  2363. pm3fb_pciid_setup(options, bn);
  2364. } else if (!strncmp(options, "noaccel:", 8)) {
  2365. options = pm3fb_boardnum_setup(options + 8, &bn);
  2366. noaccel[bn] = 1;
  2367. } else if (!strncmp(options, "font:", 5)) {
  2368. options = pm3fb_boardnum_setup(options + 5, &bn);
  2369. pm3fb_font_setup(options, bn);
  2370. } else if (!strncmp(options, "depth:", 6)) {
  2371. options = pm3fb_boardnum_setup(options + 6, &bn);
  2372. pm3fb_bootdepth_setup(options, bn);
  2373. } else if (!strncmp(options, "printtimings", 12)) {
  2374. printtimings = 1;
  2375. } else if (!strncmp(options, "flatpanel:", 10)) {
  2376. options = pm3fb_boardnum_setup(options + 10, &bn);
  2377. flatpanel[bn] = 1;
  2378. } else if (!strncmp(options, "forcesize:", 10)) {
  2379. options = pm3fb_boardnum_setup(options + 10, &bn);
  2380. pm3fb_forcesize_setup(options, bn);
  2381. }
  2382. options = next;
  2383. }
  2384. }
  2385. /* ********************************************** */
  2386. /* ***** framebuffer API standard functions ***** */
  2387. /* ********************************************** */
  2388. static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
  2389. const void *par, struct fb_info_gen *info)
  2390. {
  2391. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2392. struct pm3fb_par *p = (struct pm3fb_par *) par;
  2393. DTRACE;
  2394. strcpy(fix->id, permedia3_name);
  2395. fix->smem_start = (unsigned long)l_fb_info->p_fb;
  2396. fix->smem_len = l_fb_info->fb_size;
  2397. fix->mmio_start = (unsigned long)l_fb_info->pIOBase;
  2398. fix->mmio_len = PM3_REGS_SIZE;
  2399. #ifdef PM3FB_USE_ACCEL
  2400. if (!(noaccel[l_fb_info->board_num]))
  2401. fix->accel = FB_ACCEL_3DLABS_PERMEDIA3;
  2402. else
  2403. #endif /* PM3FB_USE_ACCEL */
  2404. fix->accel = FB_ACCEL_NONE;
  2405. fix->type = FB_TYPE_PACKED_PIXELS;
  2406. fix->visual =
  2407. (p->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
  2408. if (current_par_valid[l_fb_info->board_num])
  2409. fix->line_length =
  2410. l_fb_info->current_par->width *
  2411. depth2ByPP(l_fb_info->current_par->depth);
  2412. else
  2413. fix->line_length = 0;
  2414. fix->xpanstep = 64 / depth2bpp(p->depth);
  2415. fix->ypanstep = 1;
  2416. fix->ywrapstep = 0;
  2417. return (0);
  2418. }
  2419. static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
  2420. void *par, struct fb_info_gen *info)
  2421. {
  2422. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2423. struct pm3fb_par *p = (struct pm3fb_par *) par;
  2424. struct pm3fb_par temp_p;
  2425. u32 xres;
  2426. DTRACE;
  2427. DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
  2428. DASSERT((p != NULL), "pm3fb_par* not NULL");
  2429. DASSERT((l_fb_info != NULL), "pm3fb_info* not NULL");
  2430. memset(&temp_p, 0, sizeof(struct pm3fb_par));
  2431. temp_p.width = (var->xres_virtual + 7) & ~7;
  2432. temp_p.height = var->yres_virtual;
  2433. if (!(depth_supported(var->bits_per_pixel))) /* round unsupported up to a multiple of 8 */
  2434. temp_p.depth = depth2bpp(var->bits_per_pixel);
  2435. else
  2436. temp_p.depth = var->bits_per_pixel;
  2437. temp_p.depth = (temp_p.depth > 32) ? 32 : temp_p.depth; /* max 32 */
  2438. temp_p.depth = (temp_p.depth == 24) ? 32 : temp_p.depth; /* 24 unsupported, round-up to 32 */
  2439. if ((temp_p.depth == 16) && (var->red.length == 5) && (var->green.length == 5) && (var->blue.length == 5))
  2440. temp_p.depth = 15; /* RGBA 5551 is stored as depth 15 */
  2441. if ((temp_p.depth == 16) && (var->red.length == 4) && (var->green.length == 4) && (var->blue.length == 4))
  2442. temp_p.depth = 12; /* RGBA 4444 is stored as depth 12 */
  2443. DPRINTK(2,
  2444. "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n",
  2445. var->xres, var->yres, var->xres_virtual, var->yres_virtual,
  2446. var->xoffset, var->yoffset);
  2447. xres = (var->xres + 31) & ~31;
  2448. if (temp_p.width < xres + var->xoffset)
  2449. temp_p.width = xres + var->xoffset;
  2450. if (temp_p.height < var->yres + var->yoffset)
  2451. temp_p.height = var->yres + var->yoffset;
  2452. if (temp_p.width > 2048) {
  2453. DPRINTK(1, "virtual width not supported: %u\n",
  2454. temp_p.width);
  2455. return (-EINVAL);
  2456. }
  2457. if (var->yres < 200) {
  2458. DPRINTK(1, "height not supported: %u\n", (u32) var->yres);
  2459. return (-EINVAL);
  2460. }
  2461. if (temp_p.height < 200 || temp_p.height > 4095) {
  2462. DPRINTK(1, "virtual height not supported: %u\n",
  2463. temp_p.height);
  2464. return (-EINVAL);
  2465. }
  2466. if (!(depth_supported(temp_p.depth))) {
  2467. DPRINTK(1, "depth not supported: %u\n", temp_p.depth);
  2468. return (-EINVAL);
  2469. }
  2470. if ((temp_p.width * temp_p.height * depth2ByPP(temp_p.depth)) >
  2471. l_fb_info->fb_size) {
  2472. DPRINTK(1, "no memory for screen (%ux%ux%u)\n",
  2473. temp_p.width, temp_p.height, temp_p.depth);
  2474. return (-EINVAL);
  2475. }
  2476. if ((!var->pixclock) ||
  2477. (!var->right_margin) ||
  2478. (!var->hsync_len) ||
  2479. (!var->left_margin) ||
  2480. (!var->lower_margin) ||
  2481. (!var->vsync_len) || (!var->upper_margin)
  2482. ) {
  2483. unsigned long i = 0, done = 0;
  2484. printk(KERN_WARNING "pm3fb: refusing to use a likely wrong timing\n");
  2485. while ((mode_base[i].user_mode.width) && !done) {
  2486. if ((mode_base[i].user_mode.width == temp_p.width)
  2487. && (mode_base[i].user_mode.height ==
  2488. temp_p.height)) {
  2489. printk(KERN_NOTICE "pm3fb: using close match %s\n",
  2490. mode_base[i].name);
  2491. temp_p = mode_base[i].user_mode;
  2492. done = 1;
  2493. }
  2494. i++;
  2495. }
  2496. if (!done)
  2497. return (-EINVAL);
  2498. } else {
  2499. temp_p.pixclock = PICOS2KHZ(var->pixclock);
  2500. if (temp_p.pixclock > PM3_MAX_PIXCLOCK) {
  2501. DPRINTK(1, "pixclock too high (%uKHz)\n",
  2502. temp_p.pixclock);
  2503. return (-EINVAL);
  2504. }
  2505. temp_p.hsstart = var->right_margin;
  2506. temp_p.hsend = var->right_margin + var->hsync_len;
  2507. temp_p.hbend =
  2508. var->right_margin + var->hsync_len + var->left_margin;
  2509. temp_p.htotal = xres + temp_p.hbend;
  2510. temp_p.vsstart = var->lower_margin;
  2511. temp_p.vsend = var->lower_margin + var->vsync_len;
  2512. temp_p.vbend =
  2513. var->lower_margin + var->vsync_len + var->upper_margin;
  2514. temp_p.vtotal = var->yres + temp_p.vbend;
  2515. temp_p.stride = temp_p.width;
  2516. DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n",
  2517. temp_p.width, temp_p.height, temp_p.pixclock,
  2518. temp_p.stride);
  2519. temp_p.base =
  2520. pm3fb_Shiftbpp(l_fb_info, temp_p.depth,
  2521. (var->yoffset * xres) + var->xoffset);
  2522. temp_p.video = 0;
  2523. if (var->sync & FB_SYNC_HOR_HIGH_ACT)
  2524. temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_HIGH;
  2525. else
  2526. temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_LOW;
  2527. if (var->sync & FB_SYNC_VERT_HIGH_ACT)
  2528. temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_HIGH;
  2529. else
  2530. temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_LOW;
  2531. if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
  2532. DPRINTK(1, "Interlaced mode not supported\n\n");
  2533. return (-EINVAL);
  2534. }
  2535. if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
  2536. temp_p.video |= PM3VideoControl_LINE_DOUBLE_ON;
  2537. else
  2538. temp_p.video |= PM3VideoControl_LINE_DOUBLE_OFF;
  2539. if (var->activate == FB_ACTIVATE_NOW)
  2540. temp_p.video |= PM3VideoControl_ENABLE;
  2541. else {
  2542. temp_p.video |= PM3VideoControl_DISABLE;
  2543. DPRINTK(2, "PM3Video disabled\n");
  2544. }
  2545. switch (temp_p.depth) {
  2546. case 8:
  2547. temp_p.video |= PM3VideoControl_PIXELSIZE_8BIT;
  2548. break;
  2549. case 12:
  2550. case 15:
  2551. case 16:
  2552. temp_p.video |= PM3VideoControl_PIXELSIZE_16BIT;
  2553. break;
  2554. case 32:
  2555. temp_p.video |= PM3VideoControl_PIXELSIZE_32BIT;
  2556. break;
  2557. default:
  2558. DPRINTK(1, "Unsupported depth\n");
  2559. break;
  2560. }
  2561. }
  2562. (*p) = temp_p;
  2563. #ifdef PM3FB_USE_ACCEL
  2564. if (var->accel_flags & FB_ACCELF_TEXT)
  2565. noaccel[l_fb_info->board_num] = 0;
  2566. else
  2567. noaccel[l_fb_info->board_num] = 1;
  2568. #endif /* PM3FB_USE_ACCEL */
  2569. return (0);
  2570. }
  2571. static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d)
  2572. {
  2573. switch (d) {
  2574. case 8:
  2575. var->red.length = var->green.length = var->blue.length = 8;
  2576. var->red.offset = var->green.offset = var->blue.offset = 0;
  2577. var->transp.offset = var->transp.length = 0;
  2578. break;
  2579. case 12:
  2580. var->red.offset = 8;
  2581. var->red.length = 4;
  2582. var->green.offset = 4;
  2583. var->green.length = 4;
  2584. var->blue.offset = 0;
  2585. var->blue.length = 4;
  2586. var->transp.offset = 12;
  2587. var->transp.length = 4;
  2588. break;
  2589. case 15:
  2590. var->red.offset = 10;
  2591. var->red.length = 5;
  2592. var->green.offset = 5;
  2593. var->green.length = 5;
  2594. var->blue.offset = 0;
  2595. var->blue.length = 5;
  2596. var->transp.offset = 15;
  2597. var->transp.length = 1;
  2598. break;
  2599. case 16:
  2600. var->red.offset = 11;
  2601. var->red.length = 5;
  2602. var->green.offset = 5;
  2603. var->green.length = 6;
  2604. var->blue.offset = 0;
  2605. var->blue.length = 5;
  2606. var->transp.offset = var->transp.length = 0;
  2607. break;
  2608. case 32:
  2609. var->transp.offset = 24;
  2610. var->red.offset = 16;
  2611. var->green.offset = 8;
  2612. var->blue.offset = 0;
  2613. var->red.length = var->green.length =
  2614. var->blue.length = var->transp.length = 8;
  2615. break;
  2616. default:
  2617. DPRINTK(1, "Unsupported depth %ld\n", d);
  2618. break;
  2619. }
  2620. }
  2621. static int pm3fb_encode_var(struct fb_var_screeninfo *var,
  2622. const void *par, struct fb_info_gen *info)
  2623. {
  2624. struct pm3fb_par *p = (struct pm3fb_par *) par;
  2625. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2626. u32 base;
  2627. DTRACE;
  2628. DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
  2629. DASSERT((p != NULL), "pm3fb_par* not NULL");
  2630. DASSERT((info != NULL), "fb_info_gen* not NULL");
  2631. memset(var, 0, sizeof(struct fb_var_screeninfo));
  2632. #ifdef PM3FB_USE_ACCEL
  2633. if (!(noaccel[l_fb_info->board_num]))
  2634. var->accel_flags |= FB_ACCELF_TEXT;
  2635. #endif /* PM3FB_USE_ACCEL */
  2636. var->xres_virtual = p->width;
  2637. var->yres_virtual = p->height;
  2638. var->xres = p->htotal - p->hbend;
  2639. var->yres = p->vtotal - p->vbend;
  2640. DPRINTK(2, "xres = %d, yres : %d\n", var->xres, var->yres);
  2641. var->right_margin = p->hsstart;
  2642. var->hsync_len = p->hsend - p->hsstart;
  2643. var->left_margin = p->hbend - p->hsend;
  2644. var->lower_margin = p->vsstart;
  2645. var->vsync_len = p->vsend - p->vsstart;
  2646. var->upper_margin = p->vbend - p->vsend;
  2647. var->bits_per_pixel = depth2bpp(p->depth);
  2648. pm3fb_encode_depth(var, p->depth);
  2649. base = pm3fb_Unshiftbpp(l_fb_info, p->depth, p->base);
  2650. var->xoffset = base % var->xres;
  2651. var->yoffset = base / var->xres;
  2652. var->height = var->width = -1;
  2653. var->pixclock = KHZ2PICOS(p->pixclock);
  2654. if ((p->video & PM3VideoControl_HSYNC_MASK) ==
  2655. PM3VideoControl_HSYNC_ACTIVE_HIGH)
  2656. var->sync |= FB_SYNC_HOR_HIGH_ACT;
  2657. if ((p->video & PM3VideoControl_VSYNC_MASK) ==
  2658. PM3VideoControl_VSYNC_ACTIVE_HIGH)
  2659. var->sync |= FB_SYNC_VERT_HIGH_ACT;
  2660. if (p->video & PM3VideoControl_LINE_DOUBLE_ON)
  2661. var->vmode = FB_VMODE_DOUBLE;
  2662. return (0);
  2663. }
  2664. static void pm3fb_get_par(void *par, struct fb_info_gen *info)
  2665. {
  2666. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2667. DTRACE;
  2668. if (!current_par_valid[l_fb_info->board_num]) {
  2669. if (l_fb_info->use_current)
  2670. pm3fb_read_mode(l_fb_info, l_fb_info->current_par);
  2671. else
  2672. memcpy(l_fb_info->current_par,
  2673. &(mode_base[0].user_mode),
  2674. sizeof(struct pm3fb_par));
  2675. current_par_valid[l_fb_info->board_num] = 1;
  2676. }
  2677. *((struct pm3fb_par *) par) = *(l_fb_info->current_par);
  2678. }
  2679. static void pm3fb_set_par(const void *par, struct fb_info_gen *info)
  2680. {
  2681. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2682. DTRACE;
  2683. *(l_fb_info->current_par) = *((struct pm3fb_par *) par);
  2684. current_par_valid[l_fb_info->board_num] = 1;
  2685. pm3fb_write_mode(l_fb_info);
  2686. #ifdef PM3FB_USE_ACCEL
  2687. pm3fb_init_engine(l_fb_info);
  2688. #endif /* PM3FB_USE_ACCEL */
  2689. }
  2690. static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
  2691. unsigned char regno, unsigned char r,
  2692. unsigned char g, unsigned char b)
  2693. {
  2694. DTRACE;
  2695. PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress, regno);
  2696. PM3_SLOW_WRITE_REG(PM3RD_PaletteData, r);
  2697. PM3_SLOW_WRITE_REG(PM3RD_PaletteData, g);
  2698. PM3_SLOW_WRITE_REG(PM3RD_PaletteData, b);
  2699. }
  2700. static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
  2701. unsigned *blue, unsigned *transp,
  2702. struct fb_info *info)
  2703. {
  2704. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2705. DTRACE;
  2706. if (regno < 256) {
  2707. *red =
  2708. l_fb_info->palette[regno].red << 8 | l_fb_info->
  2709. palette[regno].red;
  2710. *green =
  2711. l_fb_info->palette[regno].green << 8 | l_fb_info->
  2712. palette[regno].green;
  2713. *blue =
  2714. l_fb_info->palette[regno].blue << 8 | l_fb_info->
  2715. palette[regno].blue;
  2716. *transp =
  2717. l_fb_info->palette[regno].transp << 8 | l_fb_info->
  2718. palette[regno].transp;
  2719. }
  2720. return (regno > 255);
  2721. }
  2722. static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
  2723. unsigned blue, unsigned transp,
  2724. struct fb_info *info)
  2725. {
  2726. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2727. DTRACE;
  2728. if (regno < 16) {
  2729. switch (l_fb_info->current_par->depth) {
  2730. #ifdef FBCON_HAS_CFB8
  2731. case 8:
  2732. break;
  2733. #endif
  2734. #ifdef FBCON_HAS_CFB16
  2735. case 12:
  2736. l_fb_info->cmap.cmap12[regno] =
  2737. (((u32) red & 0xf000) >> 4) |
  2738. (((u32) green & 0xf000) >> 8) |
  2739. (((u32) blue & 0xf000) >> 12);
  2740. break;
  2741. case 15:
  2742. l_fb_info->cmap.cmap15[regno] =
  2743. (((u32) red & 0xf800) >> 1) |
  2744. (((u32) green & 0xf800) >> 6) |
  2745. (((u32) blue & 0xf800) >> 11);
  2746. break;
  2747. case 16:
  2748. l_fb_info->cmap.cmap16[regno] =
  2749. ((u32) red & 0xf800) |
  2750. (((u32) green & 0xfc00) >> 5) |
  2751. (((u32) blue & 0xf800) >> 11);
  2752. break;
  2753. #endif
  2754. #ifdef FBCON_HAS_CFB32
  2755. case 32:
  2756. l_fb_info->cmap.cmap32[regno] =
  2757. (((u32) transp & 0xff00) << 16) |
  2758. (((u32) red & 0xff00) << 8) |
  2759. (((u32) green & 0xff00)) |
  2760. (((u32) blue & 0xff00) >> 8);
  2761. break;
  2762. #endif
  2763. default:
  2764. DPRINTK(1, "bad depth %u\n",
  2765. l_fb_info->current_par->depth);
  2766. break;
  2767. }
  2768. }
  2769. if (regno < 256) {
  2770. l_fb_info->palette[regno].red = red >> 8;
  2771. l_fb_info->palette[regno].green = green >> 8;
  2772. l_fb_info->palette[regno].blue = blue >> 8;
  2773. l_fb_info->palette[regno].transp = transp >> 8;
  2774. if (l_fb_info->current_par->depth == 8)
  2775. pm3fb_set_color(l_fb_info, regno, red >> 8,
  2776. green >> 8, blue >> 8);
  2777. }
  2778. return (regno > 255);
  2779. }
  2780. static int pm3fb_blank(int blank_mode, struct fb_info_gen *info)
  2781. {
  2782. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2783. u32 video;
  2784. DTRACE;
  2785. if (!current_par_valid[l_fb_info->board_num])
  2786. return (1);
  2787. video = l_fb_info->current_par->video;
  2788. /*
  2789. * Oxygen VX1 - it appears that setting PM3VideoControl and
  2790. * then PM3RD_SyncControl to the same SYNC settings undoes
  2791. * any net change - they seem to xor together. Only set the
  2792. * sync options in PM3RD_SyncControl. --rmk
  2793. */
  2794. video &= ~(PM3VideoControl_HSYNC_MASK |
  2795. PM3VideoControl_VSYNC_MASK);
  2796. video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
  2797. PM3VideoControl_VSYNC_ACTIVE_HIGH;
  2798. if (blank_mode > 0) {
  2799. switch (blank_mode - 1) {
  2800. case VESA_NO_BLANKING: /* FIXME */
  2801. video = video & ~(PM3VideoControl_ENABLE);
  2802. break;
  2803. case VESA_HSYNC_SUSPEND:
  2804. video = video & ~(PM3VideoControl_HSYNC_MASK |
  2805. PM3VideoControl_BLANK_ACTIVE_LOW);
  2806. break;
  2807. case VESA_VSYNC_SUSPEND:
  2808. video = video & ~(PM3VideoControl_VSYNC_MASK |
  2809. PM3VideoControl_BLANK_ACTIVE_LOW);
  2810. break;
  2811. case VESA_POWERDOWN:
  2812. video = video & ~(PM3VideoControl_HSYNC_MASK |
  2813. PM3VideoControl_VSYNC_MASK |
  2814. PM3VideoControl_BLANK_ACTIVE_LOW);
  2815. break;
  2816. default:
  2817. DPRINTK(1, "Unsupported blanking %d\n",
  2818. blank_mode);
  2819. return (1);
  2820. break;
  2821. }
  2822. }
  2823. PM3_SLOW_WRITE_REG(PM3VideoControl, video);
  2824. return (0);
  2825. }
  2826. static void pm3fb_set_disp(const void *par, struct display *disp,
  2827. struct fb_info_gen *info)
  2828. {
  2829. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  2830. struct pm3fb_par *p = (struct pm3fb_par *) par;
  2831. u32 flags;
  2832. DTRACE;
  2833. local_irq_save(flags);
  2834. info->info.screen_base = l_fb_info->v_fb;
  2835. switch (p->depth) {
  2836. #ifdef FBCON_HAS_CFB8
  2837. case 8:
  2838. #ifdef PM3FB_USE_ACCEL
  2839. if (!(noaccel[l_fb_info->board_num]))
  2840. disp->dispsw = &pm3fb_cfb8;
  2841. else
  2842. #endif /* PM3FB_USE_ACCEL */
  2843. disp->dispsw = &fbcon_cfb8;
  2844. break;
  2845. #endif
  2846. #ifdef FBCON_HAS_CFB16
  2847. case 12:
  2848. #ifdef PM3FB_USE_ACCEL
  2849. if (!(noaccel[l_fb_info->board_num]))
  2850. disp->dispsw = &pm3fb_cfb16;
  2851. else
  2852. #endif /* PM3FB_USE_ACCEL */
  2853. disp->dispsw = &fbcon_cfb16;
  2854. disp->dispsw_data = l_fb_info->cmap.cmap12;
  2855. break;
  2856. case 15:
  2857. #ifdef PM3FB_USE_ACCEL
  2858. if (!(noaccel[l_fb_info->board_num]))
  2859. disp->dispsw = &pm3fb_cfb16;
  2860. else
  2861. #endif /* PM3FB_USE_ACCEL */
  2862. disp->dispsw = &fbcon_cfb16;
  2863. disp->dispsw_data = l_fb_info->cmap.cmap15;
  2864. break;
  2865. case 16:
  2866. #ifdef PM3FB_USE_ACCEL
  2867. if (!(noaccel[l_fb_info->board_num]))
  2868. disp->dispsw = &pm3fb_cfb16;
  2869. else
  2870. #endif /* PM3FB_USE_ACCEL */
  2871. disp->dispsw = &fbcon_cfb16;
  2872. disp->dispsw_data = l_fb_info->cmap.cmap16;
  2873. break;
  2874. #endif
  2875. #ifdef FBCON_HAS_CFB32
  2876. case 32:
  2877. #ifdef PM3FB_USE_ACCEL
  2878. if (!(noaccel[l_fb_info->board_num]))
  2879. disp->dispsw = &pm3fb_cfb32;
  2880. else
  2881. #endif /* PM3FB_USE_ACCEL */
  2882. disp->dispsw = &fbcon_cfb32;
  2883. disp->dispsw_data = l_fb_info->cmap.cmap32;
  2884. break;
  2885. #endif /* FBCON_HAS_CFB32 */
  2886. default:
  2887. disp->dispsw = &fbcon_dummy;
  2888. DPRINTK(1, "Invalid depth, using fbcon_dummy\n");
  2889. break;
  2890. }
  2891. local_irq_restore(flags);
  2892. }
  2893. /* */
  2894. static void pm3fb_detect(void)
  2895. {
  2896. struct pci_dev *dev_array[PM3_MAX_BOARD];
  2897. struct pci_dev *dev = NULL;
  2898. struct pm3fb_info *l_fb_info = &(fb_info[0]);
  2899. unsigned long i, j, done;
  2900. DTRACE;
  2901. for (i = 0; i < PM3_MAX_BOARD; i++) {
  2902. dev_array[i] = NULL;
  2903. fb_info[i].dev = NULL;
  2904. }
  2905. dev =
  2906. pci_find_device(PCI_VENDOR_ID_3DLABS,
  2907. PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev);
  2908. for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) {
  2909. dev_array[i] = dev;
  2910. dev =
  2911. pci_find_device(PCI_VENDOR_ID_3DLABS,
  2912. PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev);
  2913. }
  2914. if (dev) { /* more than PM3_MAX_BOARD */
  2915. printk(KERN_WARNING "pm3fb: Warning: more than %d boards found\n",
  2916. PM3_MAX_BOARD);
  2917. }
  2918. if (!dev_array[0]) { /* not a single board, abort */
  2919. return;
  2920. }
  2921. /* allocate user-defined boards */
  2922. for (i = 0; i < PM3_MAX_BOARD; i++) {
  2923. if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) {
  2924. for (j = 0; j < PM3_MAX_BOARD; j++) {
  2925. if ((dev_array[j] != NULL) &&
  2926. (dev_array[j]->bus->number == bus[i])
  2927. && (PCI_SLOT(dev_array[j]->devfn) ==
  2928. slot[i])
  2929. && (PCI_FUNC(dev_array[j]->devfn) ==
  2930. func[i])) {
  2931. fb_info[i].dev = dev_array[j];
  2932. dev_array[j] = NULL;
  2933. }
  2934. }
  2935. }
  2936. }
  2937. /* allocate remaining boards */
  2938. for (i = 0; i < PM3_MAX_BOARD; i++) {
  2939. if (fb_info[i].dev == NULL) {
  2940. done = 0;
  2941. for (j = 0; ((j < PM3_MAX_BOARD) && (!done)); j++) {
  2942. if (dev_array[j] != NULL) {
  2943. fb_info[i].dev = dev_array[j];
  2944. dev_array[j] = NULL;
  2945. done = 1;
  2946. }
  2947. }
  2948. }
  2949. }
  2950. /* at that point, all PCI Permedia3 are detected and allocated */
  2951. /* now, initialize... or not */
  2952. for (i = 0; i < PM3_MAX_BOARD; i++) {
  2953. l_fb_info = &(fb_info[i]);
  2954. if ((l_fb_info->dev) && (!disable[i])) { /* PCI device was found and not disabled by user */
  2955. DPRINTK(2,
  2956. "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n",
  2957. (unsigned long) l_fb_info->dev,
  2958. (unsigned long) l_fb_info->dev->vendor,
  2959. (unsigned long) l_fb_info->dev->device,
  2960. (unsigned long)
  2961. pci_resource_start(l_fb_info->dev, 0),
  2962. (unsigned long)
  2963. pci_resource_start(l_fb_info->dev, 1),
  2964. (unsigned long)
  2965. pci_resource_start(l_fb_info->dev, 2),
  2966. (unsigned long)
  2967. pci_resource_start(l_fb_info->dev, 3),
  2968. (unsigned long)
  2969. pci_resource_start(l_fb_info->dev, 4),
  2970. (unsigned long)
  2971. pci_resource_start(l_fb_info->dev, 5),
  2972. (unsigned long) l_fb_info->dev->irq);
  2973. l_fb_info->pIOBase =
  2974. (unsigned char *)
  2975. pci_resource_start(l_fb_info->dev, 0);
  2976. #ifdef __BIG_ENDIAN
  2977. l_fb_info->pIOBase += PM3_REGS_SIZE;
  2978. #endif
  2979. l_fb_info->vIOBase = (unsigned char *) -1;
  2980. l_fb_info->p_fb =
  2981. (unsigned char *)
  2982. pci_resource_start(l_fb_info->dev, 1);
  2983. l_fb_info->v_fb = (unsigned char *) -1;
  2984. if (!request_mem_region
  2985. ((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */
  2986. "pm3fb")) {
  2987. printk
  2988. (KERN_ERR "pm3fb: Error: couldn't request framebuffer memory, board #%ld\n",
  2989. l_fb_info->board_num);
  2990. continue;
  2991. }
  2992. if (!request_mem_region
  2993. ((unsigned long)l_fb_info->pIOBase, PM3_REGS_SIZE,
  2994. "pm3fb I/O regs")) {
  2995. printk
  2996. (KERN_ERR "pm3fb: Error: couldn't request IObase memory, board #%ld\n",
  2997. l_fb_info->board_num);
  2998. continue;
  2999. }
  3000. if (forcesize[l_fb_info->board_num])
  3001. l_fb_info->fb_size = forcesize[l_fb_info->board_num];
  3002. l_fb_info->fb_size =
  3003. pm3fb_size_memory(l_fb_info);
  3004. if (l_fb_info->fb_size) {
  3005. (void) pci_enable_device(l_fb_info->dev);
  3006. pm3fb_common_init(l_fb_info);
  3007. } else
  3008. printk(KERN_ERR "pm3fb: memory problem, not enabling board #%ld\n", l_fb_info->board_num);
  3009. }
  3010. }
  3011. }
  3012. static int pm3fb_pan_display(const struct fb_var_screeninfo *var,
  3013. struct fb_info_gen *info)
  3014. {
  3015. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  3016. DTRACE;
  3017. if (!current_par_valid[l_fb_info->board_num])
  3018. return -EINVAL;
  3019. l_fb_info->current_par->base = /* in 128 bits chunk - i.e. AFTER Shiftbpp */
  3020. pm3fb_Shiftbpp(l_fb_info,
  3021. l_fb_info->current_par->depth,
  3022. (var->yoffset * l_fb_info->current_par->width) +
  3023. var->xoffset);
  3024. PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base);
  3025. return 0;
  3026. }
  3027. static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
  3028. {
  3029. struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
  3030. u32 cm, i;
  3031. #ifdef PM3FB_MASTER_DEBUG
  3032. char cc[3];
  3033. #endif /* PM3FB_MASTER_DEBUG */
  3034. switch(cmd)
  3035. {
  3036. #ifdef PM3FB_MASTER_DEBUG
  3037. case PM3FBIO_CLEARMEMORY:
  3038. if (copy_from_user(&cm, (void *)arg, sizeof(u32)))
  3039. return(-EFAULT);
  3040. pm3fb_clear_memory(l_fb_info, cm);
  3041. return(0);
  3042. break;
  3043. case PM3FBIO_CLEARCMAP:
  3044. if (copy_from_user(cc, (void*)arg, 3 * sizeof(char)))
  3045. return(-EFAULT);
  3046. pm3fb_clear_colormap(l_fb_info, cc[0], cc[1], cc[2]);
  3047. return(0);
  3048. break;
  3049. #endif /* PM3FB_MASTER_DEBUG */
  3050. case PM3FBIO_RESETCHIP:
  3051. cm = 1;
  3052. PM3_SLOW_WRITE_REG(PM3ResetStatus, 1);
  3053. for (i = 0 ; (i < 10000) && cm ; i++)
  3054. {
  3055. PM3_DELAY(10);
  3056. cm = PM3_READ_REG(PM3ResetStatus);
  3057. }
  3058. if (cm)
  3059. {
  3060. printk(KERN_ERR "pm3fb: chip reset failed with status 0x%x\n", cm);
  3061. return(-EIO);
  3062. }
  3063. /* first thing first, reload memory timings */
  3064. pm3fb_write_memory_timings(l_fb_info);
  3065. #ifdef PM3FB_USE_ACCEL
  3066. pm3fb_init_engine(l_fb_info);
  3067. #endif /* PM3FB_USE_ACCEL */
  3068. pm3fb_write_mode(l_fb_info);
  3069. return(0);
  3070. break;
  3071. default:
  3072. DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd, cmd);
  3073. return(-EINVAL);
  3074. }
  3075. }
  3076. /* ****************************************** */
  3077. /* ***** standard FB API init functions ***** */
  3078. /* ****************************************** */
  3079. int __init pm3fb_setup(char *options)
  3080. {
  3081. long opsi = strlen(options);
  3082. DTRACE;
  3083. memcpy(g_options, options,
  3084. ((opsi + 1) >
  3085. PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1));
  3086. g_options[PM3_OPTIONS_SIZE - 1] = 0;
  3087. return (0);
  3088. }
  3089. int __init pm3fb_init(void)
  3090. {
  3091. DTRACE;
  3092. DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $");
  3093. pm3fb_real_setup(g_options);
  3094. pm3fb_detect();
  3095. if (!fb_info[0].dev) { /* not even one board ??? */
  3096. DPRINTK(1, "No PCI Permedia3 board detected\n");
  3097. }
  3098. return (0);
  3099. }
  3100. /* ************************* */
  3101. /* **** Module support ***** */
  3102. /* ************************* */
  3103. #ifdef MODULE
  3104. MODULE_AUTHOR("Romain Dolbeau");
  3105. MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
  3106. static char *mode[PM3_MAX_BOARD];
  3107. module_param_array(mode, charp, NULL, 0);
  3108. MODULE_PARM_DESC(mode,"video mode");
  3109. module_param_array(disable, short, NULL, 0);
  3110. MODULE_PARM_DESC(disable,"disable board");
  3111. static short off[PM3_MAX_BOARD];
  3112. module_param_array(off, short, NULL, 0);
  3113. MODULE_PARM_DESC(off,"disable board");
  3114. static char *pciid[PM3_MAX_BOARD];
  3115. module_param_array(pciid, charp, NULL, 0);
  3116. MODULE_PARM_DESC(pciid,"board PCI Id");
  3117. module_param_array(noaccel, short, NULL, 0);
  3118. MODULE_PARM_DESC(noaccel,"disable accel");
  3119. static char *font[PM3_MAX_BOARD];
  3120. module_param_array(font, charp, NULL, 0);
  3121. MODULE_PARM_DESC(font,"choose font");
  3122. module_param(depth, short, NULL, 0);
  3123. MODULE_PARM_DESC(depth,"boot-time depth");
  3124. module_param(printtimings, short, NULL, 0);
  3125. MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
  3126. module_param(forcesize, short, NULL, 0);
  3127. MODULE_PARM_DESC(forcesize, "force specified memory size");
  3128. /*
  3129. MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
  3130. MODULE_GENERIC_TABLE(gtype,name)
  3131. MODULE_DEVICE_TABLE(type,name)
  3132. */
  3133. void pm3fb_build_options(void)
  3134. {
  3135. int i;
  3136. char ts[128];
  3137. strcpy(g_options, "pm3fb");
  3138. for (i = 0; i < PM3_MAX_BOARD ; i++)
  3139. {
  3140. if (mode[i])
  3141. {
  3142. sprintf(ts, ",mode:%d:%s", i, mode[i]);
  3143. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3144. }
  3145. if (disable[i] || off[i])
  3146. {
  3147. sprintf(ts, ",disable:%d:", i);
  3148. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3149. }
  3150. if (pciid[i])
  3151. {
  3152. sprintf(ts, ",pciid:%d:%s", i, pciid[i]);
  3153. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3154. }
  3155. if (noaccel[i])
  3156. {
  3157. sprintf(ts, ",noaccel:%d:", i);
  3158. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3159. }
  3160. if (font[i])
  3161. {
  3162. sprintf(ts, ",font:%d:%s", i, font[i]);
  3163. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3164. }
  3165. if (depth[i])
  3166. {
  3167. sprintf(ts, ",depth:%d:%d", i, depth[i]);
  3168. strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
  3169. }
  3170. }
  3171. g_options[PM3_OPTIONS_SIZE - 1] = '\0';
  3172. DPRINTK(1, "pm3fb use options: %s\n", g_options);
  3173. }
  3174. int init_module(void)
  3175. {
  3176. DTRACE;
  3177. pm3fb_build_options();
  3178. pm3fb_init();
  3179. return (0);
  3180. }
  3181. void cleanup_module(void)
  3182. {
  3183. DTRACE;
  3184. {
  3185. unsigned long i;
  3186. struct pm3fb_info *l_fb_info;
  3187. for (i = 0; i < PM3_MAX_BOARD; i++) {
  3188. l_fb_info = &(fb_info[i]);
  3189. if ((l_fb_info->dev != NULL)
  3190. && (!(disable[l_fb_info->board_num]))) {
  3191. if (l_fb_info->vIOBase !=
  3192. (unsigned char *) -1) {
  3193. pm3fb_unmapIO(l_fb_info);
  3194. release_mem_region(l_fb_info->p_fb,
  3195. l_fb_info->
  3196. fb_size);
  3197. release_mem_region(l_fb_info->
  3198. pIOBase,
  3199. PM3_REGS_SIZE);
  3200. }
  3201. unregister_framebuffer(&l_fb_info->gen.
  3202. info);
  3203. }
  3204. }
  3205. }
  3206. return;
  3207. }
  3208. #endif /* MODULE */