pm3fb.c 109 KB

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