fbdev.c 58 KB

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