fbdev.c 58 KB

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