fbdev.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238
  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 < par->bus; i++) {
  1590. riva_probe_i2c_connector(par, i+1, &par->EDID);
  1591. if (par->EDID && !fb_parse_edid(par->EDID, &var)) {
  1592. printk(PFX "Found EDID Block from BUS %i\n", i);
  1593. break;
  1594. }
  1595. }
  1596. NVTRACE_LEAVE();
  1597. return (par->EDID) ? 1 : 0;
  1598. }
  1599. #endif /* CONFIG_FB_RIVA_I2C */
  1600. static void __devinit riva_update_default_var(struct fb_var_screeninfo *var,
  1601. struct fb_info *info)
  1602. {
  1603. struct fb_monspecs *specs = &info->monspecs;
  1604. struct fb_videomode modedb;
  1605. NVTRACE_ENTER();
  1606. /* respect mode options */
  1607. if (mode_option) {
  1608. fb_find_mode(var, info, mode_option,
  1609. specs->modedb, specs->modedb_len,
  1610. NULL, 8);
  1611. } else if (specs->modedb != NULL) {
  1612. /* get preferred timing */
  1613. if (info->monspecs.misc & FB_MISC_1ST_DETAIL) {
  1614. int i;
  1615. for (i = 0; i < specs->modedb_len; i++) {
  1616. if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
  1617. modedb = specs->modedb[i];
  1618. break;
  1619. }
  1620. }
  1621. } else {
  1622. /* otherwise, get first mode in database */
  1623. modedb = specs->modedb[0];
  1624. }
  1625. var->bits_per_pixel = 8;
  1626. riva_update_var(var, &modedb);
  1627. }
  1628. NVTRACE_LEAVE();
  1629. }
  1630. static void __devinit riva_get_EDID(struct fb_info *info, struct pci_dev *pdev)
  1631. {
  1632. NVTRACE_ENTER();
  1633. #ifdef CONFIG_PPC_OF
  1634. if (!riva_get_EDID_OF(info, pdev))
  1635. printk(PFX "could not retrieve EDID from OF\n");
  1636. #elif defined(CONFIG_FB_RIVA_I2C)
  1637. if (!riva_get_EDID_i2c(info))
  1638. printk(PFX "could not retrieve EDID from DDC/I2C\n");
  1639. #endif
  1640. NVTRACE_LEAVE();
  1641. }
  1642. static void __devinit riva_get_edidinfo(struct fb_info *info)
  1643. {
  1644. struct fb_var_screeninfo *var = &rivafb_default_var;
  1645. struct riva_par *par = info->par;
  1646. fb_edid_to_monspecs(par->EDID, &info->monspecs);
  1647. fb_videomode_to_modelist(info->monspecs.modedb, info->monspecs.modedb_len,
  1648. &info->modelist);
  1649. riva_update_default_var(var, info);
  1650. /* if user specified flatpanel, we respect that */
  1651. if (info->monspecs.input & FB_DISP_DDI)
  1652. par->FlatPanel = 1;
  1653. }
  1654. /* ------------------------------------------------------------------------- *
  1655. *
  1656. * PCI bus
  1657. *
  1658. * ------------------------------------------------------------------------- */
  1659. static u32 __devinit riva_get_arch(struct pci_dev *pd)
  1660. {
  1661. u32 arch = 0;
  1662. switch (pd->device & 0x0ff0) {
  1663. case 0x0100: /* GeForce 256 */
  1664. case 0x0110: /* GeForce2 MX */
  1665. case 0x0150: /* GeForce2 */
  1666. case 0x0170: /* GeForce4 MX */
  1667. case 0x0180: /* GeForce4 MX (8x AGP) */
  1668. case 0x01A0: /* nForce */
  1669. case 0x01F0: /* nForce2 */
  1670. arch = NV_ARCH_10;
  1671. break;
  1672. case 0x0200: /* GeForce3 */
  1673. case 0x0250: /* GeForce4 Ti */
  1674. case 0x0280: /* GeForce4 Ti (8x AGP) */
  1675. arch = NV_ARCH_20;
  1676. break;
  1677. case 0x0300: /* GeForceFX 5800 */
  1678. case 0x0310: /* GeForceFX 5600 */
  1679. case 0x0320: /* GeForceFX 5200 */
  1680. case 0x0330: /* GeForceFX 5900 */
  1681. case 0x0340: /* GeForceFX 5700 */
  1682. arch = NV_ARCH_30;
  1683. break;
  1684. case 0x0020: /* TNT, TNT2 */
  1685. arch = NV_ARCH_04;
  1686. break;
  1687. case 0x0010: /* Riva128 */
  1688. arch = NV_ARCH_03;
  1689. break;
  1690. default: /* unknown architecture */
  1691. break;
  1692. }
  1693. return arch;
  1694. }
  1695. static int __devinit rivafb_probe(struct pci_dev *pd,
  1696. const struct pci_device_id *ent)
  1697. {
  1698. struct riva_par *default_par;
  1699. struct fb_info *info;
  1700. int ret;
  1701. NVTRACE_ENTER();
  1702. assert(pd != NULL);
  1703. info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
  1704. if (!info) {
  1705. printk (KERN_ERR PFX "could not allocate memory\n");
  1706. ret = -ENOMEM;
  1707. goto err_ret;
  1708. }
  1709. default_par = info->par;
  1710. default_par->pdev = pd;
  1711. info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL);
  1712. if (info->pixmap.addr == NULL) {
  1713. ret = -ENOMEM;
  1714. goto err_framebuffer_release;
  1715. }
  1716. ret = pci_enable_device(pd);
  1717. if (ret < 0) {
  1718. printk(KERN_ERR PFX "cannot enable PCI device\n");
  1719. goto err_free_pixmap;
  1720. }
  1721. ret = pci_request_regions(pd, "rivafb");
  1722. if (ret < 0) {
  1723. printk(KERN_ERR PFX "cannot request PCI regions\n");
  1724. goto err_disable_device;
  1725. }
  1726. mutex_init(&default_par->open_lock);
  1727. default_par->riva.Architecture = riva_get_arch(pd);
  1728. default_par->Chipset = (pd->vendor << 16) | pd->device;
  1729. printk(KERN_INFO PFX "nVidia device/chipset %X\n",default_par->Chipset);
  1730. if(default_par->riva.Architecture == 0) {
  1731. printk(KERN_ERR PFX "unknown NV_ARCH\n");
  1732. ret=-ENODEV;
  1733. goto err_release_region;
  1734. }
  1735. if(default_par->riva.Architecture == NV_ARCH_10 ||
  1736. default_par->riva.Architecture == NV_ARCH_20 ||
  1737. default_par->riva.Architecture == NV_ARCH_30) {
  1738. sprintf(rivafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
  1739. } else {
  1740. sprintf(rivafb_fix.id, "NV%x", default_par->riva.Architecture);
  1741. }
  1742. default_par->FlatPanel = flatpanel;
  1743. if (flatpanel == 1)
  1744. printk(KERN_INFO PFX "flatpanel support enabled\n");
  1745. default_par->forceCRTC = forceCRTC;
  1746. rivafb_fix.mmio_len = pci_resource_len(pd, 0);
  1747. rivafb_fix.smem_len = pci_resource_len(pd, 1);
  1748. {
  1749. /* enable IO and mem if not already done */
  1750. unsigned short cmd;
  1751. pci_read_config_word(pd, PCI_COMMAND, &cmd);
  1752. cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
  1753. pci_write_config_word(pd, PCI_COMMAND, cmd);
  1754. }
  1755. rivafb_fix.mmio_start = pci_resource_start(pd, 0);
  1756. rivafb_fix.smem_start = pci_resource_start(pd, 1);
  1757. default_par->ctrl_base = ioremap(rivafb_fix.mmio_start,
  1758. rivafb_fix.mmio_len);
  1759. if (!default_par->ctrl_base) {
  1760. printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
  1761. ret = -EIO;
  1762. goto err_release_region;
  1763. }
  1764. switch (default_par->riva.Architecture) {
  1765. case NV_ARCH_03:
  1766. /* Riva128's PRAMIN is in the "framebuffer" space
  1767. * Since these cards were never made with more than 8 megabytes
  1768. * we can safely allocate this separately.
  1769. */
  1770. default_par->riva.PRAMIN = ioremap(rivafb_fix.smem_start + 0x00C00000, 0x00008000);
  1771. if (!default_par->riva.PRAMIN) {
  1772. printk(KERN_ERR PFX "cannot ioremap PRAMIN region\n");
  1773. ret = -EIO;
  1774. goto err_iounmap_ctrl_base;
  1775. }
  1776. break;
  1777. case NV_ARCH_04:
  1778. case NV_ARCH_10:
  1779. case NV_ARCH_20:
  1780. case NV_ARCH_30:
  1781. default_par->riva.PCRTC0 =
  1782. (u32 __iomem *)(default_par->ctrl_base + 0x00600000);
  1783. default_par->riva.PRAMIN =
  1784. (u32 __iomem *)(default_par->ctrl_base + 0x00710000);
  1785. break;
  1786. }
  1787. riva_common_setup(default_par);
  1788. if (default_par->riva.Architecture == NV_ARCH_03) {
  1789. default_par->riva.PCRTC = default_par->riva.PCRTC0
  1790. = default_par->riva.PGRAPH;
  1791. }
  1792. rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024;
  1793. default_par->dclk_max = riva_get_maxdclk(default_par) * 1000;
  1794. info->screen_base = ioremap(rivafb_fix.smem_start,
  1795. rivafb_fix.smem_len);
  1796. if (!info->screen_base) {
  1797. printk(KERN_ERR PFX "cannot ioremap FB base\n");
  1798. ret = -EIO;
  1799. goto err_iounmap_pramin;
  1800. }
  1801. #ifdef CONFIG_MTRR
  1802. if (!nomtrr) {
  1803. default_par->mtrr.vram = mtrr_add(rivafb_fix.smem_start,
  1804. rivafb_fix.smem_len,
  1805. MTRR_TYPE_WRCOMB, 1);
  1806. if (default_par->mtrr.vram < 0) {
  1807. printk(KERN_ERR PFX "unable to setup MTRR\n");
  1808. } else {
  1809. default_par->mtrr.vram_valid = 1;
  1810. /* let there be speed */
  1811. printk(KERN_INFO PFX "RIVA MTRR set to ON\n");
  1812. }
  1813. }
  1814. #endif /* CONFIG_MTRR */
  1815. info->fbops = &riva_fb_ops;
  1816. info->fix = rivafb_fix;
  1817. riva_get_EDID(info, pd);
  1818. riva_get_edidinfo(info);
  1819. ret=riva_set_fbinfo(info);
  1820. if (ret < 0) {
  1821. printk(KERN_ERR PFX "error setting initial video mode\n");
  1822. goto err_iounmap_screen_base;
  1823. }
  1824. fb_destroy_modedb(info->monspecs.modedb);
  1825. info->monspecs.modedb = NULL;
  1826. pci_set_drvdata(pd, info);
  1827. if (backlight)
  1828. riva_bl_init(info->par);
  1829. ret = register_framebuffer(info);
  1830. if (ret < 0) {
  1831. printk(KERN_ERR PFX
  1832. "error registering riva framebuffer\n");
  1833. goto err_iounmap_screen_base;
  1834. }
  1835. printk(KERN_INFO PFX
  1836. "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n",
  1837. info->fix.id,
  1838. RIVAFB_VERSION,
  1839. info->fix.smem_len / (1024 * 1024),
  1840. info->fix.smem_start);
  1841. NVTRACE_LEAVE();
  1842. return 0;
  1843. err_iounmap_screen_base:
  1844. #ifdef CONFIG_FB_RIVA_I2C
  1845. riva_delete_i2c_busses(info->par);
  1846. #endif
  1847. iounmap(info->screen_base);
  1848. err_iounmap_pramin:
  1849. if (default_par->riva.Architecture == NV_ARCH_03)
  1850. iounmap(default_par->riva.PRAMIN);
  1851. err_iounmap_ctrl_base:
  1852. iounmap(default_par->ctrl_base);
  1853. err_release_region:
  1854. pci_release_regions(pd);
  1855. err_disable_device:
  1856. err_free_pixmap:
  1857. kfree(info->pixmap.addr);
  1858. err_framebuffer_release:
  1859. framebuffer_release(info);
  1860. err_ret:
  1861. return ret;
  1862. }
  1863. static void __exit rivafb_remove(struct pci_dev *pd)
  1864. {
  1865. struct fb_info *info = pci_get_drvdata(pd);
  1866. struct riva_par *par = info->par;
  1867. NVTRACE_ENTER();
  1868. #ifdef CONFIG_FB_RIVA_I2C
  1869. riva_delete_i2c_busses(par);
  1870. kfree(par->EDID);
  1871. #endif
  1872. unregister_framebuffer(info);
  1873. riva_bl_exit(info);
  1874. #ifdef CONFIG_MTRR
  1875. if (par->mtrr.vram_valid)
  1876. mtrr_del(par->mtrr.vram, info->fix.smem_start,
  1877. info->fix.smem_len);
  1878. #endif /* CONFIG_MTRR */
  1879. iounmap(par->ctrl_base);
  1880. iounmap(info->screen_base);
  1881. if (par->riva.Architecture == NV_ARCH_03)
  1882. iounmap(par->riva.PRAMIN);
  1883. pci_release_regions(pd);
  1884. kfree(info->pixmap.addr);
  1885. framebuffer_release(info);
  1886. pci_set_drvdata(pd, NULL);
  1887. NVTRACE_LEAVE();
  1888. }
  1889. /* ------------------------------------------------------------------------- *
  1890. *
  1891. * initialization
  1892. *
  1893. * ------------------------------------------------------------------------- */
  1894. #ifndef MODULE
  1895. static int __init rivafb_setup(char *options)
  1896. {
  1897. char *this_opt;
  1898. NVTRACE_ENTER();
  1899. if (!options || !*options)
  1900. return 0;
  1901. while ((this_opt = strsep(&options, ",")) != NULL) {
  1902. if (!strncmp(this_opt, "forceCRTC", 9)) {
  1903. char *p;
  1904. p = this_opt + 9;
  1905. if (!*p || !*(++p)) continue;
  1906. forceCRTC = *p - '0';
  1907. if (forceCRTC < 0 || forceCRTC > 1)
  1908. forceCRTC = -1;
  1909. } else if (!strncmp(this_opt, "flatpanel", 9)) {
  1910. flatpanel = 1;
  1911. } else if (!strncmp(this_opt, "backlight:", 10)) {
  1912. backlight = simple_strtoul(this_opt+10, NULL, 0);
  1913. #ifdef CONFIG_MTRR
  1914. } else if (!strncmp(this_opt, "nomtrr", 6)) {
  1915. nomtrr = 1;
  1916. #endif
  1917. } else if (!strncmp(this_opt, "strictmode", 10)) {
  1918. strictmode = 1;
  1919. } else if (!strncmp(this_opt, "noaccel", 7)) {
  1920. noaccel = 1;
  1921. } else
  1922. mode_option = this_opt;
  1923. }
  1924. NVTRACE_LEAVE();
  1925. return 0;
  1926. }
  1927. #endif /* !MODULE */
  1928. static struct pci_driver rivafb_driver = {
  1929. .name = "rivafb",
  1930. .id_table = rivafb_pci_tbl,
  1931. .probe = rivafb_probe,
  1932. .remove = __exit_p(rivafb_remove),
  1933. };
  1934. /* ------------------------------------------------------------------------- *
  1935. *
  1936. * modularization
  1937. *
  1938. * ------------------------------------------------------------------------- */
  1939. static int __devinit rivafb_init(void)
  1940. {
  1941. #ifndef MODULE
  1942. char *option = NULL;
  1943. if (fb_get_options("rivafb", &option))
  1944. return -ENODEV;
  1945. rivafb_setup(option);
  1946. #endif
  1947. return pci_register_driver(&rivafb_driver);
  1948. }
  1949. module_init(rivafb_init);
  1950. #ifdef MODULE
  1951. static void __exit rivafb_exit(void)
  1952. {
  1953. pci_unregister_driver(&rivafb_driver);
  1954. }
  1955. module_exit(rivafb_exit);
  1956. #endif /* MODULE */
  1957. module_param(noaccel, bool, 0);
  1958. MODULE_PARM_DESC(noaccel, "bool: disable acceleration");
  1959. module_param(flatpanel, int, 0);
  1960. MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)");
  1961. module_param(forceCRTC, int, 0);
  1962. MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)");
  1963. #ifdef CONFIG_MTRR
  1964. module_param(nomtrr, bool, 0);
  1965. MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
  1966. #endif
  1967. module_param(strictmode, bool, 0);
  1968. MODULE_PARM_DESC(strictmode, "Only use video modes from EDID");
  1969. MODULE_AUTHOR("Ani Joshi, maintainer");
  1970. MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2, and the GeForce series");
  1971. MODULE_LICENSE("GPL");