pm3fb.c 109 KB

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