fbdev.c 58 KB

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