fbdev.c 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234
  1. /*
  2. * linux/drivers/video/riva/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver
  3. *
  4. * Maintained by Ani Joshi <ajoshi@shell.unixbox.com>
  5. *
  6. * Copyright 1999-2000 Jeff Garzik
  7. *
  8. * Contributors:
  9. *
  10. * Ani Joshi: Lots of debugging and cleanup work, really helped
  11. * get the driver going
  12. *
  13. * Ferenc Bakonyi: Bug fixes, cleanup, modularization
  14. *
  15. * Jindrich Makovicka: Accel code help, hw cursor, mtrr
  16. *
  17. * Paul Richards: Bug fixes, updates
  18. *
  19. * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven
  20. * Includes riva_hw.c from nVidia, see copyright below.
  21. * KGI code provided the basis for state storage, init, and mode switching.
  22. *
  23. * This file is subject to the terms and conditions of the GNU General Public
  24. * License. See the file COPYING in the main directory of this archive
  25. * for more details.
  26. *
  27. * Known bugs and issues:
  28. * restoring text mode fails
  29. * doublescan modes are broken
  30. */
  31. #include <linux/module.h>
  32. #include <linux/kernel.h>
  33. #include <linux/errno.h>
  34. #include <linux/string.h>
  35. #include <linux/mm.h>
  36. #include <linux/slab.h>
  37. #include <linux/delay.h>
  38. #include <linux/fb.h>
  39. #include <linux/init.h>
  40. #include <linux/pci.h>
  41. #include <linux/backlight.h>
  42. #include <linux/bitrev.h>
  43. #ifdef CONFIG_MTRR
  44. #include <asm/mtrr.h>
  45. #endif
  46. #ifdef CONFIG_PPC_OF
  47. #include <asm/prom.h>
  48. #include <asm/pci-bridge.h>
  49. #endif
  50. #ifdef CONFIG_PMAC_BACKLIGHT
  51. #include <asm/machdep.h>
  52. #include <asm/backlight.h>
  53. #endif
  54. #include "rivafb.h"
  55. #include "nvreg.h"
  56. /* version number of this driver */
  57. #define RIVAFB_VERSION "0.9.5b"
  58. /* ------------------------------------------------------------------------- *
  59. *
  60. * various helpful macros and constants
  61. *
  62. * ------------------------------------------------------------------------- */
  63. #ifdef CONFIG_FB_RIVA_DEBUG
  64. #define NVTRACE printk
  65. #else
  66. #define NVTRACE if(0) printk
  67. #endif
  68. #define NVTRACE_ENTER(...) NVTRACE("%s START\n", __func__)
  69. #define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __func__)
  70. #ifdef CONFIG_FB_RIVA_DEBUG
  71. #define assert(expr) \
  72. if(!(expr)) { \
  73. printk( "Assertion failed! %s,%s,%s,line=%d\n",\
  74. #expr,__FILE__,__func__,__LINE__); \
  75. BUG(); \
  76. }
  77. #else
  78. #define assert(expr)
  79. #endif
  80. #define PFX "rivafb: "
  81. /* macro that allows you to set overflow bits */
  82. #define SetBitField(value,from,to) SetBF(to,GetBF(value,from))
  83. #define SetBit(n) (1<<(n))
  84. #define Set8Bits(value) ((value)&0xff)
  85. /* HW cursor parameters */
  86. #define MAX_CURS 32
  87. /* ------------------------------------------------------------------------- *
  88. *
  89. * prototypes
  90. *
  91. * ------------------------------------------------------------------------- */
  92. static int rivafb_blank(int blank, struct fb_info *info);
  93. /* ------------------------------------------------------------------------- *
  94. *
  95. * card identification
  96. *
  97. * ------------------------------------------------------------------------- */
  98. static struct pci_device_id rivafb_pci_tbl[] = {
  99. { PCI_VENDOR_ID_NVIDIA_SGS, PCI_DEVICE_ID_NVIDIA_SGS_RIVA128,
  100. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  101. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_TNT,
  102. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  103. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_TNT2,
  104. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  105. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_UTNT2,
  106. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  107. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_VTNT2,
  108. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  109. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_UVTNT2,
  110. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  111. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_ITNT2,
  112. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  113. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR,
  114. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  115. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR,
  116. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  117. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO,
  118. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  119. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX,
  120. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  121. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2,
  122. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  123. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO,
  124. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  125. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR,
  126. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  127. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS,
  128. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  129. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2,
  130. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  131. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA,
  132. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  133. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO,
  134. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  135. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460,
  136. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  137. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440,
  138. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  139. // NF2/IGP version, GeForce 4 MX, NV18
  140. { PCI_VENDOR_ID_NVIDIA, 0x01f0,
  141. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  142. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420,
  143. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  144. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO,
  145. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  146. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO,
  147. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  148. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32,
  149. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  150. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL,
  151. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  152. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64,
  153. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  154. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_200,
  155. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  156. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL,
  157. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  158. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL,
  159. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  160. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_IGEFORCE2,
  161. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  162. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3,
  163. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  164. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_1,
  165. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  166. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_2,
  167. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  168. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO_DDC,
  169. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  170. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600,
  171. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  172. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400,
  173. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  174. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200,
  175. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  176. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL,
  177. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  178. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL,
  179. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  180. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL,
  181. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  182. { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_GO_5200,
  183. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  184. { 0, } /* terminate list */
  185. };
  186. MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
  187. /* ------------------------------------------------------------------------- *
  188. *
  189. * global variables
  190. *
  191. * ------------------------------------------------------------------------- */
  192. /* command line data, set in rivafb_setup() */
  193. static int flatpanel __devinitdata = -1; /* Autodetect later */
  194. static int forceCRTC __devinitdata = -1;
  195. static int noaccel __devinitdata = 0;
  196. #ifdef CONFIG_MTRR
  197. static int nomtrr __devinitdata = 0;
  198. #endif
  199. #ifdef CONFIG_PMAC_BACKLIGHT
  200. static int backlight __devinitdata = 1;
  201. #else
  202. static int backlight __devinitdata = 0;
  203. #endif
  204. static char *mode_option __devinitdata = NULL;
  205. static int strictmode = 0;
  206. static struct fb_fix_screeninfo __devinitdata rivafb_fix = {
  207. .type = FB_TYPE_PACKED_PIXELS,
  208. .xpanstep = 1,
  209. .ypanstep = 1,
  210. };
  211. static struct fb_var_screeninfo __devinitdata rivafb_default_var = {
  212. .xres = 640,
  213. .yres = 480,
  214. .xres_virtual = 640,
  215. .yres_virtual = 480,
  216. .bits_per_pixel = 8,
  217. .red = {0, 8, 0},
  218. .green = {0, 8, 0},
  219. .blue = {0, 8, 0},
  220. .transp = {0, 0, 0},
  221. .activate = FB_ACTIVATE_NOW,
  222. .height = -1,
  223. .width = -1,
  224. .pixclock = 39721,
  225. .left_margin = 40,
  226. .right_margin = 24,
  227. .upper_margin = 32,
  228. .lower_margin = 11,
  229. .hsync_len = 96,
  230. .vsync_len = 2,
  231. .vmode = FB_VMODE_NONINTERLACED
  232. };
  233. /* from GGI */
  234. static const struct riva_regs reg_template = {
  235. {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* ATTR */
  236. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  237. 0x41, 0x01, 0x0F, 0x00, 0x00},
  238. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* CRT */
  239. 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
  240. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, /* 0x10 */
  241. 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  242. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */
  243. 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  244. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30 */
  245. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  246. 0x00, /* 0x40 */
  247. },
  248. {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, /* GRA */
  249. 0xFF},
  250. {0x03, 0x01, 0x0F, 0x00, 0x0E}, /* SEQ */
  251. 0xEB /* MISC */
  252. };
  253. /*
  254. * Backlight control
  255. */
  256. #ifdef CONFIG_FB_RIVA_BACKLIGHT
  257. /* We do not have any information about which values are allowed, thus
  258. * we used safe values.
  259. */
  260. #define MIN_LEVEL 0x158
  261. #define MAX_LEVEL 0x534
  262. #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX)
  263. static int riva_bl_get_level_brightness(struct riva_par *par,
  264. int level)
  265. {
  266. struct fb_info *info = pci_get_drvdata(par->pdev);
  267. int nlevel;
  268. /* Get and convert the value */
  269. /* No locking on bl_curve since accessing a single value */
  270. nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
  271. if (nlevel < 0)
  272. nlevel = 0;
  273. else if (nlevel < MIN_LEVEL)
  274. nlevel = MIN_LEVEL;
  275. else if (nlevel > MAX_LEVEL)
  276. nlevel = MAX_LEVEL;
  277. return nlevel;
  278. }
  279. static int riva_bl_update_status(struct backlight_device *bd)
  280. {
  281. struct riva_par *par = bl_get_data(bd);
  282. U032 tmp_pcrt, tmp_pmc;
  283. int level;
  284. if (bd->props.power != FB_BLANK_UNBLANK ||
  285. bd->props.fb_blank != FB_BLANK_UNBLANK)
  286. level = 0;
  287. else
  288. level = bd->props.brightness;
  289. tmp_pmc = NV_RD32(par->riva.PMC, 0x10F0) & 0x0000FFFF;
  290. tmp_pcrt = NV_RD32(par->riva.PCRTC0, 0x081C) & 0xFFFFFFFC;
  291. if(level > 0) {
  292. tmp_pcrt |= 0x1;
  293. tmp_pmc |= (1 << 31); /* backlight bit */
  294. tmp_pmc |= riva_bl_get_level_brightness(par, level) << 16; /* level */
  295. }
  296. NV_WR32(par->riva.PCRTC0, 0x081C, tmp_pcrt);
  297. NV_WR32(par->riva.PMC, 0x10F0, tmp_pmc);
  298. return 0;
  299. }
  300. static int riva_bl_get_brightness(struct backlight_device *bd)
  301. {
  302. return bd->props.brightness;
  303. }
  304. static struct backlight_ops riva_bl_ops = {
  305. .get_brightness = riva_bl_get_brightness,
  306. .update_status = riva_bl_update_status,
  307. };
  308. static void riva_bl_init(struct riva_par *par)
  309. {
  310. struct fb_info *info = pci_get_drvdata(par->pdev);
  311. struct backlight_device *bd;
  312. char name[12];
  313. if (!par->FlatPanel)
  314. return;
  315. #ifdef CONFIG_PMAC_BACKLIGHT
  316. if (!machine_is(powermac) ||
  317. !pmac_has_backlight_type("mnca"))
  318. return;
  319. #endif
  320. snprintf(name, sizeof(name), "rivabl%d", info->node);
  321. bd = backlight_device_register(name, info->dev, par, &riva_bl_ops);
  322. if (IS_ERR(bd)) {
  323. info->bl_dev = NULL;
  324. printk(KERN_WARNING "riva: Backlight registration failed\n");
  325. goto error;
  326. }
  327. info->bl_dev = bd;
  328. fb_bl_default_curve(info, 0,
  329. MIN_LEVEL * FB_BACKLIGHT_MAX / MAX_LEVEL,
  330. FB_BACKLIGHT_MAX);
  331. bd->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
  332. bd->props.brightness = bd->props.max_brightness;
  333. bd->props.power = FB_BLANK_UNBLANK;
  334. backlight_update_status(bd);
  335. printk("riva: Backlight initialized (%s)\n", name);
  336. return;
  337. error:
  338. return;
  339. }
  340. static void riva_bl_exit(struct fb_info *info)
  341. {
  342. struct backlight_device *bd = info->bl_dev;
  343. backlight_device_unregister(bd);
  344. printk("riva: Backlight unloaded\n");
  345. }
  346. #else
  347. static inline void riva_bl_init(struct riva_par *par) {}
  348. static inline void riva_bl_exit(struct fb_info *info) {}
  349. #endif /* CONFIG_FB_RIVA_BACKLIGHT */
  350. /* ------------------------------------------------------------------------- *
  351. *
  352. * MMIO access macros
  353. *
  354. * ------------------------------------------------------------------------- */
  355. static inline void CRTCout(struct riva_par *par, unsigned char index,
  356. unsigned char val)
  357. {
  358. VGA_WR08(par->riva.PCIO, 0x3d4, index);
  359. VGA_WR08(par->riva.PCIO, 0x3d5, val);
  360. }
  361. static inline unsigned char CRTCin(struct riva_par *par,
  362. unsigned char index)
  363. {
  364. VGA_WR08(par->riva.PCIO, 0x3d4, index);
  365. return (VGA_RD08(par->riva.PCIO, 0x3d5));
  366. }
  367. static inline void GRAout(struct riva_par *par, unsigned char index,
  368. unsigned char val)
  369. {
  370. VGA_WR08(par->riva.PVIO, 0x3ce, index);
  371. VGA_WR08(par->riva.PVIO, 0x3cf, val);
  372. }
  373. static inline unsigned char GRAin(struct riva_par *par,
  374. unsigned char index)
  375. {
  376. VGA_WR08(par->riva.PVIO, 0x3ce, index);
  377. return (VGA_RD08(par->riva.PVIO, 0x3cf));
  378. }
  379. static inline void SEQout(struct riva_par *par, unsigned char index,
  380. unsigned char val)
  381. {
  382. VGA_WR08(par->riva.PVIO, 0x3c4, index);
  383. VGA_WR08(par->riva.PVIO, 0x3c5, val);
  384. }
  385. static inline unsigned char SEQin(struct riva_par *par,
  386. unsigned char index)
  387. {
  388. VGA_WR08(par->riva.PVIO, 0x3c4, index);
  389. return (VGA_RD08(par->riva.PVIO, 0x3c5));
  390. }
  391. static inline void ATTRout(struct riva_par *par, unsigned char index,
  392. unsigned char val)
  393. {
  394. VGA_WR08(par->riva.PCIO, 0x3c0, index);
  395. VGA_WR08(par->riva.PCIO, 0x3c0, val);
  396. }
  397. static inline unsigned char ATTRin(struct riva_par *par,
  398. unsigned char index)
  399. {
  400. VGA_WR08(par->riva.PCIO, 0x3c0, index);
  401. return (VGA_RD08(par->riva.PCIO, 0x3c1));
  402. }
  403. static inline void MISCout(struct riva_par *par, unsigned char val)
  404. {
  405. VGA_WR08(par->riva.PVIO, 0x3c2, val);
  406. }
  407. static inline unsigned char MISCin(struct riva_par *par)
  408. {
  409. return (VGA_RD08(par->riva.PVIO, 0x3cc));
  410. }
  411. static inline void reverse_order(u32 *l)
  412. {
  413. u8 *a = (u8 *)l;
  414. a[0] = bitrev8(a[0]);
  415. a[1] = bitrev8(a[1]);
  416. a[2] = bitrev8(a[2]);
  417. a[3] = bitrev8(a[3]);
  418. }
  419. /* ------------------------------------------------------------------------- *
  420. *
  421. * cursor stuff
  422. *
  423. * ------------------------------------------------------------------------- */
  424. /**
  425. * rivafb_load_cursor_image - load cursor image to hardware
  426. * @data: address to monochrome bitmap (1 = foreground color, 0 = background)
  427. * @par: pointer to private data
  428. * @w: width of cursor image in pixels
  429. * @h: height of cursor image in scanlines
  430. * @bg: background color (ARGB1555) - alpha bit determines opacity
  431. * @fg: foreground color (ARGB1555)
  432. *
  433. * DESCRIPTiON:
  434. * Loads cursor image based on a monochrome source and mask bitmap. The
  435. * image bits determines the color of the pixel, 0 for background, 1 for
  436. * foreground. Only the affected region (as determined by @w and @h
  437. * parameters) will be updated.
  438. *
  439. * CALLED FROM:
  440. * rivafb_cursor()
  441. */
  442. static void rivafb_load_cursor_image(struct riva_par *par, u8 *data8,
  443. u16 bg, u16 fg, u32 w, u32 h)
  444. {
  445. int i, j, k = 0;
  446. u32 b, tmp;
  447. u32 *data = (u32 *)data8;
  448. bg = le16_to_cpu(bg);
  449. fg = le16_to_cpu(fg);
  450. w = (w + 1) & ~1;
  451. for (i = 0; i < h; i++) {
  452. b = *data++;
  453. reverse_order(&b);
  454. for (j = 0; j < w/2; j++) {
  455. tmp = 0;
  456. #if defined (__BIG_ENDIAN)
  457. tmp = (b & (1 << 31)) ? fg << 16 : bg << 16;
  458. b <<= 1;
  459. tmp |= (b & (1 << 31)) ? fg : bg;
  460. b <<= 1;
  461. #else
  462. tmp = (b & 1) ? fg : bg;
  463. b >>= 1;
  464. tmp |= (b & 1) ? fg << 16 : bg << 16;
  465. b >>= 1;
  466. #endif
  467. writel(tmp, &par->riva.CURSOR[k++]);
  468. }
  469. k += (MAX_CURS - w)/2;
  470. }
  471. }
  472. /* ------------------------------------------------------------------------- *
  473. *
  474. * general utility functions
  475. *
  476. * ------------------------------------------------------------------------- */
  477. /**
  478. * riva_wclut - set CLUT entry
  479. * @chip: pointer to RIVA_HW_INST object
  480. * @regnum: register number
  481. * @red: red component
  482. * @green: green component
  483. * @blue: blue component
  484. *
  485. * DESCRIPTION:
  486. * Sets color register @regnum.
  487. *
  488. * CALLED FROM:
  489. * rivafb_setcolreg()
  490. */
  491. static void riva_wclut(RIVA_HW_INST *chip,
  492. unsigned char regnum, unsigned char red,
  493. unsigned char green, unsigned char blue)
  494. {
  495. VGA_WR08(chip->PDIO, 0x3c8, regnum);
  496. VGA_WR08(chip->PDIO, 0x3c9, red);
  497. VGA_WR08(chip->PDIO, 0x3c9, green);
  498. VGA_WR08(chip->PDIO, 0x3c9, blue);
  499. }
  500. /**
  501. * riva_rclut - read fromCLUT register
  502. * @chip: pointer to RIVA_HW_INST object
  503. * @regnum: register number
  504. * @red: red component
  505. * @green: green component
  506. * @blue: blue component
  507. *
  508. * DESCRIPTION:
  509. * Reads red, green, and blue from color register @regnum.
  510. *
  511. * CALLED FROM:
  512. * rivafb_setcolreg()
  513. */
  514. static void riva_rclut(RIVA_HW_INST *chip,
  515. unsigned char regnum, unsigned char *red,
  516. unsigned char *green, unsigned char *blue)
  517. {
  518. VGA_WR08(chip->PDIO, 0x3c7, regnum);
  519. *red = VGA_RD08(chip->PDIO, 0x3c9);
  520. *green = VGA_RD08(chip->PDIO, 0x3c9);
  521. *blue = VGA_RD08(chip->PDIO, 0x3c9);
  522. }
  523. /**
  524. * riva_save_state - saves current chip state
  525. * @par: pointer to riva_par object containing info for current riva board
  526. * @regs: pointer to riva_regs object
  527. *
  528. * DESCRIPTION:
  529. * Saves current chip state to @regs.
  530. *
  531. * CALLED FROM:
  532. * rivafb_probe()
  533. */
  534. /* from GGI */
  535. static void riva_save_state(struct riva_par *par, struct riva_regs *regs)
  536. {
  537. int i;
  538. NVTRACE_ENTER();
  539. par->riva.LockUnlock(&par->riva, 0);
  540. par->riva.UnloadStateExt(&par->riva, &regs->ext);
  541. regs->misc_output = MISCin(par);
  542. for (i = 0; i < NUM_CRT_REGS; i++)
  543. regs->crtc[i] = CRTCin(par, i);
  544. for (i = 0; i < NUM_ATC_REGS; i++)
  545. regs->attr[i] = ATTRin(par, i);
  546. for (i = 0; i < NUM_GRC_REGS; i++)
  547. regs->gra[i] = GRAin(par, i);
  548. for (i = 0; i < NUM_SEQ_REGS; i++)
  549. regs->seq[i] = SEQin(par, i);
  550. NVTRACE_LEAVE();
  551. }
  552. /**
  553. * riva_load_state - loads current chip state
  554. * @par: pointer to riva_par object containing info for current riva board
  555. * @regs: pointer to riva_regs object
  556. *
  557. * DESCRIPTION:
  558. * Loads chip state from @regs.
  559. *
  560. * CALLED FROM:
  561. * riva_load_video_mode()
  562. * rivafb_probe()
  563. * rivafb_remove()
  564. */
  565. /* from GGI */
  566. static void riva_load_state(struct riva_par *par, struct riva_regs *regs)
  567. {
  568. RIVA_HW_STATE *state = &regs->ext;
  569. int i;
  570. NVTRACE_ENTER();
  571. CRTCout(par, 0x11, 0x00);
  572. par->riva.LockUnlock(&par->riva, 0);
  573. par->riva.LoadStateExt(&par->riva, state);
  574. MISCout(par, regs->misc_output);
  575. for (i = 0; i < NUM_CRT_REGS; i++) {
  576. switch (i) {
  577. case 0x19:
  578. case 0x20 ... 0x40:
  579. break;
  580. default:
  581. CRTCout(par, i, regs->crtc[i]);
  582. }
  583. }
  584. for (i = 0; i < NUM_ATC_REGS; i++)
  585. ATTRout(par, i, regs->attr[i]);
  586. for (i = 0; i < NUM_GRC_REGS; i++)
  587. GRAout(par, i, regs->gra[i]);
  588. for (i = 0; i < NUM_SEQ_REGS; i++)
  589. SEQout(par, i, regs->seq[i]);
  590. NVTRACE_LEAVE();
  591. }
  592. /**
  593. * riva_load_video_mode - calculate timings
  594. * @info: pointer to fb_info object containing info for current riva board
  595. *
  596. * DESCRIPTION:
  597. * Calculate some timings and then send em off to riva_load_state().
  598. *
  599. * CALLED FROM:
  600. * rivafb_set_par()
  601. */
  602. static int riva_load_video_mode(struct fb_info *info)
  603. {
  604. int bpp, width, hDisplaySize, hDisplay, hStart,
  605. hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock;
  606. int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd;
  607. int rc;
  608. struct riva_par *par = info->par;
  609. struct riva_regs newmode;
  610. NVTRACE_ENTER();
  611. /* time to calculate */
  612. rivafb_blank(FB_BLANK_NORMAL, info);
  613. bpp = info->var.bits_per_pixel;
  614. if (bpp == 16 && info->var.green.length == 5)
  615. bpp = 15;
  616. width = info->var.xres_virtual;
  617. hDisplaySize = info->var.xres;
  618. hDisplay = (hDisplaySize / 8) - 1;
  619. hStart = (hDisplaySize + info->var.right_margin) / 8 - 1;
  620. hEnd = (hDisplaySize + info->var.right_margin +
  621. info->var.hsync_len) / 8 - 1;
  622. hTotal = (hDisplaySize + info->var.right_margin +
  623. info->var.hsync_len + info->var.left_margin) / 8 - 5;
  624. hBlankStart = hDisplay;
  625. hBlankEnd = hTotal + 4;
  626. height = info->var.yres_virtual;
  627. vDisplay = info->var.yres - 1;
  628. vStart = info->var.yres + info->var.lower_margin - 1;
  629. vEnd = info->var.yres + info->var.lower_margin +
  630. info->var.vsync_len - 1;
  631. vTotal = info->var.yres + info->var.lower_margin +
  632. info->var.vsync_len + info->var.upper_margin + 2;
  633. vBlankStart = vDisplay;
  634. vBlankEnd = vTotal + 1;
  635. dotClock = 1000000000 / info->var.pixclock;
  636. memcpy(&newmode, &reg_template, sizeof(struct riva_regs));
  637. if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
  638. vTotal |= 1;
  639. if (par->FlatPanel) {
  640. vStart = vTotal - 3;
  641. vEnd = vTotal - 2;
  642. vBlankStart = vStart;
  643. hStart = hTotal - 3;
  644. hEnd = hTotal - 2;
  645. hBlankEnd = hTotal + 4;
  646. }
  647. newmode.crtc[0x0] = Set8Bits (hTotal);
  648. newmode.crtc[0x1] = Set8Bits (hDisplay);
  649. newmode.crtc[0x2] = Set8Bits (hBlankStart);
  650. newmode.crtc[0x3] = SetBitField (hBlankEnd, 4: 0, 4:0) | SetBit (7);
  651. newmode.crtc[0x4] = Set8Bits (hStart);
  652. newmode.crtc[0x5] = SetBitField (hBlankEnd, 5: 5, 7:7)
  653. | SetBitField (hEnd, 4: 0, 4:0);
  654. newmode.crtc[0x6] = SetBitField (vTotal, 7: 0, 7:0);
  655. newmode.crtc[0x7] = SetBitField (vTotal, 8: 8, 0:0)
  656. | SetBitField (vDisplay, 8: 8, 1:1)
  657. | SetBitField (vStart, 8: 8, 2:2)
  658. | SetBitField (vBlankStart, 8: 8, 3:3)
  659. | SetBit (4)
  660. | SetBitField (vTotal, 9: 9, 5:5)
  661. | SetBitField (vDisplay, 9: 9, 6:6)
  662. | SetBitField (vStart, 9: 9, 7:7);
  663. newmode.crtc[0x9] = SetBitField (vBlankStart, 9: 9, 5:5)
  664. | SetBit (6);
  665. newmode.crtc[0x10] = Set8Bits (vStart);
  666. newmode.crtc[0x11] = SetBitField (vEnd, 3: 0, 3:0)
  667. | SetBit (5);
  668. newmode.crtc[0x12] = Set8Bits (vDisplay);
  669. newmode.crtc[0x13] = (width / 8) * ((bpp + 1) / 8);
  670. newmode.crtc[0x15] = Set8Bits (vBlankStart);
  671. newmode.crtc[0x16] = Set8Bits (vBlankEnd);
  672. newmode.ext.screen = SetBitField(hBlankEnd,6:6,4:4)
  673. | SetBitField(vBlankStart,10:10,3:3)
  674. | SetBitField(vStart,10:10,2:2)
  675. | SetBitField(vDisplay,10:10,1:1)
  676. | SetBitField(vTotal,10:10,0:0);
  677. newmode.ext.horiz = SetBitField(hTotal,8:8,0:0)
  678. | SetBitField(hDisplay,8:8,1:1)
  679. | SetBitField(hBlankStart,8:8,2:2)
  680. | SetBitField(hStart,8:8,3:3);
  681. newmode.ext.extra = SetBitField(vTotal,11:11,0:0)
  682. | SetBitField(vDisplay,11:11,2:2)
  683. | SetBitField(vStart,11:11,4:4)
  684. | SetBitField(vBlankStart,11:11,6:6);
  685. if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
  686. int tmp = (hTotal >> 1) & ~1;
  687. newmode.ext.interlace = Set8Bits(tmp);
  688. newmode.ext.horiz |= SetBitField(tmp, 8:8,4:4);
  689. } else
  690. newmode.ext.interlace = 0xff; /* interlace off */
  691. if (par->riva.Architecture >= NV_ARCH_10)
  692. par->riva.CURSOR = (U032 __iomem *)(info->screen_base + par->riva.CursorStart);
  693. if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
  694. newmode.misc_output &= ~0x40;
  695. else
  696. newmode.misc_output |= 0x40;
  697. if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
  698. newmode.misc_output &= ~0x80;
  699. else
  700. newmode.misc_output |= 0x80;
  701. rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width,
  702. hDisplaySize, height, dotClock);
  703. if (rc)
  704. goto out;
  705. newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) &
  706. 0xfff000ff;
  707. if (par->FlatPanel == 1) {
  708. newmode.ext.pixel |= (1 << 7);
  709. newmode.ext.scale |= (1 << 8);
  710. }
  711. if (par->SecondCRTC) {
  712. newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) &
  713. ~0x00001000;
  714. newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) |
  715. 0x00001000;
  716. newmode.ext.crtcOwner = 3;
  717. newmode.ext.pllsel |= 0x20000800;
  718. newmode.ext.vpll2 = newmode.ext.vpll;
  719. } else if (par->riva.twoHeads) {
  720. newmode.ext.head = NV_RD32(par->riva.PCRTC0, 0x00000860) |
  721. 0x00001000;
  722. newmode.ext.head2 = NV_RD32(par->riva.PCRTC0, 0x00002860) &
  723. ~0x00001000;
  724. newmode.ext.crtcOwner = 0;
  725. newmode.ext.vpll2 = NV_RD32(par->riva.PRAMDAC0, 0x00000520);
  726. }
  727. if (par->FlatPanel == 1) {
  728. newmode.ext.pixel |= (1 << 7);
  729. newmode.ext.scale |= (1 << 8);
  730. }
  731. newmode.ext.cursorConfig = 0x02000100;
  732. par->current_state = newmode;
  733. riva_load_state(par, &par->current_state);
  734. par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */
  735. out:
  736. rivafb_blank(FB_BLANK_UNBLANK, info);
  737. NVTRACE_LEAVE();
  738. return rc;
  739. }
  740. static void riva_update_var(struct fb_var_screeninfo *var,
  741. const struct fb_videomode *modedb)
  742. {
  743. NVTRACE_ENTER();
  744. var->xres = var->xres_virtual = modedb->xres;
  745. var->yres = modedb->yres;
  746. if (var->yres_virtual < var->yres)
  747. var->yres_virtual = var->yres;
  748. var->xoffset = var->yoffset = 0;
  749. var->pixclock = modedb->pixclock;
  750. var->left_margin = modedb->left_margin;
  751. var->right_margin = modedb->right_margin;
  752. var->upper_margin = modedb->upper_margin;
  753. var->lower_margin = modedb->lower_margin;
  754. var->hsync_len = modedb->hsync_len;
  755. var->vsync_len = modedb->vsync_len;
  756. var->sync = modedb->sync;
  757. var->vmode = modedb->vmode;
  758. NVTRACE_LEAVE();
  759. }
  760. /**
  761. * rivafb_do_maximize -
  762. * @info: pointer to fb_info object containing info for current riva board
  763. * @var:
  764. * @nom:
  765. * @den:
  766. *
  767. * DESCRIPTION:
  768. * .
  769. *
  770. * RETURNS:
  771. * -EINVAL on failure, 0 on success
  772. *
  773. *
  774. * CALLED FROM:
  775. * rivafb_check_var()
  776. */
  777. static int rivafb_do_maximize(struct fb_info *info,
  778. struct fb_var_screeninfo *var,
  779. int nom, int den)
  780. {
  781. static struct {
  782. int xres, yres;
  783. } modes[] = {
  784. {1600, 1280},
  785. {1280, 1024},
  786. {1024, 768},
  787. {800, 600},
  788. {640, 480},
  789. {-1, -1}
  790. };
  791. int i;
  792. NVTRACE_ENTER();
  793. /* use highest possible virtual resolution */
  794. if (var->xres_virtual == -1 && var->yres_virtual == -1) {
  795. printk(KERN_WARNING PFX
  796. "using maximum available virtual resolution\n");
  797. for (i = 0; modes[i].xres != -1; i++) {
  798. if (modes[i].xres * nom / den * modes[i].yres <
  799. info->fix.smem_len)
  800. break;
  801. }
  802. if (modes[i].xres == -1) {
  803. printk(KERN_ERR PFX
  804. "could not find a virtual resolution that fits into video memory!!\n");
  805. NVTRACE("EXIT - EINVAL error\n");
  806. return -EINVAL;
  807. }
  808. var->xres_virtual = modes[i].xres;
  809. var->yres_virtual = modes[i].yres;
  810. printk(KERN_INFO PFX
  811. "virtual resolution set to maximum of %dx%d\n",
  812. var->xres_virtual, var->yres_virtual);
  813. } else if (var->xres_virtual == -1) {
  814. var->xres_virtual = (info->fix.smem_len * den /
  815. (nom * var->yres_virtual)) & ~15;
  816. printk(KERN_WARNING PFX
  817. "setting virtual X resolution to %d\n", var->xres_virtual);
  818. } else if (var->yres_virtual == -1) {
  819. var->xres_virtual = (var->xres_virtual + 15) & ~15;
  820. var->yres_virtual = info->fix.smem_len * den /
  821. (nom * var->xres_virtual);
  822. printk(KERN_WARNING PFX
  823. "setting virtual Y resolution to %d\n", var->yres_virtual);
  824. } else {
  825. var->xres_virtual = (var->xres_virtual + 15) & ~15;
  826. if (var->xres_virtual * nom / den * var->yres_virtual > info->fix.smem_len) {
  827. printk(KERN_ERR PFX
  828. "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n",
  829. var->xres, var->yres, var->bits_per_pixel);
  830. NVTRACE("EXIT - EINVAL error\n");
  831. return -EINVAL;
  832. }
  833. }
  834. if (var->xres_virtual * nom / den >= 8192) {
  835. printk(KERN_WARNING PFX
  836. "virtual X resolution (%d) is too high, lowering to %d\n",
  837. var->xres_virtual, 8192 * den / nom - 16);
  838. var->xres_virtual = 8192 * den / nom - 16;
  839. }
  840. if (var->xres_virtual < var->xres) {
  841. printk(KERN_ERR PFX
  842. "virtual X resolution (%d) is smaller than real\n", var->xres_virtual);
  843. return -EINVAL;
  844. }
  845. if (var->yres_virtual < var->yres) {
  846. printk(KERN_ERR PFX
  847. "virtual Y resolution (%d) is smaller than real\n", var->yres_virtual);
  848. return -EINVAL;
  849. }
  850. if (var->yres_virtual > 0x7fff/nom)
  851. var->yres_virtual = 0x7fff/nom;
  852. if (var->xres_virtual > 0x7fff/nom)
  853. var->xres_virtual = 0x7fff/nom;
  854. NVTRACE_LEAVE();
  855. return 0;
  856. }
  857. static void
  858. riva_set_pattern(struct riva_par *par, int clr0, int clr1, int pat0, int pat1)
  859. {
  860. RIVA_FIFO_FREE(par->riva, Patt, 4);
  861. NV_WR32(&par->riva.Patt->Color0, 0, clr0);
  862. NV_WR32(&par->riva.Patt->Color1, 0, clr1);
  863. NV_WR32(par->riva.Patt->Monochrome, 0, pat0);
  864. NV_WR32(par->riva.Patt->Monochrome, 4, pat1);
  865. }
  866. /* acceleration routines */
  867. static inline void wait_for_idle(struct riva_par *par)
  868. {
  869. while (par->riva.Busy(&par->riva));
  870. }
  871. /*
  872. * Set ROP. Translate X rop into ROP3. Internal routine.
  873. */
  874. static void
  875. riva_set_rop_solid(struct riva_par *par, int rop)
  876. {
  877. riva_set_pattern(par, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
  878. RIVA_FIFO_FREE(par->riva, Rop, 1);
  879. NV_WR32(&par->riva.Rop->Rop3, 0, rop);
  880. }
  881. static void riva_setup_accel(struct fb_info *info)
  882. {
  883. struct riva_par *par = info->par;
  884. RIVA_FIFO_FREE(par->riva, Clip, 2);
  885. NV_WR32(&par->riva.Clip->TopLeft, 0, 0x0);
  886. NV_WR32(&par->riva.Clip->WidthHeight, 0,
  887. (info->var.xres_virtual & 0xffff) |
  888. (info->var.yres_virtual << 16));
  889. riva_set_rop_solid(par, 0xcc);
  890. wait_for_idle(par);
  891. }
  892. /**
  893. * riva_get_cmap_len - query current color map length
  894. * @var: standard kernel fb changeable data
  895. *
  896. * DESCRIPTION:
  897. * Get current color map length.
  898. *
  899. * RETURNS:
  900. * Length of color map
  901. *
  902. * CALLED FROM:
  903. * rivafb_setcolreg()
  904. */
  905. static int riva_get_cmap_len(const struct fb_var_screeninfo *var)
  906. {
  907. int rc = 256; /* reasonable default */
  908. switch (var->green.length) {
  909. case 8:
  910. rc = 256; /* 256 entries (2^8), 8 bpp and RGB8888 */
  911. break;
  912. case 5:
  913. rc = 32; /* 32 entries (2^5), 16 bpp, RGB555 */
  914. break;
  915. case 6:
  916. rc = 64; /* 64 entries (2^6), 16 bpp, RGB565 */
  917. break;
  918. default:
  919. /* should not occur */
  920. break;
  921. }
  922. return rc;
  923. }
  924. /* ------------------------------------------------------------------------- *
  925. *
  926. * framebuffer operations
  927. *
  928. * ------------------------------------------------------------------------- */
  929. static int rivafb_open(struct fb_info *info, int user)
  930. {
  931. struct riva_par *par = info->par;
  932. NVTRACE_ENTER();
  933. mutex_lock(&par->open_lock);
  934. if (!par->ref_count) {
  935. #ifdef CONFIG_X86
  936. memset(&par->state, 0, sizeof(struct vgastate));
  937. par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS;
  938. /* save the DAC for Riva128 */
  939. if (par->riva.Architecture == NV_ARCH_03)
  940. par->state.flags |= VGA_SAVE_CMAP;
  941. save_vga(&par->state);
  942. #endif
  943. /* vgaHWunlock() + riva unlock (0x7F) */
  944. CRTCout(par, 0x11, 0xFF);
  945. par->riva.LockUnlock(&par->riva, 0);
  946. riva_save_state(par, &par->initial_state);
  947. }
  948. par->ref_count++;
  949. mutex_unlock(&par->open_lock);
  950. NVTRACE_LEAVE();
  951. return 0;
  952. }
  953. static int rivafb_release(struct fb_info *info, int user)
  954. {
  955. struct riva_par *par = info->par;
  956. NVTRACE_ENTER();
  957. mutex_lock(&par->open_lock);
  958. if (!par->ref_count) {
  959. mutex_unlock(&par->open_lock);
  960. return -EINVAL;
  961. }
  962. if (par->ref_count == 1) {
  963. par->riva.LockUnlock(&par->riva, 0);
  964. par->riva.LoadStateExt(&par->riva, &par->initial_state.ext);
  965. riva_load_state(par, &par->initial_state);
  966. #ifdef CONFIG_X86
  967. restore_vga(&par->state);
  968. #endif
  969. par->riva.LockUnlock(&par->riva, 1);
  970. }
  971. par->ref_count--;
  972. mutex_unlock(&par->open_lock);
  973. NVTRACE_LEAVE();
  974. return 0;
  975. }
  976. static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  977. {
  978. const struct fb_videomode *mode;
  979. struct riva_par *par = info->par;
  980. int nom, den; /* translating from pixels->bytes */
  981. int mode_valid = 0;
  982. NVTRACE_ENTER();
  983. switch (var->bits_per_pixel) {
  984. case 1 ... 8:
  985. var->red.offset = var->green.offset = var->blue.offset = 0;
  986. var->red.length = var->green.length = var->blue.length = 8;
  987. var->bits_per_pixel = 8;
  988. nom = den = 1;
  989. break;
  990. case 9 ... 15:
  991. var->green.length = 5;
  992. /* fall through */
  993. case 16:
  994. var->bits_per_pixel = 16;
  995. /* The Riva128 supports RGB555 only */
  996. if (par->riva.Architecture == NV_ARCH_03)
  997. var->green.length = 5;
  998. if (var->green.length == 5) {
  999. /* 0rrrrrgg gggbbbbb */
  1000. var->red.offset = 10;
  1001. var->green.offset = 5;
  1002. var->blue.offset = 0;
  1003. var->red.length = 5;
  1004. var->green.length = 5;
  1005. var->blue.length = 5;
  1006. } else {
  1007. /* rrrrrggg gggbbbbb */
  1008. var->red.offset = 11;
  1009. var->green.offset = 5;
  1010. var->blue.offset = 0;
  1011. var->red.length = 5;
  1012. var->green.length = 6;
  1013. var->blue.length = 5;
  1014. }
  1015. nom = 2;
  1016. den = 1;
  1017. break;
  1018. case 17 ... 32:
  1019. var->red.length = var->green.length = var->blue.length = 8;
  1020. var->bits_per_pixel = 32;
  1021. var->red.offset = 16;
  1022. var->green.offset = 8;
  1023. var->blue.offset = 0;
  1024. nom = 4;
  1025. den = 1;
  1026. break;
  1027. default:
  1028. printk(KERN_ERR PFX
  1029. "mode %dx%dx%d rejected...color depth not supported.\n",
  1030. var->xres, var->yres, var->bits_per_pixel);
  1031. NVTRACE("EXIT, returning -EINVAL\n");
  1032. return -EINVAL;
  1033. }
  1034. if (!strictmode) {
  1035. if (!info->monspecs.vfmax || !info->monspecs.hfmax ||
  1036. !info->monspecs.dclkmax || !fb_validate_mode(var, info))
  1037. mode_valid = 1;
  1038. }
  1039. /* calculate modeline if supported by monitor */
  1040. if (!mode_valid && info->monspecs.gtf) {
  1041. if (!fb_get_mode(FB_MAXTIMINGS, 0, var, info))
  1042. mode_valid = 1;
  1043. }
  1044. if (!mode_valid) {
  1045. mode = fb_find_best_mode(var, &info->modelist);
  1046. if (mode) {
  1047. riva_update_var(var, mode);
  1048. mode_valid = 1;
  1049. }
  1050. }
  1051. if (!mode_valid && info->monspecs.modedb_len)
  1052. return -EINVAL;
  1053. if (var->xres_virtual < var->xres)
  1054. var->xres_virtual = var->xres;
  1055. if (var->yres_virtual <= var->yres)
  1056. var->yres_virtual = -1;
  1057. if (rivafb_do_maximize(info, var, nom, den) < 0)
  1058. return -EINVAL;
  1059. if (var->xoffset < 0)
  1060. var->xoffset = 0;
  1061. if (var->yoffset < 0)
  1062. var->yoffset = 0;
  1063. /* truncate xoffset and yoffset to maximum if too high */
  1064. if (var->xoffset > var->xres_virtual - var->xres)
  1065. var->xoffset = var->xres_virtual - var->xres - 1;
  1066. if (var->yoffset > var->yres_virtual - var->yres)
  1067. var->yoffset = var->yres_virtual - var->yres - 1;
  1068. var->red.msb_right =
  1069. var->green.msb_right =
  1070. var->blue.msb_right =
  1071. var->transp.offset = var->transp.length = var->transp.msb_right = 0;
  1072. NVTRACE_LEAVE();
  1073. return 0;
  1074. }
  1075. static int rivafb_set_par(struct fb_info *info)
  1076. {
  1077. struct riva_par *par = info->par;
  1078. int rc = 0;
  1079. NVTRACE_ENTER();
  1080. /* vgaHWunlock() + riva unlock (0x7F) */
  1081. CRTCout(par, 0x11, 0xFF);
  1082. par->riva.LockUnlock(&par->riva, 0);
  1083. rc = riva_load_video_mode(info);
  1084. if (rc)
  1085. goto out;
  1086. if(!(info->flags & FBINFO_HWACCEL_DISABLED))
  1087. riva_setup_accel(info);
  1088. par->cursor_reset = 1;
  1089. info->fix.line_length = (info->var.xres_virtual * (info->var.bits_per_pixel >> 3));
  1090. info->fix.visual = (info->var.bits_per_pixel == 8) ?
  1091. FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
  1092. if (info->flags & FBINFO_HWACCEL_DISABLED)
  1093. info->pixmap.scan_align = 1;
  1094. else
  1095. info->pixmap.scan_align = 4;
  1096. out:
  1097. NVTRACE_LEAVE();
  1098. return rc;
  1099. }
  1100. /**
  1101. * rivafb_pan_display
  1102. * @var: standard kernel fb changeable data
  1103. * @con: TODO
  1104. * @info: pointer to fb_info object containing info for current riva board
  1105. *
  1106. * DESCRIPTION:
  1107. * Pan (or wrap, depending on the `vmode' field) the display using the
  1108. * `xoffset' and `yoffset' fields of the `var' structure.
  1109. * If the values don't fit, return -EINVAL.
  1110. *
  1111. * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
  1112. */
  1113. static int rivafb_pan_display(struct fb_var_screeninfo *var,
  1114. struct fb_info *info)
  1115. {
  1116. struct riva_par *par = info->par;
  1117. unsigned int base;
  1118. NVTRACE_ENTER();
  1119. base = var->yoffset * info->fix.line_length + var->xoffset;
  1120. par->riva.SetStartAddress(&par->riva, base);
  1121. NVTRACE_LEAVE();
  1122. return 0;
  1123. }
  1124. static int rivafb_blank(int blank, struct fb_info *info)
  1125. {
  1126. struct riva_par *par= info->par;
  1127. unsigned char tmp, vesa;
  1128. tmp = SEQin(par, 0x01) & ~0x20; /* screen on/off */
  1129. vesa = CRTCin(par, 0x1a) & ~0xc0; /* sync on/off */
  1130. NVTRACE_ENTER();
  1131. if (blank)
  1132. tmp |= 0x20;
  1133. switch (blank) {
  1134. case FB_BLANK_UNBLANK:
  1135. case FB_BLANK_NORMAL:
  1136. break;
  1137. case FB_BLANK_VSYNC_SUSPEND:
  1138. vesa |= 0x80;
  1139. break;
  1140. case FB_BLANK_HSYNC_SUSPEND:
  1141. vesa |= 0x40;
  1142. break;
  1143. case FB_BLANK_POWERDOWN:
  1144. vesa |= 0xc0;
  1145. break;
  1146. }
  1147. SEQout(par, 0x01, tmp);
  1148. CRTCout(par, 0x1a, vesa);
  1149. NVTRACE_LEAVE();
  1150. return 0;
  1151. }
  1152. /**
  1153. * rivafb_setcolreg
  1154. * @regno: register index
  1155. * @red: red component
  1156. * @green: green component
  1157. * @blue: blue component
  1158. * @transp: transparency
  1159. * @info: pointer to fb_info object containing info for current riva board
  1160. *
  1161. * DESCRIPTION:
  1162. * Set a single color register. The values supplied have a 16 bit
  1163. * magnitude.
  1164. *
  1165. * RETURNS:
  1166. * Return != 0 for invalid regno.
  1167. *
  1168. * CALLED FROM:
  1169. * fbcmap.c:fb_set_cmap()
  1170. */
  1171. static int rivafb_setcolreg(unsigned regno, unsigned red, unsigned green,
  1172. unsigned blue, unsigned transp,
  1173. struct fb_info *info)
  1174. {
  1175. struct riva_par *par = info->par;
  1176. RIVA_HW_INST *chip = &par->riva;
  1177. int i;
  1178. if (regno >= riva_get_cmap_len(&info->var))
  1179. return -EINVAL;
  1180. if (info->var.grayscale) {
  1181. /* gray = 0.30*R + 0.59*G + 0.11*B */
  1182. red = green = blue =
  1183. (red * 77 + green * 151 + blue * 28) >> 8;
  1184. }
  1185. if (regno < 16 && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
  1186. ((u32 *) info->pseudo_palette)[regno] =
  1187. (regno << info->var.red.offset) |
  1188. (regno << info->var.green.offset) |
  1189. (regno << info->var.blue.offset);
  1190. /*
  1191. * The Riva128 2D engine requires color information in
  1192. * TrueColor format even if framebuffer is in DirectColor
  1193. */
  1194. if (par->riva.Architecture == NV_ARCH_03) {
  1195. switch (info->var.bits_per_pixel) {
  1196. case 16:
  1197. par->palette[regno] = ((red & 0xf800) >> 1) |
  1198. ((green & 0xf800) >> 6) |
  1199. ((blue & 0xf800) >> 11);
  1200. break;
  1201. case 32:
  1202. par->palette[regno] = ((red & 0xff00) << 8) |
  1203. ((green & 0xff00)) |
  1204. ((blue & 0xff00) >> 8);
  1205. break;
  1206. }
  1207. }
  1208. }
  1209. switch (info->var.bits_per_pixel) {
  1210. case 8:
  1211. /* "transparent" stuff is completely ignored. */
  1212. riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8);
  1213. break;
  1214. case 16:
  1215. if (info->var.green.length == 5) {
  1216. for (i = 0; i < 8; i++) {
  1217. riva_wclut(chip, regno*8+i, red >> 8,
  1218. green >> 8, blue >> 8);
  1219. }
  1220. } else {
  1221. u8 r, g, b;
  1222. if (regno < 32) {
  1223. for (i = 0; i < 8; i++) {
  1224. riva_wclut(chip, regno*8+i,
  1225. red >> 8, green >> 8,
  1226. blue >> 8);
  1227. }
  1228. }
  1229. riva_rclut(chip, regno*4, &r, &g, &b);
  1230. for (i = 0; i < 4; i++)
  1231. riva_wclut(chip, regno*4+i, r,
  1232. green >> 8, b);
  1233. }
  1234. break;
  1235. case 32:
  1236. riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8);
  1237. break;
  1238. default:
  1239. /* do nothing */
  1240. break;
  1241. }
  1242. return 0;
  1243. }
  1244. /**
  1245. * rivafb_fillrect - hardware accelerated color fill function
  1246. * @info: pointer to fb_info structure
  1247. * @rect: pointer to fb_fillrect structure
  1248. *
  1249. * DESCRIPTION:
  1250. * This function fills up a region of framebuffer memory with a solid
  1251. * color with a choice of two different ROP's, copy or invert.
  1252. *
  1253. * CALLED FROM:
  1254. * framebuffer hook
  1255. */
  1256. static void rivafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  1257. {
  1258. struct riva_par *par = info->par;
  1259. u_int color, rop = 0;
  1260. if ((info->flags & FBINFO_HWACCEL_DISABLED)) {
  1261. cfb_fillrect(info, rect);
  1262. return;
  1263. }
  1264. if (info->var.bits_per_pixel == 8)
  1265. color = rect->color;
  1266. else {
  1267. if (par->riva.Architecture != NV_ARCH_03)
  1268. color = ((u32 *)info->pseudo_palette)[rect->color];
  1269. else
  1270. color = par->palette[rect->color];
  1271. }
  1272. switch (rect->rop) {
  1273. case ROP_XOR:
  1274. rop = 0x66;
  1275. break;
  1276. case ROP_COPY:
  1277. default:
  1278. rop = 0xCC;
  1279. break;
  1280. }
  1281. riva_set_rop_solid(par, rop);
  1282. RIVA_FIFO_FREE(par->riva, Bitmap, 1);
  1283. NV_WR32(&par->riva.Bitmap->Color1A, 0, color);
  1284. RIVA_FIFO_FREE(par->riva, Bitmap, 2);
  1285. NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].TopLeft, 0,
  1286. (rect->dx << 16) | rect->dy);
  1287. mb();
  1288. NV_WR32(&par->riva.Bitmap->UnclippedRectangle[0].WidthHeight, 0,
  1289. (rect->width << 16) | rect->height);
  1290. mb();
  1291. riva_set_rop_solid(par, 0xcc);
  1292. }
  1293. /**
  1294. * rivafb_copyarea - hardware accelerated blit function
  1295. * @info: pointer to fb_info structure
  1296. * @region: pointer to fb_copyarea structure
  1297. *
  1298. * DESCRIPTION:
  1299. * This copies an area of pixels from one location to another
  1300. *
  1301. * CALLED FROM:
  1302. * framebuffer hook
  1303. */
  1304. static void rivafb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
  1305. {
  1306. struct riva_par *par = info->par;
  1307. if ((info->flags & FBINFO_HWACCEL_DISABLED)) {
  1308. cfb_copyarea(info, region);
  1309. return;
  1310. }
  1311. RIVA_FIFO_FREE(par->riva, Blt, 3);
  1312. NV_WR32(&par->riva.Blt->TopLeftSrc, 0,
  1313. (region->sy << 16) | region->sx);
  1314. NV_WR32(&par->riva.Blt->TopLeftDst, 0,
  1315. (region->dy << 16) | region->dx);
  1316. mb();
  1317. NV_WR32(&par->riva.Blt->WidthHeight, 0,
  1318. (region->height << 16) | region->width);
  1319. mb();
  1320. }
  1321. static inline void convert_bgcolor_16(u32 *col)
  1322. {
  1323. *col = ((*col & 0x0000F800) << 8)
  1324. | ((*col & 0x00007E0) << 5)
  1325. | ((*col & 0x0000001F) << 3)
  1326. | 0xFF000000;
  1327. mb();
  1328. }
  1329. /**
  1330. * rivafb_imageblit: hardware accelerated color expand function
  1331. * @info: pointer to fb_info structure
  1332. * @image: pointer to fb_image structure
  1333. *
  1334. * DESCRIPTION:
  1335. * If the source is a monochrome bitmap, the function fills up a a region
  1336. * of framebuffer memory with pixels whose color is determined by the bit
  1337. * setting of the bitmap, 1 - foreground, 0 - background.
  1338. *
  1339. * If the source is not a monochrome bitmap, color expansion is not done.
  1340. * In this case, it is channeled to a software function.
  1341. *
  1342. * CALLED FROM:
  1343. * framebuffer hook
  1344. */
  1345. static void rivafb_imageblit(struct fb_info *info,
  1346. const struct fb_image *image)
  1347. {
  1348. struct riva_par *par = info->par;
  1349. u32 fgx = 0, bgx = 0, width, tmp;
  1350. u8 *cdat = (u8 *) image->data;
  1351. volatile u32 __iomem *d;
  1352. int i, size;
  1353. if ((info->flags & FBINFO_HWACCEL_DISABLED) || image->depth != 1) {
  1354. cfb_imageblit(info, image);
  1355. return;
  1356. }
  1357. switch (info->var.bits_per_pixel) {
  1358. case 8:
  1359. fgx = image->fg_color;
  1360. bgx = image->bg_color;
  1361. break;
  1362. case 16:
  1363. case 32:
  1364. if (par->riva.Architecture != NV_ARCH_03) {
  1365. fgx = ((u32 *)info->pseudo_palette)[image->fg_color];
  1366. bgx = ((u32 *)info->pseudo_palette)[image->bg_color];
  1367. } else {
  1368. fgx = par->palette[image->fg_color];
  1369. bgx = par->palette[image->bg_color];
  1370. }
  1371. if (info->var.green.length == 6)
  1372. convert_bgcolor_16(&bgx);
  1373. break;
  1374. }
  1375. RIVA_FIFO_FREE(par->riva, Bitmap, 7);
  1376. NV_WR32(&par->riva.Bitmap->ClipE.TopLeft, 0,
  1377. (image->dy << 16) | (image->dx & 0xFFFF));
  1378. NV_WR32(&par->riva.Bitmap->ClipE.BottomRight, 0,
  1379. (((image->dy + image->height) << 16) |
  1380. ((image->dx + image->width) & 0xffff)));
  1381. NV_WR32(&par->riva.Bitmap->Color0E, 0, bgx);
  1382. NV_WR32(&par->riva.Bitmap->Color1E, 0, fgx);
  1383. NV_WR32(&par->riva.Bitmap->WidthHeightInE, 0,
  1384. (image->height << 16) | ((image->width + 31) & ~31));
  1385. NV_WR32(&par->riva.Bitmap->WidthHeightOutE, 0,
  1386. (image->height << 16) | ((image->width + 31) & ~31));
  1387. NV_WR32(&par->riva.Bitmap->PointE, 0,
  1388. (image->dy << 16) | (image->dx & 0xFFFF));
  1389. d = &par->riva.Bitmap->MonochromeData01E;
  1390. width = (image->width + 31)/32;
  1391. size = width * image->height;
  1392. while (size >= 16) {
  1393. RIVA_FIFO_FREE(par->riva, Bitmap, 16);
  1394. for (i = 0; i < 16; i++) {
  1395. tmp = *((u32 *)cdat);
  1396. cdat = (u8 *)((u32 *)cdat + 1);
  1397. reverse_order(&tmp);
  1398. NV_WR32(d, i*4, tmp);
  1399. }
  1400. size -= 16;
  1401. }
  1402. if (size) {
  1403. RIVA_FIFO_FREE(par->riva, Bitmap, size);
  1404. for (i = 0; i < size; i++) {
  1405. tmp = *((u32 *) cdat);
  1406. cdat = (u8 *)((u32 *)cdat + 1);
  1407. reverse_order(&tmp);
  1408. NV_WR32(d, i*4, tmp);
  1409. }
  1410. }
  1411. }
  1412. /**
  1413. * rivafb_cursor - hardware cursor function
  1414. * @info: pointer to info structure
  1415. * @cursor: pointer to fbcursor structure
  1416. *
  1417. * DESCRIPTION:
  1418. * A cursor function that supports displaying a cursor image via hardware.
  1419. * Within the kernel, copy and invert rops are supported. If exported
  1420. * to user space, only the copy rop will be supported.
  1421. *
  1422. * CALLED FROM
  1423. * framebuffer hook
  1424. */
  1425. static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
  1426. {
  1427. struct riva_par *par = info->par;
  1428. u8 data[MAX_CURS * MAX_CURS/8];
  1429. int i, set = cursor->set;
  1430. u16 fg, bg;
  1431. if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS)
  1432. return -ENXIO;
  1433. par->riva.ShowHideCursor(&par->riva, 0);
  1434. if (par->cursor_reset) {
  1435. set = FB_CUR_SETALL;
  1436. par->cursor_reset = 0;
  1437. }
  1438. if (set & FB_CUR_SETSIZE)
  1439. memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
  1440. if (set & FB_CUR_SETPOS) {
  1441. u32 xx, yy, temp;
  1442. yy = cursor->image.dy - info->var.yoffset;
  1443. xx = cursor->image.dx - info->var.xoffset;
  1444. temp = xx & 0xFFFF;
  1445. temp |= yy << 16;
  1446. NV_WR32(par->riva.PRAMDAC, 0x0000300, temp);
  1447. }
  1448. if (set & (FB_CUR_SETSHAPE | FB_CUR_SETCMAP | FB_CUR_SETIMAGE)) {
  1449. u32 bg_idx = cursor->image.bg_color;
  1450. u32 fg_idx = cursor->image.fg_color;
  1451. u32 s_pitch = (cursor->image.width+7) >> 3;
  1452. u32 d_pitch = MAX_CURS/8;
  1453. u8 *dat = (u8 *) cursor->image.data;
  1454. u8 *msk = (u8 *) cursor->mask;
  1455. u8 *src;
  1456. src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
  1457. if (src) {
  1458. switch (cursor->rop) {
  1459. case ROP_XOR:
  1460. for (i = 0; i < s_pitch * cursor->image.height; i++)
  1461. src[i] = dat[i] ^ msk[i];
  1462. break;
  1463. case ROP_COPY:
  1464. default:
  1465. for (i = 0; i < s_pitch * cursor->image.height; i++)
  1466. src[i] = dat[i] & msk[i];
  1467. break;
  1468. }
  1469. fb_pad_aligned_buffer(data, d_pitch, src, s_pitch,
  1470. cursor->image.height);
  1471. bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
  1472. ((info->cmap.green[bg_idx] & 0xf8) << 2) |
  1473. ((info->cmap.blue[bg_idx] & 0xf8) >> 3) |
  1474. 1 << 15;
  1475. fg = ((info->cmap.red[fg_idx] & 0xf8) << 7) |
  1476. ((info->cmap.green[fg_idx] & 0xf8) << 2) |
  1477. ((info->cmap.blue[fg_idx] & 0xf8) >> 3) |
  1478. 1 << 15;
  1479. par->riva.LockUnlock(&par->riva, 0);
  1480. rivafb_load_cursor_image(par, data, bg, fg,
  1481. cursor->image.width,
  1482. cursor->image.height);
  1483. kfree(src);
  1484. }
  1485. }
  1486. if (cursor->enable)
  1487. par->riva.ShowHideCursor(&par->riva, 1);
  1488. return 0;
  1489. }
  1490. static int rivafb_sync(struct fb_info *info)
  1491. {
  1492. struct riva_par *par = info->par;
  1493. wait_for_idle(par);
  1494. return 0;
  1495. }
  1496. /* ------------------------------------------------------------------------- *
  1497. *
  1498. * initialization helper functions
  1499. *
  1500. * ------------------------------------------------------------------------- */
  1501. /* kernel interface */
  1502. static struct fb_ops riva_fb_ops = {
  1503. .owner = THIS_MODULE,
  1504. .fb_open = rivafb_open,
  1505. .fb_release = rivafb_release,
  1506. .fb_check_var = rivafb_check_var,
  1507. .fb_set_par = rivafb_set_par,
  1508. .fb_setcolreg = rivafb_setcolreg,
  1509. .fb_pan_display = rivafb_pan_display,
  1510. .fb_blank = rivafb_blank,
  1511. .fb_fillrect = rivafb_fillrect,
  1512. .fb_copyarea = rivafb_copyarea,
  1513. .fb_imageblit = rivafb_imageblit,
  1514. .fb_cursor = rivafb_cursor,
  1515. .fb_sync = rivafb_sync,
  1516. };
  1517. static int __devinit riva_set_fbinfo(struct fb_info *info)
  1518. {
  1519. unsigned int cmap_len;
  1520. struct riva_par *par = info->par;
  1521. NVTRACE_ENTER();
  1522. info->flags = FBINFO_DEFAULT
  1523. | FBINFO_HWACCEL_XPAN
  1524. | FBINFO_HWACCEL_YPAN
  1525. | FBINFO_HWACCEL_COPYAREA
  1526. | FBINFO_HWACCEL_FILLRECT
  1527. | FBINFO_HWACCEL_IMAGEBLIT;
  1528. /* Accel seems to not work properly on NV30 yet...*/
  1529. if ((par->riva.Architecture == NV_ARCH_30) || noaccel) {
  1530. printk(KERN_DEBUG PFX "disabling acceleration\n");
  1531. info->flags |= FBINFO_HWACCEL_DISABLED;
  1532. }
  1533. info->var = rivafb_default_var;
  1534. info->fix.visual = (info->var.bits_per_pixel == 8) ?
  1535. FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
  1536. info->pseudo_palette = par->pseudo_palette;
  1537. cmap_len = riva_get_cmap_len(&info->var);
  1538. fb_alloc_cmap(&info->cmap, cmap_len, 0);
  1539. info->pixmap.size = 8 * 1024;
  1540. info->pixmap.buf_align = 4;
  1541. info->pixmap.access_align = 32;
  1542. info->pixmap.flags = FB_PIXMAP_SYSTEM;
  1543. info->var.yres_virtual = -1;
  1544. NVTRACE_LEAVE();
  1545. return (rivafb_check_var(&info->var, info));
  1546. }
  1547. #ifdef CONFIG_PPC_OF
  1548. static int __devinit riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd)
  1549. {
  1550. struct riva_par *par = info->par;
  1551. struct device_node *dp;
  1552. const unsigned char *pedid = NULL;
  1553. const unsigned char *disptype = NULL;
  1554. static char *propnames[] = {
  1555. "DFP,EDID", "LCD,EDID", "EDID", "EDID1", "EDID,B", "EDID,A", NULL };
  1556. int i;
  1557. NVTRACE_ENTER();
  1558. dp = pci_device_to_OF_node(pd);
  1559. for (; dp != NULL; dp = dp->child) {
  1560. disptype = of_get_property(dp, "display-type", NULL);
  1561. if (disptype == NULL)
  1562. continue;
  1563. if (strncmp(disptype, "LCD", 3) != 0)
  1564. continue;
  1565. for (i = 0; propnames[i] != NULL; ++i) {
  1566. pedid = of_get_property(dp, propnames[i], NULL);
  1567. if (pedid != NULL) {
  1568. par->EDID = (unsigned char *)pedid;
  1569. NVTRACE("LCD found.\n");
  1570. return 1;
  1571. }
  1572. }
  1573. }
  1574. NVTRACE_LEAVE();
  1575. return 0;
  1576. }
  1577. #endif /* CONFIG_PPC_OF */
  1578. #if defined(CONFIG_FB_RIVA_I2C) && !defined(CONFIG_PPC_OF)
  1579. static int __devinit riva_get_EDID_i2c(struct fb_info *info)
  1580. {
  1581. struct riva_par *par = info->par;
  1582. struct fb_var_screeninfo var;
  1583. int i;
  1584. NVTRACE_ENTER();
  1585. riva_create_i2c_busses(par);
  1586. for (i = 0; i < 3; i++) {
  1587. if (!par->chan[i].par)
  1588. continue;
  1589. riva_probe_i2c_connector(par, i, &par->EDID);
  1590. if (par->EDID && !fb_parse_edid(par->EDID, &var)) {
  1591. printk(PFX "Found EDID Block from BUS %i\n", i);
  1592. break;
  1593. }
  1594. }
  1595. NVTRACE_LEAVE();
  1596. return (par->EDID) ? 1 : 0;
  1597. }
  1598. #endif /* CONFIG_FB_RIVA_I2C */
  1599. static void __devinit riva_update_default_var(struct fb_var_screeninfo *var,
  1600. struct fb_info *info)
  1601. {
  1602. struct fb_monspecs *specs = &info->monspecs;
  1603. struct fb_videomode modedb;
  1604. NVTRACE_ENTER();
  1605. /* respect mode options */
  1606. if (mode_option) {
  1607. fb_find_mode(var, info, mode_option,
  1608. specs->modedb, specs->modedb_len,
  1609. NULL, 8);
  1610. } else if (specs->modedb != NULL) {
  1611. /* get preferred timing */
  1612. if (info->monspecs.misc & FB_MISC_1ST_DETAIL) {
  1613. int i;
  1614. for (i = 0; i < specs->modedb_len; i++) {
  1615. if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
  1616. modedb = specs->modedb[i];
  1617. break;
  1618. }
  1619. }
  1620. } else {
  1621. /* otherwise, get first mode in database */
  1622. modedb = specs->modedb[0];
  1623. }
  1624. var->bits_per_pixel = 8;
  1625. riva_update_var(var, &modedb);
  1626. }
  1627. NVTRACE_LEAVE();
  1628. }
  1629. static void __devinit riva_get_EDID(struct fb_info *info, struct pci_dev *pdev)
  1630. {
  1631. NVTRACE_ENTER();
  1632. #ifdef CONFIG_PPC_OF
  1633. if (!riva_get_EDID_OF(info, pdev))
  1634. printk(PFX "could not retrieve EDID from OF\n");
  1635. #elif defined(CONFIG_FB_RIVA_I2C)
  1636. if (!riva_get_EDID_i2c(info))
  1637. printk(PFX "could not retrieve EDID from DDC/I2C\n");
  1638. #endif
  1639. NVTRACE_LEAVE();
  1640. }
  1641. static void __devinit riva_get_edidinfo(struct fb_info *info)
  1642. {
  1643. struct fb_var_screeninfo *var = &rivafb_default_var;
  1644. struct riva_par *par = info->par;
  1645. fb_edid_to_monspecs(par->EDID, &info->monspecs);
  1646. fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len,
  1647. &info->modelist);
  1648. riva_update_default_var(var, info);
  1649. /* if user specified flatpanel, we respect that */
  1650. if (info->monspecs.input & FB_DISP_DDI)
  1651. par->FlatPanel = 1;
  1652. }
  1653. /* ------------------------------------------------------------------------- *
  1654. *
  1655. * PCI bus
  1656. *
  1657. * ------------------------------------------------------------------------- */
  1658. static u32 __devinit riva_get_arch(struct pci_dev *pd)
  1659. {
  1660. u32 arch = 0;
  1661. switch (pd->device & 0x0ff0) {
  1662. case 0x0100: /* GeForce 256 */
  1663. case 0x0110: /* GeForce2 MX */
  1664. case 0x0150: /* GeForce2 */
  1665. case 0x0170: /* GeForce4 MX */
  1666. case 0x0180: /* GeForce4 MX (8x AGP) */
  1667. case 0x01A0: /* nForce */
  1668. case 0x01F0: /* nForce2 */
  1669. arch = NV_ARCH_10;
  1670. break;
  1671. case 0x0200: /* GeForce3 */
  1672. case 0x0250: /* GeForce4 Ti */
  1673. case 0x0280: /* GeForce4 Ti (8x AGP) */
  1674. arch = NV_ARCH_20;
  1675. break;
  1676. case 0x0300: /* GeForceFX 5800 */
  1677. case 0x0310: /* GeForceFX 5600 */
  1678. case 0x0320: /* GeForceFX 5200 */
  1679. case 0x0330: /* GeForceFX 5900 */
  1680. case 0x0340: /* GeForceFX 5700 */
  1681. arch = NV_ARCH_30;
  1682. break;
  1683. case 0x0020: /* TNT, TNT2 */
  1684. arch = NV_ARCH_04;
  1685. break;
  1686. case 0x0010: /* Riva128 */
  1687. arch = NV_ARCH_03;
  1688. break;
  1689. default: /* unknown architecture */
  1690. break;
  1691. }
  1692. return arch;
  1693. }
  1694. static int __devinit rivafb_probe(struct pci_dev *pd,
  1695. const struct pci_device_id *ent)
  1696. {
  1697. struct riva_par *default_par;
  1698. struct fb_info *info;
  1699. int ret;
  1700. NVTRACE_ENTER();
  1701. assert(pd != NULL);
  1702. info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
  1703. if (!info) {
  1704. printk (KERN_ERR PFX "could not allocate memory\n");
  1705. ret = -ENOMEM;
  1706. goto err_ret;
  1707. }
  1708. default_par = info->par;
  1709. default_par->pdev = pd;
  1710. info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL);
  1711. if (info->pixmap.addr == NULL) {
  1712. ret = -ENOMEM;
  1713. goto err_framebuffer_release;
  1714. }
  1715. ret = pci_enable_device(pd);
  1716. if (ret < 0) {
  1717. printk(KERN_ERR PFX "cannot enable PCI device\n");
  1718. goto err_free_pixmap;
  1719. }
  1720. ret = pci_request_regions(pd, "rivafb");
  1721. if (ret < 0) {
  1722. printk(KERN_ERR PFX "cannot request PCI regions\n");
  1723. goto err_disable_device;
  1724. }
  1725. mutex_init(&default_par->open_lock);
  1726. default_par->riva.Architecture = riva_get_arch(pd);
  1727. default_par->Chipset = (pd->vendor << 16) | pd->device;
  1728. printk(KERN_INFO PFX "nVidia device/chipset %X\n",default_par->Chipset);
  1729. if(default_par->riva.Architecture == 0) {
  1730. printk(KERN_ERR PFX "unknown NV_ARCH\n");
  1731. ret=-ENODEV;
  1732. goto err_release_region;
  1733. }
  1734. if(default_par->riva.Architecture == NV_ARCH_10 ||
  1735. default_par->riva.Architecture == NV_ARCH_20 ||
  1736. default_par->riva.Architecture == NV_ARCH_30) {
  1737. sprintf(rivafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
  1738. } else {
  1739. sprintf(rivafb_fix.id, "NV%x", default_par->riva.Architecture);
  1740. }
  1741. default_par->FlatPanel = flatpanel;
  1742. if (flatpanel == 1)
  1743. printk(KERN_INFO PFX "flatpanel support enabled\n");
  1744. default_par->forceCRTC = forceCRTC;
  1745. rivafb_fix.mmio_len = pci_resource_len(pd, 0);
  1746. rivafb_fix.smem_len = pci_resource_len(pd, 1);
  1747. {
  1748. /* enable IO and mem if not already done */
  1749. unsigned short cmd;
  1750. pci_read_config_word(pd, PCI_COMMAND, &cmd);
  1751. cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
  1752. pci_write_config_word(pd, PCI_COMMAND, cmd);
  1753. }
  1754. rivafb_fix.mmio_start = pci_resource_start(pd, 0);
  1755. rivafb_fix.smem_start = pci_resource_start(pd, 1);
  1756. default_par->ctrl_base = ioremap(rivafb_fix.mmio_start,
  1757. rivafb_fix.mmio_len);
  1758. if (!default_par->ctrl_base) {
  1759. printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
  1760. ret = -EIO;
  1761. goto err_release_region;
  1762. }
  1763. switch (default_par->riva.Architecture) {
  1764. case NV_ARCH_03:
  1765. /* Riva128's PRAMIN is in the "framebuffer" space
  1766. * Since these cards were never made with more than 8 megabytes
  1767. * we can safely allocate this separately.
  1768. */
  1769. default_par->riva.PRAMIN = ioremap(rivafb_fix.smem_start + 0x00C00000, 0x00008000);
  1770. if (!default_par->riva.PRAMIN) {
  1771. printk(KERN_ERR PFX "cannot ioremap PRAMIN region\n");
  1772. ret = -EIO;
  1773. goto err_iounmap_ctrl_base;
  1774. }
  1775. break;
  1776. case NV_ARCH_04:
  1777. case NV_ARCH_10:
  1778. case NV_ARCH_20:
  1779. case NV_ARCH_30:
  1780. default_par->riva.PCRTC0 =
  1781. (u32 __iomem *)(default_par->ctrl_base + 0x00600000);
  1782. default_par->riva.PRAMIN =
  1783. (u32 __iomem *)(default_par->ctrl_base + 0x00710000);
  1784. break;
  1785. }
  1786. riva_common_setup(default_par);
  1787. if (default_par->riva.Architecture == NV_ARCH_03) {
  1788. default_par->riva.PCRTC = default_par->riva.PCRTC0
  1789. = default_par->riva.PGRAPH;
  1790. }
  1791. rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024;
  1792. default_par->dclk_max = riva_get_maxdclk(default_par) * 1000;
  1793. info->screen_base = ioremap(rivafb_fix.smem_start,
  1794. rivafb_fix.smem_len);
  1795. if (!info->screen_base) {
  1796. printk(KERN_ERR PFX "cannot ioremap FB base\n");
  1797. ret = -EIO;
  1798. goto err_iounmap_pramin;
  1799. }
  1800. #ifdef CONFIG_MTRR
  1801. if (!nomtrr) {
  1802. default_par->mtrr.vram = mtrr_add(rivafb_fix.smem_start,
  1803. rivafb_fix.smem_len,
  1804. MTRR_TYPE_WRCOMB, 1);
  1805. if (default_par->mtrr.vram < 0) {
  1806. printk(KERN_ERR PFX "unable to setup MTRR\n");
  1807. } else {
  1808. default_par->mtrr.vram_valid = 1;
  1809. /* let there be speed */
  1810. printk(KERN_INFO PFX "RIVA MTRR set to ON\n");
  1811. }
  1812. }
  1813. #endif /* CONFIG_MTRR */
  1814. info->fbops = &riva_fb_ops;
  1815. info->fix = rivafb_fix;
  1816. riva_get_EDID(info, pd);
  1817. riva_get_edidinfo(info);
  1818. ret=riva_set_fbinfo(info);
  1819. if (ret < 0) {
  1820. printk(KERN_ERR PFX "error setting initial video mode\n");
  1821. goto err_iounmap_screen_base;
  1822. }
  1823. fb_destroy_modedb(info->monspecs.modedb);
  1824. info->monspecs.modedb = NULL;
  1825. pci_set_drvdata(pd, info);
  1826. if (backlight)
  1827. riva_bl_init(info->par);
  1828. ret = register_framebuffer(info);
  1829. if (ret < 0) {
  1830. printk(KERN_ERR PFX
  1831. "error registering riva framebuffer\n");
  1832. goto err_iounmap_screen_base;
  1833. }
  1834. printk(KERN_INFO PFX
  1835. "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n",
  1836. info->fix.id,
  1837. RIVAFB_VERSION,
  1838. info->fix.smem_len / (1024 * 1024),
  1839. info->fix.smem_start);
  1840. NVTRACE_LEAVE();
  1841. return 0;
  1842. err_iounmap_screen_base:
  1843. #ifdef CONFIG_FB_RIVA_I2C
  1844. riva_delete_i2c_busses(info->par);
  1845. #endif
  1846. iounmap(info->screen_base);
  1847. err_iounmap_pramin:
  1848. if (default_par->riva.Architecture == NV_ARCH_03)
  1849. iounmap(default_par->riva.PRAMIN);
  1850. err_iounmap_ctrl_base:
  1851. iounmap(default_par->ctrl_base);
  1852. err_release_region:
  1853. pci_release_regions(pd);
  1854. err_disable_device:
  1855. err_free_pixmap:
  1856. kfree(info->pixmap.addr);
  1857. err_framebuffer_release:
  1858. framebuffer_release(info);
  1859. err_ret:
  1860. return ret;
  1861. }
  1862. static void __devexit rivafb_remove(struct pci_dev *pd)
  1863. {
  1864. struct fb_info *info = pci_get_drvdata(pd);
  1865. struct riva_par *par = info->par;
  1866. NVTRACE_ENTER();
  1867. #ifdef CONFIG_FB_RIVA_I2C
  1868. riva_delete_i2c_busses(par);
  1869. kfree(par->EDID);
  1870. #endif
  1871. unregister_framebuffer(info);
  1872. riva_bl_exit(info);
  1873. #ifdef CONFIG_MTRR
  1874. if (par->mtrr.vram_valid)
  1875. mtrr_del(par->mtrr.vram, info->fix.smem_start,
  1876. info->fix.smem_len);
  1877. #endif /* CONFIG_MTRR */
  1878. iounmap(par->ctrl_base);
  1879. iounmap(info->screen_base);
  1880. if (par->riva.Architecture == NV_ARCH_03)
  1881. iounmap(par->riva.PRAMIN);
  1882. pci_release_regions(pd);
  1883. kfree(info->pixmap.addr);
  1884. framebuffer_release(info);
  1885. pci_set_drvdata(pd, NULL);
  1886. NVTRACE_LEAVE();
  1887. }
  1888. /* ------------------------------------------------------------------------- *
  1889. *
  1890. * initialization
  1891. *
  1892. * ------------------------------------------------------------------------- */
  1893. #ifndef MODULE
  1894. static int __devinit rivafb_setup(char *options)
  1895. {
  1896. char *this_opt;
  1897. NVTRACE_ENTER();
  1898. if (!options || !*options)
  1899. return 0;
  1900. while ((this_opt = strsep(&options, ",")) != NULL) {
  1901. if (!strncmp(this_opt, "forceCRTC", 9)) {
  1902. char *p;
  1903. p = this_opt + 9;
  1904. if (!*p || !*(++p)) continue;
  1905. forceCRTC = *p - '0';
  1906. if (forceCRTC < 0 || forceCRTC > 1)
  1907. forceCRTC = -1;
  1908. } else if (!strncmp(this_opt, "flatpanel", 9)) {
  1909. flatpanel = 1;
  1910. } else if (!strncmp(this_opt, "backlight:", 10)) {
  1911. backlight = simple_strtoul(this_opt+10, NULL, 0);
  1912. #ifdef CONFIG_MTRR
  1913. } else if (!strncmp(this_opt, "nomtrr", 6)) {
  1914. nomtrr = 1;
  1915. #endif
  1916. } else if (!strncmp(this_opt, "strictmode", 10)) {
  1917. strictmode = 1;
  1918. } else if (!strncmp(this_opt, "noaccel", 7)) {
  1919. noaccel = 1;
  1920. } else
  1921. mode_option = this_opt;
  1922. }
  1923. NVTRACE_LEAVE();
  1924. return 0;
  1925. }
  1926. #endif /* !MODULE */
  1927. static struct pci_driver rivafb_driver = {
  1928. .name = "rivafb",
  1929. .id_table = rivafb_pci_tbl,
  1930. .probe = rivafb_probe,
  1931. .remove = __devexit_p(rivafb_remove),
  1932. };
  1933. /* ------------------------------------------------------------------------- *
  1934. *
  1935. * modularization
  1936. *
  1937. * ------------------------------------------------------------------------- */
  1938. static int __devinit rivafb_init(void)
  1939. {
  1940. #ifndef MODULE
  1941. char *option = NULL;
  1942. if (fb_get_options("rivafb", &option))
  1943. return -ENODEV;
  1944. rivafb_setup(option);
  1945. #endif
  1946. return pci_register_driver(&rivafb_driver);
  1947. }
  1948. module_init(rivafb_init);
  1949. static void __exit rivafb_exit(void)
  1950. {
  1951. pci_unregister_driver(&rivafb_driver);
  1952. }
  1953. module_exit(rivafb_exit);
  1954. module_param(noaccel, bool, 0);
  1955. MODULE_PARM_DESC(noaccel, "bool: disable acceleration");
  1956. module_param(flatpanel, int, 0);
  1957. MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)");
  1958. module_param(forceCRTC, int, 0);
  1959. MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)");
  1960. #ifdef CONFIG_MTRR
  1961. module_param(nomtrr, bool, 0);
  1962. MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
  1963. #endif
  1964. module_param(strictmode, bool, 0);
  1965. MODULE_PARM_DESC(strictmode, "Only use video modes from EDID");
  1966. MODULE_AUTHOR("Ani Joshi, maintainer");
  1967. MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2, and the GeForce series");
  1968. MODULE_LICENSE("GPL");