pm3fb.c 109 KB

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