This patch should be applied to an un-modified XFree86 version 4.0.1 source tree. It is the fourth of four patches that will convert the source tree to XFree86 version 4.0.2. To apply the patches, run the following from the directory containing your 'xc' directory: patch -p0 -E < 4.0.1-4.0.2.diff1 patch -p0 -E < 4.0.1-4.0.2.diff2 patch -p0 -E < 4.0.1-4.0.2.diff3 patch -p0 -E < 4.0.1-4.0.2.diff4 gzip -d < 4.0.2.tgz | tar vxf - ------------------------------------------------------------------------------- Index: xc/programs/Xserver/hw/xfree86/CHANGELOG diff -u xc/programs/Xserver/hw/xfree86/CHANGELOG:3.1230 xc/programs/Xserver/hw/xfree86/CHANGELOG:3.1485 --- xc/programs/Xserver/hw/xfree86/CHANGELOG:3.1230 Sat Jul 1 22:35:25 2000 +++ xc/programs/Xserver/hw/xfree86/CHANGELOG Mon Dec 18 10:55:33 2000 @@ -1,3 +1,1312 @@ +XFree86 4.0.2 (18 December 2000) +1211. Fix a problem introduced recently when using the "ps/2" protocol for + mice on FreeBSD (David Dawes). +1210. Disable DRI for tdfx when there's insufficient memory for textures + (Alan Hourihane). +1209. Rename the R6.4 INSTALL and RELNOTES docs at the top level of the source + tree, and add a copy of the XFree86 RELNOTES. +1208. Add Solaris 8/x86 key mappings for some more jp106 keys. +1207. Fix wacom man page to match the driver (based on #4398, Akio Morita). +1206. Install the iso8859-13 encoding file (#4397, Nerijus Baliunas). +1205. Misc doc-related updates. + +XFree86 4.0.1Zc (15 December 2000) +1204. Fix an Xlib memory overrun when the Xutf8TextPropertyToTextList function + is used in a unibyte locale (#4394, Bruno Haible). +1203. Fix the yen/backslash keys for Solaris 8/x86 with Japanese 106 keyboards + (based on #4393, Takaaki Nomura). +1202. Fix type mismatches in the r128 DRI driver on Alpha platforms (#4392, + Gareth Hughes). +1201. Fix build on Japanized version of Solaris 8 for x86 (#4390, + Takaaki Nomura). +1200. Remove some old XtOffset magic for the arm that affects building + with gcc (#4388, Keith Packard). +1199. Release notes updates (David Dawes, Egbert Eich, Mark Vojkovich, + Robin Cutshaw, Keith Packard, Alan Hourihane, #4391, Kevin Brosius). +1198. Revert the tdfx driver to something functionally close to the + last known working version (4.0.1g) (David Dawes). + +XFree86 4.0.1Zb (14 December 2000) +1197. New fonts document (#4386, 4387, Juliusz Chroboczek). +1196. Status doc update for Trident (Alan Hourihane). +1195. Update the R6.4 INSTALL and RELNOTES docs to include references at + the top to the XFree86-specific docs (David Dawes). +1194. Make it possible to install platform-specific man pages with most + ix86 builds (David Dawes). +1193. Add a short man page for the newport driver, update it's sample config + file, and have the driver check user-supplied parameters (#4385, + Guido Guenther). +1192. Missing part of fix for FreeBSD sysmouse support (#4317, from FreeBSD + ports collection). +1191. Trident driver bug fixes (Alan Hourihane). +1190. Make it possible to install hardcopy specs docs that we can't generate + from source (David Dawes). +1189. Set the HasPerl default correctly for LynxOS (#4384, Thomas Mueller). +1188. Lots of Status doc updates (#4383, Branden Robinson). +1187. Update some DebianMaintainer defaults in linux.cf (#4380, + Branden Robinson). +1186. Fix a segfault in the font path verification code in xfs (#4379, + Charles C. Fu). +1185. Rework and document the various MatroxHal imake parameters, and + build in support for the mga_hal module by default for loadable server + builds (David Dawes). +1184. Fix sis driver corrupt display with more than 8MB of video memory (#4378, + Can-Ru Yeou). +1183. Fix xf86cfg build problem on systems that don't come with snprintf + and/or regex (based on #4361, Thomas Mueller). +1182. Fix siliconmotion driver screen restoration when a graphics vesafb mode + is selected during boot up (#4377, Frido Garritsen). +1181. Install and RELNOTES updates for Darwin (#4375, 4376, Torrey T. Lyons). +1180. s3virge patch to get Xft/Xrender working (#4374, Kevin Brosius). +1179. Improve aperture driver related error messages on OpenBSD + (Matthieu Herrb). +1178. Workaround for IA-64 loader bug (Marc La France). +1177. Fix recognition of valid depth/fbbpp combinations in ATI driver + (Marc La France). +1176. Fix 1bpp in ATI driver (Marc La France). +1175. Fix ATI DPMS support on panels by mimicking BIOS behaviour more closely + (Marc La France). + +XFree86 4.0.1Za (12 December 2000) +1174. Set defaults for Mesa's x86 CPU-specific asm options, and make it + possible to build with MMX disabled for systems with older assemblers + (David Dawes). +1173. Fix some R128 DRI bugs: + - Fix depth span functions (was causing rendering errors for windows + not at (0,0)). + - Don't use 32-bit depth buffers since they're not supported by Mesa. + - Use subpixel offsets to fix coordinate rounding errors. + (#4373, Gareth Hughes). +1172. Reinstate the AllTarget for the rule to make html man pages + (David Dawes). +1171. Build all modules on Linux/mips, fixing Xnest build (#4372, + Guido Guenther). +1170. Update Permedia 3 README, Cards file, and glint section in the Status + doc (#4371, Sven Luther). +1169. Fix depth passed to the BIOS in the savage driver (affects depth 15) + (#4369, Ani Joshi). +1168. Update fbdev man page (#4368, Michel Daenzer). +1167. Fix a problem with 32-bit depth buffers when using indirect rendering, + by not advertising them in the mga driver (#4367, Brian Paul). +1166. Update man page version strings, and convert some server/XFree86 man + pages to cpp-processed files to make the references to pages in + system-dependent sections correct (David Dawes). +1165. Update the release notes for the i18n and Unicode support (#4366, + Bruno Haible). +1164. Document most of the environment variables that can influence libX11 + and libXt in the 'X' man page (#4365, Bruno Haible). +1163. Update the ICCCM spec document to relfect the selection targets currently + used in XFree86 (#4364, Bruno Haible). +1162. Update the CTEXT spec document to reflect part of the current + practice in XFree86 (#4363, Bruno Haible). +1161. Augment SpecsDocDirs to reflect additional docs that have XFree86 changes + (#4362, Bruno Haible). +1160. Fix Xv library references in the xvinfo Imakefile (#4361, + Thomas Mueller). +1159. Fix a signed/unsigned error in the calculation of 16-bit displacements + in x86emu (#4359, Tim Roberts). +1158. Fix "noaccel" option in the tdfx driver when building without DRI + (David Dawes). +1157. Add Darwin documentation (Torrey T. Lyons). +1156. Add Darwin bindist files and update Xinstall.sh (Matthieu Herrb). +1155. Update bindist files for NetBSD 1.5 ELF (Matthieu Herrb). +1154. Add DGA support to I128 driver (Robin Cutshaw). + +XFree86 4.0.1Z (8 December 2000) +1153. Flesh out the wacom man page (#4358, Frederic Lepied). +1152. Fix incorrect documentation for xf86UnMapVidMem() in README.OS-lib + (#4357, Guido Guenther). +1151. Update the newport driver to use the map/unmap functions provided by + the os-support layer (#4356, Guido Guenther). +1150. Bugfix to xf86UDelay() (Egbert Eich). +1149. Added a sanity check to pciConvertRange2Host() (Egbert Eich). +1148. Added more log messages to Linux APM code (Egbert Eich). +1147. Added a sanity check to xf86ConfigPciEntity() (Egbert Eich). +1146. Resync with DRI CVS trunk (tdfx driver updates) (Daryll Strauss). +1145. Add -textmode mode option for xf86cfg, to run a ncurses interface, and + add the "expert" interface, to provide more control over the config file. + Updates to vesa driver, removed debug messages and fixed problem with + console restoration in some S3 cards. +1144. Merge tdfx 3D driver code (VA Linux). +1143. Add support PPC support on Rage 128 and disable Int10 for PPC on + Rage 128 (until the bug in PPC Int10 support is fixed) (Kevin Martin). +1142. Install an alternative fonts.alias file that references the UCS-encoded + fonts on systems without Perl (David Dawes). +1141. Add CyberShadow Option back into Trident driver (Alan Hourihane). +1140. Resync with DRI CVS trunk, including: + - SSE support updates + - DRI-specific full screen mode + - Reduce the minimum space required for 3D on the Rage 128 + (VA Linux). +1139. Fix a memory leak in the UTF-8 <--> CompoundText converter (#4354, + Bruno Haible). +1138. Add support for the selection target UTF8_STRING to libXaw (#4353, + Bruno Haible). +1137. Make Xlib's CompoundText converter ISO-2022 compliant (#4352, + Bruno Haible). +1136. Fix 2 wacom driver bugs (core dump on VT switching, and USB support) + (#4350, Frederic Lepied). +1135. Update the ClearlyU fonts to 1.8b. Changes include: + - Cleaned up the Arabic glyphs so they don't look quite so juvenile. + - Squared up the Hebrew glyphs so they match the style of the other + scripts better. + - Added many of the basic Hangul glyphs. + - Brought the Cyrillic block in line with Unicode 3.0 and moved the + extra glyphs into the PUA font in the 0xE4XX range. + (#4349, Mark Leisher). +1134. Update the savage driver to all I/O via MMIO, and add DPMS support + (4347, Ani Joshi). +1133. Change xfs to drop privs after daemonising so that the pid file can + be written (#4346, Frederic Lepied). +1132. Miscellaneous fixups to the trident driver (Alan Hourihane). +1131. Add Xv support to the trident driver. Works for Blade and Image series + chips, but zooming currently doesn't work on Image series. + (Alan Hourihane). +1130. Don't perform a software reset on the Graphics Engine for Trident + Blade3D's and CyberBlade's (Alan Hourihane). +1129. Fix typo in int10 for IA-64's (Marc La France). +1128. Make PCI bridge information in the log more accurate (Marc La France). +1127. Update ATI docs (Marc La France). +1126. Another getValidBIOSBase() fix (Marc La France). +1125. If the loader server dies from a signal during initialisation, print a + list of undefined symbols (Marc La France). +1124. Move Alpha MMIO definitions from xf86_OSproc.h to compiler.h + (Marc La France). +1123. Change update.docs rule for shadow tree friendliness (Marc La France). +1122. Don't reference libc wrapper names directly in the newport driver + (David Dawes). +1121. Fix the fr_CH xkb Macintosh symbols file (#4345, Olaf Hering). +1120. Revert the Estonian_Estonia.1257 change in patch #4297 because + windows-1257 is a closer match to iso8859-13 than iso8859-15. + Also add entries for the et_EE.ISO8859-1 locale (while not perfect for + Estonian, it is commonly used) (#4344, Ville Hallik). +1119. Change name of long Unicode keysyms from 6 to 8 hex digits, which + matches conventional usage better (#4343, Ivan Pascal). +1118. Make XF86VidModeSetViewPort() actually set the viewport to the + X and Y coordinates specified as opposed to always setting it to (0,0) + (#4342, Joe Moss). +1117. Work around some build problems on SVR4.0 (#4341, Satoshi Kimura). +1116. Compose characters for the Macedonian UTF-8 locale (#4338, + Damjan Georgievski). +1115. Fix build problems with the wacom driver on Linux 2.4 when building + a static server (Frederic Lepied, David Dawes). +1114. Changed name of server binary to call by xf86cfg back to "XFree86 + (Egbert Eich). +1113. Modified handling of memory alloctaion in TDFX driver (Egbert Eich). +1112. Attempt to fix the 'UseModes' directive in the Monitor section + (Egbert Eich). +1111. Added debugging output for BIOS base address search (Egbert Eich). +1110. Changed neomagic driver to treat disable stretching for each mode + individually (Egbert Eich). +1109. Removed '-traditional' from cpp rule for makedpend. Required for + new glibc header files (Ruediger Oertel). +1107. Fix to make SuperProbe build again on ia64 (Andreas Schwab). +1107. Attempt to fix int10 (Egbert Eich). +1106. Modified blitter busy test to use the MMIO mapped registers on chips + > CT69000 (Egbert Eich). +1105. Attempt to improve dga support in C&T driver (Egbert Eich). +1104. Moved ppc_flush_icache to compiler.h - hope this fixes build problems + (Egert Eich). +1103. changed cirrus driver to us fb instead of cfb (Egbert Eich). +1102. Modularized HALlib for mga driver (Egbert Eich). +1101. Added DGA support to tseng driver (Rainer Keller). +1100. Added "framebuffer" bus type allowing resource control to take place + outside of the server (Egbert Eich). +1099. Added turkish keyboard layout (Togan Muftuoglu). +1098. Fix Cyber9397/DVD acceleration problem (Alan Hourihane). +1097. Resync with the DRI CVS trunk. +1096. Fix alot of Rage 128 Xv bugs (Mark Vojkovich). +1095. Fix XKB symbols for Swedish Macintosh keyboards (#4337, Olaf Hering). +1094. Disable DRI on PPC (#4337, Olaf Hering). +1093. Suppress xf86ReadBIOS debugging messages for BSD (#4336, Takaaki Nomura). +1092. Silicon Motion driver update, includes bug fixes (#4335, + Frido Garritsen, Silicon Motion, Inc.). +1091. Updates to the dumpkeymap utility and its documentation (#4323, + Eric Sunshine). +1090. Enable 3D support for Rage 128 Mobility chips (Kevin Martin). +1089. Add clip rectangles support to Render extension, Xrender and Xft. + Make Xrender and Xft usable from c++. + Fix a bunch of compiler warnings in Render extension code + (Keith Packard) + +XFree86 4.0.1h (4 December 2000) +1088. Fix key mapping for the '\' key on GB keyboards in Solaris 8. +1087. Status doc updates for Neomagic an NVIDIA (#4334, Andrew C. Aitchison, + Mark Vojkovich). +1086. Updated Rage 128 DRI support from the DRI CVS (Gareth Hughes, VA Linux). +1085. Updates for Hurd support (#A.209, Marcus Brinkmann). +1084. Bump the minor revisions of libXmu (UTF8_STRING) and libX11 + (Xutf8LookupString). +1083. Fixes for all known bugs in the CompoundText parser and generator, + including: + * While adding a charset: + - Adding a charset with two different escape sequences (e.g. + ISO-8859-14) led to broken behaviour of the converter. Moreover + the second added would have priority over the first added. + - If an invalid escape sequence was detected by _XlcParseCharSet, it + was still used when generating compound text. + - Extended segment charsets with varying number of bytes per character + were treated like those with 1 byte per character. + - _XlcAddCT failed to copy its ct_sequence argument, thus leading to + bugs when this argument was a dynamically allocated string. + - Missing detection of different charsets having the same escape + sequence. + * Parsing Compound Text: + - The functions _XlcParseCT and _XlcGetCTInfo did not perform range + checks on the strings being parsed. Danger of core dump through + out-of-bounds string access if a malicious client provides malformed + text. + - Builtin extended segment charsets were not recognized because the + strncmp in _XlcGetCTInfo was returning false most of the time, due + to the embedded length bytes. + - Extended segment charsets in general would not be deactivated after + the specified number of bytes. + - In _XlcCheckCTSequence, extended segments with invalid embedded + length bytes would lead to out-of-bounds string accesses as well. + - Unrecognized escape sequences did not lead to a return value > 0. + - Left-to-right and right-to-left indicators (starting with 0x9b) were + just ignored, without leading to a return value > 0. + - If the source string was larger than the intermediate buffer, + multibyte characters could be split into pieces, leading to + conversion errors. + * Generating Compound Text: + - The length embedded in an extended segment prefix was always wrong. + - Long strings could give rise to extended segments with a length that + doesn't fit in the allowed 14 bits. + - After an extended segment, GL or GR designators would unnecessarily + be repeated. + - Bytes in the range 0x81..0x88, 0x8b..0x9a, 0x9c..0x9f in multibyte + encodings could not be output, would be thrown away. + - Byte 0x9b could not be output in the UTF-8 charset. + * udcInf.c was generating invalid Compound Text (invalid length in + extended segment). + * lcConv.c: If in the indirect converter, the first step led to no + output, the second step would still be called, possibly leading to + out-of-bounds accesses. + * lcUTF8.c: had knowledge about JISX0208.1983-0 but not about + JISX0208.1990-0. + (#4333, Bruno Haible). +1082. Fix documentation for XSetOMValues() (#4332, Bruno Haible). +1081. Fix namespace polution in introduced with patch #4293 + (#4331, Bruno Haible). +1080. Fix a bug in the newly introduced Xutf8LookupString() function that + loses input not representable in the locale encoding (#4330, + Bruno Haible). +1079. Avoid four new gcc warnings about const in lcUTF8.c introduced by + patch #4293 (#4329, Bruno Haible). +1078. Fix some additional cases of confusing local typedef for wchar_t + (#4328, Bruno Haible). +1077. Fix some round-trip conversion errors in COMPOUND_TEXT -> UTF8_STRING -> + COMPOUND_TEXT due to wrong tables introduced by patches #4214, 4215 + (#4327, Pablo Saratxaga). +1076. Cygwin update for building Xrender DLL (#4326, Suhaib M. Siddiqi). +1075. Fix an undefined SUBDIRS in xc/lib/GL/mesa/src/drv/Imakefile when + compiling on something other than x86, alpha or sparc (#4325, + Brian Paul). +1074. Don't have the neomagic driver disable stretching when a mode that + fills the panel is selected (#4324, Andrew C. Aitchison). +1073. Fix a bug in Xlib's _XimLocalMbLookupString() that causes a crash when + a zero keycode keypress event is received (#4322, HIBINO Kei). +1072. NetBSD doesn't have perl in its default install (Matthieu Herrb). +1071. Add Xft support to xditview with #ifdefs (Keith Packard) +1070. Add a MIT-MAGIC-COOKIE-1 generator to startx for NetBSD 1.5 and OpenBSD + and FreeBSD and make mkcookie support more generic (Matthieu Herrb). +1069. Update OpenBSD and NetBSD docs (Matthieu Herrb). +1068. Clean up r128_video.c again (Marc La France). +1067. Fix ATI clock generator recognition when an adapter BIOS cannot be + retrieved (Linus Torvalds). +1066. Fix int10 and ATI driver for video BIOSes larger than 64kB + (Marc La France). +1065. Change xf86MatchDevice() to initialise its return pointer and clean up + drivers accordingly (Marc La France). +1064. Fix for bug in new imConv.c (#4318, Ivan Pascal). +1063. Fix for FreeBSD sysmouse support (#4317, from FreeBSD ports collection). +1062. Enable the ru_SU local entries for FreeBSD (based on patch from FreeBSD + ports collection). +1061. Driver for the S3 Savage family of chips (#4315, 4316, 4319-4321, + Tim Roberts). +1060. Add xkb definitions for the Logitech cordless keyboard (#4314, + Michel Goraczko). +1059. Add support for "unicode keysym" to XKeysymToString() and + XStringToKeysym() (#4313, Ivan Pascal). +1058. SiS driver updates, including: + - Performance tuning for sis630 + - Support XV extension for sis630 + - Support Chrontel TV for sis630 + (#4312, Can-Ru Yeou). +1057. Fix Xrender library to handle strings > 254 chars long. + Change Xrender and Xft interfaces to use 'unsigned int' + instead of 'unsigned long' for 32-bit glyph values. + (Keith Packard) +1056. Fix neomagic driver mangled acceleration test (#4309, 4310, + Chip Salzenberg). +1055. Add a rudimentary driver for the SGI Indy's newport cards (only + 8-bit and non-accelerated so far) (#4308, Guido Guenther). +1054. Fix a bug in rman that is provoked by the new dumpkeymap man page + (David Dawes). +1053. Updates to the dumpkeymap utility, and add documentation (including + a man page) (#4307, Eric Sunshine). +1052. Add -version and -showconfig options to the Darwin Xserver, and print + the usual "XFree86" banner message (#4306, Torrey T. Lyons). +1051. Fix i810 crash when running XFree86 -configure (#4305, Ryan Drake). +1050. Linux APM fix, which fixes a problem that shows up with the neomagic + driver after an APM suspend (#4304, 4311, Chip Salzenberg). +1049. Correct maximum ranges for Wacom IV devices (#4303, Frederic Lepied). +1048. Add preliminary support for USB input devices under Linux (wacom + driver (#4303, MATSUMURA Namihiko). +1047. Locale fixes/cleanups, including: + - Cleanup garbage in XLC_LOCALES. + - Add "use_stdc_env' to locales where it was absent. + - Move non-standard charset descriptions from the lcCT.c table to + the XLC_LOCALE files. + (#4302, Ivan Pascal). +1046. Make sure the correct "driverName" string is used in xf86Configure.c. +1045. Fix some i810 driver problems when too little videoRam is specified + (David Dawes). +1044. Fix an i810 driver bug that prevents the DRI from being enabled + after a server reset (Jeff Hartmann). +1043. Add a "dri" config file option to the i810 driver that can be used + to enable/disable the DRI (no other method works for statically + linked servers) (David Dawes, from VA's 7.0.1). +1042. Update the i810 driver to check the max available GART memory + (Jeff Hartmann, David Dawes, from VA's 7.0.1). +1041. Resync DRI code/drivers with the DRI CVS (VA Linux). Includes + 3dfx driver updates (Daryll Strauss). +1040. Fix a couple of clipping problems on the Trident CyberBlade/Blade3d + chipsets (Alan Hourihane). +1039. Fix a couple of Alpha related issues (Jay Estabrook). +1038. Change Xft interface (again) to use new XftColor datatype for + colors instead of XRenderColor. xterm and x11perf updated to + match. (Keith Packard) +1037. Fix an i810 init problem that resulted in the fallback to 2D failing + for one case where there's insufficient memory to enable the DRI + (David Dawes, from VA's 7.0.1). +1036. Add support for printing a vendor-specific version string in the + X server startup messages (David Dawes, from VA's 7.0.1). +1035. Xwd workaround for a gcc bug (Red Hat's XFree86-4.0.1-xwd-gcc-workaround + patch). +1034. Fixes for sparc drivers, mostly to prevent accessing the hardware + when the server doesn't have control of the VT (Red Hat's + XFree86-4.0.1-ffb patch). +1033. Use OS-provided interface for accessing PCI config space on Linux/ia64 + (based on Red Hat's XFree86-4.0.1-ia64-pci patch). +1032. Use AsmDefines when processing the Sparc assembler code for cfb + (based on Red Hat's XFree86-4.0-sparc-asmflags patch). +1031. Add PAM authentication to the X server (based on Red Hat's + XFree86-4.0-Xwrapper patch). +1030. Add Slovenian and Romanian entries to XKB's keymap/xfree86 file + (Red Hat's XFree86-4.0-si_xkb patch and XFree86-4.0-ro_xkb.patch). +1029. Fix for PAM support in xdm SessionExit() (Red Hat's + XFree86-4.0-pamsession patch). +1028. XlibInt.c patch to avoid buffer overflow (Red Hat's + XFree86-3.3.6-fixemacs patch). +1027. Updates to xfs from Red Hat and Debian, including: + - command line options to make xfs drop it's root privs (-droppriv + and -user) - command line options to make xfs start as a daemon, + and a build option to make this the default. + - don't let a port option in the config file override the -port + command line option + - cleanup/fix syslogging + (based on #4253, Topi Miettinen, Debian, and Red Hat's + XFree86-4.0-xfsredhat patch). +1026. Support for startx to set up the Xauth when starting an X server + (based on Red Hat's XFree86-4.0-startx_xauth patch). +1025. Fix an unaligned access on Alpha with the tdfx driver (Jay Estabrook). +1024. Add detection for CyberBlade/Ai1 Socket A chipsets (Alan Hourihane). + +XFree86 4.0.1g (29 November 2000) +1023. Fix small bug in lcGeneric.c (#4301, Ivan Pascal). +1022. Rewrite Xft library for Render extension/core text and font management + Change xterm to use new interface (Keith Packard). +1021. s3virge driver updates, including Xv fixes for the ViRGE DX, disable + GX2 color expansion until it's stable, GX2 Xv code (not enabled or + working yet) (#4299, Kevin Brosius). +1020. Siliconmotion driver (#4298, Frido Garritsen, Silicon Motion, Inc.). +1019. Fix Estonian_Estonia.1257 entry in locale.alias (#4297, 4300, + Nerijus Baliunas). +1018. New Lithuanian XKB map (#4296, Nerijus Baliunas). +1017. Fix a problem with the "xtt" font module introduced with recent + changes to the "freetype" module (#4295, ISHIKAWA Mutsumi). +1016. Fix the return value for the "indirect" converter in Xlib (#4294, + Bruno Haible). +1015. ANSI C cleanup of Xlib locale core code (#4293, Bruno Haible). +1014. Optimize the i18n support for parsing resource files for the unibyte + locales, and clean up pre-ANSI-C-isms and warnings (#4292, Bruno Haible). +1013. Enhance the CompoundText <-> UTF-8 converter so that it understands + the BIG5 encoding scheme used by Emacs (#4291, Bruno Haible). +1012. Fix documentation and implementation of _XlcCompareISOLatin1 and + _XlcNCompareISOLatin1 (#4290, Bruno Haible). +1011. Add new Unicode-based APIs for internationalized text for Xlib (#4289, + Bruno Haible). +1010. Fix a minor Mesa lighting bug (#4288, Brian Paul). +1009. Fix the glide driver's resolution of symbols from the glide library + (#4281, Pontus Lidman). +1008. Fix X server stalling forever with local font servers on Linux 2.4 + kernels (#4280, Branden Robinson). +1007. Improve temp file handling in the Xaw library (#4279, Branden Robinson). +1006. Add support for Rage 128 RG (#4277, Michael Mattice). +1005. Modify XimGetCharCode() to use conversion from keysym to UCS and then + from UCS to the appropriate charset specified in the locale description + (#4276, Ivan Pascal). +1004. Allow Unicode fonts to be used as UTF-8 locale native fonts (#4275, + Ivan Pascal). +1003. Fix abnt2/br XKB config (#4274, Paulo Cesar Pereira de Andrade). +1002. Let the Darwin X server build on pure Darwin as well as Mac OS X systems + (#4273, Torrey T. Lyons). +1001. Patch to allow xdm to build on Darwin (#4273, Torrey T. Lyons). +1000. Fix parser not dup'ing a string (#4272, Paulo Cesar Pereira de Andrade). + 999. Improve direct fifo writes for the glint/permedia3 pixmapwrite hook + when using FIFO disconnect (#4271, Sven Luther). + 998. Fix a sprite problem with the "xwin" server (#4269, Suhaib M. Siddiqi). + 997. Fix a confusing local typedef for "wchar_t' in xc/lib/X11/lcUTF8.c + (#4268, Bruno Haible). + 996. Allow ProjectVar to override "/var" when set (based on #4266, + Bruno Haible). + 995. Rework Trident Blade/CyberBlade acceleration (Alan Hourihane). + 994. Make the CyberBlade/e4 (aka 9540) work (Alan Hourihane). + 993. Updates to Big5 encodings for the TrueType font backends (#4265, + Jacky Bryant). + 992. Fixes for Thai (th_TH) locale support in Xlib (#4264, + Theppitak Karoonboonyanan) + 991. Fix a segv in Xnest caused by overflowing the pixmap formats array + (based on #4262, Matthieu Herrb). + 990. Fix an xdm problem that prevents the chooser from working (#4261, + Matthieu Herrb). + 989. Update the Cards file (#4260, Paulo Cesar Pereira de Andrade). + 988. Update Macedonian xkb symbols, and add mk_MK.utf8 to locale.alias + (#4258, 4259, Damjan Georgievski). + 987. Safe tempfile handline for imake's probing of glibc version (based on + #4257, Colin Phipps). + 986. Fix typo in dvorak xkb symbols file, plus white space cleanup (#4256, + Branden Robinson). + 985. Fix typo in server startup message (#4255, Branden Robinson). + 984. Make XOpenDisplay() bail out if the server claims that its vendor + string is > 256 in length (#4254). + 983. Add some useful default key bindings for the xdm login widget (#4252, + Branden Robinson). + 982. Change the default xdm Xaccess file to not allow any connections + (#4252, Branden Robinson). + 981. Set the default glyph caching mode to "CACHE_16_BIT_GLYPHS" + (#4251, Branden Robinson). + 980. Make the X server use the XAUTHORITY environment variable (if set) + when the -authfile command line flag isn't given (#4250, + Branden Robinson). + 979. Add Debian-specific settings to linux.cf (#4249, Branden Robinson). + 978. Rename Trident Cyber9540 to CyberBlade/e4 and make appropriate + changes in driver (Alan Hourihane). + 977. Fix Trident Cyber series to only detect SDRAM (Alan Hourihane). + 976. Make xf86SoundKbdBell() available to modules (for citron driver) + (Marc La France, #4270, Frederic Lepied). + 975. Fix glide driver's check for glide library presence (Marc La France). + 974. Add missing symbol references in r128 and s3virge drivers + (Marc La France). + 973. Fix int10 debugging and reading in all segments between 0x0C0000 and + 0x0F0000 (Marc La France). + 972. Fix typo in imake.c (Marc La France). + 971. Turn off SGRAM optimization for Trident Blade chips, causes some + problems. (Alan Hourihane). + 970. Ignore various ".stab.*" sections for Solaris (Marc La France). + 969. Fix ENXIO errors on Linux BIOS retrievals by removing restriction on + several OSes that xf86ReadBIOS()'s Base be page-aligned (Marc La France). + 968. Disable change 873. It causes device/monitor mismatches + (Marc La France). + 967. Change linux/int10 to intercept signals generated by the vm86() syscall + rather than killing the server (Marc La France). + 966. Reinstate DG/UX mmap() bug work-around in int10 (Marc La France). + 965. Rage128 and Radeon fix for -configure (Marc La France). + 964. Fix int10 woes with retrieving PCI BIOSes (Marc La France). + 963. Allow modules to intercept signals that would otherwise kill the server + (Marc La France). + 962. Fix static Xvfb server build (Marc La France). + 961. Some warning fixes (Marc La France). + 960. Rage128 and Radeon #include changes to reduce recompilations + (Marc La France). + 959. Modify item no. 949 - only reset clipping for Cyber9382, Cyber9385 and + ProVidia9682 (Alan Hourihane). + 958. Added messages about modes rejected on lookup (Egbert Eich). + 957. Attempt to fix DDC1 support on Neomagic (Egbert Eich). + 956. Added Block/UnblockSIGIO() to DDC1 readout code (Egbert Eich). + 955. Enabled virtual depth for a second head on a G400 multihead + (this needs to be looked at) (Egbert Eich). + 954. Added code to check if the PictureScreen structure was initialized + before referencing it (Egbert Eich). + 953. Modified xf86UDelay() to use Block/UnblockSIGIO and usleep() + instead of gettimeofday() (Egbert Eich). + 952. Modified xf86MatchPciInstances() to allow for chipset overrides + even when called with no separate vendorID (Egbert Eich). + 951. Changed Xvfb to use fb instead of cfb (Egbert Eich). + 950. Moved a misplaced xfree() in the generic driver. Now more than + one chipset can use this driver in a multihead setup (Egbert Eich). + 949. Did some fixes for the Trident driver ie. fixed a LCD modeline, + reset clipping register on all non 3D chips (Egbert Eich). + 948. Added missing parts for AXP support to lnx_video.c (Egbert Eich). + 947. Added bsr/bsf to x86emu (Jeff Wiedemeier). + +XFree86 4.0.1f (16 November 2000) + 946. Add a dumpkeymap utility for Darwin (#4248, Eric Sunshine). + 945. Fix a Darwin build problem with mkcfm, and get xdm closer to building + (#4247, Torrey T. Lyons). + 944. DDX for the Xdarwin server (#4246, Torrey T. Lyons). + 943. Enable xdm/PAM support by default for FreeBSD versions with PAM. + 942. Fix a problem where the X server thinks it has acquired a VT at startup + before it has really been released. This is due to the ioctl() + returning prematurely because of a pending signal (Jeff Hartmann). + 941. Fix a problem with the PAM support in xdm that prevents + pam_start_session() from ever being called (Takanori Saneto). + 940. Enable PAM support for xdm on FreeBSD (#A.202, Jean-Marc Zucconi, and + Takanori Saneto). + 939. Fix xf86cfg build problem when BuildXinerama is set to NO (#A.200, + Jean-Marc Zucconi). + 938. gccmakedep has a typo which affects handling the -o and -O options + (A.192, Ivan Zakharyaschev). + 937. Specify the units for the dpms and rate commands in the xset man + page (#A.191, John Heidemann). + 936. Let makedepend ignore "//" style comments on all platforms, not + just Win32, and fix a bug in that code that was causing the line + after such comments to also be ignored (#A.189, Guenther Grau). + 935. Update GNU/Hurd support (#A.188, Marcus Brinkmann). + 934. Initial port of the ark driver to 4.x (#4242, Ani Joshi). + 933. Wacom input driver update, including support for 38400 link speed + and fix wrong advertisement of min/max values (#4241, Frederic Lepied). + 932. Fix some parser problems, including: + - parser does not write Modes section and UseModes keyword + - the vscan value wasn't being used + - make the XF86ConfModesPtr structure accessible from the + XF86ConfMonitorPtr structure + - allow xf86Parser.h to be included from in a C++ program + (#4238, 4243-4245, Paulo Cesar Pereira de Andrade). + 931. Fix the name of the Serbian xkb symbols file (rename from yu to sr) + (#4237, Ivan Pascal). + 930. Fix mkcfm bug (#4236, Juliusz Chroboczek). + 929. Glint/permedia3 updates (#4235, 4238, Sven Luther). + 928. Fix an SVR4 loader build problem introduced in 4.0.1d (#4234, + Takaaki Nomura). + 927. Fix a bug in fontenc that would cause a memory leak whenever an + encoding would be declared in encodings.dir but not in the encoding + file itself (#4233, Juliusz Chroboczek). + 926. Make the freetype backend use the fontenc matrix encoding support, + remove support for the defunct XAnti extension, and bump the version + of the freetype backend to 1.1.8 (#4233, Juliusz Chroboczek). + 925. Add proper support for matrix encodings in fontenc (including the + new FIRSTINDEX keyword in encoding files), and bump the version of + the font module ABI to 0.2 (#4233, Juliusz Chroboczek). + 924. Fix a problem the vesa driver (#4232, Paulo Cesar Pereira de Andrade). + 923. Fix problems building the C&T driver with DEBUG defined (#4231, + Taketoshi Sano). + 922. Remove lt_LT.ISO8859-1 entry from compose.dir (#4230, Nerijus Baliunas). + 921. s3virge driver updates, including: + - Stabilize GX2 support, reenable silken mouse + - Enable MX fixes + - Add support for the render extension + - Enable BLT_BUG for ViRGE and VX chipsets + (#4229, Kevin Brosius). + 920. Don't initialize DRI when noaccel is specified in the tdfx driver + (Alan Hourihane). + 919. Make module ABI compatibility mismatches fatal by default, and + add a command line option for making them non-fatal (David Dawes). + 918. Changed SiS driver to use fb instead of cfb (Alan Hourihane). + 917. Fix r128 and radeon driver source code formatting that was munged + during ATI merge (Kevin Martin). + 916. Update Markus Kuhn's UCS fonts, and add his scripts for extracting + subsets of them to the build process (David Dawes). + 915. Fix visual setting in ATI r128/radeon driver (Jeff Wiedemeier). + 914. Alpha fix for xf86cfg (Alan Hourihane). + 913. Resync DRI code/drivers with the DRI CVS (VA Linux). + 912. Fix tdfx driver to register resources and remove some redundant code + (Alan Hourihane). + +XFree86 4.0.1e (6 November 2000) + 911. Fix the ksc5601.1987-0 encoding file (#4226, 4228, Pablo Saratxaga). + 910. Update xdm/sessreg to write ":0" type entried in utmp on OpenBSD + (#4225, Matthieu Herrb). + 909. Fix for Xmu under NetBSD, which doesn't #define "unix" anymore (#4225, + Matthieu Herrb). + 908. Preliminary support for OpenBSD/powerpc (#4225, Tsubai Masanari, + Matthieu Herrb). + 907. Support for native WSCONS driver on NetBSD and OpenBSD (#4225, + Tsubai Masanari). + 906. Support for new OpenBSD 2.8 shared libs scheme (#4225, Matthieu Herrb). + 905. Support for the OpenBSD ports tree (#4225, Marc Espie). + 904. Update the list of layouts in the xfree86.lst file (#4224, Ivan Pascal). + 903. Add an XKB map for Serbian (#4224, Milos Rancic). + 903. New revision of the Bulgarian XKB map (#4224, Anton Zinoviev). + 902. Change the Alt key definitions in the "group switcher" descriptions + to not override the base Alt key mappings (#4223, Ivan Pascal). + 901. Change XKB Mode_switch behavior description to not clear "locked + group" (#4223, Ivan Pascal). + 900. Create a root window property "XFree86_DDC_EDID2_RAWDATA" when + suitable data is available (#4222, Andrew C. Aitchison). + 899. Fix some typos/errors in the Latvian and Lithuanian entries in + the locale.alias and locale.dir files (#4221, Nerijus Baliunas). + 898. Fix two more bugs in xkbcomp: handling of 'keycode aliases', and + copying of strings when copying structures (#4208, Ivan Pascal). + 897. Added render extension support to tseng driver (Egbert Eich). + 896. Fixed clock code in neomagic driver (Egbert Eich). + 899. xf86Configure now uses the imake variable xf86ConfigFile (Egbert Eich). + 898. xf86cfg has a new option for a server path (Egbert Eich). + 897. xf86cfg can now handle more than one command line argument (Egbert Eich). + 895. Added a delay to dac code in neomagic driver (Egbert Eich). + 894. Changed shadowfb to use delayed updates in neomagic + driver (Egbert Eich). + 893. Rewrote ddc code in nv driver (Egbert Eich). + 892. Rewrote ddc code in neomagic driver (Egbert Eich). + 891. Fixed problems with enter/leave/closeScreen in nv + driver (Egbert Eich). + 890. Fixed a bug in the fixed modelines in trident driver (Egbert Eich). + 889. Added reinitialization of blitter on enterVT in trident + driver (Egbert Eich). + 888. Fixed a typo which caused wrong register to be set in trident + driver (Egbert Eich). + 887. Added loader symbol handling to tseng driver (Egbert Eich). + 886. Changed tseng driver to use fb instead of cfb (Egbert Eich). + 885. Changed chips driver to use fb instead of cfb (Egbert Eich). + 884. Added render extension support to chips driver (Egbert Eich). + 883. Added render extension support to neomagic driver (Egbert Eich). + 882. Added render extension support to nv driver (Egbert Eich). + 881. Modified helper_mem.c to map everything between video bios and + system bios on PC-like platforms (Egbert Eich). + 880. Modified Linux mapVidMem() to map memory on page boundaries + (Egbert Eich). + 879. Changed BIOS_SIZE (Sys BIOS) from 0x10000 to 0xffff to make + int10 work un DGUX (Takis Psarogiannakopoulos). + 878. Fixed a bug in the argument list of the call to xf86ReadPciBIOS() + from int10/pci.c (Egbert Eich). + 877. Added simple sanity check to catch situation where DDC reads + all 0 and therefore trivially has the correct checksum (Egbert Eich). + 876. Changed i2c code to allow for longer rise/fall times on longer + cables (Egbert Eich). + 875. Removed limit on default visual for 4bpp (Egbert Eich). + 874. Added macros to build nv driver on AXP (Jay Estabrook). + 873. Changed -configure to use primary card as first card (Egbert Eich). + 872. Changed generic vga driver to not unmap memory when switched away. + 871. Fixed problem that caused APM support to be disabled on server + reset (Egbert Eich). + 870. Added support for newer sparse AXP systems (Egbert Eich). + 869. Added support for MGA G100 PCI (Egbert Eich). + 868. Add missing exported libXext Shm functions to loader (Alan Hourihane). + 867. Change Rage 128 DRM driver name to what the r128 kernel module + expects (Kevin Martin). + 866. Fix newly merged "ati" driver probe to allow "r128" and "radeon" + driver names in the XF86Config file for backwards compatibility + (Kevin Martin). + 865. Use vgaHW module to fix font save/restore in i128 driver (Robin Cutshaw). + 864. Fixed (hopefully) a Xinerama problem with BE clients (Mark Vojkovich). + 863. Modifications to GLw to allow it to build without Motif, and + integrate it into the regular build process (#4142, + Carlos A. M. dos Santos, David Dawes). + 862. Import the GLw parts of SGI's ogl-sample (snapshot from 20001102) + under xc/extras/ogl-sample. + 861. Add support for SubSection in the Vendor Section of the config file + (Stuart Anderson) + 860. Fix a typo introduced in a recent update to the 'no' xkb symbols + file (#4218, Pablo Saratxaga, 4219, Harald Nordgård-Hansen). + 859. Parser symbol update (#4217, Paulo Cesar Pereira de Andrade). + 858. Updates to iso8859-9e, microsoft_cp1251 charset handling, and + add real support for microsoft_cp1255 and microsoft_cp1256 (#4214, 4215, + Pablo Saratxaga). + 857. Fix Sparc build problems linking xf86cfb with libloader that were + related to various interdependencies (#4212, David S. Miller). + 856. Allow generic XVideo adaptors (like v4l) to be initialised for + the G400 crtc2 (#4211, Antti Tapaninen). + 855. Update mga driver to check the chipset much earlier to prevent + server hang when using g400 dual head + millennium 2, and some + G200 PCI/warp cleanups (#4211, Antti Tapaninen). + 854. Updates to the Macedonian xkb symbols (#4210, 4220, Damjan Georgievski). + 853. Combine the ATI, Rage128 and Radeon drivers into one with multiple + sub-modules (Marc La France). + 852. Make BIOS accesses in the Rage128 and Radeon drivers independent of + endianess and alignment (Marc La France). + 851. Fix the claiming of XF86Config device sections by drivers, and change + xf86MatchDevices() to only return unclaimed sections (Marc La France). + 850. Fixed build problem in s3virge when XvExtension is not set (Stuart + Anderson) + 849. Add a message at the top of the server/log output for pre-release + versions stating that they are unsupported (David Dawes). + 848. Fix two problems in Imake.rules: have LinkBuildBinary create the + used directory if it doesn't exist, and fix a missing ')' in + the LinkConfFileLong (#A.187, Ivan Zakharyaschev). + 847. Fix a libXt bug that affects multidisplay applications when Xt is + built to use select(2) rather than poll(2) (#A.181, Antony Uspensky). + 846. Add a -utime option to xclock that allows the digital clock to + display the number of seconds since the Epoch (based on A.173, + Kelsey Hudson). + 845. Add symbols mappings for extra keys on the BTC 9000 keyboard (#A.167, + Stefano Cavallari). + 844. Fix twm's icon manager so that it is functional before an EnterNotify + event is received in twm's event loop (#A.156, Jason Zwolak). + 843. Update comments about standards for Estonian support, and add an + entry for the Estonian keyboard layout to the xfree86.lst file + (#A.155). + 842. Fix for G400 crtc2 blank screen color (#4205, Antti Tapaninen). + 841. Modify the mga/HALlib support to allow it to be selected at + run-time. This allows a driver built with HALlib to be used with + older hardware (like the Millennium, Millennium 2) (#4204, + Antii Tapaninen). + 840. Add config/imake support for Darwin (#4200, Torrey T. Lyons). + 839. Add a driver for the citron touch screen (#4199, Peter Kunzmann). + 838. Fix Html man page install problem (Robin Cutshaw). + 837. Fix transparency problem with blits, add DDC2 for i128-II chipset + in i128 driver (Robin Cutshaw). + 836. Allow loader to be build if HasShm == NO (Marcus Brinkmann). + 835. Allow the log file to be set in the config files (Stuart Anderson). + 834. Fix Rage128/Radeon drivers to free correct scratch buffer on LeaveVT + (Alan Hourihane). + 833. Xterm patch #148 (#4213, Thomas Dickey). + 832. Split ATI driver into two modules in preparation for merging in the + r128 and radeon drivers (Marc La France). + 831. Update the XFree86 -configure code to put the default font path + in the Files section of the config file it generates (#4202, + Paulo Cesar Pereira de Andrade). + 830. Add write-combine support for IA-64 (Mark Vojkovich). + +XFree86 4.0.1d (27 October 2000) + 829. Add code to the xf86config utility to get the list of XKB selections + from the appropriate XKB files rather than having them hard-coded. + Also allow XkbOptions to be set (#4209, Ivan Pascal). + 828. - + 827. Xterm patch #147 (#4207, Thomas Dickey). + 826. Move the initialisation of pScrn->EnableDisableFBAccess into + InitOutput(), which fixes an infinite loop problem that can show up + on server resets (#4206, Joe Moss). + 825. Make xf86cfg use the same config file search path as the X server + (#4203, Paulo Cesar Pereira de Andrade). + 824. - + 823. Fix a bug in the vesa driver when finding the linear address for the + card, some compile time warnings, faster code for handling colormap + changes, and add DGA support (#4201, Paulo Cesar Pereira de Andrade). + 822. Fix a typo in the mga driver that causes planemask problems with + the PCI version of the G100 (#4198, Antti Tapaninen). + 821. Add an option to the C&T driver to disable "TMED" (DSTN dithering + scheme) (#A.172, Damir Anicic, #4196, 4197, David Bateman). + 820. Pablo Saratxaga's i18n updates for XFree86 that are used in Mandrake 7.2. + Includes various new and fixed xkb files, locale name additions and + updates, and new support for various charset encodings (#4195, + Pablo Saratxaga). + 819. Improve Xaw 7 compatibility with version 6 in the form widget geometry + management code. This should fix some problems seen with ghostview + (#4194, Paulo Cesar Pereira de Andrade). + 818. Build fixes for XFree86 on Cygwin (#4193, Suhaib Siddiqi). + 817. Fix for missing symbol messages in int10 and cirrus driver + (Marc La France). + 816. Detect null windows of PCI-to-PCI bridges (Marc La France). + 815. Update pciConfigRec's and pciVideoRec's when relocating PCI resources + (Marc La France). + 814. Fix handling of 64-bit PCI bases (Marc La France). + 813. Fix cursor hide on i128 in multi-head mode (Robin Cutshaw). + 812. Fix accel on i128 non-primary cards (Robin Cutshaw). + 811. locale.alias fix for ko_KR.utf8 (#4190, Won-kyu Park). + 810. Fix incorrect vtSema usage in neomagic driver DPMS code (#4184, + Andrew C Aitchison). + 809. Fix a 1-byte overflow in Xtrans.c (#4182, Aaron Campbell). + 808. Enable building the loadable server for BSD/OS. + 807. Fix the following xkbcomp bugs: + - 'base group' keyword added to 'whichGroup' possible values list + - 'groupsWrap' keyword removed from 'controls' possible values list + - fix crash in processing files with unnamed sections + - now keep 'per key group adjustment mode' in XKM file + - now allow an empty 'key' description to be specified in an + xkb_symbols file. + (#4170, Ivan Pascal). + 806. Add a "bcast" flag for mode lines, which is needed to display + broadcast resolutions (#4169, Michel Danzer). + 805. Fix compiler warnings when building the mga driver with or without + the Matrox HALlib, add the digital/tv-out/tvstandard/cabletype + options, missing files, and some cleanups (#4166, Antti Tapaninen). + 804. Fix spelling from xvinfo (#4166, Antti Tapaninen). + 803. Add support to twm for displaying multibyte strings on window titles, + and make the twm config file reader 8-bit clean (#4165, 4168, 4180, + Tomohiro Kubota). + 802. Fix a tseng driver problem related to the usable amount of video memory + (#4164, A.182, Randy McCaskill). + 801. Add support for the new Render extension to the nv driver, and + turn on fb support by default in the nv driver (#4161, Jarno Paananen). + 800. Fix a typo that prevents DPS from being built statically (#4160, + Juliusz Chroboczek). + 799. Fix some xkbfile bugs in the .xkb files that it writes + (two adjacent commas, no xkb_types section in xkb_layout) (#4159, + Ivan Pascal). + 798. Fix an xkbcomp bug that causes an infinite loop for some error + message output (#4158, Ivan Pascal). + 797. Fix XlcNONE usage in charset description (#4153, Ivan Pascal). + 796. Fix a bug in XKB group adjustment (#4152, Ivan Pascal). + 795. Fix some build problems that show up with the SVR4 C compiler + (based on #4139, Takaaki Nomura). + 794. Add two new XKB group switches (Alt+Shift and Menu key) (#4151, + Ivan Pascal). + 793. Fix HTML man page links when the man page suffix has more than one + character (#4150, Bruno Haible, A.149, Serguei Ostrovskii). + 792. Remove the old UTF-1 locale (it's not filesystems safe, deprecated + for years, withdrawn from ISO standards, and nobody uses it) (#4147, + 4149, Bruno Haible). + 791. Replace multiple stub functions in libXThrStub by only one (#4141, + Carlos A. M. dos Santos). + 790. Fix some build problems that show up with glibc 2.1.3 where ctype.h + sometimes (always?) depends on stdlib.h being included (#4134, + Kevin Brosius). + 789. Updates for building on BSD/OS 4.2 on UltraSparc (#4132, Kurt J. Lidl). + 788. Default to linking the Xfont library into the X server statically + (based on #4127, Kurt J. Lidl). + 787. Update apNetBSD.shar for a kernel mmap interface change (#4124, + Bernd Ernesti). + 786. When the "auto" mouse protocol is specified, do the auto-detection + whenever regaining control of the VT (based on #4120, Kazutaka Yokota). + 785. Change the usage of the "Xinerama" config file option to be consistent + with all the other ServerLayout/ServerFlags options, and document it + in the XF86Config man page (#4118, Itai Nahshon). + 784. Add I2C/DDC support to i128 driver (Robin Cutshaw). + 783. Add non-GXcopy raster op support to cirrus driver (#4178, David Monniaux). + 782. Use DlLibrary instead of referencing -ldl explicitly in xf86cfg + (#4189, Matthieu Herrb). + 781. Add S3 Virge XVideo support (preliminary) (#4186, Kevin Brosius). + 780. Fix non-DRI build problem in r128 driver (#4188, Matthieu Herrb). + 779. Add XLIB for OpenBSD/i386 dependency problem to xvinfo + (#4187, Matthieu Herrb). + 778. Update C&T driver, remove obsolete acceleration and use fb instead + of cfb with USE_FB option (#4185, David Bateman). + 777. Experimental XAA Render support in the MGA driver (Mark Vojkovich). + 776. Preliminary XAA support for the Render extension (Mark Vojkovich). + 775. Pass depth/bpp correctly, scan all fbdev devices, misc fbdev fixes. + (#4179, Michel Danzer). + 774. Add generic Vesa driver, fixes for xf86cfg plus changes to parser to + reflect xf86cfg changes (#4174,#4175, Paulo Cesar Pereira de Andrade). + 773. Loader fixes for Alpha. (Jay Estabrook). + 772. Accelerated TGA2 32bpp for tga driver (Jay Estabrook). + 771. Allow use of Compaq's Math Library on Alpha (currently for Mesa) + (Alan Hourihane). + 770. Update Tiny-X Xvesa server for standard VGA BIOS modes. (Keith Packard) + 769. Added ATI Radeon driver, accelerated 2D only (for now) (VA Linux). + 768. Fix depth24/32 issue in i128 driver (#4176, Andrew C Aitchison). + 767. On IA-64's, build DRI and drm's if they would be built on IA-32's + (David Mosberger). + 766. Fix xf8_32wid build on Sparc's (Marc La France). + 765. Fix MMIO macros for Sparc's (David S. Miller, Jakub Jelinek, + Marc La France). + 764. Sparc warning fixes (Marc La France). + 763. Fix for decoded I/O and memory ranges of certain Sun PCI-to-PCI bridges + (David S. Miller, Jakub Jelinek). + 762. Force ATIAvoidCPIO to YES on Sparc's (Marc La France). + 761. Minor fix for the ATI driver's printing of MMIO registers + (Marc La France). + 760. Minor fix for sunffb DGA support (Marc La France). + 759. Remove unnecessary pointer<->long casts in tseng driver (Marc La France). + 758. Re-align Sparc PCI support with that of other architectures + (Marc La France). + 757. mmap() /dev/fb instead of /dev/mem on Linux/Sparc (Marc La France). + 756. Fix OS-reported PCI ranges on Linux/Sparc (David S. Miller, + Jakub Jelinek). + 755. Remove a dependency on word size in the determination of PCI resource + sizes on Linux (Marc La France). + 754. Permedia3 updates (#4177, 4183, 4192, Sven Luther). + 753. Add Xv support to the r128 driver (Stuart Anderson/Vladmir Dergacheb) + 752. Make VBE module log a message when the BIOS doesn't support any VESA + extensions (Marc La France). + 751. Fix int10 so that it rejects BIOS's that are not aligned on a 512-byte + boundary (Marc La France). + 750. Fix int10 for ISA adapters on Alpha's (Egbert Eich). + 749. Fix for ATI ISA adapters on Alpha's or with -configure (Marc La France). + 748. Fix stupid clock probe bug in ATI driver (Marc La France). + 747. Reorganise ATI driver in preparation for futuure changes + (Marc La France). + 746. Formatting changes to hsync/vrefresh messages (Marc La France). + 745. Fix spurious free() when using an ISA adapter (Marc La France). + 744. Preliminary acceleration of the Render extension for Matrox G200/G400 + (Mark Vojkovich). + 743. Fix ordering of drawable destruction in client-side DRI (Brian Paul). + 742. Update Trident's text acceleration routines (Alan Hourihane). + 741. Destroy unbound window info when a client destroys a context in + the client-side DRI driver (Kevin Martin). + 740. Make ATI driver's detection of Rage 128's more precise (Marc La France). + 739. Reinstate BIOS checksum verification but make it non-fatal + (Marc La France). + 738. Don't set protection register on older trident chips + Fixes Vertical line problem. (Alan Hourihane). + 737. Add missing symbols for Solaris (incomplete) (Marc La France). + 736. Add primitive support in xterm for Xft based fonts (Keith Packard) + 735. Add new Xft library to hook FreeType 2 to Render (Keith Packard) + 734. Added support for Number Nine I128 chipsets (Robin Cutshaw). + 733. Added support for softbooting BIOSes on ia64 (Egbert Eich). + 732. Fixed handling of XtMakeGeometryRequest() to test for parent + belonging to subclass of composite class only if the widget + itself is managed. This follows the specs more closely. + (Keith Packard). + 731. Changed handling of DDC read in r128 driver. Driver does not + fail any more if vbe DDC reads don't succeed (Egbert Eich). + 730. Fixed infinite loop when referencing the same mnitor section + twice when using a Mode Section (Egbert Eich). + 729. Fixed problem that caused SIGV in xf86GetValidBiosBase() (Egbert Eich). + 728. Fixed macintosh us keyboard (Olaf Hering). + 727. Added missing symbols to mga driver (Stefan Dirsch). + 726. Fixed a ia64 loader problem that caused SIGV when PLT was present + (Andreas Schwab). + 725. Fixed ia64 build rules (Andreas Schwab). + 724. Fix DGA library to only swap events for DGA 2.0 X servers + 723. Fix locale parsing code in Xlib and Xt (Matthieu Herrb) + 722. Fix X Test Suite to work on 800x600 screens (Keith Packard) + 721. PCI chip ID updates to ATI driver (Marc La France). + 720. Fix i810 driver for -probe and -configure (Marc La France). + 719. Change message when default modes are deleted (Marc La France). + 718. Fix Xinerama byte swapping bug (Marc La France). + 717. IA-64 and Alpha fixes for pswrap, Mesa, DRI, Xpm, libX11, Xt, Xaw, Xmu, + dps, Type1 fonts, cfb24, most output drivers, ELF loader, ramdac module, + xf4bpp and xf86cfg (Marc La France). + 716. Improve IA-64 support by removing a plethora of 32-bit'isms + (Marc La France). + 715. Default HasLinuxDoc to NO (Marc La France). + 714. Lots of Neomagic driver fixes/enhancements (Mark Vojkovich). + - Fix logic bug that kept HW cursor from being used. + - Added support for gamma correction and DirectColor visuals. + - Fixed some depth/bpp confusion (depth 15 works now). + - Convert from cfb to fb. + - Fix typo that kept the pixmap cache from being used. + - Fixed DGA support. + - Disable 8x8 pattern fills because they don't work. + - Set correct virtual desktop size limits for 2160 and older chips. + - Preliminary man page. + - Enable burst modes by default. + - Accelerate ImageWrite support for 2097/2160. + 713. Fix some depth 32 problems in XAA (Mark Vojkovich). + 712. Add Silken Mouse to Rage 128 driver (Alan Hourihane). + 711. Resync DRI code/drivers with the DRI CVS (VA Linux). + 710. Add glxinfo to programs list (#4138, Mark Paton). + 709. Add LVDS support for SiS and fix copyright messages (#4136, Can-Ru Yeou). + 708. Fix support for C&T 69030 (#4137, David Bateman). + 707. Support Cirrus Logic 7548 chip (#4146, David Monniaux). + 706. Fix typos in Xt man pages (#4156, Carlos Santos). + 705. Fix libdps bug (#4154, Juliusz Chroboczek). + 704. Xterm patch #146 (#4144, Thomas Dickey). + 703. Xterm patch #145 (#4140, Thomas Dickey). + 702. Fix 32bpp on the Permedia3 (Sven Luther). + 701. Fix to xterm InsertChar() to handle cases where cur_col + n + ends up past the end of the line (Andreas Schwab). + 700. Added keyboard layouts for PowerMac (Olaf Hering). + 609. Fixed Macintosh keyboard layouts (Olaf Hering). + 608. Fixed build when BuildServer defined NO (Egbert Eich). + 607. Fixes for C&T 69030 (David Bateman). + 606. Fix for locale setting in Xlib and Xt using getlocale() + from glibc5 (Egbert Eich). + 605. Added handling of i5/686 and k6 compiler defines to Imake.cf + (Philipp Thomas). + 604. Added support for non-English locales in xload (Egbert Eich). + 603. Fixed memory initialization in Xlib (Vladimir Nadvornik). + 602. Fixed memory initialization in xdm (Egbert Eich). + 601. Rudimentary S390 support (Ruediger Oertel, Bernhard Kaindl). + 600. Enabled support for compressed xpm-files (Stefan Dirsch). + 599. Added support for Czech querty keyboard (Jan Holesovsky). + Some fixes for ia64 (). + 598. Added CPU to Screen Color expansion to Neomagic driver (Egbert Eich). + 597. Added support for hotkey display output switch for Neomagic + driver (Egbert Eich). + 596. Add "xvinfo" client for querying Xv adaptors (Mark Vojkovich). + 595. Fix DGA support in the i810 driver (Mark Vojkovich). + 594. Enlarge the i810 pixmap cache and have the YUV overlay use that memory + rather than allocate dedicated memory for overlay data (Mark Vojkovich). + 593. Add/fix support for the Rage 128 Mobility chips (M3/M4) (Kevin Martin). + 592. Fix RegisterResources for multiple heads in glint driver + (#4143, Berend Ozceri). + 591. Update Permedia3's hw cursor to match the Permedia2v's they are + the same (Alan Hourihane). + 590. Fix glint driver to use colorKey rather than fixed value (Alan Hourihane). + 589. Add ScreenToScreenCopies for Permedia3 (Alan Hourihane). + 588. Add SilkenMouse support to the i810 driver (Mark Vojkovich). + 587. Disable DRI acceleration in depth 15 on the i810 because it doesn't + work (Mark Vojkovich). + 586. Fix some ordering problems in the I810ScreenInit that broke the + software cursor and backing store (Mark Vojkovich). + 585. Convert the i810 driver from cfb to fb (Mark Vojkovich). + 584. Fix some depth/bpp confusion in the i810 driver. Depth 15 works now + (Mark Vojkovich). + 583. Turn off visual ID matching in Xv (Mark Vojkovich). + 582. Add the IA-64 ELF loader (Jakub Jelinek). + 581. Add I420 and UYVY image formats to the i810 driver (#4135, Jonathan Bian). + 580. Fix an Xaw problem with illegal aliases (#4133, Jakub Jelinek). + 579. Set $(SHELL) to '/bin/sh -e' on Linux to allow builds/installs stop + immediately on errors as on other platforms (Brandon Robinson). + 578. Update i810 driver for -configure to work (Alan Hourihane). + 577. Have Xv silently ignore client requests with zero sized primitives + (Mark Vojkovich). + 576. Disable gamma correction and DirectColor visuals on the i810 because + they don't work (Mark Vojkovich). + 575. Fix a bug in XAA's MSBFIRST color expansion support (Mark Vojkovich). + 574. Allow the default i810 video overlay key to be changed from the + XF86Config file (Mark Vojkovich). + 573. Don't build DRM modules with a non-module Linux kernel (Marc La France). + 572. Reinstate non-MMIO-only version of ATI driver for Alpha architecture + (Marc La France). + 571. Fix input event queueuing for 64-bit platforms (Marc La France). + 570. IA-64 changes resulting from a source cross-check with Alpha support + for 64-bit dependencies (Marc La France). + 569. Fix in ATI drivber for DPMS support on panels (Marc La France). + 568. I810 bugs fixes and enhancements relating to Xv (#4121, 4117, 4123, + 4128, Jonathan Bian). + +XFree86 4.0.1c (28 August 2000) + 567. Add support to xset for setting the keyboard repeat rate using XKB + (A.119, A.126, Stephen Montgomery-Smith). + 566. Various DRI-related 64-bit/IA-64 fixes (#A.134, David Mosberger). + 565. Support for multithreaded libraries on NetBSD when used in conjunction + with the GNU pth library (#4113, Chris Sekiya). + 564. Add /usr/pkg/bin to NetBSD's DefaultUserPath (#4112, Bernd Ernesti). + 563. Add a (Linux-specific) VESA driver for Keith's small X server (#4111, + Juliusz Chroboczek). + 562. Update Hungarian xkb maps (#A.145, Peter Soos). + 561. Fix ATI driver bug that prevented the disabling of int10, ddc and vbe + through options (Marc La France). + 560. Improve libX11 behaviour when a server doesn't have XKB, allowing + XKB-aware XLookupString features with servers without XKB (#4108, + Ivan Pascal). + 559. Fix a bug in xkbcomp'shandling of 'group compat' data (#4107, + Ivan Pascal). + 558. Fix an i810 driver problem doing XvImage with clipping (#4106, 4110, + Jonathan Bian). + 557. Add PCI info for devices found on the G4 Mac (#4105, Matthieu Herrb). + 556. New XkbOptions for LED selection (#4101, Ivan Pascal). + 555. Changes to XkbGetControls regarding ax_options (#4100, Ivan Pascal, + based on A.125, Stephen Montgomery-Smith). + 554. Changes to XkbSetControls regarding per_key_repeat (#4099, Ivan Pascal, + based on A.124, Stephen Montgomery-Smith). + 553. Fix MouseKeys acceleration (#4098, Ivan Pascal, based on A.112, + Stephen Montgomery-Smith). + 552. - + 551. Man page for Xmark (#4097, Richard Braakman). + 550. Fixes for Macintosh XKB data files (#4094, Ani Joshi). + 549. Change VarDbDirectory to /var/lib on Linux to comply with FHS 2.1 + (#4093, Branden Robinson). + 548. Include in agpgart.h (#4091, Branden Robinson). + 547. Re-add installation of the micro font (#4090, Branden Robinson). + 546. Fix the rstart/server script generation (#4088, 4089, Branden Robinson). + 545. Allow mkhtmlindex.sh to work when the shell's -e flag is used (#4087, + Branden Robinson). + 544. Xterm patch #144 (#4109, Thomas Dickey). + 543. Xterm patch #143 (#4104, Thomas Dickey). + 542. Xterm patch #142 (#4102, Thomas Dickey). + 541. Xterm patch #141 (#4085, Thomas Dickey). + 540. Xterm patch #140 (Thomas Dickey). + 539. Xaw bug fix (#4084, Paulo Cesar Pereira de Andrade). + 538. Add support for the NeoMagic NM2230 MagicMedia 256AV+ to the neomagic + driver (#4083, Andrew C Aitchison). + 537. Fix generic Xom to select the same font for measuring text escapement + as is used for drawing (#4082, Owen Taylor). + 536. Resync DRI code/drivers with the DRI CVS (VA Linux). + 535. Engine polling changes in r128 driver (David Mosberger). + 534. Fix linear memory mapping in ATI driver (Marc La France). + 533. Fix endianness problems in the ATI driver when accessing BIOS images + (Marc La France). + 532. Allow building Xptr, Xnest and Xvfb with MakeDllModules + (Bill Nottingham). + 531. Build DRI drivers on IA-64 (David Mosberger, Marc La France). + 530. Use $(CC) instead of $(LD) when building modules (Bill Nottingham). + 529. When building with MakeDllModules, generate both dynamic and static + libraries (Bill Nottingham, Marc La France). + 528. Fix detection problem with ramdac for Glint Permedia1's + (Alan Hourihane). + 527. Fix minor symbol resoltion problem in dlopen() loader (Marc La France). + 526. Alpha changes that fell out of RadHat's IA-64 changes (Marc La France). + 525. A merge of most of RedHat's IA-64 changes (Keith Fish, Stephane Eranian, + Bill Nottingham, Marc La France): + - Don't force static server build. + - Fix NULL #define'ition for loader server. + - Various #if-testing changes. + 524. Fix the few problems that showed up with the integration of the cygwin + support (Suhaib M. Siddiqi). + 523. ATI driver changes (Marc La France): + - Make ATIProbe() and ATIPreInit() optionally more verbose. + - Fix compile problem on Alpha's. + - Fix Mach64 hardware clipping bug. + - Support transparency during Mach64 screen-to-screen copies. + - Disable int10 interface in MMIO-only driver version. + - Fix determination of MMIO base address for Mach64 GX, CX, CT, ET, + VT and GT. + - "Wake" up ATI VGA's before probing for them. + - Other cosmetic changes. + 522. Workaround for problems with static during palette changes on the + MGA G400 (Mark Vojkovich). + 521. Share common drm files between Linux and FreeBSD. This fixes + DRI-related build problems on FreeBSD (David Dawes). + 520. Add Romanian xkb symbols definitions (Cristian Gafton). + 519. First cut at pushing the AGP GART interface into the os-support + layer, with support for Linux and FreeBSD (David Dawes). + 518. Fix SHM support in Xv that was broken in 4.0.1b (David Dawes) + 517. Change the Solaris8/x86 keyboard handling to map the raw keycodes to + the same keycodes that we use on other platforms, and remove the + Solaris8/x86-specific XKB definitions (David Dawes). + 516. Fix a problem in the fbdev driver where xf86DrvMsg() is called before + the necessary pScrn fields have been initialised (Martin Dalecki). + 515. Fix mga dri bug that caused some rendering corruption when the dri module + was loaded (Mark Vojkovich). + +XFree86 4.0.1b (11 August 2000) + 514. Fix the freetype font renderer's handling of True Type Collections + (.ttc files) (based on #A.123, timecop at japan.co.jp). + 513. Add PCI IDs for Silicon Motion, Inc (#A.122, Martin Dalecki). + 512. Fix a problem with the sequence number not being byte-swapped + for the reply to the DPMSCapable request (#A.120, Stephen Tse). + 511. Fix input driver PreInit funtions to behave as expected by InitInput() + (David Dawes). + 510. Port the spaceorb input driver to 4.x (Guido Heumer). + 509. Port the Summa input driver to 4.x (#A.116, Peter Schlaile). + 508. Add a DigitalEdge input driver (#A.116, Peter Schlaile). + 507. Remove obsolete PC98 code (#4081, Takaaki Nomura). + 506. Fix PC98 keyboard problems (#4081, Osamu Tomita). + 505. Imake support for building on Linux/arm32 (#4080, Andrew E. Mileski). + 504. Fix a problem with restoring the PIXCONF register in the i810 driver + (#4078, Jonathan Bian). + 503. Fix a build problem with the sis dri driver Imakefile (#4076, + Takaaki Nomura). + 502. Add DPMS support to the fbdev driver (#4075, Ani Joshi). + 501. Add DPMS support to the fbdevhw module (#4074, Ani Joshi). + 500. Fix VGA detection bug with Mach64 integrated controllers + (Marc La France). + 499. Accelerated line support for the NV driver (Chas Inman, Mark Vojkovich). + 498. Add GeForce2 support to the NV driver (Chas Inman). + 497. Integrate Cygwin support. To compile, this requires Cygwin 1.0 or + later with gcc 2.95.2 and Windows NT (#4073, Suhaib M. Siddiqi). + 496. Add en_GB.ISO8859-15 to locale.dir (David Dawes) + 495. Build int10 on all platforms and move ATI driver after r128 driver in + compiled-in probe lists (Marc La France, Michael Madore). + 494. Fix bug in parser code: addNewOption2() trunkates option list + when an option is added that already exists (Egbert Eich). + 493. Fix tmp file problem with makedepend scripts (based on report from + Alan Cox). + 492. ATI driver changes (Marc La France): + - Fix resource relocation bug. + - An attempt at fixing problems reported with Chrontel 8398's. + - Workaround for Mobility BIOS bug that affected the driver's ability to + restore the mode on server entry. + - Fix SEGV that occurs with ATI adapter BIOS'es that do not support some + flavour of VBE. + - Allow the driver to tolerate the absence of an initialised adapter BIOS + image and introduce XF86Config options for the information the driver + would otherwise require from it. + - Recognise more cases where a DFP panel might be in use. + - Fix minor bug that occurred on xf86SetDepthBpp() failures. + - Implement a compilation option that produces an MMIO-only version of + the driver. Intended for non-Intel architectures. See the driver's + Imakefile for details. + 491. fixed handling of backwards compatibility in xvmode (Egbert Eich). + 490. fixed changing mouse protocol with xf86misc extensions (Egbert Eich). + 489. added code to sanitize uninitialized PCI config space + base addresses (Egbert Eich). + 488. Changed xf86xv.c to call StopVideo(exit=TRUE) even + if StopVideo(exit=FALSE) has already been sent (Egbert Eich). + 487. fixed core dump in C&T video driver when vt switching + Changed C&T video driver to only register a block handler + when StopVideo() is called with exit = TRUE (Egbert Eich). + 486. Fixed Cirrus driver not segfault when termineated while + switched away (Egbert Eich). + 485. Neomagic driver: select sw cursor when screen stretching is + enabled (Egbert Eich). + 484. Neomagic driver: fixed problem with screen to screen copy + on 2200 chipsets (Egbert Eich). + 483. Neomagic driver: fixed 'white screen problem' by implementing + a signal save delay routine (Egbert Eich). + 482. r128 driver: Fixed colormap set problem when server is switched + away (Egbert Eich). + 481. r128 driver Added reinitialization of accel engine after vt switch. + 480. fixed a fg/bg color problem in SiS driver (Egbert Eich). + 479. attempt to address some problems with Cyber LCD chipsets in + Trident driver (Egbert Eich). + 478. tseng driver: Implemented correct MMIO handling (Egbert Eich). + 477. tseng driver: made accel driver multi screen capable (Egbert Eich). + 476. fixed vgaHW driver to use forground color for readability + test of pallette registers. This prevents annoying flashing + screen on server start (Egbert Eich). + 475. added module/font/rgb path parameters to xf86cfg (Egbert Eich). + +XFree86 4.0.1a (2 August 2000) + 474. i810 DRI updates (Jeff Hartmann). + 473. i810 driver updates (H. J. Lu). + 472. Save/restore the text mode colourmap for Solaris, to fix a blank + screen problem on Solaris 8 after exiting the X server (#A.104, + Richard Coley). + 471. Patch for SuperProbe on Linux with devfs (#A.103, Adam J. Richter). + 470. Enable BSD/gcc-2.95.2 workaround for BSD/OS 4.2 (#4072, Kurt Lidl). + 469. Fix a problem with the header symlinks in Xserver/GL/mesa/include/GL + (#4071, Matthieu Herrb). + 468. Finish integrating the SiS DRI driver support (Can-Ru Yeou, SiS). + 467. Change references to the Mesa source directory in Imakefiles to + $(MESASRCDIR) (David Dawes). + 467. Fix a typo an error in the example code in the XtAppAddInput man page + (#4070, Carlos A. M. dos Santos). + 466. Imstt driver updates, including moving from cfb to fb, fixing fbdev + bugs and an accel blit bug, and a general cleanup (#4068, Ani Joshi). + 465. Fix the installation path of the xditview bitmap (#4067, + Carlos A. M. dos Santos). + 464. Some xf86cfg fixes (#4065, 4068, Paulo Cesar Pereira de Andrade). + 463. Fix some syntax errors in xkb config files and a size mismatch between + two xkbcomp structures that were being masked one to another (#4063, + Paulo Cesar Pereira de Andrade). + 462. Fix a problem where the xkbcomp would read junk data from the server + if SmartScheduleTimer() is called while writing to it (#4063, + Paulo Cesar Pereira de Andrade). + 461. Increase MAXVISUALSPERDEPTH further for Xnest so that it will work + with GLX (#4062, Harald Koenig). + 460. Xv overlay support for the Intel i810 chipset (#4061, Jonathan Bian, + Matthew J Sottek, Intel). + 459. Penmount touch panel input driver (#4060, Mayk Langer). + 458. Fix the r128 SaveScreen function so that it doesn't touch the hardware + when switched away (#4056, Benjamin Herrenschmidt). + 457. Add support to xman for FreeBSD's /etc/manpath.config (#4055, + Carlos A M dos Santos). + 456. Update Xinstall.sh to handle the different behaviour of ldconfig + 2.1.3 (used on SuSE 6.4) (#4058, Michael Rohleder). + 455. Fix incorrect use of xf86{En,Dis}ableInterrupts() for ppc + (Marc La France). + 454. Add man pages for pcitweak and scanpci (David Dawes). + 453. Fix problems with xkb "Internet" keyboard mapping support (David Dawes). + 452. A few corrections to PIO and MMIO definitions affecting mips, arm32, + powerpc architectures and QNX4 (Marc La France). + 451. Minor int10 and VBE fixups (Marc La France). + 450. For frequency options, don't clobber the old value before verifying the + new one is valid (Marc La France). + 449. Ensure xf86_ansic.h is always #include'd before compiler.h in code + that can be compiled as a module (even for the static server). Generate + an error if not (Marc La France). + 448. Make linux/int10 module complain when SystemV IPC isn't configured + into the kernel (Marc La France). + 447. Add new offscreen frame bufffer manager functions for managing linear + offscreen areas (Mark Vojkovich). + 446. int10 fixes and remove checksum verification (Marc La France). + 445. More message formatting changes for DDC (Marc La France). + 444. Add missing xf86write symbol (Marc La France). + 443. Fix open(, O_CREAT) emulation (Marc La France). + 442. Fix Trident Cyber9320 > 8bpp modes (Alan Hourihane). + 441. Allow memory mapping during probe phase (Marc La France). + 440. Clean up os-support/dgux/dgux_video.c (Marc La France). + 439. Fix int10 bug that prevented recognition of video BIOS'es that are part + of the system BIOS (Marc La France). + 438. MGA driver warning fix (Marc La France). + 437. An update to change 425 (Marc La France). + 436. More EDID formatting changes (Marc La France). + 435. Fix bug that caused the relocation of PCI I/O bases assigned to multiples + of 0x0100 (but not 0x0400) by the system BIOS (Marc La France). + 434. Add ATI driver to Alpha, and experimentally, to ppc architectures. ppc + support is still known to be incomplete (Marc La France). + 433. For IA64, compile everything, except PEX, that is also compiled for IA32 + (Marc La France). + 432. Fix Cyrix driver for -configure (Alan Hourihane). + 431. Fix Glint PM3 memory detect when only 1MB of videoram (Alan Hourihane). + 430. Fix DAC colour problem and blank out issue in glint driver + (Alan Hourihane). + 429. Add missing clock values to the trident driver (Alan Hourihane). + 428. Fix Glint driver's SaveScreen function (#4057, Michel Danzer). + 427. Convert MGA driver to use fb instead of cfb (Mark Vojkovich). + 426. Rewrite MGA color expansion routines so that pci retries never occur + (Mark Vojkovich). + 425. Make ATI driver tolerate relocation of conflicting resources + (Marc La France). + 424. Make Mach64 FIFO handling available to GATOS (Marc La France). + 423. Fix bug in Mach64 scissor handling (Marc La France). + 422. Implement Mark Vojkovich's suggestions in the ATI driver + (LSB ordering of monochrome data and host transfer burst modes) + (Marc La France). + 421. More fixes to ATI DSP register calculation (Marc La France). + 420. ATI DGA support fixes for VGA Wonder capable adapters and the + setting of the DGA_CONCURRENT_ACCESS flag (Marc La France). + 419. Change imake to generate symbols for the GCC version used to + compile it (Marc La France). + 418. Fix xf1bpp/xf4bpp in trident driver and some planemask problems + (Alan Hourihane). + XFree86 4.0.1 (1 July 2000) 417. Update OpenBSD and NetBSD docs (#4053, Matthieu Herrb). 416. Fix segfault when destroying a GLX context (Kevin Martin). @@ -10804,17 +12113,5 @@ XFree86 3.0 (26 April 1994) - - - - - - - - - - - - -$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1230 2000/07/02 02:35:25 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1485 2000/12/18 15:55:33 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/Imakefile diff -u xc/programs/Xserver/hw/xfree86/Imakefile:3.68 xc/programs/Xserver/hw/xfree86/Imakefile:3.70 --- xc/programs/Xserver/hw/xfree86/Imakefile:3.68 Mon Jun 12 22:28:30 2000 +++ xc/programs/Xserver/hw/xfree86/Imakefile Sat Oct 21 21:51:36 2000 @@ -3,7 +3,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/Imakefile,v 3.68 2000/06/13 02:28:30 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/Imakefile,v 3.70 2000/10/22 01:51:36 dawes Exp $ #include #define IHaveSubdirs @@ -97,10 +97,10 @@ $(XF8_32BPPDIR) $(XF8_16BPPDIR) $(XF24_32BPPDIR) $(SHADOWFBDIR) \ drivers $(LOADERDIR) $(VGAHWDIR) $(FBDEVHWDIR) $(RAMDACDIR) \ $(RACDIR) $(I2CDIR) $(DDCDIR) $(INPUTDIR) $(INT10DIR) parser \ - scanpci doc xf86config $(XF86CFGDIR) $(XF86SETUPDIR) dummylib etc \ + scanpci doc xf86config dummylib $(XF86CFGDIR) $(XF86SETUPDIR) etc \ $(SUPERPROBE) $(DRIVERSDK) $(XF8_32WIDDIR) -#ifndef OS2Architecture +#if !defined(OS2Architecture) && !defined(cygwinArchitecture) XF86CONFIG = XF86Config XF98CONFIG = XF98Config #else Index: xc/programs/Xserver/hw/xfree86/XF86Config.cpp diff -u xc/programs/Xserver/hw/xfree86/XF86Config.cpp:1.10 xc/programs/Xserver/hw/xfree86/XF86Config.cpp:1.13 --- xc/programs/Xserver/hw/xfree86/XF86Config.cpp:1.10 Tue Jun 20 01:08:42 2000 +++ xc/programs/Xserver/hw/xfree86/XF86Config.cpp Mon Dec 11 15:18:01 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/XF86Config.cpp,v 1.10 2000/06/20 05:08:42 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/XF86Config.cpp,v 1.13 2000/12/11 20:18:01 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH XF86Config __filemansuffix__ "Version 4.0.1" "XFree86" +.TH XF86Config __filemansuffix__ "Version 4.0.2" "XFree86" .SH NAME XF86Config - Configuration File for XFree86 .SH DESCRIPTION @@ -516,6 +516,9 @@ .BI "Option \*qNoPM\*q \*q" boolean \*q Disables something to do with power management events. Default: PM enabled on platforms that support it. +.TP 7 +.BI "Option \*qXinerama\*q \*q" boolean \*q +enable or disable XINERAMA extension. Default is disabled. .SH MODULE SECTION The .B Module @@ -1555,20 +1558,31 @@ fbdev(__drivermansuffix__), glide(__drivermansuffix__), glint(__drivermansuffix__), +i128(__drivermansuffix__), i740(__drivermansuffix__), i810(__drivermansuffix__), +imstt(__drivermansuffix__), mga(__drivermansuffix__), neomagic(__drivermansuffix__), nv(__drivermansuffix__), r128(__drivermansuffix__), rendition(__drivermansuffix__), s3virge(__drivermansuffix__), +siliconmotion(__drivermansuffix__), sis(__drivermansuffix__), +sunbw2(__drivermansuffix__), +suncg14(__drivermansuffix__), +suncg3(__drivermansuffix__), +suncg6(__drivermansuffix__), +sunffb(__drivermansuffix__), +sunleo(__drivermansuffix__), +suntcx(__drivermansuffix__), tdfx(__drivermansuffix__), tga(__drivermansuffix__), trident(__drivermansuffix__), tseng(__drivermansuffix__), v4l(__drivermansuffix__), +vesa(__drivermansuffix__), vga(__drivermansuffix__), .br README Index: xc/programs/Xserver/hw/xfree86/XFree86.cpp diff -u xc/programs/Xserver/hw/xfree86/XFree86.cpp:1.2 xc/programs/Xserver/hw/xfree86/XFree86.cpp:1.4 --- xc/programs/Xserver/hw/xfree86/XFree86.cpp:1.2 Thu Jun 15 16:50:02 2000 +++ xc/programs/Xserver/hw/xfree86/XFree86.cpp Mon Dec 11 15:29:50 2000 @@ -1,5 +1,5 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/XFree86.cpp,v 1.2 2000/06/15 20:50:02 dawes Exp $ -.TH XFree86 1 "Version 4.0" "XFree86" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/XFree86.cpp,v 1.4 2000/12/11 20:29:50 dawes Exp $ +.TH XFree86 1 "Version 4.0.2" "XFree86" .SH NAME XFree86 - X11R6 X server .SH SYNOPSIS @@ -304,8 +304,8 @@ .LP Note: refers to the root of the X11 install tree. .SH "SEE ALSO" -X(1), Xserver(1), xdm(1), xinit(1), XF86Config(4/5), xf86config(1), -XF86_SVGA(1), XF86_VGA16(1), XF86_Mono(1), XF86_Accel(1), xvidtune(1) +X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), +XF86Config(__filemansuffix__), xf86config(1), xf86cfg(1), xvidtune(1) .SH AUTHORS .PP For X11R5, \fIXF86 1.2\fP was provided by: Index: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h:3.16 xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h:3.17 --- xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h:3.16 Mon Feb 21 20:00:15 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h Fri Sep 29 04:59:44 2000 @@ -57,21 +57,16 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.16 2000/02/22 01:00:15 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/AsmMacros.h,v 3.17 2000/09/29 08:59:44 eich Exp $ */ #if defined(__GNUC__) -#if defined(linux) && defined(__alpha__) +#if defined(linux) && (defined(__alpha__) || defined(__ia64__)) #define inb _inb #define inw _inw #define inl _inl #define outb(p,v) _outb((v),(p)) #define outw(p,v) _outw((v),(p)) #define outl(p,v) _outl((v),(p)) -#elif defined(linux) && defined(__ia64__) -#include -#include -#include -#include #else #if defined(__sparc__) #ifndef ASI_PL Index: xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c:3.2 xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c:3.3 --- xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c:3.2 Fri Nov 19 08:54:14 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c Fri Aug 11 13:27:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c,v 3.2 1999/11/19 13:54:14 hohndel Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/GLINT.c,v 3.3 2000/08/11 17:27:12 dawes Exp $ */ /* * (c) Copyright 1993,1994 by Dirk Hohndel * @@ -30,11 +30,7 @@ #define PCI_EN 0x80000000 -#ifdef PC98 -static Word Ports[] = {0xCF8, 0xCF9, 0xCFC, 0x000 }; -#else static Word Ports[] = {0xCF8, 0xCFA, 0xCFC, 0x000 }; -#endif #define NUMPORTS (sizeof(Ports)/sizeof(Word)) Index: xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c:3.8 xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c:3.9 --- xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c:3.8 Sat Mar 13 22:21:40 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c Fri Aug 11 13:27:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c,v 3.8 1999/03/14 03:21:40 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/I128.c,v 3.9 2000/08/11 17:27:12 dawes Exp $ */ /* * (c) Copyright 1993,1994 by Robin Cutshaw * @@ -30,11 +30,7 @@ #include "Probe.h" -#ifdef PC98 -static Word Ports[] = {0xCF8, 0xCF9, 0xCFC, 0x000 }; -#else static Word Ports[] = {0xCF8, 0xCFA, 0xCFC, 0x000 }; -#endif #define NUMPORTS (sizeof(Ports)/sizeof(Word)) Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile:3.35 xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile:3.37 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile:3.35 Sat Feb 12 15:45:13 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile Tue Nov 28 15:59:16 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile,v 3.35 2000/02/12 20:45:13 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Imakefile,v 3.37 2000/11/28 20:59:16 dawes Exp $ #if (defined(SVR3Architecture) || defined(SVR4Architecture) || defined(SCOArchitecture)) && !defined(DguxArchitecture) # define OSModule OS_SYSV @@ -69,6 +69,11 @@ # define OSModule OS_Mach #endif #endif + +#if defined(cygwinArchitecture) +#define OSModule OS_cygwin +#endif + #if defined(OS2Architecture) # define OSModule OS_Os2 CCOPTIONS = -Zmts @@ -86,12 +91,12 @@ Cirrus.c Ahead.c ATI.c S3.c AL.c Yamaha.c NCR.c MX.c \ RealTek.c Primus.c Compaq.c HMC.c UMC.c Weitek.c SiS.c \ ARK.c Alliance.c Matrox.c SigmaDesigns.c Intergraphics.c \ - Epson.c Rendition.c + Epson.c Rendition.c SiliconMotion.c SVGA_OBJ = Tseng.o WD.o ChipsTech.o Video7.o Genoa.o Trident.o Oak.o \ Cirrus.o Ahead.o ATI.o S3.o AL.o Yamaha.o NCR.o MX.o \ RealTek.o Primus.o Compaq.o HMC.o UMC.o Weitek.o SiS.o \ ARK.o Alliance.o Matrox.o SigmaDesigns.o Intergraphics.o \ - Epson.o Rendition.o + Epson.o Rendition.o SiliconMotion.o COPROC_SRC = 8514.c ATIMach.c I128.c GLINT.c COPROC_OBJ = 8514.o ATIMach.o I128.o GLINT.o SRCS = Main.c $(SVGA_SRC) $(COPROC_SRC) $(BASE_SRC) Print.c Utils.c $(OS_SRC) Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c:3.28 xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c:3.30 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c:3.28 Sat Mar 13 22:21:41 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c Tue Nov 28 15:59:16 2000 @@ -28,7 +28,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c,v 3.28 1999/03/14 03:21:41 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Main.c,v 3.30 2000/11/28 20:59:16 dawes Exp $ */ #include "Probe.h" #include "PatchLevel.h" @@ -82,6 +82,7 @@ &Alliance_Descriptor, &SigmaDesigns_Descriptor, &Intergraphics_Descriptor, + &SiliconMotion_Descriptor, &CT_Descriptor, /* I think this is screwing people up, so put it last */ NULL }; @@ -350,7 +351,7 @@ { if (score[i] != 0) { - base = (Byte *)(0xC0000+(i<<15)); + base = (Byte *)(unsigned long)(0x0C0000+(i<<15)); } } return(base); @@ -601,7 +602,7 @@ } else { - printf("BIOS Base address = 0x%X\n\n", (int)Bios_Base); + printf("BIOS Base address = 0x%lX\n\n", (long)Bios_Base); } fflush(stdout); } Index: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c:3.13 xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c:3.16 --- xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c:3.13 Sun Mar 28 10:32:21 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c Thu Oct 12 08:00:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c,v 3.13 1999/03/28 15:32:21 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_Linux.c,v 3.16 2000/10/12 12:00:28 tsi Exp $ */ /* * (c) Copyright 1993,1994 by Orest Zborowski * @@ -112,7 +112,11 @@ } close(fd); sprintf(fn, "/dev/tty%d", VT_num); - if ((VT_fd = open(fn, O_RDWR|O_NDELAY, 0)) < 0) + if ((VT_fd = open(fn, O_RDWR|O_NDELAY, 0)) < 0) { + sprintf(fn, "/dev/vc/%d", VT_num); + VT_fd = open(fn, O_RDWR|O_NDELAY, 0); + } + if (VT_fd < 0) { fprintf(stderr, "%s: Could not open VT %s\n", MyName, fn); return(-1); @@ -197,7 +201,11 @@ } #endif - if ((fd = open("/dev/mem", O_RDWR)) < 0) +#if defined(__ia64__) + if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) +#else + if ((fd = open("/dev/mem", O_RDWR)) < 0) +#endif { fprintf(stderr, "%s: Failed to open /dev/mem\n", MyName); return((Byte *)0); @@ -337,8 +345,8 @@ if (tmp != (Word)0xAA55) { fprintf(stderr, - "%s: BIOS sanity check failed, addr=%x\n", - MyName, (int)Base); + "%s: BIOS sanity check failed, addr=%lx\n", + MyName, (long)Base); return(-1); } } Index: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_cygwin.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/SuperProbe/OS_cygwin.c:1.1 --- /dev/null Mon Dec 18 14:29:20 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/OS_cygwin.c Wed Aug 23 16:56:50 2000 @@ -0,0 +1,221 @@ +/* + * (c) Copyright 1998,1999 by Sebastien Marineau + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * OREST ZBOROWSKI BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Orest Zborowski shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Orest Zborowski. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_cygwin.c,v 1.1 2000/08/23 20:56:50 dawes Exp $ + */ + +#include "Probe.h" + +#include +#include +#include +#include +#include +#include +#include + +static int VT_fd = -1; +static int BIOS_fd = -1; + +/* + * OpenVideo -- + * + * Enable access to the installed video hardware. + */ +int OpenVideo() +{ + int fd; + char fn[20]; + + if (geteuid() != 0) { + fprintf(stderr, "%s: Must be run as root\n", MyName); + return(-1); + } + + if ((fd = open("/dev/conin", O_WRONLY, 0)) < 0) { + fprintf(stderr, "%s: Cannot open /dev/conin\n", MyName); + return(-1); + } + + return fd; +} + +/* + * CloseVideo -- + * + * Disable access to the video hardware. + */ +void CloseVideo() +{ + int fd; + + if (VT_fd > 0) { + close(VT_fd); + } +} + +/* + * MapVGA -- + * + * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for + * the process for use in probing memory. + */ +Byte *MapVGA() +{ + return( MapMem(0xA0000,0x10000) ); +} + +Byte *MapMem(address, size) + unsigned long address; + unsigned long size; +{ + int fd; + Byte *base; + + if ((fd = open("/dev/zero", O_RDWR)) < 0) { + fprintf(stderr, "%s: Failed to open /dev/zero\n", MyName); + return((Byte *)0); + } + + base = (Byte *)mmap((void *)0, size, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, (off_t)address); + close(fd); + + if ((long)base == -1) { + fprintf(stderr, "%s: Failed to mmap framebuffer\n", MyName); + return((Byte *)0); + } + + return base; +} + +/* + * UnMapVGA -- + * + * Unmap the VGA memory window. + */ +void UnMapVGA(base) + Byte *base; +{ + UnMapMem(base,0x10000); + return; +} + +void UnMapMem(base,size) + Byte *base; + unsigned long size; +{ + munmap((void *)base, size); + return; +} + +/* + * ReadBIOS -- + * + * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into + * buffer 'Buffer'. + */ +int ReadBIOS(Offset, Buffer, Len) +unsigned Offset; +Byte *Buffer; +int Len; +{ + Word tmp; + Byte *Base = Bios_Base + Offset; + Byte *mybase; + off_t myoffset; + int mysize; + + if (BIOS_fd == -1) { + if ((BIOS_fd = open("/dev/mem", O_RDONLY, 0)) < 0) { + fprintf(stderr, "%s: cannot open /dev/mem\n", MyName); + return(-1); + } + } + + if ((off_t)((off_t)Base & 0x7FFF) != (off_t)0) { + /* + * Sanity check... + */ + (void)lseek(BIOS_fd, (off_t)((off_t)Base & 0xF8000), SEEK_SET); + (void)read(BIOS_fd, &tmp, 2); + if (tmp != (Word)0xAA55) { + fprintf(stderr, "%s: BIOS sanity check failed, addr=%x\n", + MyName, (int)Base); + return(-1); + } + } + + if (lseek(BIOS_fd, (off_t)Base, SEEK_SET) < 0) { + fprintf(stderr, "%s: BIOS seek failed\n", MyName); + return(-1); + } + + if (read(BIOS_fd, Buffer, Len) != Len) { + fprintf(stderr, "%s: BIOS read failed\n", MyName); + return(-1); + } + + return Len; +} + +/* + * EnableIOPort -- + * + * Enable access to 'NumPorts' IO ports listed in array 'Ports'. + */ + +/*ARGSUSED*/ +int EnableIOPorts(NumPorts, Ports) +CONST int NumPorts; +CONST Word *Ports; +{ + return(0); +} + +/* + * DisableIOPort -- + * + * Disable access to 'NumPorts' IO ports listed in array 'Ports'. + */ + +/*ARGSUSED*/ +int DisableIOPorts(NumPorts, Port) +CONST int NumPorts; +CONST Word *Port; +{ + return(0); +} + +/* + * ShortSleep -- + * + * Sleep for the number of milliseconds specified in 'Delay'. + */ +void ShortSleep(Delay) +int Delay; +{ + usleep(Delay * 1000); +} Index: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c:3.9 xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c:3.10 --- xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c:3.9 Sat Mar 13 22:21:42 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c Fri Aug 11 13:27:12 2000 @@ -7,7 +7,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c,v 3.9 1999/03/14 03:21:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.c,v 3.10 2000/08/11 17:27:12 dawes Exp $ */ /* #define DEBUGPCI */ @@ -23,11 +23,7 @@ unsigned int i, j, idx = 0; int func; struct pci_config_reg pcr; -#ifdef PC98 - Word PCI_CtrlIOPorts[] = { 0xCF8, 0xCF9, 0xCFC }; -#else Word PCI_CtrlIOPorts[] = { 0xCF8, 0xCFA, 0xCFC }; -#endif int Num_PCI_CtrlIOPorts = 3; unsigned PCI_DevIOAddrPorts[16*16]; int Num_PCI_DevIOAddrPorts = 16*16; Index: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h:3.35 xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h:3.36 --- xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h:3.35 Sat Feb 12 15:45:13 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h Tue Nov 28 15:59:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h,v 3.35 2000/02/12 20:45:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PCI.h,v 3.36 2000/11/28 20:59:16 dawes Exp $ */ /* * PCI Probe * @@ -224,6 +224,7 @@ #define PCI_VENDOR_ARK 0xEDD8 #define PCI_VENDOR_3DLABS 0x3D3D #define PCI_VENDOR_INTERGRAPHICS 0x10EA +#define PCI_VENDOR_SMI 0x126F /* Matrox */ #define PCI_CHIP_MGA2085PX 0x0518 @@ -384,6 +385,14 @@ /* Intergraphics */ #define PCI_CHIP_INTERG_1680 0x1680 #define PCI_CHIP_INTERG_1682 0x1682 + +/* Silicon Motion */ +#define PCI_CHIP_SMI_910 0x0910 +#define PCI_CHIP_SMI_810 0x0810 +#define PCI_CHIP_SMI_820 0x0820 +#define PCI_CHIP_SMI_710 0x0710 +#define PCI_CHIP_SMI_712 0x0712 +#define PCI_CHIP_SMI_720 0x0720 /* Increase this as required */ #define MAX_DEV_PER_VENDOR 18 Index: xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h:3.26 xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h:3.27 --- xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h:3.26 Wed Mar 8 14:23:25 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h Tue Nov 28 15:59:16 2000 @@ -26,10 +26,10 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h,v 3.26 2000/03/08 19:23:25 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/PatchLevel.h,v 3.27 2000/11/28 20:59:16 dawes Exp $ */ #define VERSION 2 -#define PATCHLEV 22 -#define RELDATE "2000 March 6" +#define PATCHLEV 23 +#define RELDATE "2000 November 28" #define PRINT_VERSION printf("\n%s Version %d.%d (%s)\n", \ MyName,VERSION,PATCHLEV,RELDATE) Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c:3.70 xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c:3.71 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c:3.70 Sat Feb 12 15:45:14 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c Tue Nov 28 15:59:16 2000 @@ -26,7 +26,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c,v 3.70 2000/02/12 20:45:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Print.c,v 3.71 2000/11/28 20:59:16 dawes Exp $ */ #include "Probe.h" @@ -237,6 +237,13 @@ "Intergraphics IGA-1680", "Intergraphics IGA-1682" }, /* Epson */ { "Epson SPC8110" }, +/* Silicon Motion */ { "Silicon Motion (chipset unknown)" + "Silicon Motion SM910 Lynx", + "Silicon Motion SM810 LynxE", + "Silicon Motion SM820 Lynx3D", + "Silicon Motion SM710 LynxEM", + "Silicon Motion SM712 LynxEM+", + "Silicon Motion SM720 Lynx3DM" }, }; static CONST char *Herc_Names[] = @@ -325,6 +332,8 @@ "Matrox G200 built-in DAC w/clock" }, { "SiS", "SiS built-in DAC w/clock" }, + { "SMI", + "Silicon Motion built-in DAC w/clock" }, }; static CONST char *CoProc_Names[NUM_CP_TYPES][CHPS_PER_CPTYPE] = Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h:3.73 xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h:3.77 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h:3.73 Mon Feb 21 20:00:15 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h Wed Dec 6 10:35:05 2000 @@ -26,7 +26,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h,v 3.73 2000/02/22 01:00:15 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Probe.h,v 3.77 2000/12/06 15:35:05 eich Exp $ */ /* * Includes @@ -44,10 +44,9 @@ #include #endif /* MACH386 */ #include -#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__QNX__) || defined(__QNXNTO__) -#if defined(__ia64__) +#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__QNX__) || defined(__QNXNTO__) || defined(__GNU__) +#if defined(__ia64__) || defined(ia64) #include -#include #endif # include #if !(defined(__QNX__) && !defined(__QNXNTO__)) @@ -156,7 +155,7 @@ void waitforretrace __STDCARGS((void)); Bool Excluded __STDCARGS((Range *, Chip_Descriptor *, Bool)); int StrCaseCmp __STDCARGS((char *, char *)); -unsigned int StrToUL __STDCARGS((const char *)); +unsigned long StrToUL __STDCARGS((const char *)); /* * Ident functions @@ -199,6 +198,7 @@ Bool Probe_SigmaDesigns __STDCARGS((int *)); Bool Probe_Intergraphics __STDCARGS((int *)); Bool Probe_Epson __STDCARGS((int *)); +Bool Probe_SiliconMotion __STDCARGS((int *)); /* CoProc */ Bool Probe_8514 __STDCARGS((int *)); Bool Probe_ATIMach __STDCARGS((int *)); @@ -259,6 +259,7 @@ extern Chip_Descriptor ARK_Descriptor; extern Chip_Descriptor SigmaDesigns_Descriptor; extern Chip_Descriptor Intergraphics_Descriptor; +extern Chip_Descriptor SiliconMotion_Descriptor; extern Chip_Descriptor IBM8514_Descriptor; extern Chip_Descriptor ATIMach_Descriptor; @@ -358,8 +359,9 @@ #define DAC_MGAG100 55 /* Matrox G100 integrated DAC */ #define DAC_MGAG200 56 /* Matrox G200 integrated DAC */ #define DAC_SIS 57 /* SiS integrated DAC */ +#define DAC_SMI 58 /* Silicon Motion integrated DAC */ -#define DAC_MAX DAC_SIS /* UPDATE THIS! */ +#define DAC_MAX DAC_SMI /* UPDATE THIS! */ #define DAC_6_8_PROGRAM 0x40 /* RAMDAC programmable for 6/8-bit tables */ #define DAC_8BIT 0x80 /* RAMDAC with 8-bit wide lookup tables */ @@ -429,8 +431,9 @@ #define V_SD 27 #define V_IG 28 #define V_EPSON 29 +#define V_SMI 30 -#define NUM_VENDORS 29 +#define NUM_VENDORS 30 #define CHPS_PER_VENDOR 64 #define CHIP_AHEAD_UNK SVGA_TYPE(V_AHEAD,0) /* Ahead unknown */ @@ -718,6 +721,13 @@ #define CHIP_IG_1680 SVGA_TYPE(V_IG,1) /* Intergraphics IGA-1680 */ #define CHIP_IG_1682 SVGA_TYPE(V_IG,2) /* Intergraphics IGA-1682 */ #define CHIP_EPSON_8110 SVGA_TYPE(V_EPSON,0) /* Epson SPC8110 */ +#define CHIP_SMI_UNK SVGA_TYPE(V_SMI,0) /* SMI unknwon */ +#define CHIP_SMI_910 SVGA_TYPE(V_SMI,1) /* SMI 910 */ +#define CHIP_SMI_810 SVGA_TYPE(V_SMI,2) /* SMI 810 */ +#define CHIP_SMI_820 SVGA_TYPE(V_SMI,3) /* SMI 820 */ +#define CHIP_SMI_710 SVGA_TYPE(V_SMI,4) /* SMI 710 */ +#define CHIP_SMI_712 SVGA_TYPE(V_SMI,5) /* SMI 712 */ +#define CHIP_SMI_720 SVGA_TYPE(V_SMI,6) /* SMI 720 */ /* * Graphics Coprocessors Index: xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c:3.36 xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c:3.37 --- xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c:3.36 Sat Feb 12 15:45:15 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c Tue Nov 28 15:59:16 2000 @@ -30,7 +30,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c,v 3.36 2000/02/12 20:45:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/RamDac.c,v 3.37 2000/11/28 20:59:16 dawes Exp $ */ #include "Probe.h" @@ -1208,6 +1208,11 @@ { if ((Chipset >= CHIP_SIS86C201) && (Chipset <= CHIP_SIS540)) *RamDac = DAC_SIS; + } + else if (SVGA_VENDOR(Chipset) == V_SMI) + { + if ((Chipset >= CHIP_SMI_910) && (Chipset <= CHIP_SMI_720)) + *RamDac = DAC_SMI; } /* * Save current state. Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c:3.2 xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c:3.3 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c:3.2 Fri Nov 19 08:54:16 1999 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c Fri Aug 11 13:27:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c,v 3.2 1999/11/19 13:54:16 hohndel Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Rendition.c,v 3.3 2000/08/11 17:27:12 dawes Exp $ */ /* * (c) Copyright 1997 by Dirk Hohndel * @@ -30,11 +30,7 @@ #define PCI_EN 0x80000000 -#ifdef PC98 -static Word Ports[] = {0xCF8, 0xCF9, 0xCFC, 0x000 }; -#else static Word Ports[] = {0xCF8, 0xCFA, 0xCFC, 0x000 }; -#endif #define NUMPORTS (sizeof(Ports)/sizeof(Word)) Index: xc/programs/Xserver/hw/xfree86/SuperProbe/SiliconMotion.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/SuperProbe/SiliconMotion.c:1.1 --- /dev/null Mon Dec 18 14:29:22 2000 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/SiliconMotion.c Tue Nov 28 15:59:16 2000 @@ -0,0 +1,142 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/SiliconMotion.c,v 1.1 2000/11/28 20:59:16 dawes Exp $ */ +/* + * (c) Copyright 1993,1994 by David Wexelblat + * (c) Copyright 2000 by Silicon Motion + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of David Wexelblat shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from David Wexelblat. + * + */ + +#include "Probe.h" + +static Word Ports[] = {0x000, 0x000}; +#define NUMPORTS (sizeof(Ports)/sizeof(Word)) + +static int MemProbe_SiliconMotion __STDCARGS((int)); + +Chip_Descriptor SiliconMotion_Descriptor = { + "Silicon Motion", + Probe_SiliconMotion, + Ports, + NUMPORTS, + FALSE, + FALSE, + FALSE, + MemProbe_SiliconMotion, +}; + +Bool Probe_SiliconMotion(Chipset) +int *Chipset; +{ + int i = 0; + + if (!NoPCI) + { + while ((pcrp = pci_devp[i]) != (struct pci_config_reg *)NULL) + { + if (pcrp->_vendor == PCI_VENDOR_SMI && pcrp->_status_command & 7) + { + switch (pcrp->_device) + { + case PCI_CHIP_SMI_910: + *Chipset = CHIP_SMI_910; + PCIProbed = TRUE; + break; + + case PCI_CHIP_SMI_810: + *Chipset = CHIP_SMI_810; + PCIProbed = TRUE; + break; + + case PCI_CHIP_SMI_820: + *Chipset = CHIP_SMI_820; + PCIProbed = TRUE; + break; + + case PCI_CHIP_SMI_710: + *Chipset = CHIP_SMI_710; + PCIProbed = TRUE; + break; + + case PCI_CHIP_SMI_712: + *Chipset = CHIP_SMI_712; + PCIProbed = TRUE; + break; + + case PCI_CHIP_SMI_720: + *Chipset = CHIP_SMI_720; + PCIProbed = TRUE; + break; + } + + if (PCIProbed) + { + return(TRUE); + } + } + i++; + } + } + + return(FALSE); +} + +static int MemProbe_SiliconMotion(Chipset) +int Chipset; +{ + Byte config; + int Mem = 0; + + EnableIOPorts(NUMPORTS, Ports); + + config = rdinx(SEQ_IDX, 0x71); + switch (Chipset) + { + case CHIP_SMI_910: + case CHIP_SMI_810: + case CHIP_SMI_710: + case CHIP_SMI_712: + { + int memsize[] = { 1, 2, 4, 0 }; + Mem = memsize[config >> 6] * 1024; + break; + } + + case CHIP_SMI_820: + { + int memsize[] = { 0, 2, 4, 6 }; + Mem = memsize[config >> 6] * 1024 + 512; + break; + } + + case CHIP_SMI_720: + { + int memsize[] = { 16, 2, 4, 8 }; + Mem = memsize[config >> 6] * 1024; + break; + } + } + + DisableIOPorts(NUMPORTS, Ports); + return(Mem); +} Index: xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c diff -u xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c:3.5 xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c:3.7 --- xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c:3.5 Mon Dec 23 01:31:42 1996 +++ xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c Tue Sep 19 08:46:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c,v 3.5 1996/12/23 06:31:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/Utils.c,v 3.7 2000/09/19 12:46:12 eich Exp $ */ /* * (c) Copyright 1993,1994 by David Wexelblat * @@ -510,12 +510,12 @@ return(c1 - c2); } -unsigned int StrToUL(str) +unsigned long StrToUL(str) CONST char *str; { int base = 10; CONST char *p = str; - unsigned int tot = 0; + unsigned long tot = 0; if (*p == '0') { @@ -552,3 +552,4 @@ } return(tot); } + Index: xc/programs/Xserver/hw/xfree86/common/Imakefile diff -u xc/programs/Xserver/hw/xfree86/common/Imakefile:3.117 xc/programs/Xserver/hw/xfree86/common/Imakefile:3.125 --- xc/programs/Xserver/hw/xfree86/common/Imakefile:3.117 Fri Jun 30 13:15:10 2000 +++ xc/programs/Xserver/hw/xfree86/common/Imakefile Wed Dec 6 10:35:06 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.117 2000/06/30 17:15:10 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.125 2000/12/06 15:35:06 eich Exp $ @@ -42,13 +42,18 @@ XKBDDXOBJ = xf86XKB.o #endif +#if BuildDebug + DEBUGSRC = xf86Debug.c + DEBUGOBJ = xf86Debug.o +#endif + #if BuildXInputExt XF86_XINPUT_SRC = xf86Xinput.c xf86Switch.c xisb.c XF86_XINPUT_OBJ = xf86Xinput.o xf86Switch.o xisb.o #endif MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\" -LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XFree86.\" +LOGDEFINES = -DDEFAULT_LOGPREFIX=\"$(LOGDIRECTORY)/XLogFile.\" #if DoLoadableServer EXT_MODULES_DEFINES = $(GLX_DEFINES) @@ -84,6 +89,7 @@ xf86Bus.c \ xf86isaBus.c \ xf86pciBus.c \ + xf86fbBus.c \ xf86IniExt.c \ xf86Config.c \ xf86Cursor.c \ @@ -105,6 +111,7 @@ xf86xv.c \ xf86cmap.c\ xf86PM.c \ + $(DEBUGSRC) \ $(KBD).c \ $(SBUSSRC) \ $(XF86_XINPUT_SRC) \ @@ -118,6 +125,7 @@ xf86Bus.o \ xf86isaBus.o \ xf86pciBus.o \ + xf86fbBus.o \ xf86Config.o \ xf86Cursor.o \ xf86DGA.o \ @@ -137,6 +145,7 @@ xf86xv.o \ xf86cmap.o\ xf86PM.o \ + $(DEBUGOBJ) \ $(SBUSOBJ) \ $(XF86_XINPUT_OBJ) \ $(XKBDDXOBJ) \ @@ -160,7 +169,15 @@ OSNAME = OSName OSVENDOR = OSVendor - OSNAMEDEF = -DOSNAME='"$(OSNAME)"' -DOSVENDOR='"$(OSVENDOR)"' + OSNAMEDEF = -DOSNAME='" $(OSNAME)"' -DOSVENDOR='" $(OSVENDOR)"' +#if defined(XFree86CustomVersion) +CUSTOMVERSION = XFree86CustomVersion + CUSTOMVERDEF = -DXF86_CUSTOM_VERSION='$(CUSTOMVERSION)' +#endif +#if defined(BuilderString) + BUILDERSTRING = BuilderString + BUILDERMSG = -DBUILDERSTRING='$(BUILDERSTRING)' +#endif CONSDEFINES = XFree86ConsoleDefines EXP_DEFINES = -DEXPIRY_TIME=XF86ServerExpiry $(EXP_FORCE_DEFINES) PROJECTROOT = ProjectRoot @@ -169,20 +186,19 @@ XCONFIGDEFINES = -DPROJECTROOT='"$(PROJECTROOT)"' \ -DDRIVERS='"$(DRIVERS)"' \ -DIDRIVERS='"$(IDRIVERS)"' - -#if defined(SunArchitecture) && defined(SVR4Architecture) && OSMinorVersion >= 8 - OSDEFINES = -DSOL8 -#endif +XF86CONFIGFILE = XConfigFile +XCONFIGUREDEFINES = -DXF86CONFIGFILE='"$(XF86CONFIGFILE)"' DEFINES = $(CONSDEFINES) $(KBDDEFINES) $(EXT_DEFINES) $(OSDEFINES) AllTarget($(OFILES)) -SpecialCObjectRule(xf86Bus,NullParameter,$(VGAINCLUDES)) -SpecialCObjectRule(xf86Init,$(ICONFIGFILES),$(OSNAMEDEF) $(EXT_DEFINES) $(BETADEFS)) +SpecialCObjectRule(xf86Bus,NullParameter,$(BUGMSG) $(VGAINCLUDES)) +SpecialCObjectRule(xf86Init,$(ICONFIGFILES),$(OSNAMEDEF) $(BUILDERMSG) $(BUGMSG) $(CUSTOMVERDEF) $(EXT_DEFINES) $(BETADEFS)) SpecialCObjectRule(xf86Events,$(ICONFIGFILES),$(EXT_DEFINES)) SpecialCObjectRule(xf86Globals,$(ICONFIGFILES),$(EXT_DEFINES) $(MODPATHDEFINES) $(LOGDEFINES)) SpecialCObjectRule(xf86Config,$(ICONFIGFILES),$(XCONFIGDEFINES)) +SpecialCObjectRule(xf86Configure,$(ICONFIGFILES),$(XCONFIGUREDEFINES)) #if NeedXF86Beta SpecialCObjectRule($(BETAOBJ),NullParameter,$(EXP_DEFINES)) Index: xc/programs/Xserver/hw/xfree86/common/atKeynames.h diff -u xc/programs/Xserver/hw/xfree86/common/atKeynames.h:3.13 xc/programs/Xserver/hw/xfree86/common/atKeynames.h:3.15 --- xc/programs/Xserver/hw/xfree86/common/atKeynames.h:3.13 Wed Feb 9 17:00:05 2000 +++ xc/programs/Xserver/hw/xfree86/common/atKeynames.h Fri Aug 11 19:59:48 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.13 2000/02/09 22:00:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.15 2000/08/11 23:59:48 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -69,8 +69,6 @@ * ---------------- ---------- ------- ------ ------ */ -#ifndef PC98 - #define KEY_Escape /* Escape 0x01 */ 1 #define KEY_1 /* 1 ! 0x02 */ 2 #define KEY_2 /* 2 @ 0x03 */ 3 @@ -194,117 +192,9 @@ #define KEY_F16 /* F16 0x71 */ 113 #define KEY_F17 /* F17 0x72 */ 114 #define KEY_KP_DEC /* KP_DEC 0x73 */ 115 - -#else - -#define KEY_Escape /* Escape 0x01 */ 0 -#define KEY_1 /* 1 ! 0x02 */ 1 -#define KEY_2 /* 2 " 0x03 */ 2 -#define KEY_3 /* 3 # 0x04 */ 3 -#define KEY_4 /* 4 $ 0x05 */ 4 -#define KEY_5 /* 5 % 0x06 */ 5 -#define KEY_6 /* 6 & 0x07 */ 6 -#define KEY_7 /* 7 ' 0x08 */ 7 -#define KEY_8 /* 8 ( 0x09 */ 8 -#define KEY_9 /* 9 ) 0x0a */ 9 -#define KEY_0 /* 0 0x0b */ 10 -#define KEY_Minus /* - (Minus) = (Equal) 0x0c */ 11 -#define KEY_Hat /* ^ (Hat) ` 0x0d */ 12 -#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 13 -#define KEY_BackSpace /* Back Space 0x0e */ 14 -#define KEY_Tab /* Tab 0x0f */ 15 -#define KEY_Q /* Q 0x10 */ 16 -#define KEY_W /* W 0x11 */ 17 -#define KEY_E /* E 0x12 */ 18 -#define KEY_R /* R 0x13 */ 19 -#define KEY_T /* T 0x14 */ 20 -#define KEY_Y /* Y 0x15 */ 21 -#define KEY_U /* U 0x16 */ 22 -#define KEY_I /* I 0x17 */ 23 -#define KEY_O /* O 0x18 */ 24 -#define KEY_P /* P 0x19 */ 25 -#define KEY_At /* @ ~ 0x1a */ 26 -#define KEY_LBrace /* [ { 0x1b */ 27 -#define KEY_Enter /* Enter 0x1c */ 28 -#define KEY_A /* A 0x1d */ 29 -#define KEY_S /* S 0x1e */ 30 -#define KEY_D /* D 0x1f */ 31 -#define KEY_F /* F 0x20 */ 32 -#define KEY_G /* G 0x21 */ 33 -#define KEY_H /* H 0x22 */ 34 -#define KEY_J /* J 0x23 */ 35 -#define KEY_K /* K 0x24 */ 36 -#define KEY_L /* L 0x25 */ 37 -#define KEY_SemiColon /* ;(SemiColon) +(Plus) 0x26 */ 38 -#define KEY_Colon /* :(Colon) *(Quote) 0x27 */ 39 -#define KEY_RBrace /* ] } 0x28 */ 40 -#define KEY_Z /* Z 0x29 */ 41 -#define KEY_X /* X 0x2a */ 42 -#define KEY_C /* C 0x2b */ 43 -#define KEY_V /* V 0x2c */ 44 -#define KEY_B /* B 0x2d */ 45 -#define KEY_N /* N 0x2e */ 46 -#define KEY_M /* M 0x2f */ 47 -#define KEY_Comma /* , (Comma) < (Less) 0x30 */ 48 -#define KEY_Period /* . (Period) >(Greater)0x31 */ 49 -#define KEY_Slash /* / (Slash) ? 0x32 */ 50 -#define KEY_Under /* _ 0x33 */ 51 -#define KEY_Space /* (SpaceBar) 0x34 */ 52 -#define KEY_Xfer /* (XFER) 0x35 */ 53 -#define KEY_PgUp /* PgUp 0x36 */ 54 -#define KEY_Pgdown /* (Roll Down) 0x37 */ 55 -#define KEY_Insert /* Insert 0x38 */ 56 -#define KEY_Delete /* Delete 0x39 */ 57 -#define KEY_Up /* Up 0x3a */ 58 -#define KEY_Left /* Left 0x3b */ 59 -#define KEY_Right /* Right 0x3c */ 60 -#define KEY_Down /* Down 0x3d */ 61 -#define KEY_Home /* Home 0x3e */ 62 -#define KEY_Help /* Help 0x3f */ 63 -#define KEY_KP_Subtract /* - (Minus) 0x40 */ 64 -#define KEY_KP_Minus /* - */ 64 -#define KEY_KP_Divide /* / (Slash) 0x41 */ 65 -#define KEY_KP_7 /* 7 0x42 */ 66 -#define KEY_KP_8 /* 8 0x43 */ 67 -#define KEY_KP_9 /* 9 0x44 */ 68 -#define KEY_KP_Multiply /* * 0x45 */ 69 -#define KEY_KP_4 /* 4 0x46 */ 70 -#define KEY_KP_5 /* 5 0x47 */ 71 -#define KEY_KP_6 /* 6 0x48 */ 72 -#define KEY_KP_Add /* + (Plus) 0x49 */ 73 -#define KEY_KP_Plus /* + */ 73 -#define KEY_KP_1 /* 1 0x4a */ 74 -#define KEY_KP_2 /* 2 0x4b */ 75 -#define KEY_KP_3 /* 3 0x4c */ 76 -#define KEY_KP_Equal /* = 0x4d */ 77 -#define KEY_KP_0 /* 0 0x4e */ 78 -#define KEY_KP_Separator /* , 0x4f */ 79 -#define KEY_KP_Decimal /* . (Decimal) 0x50 */ 80 -#define KEY_Nfer /* (NFER) 0x51 */ 81 -#define KEY_F11 /* F11 0x52 */ 82 -#define KEY_F12 /* F12 0x53 */ 83 -#define KEY_F13 /* F13 0x54 */ 84 -#define KEY_F14 /* F14 0x55 */ 85 -#define KEY_F15 /* F15 0x56 */ 86 -#define KEY_Break /* (Stop) 0x60 */ 96 -#define KEY_Copy /* (Copy) 0x61 */ 97 -#define KEY_Begin /* Begin ?? */ 97 -#define KEY_F1 /* F1 0x62 */ 98 -#define KEY_F2 /* F2 0x63 */ 99 -#define KEY_F3 /* F3 0x64 */ 100 -#define KEY_F4 /* F4 0x65 */ 101 -#define KEY_F5 /* F5 0x66 */ 102 -#define KEY_F6 /* F6 0x67 */ 103 -#define KEY_F7 /* F7 0x68 */ 104 -#define KEY_F8 /* F8 0x69 */ 105 -#define KEY_F9 /* F9 0x6a */ 106 -#define KEY_F10 /* F10 0x6b */ 107 -#define KEY_ShiftL /* Shift(left) 0x70 */ 112 -#define KEY_CapsLock /* CapsLock 0x71 */ 113 -#define KEY_KanaLock /* Kana 0x72 */ 114 -#define KEY_Alt /* Alt(left) 0x73 */ 115 -#define KEY_LCtrl /* Ctrl(left) 0x74 */ 116 -#endif /* PC98 */ +/* These are for "notused" and "uknown" entries in translation maps. */ +#define KEY_NOTUSED 0 +#define KEY_UNKNOWN 255 #endif /* _ATKEYNAMES_H */ Index: xc/programs/Xserver/hw/xfree86/common/compiler.h diff -u xc/programs/Xserver/hw/xfree86/common/compiler.h:3.62 xc/programs/Xserver/hw/xfree86/common/compiler.h:3.76 --- xc/programs/Xserver/hw/xfree86/common/compiler.h:3.62 Sun Jun 25 08:35:53 2000 +++ xc/programs/Xserver/hw/xfree86/common/compiler.h Thu Dec 7 10:43:40 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.62 2000/06/25 12:35:53 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.76 2000/12/07 15:43:40 tsi Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -24,6 +24,11 @@ /* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */ #ifndef _COMPILER_H + +#if !defined(_XF86_ANSIC_H) && defined(XFree86Module) +# error missing #include "xf86_ansic.h" before #include "compiler.h" +#endif + #define _COMPILER_H #ifndef __STDC__ @@ -40,14 +45,8 @@ # ifdef __GNUC__ # define volatile __volatile__ # define const __const__ -# ifdef PC98 -# undef NO_INLINE -# endif # else # define const /**/ -# ifdef PC98 -# define __inline__ /**/ -# endif # ifdef __HIGHC__ # define __inline__ _Inline # endif @@ -356,6 +355,10 @@ #endif } +/* to flush the I-cache before jumping to code which just got loaded */ +#define PAL_imb 134 +#define istream_mem_barrier() \ + __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") #define mem_barrier() __asm__ __volatile__("mb" : : : "memory") #ifdef __ELF__ #define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory") @@ -365,20 +368,63 @@ #elif defined(linux) && defined(__ia64__) -#define inline __inline__ -#include -#include -#include +#include + #include -#include - -#define ldq_u(p) __uldq(p) -#define ldl_u(p) __uldl(p) -#define ldw_u(p) __uldw(p) -#define stq_u(v,p) __ustq(v,p) -#define stl_u(v,p) __ustl(v,p) -#define stw_u(v,p) __ustw(v,p) + +struct __una_u64 { uint64_t x __attribute__((packed)); }; +struct __una_u32 { uint32_t x __attribute__((packed)); }; +struct __una_u16 { uint16_t x __attribute__((packed)); }; + +extern __inline__ unsigned long +__uldq (const unsigned long * r11) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +} + +extern __inline__ unsigned long +__uldl (const unsigned int * r11) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +} + +extern __inline__ unsigned long +__uldw (const unsigned short * r11) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +} + +extern __inline__ void +__ustq (unsigned long r5, unsigned long * r11) +{ + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +} + +extern __inline__ void +__ustl (unsigned long r5, unsigned int * r11) +{ + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +} + +extern __inline__ void +__ustw (unsigned long r5, unsigned short * r11) +{ + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +} + +#define ldq_u(p) __uldq(p) +#define ldl_u(p) __uldl(p) +#define ldw_u(p) __uldw(p) +#define stq_u(v,p) __ustq(v,p) +#define stl_u(v,p) __ustl(v,p) +#define stw_u(v,p) __ustw(v,p) #define mem_barrier() __asm__ __volatile__ ("mf" ::: "memory") #define write_mem_barrier() __asm__ __volatile__ ("mf" ::: "memory") @@ -398,19 +444,24 @@ #define ASI_PL 0x88 #endif +#define barrier() __asm__ __volatile__(".word 0x8143e00a": : :"memory") + static __inline__ void outb(unsigned long port, unsigned char val) { __asm__ __volatile__("stba %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); } static __inline__ void outw(unsigned long port, unsigned short val) { __asm__ __volatile__("stha %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); } static __inline__ void outl(unsigned long port, unsigned int val) { __asm__ __volatile__("sta %0, [%1] %2" : : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); } static __inline__ unsigned int inb(unsigned long port) @@ -434,6 +485,156 @@ return ret; } +static __inline__ unsigned char xf86ReadMmio8(void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned char ret; + + __asm__ __volatile__("lduba [%1] %2, %0" : "=r" (ret) : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned short xf86ReadMmio16Be(void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduh [%1], %0" : "=r" (ret) : "r" (addr)); + return ret; +} + +static __inline__ unsigned short xf86ReadMmio16Le(void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduha [%1] %2, %0" : "=r" (ret) : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int xf86ReadMmio32Be(void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("ld [%1], %0" : "=r" (ret) : "r" (addr)); + return ret; +} + +static __inline__ unsigned int xf86ReadMmio32Le(void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("lda [%1] %2, %0" : "=r" (ret) : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ void xf86WriteMmio8(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void xf86WriteMmio16Be(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void xf86WriteMmio16Le(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void xf86WriteMmio32Be(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void xf86WriteMmio32Le(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void xf86WriteMmio8NB(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void xf86WriteMmio16BeNB(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void xf86WriteMmio16LeNB(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void xf86WriteMmio32BeNB(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void xf86WriteMmio32LeNB(void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + #endif /* !Lynx */ /* @@ -546,7 +747,7 @@ static __inline__ void outl(unsigned short port, unsigned int val) { - *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; + *(volatile unsigned int*)(((unsigned short)(port))+IOPortBase) = val; } static __inline__ unsigned int @@ -564,7 +765,7 @@ static __inline__ unsigned int inl(unsigned short port) { - return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); + return(*(volatile unsigned int*)(((unsigned short)(port))+IOPortBase)); } @@ -628,7 +829,7 @@ #define write_mem_barrier() /* NOP */ #endif /* __arm32__ */ -#elif (defined(Lynx) || defined(linux)) && defined(__powerpc__) +#elif (defined(Lynx) || defined(linux) || defined(__OpenBSD__)) && defined(__powerpc__) #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) @@ -647,7 +848,7 @@ "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -660,7 +861,7 @@ "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -673,7 +874,7 @@ "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -686,7 +887,7 @@ "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } @@ -699,63 +900,63 @@ "eieio" : "=r" (val) : "b" (base), "r" (offset), - "m" (*(volatile unsigned char *)(base+offset))); + "m" (*((volatile unsigned char *)base+offset))); return(val); } static __inline__ void xf86WriteMmioNB8(void *base, const unsigned long offset, - const unsigned int val) + const unsigned char val) { __asm__ __volatile__( "stbx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } static __inline__ void xf86WriteMmioNB16Le(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { __asm__ __volatile__( "sthbrx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } static __inline__ void xf86WriteMmioNB16Be(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { __asm__ __volatile__( "sthx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } static __inline__ void xf86WriteMmioNB32Le(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { __asm__ __volatile__( "stwbrx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } static __inline__ void xf86WriteMmioNB32Be(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { __asm__ __volatile__( "stwx %1,%2,%3\n\t" - : "=m" (*(volatile unsigned char *)(base+offset)) + : "=m" (*((volatile unsigned char *)base+offset)) : "r" (val), "b" (base), "r" (offset)); } static __inline__ void xf86WriteMmio8(void *base, const unsigned long offset, - const unsigned int val) + const unsigned char val) { xf86WriteMmioNB8(base,offset,val); eieio(); @@ -763,7 +964,7 @@ static __inline__ void xf86WriteMmio16Le(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { xf86WriteMmioNB16Le(base,offset,val); eieio(); @@ -771,7 +972,7 @@ static __inline__ void xf86WriteMmio16Be(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { xf86WriteMmioNB16Be(base,offset,val); eieio(); @@ -779,7 +980,7 @@ static __inline__ void xf86WriteMmio32Le(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { xf86WriteMmioNB32Le(base,offset,val); eieio(); @@ -787,7 +988,7 @@ static __inline__ void xf86WriteMmio32Be(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { xf86WriteMmioNB32Be(base,offset,val); eieio(); @@ -873,7 +1074,6 @@ * If gcc uses gas rather than the native assembler, the syntax of these * inlines has to be different. DHD */ -#ifndef PC98 static __inline__ void outb(unsigned short port, unsigned char val) @@ -924,245 +1124,6 @@ return ret; } -#else /* PC98 */ - -static __inline__ void -_outb(unsigned short port, unsigned char val) -{ - __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port)); -} - -static __inline__ void -_outw(unsigned short port, unsigned short val) -{ - __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port)); -} - -static __inline__ void -_outl(unsigned short port, unsigned int val) -{ - __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); -} - - -static __inline__ unsigned int -_inb(unsigned short port) -{ - unsigned char ret; - __asm__ __volatile__("inb %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -_inw(unsigned short port) -{ - unsigned char ret; - __asm__ __volatile__("inw %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -_inl(unsigned short port) -{ - unsigned int ret; - __asm__ __volatile__("inl %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - - -#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) -#define PW_PORT 0x600 -extern short chipID; -extern void *mmioBase; -extern unsigned short _port_tbl[]; -#define port_convert(x) _port_tbl[(unsigned short)x] -#endif - -#if defined(PC98_WAB) || defined(PC98_GANB_WAP) -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE0; - return port; -} -#endif /* PC98_WAB || PC98_GANB_WAP */ - -#if defined(PC98_WABEP) -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port &= 0x7f; /* Mask 0000 0000 0111 1111 */ - port |= 0x0f00; - return port; -} -#endif /* PC98_WABEP */ - -#ifdef PC98_WSNA -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE2; - return port; -} -#endif /* PC98_WSNA */ - -#ifdef PC98_NKVNEC -#ifdef PC98_NEC_CIRRUS2 -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; - return port; -} -#else -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; - return port; -} -#endif /* PC98_NEC_CIRRUS2 */ -#endif /* PC98_NKVNEC */ - -#if defined(PC98_TGUI) -extern void *mmioBase; -#endif - -static __inline__ void -outb(unsigned short port, unsigned char val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); -#else - __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ void -outw(unsigned short port, unsigned short val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); -#else - __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ void -outl(unsigned short port, unsigned int val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); -#else - __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ unsigned int -inb(unsigned short port) -{ - unsigned char ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned char *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inb %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -static __inline__ unsigned int -inw(unsigned short port) -{ - unsigned short ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned short *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inw %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -static __inline__ unsigned int -inl(unsigned short port) -{ - unsigned int ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned int *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inl %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -#endif /* PC98 */ - #else /* GCCUSESGAS */ static __inline__ void @@ -1300,10 +1261,10 @@ extern void debug_outb(unsigned int a, unsigned char b, int line, char *file); extern void debug_outw(unsigned int a, unsigned short w, int line, char *file); -extern void debug_outl(unsigned int a, unsigned long l, int line, char *file); +extern void debug_outl(unsigned int a, unsigned int l, int line, char *file); extern unsigned char debug_inb(unsigned int a, int line, char *file); extern unsigned short debug_inw(unsigned int a, int line, char *file); -extern unsigned long debug_inl(unsigned int a, int line, char *file); +extern unsigned int debug_inl(unsigned int a, int line, char *file); #define outb(a,b) debug_outb(a,b, __LINE__, __FILE__) #define outw(a,w) debug_outw(a,w, __LINE__, __FILE__) @@ -1316,7 +1277,7 @@ extern unsigned char inb(unsigned int a); extern unsigned short inw(unsigned int a); -extern unsigned long inl(unsigned int a); +extern unsigned int inl(unsigned int a); # if PPCIO_INLINE @@ -1327,8 +1288,8 @@ # else /* !PPCIO_INLINE */ extern void outb(unsigned int a, unsigned char b); -extern void outw(unsigned int a, unsigned char w); -extern void outl(unsigned int a, unsigned char l); +extern void outw(unsigned int a, unsigned short w); +extern void outl(unsigned int a, unsigned int l); # endif /* PPCIO_INLINE */ @@ -1351,7 +1312,6 @@ # endif # endif # endif -# ifndef PC98 # ifndef SCO325 # if defined(USL) # if defined(IN_MODULE) @@ -1370,278 +1330,7 @@ # else # include "scoasm.h" # endif -# else -#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) -#define PW_PORT 0x600 -extern short chipID; -extern void *mmioBase; -extern unsigned short _port_tbl[]; -#define port_convert(x) _port_tbl[(unsigned short)x] -#endif - -asm void _outl(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outl (%dx) -%reg port; mem val; - movl port, %edx - movl val, %eax - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outl (%dx) -%mem port,val; - movw port, %dx - movl val, %eax - outl (%dx) -} - -asm void _outw(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - data16 - outl (%dx) -%reg port; mem val; - movl port, %edx - movw val, %ax - data16 - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - data16 - outl (%dx) -%mem port,val; - movw port, %dx - movw val, %ax - data16 - outl (%dx) -} - -asm void _outb(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outb (%dx) -%reg port; mem val; - movl port, %edx - movb val, %al - outb (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outb (%dx) -%mem port,val; - movw port, %dx - movb val, %al - outb (%dx) -} - -asm int _inl(port) -{ -%reg port; - movl port, %edx - inl (%dx) -%mem port; - movw port, %dx - inl (%dx) -} - -asm int _inw(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - data16 - inl (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - data16 - inl (%dx) -} - -asm int _inb(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - inb (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - inb (%dx) -} - -#if defined(PC98_WAB) || defined(PC98_GANB_WAP) -static unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE0; - return port; -} -#endif /* PC98_WAB || PC98_GANB_WAP */ - -#if defined(PC98_WABEP) -static unsigned short -port_convert(unsigned short port) -{ - port &= 0x7f; /* Mask 0000 0000 0111 1111 */ - port |= 0x0f00; - return port; -} -#endif /* PC98_WABEP */ - -#ifdef PC98_WSNA -static unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE2; - return port; -} -#endif /* PC98_WSNA */ - -#ifdef PC98_NKVNEC -#ifdef PC98_NEC_CIRRUS2 -static unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; - return port; -} -#else -static unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; - return port; -} -#endif /* PC98_NEC_CIRRUS2 */ -#endif /* PC98_NKVNEC */ - -static void outl(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); -#else - _outl(port,val); -#endif -} - -static void outw(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); -#else - _outw(port,val); -#endif -} - -static void outb(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); -#else - _outb(port,val); -#endif -} -static int inl(port) -{ - unsigned int ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned int *)((char *)mmioBase+(port)); -#else - ret = _inl(port); -#endif - return ret; -} - -static int inw(port) -{ - unsigned short ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned short *)((char *)mmioBase+(port)); -#else - ret = _inw(port); -#endif - return ret; -} - -static int inb(port) -{ - unsigned char ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned char *)((char *)mmioBase+(port)); -#else - ret = _inb(port); -#endif - return ret; -} - - -# endif /* PC98 */ # if !defined(__HIGHC__) && !defined(SCO325) # pragma asm partial_optimization outl # pragma asm partial_optimization outw @@ -1691,7 +1380,7 @@ #undef outl #define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) #define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) -#define inl(a) __extension__ ({unsigned long __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +#define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) #define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b)) #define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b)) @@ -1806,59 +1495,144 @@ #endif /* NO_INLINE */ -/* Some macros to hide the system dependencies for MMIO accesses */ #ifdef __alpha__ +/* entry points for Mmio memory access routines */ +extern int (*xf86ReadMmio8)(void *, unsigned long); +extern int (*xf86ReadMmio16)(void *, unsigned long); +extern int (*xf86ReadMmio32)(void *, unsigned long); +extern void (*xf86WriteMmio8)(int, void *, unsigned long); +extern void (*xf86WriteMmio16)(int, void *, unsigned long); +extern void (*xf86WriteMmio32)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB8)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB16)(int, void *, unsigned long); +extern void (*xf86WriteMmioNB32)(int, void *, unsigned long); +extern void xf86JensenMemToBus(char *, long, long, int); +extern void xf86JensenBusToMem(char *, char *, unsigned long, int); +extern void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int); +extern void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int); +/* Some macros to hide the system dependencies for MMIO accesses */ +/* Changed to kill noise generated by gcc's -Wcast-align */ #define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset) #define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset) # if defined (JENSEN_SUPPORT) #define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset) -#define MMIO_OUT32(base, offset, val) (*xf86WriteMmio32)(val, base, offset) -#define MMIO_ONB32(base, offset, val) (*xf86WriteMmioNB32)(val, base, offset) +#define MMIO_OUT32(base, offset, val) \ + (*xf86WriteMmio32)((CARD32)(val), base, offset) +#define MMIO_ONB32(base, offset, val) \ + (*xf86WriteMmioNB32)((CARD32)(val), base, offset) # else #define MMIO_IN32(base, offset) \ - *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) -#define MMIO_OUT32(base, offset, val) do { \ - *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) = (val);\ - write_mem_barrier();\ - } while (0) + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_OUT32(base, offset, val) \ + do { \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \ + write_mem_barrier(); \ + } while (0) #define MMIO_ONB32(base, offset, val) \ - *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) = (val) + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) # endif -#define MMIO_OUT8(base, offset, val) (*xf86WriteMmio8)(val, base, offset) -#define MMIO_OUT16(base, offset, val) (*xf86WriteMmio16)(val, base, offset) -#define MMIO_ONB8(base, offset, val) (*xf86WriteMmioNB8)(val, base, offset) -#define MMIO_ONB16(base, offset, val) (*xf86WriteMmioNB16)(val, base, offset) +#define MMIO_OUT8(base, offset, val) \ + (*xf86WriteMmio8)((CARD8)(val), base, offset) +#define MMIO_OUT16(base, offset, val) \ + (*xf86WriteMmio16)((CARD16)(val), base, offset) +#define MMIO_ONB8(base, offset, val) \ + (*xf86WriteMmioNB8)((CARD8)(val), base, offset) +#define MMIO_ONB16(base, offset, val) \ + (*xf86WriteMmioNB16)((CARD16)(val), base, offset) #elif defined(__powerpc__) /* * we provide byteswapping and no byteswapping functions here * with byteswapping as default, * drivers that don't need byteswapping should define PPC_MMIO_IS_BE */ - #define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) - #define MMIO_OUT8(base, offset, val) xf86WriteMmio8(base, offset, val) - #define MMIO_ONB8(base, offset, val) xf86WriteMmioNB8(base, offset, val) - #if defined(PPC_MMIO_IS_BE) /* No byteswapping */ - #define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) - #define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) - #define MMIO_OUT16(base, offset, val) xf86WriteMmio16Be(base, offset, val) - #define MMIO_OUT32(base, offset, val) xf86WriteMmio32Be(base, offset, val) - #define MMIO_ONB16(base, offset, val) xf86WriteMmioNB16Be(base, offset, val) - #define MMIO_ONB32(base, offset, val) xf86WriteMmioNB32Be(base, offset, val) - #else /* byteswapping is the default */ - #define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) - #define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) - #define MMIO_OUT16(base, offset, val) xf86WriteMmio16Le(base, offset, val) - #define MMIO_OUT32(base, offset, val) xf86WriteMmio32Le(base, offset, val) - #define MMIO_ONB16(base, offset, val) xf86WriteMmioNB16Le(base, offset, val) - #define MMIO_ONB32(base, offset, val) xf86WriteMmioNB32Le(base, offset, val) - #endif -#else /* !__alpha__ && !__powerpc__ */ -#define MMIO_IN8(base, offset) *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) -#define MMIO_IN16(base, offset) *(volatile CARD16 *)(((CARD8*)(base)) + (offset)) -#define MMIO_IN32(base, offset) *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) -#define MMIO_OUT8(base, offset, val) *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) -#define MMIO_OUT16(base, offset, val) *(volatile CARD16 *)(((CARD8*)(base)) + (offset)) = (val) -#define MMIO_OUT32(base, offset, val) *(volatile CARD32 *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmioNB8(base, offset, (CARD8)(val)) +# if defined(PPC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Be(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Be(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Le(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Le(base, offset, (CARD32)(val)) +# endif +static __inline__ void ppc_flush_icache(char *addr) +{ + __asm__ volatile ( + "dcbf 0,%0;" + "sync;" + "icbi 0,%0;" + "sync;" + "isync;" + : : "r"(addr) : "memory"); +} + +#elif defined(__sparc__) + /* + * Like powerpc, we provide byteswapping and no byteswapping functions + * here with byteswapping as default, drivers that don't need byteswapping + * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we + * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places + * of drivers?). + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmio8NB(base, offset, (CARD8)(val)) +# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16BeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32BeNB(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16LeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32LeNB(base, offset, (CARD32)(val)) +# endif +#else /* !__alpha__ && !__powerpc__ && !__sparc__ */ +#define MMIO_IN8(base, offset) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN16(base, offset) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +#define MMIO_OUT8(base, offset, val) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT16(base, offset, val) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +#define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) #define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val) #define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val) #define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val) Index: xc/programs/Xserver/hw/xfree86/common/xf86.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86.h:3.140 xc/programs/Xserver/hw/xfree86/common/xf86.h:3.147 --- xc/programs/Xserver/hw/xfree86/common/xf86.h:3.140 Tue Jun 20 01:08:43 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86.h Thu Dec 7 15:26:19 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.140 2000/06/20 05:08:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.147 2000/12/07 20:26:19 dawes Exp $ */ /* * Copyright (c) 1997 by The XFree86 Project, Inc. @@ -36,7 +36,12 @@ extern const unsigned char byte_reversed[256]; extern PropertyPtr *xf86RegisteredPropertiesTable; extern ScrnInfoPtr xf86CurrentScreen; - +extern Bool pciSlotClaimed; +extern Bool isaSlotClaimed; +extern Bool fbSlotClaimed; +#ifdef __sparc__ +extern Bool sbusSlotClaimed; +#endif #define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr)) #define XF86FLIP_PIXELS() \ @@ -77,7 +82,9 @@ resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex); int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); int xf86GetIsaInfoForScreen(int scrnIndex); +int xf86GetFbInfoForScreen(int scrnIndex); Bool xf86ParseIsaBusString(const char *busID); +int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); void xf86EnableAccess(ScrnInfoPtr pScrn); void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn); Bool xf86IsPrimaryPci(pciVideoPtr pPci); @@ -177,6 +184,8 @@ int xf86RemoveInputHandler(pointer handler); void xf86DisableInputHandler(pointer handler); void xf86EnableInputHandler(pointer handler); +void xf86InterceptSignals(int *signo); +Bool xf86EnableVTSwitch(Bool new); /* xf86Helper.c */ @@ -223,6 +232,7 @@ void (*ProtectRegs)(ScrnInfoPtr, Bool), void (*BlankScreen)(ScrnInfoPtr, Bool), int vertsyncreg, int maskval, int knownclkindex, int knownclkvalue); +void xf86SetPriority(Bool up); const char *xf86GetVisualName(int visual); int xf86GetVerbosity(void); Pix24Flags xf86GetPix24(void); @@ -234,6 +244,7 @@ Bool xf86ServerIsExiting(void); Bool xf86ServerIsResetting(void); Bool xf86ServerIsInitialising(void); +Bool xf86ServerIsOnlyDetecting(void); Bool xf86ServerIsOnlyProbing(void); Bool xf86CaughtSignal(void); Bool xf86GetVidModeAllowNonLocal(void); @@ -244,27 +255,11 @@ Bool xf86IsPc98(void); pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name); pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name); +pointer xf86LoadOneModule(char *name, pointer optlist); void xf86UnloadSubModule(pointer mod); Bool xf86LoaderCheckSymbol(const char *name); void xf86LoaderReqSymLists(const char **, ...); void xf86LoaderReqSymbols(const char *, ...); -/* debugging */ - void xf86Break1(void); -void xf86Break2(void); -void xf86Break3(void); -CARD8 xf86PeekFb8(CARD8 *p); -CARD16 xf86PeekFb16(CARD16 *p); -CARD32 xf86PeekFb32(CARD32 *p); -void xf86PokeFb8(CARD8 *p, CARD8 v); -void xf86PokeFb16(CARD16 *p, CARD16 v); -void xf86PokeFb32(CARD16 *p, CARD32 v); -CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset); -CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset); -CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset); -void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v); -void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v); -void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v); - void xf86SetBackingStore(ScreenPtr pScreen); void xf86SetSilkenMouse(ScreenPtr pScreen); int xf86NewSerialNumber(WindowPtr p, pointer unused); @@ -281,6 +276,10 @@ resList res, EntityProc init, EntityProc enter, EntityProc leave, pointer private); +ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); /* Obsolete! don't use */ Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,PciChipsets *p_chip, @@ -301,13 +300,36 @@ resList res, EntityProc init, EntityProc enter, EntityProc leave, pointer private); +void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); Bool xf86IsScreenPrimary(int scrnIndex); int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, int format, unsigned long len, pointer value); Bool xf86IsUnblank(int mode); - +/* xf86Debug.c */ +#ifdef BUILDDEBUG + void xf86Break1(void); +void xf86Break2(void); +void xf86Break3(void); +CARD8 xf86PeekFb8(CARD8 *p); +CARD16 xf86PeekFb16(CARD16 *p); +CARD32 xf86PeekFb32(CARD32 *p); +void xf86PokeFb8(CARD8 *p, CARD8 v); +void xf86PokeFb16(CARD16 *p, CARD16 v); +void xf86PokeFb32(CARD16 *p, CARD32 v); +CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset); +CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset); +CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset); +void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v); +void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v); +void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v); +extern void xf86SPTimestamp(xf86TsPtr* timestamp, char* string); +extern void xf86STimestamp(xf86TsPtr* timestamp); +#endif + /* xf86Init.c */ PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth); Index: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Bus.c:1.52 xc/programs/Xserver/hw/xfree86/common/xf86Bus.c:1.56 --- xc/programs/Xserver/hw/xfree86/common/xf86Bus.c:1.52 Fri Jun 30 13:15:10 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Bus.c Wed Dec 6 10:35:07 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.52 2000/06/30 17:15:10 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.56 2000/12/06 15:35:07 eich Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. */ @@ -65,6 +65,7 @@ /* Flag: do we need RAC ? */ static Bool needRAC = FALSE; +static Bool doFramebufferMode = FALSE; /* state change notification callback list */ static StateChangeNotificationPtr StateChangeNotificationList; @@ -418,6 +419,7 @@ pEnt->devices = xnfrealloc(pEnt->devices, pEnt->numInstances * sizeof(GDevPtr)); pEnt->devices[pEnt->numInstances - 1] = dev; + dev->claimed = TRUE; } /* @@ -606,6 +608,19 @@ } /* + * xf86AccessRestoreState() - Restore the access registers to the + * state before X was started. This is handy for framebuffers. + */ +void +xf86AccessRestoreState(void) +{ + if (!xf86ResAccessEnter) + return; + PciStateLeave(); + PciBusStateLeave(); +} + +/* * xf86EnableAccess() -- enable access to controlled resources. * To reduce latency when switching access the ScrnInfoRec has * a linked list of the EntityAccPtr of all screen entities. @@ -879,9 +894,14 @@ switch (pRes->res_type & ResExtMask) { case ResBlock: if (range->rBegin < pRes->block_end && - range->rEnd > pRes->block_begin) + range->rEnd > pRes->block_begin) { +#ifdef DEBUG + ErrorF("b-b conflict w: %lx %lx\n", + pRes->block_begin,pRes->block_end); +#endif return pRes->block_end < range->rEnd ? - pRes->block_end : range->rEnd; + pRes->block_end : range->rEnd; + } return 0; case ResSparse: if (pRes->sparse_base > range->rEnd) return 0; @@ -906,6 +926,8 @@ if (tmp >= range->rBegin) { #ifdef DEBUG ErrorF("conflict found at: 0x%lx\n",tmp); + ErrorF("b-d conflict w: %lx %lx\n", + pRes->sparse_base,pRes->sparse_mask); #endif return tmp; } @@ -930,8 +952,13 @@ switch (pRes->res_type & ResExtMask) { case ResSparse: tmp = pRes->sparse_mask & range->rMask; - if ((tmp & pRes->sparse_base) == (tmp & range->rBase)) + if ((tmp & pRes->sparse_base) == (tmp & range->rBase)) { +#ifdef DEBUG + ErrorF("s-b conflict w: %lx %lx\n", + pRes->sparse_base,pRes->sparse_mask); +#endif return pRes->sparse_mask; + } return 0; case ResBlock: @@ -973,6 +1000,8 @@ } #ifdef DEBUG ErrorF("conflict found at: 0x%lx\n",tmp); + ErrorF("b-b conflict w: %lx %lx\n", + pRes->block_begin,pRes->block_end); #endif return ~m_mask; } @@ -1277,13 +1306,13 @@ xf86ErrorFVerb(verb, "%s", s); switch (list->res_type & ResExtMask) { case ResBlock: - s = "B"; + s = "[B]"; break; case ResSparse: - s = "S"; + s = "[S]"; break; default: - s = "?"; + s = "[?]"; } xf86ErrorFVerb(verb, "%s", s); if (list->res_type & ResEstimated) @@ -1792,6 +1821,7 @@ * setAccess() -- sets access functions according to resources * required. */ + static void setAccess(EntityPtr pEnt, xf86State state) { @@ -2055,6 +2085,9 @@ else ErrorF("Entering OPERATING state\n"); #endif + /* When servicing a dump framebuffer we don't need to do anything */ + if (doFramebufferMode) return; + for (i=0; ientityList[pScrn->numEntities - 1]; @@ -2206,12 +2239,12 @@ { FatalError("A driver tried to allocate the %s %sresource at \n" "0x%x:0x%x which conflicted with another resource. Send the\n" - "output of the server to xfree86@xfree86.org. Please \n" + "output of the server to %s. Please \n" "specify your computer hardware as closely as possible.\n", ResIsBlock(list)?"Block":"Sparse", ResIsMem(list)?"Mem":"Io", ResIsBlock(list)?list->rBegin:list->rBase, - ResIsBlock(list)?list->rEnd:list->rMask); + ResIsBlock(list)?list->rEnd:list->rMask,BUILDERADDR); } /* @@ -2351,6 +2384,24 @@ int i,j; resPtr resp, acc, tmp, resp_x, *pprev_next; + if (fbSlotClaimed) { + if (pciSlotClaimed || isaSlotClaimed +#ifdef __sparc__ + || sbusSlotClaimed +#endif + ) { + FatalError("Cannot run in framebuffer mode. Please specify busIDs " + " for all framebuffer devices\n"); + return; + } else { + xf86Msg(X_INFO,"Running in FRAMEBUFFER Mode\n"); + xf86AccessRestoreState(); + notifyStateChange(NOTIFY_ENABLE); + doFramebufferMode = TRUE; + + return; + } + } /* don't compare against ResInit - remove it from clone.*/ acc = tmp = xf86DupResList(Acc); pprev_next = &acc; @@ -2480,6 +2531,8 @@ void xf86PostPreInit() { + if (doFramebufferMode) return; + if (xf86NumScreens > 1) needRAC = TRUE; @@ -2506,9 +2559,13 @@ ScreenPtr pScreen; unsigned int flags; int nummem = 0, numio = 0; - #ifdef XFree86LOADER pointer xf86RACInit = NULL; +#endif + + if (doFramebufferMode) return; + +#ifdef XFree86LOADER if (needRAC) { xf86RACInit = LoaderSymbol("xf86RACInit"); if (!xf86RACInit) @@ -2914,6 +2971,34 @@ /* if no VGA device is found check for primary PCI device */ if (primaryBus.type == BUS_NONE) CheckGenericGA(); + if (primaryBus.type != BUS_NONE) { + char *bus; + char *loc = xnfcalloc(1,8); + if (loc == NULL) return; + + switch (primaryBus.type) { + case BUS_PCI: + bus = "PCI"; + sprintf(loc,"%2.2x:%2.2x:%1.1x",primaryBus.id.pci.bus, + primaryBus.id.pci.device,primaryBus.id.pci.func); + break; + case BUS_ISA: + bus = "ISA"; + loc[0] = '\0'; + break; + case BUS_SBUS: + bus = "SBUS"; + sprintf(loc,"%2.2x",primaryBus.id.sbus.fbNum); + break; + default: + bus = ""; + loc[0] = '\0'; + } + + xf86MsgVerb(X_INFO, 2, "Primary Device is: %s %s\n",bus,loc); + xfree(loc); + } + } #include "vgaHW.h" Index: xc/programs/Xserver/hw/xfree86/common/xf86Config.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Config.c:3.226 xc/programs/Xserver/hw/xfree86/common/xf86Config.c:3.236 --- xc/programs/Xserver/hw/xfree86/common/xf86Config.c:3.226 Tue Jun 20 01:08:43 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Config.c Wed Dec 6 10:35:07 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.226 2000/06/20 05:08:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.236 2000/12/06 15:35:07 eich Exp $ */ /* @@ -41,7 +41,7 @@ #if (defined(i386) || defined(__i386__)) && \ (defined(__FreeBSD__) || defined(__NetBSD__) || defined(linux) || \ - (defined(SVR4) && !defined(sun))) + (defined(SVR4) && !defined(sun)) || defined(__GNU__)) #define SUPPORT_PC98 #endif @@ -692,7 +692,8 @@ FLAG_PIXMAP, FLAG_PC98, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, - FLAG_NOPM + FLAG_NOPM, + FLAG_XINERAMA } FlagValues; static OptionInfoRec FlagOptions[] = { @@ -742,6 +743,8 @@ {0}, FALSE }, { FLAG_NOPM, "NoPM", OPTV_BOOLEAN, {0}, FALSE }, + { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN, + {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -770,6 +773,7 @@ int i; Pix24Flags pix24 = Pix24DontCare; Bool value; + MessageType from; if(flagsconf == NULL) return TRUE; @@ -779,11 +783,11 @@ */ optp = NULL; if (flagsconf->flg_option_lst) - optp = OptionListDup(flagsconf->flg_option_lst); + optp = xf86optionListDup(flagsconf->flg_option_lst); if (layoutopts) { - tmp = OptionListDup(layoutopts); + tmp = xf86optionListDup(layoutopts); if (optp) - optp = OptionListMerge(optp, tmp); + optp = xf86optionListMerge(optp, tmp); else optp = tmp; } @@ -912,6 +916,18 @@ } #endif +#ifdef PANORAMIX + from = X_DEFAULT; + if (!noPanoramiXExtension) + from = X_CMDLINE; + else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) { + noPanoramiXExtension = !value; + from = X_CONFIG; + } + if (!noPanoramiXExtension) + xf86Msg(from, "Xinerama: enabled\n"); +#endif + return TRUE; } @@ -941,11 +957,7 @@ #ifdef XKB if (!xf86IsPc98()) { xf86Info.xkbrules = "xfree86"; -#ifdef SOL8 - xf86Info.xkbmodel = "pc101_sol8x86"; -#else xf86Info.xkbmodel = "pc101"; -#endif xf86Info.xkblayout = "us"; xf86Info.xkbvariant = NULL; xf86Info.xkboptions = NULL; @@ -969,7 +981,7 @@ s = xf86SetStrOption(inputp->commonOptions, "Protocol", "standard"); if (xf86NameCmp(s, "standard") == 0) { xf86Info.kbdProc = xf86KbdProc; -#ifdef AMOEBA +#if defined(AMOEBA) || defined(__CYGWIN__) xf86Info.kbdEvents = NULL; #else xf86Info.kbdEvents = xf86KbdEvents; @@ -980,6 +992,20 @@ xf86Info.kbdEvents = xf86XqueEvents; xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n"); #endif +#ifdef WSCONS_SUPPORT + } else if (xf86NameCmp(s, "wskbd") == 0) { + int xf86WSKbdProc(DeviceIntPtr, int); + + xf86Info.kbdProc = xf86WSKbdProc; + xf86Info.kbdEvents = xf86KbdEvents; + s = xf86SetStrOption(inputp->commonOptions, "Device", NULL); + xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n"); + xf86Info.kbdFd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + if (xf86Info.kbdFd == -1) { + xf86ConfigError("cannot open \"%s\"", s); + return FALSE; + } +#endif } else { xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s); return FALSE; @@ -1131,7 +1157,7 @@ } if (!havePointer) { if (xf86PointerName) { - confInput = xf86FindInput(xf86PointerName, + confInput = xf86findInput(xf86PointerName, xf86configptr->conf_input_lst); if (!confInput) { xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", @@ -1141,10 +1167,10 @@ from = X_CMDLINE; } else { from = X_DEFAULT; - confInput = xf86FindInput(CONF_IMPLICIT_POINTER, + confInput = xf86findInput(CONF_IMPLICIT_POINTER, xf86configptr->conf_input_lst); if (!confInput && implicitLayout) { - confInput = xf86FindInputByDriver("mouse", + confInput = xf86findInputByDriver("mouse", xf86configptr->conf_input_lst); } } @@ -1153,7 +1179,7 @@ } if (!haveKeyboard) { if (xf86KeyboardName) { - confInput = xf86FindInput(xf86KeyboardName, + confInput = xf86findInput(xf86KeyboardName, xf86configptr->conf_input_lst); if (!confInput) { xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", @@ -1163,10 +1189,10 @@ from = X_CMDLINE; } else { from = X_DEFAULT; - confInput = xf86FindInput(CONF_IMPLICIT_KEYBOARD, + confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD, xf86configptr->conf_input_lst); if (!confInput && implicitLayout) { - confInput = xf86FindInputByDriver("keyboard", + confInput = xf86findInputByDriver("keyboard", xf86configptr->conf_input_lst); } } @@ -1177,7 +1203,7 @@ count++; indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec)); indp[count - 1] = Pointer; - indp[count - 1].extraOptions = addNewOption(NULL, "CorePointer", NULL); + indp[count - 1].extraOptions = xf86addNewOption(NULL, "CorePointer", NULL); indp[count].identifier = NULL; servlayoutp->inputs = indp; } else if (!havePointer) { @@ -1191,7 +1217,7 @@ count++; indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec)); indp[count - 1] = Keyboard; - indp[count - 1].extraOptions = addNewOption(NULL, "CoreKeyboard", NULL); + indp[count - 1].extraOptions = xf86addNewOption(NULL, "CoreKeyboard", NULL); indp[count].identifier = NULL; servlayoutp->inputs = indp; } else if (!haveKeyboard) { @@ -1241,7 +1267,7 @@ from = X_CONFIG; } if (xf86LayoutName != NULL) { - if ((l = xf86FindLayout(xf86LayoutName, conf_layout)) == NULL) { + if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) { xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n", xf86LayoutName); return FALSE; @@ -1343,6 +1369,13 @@ slp[i].right = slp[j].screen; } } + if (slp[i].where != CONF_ADJ_OBSOLETE + && slp[i].where != CONF_ADJ_ABSOLUTE + && !slp[i].refscreen) { + xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n", + slp[i].refname); + slp[i].where = 0; + } } #ifdef LAYOUT_DEBUG @@ -1437,17 +1470,6 @@ servlayoutp->inputs = indp; servlayoutp->options = conf_layout->lay_option_lst; from = X_DEFAULT; -#ifdef PANORAMIX - if (!noPanoramiXExtension) - from = X_CMDLINE; - else if (xf86FindOption(conf_layout->lay_option_lst, "Xinerama")) { - noPanoramiXExtension = - !xf86SetBoolOption(conf_layout->lay_option_lst, "Xinerama", FALSE); - from = X_CONFIG; - } - if (!noPanoramiXExtension) - xf86Msg(from, "Xinerama: enabled\n"); -#endif if (!checkCoreInputDevices(servlayoutp, FALSE)) return FALSE; @@ -1483,7 +1505,7 @@ from = X_CONFIG; if (xf86ScreenName != NULL) { - if ((s = xf86FindScreen(xf86ScreenName, conf_screen)) == NULL) { + if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) { xf86Msg(X_ERROR, "No Screen section called \"%s\"\n", xf86ScreenName); return FALSE; @@ -1657,16 +1679,24 @@ */ while(modeslnk) { - modes = xf86FindModes (modeslnk->ml_modes_str, + modes = xf86findModes (modeslnk->ml_modes_str, xf86configptr->conf_modes_lst); modeslnk->ml_modes = modes; + /* now add the modes found in the modes section to the list of modes for this - monitor */ - conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr) - addListItem((GenericListPtr)conf_monitor->mon_modeline_lst, - (GenericListPtr)modes->mon_modeline_lst); + monitor unless it has been added before + because we are reusing the same section + for another screen */ + if (xf86itemNotSublist( + (GenericListPtr)conf_monitor->mon_modeline_lst, + (GenericListPtr)modes->mon_modeline_lst)) { + conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr) + xf86addListItem( + (GenericListPtr)conf_monitor->mon_modeline_lst, + (GenericListPtr)modes->mon_modeline_lst); + } modeslnk = modeslnk->list.next; } @@ -1755,7 +1785,7 @@ return -1; for (i = 0; i <= DirectColor; i++) { - if (!NameCompare(visname, xf86VisualNames[i])) + if (!xf86nameCompare(visname, xf86VisualNames[i])) break; } @@ -2003,7 +2033,7 @@ if (xf86ConfigFile) from = X_CMDLINE; - filename = xf86OpenConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); + filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); if (filename) { xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); } else { @@ -2013,11 +2043,11 @@ xf86ErrorFVerb(0, "\n"); return FALSE; } - if ((xf86configptr = xf86ReadConfigFile ()) == NULL) { + if ((xf86configptr = xf86readConfigFile ()) == NULL) { xf86Msg(X_ERROR, "Problem parsing the config file\n"); return FALSE; } - xf86CloseConfigFile (); + xf86closeConfigFile (); /* Initialise a few things. */ @@ -2116,12 +2146,12 @@ Bool xf86PathIsAbsolute(const char *path) { - return (PathIsAbsolute(path) != 0); + return (xf86pathIsAbsolute(path) != 0); } Bool xf86PathIsSafe(const char *path) { - return (PathIsSafe(path) != 0); + return (xf86pathIsSafe(path) != 0); } Index: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Configure.c:3.39 xc/programs/Xserver/hw/xfree86/common/xf86Configure.c:3.49 --- xc/programs/Xserver/hw/xfree86/common/xf86Configure.c:3.39 Fri Jun 23 07:01:51 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Configure.c Tue Dec 12 13:23:50 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.39 2000/06/23 11:01:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.49 2000/12/12 18:23:50 tsi Exp $ */ /* * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales. * @@ -116,6 +116,7 @@ { int i, j; pciVideoPtr pVideo = NULL; + Bool isPrimary = FALSE; if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1) return NULL; @@ -130,6 +131,7 @@ (DevToConfig[i].pVideo->device == pVideo->device) && (DevToConfig[i].pVideo->func == pVideo->func)) return NULL; + isPrimary = xf86IsPrimaryPci(pVideo); break; case BUS_ISA: /* @@ -138,6 +140,7 @@ */ if (!xf86IsPrimaryIsa()) return NULL; + isPrimary = TRUE; for (i = 0; i < nDevToConfig; i++) if (!DevToConfig[i].pVideo) return NULL; @@ -158,6 +161,13 @@ i = nDevToConfig++; DevToConfig = xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); +#if 0 /* Doesn't work when a driver detects more than one adapter */ + if (i > 0 && isPrimary) { + memmove(DevToConfig + 1,DevToConfig, + (nDevToConfig - 1) * sizeof(DevToConfigRec)); + i = 0; + } +#endif memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); # define NewDevice DevToConfig[i] @@ -291,10 +301,10 @@ mouse->inp_identifier = "Mouse0"; mouse->inp_driver = "mouse"; mouse->inp_option_lst = - addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO); + xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO); mouse->inp_option_lst = - addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV); - ptr = (XF86ConfInputPtr)addListItem((glp)ptr, (glp)mouse); + xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV); + ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse); return ptr; } @@ -321,7 +331,7 @@ configureScreenSection (int screennum) { int i; - int depths[] = { 1, 4, 8, 15, 16, 24 }; + int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ }; parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) ptr->scrn_identifier = xf86confmalloc(18); @@ -331,14 +341,17 @@ ptr->scrn_device_str = xf86confmalloc(16); sprintf(ptr->scrn_device_str, "Card%d", screennum); - for (i=0; i<6; i++) + for (i=0; idisp_depth = depths[i]; - ptr->scrn_display_lst = (XF86ConfDisplayPtr)addListItem( + display->disp_black.red = display->disp_white.red = -1; + display->disp_black.green = display->disp_white.green = -1; + display->disp_black.blue = display->disp_white.blue = -1; + ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem( (glp)ptr->scrn_display_lst, (glp)display); } @@ -413,7 +426,7 @@ memset((XF86OptionPtr)fbdev,0,sizeof(XF86OptionRec)); fbdev->opt_name = "UseFBDev"; fbdev->opt_val = "ON"; - ptr->dev_option_lst = (XF86OptionPtr)addListItem( + ptr->dev_option_lst = (XF86OptionPtr)xf86addListItem( (glp)ptr->dev_option_lst, (glp)fbdev); } */ @@ -439,9 +452,9 @@ iptr->iref_option_lst = NULL; iptr->iref_inputdev_str = "Mouse0"; iptr->iref_option_lst = - addNewOption (iptr->iref_option_lst, "CorePointer", NULL); + xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) - addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); } { @@ -452,9 +465,9 @@ iptr->iref_option_lst = NULL; iptr->iref_inputdev_str = "Keyboard0"; iptr->iref_option_lst = - addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL); + xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) - addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); } for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { @@ -477,7 +490,7 @@ sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1); } ptr->lay_adjacency_lst = - (XF86ConfAdjacencyPtr)addListItem((glp)ptr->lay_adjacency_lst, + (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst, (glp)aptr); } @@ -533,7 +546,7 @@ module = xf86confmalloc(sizeof(XF86LoadRec)); memset((XF86LoadPtr)module,0,sizeof(XF86LoadRec)); module->load_name = *el; - ptr->mod_load_lst = (XF86LoadPtr)addListItem( + ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem( (glp)ptr->mod_load_lst, (glp)module); } xfree(elist); @@ -549,12 +562,12 @@ parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) #ifdef XFree86LOADER - if (xf86ModulePath && xf86ModPathFrom == X_CMDLINE) + if (xf86ModulePath) ptr->file_modulepath = strdup(xf86ModulePath); #endif - if (xf86fpFlag && defaultFontPath) + if (defaultFontPath) ptr->file_fontpath = strdup(defaultFontPath); - if (xf86coFlag && rgbPath) + if (rgbPath) ptr->file_rgbpath = strdup(rgbPath); return ptr; @@ -674,13 +687,13 @@ XF86ConfScreenPtr ScreenPtr; DevicePtr = configureDeviceSection(screennum); - xf86config->conf_device_lst = (XF86ConfDevicePtr)addListItem( + xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem( (glp)xf86config->conf_device_lst, (glp)DevicePtr); MonitorPtr = configureMonitorSection(screennum); - xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)addListItem( + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); ScreenPtr = configureScreenSection(screennum); - xf86config->conf_screen_lst = (XF86ConfScreenPtr)addListItem( + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); } @@ -688,9 +701,9 @@ xf86config->conf_modules = configureModuleSection(); xf86config->conf_flags = configureFlagsSection(); xf86config->conf_videoadaptor_lst = configureVideoAdaptorSection(); - xf86config->conf_modes_lst = configureModesSection(); +/* xf86config->conf_modes_lst = configureModesSection(); */ xf86config->conf_vendor_lst = configureVendorSection(); -/* xf86config->conf_dri = configureDRISection();*/ +/* xf86config->conf_dri = configureDRISection(); */ xf86config->conf_input_lst = configureInputSection(); xf86config->conf_layout_lst = configureLayoutSection(); @@ -700,22 +713,22 @@ #ifdef __EMX__ #define PATH_MAX 2048 #endif + const char* configfile = XF86CONFIGFILE".new"; char homebuf[PATH_MAX]; /* getenv might return R/O memory, as with OS/2 */ strncpy(homebuf,home,PATH_MAX-1); homebuf[PATH_MAX-1] = '\0'; home = homebuf; - if (!(filename = (char *)ALLOCATE_LOCAL(strlen(home) + - strlen("XF86Config.new") + 3))) + strlen(configfile) + 3))) if (home[0] == '/' && home[1] == '\0') home[0] = '\0'; - sprintf(filename, "%s/XF86Config.new", home); + sprintf(filename, "%s/%s", home,configfile); } - xf86WriteConfigFile(filename, xf86config); + xf86writeConfigFile(filename, xf86config); xf86DoConfigurePass1 = FALSE; /* Try to get DDC information filled in */ @@ -725,17 +738,22 @@ } xf86DoConfigurePass1 = FALSE; - - i = -1; - for (screennum = 0; screennum < nDevToConfig; screennum++) { - if (i == DevToConfig[screennum].iDriver) continue; - - i = DevToConfig[screennum].iDriver; + + { + Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool)); + for (screennum = 0; screennum < nDevToConfig; screennum++) { + i = DevToConfig[screennum].iDriver; + + if (driverProbed[i]) continue; + driverProbed[i] = TRUE; - (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0); + (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0); - xf86SetPciVideo(NULL,NONE); + xf86SetPciVideo(NULL,NONE); + } + xfree(driverProbed); } + if (nDevToConfig != xf86NumScreens) { ErrorF("Number of created screens does not match number of detected" @@ -750,9 +768,9 @@ xf86Screens[j]->scrnIndex = j; } - freeMonitorList(xf86config->conf_monitor_lst); + xf86freeMonitorList(xf86config->conf_monitor_lst); xf86config->conf_monitor_lst = NULL; - freeScreenList(xf86config->conf_screen_lst); + xf86freeScreenList(xf86config->conf_screen_lst); xf86config->conf_screen_lst = NULL; for (j = 0; j < xf86NumScreens; j++) { XF86ConfMonitorPtr MonitorPtr; @@ -768,13 +786,13 @@ MonitorPtr = configureMonitorSection(j); } ScreenPtr = configureScreenSection(j); - xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)addListItem( + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); - xf86config->conf_screen_lst = (XF86ConfScreenPtr)addListItem( + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); } - xf86WriteConfigFile(filename, xf86config); + xf86writeConfigFile(filename, xf86config); ErrorF("\n"); Index: xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c:1.4 xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c:1.5 --- xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c:1.4 Sun Jun 20 01:23:29 1999 +++ xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c Tue Sep 19 08:46:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c,v 1.4 1999/06/20 05:23:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DPMS.c,v 1.5 2000/09/19 12:46:13 eich Exp $ */ /* * Copyright (c) 1997-1998 by The XFree86 Project, Inc. @@ -39,6 +39,8 @@ DPMSGeneration = serverGeneration; } + if (DPMSDisabledSwitch) + DPMSEnabled = FALSE; if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1))) return FALSE; @@ -47,11 +49,19 @@ pDPMS->Flags = flags; DPMSOpt = xf86FindOption(xf86Screens[pScreen->myNum]->options, "dpms"); if (DPMSOpt) { - pDPMS->Enabled = TRUE; - DPMSEnabled = TRUE; + if (pDPMS->Enabled + = xf86SetBoolOption(xf86Screens[pScreen->myNum]->options, + "dpms",FALSE) + && !DPMSDisabledSwitch) + DPMSEnabled = TRUE; xf86MarkOptionUsed(DPMSOpt); xf86DrvMsg(pScreen->myNum, X_CONFIG, "DPMS enabled\n"); - } else { + } else if (DPMSEnabledSwitch) { + if (!DPMSDisabledSwitch) + DPMSEnabled = TRUE; + pDPMS->Enabled = TRUE; + } + else { pDPMS->Enabled = FALSE; } pDPMS->CloseScreen = pScreen->CloseScreen; Index: xc/programs/Xserver/hw/xfree86/common/xf86Debug.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/common/xf86Debug.c:1.3 --- /dev/null Mon Dec 18 14:29:37 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Debug.c Tue Sep 26 11:57:08 2000 @@ -0,0 +1,96 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Debug.c,v 1.3 2000/09/26 15:57:08 tsi Exp $ */ + +#include +#include +#include "X.h" +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "compiler.h" + +void xf86Break1(void) +{ +} + +void xf86Break2(void) +{ +} + +void xf86Break3(void) +{ +} + +CARD32 xf86DummyVar1; +CARD32 xf86DummyVar2; +CARD32 xf86DummyVar3; + +CARD8 xf86PeekFb8(CARD8 *p) { return *p; } +CARD16 xf86PeekFb16(CARD16 *p) { return *p; } +CARD32 xf86PeekFb32(CARD32 *p) { return *p; } +void xf86PokeFb8(CARD8 *p, CARD8 v) { *p = v; } +void xf86PokeFb16(CARD16 *p, CARD16 v) { *p = v; } +void xf86PokeFb32(CARD16 *p, CARD32 v) { *p = v; } + +CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset) +{ + return MMIO_IN8(Base,Offset); +} + +CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset) +{ + return MMIO_IN16(Base,Offset); +} + +CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset) +{ + return MMIO_IN32(Base,Offset); +} + +void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v) +{ + MMIO_OUT8(Base,Offset,v); +} + +void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v) +{ + MMIO_OUT16(Base,Offset,v); +} + +void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v) +{ + MMIO_OUT32(Base,Offset,v); +} + + +void +xf86STimestamp(xf86TsPtr* timestamp) +{ + if (*timestamp) { + gettimeofday((struct timeval*)*timestamp,NULL); + } else { + *timestamp = xnfalloc(sizeof(xf86TsRec)); + gettimeofday((struct timeval*)*timestamp,NULL); + } +} + +void +xf86SPTimestamp(xf86TsPtr* timestamp, char *str) +{ + if (*timestamp) { + long diff; + struct timeval ts; + ts = **(struct timeval**)timestamp; + gettimeofday((struct timeval*)*timestamp,NULL); + if (ts.tv_usec > (*timestamp)->usec) + diff = ((*timestamp)->sec - ts.tv_sec - 1) * 1000 + + (ts.tv_usec - (*timestamp)->usec) / 1000; + else + diff = ((*timestamp)->sec - ts.tv_sec) * 1000 + +(- ts.tv_usec + (*timestamp)->usec) / 1000; + ErrorF("%s Elapsed: %i\n",str,diff); + } else { + *timestamp = xnfalloc(sizeof(xf86TsRec)); + gettimeofday((struct timeval*)*timestamp,NULL); + } +} Index: xc/programs/Xserver/hw/xfree86/common/xf86Events.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Events.c:3.94 xc/programs/Xserver/hw/xfree86/common/xf86Events.c:3.104 --- xc/programs/Xserver/hw/xfree86/common/xf86Events.c:3.94 Thu May 18 19:21:33 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Events.c Thu Dec 7 15:32:54 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.94 2000/05/18 23:21:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.104 2000/12/07 20:32:54 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -31,12 +31,12 @@ #include "compiler.h" -#include "Xpoll.h" #include "xf86.h" #include "xf86Priv.h" #define XF86_OS_PRIVS #include "xf86_OSlib.h" #include "atKeynames.h" +#include "Xpoll.h" #ifdef XFreeXDGA @@ -115,7 +115,10 @@ #ifdef USE_VT_SYSREQ static Bool VTSysreqToggle = FALSE; #endif /* !USE_VT_SYSREQ */ -static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for *BSD */ +static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for + *BSD and for avoiding VT + switches when using the DRI + automatic full screen mode.*/ extern fd_set EnabledDevices; @@ -296,7 +299,7 @@ extern u_char SpecialServerMap[]; #endif /* ASSUME_CUSTOM_KEYCODES */ -#if !defined(__EMX__) && !defined(SOL8) +#if !defined(__EMX__) && !defined(__SOL8__) && !defined(__CYGWIN__) void xf86PostKbdEvent(unsigned key) { @@ -339,7 +342,7 @@ goto special; #endif /* __sparc__ */ -#if defined (i386) && defined (SVR4) && !defined (PC98) +#if defined (i386) && defined (SVR4) /* * PANIX returns DICOP standards based keycodes in using 106jp * keyboard. We need to remap some keys. @@ -374,8 +377,6 @@ if (xf86Info.scanPrefix == 0) { switch (scanCode) { - -#ifndef PC98 case KEY_Prefix0: case KEY_Prefix1: #if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) @@ -388,11 +389,9 @@ } break; #endif -#endif /* not PC98 */ } } -#ifndef PC98 else if ( #ifdef CSRG_BASED (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS @@ -458,7 +457,6 @@ if (scanCode != KEY_NumLock) return; scanCode = KEY_Pause; /* pause */ } -#endif /* not PC98 */ #endif /* !ASSUME_CUSTOM_KEYCODES */ /* @@ -471,6 +469,27 @@ specialkey = scanCode; #endif /* ASSUME_CUSTOM_KEYCODES */ + if (xf86IsPc98()) { + switch (scanCode) { + case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */ + case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus */ + case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus */ + case 0x62: specialkey = 0x3b; break; /* KEY_F1 */ + case 0x63: specialkey = 0x3c; break; /* KEY_F2 */ + case 0x64: specialkey = 0x3d; break; /* KEY_F3 */ + case 0x65: specialkey = 0x3e; break; /* KEY_F4 */ + case 0x66: specialkey = 0x3f; break; /* KEY_F5 */ + case 0x67: specialkey = 0x40; break; /* KEY_F6 */ + case 0x68: specialkey = 0x41; break; /* KEY_F7 */ + case 0x69: specialkey = 0x42; break; /* KEY_F8 */ + case 0x6a: specialkey = 0x43; break; /* KEY_F9 */ + case 0x6b: specialkey = 0x44; break; /* KEY_F10 */ + /* case 0x73: specialkey = 0x38; break; KEY_Alt */ + /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl */ + default: specialkey = 0x00; break; + } + } + #if defined (__sparc__) special: if (kbdSun) { @@ -704,17 +723,13 @@ /* Ignore these keys -- ie don't let them cancel an alt-sysreq */ case KEY_Alt: -#ifndef PC98 case KEY_AltLang: -#endif /* not PC98 */ break; -#ifndef PC98 case KEY_SysReqest: if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask))) VTSysreqToggle = TRUE; break; -#endif /* not PC98 */ default: if (VTSysreqToggle) @@ -822,7 +837,6 @@ * ignore releases, toggle on & off on presses. * Don't deal with the Caps_Lock keysym directly, but check the lock modifier */ -#ifndef PC98 if (keyc->modifierMap[keycode] & LockMask || keysym[0] == XK_Scroll_Lock || keysym[1] == XF86XK_ModeLock || @@ -844,14 +858,13 @@ if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag; updateLeds = TRUE; } -#endif /* not PC98 */ #ifndef ASSUME_CUSTOM_KEYCODES /* * normal, non-keypad keys */ if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) { -#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__) && !defined(__GNU__) +#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__) && !defined(__GNU__) && !defined(__CYGWIN__) /* * magic ALT_L key on AT84 keyboards for multilingual support */ @@ -918,7 +931,7 @@ void xf86Wakeup(pointer blockData, int err, pointer pReadmask) { -#if !defined(__EMX__) && !defined(__QNX__) +#if !defined(__EMX__) && !defined(__QNX__) && !defined(__CYGWIN__) #ifdef __OSF__ fd_set kbdDevices; fd_set mseDevices; @@ -1052,21 +1065,37 @@ } } +static int *xf86SignalIntercept = NULL; + +void +xf86InterceptSignals(int *signo) +{ + if ((xf86SignalIntercept = signo)) + *signo = -1; +} + /* * xf86SigHandler -- - * Catch unexpected signals and exit cleanly. + * Catch unexpected signals and exit or continue cleanly. */ void xf86SigHandler(int signo) { + if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) { + /* Re-arm handler just in case */ + (void) signal(signo, xf86SigHandler); + *xf86SignalIntercept = signo; + return; + } + signal(signo,SIG_IGN); xf86Info.caughtSignal = TRUE; #ifdef XF86BIGFONT XF86BigfontCleanup(); #endif -#if defined(DEBUG) && defined(XFree86LOADER) - if (signo == SIGSEGV) - LoaderDumpSymbols(); +#if defined(XFree86LOADER) + if (xf86Initialising) + LoaderCheckUnresolved(LD_RESOLV_IFDONE); #endif FatalError("Caught signal %d. Server aborting\n", signo); } @@ -1110,7 +1139,7 @@ for (i = 0; i < xf86NumScreens; i++) { xf86Screens[i]->LeaveVT(i, 0); } -#ifndef __EMX__ +#if !defined(__EMX__) && !defined(__CYGWIN__) DisableDevice((DeviceIntPtr)xf86Info.pKeyboard); pInfo = xf86InputDevs; while (pInfo) { @@ -1146,7 +1175,7 @@ } SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); -#ifndef __EMX__ +#if !defined(__EMX__) && !defined(__CYGWIN__) EnableDevice((DeviceIntPtr)xf86Info.pKeyboard); pInfo = xf86InputDevs; while (pInfo) { @@ -1158,9 +1187,10 @@ xf86EnableInputHandler(ih); } else { - if (xf86OSPMClose) - xf86OSPMClose(); - + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; + for (i = 0; i < xf86NumScreens; i++) { /* * zero all access functions to @@ -1196,7 +1226,7 @@ /* Turn screen saver off when switching back */ SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset); -#ifndef __EMX__ +#if !defined(__EMX__) && !defined(__CYGWIN__) EnableDevice((DeviceIntPtr)xf86Info.pKeyboard); pInfo = xf86InputDevs; while (pInfo) { @@ -1293,6 +1323,27 @@ AddEnabledDevice(ih->fd); } +/* + * As used currently by the DRI, the return value is ignored. + */ +Bool +xf86EnableVTSwitch(Bool new) +{ + static Bool def = TRUE; + Bool old; + + old = VTSwitchEnabled; + if (!new) { + /* Disable VT switching */ + def = VTSwitchEnabled; + VTSwitchEnabled = FALSE; + } else { + /* Restore VT switching to default */ + VTSwitchEnabled = def; + } + return old; +} + #ifdef XTESTEXT1 void @@ -1336,3 +1387,38 @@ #endif /* XTESTEXT1 */ +#ifdef WSCONS_SUPPORT + +/* XXX Currently XKB is mandatory. */ + +void +xf86PostWSKbdEvent(struct wscons_event *event) +{ + int type = event->type; + int value = event->value; + Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE); + KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key; + xEvent kevent; + KeySym *keysym; + int keycode; + + /* + * Now map the scancodes to real X-keycodes ... + */ + keycode = value + MIN_KEYCODE; + keysym = keyc->curKeySyms.map + + keyc->curKeySyms.mapWidth * (keycode - keyc->curKeySyms.minKeyCode); + + /* + * check for an autorepeat-event + */ + if ((down && KeyPressed(keycode)) && + (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode])) + return; + + xf86Info.lastEventTime = kevent.u.keyButtonPointer.time + = event->time.tv_sec * 1000 + event->time.tv_nsec / 1000000; + + ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); +} +#endif /* WSCONS_SUPPORT */ Index: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Helper.c:1.94 xc/programs/Xserver/hw/xfree86/common/xf86Helper.c:1.108 --- xc/programs/Xserver/hw/xfree86/common/xf86Helper.c:1.94 Tue Jun 20 01:08:44 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Helper.c Thu Dec 14 11:33:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.94 2000/06/20 05:08:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.108 2000/12/14 16:33:08 eich Exp $ */ /* * Copyright (c) 1997-1998 by The XFree86 Project, Inc. @@ -31,7 +31,8 @@ #include "xf86Bus.h" /* For xf86GetClocks */ -#if defined(CSRG_BASED) || defined(MACH386) +#if defined(CSRG_BASED) || defined(MACH386) || defined(__GNU__) +#define HAS_SETPRIORITY #include #endif @@ -122,10 +123,9 @@ xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion), xf86ScrnInfoPrivateCount); /* - * Almost everything uses this default, and many of those that don't - * will wrap it. + * EnableDisableFBAccess now gets initialized in InitOutput() + * xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; */ - xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; xf86Screens[i]->drv = drv; drv->refCount++; @@ -769,10 +769,12 @@ /* Check if the visual is valid for the depth */ if (scrp->depth == 1 && scrp->defaultVisual != StaticGray) bad = TRUE; +#if 0 else if (scrp->depth == 4 && (scrp->defaultVisual == TrueColor || scrp->defaultVisual == DirectColor)) bad = TRUE; +#endif else if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->defaultVisual != TrueColor && scrp->defaultVisual != DirectColor) @@ -1447,17 +1449,15 @@ int -xf86MatchDevice(const char *drivername, GDevPtr **driversectlist) +xf86MatchDevice(const char *drivername, GDevPtr **sectlist) { - static char * drivernames[MAXDRIVERS]; - static GDevPtr * devices[MAXDRIVERS]; - static int count[MAXDRIVERS]; - GDevPtr gdp; + GDevPtr gdp, *pgdp = NULL; confScreenPtr screensecptr; int i,j; - *driversectlist = NULL; - + if (sectlist) + *sectlist = NULL; + if (xf86DoProbe) return 1; if (xf86DoConfigure && xf86DoConfigurePass1) return 1; @@ -1466,48 +1466,18 @@ * This is a very important function that matches the device sections * as they show up in the config file with the drivers that the server * loads at run time. - + * * ChipProbe can call - * int xf86MatchDevice(char * drivername, GDevPtr * driversectlist) + * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist) * with its driver name. The function allocates an array of GDevPtr and - * returns this via driversectlist and returns the number of elements in + * returns this via sectlist and returns the number of elements in * this list as return value. 0 means none found, -1 means fatal error. * * It can figure out which of the Device sections to use for which card * (using things like the Card statement, etc). For single headed servers * there will of course be just one such Device section. - * - * If there's no Device section with matching name, then xf86MatchDevice() - * returns the first Device section without a Driver statement. This will - * again work out ok in a single headed environment. - */ - /* - * in order to be able to access the results of these queries again, we - * keep two parallel static arrays, one holding the name of the driver, - * the other holding the coresponding Device section pointers. - * So first, we need to check if the query has already been answered - * and simply return that old answer if this is the case. */ i = 0; - while (drivernames[i] && i < MAXDRIVERS) { - if (xf86NameCmp(drivername,drivernames[i]) == 0) { - /* - * we already had that one - */ - *driversectlist = devices[i]; - return count[i]; - } - i++; - } - - if (i == MAXDRIVERS) - return -1; - - /* - * if we get here, this is a new name - */ - drivernames[i] = xstrdup(drivername); - count[i] = 0; /* * first we need to loop over all the Screens sections to get to all @@ -1521,10 +1491,8 @@ /* * we have a matching driver that wasn't claimed, yet */ - screensecptr->device->claimed = TRUE; - devices[i] = xnfrealloc(devices[i], - (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = screensecptr->device; + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = screensecptr->device; } } @@ -1535,50 +1503,23 @@ if (gdp->driver && !gdp->claimed && !xf86NameCmp(gdp->driver,drivername)) { /* we have a matching driver that wasn't claimed yet */ - gdp->claimed = TRUE; - devices[i] = - xnfrealloc(devices[i], (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = gdp; + pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr)); + pgdp[i++] = gdp; } j++; } -#if 0 /* - * XXX The parser won't let devices with no Driver name through, so - * this can be removed. - */ - if (count[i] == 0) { - /* - * we haven't found a single one, let's try to find one that - * wasn't claimed and has no driver given - */ - for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) { - screensecptr = xf86ConfigLayout.screens[j].screen; - if ((screensecptr->device->driver == NULL) - && (! screensecptr->device->claimed)) { - /* - * we have a device section without driver that wasn't claimed - */ - screensecptr->device->claimed = TRUE; - devices[i] = xnfrealloc(devices[i], - (count[i] + 2) * sizeof(GDevPtr)); - devices[i][count[i]++] = screensecptr->device; - } - } - } -#endif - /* * make the array NULL terminated and return its address */ - if( count[i] ) - devices[i][count[i]] = NULL; - else - devices[i] = NULL; - - *driversectlist = devices[i]; + if (i) + pgdp[i] = NULL; - return count[i]; + if (sectlist) + *sectlist = pgdp; + else + xfree(pgdp); + return i; } struct Inst { @@ -1619,23 +1560,29 @@ *foundEntities = NULL; if (vendorID == 0) { - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + Bool foundVendor = FALSE; for (id = PCIchipsets; id->PCIid != -1; id++) { - if ( (((id->PCIid & 0xFFFF0000) >> 16) == (*ppPci)->vendor) && - ((id->PCIid & 0x0000FFFF) == (*ppPci)->chipType)){ - ++allocatedInstances; - instances = xnfrealloc(instances, - allocatedInstances * sizeof(struct Inst)); - instances[allocatedInstances - 1].pci = *ppPci; - instances[allocatedInstances - 1].dev = NULL; - instances[allocatedInstances - 1].claimed = FALSE; - instances[allocatedInstances - 1].foundHW = TRUE; - instances[allocatedInstances - 1].chip = id->numChipset; - instances[allocatedInstances - 1].screen = 0; - numFound++; - } + if ( (((id->PCIid & 0xFFFF0000) >> 16) == (*ppPci)->vendor)) { + if (!foundVendor) { + ++allocatedInstances; + instances = xnfrealloc(instances, + allocatedInstances * sizeof(struct Inst)); + instances[allocatedInstances - 1].pci = *ppPci; + instances[allocatedInstances - 1].dev = NULL; + instances[allocatedInstances - 1].claimed = FALSE; + instances[allocatedInstances - 1].foundHW = FALSE; + instances[allocatedInstances - 1].screen = 0; + foundVendor = TRUE; + } + if ((id->PCIid & 0x0000FFFF) == (*ppPci)->chipType) { + instances[allocatedInstances - 1].foundHW = TRUE; + instances[allocatedInstances - 1].chip = id->numChipset; + numFound++; + } + } } - } + } } else if (vendorID == PCI_VENDOR_GENERIC) { for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { for (id = PCIchipsets; id->PCIid != -1; id++) { @@ -1655,7 +1602,8 @@ } } else { /* Find PCI devices that match the given vendor ID */ - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + for (ppPci = xf86PciVideoInfo; (ppPci != NULL) + && (*ppPci != NULL); ppPci++) { if ((*ppPci)->vendor == vendorID) { ++allocatedInstances; instances = xnfrealloc(instances, @@ -1679,6 +1627,7 @@ } } } + /* * This may be debatable, but if no PCI devices with a matching vendor * type is found, return zero now. It is probably not desirable to @@ -1700,7 +1649,7 @@ for (i = 0; i < allocatedInstances; i++) { if (instances[i].foundHW) { actualcards++; - pGDev = xf86AddDeviceToConfigure(driverName, + pGDev = xf86AddDeviceToConfigure(drvp->driverName, instances[i].pci, -1); if (pGDev) { /* @@ -1957,7 +1906,7 @@ if (xf86DoProbe || (xf86DoConfigure && xf86DoConfigurePass1)) { if (FindIsaDevice && ((foundChip = (*FindIsaDevice)(NULL)) != -1)) { - xf86AddDeviceToConfigure(driverName, NULL, foundChip); + xf86AddDeviceToConfigure(drvp->driverName, NULL, foundChip); return 1; } return 0; @@ -2053,14 +2002,7 @@ /* First save registers that get written on */ (*ClockFunc)(pScrn, CLK_REG_SAVE); -#if defined(CSRG_BASED) || defined(MACH386) - saved_nice = getpriority(PRIO_PROCESS, 0); - setpriority(PRIO_PROCESS, 0, -20); -#endif -#if defined(SYSV) || defined(SVR4) || defined(linux) - saved_nice = nice(0); - nice(-20 - saved_nice); -#endif + xf86SetPriority(TRUE); if (num > MAXCLOCKS) num = MAXCLOCKS; @@ -2119,12 +2061,7 @@ (*BlankScreen)(pScrn, TRUE); } -#if defined(CSRG_BASED) || defined(MACH386) - setpriority(PRIO_PROCESS, 0, saved_nice); -#endif -#if defined(SYSV) || defined(SVR4) || defined(linux) - nice(20 + saved_nice); -#endif + xf86SetPriority(FALSE); for (i = 0; i < num; i++) { @@ -2153,6 +2090,31 @@ /* Restore registers that were written on */ (*ClockFunc)(pScrn, CLK_REG_RESTORE); } + +void +xf86SetPriority(Bool up) +{ + static int saved_nice; + + if (up) { +#ifdef HAS_SETPRIORITY + saved_nice = getpriority(PRIO_PROCESS, 0); + setpriority(PRIO_PROCESS, 0, -20); +#endif +#if defined(SYSV) || defined(SVR4) || defined(linux) + saved_nice = nice(0); + nice(-20 - saved_nice); +#endif + } else { +#ifdef HAS_SETPRIORITY + setpriority(PRIO_PROCESS, 0, saved_nice); +#endif +#if defined(SYSV) || defined(SVR4) || defined(linux) + nice(20 + saved_nice); +#endif + } +} + const char * xf86GetVisualName(int visual) { @@ -2234,6 +2196,13 @@ Bool +xf86ServerIsOnlyDetecting(void) +{ + return xf86DoProbe || xf86DoConfigure; +} + + +Bool xf86ServerIsOnlyProbing(void) { return xf86ProbeOnly; @@ -2325,6 +2294,47 @@ #endif } +/* + * xf86LoadOneModule loads a single module. + */ +pointer +xf86LoadOneModule(char *name, pointer opt) +{ +#ifdef XFree86LOADER + int errmaj, errmin; +#endif + char *Name; + pointer mod; + + if (!name) + return NULL; + +#ifndef NORMALISE_MODULE_NAME + Name = xstrdup(name); +#else + /* Normalise the module name */ + Name = xf86NormalizeName(name); +#endif + + /* Skip empty names */ + if (Name == NULL) + return NULL; + if (*Name == '\0') { + xfree(Name); + return NULL; + } + +#ifdef XFree86LOADER + mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin); + if (!mod) + LoaderErrorMsg(NULL, Name, errmaj, errmin); +#else + mod = (pointer)1; +#endif + xfree(Name); + return mod; +} + void xf86UnloadSubModule(pointer mod) { @@ -2371,60 +2381,7 @@ #endif } -void xf86Break1(void) -{ -} - -void xf86Break2(void) -{ -} - -void xf86Break3(void) -{ -} - -CARD32 xf86DummyVar1; -CARD32 xf86DummyVar2; -CARD32 xf86DummyVar3; - -CARD8 xf86PeekFb8(CARD8 *p) { return *p; } -CARD16 xf86PeekFb16(CARD16 *p) { return *p; } -CARD32 xf86PeekFb32(CARD32 *p) { return *p; } -void xf86PokeFb8(CARD8 *p, CARD8 v) { *p = v; } -void xf86PokeFb16(CARD16 *p, CARD16 v) { *p = v; } -void xf86PokeFb32(CARD16 *p, CARD32 v) { *p = v; } - -CARD8 xf86PeekMmio8(pointer Base, unsigned long Offset) -{ - return MMIO_IN8(Base,Offset); -} - -CARD16 xf86PeekMmio16(pointer Base, unsigned long Offset) -{ - return MMIO_IN16(Base,Offset); -} -CARD32 xf86PeekMmio32(pointer Base, unsigned long Offset) -{ - return MMIO_IN32(Base,Offset); -} - -void xf86PokeMmio8(pointer Base, unsigned long Offset, CARD8 v) -{ - MMIO_OUT8(Base,Offset,v); -} - -void xf86PokeMmio16(pointer Base, unsigned long Offset, CARD16 v) -{ - MMIO_OUT16(Base,Offset,v); -} - -void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v) -{ - MMIO_OUT32(Base,Offset,v); -} - - typedef enum { OPTION_BACKING_STORE } BSOpts; @@ -2558,6 +2515,7 @@ { IsaChipsets *i_id; EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; if (!(pEnt->location.type == BUS_ISA)) { xfree(pEnt); @@ -2594,8 +2552,10 @@ { PciChipsets *p_id; EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; - if (!(pEnt->location.type == BUS_PCI)) { + if (!(pEnt->location.type == BUS_PCI) + || !xf86GetPciInfoForEntity(entityIndex)) { xfree(pEnt); return pScrn; } @@ -2628,6 +2588,33 @@ return pScrn; } +ScrnInfoPtr +xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex, + EntityProc init, EntityProc enter, EntityProc leave, + pointer private) +{ + EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return pScrn; + + if (!(pEnt->location.type == BUS_NONE)) { + xfree(pEnt); + return pScrn; + } + + if (!pEnt->active) { + xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private); + return pScrn; + } + + if (!pScrn) + pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); + xf86AddEntityToScreen(pScrn,entityIndex); + + xf86SetEntityFuncs(entityIndex,init,enter,leave,private); + + return pScrn; +} + /* * * OBSOLETE ! xf86ConfigActiveIsaEntity() and xf86ConfigActivePciEntity() @@ -2641,6 +2628,7 @@ { IsaChipsets *i_id; EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; if (!pEnt->active || !(pEnt->location.type == BUS_ISA)) { xfree(pEnt); @@ -2670,6 +2658,7 @@ { PciChipsets *p_id; EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex); + if (!pEnt) return FALSE; if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) { xfree(pEnt); @@ -2740,6 +2729,17 @@ xf86ClaimFixedResources(res,pEnt->index); /* shared resources are only needed when entity is active: remove */ xf86DeallocateResourcesForEntity(pEnt->index, ResShared); + xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); +} + +void +xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, + EntityProc enter, EntityProc leave, pointer private) +{ + ScrnInfoPtr pScrn; + + if ((pScrn = xf86FindScreenForEntity(pEnt->index))) + xf86RemoveEntityFromScreen(pScrn,pEnt->index); xf86SetEntityFuncs(pEnt->index,init,enter,leave,private); } Index: xc/programs/Xserver/hw/xfree86/common/xf86Init.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Init.c:3.162 xc/programs/Xserver/hw/xfree86/common/xf86Init.c:3.173 --- xc/programs/Xserver/hw/xfree86/common/xf86Init.c:3.162 Sun Jun 25 16:17:32 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Init.c Thu Nov 30 19:24:33 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.162 2000/06/25 20:17:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.173 2000/12/01 00:24:33 dawes Exp $ */ /* * Copyright 1991-1999 by The XFree86 Project, Inc. @@ -90,9 +90,16 @@ { 8, 8, BITMAP_SCANLINE_PAD }, { 15, 16, BITMAP_SCANLINE_PAD }, { 16, 16, BITMAP_SCANLINE_PAD }, - { 24, 32, BITMAP_SCANLINE_PAD } + { 24, 32, BITMAP_SCANLINE_PAD }, +#ifdef RENDER + { 32, 32, BITMAP_SCANLINE_PAD }, +#endif }; +#ifdef RENDER +static int numFormats = 7; +#else static int numFormats = 6; +#endif static Bool formatsDone = FALSE; InputDriverRec xf86KEYBOARD = { @@ -725,8 +732,17 @@ * serverGeneration != 1; some OSs have to do things here, too. */ xf86OpenConsole(); - xf86OSPMClose = xf86OSPMOpen(); - + + /* + should we reopen it here? We need to deal with an already opened + device. We could leave this to the OS layer. For now we simply + close it here + */ + if (xf86OSPMClose) + xf86OSPMClose(); + if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) + xf86MsgVerb(3,X_INFO,"APM registered successfully\n"); + /* Make sure full I/O access is enabled */ xf86EnableIO(); } @@ -801,6 +817,11 @@ for (i = 0; i < xf86NumScreens; i++) { xf86EnableAccess(xf86Screens[i]); + /* + * Almost everything uses this default, and many of those that + * don't, will wrap it. + */ + xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); if (scr_index == i) { /* @@ -1035,7 +1056,8 @@ xf86CloseConsole(); if (xf86OSPMClose) xf86OSPMClose(); - + xf86OSPMClose = NULL; + xf86CloseLog(); /* If an unexpected signal was caught, dump a core for debugging */ @@ -1101,6 +1123,7 @@ "the full server output, not just the last messages.\n"); if (xf86LogFile) ErrorF("This can be found in the log file \"%s\".\n", xf86LogFile); + ErrorF("Please report problems to %s.\n",BUILDERADDR); ErrorF("\n"); } @@ -1226,6 +1249,13 @@ xf86BestRefresh = TRUE; return 1; } + if (!strcmp(argv[i],"-ignoreABI")) + { +#ifdef XFree86LOADER + LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); +#endif + return 1; + } #ifdef DO_CHECK_BETA if (!strcmp(argv[i],"-extendExpiry")) { @@ -1508,7 +1538,8 @@ ErrorF(" from non-local clients\n"); ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); #endif - ErrorF("-bestRefresh chose modes with the best refresh rate\n"); + ErrorF("-bestRefresh choose modes with the best refresh rate\n"); + ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); ErrorF("-version show the server version\n"); /* OS-specific usage */ xf86UseMsg(); @@ -1517,25 +1548,41 @@ #ifndef OSNAME -#define OSNAME "unknown" +#define OSNAME " unknown" #endif #ifndef OSVENDOR #define OSVENDOR "" #endif +#ifndef PRE_RELEASE +#define PRE_RELEASE (XF86_VERSION_BETA || XF86_VERSION_ALPHA) +#endif static void xf86PrintBanner() { - ErrorF("\nXFree86 Version%s/ X Window System\n", XF86_VERSION); +#if PRE_RELEASE + ErrorF("\n" + "This is a pre-release version of XFree86, and is not supported in any\n" + "way. Bugs may be reported to XFree86@XFree86.Org and patches submitted\n" + "to fixes@XFree86.Org. Before reporting bugs in pre-release versions,\n" + "please check the latest version in the XFree86 CVS repository\n" + "(http://www.XFree86.Org/cvs)\n"); +#endif + ErrorF("\nXFree86 Version%s", XF86_VERSION); +#ifdef XF86_CUSTOM_VERSION + ErrorF("(%s) ", XF86_CUSTOM_VERSION); +#endif + ErrorF("/ X Window System\n"); ErrorF("(protocol Version %d, revision %d, vendor release %d)\n", X_PROTOCOL, X_PROTOCOL_REVISION, VENDOR_RELEASE ); ErrorF("Release Date: %s\n", XF86_DATE); - ErrorF("\tIf the server is older than 6-12 months, or if your card is " - "newer\n" - "\tthan the above date, look for a newer version before " - "reporting\n" - "\tproblems. (see http://www.XFree86.Org/FAQ)\n"); - ErrorF("Operating System: %s %s\n", OSNAME, OSVENDOR); + ErrorF("\tIf the server is older than 6-12 months, or if your card is\n" + "\tnewer than the above date, look for a newer version before\n" + "\treporting problems. (See http://www.XFree86.Org/FAQ)\n"); + ErrorF("Operating System:%s%s\n", OSNAME, OSVENDOR); +#if defined(BUILDERSTRING) + ErrorF("%s \n",BUILDERSTRING); +#endif #ifdef XFree86LOADER ErrorF("Module Loader present\n"); #endif @@ -1618,39 +1665,6 @@ xfree(name); } return !failed; -} - -/* - * xf86LoadOneModule loads a single module. - */ -pointer -xf86LoadOneModule(char *name, pointer opt) -{ - int errmaj, errmin; - char *Name; - pointer mod; - - if (!name) - return NULL; - -#ifndef NORMALISE_MODULE_NAME - Name = xstrdup(name); -#else - /* Normalise the module name */ - Name = xf86NormalizeName(name); -#endif - - /* Skip empty names */ - if (Name == NULL || *Name == '\0') - return NULL; - - if (!(mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin))){ - LoaderErrorMsg(NULL, Name, errmaj, errmin); - xfree(Name); - return FALSE; - } - xfree(Name); - return mod; } #endif Index: xc/programs/Xserver/hw/xfree86/common/xf86Io.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Io.c:3.39 xc/programs/Xserver/hw/xfree86/common/xf86Io.c:3.41 --- xc/programs/Xserver/hw/xfree86/common/xf86Io.c:3.39 Mon Jun 12 22:28:31 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Io.c Mon Nov 6 14:24:06 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.39 2000/06/13 02:28:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.41 2000/11/06 19:24:06 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -369,7 +369,7 @@ read(kbdFd, buf, 16); } -#ifndef __EMX__ /* Under EMX, keyboard cannot be select()'ed */ +#if !defined(__EMX__) && !defined(__CYGWIN__) /* Under EMX, keyboard cannot be select()'ed */ if (kbdFd != -1) AddEnabledDevice(kbdFd); #endif /* __EMX__ */ @@ -411,3 +411,36 @@ } #endif /* !AMOEBA && !(sun || SVR4) && !MINIX */ +#ifdef WSCONS_SUPPORT + +#define NUMEVENTS 64 + +static void +wsconssig(fd, closure) + int fd; + void *closure; +{ + static struct wscons_event events[NUMEVENTS]; + int n, i; + + n = read(fd, events, sizeof events); + if (n <= 0) + return; + n /= sizeof(struct wscons_event); + for (i = 0; i < n; i++) + xf86PostWSKbdEvent(&events[i]); +} + +int +xf86WSKbdProc(pKeyboard, what) + DeviceIntPtr pKeyboard; /* Keyboard to manipulate */ + int what; /* What to do to it */ +{ + switch (what) { + case DEVICE_INIT: + xf86FlushInput(xf86Info.kbdFd); + xf86InstallSIGIOHandler(xf86Info.kbdFd, wsconssig, pKeyboard); + } + return xf86KbdProc(pKeyboard, what); +} +#endif /* WSCONS_SUPPORT */ Index: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c:3.13 xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c:3.14 --- xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c:3.13 Fri Jun 23 18:42:02 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c Fri Aug 11 13:27:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.13 2000/06/23 22:42:02 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.14 2000/08/11 17:27:13 dawes Exp $ */ /* * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk) * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. @@ -40,7 +40,6 @@ #define KD_GET_ENTRY(i,n) \ eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]] -#ifndef PC98 static unsigned char remap[128] = { 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ @@ -59,27 +58,6 @@ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ }; -#else /* PC98 */ -static unsigned char remap[128] = { - 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ - 0x30, 0x31, 0x32, 0x33, 0x34, 0, 0, 0, /* 0x30 - 0x37 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x38 - 0x3f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x47 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ - 0, 0, 0x52, 0x53, 0x54, 0x55, 0x56, 0, /* 0x50 - 0x57 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 - 0x67 */ - 0x68, 0x69, 0x6a, 0x6b, 0, 0, 0, 0, /* 0x68 - 0x6f */ - 0x70, 0x71, 0x72, 0x73, 0x74, 0, 0, 0, /* 0x70 - 0x77 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ -}; -#endif /* PC98 */ - /* This table assumes the ibm code page 437 coding for characters * > 0x80. They are returned in this form by PCVT */ @@ -458,11 +436,7 @@ if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) { for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++) -#ifdef PC98 - if (remap[i] || i == 0) { -#else if (remap[i]) { -#endif k = map + (remap[i] << 2); k[0] = KD_GET_ENTRY(i,0); /* non-shifed */ k[1] = KD_GET_ENTRY(i,1); /* shifted */ Index: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h:3.12 xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h:3.13 --- xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h:3.12 Thu Apr 29 01:12:58 1999 +++ xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h Fri Aug 11 13:27:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.12 1999/04/29 05:12:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.13 2000/08/11 17:27:13 dawes Exp $ */ /* * * For Scancodes see notes in atKeynames.h !!!! @@ -7,7 +7,6 @@ /* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */ static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { -#ifndef PC98 /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol, @@ -136,135 +135,6 @@ /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, -#else /* PC98 */ - /* 0x00 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, - /* 0x01 */ XK_1, XK_exclam, XK_kana_NU, NoSymbol, - /* 0x02 */ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol, - /* 0x03 */ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, - /* 0x04 */ XK_4, XK_dollar, XK_kana_U, XK_kana_u, - /* 0x05 */ XK_5, XK_percent, XK_kana_E, XK_kana_e, - /* 0x06 */ XK_6, XK_ampersand, XK_kana_O, XK_kana_o, - /* 0x07 */ XK_7, XK_quoteright, XK_kana_YA, XK_kana_ya, - /* 0x08 */ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu, - /* 0x09 */ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo, - /* 0x0a */ XK_0, NoSymbol, XK_kana_WA, XK_kana_WO, - /* 0x0b */ XK_minus, XK_equal, XK_kana_HO, NoSymbol, - /* 0x0c */ XK_asciicircum, XK_quoteleft, XK_kana_HE, NoSymbol, - /* 0x0d */ XK_backslash, XK_bar, XK_prolongedsound, NoSymbol, - /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, - /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol, - /* 0x10 */ XK_Q, NoSymbol, XK_kana_TA, NoSymbol, - /* 0x11 */ XK_W, NoSymbol, XK_kana_TE, NoSymbol, - /* 0x12 */ XK_E, NoSymbol, XK_kana_I, XK_kana_i, - /* 0x13 */ XK_R, NoSymbol, XK_kana_SU, NoSymbol, - /* 0x14 */ XK_T, NoSymbol, XK_kana_KA, NoSymbol, - /* 0x15 */ XK_Y, NoSymbol, XK_kana_N, NoSymbol, - /* 0x16 */ XK_U, NoSymbol, XK_kana_NA, NoSymbol, - /* 0x17 */ XK_I, NoSymbol, XK_kana_NI, NoSymbol, - /* 0x18 */ XK_O, NoSymbol, XK_kana_RA, NoSymbol, - /* 0x19 */ XK_P, NoSymbol, XK_kana_SE, NoSymbol, - /* 0x1a */ XK_at, XK_asciitilde, XK_voicedsound, NoSymbol, - /* 0x1b */ XK_bracketleft, XK_braceleft, XK_semivoicedsound, XK_kana_openingbracket, - /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, - /* 0x1d */ XK_A, NoSymbol, XK_kana_CHI, NoSymbol, - /* 0x1e */ XK_S, NoSymbol, XK_kana_TO, NoSymbol, - /* 0x1f */ XK_D, NoSymbol, XK_kana_SHI, NoSymbol, - /* 0x20 */ XK_F, NoSymbol, XK_kana_HA, NoSymbol, - /* 0x21 */ XK_G, NoSymbol, XK_kana_KI, NoSymbol, - /* 0x22 */ XK_H, NoSymbol, XK_kana_KU, NoSymbol, - /* 0x23 */ XK_J, NoSymbol, XK_kana_MA, NoSymbol, - /* 0x24 */ XK_K, NoSymbol, XK_kana_NO, NoSymbol, - /* 0x25 */ XK_L, NoSymbol, XK_kana_RI, NoSymbol, - /* 0x26 */ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol, - /* 0x27 */ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol, - /* 0x28 */ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket, - /* 0x29 */ XK_Z, NoSymbol, XK_kana_TSU, NoSymbol, - /* 0x2a */ XK_X, NoSymbol, XK_kana_SA, NoSymbol, - /* 0x2b */ XK_C, NoSymbol, XK_kana_SO, NoSymbol, - /* 0x2c */ XK_V, NoSymbol, XK_kana_HI, NoSymbol, - /* 0x2d */ XK_B, NoSymbol, XK_kana_KO, NoSymbol, - /* 0x2e */ XK_N, NoSymbol, XK_kana_MI, NoSymbol, - /* 0x2f */ XK_M, NoSymbol, XK_kana_MO, NoSymbol, - /* 0x30 */ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, - /* 0x31 */ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, - /* 0x32 */ XK_slash, XK_question, XK_kana_ME, XK_kana_middledot, - /* 0x33 */ XK_underscore, XK_underscore, XK_kana_RO, NoSymbol, - /* 0x34 */ XK_space, NoSymbol, NoSymbol, NoSymbol, - /* 0x35 */ XK_Henkan, XK_Kanji, NoSymbol, NoSymbol, - /* 0x36 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, - /* 0x37 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, - /* 0x38 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, - /* 0x39 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, - /* 0x3a */ XK_Up, NoSymbol, NoSymbol, NoSymbol, - /* 0x3b */ XK_Left, NoSymbol, NoSymbol, NoSymbol, - /* 0x3c */ XK_Right, NoSymbol, NoSymbol, NoSymbol, - /* 0x3d */ XK_Down, NoSymbol, NoSymbol, NoSymbol, - /* 0x3e */ XK_Clear, XK_Home, NoSymbol, NoSymbol, - /* 0x3f */ XK_Help, NoSymbol, NoSymbol, NoSymbol, - /* 0x40 */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, - /* 0x41 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, - /* 0x42 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, - /* 0x43 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, - /* 0x44 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, - /* 0x45 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, - /* 0x46 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, - /* 0x47 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, - /* 0x48 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, - /* 0x49 */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, - /* 0x4a */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, - /* 0x4b */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, - /* 0x4c */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, - /* 0x4d */ XK_KP_Equal, NoSymbol, NoSymbol, NoSymbol, - /* 0x4e */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, - /* 0x4f */ XK_KP_Separator,NoSymbol, NoSymbol, NoSymbol, - /* 0x50 */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol, - /* 0x51 */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol, - /* 0x52 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, - /* 0x53 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, - /* 0x54 */ XK_F13, NoSymbol, NoSymbol, NoSymbol, - /* 0x55 */ XK_F14, NoSymbol, NoSymbol, NoSymbol, - /* 0x56 */ XK_F15, NoSymbol, NoSymbol, NoSymbol, - /* 0x57 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x58 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x60 */ XK_Break, NoSymbol, NoSymbol, NoSymbol, - /* 0x61 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, - /* 0x62 */ XK_F1, NoSymbol, NoSymbol, NoSymbol, - /* 0x63 */ XK_F2, NoSymbol, NoSymbol, NoSymbol, - /* 0x64 */ XK_F3, NoSymbol, NoSymbol, NoSymbol, - /* 0x65 */ XK_F4, NoSymbol, NoSymbol, NoSymbol, - /* 0x66 */ XK_F5, NoSymbol, NoSymbol, NoSymbol, - /* 0x67 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, - /* 0x68 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, - /* 0x69 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, - /* 0x6a */ XK_F9, NoSymbol, NoSymbol, NoSymbol, - /* 0x6b */ XK_F10, NoSymbol, NoSymbol, NoSymbol, - /* 0x6c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x6d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x70 */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, - /* 0x71 */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, - /* 0x72 */ XK_kana_switch, NoSymbol, XK_kana_switch, NoSymbol, - /* 0x73 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, - /* 0x74 */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, - /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, - /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, -#endif /* PC98 */ }; #if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) && !defined(linux) && !defined(CSRG_BASED) Index: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c:1.5 xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c:1.6 --- xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c:1.5 Mon Apr 17 12:29:53 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c Fri Aug 4 12:13:25 2000 @@ -1,7 +1,7 @@ /* * Copyright (c) 1999 by The XFree86 Project, Inc. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.5 2000/04/17 16:29:53 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.6 2000/08/04 16:13:25 eich Exp $ */ /* * This file contains the Pointer/Keyboard functions needed by the @@ -34,7 +34,7 @@ #include "xf86OSmouse.h" #include "../input/mouse/mouse.h" -#define DEBUG + #ifdef DEBUG # define DEBUG_P(x) ErrorF(x"\n"); #else @@ -53,7 +53,8 @@ int em3timeout; Bool chordmiddle; int flags; - pointer private; + char* device; + pointer private; } mseParamsRec, *mseParamsPtr; typedef struct { @@ -202,6 +203,15 @@ } Bool +MiscExtSetMouseDevice(pointer mouse, char* device) +{ + mseParamsPtr mse = mouse; + + mse->device = device; + return TRUE; +} + +Bool MiscExtGetKbdSettings(pointer *kbd) { kbdParamsPtr kbdptr; @@ -411,6 +421,9 @@ if (reopen) (pMse->device->deviceProc)(pMse->device, DEVICE_ON); /* Set pInfo->options too */ + + if (mse->device) + xf86ReplaceStrOption(pInfo->options, "Device", mse->device); } if (mse_or_kbd == MISC_KEYBOARD) { Index: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Mode.c:1.32 xc/programs/Xserver/hw/xfree86/common/xf86Mode.c:1.36 --- xc/programs/Xserver/hw/xfree86/common/xf86Mode.c:1.32 Tue Jun 20 01:08:44 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Mode.c Wed Dec 6 10:35:11 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.32 2000/06/20 05:08:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.36 2000/12/06 15:35:11 eich Exp $ */ /* * Copyright (c) 1997,1998 by The XFree86 Project, Inc. @@ -269,7 +269,7 @@ modep->PrivFlags = cp->PrivFlags; } else { if(!scrp->progClock) { - modep->Clock = p->Clock; + modep->Clock = p->Clock; modep->ClockIndex = p->ClockIndex; modep->SynthClock = p->SynthClock; } else { @@ -382,7 +382,6 @@ /* Scan the mode pool for matching names */ for (p = scrp->modePool; p != NULL; p = p->next) { if (strcmp(p->name, modep->name) == 0) { - /* * Requested mode is a built-in mode. Don't let the user * override it. @@ -1137,12 +1136,12 @@ for (i = 0; i < scrp->monitor->nHsync; i++) if (scrp->monitor->hsync[i].lo == scrp->monitor->hsync[i].hi) xf86DrvMsg(scrp->scrnIndex, X_INFO, - "%s: Using hsync value of %6.2f kHz\n", + "%s: Using hsync value of %.2f kHz\n", scrp->monitor->id, scrp->monitor->hsync[i].lo); else xf86DrvMsg(scrp->scrnIndex, X_INFO, - "%s: Using hsync range of %6.2f-%6.2f kHz\n", + "%s: Using hsync range of %.2f-%.2f kHz\n", scrp->monitor->id, scrp->monitor->hsync[i].lo, scrp->monitor->hsync[i].hi); @@ -1158,12 +1157,12 @@ for (i = 0; i < scrp->monitor->nVrefresh; i++) if (scrp->monitor->vrefresh[i].lo == scrp->monitor->vrefresh[i].hi) xf86DrvMsg(scrp->scrnIndex, X_INFO, - "%s: Using vrefresh value of %6.2f Hz\n", + "%s: Using vrefresh value of %.2f Hz\n", scrp->monitor->id, scrp->monitor->vrefresh[i].lo); else xf86DrvMsg(scrp->scrnIndex, X_INFO, - "%s: Using vrefresh range of %6.2f-%6.2f Hz\n", + "%s: Using vrefresh range of %.2f-%.2f Hz\n", scrp->monitor->id, scrp->monitor->vrefresh[i].lo, scrp->monitor->vrefresh[i].hi); @@ -1309,6 +1308,10 @@ xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Built-in mode \"%s\" deleted (%s)\n", p->name, xf86ModeStatusToString(status)); + else if (p->type & M_T_DEFAULT) + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Default mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(status)); else xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode \"%s\" deleted (%s)\n", p->name, @@ -1396,7 +1399,20 @@ lookupNext: status = xf86LookupMode(scrp, p, clockRanges, strategy); - + if (status != MODE_OK) { + if (p->type & M_T_BUILTIN) + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Built-in mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(status)); + else if (p->type & M_T_DEFAULT) + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Default mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(status)); + else + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(status)); + } if (status == MODE_ERROR) { ErrorF("xf86ValidateModes: " "unexpected result from xf86LookupMode()\n"); @@ -1480,10 +1496,15 @@ xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Built-in mode \"%s\" deleted (%s)\n", p->name, xf86ModeStatusToString(p->status)); - else + else if (p->type & M_T_DEFAULT) + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Default mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(p->status)); + else xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Mode \"%s\" deleted (%s)\n", p->name, xf86ModeStatusToString(p->status)); + goto lookupNext; } } @@ -1584,14 +1605,20 @@ return; n = p->next; if (p->status != MODE_OK) { +#if 0 if (p->type & M_T_BUILTIN) xf86DrvMsg(scrp->scrnIndex, X_WARNING, "Built-in mode \"%s\" deleted (%s)\n", p->name, - xf86ModeStatusToString(p->status)); - else if ((p->type & M_T_DEFAULT) == 0) - xf86DrvMsg(scrp->scrnIndex, X_WARNING, - "Mode \"%s\" deleted (%s)\n", p->name, xf86ModeStatusToString(p->status)); + else if (p->type & M_T_DEFAULT) + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Default mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(p->status)); + else + xf86DrvMsg(scrp->scrnIndex, X_WARNING, + "Mode \"%s\" deleted (%s)\n", p->name, + xf86ModeStatusToString(p->status)); +#endif xf86DeleteMode(&(scrp->modes), p); } p = n; Index: xc/programs/Xserver/hw/xfree86/common/xf86Module.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Module.h:1.24 xc/programs/Xserver/hw/xfree86/common/xf86Module.h:1.27 --- xc/programs/Xserver/hw/xfree86/common/xf86Module.h:1.24 Wed Apr 5 14:13:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Module.h Tue Nov 14 11:54:49 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.24 2000/04/05 18:13:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.27 2000/11/14 16:54:49 dawes Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. @@ -23,7 +23,7 @@ #include "misc.h" #include "xf86Version.h" #ifndef NULL -#define NULL 0 +#define NULL ((void *)0) #endif typedef enum { @@ -62,10 +62,10 @@ * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 1) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 2) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 3) #define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 1) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 1) -#define ABI_FONT_VERSION SET_ABI_VERSION(0, 1) +#define ABI_FONT_VERSION SET_ABI_VERSION(0, 2) #define MODINFOSTRING1 0xef23fdc5 #define MODINFOSTRING2 0x10dc023a Index: xc/programs/Xserver/hw/xfree86/common/xf86Opt.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Opt.h:1.9 xc/programs/Xserver/hw/xfree86/common/xf86Opt.h:1.10 --- xc/programs/Xserver/hw/xfree86/common/xf86Opt.h:1.9 Sat Jun 5 11:55:22 1999 +++ xc/programs/Xserver/hw/xfree86/common/xf86Opt.h Fri Aug 4 12:13:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Opt.h,v 1.9 1999/06/05 15:55:22 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Opt.h,v 1.10 2000/08/04 16:13:25 eich Exp $ */ /* Option handling things that ModuleSetup procs can use */ @@ -75,5 +75,7 @@ Bool xf86ReturnOptValBool(OptionInfoPtr table, int token, Bool def); int xf86NameCmp(const char *s1, const char *s2); char *xf86NormalizeName(const char *s); - +pointer xf86ReplaceIntOption(pointer optlist, char *name, int val); +pointer xf86ReplaceBoolOption(pointer optlist, char *name, Bool val); +pointer xf86ReplaceStrOption(pointer optlist, char *name, char* val); #endif Index: xc/programs/Xserver/hw/xfree86/common/xf86Option.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Option.c:1.15 xc/programs/Xserver/hw/xfree86/common/xf86Option.c:1.21 --- xc/programs/Xserver/hw/xfree86/common/xf86Option.c:1.15 Tue Jun 20 01:08:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Option.c Fri Oct 20 10:58:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Option.c,v 1.15 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Option.c,v 1.21 2000/10/20 14:58:59 alanh Exp $ */ /* * Copyright (c) 1998 by The XFree86 Project, Inc. @@ -52,38 +52,38 @@ device = xf86GetDevFromEntity(pScrn->entityList[i], pScrn->entityInstanceList[i]); if (device && device->options) { - tmp = OptionListDup(device->options); + tmp = xf86optionListDup(device->options); if (pScrn->options) - OptionListMerge(pScrn->options,tmp); + xf86optionListMerge(pScrn->options,tmp); else pScrn->options = tmp; } } if (pScrn->monitor->options) { - tmp = OptionListDup(pScrn->monitor->options); + tmp = xf86optionListDup(pScrn->monitor->options); if (pScrn->options) - pScrn->options = OptionListMerge(pScrn->options, tmp); + pScrn->options = xf86optionListMerge(pScrn->options, tmp); else pScrn->options = tmp; } if (pScrn->confScreen->options) { - tmp = OptionListDup(pScrn->confScreen->options); + tmp = xf86optionListDup(pScrn->confScreen->options); if (pScrn->options) - pScrn->options = OptionListMerge(pScrn->options, tmp); + pScrn->options = xf86optionListMerge(pScrn->options, tmp); else pScrn->options = tmp; } if (pScrn->display->options) { - tmp = OptionListDup(pScrn->display->options); + tmp = xf86optionListDup(pScrn->display->options); if (pScrn->options) - pScrn->options = OptionListMerge(pScrn->options, tmp); + pScrn->options = xf86optionListMerge(pScrn->options, tmp); else pScrn->options = tmp; } if (extras) { - tmp = OptionListDup(extras); + tmp = xf86optionListDup(extras); if (pScrn->options) - pScrn->options = OptionListMerge(pScrn->options, tmp); + pScrn->options = xf86optionListMerge(pScrn->options, tmp); else pScrn->options = tmp; } @@ -116,23 +116,23 @@ pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0); } if (pInfo->conf_idev->commonOptions) { - tmp = OptionListDup(pInfo->conf_idev->commonOptions); + tmp = xf86optionListDup(pInfo->conf_idev->commonOptions); if (pInfo->options) - pInfo->options = OptionListMerge(pInfo->options, tmp); + pInfo->options = xf86optionListMerge(pInfo->options, tmp); else pInfo->options = tmp; } if (pInfo->conf_idev->extraOptions) { - tmp = OptionListDup(pInfo->conf_idev->extraOptions); + tmp = xf86optionListDup(pInfo->conf_idev->extraOptions); if (pInfo->options) - pInfo->options = OptionListMerge(pInfo->options, tmp); + pInfo->options = xf86optionListMerge(pInfo->options, tmp); else pInfo->options = tmp; } if (extras) { - tmp = OptionListDup(extras); + tmp = xf86optionListDup(extras); if (pInfo->options) - pInfo->options = OptionListMerge(pInfo->options, tmp); + pInfo->options = xf86optionListMerge(pInfo->options, tmp); else pInfo->options = tmp; } @@ -183,55 +183,80 @@ return deflt; } +/* + * addNewOption() has the required property of replacing the option value + * it the option is alread present. + */ +pointer +xf86ReplaceIntOption(pointer optlist, char *name, int val) +{ + char *tmp = xnfalloc(16); + sprintf(tmp,"%i",val); + return xf86AddNewOption(optlist,name,tmp); +} pointer +xf86ReplaceBoolOption(pointer optlist, char *name, Bool val) +{ + return xf86AddNewOption(optlist,name,(Bool)val?"True":"False"); +} + +pointer +xf86ReplaceStrOption(pointer optlist, char *name, char* val) +{ + return xf86AddNewOption(optlist,name,val); +} + +pointer xf86AddNewOption(pointer head, char *name, char *val) { - return addNewOption(head, name, val); + char *tmp = strdup(val); + + return xf86addNewOption(head, name, tmp); } pointer xf86NewOption(char *name, char *value) { - return NewOption(name, value); + return xf86newOption(name, value); } pointer xf86NextOption(pointer list) { - return NextOption(list); + return xf86nextOption(list); } pointer xf86OptionListCreate(const char **options, int count, int used) { - return OptionListCreate(options, count, used); + return xf86optionListCreate(options, count, used); } pointer xf86OptionListMerge(pointer head, pointer tail) { - return OptionListMerge(head, tail); + return xf86optionListMerge(head, tail); } void xf86OptionListFree(pointer opt) { - OptionListFree(opt); + xf86optionListFree(opt); } char * xf86OptionName(pointer opt) { - return OptionName(opt); + return xf86optionName(opt); } char * xf86OptionValue(pointer opt) { - return OptionValue(opt); + return xf86optionValue(opt); } void @@ -240,12 +265,12 @@ XF86OptionPtr opts = parm; while(opts) { - if (OptionValue(opts)) + if (xf86optionValue(opts)) xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n", - OptionName(opts), OptionValue(opts)); + xf86optionName(opts), xf86optionValue(opts)); else - xf86ErrorFVerb( 5, "\tOption \"%s\"\n", OptionName(opts)); - opts = NextOption(opts); + xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts)); + opts = xf86nextOption(opts); } } @@ -254,14 +279,14 @@ pointer xf86FindOption(pointer options, const char *name) { - return FindOption(options, name); + return xf86findOption(options, name); } char * xf86FindOptionValue(pointer options, const char *name) { - return FindOptionValue(options, name); + return xf86findOptionValue(options, name); } @@ -278,7 +303,7 @@ { XF86OptionPtr opt; - opt = FindOption(options, name); + opt = xf86findOption(options, name); if (opt != NULL) opt->opt_used = TRUE; } @@ -297,7 +322,7 @@ { XF86OptionPtr opt; - opt = FindOption(options, name); + opt = xf86findOption(options, name); if (opt != NULL) return opt->opt_used; else @@ -353,7 +378,7 @@ char *s, *end; Bool wasUsed; - if ((s = FindOptionValue(options, p->name)) != NULL) { + if ((s = xf86findOptionValue(options, p->name)) != NULL) { wasUsed = xf86CheckIfOptionUsedByName(options, p->name); xf86MarkOptionUsedByName(options, p->name); switch (p->type) { @@ -424,32 +449,37 @@ p->name); p->found = FALSE; } else { - p->value.freq.freq = strtod(s, &end); - p->value.freq.units = 0; + double freq = strtod(s, &end); + int units = 0; + if (end != s) { p->found = TRUE; if (!xf86NameCmp(end, "Hz")) - p->value.freq.units = 1; + units = 1; else if (!xf86NameCmp(end, "kHz") || !xf86NameCmp(end, "k")) - p->value.freq.units = 1000; + units = 1000; else if (!xf86NameCmp(end, "MHz") || !xf86NameCmp(end, "M")) - p->value.freq.units = 1000000; + units = 1000000; else { xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" requires a frequency value\n", p->name); p->found = FALSE; } - if (p->found && p->value.freq.units > 0) - p->value.freq.freq *= (double)p->value.freq.units; + if (p->found) + freq *= (double)units; } else { xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" requires a frequency value\n", p->name); p->found = FALSE; } + if (p->found) { + p->value.freq.freq = freq; + p->value.freq.units = units; + } } break; case OPTV_NONE: @@ -490,7 +520,7 @@ strcat(n, p->name); newn = n; } - if ((s = FindOptionValue(options, newn)) != NULL) { + if ((s = xf86findOptionValue(options, newn)) != NULL) { xf86MarkOptionUsedByName(options, newn); if (GetBoolValue(&opt, s)) { p->value.bool = !opt.value.bool; @@ -697,7 +727,7 @@ int xf86NameCmp(const char *s1, const char *s2) { - return NameCompare(s1, s2); + return xf86nameCompare(s1, s2); } char * Index: xc/programs/Xserver/hw/xfree86/common/xf86PM.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86PM.c:3.2 xc/programs/Xserver/hw/xfree86/common/xf86PM.c:3.4 --- xc/programs/Xserver/hw/xfree86/common/xf86PM.c:3.2 Sat Feb 12 18:59:10 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86PM.c Fri Dec 8 15:13:34 2000 @@ -1,6 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PM.c,v 3.2 2000/02/12 23:59:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PM.c,v 3.4 2000/12/08 20:13:34 eich Exp $ */ -#define NOT_YET #include "X.h" #include "xf86.h" @@ -34,9 +33,10 @@ static void DoApmEvent(pmEvent event) { - /* we leave that as a global for now. I don't know if this might - * cause problems in the future. It is a global server variable - * therefore it needs to be in a server info structure + /* + * we leave that as a global function for now. I don't know if + * this might cause problems in the future. It is a global server + * variable therefore it needs to be in a server info structure */ static Bool suspended; int i; @@ -49,7 +49,6 @@ case XF86_APM_USER_SUSPEND: /* should we do this ? */ if (!suspended) { -#ifdef NOT_YET for (i = 0; i < xf86NumScreens; i++) { xf86EnableAccess(xf86Screens[i]); if (xf86Screens[i]->EnableDisableFBAccess) @@ -65,7 +64,6 @@ } xf86AccessLeave(); xf86AccessLeaveState(); -#endif suspended = TRUE; } break; @@ -75,7 +73,6 @@ case XF86_APM_STANDBY_FAILED: case XF86_APM_SUSPEND_FAILED: if (suspended) { -#ifdef NOT_YET xf86AccessEnter(); xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { @@ -92,7 +89,6 @@ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); -#endif suspended = FALSE; } break; @@ -123,7 +119,7 @@ if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) { do { for (i = 0; i < n; i++) { - xf86MsgVerb(3,X_INFO,"PM Event received: %s\n", + xf86MsgVerb(X_INFO,3,"PM Event received: %s\n", eventName(events[i])); DoApmEvent(events[i]); switch (xf86PMConfirmEventToOs(fd,events[i])) { Index: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h:1.65 xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h:1.83 --- xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h:1.65 Fri Jun 30 13:15:11 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h Thu Dec 7 16:34:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.65 2000/06/30 17:15:11 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.83 2000/12/07 21:34:20 mvojkovi Exp $ */ /* * PCI Probe * @@ -86,7 +86,6 @@ #define PCI_VENDOR_PICOP 0x1066 #define PCI_VENDOR_MYLEX 0x1069 #define PCI_VENDOR_APPLE 0x106B -/* Yahama is a guess based on chipset */ #define PCI_VENDOR_YAMAHA 0x1073 #define PCI_VENDOR_NEXGEN 0x1074 #define PCI_VENDOR_QLOGIC 0x1077 @@ -98,6 +97,7 @@ #define PCI_VENDOR_SUN 0x108E #define PCI_VENDOR_DIAMOND 0x1092 #define PCI_VENDOR_CMD 0x1095 +#define PCI_VENDOR_APPIAN 0x1097 #define PCI_VENDOR_VISION 0x1098 #define PCI_VENDOR_BROOKTREE 0x109E #define PCI_VENDOR_SIERRA 0x10A8 @@ -143,6 +143,7 @@ #define PCI_VENDOR_CYCLADES 0x120E #define PCI_VENDOR_3DFX 0x121A #define PCI_VENDOR_SIGMADESIGNS 0x1236 +#define PCI_VENDOR_SMI 0x126f #define PCI_VENDOR_ENSONIQ 0x1274 #define PCI_VENDOR_ROCKWELL 0x127A #define PCI_VENDOR_YOKOGAWA 0x1281 @@ -228,10 +229,17 @@ #define PCI_CHIP_MACH64LP 0x4C50 #define PCI_CHIP_MACH64LR 0x4C52 #define PCI_CHIP_MACH64LS 0x4C53 +#define PCI_CHIP_RAGE128MF 0x4D46 +#define PCI_CHIP_RAGE128ML 0x4D4C #define PCI_CHIP_RAGE128PF 0x5046 #define PCI_CHIP_RAGE128PR 0x5052 +#define PCI_CHIP_RADEON_QD 0x5144 +#define PCI_CHIP_RADEON_QE 0x5145 +#define PCI_CHIP_RADEON_QF 0x5146 +#define PCI_CHIP_RADEON_QG 0x5147 #define PCI_CHIP_RAGE128RE 0x5245 #define PCI_CHIP_RAGE128RF 0x5246 +#define PCI_CHIP_RAGE128RG 0x5247 #define PCI_CHIP_RAGE128RK 0x524B #define PCI_CHIP_RAGE128RL 0x524C #define PCI_CHIP_MACH64VT 0x5654 @@ -248,6 +256,7 @@ #define PCI_CHIP_VAS96011 0x0702 /* Avance Logic */ +#define PCI_CHIP_ALG2064 0x2064 #define PCI_CHIP_ALG2301 0x2301 /* NS */ @@ -315,6 +324,8 @@ #define PCI_CHIP_8420 0x8420 #define PCI_CHIP_8500 0x8500 #define PCI_CHIP_8520 0x8520 +#define PCI_CHIP_8600 0x8600 +#define PCI_CHIP_8620 0x8620 #define PCI_CHIP_9320 0x9320 #define PCI_CHIP_9388 0x9388 #define PCI_CHIP_9397 0x9397 @@ -466,6 +477,14 @@ #define PCI_CHIP_GEFORCE256 0x0100 #define PCI_CHIP_GEFORCEDDR 0x0101 #define PCI_CHIP_QUADRO 0x0103 +#define PCI_CHIP_GEFORCE2MX 0x0110 +#define PCI_CHIP_GEFORCE2MXDDR 0x0111 +#define PCI_CHIP_GEFORCE2GO 0x0112 +#define PCI_CHIP_QUADRO2MXR 0x0113 +#define PCI_CHIP_GEFORCE2GTS 0x0150 +#define PCI_CHIP_GEFORCE2GTS_1 0x0151 +#define PCI_CHIP_GEFORCE2ULTRA 0x0152 +#define PCI_CHIP_QUADRO2PRO 0x0153 /* NVIDIA & SGS */ #define PCI_CHIP_RIVA128 0x0018 @@ -518,13 +537,19 @@ #define PCI_CHIP_Trio3D_2X 0x8A13 #define PCI_CHIP_VIRGE_DXGX 0x8A01 #define PCI_CHIP_VIRGE_GX2 0x8A10 -#define PCI_CHIP_Savage3D 0x8A20 -#define PCI_CHIP_Savage3D_MV 0x8A21 -#define PCI_CHIP_Savage4 0x8A22 -#define PCI_CHIP_Savage2000 0x9102 +#define PCI_CHIP_SAVAGE3D 0x8A20 +#define PCI_CHIP_SAVAGE3D_MV 0x8A21 +#define PCI_CHIP_SAVAGE4 0x8A22 +#define PCI_CHIP_SAVAGE2000 0x9102 #define PCI_CHIP_VIRGE_MX 0x8C01 #define PCI_CHIP_VIRGE_MXPLUS 0x8C01 #define PCI_CHIP_VIRGE_MXP 0x8C03 +#define PCI_CHIP_PROSAVAGE_PM 0x8A25 +#define PCI_CHIP_PROSAVAGE_KM 0x8A26 +#define PCI_CHIP_SAVAGE_MX_MV 0x8c10 +#define PCI_CHIP_SAVAGE_MX 0x8c11 +#define PCI_CHIP_SAVAGE_IX_MV 0x8c12 +#define PCI_CHIP_SAVAGE_IX 0x8c13 /* ARK Logic */ #define PCI_CHIP_1000PV 0xA091 @@ -542,6 +567,7 @@ #define PCI_CHIP_NM2097 0x0083 #define PCI_CHIP_NM2160 0x0004 #define PCI_CHIP_NM2200 0x0005 +#define PCI_CHIP_NM2230 0x0025 #define PCI_CHIP_NM2360 0x0006 #define PCI_CHIP_NM2380 0x0016 @@ -556,6 +582,14 @@ #define PCI_CHIP_I810_E 0x7125 #define PCI_CHIP_I740_AGP 0x7800 +/* Silicon Motion Inc. */ +#define PCI_CHIP_SMI910 0x910 +#define PCI_CHIP_SMI810 0x810 +#define PCI_CHIP_SMI820 0x820 +#define PCI_CHIP_SMI710 0x710 +#define PCI_CHIP_SMI712 0x712 +#define PCI_CHIP_SMI720 0x720 + /* * first the VendorId - VendorName mapping */ @@ -614,6 +648,7 @@ {PCI_VENDOR_SUN, "Sun"}, {PCI_VENDOR_DIAMOND, "Diamond"}, {PCI_VENDOR_CMD, "CMD"}, + {PCI_VENDOR_APPIAN, "Appian Graphics"}, {PCI_VENDOR_VISION, "Vision"}, {PCI_VENDOR_BROOKTREE, "BrookTree"}, {PCI_VENDOR_SIERRA, "Sierra"}, @@ -674,6 +709,7 @@ {PCI_VENDOR_ATRONICS, "Atronics"}, {PCI_VENDOR_ARK, "ARK Logic"}, {PCI_VENDOR_YAMAHA, "Yamaha"}, + {PCI_VENDOR_SMI, "Silicon Motion Inc."}, {0,NULL} }; #endif @@ -749,8 +785,8 @@ {PCI_CHIP_MACH64GZ, "Mach64 GZ",0}, {PCI_CHIP_MACH64LB, "Mach64 LB",0}, {PCI_CHIP_MACH64LD, "Mach64 LD",0}, - {PCI_CHIP_RAGE128LE, "Rage 128 Mobility LE",0}, - {PCI_CHIP_RAGE128LF, "Rage 128 Mobility LF",0}, + {PCI_CHIP_RAGE128LE, "Rage 128 Mobility LE",0}, + {PCI_CHIP_RAGE128LF, "Rage 128 Mobility LF",0}, {PCI_CHIP_MACH64LG, "Mach64 LG",0}, {PCI_CHIP_MACH64LI, "Mach64 LI",0}, {PCI_CHIP_MACH64LM, "Mach64 LM",0}, @@ -758,8 +794,14 @@ {PCI_CHIP_MACH64LP, "Mach64 LP",0}, {PCI_CHIP_MACH64LR, "Mach64 LR",0}, {PCI_CHIP_MACH64LS, "Mach64 LS",0}, - {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0}, - {PCI_CHIP_RAGE128PR, "Rage 128 Pro PR",0}, + {PCI_CHIP_RAGE128MF, "Rage 128 Mobility MF",0}, + {PCI_CHIP_RAGE128ML, "Rage 128 Mobility ML",0}, + {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0}, + {PCI_CHIP_RAGE128PR, "Rage 128 Pro PR",0}, + {PCI_CHIP_RADEON_QD, "Radeon QD",0}, + {PCI_CHIP_RADEON_QE, "Radeon QE",0}, + {PCI_CHIP_RADEON_QF, "Radeon QF",0}, + {PCI_CHIP_RADEON_QG, "Radeon QG",0}, {PCI_CHIP_RAGE128RE, "Rage 128 RE",0}, {PCI_CHIP_RAGE128RF, "Rage 128 RF",0}, {PCI_CHIP_RAGE128RK, "Rage 128 RK",0}, @@ -872,6 +914,8 @@ {PCI_CHIP_8420, "CyberBlade/DSTN/i7",0}, {PCI_CHIP_8500, "CyberBlade/i1",0}, {PCI_CHIP_8520, "CyberBlade/DSTN/i1",0}, + {PCI_CHIP_8600, "CyberBlade/Ai1",0}, + {PCI_CHIP_8620, "CyberBlade/DSTN/Ai1",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_ALI, { @@ -953,6 +997,7 @@ {PCI_CHIP_TI_PERMEDIA2, "Permedia 2",0}, {PCI_CHIP_PCI_1130, "PCI 1130",0}, {PCI_CHIP_PCI_1131, "PCI 1131",0}, + {0x8019, "TSB12LV23 IEEE1394/FireWire",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_SONY, { @@ -979,8 +1024,8 @@ {PCI_VENDOR_NUMNINE, { {PCI_CHIP_I128, "Imagine 128",0}, {PCI_CHIP_I128_2, "Imagine 128 II",0}, - {PCI_CHIP_I128_T2R, "Imagine 128 T2R",0}, - {PCI_CHIP_I128_T2R4, "Imagine 128 T2R4",0}, + {PCI_CHIP_I128_T2R, "Imagine 128 Rev 3D T2R",0}, + {PCI_CHIP_I128_T2R4, "Imagine 128 Rev IV T2R4",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_UMC, { @@ -1007,6 +1052,9 @@ {0x0001, "Bandit",0 }, {0x0002, "Grand Central",0 }, {0x000E, "Hydra",0 }, + {0x0019, "Keylargo USB",0 }, + {0x0020, "Uni-North AGP",0 }, + {0x0022, "Keylargo I/O",0 }, {0x0000, NULL,0}}}, #ifdef INCLUDE_EMPTY_LISTS {PCI_VENDOR_NEXGEN, { @@ -1051,6 +1099,7 @@ {PCI_VENDOR_SUN, { {0x1000, "EBUS",0 }, {0x1001, "Happy Meal",0 }, + {0x5000, "Advanced PCI bridge",0 }, {0x8000, "PCI Bus Module",0 }, {0x0000, NULL,0}}}, {PCI_VENDOR_CMD, { @@ -1059,6 +1108,11 @@ {0x0646, "646",0 }, {0x0670, "670",0 }, {0x0000, NULL,0}}}, +#endif + {PCI_VENDOR_APPIAN, { + {0x3D32, "Jeronimo 2000 AGP",0 }, + {0x0000, NULL,0}}}, +#ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_VISION, { {0x0001, "QD 8500",0 }, {0x0002, "QD 8580",0 }, @@ -1127,6 +1181,7 @@ {PCI_CHIP_NM2093, "NM2093",0}, {PCI_CHIP_NM2160, "NM2160",0}, {PCI_CHIP_NM2200, "NM2200",0}, + {PCI_CHIP_NM2230, "NM2230 MagicMedia 256AV+",0}, {PCI_CHIP_NM2360, "NM2360",0}, {PCI_CHIP_NM2380, "NM2380",0}, #ifdef VENDOR_INCLUDE_NONVIDEO @@ -1155,6 +1210,13 @@ {PCI_CHIP_GEFORCE256, "GeForce 256",0}, {PCI_CHIP_GEFORCEDDR, "GeForce DDR",0}, {PCI_CHIP_QUADRO, "Quadro",0}, + {PCI_CHIP_GEFORCE2MX, "GeForce2 MX",0}, + {PCI_CHIP_GEFORCE2MXDDR,"GeForce2 MX DDR",0}, + {PCI_CHIP_QUADRO2MXR, "GeForce2 MXR",0}, + {PCI_CHIP_GEFORCE2GTS, "GeForce2 GTS",0}, + {PCI_CHIP_GEFORCE2GTS_1,"GeForce2 GTS (rev 1)",0}, + {PCI_CHIP_GEFORCE2ULTRA,"GeForce2 Ultra",0}, + {PCI_CHIP_QUADRO2PRO, "Quadro 2 Pro",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_IMS, { @@ -1317,6 +1379,7 @@ {PCI_CHIP_PERMEDIA3, "GLINT Permedia 3",0}, {0x0000, NULL,0}}}, {PCI_VENDOR_AVANCE_2, { + {PCI_CHIP_ALG2064, "ALG2064",0}, {0x0000, NULL,0}}}, {PCI_VENDOR_S3, { {PCI_CHIP_PLATO, "PLATO/PX",0}, @@ -1331,10 +1394,16 @@ {PCI_CHIP_VIRGE_VX, "ViRGE/VX",0}, {PCI_CHIP_VIRGE_DXGX, "ViRGE/DX or /GX",0}, {PCI_CHIP_VIRGE_GX2, "ViRGE/GX2",0}, - {PCI_CHIP_Savage3D, "Savage3D (86E391)",0}, - {PCI_CHIP_Savage3D_MV, "Savage3D+MacroVision (86E390)",0}, - {PCI_CHIP_Savage4, "Savage4",0}, - {PCI_CHIP_Savage2000, "Savage2000",0}, + {PCI_CHIP_SAVAGE3D, "Savage3D (86E391)",0}, + {PCI_CHIP_SAVAGE3D_MV, "Savage3D+MacroVision (86E390)",0}, + {PCI_CHIP_SAVAGE4, "Savage4",0}, + {PCI_CHIP_SAVAGE2000, "Savage2000",0}, + {PCI_CHIP_SAVAGE_MX, "Savage/MX",0}, + {PCI_CHIP_SAVAGE_MX_MV, "Savage/MX-MV",0}, + {PCI_CHIP_SAVAGE_IX, "Savage/IX",0}, + {PCI_CHIP_SAVAGE_IX_MV, "Savage/IX-MV",0}, + {PCI_CHIP_PROSAVAGE_PM, "ProSavage PM133",0}, + {PCI_CHIP_PROSAVAGE_KM, "ProSavage KM133",0}, {PCI_CHIP_VIRGE_MX, "ViRGE/MX",0}, {PCI_CHIP_VIRGE_MXPLUS, "ViRGE/MX+",0}, {PCI_CHIP_VIRGE_MXP, "ViRGE/MX+MV",0}, @@ -1432,6 +1501,14 @@ {0x000a, "YMF740-V Audio",0}, {0x0000, NULL,0}}}, #endif + {PCI_VENDOR_SMI, { + {PCI_CHIP_SMI910, "Lynx",0}, + {PCI_CHIP_SMI810, "LynxE",0}, + {PCI_CHIP_SMI820, "Lynx3D",0}, + {PCI_CHIP_SMI710, "LynxEM",0}, + {PCI_CHIP_SMI712, "LynxEM+",0}, + {PCI_CHIP_SMI720, "Lynx3DM",0}, + {0x0000, NULL,0}}}, {0x0000, { {0x0000, NULL,0}}}, }; Index: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Priv.h:3.67 xc/programs/Xserver/hw/xfree86/common/xf86Priv.h:3.69 --- xc/programs/Xserver/hw/xfree86/common/xf86Priv.h:3.67 Tue Jun 20 01:08:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Priv.h Thu Dec 7 10:43:40 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.67 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.69 2000/12/07 15:43:40 tsi Exp $ */ /* * Copyright (c) 1997 by The XFree86 Project, Inc. @@ -126,7 +126,7 @@ void xf86AddDevToEntity(int entityIndex, GDevPtr dev); extern void xf86PostPreInit(void); extern void xf86PostScreenInit(void); -extern memType getValidBIOSBase(PCITAG tag, int num); +extern memType getValidBIOSBase(PCITAG tag, int *num); extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag); /* xf86Config.c */ @@ -165,7 +165,6 @@ /* xf86Init.c */ Bool xf86LoadModules(char **list, pointer *optlist); -pointer xf86LoadOneModule(char *name, pointer optlist); /* xf86Io.c */ Index: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h:1.19 xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h:1.21 --- xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h:1.19 Wed May 31 03:15:00 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h Mon Nov 6 14:24:07 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.19 2000/05/31 07:15:00 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.21 2000/11/06 19:24:07 dawes Exp $ */ /* * Copyright (c) 1997,1998 by The XFree86 Project, Inc. @@ -146,17 +146,6 @@ } VidModeRec, *VidModePtr; #endif -typedef struct pciBusRec { - int brbus, brdev, brfunc; /* ID of the bridge to this bus */ - int primary, secondary, subordinate; - int subclass; /* bridge type */ - resPtr io; /* I/O range */ - resPtr mem; /* non-prefetchable memory range */ - resPtr pmem; /* prefetchable memory range */ - int brcontrol; /* bridge_control byte */ - struct pciBusRec *next; -} PciBusRec, *PciBusPtr; - /* private resource types */ #define ResNoAvoid ResBios @@ -177,6 +166,7 @@ #define CODRV01X 2 #define SYSCONS 8 #define PCVT 16 +#define WSCONS 32 #endif /* Values of xf86Info.mouseFlags */ Index: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Resources.h:1.9 xc/programs/Xserver/hw/xfree86/common/xf86Resources.h:1.11 --- xc/programs/Xserver/hw/xfree86/common/xf86Resources.h:1.9 Sun Apr 23 15:26:57 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Resources.h Tue Jul 11 12:14:57 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.9 2000/04/23 19:26:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.11 2000/07/11 16:14:57 tsi Exp $ */ #ifndef _XF86_RESOURCES_H @@ -110,5 +110,3 @@ #define RES_UNDEFINED NULL #endif - - Index: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c:1.8 xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c:1.9 --- xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c:1.8 Sun Dec 12 20:39:46 1999 +++ xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c Wed Dec 6 17:00:46 2000 @@ -1,7 +1,7 @@ /* * Copyright (c) 1999 by The XFree86 Project, Inc. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c,v 1.8 1999/12/13 01:39:46 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86VidMode.c,v 1.9 2000/12/06 22:00:46 dawes Exp $ */ /* * This file contains the VidMode functions required by the extension. @@ -294,10 +294,18 @@ return FALSE; pScrn = xf86Screens[scrnIndex]; - xf86SetViewport(pScrn->pScreen, min(0, x), min(0, y)); + pScrn->frameX0 = min( max(x, 0), + pScrn->virtualX - pScrn->currentMode->HDisplay ); + pScrn->frameX1 = pScrn->frameX0 + pScrn->currentMode->HDisplay - 1; + pScrn->frameY0 = min( max(y, 0), + pScrn->virtualY - pScrn->currentMode->VDisplay ); + pScrn->frameY1 = pScrn->frameY0 + pScrn->currentMode->VDisplay - 1; + if (pScrn->AdjustFrame != NULL) + (pScrn->AdjustFrame)(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); return TRUE; } + Bool VidModeGetViewPort(int scrnIndex, int *x, int *y) { Index: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c:3.60 xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c:3.62 --- xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c:3.60 Fri Jun 30 15:06:56 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c Fri Sep 22 19:41:01 2000 @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.60 2000/06/30 19:06:56 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.62 2000/09/22 23:41:01 keithp Exp $ */ #include "Xfuncproto.h" #include "Xmd.h" @@ -872,18 +872,6 @@ * convenient functions to post events */ -/* - * Relative devices send accumulated valuators. - */ -#define RELATIVE_CHECK(VALUATOR,IDX) \ - { \ - if (!is_absolute) { \ - (VALUATOR) += axisvals[(IDX)]; \ - axisvals[(IDX)] = (VALUATOR); \ - } \ - } - - void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute, @@ -903,13 +891,16 @@ Bool is_shared = xf86ShareCorePointer(device); Bool drag = xf86SendDragEvents(device); ValuatorClassPtr val = device->valuator; + int valuator[6]; + int oldaxis[6]; int *axisvals; AxisInfoPtr axes; int dx, dy; float mult; -#ifdef XFreeXDGA - int rawx = 0, rawy = 0; -#endif + int x, y; + int loop_start; + int i; + int num; DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) switch=0x%x is_core=%s is_shared=%s is_absolute=%s\n", device, device->name, switch_device, @@ -921,7 +912,7 @@ xf86SwitchCoreDevice(switch_device, device); } - current = GetTimeInMillis(); + xf86Info.lastEventTime = xev->time = current = GetTimeInMillis(); if (!is_core) { if (HAS_MOTION_HISTORY(local)) { @@ -940,207 +931,150 @@ va_start(var, num_valuators); + loop_start = 0; for(loop=0; loopvaluator0 = va_arg(var, int); - if (loop == num_valuators) - RELATIVE_CHECK(xv->valuator0, loop+first_valuator); - break; - case 1: - xv->valuator1 = va_arg(var, int); - - DBG(5, ErrorF("xf86PostMotionEvent v0=%d v1=%d\n", xv->valuator0, xv->valuator1)); - -#ifdef XFreeXDGA + + valuator[loop%6] = va_arg(var,int); + + if (loop % 6 == 5 || loop == num_valuators - 1) { + num = loop % 6 + 1; /* - * DGA wants raw dx/dy (or at least, I think it does -keithp) + * Adjust first two relative valuators */ - rawx = xv->valuator0; - rawy = xv->valuator1; - if (is_absolute) - { - rawx -= local->old_x; - rawy -= local->old_y; - } -#endif - if (loop == 1 && !is_absolute && device->ptrfeed && device->ptrfeed->ctrl.num) { - /* modeled from xf86Events.c */ - if (device->ptrfeed->ctrl.threshold) { - if ((abs(xv->valuator0) + abs(xv->valuator1)) >= device->ptrfeed->ctrl.threshold) { - xv->valuator0 = (xv->valuator0 * device->ptrfeed->ctrl.num) / - device->ptrfeed->ctrl.den; - xv->valuator1 = (xv->valuator1 * device->ptrfeed->ctrl.num) / - device->ptrfeed->ctrl.den; - } - } - else if (xv->valuator0 || xv->valuator1) { - dx = xv->valuator0; - dy = xv->valuator1; - mult = pow((float)(dx*dx+dy*dy), - ((float)(device->ptrfeed->ctrl.num) / - (float)(device->ptrfeed->ctrl.den) - 1.0) / - 2.0) / 2.0; - if (dx) { - local->dxremaind = mult * (float)dx + local->dxremaind; - xv->valuator0 = dx = (int)local->dxremaind; - local->dxremaind = local->dxremaind - (float)dx; + if (!is_absolute && num_valuators >= 2 && loop_start == 0) { + + dx = valuator[0]; + dy = valuator[1]; + + /* + * Accelerate + */ + if (device->ptrfeed && device->ptrfeed->ctrl.num) { + /* modeled from xf86Events.c */ + if (device->ptrfeed->ctrl.threshold) { + if ((abs(dx) + abs(dy)) >= device->ptrfeed->ctrl.threshold) { + valuator[0] = (dx * device->ptrfeed->ctrl.num) / + device->ptrfeed->ctrl.den; + valuator[1] = (dy * device->ptrfeed->ctrl.num) / + device->ptrfeed->ctrl.den; + } } - if (dy) { - local->dyremaind = mult * (float)dy + local->dyremaind; - xv->valuator1 = dy = (int)local->dyremaind; - local->dyremaind = local->dyremaind - (float)dy; + else if (dx || dy) { + mult = pow((float)(dx*dx+dy*dy), + ((float)(device->ptrfeed->ctrl.num) / + (float)(device->ptrfeed->ctrl.den) - 1.0) / + 2.0) / 2.0; + if (dx) { + local->dxremaind = mult * (float)dx + local->dxremaind; + valuator[0] = (int)local->dxremaind; + local->dxremaind = local->dxremaind - (float)valuator[0]; + } + if (dy) { + local->dyremaind = mult * (float)dy + local->dyremaind; + valuator[1] = (int)local->dyremaind; + local->dyremaind = local->dyremaind - (float)valuator[1]; + } } + DBG(6, ErrorF("xf86PostMotionEvent acceleration v0=%d v1=%d\n", + valuator[0], valuator[1])); } - DBG(6, ErrorF("xf86PostMotionEvent acceleration v0=%d v1=%d\n", xv->valuator0, xv->valuator1)); - } - - /* mr Sat Jul 5 13:46:55 MET 1997 - * fix to recognize XWarpCursor requests - * FL Thu Nov 12 07:42:03 1998 - * Fix the fix to revert x/y coordinates to valuators space. - * This has to be done only for relative devices which control - * the core pointer. - */ - if ((loop == 1) && !is_absolute && (is_core || is_shared)) { - int x1, y1; - - miPointerPosition(&x1,&y1); - if (x1!=local->old_x || y1!=local->old_y ) { - if (!local->reverse_conversion_proc) { - axisvals[loop+first_valuator-1] = x1; - axisvals[loop+first_valuator] = y1; - } - else { - (*local->reverse_conversion_proc)(local, x1, y1, axisvals); + /* + * Map current position back to device space in case + * the cursor was warped + */ + if (is_core || is_shared) + { + miPointerPosition (&x, &y); + if (local->reverse_conversion_proc) + (*local->reverse_conversion_proc)(local, x, y, axisvals); + else + { + axisvals[0] = x; + axisvals[1] = y; } - DBG(5, ErrorF("xf86PostMotionEvent(mr) x1=%d y1=%d\n", x1,y1)); } - } - RELATIVE_CHECK(xv->valuator0, loop+first_valuator-1); - RELATIVE_CHECK(xv->valuator1, loop+first_valuator); - break; - case 2: - xv->valuator2 = va_arg(var, int); - RELATIVE_CHECK(xv->valuator2, loop+first_valuator); - break; - case 3: - xv->valuator3 = va_arg(var, int); - RELATIVE_CHECK(xv->valuator3, loop+first_valuator); - break; - case 4: - xv->valuator4 = va_arg(var, int); - RELATIVE_CHECK(xv->valuator4, loop+first_valuator); - break; - case 5: - xv->valuator5 = va_arg(var, int); - RELATIVE_CHECK(xv->valuator5, loop+first_valuator); - break; - } - if ((loop % 6 == 5) || (loop == num_valuators - 1)) { - xv->num_valuators = (loop % 6) + 1; - xv->first_valuator = first_valuator + (loop / 6) * 6; - + } + + /* + * Update axes + */ + for (i = 0; i < num; i++) + { + oldaxis[i] = axisvals[loop_start + i]; + if (is_absolute) + axisvals[loop_start + i] = valuator[i]; + else + axisvals[loop_start + i] += valuator[i]; + } + + /* + * Deliver extension event + */ if (!is_core) { xev->type = DeviceMotionNotify; xev->detail = 0; - xf86Info.lastEventTime = xev->time = current; xev->deviceid = device->id | MORE_EVENTS; xv->type = DeviceValuator; xv->deviceid = device->id; xv->device_state = 0; + xv->num_valuators = num; + xv->first_valuator = loop_start; + memcpy (&xv->valuator0, &axisvals[loop_start], + sizeof(INT32)*xv->num_valuators); if (HAS_MOTION_HISTORY(local)) { *(Time*)buff = current; - memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator, &xv->valuator0, + memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator, + &axisvals[loop_start], sizeof(INT32)*xv->num_valuators); } ENQUEUE(xE); } - /* Drag is true if no buttons are down, or if there are buttons - * down and SendDragEvents is true. + + /* + * Deliver core event */ - if ((is_core || is_shared) && (num_valuators >= 2) && drag) { - int x, y; - - if ((*local->conversion_proc)(local, - xv->first_valuator, - xv->num_valuators, - xv->valuator0, - xv->valuator1, - xv->valuator2, - xv->valuator3, - xv->valuator4, - xv->valuator5, - &x, &y) == FALSE) { - DBG(4, ErrorF("xf86PostMotionEvent conversion failed\n")); - continue; - } - - DBG(4, ErrorF("xf86PostMotionEvent x=%d y=%d\n", x, y)); - - if (x == local->old_x && y == local->old_y) { - DBG(4, ErrorF("xf86PostMotionEvent same cursor position continuing\n")); - continue; - } - - xf86Info.lastEventTime = current; - - /* FL [Sat Jun 14 14:32:01 1997] - * needs to integrate with DGA and XTEST event posting - */ - + if (is_core || is_shared && num_valuators >= 2 && loop_start == 0) { #ifdef XFreeXDGA + /* + * Let DGA peek at the event and steal it + */ xev->type = MotionNotify; - if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, rawx, rawy )) { -#endif - miPointerAbsoluteCursor(x, y, xf86Info.lastEventTime); - - /* Fix valuators for relative devices when the mi layer - * has bounded the x and y coordinates. This is needed - * to be sure to have an exact mapping between x,y coordinates - * and valuators space. - */ - if (!is_absolute) { - int x1, y1; - - miPointerPosition(&x1, &y1); - - /* The mi layer has bounded the coordinates. - */ - if (x != x1 || y != y1) { - /* When there is no reverse conversion proc, we - * asume that x,y are mapped to the first valuators. - */ - if (!local->reverse_conversion_proc) { - axisvals[0] = x1; - axisvals[1] = y1; - } - else { - (*local->reverse_conversion_proc)(local, x1, y1, axisvals); - } - x = x1; - y = y1; - } - } -#ifdef XFreeXDGA + xev->detail = 0; + if (is_absolute) + { + dx = axisvals[0] - oldaxis[0]; + dy = axisvals[1] - oldaxis[1]; } + if (DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, + xE, dx, dy)) + continue; #endif - /* Save the core pointer coordinates to be able to work - * with multiple relative devices and to detect XWarpCursor - * requests. - */ - local->old_x = x; - local->old_y = y; + if (!(*local->conversion_proc)(local, loop_start, num, + axisvals[0], axisvals[1], + axisvals[2], axisvals[3], + axisvals[4], axisvals[5], + &x, &y)) + continue; - /* If the device don't send extended events, stop the loop. + if (drag) + miPointerAbsoluteCursor (x, y, current); + /* + * Retrieve the position */ - if (!is_shared) - break; + miPointerPosition (&x, &y); + if (local->reverse_conversion_proc) + (*local->reverse_conversion_proc)(local, x, y, axisvals); + else + { + axisvals[0] = x; + axisvals[1] = y; + } } + loop_start = loop + 1; } } va_end(var); Index: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h:3.31 xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h:3.32 --- xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h:3.31 Sun Dec 26 19:39:43 1999 +++ xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h Wed Nov 29 10:51:20 2000 @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.31 1999/12/27 00:39:43 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.32 2000/11/29 15:51:20 dawes Exp $ */ #ifndef _xf86Xinput_h #define _xf86Xinput_h @@ -167,8 +167,6 @@ void xf86XinputFinalizeInit(DeviceIntPtr dev); Bool xf86CheckButton(int button, int down); void xf86SwitchCoreDevice(LocalDevicePtr device, DeviceIntPtr core); -void xf86AddLocalDevice(LocalDevicePtr device, pointer options); -Bool xf86RemoveLocalDevice(LocalDevicePtr device); LocalDevicePtr xf86FirstLocalDevice(void); int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow); void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y); Index: xc/programs/Xserver/hw/xfree86/common/xf86fbBus.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/common/xf86fbBus.c:1.1 --- /dev/null Mon Dec 18 14:29:40 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86fbBus.c Wed Dec 6 10:35:11 2000 @@ -0,0 +1,71 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbBus.c,v 1.1 2000/12/06 15:35:11 eich Exp $ */ + +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + */ + +/* + * This file contains the interfaces to the bus-specific code + */ + +#include +#include +#include +#include "X.h" +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Resources.h" + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#define NEED_OS_RAC_PROTOS +#include "xf86_OSproc.h" + +#include "xf86RAC.h" + +Bool fbSlotClaimed = FALSE; + +int +xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active) +{ + EntityPtr p; + BusAccPtr pbap = xf86BusAccInfo; + int num; + + num = xf86AllocateEntity(); + p = xf86Entities[num]; + p->driver = drvp; + p->chipset = 0; + p->busType = BUS_NONE; + p->active = active; + p->inUse = FALSE; + xf86AddDevToEntity(num, dev); + p->access = xnfcalloc(1,sizeof(EntityAccessRec)); + p->access->fallback = &AccessNULL; + p->access->pAccess = &AccessNULL; + p->busAcc = NULL; + + fbSlotClaimed = TRUE; + return num; +} + +/* + * Get the list of FB "slots" claimed by a screen + */ +int +xf86GetFbInfoForScreen(int scrnIndex) +{ + int num = 0; + int i; + EntityPtr p; + + for (i = 0; i < xf86Screens[scrnIndex]->numEntities; i++) { + p = xf86Entities[xf86Screens[scrnIndex]->entityList[i]]; + if (p->busType == BUS_NONE) { + num++; + } + } + return num; +} Index: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86fbman.c:1.15 xc/programs/Xserver/hw/xfree86/common/xf86fbman.c:1.19 --- xc/programs/Xserver/hw/xfree86/common/xf86fbman.c:1.15 Sat Jun 10 14:10:59 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86fbman.c Fri Nov 24 18:18:29 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.15 2000/06/10 18:10:59 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.19 2000/11/24 23:18:29 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -11,7 +11,6 @@ static int xf86FBMangerIndex = -1; static unsigned long xf86ManagerGeneration = 0; - Bool xf86RegisterOffscreenManager( ScreenPtr pScreen, FBManagerFuncsPtr funcs @@ -78,6 +77,27 @@ } +FBLinearPtr +xf86AllocateOffscreenLinear( + ScreenPtr pScreen, + int length, + int gran, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +){ + FBManagerFuncsPtr funcs; + + if(xf86FBMangerIndex < 0) + return NULL; + if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + return NULL; + + return (*funcs->AllocateOffscreenLinear)( + pScreen, length, gran, moveCB, removeCB, privData); +} + + void xf86FreeOffscreenArea(FBAreaPtr area) { @@ -97,6 +117,25 @@ } +void +xf86FreeOffscreenLinear(FBLinearPtr area) +{ + FBManagerFuncsPtr funcs; + + if(!area) return; + + if(xf86FBMangerIndex < 0) + return; + if(!(funcs = + (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + return; + + (*funcs->FreeOffscreenLinear)(area); + + return; +} + + Bool xf86ResizeOffscreenArea( FBAreaPtr resize, @@ -115,7 +154,25 @@ return (*funcs->ResizeOffscreenArea)(resize, w, h); } +Bool +xf86ResizeOffscreenLinear( + FBLinearPtr resize, + int size +){ + FBManagerFuncsPtr funcs; + + if(!resize) return FALSE; + + if(xf86FBMangerIndex < 0) + return FALSE; + if(!(funcs = + (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr)) + return FALSE; + + return (*funcs->ResizeOffscreenLinear)(resize, size); +} + Bool xf86QueryLargestOffscreenArea( ScreenPtr pScreen, @@ -126,6 +183,9 @@ ){ FBManagerFuncsPtr funcs; + *w = 0; + *h = 0; + if(xf86FBMangerIndex < 0) return FALSE; if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) @@ -135,7 +195,27 @@ pScreen, w, h, gran, preferences, severity); } +Bool +xf86QueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int gran, + int severity +){ + FBManagerFuncsPtr funcs; + + *size = 0; + if(xf86FBMangerIndex < 0) + return FALSE; + if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + return FALSE; + + return (*funcs->QueryLargestOffscreenLinear)( + pScreen, size, gran, severity); +} + + Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen) { @@ -158,6 +238,31 @@ static unsigned long xf86FBGeneration = 0; static int xf86FBScreenIndex = -1; +typedef struct _FBLink { + FBArea area; + struct _FBLink *next; +} FBLink, *FBLinkPtr; + +typedef struct _FBLinearLink { + FBLinear linear; + FBAreaPtr area; + struct _FBLinearLink *next; +} FBLinearLink, *FBLinearLinkPtr; + + +typedef struct { + ScreenPtr pScreen; + RegionPtr InitialBoxes; + RegionPtr FreeBoxes; + FBLinkPtr UsedAreas; + int NumUsedAreas; + FBLinearLinkPtr LinearAreas; + CloseScreenProcPtr CloseScreen; + int NumCallbacks; + FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback; + DevUnion *devPrivates; +} FBManager, *FBManagerPtr; + static void SendCallFreeBoxCallbacks(FBManagerPtr offman) @@ -636,13 +741,244 @@ return TRUE; } +static void +LinearMoveCBWrapper(FBAreaPtr from, FBAreaPtr to) +{ + /* this will never get called */ +} + +static void +LinearRemoveCBWrapper(FBAreaPtr area) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink, pLinkPrev = NULL; + ScreenPtr pScreen = area->pScreen; + + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + + pLink = offman->LinearAreas; + if(!pLink) return; + + while(pLink->area != area) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return; + } + + /* give the user the callback it is expecting */ + (*pLink->linear.RemoveLinearCallback)(&(pLink->linear)); + + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->LinearAreas = pLink->next; + + xfree(pLink); +} + + +static FBLinearPtr +localAllocateOffscreenLinear( + ScreenPtr pScreen, + int length, + int gran, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +){ + FBManagerPtr offman; + FBLinearLinkPtr link; + FBAreaPtr area; + FBLinearPtr linear = NULL; + BoxPtr extents; + int w, h, pitch; + + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + + if(!(link = xalloc(sizeof(FBLinearLink)))) + return NULL; +#if 0 + if(we have linear heap space) { + if(able to allocate some) { + link->area = NULL; + link->next = offman->LinearAreas; + offman->LinearAreas = link; + linear = link->linear; + linear->pScreen = pScreen; + linear->size = length; + linear->offset = ????; + linear->granularity = gran; + linear->MoveLinearAreaCallback = moveCB; + linear->RemoveLinearAreaCallback = removeCB; + linear->devPrivate.ptr = privData; + return linear; + } /* else fallthrough */ + } +#endif + + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + pitch = extents->x2 - extents->x1; + + if(gran && ((gran > pitch) || (pitch % gran))) { + /* we can't match the specified alignment with XY allocations */ + xfree(link); + return NULL; + } + + if(length < pitch) { /* special case */ + w = length; + h = 1; + } else { + w = pitch; + h = (length + pitch - 1) / pitch; + } + + if((area = localAllocateOffscreenArea(pScreen, w, h, gran, + moveCB ? LinearMoveCBWrapper : NULL, + removeCB ? LinearRemoveCBWrapper : NULL, + privData))) + { + link->area = area; + link->next = offman->LinearAreas; + offman->LinearAreas = link; + linear = &(link->linear); + linear->pScreen = pScreen; + linear->size = h * w; + linear->offset = (pitch * area->box.y1) + area->box.x1; + linear->granularity = gran; + linear->MoveLinearCallback = moveCB; + linear->RemoveLinearCallback = removeCB; + linear->devPrivate.ptr = privData; + } else + xfree(link); + + return linear; +} + + +static void +localFreeOffscreenLinear(FBLinearPtr linear) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink, pLinkPrev = NULL; + ScreenPtr pScreen = linear->pScreen; + + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + + pLink = offman->LinearAreas; + if(!pLink) return; + + while(&(pLink->linear) != linear) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return; + } + + if(pLink->area) { /* really an XY area */ + localFreeOffscreenArea(pLink->area); + } else { + /* free the linear area */ + } + + if(pLinkPrev) + pLinkPrev->next = pLink->next; + else offman->LinearAreas = pLink->next; + + xfree(pLink); +} + + +static Bool +localResizeOffscreenLinear(FBLinearPtr resize, int length) +{ + FBManagerPtr offman; + FBLinearLinkPtr pLink, pLinkPrev = NULL; + ScreenPtr pScreen = resize->pScreen; + + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + + pLink = offman->LinearAreas; + if(!pLink) return FALSE; + + while(&(pLink->linear) != resize) { + pLinkPrev = pLink; + pLink = pLink->next; + if(!pLink) return FALSE; + } + + /* This could actually be alot smarter and try to move allocations + from XY to linear when available. For now if it was XY, we keep + it XY */ + + if(pLink->area) { /* really an XY area */ + BoxPtr extents; + int pitch, w, h; + + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + pitch = extents->x2 - extents->x1; + + if(length < w) { /* special case */ + w = length; + h = 1; + } else { + w = pitch; + h = (length + pitch - 1) / pitch; + } + + if(localResizeOffscreenArea(pLink->area, w, h)) { + resize->size = h * w; + resize->offset = (pitch * pLink->area->box.y1) + pLink->area->box.x1; + return TRUE; + } + } else { + /* resize the linear area */ + } + + return FALSE; +} + + +static Bool +localQueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int gran, + int priority +) +{ + int w, h; + + *size = 0; + + /* for now, we only look at XY space */ + if(localQueryLargestOffscreenArea(pScreen, &w, &h, gran, + FAVOR_WIDTH_THEN_AREA, priority)) + { + FBManagerPtr offman; + BoxPtr extents; + + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + if((extents->x2 - extents->x1) == w) + *size = w * h; + return TRUE; + } + + return FALSE; +} + + + static FBManagerFuncs xf86FBManFuncs = { localAllocateOffscreenArea, localFreeOffscreenArea, localResizeOffscreenArea, localQueryLargestOffscreenArea, localRegisterFreeBoxCallback, + localAllocateOffscreenLinear, + localFreeOffscreenLinear, + localResizeOffscreenLinear, + localQueryLargestOffscreenLinear, localPurgeUnlockedOffscreenAreas }; @@ -651,6 +987,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen) { FBLinkPtr pLink, tmp; + FBLinearLinkPtr pLinearLink, tmp2; FBManagerPtr offman = (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr; @@ -658,13 +995,19 @@ pScreen->CloseScreen = offman->CloseScreen; pLink = offman->UsedAreas; - while(pLink) { tmp = pLink; pLink = pLink->next; xfree(tmp); } + pLinearLink = offman->LinearAreas; + while(pLinearLink) { + tmp2 = pLinearLink; + pLinearLink = pLinearLink->next; + xfree(tmp2); + } + REGION_DESTROY(pScreen, offman->InitialBoxes); REGION_DESTROY(pScreen, offman->FreeBoxes); @@ -742,6 +1085,7 @@ offman->pScreen = pScreen; offman->UsedAreas = NULL; + offman->LinearAreas = NULL; offman->NumUsedAreas = 0; offman->NumCallbacks = 0; offman->FreeBoxesUpdateCallback = NULL; @@ -750,82 +1094,48 @@ return TRUE; } -/*************************************************************\ - These functions are specific to this implementation and - may only be called by the driver that initialized this - implementation. -\*************************************************************/ +/* This is an implementation specific function and should + disappear after the next release. People should use the + real linear functions instead */ -FBAreaPtr -xf86AllocateLinearOffscreenArea( - ScreenPtr pScreen, - int length, - int gran, - MoveAreaCallbackProcPtr moveCB, - RemoveAreaCallbackProcPtr removeCB, - pointer privData +FBAreaPtr +xf86AllocateLinearOffscreenArea ( + ScreenPtr pScreen, + int length, + int gran, + MoveAreaCallbackProcPtr moveCB, + RemoveAreaCallbackProcPtr removeCB, + pointer privData ){ - FBManagerPtr offman; - FBLinkPtr link = NULL; - FBAreaPtr area = NULL; - RegionRec NewReg; - BoxPtr boxp, box1p = NULL; - int i, num, w, h; - - if(xf86FBScreenIndex < 0) - return NULL; - if(!(offman = pScreen->devPrivates[xf86FBScreenIndex].ptr)) - return NULL; + FBManagerFuncsPtr funcs; + FBManagerPtr offman; + BoxPtr extents; + int w, h; - if (offman->InitialBoxes->extents.x1 != 0 || - length <= 0) return NULL; + if(xf86FBMangerIndex < 0) + return NULL; + if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr)) + return NULL; - w = offman->InitialBoxes->extents.x2 - - offman->InitialBoxes->extents.x1; - h = (length + w - 1) / w; - - /* look through the free boxes, - bottom up to reduce fragmentation troubles */ - - boxp = REGION_RECTS(offman->FreeBoxes); - num = REGION_NUM_RECTS(offman->FreeBoxes); - - for (i = 0; i < num; i++, boxp++) { - if (((boxp->y2 - boxp->y1) < h) || - ((boxp->x2 - boxp->x1) < w) || - (box1p && box1p->y1 > boxp->y1)) - continue; + offman = pScreen->devPrivates[xf86FBScreenIndex].ptr; - box1p = boxp; - } + extents = REGION_EXTENTS(pScreen, offman->InitialBoxes); + w = extents->x2 - extents->x1; - if (!box1p) return NULL; - link = xalloc(sizeof(FBLink)); - if (!link) return NULL; - area = &(link->area); - - area->pScreen = pScreen; - area->granularity = gran; - area->box.x1 = box1p->x1; /* Presumed zero */ - area->box.x2 = box1p->x1 + w; - area->box.y1 = box1p->y2 - h; - area->box.y2 = box1p->y2; - area->MoveAreaCallback = moveCB; - area->RemoveAreaCallback = removeCB; - area->devPrivate.ptr = privData; - - REGION_INIT(pScreen, &NewReg, &(area->box), 1); - REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg); - REGION_UNINIT(pScreen, &NewReg); - - link->next = offman->UsedAreas; - offman->UsedAreas = link; - offman->NumUsedAreas++; + if(gran && ((gran > w) || (w % gran))) { + /* we can't match the specified alignment with XY allocations */ + return NULL; + } - SendCallFreeBoxCallbacks(offman); + if(length <= w) { /* special case */ + h = 1; + w = length; + } else { + h = (length + w - 1) / w; + } - return area; + return (*funcs->AllocateOffscreenArea)( + pScreen, w, h, gran, moveCB, removeCB, privData); } - Index: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86fbman.h:1.10 xc/programs/Xserver/hw/xfree86/common/xf86fbman.h:1.11 --- xc/programs/Xserver/hw/xfree86/common/xf86fbman.h:1.10 Sat Jun 10 14:10:59 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86fbman.h Fri Jul 14 18:38:50 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h,v 1.10 2000/06/10 18:10:59 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h,v 1.11 2000/07/14 22:38:50 mvojkovi Exp $ */ #ifndef _XF86FBMAN_H #define _XF86FBMAN_H @@ -27,27 +27,24 @@ DevUnion devPrivate; } FBArea, *FBAreaPtr; -typedef struct _FBLink { - FBArea area; - struct _FBLink *next; -} FBLink, *FBLinkPtr; +typedef struct _FBLinear { + ScreenPtr pScreen; + int size; + int offset; + int granularity; + void (*MoveLinearCallback)(struct _FBLinear*, struct _FBLinear*); + void (*RemoveLinearCallback)(struct _FBLinear*); + DevUnion devPrivate; +} FBLinear, *FBLinearPtr; typedef void (*FreeBoxCallbackProcPtr)(ScreenPtr, RegionPtr, pointer); typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr, FBAreaPtr); typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr); -typedef struct { - ScreenPtr pScreen; - RegionPtr InitialBoxes; - RegionPtr FreeBoxes; - FBLinkPtr UsedAreas; - int NumUsedAreas; - CloseScreenProcPtr CloseScreen; - int NumCallbacks; - FreeBoxCallbackProcPtr *FreeBoxesUpdateCallback; - DevUnion *devPrivates; -} FBManager, *FBManagerPtr; +typedef void (*MoveLinearCallbackProcPtr)(FBLinearPtr, FBLinearPtr); +typedef void (*RemoveLinearCallbackProcPtr)(FBLinearPtr); + typedef struct { FBAreaPtr (*AllocateOffscreenArea)( ScreenPtr pScreen, @@ -68,6 +65,21 @@ ScreenPtr pScreen, FreeBoxCallbackProcPtr FreeBoxCallback, pointer devPriv); +/* linear functions */ + FBLinearPtr (*AllocateOffscreenLinear)( + ScreenPtr pScreen, + int size, + int granularity, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData); + void (*FreeOffscreenLinear)(FBLinearPtr area); + Bool (*ResizeOffscreenLinear)(FBLinearPtr area, int size); + Bool (*QueryLargestOffscreenLinear)( + ScreenPtr pScreen, + int *size, + int granularity, + int priority); Bool (*PurgeOffscreenAreas) (ScreenPtr); } FBManagerFuncs, *FBManagerFuncsPtr; @@ -114,7 +126,18 @@ pointer privData ); +FBLinearPtr +xf86AllocateOffscreenLinear ( + ScreenPtr pScreen, + int length, + int granularity, + MoveLinearCallbackProcPtr moveCB, + RemoveLinearCallbackProcPtr removeCB, + pointer privData +); + void xf86FreeOffscreenArea(FBAreaPtr area); +void xf86FreeOffscreenLinear(FBLinearPtr area); Bool xf86ResizeOffscreenArea( @@ -122,6 +145,13 @@ int w, int h ); +Bool +xf86ResizeOffscreenLinear( + FBLinearPtr resize, + int size +); + + Bool xf86RegisterFreeBoxCallback( ScreenPtr pScreen, @@ -143,5 +173,14 @@ int preferences, int priority ); + +Bool +xf86QueryLargestOffscreenLinear( + ScreenPtr pScreen, + int *size, + int granularity, + int priority +); + #endif /* _XF86FBMAN_H */ Index: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c:3.4 xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c:3.5 --- xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c:3.4 Tue Jun 20 01:08:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c Wed Dec 6 10:35:11 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.4 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.5 2000/12/06 15:35:11 eich Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. @@ -25,6 +25,7 @@ #include "xf86RAC.h" +Bool isaSlotClaimed = FALSE; /* * If the slot requested is already in use, return FALSE. @@ -55,6 +56,7 @@ p->busAcc = pbap; pbap = pbap->next; } + isaSlotClaimed = TRUE; return num; } Index: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c:3.18 xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c:3.28 --- xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c:3.18 Tue Jun 20 01:08:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c Fri Dec 8 15:13:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.18 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.28 2000/12/08 20:13:35 eich Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. @@ -33,6 +33,7 @@ #include "xf86RAC.h" /* Bus-specific globals */ +Bool pciSlotClaimed = FALSE; pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */ pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */ pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */ @@ -116,6 +117,8 @@ static void getPciClassFlags(pciConfigPtr *pcrpp); +static void +pciConvertListToHost(int bus, int dev, int func, resPtr list); static void FindPCIVideoInfo(void) @@ -193,11 +196,29 @@ info->type[j] = 0; } + if (!(pcrp->pci_base0) && info->size[0] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base0 = pciCheckForBrokenBase(pcrp->tag,0); + if (!(pcrp->pci_base1) && info->size[1] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base1 = pciCheckForBrokenBase(pcrp->tag,1); + if (!(pcrp->pci_base2) && info->size[2] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base2 = pciCheckForBrokenBase(pcrp->tag,2); + if (!(pcrp->pci_base3) && info->size[3] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base3 = pciCheckForBrokenBase(pcrp->tag,3); + if (!(pcrp->pci_base4) && info->size[4] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base4 = pciCheckForBrokenBase(pcrp->tag,4); + if (!(pcrp->pci_base5) && info->size[5] + && PCINONSYSTEMCLASSES(info->class, info->subclass)) + pcrp->pci_base5 = pciCheckForBrokenBase(pcrp->tag,5); + /* * 64-bit base addresses are checked for and avoided. * XXX Should deal with them on platforms that support them. */ - if (pcrp->pci_base0) { if (pcrp->pci_base0 & PCI_MAP_IO) { info->ioBase[0] = (memType)PCIGETIO(pcrp->pci_base0); @@ -209,8 +230,9 @@ mem64 = TRUE; #if defined LONG64 || defined WORD64 info->memBase[0] |= - (memType)PCIGETMEMORY64HIGH(pcrp->pci_base0) << 32; + (memType)PCIGETMEMORY64HIGH(pcrp->pci_base1) << 32; #else + if (pcrp->pci_base1) info->memBase[0] = 0; #endif } @@ -228,13 +250,14 @@ mem64 = TRUE; #if defined LONG64 || defined WORD64 info->memBase[1] |= - (memType)PCIGETMEMORY64HIGH(pcrp->pci_base1) << 32; + (memType)PCIGETMEMORY64HIGH(pcrp->pci_base2) << 32; #else + if (pcrp->pci_base2) info->memBase[1] = 0; #endif } } - } else if (mem64) + } else mem64 = FALSE; if (pcrp->pci_base2 && !mem64) { @@ -247,14 +270,15 @@ if (PCI_MAP_IS64BITMEM(pcrp->pci_base2)) { mem64 = TRUE; #if defined LONG64 || defined WORD64 - info->memBase[1] |= - (memType)PCIGETMEMORY64HIGH(pcrp->pci_base1) << 32; + info->memBase[2] |= + (memType)PCIGETMEMORY64HIGH(pcrp->pci_base3) << 32; #else - info->memBase[1] = 0; + if (pcrp->pci_base3) + info->memBase[2] = 0; #endif } } - } else if (mem64) + } else mem64 = FALSE; if (pcrp->pci_base3 && !mem64) { @@ -268,13 +292,14 @@ mem64 = TRUE; #if defined LONG64 || defined WORD64 info->memBase[3] |= - (memType)PCIGETMEMORY64HIGH(pcrp->pci_base3) << 32; + (memType)PCIGETMEMORY64HIGH(pcrp->pci_base4) << 32; #else + if (pcrp->pci_base4) info->memBase[3] = 0; #endif } } - } else if (mem64) + } else mem64 = FALSE; if (pcrp->pci_base4 && !mem64) { @@ -288,13 +313,14 @@ mem64 = TRUE; #if defined LONG64 || defined WORD64 info->memBase[4] |= - (memType)PCIGETMEMORY64HIGH(pcrp->pci_base4) << 32; + (memType)PCIGETMEMORY64HIGH(pcrp->pci_base5) << 32; #else + if (pcrp->pci_base5) info->memBase[4] = 0; #endif } } - } else if (mem64) + } else mem64 = FALSE; if (pcrp->pci_base5 && !mem64) { @@ -305,7 +331,8 @@ info->type[5] = pcrp->pci_base5 & PCI_MAP_MEMORY_ATTR_MASK; info->memBase[5] = (memType)PCIGETMEMORY(pcrp->pci_base5); } - } + } else + mem64 = FALSE; info->listed_class = pcrp->listed_class; } i++; @@ -716,11 +743,11 @@ for (pbp=xf86PciBus; pbp; pbp = pbp->next) { if (pbp->primary == busIndex) { - tmp = xf86DupResList(pbp->io); + tmp = xf86DupResList(pbp->preferred_io); bridgeRes = xf86JoinResLists(tmp,bridgeRes); - tmp = xf86DupResList(pbp->mem); + tmp = xf86DupResList(pbp->preferred_mem); bridgeRes = xf86JoinResLists(tmp,bridgeRes); - tmp = xf86DupResList(pbp->pmem); + tmp = xf86DupResList(pbp->preferred_pmem); bridgeRes = xf86JoinResLists(tmp,bridgeRes); } } @@ -974,11 +1001,14 @@ resRange range; resPtr resSize = NULL; resPtr w_tmp, w = NULL, w_2nd = NULL; - PCITAG tag = pciTag(pvp->bus,pvp->device,pvp->func); + PCITAG tag; PciBusPtr pbp = xf86PciBus, pbp1 = xf86PciBus; + pciConfigPtr pcp; resPtr tmp; if (!pvp) return FALSE; + tag = pciTag(pvp->bus,pvp->device,pvp->func); + pcp = pvp->thisCard; type &= ResAccMask; if (!type) type = ResShared; @@ -1025,28 +1055,42 @@ #if 0 /*EE*/ || (res_n == 0xff)/* bios should also be prefetchable */ #endif - ) - && pbp->pmem) { - w = xf86FindIntersectOfLists(pbp->pmem,ResRange); - if (pbp->mem) { - w_2nd = xf86FindIntersectOfLists(pbp->mem,ResRange); - } - } else if (pbp->mem) { - w = xf86FindIntersectOfLists(pbp->mem,ResRange); - } - } else if (pbp->io) { + )) { + if (pbp->preferred_pmem) + w = xf86FindIntersectOfLists(pbp->preferred_pmem, + ResRange); + else if (pbp->pmem) + w = xf86FindIntersectOfLists(pbp->pmem,ResRange); + + if (pbp->preferred_mem) + w_2nd = xf86FindIntersectOfLists(pbp->preferred_mem, + ResRange); + else if (pbp->mem) + w_2nd = xf86FindIntersectOfLists(pbp->mem, + ResRange); + } else { + if (pbp->preferred_mem) + w = xf86FindIntersectOfLists(pbp->preferred_mem, + ResRange); + else if (pbp->mem) + w = xf86FindIntersectOfLists(pbp->mem,ResRange); + } + } else { + if (pbp->preferred_io) + w = xf86FindIntersectOfLists(pbp->preferred_io,ResRange); + if (pbp->io) w = xf86FindIntersectOfLists(pbp->io,ResRange); } while (pbp1) { if (pbp1->primary == pvp->bus) { if (type & ResMem) { - tmp = xf86DupResList(pbp1->pmem); + tmp = xf86DupResList(pbp1->preferred_pmem); avoid = xf86JoinResLists(avoid,tmp); - tmp = xf86DupResList(pbp1->mem); + tmp = xf86DupResList(pbp1->preferred_mem); avoid = xf86JoinResLists(avoid,tmp); } else { - tmp = xf86DupResList(pbp1->io); + tmp = xf86DupResList(pbp1->preferred_io); avoid = xf86JoinResLists(avoid,tmp); } } @@ -1058,8 +1102,7 @@ } /* convert bus based entries in avoid list to host base */ - xf86ConvertListToHost( - xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid); + pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); if (!w) w = xf86DupResList(ResRange); @@ -1206,23 +1249,36 @@ while (alignment >> (*p_size)) (*p_size)++; (*p_base) = H2B(tag,range.rBegin,type); - #ifdef DEBUG ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n", - res_n,(*p_base),(1 << (*p_size)),type | ResMem ? "Mem" : "Io"); + res_n,(*p_base),(1 << (*p_size)), (type & ResMem) ? "Mem" : "Io"); #endif - if (res_n != 0xff) { - pciWriteLong(tag,PCI_CMD_BASE_REG + res_n * sizeof(CARD32), - (CARD32)(*p_base) | (CARD32)(p_type)); + if (type & ResMem) + pvp->memBase[prt] = range.rBegin; + else + pvp->ioBase[prt] = range.rBegin; + ((CARD32 *)(&(pcp->pci_base0)))[res_n] = + (CARD32)(*p_base) | (CARD32)(p_type); + pciWriteLong(tag, PCI_CMD_BASE_REG + res_n * sizeof(CARD32), + ((CARD32 *)(&(pcp->pci_base0)))[res_n]); + if (PCI_MAP_IS64BITMEM(p_type)) { #if defined LONG64 || defined WORD64 - if (PCI_MAP_IS64BITMEM(p_type)) - pciWriteLong(tag,PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32), - (CARD32)(*p_base >> 32)); + ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = + (CARD32)(*p_base >> 32); + pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32), + ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1]); +#else + ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = 0; + pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32), + 0); #endif + } } else { - CARD32 val = pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01; - pciWriteLong(tag,PCI_CMD_BIOS_REG,(CARD32)(*p_base) | val); + pvp->biosBase = range.rBegin; + pcp->pci_baserom = (pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01) | + (CARD32)(*p_base); + pciWriteLong(tag, PCI_CMD_BIOS_REG, pcp->pci_baserom); } /* @@@ fake BIOS allocated resource */ range.type |= ResBios; @@ -1295,7 +1351,7 @@ */ memType -getValidBIOSBase(PCITAG tag, int num) +getValidBIOSBase(PCITAG tag, int *num) { pciVideoPtr pvp = NULL; PciBusPtr pbp, pbp1; @@ -1303,7 +1359,6 @@ resPtr tmp, avoid; resRange range; int n = 0; - int maxnum = 5; CARD32 biosSize, alignment; if (!xf86PciVideoInfo) return 0; @@ -1323,9 +1378,15 @@ pbp = pbp1 = xf86PciBus; while (pbp) { if (pbp->secondary == pvp->bus) { - tmp = xf86DupResList(pbp->pmem); + if (pbp->preferred_pmem) + tmp = xf86DupResList(pbp->preferred_pmem); + else + tmp = xf86DupResList(pbp->pmem); m = xf86JoinResLists(m,tmp); - tmp = xf86DupResList(pbp->mem); + if (pbp->preferred_mem) + tmp = xf86DupResList(pbp->preferred_mem); + else + tmp = xf86DupResList(pbp->mem); m = xf86JoinResLists(m,tmp); tmp = m; while (tmp) { @@ -1335,8 +1396,12 @@ } while (pbp1) { if (pbp1->primary == pvp->bus) { + tmp = xf86DupResList(pbp1->preferred_pmem); + avoid = xf86JoinResLists(avoid,tmp); tmp = xf86DupResList(pbp1->pmem); avoid = xf86JoinResLists(avoid,tmp); + tmp = xf86DupResList(pbp1->preferred_mem); + avoid = xf86JoinResLists(avoid,tmp); tmp = xf86DupResList(pbp1->mem); avoid = xf86JoinResLists(avoid,tmp); } @@ -1344,8 +1409,7 @@ } pbp = pbp->next; } - xf86ConvertListToHost( - xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid); + pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); if (pvp->biosBase) { /* try biosBase first */ P_M_RANGE(range, TAG(pvp),pvp->biosBase,biosSize,ResExcMemBlock); @@ -1355,20 +1419,27 @@ return pvp->biosBase; } } - if (num >= 0 && num <= 5 && pvp->memBase[num]) - maxnum = num; - else { - num = 0; + + /* Validate alternate base, and, on failure, look for another one */ + if ((*num < 0) || (*num > 5) || + !pvp->memBase[*num] || (pvp->size[*num] < biosSize)) { + *num = -1; + for (n = 0; n <= 5; n++) { + if (pvp->memBase[n] && (pvp->size[n] >= biosSize)) { + *num = n; + break; + } + } } - for (; num <= maxnum; num++) { + + if (*num >= 0) { /* then try suggested memBase */ /* keep bios size ! */ - P_M_RANGE(range,TAG(pvp),pvp->memBase[num],biosSize,ResExcMemBlock); - if ( pvp->size[num] >= biosSize && xf86IsSubsetOf(range,m) - && ! ChkConflict(&range,avoid,SETUP)) { + P_M_RANGE(range,TAG(pvp),pvp->memBase[*num],biosSize,ResExcMemBlock); + if (xf86IsSubsetOf(range,m) && !ChkConflict(&range,avoid,SETUP)) { xf86FreeResList(avoid); xf86FreeResList(m); - return pvp->memBase[num]; + return pvp->memBase[*num]; } } while (m) { @@ -1383,6 +1454,9 @@ xf86FreeResList(avoid); xf86FreeResList(m); + xf86MsgVerb(X_INFO,5,"GetVaildBIOSBase for %x:%x:%x: BIOSbase 0x%lx\n", + pvp->bus,pvp->device,pvp->func, + (memType)M2B(TAG(pvp),range.rBase)); return M2B(TAG(pvp),range.rBase); } @@ -1413,6 +1487,69 @@ static void alignBridgeRanges(PciBusPtr PciBusBase, PciBusPtr primary); +static void +printBridgeInfo(PciBusPtr PciBus) +{ + xf86MsgVerb(X_INFO, 3, "Bus %d: bridge is at (%d:%d:%d), " + "(%d,%d,%d), BCTRL: 0x%02x (VGA_EN is %s)\n", + PciBus->secondary,PciBus->brbus, PciBus->brdev, + PciBus->brfunc, PciBus->primary, + PciBus->secondary, PciBus->subordinate, + PciBus->brcontrol, + (PciBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN) + ? "set" : "cleared"); + xf86MsgVerb(X_INFO, 3, "Bus %d I/O range:\n", + PciBus->secondary); + xf86PrintResList(3, PciBus->preferred_io); + xf86MsgVerb(X_INFO, 3, + "Bus %d non-prefetchable memory range:\n", + PciBus->secondary); + xf86PrintResList(3, PciBus->preferred_mem); + xf86MsgVerb(X_INFO, 3, "Bus %d prefetchable memory range:" + "\n",PciBus->secondary); + xf86PrintResList(3, PciBus->preferred_pmem); +} + +/* + * This Sun PCI-->PCI bridge must be handled specially since it does + * not report the decoded I/O and MEM ranges in the usual way. + */ +#define APB_IO_ADDRESS_MAP 0xde +#define APB_MEM_ADDRESS_MAP 0xdf + +static void +get_sun_apb_ranges(PciBusPtr PciBus, pciConfigPtr pcrp) +{ + unsigned char iomap, memmap; + resRange range; + int i; + + iomap = pciReadByte(pcrp->tag, APB_IO_ADDRESS_MAP); + memmap = pciReadByte(pcrp->tag, APB_MEM_ADDRESS_MAP); + + /* if (pcrp->pci_command & PCI_CMD_IO_ENABLE) */ { /* ??? */ + for (i = 0; i < 8; i++) { + if ((iomap & (1 << i)) != 0) { + PCI_I_RANGE(range, pcrp->tag, + (i << 21), (i << 21) + ((1 << 21) - 1), + ResIo | ResBlock | ResExclusive); + PciBus->io = xf86AddResToList(PciBus->io, &range, -1); + } + } + } + + /* if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) */ { /* ??? */ + for (i = 0; i < 8; i++) { + if ((memmap & (1 << i)) != 0) { + PCI_M_RANGE(range, pcrp->tag, + (i << 29), (i << 29) + ((1 << 29) - 1), + ResMem | ResBlock | ResExclusive); + PciBus->mem = xf86AddResToList(PciBus->mem, &range, -1); + } + } + } +} + PciBusPtr xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo) { @@ -1454,8 +1591,16 @@ PciBus->brdev = pcrp->devnum; PciBus->brfunc = pcrp->funcnum; PciBus->subclass = sub_class; + PciBus->interface = pcrp->pci_prog_if; PciBus->brcontrol = pcrp->pci_bridge_control; - if (pcrp->pci_command & PCI_CMD_IO_ENABLE) { + if (pcrp->pci_vendor == PCI_VENDOR_SUN && + pcrp->pci_device == 0x5000) { + get_sun_apb_ranges(PciBus, pcrp); + break; + } + if ((pcrp->pci_command & PCI_CMD_IO_ENABLE) && + (pcrp->pci_upper_io_base || pcrp->pci_io_base || + pcrp->pci_upper_io_limit || pcrp->pci_io_limit)) { base = (pcrp->pci_upper_io_base << 16) | ((pcrp->pci_io_base & 0xf0u) << 8); limit = (pcrp->pci_upper_io_limit << 16) | @@ -1469,26 +1614,41 @@ PCI_I_RANGE(range, pcrp->tag, base, base + (CARD8)(-1), ResIo | ResBlock | ResExclusive); - PciBus->io = xf86AddResToList(PciBus->io, - &range, -1); + PciBus->preferred_io = xf86AddResToList( + PciBus->preferred_io,&range, -1); base += 0x0400; } } if (base <= limit) { PCI_I_RANGE(range, pcrp->tag, base, limit, ResIo | ResBlock | ResExclusive); - PciBus->io = xf86AddResToList(PciBus->io, &range, -1); + PciBus->preferred_io = xf86AddResToList( + PciBus->preferred_io, &range, -1); } } - if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) { + if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) { + /* + * The P2P spec requires these next two, but some bridges + * don't comply. Err on the side of caution, making the not + * so bold assumption that no bridge would ever re-route the + * bottom megabyte. + */ + if (pcrp->pci_mem_base || pcrp->pci_mem_limit) { base = pcrp->pci_mem_base & 0xfff0u; limit = pcrp->pci_mem_limit & 0xfff0u; if (base <= limit) { PCI_M_RANGE(range, pcrp->tag, base << 16, (limit << 16) | 0x0fffff, ResMem | ResBlock | ResExclusive); - PciBus->mem = xf86AddResToList(NULL, &range, -1); + PciBus->preferred_mem + = xf86AddResToList(NULL, &range, -1); } + } + + if (pcrp->pci_prefetch_mem_base || + pcrp->pci_prefetch_mem_limit || + pcrp->pci_prefetch_upper_mem_base || + pcrp->pci_prefetch_upper_mem_limit) { base = pcrp->pci_prefetch_mem_base & 0xfff0u; limit = pcrp->pci_prefetch_mem_limit & 0xfff0u; #if defined(LONG64) || defined(WORD64) @@ -1499,8 +1659,10 @@ PCI_M_RANGE(range, pcrp->tag, base << 16, (limit << 16) | 0xfffff, ResMem | ResBlock | ResExclusive); - PciBus->pmem = xf86AddResToList(NULL, &range, -1); + PciBus->preferred_pmem + = xf86AddResToList(NULL, &range, -1); } + } } break; case PCI_SUBCLASS_BRIDGE_ISA: @@ -1512,6 +1674,7 @@ PciBus->brdev = pcrp->devnum; PciBus->brfunc = pcrp->funcnum; PciBus->subclass = sub_class; + xf86MsgVerb(X_INFO,3,"PCI-to-ISA bridge:\n"); break; case PCI_SUBCLASS_BRIDGE_HOST: *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); @@ -1519,12 +1682,13 @@ PciBus->primary = -1; PciBus->secondary = -1; /* to be set below */ PciBus->subclass = sub_class; - PciBus->io = xf86ExtractTypeFromList( + PciBus->preferred_io = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResIo); - PciBus->mem = xf86ExtractTypeFromList( + PciBus->preferred_mem = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResMem); - PciBus->pmem = xf86ExtractTypeFromList( + PciBus->preferred_pmem = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResMem); + xf86MsgVerb(X_INFO,3,"Host-to-PCI bridge:\n"); break; default: break; @@ -1554,12 +1718,13 @@ PciBus->primary = -1; PciBus->secondary = i; PciBus->subclass = PCI_SUBCLASS_BRIDGE_HOST; - PciBus->io = xf86ExtractTypeFromList( + PciBus->preferred_io = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResIo); - PciBus->mem = xf86ExtractTypeFromList( + PciBus->preferred_mem = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResMem); - PciBus->pmem = xf86ExtractTypeFromList( + PciBus->preferred_pmem = xf86ExtractTypeFromList( xf86PciBusAccWindowsFromOS(),ResMem); + xf86MsgVerb(X_INFO,3,"Host-to-PCI bridge:\n"); } } } @@ -1569,6 +1734,25 @@ alignBridgeRanges(PciBusBase, PciBus); } } + for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) { + if (PciBus->subclass == PCI_SUBCLASS_BRIDGE_PCI && + PciBus->interface == PCI_IF_BRIDGE_PCI_SUBTRACTIVE) { + PciBusPtr PciBus1; + for (PciBus1 = PciBusBase; PciBus1; PciBus1 = PciBus->next) { + if (PciBus1->secondary == PciBus->primary) { + PciBus->io = PciBus1->io ? PciBus1->io + : PciBus1->preferred_io; + PciBus->mem = PciBus1->mem ? PciBus1->mem + : PciBus1->preferred_mem; + PciBus->pmem = PciBus1->pmem ? PciBus1->pmem + : PciBus1->preferred_pmem; + xf86MsgVerb(X_INFO,3,"Subtractive PCI-to-PCI bridge:\n"); + break; + } + } + } + printBridgeInfo(PciBus); + } return PciBusBase; @@ -1583,33 +1767,19 @@ if ((PciBus->primary == primary->secondary) && (PciBus->subclass == PCI_SUBCLASS_BRIDGE_PCI)) { resPtr tmp; - tmp = xf86FindIntersectOfLists(primary->io,PciBus->io); - xf86FreeResList(PciBus->io); - PciBus->io = tmp; - tmp = xf86FindIntersectOfLists(primary->pmem,PciBus->pmem); - xf86FreeResList(PciBus->pmem); - PciBus->pmem = tmp; - tmp = xf86FindIntersectOfLists(primary->mem,PciBus->mem); - xf86FreeResList(PciBus->mem); - PciBus->mem = tmp; - xf86MsgVerb(X_INFO, 3, "Bus %d: bridge is at (%d:%d:%d), " - "(%d,%d,%d), BCTRL: 0x%02x (VGA_EN is %s)\n", - PciBus->secondary,PciBus->brbus, PciBus->brdev, - PciBus->brfunc, PciBus->primary, - PciBus->secondary, PciBus->subordinate, - PciBus->brcontrol, - (PciBus->brcontrol & PCI_PCI_BRIDGE_VGA_EN) - ? "set" : "cleared"); - xf86MsgVerb(X_INFO, 3, "Bus %d I/O range:\n", - PciBus->secondary); - xf86PrintResList(3, PciBus->io); - xf86MsgVerb(X_INFO, 3, - "Bus %d non-prefetchable memory range:\n", - PciBus->secondary); - xf86PrintResList(3, PciBus->mem); - xf86MsgVerb(X_INFO, 3, "Bus %d prefetchable memory range:" - "\n",PciBus->secondary); - xf86PrintResList(3, PciBus->pmem); + tmp = xf86FindIntersectOfLists(primary->preferred_io, + PciBus->preferred_io); + xf86FreeResList(PciBus->preferred_io); + PciBus->preferred_io = tmp; + tmp = xf86FindIntersectOfLists(primary->preferred_pmem, + PciBus->preferred_pmem); + xf86FreeResList(PciBus->preferred_pmem); + PciBus->preferred_pmem = tmp; + tmp = xf86FindIntersectOfLists(primary->preferred_mem, + PciBus->preferred_mem); + xf86FreeResList(PciBus->preferred_mem); + PciBus->preferred_mem = tmp; + xf86MsgVerb(X_INFO,3,"PCI-to-PCI bridge:\n"); alignBridgeRanges(PciBusBase, PciBus); } } @@ -1724,7 +1894,6 @@ resPtr tmp, avoid = NULL; if (!pvp->validate) continue; - avoid = xf86DupResList(pciAvoidRes); NonSys = xf86DupResList(Sys); m = n; while ((pvp1 = xf86PciVideoInfo[m++])) { @@ -1746,25 +1915,37 @@ pbp = pbp1 = xf86PciBus; while (pbp) { if (pbp->secondary == pvp->bus) { - if (pbp->pmem) { + if (pbp->preferred_pmem) { /* keep prefetchable separate */ - res_mp = xf86FindIntersectOfLists(pbp->pmem,ResRange); + res_mp = xf86FindIntersectOfLists(pbp->preferred_pmem, + ResRange); } + if (pbp->pmem) { + res_mp = xf86FindIntersectOfLists(pbp->pmem, ResRange); + } + if (pbp->preferred_mem) { + res_m_io = xf86FindIntersectOfLists(pbp->preferred_mem, + ResRange); + } if (pbp->mem) { - res_m_io = xf86FindIntersectOfLists(pbp->mem,ResRange); + res_m_io = xf86FindIntersectOfLists(pbp->mem, ResRange); + } + if (pbp->preferred_io) { + res_m_io = xf86JoinResLists(res_m_io, + xf86FindIntersectOfLists(pbp->preferred_io,ResRange)); } if (pbp->io) { res_m_io = xf86JoinResLists(res_m_io, - xf86FindIntersectOfLists(pbp->io,ResRange)); + xf86FindIntersectOfLists(pbp->preferred_io,ResRange)); } } while (pbp1) { if (pbp1->primary == pvp->bus) { - tmp = xf86DupResList(pbp1->pmem); + tmp = xf86DupResList(pbp1->preferred_pmem); avoid = xf86JoinResLists(avoid,tmp); - tmp = xf86DupResList(pbp1->mem); + tmp = xf86DupResList(pbp1->preferred_mem); avoid = xf86JoinResLists(avoid,tmp); - tmp = xf86DupResList(pbp1->io); + tmp = xf86DupResList(pbp1->preferred_io); avoid = xf86JoinResLists(avoid,tmp); } pbp1 = pbp1->next; @@ -1774,8 +1955,7 @@ if (res_m_io == NULL) res_m_io = xf86DupResList(ResRange); - xf86ConvertListToHost( - xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid); + pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); #ifdef DEBUG xf86MsgVerb(X_INFO, 3,"avoid:\n"); @@ -1834,16 +2014,16 @@ "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx " "correcting\a\n", range.rBegin,range.rEnd); if (ChkConflict(&range,own,SETUP)) { - ErrorF("own\n"); - xf86PrintResList(0,own); + xf86MsgVerb(X_INFO,3,"own\n"); + xf86PrintResList(3,own); } if (ChkConflict(&range,avoid,SETUP)) { - ErrorF("avoid\n"); - xf86PrintResList(0,avoid); + xf86MsgVerb(X_INFO,3,"avoid\n"); + xf86PrintResList(3,avoid); } if (ChkConflict(&range,NonSys,SETUP)) { - ErrorF("NonSys\n"); - xf86PrintResList(0,NonSys); + xf86MsgVerb(X_INFO,3,"NonSys\n"); + xf86PrintResList(3,NonSys); } #ifdef DEBUG @@ -2192,6 +2372,7 @@ /* in case bios is enabled disable it */ disablePciBios(pciTag(bus,device,func)); + pciSlotClaimed = TRUE; return num; } else @@ -2700,11 +2881,9 @@ return j; } -void -pciConvertRange2Host(int entityIndex, resRange *pRange) +static void +pciTagConvertRange2Host(PCITAG tag, resRange *pRange) { - PCITAG tag = TAG(xf86GetPciInfoForEntity(entityIndex)); - switch(pRange->type & ResPhysMask) { case ResMem: switch(pRange->type & ResExtMask) { @@ -2737,4 +2916,26 @@ } } +static void +pciConvertListToHost(int bus, int dev, int func, resPtr list) +{ + PCITAG tag = pciTag(bus,dev,func); + while (list) { + pciTagConvertRange2Host(tag, &list->val); + list = list->next; + } +} + + +void +pciConvertRange2Host(int entityIndex, resRange *pRange) +{ + PCITAG tag; + pciVideoPtr pvp; + + pvp = xf86GetPciInfoForEntity(entityIndex); + if (!pvp) return; + tag = TAG(pvp); + pciTagConvertRange2Host(tag, pRange); +} Index: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h:3.4 xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h:3.5 --- xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h:3.4 Sat Feb 12 18:59:10 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h Tue Sep 19 08:46:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h,v 3.4 2000/02/12 23:59:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.h,v 3.5 2000/09/19 12:46:13 eich Exp $ */ #ifndef _XF86_PCI_BUS_H #define _XF86_PCI_BUS_H @@ -42,6 +42,21 @@ CARD32 pmem; CARD8 control; } pciBridgeSave, *pciBridgeSavePtr; + +typedef struct pciBusRec { + int brbus, brdev, brfunc; /* ID of the bridge to this bus */ + int primary, secondary, subordinate; + int subclass; /* bridge type */ + int interface; + resPtr preferred_io; /* I/O range */ + resPtr preferred_mem; /* non-prefetchable memory range */ + resPtr preferred_pmem; /* prefetchable memory range */ + resPtr io; /* for subtractive PCI-PCI bridges */ + resPtr mem; + resPtr pmem; + int brcontrol; /* bridge_control byte */ + struct pciBusRec *next; +} PciBusRec, *PciBusPtr; void xf86PciProbe(void); PciBusPtr xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo); Index: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c:3.3 xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c:3.5 --- xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c:3.3 Tue Jun 20 12:01:20 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c Wed Dec 6 10:35:11 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c,v 3.3 2000/06/20 16:01:20 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c,v 3.5 2000/12/06 15:35:11 eich Exp $ */ #include #include @@ -40,6 +40,8 @@ #define FB_DEV_PATH "/dev/fb%d" +Bool sbusSlotClaimed = FALSE; + sbusDevicePtr *xf86SbusInfo = NULL; static int xf86nSbusInfo; @@ -372,6 +374,7 @@ p->access = xnfcalloc(1,sizeof(EntityAccessRec)); p->access->fallback = &AccessNULL; p->access->pAccess = &AccessNULL; + sbusSlotClaimed = TRUE; return num; } else return -1; @@ -436,7 +439,7 @@ int actualcards = 0; for (i = 0; i < allocatedInstances; i++) { actualcards++; - pGDev = xf86AddBusDeviceToConfigure(driverName, BUS_SBUS, + pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS, instances[i].sbus, -1); if (pGDev) { /* Index: xc/programs/Xserver/hw/xfree86/common/xf86str.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86str.h:1.71 xc/programs/Xserver/hw/xfree86/common/xf86str.h:1.74 --- xc/programs/Xserver/hw/xfree86/common/xf86str.h:1.71 Tue Jun 20 01:08:45 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86str.h Tue Dec 12 21:44:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.71 2000/06/20 05:08:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.74 2000/12/13 02:44:59 tsi Exp $ */ /* * Copyright (c) 1997-2000 by The XFree86 Project, Inc. @@ -38,6 +38,7 @@ V_PCSYNC = 0x0080, V_NCSYNC = 0x0100, V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, V_PIXMUX = 0x1000, V_DBLCLK = 0x2000, V_CLKDIV2 = 0x4000 @@ -690,6 +691,26 @@ #define PROBE_TRYHARD 0x02 /* + * Driver entry point types + */ +typedef struct _ScrnInfoRec *ScrnInfoPtr; + +typedef Bool xf86ProbeProc (DriverPtr, int); +typedef Bool xf86PreInitProc (ScrnInfoPtr, int); +typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**); +typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int); +typedef void xf86AdjustFrameProc (int, int, int, int); +typedef Bool xf86EnterVTProc (int, int); +typedef void xf86LeaveVTProc (int, int); +typedef void xf86FreeScreenProc (int, int); +typedef int xf86ValidModeProc (int, DisplayModePtr, Bool, int); +typedef void xf86EnableDisableFBAccessProc(int, Bool); +typedef int xf86SetDGAModeProc (int, int, DGADevicePtr); +typedef int xf86ChangeGammaProc (int, Gamma); +typedef void xf86PointerMovedProc (int, int, int); +typedef Bool xf86PMEventProc (int, pmEvent); + +/* * ScrnInfoRec * * There is one of these for each screen, and it holds all the screen-specific @@ -816,7 +837,7 @@ */ int reservedInt[NUM_RESERVED_INTS]; - int * entityInstanceList; + int * entityInstanceList; pointer reservedPtr[NUM_RESERVED_POINTERS]; /* @@ -824,24 +845,20 @@ * */ - Bool (*Probe)(DriverPtr drv, int flags); - Bool (*PreInit)(struct _ScrnInfoRec *pScrn, int flags); - Bool (*ScreenInit)(int scrnIndex, ScreenPtr pScreen, - int argc, char **argv); - Bool (*SwitchMode)(int scrnIndex, DisplayModePtr mode, - int flags); - void (*AdjustFrame)(int scrnIndex, int x, int y, int flags); - Bool (*EnterVT)(int scrnIndex, int flags); - void (*LeaveVT)(int scrnIndex, int flags); - void (*FreeScreen)(int scrnIndex, int flags); - int (*ValidMode)(int scrnIndex, DisplayModePtr mode, - Bool verbose, int flags); - void (*EnableDisableFBAccess)(int scrnIndex, Bool enable); - int (*SetDGAMode)(int scrnIndex, int num, - DGADevicePtr devRet); - int (*ChangeGamma)(int scrnIndex, Gamma newGamma); - void (*PointerMoved)(int scrnIndex, int x, int y); - Bool (*PMEvent)(int scrnIndex, pmEvent event); + xf86ProbeProc *Probe; + xf86PreInitProc *PreInit; + xf86ScreenInitProc *ScreenInit; + xf86SwitchModeProc *SwitchMode; + xf86AdjustFrameProc *AdjustFrame; + xf86EnterVTProc *EnterVT; + xf86LeaveVTProc *LeaveVT; + xf86FreeScreenProc *FreeScreen; + xf86ValidModeProc *ValidMode; + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + xf86SetDGAModeProc *SetDGAMode; + xf86ChangeGammaProc *ChangeGamma; + xf86PointerMovedProc *PointerMoved; + xf86PMEventProc *PMEvent; /* * This can be used when the minor ABI version is incremented. @@ -850,7 +867,7 @@ */ funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; -} ScrnInfoRec, *ScrnInfoPtr; +} ScrnInfoRec; typedef struct { @@ -920,6 +937,14 @@ /* These are used by xf86GetClocks */ #define CLK_REG_SAVE -1 #define CLK_REG_RESTORE -2 + +/* xf86Debug.c */ +#ifdef BUILDDEBUG +typedef struct { + long sec; + long usec; +} xf86TsRec, *xf86TsPtr; +#endif /* * misc constants Index: xc/programs/Xserver/hw/xfree86/common/xf86xv.c diff -u xc/programs/Xserver/hw/xfree86/common/xf86xv.c:1.26 xc/programs/Xserver/hw/xfree86/common/xf86xv.c:1.28 --- xc/programs/Xserver/hw/xfree86/common/xf86xv.c:1.26 Fri Jun 9 18:41:06 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86xv.c Fri Aug 4 23:32:37 2000 @@ -6,7 +6,7 @@ */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.26 2000/06/09 22:41:06 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.28 2000/08/05 03:32:37 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -694,14 +694,14 @@ &ClipRegion, portPriv->DevPriv.ptr); if(ret == Success) - portPriv->isOn = TRUE; + portPriv->isOn = XV_ON; CLIP_VIDEO_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } /* This clip was copied and only good for one shot */ @@ -782,14 +782,14 @@ portPriv->drw_w, portPriv->drw_h, &ClipRegion, portPriv->DevPriv.ptr); - if(ret == Success) portPriv->isOn = TRUE; + if(ret == Success) portPriv->isOn = XV_ON; CLIP_VIDEO_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } /* This clip was copied and only good for one shot */ @@ -866,14 +866,14 @@ WinBox.x1, WinBox.y1, &ClipRegion, portPriv->DevPriv.ptr); - portPriv->isOn = (ret == Success); + portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF; CLIP_VIDEO_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } /* This clip was copied and only good for one shot */ @@ -982,10 +982,10 @@ while(WinPriv) { XvPortRecPrivatePtr pPriv = WinPriv->PortRec; - if(pPriv->isOn) { + if(pPriv->isOn > XV_OFF) { (*pPriv->AdaptorRec->StopVideo)( pPriv->pScrn, pPriv->DevPriv.ptr, TRUE); - pPriv->isOn = FALSE; + pPriv->isOn = XV_OFF; } pPriv->pDraw = NULL; @@ -1043,9 +1043,11 @@ else if(AreasExposed) { XF86XVWindowPtr tmp; - (*pPriv->AdaptorRec->StopVideo)( - pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = FALSE; + if (pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)( + pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); + pPriv->isOn = XV_PENDING; + } pPriv->pDraw = NULL; if(!pPrev) @@ -1089,9 +1091,11 @@ window isn't visible. But we only remove the images. */ if(pPriv->type || !visible) { - (*pPriv->AdaptorRec->StopVideo)( + if(pPriv->isOn == XV_ON) { + (*pPriv->AdaptorRec->StopVideo)( pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); - pPriv->isOn = FALSE; + pPriv->isOn = XV_PENDING; + } if(!pPriv->type) { /* overlaid still/image */ pPriv->pDraw = NULL; @@ -1204,10 +1208,11 @@ for(j = 0; j < pAdaptor->nPorts; j++) { pPort = &pAdaptor->pPorts[j]; pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - if(pPriv->isOn) { + if(pPriv->isOn > XV_OFF) { + (*pPriv->AdaptorRec->StopVideo)( pPriv->pScrn, pPriv->DevPriv.ptr, TRUE); - pPriv->isOn = FALSE; + pPriv->isOn = XV_OFF; if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) REGION_DESTROY(pScreen, pPriv->pCompositeClip); @@ -1248,7 +1253,7 @@ for(i = pa->nPorts; i > 0; i--, pPort++) { pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; - if(!pPriv->type && pPriv->isOn) { /* overlaid still/image */ + if(!pPriv->type && (pPriv->isOn == XV_ON)) { /* overlaid still/image */ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) REGION_DESTROY(pScreen, pPriv->pCompositeClip); @@ -1266,7 +1271,7 @@ (*pPriv->AdaptorRec->StopVideo)( pPriv->pScrn, pPriv->DevPriv.ptr, FALSE); xf86XVRemovePortFromWindow(pWin, pPriv); - pPriv->isOn = FALSE; + pPriv->isOn = XV_PENDING; continue; } } @@ -1424,7 +1429,7 @@ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) { xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - portPriv->isOn = TRUE; + portPriv->isOn = XV_ON; portPriv->pDraw = pDraw; portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; @@ -1435,10 +1440,10 @@ PUT_STILL_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } REGION_UNINIT(pScreen, &WinRegion); @@ -1548,10 +1553,10 @@ GET_STILL_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } REGION_UNINIT(pScreen, &WinRegion); @@ -1579,10 +1584,10 @@ /* Must free resources. */ - if(portPriv->isOn) { + if(portPriv->isOn > XV_OFF) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, TRUE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_OFF; } return Success; @@ -1720,7 +1725,7 @@ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) { xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); - portPriv->isOn = TRUE; + portPriv->isOn = XV_ON; portPriv->pDraw = pDraw; portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; portPriv->drw_w = drw_w; portPriv->drw_h = drw_h; @@ -1731,10 +1736,10 @@ PUT_IMAGE_BAILOUT: - if((clippedAway || (ret != Success)) && portPriv->isOn) { + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { (*portPriv->AdaptorRec->StopVideo)( portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); - portPriv->isOn = FALSE; + portPriv->isOn = XV_PENDING; } REGION_UNINIT(pScreen, &WinRegion); Index: xc/programs/Xserver/hw/xfree86/common/xf86xv.h diff -u xc/programs/Xserver/hw/xfree86/common/xf86xv.h:1.17 xc/programs/Xserver/hw/xfree86/common/xf86xv.h:1.19 --- xc/programs/Xserver/hw/xfree86/common/xf86xv.h:1.17 Fri Jun 9 18:41:06 2000 +++ xc/programs/Xserver/hw/xfree86/common/xf86xv.h Thu Nov 2 11:33:27 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.17 2000/06/09 22:41:06 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.19 2000/11/02 16:33:27 tsi Exp $ */ #ifndef _XVDIX_H_ #define _XVDIX_H_ @@ -68,7 +68,7 @@ short vid_x, short vid_y, short drw_x, short drw_y, short vid_w, short vid_h, short drw_w, short drw_h, RegionPtr clipBoxes, pointer data ); -typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool exit); +typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit); typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data); typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute, @@ -79,7 +79,7 @@ typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, short drw_y, short src_w, short src_h, short drw_w, short drw_h, - int image, unsigned char* buf, short width, short height, Bool sync, + int image, unsigned char* buf, short width, short height, Bool Sync, RegionPtr clipBoxes, pointer data ); typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn, short drw_x, short drw_y, RegionPtr clipBoxes, pointer data ); @@ -87,6 +87,12 @@ int image, unsigned short *width, unsigned short *height, int *pitches, int *offsets); +typedef enum { + XV_OFF, + XV_PENDING, + XV_ON +} XvStatus; + /*** this is what the driver needs to fill out ***/ typedef struct { @@ -235,7 +241,7 @@ RegionPtr pCompositeClip; Bool FreeCompositeClip; XvAdaptorRecPrivatePtr AdaptorRec; - Bool isOn; + XvStatus isOn; Bool moved; int vid_x, vid_y, vid_w, vid_h; int drw_x, drw_y, drw_w, drw_h; Index: xc/programs/Xserver/hw/xfree86/common/xisb.c diff -u xc/programs/Xserver/hw/xfree86/common/xisb.c:1.4 xc/programs/Xserver/hw/xfree86/common/xisb.c:1.5 --- xc/programs/Xserver/hw/xfree86/common/xisb.c:1.4 Sat Mar 6 08:12:32 1999 +++ xc/programs/Xserver/hw/xfree86/common/xisb.c Mon Nov 6 14:24:07 2000 @@ -24,7 +24,7 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xisb.c,v 1.4 1999/03/06 13:12:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xisb.c,v 1.5 2000/11/06 19:24:07 dawes Exp $ */ /* X Input Serial Buffer routines for use in any XInput driver that accesses @@ -127,7 +127,8 @@ } } if (b->trace) - ErrorF ("read 0x%02x (%c)\n", b->buf[b->current], b->buf[b->current]); + ErrorF ("read 0x%02x (%c)\n", b->buf[b->current], + isprint(b->buf[b->current])?b->buf[b->current]:'.'); return (b->buf[b->current++]); } Index: xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c diff -u xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c:1.3 xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c:1.4 --- xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c:1.3 Sun Mar 5 18:47:50 2000 +++ xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c Mon Nov 6 14:24:07 2000 @@ -3,7 +3,7 @@ * * Copyright 1999 by Andrew C Aitchison */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c,v 1.3 2000/03/05 23:47:50 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/ddcProperty.c,v 1.4 2000/11/06 19:24:07 dawes Exp $ */ #include "misc.h" #include "xf86.h" @@ -28,7 +28,7 @@ int i, ret; #ifdef DEBUG - ErrorF("xf86SetXDDCprop(%p, %p)\n", pScrnInfo, DDC); + ErrorF("xf86SetDDCproperties(%p, %p)\n", pScrnInfo, DDC); #endif if (pScrnInfo==NULL || pScrnInfo->monitor==NULL || DDC==NULL) { @@ -60,19 +60,13 @@ ErrorF("xf86RegisterRootWindowProperty %p(%d,%d,%d,%d,%d,%p)\n", xf86RegisterRootWindowProperty, pScrnInfo->scrnIndex, - EDID1Atom, XA_STRING, 8, + EDID1Atom, XA_INTEGER, 8, 128, (unsigned char *)EDID1rawdata ); #endif ret = xf86RegisterRootWindowProperty(pScrnInfo->scrnIndex, EDID1Atom, XA_INTEGER, 8, -#if 1 128, (unsigned char *)EDID1rawdata -#else -#define EDID1_DUMMY_STRING "Dummy EDID1 property - please insert correct values" - strlen(EDID1_DUMMY_STRING), - EDID1_DUMMY_STRING -#endif ); #ifdef DEBUG ErrorF("xf86RegisterRootWindowProperty returns %d\n", ret ); @@ -80,15 +74,35 @@ } else if (DDC->ver.version == 2) { if ( (EDID2rawdata = xalloc(256*sizeof(CARD8)))==NULL ) { - xfree(EDID1rawdata); + xfree(EDID2rawdata); return FALSE; } + for (i=0; i<256; i++) { + EDID2rawdata[i] = DDC->rawData[i]; + } EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME), TRUE); - xf86DrvMsg(pScrnInfo->scrnIndex, X_PROBED, - "ignoring property %s for now - please fix\n", - EDID2_ATOM_NAME); +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty %p(%d,%d,%d,%d,%d,%p)\n", + xf86RegisterRootWindowProperty, + pScrnInfo->scrnIndex, + EDID2Atom, XA_INTEGER, 8, + 256, (unsigned char *)EDID2rawdata ); +#endif + ret = xf86RegisterRootWindowProperty(pScrnInfo->scrnIndex, + EDID2Atom, XA_INTEGER, 8, +#if 1 + 256, (unsigned char *)EDID1rawdata +#else +#define EDID2_DUMMY_STRING "Dummy EDID2 property - please insert correct values" + strlen(EDID2_DUMMY_STRING), + EDID2_DUMMY_STRING +#endif + ); +#ifdef DEBUG + ErrorF("xf86RegisterRootWindowProperty returns %d\n", ret ); +#endif } else { xf86DrvMsg(pScrnInfo->scrnIndex, X_PROBED, "unexpected EDID version %d revision %d\n", Index: xc/programs/Xserver/hw/xfree86/ddc/edid.c diff -u xc/programs/Xserver/hw/xfree86/ddc/edid.c:1.2 xc/programs/Xserver/hw/xfree86/ddc/edid.c:1.3 --- xc/programs/Xserver/hw/xfree86/ddc/edid.c:1.2 Thu Jan 14 08:04:14 1999 +++ xc/programs/Xserver/hw/xfree86/ddc/edid.c Fri Nov 3 13:46:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.c,v 1.2 1999/01/14 13:04:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.c,v 1.3 2000/11/03 18:46:08 eich Exp $ */ /* edid.c: retrieve EDID record from raw DDC1 data stream: data * is contained in an array of unsigned int each unsigned int @@ -52,11 +52,21 @@ checksum(unsigned char *block, int len) { int i, result = 0; - for (i=0;iinput_setup)) xf86DrvMsg(scrnIndex,X_INFO,"Signal levels configurable\n"); - xf86DrvMsg(scrnIndex,X_INFO,"Sync: "); + xf86DrvMsg(scrnIndex,X_INFO,"Sync:"); if (SEP_SYNC(c->input_sync)) - xf86ErrorF("Separate "); + xf86ErrorF(" Separate"); if (COMP_SYNC(c->input_sync)) - xf86ErrorF("Composite "); + xf86ErrorF(" Composite"); if (SYNC_O_GREEN(c->input_sync)) - xf86ErrorF("SyncOnGreen "); + xf86ErrorF(" SyncOnGreen"); if (SYNC_SERR(c->input_sync)) - xf86ErrorF("\n Serration on" + xf86ErrorF("Serration on. " "V.Sync Pulse req. if CompSync or SyncOnGreen\n"); else xf86ErrorF("\n"); } @@ -131,6 +131,7 @@ xf86ErrorF("; Non RGB Multicolor Display\n"); break; default: + xf86ErrorF("\n"); break; } if (STD_COLOR_SPACE(c->msc)) @@ -217,13 +218,13 @@ print_detailed_timings(scrnIndex,&m[i].section.d_timings); break; case DS_SERIAL: - xf86DrvMsg(scrnIndex,X_INFO,"Serial No: %s",m[i].section.serial); + xf86DrvMsg(scrnIndex,X_INFO,"Serial No: %s\n",m[i].section.serial); break; case DS_ASCII_STR: - xf86DrvMsg(scrnIndex,X_INFO," %s",m[i].section.ascii_data); + xf86DrvMsg(scrnIndex,X_INFO," %s\n",m[i].section.ascii_data); break; case DS_NAME: - xf86DrvMsg(scrnIndex,X_INFO,"Monitor name: %s",m[i].section.name); + xf86DrvMsg(scrnIndex,X_INFO,"Monitor name: %s\n",m[i].section.name); break; case DS_RANGES: xf86DrvMsg(scrnIndex,X_INFO, @@ -231,7 +232,7 @@ m[i].section.ranges.min_v, m[i].section.ranges.max_v, m[i].section.ranges.min_h, m[i].section.ranges.max_h); if (m[i].section.ranges.max_clock != 0) - xf86ErrorF(" PixClock max %i MHz\n",m[i].section.ranges.max_clock); + xf86ErrorF(" PixClock max %i kHz\n",m[i].section.ranges.max_clock); else xf86DrvMsg(scrnIndex,X_INFO,"\n"); break; Index: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c diff -u xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c:1.17 xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c:1.19 --- xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c:1.17 Wed Jun 7 18:03:09 2000 +++ xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c Thu Nov 16 14:44:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.17 2000/06/07 22:03:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.19 2000/11/16 19:44:55 eich Exp $ */ /* xf86DDC.c * @@ -130,6 +130,7 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; unsigned char *EDID_block = NULL; xf86MonPtr tmp = NULL; + int sigio; /* Default DDC and DDC1 to enabled. */ Bool noddc = FALSE, noddc1 = FALSE; OptionInfoRec options[nDDCOptions]; @@ -142,8 +143,10 @@ if (noddc || noddc1) return NULL; - + + sigio = xf86BlockSIGIO(); EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read); + xf86UnblockSIGIO(sigio); if (EDID_block){ tmp = xf86InterpretEDID(scrnIndex,EDID_block); @@ -315,6 +318,10 @@ dev->SlaveAddr = 0xA0; dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ dev->StartTimeout = 550; + dev->BitTimeout = 40; + dev->ByteTimeout = 40; + dev->AcknTimeout = 40; + dev->pI2CBus = pBus; if (! xf86I2CDevInit(dev)) { xf86DrvMsg(X_PROBED,scrnIndex,"No DDC2 device\n"); Index: xc/programs/Xserver/hw/xfree86/doc/BugReport diff -u xc/programs/Xserver/hw/xfree86/doc/BugReport:1.1 xc/programs/Xserver/hw/xfree86/doc/BugReport:1.3 --- xc/programs/Xserver/hw/xfree86/doc/BugReport:1.1 Tue Feb 22 14:06:42 2000 +++ xc/programs/Xserver/hw/xfree86/doc/BugReport Thu Aug 3 08:24:02 2000 @@ -5,7 +5,7 @@ VERSION: -3.9.18 +4.0.1a VIDEO DRIVER: @@ -53,3 +53,5 @@ reproduce it.] + +$XFree86: xc/programs/Xserver/hw/xfree86/doc/BugReport,v 1.3 2000/08/03 12:24:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/DESIGN diff -u xc/programs/Xserver/hw/xfree86/doc/DESIGN:1.26 xc/programs/Xserver/hw/xfree86/doc/DESIGN:1.33 --- xc/programs/Xserver/hw/xfree86/doc/DESIGN:1.26 Mon Jun 19 11:12:26 2000 +++ xc/programs/Xserver/hw/xfree86/doc/DESIGN Mon Dec 4 14:47:21 2000 @@ -2,7 +2,7 @@ The XFree86 Project, Inc - Last modified 1 May 2000 + Last modified 2 December 2000 NOTE: This is a DRAFT document, and the interfaces described here are subject to change without notice. @@ -409,11 +409,11 @@ it to the global xf86DriverList[] array. The DriverRec contains the driver's version, a short descriptive message, the -Identify() and Probe() function entry points as well as a pointer to the -driver's module (as returned from the loader when the driver was loaded) and -a reference count which keeps track of how many screens are using the driver. -The entry driver entry points are those required prior to the driver allocat- -ing and filling in its ScrnInfoRec. +Identify(), Probe() and AvailableOptions() function entry points as well as a +pointer to the driver's module (as returned from the loader when the driver +was loaded) and a reference count which keeps track of how many screens are +using the driver. The entry driver entry points are those required prior to +the driver allocating and filling in its ScrnInfoRec. For a static server, the xf86DriverList[] array is initialised at build time, and the loading of modules is not done. @@ -465,13 +465,17 @@ The purpose of this is to identify all instances of hard- ware supported by the driver. The flags value is cur- - rently not used, and should be ignored by the driver. + rently either 0, PROBE_DEFAULT or PROBE_DETECT. + PROBE_DETECT is used if "-configure" or "-probe" command + line arguments are given and indicates to the Probe() + function that it should not configure the bus entities + and that no XF86Config information is available. The probe must find the active device sections that match the driver by calling xf86MatchDevice(). The number of matches found limits the maximum number of instances for - this driver. If no matches are found, the problem should - return FALSE immediately. + this driver. If no matches are found, the function + should return FALSE immediately. Devices that cannot be identified by using device-inde- pendent methods should be probed at this stage (keeping @@ -3204,9 +3208,7 @@ video stream be scaled to rectangle of drw_w by drw_h on the screen. Since it is not expected that all hardware will be able to get the target dimensions exactly, it is - important that the driver provide this function. The - returned dimensions must be less than or equal to the - requested dimension. + important that the driver provide this function. typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x, short drw_y, @@ -4541,7 +4543,8 @@ clockRanges is a linked list of clock ranges allowed by the driver. If a mode doesn't fit in any of the defined clockRanges, it is rejected. The first clockRange that - matches all requirements is used. + matches all requirements is used. This structure needs + to be initialized to NULL when allocated. clockRanges contains the following fields: @@ -5506,6 +5509,11 @@ fields. By using xnfcalloc() to do the allocation it is zeroed, and if the allocation fails the server exits. +NOTE: When allocating structures from inside the driver which are defined on +the common level it is important to initialize the structure to zero. Only +this guarantees that the server remains source compatible to future changes +in common level structures. + static Bool ZZZGetRec(ScrnInfoPtr pScrn) { @@ -5620,8 +5628,7 @@ /* add screen to entity */ } } - if (numUsed > 0) - xfree(usedChips); + xfree(usedChips); } #ifdef HAS_ISA_DEVS @@ -5652,8 +5659,7 @@ foundScreen = TRUE; } } - if (numUsed > 0) - xfree(usedChips); + xfree(usedChips); #endif /* HAS_ISA_DEVS */ xfree(devSections); @@ -6246,8 +6252,10 @@ ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - ZZZRestore(pScrn); - ZZZUnmapMem(pScrn); + if (pScrn->vtSema) { + ZZZRestore(pScrn); + ZZZUnmapMem(pScrn); + } pScrn->vtSema = FALSE; pScreen->CloseScreen = ZZZPTR(pScrn)->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); @@ -6258,7 +6266,16 @@ Define the SaveScreen() function (the screen blanking function). When using the vgahw module, this will typically be: -This function is mandatory. +This function is mandatory. Before modifying any hardware register directly +this function needs to make sure that the Xserver is active by checking if + + pScrn + + is non-NULL and for + + pScrn->vtSema == TRUE + +. static Bool ZZZSaveScreen(ScreenPtr pScreen, int mode) @@ -6285,7 +6302,7 @@ ZZZFreeRec(xf86Screens[scrnIndex]); } - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.30 2000/06/19 15:00:52 tsi Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.39 2000/12/04 18:49:54 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/DESIGN,v 1.26 2000/06/19 15:12:26 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/DESIGN,v 1.33 2000/12/04 19:47:21 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/Imakefile diff -u xc/programs/Xserver/hw/xfree86/doc/Imakefile:3.68 xc/programs/Xserver/hw/xfree86/doc/Imakefile:3.72 --- xc/programs/Xserver/hw/xfree86/doc/Imakefile:3.68 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/Imakefile Mon Dec 11 11:06:49 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.68 2000/06/17 17:44:20 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.72 2000/12/11 16:06:49 dawes Exp $ #include #include @@ -28,6 +28,7 @@ #if !BuildLinuxDocText OSREADMES = \ /*ReadmeFile(Bsdi)*/ \ + ReadmeFile(Darwin) \ /*ReadmeFile(DGUX)*/ \ /*ReadmeFile(FreeBSD)*/ \ ReadmeFile(isc) \ @@ -54,12 +55,13 @@ ReadmeFile(DECtga) \ /*ReadmeFile(epson)*/ \ /*ReadmeFile(fbdev)*/ \ - /*ReadmeFile(I128)*/ \ + ReadmeFile(I128) \ ReadmeFile(i740) \ ReadmeFile(i810) \ /*ReadmeFile(Mach32)*/ \ /*ReadmeFile(Mach64)*/ \ /*ReadmeFile(MGA)*/ \ + ReadmeFile(newport) \ /*ReadmeFile(NVIDIA)*/ \ /*ReadmeFile(Oak)*/ \ /*ReadmeFile(P9000)*/ \ Index: xc/programs/Xserver/hw/xfree86/doc/Install diff -u xc/programs/Xserver/hw/xfree86/doc/Install:1.5 xc/programs/Xserver/hw/xfree86/doc/Install:1.10 --- xc/programs/Xserver/hw/xfree86/doc/Install:1.5 Sat Jul 1 22:46:26 2000 +++ xc/programs/Xserver/hw/xfree86/doc/Install Fri Dec 15 14:38:06 2000 @@ -1,8 +1,8 @@ - Installation Details for XFree86[tm] 4.0.1 + Installation Details for XFree86[tm] 4.0.2 The XFree86 Project, Inc - 30 June 2000 + 15 December 2000 Abstract @@ -13,40 +13,48 @@ This document contains information about installing the XFree86 binaries as provided by The XFree86 Project. -The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs and -Solaris) are packaged in a platform-independent gzipped format (aka "tar- -balls" identified by the .tgz suffix). Along with the binaries we provide a -customized version of the GNU tar utility called "extract" and an installa- -tion script. We recommend that these be used to install the binaries. - -2. Downloading the XFree86 4.0.1 binaries - -We, The XFree86 Project, provide XFree86 4.0.1 binaries for a range of oper- -ating systems at our ftp site -. Often during -releases, our ftp site is heavily loaded. Instead of downloading directly +The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs, +Solaris, etc) are packaged in a platform-independent gzipped tar format (aka +"tarballs" identified by the .tgz suffix). Along with the binaries we pro- +vide a customized version of the GNU tar utility called "extract" and an +installation script. We recommend that these be used to install the bina- +ries. + +2. Downloading the XFree86 4.0.2 binaries + +We provide XFree86 4.0.2 binaries for a range of operating systems at our ftp +site . Often during +releases our ftp site is heavily loaded. Instead of downloading directly from us we recommend that instead you use one of our mirror sites. Another advantage of using our mirror sites is that some of them support http access (ours does not). Our binaries are organized by sub-directories which correspond to each of the OS/platforms for which we provide binaries. First go to the sub-directory -that represents your OS Platform. In some cases (e.g., Linux) there may be a +that represents your OS platform. In some cases (e.g., Linux) there may be a number of choices depending on the architecture or libc version your platform uses. In all case we recommend that you first download the Xinstall.sh -script, and run it as in the following example to find out which binary dis- +script, and run it as in the following example to find out which binary dis- tribution you should download. sh Xinstall.sh -check -The output of this utility tells you which is the correct set of binaries -for you to download. If you are careful with this step you will save your- -self a lot time and trouble from NOT downloading an incompatible distribu- -tion. - -Once that is done download the necessary files. The twelve (12) mandatory -files for all installations are listed below. If you have not downloaded all -of the files, the installer script will complain. +The output of this utility tells you which is the correct set of binaries for +you to download. If you are careful with this step you will save yourself a +lot time and trouble from NOT downloading an incompatible distribution. + +NOTE: the Xinstall.sh script must be downloaded in binary mode, otherwise it +won't run correctly. If you get lots of "command not found" messages when +you try to run it, then it is most likely because the script wasn't down- +loaded in binary mode. Some web browsers won't do this for files of that +name, so we also have a copy of it called "Xinstall.bin", and most browsers +should download that correctly. When downloading it under this name, select +"save as" on your browser, and save the file under the name "Xinstall.sh". + +Once you're run the Xinstall.sh script and found which binary distribution is +suitable for your system, download the necessary files. The twelve (12) +mandatory files for all installations are listed below. If you have not +downloaded all of the files, the installer script will complain. 1. Xinstall.sh The installer script 2. extract The utility for extracting tarballs @@ -72,6 +80,9 @@ is present in the binaries sub-directory for your platform, then it is required. + o The Darwin/Mac OS X distribution doesn't have or require the Xmod.tgz + tarball. + o Some distributions may have additional mandatory tarballs. While rare, the installer script will tell you if any are missing. @@ -99,9 +110,9 @@ If you miss some and want to install them later, go to the Manual Installa- tion (section 4., page 1) section. -3. Installing XFree86 4.0.1 using the Xinstall.sh script +3. Installing XFree86 4.0.2 using the Xinstall.sh script -We strongly recommend that our XFree86 4.0.1 binaries be installed using the +We strongly recommend that our XFree86 4.0.2 binaries be installed using the Xinstall.sh script that we provide. There are a lot of steps in the manual installation process, and those steps can vary according to the platform and hardware setup. There is a description of the manual installation process @@ -217,12 +228,17 @@ 3.2 After the installation is complete The next step is to configure the X server. That is covered in detail in an -as-yet unwritten document :-(. In the meantime, there are two ways to create -a basic X server configuration file for XFree86 4.0.1. One is to run the -xf86config utility. Another is to use the new -configure X server option: +as-yet unwritten document :-(. In the meantime, there are three ways to cre- +ate a basic X server configuration file for XFree86 4.0.2. One is to run the +xf86config utility. Another is to run the xf86cfg utility. The third option +is to use the new -configure X server option: XFree86 -configure +Note that if you are running Darwin/Mac OS X, there is no step 3 :-). You +should skip this step, as configuration is not required or possible. The X +server configuration file is not used on Darwin/Mac OS X. + The X server config file (XF86Config) format has changed compared to 3.3.x. Also, its default location is now /etc/X11. Finally, there is now only one X server for driving video hardware, and it is called "XFree86". Once you're @@ -232,9 +248,9 @@ After the X server configuration is done, it may be advisable to reboot, especially if you run xdm (or equivalent) or the font server (xfs). -4. Installing XFree86 4.0.1 manually +4. Installing XFree86 4.0.2 manually -This section describes how to manually install the XFree86 4.0.1 binary dis- +This section describes how to manually install the XFree86 4.0.2 binary dis- tributions. You should only use this method if you know what you're doing. The information here covers some common cases, but not every possible case. @@ -328,14 +344,14 @@ Once that's done, the main part of the installation can be done: - ./extract -C /usr/X11R6 X[a-df-uw-z]*.tgz + ./extract -C /usr/X11R6 `pwd`/X[a-df-uw-z]*.tgz ./extract -C /usr/X11R6 Xvfb.tgz # If you are installing Xvfb ./extract -C /var Xvar.tgz /sbin/ldconfig /usr/X11R6/lib # For Linux /sbin/ldconfig -m /usr/X11R6/lib # For FreeBSD, NetBSD, OpenBSD /usr/X11R6/bin/mkfontdir /usr/X11R6/lib/X11/fonts/misc - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.6 2000/07/02 02:35:27 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.10 2000/12/15 19:09:06 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/Install,v 1.5 2000/07/02 02:46:26 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/Install,v 1.10 2000/12/15 19:38:06 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/LICENSE diff -u xc/programs/Xserver/hw/xfree86/doc/LICENSE:1.10 xc/programs/Xserver/hw/xfree86/doc/LICENSE:1.11 --- xc/programs/Xserver/hw/xfree86/doc/LICENSE:1.10 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/LICENSE Fri Dec 1 14:47:45 2000 @@ -595,4 +595,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LICENSE.sgml,v 1.7 2000/03/06 22:59:23 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/LICENSE,v 1.10 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/LICENSE,v 1.11 2000/12/01 19:47:45 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/OS2.Notes diff -u xc/programs/Xserver/hw/xfree86/doc/OS2.Notes:3.16 xc/programs/Xserver/hw/xfree86/doc/OS2.Notes:3.17 --- xc/programs/Xserver/hw/xfree86/doc/OS2.Notes:3.16 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/OS2.Notes Fri Dec 1 14:47:45 2000 @@ -226,4 +226,4 @@ $XConsortium: OS2note.sgml /main/1 1996/02/24 10:08:59 kaleb $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/OS2.Notes,v 3.16 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/OS2.Notes,v 3.17 2000/12/01 19:47:45 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README diff -u xc/programs/Xserver/hw/xfree86/doc/README:3.105 xc/programs/Xserver/hw/xfree86/doc/README:3.109 --- xc/programs/Xserver/hw/xfree86/doc/README:3.105 Sat Jul 1 22:46:26 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README Fri Dec 15 13:14:32 2000 @@ -1,8 +1,8 @@ - README for XFree86[tm] 4.0.1 + README for XFree86[tm] 4.0.2 The XFree86 Project, Inc - 30 June 2000 + 15 December 2000 Abstract @@ -10,31 +10,33 @@ supports several UNIX(R) and UNIX-like (such as Linux, the BSDs and Solaris x86) operating systems on Intel and other platforms. -1. What is XFree86 4.0.1? +1. What is XFree86 4.0.2? -XFree86 4.0.1 is a the upgrade to the first full release in the new XFree86 4 -series. Release 4 is a major re-design of the basic architectural underpin- +XFree86 4.0.2 is the third full release in the new XFree86 4 series. + +XFree86 release 4 is a major re-design of the basic architectural underpin- nings of XFree86's implementation of the original X Consortium's X Server. This re-design allows for a modular interaction between the hardware drivers -and the XFree86 core X server. With 4.0, upgrades to the X server with new +and the XFree86 core X server. With 4.x, upgrades to the X server with new and unsupported hardware can be easily done and installed without undergoing -the previous process of rebuilding a X server. All that is required is +the previous process of rebuilding an X server. All that is required is installing the new driver module and updating the configuration file. -The road to XFree86 Release 4 began as an architectural concept in mid 1997, +The road to XFree86 release 4 began as an architectural concept in mid 1997, with the serious framework being implemented in code the beginning of 1998. There were several snapshots on the road to 4.0 which are now part of the 4.0 -base release. The 4.0.1 version is an upgrade to 4.0, which include more +base release. The 4.0.2 version is an upgrade to 4.0.1, which include more hardware ports, code enhancements and bug fixes. Release 4 also included the long-awaited integration of the DRI (Direct Ren- dering Infrastructure). This upgrade into the code base gives XFree86 the -abilities of direct 3-D graphics rendering, used widely in games and other -visualization programs. +abilities of accelerated direct 3-D graphics rendering, used widely in games +and other visualization programs. -Many drivers used in the old 3.3.x series have not be converted over to the -4.0 design and so check first whether your hardware is supported before -upgrading to the 4.0 series in the Driver Status document. +While some driver available in the old 3.3.x release series have not been +converted over to the 4.x series, those required for most modern video hard- +ware are available. Please check the Driver Status document first to see +whether your hardware is supported before upgrading to the 4.x series. Specific release enhancements can be viewed in the Release Notes. @@ -49,9 +51,9 @@ 2.1 Development If you would like to work on the development of XFree86 4, either by helping -with the conversion of our older drivers to the new 4.0 design, or assisting +with the conversion of our older drivers to the new 4.x design, or assisting in the addition of new drivers or platforms to the code base then send a -request to to join the XFree86 development team +request to join the XFree86 development team . This will give you direct access to the latest XFree86 related development topics and discussions. Include in your note, your name, email address, reason for joining (what you @@ -97,13 +99,6 @@ dynamically every time the repository is updated after the the commit hap- pens. -A followup to the commit list is the soon to be public, patch archives. This -archive will be available on our web-site and will show what patches have -been submitted and will soon be committed. This is helpful for people who -are interested in a specific area and want to know what work is happening -there. When this goes public we will announce it on our web site and our -Announce mailing list, so keep watching. - 3.4 Xpert If instead you are the lone developer who is improving XFree86 on an ad hoc @@ -118,35 +113,41 @@ fix to . This will ensure that they are included in future releases. And thanks! You make this truly an Open group. -4. How to get XFree86 4.0.1 +4. How to get XFree86 4.0.2 -XFree86 4.0.1 can be found at the XFree86 ftp server -, and at mirrors of this +XFree86 4.0.2 can be found at the XFree86 ftp server +, and at mirrors of this server. Information about obtaining and installing binary distributions of this release can be found in the Installation Document. Information about obtaining the release in source form is given below. -The source for version 4.0.1 is split into three tarballs: X401src-1.tgz, -X401src-2.tgz, X401src-3.tgz. The first contains everything except the fonts +The source for version 4.0.2 is split into three tarballs: X402src-1.tgz, +X402src-2.tgz, X402src-3.tgz. The first contains everything except the fonts and general X11 documentation. It is sufficient for building XFree86 is you already have a set of fonts. The second contains the fonts and the source for the general X11 documentation. The third contains the general X11 docu- mentation in hardcopy format. -A source patch relative to version 4.0 is also available. Because of its -size, it is split into two parts. The patch files are 4.0-4.0.1.diff1.gz and -4.0-4.0.1.diff2.gz. These patches should be applied to a clean 4.0 source -tree, working from the directory containing the xc/ directory. The patches -should be applied by running: +A source patch relative to version 4.0.1 is also available. Because of its +size, it is split into four parts. The patch files are 4.0.1-4.0.2.diff1.gz, +4.0.1-4.0.2.diff2.gz, 4.0.1-4.0.2.diff3.gz and 4.0.1-4.0.2.diff4.gz. There +is also a tarball that contains some files that have components that can't be +included in a diff. It is 4.0.2.tgz. These patches should be applied to a +clean 4.0.1 source tree, working from the directory containing the xc/ direc- +tory. The patches should be applied by running: + + gzip -d < 4.0.1-4.0.2.diff1.gz | patch -p0 -E + gzip -d < 4.0.1-4.0.2.diff2.gz | patch -p0 -E + gzip -d < 4.0.1-4.0.2.diff3.gz | patch -p0 -E + gzip -d < 4.0.1-4.0.2.diff4.gz | patch -p0 -E - gunzip < 4.0-4.0.1.diff1.gz | patch -p0 -E - gunzip < 4.0-4.0.1.diff2.gz | patch -p0 -E + gzip -d < 4.0.2.tgz | tar vxf - The contrib part of the distribution has been folded into the main source tree, so a separate contrib tarball is no longer required. To format the XFree86 documentation use the latest version of our doctools -package available as doctools-1.1.3.tgz. +package available as doctools-1.2.tgz. 5. Reporting Bugs @@ -157,7 +158,7 @@ system core dump. Do not edit the log file as our developers use it to reproduce and debug your problem. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.106 2000/07/02 02:35:27 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.110 2000/12/15 16:11:57 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README,v 3.105 2000/07/02 02:46:26 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README,v 3.109 2000/12/15 18:14:32 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.DECtga diff -u xc/programs/Xserver/hw/xfree86/doc/README.DECtga:3.16 xc/programs/Xserver/hw/xfree86/doc/README.DECtga:3.17 --- xc/programs/Xserver/hw/xfree86/doc/README.DECtga:3.16 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.DECtga Fri Dec 1 14:47:46 2000 @@ -6,7 +6,7 @@ 1. DEC 21030 - o The DEC 21030 is supported by XFree86 4.0.1. The driver is now par- + o The DEC 21030 is supported by XFree86 4.0.2. The driver is now par- tially accelerated. The built-in graphics on the Multia is supported in 8-plane mode, and PCI cards with 8 or 16 MB framebuffers are supported in 24-plane mode. TGA2 (aka PowerStorm 3D30/4D20) cards are not cur- @@ -65,4 +65,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DECtga.sgml,v 3.9 2000/03/06 22:59:23 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DECtga,v 3.16 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DECtga,v 3.17 2000/12/01 19:47:46 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.DRI diff -u xc/programs/Xserver/hw/xfree86/doc/README.DRI:1.6 xc/programs/Xserver/hw/xfree86/doc/README.DRI:1.12 --- xc/programs/Xserver/hw/xfree86/doc/README.DRI:1.6 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.DRI Tue Dec 12 14:04:02 2000 @@ -1,15 +1,14 @@ DRI User Guide - Precision Insight, Inc. + VA Linux Systems, Inc. Professional Services - Graphics. - 18 May 2000 + 20 November 2000 1. Preamble 1.1 Copyright -Copyright © 2000 by Precision Insight, Inc., Cedar Park, Texas. All Rights -Reserved. +Copyright © 2000 by VA Linux Systems, Inc. All Rights Reserved. Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all @@ -30,10 +29,9 @@ 2. Introduction -With XFree86 4.0 and Precision Insight's Direct Rendering Interface (DRI), -hardware accelerated 3D graphics can be considered a standard feature on -Linux workstations. Support for other operating systems, such as FreeBSD, is -underway. +With XFree86 4.0 and the Direct Rendering Interface (DRI), hardware acceler- +ated 3D graphics can be considered a standard feature on Linux workstations. +Support for other operating systems, such as FreeBSD, is underway. This document describes how to use the DRI system and troubleshoot problems which may occur. Readers should have a basic understanding of Linux, X and @@ -46,17 +44,64 @@ the DRI for himself. DRI download, compilation and installation instructions can be found at http://dri.sourceforge.net/DRIcompile.html -3. Supported Hardware +Edits, corrections and updates to this document may be mailed to brianp@val- +inux.com. -3D acceleration is currently only available for systems with Intel-compatible -CPUs. Support for Alpha, and perhaps other CPUs, should be available in the -future. +3. Supported Architectures & Hardware + " + +3.1 Architectures + + " + +The Architectures currently supported by the DRI have grown from the initial +Intel i386 based machines to now include, the Alpha Processor and the Sun +SPARC machines. + +The build environment for both of these new architectures have a pre-build +environment that will correctly build the DRI drivers and Mesa meaning no +extra configuration is necessary to build the DRI for these architectures. + +3.1.1 Alpha Features + + " + +On newer Alpha processors, it should be noted that a significant performance +increase can be seen with the addition of the -mcpu= command that should be +passed to GCC upon compilation. Dependent of the architecture of the proces- +sor, for example -mcpu=ev6 will build specifically for the EV6 based AXP's, +giving both byte and word alignment access to the DRI/Mesa drivers. + +Use this as an example of compiling with this extra speed. In your host.def +file that should reside in the xc/config directory, add the line. + +#define DefaultGcc2AxpOpt -O2 -mcpu=ev6 + +Additional speed improvements to 3D rendering can be achieved by installing +Compaq's Math Libraries (CPML) which can be obtained from the following URL. + +http://www.support.compaq.com/alpha-tools/software/index.html + +Once installed, you can set this option in your host.def to build against the +CPML libraries. + +#define UseCompaqMathLibrary YES + +3.2 Graphics Hardware + + " + XFree86 4.0 (or later versions) includes 3D acceleration for the following graphics hardware: +NOTE: This is a complete list of graphics hardware supported. It may not be +supported on your platform. + o 3dfx: + o Voodoo5 5500 + o Voodoo3 3500 TV o Voodoo3 3000 AGP @@ -107,44 +152,53 @@ not yet supported. o 3Dlabs Oxygen GMX 2000 (MX/Gamma based) - -Support for the following hardware is underway: - o 3dfx Voodoo4 and Voodoo5 series +Support for other hardware is underway. 4. Prerequisite Software + + o The DRI is available in XFree86 4.0 and later. - o XFree86 4.0 + o Some hardware drivers require specific versions of the Linux kernel for + AGP support, etc. See section 10 for specifics. - o For the 3dfx Voodoo3 driver, Linux kernel 2.2.x (later kernels will be - supported in the near future, and may be required for some chipsets) + o You DO NOT need to install Mesa separately. The parts of Mesa needed + for hardware acceleration are already in the XFree86/DRI project. - o For the Matrox G200/G400, Linux kernel 2.3.51, with AGP support +5. Kernel Modules - o For the Intel i810, Linux kernel 2.3.99-pre6, with AGP support + " -Mesa 3.3 (beta) is included with XFree86 4.0; there is no need to download -the stand-alone Mesa distribution. +3D hardware acceleration requires a DRI kernel module that's specific to your +graphics hardware. -5. X Server Start-up +The DRI kernel module version must exactly match your running kernel version. +Since there are so many versions of the kernel, it's difficult to provide +precompiled kernel modules. -This section describes the steps needed to start the X server with 3D accel- -eration support. +While the Linux source tree includes the DRI kernel module sources, the lat- +est DRI kernel sources will be found in the DRI source tree. -5.1 Kernel module +See the DRI Compilation Guide for information on compiling the DRI kernel +modules. XFree86 4.0.1 added automatic kernel module loading to the X server. On -Linux, the X server uses modprobe to load kernel modules. The DRM kernel -modules should be in /lib/modules/KERNEL-VERSION/misc/ for automatic loading -to work. +Linux, the X server uses modprobe to load kernel modules. In Linux 2.4.x the +DRM kernel modules should be kept in /lib/modules/2.4.x/ker- +nel/driver/char/drm/ for automatic loading to work. Optionally, DRM kernel modules can be loaded manually with insmod prior to starting the X server. You can verify that the kernel module was installed with lsmod, checking the X server startup log, and checking that /proc/dri/0 exists. + +6. XF86Config file + + " -5.2 XF86Config file +The XFree86 configuration file is usually found in /etc/X11/XF86Config. This +section describes the parts which must be specially set for the DRI. First, the XF86Config file must load the GLX and DRI modules: @@ -194,68 +248,12 @@ the DRI section, please also remove the /dev/dri directory with the rm -rf /dev/dri command.] -Next, the Device section of the XF86Config file must describe your particular -hardware. +Finally, the XF86Config file needs Device and Screen sections specific to +your hardware. Look in section 10: Hardware-Specific Information and Trou- +bleshooting for details. -For example, here's the Device section for a 3dfx Voodoo3 card: +7. Memory usage - Section "Device" - Identifier "Voodoo3" - VendorName "3dfx" - Driver "tdfx" - EndSection - -Here's the Device section for a Matrox G400 card: - - Section "Device" - Identifier "G400" - VendorName "Matrox" - Driver "mga" - VideoRam 32768 - EndSection - -Here's the Device section for an ATI Rage 128 card: - - Section "Device" - Identifier "Rage128" - VendorName "ATI" - Driver "r128" - EndSection - -Here's the Device section for an Intel i810 motherboard: - - Section "Device" - Identifier "i810" - VendorName "Intel" - Driver "i810" - VideoRam 10000 - EndSection - -Finally, the Screen section of the XF86Config file may have to be specially -configured as well. For example, Voodoo3 hardware acceleration is only -available in 16bpp mode. - - Section "Screen" - Identifier "Screen 1" - Device "Voodoo3" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - -Replace Voodoo3 with G400 for Matrox G400. - -Replace Voodoo3 with Rage128 for ATI Rage 128. - -If there are errors in the XF86Config file, the X server will log errors to -the file /var/log/XFree86.0.log - -5.3 Memory usage - Using the 3D features of a graphics card requires more memory than when it's just used as a 2D device. Double buffering, depth buffering, stencil buffers, textures, etc. all require extra graphics memory. These features @@ -263,17 +261,21 @@ If your graphics card doesn't have a lot of memory (less than 16MB, for exam- ple), you may have to reduce your screen size and/or color depth in order to -use 3D features. +use 3D features. Reducing the screen resolution will also leave more space +for texture images, possibly improving 3D performance. If, for example, you +play Quake3 at 1024x768 but start your display at 1600x1200 you might con- +sider restarting X at 1024x768 in order to maximize your texture memory +space. The documentation included with your card should have information about maxi- mum screen size when using 3D. -6. Using 3D Acceleration +8. Using 3D Acceleration This section describes how to link your application with libGL.so and verify that you are in fact using 3D acceleration. -6.1 libGL.so +8.1 libGL.so Your OpenGL program must link with the libGL.so.1.2 library provided by XFree86 4.0. The libGL.so.1.2 library contains a GLX protocol encoder for @@ -288,7 +290,7 @@ Most simple OpenGL programs also use the GLUT and GLU libraries. A source for these libraries is listed in the Resources section below. -6.2 Compiling and linking an OpenGL program +8.2 Compiling and linking an OpenGL program A simple GLUT/OpenGL program may be compiled and linked as follows: @@ -297,13 +299,14 @@ The -I option is used to specify where the GL/glut.h (and possibly the GL/gl.h and GL/glu.h) header file may be found. -The -L options specify where the libglut.so, libGLU.so and X libraries are -located. +The -L options specify where the libglut.so and the X libraries are located. +libGL.so and libGLU.so should be in /usr/lib, as specified by the +Linux/OpenGL ABI standard. The -lglut -lGLU -lGL arguments specify that the application should link with -the GLUT, GLU and GL libraries. +the GLUT, GLU and GL libraries, in that order. -6.3 Running your OpenGL program +8.3 Running your OpenGL program Simply typing ./program in your shell should execute the program. @@ -315,22 +318,24 @@ if means that the libGL.so.1 file is not the right location. Proceed to the trouble shooting section. -6.4 libOSMesa.so +8.4 libOSMesa.so OSMesa (Off-Screen Mesa) is an interface and driver for rendering 3D images -into a user-allocated block of memory rather than an on-screen window. +into a user-allocated block of memory rather than an on-screen window. It +was originally developed for Mesa before Mesa became part of the XFree86/DRI +project. It can now be used with the XFree86/DRI libGL.so as well. -libOSMesa.so implements the OSMesa interface and must be linked with your +libOSMesa.so implements the OSMesa interface and it must be linked with your application if you want to use the OSMesa functions. You must also link with libGL.so. For example: - gcc osdemo.c -L/usr/X11R6/lib -lOSMesa -lGLU -lGL -o osdemo + gcc osdemo.c -lOSMesa -lGLU -lGL -o osdemo In stand-alone Mesa this interface was compiled into the monolithic libGL.so (formerly libMesaGL.so) library. In XFree86 4.0.1 and later this interface is implemented in a separate library. -6.5 glxinfo +8.5 glxinfo glxinfo is a useful program for checking which version of libGL you're using as well as which DRI-based driver. Simply type glxinfo and examine the @@ -354,11 +359,11 @@ If you see that indirect rendering is being used when direct rendering was expected, proceed to the troubleshooting section. -glxinfo also lists all of the GLX-enhanced visuals available. Here you can -determine which visuals may have depth buffers, stencil buffers, accumulation -buffers, etc. +glxinfo also lists all of the GLX-enhanced visuals available so you can +determine which visuals are double-bufferd, have depth (Z) buffers, stencil +buffers, accumulation buffers, etc. -6.6 Environment Variables +8.6 Environment Variables The libGL.so library recognizes three environment variables. Normally, none of them need to be defined. If you're using the csh or tcsh shells, type @@ -381,23 +386,27 @@ grams. This variable replaces the LIBGL_DRIVERS_DIR env var used in XFree86 4.0. + 4. MESA_DEBUG, if defined, will cause Mesa-based 3D drivers to print user + error messages to stderr. These are errors that you'd otherwise detect + by calling glGetError. + Mesa-based drivers (this includes most of the drivers listed above) also observe many of the existing Mesa environment variables. These include the MESA_DEBUG and MESA_INFO variables. -7. General Trouble Shooting +9. General Trouble Shooting This section contains information to help you diagnose general problems. See below for additional information for specific hardware. -7.1 Starting the X server +9.1 The X Server 1. Before you start the X server, verify the appropriate 3D kernel module is installed. Type lsmod and look for the appropriate kernel module. For 3dfx hardware you should see tdfx, for example. - 2. Verify you're running XFree86 4.0 and not an older version. If you run - xdpyinfo and look for the following line near the top: + 2. Verify you're running XFree86 4.0 (or newer) and not an older version. + If you run xdpyinfo and look for the following line near the top: vendor release number: 4000 @@ -444,7 +453,7 @@ SGI-GLX XFree86-DRI -7.2 Linking, running and verifying 3D acceleration +9.2 Linking, running and verifying 3D acceleration After you've verified that the X server and DRI have started correctly it's time to verify that the GL library and hardware drivers are working cor- @@ -507,14 +516,19 @@ If you're still having trouble, look in the next section for information spe- cific to your graphics card. -8. Hardware-Specific Information and Troubleshooting +10. Hardware-Specific Information and Troubleshooting This section presents hardware-specific information for normal use and trou- bleshooting. + +10.1 3dfx Voodoo3 Series + +10.1.1 Dependencies -8.1 3dfx Voodoo3 +The Voodoo3 DRI driver requires a special versions of the 3dfx Glide library. +It can be downloaded from the DRI website. -8.1.1 Configuration +10.1.2 Configuration Your XF86Config file's device section must specify the tdfx device: @@ -539,14 +553,22 @@ EndSection The kernel module for the Voodoo3 is named tdfx.o and should be installed in -/lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the -Xserver if needed. +/lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded +by the Xserver if needed. The DRI 3D driver for the Voodoo3 should be in /usr/X11R6/lib/mod- ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. -8.1.2 Troubleshooting +10.1.3 Troubleshooting + o If you try to run an OpenGL application and see an error message similar + to + + gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS + + it means that you have the wrong version of the Glide library for your + hardware. + o 3D acceleration for Voodoo3 is only supported in the 16 bit/pixel screen mode. Use xdpyinfo to verify that all your visuals are depth 16. Edit your XF86Config file if needed. @@ -554,32 +576,171 @@ o The /dev/3dfx device is not used for DRI; it's only for Glide on older 3dfx hardware. -8.1.3 Performance +10.1.4 Performance o Normally, buffer swapping in double-buffered applications is synchro- nized to your monitor's refresh rate. This may be overridden by setting the FX_GLIDE_SWAPINTERNVAL environment variable. The value of this variable indicates the maximum number of swap buffer commands can be buffered. Zero allows maximum frame rate. + + o The glTexEnv mode GL_BLEND is not directly supported by the Voodoo3 + hardware. It can be accomplished with a multipass algorithm but it's + not implemented at this time. Applications which use that mode, such as + the Performer Town demo, may become sluggish when falling back to soft- + ware rendering to render in that mode. + + o The Voodoo3/Banshee driver reverts to software rendering under the fol- + lowing conditions: - o The glTexEnv mode GL_BLEND is not directly supported by the 3dfx hard- - ware. It can be accomplished with a multipass algorithm but it's not - implemented at this time. Applications which use that mode, such as the - Performer Town demo, may become sluggish when falling back to software - rendering to render in that mode. + o Setting GL_LIGHT_MODEL_COLOR_CONTROL to GL_SEPARATE_SPECULAR_COLOR. -8.1.4 Known Problems + o Enabling line stippling or polygon stippling. - o Glide cannot be used directly; only OpenGL-based programs are supported - on the Voodoo3. + o Enabling point smoothing or polygon smoothing. + o Enabling line smoothing when line width is not 1.0. That is, + antialiased lines are done in hardware only when the line width is + 1.0. + + o Using 1-D or 3-D texture maps. + + o Using the GL_BLEND texture environment. + + o Using stencil operations. + + o Using the accumulation buffer. + + o Using glBlendEquation(GL_LOGIC_OP). + + o Using glDrawBuffer(GL_FRONT_AND_BACK). + + o Using glPolygonMode(face, GL_POINT) or glPolygonMode(face, + GL_LINE). + + o Using point size attenuation (i.e. GL_DISTANCE_ATTENUATION_EXT). + + o Using glColorMask(r, g, b, a) when r!=g or g!=b. + +10.1.5 Known Problems + + o The Glide library cannot be used directly; it's only meant to be used + via the tdfx DRI driver. + o SSystem has problems because of poorly set near and far clipping planes. The office.unc Performer model also suffers from this problem. + + o The lowest mipmap level is sometimes miscolored in trilinear- sampled + polygons. + +10.2 3dfx Voodoo5 Series + +10.2.1 Dependencies + +The Voodoo5 DRI driver requires a special versions of the 3dfx Glide library, +different than that used for Voodoo3 hardware. It can be downloaded from the +DRI website. -8.2 Intel i810 +10.2.2 Configuration -8.2.1 Configuration +Your XF86Config file's device section must specify the tdfx device: + Section "Device" + Identifier "Voodoo5" + VendorName "3dfx" + Driver "tdfx" + EndSection + +The Screen section should then reference the Voodoo3 device: + + Section "Screen" + Identifier "Screen 1" + Device "Voodoo5" + Monitor "High Res Monitor" + DefaultDepth 24 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + +The kernel module for the Voodoo5 is named tdfx.o and should be installed in +/lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded +by the Xserver if needed. + +The DRI 3D driver for the Voodoo5 should be in /usr/X11R6/lib/mod- +ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so. + +The Voodoo5 supports 3D rendering in 16 and 32 bpp modes. When running in +32bpp mode an 8-bit stencil buffer and 24-bit Z (depth) buffer are offered. +When running in 16bpp mode only a 16-bit Z (depth) buffer is offered and +stencil is implemented in software. + +A software-based accumulation buffer is available in both 16 and 32bpp modes. + +10.2.3 Troubleshooting + + o The /dev/3dfx device is not used for DRI; it's only for Glide on older + 3dfx hardware. + + o Different versions of Glide are needed for Voodoo3 and Voodoo5. See the + DRI website's resources page to download the right version of Glide. + +10.2.4 Performance + + o Normally, buffer swapping in double-buffered applications is synchro- + nized to your monitor's refresh rate. This may be overridden by setting + the FX_GLIDE_SWAPINTERNVAL environment variable. The value of this + variable indicates the maximum number of swap buffer commands can be + buffered. Zero allows maximum frame rate. + + o Rendering with 16-bit per texel textures is faster than using 32-bit per + texel textures. The internalFormat parameter to glTexImage2D can be + used to control texel size. + + o The Voodoo5 driver reverts to software rendering under the same condi- + tions Voodoo3 with three exceptions. First, stencil operations are + implemented in hardware when the screen is configured for 32 bits/pixel. + Second, the GL_BLEND texture env mode is fully supported in hardware. + Third, glColorMask is fully supported in hardware when the screen is + configured for 32 bits/pixel. + +10.2.5 Known Problems + + o The Glide library cannot be used directly; it's only meant to be used + via the tdfx DRI driver. + + o 24bpp screen modes are supported by the hardware but not by the current + driver. 32bpp is fully supported. + + o As of October, 2000 the second VSA-100 chip on the Voodoo5 is not yet + operational. Therefore, the board isn't being used to its full capac- + ity. The second VSA-100 chip will allow Scan-Line Interleave (SLI) mode + for full-screen applications and games, potentially doubling the sys- + tem's fill rate. + +10.3 Intel i810 + + " + +10.3.1 Dependencies + + " + +A Linux kernel with AGP GART support is required. The 2.2.x kernel series +does not have AGP GART support. The 2.4.x test kernels have AGP GART and +have been tested with the i810. + +10.3.2 Configuration + + " + Your XF86Config file's device section must specify the i810 device, and spec- ify a usable amount of video ram to reserve. @@ -605,13 +766,13 @@ EndSection The kernel module for the i810 is named i810.o and should be installed in -/lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the -Xserver if needed. +/lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded +by the Xserver if needed. The DRI 3D driver for the i810 should be in /usr/X11R6/lib/mod- ules/dri/i810_dri.so. This will be automatically loaded by libGL.so. -8.2.2 Troubleshooting +10.3.3 Troubleshooting o 3D acceleration for the i810 is only available in the 16 bit/pixel screen mode at this time. 32bpp acceleration is not supported by this @@ -625,17 +786,29 @@ ber between 10000 and 16384 seems adequate for most requirements. If too little memory is available for DMA buffers, back and depth buffers and textures, direct rendering will be disabled. + +10.4 Matrox G200 and G400 -8.3 Matrox G200 and G400 + " -8.3.1 Configuration +10.4.1 Dependencies + " + +A Linux kernel with AGP GART support (such as the 2.4.x test kernels) is +needed. + +10.4.2 Configuration + + " + Your XF86Config file's device section must specify the mga device: Section "Device" Identifier "MGA" VendorName "Matrox" Driver "mga" + VideoRam 32768 EndSection The Screen section should then reference the MGA device: @@ -652,33 +825,100 @@ EndSubsection EndSection +To use a 32bpp screen mode, use this Screen section instead: + + Section "Screen" + Identifier "Screen 1" + Device "MGA" + Monitor "High Res Monitor" + DefaultDepth 24 + DefaultFbBpp 32 + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + The kernel module for the G200/G400 is named mga.o and should be installed in -/lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the -Xserver if needed. +/lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded +by the Xserver if needed. The DRI 3D driver for the G200/G400 should be in /usr/X11R6/lib/mod- ules/dri/mga_dri.so. This will be automatically loaded by libGL.so. -8.3.2 Troubleshooting +10.4.3 Performance - o 3D acceleration for the G200 and G400 is only supported in the 16 - bit/pixel screen mode at this time. 32bpp will be supported in the - future. Use xdpyinfo to verify that all your visuals are depth 16. - Edit your XF86Config file if needed. +Software rendering will be used under any of the following conditions: + + o Using glDrawBuffer(GL_FRONT_AND_BACK). + + o Using point, line, or triangle smoothing. + + o Using glLogicOp. + + o Using glPolygonStipple or glLineStipple. + + o Using 1D or 3D textures. + + o Using the accumulation buffer. + +10.4.4 IRQ Assignment + +There have been problems in the past with the MGA driver being very sluggish +when the DRI is enabled (to the point of being unusable.) This is caused by +the graphics card not having an interrupt assigned to it. The current DRI +trunk will attempt to detect this condition and bail out gracefully. + +The solution to the above problem is to assign an interrupt to your graphics +card. This is something you must turn on in your system BIOS configuration. +Please consult your system BIOS manual for instructions on how to enable an +interrupt for your graphics card. -8.3.3 Performance +10.4.5 MGA HAL lib -No data at this time. +MGAHALlib.a is a binary library Matrox has provided for use under Linux to +expose functionality for which they can not provide documentation. (For +example TV-Out requires MacroVision be enabled on the output.) This binary +library also sets the pixel/memory clocks to the optimal settings for your +Matrox card. -8.3.4 Known Problems +Currently the MGAHAL library is required for the G450 to work. You can down- +load this from the driver section on Matrox's website: www.matrox.com/mga - o Multitexture is currently disabled on the G400 to work around a hardware - lockup bug. This should be restored in a subsequent release. +Here modifications to the DRI build instructions which make the mga ddx +driver use the MGAHAL library: -8.4 ATI Rage 128 + 1.Put the following define in your host.def file + #define UseMatroxHal YES + 2. Place mgaHALlib.a in the following directory + xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/ -8.4.1 Configuration +You can use DualHead on the G400/G450 DH cards by creating two device sec- +tions which both point to the same BusID. For most AGP devices the BusID +will be "PCI:1:0:0". Configure your screen section as you would normally +configure XFree86 4.x Multihead. It should be noted that currently the sec- +ond head does not support direct rendering. +10.4.6 Known Problems + +None. + +10.5 ATI Rage 128 + + " + +10.5.1 Dependencies + + " + +A Linux kernel with AGP GART support (such as the 2.4.x test kernels) is +needed. + +10.5.2 Configuration + + " + Your XF86Config file's device section must specify the r128 device: Section "Device" @@ -707,63 +947,66 @@ EndSection The kernel module for the Rage 128 is named r128.o and should be installed in -/lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the -Xserver if needed. +/lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded +by the Xserver if needed. The DRI 3D driver for the Rage 128 should be in /usr/X11R6/lib/mod- ules/dri/r128_dri.so. This will be automatically loaded by libGL.so. You may also set your screen depth to 32 for 32bpp mode. -8.4.2 Performance +10.5.3 Performance While PCI Rage 128 based cards are supported, they do not yet support PCI GART, so they will not perform as well as their AGP counterparts. -8.4.3 Known Problems +10.5.4 Known Problems DGA is not yet supported in the ATI Rage 128 X server. This feature will be added in a future release. -8.5 3DLabs Oxygen GMX 2000 +10.6 3DLabs Oxygen GMX 2000 The driver for this hardware was experimental and is no longer being devel- oped or supported. -9. Limitations and Known Bugs +11. General Limitations and Known Bugs -9.1 OpenGL +11.1 OpenGL The following OpenGL features are not supported at this time: overlays, stereo, hardware-accelerated indirect rendering. -OpenGL-like functionality is provided with the Mesa library. XFree86 4.0 -uses a beta version Mesa 3.3. When newer versions of Mesa are available, the -3D drivers can be updated without reinstalling XFree86 or libGL.so. +OpenGL-like functionality is provided with the Mesa library. XFree86 4.0.1 +uses Mesa 3.3. Subsequent releases of XFree86 will use newer versions of +Mesa. When newer versions of Mesa are available, the 3D drivers can be +updated without reinstalling XFree86 or libGL.so. -9.2 GLX +11.2 GLX The GLX 1.3 API is exported but none of the new 1.3 functions are opera- tional. The new glXGetProcAddressARB function is fully supported. - -9.3 Signal Handling -There are several understood, but unresolved problems relating to hardware -locking and signal handling. Hitting CTRL-z to suspend a 3D application can -sometimes cause the X server to lock-up if executing device driver code at -that moment. Also, using a debugger to step through OpenGL/Mesa device -driver functions code could cause a lock-up. These problems will be fixed in -the future. +GLXPixmap rendering is only supported for indirect rendering contexts. This +is a common OpenGL limitation. Attempting to use a direct rendering context +with a GLXPixmap will result in an X protocol error. + +11.3 Debugging + +Debugging DRI drivers with gdb can be difficult because of the locking +involved. When debugging OpenGL applications, you should avoid stepping +inside the GL functions. If you're trying to debug a DRI driver it's recom- +mended that you do so remotely, from a second system. -9.4 Scheduling +11.4 Scheduling When you run multiple GL applications at once you may notice poor time slic- ing. This is due to an interaction problem with the Linux scheduler which will be addressed in the future. -9.5 libGL.so and dlopen() +11.5 libGL.so and dlopen() A number of popular OpenGL applications on Linux (such as Quake3, HereticII, Heavy Gear 2, etc) dynamically open the libGL.so library at runtime with @@ -796,7 +1039,7 @@ problem. The DRI developers are working with game vendors to prevent this problem in the future. -9.6 Bug Database +11.6 Bug Database The DRI bug database which includes bugs related to specific drivers is at the SourceForge DRI Bug Database @@ -804,15 +1047,15 @@ Please scan both the open and closed bug lists to determine if your problem has already been reported and perhaps fixed. -10. Resources +12. Resources -10.1 Software +12.1 Software A collection of useful configuration files, libraries, headers, utilities and demo programs is available from http://dri.source- forge.net/resources/resources.html -10.2 Documentation +12.2 Documentation o General OpenGL information is available at the OpenGL Home Page @@ -827,7 +1070,7 @@ o The DRI Compilation Guide explains how to download, compile and install the DRI for yourself. -10.3 Support +12.3 Support o The DRI-users mailing list at SourceForge is a forum for people to dis- cuss DRI problems. @@ -835,7 +1078,7 @@ o In the future there may be IHV and Linux vendor support resources for the DRI. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.5 2000/06/17 00:03:17 martin Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.15 2000/12/12 18:54:29 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.6 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.12 2000/12/12 19:04:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp diff -u xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp:3.1 xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp:3.6 --- xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp:3.1 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp Tue Dec 12 14:04:02 2000 @@ -1,15 +1,14 @@ DRI Compilation Guide - Precision Insight, Inc. + VA Linux Systems, Inc. Professional Services - Graphics. - 18 May 2000 + 29 October 2000 1. Preamble 1.1 Copyright -Copyright © 2000 by Precision Insight, Inc., Cedar Park, Texas. All Rights -Reserved. +Copyright © 2000 by VA Linux Systems, Inc. All Rights Reserved. Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all @@ -34,8 +33,8 @@ This information is intended for experienced Linux developers. Beginners are probably better off installing precompiled packages. -Edits, corrections and updates to this document may be mailed to brian@preci- -sioninsight.com. +Edits, corrections and updates to this document may be mailed to brianp@val- +inux.com. 3. Prerequisites @@ -52,98 +51,113 @@ o ssh (secure shell) for registered developer downloading of the DRI source tree + o A recent Linux Kernel. See below for details. + + o FreeBSD support is not currently being maintained and may not work. + For 3dfx Voodoo3 hardware, you'll also need: o Glide3x headers and runtime library if you want to use the 3dfx driver. These can be obtained from linux.3dfx.com. - o Linux kernel 2.2.x. The DRI developers have been using stock RedHat 6.1 - systems (kernel 2.2.12-20). Later kernel versions will be supported in - the future. + o A recent Linux 2.4.x kernel. AGP support is not required. For Matrox G200/G400 hardware, you'll also need: - o Linux kernel 2.3.51. Older kernel versions will not work. + o A recent Linux 2.4.x kernel with AGP support. For Intel i810 hardware, you'll also need: - o Linux kernel 2.3.99-pre6. Older kernel versions will not work. + o A recent Linux 2.4.x kernel with AGP support. For ATI Rage hardware, you'll also need: - o Linux kernel 2.3.51. Other kernel versions may work but this one is - known to work. + o A recent Linux 2.4.x kernel with AGP support. -4. Kernel preparation +4. Linux Kernel Preparation -You may have to upgrade your Linux kernel in order to use the DRI. This is -because you need a kernel version which supports AGP. Building a new Linux -kernel can be difficult for beginners but there are resources on the Internet -to help. This document assumes experience with configuring, building and -installing Linux kernels. +The DRI project closely tracks Linux kernel development. Since the internal +Linux data structures change frequently in the 2.4 development branch it's +important to have use the most recent Linux kernel. As of this writing (Nov +2000), 2.4.0-test11-pre5 is the most recent version of Linux which the DRI is +synchronized to. + +Most of the DRI drivers require AGP support and using Intel Pentium III SSE +optimizations also requires an up-to-date Linux kernel. + +Building a new Linux kernel can be difficult for beginners but there are +resources on the Internet to help. This document assumes experience with +configuring, building and installing Linux kernels. Linux kernels can be downloaded from www.kernel.org + +Here are the basic steps for kernel setup. -Download the needed kernel and put it in /usr/src. Create a directory for -the source and unpack it. For example: + o Download the needed kernel and put it in /usr/src. Create a directory + for the source and unpack it. For example: - cd /usr/src - rm -f linux - mkdir linux-2.3.51 - ln -s linux-2.3.51 linux - bzcat linux-2.3.51.tar.bz2 | tar xf - + cd /usr/src + rm -f linux + mkdir linux-2.4.x + ln -s linux-2.4.x linux + bzcat linux-2.4.x.tar.bz2 | tar xf - -Now configure your kernel. You might, for example, use make menuconfig and -do the following: + o Configure your kernel. You might, for example, use make menuconfig and + do the following: - o Go to Code maturity level options + o Go to Code maturity level options - o Enable Prompt for development and/or incomplete code/drivers + o Enable Prompt for development and/or incomplete code/drivers - o hit ESC + o hit ESC to return to the top-level menu - o Go to Character devices + o Go to Character devices - o Disable Direct Rendering Manager (XFree86 DRI support) since we'll use - the DRI module from the XFree86/DRI tree. + o Disable Direct Rendering Manager (XFree86 DRI support) since we'll + use the DRI module from the XFree86/DRI tree. - o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW) + o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW) - o Hit SPACE twice + o Hit SPACE twice to build AGP support into the kernel - o Enable all chipsets' support for AGP + o Enable all chipsets' support for AGP -It's recommended that you turn on MTRRs under Processor type and Features, -but not required. + o It's recommended that you turn on MTRRs under Processor type and + Features, but not required. -Configure the rest of the kernel as required for your system (i.e. Ethernet, -SCSI, etc) + o Configure the rest of the kernel as required for your system (i.e. Eth- + ernet, SCSI, etc) -Exit, saving your kernel configuration. + o Exit, saving your kernel configuration. -Edit your /etc/lilo.conf file. Make sure you have an image entry as follows -(or similar): + o Edit your /etc/lilo.conf file. Make sure you have an image entry as + follows (or similar): - image=/boot/vmlinuz - label=linux.2.3.51 - read-only - root=/dev/hda1 + image=/boot/vmlinuz + label=linux.2.4.x + read-only + root=/dev/hda1 -The important part is that you have /boot/vmlinuz without a trailing version -number. If this is the first entry in your /etc/lilo.conf AND you haven't -set a default, then this will be your default kernel. + The important part is that you have /boot/vmlinuz without a trailing + version number. If this is the first entry in your /etc/lilo.conf AND + you haven't set a default, then this will be your default kernel. -Now compile the new kernel: + o Compile the new kernel. - cd /usr/src/linux-2.3.51 - make dep ; make bzImage - make modules ; make modules_install - make install + cd /usr/src/linux-2.4.x + make dep + make bzImage + make modules + make modules_install + make install -Note that the final part, make install, will automatically run lilo for you. + Note that last make command will automatically run lilo for you. -Now reboot to use this new kernel. + o Upgrade your modutils package for Linux 2.4.x if you're upgrading from + Linux 2.2.x. + o Now reboot to use the new kernel. + 5. Downloading the XFree86/DRI CVS Sources The DRI project is hosted by VA Linux Systems' SourceForge. The DRI source @@ -201,17 +215,30 @@ The -z3 flag causes compression to be used in order to reduce the down- load time. -6. Updating your CVS sources +5.3 Updating your CVS sources In the future you'll want to occasionally update your local copy of the DRI source code to get the latest changes. This can be done with: - cd ~/DRI-CVS - cvs -z3 update -dA xc + cd ~/DRI-CVS + cvs -z3 update -dA xc The -d flag causes any new subdirectories to be created and -A causes most recent trunk sources to be fetched, not branch sources. +6. Mesa + +Most of the DRI 3D drivers are based on Mesa (the free implementation of the +OpenGL API). The relevant files from Mesa are already included in the +XFree86/DRI source tree. There is no need to download or install the Mesa +source files separately. + +Sometimes a newer version of Mesa will be available than the version included +in XFree86/DRI. Upgrading Mesa within XFree86/DRI is not always straightfor- +ward. It can be an error-prone undertaking, especially for beginners, and is +not generally recommended. The DRI developers will upgrade Mesa when appro- +priate. + 7. Compiling the XFree86/DRI tree 7.1 Make a build tree @@ -241,7 +268,8 @@ The default host.def file will look something like this: #define DefaultCCOptions -Wall - #define DefaultGcc2i386Opt -O2 + (i386) #define DefaultGcc2i386Opt -O2 + (Alpha) #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar) #define LibraryCDebugFlags -O2 #define BuildServersOnly YES #define XF86CardDrivers vga tdfx mga r128 i810 @@ -260,7 +288,7 @@ You probably don't want to use /usr/X11R6/ because that would overwrite your default X files. The following is recommended: - #define ProjectRoot /usr/XF86-main + #define ProjectRoot /usr/X11R6-DRI Especially note the XF86CardDrivers line to be sure your driver is listed. @@ -270,7 +298,7 @@ If you do not have 3dfx hardware comment out the HasGlide3 line in host.def. -7.3 Compile +7.3 Compilation To compile the complete DRI tree: @@ -289,6 +317,9 @@ Building will take some time so you may want to go check your email or visit slashdot. +WARNING: do not use the -j option with make. It's reported that it does not +work with XFree86/DRI. + 7.4 Check for compilation errors Using your text editor, examine World.LOG for errors by searching for the @@ -308,110 +339,182 @@ always supported. If your build machine is running a different version of the kernel than your -target machine (i.e. 2.2.12-20 vs. 2.3.99-pre6), make will select the wrong -kernel headers. This can be fixed by explicitly setting the value of TREE. -If the path to your kernel source is /bigdisk/linux-2.3.99-pre6, +target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel +headers. This can be fixed by explicitly setting the value of TREE. If the +path to your kernel source is /usr/src/linux-2.4.x, cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel - make TREE=/bigdisk/linux-2.3.99-pre6 + make TREE=/usr/src/linux-2.4 or alternatively, edit Makefile to include this change. -After fixing the errors, do make World again. Later, you might just compile +After fixing the errors, run make World again. Later, you might just compile parts of the source tree but it's important that the whole tree will build first. + +7.5 DRI kernel module installation + +The DRI kernel modules are in ~/DRI-CVS/build/xc/pro- +grams/Xserver/hw/xfree86/os-support/linux/drm/kernel/. -8. Installing +To load the appropriate DRI module in your running kernel you can either use +ismod and restart your X server or copy the kernel module to /lib/mod- +ules/2.4.x/kernel/driver/char/drm/ then run depmod and restart your X server. -After the DRI tree has been compiled you can install the XFree86 headers, -libraries, programs, etc for testing. +Make sure you first unload any older DRI kernel modules that might be already +loaded. +8. Normal Installation and Configuration + +Most users will want to install the new X server and use it instead of the +original X server. This section explains how to do that. We assume that the +user is upgrading from XFree86 3.3.x. + +Developers, on the other hand, may just want to test the X server without +actually installing it as their default server. If you want to do that, skip +to the next section. + 8.1 X Installation -As mentioned above, the install directory is specified by the ProjectRoot -variable in the host.def file. Create that directory now if it doesn't -already exist: +You'll need to run as root to do the following commands: - mkdir /usr/XF86-main + su -You'll have to change to root since the install process puts several files in -/etc/X11/ and sets the setuid flag on the X server executable. +As mentioned above, the installation directory is specified by the Project- +Root variable in the host.def file. Create that directory now if it doesn't +already exist, then run the install commands: + mkdir /usr/X11R6-DRI cd ~/DRI-CVS/build/xc - su make install -Edit your /etc/ld.so.conf file and put /usr/XF86-main/lib as the first line. -Continue with: +8.2 Linker configuration - ldconfig - exit +Edit your /etc/ld.so.conf file and put /usr/X11R6-DRI/lib as the first line. +Then run: -Look in /usr/XF86-main to be sure the files installed there. + ldconfig -Strictly speaking, installing the DRI tree isn't required. It's possible to -run and test the X server directly from the build directory but it's a bit -error prone. +This will ensure that you use the new X libraries when you run X programs. -8.2 Update Locale Information +8.3 Update Locale Information To update your X locale information do the following: cd ~/DRI-CVS/build/xc/nls - xmkmf -a + ../config/util/xmkmf -a make make install This will prevent a locale error message from being printed when you run Xlib programs. -9. X Server Configuration +8.4 Setup Miscellaneous Files -If your X server is currently running you'll have to stop it and return to a -virtual terminal. +Issue the following commands: -First, setup your XF86Config file. It should load the GLX and DRI modules -and specify the driver to use for your hardware. See the DRI User Guide for -detailed information. + cd /usr/X11R6-DRI/lib/X11 + ln -s /usr/X11R6/lib/X11/rgb.txt . + ln -s /usr/X11R6/lib/X11/fonts . + ln -s /usr/X11R6/lib/X11/app-defaults . -You may want to make a backup copy of your existing /etc/X11/XF86Config file -first. +This will allow applications to use the fonts and resources that they used in +the past. + +8.5 Disable the Old X Server and Enable the New One + +Assuming that an installation of XFree86 3.3.x is present, we need to disable +the old 3.3.x X server and enable the new 4.0.x X server. + +Issue the following commands: + + cd /usr/X11R6/bin + mv Xwrapper Xwrapper.old + rm X + ln -s /usr/X11R6-DRI/bin/XFree86 X + +This will cause the new X server to be used instead of the original one. + +8.6 Create the XF86Config File + +Configuration files for XFree86 3.3.x will not work with XFree86 4.0.x. + +The new 4.0.x server can generate a basic configuration file itself. Simply +do this: + + cd /usr/X11R6-DRI/bin + ./XFree86 -configure + +A file named /root/XF86Config.new will be created. It should allow you to +try your X server but you'll almost certainly have to edit it. For example, +you should add HorizSync and VertRefresh options to the Monitor section and +Modes options to the Screen section. Also, the ModulePath option in the +Files section should be set to /usr/X11R6-DRI/lib/modules. + +On the DRI web site, in the resources section, you'll find example XF86Config +files for a number of graphics cards. These configuration files also setup +DRI options so it's highly recommended that you look at these examples. + +In any case, your new XF86Config file should be placed in /etc/X11/XF86Con- +fig-4. This configuration file will be recognized by the 4.0.x server but +not by 3.3.x servers. You can instead name it /etc/X11/XF86Config but +that'll overwrite your old config file, which you may want to preserve. + +8.7 Start the New X Server + +The new X server should be ready to use now. Start your X server in your +usual manner. Typically, the startx command is used: + + startx + +9. Testing the Server Without Installing It + +As mentioned at the start of section 8, developers may want to simply run the +X server without installing it. This can save some time and allow you to +keep a number of X servers available for testing. + +9.1 Configuration + +As described in the preceding section, you'll need to create a configuration +file for the new server. Put the XF86Config file in your ~/DRI- +CVS/build/xc/programs/Xserver directory. -It's very important that you set the ModulePath option to point to your -installation directory: +Be sure the ModulePath option is set correctly. - ModulePath "/usr/XF86-main/lib/modules" +9.2 A Startup Script -Double check with this: +A simple shell script can be used to start the X server. Here's an example. - grep ModulePath /etc/X11/XF86Config + #!/bin/sh + export DISPLAY=:0 + ./XFree86 -xf86config XF86Config & \ + sleep 2 + fvwm2 & + xset b off + xmodmap -e "clear mod4" + xsetroot -solid "#00306f" + xterm -geometry 80x40+0+0 -Next, your ~/.xinitrc file controls which clients will be launched when your -X server starts. You might put the following in yours: +You might name this script start-dri. Put it in your ~/DRI-CVS/build/xc/pro- +grams/Xserver directory. - xset b off - xsetroot -solid "#004070" - xmodmap -e "clear mod4" - xrdb -merge ~/.Xdefaults - xterm -geometry +0+0 & - xterm -geometry +512+0 & - fvwm +To test the server run the script: -10. X Server Start-up + cd ~/DRI-CVS/build/xc/programs/Xserver + ./start-dri -The X server can be started with: +For debugging, you may also want to capture the log messages printed by the +server in a file. If you're using the C-shell: - xinit -- /usr/XF86-main/bin/XFree86 + ./start-dri >& log -Automatic loading of DRM kernel modules was added to the X server in XFree86 -4.0.1. This feature, and manual loading of kernel modules, is documented in -the DRI user guide. +10. Where To Go From Here At this point your X server should be up and running with hardware-acceler- -ated direct rendering. Please read the DRI User Guide for trouble shooting -information. +ated direct rendering. Please read the DRI User Guide for information about +trouble shooting and how to use the DRI-enabled X server for 3D applications. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.3 2000/06/17 02:16:49 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.9 2000/12/12 17:48:10 alanh Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp,v 3.1 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp,v 3.6 2000/12/12 19:04:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.Darwin diff -u /dev/null xc/programs/Xserver/hw/xfree86/doc/README.Darwin:1.3 --- /dev/null Mon Dec 18 14:29:45 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.Darwin Tue Dec 12 14:04:02 2000 @@ -0,0 +1,348 @@ + XFree86 on Darwin and Mac OS X + + Torrey T. Lyons + + 11 December 2000 + +1. Introduction + +XFree86, a free implementation of X Windows, has been ported to Darwin and +Mac OS X. This document is a collection of information for anyone experiment- +ing with running X Windows on Apple's next generation operating system. +Please send any comments on this page to . If you are also +working on modifications to the Darwin X server, please let me know. + +2. Hardware Support and Configuration + +The Darwin port of XFree86 uses the IOKit for device driver loading and dis- +covery, rather than the XFree86 module loader. Because of this, the XFree86 +configuration file is not used on Darwin systems. The descriptions found +elsewhere of devices supported by XFree86 for other operating systems also do +not apply. + +XFree86 for Darwin will work with any video card that you have an IOKit +driver for. If you are running Mac OS X, this typically means any card that +has been shipped by Apple. If a card works for you with the Mac OS X GUI, it +will work on the same machine with XFree86. If you have a pure Darwin instal- +lation, your hardware support may be somewhat limited because Apple does not +include all its hardware drivers with Darwin. IOKit drivers are typically +found in /System/Library/Extensions/ or /Library/Extensions/. + +Multi-button and scroll wheel mouse support works well with all USB mice that +I have tested. I have done no testing with serial mice. + +3. Getting Started + +Following are instructions for building and running your own copy of XFree86. +The procedure for getting your X server up and running on Darwin and Mac OS X +are very similar, but it is actually somewhat more difficult on Mac OS X. +Where there are differences I have noted them below. Both Mac OS X Develop- +ers' Preview 4 and Mac OS X Public Beta are covered. Note that to build +XFree86 for yourself on Mac OS X Beta, you will need to have the Developers' +Tools. If you did not receive these as a member of ADC, they are available +for download from the Apple Developer Connection. + +If you want to save some time, you can use the precompiled binaries provided +by the XFree86 server at . Follow the instructions in the Install document to install +it. + +This will create two new directory trees, /usr/X11R6 and /private/etc/X11. If +you have the developers' tools, you may have to run ranlib on all the +libraries in /usr/X11R6/lib/* before trying to build other X applications. + +If you get the precompiled binaries you can skip ahead to the section on run- +ning X windows (section 4., page 1) + +On the other hand, if you want to build things yourself from scratch, follow +the directions below. + +If you want to recompile the X server on Mac OS X, you will have to make the +header files as described below (section 3.2, page 1). + +3.1 Get the Code + +The first thing you need to do is to get the source code from the XFree86 +project. + + o Setup CVS: Both Darwin and Mac OS X include CVS (Concurrent Versions + System), which is an easy way to download and keep up to date with open + source code released by XFree86 and others. You do have to setup CVS + properly, however, to tell it where to look. Follow the instructions + here on how to do this either via ssh or via the cvs pserver. + + o Now make a directory in some convenient place which will serve as your + top level directory for you open source development efforts. I am going + to call this directory sandbox/ in the following discussions and you + could put this directory, for example, in ~/sandbox/. + + o From the command line type: + + cd sandbox + cvs checkout xc + + Wait for all the files to complete downloading. + +3.2 Make Header Files for Mac OS X + +These next steps are not necessary if you are building XFree86 on Darwin. Mac +OS X Beta or DP4 does not include many of the 'in-progress' header files that +are needed to successfully build XFree86. The general philosophy is that at +any given time, Mac OS X will include only headers files that are 'ready for +prime time' while Darwin will include a snapshot of Apple's current efforts. +So if you have access to a Darwin system, I would suggest using this instead +of Mac OS X to build XFree86. If you don't, read the appropriate page below +for an outline of what you need to do: + + o Mac OS X Public Beta (section 6.1, page 1) + + o Mac OS X Developers' Preview 4 (section 6.2, page 1) + +3.3 Build XFree86 + +Once you have everything ready it is easy to build and install XFree86. From +the command line: + + cd sandbox/xc + make World >& world.log + + (wait for several hours) + + su root + make install >& install.log + make install.man >& man.log + +4. Run X Windows + +You will want to add the X windows executables to your path. Your path is the +list of directories to be searched when you type a command. You will also +want to add the man pages from XFree86 to the list of pages to be searched +when you are looking for documentation. The way to do this depends on the +shell you are using. With tcsh or csh add the following two lines to a file +in your home directory called .cshrc (create this file if you don't have one +yet): + + setenv MANPATH "${MANPATH}:/usr/X11R6/man:/usr/local/man" + setenv PATH "${PATH}:/usr/X11R6/bin" + +Now type ``source ~/.cshrc;rehash'' to get these changes to take effect. On +future logins, this file will be executed automatically. + +You are now ready to go. On Mac OS X, you have to do a few extra steps each +time you want to run X windows. You can't run XFree86 with CoreGraphics run- +ning since they both want to control the screen. So for Mac OS X you first +need to logout. Then for Mac OS X DP4, from the login window type ``console'' +as the user name and push login. For Mac OS X Beta, type ``>console'' as the +user name. This should shutdown CoreGraphics and bring you up with a text +console. Login again. + +Now from the text console you can start X Windows in either Darwin or Mac OS +X by typing ``startx''. After a brief wait at least one terminal window +should pop up for you. So far it probably isn't very impressive as you might +not even have a window manager running to allow you to move windows around. + +When you are ready to quit X windows type ``exit'' in the main terminal win- +dow or quit with the window manager if you have one running. Unfortunately +the X server won't shutdown correctly and you will get an apparently frozen +screen with only a spinning beachball cursor on it. Nothing you type shows up +on the screen, but in fact your keystrokes are being received by the console. +Type ``logout'' to return to normalcy after a brief delay. With Darwin this +should put you back at the text console login prompt. With Mac OS X, Core- +Graphics will restart and you should be given a login window. + +Customize X Windows + +X windows is very customizable and you will certainly want to change some +things. There is a lot you can do to control how your windows look, how the +windows are moved, resized, etc. You will likely want to get a better window +manager than twm, which is included with XFree86. The .xinitrc file in your +home directory controls what programs are run when you start X windows. You +can find a sample .xinitrc file in /private/etc/X11/xinit/xinitrc. + +There are several window managers that have been ported to Darwin. The best +collection of window managers and other X windows applications is at Dar- +winfo's ports page. Another good place to look for Darwin ports in general is +at Stepwise's Softrak site. + +Good luck! + +5. Outstanding Issues with the X server + +There is a still a lot to be done with the X server. As always please let me +know if you are interested in working on any of these issues. + +Things that are broken: + + o The bell is broken. + + o Server shutdown problem: After quitting the X server the colored beach- + ball cursor reappears, but the screen never returns to the console dis- + play. The console is accepting input however, so typing ``logout'' will + return you to the login prompt. + + o Only one display is currently supported. + + o Screen saver not supported. + + o Key repeat rate can not be adjusted. + +Things I am working on: + + o Allowing rootless use on Mac OS X + + o Correct wake from sleep behavior + +6. Appendix + +6.1 Installing IOKit Header files on Mac OS X Beta + +Here is what you need to do to be able to build XFree86 (or other clients of +IOGraphics services) on Mac OS X Public Beta. + + 1. You need to install some more build tools that aren't included in Mac + OS X Beta, but are included in Darwin. These are needed for the next + step. Go to your development directory and type: + + cvs checkout bootstrap_cmds + cd bootstrap_cmds + make + + Now su to root and do a ``make install'' from the bootstrap_cmds direc- + tory. + + 2. The IOKit framework included with Mac OS X Beta is a little on the + wimpy side, even after installing the Developer Tools. You'll need to + rebuild it, but to do so safely we'll take advantage of the cool direc- + tory structure of Mac OS X and put the new version in /Library/Frame- + works/. This will override the version in /System/Library/Frameworks/. + Or at least, that's where you should put it using the new Mac OS X Beta + file structure, but in fact the compiler doesn't know this and still + looks in /Local/Library/Frameworks. (I have already filed a developer's + bug report on this.) To start we make a copy of the original. Login as + root and do the following: + + cd /Library + mkdir -p Frameworks + cp -R /System/Library/Frameworks/IOKit.framework Frameworks/IOKit.framework + cd / + mkdir -p Local + ln -s /Library /Local/Library + + 3. Now you need to get a full version of the IOKit framework from the Dar- + win repository. This comes as part of the kernel. So, in your develop- + ment directory again: + + cvs checkout xnu + cd xnu + source SETUP/setup.csh + make exporthdrs + make install + + The "make install" will start by assembling all the headers you need, + but then will proceed to build a new kernel. You can Control-C out of + the build once it starts compiling things if you want. Otherwise, just + be patient. + + 4. You also need to get the IOKitUser project, which contains the user + interface to the IOKit, and merge it into the IOKit framework. From + your development directory type: + + cvs checkout IOKitUser + + Then you need to change the Makefile so it builds on top of the new + IOKit framework you are building. Change to the IOKitUser project + directory and edit the Makefile. Change the following line: + + NEXTSTEP_BUILD_OUTPUT_DIR = /$(USER)/build/$(NAME) + + to: + + NEXTSTEP_BUILD_OUTPUT_DIR = /BUILD/dst/System/Library/Frameworks + + Now, run ``make'' while in the IOKitUser directory. It will likely not + finish building since the IOKitUser project relies on some stuff that + Apple hasn't really made public yet, but it should finish populating + the new IOKit framework with headers and start compiling. (Strangely + enough, the headers installed in your new IOKit framework don't contain + the real header files. They are just single line files with an #import + of the file in your IOKitUser project. This works fine as long as you + don't ever delete or move your IOKitUser project. I imagine that using + ``make install'' would fix this up, but you can't do this as long as + the project doesn't build correctly. So for now you can either move the + header files by hand, or make sure you leave your IOKitUser project in + place.) + + 5. Now put the new IOKit headers into our local copy. Change to the xnu + project directory and do the following as root: + + cd BUILD/dst/System/Library/Frameworks/ + cp -R IOKit.framework/Versions/A/Headers/* \ + /Library/Frameworks/IOKit.framework/Versions/A/Headers + + 6. The System framework needs touching up a bit too. You need to copy the + libkern header files from the new System.framework. As root, go to the + xnu project directory and type: (Of course you could make a local copy + of the System framework in /Library/Frameworks/, but the additions to + the System framework are small.) + + cd BUILD/dst/System/Library/Frameworks/System.framework/Versions/B/Headers + cp -R libkern /System/Library/Frameworks/System.framework/Headers/libkern + +6.2 Installing IOKit Header files on Mac OS X DP4 + +Here is an outline of what you need to do to be able to build XFree86 (or +other clients of IOGraphics services) on Mac OS X Developers' Preview 4. + + 1. Checkout, build, and install bootstrap_cmds from the CVS repository. + + 2. Checkout xnu from the CVS repository. Go to sandbox/xnu and do the fol- + lowing: + + source SETUP/setup.csh + make exporthdrs + + 3. su to root and do the following: + + mkdir -p /Local/Library/Frameworks + cp -R /System/Library/Frameworks/IOKit.framework /Local/Library/Frameworks + + This will create a new local version of the IOKit framework that will + override the System version without changing the original. + + 4. You now want to merge the IOKit headers from the xnu project into your + local IOKit framework. I did this fairly tediously by hand, but I would + suggest something like: + + cp -R sandbox/xnu/BUILD/dst/System/Library/Frameworks/IOKit.framework/Versions/A/Headers \ + /Local/Library/Frameworks/IOKit.framework/Versions/A + + The only problem with this is that there are a few stub header files + included that are just a single line with an #import to the appropriate + place in the xnu source on your disk. This is fine as long as you don't + move your xnu project. If you do, you can copy the original file to + replace the stub. There is probably an easier way to automatically + build a clean version of the IOKit framework, but I didn't find it. + (Let me know if you do.) + + 5. There are just a few more files you need in the IOKit framework. Check- + out the IO project from CVS. Get the necessary header files from there + and put them in your new local IOKit framework. You'll get errors when + you try to build XFree86 from which you can tell which files are + needed. I also needed to make the following patch to IOLLEvent.h. Your + mileage may vary. + + 47c47 + < #include + --- + > #include + + 6. You'll also need a few extra CoreFoundation header files. Checkout + CoreFoundation. You can make a new local version of the CoreFoundation + framework as above, or just add to the existing one. The files you need + are CFMachPort.h and CFMessagePort.h in the RunLoop.subproj and CFStor- + age.h in Collections.subproj. + + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Darwin.sgml,v 1.4 2000/12/12 18:54:29 dawes Exp $ + + +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.Darwin,v 1.3 2000/12/12 19:04:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.I128 diff -u xc/programs/Xserver/hw/xfree86/doc/README.I128:1.6 xc/programs/Xserver/hw/xfree86/doc/README.I128:1.10 --- xc/programs/Xserver/hw/xfree86/doc/README.I128:1.6 Tue Feb 29 20:48:05 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.I128 Thu Dec 14 12:12:00 2000 @@ -2,7 +2,7 @@ The XFree86 Project Inc. - 24 October 1998 + 3 November 2000 1. Supported hardware @@ -43,17 +43,17 @@ probe for clocks. The driver will auto-detect the amount of video ram pre- sent. -The following Section "Device" options are supported by the MGA driver: +The following Section "Device" options are supported by the I128 driver: - o Option "dac_8_bit" + o Option "Dac6Bit" - Will enable 8-bit DAC support. + Will enable 6-bit DAC support. - o Option "no_accel" + o Option "NoAccel" Will disable all hardware acceleration. - o Option "sync_on_green" + o Option "SyncOnGreen" Will enable syncing on green for sync-on-green monitors (these are typi- cally fixed frequency workstation monitors). @@ -81,15 +81,23 @@ o Modeline "800x512d08" 54.375 800 800 840 848 512 512 514 515 HSkew 1 DoubleScan +Hsync +Vsync + o These lines are required for use with the SGI Multilink Adapter and the + SiliconGraphics Flat Panel display. + + o Modeline "1600x1024g" 108.0 1600 1616 1656 1704 1024 1027 1030 1056 + -Hsync -Vsync + + o Option "OverridePolarity" "1" + 5. Author(s) -Robin Cutshaw, robin@XFree86.Org +Robin Cutshaw, and special help from: - o Galen Brooks, galen@nine.com + o Galen Brooks, - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.3 1999/08/28 10:43:32 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.6 2000/12/13 01:55:47 robin Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.I128,v 1.6 2000/03/01 01:48:05 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.I128,v 1.10 2000/12/14 17:12:00 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.LynxOS diff -u xc/programs/Xserver/hw/xfree86/doc/README.LynxOS:3.27 xc/programs/Xserver/hw/xfree86/doc/README.LynxOS:3.28 --- xc/programs/Xserver/hw/xfree86/doc/README.LynxOS:3.27 Sat Jun 17 13:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.LynxOS Fri Dec 1 14:47:46 2000 @@ -1,4 +1,4 @@ - README for XFree86 4.0.1 on LynxOS + README for XFree86 4.0.2 on LynxOS Thomas Mueller @@ -13,19 +13,19 @@ See the Copyright Notice. -The sources for XFree86 4.0.1 are available by anonymous ftp from: +The sources for XFree86 4.0.2 are available by anonymous ftp from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1 +ftp://ftp.XFree86.org/pub/XFree86/4.0.2 Binaries of XFree86 for LynxOS x86 are available from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/LynxOS +ftp://ftp.XFree86.org/pub/XFree86/4.0.2/binaries/LynxOS A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR- RORS The binaries on the FTP site were built on the latest released LynxOS version -at the time XFree86 4.0.1 was released. In this case it is `LynxOS x86 +at the time XFree86 4.0.2 was released. In this case it is `LynxOS x86 3.0.1'. Because of changes made to the object format they don't run on LynxOS versions earlier than 3.0.0. @@ -37,7 +37,7 @@ 3.1.0' support has to be considered to be in `alpha state'. Initial tests were performed on LynxOS x86 only! -XFree86 4.0.1 supports LynxOS on the x86 and on the PowerPC platform. X +XFree86 4.0.2 supports LynxOS on the x86 and on the PowerPC platform. X servers are currently available only on the x86 platform. The X server may work with some PowerPC platforms supported by LynxOS though this has not (yet) been thoroughly tested. @@ -163,7 +163,7 @@ 3.5 X Server debug diagnostics output and other VT peculiarities Output made by the XFree86 X on its stdout or stderr will be lost after the -server switches to graphics mode. The XFree86 4.0.1 server stores its output +server switches to graphics mode. The XFree86 4.0.2 server stores its output in /usr/adm/XFree86.n.log (where n is the screen number). When the X server is running output made to other consoles will be lost. @@ -266,4 +266,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml,v 3.20 2000/06/17 00:27:32 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.LynxOS,v 3.27 2000/06/17 17:44:20 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.LynxOS,v 3.28 2000/12/01 19:47:46 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.NetBSD diff -u xc/programs/Xserver/hw/xfree86/doc/README.NetBSD:3.70 xc/programs/Xserver/hw/xfree86/doc/README.NetBSD:3.75 --- xc/programs/Xserver/hw/xfree86/doc/README.NetBSD:3.70 Sat Jul 1 22:46:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.NetBSD Tue Dec 12 14:04:02 2000 @@ -1,8 +1,8 @@ - README for XFree86 4.0.1 on NetBSD + README for XFree86 4.0.2 on NetBSD Rich Murphey, David Dawes, Marc Wandschneider, Mark Weaver, Matthieu Herrb - Last modified on: 1 July 2000 + Last modified on: 7 December 2000 1. What and Where is XFree86? @@ -15,16 +15,15 @@ The sources for XFree86 are available by anonymous ftp from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1 +ftp://ftp.XFree86.org/pub/XFree86/4.0.2 Binaries for NetBSD 1.3 and later are available from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/NetBSD +ftp://ftp.XFree86.org/pub/XFree86/4.0.2/binaries/NetBSD -A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR- -RORS +A list of mirror sites is provided by http://www.xfree86.org/MIRRORS.shtml XFree86 also builds on other NetBSD architectures. See section Building on -other architectures (section 8.3, page 1) for details. +other architectures (section 8.4, page 1) for details. XFree86 also supports NetBSD on PC98 machines. @@ -35,24 +34,37 @@ 3. New OS dependent features -See the Release Notes for non-OS dependent new features in XFree86 4.0.1. +See the Release Notes for non-OS dependent new features in XFree86 4.0.2. -3.1 New OS dependent features in 4.0.1 +3.1 New OS dependent features in 4.0.2 + o A fix for libXmu OS detection which was broken since unix isn't defined + anymore by the C preprocessor. + + o (limited) native wscons support. This is not activated by default. + + o Updates to the aperture driver + + o Support for multithread libraries with GNU pth + + o Add /usr/pkg/bin to the default user path. + +3.2 New OS dependent features in 4.0.1 + o Support for NetBSD 1.5_ALPHA o The Xsun server can be built on NetBSD/sparc -3.2 New OS dependent features in 4.0 +3.3 New OS dependent features in 4.0 o Preliminary APM support. -3.3 New OS dependent features in 3.9.18 +3.4 New OS dependent features in 3.9.18 o Soft-booting secondary cards through the int10 BIOS interface is now possible using the x86emu real mode emulator. -3.4 New OS dependent features in 3.9.17 +3.5 New OS dependent features in 3.9.17 o Support for silken mouse with the wsmouse protocol has been added. @@ -93,7 +105,7 @@ send more than three bytes at a time (especially Intellimouse, or MouseMan+ with a ``3D'' roller) are not supported yet. -XFree86 4.0.1 also has support for the mouse driver included in the new +XFree86 4.0.2 also has support for the mouse driver included in the new wscons console driver introduced by NetBSD 1.4. Specify ``wsmouse'' as the protocol and ``/dev/wsmouse0'' as the device in /etc/XF86Config if you're using NetBSD 1.4 with wscons. @@ -200,14 +212,14 @@ access to the /dev/mem device when in multi-users mode. But XFree86 servers can take advantage (or require) linear access to the display memory. -Most XFree86 4.0.1 card drivers require linear memory access. There are two +Most XFree86 4.0.2 card drivers require linear memory access. There are two ways to allow XFree86 to access linear memory: The first way is to disable the kernel security feature by adding ``option INSECURE'' in the kernel configuration file and build a new kernel. The second way is to install the aperture driver, included in source form in -xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar in the XFree86 4.0.1 source +xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar in the XFree86 4.0.2 source distribution. Unpack it in a new directory of your choice by running: sh apNetBSD.shar @@ -257,24 +269,35 @@ You should configure the distribution by editing xc/config/cf/host.def before compiling. To compile the sources, invoke ``make World'' in the xc directory. + +8.1 Perl support + +Starting with XFree86 4.0.2, perl is needed to build the fonts in XFree86. +Since perl is not included with standard NetBSD installation, fonts that need +perl are not built by default. -8.1 Aperture driver +If you have installed perl (from the NetBSD packages, for instance), add the +line + #define HasPerl YES + +in xc/config/cf/host.def before rebuilding XFree86. + +8.2 Aperture driver + To build the XFree86 server with the Aperture driver enabled, you should unpack apNetBSD.shar and install it first. Then edit xc/config/cf/host.def and add the line #define HasNetBSDApertureDriver YES - -to it. -And finally run make World in the xc directory. +to it before rebuilding XFree86. -8.2 Console drivers +8.3 Console drivers XFree86 has a configuration option to select the console drivers to use in -xf86site.def: +host.def: o if you're using pccons put: @@ -284,16 +307,27 @@ #define XFree86ConsoleDefines -DPCVT_SUPPORT -If you don't define XFree86ConsoleDefines in xf86site.def the pccons and pcvt +If you don't define XFree86ConsoleDefines in host.def the pccons and pcvt drivers will be supported by default. -8.3 Building on other architectures +Experimental native support for the wscons console driver can be built by +adding: + #define XFree86ConsoleDefines -DWSCONS_SUPPORT + +to xc/config/host.def before rebuilding the server. This has not been thor- +oughly tested, except on the macppc. + +8.4 Building on other architectures + Note that the NetBSD project has now its own source tree, based on the XFree86 source tree, with some local modifications. You may want to start with this tree to rebuild from sources. The NetBSD xsrc source tree is available at: ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/xsrc/ +There's an experimental patch by Tsubai Masanari to make XFree86 4.0.1 work +on NetBSD/macppc at: ftp://nandra.iri.co.jp/pub/NetBSD/macppc/XFree86/README. + 9. Building New X Clients The easiest way to build a new client (X application) is to use xmkmf if an @@ -324,7 +358,7 @@ particular, David Dawes, Pace Willison, Amancio Hasty, Christoph Robitschko, Nate Williams, Rod Grimes, Jack Velte and Michael Smith. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.56 2000/07/02 02:35:27 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.59 2000/12/12 18:54:29 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.NetBSD,v 3.70 2000/07/02 02:46:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.NetBSD,v 3.75 2000/12/12 19:04:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD diff -u xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD:1.13 xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD:1.20 --- xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD:1.13 Sat Jul 1 22:46:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD Tue Dec 12 14:04:02 2000 @@ -1,8 +1,8 @@ - README for XFree86 4.0.1 on OpenBSD + README for XFree86 4.0.2 on OpenBSD Matthieu Herrb - Last modified on: 1 July 2000 + Last modified on: 2 December 2000 1. What and Where is XFree86? @@ -13,16 +13,15 @@ See the Copyright Notice. -The sources for XFree86 4.0.1 are available by anonymous ftp from: +The sources for XFree86 4.0.2 are available by anonymous ftp from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1 +ftp://ftp.XFree86.org/pub/XFree86/4.0.2 -Binaries for OpenBSD/i386 2.6 and later are available from: +Binaries for OpenBSD/i386 2.8 and later are available from: -ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/OpenBSD +ftp://ftp.XFree86.org/pub/XFree86/4.0.2/binaries/OpenBSD -A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR- -RORS +A list of mirror sites is provided by http://www.xfree86.org/MIRRORS.shtml XFree86 also builds on other OpenBSD architectures. See section Building on other architectures (section 8.2, page 1) for details. @@ -34,10 +33,21 @@ 3. New OS dependent features -See the Release Notes for non-OS dependent new features in XFree86 4.0.1. +See the Release Notes for non-OS dependent new features in XFree86 4.0.2. -3.1 New OS dependent features in 4.0.1 +3.1 New OS dependent features in 4.0.2 + o Support for the OpenBSD ports tree, + + o Preliminary support for the powerpc architecture (clients build and + work, the server doesn't work yet), + + o xdm now writes an utmp entry, + + o startx now creates an Xauthority magic cookie for the display. + +3.2 New OS dependent features in 4.0.1 + o Several features from the OpenBSD X11 tree were merged into xdm: o support for Kerberos IV authentication @@ -55,21 +65,21 @@ o The Xsun server can be built again on OpenBSD/sparc. -3.2 New OS dependent features in 4.0 +3.3 New OS dependent features in 4.0 o Multi-thread safe libraries are built by default on OpenBSD 2.6 and later, o Preliminary APM support. -3.3 New OS dependent features in 3.9.18 +3.4 New OS dependent features in 3.9.18 o Support for USB mices has been added on OpenBSD. o Soft-booting secondary cards through the int10 BIOS interface is now possible using the x86emu real mode emulator. -3.4 New OS dependent features in 3.9.17 +3.5 New OS dependent features in 3.9.17 o Silken mouse is supported for serial mices, and, under post 2.6 OpenBSD- current for PS/2 mices. @@ -177,6 +187,38 @@ in /etc/sysctl.conf. +Some drivers need a patch to the aperture driver in the kernel to work cor- +rectly with int10 support. If you get warning from xf86ReadBIOS like this +one: + + (II) checkDevMem: using aperture driver /dev/xf86 + (WW) xf86ReadBIOS: /dev/mem mmap[s=600,a=0,o=0] failed (Invalid argument) + +you should patch your kernel and rebuild it. Until it's integrated in +OpenBSD-current, or a better fix is found, the patch is available at +ftp://ftp.laas.fr/pub/ii/matthieu/OpenBSD/patch-kernel-xf4. + +I've also included it below, if you want to edit the source file by hand. + + Index: sys/arch/i386/i386/mem.c + =================================================================== + RCS file: /cvs/src/sys/arch/i386/i386/mem.c,v + retrieving revision 1.14 + diff -u -r1.14 mem.c + --- sys/arch/i386/i386/mem.c 1999/11/20 11:11:28 1.14 + +++ sys/arch/i386/i386/mem.c 2000/11/13 10:54:22 + @@ -269,8 +269,8 @@ + /* minor device 4 is aperture driver */ + case 4: + if (allowaperture && + - (((off >= VGA_START && off <= BIOS_END) || + - (unsigned)off > (unsigned)ctob(physmem)))) + + (off <= BIOS_END || + + (unsigned)off > (unsigned)ctob(physmem))) + return i386_btop(off); + else + return -1; + Another (less recommended) way to enable linear memory and I/O ports access is to disable the kernel security feature by adding ``option INSECURE'' in your kernel configuration file and build a new kernel. You will also need to @@ -216,7 +258,7 @@ 8.1 Console drivers XFree86 has a configuration option to select the console drivers to use in -xf86site.def: +host.def: o if you're using pccons only put: @@ -225,9 +267,17 @@ o if you're using pcvt only put: #define XFree86ConsoleDefines -DPCVT_SUPPORT + +If you don't define XFree86ConsoleDefines in host.def the pccons and pcvt +drivers will be supported by default. + +Experimental native support for the wscons console driver found on +OpenBSD/powerpc and on OpenBSD/i386 -current can be built by adding: + + #define XFree86ConsoleDefines -DWSCONS_SUPPORT -If you don't define XFree86ConsoleDefines in xf86site.def the pccons and pcvt -drivers will be supported. +to xc/config/host.def before rebuilding the server. This has not been thor- +oughly tested, except on the macppc. 8.2 Building on other architectures @@ -248,7 +298,7 @@ particular, David Dawes, Pace Willison, Amancio Hasty, Christoph Robitschko, Nate Williams, Rod Grimes, Jack Velte and Michael Smith. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.11 2000/07/02 02:35:27 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.15 2000/12/12 18:54:29 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD,v 1.13 2000/07/02 02:46:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD,v 1.20 2000/12/12 19:04:02 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.SiS diff -u xc/programs/Xserver/hw/xfree86/doc/README.SiS:3.15 xc/programs/Xserver/hw/xfree86/doc/README.SiS:3.16 --- xc/programs/Xserver/hw/xfree86/doc/README.SiS:3.15 Sat Jun 17 13:44:21 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.SiS Fri Dec 1 14:47:48 2000 @@ -113,4 +113,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/SiS.sgml,v 3.7 2000/03/06 22:59:24 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.SiS,v 3.15 2000/06/17 17:44:21 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.SiS,v 3.16 2000/12/01 19:47:48 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.apm diff -u xc/programs/Xserver/hw/xfree86/doc/README.apm:1.7 xc/programs/Xserver/hw/xfree86/doc/README.apm:1.8 --- xc/programs/Xserver/hw/xfree86/doc/README.apm:1.7 Sat Jun 17 13:44:21 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.apm Fri Dec 1 14:47:48 2000 @@ -111,4 +111,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/apm.sgml,v 1.3 2000/03/08 05:38:43 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.apm,v 1.7 2000/06/17 17:44:21 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.apm,v 1.8 2000/12/01 19:47:48 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.ati diff -u xc/programs/Xserver/hw/xfree86/doc/README.ati:3.49 xc/programs/Xserver/hw/xfree86/doc/README.ati:3.53 --- xc/programs/Xserver/hw/xfree86/doc/README.ati:3.49 Mon Jun 19 11:12:28 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.ati Thu Dec 7 10:48:14 2000 @@ -2,7 +2,7 @@ Marc Aurele La France - 2000 June 15 + 2000 December 6 Abstract @@ -80,9 +80,11 @@ The driver also supports 32K, 64K and 16M-colour modes on the 264xT and 3D Rage series of adapters using the accelerator CRTC (but not the VGA CRTC). -The newer Rage 128 chips are not yet supported by this driver. Rage 128's -are, however, supported by a separate driver, and Rage 128 owners should read -the r128 driver's documentation for details. +The newer Rage 128 and Radeon chips are not yet supported by this driver. +Rage 128's and Radeon's are, however, supported by separate drivers, and own- +ers of such adapters should consult the documentation provided with these +drivers. This driver will also invoke the appropriate driver if it finds +Rage 128 and/or Radeon adapter(s) in the system. Adapters based on the above chips have been marketed under a rather large number of names over the years. Among them are: @@ -135,16 +137,20 @@ non-PCI adapters) enable it or move it to some other address. By default, the driver provides some acceleration for Mach64 if the accelera- -tor CRTC is used. This support is as yet incomplete and can be disabled -entirely with an XF86Config option. +tor CRTC is used, and modes whose colour depth greater than or equal to 8 are +to be used. This support is as yet incomplete and can be disabled entirely +with an XF86Config option. +On non-Intel platforms, the driver can, currently, only support PCI Mach64 +adapters. + 4. Current implementation of generic VGA support for non-ATI adapters Support for generic VGA with non-ATI adapters is also implemented, but has undergone only limited testing. The driver will intentionally disallow the use of this support with ATI adapters. This support must be explicitly requested through an XF86Config ChipSet specification. This prevents the -current generic driver from being disabled. +current VGA generic driver from being disabled. This driver's generic VGA support is intended as an extension of that pro- vided by the current generic driver. Specifically, within the architectural @@ -223,6 +229,9 @@ fore, only be used when there is in fact such an adapter in the system. They are otherwise equivalent to ``ati''. +On non-Intel platforms, only ``ati'' and ``mach64'' ChipSet values are opera- +tive. + 5.3 ChipID & ChipRev specifications These specifications will cause the driver to associate the ``Device'' sec- @@ -375,7 +384,7 @@ 25.000 27.500 31.500 33.750 10.000 11.225 12.500 16.250 VGAWonder VLB, VGA 1024 VLB, Mach32 and Mach64 owners should only specify up -to the first 32 frequencies. +to the first 32 frequencies. Any more will be ignored. Other clock generators that have been used on ATI adapters (which can all be said to be clones of one of the above) might generate non-zero frequencies @@ -398,10 +407,9 @@ This specification is only effective when the driver detects that the adapter's BIOS has initialised both the digital flat panel and CRT inter- -faces. In such a situation, the driver will normally drive the panel and -disable the CRT. This specification causes the driver to disable the digital -flat panel and display the screen image on the CRT instead. This specifica- -tion will be reworked in the near future. +faces. In such a situation, the driver will normally drive both the panel +and the CRT. This specification causes the driver to disable the digital +flat panel and display the screen image on the CRT instead. 5.8 Option ``noaccel'' @@ -417,6 +425,9 @@ CRTC or an integrated Mach64 graphics chip. This option disables this linear aperture. +On non-Intel platforms, the driver requires a linear aperture and, so, this +option should not be specified. + 5.10 Option ``shadowfb'' If this option is enabled, the driver will cause the CPU to do each drawing @@ -459,6 +470,26 @@ requirements of most devices in the system. This means the driver can not easily change the linear aperture address. +5.14 Option ``ReferenceClock'' ``frequency'' + +This option is only applicable to non-Intel platforms, where an adapter BIOS +is not available to the driver. The option specifies the reference frequency +used by the adapter's clock generator. The default is 14.318 MHz, and other +typical values are 28.636, or 29.5 MHz. + +5.15 ClockChip ``name'' + +This option is only applicable to non-Intel platforms, where an adapter BIOS +is not available to the driver, and the driver cannot reliably determine +whether the clock generator the adapter uses is a variant of an ATI 18818 +(a.k.a. ICS 2595) or an unsupported clock generator. The only values that +are acted upon are ``ATI 18818-0'' or ``ATI 18818-1''. From this specifica- +tion, the driver derives a reference divider of 43 or 46 (respectively) for +use in clock programming calculations. The driver's default behaviour, in +this case, is to assume an unsupported clock generator, which means it will +treat it as a fixed-frequency clock generator, as described under the heading +``Clocks for unsupported programmable clock generators'' above. + 6. Video modes Mode timings can be derived from the information in XFree86's doc subdirec- @@ -638,8 +669,11 @@ Version 5 is an almost complete restructuring of version 4 to fit in the newer driver API of XFree86 4.0 and later. + +The introduction of version 6 is a first swipe at porting the driver to non- +Intel architectures. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.31 2000/06/19 15:00:54 tsi Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.34 2000/12/07 15:43:41 tsi Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.ati,v 3.49 2000/06/19 15:12:28 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.ati,v 3.53 2000/12/07 15:48:14 tsi Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.chips diff -u xc/programs/Xserver/hw/xfree86/doc/README.chips:3.32 xc/programs/Xserver/hw/xfree86/doc/README.chips:3.35 --- xc/programs/Xserver/hw/xfree86/doc/README.chips:3.32 Sat Jun 17 13:44:21 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.chips Mon Dec 4 14:47:24 2000 @@ -7,7 +7,7 @@ 1. Introduction -With the release of XFree86 version 4.0.1, the Chips and Technologies driver +With the release of XFree86 version 4.0.2, the Chips and Technologies driver has been extensively rewritten and contains many new features. This driver must be considered work in progress, and those users wanting stability are encouraged to use the older XFree86 3.3.x versions. However this version of @@ -277,19 +277,19 @@ allows the user to select a different clock for the server to use when returning to the text console. - Option "FPClock8" "65.0" - Option "FPClock16" "65.0" Option "FPClock24" "65.0" Option - "FPClock32" "65.0"" In general the LCD panel clock should be set - independently of the modelines supplied. Normally the chips BIOS - set the flat panel clock correctly and so the default behaviour - with HiQV chipset is to leave the flat panel clock alone, or - force it to be 90% of the maximum allowable clock if the current - panel clock exceeds the dotclock limitation due to a depth - change. This option allows the user to force the server the - reprogram the flat panel clock independently of the modeline with - HiQV chipset. The four options are for 8bpp or less, 16, 24 or - 32bpp LCD panel clocks, where the options above set the clocks to - 65MHz. + Option "FPClock8" "65.0MHz" + Option "FPClock16" "65.0MHz" Option "FPClock24" "65.0MHz" + Option "FPClock32" "65.0MHz"" In general the LCD panel clock + should be set independently of the modelines supplied. Normally + the chips BIOS set the flat panel clock correctly and so the + default behaviour with HiQV chipset is to leave the flat panel + clock alone, or force it to be 90% of the maximum allowable clock + if the current panel clock exceeds the dotclock limitation due to + a depth change. This option allows the user to force the server + the reprogram the flat panel clock independently of the modeline + with HiQV chipset. The four options are for 8bpp or less, 16, 24 + or 32bpp LCD panel clocks, where the options above set the clocks + to 65MHz. Option "MMIO" This has a different effect depending on the hardware on which it @@ -369,6 +369,14 @@ improved. Because the rendering is all done into a virtual frame- buffer acceleration can not be used. + Option "NoTMED" + The new TMED DSTN dithering scheme available on recent HiQV + chipsets gives improved performance. However, some machines + appear to have this feature incorrectly setup. If you have snow + on your DSTN LCD, try using this option. This option is only rel- + evant for chipsets more recent than the ct65555 and only when + used with a DSTN LCD. + Option "Overlay" The HiQV chipsets contain a multimedia engine that allow a 16bpp window to be overlayed on the screen. This driver uses this capa- @@ -795,6 +803,16 @@ colour depths. However, 8 and 24 bit colour depths seem to work fine. + My ct69030 machine locks up when starting XFree + The ct69030 chipset introduced a new dual channel architecture. + In its current form, XFree can not take advantage of this second + display channel. In fact if the video BIOS on the machine sets + the ct69030 to a dual channel mode by default, XFree will lockup + hard at this point. The solution is to use the BIOS setup to + change to a single display channel mode, ensuring that both the + IOSS and MSS registers are set to a single channel mode. Work is + underway to fix this. + I can't start X-windows with 16, 24 or 32bpp Firstly, is your machine capable of 16/24/32bpp with the mode specified. Many LCD displays are incapable of using a 24bpp mode. @@ -811,7 +829,7 @@ startx -- -depth 24 -fbbpp 32 8-8-8 RGB truecolor - however as XFree86 version 4.0.1 allows 32bpp pixmaps to be used + however as XFree86 version 4.0.2 allows 32bpp pixmaps to be used with framebuffers operating in 24bpp, this mode of operating will cost performance for no gain in functionality. @@ -881,7 +899,7 @@ We also thank the many people on the net who have contributed by reporting bugs and extensively testing this server. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.31 2000/06/14 01:43:49 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.33 2000/12/02 21:52:22 dbateman Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.32 2000/06/17 17:44:21 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.35 2000/12/04 19:47:24 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.cyrix diff -u xc/programs/Xserver/hw/xfree86/doc/README.cyrix:1.7 xc/programs/Xserver/hw/xfree86/doc/README.cyrix:1.8 --- xc/programs/Xserver/hw/xfree86/doc/README.cyrix:1.7 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.cyrix Fri Dec 1 14:47:49 2000 @@ -50,4 +50,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/cyrix.sgml,v 1.3 2000/03/08 05:38:43 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.cyrix,v 1.7 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.cyrix,v 1.8 2000/12/01 19:47:49 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.fonts diff -u xc/programs/Xserver/hw/xfree86/doc/README.fonts:1.10 xc/programs/Xserver/hw/xfree86/doc/README.fonts:1.15 --- xc/programs/Xserver/hw/xfree86/doc/README.fonts:1.10 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.fonts Fri Dec 15 15:22:16 2000 @@ -1,195 +1,449 @@ Fonts in XFree86 - Juliusz Chroboczek, Juliusz.Chroboczek@ens.fr + Juliusz Chroboczek, - 5 March 2000 + 14 December 2000 -XFree86 contains a number of improvements related to fonts, including +1. Introduction - o inclusion of new fonts; +This document describes the support for fonts in XFree86. Section Installing +fonts (section 2., page 1) is aimed at the casual user wishing to install +fonts in the X server; the rest of the document describes the font support in +more detail. - o internationalisation of the scalable font backends (Type 1, Speedo, and - TrueType); +We only describe font support within the core X protocol. Issues relating to +fonts within the RENDER extension, the GLX (OpenGL) extension or the PEX +extension are outside the scope of this document. - o support for TrueType fonts; +We assume some familiarity with digital fonts. If anything is not clear to +you, please consult Appendix Background (section 6., page 1) at the end of +this document for background information. - o support for CID-keyed fonts. +2. Installing fonts -This document describes these improvements. It does not attempt to describe -the standard support for fonts in X11; the reader is referred to the X(1), -Xserver(1), and mkfontdir(1) manpages. +Installing fonts in XFree86 is a two step process. First, you need to create +a font directory that contains all the relevant font files as well as some +index files. You then need to inform the X server of the existence of this +new directory by including it in the font path. -1. Background and terminology +2.1 Installing bitmap fonts -1.1 Characters and glyphs +The XFree86 server can use bitmap fonts in both the cross-platform BDF format +and the somewhat more efficient binary PCF format. (XFree86 also supports +the obsolete SNF format.) -A character is an abstract unit of a writing system. Examples of characters -include the Latin capital letter A, the Arabic letter jim, and the dingbat -black scissors. +Bitmap fonts are normally distributed in the BDF format. Before installing +such fonts, it is desirable (but not absolutely necessary) to convert the +font files to the PCF format. This is done by using the command `bdftopcf', +e.g. -A glyph is a shape that may represent one or many characters when displayed -by a window system or printed by a printer. + $ bdftopcf courier12.bdf -While glyphs roughly correspond to characters in most cases, this correspon- -dence is not, in general, one to one. For example, a font may have many vari- -ant forms of the capital letter A; a single fi ligature may correspond to the -letters f and i. +You may then want to compress the resulting PCF font files: -A coded character set is a set of characters together with a mapping from -integer codes -- known as codepoints -- to characters. Examples of coded -character sets include US-ASCII, ISO 8859-1, KOI8-R, and JIS X 0208(1990). + $ gzip courier12.pcf -A coded character set need not use 8-bit integers to index characters. Many -early mainframes used 6-bit character sets, while 16-bit (or more) character -sets are necessary for ideographic writing systems. +After the fonts have been converted, you should copy all the font files that +you wish to make available into a arbitrary directory, say +`/usr/local/share/fonts/bitmap/'. You should then create the index file +`fonts.dir' by running the command `mkfontdir' (please see the mkfontdir(1) +manual page for more information): -1.2 Font files, fonts, and XLFD + $ mkdir /usr/local/share/fonts/bitmap + $ cp *.pcf.gz /usr/local/share/fonts/bitmap + $ cd /usr/local/share/fonts/bitmap + $ mkfontdir -Traditionally, typographers speak about typefaces and founts (we use the tra- -ditional British spelling to distinguish founts from digital fonts). A type- -face is a particular style or design, such as Times Italic, while a fount is -a molten-lead incarnation of a given typeface at a given size. +All that remains is to tell the X server about the existence of the new font +directory; see Section Setting the server font path (section 2.4, page 1). -Digital fonts come in font files. A font file contains all the information -necessary for generating glyphs of a given typeface, and applications using -font files may access glyph information in arbitrary order. +2.2 Installing scalable fonts -Digital fonts may consist of bitmap data, in which case they are said to be -bitmap fonts. They may also consist of a mathematical description of glyph -shapes, in which case they are said to be scalable fonts. Common formats for -scalable font files are Type 1 (sometimes incorrectly called ATM fonts or -PostScript fonts), Speedo and TrueType. +The XFree86 server supports scalable fonts in four formats: Type 1, Speedo, +TrueType and CIDFont. This section only applies to the former three; for +information on CIDFonts, please see Section Installing CIDFonts (section 2.3, +page 1) later in this document. -The glyph data in a digital font needs to be indexed somehow. How this is -done depends on the font file format. In the case of Type 1 fonts, glyphs -are identified by glyph names. In the case of TrueType fonts, glyphs are -indexed by integers corresponding to one of a number of indexing schemes -(usually Unicode --- see below). +Installing scalable fonts is very similar to installing bitmap fonts: you +create a directory with the font files, and run `mkfontdir' to create an +index file called `fonts.dir'. -The X11 system uses the data in font file to generate font instances, which -are collections of glyphs at a given size indexed according to a given encod- -ing. X11 font instances are specified using a notation known as the X Logi- -cal Font Description (XLFD). An XLFD starts with a dash `-', and consists of -fourteen fields separated by dashes, for example +There is, however, a big difference: `mkfontdir' cannot automatically recog- +nise scalable font files. For that reason, you must first index all the font +files in a file called `fonts.scale'. This file has the same format as a +`fonts.dir' file, and typically looks as follows: - -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 + 4 + cour.pfa -adobe-courier-medium-r-normal-0-0-0-0-p-0-iso8859-1 + cour.pfa -adobe-courier-medium-r-normal-0-0-0-0-p-0-iso8859-2 + couri.pfa -adobe-courier-medium-i-normal-0-0-0-0-p-0-iso8859-1 + couri.pfa -adobe-courier-medium-i-normal-0-0-0-0-p-0-iso8859-2 -Or particular interest are the last two fields `iso8859-1', which specify the -font instance's encoding. +The first line indicates the number of entries in the file. Each line after +the first consists of two fields separated by a space; the first field is the +name of the font file, and the second one is the name under which the font +will appear to the server. This name should obey the X Logical Font Descrip- +tion conventions (see Section The X Logical Font Description (section 6.2, +page 1)). The format of this file is fully described in the mkfontdir(1) +manual page. -1.3 Unicode +Note that multiple lines may point at the same font file. This is most com- +monly done in order to make a single font available under multiple encodings; +please see Section Fonts and internationalisation (section 4., page 1). -Unicode () is a coded character set with the goal -of uniquely identifying all characters for all scripts, current and histori- -cal. While Unicode was explicitly not designed as a glyph encoding scheme, -it is often possible to use it as such. +While it is possible to create the `fonts.scale' file by hand, it is simpler +and more convenient to have it generated automatically. Utilities to perform +this task are available, but are not currently included with XFree86. For +Type 1 fonts, you may use a utility called `type1inst' which is available +from standard Free Software repositories throughout the world. -Unicode is an open character set, in that codepoint assignments may be added -to Unicode at any time (once specified, though, an assignment can never be -changed). For this reason, a Unicode font will be sparse, and only define -glyphs for a subset of the character registry of Unicode. +For TrueType fonts, you may use `ttmkfdir', available from Joerg Pommnitz's +xfsft page . -The Unicode standard is defined in parallel with ISO 10646. Assignments in -the two standards are always equivalent, and this document uses the terms -``Unicode'' and ``ISO 10646'' interchangeably. +After the `fonts.scale' is created, you may run `mkfontdir' as above; this +time, however, you need to create an index of encoding files called `encod- +ings.dir' in addition to the `fonts.dir' file. This is done by using +`mkfontdir' with the `-e' flag: -When used in X11, Unicode-encoded fonts should have the last two fields of -their XLFD set to `iso10646-1'. + $ cd /usr/local/share/fonts/Type1 + $ mkfontdir -e /usr/X11R6/lib/font/encodings -2. New fonts +For more information, please see the mkfontdir(1) manual page and Section +Fonts and internationalisation (section 4., page 1) later in this document. -2.1 Bitmap fonts +2.3 Installing CID-keyed fonts -XFree86 includes two new Unicode-encoded fonts with a large collection of -non-ideographic glyphs. While it is possible to use these fonts as main -fonts, applications may also use them as fallbacks when a given glyph is not -available in the current font. +The CID-keyed font format was designed by Adobe Systems for fonts with large +character sets. A CID-keyed font, or CIDFont for short, contains a collec- +tion of glyphs indexed by character ID (CID). -2.1.1 The Unicode `fixed' font +Adobe make some sample CIDFonts and a complete set of CMaps available from +O'Reilly's FTP site . + +In order to map such glyphs to meaningful indices, Adobe provide a set of +CMap files. The PostScript name of a font generated from a CIDFont consists +of the name of the CIDFont and the name of the CMap separated by two dashes. +For example, the font generated from the CIDFont `Munhwa-Regular' using the +CMap `UniKS-UCS2-H' is called + + Munhwa-Regular--UniKS-UCS2-H + +The CIDFont support in XFree86 requires a very rigid directory structure. +The main directory must be called `CID' (its location defaults to +`/usr/X11R6/lib/X11/fonts/CID' but it may be located anywhere), and it should +contain a subdirectory for every CID collection. Every subdirectory must +contain subdirectories called CIDFont (containing the actual CIDFont files), +CMap (containing all the needed CMaps), AFM (containing the font metric +files) and CFM (initially empty). For example, in the case of the font +Munhwa-Regular that uses the CID collection Adobe-Korea1-0, the directory +structure should be as follows: -The font file + CID/Adobe-Korea1/CIDFont/Munhwa-Regular + CID/Adobe-Korea1/CMap/UniKS-UCS2-H + CID/Adobe-Korea1/AFM/Munhwa-Regular.afm + CID/Adobe-Korea1/CFM/ + CID/fonts.dir + CID/fonts.scale - /usr/X11/lib/X11/fonts/misc/6x13.pcf.gz +After creating this directory structure and copying the relevant files, you +should create a <`tt/fonts.scale/' file. This file has the same format as in +the case of (non-CID) scalable fonts, except that its first column contains +PostScript font names with the extension `.cid' appended rather than actual +filenames: -with XLFD + 1 + Adobe-Korea1/Munhwa-Regular--UniKS-UCS2-H.cid \ + -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-iso10646-1 - -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 +(both names on the same line). As above, running `mkfontdir' creates the +`fonts.dir' file: -is a Unicode-encoded version of the standard `fixed' font with added support -for the Latin, Greek, Cyrillic, Georgian, Armenian, IPA and other scripts -plus numerous technical symbols. It contains over 2800 characters, covering -all characters of ISO 8859 parts 1-5, 7-10, 13-15, as well as all European -IBM and Microsoft code pages, KOI8, WGL4, and the repertoires of many other -character sets. This font is compatible with the standard 8-bit fixed font -and therefore also includes the DEC line-drawing glyphs in the range 0x00 to -0x1F, which are not part of Unicode or ISO 10646-1. + $ cd /usr/local/share/fonts/CID + $ mkfontdir + +Finally, you should create the font metrics summary files in the directory +`CFM' by running the command `mkcfm': + + $ mkcfm /usr/local/share/fonts/CID + +If no CFM files are available, the server will still be able to use the CID +fonts but querying them will take a long time. You should run `mkcfm' again +whenever a change is made to any of the CID-keyed fonts, or when the CID- +keyed fonts are copied to a machine with a different architecture. + +2.4 Setting the server's font path + +The list of directories where the server looks for fonts is known as the font +path. Informing the server of the existence of a new font directory consists +in putting it on the font path. + +The font path is an ordered list; if a client's request matches multiple +fonts, the first one in the font path is the one that gets used. When match- +ing fonts, the server makes two passes over the font path: during the first +pass, it searches for an exact match; during the second, it searches for +fonts suitable for scaling. -An ISO 8859-1 version of this font is still available in file +For best results, scalable fonts should appear in the font path before the +bitmap fonts; this way, the server will prefer bitmap fonts to scalable fonts +when an exact match is possible, but will avoid scaling bitmap fonts when a +scalable font can be used. (The `:unscaled' hack, while still supported, +should no longer be necessary in XFree86 4.0 and later.) - /usr/X11/lib/X11/fonts/misc/6x13-ISO8859-1.pcf.gz +You may check the font path of the running server by typing the command + $ xset q + +2.4.1 Temporary modification of the font path + +The `xset' utility may be used to modify the font path for the current ses- +sion. The font path is set with the command xset fp; a new element is added +to the front with xset +fp, and added to the end with xset fp+. For example, + + $ xset +fp /usr/local/fonts/Type1 + $ xset fp+ /usr/local/fonts/bitmap + +Conversely, an element may be removed from the front of the font path with +`xset -fp', and removed from the end with `xset fp-'. + +For more information, please consult the xset(1) manual page. + +2.4.2 Permanent modification of the font path + +The default font path (the one used just after server startup) is specified +in the X server's `XF86Config' file. It is computed by appending all the +directories mentioned in the `FontPath' entries of the `Files' section in the +order in which they appear. + + FontPath "/usr/local/fonts/Type1" + ... + FontPath "/usr/local/fonts/bitmap" + +For more information, please consult the `XF86Config'(5) manual page. + +2.5 Troubleshooting + +If you seem to be unable to use some of the fonts you have installed, the +first thing to check is that the `fonts.dir' files are correct and that they +are readable by the server. If this doesn't help, it is quite possible that +you are trying to use a font in a format that is not supported by your +server. + +XFree86 supports the BDF, PCF, SNF, Type 1, Speedo, TrueType and CIDFont font +formats. However, not all XFree86 servers come with all the font backends +configured in. + +On most platforms, the XFree86 servers are modular: the font backends are +included in modules that are loaded at runtime. The modules to be loaded are +specified in the `XF86Config' file using the `Load' directive: + + Load "Type1" + +If you have trouble installing fonts in a specific format, you may want to +check the server's log file in order to see whether the relevant modules are +properly loaded. The list of font modules distributed with XFree86 is as +follows: + + o "bitmap": bitmap fonts (`*.bdf', `*.pcf' and `*.snf'); + + o "Type1": Type 1 fonts (`*.pfa' and `*.pfb') and CIDFonts; + + o "Speedo": Bitstream Speedo fonts (`*.spd'); + + o "freetype": TrueType fonts (`*.ttf' and `*.ttc'); + + o "xtt": alternate TrueType backend (`*.ttf' and `*.ttc'). + +3. Fonts included with XFree86 + +3.1 Standard bitmap fonts + +The Sample Implementation of X11 comes with a large number of bitmap fonts, +including the `fixed' family, and bitmap versions of Courier, Times and Hel- +vetica. In the SI, these fonts are provided in the ISO 8859-1 encoding (ISO +Latin Western-European). + +In XFree86, a number of these fonts are provided in Unicode-encoded font +files instead. At build time, these fonts are split into font files encoded +according to legacy encodings, a process which enables us to provide the +standard fonts in a number of regional encodings with no duplication of work. + +For example, the font file + + /usr/X11R6/lib/X11/fonts/misc/6x13.bdf + with XLFD - -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 + -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 -The standard aliases `fixed' and `6x13' still point at the ISO 8859-1 ver- -sions of the font. +is a Unicode-encoded version of the standard `fixed' font with added support +for the Latin, Greek, Cyrillic, Georgian, Armenian, IPA and other scripts +plus numerous technical symbols. It contains over 2800 glyphs, covering all +characters of ISO 8859 parts 1-5, 7-10, 13-15, as well as all European IBM +and Microsoft code pages, KOI8, WGL4, and the repertoires of many other char- +acter sets. + +This font is used at build time for generating the font files + + 6x13-ISO8859-1.bdf + 6x13-ISO8859-2.bdf + 6x13-ISO8859-3.bdf + 6x13-ISO8859-4.bdf + 6x13-ISO8859-5.bdf + 6x13-ISO8859-7.bdf + 6x13-ISO8859-8.bdf + 6x13-ISO8859-9.bdf + 6x13-ISO8859-10.bdf + 6x13-ISO8859-13.bdf + 6x13-ISO8859-15.bdf + 6x13-KOI8-R.bdf + +with respective XLFDs + + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-2 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-3 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-4 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-5 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-7 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-8 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-9 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-10 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-13 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-15 + -misc-fixed-medium-r-normal--13-120-75-75-c-60-koi8-r + +The standard short name `fixed' is normally an alias for + + -misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 + +(The conversion of the standard fonts to Unicode was mainly performed by +Markus Kuhn. Markus is a man of taste, which makes his use of Perl in the +conversion process somewhat surprising.) -2.1.2 The ClearlyU Unicode font +3.2 The ClearlyU Unicode font family -The ClearlyU font set of fonts provides a set of 12pt, 100dpi proportional +The ClearlyU family of fonts provides a set of 12 pt, 100 dpi proportional fonts with many of the glyphs needed for Unicode text. Together, the fonts -contain over 4000 glyphs. +contain approximately 7500 glyphs. -The main ClearlyU font has XLFD name +The main ClearlyU font has the XLFD - -mutt-ClearlyU-medium-r-normal--17-120-100-100-p-101-iso10646-1 + -mutt-clearlyu-medium-r-normal--17-120-100-100-p-101-iso10646-1 and resides in the font file - /usr/X11/lib/X11/fonts/misc/cu12.pcf.gz + /usr/X11R6/lib/X11/fonts/misc/cu12.pcf.gz Additional ClearlyU fonts include + + -mutt-clearlyu alternate glyphs-medium-r-normal--17-120-100-100-p-91-iso10646-1 + -mutt-clearlyu pua-medium-r-normal--17-120-100-100-p-111-iso10646-1 + -mutt-clearlyu arabic extra-medium-r-normal--17-120-100-100-p-103-fontspecific-0 + -mutt-clearlyu ligature-medium-r-normal--17-120-100-100-p-141-fontspecific-0 + +The Alternate Glyphs font contains additional glyph shapes that are needed +for certain languages. A second alternate glyph font will be provided later +for cases where a character has more than one commonly used alternate shape +(e.g. the Urdu heh). + +The PUA font contains extra glyphs that are useful for certain rendering pur- +poses. + +The Arabic Extra font contains the glyphs necessary for characters that don't +have all of their possible shapes encoded in ISO 10646. The glyphs are +roughly ordered according to the order of the characters in the ISO 10646 +standard. + +The Ligature font contains ligatures for various scripts that may be useful +for improved presentation of text. + +(The ClearlyU family was designed by Mark Leisher. Mark's usage of the +foundry name mutt predates the mailer of the same name, but he won't say +more.) + +3.3 Standard scalable fonts + +XFree86 includes all the scalable fonts distributed with X11R6. + +3.3.1 Standard Type 1 fonts + +The IBM Courier set of fonts cover ISO 8859-1 and ISO 8859-2 as well as Adobe +Standard Encoding. These fonts have XLFD + + -adobe-courier-medium-*-*--0-0-0-0-m-0-*-* - -mutt-ClearlyU Alternate Glyphs-medium-r-normal--17-120-100-100-p-91-iso10646-1 +and reside in the font files - -mutt-ClearlyU Arabic Extra-medium-r-normal--17-120-100-100-p-103-fontspecific-0 + /usr/X11R6/lib/X11/fonts/Type1/cour*.pfa - -mutt-ClearlyU Ligature-medium-r-normal--17-120-100-100-p-141-fontspecific-0 +The Adobe Utopia set of fonts only cover ISO 8859-1 as well as Adobe Standard +Encoding. These fonts have XLFD - -mutt-ClearlyU PUA-medium-r-normal--17-120-100-100-p-111-iso10646-1 + -adobe-utopia-*-*-normal--0-0-0-0-p-0-iso8859-1 -2.2 Scalable fonts +and reside in the font files -XFree86 includes the ``Lucidux'' family of Type 1 fonts. This family con- -sists of the fonts ``Lucidux Serif'', with XLFD + /usr/X11R6/lib/X11/fonts/Type1/UT*.pfa +Finally, XFree86 also comes with Type 1 versions of Bitstream Courier and +Charter. These fonts have XLFD + + -bitstream-courier-*-*-normal--0-0-0-0-m-0-iso8859-1 + -bitstream-charter-*-*-normal--0-0-0-0-p-0-iso8859-1 + +and reside in the font files + + /usr/X11R6/lib/X11/fonts/Type1/c*bt_.pfb + +3.3.2 Standard Speedo fonts + +XFree86 includes Speedo versions of the Bitstream Courier and Charter fonts. +In order to use these fonts, you should ensure that your X server is loading +the `Speedo' font backend; see Section Troubleshooting (section 2.5, page 1). + +These fonts cover all of ISO 8859-1 and almost all of ISO 8859-2. They have +XLFD name + + -bitstream-courier-*-*-normal--0-0-0-0-m-0-*-* + -bitstream-charter-*-*-normal--0-0-0-0-p-0-*-* + +and reside in the font files + + /usr/X11R6/lib/X11/fonts/Speedo/font*.spd + +3.4 The Bigelow & Holmes Lucidux family + +XFree86 includes the Lucidux family of Type 1 fonts. This family consists of +the fonts Lucidux Serif, with XLFD + -b&h-lucidux serif-medium-*-normal--*-*-*-*-p-*-*-* -``Lucidux Sans'', with XLFD +Lucidux Sans, with XLFD -b&h-lucidux sans-medium-*-normal--*-*-*-*-p-*-*-* -and ``Lucidux Mono'', with XLFD +and Lucidux Mono, with XLFD -b&h-lucidux mono-medium-*-normal--*-*-*-*-m-*-*-* Each of these fonts currently comes in Roman and oblique variants (bold vari- ants will be included in a future release) and has 337 glyphs covering the -basic ``ASCII'' glyph set, the Latin 1 glyph set, as well as the ``Extended -Latin'' glyph set. In particular, these fonts include all the glyphs needed -for ISO 8859 parts 1, 2, 3, 4, 9 and 15. +basic ASCII Unicode range, the Latin 1 range, as well as the Extended Latin +range. In particular, these fonts include all the glyphs needed for ISO 8859 +parts 1, 2, 3, 4, 9 and 15. The Lucidux fonts are original designs by Charles Bigelow and Kris Holmes. -Lucidux fonts include seriffed, sans-serif, and monospaced styles which share +Lucidux fonts include seriffed, sans serif, and monospaced styles that share the same stem weight, x-height, capital height, ascent and descent. Lucidux fonts harmonise with Lucida (R) fonts of the same vertical proportions and weights. The character width metrics of Lucidux roman fonts match those of core fonts bundled with several window systems. Each PFA file has a copy of the license terms in PS comment lines. The -license terms are also included in the file COPYRIGHT.BH for convenience, and -in the License document. +license terms are also included in the file `COPYRIGHT.BH' for convenience, +as well as in the License document. The design and font outlines were donated by Charles Bigelow and Kris Holmes from Bigelow and Holmes Inc., and the hinting was donated by Berthold Horn @@ -197,161 +451,157 @@ or , or consult Y&Y's web site . -3. Internationalisation of scalable font backends. +4. Fonts and internationalisation -The scalable font backends (Type 1, Speedo, TrueType) can now automatically -re-encode fonts to the encoding specified in the XLFD in `fonts.dir'. For -example, a `fonts.dir' file can now contain entries for the Type 1 Courier -font such as +The scalable font backends (Type 1, Speedo and TrueType) can now automati- +cally re-encode fonts to the encoding specified in the XLFD in fonts.dir. +For example, a fonts.dir file can contain entries for the Type 1 Courier font +such as cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 - cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-2 which will lead to the font being recoded to ISO 8859-1 and ISO 8859-2 respectively. -3.1 The `fontenc' layer +4.1 The fontenc layer -Three of the scalable backends (Type 1, Speedo, and the `freetype' TrueType -backend) use a common `fontenc' layer for font re-encoding. This allows -those backends to share their encoding data, and allows simple configuration -of new locales independently of font type. - -Please note: the X-TrueType (X-TT) backend does not use the `fontenc' layer, -but instead uses its own method for font reencoding. Readers only interested -in X-TT may want to skip to Using Symbol Fonts (section 3.5, page 1), as the -intervening information does not apply to X-TT. X-TT itself is described in -more detail in X-TrueType (section 4.1.2, page 1). - -In the `fontenc' layer, an encoding is defined by a name (such as -`iso8859-1'), eventually a number of aliases (alternate names), and an -ordered collection of mappings. A mapping defines the way the encoding can -be mapped into one of the ``target'' encodings known to the `fontenc' layer; -currently, those consist of Unicode, Adobe glyph names, and arbitrary True- -Type `cmap's. +Three of the scalable backends (Type 1, Speedo, and the FreeType TrueType +backend) use a common fontenc layer for font re-encoding. This allows these +backends to share their encoding data, and allows simple configuration of new +locales independently of font type. + +Please note: the X-TrueType (X-TT) backend does not use the fontenc layer, +but instead uses its own method for font reencoding. If you are only inter- +ested in X-TT you may want to skip to Section Using Symbol Fonts (section +4.5, page 1), as the intervening information does not apply to X-TT. X-TT +itself is described in more detail in Section X-TrueType (section 5.2, page +1). + +In the fontenc layer, an encoding is defined by a name (such as iso8859-1), +possibly a number of aliases (alternate names), and an ordered collection of +mappings. A mapping defines the way the encoding can be mapped into one of +the target encodings known to fontenc; currently, these consist of Unicode, +Adobe glyph names, and arbitrary TrueType ``cmap''s. -A number of encodings are hardwired into `fontenc', and are therefore always +A number of encodings are hardwired into fontenc, and are therefore always available; the hardcoded encodings cannot easily be redefined. These include: - o `iso10646-1': Unicode; + o iso10646-1: Unicode; - o `iso8859-1': ISO Latin-1 (Western Europe); + o iso8859-1: ISO Latin-1 (Western Europe); - o `iso8859-2': ISO Latin-2 (Eastern Europe); + o iso8859-2: ISO Latin-2 (Eastern Europe); - o `iso8859-3': ISO Latin-3 (Southern Europe); + o iso8859-3: ISO Latin-3 (Southern Europe); - o `iso8859-4': ISO Latin-4 (Northern Europe); + o iso8859-4: ISO Latin-4 (Northern Europe); - o `iso8859-5': ISO Cyrillic; + o iso8859-5: ISO Cyrillic; - o `iso8859-6': ISO Arabic; + o iso8859-6: ISO Arabic; - o `iso8859-7': ISO Greek; + o iso8859-7: ISO Greek; - o `iso8859-8': ISO Hebrew; + o iso8859-8: ISO Hebrew; - o `iso8859-9': ISO Latin-5 (Turkish); + o iso8859-9: ISO Latin-5 (Turkish); - o `iso8859-10': ISO Latin-6 (Nordic); + o iso8859-10: ISO Latin-6 (Nordic); - o `iso8859-15': ISO Latin-9, or Latin-0 (Revised Western-European); + o iso8859-15: ISO Latin-9, or Latin-0 (Revised Western-European); - o `koi8-r': KOI8 Russian; + o koi8-r: KOI8 Russian; - o `koi8-u': KOI8 Ukrainian (see RFC 2319); + o koi8-u: KOI8 Ukrainian (see RFC 2319); - o `koi8-ru': KOI8 Russian/Ukrainian + o koi8-ru: KOI8 Russian/Ukrainian - o `koi8-uni': KOI8 ``Unified'' (Russian, Ukrainian, and Byelorussian); + o koi8-uni: KOI8 ``Unified'' (Russian, Ukrainian, and Byelorussian); - o `koi8-e': KOI8 `European', ISO-IR-111, or ECMA-Cyrillic; + o koi8-e: KOI8 ``European,'' ISO-IR-111, or ECMA-Cyrillic; - o `microsoft-symbol' and `apple-roman': these are only likely to be use- - ful with TrueType symbol fonts. + o microsoft-symbol and apple-roman: these are only likely to be useful + with TrueType symbol fonts. -New encodings can be added by defining encoding files. When a font encoding -is requested that the `fontenc' layer doesn't know about, the backend checks -the directory in which the font file resides (not the directory with -`fonts.dir'!) for a file named `encodings.dir'. If found, this file is -scanned for the unknown encoding, and the requested encoding definition file -is read in. The mkfontdir(1) utility, when invoked with the `-e' option fol- -lowed by the name of a directory containing encoding files, can be used to -automatically build `encodings.dir' files. See the mkfontdir(1) manpage for -more details. +Additional encodings can be added by defining encoding files. When a font +encoding is requested that the fontenc layer doesn't know about, the backend +checks the directory in which the font file resides (not necessarily the +directory with fonts.dir!) for a file named `encodings.dir'. If found, this +file is scanned for the requested encoding, and the relevant encoding defini- +tion file is read in. The `mkfontdir' utility, when invoked with the `-e' +option followed by the name of a directory containing encoding files, can be +used to automatically build `encodings.dir' files. See the mkfontdir(1) man- +ual page for more details. -A number of predefined encoding files have been included with the distribu- -tion. Information on writing new encoding files can be found in Format of -encodings directory files (section 3.3, page 1) and Format of encodings files -(section 3.4, page 1). +A number of encoding files for common encodings are included with XFree86. +Information on writing new encoding files can be found in Section Format of +encodings directory files (section 4.3, page 1) and Format of encoding files +(section 4.4, page 1) later in this document. -3.2 Backend-specific notes about fontenc +4.2 Backend-specific notes about fontenc -3.2.1 Type 1 +4.2.1 Type 1 The Type 1 backend first searches for a mapping with a target of PostScript. -If one is found, it is used. If none is found, the backend searches for a -mapping with target Unicode, which is then composed with a built-in table -mapping codes to glyph names. Note that this table only covers part of the -Unicode code points that have been assigned names by Adobe. +If one is found, it is used. Otherwise, the backend searches for a mapping +with target Unicode, which is then composed with a built-in table mapping +codes to glyph names. Note that this table only covers part of the Unicode +code points that have been assigned names by Adobe. If neither a PostScript or Unicode mapping is found, the backend defaults to ISO 8859-1. -Specifying an encoding value of `adobe-fontspecific' disables the encoding -mechanism. This is useful with symbol and wrongly encoded fonts (see below). +Specifying an encoding value of adobe-fontspecific disables the encoding +mechanism. This is useful with symbol and incorrectly encoded fonts (see +Section Incorrectly encoded fonts (section 4.6, page 1) below). The Type 1 backend currently limits all encodings to 8-bit codes. -3.2.2 Speedo +4.2.2 Speedo The Speedo backend searches for a mapping with a target of Unicode, and uses it if found. If none is found, the backend defaults to ISO 8859-1. The Speedo backend limits all encodings to 8-bit codes. -3.2.3 The `freetype' TrueType backend +4.2.3 The FreeType TrueType backend The TrueType backend scans the mappings in order. Mappings with a target of PostScript are ignored; mappings with a TrueType or Unicode target are checked against all the cmaps in the file. The first applicable mapping is used. -Authors of encoding files to be used with the TrueType backend should ensure -that mappings are mentioned in decreasing order of preference. +If you are writing an encoding file to be used with the TrueType backend, you +should ensure that mappings are mentioned in decreasing order of preference. -3.3 Format of encodings directory files +4.3 Format of encoding directory files In order to use a font in an encoding that the font backend does not know -about, you need to have a `encodings.dir' file in the same directory as the -font file used. `encodings.dir' has the same format as `fonts.dir'. Its -first line specifies the number of encodings, while every successive line has -two columns, the name of the encoding, and the name of the encoding file; -this can be relative to the current directory, or absolute. Every encoding -name should agree with the encoding name defined in the encoding file. For -example, +about, you need to have an `encodings.dir' file in the same directory as the +font file used. The `encodings.dir' file has a similar format to +`fonts.dir'. Its first line specifies the number of encodings, while every +successive line has two columns, the name of the encoding, and the name of +the encoding file; this can be relative to the current directory, or abso- +lute. Every encoding name should agree with the encoding name defined in the +encoding file. For example, 3 - - mulearabic-0 encodings/mulearabic-0.enc - - mulearabic-1 encodings/mulearabic-1.enc - - mulearabic-2 encodings/mulearabic-2.enc + mulearabic-0 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-0.enc + mulearabic-1 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-1.enc + mulearabic-2 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-2.enc -Note that the name of an encoding must be specified in the encoding file's -STARTENCODING or ALIAS line. It is not enough to create an `encodings.dir' -entry. +The name of an encoding must be specified in the encoding file's `STARTENCOD- +ING' or `ALIAS' line. It is not enough to create an `encodings.dir' entry. If your platform supports it (it probably does), encoding files may be com- pressed or gzipped. -`encoding.dir' files are best maintained by the mkfontdir(1) utility. Please -see the mkfontdir(1) manpage for more information. +The `encoding.dir' files are best maintained by the `mkfontdir' utility. +Please see the mkfontdir(1) manual page for more information. -3.4 Format of encoding files +4.4 Format of encoding files The encoding files are ``free form,'' i.e. any string of whitespace is equiv- alent to a single space. Keywords are parsed in a non-case-sensitive manner, @@ -366,33 +616,47 @@ the line. The encoding file starts with the definition of the name of the encoding, and -eventually its alternate names (aliases): +possibly its alternate names (aliases): STARTENCODING mulearabic-0 - ALIAS arabic-0 - ALIAS something-else -The names of the encoding should be suitable for use in an XLFD font name, -and therefore contain exactly one dash `-'. +The name of the encoding and its aliases should be suitable for use in an +XLFD font name, and therefore contain exactly one dash `-'. The encoding file may then optionally declare the size of the encoding. For -a linear encoding (such as Mule Arabic, or ISO 8859-1), the SIZE line speci- -fies the maximum code plus one: +a linear encoding (such as ISO 8859-1), the SIZE line specifies the maximum +code plus one: SIZE 0x2B For a matrix encoding, it should specify two numbers. The first is the num- ber of the last row plus one, the other, the highest column number plus one. -For example, in the case of `jisx0208.1990-0' (JIS X 0208(1990), double-byte -encoding, high bit clear), it should be +In the case of `jisx0208.1990-0' (JIS X 0208(1990), double-byte encoding, +high bit clear), it should be SIZE 0x75 0x80 -Codes outside the region defined by the size line are supposed to be unde- -fined. Encodings default to linear encoding with a size of 256 (0x100). -This means that you must declare the size of all 16 bit encodings. +In the case of a matrix encoding, a `FIRSTINDEX' line may be included to +specify the minimum glyph index in an encoding. The keyword `FIRSTINDEX' is +followed by two integers, the minimum row number followed by the minimum col- +umn number: + + FIRSTINDEX 0x20 0x20 + +In the case of a linear encoding, a `FIRSTINDEX' line is not very useful. If +for some reason however you chose to include on, it should be followed by a +single integer. + +Note that in most font backends inclusion of a `FIRSTINDEX' line has the side +effect of disabling default glyph generation, and this keyword should there- +fore be avoided unless absolutely necessary. + +Codes outside the region defined by the `SIZE' and `FIRSTINDEX' lines are +understood to be undefined. Encodings default to linear encoding with a size +of 256 (0x100). This means that you must declare the size of all 16 bit +encodings. What follows is one or more mapping sections. A mapping section starts with a `STARTMAPPING' line stating the target of the mapping. The target may be @@ -402,11 +666,11 @@ STARTMAPPING unicode - o a given TrueType `cmap': + o a given TrueType ``cmap'': STARTMAPPING cmap 3 1 - o PostScript glyph names + o PostScript glyph names: STARTMAPPING postscript @@ -415,15 +679,13 @@ codes are mapped to codes: 0x21 0x0660 - 0x22 0x0661 - ... As an abbreviation, it is possible to map a contiguous range of codes in a single line. A line consisting of three integers - start end target + ) and has +support for the ``fontenc'' style of internationalisation (see Section The +fontenc layer (section 4.1, page 1)). This backend supports TrueType Font +files (`*.ttf') and TrueType Collections (`*.ttc'). In order to access the faces in a TrueType Collection file, the face number must be specified in the fonts.dir file before the filename within colons. @@ -618,8 +853,13 @@ refers to face 2 in the `mincho.ttc' TrueType Collection file. -4.1.2 The `X-TrueType' TrueType backend +The FreeType backend uses the fontenc layer in order to support recoding of +fonts; this was described in Section The fontenc layer (section 4.1, page 1) +and especially Section FreeType-specific notes about fontenc (section 4.2.3, +page 1) earlier in this document. +5.2 The X-TrueType TrueType backend + The `X-TrueType' backend is another backend based on the FreeType library. X-TrueType doesn't use the `fontenc' layer for managing font encodings, but instead uses its own database of encodings. However, X-TrueType includes a @@ -634,142 +874,141 @@ and should be specified before the filename. The most useful TTCap option is used to specify the face number to use with -TTCs; it carries the name `fn'. This means that face 2 of font file `min- +TTCs; this is the `fn' TTCap option. For example, face 2 of font file `min- cho.ttc' is specified using: :fn=2:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 More information on the TTCap syntax, and on X-TrueType in general, may be -found on - - - -4.2 Support for CID-keyed fonts - -The CID-keyed font format was designed by Adobe Systems for fonts with large -character sets. It is described in the Adobe Technical Notes nr. 5092, -"Overview of the CID-Keyed Font Technology," nr. 5014, "CMap and CIDFont File -Format Specification," and others, available from - - - -Sample CID-keyed fonts can be found at: +found on the X-TrueType home page . - +6. Appendix: background and terminology -Support for CID-keyed fonts in XFree86 is controlled by the two switches -`BuildCID' and BuildCIDFonts. Make sure that those switches are turned on -(in the directory xc/config/cf) when XFree86 is built. By default, they -should be set to YES, unless you are building XFree86 for a small memory -footprint, in which case they should be set to NO. +6.1 Characters and glyphs -The CID-keyed font backend does not use the `fontenc' layer, but instead uses -the standard `CMap' method of recoding CID-keyed fonts. +A computer text-processing system inputs keystrokes and outputs glyphs, small +pictures that are assembled on paper or on a computer screen. Keystrokes and +glyphs do not, in general, coincide: for example, if the system does generate +ligatures, then to the two keystrokes will typically correspond a sin- +gle glyph. Similarly, if the system shapes Arabic glyphs in a reasonable +manner, then multiple different glyphs may correspond to a single keystroke. + +The complex transformation rules from keystrokes to glyphs are usually fac- +tored into two simpler transformations, going through the intermediary of +characters. You may want to think of characters as the basic unit of data +that is stored e.g. in the buffer of your text editor. While the definition +of a character is intrinsically application-specific, a number of standard- +ised collections of characters have been defined. -4.2.1 Using CID-keyed fonts - -As shown in the sample install file /usr/X11R6/lib/X11/XF86Config.eg, the -font directory CID should be specified as part of the XFree86 font path: - - FontPath "/usr/X11R6/lib/X11/fonts/CID/" - -in the `XF86Config' file. When the CID font directory is on the font path it -must contain at least the empty files fonts.dir and fonts.scale. Sample -`fonts.dir' and `fonts.scale' files, with 0 entries, are installed by -default. - -A sample CID-keyed font is provided in the file: - - test/xsuite/xtest/CID - -The test directory was given the same name as the CID font directory, because -it shows how a CID-keyed font should be installed. It contains a number of -subdirectories, and any CID font directory should have the same directory -structure. - -When installing CID-keyed fonts, the empty fonts.scale and fonts.dir files in -the directory: - - xc/fonts/scaled/CID - -should be replaced by fonts.scale and fonts.dir files with a number of -entries of the form: +A coded character set is a set of characters together with a mapping from +integer codes --- known as codepoints --- to characters. Examples of coded +character sets include US-ASCII, ISO 8859-1, KOI8-R, and JIS X 0208(1990). - 1 +A coded character set need not use 8 bit integers to index characters. Many +early mainframes used 6 bit character sets, while 16 bit (or more) character +sets are necessary for ideographic writing systems. - Adobe-Korea1/Munhwa-Regular--Adobe-Korea1-0.cid \ +6.2 Font files, fonts, and XLFD - -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-adobe.korea1-0 +Traditionally, typographers speak about typefaces and founts. A typeface is +a particular style or design, such as Times Italic, while a fount is a +molten-lead incarnation of a given typeface at a given size. -(the font file name and the XLFD name should be on the same line). Note that -the first column does not specify an actual filename; instead, it specifies -the PostScript name of the CID-keyed font, followed by the extension `.cid'. -The actual names of the files used will be derived from this PostScript name. +Digital fonts come in font files. A font file contains all the information +necessary for generating glyphs of a given typeface, and applications using +font files may access glyph information in an arbitrary order. -CID-keyed fonts are divided in groups by character collection. For example, -the Korean font: +Digital fonts may consist of bitmap data, in which case they are said to be +bitmap fonts. They may also consist of a mathematical description of glyph +shapes, in which case they are said to be scalable fonts. Common formats for +scalable font files are Type 1 (sometimes incorrectly called ATM fonts or +PostScript fonts), Speedo and TrueType. - Munhwa-Regular--Adobe-Korea1-0 +The glyph data in a digital font needs to be indexed somehow. How this is +done depends on the font file format. In the case of Type 1 fonts, glyphs +are identified by glyph names. In the case of TrueType fonts, glyphs are +indexed by integers corresponding to one of a number of indexing schemes +(usually Unicode --- see below). -is in a subdirectory `Adobe-Korea1'. +The X11 system uses the data in font file to generate font instances, which +are collections of glyphs at a given size indexed according to a given encod- +ing. -The PostScript name of a CID-keyed font consists of two parts, the CIDFont- -Name and the CMapName, separated by two dashes. For instance, in the case of -the font name +X11 font instances are usually specified using a notation known as the X Log- +ical Font Description (XLFD). An XLFD starts with a dash `-', and consists +of fourteen fields separated by dashes, for example - Munhwa-Regular--Adobe-Korea1-0 + -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 -the CIDFontName is `Munhwa-Regular' while the CMapName is `Adobe-Korea1'. +Or particular interest are the last two fields `iso8859-1', which specify the +font instance's encoding. -Each CID-keyed font consist of a CIDFont file and one or more CMap files. -The CIDFont file contains the description of each character in a font. It is -stored in the subdirectory CIDFont of the Adobe-Korea1 directory. The direc- -tory structure looks as following: +X11 font instances may also be specified by short name. Unlike an XLFD, a +short name has no structure and is simply a conventional name for a font +instance. Two short names are of particular interest, as they are handled +specially by the server, and the server will not start if font instances with +these names cannot be opened. These are `fixed', which specifies the fall- +back font to use when the requested font cannot be opened, and `cursor', +which specifies the set of glyphs to be used by the mouse pointer. - CID/Adobe-Korea1/CIDFont/Munhwa-Regular +Short names are usually implemented as aliases to XLFDs; the `fixed' and +`cursor' aliases are defined in - CID/Adobe-Korea1/CMap/Adobe-Korea1-0 + /usr/X11R6/lib/X11/font/misc/fonts.alias - CID/Adobe-Korea1/AFM/Munhwa-Regular.afm +6.3 Unicode - CID/Adobe-Korea1/CFM - CID/fonts.dir +Unicode () is a coded character set with the goal +of uniquely identifying all characters for all scripts, current and histori- +cal. While Unicode was explicitly not designed as a glyph encoding scheme, +it is often possible to use it as such. - CID/fonts.scale +Unicode is an open character set, meaning that codepoint assignments may be +added to Unicode at any time (once specified, though, an assignment can never +be changed). For this reason, a Unicode font will be sparse, and only define +glyphs for a subset of the character registry of Unicode. -The file `Munhwa-Regular.afm' is an Adobe Font Metric File (AFM). The direc- -tory `CFM' will be used for summaries of that font metric file, which will be -computed later. +The Unicode standard is defined in parallel with the international standard +ISO 10646. Assignments in the two standards are always equivalent, and this +document uses the terms Unicode and ISO 10646 interchangeably. -When the CID-keyed files are installed you can run the utility +When used in X11, Unicode-encoded fonts should have the last two fields of +their XLFD set to `iso10646-1'. - /usr/X11R6/bin/mkcfm +7. References -to create the summaries of font metric file (*.cfm), and to put them in -appropriate subdirectories. By default, the program works on the directory: +XFree86 comes with extensive documentation in the form of manual pages and +typeset documents. Before installing fonts, you really should read the +mkfontdir(1) manual page; other manual pages of interest include X(1), +Xserver(1), xset(1), xlsfonts(1) and showfont(1). In addition, you may want +to read the X Logical Font Description document, by Jim Flowers, which is +provided in the file `xc/doc/xlfd.PS.Z'. - /usr/X11R6/lib/X11/fonts/CID +The comp.fonts FAQ , which is +unfortunately no longer being maintained, contains a wealth of information +about digital fonts. -A different directory can be specified on the command line of `mkcfm.' +The xfsft home page +has been superseded by this document, and is now obsolete; you may however +still find some of the information it contains useful. Joerg Pommnitz' xfsft +page is the canonical +source for the `ttmkfdir' utility. -`mkcfm' should be run as root, as it needs to write its output to a system -directory. If the program determines that it cannot write in the designated -`CFM' subdirectories, it will display a message, and switch to current direc- -tory. +The documentation of X-TrueType is available from the X-TrueType home page +. -Unless `mkcfm' is run, opening large CID-keyed fonts will take a significant -amount of time. `mkcfm' should be run again whenever a change is made to any -of the CID-keyed fonts, or when the CID-keyed fonts are copied to a machine -with a different architecture. +A number of East-Asian CIDFonts are available from O'Reilly's FTP site +. -4.2.2 Limitations +The Unicode consortium site may be of interest. +But you are more likely to find what you need on Markus Kuhn's UTF-8 and Uni- +code FAQ . -The current version of the CID-keyed fonts backend only supports the CMaps -used for horizontal text (e.g. the CMap `KSC-EUC-H' will be used, but not -`KSC-EUC-V'). This limitation is due to the fact that the core X11 protocol -only provides support for horizontal writing. +The IANA RFC documents, available from a number of sites throughout the +world, often provide interesting information about character set issues; my +favourite is RFC 373. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml,v 1.7 2000/03/06 22:59:25 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml,v 1.11 2000/12/15 20:01:56 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.fonts,v 1.10 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.fonts,v 1.15 2000/12/15 20:22:16 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.i740 diff -u xc/programs/Xserver/hw/xfree86/doc/README.i740:1.7 xc/programs/Xserver/hw/xfree86/doc/README.i740:1.8 --- xc/programs/Xserver/hw/xfree86/doc/README.i740:1.7 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.i740 Fri Dec 1 14:47:49 2000 @@ -178,4 +178,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/i740.sgml,v 1.3 2000/03/04 00:26:30 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i740,v 1.7 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i740,v 1.8 2000/12/01 19:47:49 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.i810 diff -u xc/programs/Xserver/hw/xfree86/doc/README.i810:1.4 xc/programs/Xserver/hw/xfree86/doc/README.i810:1.5 --- xc/programs/Xserver/hw/xfree86/doc/README.i810:1.4 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.i810 Fri Dec 1 14:47:49 2000 @@ -107,4 +107,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/i810.sgml,v 1.2 2000/03/04 00:00:30 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i810,v 1.4 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i810,v 1.5 2000/12/01 19:47:49 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.isc diff -u xc/programs/Xserver/hw/xfree86/doc/README.isc:3.38 xc/programs/Xserver/hw/xfree86/doc/README.isc:3.39 --- xc/programs/Xserver/hw/xfree86/doc/README.isc:3.38 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.isc Fri Dec 1 14:47:50 2000 @@ -489,4 +489,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/isc.sgml,v 3.24 2000/03/06 22:59:25 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.isc,v 3.38 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.isc,v 3.39 2000/12/01 19:47:50 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.mouse diff -u xc/programs/Xserver/hw/xfree86/doc/README.mouse:1.10 xc/programs/Xserver/hw/xfree86/doc/README.mouse:1.11 --- xc/programs/Xserver/hw/xfree86/doc/README.mouse:1.10 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.mouse Fri Dec 1 14:47:50 2000 @@ -6,7 +6,7 @@ 1. Introduction -This document describes mouse support in XFree86 4.0.1. +This document describes mouse support in XFree86 4.0.2. Mouse configuration has often been mysterious task for novice users. How- ever, once you learn several basics, it is straightforward to write the mouse @@ -928,4 +928,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/mouse.sgml,v 1.11 2000/03/01 00:25:23 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.mouse,v 1.10 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.mouse,v 1.11 2000/12/01 19:47:50 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.newport diff -u /dev/null xc/programs/Xserver/hw/xfree86/doc/README.newport:1.2 --- /dev/null Mon Dec 18 14:29:47 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.newport Tue Dec 12 14:04:03 2000 @@ -0,0 +1,44 @@ + Information for newport Users + + Guido Guenther + + 1 August 2000 + +1. Supported Hardware + +This is an unaccelerated driver for the SGI Indy's newport cards. Both the +8bit and 24bit versions are tested and working with some limitations(see +below). The 24bit newport additionally works in 8bit mode only. + +2. Notes + + o X -configure does not generate a XF86Config file + +3. Configuration + +The following Section "Device" options are supported by the newport driver: + + o Option "bitplanes" "x" Gives the maximum number of bitplanes your card + supports (8 or 24). + +4. Authors + + o Guido Guenther + +5. Acknowledgements + + o Gleb O. Raiko for getting the beast to build + + o Ralf Baechle for his patience... + + o Ulf Carlsson for comments and the dynamic + loader code + + o Nina A. Podolskaya for dynamic loader code + + o all the guys who wrote the newport_con linux kernel code + + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/newport.sgml,v 1.2 2000/12/12 18:54:29 dawes Exp $ + + +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.newport,v 1.2 2000/12/12 19:04:03 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.r128 diff -u xc/programs/Xserver/hw/xfree86/doc/README.r128:1.12 xc/programs/Xserver/hw/xfree86/doc/README.r128:1.13 --- xc/programs/Xserver/hw/xfree86/doc/README.r128:1.12 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.r128 Fri Dec 1 14:47:51 2000 @@ -119,4 +119,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml,v 1.8 2000/06/14 00:16:09 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.r128,v 1.12 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.r128,v 1.13 2000/12/01 19:47:51 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.rendition diff -u xc/programs/Xserver/hw/xfree86/doc/README.rendition:1.11 xc/programs/Xserver/hw/xfree86/doc/README.rendition:1.12 --- xc/programs/Xserver/hw/xfree86/doc/README.rendition:1.11 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.rendition Fri Dec 1 14:47:51 2000 @@ -145,4 +145,4 @@ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml,v 1.12 2000/06/17 02:30:33 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.rendition,v 1.11 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.rendition,v 1.12 2000/12/01 19:47:51 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/README.s3virge diff -u xc/programs/Xserver/hw/xfree86/doc/README.s3virge:1.5 xc/programs/Xserver/hw/xfree86/doc/README.s3virge:1.6 --- xc/programs/Xserver/hw/xfree86/doc/README.s3virge:1.5 Sat Jun 17 13:44:22 2000 +++ xc/programs/Xserver/hw/xfree86/doc/README.s3virge Fri Dec 1 14:47:51 2000 @@ -6,11 +6,12 @@ 1. Supported hardware -The s3virge driver in XFree86 4.0.1 supports the S3 ViRGE, ViRGE DX, GX, MX, +The s3virge driver in XFree86 4.0.2 supports the S3 ViRGE, ViRGE DX, GX, MX, MX+, and VX chipsets. A majority of testing is done on ViRGE DX chips, mak- -ing them the most stable to date. This release has improved support for 24 -bit color depths and resolves all the known issues with Netscape and other -applications supporting 24 bit color. +ing them the most stable to date. This release has improved support for +ViRGE GX2 stability, XVideo support for ViRGE DX (tested) and ViRGE +(untested) in depth 16 and 24, conversion to fb framebuffer rendering, and +support for the new Render extension (untested). This driver is moderately stable, however please use caution with any new install. Please report any problems to using the @@ -59,7 +60,7 @@ o Kevin Brosius - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml,v 1.2 1999/07/10 12:17:25 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml,v 1.3 2000/11/28 20:59:17 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.s3virge,v 1.5 2000/06/17 17:44:22 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.s3virge,v 1.6 2000/12/01 19:47:51 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/RELNOTES diff -u xc/programs/Xserver/hw/xfree86/doc/RELNOTES:3.84 xc/programs/Xserver/hw/xfree86/doc/RELNOTES:3.96 --- xc/programs/Xserver/hw/xfree86/doc/RELNOTES:3.84 Sat Jul 1 22:46:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/RELNOTES Mon Dec 18 00:55:38 2000 @@ -1,196 +1,384 @@ - Release Notes for XFree86[tm] 4.0.1 + Release Notes for XFree86[tm] 4.0.2 The XFree86 Project, Inc - 30 June 2000 + 17 December 2000 Abstract This document contains some information about the features present - in XFree86 4.0.1 and their status. + in XFree86 4.0.2 and their status. 1. Introduction to the 4.x Release Series -XFree86 4.0 was the first official release of the new XFree86 4. XFree86 4 -represents a significant redesign of the XFree86 X server. Not all of the -hardware drivers from 3.3.x have been ported to 4.x yet. - -1.1 Differences Between the 4.x series and the 3.3 series - -The 4.x release series is also missing a nice configuration tool. This means -that configuring the Xserver might be trickier than usual. The second point -is that is that your hardware might not be supported by 4.0.1, or it might be -supported at a lesser level (conversely, some hardware is better supported in -4.0.1). We've attempted to provide some information about the second point -in our Driver Status document. Please check there first before downloading -4.0.1. - -On the subject of configuration, we have updated the basic text-based tool -"xf86config" to generate config files in the format required by 4.0.1 (3.3.x -config files won't really work with 4.0.1). We're also working on some other -configuration tools, including one that is built-in to the X server. An -early version of this is included in the release, and it works well for some -hardware. To try it out, just run (as root) "XFree86 -configure". Both of -these configuration options will give you a reasonable starting point for a -suitable configuration file. We've put some effort into documenting the -4.0.1 config file format, and you can find that information in the XF86Config -manual page. Check that, the driver manual pages and the related documenta- -tion for further information. - -Oh, another thing you might notice is that our documentation is rather -patchy. Most of what is present should be in reasonable shape, but there are -gaps. We thought it better to leave out docs that were very out of date -rather than providing inaccurate and misleading information. We are looking -for people to also help fill those gaps in . +XFree86 4.0 was the first official release of the new XFree86 4 series. The +current release (4.0.2) is the latest in that series. XFree86 4 represents a +significant redesign of the XFree86 X server. Not all of the hardware +drivers from 3.3.x have been ported to 4.x yet, but conversely, 4.x has some +hardware support not present in 3.3.x. Our Driver Status document summarizes +how the hardware driver support compares between 3.3.6 and 4.0.2. Please +check there first before downloading 4.0.2. + +The 4.0.1 release introduced a new graphical configuration tool, "xf86cfg", +and a text mode interface was added to it for the 4.0.2 release. It is work +in progress, but definitely worth trying out. The trusty old text-based tool +"xf86config" can also be used for generating X server config files. In addi- +tion to these tools, we've been working on a configuration tool that is +built-in to the X server. It is included in the release, and it works well +for some hardware. To try it out, just run (as root) "XFree86 -configure". +Each of these configuration options will give you a reasonable starting point +for a suitable configuration file. We've put some effort into documenting +the 4.0.2 config file format, and you can find that information in the +XF86Config manual page. Check that, the driver manual pages and the related +documentation for further information. -Finally, before you download and install the binary distributions for this +Before you go to download and install the binary distributions for this release, please have a quick read through the Installation Document. It may -save you some time. +save you some time and help you figure out which of the binary releases you +need. -The next section describes what is new in the latest version (4.0.1). The +The next section describes what is new in the latest version (4.0.2). The other sections below describe some of the new features and changes between -3.3.x and 4.0. There is a lot of new features, and we definitely don't have -enough space to cover it all here. +3.3.x and 4.0. There are lot's of new features, and we definitely don't have +enough space to cover them all here. -2. Summary of new features in 4.0.1. +2. Summary of new features in 4.0.2. 2.1 X server - o New DRI drivers for Intel i810, Matrox G400 and G200 (AGP only) and the - ATI Rage 128, and updates to the 3Dfx DRI driver, including Voodoo5 sup- - port. + o Darwin/Mac OS X is now supported and the X server runs on PowerPC. The + X server for this platform is called "Xdarwin", and its installation and + configuration is different from the "XFree86" server used on other plat- + forms. Please read the XFree86 on Darwin and Mac OS X document for fur- + ther information. - o The X server now runs on Linux/Sparc including drivers for many video - cards used on SUN hardware. + o Mesa has been updated to the 3.4 stable release. - o DRI support for the Linux/Sparc implementation that allows 3D direct - rendering with Creator3D cards. + o A driver for ATI Radeon adapters has been added. - o Fixed recently publicized security issues. + o ATI driver support for multi-head configurations and non-Intel platforms + has been improved. - o Update Mesa to the latest version. + o The ATI driver has been changed to invoke the appropriate driver for any + Rage 128 and Radeon adapters that it finds in the system. - o Xinerama updates and fixes. + o A driver (i128) for Number Nine chipsets has been added. - o Xv updates and fixes. + o A driver (savage) for S3 Savage chipsets has been added. - o Mouse support in DGA 1.0 compatibility mode should now work correctly - for most games that make use of it. + o A driver (siliconmotion) for some Silicon Motion chipsets has been + added. - o Some bugs with 8+24 overlay support have been fixed. + o The driver (ark) for Ark Logic chips has been ported to 4.x. - o Some XKEYBOARD extension problems have been fixed, including improve- - ments to the MouseKeys support. + o A VESA driver has been added. - o Add generic DGA support to the sis, neomagic and i810 drivers. + o A driver for SGI newport cards has been added (Linux/mips). - o xf86cfg, a new graphical configuration tool. + o The trident driver has lots of fixes to the CyberBlade/Blade support, + XVideo support for the Image/Blade series (although scaling doesn't work + yet on the Image series). -2.2 X libraries and clients. + o The s3virge driver has stabilized ViRGE GX2 support, includes ViRGE DX + and ViRGE support for XVideo YUV images, and various fixes. + + o The 3Dlabs (glint) driver now has Permedia3 support. + + o The SiS driver has had many updates, and XVideo support for the 630 is + included. + + o The NVIDIA (nv) driver has been updated to include support for the + GeForce2, and line acceleration has been added. Also, DDC support has + been improved, and support added for Alpha platforms (dense only). + + o The neomagic driver has had various bug fixes and extended acceleration + support. DGA support has also been added. + + o The Chips and Technologies driver (chips) has initial support for the + 69030. + + o The tseng driver has multi-head fixes and DGA support has been added. + + o Most video drivers have been converted to use the integrated "fb" frame- + buffer code instead of the old "cfb" code. + + o DRI support has been updated for the Rage 128, 3Dfx Voodoo3 and Voodoo5, + Intel i810/i815 and Matrox G400. DRI support for SiS and Sun Creator3D + is available. The DRI is now also available on Alpha platforms. + + o An input driver (citron) for Citron Infrared Touch devices has been + added. + + o An input driver (penmount) for PenMount devices has been added. + + o An input driver (digitaledge) for DigitalEdge devices has been added. + + o Big endian problems in Xinerama have been fixed. + + o The new "render" extension has been added (see below (section 4.11, page + 1)). The design has been extended in the following ways: + + o A new FillRectangles request was added. + + o The 'mask' operand was changed to allow per-channel alphas. + + Server implementation: + + o Implemented remaining code for client clip lists. + + o Fixed plenty of bugs related to text rendering. + + o Complete compositing code, except for separate alpha. + + Todo: + + o Polygons + + o Image scaling + + o Separate alpha channels + + o Support for visuals other than TrueColor. + + Drivers with render extension support include: i128, glint, ati (r128 + and radeon), chips, cirrus, mga, neomagic, nv, tdfx, trident, tseng, + vesa, s3virge. + + Acceleration for the render extension: + + o XAA infrastructure for acceleration. + + o Experimental MGA acceleration using XAA + + o kdrive (TinyX) infrastructure + + o Experimental TinyX Trident 9525DVD acceleration + + Xft library: + + o New font naming/access library. + + o Abstraction for core/Render text. + + o Uses FreeType2 rasterizer. + + o Allows anti-aliased/subpixel sampled text. + + o Gracefully falls back to core rendering. + + o Complicated font matching mechanism. + + o Uses server DPI to convert point sizes to pixel sizes, even for + core fonts. + + xterm: + + o Can use Xft, by default uses core fonts. + + o Uses new options '-fa' for family name and '-fs' for font size (in + points). + + x11perf: - o Thread safety issues have been resolved in a few places in the - libraries. Upgrading to the latest libraries is essential for multi- - threaded X applications. + o Add tests for anti-aliased, subpixel sampled and aliased fonts + using the Xft library. - o Some fatal bugs in the big font support have been fixed. Upgrading to - the latest libraries will fix this too. + xditview: - o Fixed recently publicized security issues in some of the X libraries. + o When the Xft library is build, uses Xft for all font access. - o Updates and bug fixes for some clients, including xedit, xman, xcalc, - fstobdf, xdm. + Qt, Gtk, twm: - o Fix some xfs problems. + o Qt changes available here . - o XTerm updates. These include: + o Gtk changes in process. - o Improve logfile security. + o twm hacks should never see the light of day. - o Workaround for fixed fonts which are generated from Unicode fonts: - they omit glyphs for some xterm's less-used line-drawing charac- - ters, which caused xterm to set a flag telling it to use only its - internal line-drawing characters. + o xf86cfg, a new graphical configuration tool for XFree86 4.x, and can be + used to either write the initial configuration or make customisations to + the current configuration. xf86cfg is a work in progress, and allows + configuration of: - o Limit numeric parameters of control sequences to 65535 to simplify - checks for numeric overflow. + o Specific setup of monitors, cards, keyboards and mice, as well as + adding or removing them. - o Change index into UDK list to unsigned to guard against numeric - overflow making the index negative. + o Server layout setup, allowing complex configuration of physical + monitor positions, default color depth and/or rotated monitors. - o Add limit checks to ClearInLine(), ScrnInsertChar(), Scrn- - DeleteChar() to correct potential out-of-bounds indexing. + o Mode line editor that can be used to configure multiple monitors, + and allows adding a modeline specific to a monitor directly to the + configuration file. - o Add a resource (limitResize) limiting resizing via the CSI 4 t and - CSI 8 t sequences. + o AccessX configuration interface, that provides an interface to easy + setup of most AccessX options, including: - o Ignore out-of-bounds resize requests, i.e., where sign-extension or - truncation of the parameters would occur. + o Timeout to reset controls. - o Change Sun function-keys resource name to sunFunctionKeys to work - around redefinition of the token sun by xrdb on Solaris. Simi- - larly, renamed resource sun keyboard to sunKeyboard. Change simi- - lar resource names for HP and SCO to avoid potential conflict with - xrdb symbols on other systems, as well as for consistency. + o StickyKeys, for people with disabilities that cannot press two + keys at the same time. - o Change line speed from 9600bd to 38400bd to accommodate users who - mistakenly use $TERM set to vt100, to reduce the effect of padding - associated with this terminal type. + o MouseKeys, mouse control only with the keyboard. - o Fix a problem that caused the right scrollbar to be positioned - incorrectly when re-enabling it. + o RepeatKeys, repeat rate and repeat delay. - o Fix a problem with color support that showed up on some platforms. + o SlowKeys, to avoid pressing keys accidentally, they're only + accepted if pressed for some specific amount of time. - o Modify logic for deleteIsDEL resource so it has internally 3 - states: unspecified, true and false. If unspecified, the keyboard - type determines whether the Delete key transmits [3~ or \177, - and the popup menu entry reflects the internal state. Otherwise, - the popup menu entry overrides the keyboard type. + o BounceKeys, helps avoiding multiple key presses by only + accepting a key if it is pressed only once and not pressed + again in a specific amount of time. - o Portability fixes for os390, AIX 4.2, Digital Unix 4.0 and IRIX - 6.5. + New configuration options are being worked on, as well as correcting + some of the bugs in the current options. A protocol for plugging in + external modules is also planned. +2.2 X libraries and clients. + + o Significant updates to the internationalisation support in Xlib (see + below (section 2.3, page 1)). + + o Some xfs updates, including font path verification, and new options. + + o XTerm updates. + + o New "xvinfo" client for querying the XVideo extension. + 2.3 Fonts and Internationalisation o Many of the "misc" bdf fonts have been updated and extended, and a wider - range of ISO-8859 subsets have been added. Oblique/italic versions of - some of them have also been added. + range of ISO-8859 subsets have been added. These are now auto-generated + from ISO-10646 encoded master fonts. - o The converters in Xlib have been improved and reworked. UTF-8 support - has been added. + o The ClearlyU ISO-10646 encoded fonts have been updated. - o Support for ISO-8859-13 has been added to Xlib and to the UTF-8 convert- - ers. + o Functions to read keyboard input in locale independent UTF-8 encoding + have been added to libX11: Xutf8LookupString, Xutf8ResetIC. + o Functions to output strings in locale independent UTF-8 encoding have + been added to libX11: Xutf8DrawString, Xutf8DrawImageString, Xutf8Tex- + tEscapement, Xutf8TextExtents, Xutf8TextPerCharExtents, Xutf8DrawText. + + o Functions to convert between Compound Text or locale dependent encoding + and UTF-8 have been added to libX11: Xutf8TextListToTextProperty, + Xutf8TextPropertyToTextList. The converter between Compound Text and + UTF-8 in Xlib has been improved; a round-trip conversion now correctly + converts all graphic Unicode characters back and forth. + + o libXaw now offers selected text using both selection targets, + UTF8_STRING and COMPOUND_TEXT. + + o Locales with UTF-8 encodings are now supported; but the UTF-8 displaying + facilities are not adequate yet. + o XKB keyboard definitions have been added and updated for some countries. - o Locale support for Celtic languages has been updated, and a Compose file - for ISO-8859-14 added. +2.4 Platforms -2.4 Miscellaneous + o Darwin/Mac OS X. - o Preliminary support for Linux/mips (no X servers yet). + o Greatly improved IA-64 support. - o Update support for BSD/OS. + o Improved Linux/mips support. - o Update Linux/IA64 support. + o Support has been added for more Alpha platforms under Linux. This now + includes all platforms that require sparse memory mapping. + +3. Drivers + +3.1 Video Drivers + +XFree86 4.0.2 includes the following video drivers: + ++--------------+--------------------------+----------------------------------+ +|Driver Name | Description | Further Information | ++--------------+--------------------------+----------------------------------+ +|apm | Alliance Pro Motion | README.apm | +|ark | Ark Logic | | +|ati | ATI | README.ati, README.r128, r128(4) | +|chips | Chips & Technologies | README.chips, chips(4) | +|cirrus | Cirrus Logic | | +|cyrix (*) | Cyrix MediaGX | README.cyrix | +|fbdev | Linux fbdev | fbdev(4) | +|glide | Glide2x (3Dfx) | glide(4) | +|glint | 3Dlabs, TI | glint(4) | +|i128 | Number Nine | README.I128, i128(4) | +|i740 | Intel i740 | README.i740 | +|i810 | Intel i810 | README.i810, i810(4) | +|imstt | Integrated Micro Solns | | +|mga | Matrox | mga(4) | +|neomagic | NeoMagic | neomagic(4) | +|newport (-) | SGI Newport | README.newport, newport(4) | +|nv | NVIDIA | nv(4) | +|rendition | Rendition | README.rendition, rendition(4) | +|s3virge | S3 ViRGE | README.s3virge, s3virge(4) | +|savage | S3 Savage | savage(4) | +|siliconmotion | Silicon Motion | siliconmotion(4) | +|sis | SiS | README.SiS | +|sunbw2 (+) | Sun bw2 | | +|suncg14 (+) | Sun cg14 | | +|suncg3 (+) | Sun cg3 | | +|suncg6 (+) | Sun GX and Turbo GX | | +|sunffb (+) | Sun Creator/3D, Elite 3D | | +|sunleo (+) | Sun Leo (ZX) | | +|suntcx (+) | Sun TCX | | +|tdfx | 3Dfx | | +|tga | DEC TGA | README.DECtga | +|trident | Trident | trident(4) | +|tseng | Tseng Labs | | +|vesa | VESA | vesa(4) | +|vga | Generic VGA | vga(4) | ++--------------+--------------------------+----------------------------------+ - o Support for LynxOS 3.1.0. +Drivers marked with (*) are present in a preliminary form in this release, +but are not complete and/or stable yet. + +Drivers marked with (+) are for Linux/Sparc only. + +Drivers marked with (-) are for Linux/mips only. + +Darwin/Mac OS X uses IOKit drivers and does not use the module loader drivers +listed above. Further information can be found in README.Darwin. -3. The new X server +XFree86 4.0.2 includes the following input drivers: +3.2 Input Drivers + + +------------+--------------------+---------------------+ + |Driver Name | Description | Further Information | + +------------+--------------------+---------------------+ + |acecad | AceCad | | + |citron | Citron | citron(4) | + |digitaledge | DigitalEdge | | + |dynapro | Dynapro | | + |elographics | EloGraphics | | + |keyboard | generic keyboards | keyboard(4) | + |microtouch | MicroTouch | | + |mouse | most mouse devices | mouse(4) | + |mutouch | MicroTouch | | + |penmount | PenMount | | + |spaceorb | SpaceOrb | | + |summa | SummaGraphics | | + |void | dummy device | void(4) | + |wacom | Wacom tablets | wacom(4) | + +------------+--------------------+---------------------+ + +4. Summary of XFree86 4. + Unlike XFree86 3.3.x where there are multiple X server binaries, each of -which drive different hardware, XFree86 4.0.1 has a single X server binary +which drive different hardware, XFree86 4.0.2 has a single X server binary called XFree86. This binary can either have one or more video drivers linked in statically, or, more usually, dynamically load the video drivers and other modules that are needed. -XFree86 4.0.1 has X server support for most UNIX(R) and UNIX-like operating -systems on Intel/x86 platforms, plus support for Linux on Alpha, PowerPC and -Sparc platforms. Work on support for additional architectures and operating -systems is in progress, and is planned for future releases. +XFree86 4.0.2 has X server support for most UNIX(R) and UNIX-like operating +systems on Intel/x86 platforms, plus support for Linux on Alpha, PowerPC, +IA-64, Sparc, and Mips platforms, and for Darwin on PowerPC. Work on support +for additional architectures and operating systems is in progress, and is +planned for future releases. -3.1 Loader and Modules +4.1 Loader and Modules The XFree86 X server has a built-in run-time loader, donated by Metro Link . This loader can load normal object files and @@ -206,7 +394,7 @@ the future we plan to take advantage of this to provide more frequent driver module updates in between major releases. -The loader in version 4.0.1 has support for Intel (x86), Alpha and PowerPC +The loader in version 4.0.2 has support for Intel (x86), Alpha and PowerPC platforms. It also has preliminary support for Sparc platforms. The X server makes use of modules for video drivers, X server extensions, @@ -228,7 +416,7 @@ hope to have a mechanism for signing/verifying the modules that we provide available in a future release. -3.2 Configuration File +4.2 Configuration File The X server configuration file format has been extended to handle some of the new functionality. The xf86config utility can be used to generate a @@ -357,7 +545,6 @@ Identifier "MGA 1" Driver "mga" BusID "PCI:1:0:0" - Option "PCI Retry" EndSection o The Screen sections are mostly unchanged. The old Driver keyword is no @@ -389,7 +576,7 @@ and /usr/X11R6/etc/X11 being added. The full search path details are docu- mented in the XF86Config manual page. -3.3 Command Line Options +4.3 Command Line Options The following new X server command line options have been added: @@ -500,15 +687,15 @@ This makes it possible for users to choose from multiple config files that the the sysadmin has provided. -3.4 XAA +4.4 XAA The XFree86 Acceleration Architecture (XAA) has been completely rewritten -from scratch. Most drivers implement acceleration by making use of the XAA -module. +from scratch for XFree86 4.x. Most drivers implement acceleration by making +use of the XAA module. -3.5 Multi-head +4.5 Multi-head -Some multi-head configurations are supported in this release, primarily with +Some multi-head configurations are supported in XFree86 4.x, primarily with multiple PCI/AGP cards. However, this is an area that is still being worked on, and we expect that the range of configurations for which it works well will increase in future releases. A configuration that is known to work well @@ -522,7 +709,7 @@ which card is the primary card (either by using a different PCI slot, or by changing the system BIOS's preference for the primary card). -3.6 Xinerama +4.6 Xinerama Xinerama is an X server extension that allows multiple physical screens to behave as a single screen. With traditional multi-head in X11, windows can- @@ -534,30 +721,25 @@ Xinerama is not enabled by default, and can be enabled with the +xinerama command line option for the X server. -Xinerama was included with X11R6.4. The version included in this release was +Xinerama was included with X11R6.4. The version included in XFree86 4.x was completely rewritten for improved performance and correctness. Known problems: - - o Most (all?) window managers are not Xinerama-aware, and so some opera- - tions like window placement and resizing might not behave in an ideal - way. This is an issue that needs to be dealt with in the individual - window managers, and isn't specifically an XFree86 problem. - -3.7 XVideo extension -The XVideo extension is included in this release, but nobody seems interested -in writing up some information about it. + o Most window managers are not Xinerama-aware, and so some operations like + window placement and resizing might not behave in an ideal way. This is + an issue that needs to be dealt with in the individual window managers, + and isn't specifically an XFree86 problem. + +4.7 DGA version 2 + +DGA 2.0 is included in 4.0.2, but is not implemented by all drivers. Prelim- +inary documentation for the client libraries can be found in the README.DGA +document. A good degree of backwards compatibility with version 1.0 is pro- +vided. -3.8 DGA version 2 +4.8 DDC -DGA 2.0 is nearly completed but still not implemented by all drivers. Pre- -liminary documentation for the client libraries can be found in the xc/pro- -grams/Xserver/hw/xfree86/DGA document. Some degree of backwards compatibil- -ity with version 1.0 is provided. This information is out of date. - -3.9 DDC - The VESA(R) Display Data Channel (DDC[tm]) standard allows the monitor to tell the video card (or on some cases the computer directly) about itself; particularly the supported screen resolutions and refresh rates. @@ -578,11 +760,12 @@ the X server, or by specifying appropriate screen dimensions with the "Dis- playSize" keyword in the "Monitor" section of the config file. -3.10 GLX and the Direct Rendering Infrastructure (DRI) +4.9 GLX and the Direct Rendering Infrastructure (DRI) -Precision Insight has been provided -with funding and support from Red Hat , SGI -, 3Dfx , Intel +Precision Insight (now part of the Pro- +fessional Services group at VA Linux Systems ) +was provided with funding and support from Red Hat , SGI , 3Dfx , Intel , ATI , and Matrox to integrate the GLX extension for 3D rendering in an X11 window. The 3D core rendering component is the Mesa @@ -593,21 +776,105 @@ dering Infrastructure (DRI). Direct Rendering provides a highly optimized path for sending 3D data directly to the graphics hardware. This release provides a complete implementation of direct rendering support for the 3Dfx -Banshee and Voodoo3 graphics cards. Additional direct rendering drivers will -be available for 3Dfx, Intel, ATI and Matrox boards during the second quarter -of 2000. Updated information on DRI compatible drivers can be found at the -DRI Project on SourceForge -. - -3.11 X-Video Extension (Xv) - -An XvQueryPortAttributes function has been added as well as support for XvIm- -ages. XvImages are XImages in alternate color spaces such as YUV and can be -passed to the server through shared memory segments. This allows clients to -display YUV data with high quality hardware scaling and filtering. XvImages -are only supported by the Matrox G200/G400 cards at the moment. +Banshee, Voodoo3 and Voodoo5 graphics cards, as well as the Intel i810/i815 +cards, ATI Rage 128, and Matrox G400. Updated information on DRI compatible +drivers can be found at the DRI Project on +SourceForge . + +4.10 XVideo Extension (Xv) + +The XVideo extension is supported in XFree86 4.x. An XvQueryPortAttributes +function has been added as well as support for XvImages. XvImages are XIm- +ages in alternate color spaces such as YUV and can be passed to the server +through shared memory segments. This allows clients to display YUV data with +high quality hardware scaling and filtering. + +4.11 X Rendering Extension (Render) + +The X Rendering extension provides a 2D rendering model that more closely +matches application demands and hardware capabilities. It provides a render- +ing model derived from Plan 9 based on Porter/Duff image composition rather +than binary raster operations. + +Using simple compositing operators provided by most hardware, Render can draw +anti-aliased text and geometric objects as well as perform translucent image +overlays and other image operations not possible with the core X rendering +system. + +XFree86 4.0.2 provides a partial implementation of Render sufficient for +drawing anti-aliased text and image composition. Still to be implemented are +geometric primitives and affine transformation of images. + +Unlike the core protocol, Render provides no font support for applications, +rather it allows applications to upload glyphs for display on the screen. +This allows the client greater control over text rendering and complete +access to the available font information while still providing hardware +acceleration. The Xft library provides font access for Render applications. + +4.11.1 The Xft Library + +On the client side, the Xft library provides access to fonts for applications +using the FreeType library, version 2. FreeType currently supports Type1 and +TrueType font files, a future release is expected to support BDF and PCF +files as well, so Render applications will have access to the complete range +of fonts available to core applications. One important thing to note is that +Xft uses the vertical size of the monitor to compute accurate pixel sizes for +provided point sizes; if your monitor doesn't provide accurate information +via DDC, you may want to add that information to XF86Config. + +To allow a graceful transition for applications moving from core text render- +ing to the Render extension, Xft can use either core fonts or FreeType and +the Render extension for text. By default, Xft is configured to support only +core fonts, see the section on building FreeType support for the changes +needed to add FreeType/Render fonts. + +The Xft library uses a configuration file, XftConfig, which contains informa- +tion about which directories contain font files and also provides a sophisti- +cated font aliasing mechanism. Documentation for that file is included in +the Xft man page. + +4.11.2 Building FreeType support for Xft + +XFree86 4.0.2 includes sources for FreeType version 2.0.1, but they are not +built and installed automatically. As a result, Xft is configured to provide +only core fonts by default. + +To build FreeType support for Xft, first FreeType must be built and +installed, either from the sources included in XFree86 in extras/freetype2 or +from another FreeType (version 2.0.1 or later) release. Early FreeType ver- +sion 2 releases used a different header file installation and aren't compati- +ble with XFree86. Instructions for building and installing FreeType can be +found in the INSTALL file included with the FreeType release. + +Second, XFree86 needs to know the installed location for FreeType, usually +/usr/local. Edit (or create) config/cf/host.def to include: + + #define Freetype2Dir /usr/local + +Finally, build XFree86 with "make World" from the top. + +4.11.3 Application Support For Anti-Aliased Text + +Only three applications have been modified in XFree86 4.0.2 to work with the +Render extension and the Xft and FreeType libraries to provide anti-aliased +text. Xterm, xditview and x11perf. Migration of other applications may +occur in future releases. + +By default, xterm uses core fonts through the standard core API. It has two +command line options and associated resources to direct it to use Xft +instead: + + o -fa family / .VT100.faceName: family. Selects the font family to use. + + o -fs pointsize / .VT100.faceSize: pointsize. Selects the pointsize. + +Xditview will use Xft instead of the core API by default. X11perf includes +tests to measure the performance of text rendered in three ways, anti- +aliased, anti-aliased with sub-pixel sampling and regular chunky text, but +through the Render extension, a path which has not been optimized within the +X server yet. -3.12 Other extensions +4.12 Other extensions The XFree86-Misc extension has not been fully ported to the new server archi- tecture yet. This should be completed in a future release. @@ -619,166 +886,10 @@ The new xgamma utility makes use of this feature. Compatibility with the 3.3.x version of the extension is provided. The missing parts of this exten- sion and some new features should be completed in a future release. - -3.13 Drivers - -XFree86 4.0.1 includes the following drivers: - - +------------+-------------------------------------+ - |Driver Name | Description | - +------------+-------------------------------------+ - |apm | Alliance Pro Motion | - |ati | ATI | - |chips | Chips & Technologies | - |cirrus | Cirrus Logic | - |cyrix (*) | Cyrix MediaGX | - |fbdev | Linux fbdev | - |glide | Glide2x (3Dfx) | - |glint | 3Dlabs, TI | - |i740 | Intel i740 | - |i810 | Intel i810 | - |mga | Matrox | - |neomagic | NeoMagic | - |nv | NVIDIA | - |r128 | ATI Rage 128 | - |rendition | Rendition | - |s3virge | S3 ViRGE | - |sis | SiS | - |sunbw2 (+) | Sun bw2 | - |suncg14 (+) | Sun cg14 | - |suncg3 (+) | Sun cg3 | - |suncg6 (+) | Sun GX and Turbo GX | - |sunffb (+) | Sun Creator, Creator3D and Elite 3D | - |sunleo (+) | Sun Leo (ZX) | - |suntcx (+) | Sun TCX | - |tdfx | 3Dfx | - |tga | DEC TGA | - |trident | Trident | - |tseng | Tseng Labs | - |vga | Generic VGA | - +------------+-------------------------------------+ - -Drivers marked with (*) are present in a preliminary form in this release, -but are not complete and/or stable yet. - -Drivers marked with (+) are for Linux/Sparc only. - -3.13.1 APM - -This is the driver for Alliance AT3D/AT25 and AT24 chips. There is a rather -complete support for the functions with acceleration at 8,15,16,24 and 32 -bits (limited by the chip at 24bpp). There is preliminary, still buggy, sup- -port for the AP6422 chip, which is still supported in 3.3.x servers. The Xv -driver is almost ok. The Rush extension for glide2x works, with some addi- -tions, including overlay of the result. DGA and DGA2 have been tested ok. -Further information can be found in README.apm. - -3.13.2 Chips & Technologies - -Information about the C&T driver can be found in README.chips. - -3.13.3 s3virge - -The s3virge driver is a port of the 3.3.x SVGA S3 ViRGE driver. As such it -should be as stable and functional as previous XFree86 releases. There are a -couple additional benefits included primarily due to common enhancements: - - o Depth 24 problems resolved with clients using 24/32 bpp pixmaps. - - o Our common acceleration architecture (XAA) has been re-written, as has - the ViRGE acceleration code. You should find this version has better - performance than prior releases. - - o Multi-head is reported to work. - - o The s3virge man page lists options and has configuration notes for this - release of the driver. - - o Trio 3D and Trio 3D/2X support has been added, matching the 3.3.6 - driver. - o Supports screen rotation and shadow framebuffer. +4.13 Xaw -Outstanding items not implemented or fully tested: - - o DGA support is implemented, but preliminary and untested. - -Further information can be found in README.s3virge. - -3.13.4 TGA - -The TGA driver is now accelerated and supports both 8 and 32 plane frame- -buffers. It is known to work under Linux/Alpha. Please see the -README.DECtga file for further information. - -3.13.5 Matrox - -The MGA driver supports the same range or hardware as XFree86 3.3.4, but has -a number of enhancements including multi-head support and support for (non- -destructive) overlays (8-bit + 24-bit). - -Option "overlay" when the server is started in 32bpp (-fbbpp 32) will enable -the 8+24 mode. The current implementation doesn't optimize away unnecessary -exposures yet so the performance of this option will be better in future -release. By default, the color key for the overlays is 255, but this can be -changed with the "ColorKey" option to work around problems in specific pro- -grams. Valid values for the key are 2-255. - -This release contains performance enhancements for the G400 and particularly -for the G400 MAX. It also includes XvImage support for G200/G400 chips and -improved memory autodetection support. - -Further information can be found in the mga man page. - -3.13.6 ATI - -Information about the ATI driver can be found in README.ati . -The current version is not accelerated. Acceleration support is planned for -a future release. - -3.13.7 NVIDIA - -The "nv" driver supports all Riva TNT accelerators as well as the new GeForce -and Quadro accelerators. DGA 2.0 support is included. - -Further information can be found in the nv man page. - -3.13.8 Glide - -This driver is for Voodoo 1 and Voodoo 2 boards. It runs X on top of the 3DFX -Glide API (where this is available, like for Linux). You need to have Glide -2.x installed before you can run this driver. This driver uses no hardware -acceleration (since there is no 2D acceleration in these boards) but is -rather quick anyway since the CPU renders to local RAM which is then copied -block-wise to the board. Unfortunately the Voodoo 1/2 boards are rather lim- -ited in resolution. The Voodoo 1 can do 800x600 and the Voodoo 2 can do -1024x768 at best, but still it has some use as a second head in Xinerama or -multihead mode. - -16 and 24 bpp modes are supported (24 bit in 32-bit sparse-packed mode). - -Further information about this driver can be found in the 'glide' driver man -page for XFree86. You will not get this driver running before reading this -man page. - -For Voodoo Banshee and Voodoo 3 boards or later: Please use the tdfx driver -which talks directly to the hardware and is much faster. - -3.13.9 GLINT - -The "glint" driver supports most 3Dlabs/Texas Instruments GLINT/Permedia -chips. There is a rather complete support (better than in 3.3.x) for acceler- -ation at 8, 15, 16, and 24 bit depths (limited by some chips at some depths). -8+24 overlay is supported. The Xv extension is supported for some boards. - -Further information about this driver can be found in the 'glint' driver man -page. - -4. X libraries and clients - -4.1 Xaw - -Two versions of the Xaw library are provided in this release. A version with +Two versions of the Xaw library are provided with XFree86 4.x. A version with bug fixes and a few binary compatible improvements and a new version with several new features. @@ -835,189 +946,12 @@ o Several bugs were fixed in the text code, while some code was rewritten from scratch. -4.2 Xpm +4.14 Xpm Version 3.4k of the Xpm (X pixmap) library is now integrated into XFree86. - -4.3 xterm - -New Features: - - o Support Unix98 PTY's. - - o Support Unicode using UTF-8 input and output. There are a few limita- - tions, this work is still in progress: - - o You must use the -u8 command line option to use this feature, as - well as compile with the OPT_WIDE_CHARS definition. (The feature - is compiled when using imake). - - o Input (from keyboard) and output (select/paste) are in UTF-8 form. - There is no support in Xlib for UTF-8; xterm uses a lookup table to - map keysym codes. Select/paste is done either via STRING or using - the new atom UTF8_STRING. - - o Add optional feature (resource and command-line options) to make xterm - use the PTY's sense of erase character on startup, rather than requiring - it to be \177, or set the PTY's erase character to match xterm's config- - uration. Note that while $TERMCAP is modified to reflect the actual - configuration, the terminfo kdch1 string is not. (This feature is also - in XFree86 3.3.4). - - o Revised keyboard handling, making two modes (VT220 and Sun/PC) which are - switched by popup menu. This makes the numeric keypad work as expected. - Codes sent by the backarrow and delete keys also are affected. - - o Add parameters to function key escape sequences to indicate if shift, - control or alt are set. This works for Sun/PC keyboard mode. - - o Separated command-line and menu settings for reverse video from that - done under program control. This is a problem which was introduced by - X11R6. Though correct, most users are confused by allowing the reset - command to undo the effect of the command-line -rv option. - - o Blinking cursor can be specified by resource or popup menu. - - o New control sequences for switching between normal and alternate screens - maintain separate cursor-save locations for the two screens, avoiding - incorrect cursor placement on exit from vi. - - o Support line-drawing characters when the font does not include them by - drawing them. - - o Add support for switching font sizes, by stepping through the font menu - using shifted keypad plus and minus. - - o New resource trimSelection allows xterm to trim trailing blanks from - selected lines. - - o Provide user applications a means of determining the version of xterm - for feature comparison by returning the patch number (e.g., 111) in the - secondary DA response. - - o Modify treatment of XK_Delete keysym so it transmits parameterized - VT220-style "[3~" if modifiers (shift, control alt) are given. - o Add ``cacheDoublesize'' resource to limit the caching of font informa- - tion for double-sized characters, to accommodate X terminals with lim- - ited font memory. +4.15 xedit - o Add ``metaSendsEscape'' resource, with corresponding control sequence - and menu entry. Like ``eightBitInput'', this causes xterm to send ESC - prefixing the given key, but applies to all keys and is independent of - the 8-bit/7-bit terminal setting. - - o Implement an 88-color model for systems where 256-colors cannot be allo- - cated. - - o Add support for DEC Locator control sequences for xterm. This allows - the xterm mouse to be used with applications that use the DEC Locator - sequences, such as VAX Tpu, or SMG$ based applications. - - o Implement -hold option, allowing users to retain the window after a - shell has exited. - - o Add an application resource, ``messages'' (and a corresponding -/+mesg - option) which controls the initial permission on the terminal. - - o Implement UTF-8 translation for Media Copy (print) operations. - - o Implement vt320 control sequences for Print Composed Main Display and - for Print All Pages. The latter directs xterm to print the current - screen as well as the scrollback buffer. - -Bug fixes/improvements: - - o If colorMode is enabled by default, compile-in default resources to - match the colors listed in XTerm-col.ad. - - o Deprecate DA answerback string, making it settable via a resource value - for applications which may need this. - - o Input characters which are mapped when in vt220 National Replacement - Character mode. - - o Completed support for double size characters. - - o Remove kfnd/kll/kslt strings from terminfo, because curses applications - do not necessarily return khome/kend pairs. - - o Corrected ifdef's for menus, which did not allow tek4014 to be sup- - pressed properly. - - o Improved tests for determining if xterm should use overstriking to simu- - late bold fonts. - - o Add test/demo scripts for double size characters, font switching, screen - resizing and colors. - - o Amend treatment of ALT key so that if ALT is used as a modifier in key - translations, then no parameter will be sent in escape sequences for - Sun/PC function keys. - - o Improved the ptyInitialErase logic to make it work better with a ter- - minfo library. - - o Modify treatment of line-drawing characters in UTF-8 mode so that Uni- - code values are used rather than characters 1-31 for storing the trans- - lated characters. - - o Modify translation of UTF-8 sequences to reject ``overly long'' varia- - tions. - - o Correct a case where colors were not rendered properly. This happened - when an application inserted several lines, then changed colors. If - this was done all in one write, then there would be no intervening - refresh, and the new color was applied to the pending scrolling opera- - tion which was awaiting the next refresh. - - o Corrected misspelled resource name in command-line option for HP func- - tion keys. - - o Change label on ``Sun/PC Keyboard'' popup menu entry to ``VT220 Key- - board'', since the checked state corresponds to VT220 rather than - Sun/PC. - - o Two corrections to simulation of bold font via overstriking: - - o use clipping to avoid leaving trash at end of the text, and - - o add brackets so wide-character logic does not fall-through into the - overstriking logic. - - o Modify checks for repeat-character control sequence to test the charac- - ter class against xterm's state table, rather than the isprint() macro. - - o Modify terminfo entry for ``xterm-xfree86'' to reflect modifiers for - shift and control. - - o Add several entries to termcap file to make it have the same set of - aliases as the terminfo file. - - o Scale the color values used for xterm-256color terminfo entry to - 0..1000, as expected by ncurses. - - o Change xterm-r6 terminfo definitions for F1-F4 to match program. - - o Remove obsolete documentation about modifiers which can be returned in - mouse tracking mode, and modify logic to ignore modifiers other than the - existing ones, e.g., NumLock. - - o Use free bit from obsolete shift-modifier coding of mouse tracking but- - ton events to encode buttons 4 and 5, e.g., for a wheel mouse. Move the - suggested wheel-mouse button translations into charproc.c to simplify - customization. - - o Modify warning if change-ownership of PTY fails; some configurations may - not happen to have old-style PTY's. - - o Add more information, i.e., with strerror for some system calls in the - main program which may fail due to insufficient permissions. - - o Various improvements to configure script, e.g., tests for utmp. - -4.4 xedit - Xedit have been changed to use most of the new features added to the new ver- sion of the Xaw library, and some xedit only features were added. Emacs users will find that several of the emacs key bindings work with the new version of @@ -1055,44 +989,44 @@ o C-mode: this mode is expected to be stable, and fully usable. -5. Fonts and Internationalisation +4.16 Font support -Details about the font support in this version of XFree86 can be found in the +Details about the font support in XFree86 4.x can be found in the README.fonts document. -5.1 TrueType support +4.17 TrueType support -This version of XFree86 comes with two TrueType backends, known as `xfsft' -(the "freetype" module) and `X-TrueType' (the "xtt" module). Both of these -backends are based on the FreeType library. +XFree86 4.x comes with two TrueType backends, known as `xfsft' (the +"freetype" module) and `X-TrueType' (the "xtt" module). Both of these back- +ends are based on the FreeType library. -5.2 CID font support +4.18 CID font support -Support for CID-keyed fonts is included in this version of XFree86. The CID- -keyed font format was designed by Adobe Systems -for fonts with large character sets. The CID-keyed font support in XFree86 -was donated by SGI . See the LICENSE document for a -copy of the CID Font Code Public License. +Support for CID-keyed fonts is included in XFree86 4.x. The CID-keyed font +format was designed by Adobe Systems for fonts +with large character sets. The CID-keyed font support in XFree86 was donated +by SGI . See the LICENSE document for a copy of the +CID Font Code Public License. -5.3 Internationalisation of the scalable font backends +4.19 Internationalisation of the scalable font backends -A new ``fontenc'' layer has been added to allow the scalable font backends to +XFree86 4.x has a ``fontenc'' layer to allow the scalable font backends to use a common method of font re-encoding. This re-encoding makes it possible to uses fonts in encodings other than their their native encoding. This layer is used by the Type1 and Speedo backends and the `xfsft' version of the TrueType backend. The `X-TrueType' version of the TrueType backend uses a different re-encoding method based on loadable encoding modules. -5.4 Large font optimisation +4.20 Large font optimisation The glyph metrics array, which all the X clients using a particular font have access to, is now placed in shared memory, so as to reduce redundant memory consumption. For non-local clients, the glyph metrics array is transmitted in a compressed format. -5.5 Unicode/ISO 10646 support +4.21 Unicode/ISO 10646 support -What is included: +What is included in 4.x: o All ``-misc-fixed-*'' BDF fonts are now available in the ISO10646-1 encoding and cover at least the 614 characters found in ISO @@ -1123,25 +1057,8 @@ o Both the xfsft (the "freetype" module) and the X-TrueType (the "xtt" module) TrueType font backends support Unicode-encoded fonts. -Known problems: - - o Xlib does not yet fully support UTF-8 as a locale, which means that - xterm UTF-8 keyboard support is at the moment a temporary hack. - - o Most ISO10646-1 fonts encode no characters above U+31FF. This avoids the - inefficient allocation and transmission of a >700 kB large XFontStruct - structure, which would happen if the (not very important) ligatures and - symbols above U+f000 were present. - - o ISO 10646 Level 2 combining characters are not yet supported by xterm - (will be needed for instance for Thai and IPA). - - o Switching between a half-width and full-width font pair (such as 9x18 - and 18x18ja) is not yet supported by xterm (will be needed for CJK - scripts). +4.22 Lucidux fonts from Bigelow and Holmes -5.6 Lucidux fonts from Bigelow and Holmes - XFree86 now includes the ``Lucidux'' family of professionally hinted Type 1 fonts. This family consists of the fonts ``Lucidux Serif'', ``Lucidux Sans'' and ``Lucidux Mono'' in Roman and oblique variants, and includes over 370 @@ -1152,13 +1069,11 @@ Blenda Horn from Y&Y, Inc. For more information, please contact or , or consult Y&Y's web site . - -6. Miscellaneous -6.1 Directory rearrangements +4.23 Directory rearrangements Some changes to the installed XFree86 directory structure have been imple- -mented for 4.0. One important change is a modified search path for the X +mented for 4.x. One important change is a modified search path for the X server's XF86Config file. The details of this can be found in the XF86Config manual page. The other main change is moving most of the run-time configura- tion files to /etc/X11, with symbolic links in the old /usr/X11R6/lib/X11 @@ -1166,7 +1081,7 @@ located under the appropriate subdirectories of /var, again with the relevant symbolic links in the old location. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.41 2000/07/02 02:35:27 dawes Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.58 2000/12/17 23:01:10 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/RELNOTES,v 3.84 2000/07/02 02:46:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/RELNOTES,v 3.96 2000/12/18 05:55:38 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/Status diff -u xc/programs/Xserver/hw/xfree86/doc/Status:1.13 xc/programs/Xserver/hw/xfree86/doc/Status:1.21 --- xc/programs/Xserver/hw/xfree86/doc/Status:1.13 Mon Jun 19 11:12:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/Status Thu Dec 14 17:34:26 2000 @@ -1,24 +1,36 @@ - Driver Status for XFree86[tm] 4.0.1 + Driver Status for XFree86[tm] 4.0.2 The XFree86 Project, Inc - 3 March 2000 + 4 December 2000 Abstract This document provides information about the status of the driver - and hardware support in XFree86 4.0.1 compared with that in XFree86 + and hardware support in XFree86 4.0.2 compared with that in XFree86 3.3.6. Please send updates for this document to 1. Introduction This document contains one section per vendor (organised alphabetically) for -each chipset family that is supported in XFree86 3.3.6 or XFree86 4.0.1. It +each chipset family that is supported in XFree86 3.3.6 or XFree86 4.0.2. It includes information about the status of the drivers and the hardware they support, including a comparison of the level of support between versions -3.3.6 and 4.0.1. +3.3.6 and 4.0.2. +In XFree86 3.3.6, several X servers are available; much hardware uses the +XF86_SVGA server, which has a set of driver modules that are built into it at +compile time. In other cases, X servers for specific chips (or families of +chips) are provided (such as XF86_AGX, XF86_Mach64, etc.). + +In XFree86 4.0.2, there is only one X server, called "XFree86", which can +load driver modules at runtime. Thus there is no specific mention of a +server binary when 4.0.2 is discussed; only the XFree86 server is used. +Third-party vendors (often the manufacturers of various video chipsets) may +provide their own drivers for the XFree86 server, but these third-party mod- +ules are beyond the scope of this document. + NOTE: Status information needs to be checked carefully and expanded where possible. E.g., include information about acceleration, multi-head, known problems, hardware known to work on, platform dependencies/limitations, other @@ -27,36 +39,37 @@ 2. 3Dfx 3.3.6: - Support (including acceleration) for Voodoo Banshee and Voodoo 3. - Support is provided by the XF86_SVGA server with the tdfx - driver). + Support (including acceleration) for Voodoo Banshee and Voodoo3 + cards is provided by the XF86_SVGA server with the tdfx driver. - 4.0.1: - Support for Voodoo 1 and Voodoo 2 via glide on platforms where - glide is available (Linux and FreeBSD(?)). Support is provided - by the "glide" driver (requires Glide 2x). + 4.0.2: + Support for Voodoo Graphics and Voodoo 2 chips is available on + platforms where Glide is available (Linux and FreeBSD(?)) and is + provided by the "glide" driver (requires version 2.x of the Glide + library, which is not part of the XFree86 distribution). - Support (including acceleration) for Voodoo Banshee and Voodoo 3. - Support is provided by the "tdfx" driver. + Support (including acceleration) for Voodoo Banshee, Voodoo3, + Voodoo4, and Voodoo5 is provided by the "tdfx" driver. Summary: - All hardware supported in 3.3.6 is also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. 3. 3Dlabs 3.3.6: Support (including acceleration) for GLINT 500TX (with IBM RGB526 ramdac), GLINT MX plus Delta or Gamma (with IBM RGB526 and RGB640 - ramdacs), Permedia with IBM RGB526 ramdac, Permedia 2, 2a, 2v. - Support is provided by the XF86_3DLabs server. + ramdacs), Permedia with IBM RGB526 RAMDAC, and Permedia 2, 2a, 2v + is provided by the XF86_3DLabs server. - 4.0.1: - Support (including acceleration) for Permedia, Permedia 2, 2v - (and 2a??) GLINT 500TX, GLINT MX, GLINT Gamma, and Glint Delta - coproc. Support is provided by the "glint" driver. + 4.0.2: + Support (including acceleration) for Permedia, Permedia 2, 2v, + (and 2a?), Permedia 3, GLINT 500TX, GLINT MX, GLINT Gamma, and + GLINT Delta coproc is provided by the "glint" driver. Summary: - All hardware supported in 3.3.6 is also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. The + Permedia 3 is only supported in 4.0.2. 4. Alliance @@ -64,14 +77,14 @@ Support (including acceleration) for the AT24, AP6422, AT3D. Support is provided by the XF86_SVGA server with the apm driver. - 4.0.1: + 4.0.2: Support (including acceleration?) for the AT24, AT25 and AT3D. This support is provided by the "apm" driver. This driver cur- rently has only incomplete support for the AP6422. Summary: - The AP6422 is supported in 3.3.6 but not fully in 4.0.1. The - AT25 is supported in 4.0.1 but not in 3.3.6. + The AP6422 is supported in 3.3.6 but not fully in 4.0.2. The + AT25 is supported in 4.0.2 but not in 3.3.6. 5. ARK Logic @@ -80,12 +93,12 @@ and ARK2000MT. Support is provided by the XF86_SVGA server with the ark driver. - 4.0.1: - No native support for these chipsets, because the old driver has - not been ported. + 4.0.2: + Support (including acceleration) for the ARK1000PV, ARK2000PV, + and ARK2000MT. Support is provided by the "ark" driver. Summary: - No ARK Logic chips are supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. 6. ATI @@ -103,16 +116,15 @@ driver. Accelerated support is provided for the Rage 128 chips by the XF86_SVGA server with the r128 driver. - 4.0.1: - Accelerated support is provided for the Rage 128 chips by the - "r128" driver. Accelerated support is provided for the Mach64 - Rage variants by the "ati" driver. Unaccelerated support is pro- - vided for all of the others except the Mach8 and some early - Mach32 chips by the "ati" driver. + 4.0.2: + Accelerated support is provided for Mach64, Rage, Rage 128 and + Radeon chips. Unaccelerated support is provided for all of the + others except the Mach8 and some early Mach32 chips by the "ati" + driver. Summary: - All chips supported in 3.3.6 are supported in 4.0.1 except for - Mach8 and some old Mach32 chips. The support in 4.0.1 is, how- + All chips supported in 3.3.6 are supported in 4.0.2 except for + Mach8 and some old Mach32 chips. The support in 4.0.2 is, how- ever, unaccelerated for all chips except the Mach64, Rage and Rage 128 variants. @@ -122,16 +134,15 @@ Support for the AL2101, ALI2228, ALI2301, ALI2302, ALI2308, ALI2401 chipsets. Support is provided by the XF86_SVGA server, using the al2101 driver for the AL2101, and the ali driver for - the others. The status of this support is unknown because we - don't have any recent test reports, and these drivers have no + the others. These drivers reportedly work, but they have no maintainer. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old drivers have not been ported. Summary: - No Avance Logic chips are supported in 4.0.1. + No Avance Logic chips are supported in 4.0.2. 8. Chips and Technologies @@ -141,13 +152,13 @@ 64300. This support is provided by the XF86_SVGA server with the chips driver. - 4.0.1: + 4.0.2: Support (accelerated) for the 65520, 65525, 65530, 65535, 65540, 65545, 65546, 65548, 65550, 65554, 65555, 68554, 69000, 64200 and 64300. This support is provided by the "chips" driver. Summary: - All chips supported in 3.3.6 are also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. 9. Cirrus Logic @@ -159,15 +170,15 @@ 7541, 7542, 7543, 7548, 7555 and 7556 is provided by the XF86_SVGA server with the cirrus driver. - 4.0.1: + 4.0.2: Support (accelerated) for the Alpine (5430, 5434, 5436, 5446, - 5480), and Laguna (5462, 5464, 5465) chips is provided by the - "cirrus" driver. + 5480, 7548), and Laguna (5462, 5464, 5465) chips is provided by + the "cirrus" driver. Summary: - The following chips are supported in 3.3.6 but not in 4.0.1: + The following chips are supported in 3.3.6 but not in 4.0.2: 6410, 6412, 6420, 6440, 5420, 5422, 5424, 5426, 5428, 5429, 6205, - 6215, 6225, 6235, 7541, 7542, 7543, 7548, 7555 and 7556. + 6215, 6225, 6235, 7541, 7542, 7543, 7555 and 7556. 10. Compaq/Digital @@ -181,7 +192,7 @@ 24 plane 3D chips (on Alpha platforms) is provided by the XF86_TGA server. - 4.0.1: + 4.0.2: No support for the Compaq AVGA (driver hasn't been ported). Support (accelerated) for the DEC 21030 TGA 8 plane, 24 plane and @@ -189,8 +200,8 @@ the "tga" driver. Summary: - No Compaq AVGA support in 4.0.1. DEC TGA support is equivalent - in both versions. + No Compaq AVGA support in 4.0.2. DEC TGA support is equivalent + in both 3.3.6 and 4.0.2. 11. Cyrix @@ -198,12 +209,12 @@ Support (accelerated) for the Cyrix MediaGX is provided by the XF86_SVGA server with the cyrix driver. - 4.0.1: - A preliminary port of the driver is available, but it isn't ready - for widespread use. + 4.0.2: + The 3.3.6 driver has been ported to 4.0.2, including accelera- + tion, but feedback is needed. Summary: - No Cyrix chips are well-supported in 4.0.1. + Cyrix MediaGX users are encouraged to test its support in 4.0.2. 12. Epson @@ -211,12 +222,12 @@ Support (accelerated) for the Epson SPC8110 is provided by the XF86_SVGA server with the spc8100 driver. - 4.0.1: + 4.0.2: No native support for this chipset, because the old driver has not been ported. Summary: - No Epson chips are supported in 4.0.1. + No Epson chips are supported in 4.0.2. 13. Genoa @@ -226,12 +237,12 @@ because we don't have any recent test reports, and this driver has no maintainer. - 4.0.1: + 4.0.2: No native support for this chipset, because the old driver has not been ported. Summary: - No Genoa chips are supported in 4.0.1. + No Genoa chips are supported in 4.0.2. 14. IBM @@ -246,7 +257,7 @@ Support for the IBM XGA-2 chip is provided by the XF86_AGX server. - 4.0.1: + 4.0.2: Support for the standard IBM VGA chip (and compatibles) is pro- vided by the "vga" driver. @@ -255,31 +266,44 @@ Summary: The standard VGA core is supported in both versions, but there is - no support for the 8514/A or XGA-2 in 4.0.1. + no support for the 8514/A or XGA-2 in 4.0.2. 15. IIT 3.3.6: Support (accelerated) for the AGX-016, AGX-015 and AGX-014 is - provided by the XF86_AGX server.. + provided by the XF86_AGX server. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old driver has not been ported. Summary: - No IIT chips are supported in 4.0.1. + No IIT chips are supported in 4.0.2. -16. Intel +16. Integrated Micro Solutions (IMS) 3.3.6: + Support (accelerated) for the IMS Twin Turbo 128 is provided by + the XF86_SVGA server with the imstt driver. + + 4.0.2: + Support (accelerated) for the IMS Twin Turbo 128 is provided by + the "imstt" driver. + + Summary: + All hardware supported in 3.3.6 is also supported in 4.0.2. + +17. Intel + + 3.3.6: Support (accelerated) for the Intel i740 is provided by the XF86_SVGA server with the i740 driver, and for the Intel i810 with the i810 driver. The i810 is currently only supported on Linux, and requires the agpgart.o kernel module in order to use modes that require more than 1MB of video memory. - 4.0.1: + 4.0.2: Support (accelerated) for the Intel i740 is provided by the "i740" driver, and support for the Intel i810 is provided by the "i810" driver. The "i810" driver is currently Linux-only, and @@ -289,22 +313,22 @@ The i740 and i810 are supported in both versions, but the i810 is only supported on Linux/x86 platforms at present. -17. Matrox +18. Matrox 3.3.6: Support (accelerated) for the MGA2064W (Millennium I), MGA1064SG (Mystique), MGA2164W (Millennium II) (PCI and AGP), G100, G200 and G400 is provided by the XF86_SVGA server with the mga driver. - 4.0.1: + 4.0.2: Support (accelerated) for the MGA2064W (Millennium I), MGA1064SG (Mystique), MGA2164W (Millennium II) (PCI and AGP), G100, G200 and G400 is provided by the "mga" driver. Summary: - All chips supported in 3.3.6 are also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. -18. MX (???) +19. MX (???) 3.3.6: Support for the MX68000 and MX68010 chips is provided by the @@ -312,86 +336,88 @@ is unknown because we don't have any recent test reports, and this driver has no maintainer. - 4.0.1: + 4.0.2: No native support for this chipset, because the old driver has not been ported. Summary: - No MX (???) chips are supported in 4.0.1. + No MX (???) chips are supported in 4.0.2. -19. NCR +20. NCR 3.3.6: Support for the old NCR 77C22 and 77C22E chips is provided by the XF86_SVGA server and the ncr77c22 driver. The status of this support is unknown because we don't have any recent test reports. - 4.0.1: + 4.0.2: No native support for this chipset, because the old driver has not been ported. Summary: - No NCR chips are supported in 4.0.1. + No NCR chips are supported in 4.0.2. -20. NeoMagic +21. NeoMagic 3.3.6: Support (accelerated) for the NeoMagic NM2070, NM2090, NM2093, NM2097, NM2160 and NM2200 chipsets is provided by the XF86_SVGA server with the neo driver. - 4.0.1: + 4.0.2: Support (accelerated) for the NeoMagic NM2070, NM2090, NM2093, - NM2097, NM2160 and NM2200 chipsets is provided by the "neomagic" - driver. + NM2097, NM2160, NM2200, NM2230, NM2360 and NM2380 chipsets is + provided by the "neomagic" driver. Summary: - All chips supported in 3.3.6 are also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. The + NM2230 and later chips are only supported in 4.0.2. -21. NVIDIA +22. NVIDIA 3.3.6: Support (accelerated) for the NV1, Riva 128, 128ZX, TNT, TNT2 (Ultra, Vanta, M64), GeForce (DDR, 256) and Quadro is provided by the XF86_SVGA server and the nv driver. - 4.0.1: + 4.0.2: Support (accelerated) for the Riva 128, 128ZX, TNT, TNT2 (Ultra, - Vanta, M64), GeForce (DDR, 256) and Quadro is provided by the nv - driver. + Vanta, M64), GeForce (DDR, 256), GeForce2 (GTS, Ultra, MX), + Quadro, and Quadro2 is provided by the "nv" driver. Summary: All chipsets supported in 3.3.6 except the NV1 are also supported - in 4.0.1. + in 4.0.2. Support for the newer chips (GeForce2 and later) is + only available in 4.0.2. -22. Number Nine +23. Number Nine 3.3.6: Support (accelerated) for the Imagine 128, Ticket 2 Ride, Revolu- tion 3D and Revolution IV is provided by the XF86_I128 server. - 4.0.1: - No native support for these chipsets, because the old driver has - not been ported. + 4.0.2: + Support (accelerated) for the Imagine 128, Ticket 2 Ride, Revolu- + tion 3D and Revolution IV is provided by the "i128" driver. Summary: - No Number Nine chips are supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. -23. Oak Technologies Inc +24. Oak Technologies, Inc. 3.3.6: Support for the OTI067, OTI077, and OTI087 (the latter with some acceleration) is provided by the XF86_SVGA server and the oak driver. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old driver has not been ported. Summary: - No Oak chips are supported in 4.0.1. + No Oak chips are supported in 4.0.2. -24. Paradise/Western Digital +25. Paradise/Western Digital 3.3.6: Support for the Paradise PVGA1 and the Western Digital WD90C00, @@ -400,14 +426,14 @@ port for some of these chipsets is uncertain because we don't have any recent test reports, and this driver has no maintainer. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old driver has not been ported. Summary: - No Paradise/Western Digital chips are supported in 4.0.1. + No Paradise/Western Digital chips are supported in 4.0.2. -25. RealTek +26. RealTek 3.3.6: Support for the RealTek RTG3106 is provided by the XF86_SVGA @@ -415,27 +441,27 @@ unknown because we don't have any recent test reports, and this driver has no maintainer. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old driver has not been ported. Summary: - No RealTek chips are supported in 4.0.1. + No RealTek chips are supported in 4.0.2. -26. Rendition/Micron +27. Rendition/Micron 3.3.6: Support for the Verite 1000, 2100 and 2200 is provided by the XF86_SVGA server with the rendition driver. - 4.0.1: + 4.0.2: Support for the Verite 1000, 2100 and 2200 is provided by the "rendition" driver. Summary: - All chips supported in 3.3.6 are also supported in 4.0.1. + All hardware supported in 3.3.6 is also supported in 4.0.2. -27. S3 +28. S3 3.3.6: Support (accelerated) for the S3 911, 924, 801, 805, 928, 864, @@ -446,29 +472,42 @@ ViRGE/MX+ is provided by the XF86_S3V server. Support (acceler- ated) for those ViRGE chips, as well as the Trio3D and Trio3D/2X is provided by the XF86_SVGA server with the s3v driver. Support - (accelerated) for the Savage3D, Savage3D/MV, Savage4, Savage2000, - Savage/MX-MV, Savage/MX, Savage/IX-MV and Savage/IX is provided - by the XF86_SVGA server with the s3_savage driver (CHECK: is this - support Linux-only?). + (accelerated) for the Savage3D, Savage3D/MV, Savage4, and Sav- + age2000, is provided by the XF86_SVGA server with the s3_savage + driver on some OSes (Linux, *BSD). - 4.0.1: + 4.0.2: Support (accelerated) for the ViRGE, ViRGE/VX, ViRGE/DX, ViRGE/GX, ViRGE/GX2, ViRGE/MX, ViRGE/MX+, Trio3D and Trio3D/2X is - provided by the "s3virge" driver. Support for the other S3 - chipsets has not yet been ported. + provided by the "s3virge" driver. Support (accelerated) for the + Savage3D, Savage3D/MV, Savage4, and Savage2000, is provided by + the "savage" driver. Support for the other S3 chipsets has not + yet been ported. + + Summary: + Only the ViRGE, Trio3D and Savage chipsets are supported in + 4.0.2. All of the other chipsets are only supported in 3.3.6. + +29. Silicon Graphics, Inc. (SGI) + 3.3.6: + No SGI hardware is supported in 3.3.6. + + 4.0.2: + Unaccelerated support for the SGI Indy's Newport cards is pro- + vided by the "newport" driver. + Summary: - Only the ViRGE and Trio3D chipsets are supported in 4.0.1. All - of the other chipsets are only supported in 3.3.6. + SGI hardware is supported only in 4.0.2. -28. Silicon Integrated Systems (SiS) +30. Silicon Integrated Systems (SiS) 3.3.6: Support (accelerated) for the SiS 86C201, 86C202, 86C205, 86C215, 86C225, 5597, 5598, 6326, 530, 620, 300, 630 and 540 is provided by the XF86_SVGA server with the sis driver. - 4.0.1: + 4.0.2: Support (accelerated) for the SiS 530, 620, 6326 is provided by the "sis" driver. The 630, 300, and 540 are also supported, but this code is new and there are @@ -478,22 +517,39 @@ Support for the 86C201, 86C202, 86C215, 86C225, 5597 and 5598 is currently only available in 3.3.6. -29. Silicon Motion, Inc +31. Silicon Motion, Inc. 3.3.6: Support (accelerated) for the Lynx, LynxE, Lynx3D, LynxEM, LynxEM+ and Lynx3DM chips is provided by the XF86_SVGA server with the smi driver. + + 4.0.2: + Support (accelerated) for the Lynx, LynxE, Lynx3D, LynxEM, + LynxEM+ and Lynx3DM chips is provided by the "siliconmotion" + driver. + + Summary: + All hardware supported in 3.3.6 is also supported in 4.0.2. + +32. Sun Microsystems + + 3.3.6: + No Sun hardware is supported in 3.3.6. - 4.0.1: - No native support for these chipsets, because the driver has not - been ported. + 4.0.2: + Sun BW2 framebuffers are supported by the "sunbw2" driver. Sun + CG3 framebuffers are supported by the "suncg3" driver. Sun CG6 + framebuffers are supported by the "suncg6" driver. Sun CG14 + framebuffers are supported by the "suncg14" driver. Sun FFB + framebuffers are supported by the "sunffb" driver. Sun LEO + framebuffers are supported by the "sunleo" driver. Sun TCX + framebuffers are supported by the "suntcx" driver. Summary: - No SMI chips are supported in 4.0.1, but the fbdev driver is - reported to work on Linux. + Sun hardware is supported only in 4.0.2. -30. Trident Microsystems +33. Trident Microsystems 3.3.6: Support (accelerated where the chip supports it) for the @@ -506,21 +562,24 @@ CyberBlade/DSTN/i7 and CyberBlade/i1 is provided by the XF86_SVGA server with the tvga8900 driver. - 4.0.1: + 4.0.2: Support (accelerated where the chip supports it) for the - TVGA8900D, TGUI9420DGi, TGUI9440AGi, TGUI9660, TGUI9680, ProVidia - 9682, ProVidia 9685, Cyber9320, Cyber9382, Cyber9385, Cyber9388, - Cyber9397, Cyber9520, Cyber9397/DVD, Cyber9525/DVD, 3DImage975, - 3DImage875, Blade3D, CyberBlade/i7, CyberBlade/DSTN/i7 and - CyberBlade/i1 is provided by the "trident" driver. + TVGA8900D, TGUI9440AGi, TGUI9660, TGUI9680, ProVidia 9682, Pro- + Vidia 9685, Cyber9320, Cyber9382, Cyber9385, Cyber9388, + Cyber9397, Cyber9397/DVD, Cyber9520, Cyber9525/DVD, 3DImage975, + 3DImage985, Blade3D, CyberBlade/i7, CyberBlade/DSTN/i7, + CyberBlade/i1, CyberBlade/DSTN/i1, CyberBlade/Ai1, + CyberBlade/DSTN/Ai1 and CyberBlade/e4 is provided by the "tri- + dent" driver. Summary: The following (older) chipsets that are supported in 3.3.6 are - not supported in 4.0.1: TVGA8200LX, TVGA8800CS, TVGA8900B, + not supported in 4.0.2: TVGA8200LX, TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000, TVGA9000i, TVGA9100B, - TVGA9200CXr, TGUI9400CXi, TGUI9420, TGUI9430DGi. + TVGA9200CXr, TGUI9400CXi, TGUI9420, TGUI9430DGi. The remaining + listed chipsets are supported in 4.0.2. -31. Tseng Labs +34. Tseng Labs 3.3.6: Support for the ET3000 is provided by the XF86_SVGA server with @@ -530,16 +589,16 @@ driver. Support (accelerated) for the ET4000/W32 series and the ET6000 is also provided by the deprecated XF86_W32 server. - 4.0.1: + 4.0.2: Support for the ET4000AX, and accelerated support for the ET4000/W32, ET4000/W32i, ET4000/W32p, ET6000 and ET6100 is pro- vided by the "tseng" driver. Summary: - All cards supported by 3.3.6 are also supported by 4.0.1 except + All cards supported by 3.3.6 are also supported by 4.0.2 except for the old ET3000. -32. Video 7 +35. Video 7 3.3.6: Support for the Video 7 chipset is provided by the XF86_SVGA @@ -547,28 +606,28 @@ unknown because we don't have any recent test reports, and this driver has no maintainer. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old driver has not been ported. Summary: - No Video 7 chips are supported in 4.0.1. + No Video 7 chips are supported in 4.0.2. -33. Weitek +36. Weitek 3.3.6: Support (accelerated) for the P9000 is provided by the XF86_P9000 server and accelerated support for the P9100 is provided by the XF86_SVGA server with the p9x00 driver. - 4.0.1: + 4.0.2: No native support for these chipsets, because the old drivers have not been ported. Summary: - No Weitek chips are supported in 4.0.1. + No Weitek chips are supported in 4.0.2. - Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.17 2000/06/19 15:00:54 tsi Exp $ + Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.26 2000/12/14 22:15:48 dawes Exp $ -$XFree86: xc/programs/Xserver/hw/xfree86/doc/Status,v 1.13 2000/06/19 15:12:27 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/Status,v 1.21 2000/12/14 22:34:26 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml:1.2 xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml:1.4 --- xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml:1.2 Mon Aug 23 22:01:07 1999 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml Tue Oct 17 05:07:03 2000 @@ -15,6 +15,7 @@ GLINT MX plus Gamma with IBM RGB526 and IBM RGB640 RAMDAC Permedia with IBM RGB526 RAMDAC Permedia 2 (classic, 2a, 2v) +Permedia 3 Features

@@ -27,6 +28,7 @@ GLINT MX/500TX: 8/16/32 bpp Permedia: 8/16/32 bpp Permedia 2: 8/16/24/32 bpp +Permedia 3: depth 8 (bpp 8), 15, 16 (bpp 16) and 24 (bpp 32) @@ -60,6 +62,8 @@ While the server is accelerated, there is room for improvement. As our development is focusing on XFree86-4.0 we are not planning to change that in the 3.3.x branch. XFree86-4.0 will include a significantly faster server. +The Permedia 3 chipset has still some minor problems, see the README.pm3 +file in the glint driver source directory for more details. Authors

@@ -68,16 +72,19 @@ Dirk Hohndel <hohndel@XFree86.org> Stefan Dirsch <sndirsch@suse.de> Helmut Fahrion <hf@suse.de> +Sven Luther <luther@dpt-info.u-strasbg.fr> Special thanks to Elsa AG, Aachen for making it possible for us to develop this server and furnishing us with plenty of boards and information to help us on the way Very special thanks to SuSE GmbH, Nuernberg for allowing some of us to work on this server on paid time, thereby financing development of this server. +Special thanks for Appian Graphics for having provided board and +documentation for the Permedia3 chip. -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml,v 1.2 1999/08/24 02:01:07 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/3Dlabs.sgml,v 1.4 2000/10/17 09:07:03 alanh Exp $ Index: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml:1.30 xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml:1.39 --- xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml:1.30 Mon Jun 19 11:00:52 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml Mon Dec 4 13:49:54 2000 @@ -27,7 +27,7 @@ XFree86 X server ``New Design'' (DRAFT) <author>The XFree86 Project, Inc -<date>Last modified 1 May 2000 +<date>Last modified 2 December 2000 @@ -36,7 +36,7 @@ <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.30 2000/06/19 15:00:52 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.39 2000/12/04 18:49:54 dawes Exp $ </ident> @@ -518,8 +518,9 @@ it to the global &s.code;xf86DriverList[]&e.code; array. The &s.code;DriverRec&e.code; contains the driver's version, a short - descriptive message, the &s.code;Identify()&e.code; and - &s.code;Probe()&e.code; function entry points as well as a pointer + descriptive message, the &s.code;Identify()&e.code;, + &s.code;Probe()&e.code; and &s.code;AvailableOptions()&e.code; + function entry points as well as a pointer to the driver's module (as returned from the loader when the driver was loaded) and a reference count which keeps track of how many screens are using the driver. The entry driver entry points are @@ -589,13 +590,17 @@ &s.code;Bool ChipProbe(DriverPtr drv, int flags)&e.code; <quote><p> The purpose of this is to identify all instances of hardware - supported by the driver. The flags value is currently not used, - and should be ignored by the driver. + supported by the driver. The flags value is currently either 0, + &s.code;PROBE_DEFAULT&e.code; or &s.code;PROBE_DETECT&e.code;. + &s.code;PROBE_DETECT&e.code; is used if "-configure" or "-probe" + command line arguments are given and indicates to the + &s.code;Probe()&e.code; function that it should not configure the + bus entities and that no XF86Config information is available. The probe must find the active device sections that match the driver by calling &s.code;xf86MatchDevice()&e.code;. The number of matches found limits the maximum number of instances for this - driver. If no matches are found, the problem should return + driver. If no matches are found, the function should return &s.code;FALSE&e.code; immediately. Devices that cannot be identified by using device-independent @@ -3845,8 +3850,7 @@ &s.code;drw_w&e.code; by &s.code;drw_h&e.code; on the screen. Since it is not expected that all hardware will be able to get the target dimensions exactly, it is important that the - driver provide this function. The returned dimensions must - be less than or equal to the requested dimension. + driver provide this function. </quote> @@ -5352,6 +5356,7 @@ allowed by the driver. If a mode doesn't fit in any of the defined &s.code;clockRanges&e.code;, it is rejected. The first &s.code;clockRange&e.code; that matches all requirements is used. + This structure needs to be initialized to NULL when allocated. &s.code;clockRanges&e.code; contains the following fields: @@ -6493,6 +6498,13 @@ initialisation has already been done. After allocating it, initialise the fields. By using &s.code;xnfcalloc()&e.code; to do the allocation it is zeroed, and if the allocation fails the server exits. +<p> + NOTE: + When allocating structures from inside the driver which are defined + on the common level it is important to initialize the structure to + zero. + Only this guarantees that the server remains source compatible to + future changes in common level structures. <code> static Bool @@ -6622,8 +6634,7 @@ /* add screen to entity */ } } - if (numUsed > 0) - xfree(usedChips); + xfree(usedChips); } #ifdef HAS_ISA_DEVS @@ -6654,8 +6665,7 @@ foundScreen = TRUE; } } - if (numUsed > 0) - xfree(usedChips); + xfree(usedChips); #endif /* HAS_ISA_DEVS */ xfree(devSections); @@ -7292,8 +7302,10 @@ ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - ZZZRestore(pScrn); - ZZZUnmapMem(pScrn); + if (pScrn->vtSema) { + ZZZRestore(pScrn); + ZZZUnmapMem(pScrn); + } pScrn->vtSema = FALSE; pScreen->CloseScreen = ZZZPTR(pScrn)->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); @@ -7306,8 +7318,11 @@ Define the &s.code;SaveScreen()&e.code; function (the screen blanking function). When using the vgahw module, this will typically be: + +This function is mandatory. Before modifying any hardware register directly +this function needs to make sure that the Xserver is active by checking +if <code>pScrn</code> is non-NULL and for <code>pScrn->vtSema == TRUE</code>. -This function is mandatory. <code> static Bool Index: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml:1.5 xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml:1.15 --- xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml:1.5 Fri Jun 16 20:03:17 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml Tue Dec 12 13:54:29 2000 @@ -2,18 +2,20 @@ <!ENTITY % defs SYSTEM "defs.ent"> %defs; ]> -<!-- Created: Mon Feb 28 13:00:00 2000 by brian@precisioninsight.com --> +<!-- Created: Mon Feb 28 13:00:00 2000 by brianp@valinux.com --> <!-- Revised: Fri May 19 09:41:48 2000 by martin@valinux.com --> +<!-- Revised: Tue Aug 22 14:00:00 2000 by brianp@valinux.com --> <article> <title>DRI User Guide - <author><htmlurl url="http://www.precisioninsight.com/" - name="Precision Insight, Inc."> - <date>18 May 2000 + <author> + <htmlurl url="http://www.valinux.com/" + name="VA Linux Systems, Inc."> Professional Services - Graphics. + <date>20 November 2000 <ident> - $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.5 2000/06/17 00:03:17 martin Exp $ + $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.15 2000/12/12 18:54:29 dawes Exp $ </ident> <toc> @@ -22,8 +24,7 @@ <p> <sect1>Copyright <p> - <bf>Copyright © 2000 by Precision Insight, Inc., - Cedar Park, Texas. + <bf>Copyright © 2000 by VA Linux Systems, Inc. All Rights Reserved.</bf> <p> <bf>Permission is granted to make and distribute verbatim copies @@ -50,7 +51,7 @@ <sect>Introduction <p> - With XFree86 4.0 and Precision Insight's Direct Rendering Interface + With XFree86 4.0 and the Direct Rendering Interface (DRI), hardware accelerated 3D graphics can be considered a standard feature on Linux workstations. Support for other operating systems, such as FreeBSD, is underway. @@ -69,20 +70,62 @@ DRI download, compilation and installation instructions can be found at <htmlurl url="http://dri.sourceforge.net/DRIcompile.html" name="http://dri.sourceforge.net/DRIcompile.html"> - - <sect>Supported Hardware -<p> - 3D acceleration is currently only available for systems with - Intel-compatible CPUs. - Support for Alpha, and perhaps other CPUs, should be available in the - future. <p> - XFree86 4.0 (or later versions) includes 3D acceleration for the - following graphics hardware: + Edits, corrections and updates to this document may be mailed + to brianp@valinux.com. + + <sect>Supported Architectures & Hardware + <p> + <sect1>Architectures + <p> + The Architectures currently supported by the DRI have grown + from the initial Intel i386 based machines to now include, + the Alpha Processor and the Sun SPARC machines. + + The build environment for both of these new architectures + have a pre-build environment that will correctly build the + DRI drivers and Mesa meaning no extra configuration is necessary + to build the DRI for these architectures. + + <sect2>Alpha Features + <p> + On newer Alpha processors, it should be noted that a + significant performance increase can be seen with the + addition of the -mcpu= command that should be passed to + GCC upon compilation. Dependent of the architecture of the + processor, for example -mcpu=ev6 will build specifically + for the EV6 based AXP's, giving both byte and word alignment + access to the DRI/Mesa drivers. + + Use this as an example of compiling with this extra speed. + In your host.def file that should reside in the xc/config + directory, add the line. + + #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 + + Additional speed improvements to 3D rendering can be achieved + by installing Compaq's Math Libraries (CPML) which can be + obtained from the following URL. + + http://www.support.compaq.com/alpha-tools/software/index.html + + Once installed, you can set this option in your host.def + to build against the CPML libraries. + + #define UseCompaqMathLibrary YES + + <sect1> Graphics Hardware + <p> + XFree86 4.0 (or later versions) includes 3D acceleration for the + following graphics hardware: + + NOTE: This is a complete list of graphics hardware supported. It + may not be supported on your platform. <itemize> <item>3dfx: <itemize> + <item>Voodoo5 5500 <item>Voodoo3 3500 TV <item>Voodoo3 3000 AGP <item>Voodoo3 3000 PCI @@ -120,49 +163,60 @@ </itemize> <p> - Support for the following hardware is underway: - <itemize> - <item>3dfx Voodoo4 and Voodoo5 series - </itemize> + Support for other hardware is underway. + <p> <sect>Prerequisite Software <p> <itemize> - <item>XFree86 4.0 - <item>For the 3dfx Voodoo3 driver, Linux kernel 2.2.x (later - kernels will be supported in - the near future, and may be required for some chipsets) - <item>For the Matrox G200/G400, Linux kernel 2.3.51, with AGP support - <item>For the Intel i810, Linux kernel 2.3.99-pre6, with AGP support + <item>The DRI is available in XFree86 4.0 and later. + <item>Some hardware drivers require specific versions of the + Linux kernel for AGP support, etc. + See section 10 for specifics. + <item>You <em>DO NOT</em> need to install Mesa separately. + The parts of Mesa needed for hardware acceleration are + already in the XFree86/DRI project. </itemize> - <p> - Mesa 3.3 (beta) is included with XFree86 4.0; there is no need to - download the stand-alone Mesa distribution. - <sect>X Server Start-up -<p> - This section describes the steps needed to start the X server with - 3D acceleration support. - - <sect1>Kernel module -<p> - XFree86 4.0.1 added automatic kernel module loading to the X server. - On Linux, the X server uses modprobe to load kernel modules. - The DRM kernel modules should be in /lib/modules/KERNEL-VERSION/misc/ - for automatic loading to work. -<p> - Optionally, DRM kernel modules can be loaded manually with insmod - prior to starting the X server. -<p> - You can verify that the kernel module was installed with lsmod, - checking the X server startup log, and checking that /proc/dri/0 - exists. + <sect>Kernel Modules + <p> + 3D hardware acceleration requires a DRI kernel module that's + specific to your graphics hardware. + <P> + The DRI kernel module version must exactly match your running kernel + version. + Since there are so many versions of the kernel, it's difficult to + provide precompiled kernel modules. + <p> + While the Linux source tree includes the DRI kernel module sources, + the latest DRI kernel sources will be found in the DRI source tree. + <p> + See the DRI Compilation Guide for information on compiling the DRI + kernel modules. + <p> + XFree86 4.0.1 added automatic kernel module loading to the X server. + On Linux, the X server uses modprobe to load kernel modules. + In Linux 2.4.x the DRM kernel modules should be kept in + <tt>/lib/modules/2.4.x/kernel/driver/char/drm/</tt> for automatic + loading to work. + <p> + Optionally, DRM kernel modules can be loaded manually with insmod + prior to starting the X server. + <p> + You can verify that the kernel module was installed with lsmod, + checking the X server startup log, and checking that /proc/dri/0 + exists. - <sect1>XF86Config file -<p> - First, the XF86Config file must load the GLX and DRI modules: + <sect>XF86Config file + <p> + The XFree86 configuration file is usually found in + <tt>/etc/X11/XF86Config</tt>. + This section describes the parts which must be specially set for + the DRI. + <p> + First, the XF86Config file must load the GLX and DRI modules: <verb> Section "Module" @@ -174,142 +228,78 @@ EndSection </verb> - Next, the DRI section can be used to restrict access to direct - rendering. + Next, the DRI section can be used to restrict access to direct + rendering. <p> - If you want all of the users on your system to be able to use - direct-rendering, then use a simple DRI section: + If you want all of the users on your system to be able to use + direct-rendering, then use a simple DRI section: <verb> Section "DRI" Mode 0666 EndSection </verb> <p> - This section will allow any user with a current connection to the X - server to use direct rendering. + This section will allow any user with a current connection to the X + server to use direct rendering. <p> - If you want to restrict the use of direct-rendering to a - certain group of users, then create a group for those users by - editing the <tt>/etc/group</tt> file on your system. - For example, you may want to create a group called <tt>xf86dri</tt> - and place two users (e.g., <tt>fred</tt> and <tt>jane</tt>) in - that group. - To do that, you might add the following line to <tt>/etc/group</tt>: - + If you want to restrict the use of direct-rendering to a + certain group of users, then create a group for those users by + editing the <tt>/etc/group</tt> file on your system. + For example, you may want to create a group called <tt>xf86dri</tt> + and place two users (e.g., <tt>fred</tt> and <tt>jane</tt>) in + that group. + To do that, you might add the following line to <tt>/etc/group</tt>: <verb> xf86dri:x:8000:fred,jane </verb> - - You have to be careful that the group id (8000 in this example) - is unique. + You have to be careful that the group id (8000 in this example) + is unique. <p> - Then you would use the following DRI section: - + Then you would use the following DRI section: <verb> Section "DRI" Group "xf86dri" Mode 0660 EndSection </verb> - - This would limit access to direct-rendering to those users in the - <tt>xf86dri</tt> group (<tt>fred</tt> and <tt>jane</tt> in this - example). When other users tried to use direct rendering, they - would fall back to unaccelerated indirect rendering. - <p> - [Note that there is a known bug in XFree86 4.0 that prevents some - changes to the DRI section from taking effect. Until this bug is - fixed, if you change the DRI section, please also remove the - <tt>/dev/dri</tt> directory with the <tt>rm -rf /dev/dri</tt> - command.] + This would limit access to direct-rendering to those users in the + <tt>xf86dri</tt> group (<tt>fred</tt> and <tt>jane</tt> in this + example). When other users tried to use direct rendering, they + would fall back to unaccelerated indirect rendering. + <p> + [Note that there is a known bug in XFree86 4.0 that prevents some + changes to the DRI section from taking effect. Until this bug is + fixed, if you change the DRI section, please also remove the + <tt>/dev/dri</tt> directory with the <tt>rm -rf /dev/dri</tt> + command.] + <p> + Finally, the XF86Config file needs <tt>Device</tt> and + <tt>Screen</tt> sections specific to your hardware. + Look in section 10: <em>Hardware-Specific Information and + Troubleshooting</em> for details. + + <sect>Memory usage +<p> + Using the 3D features of a graphics card requires more memory + than when it's just used as a 2D device. + Double buffering, depth buffering, stencil buffers, textures, + etc. all require extra graphics memory. + These features may require four times the memory used for a simple + 2D display. + <p> + If your graphics card doesn't have a lot of memory (less than 16MB, + for example), you may have to reduce your screen size and/or + color depth in order to use 3D features. + Reducing the screen resolution will also leave more space for + texture images, possibly improving 3D performance. + If, for example, you play Quake3 at 1024x768 but start your display + at 1600x1200 you might consider restarting X at 1024x768 in order to + maximize your texture memory space. <p> - Next, the Device section of the XF86Config file must describe your - particular hardware. - <p> - For example, here's the Device section for a 3dfx Voodoo3 card: + The documentation included with your card should have information + about maximum screen size when using 3D. - <verb> - Section "Device" - Identifier "Voodoo3" - VendorName "3dfx" - Driver "tdfx" - EndSection - </verb> - <p> - Here's the Device section for a Matrox G400 card: - <verb> - Section "Device" - Identifier "G400" - VendorName "Matrox" - Driver "mga" - VideoRam 32768 - EndSection - </verb> - - <p> - Here's the Device section for an ATI Rage 128 card: - <verb> - Section "Device" - Identifier "Rage128" - VendorName "ATI" - Driver "r128" - EndSection - </verb> - - Here's the Device section for an Intel i810 motherboard: - <verb> - Section "Device" - Identifier "i810" - VendorName "Intel" - Driver "i810" - VideoRam 10000 - EndSection - </verb> - - <p> - Finally, the Screen section of the XF86Config file may have to be - specially configured as well. - For example, Voodoo3 hardware acceleration is only available - in 16bpp mode. - <verb> - Section "Screen" - Identifier "Screen 1" - Device "Voodoo3" - Monitor "High Res Monitor" - DefaultDepth 16 - Subsection "Display" - Depth 16 - Modes "1280x1024" "1024x768" "800x600" "640x480" - ViewPort 0 0 - EndSubsection - EndSection - </verb> - <p> - Replace <em>Voodoo3</em> with <em>G400</em> for Matrox G400. - <p> - Replace <em>Voodoo3</em> with <em>Rage128</em> for ATI Rage 128. - <p> - If there are errors in the XF86Config file, the X server will - log errors to the file /var/log/XFree86.0.log - - <sect1>Memory usage -<p> - Using the 3D features of a graphics card requires more memory - than when it's just used as a 2D device. - Double buffering, depth buffering, stencil buffers, textures, - etc. all require extra graphics memory. - These features may require four times the memory used for a simple - 2D display. - <p> - If your graphics card doesn't have a lot of memory (less than 16MB, - for example), you may have to reduce your screen size and/or - color depth in order to use 3D features. - <p> - The documentation included with your card should have information - about maximum screen size when using 3D. - - <sect>Using 3D Acceleration <p> This section describes how to link your application with libGL.so @@ -344,11 +334,13 @@ The <tt/-I/ option is used to specify where the GL/glut.h (and possibly the GL/gl.h and GL/glu.h) header file may be found. <p> - The <tt/-L/ options specify where the libglut.so, libGLU.so and - X libraries are located. + The <tt/-L/ options specify where the libglut.so and the X + libraries are located. + libGL.so and libGLU.so should be in /usr/lib, as specified by + the Linux/OpenGL ABI standard. <p> The <tt/-lglut -lGLU -lGL/ arguments specify that the application - should link with the GLUT, GLU and GL libraries. + should link with the GLUT, GLU and GL libraries, in that order. <sect1>Running your OpenGL program <p> @@ -367,12 +359,15 @@ OSMesa (Off-Screen Mesa) is an interface and driver for rendering 3D images into a user-allocated block of memory rather than an on-screen window. + It was originally developed for Mesa before Mesa became part of + the XFree86/DRI project. + It can now be used with the XFree86/DRI libGL.so as well. <p> - libOSMesa.so implements the OSMesa interface and must be linked + libOSMesa.so implements the OSMesa interface and it must be linked with your application if you want to use the OSMesa functions. You must also link with libGL.so. For example: <verb> - gcc osdemo.c -L/usr/X11R6/lib -lOSMesa -lGLU -lGL -o osdemo + gcc osdemo.c -lOSMesa -lGLU -lGL -o osdemo </verb> <p> In stand-alone Mesa this interface was compiled into the monolithic @@ -411,9 +406,9 @@ If you see that indirect rendering is being used when direct rendering was expected, proceed to the troubleshooting section. <p> - <tt/glxinfo/ also lists all of the GLX-enhanced visuals available. - Here you can determine which visuals may have depth buffers, stencil - buffers, accumulation buffers, etc. + <tt/glxinfo/ also lists all of the GLX-enhanced visuals available + so you can determine which visuals are double-bufferd, have depth (Z) + buffers, stencil buffers, accumulation buffers, etc. <sect1>Environment Variables <p> @@ -445,6 +440,11 @@ Note that this feature is disabled for set-uid programs. This variable replaces the <tt/LIBGL_DRIVERS_DIR/ env var used in XFree86 4.0. + <item> + <tt/MESA_DEBUG/, if defined, will cause Mesa-based 3D drivers + to print user error messages to stderr. + These are errors that you'd otherwise detect by calling + <tt>glGetError</tt>. </enum> <p> Mesa-based drivers (this includes most of the drivers listed @@ -458,7 +458,7 @@ problems. See below for additional information for specific hardware. - <sect1>Starting the X server + <sect1>The X Server <p> <enum> <item> @@ -468,7 +468,8 @@ For 3dfx hardware you should see <tt/tdfx/, for example. <item> - Verify you're running XFree86 4.0 and not an older version. + Verify you're running XFree86 4.0 (or newer) and not an + older version. If you run <tt/xdpyinfo/ and look for the following line near the top: <verb> @@ -614,7 +615,13 @@ This section presents hardware-specific information for normal use and troubleshooting. - <sect1>3dfx Voodoo3 + <sect1>3dfx Voodoo3 Series +<p> + <sect2>Dependencies +<p> + The Voodoo3 DRI driver requires a special versions of + the 3dfx Glide library. + It can be downloaded from the DRI website. <p> <sect2>Configuration <p> @@ -643,17 +650,26 @@ </verb> <p> The kernel module for the Voodoo3 is named <tt>tdfx.o</tt> and - should be installed in /lib/modules/KERNEL-VERSION/misc/. + should be installed in /lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded by the Xserver if needed. <p> The DRI 3D driver for the Voodoo3 should be in <tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>. This will be automatically loaded by libGL.so. + <p> <sect2>Troubleshooting <p> <itemize> <item> + If you try to run an OpenGL application and see an error message + similar to + <verb> + gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS + </verb> + it means that you have the wrong version of the Glide library + for your hardware. + <item> 3D acceleration for Voodoo3 is only supported in the 16 bit/pixel screen mode. Use <tt/xdpyinfo/ to verify that all your visuals are depth 16. @@ -676,35 +692,197 @@ Zero allows maximum frame rate. <item> The <tt/glTexEnv/ mode <tt/GL_BLEND/ is not directly supported - by the 3dfx hardware. + by the Voodoo3 hardware. It can be accomplished with a multipass algorithm but it's not implemented at this time. Applications which use that mode, such as the Performer Town demo, may become sluggish when falling back to software rendering to render in that mode. + <item> + The Voodoo3/Banshee driver reverts to software rendering under + the following conditions: + <itemize> + <item> + Setting <tt/GL_LIGHT_MODEL_COLOR_CONTROL/ to + <tt/GL_SEPARATE_SPECULAR_COLOR/. + <item> + Enabling line stippling or polygon stippling. + <item> + Enabling point smoothing or polygon smoothing. + <item> + Enabling line smoothing when line width is not 1.0. + That is, antialiased lines are done in hardware only when + the line width is 1.0. + <item> + Using 1-D or 3-D texture maps. + <item> + Using the GL_BLEND texture environment. + <item> + Using stencil operations. + <item> + Using the accumulation buffer. + <item> + Using <tt/glBlendEquation(GL_LOGIC_OP)/. + <item> + Using <tt/glDrawBuffer(GL_FRONT_AND_BACK)/. + <item> + Using <tt/glPolygonMode(face, GL_POINT)/ or + <tt/glPolygonMode(face, GL_LINE)/. + <item> + Using point size attenuation + (i.e. <tt/GL_DISTANCE_ATTENUATION_EXT/). + <item> + Using <tt/glColorMask(r, g, b, a)/ when r!=g or g!=b. + </itemize> </itemize> + <sect2>Known Problems <p> <itemize> <item> - Glide cannot be used directly; only OpenGL-based programs are - supported on the Voodoo3. + The Glide library cannot be used directly; it's only meant to + be used via the tdfx DRI driver. <item> SSystem has problems because of poorly set near and far clipping planes. The office.unc Performer model also suffers from this problem. + <item> + The lowest mipmap level is sometimes miscolored in trilinear- + sampled polygons. </itemize> - <sect1>Intel i810 + <sect1>3dfx Voodoo5 Series +<p> + <sect2>Dependencies <p> + The Voodoo5 DRI driver requires a special versions of + the 3dfx Glide library, different than that used for Voodoo3 + hardware. + It can be downloaded from the DRI website. +<p> <sect2>Configuration <p> Your XF86Config file's device section must specify the - <tt>i810</tt> device, and specify a usable amount of video - ram to reserve. + <tt>tdfx</tt> device: <verb> Section "Device" + Identifier "Voodoo5" + VendorName "3dfx" + Driver "tdfx" + EndSection + </verb> + The Screen section should then reference the Voodoo3 device: + <verb> + Section "Screen" + Identifier "Screen 1" + Device "Voodoo5" + Monitor "High Res Monitor" + DefaultDepth 24 + Subsection "Display" + Depth 16 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + </verb> + <p> + The kernel module for the Voodoo5 is named <tt>tdfx.o</tt> and + should be installed in /lib/modules/2.4.x/kernel/driver/char/drm/. + It will be automatically loaded by the Xserver if needed. + <p> + The DRI 3D driver for the Voodoo5 should be in + <tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>. + This will be automatically loaded by libGL.so. + <p> + The Voodoo5 supports 3D rendering in 16 and 32 bpp modes. + When running in 32bpp mode an 8-bit stencil buffer and 24-bit + Z (depth) buffer are offered. + When running in 16bpp mode only a 16-bit Z (depth) buffer is + offered and stencil is implemented in software. + <p> + A software-based accumulation buffer is available in both + 16 and 32bpp modes. + <p> + + <sect2>Troubleshooting +<p> + <itemize> + <item> + The <tt>/dev/3dfx</tt> device is not used for DRI; it's only for + Glide on older 3dfx hardware. + <item> + Different versions of Glide are needed for Voodoo3 and Voodoo5. + See the DRI website's resources page to download the right + version of Glide. + </itemize> + + <sect2>Performance +<p> + <itemize> + <item> + Normally, buffer swapping in double-buffered applications is + synchronized to your monitor's refresh rate. + This may be overridden by setting the <tt/FX_GLIDE_SWAPINTERNVAL/ + environment variable. + The value of this variable indicates the maximum number of + swap buffer commands can be buffered. + Zero allows maximum frame rate. + <item> + Rendering with 16-bit per texel textures is faster than using + 32-bit per texel textures. The <tt/internalFormat/ parameter + to <tt/glTexImage2D/ can be used to control texel size. + <item> + The Voodoo5 driver reverts to software rendering under the + same conditions Voodoo3 with three exceptions. + First, stencil operations are implemented in hardware when the + screen is configured for 32 bits/pixel. + Second, the <tt/GL_BLEND/ texture env mode is fully supported in + hardware. + Third, <tt/glColorMask/ is fully supported in hardware when + the screen is configured for 32 bits/pixel. + </itemize> + <sect2>Known Problems +<p> + <itemize> + <item> + The Glide library cannot be used directly; it's only meant to + be used via the tdfx DRI driver. + <item> + 24bpp screen modes are supported by the hardware but not by + the current driver. 32bpp is fully supported. + <item> + As of October, 2000 the second VSA-100 chip on the Voodoo5 is + not yet operational. + Therefore, the board isn't being used to its full capacity. + The second VSA-100 chip will allow Scan-Line Interleave (SLI) + mode for full-screen applications and games, potentially doubling + the system's fill rate. + </itemize> + + + <sect1>Intel i810 + <p> + <sect2>Dependencies + <p> + A Linux kernel with AGP GART support is required. + The 2.2.x kernel series does not have AGP GART support. + The 2.4.x test kernels have AGP GART and have been tested + with the i810. + <p> + + <sect2>Configuration + <p> + Your XF86Config file's device section must specify the + <tt>i810</tt> device, and specify a usable amount of video + ram to reserve. + <verb> + Section "Device" Identifier "i810" VendorName "Intel" Driver "i810" @@ -727,7 +905,7 @@ </verb> <p> The kernel module for the i810 is named <tt>i810.o</tt> and - should be installed in /lib/modules/KERNEL-VERSION/misc/. + should be installed in /lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded by the Xserver if needed. <p> The DRI 3D driver for the i810 should be in @@ -758,16 +936,22 @@ <p> <sect1>Matrox G200 and G400 -<p> + <p> + <sect2>Dependencies + <p> + A Linux kernel with AGP GART support (such as the 2.4.x test + kernels) is needed. + <p> <sect2>Configuration -<p> - Your XF86Config file's device section must specify the - <tt>mga</tt> device: - <verb> + <p> + Your XF86Config file's device section must specify the + <tt>mga</tt> device: + <verb> Section "Device" Identifier "MGA" VendorName "Matrox" Driver "mga" + VideoRam 32768 EndSection </verb> The Screen section should then reference the MGA device: @@ -784,47 +968,110 @@ EndSubsection EndSection </verb> + To use a 32bpp screen mode, use this <tt>Screen</tt> section + instead: + <verb> + Section "Screen" + Identifier "Screen 1" + Device "MGA" + Monitor "High Res Monitor" + DefaultDepth 24 + DefaultFbBpp 32 + Subsection "Display" + Depth 24 + Modes "1280x1024" "1024x768" "800x600" "640x480" + ViewPort 0 0 + EndSubsection + EndSection + </verb> + <p> The kernel module for the G200/G400 is named <tt>mga.o</tt> and - should be installed in /lib/modules/KERNEL-VERSION/misc/. + should be installed in /lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded by the Xserver if needed. <p> The DRI 3D driver for the G200/G400 should be in <tt>/usr/X11R6/lib/modules/dri/mga_dri.so</tt>. This will be automatically loaded by libGL.so. - <sect2>Troubleshooting + <sect2>Performance <p> + Software rendering will be used under any of the + following conditions: <itemize> - <item> - 3D acceleration for the G200 and G400 is only supported in the 16 - bit/pixel screen mode at this time. 32bpp will be supported - in the future. - Use <tt/xdpyinfo/ to verify that all your visuals are depth 16. - Edit your XF86Config file if needed. + <item>Using glDrawBuffer(GL_FRONT_AND_BACK). + <item>Using point, line, or triangle smoothing. + <item>Using glLogicOp. + <item>Using glPolygonStipple or glLineStipple. + <item>Using 1D or 3D textures. + <item>Using the accumulation buffer. </itemize> - <sect2>Performance + + <sect2>IRQ Assignment <p> - No data at this time. + There have been problems in the past with the MGA driver being very + sluggish when the DRI is enabled (to the point of being unusable.) + This is caused by the graphics card not having an interrupt assigned + to it. + The current DRI trunk will attempt to detect this condition and + bail out gracefully. + <p> + The solution to the above problem is to assign an interrupt to your + graphics card. + This is something you must turn on in your system BIOS configuration. + Please consult your system BIOS manual for instructions + on how to enable an interrupt for your graphics card. + <p> + <sect2>MGA HAL lib +<p> + MGAHALlib.a is a binary library Matrox has provided for use under + Linux to expose functionality for which they can not provide + documentation. + (For example TV-Out requires MacroVision be enabled on the output.) + This binary library also sets the pixel/memory clocks to the optimal + settings for your Matrox card. + <p> + Currently the MGAHAL library is required for the G450 to work. + You can download this from the driver section on Matrox's website: + <htmlurl url="http://www.matrox.com/mga/" name="www.matrox.com/mga"> + <p> + Here modifications to the DRI build instructions which make the + mga ddx driver use the MGAHAL library: + <verb> + 1.Put the following define in your host.def file + #define UseMatroxHal YES + 2. Place mgaHALlib.a in the following directory + xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/ + </verb> + <p> + You can use DualHead on the G400/G450 DH cards by creating two + device sections which both point to the same BusID. + For most AGP devices the BusID will be "PCI:1:0:0". + Configure your screen section as you would normally configure + XFree86 4.x Multihead. It should be noted that currently + the second head does not support direct rendering. + <P> + <sect2>Known Problems <p> - <itemize> - <item> - Multitexture is currently disabled on the G400 to work - around a hardware lockup bug. This should be restored in - a subsequent release. - </itemize> + None. + <p> <sect1>ATI Rage 128 -<p> + <p> + <sect2>Dependencies + <p> + A Linux kernel with AGP GART support (such as the 2.4.x test + kernels) is needed. + <p> <sect2>Configuration -<p> - Your XF86Config file's device section must specify the - <tt>r128</tt> device: - <verb> + <p> + Your XF86Config file's device section must specify the + <tt>r128</tt> device: + <verb> Section "Device" Identifier "Rage128" VendorName "ATI" @@ -852,7 +1099,7 @@ </verb> <p> The kernel module for the Rage 128 is named <tt>r128.o</tt> and - should be installed in /lib/modules/KERNEL-VERSION/misc/. + should be installed in /lib/modules/2.4.x/kernel/driver/char/drm/. It will be automatically loaded by the Xserver if needed. <p> The DRI 3D driver for the Rage 128 should be in @@ -880,7 +1127,7 @@ developed or supported. - <sect>Limitations and Known Bugs + <sect>General Limitations and Known Bugs <p> <sect1>OpenGL <p> @@ -888,7 +1135,8 @@ overlays, stereo, hardware-accelerated indirect rendering. <p> OpenGL-like functionality is provided with the Mesa library. - XFree86 4.0 uses a beta version Mesa 3.3. + XFree86 4.0.1 uses Mesa 3.3. + Subsequent releases of XFree86 will use newer versions of Mesa. When newer versions of Mesa are available, the 3D drivers can be updated without reinstalling XFree86 or libGL.so. @@ -898,17 +1146,20 @@ are operational. <p> The new <tt/glXGetProcAddressARB/ function is fully supported. + <p> + GLXPixmap rendering is only supported for indirect rendering + contexts. This is a common OpenGL limitation. Attempting + to use a direct rendering context with a GLXPixmap will result + in an X protocol error. + <p> - <sect1>Signal Handling -<p> - There are several understood, but unresolved problems relating - to hardware locking and signal handling. - Hitting CTRL-z to suspend a 3D application can sometimes cause - the X server to lock-up if executing device driver code at that - moment. - Also, using a debugger to step through OpenGL/Mesa device driver - functions code could cause a lock-up. - These problems will be fixed in the future. + <sect1>Debugging +<p> + Debugging DRI drivers with gdb can be difficult because of the + locking involved. When debugging OpenGL applications, you should + avoid stepping inside the GL functions. If you're trying to debug + a DRI driver it's recommended that you do so remotely, from a + second system. <sect1>Scheduling <p> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml:1.3 xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml:1.9 --- xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml:1.3 Fri Jun 16 22:16:49 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml Tue Dec 12 12:48:10 2000 @@ -2,27 +2,29 @@ <!ENTITY % defs SYSTEM "defs.ent"> %defs; ]> -<!-- Created: Sun Mar 12 13:00:00 2000 by brian@precisioninsight.com --> +<!-- Created: Sun Mar 12 13:00:00 2000 by brianp@valinux.com --> <!-- Revised: Fri May 19 09:36:02 2000 by martin@valinux.com --> +<!-- Revised: Sat Aug 19 14:00:00 2000 by brianp@valinux.com --> <article> <title>DRI Compilation Guide <author> - <htmlurl url="http://www.precisioninsight.com/" - name="Precision Insight, Inc."> - <date>18 May 2000 + <htmlurl url="http://www.valinux.com/" + name="VA Linux Systems, Inc."> Professional Services - Graphics. + <date>29 October 2000 <ident> - $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.3 2000/06/17 02:16:49 dawes Exp $ + $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.9 2000/12/12 17:48:10 alanh Exp $ </ident> <toc> <sect>Preamble <p> + <sect1>Copyright <p> - <bf>Copyright © 2000 by Precision Insight, Inc., - Cedar Park, Texas. + + <bf>Copyright © 2000 by VA Linux Systems, Inc. All Rights Reserved.</bf> <p> <bf>Permission is granted to make and distribute verbatim copies @@ -30,6 +32,7 @@ notice are preserved on all copies.</bf> <sect1>Trademarks <p> + OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics, Inc. Unix is a registered trademark of The Open Group. @@ -48,16 +51,18 @@ <sect>Introduction <p> + This document describes how to download, compile and install the DRI project. This information is intended for experienced Linux developers. Beginners are probably better off installing precompiled packages. <p> Edits, corrections and updates to this document may be mailed - to brian@precisioninsight.com. + to brianp@valinux.com. <sect>Prerequisites <p> + You'll need the following: <itemize> <item>At least 400MB of free disk space. More is needed if you want @@ -67,6 +72,9 @@ <item>GCC compiler and related tools. <item>ssh (secure shell) for registered developer downloading of the DRI source tree + <item>A recent Linux Kernel. See below for details. + <item>FreeBSD support is not currently being maintained and may not + work. </itemize> <p> @@ -77,35 +85,40 @@ These can be obtained from <htmlurl url="http://linux.3dfx.com/open_source/glide_kit.htm" name="linux.3dfx.com">. - <item>Linux kernel 2.2.x. - The DRI developers have been using stock RedHat 6.1 systems - (kernel 2.2.12-20). - Later kernel versions will be supported in the future. + <item>A recent Linux 2.4.x kernel. AGP support is not required. </itemize> <p> For Matrox G200/G400 hardware, you'll also need: <itemize> - <item>Linux kernel 2.3.51. Older kernel versions will not work. + <item>A recent Linux 2.4.x kernel with AGP support. </itemize> <p> For Intel i810 hardware, you'll also need: <itemize> - <item>Linux kernel 2.3.99-pre6. Older kernel versions will not work. + <item>A recent Linux 2.4.x kernel with AGP support. </itemize> <p> For ATI Rage hardware, you'll also need: <itemize> - <item>Linux kernel 2.3.51. Other kernel versions may work but - this one is known to work. + <item>A recent Linux 2.4.x kernel with AGP support. </itemize> + + <sect>Linux Kernel Preparation <p> - <sect>Kernel preparation <p> - You may have to upgrade your Linux kernel in order to use the DRI. - This is because you need a kernel version which supports AGP. + The DRI project closely tracks Linux kernel development. + Since the internal Linux data structures change frequently in + the 2.4 development branch it's important to have use the most + recent Linux kernel. + As of this writing (Nov 2000), 2.4.0-test11-pre5 is the most + recent version of Linux which the DRI is synchronized to. + <p> + Most of the DRI drivers require AGP support and using Intel + Pentium III SSE optimizations also requires an up-to-date Linux kernel. + <p> Building a new Linux kernel can be difficult for beginners but there are resources on the Internet to help. This document assumes experience with configuring, building and @@ -114,74 +127,70 @@ Linux kernels can be downloaded from <htmlurl url="http://www.kernel.org/pub/linux/kernel/" name="www.kernel.org"> - <p> - Download the needed kernel and put it in /usr/src. - Create a directory for the source and unpack it. - For example: - <verb> - cd /usr/src - rm -f linux - mkdir linux-2.3.51 - ln -s linux-2.3.51 linux - bzcat linux-2.3.51.tar.bz2 | tar xf - - </verb> <p> - Now configure your kernel. - You might, for example, use <tt>make menuconfig</tt> and do the - following: - + Here are the basic steps for kernel setup. <itemize> - <item>Go to <em>Code maturity level options</em> - <item>Enable <em>Prompt for development and/or incomplete - code/drivers</em> - <item>hit ESC - <item>Go to <em>Character devices</em> - <item>Disable <em>Direct Rendering Manager (XFree86 DRI support)</em> - since we'll use the DRI module from the XFree86/DRI tree. - <item>Go to <em>/dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)</em> - <item>Hit SPACE twice - <item>Enable all chipsets' support for AGP - </itemize> - - <p>It's recommended that you turn on MTRRs under <em>Processor type - and Features</em>, but not required. - - <p> - Configure the rest of the kernel as required for your system - (i.e. Ethernet, SCSI, etc) - <p> - Exit, saving your kernel configuration. - <p> - Edit your /etc/lilo.conf file. - Make sure you have an image entry as follows (or similar): + <item>Download the needed kernel and put it in /usr/src. + Create a directory for the source and unpack it. + For example: + <verb> + cd /usr/src + rm -f linux + mkdir linux-2.4.x + ln -s linux-2.4.x linux + bzcat linux-2.4.x.tar.bz2 | tar xf - + </verb> + <item>Configure your kernel. + You might, for example, use <tt>make menuconfig</tt> and do the + following: + + <itemize> + <item>Go to <em>Code maturity level options</em> + <item>Enable <em>Prompt for development and/or incomplete + code/drivers</em> + <item>hit ESC to return to the top-level menu + <item>Go to <em>Character devices</em> + <item>Disable <em>Direct Rendering Manager (XFree86 DRI support)</em> + since we'll use the DRI module from the XFree86/DRI tree. + <item>Go to <em>/dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)</em> + <item>Hit SPACE twice to build AGP support into the kernel + <item>Enable all chipsets' support for AGP + <item>It's recommended that you turn on MTRRs under + <em>Processor type and Features</em>, but not required. + </itemize> + <item>Configure the rest of the kernel as required for your system + (i.e. Ethernet, SCSI, etc) + <item>Exit, saving your kernel configuration. + <item>Edit your /etc/lilo.conf file. + Make sure you have an image entry as follows (or similar): <verb> image=/boot/vmlinuz - label=linux.2.3.51 + label=linux.2.4.x read-only root=/dev/hda1 </verb> - <p> - The important part is that you have /boot/vmlinuz without a - trailing version number. - If this is the first entry in your /etc/lilo.conf AND you - haven't set a default, then this will be your default kernel. - - <p> - Now compile the new kernel: - - <verb> - cd /usr/src/linux-2.3.51 - make dep ; make bzImage - make modules ; make modules_install - make install - </verb> - Note that the final part, make install, will automatically run - lilo for you. - <p> - Now reboot to use this new kernel. + The important part is that you have /boot/vmlinuz without a + trailing version number. + If this is the first entry in your /etc/lilo.conf AND you + haven't set a default, then this will be your default kernel. + <item>Compile the new kernel. + <verb> + cd /usr/src/linux-2.4.x + make dep + make bzImage + make modules + make modules_install + make install + </verb> + Note that last make command will automatically run lilo for you. + <item>Upgrade your modutils package for Linux 2.4.x if you're + upgrading from Linux 2.2.x. + <item>Now reboot to use the new kernel. + </itemize> <sect>Downloading the XFree86/DRI CVS Sources <p> + The DRI project is hosted by VA Linux Systems' <htmlurl url="http://sourceforge.net/project/?group_id=387" name="SourceForge">. @@ -195,6 +204,7 @@ in the mailing lists. <sect1>Anonymous CVS download: <p> + <enum> <item>Create a directory to store the CVS files: <p> @@ -220,6 +230,7 @@ <sect1>Registered CVS download: <p> + <enum> <item>Create a directory to store the CVS files: <p> @@ -250,20 +261,39 @@ </enum> - <sect>Updating your CVS sources <p> - In the future you'll want to occasionally update your local copy of - the DRI source code to get the latest changes. - This can be done with: - <verb> - cd ~/DRI-CVS - cvs -z3 update -dA xc - </verb> - The -d flag causes any new subdirectories to be created and -A causes - most recent trunk sources to be fetched, not branch sources. + <sect1>Updating your CVS sources <p> + In the future you'll want to occasionally update your local copy of + the DRI source code to get the latest changes. + This can be done with: + <verb> + cd ~/DRI-CVS + cvs -z3 update -dA xc + </verb> + The -d flag causes any new subdirectories to be created and -A causes + most recent trunk sources to be fetched, not branch sources. + + + <sect>Mesa <p> + + Most of the DRI 3D drivers are based on Mesa (the free implementation + of the OpenGL API). + The relevant files from Mesa are already included in the XFree86/DRI + source tree. + <em>There is no need to download or install the Mesa source files + separately.</em> + <p> + Sometimes a newer version of Mesa will be available than the version + included in XFree86/DRI. + Upgrading Mesa within XFree86/DRI is not always straightforward. + It can be an error-prone undertaking, especially for beginners, and is + not generally recommended. + The DRI developers will upgrade Mesa when appropriate. + <p> <sect>Compiling the XFree86/DRI tree <p> <sect1>Make a build tree <p> + Rather than placing object files and library files right in the source tree, they're instead put into a parallel <em>build</em> tree. The build tree is made with the <tt>lndir</tt> command: @@ -282,6 +312,7 @@ testing with different options. <sect1>Edit the host.def file <p> + <p> The <tt>~/DRI-CVS/build/xc/config/cf/host.def</tt> file is used to configure the XFree86 build process. You can change it to customize your build options or make adjustments @@ -290,7 +321,8 @@ The default <tt>host.def</tt> file will look something like this: <verb> #define DefaultCCOptions -Wall - #define DefaultGcc2i386Opt -O2 +(i386) #define DefaultGcc2i386Opt -O2 +(Alpha) #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar) #define LibraryCDebugFlags -O2 #define BuildServersOnly YES #define XF86CardDrivers vga tdfx mga r128 i810 @@ -311,7 +343,7 @@ would overwrite your default X files. The following is recommended: <verb> - #define ProjectRoot /usr/XF86-main + #define ProjectRoot /usr/X11R6-DRI </verb> <p> Especially note the <em>XF86CardDrivers</em> line to be sure your @@ -325,7 +357,8 @@ line in <tt>host.def</tt>. <p> - <sect1>Compile <p> + <sect1>Compilation <p> + To compile the complete DRI tree: <verb> cd ~/DRI-CVS/build/xc/ @@ -342,8 +375,13 @@ <p> Building will take some time so you may want to go check your email or visit slashdot. + <p> + <em>WARNING:</em> do not use the -j option with make. + It's reported that it does not work with XFree86/DRI. + <p> <sect1>Check for compilation errors <p> + Using your text editor, examine <tt>World.LOG</tt> for errors by searching for the pattern <tt>***</tt>. <p> @@ -363,124 +401,218 @@ The most recent kernels are not always supported. <p> If your build machine is running a different version of the kernel - than your target machine (i.e. 2.2.12-20 vs. 2.3.99-pre6), make will + than your target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel headers. This can be fixed by explicitly setting the value of <tt>TREE</tt>. If the path to your kernel source is - <tt>/bigdisk/linux-2.3.99-pre6</tt>, + <tt>/usr/src/linux-2.4.x</tt>, <verb> cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel - make TREE=/bigdisk/linux-2.3.99-pre6 + make TREE=/usr/src/linux-2.4 </verb> or alternatively, edit Makefile to include this change. <p> - After fixing the errors, do <tt>make World</tt> again. + After fixing the errors, run <tt>make World</tt> again. Later, you might just compile parts of the source tree but it's important that the whole tree will build first. + <sect1>DRI kernel module installation <p> - <sect>Installing <p> - After the DRI tree has been compiled you can install the XFree86 - headers, libraries, programs, etc for testing. + The DRI kernel modules are in + <tt>~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/</tt>. + <p> + To load the appropriate DRI module in your running kernel you can + either use ismod and restart your X server or copy the kernel module + to <tt>/lib/modules/2.4.x/kernel/driver/char/drm/</tt> then run + depmod and restart your X server. + <p> + Make sure you first unload any older DRI kernel modules that might + be already loaded. + <p> + + <sect>Normal Installation and Configuration <p> + + Most users will want to install the new X server and use it instead + of the original X server. + This section explains how to do that. + We assume that the user is upgrading from XFree86 3.3.x. + <p> + Developers, on the other hand, may just want to test the X server + without actually installing it as their default server. + If you want to do that, skip to the next section. + <p> <sect1>X Installation <p> - As mentioned above, the install directory is specified by the + + You'll need to run as root to do the following commands: + <verb> + su + </verb> + As mentioned above, the installation directory is specified by the <tt>ProjectRoot</tt> variable in the <tt>host.def</tt> file. - Create that directory now if it doesn't already exist: + Create that directory now if it doesn't already exist, then + run the install commands: <verb> - mkdir /usr/XF86-main - </verb> - <p> - You'll have to change to root since the install process puts - several files in <tt>/etc/X11/</tt> and sets the setuid flag on - the X server executable. - <verb> + mkdir /usr/X11R6-DRI cd ~/DRI-CVS/build/xc - su make install </verb> + + <sect1>Linker configuration <p> + Edit your <tt>/etc/ld.so.conf</tt> file and put - <tt>/usr/XF86-main/lib</tt> as the first line. - Continue with: + <tt>/usr/X11R6-DRI/lib</tt> as the first line. + Then run: <verb> ldconfig - exit </verb> - <p> - Look in <tt>/usr/XF86-main</tt> to be sure the files installed - there. - <P> - Strictly speaking, installing the DRI tree isn't required. - It's possible to run and test the X server directly from the - build directory but it's a bit error prone. + This will ensure that you use the new X libraries when you run + X programs. + <p> <sect1>Update Locale Information <p> + To update your X locale information do the following: <verb> cd ~/DRI-CVS/build/xc/nls - xmkmf -a + ../config/util/xmkmf -a make make install </verb> This will prevent a locale error message from being printed when you run Xlib programs. - <sect>X Server Configuration <p> - If your X server is currently running you'll have to stop it - and return to a virtual terminal. - <p> - First, setup your XF86Config file. - It should load the GLX and DRI modules and specify the driver to - use for your hardware. - See the <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html" - name="DRI User Guide"> for detailed information. - <p> - You may want to make a backup copy of your existing - <tt>/etc/X11/XF86Config</tt> file first. - <p> - It's very important that you set the <tt>ModulePath</tt> option to - point to your installation directory: - <verb> - ModulePath "/usr/XF86-main/lib/modules" - </verb> + <sect1>Setup Miscellaneous Files <p> + + Issue the following commands: + <verb> + cd /usr/X11R6-DRI/lib/X11 + ln -s /usr/X11R6/lib/X11/rgb.txt . + ln -s /usr/X11R6/lib/X11/fonts . + ln -s /usr/X11R6/lib/X11/app-defaults . + </verb> + + This will allow applications to use the fonts and resources + that they used in the past. + + <sect1>Disable the Old X Server and Enable the New One <p> + + Assuming that an installation of XFree86 3.3.x is present, we need + to disable the old 3.3.x X server and enable the new 4.0.x X server. + <p> + Issue the following commands: + <verb> + cd /usr/X11R6/bin + mv Xwrapper Xwrapper.old + rm X + ln -s /usr/X11R6-DRI/bin/XFree86 X + </verb> + This will cause the new X server to be used instead of the + original one. + <p> + + <sect1>Create the XF86Config File <p> + + Configuration files for XFree86 3.3.x will not work with + XFree86 4.0.x. + <p> + The new 4.0.x server can generate a basic configuration file + itself. + Simply do this: + <verb> + cd /usr/X11R6-DRI/bin + ./XFree86 -configure + </verb> + A file named <tt>/root/XF86Config.new</tt> will be created. + It should allow you to try your X server but you'll almost + certainly have to edit it. + For example, you should add <tt>HorizSync</tt> and + <tt>VertRefresh</tt> options to the <tt>Monitor</tt> section + and <tt>Modes</tt> options to the <tt>Screen</tt> section. + Also, the <tt>ModulePath</tt> option in the <tt>Files</tt> + section should be set to <tt>/usr/X11R6-DRI/lib/modules</tt>. + <p> + On the DRI web site, in the resources section, you'll find example + XF86Config files for a number of graphics cards. + These configuration files also setup DRI options so it's highly + recommended that you look at these examples. + <p> + In any case, your new XF86Config file should be placed in + <tt>/etc/X11/XF86Config-4</tt>. + This configuration file will be recognized by the 4.0.x server + but not by 3.3.x servers. + You can instead name it <tt>/etc/X11/XF86Config</tt> but + that'll overwrite your old config file, which you may want to + preserve. + <p> + + <sect1>Start the New X Server <p> + + The new X server should be ready to use now. + Start your X server in your usual manner. + Typically, the <tt>startx</tt> command is used: + <verb> + startx + </verb> + + + <sect>Testing the Server Without Installing It <p> + + As mentioned at the start of section 8, developers may want to + simply run the X server without installing it. + This can save some time and allow you to keep a number of X servers + available for testing. <p> - Double check with this: - <verb> - grep ModulePath /etc/X11/XF86Config - </verb> + + <sect1>Configuration <p> + As described in the preceding section, you'll need to create a + configuration file for the new server. + Put the <tt>XF86Config</tt> file in your + <tt>~/DRI-CVS/build/xc/programs/Xserver</tt> directory. <p> - Next, your <tt>~/.xinitrc</tt> file controls which clients will be - launched when your X server starts. - You might put the following in yours: - <verb> - xset b off - xsetroot -solid "#004070" - xmodmap -e "clear mod4" - xrdb -merge ~/.Xdefaults - xterm -geometry +0+0 & - xterm -geometry +512+0 & - fvwm - </verb> + Be sure the <tt>ModulePath</tt> option is set correctly. <p> - <sect>X Server Start-up <p> - The X server can be started with: - <p> + <sect1>A Startup Script <p> + A simple shell script can be used to start the X server. + Here's an example. <verb> - xinit -- /usr/XF86-main/bin/XFree86 + #!/bin/sh + export DISPLAY=:0 + ./XFree86 -xf86config XF86Config & \ + sleep 2 + fvwm2 & + xset b off + xmodmap -e "clear mod4" + xsetroot -solid "#00306f" + xterm -geometry 80x40+0+0 </verb> - <p> - Automatic loading of DRM kernel modules was added to the X server - in XFree86 4.0.1. - This feature, and manual loading of kernel modules, is documented - in the DRI user guide. - <p> + You might name this script <tt>start-dri</tt>. + Put it in your <tt>~/DRI-CVS/build/xc/programs/Xserver</tt> + directory. + <p> + To test the server run the script: + <verb> + cd ~/DRI-CVS/build/xc/programs/Xserver + ./start-dri + </verb> + For debugging, you may also want to capture the log messages + printed by the server in a file. + If you're using the C-shell: + <verb> + ./start-dri >& log + </verb> + + + <sect>Where To Go From Here <p> + At this point your X server should be up and running with hardware-accelerated direct rendering. Please read the <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html" - name="DRI User Guide"> for trouble shooting information. - + name="DRI User Guide"> for information about trouble shooting + and how to use the DRI-enabled X server for 3D applications. + <p> </article> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/Darwin.sgml diff -u /dev/null xc/programs/Xserver/hw/xfree86/doc/sgml/Darwin.sgml:1.4 --- /dev/null Mon Dec 18 14:29:50 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/Darwin.sgml Tue Dec 12 13:54:29 2000 @@ -0,0 +1,424 @@ +<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN" [ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> + +<article> +<title>XFree86 on Darwin and Mac OS X +<author>Torrey T. Lyons +<date>11 December 2000 + +<ident> +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Darwin.sgml,v 1.4 2000/12/12 18:54:29 dawes Exp $ +</ident> + +<toc> + +<sect>Introduction +<p> +<htmlurl url="http://www.xfree86.org/" name="XFree86">, a free +implementation of X Windows, has been ported to <htmlurl +url="http://www.publicsource.apple.com/projects/darwin/" name="Darwin"> +and <htmlurl url="http://www.apple.com/macosx/" name="Mac OS X">. This +document is +a collection of information for anyone +experimenting with running X Windows on Apple's next generation operating +system. Please send any comments on this page to +<email/torrey@mrcla.com/. If you are also +working on modifications to the Darwin X server, please let me know. + +<sect>Hardware Support and Configuration +<p> +The Darwin port of XFree86 uses the IOKit for device driver loading +and discovery, rather than the XFree86 module loader. Because of this, +the XFree86 configuration file is not used on Darwin systems. The +descriptions found elsewhere of devices supported by XFree86 for other +operating systems also do not apply. + +<p> +XFree86 for Darwin will work with any video card that you have an +IOKit driver for. If you are running Mac OS X, this typically means +any card that has been shipped by Apple. If a card works for you with +the Mac OS X GUI, it will work on the same machine with XFree86. If +you have a pure Darwin installation, your hardware support may be +somewhat limited because Apple does not include all its hardware +drivers with Darwin. IOKit drivers are typically found in +/System/Library/Extensions/ or /Library/Extensions/. + +<p> +Multi-button and scroll wheel mouse support works well with all +USB mice that I have tested. I have done no testing with serial +mice. + +<sect>Getting Started +<p> +Following are instructions for building and running your own copy of +XFree86. The procedure for getting your X server up and running on +Darwin and Mac OS X are very similar, but it is actually somewhat more +difficult on Mac OS X. Where there are differences I have noted them +below. Both Mac OS X Developers' Preview 4 and Mac OS X +Public Beta are covered. Note that to build XFree86 for yourself on +Mac OS X Beta, you will need to have the Developers' Tools. If +you did not receive these as a member of ADC, they are available for +download from the <htmlurl url="http://www.apple.com/developer/" +name="Apple Developer Connection">. + +<p> +If you want to save some time, you can use the precompiled binaries +provided by the XFree86 server at <url +url="ftp://ftp.xfree86.org/pub/XFree86/&relvers;/binaries/Darwin/">. +Follow the instructions in the <htmlurl +url="http://www.xfree86.org/&relvers;/Install.html" name="Install"> +document to install it. + +<p> +This will create two new directory trees, <tt>/usr/X11R6</tt> and +<tt>/private/etc/X11</tt>. If you have the developers' tools, you may +have to run ranlib on all the libraries in <tt>/usr/X11R6/lib/*</tt> +before trying to build other X applications. + +<p> +If you get the precompiled binaries you can skip ahead to the section +on <ref id="running" name="running X windows"> + +<p> +On the other hand, if you want to build things yourself from scratch, +follow the directions below. + +<p> +If you want to recompile the X server on Mac OS X, you will have to +make the header files as described <ref id="makeHeaders" +name="below">. + +<sect1> Get the Code + +<p> +The first thing you need to do is to get the source code from the +XFree86 project. + +<itemize> +<item> Setup CVS: Both Darwin and Mac OS X include CVS (Concurrent +Versions System), which is an easy way to download and keep up to date +with open source code released by XFree86 and others. You do have to +setup CVS properly, however, to tell it where to look. Follow the +instructions <htmlurl url="http://www.xfree86.org/cvs/" name="here"> on +how to do this either via ssh or via the cvs pserver. + +<item> Now make a directory in some convenient place which will serve +as your top level directory for you open source development efforts. I +am going to call this directory <tt>sandbox/</tt> in the following discussions +and you could put this directory, for example, in <tt>~/sandbox/</tt>. + +<item>From the command line type: +<tscreen><verb> +cd sandbox +cvs checkout xc +</verb></tscreen> +Wait for all the files to complete downloading. + +</itemize> + +<sect1>Make Header Files for Mac OS X<label id="makeHeaders"> +<p> + +These next steps are not necessary if you are building XFree86 on +Darwin. Mac OS X Beta or DP4 does not include many of the +"in-progress" header files that are needed to successfully +build XFree86. The general philosophy is that at any given time, Mac +OS X will include only headers files that are "ready for prime +time" while Darwin will include a snapshot of Apple's current +efforts. So if you have access to a Darwin system, I would suggest +using this instead of Mac OS X to build XFree86. If you don't, read +the appropriate page below for an outline of what you need to do: + +<itemize> +<item><ref id="headersXBeta" name="Mac OS X Public Beta"> +<item><ref id="headersXDP4" name="Mac OS X Developers' Preview 4"> +</itemize> + +<sect1> Build XFree86 +<p> +Once you have everything ready it is easy to build and install +XFree86. From the command line: + +<tscreen><verb> +cd sandbox/xc +make World >& world.log + +(wait for several hours) + +su root +make install >& install.log +make install.man >& man.log +</verb></tscreen> + +<sect>Run X Windows<label id="running"> +<p> +You will want to add the X windows executables to your path. Your path +is the list of directories to be searched when you type a command. You +will also want to add the man pages from XFree86 to the list of pages +to be searched when you are looking for documentation. The way to do +this depends on the shell you are using. With tcsh or csh add the +following two lines to a file in your home directory called <tt/.cshrc/ +(create this file if you don't have one yet): +<tscreen><verb> +setenv MANPATH "${MANPATH}:/usr/X11R6/man:/usr/local/man" +setenv PATH "${PATH}:/usr/X11R6/bin" +</verb></tscreen> +Now type ``<tt>source ~/.cshrc;rehash</tt>'' to +get these changes to take effect. On future logins, this file will be +executed automatically. + +<p> +You are now ready to go. On Mac OS X, you have to do a few extra steps +each time you want to run X windows. You can't run XFree86 with +CoreGraphics running since they both want to control the screen. So +for Mac OS X you first need to logout. Then for Mac OS X DP4, from the +login window type ``console'' as the user name and push +login. For Mac OS X Beta, type ``>console'' as the user +name. This should shutdown CoreGraphics and bring you up with a text +console. Login again. + +<p> +Now from the text console you can start X Windows in either Darwin or +Mac OS X by typing ``startx''. After a brief wait at least one terminal +window should pop up for you. So far it probably isn't very impressive +as you might not even have a window manager running to allow you to +move windows around. + +<p> +When you are ready to quit X windows type ``exit'' in the main +terminal window or quit with the window manager if you have one +running. Unfortunately the X server won't shutdown correctly and you +will get an apparently frozen screen with only a spinning beachball +cursor on it. Nothing you type shows up on the screen, but in fact +your keystrokes are being received by the console. Type +``logout'' to return to normalcy after a brief delay. With +Darwin this should put you back at the text console login prompt. With +Mac OS X, CoreGraphics will restart and you should be given a login +window. + +<p> +<bf/Customize X Windows/ +<p> + +X windows is very customizable and you will certainly want to change +some things. There is a lot you can do to control how your windows +look, how the windows are moved, resized, etc. You will likely want to +get a better window manager than twm, which is included with +XFree86. The <tt>.xinitrc</tt> file in your home directory controls what +programs are run when you start X windows. You can find a sample +<tt>.xinitrc</tt> file in <tt>/private/etc/X11/xinit/xinitrc</tt>. + +<p> +There are several +window managers that have been ported to Darwin. The best collection +of window managers and other X windows applications is at <htmlurl +url="http://www.darwinfo.org/ports.shtml#X Windows" name="Darwinfo's ports +page">. Another good place to look for Darwin ports in general is at +<htmlurl +url="http://softrak.stepwise.com/Apps/WebObjects/Softrak" name="Stepwise's +Softrak site">. + +<p> +Good luck! + +<sect>Outstanding Issues with the X server + +<p> +There is a still a lot to be done with the X server. As always please +let me know if you are interested in working on any of these issues. + +<bf/Things that are broken:/ +<itemize> +<item>The bell is broken. + +<item>Server shutdown problem: After quitting the X server the colored +beachball cursor reappears, but the screen never returns to the +console display. The console is accepting input however, so typing +``logout'' will return you to the login prompt. + +<item>Only one display is currently supported. + +<item>Screen saver not supported. + +<item>Key repeat rate can not be adjusted. +</itemize> + +<bf/Things I am working on:/ +<itemize> +<item> Allowing rootless use on Mac OS X +<item> Correct wake from sleep behavior +</itemize> + +<sect>Appendix + +<sect1>Installing IOKit Header files on Mac OS X Beta<label + id="headersXBeta"> +<p> +Here is what you need to do to be able to build XFree86 (or other +clients of IOGraphics services) on Mac OS X Public Beta. +<enum> + +<item>You need to install some more build tools that aren't included +in Mac OS X Beta, but are included in Darwin. These are needed for the +next step. Go to your development directory and type: +<tscreen><verb> +cvs checkout bootstrap_cmds +cd bootstrap_cmds +make +</verb></tscreen> +Now su to root and do a ``make install'' from the bootstrap_cmds +directory. + +<item> +The IOKit framework included with Mac OS X Beta is a little on the +wimpy side, even after installing the Developer Tools. You'll need to +rebuild it, but to do so safely we'll take advantage of the cool +directory structure of Mac OS X and put the new version in +/Library/Frameworks/. This will override the version in +/System/Library/Frameworks/. Or at least, that's where you should put +it using the new Mac OS X Beta file structure, but in fact the +compiler doesn't know this and still looks in +/Local/Library/Frameworks. (I have already filed a developer's bug +report on this.) To start we make a copy of the original. Login as +root and do the following: +<tscreen><verb> +cd /Library +mkdir -p Frameworks +cp -R /System/Library/Frameworks/IOKit.framework Frameworks/IOKit.framework +cd / +mkdir -p Local +ln -s /Library /Local/Library +</verb></tscreen> + +<item>Now you need to get a full version of the IOKit framework from +the Darwin repository. This comes as part of the kernel. So, in your +development directory again: + +<tscreen><verb> +cvs checkout xnu +cd xnu +source SETUP/setup.csh +make exporthdrs +make install +</verb></tscreen> + +The "make install" will start by assembling all the headers you need, +but then will proceed to build a new kernel. You can Control-C out of +the build once it starts compiling things if you want. Otherwise, just +be patient. + +<item> +You also need to get the IOKitUser project, which contains the user +interface to the IOKit, and merge it into the IOKit framework. From +your development directory type: +<tscreen><verb> +cvs checkout IOKitUser +</verb></tscreen> +Then you need to change the Makefile so it builds on top of the new +IOKit framework you are building. Change to the IOKitUser project +directory and edit the Makefile. Change the following line: +<tscreen><verb> +NEXTSTEP_BUILD_OUTPUT_DIR = /$(USER)/build/$(NAME) +</verb></tscreen> +to: +<tscreen><verb> +NEXTSTEP_BUILD_OUTPUT_DIR = <your xnudir>/BUILD/dst/System/Library/Frameworks +</verb></tscreen> + +Now, run ``make'' while in the IOKitUser directory. It will likely not +finish building since the IOKitUser project relies on some stuff that +Apple hasn't really made public yet, but it should finish populating +the new IOKit framework with headers and start compiling. (Strangely +enough, the headers installed in your new IOKit framework don't contain +the real header files. They are just single line files with an #import +of the file in your IOKitUser project. This works fine as long as you +don't ever delete or move your IOKitUser project. I imagine that using +``make install'' would fix this up, but you can't do this as long as the +project doesn't build correctly. So for now you can either move the +header files by hand, or make sure you leave your IOKitUser project in +place.) + +<item> +Now put the new IOKit headers into our local copy. Change to the xnu +project directory and do the following as root: +<tscreen><verb> +cd BUILD/dst/System/Library/Frameworks/ +cp -R IOKit.framework/Versions/A/Headers/* \ + /Library/Frameworks/IOKit.framework/Versions/A/Headers +</verb></tscreen> + +<item> +The System framework needs touching up a bit too. You need to copy the +libkern header files from the new System.framework. As root, go to the +xnu project directory and type: (Of course you could make a local copy +of the System framework in /Library/Frameworks/, but the additions to +the System framework are small.) +<tscreen><verb> +cd BUILD/dst/System/Library/Frameworks/System.framework/Versions/B/Headers +cp -R libkern /System/Library/Frameworks/System.framework/Headers/libkern +</verb></tscreen> +</enum> + +<sect1>Installing IOKit Header files on Mac OS X DP4<label +id="headersXDP4"> +<p> +Here is an outline of what you need to do to be able to build XFree86 +(or other clients of IOGraphics services) on Mac OS X Developers' +Preview 4. + +<enum> + +<item>Checkout, build, and install bootstrap_cmds from the CVS +repository. +<item>Checkout xnu from the CVS repository. Go to sandbox/xnu and do +the following: +<tscreen><verb> +source SETUP/setup.csh +make exporthdrs +</verb></tscreen> +<item>su to root and do the following: +<tscreen><verb> +mkdir -p /Local/Library/Frameworks +cp -R /System/Library/Frameworks/IOKit.framework /Local/Library/Frameworks +</verb></tscreen> +This will create a new local version of the IOKit framework that will +override the System version without changing the original. + +<item>You now want to merge the IOKit headers from the xnu project +into your local IOKit framework. I did this fairly tediously by hand, +but I would suggest something like: +<tscreen><verb> +cp -R sandbox/xnu/BUILD/dst/System/Library/Frameworks/IOKit.framework/Versions/A/Headers \ +/Local/Library/Frameworks/IOKit.framework/Versions/A +</verb></tscreen> +The only problem with this is that there are a few stub header files +included that are just a single line with an #import to the +appropriate place in the xnu source on your disk. This is fine as long +as you don't move your xnu project. If you do, you can copy the +original file to replace the stub. There is probably an easier way to +automatically build a clean version of the IOKit framework, but I +didn't find it. (Let me know if you do.) + +<item>There are just a few more files you need in the IOKit +framework. Checkout the IO project from CVS. Get the necessary header +files from there and put them in your new local IOKit +framework. You'll get errors when you try to build XFree86 from which +you can tell which files are needed. I also needed to make the +following patch to IOLLEvent.h. Your mileage may vary. +<tscreen><verb> +47c47 +< #include <Kernel/libkern/OSTypes.h> +--- +> #include <libkern/OSTypes.h> +</verb></tscreen> + +<item>You'll also need a few extra CoreFoundation header +files. Checkout CoreFoundation. You can make a new local version of +the CoreFoundation framework as above, or just add to the existing +one. The files you need are CFMachPort.h and CFMessagePort.h in the +RunLoop.subproj and CFStorage.h in Collections.subproj. +</enum> + +</article> + Index: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml:1.3 xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml:1.6 --- xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml:1.3 Sat Aug 28 06:43:32 1999 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml Tue Dec 12 20:55:47 2000 @@ -1,9 +1,15 @@ -<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN"> +<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN"[ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> <article> <title>Information for Number Nine I128 Users <author>The XFree86 Project Inc. -<date>24 October 1998 +<date>3 November 2000 +<ident> +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.6 2000/12/13 01:55:47 robin Exp $ +</ident> + <toc> <sect>Supported hardware @@ -45,15 +51,15 @@ the setup program to probe for clocks. The driver will auto-detect the amount of video ram present. -The following Section "Device" options are supported by the MGA driver: +The following Section "Device" options are supported by the I128 driver: <itemize> -<item>Option "dac_8_bit" +<item>Option "Dac6Bit" <p> -Will enable 8-bit DAC support. -<item>Option "no_accel" +Will enable 6-bit DAC support. +<item>Option "NoAccel" <p> Will disable all hardware acceleration. -<item>Option "sync_on_green" +<item>Option "SyncOnGreen" <p> Will enable syncing on green for sync-on-green monitors (these are typically fixed frequency workstation monitors). @@ -72,19 +78,22 @@ <item>Modeline "800x512d08" 54.375 800 800 840 848 512 512 514 515 HSkew 1 DoubleScan +Hsync +Vsync </itemize> +<p> +<itemize> +<item>These lines are required for use with the SGI Multilink Adapter and the SiliconGraphics Flat Panel display. +<item>Modeline "1600x1024g" 108.0 1600 1616 1656 1704 1024 1027 1030 1056 -Hsync -Vsync +<item>Option "OverridePolarity" "1" +</itemize> + <sect>Author(s) <p> -Robin Cutshaw, <it>robin@XFree86.Org</it> +Robin Cutshaw, <email>robin@XFree86.Org</email> and special help from: <itemize> -<item>Galen Brooks, <it>galen@nine.com</it> +<item>Galen Brooks, <email>galen@interlabs.com</email> </itemize> - -<verb> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/I128.sgml,v 1.3 1999/08/28 10:43:32 dawes Exp $ -</verb> </article> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile:3.64 xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile:3.69 --- xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile:3.64 Fri Jun 16 22:16:49 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile Sun Dec 17 21:43:50 2000 @@ -3,7 +3,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.64 2000/06/17 02:16:49 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.69 2000/12/18 02:43:50 dawes Exp $ #include <Server.tmpl> #include <lnxdoc.rules> @@ -13,14 +13,16 @@ INDEXLIST = README.sgml RELNOTES.sgml Status.sgml LICENSE.sgml Install.sgml \ DESIGN.sgml \ mouse.sgml fonts.sgml DRI.sgml DRIcomp.sgml \ - isc.sgml LynxOS.sgml NetBSD.sgml OpenBSD.sgml OS2note.sgml \ + Darwin.sgml isc.sgml LynxOS.sgml NetBSD.sgml OpenBSD.sgml \ + OS2note.sgml \ apm.sgml ati.sgml chips.sgml cyrix.sgml DECtga.sgml \ - i740.sgml i810.sgml \ + I128.sgml i740.sgml i810.sgml newport.sgml \ r128.sgml rendition.sgml s3virge.sgml SiS.sgml #ifdef DEADDOCS LinuxDocReadmeTarget(Bsdi) #endif +LinuxDocReadmeTarget(Darwin) #ifdef OUTOFDATE LinuxDocReadmeTarget(DGUX) LinuxDocReadmeTarget(FreeBSD) @@ -61,12 +63,15 @@ #ifdef OUTOFDATE LinuxDocReadmeTarget(epson) LinuxDocReadmeTarget(fbdev) -LinuxDocReadmeTarget(I128) #endif +LinuxDocReadmeTarget(I128) LinuxDocReadmeTarget(i740) LinuxDocReadmeTarget(i810) #ifdef OUTOFDATE LinuxDocReadmeTarget(neomagic) +#endif +LinuxDocReadmeTarget(newport) +#ifdef OUTOFDATE LinuxDocReadmeTarget(Mach32) LinuxDocReadmeTarget(Mach64) LinuxDocReadmeTarget(MGA) @@ -141,4 +146,7 @@ FORMATTEDDIR = .. + +/* Update RELNOTES at top level */ +UpdateFormattedDoc(RELNOTES,$(TOP)) Index: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml:1.6 xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml:1.10 --- xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml:1.6 Sat Jul 1 22:35:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml Fri Dec 15 14:09:06 2000 @@ -6,10 +6,10 @@ <title>Installation Details for XFree86™ &relvers; <author>The XFree86 Project, Inc -<date>30 June 2000 +<date>15 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.6 2000/07/02 02:35:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.10 2000/12/15 19:09:06 dawes Exp $ </ident> <abstract> @@ -26,8 +26,8 @@ as provided by The XFree86 Project. <p> -The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs -and Solaris) are packaged in a platform-independent gzipped format (aka +The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs, +Solaris, etc) are packaged in a platform-independent gzipped tar format (aka "tarballs" identified by the <tt>.tgz</tt> suffix). Along with the binaries we provide a customized version of the GNU tar utility called "extract" and an installation script. We recommend that these be @@ -36,7 +36,7 @@ <sect>Downloading the XFree86 &relvers; binaries <p> -We, The XFree86 Project, provide XFree86 &relvers; binaries for a range +We provide XFree86 &relvers; binaries for a range of operating systems at our <![ %snapshot; [ <url name="ftp site" @@ -46,7 +46,7 @@ <url name="ftp site" url="ftp://ftp.xfree86.org/pub/XFree86/&relvers/binaries/">. ]]> -Often during releases, our ftp site is heavily loaded. Instead of +Often during releases our ftp site is heavily loaded. Instead of downloading directly from us we recommend that instead you use one of our mirror sites. Another advantage of using our mirror sites is that some of them support http access (ours does not). @@ -54,25 +54,36 @@ <p> Our binaries are organized by sub-directories which correspond to each of the OS/platforms for which we provide binaries. First go to the -sub-directory that represents your OS Platform. In some cases (e.g., +sub-directory that represents your OS platform. In some cases (e.g., Linux) there may be a number of choices depending on the architecture or libc version your platform uses. In all case we recommend that you first download the <tt>Xinstall.sh</tt> script, and run it as in the -following example to find out which binary distribution you should +following example to find out which binary distribution you should download. <tscreen><verb> sh Xinstall.sh -check </verb></tscreen> -The output of this utility tells you which is the correct set of binaries -for you to download. If you are careful with this step you will save -yourself a lot time and trouble from NOT downloading an incompatible +The output of this utility tells you which is the correct set of binaries +for you to download. If you are careful with this step you will save +yourself a lot time and trouble from NOT downloading an incompatible distribution. -Once that is done download the necessary files. The twelve (12) -mandatory files for all installations are listed below. If you have -not downloaded all of the files, the installer script will complain. +<bf>NOTE</bf>: the Xinstall.sh script must be downloaded in binary mode, +otherwise it won't run correctly. If you get lots of "command not found" +messages when you try to run it, then it is most likely because the +script wasn't downloaded in binary mode. Some web browsers won't do +this for files of that name, so we also have a copy of it called +"<tt>Xinstall.bin</tt>", and most browsers should download that correctly. +When downloading it under this name, select "save as" on your browser, +and save the file under the name "<tt>Xinstall.sh</tt>". + +Once you're run the <tt>Xinstall.sh</tt> script and found which binary +distribution is suitable for your system, download the necessary files. +The twelve (12) mandatory files for all installations are listed below. +If you have not downloaded all of the files, the installer script will +complain. <quote><verb> 1. Xinstall.sh The installer script @@ -100,6 +111,9 @@ tarball. If it is present in the <tt>binaries</tt> sub-directory for your platform, then it is required. + <item>The Darwin/Mac OS X distribution doesn't have or require the + <tt>Xmod.tgz</tt> tarball. + <item>Some distributions may have additional mandatory tarballs. While rare, the installer script will tell you if any are missing. @@ -262,15 +276,20 @@ <sect1>After the installation is complete <p> The next step is to configure the X server. That is covered in detail -in an as-yet unwritten document :-(. In the meantime, there are two +in an as-yet unwritten document :-(. In the meantime, there are three ways to create a basic X server configuration file for XFree86 &relvers;. -One is to run the <tt>xf86config</tt> utility. Another is to use the -new <tt>-configure</tt> X server option: +One is to run the <tt>xf86config</tt> utility. Another is to run the +<tt>xf86cfg</tt> utility. The third option is to use the new +<tt>-configure</tt> X server option: <tscreen><verb> XFree86 -configure </verb></tscreen> +Note that if you are running Darwin/Mac OS X, there is no step 3 :-). +You should skip this step, as configuration is not required or possible. +The X server configuration file is not used on Darwin/Mac OS X. + The X server config file (<tt>XF86Config</tt>) format has changed compared to 3.3.x. Also, its default location is now <tt>/etc/X11</tt>. Finally, there is now only one X server for driving video hardware, @@ -400,7 +419,7 @@ Once that's done, the main part of the installation can be done: <tscreen><verb> -./extract -C /usr/X11R6 X[a-df-uw-z]*.tgz +./extract -C /usr/X11R6 `pwd`/X[a-df-uw-z]*.tgz ./extract -C /usr/X11R6 Xvfb.tgz # If you are installing Xvfb ./extract -C /var Xvar.tgz /sbin/ldconfig /usr/X11R6/lib # For Linux Index: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml:3.56 xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml:3.59 --- xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml:3.56 Sat Jul 1 22:35:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml Tue Dec 12 13:54:29 2000 @@ -9,10 +9,10 @@ Marc Wandschneider, Mark Weaver, Matthieu Herrb -<Date>Last modified on: 1 July 2000 +<Date>Last modified on: 7 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.56 2000/07/02 02:35:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.59 2000/12/12 18:54:29 dawes Exp $ </ident> <toc> @@ -38,8 +38,8 @@ A list of mirror sites is provided by -<htmlurl name="ftp://ftp.XFree86.org/pub/XFree86/MIRRORS" -url="ftp://ftp.XFree86.org/pub/XFree86/MIRRORS"> +<htmlurl name="http://www.xfree86.org/MIRRORS.shtml" +url="http://www.xfree86.org/MIRRORS.shtml"> XFree86 also builds on other NetBSD architectures. See section @@ -60,6 +60,18 @@ See the <htmlurl url="RELNOTES.html" name="Release Notes"> for non-OS dependent new features in XFree86 &relvers;. +<sect1>New OS dependent features in 4.0.2 +<p> +<itemize> +<item>A fix for libXmu OS detection which was broken since <tt/unix/ +isn't defined anymore by the C preprocessor. +<item>(limited) native wscons support. This is not activated by +default. +<item>Updates to the aperture driver +<item>Support for multithread libraries with GNU pth +<item>Add <tt>/usr/pkg/bin</tt> to the default user path. +</itemize> + <sect1>New OS dependent features in 4.0.1 <p> <itemize> @@ -341,6 +353,19 @@ <tt>xc/config/cf/host.def</tt> before compiling. To compile the sources, invoke ``<tt/make World/'' in the xc directory. +<sect1>Perl support +<p> +Starting with XFree86 4.0.2, perl is needed to build the fonts in +XFree86. Since perl is not included with standard NetBSD installation, +fonts that need perl are not built by default. +<p> +If you have installed perl (from the NetBSD packages, for instance), +add the line +<tscreen><verb> +#define HasPerl YES +</verb></tscreen> +in <tt>xc/config/cf/host.def</tt> before rebuilding XFree86. + <sect1>Aperture driver <p> To build the XFree86 server with the Aperture driver enabled, you @@ -350,15 +375,13 @@ <tscreen><verb> #define HasNetBSDApertureDriver YES </verb></tscreen> -to it. - -And finally run <tt/make World/ in the <tt/xc/ directory. +to it before rebuilding XFree86. <sect1>Console drivers<label id="console-drivers"> <p> XFree86 has a configuration option to select the console -drivers to use in <tt/xf86site.def/: +drivers to use in <tt/host.def/: <itemize> <item> if you're using pccons put: <tscreen><verb> @@ -369,9 +392,18 @@ #define XFree86ConsoleDefines -DPCVT_SUPPORT </verb></tscreen> </itemize> -If you don't define <bf/XFree86ConsoleDefines/ in <tt/xf86site.def/ the +If you don't define <bf/XFree86ConsoleDefines/ in <tt/host.def/ the pccons and pcvt drivers will be supported by default. +<p> +Experimental native support for the wscons console driver can be built +by adding: +<tscreen><verb> + #define XFree86ConsoleDefines -DWSCONS_SUPPORT +</verb></tscreen> +to <tt>xc/config/host.def</tt> before rebuilding the server. +This has not been thoroughly tested, except on the macppc. + <sect1>Building on other architectures<label id="sparc"> <p> @@ -381,6 +413,13 @@ The NetBSD xsrc source tree is available at: <htmlurl url="ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/xsrc/" name="ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/xsrc/"> + +<p> +There's an <em/experimental/ patch by Tsubai Masanari to make XFree86 +4.0.1 work on +NetBSD/macppc at: +<htmlurl url="ftp://nandra.iri.co.jp/pub/NetBSD/macppc/XFree86/README" +name="ftp://nandra.iri.co.jp/pub/NetBSD/macppc/XFree86/README">. <sect>Building New X Clients Index: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml:1.11 xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml:1.15 --- xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml:1.11 Sat Jul 1 22:35:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml Tue Dec 12 13:54:29 2000 @@ -6,10 +6,10 @@ <title>README for XFree86 &relvers; on OpenBSD <author> Matthieu Herrb -<Date>Last modified on: 1 July 2000 +<Date>Last modified on: 2 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.11 2000/07/02 02:35:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.15 2000/12/12 18:54:29 dawes Exp $ </ident> <toc> @@ -30,14 +30,14 @@ <htmlurl name="ftp://ftp.XFree86.org/pub/XFree86/&relvers;" url="ftp://ftp.XFree86.org/pub/XFree86/&relvers;"> -Binaries for OpenBSD/i386 2.6 and later are available from: +Binaries for OpenBSD/i386 2.8 and later are available from: <htmlurl name="ftp://ftp.XFree86.org/pub/XFree86/&relvers;/binaries/OpenBSD" url="ftp://ftp.XFree86.org/pub/XFree86/&relvers;/binaries/OpenBSD"> A list of mirror sites is provided by -<htmlurl name="ftp://ftp.XFree86.org/pub/XFree86/MIRRORS" -url="ftp://ftp.XFree86.org/pub/XFree86/MIRRORS"> +<htmlurl name="http://www.xfree86.org/MIRRORS.shtml" +url="http://www.xfree86.org/MIRRORS.shtml"> <p> @@ -57,6 +57,16 @@ See the <htmlurl url="RELNOTES.html" name="Release Notes"> for non-OS dependent new features in XFree86 &relvers;. +<sect1>New OS dependent features in 4.0.2 +<p> +<itemize> +<item>Support for the OpenBSD ports tree, +<item>Preliminary support for the powerpc architecture (clients build +and work, the server doesn't work yet), +<item>xdm now writes an utmp entry, +<item>startx now creates an Xauthority magic cookie for the display. +</itemize> + <sect1>New OS dependent features in 4.0.1 <p> <itemize> @@ -223,7 +233,44 @@ machdep.allowaperture=1 </verb></tscreen> in <tt>/etc/sysctl.conf</tt>. - + +Some drivers need a patch to the aperture driver in the kernel to work +correctly with int10 support. If you get warning from xf86ReadBIOS +like this one: +<tscreen><verb> +(II) checkDevMem: using aperture driver /dev/xf86 +(WW) xf86ReadBIOS: /dev/mem mmap[s=600,a=0,o=0] failed (Invalid argument) +</verb></tscreen> +you should patch your kernel and rebuild it. Until it's integrated in +OpenBSD-current, or a better fix is found, the patch is available at +<htmlurl +name="ftp://ftp.laas.fr/pub/ii/matthieu/OpenBSD/patch-kernel-xf4" +url="ftp://ftp.laas.fr/pub/ii/matthieu/OpenBSD/patch-kernel-xf4">. + +I've also included it below, if you want to edit the source file by +hand. + +<tscreen><verb> +Index: sys/arch/i386/i386/mem.c +=================================================================== +RCS file: /cvs/src/sys/arch/i386/i386/mem.c,v +retrieving revision 1.14 +diff -u -r1.14 mem.c +--- sys/arch/i386/i386/mem.c 1999/11/20 11:11:28 1.14 ++++ sys/arch/i386/i386/mem.c 2000/11/13 10:54:22 +@@ -269,8 +269,8 @@ + /* minor device 4 is aperture driver */ + case 4: + if (allowaperture && +- (((off >= VGA_START && off <= BIOS_END) || +- (unsigned)off > (unsigned)ctob(physmem)))) ++ (off <= BIOS_END || ++ (unsigned)off > (unsigned)ctob(physmem))) + return i386_btop(off); + else + return -1; +</verb></tscreen> + <p> Another (less recommended) way to enable linear memory and I/O ports access is to disable the kernel security feature by adding ``option @@ -280,7 +327,7 @@ <p> XFree86 has a configuration option to select the console -drivers to use in <tt/xf86site.def/: +drivers to use in <tt/host.def/: <itemize> <item> if you're using pccons only put: <tscreen><verb> @@ -291,8 +338,18 @@ #define XFree86ConsoleDefines -DPCVT_SUPPORT </verb></tscreen> </itemize> -If you don't define <bf/XFree86ConsoleDefines/ in <tt/xf86site.def/ the -pccons and pcvt drivers will be supported. +If you don't define <bf/XFree86ConsoleDefines/ in <tt/host.def/ the +pccons and pcvt drivers will be supported by default. + +<p> +Experimental native support for the wscons console driver found on +OpenBSD/powerpc and on OpenBSD/i386 -current can be built +by adding: +<tscreen><verb> + #define XFree86ConsoleDefines -DWSCONS_SUPPORT +</verb></tscreen> +to <tt>xc/config/host.def</tt> before rebuilding the server. +This has not been thoroughly tested, except on the macppc. Index: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml:3.106 xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml:3.110 --- xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml:3.106 Sat Jul 1 22:35:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml Fri Dec 15 11:11:57 2000 @@ -1,8 +1,10 @@ <!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN" [ <!ENTITY % defs SYSTEM "defs.ent"> %defs; <!ENTITY % onediff 'IGNORE'> <!-- patch is a single diff file --> -<!ENTITY % twodiffs 'INCLUDE'> <!-- patch is split into two diff files --> +<!ENTITY % twodiffs 'IGNORE'> <!-- patch is split into two diff files --> <!ENTITY % threediffs 'IGNORE'> <!-- patch is split into three diff files --> +<!ENTITY % fourdiffs 'INCLUDE'> <!-- patch is split into four diff files --> +<!ENTITY % difftar 'INCLUDE'> <!-- patch also contains a tarball --> ]> @@ -10,10 +12,10 @@ <title>README for XFree86&tm; &relvers; <author>The XFree86 Project, Inc -<date>30 June 2000 +<date>15 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.106 2000/07/02 02:35:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.110 2000/12/15 16:11:57 dawes Exp $ </ident> <abstract> @@ -29,42 +31,20 @@ <sect>What is XFree86 &relvers;? <p> -<![ %snapshot [ -XFree86 &relvers; is a ``work in progress'' snapshot of the XFree86 4.0 -development code. It is <![ %latersnap; [one of]]> -<![ %firstsnap; [the first in]]> -a series of snapshot releases leading up the the 4.0 release. The -plan is to release a new snapshot every four to six weeks. The target -audience for this release is developers and others who are comfortable -on the bleeding edge. This release is not targeted at beginners. -Also, most end users will find life easier using our latest 3.3.x release. -While we welcome bug reports and feedback about this release, we don't -have the resources to provide user-level support for it. If you're not -comfortable dealing with those sorts of things yourself, then the snapshot -releases are probably not for you. - -This code is very much work in progress. Many of the interfaces may -change without notice between now and the 4.0 release. The -<htmlurl name="driver design" url="DESIGN.html"> has changed significantly -compared with the 3.3.x versions, and only a small number of drivers have -been converted so far. That means that this release does not support a -wide range of video hardware. Some of the drivers and new features are -well developed and reasonably stable, while others are not. -]]> - -<![ %release [ -XFree86 &relvers; is <![ %firstrel; [the first]]> -<![ %laterrel; [a]]> the upgrade to the first full release in the <![ %earlyrel; [new]]> XFree86 4 -series. Release 4 is a major re-design of the basic architectural +XFree86 &relvers; is the third full release in the <![ %earlyrel; [new]]> +XFree86 4 series. + +<p> +XFree86 release 4 is a major re-design of the basic architectural underpinnings of XFree86's implementation of the original X Consortium's X Server. This re-design allows for a modular interaction between the -hardware drivers and the XFree86 core X server. With 4.0, upgrades to +hardware drivers and the XFree86 core X server. With 4.x, upgrades to the X server with new and unsupported hardware can be easily done and -installed without undergoing the previous process of rebuilding a X +installed without undergoing the previous process of rebuilding an X server. All that is required is installing the new driver module and updating the configuration file. -The road to XFree86 Release 4 began as an architectural concept in mid +The road to XFree86 release 4 began as an architectural concept in mid 1997, with the serious framework being implemented in code the beginning of 1998. There were several snapshots on the road to 4.0 which are now part of the 4.0 base release. The &relvers; version is an upgrade to @@ -72,16 +52,15 @@ bug fixes. Release 4 also included the long-awaited integration of the DRI (Direct -Rendering Infrastructure). This upgrade into the code base gives XFree86 -the abilities of direct 3-D graphics rendering, used widely in games -and other visualization programs. - -Many drivers used in the old 3.3.x series have not be converted over to -the 4.0 design and so check first whether your hardware is supported -before upgrading to the 4.0 series in the <htmlurl name="Driver Status -document" url="Status.html">. - -]]> +Rendering Infrastructure). This upgrade into the code base gives +XFree86 the abilities of accelerated direct 3-D graphics rendering, used +widely in games and other visualization programs. + +While some driver available in the old 3.3.x release series have not +been converted over to the 4.x series, those required for most modern +video hardware are available. Please check the <htmlurl name="Driver +Status document" url="Status.html"> first to see whether your hardware +is supported before upgrading to the 4.x series. Specific release enhancements can be viewed in the <htmlurl name="Release Notes" url="RELNOTES.html">. @@ -110,9 +89,9 @@ <p> If you would like to work on the development of XFree86 4, either by -helping with the conversion of our older drivers to the new 4.0 design, +helping with the conversion of our older drivers to the new 4.x design, or assisting in the addition of new drivers or platforms to the code base -then send a request to to <url name="join the XFree86 development team" +then send a request to <url name="join the XFree86 development team" url="http://www.xfree86.org:/developer.html">. This will give you direct access to the latest XFree86 related development topics and discussions. Include in your note, your name, email address, reason for joining (what @@ -167,6 +146,7 @@ is updated dynamically every time the repository is updated after the the commit happens. +<!-- <p> A followup to the commit list is the soon to be public, patch archives. This archive will be available on our web-site and will show what patches @@ -174,6 +154,7 @@ people who are interested in a specific area and want to know what work is happening there. When this goes public we will announce it on our web site and our Announce mailing list, so keep watching. +--> <sect1> Xpert @@ -224,53 +205,112 @@ <![ %onediff; [ A source patch relative to version &prevrelvers; is also available. -The patch file is <tt>&prevrelvers;-&relvers;.diff.gz</tt>. This patch +The patch file is <tt>&prevrelvers;-&relvers;.diff.gz</tt>. +<![ %difftar; [ +There is also a tarball that contains some files that have components that +can't be included in a diff. It is <tt>&relvers;.tgz</tt>. +]]> +The patch should be applied to a clean &prevrelvers; source tree, working from the directory containing the <tt>xc/</tt> directory. The patch should be applied by running: +<tscreen><verb> +gzip -d < &prevrelvers;-&relvers;.diff.gz | patch -p0 -E +</verb></tscreen> +<![ %difftar; [ <tscreen><verb> -gunzip < &prevrelvers;-&relvers;.diff.gz | patch -p0 -E +gzip -d < &relvers;.tgz | tar vxf - </verb></tscreen> ]]> +]]> <![ %twodiffs; [ A source patch relative to version &prevrelvers; is also available. Because of its size, it is split into two parts. The patch files are <tt>&prevrelvers;-&relvers;.diff1.gz</tt> and -<tt>&prevrelvers;-&relvers;.diff2.gz</tt>. These patches should +<tt>&prevrelvers;-&relvers;.diff2.gz</tt>. +<![ %difftar; [ +There is also a tarball that contains some files that have components that +can't be included in a diff. It is <tt>&relvers;.tgz</tt>. +]]> +These patches should be applied to a clean &prevrelvers; source tree, working from the directory containing the <tt>xc/</tt> directory. The patches should be applied by running: +<tscreen><verb> +gzip -d < &prevrelvers;-&relvers;.diff1.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff2.gz | patch -p0 -E +</verb></tscreen> +<![ %difftar; [ <tscreen><verb> -gunzip < &prevrelvers;-&relvers;.diff1.gz | patch -p0 -E -gunzip < &prevrelvers;-&relvers;.diff2.gz | patch -p0 -E +gzip -d < &relvers;.tgz | tar vxf - </verb></tscreen> ]]> +]]> <![ %threediffs; [ A source patch relative to version &prevrelvers; is also available. Because of its size, it is split into three parts. The patch files are <tt>&prevrelvers;-&relvers;.diff1.gz</tt>, <tt>&prevrelvers;-&relvers;.diff2.gz</tt> and -<tt>&prevrelvers;-&relvers;.diff3.gz</tt>. These patches should +<tt>&prevrelvers;-&relvers;.diff3.gz</tt>. +<![ %difftar; [ +There is also a tarball that contains some files that have components that +can't be included in a diff. It is <tt>&relvers;.tgz</tt>. +]]> +These patches should be applied to a clean &prevrelvers; source tree, working from the directory containing the <tt>xc/</tt> directory. The patches should be applied by running: +<tscreen><verb> +gzip -d < &prevrelvers;-&relvers;.diff1.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff2.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff3.gz | patch -p0 -E +</verb></tscreen> +<![ %difftar; [ <tscreen><verb> -gunzip < &prevrelvers;-&relvers;.diff1.gz | patch -p0 -E -gunzip < &prevrelvers;-&relvers;.diff2.gz | patch -p0 -E -gunzip < &prevrelvers;-&relvers;.diff3.gz | patch -p0 -E +gzip -d < &relvers;.tgz | tar vxf - </verb></tscreen> ]]> +]]> + +<![ %fourdiffs; [ +A source patch relative to version &prevrelvers; is also available. +Because of its size, it is split into four parts. +The patch files are <tt>&prevrelvers;-&relvers;.diff1.gz</tt>, +<tt>&prevrelvers;-&relvers;.diff2.gz</tt>, +<tt>&prevrelvers;-&relvers;.diff3.gz</tt> and +<tt>&prevrelvers;-&relvers;.diff4.gz</tt>. +<![ %difftar; [ +There is also a tarball that contains some files that have components that +can't be included in a diff. It is <tt>&relvers;.tgz</tt>. +]]> +These patches should +be applied to a clean &prevrelvers; source tree, working from the directory +containing the <tt>xc/</tt> directory. The patches should be applied by +running: + +<tscreen><verb> +gzip -d < &prevrelvers;-&relvers;.diff1.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff2.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff3.gz | patch -p0 -E +gzip -d < &prevrelvers;-&relvers;.diff4.gz | patch -p0 -E +</verb></tscreen> +<![ %difftar; [ +<tscreen><verb> +gzip -d < &relvers;.tgz | tar vxf - +</verb></tscreen> +]]> +]]> The contrib part of the distribution has been folded into the main source tree, so a separate contrib tarball is no longer required. To format the XFree86 documentation use the latest version of our doctools -package available as <tt>doctools-1.1.3.tgz</tt>. +package available as <tt>doctools-&doctoolsvers;.tgz</tt>. <sect>Reporting Bugs <p> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml:1.41 xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml:1.58 --- xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml:1.41 Sat Jul 1 22:35:27 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml Sun Dec 17 18:01:10 2000 @@ -6,10 +6,10 @@ <title>Release Notes for XFree86™ &relvers; <author>The XFree86 Project, Inc -<date>30 June 2000 +<date>17 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.41 2000/07/02 02:35:27 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.58 2000/12/17 23:01:10 dawes Exp $ </ident> <abstract> @@ -23,51 +23,47 @@ <sect>Introduction to the 4.x Release Series <p> -XFree86 4.0 was the first official release of the new XFree86 4. XFree86 +XFree86 4.0 was the first official release of the new XFree86 4 series. +The current release (&relvers;) is the latest in that series. XFree86 4 represents a significant redesign of the XFree86 X server. -Not all of the hardware drivers from 3.3.x have been ported to 4.x yet. +Not all of the hardware drivers from 3.3.x have been ported to 4.x yet, +but conversely, 4.x has some hardware support not present in 3.3.x. +Our <htmlurl name="Driver Status document" url="Status.html"> summarizes +how the hardware driver support compares between &legacyvers; and &relvers;. +Please check there first before downloading &relvers;. + +The 4.0.1 release introduced a new graphical configuration tool, +"<tt>xf86cfg</tt>", and a text mode interface was added to it for the +4.0.2 release. It is work in progress, but definitely worth trying out. +The trusty old text-based tool "<tt>xf86config</tt>" can also be used +for generating X server config files. In addition to these tools, we've +been working on a configuration tool that is built-in to the X +server. It is included in the release, and it works well for some +hardware. To try it out, just run (as root) "<tt>XFree86 -configure</tt>". +Each of these configuration options will give you a reasonable starting +point for a suitable configuration file. We've put some effort into +documenting the &relvers; config file format, and you can find that +information in the XF86Config manual page. Check that, the driver manual +pages and the related documentation for further information. -<sect1>Differences Between the 4.x series and the 3.3 series -<p> -The 4.x release series is also missing -a nice configuration tool. -This means that configuring the Xserver might be trickier than usual. -The second point is that is that your hardware might not -be supported by &relvers;, or it -might be supported at a lesser level (conversely, some hardware is better -supported in &relvers;). We've attempted to provide some information -about the second point in our <htmlurl name="Driver Status document" -url="Status.html">. Please check there first before downloading &relvers;. - -On the subject of configuration, we have updated the basic text-based -tool "<tt>xf86config</tt>" to generate config files in the format required -by &relvers; (3.3.x config files won't really work with &relvers;). We're also -working on some other configuration tools, including one that is built-in -to the X server. An early version of this is included in the release, -and it works well for some hardware. To try it out, just run (as root) -"<tt>XFree86 -configure</tt>". Both of these configuration options will -give you a reasonable starting point for a suitable configuration -file. We've put some effort into documenting the &relvers; config file format, -and you can find that information in the XF86Config manual page. Check -that, the driver manual pages and the related documentation for -further information. - +<!-- Oh, another thing you might notice is that our documentation is rather patchy. Most of what is present should be in reasonable shape, but there are gaps. We thought it better to leave out docs that were very out of date rather than providing inaccurate and misleading information. We are looking for people to also help fill those gaps in <hint hint :->. +--> -Finally, before you download and install the binary distributions for +Before you go to download and install the binary distributions for this release, please have a quick read through the <htmlurl name="Installation Document" url="Install.html">. It may save you some -time. +time and help you figure out which of the binary releases you need. The next section describes what is new in the latest version (&relvers;). The other sections below describe some of the new features and changes -between 3.3.x and 4.0. There is a lot of new features, and we definitely -don't have enough space to cover it all here. +between 3.3.x and 4.0. There are lot's of new features, and we definitely +don't have enough space to cover them all here. </sect> @@ -76,156 +72,422 @@ <sect1>X server <p> <itemize> - <item>New DRI drivers for Intel i810, Matrox G400 and G200 (AGP only) and - the ATI Rage 128, and updates to the 3Dfx DRI driver, including - Voodoo5 support. + <item>Darwin/Mac OS X is now supported and the X server runs on PowerPC. + The X server for this platform is called "Xdarwin", and its + installation and configuration is different from the "XFree86" + server used on other platforms. Please read the <htmlurl + url="Darwin.html" name="XFree86 on Darwin and Mac OS X"> document + for further information. - <item>The X server now runs on Linux/Sparc including drivers for many - video cards used on SUN hardware. + <item>Mesa has been updated to the 3.4 stable release. - <item>DRI support for the Linux/Sparc implementation that allows 3D direct - rendering with Creator3D cards. + <item>A driver for ATI Radeon adapters has been added. - <item>Fixed recently publicized security issues. + <item>ATI driver support for multi-head configurations and non-Intel + platforms has been improved. - <item>Update Mesa to the latest version. + <item>The ATI driver has been changed to invoke the appropriate driver for + any Rage 128 and Radeon adapters that it finds in the system. - <item>Xinerama updates and fixes. + <item>A driver (i128) for Number Nine chipsets has been added. - <item>Xv updates and fixes. + <item>A driver (savage) for S3 Savage chipsets has been added. - <item>Mouse support in DGA 1.0 compatibility mode should now work correctly - for most games that make use of it. + <item>A driver (siliconmotion) for some Silicon Motion chipsets has been + added. - <item>Some bugs with 8+24 overlay support have been fixed. + <item>The driver (ark) for Ark Logic chips has been ported to 4.x. - <item>Some XKEYBOARD extension problems have been fixed, including - improvements to the MouseKeys support. + <item>A VESA driver has been added. + + <item>A driver for SGI newport cards has been added (Linux/mips). - <item>Add generic DGA support to the sis, neomagic and i810 drivers. + <item>The trident driver has lots of fixes to the CyberBlade/Blade + support, XVideo support for the Image/Blade series (although + scaling doesn't work yet on the Image series). - <item><tt>xf86cfg</tt>, a new graphical configuration tool. + <item>The s3virge driver has stabilized ViRGE GX2 support, includes + ViRGE DX and ViRGE support for XVideo YUV images, and various fixes. -</itemize> -</sect1> + <item>The 3Dlabs (glint) driver now has Permedia3 support. -<sect1>X libraries and clients. -<p> -<itemize> - <item>Thread safety issues have been resolved in a few places in the - libraries. Upgrading to the latest libraries is essential for - multi-threaded X applications. + <item>The SiS driver has had many updates, and XVideo support for the 630 + is included. + + <item>The NVIDIA (nv) driver has been updated to include support for the + GeForce2, and line acceleration has been added. Also, DDC support + has been improved, and support added for Alpha platforms (dense only). + + <item>The neomagic driver has had various bug fixes and extended acceleration + support. DGA support has also been added. + + <item>The Chips and Technologies driver (chips) has initial support for + the 69030. + + <item>The tseng driver has multi-head fixes and DGA support has been added. + + <item>Most video drivers have been converted to use the integrated "fb" + framebuffer code instead of the old "cfb" code. + + <item>DRI support has been updated for the Rage 128, 3Dfx Voodoo3 and + Voodoo5, Intel i810/i815 and Matrox G400. DRI support for SiS + and Sun Creator3D is available. The DRI is now also available on + Alpha platforms. + + <item>An input driver (citron) for Citron Infrared Touch devices has been + added. + + <item>An input driver (penmount) for PenMount devices has been added. - <item>Some fatal bugs in the big font support have been fixed. Upgrading - to the latest libraries will fix this too. + <item>An input driver (digitaledge) for DigitalEdge devices has been added. - <item>Fixed recently publicized security issues in some of the X libraries. + <item>Big endian problems in Xinerama have been fixed. - <item>Updates and bug fixes for some clients, including xedit, xman, - xcalc, fstobdf, xdm. + <item>The new "render" extension has been added (see <ref id="render" + name="below">). The design has been + extended in the following ways:<p> - <item>Fix some xfs problems. + <itemize> + <item>A new FillRectangles request was added. + + <item>The 'mask' operand was changed to allow per-channel alphas. + + </itemize> + + <p>Server implementation: + + <itemize> + <item>Implemented remaining code for client clip lists. + + <item>Fixed plenty of bugs related to text rendering. - <item>XTerm updates. These include: + <item>Complete compositing code, except for separate alpha. + + </itemize> + + <p>Todo: + <itemize> - <item>Improve logfile security. + <item>Polygons - <item>Workaround for fixed fonts which are generated from - Unicode fonts: they omit glyphs for some xterm's - less-used line-drawing characters, which caused xterm - to set a flag telling it to use only its internal - line-drawing characters. - - <item>Limit numeric parameters of control sequences to 65535 - to simplify checks for numeric overflow. - - <item>Change index into UDK list to unsigned to guard against - numeric overflow making the index negative. - - <item>Add limit checks to ClearInLine(), ScrnInsertChar(), - ScrnDeleteChar() to correct potential out-of-bounds - indexing. - - <item>Add a resource (limitResize) limiting resizing via the - <tt>CSI 4 t</tt> and <tt>CSI 8 t</tt> sequences. - - <item>Ignore out-of-bounds resize requests, i.e., where - sign-extension or truncation of the parameters would - occur. - - <item>Change Sun function-keys resource name to sunFunctionKeys - to work around redefinition of the token sun by xrdb on - Solaris. Similarly, renamed resource sun keyboard to - sunKeyboard. Change similar resource names for HP and - SCO to avoid potential conflict with xrdb symbols on - other systems, as well as for consistency. - - <item>Change line speed from 9600bd to 38400bd to accommodate - users who mistakenly use $TERM set to vt100, to reduce - the effect of padding associated with this terminal - type. - - <item>Fix a problem that caused the right scrollbar to be - positioned incorrectly when re-enabling it. - - <item>Fix a problem with color support that showed up on some - platforms. - - <item>Modify logic for deleteIsDEL resource so it has internally - 3 states: unspecified, true and false. If unspecified, - the keyboard type determines whether the Delete key - transmits <tt><esc>[3~</tt> or <tt>\177</tt>, and - the popup menu entry reflects the internal state. - Otherwise, the popup menu entry overrides the keyboard - type. + <item>Image scaling + + <item>Separate alpha channels + + <item>Support for visuals other than TrueColor. + + </itemize> + + <p>Drivers with render extension support include: i128, glint, ati (r128 + and radeon), chips, cirrus, mga, neomagic, nv, tdfx, trident, tseng, + vesa, s3virge. + + <p>Acceleration for the render extension: + + <itemize> + <item>XAA infrastructure for acceleration. + + <item>Experimental MGA acceleration using XAA + + <item>kdrive (TinyX) infrastructure + + <item>Experimental TinyX Trident 9525DVD acceleration + + </itemize> + + <p>Xft library: + + <itemize> + <item>New font naming/access library. + + <item>Abstraction for core/Render text. + + <item>Uses FreeType2 rasterizer. + + <item>Allows anti-aliased/subpixel sampled text. + + <item>Gracefully falls back to core rendering. + + <item>Complicated font matching mechanism. + + <item>Uses server DPI to convert point sizes to pixel sizes, even + for core fonts. + + </itemize> + + <p>xterm: + + <itemize> + <item>Can use Xft, by default uses core fonts. + + <item>Uses new options '<tt>-fa</tt>' for family name and + '<tt>-fs</tt>' for font size (in points). + + </itemize> + + <p>x11perf: + + <itemize> + <item>Add tests for anti-aliased, subpixel sampled and aliased + fonts using the Xft library. + + </itemize> + + <p>xditview: + + <itemize> + <item>When the Xft library is build, uses Xft for all font access. + + </itemize> + + <p>Qt, Gtk, twm: + + <itemize> + <item>Qt changes available <url + url="http://XFree86.org/~keithp/download/qtkernel.tar.bz2" + name="here">. + + <item>Gtk changes in process. + + <item>twm hacks should never see the light of day. + + </itemize> - <item>Portability fixes for os390, AIX 4.2, Digital Unix 4.0 - and IRIX 6.5. + <item><tt>xf86cfg</tt>, a new graphical configuration tool for XFree86 4.x, + and can be used to either write the initial configuration or make + customisations to the current configuration. <tt>xf86cfg</tt> is + a work in progress, and allows configuration of:<p> + + <itemize> + <item>Specific setup of monitors, cards, keyboards and mice, as + well as adding or removing them. + <item>Server layout setup, allowing complex configuration of + physical monitor positions, default color depth and/or + rotated monitors. + <item>Mode line editor that can be used to configure multiple + monitors, and allows adding a modeline specific to a + monitor directly to the configuration file. + <item>AccessX configuration interface, that provides an interface + to easy setup of most AccessX options, including:<p> + + <itemize> + <item>Timeout to reset controls. + <item>StickyKeys, for people with disabilities that cannot + press two keys at the same time. + <item>MouseKeys, mouse control only with the keyboard. + <item>RepeatKeys, repeat rate and repeat delay. + <item>SlowKeys, to avoid pressing keys accidentally, they're + only accepted if pressed for some specific amount + of time. + <item>BounceKeys, helps avoiding multiple key presses by + only accepting a key if it is pressed only once and + not pressed again in a specific amount of time. + </itemize> </itemize> + + <p>New configuration options are being worked on, as well as correcting + some of the bugs in the current options. A protocol for plugging + in external modules is also planned. </itemize> +</sect1> -<sect1>Fonts and Internationalisation +<sect1>X libraries and clients. <p> <itemize> + <item>Significant updates to the internationalisation support in Xlib + (see <ref id="i18n" name="below">). + + <item>Some xfs updates, including font path verification, and new options. + + <item>XTerm updates. + + <item>New "xvinfo" client for querying the XVideo extension. + +</itemize> + +<sect1>Fonts and Internationalisation <label id="i18n"> +<p> +<itemize> <item>Many of the "misc" bdf fonts have been updated and extended, and - a wider range of ISO-8859 subsets have been added. Oblique/italic - versions of some of them have also been added. + a wider range of ISO-8859 subsets have been added. These are now + auto-generated from ISO-10646 encoded master fonts. + + <item>The ClearlyU ISO-10646 encoded fonts have been updated. + + <item>Functions to read keyboard input in locale independent UTF-8 encoding + have been added to libX11: Xutf8LookupString, Xutf8ResetIC. + + <item>Functions to output strings in locale independent UTF-8 encoding + have been added to libX11: Xutf8DrawString, Xutf8DrawImageString, + Xutf8TextEscapement, Xutf8TextExtents, Xutf8TextPerCharExtents, + Xutf8DrawText. + + <item>Functions to convert between Compound Text or locale dependent encoding + and UTF-8 have been added to libX11: Xutf8TextListToTextProperty, + Xutf8TextPropertyToTextList. The converter between Compound Text + and UTF-8 in Xlib has been improved; a round-trip conversion + now correctly converts all graphic Unicode characters back and + forth. - <item>The converters in Xlib have been improved and reworked. UTF-8 - support has been added. + <item>libXaw now offers selected text using both selection targets, + UTF8_STRING and COMPOUND_TEXT. - <item>Support for ISO-8859-13 has been added to Xlib and to the UTF-8 - converters. + <item>Locales with UTF-8 encodings are now supported; but the UTF-8 + displaying facilities are not adequate yet. <item>XKB keyboard definitions have been added and updated for some countries. - <item>Locale support for Celtic languages has been updated, and a Compose - file for ISO-8859-14 added. - </itemize> </sect1> -<sect1>Miscellaneous +<sect1>Platforms <p> <itemize> - <item>Preliminary support for Linux/mips (no X servers yet). + <item>Darwin/Mac OS X. - <item>Update support for BSD/OS. + <item>Greatly improved IA-64 support. - <item>Update Linux/IA64 support. + <item>Improved Linux/mips support. - <item>Support for LynxOS 3.1.0. + <item>Support has been added for more Alpha platforms under Linux. This + now includes all platforms that require sparse memory mapping. </itemize> </sect1> </sect> + +<sect>Drivers +<p> -<sect>The new X server +<sect1>Video Drivers <p> + +XFree86 &relvers; includes the following video drivers: + +<table border=1 align="center"> +<tabular ca="|l|l|l|"> + <tabrow>Driver Name<colsep>Description<colsep>Further Information</tabrow> + <hline> + <tabrow><tt>apm</tt><colsep>Alliance Pro Motion<colsep><htmlurl + name="README.apm" url="apm.html"></tabrow> + <tabrow><tt>ark</tt><colsep>Ark Logic<colsep> </tabrow> + <tabrow><tt>ati</tt><colsep>ATI<colsep><htmlurl + name="README.ati" url="ati.html">, <htmlurl + name="README.r128" url="r128.html">, <htmlurl + name="r128(4)" url="r128.4.html"></tabrow> + <tabrow><tt>chips</tt><colsep>Chips & Technologies<colsep><htmlurl + name="README.chips" url="chips.html">, <htmlurl + name="chips(4)" url="chips.4.html"></tabrow> + <tabrow><tt>cirrus</tt><colsep>Cirrus Logic<colsep> </tabrow> + <tabrow><tt>cyrix</tt> (*)<colsep>Cyrix MediaGX<colsep><htmlurl + name="README.cyrix" url="cyrix.html"></tabrow> + <tabrow><tt>fbdev</tt><colsep>Linux fbdev<colsep><htmlurl + name="fbdev(4)" url="fbdev.4.html"></tabrow> + <tabrow><tt>glide</tt><colsep>Glide2x (3Dfx)<colsep><htmlurl + name="glide(4)" url="glide.4.html"></tabrow> + <tabrow><tt>glint</tt><colsep>3Dlabs, TI<colsep><htmlurl + name="glint(4)" url="glint.4.html"></tabrow> + <tabrow><tt>i128</tt><colsep>Number Nine<colsep><htmlurl + name="README.I128" url="I128.html">, <htmlurl + name="i128(4)" url="i128.4.html"></tabrow> + <tabrow><tt>i740</tt><colsep>Intel i740<colsep><htmlurl + name="README.i740" url="i740.html"></tabrow> + <tabrow><tt>i810</tt><colsep>Intel i810<colsep><htmlurl + name="README.i810" url="i810.html">, <htmlurl + name="i810(4)" url="i810.4.html"></tabrow> + <tabrow><tt>imstt</tt><colsep>Integrated Micro Solns<colsep> </tabrow> + <tabrow><tt>mga</tt><colsep>Matrox<colsep><htmlurl + name="mga(4)" url="mga.4.html"></tabrow> + <tabrow><tt>neomagic</tt><colsep>NeoMagic<colsep><htmlurl + name="neomagic(4)" url="neomagic.4.html"></tabrow> + <tabrow><tt>newport</tt> (-)<colsep>SGI Newport<colsep><htmlurl + name="README.newport" url="newport.html">, <htmlurl + name="newport(4)" url="newport.4.html"></tabrow> + <tabrow><tt>nv</tt><colsep>NVIDIA<colsep><htmlurl + name="nv(4)" url="nv.4.html"></tabrow> + <tabrow><tt>rendition</tt><colsep>Rendition<colsep><htmlurl + name="README.rendition" url="rendition.html">, <htmlurl + name="rendition(4)" url="rendition.4.html"></tabrow> + <tabrow><tt>s3virge</tt><colsep>S3 ViRGE<colsep><htmlurl + name="README.s3virge" url="s3virge.html">, <htmlurl + name="s3virge(4)" url="s3virge.4.html"></tabrow> + <tabrow><tt>savage</tt><colsep>S3 Savage<colsep><htmlurl + name="savage(4)" url="savage.4.html"></tabrow> + <tabrow><tt>siliconmotion</tt><colsep>Silicon Motion<colsep><htmlurl + name="siliconmotion(4)" url="siliconmotion.4.html"></tabrow> + <tabrow><tt>sis</tt><colsep>SiS<colsep><htmlurl + name="README.SiS" url="SiS.html"></tabrow> + <tabrow><tt>sunbw2</tt> (+)<colsep>Sun bw2<colsep> </tabrow> + <tabrow><tt>suncg14</tt> (+)<colsep>Sun cg14<colsep> </tabrow> + <tabrow><tt>suncg3</tt> (+)<colsep>Sun cg3<colsep> </tabrow> + <tabrow><tt>suncg6</tt> (+)<colsep>Sun GX and Turbo GX<colsep> </tabrow> + <tabrow><tt>sunffb</tt> (+)<colsep>Sun Creator/3D, Elite 3D<colsep> </tabrow> + <tabrow><tt>sunleo</tt> (+)<colsep>Sun Leo (ZX)<colsep> </tabrow> + <tabrow><tt>suntcx</tt> (+)<colsep>Sun TCX<colsep> </tabrow> + <tabrow><tt>tdfx</tt><colsep>3Dfx<colsep> </tabrow> + <tabrow><tt>tga</tt><colsep>DEC TGA<colsep><htmlurl + name="README.DECtga" url="DECtga.html"></tabrow> + <tabrow><tt>trident</tt><colsep>Trident<colsep><htmlurl + name="trident(4)" url="trident.4.html"></tabrow> + <tabrow><tt>tseng</tt><colsep>Tseng Labs<colsep> </tabrow> + <tabrow><tt>vesa</tt><colsep>VESA<colsep><htmlurl + name="vesa(4)" url="vesa.4.html"></tabrow> + <tabrow><tt>vga</tt><colsep>Generic VGA<colsep><htmlurl + name="vga(4)" url="vga.4.html"></tabrow> +</tabular> +</table> + +Drivers marked with (*) are present in a preliminary form in this release, +but are not complete and/or stable yet. +<p> + +Drivers marked with (+) are for Linux/Sparc only. +<p> + +Drivers marked with (-) are for Linux/mips only. +<p> + +Darwin/Mac OS X uses IOKit drivers and does not use the module loader drivers +listed above. Further information can be found in +<htmlurl name="README.Darwin" url="Darwin.html">. + +XFree86 &relvers; includes the following input drivers: + +<sect1>Input Drivers +<p> + +<table border=1 align="center"> +<tabular ca="|l|l|l|"> + <tabrow>Driver Name<colsep>Description<colsep>Further Information</tabrow> + <hline> + <tabrow><tt>acecad</tt><colsep>AceCad<colsep> </tabrow> + <tabrow><tt>citron</tt><colsep>Citron<colsep><htmlurl + name="citron(4)" url="citron.4.html"></tabrow> + <tabrow><tt>digitaledge</tt><colsep>DigitalEdge<colsep> </tabrow> + <tabrow><tt>dynapro</tt><colsep>Dynapro<colsep> </tabrow> + <tabrow><tt>elographics</tt><colsep>EloGraphics<colsep> </tabrow> + <tabrow><tt>keyboard</tt><colsep>generic keyboards<colsep><htmlurl + name="keyboard(4)" url="keyboard.4.html"></tabrow> + <tabrow><tt>microtouch</tt><colsep>MicroTouch<colsep> </tabrow> + <tabrow><tt>mouse</tt><colsep>most mouse devices<colsep><htmlurl + name="mouse(4)" url="mouse.4.html"></tabrow> + <tabrow><tt>mutouch</tt><colsep>MicroTouch<colsep> </tabrow> + <tabrow><tt>penmount</tt><colsep>PenMount<colsep> </tabrow> + <tabrow><tt>spaceorb</tt><colsep>SpaceOrb<colsep> </tabrow> + <tabrow><tt>summa</tt><colsep>SummaGraphics<colsep> </tabrow> + <tabrow><tt>void</tt><colsep>dummy device<colsep><htmlurl + name="void(4)" url="void.4.html"></tabrow> + <tabrow><tt>wacom</tt><colsep>Wacom tablets<colsep><htmlurl + name="wacom(4)" url="wacom.4.html"></tabrow> +</tabular> +</table> + +<sect>Summary of XFree86 4. +<p> Unlike XFree86 3.3.x where there are multiple X server binaries, each of which drive different hardware, XFree86 &relvers; has a single X server binary called <tt>XFree86</tt>. This binary can either have one @@ -234,9 +496,9 @@ XFree86 &relvers; has X server support for most UNIX(R) and UNIX-like operating systems on Intel/x86 platforms, plus support for Linux on -Alpha, PowerPC and Sparc platforms. Work on support for additional -architectures and operating systems is in progress, and is planned for -future releases. +Alpha, PowerPC, IA-64, Sparc, and Mips platforms, and for Darwin on PowerPC. +Work on support for additional architectures and operating systems is +in progress, and is planned for future releases. <sect1>Loader and Modules <p> @@ -409,15 +671,6 @@ EndSection </verb></quote> -<!-- what is this doing in the middle of information about the config file?? -j - Note: Additional sample rates have been added for some mice. - Matching the mouse sampling rate with the vertical refresh - rate can yield very noticeable improvements in smoothness of - pointer event driven operations such as window moves and - scrolling. ---> - <item>The Monitor section is mostly unchanged. The main difference is that a set of VESA modes is defined internally in the server, and so for most monitors, it isn't necessary to specify any modes @@ -441,7 +694,6 @@ Identifier "MGA 1" Driver "mga" BusID "PCI:1:0:0" - Option "PCI Retry" EndSection </verb></quote> @@ -630,12 +882,12 @@ <p> The XFree86 Acceleration Architecture (XAA) has been completely rewritten -from scratch. Most drivers implement acceleration by making use of the -XAA module. +from scratch for XFree86 4.x. Most drivers implement acceleration by +making use of the XAA module. <sect1>Multi-head <p> -Some multi-head configurations are supported in this release, primarily +Some multi-head configurations are supported in XFree86 4.x, primarily with multiple PCI/AGP cards. However, this is an area that is still being worked on, and we expect that the range of configurations for which it works well will increase in future releases. A configuration that @@ -662,12 +914,12 @@ Xinerama is not enabled by default, and can be enabled with the <tt>+xinerama</tt> command line option for the X server. -Xinerama was included with X11R6.4. The version included in this release +Xinerama was included with X11R6.4. The version included in XFree86 4.x was completely rewritten for improved performance and correctness. Known problems: <itemize> - <item>Most (all?) window managers are not Xinerama-aware, and so some + <item>Most window managers are not Xinerama-aware, and so some operations like window placement and resizing might not behave in an ideal way. This is an issue that needs to be dealt with in the individual window managers, and isn't specifically an @@ -675,19 +927,13 @@ </itemize> -<sect1>XVideo extension -<p> - -The XVideo extension is included in this release, but nobody seems -interested in writing up some information about it. - <sect1>DGA version 2 <p> -DGA 2.0 is nearly completed but still not implemented by all drivers. +DGA 2.0 is included in &relvers;, but is not implemented by all drivers. Preliminary documentation for the client libraries can be found in the -xc/programs/Xserver/hw/xfree86/DGA document. Some degree of backwards -compatibility with version 1.0 is provided. This information is out of date. +<tt>README.DGA</tt> document. A good degree of backwards compatibility +with version 1.0 is provided. <sect1>DDC @@ -719,7 +965,9 @@ <p> <url name="Precision Insight" url="http://www.precisioninsight.com"> -has been provided with funding and support from <url name="Red Hat" +(now part of the Professional Services group at <url name="VA Linux Systems" +url="http://www.valinux.com">) +was provided with funding and support from <url name="Red Hat" url="http://www.redhat.com">, <url name="SGI" url="http://www.sgi.com">, <url name="3Dfx" url="http://www.3dfx.com">, <url name="Intel" url="http://www.intel.com">, <url name="ATI" url="http://www.ati.com">, @@ -733,222 +981,157 @@ Infrastructure (DRI). Direct Rendering provides a highly optimized path for sending 3D data directly to the graphics hardware. This release provides a complete implementation of direct rendering support -for the 3Dfx Banshee and Voodoo3 graphics cards. Additional direct -rendering drivers will be available for 3Dfx, Intel, ATI and Matrox -boards during the second quarter of 2000. Updated information on DRI +for the 3Dfx Banshee, Voodoo3 and Voodoo5 graphics cards, as well as +the Intel i810/i815 cards, ATI Rage 128, and Matrox G400. +Updated information on DRI compatible drivers can be found at the <url name="DRI Project" url="http://dri.sourceforge.net"> on <url name="SourceForge" url="http://www.sourceforge.net">. -<sect1>X-Video Extension (Xv) +<sect1>XVideo Extension (Xv) <p> +The XVideo extension is supported in XFree86 4.x. An XvQueryPortAttributes function has been added as well as support for XvImages. XvImages are XImages in alternate color spaces such as YUV and can be passed to the server through shared memory segments. This allows clients to display YUV data with high quality -hardware scaling and filtering. XvImages are only supported -by the Matrox G200/G400 cards at the moment. +hardware scaling and filtering. -<sect1>Other extensions +<sect1>X Rendering Extension (Render) <label id="render"> <p> - -The XFree86-Misc extension has not been fully ported to the new server -architecture yet. This should be completed in a future release. - -The XFree86-VidModeExtension extension has been updated, and mostly -ported to the new server architecture. The area of mode validation -needs further work, and the extension should be used with care. This -extension has support for changing the gamma setting at run-time, for -modes where this is possible. The new <tt>xgamma</tt> utility makes -use of this feature. Compatibility with the 3.3.x version of the -extension is provided. The missing parts of this extension and some -new features should be completed in a future release. +The X Rendering extension provides a 2D rendering model that more +closely matches application demands and hardware capabilities. It provides +a rendering model derived from Plan 9 based on Porter/Duff image +composition rather than binary raster operations. -<sect1>Drivers <p> +Using simple compositing operators provided by most hardware, Render +can draw anti-aliased text and geometric objects as well as perform +translucent image overlays and other image operations not possible with +the core X rendering system. -XFree86 &relvers; includes the following drivers: - -<table border=1 align="center"> -<tabular ca="|l|l|"> - <tabrow>Driver Name<colsep>Description</tabrow> - <hline> - <tabrow><tt>apm</tt><colsep>Alliance Pro Motion</tabrow> - <tabrow><tt>ati</tt><colsep>ATI</tabrow> - <tabrow><tt>chips</tt><colsep>Chips & Technologies</tabrow> - <tabrow><tt>cirrus</tt><colsep>Cirrus Logic</tabrow> - <tabrow><tt>cyrix</tt> (*)<colsep>Cyrix MediaGX</tabrow> - <tabrow><tt>fbdev</tt><colsep>Linux fbdev</tabrow> - <tabrow><tt>glide</tt><colsep>Glide2x (3Dfx)</tabrow> - <tabrow><tt>glint</tt><colsep>3Dlabs, TI</tabrow> - <tabrow><tt>i740</tt><colsep>Intel i740</tabrow> - <tabrow><tt>i810</tt><colsep>Intel i810</tabrow> - <tabrow><tt>mga</tt><colsep>Matrox</tabrow> - <tabrow><tt>neomagic</tt><colsep>NeoMagic</tabrow> - <tabrow><tt>nv</tt><colsep>NVIDIA</tabrow> - <tabrow><tt>r128</tt><colsep>ATI Rage 128</tabrow> - <tabrow><tt>rendition</tt><colsep>Rendition</tabrow> - <tabrow><tt>s3virge</tt><colsep>S3 ViRGE</tabrow> - <tabrow><tt>sis</tt><colsep>SiS</tabrow> - <tabrow><tt>sunbw2</tt> (+)<colsep>Sun bw2</tabrow> - <tabrow><tt>suncg14</tt> (+)<colsep>Sun cg14</tabrow> - <tabrow><tt>suncg3</tt> (+)<colsep>Sun cg3</tabrow> - <tabrow><tt>suncg6</tt> (+)<colsep>Sun GX and Turbo GX</tabrow> - <tabrow><tt>sunffb</tt> (+)<colsep>Sun Creator, Creator3D and Elite 3D</tabrow> - <tabrow><tt>sunleo</tt> (+)<colsep>Sun Leo (ZX)</tabrow> - <tabrow><tt>suntcx</tt> (+)<colsep>Sun TCX</tabrow> - <tabrow><tt>tdfx</tt><colsep>3Dfx</tabrow> - <tabrow><tt>tga</tt><colsep>DEC TGA</tabrow> - <tabrow><tt>trident</tt><colsep>Trident</tabrow> - <tabrow><tt>tseng</tt><colsep>Tseng Labs</tabrow> - <tabrow><tt>vga</tt><colsep>Generic VGA</tabrow> -</tabular> -</table> - -Drivers marked with (*) are present in a preliminary form in this release, -but are not complete and/or stable yet. <p> +XFree86 &relvers; provides a partial implementation of Render sufficient +for drawing anti-aliased text and image composition. Still to be +implemented are geometric primitives and affine transformation of images. -Drivers marked with (+) are for Linux/Sparc only. - -<sect2>APM <label id="apm"> <p> - -This is the driver for Alliance AT3D/AT25 and AT24 chips. There is a rather -complete support for the functions with acceleration at 8,15,16,24 and 32 bits -(limited by the chip at 24bpp). There is preliminary, still buggy, support -for the AP6422 chip, which is still supported in 3.3.x servers. The Xv driver -is almost ok. The Rush extension for glide2x works, with some additions, -including overlay of the result. DGA and DGA2 have been tested ok. -Further information can be found in <htmlurl name="README.apm" url="apm.html">. +Unlike the core protocol, Render provides no font support for applications, +rather it allows applications to upload glyphs for display on the screen. +This allows the client greater control over text rendering and complete +access to the available font information while still providing hardware +acceleration. The Xft library provides font access for +Render applications. -<sect2>Chips & Technologies +<sect2>The Xft Library <p> -Information about the C&T driver can be found in <htmlurl -name="README.chips" url="chips.html">. +On the client side, the Xft library provides access to fonts for +applications using the FreeType library, version 2. FreeType currently +supports Type1 and TrueType font files, a future release is expected to +support BDF and PCF files as well, so Render applications will have access +to the complete range of fonts available to core applications. One +important thing to note is that Xft uses the vertical size of the monitor +to compute accurate pixel sizes for provided point sizes; if your monitor +doesn't provide accurate information via DDC, you may want to add that +information to <tt>XF86Config</tt>. -<sect2>s3virge <p> +To allow a graceful transition for applications moving from core text +rendering to the Render extension, Xft can use either core fonts or +FreeType and the Render extension for text. By default, Xft is configured +to support only core fonts, see the section on building FreeType support +for the changes needed to add FreeType/Render fonts. -The s3virge driver is a port of the 3.3.x SVGA S3 ViRGE driver. As -such it should be as stable and functional as previous XFree86 -releases. There are a couple additional benefits included primarily due -to common enhancements: - -<itemize> - <item>Depth 24 problems resolved with clients using 24/32 bpp pixmaps. - <item>Our common acceleration architecture (XAA) has been re-written, - as has the ViRGE acceleration code. You should find this version - has better performance than prior releases. - - <item>Multi-head is reported to work. - <item>The <tt>s3virge</tt> man page lists options and has configuration - notes for this release of the driver. - <item>Trio 3D and Trio 3D/2X support has been added, matching the 3.3.6 - driver. - <item>Supports screen rotation and shadow framebuffer. - -</itemize> - -Outstanding items not implemented or fully tested: - -<itemize> - <item>DGA support is implemented, but preliminary and untested. -</itemize> - -Further information can be found in <htmlurl name="README.s3virge" -url="s3virge.html">. - -<sect2>TGA <p> +The Xft library uses a configuration file, <tt>XftConfig</tt>, which +contains information about which directories contain font files and also +provides a sophisticated font aliasing mechanism. Documentation for that +file is included in the Xft man page. -The TGA driver is now accelerated and supports both 8 and 32 plane -framebuffers. It is known to work under Linux/Alpha. Please see the -<htmlurl name="README.DECtga" url="DECtga.html"> file for further -information. - -<sect2>Matrox +</sect2> +<sect2>Building FreeType support for Xft <p> - -The MGA driver supports the same range or hardware as XFree86 3.3.4, -but has a number of enhancements including multi-head support and -support for (non-destructive) overlays (8-bit + 24-bit). -Option <tt>"overlay"</tt> when the server is started in 32bpp -(<tt>-fbbpp 32</tt>) will enable the 8+24 mode. The current -implementation doesn't optimize away unnecessary exposures yet so the -performance of this option will be better in future release. -By default, the color key for the overlays is 255, but this can be -changed with the <tt>"ColorKey"</tt> option to work around problems in -specific programs. Valid values for the key are 2-255. +XFree86 &relvers; includes sources for FreeType version 2.0.1, but they are +not built and installed automatically. As a result, Xft is configured to +provide only core fonts by default. -This release contains performance enhancements for the G400 and particularly -for the G400 MAX. It also includes XvImage support for G200/G400 chips and -improved memory autodetection support. - - -Further information can be found in the <tt>mga</tt> man page. - -<sect2>ATI <p> +To build FreeType support for Xft, first FreeType must be built and +installed, either from the sources included in XFree86 in +<tt>extras/freetype2</tt> or from another FreeType (version 2.0.1 or later) +release. Early FreeType version 2 releases used a different header file +installation and aren't compatible with XFree86. Instructions for building and +installing FreeType can be found in the <tt>INSTALL</tt> file included with +the FreeType release. -Information about the ATI driver can be found in <url name="README.ati" -url="ati.html">. The current version is not accelerated. Acceleration -support is planned for a future release. - -<sect2>NVIDIA <p> - -The "nv" driver supports all Riva TNT accelerators as well as the -new GeForce and Quadro accelerators. DGA 2.0 support is included. +Second, XFree86 needs to know the installed location for FreeType, usually +<tt>/usr/local</tt>. Edit (or create) <tt>config/cf/host.def</tt> to +include: +<quote><p> + #define Freetype2Dir /usr/local +</quote> -Further information can be found in the nv man page. +<p> +Finally, build XFree86 with "make World" from the top. +</sect2> -<sect2>Glide +<sect2>Application Support For Anti-Aliased Text <p> -This driver is for Voodoo 1 and Voodoo 2 boards. It runs X on top of -the 3DFX Glide API (where this is available, like for Linux). You need -to have Glide 2.x installed before you can run this driver. This -driver uses no hardware acceleration (since there is no 2D -acceleration in these boards) but is rather quick anyway since the CPU -renders to local RAM which is then copied block-wise to the -board. Unfortunately the Voodoo 1/2 boards are rather limited in -resolution. The Voodoo 1 can do 800x600 and the Voodoo 2 can do -1024x768 at best, but still it has some use as a second head in -Xinerama or multihead mode. -16 and 24 bpp modes are supported (24 bit in 32-bit sparse-packed -mode). +Only three applications have been modified in XFree86 &relvers; to work +with the Render extension and the Xft and FreeType libraries to provide +anti-aliased text. Xterm, xditview and x11perf. Migration of other +applications may occur in future releases. -Further information about this driver can be found in the 'glide' driver -man page for XFree86. You will not get this driver running before -reading this man page. +<p> +By default, xterm uses core fonts through the standard core API. It has +two command line options and associated resources to direct it to use +Xft instead: +<itemize> + <item><tt>-fa</tt> family / <tt>.VT100.faceName:</tt> family. Selects the + font family to use. + <item><tt>-fs</tt> pointsize / <tt>.VT100.faceSize:</tt> pointsize. + Selects the pointsize. +</itemize> -For Voodoo Banshee and Voodoo 3 boards or later: Please use the tdfx -driver which talks directly to the hardware and is much faster. +<p> +Xditview will use Xft instead of the core API by default. X11perf +includes tests to measure the performance of text rendered in three ways, +anti-aliased, anti-aliased with sub-pixel sampling and regular chunky +text, but through the Render extension, a path which has not been +optimized within the X server yet. +</sect2> -<sect2>GLINT <label id="glint"> +<sect1>Other extensions <p> -The "glint" driver supports most 3Dlabs/Texas Instruments GLINT/Permedia -chips. There is a rather complete support (better than in 3.3.x) for -acceleration at 8, 15, 16, and 24 bit depths (limited by some chips at -some depths). 8+24 overlay is supported. The Xv extension is supported -for some boards. +The XFree86-Misc extension has not been fully ported to the new server +architecture yet. This should be completed in a future release. -Further information about this driver can be found in the 'glint' driver -man page. +The XFree86-VidModeExtension extension has been updated, and mostly +ported to the new server architecture. The area of mode validation +needs further work, and the extension should be used with care. This +extension has support for changing the gamma setting at run-time, for +modes where this is possible. The new <tt>xgamma</tt> utility makes +use of this feature. Compatibility with the 3.3.x version of the +extension is provided. The missing parts of this extension and some +new features should be completed in a future release. + +<!-- <sect>X libraries and clients <p> +--> <sect1>Xaw <p> -Two versions of the Xaw library are provided in this release. A version with +Two versions of the Xaw library are provided with XFree86 4.x. A version with bug fixes and a few binary compatible improvements and a new version with several new features. @@ -1003,14 +1186,6 @@ </itemize> -<!-- is this still true? - <item>This release shows the current state of the work to add to the Xaw - text widget WYSIWYG capabilities. The state is very initial, and - can be seen as a candidate to a candidate to a very early alpha - snapshot. There is no public interface for programming yet, because - the current one is very likely to change before ready to use. ---> - </itemize> Bug fixes: @@ -1036,207 +1211,6 @@ Version 3.4k of the Xpm (X pixmap) library is now integrated into XFree86. -<sect1>xterm -<p> - -New Features: - -<itemize> - <item>Support Unix98 PTY's. - - <item>Support Unicode using UTF-8 input and output. There are a few - limitations, this work is still in progress: - - <itemize> - <item>You must use the <tt>-u8</tt> command line option to - use this feature, as well as compile with the - <tt>OPT_WIDE_CHARS</tt> definition. (The feature is - compiled when using imake). - - <item>Input (from keyboard) and output (select/paste) are in - UTF-8 form. There is no support in Xlib for UTF-8; - xterm uses a lookup table to map keysym codes. - Select/paste is done either via <tt>STRING</tt> or using - the new atom <tt>UTF8_STRING</tt>. - - </itemize> - - <item>Add optional feature (resource and command-line options) to make - xterm use the PTY's sense of erase character on startup, rather - than requiring it to be <tt>\177</tt>, or set the PTY's erase - character to match xterm's configuration. Note that while - <tt>$TERMCAP</tt> is modified to reflect the actual configuration, - the terminfo <tt>kdch1</tt> string is not. (This feature is - also in XFree86 3.3.4). - - <item>Revised keyboard handling, making two modes (VT220 and Sun/PC) which - are switched by popup menu. This makes the numeric keypad work as - expected. Codes sent by the backarrow and delete keys also are - affected. - - <item>Add parameters to function key escape sequences to indicate if - shift, control or alt are set. This works for Sun/PC keyboard - mode. - - <item>Separated command-line and menu settings for reverse video from that - done under program control. This is a problem which was introduced - by X11R6. Though correct, most users are confused by allowing - the reset command to undo the effect of the command-line - <tt>-rv</tt> option. - - <item>Blinking cursor can be specified by resource or popup menu. - - <item>New control sequences for switching between normal and alternate - screens maintain separate cursor-save locations for the two screens, - avoiding incorrect cursor placement on exit from vi. - - <item>Support line-drawing characters when the font does not include them - by drawing them. - - <item>Add support for switching font sizes, by stepping through the font - menu using shifted keypad plus and minus. - - <item>New resource <tt>trimSelection</tt> allows xterm to trim trailing - blanks from selected lines. - - <item>Provide user applications a means of determining the version of xterm - for feature comparison by returning the patch number (e.g., 111) in - the secondary DA response. - - <item>Modify treatment of <tt>XK_Delete</tt> keysym so it transmits - parameterized VT220-style "<tt><esc>[3~</tt>" if modifiers - (shift, control alt) are given. - - <item>Add ``cacheDoublesize'' resource to limit the caching of font - information for double-sized characters, to accommodate X terminals - with limited font memory. - - <item>Add ``metaSendsEscape'' resource, with corresponding control sequence - and menu entry. Like ``eightBitInput'', this causes xterm to send ESC - prefixing the given key, but applies to all keys and is independent - of the 8-bit/7-bit terminal setting. - - <item>Implement an 88-color model for systems where 256-colors cannot be - allocated. - - <item>Add support for DEC Locator control sequences for xterm. This allows - the xterm mouse to be used with applications that use the DEC Locator - sequences, such as VAX Tpu, or SMG$ based applications. - - <item>Implement <tt>-hold</tt> option, allowing users to retain the window - after a shell has exited. - - <item>Add an application resource, ``messages'' (and a corresponding - <tt>-</tt>/<tt>+mesg</tt> option) which controls the initial - permission on the terminal. - - <item>Implement UTF-8 translation for Media Copy (print) operations. - - <item>Implement vt320 control sequences for Print Composed Main Display and - for Print All Pages. The latter directs xterm to print the current - screen as well as the scrollback buffer. - -</itemize> - -Bug fixes/improvements: - -<itemize> - <item>If <tt>colorMode</tt> is enabled by default, compile-in default - resources to match the colors listed in <tt>XTerm-col.ad</tt>. - - <item>Deprecate DA answerback string, making it settable via a resource - value for applications which may need this. - - <item>Input characters which are mapped when in vt220 National Replacement - Character mode. - - <item>Completed support for double size characters. - - <item>Remove <tt>kfnd</tt>/<tt>kll</tt>/<tt>kslt</tt> strings from - terminfo, because curses applications do not necessarily return - <tt>khome</tt>/<tt>kend</tt> pairs. - - <item>Corrected ifdef's for menus, which did not allow tek4014 to be - suppressed properly. - - <item>Improved tests for determining if xterm should use overstriking to - simulate bold fonts. - - <item>Add test/demo scripts for double size characters, font switching, - screen resizing and colors. - - <item>Amend treatment of ALT key so that if ALT is used as a modifier in - key translations, then no parameter will be sent in escape sequences - for Sun/PC function keys. - - <item>Improved the ptyInitialErase logic to make it work better with - a terminfo library. - - <item>Modify treatment of line-drawing characters in UTF-8 mode so that - Unicode values are used rather than characters 1-31 for storing the - translated characters. - - <item>Modify translation of UTF-8 sequences to reject ``overly long'' - variations. - - <item>Correct a case where colors were not rendered properly. This - happened when an application inserted several lines, then changed - colors. If this was done all in one write, then there would be no - intervening refresh, and the new color was applied to the pending - scrolling operation which was awaiting the next refresh. - - <item>Corrected misspelled resource name in command-line option for HP - function keys. - - <item>Change label on ``Sun/PC Keyboard'' popup menu entry to ``VT220 - Keyboard'', since the checked state corresponds to VT220 rather than - Sun/PC. - - <item>Two corrections to simulation of bold font via overstriking: - - <itemize> - - <item>use clipping to avoid leaving trash at end of the text, and - - <item>add brackets so wide-character logic does not fall-through - into the overstriking logic. - - </itemize> - - <item>Modify checks for repeat-character control sequence to test the - character class against xterm's state table, rather than the - <tt>isprint()</tt> macro. - - <item>Modify terminfo entry for ``xterm-xfree86'' to reflect modifiers for - shift and control. - - <item>Add several entries to termcap file to make it have the same set - of aliases as the terminfo file. - - <item>Scale the color values used for xterm-256color terminfo entry to - 0..1000, as expected by ncurses. - - <item>Change xterm-r6 terminfo definitions for F1-F4 to match program. - - <item>Remove obsolete documentation about modifiers which can be returned - in mouse tracking mode, and modify logic to ignore modifiers other - than the existing ones, e.g., NumLock. - - <item>Use free bit from obsolete shift-modifier coding of mouse tracking - button events to encode buttons 4 and 5, e.g., for a wheel mouse. - Move the suggested wheel-mouse button translations into charproc.c to - simplify customization. - - <item>Modify warning if change-ownership of PTY fails; some - configurations may not happen to have old-style PTY's. - - <item>Add more information, i.e., with strerror for some system calls in - the main program which may fail due to insufficient permissions. - - <item>Various improvements to configure script, e.g., tests for utmp. - -</itemize> - <sect1>xedit <p> @@ -1284,12 +1258,6 @@ <item><bf>C-mode:</bf> this mode is expected to be stable, and fully usable. -<!-- This was removed, right? - - <item><bf>Html-mode:</bf> a lot of work needs to be done yet. It is - included in this snapshot only to show what the new text widget - capabilities can do. ---> </itemize> </itemize> @@ -1297,16 +1265,21 @@ <p> +<!-- <sect>Fonts and Internationalisation <p> +--> + +<sect1>Font support +<p> -Details about the font support in this version of XFree86 can be found +Details about the font support in XFree86 4.x can be found in the <htmlurl name="README.fonts" url="fonts.html"> document. <sect1>TrueType support <p> -This version of XFree86 comes with two TrueType backends, known as +XFree86 4.x comes with two TrueType backends, known as `xfsft' (the <tt>"freetype"</tt> module) and `X-TrueType' (the <tt>"xtt"</tt> module). Both of these backends are based on the FreeType library. @@ -1314,7 +1287,7 @@ <sect1>CID font support <p> -Support for CID-keyed fonts is included in this version of XFree86. +Support for CID-keyed fonts is included in XFree86 4.x. The CID-keyed font format was designed by <url name="Adobe Systems" url="http://www.adobe.com"> for fonts with large character sets. The CID-keyed font support in XFree86 was donated by <url name="SGI" @@ -1325,7 +1298,7 @@ <sect1>Internationalisation of the scalable font backends <p> -A new ``fontenc'' layer has been added to allow the scalable font backends +XFree86 4.x has a ``fontenc'' layer to allow the scalable font backends to use a common method of font re-encoding. This re-encoding makes it possible to uses fonts in encodings other than their their native encoding. This layer is used by the Type1 and Speedo backends and the @@ -1343,7 +1316,7 @@ <sect1>Unicode/ISO 10646 support <p> -What is included: +What is included in 4.x: <itemize> <item>All ``-misc-fixed-*'' BDF fonts are now available in the @@ -1382,27 +1355,6 @@ </itemize> -Known problems: - -<itemize> - <item>Xlib does not yet fully support UTF-8 as a locale, which means that - xterm UTF-8 keyboard support is at the moment a temporary hack. - - <item>Most ISO10646-1 fonts encode no characters above U+31FF. This - avoids the inefficient allocation and transmission of a - >700 kB large XFontStruct structure, which would happen if the - (not very important) ligatures and symbols above U+f000 were - present. - - <item>ISO 10646 Level 2 combining characters are not yet supported by - xterm (will be needed for instance for Thai and IPA). - - <item>Switching between a half-width and full-width font pair (such - as 9x18 and 18x18ja) is not yet supported by xterm (will be - needed for CJK scripts). - -</itemize> - <sect1>Lucidux fonts from Bigelow and Holmes <p> @@ -1419,14 +1371,16 @@ <email>sales@yandy.com</email>, or consult <url name="Y&Y's web site" url="http://www.yandy.com">. +<!-- <sect>Miscellaneous <p> +--> <sect1>Directory rearrangements <p> Some changes to the installed XFree86 directory structure have been -implemented for 4.0. +implemented for 4.x. One important change is a modified search path for the X server's <tt>XF86Config</tt> file. The details of this can be found Index: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml:1.17 xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml:1.26 --- xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml:1.17 Mon Jun 19 11:00:54 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml Thu Dec 14 17:15:48 2000 @@ -6,10 +6,10 @@ <title>Driver Status for XFree86™ &relvers; <author>The XFree86 Project, Inc -<date>3 March 2000 +<date>4 December 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.17 2000/06/19 15:00:54 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.26 2000/12/14 22:15:48 dawes Exp $ </ident> <abstract> @@ -31,27 +31,38 @@ drivers and the hardware they support, including a comparison of the level of support between versions &legacyvers; and &relvers;. -NOTE: Status information needs to be checked carefully and expanded -where possible. E.g., include information about acceleration, multi-head, -known problems, hardware known to work on, platform -dependencies/limitations, other architectures known to work on -(e.g., Alpha, PPC), etc. +In XFree86 &legacyvers;, several X servers are available; much hardware +uses the XF86_SVGA server, which has a set of driver modules that are built +into it at compile time. In other cases, X servers for specific chips (or +families of chips) are provided (such as XF86_AGX, XF86_Mach64, etc.). + +In XFree86 &relvers;, there is only one X server, called "XFree86", which +can load driver modules at runtime. Thus there is no specific mention of a +server binary when &relvers; is discussed; only the XFree86 server is +used. Third-party vendors (often the manufacturers of various video +chipsets) may provide their own drivers for the XFree86 server, but these +third-party modules are beyond the scope of this document. + +NOTE: Status information needs to be checked carefully and expanded where +possible. E.g., include information about acceleration, multi-head, known +problems, hardware known to work on, platform dependencies/limitations, +other architectures known to work on (e.g., Alpha, PPC), etc. <sect>3Dfx <p> <descrip> <tag>&legacyvers;:</tag> - Support (including acceleration) for Voodoo Banshee and Voodoo - 3. Support is provided by the XF86_SVGA server with the tdfx - driver). + Support (including acceleration) for Voodoo Banshee and Voodoo3 + cards is provided by the XF86_SVGA server with the tdfx driver. <tag>&relvers;:</tag> - Support for Voodoo 1 and Voodoo 2 via glide on platforms where - glide is available (Linux and FreeBSD(?)). Support is provided by - the "glide" driver (requires Glide 2x). + Support for Voodoo Graphics and Voodoo 2 chips is available on + platforms where Glide is available (Linux and FreeBSD(?)) and is + provided by the "glide" driver (requires version 2.x of the Glide + library, which is not part of the XFree86 distribution). - Support (including acceleration) for Voodoo Banshee and Voodoo 3. - Support is provided by the "tdfx" driver. + Support (including acceleration) for Voodoo Banshee, Voodoo3, + Voodoo4, and Voodoo5 is provided by the "tdfx" driver. <tag>Summary:</tag> All hardware supported in &legacyvers; is also supported in &relvers;. @@ -64,17 +75,18 @@ <tag>&legacyvers;:</tag> Support (including acceleration) for GLINT 500TX (with IBM RGB526 ramdac), GLINT MX plus Delta or Gamma (with IBM RGB526 and RGB640 - ramdacs), Permedia with IBM RGB526 ramdac, Permedia 2, 2a, 2v. - Support is provided by the XF86_3DLabs server. + ramdacs), Permedia with IBM RGB526 RAMDAC, and Permedia 2, 2a, 2v + is provided by the XF86_3DLabs server. <tag>&relvers;:</tag> - Support (including acceleration) for Permedia, Permedia 2, 2v - (and 2a??) GLINT 500TX, GLINT MX, GLINT Gamma, and Glint Delta - coproc. Support is provided by the "glint" driver. + Support (including acceleration) for Permedia, Permedia 2, 2v, (and + 2a?), Permedia 3, GLINT 500TX, GLINT MX, GLINT Gamma, and GLINT + Delta coproc is provided by the "glint" driver. <tag>Summary:</tag> All hardware supported in &legacyvers; is also supported in &relvers;. + The Permedia 3 is only supported in &relvers;. </descrip> @@ -106,11 +118,11 @@ Support is provided by the XF86_SVGA server with the ark driver. <tag>&relvers;:</tag> - No native support for these chipsets, because the old driver - has not been ported. + Support (including acceleration) for the ARK1000PV, ARK2000PV, + and ARK2000MT. Support is provided by the "ark" driver. <tag>Summary:</tag> - No ARK Logic chips are supported in &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. </descrip> @@ -132,11 +144,10 @@ server with the r128 driver. <tag>&relvers;:</tag> - Accelerated support is provided for the Rage 128 chips by the - "r128" driver. Accelerated support is provided for the Mach64 - Rage variants by the "ati" driver. Unaccelerated support is - provided for all of the others except the Mach8 and some early - Mach32 chips by the "ati" driver. + Accelerated support is provided for Mach64, Rage, Rage 128 and + Radeon chips. Unaccelerated support is provided for all of the + others except the Mach8 and some early Mach32 chips by the "ati" + driver. <tag>Summary:</tag> All chips supported in &legacyvers; are supported in &relvers; @@ -153,8 +164,7 @@ Support for the AL2101, ALI2228, ALI2301, ALI2302, ALI2308, ALI2401 chipsets. Support is provided by the XF86_SVGA server, using the al2101 driver for the AL2101, and the ali driver for - the others. The status of this support is unknown because we - don't have any recent test reports, and these drivers have no + the others. These drivers reportedly work, but they have no maintainer. <tag>&relvers;:</tag> @@ -181,8 +191,7 @@ and 64300. This support is provided by the "chips" driver. <tag>Summary:</tag> - All chips supported in &legacyvers; are also supported in - &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. </descrip> @@ -198,15 +207,14 @@ XF86_SVGA server with the cirrus driver. <tag>&relvers;:</tag> - Support (accelerated) for the Alpine (5430, 5434, 5436, 5446, - 5480), and Laguna (5462, 5464, 5465) chips is provided by the + Support (accelerated) for the Alpine (5430, 5434, 5436, 5446, 5480, + 7548), and Laguna (5462, 5464, 5465) chips is provided by the "cirrus" driver. <tag>Summary:</tag> The following chips are supported in &legacyvers; but not in &relvers;: 6410, 6412, 6420, 6440, 5420, 5422, 5424, 5426, 5428, - 5429, 6205, 6215, 6225, 6235, 7541, 7542, 7543, 7548, 7555 and - 7556. + 5429, 6205, 6215, 6225, 6235, 7541, 7542, 7543, 7555 and 7556. </descrip> @@ -232,7 +240,7 @@ <tag>Summary:</tag> No Compaq AVGA support in &relvers;. DEC TGA support is equivalent - in both versions. + in both &legacyvers; and &relvers;. </descrip> @@ -244,11 +252,12 @@ XF86_SVGA server with the cyrix driver. <tag>&relvers;:</tag> - A preliminary port of the driver is available, but it isn't - ready for widespread use. + The &legacyvers; driver has been ported to &relvers;, including + acceleration, but feedback is needed. <tag>Summary:</tag> - No Cyrix chips are well-supported in &relvers;. + Cyrix MediaGX users are encouraged to test its support in + &relvers;. </descrip> @@ -317,7 +326,7 @@ <descrip> <tag>&legacyvers;:</tag> Support (accelerated) for the AGX-016, AGX-015 and AGX-014 is - provided by the XF86_AGX server.. + provided by the XF86_AGX server. <tag>&relvers;:</tag> No native support for these chipsets, because the old driver @@ -328,6 +337,22 @@ </descrip> +<sect>Integrated Micro Solutions (IMS) +<p> +<descrip> +<tag>&legacyvers;:</tag> + Support (accelerated) for the IMS Twin Turbo 128 is provided by the + XF86_SVGA server with the imstt driver. + +<tag>&relvers;:</tag> + Support (accelerated) for the IMS Twin Turbo 128 is provided by the + "imstt" driver. + +<tag>Summary:</tag> + All hardware supported in &legacyvers; is also supported in &relvers;. + +</descrip> + <sect>Intel <p> <descrip> @@ -364,8 +389,7 @@ and G400 is provided by the "mga" driver. <tag>Summary:</tag> - All chips supported in &legacyvers; are also supported in - &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. </descrip> @@ -415,12 +439,12 @@ <tag>&relvers;:</tag> Support (accelerated) for the NeoMagic NM2070, NM2090, NM2093, - NM2097, NM2160 and NM2200 chipsets is provided by the "neomagic" - driver. + NM2097, NM2160, NM2200, NM2230, NM2360 and NM2380 chipsets is + provided by the "neomagic" driver. <tag>Summary:</tag> - All chips supported in &legacyvers; are also supported in - &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. + The NM2230 and later chips are only supported in &relvers;. </descrip> @@ -434,12 +458,13 @@ <tag>&relvers;:</tag> Support (accelerated) for the Riva 128, 128ZX, TNT, TNT2 (Ultra, - Vanta, M64), GeForce (DDR, 256) and Quadro is provided by - the nv driver. + Vanta, M64), GeForce (DDR, 256), GeForce2 (GTS, Ultra, MX), Quadro, + and Quadro2 is provided by the "nv" driver. <tag>Summary:</tag> All chipsets supported in &legacyvers; except the NV1 are also - supported in &relvers;. + supported in &relvers;. Support for the newer chips (GeForce2 and + later) is only available in &relvers;. </descrip> @@ -452,15 +477,15 @@ server. <tag>&relvers;:</tag> - No native support for these chipsets, because the old driver - has not been ported. + Support (accelerated) for the Imagine 128, Ticket 2 Ride, + Revolution 3D and Revolution IV is provided by the "i128" driver. <tag>Summary:</tag> - No Number Nine chips are supported in &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. </descrip> -<sect>Oak Technologies Inc +<sect>Oak Technologies, Inc. <p> <descrip> <tag>&legacyvers;:</tag> @@ -526,8 +551,7 @@ "rendition" driver. <tag>Summary:</tag> - All chips supported in &legacyvers; are also supported in - &relvers;. + All hardware supported in &legacyvers; is also supported in &relvers;. </descrip> @@ -535,31 +559,46 @@ <p> <descrip> <tag>&legacyvers;:</tag> - Support (accelerated) for the S3 911, 924, 801, 805, 928, 864, - 868, 964, 968, Trio32, Trio64, Trio64V+, Trio64UV+, Aurora64V+, + Support (accelerated) for the S3 911, 924, 801, 805, 928, 864, 868, + 964, 968, Trio32, Trio64, Trio64V+, Trio64UV+, Aurora64V+, Trio64V2, PLATO/PX is provided by the XF86_S3 server and the XF86_SVGA server with the s3_svga driver. Support (accelerated) for the ViRGE, ViRGE/VX, ViRGE/DX, ViRGE/GX, ViRGE/GX2, ViRGE/MX, ViRGE/MX+ is provided by the XF86_S3V server. Support (accelerated) for those ViRGE chips, as well as the Trio3D and - Trio3D/2X is provided by the XF86_SVGA server with the s3v - driver. Support (accelerated) for the Savage3D, Savage3D/MV, - Savage4, Savage2000, Savage/MX-MV, Savage/MX, Savage/IX-MV and - Savage/IX is provided by the XF86_SVGA server with the s3_savage - driver (CHECK: is this support Linux-only?). + Trio3D/2X is provided by the XF86_SVGA server with the s3v driver. + Support (accelerated) for the Savage3D, Savage3D/MV, Savage4, and + Savage2000, is provided by the XF86_SVGA server with the s3_savage + driver on some OSes (Linux, *BSD). <tag>&relvers;:</tag> Support (accelerated) for the ViRGE, ViRGE/VX, ViRGE/DX, ViRGE/GX, - ViRGE/GX2, ViRGE/MX, ViRGE/MX+, Trio3D and Trio3D/2X is provided - by the "s3virge" driver. Support for the other S3 chipsets has - not yet been ported. + ViRGE/GX2, ViRGE/MX, ViRGE/MX+, Trio3D and Trio3D/2X is provided by + the "s3virge" driver. Support (accelerated) for the Savage3D, + Savage3D/MV, Savage4, and Savage2000, is provided by the "savage" + driver. Support for the other S3 chipsets has not yet been ported. <tag>Summary:</tag> - Only the ViRGE and Trio3D chipsets are supported in &relvers;. + Only the ViRGE, Trio3D and Savage chipsets are supported in &relvers;. All of the other chipsets are only supported in &legacyvers;. </descrip> +<sect>Silicon Graphics, Inc. (SGI) +<p> +<descrip> +<tag>&legacyvers;:</tag> + No SGI hardware is supported in &legacyvers;. + +<tag>&relvers;:</tag> + Unaccelerated support for the SGI Indy's Newport cards is provided + by the "newport" driver. + +<tag>Summary:</tag> + SGI hardware is supported only in &relvers;. + +</descrip> + <sect>Silicon Integrated Systems (SiS) <p> <descrip> @@ -580,7 +619,7 @@ </descrip> -<sect>Silicon Motion, Inc +<sect>Silicon Motion, Inc. <p> <descrip> <tag>&legacyvers;:</tag> @@ -589,12 +628,31 @@ smi driver. <tag>&relvers;:</tag> - No native support for these chipsets, because the driver - has not been ported. + Support (accelerated) for the Lynx, LynxE, Lynx3D, LynxEM, LynxEM+ + and Lynx3DM chips is provided by the "siliconmotion" driver. + +<tag>Summary:</tag> + All hardware supported in &legacyvers; is also supported in &relvers;. + +</descrip> + +<sect>Sun Microsystems +<p> +<descrip> +<tag>&legacyvers;:</tag> + No Sun hardware is supported in &legacyvers;. + +<tag>&relvers;:</tag> + Sun BW2 framebuffers are supported by the "sunbw2" driver. + Sun CG3 framebuffers are supported by the "suncg3" driver. + Sun CG6 framebuffers are supported by the "suncg6" driver. + Sun CG14 framebuffers are supported by the "suncg14" driver. + Sun FFB framebuffers are supported by the "sunffb" driver. + Sun LEO framebuffers are supported by the "sunleo" driver. + Sun TCX framebuffers are supported by the "suntcx" driver. <tag>Summary:</tag> - No SMI chips are supported in &relvers;, but the fbdev driver is - reported to work on Linux. + Sun hardware is supported only in &relvers;. </descrip> @@ -614,17 +672,19 @@ <tag>&relvers;:</tag> Support (accelerated where the chip supports it) for the TVGA8900D, - TGUI9420DGi, TGUI9440AGi, TGUI9660, TGUI9680, ProVidia 9682, - ProVidia 9685, Cyber9320, Cyber9382, Cyber9385, Cyber9388, - Cyber9397, Cyber9520, Cyber9397/DVD, Cyber9525/DVD, 3DImage975, - 3DImage875, Blade3D, CyberBlade/i7, CyberBlade/DSTN/i7 and - CyberBlade/i1 is provided by the "trident" driver. + TGUI9440AGi, TGUI9660, TGUI9680, ProVidia 9682, ProVidia 9685, + Cyber9320, Cyber9382, Cyber9385, Cyber9388, Cyber9397, Cyber9397/DVD, + Cyber9520, Cyber9525/DVD, 3DImage975, 3DImage985, Blade3D, + CyberBlade/i7, CyberBlade/DSTN/i7, CyberBlade/i1, CyberBlade/DSTN/i1, + CyberBlade/Ai1, CyberBlade/DSTN/Ai1 and CyberBlade/e4 is provided + by the "trident" driver. <tag>Summary:</tag> The following (older) chipsets that are supported in &legacyvers; are not supported in &relvers;: TVGA8200LX, TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000, TVGA9000i, TVGA9100B, TVGA9200CXr, - TGUI9400CXi, TGUI9420, TGUI9430DGi. + TGUI9400CXi, TGUI9420, TGUI9430DGi. The remaining listed chipsets + are supported in &relvers;. </descrip> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml:3.31 xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml:3.34 --- xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml:3.31 Mon Jun 19 11:00:54 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml Thu Dec 7 10:43:41 2000 @@ -8,10 +8,14 @@ <title>ATI Adapters README file <author>Marc Aurele La France -<date>2000 June 15 +<date>2000 December 6 + + + + <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.31 2000/06/19 15:00:54 tsi Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.34 2000/12/07 15:43:41 tsi Exp $ </ident> <abstract> @@ -83,9 +87,12 @@ 3D Rage Mobility (including the -M and -P variants)</verb> The driver also supports 32K, 64K and 16M-colour modes on the 264xT and 3D Rage series of adapters using the accelerator CRTC (but not the VGA CRTC).<p> -The newer Rage 128 chips are not yet supported by this driver. -Rage 128's are, however, supported by a separate driver, and Rage 128 owners -should read the r128 driver's documentation for details.<p> +The newer Rage 128 and Radeon chips are not yet supported by this driver. +Rage 128's and Radeon's are, however, supported by separate drivers, and +owners of such adapters should consult the documentation provided with these +drivers. +This driver will also invoke the appropriate driver if it finds Rage 128 and/or +Radeon adapter(s) in the system.<p> Adapters based on the above chips have been marketed under a rather large number of names over the years. Among them are: @@ -135,9 +142,12 @@ XF86Config options are available to disable this aperture, or (for non-PCI adapters) enable it or move it to some other address.<p> By default, the driver provides some acceleration for Mach64 if the accelerator -CRTC is used. +CRTC is used, and modes whose colour depth greater than or equal to 8 are to be +used. This support is as yet incomplete and can be disabled entirely with an XF86Config option.<p> +On non-Intel platforms, the driver can, currently, only support PCI Mach64 +adapters.<p> <sect>Current implementation of generic VGA support for non-ATI adapters<p> Support for generic VGA with non-ATI adapters is also implemented, but has undergone only limited testing. @@ -145,7 +155,7 @@ adapters. This support must be explicitly requested through an XF86Config ChipSet specification. -This prevents the current generic driver from being disabled.<p> +This prevents the current VGA generic driver from being disabled.<p> This driver's generic VGA support is intended as an extension of that provided by the current generic driver. Specifically, within the architectural bounds defined by IBM's VGA standard, @@ -212,6 +222,8 @@ These ChipSet names should, therefore, only be used when there is in fact such an adapter in the system. They are otherwise equivalent to ``<it>ati</it>''.<p> +On non-Intel platforms, only ``<it>ati</it>'' and ``<it>mach64</it>'' ChipSet +values are operative.<p> <sect1>ChipID & ChipRev specifications<p> These specifications will cause the driver to associate the ``Device'' section only with an adapter having the same attributes, or an adapter whose PCI device @@ -348,7 +360,8 @@ 18.750 19.375 20.000 22.500 6.294 7.081 7.875 9.000 25.000 27.500 31.500 33.750 10.000 11.225 12.500 16.250</verb> VGAWonder VLB, VGA 1024 VLB, Mach32 and Mach64 owners should only specify up to -the first 32 frequencies.<p> +the first 32 frequencies. +Any more will be ignored.<p> Other clock generators that have been used on ATI adapters (which can all be said to be clones of one of the above) might generate non-zero frequencies for those that are zero above, or vice-versa.<p> @@ -366,11 +379,9 @@ <sect1>Option <it>``crt_screen''</it><p> This specification is only effective when the driver detects that the adapter's BIOS has initialised both the digital flat panel and CRT interfaces. -In such a situation, the driver will normally drive the panel and disable the -CRT. +In such a situation, the driver will normally drive both the panel and the CRT. This specification causes the driver to disable the digital flat panel and -display the screen image on the CRT instead. -This specification will be reworked in the near future.<p> +display the screen image on the CRT instead.<p> <sect1>Option <it>``noaccel''</it><p> By default, the driver will accelerate draw operations if a Mach64 CRTC is used to drive the display. @@ -382,6 +393,8 @@ 256-colour and higher depth modes if it is also using a Mach64 accelerator CRTC or an integrated Mach64 graphics chip. This option disables this linear aperture.<p> +On non-Intel platforms, the driver requires a linear aperture and, so, this +option should not be specified.<p> <sect1>Option <it>``shadowfb''</it><p> If this option is enabled, the driver will cause the CPU to do each drawing operation first into a shadow frame buffer in system virtual memory and then @@ -416,6 +429,25 @@ to the PCI Plug'n'Play specification which arbitrates the resource requirements of most devices in the system. This means the driver can not easily change the linear aperture address.<p> +<sect1>Option <it>``ReferenceClock''</it> ``frequency''<p> +This option is only applicable to non-Intel platforms, where an adapter BIOS is +not available to the driver. +The option specifies the reference frequency used by the adapter's clock +generator. +The default is 14.318 MHz, and other typical values are 28.636, or 29.5 MHz.<p> +<sect1>ClockChip <it>``name''</it><p> +This option is only applicable to non-Intel platforms, where an adapter BIOS is +not available to the driver, and the driver cannot reliably determine whether +the clock generator the adapter uses is a variant of an ATI 18818 (a.k.a. +ICS 2595) or an unsupported clock generator. +The only values that are acted upon are <it>``ATI 18818-0''</it> or +<it>``ATI 18818-1''</it>. +From this specification, the driver derives a reference divider of 43 or 46 +(respectively) for use in clock programming calculations. +The driver's default behaviour, in this case, is to assume an unsupported clock +generator, which means it will treat it as a fixed-frequency clock generator, +as described under the heading <bf>``Clocks for unsupported programmable clock +generators''</bf> above.<p> <sect>Video modes<p> Mode timings can be derived from the information in XFree86's doc subdirectory. However, it is no longer required to specify such timings in an XF86Config's @@ -570,4 +602,6 @@ 3.3.5 and 3.3.6.<p> Version 5 is an almost complete restructuring of version 4 to fit in the newer driver API of XFree86 4.0 and later.<p> +The introduction of version 6 is a first swipe at porting the driver to +non-Intel architectures.<p> </article> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml:3.31 xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml:3.33 --- xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml:3.31 Tue Jun 13 21:43:49 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml Sat Dec 2 16:52:22 2000 @@ -11,7 +11,7 @@ <date> 14th June 2000 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.31 2000/06/14 01:43:49 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.33 2000/12/02 21:52:22 dbateman Exp $ </ident> <!-- Table of contents --> @@ -295,10 +295,10 @@ select a different clock for the server to use when returning to the text console. <tag> -Option "FPClock8" "65.0" -Option "FPClock16" "65.0" -Option "FPClock24" "65.0" -Option "FPClock32" "65.0" +Option "FPClock8" "65.0MHz" +Option "FPClock16" "65.0MHz" +Option "FPClock24" "65.0MHz" +Option "FPClock32" "65.0MHz" </tag> In general the LCD panel clock should be set independently of the modelines supplied. Normally the chips BIOS set the flat panel @@ -401,6 +401,14 @@ rendering is all done into a virtual framebuffer acceleration can not be used. <tag> +Option "NoTMED" +</tag> + The new TMED DSTN dithering scheme available on recent HiQV chipsets + gives improved performance. However, some machines appear to have this + feature incorrectly setup. If you have <tt>snow</tt> on your DSTN + LCD, try using this option. This option is only relevant for chipsets + more recent than the ct65555 and only when used with a DSTN LCD. +<tag> Option "Overlay" </tag> The HiQV chipsets contain a multimedia engine that allow a 16bpp @@ -831,6 +839,14 @@ The XVideo extension has only recently been added to the chips driver. Some YUV to RGB colour have been noted at 15 and 16 bit colour depths. However, 8 and 24 bit colour depths seem to work fine. +<tag> My ct69030 machine locks up when starting XFree</tag> + The ct69030 chipset introduced a new dual channel architecture. In its + current form, XFree can not take advantage of this second display + channel. In fact if the video BIOS on the machine sets the ct69030 + to a dual channel mode by default, XFree will lockup hard at this + point. The solution is to use the BIOS setup to change to a single + display channel mode, ensuring that both the IOSS and MSS registers + are set to a single channel mode. Work is underway to fix this. <tag> I can't start X-windows with 16, 24 or 32bpp</tag> Firstly, is your machine capable of 16/24/32bpp with the mode specified. Many LCD displays are incapable of using a 24bpp Index: xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent:1.13 xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent:1.15 --- xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent:1.13 Fri Jun 30 12:54:28 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent Fri Dec 8 14:10:25 2000 @@ -1,18 +1,21 @@ -<!-- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent,v 1.13 2000/06/30 16:54:28 dawes Exp $ --> +<!-- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent,v 1.15 2000/12/08 19:10:25 dawes Exp $ --> <!-- shared entity definitions for the XFree86 documentation --> <!-- XFree86 version string --> -<!ENTITY relvers CDATA "4.0.1"> -<!ENTITY prevrelvers CDATA "4.0"> -<!ENTITY srcvers CDATA "401"> -<!ENTITY prevsrcvers CDATA "400"> +<!ENTITY relvers CDATA "4.0.2"> +<!ENTITY prevrelvers CDATA "4.0.1"> +<!ENTITY srcvers CDATA "402"> +<!ENTITY prevsrcvers CDATA "401"> <!-- Version of the most recent 3.3.x release --> <!ENTITY legacyvers CDATA "3.3.6"> <!-- SuperProbe version strings --> -<!ENTITY spvers CDATA "2.22"> +<!ENTITY spvers CDATA "2.23"> <!ENTITY legacyspvers CDATA "2.21"> + +<!-- doctools version strings --> +<!ENTITY doctoolsvers CDATA "1.2"> <!-- These should be set according to which snapshot/release this is --> <!ENTITY % firstsnap 'IGNORE'> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml:1.7 xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml:1.11 --- xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml:1.7 Mon Mar 6 17:59:25 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml Fri Dec 15 15:01:56 2000 @@ -1,306 +1,595 @@ -<!doctype LINUXDOC PUBLIC "-//XFree86//DTD linuxdoc//EN"[ +<!doctype LINUXDOC PUBLIC "-//XFree86//DTD linuxdoc//EN" [ <!ENTITY % defs SYSTEM "defs.ent"> %defs; ]> <article> <title>Fonts in XFree86 -<author>Juliusz Chroboczek, <tt/Juliusz.Chroboczek@ens.fr/ -<date>5 March 2000</date> +<author>Juliusz Chroboczek, <email/jch@xfree86.org/ +<date>14 December 2000</date> <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml,v 1.7 2000/03/06 22:59:25 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml,v 1.11 2000/12/15 20:01:56 dawes Exp $ </ident> <toc> -<p>XFree86 contains a number of improvements related to fonts, including -<itemize> -<item> inclusion of new fonts; -<item> internationalisation of the scalable font backends (Type 1, Speedo, - and TrueType); -<item> support for TrueType fonts; -<item> support for CID-keyed fonts. -</itemize> -This document describes these improvements. It does not attempt to -describe the standard support for fonts in X11; the reader is referred -to the <tt/X/(1), <tt/Xserver/(1), and <tt/mkfontdir/(1) manpages. - -<sect>Background and terminology - -<sect1>Characters and glyphs - -<p>A <it/character/ is an abstract unit of a writing system. Examples -of characters include the Latin capital letter <it/A/, the Arabic -letter <it/jim/, and the <it/dingbat black scissors/. - -A <it/glyph/ is a shape that may represent one or many characters when -displayed by a window system or printed by a printer. - -While glyphs roughly correspond to characters in most cases, this -correspondence is not, in general, one to one. For example, a font may -have many variant forms of the capital letter <it/A/; a single <it/fi/ -ligature may correspond to the letters <it/f/ and <it/i/. - -A <it/coded character set/ is a set of characters together with a -mapping from integer codes -- known as <it/codepoints/ -- to -characters. Examples of coded character sets include US-ASCII, -ISO 8859-1, KOI8-R, and JIS X 0208(1990). - -A coded character set need not use 8-bit integers to index -characters. Many early mainframes used 6-bit character sets, while -16-bit (or more) character sets are necessary for ideographic writing -systems. - -<sect1>Font files, fonts, and XLFD - -<p>Traditionally, typographers speak about <it/typefaces/ and -<it/founts/ (we use the traditional British spelling to distinguish -founts from digital fonts). A typeface is a particular style or -design, such as Times Italic, while a fount is a molten-lead -incarnation of a given typeface at a given size. - -Digital fonts come in <it/font files/. A font file contains all the -information necessary for generating glyphs of a given typeface, and -applications using font files may access glyph information in -arbitrary order. - -Digital fonts may consist of bitmap data, in which case they are said -to be <it/bitmap fonts/. They may also consist of a mathematical -description of glyph shapes, in which case they are said to be -<it/scalable fonts/. Common formats for scalable font files are -<it/Type 1/ (sometimes incorrectly called <it/ATM fonts/ or -<it/PostScript fonts/), <it/Speedo/ and <it/TrueType/. - -The glyph data in a digital font needs to be indexed somehow. How -this is done depends on the font file format. In the case of -Type 1 fonts, glyphs are identified by <it/glyph names/. In the -case of TrueType fonts, glyphs are indexed by integers corresponding -to one of a number of indexing schemes (usually Unicode --- see below). - -The X11 system uses the data in font file to generate <it/font -instances/, which are collections of glyphs at a given size indexed -according to a given encoding. X11 font instances are specified using -a notation known as the <it/X Logical Font Description/ (XLFD). An -XLFD starts with a dash `<tt/-/', and consists of fourteen fields -separated by dashes, for example -<tscreen> --adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 -</tscreen> -Or particular interest are the last two fields `<tt/iso8859-1/', which -specify the font instance's encoding. - -<sect1>Unicode +<sect>Introduction -<p>Unicode (<url url="http://www.unicode.org">) is a coded character -set with the goal of uniquely identifying all characters for all -scripts, current and historical. While Unicode was explicitly not -designed as a glyph encoding scheme, it is often possible to use it as -such. - -Unicode is an <it/open/ character set, in that codepoint assignments -may be added to Unicode at any time (once specified, though, an -assignment can never be changed). For this reason, a Unicode font -will be <it/sparse/, and only define glyphs for a subset of the -character registry of Unicode. - -The Unicode standard is defined in parallel with ISO 10646. -Assignments in the two standards are always equivalent, and this -document uses the terms ``Unicode'' and ``ISO 10646'' interchangeably. - -When used in X11, Unicode-encoded fonts should have the last two -fields of their XLFD set to `<tt/iso10646-1/'. +<!-- I hate SGML. What's wrong with texinfo? --> +<p>This document describes the support for fonts in XFree86. Section +<ref id="sec:installing" name="Installing fonts"> is aimed at the +casual user wishing to install fonts in the X server; the rest of the +document describes the font support in more detail. + +We only describe font support within the core X protocol. Issues +relating to fonts within the RENDER extension, the GLX (OpenGL) +extension or the PEX extension are outside the scope of this document. + +We assume some familiarity with digital fonts. If anything is not +clear to you, please consult Appendix <ref id="sec:background" +name="Background"> at the end of this document for background +information. -<sect>New fonts +<sect>Installing fonts <label id="sec:installing"> -<sect1>Bitmap fonts +<p>Installing fonts in XFree86 is a two step process. First, you need +to create a <it/font directory/ that contains all the relevant font +files as well as some index files. You then need to inform the X +server of the existence of this new directory by including it in the +<it/font path/. + +<sect1>Installing bitmap fonts + +<p>The XFree86 server can use bitmap fonts in both the cross-platform +BDF format and the somewhat more efficient binary PCF format. +(XFree86 also supports the obsolete SNF format.) + +Bitmap fonts are normally distributed in the BDF format. Before +installing such fonts, it is desirable (but not absolutely necessary) +to convert the font files to the PCF format. This is done by using the +command `<tt/bdftopcf/', <it/e.g./ +<tscreen><verb> +$ bdftopcf courier12.bdf +</verb></tscreen> +You may then want to compress the resulting PCF font files: +<tscreen><verb> +$ gzip courier12.pcf +</verb></tscreen> + +After the fonts have been converted, you should copy all the font +files that you wish to make available into a arbitrary directory, say +`<tt>/usr/local/share/fonts/bitmap/</tt>'. You should then create the +index file `<tt/fonts.dir/' by running the command `<tt/mkfontdir/' +(please see the <tt/mkfontdir/(1) manual page for more information): +<tscreen><verb> +$ mkdir /usr/local/share/fonts/bitmap +$ cp *.pcf.gz /usr/local/share/fonts/bitmap +$ cd /usr/local/share/fonts/bitmap +$ mkfontdir +</verb></tscreen> + +All that remains is to tell the X server about the existence of the +new font directory; see Section <ref id="sec:set-font-path" +name="Setting the server font path">. + +<sect1>Installing scalable fonts + +<p>The XFree86 server supports scalable fonts in four formats: +Type 1, Speedo, TrueType and CIDFont. This section only applies +to the former three; for information on CIDFonts, please see Section +<ref id="sec:cid-fonts" name="Installing CIDFonts"> later in this +document. + +Installing scalable fonts is very similar to installing bitmap fonts: +you create a directory with the font files, and run `<tt/mkfontdir/' +to create an index file called `<tt/fonts.dir/'. + +There is, however, a big difference: `<tt/mkfontdir/' cannot +automatically recognise scalable font files. For that reason, you +must first index all the font files in a file called +`<tt/fonts.scale/'. This file has the same format as a +`<tt/fonts.dir/' file, and typically looks as follows: +<tscreen><verb> +4 +cour.pfa -adobe-courier-medium-r-normal-0-0-0-0-p-0-iso8859-1 +cour.pfa -adobe-courier-medium-r-normal-0-0-0-0-p-0-iso8859-2 +couri.pfa -adobe-courier-medium-i-normal-0-0-0-0-p-0-iso8859-1 +couri.pfa -adobe-courier-medium-i-normal-0-0-0-0-p-0-iso8859-2 +</verb></tscreen> +The first line indicates the number of entries in the file. +Each line after the first consists of two fields separated by a space; +the first field is the name of the font file, and the second one is +the name under which the font will appear to the server. This name +should obey the X Logical Font Description conventions (see Section +<ref id="sec:xlfd" name="The X Logical Font Description">). The +format of this file is fully described in the <tt/mkfontdir/(1) manual +page. + +Note that multiple lines may point at the same font file. This is +most commonly done in order to make a single font available under +multiple encodings; please see Section +<ref id="sec:internationalisation" name="Fonts and internationalisation">. + +While it is possible to create the `<tt/fonts.scale/' file by hand, it +is simpler and more convenient to have it generated automatically. +Utilities to perform this task are available, but are not currently +included with XFree86. For Type 1 fonts, you may use a utility +called `<tt/type1inst/' which is available from +<url url="http://www.ibiblio.org/pub/Linux/X11/xutils/" name="standard +Free Software repositories"> throughout the world. + +For TrueType fonts, you may use `<tt/ttmkfdir/', available from +<url name="Joerg Pommnitz's xfsft page" + url="http://www.joerg-pommnitz.de/TrueType/xfsft.html">. + +After the `<tt/fonts.scale/' is created, you may run `<tt/mkfontdir/' as +above; this time, however, you need to create an index of encoding +files called `<tt>encodings.dir</tt>' in addition to the +`<tt>fonts.dir</tt>' file. This is done by using `<tt/mkfontdir/' with +the `<tt/-e/' flag: +<tscreen><verb> +$ cd /usr/local/share/fonts/Type1 +$ mkfontdir -e /usr/X11R6/lib/font/encodings +</verb></tscreen> +For more information, please see the <tt/mkfontdir/(1) manual page and +Section <ref id="sec:internationalisation" name="Fonts and +internationalisation"> later in this document. + +<sect1>Installing CID-keyed fonts <label id="sec:cid-fonts"> + +<p>The CID-keyed font format was designed by Adobe Systems for fonts +with large character sets. A CID-keyed font, or CIDFont for short, +contains a collection of glyphs indexed by <it/character ID/ (CID). + +Adobe make some sample CIDFonts and a complete set of CMaps +available from +<url name="O'Reilly's FTP site" + url="ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/">. + +In order to map such glyphs to meaningful indices, Adobe provide a set +of <it/CMap/ files. The PostScript name of a font generated from a +CIDFont consists of the name of the CIDFont and the name of the CMap +separated by two dashes. For example, the font generated from the +CIDFont `<tt/Munhwa-Regular/' using the CMap `<tt/UniKS-UCS2-H/' is +called +<tscreen><verb> +Munhwa-Regular--UniKS-UCS2-H +</verb></tscreen> + +The CIDFont support in XFree86 requires a very rigid directory +structure. The main directory must be called `<tt/CID/' (its location +defaults to `<tt>/usr/X11R6/lib/X11/fonts/CID</tt>' but it may be +located anywhere), and it should contain a subdirectory for every CID +collection. Every subdirectory <it/must/ contain subdirectories +called <tt/CIDFont/ (containing the actual CIDFont files), <tt/CMap/ +(containing all the needed CMaps), <tt/AFM/ (containing the font +metric files) and <tt/CFM/ (initially empty). For example, in the +case of the font <tt/Munhwa-Regular/ that uses the CID collection +<tt/Adobe-Korea1-0/, the directory structure should be as follows: +<tscreen><verb> +CID/Adobe-Korea1/CIDFont/Munhwa-Regular +CID/Adobe-Korea1/CMap/UniKS-UCS2-H +CID/Adobe-Korea1/AFM/Munhwa-Regular.afm +CID/Adobe-Korea1/CFM/ +CID/fonts.dir +CID/fonts.scale +</verb></tscreen> + +After creating this directory structure and copying the relevant +files, you should create a <`tt/fonts.scale/' file. This file has the +same format as in the case of (non-CID) scalable fonts, except that +its first column contains PostScript font names with the extension +`<tt/.cid/' appended rather than actual filenames: +<tscreen><verb> +1 +Adobe-Korea1/Munhwa-Regular--UniKS-UCS2-H.cid \ + -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-iso10646-1 +</verb></tscreen> +(both names on the same line). As above, running `<tt/mkfontdir/' +creates the `<tt/fonts.dir/' file: +<tscreen><verb> +$ cd /usr/local/share/fonts/CID +$ mkfontdir +</verb></tscreen> + +Finally, you should create the font metrics summary files in the +directory `<tt/CFM/' by running the command `<tt/mkcfm/': +<tscreen><verb> +$ mkcfm /usr/local/share/fonts/CID +</verb></tscreen> +If no CFM files are available, the server will still be able to use +the CID fonts but querying them will take a long time. You should run +`<tt/mkcfm/' again whenever a change is made to any of the CID-keyed +fonts, or when the CID-keyed fonts are copied to a machine with a +different architecture. + +<sect1>Setting the server's font path <label id="sec:set-font-path"> + +<p>The list of directories where the server looks for fonts is known +as the <it/font path/. Informing the server of the existence of a new +font directory consists in putting it on the font path. + +The font path is an ordered list; if a client's request matches +multiple fonts, the first one in the font path is the one that gets +used. When matching fonts, the server makes two passes over the font +path: during the first pass, it searches for an exact match; during +the second, it searches for fonts suitable for scaling. + +For best results, scalable fonts should appear in the font path before +the bitmap fonts; this way, the server will prefer bitmap fonts to +scalable fonts when an exact match is possible, but will avoid scaling +bitmap fonts when a scalable font can be used. (The `<tt/:unscaled/' +hack, while still supported, should no longer be necessary in XFree86 +4.0 and later.) + +You may check the font path of the running server by typing the command +<tscreen><verb> +$ xset q +</verb></tscreen> + +<sect2>Temporary modification of the font path + +<p>The `<tt/xset/' utility may be used to modify the font path for the +current session. The font path is set with the command <tt/xset fp/; +a new element is added to the front with <tt/xset +fp/, and added to +the end with <tt/xset fp+/. For example, +<tscreen><verb> +$ xset +fp /usr/local/fonts/Type1 +$ xset fp+ /usr/local/fonts/bitmap +</verb></tscreen> + +Conversely, an element may be removed from the front of the font path +with `<tt/xset -fp/', and removed from the end with `<tt/xset fp-/'. + +For more information, please consult the <tt/xset/(1) manual page. + +<sect2>Permanent modification of the font path + +<p>The default font path (the one used just after server startup) is +specified in the X server's `<tt/XF86Config/' file. It is computed by +appending all the directories mentioned in the `<tt/FontPath/' entries +of the `<tt/Files/' section in the order in which they appear. +<tscreen><verb> +FontPath "/usr/local/fonts/Type1" +... +FontPath "/usr/local/fonts/bitmap" +</verb></tscreen> + +For more information, please consult the `<tt/XF86Config/'(5) manual +page. + +<sect1>Troubleshooting <label id="sec:troubleshooting"> + +<p>If you seem to be unable to use some of the fonts you have +installed, the first thing to check is that the `<tt/fonts.dir/' files +are correct and that they are readable by the server. If this doesn't +help, it is quite possible that you are trying to use a font in a +format that is not supported by your server. + +XFree86 supports the BDF, PCF, SNF, Type 1, Speedo, TrueType and +CIDFont font formats. However, not all XFree86 servers come with all +the font backends configured in. + +On most platforms, the XFree86 servers are <it/modular/: the font +backends are included in modules that are loaded at runtime. The +modules to be loaded are specified in the `<tt/XF86Config/' file using +the `<tt/Load/' directive: +<tscreen><verb> +Load "Type1" +</verb></tscreen> +If you have trouble installing fonts in a specific format, you may +want to check the server's log file in order to see whether the +relevant modules are properly loaded. The list of font modules +distributed with XFree86 is as follows: +<itemize> +<item> <tt/"bitmap"/: bitmap fonts (`<tt/*.bdf/', `<tt/*.pcf/' +and `<tt/*.snf/'); +<item> <tt/"Type1"/: Type 1 fonts (`<tt/*.pfa/' and +`<tt/*.pfb/') and CIDFonts; +<item> <tt/"Speedo"/: Bitstream Speedo fonts (`<tt/*.spd/'); +<item> <tt/"freetype"/: TrueType fonts (`<tt/*.ttf/' and `<tt/*.ttc/'); +<item> <tt/"xtt"/: alternate TrueType backend (`<tt/*.ttf/' and +`<tt/*.ttc/'). +</itemize> -<p>XFree86 includes two new Unicode-encoded fonts with a large -collection of non-ideographic glyphs. While it is possible to use -these fonts as main fonts, applications may also use them as fallbacks -when a given glyph is not available in the current font. +<sect>Fonts included with XFree86 -<sect2>The Unicode `fixed' font +<sect1>Standard bitmap fonts -<p>The font file -<tscreen> -/usr/X11/lib/X11/fonts/misc/6x13.pcf.gz -</tscreen> +<p>The Sample Implementation of X11 comes with a large number of +bitmap fonts, including the `<tt/fixed/' family, and bitmap versions +of Courier, Times and Helvetica. In the SI, these fonts are provided +in the ISO 8859-1 encoding (ISO Latin Western-European). + +In XFree86, a number of these fonts are provided in Unicode-encoded +font files instead. At build time, these fonts are split into font +files encoded according to legacy encodings, a process which enables +us to provide the standard fonts in a number of regional encodings +with no duplication of work. + +For example, the font file +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/misc/6x13.bdf +</verb></tscreen> with XLFD -<tscreen> +<tscreen><verb> -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 -</tscreen> +</verb></tscreen> is a Unicode-encoded version of the standard `<tt/fixed/' font with added support for the Latin, Greek, Cyrillic, Georgian, Armenian, IPA and other scripts plus numerous technical symbols. It contains over -2800 characters, covering all characters of ISO 8859 parts 1-5, +2800 glyphs, covering all characters of ISO 8859 parts 1-5, 7-10, 13-15, as well as all European IBM and Microsoft code pages, -KOI8, WGL4, and the repertoires of many other character sets. This -font is compatible with the standard 8-bit <tt/fixed/ font and -therefore also includes the DEC line-drawing glyphs in the range 0x00 -to 0x1F, which are not part of Unicode or ISO 10646-1. - -An ISO 8859-1 version of this font is still available in file -<tscreen> -/usr/X11/lib/X11/fonts/misc/6x13-ISO8859-1.pcf.gz -</tscreen> -with XLFD -<tscreen> --misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 -</tscreen> -The standard aliases `<tt/fixed/' and `<tt/6x13/' still point at the -ISO 8859-1 versions of the font. - -<sect2>The ClearlyU Unicode font +KOI8, WGL4, and the repertoires of many other character sets. -<p>The ClearlyU font set of fonts provides a set of 12pt, 100dpi -proportional fonts with many of the glyphs needed for Unicode text. -Together, the fonts contain over 4000 glyphs. - -The main ClearlyU font has XLFD name -<tscreen> --mutt-ClearlyU-medium-r-normal--17-120-100-100-p-101-iso10646-1 -</tscreen> +This font is used at build time for generating the font files +<tscreen><verb> +6x13-ISO8859-1.bdf +6x13-ISO8859-2.bdf +6x13-ISO8859-3.bdf +6x13-ISO8859-4.bdf +6x13-ISO8859-5.bdf +6x13-ISO8859-7.bdf +6x13-ISO8859-8.bdf +6x13-ISO8859-9.bdf +6x13-ISO8859-10.bdf +6x13-ISO8859-13.bdf +6x13-ISO8859-15.bdf +6x13-KOI8-R.bdf +</verb></tscreen> +with respective XLFDs +<tscreen><verb> +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-2 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-3 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-4 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-5 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-7 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-8 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-9 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-10 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-13 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-15 +-misc-fixed-medium-r-normal--13-120-75-75-c-60-koi8-r +</verb></tscreen> +The standard short name `<tt/fixed/' is normally an alias for +<tscreen><verb> +-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1 +</verb></tscreen> + +(The conversion of the standard fonts to Unicode was mainly performed +by Markus Kuhn. Markus is a man of taste, which makes his use of Perl +in the conversion process somewhat surprising.) + +<sect1>The ClearlyU Unicode font family + +<p>The ClearlyU family of fonts provides a set of 12 pt, +100 dpi proportional fonts with many of the glyphs needed for +Unicode text. Together, the fonts contain approximately 7500 glyphs. + +The main ClearlyU font has the XLFD +<tscreen><verb> +-mutt-clearlyu-medium-r-normal--17-120-100-100-p-101-iso10646-1 +</verb></tscreen> and resides in the font file -<tscreen> -/usr/X11/lib/X11/fonts/misc/cu12.pcf.gz -</tscreen> +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/misc/cu12.pcf.gz +</verb></tscreen> Additional ClearlyU fonts include -<tscreen> --mutt-ClearlyU Alternate Glyphs-medium-r-normal--17-120-100-100-p-91-iso10646-1 -<p>-mutt-ClearlyU Arabic Extra-medium-r-normal--17-120-100-100-p-103-fontspecific-0 -<p>-mutt-ClearlyU Ligature-medium-r-normal--17-120-100-100-p-141-fontspecific-0 -<p>-mutt-ClearlyU PUA-medium-r-normal--17-120-100-100-p-111-iso10646-1 -</tscreen> - -<sect1>Scalable fonts - -<p>XFree86 includes the ``Lucidux'' family of Type 1 fonts. This -family consists of the fonts ``Lucidux Serif'', with XLFD -<tscreen> +<tscreen><verb> +-mutt-clearlyu alternate glyphs-medium-r-normal--17-120-100-100-p-91-iso10646-1 +-mutt-clearlyu pua-medium-r-normal--17-120-100-100-p-111-iso10646-1 +-mutt-clearlyu arabic extra-medium-r-normal--17-120-100-100-p-103-fontspecific-0 +-mutt-clearlyu ligature-medium-r-normal--17-120-100-100-p-141-fontspecific-0 +</verb></tscreen> + +The <it/Alternate Glyphs/ font contains additional glyph shapes that +are needed for certain languages. A second alternate glyph font will +be provided later for cases where a character has more than one +commonly used alternate shape (<it/e.g./ the Urdu heh). + +The <it/PUA/ font contains extra glyphs that are useful for certain +rendering purposes. + +The <it/Arabic Extra/ font contains the glyphs necessary for +characters that don't have all of their possible shapes encoded in +ISO 10646. The glyphs are roughly ordered according to the order +of the characters in the ISO 10646 standard. + +The <it/Ligature/ font contains ligatures for various scripts that +may be useful for improved presentation of text. + +(The ClearlyU family was designed by Mark Leisher. Mark's usage of +the foundry name <it/mutt/ predates the mailer of the same name, but +he won't say more.) + +<sect1>Standard scalable fonts + +<p>XFree86 includes all the scalable fonts distributed with X11R6. + +<sect2>Standard Type 1 fonts + +<p>The IBM Courier set of fonts cover ISO 8859-1 and +ISO 8859-2 as well as Adobe Standard Encoding. These fonts have +XLFD +<tscreen><verb> +-adobe-courier-medium-*-*--0-0-0-0-m-0-*-* +</verb></tscreen> +and reside in the font files +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/Type1/cour*.pfa +</verb></tscreen> + +The Adobe Utopia set of fonts only cover ISO 8859-1 as well as +Adobe Standard Encoding. These fonts have XLFD +<tscreen><verb> +-adobe-utopia-*-*-normal--0-0-0-0-p-0-iso8859-1 +</verb></tscreen> +and reside in the font files +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/Type1/UT*.pfa +</verb></tscreen> + +Finally, XFree86 also comes with Type 1 versions of Bitstream +Courier and Charter. These fonts have XLFD +<tscreen><verb> +-bitstream-courier-*-*-normal--0-0-0-0-m-0-iso8859-1 +-bitstream-charter-*-*-normal--0-0-0-0-p-0-iso8859-1 +</verb></tscreen> +and reside in the font files +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/Type1/c*bt_.pfb +</verb></tscreen> + +<sect2>Standard Speedo fonts + +<p>XFree86 includes Speedo versions of the Bitstream Courier and +Charter fonts. In order to use these fonts, you should ensure that +your X server is loading the `<tt/Speedo/' font backend; see Section +<ref id="sec:troubleshooting" name="Troubleshooting">. + +These fonts cover all of ISO 8859-1 and almost all of +ISO 8859-2. They have XLFD name +<tscreen><verb> +-bitstream-courier-*-*-normal--0-0-0-0-m-0-*-* +-bitstream-charter-*-*-normal--0-0-0-0-p-0-*-* +</verb></tscreen> +and reside in the font files +<tscreen><verb> +/usr/X11R6/lib/X11/fonts/Speedo/font*.spd +</verb></tscreen> + +<sect1>The Bigelow & Holmes Lucidux family + +<p>XFree86 includes the <it/Lucidux/ family of Type 1 fonts. This +family consists of the fonts <it/Lucidux Serif/, with XLFD +<tscreen><verb> -b&h-lucidux serif-medium-*-normal--*-*-*-*-p-*-*-* -</tscreen> -``Lucidux Sans'', with XLFD -<tscreen> +</verb></tscreen> +<it/Lucidux Sans/, with XLFD +<tscreen><verb> -b&h-lucidux sans-medium-*-normal--*-*-*-*-p-*-*-* -</tscreen> -and ``Lucidux Mono'', with XLFD -<tscreen> +</verb></tscreen> +and <it/Lucidux Mono/, with XLFD +<tscreen><verb> -b&h-lucidux mono-medium-*-normal--*-*-*-*-m-*-*-* -</tscreen> +</verb></tscreen> Each of these fonts currently comes in Roman and oblique variants (bold variants will be included in a future release) and has 337 -glyphs covering the basic ``ASCII'' glyph set, the Latin 1 glyph -set, as well as the ``Extended Latin'' glyph set. In particular, +glyphs covering the basic ASCII Unicode range, the Latin 1 +range, as well as the <it/Extended Latin/ range. In particular, these fonts include all the glyphs needed for ISO 8859 parts 1, 2, 3, 4, 9 and 15. The Lucidux fonts are original designs by Charles Bigelow and Kris -Holmes. Lucidux fonts include seriffed, sans-serif, and monospaced -styles which share the same stem weight, x-height, capital height, +Holmes. Lucidux fonts include seriffed, sans serif, and monospaced +styles that share the same stem weight, x-height, capital height, ascent and descent. Lucidux fonts harmonise with Lucida (R) fonts of the same vertical proportions and weights. The character width metrics of Lucidux roman fonts match those of core fonts bundled with several window systems. Each PFA file has a copy of the license terms in PS comment lines. -The license terms are also included in the file <tt/COPYRIGHT.BH/ for -convenience, and in the <htmlurl name="License document" url="LICENSE.html">. +The license terms are also included in the file `<tt/COPYRIGHT.BH/' +for convenience, as well as in the <htmlurl name="License document" +url="LICENSE.html">. The design and font outlines were donated by Charles Bigelow and Kris Holmes from Bigelow and Holmes Inc., and the hinting was donated by Berthold Horn and Blenda Horn from Y&Y, Inc. For more information, -please contact <email/design@bigelowandholmes.com/ or -<email/sales@yandy.com/, or consult <url name="Y&Y's web site" -url="http://www.yandy.com">. - - -<sect>Internationalisation of scalable font backends. - -<p>The scalable font backends (Type 1, Speedo, TrueType) can now -automatically re-encode fonts to the encoding specified in the XLFD in -`<tt/fonts.dir/'. For example, a `<tt/fonts.dir/' file can now +please contact <email>design@bigelowandholmes.com</email> or +<email>sales@yandy.com</email>, or consult +<url name="Y&Y's web site" url="http://www.yandy.com">. + +<sect>Fonts and internationalisation <label id="sec:internationalisation"> + +<p>The scalable font backends (Type 1, Speedo and TrueType) can +now automatically re-encode fonts to the encoding specified in the +XLFD in <tt/fonts.dir/. For example, a <tt/fonts.dir/ file can contain entries for the Type 1 Courier font such as -<tscreen> -cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 -<p>cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-2 -</tscreen> -which will lead to the font being recoded to ISO 8859-1 and +<tscreen><verb> +cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 +cour.pfa -adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-2 +</verb></tscreen> +which will lead to the font being recoded to ISO 8859-1 and ISO 8859-2 respectively. -<sect1>The `fontenc' layer<label id="sec-fontenc"> +<sect1>The <it/fontenc/ layer <label id="sec:fontenc"> <p>Three of the scalable backends (Type 1, Speedo, and the -`freetype' TrueType backend) use a common `fontenc' layer for font -re-encoding. This allows those backends to share their encoding data, -and allows simple configuration of new locales independently of font -type. +<it/FreeType/ TrueType backend) use a common <it/fontenc/ layer for +font re-encoding. This allows these backends to share their encoding +data, and allows simple configuration of new locales independently of +font type. <it/Please note:/ the X-TrueType (X-TT) backend does not use the -`fontenc' layer, but instead uses its own method for font reencoding. -Readers only interested in X-TT may want to skip to <ref -id="sec-symbol-fonts" name="Using Symbol Fonts">, as the intervening -information does not apply to X-TT. X-TT itself is described in more -detail in <ref id="sec-X-TT" name="X-TrueType">. - -In the `fontenc' layer, an encoding is defined by a name (such as -`<tt/iso8859-1/'), eventually a number of aliases (alternate names), -and an ordered collection of mappings. A mapping defines the way the -encoding can be mapped into one of the ``target'' encodings known to -the `fontenc' layer; currently, those consist of Unicode, Adobe glyph -names, and arbitrary TrueType `cmap's. - -A number of encodings are hardwired into `fontenc', and are therefore -always available; the hardcoded encodings cannot easily be redefined. -These include: +<it/fontenc/ layer, but instead uses its own method for font +reencoding. If you are only interested in X-TT you may want to skip +to Section <ref id="sec:symbol-fonts" name="Using Symbol Fonts">, as +the intervening information does not apply to X-TT. X-TT itself is +described in more detail in Section <ref id="sec:X-TT" +name="X-TrueType">. + +In the <it/fontenc/ layer, an encoding is defined by a name (such as +<tt/iso8859-1/), possibly a number of aliases (alternate names), and +an ordered collection of mappings. A mapping defines the way the +encoding can be mapped into one of the <it/target encodings/ known to +<it/fontenc/; currently, these consist of Unicode, Adobe glyph names, +and arbitrary TrueType ``cmap''s. + +A number of encodings are hardwired into <it/fontenc/, and are +therefore always available; the hardcoded encodings cannot easily be +redefined. These include: <itemize> -<item> `<tt/iso10646-1/': Unicode; -<item> `<tt/iso8859-1/': ISO Latin-1 (Western Europe); -<item> `<tt/iso8859-2/': ISO Latin-2 (Eastern Europe); -<item> `<tt/iso8859-3/': ISO Latin-3 (Southern Europe); -<item> `<tt/iso8859-4/': ISO Latin-4 (Northern Europe); -<item> `<tt/iso8859-5/': ISO Cyrillic; -<item> `<tt/iso8859-6/': ISO Arabic; -<item> `<tt/iso8859-7/': ISO Greek; -<item> `<tt/iso8859-8/': ISO Hebrew; -<item> `<tt/iso8859-9/': ISO Latin-5 (Turkish); -<item> `<tt/iso8859-10/': ISO Latin-6 (Nordic); -<item> `<tt/iso8859-15/': ISO Latin-9, or Latin-0 (Revised +<item> <tt/iso10646-1/: Unicode; +<item> <tt/iso8859-1/: ISO Latin-1 (Western Europe); +<item> <tt/iso8859-2/: ISO Latin-2 (Eastern Europe); +<item> <tt/iso8859-3/: ISO Latin-3 (Southern Europe); +<item> <tt/iso8859-4/: ISO Latin-4 (Northern Europe); +<item> <tt/iso8859-5/: ISO Cyrillic; +<item> <tt/iso8859-6/: ISO Arabic; +<item> <tt/iso8859-7/: ISO Greek; +<item> <tt/iso8859-8/: ISO Hebrew; +<item> <tt/iso8859-9/: ISO Latin-5 (Turkish); +<item> <tt/iso8859-10/: ISO Latin-6 (Nordic); +<item> <tt/iso8859-15/: ISO Latin-9, or Latin-0 (Revised Western-European); -<item> `<tt/koi8-r/': KOI8 Russian; -<item> `<tt/koi8-u/': KOI8 Ukrainian (see RFC 2319); -<item> `<tt/koi8-ru/': KOI8 Russian/Ukrainian -<item> `<tt/koi8-uni/': KOI8 ``Unified'' (Russian, Ukrainian, and +<item> <tt/koi8-r/: KOI8 Russian; +<item> <tt/koi8-u/: KOI8 Ukrainian (see RFC 2319); +<item> <tt/koi8-ru/: KOI8 Russian/Ukrainian +<item> <tt/koi8-uni/: KOI8 ``Unified'' (Russian, Ukrainian, and Byelorussian); -<item> `<tt/koi8-e/': KOI8 `European', ISO-IR-111, or ECMA-Cyrillic; -<item> `<tt/microsoft-symbol/' and `<tt/apple-roman/': these are only +<item> <tt/koi8-e/: KOI8 ``European,'' ISO-IR-111, or ECMA-Cyrillic; +<item> <tt/microsoft-symbol/ and <tt/apple-roman/: these are only likely to be useful with TrueType symbol fonts. </itemize> -New encodings can be added by defining <it/encoding files/. When a -font encoding is requested that the `fontenc' layer doesn't know -about, the backend checks the directory in which the font file resides -(not the directory with `<tt/fonts.dir/'!) for a file named -`<tt/encodings.dir/'. If found, this file is scanned for the unknown -encoding, and the requested encoding definition file is read in. The -mkfontdir(1) utility, when invoked with the `<tt/-e/' option followed -by the name of a directory containing encoding files, can be used to -automatically build `<tt/encodings.dir/' files. See the <tt/mkfontdir/(1) -manpage for more details. - -A number of predefined encoding files have been included with the -distribution. Information on writing new encoding files can be found -in <ref id="sec-format-encoding-directory-files" name="Format of -encodings directory files"> and <ref id="sec-format-encoding-files" -name="Format of encodings files">. +Additional encodings can be added by defining <it/encoding files/. +When a font encoding is requested that the <it/fontenc/ layer doesn't +know about, the backend checks the directory in which the font file +resides (not necessarily the directory with <tt/fonts.dir/!) for a +file named `<tt/encodings.dir/'. If found, this file is scanned for +the requested encoding, and the relevant encoding definition file is +read in. The `<tt/mkfontdir/' utility, when invoked with the +`<tt/-e/' option followed by the name of a directory containing +encoding files, can be used to automatically build +`<tt/encodings.dir/' files. See the <tt/mkfontdir/(1) manual page for +more details. + +A number of encoding files for common encodings are included with +XFree86. Information on writing new encoding files can be found in +Section <ref id="sec:format-encoding-directory-files" name="Format of +encodings directory files"> and <ref id="sec:format-encoding-files" +name="Format of encoding files"> later in this document. <sect1>Backend-specific notes about fontenc <sect2>Type 1 <p>The Type 1 backend first searches for a mapping with a target -of PostScript. If one is found, it is used. If none is found, the +of PostScript. If one is found, it is used. Otherwise, the backend searches for a mapping with target Unicode, which is then composed with a built-in table mapping codes to glyph names. Note that this table only covers part of the Unicode code points that have @@ -309,9 +598,11 @@ If neither a PostScript or Unicode mapping is found, the backend defaults to ISO 8859-1. -Specifying an encoding value of `<tt/adobe-fontspecific/' disables -the encoding mechanism. This is useful with symbol and wrongly -encoded fonts (see below). +Specifying an encoding value of <tt/adobe-fontspecific/ disables +the encoding mechanism. This is useful with symbol and incorrectly +encoded fonts (see Section +<ref id="sec:incorrect-encoding" name="Incorrectly encoded fonts"> +below). The Type 1 backend currently limits all encodings to 8-bit codes. @@ -322,51 +613,49 @@ ISO 8859-1. The Speedo backend limits all encodings to 8-bit codes. - -<sect2>The `freetype' TrueType backend -<p>The TrueType backend scans the mappings in order. Mappings with -a target of PostScript are ignored; mappings with a TrueType or -Unicode target are checked against all the cmaps in the file. The -first applicable mapping is used. +<sect2>The <it/FreeType/ TrueType backend <label id="sec:fontenc-freetype" -Authors of encoding files to be used with the TrueType backend should -ensure that mappings are mentioned in decreasing order of preference. +<p>The TrueType backend scans the mappings in order. Mappings with a +target of PostScript are ignored; mappings with a TrueType or Unicode +target are checked against all the cmaps in the file. The first +applicable mapping is used. + +If you are writing an encoding file to be used with the TrueType +backend, you should ensure that mappings are mentioned in decreasing +order of preference. +<sect1>Format of encoding directory files <label id="sec:format-encoding-directory-files"> -<sect1>Format of encodings directory files<label - id="sec-format-encoding-directory-files"> - <p>In order to use a font in an encoding that the font backend does -not know about, you need to have a `<tt/encodings.dir/' file in the -same directory as the font file used. `<tt/encodings.dir/' has the -same format as `<tt/fonts.dir/'. Its first line specifies the number -of encodings, while every successive line has two columns, the name of -the encoding, and the name of the encoding file; this can be relative -to the current directory, or absolute. Every encoding name should -agree with the encoding name defined in the encoding file. For -example, +not know about, you need to have an `<tt/encodings.dir/' file in the +same directory as the font file used. The `<tt/encodings.dir/' file +has a similar format to `<tt/fonts.dir/'. Its first line specifies +the number of encodings, while every successive line has two columns, +the name of the encoding, and the name of the encoding file; this can +be relative to the current directory, or absolute. Every encoding +name should agree with the encoding name defined in the encoding file. +For example, -<tscreen> +<tscreen><verb> 3 -<p>mulearabic-0 encodings/mulearabic-0.enc -<p>mulearabic-1 encodings/mulearabic-1.enc -<p>mulearabic-2 encodings/mulearabic-2.enc -</tscreen> +mulearabic-0 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-0.enc +mulearabic-1 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-1.enc +mulearabic-2 /usr/X11R6/lib/X11/fonts/encodings/mulearabic-2.enc +</verb></tscreen> + +The name of an encoding <it/must/ be specified in the encoding file's +`<tt/STARTENCODING/' or `<tt/ALIAS/' line. It is not enough to create +an `<tt/encodings.dir/' entry. -Note that the name of an encoding must be specified in the encoding -file's STARTENCODING or ALIAS line. It is not enough to create an -`<tt/encodings.dir/' entry. - If your platform supports it (it probably does), encoding files may be compressed or gzipped. - -`<tt/encoding.dir/' files are best maintained by the <tt/mkfontdir/(1) -utility. Please see the <tt/mkfontdir/(1) manpage for more -information. +The `<tt/encoding.dir/' files are best maintained by the +`<tt/mkfontdir/' utility. Please see the <tt/mkfontdir/(1) manual +page for more information. -<sect1>Format of encoding files<label id="sec-format-encoding-files"> +<sect1>Format of encoding files <label id="sec:format-encoding-files"> <p>The encoding files are ``free form,'' <it/i.e./ any string of whitespace is equivalent to a single space. Keywords are parsed in a @@ -382,192 +671,192 @@ `<tt/#/' are ignored, up to the end of the line. The encoding file starts with the definition of the name of the -encoding, and eventually its alternate names (aliases): -<tscreen> +encoding, and possibly its alternate names (aliases): +<tscreen><verb> STARTENCODING mulearabic-0 -<p>ALIAS arabic-0 -<p>ALIAS something-else -</tscreen> -The names of the encoding should be suitable for use in an XLFD font -name, and therefore contain exactly one dash `<tt/-/'. +ALIAS arabic-0 +ALIAS something-else +</verb></tscreen> +The name of the encoding and its aliases should be suitable for use in +an XLFD font name, and therefore contain exactly one dash `<tt/-/'. The encoding file may then optionally declare the size of the -encoding. For a linear encoding (such as Mule Arabic, or -ISO 8859-1), the SIZE line specifies the maximum code plus one: -<tscreen> +encoding. For a linear encoding (such as ISO 8859-1), the SIZE +line specifies the maximum code plus one: +<tscreen><verb> SIZE 0x2B -</tscreen> +</verb></tscreen> For a matrix encoding, it should specify two numbers. The first is the number of the last row plus one, the other, the highest column -number plus one. For example, in the case of `<tt/jisx0208.1990-0/' +number plus one. In the case of `<tt/jisx0208.1990-0/' (JIS X 0208(1990), double-byte encoding, high bit clear), it should be -<tscreen> +<tscreen><verb> SIZE 0x75 0x80 -</tscreen> -Codes outside the region defined by the size line are supposed to be -undefined. Encodings default to linear encoding with a size of 256 -(0x100). This means that you must declare the size of all 16 bit -encodings. +</verb></tscreen> +In the case of a matrix encoding, a `<tt/FIRSTINDEX/' line may be +included to specify the minimum glyph index in an encoding. The +keyword `<tt/FIRSTINDEX/' is followed by two integers, the minimum row +number followed by the minimum column number: +<tscreen><verb> +FIRSTINDEX 0x20 0x20 +</verb></tscreen> +In the case of a linear encoding, a `<tt/FIRSTINDEX/' line is not very +useful. If for some reason however you chose to include on, it should +be followed by a single integer. + +Note that in most font backends inclusion of a `<tt/FIRSTINDEX/' line +has the side effect of disabling default glyph generation, and this +keyword should therefore be avoided unless absolutely necessary. + +Codes outside the region defined by the `<tt/SIZE/' and +`<tt/FIRSTINDEX/' lines are understood to be undefined. Encodings +default to linear encoding with a size of 256 (0x100). This means +that you must declare the size of all 16 bit encodings. What follows is one or more mapping sections. A mapping section starts with a `<tt/STARTMAPPING/' line stating the target of the mapping. The target may be one of: <itemize> <item>Unicode (ISO 10646): -<tscreen> +<tscreen><verb> STARTMAPPING unicode -</tscreen> -<item>a given TrueType `<tt/cmap/': -<tscreen> +</verb></tscreen> +<item>a given TrueType ``cmap'': +<tscreen><verb> STARTMAPPING cmap 3 1 -</tscreen> -<item>PostScript glyph names -<tscreen> +</verb></tscreen> +<item>PostScript glyph names: +<tscreen><verb> STARTMAPPING postscript -</tscreen> +</verb></tscreen> </itemize> Every line in a mapping section maps one from the encoding being defined to the target of the mapping. In mappings with a Unicode or TrueType mapping, codes are mapped to codes: -<tscreen> +<tscreen><verb> 0x21 0x0660 -<p>0x22 0x0661 -<p>... -</tscreen> +0x22 0x0661 +... +</verb></tscreen> As an abbreviation, it is possible to map a contiguous range of codes in a single line. A line consisting of three integers -<tscreen> +<tscreen><verb> <it/start/ <it/end/ <it/target/ -</tscreen> +</verb></tscreen> is an abbreviation for the range of lines <tscreen> <it/start/ <it/target/ -<p><it/start/+1 <it/target/+1 -<p>... -<p><it/end/ <it/target/+<it/end/-<it/start/ +</tscreen><tscreen> +<it/start/+1 <it/target/+1 +</tscreen><tscreen> +... +</tscreen><tscreen> +<it/end/ <it/target/+<it/end/-<it/start/ </tscreen> For example, the line -<tscreen> +<tscreen><verb> 0x2121 0x215F 0x8140 -</tscreen> +</verb></tscreen> is an abbreviation for -<tscreen> +<tscreen><verb> 0x2121 0x8140 -<p>0x2122 0x8141 -<p>... -<p>0x215F 0x817E -</tscreen> +0x2122 0x8141 +... +0x215F 0x817E +</verb></tscreen> Codes not listed are assumed to map through the identity (<it/i.e./ to the same numerical value). In order to override this default mapping, you may specify a range of codes to be undefined by using an `<tt/UNDEFINE/' line: -<tscreen> +<tscreen><verb> UNDEFINE 0x00 0x2A -</tscreen> -or, for a single code -<tscreen> +</verb></tscreen> +or, for a single code, +<tscreen><verb> UNDEFINE 0x1234 -</tscreen> -This works because later values override earlier one. +</verb></tscreen> PostScript mappings are different. Every line in a PostScript mapping maps a code to a glyph name -<tscreen> +<tscreen><verb> 0x41 A -<p>0x42 B -<p>... -</tscreen> +0x42 B +... +</verb></tscreen> and codes not explicitly listed are undefined. A mapping section ends with an <tt/ENDMAPPING/ line -<tscreen> +<tscreen><verb> ENDMAPPING -</tscreen> +</verb></tscreen> After all the mappings have been defined, the file ends with an <tt/ENDENCODING/ line -<tscreen> +<tscreen><verb> ENDENCODING -</tscreen> -Lines of the form -<tscreen> -UNASSIGNED 0x00 0x1F -</tscreen> -or -<tscreen> -UNASSIGNED 0x1234 -</tscreen> -are ignored by the server, but may be used by supporting utilities. +</verb></tscreen> In order to make future extensions to the format possible, lines -starting with an unknown keyword are ignored, as are mapping sections -with an unknown target. - +starting with an unknown keyword are silently ignored, as are mapping +sections with an unknown target. -<sect1>Using symbol fonts<label id="sec-symbol-fonts"> +<sect1>Using symbol fonts <label id="sec:symbol-fonts"> <p>Type 1 symbol fonts should be installed using the -`<tt/adobe-fontspecific/' encoding. +<tt/adobe-fontspecific/ encoding. In an ideal world, all TrueType symbol fonts would be installed using -one of the `<tt/microsoft-symbol/' and `<tt/apple-roman/' encodings. A +one of the <tt/microsoft-symbol/ and <tt/apple-roman/ encodings. A number of symbol fonts, however, are not marked as such; such fonts -should be installed using `<tt/microsoft-cp1252/', or, for older -fonts, `<tt/microsoft-win3.1/'. +should be installed using <tt/microsoft-cp1252/, or, for older fonts, +<tt/microsoft-win3.1/. In order to guarantee consistent results (especially between Type 1 and TrueType versions of the same font), it is possible to define a special encoding for a given font. This has already been done -for the `<tt/ZapfDingbats/' font; see the file -`<tt>encodings/adobe-dingbats.enc</tt>'. +for the <tt/ZapfDingbats/ font; see the file +<tt>encodings/adobe-dingbats.enc</tt>. +<sect1>Hints about using badly encoded fonts <label id="sec:incorrect-encoding"> -<sect1>Using badly encoded font files<label id="sec-badly-encoded"> +<p>A number of text fonts are incorrectly encoded. Incorrect encoding +is sometimes done by design, in order to make a font for an exotic +script appear like an ordinary Western text font. It is often the +result of the font designer's laziness or incompetence; for some +reason, most people seem to find it easier to invent idiosyncratic +glyph names rather than follow the Adobe glyph list. -<p>A number of text fonts are incorrectly encoded. Incorrect encoding is -sometimes done by design, in order to make a font for an exotic script -appear like an ordinary Western text font. It is often due to the font -designer's laziness or incompetence; in particular, most people seem -to find it easier to invent idiosyncratic glyph names rather than -follow the Adobe glyph list. - There are two ways of dealing with such fonts: using them with the encoding they were designed for, and creating an <it/ad hoc/ encoding file. -Of course, most of the time the proper fix would be to hit the font -designer very hard on the head with the PLRM (preferably the first -edition, as it was published in hardcover). - <sect2>Using fonts with the designer's encoding <p>In the case of Type 1 fonts, the font designer can specify a default encoding; this encoding is requested by using the `<tt/adobe-fontspecific/' encoding in the XLFD name. Sometimes, the -font designer omitted to specify a reasonable default encoding; in -this case, you should experiment with `<tt/adobe-standard/', +font designer omitted to specify a reasonable default encoding, in +which case you should experiment with `<tt/adobe-standard/', `<tt/iso8859-1/', `<tt/microsoft-cp1252/', and -`<tt/microsoft-win3.1/', (`<tt/microsoft-symbol/' doesn't make sense -for Type 1 fonts). +`<tt/microsoft-win3.1/'. (The encoding `<tt/microsoft-symbol/' doesn't +make sense for Type 1 fonts). -TrueType fonts do not have a default encoding, and use of the -Microsoft Symbol encoding yields strange results with text fonts on -some (non-X11) platforms. However, most TrueType fonts are designed -with either Microsoft or Apple platforms in mind, so one of -`<tt/microsoft-cp1252/', `<tt/microsoft-win3.1/', or -`<tt/apple-roman/' should yield reasonable results. +TrueType fonts do not have a default encoding. However, most TrueType +fonts are designed with either Microsoft or Apple platforms in mind, +so one of `<tt/microsoft-symbol/', `<tt/microsoft-cp1252/', +`<tt/microsoft-win3.1/', or `<tt/apple-roman/' should yield reasonable +results. -<sect2>Specifying an ad hoc encoding file +<sect2>Specifying an <it/ad hoc/ encoding file <p>It is always possible to define an encoding file to put the glyphs in a font in any desired order. Again, see the -`<tt/encodings/adobe-dingbats.enc/' file to see how this is done. - +`<tt>encodings/adobe-dingbats.enc</tt>' file to see how this is done. <sect2>Specifying font aliases <p>By following the directions above, you will find yourself with a -number of fonts with unusual names -- specifying encodings such as +number of fonts with unusual names --- with encodings such as `<tt/adobe-fontspecific/', `<tt/microsoft-win3.1/' <it/etc/. In order to use these fonts with standard applications, it may be useful to remap them to their proper names. @@ -575,75 +864,76 @@ This is done by writing a `<tt/fonts.alias/' file. The format of this file is similar to the format of the `<tt/fonts.dir/' file, except that it maps XLFD names to XLFD names. A `<tt/fonts.alias/' file might look as follows: -<tscreen> +<tscreen><verb> 1 -<p>"-ogonki-alamakota-medium-r-normal--0-0-0-0-p-0-iso8859-2" \ -<p> "-ogonki-alamakota-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific" -</tscreen> +"-ogonki-alamakota-medium-r-normal--0-0-0-0-p-0-iso8859-2" \ + "-ogonki-alamakota-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific" +</verb></tscreen> (both XLFD names on a single line). The syntax of the -`<tt/fonts.alias/' file is described in the mkfontdir(1) manual page. - - -<sect>New font backends +`<tt/fonts.alias/' file is precisely described in the +<tt/mkfontdir/(1) manual page. -<sect1>New TrueType backends +<sect>Additional notes about TrueType support -<p>This version of XFree86 comes with two TrueType backends, known as -`freetype' (formerly `xfsft') and `X-TrueType' (`X-TT' for short). -Those two backends are incompatible, in that only one can be used at -any one time. Users are invited to chose whichever backend they find -more useful and stick to it. - -The `freetype' backend resides in the module `<tt/freetype/'. Before -using it, please check that the `<tt/Module/' section of your -`<tt/XF86Config/' file contains a line that reads -<tscreen> - Load "freetype" -</tscreen> +<p>This version of XFree86 comes with two TrueType backends, +<it/FreeType/ (module `<tt/freetype/', formerly known as <it/xfsft/) and +<it/X-TrueType/ (module `<tt/xtt/'). These two backends are <it/not/ +compatible: only one of them can be used at any one time. + +In order to use the <it/FreeType/ backend, please check that the +`<tt/Module/' section of your `<tt/XF86Config/' file contains a line +that reads +<tscreen><verb> +Load "freetype" +</verb></tscreen> + +In order to use the <it/X-TrueType/ backend, replace the line in your +<tt/XF86Config/ file that loads the <tt/freetype/ module with a +line that reads +<tscreen><verb> + Load "xtt" +</verb></tscreen> + +Both TrueType backends delay glyph rasterisation up to the time at +which a glyph is first used. For this reason, they only provide an +approximate value for the ``average width'' font property. -The `X-TrueType' backend resides in module `<tt/xtt/'. In order to -use it, replace the line in your `<tt/XF86Config/' file that loads the -`<tt/freetype/' module with a line reading -<tscreen> - Load "xtt" -</tscreen> - -Both TrueType backends delay glyph rasterisation to the time at which -a glyph is first used. For this reason, they only provide an -approximate value for the `average width' font property. Users are -warned not to rely on the average width of a font having an accurate -value. - Both backends also support an optimisation for character-cell fonts (fonts with all glyph metrics equal, or terminal fonts). A font with an XLFD specifying a character-cell spacing `<tt/c/', as in -<tscreen> +<tscreen><verb> -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 -</tscreen> +</verb></tscreen> will not rasterise glyphs at metrics computation time, but instead -trust the font really to be a character-cell font. Users are +trust the font really to be a character-cell font. You are encouraged to make use of this optimisation when useful, but be warned that not all monospaced fonts are character-cell fonts. - -<sect2>The `freetype' TrueType backend +<sect1>The <it/FreeType/ TrueType backend -<p>The `freetype' backend (formerly `xfsft') is a backend based on the -FreeType library (see www.freetype.org) with support for the `fontenc' -style of internationalisation (see <ref id="sec-fontenc" name="The -fontenc layer">). This backend supports TrueType Font files -(<tt/*.ttf/) and TrueType Collections (<tt/*.ttc/). +<p>The <it/FreeType/ backend (formerly <it/xfsft/) is a backend based on +the FreeType library (see <url url="http://www.freetype.org/" +name="the FreeType web site">) and has support for the ``fontenc'' +style of internationalisation (see Section <ref id="sec:fontenc" +name="The fontenc layer">). This backend supports TrueType Font files +(`<tt/*.ttf/') and TrueType Collections (`<tt/*.ttc/'). In order to access the faces in a TrueType Collection file, the face number must be specified in the fonts.dir file before the filename within colons. For example, -<tscreen> +<tscreen><verb> :2:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 -</tscreen> +</verb></tscreen> refers to face 2 in the `<tt/mincho.ttc/' TrueType Collection file. -<sect2>The `X-TrueType' TrueType backend<label id="sec-X-TT"> +The <it/FreeType/ backend uses the <it/fontenc/ layer in order to +support recoding of fonts; this was described in Section <ref +id="sec:fontenc" name="The fontenc layer"> and especially Section <ref +id="sec:fontenc-freetype" name="FreeType-specific notes about +fontenc"> earlier in this document. +<sect1>The <it/X-TrueType/ TrueType backend <label id="sec:X-TT"> + <p>The `X-TrueType' backend is another backend based on the FreeType library. X-TrueType doesn't use the `fontenc' layer for managing font encodings, but instead uses its own database of encodings. However, @@ -652,151 +942,167 @@ X-TrueType extends the `<tt/fonts.dir/' syntax with a number of options, known as `TTCap'. A `TTCap' entry follows the general syntax -<tscreen> +<tscreen><verb> :option=value: -</tscreen> +</verb></tscreen> and should be specified before the filename. The most useful TTCap option is used to specify the face number to use -with TTCs; it carries the name `<tt/fn/'. This means that face 2 of font -file `<tt/mincho.ttc/' is specified using: -<tscreen> +with TTCs; this is the `<tt/fn/' TTCap option. For example, face 2 of +font file `<tt/mincho.ttc/' is specified using: +<tscreen><verb> :fn=2:mincho.ttc -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1990-0 -</tscreen> +</verb></tscreen> More information on the TTCap syntax, and on X-TrueType in general, -may be found on -<tscreen> -<url url="http://hawk.ise.chuo-u.ac.jp/student/person/tshiozak/x-tt/index-eng.html"> -</tscreen> +may be found on <url url="http://x-tt.dsl.gr.jp/" name="the X-TrueType +home page">. -<sect1>Support for CID-keyed fonts +<sect>Appendix: background and terminology <label id="sec:background"> +<sect1>Characters and glyphs -<p>The CID-keyed font format was designed by Adobe Systems for fonts with -large character sets. It is described in the Adobe Technical Notes -nr. 5092, "Overview of the CID-Keyed Font Technology," -nr. 5014, "CMap and CIDFont File Format Specification," and -others, available from -<tscreen> -<url url="http://partners.adobe.com/supportservice/devrelations/typeforum/cidfonts.html"> -</tscreen> +<p>A computer text-processing system inputs keystrokes and outputs +<it/glyphs/, small pictures that are assembled on paper or on a +computer screen. Keystrokes and glyphs do not, in general, coincide: +for example, if the system does generate ligatures, then to the two +keystrokes <<tt/f/><<tt/i/> will typically correspond a +single glyph. Similarly, if the system shapes Arabic glyphs in a +reasonable manner, then multiple different glyphs may correspond to +a single keystroke. + +The complex transformation rules from keystrokes to glyphs are usually +factored into two simpler transformations, going through the +intermediary of <it/characters/. You may want to think of characters +as the basic unit of data that is stored <it/e.g./ in the buffer of +your text editor. While the definition of a character is intrinsically +application-specific, a number of standardised collections of +characters have been defined. -Sample CID-keyed fonts can be found at: -<tscreen> -<url url="ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/"> -</tscreen> -Support for CID-keyed fonts in XFree86 is controlled by the two -switches `<tt/BuildCID/' and <tt/BuildCIDFonts/. Make sure that those -switches are turned on (in the directory <tt>xc/config/cf</tt>) when -XFree86 is built. By default, they should be set to <tt/YES/, unless -you are building XFree86 for a small memory footprint, in which case -they should be set to <tt/NO/. - -The CID-keyed font backend does not use the `fontenc' layer, but -instead uses the standard `CMap' method of recoding CID-keyed fonts. - -<sect2>Using CID-keyed fonts - -<p>As shown in the sample install file -<tt>/usr/X11R6/lib/X11/XF86Config.eg</tt>, the font directory CID -should be specified as part of the XFree86 font path: -<tscreen> -FontPath "/usr/X11R6/lib/X11/fonts/CID/" -</tscreen> -in the `<tt/XF86Config/' file. When the CID font directory is on the -font path it must contain at least the empty files fonts.dir and -fonts.scale. Sample `<tt/fonts.dir/' and `<tt/fonts.scale/' files, -with 0 entries, are installed by default. - -A sample CID-keyed font is provided in the file: -<tscreen> -test/xsuite/xtest/CID -</tscreen> -The test directory was given the same name as the CID font directory, -because it shows how a CID-keyed font should be installed. It -contains a number of subdirectories, and any CID font directory should -have the same directory structure. +A <it/coded character set/ is a set of characters together with a +mapping from integer codes --- known as <it/codepoints/ --- to +characters. Examples of coded character sets include US-ASCII, +ISO 8859-1, KOI8-R, and JIS X 0208(1990). -When installing CID-keyed fonts, the empty fonts.scale and fonts.dir -files in the directory: -<tscreen> -xc/fonts/scaled/CID -</tscreen> -should be replaced by <tt/fonts.scale/ and <tt/fonts.dir/ files with a -number of entries of the form: -<tscreen> -1 -<p>Adobe-Korea1/Munhwa-Regular--Adobe-Korea1-0.cid \ -<p> -adobe-munhwa-medium-r-normal--0-0-0-0-p-0-adobe.korea1-0 -</tscreen> -(the font file name and the XLFD name should be on the same line). -Note that the first column does not specify an actual filename; -instead, it specifies the PostScript name of the CID-keyed font, -followed by the extension `<tt/.cid/'. The actual names of the files -used will be derived from this PostScript name. +A coded character set need not use 8 bit integers to index +characters. Many early mainframes used 6 bit character sets, while +16 bit (or more) character sets are necessary for ideographic writing +systems. -CID-keyed fonts are divided in groups by character collection. For -example, the Korean font: -<tscreen> -Munhwa-Regular--Adobe-Korea1-0 -</tscreen> -is in a subdirectory `<tt/Adobe-Korea1/'. +<sect1>Font files, fonts, and XLFD <label id="sec:xlfd"> -The PostScript name of a CID-keyed font consists of two parts, the -<it/CIDFontName/ and the <it/CMapName/, separated by two dashes. -For instance, in the case of the font name -<tscreen> -Munhwa-Regular--Adobe-Korea1-0 -</tscreen> -the <it/CIDFontName/ is `<tt/Munhwa-Regular/' while the <it/CMapName/ -is `<tt/Adobe-Korea1/'. +<p>Traditionally, typographers speak about <it/typefaces/ and +<it/founts/. A typeface is a particular style or design, such as +Times Italic, while a fount is a molten-lead incarnation of a given +typeface at a given size. -Each CID-keyed font consist of a CIDFont file and one or more CMap files. -The CIDFont file contains the description of each character in a font. It is -stored in the subdirectory CIDFont of the Adobe-Korea1 directory. The -directory structure looks as following: -<tscreen> -CID/Adobe-Korea1/CIDFont/Munhwa-Regular -<p>CID/Adobe-Korea1/CMap/Adobe-Korea1-0 -<p>CID/Adobe-Korea1/AFM/Munhwa-Regular.afm -<p>CID/Adobe-Korea1/CFM -<p>CID/fonts.dir -<p>CID/fonts.scale -</tscreen> -The file `<tt/Munhwa-Regular.afm/' is an Adobe Font Metric File (AFM). -The directory `<tt/CFM/' will be used for summaries of that font -metric file, which will be computed later. +Digital fonts come in <it/font files/. A font file contains all the +information necessary for generating glyphs of a given typeface, and +applications using font files may access glyph information in an +arbitrary order. -When the CID-keyed files are installed you can run the utility -<tscreen> -/usr/X11R6/bin/mkcfm -</tscreen> -to create the summaries of font metric file (<tt/*.cfm/), and to put them -in appropriate subdirectories. By default, the program works on the -directory: -<tscreen> -/usr/X11R6/lib/X11/fonts/CID -</tscreen> -A different directory can be specified on the command line of -`<tt/mkcfm/.' +Digital fonts may consist of bitmap data, in which case they are said +to be <it/bitmap fonts/. They may also consist of a mathematical +description of glyph shapes, in which case they are said to be +<it/scalable fonts/. Common formats for scalable font files are +<it/Type 1/ (sometimes incorrectly called <it/ATM fonts/ or +<it/PostScript fonts/), <it/Speedo/ and <it/TrueType/. -`<tt/mkcfm/' should be run as root, as it needs to write its output to -a system directory. If the program determines that it cannot write in -the designated `<tt/CFM/' subdirectories, it will display a message, -and switch to current directory. - -Unless `<tt/mkcfm/' is run, opening large CID-keyed fonts will take a -significant amount of time. `<tt/mkcfm/' should be run again whenever a -change is made to any of the CID-keyed fonts, or when the CID-keyed -fonts are copied to a machine with a different architecture. - -<sect2>Limitations - -<p>The current version of the CID-keyed fonts backend only supports -the CMaps used for horizontal text (<it/e.g./ the CMap -`<tt/KSC-EUC-H/' will be used, but not `<tt/KSC-EUC-V/'). This -limitation is due to the fact that the core X11 protocol only provides -support for horizontal writing. +The glyph data in a digital font needs to be indexed somehow. How +this is done depends on the font file format. In the case of +Type 1 fonts, glyphs are identified by <it/glyph names/. In the +case of TrueType fonts, glyphs are indexed by integers corresponding +to one of a number of indexing schemes (usually Unicode --- see below). + +The X11 system uses the data in font file to generate <it/font +instances/, which are collections of glyphs at a given size indexed +according to a given encoding. +X11 font instances are usually specified using a notation known as the +<it/X Logical Font Description/ (XLFD). An XLFD starts with a dash +`<tt/-/', and consists of fourteen fields separated by dashes, for +example +<tscreen><verb> +-adobe-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1 +</verb></tscreen> +Or particular interest are the last two fields `<tt/iso8859-1/', which +specify the font instance's encoding. -</article> +X11 font instances may also be specified by short name. Unlike an +XLFD, a short name has no structure and is simply a conventional name +for a font instance. Two short names are of particular interest, as +they are handled specially by the server, and the server will not +start if font instances with these names cannot be opened. These are +`<tt/fixed/', which specifies the fallback font to use when the +requested font cannot be opened, and `<tt/cursor/', which specifies +the set of glyphs to be used by the mouse pointer. + +Short names are usually implemented as aliases to XLFDs; the +`<tt/fixed/' and `<tt/cursor/' aliases are defined in +<tscreen><verb> +/usr/X11R6/lib/X11/font/misc/fonts.alias +</verb></tscreen> + +<sect1>Unicode +<p>Unicode (<url url="http://www.unicode.org">) is a coded character +set with the goal of uniquely identifying all characters for all +scripts, current and historical. While Unicode was explicitly not +designed as a glyph encoding scheme, it is often possible to use it as +such. + +Unicode is an <it/open/ character set, meaning that codepoint +assignments may be added to Unicode at any time (once specified, +though, an assignment can never be changed). For this reason, a +Unicode font will be <it/sparse/, and only define glyphs for a subset +of the character registry of Unicode. + +The Unicode standard is defined in parallel with the international +standard ISO 10646. Assignments in the two standards are always +equivalent, and this document uses the terms <it/Unicode/ and +<it/ISO 10646/ interchangeably. + +When used in X11, Unicode-encoded fonts should have the last two +fields of their XLFD set to `<tt/iso10646-1/'. + +<sect>References + +<p>XFree86 comes with extensive documentation in the form of manual +pages and typeset documents. Before installing fonts, you really +should read the <tt/mkfontdir/(1) manual page; other manual pages of +interest include <tt/X/(1), <tt/Xserver/(1), <tt/xset/(1), +<tt/xlsfonts/(1) and <tt/showfont/(1). In addition, you may want to +read the X Logical Font Description document, by Jim Flowers, which is +provided in the file `<tt>xc/doc/xlfd.PS.Z</tt>'. + +The <url name="comp.fonts FAQ" +url="http://www.netmeg.net/faq/computers/fonts/">, which is +unfortunately no longer being maintained, contains a wealth of +information about digital fonts. + +The +<url name="xfsft home page" + url="http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/"> +has been superseded by this document, and is now obsolete; you may +however still find some of the information it contains useful. <url +name="Joerg Pommnitz' xfsft page" +url="http://www.joerg-pommnitz.de/TrueType/xfsft.html"> is the +canonical source for the `<tt/ttmkfdir/' utility. + +The documentation of <it/X-TrueType/ is available from +<url url="http://x-tt.dsl.gr.jp/" name="the X-TrueType home page">. + +A number of East-Asian CIDFonts are available from +<url name="O'Reilly's FTP site" + url="ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/">. + +The <url url="http://www.unicode.org" name="Unicode consortium site"> +may be of interest. But you are more likely to find what you need on +Markus Kuhn's <url url="http://www.cl.cam.ac.uk/~mgk25/unicode.html" +name="UTF-8 and Unicode FAQ">. + +The IANA RFC documents, available from a number of sites throughout +the world, often provide interesting information about character set +issues; my favourite is RFC 373. + +</article> +<!-- Who was it who wrote the Linuxdoc DTD, and was he drunk at the + time ? --> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre:1.8 xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre:1.11 --- xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre:1.8 Fri Jun 30 18:09:37 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre Sun Dec 17 18:01:10 2000 @@ -8,10 +8,10 @@ <!-- Title information --> <title>Documentation for XFree86™ version &relvers; <author>The XFree86 Project, Inc -<date>30 June 2000 +<date>18 December 2000 <!-- -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre,v 1.8 2000/06/30 22:09:37 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre,v 1.11 2000/12/17 23:01:10 dawes Exp $ --> <p> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/newport.sgml diff -u /dev/null xc/programs/Xserver/hw/xfree86/doc/sgml/newport.sgml:1.2 --- /dev/null Mon Dec 18 14:29:53 2000 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/newport.sgml Tue Dec 12 13:54:29 2000 @@ -0,0 +1,53 @@ +<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN" [ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> + +<article> +<title>Information for newport Users +<author>Guido Guenther +<date>1 August 2000 +<ident> +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/newport.sgml,v 1.2 2000/12/12 18:54:29 dawes Exp $ +</ident> +<toc> + +<sect>Supported Hardware +<p> +This is an unaccelerated driver for the SGI Indy's newport cards. Both the + 8bit and 24bit versions are tested and working with some limitations(see below). +The 24bit newport additionally works in 8bit mode only. + +<sect>Notes +<p> +<itemize> + <item>X -configure does not generate a XF86Config file +</itemize> + + +<sect>Configuration +<p> +The following Section "Device" options are supported by the newport driver: +<itemize> + <item>Option "bitplanes" "x" + Gives the maximum number of bitplanes your card supports (8 or 24). +</itemize> + + +<sect>Authors +<p> +<itemize> + <item>Guido Guenther <email>guido.guenther@gmx.net</email> +</itemize> + + +<sect>Acknowledgements +<p> +<itemize> + <item>Gleb O. Raiko <email>raiko@niisi.msk.ru</email> for getting the beast to build + <item>Ralf Baechle <email>ralf@oss.sgi.com</email> for his patience... + <item>Ulf Carlsson <email>ulfc@calypso.engr.sgi.com</email> for comments and the dynamic loader code + <item>Nina A. Podolskaya <email>nap@niisi.msk.ru</email> for dynamic loader code + <item>all the guys who wrote the newport_con linux kernel code +</itemize> + +</article> Index: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml diff -u xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml:1.2 xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml:1.3 --- xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml:1.2 Sat Jul 10 08:17:25 1999 +++ xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml Tue Nov 28 15:59:17 2000 @@ -8,14 +8,14 @@ <date>10 Jul 1999 <ident> -$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml,v 1.2 1999/07/10 12:17:25 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml,v 1.3 2000/11/28 20:59:17 dawes Exp $ </ident> <toc> <sect> Supported hardware <p> -The s3virge driver in XFree86 &relvers; supports the S3 ViRGE, ViRGE DX, GX, MX, MX+, and VX chipsets. A majority of testing is done on ViRGE DX chips, making them the most stable to date. This release has improved support for 24 bit color depths and resolves all the known issues with Netscape and other applications supporting 24 bit color. +The s3virge driver in XFree86 &relvers; supports the S3 ViRGE, ViRGE DX, GX, MX, MX+, and VX chipsets. A majority of testing is done on ViRGE DX chips, making them the most stable to date. This release has improved support for ViRGE GX2 stability, XVideo support for ViRGE DX (tested) and ViRGE (untested) in depth 16 and 24, conversion to fb framebuffer rendering, and support for the new Render extension (untested). This driver is moderately stable, however please use caution with any new install. Please report any problems to <email>XFree86@Xfree86.org</email> Index: xc/programs/Xserver/hw/xfree86/drivers/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/Imakefile:1.15 xc/programs/Xserver/hw/xfree86/drivers/Imakefile:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/Imakefile:1.15 Tue Mar 7 23:05:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/Imakefile Tue Nov 28 15:59:17 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/Imakefile,v 1.15 2000/03/08 04:05:04 robin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/Imakefile,v 1.20 2000/11/28 20:59:17 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -10,12 +10,12 @@ #ifndef OS2Architecture OBJS = `cat driver.list` #else -OBJS = al2101/?*.o mx/?*.o oak/?*.o realtek/?*.o sis/?*.o trident/?*.o \ - ali/?*.o apm/?*.o apollo/?*.o ark/?*.o ati/?*.o chips/?*.o \ - cirrus/?*.o cl64xx/?*.o compaq/?*.o et3000/?*.o glint/?*.o \ - gvga/?*.o hercules/?*.o hgc1280/?*.o mga/?*.o ncr/?*.o \ - nv/?*.o s3_pio/?*.o s3_newmmio/?*.o sigma/?*.o tseng/?*.o \ - vga/?*.o video7/?*.o wd/?*.o i740/?*.o r128/?*.o +OBJS = apm/?*_drv.o ati/?*_drv.o chips/?*_drv.o cirrus/?*_drv.o \ + cyrix/?*_drv.o glint/?*_drv.o i128/?*_drv.o i740/?*_drv.o \ + i810/?*_drv.o imstt/?*_drv.o mga/?*_drv.o neomagic/?*_drv.o \ + nv/?*_drv.o rendition/?*_drv.o s3virge/?*_drv.o sis/?*_drv.o \ + tdfx/?*_drv.o tga/?*_drv.o trident/?*_drv.o tseng/?*_drv.o \ + vesa/?*_drv.o vga/?*_drv.o siliconmotion/?*.drv.o #endif Index: xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile:1.19 xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile:1.19 Fri Jun 30 14:27:02 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile Tue Sep 19 20:09:18 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile,v 1.19 2000/06/30 18:27:02 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile,v 1.20 2000/09/20 00:09:18 keithp Exp $ #define IHaveModules #include <Server.tmpl> @@ -25,7 +25,7 @@ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ -I$(XF86SRC)/shadowfb \ -I$(XF86SRC)/i2c -I$(XF86SRC)/ddc \ - -I$(SERVERSRC)/Xext -I$(EXTINCSRC) \ + -I$(SERVERSRC)/Xext -I$(EXTINCSRC) -I$(SERVERSRC)/render \ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(XF86OSSRC)/vbe -I$(FONTINCSRC) #endif Index: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp:1.4 Tue Jun 13 22:13:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp Mon Dec 11 15:18:05 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp,v 1.4 2000/06/14 02:13:07 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp,v 1.5 2000/12/11 20:18:05 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH APM __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH APM __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME apm \- Alliance ProMotion video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c:1.44 xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c:1.46 --- xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c:1.44 Fri Jun 30 14:34:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c Sat Dec 2 10:30:31 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c,v 1.44 2000/06/30 18:34:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c,v 1.46 2000/12/02 15:30:31 tsi Exp $ */ #include "apm.h" @@ -172,6 +172,12 @@ NULL }; +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + NULL +}; + static const char *ddcSymbols[] = { "xf86PrintEDID", "xf86DoEDID_DDC1", @@ -235,7 +241,7 @@ xf86AddDriver(&APM, module, 0); LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, - /*xf8_32bppSymbols,*/ ramdacSymbols, + /*xf8_32bppSymbols,*/ ramdacSymbols, vbeSymbols, ddcSymbols, i2cSymbols, shadowSymbols, NULL); return (pointer)1; @@ -372,7 +378,7 @@ ApmProbe(DriverPtr drv, int flags) { int numDevSections, numUsed, i; - GDevPtr *DevSections = NULL; + GDevPtr *DevSections; int *usedChips; int foundScreen = FALSE; @@ -439,8 +445,7 @@ } } } - if (DevSections) - xfree(DevSections); + xfree(DevSections); return foundScreen; } Index: xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile:1.5 --- /dev/null Mon Dec 18 14:29:54 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile Wed Nov 15 18:13:08 2000 @@ -0,0 +1,49 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ark/Imakefile,v 1.5 2000/11/15 23:13:08 dawes Exp $ +/* + * + * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> + * + */ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = ark_driver.c ark_accel.c + +OBJS = ark_driver.o ark_accel.o + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ + -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ + -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ + -I$(XF86SRC)/fbdevhw -I$(XF86SRC)/ddc \ + -I$(XF86SRC)/i2c \ + -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ + -I$(EXTINCSRC) -I$(SERVERSRC)/render +#endif + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +NormalAsmObjectRule() + +ModuleObjectRule() +ObjectModuleTarget(ark, $(OBJS)) + +InstallObjectModule(ark,$(MODULEDIR),drivers) + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/ark) +InstallDriverSDKNonExecFile(ark.h,$(DRIVERSDKDIR)/drivers/ark) +InstallDriverSDKNonExecFile(ark_reg.h,$(DRIVERSDKDIR)/drivers/ark) +InstallDriverSDKNonExecFile(ark_driver.c,$(DRIVERSDKDIR)/drivers/ark) +InstallDriverSDKNonExecFile(ark_accel.c,$(DRIVERSDKDIR)/drivers/ark) + Index: xc/programs/Xserver/hw/xfree86/drivers/ark/ark.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ark/ark.h:1.1 --- /dev/null Mon Dec 18 14:29:54 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ark/ark.h Tue Nov 14 12:28:12 2000 @@ -0,0 +1,71 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ark/ark.h,v 1.1 2000/11/14 17:28:12 dawes Exp $ */ +/* + * ark + */ + +#ifndef _ARK_H +#define _ARK_H + +#include "xf86.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xaa.h" +#include "xf86_ansic.h" +#include "vgaHW.h" + +typedef struct _ARKRegRec { + unsigned char sr10, sr11, sr12, sr13, sr14, + sr15, sr16, sr17, sr18, sr20, + sr21, sr22, sr23, sr24, sr25, + sr26, sr27, sr28, sr29, sr2a, + sr2b; + unsigned char sr1c, sr1d; + unsigned char cr40, cr41, cr42, cr44, cr46; + unsigned char dac_command; + unsigned char stg_17xx[3]; + unsigned char gendac[6]; +} ARKRegRec, *ARKRegPtr; + + +typedef struct _ARKRec { + pciVideoPtr PciInfo; + PCITAG PciTag; + EntityInfoPtr pEnt; + CARD32 IOAddress; + CARD32 FBAddress; + unsigned char * FBBase; + unsigned char * MMIOBase; + unsigned long videoRam; + OptionInfoPtr Options; + unsigned int Flags; + Bool NoAccel; + CARD32 Bus; + XAAInfoRecPtr pXAA; + int Chipset, ChipRev; + int clock_mult; + int dac_width; + int multiplex_threshold; + int ramdac; + ARKRegRec SavedRegs; /* original mode */ + ARKRegRec ModeRegs; /* current mode */ + Bool (*CloseScreen)(int, ScreenPtr); +} ARKRec, *ARKPtr; + + +#define ARKPTR(p) ((ARKPtr)((p)->driverPrivate)) + + +#define DRIVER_NAME "ark" +#define DRIVER_VERSION "0.5.0" +#define VERSION_MAJOR 0 +#define VERSION_MINOR 5 +#define PATCHLEVEL 0 +#define ARK_VERSION ((VERSION_MAJOR << 24) | \ + (VERSION_MINOR << 16) | \ + PATCHLEVEL) + +#define ZOOMDAC 0x404 +#define ATT490 0x101 + + +#endif /* _ARK_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c:1.4 --- /dev/null Mon Dec 18 14:29:54 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c Wed Nov 15 18:13:09 2000 @@ -0,0 +1,227 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_accel.c,v 1.4 2000/11/15 23:13:09 dawes Exp $ */ +/* + * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> + * + * XFree86 4.x driver for ARK Logic chipset + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation and + * that the name of Ani Joshi not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Ani Joshi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ANI JOSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * + * Based on the 3.3.x driver by: + * Harm Hanemaayer <H.Hanemaayer@inter.nl.net> + * + */ + + +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xaa.h" +#include "xf86PciInfo.h" +#include "compiler.h" + +#include "ark.h" +#include "ark_reg.h" + + +int curx, cury, cmd_flags; + + +static void ARKSync(ScrnInfoPtr pScrn) +{ + for (;;) { + if (!(inb(0x3cb) & 0x40)) + break; + } +} + + +static void ARKSetupForSolidFill(ScrnInfoPtr pScrn, int color, + int rop, unsigned int planemask) +{ + ARKPtr pARK = ARKPTR(pScrn); + + OUTREG16(FG_COLOR, color); + /* ARK color mix matches X raster-ops */ + OUTREG16(COLOR_MIX_SEL, (rop | (rop << 8))); + switch (pScrn->bitsPerPixel) { + case 8: + if ((planemask & 0xff) == 0xff) + cmd_flags = DISABLE_PLANEMASK; + else { + OUTREG16(WRITE_PLANEMASK, planemask); + cmd_flags = 0; + } + break; + case 16: + if ((planemask & 0xffff) == 0xffff) + cmd_flags = DISABLE_PLANEMASK; + else { + OUTREG16(WRITE_PLANEMASK, planemask); + cmd_flags = 0; + } + break; + case 32: + OUTREG16(FG_COLOR_HI, color >> 16); + if ((planemask & 0xffffff) == 0xffffff) + cmd_flags = DISABLE_PLANEMASK; + else { + OUTREG16(WRITE_PLANEMASK, planemask); + cmd_flags = 0; + } + break; + } + + curx = cury = -1; +} + + +static void ARKSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, + int y, int w, int h) +{ + ARKPtr pARK = ARKPTR(pScrn); + int dst_addr; + + OUTREG(WIDTH, ((h - 1) << 16) | (w - 1)); + if (x != curx || y != cury) { + dst_addr = y * pScrn->displayWidth + x; + OUTREG(DST_ADDR, dst_addr); + curx = x; + cury = y; + } + OUTREG16(COMMAND, SELECT_BG_COLOR | SELECT_FG_COLOR | + STENCIL_ONES | DISABLE_CLIPPING | BITBLT | + cmd_flags); + cury += h; +} + + + +static void ARKSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, + int ydir, int rop, unsigned int planemask, + int trans_color) +{ + ARKPtr pARK = ARKPTR(pScrn); + + cmd_flags = 0; + if (trans_color != -1) { + if (pScrn->bitsPerPixel <= 16) + OUTREG16(TRANS_COLOR, trans_color); + else { + OUTREG16(TRANS_COLOR, trans_color & 0xffff); + OUTREG16(TRANS_COLOR_HI, trans_color >> 16); + } + cmd_flags = STENCIL_GENERATED; + OUTREG16(COLOR_MIX_SEL, rop | 0x0500); + } else { + OUTREG16(COLOR_MIX_SEL, rop | (rop << 8)); + } + + if (ydir < 0) + cmd_flags |= UP; + if (xdir < 0) + cmd_flags |= LEFT; + + /* yes, quite ugly */ + if ((pScrn->bitsPerPixel == 8 && (planemask & 0xff) == 0xff) || + (pScrn->bitsPerPixel == 16 && (planemask & 0xffff) == 0xffff) || + (pScrn->bitsPerPixel == 32 && (planemask & 0xffffff) == 0xffffff)) + cmd_flags |= DISABLE_PLANEMASK; + else + OUTREG16(WRITE_PLANEMASK, planemask); + +} + + + +static void ARKSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int x1, int y1, + int x2, int y2, + int w, int h) +{ + ARKPtr pARK = ARKPTR(pScrn); + int src_addr, dst_addr; + + if (cmd_flags & UP) { + src_addr = (y1 + h - 1) * pScrn->displayWidth; + dst_addr = (y2 + h - 1) * pScrn->displayWidth; + } else { + src_addr = y1 * pScrn->displayWidth; + dst_addr = y2 * pScrn->displayWidth; + } + if (cmd_flags & LEFT) { + src_addr += x1 + w - 1; + dst_addr += x2 + w - 1; + } else { + src_addr += x1; + dst_addr += x2; + } + + OUTREG(SRC_ADDR, src_addr); + OUTREG(DST_ADDR, dst_addr); + OUTREG(WIDTH, ((h - 1) << 16) | (w - 1)); + OUTREG16(COMMAND, BG_BITMAP | FG_BITMAP | DISABLE_CLIPPING | + BITBLT | cmd_flags); +} + + + +Bool ARKAccelInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ARKPtr pARK = ARKPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + XAAInfoRecPtr pXAA; + + if (!(pXAA = XAACreateInfoRec())) + return FALSE; + + pXAA->Flags = LINEAR_FRAMEBUFFER; + + pXAA->Sync = ARKSync; + pXAA->SetupForSolidFill = ARKSetupForSolidFill; + pXAA->SubsequentSolidFillRect = ARKSubsequentSolidFillRect; + pXAA->ScreenToScreenCopyFlags = 0; + pXAA->SetupForScreenToScreenCopy = ARKSetupForScreenToScreenCopy; + pXAA->SubsequentScreenToScreenCopy = ARKSubsequentScreenToScreenCopy; + + OUTREG16(COLOR_MIX_SEL, 0x0303); + if (pARK->Chipset == PCI_CHIP_1000PV) { + OUTREG16(WRITE_PLANEMASK, 0xffff); + OUTREG16(TRANS_COLOR_MSK, 0xffff); + } else { + OUTREG16(TRANS_COLOR, 0xffff); + OUTREG16(TRANS_COLOR, 0xffffffff >> 16); + } + if (pARK->Chipset == PCI_CHIP_1000PV && pScrn->bitsPerPixel == 32) { + OUTREG16(STENCIL_PITCH, pScrn->displayWidth * 2); + OUTREG16(SRC_PITCH, pScrn->displayWidth * 2); + OUTREG16(DST_PITCH, pScrn->displayWidth * 2); + } else { + OUTREG16(STENCIL_PITCH, pScrn->displayWidth); + OUTREG16(SRC_PITCH, pScrn->displayWidth); + OUTREG16(DST_PITCH, pScrn->displayWidth); + } + + OUTREG16(BITMAP_CONFIG, LINEAR_STENCIL_ADDR | LINEAR_SRC_ADDR | + LINEAR_DST_ADDR); + + return XAAInit(pScreen, pXAA); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c:1.9 --- /dev/null Mon Dec 18 14:29:54 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c Sat Dec 2 10:30:31 2000 @@ -0,0 +1,1169 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_driver.c,v 1.9 2000/12/02 15:30:31 tsi Exp $ */ +/* + * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> + * + * XFree86 4.x driver for ARK Logic chipset + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation and + * that the name of Ani Joshi not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Ani Joshi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ANI JOSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * + * Based on the 3.3.x driver by: + * Harm Hanemaayer <H.Hanemaayer@inter.nl.net> + * + */ + + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xf86Version.h" +#include "xf86Resources.h" +#include "xf86fbman.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "xaa.h" +#include "mipointer.h" +#include "micmap.h" +#include "mibstore.h" + +#include "ark.h" + + +/* + * prototypes + */ +static OptionInfoPtr ARKAvailableOptions(int chipid, int busid); +static void ARKIdentify(int flags); +static Bool ARKProbe(DriverPtr drv, int flags); +static Bool ARKPreInit(ScrnInfoPtr pScrn, int flags); +static Bool ARKEnterVT(int scrnIndex, int flags); +static void ARKLeaveVT(int scrnIndex, int flags); +static void ARKSave(ScrnInfoPtr pScrn); +static Bool ARKScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv); +static Bool ARKMapMem(ScrnInfoPtr pScrn); +static void ARKUnmapMem(ScrnInfoPtr pScrn); +static Bool ARKModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void ARKAdjustFrame(int scrnIndex, int x, int y, int flags); +Bool ARKSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +Bool ARKCloseScreen(int scrnIndex, ScreenPtr pScreen); +Bool ARKSaveScreen(ScreenPtr pScreen, int mode); +static void ARKFreeScreen(int scrnIndex, int flags); +static void ARKLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indicies, LOCO *colors, + VisualPtr pVisual); +static void ARKWriteMode(ScrnInfoPtr pScrn, vgaRegPtr pVga, ARKRegPtr new); + +/* helpers */ +static unsigned char get_daccomm(); +static unsigned char set_daccom(unsigned char comm); + + +DriverRec ARK = +{ + ARK_VERSION, + DRIVER_NAME, + ARKIdentify, + ARKProbe, + ARKAvailableOptions, + NULL, + 0 +}; + +/* supported chipsets */ +static SymTabRec ARKChipsets[] = { + { PCI_CHIP_1000PV, "ark1000pv" }, + { PCI_CHIP_2000PV, "ark2000pv" }, + { PCI_CHIP_2000MT, "ark2000mt" }, + { -1, NULL } +}; + +static PciChipsets ARKPciChipsets[] = { + { PCI_CHIP_1000PV, PCI_CHIP_1000PV, RES_SHARED_VGA }, + { PCI_CHIP_2000PV, PCI_CHIP_2000PV, RES_SHARED_VGA }, + { PCI_CHIP_2000MT, PCI_CHIP_2000MT, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +typedef enum { + OPTION_NOACCEL +} ARKOpts; + +static OptionInfoRec ARKOptions[] = { + { OPTION_NOACCEL, "noaccel", OPTV_BOOLEAN, {0}, FALSE } +}; + +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; + +static const char *vgaHWSymbols[] = { + "vgaHWGetHWRec", + "vgaHWFreeHWRec", + "vgaHWGetIOBase", + "vgaHWSave", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWMapMem", + "vgaHWUnmapMem", + "vgaHWSaveScreen", + "vgaHWLock", + NULL +}; + +static const char *xaaSymbols[] = { + "XAACreateInfoRec", + "XAADestroyInfoRec", + "XAAInit", + "XAAScreenIndex", + NULL +}; + +#ifdef XFree86LOADER + +MODULESETUPPROTO(ARKSetup); + +static XF86ModuleVersionInfo ARKVersRec = { + "ark", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +XF86ModuleData arkModuleData = { &ARKVersRec, ARKSetup, NULL }; + +pointer ARKSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&ARK, module, 0); + LoaderRefSymLists(fbSymbols, vgaHWSymbols, xaaSymbols, NULL); + return (pointer) 1; + } else { + if (errmaj) + *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + + +static Bool ARKGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(ARKRec), 1); + + return TRUE; +} + +static void ARKFreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn->driverPrivate) + return; + + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +static OptionInfoPtr ARKAvailableOptions(int chipid, int busid) +{ + return ARKOptions; +} + +static void ARKIdentify(int flags) +{ + xf86PrintChipsets("ark", "driver (version " DRIVER_VERSION " for ARK Logic chipset", + ARKChipsets); +} + +static Bool ARKProbe(DriverPtr drv, int flags) +{ + int i; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool foundScreen = FALSE; + + /* sanity check */ + if ((numDevSections = xf86MatchDevice("ark", &devSections)) <= 0) + return FALSE; + + /* do ISA later */ + numUsed = xf86MatchPciInstances("ark", PCI_VENDOR_ARK, + ARKChipsets, ARKPciChipsets, + devSections, numDevSections, drv, + &usedChips); + + xfree(devSections); + + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i=0; i<numUsed; i++) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + + pScrn->driverVersion = VERSION_MAJOR; + pScrn->driverName = DRIVER_NAME; + pScrn->name = "ark"; + pScrn->Probe = ARKProbe; + pScrn->PreInit = ARKPreInit; + pScrn->ScreenInit = ARKScreenInit; + pScrn->SwitchMode = ARKSwitchMode; + pScrn->AdjustFrame = ARKAdjustFrame; + pScrn->EnterVT = ARKEnterVT; + pScrn->LeaveVT = ARKLeaveVT; + pScrn->FreeScreen = ARKFreeScreen; + foundScreen = TRUE; + xf86ConfigActivePciEntity(pScrn, usedChips[i], ARKPciChipsets, + NULL, NULL, NULL, NULL, NULL); + } + + xfree(usedChips); + + return foundScreen; +} + + +static Bool ARKPreInit(ScrnInfoPtr pScrn, int flags) +{ + EntityInfoPtr pEnt; + ARKPtr pARK; + vgaHWPtr hwp; + MessageType from = X_DEFAULT; + int i; + ClockRangePtr clockRanges; + char *mod = NULL; + const char *reqSym = NULL; + rgb zeros = {0, 0, 0}; + Gamma gzeros = {0.0, 0.0, 0.0}; + unsigned char tmp; + + if (flags & PROBE_DETECT) + return FALSE; + + if (!xf86LoadSubModule(pScrn, "vgahw")) + return FALSE; + + xf86LoaderReqSymLists(vgaHWSymbols, NULL); + + if (!vgaHWGetHWRec(pScrn)) + return FALSE; + + hwp = VGAHWPTR(pScrn); + vgaHWGetIOBase(hwp); + + pScrn->monitor = pScrn->confScreen->monitor; + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb | Support32bppFb)) + return FALSE; + else { + switch (pScrn->depth) { + case 8: + case 16: + case 24: + case 32: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + return FALSE; + } + } + + xf86PrintDepthBpp(pScrn); + + if (pScrn->depth > 8) { + if (!xf86SetWeight(pScrn, zeros, zeros)) + return FALSE; + } + + if (pScrn->depth == 8) + pScrn->rgbBits = 8; + + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + + pScrn->progClock = TRUE; + + if (!ARKGetRec(pScrn)) + return FALSE; + + pARK = ARKPTR(pScrn); + + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ARKOptions); + + if (xf86ReturnOptValBool(ARKOptions, OPTION_NOACCEL, FALSE)) { + pARK->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: NoAccel - acceleration disabled\n"); + } else + pARK->NoAccel = FALSE; + + if (pScrn->numEntities > 1) { + ARKFreeRec(pScrn); + return FALSE; + } + + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (pEnt->resources) { + xfree(pEnt); + ARKFreeRec(pScrn); + return FALSE; + } + + pARK->PciInfo = xf86GetPciInfoForEntity(pEnt->index); + xf86RegisterResources(pEnt->index, NULL, ResNone); + xf86SetOperatingState(RES_SHARED_VGA, pEnt->index, ResUnusedOpr); + xf86SetOperatingState(resVgaMemShared, pEnt->index, ResDisableOpr); + + if (pEnt->device->chipset && *pEnt->device->chipset) { + pScrn->chipset = pEnt->device->chipset; + pARK->Chipset = xf86StringToToken(ARKChipsets, pScrn->chipset); + } else if (pEnt->device->chipID >= 0) { + pARK->Chipset = pEnt->device->chipID; + pScrn->chipset = (char *)xf86TokenToString(ARKChipsets, + pARK->Chipset); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pARK->Chipset); + } else { + pARK->Chipset = pARK->PciInfo->chipType; + pScrn->chipset = (char *)xf86TokenToString(ARKChipsets, + pARK->Chipset); + } + + if (pEnt->device->chipRev >= 0) { + pARK->ChipRev = pEnt->device->chipRev; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + pARK->ChipRev); + } else + pARK->ChipRev = pARK->PciInfo->chipRev; + + xfree(pEnt); + + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Chipset: \"%s\"\n", pScrn->chipset); + + pARK->PciTag = pciTag(pARK->PciInfo->bus, pARK->PciInfo->device, + pARK->PciInfo->func); + + /* unlock CRTC[0-7] */ + outb(hwp->IOBase + 4, 0x11); + tmp = inb(hwp->IOBase + 5); + outb(hwp->IOBase + 5, tmp & 0x7f); + modinx(0x3c4, 0x1d, 0x01, 0x01); + + /* use membase's later on ??? */ + pARK->FBAddress = (rdinx(0x3c4, 0x13) << 16) + + (rdinx(0x3c4, 0x14) << 24); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Framebuffer @ 0x%x\n", + pARK->FBAddress); + + if (!xf86SetGamma(pScrn, gzeros)) + return FALSE; + + if (!pScrn->videoRam) { + unsigned char sr10; + + sr10 = rdinx(0x3c4, 0x10); + if (pARK->Chipset == PCI_CHIP_1000PV) { + if ((sr10 & 0x40) == 0) + pScrn->videoRam = 1024; + else + pScrn->videoRam = 2048; + } + if (pARK->Chipset == PCI_CHIP_2000PV || + pARK->Chipset == PCI_CHIP_2000MT) { + if ((sr10 & 0xc0) == 0) + pScrn->videoRam = 1024; + else if ((sr10 & 0xc0) == 0x40) + pScrn->videoRam = 2048; + else + pScrn->videoRam = 4096; + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected %d bytes video ram\n", + pScrn->videoRam); + + /* try to detect the RAMDAC */ + { + int man_id, dev_id; + + inb(0x3c6); /* skip command register */ + man_id = inb(0x3c6); /* manufacturer id */ + dev_id = inb(0x3c6); /* device id */ + if (man_id == 0x84 && dev_id == 0x98) { + pARK->ramdac = ZOOMDAC; + pARK->dac_width = 16; + pARK->multiplex_threshold = 40000; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Detected ZOOMDAC\n"); + } + } + + /* hack for this Bali32 */ + pARK->ramdac = ATT490; + pARK->dac_width = 8; + + pARK->clock_mult = 1; + if (pARK->dac_width == 16) { + if (pScrn->bitsPerPixel == 32) + pARK->clock_mult = 2; + } + + pScrn->numClocks = 1; + pScrn->clock[0] = 80000; /* safe */ + + clockRanges = xnfcalloc(sizeof(ClockRange), 1); + clockRanges->next = NULL; + clockRanges->minClock = 20000; + clockRanges->maxClock = 80000; + clockRanges->clockIndex = -1; + clockRanges->interlaceAllowed = FALSE; /* ? */ + clockRanges->doubleScanAllowed = FALSE; /* ? */ + + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, + NULL, 256, 2048, pScrn->bitsPerPixel, + 128, 2048, pScrn->virtualX, + pScrn->display->virtualY, pARK->videoRam * 1024, + LOOKUP_BEST_REFRESH); + if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "no valid modes left\n"); + ARKFreeRec(pScrn); + return FALSE; + } + + xf86PruneDriverModes(pScrn); + + if (i == 0 || pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "no valid modes found\n"); + ARKFreeRec(pScrn); + return FALSE; + } + + xf86SetCrtcForModes(pScrn, 0); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + xf86SetDpi(pScrn, 0, 0); + + xf86LoadSubModule(pScrn, "fb"); + xf86LoaderReqSymbols("fbScreenInit", NULL); + + if (!pARK->NoAccel) { + xf86LoadSubModule(pScrn, "xaa"); + xf86LoaderReqSymLists(xaaSymbols, NULL); + } + + return TRUE; +} +} + +static Bool ARKScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ARKPtr pARK = ARKPTR(pScrn); + BoxRec MemBox; + int i; + + pScrn->fbOffset = 0; + + if (!ARKMapMem(pScrn)) { + ARKFreeRec(pScrn); + return FALSE; + } + + ARKSave(pScrn); + +/* vgaHWBlankScreen(pScrn, TRUE); */ + + if (!ARKModeInit(pScrn, pScrn->currentMode)) + return FALSE; + + ARKSaveScreen(pScreen, SCREEN_SAVER_ON); + + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + miClearVisualTypes(); + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } else { + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } + + if (!fbScreenInit(pScreen, pARK->FBBase, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return FALSE; + + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr pVis; + + pVis = pScreen->visuals + pScreen->numVisuals; + while (--pVis >= pScreen->visuals) { + if ((pVis->class | DynamicClass) == DirectColor) { + pVis->offsetRed = pScrn->offset.red; + pVis->offsetGreen = pScrn->offset.green; + pVis->offsetBlue = pScrn->offset.blue; + pVis->redMask = pScrn->mask.red; + pVis->greenMask = pScrn->mask.green; + pVis->blueMask = pScrn->mask.blue; + } + } + } + + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + if (!pARK->NoAccel) { + if (ARKAccelInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Acceleration initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + } + + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + if (!miCreateDefColormap(pScreen)) + return FALSE; + + if (!xf86HandleColormaps(pScreen, 256, 8, ARKLoadPalette, NULL, + CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; + +/* vgaHWBlankScreen(pScrn, TRUE); */ + + pScreen->SaveScreen = ARKSaveScreen; + pARK->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = ARKCloseScreen; + + return TRUE; +} + + + +static void ARKSave(ScrnInfoPtr pScrn) +{ + ARKPtr pARK = ARKPTR(pScrn); + ARKRegPtr save = &pARK->SavedRegs; + vgaHWPtr hwp = VGAHWPTR(pScrn); + int vgaIOBase = hwp->IOBase; + + vgaHWUnlock(hwp); + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); + vgaHWLock(hwp); + + /* set read and write aperture index to 0 */ + wrinx(0x3c4, 0x15, 0x00); + wrinx(0x3c4, 0x16, 0x00); + outb(0x3c8, 0); /* reset DAC register access mode */ + + save->sr10 = rdinx(0x3c4, 0x10); + save->sr11 = rdinx(0x3c4, 0x11); + save->sr12 = rdinx(0x3c4, 0x12); + save->sr13 = rdinx(0x3c4, 0x13); + save->sr14 = rdinx(0x3c4, 0x14); + save->sr15 = rdinx(0x3c4, 0x15); + save->sr16 = rdinx(0x3c4, 0x16); + save->sr17 = rdinx(0x3c4, 0x17); + save->sr18 = rdinx(0x3c4, 0x18); + +#if 0 + save->sr1d = rdinx(0x3c4, 0x1d); + save->sr1c = rdinx(0x3c4, 0x1c); + + save->sr20 = rdinx(0x3c4, 0x20); + save->sr21 = rdinx(0x3c4, 0x21); + save->sr22 = rdinx(0x3c4, 0x22); + save->sr23 = rdinx(0x3c4, 0x23); + save->sr24 = rdinx(0x3c4, 0x24); + save->sr25 = rdinx(0x3c4, 0x25); + save->sr26 = rdinx(0x3c4, 0x26); + save->sr27 = rdinx(0x3c4, 0x27); + save->sr29 = rdinx(0x3c4, 0x29); + save->sr2a = rdinx(0x3c4, 0x2a); + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) { + save->sr28 = rdinx(0x3c4, 0x28); + save->sr2b = rdinx(0x3c4, 0x2b); + } +#endif + + save->cr40 = rdinx(vgaIOBase + 4, 0x40); + save->cr41 = rdinx(vgaIOBase + 4, 0x41); + save->cr42 = rdinx(vgaIOBase + 4, 0x42); + save->cr44 = rdinx(vgaIOBase + 4, 0x44); + + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) + save->cr46 = rdinx(vgaIOBase + 4, 0x46); + + /* save RAMDAC regs here, based on type */ + save->dac_command = get_daccomm(); +} + + + +static Bool ARKModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + ARKPtr pARK = ARKPTR(pScrn); + ARKRegPtr new = &pARK->ModeRegs; + int multiplexing, dac16, modepitch; + vgaHWPtr hwp = VGAHWPTR(pScrn); + vgaRegPtr pVga = &hwp->ModeReg; + int vgaIOBase = hwp->IOBase; + unsigned char tmp; + int offset; + + multiplexing = 0; + + if ((pScrn->bitsPerPixel == 8) && (pARK->dac_width == 16) && + (mode->Clock > pARK->multiplex_threshold)) + multiplexing = 1; + + if (pARK->clock_mult == 2) { + if (!mode->CrtcHAdjusted) { + mode->CrtcHDisplay <<= 1; + mode->CrtcHSyncStart <<= 1; + mode->CrtcHSyncEnd <<= 1; + mode->CrtcHTotal <<= 1; + mode->CrtcHSkew <<= 1; + mode->CrtcHAdjusted = TRUE; + } + } + + if (multiplexing) { + if (!mode->CrtcHAdjusted) { + mode->CrtcHDisplay >>= 1; + mode->CrtcHSyncStart >>= 1; + mode->CrtcHSyncEnd >>= 1; + mode->CrtcHTotal >>= 1; + mode->CrtcHSkew >>= 1; + mode->CrtcHAdjusted = TRUE; + } + } + + if (!vgaHWInit(pScrn, mode)) + return FALSE; + + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) { + new->cr46 = rdinx(vgaIOBase + 4, 0x46) & ~0x04; + dac16 = 0; + if (pScrn->bitsPerPixel > 8) + dac16 = 1; + if (dac16) + new->cr46 |= 0x04; + } + + offset = (pScrn->displayWidth * (pScrn->bitsPerPixel / 8)) >> 3; + pVga->CRTC[0x13] = offset; + pVga->Attribute[0x11] = 0x00; + new->cr41 = (offset & 0x100) >> 5; + + pVga->MiscOutReg |= 0x0c; + + new->sr11 = rdinx(0x3c4, 0x11) & ~0x0f; + switch (pScrn->bitsPerPixel) { + case 8: + new->sr11 |= 0x06; + break; + case 16: + new->sr11 |= 0x0a; + break; + case 24: + new->sr11 |= 0x06; + break; + case 32: + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) + new->sr11 |= 0x0e; + else + new->sr11 |= 0x0a; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported screen depth %d\n", + pScrn->bitsPerPixel); + return FALSE; + } + + switch (pScrn->displayWidth) { + case 640: + modepitch = 0; + break; + case 800: + modepitch = 1; + break; + case 1024: + modepitch = 2; + break; + case 1280: + modepitch = 4; + break; + case 1600: + modepitch = 5; + break; + case 2048: + modepitch = 6; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported screen width %d\n", + pScrn->displayWidth); + return FALSE; + } + + new->sr17 &= ~0xc7; + new->sr17 |= modepitch; + + new->sr10 = rdinx(0x3c4, 0x10) & ~0x1f; + new->sr10 |= 0x1f; + + new->sr13 = pARK->FBAddress >> 16; + new->sr14 = pARK->FBAddress >> 24; + + new->sr12 = rdinx(0x3c4, 0x12) & ~0x03; + switch (pScrn->videoRam) { + case 1024: + new->sr12 |= 0x01; + break; + case 2048: + new->sr12 |= 0x02; + break; + case 4096: + new->sr12 |= 0x03; + break; + default: + new->sr12 |= 0x01; + break; + } + + new->sr15 = new->sr16 = 0; + + tmp = 0; + if ((mode->CrtcVTotal - 2) & 0x400) + tmp |= 0x80; + if ((mode->CrtcVDisplay - 1) & 0x400) + tmp |= 0x40; + if (mode->CrtcVSyncStart & 0x400) + tmp |= 0x10; + new->cr40 = tmp; + + tmp = new->cr41; /* initialized earlier */ + if ((mode->CrtcHTotal / 8 - 5) & 0x100) + tmp |= 0x80; + if ((mode->CrtcHDisplay / 8 - 1) & 0x100) + tmp |= 0x40; + if ((mode->CrtcHSyncStart / 8 - 1) & 0x100) + tmp |= 0x20; + if ((mode->CrtcHSyncStart / 8) & 0x100) + tmp |= 0x10; + new->cr41 |= tmp; + + new->cr44 = rdinx(vgaIOBase + 4, 0x44) & ~0x34; + new->cr44 &= ~0x01; + new->cr42 = 0; + + /* check interlace here later */ + + /* set display FIFO threshold */ + { + int threshold; + unsigned char tmp; + int bandwidthused, percentused; + + /* mostly guesses here as I would need to know more about + * and from the ramdac... + */ + bandwidthused = (mode->Clock / pARK->clock_mult) * + (pScrn->bitsPerPixel / 8); + /* 120000 is another guess */ + percentused = (bandwidthused * 100) / 120000; + tmp = rdinx(0x3c4, 0x18); + if (pARK->Chipset == PCI_CHIP_1000PV) { + threshold = 4; + tmp |= 0x08; /* enable full FIFO (8 deep) */ + tmp &= ~0x07; + tmp |= threshold; + } + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) { + threshold = 12; + if (percentused >= 45) + threshold = 8; + if (percentused >= 70) + threshold = 4; + tmp &= 0x40; + tmp |= 0x10; + tmp |= (threshold & 0x0e) >> 1; + if (threshold & 0x01) + tmp |= 0x80; + if (threshold & 0x10) + tmp |= 0x20; + } + new->sr18 = tmp; + } + + /* setup the RAMDAC regs */ + if (pARK->ramdac == ZOOMDAC) { + new->dac_command = 0x04; + if ((pScrn->bitsPerPixel == 8) && multiplexing) + new->dac_command = 0x24; + if ((pScrn->bitsPerPixel == 16) && (pARK->dac_width == 16)) + /* assuming green weight is not 5 */ + new->dac_command = 0x34; + if ((pScrn->bitsPerPixel == 16) && (pARK->dac_width == 8)) + new->dac_command = 0x64; + if ((pScrn->bitsPerPixel == 24) && (pARK->dac_width == 16)) + new->dac_command = 0xb4; /* packed */ + if ((pScrn->bitsPerPixel == 32) && (pARK->dac_width == 16)) + new->dac_command = 0x54; + } else if (pARK->ramdac == ATT490) { + new->dac_command = 0x00; + if (pScrn->bitsPerPixel == 16) + /* assuming green weight is 6 */ + new->dac_command = 0xc0; + if (pScrn->bitsPerPixel == 24) + new->dac_command = 0xe0; + } + + /* hrmm... */ + new->dac_command |= 0x02; + +#if 0 + /* hw cursor regs */ + new->sr20 = rdinx(0x3c4, 0x20); + new->sr21 = rdinx(0x3c4, 0x21); + new->sr22 = rdinx(0x3c4, 0x22); + new->sr23 = rdinx(0x3c4, 0x23); + new->sr24 = rdinx(0x3c4, 0x24); + new->sr25 = rdinx(0x3c4, 0x25); + new->sr26 = rdinx(0x3c4, 0x26); + new->sr27 = rdinx(0x3c4, 0x27); + new->sr29 = rdinx(0x3c4, 0x29); + new->sr2a = rdinx(0x3c4, 0x2a); + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) { + new->sr28 = rdinx(0x3c4, 0x28); + new->sr2b = rdinx(0x3c4, 0x3b); + } +#endif + + + ARKWriteMode(pScrn, pVga, new); + + return TRUE; +} + + +static void ARKAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ARKPtr pARK = ARKPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + int vgaIOBase = hwp->IOBase; + int base; + + base = ((y * pScrn->displayWidth + x) * + (pScrn->bitsPerPixel / 8)); + + if (((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) && + (pScrn->videoRam >= 2048)) + base >>= 3; + else + base >>= 2; + if (pScrn->bitsPerPixel == 24) + base -= base % 3; + + outw(vgaIOBase + 4, (base & 0x00ff00) | 0x0c); + outw(vgaIOBase + 4, ((base & 0x00ff) << 8) | 0x0d); + + modinx(vgaIOBase + 4, 0x40, 0x07, (base & 0x070000) >> 16); +} + + + +static void ARKWriteMode(ScrnInfoPtr pScrn, vgaRegPtr pVga, ARKRegPtr new) +{ + ARKPtr pARK = ARKPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + int vgaIOBase = hwp->IOBase; + + vgaHWProtect(pScrn, TRUE); + + /* set read and write aperture index to 0 */ + wrinx(0x3c4, 0x15, 0x00); + wrinx(0x3c4, 0x16, 0x00); + + /* write the extended registers first so that textmode font + * restoration can suceed + */ + wrinx(0x3c4, 0x10, new->sr10); + modinx(0x3c4, 0x11, 0x3f, new->sr11); + wrinx(0x3c4, 0x12, new->sr12); + wrinx(0x3c4, 0x13, new->sr13); + wrinx(0x3c4, 0x14, new->sr14); + wrinx(0x3c4, 0x15, new->sr15); + wrinx(0x3c4, 0x16, new->sr16); + wrinx(0x3c4, 0x17, new->sr17); + +#if 0 + wrinx(0x3c4, 0x1c, new->sr1c); + wrinx(0x3c4, 0x1d, new->sr1d); + + /* hw cursor regs */ + wrinx(0x3c4, 0x20, new->sr20); + wrinx(0x3c4, 0x21, new->sr21); + wrinx(0x3c4, 0x22, new->sr22); + wrinx(0x3c4, 0x23, new->sr23); + wrinx(0x3c4, 0x24, new->sr24); + wrinx(0x3c4, 0x25, new->sr25); + wrinx(0x3c4, 0x26, new->sr26); + wrinx(0x3c4, 0x27, new->sr27); + wrinx(0x3c4, 0x29, new->sr29); + wrinx(0x3c4, 0x2a, new->sr2a); +#endif + + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) { + wrinx(0x3c4, 0x28, new->sr28); + wrinx(0x3c4, 0x2B, new->sr2b); + } + + wrinx(vgaIOBase + 4, 0x40, new->cr40); + wrinx(vgaIOBase + 4, 0x41, new->cr41); + wrinx(vgaIOBase + 4, 0x42, new->cr42); + wrinx(vgaIOBase + 4, 0x44, new->cr44); + + if ((pARK->Chipset == PCI_CHIP_2000PV) || + (pARK->Chipset == PCI_CHIP_2000MT)) + wrinx(vgaIOBase + 4, 0x46, new->cr46); + + /* RAMDAC regs */ + if (pARK->ramdac == ZOOMDAC) { + set_daccom(new->dac_command); + } + + if (xf86IsPrimaryPci(pARK->PciInfo)) + vgaHWRestore(pScrn, pVga, VGA_SR_ALL); + else + vgaHWRestore(pScrn, pVga, VGA_SR_MODE); + + inb(0x3c8); + outb(0x3c6, 0xff); + + vgaHWProtect(pScrn, FALSE); + +} + + +static Bool ARKEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + if (!ARKModeInit(pScrn, pScrn->currentMode)) + return FALSE; + + ARKAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + + + +static void ARKLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ARKPtr pARK = ARKPTR(pScrn); + ARKRegPtr old = &pARK->SavedRegs; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + ARKWriteMode(pScrn, &hwp->ModeReg, old); + + vgaHWUnlock(hwp); + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS); + vgaHWLock(hwp); + + return; +} + + +static Bool ARKMapMem(ScrnInfoPtr pScrn) +{ + ARKPtr pARK = ARKPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + /* extended to cover MMIO space at 0xB8000 */ + hwp->MapSize = 0x20000; + + pARK->MMIOBase = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, + 0xb8000, 0x8000); + + pARK->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, + pARK->PciTag, pARK->FBAddress, + pScrn->videoRam * 1024); + if (!pARK->FBBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cound not map framebuffer\n"); + return FALSE; + } + + return TRUE; +} + + +static void ARKUnmapMem(ScrnInfoPtr pScrn) +{ + ARKPtr pARK = ARKPTR(pScrn); + + vgaHWUnmapMem(pScrn); + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pARK->FBBase, + pScrn->videoRam * 1024); + + return; +} + + +Bool ARKCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ARKPtr pARK = ARKPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + if (pScrn->vtSema) { + vgaHWUnlock(hwp); + ARKWriteMode(pScrn, &hwp->SavedReg, &pARK->SavedRegs); + vgaHWLock(hwp); + ARKUnmapMem(pScrn); + } + + pScrn->vtSema = FALSE; + pScreen->CloseScreen = pARK->CloseScreen; + + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + + +Bool ARKSaveScreen(ScreenPtr pScreen, int mode) +{ + return vgaHWSaveScreen(pScreen, mode); +} + + +Bool ARKSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return ARKModeInit(xf86Screens[scrnIndex], mode); +} + + +static void ARKLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indicies, LOCO *colors, + VisualPtr pVisual) +{ + int i, index; + + for (i=0; i<numColors; i++) { + index = indicies[i]; + outb(0x3c8, index); + outb(0x3c9, colors[index].red); + outb(0x3c9, colors[index].green); + outb(0x3c9, colors[index].blue); + } +} + + +static void ARKFreeScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + vgaHWFreeHWRec(pScrn); + + ARKFreeRec(pScrn); +} + + +static unsigned char get_daccomm() +{ + unsigned char tmp; + + outb(0x3c8, 0); + inb(0x3c6); + inb(0x3c6); + inb(0x3c6); + inb(0x3c6); + tmp = inb(0x3c6); + outb(0x3c8, 0); + + return tmp; +} + + +static unsigned char set_daccom(unsigned char comm) +{ +#if 0 + outb(0x3c8, 0); +#else + inb(0x3c8); +#endif + inb(0x3c6); + inb(0x3c6); + inb(0x3c6); + inb(0x3c6); + outb(0x3c6, comm); +#if 0 + outb(0x3c8, 0); +#else + inb(0x3c8); +#endif + + return inb(0x3c6); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_reg.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ark/ark_reg.h:1.1 --- /dev/null Mon Dec 18 14:29:54 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ark/ark_reg.h Tue Nov 14 12:28:13 2000 @@ -0,0 +1,88 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ark/ark_reg.h,v 1.1 2000/11/14 17:28:13 dawes Exp $ */ + +#ifndef _ARK_REG_H +#define _ARK_REG_H + +/* and let there be no 'u' in color */ +#define BG_COLOR 0x00 +#define FG_COLOR 0x02 +#define BG_COLOR_HI 0x04 +#define FG_COLOR_HI 0x06 +#define TRANS_COLOR 0x08 +#define TRANS_COLOR_MSK 0x0a +#define TRANS_COLOR_HI 0x0c +#define TRANS_COLOR_MSK_HI 0x0e +#define COLOR_MIX_SEL 0x18 +#define WRITE_PLANEMASK 0x1a +#define ERROR_TERM 0x50 +#define AXIAL_ERROR_INC 0x54 +#define STENCIL_PITCH 0x60 +#define SRC_PITCH 0x62 +#define DST_PITCH 0x64 +#define STENCIL_ADDR 0x68 +#define STENCIL_X 0x68 +#define STENCIL_Y 0x6a +#define SRC_ADDR 0x6c +#define SRC_X 0x6c +#define SRC_Y 0x6e +#define DST_ADDR 0x70 +#define DST_X 0x70 +#define DST_Y 0x72 +#define WIDTH 0x74 +#define HEIGHT 0x76 +#define BITMAP_CONFIG 0x7c +#define COMMAND 0x7e + + +/* constants for COMMAND register */ + +#define DRAWSTEP 0x0000 +#define LINEDRAW 0x1000 +#define BITBLT 0x2000 +#define TEXTBITBLT 0x3000 +#define USE_PLANEMASK 0x0000 +#define DISABLE_PLANEMASK 0x0800 +#define PATTERN_8X8 0x0400 +#define SELECT_BG_COLOR 0x0000 +#define BG_BITMAP 0x0200 +#define SELECT_FG_COLOR 0x0000 +#define FG_BITMAP 0x0100 +#define STENCIL_ONES 0x0000 +#define STENCIL_GENERATED 0x0040 +#define STENCIL_BITMAP 0x0080 +#define LINE_DRAWALL 0x0000 +#define LINE_SKIP_FIRST 0x0010 +#define LINE_SKIP_LAST 0x0020 +#define ENABLE_CLIPPING 0x0000 +#define DISABLE_CLIPPING 0x0008 +#undef DOWN +#define DOWN 0x0000 +#undef UP +#define UP 0x0002 +#define RIGHT 0x0000 +#define LEFT 0x0004 +#define DX_GREATER_THAN_DY 0x0000 +#define DY_GREATER_THAN_DX 0x0001 + + +/* constants for bitmap config register */ + +#define SWAP_NIBLES 0x2000 +#define SWAP_BITS 0x1000 +#define SYSTEM_STENCIL 0x0200 +#define LINEAR_STENCIL_ADDR 0x0100 +#define SYSTEM_SRC 0x0020 +#define LINEAR_SRC_ADDR 0x0010 +#define SYSTEM_DST 0x0002 +#define LINEAR_DST_ADDR 0x0001 + + +/* IO macros */ + +#define OUTREG16(offset, value) \ + *(unsigned short *)(pARK->MMIOBase + offset) = value +#define OUTREG(offset, value) \ + *(unsigned int *)(pARK->MMIOBase + offset) = value + + +#endif /* _ARK_REG_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile:1.15 xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile:1.25 --- xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile:1.15 Mon Jun 19 11:00:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile Thu Nov 2 11:55:26 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.15 2000/06/19 15:00:55 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.25 2000/11/02 16:55:26 tsi Exp $ XCOMM XCOMM Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca XCOMM @@ -29,33 +29,118 @@ #endif #if DoLoadableServer -ATIMODSRC = atimodule.c -ATIMODOBJ = atimodule.o + +MODSRCS1 = atimodule.c +MODSRCS2 = atiload.c atimisc.c +MODSRCS3 = r128_misc.c +MODSRCS4 = radeon_misc.c + +MODOBJS1 = atimodule.o +MODOBJS2 = atiload.o atimisc.o +MODOBJS3 = r128_misc.o +MODOBJS4 = radeon_misc.o + +#endif + +#if BuildXF86DRI + +DRISRCS3 = r128_dri.c + +DRIOBJS3 = r128_dri.o + +DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include +DRIDEFINES = $(GLX_DEFINES) + +#endif + +/* + * The following configuration logic is only meant as a first cut, and is + * therefore incomplete. ...And, no, you do NOT have permission to move this + * into xfree86.cf... + * + * Currently, ATIAvoidCPIO >MUST< be #define'd as YES for those platforms + * (architecture/OS combinations) that neither provide nor emulate a + * little-endian undirected PIO address space of at least 64 kB in size. + * + * "Undirected" means the driver does not need to determine the identity nor + * location of the responding adapter before accessing a particular location in + * the PIO address space. + * + * #define'ing ATIAvoidCPIO to YES generates a driver that will only support + * PCI/AGP Mach64 adapters using a linear aperture and the accelerator CRTC. + * The resulting driver will also require the same of the environment on server + * entry. + * + * For testing purposes, #define'ing ATIAvoidCPIO as YES is also supported on + * platforms that do, in fact, provide or emulate a PIO address space as + * described above, but this should not be the default driver configuration. + */ +#if defined(i386Architecture) || \ + defined(ia64Architecture) || \ + defined(AlphaArchitecture) +# ifndef ATIAvoidCPIO +# define ATIAvoidCPIO NO +# endif +#elif defined(SparcArchitecture) || 1 +# undef ATIAvoidCPIO /* Clobber any previous setting */ +# define ATIAvoidCPIO YES +#endif + +#if !ATIAvoidCPIO + +CPIOSRCS1 = atibios.c ativgaio.c +CPIOSRCS2 = atibank.c ativga.c atiwonder.c atiwonderio.c + +CPIOOBJS1 = atibios.o ativgaio.o +CPIOOBJS2 = atibank.o ativga.o atiwonder.o atiwonderio.o + +#else + +CPIODEFINES = -DAVOID_CPIO + #endif + +DEFINES = $(CPIODEFINES) $(DRIDEFINES) + +SRCS1 = ati.c atiadapter.c atibus.c atichip.c atiident.c atioption.c \ + atiprobe.c atividmem.c $(MODSRCS1) $(CPIOSRCS1) \ + radeon_probe.c r128_probe.c +SRCS2 = atiadjust.c aticlock.c aticonfig.c aticonsole.c atidac.c atidga.c \ + atidsp.c atilock.c atimach64.c atimach64io.c atimode.c atipreinit.c \ + atiprint.c atiscreen.c atiutil.c ativalid.c $(MODSRCS2) $(CPIOSRCS2) +SRCS3 = r128_accel.c r128_cursor.c r128_dga.c r128_driver.c r128_video.c \ + $(MODSRCS3) $(DRISRCS3) +SRCS4 = radeon_accel.c radeon_cursor.c radeon_dga.c radeon_driver.c \ + radeon_video.c $(MODSRCS4) + +OBJS1 = ati.o atiadapter.o atibus.o atichip.o atiident.o atioption.o \ + atiprobe.o atividmem.o $(MODOBJS1) $(CPIOOBJS1) \ + radeon_probe.o r128_probe.o +OBJS2 = atiadjust.o aticlock.o aticonfig.o aticonsole.o atidac.o atidga.o \ + atidsp.o atilock.o atimach64.o atimach64io.o atimode.o atipreinit.o \ + atiprint.o atiscreen.o atiutil.o ativalid.o $(MODOBJS2) $(CPIOOBJS2) +OBJS3 = r128_accel.o r128_cursor.o r128_dga.o r128_driver.o r128_video.o \ + $(MODOBJS3) $(DRIOBJS3) +OBJS4 = radeon_accel.o radeon_cursor.o radeon_dga.o radeon_driver.o \ + radeon_video.o $(MODOBJS4) -SRCS = ati.c atiadapter.c atiadjust.c atibank.c atibios.c atibus.c atichip.c \ - aticlock.c aticonsole.c atidac.c atidga.c atidsp.c atiident.c atiio.c \ - atilock.c atimach64.c $(ATIMODSRC) atioption.c atipreinit.c atiprint.c \ - atiprobe.c atiscreen.c atiutil.c ativalid.c ativga.c atividmem.c \ - atiwonder.c - -OBJS = ati.o atiadapter.o atiadjust.o atibank.o atibios.o atibus.o atichip.o \ - aticlock.o aticonsole.o atidac.o atidga.o atidsp.o atiident.o atiio.o \ - atilock.o atimach64.o $(ATIMODOBJ) atioption.o atipreinit.o atiprint.o \ - atiprobe.o atiscreen.o atiutil.o ativalid.o ativga.o atividmem.o \ - atiwonder.o +SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) +OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC) \ -I$(XF86OSSRC)/vbe -I$(XF86SRC)/int10 \ - -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86SRC)/rac \ - -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa \ + -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/rac -I$(XF86SRC)/ramdac \ + -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa -I$(XF86SRC)/xf24_32bpp \ -I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \ - -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \ - -I$(SERVERSRC)/Xext -I$(XINCLUDESRC) -I$(FONTINCSRC) + -I$(SERVERSRC)/fb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/render -I$(SERVERSRC)/Xext -I$(SERVERSRC)/include \ + $(DRIINCLUDES) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(XINCLUDESRC) #endif #if MakeHasPosixVariableSubstitutions @@ -64,19 +149,29 @@ ModuleObjectRule() -ObjectModuleTarget(ati,$(OBJS)) +ObjectModuleTarget(ati,$(OBJS1)) +ObjectModuleTarget(atimisc,$(OBJS2)) +ObjectModuleTarget(r128,$(OBJS3)) +ObjectModuleTarget(radeon,$(OBJS4)) InstallObjectModule(ati,$(MODULEDIR),drivers) +InstallObjectModule(atimisc,$(MODULEDIR),drivers) +InstallObjectModule(r128,$(MODULEDIR),drivers) +InstallObjectModule(radeon,$(MODULEDIR),drivers) -#if !defined(XF86DriverSDK) +#if 0 CppManTarget(ati,) InstallModuleManPage(ati) #endif +CppManTarget(r128,) +InstallModuleManPage(r128) + DependTarget() InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ati.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(ati.cpp,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ati.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiadapter.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiadapter.h,$(DRIVERSDKDIR)/drivers/ati) @@ -92,6 +187,8 @@ InstallDriverSDKNonExecFile(atichip.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(aticlock.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(aticlock.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(aticonfig.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(aticonfig.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(aticonsole.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(aticonsole.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(aticrtc.h,$(DRIVERSDKDIR)/drivers/ati) @@ -103,12 +200,18 @@ InstallDriverSDKNonExecFile(atidsp.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiident.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiident.h,$(DRIVERSDKDIR)/drivers/ati) -InstallDriverSDKNonExecFile(atiio.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiio.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atiload.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atiload.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atilock.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atilock.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimach64io.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimach64io.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimisc.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimode.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimode.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimodule.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimodule.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimono.h,$(DRIVERSDKDIR)/drivers/ati) @@ -133,9 +236,66 @@ InstallDriverSDKNonExecFile(ativersion.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ativga.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(ativga.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(ativgaio.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(ativgaio.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atividmem.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atividmem.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiwonder.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atiwonder.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atiwonderio.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atiwonderio.h,$(DRIVERSDKDIR)/drivers/ati) + +InstallDriverSDKNonExecFile(r128.cpp,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_accel.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_cursor.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dga.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dri.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dri.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_dripriv.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_driver.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_misc.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_probe.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_probe.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_reg.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_sarea.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_version.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(r128_video.c,$(DRIVERSDKDIR)/drivers/ati) + +InstallDriverSDKNonExecFile(radeon.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_accel.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_cursor.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_dga.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_driver.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_misc.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_probe.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_probe.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_reg.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_version.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(radeon_video.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKObjectModule(ati,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(atimisc,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(r128,$(DRIVERSDKMODULEDIR),drivers) +InstallDriverSDKObjectModule(radeon,$(DRIVERSDKMODULEDIR),drivers) + +/* Remove instances of ati2 module */ +#if DoLoadableServer + +#undef ATI2DriverModuleName +#if MakeDllModules +# define ATI2DriverModuleName ati2_drv.so +#else +# define ATI2DriverModuleName ati2_drv.o +#endif + +all:: + RemoveFile($(BUILDMODULEDIR)/drivers/ATI2DriverModuleName) + +install:: + RemoveFile($(DESTDIR)$(MODULEDIR)/drivers/ATI2DriverModuleName) + +install.sdk:: + RemoveFile($(DESTDIR)$(DRIVERSDKMODULEDIR)/drivers/ATI2DriverModuleName) + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c:1.12 xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c:1.12 Thu May 11 14:14:29 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c Sat Dec 2 10:53:52 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.12 2000/05/11 18:14:29 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.14 2000/12/02 15:53:52 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -60,6 +60,12 @@ * Mark Vojkovich, mvojkovich@valinux.com * Huw D M Davies, h.davies1@physics.ox.ac.uk * Andrew C Aitchison, A.C.Aitchison@dpmms.cam.ac.uk + * Ani Joshi, ajoshi@shell.unixbox.com + * Kostas Gewrgiou, gewrgiou@imbc.gr + * Jakub Jelinek, jakub@redhat.com + * David S. Miller, davem@redhat.com + * A E Lawrence, adrian.lawrence@computing-services.oxford.ac.uk + * Linus Torvalds, torvalds@transmeta.com * * ... and, many, many others from around the world. * Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp:1.5 Mon Jun 19 11:00:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp Mon Dec 11 15:18:06 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp,v 1.5 2000/06/19 15:00:55 tsi Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp,v 1.6 2000/12/11 20:18:06 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH ATI __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH ATI __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME ati \- ATI video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h:1.5 Fri Feb 18 07:19:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h Fri Aug 4 17:07:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h,v 1.5 2000/02/18 12:19:11 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h,v 1.6 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -31,8 +31,6 @@ #include "xf86_ansic.h" #include "xf86_OSproc.h" - -#define ATI_README "\n See README.ati for details.\n" extern DriverRec ATI; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c:1.12 xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c:1.12 Mon Jun 19 11:00:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c Wed Oct 11 18:52:53 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.12 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.14 2000/10/11 22:52:53 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,16 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "ati.h" #include "atiadapter.h" -#include "atichip.h" -#include "atidac.h" -#include "atidsp.h" -#include "atiio.h" -#include "atimach64.h" -#include "atiprint.h" -#include "ativga.h" -#include "atiwonder.h" /* * Adapter-related definitions. @@ -38,6 +29,9 @@ const char *ATIAdapterNames[] = { "Unknown", + +#ifndef AVOID_CPIO + "ATI EGA Wonder800", "ATI EGA Wonder800+", "IBM VGA or compatible", @@ -51,1054 +45,10 @@ "IBM 8514/A or compatible", "ATI Mach8", "ATI Mach32", - "ATI Mach64", - "ATI Rage128" -}; - -/* - * ATICopyVGAMemory -- - * - * This function is called to copy one or all banks of a VGA plane. - */ -static void -ATICopyVGAMemory -( - ATIPtr pATI, - ATIHWPtr pATIHW, - pointer *saveptr, - pointer *from, - pointer *to -) -{ - unsigned int iBank; - - for (iBank = 0; iBank < pATIHW->nBank; iBank++) - { - (*pATIHW->SetBank)(pATI, iBank); - (void)memcpy(*to, *from, 0x00010000U); - *saveptr = (char *)(*saveptr) + 0x00010000U; - } -} - -/* - * ATISwap -- - * - * This function saves/restores video memory contents during video mode - * switches. - */ -static void -ATISwap -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW, - Bool ToFB -) -{ - pointer save, *from, *to; - unsigned int iPlane = 0, PlaneMask = 1; - CARD8 seq2, seq4, gra1, gra3, gra4, gra5, gra6, gra8; - - /* - * This is only done for non-accelerator modes. If the video state on - * server entry was an accelerator mode, the application that relinquished - * the console had better do the Right Thing (tm) anyway by saving and - * restoring its own video memory contents. - */ - if (pATIHW->crtc != ATI_CRTC_VGA) - return; - - if (ToFB) - { - if (!pATIHW->frame_buffer) - return; - - from = &save; - to = &pATI->pBank; - } - else - { - /* Allocate the memory */ - if (!pATIHW->frame_buffer) - { - pATIHW->frame_buffer = - (pointer)xalloc(pATIHW->nBank * pATIHW->nPlane * 0x00010000U); - if (!pATIHW->frame_buffer) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Temporary frame buffer could not be allocated.\n"); - return; - } - } - - from = &pATI->pBank; - to = &save; - } - - /* Turn off screen */ - ATIVGASaveScreen(pATI, SCREEN_SAVER_ON); - - /* Save register values to be modified */ - seq2 = GetReg(SEQX, 0x02U); - seq4 = GetReg(SEQX, 0x04U); - gra1 = GetReg(GRAX, 0x01U); - gra3 = GetReg(GRAX, 0x03U); - gra4 = GetReg(GRAX, 0x04U); - gra5 = GetReg(GRAX, 0x05U); - gra6 = GetReg(GRAX, 0x06U); - gra8 = GetReg(GRAX, 0x08U); - - save = pATIHW->frame_buffer; - - /* Temporarily normalise the mode */ - if (gra1 != 0x00U) - PutReg(GRAX, 0x01U, 0x00U); - if (gra3 != 0x00U) - PutReg(GRAX, 0x03U, 0x00U); - if (gra6 != 0x05U) - PutReg(GRAX, 0x06U, 0x05U); - if (gra8 != 0xFFU) - PutReg(GRAX, 0x08U, 0xFFU); - - if (seq4 & 0x08U) - { - /* Setup packed mode memory */ - if (seq2 != 0x0FU) - PutReg(SEQX, 0x02U, 0x0FU); - if (seq4 != 0x0AU) - PutReg(SEQX, 0x04U, 0x0AU); - if (pATI->Chip < ATI_CHIP_264CT) - { - if (gra5 != 0x00U) - PutReg(GRAX, 0x05U, 0x00U); - } - else - { - if (gra5 != 0x40U) - PutReg(GRAX, 0x05U, 0x40U); - } - - ATICopyVGAMemory(pATI, pATIHW, &save, from, to); - - if (seq2 != 0x0FU) - PutReg(SEQX, 0x02U, seq2); - if (seq4 != 0x0AU) - PutReg(SEQX, 0x04U, seq4); - if (pATI->Chip < ATI_CHIP_264CT) - { - if (gra5 != 0x00U) - PutReg(GRAX, 0x05U, gra5); - } - else - { - if (gra5 != 0x40U) - PutReg(GRAX, 0x05U, gra5); - } - } - else - { - gra4 = GetReg(GRAX, 0x04U); - - /* Setup planar mode memory */ - if (seq4 != 0x06U) - PutReg(SEQX, 0x04U, 0x06U); - if (gra5 != 0x00U) - PutReg(GRAX, 0x05U, 0x00U); - - for (; iPlane < pATIHW->nPlane; iPlane++) - { - PutReg(SEQX, 0x02U, PlaneMask); - PutReg(GRAX, 0x04U, iPlane); - ATICopyVGAMemory(pATI, pATIHW, &save, from, to); - PlaneMask <<= 1; - } - - PutReg(SEQX, 0x02U, seq2); - if (seq4 != 0x06U) - PutReg(SEQX, 0x04U, seq4); - PutReg(GRAX, 0x04U, gra4); - if (gra5 != 0x00U) - PutReg(GRAX, 0x05U, gra5); - } - - /* Restore registers */ - if (gra1 != 0x00U) - PutReg(GRAX, 0x01U, gra1); - if (gra3 != 0x00U) - PutReg(GRAX, 0x03U, gra3); - if (gra6 != 0x05U) - PutReg(GRAX, 0x06U, gra6); - if (gra8 != 0xFFU) - PutReg(GRAX, 0x08U, gra8); - - /* Back to bank 0 */ - (*pATIHW->SetBank)(pATI, 0); - - /* - * If restoring video memory for a server video mode, free the frame buffer - * save area. - */ - if (ToFB && (pATIHW == &pATI->NewHW)) - { - xfree(pATIHW->frame_buffer); - pATIHW->frame_buffer = NULL; - } -} - -/* - * ATIAdapterPreInit -- - * - * This function initialises an ATIHWRec with information common to all video - * states generated by the driver. - */ -void -ATIAdapterPreInit -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW -) -{ - CARD32 lcd_index; - int HDisplay, VDisplay; - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - /* Fill in VGA data */ - ATIVGAPreInit(pATI, pATIHW); - - /* Fill in VGA Wonder data */ - if (pATI->CPIO_VGAWonder) - ATIVGAWonderPreInit(pATI, pATIHW); - } - - /* Fill in Mach64 data */ - if (pATI->Chip >= ATI_CHIP_88800GXC) - ATIMach64PreInit(pScreenInfo, pATI, pATIHW); - - if (pATI->Chip >= ATI_CHIP_264CT) - { - /* Ensure proper VCLK source */ - pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) | - (PLL_VCLK_SRC_SEL | PLL_VCLK_RESET); - - /* Set provisional values for other PLL registers */ - pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV); - pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV); - pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV); - pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV); - pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV); - pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL); - - /* For now disable extended reference and feedback dividers */ - if (pATI->Chip >= ATI_CHIP_264LT) - pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL) & - ~(PLL_EXT_VPLL_EN | PLL_EXT_VPLL_VGA_EN | PLL_EXT_VPLL_INSYNC); - } - - /* Initialise CRTC data for LCD panels */ - if (pATI->LCDPanelID >= 0) - { - if (pATI->Chip == ATI_CHIP_264LT) - { - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); - pATIHW->vert_stretching = inl(pATI->CPIO_VERT_STRETCHING); - pATIHW->lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); - } - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - pATIHW->lcd_index = (lcd_index & - ~(LCD_REG_INDEX | LCD_DISPLAY_DIS | LCD_SRC_SEL)) | - (LCD_SRC_SEL_CRTC1 | LCD_CRTC2_DISPLAY_DIS); - pATIHW->config_panel = - ATIGetLTProLCDReg(LCD_CONFIG_PANEL) | DONT_SHADOW_HEND; - pATIHW->lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); - pATIHW->vert_stretching = ATIGetLTProLCDReg(LCD_VERT_STRETCHING); - outl(pATI->CPIO_LCD_INDEX, lcd_index); - } - - pATIHW->lcd_gen_ctrl &= - ~(HORZ_DIVBY2_EN | DISABLE_PCLK_RESET | DIS_HOR_CRT_DIVBY2 | - VCLK_DAC_PM_EN | XTALIN_PM_EN | CRTC_RW_SELECT | - USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR | - SHADOW_EN | SHADOW_RW_EN); - pATIHW->lcd_gen_ctrl |= DONT_SHADOW_VPAR | LOCK_8DOT; - - if (pATI->OptionCRT) - { - /* - * Use primary CRTC to drive the CRT. Turn off panel interface. - */ - pATIHW->lcd_gen_ctrl &= ~LCD_ON; - pATIHW->lcd_gen_ctrl |= CRT_ON; - } - else - { - /* Use primary CRTC to drive the panel */ - pATIHW->lcd_gen_ctrl |= LCD_ON; - - /* - * Determine porch data. The following is inaccurate (but still - * good enough) when BIOS initialisation has set things up so that - * the registers read here are not the ones actually in use by the - * panel. - */ - if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN) - { - pATIHW->crtc_h_total_disp = - inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->crtc_h_sync_strt_wid = - inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->crtc_v_total_disp = - inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->crtc_v_sync_strt_wid = - inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); - - HDisplay = GetBits(pATIHW->crtc_h_total_disp, CRTC_H_DISP); - VDisplay = GetBits(pATIHW->crtc_v_total_disp, CRTC_V_DISP); - - pATI->LCDHSyncStart = - (GetBits(pATIHW->crtc_h_sync_strt_wid, - CRTC_H_SYNC_STRT_HI) * - (MaxBits(CRTC_H_SYNC_STRT) + 1)) + - GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_STRT) - - HDisplay; - pATI->LCDHSyncWidth = - GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_WID); - pATI->LCDHBlankWidth = - GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) - HDisplay; - pATI->LCDVSyncStart = - GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_STRT) - - VDisplay; - pATI->LCDVSyncWidth = - GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_WID); - pATI->LCDVBlankWidth = - GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) - VDisplay; - } - else - { - pATIHW->crt[0] = GetReg(CRTX(pATI->CPIO_VGABase), 0x00U); - pATIHW->crt[1] = GetReg(CRTX(pATI->CPIO_VGABase), 0x01U); - pATIHW->crt[4] = GetReg(CRTX(pATI->CPIO_VGABase), 0x04U); - pATIHW->crt[5] = GetReg(CRTX(pATI->CPIO_VGABase), 0x05U); - pATIHW->crt[6] = GetReg(CRTX(pATI->CPIO_VGABase), 0x06U); - pATIHW->crt[7] = GetReg(CRTX(pATI->CPIO_VGABase), 0x07U); - pATIHW->crt[16] = GetReg(CRTX(pATI->CPIO_VGABase), 0x10U); - pATIHW->crt[17] = GetReg(CRTX(pATI->CPIO_VGABase), 0x11U); - pATIHW->crt[18] = GetReg(CRTX(pATI->CPIO_VGABase), 0x12U); - - HDisplay = pATIHW->crt[1] + 1; - VDisplay = (((pATIHW->crt[7] << 3) & 0x0200U) | - ((pATIHW->crt[7] << 7) & 0x0100U) | - pATIHW->crt[18]) + 1; - - pATI->LCDHSyncStart = pATIHW->crt[4] - HDisplay; - pATI->LCDHSyncWidth = (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU; - pATI->LCDHBlankWidth = pATIHW->crt[0] + 5 - HDisplay; - pATI->LCDVSyncStart = (((pATIHW->crt[7] << 2) & 0x0200U) | - ((pATIHW->crt[7] << 6) & 0x0100U) | - pATIHW->crt[16]) - VDisplay; - pATI->LCDVSyncWidth = - (pATIHW->crt[17] - pATIHW->crt[16]) & 0x0FU; - pATI->LCDVBlankWidth = (((pATIHW->crt[7] << 4) & 0x0200U) | - ((pATIHW->crt[7] << 8) & 0x0100U) | - pATIHW->crt[6]) + 2 - VDisplay; - } - - HDisplay <<= 3; - pATI->LCDHSyncStart <<= 3; - pATI->LCDHSyncWidth <<= 3; - pATI->LCDHBlankWidth <<= 3; - - /* If the mode on entry wasn't stretched, adjust timings */ - if (!(pATIHW->horz_stretching & HORZ_STRETCH_EN) && - ((HDisplay = pATI->LCDHorizontal - HDisplay) > 0)) - { - if ((pATI->LCDHSyncStart -= HDisplay) < 0) - pATI->LCDHSyncStart = 0; - pATI->LCDHBlankWidth -= HDisplay; - HDisplay = pATI->LCDHSyncStart + pATI->LCDHSyncWidth; - if (pATI->LCDHBlankWidth < HDisplay) - pATI->LCDHBlankWidth = HDisplay; - } - - if (!(pATIHW->vert_stretching & VERT_STRETCH_EN) && - ((VDisplay = pATI->LCDVertical - VDisplay) > 0)) - { - if ((pATI->LCDVSyncStart -= VDisplay) < 0) - pATI->LCDVSyncStart = 0; - pATI->LCDVBlankWidth -= VDisplay; - VDisplay = pATI->LCDVSyncStart + pATI->LCDVSyncWidth; - if (pATI->LCDVBlankWidth < VDisplay) - pATI->LCDVBlankWidth = VDisplay; - } - } - } - - /* Set RAMDAC data */ - ATIDACPreInit(pScreenInfo, pATI, pATIHW); -} - -/* - * ATIAdapterSave -- - * - * This function saves the current video state. - */ -void -ATIAdapterSave -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW -) -{ - int Index; - - /* Get bank to bank 0 */ - (*pATIHW->SetBank)(pATI, 0); - - /* Save clock data */ - ATIClockSave(pScreenInfo, pATI, pATIHW); - - if (pATI->Chip >= ATI_CHIP_264CT) - { - pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) | - PLL_VCLK_RESET; - pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV); - pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV); - pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV); - pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV); - pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV); - pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL); - if (pATI->Chip >= ATI_CHIP_264LT) - pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL); - } - - /* Save LCD registers */ - if (pATI->LCDPanelID >= 0) - { - if (pATI->Chip == ATI_CHIP_264LT) - { - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); - pATIHW->vert_stretching = inl(pATI->CPIO_VERT_STRETCHING); - pATIHW->lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); - - /* Set up to save non-shadow registers */ - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & - ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); - } - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - pATIHW->lcd_index = inl(pATI->CPIO_LCD_INDEX); - pATIHW->config_panel = ATIGetLTProLCDReg(LCD_CONFIG_PANEL); - pATIHW->lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); - pATIHW->vert_stretching = ATIGetLTProLCDReg(LCD_VERT_STRETCHING); - pATIHW->ext_vert_stretch = ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH); - - /* Set up to save non-shadow registers */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & - ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); - } - } - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - /* Save VGA data */ - ATIVGASave(pATI, pATIHW); - - /* Save VGA Wonder data */ - if (pATI->CPIO_VGAWonder) - ATIVGAWonderSave(pATI, pATIHW); - } - - /* Save Mach64 data */ - if (pATI->Chip >= ATI_CHIP_88800GXC) - ATIMach64Save(pATI, pATIHW); - - /* Save DSP data */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO)) - ATIDSPSave(pATI, pATIHW); - - if (pATI->LCDPanelID >= 0) - { - if (!pATI->OptionCRT) - { - /* Switch to shadow registers */ - if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, - (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | - (SHADOW_EN | SHADOW_RW_EN)); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, - (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | - (SHADOW_EN | SHADOW_RW_EN)); - - /* Save shadow VGA CRTC registers */ - for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) - pATIHW->shadow_vga[Index] = - GetReg(CRTX(pATI->CPIO_VGABase), Index); - - /* Save shadow Mach64 CRTC registers */ - pATIHW->shadow_h_total_disp = inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->shadow_h_sync_strt_wid = - inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->shadow_v_total_disp = inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->shadow_v_sync_strt_wid = - inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); - } - - /* Restore CRTC selection and shadow state */ - if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, pATIHW->lcd_index); - } - } - - /* - * For some unknown reason, CLKDIV2 needs to be turned off to save the - * DAC's LUT reliably on VGA Wonder VLB adapters. - */ - if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) - PutReg(SEQX, 0x01U, pATIHW->seq[1] & ~0x08U); - - /* Save RAMDAC state */ - ATIDACSave(pATI, pATIHW); - - if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) - PutReg(SEQX, 0x01U, pATIHW->seq[1]); - - /* - * The server has already saved video memory contents when switching out of - * its virtual console, so don't do it again. - */ - if (pATIHW != &pATI->NewHW) - { - pATIHW->FeedbackDivider = 0; /* Don't programme clock */ - ATISwap(pScreenInfo, pATI, pATIHW, FALSE); /* Save video memory */ - } +#endif /* AVOID_CPIO */ - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ -} - -/* - * ATIAdapterCalculate -- - * - * This function fills in an ATIHWRec with all register values needed to enable - * a video state. It's important that this be done without modifying the - * current video state. - */ -Bool -ATIAdapterCalculate -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW, - DisplayModePtr pMode -) -{ - CARD32 lcd_index; - int Index, ECPClock; - - /* Clobber mode timings */ - if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT && - !pMode->CrtcHAdjusted && !pMode->CrtcVAdjusted && - (!pATI->OptionSync || (pMode->type & M_T_BUILTIN))) - { - int VScan; - - pMode->Clock = pATI->LCDClock; - pMode->Flags &= ~(V_DBLSCAN | V_INTERLACE | V_CLKDIV2); - - /* - * Use doublescanning or multiscanning to get around vertical blending - * limitations. - */ - VScan = pATI->LCDVertical / pMode->VDisplay; - switch (pATIHW->crtc) - { - case ATI_CRTC_VGA: - if (VScan > 64) - VScan = 64; - pMode->VScan = VScan; - break; - - case ATI_CRTC_MACH64: - pMode->VScan = 0; - if (VScan <= 1) - break; - VScan = 2; - pMode->Flags |= V_DBLSCAN; - break; - - default: - break; - } - - pMode->HSyncStart = pMode->HDisplay + pATI->LCDHSyncStart; - pMode->HSyncEnd = pMode->HSyncStart + pATI->LCDHSyncWidth; - pMode->HTotal = pMode->HDisplay + pATI->LCDHBlankWidth; - - pMode->VSyncStart = pMode->VDisplay + - ATIDivide(pATI->LCDVSyncStart, VScan, 0, 0); - pMode->VSyncEnd = pMode->VSyncStart + - ATIDivide(pATI->LCDVSyncWidth, VScan, 0, 1); - pMode->VTotal = pMode->VDisplay + - ATIDivide(pATI->LCDVBlankWidth, VScan, 0, 0); - } - - switch (pATIHW->crtc) - { - case ATI_CRTC_VGA: - /* Fill in VGA data */ - ATIVGACalculate(pATI, pATIHW, pMode); - - /* Fill in VGA Wonder data */ - if (pATI->CPIO_VGAWonder) - ATIVGAWonderCalculate(pATI, pATIHW, pMode); - - if (pATI->Chip >= ATI_CHIP_88800GXC) - { - if (pATI->Chip >= ATI_CHIP_264CT) - { - /* - * Selected bits of accelerator & VGA CRTC registers are - * actually copies of each other. - */ - pATIHW->crtc_h_total_disp = - SetBits(pMode->CrtcHTotal, CRTC_H_TOTAL) | - SetBits(pMode->CrtcHDisplay, CRTC_H_DISP); - pATIHW->crtc_h_sync_strt_wid = - SetBits(pMode->CrtcHSyncStart, CRTC_H_SYNC_STRT) | - SetBits(pMode->CrtcHSkew, CRTC_H_SYNC_DLY) | /* ? */ - SetBits(GetBits(pMode->CrtcHSyncStart, 0x0100U), - CRTC_H_SYNC_STRT_HI) | - SetBits(pMode->CrtcHSyncEnd, CRTC_H_SYNC_WID); - if (pMode->Flags & V_NHSYNC) - pATIHW->crtc_h_sync_strt_wid |= CRTC_H_SYNC_POL; - - pATIHW->crtc_v_total_disp = - SetBits(pMode->CrtcVTotal, CRTC_V_TOTAL) | - SetBits(pMode->CrtcVDisplay, CRTC_V_DISP); - pATIHW->crtc_v_sync_strt_wid = - SetBits(pMode->CrtcVSyncStart, CRTC_V_SYNC_STRT) | - SetBits(pMode->CrtcVSyncEnd, CRTC_V_SYNC_WID); - if (pMode->Flags & V_NVSYNC) - pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; - } - - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & - ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | - CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | - CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | - CRTC_VGA_XOVERSCAN | CRTC_VGA_128KAP_PAGING | - CRTC_VFC_SYNC_TRISTATE | - CRTC_LOCK_REGS | /* Already off, but ... */ - CRTC_SYNC_TRISTATE | CRTC_EXT_DISP_EN | - CRTC_DISP_REQ_EN | CRTC_VGA_LINEAR | CRTC_VGA_TEXT_132 | - CRTC_CUR_B_TEST); -#if 0 /* This isn't needed, but is kept for reference */ - if (pMode->Flags & V_DBLSCAN) - pATIHW->crtc_gen_cntl |= CRTC_DBL_SCAN_EN; -#endif - if (pMode->Flags & V_INTERLACE) - pATIHW->crtc_gen_cntl |= CRTC_INTERLACE_EN; - if ((pMode->Flags & (V_CSYNC | V_PCSYNC)) || pATI->OptionCSync) - pATIHW->crtc_gen_cntl |= CRTC_CSYNC_EN; - if (pATI->depth <= 4) - pATIHW->crtc_gen_cntl |= CRTC_EN | CRTC_CNT_EN; - else - pATIHW->crtc_gen_cntl |= - CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; - } - break; - - case ATI_CRTC_MACH64: - /* Fill in Mach64 data */ - ATIMach64Calculate(pATI, pATIHW, pMode); - break; - - default: - break; - } - - /* Set up LCD register values */ - if (pATI->LCDPanelID >= 0) - { - int VDisplay = pMode->VDisplay; - - if (pMode->Flags & V_DBLSCAN) - VDisplay <<= 1; - if (pMode->VScan > 1) - VDisplay *= pMode->VScan; - if (pMode->Flags & V_INTERLACE) - VDisplay >>= 1; - - if (pATI->Chip == ATI_CHIP_264LT) - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); - pATIHW->ext_vert_stretch = - ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH) & - ~(AUTO_VERT_RATIO | VERT_STRETCH_MODE); - - /* - * Don't use vertical blending if the mode is too wide or not - * vertically stretched. - */ - if (!pATI->OptionCRT && - (pMode->HDisplay <= pATI->LCDVBlendFIFOSize) && - (VDisplay < pATI->LCDVertical)) - pATIHW->ext_vert_stretch |= VERT_STRETCH_MODE; - - outl(pATI->CPIO_LCD_INDEX, lcd_index); - } - - pATIHW->horz_stretching &= - ~(HORZ_STRETCH_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO | - HORZ_STRETCH_MODE | HORZ_STRETCH_EN); - if (!pATI->OptionCRT && (pMode->HDisplay < pATI->LCDHorizontal)) - pATIHW->horz_stretching |= (HORZ_STRETCH_MODE | HORZ_STRETCH_EN) | - SetBits(((pMode->HDisplay & ~7) * - (MaxBits(HORZ_STRETCH_BLEND) + 1)) / - pATI->LCDHorizontal, HORZ_STRETCH_BLEND); - - if (pATI->OptionCRT || (VDisplay >= pATI->LCDVertical)) - pATIHW->vert_stretching = 0; - else - { - pATIHW->vert_stretching = (VERT_STRETCH_USE0 | VERT_STRETCH_EN) | - SetBits((VDisplay * (MaxBits(VERT_STRETCH_RATIO0) + 1)) / - pATI->LCDVertical, VERT_STRETCH_RATIO0); - } - - if (!pATI->OptionCRT) - { - /* Copy non-shadow CRTC register values to the shadow set */ - for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) - pATIHW->shadow_vga[Index] = pATIHW->crt[Index]; - - pATIHW->shadow_h_total_disp = pATIHW->crtc_h_total_disp; - pATIHW->shadow_h_sync_strt_wid = pATIHW->crtc_h_sync_strt_wid; - pATIHW->shadow_v_total_disp = pATIHW->crtc_v_total_disp; - pATIHW->shadow_v_sync_strt_wid = pATIHW->crtc_v_sync_strt_wid; - } - } - - /* Fill in clock data */ - if (!ATIClockCalculate(pScreenInfo, pATI, pATIHW, pMode)) - return FALSE; - - /* Setup ECP clock divider */ - if (pATI->Chip >= ATI_CHIP_264VT) - { - pATIHW->pll_vclk_cntl &= ~PLL_ECP_DIV; - /* XXX Don't do this for TVOut! */ - ECPClock = pMode->SynthClock; - for (Index = 0; (ECPClock > 125000) && (Index < 2); Index++) - ECPClock >>= 1; - pATIHW->pll_vclk_cntl |= SetBits(Index, PLL_ECP_DIV); - } - - return TRUE; -} - -/* - * ATIAdapterSet -- - * - * This function sets a video mode. It writes out all video state data that - * has been previously calculated or saved. - */ -void -ATIAdapterSet -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW -) -{ - int Index; - - /* Get back to bank 0 */ - (*pATIHW->SetBank)(pATI, 0); - - if (pATI->Chip >= ATI_CHIP_264CT) - { - ATIPutMach64PLLReg(PLL_VCLK_CNTL, pATIHW->pll_vclk_cntl); - ATIPutMach64PLLReg(PLL_VCLK_POST_DIV, pATIHW->pll_vclk_post_div); - ATIPutMach64PLLReg(PLL_VCLK0_FB_DIV, pATIHW->pll_vclk0_fb_div); - ATIPutMach64PLLReg(PLL_VCLK1_FB_DIV, pATIHW->pll_vclk1_fb_div); - ATIPutMach64PLLReg(PLL_VCLK2_FB_DIV, pATIHW->pll_vclk2_fb_div); - ATIPutMach64PLLReg(PLL_VCLK3_FB_DIV, pATIHW->pll_vclk3_fb_div); - ATIPutMach64PLLReg(PLL_XCLK_CNTL, pATIHW->pll_xclk_cntl); - if (pATI->Chip >= ATI_CHIP_264LT) - ATIPutMach64PLLReg(PLL_EXT_VPLL_CNTL, pATIHW->pll_ext_vpll_cntl); - ATIPutMach64PLLReg(PLL_VCLK_CNTL, - pATIHW->pll_vclk_cntl & ~PLL_VCLK_RESET); - } - - /* Load LCD registers */ - if (pATI->LCDPanelID >= 0) - { - /* Stop CRTC */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & - ~(CRTC_EXT_DISP_EN | CRTC_EN)); - - if (pATI->Chip == ATI_CHIP_264LT) - { - /* Update non-shadow registers first */ - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & - ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | - SHADOW_EN | SHADOW_RW_EN)); - - /* Temporarily disable stretching */ - outl(pATI->CPIO_HORZ_STRETCHING, pATIHW->horz_stretching & - ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); - outl(pATI->CPIO_VERT_STRETCHING, pATIHW->vert_stretching & - ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | - VERT_STRETCH_USE0 | VERT_STRETCH_EN)); - } - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - /* Update non-shadow registers first */ - ATIPutLTProLCDReg(LCD_CONFIG_PANEL, pATIHW->config_panel); - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & - ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | - SHADOW_EN | SHADOW_RW_EN)); - - /* Temporarily disable stretching */ - ATIPutLTProLCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching & - ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); - ATIPutLTProLCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching & - ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | - VERT_STRETCH_USE0 | VERT_STRETCH_EN)); - } - } - - switch (pATIHW->crtc) - { - case ATI_CRTC_VGA: - /* Stop CRTC */ - if (pATI->Chip >= ATI_CHIP_88800GXC) - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATIHW->crtc_gen_cntl & ~CRTC_EN); - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - - /* Set pixel clock */ - if ((pATIHW->FeedbackDivider > 0) && - (pATI->ProgrammableClock != ATI_CLOCK_FIXED)) - ATIClockSet(pATI, pATIHW); - - /* Load VGA Wonder */ - if (pATI->CPIO_VGAWonder) - ATIVGAWonderSet(pATI, pATIHW); - - /* Load VGA device */ - ATIVGASet(pATI, pATIHW); - - /* Load Mach64 registers */ - if (pATI->Chip >= ATI_CHIP_88800GXC) - { - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); - outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); - outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); - if (pATI->Chip >= ATI_CHIP_264CT) - { - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, - pATIHW->crtc_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, - pATIHW->crtc_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, - pATIHW->crtc_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, - pATIHW->crtc_v_sync_strt_wid); - outl(pATI->CPIO_CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl); - } - } - - break; - - case ATI_CRTC_MACH64: - /* Load Mach64 CRTC registers */ - ATIMach64Set(pATI, pATIHW); - - if (pATI->UseSmallApertures) - { - /* Oddly enough, these need to be set also, maybe others */ - PutReg(SEQX, 0x02U, pATIHW->seq[2]); - PutReg(SEQX, 0x04U, pATIHW->seq[4]); - PutReg(GRAX, 0x06U, pATIHW->gra[6]); - if (pATI->CPIO_VGAWonder) - ATIModifyExtReg(pATI, 0xB6U, -1, 0x00U, pATIHW->b6); - } - - break; - - default: - break; - } - - if (pATI->LCDPanelID >= 0) - { - if (!pATI->OptionCRT && - (!pATI->OptionDevel || (pATIHW == &pATI->OldHW))) - { - /* Switch to shadow registers */ - if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, - (pATIHW->lcd_gen_ctrl & - ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | - (SHADOW_EN | SHADOW_RW_EN)); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, - (pATIHW->lcd_gen_ctrl & - ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | - (SHADOW_EN | SHADOW_RW_EN)); - - /* Restore shadow registers */ - switch (pATIHW->crtc) - { - case ATI_CRTC_VGA: - for (Index = 0; - Index < NumberOf(pATIHW->shadow_vga); - Index++) - PutReg(CRTX(pATI->CPIO_VGABase), Index, - pATIHW->shadow_vga[Index]); - /* Fall through */ - - case ATI_CRTC_MACH64: - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, - pATIHW->shadow_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, - pATIHW->shadow_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, - pATIHW->shadow_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, - pATIHW->shadow_v_sync_strt_wid); - break; - - default: - break; - } - } - - /* Restore CRTC selection & shadow state and enable stretching */ - if (pATI->Chip == ATI_CHIP_264LT) - { - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); - outl(pATI->CPIO_HORZ_STRETCHING, pATIHW->horz_stretching); - outl(pATI->CPIO_VERT_STRETCHING, pATIHW->vert_stretching); - } - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ - { - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); - ATIPutLTProLCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching); - ATIPutLTProLCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching); - ATIPutLTProLCDReg(LCD_EXT_VERT_STRETCH, pATIHW->ext_vert_stretch); - outl(pATI->CPIO_LCD_INDEX, pATIHW->lcd_index); - } - } - - /* - * Set DSP registers. Note that, for some reason, sequencer resets clear - * the DSP_CONFIG register on early integrated controllers. - */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO)) - ATIDSPSet(pATI, pATIHW); - - /* Load RAMDAC */ - ATIDACSet(pATI, pATIHW); - - /* Restore video memory */ - ATISwap(pScreenInfo, pATI, pATIHW, TRUE); - - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ - - if ((xf86GetVerbosity() > 3) && (pATIHW == &pATI->NewHW)) - { - xf86ErrorFVerb(4, "\n After setting mode \"%s\":\n\n", - pScreenInfo->currentMode->name); - ATIPrintMode(pScreenInfo->currentMode); - ATIPrintRegisters(pATI); - } -} - -/* - * ATIAdapterAccelInit -- - * - * This function is called to initialise XAA on a screen. - */ -Bool -ATIAdapterAccelInit -( - ScrnInfoPtr pScreenInfo, - ScreenPtr pScreen, - ATIPtr pATI -) -{ - BoxRec ScreenArea; - - if (!pATI->OptionAccel) - return TRUE; - - if (!(pATI->pXAAInfo = XAACreateInfoRec())) - return FALSE; - - switch (pATI->Adapter) - { - case ATI_ADAPTER_MACH64: - if (ATIMach64AccelInit(pATI, pATI->pXAAInfo)) - break; - - default: - XAADestroyInfoRec(pATI->pXAAInfo); - pATI->pXAAInfo = NULL; - return FALSE; - } - - ScreenArea.x1 = ScreenArea.y1 = 0; - ScreenArea.x2 = pATI->displayWidth; - ScreenArea.y2 = pScreenInfo->videoRam * 1024 * 8 / pATI->displayWidth / - pATI->bitsPerPixel; - if ((unsigned)ScreenArea.y2 > ATIMach64MaxY) - ScreenArea.y2 = ATIMach64MaxY; - xf86InitFBManager(pScreen, &ScreenArea); - - if (XAAInit(pScreen, pATI->pXAAInfo)) - return TRUE; - - XAADestroyInfoRec(pATI->pXAAInfo); - pATI->pXAAInfo = NULL; - return FALSE; -} + "ATI Mach64", + "ATI Rage128", + "ATI Radeon" +}; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h:1.5 Fri Feb 18 07:19:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h Wed Oct 11 18:52:53 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h,v 1.5 2000/02/18 12:19:12 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h,v 1.7 2000/10/11 22:52:53 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,16 +24,15 @@ #ifndef ___ATIADAPTER_H___ #define ___ATIADAPTER_H___ 1 -#include "atipriv.h" -#include "atiproto.h" -#include "xf86str.h" - /* * Adapter-related definitions. */ typedef enum { ATI_ADAPTER_NONE = 0, + +#ifndef AVOID_CPIO + ATI_ADAPTER_EGA, ATI_ADAPTER_EGA_PLUS, ATI_ADAPTER_VGA, @@ -47,23 +46,15 @@ ATI_ADAPTER_8514A, ATI_ADAPTER_MACH8, ATI_ADAPTER_MACH32, + +#endif /* AVOID_CPIO */ + ATI_ADAPTER_MACH64, ATI_ADAPTER_RAGE128, + ATI_ADAPTER_RADEON, ATI_ADAPTER_MAX /* Must be last */ } ATIAdapterType; extern const char *ATIAdapterNames[]; - -extern void ATIAdapterPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr)); -extern void ATIAdapterSave FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr)); -extern Bool ATIAdapterCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr, DisplayModePtr)); -extern void ATIAdapterSet FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr)); - -extern Bool ATIAdapterAccelInit FunctionPrototype((ScrnInfoPtr, ScreenPtr, - ATIPtr)); #endif /* ___ATIADAPTER_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c:1.6 Mon Jun 19 11:00:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c Wed Oct 11 18:52:54 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.6 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.9 2000/10/11 22:52:54 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,12 +21,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atiadjust.h" #include "atichip.h" #include "aticrtc.h" -#include "atiio.h" #include "atilock.h" -#include "xf86.h" +#include "atimach64io.h" +#include "atiwonderio.h" /* * The display start address is expressed in units of 32-bit (VGA) or 64-bit @@ -50,6 +51,8 @@ { unsigned long MaxBase; +#ifndef AVOID_CPIO + if ((pATI->CPIO_VGAWonder) && (pATI->Chip <= ATI_CHIP_18800_1) && (pATI->VideoRAM == 256) && @@ -60,6 +63,9 @@ pATI->AdjustMask = (unsigned long)(-32); } else + +#endif /* AVOID_CPIO */ + { pATI->AdjustDepth = (pATI->bitsPerPixel + 7) >> 3; @@ -73,6 +79,9 @@ switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: if (pATI->Chip >= ATI_CHIP_264CT) { @@ -88,6 +97,8 @@ pATI->AdjustMaxBase = 0x0FFFFFU << 3; break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET) << 3; break; @@ -141,6 +152,8 @@ /* Unlock registers */ ATIUnlock(pATI); +#ifndef AVOID_CPIO + if ((pATI->NewHW.crtc == ATI_CRTC_VGA) && (pATI->Chip < ATI_CHIP_264CT)) { PutReg(CRTX(pATI->CPIO_VGABase), 0x0CU, GetByte(Base, 1)); @@ -165,6 +178,9 @@ } } else + +#endif /* AVOID_CPIO */ + { /* * On integrated controllers, there is only one set of CRTC control @@ -173,19 +189,29 @@ * setting the CRTC's offset register to more than 256k needs to be * done through the accelerator port. */ + +#ifndef AVOID_CPIO + if (pATI->depth <= 4) { - outl(pATI->CPIO_CRTC_OFF_PITCH, - SetBits(pATI->displayWidth >> 4, CRTC_PITCH) | - SetBits(Base, CRTC_OFFSET)); + outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 4, CRTC_PITCH) | + SetBits(Base, CRTC_OFFSET)); } else + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) Base <<= 1; /* LSBit must be zero */ - outl(pATI->CPIO_CRTC_OFF_PITCH, - SetBits(pATI->displayWidth >> 3, CRTC_PITCH) | - SetBits(Base, CRTC_OFFSET)); + +#endif /* AVOID_CPIO */ + + outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 3, CRTC_PITCH) | + SetBits(Base, CRTC_OFFSET)); } } } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c:1.6 Tue Mar 21 22:08:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c Wed Oct 11 18:52:54 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.6 2000/03/22 03:08:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.9 2000/10/11 22:52:54 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,10 +21,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atibank.h" -#include "atiio.h" -#include "xf86.h" +#include "atimach64io.h" +#include "atiwonderio.h" +#ifndef AVOID_CPIO + /* * ATI VGA Wonder V3 adapters use an ATI 18800 chip and are single-banked. * Bank selection is done with bits 0x1E of ATI extended VGA register index @@ -266,8 +269,9 @@ ) { CARD32 tmp = ATIMach64MassagePackedBankNumber(iBank); - outl(pATI->CPIO_MEM_VGA_RP_SEL, tmp); - outl(pATI->CPIO_MEM_VGA_WP_SEL, tmp); + + outr(MEM_VGA_RP_SEL, tmp); + outr(MEM_VGA_WP_SEL, tmp); } /* @@ -282,8 +286,9 @@ unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_RP_SEL, - ATIMach64MassagePackedBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_RP_SEL, ATIMach64MassagePackedBankNumber(iBank)); return 0; } @@ -299,8 +304,9 @@ unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_WP_SEL, - ATIMach64MassagePackedBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_WP_SEL, ATIMach64MassagePackedBankNumber(iBank)); return 0; } @@ -343,8 +349,9 @@ ) { CARD32 tmp = ATIMach64MassagePlanarBankNumber(iBank); - outl(pATI->CPIO_MEM_VGA_RP_SEL, tmp); - outl(pATI->CPIO_MEM_VGA_WP_SEL, tmp); + + outr(MEM_VGA_RP_SEL, tmp); + outr(MEM_VGA_WP_SEL, tmp); } /* @@ -359,8 +366,9 @@ unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_RP_SEL, - ATIMach64MassagePlanarBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_RP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); return 0; } @@ -376,8 +384,9 @@ unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_WP_SEL, - ATIMach64MassagePlanarBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_WP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); return 0; } @@ -396,3 +405,5 @@ ATIMach64SetBankPlanar(ATIPTR(XF86SCRNINFO(pScreen)), iBank); return 0; } + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h:1.4 Fri Feb 18 07:19:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h Fri Aug 4 17:07:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h,v 1.4 2000/02/18 12:19:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h,v 1.5 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,8 +26,11 @@ #include "atipriv.h" #include "atiproto.h" + #include "mibank.h" +#ifndef AVOID_CPIO + /* * Banking definitions. */ @@ -79,5 +82,7 @@ ATIx8800SetBank, ATIMach64SetBankPacked, ATIMach64SetBankPlanar; + +#endif /* AVOID_CPIO */ #endif /* ___ATIBANK_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c:1.5 Fri Feb 18 07:19:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c Tue Aug 22 17:54:29 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c,v 1.5 2000/02/18 12:19:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c,v 1.7 2000/08/22 21:54:29 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,8 @@ #include "atibios.h" #include "atistruct.h" +#ifndef AVOID_CPIO + /* * ATIReadBIOS -- * @@ -47,10 +49,9 @@ * disabled on server entry. */ if ((pVideo = pATI->PCIInfo) && - (((pPCI = (pciConfigPtr)(pVideo->thisCard))->pci_command & + (((pPCI = pVideo->thisCard)->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)) != (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))) - { pATI->BIOSBase = PCIGETROM(pciReadLong(pPCI->tag, PCI_MAP_ROM_REG)); return xf86ReadPciBIOS(Offset, pPCI->tag, 0, Buffer, Length); @@ -61,3 +62,5 @@ pATI->BIOSBase = 0x000C0000U; return xf86ReadBIOS(pATI->BIOSBase, Offset, Buffer, Length); } + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h:1.2 Fri Feb 18 07:19:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h Fri Aug 4 17:07:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h,v 1.2 2000/02/18 12:19:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h,v 1.3 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,9 +26,14 @@ #include "atipriv.h" #include "atiproto.h" + #include "Xmd.h" +#ifndef AVOID_CPIO + extern int ATIReadBIOS FunctionPrototype((ATIPtr, pointer, unsigned long, int)); + +#endif /* AVOID_CPIO */ #endif /* ___ATIBIOS_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c:1.8 Tue May 2 20:44:03 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c Thu Oct 26 07:47:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.8 2000/05/03 00:44:03 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.12 2000/10/26 11:47:45 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atibus.h" #include "atichip.h" #include "atiio.h" +#include "atistruct.h" #include "ativersion.h" /* @@ -62,6 +63,9 @@ ) { resPtr pResources; + +#ifndef AVOID_CPIO + resRange Resources[2] = {{0, 0, 0}, _END}; /* Claim VGA and VGAWonder resources */ @@ -98,45 +102,49 @@ } } - if (Active || !pATI->SharedAccelerator) - { - /* Claim 8514/A resources */ - if (pATI->ChipHasSUBSYS_CNTL) - xf86ClaimFixedResources( - pATI->SharedAccelerator ? res8514Shared : res8514Exclusive, - pATI->iEntity); - - /* Claim Mach64 sparse I/O resources */ - if ((pATI->Adapter == ATI_ADAPTER_MACH64) && - (pATI->CPIODecoding == SPARSE_IO)) - { - if (pATI->SharedAccelerator) - Resources[0].type = ResShrIoSparse; - else - Resources[0].type = ResExcIoSparse; - Resources[0].rBase = pATI->CPIOBase; - Resources[0].rMask = 0x03FCU; +#endif /* AVOID_CPIO */ - xf86ClaimFixedResources(Resources, pATI->iEntity); - } + if (!Active && pATI->SharedAccelerator) + return; - /* Register relocatable resources for inactive adapters */ - if (!Active) - { - pResources = - xf86RegisterResources(pATI->iEntity, NULL, ResExclusive); - pResources = - xf86ReallocatePciResources(pATI->iEntity, pResources); - if (pResources) - { - xf86Msg(X_WARNING, - ATI_NAME ": Unable to register the following resources" - " for inactive adapter:\n"); - xf86PrintResList(1, pResources); - xf86FreeResList(pResources); - } - } +#ifndef AVOID_CPIO + + /* Claim 8514/A resources */ + if (pATI->ChipHasSUBSYS_CNTL) + xf86ClaimFixedResources( + pATI->SharedAccelerator ? res8514Shared : res8514Exclusive, + pATI->iEntity); + + /* Claim Mach64 sparse I/O resources */ + if ((pATI->Adapter == ATI_ADAPTER_MACH64) && + (pATI->CPIODecoding == SPARSE_IO)) + { + if (pATI->SharedAccelerator) + Resources[0].type = ResShrIoSparse; + else + Resources[0].type = ResExcIoSparse; + Resources[0].rBase = pATI->CPIOBase; + Resources[0].rMask = 0x03FCU; + + xf86ClaimFixedResources(Resources, pATI->iEntity); } + +#endif /* AVOID_CPIO */ + + /* Register relocatable resources for inactive adapters */ + if (Active) + return; + + pResources = xf86RegisterResources(pATI->iEntity, NULL, ResExclusive); + pResources = xf86ReallocatePciResources(pATI->iEntity, pResources); + if (!pResources) + return; + + xf86Msg(X_WARNING, + ATI_NAME ": Unable to register the following resources for inactive" + " adapter:\n"); + xf86PrintResList(1, pResources); + xf86FreeResList(pResources); } /* Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h:1.5 Fri Feb 18 07:19:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h Thu Oct 26 07:47:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h,v 1.5 2000/02/18 12:19:15 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h,v 1.7 2000/10/26 11:47:45 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,10 +22,17 @@ */ #ifndef ___ATIBUS_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atibus.h" +# undef XFree86Module +#endif + #define ___ATIBUS_H___ 1 #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" /* @@ -46,7 +53,7 @@ extern const char *ATIBusNames[]; -extern int ATIClaimBusSlot FunctionPrototype((DriverPtr, int, GDevPtr, Bool, - ATIPtr)); +extern int ATIClaimBusSlot FunctionPrototype((DriverPtr, int, GDevPtr, + Bool, ATIPtr)); #endif /* ___ATIBUS_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c:1.11 xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c:1.15 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c:1.11 Thu Apr 20 17:28:28 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c Tue Oct 10 11:16:34 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.11 2000/04/20 21:28:28 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.15 2000/10/10 15:16:34 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,7 +24,7 @@ #include "ati.h" #include "atibus.h" #include "atichip.h" -#include "atiio.h" +#include "atimach64io.h" #include "ativersion.h" /* @@ -33,6 +33,9 @@ const char *ATIChipNames[] = { "Unknown", + +#ifndef AVOID_CPIO + "IBM VGA or compatible", "ATI 18800", "ATI 18800-1", @@ -48,6 +51,9 @@ "ATI 68800-6", "ATI 68800LX", "ATI 68800AX", + +#endif /* AVOID_CPIO */ + "ATI 88800GX-C", "ATI 88800GX-D", "ATI 88800GX-E", @@ -71,14 +77,21 @@ "ATI 3D Rage Mobility", "ATI unknown Mach64", "ATI Rage 128 GL", - "ATI Rage 128 Pro", - "ATI Rage 128 Mobility", + "ATI Rage 128 VR", + "ATI Rage 128 Pro GL", + "ATI Rage 128 Pro VR", + "ATI Rage 128 Mobility M3", + "ATI Rage 128 Mobility M4", "ATI unknown Rage 128" + "ATI Radeon", + "ATI Rage HDTV" }; const char *ATIFoundryNames[] = { "SGS", "NEC", "KCS", "UMC", "TSMC", "5", "6", "UMC" }; +#ifndef AVOID_CPIO + /* * ATIMach32ChipID -- * @@ -121,6 +134,8 @@ } } +#endif /* AVOID_CPIO */ + /* * ATIMach64ChipID -- * @@ -134,13 +149,13 @@ const CARD16 ExpectedChipType ) { - CARD32 IOValue = inl(ATIIOPort(CONFIG_CHIP_ID)); - pATI->ChipType = GetBits(IOValue, 0xFFFFU); - pATI->ChipClass = GetBits(IOValue, CFG_CHIP_CLASS); - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REV); - pATI->ChipVersion = GetBits(IOValue, CFG_CHIP_VERSION); - pATI->ChipFoundry = GetBits(IOValue, CFG_CHIP_FOUNDRY); - pATI->ChipRev = pATI->ChipRevision; + pATI->config_chip_id = inr(CONFIG_CHIP_ID); + pATI->ChipType = GetBits(pATI->config_chip_id, 0xFFFFU); + pATI->ChipClass = GetBits(pATI->config_chip_id, CFG_CHIP_CLASS); + pATI->ChipRevision = GetBits(pATI->config_chip_id, CFG_CHIP_REV); + pATI->ChipVersion = GetBits(pATI->config_chip_id, CFG_CHIP_VERSION); + pATI->ChipFoundry = GetBits(pATI->config_chip_id, CFG_CHIP_FOUNDRY); + pATI->ChipRev = pATI->ChipRevision; switch (pATI->ChipType) { case OldChipID('G', 'X'): @@ -179,7 +194,8 @@ case OldChipID('C', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('C', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264CT; pATI->BusType = ATI_BUS_PCI; break; @@ -187,7 +203,8 @@ case OldChipID('E', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('E', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264ET; pATI->BusType = ATI_BUS_PCI; break; @@ -195,7 +212,8 @@ case OldChipID('V', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT; pATI->BusType = ATI_BUS_PCI; /* Some early GT's are detected as VT's */ @@ -216,7 +234,8 @@ case OldChipID('G', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->BusType = ATI_BUS_PCI; if (!pATI->ChipVersion) pATI->Chip = ATI_CHIP_264GT; @@ -227,7 +246,8 @@ case OldChipID('V', 'U'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'U'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT3; pATI->BusType = ATI_BUS_PCI; break; @@ -235,7 +255,8 @@ case OldChipID('G', 'U'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'U'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTDVD; pATI->BusType = ATI_BUS_PCI; break; @@ -243,7 +264,8 @@ case OldChipID('L', 'G'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'G'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LT; pATI->BusType = ATI_BUS_PCI; break; @@ -251,15 +273,19 @@ case OldChipID('V', 'V'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'V'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT4; pATI->BusType = ATI_BUS_PCI; break; case OldChipID('G', 'V'): + case OldChipID('G', 'Y'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'V'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + case NewChipID('G', 'Y'): + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GT2C; pATI->BusType = ATI_BUS_PCI; break; @@ -269,7 +295,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'W'): case NewChipID('G', 'Z'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GT2C; pATI->BusType = ATI_BUS_AGP; break; @@ -281,7 +308,8 @@ case NewChipID('G', 'I'): case NewChipID('G', 'P'): case NewChipID('G', 'Q'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTPRO; pATI->BusType = ATI_BUS_PCI; break; @@ -291,7 +319,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'B'): case NewChipID('G', 'D'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTPRO; pATI->BusType = ATI_BUS_AGP; break; @@ -301,7 +330,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'I'): case NewChipID('L', 'P'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LTPRO; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 800; @@ -312,7 +342,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'B'): case NewChipID('L', 'D'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LTPRO; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 800; @@ -327,7 +358,8 @@ case NewChipID('G', 'O'): case NewChipID('G', 'R'): case NewChipID('G', 'S'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264XL; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 1024; @@ -338,7 +370,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'M'): case NewChipID('G', 'N'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264XL; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 1024; @@ -349,7 +382,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'R'): case NewChipID('L', 'S'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_MOBILITY; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 1024; @@ -360,7 +394,8 @@ pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'M'): case NewChipID('L', 'N'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_MOBILITY; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 1024; @@ -373,7 +408,7 @@ } /* - * ATIPCIChip -- + * ATIChipID -- * * This returns the ATI_CHIP_* value (generally) associated with a particular * ChipID/ChipRev combination. @@ -387,6 +422,9 @@ { switch (ChipID) { + +#ifndef AVOID_CPIO + case OldChipID('A', 'A'): case NewChipID('A', 'A'): return ATI_CHIP_68800_3; @@ -399,6 +437,8 @@ case OldChipID('A', 'X'): case NewChipID('A', 'X'): return ATI_CHIP_68800AX; +#endif /* AVOID_CPIO */ + case OldChipID('G', 'X'): case NewChipID('G', 'X'): switch (ChipRev) { @@ -452,6 +492,7 @@ case OldChipID('G', 'V'): case NewChipID('G', 'V'): case OldChipID('G', 'W'): case NewChipID('G', 'W'): + case OldChipID('G', 'Y'): case NewChipID('G', 'Y'): case OldChipID('G', 'Z'): case NewChipID('G', 'Z'): return ATI_CHIP_264GT2C; @@ -484,9 +525,17 @@ case OldChipID('R', 'E'): case NewChipID('R', 'E'): case OldChipID('R', 'F'): case NewChipID('R', 'F'): + case OldChipID('S', 'K'): case NewChipID('S', 'K'): + case OldChipID('S', 'L'): case NewChipID('S', 'L'): + case OldChipID('S', 'M'): case NewChipID('S', 'M'): + return ATI_CHIP_RAGE128GL; + case OldChipID('R', 'K'): case NewChipID('R', 'K'): case OldChipID('R', 'L'): case NewChipID('R', 'L'): - return ATI_CHIP_RAGE128GL; + case OldChipID('S', 'E'): case NewChipID('S', 'E'): + case OldChipID('S', 'F'): case NewChipID('S', 'F'): + case OldChipID('S', 'G'): case NewChipID('S', 'G'): + return ATI_CHIP_RAGE128VR; case OldChipID('P', 'A'): case NewChipID('P', 'A'): case OldChipID('P', 'B'): case NewChipID('P', 'B'): @@ -494,6 +543,8 @@ case OldChipID('P', 'D'): case NewChipID('P', 'D'): case OldChipID('P', 'E'): case NewChipID('P', 'E'): case OldChipID('P', 'F'): case NewChipID('P', 'F'): + return ATI_CHIP_RAGE128PROGL; + case OldChipID('P', 'G'): case NewChipID('P', 'G'): case OldChipID('P', 'H'): case NewChipID('P', 'H'): case OldChipID('P', 'I'): case NewChipID('P', 'I'): @@ -512,22 +563,31 @@ case OldChipID('P', 'V'): case NewChipID('P', 'V'): case OldChipID('P', 'W'): case NewChipID('P', 'W'): case OldChipID('P', 'X'): case NewChipID('P', 'X'): - case OldChipID('S', 'E'): case NewChipID('S', 'E'): - case OldChipID('S', 'F'): case NewChipID('S', 'F'): - case OldChipID('S', 'G'): case NewChipID('S', 'G'): - case OldChipID('S', 'K'): case NewChipID('S', 'K'): - case OldChipID('S', 'L'): case NewChipID('S', 'L'): - case OldChipID('S', 'M'): case NewChipID('S', 'M'): - return ATI_CHIP_RAGE128PRO; + return ATI_CHIP_RAGE128PROVR; case OldChipID('L', 'E'): case NewChipID('L', 'E'): case OldChipID('L', 'F'): case NewChipID('L', 'F'): - return ATI_CHIP_RAGE128MOBILITY; + case OldChipID('L', 'K'): case NewChipID('L', 'K'): + case OldChipID('L', 'L'): case NewChipID('L', 'L'): + return ATI_CHIP_RAGE128MOBILITY3; + + case OldChipID('M', 'F'): case NewChipID('M', 'F'): + case OldChipID('M', 'L'): case NewChipID('M', 'L'): + return ATI_CHIP_RAGE128MOBILITY4; + + case OldChipID('Q', 'D'): case NewChipID('Q', 'D'): + case OldChipID('Q', 'E'): case NewChipID('Q', 'E'): + case OldChipID('Q', 'F'): case NewChipID('Q', 'F'): + case OldChipID('Q', 'G'): case NewChipID('Q', 'G'): + return ATI_CHIP_RADEON; + + case OldChipID('H', 'D'): case NewChipID('H', 'D'): + return ATI_CHIP_HDTV; default: /* - * I'd say it's a Rage128 here, except that I don't support them - * yet. + * I'd say it's a Rage128 or a Radeon here, except that I don't + * support them. */ return ATI_CHIP_Mach64; } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h:1.10 xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h:1.10 Thu Mar 30 10:41:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h Tue Oct 10 11:16:34 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.10 2000/03/30 15:41:17 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.13 2000/10/10 15:16:34 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiregs.h" + #include "Xmd.h" /* @@ -34,6 +35,9 @@ typedef enum { ATI_CHIP_NONE = 0, + +#ifndef AVOID_CPIO + ATI_CHIP_VGA, /* Generic VGA */ ATI_CHIP_18800, ATI_CHIP_18800_1, @@ -49,6 +53,9 @@ ATI_CHIP_68800_6, /* Mach32 */ ATI_CHIP_68800LX, /* Mach32 */ ATI_CHIP_68800AX, /* Mach32 */ + +#endif /* AVOID_CPIO */ + ATI_CHIP_88800GXC, /* Mach64 */ ATI_CHIP_88800GXD, /* Mach64 */ ATI_CHIP_88800GXE, /* Mach64 */ @@ -72,9 +79,14 @@ ATI_CHIP_MOBILITY, /* Mach64 */ ATI_CHIP_Mach64, /* Mach64 */ ATI_CHIP_RAGE128GL, /* Rage128 */ - ATI_CHIP_RAGE128PRO, /* Rage128 */ - ATI_CHIP_RAGE128MOBILITY, /* Rage128 */ - ATI_CHIP_Rage128 /* Rage128 */ + ATI_CHIP_RAGE128VR, /* Rage128 */ + ATI_CHIP_RAGE128PROGL, /* Rage128 */ + ATI_CHIP_RAGE128PROVR, /* Rage128 */ + ATI_CHIP_RAGE128MOBILITY3, /* Rage128 */ + ATI_CHIP_RAGE128MOBILITY4, /* Rage128 */ + ATI_CHIP_Rage128, /* Rage128 */ + ATI_CHIP_RADEON, /* Radeon */ + ATI_CHIP_HDTV /* HDTV */ } ATIChipType; extern const char *ATIChipNames[]; @@ -96,7 +108,12 @@ extern const char *ATIFoundryNames[]; +#ifndef AVOID_CPIO + extern void ATIMach32ChipID FunctionPrototype((ATIPtr)); + +#endif /* AVOID_CPIO */ + extern void ATIMach64ChipID FunctionPrototype((ATIPtr, const CARD16)); extern ATIChipType ATIChipID FunctionPrototype((const CARD16, const CARD8)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c:1.10 Mon Jun 19 11:00:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c Wed Oct 11 18:52:54 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.10 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.14 2000/10/11 22:52:54 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -197,6 +197,9 @@ #include "atichip.h" #include "atidac.h" #include "atidsp.h" +#include "atimach64io.h" +#include "atimode.h" +#include "atiwonderio.h" /* * Definitions related to non-programmable clock generators. @@ -241,7 +244,7 @@ "SGS-Thompson 1703 or similar" }, { - 8, 263, 8, 8, 9, + 16, 263, 8, 8, 9, 4, 12, 2, 4, ATIPostDividers, "Chrontel 8398 or similar" @@ -268,7 +271,7 @@ /* * XF86Config clocks line that start with the following will either be rejected - * for ATI boards, or accepted for non-ATI boards. + * for ATI adapters, or accepted for non-ATI adapters. */ static const int ATIVGAClocks[] = @@ -418,117 +421,10 @@ #define ATIProgrammableClockMap ClockMaps[0] #define ATIProgrammableClockUnmap ATIProgrammableClockMap #define MapClockIndex(_ClockMap, _Index) \ - (SetBits((_ClockMap)[GetBits((_Index), 0x0CU)], 0x0CU) | \ + (SetBits((_ClockMap)[GetBits(_Index, 0x0CU)], 0x0CU) | \ ((_Index) & ~0x0CU)) /* - * ATIClockSelect -- - * - * This function sets clock select bits in various registers to a specified - * value. - */ -static Bool -ATIClockSelect -( - ScrnInfoPtr pScreenInfo, - int Index -) -{ - ATIPtr pATI = ATIPTR(pScreenInfo); - CARD8 genmo; - - switch (Index) - { - case CLK_REG_SAVE: - if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) - ATIModifyExtReg(pATI, 0xB5U, pATI->OldHW.b5, 0x7FU, 0x00U); - break; - - case CLK_REG_RESTORE: - break; - - default: - /* Remap clock number */ - Index = MapClockIndex(pATI->OldHW.ClockMap, Index); - - switch (pATI->OldHW.crtc) - { - case ATI_CRTC_VGA: - /* Get generic two low-order bits */ - genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); - - if (pATI->CPIO_VGAWonder) - { - /* - * On adapters with crystals, switching to one of the - * spare assignments doesn't do anything (i.e. the - * previous setting remains in effect). So, disable - * their selection. - */ - if (((Index & 0x03U) == 0x02U) && - ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4))) - return FALSE; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - - /* Set high-order bits */ - if (pATI->Chip <= ATI_CHIP_18800) - ATIModifyExtReg(pATI, 0xB2U, -1, 0xBFU, - Index << 4); - else - { - ATIModifyExtReg(pATI, 0xBEU, -1, 0xEFU, - Index << 2); - if (pATI->Adapter != ATI_ADAPTER_V4) - { - Index >>= 1; - ATIModifyExtReg(pATI, 0xB9U, -1, 0xFDU, - Index >> 1); - } - } - - /* Set clock divider bits */ - ATIModifyExtReg(pATI, 0xB8U, -1, 0x00U, - (Index << 3) & 0xC0U); - } - else - { - /* - * Reject clocks that cannot be selected. - */ - if (Index & ~0x03U) - return FALSE; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - } - - /* Must set miscellaneous output register last */ - outb(GENMO, genmo); - - /* End sequencer reset */ - PutReg(SEQX, 0x00U, 0x03U); - - break; - - case ATI_CRTC_MACH64: - outl(pATI->CPIO_CLOCK_CNTL, CLOCK_STROBE | - SetBits(Index, CLOCK_SELECT | CLOCK_DIVIDER)); - break; - - default: - return FALSE; - } - - break; - } - - return TRUE; -} - -/* * ATIMatchClockLine -- * * This function tries to match the XF86Config clocks to one of an array of @@ -550,9 +446,18 @@ int MinimumGap = CLOCK_TOLERANCE + 1; /* For ATI adapters, reject generic VGA clocks */ - if ((pATI->Adapter != ATI_ADAPTER_VGA) && - (ClockLine == SpecificationClockLine)) - ClockChipIndex++; + +#ifndef AVOID_CPIO + + if (pATI->Adapter != ATI_ADAPTER_VGA) + +#endif /* AVOID_CPIO */ + + { + if (ClockLine == SpecificationClockLine) + ClockChipIndex++; + } + /* If checking for XF86Config clock order, skip crystals */ if (ClockMap) ClockChipIndex++; @@ -560,12 +465,16 @@ for (; ClockLine[++ClockChipIndex]; ) { int MaximumGap = 0, ClockCount = 0, ClockIndex = 0; + +#ifndef AVOID_CPIO - /* Only Mach64's and Rage128's can have programmable clocks */ + /* Only Mach64's and later can have programmable clocks */ if ((ClockChipIndex >= ATI_CLOCK_MACH64A) && (pATI->Adapter < ATI_ADAPTER_MACH64)) break; +#endif /* AVOID_CPIO */ + for (; ClockIndex < NumberOfClocks; ClockIndex++) { int Gap, XF86ConfigClock, SpecificationClock; @@ -600,11 +509,17 @@ ClockChip = ClockChipIndex; if (!(MinimumGap = MaximumGap)) break; + +SkipThisClockGenerator:; -SkipThisClockGenerator: +#ifndef AVOID_CPIO + /* For non-ATI adapters, only normalise standard VGA clocks */ if (pATI->Adapter == ATI_ADAPTER_VGA) break; + +#endif /* AVOID_CPIO */ + } return ClockChip; @@ -625,13 +540,19 @@ ClockRangePtr pRange ) { + double ScaleFactor; unsigned short int NumberOfUndividedClocks; unsigned short int NumberOfDividers, NumberOfClocks; int CalibrationClockNumber, CalibrationClockValue; - int ClockIndex, SpecificationClock, ClockMap = 0; - CARD16 VSyncRegister = GENS1(pATI->CPIO_VGABase); - CARD8 VSyncBit = 0x08U; + int ClockIndex, SpecificationClock, ClockMap = 0, Index; + CARD8 CanDisableInterrupts; + +#ifndef AVOID_CPIO + + CARD8 genmo; +#endif /* AVOID_CPIO */ + /* * Decide what to do about the XF86Config clocks for programmable clock * generators. @@ -639,7 +560,8 @@ if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) { /* Check for those that are not (yet) handled */ - if (pATI->ProgrammableClock > NumberOf(ATIClockDescriptors)) + if ((pATI->ProgrammableClock == ATI_CLOCK_UNKNOWN) || + (pATI->ProgrammableClock > NumberOf(ATIClockDescriptors))) xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Unknown programmable clock generator type (0x%02X)" " detected.\n", pATI->ProgrammableClock); @@ -658,12 +580,18 @@ pScreenInfo->progClock = TRUE; /* Set internal clock ordering */ + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) { pATI->NewHW.ClockMap = ATIVGAProgrammableClockMap; pATI->NewHW.ClockUnmap = ATIVGAProgrammableClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATI->NewHW.ClockMap = ATIProgrammableClockMap; pATI->NewHW.ClockUnmap = ATIProgrammableClockUnmap; @@ -706,15 +634,22 @@ } } +#ifndef AVOID_CPIO + /* Set default clock maps */ pATI->NewHW.ClockMap = ATIVGAWonderClockMap; pATI->NewHW.ClockUnmap = ATIVGAWonderClockUnmap; +#endif /* AVOID_CPIO */ + /* * Determine the number of clock values the adapter should be able to * generate and the dot clock to use for probe calibration. */ ProbeClocks: + +#ifndef AVOID_CPIO + if (pATI->Adapter == ATI_ADAPTER_VGA) { NumberOfDividers = 1; @@ -723,7 +658,13 @@ CalibrationClockValue = 28322; } else + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + NumberOfDividers = 4; if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) @@ -734,11 +675,20 @@ CalibrationClockValue = 56644; } else + +#endif /* AVOID_CPIO */ + { NumberOfUndividedClocks = 16; + +#ifndef AVOID_CPIO + CalibrationClockNumber = 7; CalibrationClockValue = 36000; if (pATI->Chip >= ATI_CHIP_68800) + +#endif /* AVOID_CPIO */ + { NumberOfDividers = 2; if (pATI->Chip >= ATI_CHIP_264CT) @@ -748,7 +698,14 @@ CalibrationClockNumber = 1; CalibrationClockValue = 28322; } - else if (pATI->Adapter >= ATI_ADAPTER_MACH64) + else + +#ifndef AVOID_CPIO + + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + { CalibrationClockNumber = 10 /* or 11 */; CalibrationClockValue = 75000 /* or 65000 */; @@ -758,12 +715,18 @@ * When selecting clocks, all ATI accelerators use a different * clock ordering. */ + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) { pATI->NewHW.ClockMap = ATIMachVGAClockMap; pATI->NewHW.ClockUnmap = ATIMachVGAClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATI->NewHW.ClockMap = ATIAcceleratorClockMap; pATI->NewHW.ClockUnmap = ATIAcceleratorClockUnmap; @@ -806,6 +769,8 @@ CalibrationClockValue *= 10; } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* @@ -815,37 +780,221 @@ * cannot reliably be prevented from enabling frequencies that are * greater than what the adapter can handle. */ - ATIAdapterSave(pScreenInfo, pATI, &pATI->OldHW); + ATIModeSave(pScreenInfo, pATI, &pATI->OldHW); + + /* Ensure clock select pins are not OR'ed with anything */ + if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) + ATIModifyExtReg(pATI, 0xB5, pATI->OldHW.b5, 0x7FU, 0x00U); } - switch (pATI->OldHW.crtc) +#endif /* AVOID_CPIO */ + + /* + * Probe the adapter for clock values. The following is essentially + * the common layer's xf86GetClocks() reworked to fit. One difference + * is the ability to monitor a VSync bit in MMIO space. + */ + CanDisableInterrupts = TRUE; /* An assumption verified below */ + + for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) { - case ATI_CRTC_VGA: - /* Already set */ - break; + pScreenInfo->clock[ClockIndex] = 0; - case ATI_CRTC_MACH64: - VSyncRegister = pATI->CPIO_CRTC_INT_CNTL; - VSyncBit = GetByte(CRTC_VBLANK, 0); - break; + /* Remap clock number */ + Index = MapClockIndex(pATI->OldHW.ClockMap, ClockIndex); - default: - break; + /* Select the clock */ + switch (pATI->OldHW.crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Get generic two low-order bits */ + genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); + + if (pATI->CPIO_VGAWonder) + { + /* + * On adapters with crystals, switching to one of the + * spare assignments doesn't do anything (i.e. the + * previous setting remains in effect). So, disable + * their selection. + */ + if (((Index & 0x03U) == 0x02U) && + ((pATI->Chip <= ATI_CHIP_18800) || + (pATI->Adapter == ATI_ADAPTER_V4))) + continue; + + /* Start sequencer reset */ + PutReg(SEQX, 0x00U, 0x00U); + + /* Set high-order bits */ + if (pATI->Chip <= ATI_CHIP_18800) + ATIModifyExtReg(pATI, 0xB2U, -1, 0xBFU, + Index << 4); + else + { + ATIModifyExtReg(pATI, 0xBEU, -1, 0xEFU, + Index << 2); + if (pATI->Adapter != ATI_ADAPTER_V4) + { + Index >>= 1; + ATIModifyExtReg(pATI, 0xB9U, -1, 0xFDU, + Index >> 1); + } + } + + /* Set clock divider bits */ + ATIModifyExtReg(pATI, 0xB8U, -1, 0x00U, + (Index << 3) & 0xC0U); + } + else + { + /* + * Reject clocks that cannot be selected. + */ + if (Index & ~0x03U) + continue; + + /* Start sequencer reset */ + PutReg(SEQX, 0x00U, 0x00U); + } + + /* Must set miscellaneous output register last */ + outb(GENMO, genmo); + + /* End sequencer reset */ + PutReg(SEQX, 0x00U, 0x03U); + + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + out8(CLOCK_CNTL, CLOCK_STROBE | + SetBits(Index, CLOCK_SELECT | CLOCK_DIVIDER)); + break; + + default: + continue; + } + + usleep(50000); /* Let clock stabilise */ + + xf86SetPriority(TRUE); + + /* Try to disable interrupts */ + if (CanDisableInterrupts && !xf86DisableInterrupts()) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to disable interrupts; Clock probe will not be as" + " accurate.\n"); + CanDisableInterrupts = FALSE; + } + + /* + * Generate a count while monitoring the vertical sync or blanking + * pulse. This is dependent on the CRTC used by the mode on server + * entry. + */ + switch (pATI->OldHW.crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Verify vertical sync pulses are in fact occurring */ + Index = 1 << 19; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + if (Index-- <= 0) + goto EnableInterrupts; + + /* Generate the count */ + for (Index = 0; Index < 8; Index++) + { + while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) + pScreenInfo->clock[ClockIndex]++; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + pScreenInfo->clock[ClockIndex]++; + } + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + /* Verify vertical blanking pulses are in fact occurring */ + Index = 1 << 19; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + if (Index-- <= 0) + goto EnableInterrupts; + + /* Generate the count */ + for (Index = 0; Index < 4; Index++) + { + while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) + pScreenInfo->clock[ClockIndex]++; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + pScreenInfo->clock[ClockIndex]++; + } + break; + + default: + break; + } + + EnableInterrupts: + if (CanDisableInterrupts) + xf86EnableInterrupts(); + + xf86SetPriority(FALSE); } - /* Probe the adapter for clock values */ - xf86GetClocks(pScreenInfo, NumberOfClocks, ATIClockSelect, - NULL, NULL, VSyncRegister, VSyncBit, - CalibrationClockNumber, CalibrationClockValue); + ScaleFactor = (double)CalibrationClockValue * + (double)pScreenInfo->clock[CalibrationClockNumber]; + /* Scale the clocks from counts to kHz */ + for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) + { + if (ClockIndex == CalibrationClockNumber) + pScreenInfo->clock[ClockIndex] = CalibrationClockValue; + else if (pScreenInfo->clock[ClockIndex]) + /* Round to the nearest 10 kHz */ + pScreenInfo->clock[ClockIndex] = + (((ScaleFactor / (double)pScreenInfo->clock[ClockIndex]) + + 5) / 10) * 10; + } + + pScreenInfo->numClocks = NumberOfClocks; + +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* Restore video state */ - ATIAdapterSet(pScreenInfo, pATI, &pATI->OldHW); + ATIModeSet(pScreenInfo, pATI, &pATI->OldHW); xfree(pATI->OldHW.frame_buffer); pATI->OldHW.frame_buffer = NULL; } +#endif /* AVOID_CPIO */ + /* Tell user clocks were probed, instead of supplied */ pATI->OptionProbeClocks = TRUE; @@ -854,6 +1003,8 @@ SpecificationClockLine, NumberOfUndividedClocks, CalibrationClockNumber, 0); +#ifndef AVOID_CPIO + if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) { @@ -862,6 +1013,8 @@ pATI->Clock = ATI_CLOCK_NONE; } else + +#endif /* AVOID_CPIO */ { /* All others don't have crystals */ if (pATI->Clock == ATI_CLOCK_CRYSTALS) @@ -890,21 +1043,32 @@ pATI->Clock = ATIMatchClockLine(pScreenInfo, pATI, SpecificationClockLine, NumberOfUndividedClocks, -1, 0); +#ifndef AVOID_CPIO + if (pATI->Adapter != ATI_ADAPTER_VGA) + +#endif /* AVOID_CPIO */ + { if (pATI->Clock == ATI_CLOCK_NONE) { /* * Reject certain clock lines that are obviously wrong. This - * includes the standard VGA clocks for non-ATI adapters, and - * clock lines that could have been used with the pre-2.1.1 - * driver. + * includes the standard VGA clocks for ATI adapters, and clock + * lines that could have been used with the pre-2.1.1 driver. */ if (ATIMatchClockLine(pScreenInfo, pATI, InvalidClockLine, NumberOfClocks, -1, 0)) pATI->OptionProbeClocks = TRUE; - else if ((pATI->Chip >= ATI_CHIP_18800) && - (pATI->Adapter != ATI_ADAPTER_V4)) + else + +#ifndef AVOID_CPIO + + if ((pATI->Chip >= ATI_CHIP_18800) && + (pATI->Adapter != ATI_ADAPTER_V4)) + +#endif /* AVOID_CPIO */ + { /* * Check for clocks that are specified in the wrong order. @@ -921,7 +1085,7 @@ xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "XF86Config clock ordering incorrect. Clocks" - " will be reordered." ATI_README); + " will be reordered.\n"); break; } } @@ -929,6 +1093,9 @@ } else /* Ensure crystals are not matched to clock chips, and vice versa */ + +#ifndef AVOID_CPIO + if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) { @@ -936,6 +1103,9 @@ pATI->OptionProbeClocks = TRUE; } else + +#endif /* AVOID_CPIO */ + { if (pATI->Clock == ATI_CLOCK_CRYSTALS) pATI->OptionProbeClocks = TRUE; @@ -945,7 +1115,7 @@ { xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Invalid or obsolete XF86Config clocks line rejected.\n" - " Clocks will be probed." ATI_README); + " Clocks will be probed.\n"); goto ProbeClocks; } } @@ -956,12 +1126,21 @@ else if (pATI->Clock == ATI_CLOCK_NONE) xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Unknown clock generator detected.\n"); - else if (pATI->Clock == ATI_CLOCK_CRYSTALS) + else + +#ifndef AVOID_CPIO + + if (pATI->Clock == ATI_CLOCK_CRYSTALS) xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "This adapter uses crystals to generate clock frequencies.\n"); else if (pATI->Clock != ATI_CLOCK_VGA) + +#endif /* AVOID_CPIO */ + + { xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s clock chip detected.\n", ATIClockNames[pATI->Clock]); + } if (pATI->Clock != ATI_CLOCK_NONE) { @@ -1037,14 +1216,20 @@ ATIHWPtr pATIHW ) { - if (pScreenInfo->vtSema && (pATI->ProgrammableClock != ATI_CLOCK_FIXED)) + if (pScreenInfo->vtSema && (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) { + +#ifndef AVOID_CPIO + if (pATIHW->crtc == ATI_CRTC_VGA) { pATIHW->ClockMap = ATIVGAProgrammableClockMap; pATIHW->ClockUnmap = ATIVGAProgrammableClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATIHW->ClockMap = ATIProgrammableClockMap; pATIHW->ClockUnmap = ATIProgrammableClockUnmap; @@ -1052,11 +1237,20 @@ } else { + +#ifndef AVOID_CPIO + if (pATIHW->crtc != ATI_CRTC_VGA) + +#endif /* AVOID_CPIO */ + { pATIHW->ClockMap = ATIAcceleratorClockMap; pATIHW->ClockUnmap = ATIAcceleratorClockUnmap; } + +#ifndef AVOID_CPIO + else if (pATI->Chip < ATI_CHIP_68800) { pATIHW->ClockMap = ATIVGAWonderClockMap; @@ -1067,6 +1261,9 @@ pATIHW->ClockMap = ATIMachVGAClockMap; pATIHW->ClockUnmap = ATIMachVGAClockUnmap; } + +#endif /* AVOID_CPIO */ + } } @@ -1079,7 +1276,7 @@ Bool ATIClockCalculate ( - ScrnInfoPtr pScreenInfo, + int iScreen, ATIPtr pATI, ATIHWPtr pATIHW, DisplayModePtr pMode @@ -1092,7 +1289,7 @@ /* Set default values */ pATIHW->FeedbackDivider = pATIHW->ReferenceDivider = pATIHW->PostDivider = 0; - if ((pATI->ProgrammableClock == ATI_CLOCK_FIXED) || + if ((pATI->ProgrammableClock <= ATI_CLOCK_FIXED) || ((pATI->ProgrammableClock == ATI_CLOCK_CH8398) && (pMode->ClockIndex < 2))) { @@ -1162,7 +1359,7 @@ Frequency = ATIDivide(Frequency, Multiple, 0, 0); if (abs(Frequency - pMode->Clock) > CLOCK_TOLERANCE) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + xf86DrvMsg(iScreen, X_ERROR, "Unable to programme clock %.3fMHz for mode %s.\n", (double)(pMode->Clock) / 1000.0, pMode->name); return FALSE; @@ -1177,8 +1374,7 @@ pATIHW->FeedbackDivider, pATIHW->ReferenceDivider, pATIHW->PostDivider); - if ((pATI->Chip >= ATI_CHIP_264VTB) && - (pATI->CPIODecoding == BLOCK_IO)) + if (pATI->Chip >= ATI_CHIP_264VTB) ATIDSPCalculate(pATI, pATIHW, pMode); } @@ -1188,6 +1384,9 @@ switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: pATIHW->genmo = (pATIHW->genmo & 0xF3U) | ((ClockSelect << 2) & 0x0CU); @@ -1216,6 +1415,8 @@ } break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pATIHW->clock_cntl = CLOCK_STROBE | SetBits(ClockSelect, CLOCK_SELECT | CLOCK_DIVIDER); @@ -1240,24 +1441,22 @@ ATIHWPtr pATIHW ) { - CARD8 clock_cntl0, crtc_gen_cntl3; - CARD8 tmp, tmp2; + CARD32 crtc_gen_cntl, tmp; + CARD8 clock_cntl0; + CARD8 tmp2; unsigned int Programme; int N = pATIHW->FeedbackDivider - pATI->ClockDescriptor.NAdjust; int M = pATIHW->ReferenceDivider - pATI->ClockDescriptor.MAdjust; int D = pATIHW->PostDivider; /* Temporarily switch to accelerator mode */ - crtc_gen_cntl3 = inb(pATI->CPIO_CRTC_GEN_CNTL + 3); - outb(pATI->CPIO_CRTC_GEN_CNTL + 3, - crtc_gen_cntl3 | GetByte(CRTC_EXT_DISP_EN, 3)); - - ATISetDACIOPorts(pATI, ATI_CRTC_MACH64); + crtc_gen_cntl = inr(CRTC_GEN_CNTL); + outr(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_EXT_DISP_EN); switch (pATI->ProgrammableClock) { case ATI_CLOCK_ICS2595: - clock_cntl0 = inb(pATI->CPIO_CLOCK_CNTL); + clock_cntl0 = in8(CLOCK_CNTL); Programme = (SetBits(pATIHW->clock, ICS2595_CLOCK) | SetBits(N, ICS2595_FB_DIV) | SetBits(D, ICS2595_POST_DIV)) ^ @@ -1271,9 +1470,9 @@ while (Programme >= CLOCK_BIT) { tmp = (Programme & CLOCK_BIT) | CLOCK_STROBE; - outb(pATI->CPIO_CLOCK_CNTL, tmp); + out8(CLOCK_CNTL, tmp); ATIDelay(26); /* 26 microseconds */ - outb(pATI->CPIO_CLOCK_CNTL, tmp | CLOCK_PULSE); + out8(CLOCK_CNTL, tmp | CLOCK_PULSE); ATIDelay(26); /* 26 microseconds */ Programme >>= 1; } @@ -1281,26 +1480,29 @@ xf86EnableInterrupts(); /* Restore register */ - outb(pATI->CPIO_CLOCK_CNTL, clock_cntl0 | CLOCK_STROBE); + out8(CLOCK_CNTL, clock_cntl0 | CLOCK_STROBE); break; case ATI_CLOCK_STG1703: (void)ATIGetDACCmdReg(pATI); - (void)inb(pATI->CPIO_DAC_MASK); - outb(pATI->CPIO_DAC_MASK, (pATIHW->clock << 1) + 0x20U); - outb(pATI->CPIO_DAC_MASK, 0); - outb(pATI->CPIO_DAC_MASK, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x1FU) | SetBits(D, 0xE0U)); + (void)in8(M64_DAC_MASK); + out8(M64_DAC_MASK, (pATIHW->clock << 1) + 0x20U); + out8(M64_DAC_MASK, 0); + out8(M64_DAC_MASK, SetBits(N, 0xFFU)); + out8(M64_DAC_MASK, SetBits(M, 0x1FU) | SetBits(D, 0xE0U)); break; case ATI_CLOCK_CH8398: - tmp = inb(pATI->CPIO_DAC_CNTL); - outb(pATI->CPIO_DAC_CNTL, - tmp | (DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3)); - outb(pATI->CPIO_DAC_WRITE, pATIHW->clock); - outb(pATI->CPIO_DAC_DATA, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_DATA, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); - outb(pATI->CPIO_DAC_CNTL, tmp); + tmp = inr(DAC_CNTL) | (DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3); + outr(DAC_CNTL, tmp); + out8(M64_DAC_WRITE, pATIHW->clock); + out8(M64_DAC_DATA, SetBits(N, 0xFFU)); + out8(M64_DAC_DATA, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); + out8(M64_DAC_MASK, 0x04U); + outr(DAC_CNTL, tmp & ~(DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3)); + tmp2 = in8(M64_DAC_WRITE); + out8(M64_DAC_WRITE, (tmp2 & 0x70U) | 0x80U); + outr(DAC_CNTL, tmp & ~DAC_EXT_SEL_RS2); break; case ATI_CLOCK_INTERNAL: @@ -1334,45 +1536,44 @@ case ATI_CLOCK_ATT20C408: (void)ATIGetDACCmdReg(pATI); - tmp = inb(pATI->CPIO_DAC_MASK); + tmp = in8(M64_DAC_MASK); (void)ATIGetDACCmdReg(pATI); - outb(pATI->CPIO_DAC_MASK, tmp | 1); - outb(pATI->CPIO_DAC_WRITE, 1); - outb(pATI->CPIO_DAC_MASK, tmp | 9); + out8(M64_DAC_MASK, tmp | 1); + out8(M64_DAC_WRITE, 1); + out8(M64_DAC_MASK, tmp | 9); ATIDelay(400); /* 400 microseconds */ tmp2 = (pATIHW->clock << 2) + 0x40U; - outb(pATI->CPIO_DAC_WRITE, tmp2); - outb(pATI->CPIO_DAC_MASK, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_WRITE, ++tmp2); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); - outb(pATI->CPIO_DAC_WRITE, ++tmp2); - outb(pATI->CPIO_DAC_MASK, 0x77U); + out8(M64_DAC_WRITE, tmp2); + out8(M64_DAC_MASK, SetBits(N, 0xFFU)); + out8(M64_DAC_WRITE, ++tmp2); + out8(M64_DAC_MASK, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); + out8(M64_DAC_WRITE, ++tmp2); + out8(M64_DAC_MASK, 0x77U); ATIDelay(400); /* 400 microseconds */ - outb(pATI->CPIO_DAC_WRITE, 1); - outb(pATI->CPIO_DAC_MASK, tmp); + out8(M64_DAC_WRITE, 1); + out8(M64_DAC_MASK, tmp); break; case ATI_CLOCK_IBMRGB514: - tmp = inb(pATI->CPIO_DAC_CNTL); - outb(pATI->CPIO_DAC_CNTL, - (tmp & ~DAC_EXT_SEL_RS3) | DAC_EXT_SEL_RS2); + tmp = inr(DAC_CNTL); + outr(DAC_CNTL, (tmp & ~DAC_EXT_SEL_RS3) | DAC_EXT_SEL_RS2); tmp2 = (pATIHW->clock << 1) + 0x20U; - outb(pATI->CPIO_DAC_WRITE, tmp2); - outb(pATI->CPIO_DAC_DATA, 0); - outb(pATI->CPIO_DAC_MASK, + out8(M64_DAC_WRITE, tmp2); + out8(M64_DAC_DATA, 0); + out8(M64_DAC_MASK, (SetBits(N, 0x3FU) | SetBits(D, 0xC0U)) ^ 0xC0U); - outb(pATI->CPIO_DAC_WRITE, tmp2 + 1); - outb(pATI->CPIO_DAC_DATA, 0); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x3FU)); - outb(pATI->CPIO_DAC_CNTL, tmp); + out8(M64_DAC_WRITE, tmp2 + 1); + out8(M64_DAC_DATA, 0); + out8(M64_DAC_MASK, SetBits(M, 0x3FU)); + outr(DAC_CNTL, tmp); break; default: break; } - (void)inb(pATI->CPIO_DAC_WRITE); /* Clear DAC counter */ + (void)in8(M64_DAC_WRITE); /* Clear DAC counter */ /* Restore register */ - outb(pATI->CPIO_CRTC_GEN_CNTL + 3, crtc_gen_cntl3); + outr(CRTC_GEN_CNTL, crtc_gen_cntl); } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h:1.4 Fri Feb 18 07:19:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h Fri Aug 4 17:07:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h,v 1.4 2000/02/18 12:19:18 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h,v 1.5 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" /* @@ -51,6 +52,7 @@ */ typedef enum { + ATI_CLOCK_UNKNOWN = -1, ATI_CLOCK_FIXED = 0, /* Further described by ATIClockType */ ATI_CLOCK_ICS2595, ATI_CLOCK_STG1703, @@ -77,8 +79,8 @@ ClockRangePtr)); extern void ATIClockSave FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); -extern Bool ATIClockCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr, DisplayModePtr)); +extern Bool ATIClockCalculate FunctionPrototype((int, ATIPtr, ATIHWPtr, + DisplayModePtr)); extern void ATIClockSet FunctionPrototype((ATIPtr, ATIHWPtr)); #endif /* ___ATICLOCK_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c:1.1 --- /dev/null Mon Dec 18 14:29:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c Wed Oct 11 18:52:55 2000 @@ -0,0 +1,169 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c,v 1.1 2000/10/11 22:52:55 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atiadapter.h" +#include "aticonfig.h" +#include "atioption.h" +#include "atistruct.h" + +/* + * Recognised XF86Config options. + */ +typedef enum +{ + ATI_OPTION_DEVEL, /* Intentionally undocumented */ + ATI_OPTION_SYNC /* Temporary and undocumented */ +} ATIPrivateOptionType; + +/* + * ATIProcessOptions -- + * + * This function extracts options from what was parsed out of the XF86Config + * file. + */ +void +ATIProcessOptions +( + ScrnInfoPtr pScreenInfo, + ATIPtr pATI +) +{ + OptionInfoPtr PublicOption = xnfalloc(ATIPublicOptionSize); + OptionInfoRec PrivateOption[] = + { + { + ATI_OPTION_DEVEL, + "tsi", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_SYNC, + "lcdsync", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + -1, + NULL, + OPTV_NONE, + {0, }, + FALSE + } + }; + + (void)memcpy(PublicOption, ATIPublicOptions, ATIPublicOptionSize); + +# define Accel PublicOption[ATI_OPTION_ACCEL].value.bool +# define CRTScreen PublicOption[ATI_OPTION_CRT].value.bool +# define CSync PublicOption[ATI_OPTION_CSYNC].value.bool +# define Devel PrivateOption[ATI_OPTION_DEVEL].value.bool +# define Linear PublicOption[ATI_OPTION_LINEAR].value.bool +# define CacheMMIO PublicOption[ATI_OPTION_MMIO_CACHE].value.bool +# define ProbeClocks PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool +# define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool +# define Sync PrivateOption[ATI_OPTION_SYNC].value.bool + +# define ReferenceClock \ + PublicOption[ATI_OPTION_REFERENCE_CLOCK].value.freq.freq + + /* Pick up XF86Config options */ + xf86CollectOptions(pScreenInfo, NULL); + + /* Set non-zero defaults */ + +#ifndef AVOID_CPIO + + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + + { + Accel = Linear = CacheMMIO = TRUE; + } + + ReferenceClock = ((double)157500000.0) / ((double)11.0); + +#ifndef AVOID_CPIO + + if (pATI->PCIInfo) + +#endif /* AVOID_CPIO */ + + { + ShadowFB = TRUE; + } + + Sync = TRUE; + + xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, + PublicOption); + xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, + PrivateOption); + + /* Disable linear apertures if the OS doesn't support them */ + if (!xf86LinearVidMem() && Linear) + { + if (PublicOption[ATI_OPTION_LINEAR].found) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "OS does not support linear apertures.\n"); + Linear = FALSE; + } + + /* Move option values into driver private structure */ + pATI->OptionAccel = Accel; + pATI->OptionCRT = CRTScreen; + pATI->OptionCSync = CSync; + pATI->OptionDevel = Devel; + pATI->OptionLinear = Linear; + pATI->OptionMMIOCache = CacheMMIO; + pATI->OptionProbeClocks = ProbeClocks; + pATI->OptionShadowFB = ShadowFB; + pATI->OptionSync = Sync; + + /* Only set the reference clock if it hasn't already been determined */ + if (pATI->ReferenceNumerator && pATI->ReferenceDenominator) + return; + + switch ((int)(ReferenceClock / ((double)100000.0))) + { + case 143: + pATI->ReferenceNumerator = 157500; + pATI->ReferenceDenominator = 11; + break; + + case 286: + pATI->ReferenceNumerator = 315000; + pATI->ReferenceDenominator = 11; + break; + + default: + pATI->ReferenceNumerator = + (int)(ReferenceClock / ((double)1000.0)); + pATI->ReferenceDenominator = 1; + break; + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h:1.1 --- /dev/null Mon Dec 18 14:29:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h Wed Oct 11 18:52:55 2000 @@ -0,0 +1,35 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.h,v 1.1 2000/10/11 22:52:55 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATICONFIG_H___ +#define ___ATICONFIG_H___ 1 + +#include "atipriv.h" +#include "atiproto.h" + +#include "xf86str.h" + +extern void ATIProcessOptions FunctionPrototype((ScrnInfoPtr, + ATIPtr)); + +#endif /* ___ATICONFIG_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c:1.12 xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c:1.12 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c Wed Oct 11 18:52:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.12 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.14 2000/10/11 22:52:55 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,9 +26,11 @@ #include "aticrtc.h" #include "atilock.h" #include "atimach64.h" +#include "atimode.h" #include "atistruct.h" #include "ativga.h" #include "atividmem.h" + #include "xf86.h" /* @@ -59,10 +61,15 @@ pATI = ATIPTR(pScreenInfo); switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: ATIVGASaveScreen(pATI, Mode); break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: ATIMach64SaveScreen(pATI, Mode); break; @@ -101,13 +108,23 @@ ATIMach64SetDPMSMode(pATI, DPMSMode); break; +#ifndef AVOID_CPIO + case ATI_ADAPTER_NONE: case ATI_ADAPTER_8514A: case ATI_ADAPTER_MACH8: break; +#endif /* AVOID_CPIO */ + default: /* Assume EGA/VGA */ + +#ifndef AVOID_CPIO + ATIVGASetDPMSMode(pATI, DPMSMode); + +#endif /* AVOID_CPIO */ + break; } } @@ -126,7 +143,7 @@ ) { /* Map apertures */ - if (!ATIMapApertures(pScreenInfo, pATI)) + if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) return FALSE; /* Unlock device */ @@ -134,17 +151,17 @@ /* Calculate hardware data */ if (pScreen && - !ATIAdapterCalculate(pScreenInfo, pATI, &pATI->NewHW, + !ATIModeCalculate(pScreenInfo->scrnIndex, pATI, &pATI->NewHW, pScreenInfo->currentMode)) return FALSE; pScreenInfo->vtSema = TRUE; /* Save current state */ - ATIAdapterSave(pScreenInfo, pATI, &pATI->OldHW); + ATIModeSave(pScreenInfo, pATI, &pATI->OldHW); /* Set graphics state */ - ATIAdapterSet(pScreenInfo, pATI, &pATI->NewHW); + ATIModeSet(pScreenInfo, pATI, &pATI->NewHW); /* Possibly blank the screen */ if (pScreen) @@ -175,10 +192,10 @@ { /* If not exiting, save graphics video state */ if (!xf86ServerIsExiting()) - ATIAdapterSave(pScreenInfo, pATI, &pATI->NewHW); + ATIModeSave(pScreenInfo, pATI, &pATI->NewHW); /* Restore mode in effect on server entry */ - ATIAdapterSet(pScreenInfo, pATI, &pATI->OldHW); + ATIModeSet(pScreenInfo, pATI, &pATI->OldHW); pScreenInfo->vtSema = FALSE; } @@ -188,7 +205,7 @@ /* Unmap apertures */ if (!pATI->Closeable || !pATI->nDGAMode) - ATIUnmapApertures(pScreenInfo, pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); SetTimeSinceLastInputEvent(); } @@ -210,14 +227,14 @@ ATIPtr pATI = ATIPTR(pScreenInfo); /* Calculate new hardware data */ - if (!ATIAdapterCalculate(pScreenInfo, pATI, &pATI->NewHW, pMode)) + if (!ATIModeCalculate(iScreen, pATI, &pATI->NewHW, pMode)) return FALSE; /* Set new hardware state */ if (pScreenInfo->vtSema) { pScreenInfo->currentMode = pMode; - ATIAdapterSet(pScreenInfo, pATI, &pATI->NewHW); + ATIModeSet(pScreenInfo, pATI, &pATI->NewHW); } SetTimeSinceLastInputEvent(); @@ -251,10 +268,14 @@ if (pATI->OptionShadowFB) return TRUE; +#ifndef AVOID_CPIO + /* If used, modify banking interface */ if (!miModifyBanking(pScreen, &pATI->BankInfo)) return FALSE; +#endif /* AVOID_CPIO */ + pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen); PixmapPrivate = pScreenPixmap->devPrivate; if (!PixmapPrivate.ptr) @@ -312,8 +333,12 @@ ATILeaveGraphics(pScreenInfo, pATI); +#ifndef AVOID_CPIO + xfree(pATI->OldHW.frame_buffer); xfree(pATI->NewHW.frame_buffer); + +#endif /* AVOID_CPIO */ xfree(pATI->pShadow); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h:1.5 Tue Mar 21 22:08:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h Fri Aug 4 17:07:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.5 2000/03/22 03:08:11 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.6 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern Bool ATISaveScreen FunctionPrototype((ScreenPtr, int)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h:1.4 Fri Feb 18 07:19:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h Fri Aug 4 17:07:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h,v 1.4 2000/02/18 12:19:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h,v 1.5 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,8 +29,14 @@ */ typedef enum { + +#ifndef AVOID_CPIO + ATI_CRTC_VGA, /* Use VGA CRTC */ ATI_CRTC_8514, /* Use 8514/Mach8/Mach32 accelerator CRTC */ + +#endif /* AVOID_CPIO */ + ATI_CRTC_MACH64 /* Use Mach64 accelerator CRTC */ } ATICRTCType; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c:1.8 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c Tue Dec 12 19:45:19 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.8 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.10 2000/12/13 00:45:19 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,7 +21,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atidac.h" +#include "atimach64io.h" #include "atimono.h" /* @@ -55,6 +57,8 @@ {ATI_DAC_UNKNOWN, "Unknown"} /* Must be last */ }; +#ifndef AVOID_CPIO + /* * ATISetDACIOPorts -- * @@ -77,17 +81,17 @@ break; case ATI_CRTC_8514: - pATI->CPIO_DAC_DATA = DAC_DATA; - pATI->CPIO_DAC_MASK = DAC_MASK; - pATI->CPIO_DAC_READ = DAC_R_INDEX; - pATI->CPIO_DAC_WRITE = DAC_W_INDEX; + pATI->CPIO_DAC_DATA = IBM_DAC_DATA; + pATI->CPIO_DAC_MASK = IBM_DAC_MASK; + pATI->CPIO_DAC_READ = IBM_DAC_READ; + pATI->CPIO_DAC_WRITE = IBM_DAC_WRITE; break; case ATI_CRTC_MACH64: - pATI->CPIO_DAC_DATA = pATI->CPIO_DAC_REGS + 1; - pATI->CPIO_DAC_MASK = pATI->CPIO_DAC_REGS + 2; - pATI->CPIO_DAC_READ = pATI->CPIO_DAC_REGS + 3; - pATI->CPIO_DAC_WRITE = pATI->CPIO_DAC_REGS + 0; + pATI->CPIO_DAC_DATA = ATIIOPort(DAC_REGS) + 1; + pATI->CPIO_DAC_MASK = ATIIOPort(DAC_REGS) + 2; + pATI->CPIO_DAC_READ = ATIIOPort(DAC_REGS) + 3; + pATI->CPIO_DAC_WRITE = ATIIOPort(DAC_REGS) + 0; break; default: @@ -95,6 +99,8 @@ } } +#endif /* AVOID_CPIO */ + /* * ATIGetDACCmdReg -- * @@ -106,11 +112,25 @@ ATIPtr pATI ) { + +#ifdef AVOID_CPIO + + (void)in8(M64_DAC_WRITE); /* Reset to PEL mode */ + (void)in8(M64_DAC_MASK); + (void)in8(M64_DAC_MASK); + (void)in8(M64_DAC_MASK); + return in8(M64_DAC_MASK); + +#else /* AVOID_CPIO */ + (void)inb(pATI->CPIO_DAC_WRITE); /* Reset to PEL mode */ (void)inb(pATI->CPIO_DAC_MASK); (void)inb(pATI->CPIO_DAC_MASK); (void)inb(pATI->CPIO_DAC_MASK); return inb(pATI->CPIO_DAC_MASK); + +#endif /* AVOID_CPIO */ + } /* @@ -159,16 +179,34 @@ pATIHW->lut[Index2 + 2] = maxColour; } +#ifndef AVOID_CPIO + if (pATI->depth == 1) { - rgb blackColour = pScreenInfo->display->whiteColour, + rgb blackColour = pScreenInfo->display->blackColour, whiteColour = pScreenInfo->display->whiteColour; - /* Check for defaults */ - if (!blackColour.red && !blackColour.green && !blackColour.blue && - !whiteColour.red && !whiteColour.green && !whiteColour.blue) - whiteColour.red = whiteColour.green = whiteColour.blue = - maxColour; + if (blackColour.red > maxColour) + blackColour.red = maxColour; + if (blackColour.green > maxColour) + blackColour.green = maxColour; + if (blackColour.blue > maxColour) + blackColour.blue = maxColour; + if (whiteColour.red > maxColour) + whiteColour.red = maxColour; + if (whiteColour.green > maxColour) + whiteColour.green = maxColour; + if (whiteColour.blue > maxColour) + whiteColour.blue = maxColour; + + if ((blackColour.red == whiteColour.red) && + (blackColour.green == whiteColour.green) && + (blackColour.blue == whiteColour.blue)) + { + blackColour.red = whiteColour.red ^ maxColour; + blackColour.green = whiteColour.green ^ maxColour; + blackColour.blue = whiteColour.blue ^ maxColour; + } pATIHW->lut[(MONO_BLACK * 3) + 0] = blackColour.red; pATIHW->lut[(MONO_BLACK * 3) + 1] = blackColour.green; @@ -186,6 +224,9 @@ pATIHW->lut[Index + 1] = pATIHW->lut[Index + 2] = 0x00U; } + +#endif /* AVOID_CPIO */ + } } @@ -204,6 +245,33 @@ { int Index; +#ifdef AVOID_CPIO + + pATIHW->dac_read = in8(M64_DAC_READ); + DACDelay; + pATIHW->dac_write = in8(M64_DAC_WRITE); + DACDelay; + pATIHW->dac_mask = in8(M64_DAC_MASK); + DACDelay; + + /* Save DAC's colour lookup table */ + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_READ, 0x00U); + DACDelay; + for (Index = 0; Index < NumberOf(pATIHW->lut); Index++) + { + pATIHW->lut[Index] = in8(M64_DAC_DATA); + DACDelay; + } + + out8(M64_DAC_MASK, pATIHW->dac_mask); + DACDelay; + out8(M64_DAC_READ, pATIHW->dac_read); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, pATIHW->crtc); pATIHW->dac_read = inb(pATI->CPIO_DAC_READ); @@ -228,6 +296,9 @@ DACDelay; outb(pATI->CPIO_DAC_READ, pATIHW->dac_read); DACDelay; + +#endif /* AVOID_CPIO */ + } /* @@ -244,6 +315,28 @@ { int Index; +#ifdef AVOID_CPIO + + /* Load DAC's colour lookup table */ + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_WRITE, 0x00U); + DACDelay; + for (Index = 0; Index < NumberOf(pATIHW->lut); Index++) + { + out8(M64_DAC_DATA, pATIHW->lut[Index]); + DACDelay; + } + + out8(M64_DAC_MASK, pATIHW->dac_mask); + DACDelay; + out8(M64_DAC_READ, pATIHW->dac_read); + DACDelay; + out8(M64_DAC_WRITE, pATIHW->dac_write); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, pATIHW->crtc); /* Load DAC's colour lookup table */ @@ -263,6 +356,9 @@ DACDelay; outb(pATI->CPIO_DAC_WRITE, pATIHW->dac_write); DACDelay; + +#endif /* AVOID_CPIO */ + } /* @@ -334,6 +430,20 @@ Index < (SizeOf(pATI->NewHW.lut) / 3); Index += i, LUTEntry += i * 3) { + +#ifdef AVOID_CPIO + + out8(M64_DAC_WRITE, Index); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[0]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[1]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[2]); + DACDelay; + +#else /* AVOID_CPIO */ + outb(pATI->CPIO_DAC_WRITE, Index); DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); @@ -342,6 +452,9 @@ DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); DACDelay; + +#endif /* AVOID_CPIO */ + } } } @@ -360,6 +473,20 @@ if (pScreenInfo->vtSema || pATI->currentMode) { + +#ifdef AVOID_CPIO + + out8(M64_DAC_WRITE, Index); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[0]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[1]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[2]); + DACDelay; + +#else /* AVOID_CPIO */ + outb(pATI->CPIO_DAC_WRITE, Index); DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); @@ -368,6 +495,9 @@ DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); DACDelay; + +#endif /* AVOID_CPIO */ + } } } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h:1.6 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h Wed Oct 11 18:52:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.9 2000/10/11 22:52:55 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,10 +22,18 @@ */ #ifndef ___ATIDAC_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atidac.h" +# undef XFree86Module +#endif + #define ___ATIDAC_H___ 1 #include "aticrtc.h" -#include "atiio.h" +#include "atipriv.h" +#include "atiproto.h" + #include "colormapst.h" /* @@ -67,22 +75,31 @@ const char *DACName; } DACRec; extern const DACRec ATIDACDescriptors[]; + +#ifdef AVOID_CPIO + +# define DACDelay /* Nothing */ + +#else /* AVOID_CPIO */ + +# define DACDelay \ + do \ + { \ + (void)inb(GENS1(pATI->CPIO_VGABase)); \ + (void)inb(GENS1(pATI->CPIO_VGABase)); \ + } while (0) + + extern void ATISetDACIOPorts FunctionPrototype((ATIPtr, ATICRTCType)); + +#endif /* AVOID_CPIO */ + +extern CARD8 ATIGetDACCmdReg FunctionPrototype((ATIPtr)); -#define DACDelay \ - do \ - { \ - (void)inb(GENS1(pATI->CPIO_VGABase)); \ - (void)inb(GENS1(pATI->CPIO_VGABase)); \ - } while (0) - -extern void ATISetDACIOPorts FunctionPrototype((ATIPtr, ATICRTCType)); -extern CARD8 ATIGetDACCmdReg FunctionPrototype((ATIPtr)); - -extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); -extern void ATIDACSave FunctionPrototype((ATIPtr, ATIHWPtr)); -extern void ATIDACSet FunctionPrototype((ATIPtr, ATIHWPtr)); +extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); +extern void ATIDACSave FunctionPrototype((ATIPtr, ATIHWPtr)); +extern void ATIDACSet FunctionPrototype((ATIPtr, ATIHWPtr)); -extern void ATILoadPalette FunctionPrototype((ScrnInfoPtr, int, int *, LOCO *, - VisualPtr)); +extern void ATILoadPalette FunctionPrototype((ScrnInfoPtr, int, int *, LOCO *, + VisualPtr)); #endif /* ___ATIDAC_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c:1.1 Mon Jun 19 11:02:24 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c Wed Oct 11 18:52:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c,v 1.1 2000/06/19 15:02:24 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c,v 1.4 2000/10/11 22:52:55 tsi Exp $ */ /* * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,10 +22,14 @@ */ #include "ati.h" -#include "atiadapter.h" #include "atiadjust.h" +#include "atichip.h" #include "atidac.h" #include "atidga.h" +#include "atiident.h" +#include "atimode.h" +#include "atistruct.h" + #include "dgaproc.h" /* @@ -117,7 +121,7 @@ pATI->XModifier = pATI->bitsPerPixel / UnitOf(pATI->bitsPerPixel); ATIAdjustPreInit(pATI); - ATIAdapterPreInit(pScreenInfo, pATI, &pATI->NewHW); + ATIModePreInit(pScreenInfo, pATI, &pATI->NewHW); if (!(*pScreenInfo->SwitchMode)(scrnIndex, pMode, 0)) return FALSE; @@ -233,10 +237,14 @@ /* Fill in the mode structure */ pDGAMode->mode = pMode; + pDGAMode->flags = DGA_CONCURRENT_ACCESS; if (bitsPerPixel == pScreenInfo->bitsPerPixel) { pDGAMode->flags |= DGA_PIXMAP_AVAILABLE; pDGAMode->address = pATI->pMemory; + + if (pATI->OptionAccel) + pDGAMode->flags &= ~DGA_CONCURRENT_ACCESS; } if ((pMode->Flags & V_DBLSCAN) || (pMode->VScan > 1)) pDGAMode->flags |= DGA_DOUBLESCAN; @@ -299,6 +307,9 @@ { if (!pATI->nDGAMode) { + +#ifndef AVOID_CPIO + /* * Contrary to previous extension versions, DGA 2 does not support * banked framebuffers. Also, disable DGA when non-DGA server modes @@ -307,34 +318,40 @@ if (pATI->BankInfo.BankSize || (pScreenInfo->depth <= 4)) return FALSE; +#endif /* AVOID_CPIO */ + ATIDGAAddModes(pScreenInfo, pATI, 8, 8, 0, 0, 0, PseudoColor); - ATIDGAAddModes(pScreenInfo, pATI, - 15, 16, 0x7C00U, 0x03E0U, 0x001FU, TrueColor); + if ((pATI->Chip >= ATI_CHIP_264CT) && + (pATI->Chipset == ATI_CHIPSET_ATI)) + { + ATIDGAAddModes(pScreenInfo, pATI, 15, 16, + 0x7C00U, 0x03E0U, 0x001FU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 16, 16, 0xF800U, 0x07E0U, 0x001FU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 16, 16, + 0xF800U, 0x07E0U, 0x001FU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 24, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 32, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); - if (pATI->DAC != ATI_DAC_INTERNAL) /* Not first revision */ - { - ATIDGAAddModes(pScreenInfo, pATI, - 15, 16, 0x7C00U, 0x03E0U, 0x001FU, DirectColor); + if (pATI->DAC != ATI_DAC_INTERNAL) /* Not first revision */ + { + ATIDGAAddModes(pScreenInfo, pATI, 15, 16, + 0x7C00U, 0x03E0U, 0x001FU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 16, 16, 0xF800U, 0x07E0U, 0x001FU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 16, 16, + 0xF800U, 0x07E0U, 0x001FU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 24, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 32, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + } } } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h:1.1 Mon Jun 19 11:02:24 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h Fri Aug 4 17:07:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h,v 1.1 2000/06/19 15:02:24 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h,v 1.2 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern Bool ATIDGAInit FunctionPrototype((ScrnInfoPtr, ScreenPtr, ATIPtr)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c:1.10 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c Fri Aug 4 17:07:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.10 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.12 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,12 +21,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atichip.h" #include "aticrtc.h" #include "atidsp.h" -#include "atiio.h" +#include "atimach64io.h" #include "atividmem.h" -#include "xf86.h" /* * ATIDSPPreInit -- @@ -37,17 +37,13 @@ Bool ATIDSPPreInit ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { CARD32 IOValue, dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off; int trp; - /* Set DSP register port numbers */ - pATI->CPIO_DSP_CONFIG = ATIIOPort(DSP_CONFIG); - pATI->CPIO_DSP_ON_OFF = ATIIOPort(DSP_ON_OFF); - /* * VT-B's and later have additional post-dividers that are not powers of * two. @@ -69,7 +65,7 @@ break; default: - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + xf86DrvMsg(iScreen, X_ERROR, "Unsupported XCLK source: %d.\n", pATI->XCLKPostDivider); return FALSE; } @@ -78,11 +74,11 @@ pATI->XCLKFeedbackDivider = ATIGetMach64PLLReg(PLL_MCLK_FB_DIV); /* Compute maximum RAS delay and friends */ - IOValue = inl(pATI->CPIO_MEM_INFO); - trp = GetBits(IOValue, CTL_MEM_TRP); - pATI->XCLKPageFaultDelay = GetBits(IOValue, CTL_MEM_TRCD) + - GetBits(IOValue, CTL_MEM_TCRD) + trp + 2; - pATI->XCLKMaxRASDelay = GetBits(IOValue, CTL_MEM_TRAS) + trp + 2; + trp = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRP); + pATI->XCLKPageFaultDelay = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRCD) + + GetBits(pATI->LockData.mem_cntl, CTL_MEM_TCRD) + trp + 2; + pATI->XCLKMaxRASDelay = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRAS) + + trp + 2; pATI->DisplayFIFODepth = 32; if (pATI->Chip < ATI_CHIP_264VT4) @@ -140,15 +136,15 @@ pATI->XCLKMaxRASDelay = pATI->XCLKPageFaultDelay + 1; /* Allow BIOS to override */ - dsp_config = inl(pATI->CPIO_DSP_CONFIG); - dsp_on_off = inl(pATI->CPIO_DSP_ON_OFF); - vga_dsp_config = inl(ATIIOPort(VGA_DSP_CONFIG)); - vga_dsp_on_off = inl(ATIIOPort(VGA_DSP_ON_OFF)); + dsp_config = inr(DSP_CONFIG); + dsp_on_off = inr(DSP_ON_OFF); + vga_dsp_config = inr(VGA_DSP_CONFIG); + vga_dsp_on_off = inr(VGA_DSP_ON_OFF); if (dsp_config) pATI->DisplayLoopLatency = GetBits(dsp_config, DSP_LOOP_LATENCY); - if (!dsp_on_off || + if ((!dsp_on_off && (pATI->Chip < ATI_CHIP_264GTPRO)) || ((dsp_on_off == vga_dsp_on_off) && (!dsp_config || !((dsp_config ^ vga_dsp_config) & DSP_XCLKS_PER_QW)))) { @@ -175,8 +171,8 @@ ATIHWPtr pATIHW ) { - pATIHW->dsp_on_off = inl(pATI->CPIO_DSP_ON_OFF); - pATIHW->dsp_config = inl(pATI->CPIO_DSP_CONFIG); + pATIHW->dsp_on_off = inr(DSP_ON_OFF); + pATIHW->dsp_config = inr(DSP_CONFIG); } @@ -209,13 +205,27 @@ Multiplier = pATI->XCLKFeedbackDivider * pATI->ClockDescriptor.PostDividers[pATIHW->PostDivider]; Divider = pATIHW->FeedbackDivider * pATI->XCLKReferenceDivider; + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { Divider *= pATI->bitsPerPixel / 4; - /* Start by assuming a display FIFO width of 32 bits */ - vshift = (5 - 2) - pATI->XCLKPostDivider; - if (pATIHW->crtc != ATI_CRTC_VGA) - vshift++; /* Nope, it's 64 bits wide */ + } + + /* Start by assuming a display FIFO width of 64 bits */ + vshift = (6 - 2) - pATI->XCLKPostDivider; + +#ifndef AVOID_CPIO + if (pATIHW->crtc == ATI_CRTC_VGA) + vshift--; /* Nope, it's 32 bits wide */ + +#endif /* AVOID_CPIO */ + if (!pATI->OptionCRT && (pATI->LCDPanelID >= 0)) { /* Compensate for horizontal stretching */ @@ -243,6 +253,9 @@ vshift, -1) - ATIDivide(1, 1, vshift - xshift, 1); /* Next is dsp_on */ + +#ifndef AVOID_CPIO + if ((pATIHW->crtc == ATI_CRTC_VGA) /* && (dsp_precision < 3) */) { /* @@ -252,6 +265,9 @@ dsp_on = ATIDivide(Multiplier * 5, Divider, vshift + 2, 1); } else + +#endif /* AVOID_CPIO */ + { dsp_on = ATIDivide(Multiplier, Divider, vshift, 1); tmp = ATIDivide(RASMultiplier, RASDivider, xshift, 1); @@ -260,9 +276,16 @@ dsp_on += (tmp * 2) + ATIDivide(pATI->XCLKPageFaultDelay, 1, xshift, 1); } + + /* Calculate rounding factor and apply it to dsp_on */ + tmp = ((1 << (Maximum_DSP_PRECISION - dsp_precision)) - 1) >> 1; + dsp_on = ((dsp_on + tmp) / (tmp + 1)) * (tmp + 1); - if (dsp_on >= dsp_off) + if (dsp_on >= ((dsp_off / (tmp + 1)) * (tmp + 1))) + { dsp_on = dsp_off - ATIDivide(Multiplier, Divider, vshift, -1); + dsp_on = (dsp_on / (tmp + 1)) * (tmp + 1); + } /* Last but not least: dsp_xclks */ dsp_xclks = ATIDivide(Multiplier, Divider, vshift + 5, 1); @@ -287,6 +310,6 @@ ATIHWPtr pATIHW ) { - outl(pATI->CPIO_DSP_ON_OFF, pATIHW->dsp_on_off); - outl(pATI->CPIO_DSP_CONFIG, pATIHW->dsp_config); + outr(DSP_ON_OFF, pATIHW->dsp_on_off); + outr(DSP_CONFIG, pATIHW->dsp_config); } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h:1.6 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h Fri Aug 4 17:07:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,9 +26,10 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" -extern Bool ATIDSPPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr)); +extern Bool ATIDSPPreInit FunctionPrototype((int, ATIPtr)); extern void ATIDSPSave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIDSPCalculate FunctionPrototype((ATIPtr, ATIHWPtr, DisplayModePtr)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c:1.5 Fri Feb 18 07:19:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c Thu Nov 2 11:55:27 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.5 2000/02/18 12:19:22 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.7 2000/11/02 16:55:27 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,21 +25,35 @@ #include "atiident.h" #include "ativersion.h" +#include "r128_probe.h" +#include "radeon_probe.h" + const char *ATIChipsetNames[] = { "ati", + +#ifndef AVOID_CPIO + "ativga", "ibmvga", "ibm8514", "vgawonder", "mach8", "mach32", - "mach64" + +#endif /* AVOID_CPIO */ + + "mach64", + "rage128", + "radeon" }; static SymTabRec ATIPublicChipsetNames[] = { {ATI_CHIPSET_ATI, "ati"}, + +#ifndef AVOID_CPIO + {ATI_CHIPSET_ATIVGA, "ativga"}, #ifdef __MAYBE_NOT__ {ATI_CHIPSET_IBMVGA, "ibmvga"}, @@ -47,6 +61,9 @@ #ifdef __NOT_YET__ {ATI_CHIPSET_IBM8514, "ibm8514"}, #endif + +#endif /* AVOID_CPIO */ + {-1, NULL} }; @@ -64,6 +81,8 @@ xf86PrintChipsets(ATI_NAME, "ATI driver (version " ATI_VERSION_NAME ") for chipsets", ATIPublicChipsetNames); + R128Identify(flags); + RADEONIdentify(flags); } /* @@ -82,13 +101,20 @@ static SymTabRec SpecificNames[] = { + +#ifndef AVOID_CPIO + {ATI_CHIPSET_VGAWONDER, "vgawonder"}, #ifdef __NOT_YET__ {ATI_CHIPSET_MACH8, "mach8"}, #endif {ATI_CHIPSET_MACH32, "mach32"}, + +#endif /* AVOID_CPIO */ + {ATI_CHIPSET_MACH64, "mach64"}, {ATI_CHIPSET_RAGE128, "rage128"}, + {ATI_CHIPSET_RADEON, "radeon"}, {-1, NULL} }; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h:1.6 Fri Feb 18 07:19:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h Fri Aug 4 17:07:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h,v 1.6 2000/02/18 12:19:23 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,14 +29,21 @@ typedef enum { ATI_CHIPSET_ATI, + +#ifndef AVOID_CPIO + ATI_CHIPSET_ATIVGA, ATI_CHIPSET_IBMVGA, ATI_CHIPSET_IBM8514, ATI_CHIPSET_VGAWONDER, ATI_CHIPSET_MACH8, ATI_CHIPSET_MACH32, + +#endif /* AVOID_CPIO */ + ATI_CHIPSET_MACH64, ATI_CHIPSET_RAGE128, + ATI_CHIPSET_RADEON, ATI_CHIPSET_MAX /* Must be last */ } ATIChipsetType; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c:1.4 Fri Feb 18 07:19:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c Mon Dec 18 14:29:58 2000 @@ -1,119 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c,v 1.4 2000/02/18 12:19:23 tsi Exp $ */ -/* - * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "atichip.h" -#include "atiio.h" - -/* - * ATISetVGAIOBase -- - * - * This sets vgaIOBase according to the value of the passed value of the - * miscellaneous output register. - */ -void -ATISetVGAIOBase -( - ATIPtr pATI, - const CARD8 misc -) -{ - pATI->CPIO_VGABase = (misc & 0x01U) ? ColourIOBase : MonochromeIOBase; -} - -/* - * ATIModifyExtReg -- - * - * This function is called to modify certain bits in an ATI extended VGA - * register while preserving its other bits. The function will not write the - * register if it turns out its value would not change. This helps prevent - * server hangs on older adapters. - */ -void -ATIModifyExtReg -( - ATIPtr pATI, - const CARD8 Index, - int CurrentValue, - const CARD8 CurrentMask, - CARD8 NewValue -) -{ - /* Possibly retrieve the current value */ - if (CurrentValue < 0) - CurrentValue = ATIGetExtReg(Index); - - /* Compute new value */ - NewValue &= (CARD8)(~CurrentMask); - NewValue |= CurrentValue & CurrentMask; - - /* Check if value will be changed */ - if (CurrentValue == NewValue) - return; - - /* - * The following is taken from ATI's VGA Wonder programmer's reference - * manual which says that this is needed to "ensure the proper state of the - * 8/16 bit ROM toggle". I suspect a timing glitch appeared in the 18800 - * after its die was cast. 18800-1 and later chips do not exhibit this - * problem. - */ - if ((pATI->Chip <= ATI_CHIP_18800) && (Index == 0xB2U) && - ((NewValue ^ 0x40U) & CurrentValue & 0x40U)) - { - CARD8 misc = inb(R_GENMO); - CARD8 bb = ATIGetExtReg(0xBBU); - - outb(GENMO, (misc & 0xF3U) | 0x04U | ((bb & 0x10U) >> 1)); - CurrentValue &= (CARD8)(~0x40U); - ATIPutExtReg(0xB2U, CurrentValue); - ATIDelay(5); - outb(GENMO, misc); - ATIDelay(5); - if (CurrentValue != NewValue) - ATIPutExtReg(0xB2U, NewValue); - } - else - ATIPutExtReg(Index, NewValue); -} - -/* - * ATIAccessMach64PLLReg -- - * - * This function sets up the addressing required to access, for read or write, - * a 264xT's PLL registers. - */ -void -ATIAccessMach64PLLReg -( - ATIPtr pATI, - const CARD8 Index, - const Bool Write -) -{ - CARD8 clock_cntl1 = inb(pATI->CPIO_CLOCK_CNTL + 1) & - ~GetByte(PLL_WR_EN | PLL_ADDR, 1); - - /* Set PLL register to be read or written */ - outb(pATI->CPIO_CLOCK_CNTL + 1, clock_cntl1 | - GetByte(SetBits(Index, PLL_ADDR) | SetBits(Write, PLL_WR_EN), 1)); -} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h:1.7 xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h:1.7 Thu Mar 30 10:41:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h Wed Oct 11 18:52:56 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.7 2000/03/30 15:41:17 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.10 2000/10/11 22:52:56 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,13 +22,19 @@ */ #ifndef ___ATIIO_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atiio.h" +# undef XFree86Module +#endif + #define ___ATIIO_H___ 1 +#include "atiregs.h" + #ifndef NO_COMPILER_H_EXTRAS -#define NO_COMPILER_H_EXTRAS +# define NO_COMPILER_H_EXTRAS #endif - -#include "atistruct.h" #include "compiler.h" /* I/O decoding definitions */ @@ -38,68 +44,7 @@ BLOCK_IO } ATIIODecodingType; -#define ATIIOPort(_PortTag) \ - (((pATI->CPIODecoding == SPARSE_IO) ? \ - (((_PortTag) & SPARSE_IO_SELECT) | ((_PortTag) & IO_BYTE_SELECT)) : \ - (((_PortTag) & BLOCK_IO_SELECT) | ((_PortTag) & IO_BYTE_SELECT))) | \ - pATI->CPIOBase) - -extern void ATISetVGAIOBase FunctionPrototype((ATIPtr, const CARD8)); -extern void ATIModifyExtReg FunctionPrototype((ATIPtr, const CARD8, int, - const CARD8, CARD8)); - -/* Odds and ends to ease reading and writting of registers */ -#define GetReg(_Register, _Index) \ - ( \ - outb(_Register, _Index), \ - inb((_Register) + 1) \ - ) -#define PutReg(_Register, _Index, _Value) \ - ( \ - outb(_Register, _Index), \ - outb((_Register) + 1, _Value) \ - ) - -#define ATIGetExtReg(_Index) \ - GetReg(pATI->CPIO_VGAWonder, _Index) -#define ATIPutExtReg(_Index, _Value) \ - PutReg(pATI->CPIO_VGAWonder, _Index, _Value) - -extern void ATIAccessMach64PLLReg FunctionPrototype((ATIPtr, const CARD8, - const Bool)); - -#define ATIGetMach64PLLReg(_Index) \ - ( \ - ATIAccessMach64PLLReg(pATI, _Index, FALSE), \ - inb(pATI->CPIO_CLOCK_CNTL + 2) \ - ) -#define ATIPutMach64PLLReg(_Index, _Value) \ - ( \ - ATIAccessMach64PLLReg(pATI, _Index, TRUE), \ - outb(pATI->CPIO_CLOCK_CNTL + 2, _Value) \ - ) - -#define ATIGetLTProLCDReg(_Index) \ - ( \ - outb(pATI->CPIO_LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ - inl(pATI->CPIO_LCD_DATA) \ - ) -#define ATIPutLTProLCDReg(_Index, _Value) \ - ( \ - outb(pATI->CPIO_LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ - outl(pATI->CPIO_LCD_DATA, (_Value)) \ - ) - -#define ATIGetLTProTVReg(_Index) \ - ( \ - outb(pATI->CPIO_TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ - inl(pATI->CPIO_TV_OUT_DATA) \ - ) -#define ATIPutLTProTVReg(_Index, _Value) \ - ( \ - outb(pATI->CPIO_TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ - outl(pATI->CPIO_TV_OUT_DATA, (_Value)) \ - ) +#ifndef AVOID_CPIO /* Wait until "n" queue entries are free */ #define ibm8514WaitQueue(_n) \ @@ -135,5 +80,7 @@ { \ while (!(inw(GP_STAT) & DATARDY)); \ } + +#endif /* AVOID_CPIO */ #endif /* ___ATIIO_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c:1.1 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c Fri Oct 13 09:27:00 2000 @@ -0,0 +1,132 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.c,v 1.1 2000/10/13 13:27:00 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef XFree86LOADER + +#include "ati.h" +#include "atiload.h" +#include "atistruct.h" + +/* + * ATILoadModule -- + * + * Load a specific module and register its main entry with the loader. + */ +static Bool +ATILoadModule +( + ScrnInfoPtr pScreenInfo, + const char *Module, + const char *Symbol +) +{ + if (!xf86LoadSubModule(pScreenInfo, Module)) + return FALSE; + + xf86LoaderReqSymbols(Symbol, NULL); + + return TRUE; +} + +/* + * ATILoadModules -- + * + * This function loads other modules required for a screen. + */ +Bool +ATILoadModules +( + ScrnInfoPtr pScreenInfo, + ATIPtr pATI +) +{ + /* + * Tell loader about symbols from other modules that this module might + * refer to. + */ + LoaderRefSymbols( + +#ifndef AVOID_CPIO + + "xf1bppScreenInit", + "xf4bppScreenInit", + +#endif /* AVOID_CPIO */ + + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb32ScreenInit", + "ShadowFBInit", + "XAACreateInfoRec", + "XAADestroyInfoRec", + "XAAInit", + NULL); + + /* Load shadow frame buffer code if needed */ + if (pATI->OptionShadowFB && + !ATILoadModule(pScreenInfo, "shadowfb", "ShadowFBInit")) + return FALSE; + + /* Load XAA if needed */ + if (pATI->OptionAccel) + { + if (!ATILoadModule(pScreenInfo, "xaa", "XAAInit")) + return FALSE; + + /* Require more XAA symbols */ + xf86LoaderReqSymbols("XAACreateInfoRec", "XAADestroyInfoRec", NULL); + } + + /* Load depth-specific entry points */ + switch (pATI->bitsPerPixel) + { + +#ifndef AVOID_CPIO + + case 1: + return ATILoadModule(pScreenInfo, "xf1bpp", "xf1bppScreenInit"); + + case 4: + return ATILoadModule(pScreenInfo, "xf4bpp", "xf4bppScreenInit"); + +#endif /* AVOID_CPIO */ + + case 8: + return ATILoadModule(pScreenInfo, "cfb", "cfbScreenInit"); + + case 16: + return ATILoadModule(pScreenInfo, "cfb16", "cfb16ScreenInit"); + + case 24: + return ATILoadModule(pScreenInfo, "cfb24", "cfb24ScreenInit"); + + case 32: + return ATILoadModule(pScreenInfo, "cfb32", "cfb32ScreenInit"); + + default: + return FALSE; + } +} + +#endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h:1.1 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h Fri Oct 13 09:27:00 2000 @@ -0,0 +1,34 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiload.h,v 1.1 2000/10/13 13:27:00 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if defined(XFree86LOADER) && !defined(___ATILOAD_H___) +#define ___ATILOAD_H___ 1 + +#include "atipriv.h" +#include "atiproto.h" + +#include "xf86str.h" + +extern Bool ATILoadModules FunctionPrototype((ScrnInfoPtr, ATIPtr)); + +#endif /* ___ATILOAD_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c:1.6 Tue Mar 21 22:08:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c Wed Oct 11 18:52:56 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.6 2000/03/22 03:08:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.8 2000/10/11 22:52:56 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,8 +24,9 @@ #include "ati.h" #include "atiadapter.h" #include "atichip.h" -#include "atiio.h" #include "atilock.h" +#include "atimach64io.h" +#include "atiwonderio.h" /* * ATIUnlock -- @@ -39,12 +40,20 @@ ATIPtr pATI ) { - CARD32 tmp, saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; + CARD32 tmp; + +#ifndef AVOID_CPIO + + CARD32 saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; +#endif /* AVOID_CPIO */ + if (pATI->Unlocked) return; pATI->Unlocked = TRUE; +#ifndef AVOID_CPIO + if (pATI->ChipHasSUBSYS_CNTL) { /* Save register values to be modified */ @@ -83,15 +92,13 @@ ProbeWaitIdleEmpty(); } else if (pATI->Chip >= ATI_CHIP_88800GXC) - { - /* Save register values to be modified */ - pATI->LockData.config_cntl = inl(pATI->CPIO_CONFIG_CNTL); - pATI->LockData.dac_cntl = inl(pATI->CPIO_DAC_CNTL); +#endif /* AVOID_CPIO */ + + { /* Reset everything */ pATI->LockData.bus_cntl = - (inl(pATI->CPIO_BUS_CNTL) & ~BUS_HOST_ERR_INT_EN) | - BUS_HOST_ERR_INT; + (inr(BUS_CNTL) & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT; if (pATI->Chip < ATI_CHIP_264VTB) pATI->LockData.bus_cntl = (pATI->LockData.bus_cntl & ~BUS_FIFO_ERR_INT_EN) | @@ -100,44 +107,55 @@ SetBits(15, BUS_FIFO_WS); if (pATI->Chip >= ATI_CHIP_264VT) tmp |= BUS_EXT_REG_EN; /* Enable Block 1 */ - outl(pATI->CPIO_BUS_CNTL, tmp); - pATI->LockData.crtc_int_cntl = inl(pATI->CPIO_CRTC_INT_CNTL); - outl(pATI->CPIO_CRTC_INT_CNTL, - (pATI->LockData.crtc_int_cntl & ~CRTC_INT_ENS) | CRTC_INT_ACKS); - pATI->LockData.gen_test_cntl = inl(pATI->CPIO_GEN_TEST_CNTL) & + outr(BUS_CNTL, tmp); + pATI->LockData.crtc_int_cntl = inr(CRTC_INT_CNTL); + outr(CRTC_INT_CNTL, (pATI->LockData.crtc_int_cntl & ~CRTC_INT_ENS) | + CRTC_INT_ACKS); + pATI->LockData.gen_test_cntl = inr(GEN_TEST_CNTL) & (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); tmp = pATI->LockData.gen_test_cntl & ~GEN_CUR_EN; - outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, tmp); - outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN); - tmp = pATI->LockData.crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & + outr(GEN_TEST_CNTL, tmp | GEN_GUI_EN); + outr(GEN_TEST_CNTL, tmp); + outr(GEN_TEST_CNTL, tmp | GEN_GUI_EN); + tmp = pATI->LockData.crtc_gen_cntl = inr(CRTC_GEN_CNTL) & ~(CRTC_EN | CRTC_LOCK_REGS); if (pATI->Chip >= ATI_CHIP_264XL) tmp = (tmp & ~CRTC_INT_ENS_X) | CRTC_INT_ACKS_X; - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp | CRTC_EN); - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp); - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp | CRTC_EN); + outr(CRTC_GEN_CNTL, tmp | CRTC_EN); + outr(CRTC_GEN_CNTL, tmp); + outr(CRTC_GEN_CNTL, tmp | CRTC_EN); if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) { - pATI->LockData.lcd_index = inl(pATI->CPIO_LCD_INDEX); + pATI->LockData.lcd_index = inr(LCD_INDEX); if (pATI->Chip >= ATI_CHIP_264XL) - outl(pATI->CPIO_LCD_INDEX, pATI->LockData.lcd_index & + outr(LCD_INDEX, pATI->LockData.lcd_index & ~(LCD_MONDET_INT_EN | LCD_MONDET_INT)); } +#ifndef AVOID_CPIO + /* Ensure VGA aperture is enabled */ - outl(pATI->CPIO_DAC_CNTL, pATI->LockData.dac_cntl | DAC_VGA_ADR_EN); - outl(pATI->CPIO_CONFIG_CNTL, - pATI->LockData.config_cntl & ~CFG_VGA_DIS); + pATI->LockData.config_cntl = inr(CONFIG_CNTL); + pATI->LockData.dac_cntl = inr(DAC_CNTL); + outr(DAC_CNTL, pATI->LockData.dac_cntl | DAC_VGA_ADR_EN); + outr(CONFIG_CNTL, pATI->LockData.config_cntl & ~CFG_VGA_DIS); + +#endif /* AVOID_CPIO */ + + pATI->LockData.mem_cntl = inr(MEM_CNTL); if (pATI->Chip < ATI_CHIP_264CT) - { - pATI->LockData.mem_info = inl(pATI->CPIO_MEM_INFO); - outl(pATI->CPIO_MEM_INFO, pATI->LockData.mem_info & + outr(MEM_CNTL, pATI->LockData.mem_cntl & ~(CTL_MEM_BNDRY | CTL_MEM_BNDRY_EN)); - } + else if (pATI->Chip >= ATI_CHIP_264VTB) + outr(MEM_CNTL, (pATI->LockData.mem_cntl & + ~(CTL_MEM_LOWER_APER_ENDIAN | CTL_MEM_UPPER_APER_ENDIAN)) | + (SetBits(CTL_MEM_APER_BYTE_ENDIAN, CTL_MEM_LOWER_APER_ENDIAN) | + SetBits(CTL_MEM_APER_LONG_ENDIAN, CTL_MEM_UPPER_APER_ENDIAN))); } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { if (pATI->CPIO_VGAWonder) @@ -178,23 +196,23 @@ { if (pATI->Chip == ATI_CHIP_264LT) { - saved_lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + saved_lcd_gen_ctrl = inr(LCD_GEN_CTRL); /* Setup to unlock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - saved_lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + saved_lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); /* Setup to unlock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); } } @@ -256,11 +274,11 @@ lcd_gen_ctrl |= SHADOW_EN | SHADOW_RW_EN; if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); /* Unlock shadow registers */ ATISetVGAIOBase(pATI, inb(R_GENMO)); @@ -276,6 +294,11 @@ GetReg(CRTX(pATI->CPIO_VGABase), 0x11U); if (tmp & 0x80U) /* Unprotect CRTC[0-7] */ outb(CRTD(pATI->CPIO_VGABase), tmp & 0x7FU); + else if (!tmp && pATI->LockData.crt11) + { + pATI->LockData.shadow_crt11 = tmp = pATI->LockData.crt11; + outb(CRTD(pATI->CPIO_VGABase), tmp & 0x7FU); + } } else { @@ -312,19 +335,21 @@ /* Restore selection */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, saved_lcd_gen_ctrl); + outr(LCD_GEN_CTRL, saved_lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - ATIPutLTProLCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); /* Restore LCD index */ - outb(pATI->CPIO_LCD_INDEX, - GetByte(pATI->LockData.lcd_index, 0)); + out8(LCD_INDEX, GetByte(pATI->LockData.lcd_index, 0)); } } } + +#endif /* AVOID_CPIO */ + } /* @@ -338,35 +363,42 @@ ATIPtr pATI ) { + +#ifndef AVOID_CPIO + CARD32 tmp, saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; +#endif /* AVOID_CPIO */ + if (!pATI->Unlocked) return; pATI->Unlocked = FALSE; +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { if (pATI->LCDPanelID >= 0) { if (pATI->Chip == ATI_CHIP_264LT) { - saved_lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + saved_lcd_gen_ctrl = inr(LCD_GEN_CTRL); /* Setup to lock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - saved_lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + saved_lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); /* Setup to lock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); } } @@ -382,11 +414,11 @@ lcd_gen_ctrl |= SHADOW_EN | SHADOW_RW_EN; if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); /* Lock shadow registers */ ATISetVGAIOBase(pATI, inb(R_GENMO)); @@ -398,11 +430,11 @@ /* Restore selection */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, saved_lcd_gen_ctrl); + outr(LCD_GEN_CTRL, saved_lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); } if (pATI->CPIO_VGAWonder) @@ -452,30 +484,32 @@ ProbeWaitIdleEmpty(); } else if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { /* Reset everything */ - outl(pATI->CPIO_BUS_CNTL, pATI->LockData.bus_cntl); + outr(BUS_CNTL, pATI->LockData.bus_cntl); - outl(pATI->CPIO_CRTC_INT_CNTL, pATI->LockData.crtc_int_cntl); + outr(CRTC_INT_CNTL, pATI->LockData.crtc_int_cntl); - outl(pATI->CPIO_GEN_TEST_CNTL, - pATI->LockData.gen_test_cntl | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, pATI->LockData.gen_test_cntl); - outl(pATI->CPIO_GEN_TEST_CNTL, - pATI->LockData.gen_test_cntl | GEN_GUI_EN); - - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATI->LockData.crtc_gen_cntl | CRTC_EN); - outl(pATI->CPIO_CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl); - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATI->LockData.crtc_gen_cntl | CRTC_EN); - - /* Restore registers */ - outl(pATI->CPIO_CONFIG_CNTL, pATI->LockData.config_cntl); - outl(pATI->CPIO_DAC_CNTL, pATI->LockData.dac_cntl); - if (pATI->Chip < ATI_CHIP_264CT) - outl(pATI->CPIO_MEM_INFO, pATI->LockData.mem_info); - else if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) - outl(pATI->CPIO_LCD_INDEX, pATI->LockData.lcd_index); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl | GEN_GUI_EN); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl | GEN_GUI_EN); + + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl | CRTC_EN); + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl); + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl | CRTC_EN); + +#ifndef AVOID_CPIO + + outr(CONFIG_CNTL, pATI->LockData.config_cntl); + outr(DAC_CNTL, pATI->LockData.dac_cntl); + +#endif /* AVOID_CPIO */ + + outr(MEM_CNTL, pATI->LockData.mem_cntl); + if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) + outr(LCD_INDEX, pATI->LockData.lcd_index); } } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c:1.21 xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c:1.27 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c:1.21 Mon Jun 19 11:00:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c Tue Dec 12 19:25:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.21 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.27 2000/12/13 00:25:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,7 +27,7 @@ * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sub license, and/or + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * @@ -47,116 +47,17 @@ #include "ati.h" #include "atibus.h" #include "atichip.h" -#include "atiio.h" #include "atimach64.h" +#include "atimach64io.h" + #include "miline.h" -#define DPMS_SERVER +#ifndef DPMS_SERVER +# define DPMS_SERVER +#endif #include "extensions/dpms.h" /* - * Note: Only 32-bit MMIO is needed here. - */ - -#define inm(_Register) \ - MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ - (_Register) & MM_IO_SELECT) - -/* - * ATIMach64PollEngineStatus -- - * - * This function refreshes the driver's view of the draw engine's status. - */ -static void -ATIMach64PollEngineStatus -( - ATIPtr pATI -) -{ - CARD32 IOValue; - int Count; - - if (pATI->Chip < ATI_CHIP_264VTB) - { - /* - * TODO: Deal with locked engines. - */ - IOValue = inm(FIFO_STAT); - pATI->EngineIsLocked = GetBits(IOValue, FIFO_ERR); - - /* - * The following counts the number of bits in FIFO_STAT_BITS, and is - * derived from miSetVisualTypes() (formerly cfbSetVisualTypes()). - */ - IOValue = GetBits(IOValue, FIFO_STAT_BITS); - Count = (IOValue >> 1) & 0x36DBU; - Count = IOValue - Count - ((Count >> 1) & 0x36DBU); - Count = ((Count + (Count >> 3)) & 0x71C7U) % 0x3FU; - Count = pATI->nFIFOEntries - Count; - if (Count > pATI->nAvailableFIFOEntries) - pATI->nAvailableFIFOEntries = Count; - - /* - * If the command FIFO is non-empty, then the engine isn't idle. - */ - if (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries) - { - pATI->EngineIsBusy = TRUE; - return; - } - } - - IOValue = inm(GUI_STAT); - pATI->EngineIsBusy = GetBits(IOValue, GUI_ACTIVE); - Count = GetBits(IOValue, GUI_FIFO); - if (Count > pATI->nAvailableFIFOEntries) - pATI->nAvailableFIFOEntries = Count; -} - -/* - * MMIO cache definitions. - */ -#define CacheByte(___Register) pATI->MMIOCached[CacheSlotOf(___Register) >> 3] -#define CacheBit(___Register) (0x80U >> (CacheSlotOf(___Register) & 0x07U)) - -#define RegisterIsCached(__Register) \ - (CacheByte(__Register) & CacheBit(__Register)) -#define CacheRegister(__Register) \ - CacheByte(__Register) |= CacheBit(__Register) -#define UncacheRegister(__Register) \ - CacheByte(__Register) &= ~CacheBit(__Register) - -#define CacheSlot(__Register) pATI->MMIOCache[CacheSlotOf(__Register)] - -/* This would be quite a bit slower as a function */ -#define outm(_Register, _Value) \ - do \ - { \ - CARD32 _IOValue = (_Value); \ - \ - if (!RegisterIsCached(_Register) || \ - (_IOValue != CacheSlot(_Register))) \ - { \ - while (!pATI->nAvailableFIFOEntries--) \ - ATIMach64PollEngineStatus(pATI); \ - MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ - (_Register) & MM_IO_SELECT, _IOValue); \ - CacheSlot(_Register) = _IOValue; \ - pATI->EngineIsBusy = TRUE; \ - } \ - } while (0) - -/* This is no longer as critical, especially for _n == 1 */ -#define ATIMach64WaitForFIFO(_n) \ - while ((pATI->nAvailableFIFOEntries < (_n)) && \ - (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries)) \ - ATIMach64PollEngineStatus(pATI) - -#define ATIMach64WaitForIdle() \ - while (pATI->EngineIsBusy) \ - ATIMach64PollEngineStatus(pATI) - -/* * X-to-Mach64 mix translation table. */ static CARD8 ATIMach64ALU[16] = @@ -196,12 +97,19 @@ CARD32 bus_cntl, config_cntl; int tmp; +#ifndef AVOID_CPIO + if (pATI->depth <= 4) pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 4, CRTC_PITCH); else + +#endif /* AVOID_CPIO */ + + { pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 3, CRTC_PITCH); + } - bus_cntl = inl(pATI->CPIO_BUS_CNTL); + bus_cntl = inr(BUS_CNTL); pATIHW->bus_cntl = (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT; if (pATI->Chip < ATI_CHIP_264VTB) { @@ -212,27 +120,43 @@ pATIHW->bus_cntl |= BUS_APER_REG_DIS; if (pATI->Chip >= ATI_CHIP_264VT) pATIHW->bus_cntl |= BUS_EXT_REG_EN; /* Enable Block 1 */ + +#ifdef AVOID_CPIO + + pATIHW->mem_vga_wp_sel = SetBits(0, MEM_VGA_WPS0) | + SetBits(1, MEM_VGA_WPS1); + pATIHW->mem_vga_rp_sel = SetBits(0, MEM_VGA_RPS0) | + SetBits(1, MEM_VGA_RPS1); - pATIHW->mem_vga_wp_sel = - /* SetBits(0, MEM_VGA_WPS0) | */ +#else /* AVOID_CPIO */ + + pATIHW->mem_vga_wp_sel = SetBits(0, MEM_VGA_WPS0) | SetBits(pATIHW->nPlane, MEM_VGA_WPS1); - pATIHW->mem_vga_rp_sel = - /* SetBits(0, MEM_VGA_RPS0) | */ + pATIHW->mem_vga_rp_sel = SetBits(0, MEM_VGA_RPS0) | SetBits(pATIHW->nPlane, MEM_VGA_RPS1); + +#endif /* AVOID_CPIO */ - pATIHW->dac_cntl = inl(pATI->CPIO_DAC_CNTL) & + pATIHW->dac_cntl = inr(DAC_CNTL) & ~(DAC1_CLK_SEL | DAC_PALETTE_ACCESS_CNTL | DAC_8BIT_EN); if ((pATI->depth > 8) || (pScreenInfo->rgbBits == 8)) pATIHW->dac_cntl |= DAC_8BIT_EN; + + pATIHW->config_cntl = config_cntl = inr(CONFIG_CNTL); + +#ifndef AVOID_CPIO - pATIHW->config_cntl = config_cntl = inl(pATI->CPIO_CONFIG_CNTL); if (pATI->UseSmallApertures) pATIHW->config_cntl |= CFG_MEM_VGA_AP_EN; else + +#endif /* AVOID_CPIO */ + + { pATIHW->config_cntl &= ~CFG_MEM_VGA_AP_EN; - if (pATI->LinearBase && - ((pATI->Chip < ATI_CHIP_264CT) || - ((pATI->BusType != ATI_BUS_PCI) && (pATI->BusType != ATI_BUS_AGP)))) + } + + if (pATI->LinearBase && (pATI->Chip < ATI_CHIP_264CT)) { /* Replace linear aperture size and address */ pATIHW->config_cntl &= ~(CFG_MEM_AP_LOC | CFG_MEM_AP_SIZE); @@ -247,8 +171,8 @@ if (pATI->OptionAccel) { /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); /* * When possible, max out command FIFO size. @@ -274,6 +198,10 @@ if (tmp > ATIMach64MaxY) tmp = ATIMach64MaxY; pATIHW->sc_bottom = tmp; + pATI->sc_left_right = SetWord(pATI->NewHW.sc_right, 1) | + SetWord(pATI->NewHW.sc_left, 0); + pATI->sc_top_bottom = SetWord(pATI->NewHW.sc_bottom, 1) | + SetWord(pATI->NewHW.sc_top, 0); /* Initialise data path */ pATIHW->dp_frgd_clr = (CARD32)(-1); @@ -283,7 +211,7 @@ { case 8: pATIHW->dp_chain_mask = DP_CHAIN_8BPP; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -291,7 +219,7 @@ case 15: pATIHW->dp_chain_mask = DP_CHAIN_15BPP_1555; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_15BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_15BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -299,7 +227,7 @@ case 16: pATIHW->dp_chain_mask = DP_CHAIN_16BPP_565; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_16BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_16BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -309,7 +237,7 @@ if (pATI->bitsPerPixel == 24) { pATIHW->dp_chain_mask = DP_CHAIN_24BPP_888; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -317,7 +245,7 @@ else { pATIHW->dp_chain_mask = DP_CHAIN_32BPP_8888; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_32BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_32BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -334,11 +262,11 @@ SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC); /* Initialise colour compare */ - pATIHW->clr_cmp_msk = (CARD32)(-1); + pATIHW->clr_cmp_msk = (1 << pATI->depth) - 1; /* Restore aperture enablement */ - outl(pATI->CPIO_BUS_CNTL, bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, config_cntl); + outr(BUS_CNTL, bus_cntl); + outr(CONFIG_CNTL, config_cntl); } } @@ -355,38 +283,38 @@ ATIHWPtr pATIHW ) { - pATIHW->crtc_h_total_disp = inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->crtc_h_sync_strt_wid = inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->crtc_v_total_disp = inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->crtc_v_sync_strt_wid = inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); + pATIHW->crtc_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->crtc_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->crtc_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->crtc_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); - pATIHW->crtc_off_pitch = inl(pATI->CPIO_CRTC_OFF_PITCH); + pATIHW->crtc_off_pitch = inr(CRTC_OFF_PITCH); - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL); + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL); - pATIHW->ovr_clr = inl(pATI->CPIO_OVR_CLR); - pATIHW->ovr_wid_left_right = inl(pATI->CPIO_OVR_WID_LEFT_RIGHT); - pATIHW->ovr_wid_top_bottom = inl(pATI->CPIO_OVR_WID_TOP_BOTTOM); + pATIHW->ovr_clr = inr(OVR_CLR); + pATIHW->ovr_wid_left_right = inr(OVR_WID_LEFT_RIGHT); + pATIHW->ovr_wid_top_bottom = inr(OVR_WID_TOP_BOTTOM); - pATIHW->clock_cntl = inl(pATI->CPIO_CLOCK_CNTL); + pATIHW->clock_cntl = inr(CLOCK_CNTL); - pATIHW->bus_cntl = inl(pATI->CPIO_BUS_CNTL); + pATIHW->bus_cntl = inr(BUS_CNTL); - pATIHW->mem_vga_wp_sel = inl(pATI->CPIO_MEM_VGA_WP_SEL); - pATIHW->mem_vga_rp_sel = inl(pATI->CPIO_MEM_VGA_RP_SEL); + pATIHW->mem_vga_wp_sel = inr(MEM_VGA_WP_SEL); + pATIHW->mem_vga_rp_sel = inr(MEM_VGA_RP_SEL); - pATIHW->dac_cntl = inl(pATI->CPIO_DAC_CNTL); + pATIHW->dac_cntl = inr(DAC_CNTL); - pATIHW->config_cntl = inl(pATI->CPIO_CONFIG_CNTL); + pATIHW->config_cntl = inr(CONFIG_CNTL); /* Save draw engine state */ if (pATI->OptionAccel && (pATIHW == &pATI->OldHW)) { /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl); + outr(BUS_CNTL, pATI->NewHW.bus_cntl); + outr(CONFIG_CNTL, pATI->NewHW.config_cntl); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); /* Save FIFO size */ if (pATI->Chip >= ATI_CHIP_264VT4) @@ -423,10 +351,10 @@ pATIHW->pat_cntl = inm(PAT_CNTL); /* Save scissor registers */ - pATIHW->sc_left = inm(SC_LEFT); - pATIHW->sc_right = inm(SC_RIGHT); - pATIHW->sc_top = inm(SC_TOP); - pATIHW->sc_bottom = inm(SC_BOTTOM); + pATIHW->sc_left = pATI->sc_left = inm(SC_LEFT); + pATIHW->sc_right = pATI->sc_right = inm(SC_RIGHT); + pATIHW->sc_top = pATI->sc_top = inm(SC_TOP); + pATIHW->sc_bottom = pATI->sc_bottom = inm(SC_BOTTOM); /* Save data path registers */ pATIHW->dp_bkgd_clr = inm(DP_BKGD_CLR); @@ -446,8 +374,8 @@ pATIHW->context_mask = inm(CONTEXT_MASK); /* Restore aperture enablement */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); } } @@ -565,7 +493,7 @@ if (pMode->Flags & V_NVSYNC) pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL) & ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | CRTC_VGA_XOVERSCAN | @@ -578,21 +506,31 @@ CRTC_EXT_DISP_EN | CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; switch (pATI->depth) { + +#ifndef AVOID_CPIO + case 1: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_1BPP, CRTC_PIX_WIDTH); break; + case 4: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_4BPP, CRTC_PIX_WIDTH); break; + +#endif /* AVOID_CPIO */ + case 8: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_8BPP, CRTC_PIX_WIDTH); break; + case 15: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_15BPP, CRTC_PIX_WIDTH); break; + case 16: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_16BPP, CRTC_PIX_WIDTH); break; + case 24: if (pATI->bitsPerPixel == 24) { @@ -603,9 +541,11 @@ if (pATI->bitsPerPixel != 32) break; /* Fall through */ + case 32: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_32BPP, CRTC_PIX_WIDTH); break; + default: break; } @@ -633,30 +573,30 @@ ) { /* First, turn off the display */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); if ((pATIHW->FeedbackDivider > 0) && (pATI->ProgrammableClock != ATI_CLOCK_NONE)) ATIClockSet(pATI, pATIHW); /* Programme clock */ /* Load Mach64 CRTC registers */ - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); + outr(CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); - outl(pATI->CPIO_CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); + outr(CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); /* Set pixel clock */ - outl(pATI->CPIO_CLOCK_CNTL, pATIHW->clock_cntl | CLOCK_STROBE); + outr(CLOCK_CNTL, pATIHW->clock_cntl | CLOCK_STROBE); /* Load overscan registers */ - outl(pATI->CPIO_OVR_CLR, pATIHW->ovr_clr); - outl(pATI->CPIO_OVR_WID_LEFT_RIGHT, pATIHW->ovr_wid_left_right); - outl(pATI->CPIO_OVR_WID_TOP_BOTTOM, pATIHW->ovr_wid_top_bottom); + outr(OVR_CLR, pATIHW->ovr_clr); + outr(OVR_WID_LEFT_RIGHT, pATIHW->ovr_wid_left_right); + outr(OVR_WID_TOP_BOTTOM, pATIHW->ovr_wid_top_bottom); /* Finalise CRTC setup and turn on the screen */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); /* Load draw engine */ if (pATI->OptionAccel) @@ -665,11 +605,11 @@ (void)memset(pATI->MMIOCached, 0, SizeOf(pATI->MMIOCached)); /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl); + outr(BUS_CNTL, pATI->NewHW.bus_cntl); + outr(CONFIG_CNTL, pATI->NewHW.config_cntl); pATI->EngineIsBusy = TRUE; /* Force engine poll */ - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); /* Load FIFO size */ if (pATI->Chip >= ATI_CHIP_264VT4) @@ -683,65 +623,77 @@ pATI->nFIFOEntries = pATI->nAvailableFIFOEntries; /* Load destination registers */ - ATIMach64WaitForFIFO(7); - outm(DST_OFF_PITCH, pATIHW->dst_off_pitch); - outm(DST_Y_X, SetWord(pATIHW->dst_x, 1) | SetWord(pATIHW->dst_y, 0)); - outm(DST_HEIGHT, pATIHW->dst_height); - outm(DST_BRES_ERR, pATIHW->dst_bres_err); - outm(DST_BRES_INC, pATIHW->dst_bres_inc); - outm(DST_BRES_DEC, pATIHW->dst_bres_dec); - outm(DST_CNTL, pATIHW->dst_cntl); + ATIMach64WaitForFIFO(pATI, 7); + outf(DST_OFF_PITCH, pATIHW->dst_off_pitch); + outf(DST_Y_X, SetWord(pATIHW->dst_x, 1) | SetWord(pATIHW->dst_y, 0)); + outf(DST_HEIGHT, pATIHW->dst_height); + outf(DST_BRES_ERR, pATIHW->dst_bres_err); + outf(DST_BRES_INC, pATIHW->dst_bres_inc); + outf(DST_BRES_DEC, pATIHW->dst_bres_dec); + outf(DST_CNTL, pATIHW->dst_cntl); /* Load source registers */ - ATIMach64WaitForFIFO(6); - outm(SRC_OFF_PITCH, pATIHW->src_off_pitch); - outm(SRC_Y_X, SetWord(pATIHW->src_x, 1) | SetWord(pATIHW->src_y, 0)); - outm(SRC_HEIGHT1_WIDTH1, + ATIMach64WaitForFIFO(pATI, 6); + outf(SRC_OFF_PITCH, pATIHW->src_off_pitch); + outf(SRC_Y_X, SetWord(pATIHW->src_x, 1) | SetWord(pATIHW->src_y, 0)); + outf(SRC_HEIGHT1_WIDTH1, SetWord(pATIHW->src_width1, 1) | SetWord(pATIHW->src_height1, 0)); - outm(SRC_Y_X_START, + outf(SRC_Y_X_START, SetWord(pATIHW->src_x_start, 1) | SetWord(pATIHW->src_y_start, 0)); - outm(SRC_HEIGHT2_WIDTH2, + outf(SRC_HEIGHT2_WIDTH2, SetWord(pATIHW->src_width2, 1) | SetWord(pATIHW->src_height2, 0)); - outm(SRC_CNTL, pATIHW->src_cntl); + outf(SRC_CNTL, pATIHW->src_cntl); /* Load host data register */ - ATIMach64WaitForFIFO(1); - outm(HOST_CNTL, pATIHW->host_cntl); + ATIMach64WaitForFIFO(pATI, 1); + outf(HOST_CNTL, pATIHW->host_cntl); + + /* Set host transfer window address and size clamp */ + pATI->pHOST_DATA = + (CARD8 *)pATI->pBlock[GetBits(HOST_DATA_0, BLOCK_SELECT)] + + (HOST_DATA_0 & MM_IO_SELECT); + pATI->nHostFIFOEntries = pATI->nFIFOEntries >> 1; + if (pATI->nHostFIFOEntries > 16) + pATI->nHostFIFOEntries = 16; /* Load pattern registers */ - ATIMach64WaitForFIFO(3); - outm(PAT_REG0, pATIHW->pat_reg0); - outm(PAT_REG1, pATIHW->pat_reg1); - outm(PAT_CNTL, pATIHW->pat_cntl); + ATIMach64WaitForFIFO(pATI, 3); + outf(PAT_REG0, pATIHW->pat_reg0); + outf(PAT_REG1, pATIHW->pat_reg1); + outf(PAT_CNTL, pATIHW->pat_cntl); /* Load scissor registers */ - ATIMach64WaitForFIFO(2); - outm(SC_LEFT_RIGHT, + ATIMach64WaitForFIFO(pATI, 2); + outf(SC_LEFT_RIGHT, SetWord(pATIHW->sc_right, 1) | SetWord(pATIHW->sc_left, 0)); - outm(SC_TOP_BOTTOM, + outf(SC_TOP_BOTTOM, SetWord(pATIHW->sc_bottom, 1) | SetWord(pATIHW->sc_top, 0)); + pATI->sc_left = pATIHW->sc_left; + pATI->sc_right = pATIHW->sc_right; + pATI->sc_top = pATIHW->sc_top; + pATI->sc_bottom = pATIHW->sc_bottom; /* Load data path registers */ - ATIMach64WaitForFIFO(7); - outm(DP_BKGD_CLR, pATIHW->dp_bkgd_clr); - outm(DP_FRGD_CLR, pATIHW->dp_frgd_clr); - outm(DP_WRITE_MASK, pATIHW->dp_write_mask); - outm(DP_CHAIN_MASK, pATIHW->dp_chain_mask); - outm(DP_PIX_WIDTH, pATIHW->dp_pix_width); - outm(DP_MIX, pATIHW->dp_mix); - outm(DP_SRC, pATIHW->dp_src); + ATIMach64WaitForFIFO(pATI, 7); + outf(DP_BKGD_CLR, pATIHW->dp_bkgd_clr); + outf(DP_FRGD_CLR, pATIHW->dp_frgd_clr); + outf(DP_WRITE_MASK, pATIHW->dp_write_mask); + outf(DP_CHAIN_MASK, pATIHW->dp_chain_mask); + outf(DP_PIX_WIDTH, pATIHW->dp_pix_width); + outf(DP_MIX, pATIHW->dp_mix); + outf(DP_SRC, pATIHW->dp_src); /* Load colour compare registers */ - ATIMach64WaitForFIFO(3); - outm(CLR_CMP_CLR, pATIHW->clr_cmp_clr); - outm(CLR_CMP_MSK, pATIHW->clr_cmp_msk); - outm(CLR_CMP_CNTL, pATIHW->clr_cmp_cntl); + ATIMach64WaitForFIFO(pATI, 3); + outf(CLR_CMP_CLR, pATIHW->clr_cmp_clr); + outf(CLR_CMP_MSK, pATIHW->clr_cmp_msk); + outf(CLR_CMP_CNTL, pATIHW->clr_cmp_cntl); /* Load context mask */ - ATIMach64WaitForFIFO(1); - outm(CONTEXT_MASK, pATIHW->context_mask); + ATIMach64WaitForFIFO(pATI, 1); + outf(CONTEXT_MASK, pATIHW->context_mask); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); if (pATI->OptionMMIOCache) { @@ -774,14 +726,13 @@ } /* Aperture setup */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); + outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); + outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); - outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); - outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); + outr(DAC_CNTL, pATIHW->dac_cntl); - outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl); - - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); } /* @@ -796,18 +747,18 @@ int Mode ) { - CARD32 crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL); + CARD32 crtc_gen_cntl = inr(CRTC_GEN_CNTL); switch (Mode) { case SCREEN_SAVER_OFF: case SCREEN_SAVER_FORCER: - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_DISPLAY_DIS); + outr(CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_DISPLAY_DIS); break; case SCREEN_SAVER_ON: case SCREEN_SAVER_CYCLE: - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_DISPLAY_DIS); + outr(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_DISPLAY_DIS); break; default: @@ -828,7 +779,7 @@ ) { CARD32 crtc_gen_cntl = - inl(pATI->CPIO_CRTC_GEN_CNTL) & ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); + inr(CRTC_GEN_CNTL) & ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); switch (DPMSMode) { @@ -851,58 +802,131 @@ return; } - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl); + outr(CRTC_GEN_CNTL, crtc_gen_cntl); if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT) { - CARD32 lcd_index = 0, power_management; + CARD32 lcd_index = 0; - if (pATI->Chip == ATI_CHIP_264LT) - power_management = inl(pATI->CPIO_POWER_MANAGEMENT); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ + /* + * ATI's BIOS simply turns the panel on and off, so do the same by + * default, but keep the previous behaviour around for reference. + */ + if (pATI->OptionDevel) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - power_management = ATIGetLTProLCDReg(LCD_POWER_MANAGEMENT); - } + CARD32 power_management; - power_management &= ~(STANDBY_NOW | SUSPEND_NOW); + if (pATI->Chip == ATI_CHIP_264LT) + power_management = inr(POWER_MANAGEMENT); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + lcd_index = inr(LCD_INDEX); + power_management = ATIGetMach64LCDReg(LCD_POWER_MANAGEMENT); + } - switch (DPMSMode) - { - case DPMSModeOn: - break; + power_management &= ~(STANDBY_NOW | SUSPEND_NOW); - case DPMSModeStandby: - power_management |= STANDBY_NOW; - break; + switch (DPMSMode) + { + case DPMSModeOn: + break; - case DPMSModeSuspend: - power_management |= SUSPEND_NOW; - break; + case DPMSModeStandby: + power_management |= STANDBY_NOW; + break; + + case DPMSModeSuspend: + power_management |= SUSPEND_NOW; + break; + + case DPMSModeOff: + power_management |= STANDBY_NOW | SUSPEND_NOW; /* ? */ + break; - case DPMSModeOff: - power_management |= STANDBY_NOW | SUSPEND_NOW; /* ? */ - break; + default: /* Muffle compiler */ + return; + } - default: /* Muffle compiler */ - return; + /* Panel power management seems to involve the engine */ + if (pATI->OptionAccel) + ATIMach64WaitForIdle(pATI); + + if (pATI->Chip == ATI_CHIP_264LT) + outr(POWER_MANAGEMENT, power_management); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + ATIPutMach64LCDReg(LCD_POWER_MANAGEMENT, power_management); + outr(LCD_INDEX, lcd_index); + } } - - if (pATI->Chip == ATI_CHIP_264LT) - outl(POWER_MANAGEMENT, power_management); - else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || - (pATI->Chip == ATI_CHIP_264XL) || - (pATI->Chip == ATI_CHIP_MOBILITY)) */ + else { - ATIPutLTProLCDReg(LCD_POWER_MANAGEMENT, power_management); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + CARD32 lcd_gen_ctrl; + + if (pATI->Chip == ATI_CHIP_264LT) + lcd_gen_ctrl = inr(LCD_GEN_CTRL); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); + } + + if (DPMSMode == DPMSModeOn) + lcd_gen_ctrl |= LCD_ON; + else + lcd_gen_ctrl &= ~LCD_ON; + + if (pATI->Chip == ATI_CHIP_264LT) + outr(LCD_GEN_CTRL, lcd_gen_ctrl); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + outr(LCD_INDEX, lcd_index); + } } } } /* + * ATIMach64ValidateClip -- + * + * This function ensures the current scissor settings do not interfere with + * the current draw request. + */ +static void +ATIMach64ValidateClip +( + ATIPtr pATI, + int sc_left, + int sc_right, + int sc_top, + int sc_bottom +) +{ + if ((sc_left < (int)pATI->sc_left) || (sc_right > (int)pATI->sc_right)) + { + outf(SC_LEFT_RIGHT, pATI->sc_left_right); + pATI->sc_left = pATI->NewHW.sc_left; + pATI->sc_right = pATI->NewHW.sc_right; + } + + if ((sc_top < (int)pATI->sc_top) || (sc_bottom > (int)pATI->sc_bottom)) + { + outf(SC_TOP_BOTTOM, pATI->sc_top_bottom); + pATI->sc_top = pATI->NewHW.sc_top; + pATI->sc_bottom = pATI->NewHW.sc_bottom; + } +} + +/* * ATIMach64Sync -- * * This is called to wait for the draw engine to become idle. @@ -915,7 +939,7 @@ { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); if (pATI->OptionMMIOCache) { @@ -1075,15 +1099,24 @@ pATI->dst_cntl |= DST_X_DIR; if (pATI->XModifier == 1) - outm(DST_CNTL, pATI->dst_cntl); + outf(DST_CNTL, pATI->dst_cntl); else pATI->dst_cntl |= DST_24_ROT_EN; - ATIMach64WaitForFIFO(3); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 3); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); + + if (TransparencyColour == -1) + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); + else + { + ATIMach64WaitForFIFO(pATI, 2); + outf(CLR_CMP_CLR, TransparencyColour); + outf(CLR_CMP_CNTL, CLR_CMP_FN_EQUAL | CLR_CMP_SRC_2D); + } } /* @@ -1110,14 +1143,7 @@ w *= pATI->XModifier; /* Disable clipping if it gets in the way */ - if ((xDst < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((xDst + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((yDst < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((yDst + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, xDst, xDst + w - 1, yDst, yDst + h - 1); if (!(pATI->dst_cntl & DST_X_DIR)) { @@ -1132,13 +1158,13 @@ } if (pATI->XModifier != 1) - outm(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT)); + outf(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT)); - ATIMach64WaitForFIFO(4); - outm(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0)); - outm(SRC_WIDTH1, w); - outm(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64WaitForFIFO(pATI, 4); + outf(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0)); + outf(SRC_WIDTH1, w); + outf(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1158,14 +1184,16 @@ ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); - ATIMach64WaitForFIFO(4); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 5); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, colour); + outf(DP_FRGD_CLR, colour); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); } /* @@ -1190,23 +1218,16 @@ x *= pATI->XModifier; w *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } /* Disable clipping if it gets in the way */ - if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); - - ATIMach64WaitForFIFO(2); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1); + + ATIMach64WaitForFIFO(pATI, 2); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1226,17 +1247,17 @@ { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForFIFO(6); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 5); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, colour); + outf(DP_FRGD_CLR, colour); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); - outm(SC_LEFT_RIGHT, - SetWord(pATI->NewHW.sc_right, 1) | SetWord(pATI->NewHW.sc_left, 0)); - outm(SC_TOP_BOTTOM, - SetWord(pATI->NewHW.sc_bottom, 1) | SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, pATI->NewHW.sc_left, pATI->NewHW.sc_right, + pATI->NewHW.sc_top, pATI->NewHW.sc_bottom); } /* @@ -1257,14 +1278,14 @@ { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForFIFO(3); - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + ATIMach64WaitForFIFO(pATI, 3); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); if (dir == DEGREES_0) - outm(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0)); else /* if (dir == DEGREES_270) */ - outm(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0)); } /* @@ -1297,13 +1318,13 @@ if (!(octant & YDECREASING)) dst_cntl |= DST_Y_DIR; - ATIMach64WaitForFIFO(6); - outm(DST_CNTL, dst_cntl); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_BRES_ERR, minor + err); - outm(DST_BRES_INC, minor); - outm(DST_BRES_DEC, minor - major); - outm(DST_BRES_LNTH, len); + ATIMach64WaitForFIFO(pATI, 6); + outf(DST_CNTL, dst_cntl); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_BRES_ERR, minor + err); + outf(DST_BRES_INC, minor); + outf(DST_BRES_DEC, minor - major); + outf(DST_BRES_LNTH, len); } /* @@ -1327,28 +1348,30 @@ ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); if (bg == -1) - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(MIX_DST, DP_BKGD_MIX)); else { - ATIMach64WaitForFIFO(2); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + ATIMach64WaitForFIFO(pATI, 2); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(ATIMach64ALU[rop], DP_BKGD_MIX)); - outm(DP_BKGD_CLR, bg); + outf(DP_BKGD_CLR, bg); } - ATIMach64WaitForFIFO(6); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_PATTERN | + ATIMach64WaitForFIFO(pATI, 7); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_PATTERN | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, fg); + outf(DP_FRGD_CLR, fg); - outm(PAT_REG0, patx); - outm(PAT_REG1, paty); - outm(PAT_CNTL, PAT_MONO_EN); + outf(PAT_REG0, patx); + outf(PAT_REG1, paty); + outf(PAT_CNTL, PAT_MONO_EN); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); } /* @@ -1375,23 +1398,16 @@ x *= pATI->XModifier; w *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } /* Disable clipping if it gets in the way */ - if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); - - ATIMach64WaitForFIFO(2); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1); + + ATIMach64WaitForFIFO(pATI, 2); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1412,24 +1428,26 @@ ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); if (bg == -1) - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(MIX_DST, DP_BKGD_MIX)); else { - ATIMach64WaitForFIFO(2); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + ATIMach64WaitForFIFO(pATI, 2); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(ATIMach64ALU[rop], DP_BKGD_MIX)); - outm(DP_BKGD_CLR, bg); + outf(DP_BKGD_CLR, bg); } - ATIMach64WaitForFIFO(3); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_HOST | + ATIMach64WaitForFIFO(pATI, 4); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_HOST | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, fg); + outf(DP_FRGD_CLR, fg); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); } /* @@ -1456,16 +1474,19 @@ w *= pATI->XModifier; skipleft *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } pATI->ExpansionBitmapWidth = (w + 31) / 32; - ATIMach64WaitForFIFO(3); - outm(SC_LEFT_RIGHT, SetWord(x + w - 1, 1) | SetWord(x + skipleft, 0)); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, + ATIMach64WaitForFIFO(pATI, 3); + pATI->sc_left = x + skipleft; + pATI->sc_right = x + w - 1; + outf(SC_LEFT_RIGHT, + SetWord(pATI->sc_right, 1) | SetWord(pATI->sc_left, 0)); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(pATI->ExpansionBitmapWidth * 32, 1) | SetWord(h, 0)); } @@ -1473,7 +1494,8 @@ * ATIMach64SubsequentColorExpandScanline -- * * This function feeds a bitmap scanline to the engine for a colour expansion - * fill. + * fill. This is written to do burst transfers for those platforms that can do + * them, and to improve CPU/engine concurrency. */ static void ATIMach64SubsequentColorExpandScanline @@ -1482,22 +1504,69 @@ int iBuffer ) { - ATIPtr pATI = ATIPTR(pScreenInfo); - CARD32 *pBitmapData = pATI->ExpansionBitmapScanline; - int w = pATI->ExpansionBitmapWidth; - int nFIFOEntries = pATI->nFIFOEntries; - - pATI->nFIFOEntries >>= 1; + ATIPtr pATI = ATIPTR(pScreenInfo); + CARD32 *pBitmapData = pATI->ExpansionBitmapScanlinePtr[iBuffer]; + CARD32 *pDst, *pSrc; + int w = pATI->ExpansionBitmapWidth; + int nDWord; + unsigned int iDWord; - for (; w > 0; w--, pBitmapData++) + while (w > 0) { - if (!pATI->nAvailableFIFOEntries && (w > 1)) - ATIMach64WaitForFIFO(w); + /* + * Transfers are done in chunks of up to 64 bytes in length (32 on + * earlier controllers). + */ + nDWord = w; + if (nDWord > pATI->nHostFIFOEntries) + nDWord = pATI->nHostFIFOEntries; + + /* Make enough FIFO slots available */ + ATIMach64WaitForFIFO(pATI, nDWord); + + /* + * Always start transfers on a chuck-sized boundary. Note that + * HOST_DATA_0 is actually on a 512-byte boundary, but *pBitmapData can + * only be guaranteed to be on a chunk-sized boundary. + */ + iDWord = 16 - nDWord; + pDst = (CARD32 *)pATI->pHOST_DATA - iDWord; + pSrc = pBitmapData - iDWord; + + /* + * Transfer current chunk. With any luck, the compiler won't mangle + * this too badly... + */ + switch (iDWord) + { + case 0: MMIO_OUT32(pDst + 0, 0, *(pSrc + 0)); + case 1: MMIO_OUT32(pDst + 1, 0, *(pSrc + 1)); + case 2: MMIO_OUT32(pDst + 2, 0, *(pSrc + 2)); + case 3: MMIO_OUT32(pDst + 3, 0, *(pSrc + 3)); + case 4: MMIO_OUT32(pDst + 4, 0, *(pSrc + 4)); + case 5: MMIO_OUT32(pDst + 5, 0, *(pSrc + 5)); + case 6: MMIO_OUT32(pDst + 6, 0, *(pSrc + 6)); + case 7: MMIO_OUT32(pDst + 7, 0, *(pSrc + 7)); + case 8: MMIO_OUT32(pDst + 8, 0, *(pSrc + 8)); + case 9: MMIO_OUT32(pDst + 9, 0, *(pSrc + 9)); + case 10: MMIO_OUT32(pDst + 10, 0, *(pSrc + 10)); + case 11: MMIO_OUT32(pDst + 11, 0, *(pSrc + 11)); + case 12: MMIO_OUT32(pDst + 12, 0, *(pSrc + 12)); + case 13: MMIO_OUT32(pDst + 13, 0, *(pSrc + 13)); + case 14: MMIO_OUT32(pDst + 14, 0, *(pSrc + 14)); + case 15: MMIO_OUT32(pDst + 15, 0, *(pSrc + 15)); + + default: /* Muffle compiler */ + break; + } - outm(HOST_DATA_0, *pBitmapData); + /* Step to next chunk */ + pBitmapData += nDWord; + w -= nDWord; + pATI->nAvailableFIFOEntries -= nDWord; } - pATI->nFIFOEntries = nFIFOEntries; + pATI->EngineIsBusy = TRUE; } /* @@ -1517,15 +1586,22 @@ if (pATI->XModifier == 1) { pXAAInfo->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS; + +#ifndef AVOID_CPIO + if (!pATI->BankInfo.BankSize) + +#endif /* AVOID_CPIO */ + + { pXAAInfo->Flags |= LINEAR_FRAMEBUFFER; + } } /* Sync */ pXAAInfo->Sync = ATIMach64Sync; /* Screen-to-screen copy */ - pXAAInfo->ScreenToScreenCopyFlags = NO_TRANSPARENCY; /* For now */ pXAAInfo->SetupForScreenToScreenCopy = ATIMach64SetupForScreenToScreenCopy; pXAAInfo->SubsequentScreenToScreenCopy = ATIMach64SubsequentScreenToScreenCopy; @@ -1535,8 +1611,8 @@ pXAAInfo->SubsequentSolidFillRect = ATIMach64SubsequentSolidFillRect; /* 8x8 mono pattern fills */ - pXAAInfo->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; + pXAAInfo->Mono8x8PatternFillFlags = + HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; pXAAInfo->SetupForMono8x8PatternFill = ATIMach64SetupForMono8x8PatternFill; pXAAInfo->SubsequentMono8x8PatternFillRect = ATIMach64SubsequentMono8x8PatternFillRect; @@ -1547,14 +1623,21 @@ */ pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X | - BIT_ORDER_IN_BYTE_MSBFIRST | CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD; + CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD; if (pATI->XModifier != 1) pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags |= TRIPLE_BITS_24BPP; pXAAInfo->NumScanlineColorExpandBuffers = 1; - pATI->ExpansionBitmapScanlinePtr = pATI->ExpansionBitmapScanline; + + /* Align bitmap data on a 64-byte boundary */ + pATI->ExpansionBitmapWidth = /* DWord size in bits */ + ((pATI->displayWidth * pATI->XModifier) + 31) & ~31U; + pATI->ExpansionBitmapScanlinePtr[1] = + (CARD32 *)xnfalloc((pATI->ExpansionBitmapWidth >> 3) + 63); + pATI->ExpansionBitmapScanlinePtr[0] = + (pointer)(((unsigned long)pATI->ExpansionBitmapScanlinePtr[1] + 63) & + ~63UL); pXAAInfo->ScanlineColorExpandBuffers = - (CARD8 **)&pATI->ExpansionBitmapScanlinePtr; + (CARD8 **)pATI->ExpansionBitmapScanlinePtr; pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill = ATIMach64SetupForScanlineCPUToScreenColorExpandFill; pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill = Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h:1.8 Mon Jun 19 11:00:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h Fri Aug 4 17:07:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.8 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.9 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xaa.h" #define ATIMach64MaxX 8191 Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c:1.2 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c Fri Aug 4 17:07:14 2000 @@ -0,0 +1,100 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c,v 1.2 2000/08/04 21:07:14 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atichip.h" +#include "atimach64io.h" + +/* + * ATIAccessMach64PLLReg -- + * + * This function sets up the addressing required to access, for read or write, + * a 264xT's PLL registers. + */ +void +ATIAccessMach64PLLReg +( + ATIPtr pATI, + const CARD8 Index, + const Bool Write +) +{ + CARD8 clock_cntl1 = in8(CLOCK_CNTL + 1) & + ~GetByte(PLL_WR_EN | PLL_ADDR, 1); + + /* Set PLL register to be read or written */ + out8(CLOCK_CNTL + 1, clock_cntl1 | + GetByte(SetBits(Index, PLL_ADDR) | SetBits(Write, PLL_WR_EN), 1)); +} + +/* + * ATIMach64PollEngineStatus -- + * + * This function refreshes the driver's view of the draw engine's status. This + * has been moved into a separate compilation unit to prevent inlining. + */ +void +ATIMach64PollEngineStatus +( + ATIPtr pATI +) +{ + CARD32 IOValue; + int Count; + + if (pATI->Chip < ATI_CHIP_264VTB) + { + /* + * TODO: Deal with locked engines. + */ + IOValue = inm(FIFO_STAT); + pATI->EngineIsLocked = GetBits(IOValue, FIFO_ERR); + + /* + * The following counts the number of bits in FIFO_STAT_BITS, and is + * derived from miSetVisualTypes() (formerly cfbSetVisualTypes()). + */ + IOValue = GetBits(IOValue, FIFO_STAT_BITS); + Count = (IOValue >> 1) & 0x36DBU; + Count = IOValue - Count - ((Count >> 1) & 0x36DBU); + Count = ((Count + (Count >> 3)) & 0x71C7U) % 0x3FU; + Count = pATI->nFIFOEntries - Count; + if (Count > pATI->nAvailableFIFOEntries) + pATI->nAvailableFIFOEntries = Count; + + /* + * If the command FIFO is non-empty, then the engine isn't idle. + */ + if (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries) + { + pATI->EngineIsBusy = TRUE; + return; + } + } + + IOValue = inm(GUI_STAT); + pATI->EngineIsBusy = GetBits(IOValue, GUI_ACTIVE); + Count = GetBits(IOValue, GUI_FIFO); + if (Count > pATI->nAvailableFIFOEntries) + pATI->nAvailableFIFOEntries = Count; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h:1.4 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h Wed Oct 11 18:52:56 2000 @@ -0,0 +1,214 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h,v 1.4 2000/10/11 22:52:56 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATIMACH64IO_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error Missing #include "ati.h" before #include "atimach64io.h" +# undef XFree86Module +#endif + +#define ___ATIMACH64IO_H___ 1 + +#include "atiio.h" +#include "atistruct.h" + +/* + * A few important notes on some of the I/O statements provided: + * + * inl/outl 32-bit R/W through PIO space. The register is specified as the + * actual PIO address. These are actually defined in compiler.h. + * + * inw/outw 16-bit counterparts to inl/outl. Not used for Mach64 support. + * + * inb/outb 8-bit counterparts to inl/outl. + * + * inm/outm 32-bit R/W through MMIO space. The register is specified as + * the actual MMIO offset (with Block 1 following Block 0), which, + * in this case, is equivalent to the register's IOPortTag from + * atiregs.h. Can only be used for those few non-FIFO'ed + * registers outside of Block 0's first 256 bytes. pATI->pBlock + * array elements must have been previously set up by + * ATIMapApertures(). + * + * outf 32-bit write through MMIO cache. Identical to outm() but + * intended for FIFO'ed registers. There is no inf() provided. + * + * inr/outr 32-bit R/W through PIO or MMIO. Which one depends on the + * machine architecture. The register is specified as a IOPortTag + * from atiregs.h. Can only be used for registers in the first + * 256 bytes of MMIO space (in Block 0). Note that all of these + * registers are non-FIFO'ed. + * + * in8/out8 8-bit counterparts to inr/outr. + */ + +/* + * Cave canem (or it WILL bite you): All Mach64 non-VGA registers are + * ================================ little-endian, no matter how they are + * accessed (nor by what). + */ + +#define inm(_Register) \ + MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT) +#define outm(_Register, _Value) \ + MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT, _Value) + +#ifdef AVOID_CPIO + +# define inr(_Register) \ + MMIO_IN32(pATI->pBlock[0], (_Register) & MM_IO_SELECT) +# define outr(_Register, _Value) \ + MMIO_OUT32(pATI->pBlock[0], (_Register) & MM_IO_SELECT, _Value) + +# define in8(_Register) \ + MMIO_IN8(pATI->pBlock[0], \ + (_Register) & (MM_IO_SELECT | IO_BYTE_SELECT)) +# define out8(_Register, _Value) \ + MMIO_OUT8(pATI->pBlock[0], \ + (_Register) & (MM_IO_SELECT | IO_BYTE_SELECT), _Value) + +/* Cause a cpp syntax error if any of these are used */ +#undef inb +#undef inw +#undef inl +#undef outb +#undef outw +#undef outl + +#define inb() /* Nothing */ +#define inw() /* Nothing */ +#define inl() /* Nothing */ +#define outb() /* Nothing */ +#define outw() /* Nothing */ +#define outl() /* Nothing */ + +#else /* AVOID_CPIO */ + +# define ATIIOPort(_PortTag) \ + (((pATI->CPIODecoding == SPARSE_IO) ? \ + ((_PortTag) & (SPARSE_IO_SELECT | IO_BYTE_SELECT)) : \ + ((_PortTag) & (BLOCK_IO_SELECT | IO_BYTE_SELECT))) | \ + pATI->CPIOBase) + +# define inr(_Register) \ + inl(ATIIOPort(_Register)) +# define outr(_Register, _Value) \ + outl(ATIIOPort(_Register), _Value) + +# define in8(_Register) \ + inb(ATIIOPort(_Register)) +# define out8(_Register, _Value) \ + outb(ATIIOPort(_Register), _Value) + +#endif /* AVOID_CPIO */ + +extern void ATIMach64PollEngineStatus FunctionPrototype((ATIPtr)); + +/* + * MMIO cache definitions + */ +#define CacheByte(___Register) pATI->MMIOCached[CacheSlotOf(___Register >> 3)] +#define CacheBit(___Register) (0x80U >> (CacheSlotOf(___Register) & 0x07U)) + +#define RegisterIsCached(__Register) \ + (CacheByte(__Register) & CacheBit(__Register)) +#define CacheSlot(__Register) pATI->MMIOCache[CacheSlotOf(__Register)] + +#define CacheRegister(__Register) \ + CacheByte(__Register) |= CacheBit(__Register) +#define UncacheRegister(__Register) \ + CacheByte(__Register) &= ~CacheBit(__Register) + +/* This would be quite a bit slower as a function */ +#define outf(_Register, _Value) \ + do \ + { \ + CARD32 _IOValue = (_Value); \ + \ + if (!RegisterIsCached(_Register) || \ + (_IOValue != CacheSlot(_Register))) \ + { \ + while (!pATI->nAvailableFIFOEntries--) \ + ATIMach64PollEngineStatus(pATI); \ + MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT, _IOValue); \ + CacheSlot(_Register) = _IOValue; \ + pATI->EngineIsBusy = TRUE; \ + } \ + } while (0) + +/* + * This is no longer as critical, especially for _n == 1. However, + * there is still a need to ensure _n <= pATI-<nFIFOEntries. + */ +#define ATIMach64WaitForFIFO(_pATI, _n) \ + while (pATI->nAvailableFIFOEntries < (_n)) \ + ATIMach64PollEngineStatus(pATI); + +#define ATIMach64WaitForIdle(_pATI) \ + while (pATI->EngineIsBusy) \ + ATIMach64PollEngineStatus(pATI); + +extern void ATIAccessMach64PLLReg FunctionPrototype((ATIPtr, const CARD8, + const Bool)); + +#define ATIGetMach64PLLReg(_Index) \ + ( \ + ATIAccessMach64PLLReg(pATI, _Index, FALSE), \ + in8(CLOCK_CNTL + 2) \ + ) +#define ATIPutMach64PLLReg(_Index, _Value) \ + do \ + { \ + ATIAccessMach64PLLReg(pATI, _Index, TRUE); \ + out8(CLOCK_CNTL + 2, _Value); \ + } while(0) + +#define ATIGetMach64LCDReg(_Index) \ + ( \ + out8(LCD_INDEX, SetBits(_Index, LCD_REG_INDEX)), \ + inr(LCD_DATA) \ + ) +#define ATIPutMach64LCDReg(_Index, _Value) \ + do \ + { \ + out8(LCD_INDEX, SetBits(_Index, LCD_REG_INDEX)); \ + outr(LCD_DATA, _Value); \ + } while(0) + +#define ATIGetMach64TVReg(_Index) \ + ( \ + out8(TV_OUT_INDEX, SetBits(_Index, TV_REG_INDEX)), \ + inr(TV_OUT_DATA) \ + ) +#define ATIPutMach64TVReg(_Index, _Value) \ + do \ + { \ + out8(TV_OUT_INDEX, SetBits(_Index, TV_REG_INDEX)); \ + outr(TV_OUT_DATA, _Value); \ + } while(0) + +#endif /* ___ATIMACH64IO_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c:1.1 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c Mon Oct 30 18:02:12 2000 @@ -0,0 +1,81 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimisc.c,v 1.1 2000/10/30 23:02:12 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef XFree86LOADER + +#include "ati.h" +#include "ativersion.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo ATIVersionRec = +{ + ATI_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + ATI_VERSION_MAJOR, ATI_VERSION_MINOR, ATI_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * ATISetup -- + * + * This function is called every time the module is loaded. + */ +static pointer +ATISetup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called atimiscModuleData */ +XF86ModuleData atimiscModuleData = +{ + &ATIVersionRec, + ATISetup, + NULL +}; + +#endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c:1.1 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c Wed Oct 11 18:52:56 2000 @@ -0,0 +1,1165 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.c,v 1.1 2000/10/11 22:52:56 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atiadapter.h" +#include "atichip.h" +#include "atidac.h" +#include "atidsp.h" +#include "atimach64.h" +#include "atimach64io.h" +#include "atimode.h" +#include "atiprint.h" +#include "ativga.h" +#include "atiwonder.h" +#include "atiwonderio.h" + +#ifndef AVOID_CPIO + +/* + * ATICopyVGAMemory -- + * + * This function is called to copy one or all banks of a VGA plane. + */ +static void +ATICopyVGAMemory +( + ATIPtr pATI, + ATIHWPtr pATIHW, + pointer *saveptr, + pointer *from, + pointer *to +) +{ + unsigned int iBank; + + for (iBank = 0; iBank < pATIHW->nBank; iBank++) + { + (*pATIHW->SetBank)(pATI, iBank); + (void)memcpy(*to, *from, 0x00010000U); + *saveptr = (char *)(*saveptr) + 0x00010000U; + } +} + +/* + * ATISwap -- + * + * This function saves/restores video memory contents during video mode + * switches. + */ +static void +ATISwap +( + int iScreen, + ATIPtr pATI, + ATIHWPtr pATIHW, + Bool ToFB +) +{ + pointer save, *from, *to; + unsigned int iPlane = 0, PlaneMask = 1; + CARD8 seq2, seq4, gra1, gra3, gra4, gra5, gra6, gra8; + + /* + * This is only done for non-accelerator modes. If the video state on + * server entry was an accelerator mode, the application that relinquished + * the console had better do the Right Thing (tm) anyway by saving and + * restoring its own video memory contents. + */ + if (pATIHW->crtc != ATI_CRTC_VGA) + return; + + if (ToFB) + { + if (!pATIHW->frame_buffer) + return; + + from = &save; + to = &pATI->pBank; + } + else + { + /* Allocate the memory */ + if (!pATIHW->frame_buffer) + { + pATIHW->frame_buffer = + (pointer)xalloc(pATIHW->nBank * pATIHW->nPlane * 0x00010000U); + if (!pATIHW->frame_buffer) + { + xf86DrvMsg(iScreen, X_WARNING, + "Temporary frame buffer could not be allocated.\n"); + return; + } + } + + from = &pATI->pBank; + to = &save; + } + + /* Turn off screen */ + ATIVGASaveScreen(pATI, SCREEN_SAVER_ON); + + /* Save register values to be modified */ + seq2 = GetReg(SEQX, 0x02U); + seq4 = GetReg(SEQX, 0x04U); + gra1 = GetReg(GRAX, 0x01U); + gra3 = GetReg(GRAX, 0x03U); + gra4 = GetReg(GRAX, 0x04U); + gra5 = GetReg(GRAX, 0x05U); + gra6 = GetReg(GRAX, 0x06U); + gra8 = GetReg(GRAX, 0x08U); + + save = pATIHW->frame_buffer; + + /* Temporarily normalise the mode */ + if (gra1 != 0x00U) + PutReg(GRAX, 0x01U, 0x00U); + if (gra3 != 0x00U) + PutReg(GRAX, 0x03U, 0x00U); + if (gra6 != 0x05U) + PutReg(GRAX, 0x06U, 0x05U); + if (gra8 != 0xFFU) + PutReg(GRAX, 0x08U, 0xFFU); + + if (seq4 & 0x08U) + { + /* Setup packed mode memory */ + if (seq2 != 0x0FU) + PutReg(SEQX, 0x02U, 0x0FU); + if (seq4 != 0x0AU) + PutReg(SEQX, 0x04U, 0x0AU); + if (pATI->Chip < ATI_CHIP_264CT) + { + if (gra5 != 0x00U) + PutReg(GRAX, 0x05U, 0x00U); + } + else + { + if (gra5 != 0x40U) + PutReg(GRAX, 0x05U, 0x40U); + } + + ATICopyVGAMemory(pATI, pATIHW, &save, from, to); + + if (seq2 != 0x0FU) + PutReg(SEQX, 0x02U, seq2); + if (seq4 != 0x0AU) + PutReg(SEQX, 0x04U, seq4); + if (pATI->Chip < ATI_CHIP_264CT) + { + if (gra5 != 0x00U) + PutReg(GRAX, 0x05U, gra5); + } + else + { + if (gra5 != 0x40U) + PutReg(GRAX, 0x05U, gra5); + } + } + else + { + gra4 = GetReg(GRAX, 0x04U); + + /* Setup planar mode memory */ + if (seq4 != 0x06U) + PutReg(SEQX, 0x04U, 0x06U); + if (gra5 != 0x00U) + PutReg(GRAX, 0x05U, 0x00U); + + for (; iPlane < pATIHW->nPlane; iPlane++) + { + PutReg(SEQX, 0x02U, PlaneMask); + PutReg(GRAX, 0x04U, iPlane); + ATICopyVGAMemory(pATI, pATIHW, &save, from, to); + PlaneMask <<= 1; + } + + PutReg(SEQX, 0x02U, seq2); + if (seq4 != 0x06U) + PutReg(SEQX, 0x04U, seq4); + PutReg(GRAX, 0x04U, gra4); + if (gra5 != 0x00U) + PutReg(GRAX, 0x05U, gra5); + } + + /* Restore registers */ + if (gra1 != 0x00U) + PutReg(GRAX, 0x01U, gra1); + if (gra3 != 0x00U) + PutReg(GRAX, 0x03U, gra3); + if (gra6 != 0x05U) + PutReg(GRAX, 0x06U, gra6); + if (gra8 != 0xFFU) + PutReg(GRAX, 0x08U, gra8); + + /* Back to bank 0 */ + (*pATIHW->SetBank)(pATI, 0); + + /* + * If restoring video memory for a server video mode, free the frame buffer + * save area. + */ + if (ToFB && (pATIHW == &pATI->NewHW)) + { + xfree(pATIHW->frame_buffer); + pATIHW->frame_buffer = NULL; + } +} + +#endif /* AVOID_CPIO */ + +/* + * ATIModePreInit -- + * + * This function initialises an ATIHWRec with information common to all video + * states generated by the driver. + */ +void +ATIModePreInit +( + ScrnInfoPtr pScreenInfo, + ATIPtr pATI, + ATIHWPtr pATIHW +) +{ + CARD32 lcd_index; + int HDisplay, VDisplay; + +#ifndef AVOID_CPIO + + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + { + /* Fill in VGA data */ + ATIVGAPreInit(pATI, pATIHW); + + /* Fill in VGA Wonder data */ + if (pATI->CPIO_VGAWonder) + ATIVGAWonderPreInit(pATI, pATIHW); + } + + /* Fill in Mach64 data */ + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + + { + ATIMach64PreInit(pScreenInfo, pATI, pATIHW); + } + + if (pATI->Chip >= ATI_CHIP_264CT) + { + /* Ensure proper VCLK source */ + pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) | + (PLL_VCLK_SRC_SEL | PLL_VCLK_RESET); + + /* Set provisional values for other PLL registers */ + pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV); + pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV); + pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV); + pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV); + pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV); + pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL); + + /* For now disable extended reference and feedback dividers */ + if (pATI->Chip >= ATI_CHIP_264LT) + pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL) & + ~(PLL_EXT_VPLL_EN | PLL_EXT_VPLL_VGA_EN | PLL_EXT_VPLL_INSYNC); + } + + /* Initialise CRTC data for LCD panels */ + if (pATI->LCDPanelID >= 0) + { + if (pATI->Chip == ATI_CHIP_264LT) + { + pATIHW->horz_stretching = inr(HORZ_STRETCHING); + pATIHW->vert_stretching = inr(VERT_STRETCHING); + pATIHW->lcd_gen_ctrl = inr(LCD_GEN_CTRL); + } + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + lcd_index = inr(LCD_INDEX); + pATIHW->lcd_index = (lcd_index & + ~(LCD_REG_INDEX | LCD_DISPLAY_DIS | LCD_SRC_SEL)) | + (LCD_SRC_SEL_CRTC1 | LCD_CRTC2_DISPLAY_DIS); + pATIHW->config_panel = + ATIGetMach64LCDReg(LCD_CONFIG_PANEL) | DONT_SHADOW_HEND; + pATIHW->lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATIHW->vert_stretching = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + outr(LCD_INDEX, lcd_index); + } + + pATIHW->lcd_gen_ctrl &= + ~(HORZ_DIVBY2_EN | DISABLE_PCLK_RESET | DIS_HOR_CRT_DIVBY2 | + VCLK_DAC_PM_EN | XTALIN_PM_EN | CRTC_RW_SELECT | + USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR | + SHADOW_EN | SHADOW_RW_EN); + pATIHW->lcd_gen_ctrl |= DONT_SHADOW_VPAR | LOCK_8DOT; + + if (pATI->OptionCRT) + { + /* + * Use primary CRTC to drive the CRT. Turn off panel interface. + */ + pATIHW->lcd_gen_ctrl &= ~LCD_ON; + pATIHW->lcd_gen_ctrl |= CRT_ON; + } + else + { + /* Use primary CRTC to drive the panel */ + pATIHW->lcd_gen_ctrl |= LCD_ON; + + /* + * Determine porch data. The following is inaccurate (but still + * good enough) when BIOS initialisation has set things up so that + * the registers read here are not the ones actually in use by the + * panel. + */ + +#ifndef AVOID_CPIO + + if (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN) + +#endif /* AVOID_CPIO */ + + { + pATIHW->crtc_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->crtc_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->crtc_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->crtc_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); + + HDisplay = GetBits(pATIHW->crtc_h_total_disp, CRTC_H_DISP); + VDisplay = GetBits(pATIHW->crtc_v_total_disp, CRTC_V_DISP); + + pATI->LCDHSyncStart = + (GetBits(pATIHW->crtc_h_sync_strt_wid, + CRTC_H_SYNC_STRT_HI) * + (MaxBits(CRTC_H_SYNC_STRT) + 1)) + + GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_STRT) - + HDisplay; + pATI->LCDHSyncWidth = + GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_WID); + pATI->LCDHBlankWidth = + GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) - + HDisplay; + pATI->LCDVSyncStart = + GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_STRT) - + VDisplay; + pATI->LCDVSyncWidth = + GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_WID); + pATI->LCDVBlankWidth = + GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) - + VDisplay; + } + +#ifndef AVOID_CPIO + + else + { + pATIHW->crt[0] = GetReg(CRTX(pATI->CPIO_VGABase), 0x00U); + pATIHW->crt[1] = GetReg(CRTX(pATI->CPIO_VGABase), 0x01U); + pATIHW->crt[4] = GetReg(CRTX(pATI->CPIO_VGABase), 0x04U); + pATIHW->crt[5] = GetReg(CRTX(pATI->CPIO_VGABase), 0x05U); + pATIHW->crt[6] = GetReg(CRTX(pATI->CPIO_VGABase), 0x06U); + pATIHW->crt[7] = GetReg(CRTX(pATI->CPIO_VGABase), 0x07U); + pATIHW->crt[16] = GetReg(CRTX(pATI->CPIO_VGABase), 0x10U); + pATIHW->crt[17] = GetReg(CRTX(pATI->CPIO_VGABase), 0x11U); + pATIHW->crt[18] = GetReg(CRTX(pATI->CPIO_VGABase), 0x12U); + + HDisplay = pATIHW->crt[1] + 1; + VDisplay = (((pATIHW->crt[7] << 3) & 0x0200U) | + ((pATIHW->crt[7] << 7) & 0x0100U) | + pATIHW->crt[18]) + 1; + + pATI->LCDHSyncStart = pATIHW->crt[4] - HDisplay; + pATI->LCDHSyncWidth = + (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU; + pATI->LCDHBlankWidth = pATIHW->crt[0] + 5 - HDisplay; + pATI->LCDVSyncStart = (((pATIHW->crt[7] << 2) & 0x0200U) | + ((pATIHW->crt[7] << 6) & 0x0100U) | + pATIHW->crt[16]) - VDisplay; + pATI->LCDVSyncWidth = + (pATIHW->crt[17] - pATIHW->crt[16]) & 0x0FU; + pATI->LCDVBlankWidth = (((pATIHW->crt[7] << 4) & 0x0200U) | + ((pATIHW->crt[7] << 8) & 0x0100U) | + pATIHW->crt[6]) + 2 - VDisplay; + } + +#endif /* AVOID_CPIO */ + + HDisplay <<= 3; + pATI->LCDHSyncStart <<= 3; + pATI->LCDHSyncWidth <<= 3; + pATI->LCDHBlankWidth <<= 3; + + /* If the mode on entry wasn't stretched, adjust timings */ + if (!(pATIHW->horz_stretching & HORZ_STRETCH_EN) && + ((HDisplay = pATI->LCDHorizontal - HDisplay) > 0)) + { + if ((pATI->LCDHSyncStart -= HDisplay) < 0) + pATI->LCDHSyncStart = 0; + pATI->LCDHBlankWidth -= HDisplay; + HDisplay = pATI->LCDHSyncStart + pATI->LCDHSyncWidth; + if (pATI->LCDHBlankWidth < HDisplay) + pATI->LCDHBlankWidth = HDisplay; + } + + if (!(pATIHW->vert_stretching & VERT_STRETCH_EN) && + ((VDisplay = pATI->LCDVertical - VDisplay) > 0)) + { + if ((pATI->LCDVSyncStart -= VDisplay) < 0) + pATI->LCDVSyncStart = 0; + pATI->LCDVBlankWidth -= VDisplay; + VDisplay = pATI->LCDVSyncStart + pATI->LCDVSyncWidth; + if (pATI->LCDVBlankWidth < VDisplay) + pATI->LCDVBlankWidth = VDisplay; + } + } + } + + /* Set RAMDAC data */ + ATIDACPreInit(pScreenInfo, pATI, pATIHW); +} + +/* + * ATIModeSave -- + * + * This function saves the current video state. + */ +void +ATIModeSave +( + ScrnInfoPtr pScreenInfo, + ATIPtr pATI, + ATIHWPtr pATIHW +) +{ + +#ifndef AVOID_CPIO + + int Index; + + /* Get bank to bank 0 */ + (*pATIHW->SetBank)(pATI, 0); + +#endif /* AVOID_CPIO */ + + /* Save clock data */ + ATIClockSave(pScreenInfo, pATI, pATIHW); + + if (pATI->Chip >= ATI_CHIP_264CT) + { + pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) | + PLL_VCLK_RESET; + pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV); + pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV); + pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV); + pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV); + pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV); + pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL); + if (pATI->Chip >= ATI_CHIP_264LT) + pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL); + } + + /* Save LCD registers */ + if (pATI->LCDPanelID >= 0) + { + if (pATI->Chip == ATI_CHIP_264LT) + { + pATIHW->horz_stretching = inr(HORZ_STRETCHING); + pATIHW->vert_stretching = inr(VERT_STRETCHING); + pATIHW->lcd_gen_ctrl = inr(LCD_GEN_CTRL); + + /* Set up to save non-shadow registers */ + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & + ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); + } + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + pATIHW->lcd_index = inr(LCD_INDEX); + pATIHW->config_panel = ATIGetMach64LCDReg(LCD_CONFIG_PANEL); + pATIHW->lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATIHW->vert_stretching = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + pATIHW->ext_vert_stretch = + ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH); + + /* Set up to save non-shadow registers */ + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & + ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); + } + } + +#ifndef AVOID_CPIO + + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + { + /* Save VGA data */ + ATIVGASave(pATI, pATIHW); + + /* Save VGA Wonder data */ + if (pATI->CPIO_VGAWonder) + ATIVGAWonderSave(pATI, pATIHW); + } + + /* Save Mach64 data */ + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + + { + ATIMach64Save(pATI, pATIHW); + } + + /* Save DSP data */ + if (pATI->Chip >= ATI_CHIP_264VTB) + ATIDSPSave(pATI, pATIHW); + + if (pATI->LCDPanelID >= 0) + { + if (!pATI->OptionCRT) + { + /* Switch to shadow registers */ + if (pATI->Chip == ATI_CHIP_264LT) + outr(LCD_GEN_CTRL, (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | + (SHADOW_EN | SHADOW_RW_EN)); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + ATIPutMach64LCDReg(LCD_GEN_CNTL, + (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | + (SHADOW_EN | SHADOW_RW_EN)); + +#ifndef AVOID_CPIO + + /* Save shadow VGA CRTC registers */ + for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) + pATIHW->shadow_vga[Index] = + GetReg(CRTX(pATI->CPIO_VGABase), Index); + +#endif /* AVOID_CPIO */ + + /* Save shadow Mach64 CRTC registers */ + pATIHW->shadow_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->shadow_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->shadow_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->shadow_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); + } + + /* Restore CRTC selection and shadow state */ + if (pATI->Chip == ATI_CHIP_264LT) + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); + outr(LCD_INDEX, pATIHW->lcd_index); + } + } + +#ifndef AVOID_CPIO + + /* + * For some unknown reason, CLKDIV2 needs to be turned off to save the + * DAC's LUT reliably on VGA Wonder VLB adapters. + */ + if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) + PutReg(SEQX, 0x01U, pATIHW->seq[1] & ~0x08U); + +#endif /* AVOID_CPIO */ + + /* Save RAMDAC state */ + ATIDACSave(pATI, pATIHW); + +#ifndef AVOID_CPIO + + if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) + PutReg(SEQX, 0x01U, pATIHW->seq[1]); + +#endif /* AVOID_CPIO */ + + /* + * The server has already saved video memory contents when switching out of + * its virtual console, so don't do it again. + */ + if (pATIHW != &pATI->NewHW) + { + pATIHW->FeedbackDivider = 0; /* Don't programme clock */ + +#ifndef AVOID_CPIO + + /* Save video memory */ + ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, FALSE); + +#endif /* AVOID_CPIO */ + + } + +#ifndef AVOID_CPIO + + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ + +#endif /* AVOID_CPIO */ + +} + +/* + * ATIModeCalculate -- + * + * This function fills in an ATIHWRec with all register values needed to enable + * a video state. It's important that this be done without modifying the + * current video state. + */ +Bool +ATIModeCalculate +( + int iScreen, + ATIPtr pATI, + ATIHWPtr pATIHW, + DisplayModePtr pMode +) +{ + CARD32 lcd_index; + int Index, ECPClock; + + /* Clobber mode timings */ + if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT && + !pMode->CrtcHAdjusted && !pMode->CrtcVAdjusted && + (!pATI->OptionSync || (pMode->type & M_T_BUILTIN))) + { + int VScan; + + pMode->Clock = pATI->LCDClock; + pMode->Flags &= ~(V_DBLSCAN | V_INTERLACE | V_CLKDIV2); + + /* + * Use doublescanning or multiscanning to get around vertical blending + * limitations. + */ + VScan = pATI->LCDVertical / pMode->VDisplay; + switch (pATIHW->crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + if (VScan > 64) + VScan = 64; + pMode->VScan = VScan; + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + pMode->VScan = 0; + if (VScan <= 1) + break; + VScan = 2; + pMode->Flags |= V_DBLSCAN; + break; + + default: + break; + } + + pMode->HSyncStart = pMode->HDisplay + pATI->LCDHSyncStart; + pMode->HSyncEnd = pMode->HSyncStart + pATI->LCDHSyncWidth; + pMode->HTotal = pMode->HDisplay + pATI->LCDHBlankWidth; + + pMode->VSyncStart = pMode->VDisplay + + ATIDivide(pATI->LCDVSyncStart, VScan, 0, 0); + pMode->VSyncEnd = pMode->VSyncStart + + ATIDivide(pATI->LCDVSyncWidth, VScan, 0, 1); + pMode->VTotal = pMode->VDisplay + + ATIDivide(pATI->LCDVBlankWidth, VScan, 0, 0); + } + + switch (pATIHW->crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Fill in VGA data */ + ATIVGACalculate(pATI, pATIHW, pMode); + + /* Fill in VGA Wonder data */ + if (pATI->CPIO_VGAWonder) + ATIVGAWonderCalculate(pATI, pATIHW, pMode); + + if (pATI->Chip >= ATI_CHIP_88800GXC) + { + if (pATI->Chip >= ATI_CHIP_264CT) + { + /* + * Selected bits of accelerator & VGA CRTC registers are + * actually copies of each other. + */ + pATIHW->crtc_h_total_disp = + SetBits(pMode->CrtcHTotal, CRTC_H_TOTAL) | + SetBits(pMode->CrtcHDisplay, CRTC_H_DISP); + pATIHW->crtc_h_sync_strt_wid = + SetBits(pMode->CrtcHSyncStart, CRTC_H_SYNC_STRT) | + SetBits(pMode->CrtcHSkew, CRTC_H_SYNC_DLY) | /* ? */ + SetBits(GetBits(pMode->CrtcHSyncStart, 0x0100U), + CRTC_H_SYNC_STRT_HI) | + SetBits(pMode->CrtcHSyncEnd, CRTC_H_SYNC_WID); + if (pMode->Flags & V_NHSYNC) + pATIHW->crtc_h_sync_strt_wid |= CRTC_H_SYNC_POL; + + pATIHW->crtc_v_total_disp = + SetBits(pMode->CrtcVTotal, CRTC_V_TOTAL) | + SetBits(pMode->CrtcVDisplay, CRTC_V_DISP); + pATIHW->crtc_v_sync_strt_wid = + SetBits(pMode->CrtcVSyncStart, CRTC_V_SYNC_STRT) | + SetBits(pMode->CrtcVSyncEnd, CRTC_V_SYNC_WID); + if (pMode->Flags & V_NVSYNC) + pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; + } + + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL) & + ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | + CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | + CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | + CRTC_VGA_XOVERSCAN | CRTC_VGA_128KAP_PAGING | + CRTC_VFC_SYNC_TRISTATE | + CRTC_LOCK_REGS | /* Already off, but ... */ + CRTC_SYNC_TRISTATE | CRTC_EXT_DISP_EN | + CRTC_DISP_REQ_EN | CRTC_VGA_LINEAR | CRTC_VGA_TEXT_132 | + CRTC_CUR_B_TEST); +#if 0 /* This isn't needed, but is kept for reference */ + if (pMode->Flags & V_DBLSCAN) + pATIHW->crtc_gen_cntl |= CRTC_DBL_SCAN_EN; +#endif + if (pMode->Flags & V_INTERLACE) + pATIHW->crtc_gen_cntl |= CRTC_INTERLACE_EN; + if ((pMode->Flags & (V_CSYNC | V_PCSYNC)) || pATI->OptionCSync) + pATIHW->crtc_gen_cntl |= CRTC_CSYNC_EN; + if (pATI->depth <= 4) + pATIHW->crtc_gen_cntl |= CRTC_EN | CRTC_CNT_EN; + else + pATIHW->crtc_gen_cntl |= + CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; + } + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + /* Fill in Mach64 data */ + ATIMach64Calculate(pATI, pATIHW, pMode); + break; + + default: + break; + } + + /* Set up LCD register values */ + if (pATI->LCDPanelID >= 0) + { + int VDisplay = pMode->VDisplay; + + if (pMode->Flags & V_DBLSCAN) + VDisplay <<= 1; + if (pMode->VScan > 1) + VDisplay *= pMode->VScan; + if (pMode->Flags & V_INTERLACE) + VDisplay >>= 1; + + if (pATI->Chip == ATI_CHIP_264LT) + pATIHW->horz_stretching = inr(HORZ_STRETCHING); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + lcd_index = inr(LCD_INDEX); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATIHW->ext_vert_stretch = + ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH) & + ~(AUTO_VERT_RATIO | VERT_STRETCH_MODE); + + /* + * Don't use vertical blending if the mode is too wide or not + * vertically stretched. + */ + if (!pATI->OptionCRT && + (pMode->HDisplay <= pATI->LCDVBlendFIFOSize) && + (VDisplay < pATI->LCDVertical)) + pATIHW->ext_vert_stretch |= VERT_STRETCH_MODE; + + outr(LCD_INDEX, lcd_index); + } + + pATIHW->horz_stretching &= + ~(HORZ_STRETCH_RATIO | HORZ_STRETCH_LOOP | AUTO_HORZ_RATIO | + HORZ_STRETCH_MODE | HORZ_STRETCH_EN); + if (!pATI->OptionCRT && (pMode->HDisplay < pATI->LCDHorizontal)) + pATIHW->horz_stretching |= (HORZ_STRETCH_MODE | HORZ_STRETCH_EN) | + SetBits(((pMode->HDisplay & ~7) * + (MaxBits(HORZ_STRETCH_BLEND) + 1)) / + pATI->LCDHorizontal, HORZ_STRETCH_BLEND); + + if (pATI->OptionCRT || (VDisplay >= pATI->LCDVertical)) + pATIHW->vert_stretching = 0; + else + { + pATIHW->vert_stretching = (VERT_STRETCH_USE0 | VERT_STRETCH_EN) | + SetBits((VDisplay * (MaxBits(VERT_STRETCH_RATIO0) + 1)) / + pATI->LCDVertical, VERT_STRETCH_RATIO0); + } + + if (!pATI->OptionCRT) + { + +#ifndef AVOID_CPIO + + /* Copy non-shadow CRTC register values to the shadow set */ + for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) + pATIHW->shadow_vga[Index] = pATIHW->crt[Index]; + +#endif /* AVOID_CPIO */ + + pATIHW->shadow_h_total_disp = pATIHW->crtc_h_total_disp; + pATIHW->shadow_h_sync_strt_wid = pATIHW->crtc_h_sync_strt_wid; + pATIHW->shadow_v_total_disp = pATIHW->crtc_v_total_disp; + pATIHW->shadow_v_sync_strt_wid = pATIHW->crtc_v_sync_strt_wid; + } + } + + /* Fill in clock data */ + if (!ATIClockCalculate(iScreen, pATI, pATIHW, pMode)) + return FALSE; + + /* Setup ECP clock divider */ + if (pATI->Chip >= ATI_CHIP_264VT) + { + pATIHW->pll_vclk_cntl &= ~PLL_ECP_DIV; + /* XXX Don't do this for TVOut! */ + ECPClock = pMode->SynthClock; + for (Index = 0; (ECPClock > 125000) && (Index < 2); Index++) + ECPClock >>= 1; + pATIHW->pll_vclk_cntl |= SetBits(Index, PLL_ECP_DIV); + } + + return TRUE; +} + +/* + * ATIModeSet -- + * + * This function sets a video mode. It writes out all video state data that + * has been previously calculated or saved. + */ +void +ATIModeSet +( + ScrnInfoPtr pScreenInfo, + ATIPtr pATI, + ATIHWPtr pATIHW +) +{ + +#ifndef AVOID_CPIO + + int Index; + + /* Get back to bank 0 */ + (*pATIHW->SetBank)(pATI, 0); + +#endif /* AVOID_CPIO */ + + if (pATI->Chip >= ATI_CHIP_264CT) + { + ATIPutMach64PLLReg(PLL_VCLK_CNTL, pATIHW->pll_vclk_cntl); + ATIPutMach64PLLReg(PLL_VCLK_POST_DIV, pATIHW->pll_vclk_post_div); + ATIPutMach64PLLReg(PLL_VCLK0_FB_DIV, pATIHW->pll_vclk0_fb_div); + ATIPutMach64PLLReg(PLL_VCLK1_FB_DIV, pATIHW->pll_vclk1_fb_div); + ATIPutMach64PLLReg(PLL_VCLK2_FB_DIV, pATIHW->pll_vclk2_fb_div); + ATIPutMach64PLLReg(PLL_VCLK3_FB_DIV, pATIHW->pll_vclk3_fb_div); + ATIPutMach64PLLReg(PLL_XCLK_CNTL, pATIHW->pll_xclk_cntl); + if (pATI->Chip >= ATI_CHIP_264LT) + ATIPutMach64PLLReg(PLL_EXT_VPLL_CNTL, pATIHW->pll_ext_vpll_cntl); + ATIPutMach64PLLReg(PLL_VCLK_CNTL, + pATIHW->pll_vclk_cntl & ~PLL_VCLK_RESET); + } + + /* Load LCD registers */ + if (pATI->LCDPanelID >= 0) + { + /* Stop CRTC */ + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & + ~(CRTC_EXT_DISP_EN | CRTC_EN)); + + if (pATI->Chip == ATI_CHIP_264LT) + { + /* Update non-shadow registers first */ + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & + ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | + SHADOW_EN | SHADOW_RW_EN)); + + /* Temporarily disable stretching */ + outr(HORZ_STRETCHING, pATIHW->horz_stretching & + ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); + outr(VERT_STRETCHING, pATIHW->vert_stretching & + ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | + VERT_STRETCH_USE0 | VERT_STRETCH_EN)); + } + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + /* Update non-shadow registers first */ + ATIPutMach64LCDReg(LCD_CONFIG_PANEL, pATIHW->config_panel); + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & + ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | + SHADOW_EN | SHADOW_RW_EN)); + + /* Temporarily disable stretching */ + ATIPutMach64LCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching & + ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); + ATIPutMach64LCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching & + ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | + VERT_STRETCH_USE0 | VERT_STRETCH_EN)); + } + } + + switch (pATIHW->crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Stop CRTC */ + if (pATI->Chip >= ATI_CHIP_88800GXC) + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); + + /* Start sequencer reset */ + PutReg(SEQX, 0x00U, 0x00U); + + /* Set pixel clock */ + if ((pATIHW->FeedbackDivider > 0) && + (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) + ATIClockSet(pATI, pATIHW); + + /* Load VGA Wonder */ + if (pATI->CPIO_VGAWonder) + ATIVGAWonderSet(pATI, pATIHW); + + /* Load VGA device */ + ATIVGASet(pATI, pATIHW); + + /* Load Mach64 registers */ + if (pATI->Chip >= ATI_CHIP_88800GXC) + { + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); + outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); + outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); + outr(CONFIG_CNTL, pATIHW->config_cntl); + if (pATI->Chip >= ATI_CHIP_264CT) + { + outr(CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); + outr(CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(DAC_CNTL, pATIHW->dac_cntl); + } + } + + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + /* Load Mach64 CRTC registers */ + ATIMach64Set(pATI, pATIHW); + +#ifndef AVOID_CPIO + + if (pATI->UseSmallApertures) + { + /* Oddly enough, these need to be set also, maybe others */ + PutReg(SEQX, 0x02U, pATIHW->seq[2]); + PutReg(SEQX, 0x04U, pATIHW->seq[4]); + PutReg(GRAX, 0x06U, pATIHW->gra[6]); + if (pATI->CPIO_VGAWonder) + ATIModifyExtReg(pATI, 0xB6U, -1, 0x00U, pATIHW->b6); + } + +#endif /* AVOID_CPIO */ + + break; + + default: + break; + } + + if (pATI->LCDPanelID >= 0) + { + if (!pATI->OptionCRT && + (!pATI->OptionDevel || (pATIHW == &pATI->OldHW))) + { + /* Switch to shadow registers */ + if (pATI->Chip == ATI_CHIP_264LT) + outr(LCD_GEN_CTRL, (pATIHW->lcd_gen_ctrl & + ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | + (SHADOW_EN | SHADOW_RW_EN)); + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + ATIPutMach64LCDReg(LCD_GEN_CNTL, + (pATIHW->lcd_gen_ctrl & + ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | + (SHADOW_EN | SHADOW_RW_EN)); + + /* Restore shadow registers */ + switch (pATIHW->crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + for (Index = 0; + Index < NumberOf(pATIHW->shadow_vga); + Index++) + PutReg(CRTX(pATI->CPIO_VGABase), Index, + pATIHW->shadow_vga[Index]); + /* Fall through */ + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + outr(CRTC_H_TOTAL_DISP, pATIHW->shadow_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->shadow_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->shadow_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->shadow_v_sync_strt_wid); + break; + + default: + break; + } + } + + /* Restore CRTC selection & shadow state and enable stretching */ + if (pATI->Chip == ATI_CHIP_264LT) + { + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); + outr(HORZ_STRETCHING, pATIHW->horz_stretching); + outr(VERT_STRETCHING, pATIHW->vert_stretching); + } + else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || + (pATI->Chip == ATI_CHIP_264XL) || + (pATI->Chip == ATI_CHIP_MOBILITY)) */ + { + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching); + ATIPutMach64LCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching); + ATIPutMach64LCDReg(LCD_EXT_VERT_STRETCH, pATIHW->ext_vert_stretch); + outr(LCD_INDEX, pATIHW->lcd_index); + } + } + + /* + * Set DSP registers. Note that, for some reason, sequencer resets clear + * the DSP_CONFIG register on early integrated controllers. + */ + if (pATI->Chip >= ATI_CHIP_264VTB) + ATIDSPSet(pATI, pATIHW); + + /* Load RAMDAC */ + ATIDACSet(pATI, pATIHW); + +#ifndef AVOID_CPIO + + /* Restore video memory */ + ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, TRUE); + + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ + +#endif /* AVOID_CPIO */ + + if ((xf86GetVerbosity() > 3) && (pATIHW == &pATI->NewHW)) + { + xf86ErrorFVerb(4, "\n After setting mode \"%s\":\n\n", + pScreenInfo->currentMode->name); + ATIPrintMode(pScreenInfo->currentMode); + ATIPrintRegisters(pATI); + } +} + +/* + * ATIModeAccelInit -- + * + * This function is called to initialise XAA on a screen. + */ +Bool +ATIModeAccelInit +( + ScrnInfoPtr pScreenInfo, + ScreenPtr pScreen, + ATIPtr pATI +) +{ + BoxRec ScreenArea; + + if (!pATI->OptionAccel) + return TRUE; + + if (!(pATI->pXAAInfo = XAACreateInfoRec())) + return FALSE; + + switch (pATI->Adapter) + { + case ATI_ADAPTER_MACH64: + if (ATIMach64AccelInit(pATI, pATI->pXAAInfo)) + break; + + default: + XAADestroyInfoRec(pATI->pXAAInfo); + pATI->pXAAInfo = NULL; + return FALSE; + } + + ScreenArea.x1 = ScreenArea.y1 = 0; + ScreenArea.x2 = pATI->displayWidth; + ScreenArea.y2 = pScreenInfo->videoRam * 1024 * 8 / pATI->displayWidth / + pATI->bitsPerPixel; + if ((unsigned)ScreenArea.y2 > ATIMach64MaxY) + ScreenArea.y2 = ATIMach64MaxY; + xf86InitFBManager(pScreen, &ScreenArea); + + if (XAAInit(pScreen, pATI->pXAAInfo)) + return TRUE; + + XAADestroyInfoRec(pATI->pXAAInfo); + pATI->pXAAInfo = NULL; + return FALSE; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h:1.1 --- /dev/null Mon Dec 18 14:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h Wed Oct 11 18:52:56 2000 @@ -0,0 +1,44 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimode.h,v 1.1 2000/10/11 22:52:56 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATIMODE_H___ +#define ___ATIMODE_H___ 1 + +#include "atipriv.h" +#include "atiproto.h" + +#include "xf86str.h" + +extern void ATIModePreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, + ATIHWPtr)); +extern void ATIModeSave FunctionPrototype((ScrnInfoPtr, ATIPtr, + ATIHWPtr)); +extern Bool ATIModeCalculate FunctionPrototype((int, ATIPtr, ATIHWPtr, + DisplayModePtr)); +extern void ATIModeSet FunctionPrototype((ScrnInfoPtr, ATIPtr, + ATIHWPtr)); + +extern Bool ATIModeAccelInit FunctionPrototype((ScrnInfoPtr, ScreenPtr, + ATIPtr)); + +#endif /* ___ATIMODE_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c:1.6 Mon Jun 19 11:00:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c Thu Nov 2 11:55:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.6 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.11 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,11 +25,51 @@ #include "ati.h" #include "atimodule.h" -#include "atistruct.h" #include "ativersion.h" /* Module loader interface */ +const char *ATISymbols[] = +{ + "ATIPreInit", + "ATIScreenInit", + "ATISwitchMode", + "ATIAdjustFrame", + "ATIEnterVT", + "ATILeaveVT", + "ATIFreeScreen", + "ATIValidMode", + NULL +}; + +const char *R128Symbols[] = +{ + "R128PreInit", + "R128ScreenInit", + "R128SwitchMode", + "R128AdjustFrame", + "R128EnterVT", + "R128LeaveVT", + "R128FreeScreen", + "R128ValidMode", + "R128Options", + NULL +}; + +const char *RADEONSymbols[] = +{ + "RADEONPreInit", + "RADEONScreenInit", + "RADEONSwitchMode", + "RADEONAdjustFrame", + "RADEONEnterVT", + "RADEONLeaveVT", + "RADEONFreeScreen", + "RADEONValidMode", + "RADEONOptions", + NULL +}; + static XF86ModuleVersionInfo ATIVersionRec = { ATI_DRIVER_NAME, @@ -65,29 +105,14 @@ Inited = TRUE; xf86AddDriver(&ATI, Module, 0); - /* - * Tell loader about symbols from other modules that this module might - * refer to. - */ - LoaderRefSymbols( - "xf1bppScreenInit", - "xf4bppScreenInit", - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", - "ShadowFBInit", - "XAACreateInfoRec", - "XAADestroyInfoRec", - "XAAInit", + LoaderRefSymLists( + ATISymbols, + R128Symbols, + RADEONSymbols, NULL); - - return (pointer)TRUE; } - if (ErrorMajor) - *ErrorMajor = LDR_ONCEONLY; - return NULL; + return (pointer)1; } /* The following record must be called atiModuleData */ @@ -97,79 +122,5 @@ ATISetup, NULL }; - -/* - * ATILoadModule -- - * - * Load a specific module and register its main entry with the loader. - */ -static Bool -ATILoadModule -( - ScrnInfoPtr pScreenInfo, - const char *Module, - const char *Symbol -) -{ - if (!xf86LoadSubModule(pScreenInfo, Module)) - return FALSE; - - xf86LoaderReqSymbols(Symbol, NULL); - - return TRUE; -} - -/* - * ATILoadModules -- - * - * This function loads other modules required for a screen. - */ -Bool -ATILoadModules -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI -) -{ - /* Load shadow frame buffer code if needed */ - if (pATI->OptionShadowFB && - !ATILoadModule(pScreenInfo, "shadowfb", "ShadowFBInit")) - return FALSE; - - /* Load XAA if needed */ - if (pATI->OptionAccel) - { - if (!ATILoadModule(pScreenInfo, "xaa", "XAAInit")) - return FALSE; - - /* Require more XAA symbols */ - xf86LoaderReqSymbols("XAACreateInfoRec", "XAADestroyInfoRec", NULL); - } - - /* Load depth-specific entry points */ - switch (pATI->bitsPerPixel) - { - case 1: - return ATILoadModule(pScreenInfo, "xf1bpp", "xf1bppScreenInit"); - - case 4: - return ATILoadModule(pScreenInfo, "xf4bpp", "xf4bppScreenInit"); - - case 8: - return ATILoadModule(pScreenInfo, "cfb", "cfbScreenInit"); - - case 16: - return ATILoadModule(pScreenInfo, "cfb16", "cfb16ScreenInit"); - - case 24: - return ATILoadModule(pScreenInfo, "cfb24", "cfb24ScreenInit"); - - case 32: - return ATILoadModule(pScreenInfo, "cfb32", "cfb32ScreenInit"); - - default: - return FALSE; - } -} #endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h:1.3 xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h:1.3 Fri Feb 18 07:19:26 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h Thu Nov 2 11:55:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.3 2000/02/18 12:19:26 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.6 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,13 +21,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#if defined(XFree86LOADER) && !defined(___ATI_MODULE_H___) -#define ___ATI_MODULE_H___ 1 +#if defined(XFree86LOADER) && !defined(___ATIMODULE_H___) +#define ___ATIMODULE_H___ 1 -#include "atipriv.h" -#include "atiproto.h" -#include "xf86str.h" +extern const char *ATISymbols[]; +extern const char *R128Symbols[]; +extern const char *RADEONSymbols[]; -extern Bool ATILoadModules FunctionPrototype((ScrnInfoPtr, ATIPtr)); - -#endif +#endif /* ___ATIMODULE_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c:1.8 Tue May 2 20:44:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c Thu Nov 2 11:55:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.8 2000/05/03 00:44:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.13 2000/11/02 16:55:28 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,44 +21,84 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "ati.h" -#include "atiadapter.h" -#include "atibus.h" #include "atioption.h" -#include "atistruct.h" +#include "atiutil.h" +#include "radeon_probe.h" +#include "r128_probe.h" + /* * Recognised XF86Config options. */ -typedef enum -{ - ATI_OPTION_ACCEL, - ATI_OPTION_CRT, - ATI_OPTION_CSYNC, - ATI_OPTION_LINEAR, - ATI_OPTION_MMIO_CACHE, - ATI_OPTION_PROBE_CLOCKS, - ATI_OPTION_SHADOW_FB -} ATIPublicOptionType; - -typedef enum +OptionInfoRec ATIPublicOptions[] = { - ATI_OPTION_DEVEL, /* Intentionally undocumented */ - ATI_OPTION_SYNC /* Temporary and undocumented */ -} ATIPrivateOptionType; - -static OptionInfoRec ATIPublicOptions[] = -{ - {ATI_OPTION_ACCEL, "accel", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_CRT, "crt_screen", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_CSYNC, "composite_sync", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_LINEAR, "linear", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_MMIO_CACHE, "mmio_cache", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_PROBE_CLOCKS, "probe_clocks", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_SHADOW_FB, "shadow_fb", OPTV_BOOLEAN, {0, }, FALSE}, - {-1, NULL, OPTV_NONE , {0, }, FALSE} + { + ATI_OPTION_ACCEL, + "accel", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_CRT, + "crt_screen", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_CSYNC, + "composite_sync", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_LINEAR, + "linear", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_MMIO_CACHE, + "mmio_cache", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_PROBE_CLOCKS, + "probe_clocks", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_REFERENCE_CLOCK, + "reference_clock", + OPTV_FREQ, + {0, }, + FALSE + }, + { + ATI_OPTION_SHADOW_FB, + "shadow_fb", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + -1, + NULL, + OPTV_NONE, + {0, }, + FALSE + } }; +const unsigned long ATIPublicOptionSize = SizeOf(ATIPublicOptions); + /* * ATIAvailableOptions -- * @@ -71,74 +111,13 @@ int BusId /* Ignored */ ) { - return ATIPublicOptions; -} + OptionInfoPtr pOptions; -/* - * ATIProcessOptions -- - * - * This function extracts options from what was parsed out of the XF86Config - * file. - */ -void -ATIProcessOptions -( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI -) -{ - OptionInfoRec PublicOption[NumberOf(ATIPublicOptions)]; - OptionInfoRec PrivateOption[] = - { - {ATI_OPTION_DEVEL, "tsi", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_SYNC, "lcdsync", OPTV_BOOLEAN, {0, }, FALSE}, - {-1, NULL, OPTV_NONE , {0, }, FALSE} - }; - - (void)memcpy(PublicOption, ATIPublicOptions, SizeOf(ATIPublicOptions)); - -# define Accel PublicOption[ATI_OPTION_ACCEL].value.bool -# define CRTScreen PublicOption[ATI_OPTION_CRT].value.bool -# define CSync PublicOption[ATI_OPTION_CSYNC].value.bool -# define Devel PrivateOption[ATI_OPTION_DEVEL].value.bool -# define Linear PublicOption[ATI_OPTION_LINEAR].value.bool -# define CacheMMIO PublicOption[ATI_OPTION_MMIO_CACHE].value.bool -# define ProbeClocks PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool -# define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool -# define Sync PrivateOption[ATI_OPTION_SYNC].value.bool - - /* Pick up XF86Config options */ - xf86CollectOptions(pScreenInfo, NULL); - - /* Set non-zero defaults */ - if (pATI->Adapter >= ATI_ADAPTER_MACH64) - Accel = Linear = CacheMMIO = TRUE; - if (pATI->BusType >= ATI_BUS_PCI) - ShadowFB = TRUE; - Sync = TRUE; - - xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, - PublicOption); - xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, - PrivateOption); - - /* Disable linear apertures if the OS doesn't support them */ - if (!xf86LinearVidMem() && Linear) - { - if (PublicOption[ATI_OPTION_LINEAR].found) - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "OS does not support linear apertures.\n"); - Linear = FALSE; - } + if ((pOptions = R128AvailableOptions(ChipId, BusId))) + return pOptions; + + if ((pOptions = RADEONAvailableOptions(ChipId, BusId))) + return pOptions; - /* Move option values into driver private structure */ - pATI->OptionAccel = Accel; - pATI->OptionCRT = CRTScreen; - pATI->OptionCSync = CSync; - pATI->OptionDevel = Devel; - pATI->OptionLinear = Linear; - pATI->OptionMMIOCache = CacheMMIO; - pATI->OptionProbeClocks = ProbeClocks; - pATI->OptionShadowFB = ShadowFB; - pATI->OptionSync = Sync; + return ATIPublicOptions; } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h:1.2 Fri Feb 18 07:19:27 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h Wed Oct 11 18:52:57 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h,v 1.2 2000/02/18 12:19:27 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h,v 1.4 2000/10/11 22:52:57 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,12 +24,28 @@ #ifndef ___ATIOPTION_H___ #define ___ATIOPTION_H___ 1 -#include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" + +/* + * Documented XF86Config options. + */ +typedef enum +{ + ATI_OPTION_ACCEL, + ATI_OPTION_CRT, + ATI_OPTION_CSYNC, + ATI_OPTION_LINEAR, + ATI_OPTION_MMIO_CACHE, + ATI_OPTION_PROBE_CLOCKS, + ATI_OPTION_REFERENCE_CLOCK, + ATI_OPTION_SHADOW_FB +} ATIPublicOptionType; + +extern OptionInfoRec ATIPublicOptions[]; +extern const unsigned long ATIPublicOptionSize; -extern OptionInfoPtr ATIAvailableOptions FunctionPrototype((int, int)); -extern void ATIProcessOptions FunctionPrototype((ScrnInfoPtr, - ATIPtr)); +extern OptionInfoPtr ATIAvailableOptions FunctionPrototype((int, int)); #endif /* ___ATIOPTION_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c:1.26 xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c:1.39 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c:1.26 Mon Jun 19 11:00:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c Tue Dec 12 19:45:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.26 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.39 2000/12/13 00:45:20 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,19 +26,25 @@ #include "atiadjust.h" #include "atibus.h" #include "atichip.h" +#include "aticonfig.h" #include "atidac.h" #include "atidsp.h" #include "atiident.h" +#include "atiload.h" #include "atilock.h" #include "atimach64.h" -#include "atimodule.h" -#include "atioption.h" +#include "atimach64io.h" +#include "atimode.h" #include "atipreinit.h" #include "atiprint.h" #include "atividmem.h" +#include "atiwonderio.h" + #include "vbe.h" #include "xf86RAC.h" +#ifndef AVOID_CPIO + typedef CARD16 Colour; /* The correct spelling should be OK :-) */ /* @@ -277,6 +283,8 @@ return Test_Case[Case_Number].videoRamSize; } +#endif /* AVOID_CPIO */ + /* * ATIReportMemory -- * @@ -295,6 +303,9 @@ Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "%d kB of %s detected", pATI->VideoRAM, MemoryTypeName); + +#ifndef AVOID_CPIO + if (pATI->depth == 1) { /* 1bpp only uses one plane of four */ @@ -302,7 +313,11 @@ Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, " (using %d kB)", pScreenInfo->videoRam); } - else if (pATI->VideoRAM > pScreenInfo->videoRam) + else + +#endif /* AVOID_CPIO */ + + if (pATI->VideoRAM > pScreenInfo->videoRam) Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, " (using %d kB)", pScreenInfo->videoRam); xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s.\n", Buffer); @@ -314,6 +329,47 @@ static const Gamma defaultGamma = {0.0, 0.0, 0.0}; /* + * ATIMapMach64 -- + * + * This function attempts to mmap() a Mach64's MMIO aperture. + */ +static void +ATIMapMach64 +( + int iScreen, + ATIPtr pATI +) +{ + (void)ATIMapApertures(iScreen, pATI); + if (!pATI->pBlock[0] || + (pATI->config_chip_id != inr(CONFIG_CHIP_ID))) + ATIUnmapApertures(iScreen, pATI); +} + +/* + * ATIPrintNoiseIfRequested -- + * + * This function formats debugging information on the server's stderr when + * requested by the user through the server's verbosity setting. + */ +static void +ATIPrintNoiseIfRequested +( + ATIPtr pATI, + CARD8 *BIOS, + unsigned int BIOSSize +) +{ + if (xf86GetVerbosity() <= 3) + return; + + if (BIOSSize > 0) + ATIPrintBIOS(BIOS, BIOSSize); + xf86ErrorFVerb(4, "\n On server entry:\n"); + ATIPrintRegisters(pATI); +} + +/* * ATIPreInit -- * * This function is only called once per screen at the start of the first @@ -327,11 +383,15 @@ ) { # define BIOS_SIZE 0x00010000U /* 64kB */ - CARD8 BIOS[BIOS_SIZE], *pBIOS; -# define BIOSByte(_n) (*((CARD8 *)(BIOS + (_n)))) -# define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n)))) -# define BIOSLong(_n) (*((CARD32 *)(BIOS + (_n)))) - unsigned int BIOSSize; + CARD8 BIOS[BIOS_SIZE]; +# define BIOSByte(_n) (BIOS[_n]) +# define BIOSWord(_n) (BIOS[_n] | \ + (BIOS[(_n) + 1] << 8)) +# define BIOSLong(_n) (BIOS[_n] | \ + (BIOS[(_n) + 1] << 8) | \ + (BIOS[(_n) + 2] << 16) | \ + (BIOS[(_n) + 3] << 24)) + unsigned int BIOSSize = 0; unsigned int ROMTable = 0, ClockTable = 0, FrequencyTable = 0; unsigned int LCDTable = 0, LCDPanelInfo = 0; @@ -340,21 +400,28 @@ GDevPtr pGDev; EntityInfoPtr pEntity; resPtr pResources; + pciVideoPtr pVideo; DisplayModePtr pMode; - xf86Int10InfoPtr pInt10Info; - vbeInfoPtr pVBE; - xf86MonPtr pMonitor = NULL; - pointer pInt10Module, pDDCModule, pVBEModule = NULL; - Bool AllowCRT = TRUE; - CARD32 IOValue1, IOValue2 = 0; - int i, j, AcceleratorVideoRAM = 0, VGAVideoRAM = 0; + unsigned long Block0Base; + CARD32 IOValue1, IOValue2 = 0, IOValue3 = 0, IOValue4 = 0; + int i, j, AcceleratorVideoRAM = 0; int Numerator, Denominator; int MinX, MinY; - resRange Resources[2] = {{0, 0, 0}, _END}; ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0}; int minPitch, maxPitch = 0xFFU, maxHeight = 0; + int ApertureSize = 0x00010000U; LookupModeFlags Strategy = LOOKUP_CLOSEST_CLOCK; +#ifndef AVOID_CPIO + + xf86Int10InfoPtr pInt10Info = NULL; + vbeInfoPtr pVBE; + pointer pInt10Module, pDDCModule = NULL, pVBEModule = NULL; + int VGAVideoRAM = 0; + resRange Resources[2] = {{0, 0, 0}, _END}; + +#endif /* AVOID_CPIO */ + if (pScreenInfo->numEntities != 1) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, @@ -371,100 +438,214 @@ return FALSE; } - /* - * Get adapter BIOS, after ensuring its initialisation entry point has been - * executed. - */ - if (!(pInt10Module = xf86LoadSubModule(pScreenInfo, "int10"))) + /* Register resources */ + pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); + pGDev = pEntity->device; + pResources = pEntity->resources; + xfree(pEntity); + if (!pResources) + pResources = xf86RegisterResources(pATI->iEntity, NULL, + pATI->SharedAccelerator ? ResShared : ResExclusive); + if (pResources) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to load int10 module.\n"); + "Unable to register the following bus resources:\n"); + xf86PrintResList(0, pResources); + xf86FreeResList(pResources); return FALSE; } + + ConfiguredMonitor = NULL; - if (!(pInt10Info = xf86InitInt10(pATI->iEntity))) + if (!(flags & PROBE_DETECT)) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to initialise int10 interface.\n"); - xf86UnloadSubModule(pInt10Module); - return FALSE; + xf86DrvMsg(pScreenInfo->scrnIndex, + pATI->Chipset ? X_CONFIG : X_DEFAULT, + "Chipset: \"%s\".\n", ATIChipsetNames[pATI->Chipset]); + + /* Promote chipset specification */ + switch (pATI->Chipset) + { + +#ifndef AVOID_CPIO + + case ATI_CHIPSET_IBMVGA: + if (pATI->Adapter == ATI_ADAPTER_VGA) + break; /* XXX */ + /* Fall through */ + + case ATI_CHIPSET_VGAWONDER: + pATI->Chipset = ATI_CHIPSET_ATIVGA; + break; + + case ATI_CHIPSET_IBM8514: + if (pATI->Adapter == ATI_ADAPTER_8514A) + break; /* XXX */ + /* Fall through */ + + case ATI_CHIPSET_MACH8: + case ATI_CHIPSET_MACH32: + +#endif /* AVOID_CPIO */ + + case ATI_CHIPSET_MACH64: + case ATI_CHIPSET_RAGE128: + case ATI_CHIPSET_RADEON: + pATI->Chipset = ATI_CHIPSET_ATI; + break; + + default: + break; + } + + /* Set monitor */ + pScreenInfo->monitor = pScreenInfo->confScreen->monitor; + + /* Set depth, bpp, etc. */ + if ((pATI->Chipset != ATI_CHIPSET_ATI) || + (pATI->Chip < ATI_CHIP_264CT)) + i = NoDepth24Support; /* No support for >8bpp either */ + else + i = Support24bppFb | Support32bppFb; + if (!xf86SetDepthBpp(pScreenInfo, 8, 8, 8, i)) + return FALSE; + + for (j = 0; ; j++) + { + static const CARD8 AllowedDepthBpp[][2] = + { +#ifndef AVOID_CPIO + { 1, 1}, + { 4, 4}, + { 4, 8}, +#endif /* AVOID_CPIO */ + { 8, 8}, + {15, 16}, + {16, 16}, + {24, 24}, + {24, 32} + }; + + if (j < NumberOf(AllowedDepthBpp)) + { + if (pScreenInfo->depth > AllowedDepthBpp[j][0]) + continue; + + if (pScreenInfo->depth == AllowedDepthBpp[j][0]) + { + if (pScreenInfo->bitsPerPixel > AllowedDepthBpp[j][1]) + continue; + + if (pScreenInfo->bitsPerPixel == AllowedDepthBpp[j][1]) + break; + } + } + + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Driver does not support depth %d at fbbpp %d.\n", + pScreenInfo->depth, pScreenInfo->bitsPerPixel); + return FALSE; + } + + xf86PrintDepthBpp(pScreenInfo); + + if ((i == NoDepth24Support) && (pScreenInfo->depth > 8)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Depth %d is not supported through this adapter.\n", + pScreenInfo->depth); + return FALSE; + } + + /* Pick up XF86Config options */ + ATIProcessOptions(pScreenInfo, pATI); } - if (!(pDDCModule = xf86LoadSubModule(pScreenInfo, "ddc"))) - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to load ddc module.\n"); - else if (!(pVBEModule = xf86LoadSubModule(pScreenInfo, "vbe"))) - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to load vbe module.\n"); +#ifdef AVOID_CPIO + else - { - if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) - pMonitor = vbeDoEDID(pVBE, pDDCModule); - vbeFree(pVBE); - xf86UnloadSubModule(pVBEModule); - } + return TRUE; + +#else /* AVOID_CPIO */ /* - * Validate, then make a private copy of, the initialised BIOS. This - * allows de-activating int10 early. + * If there is an ix86-style BIOS, ensure its initialisation entry point + * has been executed, and retrieve DDC and VBE information from it. */ - pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4); - if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || !pBIOS[2]) + (void)memset(BIOS, 0, SizeOf(BIOS)); + if (!(pInt10Module = xf86LoadSubModule(pScreenInfo, "int10"))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to load int10 module.\n"); + else if (!(pInt10Info = xf86InitInt10(pATI->iEntity))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to initialise int10 interface.\n"); + else { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to correctly retrieve adapter BIOS.\n"); - xf86FreeInt10(pInt10Info); - xf86UnloadSubModule(pInt10Module); - return FALSE; - } + if (!(pDDCModule = xf86LoadSubModule(pScreenInfo, "ddc"))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to load ddc module.\n"); + else if (!(pVBEModule = xf86LoadSubModule(pScreenInfo, "vbe"))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to load vbe module.\n"); + else + { + if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) + { + ConfiguredMonitor = vbeDoEDID(pVBE, pDDCModule); + vbeFree(pVBE); + } + xf86UnloadSubModule(pVBEModule); + } - BIOSSize = pBIOS[2] << 9; - (void)memcpy(BIOS, pBIOS, BIOSSize); - if (BIOSSize < SizeOf(BIOS)) - (void)memset(BIOS + BIOSSize, 0, SizeOf(BIOS) - BIOSSize); + if (!(flags & PROBE_DETECT)) + { + /* Validate, then make a private copy of, the initialised BIOS */ + CARD8 *pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4); + if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || !pBIOS[2]) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to correctly retrieve adapter BIOS.\n"); + else + { + BIOSSize = pBIOS[2] << 9; + if (BIOSSize > BIOS_SIZE) + BIOSSize = BIOS_SIZE; + (void)memcpy(BIOS, pBIOS, BIOSSize); + } + } + } + /* De-activate int10 */ xf86FreeInt10(pInt10Info); xf86UnloadSubModule(pInt10Module); if (flags & PROBE_DETECT) { - ConfiguredMonitor = pMonitor; xf86UnloadSubModule(pDDCModule); return TRUE; } - /* Register resources */ - pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); - pGDev = pEntity->device; - pResources = pEntity->resources; - xfree(pEntity); - if (!pResources) - pResources = xf86RegisterResources(pATI->iEntity, NULL, - pATI->SharedAccelerator ? ResShared : ResExclusive); - if (pResources) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to register the following bus resources:\n"); - xf86PrintResList(0, pResources); - xf86FreeResList(pResources); - return FALSE; - } + xf86PrintEDID(ConfiguredMonitor); + xf86SetDDCproperties(pScreenInfo, ConfiguredMonitor); - pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT; - pScreenInfo->racMemFlags = RAC_FB; + /* DDC module is no longer needed at this point */ + xf86UnloadSubModule(pDDCModule); - /* Set monitor */ - pScreenInfo->monitor = pScreenInfo->confScreen->monitor; +#endif /* AVOID_CPIO */ - if (pMonitor) + pATI->Block0Base = 0; /* Might no longer be valid */ + if ((pVideo = pATI->PCIInfo)) { - xf86PrintEDID(pMonitor); - xf86SetDDCproperties(pScreenInfo, pMonitor); + if (pATI->CPIODecoding == BLOCK_IO) + pATI->CPIOBase = pVideo->ioBase[1]; + + /* Set MMIO address from PCI configuration space, if available */ + if ((pATI->Block0Base = pVideo->memBase[2])) + pATI->Block0Base += 0x0400U; } - /* DDC module is no longer needed at this point */ - xf86UnloadSubModule(pDDCModule); + pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT; + pScreenInfo->racMemFlags = RAC_FB; /* Deal with ChipID & ChipRev overrides */ if (pGDev->chipID >= 0) @@ -501,19 +682,26 @@ /* Finish private area initialisation */ pATI->DAC = ATI_DAC_GENERIC; + +#ifndef AVOID_CPIO + pATI->NewHW.SetBank = ATIx8800SetBank; pATI->BankInfo.SetSourceBank = ATIx8800SetRead; pATI->BankInfo.SetDestinationBank = ATIx8800SetWrite; pATI->BankInfo.SetSourceAndDestinationBanks = ATIx8800SetReadWrite; pATI->BankInfo.BankSize = 0x00010000U; /* 64kB */ - pATI->ApertureBase = 0x000A0000U; - pATI->ApertureSize = 0x00010000U; + +#endif /* AVOID_CPIO */ + pATI->LCDPanelID = -1; pATI->nFIFOEntries = 16; /* For now */ /* Finish probing the adapter */ switch (pATI->Adapter) { + +#ifndef AVOID_CPIO + case ATI_ADAPTER_NONE: case ATI_ADAPTER_EGA: case ATI_ADAPTER_EGA_PLUS: @@ -573,25 +761,77 @@ break; +#endif /* AVOID_CPIO */ + case ATI_ADAPTER_MACH64: - /* Set I/O port addresses */ - pATI->CPIO_CRTC_H_TOTAL_DISP = ATIIOPort(CRTC_H_TOTAL_DISP); - pATI->CPIO_CRTC_H_SYNC_STRT_WID = ATIIOPort(CRTC_H_SYNC_STRT_WID); - pATI->CPIO_CRTC_V_TOTAL_DISP = ATIIOPort(CRTC_V_TOTAL_DISP); - pATI->CPIO_CRTC_V_SYNC_STRT_WID = ATIIOPort(CRTC_V_SYNC_STRT_WID); - pATI->CPIO_CRTC_OFF_PITCH = ATIIOPort(CRTC_OFF_PITCH); - pATI->CPIO_CRTC_INT_CNTL = ATIIOPort(CRTC_INT_CNTL); - pATI->CPIO_CRTC_GEN_CNTL = ATIIOPort(CRTC_GEN_CNTL); - pATI->CPIO_OVR_CLR = ATIIOPort(OVR_CLR); - pATI->CPIO_OVR_WID_LEFT_RIGHT = ATIIOPort(OVR_WID_LEFT_RIGHT); - pATI->CPIO_OVR_WID_TOP_BOTTOM = ATIIOPort(OVR_WID_TOP_BOTTOM); - pATI->CPIO_CLOCK_CNTL = ATIIOPort(CLOCK_CNTL); - pATI->CPIO_MEM_INFO = ATIIOPort(MEM_INFO); - pATI->CPIO_DAC_REGS = ATIIOPort(DAC_REGS); - pATI->CPIO_DAC_CNTL = ATIIOPort(DAC_CNTL); - pATI->CPIO_CONFIG_CNTL = ATIIOPort(CONFIG_CNTL); + /* Find and mmap() MMIO area */ + Block0Base = pATI->Block0Base; + do + { + /* Only allow auxiliary aperture if it exists */ + if (!pATI->Block0Base) + { + if (pVideo) + { + /* Check tail end of linear (8MB or 4MB) aperture */ + if ((pATI->Block0Base = pVideo->memBase[0])) + { + pATI->Block0Base += 0x007FFC00U; + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + if (pATI->pBlock[0]) + break; + + pATI->Block0Base -= 0x00400000U; + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + if (pATI->pBlock[0]) + break; + } + } + + /* Check VGA MMIO aperture */ + pATI->Block0Base = 0x000BFC00U; + } + + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + } while(0); + pATI->Block0Base = Block0Base; + +#ifdef AVOID_CPIO + + if (!pATI->pBlock[0]) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to mmap() adapter registers.\n"); + return FALSE; + } + +#endif /* AVOID_CPIO */ + + IOValue1 = inr(CRTC_GEN_CNTL); + if (!(IOValue1 & CRTC_EN) && (pATI->Chip >= ATI_CHIP_264CT)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Adapter has not been initialised.\n"); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + +#ifdef AVOID_CPIO + + if (!(IOValue1 & CRTC_EXT_DISP_EN)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Adapters found to be in VGA mode on server entry are not" + " supported by the MMIO-only version of this driver.\n"); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } - IOValue1 = inl(pATI->CPIO_MEM_INFO); +#endif /* AVOID_CPIO */ + + IOValue1 = inr(MEM_CNTL); if (pATI->Chip < ATI_CHIP_264VTB) pATI->VideoRAM = videoRamSizes[GetBits(IOValue1, CTL_MEM_SIZE) + 2]; @@ -609,9 +849,9 @@ pATI->VideoRAM = (IOValue1 - 7) * 2048; } - pATI->DAC = GetBits(inl(pATI->CPIO_DAC_CNTL), DAC_TYPE); + pATI->DAC = GetBits(inr(DAC_CNTL), DAC_TYPE); - IOValue1 = inl(ATIIOPort(CONFIG_STATUS64_0)); + IOValue1 = inr(CONFIG_STATUS64_0); if (pATI->Chip >= ATI_CHIP_264CT) { pATI->MemoryType = GetBits(IOValue1, CFG_MEM_TYPE_T); @@ -620,13 +860,10 @@ if (pATI->Chip == ATI_CHIP_264LT) { pATI->LCDPanelID = GetBits(IOValue1, CFG_PANEL_ID); - - pATI->CPIO_HORZ_STRETCHING = ATIIOPort(HORZ_STRETCHING); - pATI->CPIO_VERT_STRETCHING = ATIIOPort(VERT_STRETCHING); - pATI->CPIO_LCD_GEN_CTRL = ATIIOPort(LCD_GEN_CTRL); - pATI->CPIO_POWER_MANAGEMENT = ATIIOPort(POWER_MANAGEMENT); - IOValue2 = inl(pATI->CPIO_LCD_GEN_CTRL); + IOValue2 = inr(HORZ_STRETCHING); + IOValue3 = inr(VERT_STRETCHING); + IOValue4 = inr(LCD_GEN_CTRL); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || @@ -634,40 +871,42 @@ { pATI->LCDPanelID = GetBits(IOValue1, CFG_PANEL_ID); - pATI->CPIO_TV_OUT_INDEX = ATIIOPort(TV_OUT_INDEX); - pATI->CPIO_TV_OUT_DATA = ATIIOPort(TV_OUT_DATA); - pATI->CPIO_LCD_INDEX = ATIIOPort(LCD_INDEX); - pATI->CPIO_LCD_DATA = ATIIOPort(LCD_DATA); - - IOValue1 = inl(pATI->CPIO_LCD_INDEX); - IOValue2 = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); -#if 0 - if (IOValue2 & AUTO_HORZ_RATIO) -#endif - pATI->LCDHorizontal = - (GetBits(IOValue2, HORZ_PANEL_SIZE) + 1) << 3; - IOValue2 = ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH); -#if 0 - if (IOValue2 & AUTO_VERT_RATIO) -#endif - pATI->LCDVertical = - GetBits(IOValue2, VERT_PANEL_SIZE) + 1; - IOValue2 = ATIGetLTProLCDReg(LCD_GEN_CNTL); - outl(pATI->CPIO_LCD_INDEX, IOValue1); + IOValue1 = inr(LCD_INDEX); + IOValue2 = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATI->LCDHorizontal = GetBits(IOValue2, HORZ_PANEL_SIZE); + if (pATI->LCDHorizontal) + { + if (pATI->LCDHorizontal == MaxBits(HORZ_PANEL_SIZE)) + pATI->LCDHorizontal = 0; + else + pATI->LCDHorizontal = + (pATI->LCDHorizontal + 1) << 3; + } + IOValue3 = ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH); + pATI->LCDVertical = GetBits(IOValue3, VERT_PANEL_SIZE); + if (pATI->LCDVertical) + { + if (pATI->LCDVertical == MaxBits(VERT_PANEL_SIZE)) + pATI->LCDVertical = 0; + else + pATI->LCDVertical++; + } + IOValue3 = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + IOValue4 = ATIGetMach64LCDReg(LCD_GEN_CNTL); + outr(LCD_INDEX, IOValue1); } - if (pATI->LCDPanelID >= 0) - { - /* - * Don't bother with panel support if it's not enabled by - * BIOS initialisation. Also, remember if the BIOS knows - * about the CRT. - */ - if (!(IOValue2 & LCD_ON)) + /* + * Don't bother with panel support if it hasn't been previously + * enabled. + */ + if ((pATI->LCDPanelID >= 0) && + !pATI->LCDHorizontal && + !pATI->LCDVertical && + !(IOValue2 & HORZ_STRETCH_EN) && + !(IOValue3 & VERT_STRETCH_EN) && + !(IOValue4 & LCD_ON)) pATI->LCDPanelID = -1; - else if (!(IOValue2 & CRT_ON)) - AllowCRT = FALSE; - } } else { @@ -675,8 +914,7 @@ /* Factor in what the BIOS says the DAC is */ pATI->DAC = ATI_DAC(pATI->DAC, - GetBits(inl(ATIIOPort(SCRATCH_REG1)), - BIOS_INIT_DAC_SUBTYPE)); + GetBits(inr(SCRATCH_REG1), BIOS_INIT_DAC_SUBTYPE)); } /* @@ -696,7 +934,13 @@ * For Mach64 adapters, pick up, from the BIOS, the type of programmable * clock generator (if any), and various information about it. */ + +#ifndef AVOID_CPIO + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { CARD16 ClockDac; @@ -720,13 +964,15 @@ FrequencyTable = BIOSWord(ClockTable - 0x02U); if ((FrequencyTable > 0) && ((FrequencyTable + 0x20U) <= BIOSSize)) + { for (i = 0; i < 16; i++) - pATI->BIOSClocks[i] = (&BIOSWord(FrequencyTable))[i]; + { + pATI->BIOSClocks[i] = BIOSWord(FrequencyTable); + FrequencyTable += 2; + } + } pATI->ProgrammableClock = BIOSByte(ClockTable); pATI->ClockNumberToProgramme = BIOSByte(ClockTable + 0x06U); - if (pATI->ProgrammableClock < ATI_CLOCK_MAX) - pATI->ClockDescriptor = - ATIClockDescriptors[pATI->ProgrammableClock]; switch (BIOSWord(ClockTable + 0x08U) / 10) { case 143: @@ -746,6 +992,45 @@ break; } } + else + { + /* + * Compensate for BIOS absence. Note that the reference + * frequency has already been set by option processing. + */ + if ((pATI->DAC & ~0x0FU) == ATI_DAC_INTERNAL) + pATI->ProgrammableClock = ATI_CLOCK_INTERNAL; + else switch (pATI->DAC) + { + case ATI_DAC_STG1703: + pATI->ProgrammableClock = ATI_CLOCK_STG1703; + break; + + case ATI_DAC_CH8398: + pATI->ProgrammableClock = ATI_CLOCK_CH8398; + break; + + case ATI_DAC_ATT20C408: + pATI->ProgrammableClock = ATI_CLOCK_ATT20C408; + break; + + case ATI_DAC_IBMRGB514: + pATI->ProgrammableClock = ATI_CLOCK_IBMRGB514; + break; + + default: /* Provisional */ + pATI->ProgrammableClock = ATI_CLOCK_ICS2595; + break; + } + + /* This should be safe for all generators except IBM's RGB514 */ + pATI->ClockNumberToProgramme = 3; + } + + if ((pATI->ProgrammableClock > ATI_CLOCK_FIXED) && + (pATI->ProgrammableClock < ATI_CLOCK_MAX)) + pATI->ClockDescriptor = + ATIClockDescriptors[pATI->ProgrammableClock]; ClockDac = pATI->DAC; switch (pATI->ProgrammableClock) @@ -756,8 +1041,17 @@ * revision level. */ if (ClockTable > 0) - pATI->ClockDescriptor.MinM = pATI->ClockDescriptor.MaxM = - BIOSWord(ClockTable + 0x0AU); + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = + BIOSWord(ClockTable + 0x0AU); + else if (!xf86NameCmp(pGDev->clockchip, "ATI 18818-0")) + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = 43; + else if (!xf86NameCmp(pGDev->clockchip, "ATI 18818-1")) + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = 46; + else + pATI->ProgrammableClock = ATI_CLOCK_UNKNOWN; break; case ATI_CLOCK_STG1703: @@ -869,15 +1163,12 @@ } /* ... verify panel width ... */ - if ((pATI->LCDHorizontal > 8) && - (pATI->LCDHorizontal <= - (int)(MaxBits(HORZ_PANEL_SIZE) << 3)) && + if (pATI->LCDHorizontal && (pATI->LCDHorizontal != BIOSWord(i + 0x19U))) continue; /* ... and verify panel height */ - if ((pATI->LCDVertical > 1) && - (pATI->LCDVertical <= (int)MaxBits(VERT_PANEL_SIZE)) && + if (pATI->LCDVertical && (pATI->LCDVertical != BIOSWord(i + 0x1BU))) continue; @@ -887,8 +1178,14 @@ * More than one possibility, but don't care if all * tables describe panels of the same size. */ - if (BIOSLong(LCDPanelInfo + 0x19U) == - BIOSLong(i + 0x19U)) + if ((BIOSByte(LCDPanelInfo + 0x19U) == + BIOSByte(i + 0x19U)) && + (BIOSByte(LCDPanelInfo + 0x1AU) == + BIOSByte(i + 0x1AU)) && + (BIOSByte(LCDPanelInfo + 0x1BU) == + BIOSByte(i + 0x1BU)) && + (BIOSByte(LCDPanelInfo + 0x1CU) == + BIOSByte(i + 0x1CU))) continue; LCDPanelInfo = 0; @@ -903,42 +1200,17 @@ if (LCDPanelInfo > 0) { - CARD8 ClockMask, PostMask; - pATI->LCDPanelID = BIOSByte(LCDPanelInfo); pATI->LCDHorizontal = BIOSWord(LCDPanelInfo + 0x19U); pATI->LCDVertical = BIOSWord(LCDPanelInfo + 0x1BU); - - /* Get clock number */ - if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN) - i = inl(pATI->CPIO_CLOCK_CNTL) & 0x03U; - else - i = (inb(R_GENMO) & 0x0CU) >> 2; - - /* - * Get post divider. A GCC bug has caused the following - * expression to be broken down into its individual - * components. - */ - ClockMask = PLL_VCLK0_XDIV << i; - PostMask = PLL_VCLK0_POST_DIV << (i * 2); - j = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask); - j *= MaxBits(PLL_VCLK0_POST_DIV) + 1; - j |= GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask); - - /* Calculate clock of mode on entry */ - Numerator = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV + i) * - pATI->ReferenceNumerator; - Denominator = pATI->ClockDescriptor.MinM * - pATI->ReferenceDenominator * - pATI->ClockDescriptor.PostDividers[j]; - pATI->LCDClock = ATIDivide(Numerator, Denominator, 1, 0); } } } ATIUnlock(pATI); /* Unlock registers */ +#ifndef AVOID_CPIO + /* Sometimes, the BIOS lies about the chip */ if ((pATI->Chip >= ATI_CHIP_28800_4) && (pATI->Chip <= ATI_CHIP_28800_6)) { @@ -948,14 +1220,18 @@ pATI->Chip = IOValue1; } - /* Report what was found */ - xf86DrvMsg(pScreenInfo->scrnIndex, pATI->Chipset ? X_CONFIG : X_DEFAULT, - "Chipset: \"%s\".\n", ATIChipsetNames[pATI->Chipset]); +#endif /* AVOID_CPIO */ + /* Report what was found */ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s graphics controller detected.\n", ATIChipNames[pATI->Chip]); +#ifndef AVOID_CPIO + if ((pATI->Chip >= ATI_CHIP_68800) && (pATI->Chip != ATI_CHIP_68800_3)) + +#endif /* AVOID_CPIO */ + { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "Chip type %04X", pATI->ChipType); @@ -977,18 +1253,34 @@ Buffer, pATI->ChipClass, pATI->ChipRevision); } +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH8) + +#endif /* AVOID_CPIO */ + { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "%s bus interface detected", ATIBusNames[pATI->BusType]); + +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + + { Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, "; %s I/O base is 0x%04X", (pATI->CPIODecoding == SPARSE_IO) ? "sparse" : "block", pATI->CPIOBase); + } + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s.\n", Buffer); } +#ifndef AVOID_CPIO + if (pATI->CPIO_VGAWonder) xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "VGA Wonder registers at I/O port 0x%04X.\n", @@ -1000,6 +1292,8 @@ " memory.\n", ATIChipNames[pATI->Coprocessor], pATI->VideoRAM); +#endif /* AVOID_CPIO */ + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s adapter detected.\n", ATIAdapterNames[pATI->Adapter]); @@ -1027,103 +1321,20 @@ } } } - - if (pATI->LCDPanelID >= 0) - { - if (LCDPanelInfo <= 0) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_ERROR, 0, - "Unable to determine dimensions of panel (ID %d).\n", - pATI->LCDPanelID); - ATILock(pATI); - return FALSE; - } - - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "%dx%d panel (ID %d) detected.\n", - pATI->LCDHorizontal, pATI->LCDVertical, pATI->LCDPanelID); - for (i = 0; i < 24; i++) - Buffer[i] = BIOSByte(LCDPanelInfo + 1 + i); - for (i = 24; --i >= 0; ) - if (Buffer[i] != ' ') - { - Buffer[i + 1] = '\0'; - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "Panel model %s.\n", Buffer); - break; - } - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "Panel clock is %.3f MHz.\n", (double)(pATI->LCDClock) / 1000.0); - } - - /* Promote chipset specification */ - switch (pATI->Chipset) - { - case ATI_CHIPSET_IBMVGA: - if (pATI->Adapter == ATI_ADAPTER_VGA) - break; /* XXX */ - /* Fall through */ - - case ATI_CHIPSET_VGAWONDER: - pATI->Chipset = ATI_CHIPSET_ATIVGA; - break; - - case ATI_CHIPSET_IBM8514: - if (pATI->Adapter == ATI_ADAPTER_8514A) - break; /* XXX */ - /* Fall through */ - - case ATI_CHIPSET_MACH8: - case ATI_CHIPSET_MACH32: - case ATI_CHIPSET_MACH64: - case ATI_CHIPSET_RAGE128: - pATI->Chipset = ATI_CHIPSET_ATI; - break; - - default: - break; - } - - /* - * Set depth, bpp, etc. - */ - - if ((pATI->Chipset != ATI_CHIPSET_ATI) || (pATI->Chip < ATI_CHIP_264CT)) - i = NoDepth24Support; /* No support for >8bpp either */ - else - i = Support24bppFb | Support32bppFb; - if (!xf86SetDepthBpp(pScreenInfo, 8, 8, 8, i)) - return FALSE; - - switch (pScreenInfo->depth) - { - case 1: case 4: case 8: case 15: case 16: case 24: - break; - - default: - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Driver does not support depth %d.\n", - pScreenInfo->depth); - ATILock(pATI); - return FALSE; - } - xf86PrintDepthBpp(pScreenInfo); +#ifdef AVOID_CPIO - if ((i == NoDepth24Support) && (pScreenInfo->depth > 8)) + if (!pATI->OptionLinear) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Depth %d is not supported through this adapter.\n", - pScreenInfo->depth); + "A linear aperture is not available in this configuration.\n"); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } - - /* - * Pick up XF86Config options. - */ - ATIProcessOptions(pScreenInfo, pATI); +#endif /* AVOID_CPIO */ /* * Set colour weights. @@ -1137,6 +1348,8 @@ if (!xf86SetWeight(pScreenInfo, defaultWeight, defaultWeight)) { ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1152,6 +1365,8 @@ pScreenInfo->weight.red, pScreenInfo->weight.green, pScreenInfo->weight.blue, pScreenInfo->depth); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1162,6 +1377,8 @@ if (!xf86SetDefaultVisual(pScreenInfo, -1)) { ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1175,17 +1392,29 @@ xf86GetVisualName(pScreenInfo->defaultVisual), pScreenInfo->depth); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } /* * Set colour gamma. */ + +#ifndef AVOID_CPIO + + if (pScreenInfo->depth > 1) - if ((pScreenInfo->depth > 1) && !xf86SetGamma(pScreenInfo, defaultGamma)) +#endif /* AVOID_CPIO */ + { - ATILock(pATI); - return FALSE; + if (!xf86SetGamma(pScreenInfo, defaultGamma)) + { + ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } } pATI->depth = pScreenInfo->depth; @@ -1197,15 +1426,22 @@ * Determine which CRT controller to use for video modes. */ +#ifndef AVOID_CPIO + if ((pATI->Chip >= ATI_CHIP_88800GXC) && (pATI->depth >= 8) && (pATI->Chipset == ATI_CHIPSET_ATI)) + +#endif /* AVOID_CPIO */ + { pATI->NewHW.crtc = ATI_CRTC_MACH64; xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using Mach64 accelerator CRTC.\n"); +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* @@ -1234,7 +1470,13 @@ } } } + +#endif /* AVOID_CPIO */ + } + +#ifndef AVOID_CPIO + else { pATI->NewHW.crtc = ATI_CRTC_VGA; @@ -1252,6 +1494,8 @@ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "VGA is not available through this adapter.\n"); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1265,27 +1509,107 @@ } } +#endif /* AVOID_CPIO */ + /* * Decide between the CRT and the panel. */ if (pATI->LCDPanelID >= 0) { - if (pATI->OptionCRT && AllowCRT) + CARD8 ClockMask, PostMask; + + if (!pATI->LCDHorizontal || !pATI->LCDVertical) + { + if (pATI->LCDPanelID || (pATI->Chip <= ATI_CHIP_264LTPRO)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to determine dimensions of panel (ID %d).\n", + pATI->LCDPanelID); + else + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to determine dimensions of panel.\n"); + + ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + + if (pATI->LCDPanelID || (pATI->Chip <= ATI_CHIP_264LTPRO)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "%dx%d panel (ID %d) detected.\n", + pATI->LCDHorizontal, pATI->LCDVertical, pATI->LCDPanelID); + else + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "%dx%d panel detected.\n", + pATI->LCDHorizontal, pATI->LCDVertical); + + if (LCDPanelInfo) + { + for (i = 0; i < 24; i++) + Buffer[i] = BIOSByte(LCDPanelInfo + 1 + i); + for (; --i >= 0; ) + if (Buffer[i] && Buffer[i] != ' ') + { + Buffer[i + 1] = '\0'; + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "Panel model %s.\n", Buffer); + break; + } + } + + /* + * Determine panel clock. This must be done after option processing so + * that the adapter's reference frequency is always available. + */ + +#ifndef AVOID_CPIO + + if (!(pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN)) + i = (inb(R_GENMO) & 0x0CU) >> 2; + else + +#endif /* AVOID_CPIO */ + + { + i = inr(CLOCK_CNTL) & 0x03U; + } + + /* + * Get post divider. A GCC bug has caused the following expression to + * be broken down into its individual components. + */ + ClockMask = PLL_VCLK0_XDIV << i; + PostMask = PLL_VCLK0_POST_DIV << (i * 2); + j = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask); + j *= MaxBits(PLL_VCLK0_POST_DIV) + 1; + j |= GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask); + + /* Calculate clock of mode on entry */ + Numerator = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV + i) * + pATI->ReferenceNumerator; + Denominator = pATI->ClockDescriptor.MinM * pATI->ReferenceDenominator * + pATI->ClockDescriptor.PostDividers[j]; + pATI->LCDClock = ATIDivide(Numerator, Denominator, 1, 0); + + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "Panel clock is %.3f MHz.\n", (double)(pATI->LCDClock) / 1000.0); + + if (pATI->OptionCRT) xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Using CRT interface and disabling digital flat panel.\n"); - else if (pATI->OptionCRT || AllowCRT) - { - pATI->OptionCRT = FALSE; + else xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using digital flat panel interface.\n"); - } } /* * Finish detecting video RAM size. */ + pScreenInfo->videoRam = pATI->VideoRAM; + +#ifndef AVOID_CPIO - AcceleratorVideoRAM = pScreenInfo->videoRam = pATI->VideoRAM; + AcceleratorVideoRAM = pScreenInfo->videoRam; if (pATI->Chip == ATI_CHIP_VGA) { if (pATI->depth <= 4) @@ -1341,33 +1665,43 @@ { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, "Virtual resolutions requiring more than %s kB\n of video" - " memory might not function properly." ATI_README, + " memory might not function properly.\n", (pATI->depth == 1) ? "64" : "256"); } else { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to 256 kB due to hardware limitations." - ATI_README); + "VideoRAM reduced to 256 kB due to hardware" + " limitations.\n"); pScreenInfo->videoRam = 256; } } } else if ((pATI->NewHW.crtc == ATI_CRTC_MACH64) || (pATI->Chip >= ATI_CHIP_264CT)) + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) - { - /* Set MMIO address from PCI configuration space, if available */ - if (pATI->PCIInfo && - (pATI->Block0Base = pATI->PCIInfo->memBase[2])) - pATI->Block0Base += 0x0400U; +#endif /* AVOID_CPIO */ + + { /* Possibly set up for linear aperture */ + +#ifndef AVOID_CPIO + if (pATI->OptionLinear) + +#endif /* AVOID_CPIO */ + { /* Get adapter's linear aperture configuration */ - IOValue1 = inl(pATI->CPIO_CONFIG_CNTL); + IOValue1 = inr(CONFIG_CNTL); pATI->LinearBase = GetBits(IOValue1, CFG_MEM_AP_LOC) << 22; if ((IOValue1 & CFG_MEM_AP_SIZE) != CFG_MEM_AP_SIZE) { @@ -1387,18 +1721,19 @@ } } +#ifndef AVOID_CPIO + /* Except for PCI & AGP, allow for user override */ - if ((pATI->BusType != ATI_BUS_PCI) && - (pATI->BusType != ATI_BUS_AGP)) + if (!pATI->PCIInfo) { if (pATI->Chip == ATI_CHIP_88800CX) - IOValue2 = ~((unsigned long)((1 << 23) - 1)); + IOValue2 = ~((CARD32)((1 << 23) - 1)); else if (pATI->Chip >= ATI_CHIP_88800GXE) - IOValue2 = ~((unsigned long)((1 << 24) - 1)); + IOValue2 = ~((CARD32)((1 << 24) - 1)); else if (pATI->VideoRAM >= 4096) - IOValue2 = ~((unsigned long)((1 << 23) - 1)); + IOValue2 = ~((CARD32)((1 << 23) - 1)); else - IOValue2 = ~((unsigned long)((1 << 22) - 1)); + IOValue2 = ~((CARD32)((1 << 22) - 1)); if ((IOValue2 &= pGDev->MemBase) && (IOValue2 <= (MaxBits(CFG_MEM_AP_LOC) << 22))) @@ -1433,19 +1768,34 @@ } } +#endif /* AVOID_CPIO */ + if (!pATI->LinearBase || !pATI->LinearSize) { + +#ifndef AVOID_CPIO + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "A linear aperture is not available through this" " adapter.\n"); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } +#ifndef AVOID_CPIO + /* Insurance */ pATI->LinearBase = pATI->LinearSize = 0; + +#endif /* AVOID_CPIO */ + } else { @@ -1456,38 +1806,33 @@ if (!pATI->Block0Base) pATI->Block0Base = pATI->LinearBase + pATI->LinearSize - 0x00000400U; + + AcceleratorVideoRAM = pATI->LinearSize >> 10; + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + + /* + * Account for MMIO area, if it cannot be disabled. This + * relinquishes the entire last page of the linear aperture + * to prevent the server from write-combining it. + */ + if (pATI->Chip < ATI_CHIP_264VTB) + AcceleratorVideoRAM -= getpagesize() >> 10; + +#else /* if X_BYTE_ORDER == X_BIG_ENDIAN */ + + /* Big-endian aperture is 8 MB higher */ + pATI->LinearBase += 0x00800000U; - AcceleratorVideoRAM = (pATI->LinearSize >> 10) - 2; /* 4? */ +#endif /* X_BYTE_ORDER */ + if (AcceleratorVideoRAM < pATI->VideoRAM) { - if (pATI->Chip < ATI_CHIP_264VTB) - { - /* - * Don't allow virtual resolution to overlay - * register aperture(s). - */ - pScreenInfo->videoRam = AcceleratorVideoRAM; - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "Virtual resolutions will be limited to %d kB" - " to account for\n accelerator register" - " aperture.\n", - AcceleratorVideoRAM); - } - else - { - /* - * On VTB's and later, ATIInit disables the primary - * register aperture. This is done so the driver - * can get at the frame buffer memory behind it. - * For MMIO purposes, the auxillary register - * aperture will be used instead. Also, ignore the - * CONFIG_CNTL register's indication of linear - * aperture size, as it is insufficient for - * adapters with more than 8MB of video memory. - */ - if (pATI->VideoRAM > (8 * 1024)) - pATI->LinearSize = 16 * 1024 * 1024; - } + pScreenInfo->videoRam = AcceleratorVideoRAM; + xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, + "Virtual resolutions will be limited to %d kB due" + " to linear aperture size.\n", + AcceleratorVideoRAM); } xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, @@ -1495,21 +1840,18 @@ pATI->LinearSize >> 20, pATI->LinearBase); /* Only mmap what is needed */ - pATI->ApertureSize = pATI->LinearSize = - pATI->VideoRAM * 1024; + ApertureSize = pATI->LinearSize = pATI->VideoRAM * 1024; } } } +#ifndef AVOID_CPIO + /* Set up for a banked aperture */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { pATI->UseSmallApertures = TRUE; - /* Set banking port numbers */ - pATI->CPIO_MEM_VGA_RP_SEL = ATIIOPort(MEM_VGA_RP_SEL); - pATI->CPIO_MEM_VGA_WP_SEL = ATIIOPort(MEM_VGA_WP_SEL); - /* Set banking functions */ if (pATI->depth <= 4) { @@ -1540,11 +1882,10 @@ pATI->Block0Base = 0x000BFC00U; } +#endif /* AVOID_CPIO */ + if (pATI->Block0Base) { - pATI->PageSize = getpagesize(); - pATI->MMIOBase = pATI->Block0Base & ~(pATI->PageSize - 1); - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using Block 0 MMIO aperture at 0x%08X.\n", pATI->Block0Base); @@ -1558,12 +1899,15 @@ } } } + +#ifndef AVOID_CPIO + else /* * After BIOS initialisation, the accelerator (if any) and the VGA won't * necessarily agree on the amount of video memory, depending on whether or * where the memory boundary is configured. Any discrepancy will be - * resolved by ATIInit. + * resolved by ATIModePreInit(). * * However, it's possible that there is more video memory than VGA Wonder * can architecturally handle. @@ -1584,8 +1928,8 @@ else { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to %d kB due to hardware limitations." - ATI_README, AcceleratorVideoRAM); + "VideoRAM reduced to %d kB due to hardware limitations.\n", + AcceleratorVideoRAM); pScreenInfo->videoRam = AcceleratorVideoRAM; } @@ -1620,8 +1964,24 @@ } } +#endif /* AVOID_CPIO */ + + /* + * Remap apertures. Must lock and re-unlock around this in case the + * remapping fails. + */ + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) + return FALSE; + + ATIUnlock(pATI); + if (pATI->OptionAccel) { + +#ifndef AVOID_CPIO + if (!pATI->Block0Base || (pATI->NewHW.crtc == ATI_CRTC_VGA)) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -1629,12 +1989,22 @@ pATI->OptionAccel = FALSE; } else + +#endif /* AVOID_CPIO */ + + { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "MMIO write caching %sabled.\n", pATI->OptionMMIOCache ? "en" : "dis"); + } } +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH32) + +#endif /* AVOID_CPIO */ + { if (pATI->Chip >= ATI_CHIP_264CT) ATIReportMemory(pScreenInfo, pATI, @@ -1646,22 +2016,42 @@ ATIReportMemory(pScreenInfo, pATI, ATIMemoryTypeNames_Mach[pATI->MemoryType]); } + +#ifndef AVOID_CPIO + else if (pATI->Adapter >= ATI_ADAPTER_V3) ATIReportMemory(pScreenInfo, pATI, (ATIGetExtReg(0xB7U) & 0x04U) ? "DRAM" : "VRAM"); else ATIReportMemory(pScreenInfo, pATI, "video memory"); +#endif /* AVOID_CPIO */ + /* * Finish banking setup. This needs to be fixed to not assume the mode on * entry is a VGA mode. XXX */ + +#ifndef AVOID_CPIO + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + { pATI->OldHW.crtc = pATI->NewHW.crtc; + +#ifndef AVOID_CPIO + pATI->OldHW.SetBank = (ATIBankProcPtr)NoopDDA; pATI->BankInfo.BankSize = 0; /* No banking */ + +#endif /* AVOID_CPIO */ + } + +#ifndef AVOID_CPIO + else { pATI->OldHW.crtc = ATI_CRTC_VGA; @@ -1672,7 +2062,7 @@ else #endif if ((pATI->Chip >= ATI_CHIP_88800GXC) && - (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN)) + (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN)) pATI->OldHW.crtc = ATI_CRTC_MACH64; if (pATI->depth <= 4) @@ -1706,7 +2096,7 @@ else if (!pATI->UseSmallApertures) pATI->OldHW.SetBank = pATI->NewHW.SetBank; else if ((pATI->OldHW.crtc == ATI_CRTC_VGA) && - !(inl(pATI->CPIO_CONFIG_CNTL) & CFG_MEM_VGA_AP_EN)) + !(pATI->LockData.config_cntl & CFG_MEM_VGA_AP_EN)) { pATI->OldHW.SetBank = (ATIBankProcPtr)NoopDDA; pATI->OldHW.nBank = 1; @@ -1716,15 +2106,19 @@ else pATI->OldHW.SetBank = ATIMach64SetBankPlanar; - if (((pATI->ApertureSize * pATI->depth) / - pATI->BankInfo.nBankDepth) >= + if (((ApertureSize * pATI->depth) / pATI->BankInfo.nBankDepth) >= (unsigned)(pScreenInfo->videoRam * 1024)) pATI->BankInfo.BankSize = 0; /* No banking */ } +#endif /* AVOID_CPIO */ + if (pATI->OptionShadowFB) { /* Until ShadowFB becomes a true screen wrapper... */ + +#ifndef AVOID_CPIO + if (pATI->BankInfo.BankSize) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -1737,7 +2131,11 @@ "Cannot shadow a planar frame buffer.\n"); pATI->OptionShadowFB = FALSE; } - else if (pATI->OptionAccel) + else + +#endif /* AVOID_CPIO */ + + if (pATI->OptionAccel) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Cannot shadow an accelerated frame buffer.\n"); @@ -1749,10 +2147,12 @@ } /* 264VT-B's and later have DSP registers */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO) && - !ATIDSPPreInit(pScreenInfo, pATI)) + if ((pATI->Chip >= ATI_CHIP_264VTB) && + !ATIDSPPreInit(pScreenInfo->scrnIndex, pATI)) { ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1794,13 +2194,25 @@ Denominator = pATI->ClockDescriptor.MinM * pATI->XCLKReferenceDivider * pATI->ReferenceDenominator; +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { Denominator *= pATI->bitsPerPixel / 4; + } + + i = (6 - 2) - pATI->XCLKPostDivider; - i = (5 - 2) - pATI->XCLKPostDivider; - if (pATI->NewHW.crtc != ATI_CRTC_VGA) - i++; +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) + i--; + +#endif /* AVOID_CPIO */ + i = (ATIDivide(Numerator, Denominator, i, -1) / 1000) * 1000; if (i < ATIClockRange.maxClock) ATIClockRange.maxClock = i; @@ -1869,6 +2281,9 @@ break; default: + +#ifndef AVOID_CPIO + /* * 80 MHz is too high in some cases. Limit 18800-x's to 40 MHz. * Don't exceed the memory clock on VGA Wonder capables with less @@ -1883,7 +2298,13 @@ ATIClockRange.maxClock = (GetBits(BIOSByte(0x44U), 0x04U) * 5000) + 40000; else + +#endif /* AVOID_CPIO */ + + { ATIClockRange.maxClock = 80000; + } + break; } if (pATI->ClockDescriptor.MaxN <= 0) @@ -1891,22 +2312,25 @@ "Maximum pixel clock: %.3f MHz.\n", (double)ATIClockRange.maxClock / 1000.0); - /* Map MMIO areas */ - if (!ATIMapApertures(pScreenInfo, pATI)) - return FALSE; - /* * Determine available pixel clock frequencies. */ ATIClockPreInit(pScreenInfo, pATI, pGDev, &ATIClockRange); - if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) + if (pATI->ProgrammableClock > ATI_CLOCK_FIXED) Strategy = LOOKUP_BEST_REFRESH; /* * Mode validation. */ +#ifdef AVOID_CPIO + + if (pATI->Chip >= ATI_CHIP_264CT) + minPitch = 8; + +#else /* AVOID_CPIO */ + if ((pATI->depth >= 8) && (pATI->Chip >= ATI_CHIP_264CT)) minPitch = 8; else if (pATI->CPIO_VGAWonder && @@ -1917,15 +2341,29 @@ minPitch = 32; /* Very strange, but true */ maxPitch = 0x3FU; } + +#endif /* AVOID_CPIO */ + else minPitch = 16; pATI->pitchInc = minPitch; + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { pATI->pitchInc *= pATI->bitsPerPixel; + } switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* * IBM's VGA doesn't allow for interlaced modes. @@ -1967,6 +2405,8 @@ break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pScreenInfo->maxHValue = (MaxBits(CRTC_H_TOTAL) + 1) << 3; @@ -2077,11 +2517,12 @@ &ATIClockRange, NULL, minPitch, maxPitch, pATI->pitchInc, 0, maxHeight, pScreenInfo->display->virtualX, pScreenInfo->display->virtualY, - pATI->ApertureSize, Strategy); + ApertureSize, Strategy); if (i <= 0) { - ATIUnmapApertures(pScreenInfo, pATI); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -2101,8 +2542,9 @@ /* Load required modules */ if (!ATILoadModules(pScreenInfo, pATI)) { - ATIUnmapApertures(pScreenInfo, pATI); ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } #endif @@ -2135,22 +2577,14 @@ } while ((pMode = pMode->next) != pScreenInfo->modes); /* Initialise CRTC code */ - ATIAdapterPreInit(pScreenInfo, pATI, &pATI->NewHW); - - /* Relock registers */ - ATIUnmapApertures(pScreenInfo, pATI); - ATILock(pATI); + ATIModePreInit(pScreenInfo, pATI, &pATI->NewHW); if (!pScreenInfo->chipset || !*pScreenInfo->chipset) pScreenInfo->chipset = (char *)ATIChipsetNames[0]; - /* Generate noise if requested */ - if (xf86GetVerbosity() > 3) - { - ATIPrintBIOS(BIOS, 0, BIOSSize); - xf86ErrorFVerb(4, "\n On server entry:\n"); - ATIPrintRegisters(pATI); - } + ATILock(pATI); + ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return TRUE; } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h:1.2 Fri Feb 18 07:19:30 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h Fri Aug 4 17:07:15 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h,v 1.2 2000/02/18 12:19:30 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h,v 1.3 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIPREINIT_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern Bool ATIPreInit FunctionPrototype((ScrnInfoPtr, int)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c:1.13 xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c:1.13 Mon Jun 19 11:00:58 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c Tue Oct 17 12:53:17 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.13 2000/06/19 15:00:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.18 2000/10/17 16:53:17 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,7 +25,9 @@ #include "atiadapter.h" #include "atichip.h" #include "atidac.h" +#include "atimach64io.h" #include "atiprint.h" +#include "atiwonderio.h" /* * ATIPrintBIOS -- @@ -36,12 +38,11 @@ ATIPrintBIOS ( const CARD8 *BIOS, - const unsigned int Start, - const unsigned int End + const unsigned int Length /* A multiple of 512 */ ) { unsigned char *Char = NULL; - unsigned int Index = Start & ~(16U - 1U); + unsigned int Index; unsigned char Printable[17]; if (xf86GetVerbosity() <= 4) @@ -49,9 +50,9 @@ (void)memset(Printable, 0, SizeOf(Printable)); - xf86ErrorFVerb(5, "\n BIOS data at offset 0x%08X:", Start); + xf86ErrorFVerb(5, "\n BIOS image:"); - for (; Index < ((End + (16U - 1U)) & ~(16U - 1U)); Index++) + for (Index = 0; Index < Length; Index++) { if (!(Index & (4U - 1U))) { @@ -64,24 +65,18 @@ } xf86ErrorFVerb(5, " "); } - if ((Index < Start) || (Index >= End)) - { - xf86ErrorFVerb(5, " "); - *Char++ = ' '; - } + xf86ErrorFVerb(5, "%02X", BIOS[Index]); + if (isprint(BIOS[Index])) + *Char++ = BIOS[Index]; else - { - xf86ErrorFVerb(5, "%02X", BIOS[Index]); - if (isprint(BIOS[Index])) - *Char++ = BIOS[Index]; - else - *Char++ = '.'; - } + *Char++ = '.'; } xf86ErrorFVerb(5, " |%s|\n", Printable); } +#ifndef AVOID_CPIO + /* * ATIPrintIndexedRegisters -- * @@ -100,7 +95,7 @@ { int Index; - xf86ErrorFVerb(4, "\n\n %s register values:", Name); + xf86ErrorFVerb(4, "\n %s register values:", Name); for (Index = StartIndex; Index < EndIndex; Index++) { if (!(Index & (4U - 1U))) @@ -119,8 +114,12 @@ (void)inb(GenS1); /* Reset flip-flop */ outb(ATTRX, 0x20U); /* Turn on PAS bit */ } + + xf86ErrorFVerb(4, "\n"); } +#endif /* AVOID_CPIO */ + /* * ATIPrintMach64Registers -- * @@ -135,47 +134,102 @@ const char *Description ) { - int Index, Step, Limit; CARD32 IOValue; CARD8 dac_read, dac_mask, dac_data, dac_write; + int Index, Limit; + +#ifndef AVOID_CPIO + + int Step; + +#endif /* AVOID_CPIO */ + + xf86ErrorFVerb(4, "\n Mach64 %s register values:", Description); + +#ifdef AVOID_CPIO - xf86ErrorFVerb(4, "\n\n Mach64 %s register values:", Description); + if (pATI->pBlock[1]) + Limit = DWORD_SELECT; + else + Limit = MM_IO_SELECT; + + for (Index = 0; Index <= Limit; Index += UnitOf(MM_IO_SELECT)) + { + if (!(Index & SetBits(3, MM_IO_SELECT))) + xf86ErrorFVerb(4, "\n 0x%04X: ", Index); + if (Index == (DAC_REGS & DWORD_SELECT)) + { + dac_read = in8(DAC_REGS + 3); + DACDelay; + dac_mask = in8(DAC_REGS + 2); + DACDelay; + dac_data = in8(DAC_REGS + 1); + DACDelay; + dac_write = in8(DAC_REGS + 0); + DACDelay; + + xf86ErrorFVerb(4, " %02X%02X%02X%02X", + dac_read, dac_mask, dac_data, dac_write); + + out8(DAC_REGS + 2, dac_mask); + DACDelay; + out8(DAC_REGS + 3, dac_read); + DACDelay; + } + else + { + IOValue = inm(Index); + + if ((Index == (CRTC_GEN_CNTL & DWORD_SELECT)) && + (IOValue & CRTC_EXT_DISP_EN)) + *crtc = ATI_CRTC_MACH64; + + xf86ErrorFVerb(4, " %08X", IOValue); + } + } + +#else /* AVOID_CPIO */ + Limit = ATIIOPort(IOPortTag(0x1FU, 0x3FU)); Step = ATIIOPort(IOPortTag(0x01U, 0x01U)) - pATI->CPIOBase; for (Index = pATI->CPIOBase; Index <= Limit; Index += Step) { if (!(((Index - pATI->CPIOBase) / Step) & 0x03U)) xf86ErrorFVerb(4, "\n 0x%04X: ", Index); - if (Index == pATI->CPIO_DAC_REGS) + if (Index == (int)ATIIOPort(DAC_REGS)) { - dac_read = inb(pATI->CPIO_DAC_REGS + 3); + dac_read = in8(DAC_REGS + 3); DACDelay; - dac_mask = inb(pATI->CPIO_DAC_REGS + 2); + dac_mask = in8(DAC_REGS + 2); DACDelay; - dac_data = inb(pATI->CPIO_DAC_REGS + 1); + dac_data = in8(DAC_REGS + 1); DACDelay; - dac_write = inb(pATI->CPIO_DAC_REGS); + dac_write = in8(DAC_REGS + 0); DACDelay; xf86ErrorFVerb(4, " %02X%02X%02X%02X", dac_read, dac_mask, dac_data, dac_write); - outb(pATI->CPIO_DAC_REGS + 2, dac_mask); + out8(DAC_REGS + 2, dac_mask); DACDelay; - outb(pATI->CPIO_DAC_REGS + 3, dac_read); + out8(DAC_REGS + 3, dac_read); DACDelay; } else { IOValue = inl(Index); - if ((Index == pATI->CPIO_CRTC_GEN_CNTL) && + if ((Index == (int)ATIIOPort(CRTC_GEN_CNTL)) && (IOValue & CRTC_EXT_DISP_EN)) *crtc = ATI_CRTC_MACH64; xf86ErrorFVerb(4, " %08X", IOValue); } } + +#endif /* AVOID_CPIO */ + + xf86ErrorFVerb(4, "\n"); } /* @@ -190,10 +244,22 @@ ATIPtr pATI ) { - int Index; + int Index, Limit; + CARD8 PLLReg[MaxBits(PLL_ADDR) + 1]; + + for (Limit = 0; Limit < SizeOf(PLLReg); Limit++) + PLLReg[Limit] = ATIGetMach64PLLReg(Limit); - xf86ErrorFVerb(4, "\n\n Mach64 PLL register values:"); - for (Index = 0; Index < 64; Index++) + /* Determine how many PLL registers there really are */ + while ((Limit = Limit >> 1)) + for (Index = 0; Index < Limit; Index++) + if (PLLReg[Index] != PLLReg[Index + Limit]) + goto FoundLimit; +FoundLimit: + Limit <<= 1; + + xf86ErrorFVerb(4, "\n Mach64 PLL register values:"); + for (Index = 0; Index < Limit; Index++) { if (!(Index & 3)) { @@ -201,8 +267,10 @@ xf86ErrorFVerb(4, "\n 0x%02X: ", Index); xf86ErrorFVerb(4, " "); } - xf86ErrorFVerb(4, "%02X", ATIGetMach64PLLReg(Index)); + xf86ErrorFVerb(4, "%02X", PLLReg[Index]); } + + xf86ErrorFVerb(4, "\n"); } /* @@ -220,52 +288,55 @@ pciConfigPtr pPCI; int Index; CARD32 lcd_index, tv_out_index, lcd_gen_ctrl; - CARD8 genmo, seq1 = 0; CARD8 dac_read, dac_mask, dac_write; - CARD8 crtc = ATI_CRTC_VGA; + CARD8 crtc; +#ifndef AVOID_CPIO + + CARD8 genmo, seq1 = 0; + + crtc = ATI_CRTC_VGA; + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { - xf86ErrorFVerb(4, "\n Miscellaneous output register value: 0x%02X.", + xf86ErrorFVerb(4, "\n Miscellaneous output register value: 0x%02X.\n", genmo = inb(R_GENMO)); if (genmo & 0x01U) { if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Non-shadow colour CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Shadow colour CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Non-shadow colour CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Shadow colour CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + outr(LCD_INDEX, lcd_index); } else ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, @@ -277,39 +348,37 @@ { if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Non-shadow monochrome CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Shadow monochrome CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Non-shadow monochrome CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Shadow monochrome CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + outr(LCD_INDEX, lcd_index); } else ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, @@ -329,7 +398,7 @@ if (pATI->ChipHasSUBSYS_CNTL) { - xf86ErrorFVerb(4, "\n\n 8514/A register values:"); + xf86ErrorFVerb(4, "\n 8514/A register values:"); for (Index = 0x02E8U; Index <= 0x0FEE8; Index += 0x0400U) { if (!((Index - 0x02E8U) & 0x0C00U)) @@ -347,20 +416,26 @@ xf86ErrorFVerb(4, " %04X", inw(Index)); } } + + xf86ErrorFVerb(4, "\n"); } - else if (pATI->Chip == ATI_CHIP_264LT) + else + +#endif /* AVOID_CPIO */ + + if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & + ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "non-shadow"); - outl(pATI->CPIO_LCD_GEN_CTRL, - (lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, (lcd_gen_ctrl & ~CRTC_RW_SELECT) | + (SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "shadow"); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); ATIPrintMach64PLLRegisters(pATI); } @@ -368,55 +443,113 @@ (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "non-shadow"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, (lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "shadow"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | CRTC_RW_SELECT); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | CRTC_RW_SELECT); ATIPrintMach64Registers(pATI, &crtc, "secondary"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); ATIPrintMach64PLLRegisters(pATI); - xf86ErrorFVerb(4, "\n\n LCD register values:"); + xf86ErrorFVerb(4, "\n LCD register values:"); for (Index = 0; Index < 64; Index++) { if (!(Index & 3)) xf86ErrorFVerb(4, "\n 0x%02X: ", Index); - xf86ErrorFVerb(4, " %08X", ATIGetLTProLCDReg(Index)); + xf86ErrorFVerb(4, " %08X", ATIGetMach64LCDReg(Index)); } - outl(pATI->CPIO_LCD_INDEX, lcd_index); + outr(LCD_INDEX, lcd_index); - tv_out_index = inl(pATI->CPIO_TV_OUT_INDEX); + tv_out_index = inr(TV_OUT_INDEX); xf86ErrorFVerb(4, "\n\n TV_OUT register values:"); for (Index = 0; Index < 256; Index++) { if (!(Index & 3)) xf86ErrorFVerb(4, "\n 0x%02X: ", Index); - xf86ErrorFVerb(4, " %08X", ATIGetLTProTVReg(Index)); + xf86ErrorFVerb(4, " %08X", ATIGetMach64TVReg(Index)); } - outl(pATI->CPIO_TV_OUT_INDEX, tv_out_index); + outr(TV_OUT_INDEX, tv_out_index); + + xf86ErrorFVerb(4, "\n"); } - else if (pATI->Chip >= ATI_CHIP_88800GXC) + else + +#ifndef AVOID_CPIO + + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { + +#ifdef AVOID_CPIO + + ATIPrintMach64Registers(pATI, &crtc, "MMIO"); + +#else /* AVOID_CPIO */ + ATIPrintMach64Registers(pATI, &crtc, (pATI->CPIODecoding == SPARSE_IO) ? "sparse" : "block"); +#endif /* AVOID_CPIO */ + if (pATI->Chip >= ATI_CHIP_264CT) ATIPrintMach64PLLRegisters(pATI); } +#ifdef AVOID_CPIO + + dac_read = in8(M64_DAC_READ); + DACDelay; + dac_write = in8(M64_DAC_WRITE); + DACDelay; + dac_mask = in8(M64_DAC_MASK); + DACDelay; + + xf86ErrorFVerb(4, "\n" + " DAC read index: 0x%02X\n" + " DAC write index: 0x%02X\n" + " DAC mask: 0x%02X\n\n" + " DAC colour lookup table:", + dac_read, dac_write, dac_mask); + + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_READ, 0x00U); + DACDelay; + + for (Index = 0; Index < 256; Index++) + { + if (!(Index & 3)) + xf86ErrorFVerb(4, "\n 0x%02X:", Index); + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + } + + out8(M64_DAC_MASK, dac_mask); + DACDelay; + out8(M64_DAC_READ, dac_read); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, crtc); /* Temporarily turn off CLKDIV2 while reading DAC's LUT */ @@ -434,7 +567,7 @@ dac_mask = inb(pATI->CPIO_DAC_MASK); DACDelay; - xf86ErrorFVerb(4, "\n\n" + xf86ErrorFVerb(4, "\n" " DAC read index: 0x%02X\n" " DAC write index: 0x%02X\n" " DAC mask: 0x%02X\n\n" @@ -466,9 +599,11 @@ if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (seq1 & 0x08U)) PutReg(SEQX, 0x01U, seq1); +#endif /* AVOID_CPIO */ + if ((pVideo = pATI->PCIInfo)) { - pPCI = (pciConfigPtr)(pVideo->thisCard); + pPCI = pVideo->thisCard; xf86ErrorFVerb(4, "\n\n PCI configuration register values:"); for (Index = 0; Index < 256; Index+= 4) { @@ -478,26 +613,35 @@ } } + xf86ErrorFVerb(4, "\n"); + +#ifndef AVOID_CPIO + if (pATI->pBank) - xf86ErrorFVerb(4, "\n\n Banked aperture at 0x%08X.\n", + xf86ErrorFVerb(4, "\n Banked aperture at 0x%0lX.", pATI->pBank); else - xf86ErrorFVerb(4, "\n\n No banked aperture.\n"); + xf86ErrorFVerb(4, "\n No banked aperture."); - if (pATI->pMemory != pATI->pBank) - xf86ErrorFVerb(4, " Linear aperture at 0x%08X.\n", pATI->pMemory); + if (pATI->pMemory == pATI->pBank) + xf86ErrorFVerb(4, "\n No linear aperture.\n"); else - xf86ErrorFVerb(4, " No linear aperture.\n"); + +#endif /* AVOID_CPIO */ + + { + xf86ErrorFVerb(4, "\n Linear aperture at 0x%0lX.\n", pATI->pMemory); + } if (pATI->pBlock[0]) { - xf86ErrorFVerb(4, " Block 0 aperture at 0x%08X.\n", pATI->pBlock[0]); - if (inl(pATI->CPIOBase) == MMIO_IN32(pATI->pBlock[0], 0)) + xf86ErrorFVerb(4, " Block 0 aperture at 0x%0lX.\n", pATI->pBlock[0]); + if (inr(CONFIG_CHIP_ID) == pATI->config_chip_id) xf86ErrorFVerb(4, " MMIO registers are correctly mapped.\n"); else xf86ErrorFVerb(4, " MMIO mapping is in error!\n"); if (pATI->pBlock[1]) - xf86ErrorFVerb(4, " Block 1 aperture at 0x%08X.\n", + xf86ErrorFVerb(4, " Block 1 aperture at 0x%0lX.\n", pATI->pBlock[1]); } else @@ -588,5 +732,6 @@ break; } } + xf86ErrorFVerb(4, "\n"); } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h:1.5 Thu Apr 20 17:28:31 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h Tue Aug 22 17:54:31 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.5 2000/04/20 21:28:31 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.7 2000/08/22 21:54:31 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,10 +26,10 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern void ATIPrintBIOS FunctionPrototype((const CARD8 *, - const unsigned int, const unsigned int)); extern void ATIPrintRegisters FunctionPrototype((ATIPtr)); extern void ATIPrintMode FunctionPrototype((DisplayModePtr)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c:1.22 xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c:1.36 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c:1.22 Mon Jun 19 11:00:58 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c Tue Dec 12 21:44:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.22 2000/06/19 15:00:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.36 2000/12/13 02:44:59 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,13 +29,21 @@ #include "atichip.h" #include "aticonsole.h" #include "atiident.h" -#include "atiio.h" +#include "atimach64io.h" +#include "atimodule.h" #include "atipreinit.h" #include "atiprobe.h" #include "atiscreen.h" #include "ativalid.h" #include "ativersion.h" +#include "atividmem.h" +#include "atiwonderio.h" +#include "radeon_probe.h" +#include "radeon_version.h" +#include "r128_probe.h" +#include "r128_version.h" + /* * NOTES: * @@ -50,10 +58,26 @@ * largely ignored. */ +/* Used as a temporary buffer */ +#define Identifier ((char *)(pATI->MMIOCache)) + +/* + * An internal structure definition to facilitate the matching of detected + * adapters to XF86Config Device sections. + */ +typedef struct _ATIGDev +{ + GDevPtr pGDev; + int iATIPtr; + CARD8 Chipset; +} ATIGDev, *ATIGDevPtr; + +#ifndef AVOID_CPIO + /* * Definitions for I/O conflict avoidance. */ -#define LongPort(_Port) GetBits((_Port), PCIGETIO(SPARSE_IO_BASE)) +#define LongPort(_Port) GetBits(_Port, PCIGETIO(SPARSE_IO_BASE)) #define DetectedVGA (1 << 0) #define Detected8514A (1 << 1) #define DetectedMach64 (1 << 2) @@ -67,17 +91,6 @@ } PortRec, *PortPtr; /* - * An internal structure definition to facilitate the matching of detected - * adapters to XF86Config Device sections. - */ -typedef struct _ATIGDev -{ - GDevPtr pGDev; - int iATIPtr; - CARD8 Chipset; -} ATIGDev, *ATIGDevPtr; - -/* * ATIScanPCIBases -- * * This function loops though a device's PCI registered bases and accumulates @@ -139,33 +152,38 @@ static CARD8 ATICheckSparseIOBases ( + pciVideoPtr pVideo, CARD8 *ProbeFlags, const CARD16 IOBase, const int Count, const Bool Override ) { - CARD32 FirstPort = LongPort(IOBase), - LastPort = LongPort(IOBase + Count - 1); + CARD32 FirstPort, LastPort; - for (; FirstPort <= LastPort; FirstPort++) + if (!pVideo || !xf86IsPrimaryPci(pVideo)) { - CARD8 ProbeFlag = ProbeFlags[FirstPort]; + FirstPort = LongPort(IOBase); + LastPort = LongPort(IOBase + Count - 1); - if (ProbeFlag & DoProbe) - continue; + for (; FirstPort <= LastPort; FirstPort++) + { + CARD8 ProbeFlag = ProbeFlags[FirstPort]; - if (!(ProbeFlag & Allowed)) - return ProbeFlag; + if (ProbeFlag & DoProbe) + continue; - if (Override) - continue; + if (!(ProbeFlag & Allowed)) + return ProbeFlag; - /* User might wish to override this decision */ - xf86Msg(X_WARNING, - ATI_NAME ": Sparse I/O base 0x%04X not probed." ATI_README, - IOBase); - return Allowed; + if (Override) + continue; + + /* User might wish to override this decision */ + xf86Msg(X_WARNING, + ATI_NAME ": Sparse I/O base 0x%04X not probed.\n", IOBase); + return Allowed; + } } return DoProbe; @@ -251,20 +269,22 @@ static void ATIVGAWonderProbe ( - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { CARD8 IOValue1, IOValue2, IOValue3, IOValue4, IOValue5, IOValue6; - switch (ATICheckSparseIOBases(ProbeFlags, pATI->CPIO_VGAWonder, 2, TRUE)) + switch (ATICheckSparseIOBases(pVideo, ProbeFlags, + pATI->CPIO_VGAWonder, 2, TRUE)) { case 0: xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a non-video PCI device." ATI_README, pATI->CPIO_VGAWonder); + " a non-video PCI/AGP device.\n", pATI->CPIO_VGAWonder); pATI->CPIO_VGAWonder = 0; break; @@ -272,7 +292,7 @@ xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a %s %s." ATI_README, pATI->CPIO_VGAWonder, + " a %s %s.\n", pATI->CPIO_VGAWonder, ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); pATI->CPIO_VGAWonder = 0; break; @@ -281,12 +301,20 @@ xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a Mach64." ATI_README, pATI->CPIO_VGAWonder); + " a Mach64.\n", pATI->CPIO_VGAWonder); pATI->CPIO_VGAWonder = 0; break; case DetectedVGA: default: /* Must be DoProbe */ + if (pVideo && !xf86IsPrimaryPci(pVideo) && + (pATI->Chip <= ATI_CHIP_88800GXD)) + { + /* Set up extended VGA register addressing */ + PutReg(GRAX, 0x50U, GetByte(pATI->CPIO_VGAWonder, 0)); + PutReg(GRAX, 0x51U, + GetByte(pATI->CPIO_VGAWonder, 1) | pATI->VGAOffset); + } /* * Register 0xBB is used by the BIOS to keep track of various * things (monitor type, etc.). Except for 18800-x's, register @@ -306,15 +334,22 @@ else IOValue6 = ATIGetExtReg(0xBCU); ATIPutExtReg(IOValue1, IOValue2); + if ((IOValue4 == (IOValue3 ^ 0xAAU)) && (IOValue5 == (IOValue3 ^ 0x55U)) && (IOValue6 == 0)) - break; - - xf86Msg(X_WARNING, - ATI_NAME ": Expected VGA Wonder capability at I/O port 0x%04X" - " was not detected." ATI_README); - pATI->CPIO_VGAWonder = 0; + { + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": VGA Wonder at I/O port 0x%04X detected.\n", + pATI->CPIO_VGAWonder); + } + else + { + xf86Msg(X_WARNING, + ATI_NAME ": Expected VGA Wonder capability at I/O port" + " 0x%04X was not detected.\n", pATI->CPIO_VGAWonder); + pATI->CPIO_VGAWonder = 0; + } break; } } @@ -373,7 +408,7 @@ return NULL; } - /* Ensure and Mach8 or Mach32 is not in 8514/A emulation mode */ + /* Ensure any Mach8 or Mach32 is not in 8514/A emulation mode */ IOValue1 = inw(CLOCK_SEL); outw(CLOCK_SEL, IOValue1); ProbeWaitIdleEmpty(); @@ -461,92 +496,217 @@ return pATI; } +#endif /* AVOID_CPIO */ + /* - * ATIMach64Probe -- + * ATIDetectMach64 -- * - * This function looks for a Mach64 at a particular I/O base address and - * returns an ATIRec if one is found. + * This function determines if a Mach64 is detectable at a particular base + * address. */ -static ATIPtr -ATIMach64Probe +static Bool +ATIDetectMach64 ( - const CARD16 IOBase, - const CARD8 IODecoding, + ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip ) { - ATIPtr pATI; CARD32 IOValue, bus_cntl, gen_test_cntl; - CARD16 IOPort; - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->CPIOBase = IOBase; - pATI->CPIODecoding = IODecoding; + (void)ATIMapApertures(-1, pATI); /* Ignore errors */ + +#ifdef AVOID_CPIO + + if (!pATI->pBlock[0]) + { + ATIUnmapApertures(-1, pATI); + return FALSE; + } +#endif /* AVOID_CPIO */ + /* Make sure any Mach64 is not in some weird state */ - pATI->CPIO_BUS_CNTL = ATIIOPort(BUS_CNTL); - bus_cntl = inl(pATI->CPIO_BUS_CNTL); + bus_cntl = inr(BUS_CNTL); if (Chip < ATI_CHIP_264VTB) - outl(pATI->CPIO_BUS_CNTL, + outr(BUS_CNTL, (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) | (BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT)); else - outl(pATI->CPIO_BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | - BUS_HOST_ERR_INT); + outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT); - pATI->CPIO_GEN_TEST_CNTL = ATIIOPort(GEN_TEST_CNTL); - gen_test_cntl = inl(pATI->CPIO_GEN_TEST_CNTL); + gen_test_cntl = inr(GEN_TEST_CNTL); IOValue = gen_test_cntl & (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + outr(GEN_TEST_CNTL, IOValue); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); /* See if a Mach64 answers */ - IOPort = ATIIOPort(SCRATCH_REG0); - IOValue = inl(IOPort); + IOValue = inr(SCRATCH_REG0); /* Test odd bits */ - outl(IOPort, 0x55555555U); - if (inl(IOPort) == 0x55555555U) + outr(SCRATCH_REG0, 0x55555555U); + if (inr(SCRATCH_REG0) == 0x55555555U) { /* Test even bits */ - outl(IOPort, 0xAAAAAAAAU); - if (inl(IOPort) == 0xAAAAAAAAU) + outr(SCRATCH_REG0, 0xAAAAAAAAU); + if (inr(SCRATCH_REG0) == 0xAAAAAAAAU) { /* - * *Something* has a R/W 32-bit register at this I/O address. Try - * to make sure it's a Mach64. The following assumes that ATI will + * *Something* has a R/W 32-bit register at this address. Try to + * make sure it's a Mach64. The following assumes that ATI will * not be producing any more adapters that do not register * themselves in PCI configuration space. */ ATIMach64ChipID(pATI, ChipType); - if ((pATI->Chip != ATI_CHIP_Mach64) || (IODecoding == BLOCK_IO)) + if ((pATI->Chip != ATI_CHIP_Mach64) || + (pATI->CPIODecoding == BLOCK_IO)) pATI->Adapter = ATI_ADAPTER_MACH64; } } /* Restore clobbered register value */ - outl(IOPort, IOValue); + outr(SCRATCH_REG0, IOValue); /* If no Mach64 was detected, return now */ if (pATI->Adapter != ATI_ADAPTER_MACH64) { - outl(pATI->CPIO_GEN_TEST_CNTL, gen_test_cntl); - outl(pATI->CPIO_BUS_CNTL, bus_cntl); - xfree(pATI); - return NULL; + outr(GEN_TEST_CNTL, gen_test_cntl); + outr(BUS_CNTL, bus_cntl); + ATIUnmapApertures(-1, pATI); + return FALSE; } /* Determine legacy BIOS address */ pATI->BIOSBase = 0x000C0000U + - (GetBits(inl(ATIIOPort(SCRATCH_REG1)), BIOS_BASE_SEGMENT) << 11); + (GetBits(inr(SCRATCH_REG1), BIOS_BASE_SEGMENT) << 11); + + ATIUnmapApertures(-1, pATI); + pATI->PCIInfo = NULL; + return TRUE; +} + +#ifdef AVOID_CPIO + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular MMIO address and returns an + * ATIRec if one is found. + */ +static ATIPtr +ATIMach64Probe +( + pciVideoPtr pVideo, + const CARD16 IOBase, + const CARD8 IODecoding, + const ATIChipType Chip +) +{ + ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); + CARD16 ChipType = 0; + + pATI->CPIOBase = IOBase; + pATI->CPIODecoding = IODecoding; + + if (pVideo) + { + pATI->PCIInfo = pVideo; + ChipType = pVideo->chipType; + + /* + * Probe through auxiliary MMIO aperture if one exists. Because such + * apertures can be enabled/disabled only through PCI, this probes no + * further. + */ + if ((pVideo->size[2] >= 12) && (pATI->Block0Base = pVideo->memBase[2])) + { + pATI->Block0Base += 0x00000400U; + goto LastProbe; + } + + /* + * Probe through the primary MMIO aperture that exists at the tail end + * of the linear aperture. Test for both 8MB and 4MB linear apertures. + */ + if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) + { + pATI->Block0Base += 0x007FFC00U; + if ((pVideo->size[0] >= 23) && + ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + + pATI->Block0Base -= 0x00400000U; + if (ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + } + } + + /* + * A last, perhaps desparate, probe attempt. Note that if this succeeds, + * there's a VGA in the system and it's likely the PIO version of the + * driver should be used instead (barring OS issues). + */ + pATI->Block0Base = 0x000BFC00U; + +LastProbe: + if (ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + + xfree(pATI); + return NULL; +} + +#else /* AVOID_CPIO */ + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular PIO address and returns an + * ATIRec if one is found. + */ +static ATIPtr +ATIMach64Probe +( + pciVideoPtr pVideo, + const CARD16 IOBase, + const CARD8 IODecoding, + const ATIChipType Chip +) +{ + ATIPtr pATI; + CARD32 IOValue; + CARD16 ChipType = 0; + + if (pVideo) + { + if ((IODecoding == BLOCK_IO) && (pVideo->size[1] < 8)) + return NULL; + + ChipType = pVideo->chipType; + } + + pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); + pATI->CPIOBase = IOBase; + pATI->CPIODecoding = IODecoding; + pATI->PCIInfo = pVideo; + + if (!ATIDetectMach64(pATI, ChipType, Chip)) + { + xfree(pATI); + return NULL; + } - /* Determine VGA capability */ - IOValue = inl(ATIIOPort(CONFIG_STATUS64_0)); - if (pATI->Chip < ATI_CHIP_264CT) + /* + * Determine VGA capability. VGA can always be enabled on integrated + * controllers. For the GX/CX, it's a board strap. + */ + if (pATI->Chip >= ATI_CHIP_264CT) + pATI->VGAAdapter = ATI_ADAPTER_MACH64; + else { + IOValue = inr(CONFIG_STATUS64_0); pATI->BusType = GetBits(IOValue, CFG_BUS_TYPE); IOValue &= (CFG_VGA_EN | CFG_CHIP_EN); if (pATI->Chip == ATI_CHIP_88800CX) @@ -558,11 +718,6 @@ pATI->VGAOffset = 0x80U; } } - else - { - if ((pATI->Chip < ATI_CHIP_264VT) || (IOValue & CFG_VGA_EN_T)) - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - } return pATI; } @@ -579,10 +734,11 @@ static void ATIAssignVGA ( - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { ATIPtr pVGA = *ppVGA; @@ -605,10 +761,10 @@ */ OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_VGA; } @@ -627,10 +783,10 @@ OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_VGA; } @@ -656,10 +812,10 @@ OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_MACH32; } @@ -674,26 +830,24 @@ case ATI_ADAPTER_MACH64: { - CARD16 DACMaskPort = ATIIOPort(DAC_REGS) + 2, - DACCntlPort = ATIIOPort(DAC_CNTL); - CARD32 DACCntl = inl(DACCntlPort); + CARD32 DACCntl = inr(DAC_CNTL); if (!(DACCntl & DAC_VGA_ADR_EN)) - outl(DACCntlPort, DACCntl | DAC_VGA_ADR_EN); + outr(DAC_CNTL, DACCntl | DAC_VGA_ADR_EN); OldDACMask = inb(VGA_DAC_MASK); - if (inb(DACMaskPort) == OldDACMask) + if (in8(M64_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DACMaskPort) == 0xA5U) + if (in8(M64_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_MACH64; } outb(VGA_DAC_MASK, OldDACMask); if (!(DACCntl & DAC_VGA_ADR_EN)) - outl(DACCntlPort, DACCntl); + outr(DAC_CNTL, DACCntl); } break; @@ -709,7 +863,7 @@ if (pATI->CPIO_VGAWonder) { - ATIVGAWonderProbe(pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); if (!pATI->CPIO_VGAWonder) { /* @@ -719,7 +873,7 @@ * of I/O through the bus tree. */ pATI->CPIO_VGAWonder = GRAX; - ATIVGAWonderProbe(pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); } } @@ -732,6 +886,8 @@ /* Assign the VGA to this adapter */ xfree(pVGA); *ppVGA = pATI; + + xf86MsgVerb(X_INFO, 3, ATI_NAME ": VGA assigned to this adapter.\n"); } /* @@ -743,21 +899,23 @@ static void ATIClaimVGA ( - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags, - int Detected + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags, + int Detected ) { - ATIAssignVGA(ppVGA, pATI, p8514, ProbeFlags); - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - { - ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, Detected); - if (pATI->CPIO_VGAWonder) - ATIClaimSparseIOBases(ProbeFlags, pATI->CPIO_VGAWonder, 2, - Detected); - } + ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + return; + + ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, Detected); + if (!pATI->CPIO_VGAWonder) + return; + + ATIClaimSparseIOBases(ProbeFlags, pATI->CPIO_VGAWonder, 2, Detected); } /* @@ -769,24 +927,37 @@ static void ATIFindVGA ( - ATIPtr *ppVGA, - ATIPtr *ppATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr *ppATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { ATIPtr pATI = *ppATI; if (*ppVGA) - ATIAssignVGA(ppVGA, pATI, p8514, ProbeFlags); + ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); else { + /* + * An ATI PCI adapter has been detected at this point, and its VGA, if + * any, is shareable. Ensure the VGA isn't in sleep mode. + */ + outb(GENENA, 0x16U); + outb(GENVS, 0x01U); + outb(GENENA, 0x0EU); + pATI = ATIVGAProbe(pATI); - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIAssignVGA(ppATI, pATI, p8514, ProbeFlags); + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + return; + + ATIAssignVGA(pVideo, ppATI, pATI, p8514, ProbeFlags); } } +#endif /* AVOID_CPIO */ + /* * ATIProbe -- * @@ -800,21 +971,28 @@ int flags ) { - ATIPtr pATI, *ATIPtrs = NULL, pVGA = NULL, p8514 = NULL; - ATIPtr pMach64[3] = {NULL, NULL, NULL}; + ATIPtr pATI, *ATIPtrs = NULL; GDevPtr *GDevs, pGDev; pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); - pciConfigPtr pPCI, *xf86PciInfo = xf86GetPciConfigInfo(); + pciConfigPtr pPCI; ATIGDev *ATIGDevs = NULL, *pATIGDev; ScrnInfoPtr pScreenInfo; - PortPtr PCIPorts = NULL; CARD32 PciReg; + Bool ProbeSuccess = FALSE; + Bool DoRage128 = FALSE, DoRadeon = FALSE; int i, j, k; - int nGDev, nATIGDev = 0, nATIPtr = 0, nPCIPort = 0; - int nAdapter = 0; + int nGDev, nATIGDev = -1, nATIPtr = 0; int Chipset; - CARD8 fChipsets[ATI_CHIPSET_MAX]; ATIChipType Chip; + +#ifndef AVOID_CPIO + + ATIPtr pVGA = NULL, p8514 = NULL; + ATIPtr pMach64[3] = {NULL, NULL, NULL}; + pciConfigPtr *xf86PciInfo = xf86GetPciConfigInfo(); + PortPtr PCIPorts = NULL; + int nPCIPort = 0; + CARD8 fChipsets[ATI_CHIPSET_MAX]; static const CARD16 Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U}; CARD8 ProbeFlags[LongPort(SPARSE_IO_BASE) + 1]; @@ -824,8 +1002,10 @@ # define PrefixSize 0x50U # define BIOSSignature 0x30U CARD8 BIOS[PrefixSize]; -# define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n)))) +# define BIOSWord(_n) (BIOS[_n] | (BIOS[(_n) + 1] << 8)) +#endif /* AVOID_CPIO */ + # define AddAdapter(_p) \ do \ { \ @@ -835,6 +1015,12 @@ (_p)->iEntity = -2; \ } while (0) +#ifndef AVOID_CPIO + + (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); + +#endif /* AVOID_CPIO */ + if (!(flags & PROBE_DETECT)) { /* @@ -844,51 +1030,67 @@ * "ChipID" not recognised by the driver. Those device sections that * specify a "ChipRev" without a "ChipID" are also weeded out. */ - if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) <= 0) - return FALSE; - - ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); - - for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) + nATIGDev = 0; + if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) > 0) { - pGDev = GDevs[i]; - Chipset = ATIIdentProbe(pGDev->chipset); - if (Chipset == -1) - continue; - - if ((pGDev->chipID > (int)((CARD16)(-1))) || - (pGDev->chipRev > (int)((CARD8)(-1)))) - continue; + ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - if (pGDev->chipID >= 0) + for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) { - if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) + pGDev = GDevs[i]; + Chipset = ATIIdentProbe(pGDev->chipset); + if (Chipset == -1) continue; - } - else - { - if (pGDev->chipRev >= 0) + + if ((pGDev->chipID > (int)((CARD16)(-1))) || + (pGDev->chipRev > (int)((CARD8)(-1)))) continue; - } - pATIGDev->pGDev = pGDev; - pATIGDev->Chipset = Chipset; - nATIGDev++; - pATIGDev++; - fChipsets[Chipset] = TRUE; - } + if (pGDev->chipID >= 0) + { + if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) + continue; + } + else + { + if (pGDev->chipRev >= 0) + continue; + } - xfree(GDevs); + pATIGDev->pGDev = pGDev; + pATIGDev->Chipset = Chipset; + nATIGDev++; + pATIGDev++; - /* If no device sections remain, return now */ - if (!nATIGDev) - { - xfree(ATIGDevs); - return FALSE; + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": Candidate \"Device\" section \"%s\".\n", + pGDev->identifier); + +#ifndef AVOID_CPIO + + fChipsets[Chipset] = TRUE; + +#endif /* AVOID_CPIO */ + + } + + xfree(GDevs); + + if (!nATIGDev) + { + xfree(ATIGDevs); + ATIGDevs = NULL; + } } + + if (xf86MatchDevice(R128_NAME, NULL) > 0) + DoRage128 = TRUE; + if (xf86MatchDevice(RADEON_NAME, NULL) > 0) + DoRadeon = TRUE; } +#ifndef AVOID_CPIO + /* * Collect hardware information. This must be done with care to avoid * lockups due to overlapping I/O port assignments. @@ -914,376 +1116,555 @@ * same I/O ports as 8514/A's or ATI sparse I/O devices without registering * them in PCI configuration space. */ - if (xf86PciVideoInfo) - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + if (nATIGDev) + { + if (xf86PciVideoInfo) { - pPCI = (pciConfigPtr)(pVideo->thisCard); - - if (pVideo->vendor == PCI_VENDOR_ATI) + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - if (pVideo->chipType == PCI_CHIP_MACH32) - continue; - - /* - * Some PCI Mach64's are not properly configured for sparse or - * block I/O. Correct PCI's USERCONFIG register, if necessary. - */ - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - if (IsATIBlockIOBase(pVideo->ioBase[1])) + if (pVideo->vendor != PCI_VENDOR_ATI) { - /* This is block I/O */ - if (!(PciReg & 0x00000004U)) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg | 0x00000004U); + pPCI = pVideo->thisCard; + + ATIScanPCIBases(&PCIPorts, &nPCIPort, + &pPCI->pci_base0, pVideo->size, + (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & + PCI_CMD_IO_ENABLE) ? 0 : Allowed); } - else + } + } + + /* Check non-video PCI devices for I/O bases */ + if (xf86PciInfo) + { + for (i = 0; (pPCI = xf86PciInfo[i++]); ) + { + if ((pPCI->pci_vendor != PCI_VENDOR_ATI) && + (pPCI->pci_base_class != PCI_CLASS_BRIDGE) && + !(pPCI->pci_header_type & + ~GetByte(PCI_HEADER_MULTIFUNCTION, 2))) { - /* This is sparse I/O */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); + ATIScanPCIBases(&PCIPorts, &nPCIPort, + &pPCI->pci_base0, pPCI->basesize, + (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & + PCI_CMD_IO_ENABLE) ? 0 : Allowed); } - continue; } + } - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pVideo->size, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); - } - - /* Check non-video PCI devices for I/O bases */ - if (xf86PciInfo) - for (i = 0; (pPCI = xf86PciInfo[i++]); ) - if ((pPCI->pci_vendor != PCI_VENDOR_ATI) && - (pPCI->pci_base_class != PCI_CLASS_BRIDGE) && - !(pPCI->pci_header_type & - ~GetByte(PCI_HEADER_MULTIFUNCTION, 2))) - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pPCI->basesize, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); - - /* Generate ProbeFlags array from list of registered PCI I/O bases */ - (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags)); - for (i = 0; i < nPCIPort; i++) - { - CARD32 Base = PCIPorts[i].Base; - CARD16 Count = (1 << PCIPorts[i].Size) - 1; - CARD8 ProbeFlag = PCIPorts[i].Flag; + /* Generate ProbeFlags array from list of registered PCI I/O bases */ + (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags)); + for (i = 0; i < nPCIPort; i++) + { + CARD32 Base = PCIPorts[i].Base; + CARD16 Count = (1 << PCIPorts[i].Size) - 1; + CARD8 ProbeFlag = PCIPorts[i].Flag; - /* - * The following reduction of Count is based on the assumption that - * PCI-registered I/O port ranges do not overlap. - */ - for (j = 0; j < nPCIPort; j++) - { - CARD32 Base2 = PCIPorts[j].Base; + /* + * The following reduction of Count is based on the assumption that + * PCI-registered I/O port ranges do not overlap. + */ + for (j = 0; j < nPCIPort; j++) + { + CARD32 Base2 = PCIPorts[j].Base; - if (Base < Base2) - while ((Base + Count) >= Base2) - Count >>= 1; - } + if (Base < Base2) + while ((Base + Count) >= Base2) + Count >>= 1; + } - Base = LongPort(Base); - Count = LongPort((Count | IO_BYTE_SELECT) + 1); - while (Count--) - ProbeFlags[Base++] &= ProbeFlag; - } + Base = LongPort(Base); + Count = LongPort((Count | IO_BYTE_SELECT) + 1); + while (Count--) + ProbeFlags[Base++] &= ProbeFlag; + } - xfree(PCIPorts); + xfree(PCIPorts); - /* - * A note on probe strategy. I/O and memory response by certain PCI - * devices has been disabled by the common layer at this point, including - * any devices this driver might be interested in. The following does - * sparse I/O probes, followed by block I/O probes. Block I/O probes are - * dictated by what is found to be of interest in PCI configuration space. - * All this will detect ATI adapters that do not implement this - * disablement, pre-PCI or not. - * - * PCI configuration space is then scanned again for ATI devices that - * failed to be detected the first time around. Each such device is probed - * for again, this time with I/O temporarily enabled through PCI. - */ - if (ATICheckSparseIOBases(ProbeFlags, ATTRX, 16, TRUE) == DoProbe) - { - pVGA = ATIVGAProbe(NULL); - if (pVGA->Adapter == ATI_ADAPTER_NONE) + /* + * A note on probe strategy. I/O and memory response by certain PCI + * devices has been disabled by the common layer at this point, + * including any devices this driver might be interested in. The + * following does sparse I/O probes, followed by block I/O probes. + * Block I/O probes are dictated by what is found to be of interest in + * PCI configuration space. All this will detect ATI adapters that do + * not implement this disablement, pre-PCI or not. + * + * PCI configuration space is then scanned again for ATI devices that + * failed to be detected the first time around. Each such device is + * probed for again, this time with I/O temporarily enabled through + * PCI. + */ + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == + DoProbe) { - xfree(pVGA); - pVGA = NULL; + pATI = ATIVGAProbe(NULL); + if (pATI->Adapter == ATI_ADAPTER_NONE) + { + xfree(pATI); + + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared VGA not detected.\n"); + } + else + { + /* + * Claim all MDA/HGA/CGA/EGA/VGA I/O ports. This might need to + * be more selective. + */ + ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, + DetectedVGA); + + pVGA = pATI; + strcpy(Identifier, "Unshared VGA"); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + } } else { - /* - * Claim all MDA/HGA/CGA/EGA/VGA I/O ports. This might need to be - * more selective. - */ - ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, - DetectedVGA); + xf86MsgVerb(X_INFO, 2, ATI_NAME ": Unshared VGA not probed.\n"); } - } - - if ((ATICheckSparseIOBases(ProbeFlags, 0x02E8U, 8, - fChipsets[ATI_CHIPSET_IBM8514] || - fChipsets[ATI_CHIPSET_MACH8] || - fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) && - (pATI = ATI8514Probe(NULL))) - { - AddAdapter(p8514 = pATI); - - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, Detected8514A); - ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); - } - - for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) - { - if (ATICheckSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, - fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) - continue; - - if (!(pATI = ATIMach64Probe(Mach64SparseIOBases[i], SPARSE_IO, 0, 0))) - continue; + if (ATICheckSparseIOBases(NULL, ProbeFlags, 0x02E8U, 8, + fChipsets[ATI_CHIPSET_IBM8514] || + fChipsets[ATI_CHIPSET_MACH8] || + fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) + { + if ((pATI = ATI8514Probe(NULL))) + { + strcpy(Identifier, "Unshared 8514/A"); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(pMach64[i] = pATI); + AddAdapter(p8514 = pATI); - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, DetectedMach64); + if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || + (pATI->Coprocessor != ATI_CHIP_NONE)) + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, + Detected8514A); - ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, - DetectedMach64); - } - - if (xf86PciVideoInfo) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); + } + else + { + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared 8514/A not detected.\n"); + } + } + else { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - !IsATIBlockIOBase(pVideo->ioBase[1])) - continue; + xf86MsgVerb(X_INFO, 2, + ATI_NAME ": Unshared 8514/A not probed.\n"); + } - /* For now, ignore Rage128's */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if (Chip > ATI_CHIP_Mach64) + for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) + { + if (ATICheckSparseIOBases(NULL, ProbeFlags, Mach64SparseIOBases[i], + 4, fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) + { + xf86MsgVerb(X_INFO, 2, + ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not" + " probed.\n", + Mach64SparseIOBases[i]); continue; + } - pATI = ATIMach64Probe(pVideo->ioBase[1], BLOCK_IO, - pVideo->chipType, Chip); + pATI = ATIMach64Probe(NULL, Mach64SparseIOBases[i], SPARSE_IO, 0); if (!pATI) + { + xf86MsgVerb(X_INFO, 4, + ATI_NAME ": Unshared Mach64 at PIO base 0x%04X not" + " detected.\n", Mach64SparseIOBases[i]); continue; + } + + sprintf(Identifier, "Unshared Mach64 at sparse PIO base 0x%04X", + Mach64SparseIOBases[i]); + xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", Identifier); - AddAdapter(pATI); + AddAdapter(pMach64[i] = pATI); - /* This is probably not necessary */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, DetectedMach64); + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, + DetectedMach64); + + ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, + DetectedMach64); } + } - /* - * This is the second pass through PCI configuration space. Much of - * this is verbiage to deal with potential situations that are very - * unlikely to occur in practice. - * - * First, look for non-ATI shareable VGA's. For now, these must the - * primary device. - */ - if (ATICheckSparseIOBases(ProbeFlags, ATTRX, 16, TRUE) == DoProbe) +#endif /* AVOID_CPIO */ + + if (xf86PciVideoInfo) + { + if (nATIGDev) { + +#ifdef AVOID_CPIO + + /* PCI sparse I/O adapters can still be used through MMIO */ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - if ((pVideo->vendor == PCI_VENDOR_ATI) || - !xf86IsPrimaryPci(pVideo)) + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) continue; - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) + pPCI = pVideo->thisCard; + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); + + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + + /* + * The CPIO base used by the adapter is of little concern here. + */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (!pATI) continue; - xf86SetPciVideo(pVideo, IO); + sprintf(Identifier, + "Unshared PCI sparse I/O Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected through Block 0 at 0x%08X.\n", + Identifier, pATI->Block0Base); + AddAdapter(pATI); + pATI->PCIInfo = pVideo; + } - pATI = ATIVGAProbe(NULL); - if (pATI->Adapter == ATI_ADAPTER_NONE) +#endif /* AVOID_CPIO */ + + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + !IsATIBlockIOBase(pVideo->ioBase[1])) + continue; + + /* For now, ignore Rage128's */ + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + if (Chip > ATI_CHIP_Mach64) + continue; + + pPCI = pVideo->thisCard; + + /* + * Possibly fix block I/O indicator in PCI configuration space. + */ + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + if (!(PciReg & 0x00000004U)) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg | 0x00000004U); + + pATI = + ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); + if (!pATI) + continue; + + sprintf(Identifier, "Unshared PCI/AGP Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + AddAdapter(pATI); + +#ifndef AVOID_CPIO + + /* This is probably not necessary */ + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIClaimVGA(pVideo, &pVGA, pATI, p8514, + ProbeFlags, DetectedMach64); + +#endif /* AVOID_CPIO */ + + } + +#ifndef AVOID_CPIO + + /* + * This is the second pass through PCI configuration space. Much + * of this is verbiage to deal with potential situations that are + * very unlikely to occur in practice. + * + * First, look for non-ATI shareable VGA's. For now, these must + * the primary device. + */ + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == + DoProbe) + { + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - xfree(pATI); - xf86Msg(X_WARNING, - ATI_NAME ": PCI/AGP VGA-compatible in slot" - " %d:%d:%d could not be detected!" ATI_README, + if ((pVideo->vendor == PCI_VENDOR_ATI) || + !xf86IsPrimaryPci(pVideo)) + continue; + + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; + + xf86SetPciVideo(pVideo, MEM_IO); + + pATI = ATIVGAProbe(NULL); + if (pATI->Adapter == ATI_ADAPTER_NONE) + { + xfree(pATI); + xf86Msg(X_WARNING, + ATI_NAME ": PCI/AGP VGA compatible in slot" + " %d:%d:%d could not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - } - else - { - AddAdapter(pATI); - pATI->SharedVGA = TRUE; - pATI->BusType = ATI_BUS_PCI; - pATI->PCIInfo = pVideo; - } + } + else + { + sprintf(Identifier, + "Shared non-ATI VGA in PCI/AGP slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", + Identifier); + AddAdapter(pATI); + pATI->SharedVGA = TRUE; + pATI->BusType = ATI_BUS_PCI; + pATI->PCIInfo = pVideo; + } - xf86SetPciVideo(NULL, NONE); + xf86SetPciVideo(NULL, NONE); + } } - } - /* Next, look for PCI Mach32's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType != PCI_CHIP_MACH32)) - continue; - - switch (ATICheckSparseIOBases(ProbeFlags, 0x02E8U, 8, TRUE)) + /* Next, look for PCI Mach32's */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - case 0: - xf86Msg(X_WARNING, + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType != PCI_CHIP_MACH32)) + continue; + + switch (ATICheckSparseIOBases(pVideo, ProbeFlags, + 0x02E8U, 8, TRUE)) + { + case 0: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" " be enabled\n because it conflicts with a" - " non-video PCI device." ATI_README, + " non-video PCI/AGP device.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - case Detected8514A: - if ((p8514->BusType >= ATI_BUS_PCI) && !p8514->PCIInfo) - p8514->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, + case Detected8514A: + if ((p8514->BusType >= ATI_BUS_PCI) && !p8514->PCIInfo) + p8514->PCIInfo = pVideo; + else + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" - " another %s %s." ATI_README, + " another %s %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); - break; + break; - case DetectedMach64: - xf86Msg(X_WARNING, + case DetectedMach64: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with a" - " Mach64 at I/O base 0x02EC." - ATI_README, + " be enabled\n because it conflicts with a Mach64" + " at I/O base 0x02EC.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; + default: /* Must be DoProbe */ + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - xf86SetPciVideo(pVideo, IO); + xf86SetPciVideo(pVideo, MEM_IO); - if (!(pATI = ATI8514Probe(pVideo))) - xf86Msg(X_WARNING, + if (!(pATI = ATI8514Probe(pVideo))) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d could" - " not be detected!" ATI_README, + " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - else - { - if (pATI->Adapter != ATI_ADAPTER_MACH32) - xf86Msg(X_WARNING, + else + { + sprintf(Identifier, + "Shared 8514/A in PCI slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s detected.\n", Identifier); + if (pATI->Adapter != ATI_ADAPTER_MACH32) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d" - " could only be detected as an %s!" - ATI_README, + " could only be detected as an %s!\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[pATI->Adapter]); - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; - if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || - (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); - } + if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || + (pATI->Coprocessor != ATI_CHIP_NONE)) + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); + } - xf86SetPciVideo(NULL, NONE); - break; + xf86SetPciVideo(NULL, NONE); + break; + } } - } - /* Next, look for sparse I/O Mach64's */ - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32) || - IsATIBlockIOBase(pVideo->ioBase[1])) - continue; + /* Next, look for sparse I/O Mach64's */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; - pPCI = (pciConfigPtr)(pVideo->thisCard); - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - j = PciReg & 0x03U; - if (j == 0x03U) - xf86Msg(X_WARNING, + pPCI = pVideo->thisCard; + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + j = PciReg & 0x03U; + if (j == 0x03U) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d cannot be" " enabled\n because it has neither a block, nor a" - " sparse, I/O base." ATI_README, + " sparse, I/O base.\n", pVideo->bus, pVideo->device, pVideo->func); - else switch(ATICheckSparseIOBases(ProbeFlags, - Mach64SparseIOBases[j], 4, TRUE)) - { - case 0: - xf86Msg(X_WARNING, + else switch(ATICheckSparseIOBases(pVideo, ProbeFlags, + Mach64SparseIOBases[j], 4, TRUE)) + { + case 0: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" " be enabled\n because it conflicts with another" - " non-video PCI device." ATI_README, + " non-video PCI device.\n", pVideo->bus, pVideo->device, pVideo->func); - break; + break; - case Detected8514A: - xf86Msg(X_WARNING, + case Detected8514A: + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with an %s." - ATI_README, + " be enabled\n because it conflicts with an %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[p8514->Adapter]); - break; + break; - case DetectedMach64: - pATI = pMach64[j]; - if ((pATI->BusType >= ATI_BUS_PCI) && !pATI->PCIInfo) - pATI->PCIInfo = pVideo; - else - xf86Msg(X_WARNING, + case DetectedMach64: + pATI = pMach64[j]; + if ((pATI->BusType >= ATI_BUS_PCI) && !pATI->PCIInfo) + pATI->PCIInfo = pVideo; + else + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" - " another %s Mach64 at sparse I/O base 0x%04X." - ATI_README, + " another %s Mach64 at sparse I/O base" + " 0x%04X.\n", pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[pATI->BusType], Mach64SparseIOBases[j]); - break; - - default: /* Must be DoProbe */ - if (!xf86CheckPciSlot(pVideo->bus, - pVideo->device, - pVideo->func)) - continue; + break; - xf86SetPciVideo(pVideo, IO); + default: /* Must be DoProbe */ + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; - pATI = ATIMach64Probe(Mach64SparseIOBases[j], SPARSE_IO, - pVideo->chipType, - ATIChipID(pVideo->chipType, pVideo->chipRev)); - if (!pATI) - xf86Msg(X_WARNING, + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); + + xf86SetPciVideo(pVideo, MEM_IO); + + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], + SPARSE_IO, Chip); + if (!pATI) + xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d could" - " not be detected!" ATI_README, + " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); - else - { - AddAdapter(pATI); - pATI->SharedAccelerator = TRUE; - pATI->PCIInfo = pVideo; + else + { + sprintf(Identifier, + "Shared PCI Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s with sparse PIO base 0x%04X" + " detected.\n", Identifier, + Mach64SparseIOBases[j]); + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; + pATI->PCIInfo = pVideo; + + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); + } - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); - } + xf86SetPciVideo(NULL, NONE); + break; + } + } - xf86SetPciVideo(NULL, NONE); - break; +#else /* AVOID_CPIO */ + + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; + + /* Check if this one has already been detected */ + for (j = 0; j < nATIPtr; j++) + { + pATI = ATIPtrs[j]; + if (pATI->PCIInfo == pVideo) + goto SkipThisSlot; + } + + if (!xf86CheckPciSlot(pVideo->bus, + pVideo->device, + pVideo->func)) + continue; + + xf86SetPciVideo(pVideo, MEM_IO); + + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + + /* The adapter's CPIO base is of little concern here */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (pATI) + { + sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s with Block 0 base 0x%08X detected.\n", + Identifier, pATI->Block0Base); + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; + pATI->PCIInfo = pVideo; + } + else + { + xf86Msg(X_WARNING, + ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" + " detected!\n", + pVideo->bus, pVideo->device, pVideo->func); + } + + xf86SetPciVideo(NULL, NONE); + + SkipThisSlot:; } + +#endif /* AVOID_CPIO */ + } /* Lastly, look for block I/O devices */ @@ -1294,9 +1675,32 @@ !IsATIBlockIOBase(pVideo->ioBase[1])) continue; - /* For now, ignore Rage128's */ + /* Check for Rage128's, Radeon's and later adapters */ Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); if (Chip > ATI_CHIP_Mach64) + { + switch (Chip) + { + case ATI_CHIP_RAGE128GL: + case ATI_CHIP_RAGE128VR: + case ATI_CHIP_RAGE128PROGL: + case ATI_CHIP_RAGE128PROVR: + case ATI_CHIP_RAGE128MOBILITY3: + case ATI_CHIP_RAGE128MOBILITY4: + DoRage128 = TRUE; + continue; + + case ATI_CHIP_RADEON: + DoRadeon = TRUE; + continue; + + case ATI_CHIP_HDTV: + default: + continue; + } + } + + if (!nATIGDev) continue; /* Check if this one has already been detected */ @@ -1311,17 +1715,25 @@ continue; /* Probe for it */ - xf86SetPciVideo(pVideo, IO); + xf86SetPciVideo(pVideo, MEM_IO); - pATI = ATIMach64Probe(pVideo->ioBase[1], BLOCK_IO, - pVideo->chipType, Chip); + pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); if (pATI) { + sprintf(Identifier, "Shared PCI/AGP Mach64 in slot %d:%d:%d", + pVideo->bus, pVideo->device, pVideo->func); + xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n", + Identifier); AddAdapter(pATI); pATI->SharedAccelerator = TRUE; +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, ProbeFlags); + +#endif /* AVOID_CPIO */ + } xf86SetPciVideo(NULL, NONE); @@ -1329,9 +1741,8 @@ if (!pATI) { xf86Msg(X_WARNING, - ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" - " detected!" ATI_README, - pVideo->bus, pVideo->device, pVideo->func); + ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not be" + " detected!\n", pVideo->bus, pVideo->device, pVideo->func); continue; } @@ -1340,13 +1751,15 @@ } } +#ifndef AVOID_CPIO + /* * At this point, if there's a non-shareable VGA with its own framebuffer, * find out if it's an ATI VGA Wonder. */ do { - if (!pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA)) + if (!nATIGDev || !pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA)) break; /* If it has not been assigned to a coprocessor, keep track of it */ @@ -1354,15 +1767,17 @@ AddAdapter(pVGA); /* - * Non-ix86's should never get here. Any VGA should have installed its - * int 10 vector. Use that to find the VGA BIOS. If this fails, scan - * all legacy BIOS segments, in 512-byte increments. + * A VGA should have installed its int 10 vector. Use that to find the + * VGA BIOS. If this fails, scan all legacy BIOS segments, in 512-byte + * increments. */ if (xf86ReadBIOS(0U, 0x42U, BIOS, 2) != 2) goto NoVGAWonder; pATI = NULL; - BIOSBase = ((BIOS[1] << 8) | BIOS[0]) << 4; + BIOSBase = 0; + if (!(BIOS[0] & 0x1FU)) /* Otherwise there's no 512-byte alignment */ + BIOSBase = ((BIOS[1] << 8) | BIOS[0]) << 4; /* Look for its BIOS */ for(; ; BIOSBase += 0x00000200U) @@ -1476,7 +1891,7 @@ if (!pVGA->CPIO_VGAWonder) pVGA->CPIO_VGAWonder = 0x01CEU; - ATIVGAWonderProbe(pVGA, p8514, ProbeFlags); + ATIVGAWonderProbe(NULL, pVGA, p8514, ProbeFlags); break; #if 0 case '2': @@ -1504,11 +1919,30 @@ NoVGAWonder:; } while (0); - /* If no appropriate adapters have been detected, return now */ - if (!nATIPtr) +#endif /* AVOID_CPIO */ + + /* + * Re-order list of detected devices so that the primary device is before + * any other PCI device. + */ + for (i = 0; i < nATIPtr; i++) { - xfree(ATIGDevs); - return FALSE; + if (!ATIPtrs[i]->PCIInfo) + continue; + + for (j = i; j < nATIPtr; j++) + { + pATI = ATIPtrs[j]; + if (!xf86IsPrimaryPci(pATI->PCIInfo)) + continue; + + for (; j > i; j--) + ATIPtrs[j] = ATIPtrs[j - 1]; + ATIPtrs[j] = pATI; + break; + } + + break; } if (flags & PROBE_DETECT) @@ -1521,12 +1955,17 @@ { pATI = ATIPtrs[i]; +#ifndef AVOID_CPIO + if ((pATI->Adapter != ATI_ADAPTER_VGA) && ((pATI->Adapter != ATI_ADAPTER_8514A) || ((pATI->VGAAdapter != ATI_ADAPTER_VGA) && (pATI->VGAAdapter != ATI_ADAPTER_NONE)))) + +#endif /* AVOID_CPIO */ + { - nAdapter++; + ProbeSuccess = TRUE; pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME, pATI->PCIInfo, ATI_CHIPSET_ATI); if (pGDev) @@ -1534,297 +1973,352 @@ /* Fill in additional information */ pGDev->vendor = ATI_NAME; pGDev->chipset = (char *)ATIChipsetNames[ATI_CHIPSET_ATI]; + if (!pATI->PCIInfo) + pGDev->busID = NULL; } } xfree(pATI); } - - xfree(ATIPtrs); - return (nAdapter != 0); } - - /* - * Re-order list of detected devices so that the primary device is before - * any other PCI device. - */ - for (i = 0; i < nATIPtr; i++) + else { - if (!ATIPtrs[i]->PCIInfo) - continue; - - for (j = i; j < nATIPtr; j++) + /* + * Assign detected devices to XF86Config Device sections. This is done + * by comparing certain Device section specifications against the + * corresponding adapter information. Begin with those specifications + * that are independent of the adapter's bus location. + */ + for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) { - pATI = ATIPtrs[j]; - if (!xf86IsPrimaryPci(pATI->PCIInfo)) - continue; + pGDev = pATIGDev->pGDev; - for (; j > i; j--) - ATIPtrs[j] = ATIPtrs[j - 1]; - ATIPtrs[j] = pATI; - break; - } + for (j = 0; j < nATIPtr; j++) + { + pATI = ATIPtrs[j]; - break; - } + /* + * First check the Chipset specification. The placement of + * "break" and "continue" statements here is carefully chosen + * to produce the intended behaviour for each Chipset value. + */ + switch (pATIGDev->Chipset) + { + case ATI_CHIPSET_ATI: - /* - * Assign detected devices to XF86Config Device sections. This is done by - * comparing certain Device section specifications against the - * corresponding adapter information. Begin with those specifications that - * are independent of the adapter's bus location. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; +#ifndef AVOID_CPIO - for (j = 0; j < nATIPtr; j++) - { - pATI = ATIPtrs[j]; + if (pATI->Adapter == ATI_ADAPTER_VGA) + continue; + if (pATI->Adapter != ATI_ADAPTER_8514A) + break; + /* Fall through */ - /* - * First check the Chipset specification. The placement of "break" - * and "continue" statements here is carefully chosen to produce - * the intended behaviour for each Chipset value. - */ - switch (pATIGDev->Chipset) - { - case ATI_CHIPSET_ATI: - if (pATI->Adapter == ATI_ADAPTER_VGA) - continue; - if (pATI->Adapter != ATI_ADAPTER_8514A) + case ATI_CHIPSET_ATIVGA: + if (pATI->VGAAdapter == ATI_ADAPTER_VGA) + continue; + /* Fall through */ + + case ATI_CHIPSET_IBMVGA: + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + continue; break; - /* Fall through */ - case ATI_CHIPSET_ATIVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_VGA) - continue; - /* Fall through */ + case ATI_CHIPSET_VGAWONDER: + if (!pATI->CPIO_VGAWonder) + continue; + break; - case ATI_CHIPSET_IBMVGA: - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + case ATI_CHIPSET_IBM8514: + if (pATI->Adapter == ATI_ADAPTER_8514A) + break; + /* Fall through */ + + case ATI_CHIPSET_MACH8: + if (pATI->Adapter == ATI_ADAPTER_MACH8) + break; + /* Fall through */ + + case ATI_CHIPSET_MACH32: + if (pATI->Adapter == ATI_ADAPTER_MACH32) + break; continue; - break; - case ATI_CHIPSET_VGAWONDER: - if (!pATI->CPIO_VGAWonder) +#endif /* AVOID_CPIO */ + + case ATI_CHIPSET_MACH64: + if (pATI->Adapter == ATI_ADAPTER_MACH64) + break; continue; - break; - case ATI_CHIPSET_IBM8514: - if (pATI->Adapter == ATI_ADAPTER_8514A) - break; - /* Fall through */ + default: + continue; + } - case ATI_CHIPSET_MACH8: - if (pATI->Adapter == ATI_ADAPTER_MACH8) - break; - /* Fall through */ + /* + * The ChipID and ChipRev specifications are compared next. + * First, require these to be unspecified for anything other + * than Mach32 or Mach64 adapters. ChipRev is also required to + * be unspecified for Mach32's. ChipID is optional for + * Mach32's, and both specifications are optional for Mach64's. + * Lastly, allow both specifications to override their detected + * value in the case of Mach64 adapters whose ChipID is + * unrecognised. + */ + if (pGDev->chipID >= 0) + { + if (pATI->ChipType != pGDev->chipID) + { + if ((pATI->Adapter != ATI_ADAPTER_MACH64) || + (pATI->Chip != ATI_CHIP_Mach64)) + continue; - case ATI_CHIPSET_MACH32: - if (pATI->Adapter == ATI_ADAPTER_MACH32) - break; - continue; + Chip = ATIChipID(pGDev->chipID, 0); + if ((Chip <= ATI_CHIP_264GTB) || + (Chip == ATI_CHIP_Mach64)) + continue; + } + if ((pGDev->chipRev >= 0) && + (pATI->ChipRev != pGDev->chipRev)) + { + if (pATI->Adapter != ATI_ADAPTER_MACH64) + continue; - case ATI_CHIPSET_MACH64: - if (pATI->Adapter == ATI_ADAPTER_MACH64) - break; - continue; + if (pATI->Chip != ATI_CHIP_Mach64) + { + if (pATI->ChipRev == pATI->ChipRevision) + continue; + + /* + * There are two foundry codes for UMC. Some + * adapters will advertise one in CONFIG_CHIP_ID + * and the other in PCI configuration space. For + * matching purposes, make both codes compare + * equal. + */ +# define UMC_IGNORE \ + (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA) +# define UMC_NOCARE \ + GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \ + CFG_CHIP_REV) + + if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE) + continue; + + if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) && + (pATI->ChipFoundry != ATI_FOUNDRY_UMCA)) + continue; + + k = GetBits(pGDev->chipRev, + GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); + if ((k != ATI_FOUNDRY_UMC) && + (k != ATI_FOUNDRY_UMCA)) + continue; + } + } + } - default: + /* + * IOBase is next. This is the first specification that is + * potentially dependent on bus location. It is only allowed + * for Mach64 adapters, and is optional. + */ + if (pGDev->IOBase && (pATI->CPIOBase != pGDev->IOBase)) continue; - } - /* - * The ChipID and ChipRev specifications are compared next. First, - * require these to be unspecified for anything other than Mach32 - * or Mach64 adapters. ChipRev is also required to be unspecified - * for Mach32's. ChipID is optional for for Mach32's, and both - * specifications are optional for Mach64's. Lastly, allow both - * specifications to override their detected value in the case of - * Mach64 adapters whose ChipID is unrecognised. - */ - if (pGDev->chipID >= 0) - { - if (pATI->ChipType != pGDev->chipID) + /* + * Compare BusID's. This specification is only allowed for PCI + * Mach32's or Mach64's and is optional. + */ + if (pGDev->busID && pGDev->busID[0]) { - if ((pATI->Adapter != ATI_ADAPTER_MACH64) || - (pATI->Chip != ATI_CHIP_Mach64)) + pVideo = pATI->PCIInfo; + +#ifndef AVOID_CPIO + + if (!pVideo) continue; + +#endif /* AVOID_CPIO */ - Chip = ATIChipID(pGDev->chipID, 0); - if ((Chip <= ATI_CHIP_264GTB) || (Chip == ATI_CHIP_Mach64)) + if (!xf86ComparePciBusString(pGDev->busID, + pVideo->bus, pVideo->device, pVideo->func)) continue; } - if ((pGDev->chipRev >= 0) && (pATI->ChipRev != pGDev->chipRev)) + + /* + * Ensure no two adapters are assigned to the same XF86Config + * Device section. + */ + if (pATIGDev->iATIPtr) { - if (pATI->Adapter != ATI_ADAPTER_MACH64) - continue; + if (pATIGDev->iATIPtr < 0) + break; - if (pATI->Chip != ATI_CHIP_Mach64) - { - if (pATI->ChipRev == pATI->ChipRevision) - continue; + xf86Msg(X_ERROR, + ATI_NAME ": XF86Config Device section \"%s\" may not" + " be assigned to more than one adapter.\n", + pGDev->identifier); + pATIGDev->iATIPtr = -1; + break; + } - /* - * There are two foundry codes for UMC. Some adapters - * will advertise one in CONFIG_CHIP_ID and the other - * in PCI configuration space. For matching purposes, - * make both codes compare equal. - */ -# define UMC_IGNORE (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA) -# define UMC_NOCARE \ - GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \ - CFG_CHIP_REV) + /* Assign adapter */ + pATIGDev->iATIPtr = j + 1; - if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE) - continue; + /* + * For compatibility with previous releases, assign the first + * applicable adapter if there is only one Device section. + */ + if (nATIGDev == 1) + break; + } + } - if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) && - (pATI->ChipFoundry != ATI_FOUNDRY_UMCA)) - continue; + /* + * Ensure no two XF86Config Device sections are assigned to the same + * adapter. Then, generate screens for any that are left. + */ + for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) + { + pGDev = pATIGDev->pGDev; - k = GetBits(pGDev->chipRev, - GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV)); - if ((k != ATI_FOUNDRY_UMC) && (k != ATI_FOUNDRY_UMCA)) - continue; - } + j = pATIGDev->iATIPtr; + if (j <= 0) + continue; + + for (k = i; ++k < nATIGDev; ) + { + if (j == ATIGDevs[k].iATIPtr) + { + xf86Msg(X_ERROR, + ATI_NAME ": XF86Config Device sections \"%s\" and" + " \"%s\" may not be assigned to the same adapter.\n", + pGDev->identifier, ATIGDevs[k].pGDev->identifier); + pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; } } - /* - * IOBase is next. This is the first specification that is - * potentially dependent on bus location. It is only allowed for - * Mach64 adapters, and is optional. - */ - if (pGDev->IOBase && (pATI->CPIOBase != pGDev->IOBase)) + j = ATIGDevs[i].iATIPtr; + if (j <= 0) continue; - /* - * Compare BusID's. This specification is only allowed for PCI - * Mach32's or Mach64's and is optional. - */ - if (pGDev->busID && pGDev->busID[0]) - { - if (!(pVideo = pATI->PCIInfo)) - continue; - if (!xf86ComparePciBusString(pGDev->busID, - pVideo->bus, pVideo->device, pVideo->func)) - continue; - } + pATI = ATIPtrs[j - 1]; + + xf86MsgVerb(X_INFO, 3, + ATI_NAME ": %s assigned to %sactive \"Device\" section" + " \"%s\".\n", + Identifier, pGDev->active ? "" : "in", pGDev->identifier); /* - * Ensure no two adapters are assigned to the same XF86Config - * Device section. + * Attach adapter to XF86Config Device section and register its + * resources. */ - if (pATIGDev->iATIPtr) + if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset, + pGDev, pGDev->active, pATI) < 0) { - if (pATIGDev->iATIPtr < 0) - break; - xf86Msg(X_ERROR, - ATI_NAME ": XF86Config Device section \"%s\" may not" - " be assigned to more than one adapter." ATI_README, - pGDev->identifier); - pATIGDev->iATIPtr = -1; - break; + ATI_NAME ": Could not claim bus slot for %s.\n", + Identifier); + continue; } - - /* Assign adapter */ - pATIGDev->iATIPtr = j + 1; - /* - * For compatibility with previous releases, assign the first - * applicable adapter if there is only one Device section. - */ - if (nATIGDev == 1) - break; - } - } + if (!pGDev->active) + continue; - /* - * Ensure no two XF86Config Device sections are assigned to the same - * adapter. Then, generate screens for any that are left. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; + /* Allocate screen */ + pScreenInfo = xf86AllocateScreen(pDriver, 0); - j = pATIGDev->iATIPtr; - if (j <= 0) - continue; +#ifdef XFree86LOADER - for (k = i; ++k < nATIGDev; ) - { - if (j == ATIGDevs[k].iATIPtr) + if (!xf86LoadSubModule(pScreenInfo, "atimisc")) { xf86Msg(X_ERROR, - ATI_NAME ": XF86Config Device sections \"%s\" and" - " \"%s\" may not be assigned to the same adapter." - ATI_README, pGDev->identifier, - ATIGDevs[k].pGDev->identifier); - pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; + ATI_NAME ": Failed to load \"atimisc\" module.\n"); + xf86DeleteScreen(pScreenInfo->scrnIndex, 0); + continue; } - } - j = ATIGDevs[i].iATIPtr; - if (j <= 0) - continue; + xf86LoaderReqSymLists(ATISymbols, NULL); - pATI = ATIPtrs[j - 1]; + /* Workaround for possible loader bug */ +# define ATIPreInit \ + (xf86PreInitProc*) LoaderSymbol("ATIPreInit") +# define ATIScreenInit \ + (xf86ScreenInitProc*) LoaderSymbol("ATIScreenInit") +# define ATISwitchMode \ + (xf86SwitchModeProc*) LoaderSymbol("ATISwitchMode") +# define ATIAdjustFrame \ + (xf86AdjustFrameProc*)LoaderSymbol("ATIAdjustFrame") +# define ATIEnterVT \ + (xf86EnterVTProc*) LoaderSymbol("ATIEnterVT") +# define ATILeaveVT \ + (xf86LeaveVTProc*) LoaderSymbol("ATILeaveVT") +# define ATIFreeScreen \ + (xf86FreeScreenProc*) LoaderSymbol("ATIFreeScreen") +# define ATIValidMode \ + (xf86ValidModeProc*) LoaderSymbol("ATIValidMode") - /* - * Attach adapter to XF86Config Device section and register its - * resources. - */ - if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset, - pGDev, pGDev->active, pATI) < 0) - continue; +#endif - if (!pGDev->active) - continue; + /* Attach device to screen */ + xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); - /* Allocate screen */ - pScreenInfo = xf86AllocateScreen(pDriver, 0); + ATIPtrs[j - 1] = NULL; - /* Attach device to screen */ - xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); + /* Fill in probe data */ + pScreenInfo->driverVersion = ATI_VERSION_CURRENT; + pScreenInfo->driverName = ATI_DRIVER_NAME; + pScreenInfo->name = ATI_NAME; + pScreenInfo->Probe = ATIProbe; + pScreenInfo->PreInit = ATIPreInit; + pScreenInfo->ScreenInit = ATIScreenInit; + pScreenInfo->SwitchMode = ATISwitchMode; + pScreenInfo->AdjustFrame = ATIAdjustFrame; + pScreenInfo->EnterVT = ATIEnterVT; + pScreenInfo->LeaveVT = ATILeaveVT; + pScreenInfo->FreeScreen = ATIFreeScreen; + pScreenInfo->ValidMode = ATIValidMode; - ATIPtrs[j - 1] = NULL; + pScreenInfo->driverPrivate = pATI; - /* Fill in probe data */ - pScreenInfo->driverVersion = ATI_VERSION_CURRENT; - pScreenInfo->driverName = ATI_DRIVER_NAME; - pScreenInfo->name = ATI_NAME; - pScreenInfo->Probe = ATIProbe; - pScreenInfo->PreInit = ATIPreInit; - pScreenInfo->ScreenInit = ATIScreenInit; - pScreenInfo->SwitchMode = ATISwitchMode; - pScreenInfo->AdjustFrame = ATIAdjustFrame; - pScreenInfo->EnterVT = ATIEnterVT; - pScreenInfo->LeaveVT = ATILeaveVT; - pScreenInfo->FreeScreen = ATIFreeScreen; - pScreenInfo->ValidMode = ATIValidMode; + pATI->Chipset = pATIGDev->Chipset; - pScreenInfo->driverPrivate = pATI; + ProbeSuccess = TRUE; + } - pATI->Chipset = pATIGDev->Chipset; + /* Deal with unassigned adapters */ + for (i = 0; i < nATIPtr; i++) + { + if (!(pATI = ATIPtrs[i])) + continue; - nAdapter++; - } +#ifndef AVOID_CPIO - /* Deal with unassigned adapters */ - for (i = 0; i < nATIPtr; i++) - { - if (!(pATI = ATIPtrs[i])) - continue; + if (pATI->Adapter > ATI_ADAPTER_VGA) - if ((pATI->Adapter > ATI_ADAPTER_VGA) && (pATI->iEntity < 0)) - (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); - xfree(pATI); +#endif /* AVOID_CPIO */ + + { + if (pATI->iEntity < 0) + (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); + } + + xfree(pATI); + } + + xfree(ATIGDevs); } + xfree(ATIPtrs); - xfree(ATIGDevs); + + /* Call Rage 128 driver probe */ + if (DoRage128 && R128Probe(pDriver, flags)) + ProbeSuccess = TRUE; + + /* Call Radeon driver probe */ + if (DoRadeon && RADEONProbe(pDriver, flags)) + ProbeSuccess = TRUE; - return (nAdapter != 0); + return ProbeSuccess; } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h:1.4 Fri Feb 18 07:19:34 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h Fri Aug 4 17:07:15 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h,v 1.4 2000/02/18 12:19:34 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h,v 1.5 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIPROBE_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern Bool ATIProbe FunctionPrototype((DriverPtr, int)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h:1.10 xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h:1.10 Thu Mar 30 10:41:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h Tue Aug 22 17:54:31 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.10 2000/03/30 15:41:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.12 2000/08/22 21:54:31 tsi Exp $ */ /* * Copyright 1994 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -124,10 +124,10 @@ #define VBLANK 0x0002u #define HORTOG 0x0004u #define H_TOTAL 0x02e8u /* Write */ -#define DAC_MASK 0x02eau -#define DAC_R_INDEX 0x02ebu -#define DAC_W_INDEX 0x02ecu -#define DAC_DATA 0x02edu +#define IBM_DAC_MASK 0x02eau +#define IBM_DAC_READ 0x02ebu +#define IBM_DAC_WRITE 0x02ecu +#define IBM_DAC_DATA 0x02edu #define H_DISP 0x06e8u /* Write */ #define H_SYNC_STRT 0x0ae8u /* Write */ #define H_SYNC_WID 0x0ee8u /* Write */ @@ -273,7 +273,7 @@ #define SCISSORS_L 0x2000u #define SCISSORS_B 0x3000u #define SCISSORS_R 0x4000u -#define MEM_CNTL 0x5000u +#define M32_MEM_CNTL 0x5000u #define HORCFG_4 0x0000u #define HORCFG_5 0x0001u #define HORCFG_8 0x0002u @@ -949,7 +949,7 @@ #define HFB_PITCH_ADDR BlockIOTag(0x2au) /* LT */ #define LCD_DATA BlockIOTag(0x2au) /* LTPro */ #define EXT_MEM_CNTL BlockIOTag(0x2bu) /* VTB/GTB/LT */ -#define MEM_INFO IOPortTag(0x14u, 0x2cu) /* Renamed MEM_CNTL */ +#define MEM_CNTL IOPortTag(0x14u, 0x2cu) #define CTL_MEM_SIZE 0x00000007ul /* ? 0x00000008ul */ #define CTL_MEM_REFRESH 0x00000078ul /* VT/GT */ @@ -993,7 +993,7 @@ #define CTL_MEM_PIX_WIDTH 0x07000000ul #define CTL_MEM_LOWER_APER_ENDIAN 0x03000000ul /* VTB/GTB/LT */ #define CTL_MEM_OE_SELECT 0x18000000ul /* VT/GT */ -#define CTL_MEM_UPPER_APER_ENDIAN 0c0c000000ul /* VTB/GTB/LT */ +#define CTL_MEM_UPPER_APER_ENDIAN 0x0c000000ul /* VTB/GTB/LT */ /* ? 0xe0000000ul */ #define CTL_MEM_PAGE_SIZE 0x30000000ul /* VTB/GTB/LT */ #define MEM_VGA_WP_SEL IOPortTag(0x15u, 0x2du) @@ -1005,6 +1005,10 @@ #define LT_GIO BlockIOTag(0x2fu) /* LT */ #define I2C_CNTL_1 BlockIOTag(0x2fu) /* GTPro */ #define DAC_REGS IOPortTag(0x17u, 0x30u) /* 4 separate bytes */ +#define M64_DAC_WRITE (DAC_REGS + 0) +#define M64_DAC_DATA (DAC_REGS + 1) +#define M64_DAC_MASK (DAC_REGS + 2) +#define M64_DAC_READ (DAC_REGS + 3) #define DAC_CNTL IOPortTag(0x18u, 0x31u) #define DAC_EXT_SEL 0x00000003ul #define DAC_EXT_SEL_RS2 0x000000001ul @@ -1471,8 +1475,8 @@ #define CLR_CMP_FN_TRUE 0x00000001ul /* ? 0x00000002ul */ /* ? 0x00000003ul */ -#define CLR_CMP_FN_EQUAL 0x00000004ul -#define CLR_CMP_FN_NOT_EQUAL 0x00000005ul +#define CLR_CMP_FN_NOT_EQUAL 0x00000004ul +#define CLR_CMP_FN_EQUAL 0x00000005ul /* ? 0x00000006ul */ /* ? 0x00000007ul */ /* ? 0x00fffff8ul */ @@ -1860,6 +1864,12 @@ /* ? BlockIOTag(0x1fdu) */ /* ? BlockIOTag(0x1feu) */ /* ? BlockIOTag(0x1ffu) */ + +/* Definitions for MEM_CNTL's CTL_MEM_?????_APER_ENDIAN fields */ +#define CTL_MEM_APER_BYTE_ENDIAN 0x00u +#define CTL_MEM_APER_WORD_ENDIAN 0x01u +#define CTL_MEM_APER_LONG_ENDIAN 0x02u +/* ? 0x03u */ /* Definitions for an ICS2595's programme word */ #define ICS2595_CLOCK 0x000001f0ul Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c:1.9 xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c:1.9 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c Wed Oct 11 18:52:57 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.9 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.12 2000/10/11 22:52:57 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,11 +22,12 @@ */ #include "ati.h" -#include "atiadapter.h" #include "aticonsole.h" #include "atidac.h" #include "atidga.h" +#include "atimode.h" #include "atiscreen.h" +#include "atistruct.h" #include "shadowfb.h" #include "xf86cmap.h" @@ -136,6 +137,9 @@ /* Initialise framebuffer layer */ switch (pATI->bitsPerPixel) { + +#ifndef AVOID_CPIO + case 1: pATI->Closeable = xf1bppScreenInit(pScreen, pFB, pScreenInfo->virtualX, pScreenInfo->virtualY, @@ -148,6 +152,8 @@ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth); break; +#endif /* AVOID_CPIO */ + case 8: pATI->Closeable = cfbScreenInit(pScreen, pFB, pScreenInfo->virtualX, pScreenInfo->virtualY, @@ -201,17 +207,21 @@ xf86SetBlackWhitePixels(pScreen); +#ifndef AVOID_CPIO + /* Initialise banking if needed */ if (!miInitializeBanking(pScreen, pScreenInfo->virtualX, pScreenInfo->virtualY, pATI->displayWidth, &pATI->BankInfo)) return FALSE; +#endif /* AVOID_CPIO */ + /* Initialise DGA support */ (void)ATIDGAInit(pScreenInfo, pScreen, pATI); /* Setup acceleration */ - if (!ATIAdapterAccelInit(pScreenInfo, pScreen, pATI)) + if (!ATIModeAccelInit(pScreenInfo, pScreen, pATI)) return FALSE; /* Initialise backing store */ @@ -225,6 +235,16 @@ if (!miCreateDefColormap(pScreen)) return FALSE; +#ifdef AVOID_CPIO + + if (!xf86HandleColormaps(pScreen, 256, pScreenInfo->rgbBits, + ATILoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | + CMAP_LOAD_EVEN_IF_OFFSCREEN)) + return FALSE; + +#else /* AVOID_CPIO */ + if (pATI->depth > 1) if (!xf86HandleColormaps(pScreen, (pATI->depth == 4) ? 16 : 256, pScreenInfo->rgbBits, ATILoadPalette, NULL, @@ -232,6 +252,8 @@ CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE; +#endif /* AVOID_CPIO */ + /* Initialise shadow framebuffer */ if (pATI->OptionShadowFB && !ShadowFBInit(pScreen, ATIRefreshArea)) @@ -282,6 +304,10 @@ pATI->Closeable = FALSE; ATILeaveGraphics(pScreenInfo, pATI); + + xfree(pATI->ExpansionBitmapScanlinePtr[1]); + pATI->ExpansionBitmapScanlinePtr[0] = + pATI->ExpansionBitmapScanlinePtr[1] = NULL; xfree(pATI->pShadow); pATI->pShadow = NULL; Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h:1.2 Fri Feb 18 07:19:40 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h,v 1.2 2000/02/18 12:19:40 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h,v 1.3 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATISCREEN_H___ 1 #include "atiproto.h" + #include "screenint.h" extern Bool ATIScreenInit FunctionPrototype((int, ScreenPtr, int, char **)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h:1.18 xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h:1.21 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h:1.18 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h Tue Aug 22 17:54:31 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.18 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.21 2000/08/22 21:54:31 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,6 +27,7 @@ #include "atibank.h" #include "aticlock.h" #include "atiregs.h" + #include "xf86Resources.h" #include "xaa.h" @@ -51,16 +52,26 @@ /* The CRTC used to drive the screen (VGA, 8514, Mach64) */ CARD8 crtc; - /* VGA registers */ - CARD8 genmo, crt[25], seq[5], gra[9], attr[21], lut[256 * 3]; + /* Colour lookup table */ + CARD8 lut[256 * 3]; - /* Generic DAC registers */ - CARD8 dac_read, dac_write, dac_mask; +#ifndef AVOID_CPIO + /* VGA registers */ + CARD8 genmo, crt[25], seq[5], gra[9], attr[21]; + /* VGA Wonder registers */ CARD8 a3, a6, a7, ab, ac, ad, ae, b0, b1, b2, b3, b5, b6, b8, b9, ba, bd, be, bf; + /* Shadow VGA CRTC registers */ + CARD8 shadow_vga[25]; + +#endif /* AVOID_CPIO */ + + /* Generic DAC registers */ + CARD8 dac_read, dac_write, dac_mask; + /* Mach64 PLL registers */ CARD8 pll_vclk_cntl, pll_vclk_post_div, pll_vclk0_fb_div, pll_vclk1_fb_div, @@ -79,9 +90,6 @@ CARD32 lcd_index, config_panel, lcd_gen_ctrl, horz_stretching, vert_stretching, ext_vert_stretch; - /* Shadow VGA CRTC registers */ - CARD8 shadow_vga[25]; - /* Shadow Mach64 CRTC registers */ CARD32 shadow_h_total_disp, shadow_h_sync_strt_wid, shadow_v_total_disp, shadow_v_sync_strt_wid; @@ -111,10 +119,15 @@ /* Clock programming data */ int FeedbackDivider, ReferenceDivider, PostDivider; +#ifndef AVOID_CPIO + /* This is used by ATISwap() */ pointer frame_buffer; ATIBankProcPtr SetBank; unsigned int nBank, nPlane; + +#endif /* AVOID_CPIO */ + } ATIHWRec; /* @@ -130,22 +143,36 @@ /* * Adapter-related definitions. */ - CARD8 Adapter, VGAAdapter; + CARD8 Adapter; +#ifndef AVOID_CPIO + + CARD8 VGAAdapter; + +#endif /* AVOID_CPIO */ + /* * Chip-related definitions. */ - CARD8 Chip, Coprocessor; + CARD32 config_chip_id; CARD16 ChipType; + CARD8 Chip; CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry; - CARD8 ChipHasSUBSYS_CNTL; +#ifndef AVOID_CPIO + + CARD8 Coprocessor, ChipHasSUBSYS_CNTL; + +#endif /* AVOID_CPIO */ + /* * Processor I/O decoding definitions. */ CARD8 CPIODecoding; CARD16 CPIOBase; +#ifndef AVOID_CPIO + /* * Processor I/O port definition for VGA. */ @@ -158,37 +185,35 @@ CARD8 B2Reg; /* The B2 mirror */ CARD8 VGAOffset; /* Low index for CPIO_VGAWonder */ - /* - * Processor I/O port definitions for Mach64. - */ - CARD16 CPIO_CRTC_H_TOTAL_DISP, CPIO_CRTC_H_SYNC_STRT_WID, - CPIO_CRTC_V_TOTAL_DISP, CPIO_CRTC_V_SYNC_STRT_WID, - CPIO_CRTC_OFF_PITCH, CPIO_CRTC_INT_CNTL, CPIO_CRTC_GEN_CNTL, - CPIO_DSP_CONFIG, CPIO_DSP_ON_OFF, CPIO_OVR_CLR, - CPIO_OVR_WID_LEFT_RIGHT, CPIO_OVR_WID_TOP_BOTTOM, - CPIO_TV_OUT_INDEX, CPIO_CLOCK_CNTL, CPIO_TV_OUT_DATA, - CPIO_BUS_CNTL, CPIO_LCD_INDEX, CPIO_LCD_DATA, CPIO_MEM_INFO, - CPIO_MEM_VGA_WP_SEL, CPIO_MEM_VGA_RP_SEL, - CPIO_DAC_REGS, CPIO_DAC_CNTL, - CPIO_HORZ_STRETCHING, CPIO_VERT_STRETCHING, - CPIO_GEN_TEST_CNTL, CPIO_LCD_GEN_CTRL, - CPIO_POWER_MANAGEMENT, CPIO_CONFIG_CNTL; +#endif /* AVOID_CPIO */ /* * DAC-related definitions. */ - CARD16 DAC; + +#ifndef AVOID_CPIO + CARD16 CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE; + +#endif /* AVOID_CPIO */ + + CARD16 DAC; CARD8 rgbBits; /* * Definitions related to system bus interface. */ pciVideoPtr PCIInfo; - resRange VGAWonderResources[2]; CARD8 BusType; - CARD8 SharedVGA, SharedAccelerator; + CARD8 SharedAccelerator; + +#ifndef AVOID_CPIO + + CARD8 SharedVGA; + resRange VGAWonderResources[2]; +#endif /* AVOID_CPIO */ + /* * Definitions related to video memory. */ @@ -203,32 +228,43 @@ /* * Definitions related to video memory apertures. */ - pointer pBank, pMemory, pShadow; - unsigned long LinearBase, ApertureBase; - int LinearSize, ApertureSize, FBPitch, FBBytesPerPixel; + pointer pMemory, pShadow; + unsigned long LinearBase; + int LinearSize, FBPitch, FBBytesPerPixel; + +#ifndef AVOID_CPIO + + pointer pBank; CARD8 UseSmallApertures; +#endif /* AVOID_CPIO */ + /* * Definitions related to MMIO register apertures. */ pointer pMMIO, pBlock[2]; - unsigned long PageSize, MMIOBase; unsigned long Block0Base, Block1Base; +#ifndef AVOID_CPIO + /* * Banking interface. */ miBankInfoRec BankInfo; +#endif /* AVOID_CPIO */ + /* * XAA interface. */ XAAInfoRecPtr pXAAInfo; - int nAvailableFIFOEntries, nFIFOEntries; + int nAvailableFIFOEntries, nFIFOEntries, nHostFIFOEntries; CARD8 EngineIsBusy, EngineIsLocked, XModifier; CARD32 dst_cntl; /* For SetupFor/Subsequent communication */ - CARD32 ExpansionBitmapScanline[256]; - CARD32 *ExpansionBitmapScanlinePtr; + CARD32 sc_left_right, sc_top_bottom; + CARD16 sc_left, sc_right, sc_top, sc_bottom; /* Current scissors */ + pointer pHOST_DATA; /* Current HOST_DATA_* transfer window address */ + CARD32 *ExpansionBitmapScanlinePtr[2]; int ExpansionBitmapWidth; /* @@ -241,9 +277,10 @@ * Clock-related definitions. */ int ClockNumberToProgramme, ReferenceNumerator, ReferenceDenominator; + int ProgrammableClock; ClockRec ClockDescriptor; CARD16 BIOSClocks[16]; - CARD8 Clock, ProgrammableClock; + CARD8 Clock; /* * DSP register data. @@ -286,21 +323,28 @@ */ struct { + /* Mach64 registers */ + CARD32 bus_cntl, crtc_gen_cntl, mem_cntl, gen_test_cntl, crtc_int_cntl, + lcd_index; + +#ifndef AVOID_CPIO + + CARD32 config_cntl, dac_cntl; + + /* Mach8/Mach32 registers */ + CARD16 clock_sel, misc_options, mem_bndry, mem_cfg; + + /* VGA Wonder registers */ + CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be; + /* VGA registers */ CARD8 crt03, crt11; /* VGA shadow registers */ CARD8 shadow_crt03, shadow_crt11; - /* VGA Wonder registers */ - CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be; +#endif /* AVOID_CPIO */ - /* Mach8/Mach32 registers */ - CARD16 clock_sel, misc_options, mem_bndry, mem_cfg; - - /* Mach64 registers */ - CARD32 bus_cntl, config_cntl, crtc_gen_cntl, mem_info, gen_test_cntl, - dac_cntl, crtc_int_cntl, lcd_index; } LockData; /* Mode data */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c:1.10 Wed Apr 12 10:44:40 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.10 2000/04/12 14:44:40 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.11 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "aticrtc.h" #include "atistruct.h" #include "ativalid.h" + #include "xf86.h" /* @@ -45,8 +46,13 @@ ScrnInfoPtr pScreenInfo = xf86Screens[iScreen]; ATIPtr pATI = ATIPTR(pScreenInfo); Bool InterlacedSeen; - int VDisplay, VTotal, HBlankWidth; - int HAdjust, VScan, VInterlace; + int HBlankWidth, HAdjust, VScan, VInterlace; + +#ifndef AVOID_CPIO + + int VDisplay, VTotal; + +#endif /* AVOID_CPIO */ if (flags & MODECHECK_FINAL) { @@ -170,7 +176,7 @@ pMode->VTotal = ATIReverseVertical(CrtcVTotal); # undef ATIReverseHorizontal -# undef ATIReverVertical +# undef ATIReverseVertical } HBlankWidth = (pMode->HTotal >> 3) - (pMode->HDisplay >> 3); @@ -179,6 +185,9 @@ switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* Prevent overscans */ if (HBlankWidth > 63) @@ -209,6 +218,8 @@ return MODE_BAD_VVALUE; break; + +#endif /* AVOID_CPIO */ case ATI_CRTC_MACH64: if (VScan > 2) Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h:1.4 Fri Feb 18 07:19:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h,v 1.4 2000/02/18 12:19:42 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h,v 1.5 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIVALID_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern int ATIValidMode FunctionPrototype((int, DisplayModePtr, Bool, int)); Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h:1.16 xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h:1.28 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h:1.16 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h Tue Dec 12 19:45:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.16 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.28 2000/12/13 00:45:21 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,14 +24,14 @@ #ifndef ___ATIVERSION_H___ #define ___ATIVERSION_H___ 1 -#define ATI_NAME "ATI" -#define ATI_DRIVER_NAME "ati" +#define ATI_NAME "ATI" +#define ATI_DRIVER_NAME "ati" -#define ATI_VERSION_NAME "5.3.5" +#define ATI_VERSION_NAME "6.2.3" -#define ATI_VERSION_MAJOR 5 -#define ATI_VERSION_MINOR 3 -#define ATI_VERSION_PATCH 5 +#define ATI_VERSION_MAJOR 6 +#define ATI_VERSION_MINOR 2 +#define ATI_VERSION_PATCH 3 #define ATI_VERSION_CURRENT \ ((ATI_VERSION_MAJOR << 20) | (ATI_VERSION_MINOR << 10) | ATI_VERSION_PATCH) Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c:1.11 xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c:1.11 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c Wed Oct 11 18:52:58 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.11 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.13 2000/10/11 22:52:58 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,14 +24,20 @@ #include "ati.h" #include "atiadapter.h" #include "atichip.h" -#include "atiio.h" #include "atimono.h" +#include "atistruct.h" #include "ativga.h" +#include "ativgaio.h" + #include "xf86.h" -#define DPMS_SERVER +#ifndef DPMS_SERVER +# define DPMS_SERVER +#endif #include "extensions/dpms.h" +#ifndef AVOID_CPIO + /* * ATIVGAPreInit -- * @@ -496,3 +502,5 @@ PutReg(CRTX(pATI->CPIO_VGABase), 0x17U, crt17); PutReg(SEQX, 0x01U, 0x03U); /* End synchonous reset */ } + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h:1.6 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.6 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.7 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,8 +26,11 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" +#ifndef AVOID_CPIO + extern void ATIVGAPreInit FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGASave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGACalculate FunctionPrototype((ATIPtr, ATIHWPtr, @@ -36,5 +39,7 @@ extern void ATIVGASaveScreen FunctionPrototype((ATIPtr, int)); extern void ATIVGASetDPMSMode FunctionPrototype((ATIPtr, int)); + +#endif /* AVOID_CPIO */ #endif /* ___ATIVGA_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c:1.1 --- /dev/null Mon Dec 18 14:30:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c Wed Oct 11 18:52:58 2000 @@ -0,0 +1,46 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.c,v 1.1 2000/10/11 22:52:58 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atistruct.h" +#include "ativgaio.h" + +#ifndef AVOID_CPIO + +/* + * ATISetVGAIOBase -- + * + * This sets vgaIOBase according to the value of the passed value of the + * miscellaneous output register. + */ +void +ATISetVGAIOBase +( + ATIPtr pATI, + const CARD8 misc +) +{ + pATI->CPIO_VGABase = (misc & 0x01U) ? ColourIOBase : MonochromeIOBase; +} + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h:1.1 --- /dev/null Mon Dec 18 14:30:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h Wed Oct 11 18:52:58 2000 @@ -0,0 +1,56 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativgaio.h,v 1.1 2000/10/11 22:52:58 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATIVGAIO_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "ativgaio.h" +# undef XFree86Module +#endif + +#define ___ATIVGAIO_H___ 1 + +#include "atiio.h" +#include "atipriv.h" +#include "atiproto.h" + +#ifndef AVOID_CPIO + +extern void ATISetVGAIOBase FunctionPrototype((ATIPtr, const CARD8)); + +/* Odds and ends to ease reading and writting of indexed registers */ +#define GetReg(_Register, _Index) \ + ( \ + outb(_Register, _Index), \ + inb((_Register) + 1) \ + ) +#define PutReg(_Register, _Index, _Value) \ + do \ + { \ + outb(_Register, _Index); \ + outb((_Register) + 1, _Value); \ + } while(0) + +#endif /* AVOID_CPIO */ + +#endif /* ___ATIVGAIO_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c:1.8 Fri Feb 18 07:19:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c Tue Aug 22 17:54:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c,v 1.8 2000/02/18 12:19:44 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c,v 1.10 2000/08/22 21:54:32 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -65,6 +65,8 @@ "Unknown video memory type" }; +#ifndef AVOID_CPIO + /* * ATIUnmapVGA -- * @@ -73,18 +75,20 @@ static void ATIUnmapVGA ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (!pATI->pBank) return; - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pBank, 0x00010000U); + xf86UnMapVidMem(iScreen, pATI->pBank, 0x00010000U); pATI->pBank = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = NULL; } +#endif /* AVOID_CPIO */ + /* * ATIUnmapLinear -- * @@ -93,14 +97,34 @@ static void ATIUnmapLinear ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { + unsigned long PageSize; + int LinearSize; + +#ifdef AVOID_CPIO + + if (!pATI->pMemory) + return; + +#else /* AVOID_CPIO */ + if (pATI->pMemory != pATI->pBank) - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pMemory, - pATI->LinearSize); +#endif /* AVOID_CPIO */ + + { + PageSize = getpagesize(); + LinearSize = pATI->LinearSize; + if (((pATI->Block0Base | (PageSize - 1)) + 1) == + (pATI->LinearBase + LinearSize)) + LinearSize -= PageSize; + + xf86UnMapVidMem(iScreen, pATI->pMemory, LinearSize); + } + pATI->pMemory = NULL; } @@ -112,12 +136,12 @@ static void ATIUnmapMMIO ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (pATI->pMMIO) - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pMMIO, pATI->PageSize); + xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize()); pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL; } @@ -130,15 +154,42 @@ Bool ATIMapApertures ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { - pciVideoPtr pVideo; + pciVideoPtr pVideo; + PCITAG Tag; + unsigned long PageSize, MMIOBase; + int LinearSize; if (pATI->Mapped) return TRUE; +#ifndef AVOID_CPIO + + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + + { + if (!pATI->LinearBase && !pATI->Block0Base) + return FALSE; + } + + PageSize = getpagesize(); + MMIOBase = pATI->Block0Base & ~(PageSize - 1); + LinearSize = pATI->LinearSize; + if ((MMIOBase + PageSize) == (pATI->LinearBase + LinearSize)) + LinearSize -= PageSize; + + if ((pVideo = pATI->PCIInfo)) + Tag = ((pciConfigPtr)(pVideo->thisCard))->tag; + else + Tag = 0; + +#ifndef AVOID_CPIO + /* Map VGA aperture */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { @@ -146,8 +197,12 @@ * No relocation, resizing, caching or write-combining of this * aperture is supported. Hence, the hard-coded values here... */ - pATI->pBank = xf86MapVidMem(pScreenInfo->scrnIndex, VIDMEM_MMIO, - 0x000A0000U, 0x00010000U); + if (pVideo) + pATI->pBank = xf86MapPciMem(iScreen, VIDMEM_MMIO, + Tag, 0x000A0000U, 0x00010000U); + else + pATI->pBank = xf86MapVidMem(iScreen, VIDMEM_MMIO, + 0x000A0000U, 0x00010000U); if (!pATI->pBank) return FALSE; @@ -155,66 +210,71 @@ pATI->pMemory = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = pATI->pBank; + + pATI->Mapped = TRUE; } - pVideo = pATI->PCIInfo; +#endif /* AVOID_CPIO */ /* Map linear aperture */ if (pATI->LinearBase) { if (pVideo) - pATI->pMemory = xf86MapPciMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, ((pciConfigPtr)(pVideo->thisCard))->tag, - pATI->LinearBase, pATI->LinearSize); + pATI->pMemory = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER, + Tag, pATI->LinearBase, LinearSize); else - pATI->pMemory = xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, pATI->LinearBase, pATI->LinearSize); + pATI->pMemory = xf86MapVidMem(iScreen, VIDMEM_FRAMEBUFFER, + pATI->LinearBase, LinearSize); if (!pATI->pMemory) { - ATIUnmapVGA(pScreenInfo, pATI); + +#ifndef AVOID_CPIO + + ATIUnmapVGA(iScreen, pATI); + +#endif /* AVOID_CPIO */ + + pATI->Mapped = FALSE; return FALSE; } + + pATI->Mapped = TRUE; } /* Map MMIO aperture */ if (pATI->Block0Base) { - if ((pATI->Block0Base >= pATI->LinearBase) && - ((pATI->Block0Base + 0x00000400U) <= - (pATI->LinearBase + pATI->LinearSize))) - { - pATI->pBlock[0] = (char *)pATI->pMemory + - (pATI->Block0Base - pATI->LinearBase); - } + if (pVideo) + pATI->pMMIO = xf86MapPciMem(iScreen, VIDMEM_MMIO, + Tag, MMIOBase, PageSize); else + pATI->pMMIO = xf86MapVidMem(iScreen, VIDMEM_MMIO, + MMIOBase, PageSize); + + if (!pATI->pMMIO) { - if (pVideo && - ((pATI->Block0Base < 0x000A0000U) || - (pATI->Block0Base > (0x000B0000U - 0x00000400U)))) - pATI->pMMIO = xf86MapPciMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, ((pciConfigPtr)(pVideo->thisCard))->tag, - pATI->MMIOBase, pATI->PageSize); - else - pATI->pMMIO = xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, pATI->MMIOBase, pATI->PageSize); - - if (!pATI->pMMIO) - { - ATIUnmapLinear(pScreenInfo, pATI); - ATIUnmapVGA(pScreenInfo, pATI); - return FALSE; - } + ATIUnmapLinear(iScreen, pATI); + +#ifndef AVOID_CPIO + + ATIUnmapVGA(iScreen, pATI); - pATI->pBlock[0] = (char *)pATI->pMMIO + - (pATI->Block0Base - pATI->MMIOBase); +#endif /* AVOID_CPIO */ + + pATI->Mapped = FALSE; + return FALSE; } + pATI->Mapped = TRUE; + + pATI->pBlock[0] = (char *)pATI->pMMIO + + (pATI->Block0Base - MMIOBase); + if (pATI->Block1Base) pATI->pBlock[1] = (char *)pATI->pBlock[0] - 0x00000400U; } - pATI->Mapped = TRUE; return TRUE; } @@ -226,8 +286,8 @@ void ATIUnmapApertures ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (!pATI->Mapped) @@ -235,11 +295,16 @@ pATI->Mapped = FALSE; /* Unmap MMIO area */ - ATIUnmapMMIO(pScreenInfo, pATI); + ATIUnmapMMIO(iScreen, pATI); /* Unmap linear aperture */ - ATIUnmapLinear(pScreenInfo, pATI); + ATIUnmapLinear(iScreen, pATI); + +#ifndef AVOID_CPIO /* Unmap VGA aperture */ - ATIUnmapVGA(pScreenInfo, pATI); + ATIUnmapVGA(iScreen, pATI); + +#endif /* AVOID_CPIO */ + } Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h:1.5 Fri Feb 18 07:19:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h,v 1.5 2000/02/18 12:19:45 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h,v 1.6 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,7 +26,6 @@ #include "atiproto.h" #include "atipriv.h" -#include "xf86str.h" /* Memory types for 68800's and 88800GX's */ typedef enum @@ -70,7 +69,7 @@ } ATI264MemoryType; extern const char *ATIMemoryTypeNames_264xT[]; -extern Bool ATIMapApertures FunctionPrototype((ScrnInfoPtr, ATIPtr)); -extern void ATIUnmapApertures FunctionPrototype((ScrnInfoPtr, ATIPtr)); +extern Bool ATIMapApertures FunctionPrototype((int, ATIPtr)); +extern void ATIUnmapApertures FunctionPrototype((int, ATIPtr)); #endif /* ___ATIVIDMEM_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c:1.8 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c Wed Oct 11 18:52:58 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.8 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.11 2000/10/11 22:52:58 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -50,10 +50,13 @@ * accessed at indices 0xB0 through 0xBF on all chipsets. */ +#include "ati.h" #include "atichip.h" -#include "atiio.h" #include "atiwonder.h" +#include "atiwonderio.h" +#ifndef AVOID_CPIO + /* * ATIVGAWonderPreInit -- * @@ -296,3 +299,5 @@ ATIModifyExtReg(pATI, 0xBAU, -1, 0x00U, pATIHW->ba); ATIModifyExtReg(pATI, 0xBDU, -1, 0x00U, pATIHW->bd); } + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h diff -u xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h:1.5 Mon Jun 19 11:00:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h Fri Aug 4 17:07:16 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.5 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.6 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,12 +26,17 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" +#ifndef AVOID_CPIO + extern void ATIVGAWonderPreInit FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGAWonderSave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGAWonderCalculate FunctionPrototype((ATIPtr, ATIHWPtr, DisplayModePtr)); extern void ATIVGAWonderSet FunctionPrototype((ATIPtr, ATIHWPtr)); + +#endif /* AVOID_CPIO */ #endif /* ___ATIWONDER_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c:1.1 --- /dev/null Mon Dec 18 14:30:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c Wed Oct 11 18:52:59 2000 @@ -0,0 +1,86 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.c,v 1.1 2000/10/11 22:52:59 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atichip.h" +#include "atiwonderio.h" + +#ifndef AVOID_CPIO + +/* + * ATIModifyExtReg -- + * + * This function is called to modify certain bits in an ATI extended VGA + * register while preserving its other bits. The function will not write the + * register if it turns out its value would not change. This helps prevent + * server hangs on older adapters. + */ +void +ATIModifyExtReg +( + ATIPtr pATI, + const CARD8 Index, + int CurrentValue, + const CARD8 CurrentMask, + CARD8 NewValue +) +{ + /* Possibly retrieve the current value */ + if (CurrentValue < 0) + CurrentValue = ATIGetExtReg(Index); + + /* Compute new value */ + NewValue &= (CARD8)(~CurrentMask); + NewValue |= CurrentValue & CurrentMask; + + /* Check if value will be changed */ + if (CurrentValue == NewValue) + return; + + /* + * The following is taken from ATI's VGA Wonder programmer's reference + * manual which says that this is needed to "ensure the proper state of the + * 8/16 bit ROM toggle". I suspect a timing glitch appeared in the 18800 + * after its die was cast. 18800-1 and later chips do not exhibit this + * problem. + */ + if ((pATI->Chip <= ATI_CHIP_18800) && (Index == 0xB2U) && + ((NewValue ^ 0x40U) & CurrentValue & 0x40U)) + { + CARD8 misc = inb(R_GENMO); + CARD8 bb = ATIGetExtReg(0xBBU); + + outb(GENMO, (misc & 0xF3U) | 0x04U | ((bb & 0x10U) >> 1)); + CurrentValue &= (CARD8)(~0x40U); + ATIPutExtReg(0xB2U, CurrentValue); + ATIDelay(5); + outb(GENMO, misc); + ATIDelay(5); + if (CurrentValue != NewValue) + ATIPutExtReg(0xB2U, NewValue); + } + else + ATIPutExtReg(Index, NewValue); +} + +#endif /* AVOID_CPIO */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h:1.1 --- /dev/null Mon Dec 18 14:30:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h Wed Oct 11 18:52:59 2000 @@ -0,0 +1,48 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonderio.h,v 1.1 2000/10/11 22:52:59 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATIWONDERIO_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atiwonderio.h" +# undef XFree86Module +#endif + +#define ___ATIWONDERIO_H___ 1 + +#include "atistruct.h" +#include "ativgaio.h" + +#ifndef AVOID_CPIO + +extern void ATIModifyExtReg FunctionPrototype((ATIPtr, const CARD8, int, + const CARD8, CARD8)); + +#define ATIGetExtReg(_Index) \ + GetReg(pATI->CPIO_VGAWonder, _Index) +#define ATIPutExtReg(_Index, _Value) \ + PutReg(pATI->CPIO_VGAWonder, _Index, _Value) + +#endif /* AVOID_CPIO */ + +#endif /* ___ATIWONDERIO_H___ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp:1.3 --- /dev/null Mon Dec 18 14:30:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp Mon Dec 11 15:18:07 2000 @@ -0,0 +1,75 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.cpp,v 1.3 2000/12/11 20:18:07 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH R128 __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +r128 \- ATI Rage 128 video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qr128\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B r128 +is an XFree86 driver for ATI Rage 128 based video cards. It contains +full support for 8, 15, 16 and 24 bit pixel depths, hardware +acceleration of drawing primitives, hardware cursor, video modes up to +1800x1440 @ 70Hz, doublescan modes (e.g., 320x200 and 320x240), gamma +correction at all pixel depths, a fully programming dot clock and robust +text mode restoration for VT switching. +.SH SUPPORTED HARDWARE +The +.B r128 +driver supports all ATI Rage 128 based video cards including the Rage +Fury AGP 32MB, the XPERT 128 AGP 16MB and the XPERT 99 AGP 8MB. +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The driver auto-detects all device information necessary to initialize +the card. However, if you have problems with auto-detection, you can +specify: +.PP +.RS 4 +VideoRam - in kilobytes +.br +MemBase - physical address of the linear framebuffer +.br +IOBase - physical address of the MMIO registers +.br +ChipID - PCI DEVICE ID +.RE +.PP +In addition, the following driver +.B Options +are supported: +.TP +.BI "Option \*qSWcursor\*q \*q" boolean \*q +Selects software cursor. The default is +.B off. +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Enables or disables all hardware acceleration. The default is to +.B enable +hardware acceleration. +.TP +.BI "Option \*qDac6Bit\*q \*q" boolean \*q +Enables or disables the use of 6 bits per color component when in 8 bpp +mode (emulates VGA mode). By default, all 8 bits per color component +are used. The default is +.B off. +.TP +.BI "Option \*qVideoKey\*q \*q" integer \*q +This overrides the default pixel value for the YUV video overlay key. +The default value is +.B undefined. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +.nf +Rickard E. (Rik) Faith \fIfaith@precisioninsight.com\fP +Kevin E. Martin \fIkevin@precisioninsight.com\fP Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h:1.8 --- /dev/null Mon Dec 18 14:30:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h Fri Dec 8 14:15:33 2000 @@ -0,0 +1,435 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h,v 1.8 2000/12/08 19:15:33 martin Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * + */ + +#ifndef _R128_H_ +#define _R128_H_ + +#include "xf86str.h" + + /* PCI support */ +#include "xf86Pci.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xf86Cursor.h" + + /* Xv support */ +#include "xf86xv.h" + + /* DRI support */ +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dripriv.h" +#include "dri.h" +#include "GL/glxint.h" +#endif + +#define R128_DEBUG 0 /* Turn off debugging output */ +#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ +#define R128_MMIOSIZE 0x80000 + +#define R128_VBIOS_SIZE 0x00010000 + +#if R128_DEBUG +#define R128TRACE(x) \ + do { \ + ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ + ErrorF x; \ + } while (0); +#else +#define R128TRACE(x) +#endif + + +/* Other macros */ +#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) +#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate) + +typedef struct { /* All values in XCLKS */ + int ML; /* Memory Read Latency */ + int MB; /* Memory Burst Length */ + int Trcd; /* RAS to CAS delay */ + int Trp; /* RAS percentage */ + int Twr; /* Write Recovery */ + int CL; /* CAS Latency */ + int Tr2w; /* Read to Write Delay */ + int Rloop; /* Loop Latency */ + int Rloop_fudge; /* Add to ML to get Rloop */ + char *name; +} R128RAMRec, *R128RAMPtr; + +typedef struct { + /* Common registers */ + CARD32 ovr_clr; + CARD32 ovr_wid_left_right; + CARD32 ovr_wid_top_bottom; + CARD32 ov0_scale_cntl; + CARD32 mpp_tb_config; + CARD32 mpp_gp_config; + CARD32 subpic_cntl; + CARD32 viph_control; + CARD32 i2c_cntl_1; + CARD32 gen_int_cntl; + CARD32 cap0_trig_cntl; + CARD32 cap1_trig_cntl; + CARD32 bus_cntl; + CARD32 config_cntl; + + /* Other registers to save for VT switches */ + CARD32 dp_datatype; + CARD32 gen_reset_cntl; + CARD32 clock_cntl_index; + CARD32 amcgpio_en_reg; + CARD32 amcgpio_mask; + + /* CRTC registers */ + CARD32 crtc_gen_cntl; + CARD32 crtc_ext_cntl; + CARD32 dac_cntl; + CARD32 crtc_h_total_disp; + CARD32 crtc_h_sync_strt_wid; + CARD32 crtc_v_total_disp; + CARD32 crtc_v_sync_strt_wid; + CARD32 crtc_offset; + CARD32 crtc_offset_cntl; + CARD32 crtc_pitch; + + /* CRTC2 registers */ + CARD32 crtc2_gen_cntl; + + /* Flat panel registers */ + CARD32 fp_crtc_h_total_disp; + CARD32 fp_crtc_v_total_disp; + CARD32 fp_gen_cntl; + CARD32 fp_h_sync_strt_wid; + CARD32 fp_horz_stretch; + CARD32 fp_panel_cntl; + CARD32 fp_v_sync_strt_wid; + CARD32 fp_vert_stretch; + CARD32 lvds_gen_cntl; + CARD32 tmds_crc; + + /* Computed values for PLL */ + CARD32 dot_clock_freq; + CARD32 pll_output_freq; + int feedback_div; + int post_div; + + /* PLL registers */ + CARD32 ppll_ref_div; + CARD32 ppll_div_3; + CARD32 htotal_cntl; + + /* DDA register */ + CARD32 dda_config; + CARD32 dda_on_off; + + /* Pallet */ + Bool palette_valid; + CARD32 palette[256]; +} R128SaveRec, *R128SavePtr; + +typedef struct { + CARD16 reference_freq; + CARD16 reference_div; + CARD32 min_pll_freq; + CARD32 max_pll_freq; + CARD16 xclk; +} R128PLLRec, *R128PLLPtr; + +typedef struct { + int bitsPerPixel; + int depth; + int displayWidth; + int pixel_code; + int pixel_bytes; + DisplayModePtr mode; +} R128FBLayout; + +typedef struct { + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + int Chipset; + Bool Primary; + + Bool FBDev; + + unsigned long LinearAddr; /* Frame buffer physical address */ + unsigned long MMIOAddr; /* MMIO region physical address */ + unsigned long BIOSAddr; /* BIOS physical address */ + Bool BIOSFromPCI; /* BIOS is read from PCI space */ + + unsigned char *MMIO; /* Map of MMIO region */ + unsigned char *FB; /* Map of frame buffer */ + + CARD32 MemCntl; + CARD32 BusCntl; + unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + int Flags; /* Saved copy of mode flags */ + + Bool HasPanelRegs; /* Current chip can connect to a FP */ + Bool CRTOnly; /* Only use External CRT instead of FP */ + CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */ + int FPBIOSstart; /* Start of the flat panel info */ + + /* Computed values for FPs */ + int PanelXRes; + int PanelYRes; + int PanelPwrDly; + + R128PLLRec pll; + R128RAMPtr ram; + + R128SaveRec SavedReg; /* Original (text) mode */ + R128SaveRec ModeReg; /* Current mode */ + Bool (*CloseScreen)(int, ScreenPtr); + void (*BlockHandler)(int, pointer, pointer, pointer); + + Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ + + XAAInfoRecPtr accel; + Bool accelOn; + xf86CursorInfoPtr cursor; + unsigned long cursor_start; + unsigned long cursor_end; + + int fifo_slots; /* Free slots in the FIFO (64 max) */ + int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ + Bool dac6bits; /* Use 6 bit DAC? */ + + /* Computed values for Rage 128 */ + int pitch; + int datatype; + CARD32 dp_gui_master_cntl; + + /* Saved values for ScreenToScreenCopy */ + int xdir; + int ydir; + + /* ScanlineScreenToScreenColorExpand support */ + unsigned char *scratch_buffer[1]; + unsigned char *scratch_save; + int scanline_x; + int scanline_y; + int scanline_h; + int scanline_h_w; + int scanline_words; + int scanline_direct; + int scanline_bpp; /* Only used for ImageWrite */ + + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; + + R128FBLayout CurrentLayout; +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig *pVisualConfigs; + R128ConfigPrivPtr pVisualConfigsPriv; + + drmHandle fbHandle; + + drmSize registerSize; + drmHandle registerHandle; + + Bool IsPCI; /* Current card is a PCI card */ + + drmSize agpSize; + drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ + unsigned long agpOffset; + unsigned char *AGP; /* Map */ + int agpMode; + + Bool CCEInUse; /* CCE is currently active */ + int CCEMode; /* CCE mode that server/clients use */ + int CCEFifoSize; /* Size of the CCE command FIFO */ + Bool CCESecure; /* CCE security enabled */ + int CCEusecTimeout; /* CCE timeout in usecs */ + Bool CCE2D; /* CCE is used for X server 2D prims */ + + /* CCE ring buffer data */ + unsigned long ringStart; /* Offset into AGP space */ + drmHandle ringHandle; /* Handle from drmAddMap */ + drmSize ringMapSize; /* Size of map */ + int ringSize; /* Size of ring (in MB) */ + unsigned char *ring; /* Map */ + int ringSizeLog2QW; + + unsigned long ringReadOffset; /* Offset into AGP space */ + drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ + drmSize ringReadMapSize; /* Size of map */ + unsigned char *ringReadPtr; /* Map */ + + /* CCE vertex/indirect buffer data */ + unsigned long bufStart; /* Offset into AGP space */ + drmHandle bufHandle; /* Handle from drmAddMap */ + drmSize bufMapSize; /* Size of map */ + int bufSize; /* Size of buffers (in MB) */ + unsigned char *buf; /* Map */ + int bufNumBufs; /* Number of buffers */ + drmBufMapPtr buffers; /* Buffer map */ + + /* CCE AGP Texture data */ + unsigned long agpTexStart; /* Offset into AGP space */ + drmHandle agpTexHandle; /* Handle from drmAddMap */ + drmSize agpTexMapSize; /* Size of map */ + int agpTexSize; /* Size of AGP tex space (in MB) */ + unsigned char *agpTex; /* Map */ + int log2AGPTexGran; + + /* DRI screen private data */ + int fbX; + int fbY; + int backX; + int backY; + int depthX; + int depthY; + + int frontOffset; + int frontPitch; + int backOffset; + int backPitch; + int depthOffset; + int depthPitch; + int spanOffset; + int textureOffset; + int textureSize; + int log2TexGran; + + /* Saved scissor values */ + CARD32 sc_left; + CARD32 sc_right; + CARD32 sc_top; + CARD32 sc_bottom; + CARD32 aux_sc_cntl; +#endif + + XF86VideoAdaptorPtr adaptor; + void (*VideoTimerCallback)(ScrnInfoPtr, Time); + int videoKey; + Bool showCache; +} R128InfoRec, *R128InfoPtr; + +#define R128WaitForFifo(pScrn, entries) \ +do { \ + if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ + info->fifo_slots -= entries; \ +} while (0) + +extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); +extern void R128WaitForIdle(ScrnInfoPtr pScrn); +extern void R128EngineReset(ScrnInfoPtr pScrn); +extern void R128EngineFlush(ScrnInfoPtr pScrn); + +extern unsigned R128INPLL(ScrnInfoPtr pScrn, int addr); +extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); + +extern Bool R128AccelInit(ScreenPtr pScreen); +extern void R128EngineInit(ScrnInfoPtr pScrn); +extern Bool R128CursorInit(ScreenPtr pScreen); +extern Bool R128DGAInit(ScreenPtr pScreen); + +extern int R128MinBits(int val); + +extern void R128InitVideo(ScreenPtr pScreen); + +#ifdef XF86DRI +extern Bool R128DRIScreenInit(ScreenPtr pScreen); +extern void R128DRICloseScreen(ScreenPtr pScreen); +extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen); + +#define R128CCE_START(pScrn, info) \ +do { \ + int _ret = drmR128StartCCE(info->drmFD); \ + if (_ret) { \ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "%s: CCE start %d\n", __FUNCTION__, _ret); \ + } \ + info->CCEInUse = TRUE; \ +} while (0) + +#define R128CCE_STOP(pScrn, info) \ +do { \ + int _ret = drmR128StopCCE(info->drmFD); \ + if (_ret) { \ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "%s: CCE stop %d\n", __FUNCTION__, _ret); \ + } \ + info->CCEInUse = FALSE; \ +} while (0) + +#define R128CCE_RESET(pScrn, info) \ +do { \ + if (R128CCE_USE_RING_BUFFER(info->CCEMode)) { \ + int _ret = drmR128ResetCCE(info->drmFD); \ + if (_ret) { \ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "%s: CCE reset %d\n", __FUNCTION__, _ret); \ + } \ + } \ + info->CCEInUse = FALSE; \ +} while (0) + +#define R128CCE_TO_MMIO(pScrn, info) \ +do { \ + if (info->CCEInUse) { \ + R128CCE_STOP(pScrn, info); \ + \ + R128WaitForFifo(pScrn, 5); \ + OUTREG(R128_SC_LEFT, info->sc_left); \ + OUTREG(R128_SC_RIGHT, info->sc_right); \ + OUTREG(R128_SC_TOP, info->sc_top); \ + OUTREG(R128_SC_BOTTOM, info->sc_bottom); \ + OUTREG(R128_AUX_SC_CNTL, info->aux_sc_cntl); \ + } \ +} while (0) + +#define R128MMIO_TO_CCE(pScrn, info) \ +do { \ + if (!info->CCEInUse) { \ + R128CCE_START(pScrn, info); \ + } \ +} while (0) +#endif + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c:1.4 --- /dev/null Mon Dec 18 14:30:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c Mon Dec 4 14:21:52 2000 @@ -0,0 +1,1195 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_accel.c,v 1.4 2000/12/04 19:21:52 dawes Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * Credits: + * + * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for + * providing source code to their 3.3.x Rage 128 driver. Portions of + * this file are based on the acceleration code for that driver. + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * Notes on unimplemented XAA optimizations: + * + * SetClipping: The Rage128 doesn't support the full 16bit registers needed + * for XAA clip rect support. + * SolidFillTrap: This will probably work if we can compute the correct + * Bresenham error values. + * TwoPointLine: The Rage 128 supports Bresenham lines instead. + * DashedLine with non-power-of-two pattern length: Apparently, there is + * no way to set the length of the pattern -- it is always + * assumed to be 8 or 32 (or 1024?). + * ScreenToScreenColorExpandFill: See p. 4-17 of the Technical Reference + * Manual where it states that monochrome expansion of frame + * buffer data is not supported. + * CPUToScreenColorExpandFill, direct: The implementation here uses a hybrid + * direct/indirect method. If we had more data registers, + * then we could do better. If XAA supported a trigger write + * address, the code would be simpler. + * (Alan Hourihane) Update. We now use purely indirect and clip the full + * rectangle. Seems as the direct method has some problems + * with this, although this indirect method is much faster + * than the old method of setting up the engine per scanline. + * This code was the basis of the Radeon work we did. + * Color8x8PatternFill: Apparently, an 8x8 color brush cannot take an 8x8 + * pattern from frame buffer memory. + * ImageWrites: See CPUToScreenColorExpandFill. + * + */ + +#define R128_IMAGEWRITE 0 /* Disable ImageWrites - faster in software */ +#define R128_TRAPEZOIDS 0 /* Trapezoids don't work */ + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dri.h" +#endif + + /* Line support */ +#include "miline.h" + + /* X and server generic header files */ +#include "xf86.h" + +static struct { + int rop; + int pattern; +} R128_ROP[] = { + { R128_ROP3_ZERO, R128_ROP3_ZERO }, /* GXclear */ + { R128_ROP3_DSa, R128_ROP3_DPa }, /* Gxand */ + { R128_ROP3_SDna, R128_ROP3_PDna }, /* GXandReverse */ + { R128_ROP3_S, R128_ROP3_P }, /* GXcopy */ + { R128_ROP3_DSna, R128_ROP3_DPna }, /* GXandInverted */ + { R128_ROP3_D, R128_ROP3_D }, /* GXnoop */ + { R128_ROP3_DSx, R128_ROP3_DPx }, /* GXxor */ + { R128_ROP3_DSo, R128_ROP3_DPo }, /* GXor */ + { R128_ROP3_DSon, R128_ROP3_DPon }, /* GXnor */ + { R128_ROP3_DSxn, R128_ROP3_PDxn }, /* GXequiv */ + { R128_ROP3_Dn, R128_ROP3_Dn }, /* GXinvert */ + { R128_ROP3_SDno, R128_ROP3_PDno }, /* GXorReverse */ + { R128_ROP3_Sn, R128_ROP3_Pn }, /* GXcopyInverted */ + { R128_ROP3_DSno, R128_ROP3_DPno }, /* GXorInverted */ + { R128_ROP3_DSan, R128_ROP3_DPan }, /* GXnand */ + { R128_ROP3_ONE, R128_ROP3_ONE } /* GXset */ +}; + +/* Flush all dirty data in the Pixel Cache to memory. */ +void R128EngineFlush(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + OUTREGP(R128_PC_NGUI_CTLSTAT, R128_PC_FLUSH_ALL, ~R128_PC_FLUSH_ALL); + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) break; + } +} + +/* Reset graphics card to known state. */ +void R128EngineReset(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 clock_cntl_index; + CARD32 mclk_cntl; + CARD32 gen_reset_cntl; + + R128EngineFlush(pScrn); + + clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); + mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL); + + OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP); + + gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); + + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); + INREG(R128_GEN_RESET_CNTL); + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); + INREG(R128_GEN_RESET_CNTL); + + OUTPLL(R128_MCLK_CNTL, mclk_cntl); + OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index); + OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl); +} + +/* The FIFO has 64 slots. This routines waits until at least `entries' of + these slots are empty. */ +void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + info->fifo_slots = INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; + if (info->fifo_slots >= entries) return; + } + R128TRACE(("FIFO timed out: %d entries, stat=0x%08x, probe=0x%08x\n", + INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, + INREG(R128_GUI_STAT), + INREG(R128_GUI_PROBE))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FIFO timed out, resetting engine...\n"); + R128EngineReset(pScrn); +#ifdef XF86DRI + R128CCE_RESET(pScrn, info); + if (info->CCE2D) { + R128CCE_START(pScrn, info); + } +#endif + } +} + +/* Wait for the graphics engine to be completely idle: the FIFO has + drained, the Pixel Cache is flushed, and the engine is idle. This is a + standard "sync" function that will make the hardware "quiescent". */ +void R128WaitForIdle(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + R128WaitForFifoFunction(pScrn, 64); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_GUI_STAT) & R128_GUI_ACTIVE)) { + R128EngineFlush(pScrn); + return; + } + } + R128TRACE(("Idle timed out: %d entries, stat=0x%08x, probe=0x%08x\n", + INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, + INREG(R128_GUI_STAT), + INREG(R128_GUI_PROBE))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Idle timed out, resetting engine...\n"); + R128EngineReset(pScrn); +#ifdef XF86DRI + R128CCE_RESET(pScrn, info); + if (info->CCE2D) { + R128CCE_START(pScrn, info); + } +#endif + } +} + +#ifdef XF86DRI +/* Wait until the CCE is completely idle: the FIFO has drained and the + * CCE is idle. + */ +static void R128CCEWaitForIdle(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + int ret; + int i = 0; + + for (;;) { + do { + ret = drmR128WaitForIdleCCE(info->drmFD); + if (ret && ret != -EBUSY) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "%s: CCE idle %d\n", __FUNCTION__, ret); + } + } while ((ret == -EBUSY) && (i++ < R128_TIMEOUT)); + + if (ret == 0) return; + + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Idle timed out, resetting engine...\n"); + R128EngineReset(pScrn); + + /* Always restart the engine when doing CCE 2D acceleration */ + R128CCE_RESET(pScrn, info); + R128CCE_START(pScrn, info); + } +} +#endif + +/* Setup for XAA SolidFill. */ +static void R128SetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].pattern)); + OUTREG(R128_DP_BRUSH_FRGD_CLR, color); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT + | R128_DST_Y_TOP_TO_BOTTOM)); +} + +/* Subsequent XAA SolidFillRect. + + Tests: xtest CH06/fllrctngl, xterm +*/ +static void R128SubsequentSolidFillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_WIDTH_HEIGHT, (w << 16) | h); +} + +/* Setup for XAA solid lines. */ +static void R128SetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].pattern)); + OUTREG(R128_DP_BRUSH_FRGD_CLR, color); + OUTREG(R128_DP_WRITE_MASK, planemask); +} + + +/* Subsequent XAA solid Bresenham line. + + Tests: xtest CH06/drwln, ico, Mark Vojkovich's linetest program + + [See http://www.xfree86.org/devel/archives/devel/1999-Jun/0102.shtml for + Mark Vojkovich's linetest program, posted 2Jun99 to devel@xfree86.org.] + + x11perf -line500 + 1024x768@76Hz 1024x768@76Hz + 8bpp 32bpp + not used: 39700.0/sec 34100.0/sec + used: 47600.0/sec 36800.0/sec +*/ +static void R128SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, + int x, int y, + int major, int minor, + int err, int len, int octant) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; + if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; + if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; + + R128WaitForFifo(pScrn, 6); + OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_BRES_ERR, err); + OUTREG(R128_DST_BRES_INC, minor); + OUTREG(R128_DST_BRES_DEC, -major); + OUTREG(R128_DST_BRES_LNTH, len); +} + +/* Subsequent XAA solid horizontal and vertical lines + + 1024x768@76Hz 8bpp + Without With + x11perf -hseg500 87600.0/sec 798000.0/sec + x11perf -vseg500 38100.0/sec 38000.0/sec +*/ +static void R128SubsequentSolidHorVertLine(ScrnInfoPtr pScrn, + int x, int y, int len, int dir ) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 1); + OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT + | R128_DST_Y_TOP_TO_BOTTOM)); + + if (dir == DEGREES_0) { + R128SubsequentSolidFillRect(pScrn, x, y, len, 1); + } else { + R128SubsequentSolidFillRect(pScrn, x, y, 1, len); + } +} + +/* Setup for XAA dashed lines. + + Tests: xtest CH05/stdshs, XFree86/drwln + + NOTE: Since we can only accelerate lines with power-of-2 patterns of + length <= 32, these x11perf numbers are not representative of the + speed-up on appropriately-sized patterns. + + 1024x768@76Hz 8bpp + Without With + x11perf -dseg100 218000.0/sec 222000.0/sec + x11perf -dline100 215000.0/sec 221000.0/sec + x11perf -ddline100 178000.0/sec 180000.0/sec +*/ +static void R128SetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask, + int length, unsigned char *pattern) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 pat = *(CARD32 *)pattern; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + switch (length) { + case 2: pat |= pat << 2; /* fall through */ + case 4: pat |= pat << 4; /* fall through */ + case 8: pat |= pat << 8; /* fall through */ + case 16: pat |= pat << 16; + } + + R128WaitForFifo(pScrn, 5); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? R128_GMC_BRUSH_32x1_MONO_FG_LA + : R128_GMC_BRUSH_32x1_MONO_FG_BG) + | R128_ROP[rop].pattern + | R128_GMC_BYTE_LSB_TO_MSB)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); + OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); + OUTREG(R128_BRUSH_DATA0, pat); +} + +/* Subsequent XAA dashed line. */ +static void R128SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, + int x, int y, + int major, int minor, + int err, int len, int octant, + int phase) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; + if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; + if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; + + R128WaitForFifo(pScrn, 7); + OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_BRUSH_Y_X, (phase << 16) | phase); + OUTREG(R128_DST_BRES_ERR, err); + OUTREG(R128_DST_BRES_INC, minor); + OUTREG(R128_DST_BRES_DEC, -major); + OUTREG(R128_DST_BRES_LNTH, len); +} + +#if R128_TRAPEZOIDS + /* This doesn't work. Except in the + lower-left quadrant, all of the pixel + errors appear to be because eL and eR + are not correct. Drawing from right to + left doesn't help. Be aware that the + non-_SUB registers set the sub-pixel + values to 0.5 (0x08), which isn't what + XAA wants. */ +/* Subsequent XAA SolidFillTrap. XAA always passes data that assumes we + fill from top to bottom, so dyL and dyR are always non-negative. */ +static void R128SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, + int left, int dxL, int dyL, int eL, + int right, int dxR, int dyR, int eR) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int flags = 0; + int Lymajor = 0; + int Rymajor = 0; + int origdxL = dxL; + int origdxR = dxR; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128TRACE(("Trap %d %d; L %d %d %d %d; R %d %d %d %d\n", + y, h, + left, dxL, dyL, eL, + right, dxR, dyR, eR)); + + if (dxL < 0) dxL = -dxL; else flags |= (1 << 0) /* | (1 << 8) */; + if (dxR < 0) dxR = -dxR; else flags |= (1 << 6); + + R128WaitForFifo(pScrn, 11); + +#if 1 + OUTREG(R128_DP_CNTL, flags | (1 << 1) | (1 << 7)); + OUTREG(R128_DST_Y_SUB, ((y) << 4) | 0x0 ); + OUTREG(R128_DST_X_SUB, ((left) << 4)|0x0); + OUTREG(R128_TRAIL_BRES_ERR, eR-dxR); + OUTREG(R128_TRAIL_BRES_INC, dxR); + OUTREG(R128_TRAIL_BRES_DEC, -dyR); + OUTREG(R128_TRAIL_X_SUB, ((right) << 4) | 0x0); + OUTREG(R128_LEAD_BRES_ERR, eL-dxL); + OUTREG(R128_LEAD_BRES_INC, dxL); + OUTREG(R128_LEAD_BRES_DEC, -dyL); + OUTREG(R128_LEAD_BRES_LNTH_SUB, ((h) << 4) | 0x00); +#else + OUTREG(R128_DP_CNTL, flags | (1 << 1) ); + OUTREG(R128_DST_Y_SUB, (y << 4)); + OUTREG(R128_DST_X_SUB, (right << 4)); + OUTREG(R128_TRAIL_BRES_ERR, eL); + OUTREG(R128_TRAIL_BRES_INC, dxL); + OUTREG(R128_TRAIL_BRES_DEC, -dyL); + OUTREG(R128_TRAIL_X_SUB, (left << 4) | 0); + OUTREG(R128_LEAD_BRES_ERR, eR); + OUTREG(R128_LEAD_BRES_INC, dxR); + OUTREG(R128_LEAD_BRES_DEC, -dyR); + OUTREG(R128_LEAD_BRES_LNTH_SUB, h << 4); +#endif +} +#endif + +/* Setup for XAA screen-to-screen copy. + + Tests: xtest CH06/fllrctngl (also tests transparency). +*/ +static void R128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, + int xdir, int ydir, int rop, + unsigned int planemask, + int trans_color) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + info->xdir = xdir; + info->ydir = ydir; + R128WaitForFifo(pScrn, 3); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_DP_SRC_SOURCE_MEMORY)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_CNTL, ((xdir >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) + | (ydir >= 0 + ? R128_DST_Y_TOP_TO_BOTTOM + : 0))); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA screen-to-screen copy. */ +static void R128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (info->xdir < 0) xa += w - 1, xb += w - 1; + if (info->ydir < 0) ya += h - 1, yb += h - 1; + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_SRC_Y_X, (ya << 16) | xa); + OUTREG(R128_DST_Y_X, (yb << 16) | xb); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +/* Setup for XAA mono 8x8 pattern color expansion. Patterns with + transparency use `bg == -1'. This routine is only used if the XAA + pixmap cache is turned on. + + Tests: xtest XFree86/fllrctngl (no other test will test this routine with + both transparency and non-transparency) + + 1024x768@76Hz 8bpp + Without With + x11perf -srect100 38600.0/sec 85700.0/sec + x11perf -osrect100 38600.0/sec 85700.0/sec +*/ +static void R128SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int patternx, int patterny, + int fg, int bg, int rop, + unsigned int planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 6); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? R128_GMC_BRUSH_8X8_MONO_FG_LA + : R128_GMC_BRUSH_8X8_MONO_FG_BG) + | R128_ROP[rop].pattern + | R128_GMC_BYTE_LSB_TO_MSB)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); + OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); + OUTREG(R128_BRUSH_DATA0, patternx); + OUTREG(R128_BRUSH_DATA1, patterny); +} + +/* Subsequent XAA 8x8 pattern color expansion. Because they are used in + the setup function, `patternx' and `patterny' are not used here. */ +static void R128SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int patternx, int patterny, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 3); + OUTREG(R128_BRUSH_Y_X, (patterny << 8) | patternx); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +#if 0 +/* Setup for XAA color 8x8 pattern fill. + + Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off) +*/ +static void R128SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, + int patx, int paty, + int rop, unsigned int planemask, + int trans_color) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128TRACE(("Color8x8 %d %d %d\n", trans_color, patx, paty)); + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_8x8_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_DP_SRC_SOURCE_MEMORY)); + OUTREG(R128_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA 8x8 pattern color expansion. */ +static void R128SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128TRACE(("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h)); + R128WaitForFifo(pScrn, 3); + OUTREG(R128_SRC_Y_X, (paty << 16) | patx); + OUTREG(R128_DST_Y_X, (y << 16) | x); + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); +} +#endif + +/* Setup for XAA indirect CPU-to-screen color expansion (indirect). + Because of how the scratch buffer is initialized, this is really a + mainstore-to-screen color expansion. Transparency is supported when `bg + == -1'. + + x11perf -ftext (pure indirect): + 1024x768@76Hz 1024x768@76Hz + 8bpp 32bpp + not used: 685000.0/sec 794000.0/sec + used: 1070000.0/sec 1080000.0/sec + + We could improve this indirect routine by about 10% if the hardware + could accept DWORD padded scanlines, or if XAA could provide bit-packed + data. We might also be able to move to a direct routine if there were + more HOST_DATA registers. + + Implementing the hybrid indirect/direct scheme improved performance in a + few areas: + + 1024x768@76 8bpp + Indirect Hybrid + x11perf -oddsrect10 50100.0/sec 71700.0/sec + x11perf -oddsrect100 4240.0/sec 6660.0/sec + x11perf -bigsrect10 50300.0/sec 71100.0/sec + x11perf -bigsrect100 4190.0/sec 6800.0/sec + x11perf -polytext 584000.0/sec 714000.0/sec + x11perf -polytext16 154000.0/sec 172000.0/sec + x11perf -seg1 1780000.0/sec 1880000.0/sec + x11perf -copyplane10 42900.0/sec 58300.0/sec + x11perf -copyplane100 4400.0/sec 6710.0/sec + x11perf -putimagexy10 5090.0/sec 6670.0/sec + x11perf -putimagexy100 424.0/sec 575.0/sec + + 1024x768@76 -depth 24 -fbbpp 32 + Indirect Hybrid + x11perf -oddsrect100 4240.0/sec 6670.0/sec + x11perf -bigsrect100 4190.0/sec 6800.0/sec + x11perf -polytext 585000.0/sec 719000.0/sec + x11perf -seg1 2960000.0/sec 2990000.0/sec + x11perf -copyplane100 4400.0/sec 6700.0/sec + x11perf -putimagexy100 138.0/sec 191.0/sec + +*/ +static void R128SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int + planemask) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_DST_CLIPPING + | R128_GMC_BRUSH_NONE + | (bg == -1 + ? R128_GMC_SRC_DATATYPE_MONO_FG_LA + : R128_GMC_SRC_DATATYPE_MONO_FG_BG) + | R128_ROP[rop].rop + | R128_GMC_BYTE_LSB_TO_MSB + | R128_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(R128_DP_WRITE_MASK, planemask); + OUTREG(R128_DP_SRC_FRGD_CLR, fg); + OUTREG(R128_DP_SRC_BKGD_CLR, bg); +} + +/* Subsequent XAA indirect CPU-to-screen color expansion. This is only + called once for each rectangle. */ +static void R128SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int x1clip = x+skipleft; + int x2clip = x+w; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + info->scanline_h = h; + info->scanline_words = (w + 31) >> 5; + +#if 0 + /* Seems as though the Rage128's doesn't like blitting directly + * as we must be overwriting something too quickly, therefore we + * render to the buffer first and then blit */ + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else +#endif + { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + if (pScrn->bitsPerPixel == 24) { + x1clip *= 3; + x2clip *= 3; + } + + R128WaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(R128_SC_TOP_LEFT, (y << 16) | (x1clip & 0xffff)); + OUTREG(R128_SC_BOTTOM_RIGHT, ((y+h-1) << 16) | ((x2clip-1) & 0xffff)); + OUTREG(R128_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | ((w + 31) & ~31)); +} + +/* Subsequent XAA indirect CPU-to-screen color expandion. This is called + once for each scanline. */ +static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + R128WaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} + +/* Setup for XAA indirect image write. + + 1024x768@76Hz 8bpp + Without With + x11perf -putimage10 37500.0/sec 39300.0/sec + x11perf -putimage100 2150.0/sec 1170.0/sec + x11perf -putimage500 108.0/sec 49.8/sec + */ +#if R128_IMAGEWRITE +static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int trans_color, + int bpp, + int depth) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + info->scanline_bpp = bpp; + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_DST_CLIPPING + | R128_GMC_BRUSH_1X8_COLOR + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP[rop].rop + | R128_GMC_BYTE_LSB_TO_MSB + | R128_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(R128_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + R128WaitForFifo(pScrn, 3); + OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); + OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); + OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR + | R128_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA indirect image write. This is only called once for each + rectangle. */ +static void R128SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int x1clip = x+skipleft; + int x2clip = x+w; + + int shift = 0; /* 32bpp */ + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (pScrn->bitsPerPixel == 8) shift = 3; + else if (pScrn->bitsPerPixel == 16) shift = 1; + + info->scanline_h = h; + info->scanline_words = (w * info->scanline_bpp + 31) >> 5; + +#if 0 + /* Seeing as the CPUToScreen doesn't like this, I've done this + * here too, as it uses pretty much the same path. */ + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else +#endif + { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + if (pScrn->bitsPerPixel == 24) { + x1clip *= 3; + x2clip *= 3; + } + + R128WaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(R128_SC_TOP_LEFT, (y << 16) | (x1clip & 0xffff)); + OUTREG(R128_SC_BOTTOM_RIGHT, ((y+h-1) << 16) | ((x2clip-1) & 0xffff)); + OUTREG(R128_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | ((w + shift) & ~shift)); +} + +/* Subsequent XAA indirect iamge write. This is called once for each + scanline. */ +static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + +#ifdef XF86DRI + R128CCE_TO_MMIO(pScrn, info); +#endif + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + R128WaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + R128WaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} +#endif + +/* Initialize the acceleration hardware. */ +void R128EngineInit(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + R128TRACE(("EngineInit (%d/%d)\n", info->CurrentLayout.pixel_code, info->CurrentLayout.bitsPerPixel)); + + OUTREG(R128_SCALE_3D_CNTL, 0); + R128EngineReset(pScrn); + + switch (info->CurrentLayout.pixel_code) { + case 8: info->datatype = 2; break; + case 15: info->datatype = 3; break; + case 16: info->datatype = 4; break; + case 24: info->datatype = 5; break; + case 32: info->datatype = 6; break; + default: + R128TRACE(("Unknown depth/bpp = %d/%d (code = %d)\n", + info->CurrentLayout.depth, info->CurrentLayout.bitsPerPixel, + info->CurrentLayout.pixel_code)); + } + info->pitch = (info->CurrentLayout.displayWidth / 8) * (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1); + + R128TRACE(("Pitch for acceleration = %d\n", info->pitch)); + + R128WaitForFifo(pScrn, 2); + OUTREG(R128_DEFAULT_OFFSET, 0); + OUTREG(R128_DEFAULT_PITCH, info->pitch); + + R128WaitForFifo(pScrn, 4); + OUTREG(R128_AUX_SC_CNTL, 0); + OUTREG(R128_DEFAULT_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX + | R128_DEFAULT_SC_BOTTOM_MAX)); + OUTREG(R128_SC_TOP_LEFT, 0); + OUTREG(R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX + | R128_DEFAULT_SC_BOTTOM_MAX)); + + info->dp_gui_master_cntl = ((info->datatype << R128_GMC_DST_DATATYPE_SHIFT) + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS); + R128WaitForFifo(pScrn, 1); + OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | R128_GMC_BRUSH_SOLID_COLOR + | R128_GMC_SRC_DATATYPE_COLOR)); + + R128WaitForFifo(pScrn, 8); + OUTREG(R128_DST_BRES_ERR, 0); + OUTREG(R128_DST_BRES_INC, 0); + OUTREG(R128_DST_BRES_DEC, 0); + OUTREG(R128_DP_BRUSH_FRGD_CLR, 0xffffffff); + OUTREG(R128_DP_BRUSH_BKGD_CLR, 0x00000000); + OUTREG(R128_DP_SRC_FRGD_CLR, 0xffffffff); + OUTREG(R128_DP_SRC_BKGD_CLR, 0x00000000); + OUTREG(R128_DP_WRITE_MASK, 0xffffffff); + + R128WaitForFifo(pScrn, 1); +#if X_BYTE_ORDER == X_BIG_ENDIAN + OUTREGP(R128_DP_DATATYPE, + R128_HOST_BIG_ENDIAN_EN, ~R128_HOST_BIG_ENDIAN_EN); +#else + OUTREGP(R128_DP_DATATYPE, 0, ~R128_HOST_BIG_ENDIAN_EN); +#endif + + R128WaitForIdle(pScrn); +} + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CCE to + draw 2D commands */ +static void R128CCEAccelInit(XAAInfoRecPtr a) +{ + a->Flags = 0; + + /* Sync */ + a->Sync = R128CCEWaitForIdle; +} +#endif + +static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + R128InfoPtr info = R128PTR(pScrn); + + a->Flags = (PIXMAP_CACHE + | OFFSCREEN_PIXMAPS + | LINEAR_FRAMEBUFFER); + + /* Sync */ + a->Sync = R128WaitForIdle; + + /* Solid Filled Rectangle */ + a->PolyFillRectSolidFlags = 0; + a->SetupForSolidFill = R128SetupForSolidFill; + a->SubsequentSolidFillRect = R128SubsequentSolidFillRect; + + /* Screen-to-screen Copy */ + /* Transparency uses the wrong colors for + 24 bpp mode -- the transparent part is + correct, but the opaque color is wrong. + This can be seen with netscape's I-bar + cursor when editing in the URL location + box. */ + a->ScreenToScreenCopyFlags = ((pScrn->bitsPerPixel == 24) + ? NO_TRANSPARENCY + : 0); + a->SetupForScreenToScreenCopy = R128SetupForScreenToScreenCopy; + a->SubsequentScreenToScreenCopy = R128SubsequentScreenToScreenCopy; + + /* Mono 8x8 Pattern Fill (Color Expand) */ + a->SetupForMono8x8PatternFill = R128SetupForMono8x8PatternFill; + a->SubsequentMono8x8PatternFillRect = R128SubsequentMono8x8PatternFillRect; + a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST); + + /* Indirect CPU-To-Screen Color Expand */ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#else + a->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + a->NumScanlineColorExpandBuffers = 1; + a->ScanlineColorExpandBuffers = info->scratch_buffer; + info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + + (pScrn->virtualX + * info->CurrentLayout.pixel_bytes)); + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineCPUToScreenColorExpandFill + = R128SetupForScanlineCPUToScreenColorExpandFill; + a->SubsequentScanlineCPUToScreenColorExpandFill + = R128SubsequentScanlineCPUToScreenColorExpandFill; + a->SubsequentColorExpandScanline = R128SubsequentColorExpandScanline; + + /* Bresenham Solid Lines */ + a->SetupForSolidLine = R128SetupForSolidLine; + a->SubsequentSolidBresenhamLine = R128SubsequentSolidBresenhamLine; + a->SubsequentSolidHorVertLine = R128SubsequentSolidHorVertLine; + + /* Bresenham Dashed Lines*/ + a->SetupForDashedLine = R128SetupForDashedLine; + a->SubsequentDashedBresenhamLine = R128SubsequentDashedBresenhamLine; + a->DashPatternMaxLength = 32; + a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED + | LINE_PATTERN_POWER_OF_2_ONLY); + + /* ImageWrite */ +#if R128_IMAGEWRITE + a->NumScanlineImageWriteBuffers = 1; + a->ScanlineImageWriteBuffers = info->scratch_buffer; + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineImageWrite = R128SetupForScanlineImageWrite; + a->SubsequentScanlineImageWriteRect= R128SubsequentScanlineImageWriteRect; + a->SubsequentImageWriteScanline = R128SubsequentImageWriteScanline; + a->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD + /* Performance tests show that we shouldn't use GXcopy for + * uploads as a memcpy is faster */ + | NO_GXCOPY + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X + | SCANLINE_PAD_DWORD; +#endif +} + +/* Initialize XAA for supported acceleration and also initialize the + graphics hardware for acceleration. */ +Bool R128AccelInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + XAAInfoRecPtr a; + + if (!(a = info->accel = XAACreateInfoRec())) return FALSE; + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CCE to + draw 2D commands */ + if (info->CCE2D) R128CCEAccelInit(a); + else +#endif + R128MMIOAccelInit(pScrn, a); + + R128EngineInit(pScrn); + return XAAInit(pScreen, a); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c:1.3 --- /dev/null Mon Dec 18 14:30:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c Sat Nov 18 14:37:10 2000 @@ -0,0 +1,262 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_cursor.c,v 1.3 2000/11/18 19:37:10 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" + + /* X and server generic header files */ +#include "xf86.h" + +#if X_BYTE_ORDER == X_BIG_ENDIAN +#define P_SWAP32( a , b ) \ + ((char *)a)[0] = ((char *)b)[3]; \ + ((char *)a)[1] = ((char *)b)[2]; \ + ((char *)a)[2] = ((char *)b)[1]; \ + ((char *)a)[3] = ((char *)b)[0] + +#define P_SWAP16( a , b ) \ + ((char *)a)[0] = ((char *)b)[1]; \ + ((char *)a)[1] = ((char *)b)[0]; \ + ((char *)a)[2] = ((char *)b)[3]; \ + ((char *)a)[3] = ((char *)b)[2] +#endif + + +/* Set cursor foreground and background colors. */ +static void R128SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_CUR_CLR0, bg); + OUTREG(R128_CUR_CLR1, fg); +} + +/* Set cursor position to (x,y) with offset into cursor bitmap at + (xorigin,yorigin). */ +static void R128SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + xf86CursorInfoPtr cursor = info->cursor; + int xorigin = 0; + int yorigin = 0; + int total_y = pScrn->frameY1 - pScrn->frameY0; + + if (x < 0) xorigin = -x; + if (y < 0) yorigin = -y; + if (y > total_y) y = total_y; + if (info->Flags & V_DBLSCAN) y *= 2; + if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1; + if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1; + + OUTREG(R128_CUR_HORZ_VERT_OFF, R128_CUR_LOCK | (xorigin << 16) | yorigin); + OUTREG(R128_CUR_HORZ_VERT_POSN, (R128_CUR_LOCK + | ((xorigin ? 0 : x) << 16) + | (yorigin ? 0 : y))); + OUTREG(R128_CUR_OFFSET, info->cursor_start + yorigin * 16); +} + +/* Copy cursor image from `image' to video memory. R128SetCursorPosition + will be called after this, so we can ignore xorigin and yorigin. */ +static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 *s = (CARD32 *)image; + CARD32 *d = (CARD32 *)(info->FB + info->cursor_start); + int y; + CARD32 save; + + save = INREG(R128_CRTC_GEN_CNTL); + OUTREG(R128_CRTC_GEN_CNTL, save & ~R128_CRTC_CUR_EN); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + switch(info->CurrentLayout.pixel_bytes) { + case 4: + case 3: + for (y = 0; y < 64; y++) { + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + } + break; + case 2: + for (y = 0; y < 64; y++) { + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + } + break; + default: + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + } +#else + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } +#endif + + /* Set the area after the cursor to be all transparent so that we + won't display corrupted cursors on the screen */ + for (y = 0; y < 64; y++) { + *d++ = 0xffffffff; /* The AND bits */ + *d++ = 0xffffffff; + *d++ = 0x00000000; /* The XOR bits */ + *d++ = 0x00000000; + } + + + OUTREG(R128_CRTC_GEN_CNTL, save); +} + +/* Hide hardware cursor. */ +static void R128HideCursor(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_GEN_CNTL, 0, ~R128_CRTC_CUR_EN); +} + +/* Show hardware cursor. */ +static void R128ShowCursor(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_GEN_CNTL, R128_CRTC_CUR_EN, ~R128_CRTC_CUR_EN); +} + +/* Determine if hardware cursor is in use. */ +static Bool R128UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + return info->cursor_start ? TRUE : FALSE; +} + +/* Initialize hardware cursor support. */ +Bool R128CursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + xf86CursorInfoPtr cursor; + FBAreaPtr fbarea; + int width; + int height; + int size; + + + if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; + + cursor->MaxWidth = 64; + cursor->MaxHeight = 64; + cursor->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST +#endif + | HARDWARE_CURSOR_INVERT_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK); + + cursor->SetCursorColors = R128SetCursorColors; + cursor->SetCursorPosition = R128SetCursorPosition; + cursor->LoadCursorImage = R128LoadCursorImage; + cursor->HideCursor = R128HideCursor; + cursor->ShowCursor = R128ShowCursor; + cursor->UseHWCursor = R128UseHWCursor; + + size = (cursor->MaxWidth/4) * cursor->MaxHeight; + width = pScrn->displayWidth; + height = (size*2 + 1023) / pScrn->displayWidth; + fbarea = xf86AllocateOffscreenArea(pScreen, + width, + height, + 16, + NULL, + NULL, + NULL); + + if (!fbarea) { + info->cursor_start = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Hardware cursor disabled" + " due to insufficient offscreen memory\n"); + } else { + info->cursor_start = R128_ALIGN((fbarea->box.x1 + + width * fbarea->box.y1) + * info->CurrentLayout.pixel_bytes, 16); + info->cursor_end = info->cursor_start + size; + } + + R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n", + info->cursor_start, info->cursor_end)); + + return xf86InitCursor(pScreen, cursor); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c:1.4 --- /dev/null Mon Dec 18 14:30:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c Tue Nov 21 18:10:33 2000 @@ -0,0 +1,356 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dga.c,v 1.4 2000/11/21 23:10:33 tsi Exp $ */ +/* + * Authors: + * Ove Kåven <ovek@transgaming.com>, + * borrowing some code from the Chips and MGA drivers. + */ + + /* Driver data structures */ +#include "r128.h" +#include "r128_probe.h" + + /* X and server generic header files */ +#include "xf86.h" + + /* DGA support */ +#include "dgaproc.h" + + +static Bool R128_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool R128_SetMode(ScrnInfoPtr, DGAModePtr); +static int R128_GetViewport(ScrnInfoPtr); +static void R128_SetViewport(ScrnInfoPtr, int, int, int); +static void R128_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void R128_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +#if 0 +static void R128_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); +#endif + +static +DGAFunctionRec R128_DGAFuncs = { + R128_OpenFramebuffer, + NULL, + R128_SetMode, + R128_SetViewport, + R128_GetViewport, + R128WaitForIdle, + R128_FillRect, + R128_BlitRect, +#if 0 + R128_BlitTransRect +#else + NULL +#endif +}; + + +static DGAModePtr +R128SetupDGAMode( + ScrnInfoPtr pScrn, + DGAModePtr modes, + int *num, + int bitsPerPixel, + int depth, + Bool pixmap, + int secondPitch, + unsigned long red, + unsigned long green, + unsigned long blue, + short visualClass +){ + R128InfoPtr info = R128PTR(pScrn); + DGAModePtr newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int otherPitch, Bpp = bitsPerPixel >> 3; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while(pMode) { + + otherPitch = secondPitch ? secondPitch : pMode->HDisplay; + + if(pMode->HDisplay != otherPitch) { + newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if(!newmodes) { + xfree(modes); + return NULL; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + *num; + (*num)++; + + currentMode->mode = pMode; + /* FIXME: is concurrent access really possible? */ + currentMode->flags = DGA_CONCURRENT_ACCESS; + if(pixmap) + currentMode->flags |= DGA_PIXMAP_AVAILABLE; + if(info->accel) + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if(pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if(pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = depth; + currentMode->bitsPerPixel = bitsPerPixel; + currentMode->red_mask = red; + currentMode->green_mask = green; + currentMode->blue_mask = blue; + currentMode->visualClass = visualClass; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 8; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = (unsigned char*)info->LinearAddr; + + if(oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; + currentMode->imageWidth = otherPitch; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + + pMode = pMode->next; + if(pMode == firstMode) + break; + } + + return modes; +} + + +Bool +R128DGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + DGAModePtr modes = NULL; + int num = 0; + + /* 8 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 8, 8, + (pScrn->bitsPerPixel == 8), + (pScrn->bitsPerPixel != 8) ? 0 : pScrn->displayWidth, + 0, 0, 0, PseudoColor); + + /* 15 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 15) ? 0 : pScrn->displayWidth, + 0x7c00, 0x03e0, 0x001f, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 15) ? 0 : pScrn->displayWidth, + 0x7c00, 0x03e0, 0x001f, DirectColor); + + /* 16 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 16) ? 0 : pScrn->displayWidth, + 0xf800, 0x07e0, 0x001f, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + (pScrn->depth != 16) ? 0 : pScrn->displayWidth, + 0xf800, 0x07e0, 0x001f, DirectColor); + + /* 24 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, + (pScrn->bitsPerPixel == 24), + (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, + (pScrn->bitsPerPixel == 24), + (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + /* 32 */ + modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + info->numDGAModes = num; + info->DGAModes = modes; + + return DGAInit(pScreen, &R128_DGAFuncs, modes, num); +} + + +static Bool +R128_SetMode( + ScrnInfoPtr pScrn, + DGAModePtr pMode +){ + static R128FBLayout SavedLayouts[MAXSCREENS]; + int indx = pScrn->pScreen->myNum; + R128InfoPtr info = R128PTR(pScrn); + + if(!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + if(info->DGAactive) + memcpy(&info->CurrentLayout, &SavedLayouts[indx], sizeof(R128FBLayout)); + + pScrn->currentMode = info->CurrentLayout.mode; + + R128SwitchMode(indx, pScrn->currentMode, 0); + R128AdjustFrame(indx, 0, 0, 0); + info->DGAactive = FALSE; + } else { + if(!info->DGAactive) { /* save the old parameters */ + memcpy(&SavedLayouts[indx], &info->CurrentLayout, sizeof(R128FBLayout)); + info->DGAactive = TRUE; + } + + info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel; + info->CurrentLayout.depth = pMode->depth; + info->CurrentLayout.displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16 + ? pMode->bitsPerPixel + : pMode->depth); + /* R128ModeInit() will set the mode field */ + + R128SwitchMode(indx, pMode->mode, 0); + } + + return TRUE; +} + + + +static int +R128_GetViewport( + ScrnInfoPtr pScrn +){ + R128InfoPtr info = R128PTR(pScrn); + + return info->DGAViewportStatus; +} + + +static void +R128_SetViewport( + ScrnInfoPtr pScrn, + int x, int y, + int flags +){ + R128InfoPtr info = R128PTR(pScrn); + + R128AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + info->DGAViewportStatus = 0; /* FIXME */ +} + + +static void +R128_FillRect ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color +){ + R128InfoPtr info = R128PTR(pScrn); + + if(info->accel) { + (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, (CARD32)(~0)); + (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +static void +R128_BlitRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + R128InfoPtr info = R128PTR(pScrn); + + if(info->accel) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*info->accel->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, (CARD32)(~0), -1); + (*info->accel->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(info->accel); + } +} + + +#if 0 +static void +R128_BlitTransRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +){ + /* this one should be separate since the XAA function would + prohibit usage of ~0 as the key */ +} +#endif + + +static Bool +R128_OpenFramebuffer( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + R128InfoPtr info = R128PTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)info->LinearAddr; + *size = info->FbMapSize; + *offset = 0; + *flags = /* DGA_NEED_ROOT */ 0; /* don't need root, just /dev/mem access */ + + return TRUE; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c:1.7 --- /dev/null Mon Dec 18 14:30:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c Tue Dec 12 12:17:12 2000 @@ -0,0 +1,1045 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c,v 1.7 2000/12/12 17:17:12 dawes Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * + */ + + /* Driver data structures */ +#include "r128.h" +#include "r128_dri.h" +#include "r128_reg.h" +#include "r128_sarea.h" +#include "r128_version.h" + + /* X and server generic header files */ +#include "xf86.h" +#include "windowstr.h" + + /* GLX/DRI/DRM definitions */ +#define _XF86DRI_SERVER_ +#include "GL/glxtokens.h" +#include "sarea.h" + + +/* Initialize the visual configs that are supported by the hardware. + These are combined with the visual configs that the indirect + rendering core supports, and the intersection is exported to the + client. */ +static Bool R128InitVisualConfigs(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = 0; + R128ConfigPrivPtr pR128Configs = 0; + R128ConfigPrivPtr *pR128ConfigPtrs = 0; + int i, accum, stencil; + + switch (info->CurrentLayout.pixel_code) { + case 8: /* 8bpp mode is not support */ + case 15: /* FIXME */ + case 24: /* FIXME */ + return FALSE; + +#define R128_USE_ACCUM 1 +#define R128_USE_STENCIL 1 + + case 16: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + if (R128_USE_STENCIL) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = (VisualID)(-1); + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].alphaSize = 0; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0x00000000; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + pConfigs[i].depthSize = 16; + if (stencil) + pConfigs[i].stencilSize = 8; /* Simulated in software */ + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum || stencil) { + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + } else { + pConfigs[i].visualRating = GLX_NONE_EXT; + } + pConfigs[i].transparentPixel = GLX_NONE; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + break; + + case 32: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + if (R128_USE_STENCIL) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = (VisualID)(-1); + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].alphaSize = 8; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + pConfigs[i].alphaMask = 0xFF000000; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 16; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 24; + if (stencil) { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + } else { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 0; + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum || stencil) { + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + } else { + pConfigs[i].visualRating = GLX_NONE_EXT; + } + pConfigs[i].transparentPixel = GLX_NONE; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + break; + } + + info->numVisualConfigs = numConfigs; + info->pVisualConfigs = pConfigs; + info->pVisualConfigsPriv = pR128Configs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs); + return TRUE; +} + +/* Create the Rage 128-specific context information */ +static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual, + drmContext hwContext, void *pVisualConfigPriv, + DRIContextType contextStore) +{ + /* Nothing yet */ + return TRUE; +} + +/* Destroy the Rage 128-specific context information */ +static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext, + DRIContextType contextStore) +{ + /* Nothing yet */ +} + +/* Called when the X server is woken up to allow the last client's + context to be saved and the X server's context to be loaded. This is + not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128EnterServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + if (info->accel) info->accel->NeedToSync = TRUE; +} + +/* Called when the X server goes to sleep to allow the X server's + context to be saved and the last client's context to be loaded. This + is not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128LeaveServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (!info->CCE2D) { + if (!info->CCEInUse) { + /* Save all hardware scissors */ + info->sc_left = INREG(R128_SC_LEFT); + info->sc_right = INREG(R128_SC_RIGHT); + info->sc_top = INREG(R128_SC_TOP); + info->sc_bottom = INREG(R128_SC_BOTTOM); + info->aux_sc_cntl = INREG(R128_SC_BOTTOM); + } + + R128MMIO_TO_CCE(pScrn, info); + } +} + +/* Contexts can be swapped by the X server if necessary. This callback + is currently only used to perform any functions necessary when + entering or leaving the X server, and in the future might not be + necessary. */ +static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ + R128EnterServer(pScreen); + } + if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ + R128LeaveServer(pScreen); + } +} + +/* Initialize the state of the back and depth buffers. */ +static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 indx) +{ + /* FIXME: This routine needs to have acceleration turned on */ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + BoxPtr pbox, pboxSave; + int nbox, nboxSave; + int depth; + + /* FIXME: Use accel when CCE 2D code is written */ + if (info->CCE2D) return; + + /* FIXME: This should be based on the __GLXvisualConfig info */ + switch (pScrn->bitsPerPixel) { + case 8: depth = 0x000000ff; break; + case 16: depth = 0x0000ffff; break; + case 24: depth = 0x00ffffff; break; + case 32: depth = 0xffffffff; break; + default: depth = 0x00000000; break; + } + + /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + pboxSave = pbox = REGION_RECTS(prgn); + nboxSave = nbox = REGION_NUM_RECTS(prgn); + + (*info->accel->SetupForSolidFill)(pScrn, 0, GXcopy, (CARD32)(-1)); + for (; nbox; nbox--, pbox++) { + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->fbX, + pbox->y1 + info->fbY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->backX, + pbox->y1 + info->backY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + } + + pbox = pboxSave; + nbox = nboxSave; + + /* FIXME: this needs to consider depth tiling. */ + (*info->accel->SetupForSolidFill)(pScrn, depth, GXcopy, (CARD32)(-1)); + for (; nbox; nbox--, pbox++) + (*info->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + info->depthX, + pbox->y1 + info->depthY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + + info->accel->NeedToSync = TRUE; +} + +/* Copy the back and depth buffers when the X server moves a window. */ +static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr prgnSrc, CARD32 indx) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + /* FIXME: This routine needs to have acceleration turned on */ + /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + /* FIXME: Use accel when CCE 2D code is written */ + if (info->CCE2D) return; +} + +/* Initialize the AGP state. Request memory for use in AGP space, and + initialize the Rage 128 registers to point to that memory. */ +static Bool R128DRIAgpInit(R128InfoPtr info, ScreenPtr pScreen) +{ + unsigned char *R128MMIO = info->MMIO; + unsigned long mode; + unsigned int vendor, device; + int ret; + unsigned long cntl; + int s, l; + int flags; + + if (drmAgpAcquire(info->drmFD) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n"); + return FALSE; + } + + /* Modify the mode if the default mode is + not appropriate for this particular + combination of graphics card and AGP + chipset. */ + + mode = drmAgpGetMode(info->drmFD); /* Default mode */ + vendor = drmAgpVendorId(info->drmFD); + device = drmAgpDeviceId(info->drmFD); + + mode &= ~R128_AGP_MODE_MASK; + switch (info->agpMode) { + case 4: mode |= R128_AGP_4X_MODE; + case 2: mode |= R128_AGP_2X_MODE; + case 1: default: mode |= R128_AGP_1X_MODE; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", + mode, vendor, device, + info->PciInfo->vendor, + info->PciInfo->chipType); + + if (drmAgpEnable(info->drmFD, mode) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n"); + drmAgpRelease(info->drmFD); + return FALSE; + } + + info->agpOffset = 0; + + if ((ret = drmAgpAlloc(info->drmFD, info->agpSize*1024*1024, 0, NULL, + &info->agpMemHandle)) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret); + drmAgpRelease(info->drmFD); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] %d kB allocated with handle 0x%08x\n", + info->agpSize*1024, info->agpMemHandle); + + if (drmAgpBind(info->drmFD, info->agpMemHandle, info->agpOffset) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n"); + drmAgpFree(info->drmFD, info->agpMemHandle); + drmAgpRelease(info->drmFD); + return FALSE; + } + + /* Initialize the CCE ring buffer data */ + info->ringStart = info->agpOffset; + info->ringMapSize = info->ringSize*1024*1024 + 4096; + info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1; + + info->ringReadOffset = info->ringStart + info->ringMapSize; + info->ringReadMapSize = 4096; + + /* Reserve space for vertex/indirect buffers */ + info->bufStart = info->ringReadOffset + info->ringReadMapSize; + info->bufMapSize = info->bufSize*1024*1024; + + /* Reserve the rest for AGP textures */ + info->agpTexStart = info->bufStart + info->bufMapSize; + s = (info->agpSize*1024*1024 - info->agpTexStart); + l = R128MinBits((s-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + info->agpTexMapSize = (s >> l) << l; + info->log2AGPTexGran = l; + + if (info->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + if (drmAddMap(info->drmFD, info->ringStart, info->ringMapSize, + DRM_AGP, flags, &info->ringHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring handle = 0x%08lx\n", info->ringHandle); + + if (drmMap(info->drmFD, info->ringHandle, info->ringMapSize, + (drmAddressPtr)&info->ring) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring mapped at 0x%08lx\n", + (unsigned long)info->ring); + + if (drmAddMap(info->drmFD, info->ringReadOffset, info->ringReadMapSize, + DRM_AGP, flags, &info->ringReadPtrHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring read ptr mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring read ptr handle = 0x%08lx\n", + info->ringReadPtrHandle); + + if (drmMap(info->drmFD, info->ringReadPtrHandle, info->ringReadMapSize, + (drmAddressPtr)&info->ringReadPtr) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map ring read ptr\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring read ptr mapped at 0x%08lx\n", + (unsigned long)info->ringReadPtr); + + if (drmAddMap(info->drmFD, info->bufStart, info->bufMapSize, + DRM_AGP, 0, &info->bufHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add vertex/indirect buffers mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] vertex/indirect buffers handle = 0x%08lx\n", + info->bufHandle); + + if (drmMap(info->drmFD, info->bufHandle, info->bufMapSize, + (drmAddressPtr)&info->buf) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map vertex/indirect buffers\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Vertex/indirect buffers mapped at 0x%08lx\n", + (unsigned long)info->buf); + + if (drmAddMap(info->drmFD, info->agpTexStart, info->agpTexMapSize, + DRM_AGP, 0, &info->agpTexHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add AGP texture map mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP texture map handle = 0x%08lx\n", + info->agpTexHandle); + + if (drmMap(info->drmFD, info->agpTexHandle, info->agpTexMapSize, + (drmAddressPtr)&info->agpTex) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map AGP texture map\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP Texture map mapped at 0x%08lx\n", + (unsigned long)info->agpTex); + + /* Initialize Rage 128's AGP registers */ + cntl = INREG(R128_AGP_CNTL); + cntl &= ~R128_AGP_APER_SIZE_MASK; + switch (info->agpSize) { + case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; + case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; + case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; + case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; + case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; + case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; + case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; + default: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Illegal aperture size %d kB\n", + info->agpSize*1024); + return FALSE; + } + OUTREG(R128_AGP_BASE, info->ringHandle); /* Ring buf is at AGP offset 0 */ + OUTREG(R128_AGP_CNTL, cntl); + + return TRUE; +} + +#if 0 +/* Fake the vertex buffers for PCI cards. */ +static Bool R128DRIPciInit(R128InfoPtr info) +{ + info->bufStart = 0; + info->bufMapSize = info->bufSize*1024*1024; + + return TRUE; +} +#endif + +/* Add a map for the MMIO registers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIMapInit(R128InfoPtr info, ScreenPtr pScreen) +{ + int flags; + + if (info->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + /* Map registers */ + info->registerSize = R128_MMIOSIZE; + if (drmAddMap(info->drmFD, info->MMIOAddr, info->registerSize, + DRM_REGISTERS, flags, &info->registerHandle) < 0) { + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] register handle = 0x%08lx\n", info->registerHandle); + + return TRUE; +} + +/* Initialize the kernel data structures. */ +static int R128DRIKernelInit(R128InfoPtr info, ScreenPtr pScreen) +{ + drmR128Init drmInfo; + + drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); + drmInfo.is_pci = info->IsPCI; + drmInfo.cce_mode = info->CCEMode; + drmInfo.cce_secure = info->CCESecure; + drmInfo.ring_size = info->ringSize*1024*1024; + drmInfo.usec_timeout = info->CCEusecTimeout; + + drmInfo.fb_bpp = info->CurrentLayout.pixel_code; + drmInfo.depth_bpp = info->CurrentLayout.pixel_code; + + drmInfo.front_offset = info->frontOffset; + drmInfo.front_pitch = info->frontPitch; + + drmInfo.back_offset = info->backOffset; + drmInfo.back_pitch = info->backPitch; + + drmInfo.depth_offset = info->depthOffset; + drmInfo.depth_pitch = info->depthPitch; + drmInfo.span_offset = info->spanOffset; + + drmInfo.fb_offset = info->LinearAddr; + drmInfo.mmio_offset = info->registerHandle; + drmInfo.ring_offset = info->ringHandle; + drmInfo.ring_rptr_offset = info->ringReadPtrHandle; + drmInfo.buffers_offset = info->bufHandle; + drmInfo.agp_textures_offset = info->agpTexHandle; + + if (drmR128InitCCE(info->drmFD, &drmInfo) < 0) return FALSE; + + return TRUE; +} + +/* Add a map for the vertex buffers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIBufInit(R128InfoPtr info, ScreenPtr pScreen) +{ + /* Initialize vertex buffers */ + if ((info->bufNumBufs = drmAddBufs(info->drmFD, + info->bufMapSize / R128_BUFFER_SIZE, + R128_BUFFER_SIZE, + DRM_AGP_BUFFER, + info->bufStart)) <= 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Could not create vertex/indirect buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Added %d %d byte vertex/indirect buffers\n", + info->bufNumBufs, R128_BUFFER_SIZE); + + if (drmMarkBufs(info->drmFD, 0.133333, 0.266666)) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to mark vertex/indirect buffers list\n"); + return FALSE; + } + + if (!(info->buffers = drmMapBufs(info->drmFD))) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to map vertex/indirect buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Mapped %d vertex/indirect buffers\n", + info->buffers->count); + + return TRUE; +} + +/* Initialize the CCE state, and start the CCE (if used by the X server) */ +static void R128DRICCEInit(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + /* Turn on bus mastering */ + info->BusCntl &= ~R128_BUS_MASTER_DIS; + + /* CCEMode is initialized in r128_driver.c */ + switch (info->CCEMode) { + case R128_PM4_NONPM4: info->CCEFifoSize = 0; break; + case R128_PM4_192PIO: info->CCEFifoSize = 192; break; + case R128_PM4_192BM: info->CCEFifoSize = 192; break; + case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break; + } + + if (info->CCE2D) { + /* Make sure the CCE is on for the X server */ + R128CCE_START(pScrn, info); + } else { + /* Make sure the CCE is off for the X server */ + R128CCE_STOP(pScrn, info); + } +} + +/* Initialize the screen-specific data structures for the DRI and the + Rage 128. This is the main entry point to the device-specific + initialization code. It calls device-independent DRI functions to + create the DRI data structures and initialize the DRI state. */ +Bool R128DRIScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + DRIInfoPtr pDRIInfo; + R128DRIPtr pR128DRI; + int major, minor, patch; + drmVersionPtr version; + + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for known symbols in each module. */ + if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; + if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed (libdri.a too old)\n"); + return FALSE; + } + + /* Check the DRI version */ + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRI version = %d.%d.%d, expected 3.0.x). " + "Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + + switch (info->CurrentLayout.pixel_code) { + case 8: + /* These modes are not supported (yet). */ + case 15: + case 24: + return FALSE; + + /* Only 16 and 32 color depths are supports currently. */ + case 16: + case 32: + break; + } + + /* Create the DRI data structure, and fill it in before calling the + DRIScreenInit(). */ + if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; + + info->pDRIInfo = pDRIInfo; + pDRIInfo->drmDriverName = R128_DRIVER_NAME; + pDRIInfo->clientDriverName = R128_DRIVER_NAME; + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, + "PCI:%d:%d:%d", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR; + pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR; + pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH; + pDRIInfo->frameBufferPhysicalAddress = info->LinearAddr; + pDRIInfo->frameBufferSize = info->FbMapSize; + pDRIInfo->frameBufferStride = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES; + pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES + < R128_MAX_DRAWABLES + ? SAREA_MAX_DRAWABLES + : R128_MAX_DRAWABLES); + +#ifdef NOT_DONE + /* FIXME: Need to extend DRI protocol to pass this size back to + * client for SAREA mapping that includes a device private record + */ + pDRIInfo->SAREASize = + ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ + /* + shared memory device private rec */ +#else + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) { + ErrorF("Data does not fit in SAREA\n"); + return FALSE; + } + pDRIInfo->SAREASize = SAREA_MAX; +#endif + + if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) { + DRIDestroyInfoRec(info->pDRIInfo); + info->pDRIInfo = NULL; + return FALSE; + } + pDRIInfo->devPrivate = pR128DRI; + pDRIInfo->devPrivateSize = sizeof(R128DRIRec); + pDRIInfo->contextSize = sizeof(R128DRIContextRec); + + pDRIInfo->CreateContext = R128CreateContext; + pDRIInfo->DestroyContext = R128DestroyContext; + pDRIInfo->SwapContext = R128DRISwapContext; + pDRIInfo->InitBuffers = R128DRIInitBuffers; + pDRIInfo->MoveBuffers = R128DRIMoveBuffers; + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + + if (!DRIScreenInit(pScreen, pDRIInfo, &info->drmFD)) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed!\n"); + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = NULL; + DRIDestroyInfoRec(pDRIInfo); + pDRIInfo = NULL; + return FALSE; + } + + /* Check the r128 DRM version */ + version = drmGetVersion(info->drmFD); + if (version) { + if (version->version_major != 2 || + version->version_minor != 1 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRM version = %d.%d.%d, expected 2.1.x). " + "Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + drmFreeVersion(version); + R128DRICloseScreen(pScreen); + return FALSE; + } + drmFreeVersion(version); + } + + /* Initialize AGP */ + if (!info->IsPCI && !R128DRIAgpInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } +#if 0 + /* Initialize PCI */ + if (info->IsPCI && !R128DRIPciInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } +#else + if (info->IsPCI) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "PCI cards not yet supported\n"); + R128DRICloseScreen(pScreen); + return FALSE; + } +#endif + + /* DRIScreenInit doesn't add all the + common mappings. Add additional + mappings here. */ + if (!R128DRIMapInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* FIXME: When are these mappings unmapped? */ + + if (!R128InitVisualConfigs(pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n"); + + return TRUE; +} + +/* Finish initializing the device-dependent DRI state, and call + DRIFinishScreenInit() to complete the device-independent DRI + initialization. */ +Bool R128DRIFinishScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + R128SAREAPrivPtr pSAREAPriv; + R128DRIPtr pR128DRI; + + info->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; + /* info->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ + + /* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit + because *DRIKernelInit requires that the hardware lock is held by + the X server, and the first time the hardware lock is grabbed is + in DRIFinishScreenInit. */ + if (!DRIFinishScreenInit(pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the kernel data structures */ + if (!R128DRIKernelInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the vertex buffers list */ + if (!info->IsPCI && !R128DRIBufInit(info, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize and start the CCE if required */ + R128DRICCEInit(pScrn); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); + + pR128DRI = (R128DRIPtr)info->pDRIInfo->devPrivate; + pR128DRI->registerHandle = info->registerHandle; + pR128DRI->registerSize = info->registerSize; + + pR128DRI->ringHandle = info->ringHandle; + pR128DRI->ringMapSize = info->ringMapSize; + pR128DRI->ringSize = info->ringSize*1024*1024; + + pR128DRI->ringReadPtrHandle = info->ringReadPtrHandle; + pR128DRI->ringReadMapSize = info->ringReadMapSize; + + pR128DRI->bufHandle = info->bufHandle; + pR128DRI->bufMapSize = info->bufMapSize; + pR128DRI->bufOffset = info->bufStart; + + pR128DRI->agpTexHandle = info->agpTexHandle; + pR128DRI->agpTexMapSize = info->agpTexMapSize; + pR128DRI->log2AGPTexGran = info->log2AGPTexGran; + pR128DRI->agpTexOffset = info->agpTexStart; + + pR128DRI->deviceID = info->Chipset; + pR128DRI->width = pScrn->virtualX; + pR128DRI->height = pScrn->virtualY; + pR128DRI->depth = pScrn->depth; + pR128DRI->bpp = pScrn->bitsPerPixel; + + pR128DRI->frontOffset = info->frontOffset; + pR128DRI->frontPitch = info->frontPitch; + pR128DRI->backOffset = info->backOffset; + pR128DRI->backPitch = info->backPitch; + pR128DRI->depthOffset = info->depthOffset; + pR128DRI->depthPitch = info->depthPitch; + pR128DRI->spanOffset = info->spanOffset; + pR128DRI->textureOffset = info->textureOffset; + pR128DRI->textureSize = info->textureSize; + pR128DRI->log2TexGran = info->log2TexGran; + + pR128DRI->IsPCI = info->IsPCI; + pR128DRI->AGPMode = info->agpMode; + + pR128DRI->CCEMode = info->CCEMode; + pR128DRI->CCEFifoSize = info->CCEFifoSize; + + return TRUE; +} + +/* The screen is being closed, so clean up any state and free any + resources used by the DRI. */ +void R128DRICloseScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + + /* Stop the CCE if it is still in use */ + if (info->CCE2D) { + R128CCE_STOP(pScrn, info); + } + + /* De-allocate vertex buffers */ + if (info->buffers) { + drmUnmapBufs(info->buffers); + info->buffers = NULL; + } + + /* De-allocate all kernel resources */ + drmR128CleanupCCE(info->drmFD); + + /* De-allocate all AGP resources */ + if (info->agpTex) { + drmUnmap(info->agpTex, info->agpTexMapSize); + info->agpTex = NULL; + } + if (info->buf) { + drmUnmap(info->buf, info->bufMapSize); + info->buf = NULL; + } + if (info->ringReadPtr) { + drmUnmap(info->ringReadPtr, info->ringReadMapSize); + info->ringReadPtr = NULL; + } + if (info->ring) { + drmUnmap(info->ring, info->ringMapSize); + info->ring = NULL; + } + if (info->agpMemHandle) { + drmAgpUnbind(info->drmFD, info->agpMemHandle); + drmAgpFree(info->drmFD, info->agpMemHandle); + info->agpMemHandle = 0; + drmAgpRelease(info->drmFD); + } + + /* De-allocate all DRI resources */ + DRICloseScreen(pScreen); + + /* De-allocate all DRI data structures */ + if (info->pDRIInfo) { + if (info->pDRIInfo->devPrivate) { + xfree(info->pDRIInfo->devPrivate); + info->pDRIInfo->devPrivate = NULL; + } + DRIDestroyInfoRec(info->pDRIInfo); + info->pDRIInfo = NULL; + } + if (info->pVisualConfigs) { + xfree(info->pVisualConfigs); + info->pVisualConfigs = NULL; + } + if (info->pVisualConfigsPriv) { + xfree(info->pVisualConfigsPriv); + info->pVisualConfigsPriv = NULL; + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h:1.4 --- /dev/null Mon Dec 18 14:30:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h Mon Dec 4 14:21:52 2000 @@ -0,0 +1,118 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h,v 1.4 2000/12/04 19:21:52 dawes Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * + */ + +#ifndef _R128_DRI_ +#define _R128_DRI_ + +#include "xf86drm.h" +#include "xf86drmR128.h" + +/* DRI Driver defaults */ +#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM +#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM +#define R128_DEFAULT_AGP_MODE 2 +#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */ +#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */ +#define R128_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */ +#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */ + +#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */ + +#define R128_AGP_MAX_MODE 4 + +#define R128_CARD_TYPE_R128 1 +#define R128_CARD_TYPE_R128_PRO 2 +#define R128_CARD_TYPE_R128_MOBILITY 3 + +#define R128CCE_USE_RING_BUFFER(m) \ +(((m) == R128_PM4_192BM) || \ + ((m) == R128_PM4_128BM_64INDBM) || \ + ((m) == R128_PM4_64BM_128INDBM) || \ + ((m) == R128_PM4_64BM_64VCBM_64INDBM)) + +typedef struct { + /* MMIO register data */ + drmHandle registerHandle; + drmSize registerSize; + + /* CCE ring buffer data */ + drmHandle ringHandle; + drmSize ringMapSize; + int ringSize; + + /* CCE ring read pointer data */ + drmHandle ringReadPtrHandle; + drmSize ringReadMapSize; + + /* CCE vertex/indirect buffer data */ + drmHandle bufHandle; + drmSize bufMapSize; + int bufOffset; + + /* CCE AGP Texture data */ + drmHandle agpTexHandle; + drmSize agpTexMapSize; + int log2AGPTexGran; + int agpTexOffset; + + /* DRI screen private data */ + int deviceID; /* PCI device ID */ + int width; /* Width in pixels of display */ + int height; /* Height in scanlines of display */ + int depth; /* Depth of display (8, 15, 16, 24) */ + int bpp; /* Bit depth of display (8, 16, 24, 32) */ + + int frontOffset; /* Start of front buffer */ + int frontPitch; + int backOffset; /* Start of shared back buffer */ + int backPitch; + int depthOffset; /* Start of shared depth buffer */ + int depthPitch; + int spanOffset; /* Start of scratch spanline */ + int textureOffset;/* Start of texture data in frame buffer */ + int textureSize; + int log2TexGran; + + int IsPCI; /* Current card is a PCI card */ + int AGPMode; + + int CCEMode; /* CCE mode that server/clients use */ + int CCEFifoSize; /* Size of the CCE command FIFO */ +} R128DRIRec, *R128DRIPtr; + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h:1.3 --- /dev/null Mon Dec 18 14:30:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h Sat Nov 18 14:37:11 2000 @@ -0,0 +1,58 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dripriv.h,v 1.3 2000/11/18 19:37:11 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * + */ + +#ifndef _R128_DRIPRIV_H_ +#define _R128_DRIPRIV_H_ + +#include "GL/glxint.h" + +#define R128_MAX_DRAWABLES 256 + +extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, + void **configprivs); + +typedef struct { + /* Nothing here yet */ + int dummy; +} R128ConfigPrivRec, *R128ConfigPrivPtr; + +typedef struct { + /* Nothing here yet */ + int dummy; +} R128DRIContextRec, *R128DRIContextPtr; + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c:1.13 --- /dev/null Mon Dec 18 14:30:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c Fri Dec 8 14:15:33 2000 @@ -0,0 +1,3007 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c,v 1.13 2000/12/08 19:15:33 martin Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * + * Credits: + * + * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for + * providing source code to their 3.3.x Rage 128 driver. Portions of + * this file are based on the initialization code for that driver. + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * This server does not yet support these XFree86 4.0 features: + * DDC1 & DDC2 + * shadowfb + * overlay planes + * DGA + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + + + /* Driver data structures */ +#include "r128.h" +#include "r128_probe.h" +#include "r128_reg.h" +#include "r128_version.h" + +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dri.h" +#include "r128_sarea.h" +#endif + +#define USE_FB /* not until overlays */ +#ifdef USE_FB +#include "fb.h" +#else + + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" +#endif + + /* colormap initialization */ +#include "micmap.h" + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86PciInfo.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "xf86xv.h" +#include "vbe.h" + + /* fbdevhw & vgahw */ +#include "fbdevhw.h" +#include "vgaHW.h" +#include "dixstruct.h" + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + + /* Forward definitions for driver functions */ +static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool R128SaveScreen(ScreenPtr pScreen, int mode); +static void R128Save(ScrnInfoPtr pScrn); +static void R128Restore(ScrnInfoPtr pScrn); +static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags); +static Bool R128EnterVTFBDev(int scrnIndex, int flags); +static void R128LeaveVTFBDev(int scrnIndex, int flags); + +typedef enum { + OPTION_NOACCEL, + OPTION_SW_CURSOR, + OPTION_DAC_6BIT, + OPTION_DAC_8BIT, +#ifdef XF86DRI + OPTION_IS_PCI, + OPTION_CCE_PIO, + OPTION_NO_SECURITY, + OPTION_USEC_TIMEOUT, + OPTION_AGP_MODE, + OPTION_AGP_SIZE, + OPTION_RING_SIZE, + OPTION_BUFFER_SIZE, + OPTION_USE_CCE_2D, +#endif +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + OPTION_CRT, +#endif + OPTION_PANEL_WIDTH, + OPTION_PANEL_HEIGHT, + OPTION_PROG_FP_REGS, + OPTION_FBDEV, + OPTION_VIDEO_KEY, + OPTION_SHOW_CACHE +} R128Opts; + +OptionInfoRec R128Options[] = { + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +#ifdef XF86DRI + { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_BUFFER_SIZE, "BufferSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE }, +#endif +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PROG_FP_REGS, "ProgramFPRegs", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, + { OPTION_SHOW_CACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +R128RAMRec R128RAM[] = { /* Memory Specifications + From RAGE 128 Software Development + Manual (Technical Reference Manual P/N + SDK-G04000 Rev 0.01), page 3-21. */ + { 4, 4, 3, 3, 1, 3, 1, 16, 12, "128-bit SDR SGRAM 1:1" }, + { 4, 8, 3, 3, 1, 3, 1, 17, 13, "64-bit SDR SGRAM 1:1" }, + { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SGRAM 2:1" }, + { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SGRAM" }, +}; + +static const char *vgahwSymbols[] = { + "vgaHWGetHWRec", + "vgaHWFreeHWRec", + "vgaHWLock", + "vgaHWUnlock", + "vgaHWSave", + "vgaHWRestore", + NULL +}; + +static const char *fbdevHWSymbols[] = { + "fbdevHWInit", + "fbdevHWUseBuildinMode", + + "fbdevHWGetDepth", + "fbdevHWGetVidmem", + + /* colormap */ + "fbdevHWLoadPalette", + + /* ScrnInfo hooks */ + "fbdevHWSwitchMode", + "fbdevHWAdjustFrame", + "fbdevHWEnterVT", + "fbdevHWLeaveVT", + "fbdevHWValidMode", + "fbdevHWRestore", + "fbdevHWModeInit", + "fbdevHWSave", + + "fbdevHWUnmapMMIO", + "fbdevHWUnmapVidmem", + "fbdevHWMapMMIO", + "fbdevHWMapVidmem", + + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +#ifdef XFree86LOADER +#ifdef USE_FB +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; +#else +static const char *cfbSymbols[] = { + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb32ScreenInit", + "cfb24_32ScreenInit", + NULL +}; +#endif + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAStippleScanlineFuncLSBFirst", + "XAAOverlayFBfuncs", + "XAACachePlanarMonoStipple", + "XAAScreenIndex", + NULL +}; + +static const char *xf8_32bppSymbols[] = { + "xf86Overlay8Plus32Init", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAgpAcquire", + "drmAgpAlloc", + "drmAgpBind", + "drmAgpDeviceId", + "drmAgpEnable", + "drmAgpFree", + "drmAgpGetMode", + "drmAgpRelease", + "drmAgpUnbind", + "drmAgpVendorId", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmFreeVersion", + "drmGetInterruptFromBusID", + "drmGetVersion", + "drmMap", + "drmMapBufs", + "drmMarkBufs", + "drmR128CleanupCCE", + "drmR128InitCCE", + "drmUnmap", + "drmUnmapBufs", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "DRIQueryVersion", + "GlxSetVisualConfigs", + NULL +}; +#endif + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + "vbeFree", + NULL +}; +#endif + +/* Allocate our private R128InfoRec. */ +static Bool R128GetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(R128InfoRec), 1); + return TRUE; +} + +/* Free our private R128InfoRec. */ +static void R128FreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn || !pScrn->driverPrivate) return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* Memory map the MMIO region. Used during pre-init and by R128MapMem, + below. */ +static Bool R128MapMMIO(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) { + info->MMIO = fbdevHWMapMMIO(pScrn); + } else { + info->MMIO = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, + info->PciTag, + info->MMIOAddr, + R128_MMIOSIZE); + } + + if (!info->MMIO) return FALSE; + return TRUE; +} + +/* Unmap the MMIO region. Used during pre-init and by R128UnmapMem, + below. */ +static Bool R128UnmapMMIO(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapMMIO(pScrn); + else { + xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, R128_MMIOSIZE); + } + info->MMIO = NULL; + return TRUE; +} + +/* Memory map the frame buffer. Used by R128MapMem, below. */ +static Bool R128MapFB(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) { + info->FB = fbdevHWMapVidmem(pScrn); + } else { + info->FB = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_FRAMEBUFFER, + info->PciTag, + info->LinearAddr, + info->FbMapSize); + } + + if (!info->FB) return FALSE; + return TRUE; +} + +/* Unmap the frame buffer. Used by R128UnmapMem, below. */ +static Bool R128UnmapFB(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapVidmem(pScrn); + else + xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); + info->FB = NULL; + return TRUE; +} + +/* Memory map the MMIO region and the frame buffer. */ +static Bool R128MapMem(ScrnInfoPtr pScrn) +{ + if (!R128MapMMIO(pScrn)) return FALSE; + if (!R128MapFB(pScrn)) { + R128UnmapMMIO(pScrn); + return FALSE; + } + return TRUE; +} + +/* Unmap the MMIO region and the frame buffer. */ +static Bool R128UnmapMem(ScrnInfoPtr pScrn) +{ + if (!R128UnmapMMIO(pScrn) || !R128UnmapFB(pScrn)) return FALSE; + return TRUE; +} + +/* Read PLL information */ +unsigned R128INPLL(ScrnInfoPtr pScrn, int addr) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); + return INREG(R128_CLOCK_CNTL_DATA); +} + +#if 0 +/* Read PAL information (only used for debugging). */ +static int R128INPAL(int idx) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_PALETTE_INDEX, idx << 16); + return INREG(R128_PALETTE_DATA); +} +#endif + +/* Wait for vertical sync. */ +void R128WaitForVerticalSync(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + OUTREG(R128_GEN_INT_STATUS, R128_VSYNC_INT_AK); + for (i = 0; i < R128_TIMEOUT; i++) { + if (INREG(R128_GEN_INT_STATUS) & R128_VSYNC_INT) break; + } +} + +/* Blank screen. */ +static void R128Blank(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_EXT_CNTL, R128_CRTC_DISPLAY_DIS, ~R128_CRTC_DISPLAY_DIS); +} + +/* Unblank screen. */ +static void R128Unblank(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CRTC_EXT_CNTL, 0, ~R128_CRTC_DISPLAY_DIS); +} + +/* Compute log base 2 of val. */ +int R128MinBits(int val) +{ + int bits; + + if (!val) return 1; + for (bits = 0; val; val >>= 1, ++bits); + return bits; +} + +/* Compute n/d with rounding. */ +static int R128Div(int n, int d) +{ + return (n + (d / 2)) / d; +} + +/* Read the Video BIOS block and the FP registers (if applicable). */ +static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + int i; + int FPHeader = 0; + +#define R128ReadBIOS(offset, buffer, length) \ + (info->BIOSFromPCI ? \ + xf86ReadPciBIOS(offset, info->PciTag, 0, buffer, length) : \ + xf86ReadBIOS(info->BIOSAddr, offset, buffer, length)) + +#define R128_BIOS8(v) (info->VBIOS[v]) +#define R128_BIOS16(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8)) +#define R128_BIOS32(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8) | \ + (info->VBIOS[(v) + 2] << 16) | \ + (info->VBIOS[(v) + 3] << 24)) + + if (!(info->VBIOS = xalloc(R128_VBIOS_SIZE))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate space for hold Video BIOS!\n"); + return FALSE; + } + + info->BIOSFromPCI = TRUE; + R128ReadBIOS(0x0000, info->VBIOS, R128_VBIOS_SIZE); + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected in PCI space!\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Attempting to read Video BIOS from legacy ISA space!\n"); + info->BIOSFromPCI = FALSE; + info->BIOSAddr = 0x000c0000; + R128ReadBIOS(0x0000, info->VBIOS, R128_VBIOS_SIZE); + } + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + info->BIOSAddr = 0x00000000; + xfree(info->VBIOS); + info->VBIOS = NULL; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not found!\n"); + } + + if (info->VBIOS && info->HasPanelRegs) { + info->FPBIOSstart = 0; + + /* FIXME: There should be direct access to the start of the FP info + tables, but until we find out where that offset is stored, we + must search for the ATI signature string: "M3 ". */ + for (i = 4; i < R128_VBIOS_SIZE-8; i++) { + if (R128_BIOS8(i) == 'M' && + R128_BIOS8(i+1) == '3' && + R128_BIOS8(i+2) == ' ' && + R128_BIOS8(i+3) == ' ' && + R128_BIOS8(i+4) == ' ' && + R128_BIOS8(i+5) == ' ' && + R128_BIOS8(i+6) == ' ' && + R128_BIOS8(i+7) == ' ') { + FPHeader = i-2; + break; + } + } + + if (!FPHeader) return TRUE; + + /* Assume that only one panel is attached and supported */ + for (i = FPHeader+20; i < FPHeader+84; i += 2) { + if (R128_BIOS16(i) != 0) { + info->FPBIOSstart = R128_BIOS16(i); + break; + } + } + if (!info->FPBIOSstart) return TRUE; + + if (!info->PanelXRes) + info->PanelXRes = R128_BIOS16(info->FPBIOSstart+25); + if (!info->PanelYRes) + info->PanelYRes = R128_BIOS16(info->FPBIOSstart+27); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel size: %dx%d\n", + info->PanelXRes, info->PanelYRes); + + info->PanelPwrDly = R128_BIOS8(info->FPBIOSstart+56); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel ID: "); + for (i = 1; i <= 24; i++) + ErrorF("%c", R128_BIOS8(info->FPBIOSstart+i)); + ErrorF("\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Type: "); + i = R128_BIOS16(info->FPBIOSstart+29); + if (i & 1) ErrorF("Color, "); + else ErrorF("Monochrome, "); + if (i & 2) ErrorF("Dual(split), "); + else ErrorF("Single, "); + switch ((i >> 2) & 0x3f) { + case 0: ErrorF("STN"); break; + case 1: ErrorF("TFT"); break; + case 2: ErrorF("Active STN"); break; + case 3: ErrorF("EL"); break; + case 4: ErrorF("Plasma"); break; + default: ErrorF("UNKNOWN"); break; + } + ErrorF("\n"); + if (R128_BIOS8(info->FPBIOSstart+61) & 1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Interface: LVDS\n"); + } else { + /* FIXME: Add Non-LVDS flat pael support */ + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Non-LVDS panel interface detected! " + "This support is untested and may not " + "function properly\n"); + } + } + + return TRUE; +} + +/* Read PLL parameters from BIOS block. Default to typical values if there + is no BIOS. */ +static Bool R128GetPLLParameters(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + R128PLLPtr pll = &info->pll; + +#if defined(__powerpc__) + /* there is no bios under Linux PowerPC but Open Firmware + does set up the PLL registers properly and we can use + those to calculate xclk and find the reference divider */ + + unsigned x_mpll_ref_fb_div; + unsigned xclk_cntl; + unsigned Nx, M; + unsigned PostDivSet[] = {0, 1, 2, 4, 8, 3, 6, 12}; + + /* Assume REF clock is 2950 (in units of 10khz) */ + /* and that all pllclk must be between 125 Mhz and 250Mhz */ + pll->reference_freq = 2950; + pll->min_pll_freq = 12500; + pll->max_pll_freq = 25000; + + /* need to memory map the io to use INPLL since it + has not been done yet at this point in the startup */ + R128MapMMIO(pScrn); + x_mpll_ref_fb_div = INPLL(pScrn, R128_X_MPLL_REF_FB_DIV); + xclk_cntl = INPLL(pScrn, R128_XCLK_CNTL) & 0x7; + pll->reference_div = + INPLL(pScrn,R128_PPLL_REF_DIV) & R128_PPLL_REF_DIV_MASK; + /* unmap it again */ + R128UnmapMMIO(pScrn); + + Nx = (x_mpll_ref_fb_div & 0x00FF00) >> 8; + M = (x_mpll_ref_fb_div & 0x0000FF); + + pll->xclk = R128Div((2 * Nx * pll->reference_freq), + (M * PostDivSet[xclk_cntl])); + +#else /* !defined(__powerpc__) */ + + if (!info->VBIOS) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected, using default PLL parameters!\n"); + /* These probably aren't going to work for + the card you are using. Specifically, + reference freq can be 29.50MHz, + 28.63MHz, or 14.32MHz. YMMV. */ + pll->reference_freq = 2950; + pll->reference_div = 65; + pll->min_pll_freq = 12500; + pll->max_pll_freq = 25000; + pll->xclk = 10300; + } else { + CARD16 bios_header = R128_BIOS16(0x48); + CARD16 pll_info_block = R128_BIOS16(bios_header + 0x30); + R128TRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", + bios_header, pll_info_block)); + + pll->reference_freq = R128_BIOS16(pll_info_block + 0x0e); + pll->reference_div = R128_BIOS16(pll_info_block + 0x10); + pll->min_pll_freq = R128_BIOS32(pll_info_block + 0x12); + pll->max_pll_freq = R128_BIOS32(pll_info_block + 0x16); + pll->xclk = R128_BIOS16(pll_info_block + 0x08); + } +#endif /* __powerpc__ */ + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PLL parameters: rf=%d rd=%d min=%d max=%d; xclk=%d\n", + pll->reference_freq, + pll->reference_div, + pll->min_pll_freq, + pll->max_pll_freq, + pll->xclk); + + return TRUE; +} + +/* This is called by R128PreInit to set up the default visual. */ +static Bool R128PreInitVisual(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, (Support24bppFb + | Support32bppFb + | SupportConvert32to24 + ))) + return FALSE; + + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by %s driver\n", + pScrn->depth, R128_DRIVER_NAME); + return FALSE; + } + + xf86PrintDepthBpp(pScrn); + + info->fifo_slots = 0; + info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); + info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; + info->CurrentLayout.depth = pScrn->depth; + info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 + ? pScrn->bitsPerPixel + : pScrn->depth); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", + pScrn->depth, + info->CurrentLayout.pixel_bytes, + info->CurrentLayout.pixel_bytes > 1 ? "s" : "", + info->pix24bpp); + + + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; + + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Default visual (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + return TRUE; + +} + +/* This is called by R128PreInit to handle all color weight issues. */ +static Bool R128PreInitWeight(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + /* Save flag for 6 bit DAC to use for + setting CRTC registers. Otherwise use + an 8 bit DAC, even if xf86SetWeight sets + pScrn->rgbBits to some value other than + 8. */ + info->dac6bits = FALSE; + if (pScrn->depth > 8) { + rgb defaultWeight = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + } else { + pScrn->rgbBits = 8; + if (xf86ReturnOptValBool(R128Options, OPTION_DAC_6BIT, FALSE)) { + pScrn->rgbBits = 6; + info->dac6bits = TRUE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d bits per RGB (%d bit DAC)\n", + pScrn->rgbBits, info->dac6bits ? 6 : 8); + + return TRUE; + +} + +/* This is called by R128PreInit to handle config file overrides for things + like chipset and memory regions. Also determine memory size and type. + If memory type ever needs an override, put it in this routine. */ +static Bool R128PreInitConfig(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + EntityInfoPtr pEnt = info->pEnt; + GDevPtr dev = pEnt->device; + int offset = 0; /* RAM Type */ + MessageType from; + + /* Chipset */ + from = X_PROBED; + if (dev->chipset && *dev->chipset) { + info->Chipset = xf86StringToToken(R128Chipsets, dev->chipset); + from = X_CONFIG; + } else if (dev->chipID >= 0) { + info->Chipset = dev->chipID; + from = X_CONFIG; + } else { + info->Chipset = info->PciInfo->chipType; + } + pScrn->chipset = (char *)xf86TokenToString(R128Chipsets, info->Chipset); + + if (!pScrn->chipset) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04x is not recognized\n", info->Chipset); + return FALSE; + } + + if (info->Chipset < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognized\n", pScrn->chipset); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, + "Chipset: \"%s\" (ChipID = 0x%04x)\n", + pScrn->chipset, + info->Chipset); + + /* Framebuffer */ + + from = X_PROBED; + info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; + if (dev->MemBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Linear address override, using 0x%08x instead of 0x%08x\n", + dev->MemBase, + info->LinearAddr); + info->LinearAddr = dev->MemBase; + from = X_CONFIG; + } else if (!info->LinearAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "No valid linear framebuffer address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "Linear framebuffer at 0x%08lx\n", info->LinearAddr); + + /* MMIO registers */ + from = X_PROBED; + info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; + if (dev->IOBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "MMIO address override, using 0x%08x instead of 0x%08x\n", + dev->IOBase, + info->MMIOAddr); + info->MMIOAddr = dev->IOBase; + from = X_CONFIG; + } else if (!info->MMIOAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid MMIO address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "MMIO registers at 0x%08lx\n", info->MMIOAddr); + + /* BIOS */ + from = X_PROBED; + info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; + if (dev->BiosBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BIOS address override, using 0x%08x instead of 0x%08x\n", + dev->BiosBase, + info->BIOSAddr); + info->BIOSAddr = dev->BiosBase; + from = X_CONFIG; + } + if (info->BIOSAddr) { + xf86DrvMsg(pScrn->scrnIndex, from, + "BIOS at 0x%08lx\n", info->BIOSAddr); + } + + /* Flat panel (part 1) */ + if (xf86GetOptValBool(R128Options, OPTION_PROG_FP_REGS, + &info->HasPanelRegs)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Turned flat panel register programming %s\n", + info->HasPanelRegs ? "on" : "off"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "\n\nWARNING: Forcing the driver to use/not use the flat panel registers\nmight damage your flat panel. Use at your *OWN* *RISK*.\n\n"); + } else { + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: info->HasPanelRegs = TRUE; break; + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RG: + case PCI_CHIP_RAGE128RK: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->HasPanelRegs = FALSE; break; + } + } + + /* Read registers used to determine options */ + from = X_PROBED; + R128MapMMIO(pScrn); + R128MMIO = info->MMIO; + if (info->FBDev) + pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; + else + pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024; + info->MemCntl = INREG(R128_MEM_CNTL); + + info->BusCntl = INREG(R128_BUS_CNTL); + R128MMIO = NULL; + R128UnmapMMIO(pScrn); + + /* RAM */ + switch (info->MemCntl & 0x3) { + case 0: /* SDR SGRAM 1:1 */ + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RG: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */ + case PCI_CHIP_RAGE128RK: + case PCI_CHIP_RAGE128RL: + default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ + } + break; + case 1: offset = 2; break; /* 64-bit SDR SGRAM 2:1 */ + case 2: offset = 3; break; /* 64-bit DDR SGRAM */ + default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ + } + info->ram = &R128RAM[offset]; + + if (dev->videoRam) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Video RAM override, using %d kB instead of %d kB\n", + dev->videoRam, + pScrn->videoRam); + from = X_CONFIG; + pScrn->videoRam = dev->videoRam; + } + pScrn->videoRam &= ~1023; + info->FbMapSize = pScrn->videoRam * 1024; + xf86DrvMsg(pScrn->scrnIndex, from, + "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); + + /* Flat panel (part 2) */ + if (info->HasPanelRegs) { +#if 1 + info->CRTOnly = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); +#else + /* Panel CRT mode override */ + if ((info->CRTOnly = xf86ReturnOptValBool(R128Options, + OPTION_CRT, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using external CRT instead of " + "flat panel for display\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); + } +#endif + + /* Panel width/height overrides */ + info->PanelXRes = 0; + info->PanelYRes = 0; + if (xf86GetOptValInteger(R128Options, + OPTION_PANEL_WIDTH, &(info->PanelXRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel width: %d\n", info->PanelXRes); + } + if (xf86GetOptValInteger(R128Options, + OPTION_PANEL_HEIGHT, &(info->PanelYRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel height: %d\n", info->PanelYRes); + } + } else { + info->CRTOnly = FALSE; + } + +#ifdef XF86DRI + /* AGP/PCI */ + if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) { + info->IsPCI = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); + } else { + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break; + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128MF: + case PCI_CHIP_RAGE128ML: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RG: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->IsPCI = FALSE; break; + } + } +#endif + + return TRUE; +} + +static Bool R128PreInitDDC(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + vbeInfoPtr pVbe; + + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; + xf86LoaderReqSymLists(ddcSymbols, NULL); + +#if defined(__powerpc__) + /* Int10 is broken on PPC */ + return TRUE; +#else + if (xf86LoadSubModule(pScrn, "vbe")) { +#ifdef XFree86LOADER + xf86LoaderReqSymLists(vbeSymbols,NULL); +#endif + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + vbeFree(pVbe); + return TRUE; + } else + return FALSE; +#endif +} + +/* This is called by R128PreInit to initialize gamma correction. */ +static Bool R128PreInitGamma(ScrnInfoPtr pScrn) +{ + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) return FALSE; + return TRUE; +} + +/* This is called by R128PreInit to validate modes and compute parameters + for all of the valid modes. */ +static Bool R128PreInitModes(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + ClockRangePtr clockRanges; + int modesFound; + char *mod = NULL; + const char *Sym = NULL; + + /* Get mode information */ + pScrn->progClock = TRUE; + clockRanges = xnfcalloc(sizeof(*clockRanges), 1); + clockRanges->next = NULL; + clockRanges->minClock = info->pll.min_pll_freq; + clockRanges->maxClock = info->pll.max_pll_freq * 10; + clockRanges->clockIndex = -1; + if (info->HasPanelRegs) { + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + } else { + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + } + + modesFound = xf86ValidateModes(pScrn, + pScrn->monitor->Modes, + pScrn->display->modes, + clockRanges, + NULL, /* linePitches */ + 8 * 64, /* minPitch */ + 8 * 1024, /* maxPitch */ + 64 * pScrn->bitsPerPixel, /* pitchInc */ + 128, /* minHeight */ + 2048, /* maxHeight */ + pScrn->virtualX, + pScrn->virtualY, + info->FbMapSize, + LOOKUP_BEST_REFRESH); + + if (modesFound < 1 && info->FBDev) { + fbdevHWUseBuildinMode(pScrn); + pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ + modesFound = 1; + } + + if (modesFound == -1) return FALSE; + xf86PruneDriverModes(pScrn); + if (!modesFound || !pScrn->modes) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + return FALSE; + } + xf86SetCrtcForModes(pScrn, 0); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + + /* Set DPI */ + xf86SetDpi(pScrn, 0, 0); + + /* Get ScreenInit function */ +#ifdef USE_FB + mod = "fb"; + Sym = "fbScreenInit"; +#else + switch (pScrn->bitsPerPixel) { + case 8: mod = "cfb"; Sym = "cfbScreenInit"; break; + case 16: mod = "cfb16"; Sym = "cfb16ScreenInit"; break; + case 24: + if (info->pix24bpp == 24) { + mod = "cfb24"; Sym = "cfb24ScreenInit"; + } else { + mod = "xf24_32bpp"; Sym = "cfb24_32ScreenInit"; + } + break; + case 32: mod = "cfb32"; Sym = "cfb32ScreenInit"; break; + } +#endif + if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; + xf86LoaderReqSymbols(Sym, NULL); +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif + + info->CurrentLayout.displayWidth = pScrn->displayWidth; + info->CurrentLayout.mode = pScrn->currentMode; + + return TRUE; +} + +/* This is called by R128PreInit to initialize the hardware cursor. */ +static Bool R128PreInitCursor(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { + if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; + } + return TRUE; +} + +/* This is called by R128PreInit to initialize hardware acceleration. */ +static Bool R128PreInitAccel(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; + } + return TRUE; +} + +static Bool R128PreInitInt10(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); +#if 1 + if (xf86LoadSubModule(pScrn, "int10")) { + xf86Int10InfoPtr pInt; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); + pInt = xf86InitInt10(info->pEnt->index); + xf86FreeInt10(pInt); + } +#endif + return TRUE; +} + +#ifdef XF86DRI +static Bool R128PreInitDRI(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->IsPCI) { + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CCE into PIO mode\n"); + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else { + info->CCEMode = R128_DEFAULT_CCE_BM_MODE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n"); + info->CCE2D = TRUE; + } else { + info->CCE2D = FALSE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CCE Security checks disabled!!! **********\n"); + info->CCESecure = FALSE; + } else { + info->CCESecure = TRUE; + } + + info->agpMode = R128_DEFAULT_AGP_MODE; + info->agpSize = R128_DEFAULT_AGP_SIZE; + info->ringSize = R128_DEFAULT_RING_SIZE; + info->bufSize = R128_DEFAULT_BUFFER_SIZE; + info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; + + info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; + + if (!info->IsPCI) { + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_MODE, &(info->agpMode))) { + if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP Mode: %d\n", info->agpMode); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using AGP %dx mode\n", info->agpMode); + } + + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_SIZE, (int *)&(info->agpSize))) { + switch (info->agpSize) { + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP size: %d MB\n", info->agpSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_RING_SIZE, &(info->ringSize))) { + if (info->ringSize < 1 || info->ringSize >= (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal ring buffer size: %d MB\n", + info->ringSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_BUFFER_SIZE, &(info->bufSize))) { + if (info->bufSize < 1 || info->bufSize >= (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex/indirect buffers size: %d MB\n", + info->bufSize); + return FALSE; + } + if (info->bufSize > 2) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex/indirect buffers size: %d MB\n", + info->bufSize); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Clamping vertex/indirect buffers size to 2 MB\n"); + info->bufSize = 2; + } + } + + if (info->ringSize + info->bufSize + info->agpTexSize > + (int)info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Buffers are too big for requested AGP space\n"); + return FALSE; + } + + info->agpTexSize = info->agpSize - (info->ringSize + info->bufSize); + } + + if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT, + &(info->CCEusecTimeout))) { + /* This option checked by the R128 DRM kernel module */ + } + + return TRUE; +} +#endif + +static void +R128ProbeDDC(ScrnInfoPtr pScrn, int indx) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,indx); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + +/* R128PreInit is called once at server startup. */ +Bool R128PreInit(ScrnInfoPtr pScrn, int flags) +{ + R128InfoPtr info; + + R128TRACE(("R128PreInit\n")); + +#ifdef XFree86LOADER + /* + * Tell the loader about symbols from other modules that this module might + * refer to. + */ + LoaderRefSymLists(vgahwSymbols, +#ifdef USE_FB + fbSymbols, +#else + cfbSymbols, +#endif + xaaSymbols, + xf8_32bppSymbols, + ramdacSymbols, +#ifdef XF86DRI + drmSymbols, + driSymbols, +#endif + fbdevHWSymbols, + vbeSymbols, + /* ddcsymbols, */ + /* i2csymbols, */ + /* shadowSymbols, */ + NULL); +#endif + + if (pScrn->numEntities != 1) return FALSE; + + if (!R128GetRec(pScrn)) return FALSE; + + info = R128PTR(pScrn); + + info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (info->pEnt->location.type != BUS_PCI) goto fail; + + if (flags & PROBE_DETECT) { + R128ProbeDDC(pScrn, info->pEnt->index); + return TRUE; + } + + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + xf86LoaderReqSymLists(vgahwSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) { + R128FreeRec(pScrn); + return FALSE; + } + + info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); + info->PciTag = pciTag(info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PCI bus %d card %d func %d\n", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + + if (!R128PreInitVisual(pScrn)) goto fail; + + /* We can't do this until we have a + pScrn->display. */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, R128Options); + + if (!R128PreInitWeight(pScrn)) goto fail; + + if(xf86GetOptValInteger(R128Options, OPTION_VIDEO_KEY, &(info->videoKey))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", + info->videoKey); + } else { + info->videoKey = 0x1E; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_SHOW_CACHE, FALSE)) { + info->showCache = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShowCache enabled\n"); + } + + if (xf86ReturnOptValBool(R128Options, OPTION_FBDEV, FALSE)) { + info->FBDev = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using framebuffer device\n"); + } + + if (info->FBDev) { + /* check for linux framebuffer device */ + if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; + xf86LoaderReqSymLists(fbdevHWSymbols, NULL); + if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; + pScrn->SwitchMode = fbdevHWSwitchMode; + pScrn->AdjustFrame = fbdevHWAdjustFrame; + pScrn->EnterVT = R128EnterVTFBDev; + pScrn->LeaveVT = R128LeaveVTFBDev; + pScrn->ValidMode = fbdevHWValidMode; + } + + if (!info->FBDev) + if (!R128PreInitInt10(pScrn)) goto fail; + + if (!R128PreInitConfig(pScrn)) goto fail; + + if (!R128GetBIOSParameters(pScrn)) goto fail; + + if (!R128GetPLLParameters(pScrn)) goto fail; + + if (!R128PreInitDDC(pScrn)) goto fail; + + if (!R128PreInitGamma(pScrn)) goto fail; + + if (!R128PreInitModes(pScrn)) goto fail; + + if (!R128PreInitCursor(pScrn)) goto fail; + + if (!R128PreInitAccel(pScrn)) goto fail; + +#ifdef XF86DRI + if (!R128PreInitDRI(pScrn)) goto fail; +#endif + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + return TRUE; + + fail: + /* Pre-init failed. */ + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + vgaHWFreeHWRec(pScrn); + R128FreeRec(pScrn); + return FALSE; +} + +/* Load a palette. */ +static void R128LoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + int idx; + unsigned char r, g, b; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + if (info->CurrentLayout.depth == 15) { + /* 15bpp mode. This sends 32 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + g = colors[idx].green; + b = colors[idx].blue; + OUTPAL(idx * 8, r, g, b); + } + } + else if (info->CurrentLayout.depth == 16) { + /* 16bpp mode. This sends 64 values. */ + /* There are twice as many green values as + there are values for red and blue. So, + we take each red and blue pair, and + combine it with each of the two green + values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx / 2].red; + g = colors[idx].green; + b = colors[idx / 2].blue; + OUTPAL(idx * 4, r, g, b); + } + } + else { + /* 8bpp mode. This sends 256 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + b = colors[idx].blue; + g = colors[idx].green; + OUTPAL(idx, r, g, b); + } + } +} + +static void +R128BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + R128InfoPtr info = R128PTR(pScrn); + + pScreen->BlockHandler = info->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = R128BlockHandler; + + if(info->VideoTimerCallback) { + (*info->VideoTimerCallback)(pScrn, currentTime.milliseconds); + } +} + +/* Called at the start of each server generation. */ +Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + BoxRec MemBox; + + R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); + +#ifdef XF86DRI + /* Turn off the CCE for now. */ + info->CCEInUse = FALSE; +#endif + + if (!R128MapMem(pScrn)) return FALSE; + pScrn->fbOffset = 0; +#ifdef XF86DRI + info->fbX = 0; + info->fbY = 0; + info->frontOffset = 0; + info->frontPitch = pScrn->displayWidth; +#endif + + info->PaletteSavedOnVT = FALSE; + + R128Save(pScrn); + if (info->FBDev) { + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; + } else { + if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; + } + + R128SaveScreen(pScreen, SCREEN_SAVER_ON); + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* Visual setup */ + miClearVisualTypes(); + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, + pScrn->defaultVisual)) return FALSE; + miSetPixmapDepths (); + +#ifdef XF86DRI + /* Setup DRI after visuals have been + established, but before cfbScreenInit is + called. cfbScreenInit will eventually + call the driver's InitGLXVisuals call + back. */ + { + /* FIXME: When we move to dynamic allocation of back and depth + buffers, we will want to revisit the following check for 3 + times the virtual size of the screen below. */ + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + + if (xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { + xf86DrvMsg(scrnIndex, X_WARNING, + "Acceleration disabled, not initializing the DRI\n"); + info->directRenderingEnabled = FALSE; + } else if (maxy <= pScrn->virtualY * 3) { + xf86DrvMsg(scrnIndex, X_WARNING, + "Static buffer allocation failed -- " + "need at least %d kB video memory\n", + (pScrn->displayWidth * pScrn->virtualY * + info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024); + info->directRenderingEnabled = FALSE; + } else { + info->directRenderingEnabled = R128DRIScreenInit(pScreen); + } + } +#endif + +#ifdef USE_FB + if (!fbScreenInit (pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel)) + return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif +#else + switch (pScrn->bitsPerPixel) { + case 8: + if (!cfbScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 16: + if (!cfb16ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 24: + if (info->pix24bpp == 24) { + if (!cfb24ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return FALSE; + } else { + if (!cfb24_32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return FALSE; + } + break; + case 32: + if (!cfb32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Invalid bpp (%d)\n", pScrn->bitsPerPixel); + return FALSE; + } +#endif + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr visual; + + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + R128DGAInit(pScreen); + + /* Memory manager setup */ +#ifdef XF86DRI + if (info->directRenderingEnabled) { + FBAreaPtr fbarea; + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int cpp = info->CurrentLayout.pixel_bytes; + int bufferSize = pScrn->virtualY * width_bytes; + int l, total; + int scanlines; + + switch (info->CCEMode) { + case R128_DEFAULT_CCE_PIO_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in PIO mode\n"); + break; + case R128_DEFAULT_CCE_BM_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in BM mode\n"); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in UNKNOWN mode\n"); + break; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB AGP aperture\n", info->agpSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for the ring buffer\n", info->ringSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for vertex/indirect buffers\n", info->bufSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for AGP textures\n", info->agpTexSize); + + /* Try for front, back, depth, and two framebuffers worth of + * pixmap cache. Should be enough for a fullscreen background + * image plus some leftovers. + */ + info->textureSize = info->FbMapSize - 5 * bufferSize; + + /* If that gives us less than half the available memory, let's + * be greedy and grab some more. Sorry, I care more about 3D + * performance than playing nicely, and you'll get around a full + * framebuffer's worth of pixmap cache anyway. + */ + if ( info->textureSize < (int)info->FbMapSize / 2 ) { + info->textureSize = info->FbMapSize - 4 * bufferSize; + } + if ( info->textureSize > 0 ) { + l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + + /* Round the texture size up to the nearest whole number of + * texture regions. Again, be greedy about this, don't + * round down. + */ + info->log2TexGran = l; + info->textureSize = ((info->textureSize >> l) + 1) << l; + } else { + info->textureSize = 0; + } + + total = info->FbMapSize - info->textureSize; + scanlines = total / width_bytes; + if (scanlines > 8191) scanlines = 8191; + + /* Recalculate the texture offset and size to accomodate any + * rounding to a whole number of scanlines. + * FIXME: Is this actually needed? + */ + info->textureOffset = scanlines * width_bytes; + info->textureSize = info->FbMapSize - info->textureOffset; + + /* Set a minimum usable local texture heap size. This will fit + * two 256x256x32bpp textures. + */ + if ( info->textureSize < 512 * 1024 ) { + info->textureOffset = 0; + info->textureSize = 0; + } + + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + MemBox.y2 = scanlines; + + if (!xf86InitFBManager(pScreen, &MemBox)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + return FALSE; + } else { + int width, height; + + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + 2, 0, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved area from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); + } + if (xf86QueryLargestOffscreenArea(pScreen, &width, + &height, 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } + + /* Allocate the shared back buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved back buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->backX = fbarea->box.x1; + info->backY = fbarea->box.y1; + info->backOffset = (fbarea->box.y1 * width_bytes + + fbarea->box.x1 * cpp); + info->backPitch = pScrn->displayWidth; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); + info->backX = -1; + info->backY = -1; + info->backOffset = -1; + info->backPitch = -1; + } + + /* Allocate the shared depth buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY + 1, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->depthX = fbarea->box.x1; + info->depthY = fbarea->box.y1; + info->depthOffset = (fbarea->box.y1 * width_bytes + + fbarea->box.x1 * cpp); + info->depthPitch = pScrn->displayWidth; + info->spanOffset = ((fbarea->box.y2 - 1) * width_bytes + + fbarea->box.x1 * cpp); + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth span from (%d,%d) offset 0x%x\n", + fbarea->box.x1, fbarea->box.y2 - 1, info->spanOffset); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); + info->depthX = -1; + info->depthY = -1; + info->depthOffset = -1; + info->depthPitch = -1; + info->spanOffset = -1; + } + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures at offset 0x%x\n", + info->textureSize/1024, total); + } + else +#endif + { + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + MemBox.y2 = (info->FbMapSize + / (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes)); + /* The acceleration engine uses 14 bit + signed coordinates, so we can't have any + drawable caches beyond this region. */ + if (MemBox.y2 > 8191) MemBox.y2 = 8191; + + if (!xf86InitFBManager(pScreen, &MemBox)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + return FALSE; + } else { + int width, height; + FBAreaPtr fbarea; + + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + 2, 0, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved area from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); + } + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, + 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } + } + /* Backing store setup */ + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + /* Set Silken Mouse */ + xf86SetSilkenMouse(pScreen); + + /* Acceleration setup */ + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { + if (R128AccelInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); + info->accelOn = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Acceleration initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + + /* Cursor setup */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Hardware cursor setup */ + if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { + if (R128CursorInit(pScreen)) { + int width, height; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using hardware cursor (scanline %d)\n", + info->cursor_start / pScrn->displayWidth); + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, + 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + + /* Colormap setup */ + if (!miCreateDefColormap(pScreen)) return FALSE; + if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8, + (info->FBDev ? fbdevHWLoadPalette : + R128LoadPalette), NULL, + CMAP_PALETTED_TRUECOLOR + | CMAP_RELOAD_ON_MODE_SWITCH +#if 0 /* This option messes up text mode! (eich@suse.de) */ + | CMAP_LOAD_EVEN_IF_OFFSCREEN +#endif + )) return FALSE; + + /* DPMS setup */ +#ifdef DPMSExtension + if (!info->HasPanelRegs || info->CRTOnly) + xf86DPMSInit(pScreen, R128DisplayPowerManagementSet, 0); +#endif + + R128InitVideo(pScreen); + + /* Provide SaveScreen */ + pScreen->SaveScreen = R128SaveScreen; + + /* Wrap CloseScreen */ + info->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = R128CloseScreen; + + /* Note unused options */ + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + +#ifdef XF86DRI + /* DRI finalization */ + if (info->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have + done their thing, complete the DRI + setup. */ + info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen); + } + if (info->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } +#endif + + info->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = R128BlockHandler; + + return TRUE; +} + +/* Write common registers (initialized to 0). */ +static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_OVR_CLR, restore->ovr_clr); + OUTREG(R128_OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right); + OUTREG(R128_OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom); + OUTREG(R128_OV0_SCALE_CNTL, restore->ov0_scale_cntl); + OUTREG(R128_MPP_TB_CONFIG, restore->mpp_tb_config ); + OUTREG(R128_MPP_GP_CONFIG, restore->mpp_gp_config ); + OUTREG(R128_SUBPIC_CNTL, restore->subpic_cntl); + OUTREG(R128_VIPH_CONTROL, restore->viph_control); + OUTREG(R128_I2C_CNTL_1, restore->i2c_cntl_1); + OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl); + OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); + OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); + OUTREG(R128_BUS_CNTL, restore->bus_cntl); + OUTREG(R128_CONFIG_CNTL, restore->config_cntl); +} + +/* Write CRTC registers. */ +static void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_CRTC_GEN_CNTL, restore->crtc_gen_cntl); + + OUTREGP(R128_CRTC_EXT_CNTL, restore->crtc_ext_cntl, + R128_CRTC_VSYNC_DIS | R128_CRTC_HSYNC_DIS | R128_CRTC_DISPLAY_DIS); + + OUTREGP(R128_DAC_CNTL, restore->dac_cntl, + R128_DAC_RANGE_CNTL | R128_DAC_BLANKING); + + OUTREG(R128_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); + OUTREG(R128_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); + OUTREG(R128_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); + OUTREG(R128_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); + OUTREG(R128_CRTC_OFFSET, restore->crtc_offset); + OUTREG(R128_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); + OUTREG(R128_CRTC_PITCH, restore->crtc_pitch); +} + +/* Write flat panel registers */ +static void R128RestoreFPRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + CARD32 tmp; + + OUTREG(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); + OUTREG(R128_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); + OUTREG(R128_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); + OUTREG(R128_FP_GEN_CNTL, restore->fp_gen_cntl); + OUTREG(R128_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); + OUTREG(R128_FP_HORZ_STRETCH, restore->fp_horz_stretch); + OUTREG(R128_FP_PANEL_CNTL, restore->fp_panel_cntl); + OUTREG(R128_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); + OUTREG(R128_FP_VERT_STRETCH, restore->fp_vert_stretch); + OUTREG(R128_TMDS_CRC, restore->tmds_crc); + + tmp = INREG(R128_LVDS_GEN_CNTL); + if ((tmp & (R128_LVDS_ON | R128_LVDS_BLON)) == + (restore->lvds_gen_cntl & (R128_LVDS_ON | R128_LVDS_BLON))) { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + if (restore->lvds_gen_cntl & (R128_LVDS_ON | R128_LVDS_BLON)) { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl & ~R128_LVDS_BLON); + usleep(R128PTR(pScrn)->PanelPwrDly * 1000); + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl | R128_LVDS_BLON); + usleep(R128PTR(pScrn)->PanelPwrDly * 1000); + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } + } +} + +static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) +{ + while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); +} + +static void R128PLLWriteUpdate(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTPLLP(pScrn, R128_PPLL_REF_DIV, R128_PPLL_ATOMIC_UPDATE_W, 0xffff); +} + +/* Write PLL registers. */ +static void R128RestorePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_CLOCK_CNTL_INDEX, R128_PLL_DIV_SEL, 0xffff); + + OUTPLLP(pScrn, + R128_PPLL_CNTL, + R128_PPLL_RESET + | R128_PPLL_ATOMIC_UPDATE_EN + | R128_PPLL_VGA_ATOMIC_UPDATE_EN, + 0xffff); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLLP(pScrn, R128_PPLL_REF_DIV, + restore->ppll_ref_div, ~R128_PPLL_REF_DIV_MASK); + R128PLLWriteUpdate(pScrn); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLLP(pScrn, R128_PPLL_DIV_3, + restore->ppll_div_3, ~R128_PPLL_FB3_DIV_MASK); + R128PLLWriteUpdate(pScrn); + OUTPLLP(pScrn, R128_PPLL_DIV_3, + restore->ppll_div_3, ~R128_PPLL_POST3_DIV_MASK); + R128PLLWriteUpdate(pScrn); + + R128PLLWaitForReadUpdateComplete(pScrn); + OUTPLL(R128_HTOTAL_CNTL, restore->htotal_cntl); + R128PLLWriteUpdate(pScrn); + + OUTPLLP(pScrn, R128_PPLL_CNTL, 0, ~R128_PPLL_RESET); + + R128TRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", + restore->ppll_ref_div, + restore->ppll_div_3, + restore->htotal_cntl, + INPLL(pScrn, R128_PPLL_CNTL))); + R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", + restore->ppll_ref_div & R128_PPLL_REF_DIV_MASK, + restore->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, + (restore->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Write DDA registers. */ +static void R128RestoreDDARegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREG(R128_DDA_CONFIG, restore->dda_config); + OUTREG(R128_DDA_ON_OFF, restore->dda_on_off); +} + +/* Write palette data. */ +static void R128RestorePalette(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + if (!restore->palette_valid) return; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + OUTPAL_START(0); + for (i = 0; i < 256; i++) OUTPAL_NEXT_CARD32(restore->palette[i]); +} + +/* Write out state to define a new video mode. */ +static void R128RestoreMode(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128RestoreMode(%p)\n", restore)); + R128RestoreCommonRegisters(pScrn, restore); + R128RestoreCrtcRegisters(pScrn, restore); + if (info->HasPanelRegs) + R128RestoreFPRegisters(pScrn, restore); + if (!info->HasPanelRegs || info->CRTOnly) + R128RestorePLLRegisters(pScrn, restore); + R128RestoreDDARegisters(pScrn, restore); + R128RestorePalette(pScrn, restore); +} + +/* Read common registers. */ +static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->ovr_clr = INREG(R128_OVR_CLR); + save->ovr_wid_left_right = INREG(R128_OVR_WID_LEFT_RIGHT); + save->ovr_wid_top_bottom = INREG(R128_OVR_WID_TOP_BOTTOM); + save->ov0_scale_cntl = INREG(R128_OV0_SCALE_CNTL); + save->mpp_tb_config = INREG(R128_MPP_TB_CONFIG); + save->mpp_gp_config = INREG(R128_MPP_GP_CONFIG); + save->subpic_cntl = INREG(R128_SUBPIC_CNTL); + save->viph_control = INREG(R128_VIPH_CONTROL); + save->i2c_cntl_1 = INREG(R128_I2C_CNTL_1); + save->gen_int_cntl = INREG(R128_GEN_INT_CNTL); + save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL); + save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL); + save->bus_cntl = INREG(R128_BUS_CNTL); + save->config_cntl = INREG(R128_CONFIG_CNTL); +} + +/* Read CRTC registers. */ +static void R128SaveCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->crtc_gen_cntl = INREG(R128_CRTC_GEN_CNTL); + save->crtc_ext_cntl = INREG(R128_CRTC_EXT_CNTL); + save->dac_cntl = INREG(R128_DAC_CNTL); + save->crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP); + save->crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID); + save->crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP); + save->crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID); + save->crtc_offset = INREG(R128_CRTC_OFFSET); + save->crtc_offset_cntl = INREG(R128_CRTC_OFFSET_CNTL); + save->crtc_pitch = INREG(R128_CRTC_PITCH); +} + +/* Read flat panel registers */ +static void R128SaveFPRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->crtc2_gen_cntl = INREG(R128_CRTC2_GEN_CNTL); + save->fp_crtc_h_total_disp = INREG(R128_FP_CRTC_H_TOTAL_DISP); + save->fp_crtc_v_total_disp = INREG(R128_FP_CRTC_V_TOTAL_DISP); + save->fp_gen_cntl = INREG(R128_FP_GEN_CNTL); + save->fp_h_sync_strt_wid = INREG(R128_FP_H_SYNC_STRT_WID); + save->fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); + save->fp_panel_cntl = INREG(R128_FP_PANEL_CNTL); + save->fp_v_sync_strt_wid = INREG(R128_FP_V_SYNC_STRT_WID); + save->fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); + save->lvds_gen_cntl = INREG(R128_LVDS_GEN_CNTL); + save->tmds_crc = INREG(R128_TMDS_CRC); +} + +/* Read PLL registers. */ +static void R128SavePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + save->ppll_ref_div = INPLL(pScrn, R128_PPLL_REF_DIV); + save->ppll_div_3 = INPLL(pScrn, R128_PPLL_DIV_3); + save->htotal_cntl = INPLL(pScrn, R128_HTOTAL_CNTL); + + R128TRACE(("Read: 0x%08x 0x%08x 0x%08x\n", + save->ppll_ref_div, + save->ppll_div_3, + save->htotal_cntl)); + R128TRACE(("Read: rd=%d, fd=%d, pd=%d\n", + save->ppll_ref_div & R128_PPLL_REF_DIV_MASK, + save->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, + (save->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Read DDA registers. */ +static void R128SaveDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + save->dda_config = INREG(R128_DDA_CONFIG); + save->dda_on_off = INREG(R128_DDA_ON_OFF); +} + +/* Read palette data. */ +static void R128SavePalette(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); + + INPAL_START(0); + for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT(); + save->palette_valid = TRUE; +} + +/* Save state that defines current video mode. */ +static void R128SaveMode(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128TRACE(("R128SaveMode(%p)\n", save)); + + R128SaveCommonRegisters(pScrn, save); + R128SaveCrtcRegisters(pScrn, save); + if (R128PTR(pScrn)->HasPanelRegs) + R128SaveFPRegisters(pScrn, save); + R128SavePLLRegisters(pScrn, save); + R128SaveDDARegisters(pScrn, save); + R128SavePalette(pScrn, save); + + R128TRACE(("R128SaveMode returns %p\n", save)); +} + +/* Save everything needed to restore the original VC state. */ +static void R128Save(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SavePtr save = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + R128TRACE(("R128Save\n")); + if (info->FBDev) { + fbdevHWSave(pScrn); + return; + } + vgaHWUnlock(hwp); + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ + vgaHWLock(hwp); + + R128SaveMode(pScrn, save); + + save->dp_datatype = INREG(R128_DP_DATATYPE); + save->gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); + save->clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); + save->amcgpio_en_reg = INREG(R128_AMCGPIO_EN_REG); + save->amcgpio_mask = INREG(R128_AMCGPIO_MASK); +} + +/* Restore the original (text) mode. */ +static void R128Restore(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SavePtr restore = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + R128TRACE(("R128Restore\n")); + if (info->FBDev) { + fbdevHWRestore(pScrn); + return; + } + + R128Blank(pScrn); + OUTREG(R128_AMCGPIO_MASK, restore->amcgpio_mask); + OUTREG(R128_AMCGPIO_EN_REG, restore->amcgpio_en_reg); + OUTREG(R128_CLOCK_CNTL_INDEX, restore->clock_cntl_index); + OUTREG(R128_GEN_RESET_CNTL, restore->gen_reset_cntl); + OUTREG(R128_DP_DATATYPE, restore->dp_datatype); + + R128RestoreMode(pScrn, restore); + vgaHWUnlock(hwp); + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); + vgaHWLock(hwp); + + R128WaitForVerticalSync(pScrn); + R128Unblank(pScrn); +} + +/* Define common registers for requested video mode. */ +static void R128InitCommonRegisters(R128SavePtr save, R128InfoPtr info) +{ + save->ovr_clr = 0; + save->ovr_wid_left_right = 0; + save->ovr_wid_top_bottom = 0; + save->ov0_scale_cntl = 0; + save->mpp_tb_config = 0; + save->mpp_gp_config = 0; + save->subpic_cntl = 0; + save->viph_control = 0; + save->i2c_cntl_1 = 0; + save->gen_int_cntl = 0; + save->cap0_trig_cntl = 0; + save->cap1_trig_cntl = 0; + save->bus_cntl = info->BusCntl; + /* + * If bursts are enabled, turn on discards and aborts + */ + if (save->bus_cntl & (R128_BUS_WRT_BURST|R128_BUS_READ_BURST)) + save->bus_cntl |= R128_BUS_RD_DISCARD_EN | R128_BUS_RD_ABORT_EN; +} + +/* Define CRTC registers for requested video mode. */ +static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save, + DisplayModePtr mode, R128InfoPtr info) +{ + int format; + int hsync_start; + int hsync_wid; + int hsync_fudge; + int vsync_wid; + int bytpp; + int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; + int hsync_fudge_fp[] = { 0x12, 0x11, 0x09, 0x09, 0x05, 0x05 }; + int hsync_fudge_fp_crt[] = { 0x12, 0x10, 0x08, 0x08, 0x04, 0x04 }; + + switch (info->CurrentLayout.pixel_code) { + case 4: format = 1; bytpp = 0; break; + case 8: format = 2; bytpp = 1; break; + case 15: format = 3; bytpp = 2; break; /* 555 */ + case 16: format = 4; bytpp = 2; break; /* 565 */ + case 24: format = 5; bytpp = 3; break; /* RGB */ + case 32: format = 6; bytpp = 4; break; /* xRGB */ + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); + return FALSE; + } + R128TRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp)); + + if (info->HasPanelRegs) + if (info->CRTOnly) hsync_fudge = hsync_fudge_fp_crt[format-1]; + else hsync_fudge = hsync_fudge_fp[format-1]; + else hsync_fudge = hsync_fudge_default[format-1]; + + save->crtc_gen_cntl = (R128_CRTC_EXT_DISP_EN + | R128_CRTC_EN + | (format << 8) + | ((mode->Flags & V_DBLSCAN) + ? R128_CRTC_DBL_SCAN_EN + : 0) + | ((mode->Flags & V_INTERLACE) + ? R128_CRTC_INTERLACE_EN + : 0)); + + save->crtc_ext_cntl = R128_VGA_ATI_LINEAR | R128_XCRT_CNT_EN; + save->dac_cntl = (R128_DAC_MASK_ALL + | R128_DAC_VGA_ADR_EN + | (info->dac6bits ? 0 : R128_DAC_8BIT_EN)); + + save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) + | (((mode->CrtcHDisplay / 8) - 1) << 16)); + + hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; + if (!hsync_wid) hsync_wid = 1; + if (hsync_wid > 0x3f) hsync_wid = 0x3f; + + hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; + + save->crtc_h_sync_strt_wid = ((hsync_start & 0xfff) + | (hsync_wid << 16) + | ((mode->Flags & V_NHSYNC) + ? R128_CRTC_H_SYNC_POL + : 0)); + +#if 1 + /* This works for double scan mode. */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay - 1) << 16)); +#else + /* This is what cce/nbmode.c example code + does -- is this correct? */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay + * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) + << 16)); +#endif + + vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; + if (!vsync_wid) vsync_wid = 1; + if (vsync_wid > 0x1f) vsync_wid = 0x1f; + + save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) + | (vsync_wid << 16) + | ((mode->Flags & V_NVSYNC) + ? R128_CRTC_V_SYNC_POL + : 0)); + save->crtc_offset = 0; + save->crtc_offset_cntl = 0; + save->crtc_pitch = info->CurrentLayout.displayWidth / 8; + + R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", + save->crtc_pitch, pScrn->virtualX, info->CurrentLayout.displayWidth)); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + /* Change the endianness of the aperture */ + switch (info->CurrentLayout.pixel_code) { + case 15: + case 16: save->config_cntl |= APER_0_BIG_ENDIAN_16BPP_SWAP; break; + case 32: save->config_cntl |= APER_0_BIG_ENDIAN_32BPP_SWAP; break; + default: break; + } +#endif + + return TRUE; +} + +/* Define CRTC registers for requested video mode. */ +static void R128InitFPRegisters(R128SavePtr orig, R128SavePtr save, + DisplayModePtr mode, R128InfoPtr info) +{ + int xres = mode->CrtcHDisplay; + int yres = mode->CrtcVDisplay; + float Hratio, Vratio; + + if (info->CRTOnly) { + save->crtc_ext_cntl |= R128_CRTC_CRT_ON; + save->crtc2_gen_cntl = 0; + save->fp_gen_cntl = orig->fp_gen_cntl; + save->fp_gen_cntl &= ~(R128_FP_FPON | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN); + save->fp_gen_cntl |= (R128_FP_SEL_CRTC2 | + R128_FP_CRTC_DONT_SHADOW_VPAR); + save->fp_panel_cntl = orig->fp_panel_cntl & ~R128_FP_DIGON; + save->lvds_gen_cntl = orig->lvds_gen_cntl & ~(R128_LVDS_ON | + R128_LVDS_BLON); + return; + } + + if (xres > info->PanelXRes) xres = info->PanelXRes; + if (yres > info->PanelYRes) yres = info->PanelYRes; + + Hratio = (float)xres/(float)info->PanelXRes; + Vratio = (float)yres/(float)info->PanelYRes; + + save->fp_horz_stretch = + (((((int)(Hratio * R128_HORZ_STRETCH_RATIO_MAX + 0.5)) + & R128_HORZ_STRETCH_RATIO_MASK) << R128_HORZ_STRETCH_RATIO_SHIFT) | + (orig->fp_horz_stretch & (R128_HORZ_PANEL_SIZE | + R128_HORZ_FP_LOOP_STRETCH | + R128_HORZ_STRETCH_RESERVED))); + save->fp_horz_stretch &= ~R128_HORZ_AUTO_RATIO_FIX_EN; + if (Hratio == 1.0) save->fp_horz_stretch &= ~(R128_HORZ_STRETCH_BLEND | + R128_HORZ_STRETCH_ENABLE); + else save->fp_horz_stretch |= (R128_HORZ_STRETCH_BLEND | + R128_HORZ_STRETCH_ENABLE); + + save->fp_vert_stretch = + (((((int)(Vratio * R128_VERT_STRETCH_RATIO_MAX + 0.5)) + & R128_VERT_STRETCH_RATIO_MASK) << R128_VERT_STRETCH_RATIO_SHIFT) | + (orig->fp_vert_stretch & (R128_VERT_PANEL_SIZE | + R128_VERT_STRETCH_RESERVED))); + save->fp_vert_stretch &= ~R128_VERT_AUTO_RATIO_EN; + if (Vratio == 1.0) save->fp_vert_stretch &= ~(R128_VERT_STRETCH_ENABLE | + R128_VERT_STRETCH_BLEND); + else save->fp_vert_stretch |= (R128_VERT_STRETCH_ENABLE | + R128_VERT_STRETCH_BLEND); + + save->fp_gen_cntl = (orig->fp_gen_cntl & ~(R128_FP_SEL_CRTC2 | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN)); + if (orig->fp_gen_cntl & R128_FP_DETECT_SENSE) { + save->fp_gen_cntl |= (R128_FP_CRTC_DONT_SHADOW_VPAR | + R128_FP_TDMS_EN); + } + + save->fp_panel_cntl = orig->fp_panel_cntl; + save->lvds_gen_cntl = orig->lvds_gen_cntl; + + save->tmds_crc = orig->tmds_crc; + + /* Disable CRT output by disabling CRT output and setting the CRT + DAC to use CRTC2, which we set to 0's. In the future, we will + want to use the dual CRTC capabilities of the R128 to allow both + the flat panel and external CRT to either simultaneously display + the same image or display two different images. */ + save->crtc_ext_cntl &= ~R128_CRTC_CRT_ON; + save->dac_cntl |= R128_DAC_CRT_SEL_CRTC2; + save->crtc2_gen_cntl = 0; + + /* WARNING: Be careful about turning on the flat panel */ +#if 1 + save->lvds_gen_cntl |= (R128_LVDS_ON | R128_LVDS_BLON); +#else + save->fp_panel_cntl |= (R128_FP_DIGON | R128_FP_BLON); + save->fp_gen_cntl |= (R128_FP_FPON); +#endif + + save->fp_crtc_h_total_disp = save->crtc_h_total_disp; + save->fp_crtc_v_total_disp = save->crtc_v_total_disp; + save->fp_h_sync_strt_wid = save->crtc_h_sync_strt_wid; + save->fp_v_sync_strt_wid = save->crtc_v_sync_strt_wid; +} + +/* Define PLL registers for requested video mode. */ +static void R128InitPLLRegisters(R128SavePtr save, R128PLLPtr pll, + double dot_clock) +{ + unsigned long freq = dot_clock * 100; + struct { + int divider; + int bitvalue; + } *post_div, + post_divs[] = { + /* From RAGE 128 VR/RAGE 128 GL Register + Reference Manual (Technical Reference + Manual P/N RRG-G04100-C Rev. 0.04), page + 3-17 (PLL_DIV_[3:0]). */ + { 1, 0 }, /* VCLK_SRC */ + { 2, 1 }, /* VCLK_SRC/2 */ + { 4, 2 }, /* VCLK_SRC/4 */ + { 8, 3 }, /* VCLK_SRC/8 */ + + { 3, 4 }, /* VCLK_SRC/3 */ + /* bitvalue = 5 is reserved */ + { 6, 6 }, /* VCLK_SRC/6 */ + { 12, 7 }, /* VCLK_SRC/12 */ + { 0, 0 } + }; + + if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; + if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; + + for (post_div = &post_divs[0]; post_div->divider; ++post_div) { + save->pll_output_freq = post_div->divider * freq; + if (save->pll_output_freq >= pll->min_pll_freq + && save->pll_output_freq <= pll->max_pll_freq) break; + } + + save->dot_clock_freq = freq; + save->feedback_div = R128Div(pll->reference_div * save->pll_output_freq, + pll->reference_freq); + save->post_div = post_div->divider; + + R128TRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", + save->dot_clock_freq, + save->pll_output_freq, + save->feedback_div, + save->post_div)); + + save->ppll_ref_div = pll->reference_div; + save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); + save->htotal_cntl = 0; +} + +/* Define DDA registers for requested video mode. */ +static Bool R128InitDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save, + R128PLLPtr pll, R128InfoPtr info) +{ + int DisplayFifoWidth = 128; + int DisplayFifoDepth = 32; + int XclkFreq; + int VclkFreq; + int XclksPerTransfer; + int XclksPerTransferPrecise; + int UseablePrecision; + int Roff; + int Ron; + + XclkFreq = pll->xclk; + + VclkFreq = R128Div(pll->reference_freq * save->feedback_div, + pll->reference_div * save->post_div); + + XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth, + VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); + + UseablePrecision = R128MinBits(XclksPerTransfer) + 1; + + XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth) + << (11 - UseablePrecision), + VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); + + Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); + + Ron = (4 * info->ram->MB + + 3 * MAX(info->ram->Trcd - 2, 0) + + 2 * info->ram->Trp + + info->ram->Twr + + info->ram->CL + + info->ram->Tr2w + + XclksPerTransfer) << (11 - UseablePrecision); + + if (Ron + info->ram->Rloop >= Roff) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", + Ron, info->ram->Rloop, Roff); + return FALSE; + } + + save->dda_config = (XclksPerTransferPrecise + | (UseablePrecision << 16) + | (info->ram->Rloop << 20)); + + save->dda_on_off = (Ron << 16) | Roff; + + R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", + XclkFreq, + VclkFreq, + XclksPerTransfer, + XclksPerTransferPrecise, + UseablePrecision)); + R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n", + Roff, Ron, info->ram->Rloop)); + + return TRUE; +} + + +/* Define initial palette for requested video mode. This doesn't do + anything for XFree86 4.0. */ +static void R128InitPalette(R128SavePtr save) +{ + save->palette_valid = FALSE; +} + +/* Define registers for a requested video mode. */ +static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save) +{ + R128InfoPtr info = R128PTR(pScrn); + double dot_clock = mode->Clock/1000.0; + +#if R128_DEBUG + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->HDisplay, + mode->HSyncStart, + mode->HSyncEnd, + mode->HTotal, + + mode->VDisplay, + mode->VSyncStart, + mode->VSyncEnd, + mode->VTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->CrtcHDisplay, + mode->CrtcHSyncStart, + mode->CrtcHSyncEnd, + mode->CrtcHTotal, + + mode->CrtcVDisplay, + mode->CrtcVSyncStart, + mode->CrtcVSyncEnd, + mode->CrtcVTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); +#endif + + info->Flags = mode->Flags; + + R128InitCommonRegisters(save, info); + if (!R128InitCrtcRegisters(pScrn, save, mode, info)) return FALSE; + if (info->HasPanelRegs) + R128InitFPRegisters(&info->SavedReg, save, mode, info); + R128InitPLLRegisters(save, &info->pll, dot_clock); + if (!R128InitDDARegisters(pScrn, save, &info->pll, info)) + return FALSE; + if (!info->PaletteSavedOnVT) R128InitPalette(save); + + R128TRACE(("R128Init returns %p\n", save)); + return TRUE; +} + +/* Initialize a new mode. */ +static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE; + /* FIXME? DRILock/DRIUnlock here? */ + pScrn->vtSema = TRUE; + R128Blank(pScrn); + R128RestoreMode(pScrn, &info->ModeReg); + R128Unblank(pScrn); + + info->CurrentLayout.mode = mode; + + return TRUE; +} + +static Bool R128SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool unblank; + + unblank = xf86IsUnblank(mode); + if (unblank) + SetTimeSinceLastInputEvent(); + + if ((pScrn != NULL) && pScrn->vtSema) { + if (unblank) + R128Unblank(pScrn); + else + R128Blank(pScrn); + } + return TRUE; +} + +Bool R128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return R128ModeInit(xf86Screens[scrnIndex], mode); +} + +/* Used to disallow modes that are not supported by the hardware. */ +int R128ValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flag) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + if (info->HasPanelRegs) { + if (mode->Flags & V_INTERLACE) return MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN) return MODE_NO_DBLESCAN; + } + + if (info->HasPanelRegs && !info->CRTOnly && info->VBIOS) { + int i; + for (i = info->FPBIOSstart+64; R128_BIOS16(i) != 0; i += 2) { + int j = R128_BIOS16(i); + + if (mode->CrtcHDisplay == R128_BIOS16(j) && + mode->CrtcVDisplay == R128_BIOS16(j+2)) { + /* Assume we are using expanded mode */ + if (R128_BIOS16(j+5)) j = R128_BIOS16(j+5); + else j += 9; + + mode->Clock = (CARD32)R128_BIOS16(j) * 10; + + mode->HDisplay = mode->CrtcHDisplay = + ((R128_BIOS16(j+10) & 0x01ff)+1)*8; + mode->HSyncStart = mode->CrtcHSyncStart = + ((R128_BIOS16(j+12) & 0x01ff)+1)*8; + mode->HSyncEnd = mode->CrtcHSyncEnd = + mode->CrtcHSyncStart + (R128_BIOS8(j+14) & 0x1f); + mode->HTotal = mode->CrtcHTotal = + ((R128_BIOS16(j+8) & 0x01ff)+1)*8; + + mode->VDisplay = mode->CrtcVDisplay = + (R128_BIOS16(j+17) & 0x07ff)+1; + mode->VSyncStart = mode->CrtcVSyncStart = + (R128_BIOS16(j+19) & 0x07ff)+1; + mode->VSyncEnd = mode->CrtcVSyncEnd = + mode->CrtcVSyncStart + ((R128_BIOS16(j+19) >> 11) & 0x1f); + mode->VTotal = mode->CrtcVTotal = + (R128_BIOS16(j+15) & 0x07ff)+1; + + return MODE_OK; + } + } + return MODE_NOMODE; + } + + return MODE_OK; +} + +/* Adjust viewport into virtual desktop such that (0,0) in viewport space + is (x,y) in virtual space. */ +void R128AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int Base; + + if(info->showCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + Base = y * info->CurrentLayout.displayWidth + x; + + switch (info->CurrentLayout.pixel_code) { + case 15: + case 16: Base *= 2; break; + case 24: Base *= 3; break; + case 32: Base *= 4; break; + } + + Base &= ~7; /* 3 lower bits are always 0 */ + + if (info->CurrentLayout.pixel_code == 24) + Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */ + + OUTREG(R128_CRTC_OFFSET, Base); +} + +/* Called when VT switching back to the X server. Reinitialize the video + mode. */ +Bool R128EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128EnterVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + R128CCE_START(pScrn, info); + DRIUnlock(pScrn->pScreen); + } +#endif + if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; + if (info->accelOn) + R128EngineInit(pScrn); + + info->PaletteSavedOnVT = FALSE; + R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +/* Called when VT switching away from the X server. Restore the original + text mode. */ +void R128LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr save = &info->ModeReg; + + R128TRACE(("R128LeaveVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + DRILock(pScrn->pScreen, 0); + R128CCE_STOP(pScrn, info); + } +#endif + R128SavePalette(pScrn, save); + info->PaletteSavedOnVT = TRUE; + R128Restore(pScrn); +} + +static Bool +R128EnterVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr restore = &info->SavedReg; + fbdevHWEnterVT(scrnIndex,flags); + R128RestorePalette(pScrn,restore); + R128EngineInit(pScrn); + return TRUE; +} + +static void R128LeaveVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr save = &info->SavedReg; + R128SavePalette(pScrn,save); + fbdevHWLeaveVT(scrnIndex,flags); +} + +/* Called at the end of each server generation. Restore the original text + mode, unmap video memory, and unwrap and call the saved CloseScreen + function. */ +static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + + R128TRACE(("R128CloseScreen\n")); + +#ifdef XF86DRI + /* Disable direct rendering */ + if (info->directRenderingEnabled) { + R128DRICloseScreen(pScreen); + info->directRenderingEnabled = FALSE; + } +#endif + + if (pScrn->vtSema) { + R128Restore(pScrn); + R128UnmapMem(pScrn); + } + + if (info->accel) XAADestroyInfoRec(info->accel); + info->accel = NULL; + + if (info->scratch_save) xfree(info->scratch_save); + info->scratch_save = NULL; + + if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); + info->cursor = NULL; + + if (info->DGAModes) xfree(info->DGAModes); + info->DGAModes = NULL; + + if (info->adaptor) { + xfree(info->adaptor->pPortPrivates[0].ptr); + xf86XVFreeVideoAdaptorRec(info->adaptor); + info->adaptor = NULL; + } + + pScrn->vtSema = FALSE; + + pScreen->BlockHandler = info->BlockHandler; + pScreen->CloseScreen = info->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + +void R128FreeScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + R128TRACE(("R128FreeScreen\n")); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(pScrn); + R128FreeRec(pScrn); +} + +#ifdef DPMSExtension +/* Sets VESA Display Power Management Signaling (DPMS) Mode. */ +static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int mask = (R128_CRTC_DISPLAY_DIS + | R128_CRTC_HSYNC_DIS + | R128_CRTC_VSYNC_DIS); + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + OUTREGP(R128_CRTC_EXT_CNTL, 0, ~mask); + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On */ + OUTREGP(R128_CRTC_EXT_CNTL, + R128_CRTC_DISPLAY_DIS | R128_CRTC_HSYNC_DIS, ~mask); + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off */ + OUTREGP(R128_CRTC_EXT_CNTL, + R128_CRTC_DISPLAY_DIS | R128_CRTC_VSYNC_DIS, ~mask); + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + OUTREGP(R128_CRTC_EXT_CNTL, mask, ~mask); + break; + } +} +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c:1.1 --- /dev/null Mon Dec 18 14:30:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c Thu Nov 2 11:55:36 2000 @@ -0,0 +1,84 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_misc.c,v 1.1 2000/11/02 16:55:36 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef XFree86LOADER + +#include "ativersion.h" + +#include "r128_version.h" + +#include "xf86.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo R128VersionRec = +{ + R128_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + R128_VERSION_MAJOR, R128_VERSION_MINOR, R128_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * R128Setup -- + * + * This function is called every time the module is loaded. + */ +static pointer +R128Setup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called r128ModuleData */ +XF86ModuleData r128ModuleData = +{ + &R128VersionRec, + R128Setup, + NULL +}; + +#endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c:1.6 --- /dev/null Mon Dec 18 14:30:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c Tue Dec 12 21:45:00 2000 @@ -0,0 +1,219 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.c,v 1.6 2000/12/13 02:45:00 tsi Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#include "atimodule.h" +#include "ativersion.h" + +#include "r128_probe.h" +#include "r128_version.h" + +#include "xf86PciInfo.h" + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86Resources.h" + +SymTabRec R128Chipsets[] = { + { PCI_CHIP_RAGE128RE, "ATI Rage 128 RE (PCI)" }, + { PCI_CHIP_RAGE128RF, "ATI Rage 128 RF (AGP)" }, + { PCI_CHIP_RAGE128RG, "ATI Rage 128 RG (AGP)" }, + { PCI_CHIP_RAGE128RK, "ATI Rage 128 RK (PCI)" }, + { PCI_CHIP_RAGE128RL, "ATI Rage 128 RL (AGP)" }, + { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro PF (AGP)" }, + { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility LE (PCI)" }, + { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility LF (AGP)" }, + { PCI_CHIP_RAGE128MF, "ATI Rage 128 Mobility MF (AGP)" }, + { PCI_CHIP_RAGE128ML, "ATI Rage 128 Mobility ML (AGP)" }, + { -1, NULL } +}; + +PciChipsets R128PciChipsets[] = { + { PCI_CHIP_RAGE128RE, PCI_CHIP_RAGE128RE, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RF, PCI_CHIP_RAGE128RF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RG, PCI_CHIP_RAGE128RG, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RK, PCI_CHIP_RAGE128RK, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128RL, PCI_CHIP_RAGE128RL, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128PF, PCI_CHIP_RAGE128PF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128MF, PCI_CHIP_RAGE128MF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128ML, PCI_CHIP_RAGE128ML, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +/* Return the options for supported chipset 'n'; NULL otherwise */ +OptionInfoPtr +R128AvailableOptions(int chipid, int busid) +{ + int i; + + /* + * Return options defined in the r128 submodule which will have been + * loaded by this point. + */ + for (i = 0; R128PciChipsets[i].PCIid > 0; i++) { + if (chipid == R128PciChipsets[i].PCIid) + return R128Options; + } + return NULL; +} + +/* Return the string name for supported chipset 'n'; NULL otherwise. */ +void +R128Identify(int flags) +{ + xf86PrintChipsets(R128_NAME, + "Driver for ATI Rage 128 chipsets", + R128Chipsets); +} + +/* Return TRUE if chipset is present; FALSE otherwise. */ +Bool +R128Probe(DriverPtr drv, int flags) +{ + int numUsed; + int numDevSections, nATIGDev, nR128GDev; + int *usedChips; + GDevPtr *devSections, *ATIGDevs, *R128GDevs; + EntityInfoPtr pEnt; + Bool foundScreen = FALSE; + int i; + + if (!xf86GetPciVideoInfo()) return FALSE; + + /* Collect unclaimed device sections for both driver names */ + nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs); + nR128GDev = xf86MatchDevice(R128_NAME, &R128GDevs); + + if (!(numDevSections = nATIGDev + nR128GDev)) return FALSE; + + if (!ATIGDevs) { + if (!(devSections = R128GDevs)) + numDevSections = 1; + else + numDevSections = nR128GDev; + } if (!R128GDevs) { + devSections = ATIGDevs; + numDevSections = nATIGDev; + } else { + /* Combine into one list */ + devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr)); + (void)memcpy(devSections, + ATIGDevs, nATIGDev * sizeof(GDevPtr)); + (void)memcpy(devSections + nATIGDev, + R128GDevs, nR128GDev * sizeof(GDevPtr)); + devSections[numDevSections] = NULL; + xfree(ATIGDevs); + xfree(R128GDevs); + } + + numUsed = xf86MatchPciInstances(R128_NAME, + PCI_VENDOR_ATI, + R128Chipsets, + R128PciChipsets, + devSections, + numDevSections, + drv, + &usedChips); + + if (numUsed<=0) return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + pEnt = xf86GetEntityInfo(usedChips[i]); + + if (pEnt->active) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + +#ifdef XFree86LOADER + if (!xf86LoadSubModule(pScrn, "r128")) { + xf86Msg(X_ERROR, + R128_NAME ": Failed to load \"r128\" module.\n"); + xf86DeleteScreen(pScrn->scrnIndex, 0); + continue; + } + + xf86LoaderReqSymLists(R128Symbols, NULL); + + /* Workaround for possible loader bug */ +# define R128PreInit \ + (xf86PreInitProc*) LoaderSymbol("R128PreInit") +# define R128ScreenInit \ + (xf86ScreenInitProc*) LoaderSymbol("R128ScreenInit") +# define R128SwitchMode \ + (xf86SwitchModeProc*) LoaderSymbol("R128SwitchMode") +# define R128AdjustFrame \ + (xf86AdjustFrameProc*)LoaderSymbol("R128AdjustFrame") +# define R128EnterVT \ + (xf86EnterVTProc*) LoaderSymbol("R128EnterVT") +# define R128LeaveVT \ + (xf86LeaveVTProc*) LoaderSymbol("R128LeaveVT") +# define R128FreeScreen \ + (xf86FreeScreenProc*) LoaderSymbol("R128FreeScreen") +# define R128ValidMode \ + (xf86ValidModeProc*) LoaderSymbol("R128ValidMode") + +#endif + + pScrn->driverVersion = R128_VERSION_CURRENT; + pScrn->driverName = R128_DRIVER_NAME; + pScrn->name = R128_NAME; + pScrn->Probe = R128Probe; + pScrn->PreInit = R128PreInit; + pScrn->ScreenInit = R128ScreenInit; + pScrn->SwitchMode = R128SwitchMode; + pScrn->AdjustFrame = R128AdjustFrame; + pScrn->EnterVT = R128EnterVT; + pScrn->LeaveVT = R128LeaveVT; + pScrn->FreeScreen = R128FreeScreen; + pScrn->ValidMode = R128ValidMode; + + foundScreen = TRUE; + + xf86ConfigActivePciEntity(pScrn, usedChips[i], R128PciChipsets, + 0, 0, 0, 0, 0); + } + xfree(pEnt); + } + + xfree(usedChips); + xfree(devSections); + + return foundScreen; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h:1.3 --- /dev/null Mon Dec 18 14:30:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h Sat Nov 18 14:37:11 2000 @@ -0,0 +1,75 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_probe.h,v 1.3 2000/11/18 19:37:11 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#ifndef _R128_PROBE_H_ +#define _R128_PROBE_H_ 1 + +#include "atiproto.h" + +#include "xf86str.h" + +/* r128_probe.c */ +extern OptionInfoPtr R128AvailableOptions + FunctionPrototype((int, int)); +extern void R128Identify + FunctionPrototype((int)); +extern Bool R128Probe + FunctionPrototype((DriverPtr, int)); + +extern SymTabRec R128Chipsets[]; +extern PciChipsets R128PciChipsets[]; + +/* r128_driver.c */ +extern Bool R128PreInit + FunctionPrototype((ScrnInfoPtr, int)); +extern Bool R128ScreenInit + FunctionPrototype((int, ScreenPtr, int, char **)); +extern Bool R128SwitchMode + FunctionPrototype((int, DisplayModePtr, int)); +extern void R128AdjustFrame + FunctionPrototype((int, int, int, int)); +extern Bool R128EnterVT + FunctionPrototype((int, int)); +extern void R128LeaveVT + FunctionPrototype((int, int)); +extern void R128FreeScreen + FunctionPrototype((int, int)); +extern int R128ValidMode + FunctionPrototype((int, DisplayModePtr, Bool, int)); + +extern OptionInfoRec R128Options[]; + +#endif /* _R128_PROBE_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h:1.6 --- /dev/null Mon Dec 18 14:30:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h Tue Dec 12 12:17:13 2000 @@ -0,0 +1,1472 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h,v 1.6 2000/12/12 17:17:13 dawes Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Rickard E. Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * + * References: + * + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + +#ifndef _R128_REG_H_ +#define _R128_REG_H_ + +#include "xf86_ansic.h" +#include "compiler.h" + + /* Memory mapped register access macros */ +#define INREG8(addr) MMIO_IN8(R128MMIO, addr) +#define INREG16(addr) MMIO_IN16(R128MMIO, addr) +#define INREG(addr) MMIO_IN32(R128MMIO, addr) +#define OUTREG8(addr, val) MMIO_OUT8(R128MMIO, addr, val) +#define OUTREG16(addr, val) MMIO_OUT16(R128MMIO, addr, val) +#define OUTREG(addr, val) MMIO_OUT32(R128MMIO, addr, val) + +#define ADDRREG(addr) ((volatile CARD32 *)(R128MMIO + (addr))) + + +#define OUTREGP(addr, val, mask) \ + do { \ + CARD32 tmp = INREG(addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTREG(addr, tmp); \ + } while (0) + +#define INPLL(pScrn, addr) R128INPLL(pScrn, addr) + +#define OUTPLL(addr, val) \ + do { \ + OUTREG8(R128_CLOCK_CNTL_INDEX, ((addr) & 0x1f) | R128_PLL_WR_EN); \ + OUTREG(R128_CLOCK_CNTL_DATA, val); \ + } while (0) + +#define OUTPLLP(pScrn, addr, val, mask) \ + do { \ + CARD32 tmp = INPLL(pScrn, addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTPLL(addr, tmp); \ + } while (0) + +#define OUTPAL_START(idx) \ + do { \ + OUTREG8(R128_PALETTE_INDEX, (idx)); \ + } while (0) + +#define OUTPAL_NEXT(r, g, b) \ + do { \ + OUTREG(R128_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ + } while (0) + +#define OUTPAL_NEXT_CARD32(v) \ + do { \ + OUTREG(R128_PALETTE_DATA, (v & 0x00ffffff)); \ + } while (0) + +#define OUTPAL(idx, r, g, b) \ + do { \ + OUTPAL_START((idx)); \ + OUTPAL_NEXT((r), (g), (b)); \ + } while (0) + +#define INPAL_START(idx) \ + do { \ + OUTREG(R128_PALETTE_INDEX, (idx) << 16); \ + } while (0) + +#define INPAL_NEXT() INREG(R128_PALETTE_DATA) + +#define PAL_SELECT(idx) \ + do { \ + if (idx) { \ + OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) | \ + R128_DAC_PALETTE_ACC_CTL); \ + } else { \ + OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) & \ + ~R128_DAC_PALETTE_ACC_CTL); \ + } \ + } while (0) + +#define R128_ADAPTER_ID 0x0f2c /* PCI */ +#define R128_AGP_APER_OFFSET 0x0178 +#define R128_AGP_BASE 0x0170 +#define R128_AGP_CNTL 0x0174 +# define R128_AGP_APER_SIZE_256MB (0x00 << 0) +# define R128_AGP_APER_SIZE_128MB (0x20 << 0) +# define R128_AGP_APER_SIZE_64MB (0x30 << 0) +# define R128_AGP_APER_SIZE_32MB (0x38 << 0) +# define R128_AGP_APER_SIZE_16MB (0x3c << 0) +# define R128_AGP_APER_SIZE_8MB (0x3e << 0) +# define R128_AGP_APER_SIZE_4MB (0x3f << 0) +# define R128_AGP_APER_SIZE_MASK (0x3f << 0) +#define R128_AGP_CNTL_B 0x0b44 +#define R128_AGP_COMMAND 0x0f58 /* PCI */ +#define R128_AGP_PLL_CNTL 0x0010 /* PLL */ +#define R128_AGP_STATUS 0x0f54 /* PCI */ +# define R128_AGP_1X_MODE 0x01 +# define R128_AGP_2X_MODE 0x02 +# define R128_AGP_4X_MODE 0x04 +# define R128_AGP_MODE_MASK 0x07 +#define R128_AMCGPIO_A_REG 0x01a0 +#define R128_AMCGPIO_EN_REG 0x01a8 +#define R128_AMCGPIO_MASK 0x0194 +#define R128_AMCGPIO_Y_REG 0x01a4 +#define R128_ATTRDR 0x03c1 /* VGA */ +#define R128_ATTRDW 0x03c0 /* VGA */ +#define R128_ATTRX 0x03c0 /* VGA */ +#define R128_AUX_SC_CNTL 0x1660 +# define R128_AUX1_SC_EN (1 << 0) +# define R128_AUX1_SC_MODE_OR (0 << 1) +# define R128_AUX1_SC_MODE_NAND (1 << 1) +# define R128_AUX2_SC_EN (1 << 2) +# define R128_AUX2_SC_MODE_OR (0 << 3) +# define R128_AUX2_SC_MODE_NAND (1 << 3) +# define R128_AUX3_SC_EN (1 << 4) +# define R128_AUX3_SC_MODE_OR (0 << 5) +# define R128_AUX3_SC_MODE_NAND (1 << 5) +#define R128_AUX1_SC_BOTTOM 0x1670 +#define R128_AUX1_SC_LEFT 0x1664 +#define R128_AUX1_SC_RIGHT 0x1668 +#define R128_AUX1_SC_TOP 0x166c +#define R128_AUX2_SC_BOTTOM 0x1680 +#define R128_AUX2_SC_LEFT 0x1674 +#define R128_AUX2_SC_RIGHT 0x1678 +#define R128_AUX2_SC_TOP 0x167c +#define R128_AUX3_SC_BOTTOM 0x1690 +#define R128_AUX3_SC_LEFT 0x1684 +#define R128_AUX3_SC_RIGHT 0x1688 +#define R128_AUX3_SC_TOP 0x168c +#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8 +#define R128_AUX_WINDOW_VERT_CNTL 0x02dc + +#define R128_BASE_CODE 0x0f0b +#define R128_BIOS_0_SCRATCH 0x0010 +#define R128_BIOS_1_SCRATCH 0x0014 +#define R128_BIOS_2_SCRATCH 0x0018 +#define R128_BIOS_3_SCRATCH 0x001c +#define R128_BIOS_ROM 0x0f30 /* PCI */ +#define R128_BIST 0x0f0f /* PCI */ +#define R128_BRUSH_DATA0 0x1480 +#define R128_BRUSH_DATA1 0x1484 +#define R128_BRUSH_DATA10 0x14a8 +#define R128_BRUSH_DATA11 0x14ac +#define R128_BRUSH_DATA12 0x14b0 +#define R128_BRUSH_DATA13 0x14b4 +#define R128_BRUSH_DATA14 0x14b8 +#define R128_BRUSH_DATA15 0x14bc +#define R128_BRUSH_DATA16 0x14c0 +#define R128_BRUSH_DATA17 0x14c4 +#define R128_BRUSH_DATA18 0x14c8 +#define R128_BRUSH_DATA19 0x14cc +#define R128_BRUSH_DATA2 0x1488 +#define R128_BRUSH_DATA20 0x14d0 +#define R128_BRUSH_DATA21 0x14d4 +#define R128_BRUSH_DATA22 0x14d8 +#define R128_BRUSH_DATA23 0x14dc +#define R128_BRUSH_DATA24 0x14e0 +#define R128_BRUSH_DATA25 0x14e4 +#define R128_BRUSH_DATA26 0x14e8 +#define R128_BRUSH_DATA27 0x14ec +#define R128_BRUSH_DATA28 0x14f0 +#define R128_BRUSH_DATA29 0x14f4 +#define R128_BRUSH_DATA3 0x148c +#define R128_BRUSH_DATA30 0x14f8 +#define R128_BRUSH_DATA31 0x14fc +#define R128_BRUSH_DATA32 0x1500 +#define R128_BRUSH_DATA33 0x1504 +#define R128_BRUSH_DATA34 0x1508 +#define R128_BRUSH_DATA35 0x150c +#define R128_BRUSH_DATA36 0x1510 +#define R128_BRUSH_DATA37 0x1514 +#define R128_BRUSH_DATA38 0x1518 +#define R128_BRUSH_DATA39 0x151c +#define R128_BRUSH_DATA4 0x1490 +#define R128_BRUSH_DATA40 0x1520 +#define R128_BRUSH_DATA41 0x1524 +#define R128_BRUSH_DATA42 0x1528 +#define R128_BRUSH_DATA43 0x152c +#define R128_BRUSH_DATA44 0x1530 +#define R128_BRUSH_DATA45 0x1534 +#define R128_BRUSH_DATA46 0x1538 +#define R128_BRUSH_DATA47 0x153c +#define R128_BRUSH_DATA48 0x1540 +#define R128_BRUSH_DATA49 0x1544 +#define R128_BRUSH_DATA5 0x1494 +#define R128_BRUSH_DATA50 0x1548 +#define R128_BRUSH_DATA51 0x154c +#define R128_BRUSH_DATA52 0x1550 +#define R128_BRUSH_DATA53 0x1554 +#define R128_BRUSH_DATA54 0x1558 +#define R128_BRUSH_DATA55 0x155c +#define R128_BRUSH_DATA56 0x1560 +#define R128_BRUSH_DATA57 0x1564 +#define R128_BRUSH_DATA58 0x1568 +#define R128_BRUSH_DATA59 0x156c +#define R128_BRUSH_DATA6 0x1498 +#define R128_BRUSH_DATA60 0x1570 +#define R128_BRUSH_DATA61 0x1574 +#define R128_BRUSH_DATA62 0x1578 +#define R128_BRUSH_DATA63 0x157c +#define R128_BRUSH_DATA7 0x149c +#define R128_BRUSH_DATA8 0x14a0 +#define R128_BRUSH_DATA9 0x14a4 +#define R128_BRUSH_SCALE 0x1470 +#define R128_BRUSH_Y_X 0x1474 +#define R128_BUS_CNTL 0x0030 +# define R128_BUS_MASTER_DIS (1 << 6) +# define R128_BUS_RD_DISCARD_EN (1 << 24) +# define R128_BUS_RD_ABORT_EN (1 << 25) +# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) +# define R128_BUS_WRT_BURST (1 << 29) +# define R128_BUS_READ_BURST (1 << 30) +#define R128_BUS_CNTL1 0x0034 +# define R128_BUS_WAIT_ON_LOCK_EN (1 << 4) + +#define R128_CACHE_CNTL 0x1724 +#define R128_CACHE_LINE 0x0f0c /* PCI */ +#define R128_CAP0_TRIG_CNTL 0x0950 /* ? */ +#define R128_CAP1_TRIG_CNTL 0x09c0 /* ? */ +#define R128_CAPABILITIES_ID 0x0f50 /* PCI */ +#define R128_CAPABILITIES_PTR 0x0f34 /* PCI */ +#define R128_CLK_PIN_CNTL 0x0001 /* PLL */ +#define R128_CLOCK_CNTL_DATA 0x000c +#define R128_CLOCK_CNTL_INDEX 0x0008 +# define R128_PLL_WR_EN (1 << 7) +# define R128_PLL_DIV_SEL (3 << 8) +#define R128_CLR_CMP_CLR_3D 0x1a24 +#define R128_CLR_CMP_CLR_DST 0x15c8 +#define R128_CLR_CMP_CLR_SRC 0x15c4 +#define R128_CLR_CMP_CNTL 0x15c0 +# define R128_SRC_CMP_EQ_COLOR (4 << 0) +# define R128_SRC_CMP_NEQ_COLOR (5 << 0) +# define R128_CLR_CMP_SRC_SOURCE (1 << 24) +#define R128_CLR_CMP_MASK 0x15cc +# define R128_CLR_CMP_MSK 0xffffffff +#define R128_CLR_CMP_MASK_3D 0x1A28 +#define R128_COMMAND 0x0f04 /* PCI */ +#define R128_COMPOSITE_SHADOW_ID 0x1a0c +#define R128_CONFIG_APER_0_BASE 0x0100 +#define R128_CONFIG_APER_1_BASE 0x0104 +#define R128_CONFIG_APER_SIZE 0x0108 +#define R128_CONFIG_BONDS 0x00e8 +#define R128_CONFIG_CNTL 0x00e0 +# define APER_0_BIG_ENDIAN_16BPP_SWAP (1 << 0) +# define APER_0_BIG_ENDIAN_32BPP_SWAP (2 << 0) +#define R128_CONFIG_MEMSIZE 0x00f8 +#define R128_CONFIG_MEMSIZE_EMBEDDED 0x0114 +#define R128_CONFIG_REG_1_BASE 0x010c +#define R128_CONFIG_REG_APER_SIZE 0x0110 +#define R128_CONFIG_XSTRAP 0x00e4 +#define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_COLOR_MASK 0x00ffffff +# define R128_CONSTANT_COLOR_ONE 0x00ffffff +# define R128_CONSTANT_COLOR_ZERO 0x00000000 +#define R128_CRC_CMDFIFO_ADDR 0x0740 +#define R128_CRC_CMDFIFO_DOUT 0x0744 +#define R128_CRTC_CRNT_FRAME 0x0214 +#define R128_CRTC_DEBUG 0x021c +#define R128_CRTC_EXT_CNTL 0x0054 +# define R128_CRTC_VGA_XOVERSCAN (1 << 0) +# define R128_VGA_ATI_LINEAR (1 << 3) +# define R128_XCRT_CNT_EN (1 << 6) +# define R128_CRTC_HSYNC_DIS (1 << 8) +# define R128_CRTC_VSYNC_DIS (1 << 9) +# define R128_CRTC_DISPLAY_DIS (1 << 10) +# define R128_CRTC_CRT_ON (1 << 15) +#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 +# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0) +# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1) +# define R128_CRTC_DISPLAY_DIS_BYTE (1 << 2) +#define R128_CRTC_GEN_CNTL 0x0050 +# define R128_CRTC_DBL_SCAN_EN (1 << 0) +# define R128_CRTC_INTERLACE_EN (1 << 1) +# define R128_CRTC_CSYNC_EN (1 << 4) +# define R128_CRTC_CUR_EN (1 << 16) +# define R128_CRTC_CUR_MODE_MASK (7 << 17) +# define R128_CRTC_ICON_EN (1 << 20) +# define R128_CRTC_EXT_DISP_EN (1 << 24) +# define R128_CRTC_EN (1 << 25) +# define R128_CRTC_DISP_REQ_EN_B (1 << 26) +#define R128_CRTC_GUI_TRIG_VLINE 0x0218 +#define R128_CRTC_H_SYNC_STRT_WID 0x0204 +# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0) +# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) +# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 +# define R128_CRTC_H_SYNC_WID (0x3f << 16) +# define R128_CRTC_H_SYNC_WID_SHIFT 16 +# define R128_CRTC_H_SYNC_POL (1 << 23) +#define R128_CRTC_H_TOTAL_DISP 0x0200 +# define R128_CRTC_H_TOTAL (0x01ff << 0) +# define R128_CRTC_H_TOTAL_SHIFT 0 +# define R128_CRTC_H_DISP (0x00ff << 16) +# define R128_CRTC_H_DISP_SHIFT 16 +#define R128_CRTC_OFFSET 0x0224 +#define R128_CRTC_OFFSET_CNTL 0x0228 +#define R128_CRTC_PITCH 0x022c +#define R128_CRTC_STATUS 0x005c +# define R128_CRTC_VBLANK_SAVE (1 << 1) +#define R128_CRTC_V_SYNC_STRT_WID 0x020c +# define R128_CRTC_V_SYNC_STRT (0x7ff << 0) +# define R128_CRTC_V_SYNC_STRT_SHIFT 0 +# define R128_CRTC_V_SYNC_WID (0x1f << 16) +# define R128_CRTC_V_SYNC_WID_SHIFT 16 +# define R128_CRTC_V_SYNC_POL (1 << 23) +#define R128_CRTC_V_TOTAL_DISP 0x0208 +# define R128_CRTC_V_TOTAL (0x07ff << 0) +# define R128_CRTC_V_TOTAL_SHIFT 0 +# define R128_CRTC_V_DISP (0x07ff << 16) +# define R128_CRTC_V_DISP_SHIFT 16 +#define R128_CRTC_VLINE_CRNT_VLINE 0x0210 +# define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16) +#define R128_CRTC2_CRNT_FRAME 0x0314 +#define R128_CRTC2_DEBUG 0x031c +#define R128_CRTC2_GEN_CNTL 0x03f8 +#define R128_CRTC2_GUI_TRIG_VLINE 0x0318 +#define R128_CRTC2_H_SYNC_STRT_WID 0x0304 +#define R128_CRTC2_H_TOTAL_DISP 0x0300 +#define R128_CRTC2_OFFSET 0x0324 +#define R128_CRTC2_OFFSET_CNTL 0x0328 +#define R128_CRTC2_PITCH 0x032c +#define R128_CRTC2_STATUS 0x03fc +#define R128_CRTC2_V_SYNC_STRT_WID 0x030c +#define R128_CRTC2_V_TOTAL_DISP 0x0308 +#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310 +#define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ +#define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ +#define R128_CUR_CLR0 0x026c +#define R128_CUR_CLR1 0x0270 +#define R128_CUR_HORZ_VERT_OFF 0x0268 +#define R128_CUR_HORZ_VERT_POSN 0x0264 +#define R128_CUR_OFFSET 0x0260 +# define R128_CUR_LOCK (1 << 31) + +#define R128_DAC_CNTL 0x0058 +# define R128_DAC_RANGE_CNTL (3 << 0) +# define R128_DAC_BLANKING (1 << 2) +# define R128_DAC_CRT_SEL_CRTC2 (1 << 4) +# define R128_DAC_PALETTE_ACC_CTL (1 << 5) +# define R128_DAC_8BIT_EN (1 << 8) +# define R128_DAC_VGA_ADR_EN (1 << 13) +# define R128_DAC_MASK_ALL (0xff << 24) +#define R128_DAC_CRC_SIG 0x02cc +#define R128_DAC_DATA 0x03c9 /* VGA */ +#define R128_DAC_MASK 0x03c6 /* VGA */ +#define R128_DAC_R_INDEX 0x03c7 /* VGA */ +#define R128_DAC_W_INDEX 0x03c8 /* VGA */ +#define R128_DDA_CONFIG 0x02e0 +#define R128_DDA_ON_OFF 0x02e4 +#define R128_DEFAULT_OFFSET 0x16e0 +#define R128_DEFAULT_PITCH 0x16e4 +#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 +# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) +# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) +#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820 +#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 +#define R128_DEVICE_ID 0x0f02 /* PCI */ +#define R128_DP_BRUSH_BKGD_CLR 0x1478 +#define R128_DP_BRUSH_FRGD_CLR 0x147c +#define R128_DP_CNTL 0x16c0 +# define R128_DST_X_LEFT_TO_RIGHT (1 << 0) +# define R128_DST_Y_TOP_TO_BOTTOM (1 << 1) +#define R128_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 +# define R128_DST_Y_MAJOR (1 << 2) +# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) +# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) +#define R128_DP_DATATYPE 0x16c4 +# define R128_HOST_BIG_ENDIAN_EN (1 << 29) +#define R128_DP_GUI_MASTER_CNTL 0x146c +# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) +# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) +# define R128_GMC_SRC_CLIPPING (1 << 2) +# define R128_GMC_DST_CLIPPING (1 << 3) +# define R128_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) +# define R128_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) +# define R128_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) +# define R128_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) +# define R128_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) +# define R128_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) +# define R128_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) +# define R128_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4) +# define R128_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4) +# define R128_GMC_BRUSH_8x8_COLOR (10 << 4) +# define R128_GMC_BRUSH_1X8_COLOR (12 << 4) +# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define R128_GMC_BRUSH_NONE (15 << 4) +# define R128_GMC_DST_8BPP_CI (2 << 8) +# define R128_GMC_DST_15BPP (3 << 8) +# define R128_GMC_DST_16BPP (4 << 8) +# define R128_GMC_DST_24BPP (5 << 8) +# define R128_GMC_DST_32BPP (6 << 8) +# define R128_GMC_DST_8BPP_RGB (7 << 8) +# define R128_GMC_DST_Y8 (8 << 8) +# define R128_GMC_DST_RGB8 (9 << 8) +# define R128_GMC_DST_VYUY (11 << 8) +# define R128_GMC_DST_YVYU (12 << 8) +# define R128_GMC_DST_AYUV444 (14 << 8) +# define R128_GMC_DST_ARGB4444 (15 << 8) +# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8) +# define R128_GMC_DST_DATATYPE_SHIFT 8 +# define R128_GMC_SRC_DATATYPE_MASK (3 << 12) +# define R128_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) +# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) +# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) +# define R128_GMC_BYTE_PIX_ORDER (1 << 14) +# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14) +# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14) +# define R128_GMC_CONVERSION_TEMP (1 << 15) +# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15) +# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15) +# define R128_GMC_ROP3_MASK (0xff << 16) +# define R128_DP_SRC_SOURCE_MASK (7 << 24) +# define R128_DP_SRC_SOURCE_MEMORY (2 << 24) +# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24) +# define R128_GMC_3D_FCN_EN (1 << 27) +# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) +# define R128_GMC_AUX_CLIP_DIS (1 << 29) +# define R128_GMC_WR_MSK_DIS (1 << 30) +# define R128_GMC_LD_BRUSH_Y_X (1 << 31) +# define R128_ROP3_ZERO 0x00000000 +# define R128_ROP3_DSa 0x00880000 +# define R128_ROP3_SDna 0x00440000 +# define R128_ROP3_S 0x00cc0000 +# define R128_ROP3_DSna 0x00220000 +# define R128_ROP3_D 0x00aa0000 +# define R128_ROP3_DSx 0x00660000 +# define R128_ROP3_DSo 0x00ee0000 +# define R128_ROP3_DSon 0x00110000 +# define R128_ROP3_DSxn 0x00990000 +# define R128_ROP3_Dn 0x00550000 +# define R128_ROP3_SDno 0x00dd0000 +# define R128_ROP3_Sn 0x00330000 +# define R128_ROP3_DSno 0x00bb0000 +# define R128_ROP3_DSan 0x00770000 +# define R128_ROP3_ONE 0x00ff0000 +# define R128_ROP3_DPa 0x00a00000 +# define R128_ROP3_PDna 0x00500000 +# define R128_ROP3_P 0x00f00000 +# define R128_ROP3_DPna 0x000a0000 +# define R128_ROP3_D 0x00aa0000 +# define R128_ROP3_DPx 0x005a0000 +# define R128_ROP3_DPo 0x00fa0000 +# define R128_ROP3_DPon 0x00050000 +# define R128_ROP3_PDxn 0x00a50000 +# define R128_ROP3_PDno 0x00f50000 +# define R128_ROP3_Pn 0x000f0000 +# define R128_ROP3_DPno 0x00af0000 +# define R128_ROP3_DPan 0x005f0000 + + +#define R128_DP_GUI_MASTER_CNTL_C 0x1c84 +#define R128_DP_MIX 0x16c8 +#define R128_DP_SRC_BKGD_CLR 0x15dc +#define R128_DP_SRC_FRGD_CLR 0x15d8 +#define R128_DP_WRITE_MASK 0x16cc +#define R128_DST_BRES_DEC 0x1630 +#define R128_DST_BRES_ERR 0x1628 +#define R128_DST_BRES_INC 0x162c +#define R128_DST_BRES_LNTH 0x1634 +#define R128_DST_BRES_LNTH_SUB 0x1638 +#define R128_DST_HEIGHT 0x1410 +#define R128_DST_HEIGHT_WIDTH 0x143c +#define R128_DST_HEIGHT_WIDTH_8 0x158c +#define R128_DST_HEIGHT_WIDTH_BW 0x15b4 +#define R128_DST_HEIGHT_Y 0x15a0 +#define R128_DST_OFFSET 0x1404 +#define R128_DST_PITCH 0x1408 +#define R128_DST_PITCH_OFFSET 0x142c +#define R128_DST_PITCH_OFFSET_C 0x1c80 +# define R128_PITCH_SHIFT 21 +# define R128_DST_TILE (1 << 31) +#define R128_DST_WIDTH 0x140c +#define R128_DST_WIDTH_HEIGHT 0x1598 +#define R128_DST_WIDTH_X 0x1588 +#define R128_DST_WIDTH_X_INCY 0x159c +#define R128_DST_X 0x141c +#define R128_DST_X_SUB 0x15a4 +#define R128_DST_X_Y 0x1594 +#define R128_DST_Y 0x1420 +#define R128_DST_Y_SUB 0x15a8 +#define R128_DST_Y_X 0x1438 + +#define R128_EXT_MEM_CNTL 0x0144 + +#define R128_FCP_CNTL 0x0012 /* PLL */ +#define R128_FLUSH_1 0x1704 +#define R128_FLUSH_2 0x1708 +#define R128_FLUSH_3 0x170c +#define R128_FLUSH_4 0x1710 +#define R128_FLUSH_5 0x1714 +#define R128_FLUSH_6 0x1718 +#define R128_FLUSH_7 0x171c +#define R128_FOG_3D_TABLE_START 0x1810 +#define R128_FOG_3D_TABLE_END 0x1814 +#define R128_FOG_3D_TABLE_DENSITY 0x181c +#define R128_FOG_TABLE_INDEX 0x1a14 +#define R128_FOG_TABLE_DATA 0x1a18 +#define R128_FP_CRTC_H_TOTAL_DISP 0x0250 +#define R128_FP_CRTC_V_TOTAL_DISP 0x0254 +#define R128_FP_GEN_CNTL 0x0284 +# define R128_FP_FPON (1 << 0) +# define R128_FP_TDMS_EN (1 << 2) +# define R128_FP_DETECT_SENSE (1 << 8) +# define R128_FP_SEL_CRTC2 (1 << 13) +# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) +# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18) +# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20) +# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) +# define R128_FP_USE_SHADOW_EN (1 << 24) +#define R128_FP_H_SYNC_STRT_WID 0x02c4 +#define R128_FP_HORZ_STRETCH 0x028c +# define R128_HORZ_STRETCH_RATIO_MASK 0xffff +# define R128_HORZ_STRETCH_RATIO_SHIFT 0 +# define R128_HORZ_STRETCH_RATIO_MAX 4096 +# define R128_HORZ_PANEL_SIZE (0xff << 16) +# define R128_HORZ_PANEL_SHIFT 16 +# define R128_HORZ_STRETCH_PIXREP (0 << 25) +# define R128_HORZ_STRETCH_BLEND (1 << 25) +# define R128_HORZ_STRETCH_ENABLE (1 << 26) +# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27) +# define R128_HORZ_STRETCH_RESERVED (1 << 30) +# define R128_HORZ_AUTO_RATIO_FIX_EN (1 << 31) + +#define R128_FP_PANEL_CNTL 0x0288 +# define R128_FP_DIGON (1 << 0) +# define R128_FP_BLON (1 << 1) +#define R128_FP_V_SYNC_STRT_WID 0x02c8 +#define R128_FP_VERT_STRETCH 0x0290 +# define R128_VERT_PANEL_SIZE (0x7ff << 0) +# define R128_VERT_PANEL_SHIFT 0 +# define R128_VERT_STRETCH_RATIO_MASK 0x3ff +# define R128_VERT_STRETCH_RATIO_SHIFT 11 +# define R128_VERT_STRETCH_RATIO_MAX 1024 +# define R128_VERT_STRETCH_ENABLE (1 << 24) +# define R128_VERT_STRETCH_LINEREP (0 << 25) +# define R128_VERT_STRETCH_BLEND (1 << 25) +# define R128_VERT_AUTO_RATIO_EN (1 << 26) +# define R128_VERT_STRETCH_RESERVED 0xf8e00000 + +#define R128_GEN_INT_CNTL 0x0040 +#define R128_GEN_INT_STATUS 0x0044 +# define R128_VSYNC_INT_AK (1 << 2) +# define R128_VSYNC_INT (1 << 2) +#define R128_GEN_RESET_CNTL 0x00f0 +# define R128_SOFT_RESET_GUI (1 << 0) +# define R128_SOFT_RESET_VCLK (1 << 8) +# define R128_SOFT_RESET_PCLK (1 << 9) +# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11) +# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12) +#define R128_GENENB 0x03c3 /* VGA */ +#define R128_GENFC_RD 0x03ca /* VGA */ +#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */ +#define R128_GENMO_RD 0x03cc /* VGA */ +#define R128_GENMO_WT 0x03c2 /* VGA */ +#define R128_GENS0 0x03c2 /* VGA */ +#define R128_GENS1 0x03da /* VGA, 0x03ba */ +#define R128_GPIO_MONID 0x0068 +# define R128_GPIO_MONID_A_0 (1 << 0) +# define R128_GPIO_MONID_A_1 (1 << 1) +# define R128_GPIO_MONID_A_2 (1 << 2) +# define R128_GPIO_MONID_A_3 (1 << 3) +# define R128_GPIO_MONID_Y_0 (1 << 8) +# define R128_GPIO_MONID_Y_1 (1 << 9) +# define R128_GPIO_MONID_Y_2 (1 << 10) +# define R128_GPIO_MONID_Y_3 (1 << 11) +# define R128_GPIO_MONID_EN_0 (1 << 16) +# define R128_GPIO_MONID_EN_1 (1 << 17) +# define R128_GPIO_MONID_EN_2 (1 << 18) +# define R128_GPIO_MONID_EN_3 (1 << 19) +# define R128_GPIO_MONID_MASK_0 (1 << 24) +# define R128_GPIO_MONID_MASK_1 (1 << 25) +# define R128_GPIO_MONID_MASK_2 (1 << 26) +# define R128_GPIO_MONID_MASK_3 (1 << 27) +#define R128_GPIO_MONIDB 0x006c +#define R128_GRPH8_DATA 0x03cf /* VGA */ +#define R128_GRPH8_IDX 0x03ce /* VGA */ +#define R128_GUI_DEBUG0 0x16a0 +#define R128_GUI_DEBUG1 0x16a4 +#define R128_GUI_DEBUG2 0x16a8 +#define R128_GUI_DEBUG3 0x16ac +#define R128_GUI_DEBUG4 0x16b0 +#define R128_GUI_DEBUG5 0x16b4 +#define R128_GUI_DEBUG6 0x16b8 +#define R128_GUI_PROBE 0x16bc +#define R128_GUI_SCRATCH_REG0 0x15e0 +#define R128_GUI_SCRATCH_REG1 0x15e4 +#define R128_GUI_SCRATCH_REG2 0x15e8 +#define R128_GUI_SCRATCH_REG3 0x15ec +#define R128_GUI_SCRATCH_REG4 0x15f0 +#define R128_GUI_SCRATCH_REG5 0x15f4 +#define R128_GUI_STAT 0x1740 +# define R128_GUI_FIFOCNT_MASK 0x0fff +# define R128_GUI_ACTIVE (1 << 31) + +#define R128_HEADER 0x0f0e /* PCI */ +#define R128_HOST_DATA0 0x17c0 +#define R128_HOST_DATA1 0x17c4 +#define R128_HOST_DATA2 0x17c8 +#define R128_HOST_DATA3 0x17cc +#define R128_HOST_DATA4 0x17d0 +#define R128_HOST_DATA5 0x17d4 +#define R128_HOST_DATA6 0x17d8 +#define R128_HOST_DATA7 0x17dc +#define R128_HOST_DATA_LAST 0x17e0 +#define R128_HOST_PATH_CNTL 0x0130 +#define R128_HTOTAL_CNTL 0x0009 /* PLL */ +#define R128_HW_DEBUG 0x0128 +#define R128_HW_DEBUG2 0x011c + +#define R128_I2C_CNTL_1 0x0094 /* ? */ +#define R128_INTERRUPT_LINE 0x0f3c /* PCI */ +#define R128_INTERRUPT_PIN 0x0f3d /* PCI */ +#define R128_IO_BASE 0x0f14 /* PCI */ + +#define R128_LATENCY 0x0f0d /* PCI */ +#define R128_LEAD_BRES_DEC 0x1608 +#define R128_LEAD_BRES_ERR 0x1600 +#define R128_LEAD_BRES_INC 0x1604 +#define R128_LEAD_BRES_LNTH 0x161c +#define R128_LEAD_BRES_LNTH_SUB 0x1624 +#define R128_LVDS_GEN_CNTL 0x02d0 +# define R128_LVDS_ON (1 << 0) +# define R128_LVDS_BLON (1 << 19) +# define R128_LVDS_SEL_CRTC2 (1 << 23) +# define R128_HSYNC_DELAY_SHIFT 28 +# define R128_HSYNC_DELAY_MASK (0xf << 28) + +#define R128_MAX_LATENCY 0x0f3f /* PCI */ +#define R128_MCLK_CNTL 0x000f /* PLL */ +# define R128_FORCE_GCP (1 << 16) +# define R128_FORCE_PIPE3D_CP (1 << 17) +# define R128_FORCE_RCP (1 << 18) +#define R128_MDGPIO_A_REG 0x01ac +#define R128_MDGPIO_EN_REG 0x01b0 +#define R128_MDGPIO_MASK 0x0198 +#define R128_MDGPIO_Y_REG 0x01b4 +#define R128_MEM_ADDR_CONFIG 0x0148 +#define R128_MEM_BASE 0x0f10 /* PCI */ +#define R128_MEM_CNTL 0x0140 +#define R128_MEM_INIT_LAT_TIMER 0x0154 +#define R128_MEM_INTF_CNTL 0x014c +#define R128_MEM_SDRAM_MODE_REG 0x0158 +#define R128_MEM_STR_CNTL 0x0150 +#define R128_MEM_VGA_RP_SEL 0x003c +#define R128_MEM_VGA_WP_SEL 0x0038 +#define R128_MIN_GRANT 0x0f3e /* PCI */ +#define R128_MM_DATA 0x0004 +#define R128_MM_INDEX 0x0000 +#define R128_MPLL_CNTL 0x000e /* PLL */ +#define R128_MPP_TB_CONFIG 0x01c0 /* ? */ +#define R128_MPP_GP_CONFIG 0x01c8 /* ? */ + +#define R128_N_VIF_COUNT 0x0248 + +#define R128_OVR_CLR 0x0230 +#define R128_OVR_WID_LEFT_RIGHT 0x0234 +#define R128_OVR_WID_TOP_BOTTOM 0x0238 + +/* first overlay unit (there is only one) */ + +#define R128_OV0_Y_X_START 0x0400 +#define R128_OV0_Y_X_END 0x0404 +#define R128_OV0_EXCLUSIVE_HORZ 0x0408 +# define R128_EXCL_HORZ_START_MASK 0x000000ff +# define R128_EXCL_HORZ_END_MASK 0x0000ff00 +# define R128_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000 +# define R128_EXCL_HORZ_EXCLUSIVE_EN 0x80000000 +#define R128_OV0_EXCLUSIVE_VERT 0x040C +# define R128_EXCL_VERT_START_MASK 0x000003ff +# define R128_EXCL_VERT_END_MASK 0x03ff0000 +#define R128_OV0_REG_LOAD_CNTL 0x0410 +# define R128_REG_LD_CTL_LOCK 0x00000001L +# define R128_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L +# define R128_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L +# define R128_REG_LD_CTL_LOCK_READBACK 0x00000008L +#define R128_OV0_SCALE_CNTL 0x0420 +# define R128_SCALER_PIX_EXPAND 0x00000001L +# define R128_SCALER_Y2R_TEMP 0x00000002L +# define R128_SCALER_HORZ_PICK_NEAREST 0x00000003L +# define R128_SCALER_VERT_PICK_NEAREST 0x00000004L +# define R128_SCALER_SIGNED_UV 0x00000010L +# define R128_SCALER_GAMMA_SEL_MASK 0x00000060L +# define R128_SCALER_GAMMA_SEL_BRIGHT 0x00000000L +# define R128_SCALER_GAMMA_SEL_G22 0x00000020L +# define R128_SCALER_GAMMA_SEL_G18 0x00000040L +# define R128_SCALER_GAMMA_SEL_G14 0x00000060L +# define R128_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L +# define R128_SCALER_SURFAC_FORMAT 0x00000f00L +# define R128_SCALER_SOURCE_15BPP 0x00000300L +# define R128_SCALER_SOURCE_16BPP 0x00000400L +# define R128_SCALER_SOURCE_32BPP 0x00000600L +# define R128_SCALER_SOURCE_YUV9 0x00000900L +# define R128_SCALER_SOURCE_YUV12 0x00000A00L +# define R128_SCALER_SOURCE_VYUY422 0x00000B00L +# define R128_SCALER_SOURCE_YVYU422 0x00000C00L +# define R128_SCALER_SMART_SWITCH 0x00008000L +# define R128_SCALER_BURST_PER_PLANE 0x00ff0000L +# define R128_SCALER_DOUBLE_BUFFER 0x01000000L +# define R128_SCALER_DIS_LIMIT 0x08000000L +# define R128_SCALER_PRG_LOAD_START 0x10000000L +# define R128_SCALER_INT_EMU 0x20000000L +# define R128_SCALER_ENABLE 0x40000000L +# define R128_SCALER_SOFT_RESET 0x80000000L +#define R128_OV0_V_INC 0x0424 +#define R128_OV0_P1_V_ACCUM_INIT 0x0428 +# define R128_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L +# define R128_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L +#define R128_OV0_P23_V_ACCUM_INIT 0x042C +#define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430 +# define R128_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL +# define R128_P1_ACTIVE_LINES_M1 0x0fff0000L +#define R128_OV0_P23_BLANK_LINES_AT_TOP 0x0434 +# define R128_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL +# define R128_P23_ACTIVE_LINES_M1 0x07ff0000L +#define R128_OV0_VID_BUF0_BASE_ADRS 0x0440 +# define R128_VIF_BUF0_PITCH_SEL 0x00000001L +# define R128_VIF_BUF0_TILE_ADRS 0x00000002L +# define R128_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF1_BASE_ADRS 0x0444 +# define R128_VIF_BUF1_PITCH_SEL 0x00000001L +# define R128_VIF_BUF1_TILE_ADRS 0x00000002L +# define R128_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF2_BASE_ADRS 0x0448 +# define R128_VIF_BUF2_PITCH_SEL 0x00000001L +# define R128_VIF_BUF2_TILE_ADRS 0x00000002L +# define R128_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L +# define R128_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L +#define R128_OV0_VID_BUF3_BASE_ADRS 0x044C +#define R128_OV0_VID_BUF4_BASE_ADRS 0x0450 +#define R128_OV0_VID_BUF5_BASE_ADRS 0x0454 +#define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460 +#define R128_OV0_VID_BUF_PITCH1_VALUE 0x0464 +#define R128_OV0_AUTO_FLIP_CNTL 0x0470 +#define R128_OV0_DEINTERLACE_PATTERN 0x0474 +#define R128_OV0_H_INC 0x0480 +#define R128_OV0_STEP_BY 0x0484 +#define R128_OV0_P1_H_ACCUM_INIT 0x0488 +#define R128_OV0_P23_H_ACCUM_INIT 0x048C +#define R128_OV0_P1_X_START_END 0x0494 +#define R128_OV0_P2_X_START_END 0x0498 +#define R128_OV0_P3_X_START_END 0x049C +#define R128_OV0_FILTER_CNTL 0x04A0 +#define R128_OV0_FOUR_TAP_COEF_0 0x04B0 +#define R128_OV0_FOUR_TAP_COEF_1 0x04B4 +#define R128_OV0_FOUR_TAP_COEF_2 0x04B8 +#define R128_OV0_FOUR_TAP_COEF_3 0x04BC +#define R128_OV0_FOUR_TAP_COEF_4 0x04C0 +#define R128_OV0_COLOUR_CNTL 0x04E0 +#define R128_OV0_VIDEO_KEY_CLR 0x04E4 +#define R128_OV0_VIDEO_KEY_MSK 0x04E8 +#define R128_OV0_GRAPHICS_KEY_CLR 0x04EC +#define R128_OV0_GRAPHICS_KEY_MSK 0x04F0 +#define R128_OV0_KEY_CNTL 0x04F4 +# define R128_VIDEO_KEY_FN_MASK 0x00000007L +# define R128_VIDEO_KEY_FN_FALSE 0x00000000L +# define R128_VIDEO_KEY_FN_TRUE 0x00000001L +# define R128_VIDEO_KEY_FN_EQ 0x00000004L +# define R128_VIDEO_KEY_FN_NE 0x00000005L +# define R128_GRAPHIC_KEY_FN_MASK 0x00000070L +# define R128_GRAPHIC_KEY_FN_FALSE 0x00000000L +# define R128_GRAPHIC_KEY_FN_TRUE 0x00000010L +# define R128_GRAPHIC_KEY_FN_EQ 0x00000040L +# define R128_GRAPHIC_KEY_FN_NE 0x00000050L +# define R128_CMP_MIX_MASK 0x00000100L +# define R128_CMP_MIX_OR 0x00000000L +# define R128_CMP_MIX_AND 0x00000100L +#define R128_OV0_TEST 0x04F8 + + +#define R128_PALETTE_DATA 0x00b4 +#define R128_PALETTE_INDEX 0x00b0 +#define R128_PC_DEBUG_MODE 0x1760 +#define R128_PC_GUI_CTLSTAT 0x1748 +#define R128_PC_GUI_MODE 0x1744 +# define R128_PC_IGNORE_UNIFY (1 << 5) +#define R128_PC_MISC_CNTL 0x0188 +#define R128_PC_NGUI_CTLSTAT 0x0184 +# define R128_PC_FLUSH_GUI (3 << 0) +# define R128_PC_RI_GUI (1 << 2) +# define R128_PC_FLUSH_ALL 0x00ff +# define R128_PC_BUSY (1 << 31) +#define R128_PC_NGUI_MODE 0x0180 +#define R128_PCI_GART_PAGE 0x017c +#define R128_PLANE_3D_MASK_C 0x1d44 +#define R128_PLL_TEST_CNTL 0x0013 /* PLL */ +#define R128_PMI_CAP_ID 0x0f5c /* PCI */ +#define R128_PMI_DATA 0x0f63 /* PCI */ +#define R128_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ +#define R128_PMI_PMC_REG 0x0f5e /* PCI */ +#define R128_PMI_PMCSR_REG 0x0f60 /* PCI */ +#define R128_PMI_REGISTER 0x0f5c /* PCI */ +#define R128_PPLL_CNTL 0x0002 /* PLL */ +# define R128_PPLL_RESET (1 << 0) +# define R128_PPLL_SLEEP (1 << 1) +# define R128_PPLL_ATOMIC_UPDATE_EN (1 << 16) +# define R128_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) +#define R128_PPLL_DIV_0 0x0004 /* PLL */ +#define R128_PPLL_DIV_1 0x0005 /* PLL */ +#define R128_PPLL_DIV_2 0x0006 /* PLL */ +#define R128_PPLL_DIV_3 0x0007 /* PLL */ +# define R128_PPLL_FB3_DIV_MASK 0x07ff +# define R128_PPLL_POST3_DIV_MASK 0x00070000 +#define R128_PPLL_REF_DIV 0x0003 /* PLL */ +# define R128_PPLL_REF_DIV_MASK 0x03ff +# define R128_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ +# define R128_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ +#define R128_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ +#define R128_REG_BASE 0x0f18 /* PCI */ +#define R128_REGPROG_INF 0x0f09 /* PCI */ +#define R128_REVISION_ID 0x0f08 /* PCI */ + +#define R128_SC_BOTTOM 0x164c +#define R128_SC_BOTTOM_RIGHT 0x16f0 +#define R128_SC_BOTTOM_RIGHT_C 0x1c8c +#define R128_SC_LEFT 0x1640 +#define R128_SC_RIGHT 0x1644 +#define R128_SC_TOP 0x1648 +#define R128_SC_TOP_LEFT 0x16ec +#define R128_SC_TOP_LEFT_C 0x1c88 +#define R128_SEQ8_DATA 0x03c5 /* VGA */ +#define R128_SEQ8_IDX 0x03c4 /* VGA */ +#define R128_SNAPSHOT_F_COUNT 0x0244 +#define R128_SNAPSHOT_VH_COUNTS 0x0240 +#define R128_SNAPSHOT_VIF_COUNT 0x024c +#define R128_SRC_OFFSET 0x15ac +#define R128_SRC_PITCH 0x15b0 +#define R128_SRC_PITCH_OFFSET 0x1428 +#define R128_SRC_SC_BOTTOM 0x165c +#define R128_SRC_SC_BOTTOM_RIGHT 0x16f4 +#define R128_SRC_SC_RIGHT 0x1654 +#define R128_SRC_X 0x1414 +#define R128_SRC_X_Y 0x1590 +#define R128_SRC_Y 0x1418 +#define R128_SRC_Y_X 0x1434 +#define R128_STATUS 0x0f06 /* PCI */ +#define R128_SUBPIC_CNTL 0x0540 /* ? */ +#define R128_SUB_CLASS 0x0f0a /* PCI */ +#define R128_SURFACE_DELAY 0x0b00 +#define R128_SURFACE0_INFO 0x0b0c +#define R128_SURFACE0_LOWER_BOUND 0x0b04 +#define R128_SURFACE0_UPPER_BOUND 0x0b08 +#define R128_SURFACE1_INFO 0x0b1c +#define R128_SURFACE1_LOWER_BOUND 0x0b14 +#define R128_SURFACE1_UPPER_BOUND 0x0b18 +#define R128_SURFACE2_INFO 0x0b2c +#define R128_SURFACE2_LOWER_BOUND 0x0b24 +#define R128_SURFACE2_UPPER_BOUND 0x0b28 +#define R128_SURFACE3_INFO 0x0b3c +#define R128_SURFACE3_LOWER_BOUND 0x0b34 +#define R128_SURFACE3_UPPER_BOUND 0x0b38 +#define R128_SW_SEMAPHORE 0x013c + +#define R128_TEST_DEBUG_CNTL 0x0120 +#define R128_TEST_DEBUG_MUX 0x0124 +#define R128_TEST_DEBUG_OUT 0x012c +#define R128_TMDS_CRC 0x02a0 +#define R128_TRAIL_BRES_DEC 0x1614 +#define R128_TRAIL_BRES_ERR 0x160c +#define R128_TRAIL_BRES_INC 0x1610 +#define R128_TRAIL_X 0x1618 +#define R128_TRAIL_X_SUB 0x1620 + +#define R128_VCLK_ECP_CNTL 0x0008 /* PLL */ +#define R128_VENDOR_ID 0x0f00 /* PCI */ +#define R128_VGA_DDA_CONFIG 0x02e8 +#define R128_VGA_DDA_ON_OFF 0x02ec +#define R128_VID_BUFFER_CONTROL 0x0900 +#define R128_VIDEOMUX_CNTL 0x0190 +#define R128_VIPH_CONTROL 0x01D0 /* ? */ + +#define R128_WAIT_UNTIL 0x1720 + +#define R128_X_MPLL_REF_FB_DIV 0x000a /* PLL */ +#define R128_XCLK_CNTL 0x000d /* PLL */ +#define R128_XDLL_CNTL 0x000c /* PLL */ +#define R128_XPLL_CNTL 0x000b /* PLL */ + + /* Registers for CCE and Microcode Engine */ +#define R128_PM4_MICROCODE_ADDR 0x07d4 +#define R128_PM4_MICROCODE_RADDR 0x07d8 +#define R128_PM4_MICROCODE_DATAH 0x07dc +#define R128_PM4_MICROCODE_DATAL 0x07e0 + +#define R128_PM4_BUFFER_OFFSET 0x0700 +#define R128_PM4_BUFFER_CNTL 0x0704 +# define R128_PM4_NONPM4 (0 << 28) +# define R128_PM4_192PIO (1 << 28) +# define R128_PM4_192BM (2 << 28) +# define R128_PM4_128PIO_64INDBM (3 << 28) +# define R128_PM4_128BM_64INDBM (4 << 28) +# define R128_PM4_64PIO_128INDBM (5 << 28) +# define R128_PM4_64BM_128INDBM (6 << 28) +# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) +# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) +# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) +#define R128_PM4_BUFFER_WM_CNTL 0x0708 +# define R128_WMA_SHIFT 0 +# define R128_WMB_SHIFT 8 +# define R128_WMC_SHIFT 16 +# define R128_WB_WM_SHIFT 24 +#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c +#define R128_PM4_BUFFER_DL_RPTR 0x0710 +#define R128_PM4_BUFFER_DL_WPTR 0x0714 +# define R128_PM4_BUFFER_DL_DONE (1 << 31) +#define R128_PM4_BUFFER_DL_WPTR_DELAY 0x0718 +# define R128_PRE_WRITE_TIMER_SHIFT 0 +# define R128_PRE_WRITE_LIMIT_SHIFT 23 +#define R128_PM4_VC_FPU_SETUP 0x071c +# define R128_FRONT_DIR_CW (0 << 0) +# define R128_FRONT_DIR_CCW (1 << 0) +# define R128_FRONT_DIR_MASK (1 << 0) +# define R128_BACKFACE_CULL (0 << 1) +# define R128_BACKFACE_POINTS (1 << 1) +# define R128_BACKFACE_LINES (2 << 1) +# define R128_BACKFACE_SOLID (3 << 1) +# define R128_BACKFACE_MASK (3 << 1) +# define R128_FRONTFACE_CULL (0 << 3) +# define R128_FRONTFACE_POINTS (1 << 3) +# define R128_FRONTFACE_LINES (2 << 3) +# define R128_FRONTFACE_SOLID (3 << 3) +# define R128_FRONTFACE_MASK (3 << 3) +# define R128_FPU_COLOR_SOLID (0 << 5) +# define R128_FPU_COLOR_FLAT (1 << 5) +# define R128_FPU_COLOR_GOURAUD (2 << 5) +# define R128_FPU_COLOR_GOURAUD2 (3 << 5) +# define R128_FPU_COLOR_MASK (3 << 5) +# define R128_FPU_SUB_PIX_2BITS (0 << 7) +# define R128_FPU_SUB_PIX_4BITS (1 << 7) +# define R128_FPU_MODE_2D (0 << 8) +# define R128_FPU_MODE_3D (1 << 8) +# define R128_TRAP_BITS_DISABLE (1 << 9) +# define R128_EDGE_ANTIALIAS (1 << 10) +# define R128_SUPERSAMPLE (1 << 11) +# define R128_XFACTOR_2 (0 << 12) +# define R128_XFACTOR_4 (1 << 12) +# define R128_YFACTOR_2 (0 << 13) +# define R128_YFACTOR_4 (1 << 13) +# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14) +# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14) +# define R128_FPU_ROUND_TRUNCATE (0 << 15) +# define R128_FPU_ROUND_NEAREST (1 << 15) +# define R128_WM_SEL_8DW (0 << 16) +# define R128_WM_SEL_16DW (1 << 16) +# define R128_WM_SEL_32DW (2 << 16) +#define R128_PM4_VC_DEBUG_CONFIG 0x07a4 +#define R128_PM4_VC_STAT 0x07a8 +#define R128_PM4_VC_TIMESTAMP0 0x07b0 +#define R128_PM4_VC_TIMESTAMP1 0x07b4 +#define R128_PM4_STAT 0x07b8 +# define R128_PM4_FIFOCNT_MASK 0x0fff +# define R128_PM4_BUSY (1 << 16) +# define R128_PM4_GUI_ACTIVE (1 << 31) +#define R128_PM4_BUFFER_ADDR 0x07f0 +#define R128_PM4_MICRO_CNTL 0x07fc +# define R128_PM4_MICRO_FREERUN (1 << 30) +#define R128_PM4_FIFO_DATA_EVEN 0x1000 +#define R128_PM4_FIFO_DATA_ODD 0x1004 + +#define R128_SCALE_3D_CNTL 0x1a00 +# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) +# define R128_SCALE_DITHER_TABLE (1 << 1) +# define R128_TEX_CACHE_SIZE_FULL (0 << 2) +# define R128_TEX_CACHE_SIZE_HALF (1 << 2) +# define R128_DITHER_INIT_CURR (0 << 3) +# define R128_DITHER_INIT_RESET (1 << 3) +# define R128_ROUND_24BIT (1 << 4) +# define R128_TEX_CACHE_DISABLE (1 << 5) +# define R128_SCALE_3D_NOOP (0 << 6) +# define R128_SCALE_3D_SCALE (1 << 6) +# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define R128_SCALE_PIX_BLEND (0 << 8) +# define R128_SCALE_PIX_REPLICATE (1 << 8) +# define R128_TEX_CACHE_SPLIT (1 << 9) +# define R128_APPLE_YUV_MODE (1 << 10) +# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define R128_FOG_TABLE (1 << 14) +# define R128_SIGNED_DST_CLAMP (1 << 15) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16) +# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) +# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) +# define R128_COMPOSITE_SHADOW (1 << 29) +# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) +# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31) +# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31) +#define R128_SCALE_3D_DATATYPE 0x1a20 + +#define R128_SETUP_CNTL 0x1bc4 +# define R128_DONT_START_TRIANGLE (1 << 0) +# define R128_Z_BIAS (0 << 1) +# define R128_DONT_START_ANY_ON (1 << 2) +# define R128_COLOR_SOLID_COLOR (0 << 3) +# define R128_COLOR_FLAT_VERT_1 (1 << 3) +# define R128_COLOR_FLAT_VERT_2 (2 << 3) +# define R128_COLOR_FLAT_VERT_3 (3 << 3) +# define R128_COLOR_GOURAUD (4 << 3) +# define R128_PRIM_TYPE_TRI (0 << 7) +# define R128_PRIM_TYPE_LINE (1 << 7) +# define R128_PRIM_TYPE_POINT (2 << 7) +# define R128_PRIM_TYPE_POLY_EDGE (3 << 7) +# define R128_TEXTURE_ST_MULT_W (0 << 9) +# define R128_TEXTURE_ST_DIRECT (1 << 9) +# define R128_STARTING_VERTEX_1 (1 << 14) +# define R128_STARTING_VERTEX_2 (2 << 14) +# define R128_STARTING_VERTEX_3 (3 << 14) +# define R128_ENDING_VERTEX_1 (1 << 16) +# define R128_ENDING_VERTEX_2 (2 << 16) +# define R128_ENDING_VERTEX_3 (3 << 16) +# define R128_SU_POLY_LINE_LAST (0 << 18) +# define R128_SU_POLY_LINE_NOT_LAST (1 << 18) +# define R128_SUB_PIX_2BITS (0 << 19) +# define R128_SUB_PIX_4BITS (1 << 19) +# define R128_SET_UP_CONTINUE (1 << 31) + +#define R128_WINDOW_XY_OFFSET 0x1bcc +# define R128_WINDOW_Y_SHIFT 4 +# define R128_WINDOW_X_SHIFT 20 + +#define R128_Z_OFFSET_C 0x1c90 +#define R128_Z_PITCH_C 0x1c94 +# define R128_Z_TILE (1 << 16) +#define R128_Z_STEN_CNTL_C 0x1c98 +# define R128_Z_PIX_WIDTH_16 (0 << 1) +# define R128_Z_PIX_WIDTH_24 (1 << 1) +# define R128_Z_PIX_WIDTH_32 (2 << 1) +# define R128_Z_PIX_WIDTH_MASK (3 << 1) +# define R128_Z_TEST_NEVER (0 << 4) +# define R128_Z_TEST_LESS (1 << 4) +# define R128_Z_TEST_LESSEQUAL (2 << 4) +# define R128_Z_TEST_EQUAL (3 << 4) +# define R128_Z_TEST_GREATEREQUAL (4 << 4) +# define R128_Z_TEST_GREATER (5 << 4) +# define R128_Z_TEST_NEQUAL (6 << 4) +# define R128_Z_TEST_ALWAYS (7 << 4) +# define R128_Z_TEST_MASK (7 << 4) +# define R128_STENCIL_TEST_NEVER (0 << 12) +# define R128_STENCIL_TEST_LESS (1 << 12) +# define R128_STENCIL_TEST_LESSEQUAL (2 << 12) +# define R128_STENCIL_TEST_EQUAL (3 << 12) +# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12) +# define R128_STENCIL_TEST_GREATER (5 << 12) +# define R128_STENCIL_TEST_NEQUAL (6 << 12) +# define R128_STENCIL_TEST_ALWAYS (7 << 12) +# define R128_STENCIL_S_FAIL_KEEP (0 << 16) +# define R128_STENCIL_S_FAIL_ZERO (1 << 16) +# define R128_STENCIL_S_FAIL_REPLACE (2 << 16) +# define R128_STENCIL_S_FAIL_INC (3 << 16) +# define R128_STENCIL_S_FAIL_DEC (4 << 16) +# define R128_STENCIL_S_FAIL_INV (5 << 16) +# define R128_STENCIL_ZPASS_KEEP (0 << 20) +# define R128_STENCIL_ZPASS_ZERO (1 << 20) +# define R128_STENCIL_ZPASS_REPLACE (2 << 20) +# define R128_STENCIL_ZPASS_INC (3 << 20) +# define R128_STENCIL_ZPASS_DEC (4 << 20) +# define R128_STENCIL_ZPASS_INV (5 << 20) +# define R128_STENCIL_ZFAIL_KEEP (0 << 24) +# define R128_STENCIL_ZFAIL_ZERO (1 << 24) +# define R128_STENCIL_ZFAIL_REPLACE (2 << 24) +# define R128_STENCIL_ZFAIL_INC (3 << 24) +# define R128_STENCIL_ZFAIL_DEC (4 << 24) +# define R128_STENCIL_ZFAIL_INV (5 << 24) +#define R128_TEX_CNTL_C 0x1c9c +# define R128_Z_ENABLE (1 << 0) +# define R128_Z_WRITE_ENABLE (1 << 1) +# define R128_STENCIL_ENABLE (1 << 3) +# define R128_SHADE_ENABLE (0 << 4) +# define R128_TEXMAP_ENABLE (1 << 4) +# define R128_SEC_TEXMAP_ENABLE (1 << 5) +# define R128_FOG_ENABLE (1 << 7) +# define R128_DITHER_ENABLE (1 << 8) +# define R128_ALPHA_ENABLE (1 << 9) +# define R128_ALPHA_TEST_ENABLE (1 << 10) +# define R128_SPEC_LIGHT_ENABLE (1 << 11) +# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) +# define R128_LIGHT_DIS (0 << 14) +# define R128_LIGHT_COPY (1 << 14) +# define R128_LIGHT_MODULATE (2 << 14) +# define R128_LIGHT_ADD (3 << 14) +# define R128_LIGHT_BLEND_CONSTANT (4 << 14) +# define R128_LIGHT_BLEND_TEXTURE (5 << 14) +# define R128_LIGHT_BLEND_VERTEX (6 << 14) +# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define R128_ALPHA_LIGHT_DIS (0 << 18) +# define R128_ALPHA_LIGHT_COPY (1 << 18) +# define R128_ALPHA_LIGHT_MODULATE (2 << 18) +# define R128_ALPHA_LIGHT_ADD (3 << 18) +# define R128_ANTI_ALIAS (1 << 21) +# define R128_TEX_CACHE_FLUSH (1 << 23) +# define R128_LOD_BIAS_SHIFT 24 +# define R128_LOD_BIAS_MASK (0xff << 24) +#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0 +# define R128_REF_ALPHA_MASK 0xff +# define R128_MISC_SCALE_3D_NOOP (0 << 8) +# define R128_MISC_SCALE_3D_SCALE (1 << 8) +# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define R128_MISC_SCALE_PIX_BLEND (0 << 10) +# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define R128_FOG_VERTEX (0 << 14) +# define R128_FOG_TABLE (1 << 14) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) +# define R128_ALPHA_BLEND_SRC_MASK (15 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) +# define R128_ALPHA_BLEND_DST_MASK (15 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_ALPHA_TEST_MASK (7 << 24) +#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 +#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 +#define R128_FOG_COLOR_C 0x1cac +# define R128_FOG_BLUE_SHIFT 0 +# define R128_FOG_GREEN_SHIFT 8 +# define R128_FOG_RED_SHIFT 16 +#define R128_PRIM_TEX_CNTL_C 0x1cb0 +# define R128_MIN_BLEND_NEAREST (0 << 1) +# define R128_MIN_BLEND_LINEAR (1 << 1) +# define R128_MIN_BLEND_MIPNEAREST (2 << 1) +# define R128_MIN_BLEND_MIPLINEAR (3 << 1) +# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1) +# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1) +# define R128_MIN_BLEND_MASK (7 << 1) +# define R128_MAG_BLEND_NEAREST (0 << 4) +# define R128_MAG_BLEND_LINEAR (1 << 4) +# define R128_MAG_BLEND_MASK (7 << 4) +# define R128_MIP_MAP_DISABLE (1 << 7) +# define R128_TEX_CLAMP_S_WRAP (0 << 8) +# define R128_TEX_CLAMP_S_MIRROR (1 << 8) +# define R128_TEX_CLAMP_S_CLAMP (2 << 8) +# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8) +# define R128_TEX_CLAMP_S_MASK (3 << 8) +# define R128_TEX_WRAP_S (1 << 10) +# define R128_TEX_CLAMP_T_WRAP (0 << 11) +# define R128_TEX_CLAMP_T_MIRROR (1 << 11) +# define R128_TEX_CLAMP_T_CLAMP (2 << 11) +# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11) +# define R128_TEX_CLAMP_T_MASK (3 << 11) +# define R128_TEX_WRAP_T (1 << 13) +# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14) +# define R128_DATATYPE_VQ (0 << 16) +# define R128_DATATYPE_CI4 (1 << 16) +# define R128_DATATYPE_CI8 (2 << 16) +# define R128_DATATYPE_ARGB1555 (3 << 16) +# define R128_DATATYPE_RGB565 (4 << 16) +# define R128_DATATYPE_RGB888 (5 << 16) +# define R128_DATATYPE_ARGB8888 (6 << 16) +# define R128_DATATYPE_RGB332 (7 << 16) +# define R128_DATATYPE_Y8 (8 << 16) +# define R128_DATATYPE_RGB8 (9 << 16) +# define R128_DATATYPE_CI16 (10 << 16) +# define R128_DATATYPE_YUV422 (11 << 16) +# define R128_DATATYPE_YUV422_2 (12 << 16) +# define R128_DATATYPE_AYUV444 (14 << 16) +# define R128_DATATYPE_ARGB4444 (15 << 16) +# define R128_PALLETE_EITHER (0 << 20) +# define R128_PALLETE_1 (1 << 20) +# define R128_PALLETE_2 (2 << 20) +# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) +#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 +# define R128_COMB_DIS (0 << 0) +# define R128_COMB_COPY (1 << 0) +# define R128_COMB_COPY_INP (2 << 0) +# define R128_COMB_MODULATE (3 << 0) +# define R128_COMB_MODULATE2X (4 << 0) +# define R128_COMB_MODULATE4X (5 << 0) +# define R128_COMB_ADD (6 << 0) +# define R128_COMB_ADD_SIGNED (7 << 0) +# define R128_COMB_BLEND_VERTEX (8 << 0) +# define R128_COMB_BLEND_TEXTURE (9 << 0) +# define R128_COMB_BLEND_CONST (10 << 0) +# define R128_COMB_BLEND_PREMULT (11 << 0) +# define R128_COMB_BLEND_PREV (12 << 0) +# define R128_COMB_BLEND_PREMULT_INV (13 << 0) +# define R128_COMB_ADD_SIGNED2X (14 << 0) +# define R128_COMB_BLEND_CONST_COLOR (15 << 0) +# define R128_COMB_MASK (15 << 0) +# define R128_COLOR_FACTOR_TEX (4 << 4) +# define R128_COLOR_FACTOR_NTEX (5 << 4) +# define R128_COLOR_FACTOR_ALPHA (6 << 4) +# define R128_COLOR_FACTOR_NALPHA (7 << 4) +# define R128_COLOR_FACTOR_MASK (15 << 4) +# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10) +# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10) +# define R128_INPUT_FACTOR_INT_COLOR (4 << 10) +# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10) +# define R128_INPUT_FACTOR_MASK (15 << 10) +# define R128_COMB_ALPHA_DIS (0 << 14) +# define R128_COMB_ALPHA_COPY (1 << 14) +# define R128_COMB_ALPHA_COPY_INP (2 << 14) +# define R128_COMB_ALPHA_MODULATE (3 << 14) +# define R128_COMB_ALPHA_MODULATE2X (4 << 14) +# define R128_COMB_ALPHA_MODULATE4X (5 << 14) +# define R128_COMB_ALPHA_ADD (6 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14) +# define R128_COMB_ALPHA_MASK (15 << 14) +# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18) +# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) +# define R128_ALPHA_FACTOR_MASK (15 << 18) +# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25) +# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25) +# define R128_INP_FACTOR_A_MASK (7 << 25) +#define R128_TEX_SIZE_PITCH_C 0x1cb8 +# define R128_TEX_PITCH_SHIFT 0 +# define R128_TEX_SIZE_SHIFT 4 +# define R128_TEX_HEIGHT_SHIFT 8 +# define R128_TEX_MIN_SIZE_SHIFT 12 +# define R128_SEC_TEX_PITCH_SHIFT 16 +# define R128_SEC_TEX_SIZE_SHIFT 20 +# define R128_SEC_TEX_HEIGHT_SHIFT 24 +# define R128_SEC_TEX_MIN_SIZE_SHIFT 28 +# define R128_TEX_PITCH_MASK (0x0f << 0) +# define R128_TEX_SIZE_MASK (0x0f << 4) +# define R128_TEX_HEIGHT_MASK (0x0f << 8) +# define R128_TEX_MIN_SIZE_MASK (0x0f << 12) +# define R128_SEC_TEX_PITCH_MASK (0x0f << 16) +# define R128_SEC_TEX_SIZE_MASK (0x0f << 20) +# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24) +# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) +# define R128_TEX_SIZE_PITCH_SHIFT 0 +# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16 +# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0) +# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) +#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc +#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0 +#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4 +#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8 +#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc +#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0 +#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4 +#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8 +#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc +#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0 +#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4 +# define R128_TEX_NO_TILE (0 << 30) +# define R128_TEX_TILED_BY_HOST (1 << 30) +# define R128_TEX_TILED_BY_STORAGE (2 << 30) +# define R128_TEX_TILED_BY_STORAGE2 (3 << 30) + +#define R128_SEC_TEX_CNTL_C 0x1d00 +# define R128_SEC_SELECT_PRIM_ST (0 << 0) +# define R128_SEC_SELECT_SEC_ST (1 << 0) +#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04 +# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) +# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) +# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) +#define R128_SEC_TEX_0_OFFSET_C 0x1d08 +#define R128_SEC_TEX_1_OFFSET_C 0x1d0c +#define R128_SEC_TEX_2_OFFSET_C 0x1d10 +#define R128_SEC_TEX_3_OFFSET_C 0x1d14 +#define R128_SEC_TEX_4_OFFSET_C 0x1d18 +#define R128_SEC_TEX_5_OFFSET_C 0x1d1c +#define R128_SEC_TEX_6_OFFSET_C 0x1d20 +#define R128_SEC_TEX_7_OFFSET_C 0x1d24 +#define R128_SEC_TEX_8_OFFSET_C 0x1d28 +#define R128_SEC_TEX_9_OFFSET_C 0x1d2c +#define R128_SEC_TEX_10_OFFSET_C 0x1d30 +#define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_BLUE_SHIFT 0 +# define R128_CONSTANT_GREEN_SHIFT 8 +# define R128_CONSTANT_RED_SHIFT 16 +# define R128_CONSTANT_ALPHA_SHIFT 24 +#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 +# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0 +# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8 +# define R128_PRIM_TEX_BORDER_RED_SHIFT 16 +# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0 +# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8 +# define R128_SEC_TEX_BORDER_RED_SHIFT 16 +# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_STEN_REF_MASK_C 0x1d40 +# define R128_STEN_REFERENCE_SHIFT 0 +# define R128_STEN_MASK_SHIFT 16 +# define R128_STEN_WRITE_MASK_SHIFT 24 +#define R128_PLANE_3D_MASK_C 0x1d44 +#define R128_TEX_CACHE_STAT_COUNT 0x1974 + + + /* Constants */ +#define R128_AGP_TEX_OFFSET 0x02000000 + +#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0 + + /* CCE packet types */ +#define R128_CCE_PACKET0 0x00000000 +#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000 +#define R128_CCE_PACKET1 0x40000000 +#define R128_CCE_PACKET2 0x80000000 +#define R128_CCE_PACKET3 0xC0000000 +#define R128_CCE_PACKET3_NOP 0xC0001000 +#define R128_CCE_PACKET3_PAINT 0xC0001100 +#define R128_CCE_PACKET3_BITBLT 0xC0001200 +#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300 +#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 +#define R128_CCE_PACKET3_POLYLINE 0xC0001500 +#define R128_CCE_PACKET3_SCALING 0xC0001600 +#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700 +#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800 +#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900 +#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00 +#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 +#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 +#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00 +#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 +#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100 +#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200 +#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 +#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 +#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 +#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600 +#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 +#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 +#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 +#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 +#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 +#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 +#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 +#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 +#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 +#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 +#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 +#define R128_CCE_PACKET3_PURGE 0xC0002D00 +#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 +# define R128_CCE_PACKET_MASK 0xC0000000 +# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 +# define R128_CCE_PACKET_MAX_DWORDS (1 << 12) +# define R128_CCE_PACKET0_REG_MASK 0x000007ff +# define R128_CCE_PACKET1_REG0_MASK 0x000007ff +# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define R128_CCE_VC_FRMT_RHW 0x00000001 +#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 +#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004 +#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 +#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010 +#define R128_CCE_VC_FRMT_SPEC_F 0x00000020 +#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040 +#define R128_CCE_VC_FRMT_S_T 0x00000080 +#define R128_CCE_VC_FRMT_S2_T2 0x00000100 +#define R128_CCE_VC_FRMT_RHW2 0x00000200 + +#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define R128_CCE_VC_CNTL_NUM_SHIFT 16 + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h:1.5 --- /dev/null Mon Dec 18 14:30:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h Fri Dec 15 17:48:43 2000 @@ -0,0 +1,201 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h,v 1.5 2000/12/15 22:48:43 dawes Exp $ */ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * + */ + +#ifndef _R128_SAREA_H_ +#define _R128_SAREA_H_ + +#include "Xmd.h" + +/* WARNING: If you change any of these defines, make sure to change the + * defines in the kernel file (r128_drm.h) + */ +#ifndef __R128_SAREA_DEFINES__ +#define __R128_SAREA_DEFINES__ + +/* What needs to be changed for the current vertex buffer? + */ +#define R128_UPLOAD_CONTEXT 0x001 +#define R128_UPLOAD_SETUP 0x002 +#define R128_UPLOAD_TEX0 0x004 +#define R128_UPLOAD_TEX1 0x008 +#define R128_UPLOAD_TEX0IMAGES 0x010 +#define R128_UPLOAD_TEX1IMAGES 0x020 +#define R128_UPLOAD_CORE 0x040 +#define R128_UPLOAD_MASKS 0x080 +#define R128_UPLOAD_WINDOW 0x100 +#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */ +#define R128_REQUIRE_QUIESCENCE 0x400 +#define R128_UPLOAD_ALL 0x7ff + +#define R128_FRONT 0x1 +#define R128_BACK 0x2 +#define R128_DEPTH 0x4 + +/* Primitive types + */ +#define R128_POINTS 0x1 +#define R128_LINES 0x2 +#define R128_LINE_STRIP 0x3 +#define R128_TRIANGLES 0x4 +#define R128_TRIANGLE_FAN 0x5 +#define R128_TRIANGLE_STRIP 0x6 + +/* Vertex/indirect buffer size + */ +#if 1 +#define R128_BUFFER_SIZE 16384 +#else +#define R128_BUFFER_SIZE (128 * 1024) +#endif + +/* Byte offsets for indirect buffer data + */ +#define R128_INDEX_PRIM_OFFSET 20 +#define R128_HOSTDATA_BLIT_OFFSET 32 + +/* Keep these small for testing + */ +#define R128_NR_SAREA_CLIPRECTS 12 + +/* There are 2 heaps (local/AGP). Each region within a heap is a + * minimum of 64k, and there are at most 64 of them per heap. + */ +#define R128_LOCAL_TEX_HEAP 0 +#define R128_AGP_TEX_HEAP 1 +#define R128_NR_TEX_HEAPS 2 +#define R128_NR_TEX_REGIONS 64 +#define R128_LOG_TEX_GRANULARITY 16 + +#define R128_NR_CONTEXT_REGS 12 +#define R128_TEX_MAXLEVELS 11 + +#endif /* __R128_SAREA_DEFINES__ */ + +typedef struct { + /* Context state - can be written in one large chunk */ + unsigned int dst_pitch_offset_c; + unsigned int dp_gui_master_cntl_c; + unsigned int sc_top_left_c; + unsigned int sc_bottom_right_c; + unsigned int z_offset_c; + unsigned int z_pitch_c; + unsigned int z_sten_cntl_c; + unsigned int tex_cntl_c; + unsigned int misc_3d_state_cntl_reg; + unsigned int texture_clr_cmp_clr_c; + unsigned int texture_clr_cmp_msk_c; + unsigned int fog_color_c; + + /* Texture state */ + unsigned int tex_size_pitch_c; + unsigned int constant_color_c; + + /* Setup state */ + unsigned int pm4_vc_fpu_setup; + unsigned int setup_cntl; + + /* Mask state */ + unsigned int dp_write_mask; + unsigned int sten_ref_mask_c; + unsigned int plane_3d_mask_c; + + /* Window state */ + unsigned int window_xy_offset; + + /* Core state */ + unsigned int scale_3d_cntl; +} r128_context_regs_t; + +/* Setup registers for each texture unit + */ +typedef struct { + unsigned int tex_cntl; + unsigned int tex_combine_cntl; + unsigned int tex_size_pitch; + unsigned int tex_offset[R128_TEX_MAXLEVELS]; + unsigned int tex_border_color; +} r128_texture_regs_t; + +typedef struct { + unsigned char next, prev; /* indices to form a circular LRU */ + unsigned char in_use; /* owned by a client, or free? */ + int age; /* tracked by clients to update local LRU's */ +} r128_tex_region_t; + +typedef struct { + /* The channel for communication of state information to the kernel + * on firing a vertex buffer. + */ + r128_context_regs_t ContextState; + r128_texture_regs_t TexState[R128_NR_TEX_HEAPS]; + unsigned int dirty; + unsigned int vertsize; + unsigned int vc_format; + + /* The current cliprects, or a subset thereof. + */ + XF86DRIClipRectRec boxes[R128_NR_SAREA_CLIPRECTS]; + unsigned int nbox; + + /* Counters for throttling of rendering clients. + */ + unsigned int last_frame; + unsigned int last_dispatch; + + /* Maintain an LRU of contiguous regions of texture space. If you + * think you own a region of texture memory, and it has an age + * different to the one you set, then you are mistaken and it has + * been stolen by another client. If global texAge hasn't changed, + * there is no need to walk the list. + * + * These regions can be used as a proxy for the fine-grained texture + * information of other clients - by maintaining them in the same + * lru which is used to age their own textures, clients have an + * approximate lru for the whole of global texture space, and can + * make informed decisions as to which areas to kick out. There is + * no need to choose whether to kick out your own texture or someone + * else's - simply eject them all in LRU order. + */ + /* Last elt is sentinal */ + r128_tex_region_t texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; + /* last time texture was uploaded */ + int texAge[R128_NR_TEX_HEAPS]; + + int ctxOwner; /* last context to upload state */ +} R128SAREAPriv, *R128SAREAPrivPtr; + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h:1.1 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h Thu Nov 2 11:55:39 2000 @@ -0,0 +1,41 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h,v 1.1 2000/11/02 16:55:39 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _R128_VERSION_H_ +#define _R128_VERSION_H_ 1 + +#define R128_NAME "R128" +#define R128_DRIVER_NAME "r128" + +#define R128_VERSION_NAME "4.0.1" + +#define R128_VERSION_MAJOR 4 +#define R128_VERSION_MINOR 0 +#define R128_VERSION_PATCH 1 + +#define R128_VERSION_CURRENT \ + ((R128_VERSION_MAJOR << 20) | \ + (R128_VERSION_MINOR << 10) | \ + (R128_VERSION_PATCH)) + +#endif /* _R128_VERSION_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c:1.14 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c Thu Dec 7 15:42:52 2000 @@ -0,0 +1,866 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c,v 1.14 2000/12/07 20:42:52 mvojkovi Exp $ */ + +#include "r128.h" +#include "r128_reg.h" + +#include "xf86.h" +#include "dixstruct.h" + +#include "Xv.h" +#include "fourcc.h" + +#define OFF_DELAY 250 /* milliseconds */ +#define FREE_DELAY 15000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 + +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +#ifndef XvExtension +void R128InitVideo(ScreenPtr pScreen) {} +#else + +static XF86VideoAdaptorPtr R128SetupImageVideo(ScreenPtr); +static int R128SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int R128GetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +static void R128StopVideo(ScrnInfoPtr, pointer, Bool); +static void R128QueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, + unsigned int *, unsigned int *, pointer); +static int R128PutImage(ScrnInfoPtr, short, short, short, short, short, + short, short, short, int, unsigned char*, short, + short, Bool, RegionPtr, pointer); +static int R128QueryImageAttributes(ScrnInfoPtr, int, unsigned short *, + unsigned short *, int *, int *); + + +static void R128ResetVideo(ScrnInfoPtr); + +static void R128VideoTimerCallback(ScrnInfoPtr pScrn, Time time); + + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvColorKey, xvSaturation, xvDoubleBuffer; + + +typedef struct { + int brightness; + int saturation; + Bool doubleBuffer; + unsigned char currentBuffer; + FBLinearPtr linear; + RegionRec clip; + CARD32 colorKey; + CARD32 videoStatus; + Time offTime; + Time freeTime; +} R128PortPrivRec, *R128PortPrivPtr; + + +void R128InitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + if(info->accel && info->accel->FillSolidRects) + newAdaptor = R128SetupImageVideo(pScreen); + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding = +{ + 0, + "XV_IMAGE", + 2048, 2048, + {1, 1} +}; + +#define NUM_FORMATS 12 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {8, TrueColor}, {8, DirectColor}, {8, PseudoColor}, + {8, GrayScale}, {8, StaticGray}, {8, StaticColor}, + {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, + {15, DirectColor}, {16, DirectColor}, {24, DirectColor} +}; + + +#define NUM_ATTRIBUTES 4 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, + {XvSettable | XvGettable, -64, 63, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 31, "XV_SATURATION"}, + {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"} +}; + +#define NUM_IMAGES 4 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_UYVY, + XVIMAGE_YV12, + XVIMAGE_I420 +}; + +static void +R128ResetVideo(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + + OUTREG(R128_OV0_SCALE_CNTL, 0x80000000); + OUTREG(R128_OV0_EXCLUSIVE_HORZ, 0); + OUTREG(R128_OV0_AUTO_FLIP_CNTL, 0); /* maybe */ + OUTREG(R128_OV0_FILTER_CNTL, 0x0000000f); + OUTREG(R128_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + OUTREG(R128_OV0_GRAPHICS_KEY_MSK, (1 << pScrn->depth) - 1); + OUTREG(R128_OV0_GRAPHICS_KEY_CLR, pPriv->colorKey); + OUTREG(R128_OV0_KEY_CNTL, R128_GRAPHIC_KEY_FN_NE); + OUTREG(R128_OV0_TEST, 0); +} + + +static XF86VideoAdaptorPtr +R128AllocAdaptor(ScrnInfoPtr pScrn) +{ + XF86VideoAdaptorPtr adapt; + R128InfoPtr info = R128PTR(pScrn); + R128PortPrivPtr pPriv; + + if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) + return NULL; + + if(!(pPriv = xcalloc(1, sizeof(R128PortPrivRec) + sizeof(DevUnion)))) + { + xfree(adapt); + return NULL; + } + + adapt->pPortPrivates = (DevUnion*)(&pPriv[1]); + adapt->pPortPrivates[0].ptr = (pointer)pPriv; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvSaturation = MAKE_ATOM("XV_SATURATION"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); + + pPriv->colorKey = info->videoKey; + pPriv->doubleBuffer = TRUE; + pPriv->videoStatus = 0; + pPriv->brightness = 0; + pPriv->saturation = 16; + pPriv->currentBuffer = 0; + + return adapt; +} + +static XF86VideoAdaptorPtr +R128SetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr info = R128PTR(pScrn); + R128PortPrivPtr pPriv; + XF86VideoAdaptorPtr adapt; + + if(!(adapt = R128AllocAdaptor(pScrn))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "ATI Rage128 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = &DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = R128StopVideo; + adapt->SetPortAttribute = R128SetPortAttribute; + adapt->GetPortAttribute = R128GetPortAttribute; + adapt->QueryBestSize = R128QueryBestSize; + adapt->PutImage = R128PutImage; + adapt->QueryImageAttributes = R128QueryImageAttributes; + + info->adaptor = adapt; + + pPriv = (R128PortPrivPtr)(adapt->pPortPrivates[0].ptr); + REGION_INIT(pScreen, &(pPriv->clip), NullBox, 0); + + R128ResetVideo(pScrn); + + return adapt; +} + +/* I really should stick this in miregion */ +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + + +/* R128ClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (xa, ya + inclusive, xb, yb exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +#define DummyScreen screenInfo.screens[0] + +static Bool +R128ClipVideo( + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height +){ + INT32 vscale, hscale, delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + + hscale = ((*xb - *xa) << 16) / (dst->x2 - dst->x1); + vscale = ((*yb - *ya) << 16) / (dst->y2 - dst->y1); + + *xa <<= 16; *xb <<= 16; + *ya <<= 16; *yb <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *xa += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *xb -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *ya += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *yb -= diff * vscale; + } + + if(*xa < 0) { + diff = (- *xa + hscale - 1)/ hscale; + dst->x1 += diff; + *xa += diff * hscale; + } + delta = *xb - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *xb -= diff * hscale; + } + if(*xa >= *xb) return FALSE; + + if(*ya < 0) { + diff = (- *ya + vscale - 1)/ vscale; + dst->y1 += diff; + *ya += diff * vscale; + } + delta = *yb - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *yb -= diff * vscale; + } + if(*ya >= *yb) return FALSE; + + if((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || + (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) + { + RegionRec clipReg; + REGION_INIT(DummyScreen, &clipReg, dst, 1); + REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); + REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; +} + +static void +R128StopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(cleanup) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(R128_OV0_SCALE_CNTL, 0); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } +} + +static int +R128SetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + + if(attribute == xvBrightness) { + if((value < -64) || (value > 63)) + return BadValue; + pPriv->brightness = value; + OUTREG(R128_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + } else + if(attribute == xvSaturation) { + if((value < 0) || (value > 31)) + return BadValue; + pPriv->saturation = value; + OUTREG(R128_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + } else + if(attribute == xvDoubleBuffer) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->doubleBuffer = value; + } else + if(attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(R128_OV0_GRAPHICS_KEY_CLR, pPriv->colorKey); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else return BadMatch; + + return Success; +} + +static int +R128GetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + + if(attribute == xvBrightness) { + *value = pPriv->brightness; + } else + if(attribute == xvSaturation) { + *value = pPriv->saturation; + } else + if(attribute == xvDoubleBuffer) { + *value = pPriv->doubleBuffer ? 1 : 0; + } else + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else return BadMatch; + + return Success; +} + + +static void +R128QueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; +} + + +static void +R128CopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w +){ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +R128CopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w +){ + CARD32 *dst; + CARD8 *s1, *s2, *s3; + int i, j; + + w >>= 1; + + for(j = 0; j < h; j++) { + dst = (CARD32*)dst1; + s1 = src1; s2 = src2; s3 = src3; + i = w; + while(i > 4) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24); + dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24); + dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24); + dst += 4; s2 += 4; s3 += 4; s1 += 8; + i -= 4; + } + while(i--) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst++; s2++; s3++; + s1 += 2; + } + + dst1 += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + + +static FBLinearPtr +R128AllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +){ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16, + PRIORITY_EXTREME); + + if(max_size < size) + return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + } + + return new_linear; +} + +static void +R128DisplayVideo( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, short height, + int pitch, + int left, int right, int top, + BoxPtr dstBox, + short src_w, short src_h, + short drw_w, short drw_h +){ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int v_inc, h_inc, step_by, tmp; + int p1_h_accum_init, p23_h_accum_init; + int p1_v_accum_init; + + v_inc = (src_h << 20) / drw_h; + h_inc = (src_w << 12) / drw_w; + step_by = 1; + + while(h_inc >= (2 << 12)) { + step_by++; + h_inc >>= 1; + } + + /* keep everything in 16.16 */ + + offset += ((left >> 16) & ~7) << 1; + + tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3); + p1_h_accum_init = ((tmp << 4) & 0x000f8000) | + ((tmp << 12) & 0xf0000000); + + tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2); + p23_h_accum_init = ((tmp << 4) & 0x000f8000) | + ((tmp << 12) & 0x70000000); + + tmp = (top & 0x0000ffff) + 0x00018000; + p1_v_accum_init = ((tmp << 4) & 0x03ff8000) | 0x00000001; + + left = (left >> 16) & 7; + + + OUTREG(R128_OV0_REG_LOAD_CNTL, 1); + while(!(INREG(R128_OV0_REG_LOAD_CNTL) & (1 << 3))); + + OUTREG(R128_OV0_H_INC, h_inc | ((h_inc >> 1) << 16)); + OUTREG(R128_OV0_STEP_BY, step_by | (step_by << 8)); + OUTREG(R128_OV0_Y_X_START, dstBox->x1 | (dstBox->y1 << 16)); + OUTREG(R128_OV0_Y_X_END, dstBox->x2 | (dstBox->y2 << 16)); + OUTREG(R128_OV0_V_INC, v_inc); + OUTREG(R128_OV0_P1_BLANK_LINES_AT_TOP, 0x00000fff | ((src_h - 1) << 16)); + OUTREG(R128_OV0_VID_BUF_PITCH0_VALUE, pitch); + OUTREG(R128_OV0_P1_X_START_END, (src_w + left - 1) | (left << 16)); + left >>= 1; src_w >>= 1; + OUTREG(R128_OV0_P2_X_START_END, (src_w + left - 1) | (left << 16)); + OUTREG(R128_OV0_P3_X_START_END, (src_w + left - 1) | (left << 16)); + OUTREG(R128_OV0_VID_BUF0_BASE_ADRS, offset & 0xfffffff0); + OUTREG(R128_OV0_P1_V_ACCUM_INIT, p1_v_accum_init); + OUTREG(R128_OV0_P1_H_ACCUM_INIT, p1_h_accum_init); + OUTREG(R128_OV0_P23_H_ACCUM_INIT, p23_h_accum_init); + + if(id == FOURCC_UYVY) + OUTREG(R128_OV0_SCALE_CNTL, 0x41008C03); + else + OUTREG(R128_OV0_SCALE_CNTL, 0x41008B03); + + OUTREG(R128_OV0_REG_LOAD_CNTL, 0); +} + + +static int +R128PutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool Sync, + RegionPtr clipBoxes, pointer data +){ + R128InfoPtr info = R128PTR(pScrn); + R128PortPrivPtr pPriv = (R128PortPrivPtr)data; + INT32 xa, xb, ya, yb; + unsigned char *dst_start; + int pitch, new_size, offset, s2offset, s3offset; + int srcPitch, srcPitch2, dstPitch; + int top, left, npixels, nlines, bpp; + BoxRec dstBox; + CARD32 tmp; + + /* + * s2offset, s3offset - byte offsets into U and V plane of the + * source where copying starts. Y plane is + * done by editing "buf". + * + * offset - byte offset to the first line of the destination. + * + * dst_start - byte address to the first displayed pel. + * + */ + + /* make the compiler happy */ + s2offset = s3offset = srcPitch2 = 0; + + if(src_w > (drw_w << 4)) + drw_w = src_w >> 4; + if(src_h > (drw_h << 4)) + drw_h = src_h >> 4; + + /* Clip */ + xa = src_x; + xb = src_x + src_w; + ya = src_y; + yb = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if(!R128ClipVideo(&dstBox, &xa, &xb, &ya, &yb, clipBoxes, width, height)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + bpp = pScrn->bitsPerPixel >> 3; + pitch = bpp * pScrn->displayWidth; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + dstPitch = ((width << 1) + 15) & ~15; + new_size = ((dstPitch * height) + bpp - 1) / bpp; + srcPitch = (width + 3) & ~3; + s2offset = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + s3offset = (srcPitch2 * (height >> 1)) + s2offset; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + dstPitch = ((width << 1) + 15) & ~15; + new_size = ((dstPitch * height) + bpp - 1) / bpp; + srcPitch = (width << 1); + break; + } + + if(!(pPriv->linear = R128AllocateMemory(pScrn, pPriv->linear, + pPriv->doubleBuffer ? (new_size << 1) : new_size))) + { + return BadAlloc; + } + + pPriv->currentBuffer ^= 1; + + /* copy data */ + top = ya >> 16; + left = (xa >> 16) & ~1; + npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left; + + offset = (pPriv->linear->offset * bpp) + (top * dstPitch); + if(pPriv->doubleBuffer) + offset += pPriv->currentBuffer * new_size * bpp; + dst_start = info->FB + offset; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + dst_start += left << 1; + tmp = ((top >> 1) * srcPitch2) + (left >> 1); + s2offset += tmp; + s3offset += tmp; + if(id == FOURCC_I420) { + tmp = s2offset; + s2offset = s3offset; + s3offset = tmp; + } + nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top; + R128CopyMungedData(buf + (top * srcPitch) + left, buf + s2offset, + buf + s3offset, dst_start, srcPitch, srcPitch2, + dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + left <<= 1; + buf += (top * srcPitch) + left; + nlines = ((yb + 0xffff) >> 16) - top; + dst_start += left; + R128CopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + } + + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + (*info->accel->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + R128DisplayVideo(pScrn, id, offset, width, height, dstPitch, + xa, xb, ya, &dstBox, src_w, src_h, drw_w, drw_h); + + pPriv->videoStatus = CLIENT_VIDEO_ON; + + info->VideoTimerCallback = R128VideoTimerCallback; + + return Success; +} + + +static int +R128QueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int size, tmp; + + if(*w > 2048) *w = 2048; + if(*h > 2048) *h = 2048; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) pitches[0] = size; + size *= *h; + if(offsets) offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} + +static void +R128VideoTimerCallback(ScrnInfoPtr pScrn, Time time) +{ + R128InfoPtr info = R128PTR(pScrn); + R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + if(pPriv->videoStatus & TIMER_MASK) { + if(pPriv->videoStatus & OFF_TIMER) { + if(pPriv->offTime < time) { + unsigned char *R128MMIO = info->MMIO; + OUTREG(R128_OV0_SCALE_CNTL, 0); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = time + FREE_DELAY; + } + } else { /* FREE_TIMER */ + if(pPriv->freeTime < time) { + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + info->VideoTimerCallback = NULL; + } + } + } else /* shouldn't get here */ + info->VideoTimerCallback = NULL; +} + + +#endif /* !XvExtension */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h:1.8 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h Fri Dec 8 09:41:16 2000 @@ -0,0 +1,387 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h,v 1.8 2000/12/08 14:41:16 alanh Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + */ + +#ifndef _RADEON_H_ +#define _RADEON_H_ + +#include "xf86str.h" + + /* PCI support */ +#include "xf86Pci.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xf86Cursor.h" + + /* Xv support */ +#include "xf86xv.h" + + /* DRI support */ +#undef XF86DRI /* Not yet */ +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dripriv.h" +#include "dri.h" +#include "GL/glxint.h" +#endif + +#define RADEON_DEBUG 0 /* Turn off debugging output */ +#define RADEON_TIMEOUT 2000000 /* Fall out of wait loops after this count */ +#define RADEON_MMIOSIZE 0x80000 +/* Atomic updates of PLL clock don't seem to always work and stick, thus + * the bit never resets. Here - we use our own check by reading back the + * register we've just wrote to make sure it's got the Right! value */ +#define RADEON_ATOMIC_UPDATE 0 /* Use PLL Atomic updates (seems broken) */ + +#define RADEON_VBIOS_SIZE 0x00010000 + +#if RADEON_DEBUG +#define RADEONTRACE(x) \ + do { \ + ErrorF("(**) %s(%d): ", RADEON_NAME, pScrn->scrnIndex); \ + ErrorF x; \ + } while (0); +#else +#define RADEONTRACE(x) +#endif + + +/* Other macros */ +#define RADEON_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#define RADEON_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) +#define RADEONPTR(pScrn) ((RADEONInfoPtr)(pScrn)->driverPrivate) + +typedef struct { /* All values in XCLKS */ + int ML; /* Memory Read Latency */ + int MB; /* Memory Burst Length */ + int Trcd; /* RAS to CAS delay */ + int Trp; /* RAS percentage */ + int Twr; /* Write Recovery */ + int CL; /* CAS Latency */ + int Tr2w; /* Read to Write Delay */ + int Rloop; /* Loop Latency */ + int Rloop_fudge; /* Add to ML to get Rloop */ + char *name; +} RADEONRAMRec, *RADEONRAMPtr; + +typedef struct { + /* Common registers */ + CARD32 ovr_clr; + CARD32 ovr_wid_left_right; + CARD32 ovr_wid_top_bottom; + CARD32 ov0_scale_cntl; + CARD32 mpp_tb_config; + CARD32 mpp_gp_config; + CARD32 subpic_cntl; + CARD32 viph_control; + CARD32 i2c_cntl_1; + CARD32 gen_int_cntl; + CARD32 cap0_trig_cntl; + CARD32 cap1_trig_cntl; + CARD32 bus_cntl; + + /* Other registers to save for VT switches */ + CARD32 dp_datatype; + CARD32 rbbm_soft_reset; + CARD32 clock_cntl_index; + CARD32 amcgpio_en_reg; + CARD32 amcgpio_mask; + + /* CRTC registers */ + CARD32 crtc_gen_cntl; + CARD32 crtc_ext_cntl; + CARD32 dac_cntl; + CARD32 crtc_h_total_disp; + CARD32 crtc_h_sync_strt_wid; + CARD32 crtc_v_total_disp; + CARD32 crtc_v_sync_strt_wid; + CARD32 crtc_offset; + CARD32 crtc_offset_cntl; + CARD32 crtc_pitch; + + /* CRTC2 registers */ + CARD32 crtc2_gen_cntl; + + /* Flat panel registers */ + CARD32 fp_crtc_h_total_disp; + CARD32 fp_crtc_v_total_disp; + CARD32 fp_gen_cntl; + CARD32 fp_h_sync_strt_wid; + CARD32 fp_horz_stretch; + CARD32 fp_panel_cntl; + CARD32 fp_v_sync_strt_wid; + CARD32 fp_vert_stretch; + CARD32 lvds_gen_cntl; + CARD32 tmds_crc; + + /* Computed values for PLL */ + CARD32 dot_clock_freq; + CARD32 pll_output_freq; + int feedback_div; + int post_div; + + /* PLL registers */ + CARD32 ppll_ref_div; + CARD32 ppll_div_3; + CARD32 htotal_cntl; + + /* DDA register */ + CARD32 dda_config; + CARD32 dda_on_off; + + /* Pallet */ + Bool palette_valid; + CARD32 palette[256]; +} RADEONSaveRec, *RADEONSavePtr; + +typedef struct { + CARD16 reference_freq; + CARD16 reference_div; + CARD32 min_pll_freq; + CARD32 max_pll_freq; + CARD16 xclk; +} RADEONPLLRec, *RADEONPLLPtr; + +typedef struct { + int bitsPerPixel; + int depth; + int displayWidth; + int pixel_code; + int pixel_bytes; + DisplayModePtr mode; +} RADEONFBLayout; + +typedef struct { + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + int Chipset; + Bool Primary; + + Bool FBDev; + + unsigned long LinearAddr; /* Frame buffer physical address */ + unsigned long MMIOAddr; /* MMIO region physical address */ + unsigned long BIOSAddr; /* BIOS physical address */ + Bool BIOSFromPCI; /* BIOS is read from PCI space */ + + unsigned char *MMIO; /* Map of MMIO region */ + unsigned char *FB; /* Map of frame buffer */ + CARD8 *VBIOS; /* Video BIOS pointer */ + + CARD32 MemCntl; + CARD32 BusCntl; + unsigned long FbMapSize; /* Size of frame buffer, in bytes */ + int Flags; /* Saved copy of mode flags */ + +#ifdef ENABLE_FLAT_PANEL + Bool HasPanelRegs; /* Current chip can connect to a FP */ + Bool CRTOnly; /* Only use External CRT instead of FP */ + int FPBIOSstart; /* Start of the flat panel info */ + + /* Computed values for FPs */ + int PanelXRes; + int PanelYRes; + int PanelPwrDly; +#endif + + RADEONPLLRec pll; + RADEONRAMPtr ram; + + RADEONSaveRec SavedReg; /* Original (text) mode */ + RADEONSaveRec ModeReg; /* Current mode */ + Bool (*CloseScreen)(int, ScreenPtr); + + void (*BlockHandler)(int, pointer, pointer, pointer); + + Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ + + XAAInfoRecPtr accel; + Bool accelOn; + xf86CursorInfoPtr cursor; + unsigned long cursor_start; + unsigned long cursor_end; + + int fifo_slots; /* Free slots in the FIFO (64 max) */ + int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ + Bool dac6bits; /* Use 6 bit DAC? */ + + /* Computed values for Radeon */ + int pitch; + int datatype; + CARD32 dp_gui_master_cntl; + + /* Saved values for ScreenToScreenCopy */ + int xdir; + int ydir; + + /* ScanlineScreenToScreenColorExpand support */ + unsigned char *scratch_buffer[1]; + unsigned char *scratch_save; + int scanline_x; + int scanline_y; + int scanline_h; + int scanline_h_w; + int scanline_words; + int scanline_direct; + int scanline_bpp; /* Only used for ImageWrite */ + + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; + + RADEONFBLayout CurrentLayout; +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig *pVisualConfigs; + RADEONConfigPrivPtr pVisualConfigsPriv; + + drmHandle fbHandle; + + drmSize registerSize; + drmHandle registerHandle; + + Bool IsPCI; /* Current card is a PCI card */ + + drmSize agpSize; + drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ + unsigned long agpOffset; + unsigned char *AGP; /* Map */ + int agpMode; + + Bool CPInUse; /* CP is currently active */ + int CPMode; /* CP mode that server/clients use */ + int CPFifoSize; /* Size of the CP command FIFO */ + Bool CPSecure; /* CP security enabled */ + int CPusecTimeout; /* CP timeout in usecs */ + Bool CP2D; /* CP is used for X server 2D prims */ + + /* CP ring buffer data */ + unsigned long ringStart; /* Offset into AGP space */ + drmHandle ringHandle; /* Handle from drmAddMap */ + drmSize ringMapSize; /* Size of map */ + int ringSize; /* Size of ring (in MB) */ + unsigned char *ring; /* Map */ + int ringSizeLog2QW; + + unsigned long ringReadOffset; /* Offset into AGP space */ + drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ + drmSize ringReadMapSize; /* Size of map */ + unsigned char *ringReadPtr; /* Map */ + + /* CP vertex buffer data */ + unsigned long vbStart; /* Offset into AGP space */ + drmHandle vbHandle; /* Handle from drmAddMap */ + drmSize vbMapSize; /* Size of map */ + int vbSize; /* Size of vert bufs (in MB) */ + unsigned char *vb; /* Map */ + int vbBufSize; /* Size of individual vert buf */ + int vbNumBufs; /* Number of vert bufs */ + drmBufMapPtr vbBufs; /* Buffer map */ + + /* CP indirect buffer data */ + unsigned long indStart; /* Offset into AGP space */ + drmHandle indHandle; /* Handle from drmAddMap */ + drmSize indMapSize; /* Size of map */ + int indSize; /* Size of indirect bufs (in MB) */ + unsigned char *ind; /* Map */ + + /* CP AGP Texture data */ + unsigned long agpTexStart; /* Offset into AGP space */ + drmHandle agpTexHandle; /* Handle from drmAddMap */ + drmSize agpTexMapSize; /* Size of map */ + int agpTexSize; /* Size of AGP tex space (in MB) */ + unsigned char *agpTex; /* Map */ + int log2AGPTexGran; + + /* DRI screen private data */ + int fbX; + int fbY; + int backX; + int backY; + int depthX; + int depthY; + int textureX; + int textureY; + int textureSize; + int log2TexGran; +#endif + XF86VideoAdaptorPtr adaptor; + void (*VideoTimerCallback)(ScrnInfoPtr, Time); + int videoKey; + Bool showCache; +} RADEONInfoRec, *RADEONInfoPtr; + +#define RADEONWaitForFifo(pScrn, entries) \ +do { \ + if (info->fifo_slots < entries) \ + RADEONWaitForFifoFunction(pScrn, entries); \ + info->fifo_slots -= entries; \ +} while (0) + +extern void RADEONWaitForFifoFunction(ScrnInfoPtr pScrn, int entries); +extern void RADEONWaitForIdle(ScrnInfoPtr pScrn); +extern void RADEONEngineReset(ScrnInfoPtr pScrn); +extern void RADEONEngineFlush(ScrnInfoPtr pScrn); + +extern unsigned RADEONINPLL(ScrnInfoPtr pScrn, int addr); +extern void RADEONWaitForVerticalSync(ScrnInfoPtr pScrn); + +extern Bool RADEONAccelInit(ScreenPtr pScreen); +extern void RADEONEngineInit(ScrnInfoPtr pScrn); +extern Bool RADEONCursorInit(ScreenPtr pScreen); +extern Bool RADEONDGAInit(ScreenPtr pScreen); + +extern int RADEONMinBits(int val); + +extern void RADEONInitVideo(ScreenPtr); + +#ifdef XF86DRI +extern Bool RADEONDRIScreenInit(ScreenPtr pScreen); +extern void RADEONDRICloseScreen(ScreenPtr pScreen); +extern Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen); +extern void RADEONCPStart(ScrnInfoPtr pScrn); +extern void RADEONCPStop(ScrnInfoPtr pScrn); +extern void RADEONCPResetRing(ScrnInfoPtr pScrn); +extern void RADEONCPWaitForIdle(ScrnInfoPtr pScrn); +#endif + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c:1.4 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c Sat Nov 18 14:37:12 2000 @@ -0,0 +1,974 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c,v 1.4 2000/11/18 19:37:12 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * Credits: + * + * Thanks to Ani Joshi <ajoshi@shell.unixbox.com> for providing source + * code to his Radeon driver. Portions of this file are based on the + * initialization code for that driver. + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * Notes on unimplemented XAA optimizations: + * + * SetClipping: This has been removed as XAA expects 16bit registers + * for full clipping. + * TwoPointLine: The Radeon supports this. Not Bresenham. + * DashedLine with non-power-of-two pattern length: Apparently, there is + * no way to set the length of the pattern -- it is always + * assumed to be 8 or 32 (or 1024?). + * ScreenToScreenColorExpandFill: See p. 4-17 of the Technical Reference + * Manual where it states that monochrome expansion of frame + * buffer data is not supported. + * CPUToScreenColorExpandFill, direct: The implementation here uses a hybrid + * direct/indirect method. If we had more data registers, + * then we could do better. If XAA supported a trigger write + * address, the code would be simpler. + * Color8x8PatternFill: Apparently, an 8x8 color brush cannot take an 8x8 + * pattern from frame buffer memory. + * ImageWrites: Same as CPUToScreenColorExpandFill + * + */ + +#define RADEON_IMAGEWRITE 0 /* Turned off by default - slower in accel */ + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_reg.h" +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dri.h" +#endif + + /* Line support */ +#include "miline.h" + + /* X and server generic header files */ +#include "xf86.h" + +static struct { + int rop; + int pattern; +} RADEON_ROP[] = { + { RADEON_ROP3_ZERO, RADEON_ROP3_ZERO }, /* GXclear */ + { RADEON_ROP3_DSa, RADEON_ROP3_DPa }, /* Gxand */ + { RADEON_ROP3_SDna, RADEON_ROP3_PDna }, /* GXandReverse */ + { RADEON_ROP3_S, RADEON_ROP3_P }, /* GXcopy */ + { RADEON_ROP3_DSna, RADEON_ROP3_DPna }, /* GXandInverted */ + { RADEON_ROP3_D, RADEON_ROP3_D }, /* GXnoop */ + { RADEON_ROP3_DSx, RADEON_ROP3_DPx }, /* GXxor */ + { RADEON_ROP3_DSo, RADEON_ROP3_DPo }, /* GXor */ + { RADEON_ROP3_DSon, RADEON_ROP3_DPon }, /* GXnor */ + { RADEON_ROP3_DSxn, RADEON_ROP3_PDxn }, /* GXequiv */ + { RADEON_ROP3_Dn, RADEON_ROP3_Dn }, /* GXinvert */ + { RADEON_ROP3_SDno, RADEON_ROP3_PDno }, /* GXorReverse */ + { RADEON_ROP3_Sn, RADEON_ROP3_Pn }, /* GXcopyInverted */ + { RADEON_ROP3_DSno, RADEON_ROP3_DPno }, /* GXorInverted */ + { RADEON_ROP3_DSan, RADEON_ROP3_DPan }, /* GXnand */ + { RADEON_ROP3_ONE, RADEON_ROP3_ONE } /* GXset */ +}; + +/* Flush all dirty data in the Pixel Cache to memory. */ +void RADEONEngineFlush(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + OUTREGP(RADEON_RB2D_DSTCACHE_CTLSTAT, RADEON_RB2D_DC_FLUSH_ALL, + ~RADEON_RB2D_DC_FLUSH_ALL); + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (!(INREG(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY)) break; + } +} + +/* Reset graphics card to known state. */ +void RADEONEngineReset(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 clock_cntl_index; + CARD32 mclk_cntl; + CARD32 rbbm_soft_reset; + + RADEONEngineFlush(pScrn); + + clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); + mclk_cntl = INPLL(pScrn, RADEON_MCLK_CNTL); + + OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | 0x003f0000)); + + rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); + + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset | + RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB | + RADEON_SOFT_RESET_HDP); + INREG(RADEON_RBBM_SOFT_RESET); + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset & + ~(RADEON_SOFT_RESET_CP | + RADEON_SOFT_RESET_HI | + RADEON_SOFT_RESET_SE | + RADEON_SOFT_RESET_RE | + RADEON_SOFT_RESET_PP | + RADEON_SOFT_RESET_E2 | + RADEON_SOFT_RESET_RB | + RADEON_SOFT_RESET_HDP)); + INREG(RADEON_RBBM_SOFT_RESET); + + OUTPLL(RADEON_MCLK_CNTL, mclk_cntl); + OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); + OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); + +#ifdef XF86DRI + if (RADEONCP_USE_RING_BUFFER(info->CPMode)) RADEONCPResetRing(pScrn); +#endif +} + +/* The FIFO has 64 slots. This routines waits until at least `entries' of + these slots are empty. */ +void RADEONWaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < RADEON_TIMEOUT; i++) { + info->fifo_slots = + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK; + if (info->fifo_slots >= entries) return; + } + RADEONTRACE(("FIFO timed out: %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FIFO timed out, resetting engine...\n"); + RADEONEngineInit(pScrn); +#ifdef XF86DRI + if (info->CP2D) RADEONCPStart(pScrn); +#endif + } +} + +/* Wait for the graphics engine to be completely idle: the FIFO has + drained, the Pixel Cache is flushed, and the engine is idle. This is a + standard "sync" function that will make the hardware "quiescent". */ +void RADEONWaitForIdle(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + RADEONTRACE(("WaitForIdle (entering): %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + + RADEONWaitForFifoFunction(pScrn, 64); + + for (;;) { + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (!(INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_ACTIVE)) { + RADEONEngineFlush(pScrn); + return; + } + } + RADEONTRACE(("Idle timed out: %d entries, stat=0x%08x\n", + INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, + INREG(RADEON_RBBM_STATUS))); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Idle timed out, resetting engine...\n"); + RADEONEngineInit(pScrn); +#ifdef XF86DRI + if (info->CP2D) RADEONCPStart(pScrn); +#endif + } +} + +/* Setup for XAA SolidFill. */ +static void RADEONSetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern)); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, color); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT + | RADEON_DST_Y_TOP_TO_BOTTOM)); +} + +/* Subsequent XAA SolidFillRect. + + Tests: xtest CH06/fllrctngl, xterm +*/ +static void RADEONSubsequentSolidFillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 2); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_WIDTH_HEIGHT, (w << 16) | h); +} + +/* Setup for XAA solid lines. */ +static void RADEONSetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern)); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, color); + OUTREG(RADEON_DP_WRITE_MASK, planemask); +} + + +/* Subsequent XAA solid TwoPointLine line. + + Tests: xtest CH06/drwln, ico, Mark Vojkovich's linetest program + + [See http://www.xfree86.org/devel/archives/devel/1999-Jun/0102.shtml for + Mark Vojkovich's linetest program, posted 2Jun99 to devel@xfree86.org.] +*/ +static void RADEONSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, + int xa, int ya, int xb, int yb, + int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int direction = 0; + + if (xa < xb) direction |= RADEON_DST_X_DIR_LEFT_TO_RIGHT; + if (ya < yb) direction |= RADEON_DST_Y_DIR_TOP_TO_BOTTOM; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DST_Y_X, (ya << 16) | xa); + if (!(flags & OMIT_LAST)) + OUTREG(RADEON_DP_CNTL_XDIR_YDIR_YMAJOR, direction); + OUTREG(RADEON_DST_LINE_START, (ya << 16) | xa); + OUTREG(RADEON_DST_LINE_END, (yb << 16) | xb); +} + +/* Subsequent XAA solid horizontal and vertical lines */ +static void RADEONSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, + int x, int y, int len, int dir ) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DP_CNTL, (RADEON_DST_X_LEFT_TO_RIGHT + | RADEON_DST_Y_TOP_TO_BOTTOM)); + + if (dir == DEGREES_0) { + RADEONSubsequentSolidFillRect(pScrn, x, y, len, 1); + } else { + RADEONSubsequentSolidFillRect(pScrn, x, y, 1, len); + } +} + +/* Setup for XAA dashed lines. + + Tests: xtest CH05/stdshs, XFree86/drwln + + NOTE: Since we can only accelerate lines with power-of-2 patterns of + length <= 32. +*/ +static void RADEONSetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, unsigned int planemask, + int length, unsigned char *pattern) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 pat = *(CARD32 *)pattern; + + switch (length) { + case 2: pat |= pat << 2; /* fall through */ + case 4: pat |= pat << 4; /* fall through */ + case 8: pat |= pat << 8; /* fall through */ + case 16: pat |= pat << 16; + } + + RADEONWaitForFifo(pScrn, 5); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? RADEON_GMC_BRUSH_32x1_MONO_FG_LA + : RADEON_GMC_BRUSH_32x1_MONO_FG_BG) + | RADEON_ROP[rop].pattern + | RADEON_GMC_BYTE_LSB_TO_MSB)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, fg); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, bg); + OUTREG(RADEON_BRUSH_DATA0, pat); +} + +/* Subsequent XAA dashed line. */ +static void RADEONSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int flags, + int phase) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int direction = 0; + + if (xa < xb) direction |= RADEON_DST_X_DIR_LEFT_TO_RIGHT; + if (ya < yb) direction |= RADEON_DST_Y_DIR_TOP_TO_BOTTOM; + + RADEONWaitForFifo(pScrn, 5); + if (!(flags & OMIT_LAST)) + OUTREG(RADEON_DP_CNTL_XDIR_YDIR_YMAJOR, direction); + OUTREG(RADEON_DST_Y_X, (ya << 16) | xa); + OUTREG(RADEON_BRUSH_Y_X, (phase << 16) | phase); + OUTREG(RADEON_DST_LINE_START, (ya << 16) | xa); + OUTREG(RADEON_DST_LINE_END, (yb << 16) | xb); +} + +/* Setup for XAA screen-to-screen copy. + + Tests: xtest CH06/fllrctngl (also tests transparency). +*/ +static void RADEONSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, + int xdir, int ydir, int rop, + unsigned int planemask, + int trans_color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->xdir = xdir; + info->ydir = ydir; + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_NONE + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].rop + | RADEON_DP_SRC_SOURCE_MEMORY)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_CNTL, ((xdir >= 0 + ? RADEON_DST_X_LEFT_TO_RIGHT + : 0) + | (ydir >= 0 + ? RADEON_DST_Y_TOP_TO_BOTTOM + : 0))); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA screen-to-screen copy. */ +static void RADEONSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int xa, int ya, + int xb, int yb, + int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + if (info->xdir < 0) xa += w - 1, xb += w - 1; + if (info->ydir < 0) ya += h - 1, yb += h - 1; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_SRC_Y_X, (ya << 16) | xa); + OUTREG(RADEON_DST_Y_X, (yb << 16) | xb); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +/* Setup for XAA mono 8x8 pattern color expansion. Patterns with + transparency use `bg == -1'. This routine is only used if the XAA + pixmap cache is turned on. + + Tests: xtest XFree86/fllrctngl (no other test will test this routine with + both transparency and non-transparency) +*/ +static void RADEONSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int patternx, int patterny, + int fg, int bg, int rop, + unsigned int planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 6); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | (bg == -1 + ? RADEON_GMC_BRUSH_8X8_MONO_FG_LA + : RADEON_GMC_BRUSH_8X8_MONO_FG_BG) + | RADEON_ROP[rop].pattern + | RADEON_GMC_BYTE_LSB_TO_MSB)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, fg); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, bg); + OUTREG(RADEON_BRUSH_DATA0, patternx); + OUTREG(RADEON_BRUSH_DATA1, patterny); +} + +/* Subsequent XAA 8x8 pattern color expansion. Because they are used in + the setup function, `patternx' and `patterny' are not used here. */ +static void RADEONSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int patternx, int patterny, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_BRUSH_Y_X, (patterny << 8) | patternx); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} + +#if 0 +/* Setup for XAA color 8x8 pattern fill. + + Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off) +*/ +static void RADEONSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, + int patx, int paty, + int rop, unsigned int planemask, + int trans_color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + ErrorF("Color8x8 %d %d %d\n", trans_color, patx, paty); + + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_8x8_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].pattern + | RADEON_DP_SRC_SOURCE_MEMORY)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_SRC_Y_X, (paty << 16) | patx); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA 8x8 pattern color expansion. */ +static void RADEONSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, + int patx, int paty, + int x, int y, int w, int h) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + ErrorF("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h); + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_BRUSH_Y_X, (paty << 16) | patx); + OUTREG(RADEON_DST_Y_X, (y << 16) | x); + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | w); +} +#endif + +/* Setup for XAA indirect CPU-to-screen color expansion (indirect). + Because of how the scratch buffer is initialized, this is really a + mainstore-to-screen color expansion. Transparency is supported when `bg + == -1'. + Implementing the hybrid indirect/direct scheme improved performance in a + few areas: +*/ +static void RADEONSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int + planemask) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + RADEONWaitForFifo(pScrn, 4); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_DST_CLIPPING + | RADEON_GMC_BRUSH_NONE + | (bg == -1 + ? RADEON_GMC_SRC_DATATYPE_MONO_FG_LA + : RADEON_GMC_SRC_DATATYPE_MONO_FG_BG) + | RADEON_ROP[rop].rop + | RADEON_GMC_BYTE_LSB_TO_MSB + | RADEON_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + OUTREG(RADEON_DP_SRC_FRGD_CLR, fg); + OUTREG(RADEON_DP_SRC_BKGD_CLR, bg); +} + +/* Subsequent XAA indirect CPU-to-screen color expansion. This is only + called once for each rectangle. */ +static void RADEONSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr + pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->scanline_h = h; + info->scanline_words = (w + 31) >> 5; + + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(RADEON_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + RADEONWaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(RADEON_SC_TOP_LEFT, (y << 16) | ((x+skipleft) & 0xffff)); + /* MMmm, we don't need the -1 on both y+h or x+w, why ? */ + OUTREG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | ((x+w) & 0xffff)); + OUTREG(RADEON_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | ((w + 31) & ~31)); +} + +/* Subsequent XAA indirect CPU-to-screen color expandion. This is called + once for each scanline. */ +static void RADEONSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + RADEONWaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} + +#if RADEON_IMAGEWRITE +/* Setup for XAA indirect image write. */ +static void RADEONSetupForScanlineImageWrite(ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int trans_color, + int bpp, + int depth) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + info->scanline_bpp = bpp; + + RADEONWaitForFifo(pScrn, 2); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_DST_CLIPPING + | RADEON_GMC_BRUSH_NONE + | RADEON_GMC_SRC_DATATYPE_COLOR + | RADEON_ROP[rop].rop + | RADEON_GMC_BYTE_LSB_TO_MSB + | RADEON_DP_SRC_SOURCE_HOST_DATA)); + OUTREG(RADEON_DP_WRITE_MASK, planemask); + + if (trans_color != -1) { + /* Set up for transparency */ + RADEONWaitForFifo(pScrn, 3); + OUTREG(RADEON_CLR_CMP_CLR_SRC, trans_color); + OUTREG(RADEON_CLR_CMP_MASK, RADEON_CLR_CMP_MSK); + /* Mmmm, Seems as though the transparency compare is opposite to r128 + * It should only draw when source != trans_color, + * this is the opposite of that. */ + OUTREG(RADEON_CLR_CMP_CNTL, (RADEON_SRC_CMP_EQ_COLOR + | RADEON_CLR_CMP_SRC_SOURCE)); + } +} + +/* Subsequent XAA indirect image write. This is only called once for each + rectangle. */ +static void RADEONSubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, + int w, int h, + int skipleft) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int shift = 0; /* 32bpp */ + + if (pScrn->bitsPerPixel == 8) shift = 3; + else if (pScrn->bitsPerPixel == 16) shift = 1; + + info->scanline_h = h; + info->scanline_words = (w * info->scanline_bpp + 31) >> 5; + + if ((info->scanline_words * h) <= 9) { + /* Turn on direct for less than 9 dword colour expansion */ + info->scratch_buffer[0] + = (unsigned char *)(ADDRREG(RADEON_HOST_DATA_LAST) + - (info->scanline_words - 1)); + info->scanline_direct = 1; + } else { + /* Use indirect for anything else */ + info->scratch_buffer[0] = info->scratch_save; + info->scanline_direct = 0; + } + + RADEONWaitForFifo(pScrn, 4 + (info->scanline_direct ? + (info->scanline_words * h) : 0) ); + OUTREG(RADEON_SC_TOP_LEFT, (y << 16) | ((x+skipleft) & 0xffff)); + /* MMmm, we don't need the -1 on both y+h or x+w, why ? */ + OUTREG(RADEON_SC_BOTTOM_RIGHT, ((y+h) << 16) | ((x+w) & 0xffff)); + OUTREG(RADEON_DST_Y_X, (y << 16) | (x & 0xffff)); + /* Have to pad the width here and use clipping engine */ + OUTREG(RADEON_DST_HEIGHT_WIDTH, (h << 16) | ((w + shift) & ~shift)); +} + +/* Subsequent XAA indirect image write. This is called once for each + scanline. */ +static void RADEONSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; + int i; + int left = info->scanline_words; + volatile CARD32 *d; + + if (info->scanline_direct) return; + --info->scanline_h; + while (left) { + if (left <= 8) { + /* Last scanline - finish write to DATA_LAST */ + if (info->scanline_h == 0) { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA_LAST) - (left - 1); left; --left) + *d++ = *p++; + return; + } else { + RADEONWaitForFifo(pScrn, left); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA7) - (left - 1); left; --left) + *d++ = *p++; + } + } else { + RADEONWaitForFifo(pScrn, 8); + /* Unrolling doesn't improve performance */ + for (d = ADDRREG(RADEON_HOST_DATA0), i = 0; i < 8; i++) + *d++ = *p++; + left -= 8; + } + } +} +#endif + +/* Initialize the acceleration hardware. */ +void RADEONEngineInit(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int pitch64; + + RADEONTRACE(("EngineInit (%d/%d)\n", + info->CurrentLayout.pixel_code, + info->CurrentLayout.bitsPerPixel)); + + OUTREG(RADEON_SCALE_3D_CNTL, 0); + RADEONEngineReset(pScrn); + + RADEONWaitForFifo(pScrn, 1); + /* turn of all automatic flushing - we'll do it all */ + OUTREG(RADEON_RB2D_DSTCACHE_MODE, 0); + + switch (info->CurrentLayout.pixel_code) { + case 8: info->datatype = 2; break; + case 15: info->datatype = 3; break; + case 16: info->datatype = 4; break; + case 24: info->datatype = 5; break; + case 32: info->datatype = 6; break; + default: + RADEONTRACE(("Unknown depth/bpp = %d/%d (code = %d)\n", + info->CurrentLayout.depth, + info->CurrentLayout.bitsPerPixel, + info->CurrentLayout.pixel_code)); + } + info->pitch = ((info->CurrentLayout.displayWidth / 8) * + (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1)); + + RADEONTRACE(("Pitch for acceleration = %d\n", info->pitch)); + + pitch64 = ((pScrn->displayWidth * (pScrn->bitsPerPixel / 8) + 0x3f)) >> 6; + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DEFAULT_OFFSET, (INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000) | + (pitch64 << 22)); + + RADEONWaitForFifo(pScrn, 1); +#if X_BYTE_ORDER == X_BIG_ENDIAN + OUTREGP(RADEON_DP_DATATYPE, + RADEON_HOST_BIG_ENDIAN_EN, ~RADEON_HOST_BIG_ENDIAN_EN); +#else + OUTREGP(RADEON_DP_DATATYPE, 0, ~RADEON_HOST_BIG_ENDIAN_EN); +#endif + + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX + | RADEON_DEFAULT_SC_BOTTOM_MAX)); + info->dp_gui_master_cntl = + ((info->datatype << RADEON_GMC_DST_DATATYPE_SHIFT) + | RADEON_GMC_CLR_CMP_CNTL_DIS); + RADEONWaitForFifo(pScrn, 1); + OUTREG(RADEON_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl + | RADEON_GMC_BRUSH_SOLID_COLOR + | RADEON_GMC_SRC_DATATYPE_COLOR)); + + RADEONWaitForFifo(pScrn, 7); + OUTREG(RADEON_DST_LINE_START, 0); + OUTREG(RADEON_DST_LINE_END, 0); + OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff); + OUTREG(RADEON_DP_BRUSH_BKGD_CLR, 0x00000000); + OUTREG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff); + OUTREG(RADEON_DP_SRC_BKGD_CLR, 0x00000000); + OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff); + + RADEONWaitForIdle(pScrn); +} + +#ifdef XF86DRI +/* FIXME: When direct rendering is enabled, we should use the CP to + draw 2D commands */ +static void RADEONCPAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + a->Flags = 0; + + /* Sync */ +#if 1 + a->Sync = RADEONWaitForIdle; +#else + a->Sync = RADEONCCEWaitForIdle; +#endif + +} +#endif + +static void RADEONMMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + a->Flags = (PIXMAP_CACHE + | OFFSCREEN_PIXMAPS + | LINEAR_FRAMEBUFFER); + + /* Sync */ + a->Sync = RADEONWaitForIdle; + + /* Solid Filled Rectangle */ + a->PolyFillRectSolidFlags = 0; + a->SetupForSolidFill = RADEONSetupForSolidFill; + a->SubsequentSolidFillRect = RADEONSubsequentSolidFillRect; + + /* Screen-to-screen Copy */ + a->ScreenToScreenCopyFlags = 0; + a->SetupForScreenToScreenCopy = RADEONSetupForScreenToScreenCopy; + a->SubsequentScreenToScreenCopy = RADEONSubsequentScreenToScreenCopy; + + /* Mono 8x8 Pattern Fill (Color Expand) */ + a->SetupForMono8x8PatternFill + = RADEONSetupForMono8x8PatternFill; + a->SubsequentMono8x8PatternFillRect + = RADEONSubsequentMono8x8PatternFillRect; + a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST); + + /* Indirect CPU-To-Screen Color Expand */ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's drwarc */ + | ROP_NEEDS_SOURCE + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#else + a->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's drwarc */ + | ROP_NEEDS_SOURCE + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + a->NumScanlineColorExpandBuffers = 1; + a->ScanlineColorExpandBuffers = info->scratch_buffer; + info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) + + (pScrn->virtualX + * info->CurrentLayout.pixel_bytes)); + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineCPUToScreenColorExpandFill + = RADEONSetupForScanlineCPUToScreenColorExpandFill; + a->SubsequentScanlineCPUToScreenColorExpandFill + = RADEONSubsequentScanlineCPUToScreenColorExpandFill; + a->SubsequentColorExpandScanline = RADEONSubsequentColorExpandScanline; + + a->SetupForSolidLine = RADEONSetupForSolidLine; + a->SubsequentSolidTwoPointLine = RADEONSubsequentSolidTwoPointLine; + a->SubsequentSolidHorVertLine = RADEONSubsequentSolidHorVertLine; + + a->SetupForDashedLine = RADEONSetupForDashedLine; + a->SubsequentDashedTwoPointLine = RADEONSubsequentDashedTwoPointLine; + a->DashPatternMaxLength = 32; + a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED + | LINE_PATTERN_POWER_OF_2_ONLY); + +#if RADEON_IMAGEWRITE + /* ImageWrite */ + a->NumScanlineImageWriteBuffers = 1; + a->ScanlineImageWriteBuffers = info->scratch_buffer; + info->scratch_buffer[0] = info->scratch_save; + a->SetupForScanlineImageWrite = RADEONSetupForScanlineImageWrite; + a->SubsequentScanlineImageWriteRect + = RADEONSubsequentScanlineImageWriteRect; + a->SubsequentImageWriteScanline = RADEONSubsequentImageWriteScanline; + a->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD + /* Performance tests show that we shouldn't use GXcopy for + * uploads as a memcpy is faster */ + | NO_GXCOPY + /* RADEON gets upset, when using HOST provided data + * without a source rop. To show run 'xtest's ptimg */ + | ROP_NEEDS_SOURCE + | SCANLINE_PAD_DWORD + | LEFT_EDGE_CLIPPING + | LEFT_EDGE_CLIPPING_NEGATIVE_X; +#endif + +#if 0 + /* Color 8x8 Pattern Fill */ + a->SetupForColor8x8PatternFill + = RADEONSetupForColor8x8PatternFill; + a->SubsequentColor8x8PatternFillRect + = RADEONSubsequentColor8x8PatternFillRect; + a->Color8x8PatternFillFlags = + HARDWARE_PATTERN_PROGRAMMED_ORIGIN + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST; +#endif +} + +/* Initialize XAA for supported acceleration and also initialize the + graphics hardware for acceleration. */ +Bool RADEONAccelInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + XAAInfoRecPtr a; + + if (!(a = info->accel = XAACreateInfoRec())) return FALSE; + +#ifdef XF86DRI + /* FIXME: When direct rendering is enabled, we should use the CP to + draw 2D commands */ + if (info->CP2D) RADEONCPAccelInit(pScrn, a); + else +#endif + RADEONMMIOAccelInit(pScrn, a); + + RADEONEngineInit(pScrn); + return XAAInit(pScreen, a); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c:1.3 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c Sat Nov 18 14:37:12 2000 @@ -0,0 +1,264 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c,v 1.3 2000/11/18 19:37:12 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_reg.h" + + /* X and server generic header files */ +#include "xf86.h" + +#if X_BYTE_ORDER == X_BIG_ENDIAN +#define P_SWAP32( a , b ) \ + ((char *)a)[0] = ((char *)b)[3]; \ + ((char *)a)[1] = ((char *)b)[2]; \ + ((char *)a)[2] = ((char *)b)[1]; \ + ((char *)a)[3] = ((char *)b)[0] + +#define P_SWAP16( a , b ) \ + ((char *)a)[0] = ((char *)b)[1]; \ + ((char *)a)[1] = ((char *)b)[0]; \ + ((char *)a)[2] = ((char *)b)[3]; \ + ((char *)a)[3] = ((char *)b)[2] +#endif + + +/* Set cursor foreground and background colors. */ +static void RADEONSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_CUR_CLR0, bg); + OUTREG(RADEON_CUR_CLR1, fg); +} + +/* Set cursor position to (x,y) with offset into cursor bitmap at + (xorigin,yorigin). */ +static void RADEONSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + xf86CursorInfoPtr cursor = info->cursor; + int xorigin = 0; + int yorigin = 0; + int total_y = pScrn->frameY1 - pScrn->frameY0; + + if (x < 0) xorigin = -x; + if (y < 0) yorigin = -y; + if (y > total_y) y = total_y; + if (info->Flags & V_DBLSCAN) y *= 2; + if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1; + if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1; + + OUTREG(RADEON_CUR_HORZ_VERT_OFF, (RADEON_CUR_LOCK + | (xorigin << 16) + | yorigin)); + OUTREG(RADEON_CUR_HORZ_VERT_POSN, (RADEON_CUR_LOCK + | ((xorigin ? 0 : x) << 16) + | (yorigin ? 0 : y))); + OUTREG(RADEON_CUR_OFFSET, info->cursor_start + yorigin * 16); +} + +/* Copy cursor image from `image' to video memory. RADEONSetCursorPosition + will be called after this, so we can ignore xorigin and yorigin. */ +static void RADEONLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 *s = (CARD32 *)image; + CARD32 *d = (CARD32 *)(info->FB + info->cursor_start); + int y; + CARD32 save; + + save = INREG(RADEON_CRTC_GEN_CNTL); + OUTREG(RADEON_CRTC_GEN_CNTL, save & ~RADEON_CRTC_CUR_EN); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + switch(info->CurrentLayout.pixel_bytes) { + case 4: + case 3: + for (y = 0; y < 64; y++) { + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + P_SWAP32(d,s); + d++; s++; + } + break; + case 2: + for (y = 0; y < 64; y++) { + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + P_SWAP16(d,s); + d++; s++; + } + break; + default: + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + } +#else + for (y = 0; y < 64; y++) { + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } +#endif + + /* Set the area after the cursor to be all transparent so that we + won't display corrupted cursors on the screen */ + for (y = 0; y < 64; y++) { + *d++ = 0xffffffff; /* The AND bits */ + *d++ = 0xffffffff; + *d++ = 0x00000000; /* The XOR bits */ + *d++ = 0x00000000; + } + + OUTREG(RADEON_CRTC_GEN_CNTL, save); +} + +/* Hide hardware cursor. */ +static void RADEONHideCursor(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_GEN_CNTL, 0, ~RADEON_CRTC_CUR_EN); +} + +/* Show hardware cursor. */ +static void RADEONShowCursor(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_CUR_EN, ~RADEON_CRTC_CUR_EN); +} + +/* Determine if hardware cursor is in use. */ +static Bool RADEONUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + return info->cursor_start ? TRUE : FALSE; +} + +/* Initialize hardware cursor support. */ +Bool RADEONCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + xf86CursorInfoPtr cursor; + FBAreaPtr fbarea; + int width; + int height; + int size; + + + if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; + + cursor->MaxWidth = 64; + cursor->MaxHeight = 64; + cursor->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST +#endif + | HARDWARE_CURSOR_INVERT_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK); + + cursor->SetCursorColors = RADEONSetCursorColors; + cursor->SetCursorPosition = RADEONSetCursorPosition; + cursor->LoadCursorImage = RADEONLoadCursorImage; + cursor->HideCursor = RADEONHideCursor; + cursor->ShowCursor = RADEONShowCursor; + cursor->UseHWCursor = RADEONUseHWCursor; + + size = (cursor->MaxWidth/4) * cursor->MaxHeight; + width = pScrn->displayWidth; + height = (size*2 + 1023) / pScrn->displayWidth; + fbarea = xf86AllocateOffscreenArea(pScreen, + width, + height, + 16, + NULL, + NULL, + NULL); + + if (!fbarea) { + info->cursor_start = 0; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Hardware cursor disabled" + " due to insufficient offscreen memory\n"); + } else { + info->cursor_start = RADEON_ALIGN((fbarea->box.x1 + + width * fbarea->box.y1) + * info->CurrentLayout.pixel_bytes, + 16); + info->cursor_end = info->cursor_start + size; + } + + RADEONTRACE(("RADEONCursorInit (0x%08x-0x%08x)\n", + info->cursor_start, info->cursor_end)); + + return xf86InitCursor(pScreen, cursor); +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c:1.5 --- /dev/null Mon Dec 18 14:30:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c Tue Nov 21 18:10:35 2000 @@ -0,0 +1,355 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dga.c,v 1.5 2000/11/21 23:10:35 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Credits: + * + * Thanks to Ove Kåven <ovek@transgaming.com> for writing the Rage 128 + * DGA support. Portions of this file are based on the initialization + * code for that driver. + * + */ + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_probe.h" + + /* X and server generic header files */ +#include "xf86.h" + + /* DGA support */ +#include "dgaproc.h" + + +static Bool RADEON_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool RADEON_SetMode(ScrnInfoPtr, DGAModePtr); +static int RADEON_GetViewport(ScrnInfoPtr); +static void RADEON_SetViewport(ScrnInfoPtr, int, int, int); +static void RADEON_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void RADEON_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +#if 0 +static void RADEON_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); +#endif + +static +DGAFunctionRec RADEON_DGAFuncs = { + RADEON_OpenFramebuffer, + NULL, + RADEON_SetMode, + RADEON_SetViewport, + RADEON_GetViewport, + RADEONWaitForIdle, + RADEON_FillRect, + RADEON_BlitRect, +#if 0 + RADEON_BlitTransRect +#else + NULL +#endif +}; + + +static DGAModePtr RADEONSetupDGAMode(ScrnInfoPtr pScrn, + DGAModePtr modes, + int *num, + int bitsPerPixel, + int depth, + Bool pixmap, + int secondPitch, + unsigned long red, + unsigned long green, + unsigned long blue, + short visualClass) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + DGAModePtr newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int otherPitch, Bpp = bitsPerPixel >> 3; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while (pMode) { + otherPitch = secondPitch ? secondPitch : pMode->HDisplay; + + if (pMode->HDisplay != otherPitch) { + newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if (!newmodes) { + xfree(modes); + return NULL; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + *num; + (*num)++; + + currentMode->mode = pMode; + /* FIXME: is concurrent access really possible? */ + currentMode->flags = DGA_CONCURRENT_ACCESS; + if (pixmap) + currentMode->flags |= DGA_PIXMAP_AVAILABLE; + if (info->accel) + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if (pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if (pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = depth; + currentMode->bitsPerPixel = bitsPerPixel; + currentMode->red_mask = red; + currentMode->green_mask = green; + currentMode->blue_mask = blue; + currentMode->visualClass = visualClass; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 8; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = (unsigned char*)info->LinearAddr; + + if (oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = (((pMode->HDisplay * Bpp) + 3) + & ~3L); + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = (currentMode->imageHeight - + currentMode->viewportHeight); + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; + currentMode->imageWidth = otherPitch; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = (currentMode->imageWidth - + currentMode->viewportWidth); + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = (currentMode->imageHeight - + currentMode->viewportHeight); + } + + pMode = pMode->next; + if (pMode == firstMode) + break; + } + + return modes; +} + +Bool RADEONDGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + DGAModePtr modes = NULL; + int num = 0; + + /* 8 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 8, 8, + (pScrn->bitsPerPixel == 8), + ((pScrn->bitsPerPixel != 8) + ? 0 : pScrn->displayWidth), + 0, 0, 0, PseudoColor); + + /* 15 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 15) + ? 0 : pScrn->displayWidth), + 0x7c00, 0x03e0, 0x001f, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 15, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 15) + ? 0 : pScrn->displayWidth), + 0x7c00, 0x03e0, 0x001f, DirectColor); + + /* 16 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 16) + ? 0 : pScrn->displayWidth), + 0xf800, 0x07e0, 0x001f, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 16, 16, + (pScrn->bitsPerPixel == 16), + ((pScrn->depth != 16) + ? 0 : pScrn->displayWidth), + 0xf800, 0x07e0, 0x001f, DirectColor); + + /* 32 */ + modes = RADEONSetupDGAMode(pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + ((pScrn->bitsPerPixel != 32) + ? 0 : pScrn->displayWidth), + 0xff0000, 0x00ff00, 0x0000ff, TrueColor); + + modes = RADEONSetupDGAMode(pScrn, modes, &num, 32, 24, + (pScrn->bitsPerPixel == 32), + ((pScrn->bitsPerPixel != 32) + ? 0 : pScrn->displayWidth), + 0xff0000, 0x00ff00, 0x0000ff, DirectColor); + + info->numDGAModes = num; + info->DGAModes = modes; + + return DGAInit(pScreen, &RADEON_DGAFuncs, modes, num); +} + +static Bool RADEON_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) +{ + static RADEONFBLayout SavedLayouts[MAXSCREENS]; + int indx = pScrn->pScreen->myNum; + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + if (info->DGAactive) + memcpy(&info->CurrentLayout, &SavedLayouts[indx], + sizeof(RADEONFBLayout)); + + pScrn->currentMode = info->CurrentLayout.mode; + + RADEONSwitchMode(indx, pScrn->currentMode, 0); + RADEONAdjustFrame(indx, 0, 0, 0); + info->DGAactive = FALSE; + } else { + if (!info->DGAactive) { /* save the old parameters */ + memcpy(&SavedLayouts[indx], &info->CurrentLayout, + sizeof(RADEONFBLayout)); + info->DGAactive = TRUE; + } + + info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel; + info->CurrentLayout.depth = pMode->depth; + info->CurrentLayout.displayWidth = (pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3)); + info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16 + ? pMode->bitsPerPixel + : pMode->depth); + /* RADEONModeInit() will set the mode field */ + + RADEONSwitchMode(indx, pMode->mode, 0); + } + + return TRUE; +} + +static int RADEON_GetViewport(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + return info->DGAViewportStatus; +} + +static void RADEON_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + info->DGAViewportStatus = 0; /* FIXME */ +} + +static void RADEON_FillRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->accel) { + (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, (CARD32)(~0)); + (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +static void RADEON_BlitRect(ScrnInfoPtr pScrn, + int srcx, int srcy, int w, int h, + int dstx, int dsty) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->accel) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*info->accel->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, + GXcopy, (CARD32)(~0), -1); + (*info->accel->SubsequentScreenToScreenCopy)(pScrn, srcx, srcy, + dstx, dsty, w, h); + SET_SYNC_FLAG(info->accel); + } +} + +#if 0 +static void RADEON_BlitTransRect(ScrnInfoPtr pScrn, + int srcx, int srcy, int w, int h, + int dstx, int dsty, unsigned long color) +{ + /* this one should be separate since the XAA function would prohibit + usage of ~0 as the key */ +} +#endif + +static Bool RADEON_OpenFramebuffer(ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, int *offset, int *flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)info->LinearAddr; + *size = info->FbMapSize; + *offset = 0; + *flags = 0; /* DGA_NEED_ROOT; -- don't need root, just /dev/mem access */ + + return TRUE; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c:1.8 --- /dev/null Mon Dec 18 14:30:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c Fri Dec 8 09:40:01 2000 @@ -0,0 +1,2982 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v 1.8 2000/12/08 14:40:01 alanh Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * Credits: + * + * Thanks to Ani Joshi <ajoshi@shell.unixbox.com> for providing source + * code to his Radeon driver. Portions of this file are based on the + * initialization code for that driver. + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + * This server does not yet support these XFree86 4.0 features: + * !!!! FIXME !!!! + * DDC1 & DDC2 + * shadowfb + * overlay planes + * + * Modified by Marc Aurele La France (tsi@xfree86.org) for ATI driver merge. + */ + + /* Driver data structures */ +#include "radeon.h" +#include "radeon_probe.h" +#include "radeon_reg.h" +#include "radeon_version.h" + +#ifdef XF86DRI +#define _XF86DRI_SERVER_ +#include "r128_dri.h" +#include "r128_sarea.h" +#endif + +#define USE_FB /* not until overlays */ +#ifdef USE_FB +#include "fb.h" +#else + + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" +#endif + + /* colormap initialization */ +#include "micmap.h" +#include "dixstruct.h" + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86PciInfo.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "vbe.h" + + /* fbdevhw * vgaHW definitions */ +#include "fbdevhw.h" +#include "vgaHW.h" + +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + + /* Forward definitions for driver functions */ +static Bool RADEONCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool RADEONSaveScreen(ScreenPtr pScreen, int mode); +static void RADEONSave(ScrnInfoPtr pScrn); +static void RADEONRestore(ScrnInfoPtr pScrn); +static Bool RADEONModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, + int flags); +static Bool RADEONEnterVTFBDev(int scrnIndex, int flags); +static void RADEONLeaveVTFBDev(int scrnIndex, int flags); + +typedef enum { + OPTION_NOACCEL, + OPTION_SW_CURSOR, + OPTION_DAC_6BIT, + OPTION_DAC_8BIT, +#ifdef XF86DRI + OPTION_IS_PCI, + OPTION_CP_PIO, + OPTION_NO_SECURITY, + OPTION_USEC_TIMEOUT, + OPTION_AGP_MODE, + OPTION_AGP_SIZE, + OPTION_RING_SIZE, + OPTION_VERT_SIZE, + OPTION_VBUF_SIZE, + OPTION_USE_CP_2D, +#endif +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + OPTION_CRT, +#endif + OPTION_PANEL_WIDTH, + OPTION_PANEL_HEIGHT, +#endif + OPTION_FBDEV +} RADEONOpts; + +OptionInfoRec RADEONOptions[] = { + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +#ifdef XF86DRI + { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CP_PIO, "CPPIOMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NO_SECURITY, "CPNoSecurity", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEC_TIMEOUT, "CPusecTimeout", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_USE_CP_2D, "UseCPfor2D", OPTV_BOOLEAN, {0}, FALSE }, +#endif +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ +#if 0 + /* FIXME: Disable CRTOnly until it is tested */ + { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, + { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, +#endif + { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +RADEONRAMRec RADEONRAM[] = { /* Memory Specifications + From Radeon Manual */ + { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SDRAM" }, + { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SDRAM" }, +}; + +static const char *vgahwSymbols[] = { + "vgaHWGetHWRec", + "vgaHWFreeHWRec", + "vgaHWLock", + "vgaHWUnlock", + "vgaHWSave", + "vgaHWRestore", + NULL +}; + +static const char *fbdevHWSymbols[] = { + "fbdevHWInit", + "fbdevHWUseBuildinMode", + + "fbdevHWGetDepth", + "fbdevHWGetVidmem", + + /* colormap */ + "fbdevHWLoadPalette", + + /* ScrnInfo hooks */ + "fbdevHWSwitchMode", + "fbdevHWAdjustFrame", + "fbdevHWEnterVT", + "fbdevHWLeaveVT", + "fbdevHWValidMode", + "fbdevHWRestore", + "fbdevHWModeInit", + "fbdevHWSave", + + "fbdevHWUnmapMMIO", + "fbdevHWUnmapVidmem", + "fbdevHWMapMMIO", + "fbdevHWMapVidmem", + + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +#ifdef XFree86LOADER +#ifdef USE_FB +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; +#else +static const char *cfbSymbols[] = { + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb32ScreenInit", + "cfb24_32ScreenInit", + NULL +}; +#endif + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAStippleScanlineFuncLSBFirst", + "XAAOverlayFBfuncs", + "XAACachePlanarMonoStipple", + "XAAScreenIndex", + NULL +}; + +static const char *xf8_32bppSymbols[] = { + "xf86Overlay8Plus32Init", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmGetInterruptFromBusID", + "drmMapBufs", + "drmMarkBufs", + "drmUnmapBufs", + "drmFreeVersion", + "drmGetVersion", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "DRIQueryVersion", + "GlxSetVisualConfigs", + NULL +}; +#endif + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + NULL +}; +#endif + +/* Allocate our private RADEONInfoRec. */ +static Bool RADEONGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(RADEONInfoRec), 1); + return TRUE; +} + +/* Free our private RADEONInfoRec. */ +static void RADEONFreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn || !pScrn->driverPrivate) return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* Memory map the MMIO region. Used during pre-init and by RADEONMapMem, + below. */ +static Bool RADEONMapMMIO(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) { + info->MMIO = fbdevHWMapMMIO(pScrn); + } else { + info->MMIO = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, + info->PciTag, + info->MMIOAddr, + RADEON_MMIOSIZE); + } + + if (!info->MMIO) return FALSE; + return TRUE; +} + +/* Unmap the MMIO region. Used during pre-init and by RADEONUnmapMem, + below. */ +static Bool RADEONUnmapMMIO(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapMMIO(pScrn); + else { + xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, RADEON_MMIOSIZE); + } + info->MMIO = NULL; + return TRUE; +} + +/* Memory map the frame buffer. Used by RADEONMapMem, below. */ +static Bool RADEONMapFB(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) { + info->FB = fbdevHWMapVidmem(pScrn); + } else { + info->FB = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_FRAMEBUFFER, + info->PciTag, + info->LinearAddr, + info->FbMapSize); + } + + if (!info->FB) return FALSE; + return TRUE; +} + +/* Unmap the frame buffer. Used by RADEONUnmapMem, below. */ +static Bool RADEONUnmapFB(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->FBDev) + fbdevHWUnmapVidmem(pScrn); + else + xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); + info->FB = NULL; + return TRUE; +} + +/* Memory map the MMIO region and the frame buffer. */ +static Bool RADEONMapMem(ScrnInfoPtr pScrn) +{ + if (!RADEONMapMMIO(pScrn)) return FALSE; + if (!RADEONMapFB(pScrn)) { + RADEONUnmapMMIO(pScrn); + return FALSE; + } + return TRUE; +} + +/* Unmap the MMIO region and the frame buffer. */ +static Bool RADEONUnmapMem(ScrnInfoPtr pScrn) +{ + if (!RADEONUnmapMMIO(pScrn) || !RADEONUnmapFB(pScrn)) return FALSE; + return TRUE; +} + +/* Read PLL information */ +unsigned RADEONINPLL(ScrnInfoPtr pScrn, int addr) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + +#if !RADEON_ATOMIC_UPDATE + while ( (INREG8(RADEON_CLOCK_CNTL_INDEX) & 0x9f) != addr) { +#endif + OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x1f); +#if !RADEON_ATOMIC_UPDATE + } +#endif + return INREG(RADEON_CLOCK_CNTL_DATA); +} + +#if 0 +/* Read PAL information (only used for debugging). */ +static int RADEONINPAL(int idx) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_PALETTE_INDEX, idx << 16); + return INREG(RADEON_PALETTE_DATA); +} +#endif + +/* Wait for vertical sync. */ +void RADEONWaitForVerticalSync(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + OUTREG(RADEON_GEN_INT_STATUS, RADEON_VSYNC_INT_AK); + for (i = 0; i < RADEON_TIMEOUT; i++) { + if (INREG(RADEON_GEN_INT_STATUS) & RADEON_VSYNC_INT) break; + } +} + +/* Blank screen. */ +static void RADEONBlank(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS, + ~(RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS)); +} + +/* Unblank screen. */ +static void RADEONUnblank(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREGP(RADEON_CRTC_EXT_CNTL, 0, + ~(RADEON_CRTC_DISPLAY_DIS | + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS)); +} + +/* Compute log base 2 of val. */ +int RADEONMinBits(int val) +{ + int bits; + + if (!val) return 1; + for (bits = 0; val; val >>= 1, ++bits); + return bits; +} + +/* Compute n/d with rounding. */ +static int RADEONDiv(int n, int d) +{ + return (n + (d / 2)) / d; +} + +/* Read the Video BIOS block and the FP registers (if applicable). */ +static Bool RADEONGetBIOSParameters(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); +#ifdef ENABLE_FLAT_PANEL + int i; + int FPHeader = 0; +#endif + +#define RADEONReadBIOS(offset, buffer, length) \ + (info->BIOSFromPCI ? \ + xf86ReadPciBIOS(offset, info->PciTag, 0, buffer, length) : \ + xf86ReadBIOS(info->BIOSAddr, offset, buffer, length)) + +#define RADEON_BIOS8(v) (info->VBIOS[v]) +#define RADEON_BIOS16(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8)) +#define RADEON_BIOS32(v) (info->VBIOS[v] | \ + (info->VBIOS[(v) + 1] << 8) | \ + (info->VBIOS[(v) + 2] << 16) | \ + (info->VBIOS[(v) + 3] << 24)) + + if (!(info->VBIOS = xalloc(RADEON_VBIOS_SIZE))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate space for hold Video BIOS!\n"); + return FALSE; + } + + info->BIOSFromPCI = TRUE; + RADEONReadBIOS(0x0000, info->VBIOS, RADEON_VBIOS_SIZE); + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected in PCI space!\n"); + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Attempting to read Video BIOS from legacy ISA space!\n"); + info->BIOSFromPCI = FALSE; + info->BIOSAddr = 0x000c0000; + RADEONReadBIOS(0x0000, info->VBIOS, RADEON_VBIOS_SIZE); + } + if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) { + info->BIOSAddr = 0x00000000; + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not found!\n"); + } + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) { + info->FPBIOSstart = 0; + + /* FIXME: There should be direct access to the start of the FP info + tables, but until we find out where that offset is stored, we + must search for the ATI signature string: "M3 ". */ + for (i = 4; i < RADEON_VBIOS_SIZE-8; i++) { + if (RADEON_BIOS8(i) == 'M' && + RADEON_BIOS8(i+1) == '3' && + RADEON_BIOS8(i+2) == ' ' && + RADEON_BIOS8(i+3) == ' ' && + RADEON_BIOS8(i+4) == ' ' && + RADEON_BIOS8(i+5) == ' ' && + RADEON_BIOS8(i+6) == ' ' && + RADEON_BIOS8(i+7) == ' ') { + FPHeader = i-2; + break; + } + } + + if (!FPHeader) return TRUE; + + /* Assume that only one panel is attached and supported */ + for (i = FPHeader+20; i < FPHeader+84; i += 2) { + if (RADEON_BIOS16(i) != 0) { + info->FPBIOSstart = RADEON_BIOS16(i); + break; + } + } + if (!info->FPBIOSstart) return TRUE; + + if (!info->PanelXRes) + info->PanelXRes = RADEON_BIOS16(info->FPBIOSstart+25); + if (!info->PanelYRes) + info->PanelYRes = RADEON_BIOS16(info->FPBIOSstart+27); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel size: %dx%d\n", + info->PanelXRes, info->PanelYRes); + + info->PanelPwrDly = RADEON_BIOS8(info->FPBIOSstart+56); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel ID: "); + for (i = 1; i <= 24; i++) + ErrorF("%c", RADEON_BIOS8(info->FPBIOSstart+i)); + ErrorF("\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Type: "); + i = RADEON_BIOS16(info->FPBIOSstart+29); + if (i & 1) ErrorF("Color, "); + else ErrorF("Monochrome, "); + if (i & 2) ErrorF("Dual(split), "); + else ErrorF("Single, "); + switch ((i >> 2) & 0x3f) { + case 0: ErrorF("STN"); break; + case 1: ErrorF("TFT"); break; + case 2: ErrorF("Active STN"); break; + case 3: ErrorF("EL"); break; + case 4: ErrorF("Plasma"); break; + default: ErrorF("UNKNOWN"); break; + } + ErrorF("\n"); + if (RADEON_BIOS8(info->FPBIOSstart+61) & 1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel Interface: LVDS\n"); + } else { + /* FIXME: Add Non-LVDS flat pael support */ + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Non-LVDS panel interface detected! " + "This support is untested and may not " + "function properly\n"); + } + } +#endif + + return TRUE; +} + +/* Read PLL parameters from BIOS block. Default to typical values if there + is no BIOS. */ +static Bool RADEONGetPLLParameters(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPLLPtr pll = &info->pll; + CARD16 bios_header; + CARD16 pll_info_block; + + if (!info->VBIOS) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Video BIOS not detected, using default PLL parameters!\n"); + /* These probably aren't going to work for + the card you are using. Specifically, + reference freq can be 29.50MHz, + 28.63MHz, or 14.32MHz. YMMV. */ + pll->reference_freq = 2950; + pll->reference_div = 65; + pll->min_pll_freq = 12500; + pll->max_pll_freq = 35000; + pll->xclk = 10300; + } else { + bios_header = RADEON_BIOS16(0x48); + pll_info_block = RADEON_BIOS16(bios_header + 0x30); + RADEONTRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", + bios_header, pll_info_block)); + + pll->reference_freq = RADEON_BIOS16(pll_info_block + 0x0e); + pll->reference_div = RADEON_BIOS16(pll_info_block + 0x10); + pll->min_pll_freq = RADEON_BIOS32(pll_info_block + 0x12); + pll->max_pll_freq = RADEON_BIOS32(pll_info_block + 0x16); + pll->xclk = RADEON_BIOS16(pll_info_block + 0x08); + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PLL parameters: rf=%d rd=%d min=%d max=%d; xclk=%d\n", + pll->reference_freq, + pll->reference_div, + pll->min_pll_freq, + pll->max_pll_freq, + pll->xclk); + + return TRUE; +} + +/* This is called by RADEONPreInit to set up the default visual. */ +static Bool RADEONPreInitVisual(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support32bppFb)) + return FALSE; + + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by %s driver\n", + pScrn->depth, RADEON_DRIVER_NAME); + return FALSE; + } + + xf86PrintDepthBpp(pScrn); + + info->fifo_slots = 0; + info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); + info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; + info->CurrentLayout.depth = pScrn->depth; + info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 + ? pScrn->bitsPerPixel + : pScrn->depth); + + if (info->pix24bpp == 24) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Radeon does NOT support 24bpp\n"); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", + pScrn->depth, + info->CurrentLayout.pixel_bytes, + info->CurrentLayout.pixel_bytes > 1 ? "s" : "", + info->pix24bpp); + + + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; + + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Default visual (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + return TRUE; + +} + +/* This is called by RADEONPreInit to handle all color weight issues. */ +static Bool RADEONPreInitWeight(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + /* Save flag for 6 bit DAC to use for + setting CRTC registers. Otherwise use + an 8 bit DAC, even if xf86SetWeight sets + pScrn->rgbBits to some value other than + 8. */ + info->dac6bits = FALSE; + if (pScrn->depth > 8) { + rgb defaultWeight = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + } else { + pScrn->rgbBits = 8; + if (xf86ReturnOptValBool(RADEONOptions, OPTION_DAC_6BIT, FALSE)) { + pScrn->rgbBits = 6; + info->dac6bits = TRUE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d bits per RGB (%d bit DAC)\n", + pScrn->rgbBits, info->dac6bits ? 6 : 8); + + return TRUE; + +} + +/* This is called by RADEONPreInit to handle config file overrides for things + like chipset and memory regions. Also determine memory size and type. + If memory type ever needs an override, put it in this routine. */ +static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + EntityInfoPtr pEnt = info->pEnt; + GDevPtr dev = pEnt->device; + int offset = 0; /* RAM Type */ + MessageType from; + unsigned char *RADEONMMIO; + + /* Chipset */ + from = X_PROBED; + if (dev->chipset && *dev->chipset) { + info->Chipset = xf86StringToToken(RADEONChipsets, dev->chipset); + from = X_CONFIG; + } else if (dev->chipID >= 0) { + info->Chipset = dev->chipID; + from = X_CONFIG; + } else { + info->Chipset = info->PciInfo->chipType; + } + pScrn->chipset = (char *)xf86TokenToString(RADEONChipsets, info->Chipset); + + if (!pScrn->chipset) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04x is not recognized\n", info->Chipset); + return FALSE; + } + + if (info->Chipset < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognized\n", pScrn->chipset); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, + "Chipset: \"%s\" (ChipID = 0x%04x)\n", + pScrn->chipset, + info->Chipset); + + /* Framebuffer */ + + from = X_PROBED; + info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; + if (dev->MemBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Linear address override, using 0x%08x instead of 0x%08x\n", + dev->MemBase, + info->LinearAddr); + info->LinearAddr = dev->MemBase; + from = X_CONFIG; + } else if (!info->LinearAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "No valid linear framebuffer address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "Linear framebuffer at 0x%08lx\n", info->LinearAddr); + + /* MMIO registers */ + from = X_PROBED; + info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; + if (dev->IOBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "MMIO address override, using 0x%08x instead of 0x%08x\n", + dev->IOBase, + info->MMIOAddr); + info->MMIOAddr = dev->IOBase; + from = X_CONFIG; + } else if (!info->MMIOAddr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid MMIO address\n"); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, + "MMIO registers at 0x%08lx\n", info->MMIOAddr); + + /* BIOS */ + from = X_PROBED; + info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; + if (dev->BiosBase) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BIOS address override, using 0x%08x instead of 0x%08x\n", + dev->BiosBase, + info->BIOSAddr); + info->BIOSAddr = dev->BiosBase; + from = X_CONFIG; + } + if (info->BIOSAddr) { + xf86DrvMsg(pScrn->scrnIndex, from, + "BIOS at 0x%08lx\n", info->BIOSAddr); + } + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Flat panel (part 1) */ + /* FIXME: Make this an option */ + switch (info->Chipset) { +#if 0 + case PCI_CHIP_RADEON_XX: info->HasPanelRegs = TRUE; break; +#endif + case PCI_CHIP_RADEON_QD: + case PCI_CHIP_RADEON_QE: + case PCI_CHIP_RADEON_QF: + case PCI_CHIP_RADEON_QG: + default: info->HasPanelRegs = FALSE; break; + } +#endif + + /* Read registers used to determine options */ + from = X_PROBED; + RADEONMapMMIO(pScrn); + RADEONMMIO = info->MMIO; + if (info->FBDev) + pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; + else + pScrn->videoRam = INREG(RADEON_CONFIG_MEMSIZE) / 1024; + info->MemCntl = INREG(RADEON_SDRAM_MODE_REG); + info->BusCntl = INREG(RADEON_BUS_CNTL); + RADEONMMIO = NULL; + RADEONUnmapMMIO(pScrn); + + /* RAM */ + switch (info->MemCntl >> 30) { + case 0: offset = 0; break; /* 64-bit SDR SDRAM */ + case 1: offset = 1; break; /* 64-bit DDR SDRAM */ + default: offset = 0; + } + info->ram = &RADEONRAM[offset]; + + if (dev->videoRam) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Video RAM override, using %d kB instead of %d kB\n", + dev->videoRam, + pScrn->videoRam); + from = X_CONFIG; + pScrn->videoRam = dev->videoRam; + } + pScrn->videoRam &= ~1023; + info->FbMapSize = pScrn->videoRam * 1024; + xf86DrvMsg(pScrn->scrnIndex, from, + "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Flat panel (part 2) */ + if (info->HasPanelRegs) { +#if 1 + info->CRTOnly = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); +#else + /* Panel CRT mode override */ + if ((info->CRTOnly = xf86ReturnOptValBool(RADEONOptions, + OPTION_CRT, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using external CRT instead of " + "flat panel for display\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); + } +#endif + + /* Panel width/height overrides */ + info->PanelXRes = 0; + info->PanelYRes = 0; + if (xf86GetOptValInteger(RADEONOptions, + OPTION_PANEL_WIDTH, &(info->PanelXRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel width: %d\n", info->PanelXRes); + } + if (xf86GetOptValInteger(RADEONOptions, + OPTION_PANEL_HEIGHT, &(info->PanelYRes))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Flat panel height: %d\n", info->PanelYRes); + } + } else { + info->CRTOnly = FALSE; + } +#endif + +#ifdef XF86DRI + /* AGP/PCI */ + if (xf86ReturnOptValBool(RADEONOptions, OPTION_IS_PCI, FALSE)) { + info->IsPCI = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); + } else { + switch (info->Chipset) { +#if 0 + case PCI_CHIP_RADEON_XX: info->IsPCI = TRUE; break; +#endif + case PCI_CHIP_RADEON_QD: + case PCI_CHIP_RADEON_QE: + case PCI_CHIP_RADEON_QF: + case PCI_CHIP_RADEON_QG: + default: info->IsPCI = FALSE; break; + } + } +#endif + + return TRUE; +} + +static Bool RADEONPreInitDDC(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + vbeInfoPtr pVbe; + + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; + xf86LoaderReqSymLists(ddcSymbols, NULL); + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; +} + +/* This is called by RADEONPreInit to initialize gamma correction. */ +static Bool RADEONPreInitGamma(ScrnInfoPtr pScrn) +{ + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) return FALSE; + return TRUE; +} + +/* This is called by RADEONPreInit to validate modes and compute parameters + for all of the valid modes. */ +static Bool RADEONPreInitModes(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + ClockRangePtr clockRanges; + int modesFound; + char *mod = NULL; + const char *Sym = NULL; + + /* Get mode information */ + pScrn->progClock = TRUE; + clockRanges = xnfcalloc(sizeof(*clockRanges), 1); + clockRanges->next = NULL; + clockRanges->minClock = info->pll.min_pll_freq; + clockRanges->maxClock = info->pll.max_pll_freq * 10; + clockRanges->clockIndex = -1; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) { + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + } else { + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + } +#else + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; +#endif + + modesFound = xf86ValidateModes(pScrn, + pScrn->monitor->Modes, + pScrn->display->modes, + clockRanges, + NULL, /* linePitches */ + 8 * 64, /* minPitch */ + 8 * 1024, /* maxPitch */ + 64 * pScrn->bitsPerPixel, /* pitchInc */ + 128, /* minHeight */ + 2048, /* maxHeight */ + pScrn->virtualX, + pScrn->virtualY, + info->FbMapSize, + LOOKUP_BEST_REFRESH); + + if (modesFound < 1 && info->FBDev) { + fbdevHWUseBuildinMode(pScrn); + pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ + modesFound = 1; + } + + if (modesFound == -1) return FALSE; + xf86PruneDriverModes(pScrn); + if (!modesFound || !pScrn->modes) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + return FALSE; + } + xf86SetCrtcForModes(pScrn, 0); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + + /* Set DPI */ + xf86SetDpi(pScrn, 0, 0); + + /* Get ScreenInit function */ +#ifdef USE_FB + mod = "fb"; + Sym = "fbScreenInit"; +#else + switch (pScrn->bitsPerPixel) { + case 8: mod = "cfb"; Sym = "cfbScreenInit"; break; + case 16: mod = "cfb16"; Sym = "cfb16ScreenInit"; break; + case 32: mod = "cfb32"; Sym = "cfb32ScreenInit"; break; + } +#endif + if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; + xf86LoaderReqSymbols(Sym, NULL); + +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif + + info->CurrentLayout.displayWidth = pScrn->displayWidth; + info->CurrentLayout.mode = pScrn->currentMode; + + return TRUE; +} + +/* This is called by RADEONPreInit to initialize the hardware cursor. */ +static Bool RADEONPreInitCursor(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_SW_CURSOR, FALSE)) { + if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; + } + return TRUE; +} + +/* This is called by RADEONPreInit to initialize hardware acceleration. */ +static Bool RADEONPreInitAccel(ScrnInfoPtr pScrn) +{ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE)) { + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; + } + return TRUE; +} + +static Bool RADEONPreInitInt10(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); +#if 1 + if (xf86LoadSubModule(pScrn, "int10")) { + xf86Int10InfoPtr pInt; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); + pInt = xf86InitInt10(info->pEnt->index); + xf86FreeInt10(pInt); + } +#endif + return TRUE; +} + +#ifdef XF86DRI +static Bool RADEONPreInitDRI(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->IsPCI) { + info->CPMode = RADEON_DEFAULT_CP_PIO_MODE; + } else if (xf86ReturnOptValBool(RADEONOptions, OPTION_CP_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CP into PIO mode\n"); + info->CPMode = RADEON_DEFAULT_CP_PIO_MODE; + } else { + info->CPMode = RADEON_DEFAULT_CP_BM_MODE; + } + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_USE_CP_2D, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CP for 2D\n"); + info->CP2D = TRUE; + } else { + info->CP2D = FALSE; + } + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CP Security checks disabled!!! **********\n"); + info->CPSecure = FALSE; + } else { + info->CPSecure = TRUE; + } + + info->agpMode = RADEON_DEFAULT_AGP_MODE; + info->agpSize = RADEON_DEFAULT_AGP_SIZE; + info->ringSize = RADEON_DEFAULT_RING_SIZE; + info->vbSize = RADEON_DEFAULT_VB_SIZE; + info->indSize = RADEON_DEFAULT_IND_SIZE; + info->agpTexSize = RADEON_DEFAULT_AGP_TEX_SIZE; + + info->vbBufSize = RADEON_DEFAULT_VB_BUF_SIZE; + + info->CPusecTimeout = RADEON_DEFAULT_CP_TIMEOUT; + + if (!info->IsPCI) { + if (xf86GetOptValInteger(RADEONOptions, + OPTION_AGP_MODE, &(info->agpMode))) { + if (info->agpMode < 1 || info->agpMode > RADEON_AGP_MAX_MODE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP Mode: %d\n", info->agpMode); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using AGP %dx mode\n", info->agpMode); + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_AGP_SIZE, (int *)&(info->agpSize))) { + switch (info->agpSize) { + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP size: %d MB\n", info->agpSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_RING_SIZE, &(info->ringSize))) { + if (info->ringSize < 1 || info->ringSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal ring buffer size: %d MB\n", + info->ringSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_VERT_SIZE, &(info->vbSize))) { + if (info->vbSize < 1 || info->vbSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex buffers list size: %d MB\n", + info->vbSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(RADEONOptions, + OPTION_VBUF_SIZE, &(info->vbBufSize))) { + int numBufs = info->vbSize*1024*1024/info->vbBufSize; + if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal individual vertex buffer size: %d bytes\n", + info->vbBufSize); + return FALSE; + } + } + + if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize > + info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Buffers are too big for requested AGP space\n"); + return FALSE; + } + + info->agpTexSize = info->agpSize - (info->ringSize + + info->vbSize + + info->indSize); + } + + if (xf86GetOptValInteger(RADEONOptions, OPTION_USEC_TIMEOUT, + &(info->CPusecTimeout))) { + /* This option checked by the RADEON DRM kernel module */ + } + + return TRUE; +} +#endif + +static void +RADEONProbeDDC(ScrnInfoPtr pScrn, int indx) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,indx); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + +/* RADEONPreInit is called once at server startup. */ +Bool RADEONPreInit(ScrnInfoPtr pScrn, int flags) +{ + RADEONInfoPtr info; + +#ifdef XFree86LOADER + /* + * Tell the loader about symbols from other modules that this module might + * refer to. + */ + LoaderRefSymLists(vgahwSymbols, +#ifdef USE_FB + fbSymbols, +#else + cfbSymbols, +#endif + xaaSymbols, + xf8_32bppSymbols, + ramdacSymbols, +#ifdef XF86DRI + drmSymbols, + driSymbols, +#endif + fbdevHWSymbols, + vbeSymbols, + /* ddcsymbols, */ + /* i2csymbols, */ + /* shadowSymbols, */ + NULL); +#endif + + RADEONTRACE(("RADEONPreInit\n")); + if (pScrn->numEntities != 1) return FALSE; + + if (!RADEONGetRec(pScrn)) return FALSE; + + info = RADEONPTR(pScrn); + + info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (info->pEnt->location.type != BUS_PCI) goto fail; + + if (flags & PROBE_DETECT) { + RADEONProbeDDC(pScrn, info->pEnt->index); + return TRUE; + } + + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + xf86LoaderReqSymLists(vgahwSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) { + RADEONFreeRec(pScrn); + return FALSE; + } + + info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); + info->PciTag = pciTag(info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "PCI bus %d card %d func %d\n", + info->PciInfo->bus, + info->PciInfo->device, + info->PciInfo->func); + + if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; + + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; + pScrn->monitor = pScrn->confScreen->monitor; + + if (!RADEONPreInitVisual(pScrn)) goto fail; + + /* We can't do this until we have a + pScrn->display. */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, RADEONOptions); + + if (!RADEONPreInitWeight(pScrn)) goto fail; + + if (xf86ReturnOptValBool(RADEONOptions, OPTION_FBDEV, FALSE)) { + info->FBDev = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using framebuffer device\n"); + } + + if (info->FBDev) { + /* check for linux framebuffer device */ + if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; + xf86LoaderReqSymLists(fbdevHWSymbols, NULL); + if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; + pScrn->SwitchMode = fbdevHWSwitchMode; + pScrn->AdjustFrame = fbdevHWAdjustFrame; + pScrn->EnterVT = RADEONEnterVTFBDev; + pScrn->LeaveVT = RADEONLeaveVTFBDev; + pScrn->ValidMode = fbdevHWValidMode; + } + + if (!info->FBDev) + if (!RADEONPreInitInt10(pScrn)) goto fail; + + if (!RADEONPreInitConfig(pScrn)) goto fail; + + if (!RADEONGetBIOSParameters(pScrn)) goto fail; + + if (!RADEONGetPLLParameters(pScrn)) goto fail; + + if (!RADEONPreInitDDC(pScrn)) goto fail; + + if (!RADEONPreInitGamma(pScrn)) goto fail; + + if (!RADEONPreInitModes(pScrn)) goto fail; + + if (!RADEONPreInitCursor(pScrn)) goto fail; + + if (!RADEONPreInitAccel(pScrn)) goto fail; + +#ifdef XF86DRI + if (!RADEONPreInitDRI(pScrn)) goto fail; +#endif + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + return TRUE; + + fail: + /* Pre-init failed. */ + + /* Free the video bios (if applicable) */ + if (info->VBIOS) { + xfree(info->VBIOS); + info->VBIOS = NULL; + } + + vgaHWFreeHWRec(pScrn); + RADEONFreeRec(pScrn); + return FALSE; +} + +/* Load a palette. */ +static void RADEONLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + int idx; + unsigned char r, g, b; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + if (info->CurrentLayout.depth == 15) { + /* 15bpp mode. This sends 32 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + g = colors[idx].green; + b = colors[idx].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 8, r, g, b); + } + } + else if (info->CurrentLayout.depth == 16) { + /* 16bpp mode. This sends 64 values. */ + /* There are twice as many green values as + there are values for red and blue. So, + we take each red and blue pair, and + combine it with each of the two green + values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx / 2].red; + g = colors[idx].green; + b = colors[idx / 2].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 4, r, g, b); + + /* AH - Added to write extra green data - How come this isn't + * needed on R128 ? We didn't load the extra green data in the + * other routine */ + if (idx <= 31) { + r = colors[idx].red; + g = colors[(idx * 2) + 1].green; + b = colors[idx].blue; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx * 8, r, g, b); + } + } + } + else { + /* 8bpp mode. This sends 256 values. */ + for (i = 0; i < numColors; i++) { + idx = indices[i]; + r = colors[idx].red; + b = colors[idx].blue; + g = colors[idx].green; + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL(idx, r, g, b); + } + } +} + +static void +RADEONBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + pScreen->BlockHandler = info->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = RADEONBlockHandler; + + if(info->VideoTimerCallback) { + (*info->VideoTimerCallback)(pScrn, currentTime.milliseconds); + } +} + +/* Called at the start of each server generation. */ +Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + BoxRec MemBox; + int y2; + + RADEONTRACE(("RADEONScreenInit %x %d\n", + pScrn->memPhysBase, pScrn->fbOffset)); + +#ifdef XF86DRI + /* Turn off the CP for now. */ + info->CPInUse = FALSE; +#endif + + if (!RADEONMapMem(pScrn)) return FALSE; + pScrn->fbOffset = 0; +#ifdef XF86DRI + info->fbX = 0; + info->fbY = 0; +#endif + + info->PaletteSavedOnVT = FALSE; + + RADEONSave(pScrn); + if (info->FBDev) { + if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; + } else { + if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE; + } + + RADEONSaveScreen(pScreen, SCREEN_SAVER_ON); + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* Visual setup */ + miClearVisualTypes(); + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, + pScrn->defaultVisual)) return FALSE; + miSetPixmapDepths (); + +#ifdef XF86DRI + /* Setup DRI after visuals have been + established, but before cfbScreenInit is + called. cfbScreenInit will eventually + call the driver's InitGLXVisuals call + back. */ + { + /* FIXME: When we move to dynamic allocation of back and depth + buffers, we will want to revisit the following check for 3 + times the virtual size of the screen below. */ + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE) && + (maxy > pScrn->virtualY * 3) +#ifdef ENABLE_FLAT_PANEL + /* FIXME: Disable 3D support for FPs until it is tested */ + && !info->HasPanelRegs +#endif + ) { + info->directRenderingEnabled = RADEONDRIScreenInit(pScreen); + } else { + xf86DrvMsg(scrnIndex, X_WARNING, + "Static buffer allocation failed -- " + "need at least %d kB video memory\n", + (pScrn->displayWidth * pScrn->virtualY * + info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024); + info->directRenderingEnabled = FALSE; + } + } +#endif + +#ifdef USE_FB + if (!fbScreenInit (pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel)) + return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif +#else + switch (pScrn->bitsPerPixel) { + case 8: + if (!cfbScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 16: + if (!cfb16ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + case 32: + if (!cfb32ScreenInit(pScreen, info->FB, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return FALSE; + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Invalid bpp (%d)\n", pScrn->bitsPerPixel); + return FALSE; + } +#endif + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr visual; + + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + RADEONDGAInit(pScreen); + + /* Memory manager setup */ + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + y2 = (info->FbMapSize + / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes)); + if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */ + MemBox.y2 = y2; + + /* The acceleration engine uses 14 bit + signed coordinates, so we can't have any + drawable caches beyond this region. */ + if (MemBox.y2 > 8191) MemBox.y2 = 8191; + + if (!xf86InitFBManager(pScreen, &MemBox)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + return FALSE; + } else { + int width, height; + FBAreaPtr fbarea; + + xf86DrvMsg(scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); + if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + 2, 0, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved area from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); + } + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } + +#ifdef XF86DRI + /* Allocate frame buffer space for the + shared back and depth buffers as well + as for local textures. */ + if (info->directRenderingEnabled) { + FBAreaPtr fbarea; + int width_bytes = (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + int maxy = info->FbMapSize / width_bytes; + int l; + + switch (info->CPMode) { + case RADEON_DEFAULT_CP_PIO_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in PIO mode\n"); + break; + case RADEON_DEFAULT_CP_BM_MODE: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in BM mode\n"); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CP in UNKNOWN mode\n"); + break; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB AGP aperture\n", info->agpSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for the ring buffer\n", info->ringSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for vertex buffers\n", info->vbSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for indirect buffers\n", info->indSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d MB for AGP textures\n", info->agpTexSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d byte vertex buffers\n", info->vbBufSize); + + /* Allocate the shared back buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved back buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->backX = fbarea->box.x1; + info->backY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); + info->backX = -1; + info->backY = -1; + } + + /* Allocate the shared depth buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->depthX = fbarea->box.x1; + info->depthY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); + info->depthX = -1; + info->depthY = -1; + } + + /* Allocate local texture space */ + if (((maxy - MemBox.y2 - 1) * width_bytes) > + (pScrn->virtualX * pScrn->virtualY * 2 * + info->CurrentLayout.pixel_bytes)) { + info->textureX = 0; + info->textureY = MemBox.y2 + 1; + info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes; + + l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); + if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + info->textureX, info->textureY, + pScrn->displayWidth, maxy); + } else if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY * 2, + 32, + NULL, NULL, NULL))) { + info->textureX = fbarea->box.x1; + info->textureY = fbarea->box.y1; + info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) * + (fbarea->box.x2 - fbarea->box.x1) * + info->CurrentLayout.pixel_bytes); + + l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); + if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve texture space in frame buffer\n"); + info->textureX = -1; + info->textureY = -1; + } + } +#endif + + /* Backing store setup */ + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + /* Set Silken Mouse */ + xf86SetSilkenMouse(pScreen); + + /* Acceleration setup */ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_NOACCEL, FALSE)) { + if (RADEONAccelInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); + info->accelOn = TRUE; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Acceleration initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); + info->accelOn = FALSE; + } + + /* Cursor setup */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Hardware cursor setup */ + if (!xf86ReturnOptValBool(RADEONOptions, OPTION_SW_CURSOR, FALSE)) { + if (RADEONCursorInit(pScreen)) { + int width, height; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using hardware cursor (scanline %d)\n", + info->cursor_start / pScrn->displayWidth); + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, + 0, 0, 0)) { + xf86DrvMsg(scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + } + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + } else { + xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); + } + + /* Colormap setup */ + if (!miCreateDefColormap(pScreen)) return FALSE; + if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8, + (info->FBDev ? fbdevHWLoadPalette : + RADEONLoadPalette), NULL, + CMAP_PALETTED_TRUECOLOR + | CMAP_RELOAD_ON_MODE_SWITCH +#if 0 /* This option messes up text mode! (eich@suse.de) */ + | CMAP_LOAD_EVEN_IF_OFFSCREEN +#endif + )) return FALSE; + + /* DPMS setup */ +#ifdef DPMSExtension +#ifdef ENABLE_FLAT_PANEL + if (!info->HasPanelRegs || info->CRTOnly) + xf86DPMSInit(pScreen, RADEONDisplayPowerManagementSet, 0); +#else + xf86DPMSInit(pScreen, RADEONDisplayPowerManagementSet, 0); +#endif +#endif + + RADEONInitVideo(pScreen); + + /* Provide SaveScreen */ + pScreen->SaveScreen = RADEONSaveScreen; + + /* Wrap CloseScreen */ + info->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = RADEONCloseScreen; + + /* Note unused options */ + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + +#ifdef XF86DRI + /* DRI finalization */ + if (info->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have + done their thing, complete the DRI + setup. */ + info->directRenderingEnabled = RADEONDRIFinishScreenInit(pScreen); + } + if (info->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } +#endif + + info->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = RADEONBlockHandler; + + return TRUE; +} + +/* Write common registers (initialized to 0). */ +static void RADEONRestoreCommonRegisters(ScrnInfoPtr pScrn, + RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_OVR_CLR, restore->ovr_clr); + OUTREG(RADEON_OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right); + OUTREG(RADEON_OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom); + OUTREG(RADEON_OV0_SCALE_CNTL, restore->ov0_scale_cntl); + OUTREG(RADEON_MPP_TB_CONFIG, restore->mpp_tb_config ); + OUTREG(RADEON_MPP_GP_CONFIG, restore->mpp_gp_config ); + OUTREG(RADEON_SUBPIC_CNTL, restore->subpic_cntl); + OUTREG(RADEON_VIPH_CONTROL, restore->viph_control); + OUTREG(RADEON_I2C_CNTL_1, restore->i2c_cntl_1); + OUTREG(RADEON_GEN_INT_CNTL, restore->gen_int_cntl); + OUTREG(RADEON_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); + OUTREG(RADEON_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); + OUTREG(RADEON_BUS_CNTL, restore->bus_cntl); +} + +/* Write CRTC registers. */ +static void RADEONRestoreCrtcRegisters(ScrnInfoPtr pScrn, + RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_CRTC_GEN_CNTL, restore->crtc_gen_cntl); + + OUTREGP(RADEON_CRTC_EXT_CNTL, restore->crtc_ext_cntl, + RADEON_CRTC_VSYNC_DIS | + RADEON_CRTC_HSYNC_DIS | + RADEON_CRTC_DISPLAY_DIS); + + OUTREGP(RADEON_DAC_CNTL, restore->dac_cntl, + RADEON_DAC_RANGE_CNTL | + RADEON_DAC_BLANKING); + + OUTREG(RADEON_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); + OUTREG(RADEON_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); + OUTREG(RADEON_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); + OUTREG(RADEON_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); + OUTREG(RADEON_CRTC_OFFSET, restore->crtc_offset); + OUTREG(RADEON_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); + OUTREG(RADEON_CRTC_PITCH, restore->crtc_pitch); +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Write flat panel registers */ +static void RADEONRestoreFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + CARD32 tmp; + + OUTREG(RADEON_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); + OUTREG(RADEON_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); + OUTREG(RADEON_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); + OUTREG(RADEON_FP_GEN_CNTL, restore->fp_gen_cntl); + OUTREG(RADEON_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); + OUTREG(RADEON_FP_HORZ_STRETCH, restore->fp_horz_stretch); + OUTREG(RADEON_FP_PANEL_CNTL, restore->fp_panel_cntl); + OUTREG(RADEON_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); + OUTREG(RADEON_FP_VERT_STRETCH, restore->fp_vert_stretch); + OUTREG(RADEON_TMDS_CRC, restore->tmds_crc); + + tmp = INREG(RADEON_LVDS_GEN_CNTL); + if ((tmp & (RADEON_LVDS_ON | RADEON_LVDS_BLON)) == + (restore->lvds_gen_cntl & (RADEON_LVDS_ON | RADEON_LVDS_BLON))) { + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + if (restore->lvds_gen_cntl & (RADEON_LVDS_ON | RADEON_LVDS_BLON)) { + OUTREG(RADEON_LVDS_GEN_CNTL, + restore->lvds_gen_cntl & ~RADEON_LVDS_BLON); + usleep(RADEONPTR(pScrn)->PanelPwrDly * 1000); + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } else { + OUTREG(RADEON_LVDS_GEN_CNTL, + restore->lvds_gen_cntl | RADEON_LVDS_BLON); + usleep(RADEONPTR(pScrn)->PanelPwrDly * 1000); + OUTREG(RADEON_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + } + } +} +#endif + +#if RADEON_ATOMIC_UPDATE +static void RADEONPLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) +{ + while (INPLL(pScrn, RADEON_PPLL_REF_DIV) & RADEON_PPLL_ATOMIC_UPDATE_R); +} + +static void RADEONPLLWriteUpdate(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTPLLP(pScrn, RADEON_PPLL_REF_DIV, RADEON_PPLL_ATOMIC_UPDATE_W, 0xffff); +} +#endif + +/* Write PLL registers. */ +static void RADEONRestorePLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + +#if !RADEON_ATOMIC_UPDATE + while ( (INREG(RADEON_CLOCK_CNTL_INDEX) & RADEON_PLL_DIV_SEL) != + RADEON_PLL_DIV_SEL) { +#endif + OUTREGP(RADEON_CLOCK_CNTL_INDEX, RADEON_PLL_DIV_SEL, 0xffff); +#if !RADEON_ATOMIC_UPDATE + } +#endif + +#if RADEON_ATOMIC_UPDATE + OUTPLLP(pScrn, + RADEON_PPLL_CNTL, + RADEON_PPLL_RESET + | RADEON_PPLL_ATOMIC_UPDATE_EN + | RADEON_PPLL_VGA_ATOMIC_UPDATE_EN, + 0xffff); +#else + OUTPLLP(pScrn, + RADEON_PPLL_CNTL, + RADEON_PPLL_RESET, + 0xffff); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_REF_DIV) & RADEON_PPLL_REF_DIV_MASK) != + (restore->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_REF_DIV, + restore->ppll_ref_div, ~RADEON_PPLL_REF_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_DIV_3) & RADEON_PPLL_FB3_DIV_MASK) != + (restore->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_DIV_3, + restore->ppll_div_3, ~RADEON_PPLL_FB3_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + while ( (INPLL(pScrn, RADEON_PPLL_DIV_3) & RADEON_PPLL_POST3_DIV_MASK) != + (restore->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK)) { + OUTPLLP(pScrn, RADEON_PPLL_DIV_3, + restore->ppll_div_3, ~RADEON_PPLL_POST3_DIV_MASK); + } +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + +#if RADEON_ATOMIC_UPDATE + RADEONPLLWaitForReadUpdateComplete(pScrn); +#endif + OUTPLL(RADEON_HTOTAL_CNTL, restore->htotal_cntl); +#if RADEON_ATOMIC_UPDATE + RADEONPLLWriteUpdate(pScrn); +#endif + + OUTPLLP(pScrn, RADEON_PPLL_CNTL, 0, ~RADEON_PPLL_RESET); + + RADEONTRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", + restore->ppll_ref_div, + restore->ppll_div_3, + restore->htotal_cntl, + INPLL(pScrn, RADEON_PPLL_CNTL))); + RADEONTRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", + restore->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK, + restore->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK, + (restore->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Write DDA registers. */ +static void RADEONRestoreDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + OUTREG(RADEON_DDA_CONFIG, restore->dda_config); + OUTREG(RADEON_DDA_ON_OFF, restore->dda_on_off); +} + +/* Write palette data. */ +static void RADEONRestorePalette(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + + if (!restore->palette_valid) return; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + OUTPAL_START(0); + for (i = 0; i < 256; i++) { + RADEONWaitForFifo(pScrn, 32); /* delay */ + OUTPAL_NEXT_CARD32(restore->palette[i]); + } +} + +/* Write out state to define a new video mode. */ +static void RADEONRestoreMode(ScrnInfoPtr pScrn, RADEONSavePtr restore) +{ +#ifdef ENABLE_FLAT_PANEL + RADEONInfoPtr info = RADEONPTR(pScrn); +#endif + + RADEONTRACE(("RADEONRestoreMode(%p)\n", restore)); + RADEONRestoreCommonRegisters(pScrn, restore); + RADEONRestoreCrtcRegisters(pScrn, restore); +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + RADEONRestoreFPRegisters(pScrn, restore); + if (!info->HasPanelRegs || info->CRTOnly) + RADEONRestorePLLRegisters(pScrn, restore); +#else + RADEONRestorePLLRegisters(pScrn, restore); +#endif + RADEONRestoreDDARegisters(pScrn, restore); + RADEONRestorePalette(pScrn, restore); +} + +/* Read common registers. */ +static void RADEONSaveCommonRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->ovr_clr = INREG(RADEON_OVR_CLR); + save->ovr_wid_left_right = INREG(RADEON_OVR_WID_LEFT_RIGHT); + save->ovr_wid_top_bottom = INREG(RADEON_OVR_WID_TOP_BOTTOM); + save->ov0_scale_cntl = INREG(RADEON_OV0_SCALE_CNTL); + save->mpp_tb_config = INREG(RADEON_MPP_TB_CONFIG); + save->mpp_gp_config = INREG(RADEON_MPP_GP_CONFIG); + save->subpic_cntl = INREG(RADEON_SUBPIC_CNTL); + save->viph_control = INREG(RADEON_VIPH_CONTROL); + save->i2c_cntl_1 = INREG(RADEON_I2C_CNTL_1); + save->gen_int_cntl = INREG(RADEON_GEN_INT_CNTL); + save->cap0_trig_cntl = INREG(RADEON_CAP0_TRIG_CNTL); + save->cap1_trig_cntl = INREG(RADEON_CAP1_TRIG_CNTL); + save->bus_cntl = INREG(RADEON_BUS_CNTL); +} + +/* Read CRTC registers. */ +static void RADEONSaveCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->crtc_gen_cntl = INREG(RADEON_CRTC_GEN_CNTL); + save->crtc_ext_cntl = INREG(RADEON_CRTC_EXT_CNTL); + save->dac_cntl = INREG(RADEON_DAC_CNTL); + save->crtc_h_total_disp = INREG(RADEON_CRTC_H_TOTAL_DISP); + save->crtc_h_sync_strt_wid = INREG(RADEON_CRTC_H_SYNC_STRT_WID); + save->crtc_v_total_disp = INREG(RADEON_CRTC_V_TOTAL_DISP); + save->crtc_v_sync_strt_wid = INREG(RADEON_CRTC_V_SYNC_STRT_WID); + save->crtc_offset = INREG(RADEON_CRTC_OFFSET); + save->crtc_offset_cntl = INREG(RADEON_CRTC_OFFSET_CNTL); + save->crtc_pitch = INREG(RADEON_CRTC_PITCH); +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Read flat panel registers */ +static void RADEONSaveFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->crtc2_gen_cntl = INREG(RADEON_CRTC2_GEN_CNTL); + save->fp_crtc_h_total_disp = INREG(RADEON_FP_CRTC_H_TOTAL_DISP); + save->fp_crtc_v_total_disp = INREG(RADEON_FP_CRTC_V_TOTAL_DISP); + save->fp_gen_cntl = INREG(RADEON_FP_GEN_CNTL); + save->fp_h_sync_strt_wid = INREG(RADEON_FP_H_SYNC_STRT_WID); + save->fp_horz_stretch = INREG(RADEON_FP_HORZ_STRETCH); + save->fp_panel_cntl = INREG(RADEON_FP_PANEL_CNTL); + save->fp_v_sync_strt_wid = INREG(RADEON_FP_V_SYNC_STRT_WID); + save->fp_vert_stretch = INREG(RADEON_FP_VERT_STRETCH); + save->lvds_gen_cntl = INREG(RADEON_LVDS_GEN_CNTL); + save->tmds_crc = INREG(RADEON_TMDS_CRC); +} +#endif + +/* Read PLL registers. */ +static void RADEONSavePLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + save->ppll_ref_div = INPLL(pScrn, RADEON_PPLL_REF_DIV); + save->ppll_div_3 = INPLL(pScrn, RADEON_PPLL_DIV_3); + save->htotal_cntl = INPLL(pScrn, RADEON_HTOTAL_CNTL); + + RADEONTRACE(("Read: 0x%08x 0x%08x 0x%08x\n", + save->ppll_ref_div, + save->ppll_div_3, + save->htotal_cntl)); + RADEONTRACE(("Read: rd=%d, fd=%d, pd=%d\n", + save->ppll_ref_div & RADEON_PPLL_REF_DIV_MASK, + save->ppll_div_3 & RADEON_PPLL_FB3_DIV_MASK, + (save->ppll_div_3 & RADEON_PPLL_POST3_DIV_MASK) >> 16)); +} + +/* Read DDA registers. */ +static void RADEONSaveDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + + save->dda_config = INREG(RADEON_DDA_CONFIG); + save->dda_on_off = INREG(RADEON_DDA_ON_OFF); +} + +/* Read palette data. */ +static void RADEONSavePalette(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int i; + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + /* Select palette 0 (main CRTC) if using FP-enabled chip */ + if (info->HasPanelRegs) PAL_SELECT(0); +#endif + + INPAL_START(0); + for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT(); + save->palette_valid = TRUE; +} + +/* Save state that defines current video mode. */ +static void RADEONSaveMode(ScrnInfoPtr pScrn, RADEONSavePtr save) +{ + RADEONTRACE(("RADEONSaveMode(%p)\n", save)); + + RADEONSaveCommonRegisters(pScrn, save); + RADEONSaveCrtcRegisters(pScrn, save); +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (RADEONPTR(pScrn)->HasPanelRegs) + RADEONSaveFPRegisters(pScrn, save); +#endif + RADEONSavePLLRegisters(pScrn, save); + RADEONSaveDDARegisters(pScrn, save); + RADEONSavePalette(pScrn, save); + + RADEONTRACE(("RADEONSaveMode returns %p\n", save)); +} + +/* Save everything needed to restore the original VC state. */ +static void RADEONSave(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONSavePtr save = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + RADEONTRACE(("RADEONSave\n")); + if (info->FBDev) { + fbdevHWSave(pScrn); + return; + } + vgaHWUnlock(hwp); + vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ + vgaHWLock(hwp); + + RADEONSaveMode(pScrn, save); + + save->dp_datatype = INREG(RADEON_DP_DATATYPE); + save->rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); + save->clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); + save->amcgpio_en_reg = INREG(RADEON_AMCGPIO_EN_REG); + save->amcgpio_mask = INREG(RADEON_AMCGPIO_MASK); +} + +/* Restore the original (text) mode. */ +static void RADEONRestore(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONSavePtr restore = &info->SavedReg; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + RADEONTRACE(("RADEONRestore\n")); + if (info->FBDev) { + fbdevHWRestore(pScrn); + return; + } + + RADEONBlank(pScrn); + + OUTREG(RADEON_AMCGPIO_MASK, restore->amcgpio_mask); + OUTREG(RADEON_AMCGPIO_EN_REG, restore->amcgpio_en_reg); + OUTREG(RADEON_CLOCK_CNTL_INDEX, restore->clock_cntl_index); + OUTREG(RADEON_RBBM_SOFT_RESET, restore->rbbm_soft_reset); + OUTREG(RADEON_DP_DATATYPE, restore->dp_datatype); + + RADEONRestoreMode(pScrn, restore); + vgaHWUnlock(hwp); + vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); + vgaHWLock(hwp); + +#if 0 + RADEONWaitForVerticalSync(pScrn); +#endif + RADEONUnblank(pScrn); +} + +/* Define common registers for requested video mode. */ +static void RADEONInitCommonRegisters(RADEONSavePtr save, RADEONInfoPtr info) +{ + save->ovr_clr = 0; + save->ovr_wid_left_right = 0; + save->ovr_wid_top_bottom = 0; + save->ov0_scale_cntl = 0; + save->mpp_tb_config = 0; + save->mpp_gp_config = 0; + save->subpic_cntl = 0; + save->viph_control = 0; + save->i2c_cntl_1 = 0; + save->rbbm_soft_reset = 0; + save->cap0_trig_cntl = 0; + save->cap1_trig_cntl = 0; + save->bus_cntl = info->BusCntl; + /* + * If bursts are enabled, turn on discards + * Radeon doesn't have write bursts + */ + if (save->bus_cntl & (RADEON_BUS_READ_BURST)) + save->bus_cntl |= RADEON_BUS_RD_DISCARD_EN; +} + +/* Define CRTC registers for requested video mode. */ +static Bool RADEONInitCrtcRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, + DisplayModePtr mode, RADEONInfoPtr info) +{ + int format; + int hsync_start; + int hsync_wid; + int hsync_fudge; + int vsync_wid; + int bytpp; + int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + int hsync_fudge_fp[] = { 0x12, 0x11, 0x09, 0x09, 0x05, 0x05 }; + int hsync_fudge_fp_crt[] = { 0x12, 0x10, 0x08, 0x08, 0x04, 0x04 }; +#endif + + switch (info->CurrentLayout.pixel_code) { + case 4: format = 1; bytpp = 0; break; + case 8: format = 2; bytpp = 1; break; + case 15: format = 3; bytpp = 2; break; /* 555 */ + case 16: format = 4; bytpp = 2; break; /* 565 */ + case 24: format = 5; bytpp = 3; break; /* RGB */ + case 32: format = 6; bytpp = 4; break; /* xRGB */ + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); + return FALSE; + } + RADEONTRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp)); + +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + if (info->CRTOnly) hsync_fudge = hsync_fudge_fp_crt[format-1]; + else hsync_fudge = hsync_fudge_fp[format-1]; + else hsync_fudge = hsync_fudge_default[format-1]; +#else + hsync_fudge = hsync_fudge_default[format-1]; +#endif + + save->crtc_gen_cntl = (RADEON_CRTC_EXT_DISP_EN + | RADEON_CRTC_EN + | (format << 8) + | ((mode->Flags & V_DBLSCAN) + ? RADEON_CRTC_DBL_SCAN_EN + : 0) + | ((mode->Flags & V_INTERLACE) + ? RADEON_CRTC_INTERLACE_EN + : 0)); + + save->crtc_ext_cntl = RADEON_VGA_ATI_LINEAR | RADEON_XCRT_CNT_EN; + save->dac_cntl = (RADEON_DAC_MASK_ALL + | RADEON_DAC_VGA_ADR_EN + | (info->dac6bits ? 0 : RADEON_DAC_8BIT_EN)); + + save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) + | (((mode->CrtcHDisplay / 8) - 1) << 16)); + + hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; + if (!hsync_wid) hsync_wid = 1; + if (hsync_wid > 0x3f) hsync_wid = 0x3f; + + hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; + + save->crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) + | (hsync_wid << 16) + | ((mode->Flags & V_NHSYNC) + ? RADEON_CRTC_H_SYNC_POL + : 0)); + +#if 1 + /* This works for double scan mode. */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay - 1) << 16)); +#else + /* This is what cce/nbmode.c example code + does -- is this correct? */ + save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) + | ((mode->CrtcVDisplay + * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) + << 16)); +#endif + + vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; + if (!vsync_wid) vsync_wid = 1; + if (vsync_wid > 0x1f) vsync_wid = 0x1f; + + save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) + | (vsync_wid << 16) + | ((mode->Flags & V_NVSYNC) + ? RADEON_CRTC_V_SYNC_POL + : 0)); + save->crtc_offset = 0; + save->crtc_offset_cntl = 0; + + save->crtc_pitch = ((pScrn->displayWidth * pScrn->bitsPerPixel) + + ((pScrn->bitsPerPixel * 8) -1)) / + (pScrn->bitsPerPixel * 8); + save->crtc_pitch |= save->crtc_pitch << 16; + + RADEONTRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", + save->crtc_pitch, pScrn->virtualX, + info->CurrentLayout.displayWidth)); + return TRUE; +} + +#ifdef ENABLE_FLAT_PANEL +/* Note: Radeon flat panel support has been disabled for now */ +/* Define CRTC registers for requested video mode. */ +static void RADEONInitFPRegisters(ScrnInfoPtr pScrn, RADEONSavePtr orig, + RADEONSavePtr save, DisplayModePtr mode, + RADEONInfoPtr info) +{ + int xres = mode->CrtcHDisplay; + int yres = mode->CrtcVDisplay; + float Hratio, Vratio; + + if (info->CRTOnly) { + save->crtc_ext_cntl |= RADEON_CRTC_CRT_ON; + save->crtc2_gen_cntl = 0; + save->fp_gen_cntl = orig->fp_gen_cntl; + save->fp_gen_cntl &= ~(RADEON_FP_FPON | + RADEON_FP_CRTC_USE_SHADOW_VEND | + RADEON_FP_CRTC_HORZ_DIV2_EN | + RADEON_FP_CRTC_HOR_CRT_DIV2_DIS | + RADEON_FP_USE_SHADOW_EN); + save->fp_gen_cntl |= (RADEON_FP_SEL_CRTC2 | + RADEON_FP_CRTC_DONT_SHADOW_VPAR); + save->fp_panel_cntl = orig->fp_panel_cntl & ~RADEON_FP_DIGON; + save->lvds_gen_cntl = orig->lvds_gen_cntl & ~(RADEON_LVDS_ON | + RADEON_LVDS_BLON); + return; + } + + if (xres > info->PanelXRes) xres = info->PanelXRes; + if (yres > info->PanelYRes) yres = info->PanelYRes; + + Hratio = (float)xres/(float)info->PanelXRes; + Vratio = (float)yres/(float)info->PanelYRes; + + save->fp_horz_stretch = + (((((int)(Hratio * RADEON_HORZ_STRETCH_RATIO_MAX + 0.5)) + & RADEON_HORZ_STRETCH_RATIO_MASK) + << RADEON_HORZ_STRETCH_RATIO_SHIFT) | + (orig->fp_horz_stretch & (RADEON_HORZ_PANEL_SIZE | + RADEON_HORZ_FP_LOOP_STRETCH | + RADEON_HORZ_STRETCH_RESERVED))); + save->fp_horz_stretch &= ~RADEON_HORZ_AUTO_RATIO_FIX_EN; + if (Hratio == 1.0) save->fp_horz_stretch &= ~(RADEON_HORZ_STRETCH_BLEND | + RADEON_HORZ_STRETCH_ENABLE); + else save->fp_horz_stretch |= (RADEON_HORZ_STRETCH_BLEND | + RADEON_HORZ_STRETCH_ENABLE); + + save->fp_vert_stretch = + (((((int)(Vratio * RADEON_VERT_STRETCH_RATIO_MAX + 0.5)) + & RADEON_VERT_STRETCH_RATIO_MASK) + << RADEON_VERT_STRETCH_RATIO_SHIFT) | + (orig->fp_vert_stretch & (RADEON_VERT_PANEL_SIZE | + RADEON_VERT_STRETCH_RESERVED))); + save->fp_vert_stretch &= ~RADEON_VERT_AUTO_RATIO_EN; + if (Vratio == 1.0) save->fp_vert_stretch &= ~(RADEON_VERT_STRETCH_ENABLE | + RADEON_VERT_STRETCH_BLEND); + else save->fp_vert_stretch |= (RADEON_VERT_STRETCH_ENABLE | + RADEON_VERT_STRETCH_BLEND); + + save->fp_gen_cntl = (orig->fp_gen_cntl & ~(RADEON_FP_SEL_CRTC2 | + RADEON_FP_CRTC_USE_SHADOW_VEND | + RADEON_FP_CRTC_HORZ_DIV2_EN | + RADEON_FP_CRTC_HOR_CRT_DIV2_DIS | + RADEON_FP_USE_SHADOW_EN)); + if (orig->fp_gen_cntl & RADEON_FP_DETECT_SENSE) { + save->fp_gen_cntl |= (RADEON_FP_CRTC_DONT_SHADOW_VPAR | + RADEON_FP_TDMS_EN); + } + + save->fp_panel_cntl = orig->fp_panel_cntl; + save->lvds_gen_cntl = orig->lvds_gen_cntl; + + save->tmds_crc = orig->tmds_crc; + + /* Disable CRT output by disabling CRT output and setting the CRT + DAC to use CRTC2, which we set to 0's. In the future, we will + want to use the dual CRTC capabilities of the RADEON to allow both + the flat panel and external CRT to either simultaneously display + the same image or display two different images. */ + save->crtc_ext_cntl &= ~RADEON_CRTC_CRT_ON; + save->dac_cntl |= RADEON_DAC_CRT_SEL_CRTC2; + save->crtc2_gen_cntl = 0; + + /* WARNING: Be careful about turning on the flat panel */ +#if 1 + save->lvds_gen_cntl |= (RADEON_LVDS_ON | RADEON_LVDS_BLON); +#else + save->fp_panel_cntl |= (RADEON_FP_DIGON | RADEON_FP_BLON); + save->fp_gen_cntl |= (RADEON_FP_FPON); +#endif + + save->fp_crtc_h_total_disp = save->crtc_h_total_disp; + save->fp_crtc_v_total_disp = save->crtc_v_total_disp; + save->fp_h_sync_strt_wid = save->crtc_h_sync_strt_wid; + save->fp_v_sync_strt_wid = save->crtc_v_sync_strt_wid; +} +#endif + +/* Define PLL registers for requested video mode. */ +static void RADEONInitPLLRegisters(RADEONSavePtr save, RADEONPLLPtr pll, + double dot_clock) +{ + unsigned long freq = dot_clock * 100; + struct { + int divider; + int bitvalue; + } *post_div, + post_divs[] = { + /* From RAGE 128 VR/RAGE 128 GL Register + Reference Manual (Technical Reference + Manual P/N RRG-G04100-C Rev. 0.04), page + 3-17 (PLL_DIV_[3:0]). */ + { 1, 0 }, /* VCLK_SRC */ + { 2, 1 }, /* VCLK_SRC/2 */ + { 4, 2 }, /* VCLK_SRC/4 */ + { 8, 3 }, /* VCLK_SRC/8 */ + { 3, 4 }, /* VCLK_SRC/3 */ + { 16, 5 }, /* VCLK_SRC/16 */ + { 6, 6 }, /* VCLK_SRC/6 */ + { 12, 7 }, /* VCLK_SRC/12 */ + { 0, 0 } + }; + + if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; + if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; + + for (post_div = &post_divs[0]; post_div->divider; ++post_div) { + save->pll_output_freq = post_div->divider * freq; + if (save->pll_output_freq >= pll->min_pll_freq + && save->pll_output_freq <= pll->max_pll_freq) break; + } + + save->dot_clock_freq = freq; + save->feedback_div = RADEONDiv(pll->reference_div + * save->pll_output_freq, + pll->reference_freq); + save->post_div = post_div->divider; + + RADEONTRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", + save->dot_clock_freq, + save->pll_output_freq, + save->feedback_div, + save->post_div)); + + save->ppll_ref_div = pll->reference_div; + save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); + save->htotal_cntl = 0; +} + +/* Define DDA registers for requested video mode. */ +static Bool RADEONInitDDARegisters(ScrnInfoPtr pScrn, RADEONSavePtr save, + RADEONPLLPtr pll, RADEONInfoPtr info) +{ + int DisplayFifoWidth = 128; + int DisplayFifoDepth = 32; + int XclkFreq; + int VclkFreq; + int XclksPerTransfer; + int XclksPerTransferPrecise; + int UseablePrecision; + int Roff; + int Ron; + + XclkFreq = pll->xclk; + + VclkFreq = RADEONDiv(pll->reference_freq * save->feedback_div, + pll->reference_div * save->post_div); + + XclksPerTransfer = RADEONDiv(XclkFreq * DisplayFifoWidth, + VclkFreq * + (info->CurrentLayout.pixel_bytes * 8)); + + UseablePrecision = RADEONMinBits(XclksPerTransfer) + 1; + + XclksPerTransferPrecise = RADEONDiv((XclkFreq * DisplayFifoWidth) + << (11 - UseablePrecision), + VclkFreq * + (info->CurrentLayout.pixel_bytes * 8)); + + Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); + + Ron = (4 * info->ram->MB + + 3 * MAX(info->ram->Trcd - 2, 0) + + 2 * info->ram->Trp + + info->ram->Twr + + info->ram->CL + + info->ram->Tr2w + + XclksPerTransfer) << (11 - UseablePrecision); + + if (Ron + info->ram->Rloop >= Roff) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", + Ron, info->ram->Rloop, Roff); + return FALSE; + } + + save->dda_config = (XclksPerTransferPrecise + | (UseablePrecision << 16) + | (info->ram->Rloop << 20)); + + save->dda_on_off = (Ron << 16) | Roff; + + RADEONTRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", + XclkFreq, + VclkFreq, + XclksPerTransfer, + XclksPerTransferPrecise, + UseablePrecision)); + RADEONTRACE(("Roff = %d, Ron = %d, Rloop = %d\n", + Roff, Ron, info->ram->Rloop)); + + return TRUE; +} + + +/* Define initial palette for requested video mode. This doesn't do + anything for XFree86 4.0. */ +static void RADEONInitPalette(RADEONSavePtr save) +{ + save->palette_valid = FALSE; +} + +/* Define registers for a requested video mode. */ +static Bool RADEONInit(ScrnInfoPtr pScrn, DisplayModePtr mode, + RADEONSavePtr save) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + double dot_clock = mode->Clock/1000.0; + +#if RADEON_DEBUG + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->HDisplay, + mode->HSyncStart, + mode->HSyncEnd, + mode->HTotal, + + mode->VDisplay, + mode->VSyncStart, + mode->VSyncEnd, + mode->VTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); + ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", + mode->name, + dot_clock, + + mode->CrtcHDisplay, + mode->CrtcHSyncStart, + mode->CrtcHSyncEnd, + mode->CrtcHTotal, + + mode->CrtcVDisplay, + mode->CrtcVSyncStart, + mode->CrtcVSyncEnd, + mode->CrtcVTotal, + pScrn->depth, + pScrn->bitsPerPixel); + if (mode->Flags & V_DBLSCAN) ErrorF(" D"); + if (mode->Flags & V_INTERLACE) ErrorF(" I"); + if (mode->Flags & V_PHSYNC) ErrorF(" +H"); + if (mode->Flags & V_NHSYNC) ErrorF(" -H"); + if (mode->Flags & V_PVSYNC) ErrorF(" +V"); + if (mode->Flags & V_NVSYNC) ErrorF(" -V"); + ErrorF("\n"); +#endif + + info->Flags = mode->Flags; + + RADEONInitCommonRegisters(save, info); + if (!RADEONInitCrtcRegisters(pScrn, save, mode, info)) return FALSE; +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + if (info->HasPanelRegs) + RADEONInitFPRegisters(pScrn, &info->SavedReg, save, mode, info); +#endif + RADEONInitPLLRegisters(save, &info->pll, dot_clock); + if (!RADEONInitDDARegisters(pScrn, save, &info->pll, info)) + return FALSE; + if (!info->PaletteSavedOnVT) RADEONInitPalette(save); + + RADEONTRACE(("RADEONInit returns %p\n", save)); + return TRUE; +} + +/* Initialize a new mode. */ +static Bool RADEONModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (!RADEONInit(pScrn, mode, &info->ModeReg)) return FALSE; + /* FIXME? DRILock/DRIUnlock here? */ + pScrn->vtSema = TRUE; + RADEONBlank(pScrn); + RADEONRestoreMode(pScrn, &info->ModeReg); + RADEONUnblank(pScrn); + + info->CurrentLayout.mode = mode; + + return TRUE; +} + +static Bool RADEONSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool unblank; + + unblank = xf86IsUnblank(mode); + if (unblank) + SetTimeSinceLastInputEvent(); + + if ((pScrn != NULL) && pScrn->vtSema) { + if (unblank) + RADEONUnblank(pScrn); + else + RADEONBlank(pScrn); + } + return TRUE; +} + +Bool RADEONSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return RADEONModeInit(xf86Screens[scrnIndex], mode); +} + +/* Used to disallow modes that are not supported by the hardware. */ +int RADEONValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flag) +{ +#ifdef ENABLE_FLAT_PANEL + /* Note: Radeon flat panel support has been disabled for now */ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (info->HasPanelRegs) { + if (mode->Flags & V_INTERLACE) return MODE_NO_INTERLACE; + if (mode->Flags & V_DBLSCAN) return MODE_NO_DBLESCAN; + } + + if (info->HasPanelRegs && !info->CRTOnly && info->VBIOS) { + int i; + for (i = info->FPBIOSstart+64; RADEON_BIOS16(i) != 0; i += 2) { + int j = RADEON_BIOS16(i); + + if (mode->CrtcHDisplay == RADEON_BIOS16(j) && + mode->CrtcVDisplay == RADEON_BIOS16(j+2)) { + /* Assume we are using expanded mode */ + if (RADEON_BIOS16(j+5)) j = RADEON_BIOS16(j+5); + else j += 9; + + mode->Clock = (CARD32)RADEON_BIOS16(j) * 10; + + mode->HDisplay = mode->CrtcHDisplay = + ((RADEON_BIOS16(j+10) & 0x01ff)+1)*8; + mode->HSyncStart = mode->CrtcHSyncStart = + ((RADEON_BIOS16(j+12) & 0x01ff)+1)*8; + mode->HSyncEnd = mode->CrtcHSyncEnd = + mode->CrtcHSyncStart + (RADEON_BIOS8(j+14) & 0x1f); + mode->HTotal = mode->CrtcHTotal = + ((RADEON_BIOS16(j+8) & 0x01ff)+1)*8; + + mode->VDisplay = mode->CrtcVDisplay = + (RADEON_BIOS16(j+17) & 0x07ff)+1; + mode->VSyncStart = mode->CrtcVSyncStart = + (RADEON_BIOS16(j+19) & 0x07ff)+1; + mode->VSyncEnd = mode->CrtcVSyncEnd = + mode->CrtcVSyncStart + ((RADEON_BIOS16(j+19) >> 11)&0x1f); + mode->VTotal = mode->CrtcVTotal = + (RADEON_BIOS16(j+15) & 0x07ff)+1; + + return MODE_OK; + } + } + return MODE_NOMODE; + } +#endif + + return MODE_OK; +} + +/* Adjust viewport into virtual desktop such that (0,0) in viewport space + is (x,y) in virtual space. */ +void RADEONAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int Base; + + Base = y * info->CurrentLayout.displayWidth + x; + + switch (info->CurrentLayout.pixel_code) { + case 15: + case 16: Base *= 2; break; + case 24: Base *= 3; break; + case 32: Base *= 4; break; + } + + Base &= ~7; /* 3 lower bits are always 0 */ + + OUTREG(RADEON_CRTC_OFFSET, Base); +} + +/* Called when VT switching back to the X server. Reinitialize the video + mode. */ +Bool RADEONEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONTRACE(("RADEONEnterVT\n")); +#ifdef XF86DRI + if (RADEONPTR(pScrn)->directRenderingEnabled) { + RADEONCPStart(pScrn); + DRIUnlock(pScrn->pScreen); + } +#endif + if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE; + if (info->accelOn) + RADEONEngineInit(pScrn); + + info->PaletteSavedOnVT = FALSE; + RADEONAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +/* Called when VT switching away from the X server. Restore the original + text mode. */ +void RADEONLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr save = &info->ModeReg; + + RADEONTRACE(("RADEONLeaveVT\n")); +#ifdef XF86DRI + if (RADEONPTR(pScrn)->directRenderingEnabled) { + DRILock(pScrn->pScreen, 0); + RADEONCPStop(pScrn); + } +#endif + RADEONSavePalette(pScrn, save); + info->PaletteSavedOnVT = TRUE; + RADEONRestore(pScrn); +} + +static Bool +RADEONEnterVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr restore = &info->SavedReg; + fbdevHWEnterVT(scrnIndex,flags); + RADEONRestorePalette(pScrn,restore); + RADEONEngineInit(pScrn); + return TRUE; +} + +static void RADEONLeaveVTFBDev(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONSavePtr save = &info->SavedReg; + RADEONSavePalette(pScrn,save); + fbdevHWLeaveVT(scrnIndex,flags); +} + +/* Called at the end of each server generation. Restore the original text + mode, unmap video memory, and unwrap and call the saved CloseScreen + function. */ +static Bool RADEONCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + RADEONInfoPtr info = RADEONPTR(pScrn); + + RADEONTRACE(("RADEONCloseScreen\n")); + +#ifdef XF86DRI + /* Disable direct rendering */ + if (info->directRenderingEnabled) { + RADEONDRICloseScreen(pScreen); + info->directRenderingEnabled = FALSE; + } +#endif + + if (pScrn->vtSema) { + RADEONRestore(pScrn); + RADEONUnmapMem(pScrn); + } + + if (info->accel) XAADestroyInfoRec(info->accel); + info->accel = NULL; + + if (info->scratch_save) xfree(info->scratch_save); + info->scratch_save = NULL; + + if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); + info->cursor = NULL; + + if (info->DGAModes) xfree(info->DGAModes); + info->DGAModes = NULL; + + pScrn->vtSema = FALSE; + + pScreen->BlockHandler = info->BlockHandler; + pScreen->CloseScreen = info->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + +void RADEONFreeScreen(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + RADEONTRACE(("RADEONFreeScreen\n")); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(pScrn); + RADEONFreeRec(pScrn); +} + +#ifdef DPMSExtension +/* Sets VESA Display Power Management Signaling (DPMS) Mode. */ +static void RADEONDisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int mask = (RADEON_CRTC_DISPLAY_DIS + | RADEON_CRTC_HSYNC_DIS + | RADEON_CRTC_VSYNC_DIS); + + switch (PowerManagementMode) { + case DPMSModeOn: + /* Screen: On; HSync: On, VSync: On */ + OUTREGP(RADEON_CRTC_EXT_CNTL, 0, ~mask); + break; + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On */ + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | RADEON_CRTC_HSYNC_DIS, ~mask); + break; + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off */ + OUTREGP(RADEON_CRTC_EXT_CNTL, + RADEON_CRTC_DISPLAY_DIS | RADEON_CRTC_VSYNC_DIS, ~mask); + break; + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + OUTREGP(RADEON_CRTC_EXT_CNTL, mask, ~mask); + break; + } +} +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c:1.2 --- /dev/null Mon Dec 18 14:30:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c Sat Nov 18 14:37:12 2000 @@ -0,0 +1,84 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_misc.c,v 1.2 2000/11/18 19:37:12 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef XFree86LOADER + +#include "ativersion.h" + +#include "radeon_version.h" + +#include "xf86.h" + +/* Module loader interface for subsidiary driver module */ + +static XF86ModuleVersionInfo RADEONVersionRec = +{ + RADEON_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + RADEON_VERSION_MAJOR, RADEON_VERSION_MINOR, RADEON_VERSION_PATCH, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * RADEONSetup -- + * + * This function is called every time the module is loaded. + */ +static pointer +RADEONSetup +( + pointer Module, + pointer Options, + int *ErrorMajor, + int *ErrorMinor +) +{ + static Bool Inited = FALSE; + + if (!Inited) + { + /* Ensure main driver module is loaded, but not as a submodule */ + if (!xf86ServerIsOnlyDetecting() && !LoaderSymbol(ATI_NAME)) + xf86LoadOneModule(ATI_DRIVER_NAME, Options); + + Inited = TRUE; + } + + return (pointer)TRUE; +} + +/* The following record must be called radeonModuleData */ +XF86ModuleData radeonModuleData = +{ + &RADEONVersionRec, + RADEONSetup, + NULL +}; + +#endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c:1.5 --- /dev/null Mon Dec 18 14:30:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c Tue Dec 12 21:45:00 2000 @@ -0,0 +1,206 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.c,v 1.5 2000/12/13 02:45:00 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#include "atimodule.h" +#include "ativersion.h" + +#include "radeon_probe.h" +#include "radeon_version.h" + +#include "xf86PciInfo.h" + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86Resources.h" + +SymTabRec RADEONChipsets[] = { + { PCI_CHIP_RADEON_QD, "ATI Radeon QD (AGP)" }, + { PCI_CHIP_RADEON_QE, "ATI Radeon QE (AGP)" }, + { PCI_CHIP_RADEON_QF, "ATI Radeon QF (AGP)" }, + { PCI_CHIP_RADEON_QG, "ATI Radeon QG (AGP)" }, + { -1, NULL } +}; + +PciChipsets RADEONPciChipsets[] = { + { PCI_CHIP_RADEON_QD, PCI_CHIP_RADEON_QD, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QE, PCI_CHIP_RADEON_QE, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QF, PCI_CHIP_RADEON_QF, RES_SHARED_VGA }, + { PCI_CHIP_RADEON_QG, PCI_CHIP_RADEON_QG, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +/* Return the options for supported chipset 'n'; NULL otherwise */ +OptionInfoPtr +RADEONAvailableOptions(int chipid, int busid) +{ + int i; + + /* + * Return options defined in the radeon submodule which will have been + * loaded by this point. + */ + for (i = 0; RADEONPciChipsets[i].PCIid > 0; i++) { + if (chipid == RADEONPciChipsets[i].PCIid) + return RADEONOptions; + } + return NULL; +} + +/* Return the string name for supported chipset 'n'; NULL otherwise. */ +void +RADEONIdentify(int flags) +{ + xf86PrintChipsets(RADEON_NAME, + "Driver for ATI Radeon chipsets", + RADEONChipsets); +} + +/* Return TRUE if chipset is present; FALSE otherwise. */ +Bool +RADEONProbe(DriverPtr drv, int flags) +{ + int numUsed; + int numDevSections, nATIGDev, nRadeonGDev; + int *usedChips; + GDevPtr *devSections, *ATIGDevs, *RadeonGDevs; + EntityInfoPtr pEnt; + Bool foundScreen = FALSE; + int i; + + if (!xf86GetPciVideoInfo()) return FALSE; + + /* Collect unclaimed device sections for both driver names */ + nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs); + nRadeonGDev = xf86MatchDevice(RADEON_NAME, &RadeonGDevs); + + if (!(numDevSections = nATIGDev + nRadeonGDev)) return FALSE; + + if (!ATIGDevs) { + if (!(devSections = RadeonGDevs)) + numDevSections = 1; + else + numDevSections = nRadeonGDev; + } if (!RadeonGDevs) { + devSections = ATIGDevs; + numDevSections = nATIGDev; + } else { + /* Combine into one list */ + devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr)); + (void)memcpy(devSections, + ATIGDevs, nATIGDev * sizeof(GDevPtr)); + (void)memcpy(devSections + nATIGDev, + RadeonGDevs, nRadeonGDev * sizeof(GDevPtr)); + devSections[numDevSections] = NULL; + xfree(ATIGDevs); + xfree(RadeonGDevs); + } + + numUsed = xf86MatchPciInstances(RADEON_NAME, + PCI_VENDOR_ATI, + RADEONChipsets, + RADEONPciChipsets, + devSections, + numDevSections, + drv, + &usedChips); + + if (numUsed<=0) return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + pEnt = xf86GetEntityInfo(usedChips[i]); + + if (pEnt->active) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + +#ifdef XFree86LOADER + if (!xf86LoadSubModule(pScrn, "radeon")) { + xf86Msg(X_ERROR, + RADEON_NAME ": Failed to load \"radeon\" module.\n"); + xf86DeleteScreen(pScrn->scrnIndex, 0); + continue; + } + + xf86LoaderReqSymLists(RADEONSymbols, NULL); + + /* Workaround for possible loader bug */ +# define RADEONPreInit \ + (xf86PreInitProc*) LoaderSymbol("RADEONPreInit") +# define RADEONScreenInit \ + (xf86ScreenInitProc*) LoaderSymbol("RADEONScreenInit") +# define RADEONSwitchMode \ + (xf86SwitchModeProc*) LoaderSymbol("RADEONSwitchMode") +# define RADEONAdjustFrame \ + (xf86AdjustFrameProc*)LoaderSymbol("RADEONAdjustFrame") +# define RADEONEnterVT \ + (xf86EnterVTProc*) LoaderSymbol("RADEONEnterVT") +# define RADEONLeaveVT \ + (xf86LeaveVTProc*) LoaderSymbol("RADEONLeaveVT") +# define RADEONFreeScreen \ + (xf86FreeScreenProc*) LoaderSymbol("RADEONFreeScreen") +# define RADEONValidMode \ + (xf86ValidModeProc*) LoaderSymbol("RADEONValidMode") + +#endif + + pScrn->driverVersion = RADEON_VERSION_CURRENT; + pScrn->driverName = RADEON_DRIVER_NAME; + pScrn->name = RADEON_NAME; + pScrn->Probe = RADEONProbe; + pScrn->PreInit = RADEONPreInit; + pScrn->ScreenInit = RADEONScreenInit; + pScrn->SwitchMode = RADEONSwitchMode; + pScrn->AdjustFrame = RADEONAdjustFrame; + pScrn->EnterVT = RADEONEnterVT; + pScrn->LeaveVT = RADEONLeaveVT; + pScrn->FreeScreen = RADEONFreeScreen; + pScrn->ValidMode = RADEONValidMode; + + foundScreen = TRUE; + + xf86ConfigActivePciEntity(pScrn, usedChips[i], RADEONPciChipsets, + 0, 0, 0, 0, 0); + } + xfree(pEnt); + } + + xfree(usedChips); + xfree(devSections); + + return foundScreen; +} Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h:1.3 --- /dev/null Mon Dec 18 14:30:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h Sat Nov 18 14:37:12 2000 @@ -0,0 +1,75 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_probe.h,v 1.3 2000/11/18 19:37:12 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * + * Modified by Marc Aurele La France <tsi@xfree86.org> for ATI driver merge. + */ + +#ifndef _RADEON_PROBE_H_ +#define _RADEON_PROBE_H_ 1 + +#include "atiproto.h" + +#include "xf86str.h" + +/* radeon_probe.c */ +extern OptionInfoPtr RADEONAvailableOptions + FunctionPrototype((int, int)); +extern void RADEONIdentify + FunctionPrototype((int)); +extern Bool RADEONProbe + FunctionPrototype((DriverPtr, int)); + +extern SymTabRec RADEONChipsets[]; +extern PciChipsets RADEONPciChipsets[]; + +/* radeon_driver.c */ +extern Bool RADEONPreInit + FunctionPrototype((ScrnInfoPtr, int)); +extern Bool RADEONScreenInit + FunctionPrototype((int, ScreenPtr, int, char **)); +extern Bool RADEONSwitchMode + FunctionPrototype((int, DisplayModePtr, int)); +extern void RADEONAdjustFrame + FunctionPrototype((int, int, int, int)); +extern Bool RADEONEnterVT + FunctionPrototype((int, int)); +extern void RADEONLeaveVT + FunctionPrototype((int, int)); +extern void RADEONFreeScreen + FunctionPrototype((int, int)); +extern int RADEONValidMode + FunctionPrototype((int, DisplayModePtr, Bool, int)); + +extern OptionInfoRec RADEONOptions[]; + +#endif /* _RADEON_PROBE_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h:1.4 --- /dev/null Mon Dec 18 14:30:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h Sat Nov 18 14:37:12 2000 @@ -0,0 +1,1481 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.4 2000/11/18 19:37:12 tsi Exp $ */ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and + * VA Linux Systems Inc., Fremont, California. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Rickard E. Faith <faith@valinux.com> + * Alan Hourihane <ahourihane@valinux.com> + * + * References: + * + * !!!! FIXME !!!! + * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical + * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April + * 1999. + * + * !!!! FIXME !!!! + * RAGE 128 Software Development Manual (Technical Reference Manual P/N + * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. + * + */ + +/* !!!! FIXME !!!! NOTE: THIS FILE HAS BEEN CONVERTED FROM r128_reg.h + * AND CONTAINS REGISTERS AND REGISTER DEFINITIONS THAT ARE NOT CORRECT + * ON THE RADEON. A FULL AUDIT OF THIS CODE IS NEEDED! */ + +#ifndef _RADEON_REG_H_ +#define _RADEON_REG_H_ + +#include "xf86_ansic.h" +#include "compiler.h" + + /* Memory mapped register access macros */ +#define INREG8(addr) MMIO_IN8(RADEONMMIO, addr) +#define INREG16(addr) MMIO_IN16(RADEONMMIO, addr) +#define INREG(addr) MMIO_IN32(RADEONMMIO, addr) +#define OUTREG8(addr, val) MMIO_OUT8(RADEONMMIO, addr, val) +#define OUTREG16(addr, val) MMIO_OUT16(RADEONMMIO, addr, val) +#define OUTREG(addr, val) MMIO_OUT32(RADEONMMIO, addr, val) + +#define ADDRREG(addr) ((volatile CARD32 *)(RADEONMMIO + (addr))) + + +#define OUTREGP(addr, val, mask) \ + do { \ + CARD32 tmp = INREG(addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTREG(addr, tmp); \ + } while (0) + +#define INPLL(pScrn, addr) RADEONINPLL(pScrn, addr) + +#if !RADEON_ATOMIC_UPDATE +#define OUTPLL(addr, val) \ + do { \ + while ( (INREG(RADEON_CLOCK_CNTL_INDEX) & 0x9f) != \ + (addr | RADEON_PLL_WR_EN)) { \ + OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x1f) | \ + RADEON_PLL_WR_EN)); \ + } \ + OUTREG(RADEON_CLOCK_CNTL_DATA, val); \ + } while (0) +#else +#define OUTPLL(addr, val) \ + do { \ + OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x1f) | \ + RADEON_PLL_WR_EN)); \ + OUTREG(RADEON_CLOCK_CNTL_DATA, val); \ + } while (0) +#endif + +#define OUTPLLP(pScrn, addr, val, mask) \ + do { \ + CARD32 tmp = INPLL(pScrn, addr); \ + tmp &= (mask); \ + tmp |= (val); \ + OUTPLL(addr, tmp); \ + } while (0) + +#define OUTPAL_START(idx) \ + do { \ + OUTREG8(RADEON_PALETTE_INDEX, (idx)); \ + } while (0) + +#define OUTPAL_NEXT(r, g, b) \ + do { \ + OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ + } while (0) + +#define OUTPAL_NEXT_CARD32(v) \ + do { \ + OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \ + } while (0) + +#define OUTPAL(idx, r, g, b) \ + do { \ + OUTPAL_START((idx)); \ + OUTPAL_NEXT((r), (g), (b)); \ + } while (0) + +#define INPAL_START(idx) \ + do { \ + OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \ + } while (0) + +#define INPAL_NEXT() INREG(RADEON_PALETTE_DATA) + +#define PAL_SELECT(idx) \ + do { \ + if (idx) { \ + OUTREG(RADEON_DAC_CNTL, INREG(RADEON_DAC_CNTL) | \ + RADEON_DAC_PALETTE_ACC_CTL); \ + } else { \ + OUTREG(RADEON_DAC_CNTL, INREG(RADEON_DAC_CNTL) & \ + ~RADEON_DAC_PALETTE_ACC_CTL); \ + } \ + } while (0) + +#define RADEON_ADAPTER_ID 0x0f2c /* PCI */ +#define RADEON_AGP_BASE 0x0170 +#define RADEON_AGP_CNTL 0x0174 +# define RADEON_AGP_APER_SIZE_256MB (0x00 << 0) +# define RADEON_AGP_APER_SIZE_128MB (0x20 << 0) +# define RADEON_AGP_APER_SIZE_64MB (0x30 << 0) +# define RADEON_AGP_APER_SIZE_32MB (0x38 << 0) +# define RADEON_AGP_APER_SIZE_16MB (0x3c << 0) +# define RADEON_AGP_APER_SIZE_8MB (0x3e << 0) +# define RADEON_AGP_APER_SIZE_4MB (0x3f << 0) +# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0) +#define RADEON_AGP_COMMAND 0x0f60 /* PCI */ +#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */ +#define RADEON_AGP_STATUS 0x0f5c /* PCI */ +# define RADEON_AGP_1X_MODE 0x01 +# define RADEON_AGP_2X_MODE 0x02 +# define RADEON_AGP_4X_MODE 0x04 +# define RADEON_AGP_MODE_MASK 0x07 +#define RADEON_AMCGPIO_A_REG 0x01a0 +#define RADEON_AMCGPIO_EN_REG 0x01a8 +#define RADEON_AMCGPIO_MASK 0x0194 +#define RADEON_AMCGPIO_Y_REG 0x01a4 +#define RADEON_ATTRDR 0x03c1 /* VGA */ +#define RADEON_ATTRDW 0x03c0 /* VGA */ +#define RADEON_ATTRX 0x03c0 /* VGA */ +# define RADEON_AUX1_SC_EN (1 << 0) +# define RADEON_AUX1_SC_MODE_OR (0 << 1) +# define RADEON_AUX1_SC_MODE_NAND (1 << 1) +# define RADEON_AUX2_SC_EN (1 << 2) +# define RADEON_AUX2_SC_MODE_OR (0 << 3) +# define RADEON_AUX2_SC_MODE_NAND (1 << 3) +# define RADEON_AUX3_SC_EN (1 << 4) +# define RADEON_AUX3_SC_MODE_OR (0 << 5) +# define RADEON_AUX3_SC_MODE_NAND (1 << 5) +#define RADEON_AUX_SC_CNTL 0x1660 +#define RADEON_AUX1_SC_BOTTOM 0x1670 +#define RADEON_AUX1_SC_LEFT 0x1664 +#define RADEON_AUX1_SC_RIGHT 0x1668 +#define RADEON_AUX1_SC_TOP 0x166c +#define RADEON_AUX2_SC_BOTTOM 0x1680 +#define RADEON_AUX2_SC_LEFT 0x1674 +#define RADEON_AUX2_SC_RIGHT 0x1678 +#define RADEON_AUX2_SC_TOP 0x167c +#define RADEON_AUX3_SC_BOTTOM 0x1690 +#define RADEON_AUX3_SC_LEFT 0x1684 +#define RADEON_AUX3_SC_RIGHT 0x1688 +#define RADEON_AUX3_SC_TOP 0x168c +#define RADEON_AUX_WINDOW_HORZ_CNTL 0x02d8 +#define RADEON_AUX_WINDOW_VERT_CNTL 0x02dc + +#define RADEON_BASE_CODE 0x0f0b +#define RADEON_BIOS_0_SCRATCH 0x0010 +#define RADEON_BIOS_1_SCRATCH 0x0014 +#define RADEON_BIOS_2_SCRATCH 0x0018 +#define RADEON_BIOS_3_SCRATCH 0x001c +#define RADEON_BIOS_ROM 0x0f30 /* PCI */ +#define RADEON_BIST 0x0f0f /* PCI */ +#define RADEON_BRUSH_DATA0 0x1480 +#define RADEON_BRUSH_DATA1 0x1484 +#define RADEON_BRUSH_DATA10 0x14a8 +#define RADEON_BRUSH_DATA11 0x14ac +#define RADEON_BRUSH_DATA12 0x14b0 +#define RADEON_BRUSH_DATA13 0x14b4 +#define RADEON_BRUSH_DATA14 0x14b8 +#define RADEON_BRUSH_DATA15 0x14bc +#define RADEON_BRUSH_DATA16 0x14c0 +#define RADEON_BRUSH_DATA17 0x14c4 +#define RADEON_BRUSH_DATA18 0x14c8 +#define RADEON_BRUSH_DATA19 0x14cc +#define RADEON_BRUSH_DATA2 0x1488 +#define RADEON_BRUSH_DATA20 0x14d0 +#define RADEON_BRUSH_DATA21 0x14d4 +#define RADEON_BRUSH_DATA22 0x14d8 +#define RADEON_BRUSH_DATA23 0x14dc +#define RADEON_BRUSH_DATA24 0x14e0 +#define RADEON_BRUSH_DATA25 0x14e4 +#define RADEON_BRUSH_DATA26 0x14e8 +#define RADEON_BRUSH_DATA27 0x14ec +#define RADEON_BRUSH_DATA28 0x14f0 +#define RADEON_BRUSH_DATA29 0x14f4 +#define RADEON_BRUSH_DATA3 0x148c +#define RADEON_BRUSH_DATA30 0x14f8 +#define RADEON_BRUSH_DATA31 0x14fc +#define RADEON_BRUSH_DATA32 0x1500 +#define RADEON_BRUSH_DATA33 0x1504 +#define RADEON_BRUSH_DATA34 0x1508 +#define RADEON_BRUSH_DATA35 0x150c +#define RADEON_BRUSH_DATA36 0x1510 +#define RADEON_BRUSH_DATA37 0x1514 +#define RADEON_BRUSH_DATA38 0x1518 +#define RADEON_BRUSH_DATA39 0x151c +#define RADEON_BRUSH_DATA4 0x1490 +#define RADEON_BRUSH_DATA40 0x1520 +#define RADEON_BRUSH_DATA41 0x1524 +#define RADEON_BRUSH_DATA42 0x1528 +#define RADEON_BRUSH_DATA43 0x152c +#define RADEON_BRUSH_DATA44 0x1530 +#define RADEON_BRUSH_DATA45 0x1534 +#define RADEON_BRUSH_DATA46 0x1538 +#define RADEON_BRUSH_DATA47 0x153c +#define RADEON_BRUSH_DATA48 0x1540 +#define RADEON_BRUSH_DATA49 0x1544 +#define RADEON_BRUSH_DATA5 0x1494 +#define RADEON_BRUSH_DATA50 0x1548 +#define RADEON_BRUSH_DATA51 0x154c +#define RADEON_BRUSH_DATA52 0x1550 +#define RADEON_BRUSH_DATA53 0x1554 +#define RADEON_BRUSH_DATA54 0x1558 +#define RADEON_BRUSH_DATA55 0x155c +#define RADEON_BRUSH_DATA56 0x1560 +#define RADEON_BRUSH_DATA57 0x1564 +#define RADEON_BRUSH_DATA58 0x1568 +#define RADEON_BRUSH_DATA59 0x156c +#define RADEON_BRUSH_DATA6 0x1498 +#define RADEON_BRUSH_DATA60 0x1570 +#define RADEON_BRUSH_DATA61 0x1574 +#define RADEON_BRUSH_DATA62 0x1578 +#define RADEON_BRUSH_DATA63 0x157c +#define RADEON_BRUSH_DATA7 0x149c +#define RADEON_BRUSH_DATA8 0x14a0 +#define RADEON_BRUSH_DATA9 0x14a4 +#define RADEON_BRUSH_SCALE 0x1470 +#define RADEON_BRUSH_Y_X 0x1474 +#define RADEON_BUS_CNTL 0x0030 +# define RADEON_BUS_MASTER_DIS (1 << 6) +# define RADEON_BUS_RD_DISCARD_EN (1 << 24) +# define RADEON_BUS_RD_ABORT_EN (1 << 25) +# define RADEON_BUS_MSTR_DISCONNECT_EN (1 << 28) +# define RADEON_BUS_WRT_BURST (1 << 29) +# define RADEON_BUS_READ_BURST (1 << 30) +#define RADEON_BUS_CNTL1 0x0034 +# define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4) + +#define RADEON_CACHE_CNTL 0x1724 +#define RADEON_CACHE_LINE 0x0f0c /* PCI */ +#define RADEON_CAP0_TRIG_CNTL 0x0950 /* ? */ +#define RADEON_CAP1_TRIG_CNTL 0x09c0 /* ? */ +#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */ +#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */ +#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */ +#define RADEON_CLOCK_CNTL_DATA 0x000c +#define RADEON_CLOCK_CNTL_INDEX 0x0008 +# define RADEON_PLL_WR_EN (1 << 7) +# define RADEON_PLL_DIV_SEL (3 << 8) +#define RADEON_CLR_CMP_CLR_3D 0x1a24 +#define RADEON_CLR_CMP_CLR_DST 0x15c8 +#define RADEON_CLR_CMP_CLR_SRC 0x15c4 +#define RADEON_CLR_CMP_CNTL 0x15c0 +# define RADEON_SRC_CMP_EQ_COLOR (4 << 0) +# define RADEON_SRC_CMP_NEQ_COLOR (5 << 0) +# define RADEON_CLR_CMP_SRC_SOURCE (1 << 24) +#define RADEON_CLR_CMP_MASK 0x15cc +# define RADEON_CLR_CMP_MSK 0xffffffff +#define RADEON_CLR_CMP_MASK_3D 0x1A28 +#define RADEON_COMMAND 0x0f04 /* PCI */ +#define RADEON_COMPOSITE_SHADOW_ID 0x1a0c +#define RADEON_CONFIG_APER_0_BASE 0x0100 +#define RADEON_CONFIG_APER_1_BASE 0x0104 +#define RADEON_CONFIG_APER_SIZE 0x0108 +#define RADEON_CONFIG_BONDS 0x00e8 +#define RADEON_CONFIG_CNTL 0x00e0 +#define RADEON_CONFIG_MEMSIZE 0x00f8 +#define RADEON_CONFIG_MEMSIZE_EMBEDDED 0x0114 +#define RADEON_CONFIG_REG_1_BASE 0x010c +#define RADEON_CONFIG_REG_APER_SIZE 0x0110 +#define RADEON_CONFIG_XSTRAP 0x00e4 +#define RADEON_CONSTANT_COLOR_C 0x1d34 +# define RADEON_CONSTANT_COLOR_MASK 0x00ffffff +# define RADEON_CONSTANT_COLOR_ONE 0x00ffffff +# define RADEON_CONSTANT_COLOR_ZERO 0x00000000 +#define RADEON_CRC_CMDFIFO_ADDR 0x0740 +#define RADEON_CRC_CMDFIFO_DOUT 0x0744 +#define RADEON_CRTC_CRNT_FRAME 0x0214 +#define RADEON_CRTC_DEBUG 0x021c +#define RADEON_CRTC_EXT_CNTL 0x0054 +# define RADEON_CRTC_VGA_XOVERSCAN (1 << 0) +# define RADEON_VGA_ATI_LINEAR (1 << 3) +# define RADEON_XCRT_CNT_EN (1 << 6) +# define RADEON_CRTC_HSYNC_DIS (1 << 8) +# define RADEON_CRTC_VSYNC_DIS (1 << 9) +# define RADEON_CRTC_DISPLAY_DIS (1 << 10) +# define RADEON_CRTC_CRT_ON (1 << 15) +#define RADEON_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 +# define RADEON_CRTC_HSYNC_DIS_BYTE (1 << 0) +# define RADEON_CRTC_VSYNC_DIS_BYTE (1 << 1) +# define RADEON_CRTC_DISPLAY_DIS_BYTE (1 << 2) +#define RADEON_CRTC_GEN_CNTL 0x0050 +# define RADEON_CRTC_DBL_SCAN_EN (1 << 0) +# define RADEON_CRTC_INTERLACE_EN (1 << 1) +# define RADEON_CRTC_CSYNC_EN (1 << 4) +# define RADEON_CRTC_CUR_EN (1 << 16) +# define RADEON_CRTC_CUR_MODE_MASK (7 << 17) +# define RADEON_CRTC_ICON_EN (1 << 20) +# define RADEON_CRTC_EXT_DISP_EN (1 << 24) +# define RADEON_CRTC_EN (1 << 25) +# define RADEON_CRTC_DISP_REQ_EN_B (1 << 26) +#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218 +#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204 +# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0) +# define RADEON_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) +# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 +# define RADEON_CRTC_H_SYNC_WID (0x3f << 16) +# define RADEON_CRTC_H_SYNC_WID_SHIFT 16 +# define RADEON_CRTC_H_SYNC_POL (1 << 23) +#define RADEON_CRTC_H_TOTAL_DISP 0x0200 +# define RADEON_CRTC_H_TOTAL (0x01ff << 0) +# define RADEON_CRTC_H_TOTAL_SHIFT 0 +# define RADEON_CRTC_H_DISP (0x00ff << 16) +# define RADEON_CRTC_H_DISP_SHIFT 16 +#define RADEON_CRTC_OFFSET 0x0224 +#define RADEON_CRTC_OFFSET_CNTL 0x0228 +#define RADEON_CRTC_PITCH 0x022c +#define RADEON_CRTC_STATUS 0x005c +# define RADEON_CRTC_VBLANK_SAVE (1 << 1) +#define RADEON_CRTC_V_SYNC_STRT_WID 0x020c +# define RADEON_CRTC_V_SYNC_STRT (0x7ff << 0) +# define RADEON_CRTC_V_SYNC_STRT_SHIFT 0 +# define RADEON_CRTC_V_SYNC_WID (0x1f << 16) +# define RADEON_CRTC_V_SYNC_WID_SHIFT 16 +# define RADEON_CRTC_V_SYNC_POL (1 << 23) +#define RADEON_CRTC_V_TOTAL_DISP 0x0208 +# define RADEON_CRTC_V_TOTAL (0x07ff << 0) +# define RADEON_CRTC_V_TOTAL_SHIFT 0 +# define RADEON_CRTC_V_DISP (0x07ff << 16) +# define RADEON_CRTC_V_DISP_SHIFT 16 +#define RADEON_CRTC_VLINE_CRNT_VLINE 0x0210 +# define RADEON_CRTC_CRNT_VLINE_MASK (0x7ff << 16) +#define RADEON_CRTC2_CRNT_FRAME 0x0314 +#define RADEON_CRTC2_DEBUG 0x031c +#define RADEON_CRTC2_GEN_CNTL 0x03f8 +#define RADEON_CRTC2_GUI_TRIG_VLINE 0x0318 +#define RADEON_CRTC2_H_SYNC_STRT_WID 0x0304 +#define RADEON_CRTC2_H_TOTAL_DISP 0x0300 +#define RADEON_CRTC2_OFFSET 0x0324 +#define RADEON_CRTC2_OFFSET_CNTL 0x0328 +#define RADEON_CRTC2_PITCH 0x032c +#define RADEON_CRTC2_STATUS 0x03fc +#define RADEON_CRTC2_V_SYNC_STRT_WID 0x030c +#define RADEON_CRTC2_V_TOTAL_DISP 0x0308 +#define RADEON_CRTC2_VLINE_CRNT_VLINE 0x0310 +#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ +#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ +#define RADEON_CUR_CLR0 0x026c +#define RADEON_CUR_CLR1 0x0270 +#define RADEON_CUR_HORZ_VERT_OFF 0x0268 +#define RADEON_CUR_HORZ_VERT_POSN 0x0264 +#define RADEON_CUR_OFFSET 0x0260 +# define RADEON_CUR_LOCK (1 << 31) + +#define RADEON_DAC_CNTL 0x0058 +# define RADEON_DAC_RANGE_CNTL (3 << 0) +# define RADEON_DAC_BLANKING (1 << 2) +# define RADEON_DAC_CRT_SEL_CRTC2 (1 << 4) +# define RADEON_DAC_PALETTE_ACC_CTL (1 << 5) +# define RADEON_DAC_8BIT_EN (1 << 8) +# define RADEON_DAC_VGA_ADR_EN (1 << 13) +# define RADEON_DAC_MASK_ALL (0xff << 24) +#define RADEON_DAC_CRC_SIG 0x02cc +#define RADEON_DAC_DATA 0x03c9 /* VGA */ +#define RADEON_DAC_MASK 0x03c6 /* VGA */ +#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */ +#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */ +#define RADEON_DDA_CONFIG 0x02e0 +#define RADEON_DDA_ON_OFF 0x02e4 +#define RADEON_DEFAULT_OFFSET 0x16e0 +#define RADEON_DEFAULT_PITCH 0x16e4 +#define RADEON_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 +# define RADEON_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) +# define RADEON_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) +#define RADEON_DESTINATION_3D_CLR_CMP_VAL 0x1820 +#define RADEON_DESTINATION_3D_CLR_CMP_MSK 0x1824 +#define RADEON_DEVICE_ID 0x0f02 /* PCI */ +#define RADEON_DISP_MISC_CNTL 0x0d00 +# define RADEON_SOFT_RESET_GRPH_PP (1 << 0) +#define RADEON_DP_BRUSH_BKGD_CLR 0x1478 +#define RADEON_DP_BRUSH_FRGD_CLR 0x147c +#define RADEON_DP_CNTL 0x16c0 +# define RADEON_DST_X_LEFT_TO_RIGHT (1 << 0) +# define RADEON_DST_Y_TOP_TO_BOTTOM (1 << 1) +#define RADEON_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 +# define RADEON_DST_Y_MAJOR (1 << 2) +# define RADEON_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) +# define RADEON_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) +#define RADEON_DP_DATATYPE 0x16c4 +# define RADEON_HOST_BIG_ENDIAN_EN (1 << 29) +#define RADEON_DP_GUI_MASTER_CNTL 0x146c +# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) +# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) +# define RADEON_GMC_SRC_CLIPPING (1 << 2) +# define RADEON_GMC_DST_CLIPPING (1 << 3) +# define RADEON_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) +# define RADEON_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) +# define RADEON_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) +# define RADEON_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) +# define RADEON_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) +# define RADEON_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) +# define RADEON_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) +# define RADEON_GMC_BRUSH_8x8_COLOR (10 << 4) +# define RADEON_GMC_BRUSH_1X8_COLOR (12 << 4) +# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define RADEON_GMC_BRUSH_NONE (15 << 4) +# define RADEON_GMC_DST_8BPP_CI (2 << 8) +# define RADEON_GMC_DST_15BPP (3 << 8) +# define RADEON_GMC_DST_16BPP (4 << 8) +# define RADEON_GMC_DST_24BPP (5 << 8) +# define RADEON_GMC_DST_32BPP (6 << 8) +# define RADEON_GMC_DST_8BPP_RGB (7 << 8) +# define RADEON_GMC_DST_Y8 (8 << 8) +# define RADEON_GMC_DST_RGB8 (9 << 8) +# define RADEON_GMC_DST_VYUY (11 << 8) +# define RADEON_GMC_DST_YVYU (12 << 8) +# define RADEON_GMC_DST_AYUV444 (14 << 8) +# define RADEON_GMC_DST_ARGB4444 (15 << 8) +# define RADEON_GMC_DST_DATATYPE_MASK (0x0f << 8) +# define RADEON_GMC_DST_DATATYPE_SHIFT 8 +# define RADEON_GMC_SRC_DATATYPE_MASK (3 << 12) +# define RADEON_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) +# define RADEON_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) +# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12) +# define RADEON_GMC_BYTE_PIX_ORDER (1 << 14) +# define RADEON_GMC_BYTE_MSB_TO_LSB (0 << 14) +# define RADEON_GMC_BYTE_LSB_TO_MSB (1 << 14) +# define RADEON_GMC_CONVERSION_TEMP (1 << 15) +# define RADEON_GMC_CONVERSION_TEMP_6500 (0 << 15) +# define RADEON_GMC_CONVERSION_TEMP_9300 (1 << 15) +# define RADEON_GMC_ROP3_MASK (0xff << 16) +# define RADEON_DP_SRC_SOURCE_MASK (7 << 24) +# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24) +# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24) +# define RADEON_GMC_3D_FCN_EN (1 << 27) +# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28) +# define RADEON_GMC_AUX_CLIP_DIS (1 << 29) +# define RADEON_GMC_WR_MSK_DIS (1 << 30) +# define RADEON_GMC_LD_BRUSH_Y_X (1 << 31) +# define RADEON_ROP3_ZERO 0x00000000 +# define RADEON_ROP3_DSa 0x00880000 +# define RADEON_ROP3_SDna 0x00440000 +# define RADEON_ROP3_S 0x00cc0000 +# define RADEON_ROP3_DSna 0x00220000 +# define RADEON_ROP3_D 0x00aa0000 +# define RADEON_ROP3_DSx 0x00660000 +# define RADEON_ROP3_DSo 0x00ee0000 +# define RADEON_ROP3_DSon 0x00110000 +# define RADEON_ROP3_DSxn 0x00990000 +# define RADEON_ROP3_Dn 0x00550000 +# define RADEON_ROP3_SDno 0x00dd0000 +# define RADEON_ROP3_Sn 0x00330000 +# define RADEON_ROP3_DSno 0x00bb0000 +# define RADEON_ROP3_DSan 0x00770000 +# define RADEON_ROP3_ONE 0x00ff0000 +# define RADEON_ROP3_DPa 0x00a00000 +# define RADEON_ROP3_PDna 0x00500000 +# define RADEON_ROP3_P 0x00f00000 +# define RADEON_ROP3_DPna 0x000a0000 +# define RADEON_ROP3_D 0x00aa0000 +# define RADEON_ROP3_DPx 0x005a0000 +# define RADEON_ROP3_DPo 0x00fa0000 +# define RADEON_ROP3_DPon 0x00050000 +# define RADEON_ROP3_PDxn 0x00a50000 +# define RADEON_ROP3_PDno 0x00f50000 +# define RADEON_ROP3_Pn 0x000f0000 +# define RADEON_ROP3_DPno 0x00af0000 +# define RADEON_ROP3_DPan 0x005f0000 + + +#define RADEON_DP_GUI_MASTER_CNTL_C 0x1c84 +#define RADEON_DP_MIX 0x16c8 +#define RADEON_DP_SRC_BKGD_CLR 0x15dc +#define RADEON_DP_SRC_FRGD_CLR 0x15d8 +#define RADEON_DP_WRITE_MASK 0x16cc +#define RADEON_DST_BRES_DEC 0x1630 +#define RADEON_DST_BRES_ERR 0x1628 +#define RADEON_DST_BRES_INC 0x162c +#define RADEON_DST_BRES_LNTH 0x1634 +#define RADEON_DST_BRES_LNTH_SUB 0x1638 +#define RADEON_DST_HEIGHT 0x1410 +#define RADEON_DST_HEIGHT_WIDTH 0x143c +#define RADEON_DST_HEIGHT_WIDTH_8 0x158c +#define RADEON_DST_HEIGHT_WIDTH_BW 0x15b4 +#define RADEON_DST_HEIGHT_Y 0x15a0 +#define RADEON_DST_LINE_START 0x1600 +#define RADEON_DST_LINE_END 0x1604 +#define RADEON_DST_OFFSET 0x1404 +#define RADEON_DST_PITCH 0x1408 +#define RADEON_DST_PITCH_OFFSET 0x142c +#define RADEON_DST_PITCH_OFFSET_C 0x1c80 +# define RADEON_PITCH_SHIFT 21 +#define RADEON_DST_WIDTH 0x140c +#define RADEON_DST_WIDTH_HEIGHT 0x1598 +#define RADEON_DST_WIDTH_X 0x1588 +#define RADEON_DST_WIDTH_X_INCY 0x159c +#define RADEON_DST_X 0x141c +#define RADEON_DST_X_SUB 0x15a4 +#define RADEON_DST_X_Y 0x1594 +#define RADEON_DST_Y 0x1420 +#define RADEON_DST_Y_SUB 0x15a8 +#define RADEON_DST_Y_X 0x1438 + +#define RADEON_FCP_CNTL 0x0012 /* PLL */ +#define RADEON_FLUSH_1 0x1704 +#define RADEON_FLUSH_2 0x1708 +#define RADEON_FLUSH_3 0x170c +#define RADEON_FLUSH_4 0x1710 +#define RADEON_FLUSH_5 0x1714 +#define RADEON_FLUSH_6 0x1718 +#define RADEON_FLUSH_7 0x171c +#define RADEON_FOG_3D_TABLE_START 0x1810 +#define RADEON_FOG_3D_TABLE_END 0x1814 +#define RADEON_FOG_3D_TABLE_DENSITY 0x181c +#define RADEON_FOG_TABLE_INDEX 0x1a14 +#define RADEON_FOG_TABLE_DATA 0x1a18 +#define RADEON_FP_CRTC_H_TOTAL_DISP 0x0250 +#define RADEON_FP_CRTC_V_TOTAL_DISP 0x0254 +#define RADEON_FP_GEN_CNTL 0x0284 +# define RADEON_FP_FPON (1 << 0) +# define RADEON_FP_TDMS_EN (1 << 2) +# define RADEON_FP_DETECT_SENSE (1 << 8) +# define RADEON_FP_SEL_CRTC2 (1 << 13) +# define RADEON_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) +# define RADEON_FP_CRTC_USE_SHADOW_VEND (1 << 18) +# define RADEON_FP_CRTC_HORZ_DIV2_EN (1 << 20) +# define RADEON_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) +# define RADEON_FP_USE_SHADOW_EN (1 << 24) +#define RADEON_FP_H_SYNC_STRT_WID 0x02c4 +#define RADEON_FP_HORZ_STRETCH 0x028c +# define RADEON_HORZ_STRETCH_RATIO_MASK 0xffff +# define RADEON_HORZ_STRETCH_RATIO_SHIFT 0 +# define RADEON_HORZ_STRETCH_RATIO_MAX 4096 +# define RADEON_HORZ_PANEL_SIZE (0xff << 16) +# define RADEON_HORZ_PANEL_SHIFT 16 +# define RADEON_HORZ_STRETCH_PIXREP (0 << 25) +# define RADEON_HORZ_STRETCH_BLEND (1 << 25) +# define RADEON_HORZ_STRETCH_ENABLE (1 << 26) +# define RADEON_HORZ_FP_LOOP_STRETCH (0x7 << 27) +# define RADEON_HORZ_STRETCH_RESERVED (1 << 30) +# define RADEON_HORZ_AUTO_RATIO_FIX_EN (1 << 31) + +#define RADEON_FP_PANEL_CNTL 0x0288 +# define RADEON_FP_DIGON (1 << 0) +# define RADEON_FP_BLON (1 << 1) +#define RADEON_FP_V_SYNC_STRT_WID 0x02c8 +#define RADEON_FP_VERT_STRETCH 0x0290 +# define RADEON_VERT_PANEL_SIZE (0x7ff << 0) +# define RADEON_VERT_PANEL_SHIFT 0 +# define RADEON_VERT_STRETCH_RATIO_MASK 0x3ff +# define RADEON_VERT_STRETCH_RATIO_SHIFT 11 +# define RADEON_VERT_STRETCH_RATIO_MAX 1024 +# define RADEON_VERT_STRETCH_ENABLE (1 << 24) +# define RADEON_VERT_STRETCH_LINEREP (0 << 25) +# define RADEON_VERT_STRETCH_BLEND (1 << 25) +# define RADEON_VERT_AUTO_RATIO_EN (1 << 26) +# define RADEON_VERT_STRETCH_RESERVED 0xf8e00000 + +#define RADEON_GEN_INT_CNTL 0x0040 +#define RADEON_GEN_INT_STATUS 0x0044 +# define RADEON_VSYNC_INT_AK (1 << 2) +# define RADEON_VSYNC_INT (1 << 2) +#define RADEON_RBBM_SOFT_RESET 0x00f0 +# define RADEON_SOFT_RESET_CP (1 << 0) +# define RADEON_SOFT_RESET_HI (1 << 1) +# define RADEON_SOFT_RESET_SE (1 << 2) +# define RADEON_SOFT_RESET_RE (1 << 3) +# define RADEON_SOFT_RESET_PP (1 << 4) +# define RADEON_SOFT_RESET_E2 (1 << 5) +# define RADEON_SOFT_RESET_RB (1 << 6) +# define RADEON_SOFT_RESET_HDP (1 << 7) +#define RADEON_GENENB 0x03c3 /* VGA */ +#define RADEON_GENFC_RD 0x03ca /* VGA */ +#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */ +#define RADEON_GENMO_RD 0x03cc /* VGA */ +#define RADEON_GENMO_WT 0x03c2 /* VGA */ +#define RADEON_GENS0 0x03c2 /* VGA */ +#define RADEON_GENS1 0x03da /* VGA, 0x03ba */ +#define RADEON_GPIO_MONID 0x0068 +# define RADEON_GPIO_MONID_A_0 (1 << 0) +# define RADEON_GPIO_MONID_A_1 (1 << 1) +# define RADEON_GPIO_MONID_A_2 (1 << 2) +# define RADEON_GPIO_MONID_A_3 (1 << 3) +# define RADEON_GPIO_MONID_Y_0 (1 << 8) +# define RADEON_GPIO_MONID_Y_1 (1 << 9) +# define RADEON_GPIO_MONID_Y_2 (1 << 10) +# define RADEON_GPIO_MONID_Y_3 (1 << 11) +# define RADEON_GPIO_MONID_EN_0 (1 << 16) +# define RADEON_GPIO_MONID_EN_1 (1 << 17) +# define RADEON_GPIO_MONID_EN_2 (1 << 18) +# define RADEON_GPIO_MONID_EN_3 (1 << 19) +# define RADEON_GPIO_MONID_MASK_0 (1 << 24) +# define RADEON_GPIO_MONID_MASK_1 (1 << 25) +# define RADEON_GPIO_MONID_MASK_2 (1 << 26) +# define RADEON_GPIO_MONID_MASK_3 (1 << 27) +#define RADEON_GPIO_MONIDB 0x006c +#define RADEON_GRPH8_DATA 0x03cf /* VGA */ +#define RADEON_GRPH8_IDX 0x03ce /* VGA */ +#define RADEON_GUI_DEBUG0 0x16a0 +#define RADEON_GUI_DEBUG1 0x16a4 +#define RADEON_GUI_DEBUG2 0x16a8 +#define RADEON_GUI_DEBUG3 0x16ac +#define RADEON_GUI_DEBUG4 0x16b0 +#define RADEON_GUI_DEBUG5 0x16b4 +#define RADEON_GUI_DEBUG6 0x16b8 +#define RADEON_GUI_SCRATCH_REG0 0x15e0 +#define RADEON_GUI_SCRATCH_REG1 0x15e4 +#define RADEON_GUI_SCRATCH_REG2 0x15e8 +#define RADEON_GUI_SCRATCH_REG3 0x15ec +#define RADEON_GUI_SCRATCH_REG4 0x15f0 +#define RADEON_GUI_SCRATCH_REG5 0x15f4 +#define RADEON_HEADER 0x0f0e /* PCI */ +#define RADEON_HOST_DATA0 0x17c0 +#define RADEON_HOST_DATA1 0x17c4 +#define RADEON_HOST_DATA2 0x17c8 +#define RADEON_HOST_DATA3 0x17cc +#define RADEON_HOST_DATA4 0x17d0 +#define RADEON_HOST_DATA5 0x17d4 +#define RADEON_HOST_DATA6 0x17d8 +#define RADEON_HOST_DATA7 0x17dc +#define RADEON_HOST_DATA_LAST 0x17e0 +#define RADEON_HOST_PATH_CNTL 0x0130 +#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */ +#define RADEON_HW_DEBUG 0x0128 +#define RADEON_HW_DEBUG2 0x011c + +#define RADEON_I2C_CNTL_1 0x0094 /* ? */ +#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */ +#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */ +#define RADEON_IO_BASE 0x0f14 /* PCI */ + +#define RADEON_LATENCY 0x0f0d /* PCI */ +#define RADEON_LEAD_BRES_DEC 0x1608 +#define RADEON_LEAD_BRES_LNTH 0x161c +#define RADEON_LEAD_BRES_LNTH_SUB 0x1624 +#define RADEON_LVDS_GEN_CNTL 0x02d0 +# define RADEON_LVDS_ON (1 << 0) +# define RADEON_LVDS_BLON (1 << 19) +# define RADEON_LVDS_SEL_CRTC2 (1 << 23) +# define RADEON_HSYNC_DELAY_SHIFT 28 +# define RADEON_HSYNC_DELAY_MASK (0xf << 28) + +#define RADEON_MAX_LATENCY 0x0f3f /* PCI */ +#define RADEON_MC_AGP_LOCATION 0x014c +#define RADEON_MC_FB_LOCATION 0x0148 +#define RADEON_MCLK_CNTL 0x0012 /* PLL */ +# define RADEON_FORCE_GCP (1 << 16) +# define RADEON_FORCE_PIPE3D_CP (1 << 17) +# define RADEON_FORCE_RCP (1 << 18) +#define RADEON_MDGPIO_A_REG 0x01ac +#define RADEON_MDGPIO_EN_REG 0x01b0 +#define RADEON_MDGPIO_MASK 0x0198 +#define RADEON_MDGPIO_Y_REG 0x01b4 +#define RADEON_MEM_ADDR_CONFIG 0x0148 +#define RADEON_MEM_BASE 0x0f10 /* PCI */ +#define RADEON_MEM_CNTL 0x0140 +#define RADEON_MEM_INIT_LAT_TIMER 0x0154 +#define RADEON_MEM_INTF_CNTL 0x014c +#define RADEON_MEM_SDRAM_MODE_REG 0x0158 +#define RADEON_MEM_STR_CNTL 0x0150 +#define RADEON_MEM_VGA_RP_SEL 0x003c +#define RADEON_MEM_VGA_WP_SEL 0x0038 +#define RADEON_MIN_GRANT 0x0f3e /* PCI */ +#define RADEON_MM_DATA 0x0004 +#define RADEON_MM_INDEX 0x0000 +#define RADEON_MPLL_CNTL 0x000e /* PLL */ +#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */ +#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */ + +#define RADEON_N_VIF_COUNT 0x0248 + +#define RADEON_OV0_SCALE_CNTL 0x0420 /* ? */ +#define RADEON_OVR_CLR 0x0230 +#define RADEON_OVR_WID_LEFT_RIGHT 0x0234 +#define RADEON_OVR_WID_TOP_BOTTOM 0x0238 + +/* first overlay unit (there is only one) */ + +#define RADEON_OV0_Y_X_START 0x0400 +#define RADEON_OV0_Y_X_END 0x0404 +#define RADEON_OV0_EXCLUSIVE_HORZ 0x0408 +# define RADEON_EXCL_HORZ_START_MASK 0x000000ff +# define RADEON_EXCL_HORZ_END_MASK 0x0000ff00 +# define RADEON_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000 +# define RADEON_EXCL_HORZ_EXCLUSIVE_EN 0x80000000 +#define RADEON_OV0_EXCLUSIVE_VERT 0x040C +# define RADEON_EXCL_VERT_START_MASK 0x000003ff +# define RADEON_EXCL_VERT_END_MASK 0x03ff0000 +#define RADEON_OV0_REG_LOAD_CNTL 0x0410 +# define RADEON_REG_LD_CTL_LOCK 0x00000001L +# define RADEON_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L +# define RADEON_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L +# define RADEON_REG_LD_CTL_LOCK_READBACK 0x00000008L +#define RADEON_OV0_SCALE_CNTL 0x0420 +# define RADEON_SCALER_PIX_EXPAND 0x00000001L +# define RADEON_SCALER_Y2R_TEMP 0x00000002L +# define RADEON_SCALER_HORZ_PICK_NEAREST 0x00000003L +# define RADEON_SCALER_VERT_PICK_NEAREST 0x00000004L +# define RADEON_SCALER_SIGNED_UV 0x00000010L +# define RADEON_SCALER_GAMMA_SEL_MASK 0x00000060L +# define RADEON_SCALER_GAMMA_SEL_BRIGHT 0x00000000L +# define RADEON_SCALER_GAMMA_SEL_G22 0x00000020L +# define RADEON_SCALER_GAMMA_SEL_G18 0x00000040L +# define RADEON_SCALER_GAMMA_SEL_G14 0x00000060L +# define RADEON_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L +# define RADEON_SCALER_SURFAC_FORMAT 0x00000f00L +# define RADEON_SCALER_SOURCE_15BPP 0x00000300L +# define RADEON_SCALER_SOURCE_16BPP 0x00000400L +# define RADEON_SCALER_SOURCE_32BPP 0x00000600L +# define RADEON_SCALER_SOURCE_YUV9 0x00000900L +# define RADEON_SCALER_SOURCE_YUV12 0x00000A00L +# define RADEON_SCALER_SOURCE_VYUY422 0x00000B00L +# define RADEON_SCALER_SOURCE_YVYU422 0x00000C00L +# define RADEON_SCALER_SMART_SWITCH 0x00008000L +# define RADEON_SCALER_BURST_PER_PLANE 0x00ff0000L +# define RADEON_SCALER_DOUBLE_BUFFER 0x01000000L +# define RADEON_SCALER_DIS_LIMIT 0x08000000L +# define RADEON_SCALER_PRG_LOAD_START 0x10000000L +# define RADEON_SCALER_INT_EMU 0x20000000L +# define RADEON_SCALER_ENABLE 0x40000000L +# define RADEON_SCALER_SOFT_RESET 0x80000000L +#define RADEON_OV0_V_INC 0x0424 +#define RADEON_OV0_P1_V_ACCUM_INIT 0x0428 +# define RADEON_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L +# define RADEON_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L +#define RADEON_OV0_P23_V_ACCUM_INIT 0x042C +#define RADEON_OV0_P1_BLANK_LINES_AT_TOP 0x0430 +# define RADEON_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL +# define RADEON_P1_ACTIVE_LINES_M1 0x0fff0000L +#define RADEON_OV0_P23_BLANK_LINES_AT_TOP 0x0434 +# define RADEON_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL +# define RADEON_P23_ACTIVE_LINES_M1 0x07ff0000L +#define RADEON_OV0_VID_BUF0_BASE_ADRS 0x0440 +# define RADEON_VIF_BUF0_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF0_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF1_BASE_ADRS 0x0444 +# define RADEON_VIF_BUF1_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF1_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF2_BASE_ADRS 0x0448 +# define RADEON_VIF_BUF2_PITCH_SEL 0x00000001L +# define RADEON_VIF_BUF2_TILE_ADRS 0x00000002L +# define RADEON_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L +# define RADEON_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L +#define RADEON_OV0_VID_BUF3_BASE_ADRS 0x044C +#define RADEON_OV0_VID_BUF4_BASE_ADRS 0x0450 +#define RADEON_OV0_VID_BUF5_BASE_ADRS 0x0454 +#define RADEON_OV0_VID_BUF_PITCH0_VALUE 0x0460 +#define RADEON_OV0_VID_BUF_PITCH1_VALUE 0x0464 +#define RADEON_OV0_AUTO_FLIP_CNTL 0x0470 +#define RADEON_OV0_DEINTERLACE_PATTERN 0x0474 +#define RADEON_OV0_H_INC 0x0480 +#define RADEON_OV0_STEP_BY 0x0484 +#define RADEON_OV0_P1_H_ACCUM_INIT 0x0488 +#define RADEON_OV0_P23_H_ACCUM_INIT 0x048C +#define RADEON_OV0_P1_X_START_END 0x0494 +#define RADEON_OV0_P2_X_START_END 0x0498 +#define RADEON_OV0_P3_X_START_END 0x049C +#define RADEON_OV0_FILTER_CNTL 0x04A0 +#define RADEON_OV0_FOUR_TAP_COEF_0 0x04B0 +#define RADEON_OV0_FOUR_TAP_COEF_1 0x04B4 +#define RADEON_OV0_FOUR_TAP_COEF_2 0x04B8 +#define RADEON_OV0_FOUR_TAP_COEF_3 0x04BC +#define RADEON_OV0_FOUR_TAP_COEF_4 0x04C0 +#define RADEON_OV0_COLOUR_CNTL 0x04E0 +#define RADEON_OV0_VIDEO_KEY_CLR 0x04E4 +#define RADEON_OV0_VIDEO_KEY_MSK 0x04E8 +#define RADEON_OV0_GRAPHICS_KEY_CLR 0x04EC +#define RADEON_OV0_GRAPHICS_KEY_MSK 0x04F0 +#define RADEON_OV0_KEY_CNTL 0x04F4 +# define RADEON_VIDEO_KEY_FN_MASK 0x00000007L +# define RADEON_VIDEO_KEY_FN_FALSE 0x00000000L +# define RADEON_VIDEO_KEY_FN_TRUE 0x00000001L +# define RADEON_VIDEO_KEY_FN_EQ 0x00000004L +# define RADEON_VIDEO_KEY_FN_NE 0x00000005L +# define RADEON_GRAPHIC_KEY_FN_MASK 0x00000070L +# define RADEON_GRAPHIC_KEY_FN_FALSE 0x00000000L +# define RADEON_GRAPHIC_KEY_FN_TRUE 0x00000010L +# define RADEON_GRAPHIC_KEY_FN_EQ 0x00000040L +# define RADEON_GRAPHIC_KEY_FN_NE 0x00000050L +# define RADEON_CMP_MIX_MASK 0x00000100L +# define RADEON_CMP_MIX_OR 0x00000000L +# define RADEON_CMP_MIX_AND 0x00000100L +#define RADEON_OV0_TEST 0x04F8 + +#define RADEON_PALETTE_DATA 0x00b4 +#define RADEON_PALETTE_30_DATA 0x00b8 +#define RADEON_PALETTE_INDEX 0x00b0 +#define RADEON_PCI_GART_PAGE 0x017c +#define RADEON_PLANE_3D_MASK_C 0x1d44 +#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */ +#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */ +#define RADEON_PMI_DATA 0x0f63 /* PCI */ +#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ +#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */ +#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */ +#define RADEON_PMI_REGISTER 0x0f5c /* PCI */ +#define RADEON_PPLL_CNTL 0x0002 /* PLL */ +# define RADEON_PPLL_RESET (1 << 0) +# define RADEON_PPLL_SLEEP (1 << 1) +# define RADEON_PPLL_ATOMIC_UPDATE_EN (1 << 16) +# define RADEON_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) +# define RADEON_PPLL_ATOMIC_UPDATE_VSYNC (1 << 18) +#define RADEON_PPLL_DIV_0 0x0004 /* PLL */ +#define RADEON_PPLL_DIV_1 0x0005 /* PLL */ +#define RADEON_PPLL_DIV_2 0x0006 /* PLL */ +#define RADEON_PPLL_DIV_3 0x0007 /* PLL */ +# define RADEON_PPLL_FB3_DIV_MASK 0x07ff +# define RADEON_PPLL_POST3_DIV_MASK 0x00070000 +#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */ +# define RADEON_PPLL_REF_DIV_MASK 0x03ff +# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ +# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ +#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ +#define RADEON_RBBM_SOFT_RESET 0x00f0 +#define RADEON_RBBM_STATUS 0x0e40 +# define RADEON_RBBM_FIFOCNT_MASK 0x007f +# define RADEON_RBBM_ACTIVE (1 << 31) +#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c +# define RADEON_RB2D_DC_FLUSH_ALL 0xf +# define RADEON_RB2D_DC_BUSY (1 << 31) +#define RADEON_RB2D_DSTCACHE_MODE 0x3428 +#define RADEON_REG_BASE 0x0f18 /* PCI */ +#define RADEON_REGPROG_INF 0x0f09 /* PCI */ +#define RADEON_REVISION_ID 0x0f08 /* PCI */ + +#define RADEON_SC_BOTTOM 0x164c +#define RADEON_SC_BOTTOM_RIGHT 0x16f0 +#define RADEON_SC_BOTTOM_RIGHT_C 0x1c8c +#define RADEON_SC_LEFT 0x1640 +#define RADEON_SC_RIGHT 0x1644 +#define RADEON_SC_TOP 0x1648 +#define RADEON_SC_TOP_LEFT 0x16ec +#define RADEON_SC_TOP_LEFT_C 0x1c88 +#define RADEON_SDRAM_MODE_REG 0x0158 +#define RADEON_SEQ8_DATA 0x03c5 /* VGA */ +#define RADEON_SEQ8_IDX 0x03c4 /* VGA */ +#define RADEON_SNAPSHOT_F_COUNT 0x0244 +#define RADEON_SNAPSHOT_VH_COUNTS 0x0240 +#define RADEON_SNAPSHOT_VIF_COUNT 0x024c +#define RADEON_SRC_OFFSET 0x15ac +#define RADEON_SRC_PITCH 0x15b0 +#define RADEON_SRC_PITCH_OFFSET 0x1428 +#define RADEON_SRC_SC_BOTTOM 0x165c +#define RADEON_SRC_SC_BOTTOM_RIGHT 0x16f4 +#define RADEON_SRC_SC_RIGHT 0x1654 +#define RADEON_SRC_X 0x1414 +#define RADEON_SRC_X_Y 0x1590 +#define RADEON_SRC_Y 0x1418 +#define RADEON_SRC_Y_X 0x1434 +#define RADEON_STATUS 0x0f06 /* PCI */ +#define RADEON_SUBPIC_CNTL 0x0540 /* ? */ +#define RADEON_SUB_CLASS 0x0f0a /* PCI */ +#define RADEON_SURFACE_DELAY 0x0b00 +#define RADEON_SURFACE0_INFO 0x0b0c +#define RADEON_SURFACE0_LOWER_BOUND 0x0b04 +#define RADEON_SURFACE0_UPPER_BOUND 0x0b08 +#define RADEON_SURFACE1_INFO 0x0b1c +#define RADEON_SURFACE1_LOWER_BOUND 0x0b14 +#define RADEON_SURFACE1_UPPER_BOUND 0x0b18 +#define RADEON_SURFACE2_INFO 0x0b2c +#define RADEON_SURFACE2_LOWER_BOUND 0x0b24 +#define RADEON_SURFACE2_UPPER_BOUND 0x0b28 +#define RADEON_SURFACE3_INFO 0x0b3c +#define RADEON_SURFACE3_LOWER_BOUND 0x0b34 +#define RADEON_SURFACE3_UPPER_BOUND 0x0b38 +#define RADEON_SW_SEMAPHORE 0x013c + +#define RADEON_TEST_DEBUG_CNTL 0x0120 +#define RADEON_TEST_DEBUG_MUX 0x0124 +#define RADEON_TEST_DEBUG_OUT 0x012c +#define RADEON_TMDS_CRC 0x02a0 +#define RADEON_TRAIL_BRES_DEC 0x1614 +#define RADEON_TRAIL_BRES_ERR 0x160c +#define RADEON_TRAIL_BRES_INC 0x1610 +#define RADEON_TRAIL_X 0x1618 +#define RADEON_TRAIL_X_SUB 0x1620 + +#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */ +#define RADEON_VENDOR_ID 0x0f00 /* PCI */ +#define RADEON_VGA_DDA_CONFIG 0x02e8 +#define RADEON_VGA_DDA_ON_OFF 0x02ec +#define RADEON_VID_BUFFER_CONTROL 0x0900 +#define RADEON_VIDEOMUX_CNTL 0x0190 +#define RADEON_VIPH_CONTROL 0x0c40 /* ? */ + +#define RADEON_WAIT_UNTIL 0x1720 + +#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */ +#define RADEON_XCLK_CNTL 0x000d /* PLL */ +#define RADEON_XDLL_CNTL 0x000c /* PLL */ +#define RADEON_XPLL_CNTL 0x000b /* PLL */ + + /* Registers for CCE and Microcode Engine */ +#define RADEON_CP_ME_RAM_ADDR 0x07d4 +#define RADEON_CP_ME_RAM_RADDR 0x07d8 +#define RADEON_CP_ME_RAM_DATAH 0x07dc +#define RADEON_CP_ME_RAM_DATAL 0x07e0 + +#define RADEON_CP_RB_BASE 0x0700 +#define RADEON_CP_RB_CNTL 0x0704 +#define RADEON_CP_RB_RPTR_ADDR 0x070c +#define RADEON_CP_RB_RPTR 0x0710 +#define RADEON_CP_RB_WPTR 0x0714 +# define RADEON_PM4_BUFFER_DL_DONE (1 << 31) + +#define RADEON_CP_IB_BASE 0x0738 +#define RADEON_CP_IB_BUFSZ 0x073c + +#define RADEON_CP_CSQ_CNTL 0x0740 +# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28) +# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28) +# define RADEON_CSQ_PRIBM_INDDIS (2 << 28) +# define RADEON_CSQ_PRIPIO_INDBM (3 << 28) +# define RADEON_CSQ_PRIBM_INDBM (4 << 28) +# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28) +#define RADEON_CP_RB_WPTR_DELAY 0x0718 +# define RADEON_PRE_WRITE_TIMER_SHIFT 0 +# define RADEON_PRE_WRITE_LIMIT_SHIFT 23 + +#define RADEON_AIC_CNTL 0x01d0 +# define RADEON_PCIGART_TRANSLATE_EN (1 << 0) + +#define RADEON_PM4_VC_FPU_SETUP 0x071c +# define RADEON_FRONT_DIR_CW (0 << 0) +# define RADEON_FRONT_DIR_CCW (1 << 0) +# define RADEON_FRONT_DIR_MASK (1 << 0) +# define RADEON_BACKFACE_CULL (0 << 1) +# define RADEON_BACKFACE_POINTS (1 << 1) +# define RADEON_BACKFACE_LINES (2 << 1) +# define RADEON_BACKFACE_SOLID (3 << 1) +# define RADEON_BACKFACE_MASK (3 << 1) +# define RADEON_FRONTFACE_CULL (0 << 3) +# define RADEON_FRONTFACE_POINTS (1 << 3) +# define RADEON_FRONTFACE_LINES (2 << 3) +# define RADEON_FRONTFACE_SOLID (3 << 3) +# define RADEON_FRONTFACE_MASK (3 << 3) +# define RADEON_FPU_COLOR_SOLID (0 << 5) +# define RADEON_FPU_COLOR_FLAT (1 << 5) +# define RADEON_FPU_COLOR_GOURAUD (2 << 5) +# define RADEON_FPU_COLOR_GOURAUD2 (3 << 5) +# define RADEON_FPU_COLOR_MASK (3 << 5) +# define RADEON_FPU_SUB_PIX_2BITS (0 << 7) +# define RADEON_FPU_SUB_PIX_4BITS (1 << 7) +# define RADEON_FPU_MODE_2D (0 << 8) +# define RADEON_FPU_MODE_3D (1 << 8) +# define RADEON_TRAP_BITS_DISABLE (1 << 9) +# define RADEON_EDGE_ANTIALIAS (1 << 10) +# define RADEON_SUPERSAMPLE (1 << 11) +# define RADEON_XFACTOR_2 (0 << 12) +# define RADEON_XFACTOR_4 (1 << 12) +# define RADEON_YFACTOR_2 (0 << 13) +# define RADEON_YFACTOR_4 (1 << 13) +# define RADEON_FLAT_SHADE_VERTEX_D3D (0 << 14) +# define RADEON_FLAT_SHADE_VERTEX_OGL (1 << 14) +# define RADEON_FPU_ROUND_TRUNCATE (0 << 15) +# define RADEON_FPU_ROUND_NEAREST (1 << 15) +# define RADEON_WM_SEL_8DW (0 << 16) +# define RADEON_WM_SEL_16DW (1 << 16) +# define RADEON_WM_SEL_32DW (2 << 16) +#define RADEON_PM4_VC_DEBUG_CONFIG 0x07a4 +#define RADEON_PM4_VC_STAT 0x07a8 +#define RADEON_PM4_VC_TIMESTAMP0 0x07b0 +#define RADEON_PM4_VC_TIMESTAMP1 0x07b4 +#define RADEON_PM4_STAT 0x07b8 +# define RADEON_PM4_FIFOCNT_MASK 0x0fff +# define RADEON_PM4_BUSY (1 << 16) +# define RADEON_PM4_GUI_ACTIVE (1 << 31) +#define RADEON_PM4_BUFFER_ADDR 0x07f0 +#define RADEON_CP_ME_CNTL 0x07d0 +# define RADEON_CP_ME_FREERUN (1 << 30) +#define RADEON_PM4_FIFO_DATA_EVEN 0x1000 +#define RADEON_PM4_FIFO_DATA_ODD 0x1004 + +#define RADEON_SCALE_3D_CNTL 0x1a00 +# define RADEON_SCALE_DITHER_ERR_DIFF (0 << 1) +# define RADEON_SCALE_DITHER_TABLE (1 << 1) +# define RADEON_TEX_CACHE_SIZE_FULL (0 << 2) +# define RADEON_TEX_CACHE_SIZE_HALF (1 << 2) +# define RADEON_DITHER_INIT_CURR (0 << 3) +# define RADEON_DITHER_INIT_RESET (1 << 3) +# define RADEON_ROUND_24BIT (1 << 4) +# define RADEON_TEX_CACHE_DISABLE (1 << 5) +# define RADEON_SCALE_3D_NOOP (0 << 6) +# define RADEON_SCALE_3D_SCALE (1 << 6) +# define RADEON_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define RADEON_SCALE_PIX_BLEND (0 << 8) +# define RADEON_SCALE_PIX_REPLICATE (1 << 8) +# define RADEON_TEX_CACHE_SPLIT (1 << 9) +# define RADEON_APPLE_YUV_MODE (1 << 10) +# define RADEON_TEX_CACHE_PALLETE_MODE (1 << 11) +# define RADEON_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define RADEON_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define RADEON_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define RADEON_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define RADEON_FOG_TABLE (1 << 14) +# define RADEON_SIGNED_DST_CLAMP (1 << 15) +# define RADEON_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define RADEON_ALPHA_BLEND_SRC_ONE (1 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define RADEON_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +# define RADEON_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) +# define RADEON_ALPHA_BLEND_SRC_SAT (10 << 16) +# define RADEON_ALPHA_BLEND_SRC_BLEND (11 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVBLEND (12 << 16) +# define RADEON_ALPHA_BLEND_DST_ZERO (0 << 20) +# define RADEON_ALPHA_BLEND_DST_ONE (1 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define RADEON_ALPHA_BLEND_DST_DSTALPHA (6 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) +# define RADEON_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) +# define RADEON_ALPHA_TEST_NEVER (0 << 24) +# define RADEON_ALPHA_TEST_LESS (1 << 24) +# define RADEON_ALPHA_TEST_LESSEQUAL (2 << 24) +# define RADEON_ALPHA_TEST_EQUAL (3 << 24) +# define RADEON_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define RADEON_ALPHA_TEST_GREATER (5 << 24) +# define RADEON_ALPHA_TEST_NEQUAL (6 << 24) +# define RADEON_ALPHA_TEST_ALWAYS (7 << 24) +# define RADEON_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) +# define RADEON_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) +# define RADEON_COMPOSITE_SHADOW (1 << 29) +# define RADEON_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) +# define RADEON_TEX_CACHE_LINE_SIZE_8QW (0 << 31) +# define RADEON_TEX_CACHE_LINE_SIZE_4QW (1 << 31) +#define RADEON_SCALE_3D_DATATYPE 0x1a20 + +#define RADEON_SETUP_CNTL 0x1bc4 +# define RADEON_DONT_START_TRIANGLE (1 << 0) +# define RADEON_Z_BIAS (0 << 1) +# define RADEON_DONT_START_ANY_ON (1 << 2) +# define RADEON_COLOR_SOLID_COLOR (0 << 3) +# define RADEON_COLOR_FLAT_VERT_1 (1 << 3) +# define RADEON_COLOR_FLAT_VERT_2 (2 << 3) +# define RADEON_COLOR_FLAT_VERT_3 (3 << 3) +# define RADEON_COLOR_GOURAUD (4 << 3) +# define RADEON_PRIM_TYPE_TRI (0 << 7) +# define RADEON_PRIM_TYPE_LINE (1 << 7) +# define RADEON_PRIM_TYPE_POINT (2 << 7) +# define RADEON_PRIM_TYPE_POLY_EDGE (3 << 7) +# define RADEON_TEXTURE_ST_MULT_W (0 << 9) +# define RADEON_TEXTURE_ST_DIRECT (1 << 9) +# define RADEON_STARTING_VERTEX_1 (1 << 14) +# define RADEON_STARTING_VERTEX_2 (2 << 14) +# define RADEON_STARTING_VERTEX_3 (3 << 14) +# define RADEON_ENDING_VERTEX_1 (1 << 16) +# define RADEON_ENDING_VERTEX_2 (2 << 16) +# define RADEON_ENDING_VERTEX_3 (3 << 16) +# define RADEON_SU_POLY_LINE_LAST (0 << 18) +# define RADEON_SU_POLY_LINE_NOT_LAST (1 << 18) +# define RADEON_SUB_PIX_2BITS (0 << 19) +# define RADEON_SUB_PIX_4BITS (1 << 19) +# define RADEON_SET_UP_CONTINUE (1 << 31) + +#define RADEON_WINDOW_XY_OFFSET 0x1bcc +# define RADEON_WINDOW_Y_SHIFT 4 +# define RADEON_WINDOW_X_SHIFT 20 + +#define RADEON_Z_OFFSET_C 0x1c90 +#define RADEON_Z_PITCH_C 0x1c94 +#define RADEON_Z_STEN_CNTL_C 0x1c98 +# define RADEON_Z_PIX_WIDTH_16 (0 << 1) +# define RADEON_Z_PIX_WIDTH_24 (1 << 1) +# define RADEON_Z_PIX_WIDTH_32 (2 << 1) +# define RADEON_Z_PIX_WIDTH_MASK (3 << 1) +# define RADEON_Z_TEST_NEVER (0 << 4) +# define RADEON_Z_TEST_LESS (1 << 4) +# define RADEON_Z_TEST_LESSEQUAL (2 << 4) +# define RADEON_Z_TEST_EQUAL (3 << 4) +# define RADEON_Z_TEST_GREATEREQUAL (4 << 4) +# define RADEON_Z_TEST_GREATER (5 << 4) +# define RADEON_Z_TEST_NEQUAL (6 << 4) +# define RADEON_Z_TEST_ALWAYS (7 << 4) +# define RADEON_Z_TEST_MASK (7 << 4) +# define RADEON_STENCIL_TEST_NEVER (0 << 12) +# define RADEON_STENCIL_TEST_LESS (1 << 12) +# define RADEON_STENCIL_TEST_LESSEQUAL (2 << 12) +# define RADEON_STENCIL_TEST_EQUAL (3 << 12) +# define RADEON_STENCIL_TEST_GREATEREQUAL (4 << 12) +# define RADEON_STENCIL_TEST_GREATER (5 << 12) +# define RADEON_STENCIL_TEST_NEQUAL (6 << 12) +# define RADEON_STENCIL_TEST_ALWAYS (7 << 12) +# define RADEON_STENCIL_S_FAIL_KEEP (0 << 16) +# define RADEON_STENCIL_S_FAIL_ZERO (1 << 16) +# define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16) +# define RADEON_STENCIL_S_FAIL_INC (3 << 16) +# define RADEON_STENCIL_S_FAIL_DEC (4 << 16) +# define RADEON_STENCIL_S_FAIL_INV (5 << 16) +# define RADEON_STENCIL_ZPASS_KEEP (0 << 20) +# define RADEON_STENCIL_ZPASS_ZERO (1 << 20) +# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20) +# define RADEON_STENCIL_ZPASS_INC (3 << 20) +# define RADEON_STENCIL_ZPASS_DEC (4 << 20) +# define RADEON_STENCIL_ZPASS_INV (5 << 20) +# define RADEON_STENCIL_ZFAIL_KEEP (0 << 24) +# define RADEON_STENCIL_ZFAIL_ZERO (1 << 24) +# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24) +# define RADEON_STENCIL_ZFAIL_INC (3 << 24) +# define RADEON_STENCIL_ZFAIL_DEC (4 << 24) +# define RADEON_STENCIL_ZFAIL_INV (5 << 24) +#define RADEON_TEX_CNTL_C 0x1c9c +# define RADEON_Z_ENABLE (1 << 0) +# define RADEON_Z_WRITE_ENABLE (1 << 1) +# define RADEON_STENCIL_ENABLE (1 << 3) +# define RADEON_SHADE_ENABLE (0 << 4) +# define RADEON_TEXMAP_ENABLE (1 << 4) +# define RADEON_SEC_TEXMAP_ENABLE (1 << 5) +# define RADEON_FOG_ENABLE (1 << 7) +# define RADEON_DITHER_ENABLE (1 << 8) +# define RADEON_ALPHA_ENABLE (1 << 9) +# define RADEON_ALPHA_TEST_ENABLE (1 << 10) +# define RADEON_SPEC_LIGHT_ENABLE (1 << 11) +# define RADEON_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define RADEON_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define RADEON_ALPHA_IN_TEX_LSB_A (1 << 13) +# define RADEON_LIGHT_DIS (0 << 14) +# define RADEON_LIGHT_COPY (1 << 14) +# define RADEON_LIGHT_MODULATE (2 << 14) +# define RADEON_LIGHT_ADD (3 << 14) +# define RADEON_LIGHT_BLEND_CONSTANT (4 << 14) +# define RADEON_LIGHT_BLEND_TEXTURE (5 << 14) +# define RADEON_LIGHT_BLEND_VERTEX (6 << 14) +# define RADEON_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define RADEON_ALPHA_LIGHT_DIS (0 << 18) +# define RADEON_ALPHA_LIGHT_COPY (1 << 18) +# define RADEON_ALPHA_LIGHT_MODULATE (2 << 18) +# define RADEON_ALPHA_LIGHT_ADD (3 << 18) +# define RADEON_ANTI_ALIAS (1 << 21) +# define RADEON_TEX_CACHE_FLUSH (1 << 23) +# define RADEON_LOD_BIAS_SHIFT 24 +#define RADEON_MISC_3D_STATE_CNTL_REG 0x1ca0 +# define RADEON_REF_ALPHA_MASK 0xff +# define RADEON_MISC_SCALE_3D_NOOP (0 << 8) +# define RADEON_MISC_SCALE_3D_SCALE (1 << 8) +# define RADEON_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define RADEON_MISC_SCALE_PIX_BLEND (0 << 10) +# define RADEON_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define RADEON_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define RADEON_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define RADEON_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define RADEON_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define RADEON_FOG_VERTEX (0 << 14) +# define RADEON_FOG_TABLE (1 << 14) +# define RADEON_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define RADEON_ALPHA_BLEND_SRC_ONE (1 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define RADEON_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) +# define RADEON_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) +# define RADEON_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) +# define RADEON_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) +# define RADEON_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) +# define RADEON_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) +# define RADEON_ALPHA_BLEND_SRC_MASK (15 << 16) +# define RADEON_ALPHA_BLEND_DST_ZERO (0 << 20) +# define RADEON_ALPHA_BLEND_DST_ONE (1 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define RADEON_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define RADEON_ALPHA_BLEND_DST_DESTALPHA (6 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) +# define RADEON_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) +# define RADEON_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) +# define RADEON_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) +# define RADEON_ALPHA_BLEND_DST_MASK (15 << 20) +# define RADEON_ALPHA_TEST_NEVER (0 << 24) +# define RADEON_ALPHA_TEST_LESS (1 << 24) +# define RADEON_ALPHA_TEST_LESSEQUAL (2 << 24) +# define RADEON_ALPHA_TEST_EQUAL (3 << 24) +# define RADEON_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define RADEON_ALPHA_TEST_GREATER (5 << 24) +# define RADEON_ALPHA_TEST_NEQUAL (6 << 24) +# define RADEON_ALPHA_TEST_ALWAYS (7 << 24) +# define RADEON_ALPHA_TEST_MASK (7 << 24) +#define RADEON_TEXTURE_CLR_CMP_CLR_C 0x1ca4 +#define RADEON_TEXTURE_CLR_CMP_MSK_C 0x1ca8 +#define RADEON_FOG_COLOR_C 0x1cac +# define RADEON_FOG_BLUE_SHIFT 0 +# define RADEON_FOG_GREEN_SHIFT 8 +# define RADEON_FOG_RED_SHIFT 16 +#define RADEON_PRIM_TEX_CNTL_C 0x1cb0 +# define RADEON_MIN_BLEND_NEAREST (0 << 1) +# define RADEON_MIN_BLEND_LINEAR (1 << 1) +# define RADEON_MIN_BLEND_MIPNEAREST (2 << 1) +# define RADEON_MIN_BLEND_MIPLINEAR (3 << 1) +# define RADEON_MIN_BLEND_LINEARMIPNEAREST (4 << 1) +# define RADEON_MIN_BLEND_LINEARMIPLINEAR (5 << 1) +# define RADEON_MIN_BLEND_MASK (7 << 1) +# define RADEON_MAG_BLEND_NEAREST (0 << 4) +# define RADEON_MAG_BLEND_LINEAR (1 << 4) +# define RADEON_MAG_BLEND_MASK (7 << 4) +# define RADEON_MIP_MAP_DISABLE (1 << 7) +# define RADEON_TEX_CLAMP_S_WRAP (0 << 8) +# define RADEON_TEX_CLAMP_S_MIRROR (1 << 8) +# define RADEON_TEX_CLAMP_S_CLAMP (2 << 8) +# define RADEON_TEX_CLAMP_S_BORDER_COLOR (3 << 8) +# define RADEON_TEX_CLAMP_S_MASK (3 << 8) +# define RADEON_TEX_WRAP_S (1 << 10) +# define RADEON_TEX_CLAMP_T_WRAP (0 << 11) +# define RADEON_TEX_CLAMP_T_MIRROR (1 << 11) +# define RADEON_TEX_CLAMP_T_CLAMP (2 << 11) +# define RADEON_TEX_CLAMP_T_BORDER_COLOR (3 << 11) +# define RADEON_TEX_CLAMP_T_MASK (3 << 11) +# define RADEON_TEX_WRAP_T (1 << 13) +# define RADEON_TEX_PERSPECTIVE_DISABLE (1 << 14) +# define RADEON_DATATYPE_VQ (0 << 16) +# define RADEON_DATATYPE_CI4 (1 << 16) +# define RADEON_DATATYPE_CI8 (2 << 16) +# define RADEON_DATATYPE_ARGB1555 (3 << 16) +# define RADEON_DATATYPE_RGB565 (4 << 16) +# define RADEON_DATATYPE_RGB888 (5 << 16) +# define RADEON_DATATYPE_ARGB8888 (6 << 16) +# define RADEON_DATATYPE_RGB332 (7 << 16) +# define RADEON_DATATYPE_Y8 (8 << 16) +# define RADEON_DATATYPE_RGB8 (9 << 16) +# define RADEON_DATATYPE_CI16 (10 << 16) +# define RADEON_DATATYPE_YUV422 (11 << 16) +# define RADEON_DATATYPE_YUV422_2 (12 << 16) +# define RADEON_DATATYPE_AYUV444 (14 << 16) +# define RADEON_DATATYPE_ARGB4444 (15 << 16) +# define RADEON_PALLETE_EITHER (0 << 20) +# define RADEON_PALLETE_1 (1 << 20) +# define RADEON_PALLETE_2 (2 << 20) +# define RADEON_PSEUDOCOLOR_DT_RGB565 (0 << 24) +# define RADEON_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) +# define RADEON_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) +#define RADEON_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 +# define RADEON_COMB_DIS (0 << 0) +# define RADEON_COMB_COPY (1 << 0) +# define RADEON_COMB_COPY_INP (2 << 0) +# define RADEON_COMB_MODULATE (3 << 0) +# define RADEON_COMB_MODULATE2X (4 << 0) +# define RADEON_COMB_MODULATE4X (5 << 0) +# define RADEON_COMB_ADD (6 << 0) +# define RADEON_COMB_ADD_SIGNED (7 << 0) +# define RADEON_COMB_BLEND_VERTEX (8 << 0) +# define RADEON_COMB_BLEND_TEXTURE (9 << 0) +# define RADEON_COMB_BLEND_CONST (10 << 0) +# define RADEON_COMB_BLEND_PREMULT (11 << 0) +# define RADEON_COMB_BLEND_PREV (12 << 0) +# define RADEON_COMB_BLEND_PREMULT_INV (13 << 0) +# define RADEON_COMB_ADD_SIGNED2X (14 << 0) +# define RADEON_COMB_BLEND_CONST_COLOR (15 << 0) +# define RADEON_COMB_MASK (15 << 0) +# define RADEON_COLOR_FACTOR_TEX (4 << 4) +# define RADEON_COLOR_FACTOR_NTEX (5 << 4) +# define RADEON_COLOR_FACTOR_ALPHA (6 << 4) +# define RADEON_COLOR_FACTOR_NALPHA (7 << 4) +# define RADEON_COLOR_FACTOR_MASK (15 << 4) +# define RADEON_INPUT_FACTOR_CONST_COLOR (2 << 10) +# define RADEON_INPUT_FACTOR_CONST_ALPHA (3 << 10) +# define RADEON_INPUT_FACTOR_INT_COLOR (4 << 10) +# define RADEON_INPUT_FACTOR_INT_ALPHA (5 << 10) +# define RADEON_INPUT_FACTOR_MASK (15 << 10) +# define RADEON_COMB_ALPHA_DIS (0 << 14) +# define RADEON_COMB_ALPHA_COPY (1 << 14) +# define RADEON_COMB_ALPHA_COPY_INP (2 << 14) +# define RADEON_COMB_ALPHA_MODULATE (3 << 14) +# define RADEON_COMB_ALPHA_MODULATE2X (4 << 14) +# define RADEON_COMB_ALPHA_MODULATE4X (5 << 14) +# define RADEON_COMB_ALPHA_ADD (6 << 14) +# define RADEON_COMB_ALPHA_ADD_SIGNED (7 << 14) +# define RADEON_COMB_ALPHA_ADD_SIGNED2X (14 << 14) +# define RADEON_COMB_ALPHA_MASK (15 << 14) +# define RADEON_ALPHA_FACTOR_TEX_ALPHA (6 << 18) +# define RADEON_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) +# define RADEON_ALPHA_FACTOR_MASK (15 << 18) +# define RADEON_INP_FACTOR_A_CONST_ALPHA (1 << 25) +# define RADEON_INP_FACTOR_A_INT_ALPHA (2 << 25) +# define RADEON_INP_FACTOR_A_MASK (7 << 25) +#define RADEON_TEX_SIZE_PITCH_C 0x1cb8 +# define RADEON_TEX_PITCH_SHIFT 0 +# define RADEON_TEX_SIZE_SHIFT 4 +# define RADEON_TEX_HEIGHT_SHIFT 8 +# define RADEON_TEX_MIN_SIZE_SHIFT 12 +# define RADEON_SEC_TEX_PITCH_SHIFT 16 +# define RADEON_SEC_TEX_SIZE_SHIFT 20 +# define RADEON_SEC_TEX_HEIGHT_SHIFT 24 +# define RADEON_SEC_TEX_MIN_SIZE_SHIFT 28 +# define RADEON_TEX_PITCH_MASK (0x0f << 0) +# define RADEON_TEX_SIZE_MASK (0x0f << 4) +# define RADEON_TEX_HEIGHT_MASK (0x0f << 8) +# define RADEON_TEX_MIN_SIZE_MASK (0x0f << 12) +# define RADEON_SEC_TEX_PITCH_MASK (0x0f << 16) +# define RADEON_SEC_TEX_SIZE_MASK (0x0f << 20) +# define RADEON_SEC_TEX_HEIGHT_MASK (0x0f << 24) +# define RADEON_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) +# define RADEON_TEX_SIZE_PITCH_SHIFT 0 +# define RADEON_SEC_TEX_SIZE_PITCH_SHIFT 16 +# define RADEON_TEX_SIZE_PITCH_MASK (0xffff << 0) +# define RADEON_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) +#define RADEON_PRIM_TEX_0_OFFSET_C 0x1cbc +#define RADEON_PRIM_TEX_1_OFFSET_C 0x1cc0 +#define RADEON_PRIM_TEX_2_OFFSET_C 0x1cc4 +#define RADEON_PRIM_TEX_3_OFFSET_C 0x1cc8 +#define RADEON_PRIM_TEX_4_OFFSET_C 0x1ccc +#define RADEON_PRIM_TEX_5_OFFSET_C 0x1cd0 +#define RADEON_PRIM_TEX_6_OFFSET_C 0x1cd4 +#define RADEON_PRIM_TEX_7_OFFSET_C 0x1cd8 +#define RADEON_PRIM_TEX_8_OFFSET_C 0x1cdc +#define RADEON_PRIM_TEX_9_OFFSET_C 0x1ce0 +#define RADEON_PRIM_TEX_10_OFFSET_C 0x1ce4 +# define RADEON_TEX_NO_TILE (0 << 30) +# define RADEON_TEX_TILED_BY_HOST (1 << 30) +# define RADEON_TEX_TILED_BY_STORAGE (2 << 30) +# define RADEON_TEX_TILED_BY_STORAGE2 (3 << 30) + +#define RADEON_SEC_TEX_CNTL_C 0x1d00 +# define RADEON_SEC_SELECT_PRIM_ST (0 << 0) +# define RADEON_SEC_SELECT_SEC_ST (1 << 0) +#define RADEON_SEC_TEX_COMBINE_CNTL_C 0x1d04 +# define RADEON_INPUT_FACTOR_PREV_COLOR (8 << 10) +# define RADEON_INPUT_FACTOR_PREV_ALPHA (9 << 10) +# define RADEON_INP_FACTOR_A_PREV_ALPHA (4 << 25) +#define RADEON_SEC_TEX_0_OFFSET_C 0x1d08 +#define RADEON_SEC_TEX_1_OFFSET_C 0x1d0c +#define RADEON_SEC_TEX_2_OFFSET_C 0x1d10 +#define RADEON_SEC_TEX_3_OFFSET_C 0x1d14 +#define RADEON_SEC_TEX_4_OFFSET_C 0x1d18 +#define RADEON_SEC_TEX_5_OFFSET_C 0x1d1c +#define RADEON_SEC_TEX_6_OFFSET_C 0x1d20 +#define RADEON_SEC_TEX_7_OFFSET_C 0x1d24 +#define RADEON_SEC_TEX_8_OFFSET_C 0x1d28 +#define RADEON_SEC_TEX_9_OFFSET_C 0x1d2c +#define RADEON_SEC_TEX_10_OFFSET_C 0x1d30 +#define RADEON_CONSTANT_COLOR_C 0x1d34 +# define RADEON_CONSTANT_BLUE_SHIFT 0 +# define RADEON_CONSTANT_GREEN_SHIFT 8 +# define RADEON_CONSTANT_RED_SHIFT 16 +# define RADEON_CONSTANT_ALPHA_SHIFT 24 +#define RADEON_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 +# define RADEON_PRIM_TEX_BORDER_BLUE_SHIFT 0 +# define RADEON_PRIM_TEX_BORDER_GREEN_SHIFT 8 +# define RADEON_PRIM_TEX_BORDER_RED_SHIFT 16 +# define RADEON_PRIM_TEX_BORDER_ALPHA_SHIFT 24 +#define RADEON_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +# define RADEON_SEC_TEX_BORDER_BLUE_SHIFT 0 +# define RADEON_SEC_TEX_BORDER_GREEN_SHIFT 8 +# define RADEON_SEC_TEX_BORDER_RED_SHIFT 16 +# define RADEON_SEC_TEX_BORDER_ALPHA_SHIFT 24 +#define RADEON_STEN_REF_MASK_C 0x1d40 +# define RADEON_STEN_REFERENCE_SHIFT 0 +# define RADEON_STEN_MASK_SHIFT 16 +# define RADEON_STEN_WRITE_MASK_SHIFT 24 +#define RADEON_PLANE_3D_MASK_C 0x1d44 +#define RADEON_TEX_CACHE_STAT_COUNT 0x1974 + + + /* Constants */ +#define RADEON_AGP_TEX_OFFSET 0x02000000 + +#define RADEON_VB_AGE_REG RADEON_GUI_SCRATCH_REG0 +#define RADEON_SWAP_AGE_REG RADEON_GUI_SCRATCH_REG1 + + /* CCE packet types */ +#define RADEON_CCE_PACKET0 0x00000000 +#define RADEON_CCE_PACKET0_ONE_REG_WR 0x00008000 +#define RADEON_CCE_PACKET1 0x40000000 +#define RADEON_CCE_PACKET2 0x80000000 +#define RADEON_CCE_PACKET3_NOP 0xC0001000 +#define RADEON_CCE_PACKET3_PAINT 0xC0001100 +#define RADEON_CCE_PACKET3_BITBLT 0xC0001200 +#define RADEON_CCE_PACKET3_SMALLTEXT 0xC0001300 +#define RADEON_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 +#define RADEON_CCE_PACKET3_POLYLINE 0xC0001500 +#define RADEON_CCE_PACKET3_SCALING 0xC0001600 +#define RADEON_CCE_PACKET3_TRANS_SCALING 0xC0001700 +#define RADEON_CCE_PACKET3_POLYSCANLINES 0xC0001800 +#define RADEON_CCE_PACKET3_NEXT_CHAR 0xC0001900 +#define RADEON_CCE_PACKET3_PAINT_MULTI 0xC0001A00 +#define RADEON_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 +#define RADEON_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 +#define RADEON_CCE_PACKET3_SET_SCISSORS 0xC0001E00 +#define RADEON_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 +#define RADEON_CCE_PACKET3_CNTL_PAINT 0xC0009100 +#define RADEON_CCE_PACKET3_CNTL_BITBLT 0xC0009200 +#define RADEON_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 +#define RADEON_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 +#define RADEON_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 +#define RADEON_CCE_PACKET3_CNTL_SCALING 0xC0009600 +#define RADEON_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 +#define RADEON_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 +#define RADEON_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 +#define RADEON_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 +#define RADEON_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 +#define RADEON_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 +#define RADEON_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 +#define RADEON_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 +#define RADEON_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 +#define RADEON_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 +#define RADEON_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 +#define RADEON_CCE_PACKET3_PURGE 0xC0002D00 +#define RADEON_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 +# define RADEON_CCE_PACKET_MASK 0xC0000000 +# define RADEON_CCE_PACKET_COUNT_MASK 0x3fff0000 +# define RADEON_CCE_PACKET_MAX_DWORDS (1 << 14) +# define RADEON_CCE_PACKET0_REG_MASK 0x000007ff +# define RADEON_CCE_PACKET1_REG0_MASK 0x000007ff +# define RADEON_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define RADEON_CCE_VC_FRMT_RHW 0x00000001 +#define RADEON_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 +#define RADEON_CCE_VC_FRMT_DIFFUSE_A 0x00000004 +#define RADEON_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 +#define RADEON_CCE_VC_FRMT_SPEC_BGR 0x00000010 +#define RADEON_CCE_VC_FRMT_SPEC_F 0x00000020 +#define RADEON_CCE_VC_FRMT_SPEC_FRGB 0x00000040 +#define RADEON_CCE_VC_FRMT_S_T 0x00000080 +#define RADEON_CCE_VC_FRMT_S2_T2 0x00000100 +#define RADEON_CCE_VC_FRMT_RHW2 0x00000200 + +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define RADEON_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define RADEON_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define RADEON_CCE_VC_CNTL_NUM_SHIFT 16 + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h:1.1 --- /dev/null Mon Dec 18 14:30:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h Thu Nov 2 11:55:46 2000 @@ -0,0 +1,41 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h,v 1.1 2000/11/02 16:55:46 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _RADEON_VERSION_H_ +#define _RADEON_VERSION_H_ 1 + +#define RADEON_NAME "RADEON" +#define RADEON_DRIVER_NAME "radeon" + +#define RADEON_VERSION_NAME "4.0.1" + +#define RADEON_VERSION_MAJOR 4 +#define RADEON_VERSION_MINOR 0 +#define RADEON_VERSION_PATCH 1 + +#define RADEON_VERSION_CURRENT \ + ((RADEON_VERSION_MAJOR << 20) | \ + (RADEON_VERSION_MINOR << 10) | \ + (RADEON_VERSION_PATCH)) + +#endif /* _RADEON_VERSION_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c:1.8 --- /dev/null Mon Dec 18 14:30:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c Wed Dec 13 07:58:19 2000 @@ -0,0 +1,866 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_video.c,v 1.8 2000/12/13 12:58:19 tsi Exp $ */ + +#include "radeon.h" +#include "radeon_reg.h" + +#include "xf86.h" +#include "dixstruct.h" + +#include "Xv.h" +#include "fourcc.h" + +#define OFF_DELAY 250 /* milliseconds */ +#define FREE_DELAY 15000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 + +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +#ifndef XvExtension +void RADEONInitVideo(ScreenPtr pScreen) {} +#else + +static XF86VideoAdaptorPtr RADEONSetupImageVideo(ScreenPtr); +static int RADEONSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int RADEONGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +static void RADEONStopVideo(ScrnInfoPtr, pointer, Bool); +static void RADEONQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, + unsigned int *, unsigned int *, pointer); +static int RADEONPutImage(ScrnInfoPtr, short, short, short, short, short, + short, short, short, int, unsigned char*, short, + short, Bool, RegionPtr, pointer); +static int RADEONQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, + unsigned short *, int *, int *); + + +static void RADEONResetVideo(ScrnInfoPtr); + +static void RADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time time); + + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvColorKey, xvSaturation, xvDoubleBuffer; + + +typedef struct { + int brightness; + int saturation; + Bool doubleBuffer; + unsigned char currentBuffer; + FBLinearPtr linear; + RegionRec clip; + CARD32 colorKey; + CARD32 videoStatus; + Time offTime; + Time freeTime; +} RADEONPortPrivRec, *RADEONPortPrivPtr; + + +void RADEONInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + if(info->accel && info->accel->FillSolidRects) + newAdaptor = RADEONSetupImageVideo(pScreen); + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding = +{ + 0, + "XV_IMAGE", + 2048, 2048, + {1, 1} +}; + +#define NUM_FORMATS 12 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {8, TrueColor}, {8, DirectColor}, {8, PseudoColor}, + {8, GrayScale}, {8, StaticGray}, {8, StaticColor}, + {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, + {15, DirectColor}, {16, DirectColor}, {24, DirectColor} +}; + + +#define NUM_ATTRIBUTES 4 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, + {XvSettable | XvGettable, -64, 63, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 31, "XV_SATURATION"}, + {XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"} +}; + +#define NUM_IMAGES 4 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_UYVY, + XVIMAGE_YV12, + XVIMAGE_I420 +}; + +static void +RADEONResetVideo(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + + OUTREG(RADEON_OV0_SCALE_CNTL, 0x80000000); + OUTREG(RADEON_OV0_EXCLUSIVE_HORZ, 0); + OUTREG(RADEON_OV0_AUTO_FLIP_CNTL, 0); /* maybe */ + OUTREG(RADEON_OV0_FILTER_CNTL, 0x0000000f); + OUTREG(RADEON_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + OUTREG(RADEON_OV0_GRAPHICS_KEY_MSK, (1 << pScrn->depth) - 1); + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR, pPriv->colorKey); + OUTREG(RADEON_OV0_KEY_CNTL, RADEON_GRAPHIC_KEY_FN_NE); + OUTREG(RADEON_OV0_TEST, 0); +} + + +static XF86VideoAdaptorPtr +RADEONAllocAdaptor(ScrnInfoPtr pScrn) +{ + XF86VideoAdaptorPtr adapt; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPortPrivPtr pPriv; + + if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) + return NULL; + + if(!(pPriv = xcalloc(1, sizeof(RADEONPortPrivRec) + sizeof(DevUnion)))) + { + xfree(adapt); + return NULL; + } + + adapt->pPortPrivates = (DevUnion*)(&pPriv[1]); + adapt->pPortPrivates[0].ptr = (pointer)pPriv; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvSaturation = MAKE_ATOM("XV_SATURATION"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER"); + + pPriv->colorKey = info->videoKey; + pPriv->doubleBuffer = TRUE; + pPriv->videoStatus = 0; + pPriv->brightness = 0; + pPriv->saturation = 16; + pPriv->currentBuffer = 0; + + return adapt; +} + +static XF86VideoAdaptorPtr +RADEONSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPortPrivPtr pPriv; + XF86VideoAdaptorPtr adapt; + + if(!(adapt = RADEONAllocAdaptor(pScrn))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "ATI Rage128 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = &DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = RADEONStopVideo; + adapt->SetPortAttribute = RADEONSetPortAttribute; + adapt->GetPortAttribute = RADEONGetPortAttribute; + adapt->QueryBestSize = RADEONQueryBestSize; + adapt->PutImage = RADEONPutImage; + adapt->QueryImageAttributes = RADEONQueryImageAttributes; + + info->adaptor = adapt; + + pPriv = (RADEONPortPrivPtr)(adapt->pPortPrivates[0].ptr); + REGION_INIT(pScreen, &(pPriv->clip), NullBox, 0); + + RADEONResetVideo(pScrn); + + return adapt; +} + +/* I really should stick this in miregion */ +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + + +/* RADEONClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (xa, ya + inclusive, xb, yb exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +#define DummyScreen screenInfo.screens[0] + +static Bool +RADEONClipVideo( + BoxPtr dst, + INT32 *xa, + INT32 *xb, + INT32 *ya, + INT32 *yb, + RegionPtr reg, + INT32 width, + INT32 height +){ + INT32 vscale, hscale, delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + + hscale = ((*xb - *xa) << 16) / (dst->x2 - dst->x1); + vscale = ((*yb - *ya) << 16) / (dst->y2 - dst->y1); + + *xa <<= 16; *xb <<= 16; + *ya <<= 16; *yb <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *xa += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *xb -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *ya += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *yb -= diff * vscale; + } + + if(*xa < 0) { + diff = (- *xa + hscale - 1)/ hscale; + dst->x1 += diff; + *xa += diff * hscale; + } + delta = *xb - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *xb -= diff * hscale; + } + if(*xa >= *xb) return FALSE; + + if(*ya < 0) { + diff = (- *ya + vscale - 1)/ vscale; + dst->y1 += diff; + *ya += diff * vscale; + } + delta = *yb - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *yb -= diff * vscale; + } + if(*ya >= *yb) return FALSE; + + if((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || + (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) + { + RegionRec clipReg; + REGION_INIT(DummyScreen, &clipReg, dst, 1); + REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); + REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; +} + +static void +RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(cleanup) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTREG(RADEON_OV0_SCALE_CNTL, 0); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } +} + +static int +RADEONSetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + + if(attribute == xvBrightness) { + if((value < -64) || (value > 63)) + return BadValue; + pPriv->brightness = value; + OUTREG(RADEON_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + } else + if(attribute == xvSaturation) { + if((value < 0) || (value > 31)) + return BadValue; + pPriv->saturation = value; + OUTREG(RADEON_OV0_COLOUR_CNTL, (pPriv->brightness & 0x7f) | + (pPriv->saturation << 8) | + (pPriv->saturation << 16)); + } else + if(attribute == xvDoubleBuffer) { + if((value < 0) || (value > 1)) + return BadValue; + pPriv->doubleBuffer = value; + } else + if(attribute == xvColorKey) { + pPriv->colorKey = value; + OUTREG(RADEON_OV0_GRAPHICS_KEY_CLR, pPriv->colorKey); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else return BadMatch; + + return Success; +} + +static int +RADEONGetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + + if(attribute == xvBrightness) { + *value = pPriv->brightness; + } else + if(attribute == xvSaturation) { + *value = pPriv->saturation; + } else + if(attribute == xvDoubleBuffer) { + *value = pPriv->doubleBuffer ? 1 : 0; + } else + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else return BadMatch; + + return Success; +} + + +static void +RADEONQueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; +} + + +static void +RADEONCopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w +){ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +RADEONCopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w +){ + CARD32 *dst; + CARD8 *s1, *s2, *s3; + int i, j; + + w >>= 1; + + for(j = 0; j < h; j++) { + dst = (CARD32*)dst1; + s1 = src1; s2 = src2; s3 = src3; + i = w; + while(i > 4) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24); + dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24); + dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24); + dst += 4; s2 += 4; s3 += 4; s1 += 8; + i -= 4; + } + while(i--) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst++; s2++; s3++; + s1 += 2; + } + + dst1 += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + + +static FBLinearPtr +RADEONAllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +){ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16, + PRIORITY_EXTREME); + + if(max_size < size) + return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + } + + return new_linear; +} + +static void +RADEONDisplayVideo( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, short height, + int pitch, + int left, int right, int top, + BoxPtr dstBox, + short src_w, short src_h, + short drw_w, short drw_h +){ + RADEONInfoPtr info = RADEONPTR(pScrn); + unsigned char *RADEONMMIO = info->MMIO; + int v_inc, h_inc, step_by, tmp; + int p1_h_accum_init, p23_h_accum_init; + int p1_v_accum_init; + + v_inc = (src_h << 20) / drw_h; + h_inc = (src_w << 12) / drw_w; + step_by = 1; + + while(h_inc >= (2 << 12)) { + step_by++; + h_inc >>= 1; + } + + /* keep everything in 16.16 */ + + offset += ((left >> 16) & ~7) << 1; + + tmp = (left & 0x0003ffff) + 0x00028000 + (h_inc << 3); + p1_h_accum_init = ((tmp << 4) & 0x000f8000) | + ((tmp << 12) & 0xf0000000); + + tmp = ((left >> 1) & 0x0001ffff) + 0x00028000 + (h_inc << 2); + p23_h_accum_init = ((tmp << 4) & 0x000f8000) | + ((tmp << 12) & 0x70000000); + + tmp = (top & 0x0000ffff) + 0x00018000; + p1_v_accum_init = ((tmp << 4) & 0x03ff8000) | 0x00000001; + + left = (left >> 16) & 7; + + + OUTREG(RADEON_OV0_REG_LOAD_CNTL, 1); + while(!(INREG(RADEON_OV0_REG_LOAD_CNTL) & (1 << 3))); + + OUTREG(RADEON_OV0_H_INC, h_inc | ((h_inc >> 1) << 16)); + OUTREG(RADEON_OV0_STEP_BY, step_by | (step_by << 8)); + OUTREG(RADEON_OV0_Y_X_START, (dstBox->x1 + 8) | (dstBox->y1 << 16)); + OUTREG(RADEON_OV0_Y_X_END, (dstBox->x2 + 8) | (dstBox->y2 << 16)); + OUTREG(RADEON_OV0_V_INC, v_inc); + OUTREG(RADEON_OV0_P1_BLANK_LINES_AT_TOP, 0x00000fff | ((src_h - 1) << 16)); + OUTREG(RADEON_OV0_VID_BUF_PITCH0_VALUE, pitch); + OUTREG(RADEON_OV0_P1_X_START_END, (src_w + left - 1) | (left << 16)); + left >>= 1; src_w >>= 1; + OUTREG(RADEON_OV0_P2_X_START_END, (src_w + left - 1) | (left << 16)); + OUTREG(RADEON_OV0_P3_X_START_END, (src_w + left - 1) | (left << 16)); + OUTREG(RADEON_OV0_VID_BUF0_BASE_ADRS, offset & 0xfffffff0); + OUTREG(RADEON_OV0_P1_V_ACCUM_INIT, p1_v_accum_init); + OUTREG(RADEON_OV0_P1_H_ACCUM_INIT, p1_h_accum_init); + OUTREG(RADEON_OV0_P23_H_ACCUM_INIT, p23_h_accum_init); + + if(id == FOURCC_UYVY) + OUTREG(RADEON_OV0_SCALE_CNTL, 0x41008C03); + else + OUTREG(RADEON_OV0_SCALE_CNTL, 0x41008B03); + + OUTREG(RADEON_OV0_REG_LOAD_CNTL, 0); +} + + +static int +RADEONPutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool Sync, + RegionPtr clipBoxes, pointer data +){ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data; + INT32 xa, xb, ya, yb; + unsigned char *dst_start; + int pitch, new_size, offset, s2offset, s3offset; + int srcPitch, srcPitch2, dstPitch; + int top, left, npixels, nlines, bpp; + BoxRec dstBox; + CARD32 tmp; + + /* + * s2offset, s3offset - byte offsets into U and V plane of the + * source where copying starts. Y plane is + * done by editing "buf". + * + * offset - byte offset to the first line of the destination. + * + * dst_start - byte address to the first displayed pel. + * + */ + + /* make the compiler happy */ + s2offset = s3offset = srcPitch2 = 0; + + if(src_w > (drw_w << 4)) + drw_w = src_w >> 4; + if(src_h > (drw_h << 4)) + drw_h = src_h >> 4; + + /* Clip */ + xa = src_x; + xb = src_x + src_w; + ya = src_y; + yb = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if(!RADEONClipVideo(&dstBox, &xa, &xb, &ya, &yb, clipBoxes, width, height)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + bpp = pScrn->bitsPerPixel >> 3; + pitch = bpp * pScrn->displayWidth; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + dstPitch = ((width << 1) + 15) & ~15; + new_size = ((dstPitch * height) + bpp - 1) / bpp; + srcPitch = (width + 3) & ~3; + s2offset = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + s3offset = (srcPitch2 * (height >> 1)) + s2offset; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + dstPitch = ((width << 1) + 15) & ~15; + new_size = ((dstPitch * height) + bpp - 1) / bpp; + srcPitch = (width << 1); + break; + } + + if(!(pPriv->linear = RADEONAllocateMemory(pScrn, pPriv->linear, + pPriv->doubleBuffer ? (new_size << 1) : new_size))) + { + return BadAlloc; + } + + pPriv->currentBuffer ^= 1; + + /* copy data */ + top = ya >> 16; + left = (xa >> 16) & ~1; + npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left; + + offset = (pPriv->linear->offset * bpp) + (top * dstPitch); + if(pPriv->doubleBuffer) + offset += pPriv->currentBuffer * new_size * bpp; + dst_start = info->FB + offset; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + dst_start += left << 1; + tmp = ((top >> 1) * srcPitch2) + (left >> 1); + s2offset += tmp; + s3offset += tmp; + if(id == FOURCC_I420) { + tmp = s2offset; + s2offset = s3offset; + s3offset = tmp; + } + nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top; + RADEONCopyMungedData(buf + (top * srcPitch) + left, buf + s2offset, + buf + s3offset, dst_start, srcPitch, srcPitch2, + dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + left <<= 1; + buf += (top * srcPitch) + left; + nlines = ((yb + 0xffff) >> 16) - top; + dst_start += left; + RADEONCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + } + + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + (*info->accel->FillSolidRects)(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + RADEONDisplayVideo(pScrn, id, offset, width, height, dstPitch, + xa, xb, ya, &dstBox, src_w, src_h, drw_w, drw_h); + + pPriv->videoStatus = CLIENT_VIDEO_ON; + + info->VideoTimerCallback = RADEONVideoTimerCallback; + + return Success; +} + + +static int +RADEONQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int size, tmp; + + if(*w > 2048) *w = 2048; + if(*h > 2048) *h = 2048; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) pitches[0] = size; + size *= *h; + if(offsets) offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} + +static void +RADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time time) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; + + if(pPriv->videoStatus & TIMER_MASK) { + if(pPriv->videoStatus & OFF_TIMER) { + if(pPriv->offTime < time) { + unsigned char *RADEONMMIO = info->MMIO; + OUTREG(RADEON_OV0_SCALE_CNTL, 0); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = time + FREE_DELAY; + } + } else { /* FREE_TIMER */ + if(pPriv->freeTime < time) { + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + info->VideoTimerCallback = NULL; + } + } + } else /* shouldn't get here */ + info->VideoTimerCallback = NULL; +} + + +#endif /* !XvExtension */ Index: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile:1.24 xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile:1.27 --- xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile:1.24 Tue Apr 4 15:25:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile Fri Nov 3 13:46:08 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.24 2000/04/04 19:25:05 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.27 2000/11/03 18:46:08 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -21,14 +21,14 @@ INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC)/fbdevhw\ - -I$(XF86SRC)/vgafb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \ -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/Xext \ -I$(XINCLUDESRC) -I$(XF86SRC)/xaa -I$(FONTINCSRC) \ -I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \ -I$(XF86SRC)/i2c -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb \ -I$(XF86SRC)/xf8_16bpp -I$(XF86SRC)/int10 \ - -I$(XF86OSSRC)/vbe -I$(EXTINCSRC) + -I$(XF86OSSRC)/vbe -I$(EXTINCSRC) -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp:1.7 xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp:1.7 Tue Jun 13 22:13:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp Tue Dec 12 13:54:30 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp,v 1.7 2000/06/14 02:13:08 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp,v 1.9 2000/12/12 18:54:30 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH CHIPS __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH CHIPS __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME chips \- Chips and Technologies video driver .SH SYNOPSIS @@ -112,7 +112,7 @@ Default: off .TP .BI "Option \*qLinear\*q \*q" boolean \*q -Enables linear addressing in cases where it isdisabled by default. +Enables linear addressing in cases where it is disabled by default. Default: off .TP .BI "Option \*qHWCursor\*q \*q" boolean \*q @@ -160,7 +160,7 @@ Force the use of memory mapped IO where it can be used. Default: off .TP .BI "Option \*qSuspendHack\*q \*q" boolean \*q -Force driver to leave centering and stretching resgisters alone. This +Force driver to leave centering and stretching registers alone. This can fix some laptop suspend/resume problems. Default: off .TP .BI "Option \*qOverlay\*q" Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h:1.8 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h:1.8 Sun Dec 20 06:57:40 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h Wed Dec 6 10:35:12 2000 @@ -4,7 +4,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h,v 1.8 1998/12/20 11:57:40 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_BltHiQV.h,v 1.10 2000/12/06 15:35:12 eich Exp $ */ /* Definitions for the Chips and Technology BitBLT engine communication. */ /* These are done using Memory Mapped IO, of the registers */ @@ -68,16 +68,23 @@ * the BRxx registers. */ #define ctBLTWAIT \ - {int timeout; \ + {int timeout; \ timeout = 0; \ for (;;) { \ - if (!((cPtr->readXR(cPtr, 0x20)) & 0x1)) break; \ + if (cPtr->Chipset >= CHIPS_CT69000) { \ + if (!(MMIO_IN32(cPtr->MMIOBase,BR(0x4))&(1<<31)))\ + break; \ + } else { \ + if (!(cPtr->readXR(cPtr,0x20) & 0x1)) break; \ + } \ timeout++; \ if (timeout == 100000) { \ unsigned char tmp; \ + ErrorF("timeout\n"); \ tmp = cPtr->readXR(cPtr, 0x20); \ cPtr->writeXR(cPtr, 0x20, ((tmp & 0xFD) | 0x2)); \ - cPtr->writeXR(cPtr, 0x20, (tmp & 0xFD)); \ + xf86UDelay(10000); \ + cPtr->writeXR(cPtr, 0x20, (tmp & 0xFD)); \ break; \ } \ } \ Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c:1.33 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c:1.35 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c:1.33 Wed Oct 13 00:21:12 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c Tue Sep 26 11:57:10 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c,v 1.33 1999/10/13 04:21:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_accel.c,v 1.35 2000/09/26 15:57:10 tsi Exp $ */ /* * Copyright 1996, 1997, 1998 by David Bateman <dbateman@ee.uts.edu.au> * Modified 1997, 1998 by Nozomi Ytow @@ -146,9 +146,11 @@ static void CTNAME(WritePixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, int trans, int bpp, int depth); +#if 0 static void CTNAME(ReadPixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *dst, int dstwidth, int bpp, int depth); #endif +#endif Bool @@ -373,7 +375,6 @@ infoPtr->WritePixmapFlags |= NO_PLANEMASK; infoPtr->WritePixmap = CTNAME(WritePixmap); - #if 0 /* Not used by XAA as yet, but coming soon */ if (cPtr->Flags & ChipsImageReadSupport) { infoPtr->ReadPixmapFlags = CPU_TRANSFER_PAD_QWORD | ROP_NEEDS_SOURCE; @@ -803,6 +804,7 @@ #endif ctBLTWAIT; switch (cAcl->BitsPerPixel) { +#if 0 case 8: if ((planemask & 0xFF) == 0xFF) { ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]); @@ -821,6 +823,7 @@ ctWRITEPLANEMASK16(planemask, cAcl->ScratchAddress); } break; +#endif default: ctSETROP(cAcl->CommandFlags | ChipsAluConv[rop & 0xF]); break; @@ -1548,18 +1551,16 @@ int dwords; int skipleft; int destaddr; - int olddepth = -1; DEBUG_P("WritePixmap"); #ifdef DEBUG ErrorF("WritePixmap x %d, y %d, w %d, h %d, src 0x%X, srcwidth %d, rop 0x%X, planemask 0x%X, trans 0x%X, bpp %d, depth %d\n", x, y, w, h, src, srcwidth, rop, planemask, trans, bpp, depth); #endif - bytesPerLine = w * (bpp >> 3); byteWidthSrc = ((srcwidth * (bpp >> 3) + 3L) & ~0x3L); cAcl->CommandFlags = ctSRCSYSTEM | ctLEFT2RIGHT | ctTOP2BOTTOM; - skipleft = (unsigned int)src & 0x7; - src = (unsigned char *)((unsigned int)src & ~0x7L); + skipleft = (unsigned long)src & 0x7; + src = (unsigned char *)((unsigned long)src & ~0x7L); dwords = (((skipleft + bytesPerLine + 0x7) & ~0x7)) >> 2; destaddr = (y * pScrn->displayWidth + x) * (bpp >> 3); destpitch = pScrn->displayWidth * (bpp >> 3); @@ -1668,6 +1669,7 @@ cPtr->AccelInfoRec->NeedToSync = TRUE; } +#if 0 static void CTNAME(ReadPixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *dst, int dstwidth, int bpp, int depth) @@ -1734,4 +1736,6 @@ cPtr->AccelInfoRec->NeedToSync = TRUE; } +#endif /* ReadPixmap */ + #endif Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c:1.1 Sat Aug 14 06:49:38 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c Wed Dec 6 10:35:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c,v 1.1 1999/08/14 10:49:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_dga.c,v 1.2 2000/12/06 15:35:12 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -83,6 +83,8 @@ int Bpp = pScrn->bitsPerPixel >> 3; int num = 0; Bool oneMore; + int imlines = (pScrn->videoRam * 1024) / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); pMode = firstMode = pScrn->modes; @@ -133,7 +135,7 @@ if(oneMore) { /* first one is narrow width */ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; + currentMode->imageHeight = imlines; currentMode->pixmapWidth = currentMode->imageWidth; currentMode->pixmapHeight = currentMode->imageHeight; currentMode->maxViewportX = currentMode->imageWidth - @@ -147,7 +149,7 @@ currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 3) & ~3L; currentMode->imageWidth = pScrn->displayWidth; - currentMode->imageHeight = pMode->VDisplay; + currentMode->imageHeight = imlines; currentMode->pixmapWidth = currentMode->imageWidth; currentMode->pixmapHeight = currentMode->imageHeight; currentMode->maxViewportX = currentMode->imageWidth - @@ -187,17 +189,18 @@ CHIPSPtr cPtr = CHIPSPTR(pScrn); - if(!pMode) { /* restore the original mode */ + if (!pMode) { /* restore the original mode */ /* put the ScreenParameters back */ - - pScrn->displayWidth = OldDisplayWidth[index]; - - CHIPSSwitchMode(index, pScrn->currentMode, 0); - cPtr->DGAactive = FALSE; + if (cPtr->DGAactive) { + pScrn->displayWidth = OldDisplayWidth[index]; + pScrn->EnterVT(pScrn->scrnIndex,0); + + cPtr->DGAactive = FALSE; + } } else { if(!cPtr->DGAactive) { /* save the old parameters */ OldDisplayWidth[index] = pScrn->displayWidth; - + pScrn->LeaveVT(pScrn->scrnIndex,0); cPtr->DGAactive = TRUE; } Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c:1.91 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c:1.103 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c:1.91 Wed Jun 21 13:28:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c Wed Dec 6 10:35:12 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.91 2000/06/21 17:28:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.103 2000/12/06 15:35:12 eich Exp $ */ /* * Copyright 1993 by Jon Block <block@frc.com> @@ -105,16 +105,10 @@ /* All drivers using the mi colormap manipulation need this */ #include "micmap.h" -/* If using cfb, cfb.h is required. */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" #include "cfb8_16.h" + /* Needed for the 1 and 4 bpp framebuffers */ #include "xf1bpp.h" #include "xf4bpp.h" @@ -132,6 +126,10 @@ /* Needed for replacement LoadPalette function for Gamma Correction */ #include "xf86cmap.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* Driver specific headers */ #include "ct_driver.h" @@ -180,8 +178,8 @@ static Bool chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode); static Bool chipsModeInitWingine(ScrnInfoPtr pScrn, DisplayModePtr mode); static Bool chipsModeInit655xx(ScrnInfoPtr pScrn, DisplayModePtr mode); -static int chipsVideoMode(int vgaBitsPerPixel, int weightGreen, - int displayHSize, int displayVSize); +static int chipsVideoMode(int vgaBitsPerPixel,int displayHSize, + int displayVSize); static void chipsDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); static void chipsHWCursorOn(CHIPSPtr cPtr); @@ -544,6 +542,7 @@ OPTION_LCD_STRETCH, OPTION_LCD_CENTER, OPTION_MMIO, + OPTION_FULL_MMIO, OPTION_SUSPEND_HACK, OPTION_RGB_BITS, OPTION_SYNC_ON_GREEN, @@ -559,7 +558,8 @@ OPTION_FP_CLOCK_24, OPTION_FP_CLOCK_32, OPTION_SET_MCLK, - OPTION_ROTATE + OPTION_ROTATE, + OPTION_NO_TMED } CHIPSOpts; static OptionInfoRec Chips655xxOptions[] = { @@ -614,6 +614,7 @@ { OPTION_LCD_STRETCH, "NoStretch", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_LCD_CENTER, "LcdCenter", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_MMIO, "MMIO", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FULL_MMIO, "FullMMIO", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SUSPEND_HACK, "SuspendHack", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PANEL_SIZE, "FixPanelSize", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_RGB_BITS, "RGBbits", OPTV_INTEGER, {0}, FALSE }, @@ -629,6 +630,7 @@ { OPTION_FP_CLOCK_24, "FPClock24", OPTV_FREQ, {0}, FALSE }, { OPTION_FP_CLOCK_32, "FPClock32", OPTV_FREQ, {0}, FALSE }, { OPTION_SET_MCLK, "SetMclk", OPTV_FREQ, {0}, FALSE }, + { OPTION_NO_TMED, "NoTMED", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -654,15 +656,11 @@ NULL }; -static const char *cfbSymbols[] = { +static const char *fbSymbols[] = { "xf1bppScreenInit", "xf4bppScreenInit", - "cfbScreenInit", - "cfb16ScreenInit", "cfb8_16ScreenInit", - "cfb24ScreenInit", - "cfb24_32ScreenInit", - "cfb32ScreenInit", + "fb_ScreenInit", NULL }; @@ -748,7 +746,7 @@ * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, shadowSymbols, vbeSymbols, NULL); @@ -805,7 +803,6 @@ OptionInfoPtr CHIPSAvailableOptions(int chipid, int busid) { - int vendor = ((chipid & 0xffff0000) >> 16); int chip = chipid & 0x0000ffff; if (busid == BUS_ISA) { @@ -825,7 +822,7 @@ { Bool foundScreen = FALSE; int numDevSections, numUsed; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int i; @@ -1061,6 +1058,7 @@ /* Now that we've identified the chipset, setup the capabilities flags */ switch (cPtr->Chipset) { case CHIPS_CT69030: + cPtr->Flags |= ChipsDualChannelSupport; case CHIPS_CT69000: cPtr->Flags |= ChipsFullMMIOSupport; /* Fall through */ @@ -1135,21 +1133,8 @@ */ pScrn->videoRam -= (cPtr->FrameBufferSize + 1023) / 1024; - if (cPtr->Flags & ChipsAccelSupport) { - /* - * If we are using acceleration then we want a display pitch that is - * a multiple of 64 pixels. This allows for alignment issues for the - * 8x8 pattern fills. Try to widen the display pitch to 64 if necessary - */ - cPtr->Rounding = 64 * (pScrn->bitsPerPixel <= 8 ? 8 - : pScrn->bitsPerPixel); - /* 16 Kb cache for each bpp */ - pScrn->videoRam -= 16 * (pScrn->bitsPerPixel >> 3); - } else { - cPtr->Rounding = 8; - if (pScrn->bitsPerPixel >= 8) - cPtr->Rounding *= (pScrn->bitsPerPixel >> 3); - } + cPtr->Rounding = 8 * (pScrn->bitsPerPixel <= 8 ? 8 + : pScrn->bitsPerPixel); i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, @@ -1157,40 +1142,7 @@ 128, 2048, pScrn->display->virtualX, pScrn->display->virtualY, cPtr->FbMapSize, LOOKUP_BEST_REFRESH); - /* - * If we are using accel and don't find any valid modes - * we might not have enough memory for a 64 bit rounding - * and 16 Kb per bpp cache. Let's try without it. - */ - if (i < 1 && (cPtr->Flags & ChipsAccelSupport)) { - cPtr->Rounding = 8; - if (pScrn->bitsPerPixel >= 8) - cPtr->Rounding *= pScrn->bitsPerPixel; - pScrn->videoRam += 16 * (pScrn->bitsPerPixel >> 3); - - /* - * If the modepool isn't empty, we'll need to delete it - * before revalidating the mode list - */ - while (pScrn->modes) - xf86DeleteMode(&pScrn->modes, pScrn->modes); - while (pScrn->modePool) - xf86DeleteMode(&pScrn->modePool, pScrn->modePool); - - i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, - pScrn->display->modes, clockRanges, - NULL, 256, 2048, cPtr->Rounding, - 128, 2048, pScrn->display->virtualX, - pScrn->display->virtualY, cPtr->FbMapSize, - LOOKUP_BEST_REFRESH); - if (i >= 1) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "not enough free memory to adjust display pitch.\n"); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "some acceleration may be disabled.\n"); - } - } if (i == -1) { CHIPSFreeRec(pScrn); return FALSE; @@ -1232,47 +1184,40 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: - mod = "xf1bpp"; - reqSym = "xf1bppScreenInit"; + if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf1bppScreenInit", NULL); break; case 4: - mod = "xf4bpp"; - reqSym = "xf4bppScreenInit"; - break; - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; + if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf4bppScreenInit", NULL); break; case 16: if (cPtr->Flags & ChipsOverlay8plus16) { - mod = "xf8_16bpp"; - reqSym = "cfb8_16ScreenInit"; - } else { - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - } - break; - case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - reqSym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - reqSym = "cfb24_32ScreenInit"; + if (xf86LoadSubModule(pScrn, "xf8_16bpp") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("cfb8_16bppScreenInit", NULL); + break; } + default: + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + CHIPSFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif break; - case 32: - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - CHIPSFreeRec(pScrn); - return FALSE; } - - xf86LoaderReqSymbols(reqSym, NULL); - + if (cPtr->Flags & ChipsAccelSupport) { if (!xf86LoadSubModule(pScrn, "xaa")) { CHIPSFreeRec(pScrn); @@ -1383,17 +1328,8 @@ } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -1492,7 +1428,6 @@ "Enabling linear addressing\n"); xf86DrvMsg(pScrn->scrnIndex, from, "base address is set at 0x%X.\n", cPtr->FbAddress); - cPtr->UseMMIO = TRUE; cPtr->IOAddress = cPtr->FbAddress + 0x400000L; } else xf86DrvMsg(pScrn->scrnIndex, from, @@ -1549,6 +1484,9 @@ if (!xf86IsOptionSet(cPtr->Options, OPTION_LCD_STRETCH)) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, " - Forcing option \"NoStretch\".\n"); + if (!xf86IsOptionSet(cPtr->Options, OPTION_LCD_CENTER)) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + " - Forcing option \"LcdCenter\".\n"); if (cPtr->Flags & ChipsShadowFB) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, " - Disabling \"Shadow Framebuffer\".\n"); @@ -1599,7 +1537,44 @@ cPtr->Flags |= ChipsHWCursor; else cPtr->Flags &= ~ChipsHWCursor; + + if (xf86ReturnOptValBool(cPtr->Options, OPTION_MMIO, TRUE)) { + cPtr->UseMMIO = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using MMIO\n"); + /* Are we using MMIO mapping of VGA registers */ + if (xf86ReturnOptValBool(cPtr->Options, OPTION_FULL_MMIO, FALSE)) { + if ((cPtr->Flags & ChipsLinearSupport) + && (cPtr->Flags & ChipsFullMMIOSupport) + && (cPtr->pEnt->location.type == BUS_PCI)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Enabling Full MMIO\n"); + cPtr->UseFullMMIO = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using Full MMIO\n"); + + /* Map the linear framebuffer */ + if (!chipsMapMem(pScrn)) + return FALSE; + + /* Setup the MMIO register functions */ + if (cPtr->MMIOBaseVGA) { + CHIPSSetMmioExtFuncs(cPtr); + CHIPSHWSetMmioFuncs(pScrn, cPtr->MMIOBaseVGA, 0x0); + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "FULL_MMIO option ignored\n"); + } + } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,"Disabling MMIO: " + "no acceleration, no hw_cursor\n"); + cPtr->UseMMIO = FALSE; + cPtr->Accel.UseHWCursor = FALSE; + cPtr->Flags &= ~ChipsAccelSupport; + } + /* memory size */ if (cPtr->pEnt->device->videoRam != 0) { pScrn->videoRam = cPtr->pEnt->device->videoRam; @@ -1668,29 +1643,6 @@ } cPtr->FbMapSize = pScrn->videoRam * 1024; - /* Are we using MMIO mapping of VGA registers */ - if (xf86ReturnOptValBool(cPtr->Options, OPTION_MMIO, FALSE)) { - if ((cPtr->Flags & ChipsLinearSupport) && cPtr->UseMMIO && - (cPtr->Flags & ChipsFullMMIOSupport) && - cPtr->pEnt->location.type == BUS_PCI) { - - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Enabling MMIO\n"); - cPtr->UseFullMMIO = TRUE; - - /* Map the linear framebuffer */ - if (!chipsMapMem(pScrn)) - return FALSE; - - /* Setup the MMIO register funstions */ - if (cPtr->MMIOBaseVGA) { - CHIPSSetMmioExtFuncs(cPtr); - CHIPSHWSetMmioFuncs(pScrn, cPtr->MMIOBaseVGA, 0x0); - } - } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MMIO option ignored\n"); - } - } - /* Store register values that might be messed up by a suspend resume */ /* Do this early as some of the other code in PreInit relies on it */ cPtr->SuspendHack.vgaIOBaseFlag = ((hwp->readMiscOut(hwp)) & 0x01); @@ -1889,8 +1841,10 @@ N = (cPtr->readXR(cPtr, 0xC1 + offset) | (( tmp >> 4) & 0x03)) + 2; tmp = cPtr->readXR(cPtr, 0xC3 + offset); - PSN = ((tmp & 0x1) ? 1 : 4) * ((tmp & 0x02) ? 5 : 1); - VCO_D = ((tmp & 0x04) ? 16 : 4); + PSN = (cPtr->Chipset == CHIPS_CT69000 || cPtr->Chipset == CHIPS_CT69030) + ? 1 : (((tmp & 0x1) ? 1 : 4) * ((tmp & 0x02) ? 5 : 1)); + VCO_D = ((tmp & 0x04) ? ((cPtr->Chipset == CHIPS_CT69000 || + cPtr->Chipset == CHIPS_CT69030) ? 1 : 16) : 4); P = ((tmp & 0x70) >> 4); Probed[i] = VCO_D * Fref / N; Probed[i] = Probed[i] * M / (PSN * (1 << P)); @@ -1898,7 +1852,17 @@ } CRTclkI = (hwp->readMiscOut(hwp) >> 2) & 0x03; if (CRTclkI == 3) CRTclkI = 2; - FPclkI = (cPtr->readFR(cPtr, 0x03) >> 2) & 0x3; + if (cPtr->Flags & ChipsDualChannelSupport) { + unsigned char IOSS, MSS; + IOSS = cPtr->readIOSS(cPtr); + MSS = cPtr->readMSS(cPtr); + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline A */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + FPclkI = (cPtr->readFR(cPtr, 0x01) >> 2) & 0x3; + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } else + FPclkI = (cPtr->readFR(cPtr, 0x03) >> 2) & 0x3; if (FPclkI == 3) FPclkI = 2; for (i = 0; i < 3; i++) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, @@ -2004,8 +1968,8 @@ /* Check if maxClock is limited by the MemClk. Only 70% to allow for */ /* RAS/CAS. Extra byte per memory clock needed if framebuffer used */ /* Extra byte if the overlay plane is avtivated */ - if (cPtr->FrameBufferSize) - if (cPtr->Flags & ChipsOverlay8plus16) + if (cPtr->FrameBufferSize && (cPtr->PanelType & ChipsLCD)) + if (cPtr->Flags & ChipsOverlay8plus16 ) cPtr->MaxClock = min(cPtr->MaxClock, MemClk->Clk * 4 * 0.7 / 4); else cPtr->MaxClock = min(cPtr->MaxClock, @@ -2050,7 +2014,7 @@ } /* * Prepare the FPclock: - * if FPclock >= MaxClock : don't modify the FP clock. + * if FPclock <= MaxClock : don't modify the FP clock. * else set FPclock to 90% of MaxClock. */ real = 0.; @@ -2206,17 +2170,8 @@ } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -2680,17 +2635,8 @@ } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -3382,14 +3328,19 @@ { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; CHIPSPtr cPtr = CHIPSPTR(pScrn); - ErrorF("CHIPSEnterVT"); + /* Should we re-save the text mode on each VT enter? */ if(!chipsModeInit(pScrn, pScrn->currentMode)) return FALSE; + if ((!(cPtr->Flags & ChipsOverlay8plus16)) && + (cPtr->Flags & ChipsVideoSupport)) + CHIPSResetVideo(pScrn); + xf86UDelay(50000); chipsHWCursorOn(cPtr); /* cursor settle delay */ - usleep(50000); + xf86UDelay(50000); CHIPSAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + xf86UDelay(50000); return TRUE; } @@ -3418,7 +3369,7 @@ vgaHWPtr hwp = VGAHWPTR(pScrn); CHIPSPtr cPtr = CHIPSPTR(pScrn); int i, index, shift ; - + shift = ((pScrn->depth == 15) && (!(cPtr->Flags & ChipsOverlay8plus16))) ? 3 : 0; @@ -3475,8 +3426,9 @@ unsigned int racflag = 0; unsigned char *FBStart; int height, width, displayWidth; +#ifdef DEBUG ErrorF("CHIPSScreenInit\n"); - +#endif /* * we need to get the ScrnInfoRec for this screen, so let's allocate * one first thing @@ -3564,24 +3516,13 @@ if (!miSetVisualTypes(8, PseudoColorMask | GrayScaleMask, pScrn->rgbBits, PseudoColor)) return FALSE; - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - TrueColor)) - return FALSE; - } else if ((pScrn->depth > 8) && (!(cPtr->Flags & ChipsGammaSupport))) { - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. To deal with this, call - * miSetVisualTypes for each visual supported. - */ - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; } + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -3619,49 +3560,26 @@ pScrn->xDpi, pScrn->yDpi, displayWidth); break; - case 8: - ret = cfbScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 16: - if (cPtr->Flags & ChipsOverlay8plus16) - ret = cfb8_16ScreenInit(pScreen, (unsigned char *)FBStart + - cPtr->FbOffset16, FBStart, width, - height, pScrn->xDpi, pScrn->yDpi, - displayWidth, displayWidth); - else - ret = cfb16ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 32: - ret = cfb32ScreenInit(pScreen, FBStart, + if (cPtr->Flags & ChipsOverlay8plus16) { + ret = cfb8_16ScreenInit(pScreen, (unsigned char *)FBStart + + cPtr->FbOffset16, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth, displayWidth); + break; + } + default: + ret = fbScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in CHIPSScreenInit\n", - pScrn->bitsPerPixel); - ret = FALSE; + displayWidth,pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif break; } + if (!ret) return FALSE; @@ -3682,7 +3600,7 @@ xf86SetBlackWhitePixels(pScreen); - if ((cPtr->Flags & ChipsAccelSupport) && (pScrn->depth >= 8)) + if ( (pScrn->depth >= 8)) CHIPSDGAInit(pScreen); cPtr->HWCursorShown = FALSE; @@ -3771,6 +3689,7 @@ /* Setup pointers to free space in video ram */ #define CHIPSALIGN(size, align) (currentaddr - ((currentaddr - size) & ~align)) allocatebase = (pScrn->videoRam<<10) - cPtr->FrameBufferSize; + if (pScrn->bitsPerPixel < 8) freespace = allocatebase - pScrn->displayWidth * pScrn->virtualY / 2; @@ -3954,11 +3873,11 @@ xf86SetSilkenMouse(pScreen); #endif - if ((!(cPtr->Flags & ChipsOverlay8plus16)) && - (cPtr->Flags & ChipsVideoSupport)) { - CHIPSInitVideo(pScreen); + if ((!(cPtr->Flags & ChipsOverlay8plus16)) && + (cPtr->Flags & ChipsVideoSupport)) { + CHIPSInitVideo(pScreen); } - + pScreen->SaveScreen = CHIPSSaveScreen; #ifdef DPMSExtension @@ -4132,6 +4051,9 @@ CHIPSPtr cPtr = CHIPSPTR(pScrn); unsigned char dpmsreg, seqreg, lcdoff, tmp; + if (!pScrn->vtSema) + return; + xf86EnableAccess(pScrn); switch (PowerManagementMode) { case DPMSModeOn: @@ -4175,11 +4097,22 @@ /* Turn off the flat panel */ if (cPtr->PanelType & ChipsLCD) { if (IS_HiQV(cPtr)) { - tmp = cPtr->readFR(cPtr, 0x05); - if (lcdoff) - cPtr->writeFR(cPtr, 0x05, tmp | 0x08); - else - cPtr->writeFR(cPtr, 0x05, tmp & 0xF7); + if (cPtr->Chipset == CHIPS_CT69030) { +#if 0 + /* Where is this for the 69030?? */ + tmp = cPtr->readFR(cPtr, 0x05); + if (lcdoff) + cPtr->writeFR(cPtr, 0x05, tmp | 0x08); + else + cPtr->writeFR(cPtr, 0x05, tmp & 0xF7); +#endif + } else { + tmp = cPtr->readFR(cPtr, 0x05); + if (lcdoff) + cPtr->writeFR(cPtr, 0x05, tmp | 0x08); + else + cPtr->writeFR(cPtr, 0x05, tmp & 0xF7); + } } else { tmp = cPtr->readXR(cPtr, 0x52); if (lcdoff) @@ -4263,7 +4196,19 @@ Clock->msr = hwp->readMiscOut(hwp)&0xFE; /* save standard VGA clock reg */ switch (Type & GET_STYLE) { case HiQV_STYLE: - Clock->fr03 = cPtr->readFR(cPtr, 0x03); /* save alternate clock select reg.*/ + /* save alternate clock select reg.*/ + /* The 69030 FP clock select is at FR01 instead */ + if (cPtr->Flags & ChipsDualChannelSupport) { + unsigned char IOSS, MSS; + IOSS = cPtr->readIOSS(cPtr); + MSS = cPtr->readMSS(cPtr); + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline A */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + Clock->fr03 = cPtr->readFR(cPtr, 0x01); + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } else + Clock->fr03 = cPtr->readFR(cPtr, 0x03); if (!Clock->Clock) { /* save HiQV console clock */ tmp = cPtr->CRTclkInx << 2; cPtr->CRTClk[0] = cPtr->readXR(cPtr, 0xC0 + tmp); @@ -4325,10 +4270,10 @@ Clock->xr33 = 0; Clock->xr54 = Clock->msr; /* update panel type in case somebody switched. - * This should be handeled more generally: + * This should be handled more generally: * On mode switch DDC should be reread, all * display dependent data should be reevaluated. - * This will be build in when we start Display + * This will be built in when we start Display * HotPlug support. * Until then we have to do it here as somebody * might have switched displays on us and we only @@ -4433,16 +4378,36 @@ volatile unsigned char tmp, tmpmsr, tmpfcr, tmp02; volatile unsigned char tmp33, tmp54, tmpf03; unsigned char vclk[3]; + volatile unsigned char IOSS, MSS; tmpmsr = hwp->readMiscOut(hwp); /* read msr, needed for all styles */ switch (Type & GET_STYLE) { case HiQV_STYLE: - tmpf03 = cPtr->readFR(cPtr, 0x03); /* save alternate clock select reg. */ + /* save alternate clock select reg. */ + /* The 69030 FP clock select is at FR01 instead */ + if (cPtr->Flags & ChipsDualChannelSupport) { + IOSS = cPtr->readIOSS(cPtr); + MSS = cPtr->readMSS(cPtr); + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline A */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + tmpf03 = cPtr->readFR(cPtr, 0x01); + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } else + tmpf03 = cPtr->readFR(cPtr, 0x03); /* select fixed clock 0 before tampering with VCLK select */ hwp->writeMiscOut(hwp, (tmpmsr & ~0x0D) | cPtr->SuspendHack.vgaIOBaseFlag); - cPtr->writeFR(cPtr, 0x03, (tmpf03 & ~0x0C) | 0x04); + /* The 69030 FP clock select is at FR01 instead */ + if (cPtr->Flags & ChipsDualChannelSupport) { + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline A */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + cPtr->writeFR(cPtr, 0x01, (tmpf03 & ~0x0C) | 0x04); + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } else + cPtr->writeFR(cPtr, 0x03, (tmpf03 & ~0x0C) | 0x04); if (!Clock->Clock) { /* Hack to load saved console clock */ tmp = cPtr->CRTclkInx << 2; cPtr->writeXR(cPtr, 0xC0 + tmp, (cPtr->CRTClk[0] & 0xFF)); @@ -4481,7 +4446,17 @@ } } usleep(10000); /* Let VCO stabilise */ - cPtr->writeFR(cPtr, 0x03, ((tmpf03 & ~0x0C) | (Clock->fr03 & 0x0C))); + /* The 69030 FP clock select is at FR01 instead */ + if (cPtr->Flags & ChipsDualChannelSupport) { + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline A */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + cPtr->writeFR(cPtr, 0x01, ((tmpf03 & ~0x0C) | + (Clock->fr03 & 0x0C))); + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } else + cPtr->writeFR(cPtr, 0x03, ((tmpf03 & ~0x0C) | + (Clock->fr03 & 0x0C))); break; case WINGINE_1_STYLE: break; @@ -4568,8 +4543,9 @@ int M_min = 3; /* Hack to deal with problem of Toshiba 720CDT clock */ - int M_max = (IS_HiQV(cPtr) && cPtr->Chipset != CHIPS_CT69000) ? 63 : 127; - /* @@@ < CHIPS_CT69000 ?? */ + int M_max = (IS_HiQV(cPtr) && cPtr->Chipset != CHIPS_CT69000 && + cPtr->Chipset != CHIPS_CT69030) ? 63 : 127; + /* @@@ < CHIPS_CT690x0 ?? */ /* Other parameters available on the 65548 but not the 65545, and * not documented in the Clock Synthesizer doc in rev 1.0 of the @@ -4597,9 +4573,9 @@ * they should be set to 0 on the 65548, and left untouched on * earlier chips. * - * Other parameters available on the 69000 + * Other parameters available on the 690x0 * - * + The 69000 has no reference clock divider, so PSN must + * + The 690x0 has no reference clock divider, so PSN must * always be 1. * XRCB[0:1] are reserved according to the data book */ @@ -4607,8 +4583,9 @@ target = Clock * 1000; - /* @@@ >= CHIPS_CT69000 ?? */ - for (PSNx = (cPtr->Chipset == CHIPS_CT69000) ? 1 : 0; PSNx <= 1; PSNx++) { + /* @@@ >= CHIPS_CT690x0 ?? */ + for (PSNx = (cPtr->Chipset == CHIPS_CT69000 || + cPtr->Chipset == CHIPS_CT69030) ? 1 : 0; PSNx <= 1; PSNx++) { int low_N, high_N; double Fref4PSN; @@ -4626,8 +4603,9 @@ for (N = low_N; N <= high_N; N++) { double tmp = Fref4PSN / N; - /* @@@ < CHIPS_CT69000 ?? */ - for (P = (IS_HiQV(cPtr) && cPtr->Chipset != CHIPS_CT69000) ? 1 : 0; + /* @@@ < CHIPS_CT690x0 ?? */ + for (P = (IS_HiQV(cPtr) && cPtr->Chipset != CHIPS_CT69000 && + cPtr->Chipset != CHIPS_CT69030) ? 1 : 0; P <= 5; P++) { /* to force post divisor on Toshiba 720CDT */ double Fvco_desired = target * (1 << P); @@ -4648,9 +4626,9 @@ for (M = M_low; M <= M_hi; M++) { Fvco = tmp * M; - /* @@@ >= CHIPS_CT69000 ?? */ - if (Fvco <= ((cPtr->Chipset == CHIPS_CT69000) ? 100.0e6 - : 48.0e6)) + /* @@@ >= CHIPS_CT690x0 ?? */ + if (Fvco <= ((cPtr->Chipset == CHIPS_CT69000 || + cPtr->Chipset == CHIPS_CT69030) ? 100.0e6 : 48.0e6)) continue; if (Fvco > 220.0e6) break; @@ -4673,9 +4651,10 @@ } } } - /* @@@ >= CHIPS_CT69000 ?? */ + /* @@@ >= CHIPS_CT690x0 ?? */ vclk[0] = (bestP << (IS_HiQV(cPtr) ? 4 : 1)) + - ((cPtr->Chipset == CHIPS_CT69000) ? 0 : (bestPSN == 1)); + ((cPtr->Chipset == CHIPS_CT69000 || cPtr->Chipset == CHIPS_CT69030) + ? 0 : (bestPSN == 1)); vclk[1] = bestM - 2; vclk[2] = bestN - 2; #ifdef DEBUG @@ -4694,7 +4673,9 @@ CHIPSRegPtr ChipsSave; int i; unsigned char tmp; +#ifdef DEBUG ErrorF("chipsSave\n"); +#endif ChipsSave = &cPtr->SavedReg; @@ -4717,6 +4698,12 @@ /* save clock */ chipsClockSave(pScrn, &ChipsSave->Clock); + /* Save the IOSS/MSS dual display channel registers */ + if (cPtr->Flags & ChipsDualChannelSupport) { + ChipsSave->MSS = cPtr->readMSS(cPtr); + ChipsSave->IOSS = cPtr->readIOSS(cPtr); + } + /* save extended registers */ if (IS_HiQV(cPtr)) { for (i = 0; i < 0xFF; i++) { @@ -4764,7 +4751,9 @@ chipsModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { CHIPSPtr cPtr = CHIPSPTR(pScrn); +#ifdef DEBUG ErrorF("chipsModeInit\n"); +#endif #if 0 *(int*)0xFFFFFF0 = 0; ErrorF("done\n"); @@ -4795,7 +4784,7 @@ * Normally the alternalte registers are set by the BIOS to optimized * values. * While the horizontal an vertical refresh rates are fixed independent - * of the visible display size to enshure optimal performace of both + * of the visible display size to ensure optimal performace of both * displays they can be adapted to the screen resolution and CRT * requirements in CRT mode by programming the standard timing registers * in the VGA fashion. @@ -4805,6 +4794,8 @@ * by the _alternate_ horizontal and vertical display size registers. * The size of the visible should always be equal or less than the * physical size. + * For the 69030 chipsets, the CRT and LCD display channels are seperate + * and so can be driven independently. */ static Bool chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode) @@ -4865,6 +4856,14 @@ ChipsNew->CR[i] = hwp->readCrtc(hwp, i); } + /* Read the display panel registers and force them to desired mode */ + if (cPtr->Flags & ChipsDualChannelSupport) { + ChipsNew->MSS = cPtr->readMSS(cPtr); + ChipsNew->IOSS = cPtr->readIOSS(cPtr); + ChipsNew->MSS &= 0xF0 | 0x0B ; + ChipsNew->IOSS &= 0xE0 |0x13 ; + } + /* * Here all of the other fields of 'ChipsNew' get filled in, to * handle the SVGA extended registers. It is also allowable @@ -5005,8 +5004,9 @@ if (xf86ReturnOptValBool(cPtr->Options, OPTION_HW_CURSOR, FALSE)) cPtr->Accel.UseHWCursor = TRUE; /* H/W cursor forced */ else { - if ((cPtr->PanelSize.HDisplay != mode->CrtcHDisplay) && - (cPtr->PanelSize.VDisplay != mode->CrtcVDisplay)) { + if ((cPtr->PanelSize.HDisplay && cPtr->PanelSize.VDisplay) + && (cPtr->PanelSize.HDisplay != mode->CrtcHDisplay) + && (cPtr->PanelSize.VDisplay != mode->CrtcVDisplay)) { if(cPtr->Accel.UseHWCursor) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Disabling HW Cursor on stretched LCD\n"); @@ -5016,12 +5016,13 @@ } } - if (!xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_CENTER, FALSE)) { - ChipsNew->FR[0x40] &= 0xFD; /* Disable Horizontal centering */ - ChipsNew->FR[0x48] &= 0xFD; /* Disable Vertical centering */ - } else { + if ((xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_CENTER, FALSE)) + || (cPtr->Flags & ChipsOverlay8plus16)) { ChipsNew->FR[0x40] |= 0x3; /* Enable Horizontal centering */ ChipsNew->FR[0x48] |= 0x3; /* Enable Vertical centering */ + } else { + ChipsNew->FR[0x40] &= 0xFD; /* Disable Horizontal centering */ + ChipsNew->FR[0x48] &= 0xFD; /* Disable Vertical centering */ } /* sync on green */ @@ -5030,8 +5031,7 @@ /* software mode flag */ ChipsNew->XR[0xE2] = chipsVideoMode(((cPtr->Flags & ChipsOverlay8plus16) ? - 8 : pScrn->bitsPerPixel), - pScrn->weight.green, (cPtr->PanelType & ChipsLCD) ? + 8 : pScrn->depth), (cPtr->PanelType & ChipsLCD) ? min(mode->CrtcHDisplay, cPtr->PanelSize.HDisplay) : mode->CrtcHDisplay, mode->CrtcVDisplay); #ifdef DEBUG @@ -5132,7 +5132,8 @@ ChipsNew->FR[0x11] &= ~0x8C; /* Dither clear */ ChipsNew->FR[0x11] |= 0x01; /* 16 frame FRC */ ChipsNew->FR[0x11] |= 0x84; /* Dither */ - if (cPtr->Flags & ChipsTMEDSupport) { + if ((cPtr->Flags & ChipsTMEDSupport) && + !xf86ReturnOptValBool(cPtr->Options, OPTION_NO_TMED, FALSE)) { ChipsNew->FR[0x73] &= 0x4F; /* Clear TMED */ ChipsNew->FR[0x73] |= 0x80; /* Enable TMED */ ChipsNew->FR[0x73] |= 0x30; /* TMED 256 Shades of RGB */ @@ -5180,6 +5181,9 @@ } } + /* Turn off multimedia by default as it degrades performance */ + ChipsNew->XR[0xD0] &= 0x0f; + /* Setup the video/overlay */ if (cPtr->Flags & ChipsOverlay8plus16) { ChipsNew->XR[0xD0] |= 0x10; /* Force the Multimedia engine on */ @@ -5205,20 +5209,22 @@ /* Left Edge of Overlay */ ChipsNew->MR[0x2A] = cPtr->OverlaySkewX; - ChipsNew->MR[0x2B] &= 0xF8; + ChipsNew->MR[0x2B] &= 0xF8; /* Mask reserved bits */ + ChipsNew->MR[0x2B] |= ((cPtr->OverlaySkewX >> 8) & 0x7); /* Right Edge of Overlay */ ChipsNew->MR[0x2C] = (cPtr->OverlaySkewX + pScrn->displayWidth - 1) & 0xFF; ChipsNew->MR[0x2D] &= 0xF8; /* Mask reserved bits */ - ChipsNew->MR[0x2D] = ((cPtr->OverlaySkewX + pScrn->displayWidth - + ChipsNew->MR[0x2D] |= ((cPtr->OverlaySkewX + pScrn->displayWidth - 1) >> 8) & 0x07; /* Top Edge of Overlay */ ChipsNew->MR[0x2E] = cPtr->OverlaySkewY; ChipsNew->MR[0x2F] &= 0xF8; + ChipsNew->MR[0x2F] |= ((cPtr->OverlaySkewY >> 8) & 0x7); /* Bottom Edge of Overlay*/ ChipsNew->MR[0x30] = (cPtr->OverlaySkewY + pScrn->virtualY - 1 )& 0xFF; ChipsNew->MR[0x31] &= 0xF8; /* Mask reserved bits */ - ChipsNew->MR[0x31] = ((cPtr->OverlaySkewY + pScrn->virtualY - + ChipsNew->MR[0x31] |= ((cPtr->OverlaySkewY + pScrn->virtualY - 1 ) >> 8) & 0x07; ChipsNew->MR[0x3C] &= 0x18; /* Mask reserved bits */ @@ -5230,7 +5236,9 @@ ChipsNew->MR[0x41] = 0xFF; ChipsNew->MR[0x42] = 0x00; } else if (cPtr->Flags & ChipsVideoSupport) { +#if 0 ChipsNew->XR[0xD0] |= 0x10; /* Force the Multimedia engine on */ +#endif ChipsNew->XR[0x4F] = 0x2A; /* SAR04 >352 pixel overlay width */ ChipsNew->MR[0x3C] &= 0x18; /* Ensure that the overlay is off */ cPtr->VideoZoomMax = 0x100; @@ -5386,8 +5394,7 @@ | (((mode->CrtcVBlankStart) & 0x400) >> 6 ); /* set video mode */ - ChipsNew->XR[0x2B] = chipsVideoMode(pScrn->bitsPerPixel, - pScrn->weight.green, mode->CrtcHDisplay, mode->CrtcVDisplay); + ChipsNew->XR[0x2B] = chipsVideoMode(pScrn->depth, mode->CrtcHDisplay, mode->CrtcVDisplay); #ifdef DEBUG ErrorF("VESA Mode: %Xh\n", ChipsNew->XR[0x2B]); #endif @@ -5783,7 +5790,9 @@ FALSE)) cPtr->Accel.UseHWCursor = TRUE; /* H/W cursor forced */ else { - if ((cPtr->PanelSize.HDisplay != mode->CrtcHDisplay) + if (cPtr->PanelSize.HDisplay + && cPtr->PanelSize.VDisplay + && (cPtr->PanelSize.HDisplay != mode->CrtcHDisplay) && (cPtr->PanelSize.VDisplay != mode->CrtcVDisplay)) { /* Possible H/W bug? */ if(cPtr->Accel.UseHWCursor) @@ -5808,10 +5817,8 @@ } /* set video mode */ - ChipsNew->XR[0x2B] = chipsVideoMode(pScrn->bitsPerPixel, - pScrn->weight.green, (cPtr->PanelType & ChipsLCD) ? - min(HDisplay, cPtr->PanelSize.HDisplay) : HDisplay, - cPtr->PanelSize.VDisplay); + ChipsNew->XR[0x2B] = chipsVideoMode(pScrn->depth, (cPtr->PanelType & ChipsLCD) ? + min(HDisplay, cPtr->PanelSize.HDisplay) : HDisplay,cPtr->PanelSize.VDisplay); #ifdef DEBUG ErrorF("VESA Mode: %Xh\n", ChipsNew->XR[0x2B]); #endif @@ -5971,6 +5978,12 @@ CHIPSPtr cPtr = CHIPSPTR(pScrn); unsigned char tmp = 0; + /* Before we do anything, if using dual channel set the IOSS/MSS regs */ + if (cPtr->Flags & ChipsDualChannelSupport) { + cPtr->writeIOSS(cPtr,ChipsReg->IOSS); + cPtr->writeMSS(cPtr,ChipsReg->MSS); + } + /*vgaHWProtect(pScrn, TRUE);*/ /* set registers so that we can program the controller */ @@ -6002,7 +6015,27 @@ /* set extended regs */ chipsRestoreExtendedRegs(pScrn, ChipsReg); + #if 0 + /* + * If we are using the multimedia engine with the 69030, make sure only + * pipeline A's multimedia engine is on + */ + if (cPtr->Flags & ChipsDualChannelSupport) { + unsigned char IOSS, MSS, tmpXRD0; + IOSS = cPtr->readIOSS(cPtr); + MSS = cPtr->readMSS(cPtr); + cPtr->writeIOSS(cPtr,((IOSS&0xE0) | 0x11)); /* Select Pipeline B */ + cPtr->writeMSS(cPtr,((MSS&0xF0) | 0x8)); + + tmpXRD0 = cPtr->readXR(cPtr, 0xD0); + cPtr->writeXR(cPtr, 0xD0, (tmpXRD0 & 0xEF)); + cPtr->writeIOSS(cPtr,IOSS); + cPtr->writeMSS(cPtr,MSS); + } +#endif + +#if 0 /* if people complain about lock ups or blank screens -- reenable */ /* set CRTC registers - do it before sequencer restarts */ for (i=0; i<25; i++) @@ -6097,15 +6130,18 @@ if ((cPtr->readXR(cPtr, i)) != Regs->XR[i]) cPtr->writeXR(cPtr, i, Regs->XR[i]); } - for (i = 0; i < 0x2; i++) { - if ((cPtr->readFR(cPtr, i)) != Regs->FR[i]) - cPtr->writeFR(cPtr, i, Regs->FR[i]); - } - tmp = cPtr->readFR(cPtr, 0x03); /* restore the non clock bits */ - cPtr->writeFR(cPtr, 0x03, ((Regs->FR[0x03] & 0xC3) | (tmp & ~0xC3))); - i++; - /* Don't touch alternate clock select reg. */ - for (; i < 0x80; i++) { + + for (i = 0; i < 0x80; i++) { + /* Don't touch alternate clock select reg. */ + if ((i == 0x01) && (cPtr->Chipset == CHIPS_CT69030)) + continue; + if ((i == 0x03) && (cPtr->Chipset != CHIPS_CT69030)) { + /* restore the non clock bits */ + tmp = cPtr->readFR(cPtr, 0x03); + cPtr->writeFR(cPtr, 0x03, ((Regs->FR[0x03] & 0xC3) | + (tmp & ~0xC3))); + continue; + } if ( (i == 0x40) || (i==0x48)) { /* !! set stretching but disable compensation */ cPtr->writeFR(cPtr, i, Regs->FR[i] & 0xFE); @@ -6154,16 +6190,16 @@ /* debug - dump out all the extended registers... */ if (IS_HiQV(cPtr)) { for (i = 0; i < 0xFF; i++) { - ErrorF("XR%X - %X : %X\n", i, ChipsReg->XR[i], + ErrorF("XR%X - %X : %X\n", i, Regs->XR[i], cPtr->readXR(cPtr, i)); } for (i = 0; i < 0x80; i++) { - ErrorF("FR%X - %X : %X\n", i, ChipsReg->FR[i], + ErrorF("FR%X - %X : %X\n", i, Regs->FR[i], cPtr->readFR(cPtr, i)); } } else { for (i = 0; i < 0x80; i++) { - ErrorF("XR%X - %X : %X\n", i, ChipsReg->XR[i], + ErrorF("XR%X - %X : %X\n", i, Regs->XR[i], cPtr->readXR(cPtr, i)); } } @@ -6194,7 +6230,7 @@ } static int -chipsVideoMode(int vgaBitsPerPixel, int weightGreen, int displayHSize, +chipsVideoMode(int depth, int displayHSize, int displayVSize) { /* 4 bpp 8 bpp 16 bpp 18 bpp 24 bpp 32 bpp */ @@ -6209,7 +6245,7 @@ int videoMode = 0; - switch (vgaBitsPerPixel) { + switch (depth) { case 1: case 4: videoMode = 0x20; @@ -6217,11 +6253,12 @@ case 8: videoMode = 0x30; break; - case 16: + case 15: videoMode = 0x40; - if (weightGreen != 5) - videoMode |= 0x01; break; + case 16: + videoMode = 0x41; + break; default: videoMode = 0x50; break; @@ -6241,13 +6278,9 @@ break; case 1280: videoMode |= 0x08; - if (vgaBitsPerPixel == 16) - videoMode |= 0x01; break; case 1600: - videoMode |= 0x0C; - if (vgaBitsPerPixel == 16) - videoMode |= 0x01; + videoMode |= 0x0C; /*0x0A??*/ break; } @@ -6288,18 +6321,19 @@ if (cPtr->MMIOBase == NULL) return FALSE; } - - if (cPtr->Bus == ChipsPCI) - cPtr->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - cPtr->PciTag, (unsigned long)cPtr->FbAddress, - cPtr->FbMapSize); - else - cPtr->FbBase = xf86MapVidMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - (unsigned long)cPtr->FbAddress, cPtr->FbMapSize); + if (cPtr->FbMapSize) { + if (cPtr->Bus == ChipsPCI) + cPtr->FbBase = xf86MapPciMem(pScrn->scrnIndex,VIDMEM_FRAMEBUFFER, + cPtr->PciTag, (unsigned long)cPtr->FbAddress, + cPtr->FbMapSize); + else + cPtr->FbBase = xf86MapVidMem(pScrn->scrnIndex,VIDMEM_FRAMEBUFFER, + (unsigned long)cPtr->FbAddress, + cPtr->FbMapSize); - if (cPtr->FbBase == NULL) - return FALSE; - + if (cPtr->FbBase == NULL) + return FALSE; + } if (cPtr->Flags & ChipsFullMMIOSupport) cPtr->MMIOBaseVGA = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,cPtr->PciTag, Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h:1.27 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h:1.30 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h:1.27 Tue Apr 4 15:25:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h Mon Oct 23 08:10:13 2000 @@ -22,7 +22,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h,v 1.27 2000/04/04 19:25:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h,v 1.30 2000/10/23 12:10:13 alanh Exp $ */ #ifndef _CT_DRIVER_H_ @@ -105,11 +105,13 @@ #define ChipsTMEDSupport 0x00000040 #define ChipsGammaSupport 0x00000080 #define ChipsVideoSupport 0x00000100 +#define ChipsDualChannelSupport 0x00000200 /* Options flags for the C&T chipsets */ #define ChipsHWCursor 0x00001000 #define ChipsShadowFB 0x00002000 #define ChipsOverlay8plus16 0x00004000 +#define ChipsUseNewFB 0x00008000 /* Architecture type flags */ #define ChipsHiQV 0x00010000 @@ -156,6 +158,8 @@ unsigned char CR[0x80]; unsigned char FR[0x80]; unsigned char MR[0x80]; + unsigned char MSS; + unsigned char IOSS; CHIPSClockReg Clock; } CHIPSRegRec, *CHIPSRegPtr; @@ -226,6 +230,10 @@ typedef void (*chipsWriteFRPtr)(CHIPSPtr cPtr, CARD8 index, CARD8 value); typedef CARD8 (*chipsReadMRPtr)(CHIPSPtr cPtr, CARD8 index); typedef void (*chipsWriteMRPtr)(CHIPSPtr cPtr, CARD8 index, CARD8 value); +typedef CARD8 (*chipsReadMSSPtr)(CHIPSPtr cPtr); +typedef void (*chipsWriteMSSPtr)(CHIPSPtr cPtr, CARD8 value); +typedef CARD8 (*chipsReadIOSSPtr)(CHIPSPtr cPtr); +typedef void (*chipsWriteIOSSPtr)(CHIPSPtr cPtr, CARD8 value); /* The privates of the C&T driver */ #define CHIPSPTR(p) ((CHIPSPtr)((p)->driverPrivate)) @@ -236,7 +244,7 @@ int Chipset; EntityInfoPtr pEnt; CARD32 IOAddress; - CARD32 FbAddress; + unsigned long FbAddress; unsigned int IOBase; unsigned char * FbBase; unsigned char * MMIOBase; @@ -254,6 +262,7 @@ Bool SyncResetIgn; Bool UseMMIO; Bool UseFullMMIO; + Bool UseDualChannel; int Monitor; int MinClock; int MaxClock; @@ -307,6 +316,10 @@ chipsWriteFRPtr writeFR; chipsReadMRPtr readMR; chipsWriteMRPtr writeMR; + chipsReadMSSPtr readMSS; + chipsWriteMSSPtr writeMSS; + chipsReadIOSSPtr readIOSS; + chipsWriteIOSSPtr writeIOSS; } CHIPSRec; typedef struct _CHIPSi2c { Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c:1.3 Tue Apr 4 15:25:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c Fri Sep 22 07:35:48 2000 @@ -19,7 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c,v 1.3 2000/04/04 19:25:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c,v 1.5 2000/09/22 11:35:48 alanh Exp $ */ /* * The functions in this file are used to read/write the C&T extension register @@ -73,6 +73,8 @@ #define CHIPS_MONO_STAT_1 0x3BA #define CHIPS_STAT_0 0x3BA +#define CHIPS_MSS 0x3CB +#define CHIPS_IOSS 0x3CD #define CHIPS_FR_INDEX 0x3D0 #define CHIPS_FR_DATA 0x3D1 #define CHIPS_MR_INDEX 0x3D2 @@ -96,7 +98,9 @@ #define CHIPS_MMIO_DAC_WRITE_ADDR 0x790 #define CHIPS_MMIO_DAC_DATA 0x791 #define CHIPS_MMIO_FEATURE_R 0x794 +#define CHIPS_MMIO_MSS 0x795 #define CHIPS_MMIO_MISC_OUT_R 0x798 +#define CHIPS_MMIO_IOSS 0x799 #define CHIPS_MMIO_GRAPH_INDEX 0x79C #define CHIPS_MMIO_GRAPH_DATA 0x79D #define CHIPS_MMIO_FR_INDEX 0x7A0 @@ -112,7 +116,7 @@ /* * PIO Access to the C&T extension registers */ -static void +void chipsStdWriteXR(CHIPSPtr cPtr, CARD8 index, CARD8 value) { outb(CHIPS_XR_INDEX, index); @@ -154,6 +158,30 @@ return inb(CHIPS_MR_DATA); } +static void +chipsStdWriteMSS(CHIPSPtr cPtr, CARD8 value) +{ + outb(CHIPS_MSS, value); +} + +static CARD8 +chipsStdReadMSS(CHIPSPtr cPtr) +{ + return inb(CHIPS_MSS); +} + +static void +chipsStdWriteIOSS(CHIPSPtr cPtr, CARD8 value) +{ + outb(CHIPS_IOSS, value); +} + +static CARD8 +chipsStdReadIOSS(CHIPSPtr cPtr) +{ + return inb(CHIPS_IOSS); +} + void CHIPSSetStdExtFuncs(CHIPSPtr cPtr) { @@ -163,6 +191,10 @@ cPtr->readMR = chipsStdReadMR; cPtr->writeXR = chipsStdWriteXR; cPtr->readXR = chipsStdReadXR; + cPtr->writeMSS = chipsStdWriteMSS; + cPtr->readMSS = chipsStdReadMSS; + cPtr->writeIOSS = chipsStdWriteIOSS; + cPtr->readIOSS = chipsStdReadIOSS; } /* @@ -214,6 +246,30 @@ return chipsminb(CHIPS_MMIO_MR_DATA); } +static void +chipsMmioWriteMSS(CHIPSPtr cPtr, CARD8 value) +{ + chipsmoutb(CHIPS_MMIO_MSS, value); +} + +static CARD8 +chipsMmioReadMSS(CHIPSPtr cPtr) +{ + return chipsminb(CHIPS_MMIO_MSS); +} + +static void +chipsMmioWriteIOSS(CHIPSPtr cPtr, CARD8 value) +{ + chipsmoutb(CHIPS_MMIO_IOSS, value); +} + +static CARD8 +chipsMmioReadIOSS(CHIPSPtr cPtr) +{ + return chipsminb(CHIPS_MMIO_IOSS); +} + void CHIPSSetMmioExtFuncs(CHIPSPtr cPtr) { @@ -223,6 +279,10 @@ cPtr->readMR = chipsMmioReadMR; cPtr->writeXR = chipsMmioWriteXR; cPtr->readXR = chipsMmioReadXR; + cPtr->writeMSS = chipsMmioWriteMSS; + cPtr->readMSS = chipsMmioReadMSS; + cPtr->writeIOSS = chipsMmioWriteIOSS; + cPtr->readIOSS = chipsMmioReadIOSS; } /* Index: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c:1.2 Thu Apr 6 23:57:50 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c Fri Sep 22 07:35:48 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c,v 1.2 2000/04/07 03:57:50 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c,v 1.5 2000/09/22 11:35:48 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -15,6 +15,7 @@ #include "xaa.h" #include "xaalocal.h" #include "dixstruct.h" +#include "fourcc.h" #define OFF_DELAY 200 /* milliseconds */ #define FREE_DELAY 60000 @@ -152,40 +153,8 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, XvTopToBottom }, - { - 0x32315659, - XvYUV, - LSBFirst, - {'Y','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 3, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { - 0x32595559, - XvYUV, - LSBFirst, - {'Y','U','Y','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','U','Y','V', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - } + XVIMAGE_YV12, + XVIMAGE_YUY2 }; typedef struct { @@ -302,9 +271,6 @@ cPtr->adaptor = adapt; - cPtr->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = CHIPSBlockHandler; - xvColorKey = MAKE_ATOM("XV_COLORKEY"); CHIPSResetVideo(pScrn); @@ -422,25 +388,31 @@ { CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data; CHIPSPtr cPtr = CHIPSPTR(pScrn); - unsigned char mr3c; + unsigned char mr3c, tmp; + ErrorF("StopVideo\n"); REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - CHIPSHiQVSync(pScrn); if(exit) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + ErrorF("StopVideo Exit\n"); mr3c = cPtr->readMR(cPtr, 0x3C); cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE)); + tmp = cPtr->readXR(cPtr, 0xD0); + cPtr->writeXR(cPtr, 0xD0, (tmp & 0xf)); } if(pPriv->area) { xf86FreeOffscreenArea(pPriv->area); pPriv->area = NULL; } pPriv->videoStatus = 0; + pScrn->pScreen->BlockHandler = cPtr->BlockHandler; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { pPriv->videoStatus |= OFF_TIMER; pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + cPtr->BlockHandler = pScrn->pScreen->BlockHandler; + pScrn->pScreen->BlockHandler = CHIPSBlockHandler; } } } @@ -638,6 +610,10 @@ CHIPSHiQVSync(pScrn); + ErrorF("DisplayVideo\n"); + tmp = cPtr->readXR(cPtr, 0xD0); + cPtr->writeXR(cPtr, 0xD0, (tmp | 0x10)); + tmp = cPtr->readMR(cPtr, 0x1E); tmp &= 0xE0; /* Set Zoom and Direction */ if ((!(cPtr->PanelType & ChipsLCD)) && (mode->Flags & V_INTERLACE)) @@ -652,10 +628,10 @@ case 0x36315652: /* RGB16 */ tmp |= 0x08; break; - case 0x32315659: /* YV12 */ - tmp |= 0x00; + case FOURCC_YV12: /* YV12 */ + tmp |= 0x03; break; - case 0x32595559: /* YUY2 */ + case FOURCC_YUY2: /* YUY2 */ default: tmp |= 0x00; /* Do nothing here */ break; @@ -721,6 +697,7 @@ tmp = cPtr->readMR(cPtr, 0x3C); cPtr->writeMR(cPtr, 0x3C, (tmp | 0x7)); + CHIPSHiQVSync(pScrn); } static int @@ -745,6 +722,9 @@ BoxRec dstBox; CARD32 tmp; + if (pScrn->pScreen->BlockHandler == CHIPSBlockHandler) + pScrn->pScreen->BlockHandler = cPtr->BlockHandler; + if(drw_w > 16384) drw_w = 16384; /* Clip */ @@ -775,23 +755,19 @@ new_h = ((dstPitch * height) + pitch - 1) / pitch; switch(id) { - case 0x32315659: /* YV12 */ + case FOURCC_YV12: /* YV12 */ srcPitch = (width + 3) & ~3; offset2 = srcPitch * height; srcPitch2 = ((width >> 1) + 3) & ~3; offset3 = (srcPitch2 * (height >> 1)) + offset2; break; - case 0x35315652: /* RGB15 */ - case 0x36315652: /* RGB16 */ - case 0x32595559: /* YUY2 */ - default: + default: /* RGB15, RGB16, YUY2 */ srcPitch = (width << 1); break; } if(!(pPriv->area = CHIPSAllocateMemory(pScrn, pPriv->area, new_h))) return BadAlloc; - /* copy data */ top = y1 >> 16; left = (x1 >> 16) & ~1; @@ -802,8 +778,8 @@ dst_start = cPtr->FbBase + offset + left; switch(id) { - case 0x32315659: /* YV12 */ - top &= ~1; + case FOURCC_YV12: /* YV12 */ + top &= ~1; tmp = ((top >> 1) * srcPitch2) + (left >> 2); offset2 += tmp; offset3 += tmp; @@ -812,10 +788,7 @@ buf + offset2, buf + offset3, dst_start, srcPitch, srcPitch2, dstPitch, nlines, npixels); break; - case 0x35315652: /* RGB15 */ - case 0x36315652: /* RGB16 */ - case 0x32595559: /* YUY2 */ - default: + default: /* RGB15, RGB16, YUY2 */ buf += (top * srcPitch) + left; nlines = ((y2 + 0xffff) >> 16) - top; CHIPSCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); @@ -855,7 +828,7 @@ if(offsets) offsets[0] = 0; switch(id) { - case 0x32315659: /* YV12 */ + case FOURCC_YV12: /* YV12 */ *h = (*h + 1) & ~1; size = (*w + 3) & ~3; if(pitches) pitches[0] = size; @@ -868,10 +841,7 @@ if(offsets) offsets[2] = size; size += tmp; break; - case 0x35315652: /* RGB15 */ - case 0x36315652: /* RGB16 */ - case 0x32595559: /* YUY2 */ - default: + default: /* RGB15, RGB16, YUY2 */ size = *w << 1; if(pitches) pitches[0] = size; size *= *h; @@ -900,11 +870,11 @@ pScreen->BlockHandler = CHIPSBlockHandler; - CHIPSHiQVSync(pScrn); if(pPriv->videoStatus & TIMER_MASK) { UpdateCurrentTime(); if(pPriv->videoStatus & OFF_TIMER) { if(pPriv->offTime < currentTime.milliseconds) { + CHIPSHiQVSync(pScrn); mr3c = cPtr->readMR(cPtr, 0x3C); cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE)); pPriv->videoStatus = FREE_TIMER; @@ -917,6 +887,7 @@ pPriv->area = NULL; } pPriv->videoStatus = 0; + pScreen->BlockHandler = cPtr->BlockHandler; } } } @@ -988,7 +959,9 @@ if(pPriv->isOn) { CHIPSPtr cPtr = CHIPSPTR(surface->pScrn); - unsigned char mr3c; + unsigned char mr3c, tmp; + tmp = cPtr->readXR(cPtr, 0xD0); + cPtr->writeXR(cPtr, 0xD0, (tmp & 0xf)); mr3c = cPtr->readMR(cPtr, 0x3C); cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE)); pPriv->isOn = FALSE; Index: xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c:1.4 Sun Apr 4 04:46:14 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c Fri Sep 22 07:35:49 2000 @@ -4,7 +4,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c,v 1.4 1999/04/04 08:46:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/dRegs.c,v 1.6 2000/09/22 11:35:49 alanh Exp $ */ #ifdef __NetBSD__ # include <sys/types.h> @@ -65,9 +65,10 @@ { int i, HTotal, HDisplay, HSyncStart, HSyncEnd, VTotal, VDisplay, VSyncStart, VSyncEnd, Clock; - unsigned char storeReg, bpp, shift; + unsigned char storeReg, bpp, shift, IOSS, MSS, again; unsigned short port; int isHiQV = 0; + int is69030 = 0; SET_IOPL(); @@ -83,19 +84,33 @@ || storeReg == 0xC0) /* CT69000 */ { isHiQV = 1; + } else if (storeReg == 0x30) { + outb(0x3D6,0x03); + storeReg = inb(0x3D7); + if (storeReg == 0xC) { + isHiQV = 1; + is69030 = 1; + IOSS=inb(0x3CD); + MSS=inb(0x3CB); + outb(0x3CD,((IOSS&0xE0)| 0x11)); /* Select Channel 0 */ + outb(0x3CB,((MSS&0xF0)| 0x8)); + again = 1; + printf("Pipeline A:\n"); + } } + again: printf("port 0x3D6 (C&T)\n"); storeReg = inb(0x3D6); shift = 3; if (isHiQV==1) { outw(0x102,1); /*global enable, VGA awake*/ - printf("0x%2X\n",inb(0x3C3)&0xFF); + printf("0x%2.2X\n",inb(0x3C3)&0xFF); outb(0x3C3,0); /*disable VGA*/ outb(0x3C3,1); /*enable VGA*/ for(i = 0;i < 0xFF;i++){ outb(0x3D6,i); - printf("XR 0x%2X\t0x%X\n",i,inb(0x3D7)&0xFF); + printf("XR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D7)&0xFF); } outb(0x3D6,0xE2); bpp = inb(0x3D7)&0xF0; @@ -105,7 +120,7 @@ outw(0x46E8,0x0016); /*setup mode*/ outw(0x102,1); /*global enable, VGA awake*/ outw(0x46E8,0x000E); /*exit from setup mode*/ - printf("0x%2X\n",inb(0x3C3)&0xFF); + printf("0x%2.2X\n",inb(0x3C3)&0xFF); outb(0x3C3,0); /*disable VGA*/ outw(0x46E8,0x0000); /*exit from setup mode*/ outw(0x46E8,0x000E); /*exit from setup mode*/ @@ -113,7 +128,7 @@ outw(0x46E8,0x0000); /*exit from setup mode*/ for(i = 0;i < 0x80;i++){ outb(0x3D6,i); - printf("XR 0x%2X\t0x%X\n",i,inb(0x3D7)&0xFF); + printf("XR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D7)&0xFF); } outb(0x3D6,0x2B); bpp = inb(0x3D7)&0xF0; @@ -143,27 +158,27 @@ if (isHiQV==1) { for(i = 0;i < 0x7F;i++){ outb(0x3D4,i); - printf("CR 0x%2X\t0x%X\n",i,inb(0x3D5)&0xFF); + printf("CR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D5)&0xFF); } outb(0x3D4,storeReg); printf("\nport 0x3D0 (Flat Panel)\n"); storeReg = inb(0x3D0); for(i = 0;i < 0x7F;i++){ outb(0x3D0,i); - printf("FR 0x%2X\t0x%X\n",i,inb(0x3D1)&0xFF); + printf("FR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D1)&0xFF); } outb(0x3D1,storeReg); printf("\nport 0x3D2 (Multimedia)\n"); storeReg = inb(0x3D2); for(i = 0;i < 0x7F;i++){ outb(0x3D2,i); - printf("MR 0x%2X\t0x%X\n",i,inb(0x3D3)&0xFF); + printf("MR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D3)&0xFF); } outb(0x3D3,storeReg); } else { for(i = 0;i < 0x40;i++){ outb(0x3D4,i); - printf("CR 0x%2X\t0x%X\n",i,inb(0x3D5)&0xFF); + printf("CR 0x%2.2X\t0x%2.2X\n",i,inb(0x3D5)&0xFF); } outb(0x3D4,storeReg); } @@ -173,14 +188,14 @@ storeReg = inb(0x3CE); for(i = 0;i < 0x10;i++){ outb(0x3CE,i); - printf("GC 0x%2X\t0x%X\n",i,inb(0x3CF)&0xFF); + printf("GC 0x%2.2X\t0x%X2.2\n",i,inb(0x3CF)&0xFF); } outb(0x3CE,storeReg); printf("port 0x3C4 (Sequencer)\n"); storeReg = inb(0x3C4); for(i = 0;i < 0x10;i++){ outb(0x3C4,i); - printf("SQ 0x%2X\t0x%X\n",i,inb(0x3C5)&0xFF); + printf("SQ 0x%2.2X\t0x%X2.2\n",i,inb(0x3C5)&0xFF); } outb(0x3C4,storeReg); @@ -191,7 +206,7 @@ for(i = 0;i < 0xFF;i++){ inb(0x3DA); outb(0x3C0,i); - printf("AT 0x%2X\t0x%X\n",i,inb(0x3C1)&0xFF); + printf("AT 0x%2.2X\t0x%2.2X\n",i,inb(0x3C1)&0xFF); } inb(0x3DA); outb(0x3C0,storeReg); @@ -210,12 +225,12 @@ if (isHiQV!=1) { printf("\nBitBLT\nport\tvalue\n"); for(port = 0x83D0; port <= 0x9FD0;port+=0x400){ - printf("0x%4X\t0x%4X\n",port,inw(port)); + printf("0x%4.4X\t0x%4X\n",port,inw(port)); } printf("\nH/W cursor\nport\tvalue\n"); for(port = 0xA3D0; port <= 0xB3D0;port+=0x400){ - printf("0x%4X\t0x%4X\n",port,inw(port)); + printf("0x%4.4X\t0x%4X\n",port,inw(port)); } @@ -270,6 +285,21 @@ HDisplay, HSyncStart, HSyncEnd, HTotal, VDisplay, VSyncStart, VSyncEnd, VTotal); + + if (is69030==1) { + if (again==1) { + again=0; + printf("\n\nPipeline B:\n"); + outb(0x3CD,((IOSS&0xE0)| 0x1F)); /* Select Channel 1 */ + outb(0x3CB,((MSS&0xF0)| 0xF)); + goto again; + } else { + outb(0x3CD,IOSS); + outb(0x3CB,MSS); + printf("\n\n0x3CB\t0x%X (MSS)\n",inb(0x3CB)&0xFF); + printf("0x3CD\t0x%X (IOSS)\n",inb(0x3CD)&0xFF); + } + } RESET_IOPL(); } Index: xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c:1.4 Fri Apr 28 14:19:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c Mon Oct 23 08:10:13 2000 @@ -4,7 +4,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c,v 1.4 2000/04/28 18:19:23 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c,v 1.5 2000/10/23 12:10:13 alanh Exp $ */ #ifdef __NetBSD__ # include <sys/types.h> @@ -68,11 +68,11 @@ int i, value, index; char c, cport; char* str; - unsigned int port; + unsigned int port, port1; int query = 0; if(argc < 2) { - printf("usage: %s Cvvxx [Cvvxx]\n",argv[0]); + printf("usage: %s [Cvvxx [Cvvxx]] [Dxx]\n",argv[0]); printf(" where C = A|a write vv to ARxx\n"); printf(" = C|c write vv to CRxx\n"); printf(" = F|f write vv to FRxx (6555x only)\n"); @@ -80,6 +80,8 @@ printf(" = M|m write vv to MRxx (6555x only)\n"); printf(" = S|s write vv to SRxx\n"); printf(" = X|x write vv to XRxx\n"); + printf(" where D = Y|y write xx to FCR\n"); + printf(" = Z|z write vv to MSR\n"); printf(" xx is in hexadecimal\n"); printf(" vv is in hexadecimal or '?' for query\n"); } @@ -127,11 +129,23 @@ cport = 'M'; port = 0x3D2; break; + case 'y': + case 'Y': + cport = 'Y'; + port = 0x3DA; + port1 = 0x3CA; + break; + case 'z': + case 'Z': + cport = 'Z'; + port = 0x3C2; + port1 = 0x3CC; + break; default: continue; break; } - index = inb(port); + if ((cport != 'Z') && (cport != 'Y')) index = inb(port); while (c = *str++){ if (c == '?') { query = 1; @@ -143,15 +157,29 @@ else if(c >= 'a' && c < 'g') value = (value << 4) | (c - 'a'+10); /*ASCII assumed*/ } - outb(port,value&0xFF); + if ((cport != 'Z') && (cport != 'Y')) outb(port,value&0xFF); if (query) { - printf("%cR%X: 0x%X\n", cport, value & 0xFF, + if ((cport != 'Z') && (cport != 'Y')) + printf("%cR%X: 0x%X\n", cport, value & 0xFF, inb(port+1)&0xFF); + else + if (cport == 'Z') + printf("MSR: 0x%X\n", inb(port1)&0xFF); + else + printf("FCR: 0x%X\n", inb(port1)&0xFF); } else { - printf("%cR%X: 0x%X -> 0x%X\n", cport, value & 0xFF, + if ((cport != 'Z') && (cport != 'Y')) { + printf("%cR%X: 0x%X -> 0x%X\n", cport, value & 0xFF, inb(port+1)&0xFF, (value&0xFF00)>>8); - outw(port, value); - outb(port, index &0xFF); + outw(port, value); + outb(port, index &0xFF); + } else { + if (cport == 'Z') + printf("MSR: 0x%X -> 0x%X\n", inb(port1)&0xFF, value&0xFF); + else + printf("FCR: 0x%X -> 0x%X\n", inb(port1)&0xFF, value&0xFF); + outb(port, value & 0xFF); + } } } RESET_IOPL(); Index: xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c diff -u xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c:1.3 Sun Apr 4 04:46:14 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c Fri Sep 22 07:35:49 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c,v 1.3 1999/04/04 08:46:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/modClock.c,v 1.4 2000/09/22 11:35:49 alanh Exp $ */ #ifdef __NetBSD__ # include <sys/types.h> @@ -197,6 +197,7 @@ #define CT65555 0x33 #define CT68554 0x34 #define CT69000 0x35 +#define CT69030 0x36 #define IS_Programmable(X) X&0x10 #define IS_HiQV(X) X&0x20 @@ -333,6 +334,11 @@ } if (temp == 0xC0) { ChipType = CT69000; + } + if (temp == 0x30) { + outb(0x3D6, 0x03); + temp = inb(0x03D7); + if (temp == 0x0C) ChipType = CT69030; } } Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile:1.28 xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile:1.30 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile:1.28 Fri Mar 31 17:55:39 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile Wed Dec 6 10:35:14 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile,v 1.28 2000/03/31 22:55:39 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile,v 1.30 2000/12/06 15:35:14 eich Exp $ XCOMM XCOMM This is an Imakefile for the Cirrus Logic driver. XCOMM @@ -22,14 +22,15 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa \ -I$(XF86SRC)/ramdac -I$(XF86SRC)/i2c \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc \ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp \ -I$(FONTINCSRC) -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) \ - -I$(XF86OSSRC)/int10 -I$(XF86SRC)/shadowfb + -I$(XF86OSSRC)/int10 -I$(XF86SRC)/shadowfb \ + -I$(SERVERSRC)/render -I$(XF86OSSRC)/vbe #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h:1.2 Tue Feb 8 08:13:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h Wed Dec 6 10:35:15 2000 @@ -1,12 +1,14 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h,v 1.2 2000/02/08 13:13:13 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h,v 1.4 2000/12/06 15:35:15 eich Exp $ */ /* (c) Itai Nahshon */ #ifndef ALP_H #define ALP_H -#undef ALP_DEBUG +extern ScrnInfoPtr AlpProbe(int entity); +extern OptionInfoPtr AlpAvailableOptions(int chipid); +# ifdef _ALP_PRIVATE_ /* Saved registers that are not part of the core VGA */ /* CRTC >= 0x19; Sequencer >= 0x05; Graphics >= 0x09; Attribute >= 0x15 */ @@ -20,7 +22,10 @@ SR0E, SR12, SR13, + SR17, SR1E, + SR21, + SR2D, /* GR regs */ GR17, GR18, @@ -52,10 +57,22 @@ int CursorWidth; int CursorHeight; int waitMsk; + int scanlineDest; + int scanlineCount; + int scanlineWidth; + + int SubsequentColorExpandScanlineDest; + int SubsequentColorExpandScanlineByteWidth; + int SubsequentColorExpandScanlineDWordWidth; + + /* Offset into framebuffer of a 8-byte scratch area for fills */ + CARD32 monoPattern8x8; + Bool autoStart; /* XXX For XF86Config based mem configuration */ CARD32 sr0f, sr17; } AlpRec, *AlpPtr; +# endif /* _ALP_PRIVATE_ */ #endif /* ALP_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c:1.11 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c:1.11 Wed Jun 21 13:28:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c Thu Dec 7 10:43:44 2000 @@ -2,6 +2,8 @@ * Driver for CL-GD5480. * Itai Nahshon. * + * Support for the CL-GD7548: David Monniaux + * * This is mainly a cut & paste from the MGA driver. * Original autors and contributors list include: * Radoslaw Kapitan, Andrew Vanderstock, Dirk Hohndel, @@ -9,7 +11,7 @@ * Guy DESBIEF */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c,v 1.11 2000/06/21 17:28:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c,v 1.17 2000/12/07 15:43:44 tsi Exp $ */ /* All drivers should typically include these */ #include "xf86.h" @@ -45,19 +47,15 @@ /* Needed by the Shadow Framebuffer */ #include "shadowfb.h" -/* - * If using cfb, cfb.h is required. Select the others for the bpp values - * the driver supports. - */ +/* Note: can HWCUR64 be set even though the hw cursor is disabled for + want of memory ? */ + +/* Framebuffer memory manager */ +#include "xf86fbman.h" + #include "xf4bpp.h" #include "xf1bpp.h" -#define PSZ 8 /* needed for cfb.h */ -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" /* These need to be checked */ #if 0 @@ -71,6 +69,7 @@ #include "xf86int10.h" #include "cir.h" +#define _ALP_PRIVATE_ #include "alp.h" #ifdef XvExtension @@ -87,8 +86,6 @@ * Forward definitions for the functions that make up the driver. */ -ScrnInfoPtr AlpProbe(int entity); - /* Mandatory functions */ Bool AlpPreInit(ScrnInfoPtr pScrn, int flags); @@ -111,6 +108,8 @@ static void AlpRestore(ScrnInfoPtr pScrn); static Bool AlpModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void AlpProbeLCD(ScrnInfoPtr pScrn); + static void AlpSetClock(CirPtr pCir, vgaHWPtr hwp, int freq); #ifdef DPMSExtension @@ -151,6 +150,7 @@ static int gd5430_MaxClocks[] = { 85500, 85500, 50000, 28500, 0 }; static int gd5446_MaxClocks[] = { 135100, 135100, 85500, 85500, 0 }; static int gd5480_MaxClocks[] = { 135100, 200000, 200000, 135100, 135100 }; +static int gd7548_MaxClocks[] = { 80100, 80100, 80100, 80100, 80100 }; /* * List of symbols from other modules that this module references. This @@ -175,22 +175,12 @@ "vgaHWddc1SetSpeed", NULL }; - -static const char *cfbSymbols[] = { - "xf1bppScreenInit", - "xf4bppScreenInit", - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", - "cfb8_32ScreenInit", - "cfb24_32ScreenInit", - NULL -}; -static const char *xf8_32bppSymbols[] = { - "xf86Overlay8Plus32Init", - NULL +static const char *fbSymbols[] = { + "xf1bppScreenInit", + "xf4bppScreenInit", + "fbScreenInit", + NULL }; static const char *xaaSymbols[] = { @@ -273,8 +263,8 @@ static Bool setupDone = FALSE; if (!setupDone) { setupDone = TRUE; - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, - xf8_32bppSymbols, ramdacSymbols,int10Symbols, + LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols, + ramdacSymbols,int10Symbols, ddcSymbols, i2cSymbols, shadowSymbols, NULL); } return (pointer)1; @@ -357,10 +347,18 @@ pCir->IoMapSize = 0x4000; /* 16K for moment */ if (!CirMapMem(pCir, pScrn->scrnIndex)) return 0; - - if (pCir->UseMMIO) + + /* The 754x supports MMIO for the BitBlt engine but + not for the VGA registers */ + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + break; + default: + if (pCir->UseMMIO) vgaHWSetMmioFuncs(hwp, pCir->IOBase, -0x3C0); - + } + if (pCir->chip.alp->sr0f != (CARD32)-1) { from = X_CONFIG; hwp->writeSeq(hwp, 0x0F, pCir->chip.alp->sr0f); @@ -448,6 +446,10 @@ if (pCir->chip.alp->sr17 & 0x80) videoram <<= 1; break; + + case PCI_CHIP_GD7548: + videoram = 1024; /* TODO: actual size */ + break; } /* UNMap the Alp memory and MMIO areas */ @@ -511,11 +513,13 @@ MessageType from; int i; ClockRangePtr clockRanges; - char *mod = NULL; char *s; - if (flags & PROBE_DETECT) return FALSE; - + if (flags & PROBE_DETECT) { + cirProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index ); + return TRUE; + } + #ifdef ALP_DEBUG ErrorF("AlpPreInit\n"); #endif @@ -564,6 +568,13 @@ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); pInt = xf86InitInt10(pCir->pEnt->index); xf86FreeInt10(pInt); + /* + * This is a hack: We restore the PCI base regs as some Colorgraphic + * BIOSes tend to mess them up + */ + pciWriteLong(pCir->PciTag,0x10,pCir->PciInfo->memBase[0]); + pciWriteLong(pCir->PciTag,0x14,pCir->PciInfo->memBase[1]); + #endif } #endif @@ -621,23 +632,16 @@ if (!xf86SetDefaultVisual(pScrn, -1)) { return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } - + } /* Collect all of the relevant option flags (fill in pScrn->options) */ xf86CollectOptions(pScrn, NULL); /* Process the options */ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, CirOptions); - pScrn->rgbBits = 6; + if (pScrn->depth == 8) + pScrn->rgbBits = 6; + from = X_DEFAULT; pCir->HWCursor = FALSE; if (xf86GetOptValBool(CirOptions, OPTION_HW_CURSOR, &pCir->HWCursor)) @@ -775,6 +779,9 @@ xf86SetDDCproperties(pScrn,xf86PrintEDID( xf86DoEDID_DDC2(pScrn->scrnIndex,pCir->I2CPtr1))); + /* Probe the possible LCD display */ + AlpProbeLCD(pScrn); + #ifdef CIRPROBEI2C CirProbeI2C(pScrn->scrnIndex); #endif @@ -863,7 +870,12 @@ if ((pCir->chip.alp->sr0f & 0x18) > 0x8) pCir->properties |= HWCUR64; + switch (pCir->Chipset) { + case PCI_CHIP_GD7548: + pCir->properties |= HWCUR64; + pCir->properties |= ACCEL_AUTOSTART; + break; case PCI_CHIP_GD5436: case PCI_CHIP_GD5480: pCir->properties |= ACCEL_AUTOSTART; @@ -905,6 +917,9 @@ case PCI_CHIP_GD5480: p = gd5480_MaxClocks; break; + case PCI_CHIP_GD7548: + p = gd7548_MaxClocks; + break; } if (!p) return FALSE; @@ -954,8 +969,16 @@ clockRanges->ClockDivFactor = 1; clockRanges->PrivFlags = 0; - pCir->Rounding = 128 >> pCir->BppShift; + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + pCir->Rounding = 1; + break; + default: + pCir->Rounding = 128 >> pCir->BppShift; + } + #if 0 if (pCir->Chipset != PCI_CHIP_GD5446 && pCir->Chipset != PCI_CHIP_GD5480) { @@ -1033,21 +1056,33 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { - case 1: mod = "xf1bpp"; break; - case 4: mod = "xf4bpp"; break; - case 8: mod = "cfb"; break; - case 16: mod = "cfb16"; break; + case 1: + if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) { + AlpFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf1bppScreenInit",NULL); + break; + case 4: + if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) { + AlpFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf4bppScreenInit",NULL); + break; + case 8: + case 16: case 24: - if (pix24bpp == 24) - mod = "cfb24"; - else - mod = "xf24_32bpp"; - break; - case 32: mod = "cfb32"; break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - AlpFreeRec(pScrn); + case 32: + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + AlpFreeRec(pScrn); return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit",NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + break; } /* Load XAA if needed */ @@ -1100,7 +1135,10 @@ pCir->chip.alp->ModeReg.ExtVga[SR0E] = pCir->chip.alp->SavedReg.ExtVga[SR0E] = hwp->readSeq(hwp, 0x0E); pCir->chip.alp->ModeReg.ExtVga[SR12] = pCir->chip.alp->SavedReg.ExtVga[SR12] = hwp->readSeq(hwp, 0x12); pCir->chip.alp->ModeReg.ExtVga[SR13] = pCir->chip.alp->SavedReg.ExtVga[SR13] = hwp->readSeq(hwp, 0x13); + pCir->chip.alp->ModeReg.ExtVga[SR17] = pCir->chip.alp->SavedReg.ExtVga[SR17] = hwp->readSeq(hwp, 0x17); pCir->chip.alp->ModeReg.ExtVga[SR1E] = pCir->chip.alp->SavedReg.ExtVga[SR1E] = hwp->readSeq(hwp, 0x1E); + pCir->chip.alp->ModeReg.ExtVga[SR21] = pCir->chip.alp->SavedReg.ExtVga[SR21] = hwp->readSeq(hwp, 0x21); + pCir->chip.alp->ModeReg.ExtVga[SR2D] = pCir->chip.alp->SavedReg.ExtVga[SR2D] = hwp->readSeq(hwp, 0x2D); pCir->chip.alp->ModeReg.ExtVga[GR17] = pCir->chip.alp->SavedReg.ExtVga[GR17] = hwp->readGr(hwp, 0x17); pCir->chip.alp->ModeReg.ExtVga[GR18] = pCir->chip.alp->SavedReg.ExtVga[GR18] = hwp->readGr(hwp, 0x18); /* The first 4 reads are for the pixel mask register. After 4 times that @@ -1139,7 +1177,10 @@ hwp->writeSeq(hwp, 0x0E, cirReg->ExtVga[SR0E]); hwp->writeSeq(hwp, 0x12, cirReg->ExtVga[SR12]); hwp->writeSeq(hwp, 0x13, cirReg->ExtVga[SR13]); + hwp->writeSeq(hwp, 0x17, cirReg->ExtVga[SR17]); hwp->writeSeq(hwp, 0x1E, cirReg->ExtVga[SR1E]); + hwp->writeSeq(hwp, 0x21, cirReg->ExtVga[SR21]); + hwp->writeSeq(hwp, 0x2D, cirReg->ExtVga[SR2D]); hwp->writeGr(hwp, 0x17, cirReg->ExtVga[GR17]); hwp->writeGr(hwp, 0x18, cirReg->ExtVga[GR18]); /* The first 4 reads are for the pixel mask register. After 4 times that @@ -1234,7 +1275,16 @@ /* Turn off HW cursor, gamma correction, overscan color protect. */ pCir->chip.alp->ModeReg.ExtVga[SR12] = 0; if ((pCir->properties & HWCUR64) == HWCUR64) - pCir->chip.alp->ModeReg.ExtVga[SR12] = 0x4; + { + pCir->chip.alp->ModeReg.ExtVga[SR12] = 0x4; + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + pCir->chip.alp->ModeReg.ExtVga[SR21] |= 0x10; + break; + } + + } else pCir->chip.alp->ModeReg.ExtVga[SR12] = 0; @@ -1314,6 +1364,27 @@ else pCir->chip.alp->ModeReg.ExtVga[GR18] &= ~0x20; + + /* Some extra init stuff */ + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + /* Do we use MMIO ? + If we do and we are on a 7548, we need to tell the board + that we want MMIO. */ + if (pCir->UseMMIO) + { + pCir->chip.alp->ModeReg.ExtVga[SR17] = + (pCir->chip.alp->ModeReg.ExtVga[SR17] & ~0x40) | 4; + ErrorF("UseMMIO: SR17=%2X\n", (int) (pCir->chip.alp->ModeReg.ExtVga[SR17])); + } +#ifdef ALP_SETUP + ErrorF("SR2D=%2X\n", (int) (pCir->chip.alp->ModeReg.ExtVga[SR17])); +#endif + pCir->chip.alp->ModeReg.ExtVga[SR2D] |= 0xC0; + break; + } + /* No support for interlace (yet) */ pCir->chip.alp->ModeReg.ExtVga[CR1A] = 0x00; @@ -1382,6 +1453,7 @@ ScrnInfoPtr pScrn; vgaHWPtr hwp; CirPtr pCir; + AlpPtr pAlp; int i, ret; VisualPtr visual; int displayWidth,width,height; @@ -1398,7 +1470,8 @@ hwp = VGAHWPTR(pScrn); pCir = CIRPTR(pScrn); - + pAlp = ALPPTR(pCir); + /* Map the VGA memory when the primary video */ if (!vgaHWMapMem(pScrn)) return FALSE; @@ -1407,8 +1480,16 @@ if (!CirMapMem(pCir, pScrn->scrnIndex)) return FALSE; - if(pCir->UseMMIO) + /* The 754x supports MMIO for the BitBlt engine but + not for the VGA registers */ + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + break; + default: + if(pCir->UseMMIO) vgaHWSetMmioFuncs(hwp, pCir->IOBase, -0x3C0); + } vgaHWGetIOBase(hwp); @@ -1430,8 +1511,6 @@ * function. If not, the visuals will need to be setup before calling * a fb ScreenInit() function and fixed up after. * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. */ /* @@ -1441,27 +1520,13 @@ /* Setup the visuals we support. */ - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. To deal with this, call - * miSetVisualTypes with the appropriate visual mask. - */ -#ifdef ALP_DEBUG - ErrorF("AlpScreenInit before miSetVisualTypes\n"); -#endif - if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } -#ifdef ALP_DEBUG - ErrorF("AlpScreenInit after miSetVisualTypes\n"); -#endif + + miSetPixmapDepths (); + displayWidth = pScrn->displayWidth; if (pCir->rotate) { height = pScrn->virtualX; @@ -1500,34 +1565,13 @@ displayWidth); break; case 8: - ret = cfbScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 16: - ret = cfb16ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 32: - ret = cfb32ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); + ret = fbScreenInit(pScreen, FbBase, + width,height, + pScrn->xDpi, pScrn->yDpi, + displayWidth,pScrn->bitsPerPixel); break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -1538,6 +1582,9 @@ } if (!ret) return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif #ifdef ALP_DEBUG ErrorF("AlpScreenInit after depth dependent init\n"); @@ -1565,29 +1612,79 @@ */ xf86SetBlackWhitePixels(pScreen); - if (!pCir->NoAccel) { /* Initialize XAA functions */ - if (!(pCir->UseMMIO ? AlpXAAInitMMIO(pScreen) : - AlpXAAInit(pScreen))) - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not initialize XAA\n"); - } + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - if (pCir->HWCursor) { /* Initialize HW cursor layer */ - int offscreen_size = pScrn->videoRam * 1024 - - (BitmapBytePad(pScrn->displayWidth - * pScrn->bitsPerPixel) * pScrn->virtualY); - int cursor_size = 32; - if ((pCir->properties & HWCUR64) - && (offscreen_size >= 64*8*2)) - cursor_size = 64; - else if (offscreen_size < 32*4*2) - cursor_size = 0; - if (!AlpHWCursorInit(pScreen,cursor_size)) + /* Allocation of off-screen memory to various stuff + (hardware cursor, 8x8 mono pattern...) + Allocation goes top-down in memory, since the cursor + *must* be in the last videoram locations */ + { + int offscreen_offset = pScrn->videoRam*1024, + offscreen_size = pScrn->videoRam * 1024 - pScrn->virtualY * + (BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel)); + int cursor_size = 0; + +#ifdef ALP_DEBUG + ErrorF("offscreen_offset=%d, offscreen_size=%d\n", + offscreen_offset, offscreen_size); +#endif + + /* Initialise cursor functions */ + if (pCir->HWCursor) { /* Initialize HW cursor layer */ + if ((pCir->properties & HWCUR64) + && (offscreen_size >= 64*8*2)) + { + cursor_size = 64; + offscreen_size -= 64*8*2; + offscreen_offset -= 64*8*2; + } + else if (offscreen_size >= 32*4*2) + { + cursor_size = 32; + offscreen_size -= 32*8*2; + offscreen_offset -= 32*8*2; + } + if (!AlpHWCursorInit(pScreen, cursor_size)) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); + "Hardware cursor initialization failed\n"); + } +#ifdef ALP_DEBUG + ErrorF("AlpHWCursorInit complete.\n"); +#endif + if (offscreen_size >= 8 && !pCir->NoAccel && + pCir->Chipset == PCI_CHIP_GD7548) + { + offscreen_offset -= 8; + offscreen_size -= 8; + pAlp->monoPattern8x8 = offscreen_offset; +#ifdef ALP_DEBUG + ErrorF("monoPattern8x8=%d\n", pAlp->monoPattern8x8); +#endif + } + else pAlp->monoPattern8x8 = 0; + { + /* TODO: probably not correct if rotated */ + BoxRec box; + box.x1=0; + box.y1=0; + box.x2=pScrn->virtualX; + box.y2=offscreen_offset / pCir->pitch; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d lines for offscreen memory\n", + box.y2 - pScrn->virtualY); + } + + } + + if (!pCir->NoAccel) { /* Initialize XAA functions */ + if (!(pCir->UseMMIO ? AlpXAAInitMMIO(pScreen) : + AlpXAAInit(pScreen))) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not initialize XAA\n"); } + #if 0 if (!AlpDGAInit(pScreen)) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DGA initialization failed\n"); @@ -1760,10 +1857,12 @@ vgaHWPtr hwp = VGAHWPTR(pScrn); CirPtr pCir = CIRPTR(pScrn); - AlpRestore(pScrn); - vgaHWLock(hwp); + if(pScrn->vtSema) { + AlpRestore(pScrn); + vgaHWLock(hwp); + CirUnmapMem(pCir, pScrn->scrnIndex); + } - CirUnmapMem(pCir, pScrn->scrnIndex); if (pCir->AccelInfoRec) XAADestroyInfoRec(pCir->AccelInfoRec); pCir->AccelInfoRec = NULL; @@ -1846,7 +1945,9 @@ int num, den, ffreq, usemclk, diff, mclk; CARD8 tmp; +#ifdef ALP_DEBUG ErrorF("AlpSetClock freq=%d.%03dMHz\n", freq / 1000, freq % 1000); +#endif ffreq = freq; if (!CirrusFindClock(&ffreq, pCir->MaxClock, &num, &den)) @@ -1865,9 +1966,10 @@ else usemclk = FALSE; +#ifdef ALP_DEBUG ErrorF("AlpSetClock: nom=%x den=%x ffreq=%d.%03dMHz usemclk=%x\n", num, den, ffreq / 1000, ffreq % 1000, usemclk); - +#endif /* So - how do we use MCLK here for the VCLK ? */ /* Set VCLK3. */ @@ -1955,3 +2057,73 @@ } } #endif + +static void +AlpProbeLCD(ScrnInfoPtr pScrn) +{ + CirPtr pCir = CIRPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + static const char* lcd_type_names[] = + { + "none", + "dual-scan monochrome", + "unknown", + "DSTN (dual scan color)", + "TFT (active matrix)" + }; + + + pCir -> lcdType = LCD_NONE; + + switch (pCir -> Chipset) + { + case PCI_CHIP_GD7548: + switch (hwp->readCrtc(hwp, 0x2C) >> 6) + { + case 0: pCir->lcdType = LCD_DUAL_MONO; break; + case 1: pCir->lcdType = LCD_UNKNOWN; break; + case 2: pCir->lcdType = LCD_DSTN; break; + case 3: pCir->lcdType = LCD_TFT; break; + } + + /* Enable LCD control registers instead of normal CRTC registers */ + hwp->writeCrtc(hwp, 0x2D, hwp->readCrtc(hwp, 0x2D) | 0x80); + + switch ((hwp->readCrtc(hwp, 0x9) >> 2) & 3) + { + case 0: + pCir->lcdWidth = 640; + pCir->lcdHeight = 480; + break; + + case 1: + pCir->lcdWidth = 800; + pCir->lcdHeight = 600; + break; + + case 2: + pCir->lcdWidth = 1024; + pCir->lcdHeight = 768; + break; + + case 3: + pCir->lcdWidth = 0; + pCir->lcdHeight = 0; + break; + } + + /* Disable LCD control registers */ + hwp->writeCrtc(hwp, 0x2D, hwp->readCrtc(hwp, 0x2D) & ~0x80); + break; + } + + if (pCir -> lcdType != LCD_NONE) + { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "LCD display: %dx%d %s\n", + pCir->lcdWidth, pCir->lcdHeight, + lcd_type_names[pCir->lcdType]); + } +} + + Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c:1.3 Thu Feb 10 17:33:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c Wed Dec 6 10:35:15 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c,v 1.3 2000/02/10 22:33:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c,v 1.4 2000/12/06 15:35:15 eich Exp $ */ /* (c) Itai Nahshon */ @@ -13,6 +13,7 @@ #include "vgaHW.h" #include "cir.h" +#define _ALP_PRIVATE_ #include "alp.h" #define CURSORWIDTH pAlp->CursorWidth Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c:1.2 Tue Feb 8 08:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c Wed Dec 6 10:35:15 2000 @@ -1,6 +1,6 @@ /* (c) Itai Nahshon */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c,v 1.2 2000/02/08 13:13:14 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c,v 1.3 2000/12/06 15:35:15 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -13,6 +13,7 @@ #include "vgaHW.h" #include "cir.h" +#define _ALP_PRIVATE_ #include "alp.h" /* Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c:1.2 Tue Feb 8 08:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c Wed Dec 6 10:35:15 2000 @@ -1,6 +1,6 @@ /* (c) Itai Nahshon */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c,v 1.2 2000/02/08 13:13:14 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c,v 1.5 2000/12/06 15:35:15 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -13,11 +13,38 @@ #include "vgaHW.h" #include "cir.h" +#define _ALP_PRIVATE_ #include "alp.h" #define WAIT outb(0x3CE,0x31); while(inb(0x3CF) & pCir->chip.alp->waitMsk){}; #define WAIT_1 outb(0x3CE,0x31); while(inb(0x3CF) & 0x1){}; +static const CARD16 translated_rop[] = +{ + /* GXclear */ 0x0032U, + /* GXand */ 0x0532U, + /* GXandreverse */ 0x0932U, + /* GXcopy */ 0x0D32U, + /* GXandinversted */ 0x5032U, + /* GXnoop */ 0x0632U, + /* GXxor */ 0x5932U, + /* GXor */ 0x6D32U, + /* GXnor */ 0x9032U, + /* GXequiv */ 0x9532U, + /* GXinvert */ 0x0B32U, + /* GXorReverse */ 0xAD32U, + /* GXcopyInverted */ 0xD032U, + /* GXorInverted */ 0xD632U, + /* GXnand */ 0xDA32U, + /* GXset */ 0x0E32U +}; + +#if 1 +#define SetupForRop(rop) outw(0x3CE, translated_rop[rop]) +#else +#define SetupForRop(rop) outw(0x3CE, 0x0D32) +#endif + static void AlpSync(ScrnInfoPtr pScrn) { #ifdef ALP_DEBUG @@ -29,8 +56,8 @@ static void AlpSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, - int rop, unsigned int planemask, - int trans_color) + int rop, unsigned int planemask, + int trans_color) { CirPtr pCir = CIRPTR(pScrn); int pitch = pCir->pitch; @@ -40,7 +67,7 @@ xdir, ydir, rop, planemask, trans_color); #endif WAIT; - outw(0x3CE,0x0d32); + SetupForRop(rop); /* Set dest pitch */ outw(0x3CE, ((pitch << 8) & 0xff00) | 0x24); outw(0x3CE, ((pitch) & 0x1f00) | 0x25); @@ -109,6 +136,7 @@ unsigned int planemask) { CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); int pitch = pCir->pitch; #ifdef ALP_DEBUG @@ -117,12 +145,34 @@ #endif WAIT; - outb(0x3CE, 0x32); outb(0x3CF, 0x0d); + SetupForRop(rop); - outb(0x3CE, 0x33); - outb(0x3CF, 0x04); - outb(0x3CE, 0x30); - outb(0x3CF, 0xC0|((pScrn->bitsPerPixel - 8) << 1)); + switch (pCir -> Chipset) + { + case PCI_CHIP_GD7548: + /* The GD7548 does not (apparently) support solid filling + directly, it always need an actual source. + We therefore use it as a pattern fill with a solid + pattern */ + { + int source = pAlp->monoPattern8x8; + /* source = 8x8 solid mono pattern */ + outw(0x3CE, ((source << 8) & 0xff00) | 0x2C); + outw(0x3CE, ((source) & 0xff00) | 0x2D); + outw(0x3CE, ((source >> 8) & 0x3f00) | 0x2E); + /* memset() may not be the fastest */ + memset(pCir->FbBase + pAlp->monoPattern8x8, 0xFF, 8); + write_mem_barrier(); + break; + } + default: + /* GR33 = 0x04 => does not exist on GD7548 */ + outw(0x3CE, 0x0433); + } + + /* GR30 = color expansion, pattern copy */ + /* Choses 8bpp / 16bpp color expansion */ + outw(0x3CE, 0xC030 |((pScrn->bitsPerPixel - 8) << 9)); outw(0x3CE, ((color << 8) & 0xff00) | 0x01); outw(0x3CE, ((color) & 0xff00) | 0x11); @@ -169,12 +219,358 @@ } +static void +AlpSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int patx, int paty, + int fg, int bg, + int rop, unsigned int planemask) +{ + CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); + int pitch = pCir->pitch; + +#ifdef ALP_DEBUG + ErrorF("AlpSetupFor8x8PatternFill pattern=%8x%8x" + "fg=%x bg=%x rop=%x planemask=%x\n", + patx, paty, fg, bg, rop, planemask); +#endif + WAIT; + + SetupForRop(rop); + + { + int source = pAlp->monoPattern8x8; + /* source = 8x8 solid mono pattern */ + outw(0x3CE, ((source << 8) & 0xff00) | 0x2C); + outw(0x3CE, ((source) & 0xff00) | 0x2D); + outw(0x3CE, ((source >> 8) & 0x3f00) | 0x2E); + } + + /* GR30 = color expansion, pattern copy */ + /* Choses 8bpp / 16bpp color expansion */ + if (bg == -1) + { /* transparency requested */ + outw(0x3CE, 0xC830 |((pScrn->bitsPerPixel - 8) << 9)); + + bg = ~fg; + /* transparent color compare */ + outw(0x3CE, ((bg << 8) & 0xff00) | 0x34); + outw(0x3CE, ((bg) & 0xff00) | 0x35); + + /* transparent color mask = 0 (all bits matters) */ + outw(0x3CE, 0x38); + outw(0x3CE, 0x39); + } + else + { + outw(0x3CE, 0xC030 |((pScrn->bitsPerPixel - 8) << 9)); + } + + outw(0x3CE, ((fg << 8) & 0xff00) | 0x01); + outw(0x3CE, ((fg) & 0xff00) | 0x11); + + outw(0x3CE, ((bg << 8) & 0xff00) | 0x00); + outw(0x3CE, ((bg) & 0xff00) | 0x10); + + /* Set dest pitch */ + outw(0x3CE, ((pitch << 8) & 0xff00) | 0x24); + outw(0x3CE, ((pitch) & 0x1f00) | 0x25); +} + +static void +AlpSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty, + int x, int y, int w, int h) +{ + CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); + int dest; + int hh, ww; + int pitch = pCir->pitch; + ww = (w * pScrn->bitsPerPixel / 8) - 1; + hh = h - 1; + dest = y * pitch + x * pScrn->bitsPerPixel / 8; + + WAIT; + /* memcpy() may not be the fastest */ + memcpy(pCir->FbBase + pAlp->monoPattern8x8, &patx, 4); + memcpy(pCir->FbBase + pAlp->monoPattern8x8 + 4, &paty, 4); + write_mem_barrier(); + + /* Width */ + outw(0x3CE, ((ww << 8) & 0xff00) | 0x20); + outw(0x3CE, ((ww) & 0x1f00) | 0x21); + /* Height */ + outw(0x3CE, ((hh << 8) & 0xff00) | 0x22); + outw(0x3CE, ((hh) & 0x0700) | 0x23); + + /* dest */ + outw(0x3CE, ((dest << 8) & 0xff00) | 0x28); + outw(0x3CE, ((dest) & 0xff00) | 0x29); + outw(0x3CE, ((dest >> 8) & 0x3f00) | 0x2A); + if (!pCir->chip.alp->autoStart) + outw(0x3CE,0x0231); + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequent8x8PatternFill x=%d y=%d w=%d h=%d\n", + x, y, w, h); +#endif + +} + +#if 0 +/* XF86 does not support byte-padded scanlines */ + +static void +AlpSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) +{ + CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); + int pitch = pCir->pitch; + +#ifdef ALP_DEBUG + ErrorF("AlpSetupForCPUToScreenColorExpandFill " + "fg=%x bg=%x rop=%x planemask=%x\n", + fg, bg, rop, planemask); +#endif + WAIT; + + SetupForRop(rop); + + /* GR30 = color expansion, CPU->display copy */ + /* Choses 8bpp / 16bpp color expansion */ + if (bg == -1) + { /* transparency requested */ + outw(0x3CE, 0x8C30 |((pScrn->bitsPerPixel - 8) << 9)); + + bg = ~fg; + /* transparent color compare */ + outw(0x3CE, ((bg << 8) & 0xff00) | 0x34); + outw(0x3CE, ((bg) & 0xff00) | 0x35); + + /* transparent color mask = 0 (all bits matters) */ + outw(0x3CE, 0x38); + outw(0x3CE, 0x39); + } + else + { + outw(0x3CE, 0x8430 |((pScrn->bitsPerPixel - 8) << 9)); + } + + outw(0x3CE, ((bg << 8) & 0xff00) | 0x00); + outw(0x3CE, ((bg) & 0xff00) | 0x10); + + outw(0x3CE, ((fg << 8) & 0xff00) | 0x01); + outw(0x3CE, ((fg) & 0xff00) | 0x11); + + /* Set dest pitch */ + outw(0x3CE, ((pitch << 8) & 0xff00) | 0x24); + outw(0x3CE, ((pitch) & 0x1f00) | 0x25); +} + +static void +AlpSubsequentCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft) +{ + CirPtr pCir = CIRPTR(pScrn); + int dest; + int hh, ww; + int pitch = pCir->pitch; + + ww = (((w+7) & ~7) * pScrn->bitsPerPixel / 8) - 1; + hh = h - 1; + dest = y * pitch + x * pScrn->bitsPerPixel / 8; + + WAIT; + + /* Width */ + outw(0x3CE, ((ww << 8) & 0xff00) | 0x20); + outw(0x3CE, ((ww) & 0x1f00) | 0x21); + /* Height */ + outw(0x3CE, ((hh << 8) & 0xff00) | 0x22); + outw(0x3CE, ((hh) & 0x0700) | 0x23); + + /* source = CPU ; description of bit 2 of GR30 in the 7548 manual + says that if we do color expansion we must zero the source + adress registers (GR2C, GR2D, GR2E) */ + outw(0x3CE, 0x2C); + outw(0x3CE, 0x2D); + outw(0x3CE, 0x2E); + + /* dest */ + outw(0x3CE, ((dest << 8) & 0xff00) | 0x28); + outw(0x3CE, ((dest) & 0xff00) | 0x29); + outw(0x3CE, ((dest >> 8) & 0x3f00) | 0x2A); + if (!pCir->chip.alp->autoStart) + outw(0x3CE,0x0231); + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequentCPUToScreenColorExpandFill x=%d y=%d w=%d h=%d\n", + x, y, w, h); +#endif +} +#endif + +#if 1 +static void +AlpSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) +{ + CirPtr pCir = CIRPTR(pScrn); + int pitch = pCir->pitch; + +#ifdef ALP_DEBUG + ErrorF("AlpSetupForCPUToScreenColorExpandFill " + "fg=%x bg=%x rop=%x planemask=%x, bpp=%d\n", + fg, bg, rop, planemask, pScrn->bitsPerPixel); +#endif + WAIT; + + SetupForRop(rop); + + /* GR30 = color expansion, CPU->display copy */ + /* Choses 8bpp / 16bpp color expansion */ + if (bg == -1) + { /* transparency requested */ + if (pScrn->bitsPerPixel > 8) /* 16 bpp */ + { + outw(0x3CE, 0x9C30); + + bg = ~fg; + /* transparent color compare */ + outw(0x3CE, ((bg << 8) & 0xff00) | 0x34); + outw(0x3CE, ((bg) & 0xff00) | 0x35); + } else /* 8 bpp */ + { + outw(0x3CE, 0x8C30); + + bg = ~fg; + /* transparent color compare */ + outw(0x3CE, ((bg << 8) & 0xff00) | 0x34); + outw(0x3CE, ((bg << 8) & 0xff00) | 0x35); + } + + /* transparent color mask = 0 (all bits matters) */ + outw(0x3CE, 0x38); + outw(0x3CE, 0x39); + } + else + { + outw(0x3CE, 0x8430 |((pScrn->bitsPerPixel - 8) << 9)); + } + + outw(0x3CE, ((bg << 8) & 0xff00) | 0x00); + outw(0x3CE, ((bg) & 0xff00) | 0x10); + + outw(0x3CE, ((fg << 8) & 0xff00) | 0x01); + outw(0x3CE, ((fg) & 0xff00) | 0x11); + + /* Set dest pitch */ + outw(0x3CE, ((pitch << 8) & 0xff00) | 0x24); + outw(0x3CE, ((pitch) & 0x1f00) | 0x25); +} + +static void +AlpSubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft) +{ + CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); + + int pitch = pCir->pitch; + + pAlp->SubsequentColorExpandScanlineByteWidth = + (w * pScrn->bitsPerPixel / 8) - 1; + pAlp->SubsequentColorExpandScanlineDWordWidth = + (w + 31) >> 5; + pAlp->SubsequentColorExpandScanlineDest = + y * pitch + x * pScrn->bitsPerPixel / 8; + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequentScanlineCPUToScreenColorExpandFill x=%d y=%d w=%d h=%d skipleft=%d\n", + x, y, w, h, skipleft); +#endif +} + +static void +AlpSubsequentColorExpandScanline( + ScrnInfoPtr pScrn, + int bufno) +{ + CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); + int dest=pAlp->SubsequentColorExpandScanlineDest; + int ww=pAlp->SubsequentColorExpandScanlineByteWidth; + int width=pAlp->SubsequentColorExpandScanlineDWordWidth; + CARD32* from; + volatile CARD32 *to; + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequentColorExpandScanline\n"); +#endif + + pAlp->SubsequentColorExpandScanlineDest += pCir->pitch; + + to = (CARD32*) pCir->FbBase; + from = (CARD32*) (pCir->ScanlineColorExpandBuffers[bufno]); + WAIT_1; + + /* Width */ + outw(0x3CE, ((ww << 8) & 0xff00) | 0x20); + outw(0x3CE, ((ww) & 0x1f00) | 0x21); + + /* Height = 1 */ + outw(0x3CE, 0x22); + outw(0x3CE, 0x23); + + /* source = CPU ; description of bit 2 of GR30 in the 7548 manual + says that if we do color expansion we must zero the source + adress registers (GR2C, GR2D, GR2E) */ + outw(0x3CE, 0x2C); + outw(0x3CE, 0x2D); + outw(0x3CE, 0x2E); + + /* dest */ + outw(0x3CE, ((dest << 8) & 0xff00) | 0x28); + outw(0x3CE, ((dest) & 0xff00) | 0x29); + write_mem_barrier(); + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequentColorExpandScanline (2)\n"); +#endif + + outw(0x3CE, ((dest >> 8) & 0x3f00) | 0x2A); + if (!pCir->chip.alp->autoStart) + outw(0x3CE,0x0231); + + { + int i; + for (i=0; i<width; i++) + *to=*(from++); + write_mem_barrier(); + } + +#ifdef ALP_DEBUG + ErrorF("AlpSubsequentColorExpandScanline (3)\n"); +#endif +} +#endif + Bool AlpXAAInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; CirPtr pCir = CIRPTR(pScrn); + AlpPtr pAlp = ALPPTR(pCir); XAAInfoRecPtr XAAPtr; #ifdef ALP_DEBUG @@ -186,20 +582,93 @@ XAAPtr->SetupForScreenToScreenCopy = AlpSetupForScreenToScreenCopy; XAAPtr->SubsequentScreenToScreenCopy = AlpSubsequentScreenToScreenCopy; - XAAPtr->ScreenToScreenCopyFlags = GXCOPY_ONLY|NO_TRANSPARENCY|NO_PLANEMASK; - - if (pCir->Chipset == PCI_CHIP_GD5446 || - pCir->Chipset == PCI_CHIP_GD5480) { + XAAPtr->ScreenToScreenCopyFlags = + NO_TRANSPARENCY | NO_PLANEMASK; - XAAPtr->SetupForSolidFill = AlpSetupForSolidFill; - XAAPtr->SubsequentSolidFillRect = AlpSubsequentSolidFillRect; - XAAPtr->SubsequentSolidFillTrap = NULL; - XAAPtr->SolidFillFlags = GXCOPY_ONLY|NO_TRANSPARENCY|NO_PLANEMASK; + switch (pCir->Chipset) + { + case PCI_CHIP_GD7548: + if (!pAlp->monoPattern8x8) break; + XAAPtr->SetupForSolidFill = AlpSetupForSolidFill; + XAAPtr->SubsequentSolidFillRect = AlpSubsequentSolidFillRect; + XAAPtr->SubsequentSolidFillTrap = NULL; + XAAPtr->SolidFillFlags = NO_PLANEMASK; + + XAAPtr->SetupForMono8x8PatternFill = AlpSetupForMono8x8PatternFill; + XAAPtr->SubsequentMono8x8PatternFillRect = + AlpSubsequentMono8x8PatternFillRect; + XAAPtr->SubsequentMono8x8PatternFillTrap = NULL; + XAAPtr->Mono8x8PatternFillFlags = + NO_PLANEMASK | + HARDWARE_PATTERN_PROGRAMMED_BITS | BIT_ORDER_IN_BYTE_MSBFIRST; + +#if 0 + /* Currently disabled: XF86 sends DWORD-padded data, + not byte-padded */ + XAAPtr->SetupForCPUToScreenColorExpandFill = + AlpSetupForCPUToScreenColorExpandFill; + XAAPtr->SubsequentCPUToScreenColorExpandFill = + AlpSubsequentCPUToScreenColorExpandFill; + XAAPtr->ColorExpandBase = pCir->FbBase + 4; + XAAPtr->CPUToScreenColorExpandFillFlags = + NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST | + SCANLINE_PAD_DWORD | ROP_NEEDS_SOURCE | + CPU_TRANSFER_PAD_DWORD | CPU_TRANSFER_BASE_FIXED; +#endif +#if 1 + /* kludge: since XF86 does not support byte-padded + mono bitmaps (only dword-padded), use the + scanline version */ + XAAPtr->SetupForScanlineCPUToScreenColorExpandFill = + AlpSetupForScanlineCPUToScreenColorExpandFill; + XAAPtr->SubsequentScanlineCPUToScreenColorExpandFill = + AlpSubsequentScanlineCPUToScreenColorExpandFill; + XAAPtr->SubsequentColorExpandScanline = + AlpSubsequentColorExpandScanline; + { + const int NumScanlineColorExpandBuffers = 2; + int i; + int buffer_size = (pCir->pScrn->virtualX + 31) & ~31; +#ifdef ALP_DEBUG + ErrorF("Computing buffers for %d pixel lines\n", + pCir->pScrn->virtualX); +#endif + XAAPtr->NumScanlineColorExpandBuffers = + NumScanlineColorExpandBuffers; + XAAPtr->ScanlineColorExpandBuffers = + pCir->ScanlineColorExpandBuffers = (unsigned char **) + (malloc(sizeof(unsigned char *) * + NumScanlineColorExpandBuffers)); + /* TODO: are those mallocs to be freed ? */ + + for(i=0; i<NumScanlineColorExpandBuffers; i++) + pCir->ScanlineColorExpandBuffers[i] = (unsigned char *) + malloc(buffer_size); + } + XAAPtr->ScanlineCPUToScreenColorExpandFillFlags = + NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST | + SCANLINE_PAD_DWORD | ROP_NEEDS_SOURCE; +#endif + break; + + case PCI_CHIP_GD5446: + case PCI_CHIP_GD5480: + XAAPtr->SetupForSolidFill = AlpSetupForSolidFill; + XAAPtr->SubsequentSolidFillRect = AlpSubsequentSolidFillRect; + XAAPtr->SubsequentSolidFillTrap = NULL; + XAAPtr->SolidFillFlags = NO_TRANSPARENCY|NO_PLANEMASK; + outw(0x3CE, 0x200E); /* enable writes to gr33 */ + break; } + /* TODO: probably too limited */ + XAAPtr->Sync = AlpSync; + + /* Pixmap cache */ + XAAPtr -> Flags |= LINEAR_FRAMEBUFFER; - outw(0x3CE, 0x200E); /* enable writes to gr33 */ + /* Setup things for autostart */ if (pCir->properties & ACCEL_AUTOSTART) { outw(0x3CE, 0x8031); /* enable autostart */ pCir->chip.alp->waitMsk = 0x10; Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c:1.2 Tue Feb 8 08:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c Wed Dec 6 10:35:15 2000 @@ -1,6 +1,6 @@ /* (c) Itai Nahshon */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c,v 1.2 2000/02/08 13:13:14 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c,v 1.4 2000/12/06 15:35:15 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -13,18 +13,31 @@ #include "vgaHW.h" #include "cir.h" +#define _ALP_PRIVATE_ #include "alp.h" -#define minb(p) MMIO_IN8(hwp->MMIOBase, hwp->MMIOOffset + (p)) +#ifdef DEBUG +#define minb(p) \ + ErrorF("minb(%X)\n", p),\ + MMIO_IN8(pCir->IOBase, (p)) #define moutb(p,v) \ - MMIO_OUT8(hwp->MMIOBase, hwp->MMIOOffset + (p),(v)) -#define minl(p) MMIO_IN32(pCir->IOBase, (p)) + ErrorF("moutb(%X)\n", p),\ + MMIO_OUT8(pCir->IOBase, (p),(v)) +#define minl(p) \ + ErrorF("minl(%X)\n", p),\ + MMIO_IN32(pCir->IOBase, (p)) #define moutl(p,v) \ + ErrorF("moutl(%X)\n", p),\ MMIO_OUT32(pCir->IOBase, (p),(v)) - +#else +#define minb(p) MMIO_IN8(pCir->IOBase, (p)) +#define moutb(p,v) MMIO_OUT8(pCir->IOBase, (p),(v)) +#define minl(p) MMIO_IN32(pCir->IOBase, (p)) +#define moutl(p,v) MMIO_OUT32(pCir->IOBase, (p),(v)) +#endif -#define WAIT while(minl(0x140) & pCir->chip.alp->waitMsk){}; -#define WAIT_1 while(minl(0x140) & 0x100){}; +#define WAIT while(minb(0x40) & pCir->chip.alp->waitMsk){}; +#define WAIT_1 while(minb(0x40) & 0x1){}; static void AlpSync(ScrnInfoPtr pScrn) { @@ -49,7 +62,7 @@ ErrorF("AlpSetupForScreenToScreenCopy xdir=%d ydir=%d rop=%x planemask=%x trans_color=%x\n", xdir, ydir, rop, planemask, trans_color); #endif - moutl(0x10C, (pitch << 16) | pitch); + moutl(0x0C, (pitch << 16) | pitch); } @@ -76,14 +89,14 @@ WAIT; /* Width / Height */ - moutl(0x108, (hh << 16) | ww); + moutl(0x08, (hh << 16) | ww); /* source */ - moutl(0x114, source & 0x3fffff); - moutl(0x118, 0x0d0000 | decrement); + moutl(0x14, source & 0x3fffff); + moutl(0x18, 0x0d0000 | decrement); /* dest */ write_mem_barrier(); - moutl(0x110, dest & 0x3fffff); + moutl(0x10, dest & 0x3fffff); #ifdef ALP_DEBUG ErrorF("AlpSubsequentScreenToScreenCopy x1=%d y1=%d x2=%d y2=%d w=%d h=%d\n", @@ -92,7 +105,7 @@ source, dest, ww, hh); #endif if (!pCir->chip.alp->autoStart) - moutl(0x140,0x02); + moutb(0x40,0x02); write_mem_barrier(); } @@ -111,11 +124,11 @@ color, rop, planemask); #endif - moutl(0x104, color & 0xffffff); + moutl(0x04, color & 0xffffff); /* Set dest pitch */ - moutl(0x10C, pitch & 0x1fff); - moutl(0x118, (0xC0|((pScrn->bitsPerPixel - 8) << 1)) | 0x040d0000); + moutl(0x0C, pitch & 0x1fff); + moutl(0x18, (0xC0|((pScrn->bitsPerPixel - 8) << 1)) | 0x040d0000); } static void @@ -134,17 +147,17 @@ /* Width / Height */ write_mem_barrier(); - moutl(0x108, (hh << 16) | ww); + moutl(0x08, (hh << 16) | ww); #ifdef ALP_DEBUG ErrorF("AlpSubsequentSolidFillRect x=%d y=%d w=%d h=%d\n", x, y, w, h); #endif /* dest */ - moutl(0x110, (dest & 0x3fffff)); + moutl(0x10, (dest & 0x3fffff)); if (!pCir->chip.alp->autoStart) - moutl(0x140,0x02); + moutb(0x40,0x02); write_mem_barrier(); } @@ -152,12 +165,11 @@ AlpXAAInitMMIO(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - vgaHWPtr hwp = VGAHWPTR(pScrn); CirPtr pCir = CIRPTR(pScrn); XAAInfoRecPtr XAAPtr; #ifdef ALP_DEBUG - ErrorF("AlpXAAInit\n"); + ErrorF("AlpXAAInit mm\n"); #endif XAAPtr = XAACreateInfoRec(); @@ -173,15 +185,19 @@ XAAPtr->SolidFillFlags = GXCOPY_ONLY|NO_TRANSPARENCY|NO_PLANEMASK; XAAPtr->Sync = AlpSync; + + if (pCir->Chipset != PCI_CHIP_GD7548) + { + moutb(0x3CE, 0x0E); /* enable writes to gr33 */ + moutb(0x3CF, 0x20); /* enable writes to gr33 */ + } - moutb(0x3CE, 0x0E); /* enable writes to gr33 */ - moutb(0x3CF, 0x20); /* enable writes to gr33 */ if (pCir->properties & ACCEL_AUTOSTART) { - moutl(0x140, 0x80); /* enable autostart */ - pCir->chip.alp->waitMsk = 0x1000; + moutb(0x40, 0x80); /* enable autostart */ + pCir->chip.alp->waitMsk = 0x10; pCir->chip.alp->autoStart = TRUE; } else { - pCir->chip.alp->waitMsk = 0x100; + pCir->chip.alp->waitMsk = 0x1; pCir->chip.alp->autoStart = FALSE; } Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h:1.15 xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h:1.15 Sun Mar 5 18:47:50 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h Wed Dec 6 10:35:15 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h,v 1.15 2000/03/05 23:47:50 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h,v 1.17 2000/12/06 15:35:15 eich Exp $ */ /* (c) Itai Nahshon */ @@ -9,15 +9,14 @@ #include "xaa.h" #include "xf86i2c.h" -#if 0 -#define CIR_DEBUG -#endif - /* Card-specific driver information */ #define CIRPTR(p) ((CirPtr)((p)->driverPrivate)) struct lgRec; struct alpRec; +typedef enum { + LCD_NONE, LCD_DUAL_MONO, LCD_UNKNOWN, LCD_DSTN, LCD_TFT } LCDType; + typedef struct { ScrnInfoPtr pScrn; CARD32 properties; @@ -40,7 +39,7 @@ long FbMapSize; long IoMapSize; int MinClock; - int MaxClock; + int MaxClock; Bool NoAccel; Bool HWCursor; Bool UseMMIO; @@ -60,6 +59,11 @@ unsigned char * ShadowPtr; void (*PointerMoved)(int index, int x, int y); int pitch; + + unsigned char ** ScanlineColorExpandBuffers; + + LCDType lcdType; + int lcdWidth, lcdHeight; } CirRec, *CirPtr; /* CirrusClk.c */ @@ -72,6 +76,7 @@ extern Bool CirMapMem(CirPtr pCir, int scrnIndex); extern Bool CirUnmapMem(CirPtr pCir, int scrnIndex); +extern void cirProbeDDC(ScrnInfoPtr pScrn, int index); /* in cir_shadow.c */ void cirPointerMoved(int index, int x, int y); Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c:1.58 xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c:1.62 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c:1.58 Thu Apr 27 12:26:47 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c Wed Dec 6 10:35:15 2000 @@ -2,6 +2,8 @@ * Driver for CL-GD5480. * Itai Nahshon. * + * Support for the CL-GD7548: David Monniaux + * * This is mainly a cut & paste from the MGA driver. * Original autors and contributors list include: * Radoslaw Kapitan, Andrew Vanderstock, Dirk Hohndel, @@ -9,7 +11,7 @@ * Guy DESBIEF */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c,v 1.58 2000/04/27 16:26:47 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c,v 1.62 2000/12/06 15:35:15 eich Exp $ */ /* All drivers should typically include these */ #include "xf86.h" @@ -27,7 +29,11 @@ #include "xf86Pci.h" #include "cir.h" +#include "alp.h" +#include "lg.h" +#include "vbe.h" + /* * Forward definitions for the functions that make up the driver. */ @@ -38,11 +44,6 @@ static void CIRIdentify(int flags); static Bool CIRProbe(DriverPtr drv, int flags); -extern OptionInfoPtr AlpAvailableOptions(int chipid); -extern OptionInfoPtr LgAvailableOptions(int chipid); -extern ScrnInfoPtr AlpProbe(int entity); -extern ScrnInfoPtr LgProbe(int entity); - static Bool lg_loaded = FALSE; static Bool alp_loaded = FALSE; @@ -87,6 +88,7 @@ { PCI_CHIP_GD5464, "CL-GD5464" }, { PCI_CHIP_GD5464BD, "CL-GD5464BD" }, { PCI_CHIP_GD5465, "CL-GD5465" }, + { PCI_CHIP_GD7548, "CL-GD7548" }, {-1, NULL } }; @@ -103,6 +105,7 @@ { PCI_CHIP_GD5464, PCI_CHIP_GD5464, RES_SHARED_VGA }, { PCI_CHIP_GD5464BD,PCI_CHIP_GD5464BD, RES_SHARED_VGA }, { PCI_CHIP_GD5465, PCI_CHIP_GD5465, RES_SHARED_VGA }, + { PCI_CHIP_GD7548, PCI_CHIP_GD7548, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED} }; @@ -117,10 +120,12 @@ static const char *alpSymbols[] = { "AlpProbe", + "AlpAvailableOptions", NULL }; static const char *lgSymbols[] = { "LgProbe", + "LgAvailableOptions", NULL }; @@ -182,15 +187,18 @@ { int chip = chipid & 0xffff; - if (chip == PCI_CHIP_GD5462 || - chip == PCI_CHIP_GD5464 || - chip == PCI_CHIP_GD5464BD || - chip == PCI_CHIP_GD5465) { + switch (chip) + { + case PCI_CHIP_GD5462: + case PCI_CHIP_GD5464: + case PCI_CHIP_GD5464BD: + case PCI_CHIP_GD5465: if (lg_loaded) return LgAvailableOptions(chipid); else return NULL; - } else { + + default: if (alp_loaded) return AlpAvailableOptions(chipid); else @@ -202,7 +210,7 @@ CIRProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; pciVideoPtr pPci; int *usedChips; int numDevSections; @@ -253,9 +261,7 @@ CIRChipsets, CIRPciChipsets, devSections, numDevSections, drv, &usedChips); /* Free it since we don't need that list after this */ - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; if (flags & PROBE_DETECT) @@ -345,14 +351,18 @@ * byte/short access. Common-level will automatically use * sparse mapping for MMIO. */ - pCir->IOBase = xf86MapPciMem(scrnIndex, mmioFlags, pCir->PciTag, - pCir->IOAddress, pCir->IoMapSize); + pCir->IOBase = + xf86MapPciMem(scrnIndex, mmioFlags, pCir->PciTag, + pCir->IOAddress, pCir->IoMapSize); if (pCir->IOBase == NULL) return FALSE; } #ifdef CIR_DEBUG - ErrorF("CirMapMem pCir->IOBase=0x%08x\n", pCir->IOBase); + ErrorF("CirMapMem pCir->IOBase=0x%08x [length=%08x] from PCI=%08x\n", + pCir->IOBase, pCir->IoMapSize, pCir->IOAddress); + ErrorF("MMIO[GR31] = %2X\n", (int) + ((volatile unsigned char*) pCir->IOBase)[0x40]); #endif return TRUE; @@ -381,4 +391,15 @@ xf86UnMapVidMem(scrnIndex, (pointer)pCir->FbBase, pCir->FbMapSize); pCir->FbBase = NULL; return TRUE; +} + +void +cirProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } } Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp:1.4 Tue Jun 13 22:13:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp Mon Dec 11 15:18:09 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp,v 1.4 2000/06/14 02:13:08 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp,v 1.5 2000/12/11 20:18:09 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH CIRRUS __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH CIRRUS __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME cirrus \- Cirrus Logic video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h:1.10 xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h:1.10 Tue Feb 8 08:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h Wed Dec 6 10:35:16 2000 @@ -10,13 +10,16 @@ * Inspired by cir.h */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h,v 1.10 2000/02/08 13:13:15 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h,v 1.11 2000/12/06 15:35:16 eich Exp $ */ #ifndef LG_H #define LG_H +#define LG_DEBUG +extern ScrnInfoPtr LgProbe(int entity); +extern OptionInfoPtr LgAvailableOptions(int chipid); -#define LG_DEBUG +# ifdef _LG_PRIVATE_ /* Saved registers that are not part of the core VGA */ /* CRTC >= 0x19; Sequencer >= 0x05; Graphics >= 0x09; Attribute >= 0x15 */ @@ -98,6 +101,7 @@ int blitYDir; } LgRec, *LgPtr; +# endif /* _LG_PRIVATE_ */ #endif /* LG_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c:1.30 xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c:1.33 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c:1.30 Wed Jun 21 13:28:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c Wed Dec 6 10:35:16 2000 @@ -13,7 +13,7 @@ * David Dawes, Andrew E. Mileski, Leonard N. Zubkoff, * Guy DESBIEF, Itai Nahshon. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c,v 1.30 2000/06/21 17:28:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c,v 1.33 2000/12/06 15:35:16 eich Exp $ */ #define EXPERIMENTAL @@ -52,23 +52,14 @@ #include "xf86int10.h" -/* - * If using cfb, cfb.h is required. Select the others for the bpp values - * the driver supports. - */ -#define PSZ 8 /* needed for cfb.h */ -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb24_32.h" -#include "cfb32.h" +#include "fb.h" #include "xf86DDC.h" #undef LG_DEBUG #include "cir.h" +#define _LG_PRIVATE_ #include "lg.h" #ifdef XvExtension @@ -80,8 +71,6 @@ * Forward definitions for the functions that make up the driver. */ -ScrnInfoPtr LgProbe(int entity); - /* Mandatory functions */ Bool LgPreInit(ScrnInfoPtr pScrn, int flags); Bool LgScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); @@ -196,13 +185,8 @@ NULL }; -static const char *cfbSymbols[] = { - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", - "cfb8_32ScreenInit", - "cfb24_32ScreenInit", +static const char *fbSymbols[] = { + "fbScreenInit", NULL }; @@ -287,7 +271,7 @@ if (!setupDone) { setupDone = TRUE; - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, int10Symbols, NULL); } @@ -426,11 +410,13 @@ MessageType from; int i; ClockRangePtr clockRanges; - char *mod = NULL; int fbPCIReg, ioPCIReg; char *s; - if (flags & PROBE_DETECT) return FALSE; + if (flags & PROBE_DETECT) { + cirProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index ); + return TRUE; + } #ifdef LG_DEBUG ErrorF("LgPreInit\n"); @@ -538,13 +524,6 @@ if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } /* Collect all of the relevant option flags (fill in pScrn->options) */ xf86CollectOptions(pScrn, NULL); @@ -876,19 +855,19 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { - case 8: mod = "cfb"; break; - case 16: mod = "cfb16"; break; + case 8: + case 16: case 24: - if (pix24bpp == 24) - mod = "cfb24"; - else - mod = "xf24_32bpp"; - break; - case 32: mod = "cfb32"; break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - LgFreeRec(pScrn); - return FALSE; + case 32: + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + LgFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit",NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + break; } /* Load XAA if needed */ @@ -1385,8 +1364,6 @@ * function. If not, the visuals will need to be setup before calling * a fb ScreenInit() function and fixed up after. * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. */ /* @@ -1396,24 +1373,13 @@ /* Setup the visuals we support. */ - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. To deal with this, call - * miSetVisualTypes with the appropriate visual mask. - */ -#ifdef LG_DEBUG - ErrorF("LgScreenInit before miSetVisualTypes\n"); -#endif - if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + miSetPixmapDepths (); + #ifdef LG_DEBUG ErrorF("LgScreenInit after miSetVisualTypes\n"); #endif @@ -1442,34 +1408,13 @@ */ switch (pScrn->bitsPerPixel) { case 8: - ret = cfbScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 16: - ret = cfb16ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; case 32: - ret = cfb32ScreenInit(pScreen, FbBase, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); + ret = fbScreenInit(pScreen, FbBase, + width,height, + pScrn->xDpi, pScrn->yDpi, + displayWidth,pScrn->bitsPerPixel); break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -1512,6 +1457,8 @@ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not initialize XAA\n"); } + xf86SetSilkenMouse(pScreen); + /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); @@ -1727,14 +1674,15 @@ vgaHWPtr hwp = VGAHWPTR(pScrn); CirPtr pCir = CIRPTR(pScrn); + if(pScrn->vtSema) { LgRestore(pScrn); - if (pCir->HWCursor) - LgHideCursor(pScrn); + LgHideCursor(pScrn); vgaHWLock(hwp); - + CirUnmapMem(pCir, pScrn->scrnIndex); + } if (pCir->AccelInfoRec) XAADestroyInfoRec(pCir->AccelInfoRec); @@ -1801,17 +1749,23 @@ LgSaveScreen(ScreenPtr pScreen, int mode) { CirPtr pCir = CIRPTR(xf86Screens[pScreen->myNum]); + ScrnInfoPtr pScrn = NULL; Bool unblank; unblank = xf86IsUnblank(mode); - - if (unblank) + + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn != NULL && pScrn->vtSema) { + if (unblank) /* Power up the palette DAC */ memwb(0xB0,memrb(0xB0) & 0x7F); - else + else /* Power down the palette DAC */ memwb(0xB0,memrb(0xB0) | 0x80); - + } + return vgaHWSaveScreen(pScreen, mode); } Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c:1.3 Tue Feb 8 08:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c Wed Dec 6 10:35:17 2000 @@ -10,7 +10,7 @@ * Much of this code is inspired by the HW cursor code from XFree86 * 3.3.3. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c,v 1.3 2000/02/08 13:13:15 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -23,6 +23,7 @@ #include "vgaHW.h" #include "cir.h" +#define _LG_PRIVATE_ #include "lg.h" #include "lg_xaa.h" /* For BitBLT engine macros */ Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c:1.3 Tue Feb 8 08:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c Wed Dec 6 10:35:17 2000 @@ -1,6 +1,6 @@ /* (c) Itai Nahshon */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c,v 1.3 2000/02/08 13:13:15 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -13,6 +13,7 @@ #include "vgaHW.h" #include "cir.h" +#define _LG_PRIVATE_ #include "lg.h" static void Index: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c:1.3 Tue Feb 8 12:19:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c Wed Dec 6 10:35:17 2000 @@ -10,7 +10,7 @@ * Much of this code is inspired by the XAA acceleration from XFree86 * 3.3.3, laguna_acl.c */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c,v 1.3 2000/02/08 17:19:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -23,6 +23,7 @@ #include "vgaHW.h" #include "cir.h" +#define _LG_PRIVATE_ #include "lg.h" #include "lg_xaa.h" Index: xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile:1.3 xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile:1.3 Fri Mar 31 17:55:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile Tue Sep 19 20:09:20 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile,v 1.3 2000/03/31 22:55:41 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile,v 1.4 2000/09/20 00:09:20 keithp Exp $ XCOMM XCOMM This is an Imakefile for the CYRIX driver. XCOMM @@ -17,7 +17,7 @@ -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/ramdac \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(XTOP)/include/extensions + -I$(XTOP)/include/extensions -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp:1.4 Tue Jun 13 22:13:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp Mon Dec 11 15:18:10 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp,v 1.4 2000/06/14 02:13:08 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp,v 1.5 2000/12/11 20:18:10 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH CYRIX __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH CYRIX __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME cyrix \- Cyrix video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c:1.1 Sat Feb 12 19:56:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c Tue Jul 25 21:52:18 2000 @@ -26,17 +26,17 @@ * Dirk H. Hohndel (hohndel@suse.de), * Portions: the GGI project & confidential CYRIX databooks. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c,v 1.1 2000/02/13 00:56:10 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_bank.c,v 1.2 2000/07/26 01:52:18 tsi Exp $ */ #define PSZ 8 -/* Everything using inb/outb, etc needs "compiler.h" */ -#include "compiler.h" - /* All drivers should typically include these */ #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" + +/* Everything using inb/outb, etc needs "compiler.h" */ +#include "compiler.h" /* Drivers for PCI hardware need this */ #include "xf86PciInfo.h" Index: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c:1.9 xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c:1.9 Wed Jun 21 13:28:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c Sat Dec 2 10:30:37 2000 @@ -26,9 +26,8 @@ * Dirk H. Hohndel (hohndel@suse.de), * Portions: the GGI project & confidential CYRIX databooks. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c,v 1.9 2000/06/21 17:28:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c,v 1.14 2000/12/02 15:30:37 tsi Exp $ */ -#include "compiler.h" #include "fb.h" #include "mibank.h" #include "micmap.h" @@ -42,6 +41,7 @@ #include "vgaHW.h" #include "xf86RAC.h" #include "xf86Resources.h" +#include "compiler.h" #include "cyrix.h" @@ -301,6 +301,7 @@ int i, numDevSections, numUsed, *usedChips; GDevPtr *devSections; ScrnInfoPtr pScrn; + Bool foundScreen = FALSE; /* * The aim here is to find all cards that this driver can handle, @@ -332,13 +333,15 @@ if (numUsed <= 0) return FALSE; + foundScreen = TRUE; + /* Free it since we don't need that list after this */ xfree(devSections); - - for (i=0; i < numUsed; i++) { + if (!(flags & PROBE_DETECT)) { + for (i=0; i < numUsed; i++) { - /* Fill in what we can of the ScrnInfoRec */ + /* Fill in what we can of the ScrnInfoRec */ pScrn = NULL; if ((pScrn = xf86ConfigIsaEntity(pScrn, 0, usedChips[i], CYRIXISAChipsets, NULL, @@ -355,11 +358,11 @@ pScrn->EnterVT = CYRIXEnterVT; pScrn->FreeScreen = CYRIXFreeScreen; pScrn->ValidMode = CYRIXValidMode; - return (TRUE); } - xfree(usedChips); + } } - return (TRUE); + xfree(usedChips); + return (foundScreen); } static int @@ -498,9 +501,6 @@ /* end GGI MediaGX driver based code */ if (padsize == 0) return (FALSE); - if (flags & PROBE_DETECT) - return TRUE; - xf86ErrorF("%s: GX_BASE: 0x%x\n",CYRIX_NAME, physbase); xf86ErrorF("%s: Scratchpad size: %d kbytes\n",CYRIX_NAME, padsize); @@ -1070,6 +1070,8 @@ miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); Index: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c diff -u xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c:1.2 Wed Apr 19 12:57:43 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c Tue Jul 25 21:52:19 2000 @@ -26,12 +26,12 @@ * Dirk H. Hohndel (hohndel@suse.de), * Portions: the GGI project & confidential CYRIX databooks. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c,v 1.2 2000/04/19 16:57:43 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c,v 1.3 2000/07/26 01:52:19 tsi Exp $ */ #include "cyrix.h" -#include "compiler.h" #include "vgaHW.h" #include "xf86_ansic.h" +#include "compiler.h" #define CYRIXmarkLinesDirty { \ int k = 0; \ Index: xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile:1.7 xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile:1.7 Fri Feb 25 13:28:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile Tue Sep 19 20:09:20 2000 @@ -1,7 +1,7 @@ XCOMM XCOMM This is an Imakefile for the fbdev driver. XCOMM -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile,v 1.7 2000/02/25 18:28:10 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/Imakefile,v 1.8 2000/09/20 00:09:20 keithp Exp $ #define IHaveModules #include <Server.tmpl> @@ -21,7 +21,7 @@ -I$(XF86SRC)/rac \ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp\ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) + -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) -I$(SERVERSRC)/render #endif DEFINES = FbdevDefines Index: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c diff -u xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c:1.22 xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c:1.27 --- xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c:1.22 Mon Jun 12 22:28:33 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c Wed Dec 6 10:35:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c,v 1.22 2000/06/13 02:28:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c,v 1.27 2000/12/06 15:35:18 eich Exp $ */ /* * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> @@ -56,6 +56,7 @@ char **argv); static Bool FBDevCloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool FBDevSaveScreen(ScreenPtr pScreen, int mode); +static void FBDevDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); /* -------------------------------------------------------------------- */ @@ -138,6 +139,7 @@ "fbdevHWGetName", "fbdevHWGetDepth", + "fbdevHWGetLineLength", "fbdevHWGetVidmem", /* colormap */ @@ -244,7 +246,7 @@ { int i; ScrnInfoPtr pScrn; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int numDevSections; int bus,device,func; char *dev; @@ -265,15 +267,23 @@ xf86LoaderReqSymLists(fbdevHWSymbols, NULL); for (i = 0; i < numDevSections; i++) { + Bool isIsa = FALSE; + Bool isPci = FALSE; + dev = xf86FindOptionValue(devSections[i]->options,"fbdev"); if (devSections[i]->busID) { - xf86ParsePciBusString(devSections[i]->busID,&bus,&device,&func); - if (!xf86CheckPciSlot(bus,device,func)) - continue; + if (xf86ParsePciBusString(devSections[i]->busID,&bus,&device, + &func)) { + if (!xf86CheckPciSlot(bus,device,func)) + continue; + isPci = TRUE; + } else if (xf86ParseIsaBusString(devSections[i]->busID)) + isIsa = TRUE; + } if (fbdevHWProbe(NULL,dev,NULL)) { pScrn = NULL; - if (devSections[i]->busID) { + if (isPci) { /* XXX what about when there's no busID set? */ int entity; @@ -283,11 +293,13 @@ pScrn = xf86ConfigPciEntity(pScrn,0,entity, NULL,RES_SHARED_VGA, NULL,NULL,NULL,NULL); + /* xf86DrvMsg() can't be called without setting these */ + pScrn->driverName = FBDEV_DRIVER_NAME; + pScrn->name = FBDEV_NAME; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "claimed PCI slot %d:%d:%d\n",bus,device,func); - } else { - /* XXX This is a quick hack */ + } else if (isIsa) { int entity; entity = xf86ClaimIsaSlot(drv, 0, @@ -295,6 +307,14 @@ pScrn = xf86ConfigIsaEntity(pScrn,0,entity, NULL,RES_SHARED_VGA, NULL,NULL,NULL,NULL); + } else { + int entity; + + entity = xf86ClaimFbSlot(drv, 0, + devSections[i], TRUE); + pScrn = xf86ConfigFbEntity(pScrn,0,entity, + NULL,NULL,NULL,NULL); + } if (pScrn) { foundScreen = TRUE; @@ -426,7 +446,14 @@ if (NULL == pScrn->modes) fbdevHWUseBuildinMode(pScrn); pScrn->currentMode = pScrn->modes; - pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ + + if (fPtr->shadowFB) + pScrn->displayWidth = pScrn->virtualX; /* ShadowFB handles this correctly */ + else + /* FIXME: this doesn't work for all cases, e.g. when each scanline + has a padding which is independent from the depth (controlfb) */ + pScrn->displayWidth = fbdevHWGetLineLength(pScrn)/(fbdevHWGetDepth(pScrn) >> 3); + xf86PrintModes(pScrn); /* Set display resolution */ @@ -512,7 +539,7 @@ unsigned char *src, *dst; Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = pScrn->displayWidth * Bpp; + FBPitch = fbdevHWGetLineLength(pScrn); while(num--) { width = (pbox->x2 - pbox->x1) * Bpp; @@ -740,6 +767,10 @@ if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPalette, NULL, flags)) return FALSE; +#ifdef DPMSExtension + xf86DPMSInit(pScreen, FBDevDPMSSet, 0); +#endif + pScreen->SaveScreen = FBDevSaveScreen; /* Wrap the current CloseScreen function */ @@ -778,3 +809,12 @@ pScreen->CloseScreen = fPtr->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); } + + +#ifdef DPMSExtension +static void +FBDevDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + fbdevHWDPMSSet(pScrn, mode, flags); +} +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp:1.8 xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp:1.8 Tue Jun 13 22:13:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp Mon Dec 11 17:40:25 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp,v 1.8 2000/06/14 02:13:09 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp,v 1.10 2000/12/11 22:40:25 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH FBDEV __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH FBDEV __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME fbdev \- video driver for framebuffer device .SH SYNOPSIS @@ -45,6 +45,9 @@ .B Options are supported: .TP +.BI "Option \*qfbdev\*q \*q" string \*q +The framebuffer device to use. Default: /dev/fb0. +.TP .BI "Option \*qShadowFB\*q \*q" boolean \*q Enable or disable use of the shadow framebuffer layer. See shadowfb(__drivermansuffix__) for further information. Default: on. @@ -52,4 +55,4 @@ XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__), fbdevhw(__drivermansuffix__) .SH AUTHORS -Authors include: Gerd Knorr +Authors include: Gerd Knorr, Michel Dänzer, Geert Uytterhoeven Index: xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile:1.3 xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile:1.3 Tue Mar 7 09:31:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile Sat Oct 21 21:41:58 2000 @@ -1,7 +1,7 @@ XCOMM XCOMM This is an Imakefile for the glide driver. XCOMM -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile,v 1.3 2000/03/07 14:31:45 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/Imakefile,v 1.5 2000/10/22 01:41:58 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -28,7 +28,8 @@ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf8_32bpp\ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb + -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb \ + -I$(EXTINCSRC) -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp:1.10 xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp:1.10 Tue Jun 13 22:13:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp Mon Dec 11 15:18:12 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp,v 1.10 2000/06/14 02:13:09 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp,v 1.11 2000/12/11 20:18:12 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH GLIDE __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH GLIDE __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME glide \- Glide video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c:1.15 xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c:1.15 Wed Jun 21 13:28:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c Sat Dec 2 10:30:38 2000 @@ -45,7 +45,7 @@ * Support static loading. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c,v 1.15 2000/06/21 17:28:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c,v 1.19 2000/12/02 15:30:38 tsi Exp $ */ #include "xaa.h" #include "xf86Cursor.h" @@ -374,7 +374,7 @@ { GrHwConfiguration hw; int i, sst, r; - GDevPtr *devList = NULL; + GDevPtr *devList; GDevPtr dev = NULL; int numdevList; Bool foundScreen = FALSE; @@ -442,7 +442,7 @@ } cleanup: - if (devList) xfree(devList); + xfree(devList); return foundScreen; } @@ -835,7 +835,8 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; GLIDEPtr pGlide = GLIDEPTR(pScrn); - GLIDERestore(pScrn, TRUE); + if (pScrn->vtSema) + GLIDERestore(pScrn, TRUE); xfree(pGlide->ShadowPtr); pScrn->vtSema = FALSE; @@ -1014,7 +1015,7 @@ #define GLIDE_FIND_FUNC(x) \ - p##x = (p##x##_t)xf86LoaderCheckSymbol(#x); \ + p##x = (p##x##_t)LoaderSymbol(#x); \ if (!p##x) \ { \ xf86Msg(X_ERROR, "Could not find " #x "() in libglide2x.so.\n"); \ Index: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile:1.28 xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile:1.29 --- xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile:1.28 Mon Jun 12 06:11:37 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile Tue Sep 19 20:09:21 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.28 2000/06/12 10:11:37 alanh Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.29 2000/09/20 00:09:21 keithp Exp $ XCOMM XCOMM This is an Imakefile for the GLINT driver. XCOMM @@ -35,7 +35,8 @@ -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(EXTINCSRC) $(DRIINCLUDES) \ -I$(XF86SRC)/shadowfb -I$(XF86SRC)/fbdevhw \ - -I$(XTOP)/include -I$(XF86OSSRC)/vbe + -I$(XTOP)/include -I$(XF86OSSRC)/vbe \ + -I$(SERVERSRC)/render #endif DEFINES = $(GLX_DEFINES) -DPPC_MMIO_IS_BE Index: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3:1.1 xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3:1.1 Tue Jun 13 19:34:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 Tue Dec 12 12:02:43 2000 @@ -1,55 +1,105 @@ -STATUS as of Sat, 10 Jun 2000 13:43:50 +0200. +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.6 2000/12/12 17:02:43 dawes Exp $ */ + +STATUS as of Mon, 16 Oct 2000 21:24:51 +0200 + +Working : + * Unaccelerated : Depth 8, 15, 16 and 24 are ok. I tested them upto + 1280x1024 only as my monitor don't support higher modes. + * Untested on big endian systems, i had some reports of endianess problems + with a Permedia4 though, so i suppose things are broken for Permedia3 + also. If you encounter problems, please contact me or try with + acceleration disabled. + * HW cursor. + * ShadowFb works. + * Full 2D Accels. + - Sync. + - Pixmap cache. + - Offscreen pixmaps. + - Clipping. + - Screen to screen copy. + - Solid fills. + - HorVert Solid Lines . + - 8x8 Mono Pattern Fills. + - Color Expansion Fills. + - Images Writes. + - Bitmap Writes using direct FIFO writes with or without FIFO Disconnect. + - Pixmap Writes using direct FIFO writes with or without FIFO Disconnect. + * Appian J2000 second head initialization. + * Dual head : The console fonts will get trashed, but dual head works. + * DRI : + - Gamma, if available, get's claimed with the UseGamma option. +Not Working : + * 2D Accel : + - Solid & Dashed Lines are not possible on glint hardware. + - 8x8 Color Pattern Fill is almost never used. + - Clipping needs cleaning up. + - Seems broken on big endian systems, cannot test it though. + * 2D Accel hooks for the Rendering extension ? + - Render extension initialization. + - CPUToScreenTexture. + - CPUToScreenAlphaTexture. + * Video Overlay. + * DRI. + +Known Problem : + + * Console gets broken when using dual headed mode. The culprit seems to be + the vga graphics index & port (GraphicsIndexReg : 0x63ce, GraphicsPort : + 0x3cf). I had to use IO acces for both these two, because if not, console + fonts would get trashed even in mono headed mode. + [FIX] Well, if you really need the console and are running linux, just use + vesafb, it will be a bit slower, but the fonts will no more become + corrupt. Maybe i will even try writting a specific fbdev for the pm3, + which will be much faster and have more functionality. + * R-B inversion. Sometimes, all of a sudden, it seems as the RGB order + gets changed. going to console and back solves this. + * [TRIGGERED IN ENLIGTHENMENT ONLY] When moving a window around a lot + quicly, the video outputs dies. I have to switch to a console and back + to have it restored. Is it possible that the accel engine gets + overloaded or something such ? Don't think so, it happens even when + PCIRetry is used too ... + * Sometimes there are blue transparent garbage in the form of small + horizontal bands, few pixels high, and more pixels width, maybe 64pixels ? + +Video Overlay [NOTHING DONE YET] : + + * I have not done anything yet here. + +DRI/3D Accels [NOTHING DONE YET] : + + * First approach would be to use the gamma for one head only (most probably + the first head, it could be configurable though). + * Sharing the gamma between both driver instances would need a setup similar + of what was done for the Matrox dualheaded G400 (mga driver). + * Alternatively it could be possible to use DRI with the gamma on one head, + and DRI with the pm3 alone on the second head. This would need writing a + pm3 drm kernel driver as well as a pm3 OpenGL driver. Could be useful for + boards without gamma chips though. + + * Claiming the Gamma (in the one head only approach) : + - The first possibility is the use of the UseGamma Option in the driver + section. The UseGamma option then tries to claim a gamma chip, if + available, on the same device. This enable the use of the gamma on + either head, in a two head setup. + - The second possibility is the automatic claiming of a gamma chip if + available. This works ok in single headed mode, but in dual head setup, + only the first head will be accelerated. + * Using the Gamma : + - A first try of using the Gamma (for 2D only) gave me a system freeze. + This is probably due to bad initialization since i only set the IOBase + to the Gamma registers, and did nothing more to initialize the Gamma. + I need more info on initialization of the Gamma chip, especially on how + to tell it which Permedia3 to use. + - A Second try, after initializing MultiGLINTAperture and MultiGLINT1 did + end in the same way. + - Once that is done, i need to write a pm3_dri.c file, inspired on the + glint_dri.c file, which does the dri setup, and the 2d/3d state saving. + * Changes to the 2D driver when using the Gamma : + - Well, there could be some changes, but in particular, the Gamma has only + a 32 entries deep Input FIFO, and not a 120 entries deep one like + permedia3. + - Another idea, is to use Gamma bypass when doing 2D accels. This way, we + don't have to worry about the Gamma smaller input Fifo. But we need to + sync the gamma also when doing syncs. Not sure where the right place for + this is though. Maybe when switching between 2D and 3D ? -Known problems : - - * Dual head : worked with 4.0a, but got broken in 4.0b - * Depth 8 with 8bpp : Tested only upto 1280x1024 as my monitor don't support - higher modes. - * Depth 15, 16 with 16 bpp : Modes above 1024x768 show a partial overlap - of the screen on the right. - * Depth 24 with 32 bpp : left half of the screen is repeated on the - right half. - * 2D Accel : only clipping pseudo accel is working. - * Video overlay : not supported by pm3 yet. - -Unaccelerated video modes : - - * [OK] Depths 8 is working upto 1280x1024 (didn't test higher modes). - * [PROBLEM] Depth 15 and 16 are working up to 1024x768 modes. Higher modes - show a partial overlap of the screen on the right. - * [PROBLEM] Depth 24, 32 bpp : the screen is repeated in the second half - * [NEED HELP] Dot clock is 300MHz. I see pm2 is lowering dotclock for - 24 & 32 bpp. I did the same for now, but don't know if it is the right. - -Hardware features : - - * [OK] HW cursor & ShadowFb works. - -Video Overlay : - - * [NOTHING DONE] Video Overlay is untested. nothing has been done here. - -2D Accels : - - * [NEED MORE WORK] only clipping pseudo accel is enabled, it makes a - difference in some case, as for example the Gnome logout anim. - True accels need more work, especially accel engine setup need to be - done with pm3 values. - -Dual head : - - * [NEW PROBLEM] Dual head got broken in 4.0b. Culprit is the pci slot - claiming code in GLINTProbe, around line 700 of glint_driver.c - * [OK] Dual head did working fine, just, i didn't know how to make - enlightenment use both heads (:0.0 and :0.1). 3.3.6 twm has also - problems with this, should use 4.0 twm instead maybe. - * [SOLUTION] I need to make a XF86Config with orientation of various screens. - - * [NEED TESTING ON NON J2000 BOARD] Second head of Jeronimo 2000 is not - initialized by the bios, So memory timings need to be set. I set them only - if subsysVendor & subsysCard are matching J2000. Need feedback of other - dual pm3 boards. - - - -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.1 2000/06/13 23:34:38 dawes Exp $ */ Index: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp:1.7 xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp:1.7 Tue Jun 13 22:13:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp Mon Dec 11 15:18:13 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp,v 1.7 2000/06/14 02:13:09 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp,v 1.10 2000/12/11 20:18:13 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH GLINT __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH GLINT __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME glint \- GLINT/Permedia video driver .SH SYNOPSIS @@ -18,9 +18,6 @@ cards. The driver is rather fully accelerated, and provides support for the following framebuffer depths: 8, 15 (may give bad results with FBDev support), 16, 24 (32 bpp recommended, 24 bpp has problems), 30, and an 8+24 overlay mode. -.B Glint permedia 3 -only support depth 8 (tested upto 1280x1024) and 15/16 -(ok upto 1024x768, partial screen overlap on the right at 1280x1024) and acceleration is not yet fully supported. .SH SUPPORTED HARDWARE The .B glint @@ -110,18 +107,8 @@ The driver will try to auto-detect the memory clock for all chips. If it's not detected correctly, the actual value (in MHz) should be specified with this option. -.SH Known problems with the Glint Permedia 3 chip -The -.B Glint Permedia 3 -chip is newly supported since the 4.0.1 release but is still work in progress. -The driver supports already unaccelerated modes at depth 8 (tested upto -1280x1024) and depth 15 and 16 (ok upto 1024x768) -Depth 24 and Depth 15 and 16 with modes higher than 1024x768 are showing a -partial overlap of the right part of the screen. -Acceleration only support clipping pseudo acceleration. -Dual head for the Appian J2000 board was working but got broken since 4.0b, -since now the driver claims all chip of the board. .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) .SH AUTHORS -Authors include: Alan Hourihane, Dirk Hohndel, Stefan Dirsch, Michel Dänzer +Authors include: Alan Hourihane, Dirk Hohndel, Stefan Dirsch, Michel Dänzer, +Sven Luther Index: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h:1.31 xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h:1.37 --- xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h:1.31 Sat Jun 17 12:32:50 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h Tue Nov 14 12:32:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.31 2000/06/17 16:32:50 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.37 2000/11/14 17:32:59 dawes Exp $ */ /* * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk> * @@ -96,7 +96,7 @@ int planemask; int realMXWidth; CARD32 IOAddress; - CARD32 FbAddress; + unsigned long FbAddress; int irq; unsigned char * IOBase; unsigned char * IOBaseVGA; @@ -142,6 +142,15 @@ I2CBusPtr DDCBus, VSBus; CARD8* XAAScanlineColorExpandBuffers[2]; CARD32 RasterizerSwap; + int PM3_Config2D; + int PM3_Render2D; + int PM3_AreaStippleMode; + int PM3_VideoControl; + Bool PM3_UseGamma; + pciVideoPtr PM3_GammaPciInfo; + PCITAG PM3_GammaPciTag; + CARD32 PM3_GammaIOAddress; + unsigned char * PM3_GammaIOBase; #ifdef XF86DRI Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -206,15 +215,16 @@ Bool Permedia2vHWCursorInit(ScreenPtr pScreen); /* pm3_dac.c */ -void Permedia3PreInit(ScrnInfoPtr pScrn, GLINTPtr pGlint); +void Permedia3PreInit(ScrnInfoPtr pScrn); int Permedia3MemorySizeDetect(ScrnInfoPtr pScrn); void Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode); -Bool Permedia3HWCursorInit(ScreenPtr pScreen); /* pm3_accel.c */ -Bool Permedia3AccelInit(ScreenPtr pScreen); +/* Not needed, ... is it ever called outside of pm3_accel.c ? void Permedia3Sync(ScrnInfoPtr pScrn); +*/ +Bool Permedia3AccelInit(ScreenPtr pScreen); void Permedia3InitializeEngine(ScrnInfoPtr pScrn); /* End of pm3 stuff */ Index: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c:1.89 xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c:1.103 --- xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c:1.89 Thu Jun 22 06:40:48 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c Fri Dec 8 08:42:35 2000 @@ -28,7 +28,7 @@ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen, * Siemens Nixdorf Informationssysteme and Appian Graphics. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.89 2000/06/22 10:40:48 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.103 2000/12/08 13:42:35 alanh Exp $ */ #include "fb.h" #include "cfb8_32.h" @@ -179,10 +179,12 @@ OPTION_OVERLAY, OPTION_SHADOW_FB, OPTION_FBDEV, - OPTION_NOWRITEBITMAP + OPTION_NOWRITEBITMAP, + OPTION_PM3_USE_GAMMA } GLINTOpts; static OptionInfoRec GLINTOptions[] = { + { OPTION_PM3_USE_GAMMA, "UseGamma", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, @@ -249,6 +251,9 @@ static const char *fbSymbols[] = { "cfb8_32ScreenInit", +#ifdef RENDER + "fbPictureInit", +#endif "fbScreenInit", "fbBres", NULL @@ -591,7 +596,7 @@ { int i; pciVideoPtr pPci, *checkusedPci; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int numDevSections; int numUsed,bus,device,func; char *dev; @@ -612,7 +617,7 @@ checkusedPci = xf86GetPciVideoInfo(); - if (checkusedPci == NULL) { + if (checkusedPci == NULL && devSections /* for xf86DoProbe */) { /* * Changed the behaviour to try probing using the FBDev support * when no PCI cards have been found. This is for systems without @@ -679,14 +684,12 @@ xfree(devSections); - } else { + } else if (checkusedPci) { numUsed = xf86MatchPciInstances(GLINT_NAME, 0, GLINTChipsets, GLINTPciChipsets, devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; foundScreen = TRUE; @@ -702,7 +705,6 @@ pPci = xf86GetPciInfoForEntity(usedChips[i]); - /* Only claim other chips when GAMMA is used */ if (pPci->chipType == PCI_CHIP_GAMMA) { while (*checkusedPci != NULL) { @@ -742,7 +744,7 @@ } } - if (usedChips) xfree(usedChips); + xfree(usedChips); TRACE_EXIT("GLINTProbe"); return foundScreen; @@ -802,25 +804,25 @@ GLINTPtr pGlint; CARD32 temp = 0; pGlint = GLINTPTR(pScrn); + + pGlint->RamDacRec = RamDacCreateInfoRec(); if (pGlint->numMXDevices == 2) { - pGlint->RamDacRec = RamDacCreateInfoRec(); pGlint->RamDacRec->ReadDAC = DUALglintInTIIndReg; pGlint->RamDacRec->WriteDAC = DUALglintOutTIIndReg; pGlint->RamDacRec->ReadAddress = DUALglintTIReadAddress; pGlint->RamDacRec->WriteAddress = DUALglintTIWriteAddress; pGlint->RamDacRec->ReadData = DUALglintTIReadData; pGlint->RamDacRec->WriteData = DUALglintTIWriteData; - pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette; } else { - pGlint->RamDacRec = RamDacCreateInfoRec(); pGlint->RamDacRec->ReadDAC = glintInTIIndReg; pGlint->RamDacRec->WriteDAC = glintOutTIIndReg; pGlint->RamDacRec->ReadAddress = glintTIReadAddress; pGlint->RamDacRec->WriteAddress = glintTIWriteAddress; pGlint->RamDacRec->ReadData = glintTIReadData; pGlint->RamDacRec->WriteData = glintTIWriteData; - pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette; } + pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette; + if(!RamDacInit(pScrn, pGlint->RamDacRec)) { RamDacDestroyInfoRec(pGlint->RamDacRec); return; @@ -1206,6 +1208,57 @@ xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); + /* SVEN : Claim a Gamma chip if available. */ + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) { + int eIndex = -1; + from = X_DEFAULT; + pGlint->PM3_UseGamma = FALSE; + if (xf86ReturnOptValBool(GLINTOptions, OPTION_PM3_USE_GAMMA, FALSE)) { + from = X_CONFIG; + pGlint->PM3_UseGamma = TRUE; + } + xf86DrvMsg(pScrn->scrnIndex, from, "%s to use Gamma with Permedia 3.\n", + (pGlint->PM3_UseGamma ? "Trying" : "Not trying")); + if (pGlint->PM3_UseGamma) { + pciVideoPtr *checkusedPci; + checkusedPci = xf86GetPciVideoInfo(); + while (*checkusedPci != NULL) { + /* Is there a free gamma on the same device ? */ + if (((*checkusedPci)->chipType == PCI_CHIP_GAMMA) && + (((*checkusedPci)->bus == pGlint->PciInfo->bus)) && + (((*checkusedPci)->device == pGlint->PciInfo->device))) + if ((eIndex = xf86ClaimPciSlot((*checkusedPci)->bus, + (*checkusedPci)->device, + (*checkusedPci)->func, + pScrn->drv, -1, + NULL, FALSE)) != -1) break; + } + checkusedPci++; + } + if (eIndex == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "No free Gamma chip was found.\n"); + pGlint->PM3_UseGamma = FALSE; + } else { + unsigned int r; + /* Add the Gamma to the screen info structure. */ + xf86AddEntityToScreen(pScrn,eIndex); + pGlint->PM3_GammaPciInfo = + xf86GetPciInfoForEntity(eIndex); + pGlint->PM3_GammaPciTag = pciTag( + pGlint->PM3_GammaPciInfo->bus, + pGlint->PM3_GammaPciInfo->device, + pGlint->PM3_GammaPciInfo->func); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Gamma Claimed at BusID PCI:%d:%d:%d.\n", + pGlint->PM3_GammaPciInfo->bus, + pGlint->PM3_GammaPciInfo->device, + pGlint->PM3_GammaPciInfo->func); + /* Let's dump the Gamma registers, at least some of them ... */ + pGlint->PM3_GammaIOAddress = + pGlint->PM3_GammaPciInfo->memBase[0] & 0xFFFFC000; + } + } if ((pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) || (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || @@ -1262,6 +1315,11 @@ */ pGlint->IOAddress = pGlint->pEnt->device->IOBase; from = X_CONFIG; +#if 0 /* This freezes the box, why ? */ + } else if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) && + pGlint->PM3_UseGamma) { + pGlint->IOAddress = pGlint->PM3_GammaPciInfo->memBase[0] & 0xFFFFC000; +#endif } else { pGlint->IOAddress = pGlint->PciInfo->memBase[0] & 0xFFFFC000; } @@ -1275,7 +1333,7 @@ pGlint->irq = pGlint->pEnt->device->irq; /* Register all entities */ - for (i = 1; i < pScrn->numEntities; i++) { + for (i = 0; i < pScrn->numEntities; i++) { EntityInfoPtr pEnt; pEnt = xf86GetEntityInfo(pScrn->entityList[i]); if (xf86RegisterResources(pEnt->index, NULL, ResExclusive)) { @@ -1301,9 +1359,12 @@ * than a J2000, as memory timings will surely change. */ GLINTMapMem(pScrn); - Permedia3PreInit(pScrn, pGlint); + Permedia3PreInit(pScrn); GLINTUnmapMem(pScrn); pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); + } else if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) { + /* The PM2v has the same problem detecting memory as the PM3 */ + pScrn->videoRam = Permedia3MemorySizeDetect(pScrn); } else { pGlint->FbMapSize = 0; /* Need to set FbMapSize for MMIO access */ /* Need to access MMIO to determine videoRam */ @@ -1429,7 +1490,6 @@ return FALSE; } break; - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: maxheight = 2048; maxwidth = 2048; @@ -1447,6 +1507,23 @@ return FALSE; } break; + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + maxheight = 4096; + maxwidth = 4096; + pGlint->RefClock = 14318; + pGlint->VGAcore = TRUE; + pGlint->RamDacRec = RamDacCreateInfoRec(); + pGlint->RamDacRec->ReadDAC = Permedia2vInIndReg; + pGlint->RamDacRec->WriteDAC = Permedia2vOutIndReg; + pGlint->RamDacRec->ReadAddress = Permedia2ReadAddress; + pGlint->RamDacRec->WriteAddress = Permedia2WriteAddress; + pGlint->RamDacRec->ReadData = Permedia2ReadData; + pGlint->RamDacRec->WriteData = Permedia2WriteData; + if(!RamDacInit(pScrn, pGlint->RamDacRec)) { + RamDacDestroyInfoRec(pGlint->RamDacRec); + return FALSE; + } + break; case PCI_VENDOR_TI_CHIP_PERMEDIA: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: maxheight = 1024; @@ -1454,7 +1531,7 @@ pGlint->VGAcore = TRUE; /* chip has a vga core */ GLINTProbeIBMramdac(pScrn); if (pGlint->RamDac == NULL) return FALSE; - if (pGlint->RamDac->RamDacType != (IBM526DB_RAMDAC) || + if (pGlint->RamDac->RamDacType != (IBM526DB_RAMDAC) && pGlint->RamDac->RamDacType != (IBM526_RAMDAC)) return FALSE; pGlint->RefClock = 14318; @@ -1593,25 +1670,9 @@ pGlint->MaxClock = 110000; break; } - } - if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) ) { - switch (pScrn->bitsPerPixel) { - case 8: - pGlint->MaxClock = 300000; - break; - case 16: - pGlint->MaxClock = 300000; - break; - case 24: - /* Not sure about the 24 & 32 bpp clocks, ... */ - pGlint->MaxClock = 150000; - break; - case 32: - /* Not sure about the 24 & 32 bpp clocks, ... */ - pGlint->MaxClock = 150000; - break; - } } + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) + pGlint->MaxClock = 300000; } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", pGlint->MaxClock / 1000); @@ -1636,7 +1697,8 @@ */ /* Select valid modes from those available */ - if (pGlint->NoAccel) { + if ((pGlint->NoAccel) || + (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3)) { /* * XXX Assuming min pitch 256, max <maxwidth> * XXX Assuming min height 128, max <maxheight> @@ -1743,7 +1805,6 @@ case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: case PCI_VENDOR_TI_CHIP_PERMEDIA: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: pGlint->pprod = partprodPermedia[pScrn->displayWidth >> 5]; @@ -2034,10 +2095,10 @@ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase, pGlint->FbMapSize); pGlint->FbBase = NULL; + TRACE_EXIT("GLINTUnmapMem"); return TRUE; } - /* * This function saves the video state. */ @@ -2304,9 +2365,19 @@ if (!vgaHWMapMem(pScrn)) return FALSE; } + /* Timing problem with PM3 & PM2V chips dont like being blasted */ - if ((pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) && - (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V)) + /* This solves the dual head problem but trahses the console font. */ + if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) { + /* Graphics Index VGA register don't work in mmio mode + * for the Permedia3 chip, it thrashes the console font. + * Let's keep the IO functions for this instead ... */ + vgaHWWriteIndexProcPtr writeGr = hwp->writeGr; + vgaHWReadIndexProcPtr readGr = hwp->readGr; + vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); + hwp->writeGr = writeGr; + hwp->readGr = readGr; + } else if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0); vgaHWGetIOBase(hwp); } @@ -2382,6 +2453,8 @@ miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; + if (!miSetPixmapDepths()) + return FALSE; } #ifdef XF86DRI @@ -2421,6 +2494,10 @@ pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit(pScreen, 0, 0); +#endif break; case 32: if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) @@ -2428,11 +2505,16 @@ pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth); - else + else { ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit(pScreen, 0, 0); +#endif + } break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -2509,12 +2591,10 @@ (pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2)) Permedia2HWCursorInit(pScreen); else - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) + if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) || + (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3)) Permedia2vHWCursorInit(pScreen); else - if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) - Permedia3HWCursorInit(pScreen); - else /* If we get here pGlint->Ramdac should have been set */ if ( ((pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC)) || (pGlint->RamDac->RamDacType == (IBM526_RAMDAC)) || @@ -2620,6 +2700,7 @@ pScrn = xf86Screens[scrnIndex]; pGlint = GLINTPTR(pScrn); + TRACE_ENTER("GLINTSwitchMode"); if (pGlint->FBDev) { Bool ret = fbdevHWSwitchMode(scrnIndex, mode, flags); @@ -2652,9 +2733,11 @@ } } + TRACE_EXIT("GLINTSwitchMode (fbdev ?)"); return ret; } + TRACE_EXIT("GLINTSwitchMode (normal)"); return GLINTModeInit(xf86Screens[scrnIndex], mode); } @@ -2673,17 +2756,14 @@ pScrn = xf86Screens[scrnIndex]; pGlint = GLINTPTR(pScrn); + TRACE_ENTER("GLINTAdjustFrame"); if (pGlint->FBDev) { fbdevHWAdjustFrame(scrnIndex, x, y, flags); + TRACE_EXIT("GLINTAdjustFrame (fbdev)"); return; } - if (pGlint->VGAcore) { - vgaHWPtr hwp; - hwp = VGAHWPTR(pScrn); - } - base = ((y * pScrn->displayWidth + x) >> 1) >> pGlint->BppShift; if (pScrn->bitsPerPixel == 24) base *= 3; @@ -2698,6 +2778,7 @@ GLINT_SLOW_WRITE_REG(base, PMScreenBase); break; } + TRACE_EXIT("GLINTAdjustFrame (normal)"); } @@ -2818,13 +2899,13 @@ if (pScrn->vtSema) { if(pGlint->CursorInfoRec) - pGlint->CursorInfoRec->HideCursor(pScrn); + pGlint->CursorInfoRec->HideCursor(pScrn); if (pGlint->FBDev) - fbdevHWRestore(pScrn); + fbdevHWRestore(pScrn); else { - GLINTRestore(pScrn); - if (pGlint->VGAcore) - vgaHWLock(VGAHWPTR(pScrn)); + GLINTRestore(pScrn); + if (pGlint->VGAcore) + vgaHWLock(VGAHWPTR(pScrn)); } GLINTUnmapMem(pScrn); } @@ -2937,22 +3018,27 @@ unblank = xf86IsUnblank(mode); - switch (pGlint->Chipset) { - case PCI_VENDOR_TI_CHIP_PERMEDIA2: - case PCI_VENDOR_TI_CHIP_PERMEDIA: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: - case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: - temp = GLINT_READ_REG(PMVideoControl); - if (unblank) temp |= 1; - else temp &= 0xFFFFFFFE; - GLINT_SLOW_WRITE_REG(temp, PMVideoControl); - break; - case PCI_VENDOR_3DLABS_CHIP_500TX: - case PCI_VENDOR_3DLABS_CHIP_300SX: - case PCI_VENDOR_3DLABS_CHIP_MX: - break; + if (unblank) + SetTimeSinceLastInputEvent(); + + if ((pScrn != NULL ) && pScrn->vtSema) { + switch (pGlint->Chipset) { + case PCI_VENDOR_TI_CHIP_PERMEDIA2: + case PCI_VENDOR_TI_CHIP_PERMEDIA: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: + case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: + temp = GLINT_READ_REG(PMVideoControl); + if (unblank) temp |= 1; + else temp &= 0xFFFFFFFE; + GLINT_SLOW_WRITE_REG(temp, PMVideoControl); + break; + case PCI_VENDOR_3DLABS_CHIP_500TX: + case PCI_VENDOR_3DLABS_CHIP_300SX: + case PCI_VENDOR_3DLABS_CHIP_MX: + break; + } } TRACE_EXIT("GLINTSaveScreen"); Index: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h:1.19 xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h:1.21 --- xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h:1.19 Wed May 10 16:01:31 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h Tue Sep 19 10:12:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.19 2000/05/10 20:01:31 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.21 2000/09/19 14:12:32 alanh Exp $ */ /* * glint register file @@ -93,10 +93,6 @@ #define SCLK_SEL_MCLK_HALF (3 << 10) #define ByDMAControl 0x00D8 -/* GLINT R3 & Permedia3 Region 0 Bypass Controls */ -#define PM3ByAperture1Mode 0x0300 -#define PM3ByAperture2Mode 0x0328 - /* GLINT 500TX LocalBuffer Registers */ #define LBMemoryCtl 0x1000 #define LBNumBanksMask 0x00000001 @@ -199,17 +195,6 @@ #define PMFramebufferWriteMask 0x1140 #define PMCount 0x1180 -/* Permedia 3 & GLINT R3 Memory Control */ -#define PM3MemCounter 0x1000 -#define PM3MemBypassWriteMask 0x1008 -#define PM3MemScratch 0x1010 -#define PM3LocalMemCaps 0x1018 -#define PM3LocalMemTimings 0x1020 -#define PM3LocalMemControl 0x1028 -#define PM3LocalMemRefresh 0x1030 -#define PM3LocalMemPowerDown 0x1038 -#define PM3RemoteMemControl 0x1100 - /* Framebuffer Registers */ #define FBMemoryCtl 0x1800 #define FBModeSel 0x1808 @@ -494,8 +479,6 @@ #define GMultGLINT1 0x0d10 #define GMultGLINT2 0x0d18 - - /************************ * GLINT Core Registers * ************************/ @@ -504,7 +487,7 @@ #define GLINT_TAG_ADDR(major,offset) (0x8000 | GLINT_TAG((major),(offset))) #define UNIT_DISABLE 0 -#define UNIT_ENABLE 1 +#define UNIT_ENABLE 1 #define StartXDom GLINT_TAG_ADDR(0x00,0x00) #define dXDom GLINT_TAG_ADDR(0x00,0x01) @@ -955,9 +938,10 @@ /* 0: */ /* FBWM_NoColorUpload */ /* FBWM_WriteDisable */ - #define FBWM_WriteEnable 1 #define FBWM_UploadColor 1 << 3 +/* Permedia3 extensions */ + #define FBWM_Enable0 1 << 12 #define FBHardwareWriteMask GLINT_TAG_ADDR(0x15,0x08) #define FBBlockColor GLINT_TAG_ADDR(0x15,0x09) @@ -1151,6 +1135,30 @@ #define DrawLine10 GLINT_TAG_ADDR(0x26,0x04) #define RepeatLine GLINT_TAG_ADDR(0x26,0x05) #define BroadcastMask GLINT_TAG_ADDR(0x26,0x0F) + +/* Permedia 3 - Accelerator Extensions */ +#define FillRectanglePosition 0x8348 +#define FillRender2D 0x8350 +#define FBDstReadBufAddr0 0xAE80 +#define FBDstReadBufOffset0 0xAEA0 +#define FBDstReadBufWidth0 0xAEC0 +#define FBDstReadMode 0xAEE0 +#define FBDRM_Enable0 1<<8 +#define FBDRM_Blocking 1<<24 +#define FBDstReadEnables 0xAEE8 +#define FBSrcReadMode 0xAF00 +#define FBSRM_Blocking 1<<11 +#define FBSrcReadBufAddr 0xAF08 +#define FBSrcReadBufOffset0 0xAF10 +#define FBSrcReadBufWidth 0xAF18 +#define FBWriteBufAddr0 0xB000 +#define FBWriteBufOffset0 0xB020 +#define FBWriteBufWidth0 0xB040 +#define FBBlockColorBack 0xB0A0 +#define ForegroundColor 0xB0C0 +#define BackgroundColor 0xB0C8 +#define RectanglePosition 0xB600 +#define Render2D 0xB640 /* Colorformats */ #define BGR555 1 Index: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c:1.18 xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c:1.18 Sat Feb 12 15:45:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c Mon Sep 11 12:58:56 2000 @@ -28,7 +28,7 @@ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and * Siemens Nixdorf Informationssysteme */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c,v 1.18 2000/02/12 20:45:22 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_dac.c,v 1.20 2000/09/11 16:58:56 alanh Exp $ */ #include "Xarch.h" #include "xf86.h" @@ -164,7 +164,7 @@ pReg->glintRegs[PMVbEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay; /* The hw cursor needs /VSYNC to recognize vert retrace. We'll stick - both sync lines to active low here and if needed invert them + both sync lines to active high here and if needed invert them using the RAMDAC's MCR below. */ pReg->glintRegs[PMVideoControl >> 3] = (1 << 5) | (1 << 3) | 1; @@ -247,7 +247,7 @@ PM2DAC_GRAPHICS | PM2DAC_8888; if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { pReg->DacRegs[PM2DACIndexColorKeyControl] = 0x11; - pReg->DacRegs[PM2DACIndexColorKeyOverlay] = 0xFF; + pReg->DacRegs[PM2DACIndexColorKeyOverlay] = pScrn->colorKey; } else pReg->DacRegs[PM2DACIndexCMR] |= PM2DAC_TRUECOLOR; break; Index: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c:1.13 xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c:1.13 Wed May 10 14:55:30 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c Mon Sep 11 12:58:56 2000 @@ -27,7 +27,7 @@ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and * Siemens Nixdorf Informationssysteme */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c,v 1.13 2000/05/10 18:55:30 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c,v 1.17 2000/09/11 16:58:56 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -170,7 +170,7 @@ pReg->glintRegs[PMVTotal >> 3] -= 1; /* PMVTotal */ pReg->glintRegs[ChipConfig >> 3] = GLINT_READ_REG(ChipConfig) & 0xFFFFFFDD; - pReg->DacRegs[PM2VDACRDDACControl] = 0x00; + pReg->DacRegs[PM2VDACRDDACControl] = 0x80; { /* Get the programmable clock values */ @@ -195,7 +195,7 @@ if (!(mode->Flags & V_PHSYNC)) pReg->DacRegs[PM2VDACRDSyncControl] |= 0x01; /* invert hsync */ if (!(mode->Flags & V_PVSYNC)) - pReg->DacRegs[PM2VDACRDSyncControl] |= 0x04; /* invert vsync */ + pReg->DacRegs[PM2VDACRDSyncControl] |= 0x08; /* invert vsync */ switch (pScrn->bitsPerPixel) { @@ -204,7 +204,6 @@ pReg->DacRegs[PM2VDACRDColorFormat] = 0x2E; break; case 16: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x01; if (pScrn->depth == 15) pReg->DacRegs[PM2VDACRDColorFormat] = 0x61; @@ -212,17 +211,15 @@ pReg->DacRegs[PM2VDACRDColorFormat] = 0x70; break; case 24: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x04; pReg->DacRegs[PM2VDACRDColorFormat] = 0x60; break; case 32: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x02; pReg->DacRegs[PM2VDACRDColorFormat] = 0x20; if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { pReg->DacRegs[PM2VDACRDMiscControl] |= 0x10; - pReg->DacRegs[PM2VDACRDOverlayKey] = 0xFF; + pReg->DacRegs[PM2VDACRDOverlayKey] = pScrn->colorKey; } break; } @@ -401,6 +398,7 @@ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorXHigh, 0x00, (x>>8) & 0x0F); Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYLow, 0x00, y & 0xFF); Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYHigh, 0x00, (y>>8) & 0x0F); + Permedia2vOutIndReg(pScrn, PM2DACCursorControl, 0x00, 0x00); } static void @@ -409,16 +407,14 @@ int bg, int fg ) { - int i; - /* The Permedia2v cursor is always 8 bits so shift 8, not 10 */ - - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+0, 0x00, bg >> 16); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+1, 0x00, bg >> 8); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+2, 0x00, bg); - - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3, 0x00, fg >> 16); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+4, 0x00, fg >> 8); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+5, 0x00, fg); + /* A 2 color cursor uses last 2 indexes into hardware cursor palette */ + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+39, 0x00, (fg>>16)&0xff); + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+40, 0x00, (fg>>8)&0xff); + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+41, 0x00, fg & 0xff); + + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+42, 0x00, (bg>>16)&0xff); + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+43, 0x00, (bg>>8)&0xff); + Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+44, 0x00, bg & 0xff); } static Bool Index: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c:1.2 Wed Jun 14 14:20:34 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c Tue Nov 28 11:10:39 2000 @@ -1,36 +1,32 @@ /* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. + * Copyright 2000 by Sven Luther <luther@dpt-info.u-strasbg.fr>. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in + * documentation, and that the name of Sven Luther not be used in * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided + * specific, written prior permission. Sven Luther makes no representations + * about the suitability of this software for any purpose. It is provided * "as is" without express or implied warranty. * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * SVEN LUTHER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * EVENT SHALL SVEN LUTHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> - * Dirk Hohndel, <hohndel@suse.de> - * Stefan Dirsch, <sndirsch@suse.de> - * Mark Vojkovich, <mvojkovi@ucsd.edu> - * Michel Dänzer, <michdaen@iiic.ethz.ch> - * Sven Luther, <luther@dpt-info.u-strasbg.fr> + * Authors: Sven Luther, <luther@dpt-info.u-strasbg.fr> + * Alan Hourihane, <alanh@fairlite.demon.co.uk> * * this work is sponsored by Appian Graphics. * * Permedia 3 accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c,v 1.2 2000/06/14 18:20:34 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c,v 1.7 2000/11/28 16:10:39 dawes Exp $ */ #include "Xarch.h" #include "xf86.h" @@ -45,189 +41,293 @@ #include "fb.h" #include "glint_regs.h" +#include "pm3_regs.h" #include "glint.h" #include "xaalocal.h" /* For replacements */ #define DEBUG 0 +#define USE_DIRECT_FIFO_WRITES 1 #if DEBUG -# define TRACE_ENTER(str) ErrorF("pm2_accel: " str " %d\n",pScrn->scrnIndex) -# define TRACE_EXIT(str) ErrorF("pm2_accel: " str " done\n") -# define TRACE(str) ErrorF("pm2_accel trace: " str "\n") +# define TRACE_ENTER(str) ErrorF("pm3_accel: " str " %d\n",pScrn->scrnIndex) +# define TRACE_EXIT(str) ErrorF("pm3_accel: " str " done\n") +# define TRACE(str) ErrorF("pm3_accel trace: " str "\n") #else # define TRACE_ENTER(str) # define TRACE_EXIT(str) # define TRACE(str) #endif -static void Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask); -static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, - int y, int w, int h); -static void Permedia3SetupForFillRectSolid24bpp(ScrnInfoPtr pScrn,int color, - int rop, unsigned int planemask); -static void Permedia3SubsequentFillRectSolid24bpp(ScrnInfoPtr pScrn, int x, - int y, int w, int h); +/* Sync */ +void Permedia3Sync(ScrnInfoPtr pScrn); +/* Clipping */ +static void Permedia3SetClippingRectangle(ScrnInfoPtr pScrn, int x, int y, + int w, int h); +static void Permedia3DisableClipping(ScrnInfoPtr pScrn); +/* ScreenToScreenCopy */ static void Permedia3SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h); static void Permedia3SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, - int transparency_color); -static void Permedia3SubsequentScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn, - int x1, int y1, int x2, int y2, int w, int h); -static void Permedia3SetupForScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, int transparency_color); -static void Permedia3SetClippingRectangle(ScrnInfoPtr pScrn, int x, int y, - int w, int h); -static void Permedia3DisableClipping(ScrnInfoPtr pScrn); -static void Permedia3SetupForSolidLine(ScrnInfoPtr pScrn, int color, +/* SolidFill */ +static void Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask); -static void Permedia3SubsequentHorVertLine(ScrnInfoPtr pScrn, int x, int y, - int len, int dir); -static void Permedia3SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, - int x, int y, int dmaj, int dmin, int e, - int len, int octant); -static void Permedia3WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, int skipleft, - int fg, int bg, int rop,unsigned int planemask); +static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, + int y, int w, int h); +/* 8x8 Mono Pattern Fills */ static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, - int patternx, int patterny, int fg, int bg, + int patternx, int patterny, int fg, int bg, int rop, unsigned int planemask); static void Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, - int patternx, int patterny, int x, int y, - int w, int h); -static void Permedia3SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn, - int patternx, int patterny, int fg, int bg, - int rop, unsigned int planemask); -static void Permedia3SubsequentMono8x8PatternFillRect24bpp(ScrnInfoPtr pScrn, - int patternx, int patterny, int x, int y, + int x_offset, int y_offset, int x, int y, int w, int h); -static void Permedia3WritePixmap8bpp(ScrnInfoPtr pScrn, int x, int y, int w, - int h, unsigned char *src, int srcwidth, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); -static void Permedia3WritePixmap16bpp(ScrnInfoPtr pScrn, int x, int y, int w, - int h, unsigned char *src, int srcwidth, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); -#if 0 -static void Permedia3WritePixmap24bpp(ScrnInfoPtr pScrn, int x, int y, int w, - int h, unsigned char *src, int srcwidth, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); -#endif -static void Permedia3WritePixmap32bpp(ScrnInfoPtr pScrn, int x, int y, int w, - int h, unsigned char *src, int srcwidth, - int rop, unsigned int planemask, - int transparency_color, int bpp, int depth); +/* Color Expansion Fills */ static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop,unsigned int planemask); static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); -static void Permedia3SetupForScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask); -static void Permedia3SubsequentScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, int x, - int y, int w, int h, int skipleft); -static void Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); -static void Permedia3LoadCoord(ScrnInfoPtr pScrn, int x, int y, int w, int h); -static void Permedia3PolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, - int mode, int npt, DDXPointPtr pPts); -static void Permedia3PolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, - int nseg, xSegment *pSeg); - -#define MAX_FIFO_ENTRIES 256 - -#if X_BYTE_ORDER == X_BIG_ENDIAN -# define STIPPLE_SWAP 1<<18 /* Mirror stipple pattern horizontally */ -#else -# define STIPPLE_SWAP 0 -#endif +/* Direct Fifo Bitmap Writes */ +static void Permedia3WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int skipleft, + int fg, int bg, int rop,unsigned int planemask); +/* Images Writes */ +static void Permedia3SetupForImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int trans_color, + int bpp, int depth); +static void Permedia3SubsequentImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft); +/* Direct Fifo Pixmap Writes */ +static void Permedia3WritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, + unsigned char *src, int srcwidth, int rop, + unsigned int planemask, int transparency_color, + int bpp, int depth); void Permedia3InitializeEngine(ScrnInfoPtr pScrn) { GLINTPtr pGlint = GLINTPTR(pScrn); + int colorformat = 0; /* Initialize the Accelerator Engine to defaults */ - TRACE_ENTER("Permedia3InitializeEngine"); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); - GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode); - GLINT_SLOW_WRITE_REG(0, dXSub); - GLINT_SLOW_WRITE_REG(GWIN_DisableLBUpdate, GLINTWindow); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureColorMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PMTextureReadMode); - GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TexelLUTMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, YUVMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); + /* Host out PreInit */ + /* Set filter mode to enable sync tag & data output */ GLINT_SLOW_WRITE_REG(0xc00, FilterMode); - GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); - GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBSourceOffset); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, WindowOrigin); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBWindowBase); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceBase); - GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); + Permedia3Sync(pScrn); -#if X_BYTE_ORDER == X_BIG_ENDIAN - pGlint->RasterizerSwap = 1; -#else - pGlint->RasterizerSwap = 0; -#endif + TRACE("Permedia3InitializeEngine : first sync"); + /* Disable most units by default */ + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3DeltaMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LineStippleMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3GIDMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3TextureCoordMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3TextureIndexMode0); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3TextureIndexMode1); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureReadMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3LUTMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureFilterMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3TextureCompositeMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3TextureApplicationMode); + GLINT_SLOW_WRITE_REG(0, PM3TextureCompositeColorMode1); + GLINT_SLOW_WRITE_REG(0, PM3TextureCompositeAlphaMode1); + GLINT_SLOW_WRITE_REG(0, PM3TextureCompositeColorMode0); + GLINT_SLOW_WRITE_REG(0, PM3TextureCompositeAlphaMode0); + + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ChromaTestMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode); + /* Not done in P3Lib ??? */ + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3AlphaTestMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, YUVMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3AlphaBlendColorMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3AlphaBlendAlphaMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode); + + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PM3Window); + + GLINT_SLOW_WRITE_REG(0, PM3Config2D); + + GLINT_SLOW_WRITE_REG(0xffffffff, PM3SpanColorMask); + + GLINT_SLOW_WRITE_REG(0, PM3XBias); + GLINT_SLOW_WRITE_REG(0, PM3YBias); + GLINT_SLOW_WRITE_REG(0, PM3DeltaControl); + + GLINT_SLOW_WRITE_REG(0xffffffff, BitMaskPattern); + Permedia3Sync(pScrn); + + /* ScissorStippleUnit Initialization (is it needed ?) */ + pGlint->ClippingOn = FALSE; + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); + /* We never use Screen Scissor ... + GLINT_SLOW_WRITE_REG( + (pScrn->virtualX&0xffff)|((pScrn->virtualY&0xffff)<<16), + ScreenSize); + GLINT_SLOW_WRITE_REG( + (0&0xffff)|((0&0xffff)<<16), + WindowOrigin); + */ + Permedia3Sync(pScrn); + + /* StencilDepthUnit Initialization */ + GLINT_SLOW_WRITE_REG(0, PM3Window); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode); + GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode); + GLINT_SLOW_WRITE_REG(0, StencilData); + Permedia3Sync(pScrn); + + /* FBReadUnit Initialization */ + TRACE("Permedia3InitializeEngine : only syncs upto now"); + GLINT_SLOW_WRITE_REG( + PM3FBDestReadEnables_E(0xff) | + PM3FBDestReadEnables_R(0xff) | + PM3FBDestReadEnables_ReferenceAlpha(0xff), + PM3FBDestReadEnables); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferAddr0); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferOffset0); + GLINT_SLOW_WRITE_REG( + PM3FBDestReadBufferWidth_Width(pScrn->displayWidth), + PM3FBDestReadBufferWidth0); + /* + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferAddr1); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferOffset1); + GLINT_SLOW_WRITE_REG( + PM3FBDestReadBufferWidth_Width(pScrn->displayWidth), + PM3FBDestReadBufferWidth1); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferAddr2); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferOffset2); + GLINT_SLOW_WRITE_REG( + PM3FBDestReadBufferWidth_Width(pScrn->displayWidth), + PM3FBDestReadBufferWidth2); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferAddr3); + GLINT_SLOW_WRITE_REG(0, PM3FBDestReadBufferOffset3); + GLINT_SLOW_WRITE_REG( + PM3FBDestReadBufferWidth_Width(pScrn->displayWidth), + PM3FBDestReadBufferWidth3); + */ + GLINT_SLOW_WRITE_REG( + PM3FBDestReadMode_ReadEnable | + /* Not needed, since FBDestRead is the same as FBWrite. + PM3FBDestReadMode_Blocking | + */ + PM3FBDestReadMode_Enable0, + PM3FBDestReadMode); + TRACE("Permedia3InitializeEngine : DestRead"); + GLINT_SLOW_WRITE_REG(0, PM3FBSourceReadBufferAddr); + GLINT_SLOW_WRITE_REG(0, PM3FBSourceReadBufferOffset); + GLINT_SLOW_WRITE_REG( + PM3FBSourceReadBufferWidth_Width(pScrn->displayWidth), + PM3FBSourceReadBufferWidth); + GLINT_SLOW_WRITE_REG( + PM3FBSourceReadMode_Blocking | + PM3FBSourceReadMode_ReadEnable, + PM3FBSourceReadMode); + TRACE("Permedia3InitializeEngine : SourceRead"); switch (pScrn->bitsPerPixel) { case 8: - pGlint->PixelWidth = 0x0; /* 8 Bits */ - pGlint->TexMapFormat = pGlint->pprod; + GLINT_SLOW_WRITE_REG(0x2, PixelSize); #if X_BYTE_ORDER == X_BIG_ENDIAN - pGlint->RasterizerSwap |= 3<<15; /* Swap host data */ + pGlint->RasterizerSwap = 3<<15; /* Swap host data */ #endif break; case 16: - pGlint->PixelWidth = 0x1; /* 16 Bits */ - pGlint->TexMapFormat = pGlint->pprod | 1<<19; + GLINT_SLOW_WRITE_REG(0x1, PixelSize); #if X_BYTE_ORDER == X_BIG_ENDIAN - pGlint->RasterizerSwap |= 2<<15; /* Swap host data */ + pGlint->RasterizerSwap = 2<<15; /* Swap host data */ #endif break; - case 24: - pGlint->PixelWidth = 0x4; /* 24 Bits */ - pGlint->TexMapFormat = pGlint->pprod | 2<<19; + case 32: + GLINT_SLOW_WRITE_REG(0x0, PixelSize); + break; + } +#if X_BYTE_ORDER == X_BIG_ENDIAN + GLINT_SLOW_WRITE_REG(1 | pGlint->RasterizerSwap, RasterizerMode); +#endif + TRACE("Permedia3InitializeEngine : PixelSize"); + Permedia3Sync(pScrn); + + /* LogicalOpUnit Initialization */ + GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); + Permedia3Sync(pScrn); + + /* FBWriteUnit Initialization */ + GLINT_SLOW_WRITE_REG( + PM3FBWriteMode_WriteEnable| + PM3FBWriteMode_OpaqueSpan| + PM3FBWriteMode_Enable0, + PM3FBWriteMode); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferAddr0); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferOffset0); + GLINT_SLOW_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth), + PM3FBWriteBufferWidth0); + Permedia3Sync(pScrn); + /* + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferAddr1); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferOffset1); + GLINT_SLOW_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth), + PM3FBWriteBufferWidth1); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferAddr2); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferOffset2); + GLINT_SLOW_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth), + PM3FBWriteBufferWidth2); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferAddr3); + GLINT_SLOW_WRITE_REG(0, PM3FBWriteBufferOffset3); + GLINT_SLOW_WRITE_REG( + PM3FBWriteBufferWidth_Width(pScrn->displayWidth), + PM3FBWriteBufferWidth3); + */ + TRACE("Permedia3InitializeEngine : FBWrite"); + /* SizeOfframebuffer */ + GLINT_SLOW_WRITE_REG( + pScrn->displayWidth * + (8 * pGlint->FbMapSize / (pScrn->bitsPerPixel * pScrn->displayWidth) + >4095?4095: 8 * pGlint->FbMapSize / + (pScrn->bitsPerPixel * pScrn->displayWidth)), + PM3SizeOfFramebuffer); + GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); + Permedia3Sync(pScrn); + TRACE("Permedia3InitializeEngine : FBHardwareWriteMask & SizeOfFramebuffer"); + /* Color Format */ + switch (pScrn->depth) { + case 8: + colorformat = 4; + break; + case 15: + colorformat = 2; + break; + case 16: + colorformat = 3; break; + case 24: case 32: - pGlint->PixelWidth = 0x2; /* 32 Bits */ - pGlint->TexMapFormat = pGlint->pprod | 2<<19; - break; + colorformat = 0; + break; } - pGlint->ClippingOn = FALSE; + GLINT_SLOW_WRITE_REG(UNIT_DISABLE| + ((colorformat&0xf)<<2)|(1<<10), + DitherMode); + + /* Other stuff */ pGlint->startxdom = 0; pGlint->startxsub = 0; pGlint->starty = 0; @@ -239,17 +339,13 @@ pGlint->h = 0; pGlint->w = 0; pGlint->ROP = 0xFF; - GLINT_SLOW_WRITE_REG(pGlint->PixelWidth, FBReadPixel); - GLINT_SLOW_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat); - GLINT_SLOW_WRITE_REG(0, RectangleSize); - GLINT_SLOW_WRITE_REG(0, RectangleOrigin); GLINT_SLOW_WRITE_REG(0, dXDom); + GLINT_SLOW_WRITE_REG(0, dXSub); GLINT_SLOW_WRITE_REG(1<<16, dY); GLINT_SLOW_WRITE_REG(0, StartXDom); GLINT_SLOW_WRITE_REG(0, StartXSub); GLINT_SLOW_WRITE_REG(0, StartY); GLINT_SLOW_WRITE_REG(0, GLINTCount); - TRACE_EXIT("Permedia3InitializeEngine"); } @@ -266,181 +362,127 @@ Permedia3InitializeEngine(pScrn); - infoPtr->Flags = PIXMAP_CACHE | - OFFSCREEN_PIXMAPS | - LINEAR_FRAMEBUFFER; + /* Generic accel engine flags */ + infoPtr->Flags = + PIXMAP_CACHE | + OFFSCREEN_PIXMAPS | + LINEAR_FRAMEBUFFER; + /* Synchronization of the accel engine */ infoPtr->Sync = Permedia3Sync; + /* Clipping Setup */ + infoPtr->ClippingFlags = 0; + /* This does not work correctly, i don't know why, but i guess it is + * because the clipping stuff is not ok ... + * Let's disable it for now (also in the respective functions, we + * clear the UserScissorEnable bit in Render2D. + HARDWARE_CLIP_MONO_8x8_FILL | + HARDWARE_CLIP_SOLID_FILL; + */ infoPtr->SetClippingRectangle = Permedia3SetClippingRectangle; infoPtr->DisableClipping = Permedia3DisableClipping; - infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL; + /* ScreenToScreenCopy */ + infoPtr->ScreenToScreenCopyFlags = + NO_TRANSPARENCY; + infoPtr->SetupForScreenToScreenCopy = + Permedia3SetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = + Permedia3SubsequentScreenToScreenCopy; + + /* SolidFill */ infoPtr->SolidFillFlags = 0; - infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; - infoPtr->WriteBitmapFlags = 0; - if (pScrn->bitsPerPixel == 24) { - /* SVEN : This should be bad also, - * didn't tested it since 24bpp is broken.... - infoPtr->SetupForSolidFill = - Permedia3SetupForFillRectSolid24bpp; - infoPtr->SubsequentSolidFillRect = - Permedia3SubsequentFillRectSolid24bpp; - */ - } else { - infoPtr->SolidLineFlags = 0; - infoPtr->PolySegmentThinSolidFlags = 0; - infoPtr->PolylinesThinSolidFlags = 0; - infoPtr->SetupForSolidLine = Permedia3SetupForSolidLine; - infoPtr->SubsequentSolidHorVertLine = Permedia3SubsequentHorVertLine; - if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)) - { - infoPtr->SubsequentSolidBresenhamLine = - Permedia3SubsequentSolidBresenhamLine; - } - infoPtr->PolySegmentThinSolid = Permedia3PolySegmentThinSolidWrapper; - infoPtr->PolylinesThinSolid = Permedia3PolylinesThinSolidWrapper; - /* SVEN : This evidently seems to be bad ... - infoPtr->SetupForSolidFill = Permedia3SetupForFillRectSolid; - infoPtr->SubsequentSolidFillRect = Permedia3SubsequentFillRectSolid; - */ - } - - if (pScrn->bitsPerPixel >= 24) { - /* SVEN : This should be bad also, - * didn't tested it since 24bpp is broken.... - infoPtr->SetupForScreenToScreenCopy = - Permedia3SetupForScreenToScreenCopy2432bpp; - infoPtr->SubsequentScreenToScreenCopy = - Permedia3SubsequentScreenToScreenCopy2432bpp; - */ - } else { - /* SVEN : This evidently seems to be bad ... - infoPtr->SetupForScreenToScreenCopy = - Permedia3SetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = - Permedia3SubsequentScreenToScreenCopy; - */ - } + infoPtr->SetupForSolidFill = Permedia3SetupForFillRectSolid; + infoPtr->SubsequentSolidFillRect = Permedia3SubsequentFillRectSolid; + /* 8x8 Mono Pattern Fills */ infoPtr->Mono8x8PatternFillFlags = - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_SCREEN_ORIGIN; - - if (pScrn->bitsPerPixel == 24) { - /* SVEN : This should be bad also, - * didn't tested it since 24bpp is broken.... - infoPtr->SetupForMono8x8PatternFill = - Permedia3SetupForMono8x8PatternFill24bpp; - infoPtr->SubsequentMono8x8PatternFillRect = - Permedia3SubsequentMono8x8PatternFillRect24bpp; - */ - } else { - /* SVEN : This evidently seems to be bad ... - infoPtr->SetupForMono8x8PatternFill = - Permedia3SetupForMono8x8PatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = - Permedia3SubsequentMono8x8PatternFillRect; - */ - } - -/* Didn't try, but anyway, pm3 uses PCIRetry, but i don't know if - * it gets declared corectly by glint_driver.c. Need to check this. - if (pGlint->UsePCIRetry) { - infoPtr->CPUToScreenColorExpandFillFlags = SYNC_AFTER_COLOR_EXPAND | - BIT_ORDER_IN_BYTE_LSBFIRST | - CPU_TRANSFER_PAD_DWORD; - - infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4; - infoPtr->SetupForCPUToScreenColorExpandFill = - Permedia3SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Permedia3SubsequentCPUToScreenColorExpandFill; - } else { - infoPtr->ScanlineCPUToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_LSBFIRST; - - infoPtr->NumScanlineColorExpandBuffers = 1; - infoPtr->ScanlineColorExpandBuffers = - pGlint->XAAScanlineColorExpandBuffers; - pGlint->XAAScanlineColorExpandBuffers[0] = - pGlint->IOBase + OutputFIFO + 4; - - infoPtr->SetupForScanlineCPUToScreenColorExpandFill = - Permedia3SetupForScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = - Permedia3SubsequentScanlineCPUToScreenColorExpandFill; - infoPtr->SubsequentColorExpandScanline = - Permedia3SubsequentColorExpandScanline; - } -*/ - - infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; + HARDWARE_PATTERN_PROGRAMMED_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_SCREEN_ORIGIN | + BIT_ORDER_IN_BYTE_LSBFIRST; + infoPtr->SetupForMono8x8PatternFill = + Permedia3SetupForMono8x8PatternFill; + infoPtr->SubsequentMono8x8PatternFillRect = + Permedia3SubsequentMono8x8PatternFillRect; - /* Seems broken also, ... +#if USE_DIRECT_FIFO_WRITES + /* Direct Fifo Bitmap Writes */ + infoPtr->WriteBitmapFlags = 0; infoPtr->WriteBitmap = Permedia3WriteBitmap; - - if (pScrn->bitsPerPixel == 8) - infoPtr->WritePixmap = Permedia3WritePixmap8bpp; - else - if (pScrn->bitsPerPixel == 16) - infoPtr->WritePixmap = Permedia3WritePixmap16bpp; - else -#if 0 - if (pScrn->bitsPerPixel == 24) { - infoPtr->WritePixmap = Permedia3WritePixmap24bpp; - infoPtr->WritePixmapFlags |= NO_PLANEMASK; - } - else #endif - if (pScrn->bitsPerPixel == 32) - infoPtr->WritePixmap = Permedia3WritePixmap32bpp; - */ - /* Now fixup if we are 24bpp */ - if (pScrn->bitsPerPixel == 24) { - infoPtr->SolidFillFlags |= NO_PLANEMASK; - infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK; - infoPtr->WriteBitmapFlags |= NO_PLANEMASK; - infoPtr->CPUToScreenColorExpandFillFlags |= NO_PLANEMASK; - infoPtr->ScanlineCPUToScreenColorExpandFillFlags |= NO_PLANEMASK; - infoPtr->Mono8x8PatternFillFlags |= NO_PLANEMASK; - } + /* Color Expand Fills */ + infoPtr->CPUToScreenColorExpandFillFlags = + /* + SYNC_AFTER_COLOR_EXPAND | + */ + LEFT_EDGE_CLIPPING | + BIT_ORDER_IN_BYTE_LSBFIRST | + CPU_TRANSFER_BASE_FIXED | + CPU_TRANSFER_PAD_DWORD; + infoPtr->ColorExpandBase = pGlint->IOBase + BitMaskPattern; + infoPtr->ColorExpandRange = 4; + infoPtr->SetupForCPUToScreenColorExpandFill = + Permedia3SetupForCPUToScreenColorExpandFill; + infoPtr->SubsequentCPUToScreenColorExpandFill = + Permedia3SubsequentCPUToScreenColorExpandFill; + +#if USE_DIRECT_FIFO_WRITES + /* Direct Fifo Images Writes */ + infoPtr->WritePixmapFlags = 0; + infoPtr->WritePixmap = Permedia3WritePixmap; +#else + /* Images Writes */ + infoPtr->ImageWriteFlags = + NO_GXCOPY | + /* + SYNC_AFTER_IMAGE_WRITE | + */ + LEFT_EDGE_CLIPPING | + LEFT_EDGE_CLIPPING_NEGATIVE_X | + BIT_ORDER_IN_BYTE_LSBFIRST | + CPU_TRANSFER_BASE_FIXED | + CPU_TRANSFER_PAD_DWORD; + infoPtr->ImageWriteBase = pGlint->IOBase + PM3FBSourceData; + infoPtr->ImageWriteRange = 4; + infoPtr->SetupForImageWrite = + Permedia3SetupForImageWrite; + infoPtr->SubsequentImageWriteRect = + Permedia3SubsequentImageWriteRect; +#endif + /* Available Framebuffer Area for XAA. */ AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; AvailFBArea.y2 = pGlint->FbMapSize / (pScrn->displayWidth * pScrn->bitsPerPixel / 8); + /* Alan does this ??? + AvailFBArea.y2 = ((pGlint->FbMapSize > 16384*1024) ? 16384*1024 : + pGlint->FbMapSize) / (pScrn->displayWidth + pScrn->bitsPerPixel / 8); + */ - if (AvailFBArea.y2 > 2047) AvailFBArea.y2 = 2047; + /* Permedia3 has a maximum 4096x4096 framebuffer */ + if (AvailFBArea.y2 > 4095) AvailFBArea.y2 = 4095; xf86InitFBManager(pScreen, &AvailFBArea); + Permedia3Sync(pScrn); return(XAAInit(pScreen, infoPtr)); } -static void Permedia3LoadCoord( - ScrnInfoPtr pScrn, - int x, int y, - int w, int h -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - if ((h != pGlint->h) || (w != pGlint->w)) { - pGlint->w = w; - pGlint->h = h; - GLINT_WRITE_REG(((h&0x0FFF)<<16)|(w&0x0FFF), RectangleSize); - } - if ((y != pGlint->y) || (x != pGlint->x)) { - pGlint->x = x; - pGlint->y = y; - GLINT_WRITE_REG(((y&0x0FFF)<<16)|(x&0x0FFF), RectangleOrigin); - } +#define CHECKCLIPPING \ +{ \ + if (pGlint->ClippingOn) { \ + pGlint->ClippingOn = FALSE; \ + GLINT_WAIT(1); \ + GLINT_WRITE_REG(0, ScissorMode); \ + } \ } - void Permedia3Sync(ScrnInfoPtr pScrn) { @@ -453,8 +495,7 @@ GLINT_WRITE_REG(0, GlintSync); do { while(GLINT_READ_REG(OutFIFOWords) == 0); -#define Sync_tag 0x188 - } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); + } while (GLINT_READ_REG(OutputFIFO) != PM3SyncTag); } static void @@ -467,7 +508,6 @@ GLINT_WRITE_REG(1, ScissorMode); pGlint->ClippingOn = TRUE; } - static void Permedia3DisableClipping(ScrnInfoPtr pScrn) { @@ -475,401 +515,155 @@ CHECKCLIPPING; } +/* ScreenToScreenCopy definition */ static void -Permedia3SetupForScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, int transparency_color) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - pGlint->BltScanDirection = 0; - if (xdir == 1) pGlint->BltScanDirection |= XPositive; - if (ydir == 1) pGlint->BltScanDirection |= YPositive; - - if (pScrn->bitsPerPixel == 24) { - GLINT_WAIT(4); - } else { - GLINT_WAIT(5); - DO_PLANEMASK(planemask); - } - - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if ((rop == GXset) || (rop == GXclear)) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - if ((rop == GXcopy) || (rop == GXcopyInverted)) { - GLINT_WRITE_REG(pGlint->pprod|FBRM_SrcEnable, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod|FBRM_SrcEnable|FBRM_DstEnable, - FBReadMode); - } - } - LOADROP(rop); -} - -static void -Permedia3SubsequentScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn, int x1, - int y1, int x2, int y2, int w, int h) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(4); - Permedia3LoadCoord(pScrn, x2, y2, w, h); - GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | ((x1-x2)&0x0FFF), FBSourceDelta); - GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render); -} - -static void Permedia3SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int transparency_color) { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SetupForScreenToScreenCopy"); - - pGlint->BltScanDirection = 0; - if (xdir == 1) pGlint->BltScanDirection |= XPositive; - if (ydir == 1) pGlint->BltScanDirection |= YPositive; - - GLINT_WAIT(4); + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_Operation_Normal; + pGlint->ClippingOn = TRUE; + pGlint->PM3_Config2D = + PM3Config2D_UserScissorEnable | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if (xdir == 1) pGlint->PM3_Render2D |= PM3Render2D_XPositive; + if (ydir == 1) pGlint->PM3_Render2D |= PM3Render2D_YPositive; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXnoop)&&(rop!=GXinvert)) { + pGlint->PM3_Render2D |= PM3Render2D_FBSourceReadEnable; + pGlint->PM3_Config2D |= PM3Config2D_Blocking; + } + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + GLINT_WAIT(2); DO_PLANEMASK(planemask); - - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if ((rop == GXset) || (rop == GXclear)) { - pGlint->FrameBufferReadMode = pGlint->pprod; - } else - if ((rop == GXcopy) || (rop == GXcopyInverted)) { - pGlint->FrameBufferReadMode = pGlint->pprod |FBRM_SrcEnable; - } else { - pGlint->FrameBufferReadMode = pGlint->pprod | FBRM_SrcEnable | - FBRM_DstEnable; - } - LOADROP(rop); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); TRACE_EXIT("Permedia3SetupForScreenToScreenCopy"); } - static void Permedia3SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h) { GLINTPtr pGlint = GLINTPTR(pScrn); - char align; - + /* Spans needs to be 32 bit aligned. */ + int x_align = x1 & 0x1f; TRACE_ENTER("Permedia3SubsequentScreenToScreenCopy"); - /* We can only use GXcopy for Packed modes */ - if (pGlint->ROP != GXcopy) { - GLINT_WAIT(5); - GLINT_WRITE_REG(pGlint->FrameBufferReadMode, FBReadMode); - Permedia3LoadCoord(pScrn, x2, y2, w, h); - GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | ((x1-x2)&0x0FFF), FBSourceDelta); - } else { - align = (x2 & pGlint->bppalign) - (x1 & pGlint->bppalign); - GLINT_WAIT(6); - GLINT_WRITE_REG(pGlint->FrameBufferReadMode|FBRM_Packed, FBReadMode); - Permedia3LoadCoord(pScrn, x2>>pGlint->BppShift, y2, - (w+7)>>pGlint->BppShift, h); - GLINT_WRITE_REG(align<<29|x2<<16|(x2+w), PackedDataLimits); - GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | (((x1 & ~pGlint->bppalign)-(x2 & ~pGlint->bppalign))&0x0FFF), FBSourceDelta); - } - - GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render); - TRACE_EXIT("Permedia3SubsequentScreenToScreenCopy"); -} - - - -static void -Permedia3PolylinesThinSolidWrapper( - DrawablePtr pDraw, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr pPts -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - GLINTPtr pGlint = GLINTPTR(infoRec->pScrn); - pGlint->CurrentGC = pGC; - pGlint->CurrentDrawable = pDraw; - if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn); - XAAPolyLines(pDraw, pGC, mode, npt, pPts); -} - -static void -Permedia3PolySegmentThinSolidWrapper( - DrawablePtr pDraw, - GCPtr pGC, - int nseg, - xSegment *pSeg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - GLINTPtr pGlint = GLINTPTR(infoRec->pScrn); - pGlint->CurrentGC = pGC; - pGlint->CurrentDrawable = pDraw; - if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn); - XAAPolySegment(pDraw, pGC, nseg, pSeg); -} - -static void -Permedia3SetupForSolidLine(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(6); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_WRITE_REG(color, GLINTColor); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); -} - -static void -Permedia3SubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(6); - GLINT_WRITE_REG(x<<16, StartXDom); - GLINT_WRITE_REG(y<<16, StartY); - if (dir == DEGREES_0) { - GLINT_WRITE_REG(1<<16, dXDom); - GLINT_WRITE_REG(0<<16, dY); - } else { - GLINT_WRITE_REG(0<<16, dXDom); - GLINT_WRITE_REG(1<<16, dY); - } - - GLINT_WRITE_REG(len, GLINTCount); - GLINT_WRITE_REG(PrimitiveLine, Render); -} - -static void -Permedia3SubsequentSolidBresenhamLine( ScrnInfoPtr pScrn, - int x, int y, int dmaj, int dmin, int e, int len, int octant) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - if(dmaj == dmin) { - GLINT_WAIT(6); - if(octant & YDECREASING) { - GLINT_WRITE_REG(-1<<16, dY); - } else { - GLINT_WRITE_REG(1<<16, dY); - } - - if(octant & XDECREASING) { - GLINT_WRITE_REG(-1<<16, dXDom); - } else { - GLINT_WRITE_REG(1<<16, dXDom); - } - - GLINT_WRITE_REG(x<<16, StartXDom); - GLINT_WRITE_REG(y<<16, StartY); - GLINT_WRITE_REG(len,GLINTCount); - GLINT_WRITE_REG(PrimitiveLine, Render); - return; - } - - fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0, - (octant & XDECREASING) ? -1 : 1, - (octant & YDECREASING) ? -1 : 1, - (octant & YMAJOR) ? Y_AXIS : X_AXIS, - x, y, dmin + e, dmin, -dmaj, len); -} - -static void -Permedia3SetupForFillRectSolid24bpp(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - pGlint->ForeGroundColor = color; - GLINT_WAIT(5); - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(color, ConstantColor); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); + GLINT_WRITE_REG(((y2&0x0fff)<<16)|(x2&0x0fff), ScissorMinXY); + GLINT_WRITE_REG((((y2+h)&0x0fff)<<16)|((x2+w)&0x0fff), ScissorMaxXY); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x2-x_align) | + PM3RectanglePosition_YOffset(y2), + PM3RectanglePosition); + GLINT_WRITE_REG( + PM3FBSourceReadBufferOffset_XOffset(x1-x2)| + PM3FBSourceReadBufferOffset_YOffset(y1-y2), + PM3FBSourceReadBufferOffset); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w+x_align)| + PM3Render2D_Height(h), + PM3Render2D); + TRACE_EXIT("Permedia3SubsequentScreenToScreenCopy"); } +/* Solid Fills */ static void Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SetupForFillRectSolid"); - REPLICATE(color); - - GLINT_WAIT(6); + /* Prepapre Common Render2D & Config2D data */ + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_Normal; + pGlint->PM3_Config2D = + PM3Config2D_UseConstantSource | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + /* Clipping is not working ok yet, let's disable it. + if (pGlint->ClippingOn) + pGlint->PM3_Config2D |= PM3Config2D_UserScissorEnable; + */ + GLINT_WAIT(3); + /* Using FBClockColor (have to disable SpanOperation) will fill only the + * first 32 pixels of the 64 pixels of a span. Lets use ForegroundColor + * instead (from the LogicOps unit) + GLINT_WRITE_REG(color, PM3FBBlockColor); + */ + GLINT_WRITE_REG(color, PM3ForegroundColor); DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - GLINT_WRITE_REG(color, FBBlockColor); - } else { - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(color, ConstantColor); - /* We can use Packed mode for filling solid non-GXcopy rasters */ - GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable|FBRM_Packed, FBReadMode); - } - LOADROP(rop); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); TRACE_EXIT("Permedia3SetupForFillRectSolid"); } - -static void -Permedia3SubsequentFillRectSolid24bpp(ScrnInfoPtr pScrn, int x, int y, int w, int h) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - GLINT_WAIT(3); - Permedia3LoadCoord(pScrn, x, y, w, h); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive, Render); -} - static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h) { GLINTPtr pGlint = GLINTPTR(pScrn); - int speed = 0; TRACE_ENTER("Permedia3SubsequentFillRectSolid"); - - if (pGlint->ROP == GXcopy) { - GLINT_WAIT(3); - Permedia3LoadCoord(pScrn, x, y, w, h); - speed = FastFillEnable; - } else { - GLINT_WAIT(4); - Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y, - (w+7)>>pGlint->BppShift, h); - GLINT_WRITE_REG(x<<16|(x+w), PackedDataLimits); - speed = 0; - } - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | speed, Render); + GLINT_WAIT(2); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); TRACE_EXIT("Permedia3SubsequentFillRectSolid"); -} - -static void MoveBYTE( - register CARD32* dest, - register unsigned char* src, - register int dwords -) -{ - while(dwords) { - *dest = *src; - src += 1; - dest += 1; - dwords -= 1; - } -} - -static void MoveWORDS( - register CARD32* dest, - register unsigned short* src, - register int dwords -) -{ - while(dwords & ~0x01) { - *dest = *src; - *(dest + 1) = *(src + 1); - src += 2; - dest += 2; - dwords -= 2; - } - switch(dwords) { - case 0: return; - case 1: *dest = *src; - return; - } -} - -static void MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords ) -{ - while(dwords & ~0x03) { - *dest = *src; - *(dest + 1) = *(src + 1); - *(dest + 2) = *(src + 2); - *(dest + 3) = *(src + 3); - src += 4; - dest += 4; - dwords -= 4; - } - if (!dwords) return; - *dest = *src; - if (dwords == 1) return; - *(dest + 1) = *(src + 1); - if (dwords == 2) return; - *(dest + 2) = *(src + 2); } - - +/* 8x8 Mono Pattern Fills */ static void -Permedia3SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn, - int patternx, int patterny, - int fg, int bg, int rop, - unsigned int planemask) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - if (bg == -1) pGlint->FrameBufferReadMode = -1; - else pGlint->FrameBufferReadMode = 0; - - pGlint->ForeGroundColor = fg; - pGlint->BackGroundColor = bg; - REPLICATE(pGlint->ForeGroundColor); - REPLICATE(pGlint->BackGroundColor); - - GLINT_WAIT(12); - GLINT_WRITE_REG((patternx & 0xFF), AreaStipplePattern0); - GLINT_WRITE_REG((patternx & 0xFF00) >> 8, AreaStipplePattern1); - GLINT_WRITE_REG((patternx & 0xFF0000) >> 16, AreaStipplePattern2); - GLINT_WRITE_REG((patternx & 0xFF000000) >> 24, AreaStipplePattern3); - GLINT_WRITE_REG((patterny & 0xFF), AreaStipplePattern4); - GLINT_WRITE_REG((patterny & 0xFF00) >> 8, AreaStipplePattern5); - GLINT_WRITE_REG((patterny & 0xFF0000) >> 16, AreaStipplePattern6); - GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7); - - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); -} - -static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, - int patternx, int patterny, - int fg, int bg, int rop, - unsigned int planemask) + int patternx, int patterny, + int fg, int bg, int rop, + unsigned int planemask) { GLINTPtr pGlint = GLINTPTR(pScrn); TRACE_ENTER("Permedia3SetupForMono8x8PatternFill"); - - if (bg == -1) pGlint->FrameBufferReadMode = -1; - else pGlint->FrameBufferReadMode = 0; - - pGlint->ForeGroundColor = fg; - pGlint->BackGroundColor = bg; - REPLICATE(pGlint->ForeGroundColor); - REPLICATE(pGlint->BackGroundColor); - -#if DEBUG - ErrorF("patternx: %x patterny: %x\n", patternx, patterny); + REPLICATE(fg); + pGlint->PM3_Render2D = + PM3Render2D_AreaStippleEnable | + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_Normal; + pGlint->PM3_Config2D = + PM3Config2D_UseConstantSource | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + /* Clipping is not working correctly yet ... + if (pGlint->ClippingOn) + pGlint->PM3_Config2D |= PM3Config2D_UserScissorEnable; + */ + pGlint->PM3_AreaStippleMode = 1; +/* Mirror stipple pattern horizontally */ +#if X_BYTE_ORDER == X_BIG_ENDIAN + pGlint->PM3_AreaStippleMode |= (1<<18); #endif - - GLINT_WAIT(13); - DO_PLANEMASK(planemask); + pGlint->PM3_AreaStippleMode |= (2<<1); + pGlint->PM3_AreaStippleMode |= (2<<4); + if (bg != -1) { + REPLICATE(bg); + pGlint->PM3_Config2D |= PM3Config2D_OpaqueSpan; + pGlint->PM3_AreaStippleMode |= 1<<20; + GLINT_WAIT(12); + GLINT_WRITE_REG(bg, BackgroundColor); + } + else GLINT_WAIT(11); GLINT_WRITE_REG((patternx & 0xFF), AreaStipplePattern0); GLINT_WRITE_REG((patternx & 0xFF00) >> 8, AreaStipplePattern1); GLINT_WRITE_REG((patternx & 0xFF0000) >> 16, AreaStipplePattern2); @@ -878,901 +672,272 @@ GLINT_WRITE_REG((patterny & 0xFF00) >> 8, AreaStipplePattern5); GLINT_WRITE_REG((patterny & 0xFF0000) >> 16, AreaStipplePattern6); GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7); - - if (rop == GXcopy) { - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - LOADROP(rop); + GLINT_WRITE_REG(fg, PM3ForegroundColor); + DO_PLANEMASK(planemask); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); TRACE_EXIT("Permedia3SetupForMono8x8PatternFill"); } - -static void -Permedia3SubsequentMono8x8PatternFillRect24bpp(ScrnInfoPtr pScrn, - int patternx, int patterny, - int x, int y, - int w, int h) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - - GLINT_WAIT(8); - Permedia3LoadCoord(pScrn, x, y, w, h); - - if (pGlint->FrameBufferReadMode != -1) { - GLINT_WRITE_REG(pGlint->BackGroundColor, ConstantColor); - GLINT_WRITE_REG(patternx<<7|patterny<<12| ASM_InvertPattern | - STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | XPositive | - YPositive | PrimitiveRectangle, Render); - } - - GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor); - GLINT_WRITE_REG(patternx<<7|patterny<<12|UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | XPositive | YPositive | - PrimitiveRectangle, Render); -} - static void Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, - int patternx, int patterny, - int x, int y, - int w, int h) + int x_offset, int y_offset, + int x, int y, int w, int h) { GLINTPtr pGlint = GLINTPTR(pScrn); - - TRACE_ENTER("Permedia3SubsequentMono8x8PatternFillRect()"); - - GLINT_WAIT(9); - Permedia3LoadCoord(pScrn, x, y, w, h); - - if (pGlint->FrameBufferReadMode != -1) { - if (pGlint->ROP == GXcopy) { - GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor); - GLINT_WRITE_REG(ASM_InvertPattern|patternx<<7|patterny<<12| - STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | FastFillEnable | - XPositive | YPositive | PrimitiveRectangle, Render); - } else { - GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor); - GLINT_WRITE_REG(pGlint->BackGroundColor, Texel0); - GLINT_WRITE_REG(patternx<<7|patterny<<12| - STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | XPositive | TextureEnable | - YPositive | PrimitiveRectangle, Render); - return; - } - } - - if (pGlint->ROP == GXcopy) { - GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor); - pGlint->FrameBufferReadMode = 0; - } - GLINT_WRITE_REG(patternx<<7|patterny<<12|STIPPLE_SWAP|UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | pGlint->FrameBufferReadMode | - XPositive | YPositive | PrimitiveRectangle, Render); - - TRACE_EXIT("Permedia3SubsequentMono8x8PatternFillRect()"); + TRACE_ENTER("Permedia3SubsequentMono8x8PatternFillRect"); + GLINT_WAIT(3); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG( + (x_offset&0x7)<<7 | (y_offset&0x7)<<12 | + pGlint->PM3_AreaStippleMode, + AreaStippleMode); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); + TRACE_EXIT("Permedia3SubsequentMono8x8PatternFillRect"); } -static void -Permedia3SetupForCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ +/* Color Expansion Fills */ +static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop,unsigned int planemask) +{ GLINTPtr pGlint = GLINTPTR(pScrn); - int dobackground = 0; - TRACE_ENTER("Permedia3SetupForCPUToScreenColorExpandFill"); - if (bg != -1) dobackground |= ForceBackgroundColor; - - GLINT_WAIT(7); - DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - pGlint->ForeGroundColor = fg; - pGlint->BackGroundColor = bg; REPLICATE(fg); - REPLICATE(bg); - - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (dobackground) { - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, FBBlockColor); - } - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - pGlint->FrameBufferReadMode = FastFillEnable; - } else { - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground| - pGlint->RasterizerSwap,RasterizerMode); - GLINT_WRITE_REG(fg, ConstantColor); - if (dobackground) { - pGlint->FrameBufferReadMode = TextureEnable; - GLINT_WRITE_REG(bg, Texel0); - } else - pGlint->FrameBufferReadMode = 0; + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_SyncOnBitMask; + pGlint->PM3_Config2D = + PM3Config2D_UserScissorEnable | + PM3Config2D_UseConstantSource | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + if (bg != -1) { + REPLICATE(bg); + pGlint->PM3_Config2D |= PM3Config2D_OpaqueSpan; + GLINT_WAIT(4); + GLINT_WRITE_REG(bg, BackgroundColor); } - LOADROP(rop); + else GLINT_WAIT(3); + GLINT_WRITE_REG(fg, PM3ForegroundColor); + DO_PLANEMASK(planemask); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); TRACE_EXIT("Permedia3SetupForCPUToScreenColorExpandFill"); } - -static void -Permedia3SubsequentCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ +static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft) +{ GLINTPtr pGlint = GLINTPTR(pScrn); - int dwords = ((w + 31) >> 5) * h; - TRACE_ENTER("Permedia3SubsequentCPUToScreenColorExpandFill"); - GLINT_WAIT(8); - Permedia3LoadCoord(pScrn, x, y, w, h); - - if ((pGlint->ROP == GXcopy) && (pGlint->BackGroundColor != -1)) { - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | FastFillEnable, Render); - REPLICATE(pGlint->ForeGroundColor) - GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor); - } - - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | SyncOnBitMask | - pGlint->FrameBufferReadMode, Render); - GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO); - GLINT_WAIT(dwords); + GLINT_WAIT(4); + GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); + GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); TRACE_EXIT("Permedia3SubsequentCPUToScreenColorExpandFill"); } -static void -Permedia3SetupForScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int planemask -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - int dobackground = 0; - TRACE_ENTER("Permedia3SetupForScanlineCPUToScreenColorExpandFill"); - if (bg != -1) dobackground |= ForceBackgroundColor; - pGlint->BackGroundColor = bg; - pGlint->ForeGroundColor = fg; - REPLICATE(fg); - REPLICATE(bg); - GLINT_WAIT(7); +/* Images Writes */ +static void Permedia3SetupForImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, int trans_color, int bpp, int depth) +{ + GLINTPtr pGlint = GLINTPTR(pScrn); + TRACE_ENTER("Permedia3SetupForImageWrite"); + pGlint->PM3_Render2D = + PM3Render2D_SpanOperation | + PM3Render2D_XPositive | + PM3Render2D_YPositive | + PM3Render2D_Operation_SyncOnHostData; + pGlint->PM3_Config2D = + PM3Config2D_UserScissorEnable | + PM3Config2D_ForegroundROPEnable | + PM3Config2D_ForegroundROP(rop) | + PM3Config2D_FBWriteEnable; + if ((rop!=GXclear)&&(rop!=GXset)&&(rop!=GXcopy)&&(rop!=GXcopyInverted)) + pGlint->PM3_Config2D |= PM3Config2D_FBDestReadEnable; + GLINT_WAIT(2); DO_PLANEMASK(planemask); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable, FBReadMode); - } - if ((rop == GXcopy) && (pGlint->BackGroundColor == -1)) { - pGlint->FrameBufferReadMode = FastFillEnable; - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_WRITE_REG(fg, FBBlockColor); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - } else { - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(fg, ConstantColor); - GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground| - pGlint->RasterizerSwap,RasterizerMode); - if (dobackground) { - GLINT_WRITE_REG(bg, Texel0); - pGlint->FrameBufferReadMode = TextureEnable; - } else { - pGlint->FrameBufferReadMode = 0; - } - } - LOADROP(rop); - TRACE_EXIT("Permedia3SetupForScanlineCPUToScreenColorExpandFill"); + GLINT_WRITE_REG(pGlint->PM3_Config2D, PM3Config2D); + TRACE_EXIT("Permedia3SetupForImageWrite"); } - -static void -Permedia3SubsequentScanlineCPUToScreenColorExpandFill( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int skipleft -){ +static void Permedia3SubsequentImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft) +{ GLINTPtr pGlint = GLINTPTR(pScrn); - - TRACE_ENTER("Permedia3SubsequentScanlineCPUToScreenColorExpandFill"); - - pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */ - - pGlint->cpucount = h; - - GLINT_WAIT(6); - Permedia3LoadCoord(pScrn, x, y, w, h); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | pGlint->FrameBufferReadMode | SyncOnBitMask, Render); - GLINT_WRITE_REG(((pGlint->dwords*h)-1)<<16 | 0x0D, OutputFIFO); - GLINT_WAIT(pGlint->dwords); - pGlint->cpucount--; - TRACE_EXIT("Permedia3SubsequentScanlineCPUToScreenColorExpandFill"); + TRACE_ENTER("Permedia3SubsequentImageWrite"); + GLINT_WAIT(4); + GLINT_WRITE_REG(((y&0x0fff)<<16)|((x+skipleft)&0x0fff), ScissorMinXY); + GLINT_WRITE_REG((((y+h)&0x0fff)<<16)|((x+w)&0x0fff), ScissorMaxXY); + GLINT_WRITE_REG( + PM3RectanglePosition_XOffset(x) | + PM3RectanglePosition_YOffset(y), + PM3RectanglePosition); + GLINT_WRITE_REG(pGlint->PM3_Render2D | + PM3Render2D_Width(w) | PM3Render2D_Height(h), + PM3Render2D); + TRACE_EXIT("Permedia3SubsequentImageWrite"); } -static void -Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) -{ - GLINTPtr pGlint = GLINTPTR(pScrn); - if (pGlint->cpucount--) - GLINT_WAIT(pGlint->dwords); -} +/* Defines for Direct Fifo access */ + +#define WriteRange 120 +#define PciRetryWriteRange 1023 +#define WriteBase_Fixed ((CARD32 *)(pGlint->IOBase + PM3FBSourceData)) +#define WriteBase ((CARD32 *)(pGlint->IOBase + OutputFIFO + 4)) +/* Direct Fifo Bitmap Writes */ static void Permedia3WriteBitmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, - int srcwidth, - int skipleft, - int fg, int bg, - int rop, + int srcwidth, int skipleft, + int fg, int bg, int rop, unsigned int planemask ) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int dwords; + int ApertureRange; GLINTPtr pGlint = GLINTPTR(pScrn); - unsigned char *srcpntr; - int dwords, height, mode; - Bool SecondPass = FALSE; - TRACE_ENTER("Permedia3WriteBitmap"); w += skipleft; x -= skipleft; - dwords = (w + 31) >> 5; - - Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - - if (pScrn->bitsPerPixel == 24) { - GLINT_WAIT(10); - } else { - GLINT_WAIT(11); - DO_PLANEMASK(planemask); - } - LOADROP(rop); - Permedia3LoadCoord(pScrn, x&0xFFFF, y, w, h); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - mode = FastFillEnable; - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - } else { - mode = 0; - GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); - GLINT_WRITE_REG(BitMaskPackingEachScanline| - pGlint->RasterizerSwap,RasterizerMode); - } - - if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ - REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, ConstantColor); - } - } else if(rop == GXcopy) { - /* >>>>> set bg <<<<<<< */ - /* >>>>> draw rect (x,y,w,h) */ - REPLICATE(bg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(bg, FBBlockColor); + dwords = (w + 31) >>5; + if (pGlint->UsePCIRetry) ApertureRange = PciRetryWriteRange; + else ApertureRange = WriteRange; + + /* width of the stuff to copy in 32 bit words */ + Permedia3SetupForCPUToScreenColorExpandFill(pScrn, fg, bg, rop, planemask); + Permedia3SubsequentCPUToScreenColorExpandFill(pScrn, x, y, w, h, skipleft); + + if (dwords > ApertureRange) { + while(h--) { + XAAMoveDWORDS_FixedBase(WriteBase_Fixed, (CARD32*)src, dwords); + src += srcwidth; + } + } else { + /* the src is exatcly as wide as the target rectangle. We copy all + * of it, so no need to separate stuff by scanline */ + if(srcwidth == (dwords << 5)) { + /* decrement contains the number of lines that can be + * put in the fifo */ + int decrement = ApertureRange/dwords; + + while(h > decrement) { + GLINT_WAIT(dwords * decrement); + GLINT_WRITE_REG((((dwords * decrement)-1) << 16) | 0xd, + OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * decrement); + src += (srcwidth * decrement); + h -= decrement; + } + if(h) { + GLINT_WAIT(dwords * h); + GLINT_WRITE_REG((((dwords * h)-1) << 16) | 0xd, OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * h); + } } else { - GLINT_WRITE_REG(bg, ConstantColor); - } - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |mode,Render); - /* >>>>>> set fg <<<<<< */ - REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, ConstantColor); - } - } else { - SecondPass = TRUE; - /* >>>>> set fg <<<<<<< */ - REPLICATE(fg); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(fg, FBBlockColor); - } else { - GLINT_WRITE_REG(fg, ConstantColor); - } - } - - /* >>>>>>>>> initiate transfer (x,y,w,h). Skipleft pixels on the - left edge will be clipped <<<<<< */ - -SECOND_PASS: - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | mode | SyncOnBitMask, Render); - - height = h; - srcpntr = src; - while(height--) { - GLINT_WAIT(dwords); - /* 0x0D is the TAG value for BitMaskPattern */ - GLINT_WRITE_REG(((dwords - 1) << 16) | 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32 *)srcpntr, dwords); - srcpntr += srcwidth; - } - - if(SecondPass) { - SecondPass = FALSE; - /* >>>>>> invert bitmask and set bg <<<<<<<< */ - REPLICATE(bg); - GLINT_WAIT(3); - if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { - GLINT_WRITE_REG(InvertBitMask|pGlint->RasterizerSwap,RasterizerMode); - GLINT_WRITE_REG(bg, FBBlockColor); - } else { - GLINT_WRITE_REG(InvertBitMask|BitMaskPackingEachScanline| - pGlint->RasterizerSwap, RasterizerMode); - GLINT_WRITE_REG(bg, ConstantColor); + while(h--) { + GLINT_WAIT(dwords); + GLINT_WRITE_REG(((dwords-1) << 16) | 0xd, OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords); + src += srcwidth; + } } - goto SECOND_PASS; } - - GLINT_WAIT(1); - GLINT_WRITE_REG(pGlint->RasterizerSwap, RasterizerMode); - Permedia3DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); TRACE_EXIT("Permedia3WriteBitmap"); } - +/* Direct Fifo Images Writes */ static void -Permedia3WritePixmap8bpp( +Permedia3WritePixmap( ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned char *src, int srcwidth, int rop, unsigned int planemask, - int transparency_color, + int trans, int bpp, int depth ) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - int skipleft, dwords, count; - CARD32* srcp; - unsigned char *srcpbyte; - Bool FastTexLoad = FALSE; - - GLINT_WAIT(3); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - dwords = (w + 3) >> 2; -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - if((!(x&3)) && (!(w&3))) FastTexLoad = TRUE; -#endif - if((rop != GXcopy) || (planemask != ~0)) - FastTexLoad = FALSE; - - if (rop == GXcopy) { - skipleft = 0; - } else { - if((skipleft = (long)src & 0x03)) { - skipleft /= (bpp>>3); + int dwords; + int skipleft = (long)src & 0x03L; + int Bpp = bpp >> 3; + int ApertureRange; + GLINTPtr pGlint = GLINTPTR(pScrn); + TRACE_ENTER("Permedia3WritePixmap"); + + if (skipleft) { + /* Skipleft is either + * - 0, 1, 2 or 3 in 8 bpp + * - 0 or 1 in 16 bpp + * - 0 in 32 bpp + */ + skipleft /= Bpp; - x -= skipleft; - w += skipleft; + x -= skipleft; + w += skipleft; - src = (unsigned char*)((long)src & ~0x03); - } + src = (unsigned char*)((long)src & ~0x03L); } - - - if(FastTexLoad) { - int address; - - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode); - Permedia3Sync(pScrn); /* we are not using the rasterizer */ - while(h--) { - count = dwords; - address = ((y * pScrn->displayWidth) + x) >> 2; - srcp = (CARD32*)src; - GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | - 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, - OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - y++; - } - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode); + Permedia3SetupForImageWrite(pScrn, rop, planemask, trans, bpp, depth); + Permedia3SubsequentImageWriteRect(pScrn, x, y, w, h, skipleft); + + /* width of the stuff to copy in 32 bit words */ + dwords = ((w * Bpp) + 3) >> 2; + if (pGlint->UsePCIRetry) ApertureRange = PciRetryWriteRange; + else ApertureRange = WriteRange; + + if (dwords > ApertureRange) { + while(h--) { + XAAMoveDWORDS_FixedBase(WriteBase_Fixed, (CARD32*)src, dwords); + src += srcwidth; + } + } else { + /* the src is exatcly as wide as the target rectangle. We copy all + * of it, so no need to separate stuff by scanline */ + if(srcwidth == (dwords << 2)) { + /* decrement contains the number of lines that can be + * put in the fifo */ + int decrement = ApertureRange/dwords; + + while(h > decrement) { + GLINT_WAIT(dwords * decrement); + GLINT_WRITE_REG((((dwords * decrement)-1) << 16) | 0x155, + OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * decrement); + src += (srcwidth * decrement); + h -= decrement; + } + if(h) { + GLINT_WAIT(dwords * h); + GLINT_WRITE_REG((((dwords * h)-1) << 16) | 0x155, OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords * h); + } } else { - char align = (x & pGlint->bppalign); - - - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (rop == GXcopy) { - GLINT_WAIT(6); - Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y, - (w+pGlint->bppalign)>>pGlint->BppShift, h); - GLINT_WRITE_REG(align<<29|x<<16|(x+w), PackedDataLimits); - } else { - Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - GLINT_WAIT(5); - Permedia3LoadCoord(pScrn, x, y, w, h); - } - LOADROP(rop); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | - SyncOnHostData, Render); - - if (rop == GXcopy) { while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - } - } else { - while(h--) { - count = w; - srcpbyte = (unsigned char *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpbyte += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, count); - } - src += srcwidth; - } - } + GLINT_WAIT(dwords); + GLINT_WRITE_REG(((dwords-1) << 16) | 0x155, OutputFIFO); + XAAMoveDWORDS(WriteBase, (CARD32*)src, dwords); + src += srcwidth; + } } - - Permedia3DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); -} - -static void -Permedia3WritePixmap16bpp( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int rop, - unsigned int planemask, - int transparency_color, - int bpp, int depth -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - int skipleft, dwords, count; - CARD32* srcp; - unsigned short* srcpword; - Bool FastTexLoad; - - TRACE_ENTER("Permedia3WritePixmap16bpp"); - GLINT_WAIT(3); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); } - - FastTexLoad = FALSE; - dwords = (w + 1) >> 1; -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - if((!(x&1)) && (!(w&1))) FastTexLoad = TRUE; -#endif - if((rop != GXcopy) || (planemask != ~0)) - FastTexLoad = FALSE; - - if (rop == GXcopy) { - skipleft = 0; - } else { - if((skipleft = (long)src & 0x03L)) { - skipleft /= (bpp>>3); - - x -= skipleft; - w += skipleft; - - src = (unsigned char*)((long)src & ~0x03L); - } - } - - if(FastTexLoad) { - int address; - - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode); - Permedia3Sync(pScrn); /* we are not using the rasterizer */ - while(h--) { - count = dwords; - address = ((y * pScrn->displayWidth) + x) >> 1; - srcp = (CARD32*)src; - GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | - 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, - OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - y++; - } - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode); - } else { - char align = (x & pGlint->bppalign); - - - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (rop == GXcopy) { - GLINT_WAIT(6); - Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y, - (w+pGlint->bppalign)>>pGlint->BppShift, h); - GLINT_WRITE_REG(align<<29|x<<16|(x+w), PackedDataLimits); - } else { - Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - GLINT_WAIT(5); - Permedia3LoadCoord(pScrn, x, y, w, h); - } - LOADROP(rop); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | - SyncOnHostData, Render); - - if (rop == GXcopy) { - while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - } - } else { - while(h--) { - count = w; - srcpword = (unsigned short *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned short *)srcpword, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpword += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned short *)srcpword, count); - } - src += srcwidth; - } - } - } - - Permedia3DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); - TRACE_EXIT("Permedia3WritePixmap16bpp"); -} - -#if 0 -static void -Permedia3WritePixmap24bpp( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int rop, - unsigned int planemask, - int transparency_color, - int bpp, int depth -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - int skipleft = 0, dwords, count; - unsigned char* srcpbyte; - CARD32* srcp; - - GLINT_WAIT(3); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - dwords = ((w+1)*3)>>2; - if((skipleft = (long)src & 0x03L)) { - skipleft = 4 - skipleft; - - x -= skipleft; - w += skipleft; - - src = (unsigned char*)(src - (3*skipleft)); - } - - { - Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - - GLINT_WAIT(4); - Permedia3LoadCoord(pScrn, x&0xFFFF, y, w, h); - LOADROP(rop); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | - SyncOnHostData, Render); - -#if 1 - while(h--) { - count = w; - srcpbyte = (unsigned char *)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcpbyte += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (unsigned char *)srcpbyte, count); - } - src += srcwidth; -#else - while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; -#endif - } - } - - Permedia3DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); -} -#endif - - -static void -Permedia3WritePixmap32bpp( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int rop, - unsigned int planemask, - int transparency_color, - int bpp, int depth -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GLINTPtr pGlint = GLINTPTR(pScrn); - int skipleft, dwords, count; - CARD32* srcp; - Bool FastTexLoad; - - GLINT_WAIT(3); - DO_PLANEMASK(planemask); - GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode); - if (rop == GXcopy) { - GLINT_WRITE_REG(pGlint->pprod, FBReadMode); - } else { - GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode); - } - - FastTexLoad = TRUE; - dwords = w; - if((rop != GXcopy) || (planemask != ~0)) - FastTexLoad = FALSE; - - if (!FastTexLoad) { - if((skipleft = (long)src & 0x03L)) { - skipleft /= (bpp>>3); - - x -= skipleft; - w += skipleft; - - src = (unsigned char*)((long)src & ~0x03L); - } - } - - if(FastTexLoad) { - int address; - - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode); - Permedia3Sync(pScrn); /* we are not using the rasterizer */ - while(h--) { - count = dwords; - address = (y * pScrn->displayWidth) + x; - srcp = (CARD32*)src; - GLINT_WRITE_REG(address, TextureDownloadOffset); - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) | - 0x0D, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - address += MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x11 << 4) | 0x0D is the TAG for TextureData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D, - OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - y++; - } - GLINT_WAIT(1); - GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode); - } else { - Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h); - - GLINT_WAIT(6); - Permedia3LoadCoord(pScrn, x, y, w, h); - GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); - LOADROP(rop); - GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | - SyncOnHostData, Render); - - while(h--) { - count = dwords; - srcp = (CARD32*)src; - while(count >= MAX_FIFO_ENTRIES) { - GLINT_WAIT(MAX_FIFO_ENTRIES); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, MAX_FIFO_ENTRIES - 1); - count -= MAX_FIFO_ENTRIES - 1; - srcp += MAX_FIFO_ENTRIES - 1; - } - if(count) { - GLINT_WAIT(count + 1); - /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */ - GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) | - 0x05, OutputFIFO); - MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), - (CARD32*)srcp, count); - } - src += srcwidth; - } - } - - Permedia3DisableClipping(pScrn); - SET_SYNC_FLAG(infoRec); + TRACE_EXIT("Permedia3WritePixmap"); } Index: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c:1.3 Mon Jun 12 06:11:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c Thu Oct 26 09:41:32 2000 @@ -1,33 +1,31 @@ /* - * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk> + * Copyright 2000 by Sven Luther <luther@dpt-info.u-strasbg.fr>. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in + * documentation, and that the name of Sven Luther not be used in * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations + * specific, written prior permission. Sven Luther makes no representations * about the suitability of this software for any purpose. It is provided * "as is" without express or implied warranty. * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * SVEN LUTHER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * EVENT SHALL SVEN LUTHER BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * - * Authors: Sven Luther, <luther@dpt-info.u-strasbg.fr> + * Authors: Sven Luther, <luther@dpt-info.u-strasbg.fr> + * Thomas Witzel, <twitzel@nmr.mgh.harvard.edu> * - * - * - * * this work is sponsored by Appian Graphics. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.3 2000/06/12 10:11:38 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.8 2000/10/26 13:41:32 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -37,6 +35,7 @@ #include "xf86Pci.h" #include "glint_regs.h" +#include "pm3_regs.h" #include "glint.h" #define DEBUG 0 @@ -51,45 +50,17 @@ # define TRACE(str) #endif -void -Permedia3PreInit(ScrnInfoPtr pScrn, GLINTPtr pGlint) -{ - TRACE_ENTER("Permedia3PreInit"); - if ((pGlint->PciInfo->subsysVendor == 0x1097) && - (pGlint->PciInfo->subsysCard == 0x3d32)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Appian Jeronimo 2000 board detected and initialized.\n\t" - "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n", - pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); - /* Memory timings for the Appian J2000 board. - * This is needed for the second head which is left unitilialized - * by the bios, thus freezing the machine. - */ - GLINT_SLOW_WRITE_REG(0xffffffff, PM3MemBypassWriteMask); - GLINT_SLOW_WRITE_REG(0x02e311B8, PM3LocalMemCaps); - GLINT_SLOW_WRITE_REG(0x07424905, PM3LocalMemTimings); - GLINT_SLOW_WRITE_REG(0x0c000003, PM3LocalMemControl); - GLINT_SLOW_WRITE_REG(0x00000069, PM3LocalMemRefresh); - } - else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unknown Glint Permedia3 board detected.\n\t" - "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n", - pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); - } - TRACE_EXIT("Permedia3PreInit"); -} +int PM3QuickFillMemory(ScrnInfoPtr pScrn,int size); int PM3QuickFillMemory(ScrnInfoPtr pScrn,int size) { - GLINTPtr pGlint; + GLINTPtr pGlint = GLINTPTR (pScrn); unsigned int * p; unsigned int p_content; unsigned int i, j; long savemapsize; - pGlint = GLINTPTR (pScrn); savemapsize = pGlint->FbMapSize; pGlint->FbMapSize = size*1024*1024; @@ -135,7 +106,10 @@ if(size == 64) break; } /* Correct memory amount since fail */ - size = size / 2; + if (size != 1) + size = size / 2; + else + return 1*1024; /* Just to make sure */ if (PM3QuickFillMemory(pScrn,size)) return size*1024; @@ -194,13 +168,10 @@ for (f=1;f<256;f++) { for (pre=1;pre<256;pre++) { for (post=0;post<5;post++) { - /* P3Lib multiplies it by two here lets try it alsos - * Didn't work at all, don't know why, ... - */ - freq = ((2*refclock * f) / (pre * (1 << post))); + freq = ((2* refclock * f) / (pre * (1 << post))); if ((reqclock > freq - freqerr)&&(reqclock < freq + freqerr)){ freqerr = (reqclock > freq) ? - reqclock - freq : freq - reqclock; + reqclock - freq : freq - reqclock; *feedback = f; *prescale = pre; *postscale = post; @@ -209,9 +180,65 @@ } } } + return(actualclock); } +void +Permedia3PreInit(ScrnInfoPtr pScrn) +{ + GLINTPtr pGlint = GLINTPTR(pScrn); + TRACE_ENTER("Permedia3PreInit"); + if ((pGlint->PciInfo->subsysVendor == 0x1097) && + (pGlint->PciInfo->subsysCard == 0x3d32)) { + unsigned char m,n,p; + unsigned long clockused; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Appian Jeronimo 2000 board detected and initialized.\n\t" + "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n", + pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); + + /* Memory timings for the Appian J2000 board. + * This is needed for the second head which is left unitilialized + * by the bios, thus freezing the machine. */ + GLINT_SLOW_WRITE_REG(0x02e311B8, PM3LocalMemCaps); + GLINT_SLOW_WRITE_REG(0x07424905, PM3LocalMemTimings); + GLINT_SLOW_WRITE_REG(0x0c000003, PM3LocalMemControl); + GLINT_SLOW_WRITE_REG(0x00000061, PM3LocalMemRefresh); + GLINT_SLOW_WRITE_REG(0x00000000, PM3LocalMemPowerDown); + + /* Let's program the K, M and S Clocks to the same values as the bios + * does for first head : + * - KClk and MClk are 105Mhz. + * - S Clock is set to PClk. + * Note 1 : pGlint->RefClock is not set yet, so use 14318 instead. + * Note 2 : KClk gets internally halved, so we need to double it. + */ + clockused = PM3DAC_CalculateClock(2*105000, 14318, &m,&n,&p); + Permedia2vOutIndReg(pScrn, PM3RD_KClkPreScale, 0x00, m); + Permedia2vOutIndReg(pScrn, PM3RD_KClkFeedbackScale, 0x00, n); + Permedia2vOutIndReg(pScrn, PM3RD_KClkPostScale, 0x00, p); + Permedia2vOutIndReg(pScrn, PM3RD_KClkControl, 0x00, + PM3RD_KClkControl_STATE_RUN | + PM3RD_KClkControl_SOURCE_PLL | + PM3RD_KClkControl_ENABLE); + Permedia2vOutIndReg(pScrn, PM3RD_MClkControl, 0x00, + PM3RD_MClkControl_STATE_RUN | + PM3RD_MClkControl_SOURCE_KCLK | + PM3RD_MClkControl_ENABLE); + Permedia2vOutIndReg(pScrn, PM3RD_SClkControl, 0x00, + PM3RD_SClkControl_STATE_RUN | + PM3RD_SClkControl_SOURCE_PCLK | + PM3RD_SClkControl_ENABLE); + } + else xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Unknown Glint Permedia3 board detected.\n\t" + "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n\t" + "Let's hope that it is correctly initialized by the bios.\n", + pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard); + TRACE_EXIT("Permedia3PreInit"); +} + Bool Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode) { @@ -219,21 +246,9 @@ GLINTRegPtr pReg = &pGlint->ModeReg; CARD32 temp1, temp2, temp3, temp4; - /* Memory timings for the Appian J2000 board - * This is not ideal, since the work here is duplicated - * in the Permedia3PreInit function :((( - */ - if ((pGlint->PciInfo->subsysVendor == 0x1097) && - (pGlint->PciInfo->subsysCard == 0x3d32)) { - pReg->glintRegs[PM3MemBypassWriteMask >> 3] = 0xffffffff; - pReg->glintRegs[PM3LocalMemCaps >> 3] = 0x02e311B8; - pReg->glintRegs[PM3LocalMemTimings >> 3] = 0x07424905; - pReg->glintRegs[PM3LocalMemControl >> 3] = 0x0c000003; - pReg->glintRegs[PM3LocalMemRefresh >> 3] = 0x00000069; - pReg->glintRegs[PM3LocalMemPowerDown >> 3] = 0x00000000; - pReg->glintRegs[PM3ByAperture1Mode >> 3] = 0x00000000; - pReg->glintRegs[PM3ByAperture2Mode >> 3] = 0x00000000; - } + pReg->glintRegs[PM3MemBypassWriteMask >> 3] = 0xffffffff; + pReg->glintRegs[PM3ByAperture1Mode >> 3] = 0x00000000; + pReg->glintRegs[PM3ByAperture2Mode >> 3] = 0x00000000; pReg->glintRegs[Aperture0 >> 3] = 0; pReg->glintRegs[Aperture1 >> 3] = 0; @@ -271,10 +286,36 @@ pReg->glintRegs[PMVsEnd >> 3] -= 1; /* The hw cursor needs /VSYNC to recognize vert retrace. We'll stick - both sync lines to active high (???) here and if needed invert them + both sync lines to active high here and if needed invert them using the RAMDAC's RDSyncControl below. */ - pReg->glintRegs[PMVideoControl >> 3] = - (1 << 5) | (1 << 3) | 1; + /* We need to set the pixelsize (bit 19 & 20) also ... */ + switch (pScrn->bitsPerPixel) + { + case 8: + pReg->glintRegs[PM3ByAperture1Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_8BIT; + pReg->glintRegs[PM3ByAperture2Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_8BIT; + pReg->glintRegs[PMVideoControl >> 3] = + 1 | (1 << 3) | (1 << 5) | (0 << 19); + break; + case 16: + pReg->glintRegs[PM3ByAperture1Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_16BIT; + pReg->glintRegs[PM3ByAperture2Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_16BIT; + pReg->glintRegs[PMVideoControl >> 3] = + 1 | (1 << 3) | (1 << 5) | (1 << 19); + break; + case 32: + pReg->glintRegs[PM3ByAperture1Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_32BIT; + pReg->glintRegs[PM3ByAperture2Mode >> 3] = + PM3ByApertureMode_PIXELSIZE_32BIT; + pReg->glintRegs[PMVideoControl >> 3] = + 1 | (1 << 3) | (1 << 5) | (2 << 19); + break; + } pReg->glintRegs[VClkCtl >> 3] = (GLINT_READ_REG(VClkCtl) & 0xFFFFFFFC); pReg->glintRegs[PMScreenBase >> 3] = 0; @@ -287,11 +328,12 @@ unsigned char m,n,p; unsigned long clockused; - clockused = PM3DAC_CalculateClock(mode->Clock,pGlint->RefClock, - &m,&n,&p); - pReg->DacRegs[PM2VDACRDDClk0PreScale] = m; - pReg->DacRegs[PM2VDACRDDClk0FeedbackScale] = n; - pReg->DacRegs[PM2VDACRDDClk0PostScale] = p; + /* Let's program the dot clock */ + clockused = PM3DAC_CalculateClock(mode->Clock, + pGlint->RefClock, &m,&n,&p); + pReg->DacRegs[PM3RD_DClk0PreScale] = m; + pReg->DacRegs[PM3RD_DClk0FeedbackScale] = n; + pReg->DacRegs[PM3RD_DClk0PostScale] = p; } pReg->DacRegs[PM2VDACRDIndexControl] = 0x00; @@ -305,8 +347,15 @@ if (!(mode->Flags & V_PHSYNC)) pReg->DacRegs[PM2VDACRDSyncControl] |= 0x01; /* invert hsync */ if (!(mode->Flags & V_PVSYNC)) - pReg->DacRegs[PM2VDACRDSyncControl] |= 0x04; /* invert vsync */ + pReg->DacRegs[PM2VDACRDSyncControl] |= 0x08; /* invert vsync */ +#if 0 /* Currently commented out while testing Flat Panel support */ + pReg->DacRegs[PM2VDACRDDACControl] = 0x01; + pReg->DacRegs[PM2VDACRDSyncControl] |= 0x40; + pReg->glintRegs[VSConfiguration >> 3] = (GLINT_READ_REG(VSConfiguration) & 0xFFFFFFF8) | 0x06; + pReg->glintRegs[VSBBase >> 3] = 1<<14; +#endif + switch (pScrn->bitsPerPixel) { case 8: @@ -314,7 +363,6 @@ pReg->DacRegs[PM2VDACRDColorFormat] = 0x2E; break; case 16: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x01; if (pScrn->depth == 15) pReg->DacRegs[PM2VDACRDColorFormat] = 0x61; @@ -322,17 +370,15 @@ pReg->DacRegs[PM2VDACRDColorFormat] = 0x70; break; case 24: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x04; pReg->DacRegs[PM2VDACRDColorFormat] = 0x60; break; case 32: - pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08; pReg->DacRegs[PM2VDACRDPixelSize] = 0x02; pReg->DacRegs[PM2VDACRDColorFormat] = 0x20; if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) { pReg->DacRegs[PM2VDACRDMiscControl] |= 0x10; - pReg->DacRegs[PM2VDACRDOverlayKey] = 0xFF; + pReg->DacRegs[PM2VDACRDOverlayKey] = pScrn->colorKey; } break; } @@ -349,16 +395,6 @@ /* Permedia 3 memory Timings */ glintReg->glintRegs[PM3MemBypassWriteMask >> 3] = GLINT_READ_REG(PM3MemBypassWriteMask); - glintReg->glintRegs[PM3LocalMemCaps >> 3] = - GLINT_READ_REG(PM3LocalMemCaps); - glintReg->glintRegs[PM3LocalMemTimings >> 3] = - GLINT_READ_REG(PM3LocalMemTimings); - glintReg->glintRegs[PM3LocalMemControl >> 3] = - GLINT_READ_REG(PM3LocalMemControl); - glintReg->glintRegs[PM3LocalMemRefresh >> 3] = - GLINT_READ_REG(PM3LocalMemRefresh); - glintReg->glintRegs[PM3LocalMemPowerDown >> 3] = - GLINT_READ_REG(PM3LocalMemPowerDown); glintReg->glintRegs[PM3ByAperture1Mode >> 3] = GLINT_READ_REG(PM3ByAperture1Mode); glintReg->glintRegs[PM3ByAperture2Mode >> 3] = @@ -383,6 +419,10 @@ glintReg->glintRegs[PMScreenBase >> 3] = GLINT_READ_REG(PMScreenBase); glintReg->glintRegs[PMVideoControl >> 3] = GLINT_READ_REG(PMVideoControl); glintReg->glintRegs[VClkCtl >> 3] = GLINT_READ_REG(VClkCtl); +#if 0 /* Currently commented out while testing Flat Panel support */ + glintReg->glintRegs[VSConfiguration >> 3] = GLINT_READ_REG(VSConfiguration); + glintReg->glintRegs[VSBBase >> 3] = GLINT_READ_REG(VSBBase); +#endif for (i=0;i<768;i++) { Permedia2ReadAddress(pScrn, i); @@ -426,16 +466,6 @@ /* Permedia 3 memory Timings */ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3MemBypassWriteMask >> 3], PM3MemBypassWriteMask); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemCaps >> 3], - PM3LocalMemCaps); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemTimings >> 3], - PM3LocalMemTimings); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemControl >> 3], - PM3LocalMemControl); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemRefresh >> 3], - PM3LocalMemRefresh); - GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemPowerDown >> 3], - PM3LocalMemPowerDown); GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture1Mode >> 3], PM3ByAperture1Mode); GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture2Mode >> 3], @@ -461,6 +491,10 @@ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVbEnd >> 3], PMVbEnd); GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsStart >> 3], PMVsStart); GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsEnd >> 3], PMVsEnd); +#if 0 /* Currently commented out while testing Flat Panel support */ + GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VSConfiguration >> 3], VSConfiguration); + GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VSBBase >> 3], VSBBase); +#endif Permedia2vOutIndReg(pScrn, PM2VDACRDIndexControl, 0x00, glintReg->DacRegs[PM2VDACRDIndexControl]); @@ -484,113 +518,10 @@ temp = Permedia2vInIndReg(pScrn, PM2VDACIndexClockControl) & 0xFC; Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PreScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0PreScale]); + glintReg->DacRegs[PM2VDACRDDClk0PreScale]); Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0FeedbackScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale]); + glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale]); Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PostScale, 0x00, - glintReg->DacRegs[PM2VDACRDDClk0PostScale]); + glintReg->DacRegs[PM2VDACRDDClk0PostScale]); Permedia2vOutIndReg(pScrn, PM2VDACIndexClockControl, 0x00, temp|0x03); -} - -static void -Permedia3ShowCursor(ScrnInfoPtr pScrn) -{ - /* Enable cursor - X11 mode */ - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorMode, 0x00, 0x11); -} - -static void -Permedia3HideCursor(ScrnInfoPtr pScrn) -{ - /* Disable cursor - X11 mode */ - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorMode, 0x00, 0x10); -} - -static void -Permedia3LoadCursorImage( - ScrnInfoPtr pScrn, - unsigned char *src -) -{ - int i; - - for (i=0; i<1024; i++) - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPattern+i, 0x00, *(src++)); -} - -static void -Permedia3SetCursorPosition( - ScrnInfoPtr pScrn, - int x, int y -) -{ - x += 64; - y += 64; - - /* Output position - "only" 11 bits of location documented */ - - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorHotSpotX, 0x00, 0x3f); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorHotSpotY, 0x00, 0x3f); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorXLow, 0x00, x & 0xFF); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorXHigh, 0x00, (x>>8) & 0x0F); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYLow, 0x00, y & 0xFF); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYHigh, 0x00, (y>>8) & 0x0F); - Permedia2vOutIndReg(pScrn, PM2DACCursorControl, 0x00, 0x00); -} - - -static void -Permedia3SetCursorColor( - ScrnInfoPtr pScrn, - int index, - int color -) -{ - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+0, - 0x00, 0xff & (color >>16)); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+1, - 0x00, 0xff & (color >>8)); - Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+2, - 0x00, 0xff & color); -} - -static void -Permedia3SetCursorColors( - ScrnInfoPtr pScrn, - int bg, int fg -) -{ - Permedia3SetCursorColor (pScrn, 0, bg); - Permedia3SetCursorColor (pScrn, 1, fg); -} - -static Bool -Permedia3UseHWCursor(ScreenPtr pScr, CursorPtr pCurs) -{ - return TRUE; -} - -Bool -Permedia3HWCursorInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - GLINTPtr pGlint = GLINTPTR(pScrn); - xf86CursorInfoPtr infoPtr; - - infoPtr = xf86CreateCursorInfoRec(); - if(!infoPtr) return FALSE; - - pGlint->CursorInfoRec = infoPtr; - - infoPtr->MaxWidth = 64; - infoPtr->MaxHeight = 64; - infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; - infoPtr->SetCursorColors = Permedia3SetCursorColors; - infoPtr->SetCursorPosition = Permedia3SetCursorPosition; - infoPtr->LoadCursorImage = Permedia3LoadCursorImage; - infoPtr->HideCursor = Permedia3HideCursor; - infoPtr->ShowCursor = Permedia3ShowCursor; - infoPtr->UseHWCursor = Permedia3UseHWCursor; - - return(xf86InitCursor(pScreen, infoPtr)); } Index: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h:1.3 --- /dev/null Mon Dec 18 14:30:40 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h Tue Oct 17 05:07:05 2000 @@ -0,0 +1,1030 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_regs.h,v 1.3 2000/10/17 09:07:05 alanh Exp $ */ + +/* + * glint register file + * + * Copyright by Sven Luther + * Authors: Sven Luther, <luther@dpt-info.u-strasbg.fr> + * Thomas Witzel, <twitzel@nmr.mgh.harvard.edu> + * + * this work is sponsored by Appian Graphics. + * + */ + +#ifndef _PM3_REG_H_ +#define _PM3_REG_H_ + +/********************************************** +* GLINT Permedia3 Control Status registers * +***********************************************/ +/* Control Status Registers */ +#define PM3ResetStatus 0x0000 +#define PM3IntEnable 0x0008 +#define PM3IntFlags 0x0010 +#define PM3InFIFOSpace 0x0018 +#define PM3OutFIFOWords 0x0020 +#define PM3DMAAddress 0x0028 +#define PM3DMACount 0x0030 +#define PM3ErrorFlags 0x0038 +#define PM3VClkCtl 0x0040 +#define PM3TestRegister 0x0048 +#define PM3Aperture0 0x0050 +#define PM3Aperture1 0x0058 +#define PM3DMAControl 0x0060 +#define PM3FIFODis 0x0068 +#define PM3ChipConfig 0x0070 +#define PM3AGPControl 0x0078 + +#define PM3GPOutDMAAddress 0x0080 +#define PM3PCIFeedbackCount 0x0088 +#define PM3PCIAbortStatus 0x0090 +#define PM3PCIAbortAddress 0x0098 + +#define PM3PCIPLLStatus 0x00f0 + +#define PM3HostTextureAddress 0x0100 +#define PM3TextureDownloadControl 0x0108 +#define PM3TextureOperation 0x0110 +#define PM3LogicalTexturePage 0x0118 +#define PM3TexDMAAddress 0x0120 +#define PM3TexFIFOSpace 0x0128 + +/********************************************** +* GLINT Permedia3 Region 0 Bypass Controls * +***********************************************/ +#define PM3ByAperture1Mode 0x0300 + #define PM3ByApertureMode_BYTESWAP_ABCD (0<<0) + #define PM3ByApertureMode_BYTESWAP_BADC (1<<0) + #define PM3ByApertureMode_BYTESWAP_CDAB (2<<0) + #define PM3ByApertureMode_BYTESWAP_DCBA (3<<0) + #define PM3ByApertureMode_PATCH_DISABLE (0<<2) + #define PM3ByApertureMode_PATCH_ENABLE (1<<2) + #define PM3ByApertureMode_FORMAT_RAW (0<<3) + #define PM3ByApertureMode_FORMAT_YUYV (1<<3) + #define PM3ByApertureMode_FORMAT_UYVY (2<<3) + #define PM3ByApertureMode_PIXELSIZE_8BIT (0<<5) + #define PM3ByApertureMode_PIXELSIZE_16BIT (1<<5) + #define PM3ByApertureMode_PIXELSIZE_32BIT (2<<5) + #define PM3ByApertureMode_EFFECTIVE_STRIDE_1024 (0<<7) + #define PM3ByApertureMode_EFFECTIVE_STRIDE_2048 (1<<7) + #define PM3ByApertureMode_EFFECTIVE_STRIDE_4096 (2<<7) + #define PM3ByApertureMode_EFFECTIVE_STRIDE_8192 (3<<7) + #define PM3ByApertureMode_PATCH_OFFSET_X(off) (((off)&7f)<<9) + #define PM3ByApertureMode_PATCH_OFFSET_Y(off) (((off)&7f)<<16) + #define PM3ByApertureMode_FRAMEBUFFER (0<<21) + #define PM3ByApertureMode_LOCALBUFFER (1<<21) + #define PM3ByApertureMode_DOUBLE_WRITE_OFF (0<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_1MB (1<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_2MB (2<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_4MB (3<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_8MB (4<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_16MB (5<<22) + #define PM3ByApertureMode_DOUBLE_WRITE_32MB (6<<22) + +#define PM3ByAperture2Mode 0x0328 + +/********************************************** +* GLINT Permedia3 Memory Control (0x1000) * +***********************************************/ +#define PM3MemCounter 0x1000 +#define PM3MemBypassWriteMask 0x1008 +#define PM3MemScratch 0x1010 +#define PM3LocalMemCaps 0x1018 +#define PM3LocalMemTimings 0x1020 +#define PM3LocalMemControl 0x1028 +#define PM3LocalMemRefresh 0x1030 +#define PM3LocalMemPowerDown 0x1038 +#define PM3RemoteMemControl 0x1100 + +/********************************************** +* GLINT Permedia3 Video Control (0x3000) * +***********************************************/ + +#define PM3ScreenBase 0x3000 +#define PM3ScreenStride 0x3008 +#define PM3HTotal 0x3010 +#define PM3HgEnd 0x3018 +#define PM3HbEnd 0x3020 +#define PM3HsStart 0x3028 +#define PM3HsEnd 0x3030 +#define PM3VTotal 0x3038 +#define PM3VbEnd 0x3040 +#define PM3VsStart 0x3048 +#define PM3VsEnd 0x3050 +#define PM3VideoControl 0x3058 + #define PM3VideoControl_DISABLE (0<<0) + #define PM3VideoControl_ENABLE (1<<0) + #define PM3VideoControl_BLANK_ACTIVE_HIGH (0<<1) + #define PM3VideoControl_BLANK_ACTIVE_LOW (1<<1) + #define PM3VideoControl_LINE_DOUBLE_OFF (0<<2) + #define PM3VideoControl_LINE_DOUBLE_ON (1<<2) + #define PM3VideoControl_HSYNC_FORCE_HIGH (0<<3) + #define PM3VideoControl_HSYNC_ACTIVE_HIGH (1<<3) + #define PM3VideoControl_HSYNC_FORCE_LOW (2<<3) + #define PM3VideoControl_HSYNC_ACTIVE_LOW (3<<3) + #define PM3VideoControl_VSYNC_FORCE_HIGH (0<<5) + #define PM3VideoControl_VSYNC_ACTIVE_HIGH (1<<5) + #define PM3VideoControl_VSYNC_FORCE_LOW (2<<5) + #define PM3VideoControl_VSYNC_ACTIVE_LOW (3<<5) + #define PM3VideoControl_BYTE_DOUBLE_OFF (0<<7) + #define PM3VideoControl_BYTE_DOUBLE_ON (1<<7) + #define PM3VideoControl_BUFFER_SWAP_SYNCON_FRAMEBLANK (0<<9) + #define PM3VideoControl_BUFFER_SWAP_FREE_RUNNING (1<<9) + #define PM3VideoControl_BUFFER_SWAP_LIMITETO_FRAMERATE (2<<9) + #define PM3VideoControl_STEREO_DISABLE (0<<11) + #define PM3VideoControl_STEREO_ENABLE (1<<11) + #define PM3VideoControl_RIGHT_EYE_ACTIVE_HIGH (0<<12) + #define PM3VideoControl_RIGHT_EYE_ACTIVE_LOW (1<<12) + #define PM3VideoControl_VIDEO_EXT_LOW (0<<14) + #define PM3VideoControl_VIDEO_EXT_HIGH (1<<14) + #define PM3VideoControl_SYNC_MODE_INDEPENDENT (0<<16) + #define PM3VideoControl_SYNC_MODE_SYNCTO_VSA (1<<16) + #define PM3VideoControl_SYNC_MODE_SYNCTO_VSB (2<<16) + #define PM3VideoControl_PATCH_DISABLE (0<<18) + #define PM3VideoControl_PATCH_ENABLE (1<<18) + #define PM3VideoControl_PIXELSIZE_8BIT (0<<19) + #define PM3VideoControl_PIXELSIZE_16BIT (1<<19) + #define PM3VideoControl_PIXELSIZE_32BIT (2<<19) + #define PM3VideoControl_DISPLAY_DISABLE (0<<21) + #define PM3VideoControl_DISPLAY_ENABLE (1<<21) + #define PM3VideoControl_PATCH_OFFSET_X(off) (((off)&0x3f)<<22) + #define PM3VideoControl_PATCH_OFFSET_Y(off) (((off)&0x3f)<<28) +#define PM3InterruptLine 0x3060 +#define PM3DisplayData 0x3068 +#define PM3VerticalLineCount 0x3070 +#define PM3FifoControl 0x3078 +#define PM3ScreenBaseRight 0x3080 +#define PM3MiscControl 0x3088 + +#define PM3VideoOverlayUpdate 0x3100 +#define PM3VideoOverlayMode 0x3108 + #define PM3VideoOverlayMode_DISABLE (0<<0) + #define PM3VideoOverlayMode_ENABLE (1<<0) + /* ... */ +#define PM3VideoOverlayFifoControl 0x3110 +#define PM3VideoOverlayIndex 0x3118 +#define PM3VideoOverlayBase0 0x3120 +#define PM3VideoOverlayBase1 0x3128 +#define PM3VideoOverlayBase2 0x3130 +#define PM3VideoOverlayStride 0x3138 +#define PM3VideoOverlayWidth 0x3140 +#define PM3VideoOverlayHeight 0x3148 +#define PM3VideoOverlayOrigin 0x3150 +#define PM3VideoOverlayShrinkXDelta 0x3158 +#define PM3VideoOverlayZoomXDelta 0x3160 +#define PM3VideoOverlayYDelta 0x3168 +#define PM3VideoOverlayFieldOffset 0x3170 +#define PM3VideoOverlayStatus 0x3178 + +/********************************************** +* GLINT Permedia3 RAMDAC Registers (0x4000) * +***********************************************/ +/* Direct Registers */ +#define PM3RD_PaletteWriteAddress 0x4000 +#define PM3RD_PaletteData 0x4008 +#define PM3RD_PixelMask 0x4010 +#define PM3RD_PaletteReadAddress 0x4018 + +#define PM3RD_IndexLow 0x4020 +#define PM3RD_IndexHigh 0x4028 +#define PM3RD_IndexedData 0x4030 +#define PM3RD_IndexControl 0x4038 + #define PM3RD_IndexControl_AUTOINCREMENT_ENABLE (1<<0) + #define PM3RD_IndexControl_AUTOINCREMENT_DISABLE (0<<0) + +/* Indirect Registers */ +#define PM3RD_MiscControl 0x000 + #define PM3RD_MiscControl_HIGHCOLOR_RES_DISABLE (0<<0) + #define PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE (1<<0) + #define PM3RD_MiscControl_PIXELDOUBLE_DISABLE (0<<1) + #define PM3RD_MiscControl_PIXELDOUBLE_ENABLE (1<<1) + #define PM3RD_MiscControl_LASTREAD_ADDR_DISABLE (0<<2) + #define PM3RD_MiscControl_LASTREAD_ADDR_ENABLE (1<<2) + #define PM3RD_MiscControl_DIRECTCOLOR_DISABLE (0<<3) + #define PM3RD_MiscControl_DIRECTCOLOR_ENABLE (1<<3) + #define PM3RD_MiscControl_OVERLAY_DISABLE (0<<4) + #define PM3RD_MiscControl_OVERLAY_ENABLE (1<<4) + #define PM3RD_MiscControl_PIXELDOUBLE_BUFFER_DISABLE (0<<5) + #define PM3RD_MiscControl_PIXELDOUBLE_BUFFER_ENABLE (1<<5) + #define PM3RD_MiscControl_VSB_OUTPUT_DISABLE (0<<6) + #define PM3RD_MiscControl_VSB_OUTPUT_ENABLE (1<<6) + #define PM3RD_MiscControl_STEREODOUBLE_BUFFER_DISABLE (0<<7) + #define PM3RD_MiscControl_STEREODOUBLE_BUFFER_ENABLE (1<<7) +#define PM3RD_SyncControl 0x001 + #define PM3RD_SyncControl_HSYNC_ACTIVE_LOW (0<<0) + #define PM3RD_SyncControl_HSYNC_ACTIVE_HIGH (1<<0) + #define PM3RD_SyncControl_HSYNC_FORCE_ACTIVE (3<<0) + #define PM3RD_SyncControl_HSYNC_FORCE_INACTIVE (4<<0) + #define PM3RD_SyncControl_HSYNC_TRI_STATE (2<<0) + #define PM3RD_SyncControl_VSYNC_ACTIVE_LOW (0<<3) + #define PM3RD_SyncControl_VSYNC_ACTIVE_HIGH (1<<3) + #define PM3RD_SyncControl_VSYNC_TRI_STATE (2<<3) + #define PM3RD_SyncControl_VSYNC_FORCE_ACTIVE (3<<3) + #define PM3RD_SyncControl_VSYNC_FORCE_INACTIVE (4<<3) + #define PM3RD_SyncControl_HSYNC_OVERRIDE_SETBY_HSYNC (0<<6) + #define PM3RD_SyncControl_HSYNC_OVERRIDE_FORCE_HIGH (1<<6) + #define PM3RD_SyncControl_VSYNC_OVERRIDE_SETBY_VSYNC (0<<7) + #define PM3RD_SyncControl_VSYNC_OVERRIDE_FORCE_HIGH (1<<7) +#define PM3RD_DACControl 0x002 + #define PM3RD_DACControl_DAC_POWER_ON (0<<0) + #define PM3RD_DACControl_DAC_POWER_OFF (1<<0) + #define PM3RD_DACControl_SYNC_ON_GREEN_DISABLE (0<<3) + #define PM3RD_DACControl_SYNC_ON_GREEN_ENABLE (1<<3) + #define PM3RD_DACControl_BLANK_RED_DAC_DISABLE (0<<4) + #define PM3RD_DACControl_BLANK_RED_DAC_ENABLE (1<<4) + #define PM3RD_DACControl_BLANK_GREEN_DAC_DISABLE (0<<5) + #define PM3RD_DACControl_BLANK_GREEN_DAC_ENABLE (1<<5) + #define PM3RD_DACControl_BLANK_BLUE_DAC_DISABLE (0<<6) + #define PM3RD_DACControl_BLANK_BLUE_DAC_ENABLE (1<<6) + #define PM3RD_DACControl_BLANK_PEDESTAL_DISABLE (0<<7) + #define PM3RD_DACControl_BLANK_PEDESTAL_ENABLE (1<<7) +#define PM3RD_PixelSize 0x003 + #define PM3RD_PixelSize_24_BIT_PIXELS (4<<0) + #define PM3RD_PixelSize_32_BIT_PIXELS (2<<0) + #define PM3RD_PixelSize_16_BIT_PIXELS (1<<0) + #define PM3RD_PixelSize_8_BIT_PIXELS (0<<0) +#define PM3RD_ColorFormat 0x004 + #define PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE (1<<6) + #define PM3RD_ColorFormat_LINEAR_COLOR_EXT_DISABLE (0<<6) + #define PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW (1<<5) + #define PM3RD_ColorFormat_COLOR_ORDER_RED_LOW (0<<5) + #define PM3RD_ColorFormat_COLOR_FORMAT_MASK (0x1f<<0) + #define PM3RD_ColorFormat_8888_COLOR (0<<0) + #define PM3RD_ColorFormat_5551_FRONT_COLOR (1<<0) + #define PM3RD_ColorFormat_4444_COLOR (2<<0) + #define PM3RD_ColorFormat_332_FRONT_COLOR (5<<0) + #define PM3RD_ColorFormat_332_BACK_COLOR (6<<0) + #define PM3RD_ColorFormat_2321_FRONT_COLOR (9<<0) + #define PM3RD_ColorFormat_2321_BACK_COLOR (10<<0) + #define PM3RD_ColorFormat_232_FRONTOFF_COLOR (11<<0) + #define PM3RD_ColorFormat_232_BACKOFF_COLOR (12<<0) + #define PM3RD_ColorFormat_5551_BACK_COLOR (13<<0) + #define PM3RD_ColorFormat_CI8_COLOR (14<<0) + #define PM3RD_ColorFormat_565_FRONT_COLOR (16<<0) + #define PM3RD_ColorFormat_565_BACK_COLOR (17<<0) +#define PM3RD_CursorMode 0x005 + #define PM3RD_CursorMode_CURSOR_DISABLE (0<<0) + #define PM3RD_CursorMode_CURSOR_ENABLE (1<<0) + #define PM3RD_CursorMode_FORMAT_64x64_2BPE_P0123 (0<<2) + #define PM3RD_CursorMode_FORMAT_32x32_2BPE_P0 (1<<2) + #define PM3RD_CursorMode_FORMAT_32x32_2BPE_P1 (2<<2) + #define PM3RD_CursorMode_FORMAT_32x32_2BPE_P2 (3<<2) + #define PM3RD_CursorMode_FORMAT_32x32_2BPE_P3 (4<<2) + #define PM3RD_CursorMode_FORMAT_32x32_4BPE_P01 (5<<2) + #define PM3RD_CursorMode_FORMAT_32x32_4BPE_P23 (6<<2) + #define PM3RD_CursorMode_TYPE_MS (0<<4) + #define PM3RD_CursorMode_TYPE_X (1<<4) + #define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_DISABLE (0<<6) + #define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_ENABLE (1<<6) + #define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_3_COLOR (2<<6) + #define PM3RD_CursorMode_REVERSE_PIXEL_ORDER_15_COLOR (3<<6) +#define PM3RD_CursorControl 0x006 + #define PM3RD_CursorControl_DOUBLE_X_DISABLED (0<<0) + #define PM3RD_CursorControl_DOUBLE_X_ENABLED (1<<0) + #define PM3RD_CursorControl_DOUBLE_Y_DISABLED (0<<1) + #define PM3RD_CursorControl_DOUBLE_Y_ENABLED (1<<1) + #define PM3RD_CursorControl_READBACK_POS_DISABLED (0<<2) + #define PM3RD_CursorControl_READBACK_POS_ENABLED (1<<2) + +#define PM3RD_CursorXLow 0x007 +#define PM3RD_CursorXHigh 0x008 +#define PM3RD_CursorYLow 0x009 +#define PM3RD_CursorYHigh 0x00a +#define PM3RD_CursorHotSpotX 0x00b +#define PM3RD_CursorHotSpotY 0x00c +#define PM3RD_OverlayKey 0x00d +#define PM3RD_Pan 0x00e + #define PM3RD_Pan_DISABLE (0<<0) + #define PM3RD_Pan_ENABLE (1<<0) + #define PM3RD_Pan_GATE_DISABLE (0<<1) + #define PM3RD_Pan_GATE_ENABLE (1<<1) +#define PM3RD_Sense 0x00f + +#define PM3RD_CheckControl 0x018 + #define PM3RD_CheckControl_PIXEL_DISABLED (0<<0) + #define PM3RD_CheckControl_PIXEL_ENABLED (1<<0) + #define PM3RD_CheckControl_LUT_DISABLED (0<<1) + #define PM3RD_CheckControl_LUT_ENABLED (1<<1) +#define PM3RD_CheckPixelRed 0x019 +#define PM3RD_CheckPixelGreen 0x01a +#define PM3RD_CheckPixelBlue 0x01b +#define PM3RD_CheckLUTRed 0x01c +#define PM3RD_CheckLUTGreen 0x01d +#define PM3RD_CheckLUTBlue 0x01e +#define PM3RD_Scratch 0x01f + +#define PM3RD_VideoOverlayControl 0x020 +#define PM3RD_VideoOverlayXStartLow 0x021 +#define PM3RD_VideoOverlayXStartHigh 0x022 +#define PM3RD_VideoOverlayYStartLow 0x023 +#define PM3RD_VideoOverlayYStartHigh 0x024 +#define PM3RD_VideoOverlayXEndLow 0x025 +#define PM3RD_VideoOverlayXEndHigh 0x026 +#define PM3RD_VideoOverlayYEndLow 0x027 +#define PM3RD_VideoOverlayYEndHigh 0x028 +#define PM3RD_VideoOverlayKeyR 0x029 +#define PM3RD_VideoOverlayKeyG 0x02a +#define PM3RD_VideoOverlayKeyB 0x02b +#define PM3RD_VideoOverlayBlend 0x02c + +#define PM3RD_DClkSetup1 0x1f0 +#define PM3RD_DClkSetup2 0x1f1 +#define PM3RD_KClkSetup1 0x1f2 +#define PM3RD_KClkSetup2 0x1f3 + +#define PM3RD_DClkControl 0x200 + #define PM3RD_DClkControl_SOURCE_PLL (0<<4) + #define PM3RD_DClkControl_SOURCE_VSA (1<<4) + #define PM3RD_DClkControl_SOURCE_VSB (2<<4) + #define PM3RD_DClkControl_SOURCE_EXT (3<<4) + #define PM3RD_DClkControl_STATE_RUN (2<<2) + #define PM3RD_DClkControl_STATE_HIGH (1<<2) + #define PM3RD_DClkControl_STATE_LOW (0<<2) + #define PM3RD_DClkControl_LOCKED (1<<1) + #define PM3RD_DClkControl_NOT_LOCKED (0<<1) + #define PM3RD_DClkControl_ENABLE (1<<0) + #define PM3RD_DClkControl_DISABLE (0<<0) +#define PM3RD_DClk0PreScale 0x201 +#define PM3RD_DClk0FeedbackScale 0x202 +#define PM3RD_DClk0PostScale 0x203 +#define PM3RD_DClk1PreScale 0x204 +#define PM3RD_DClk1FeedbackScale 0x205 +#define PM3RD_DClk1PostScale 0x206 +#define PM3RD_DClk2PreScale 0x207 +#define PM3RD_DClk2FeedbackScale 0x208 +#define PM3RD_DClk2PostScale 0x209 +#define PM3RD_DClk3PreScale 0x20a +#define PM3RD_DClk3FeedbackScale 0x20b +#define PM3RD_DClk3PostScale 0x20c +#define PM3RD_KClkControl 0x20d + #define PM3RD_KClkControl_DISABLE (0<<0) + #define PM3RD_KClkControl_ENABLE (1<<0) + #define PM3RD_KClkControl_NOT_LOCKED (0<<1) + #define PM3RD_KClkControl_LOCKED (1<<1) + #define PM3RD_KClkControl_STATE_LOW (0<<2) + #define PM3RD_KClkControl_STATE_HIGH (1<<2) + #define PM3RD_KClkControl_STATE_RUN (2<<2) + #define PM3RD_KClkControl_STATE_LOW_POWER (3<<2) + #define PM3RD_KClkControl_SOURCE_PCLK (0<<4) + #define PM3RD_KClkControl_SOURCE_HALF_PCLK (1<<4) + #define PM3RD_KClkControl_SOURCE_PLL (2<<4) +#define PM3RD_KClkPreScale 0x20e +#define PM3RD_KClkFeedbackScale 0x20f +#define PM3RD_KClkPostScale 0x210 +#define PM3RD_MClkControl 0x211 + #define PM3RD_MClkControl_DISABLE (0<<0) + #define PM3RD_MClkControl_ENABLE (1<<0) + #define PM3RD_MClkControl_NOT_LOCKED (0<<1) + #define PM3RD_MClkControl_LOCKED (1<<1) + #define PM3RD_MClkControl_STATE_LOW (0<<2) + #define PM3RD_MClkControl_STATE_HIGH (1<<2) + #define PM3RD_MClkControl_STATE_RUN (2<<2) + #define PM3RD_MClkControl_STATE_LOW_POWER (3<<2) + #define PM3RD_MClkControl_SOURCE_PCLK (0<<4) + #define PM3RD_MClkControl_SOURCE_HALF_PCLK (1<<4) + #define PM3RD_MClkControl_SOURCE_HALF_EXT (3<<4) + #define PM3RD_MClkControl_SOURCE_EXT (4<<4) + #define PM3RD_MClkControl_SOURCE_HALF_KCLK (5<<4) + #define PM3RD_MClkControl_SOURCE_KCLK (6<<4) +#define PM3RD_MClkPreScale 0x212 +#define PM3RD_MClkFeedbackScale 0x213 +#define PM3RD_MClkPostScale 0x214 +#define PM3RD_SClkControl 0x215 + #define PM3RD_SClkControl_DISABLE (0<<0) + #define PM3RD_SClkControl_ENABLE (1<<0) + #define PM3RD_SClkControl_NOT_LOCKED (0<<1) + #define PM3RD_SClkControl_LOCKED (1<<1) + #define PM3RD_SClkControl_STATE_LOW (0<<2) + #define PM3RD_SClkControl_STATE_HIGH (1<<2) + #define PM3RD_SClkControl_STATE_RUN (2<<2) + #define PM3RD_SClkControl_STATE_LOW_POWER (3<<2) + #define PM3RD_SClkControl_SOURCE_PCLK (0<<4) + #define PM3RD_SClkControl_SOURCE_HALF_PCLK (1<<4) + #define PM3RD_SClkControl_SOURCE_HALF_EXT (3<<4) + #define PM3RD_SClkControl_SOURCE_EXT (4<<4) + #define PM3RD_SClkControl_SOURCE_HALF_KCLK (5<<4) + #define PM3RD_SClkControl_SOURCE_KCLK (6<<4) +#define PM3RD_SClkPreScale 0x216 +#define PM3RD_SClkFeedbackScale 0x217 +#define PM3RD_SClkPostScale 0x218 + +#define PM3RD_CursorPalette(p) (0x303+(p)) +#define PM3RD_CursorPattern(p) (0x400+(p)) +/****************************************************** +* GLINT Permedia3 Video Streaming Registers (0x5000) * +*******************************************************/ + +#define PM3VSConfiguration 0x5800 + +/********************************************** +* GLINT Permedia3 Core Registers (0x8000+) * +***********************************************/ +#define PM3AALineWidth 0x94c0 +#define PM3AAPointsize 0x94a0 +#define PM3AlphaBlendAlphaMode 0xafa8 +#define PM3AlphaBlendAlphaModeAnd 0xad30 +#define PM3AlphaBlendAlphaModeOr 0xad38 +#define PM3AlphaBlendColorMode 0xafa0 +#define PM3AlphaBlendColorModeAnd 0xacb0 +#define PM3AlphaBlendColorModeOr 0xacb8 +#define PM3AlphaDestColor 0xaf88 +#define PM3AlphaSourceColor 0xaf80 +#define PM3AlphaTestMode 0x8800 +#define PM3AlphaTestModeAnd 0xabf0 +#define PM3AlphaTestModeOr 0xabf8 +#define PM3AntialiasMode 0x8808 +#define PM3AntialiasModeAnd 0xac00 +#define PM3AntialiasModeOr 0xac08 +/* ... */ +#define PM3BackgroundColor 0xb0c8 +/* ... */ +#define PM3ColorDDAMode 0x87e0 +#define PM3ColorDDAModeAnd 0xabe0 +#define PM3ColorDDAModeOr 0xabe8 +#define PM3CommandInterrupt 0xa990 +#define PM3ConstantColorDDA 0xafb0 + #define PM3ConstantColorDDA_R(r) ((r)&0xff) + #define PM3ConstantColorDDA_G(g) (((g)&0xff)<<8) + #define PM3ConstantColorDDA_B(b) (((b)&0xff)<<16) + #define PM3ConstantColorDDA_A(a) (((a)&0xff)<<24) +#define PM3ContextData 0x8dd0 +#define PM3ContextDump 0x8dc0 +#define PM3ContextRestore 0x8dc8 +#define PM3Continue 0x8058 +#define PM3ContinueNewDom 0x8048 +#define PM3ContinueNewLine 0x8040 +#define PM3ContinueNewSub 0x8050 +#define PM3Count 0x8030 +/* ... */ +#define PM3DeltaControl 0x9350 +#define PM3DeltaControlAnd 0xab20 +#define PM3DeltaControlOr 0xab28 +#define PM3DeltaMode 0x9300 +#define PM3DeltaModeAnd 0xaad0 +#define PM3DeltaModeOr 0xaad8 +/* ... */ +#define PM3DitherMode 0x8818 +#define PM3DitherModeAnd 0xacd0 +#define PM3DitherModeOr 0xacd8 +/* ... */ +#define PM3dXDom 0x8008 +#define PM3dXSub 0x8018 +#define PM3dY 0x8028 +/* ... */ +#define PM3FBBlockColor 0x8ac8 +#define PM3FBBlockColor0 0xb060 +#define PM3FBBlockColor1 0xb068 +#define PM3FBBlockColor2 0xb070 +#define PM3FBBlockColor3 0xb078 +#define PM3FBBlockColorBack 0xb0a0 +#define PM3FBBlockColorBack0 0xb080 +#define PM3FBBlockColorBack1 0xb088 +#define PM3FBBlockColorBack2 0xb090 +#define PM3FBBlockColorBack3 0xb098 +#define PM3FBColor 0x8a98 +#define PM3FBDestReadBufferAddr0 0xae80 +#define PM3FBDestReadBufferAddr1 0xae88 +#define PM3FBDestReadBufferAddr2 0xae90 +#define PM3FBDestReadBufferAddr3 0xae98 +#define PM3FBDestReadBufferOffset0 0xaea0 +#define PM3FBDestReadBufferOffset1 0xaea8 +#define PM3FBDestReadBufferOffset2 0xaeb0 +#define PM3FBDestReadBufferOffset3 0xaeb8 + #define PM3FBDestReadBufferOffset_XOffset(x) ((x)&0xffff) + #define PM3FBDestReadBufferOffset_YOffset(y) (((y)&0xffff)<<16) +#define PM3FBDestReadBufferWidth0 0xaec0 +#define PM3FBDestReadBufferWidth1 0xaec8 +#define PM3FBDestReadBufferWidth2 0xaed0 +#define PM3FBDestReadBufferWidth3 0xaed8 + #define PM3FBDestReadBufferWidth_Width(w) ((w)&0x0fff) + +#define PM3FBDestReadEnables 0xaee8 +#define PM3FBDestReadEnablesAnd 0xad20 +#define PM3FBDestReadEnablesOr 0xad28 + #define PM3FBDestReadEnables_E(e) ((e)&0xff) + #define PM3FBDestReadEnables_E0 1<<0 + #define PM3FBDestReadEnables_E1 1<<1 + #define PM3FBDestReadEnables_E2 1<<2 + #define PM3FBDestReadEnables_E3 1<<3 + #define PM3FBDestReadEnables_E4 1<<4 + #define PM3FBDestReadEnables_E5 1<<5 + #define PM3FBDestReadEnables_E6 1<<6 + #define PM3FBDestReadEnables_E7 1<<7 + #define PM3FBDestReadEnables_R(r) (((r)&0xff)<<8) + #define PM3FBDestReadEnables_R0 1<<8 + #define PM3FBDestReadEnables_R1 1<<9 + #define PM3FBDestReadEnables_R2 1<<10 + #define PM3FBDestReadEnables_R3 1<<11 + #define PM3FBDestReadEnables_R4 1<<12 + #define PM3FBDestReadEnables_R5 1<<13 + #define PM3FBDestReadEnables_R6 1<<14 + #define PM3FBDestReadEnables_R7 1<<15 + #define PM3FBDestReadEnables_ReferenceAlpha(a) (((a)&0xff)<<24) + +#define PM3FBDestReadMode 0xaee0 +#define PM3FBDestReadModeAnd 0xac90 +#define PM3FBDestReadModeOr 0xac98 + #define PM3FBDestReadMode_ReadDisable 0<<0 + #define PM3FBDestReadMode_ReadEnable 1<<0 + #define PM3FBDestReadMode_StripePitch(sp) (((sp)&0x7)<<2 + #define PM3FBDestReadMode_StripeHeight(sh) (((sh)&0x7)<<7 + #define PM3FBDestReadMode_Enable0 1<<8 + #define PM3FBDestReadMode_Enable1 1<<9 + #define PM3FBDestReadMode_Enable2 1<<10 + #define PM3FBDestReadMode_Enable3 1<<11 + #define PM3FBDestReadMode_Layout0(l) (((l)&0x3)<<12 + #define PM3FBDestReadMode_Layout1(l) (((l)&0x3)<<14 + #define PM3FBDestReadMode_Layout2(l) (((l)&0x3)<<16 + #define PM3FBDestReadMode_Layout3(l) (((l)&0x3)<<18 + #define PM3FBDestReadMode_Origin0 1<<20 + #define PM3FBDestReadMode_Origin1 1<<21 + #define PM3FBDestReadMode_Origin2 1<<22 + #define PM3FBDestReadMode_Origin3 1<<23 + #define PM3FBDestReadMode_Blocking 1<<24 + #define PM3FBDestReadMode_UseReadEnabled 1<<26 + #define PM3FBDestReadMode_AlphaFiltering 1<<27 + +#define PM3FBHardwareWriteMask 0x8ac0 +#define PM3FBSoftwareWriteMask 0x8820 +#define PM3FBData 0x8aa0 +#define PM3FBSourceData 0x8aa8 +#define PM3FBSourceReadBufferAddr 0xaf08 +#define PM3FBSourceReadBufferOffset 0xaf10 + #define PM3FBSourceReadBufferOffset_XOffset(x) ((x)&0xffff) + #define PM3FBSourceReadBufferOffset_YOffset(y) (((y)&0xffff)<<16) +#define PM3FBSourceReadBufferWidth 0xaf18 + #define PM3FBSourceReadBufferWidth_Width(w) ((w)&0x0fff) +#define PM3FBSourceReadMode 0xaf00 +#define PM3FBSourceReadModeAnd 0xaca0 +#define PM3FBSourceReadModeOr 0xaca8 + #define PM3FBSourceReadMode_ReadDisable (0<<0) + #define PM3FBSourceReadMode_ReadEnable (1<<0) + #define PM3FBSourceReadMode_StripePitch(sp) (((sp)&0x7)<<2 + #define PM3FBSourceReadMode_StripeHeight(sh) (((sh)&0x7)<<7 + #define PM3FBSourceReadMode_Layout(l) (((l)&0x3)<<8 + #define PM3FBSourceReadMode_Origin 1<<10 + #define PM3FBSourceReadMode_Blocking 1<<11 + #define PM3FBSourceReadMode_UserTexelCoord 1<<13 + #define PM3FBSourceReadMode_WrapXEnable 1<<14 + #define PM3FBSourceReadMode_WrapYEnable 1<<15 + #define PM3FBSourceReadMode_WrapX(w) (((w)&0xf)<<16 + #define PM3FBSourceReadMode_WrapY(w) (((w)&0xf)<<20 + #define PM3FBSourceReadMode_ExternalSourceData 1<<24 +#define PM3FBWriteBufferAddr0 0xb000 +#define PM3FBWriteBufferAddr1 0xb008 +#define PM3FBWriteBufferAddr2 0xb010 +#define PM3FBWriteBufferAddr3 0xb018 + +#define PM3FBWriteBufferOffset0 0xb020 +#define PM3FBWriteBufferOffset1 0xb028 +#define PM3FBWriteBufferOffset2 0xb030 +#define PM3FBWriteBufferOffset3 0xb038 + #define PM3FBWriteBufferOffset_XOffset(x) ((x)&0xffff) + #define PM3FBWriteBufferOffset_YOffset(y) (((y)&0xffff)<<16) + +#define PM3FBWriteBufferWidth0 0xb040 +#define PM3FBWriteBufferWidth1 0xb048 +#define PM3FBWriteBufferWidth2 0xb050 +#define PM3FBWriteBufferWidth3 0xb058 + #define PM3FBWriteBufferWidth_Width(w) ((w)&0x0fff) + +#define PM3FBWriteMode 0x8ab8 +#define PM3FBWriteModeAnd 0xacf0 +#define PM3FBWriteModeOr 0xacf8 + #define PM3FBWriteMode_WriteDisable 0<<0 + #define PM3FBWriteMode_WriteEnable 1<<0 + #define PM3FBWriteMode_Replicate 1<<4 + #define PM3FBWriteMode_OpaqueSpan 1<<5 + #define PM3FBWriteMode_StripePitch(p) (((p)&0x7)<<6) + #define PM3FBWriteMode_StripeHeight(h) (((h)&0x7)<<9) + #define PM3FBWriteMode_Enable0 1<<12 + #define PM3FBWriteMode_Enable1 1<<13 + #define PM3FBWriteMode_Enable2 1<<14 + #define PM3FBWriteMode_Enable3 1<<15 + #define PM3FBWriteMode_Layout0(l) (((l)&0x3)<<16) + #define PM3FBWriteMode_Layout1(l) (((l)&0x3)<<18) + #define PM3FBWriteMode_Layout2(l) (((l)&0x3)<<20) + #define PM3FBWriteMode_Layout3(l) (((l)&0x3)<<22) + #define PM3FBWriteMode_Origin0 1<<24 + #define PM3FBWriteMode_Origin1 1<<25 + #define PM3FBWriteMode_Origin2 1<<26 + #define PM3FBWriteMode_Origin3 1<<27 +#define PM3ForegroundColor 0xb0c0 +/* ... */ +#define PM3GIDMode 0xb538 +#define PM3GIDModeAnd 0xb5b0 +#define PM3GIDModeOr 0xb5b8 +/* ... */ +#define PM3LBDestReadBufferAddr 0xb510 +#define PM3LBDestReadBufferOffset 0xb518 +#define PM3LBDestReadEnables 0xb508 +#define PM3LBDestReadEnablesAnd 0xb590 +#define PM3LBDestReadEnablesOr 0xb598 +#define PM3LBDestReadMode 0xb500 +#define PM3LBDestReadModeAnd 0xb580 +#define PM3LBDestReadModeOr 0xb588 + #define PM3LBDestReadMode_Disable 0<<0 + #define PM3LBDestReadMode_Enable 1<<0 + #define PM3LBDestReadMode_StripePitch(p) (((p)&0x7)<<2) + #define PM3LBDestReadMode_StripeHeight(h) (((h)&0x7)<<5) + #define PM3LBDestReadMode_Layout 1<<8 + #define PM3LBDestReadMode_Origin 1<<9 + #define PM3LBDestReadMode_UserReadEnables 1<<10 + #define PM3LBDestReadMode_Packed16 1<<11 + #define PM3LBDestReadMode_Width(w) (((w)&0xfff)<<12) +#define PM3LBReadFormat 0x8888 + #define PM3LBReadFormat_DepthWidth(w) (((w)&0x3)<<0) + #define PM3LBReadFormat_StencilWidth(w) (((w)&0xf)<<2) + #define PM3LBReadFormat_StencilPosition(p) (((p)&0x1f)<<6) + #define PM3LBReadFormat_FCPWidth(w) (((w)&0xf)<<11) + #define PM3LBReadFormat_FCPPosition(p) (((p)&0x1f)<<15) + #define PM3LBReadFormat_GIDWidth(w) (((w)&0x7)<<20) + #define PM3LBReadFormat_GIDPosition(p) (((p)&0x1f)<<23) +#define PM3LBSourceReadBufferAddr 0xb528 +#define PM3LBSourceReadBufferOffset 0xb530 +#define PM3LBSourceReadMode 0xb520 +#define PM3LBSourceReadModeAnd 0xb5a0 +#define PM3LBSourceReadModeOr 0xb5a8 + #define PM3LBSourceReadMode_Enable 1<<0 + #define PM3LBSourceReadMode_StripePitch(p) (((p)&0x7)<<2) + #define PM3LBSourceReadMode_StripeHeight(h) (((h)&0x7)<<5) + #define PM3LBSourceReadMode_Layout 1<<8 + #define PM3LBSourceReadMode_Origin 1<<9 + #define PM3LBSourceReadMode_Packed16 1<<10 + #define PM3LBSourceReadMode_Width(w) (((w)&0xfff)<<11) +#define PM3LBStencil 0x88a8 +#define PM3LBWriteBufferAddr 0xb540 +#define PM3LBWriteBufferOffset 0xb548 +#define PM3LBWriteFormat 0x88c8 + #define PM3LBWriteFormat_DepthWidth(w) (((w)&0x3)<<0) + #define PM3LBWriteFormat_StencilWidth(w) (((w)&0xf)<<2) + #define PM3LBWriteFormat_StencilPosition(p) (((p)&0x1f)<<6) + #define PM3LBWriteFormat_GIDWidth(w) (((w)&0x7)<<20) + #define PM3LBWriteFormat_GIDPosition(p) (((p)&0x1f)<<23) +#define PM3LBWriteMode 0x88c0 +#define PM3LBWriteModeAnd 0xac80 +#define PM3LBWriteModeOr 0xac88 + #define PM3LBWriteMode_WriteDisable 0<<0 + #define PM3LBWriteMode_WriteEnable 1<<0 + #define PM3LBWriteMode_StripePitch(p) (((p)&0x7)<<3) + #define PM3LBWriteMode_StripeHeight(h) (((h)&0x7)<<6) + #define PM3LBWriteMode_Layout 1<<9 + #define PM3LBWriteMode_Origin 1<<10 + #define PM3LBWriteMode_Packed16 1<<11 + #define PM3LBWriteMode_Width(w) (((w)&0xfff)<<12) +/* ... */ +#define PM3LineStippleMode 0x81a8 +#define PM3LineStippleModeAnd 0xabc0 +#define PM3LineStippleModeOr 0xabc8 +#define PM3LoadLineStippleCounters 0x81b0 +/* ... */ +#define PM3LogicalOpMode 0x8828 +#define PM3LogicalOpModeAnd 0xace0 +#define PM3LogicalOpModeOr 0xace8 + #define PM3LogicalOpMode_Disable (0<<0) + #define PM3LogicalOpMode_Enable (1<<0) + #define PM3LogicalOpMode_LogicOp(op) (((op)&0xf)<<1) + #define PM3LogicalOpMode_UseConstantWriteData_Disable (0<<5) + #define PM3LogicalOpMode_UseConstantWriteData_Enable (1<<5) + #define PM3LogicalOpMode_Background_Disable (0<<6) + #define PM3LogicalOpMode_Background_Enable (1<<6) + #define PM3LogicalOpMode_Background_LogicOp(op) (((op)&0xf)<<7) + #define PM3LogicalOpMode_UseConstantSource_Disable (0<<11) + #define PM3LogicalOpMode_UseConstantSource_Enable (1<<11) + +/* ... */ +#define PM3LUT 0x8e80 +/* ... */ +#define PM3LUT 0x8e80 +#define PM3LUTAddress 0x84d0 +#define PM3LUTData 0x84c8 +#define PM3LUTIndex 0x64c0 +#define PM3LUTMode 0xb378 +#define PM3LUTModeAnd 0xad70 +#define PM3LUTModeOr 0xad78 +#define PM3LUTTransfer 0x84d8 +/* ... */ +#define PM3PixelSize 0x80c0 + #define PM3PixelSize_GLOBAL_32BIT (0<<0) + #define PM3PixelSize_GLOBAL_16BIT (1<<0) + #define PM3PixelSize_GLOBAL_8BIT (2<<0) + #define PM3PixelSize_RASTERIZER_32BIT (0<<2) + #define PM3PixelSize_RASTERIZER_16BIT (1<<2) + #define PM3PixelSize_RASTERIZER_8BIT (2<<2) + #define PM3PixelSize_SCISSOR_AND_STIPPLE_32BIT (0<<4) + #define PM3PixelSize_SCISSOR_AND_STIPPLE_16BIT (1<<4) + #define PM3PixelSize_SCISSOR_AND_STIPPLE_8BIT (2<<4) + #define PM3PixelSize_TEXTURE_32BIT (0<<6) + #define PM3PixelSize_TEXTURE_16BIT (1<<6) + #define PM3PixelSize_TEXTURE_8BIT (2<<6) + #define PM3PixelSize_LUT_32BIT (0<<8) + #define PM3PixelSize_LUT_16BIT (1<<8) + #define PM3PixelSize_LUT_8BIT (2<<8) + #define PM3PixelSize_FRAMEBUFFER_32BIT (0<<10) + #define PM3PixelSize_FRAMEBUFFER_16BIT (1<<10) + #define PM3PixelSize_FRAMEBUFFER_8BIT (2<<10) + #define PM3PixelSize_LOGICAL_OP_32BIT (0<<12) + #define PM3PixelSize_LOGICAL_OP_16BIT (1<<12) + #define PM3PixelSize_LOGICAL_OP_8BIT (2<<12) + #define PM3PixelSize_LOCALBUFFER_32BIT (0<<14) + #define PM3PixelSize_LOCALBUFFER_16BIT (1<<14) + #define PM3PixelSize_LOCALBUFFER_8BIT (2<<14) + #define PM3PixelSize_SETUP_32BIT (0<<16) + #define PM3PixelSize_SETUP_16BIT (1<<16) + #define PM3PixelSize_SETUP_8BIT (2<<16) + #define PM3PixelSize_GLOBAL (0<<31) + #define PM3PixelSize_INDIVIDUAL (1<<31) +/* ... */ +#define PM3Render 0x8038 + #define PM3Render_AreaStipple_Disable (0<<0) + #define PM3Render_AreaStipple_Enable (1<<0) + #define PM3Render_LineStipple_Disable (0<<1) + #define PM3Render_LineStipple_Enable (1<<1) + #define PM3Render_ResetLine_Disable (0<<2) + #define PM3Render_ResetLine_Enable (1<<2) + #define PM3Render_FastFill_Disable (0<<3) + #define PM3Render_FastFill_Enable (1<<3) + #define PM3Render_Primitive_Line (0<<6) + #define PM3Render_Primitive_Trapezoid (1<<6) + #define PM3Render_Primitive_Point (2<<6) + #define PM3Render_Antialias_Disable (0<<8) + #define PM3Render_Antialias_Enable (1<<8) + #define PM3Render_Antialias_SubPixelRes_4x4 (0<<9) + #define PM3Render_Antialias_SubPixelRes_8x8 (1<<9) + #define PM3Render_UsePointTable_Disable (0<<10) + #define PM3Render_UsePointTable_Enable (1<<10) + #define PM3Render_SyncOnbitMask_Disable (0<<11) + #define PM3Render_SyncOnBitMask_Enable (1<<11) + #define PM3Render_SyncOnHostData_Disable (0<<12) + #define PM3Render_SyncOnHostData_Enable (1<<12) + #define PM3Render_Texture_Disable (0<<13) + #define PM3Render_Texture_Enable (1<<13) + #define PM3Render_Fog_Disable (0<<14) + #define PM3Render_Fog_Enable (1<<14) + #define PM3Render_Coverage_Disable (0<<15) + #define PM3Render_Coverage_Enable (1<<15) + #define PM3Render_SubPixelCorrection_Disable (0<<16) + #define PM3Render_SubPixelCorrection_Enable (1<<16) + #define PM3Render_SpanOperation_Disable (0<<18) + #define PM3Render_SpanOperation_Enable (1<<18) + #define PM3Render_FBSourceRead_Disable (0<<27) + #define PM3Render_FBSourceRead_Enable (1<<27) +#define PM3RasterizerMode 0x80a0 +#define PM3RasterizerModeAnd 0xaba0 +#define PM3RasterizerModeOr 0xabb8 +#define PM3RectangleHeight 0x94e0 +#define PM3Render 0x8038 +#define PM3RepeatLine 0x9328 +#define PM3ResetPickResult 0x8c20 +#define PM3RLEMask 0x8c48 +#define PM3RouterMode 0x8840 +#define PM3RStart 0x8780 +#define PM3S1Start 0x8400 +#define PM3aveLineStippleCounters 0x81c0 +#define PM3ScissorMaxXY 0x8190 +#define PM3ScissorMinXY 0x8188 +#define PM3ScissorMode 0x8180 +#define PM3ScissorModeAnd 0xabb0 +#define PM3ScissorModeOr 0xabb8 +#define PM3ScreenSize 0x8198 +#define PM3Security 0x8908 +#define PM3SetLogicalTexturePage 0xb360 +#define PM3SizeOfFramebuffer 0xb0a8 +#define PM3SStart 0x8388 +#define PM3StartXDom 0x8000 +#define PM3StartXSub 0x8010 +#define PM3StartY 0x8020 +/* ... */ +#define PM3SpanColorMask 0x8168 +/* ... */ +#define PM3TextureApplicationMode 0x8680 +#define PM3TextureApplicationModeAnd 0xac50 +#define PM3TextureApplicationModeOr 0xac58 +#define PM3TextureBaseAddr 0x8500 +#define PM3TextureCacheControl 0x8490 +#define PM3TextureChromaLower0 0x84f0 +#define PM3TextureChromaLower1 0x8608 +#define PM3TextureChromaUpper0 0x84e8 +#define PM3TextureChromaUpper1 0x8600 +#define PM3TextureCompositeAlphaMode0 0xb310 +#define PM3TextureCompositeAlphaMode0And 0xb390 +#define PM3TextureCompositeAlphaMode0Or 0xb398 +#define PM3TextureCompositeAlphaMode1 0xb320 +#define PM3TextureCompositeAlphaMode1And 0xb3b0 +#define PM3TextureCompositeAlphaMode1Or 0xb3b8 +#define PM3TextureCompositeColorMode0 0xb308 +#define PM3TextureCompositeColorMode0And 0xb380 +#define PM3TextureCompositeColorMode0Or 0xb388 +#define PM3TextureCompositeColorMode1 0xb318 +#define PM3TextureCompositeColorMode1And 0xb3a0 +#define PM3TextureCompositeColorMode1Or 0xb3a8 +#define PM3TextureCompositeFactor0 0xb328 +#define PM3TextureCompositeFactor1 0xb330 +#define PM3TextureCompositeMode 0xb300 +#define PM3TextureCoordMode 0x8380 +#define PM3TextureCoordModeAnd 0xac20 +#define PM3TextureCoordModeOr 0xac28 +#define PM3TextureData 0x88e8 +/* +#define PM3TextureDownloadControl 0x0108 +*/ +#define PM3TextureDownloadOffset 0x88f0 +#define PM3TextureEnvColor 0x8688 +#define PM3TextureFilterMode 0x84e0 +#define PM3TextureFilterModeAnd 0xad50 +#define PM3TextureFilterModeOr 0xad58 +#define PM3TextureIndexMode0 0xb338 +#define PM3TextureIndexMode0And 0xb3c0 +#define PM3TextureIndexMode0Or 0xb3c8 +#define PM3TextureIndexMode1 0xb340 +#define PM3TextureIndexMode1And 0xb3d0 +#define PM3TextureIndexMode1Or 0xb3d8 +/* ... */ +#define PM3WaitForCompletion 0x80b8 +#define PM3Window 0x8980 + #define PM3Window_ForceLBUpdate 1<<3 + #define PM3Window_LBUpdateSource 1<<4 + #define PM3Window_FrameCount(c) (((c)&0xff)<<9 + #define PM3Window_StencilFCP 1<<17 + #define PM3Window_DepthFCP 1<<18 + #define PM3Window_OverrideWriteFiltering 1<<19 +#define PM3WindowAnd 0xab80 +#define PM3WindowOr 0xab88 +#define PM3WindowOrigin 0x81c8 +#define PM3XBias 0x9480 +#define PM3YBias 0x9488 +#define PM3YLimits 0x80a8 +#define PM3UVMode 0x8f00 +#define PM3ZFogBias 0x86b8 +#define PM3ZStart 0xadd8 +#define PM3ZStartL 0x89b8 +#define PM3ZStartU 0x89b0 + + +/********************************************** +* GLINT Permedia3 2D setup Unit * +***********************************************/ +#define PM3Config2D 0xb618 + #define PM3Config2D_OpaqueSpan 1<<0 + #define PM3Config2D_MultiRXBlit 1<<1 + #define PM3Config2D_UserScissorEnable 1<<2 + #define PM3Config2D_FBDestReadEnable 1<<3 + #define PM3Config2D_AlphaBlendEnable 1<<4 + #define PM3Config2D_DitherEnable 1<<5 + #define PM3Config2D_ForegroundROPEnable 1<<6 + #define PM3Config2D_ForegroundROP(rop) (((rop)&0xf)<<7) + #define PM3Config2D_BackgroundROPEnable 1<<11 + #define PM3Config2D_BackgroundROP(rop) (((rop)&0xf)<<12) + #define PM3Config2D_UseConstantSource 1<<16 + #define PM3Config2D_FBWriteEnable 1<<17 + #define PM3Config2D_Blocking 1<<18 + #define PM3Config2D_ExternalSourceData 1<<19 + #define PM3Config2D_LUTModeEnable 1<<20 +#define PM3DownloadGlyphwidth 0xb658 + #define PM3DownloadGlyphwidth_GlyphWidth(gw) ((gw)&0xffff) +#define PM3DownloadTarget 0xb650 + #define PM3DownloadTarget_TagName(tag) ((tag)&0x1fff) +#define PM3GlyphData 0xb660 +#define PM3GlyphPosition 0xb608 + #define PM3GlyphPosition_XOffset(x) ((x)&0xffff) + #define PM3GlyphPosition_YOffset(y) (((y)&0xffff)<<16) +#define PM3Packed4Pixels 0xb668 +#define PM3Packed8Pixels 0xb630 +#define PM3Packed16Pixels 0xb638 +#define PM3RectanglePosition 0xb600 + #define PM3RectanglePosition_XOffset(x) ((x)&0xffff) + #define PM3RectanglePosition_YOffset(y) (((y)&0xffff)<<16) +#define PM3Render2D 0xb640 + #define PM3Render2D_Width(w) ((w)&0x0fff) + #define PM3Render2D_Operation_Normal 0<<12 + #define PM3Render2D_Operation_SyncOnHostData 1<<12 + #define PM3Render2D_Operation_SyncOnBitMask 2<<12 + #define PM3Render2D_Operation_PatchOrderRendering 3<<12 + #define PM3Render2D_FBSourceReadEnable 1<<14 + #define PM3Render2D_SpanOperation 1<<15 + #define PM3Render2D_Height(h) (((h)&0x0fff)<<16) + #define PM3Render2D_XPositive 1<<28 + #define PM3Render2D_YPositive 1<<29 + #define PM3Render2D_AreaStippleEnable 1<<30 + #define PM3Render2D_TextureEnable 1<<31 +#define PM3Render2DGlyph 0xb648 + #define PM3Render2DGlyph_Width(w) ((w)&0x7f) + #define PM3Render2DGlyph_Height(h) (((h)&0x7f)<<7) + #define PM3Render2DGlyph_XOffset(x) (((x)&0x1ff)<<14) + #define PM3Render2DGlyph_YOffset(y) (((y)&0x1ff)<<23) +#define PM3RenderPatchOffset 0xb610 + #define PM3RenderPatchOffset_XOffset(x) ((x)&0xffff) + #define PM3RenderPatchOffset_YOffset(y) (((y)&0xffff)<<16) +#define PM3RLCount 0xb678 + #define PM3RLCount_Count(c) ((c)&0x0fff) +#define PM3RLData 0xb670 + +/********************************************** +* GLINT Permedia3 Alias Register * +***********************************************/ +#define PM3FillBackgroundColor 0x8330 +#define PM3FillConfig2D0 0x8338 +#define PM3FillConfig2D1 0x8360 + #define PM3FillConfig2D_OpaqueSpan 1<<0 + #define PM3FillConfig2D_MultiRXBlit 1<<1 + #define PM3FillConfig2D_UserScissorEnable 1<<2 + #define PM3FillConfig2D_FBDestReadEnable 1<<3 + #define PM3FillConfig2D_AlphaBlendEnable 1<<4 + #define PM3FillConfig2D_DitherEnable 1<<5 + #define PM3FillConfig2D_ForegroundROPEnable 1<<6 + #define PM3FillConfig2D_ForegroundROP(rop) (((rop)&0xf)<<7) + #define PM3FillConfig2D_BackgroundROPEnable 1<<11 + #define PM3FillConfig2D_BackgroundROP(rop) (((rop)&0xf)<<12) + #define PM3FillConfig2D_UseConstantSource 1<<16 + #define PM3FillConfig2D_FBWriteEnable 1<<17 + #define PM3FillConfig2D_Blocking 1<<18 + #define PM3FillConfig2D_ExternalSourceData 1<<19 + #define PM3FillConfig2D_LUTModeEnable 1<<20 +#define PM3FillFBDestReadBufferAddr 0x8310 +#define PM3FillFBSourceReadBufferAddr 0x8308 +#define PM3FillFBSourceReadBufferOffset 0x8340 + #define PM3FillFBSourceReadBufferOffset_XOffset(x) ((x)&0xffff) + #define PM3FillFBSourceReadBufferOffset_YOffset(y) (((y)&0xffff)<<16) +#define PM3FillFBWriteBufferAddr 0x8300 +#define PM3FillForegroundColor0 0x8328 +#define PM3FillForegroundColor1 0x8358 +#define PM3FillGlyphPosition 0x8368 + #define PM3FillGlyphPosition_XOffset(x) ((x)&0xffff) + #define PM3FillGlyphPosition_YOffset(y) (((y)&0xffff)<<16) +#define PM3FillRectanglePosition 0x8348 + #define PM3FillRectanglePosition_XOffset(x) ((x)&0xffff) + #define PM3FillRectanglePosition_YOffset(y) (((y)&0xffff)<<16) + +/********************************************** +* GLINT Permedia3 Tags and other stuff * +***********************************************/ +#define PM3SyncTag 0x0188 + +#if 0 + +/********************************************** +* GLINT Permedia3 Macros * +***********************************************/ + +#define WRITE_REG(base,offset,val) \ + *(volatile unsigned long *)(((unsigned char *)(base)) + offset) = (val) + +#define READ_REG(base,offset) \ + *(volatile unsigned long *)(((unsigned char *)(base)) + offset) + +#define UPDATE_SET_REG(base,offset,val) \ + { \ + unsigned long temp; \ + temp = READ_REG(base,offset); \ + WRITE_REG(base,offset,temp|(val)); \ + } + +#define UPDATE_CLEAR_REG(base,offset,val) \ + { \ + unsigned long temp; \ + temp = READ_REG(base,offset); \ + WRITE_REG(base,offset,temp&(~(val))); \ + } + +#if 0 /* Old Xfree code ... */ +#define WAIT(n) \ +do{ \ + if(!pGlint->UsePCIRetry) \ + while(READ_REG(InFIFOSpace)<(n)){ \ + mem_barrier(); \ + } \ +}while(0) +#endif + +#define RAMDAC_DELAY(b,x) do { \ + int delay = x; \ + unsigned char tmp; \ + while(delay--){tmp = READ_REG(b,PM3InFIFOSpace);}; \ +} while(0) + +#define SLOW_WRITE_REG(b,v,r) \ +do{ \ + RAMDAC_DELAY(b,5); \ + WRITE_REG(b,v,r); \ + RAMDAC_DELAY(b,5); \ +}while(0) + +#define RAMDAC_SET_INDEX(b, index) \ +{ \ + SLOW_WRITE_REG (b,PM3RD_IndexHigh,(index>>8)&0xff); \ + SLOW_WRITE_REG (b,PM3RD_IndexLow,index&0xff); \ +} + +#define RAMDAC_SET_REG(b, index, data) \ +{ \ + RAMDAC_SET_INDEX(b, index); \ + SLOW_WRITE_REG(b, PM3RD_IndexedData, data); \ +} + +#define RAMDAC_GET_REG(b, index, temp) \ +{ \ + RAMDAC_SET_INDEX(b, index); \ + temp = READ_REG(b, PM3RD_IndexedData); \ +} +#endif +#endif /* _PM3_REG_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h:1.1 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h Wed Oct 4 19:34:58 2000 @@ -0,0 +1,67 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/IBMRGB.h,v 1.1 2000/10/04 23:34:58 robin Exp $ */ + + + +/* $XConsortium: $ */ + +#define IBMRGB_REF_FREQ_1 14.31818 +#define IBMRGB_REF_FREQ_2 50.00000 + +#define IBMRGB_rev 0x00 +#define IBMRGB_id 0x01 +#define IBMRGB_misc_clock 0x02 +#define IBMRGB_sync 0x03 +#define IBMRGB_hsync_pos 0x04 +#define IBMRGB_pwr_mgmt 0x05 +#define IBMRGB_dac_op 0x06 +#define IBMRGB_pal_ctrl 0x07 +#define IBMRGB_sysclk 0x08 /* not RGB525 */ +#define IBMRGB_pix_fmt 0x0a +#define IBMRGB_8bpp 0x0b +#define IBMRGB_16bpp 0x0c +#define IBMRGB_24bpp 0x0d +#define IBMRGB_32bpp 0x0e +#define IBMRGB_pll_ctrl1 0x10 +#define IBMRGB_pll_ctrl2 0x11 +#define IBMRGB_pll_ref_div_fix 0x14 +#define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */ +#define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */ +#define IBMRGB_f0 0x20 +#define IBMRGB_m0 0x20 +#define IBMRGB_n0 0x21 +#define IBMRGB_curs 0x30 +#define IBMRGB_curs_xl 0x31 +#define IBMRGB_curs_xh 0x32 +#define IBMRGB_curs_yl 0x33 +#define IBMRGB_curs_yh 0x34 +#define IBMRGB_curs_hot_x 0x35 +#define IBMRGB_curs_hot_y 0x36 +#define IBMRGB_curs_col1_r 0x40 +#define IBMRGB_curs_col1_g 0x41 +#define IBMRGB_curs_col1_b 0x42 +#define IBMRGB_curs_col2_r 0x43 +#define IBMRGB_curs_col2_g 0x44 +#define IBMRGB_curs_col2_b 0x45 +#define IBMRGB_curs_col3_r 0x46 +#define IBMRGB_curs_col3_g 0x47 +#define IBMRGB_curs_col3_b 0x48 +#define IBMRGB_border_col_r 0x60 +#define IBMRGB_border_col_g 0x61 +#define IBMRGB_botder_col_b 0x62 +#define IBMRGB_misc1 0x70 +#define IBMRGB_misc2 0x71 +#define IBMRGB_misc3 0x72 +#define IBMRGB_misc4 0x73 /* not RGB525 */ +#define IBMRGB_dac_sense 0x82 +#define IBMRGB_misr_r 0x84 +#define IBMRGB_misr_g 0x86 +#define IBMRGB_misr_b 0x88 +#define IBMRGB_pll_vco_div_in 0x8e +#define IBMRGB_pll_ref_div_in 0x8f +#define IBMRGB_vram_mask_0 0x90 +#define IBMRGB_vram_mask_1 0x91 +#define IBMRGB_vram_mask_2 0x92 +#define IBMRGB_vram_mask_3 0x93 +#define IBMRGB_curs_array 0x100 + + Index: xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile:1.3 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile Sun Dec 10 20:53:00 2000 @@ -0,0 +1,57 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/Imakefile,v 1.3 2000/12/11 01:53:00 robin Exp $ +XCOMM +XCOMM This is the Imakefile for the I128 driver. +XCOMM + +#define IHaveModules +#include <Server.tmpl> + +SRCS = i128_driver.c i128init.c i128IBMDAC.c i128accel.c i128dga.c +OBJS = i128_driver.o i128init.o i128IBMDAC.o i128accel.o i128dga.o + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \ + -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(XF86SRC)/int10 \ + -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ + -I$(XF86SRC)/ramdac -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf8_32bpp\ + -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ + -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) \ + -I$(XF86OSSRC)/vbe $(DRIINCLUDES) -I$(SERVERSRC)/render +#endif + +DEFINES = $(DRIDEFINES) + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget(i128,$(OBJS)) + +InstallObjectModule(i128,$(MODULEDIR),drivers) + +#if !defined(XF86DriverSDK) +CppManTarget(i128,) +InstallModuleManPage(i128) +#endif + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128.h,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128reg.h,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128_driver.c,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128accel.c,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128init.c,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128IBMDAC.c,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(Ti302X.h,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(IBMRGB.h,$(DRIVERSDKDIR)/drivers/i128) +InstallDriverSDKNonExecFile(i128dga.c,$(DRIVERSDKDIR)/drivers/i128) + +InstallDriverSDKObjectModule(i128,$(DRIVERSDKMODULEDIR),drivers) + Index: xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h:1.1 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h Wed Oct 4 19:34:58 2000 @@ -0,0 +1,211 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/Ti302X.h,v 1.1 2000/10/04 23:34:58 robin Exp $ */ +/* + * Copyright 1994-2000 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ROBIN CUTSHAW BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: $ */ + +#include "compiler.h" +#include <X11/Xfuncproto.h> + + +/* Indirect indexed registers */ + +#define TI_CURS_X_LOW 0x00 +#define TI_CURS_X_HIGH 0x01 /* only lower 4 bits are used */ +#define TI_CURS_Y_LOW 0x02 +#define TI_CURS_Y_HIGH 0x03 /* only lower 4 bits are used */ +#define TI_SPRITE_ORIGIN_X 0x04 +#define TI_SPRITE_ORIGIN_Y 0x05 +#define TI_CURS_CONTROL 0x06 +#define TI_PLANAR_ACCESS 0x80 /* 3025 only - 80 == BT485 mode */ +#define TI_CURS_SPRITE_ENABLE 0x40 +#define TI_CURS_X_WINDOW_MODE 0x10 +#define TI_CURS_CTRL_MASK (TI_CURS_SPRITE_ENABLE | TI_CURS_X_WINDOW_MODE) +#define TI_CURS_RAM_ADDR_LOW 0x08 +#define TI_CURS_RAM_ADDR_HIGH 0x09 +#define TI_CURS_RAM_DATA 0x0A +#define TI_TRUE_COLOR_CONTROL 0x0E /* 3025 only */ +#define TI_TC_BTMODE 0x04 /* on = BT485 mode, off = TI3020 mode */ +#define TI_TC_NONVGAMODE 0x02 /* on = nonvgamode, off = vgamode */ +#define TI_TC_8BIT 0x01 /* on = 8/4bit, off = 16/32bit */ +#define TI_VGA_SWITCH_CONTROL 0x0F /* 3025 only */ +#define TI_LATCH_CONTROL 0x0F /* 3026 only */ +#define TI_WINDOW_START_X_LOW 0x10 +#define TI_WINDOW_START_X_HIGH 0x11 +#define TI_WINDOW_STOP_X_LOW 0x12 +#define TI_WINDOW_STOP_X_HIGH 0x13 +#define TI_WINDOW_START_Y_LOW 0x14 +#define TI_WINDOW_START_Y_HIGH 0x15 +#define TI_WINDOW_STOP_Y_LOW 0x16 +#define TI_WINDOW_STOP_Y_HIGH 0x17 +#define TI_MUX_CONTROL_1 0x18 +#define TI_MUX1_PSEUDO_COLOR 0x80 +#define TI_MUX1_DIRECT_888 0x06 +#define TI_MUX1_DIRECT_565 0x05 +#define TI_MUX1_DIRECT_555 0x04 +#define TI_MUX1_DIRECT_664 0x03 +#define TI_MUX1_TRUE_888 0x46 +#define TI_MUX1_TRUE_565 0x45 +#define TI_MUX1_TRUE_555 0x44 +#define TI_MUX1_TRUE_664 0x43 +#define TI_MUX1_3025D_888 0x0E /* 3025 only */ +#define TI_MUX1_3025D_565 0x0D /* 3025 only */ +#define TI_MUX1_3025D_555 0x0C /* 3025 only */ +#define TI_MUX1_3025T_888 0x4E /* 3025 only */ +#define TI_MUX1_3025T_565 0x4D /* 3025 only */ +#define TI_MUX1_3025T_555 0x4C /* 3025 only */ +#define TI_MUX1_3026D_888 0x06 /* 3026 only */ +#define TI_MUX1_3026D_565 0x05 /* 3026 only */ +#define TI_MUX1_3026D_555 0x04 /* 3026 only */ +#define TI_MUX1_3026D_888_P8 0x16 /* 3026 only */ +#define TI_MUX1_3026D_888_P5 0x1e /* 3026 only */ +#define TI_MUX1_3026T_888 0x46 /* 3026 only */ +#define TI_MUX1_3026T_565 0x45 /* 3026 only */ +#define TI_MUX1_3026T_555 0x44 /* 3026 only */ +#define TI_MUX1_3026T_888_P8 0x56 /* 3026 only */ +#define TI_MUX1_3026T_888_P5 0x5e /* 3026 only */ +#define TI_MUX_CONTROL_2 0x19 +#define TI_MUX2_BUS_VGA 0x98 +#define TI_MUX2_BUS_PC_D8P64 0x1C +#define TI_MUX2_BUS_DC_D24P64 0x1C +#define TI_MUX2_BUS_DC_D16P64 0x04 +#define TI_MUX2_BUS_DC_D15P64 0x04 +#define TI_MUX2_BUS_TC_D24P64 0x04 +#define TI_MUX2_BUS_TC_D16P64 0x04 +#define TI_MUX2_BUS_TC_D15P64 0x04 +#define TI_MUX2_BUS_3026PC_D8P64 0x4C +#define TI_MUX2_BUS_3026DC_D24P64 0x5C +#define TI_MUX2_BUS_3026DC_D16P64 0x54 +#define TI_MUX2_BUS_3026DC_D15P64 0x54 +#define TI_MUX2_BUS_3026TC_D24P64 0x5c +#define TI_MUX2_BUS_3026TC_D16P64 0x54 +#define TI_MUX2_BUS_3026TC_D15P64 0x54 +#define TI_MUX2_BUS_3030PC_D8P128 0x4d +#define TI_MUX2_BUS_3030DC_D24P128 0x5d +#define TI_MUX2_BUS_3030DC_D16P128 0x55 +#define TI_MUX2_BUS_3030DC_D15P128 0x55 +#define TI_MUX2_BUS_3030TC_D24P128 0x5d +#define TI_MUX2_BUS_3030TC_D16P128 0x55 +#define TI_MUX2_BUS_3030TC_D15P128 0x55 +#define TI_INPUT_CLOCK_SELECT 0x1A +#define TI_ICLK_CLK0 0x00 +#define TI_ICLK_CLK0_DOUBLE 0x10 +#define TI_ICLK_CLK1 0x01 +#define TI_ICLK_CLK1_DOUBLE 0x11 +#define TI_ICLK_CLK2 0x02 /* 3025 only */ +#define TI_ICLK_CLK2_DOUBLE 0x12 /* 3025 only */ +#define TI_ICLK_CLK2_I 0x03 /* 3025 only */ +#define TI_ICLK_CLK2_I_DOUBLE 0x13 /* 3025 only */ +#define TI_ICLK_CLK2_E 0x04 /* 3025 only */ +#define TI_ICLK_CLK2_E_DOUBLE 0x14 /* 3025 only */ +#define TI_ICLK_PLL 0x05 /* 3025 only */ +#define TI_OUTPUT_CLOCK_SELECT 0x1B +#define TI_OCLK_VGA 0x3E +#define TI_OCLK_S 0x40 +#define TI_OCLK_NS 0x80 /* 3025 only */ +#define TI_OCLK_V1 0x00 +#define TI_OCLK_V2 0x08 +#define TI_OCLK_V4 0x10 +#define TI_OCLK_V8 0x18 +#define TI_OCLK_R1 0x00 +#define TI_OCLK_R2 0x01 +#define TI_OCLK_R4 0x02 +#define TI_OCLK_R8 0x03 +#define TI_OCLK_S_V1_R8 (TI_OCLK_S | TI_OCLK_V1 | TI_OCLK_R8) +#define TI_OCLK_S_V2_R8 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R8) +#define TI_OCLK_S_V4_R8 (TI_OCLK_S | TI_OCLK_V4 | TI_OCLK_R8) +#define TI_OCLK_S_V8_R8 (TI_OCLK_S | TI_OCLK_V8 | TI_OCLK_R8) +#define TI_OCLK_S_V2_R4 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R4) +#define TI_OCLK_S_V4_R4 (TI_OCLK_S | TI_OCLK_V4 | TI_OCLK_R4) +#define TI_OCLK_S_V1_R2 (TI_OCLK_S | TI_OCLK_V1 | TI_OCLK_R2) +#define TI_OCLK_S_V2_R2 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R2) +#define TI_OCLK_NS_V1_R1 (TI_OCLK_NS | TI_OCLK_V1 | TI_OCLK_R1) +#define TI_OCLK_NS_V2_R2 (TI_OCLK_NS | TI_OCLK_V2 | TI_OCLK_R2) +#define TI_OCLK_NS_V4_R4 (TI_OCLK_NS | TI_OCLK_V4 | TI_OCLK_R4) +#define TI_PALETTE_PAGE 0x1C +#define TI_GENERAL_CONTROL 0x1D +#define TI_MISC_CONTROL 0x1E /* 3025 only */ +#define TI_MC_POWER_DOWN 0x01 +#define TI_MC_DOTCLK_DISABLE 0x02 +#define TI_MC_INT_6_8_CONTROL 0x04 /* 00 == external 6/8 pin */ +#define TI_MC_8_BPP 0x08 /* 00 == 6bpp */ +#define TI_MC_PSEL_POLARITY 0x20 /* 3026 only, PSEL polarity select */ +#define TI_MC_VCLK_POLARITY 0x20 +#define TI_MC_LCLK_LATCH 0x40 /* VCLK == 00, default */ +#define TI_MC_LOOP_PLL_RCLK 0x80 +#define TI_OVERSCAN_COLOR_RED 0x20 +#define TI_OVERSCAN_COLOR_GREEN 0x21 +#define TI_OVERSCAN_COLOR_BLUE 0x22 +#define TI_CURSOR_COLOR_0_RED 0x23 +#define TI_CURSOR_COLOR_0_GREEN 0x24 +#define TI_CURSOR_COLOR_0_BLUE 0x25 +#define TI_CURSOR_COLOR_1_RED 0x26 +#define TI_CURSOR_COLOR_1_GREEN 0x27 +#define TI_CURSOR_COLOR_1_BLUE 0x28 +#define TI_AUXILIARY_CONTROL 0x29 +#define TI_AUX_SELF_CLOCK 0x08 +#define TI_AUX_W_CMPL 0x01 +#define TI_GENERAL_IO_CONTROL 0x2A +#define TI_GIC_ALL_BITS 0x1F +#define TI_GENERAL_IO_DATA 0x2B +#define TI_GID_W2000_6BIT 0x00 +#define TI_GID_N9_964 0x01 +#define TI_GID_ELSA_SOG 0x04 +#define TI_GID_W2000_8BIT 0x08 +#define TI_GID_S3_DAC_6BIT 0x1C +#define TI_GID_S3_DAC_8BIT 0x1E +#define TI_GID_TI_DAC_6BIT 0x1D +#define TI_GID_TI_DAC_8BIT 0x1F +#define TI_PLL_CONTROL 0x2C /* 3025 only */ +#define TI_PIXEL_CLOCK_PLL_DATA 0x2D /* 3025 only */ +#define TI_PLL_ENABLE 0x08 /* 3025 only */ +#define TI_MCLK_PLL_DATA 0x2E /* 3025 only */ +#define TI_LOOP_CLOCK_PLL_DATA 0x2F /* 3025 only */ +#define TI_COLOR_KEY_OLVGA_LOW 0x30 +#define TI_COLOR_KEY_OLVGA_HIGH 0x31 +#define TI_COLOR_KEY_RED_LOW 0x32 +#define TI_COLOR_KEY_RED_HIGH 0x33 +#define TI_COLOR_KEY_GREEN_LOW 0x34 +#define TI_COLOR_KEY_GREEN_HIGH 0x35 +#define TI_COLOR_KEY_BLUE_LOW 0x36 +#define TI_COLOR_KEY_BLUE_HIGH 0x37 +#define TI_COLOR_KEY_CONTROL 0x38 +#define TI_COLOR_KEY_CMPL 0x10 +#define TI_MCLK_DCLK_CONTROL 0x39 /* 3025 only */ +#define TI_MCLK_LCLK_CONTROL 0x39 /* 3026 only */ +#define TI_SENSE_TEST 0x3A +#define TI_TEST_DATA 0x3B +#define TI_CRC_LOW 0x3C +#define TI_CRC_HIGH 0x3D +#define TI_CRC_CONTROL 0x3E +#define TI_ID 0x3F +#define TI_VIEWPOINT20_ID 0x20 +#define TI_VIEWPOINT25_ID 0x25 +#define TI_MODE_85_CONTROL 0xD5 /* 3025 only */ + +#define TI_REF_FREQ 14.31818 /* 3025 only */ + +/* + * which clocks should be set (just flags...) + */ +#define TI_BOTH_CLOCKS 1 +#define TI_LOOP_CLOCK 2 Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp:1.2 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp Mon Dec 11 15:18:14 2000 @@ -0,0 +1,70 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.cpp,v 1.2 2000/12/11 20:18:14 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH I128 __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +i128 \- Number 9 I128 video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qi128\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B i128 +is an XFree86 driver for Number 9 I128 video cards. The driver is +accelerated and provides support for all versions of the I128 chip family, +including the SGI flatpanel configuration. Multi-head configurations are +supported. +.SH SUPPORTED HARDWARE +The +.B i128 +driver supports PCI and AGP video cards based on the following I128 chips: +.TP 12 +.B I128 rev 1 +(original) +.TP 12 +.B I128-II +.TP 12 +.B I128-T2R +Ticket 2 Ride +.TP 12 +.B I128-T2R4 +Ticket 2 Ride IV +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The driver auto-detects the chipset type and may not be overridden. +.PP +The driver auto-detects the amount of video memory present for all +chips and may not be overridden. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qHWCursor\*q \*q" boolean \*q +Enable or disable the HW cursor. Default: on. +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Disable or enable acceleration. Default: acceleration is enabled. +.TP +.BI "Option \*qSyncOnGreen\*q \*q" boolean \*q +Enable or disable combining the sync signals with the green signal. +Default: off. +.TP +.BI "Option \*qDac6Bit\*q \*q" boolean \*q +Reduce DAC operations to 6 bits. +Default: false. +.TP +.BI "Option \*qDebug\*q \*q" boolean \*q +This turns on verbose debug information from the driver. +Default: off. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +Authors include: Robin Cutshaw (driver), Galen Brooks (flatpanel support). Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h:1.4 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h Sun Dec 10 20:53:00 2000 @@ -0,0 +1,140 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.h,v 1.4 2000/12/11 01:53:00 robin Exp $ */ +/* + * Number Nine I128 functions + * + * Copyright 1996 The XFree86 Project, Inc. + * + * Author + * Robin Cutshaw + * robin@XFree86.Org + */ + +#ifndef I128_H +#define I128_H + +#include "compiler.h" +#include "xaa.h" +#include "xf86Cursor.h" +#include "vgaHW.h" +#include "colormapst.h" +#include "xf86DDC.h" +#include "i128reg.h" + +/* Card-specific driver information */ + +#define I128PTR(p) ((I128Ptr)((p)->driverPrivate)) + +typedef struct { + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + xf86AccessRec Access; + int Chipset; + int ChipRev; + Bool Primary; + + /* Ramdac specific */ + int RamdacType; + Bool DAC8Bit; + Bool DACSyncOnGreen; + int hotX; + int hotY; + Bool HWCursor; + Bool BlockCursor; + Bool ReloadCursor; + Bool CursorNeedsInit; + int CursorStartX; + int CursorStartY; + int CursorLines; + int AdjustCursorXPos; + int CursGeneration; + + /* layout specific */ + int bitsPerPixel; + int depth; + rgb weight; + int displayWidth; + int displayOffset; + DisplayModePtr mode; + + /* accel specific */ + CARD32 blitdir; + CARD32 cmd; + CARD32 rop; + CARD32 clptl; + CARD32 clpbr; + + Bool NoAccel; + Bool FlatPanel; + Bool DoubleScan; + Bool ShowCache; + Bool ModeSwitched; + Bool Debug; + unsigned char *MemoryPtr; + int MemorySize; + int MemoryType; + volatile struct i128mem mem; + struct i128io io; + I128RegRec RegRec; + Bool StateSaved; + Bool Initialized; + Bool FontsSaved; + Bool LUTSaved; + Bool InitCursorFlag; + LUTENTRY lutorig[256]; + LUTENTRY lutcur[256]; + int HDisplay; + int maxClock; + int minClock; + + CloseScreenProcPtr CloseScreen; + XAAInfoRecPtr AccelInfoRec; + xf86CursorInfoPtr CursorInfoRec; + I2CBusPtr I2C; + Bool DGAactive; + int DGAViewportStatus; + int numDGAModes; + DGAModePtr DGAModes; + Bool (*ProgramDAC)(ScrnInfoPtr, DisplayModePtr); + unsigned int (*ddc1Read)(ScrnInfoPtr); + Bool (*i2cInit)(ScrnInfoPtr); + +} I128Rec, *I128Ptr; + + +/* Prototypes */ + +void I128AdjustFrame(int scrnIndex, int x, int y, int flags); +Bool I128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); + +Bool I128HWCursorInit(ScreenPtr pScreen); + +Bool I128AccelInit(ScreenPtr pScreen); +void I128EngineDone(ScrnInfoPtr pScrn); + +Bool I128Init(ScrnInfoPtr pScrn, DisplayModePtr mode); + +Bool I128DGAInit(ScreenPtr pScreen); + +void I128LoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indices, LOCO *colors, VisualPtr pVisual); + +void I128SaveState(ScrnInfoPtr pScrn); +void I128RestoreState(ScrnInfoPtr pScrn); +void I128InitLUT(I128Ptr pI128); + +Bool I128RestoreCursor(ScrnInfoPtr pScrn); +Bool I128RepositionCursor(ScrnInfoPtr pScrn); + +Bool I128IBMHWCursorInit(ScrnInfoPtr pScrn); +Bool I128TIHWCursorInit(ScrnInfoPtr pScrn); + +Bool I128ProgramTi3025(ScrnInfoPtr pScrn, DisplayModePtr mode); +Bool I128ProgramIBMRGB(ScrnInfoPtr pScrn, DisplayModePtr mode); +Bool I128ProgramSilverHammer(ScrnInfoPtr pScrn, DisplayModePtr mode); + +void I128DumpBaseRegisters(ScrnInfoPtr pScrn); +void I128DumpActiveRegisters(ScrnInfoPtr pScrn); +void I128DumpIBMDACRegisters(ScrnInfoPtr pScrn, volatile unsigned long *vrbg); + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c:1.2 --- /dev/null Mon Dec 18 14:30:41 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c Wed Oct 25 18:53:33 2000 @@ -0,0 +1,736 @@ +/* + * Copyright 1996-2000 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ROBIN CUTSHAW BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128IBMDAC.c,v 1.2 2000/10/25 22:53:33 robin Exp $ */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "cursorstr.h" +#include "servermd.h" + +#include "i128.h" +#include "i128reg.h" +#include "IBMRGB.h" + + +void I128IBMShowCursor(ScrnInfoPtr pScrn); +void I128IBMHideCursor(ScrnInfoPtr pScrn); +void I128IBMSetCursorPosition(ScrnInfoPtr pScrn, int x, int y); +void I128IBMSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); +void I128IBMLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); +unsigned char *I128IBMRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs); +static Bool I128IBMUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs); + + +Bool +I128IBMHWCursorInit(ScrnInfoPtr pScrn) +{ + xf86CursorInfoPtr infoPtr; + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + I128Ptr pI128 = I128PTR(pScrn); + + if (!pI128->HWCursor) + return FALSE; + + infoPtr = xf86CreateCursorInfoRec(); + if (!infoPtr) return FALSE; + + pI128->CursorInfoRec = infoPtr; + infoPtr->MaxWidth = 64; + infoPtr->MaxHeight = 64; + infoPtr->SetCursorColors = I128IBMSetCursorColors; + infoPtr->SetCursorPosition = I128IBMSetCursorPosition; + infoPtr->LoadCursorImage = I128IBMLoadCursorImage; + infoPtr->HideCursor = I128IBMHideCursor; + infoPtr->ShowCursor = I128IBMShowCursor; + infoPtr->UseHWCursor = I128IBMUseHWCursor; + infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1; + infoPtr->RealizeCursor = I128IBMRealizeCursor; + + return(xf86InitCursor(pScreen, infoPtr)); +} + + +/* + * Convert the cursor from server-format to hardware-format. The IBMRGB + * has two planes, plane 0 selects cursor color 0 or 1 and plane 1 + * selects transparent or display cursor. The bits of these planes + * are packed together so that one byte has 4 pixels. The organization + * looks like: + * Byte 0x000 - 0x00F top scan line, left to right + * 0x010 - 0x01F + * . . + * 0x3F0 - 0x3FF bottom scan line + * + * Byte/bit map - D7D6,D5D4,D3D2,D1D0 four pixels, two planes each + * Pixel/bit map - P1P0 (plane 1) == 1 maps to cursor color + * (plane 1) == 0 maps to transparent + * (plane 0) maps to cursor colors 0 and 1 + */ + +unsigned char * +I128IBMRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + register int i, j; + unsigned char *pServMsk; + unsigned char *pServSrc; + int wsrc, h; + unsigned char *mem, *dst; + + mem = (unsigned char *)xcalloc(1,1024); /* 64x64x2 bits */ + dst = mem; + + if (!mem) + return NULL; + + pServSrc = (unsigned char *)pCurs->bits->source; + pServMsk = (unsigned char *)pCurs->bits->mask; + + h = pCurs->bits->height; + if (h > infoPtr->MaxHeight) + h = infoPtr->MaxHeight; + + wsrc = PixmapBytePad(pCurs->bits->width, 1); /* bytes per line */ + + for (i = 0; i < infoPtr->MaxHeight; i++,mem+=16) { + for (j = 0; j < infoPtr->MaxWidth / 8; j++) { + register unsigned char mask, source; + + if (i < h && j < wsrc) { + /* + * mask byte ABCDEFGH and source byte 12345678 map to two byte + * cursor data H8G7F6E5 D4C3B2A1 + */ + mask = *pServMsk++; + source = *pServSrc++ & mask; + + /* map 1 byte source and mask into two byte cursor data */ + mem[j*2] = ((mask&0x01) << 7) | ((source&0x01) << 6) | + ((mask&0x02) << 4) | ((source&0x02) << 3) | + ((mask&0x04) << 1) | (source&0x04) | + ((mask&0x08) >> 2) | ((source&0x08) >> 3) ; + mem[(j*2)+1] = ((mask&0x10) << 3) | ((source&0x10) << 2) | + (mask&0x20) | ((source&0x20) >> 1) | + ((mask&0x40) >> 3) | ((source&0x40) >> 4) | + ((mask&0x80) >> 6) | ((source&0x80) >> 7) ; + } else { + mem[j*2] = 0x00; + mem[(j*2)+1] = 0x00; + } + } + /* + * if we still have more bytes on this line (j < wsrc), + * we have to ignore the rest of the line. + */ + while (j++ < wsrc) pServMsk++,pServSrc++; + } + return dst; +} + + +void +I128IBMShowCursor(ScrnInfoPtr pScrn) +{ + CARD32 tmpl, tmph; + I128Ptr pI128 = I128PTR(pScrn); + + /* Enable cursor - X11 mode */ + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + pI128->mem.rbase_g[IDXCTL_I] = 0; MB; + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs; MB; + pI128->mem.rbase_g[DATA_I] = 0x27; MB; + + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + return; +} + +void +I128IBMHideCursor(ScrnInfoPtr pScrn) +{ + CARD32 tmpl, tmph, tmp1; + I128Ptr pI128 = I128PTR(pScrn); + + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + pI128->mem.rbase_g[IDXCTL_I] = 0; MB; + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs; MB; + tmp1 = pI128->mem.rbase_g[DATA_I] & 0xFC; + pI128->mem.rbase_g[DATA_I] = tmp1; MB; + + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + return; +} + +void +I128IBMSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + CARD32 tmpl, tmph; + I128Ptr pI128 = I128PTR(pScrn); + + x += 64; + y += 64; + + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_hot_x; MB; + pI128->mem.rbase_g[DATA_I] = 0x3F; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_hot_y; MB; + pI128->mem.rbase_g[DATA_I] = 0x3F; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_xl; MB; + pI128->mem.rbase_g[DATA_I] = x & 0xFF; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_xh; MB; + pI128->mem.rbase_g[DATA_I] = (x >> 8) & 0x0F; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_yl; MB; + pI128->mem.rbase_g[DATA_I] = y & 0xFF; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_yh; MB; + pI128->mem.rbase_g[DATA_I] = (y >> 8) & 0x0F; MB; + + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + return; +} + +void +I128IBMSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + CARD32 tmp; + I128Ptr pI128 = I128PTR(pScrn); + + tmp = pI128->mem.rbase_g[IDXL_I] & 0xFF; + + /* Background color */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col1_r; MB; + pI128->mem.rbase_g[DATA_I] = (bg & 0x00FF0000) >> 16; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col1_g; MB; + pI128->mem.rbase_g[DATA_I] = (bg & 0x0000FF00) >> 8; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col1_b; MB; + pI128->mem.rbase_g[DATA_I] = (bg & 0x000000FF); MB; + + /* Foreground color */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col2_r; MB; + pI128->mem.rbase_g[DATA_I] = (fg & 0x00FF0000) >> 16; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col2_g; MB; + pI128->mem.rbase_g[DATA_I] = (fg & 0x0000FF00) >> 8; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_col2_b; MB; + pI128->mem.rbase_g[DATA_I] = (fg & 0x000000FF); MB; + + pI128->mem.rbase_g[IDXL_I] = tmp; MB; + + return; +} + +void +I128IBMLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + I128Ptr pI128 = I128PTR(pScrn); + register int i; + CARD32 tmph, tmpl, tmpc; + + tmpc = pI128->mem.rbase_g[IDXCTL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + + pI128->BlockCursor = TRUE; + + pI128->mem.rbase_g[IDXCTL_I] = 0; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_hot_x; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_hot_y; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_xl; MB; + pI128->mem.rbase_g[DATA_I] = 0xFF; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_xh; MB; + pI128->mem.rbase_g[DATA_I] = 0x7F; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_yl; MB; + pI128->mem.rbase_g[DATA_I] = 0xFF; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_yh; MB; + pI128->mem.rbase_g[DATA_I] = 0x7F; MB; + + pI128->mem.rbase_g[IDXH_I] = (IBMRGB_curs_array >> 8) & 0xFF; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_curs_array & 0xFF; MB; + + pI128->mem.rbase_g[IDXCTL_I] = 1; /* enable auto-inc */ MB; + + /* + * Output the cursor data. The realize function has put the planes into + * their correct order, so we can just blast this out. + */ + for (i = 0; i < 1024; i++,src++) { + pI128->mem.rbase_g[DATA_I] = (CARD32 )*src; MB; + } + + pI128->mem.rbase_g[IDXCTL_I] = tmpc; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + pI128->BlockCursor = FALSE; + + return; +} + + +static Bool +I128IBMUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) +{ + if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN ) + return FALSE; + return TRUE; +} + + +Bool I128TIHWCursorInit(ScrnInfoPtr pScrn) { return FALSE; } +Bool I128ProgramTi3025(ScrnInfoPtr pScrn, DisplayModePtr mode) { return FALSE; } + +Bool +I128ProgramIBMRGB(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + I128Ptr pI128 = I128PTR(pScrn); + unsigned char tmp2, m, n, df, best_m, best_n, best_df, max_n; + CARD32 tmpl, tmph, tmpc; + long f, vrf, outf, best_vrf, best_diff, best_outf, diff; + long requested_freq; + int freq = mode->SynthClock; + int flags = mode->Flags; + +#define REF_FREQ 25175000 +#define MAX_VREF 3380000 +/* Actually, MIN_VREF can be as low as 1000000; + * this allows clock speeds down to 17 MHz */ +#define MIN_VREF 1500000 +#define MAX_VCO 220000000 +#define MIN_VCO 65000000 + + if (freq < 25000) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too low for IBM RGB52x", + freq / 1000.0); + return(FALSE); + } else if (freq > MAX_VCO) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too high for IBM RGB52x", + freq / 1000.0); + return(FALSE); + } + + requested_freq = freq * 1000; + + best_m = best_n = best_df = 0; + best_vrf = best_outf = 0; + best_diff = requested_freq; /* worst case */ + + for (df=0; df<4; df++) { + max_n = REF_FREQ / MIN_VREF; + if (df < 3) + max_n >>= 1; + for (n=2; n<max_n; n++) + for (m=65; m<=128; m++) { + vrf = REF_FREQ / n; + if (df < 3) + vrf >>= 1; + if ((vrf > MAX_VREF) || (vrf < MIN_VREF)) + continue; + + f = vrf * m; + outf = f; + if (df < 2) + outf >>= 2 - df; + if ((f > MAX_VCO) || (f < MIN_VCO)) + continue; + + /* outf is a valid freq, pick the closest now */ + + if ((diff = (requested_freq - outf)) < 0) + diff = -diff;; + if (diff < best_diff) { + best_diff = diff; + best_m = m; + best_n = n; + best_df = df; + best_outf = outf; + } + } + } + + /* do we have an acceptably close frequency? (less than 1% diff) */ + + if (best_diff > (requested_freq/100)) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too far (best %.3f) IBM RGB52x", + requested_freq / 1000.0, best_outf / 1000.0); + return(FALSE); + } + + pI128->mem.rbase_g[PEL_MASK] = 0xFF; MB; + + tmpc = pI128->mem.rbase_g[IDXCTL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXCTL_I] = 0; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc_clock; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x81; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0+4; MB; + pI128->mem.rbase_g[DATA_I] = (best_df<<6) | (best_m&0x3f); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_n0+4; MB; + pI128->mem.rbase_g[DATA_I] = best_n; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pll_ctrl1; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = (tmp2&0xf8) | 3; /* 8 M/N pairs in PLL */ MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pll_ctrl2; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = (tmp2&0xf0) | 2; /* clock number 2 */ MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc_clock; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf0; + pI128->mem.rbase_g[DATA_I] = tmp2 | ((flags & V_DBLCLK) ? 0x03 : 0x01); MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sync; MB; + pI128->mem.rbase_g[DATA_I] = ((flags & V_PHSYNC) ? 0x10 : 0x00) + | ((flags & V_PVSYNC) ? 0x20 : 0x00); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_hsync_pos; MB; + pI128->mem.rbase_g[DATA_I] = 0x01; /* Delay syncs by 1 pclock */ MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pwr_mgmt; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_dac_op; MB; + tmp2 = (pI128->RamdacType == IBM528_DAC) ? 0x02 : 0x00; /* fast slew */ + if (pI128->DACSyncOnGreen) tmp2 |= 0x08; + pI128->mem.rbase_g[DATA_I] = tmp2; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pal_ctrl; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk; MB; + pI128->mem.rbase_g[DATA_I] = 0x01; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc1; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xbc; + tmp2 |= 0x20; + if ((pI128->MemoryType != I128_MEMORY_DRAM) && + (pI128->MemoryType != I128_MEMORY_SGRAM)) + tmp2 |= (pI128->RamdacType == IBM528_DAC) ? 3 : 1; + pI128->mem.rbase_g[DATA_I] = tmp2; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc2; MB; + tmp2 = 0x03; + if (pI128->DAC8Bit) + tmp2 |= 0x04; + if (!((pI128->MemoryType == I128_MEMORY_DRAM) && + (pI128->bitsPerPixel > 16))) + tmp2 |= 0x40; + if ((pI128->MemoryType == I128_MEMORY_SGRAM) && + (pI128->bitsPerPixel > 16) && + (pI128->RamdacType != SILVER_HAMMER_DAC) ) + tmp2 &= 0x3F; + pI128->mem.rbase_g[DATA_I] = tmp2; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc3; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc4; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + + /* ?? There is no write to cursor control register */ + + if (pI128->RamdacType == IBM526_DAC) { + if (pI128->MemoryType == I128_MEMORY_SGRAM) { + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x09; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x83; MB; + } else { + /* program mclock to 52MHz */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x08; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x41; MB; + } + /* should delay at least a millisec so we'll wait 50 */ + usleep(50000); + } + + switch (pI128->depth) { + case 24: /* 32 bit */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x06; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_32bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0x03; MB; + break; + case 16: + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x04; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_16bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0xC7; MB; + break; + case 15: + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x04; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_16bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0xC5; MB; + break; + default: /* 8 bit */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x03; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_8bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + break; + } + + pI128->mem.rbase_g[IDXCTL_I] = tmpc; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + return(TRUE); +} + + +Bool +I128ProgramSilverHammer(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + /* The SilverHammer DAC is essentially the same as the IBMRGBxxx DACs, + * but with fewer options and a different reference frequency. + */ + + I128Ptr pI128 = I128PTR(pScrn); + unsigned char tmp2, m, n, df, best_m, best_n, best_df, max_n; + CARD32 tmpl, tmph, tmpc; + long f, vrf, outf, best_vrf, best_diff, best_outf, diff; + long requested_freq; + int freq = mode->SynthClock; + int flags = mode->Flags; + int skew = mode->HSkew; + +#undef REF_FREQ +#define REF_FREQ 37500000 +#undef MAX_VREF +#define MAX_VREF 9000000 +#define MIN_VREF 1500000 +#undef MAX_VCO +#define MAX_VCO 270000000 +#define MIN_VCO 65000000 + + if (freq < 25000) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too low for SilverHammer", + freq / 1000.0); + return(FALSE); + } else if (freq > MAX_VCO) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too high for SilverHammer", + freq / 1000.0); + return(FALSE); + } + + requested_freq = freq * 1000; + + best_m = best_n = best_df = 0; + best_vrf = best_outf = 0; + best_diff = requested_freq; /* worst case */ + + for (df=0; df<4; df++) { + max_n = REF_FREQ / MIN_VREF; + if (df < 3) + max_n >>= 1; + for (n=2; n<max_n; n++) + for (m=65; m<=128; m++) { + vrf = REF_FREQ / n; + if (df < 3) + vrf >>= 1; + if ((vrf > MAX_VREF) || (vrf < MIN_VREF)) + continue; + + f = vrf * m; + outf = f; + if (df < 2) + outf >>= 2 - df; + if ((f > MAX_VCO) || (f < MIN_VCO)) + continue; + + /* outf is a valid freq, pick the closest now */ + + if ((diff = (requested_freq - outf)) < 0) + diff = -diff;; + if (diff < best_diff) { + best_diff = diff; + best_m = m; + best_n = n; + best_df = df; + best_outf = outf; + } + } + } + + /* do we have an acceptably close frequency? (less than 1% diff) */ + + if (best_diff > (requested_freq/100)) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Specified dot clock (%.3f) too far (best %.3f) SilverHammer", + requested_freq / 1000.0, best_outf / 1000.0); + return(FALSE); + } + + pI128->mem.rbase_g[PEL_MASK] = 0xFF; MB; + + tmpc = pI128->mem.rbase_g[IDXCTL_I] & 0xFF; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXCTL_I] = 0; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc_clock; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x81; MB; + + if (!pI128->Primary) { + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0; MB; + pI128->mem.rbase_g[DATA_I] = 0x15; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0+1; MB; + pI128->mem.rbase_g[DATA_I] = 0x10; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0+2; MB; + pI128->mem.rbase_g[DATA_I] = 0x2c; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0+3; MB; + pI128->mem.rbase_g[DATA_I] = 0x12; MB; + } + pI128->mem.rbase_g[IDXL_I] = IBMRGB_m0+4; MB; + pI128->mem.rbase_g[DATA_I] = (best_df<<6) | (best_m&0x3f); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_n0+4; MB; + pI128->mem.rbase_g[DATA_I] = best_n; MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pll_ctrl1; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = (tmp2&0xf8) | 3; /* 8 M/N pairs in PLL */ MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pll_ctrl2; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xFF; + pI128->mem.rbase_g[DATA_I] = (tmp2&0xf0) | 2; /* clock number 2 */ MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc_clock; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf0; + pI128->mem.rbase_g[DATA_I] = tmp2 | ((flags & V_DBLCLK) ? 0x03 : 0x01); MB; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sync; MB; + pI128->mem.rbase_g[DATA_I] = ((flags & V_PHSYNC) ? 0x10 : 0x00) + | ((flags & V_PVSYNC) ? 0x20 : 0x00); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_hsync_pos; MB; + pI128->mem.rbase_g[DATA_I] = ((flags & V_HSKEW) ? skew : 0x01); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pwr_mgmt; MB; +/* Use 0x01 below with digital flat panel to conserve energy and reduce noise */ + pI128->mem.rbase_g[DATA_I] = (pI128->FlatPanel ? 0x01 : 0x00); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_dac_op; MB; + pI128->mem.rbase_g[DATA_I] = (pI128->DACSyncOnGreen ? 0x08 : 0x00); MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pal_ctrl; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk; MB; + pI128->mem.rbase_g[DATA_I] = 0x01; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc1; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xbc; + if ((pI128->MemoryType != I128_MEMORY_DRAM) && + (pI128->MemoryType != I128_MEMORY_SGRAM)) + tmp2 |= (pI128->RamdacType == IBM528_DAC) ? 3 : 1; + pI128->mem.rbase_g[DATA_I] = tmp2; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc2; MB; + tmp2 = 0x03; + if (pI128->DAC8Bit) + tmp2 |= 0x04; + if (!((pI128->MemoryType == I128_MEMORY_DRAM) && + (pI128->bitsPerPixel > 16))) + tmp2 |= 0x40; + if ((pI128->MemoryType == I128_MEMORY_SGRAM) && + (pI128->bitsPerPixel > 16) && + (pI128->RamdacType != SILVER_HAMMER_DAC) ) + tmp2 &= 0x3F; + pI128->mem.rbase_g[DATA_I] = tmp2; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc3; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_misc4; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + + /* ?? There is no write to cursor control register */ + + /* Set the memory clock speed to 95 MHz */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x08; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + pI128->mem.rbase_g[DATA_I] = 0x50; MB; + + /* should delay at least a millisec so we'll wait 50 */ + usleep(50000); + + switch (pI128->depth) { + case 24: /* 32 bit */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x06; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_32bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0x03; MB; + break; + case 16: + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x04; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_16bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0xC7; MB; + break; + case 15: + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x04; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_16bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0xC5; MB; + break; + default: /* 8 bit */ + pI128->mem.rbase_g[IDXL_I] = IBMRGB_pix_fmt; MB; + tmp2 = pI128->mem.rbase_g[DATA_I] & 0xf8; + pI128->mem.rbase_g[DATA_I] = tmp2 | 0x03; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_8bpp; MB; + pI128->mem.rbase_g[DATA_I] = 0x00; MB; + break; + } + + pI128->mem.rbase_g[IDXCTL_I] = tmpc; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + + return(TRUE); +} + + Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c:1.17 --- /dev/null Mon Dec 18 14:30:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c Sun Dec 10 20:53:01 2000 @@ -0,0 +1,2390 @@ +/* + * Copyright 1995-2000 by Robin Cutshaw <robin@XFree86.Org> + * Copyright 1998 by Number Nine Visual Technology, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw and Number Nine make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ROBIN CUTSHAW AND NUMBER NINE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL ROBIN CUTSHAW OR NUMBER NINE BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128_driver.c,v 1.17 2000/12/11 01:53:01 robin Exp $ */ + + +/* All drivers should typically include these */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" + +/* All drivers need this */ +#include "xf86_ansic.h" + +#include "compiler.h" + +/* Drivers for PCI hardware need this */ +#include "xf86PciInfo.h" + +/* Drivers that need to access the PCI config space directly need this */ +#include "xf86Pci.h" + +/* vgaHW module is only used to save/restore fonts by this driver */ +#include "vgaHW.h" + +/* All drivers initialising the SW cursor need this */ +#include "mipointer.h" + +/* All drivers implementing backing store need this */ +#include "mibstore.h" +#include "micmap.h" + +#include "xf86DDC.h" +#include "xf86RAC.h" +#include "vbe.h" + +#include "xaa.h" +#include "xf86cmap.h" +#include "fb.h" + +#include "xf86xv.h" +#include "Xv.h" + +/* driver specific includes */ +#include "i128.h" +#include "i128reg.h" + +/* + * Forward definitions for the functions that make up the driver. + */ + +/* Mandatory functions */ +static OptionInfoPtr I128AvailableOptions(int chipid, int busid); +static void I128Identify(int flags); +static Bool I128Probe(DriverPtr drv, int flags); +static Bool I128PreInit(ScrnInfoPtr pScrn, int flags); +static Bool I128ScreenInit(int Index, ScreenPtr pScreen, int argc, + char **argv); +static Bool I128EnterVT(int scrnIndex, int flags); +static void I128LeaveVT(int scrnIndex, int flags); +static Bool I128CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool I128SaveScreen(ScreenPtr pScreen, int mode); + +/* Optional functions */ +static void I128FreeScreen(int scrnIndex, int flags); +static int I128ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, + int flags); +#ifdef DPMSExtension +static void I128DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, + int flags); +#endif + +/* Internally used functions */ +static Bool I128GetRec(ScrnInfoPtr pScrn); +static void I128FreeRec(ScrnInfoPtr pScrn); +static Bool I128MapMem(ScrnInfoPtr pScrn); +static Bool I128UnmapMem(ScrnInfoPtr pScrn); +static void I128Save(ScrnInfoPtr pScrn); +static void I128Restore(ScrnInfoPtr pScrn); +static Bool I128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static int I128CountRam(ScrnInfoPtr pScrn); +static void I128SoftReset(ScrnInfoPtr pScrn); +static Bool I128I2CInit(ScrnInfoPtr pScrn); +static xf86MonPtr I128getDDC(ScrnInfoPtr pScrn); +#if 0 +static unsigned int I128DDC1Read(ScrnInfoPtr pScrn); +#endif + +#define I128_VERSION 4000 +#define I128_NAME "I128" +#define I128_DRIVER_NAME "i128" +#define I128_MAJOR_VERSION 1 +#define I128_MINOR_VERSION 0 +#define I128_PATCHLEVEL 0 + +/* + * This contains the functions needed by the server after loading the + * driver module. It must be supplied, and gets added the driver list by + * the Module Setup funtion in the dynamic case. In the static case a + * reference to this is compiled in, and this requires that the name of + * this DriverRec be an upper-case version of the driver name. + */ + +DriverRec I128 = { + I128_VERSION, + I128_DRIVER_NAME, + I128Identify, + I128Probe, + I128AvailableOptions, + NULL, + 0 +}; + +#ifdef XFree86LOADER + +static MODULESETUPPROTO(i128Setup); + +static XF86ModuleVersionInfo i128VersRec = +{ + "i128", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + I128_MAJOR_VERSION, I128_MINOR_VERSION, I128_PATCHLEVEL, + ABI_CLASS_VIDEODRV, /* This is a video driver */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} +}; + +/* + * XF86ModuleData structure is the first part of the driver that is used + * by the module loader. It provides the XF86ModuleVersionInfo structure + * used to verify that the module version is compatable with the loader + * version. It also provides a pointer to the module specific + * ModuleSetupProc() and ModuleTearDownProc() functions. + */ + +XF86ModuleData i128ModuleData = { &i128VersRec, i128Setup, NULL }; + +#endif + + +/* + * List of symbols from other modules that this module references. This + * list is used to tell the loader that it is OK for symbols here to be + * unresolved providing that it hasn't been told that they haven't been + * told that they are essential via a call to xf86LoaderReqSymbols() or + * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about + * unresolved symbols that are not required. These are provided to the + * LoaderRefSymLists() function in the module specific Setup() function. + */ + +static const char *vgahwSymbols[] = { + "vgaHWFreeHWRec", + "vgaHWGetHWRec", + "vgaHWGetIOBase", + "vgaHWLock", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWSave", + "vgaHWUnlock", + NULL +}; + +static const char *fbSymbols[] = { + "fbScreenInit", +#ifdef RENDER + "fbPictureInit", +#endif + NULL +}; + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAStippleScanlineFuncLSBFirst", + "XAAOverlayFBfuncs", + "XAACachePlanarMonoStipple", + "XAAScreenIndex", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +static const char *i2cSymbols[] = { + "xf86CreateI2CBusRec", + "xf86I2CBusInit", + NULL +}; + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + NULL +}; + +static const char *int10Symbols[] = { + "xf86InitInt10", + "xf86FreeInt10", + NULL +}; + + +#ifdef XFree86LOADER + +/* Mandatory + * + * The Setup() function is the first entry point called once that the + * module has been linked into the server. It adds this driver to + * the driver list and lets the server know which symbols it might use. + * This is only called once, not called with each server generation. + * + * Arguments: + * pointer module - module being loaded, passed to xf86AddDriver() + * pointer opts - unused but contains options from config file + * int *errmaj - if function error returns major error value + * int *errmin - if function error returns minor error value + * Returns: + * pointer to TearDownData which is passed to TearDownProc() + * or NULL for failure. + */ + +static pointer +i128Setup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + /* This module should be loaded only once, but check to be sure. */ + + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&I128, module, 0); + + /* + * Modules that this driver always requires may be loaded here + * by calling LoadSubModule(). + */ + + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(fbSymbols, + xaaSymbols, + ramdacSymbols, + ddcSymbols, + ddcSymbols, + i2cSymbols, + vbeSymbols, + int10Symbols, + vgahwSymbols, + NULL); + + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer)1; + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + + +/* Define supported chipsets. Used by Probe(). */ + +static SymTabRec I128Chipsets[] = { + { PCI_CHIP_I128, "i128" }, + { PCI_CHIP_I128_2, "i128v2" }, + { PCI_CHIP_I128_T2R, "i128t2r" }, + { PCI_CHIP_I128_T2R4, "i128t2r4" }, + {-1, NULL } +}; + +static PciChipsets I128PciChipsets[] = { + { PCI_CHIP_I128, PCI_CHIP_I128, NULL }, + { PCI_CHIP_I128_2, PCI_CHIP_I128_2, NULL }, + { PCI_CHIP_I128_T2R, PCI_CHIP_I128_T2R, NULL }, + { PCI_CHIP_I128_T2R4, PCI_CHIP_I128_T2R4, NULL }, + { -1, -1, RES_UNDEFINED } +}; + +/* Mandatory + * + * The Probe() function is the second entry point called once that the + * module has been linked into the server. This function finds all + * instances of hardware that it supports and allocates a ScrnInfoRec + * using xf86ConfigPciEntity() for each unclaimed slot. This should be + * a minimal probe and under no circumstances should it leave the hardware + * state changed. No initialisations other than the required ScrnInfoRec + * should be done and no data structures should be allocated. + * + * Arguments: + * DriverPtr drv - pointer to the driver structure + * int flags - PROBE_DEFAULT for normal function + * PROBE_DETECT for use with "-config" and "-probe" + * Returns: + * Bool TRUE if a screen was allocated, FALSE otherwise + */ + +static Bool +I128Probe(DriverPtr drv, int flags) +{ + int i; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool foundScreen = FALSE; + + /* + * Check if there has been a chipset override in the config file. + * For this we must find out if there is an active device section which + * is relevant, i.e., which has no driver specified or has THIS driver + * specified. + */ + + if ((numDevSections = xf86MatchDevice(I128_DRIVER_NAME, + &devSections)) <= 0) { + /* + * There's no matching device section in the config file, so quit + * now. + */ + return FALSE; + } + + /* + * We need to probe the hardware first. We then need to see how this + * fits in with what is given in the config file, and allow the config + * file info to override any contradictions. + */ + + /* + * All of the cards this driver supports are PCI, so the "probing" just + * amounts to checking the PCI data that the server has already collected. + */ + if (xf86GetPciVideoInfo() == NULL) { + /* + * We won't let anything in the config file override finding no + * PCI video cards at all. This seems reasonable now, but we'll see. + */ + return FALSE; + } + + numUsed = xf86MatchPciInstances(I128_NAME, PCI_VENDOR_NUMNINE, + I128Chipsets, I128PciChipsets, devSections, + numDevSections, drv, &usedChips); + + /* Free it since we don't need that list after this */ + xfree(devSections); + + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) { + xfree(usedChips); + return FALSE; + } + + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + + /* Allocate a ScrnInfoRec and claim the slot */ + if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i], + I128PciChipsets, NULL, NULL, + NULL, NULL, NULL)) == NULL) + continue; + + + /* Fill in what we can of the ScrnInfoRec */ + pScrn->driverVersion = I128_VERSION; + pScrn->driverName = I128_DRIVER_NAME; + pScrn->name = I128_NAME; + pScrn->Probe = I128Probe; + pScrn->PreInit = I128PreInit; + pScrn->ScreenInit = I128ScreenInit; + pScrn->SwitchMode = I128SwitchMode; + pScrn->AdjustFrame = I128AdjustFrame; + pScrn->EnterVT = I128EnterVT; + pScrn->LeaveVT = I128LeaveVT; + pScrn->FreeScreen = I128FreeScreen; + pScrn->ValidMode = I128ValidMode; + foundScreen = TRUE; + } + + xfree(usedChips); + + return foundScreen; +} + + +/* Mandatory + * + * The Identify() function is the third entry point called once that the + * module has been linked into the server. This function prints driver + * identity information. + * + * Arguments: + * int flags - currently unused + * Returns: + * no return + */ + +static void +I128Identify(int flags) +{ + xf86PrintChipsets(I128_NAME, "driver for Number Nine I128 chipsets", + I128Chipsets); +} + + +/* + * Define options that this driver will accept. Used by AvailableOptions(). + */ + +typedef enum { + OPTION_FLATPANEL, + OPTION_SW_CURSOR, + OPTION_HW_CURSOR, + OPTION_SYNC_ON_GREEN, + OPTION_NOACCEL, + OPTION_SHOWCACHE, + OPTION_DAC6BIT, + OPTION_DEBUG +} I128Opts; + +static OptionInfoRec I128Options[] = { + { OPTION_FLATPANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SYNC_ON_GREEN, "SyncOnGreen", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SHOWCACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DEBUG, "Debug", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + + +/* Mandatory + * + * The AvailableOptions() function is called to provide the options that + * this driver will accept. This is used with the "-configure" server option. + * + * Arguments: + * int chipid - currently unused + * int busid - currently unused + * Returns: + * OptionInfoPtr - all accepted options + */ + +static OptionInfoPtr +I128AvailableOptions(int chipid, int busid) +{ + return I128Options; +} + + +/* Mandatory + * + * The PreInit() function called after the Probe() function once at + * server startup and not at each server generation. Only things that + * are persistent across server generations can be initialized here. + * This function determines if the configuration is usable and, if so, + * initializes those parts of the ScrnInfoRec that can be set at the + * beginning of the first server generation. This should be done in + * the least intrusive way possible. Note that although the ScrnInfoRec + * has been allocated, the ScreenRec has not. + * + * Use xf86AllocateScrnInfoPrivateIndex() for persistent data across + * screen generations and AllocateScreenprivateIndex() in ScreenInit() + * for per-generation data. + * + * Arguments: + * ScrnInfoPtr pScrn - + * int flags - PROBE_DEFAULT for normal function + * PROBE_DETECT for use with "-config" and "-probe" + * Returns: + * Bool TRUE if ScrnInfoRec was initialized, FALSE otherwise + */ + +static Bool +I128PreInit(ScrnInfoPtr pScrn, int flags) +{ + I128Ptr pI128; + int i; + int bytesPerPixel; + ClockRangePtr clockRanges; + MessageType from; + char *mod = NULL; + CARD32 iobase; + char *ramdac = NULL; + CARD32 tmpl, tmph, tmp; + unsigned char n, m, p, mdc, df; + float mclk; + xf86MonPtr mon; + + /* Check the number of entities, and fail if it isn't one. */ + if (pScrn->numEntities != 1) + return FALSE; + + /* Allocate the I128Rec driverPrivate */ + I128GetRec(pScrn); + + pI128 = I128PTR(pScrn); + + /* Get the entity, and make sure it is PCI. */ + pI128->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (pI128->pEnt->location.type != BUS_PCI) + return FALSE; + + if (flags & PROBE_DETECT) { + /* I128ProbeDDC(pScrn, pI128->pEnt->index); */ + return TRUE; + } + + /* Find the PCI info for this screen */ + pI128->PciInfo = xf86GetPciInfoForEntity(pI128->pEnt->index); + pI128->PciTag = pciTag(pI128->PciInfo->bus, pI128->PciInfo->device, + pI128->PciInfo->func); + + pI128->Primary = xf86IsPrimaryPci(pI128->PciInfo); + + /* The vgahw module should be allocated here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) + return FALSE; + + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* + * Allocate a vgaHWRec + */ + if (!vgaHWGetHWRec(pScrn)) + return FALSE; + + vgaHWGetIOBase(VGAHWPTR(pScrn)); + + /* Set pScrn->monitor */ + pScrn->monitor = pScrn->confScreen->monitor; + + /* + * The first thing we should figure out is the depth, bpp, etc. + * Our default depth is 8, so pass it to the helper function. + * We support both 24bpp and 32bpp layouts, so indicate that. + */ + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support32bppFb)) { + return FALSE; + } else { + /* Check that the returned depth is one we support */ + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + return FALSE; + } + } + xf86PrintDepthBpp(pScrn); + + /* + * This must happen after pScrn->display has been set because + * xf86SetWeight references it. + */ + if (pScrn->depth > 8) { + /* The defaults are OK for us */ + rgb zeros = {0, 0, 0}; + + if (!xf86SetWeight(pScrn, zeros, zeros)) { + return FALSE; + } else { + /* XXX check that weight returned is supported */ + ; + } + } + + if (!xf86SetDefaultVisual(pScrn, -1)) { + return FALSE; + } else { + /* We don't currently support DirectColor at > 8bpp */ + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" + " (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + } + + bytesPerPixel = pScrn->bitsPerPixel / 8; + + /* We use a programamble clock */ + pScrn->progClock = TRUE; + + /* Collect all of the relevant option flags (fill in pScrn->options) */ + xf86CollectOptions(pScrn, NULL); + + /* Process the options */ + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, I128Options); + + if (pScrn->depth == 8) + pScrn->rgbBits = 8; + + /* + * The preferred method is to use the "hw cursor" option as a tri-state + * option, with the default set above. + */ + from = X_DEFAULT; + pI128->HWCursor = TRUE; + if (xf86GetOptValBool(I128Options, OPTION_HW_CURSOR, &pI128->HWCursor)) { + from = X_CONFIG; + } + /* For compatibility, accept this too (as an override) */ + if (xf86ReturnOptValBool(I128Options, OPTION_SW_CURSOR, FALSE)) { + from = X_CONFIG; + pI128->HWCursor = FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", + pI128->HWCursor ? "HW" : "SW"); + if (xf86ReturnOptValBool(I128Options, OPTION_NOACCEL, FALSE)) { + pI128->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); + } else pI128->NoAccel = FALSE; + if (xf86ReturnOptValBool(I128Options, OPTION_SYNC_ON_GREEN, FALSE)) { + pI128->DACSyncOnGreen = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Sync-on-Green enabled\n"); + } else pI128->DACSyncOnGreen = FALSE; + if (xf86ReturnOptValBool(I128Options, OPTION_SHOWCACHE, FALSE)) { + pI128->ShowCache = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShowCache enabled\n"); + } else pI128->ShowCache = FALSE; + if (xf86ReturnOptValBool(I128Options, OPTION_DAC6BIT, FALSE)) { + pI128->DAC8Bit = FALSE; + pScrn->rgbBits = 6; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Dac6Bit enabled\n"); + } else pI128->DAC8Bit = TRUE; + if (xf86ReturnOptValBool(I128Options, OPTION_DEBUG, FALSE)) { + pI128->Debug = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Debug enabled\n"); + } else pI128->Debug = FALSE; + if (xf86ReturnOptValBool(I128Options, OPTION_FLATPANEL, FALSE)) { + pI128->FlatPanel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "FlatPanel forced\n"); + } else pI128->FlatPanel = FALSE; + + /* + * Set the Chipset and ChipRev. + */ + from = X_PROBED; + pI128->Chipset = pI128->PciInfo->chipType; + pScrn->chipset = (char *)xf86TokenToString(I128Chipsets, pI128->Chipset); + pI128->ChipRev = pI128->PciInfo->chipRev; + + /* + * This shouldn't happen because such problems should be caught in + * I128Probe(), but check it just in case. + */ + if (pScrn->chipset == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04X is not recognised\n", pI128->Chipset); + return FALSE; + } + if (pI128->Chipset < 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognised\n", pScrn->chipset); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); + + iobase = pI128->PciInfo->ioBase[5] & 0xFF00; + pI128->RegRec.iobase = iobase; + + pI128->io.rbase_g = inl(iobase) & 0xFFFFFF00; + pI128->io.rbase_w = inl(iobase + 0x04) & 0xFFFFFF00; + pI128->io.rbase_a = inl(iobase + 0x08) & 0xFFFFFF00; + pI128->io.rbase_b = inl(iobase + 0x0C) & 0xFFFFFF00; + pI128->io.rbase_i = inl(iobase + 0x10) & 0xFFFFFF00; + pI128->io.rbase_e = inl(iobase + 0x14) & 0xFFFF8003; + pI128->io.id = inl(iobase + 0x18) & /* 0x7FFFFFFF */ 0xFFFFFFFF; + pI128->io.config1 = inl(iobase + 0x1C) & /* 0xF3333F1F */ 0xFF133706; + pI128->io.config2 = inl(iobase + 0x20) & 0xC1F70FFF; + pI128->io.sgram = inl(iobase + 0x24) & 0xFFFFFFFF; + pI128->io.soft_sw = inl(iobase + 0x28) & 0x0000FFFF; + pI128->io.vga_ctl = inl(iobase + 0x30) & 0x0000FFFF; + + if (pI128->Debug) + I128DumpBaseRegisters(pScrn); + + pI128->RegRec.config1 = pI128->io.config1; + pI128->RegRec.config2 = pI128->io.config2; + pI128->RegRec.sgram = pI128->io.sgram; + if (pI128->Chipset == PCI_CHIP_I128_T2R4) + pI128->io.sgram = 0x211BF030; + else + pI128->io.sgram = 0x21089030; + /* vga_ctl is saved later */ + + /* enable all of the memory mapped windows */ + + pI128->io.config1 &= 0x3300001F; + pI128->io.config1 |= 0x00331F10; + outl(iobase + 0x1C, pI128->io.config1); + + pI128->MemoryType = I128_MEMORY_UNKNOWN; + + if (pI128->Chipset == PCI_CHIP_I128_T2R4) + pI128->MemoryType = I128_MEMORY_SGRAM; + else if (pI128->Chipset == PCI_CHIP_I128_T2R) { + if ((pI128->io.config2&6) == 2) + pI128->MemoryType = I128_MEMORY_SGRAM; + else + pI128->MemoryType = I128_MEMORY_WRAM; + } else if (pI128->Chipset == PCI_CHIP_I128_2) { + if (((((pciConfigPtr)pI128->PciInfo->thisCard)->pci_command & 0x03) + == 0x03) && (pI128->PciInfo->subsysCard == 0x08)) + pI128->MemoryType = I128_MEMORY_DRAM; + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Memory type %s\n", + pI128->MemoryType == I128_MEMORY_SGRAM ? "SGRAM" : + pI128->MemoryType == I128_MEMORY_DRAM ? "DRAM" : + pI128->MemoryType == I128_MEMORY_WRAM ? "WRAM" : "UNKNOWN"); + + pI128->io.config2 &= 0xFF0FFF7F; + pI128->io.config2 |= 0x00100000; + if (pI128->MemoryType != I128_MEMORY_SGRAM) + pI128->io.config2 |= 0x00400000; + outl(pI128->RegRec.iobase + 0x20, pI128->io.config2); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Linear framebuffer at 0x%lX\n", + (unsigned long)pI128->PciInfo->memBase[0]); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "MMIO registers at 0x%lX\n", + (unsigned long)pI128->PciInfo->ioBase[5]); + + if (xf86RegisterResources(pI128->pEnt->index, NULL, ResExclusive)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "xf86RegisterResources() found resource conflicts\n"); + I128FreeRec(pScrn); + return FALSE; + } + + /* HW bpp matches reported bpp */ + pI128->bitsPerPixel = pScrn->bitsPerPixel; + pI128->depth = pScrn->depth; + pI128->weight.red = pScrn->weight.red; + pI128->weight.green = pScrn->weight.green; + pI128->weight.blue = pScrn->weight.blue; + pI128->mode = pScrn->modes; + + pScrn->videoRam = I128CountRam(pScrn); + pI128->MemorySize = pScrn->videoRam; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n", + pScrn->videoRam); + + + /* + * If the driver can do gamma correction, it should call xf86SetGamma() + * here. + */ + + { + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } + } + + if (!I128MapMem(pScrn)) + return FALSE; + + /* + * Reset card if it isn't primary one (must be done after config1 is set) + */ + if (!pI128->Primary) + I128SoftReset(pScrn); + + if (pI128->Chipset != PCI_CHIP_I128) { + pI128->ddc1Read = NULL /*I128DDC1Read*/; + pI128->i2cInit = I128I2CInit; + } + + /* Load DDC if we have the code to use it */ + /* This gives us DDC1 */ + if (pI128->ddc1Read || pI128->i2cInit) { + if (xf86LoadSubModule(pScrn, "ddc")) { + xf86LoaderReqSymLists(ddcSymbols, NULL); + } else { + /* ddc module not found, we can do without it */ + pI128->ddc1Read = NULL; + + /* Without DDC, we have no use for the I2C bus */ + pI128->i2cInit = NULL; + } + } + /* - DDC can use I2C bus */ + /* Load I2C if we have the code to use it */ + if (pI128->i2cInit) { + if ( xf86LoadSubModule(pScrn, "i2c") ) { + xf86LoaderReqSymLists(i2cSymbols,NULL); + } else { + /* i2c module not found, we can do without it */ + pI128->i2cInit = NULL; + pI128->I2C = NULL; + } + } + + /* Read and print the Monitor DDC info */ + mon = I128getDDC(pScrn); + pScrn->monitor->DDC = mon; + + /* see if we can find a flatpanel */ + if (!pI128->FlatPanel && mon) { + int i; + for (i=0; i<4; i++) + if (mon->det_mon[i].type == DS_NAME) { + if (strncmp((char *)mon->det_mon[i].section.name, + "SGI 1600SW FP", 13) == 0) { + pI128->FlatPanel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Found FlatPanel via DDC2\n"); + } + break; + } + } + + pI128->maxClock = 175000; + + switch (pI128->Chipset) { + case PCI_CHIP_I128: + if (pI128->io.id & 0x0400) /* 2 banks VRAM */ + pI128->RamdacType = IBM528_DAC; + else + pI128->RamdacType = TI3025_DAC; + break; + case PCI_CHIP_I128_2: + if (pI128->io.id & 0x0400) /* 2 banks VRAM */ + pI128->RamdacType = IBM528_DAC; + else + pI128->RamdacType = IBM526_DAC; + pI128->maxClock = 220000; + break; + case PCI_CHIP_I128_T2R: + pI128->RamdacType = IBM526_DAC; + pI128->maxClock = 220000; + break; + case PCI_CHIP_I128_T2R4: + pI128->RamdacType = SILVER_HAMMER_DAC; + pI128->maxClock = 270000; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Unknown I128 chipset: %d\n", + pI128->Chipset); + return(FALSE); + } + + if ((pI128->maxClock == 175000) && (pI128->MemorySize == 8192)) + pI128->maxClock = 220000; + + switch(pI128->RamdacType) { + case TI3025_DAC: + /* verify that the ramdac is a TVP3025 */ + + pI128->mem.rbase_g[INDEX_TI] = TI_ID; MB; + if ((pI128->mem.rbase_g[DATA_TI]&0xFF) != TI_VIEWPOINT25_ID) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Ti3025 Ramdac not found\n"); + return(FALSE); + } + ramdac = "TI3025"; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + n = pI128->mem.rbase_g[DATA_TI]&0x7f; + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + m = pI128->mem.rbase_g[DATA_TI]&0x7f; + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + p = pI128->mem.rbase_g[DATA_TI]&0x03; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_DCLK_CONTROL; MB; + mdc = pI128->mem.rbase_g[DATA_TI]&0xFF; + if (mdc&0x08) + mdc = (mdc&0x07)*2 + 2; + else + mdc = 1; + mclk = ((1431818 * ((m+2) * 8)) / (n+2) / (1 << p) / mdc + 50) / 100; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Using TI 3025 programmable clock (MCLK %1.3f MHz)\n", + mclk / 1000.0); + pI128->minClock = 20000; + pI128->ProgramDAC = I128ProgramTi3025; + break; + + case IBM524_DAC: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "IBM524 Ramdac not supported\n"); + return(FALSE); + + case IBM526_DAC: + /* verify that the ramdac is an IBM526 */ + + ramdac = "IBM526"; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_id; MB; + tmp = pI128->mem.rbase_g[DATA_I] & 0xFF; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + n = pI128->mem.rbase_g[DATA_I] & 0x1f; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + m = pI128->mem.rbase_g[DATA_I]; + df = m>>6; + m &= 0x3f; + if (n == 0) { m=0; n=1; } + mclk = ((2517500 * (m+65)) / n / (8>>df) + 50) / 100; + + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + if (tmp != 2) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "IBM526 Ramdac not found\n"); + return(FALSE); + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Using IBM 526 programmable clock (MCLK %1.3f MHz)\n", + mclk / 1000.0); + pI128->minClock = 25000; + pI128->ProgramDAC = I128ProgramIBMRGB; + break; + + case IBM528_DAC: + /* verify that the ramdac is an IBM528 */ + + ramdac = "IBM528"; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + pI128->mem.rbase_g[IDXH_I] = 0; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_id; MB; + tmp = pI128->mem.rbase_g[DATA_I] & 0xFF; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + n = pI128->mem.rbase_g[DATA_I] & 0x1f; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + m = pI128->mem.rbase_g[DATA_I] & 0xFF; + df = m>>6; + m &= 0x3f; + if (n == 0) { m=0; n=1; } + mclk = ((2517500 * (m+65)) / n / (8>>df) + 50) / 100; + + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + if (tmp != 2) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "IBM528 Ramdac not found\n"); + return(FALSE); + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Using IBM 528 programmable clock (MCLK %1.3f MHz)\n", + mclk / 1000.0); + pI128->minClock = 25000; + pI128->ProgramDAC = I128ProgramIBMRGB; + break; + + case SILVER_HAMMER_DAC: + /* verify that the ramdac is a Silver Hammer */ + + ramdac = "SilverHammer"; + tmph = pI128->mem.rbase_g[IDXH_I] & 0xFF; + tmpl = pI128->mem.rbase_g[IDXL_I] & 0xFF; + tmp = pI128->mem.rbase_g[DATA_I] & 0xFF; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + n = pI128->mem.rbase_g[DATA_I] & 0x1f; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + m = pI128->mem.rbase_g[DATA_I]; + df = m>>6; + m &= 0x3f; + if (n == 0) { m=0; n=1; } + mclk = ((3750000 * (m+65)) / n / (8>>df) + 50) / 100; + + pI128->mem.rbase_g[IDXL_I] = tmpl; MB; + pI128->mem.rbase_g[IDXH_I] = tmph; MB; + if (pI128->Chipset != PCI_CHIP_I128_T2R4) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "SilverHammer Ramdac not found\n"); + return(FALSE); + } + + if (pI128->mem.rbase_g[CRT_1CON] & 0x00000100) { + pI128->FlatPanel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Digital flat panel detected\n"); + } else if (pI128->FlatPanel) + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Digital flat panel forced\n"); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Using SilverHammer programmable clock (MCLK %1.3f MHz)\n", + mclk / 1000.0); + pI128->minClock = 25000; + pI128->ProgramDAC = I128ProgramSilverHammer; + break; + + default: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Ramdac Unknown\n"); + return(FALSE); + } + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Ramdac Type min/max speed: %s %d/%d MHz\n", + ramdac, pI128->minClock/1000, pI128->maxClock/1000); + + /* + * Setup the ClockRanges, which describe what clock ranges are available, + * and what sort of modes they can be used for. + */ + clockRanges = xnfalloc(sizeof(ClockRange)); + clockRanges->next = NULL; + clockRanges->minClock = pI128->minClock; + clockRanges->maxClock = pI128->maxClock; + clockRanges->clockIndex = -1; /* programmable */ + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + clockRanges->ClockMulFactor = 1; + clockRanges->ClockDivFactor = 1; + + /* + * xf86ValidateModes will check that the mode HTotal and VTotal values + * don't exceed the chipset's limit if pScrn->maxHValue and + * pScrn->maxVValue are set. Since our I128ValidMode() already takes + * care of this, we don't worry about setting them here. + */ + { + int *linePitches = NULL; + int minPitch = 256; + int maxPitch = 2048; + int pitchAlignment = 256; + + if (pI128->MemoryType == I128_MEMORY_WRAM) + pitchAlignment = (128 * 8); + pitchAlignment /= pI128->bitsPerPixel; + + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, + linePitches, minPitch, maxPitch, + pitchAlignment * pI128->bitsPerPixel, + 128, 2048, + pScrn->display->virtualX, + pScrn->display->virtualY, + pI128->MemorySize, + LOOKUP_BEST_REFRESH); + + pI128->displayWidth = pScrn->virtualX; + + if ((pScrn->virtualX % pitchAlignment) != 0) + pI128->displayWidth += pitchAlignment - + (pScrn->virtualX % pitchAlignment); + } + + if (i == -1) { + I128FreeRec(pScrn); + return FALSE; + } + + /* Prune the modes marked as invalid */ + xf86PruneDriverModes(pScrn); + + if (i == 0 || pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + I128FreeRec(pScrn); + return FALSE; + } + + if ((pI128->MemorySize > 4096) && + (pI128->MemoryType != I128_MEMORY_DRAM) && + (pI128->MemoryType != I128_MEMORY_SGRAM)) + pI128->displayOffset = 0x400000L % + (pI128->displayWidth * (pI128->bitsPerPixel/8)); + else + pI128->displayOffset = 0; + + pI128->MemoryPtr = + (pointer)&((char *)pI128->MemoryPtr)[pI128->displayOffset]; + + /* Set the current mode to the first in the list */ + pScrn->currentMode = pScrn->modes; + + /* Print the list of modes being used */ + xf86PrintModes(pScrn); + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { + I128FreeRec(pScrn); + return FALSE; + } + + if (!xf86LoadSubModule(pScrn, "fb")) { + I128FreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + + /* Load XAA if needed */ + if (!pI128->NoAccel) { + if (!xf86LoadSubModule(pScrn, "xaa")) { + I128FreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(xaaSymbols, NULL); + } + + /* Load ramdac if needed */ + if (pI128->HWCursor) { + if (!xf86LoadSubModule(pScrn, "ramdac")) { + I128FreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + } + + I128UnmapMem(pScrn); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "PreInit complete\n"); + return TRUE; +} + + +static Bool +I128GetRec(ScrnInfoPtr pScrn) +{ + /* + * Allocate an I128Rec, and hook it into pScrn->driverPrivate. + * pScrn->driverPrivate is initialised to NULL, so we can check if + * the allocation has already been done. + */ + if (pScrn->driverPrivate != NULL) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(I128Rec), 1); + + return TRUE; +} + +static void +I128FreeRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate == NULL) + return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + + + +/* + * I128SoftReset -- + * + * Resets drawing engine + */ +static void +I128SoftReset(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Performing soft reset\n"); + pI128->io.config1 |= 0x00000002; + outl(pI128->RegRec.iobase + 0x1C, pI128->io.config1); + usleep(10000); + pI128->io.config1 &= 0xFFFFFFFD; + outl(pI128->RegRec.iobase + 0x1C, pI128->io.config1); +} + +/* + * I128CountRAM -- + * + * Counts amount of installed RAM + */ +static int +I128CountRam(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + int SizeFound = 0; + + SizeFound = 0; + + switch(pI128->Chipset) { + case PCI_CHIP_I128_T2R4: + /* Use the subsystem ID to determine the memory size */ + switch ((pI128->PciInfo->subsysCard) & 0x0007) { + case 0x00: /* 4MB card */ + SizeFound = 4 * 1024; break; + case 0x01: /* 8MB card */ + SizeFound = 8 * 1024; break; + case 0x02: /* 12MB card */ + SizeFound = 12 * 1024; break; + case 0x03: /* 16MB card */ + SizeFound = 16 * 1024; break; + case 0x04: /* 20MB card */ + SizeFound = 20 * 1024; break; + case 0x05: /* 24MB card */ + SizeFound = 24 * 1024; break; + case 0x06: /* 28MB card */ + SizeFound = 28 * 1024; break; + case 0x07: /* 32MB card */ + SizeFound = 32 * 1024; break; + default: /* Unknown board... */ + break; + } + case PCI_CHIP_I128_T2R: + switch ((pI128->PciInfo->subsysCard) & 0xFFF7) { + case 0x00: /* 4MB card, no daughtercard */ + SizeFound = 4 * 1024; break; + case 0x01: /* 4MB card, 4MB daughtercard */ + case 0x04: /* 8MB card, no daughtercard */ + SizeFound = 8 * 1024; break; + case 0x02: /* 4MB card, 8MB daughtercard */ + case 0x05: /* 8MB card, 4MB daughtercard */ + SizeFound = 12 * 1024; break; + case 0x06: /* 8MB card, 8MB daughtercard */ + SizeFound = 16 * 1024; break; + case 0x03: /* 4MB card, 16 daughtercard */ + SizeFound = 20 * 1024; break; + case 0x07: /* 8MB card, 16MB daughtercard */ + SizeFound = 24 * 1024; break; + default: + break; + } + } + + if (SizeFound == 0) { + SizeFound = 2048; /* default to 2MB */ + if (pI128->io.config1 & 0x04) /* 128 bit mode */ + SizeFound <<= 1; + if (pI128->io.id & 0x0400) /* 2 banks VRAM */ + SizeFound <<= 1; + } + return SizeFound; +} + + +/* + * Map the framebuffer and MMIO memory. + */ + +static Bool +I128MapMem(ScrnInfoPtr pScrn) +{ + I128Ptr pI128; + + pI128 = I128PTR(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Mapping memory\n"); + + if (pI128->mem.rbase_g != NULL) + return TRUE; + + /* + * Map IO registers to virtual address space + */ + + pI128->mem.mw0_ad = (unsigned char *)xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_FRAMEBUFFER, + pI128->PciTag, + pI128->PciInfo->memBase[0] & 0xFFC00000, + pI128->MemorySize*1024); + if (pI128->mem.mw0_ad == NULL) + return FALSE; + + pI128->MemoryPtr = pI128->mem.mw0_ad; + + pI128->mem.rbase_g = (CARD32 *)xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO | VIDMEM_MMIO_32BIT, + pI128->PciTag, + pI128->PciInfo->memBase[4] & 0xFFFF0000, + 64*1024); + if (pI128->mem.rbase_g == NULL) + return FALSE; + + pI128->mem.rbase_w = pI128->mem.rbase_g + ( 8 * 1024)/4; + pI128->mem.rbase_a = pI128->mem.rbase_g + (16 * 1024)/4; + pI128->mem.rbase_b = pI128->mem.rbase_g + (24 * 1024)/4; + pI128->mem.rbase_i = pI128->mem.rbase_g + (32 * 1024)/4; + + return TRUE; +} + + +/* + * Unmap the framebuffer and MMIO memory. + */ + +static Bool +I128UnmapMem(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Unmapping memory\n"); + + if (pI128->mem.rbase_g == NULL) + return TRUE; + + /* + * Unmap IO registers to virtual address space + */ + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pI128->mem.mw0_ad, + pI128->MemorySize*1024); + pI128->mem.mw0_ad = NULL; + pI128->MemoryPtr = NULL; + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pI128->mem.rbase_g, 64*1024); + pI128->mem.rbase_g = NULL; + pI128->mem.rbase_w = NULL; + pI128->mem.rbase_a = NULL; + pI128->mem.rbase_b = NULL; + pI128->mem.rbase_i = NULL; + + return TRUE; +} + + +/* + * This function saves the video state. + */ +static void +I128Save(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + vgaHWPtr vgaHWP = VGAHWPTR(pScrn); + + if (pI128->Primary) + vgaHWSave(pScrn, &vgaHWP->SavedReg, VGA_SR_ALL); + + I128SaveState(pScrn); +} + +/* + * Restore the initial (text) mode. + */ +static void +I128Restore(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + vgaHWPtr vgaHWP = VGAHWPTR(pScrn); + + I128RestoreState(pScrn); + + if (pI128->Primary) { + vgaHWProtect(pScrn, TRUE); + vgaHWRestore(pScrn, &vgaHWP->SavedReg, VGA_SR_ALL); + vgaHWProtect(pScrn, FALSE); + } +} + +/* Usually mandatory */ +Bool +I128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return I128ModeInit(xf86Screens[scrnIndex], mode); +} + + +static Bool +I128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + I128Ptr pI128 = I128PTR(pScrn); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "ModeInit start\n"); + + /* Initialise the ModeReg values */ + pScrn->vtSema = TRUE; + + if (!I128Init(pScrn, mode)) + return FALSE; + + pI128->ModeSwitched = TRUE; + + pI128->mode = mode; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "ModeInit complete\n"); + + return TRUE; +} + + +/* Mandatory */ + +/* This gets called at the start of each server generation */ + +static Bool +I128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn; + I128Ptr pI128; + int ret; + VisualPtr visual; + unsigned char *FBStart; + int width, height, displayWidth; + + /* + * First get the ScrnInfoRec + */ + pScrn = xf86Screens[pScreen->myNum]; + + pI128 = I128PTR(pScrn); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "ScreenInit start\n"); + + /* Map the I128 memory and MMIO areas */ + if (!I128MapMem(pScrn)) + return FALSE; + + pI128->MemoryPtr = + (pointer)&((char *)pI128->MemoryPtr)[pI128->displayOffset]; + + /* Save the current state */ + I128Save(pScrn); + + /* Initialise the first mode */ + if (!I128ModeInit(pScrn, pScrn->currentMode)) + return FALSE; + + /* Darken the screen for aesthetic reasons and set the viewport */ + I128SaveScreen(pScreen, SCREEN_SAVER_ON); + pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* + * The next step is to setup the screen's visuals, and initialise the + * framebuffer code. In cases where the framebuffer's default + * choices for things like visual layouts and bits per RGB are OK, + * this may be as simple as calling the framebuffer's ScreenInit() + * function. If not, the visuals will need to be setup before calling + * a fb ScreenInit() function and fixed up after. + * + * For most PC hardware at depths >= 8, the defaults that cfb uses + * are not appropriate. In this driver, we fixup the visuals after. + */ + + /* + * Reset the visual list. + */ + miClearVisualTypes(); + + /* Setup the visuals we support. */ + + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + if (!miSetPixmapDepths()) + return FALSE; + + + /* + * Call the framebuffer layer's ScreenInit function, and fill in other + * pScreen fields. + */ + + width = pScrn->virtualX; + height = pScrn->virtualY; + displayWidth = pScrn->displayWidth; + + FBStart = pI128->MemoryPtr; + + ret = fbScreenInit(pScreen, FBStart, + width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); + if (!ret) + return FALSE; + +#ifdef RENDER + fbPictureInit(pScreen, 0, 0); +#endif + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + xf86SetBlackWhitePixels(pScreen); + + if (!pI128->NoAccel) + I128DGAInit(pScreen); + + if (!pI128->NoAccel) + I128AccelInit(pScreen); + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + + /* Initialize software cursor. + Must precede creation of the default colormap */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Initialize HW cursor layer. + Must follow software cursor initialization*/ + if (pI128->HWCursor) { + Bool ret = TRUE; + switch(pI128->RamdacType) { + case TI3025_DAC: + ret = I128TIHWCursorInit(pScrn); break; + case IBM524_DAC: + case IBM526_DAC: + case IBM528_DAC: + ret = I128IBMHWCursorInit(pScrn); break; + case SILVER_HAMMER_DAC: + ret = I128IBMHWCursorInit(pScrn); break; + default: + break; + } + if(!ret) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + } + + /* Initialise default colourmap */ + if (!miCreateDefColormap(pScreen)) + return FALSE; + + /* Initialize colormap layer. + Must follow initialization of the default colormap */ + if(!xf86HandleColormaps(pScreen, 256, 8, + I128LoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; + +#ifdef DPMSExtension + xf86DPMSInit(pScreen, I128DisplayPowerManagementSet, 0); +#endif + + pScrn->memPhysBase = (unsigned long)pI128->MemoryPtr; + pScrn->fbOffset = 0; + + pScreen->SaveScreen = I128SaveScreen; + + /* Wrap the current CloseScreen function */ + pI128->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = I128CloseScreen; + + /* Report any unused options (only for the first generation) */ + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + } + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "ScreenInit complete\n"); + + /* Done */ + return TRUE; +} + + +/* + * This function is used to initialize the Start Address - the first + * displayed location in the video memory. + */ +/* Usually mandatory */ +void +I128AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn; + int Base; + I128Ptr pI128; +#define I128_PAN_MASK 0x01FFFFE0 + + pScrn = xf86Screens[scrnIndex]; + pI128 = I128PTR(pScrn); + + if (pI128->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + if (x > (pI128->displayWidth - pI128->mode->HDisplay)) + x = pI128->displayWidth - pI128->mode->HDisplay; + + Base = ((y*pI128->displayWidth + x) * (pI128->bitsPerPixel/8)); + pI128->mem.rbase_g[DB_ADR] = + (Base & I128_PAN_MASK) + pI128->displayOffset; MB; + + /* now warp the cursor after the screen move */ + pI128->AdjustCursorXPos = (Base - (Base & I128_PAN_MASK)) + / (pI128->bitsPerPixel/8); +} + +/* + * This is called when VT switching back to the X server. Its job is + * to reinitialise the video mode. + * + */ + +/* Mandatory */ +static Bool +I128EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + if (!I128ModeInit(pScrn, pScrn->currentMode)) + return FALSE; + I128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + return TRUE; +} + +/* + * This is called when VT switching away from the X server. Its job is + * to restore the previous (text) mode. + * + */ + +/* Mandatory */ +static void +I128LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + I128Restore(pScrn); +} + + +/* + * This is called at the end of each server generation. It restores the + * original (text) mode. It should also unmap the video memory, and free + * any per-generation data allocated by the driver. It should finish + * by unwrapping and calling the saved CloseScreen function. + */ + +/* Mandatory */ +static Bool +I128CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + I128Ptr pI128 = I128PTR(pScrn); + + if (pScrn->vtSema) { + I128Restore(pScrn); + I128UnmapMem(pScrn); + } + if (pI128->AccelInfoRec) + XAADestroyInfoRec(pI128->AccelInfoRec); + if (pI128->CursorInfoRec) + xf86DestroyCursorInfoRec(pI128->CursorInfoRec); + if (pI128->DGAModes) + xfree(pI128->DGAModes); + pScrn->vtSema = FALSE; + + pScreen->CloseScreen = pI128->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + + +/* Free up any persistent data structures */ + +/* Optional */ +static void +I128FreeScreen(int scrnIndex, int flags) +{ + /* + * This only gets called when a screen is being deleted. It does not + * get called routinely at the end of a server generation. + */ + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(xf86Screens[scrnIndex]); + + I128FreeRec(xf86Screens[scrnIndex]); +} + + +/* Checks if a mode is suitable for the selected chipset. */ + +/* Optional */ +static int +I128ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + int lace; + + lace = 1 + ((mode->Flags & V_INTERLACE) != 0); + + if ((mode->CrtcHDisplay <= 2048) && + (mode->CrtcHSyncStart <= 4096) && + (mode->CrtcHSyncEnd <= 4096) && + (mode->CrtcHTotal <= 4096) && + (mode->CrtcVDisplay <= 2048 * lace) && + (mode->CrtcVSyncStart <= 4096 * lace) && + (mode->CrtcVSyncEnd <= 4096 * lace) && + (mode->CrtcVTotal <= 4096 * lace)) { + return(MODE_OK); + } else { + return(MODE_BAD); + } +} + + +/* Do screen blanking */ + +/* Mandatory */ +static Bool +I128SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + I128Ptr pI128; + Bool on; + + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + on = xf86IsUnblank(mode); + + if ((pScrn != NULL) && pScrn->vtSema) { + pI128 = I128PTR(pScrn); + if (on) { + pI128->mem.rbase_g[CRT_1CON] |= 0x40; MB; + } else { + pI128->mem.rbase_g[CRT_1CON] &= ~0x40; MB; + } + } + return TRUE; +} + + +static const int DDC_SDA_IN_SHIFT = 1; +static const int DDC_SDA_OUT_SHIFT = 2; +static const int DDC_SCL_IN_SHIFT = 3; +static const int DDC_SCL_OUT_SHIFT = 0; + +static const int DDC_SDA_IN_MASK = 1 << 1; +static const int DDC_SDA_OUT_MASK = 1 << 2; +static const int DDC_SCL_IN_MASK = 1 << 3; +static const int DDC_SCL_OUT_MASK = 1 << 0; + +static const int DDC_MODE_SHIFT = 8; +static const int DDC_MODE_MASK = 3 << 8; +static const int DDC_MODE_DIS = 0; +static const int DDC_MODE_DDC1 = 1 << 8; +static const int DDC_MODE_DDC2 = 2 << 8; + +#if 0 +static unsigned int +I128DDC1Read(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + unsigned char val; + unsigned long tmp, ddc; + unsigned short iobase; + + iobase = pI128->RegRec.iobase; + ddc = inl(iobase + 0x2C); + if ((ddc & DDC_MODE_MASK) != DDC_MODE_DDC1) { + outl(iobase + 0x2C, DDC_MODE_DDC1); + xf86usleep(40); + } + + /* wait for Vsync */ + do { + tmp = inl(iobase + 0x2C); + } while (tmp & 1); + do { + tmp = inl(iobase + 0x2C); + } while (!(tmp & 1)); + + /* Get the result */ + tmp = inl(iobase + 0x2C); + val = tmp & DDC_SDA_IN_MASK; + + if ((ddc & DDC_MODE_MASK) != DDC_MODE_DDC1) { + outl(iobase + 0x2C, ~DDC_MODE_MASK & ddc); + xf86usleep(40); + } + + return val; +} +#endif + +static void +I128I2CGetBits(I2CBusPtr b, int *clock, int *data) +{ + I128Ptr pI128 = I128PTR(xf86Screens[b->scrnIndex]); + unsigned long ddc; + unsigned short iobase; +#if 0 + static int lastclock = -1, lastdata = -1; +#endif + + /* Get the result. */ + iobase = pI128->RegRec.iobase; + ddc = inl(iobase + 0x2C); + + *clock = (ddc & DDC_SCL_IN_MASK) != 0; + *data = (ddc & DDC_SDA_IN_MASK) != 0; + +#if 0 + if (pI128->Debug && ((lastclock != *clock) || (lastdata != *data))) { + xf86DrvMsg(b->scrnIndex, X_INFO, "i2c> c %d d %d\n", *clock, *data); + lastclock = *clock; + lastdata = *data; + } +#endif +} + +static void +I128I2CPutBits(I2CBusPtr b, int clock, int data) +{ + I128Ptr pI128 = I128PTR(xf86Screens[b->scrnIndex]); + unsigned char drv, val; + unsigned long ddc; + unsigned long tmp; + unsigned short iobase; + + iobase = pI128->RegRec.iobase; + ddc = inl(iobase + 0x2C); + + val = (clock ? DDC_SCL_IN_MASK : 0) | (data ? DDC_SDA_IN_MASK : 0); + drv = ((clock) ? DDC_SCL_OUT_MASK : 0) | ((data) ? DDC_SDA_OUT_MASK : 0); + + tmp = (DDC_MODE_MASK & ddc) | val | drv; + outl(iobase + 0x2C, tmp); +#if 0 + if (pI128->Debug) + xf86DrvMsg(b->scrnIndex, X_INFO, "i2c> 0x%x\n", tmp); +#endif +} + + +static Bool +I128I2CInit(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + I2CBusPtr I2CPtr; + unsigned short iobase; + unsigned long soft_sw, ddc; + + I2CPtr = xf86CreateI2CBusRec(); + if(!I2CPtr) return FALSE; + + pI128->I2C = I2CPtr; + + I2CPtr->BusName = "DDC"; + I2CPtr->scrnIndex = pScrn->scrnIndex; + I2CPtr->I2CPutBits = I128I2CPutBits; + I2CPtr->I2CGetBits = I128I2CGetBits; + I2CPtr->BitTimeout = 4; + I2CPtr->ByteTimeout = 4; + I2CPtr->AcknTimeout = 4; + I2CPtr->StartTimeout = 4; + + /* soft switch register bits 1,0 control I2C channel */ + iobase = pI128->RegRec.iobase; + soft_sw = inl(iobase + 0x28); + soft_sw &= 0xfffffffc; + soft_sw |= 0x00000001; + outl(iobase + 0x28, soft_sw); + xf86usleep(1000); + + /* set default as ddc2 mode */ + ddc = inl(iobase + 0x2C); + ddc &= ~DDC_MODE_MASK; + ddc |= DDC_MODE_DDC2; + outl(iobase + 0x2C, ddc); + xf86usleep(40); + + if (!xf86I2CBusInit(I2CPtr)) { + return FALSE; + } + return TRUE; +} + + +static xf86MonPtr +I128getDDC(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + xf86MonPtr MonInfo = NULL; + + /* Initialize I2C bus - used by DDC if available */ + if (pI128->i2cInit) { + pI128->i2cInit(pScrn); + } + /* Read and output monitor info using DDC2 over I2C bus */ + if (pI128->I2C) { + MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pI128->I2C); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", MonInfo); + xf86PrintEDID(MonInfo); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n"); + } + if (!MonInfo) { + /* Read and output monitor info using DDC1 */ + if (pI128->ddc1Read) { + MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, NULL, pI128->ddc1Read ) ; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", MonInfo); + xf86PrintEDID(MonInfo); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n"); + } + } + + if (MonInfo) + xf86SetDDCproperties(pScrn, MonInfo); + + return MonInfo; +} + + +/* + * I128DisplayPowerManagementSet -- + * + * Sets VESA Display Power Management Signaling (DPMS) Mode. + */ +#ifdef DPMSExtension +void +I128DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, + int flags) +{ + I128Ptr pI128 = I128PTR(pScrn); + CARD32 snc; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128DisplayPowerManagementSet: %d\n", PowerManagementMode); + + if (pI128->RamdacType == TI3025_DAC) return; + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sync; MB; + snc = pI128->mem.rbase_g[DATA_I]; + + switch (PowerManagementMode) + { + case DPMSModeOn: + /* HSync: On, VSync: On */ + snc |= 0x30; + break; + case DPMSModeStandby: + /* HSync: Off, VSync: On */ + snc = (snc & ~0x10) | 0x20; + break; + case DPMSModeSuspend: + /* HSync: On, VSync: Off */ + snc = (snc & ~0x20) | 0x10; + break; + case DPMSModeOff: + /* HSync: Off, VSync: Off */ + snc &= ~0x30; + break; + } + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sync; MB; + pI128->mem.rbase_g[DATA_I] = snc; MB; +} + +#endif + +void +I128DumpBaseRegisters(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " PCI Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " MW0_AD 0x%08x addr 0x%08x %spre-fetchable\n", + pI128->PciInfo->memBase[0], + pI128->PciInfo->memBase[0] & 0xFFC00000, + pI128->PciInfo->memBase[0] & 0x8 ? "" : "not-"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " MW1_AD 0x%08x addr 0x%08x %spre-fetchable\n", + pI128->PciInfo->memBase[1], + pI128->PciInfo->memBase[1] & 0xFFC00000, + pI128->PciInfo->memBase[1] & 0x8 ? "" : "not-"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " XYW_AD(A) 0x%08x addr 0x%08x\n", + pI128->PciInfo->memBase[2], + pI128->PciInfo->memBase[2] & 0xFFC00000); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " XYW_AD(B) 0x%08x addr 0x%08x\n", + pI128->PciInfo->memBase[3], + pI128->PciInfo->memBase[3] & 0xFFC00000); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_G 0x%08x addr 0x%08x\n", + pI128->PciInfo->memBase[4], + pI128->PciInfo->memBase[4] & 0xFFFF0000); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " IO 0x%08x addr 0x%08x\n", + pI128->PciInfo->ioBase[5], + pI128->PciInfo->ioBase[5] & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " SSC 0x%08x addr 0x%08x\n", + pI128->PciInfo->subsysCard, + pI128->PciInfo->subsysCard & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " SSV 0x%08x addr 0x%08x\n", + pI128->PciInfo->subsysVendor, + pI128->PciInfo->subsysVendor & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_E 0x%08x addr 0x%08x %sdecode-enabled\n\n", + pI128->PciInfo->biosBase, + pI128->PciInfo->biosBase & 0xFFFF8000, + pI128->PciInfo->biosBase & 0x1 ? "" : "not-"); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " PCICMDST 0x%08x 0x%08x\n", + ((pciConfigPtr)pI128->PciInfo->thisCard)->pci_command, + ((pciConfigPtr)pI128->PciInfo->thisCard)->pci_status); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " IO Mapped Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_G 0x%08x addr 0x%08x\n", + pI128->io.rbase_g, pI128->io.rbase_g & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_W 0x%08x addr 0x%08x\n", + pI128->io.rbase_w, pI128->io.rbase_w & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_A 0x%08x addr 0x%08x\n", + pI128->io.rbase_a, pI128->io.rbase_a & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_B 0x%08x addr 0x%08x\n", + pI128->io.rbase_b, pI128->io.rbase_b & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_I 0x%08x addr 0x%08x\n", + pI128->io.rbase_i, pI128->io.rbase_i & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " RBASE_E 0x%08x addr 0x%08x size 0x%x\n\n", + pI128->io.rbase_e, pI128->io.rbase_e & 0xFFFF8000, + pI128->io.rbase_e & 0x7); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " Miscellaneous IO Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " ID 0x%08x\n", pI128->io.id); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " CONFIG1 0x%08x\n", pI128->io.config1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " CONFIG2 0x%08x\n", pI128->io.config2); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " SGRAM 0x%08x\n", pI128->io.sgram); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " SOFT_SW 0x%08x\n", pI128->io.soft_sw); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + " VGA_CTL 0x%08x\n", pI128->io.vga_ctl); +} + + +void +I128DumpActiveRegisters(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + unsigned short iobase; + unsigned long rbase_g, rbase_w, rbase_a, rbase_b, rbase_i, rbase_e; + unsigned long id, config1, config2, sgram, soft_sw, ddc, vga_ctl; + volatile unsigned long *vrba, *vrbg, *vrbw; + + vrba = pI128->mem.rbase_a; + vrbg = pI128->mem.rbase_g; + vrbw = pI128->mem.rbase_w; + + iobase = pI128->RegRec.iobase; + rbase_g = inl(iobase); + rbase_w = inl(iobase + 0x04); + rbase_a = inl(iobase + 0x08); + rbase_b = inl(iobase + 0x0C); + rbase_i = inl(iobase + 0x10); + rbase_e = inl(iobase + 0x14); + id = inl(iobase + 0x18); + config1 = inl(iobase + 0x1C); + config2 = inl(iobase + 0x20); + sgram = inl(iobase + 0x24); + soft_sw = inl(iobase + 0x28); + ddc = inl(iobase + 0x2C); + vga_ctl = inl(iobase + 0x30); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "IO Mapped Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_G 0x%08x addr 0x%08x\n", + rbase_g, rbase_g & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_W 0x%08x addr 0x%08x\n", + rbase_w, rbase_w & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_A 0x%08x addr 0x%08x\n", + rbase_a, rbase_a & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_B 0x%08x addr 0x%08x\n", + rbase_b, rbase_b & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_I 0x%08x addr 0x%08x\n", + rbase_i, rbase_i & 0xFFFFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RBASE_E 0x%08x addr 0x%08x size 0x%x\n", + rbase_e, rbase_e & 0xFFFF8000, rbase_e & 0x7); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Miscellaneous IO Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " ID 0x%08x\n", id); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " REV %d HBT %d BASE0 %d VDEN %d VB %d BASE1 %d BASE2 %d DS %d\n", + id&7, (id>>3)&3, (id>>6)&3, (id>>8)&3, (id>>10)&1, + (id>>11)&3, (id>>13)&3, (id>>15)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DDEN %d DB %d BASE3 %d BASER %d MDEN %d TR %d VS %d\n", + (id>>16)&3, (id>>18)&1, (id>>19)&3, (id>>21)&7, (id>>24)&3, + (id>>26)&1, (id>>27)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CLASS %d EE %d\n", + (id>>28)&3, (id>>30)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CONFIG1 0x%08x\n", config1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " VE %d SFT_RST %d ONE28 %d VS %d\n", + config1&1, (config1>>1)&1, + (config1>>2)&1, (config1>>3)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " G %d W %d A %d B %d I %d E %d W0 %d W1 %d XA %d XB %d\n", + (config1>>8)&1, (config1>>9)&1, + (config1>>10)&1, (config1>>11)&1, + (config1>>12)&1, (config1>>13)&1, + (config1>>16)&1, (config1>>17)&1, + (config1>>20)&1, (config1>>21)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " HBPRI %d VBPRI %d DE1PRI %d ISAPRI %d\n", + (config1>>24)&3, (config1>>26)&3, + (config1>>28)&3, (config1>>30)&3); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CONFIG2 0x%08x\n", config2); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DWT %x EWS %x DWS %x MC %x FBB %d IOB %d FST %d CNT %d DEC %d\n", + config2&0x3, (config2>>8)&0xF, + (config2>>16)&0x7, (config2>>20)&0xF, + (config2>>24)&1, (config2>>25)&1, + (config2>>26)&1, (config2>>27)&1, + (config2>>28)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " PRE %d RVD %d SDAC %d\n", + (config2>>29)&1, (config2>>30)&1, (config2>>31)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " SGRAM 0x%08x\n", sgram); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " SOFT_SW 0x%08x\n", soft_sw); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DDC 0x%08x\n", ddc); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " VGA_CTL 0x%08x\n", vga_ctl); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MEMMUX %d VGADEC %d VIDMUX %d ENA %d BUFSEL %d STR %d\n", + vga_ctl&1, (vga_ctl>>1)&1, + (vga_ctl>>2)&1, (vga_ctl>>3)&1, + (vga_ctl>>4)&1, (vga_ctl>>5)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " 3C2 %d DACDEC %d MSK 0x%02x\n", + (vga_ctl>>6)&1, + (vga_ctl>>7)&1, + (vga_ctl>>8)&0xff); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " INT_VCNT 0x%08x (%d)\n", + vrbg[0x20/4]&0xFF, vrbg[0x20/4]&0xFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " INT_HCNT 0x%08x (%d)\n", + vrbg[0x24/4]&0xFFF, vrbg[0x24/4]&0xFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DB_ADR 0x%08x (%d)\n", + vrbg[0x28/4]&0x01FFFFF0, vrbg[0x28/4]&0x01FFFFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DB_PTCH 0x%08x (%d)\n", + vrbg[0x2C/4]&0xFFF0, vrbg[0x2C/4]&0xFFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_HAC 0x%08x (%d)\n", + vrbg[0x30/4]&0x3FFF, vrbg[0x30/4]&0x3FFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_HBL 0x%08x (%d)\n", + vrbg[0x34/4]&0x3FFF, vrbg[0x34/4]&0x3FFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_HFP 0x%08x (%d)\n", + vrbg[0x38/4]&0x3FFF, vrbg[0x38/4]&0x3FFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_HS 0x%08x (%d)\n", + vrbg[0x3C/4]&0x3FFF, vrbg[0x3C/4]&0x3FFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_VAC 0x%08x (%d)\n", + vrbg[0x40/4]&0xFFF, vrbg[0x40/4]&0xFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_VBL 0x%08x (%d)\n", + vrbg[0x44/4]&0xFFF, vrbg[0x44/4]&0xFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_VFP 0x%08x (%d)\n", + vrbg[0x48/4]&0xFFF, vrbg[0x48/4]&0xFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_VS 0x%08x (%d)\n", + vrbg[0x4C/4]&0xFFF, vrbg[0x4C/4]&0xFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_LCNT 0x%08x\n", vrbg[0x50/4]&0x0FFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_ZOOM 0x%08x\n", vrbg[0x54/4]&0xF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_1CON 0x%08x PH %d PV %d CS %d INL %d H/VSE %d/%d VE %d BTS %d\n", + vrbg[0x58/4], + vrbg[0x58/4]&1, (vrbg[0x58/4]>>1)&1, (vrbg[0x58/4]>>2)&1, + (vrbg[0x58/4]>>3)&1, (vrbg[0x58/4]>>4)&1, (vrbg[0x58/4]>>5)&1, + (vrbg[0x58/4]>>6)&1, (vrbg[0x58/4]>>8)&1); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CRT_2CON 0x%08x MEM %d RFR %d TRD %d SPL %d\n", + vrbg[0x5C/4], + vrbg[0x5C/4]&7, (vrbg[0x5C/4]>>8)&1, + (vrbg[0x5C/4]>>16)&7, (vrbg[0x5C/4]>>24)&1); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Memory Windows Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW0_CTRL 0x%08x\n", vrbw[0x00]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " AMV %d MP %d AMD %d SEN %d BSY %d MDM %d DEN %d PSZ %d\n", + (vrbw[0x00]>>1)&1, (vrbw[0x00]>>2)&1, (vrbw[0x00]>>3)&1, + (vrbw[0x00]>>4)&3, (vrbw[0x00]>>8)&1, (vrbw[0x00]>>21)&3, + (vrbw[0x00]>>24)&3, (vrbw[0x00]>>26)&3); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "M/V/DSE %d/%d/%d\n", + (vrbw[0x00]>>28)&1, (vrbw[0x00]>>29)&1, (vrbw[0x00]>>30)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW0_AD 0x%08x MW0_SZ 0x%08x MW0_PGE 0x%08x\n", + vrbw[0x04/4]&0xFFFFF000, vrbw[0x08/4]&0x0000000F, + vrbw[0x0C/4]&0x000F001F); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW0_ORG10 0x%08x MW0_ORG14 0x%08x MW0_MSRC 0x%08x\n", + vrbw[0x10/4]&0x01FFF000, vrbw[0x14/4]&0x01FFF000, + vrbw[0x18/4]&0x00FFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW0_WKEY 0x%08x MW0_KYDAT 0x%08x MW0_MASK 0x%08x\n", + vrbw[0x1C/4], vrbw[0x20/4]&0x000F000F, vrbw[0x24/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW1_CTRL 0x%08x\n", vrbw[0x28/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " AMV %d MP %d AMD %d SEN %d BSY %d MDM %d DEN %d PSZ %d\n", + (vrbw[0x28/4]>>1)&1, (vrbw[0x28/4]>>2)&1, (vrbw[0x28/4]>>3)&1, + (vrbw[0x28/4]>>4)&3, (vrbw[0x28/4]>>8)&1, (vrbw[0x28/4]>>21)&3, + (vrbw[0x28/4]>>24)&3, (vrbw[0x28/4]>>26)&3); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "M/V/DSE %d/%d/%d\n", + (vrbw[0x28/4]>>28)&1, (vrbw[0x28/4]>>29)&1, (vrbw[0x28/4]>>30)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW1_AD 0x%08x MW1_SZ 0x%08x MW1_PGE 0x%08x\n", + vrbw[0x2C/4]&0xFFFFF000, vrbw[0x30/4]&0x0000000F, + vrbw[0x34/4]&0x000F001F); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW1_ORG10 0x%08x MW1_ORG14 0x%08x MW1_MSRC 0x%08x\n", + vrbw[0x38/4]&0x01FFF000, vrbw[0x3c/4]&0x01FFF000, + vrbw[0x40/4]&0x00FFFF00); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MW1_WKEY 0x%08x MW1_KYDAT 0x%08x MW1_MASK 0x%08x\n", + vrbw[0x44/4], vrbw[0x48/4]&0x000F000F, vrbw[0x4C/4]); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Engine A Registers\n"); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " INTP 0x%08x\n", vrba[0x00/4]&0x03); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " INTM 0x%08x\n", vrba[0x04/4]&0x03); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " FLOW 0x%08x\n", vrba[0x08/4]&0x0F); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " BUSY 0x%08x\n", vrba[0x0C/4]&0x01); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XYW_AD 0x%08x SIZE 0x%x ADDR 0x%x\n", + vrba[0x10/4]&0xFFFFFF00, (vrba[0x10/4]>>8)&0x0F, + vrba[0x10/4]&0xFFFFF000); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " ZCTL 0x%08x\n", vrba[0x18/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " BUF_CTRL 0x%08x\n", vrba[0x20/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " AMV %d MP %d AMD %d SEN %d DEN %d DSE %d VSE %d MSE %d\n", + (vrba[0x20/4]>>1)&1, (vrba[0x20/4]>>2)&1, (vrba[0x20/4]>>3)&1, + (vrba[0x20/4]>>8)&3, (vrba[0x20/4]>>10)&3, (vrba[0x20/4]>>12)&1, + (vrba[0x20/4]>>13)&1, (vrba[0x20/4]>>14)&1); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " PS %d MDM %d PSIZE %d CRCO %d\n", + (vrba[0x20/4]>>16)&0x1F, + (vrba[0x20/4]>>21)&3, (vrba[0x20/4]>>24)&3, (vrba[0x20/4]>>30)&3); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_PGE 0x%08x DVPGE 0x%x MPGE 0x%x\n", + vrba[0x24/4]&0x000F001F, (vrba[0x24/4]>>8)&0x01F, + (vrba[0x24/4]&0x000F0000)>>16); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_SORG 0x%08x\n", vrba[0x28/4]&0x0FFFFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_DORG 0x%08x\n", vrba[0x2C/4]&0x0FFFFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_MSRC 0x%08x\n", vrba[0x30/4]&0x03FFFFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_WKEY 0x%08x\n", vrba[0x38/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_ZPTCH 0x%08x\n", vrba[0x3C/4]&0x000FFFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_SPTCH 0x%08x\n", vrba[0x40/4]&0x0000FFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " DE_DPTCH 0x%08x\n", vrba[0x44/4]&0x0000FFF0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD 0x%08x\n", vrba[0x48/4]&0x7FFFFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " OPC 0x%02x ROP 0x%02x STYLE 0x%02x CLP 0x%x PATRN 0x%x HDF %d\n", + vrba[0x48/4]&0xFF, (vrba[0x48/4]>>8)&0xFF, (vrba[0x48/4]>>16)&0x1F, + (vrba[0x48/4]>>21)&7, (vrba[0x48/4]>>24)&0xF, (vrba[0x48/4]>>28)&7); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_SHADE 0x%02x\n", vrba[0x4C/4]&0xFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_OPC 0x%02x\n", vrba[0x50/4]&0xFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_ROP 0x%02x\n", vrba[0x54/4]&0xFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_STYLE 0x%02x\n", vrba[0x58/4]&0x1F); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_PATRN 0x%02x\n", vrba[0x5C/4]&0x0F); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_CLP 0x%02x\n", vrba[0x60/4]&0x07); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CMD_HDF 0x%02x\n", vrba[0x64/4]&0x07); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " FORE 0x%08x\n", vrba[0x68/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " BACK 0x%08x\n", vrba[0x6C/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " MASK 0x%08x\n", vrba[0x70/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " RMSK 0x%08x\n", vrba[0x74/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " LPAT 0x%08x\n", vrba[0x78/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " PCTRL 0x%08x\n", vrba[0x7C/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " PLEN 0x%02d PSCL 0x%02d SPTR 0x%02d SSCL 0x%x STATE 0x%04x\n", + vrba[0x7C/4]&0x1F, (vrba[0x7C/4]>>5)&7, (vrba[0x7C/4]>>8)&0x1F, + (vrba[0x7C/4]>>13)&7, (vrba[0x7C/4]>>16)&0xFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CLPTL 0x%08x CLPTLY 0x%04x CLPTLX 0x%04x\n", + vrba[0x80/4], vrba[0x80/4]&0xFFFF, (vrba[0x80/4]>>16)&0xFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " CLPBR 0x%08x CLPBRY 0x%04x CLPBRX 0x%04x\n", + vrba[0x84/4], vrba[0x84/4]&0xFFFF, (vrba[0x84/4]>>16)&0xFFFF); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY0 0x%08x\n", vrba[0x88/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY1 0x%08x\n", vrba[0x8C/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY2 0x%08x\n", vrba[0x90/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY3 0x%08x\n", vrba[0x94/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY4 0x%08x\n", vrba[0x98/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY5 0x%08x\n", vrba[0x9C/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY6 0x%08x\n", vrba[0xA0/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY7 0x%08x\n", vrba[0xA4/4]); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " XY8 0x%08x\n", vrba[0xA8/4]); + if (pI128->RamdacType != TI3025_DAC) + I128DumpIBMDACRegisters(pScrn, vrbg); +} + +static unsigned char ibm52Xmask[0xA0] = { +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* 00-07 */ +0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, /* 08-0F */ +0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, /* 10-17 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 18-1F */ +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, /* 20-27 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 28-2F */ +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, /* 30-37 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 38-3F */ +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* 40-47 */ +0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48-4F */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 58-5F */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 58-5F */ +0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, /* 60-67 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 68-6F */ +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, /* 70-77 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 78-7F */ +0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, /* 80-87 */ +0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, /* 88-8F */ +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, /* 90-97 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 98-9F */ +}; + +void +I128DumpIBMDACRegisters(ScrnInfoPtr pScrn, volatile unsigned long *vrbg) +{ + unsigned char ibmr[0x100]; + char buf[128], tbuf[10]; + int i; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "IBM52X Registers\n"); + + vrbg[IDXH_I] = 0x00; + vrbg[IDXH_I] = 0x00; + vrbg[IDXCTL_I] = 0x01; + buf[0] = '\0'; + + for (i=0; i<0xA0; i++) { + if ((i%16 == 0) && (i != 0)) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%s\n", buf); + buf[0] = '\0'; + } + if (ibm52Xmask[i] == 0x00) { + strcat(buf, " .."); + } else { + vrbg[IDXL_I] = i; + ibmr[i] = vrbg[DATA_I] & 0xFF; + ibmr[i] &= ibm52Xmask[i]; + sprintf(tbuf, " %02x", ibmr[i]); + strcat(buf, tbuf); + } + } + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%s\n", buf); +} + Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c:1.7 --- /dev/null Mon Dec 18 14:30:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c Tue Dec 5 20:07:34 2000 @@ -0,0 +1,516 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128accel.c,v 1.7 2000/12/06 01:07:34 robin Exp $ */ + +/* + * Copyright 1997-2000 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ROBIN CUTSHAW BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#include "xaa.h" +#include "xaalocal.h" +#include "xf86fbman.h" +#include "miline.h" +#include "servermd.h" + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" + +#include "i128.h" +#include "i128reg.h" + +void I128EngineDone(ScrnInfoPtr pScrn); +void I128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, + int w, int h); +void I128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, + int rop, unsigned planemask, int transparency_color); +void I128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, + int x2, int y2, int w, int h); +void I128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, + unsigned planemask); +void I128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h); +void I128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, + int y2, int flags); +void I128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, + int x2, int y2); +void I128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, + unsigned int planemask, int nBox, register BoxPtr pBoxI); +void I128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, DDXPointPtr pptSrc, + BoxPtr pbox, int xdir, int ydir, int alu, unsigned planemask); + + +#define ENG_PIPELINE_READY() { while (pI128->mem.rbase_a[BUSY] & BUSY_BUSY) ; } +#define ENG_DONE() { while (pI128->mem.rbase_a[FLOW] & (FLOW_DEB | FLOW_MCB | FLOW_PRV)) ;} + + +/* pre-shift rops and just or in as needed */ + +static CARD32 i128alu[16] = +{ + CR_CLEAR<<8, + CR_AND<<8, + CR_AND_REV<<8, + CR_COPY<<8, + CR_AND_INV<<8, + CR_NOOP<<8, + CR_XOR<<8, + CR_OR<<8, + CR_NOR<<8, + CR_EQUIV<<8, + CR_INVERT<<8, + CR_OR_REV<<8, + CR_COPY_INV<<8, + CR_OR_INV<<8, + CR_NAND<<8, + CR_SET<<8 +}; + /* 8bpp 16bpp 32bpp unused */ +static int min_size[] = { 0x62, 0x32, 0x1A, 0x00 }; +static int max_size[] = { 0x80, 0x40, 0x20, 0x00 }; +static int split_size[] = { 0x20, 0x10, 0x08, 0x00 }; + + +void +I128EngineDone(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + ENG_DONE(); +} + + +void +I128BitBlit(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h) +{ + I128Ptr pI128 = I128PTR(pScrn); + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BB %d,%d %d,%d %d,%d 0x%x/0x%x\n", x1, y1, x2, y2, w, h, pI128->cmd); +#endif + + ENG_PIPELINE_READY(); + + pI128->mem.rbase_a[CMD] = pI128->cmd; + /*pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir;*/ + + if (pI128->blitdir & DIR_RL_TB) { + x1 += w; x1--; + x2 += w; x2--; + } + if (pI128->blitdir & DIR_LR_BT) { + y1 += h; y1--; + y2 += h; y2--; + } + + + + if (pI128->Chipset == PCI_CHIP_I128) { + int bppi; + + static int first_time_through = 1; + + /* The I128-1 has a nasty bitblit bug + * that occurs when dest is exactly 8 pages wide + */ + + bppi = (pI128->mem.rbase_a[BUF_CTRL] & BC_PSIZ_MSK) >> 24; + + if ((w >= min_size[bppi]) && (w <= max_size[bppi])) { + if (first_time_through) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using I128-1 workarounds.\n"); + first_time_through = 0; + } + + bppi = split_size[bppi]; +#if 1 + /* split method */ + + pI128->mem.rbase_a[XY2_WH] = (bppi<<16) | h; + pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; + pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; + + ENG_PIPELINE_READY(); + + w -= bppi; + + if (pI128->blitdir & DIR_RL_TB) { + /* right to left blit */ + x1 -= bppi; + x2 -= bppi; + } else { + /* left to right blit */ + x1 += bppi; + x2 += bppi; + } +#else + /* clip method */ + pI128->mem.rbase_a[CLPTL] = (x2<<16) | y2; + pI128->mem.rbase_a[CLPBR] = ((x2+w)<<16) | (y2+h); + w += bppi; +#endif + } + } + + pI128->mem.rbase_a[XY2_WH] = (w<<16) | h; + pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; + pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; +} + +void +I128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, + int rop, unsigned planemask, int transparency_color) +{ + I128Ptr pI128 = I128PTR(pScrn); + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SFSSC %d,%d %d 0x%x %d\n", xdir, ydir, rop, planemask, transparency_color); +#endif + + ENG_PIPELINE_READY(); + + if (planemask == -1) + pI128->mem.rbase_a[MASK] = -1; + else switch (pI128->bitsPerPixel) { + case 8: + pI128->mem.rbase_a[MASK] = planemask | + (planemask<<8) | + (planemask<<16) | + (planemask<<24); + break; + case 16: + pI128->mem.rbase_a[MASK] = planemask | (planemask<<16); + break; + case 24: + case 32: + default: + pI128->mem.rbase_a[MASK] = planemask; + break; + } + + + pI128->mem.rbase_a[CLPTL] = 0x00000000; + pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047; + + if (transparency_color != -1) + pI128->mem.rbase_a[BACK] = transparency_color; + + + if (xdir == -1) { + if (ydir == -1) pI128->blitdir = DIR_RL_BT; + else pI128->blitdir = DIR_RL_TB; + } else { + if (ydir == -1) pI128->blitdir = DIR_LR_BT; + else pI128->blitdir = DIR_LR_TB; + } + pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir; + + pI128->rop = i128alu[rop]; + pI128->cmd = (transparency_color != -1 ? (CS_TRNSP<<16) : 0) | + pI128->rop | CO_BITBLT; + pI128->mem.rbase_a[CMD] = pI128->cmd; +} + +void +I128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, + int x2, int y2, int w, int h) +{ + I128BitBlit(pScrn, x1, y1, x2, y2, w, h); +} + +void +I128SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) +{ + I128Ptr pI128 = I128PTR(pScrn); + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SFSF color 0x%x rop 0x%x (I128rop 0x%x) pmask 0x%x\n", color, rop, i128alu[rop]>>8, planemask); +#endif + + ENG_PIPELINE_READY(); + + if (planemask == -1) + pI128->mem.rbase_a[MASK] = -1; + else switch (pI128->bitsPerPixel) { + case 8: + pI128->mem.rbase_a[MASK] = planemask | + (planemask<<8) | + (planemask<<16) | + (planemask<<24); + break; + case 16: + pI128->mem.rbase_a[MASK] = planemask | (planemask<<16); + break; + case 24: + case 32: + default: + pI128->mem.rbase_a[MASK] = planemask; + break; + } + + pI128->mem.rbase_a[FORE] = color; + + pI128->clptl = pI128->mem.rbase_a[CLPTL] = 0x00000000; + pI128->clpbr = pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ; + + pI128->mem.rbase_a[XY3_DIR] = pI128->blitdir = DIR_LR_TB; + + pI128->rop = i128alu[rop]; + pI128->cmd = (CS_SOLID<<16) | pI128->rop | CO_BITBLT; + pI128->mem.rbase_a[CMD] = pI128->cmd; +} + +void +I128SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) +{ +#if 0 + I128Ptr pI128 = I128PTR(pScrn); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SSFR %d,%d %d,%d\n", x, y, w, h); +#endif + I128BitBlit(pScrn, 0, 0, x, y, w, h); +} + +void +I128SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, + int y2, int flags) +{ + I128Ptr pI128 = I128PTR(pScrn); + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "STPL I128rop 0x%x %d,%d %d,%d clip %d,%d %d,%d\n", pI128->rop, x1, y1, x2, y2, pI128->clptl>>16, pI128->clptl&0xffff, (pI128->clpbr>>16)&0xffff, pI128->clpbr&0xffff); +#endif + + ENG_PIPELINE_READY(); + + pI128->mem.rbase_a[CMD] = + ((flags&0x0100) ? (CP_NLST<<24) : 0) | + (CC_CLPRECI<<21) | + (CS_SOLID<<16) | + pI128->rop | + CO_LINE; + + pI128->mem.rbase_a[CLPTL] = pI128->clptl; + pI128->mem.rbase_a[CLPBR] = pI128->clpbr; + + pI128->mem.rbase_a[XY0_SRC] = (x1<<16) | y1; MB; + pI128->mem.rbase_a[XY1_DST] = (x2<<16) | y2; MB; +} + +void +I128SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) +{ + I128Ptr pI128 = I128PTR(pScrn); + int tmp; + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "SCR %d,%d %d,%d\n", x1, y1, x2, y2); +#endif + + if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; } + if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; } + + pI128->clptl = (x1<<16) | y1; + pI128->clpbr = (x2<<16) | y2; +} + + +void +I128FillSolidRects(ScrnInfoPtr pScrn, int fg, int rop, unsigned int planemask, + int nBox, register BoxPtr pBoxI) +{ + I128Ptr pI128 = I128PTR(pScrn); + register int w, h; + +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FSR color 0x%x rop 0x%x (I128rop 0x%x) pmask 0x%x\n", fg, rop, i128alu[rop]>>8, planemask); +#endif + + ENG_PIPELINE_READY(); + + if (planemask != -1) { + if (pI128->bitsPerPixel == 8) { + planemask |= (planemask<<8) | + (planemask<<16) | + (planemask<<24); + } else if (pI128->bitsPerPixel == 16) + planemask |= planemask<<16; + } + + pI128->mem.rbase_a[MASK] = planemask; + pI128->mem.rbase_a[FORE] = fg; + pI128->mem.rbase_a[CMD] = (CS_SOLID<<16) | i128alu[rop] | CO_BITBLT; + pI128->mem.rbase_a[CLPTL] = 0x00000000; + pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047; + + pI128->mem.rbase_a[XY3_DIR] = DIR_LR_TB; + pI128->mem.rbase_a[XY0_SRC] = 0x00000000; + + while (nBox > 0) { + w = pBoxI->x2 - pBoxI->x1; + h = pBoxI->y2 - pBoxI->y1; + if (w > 0 && h > 0) { + pI128->mem.rbase_a[XY2_WH] = (w<<16) | h; MB; + pI128->mem.rbase_a[XY1_DST] = + (pBoxI->x1<<16) | pBoxI->y1; MB; + + ENG_PIPELINE_READY(); +#if 0 + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FSR x,y %d,%d w,h %d,%d\n", pBoxI->x1, pBoxI->y1, w, h); +#endif + + } + pBoxI++; + nBox--; + } + + ENG_DONE(); + +} + + +void +I128ScreenToScreenBitBlt(ScrnInfoPtr pScrn, int nbox, DDXPointPtr pptSrc, + BoxPtr pbox, int xdir, int ydir, int alu, unsigned planemask) +{ + I128Ptr pI128 = I128PTR(pScrn); + I128SetupForScreenToScreenCopy(pScrn, xdir, ydir, alu, planemask, -1); + for (; nbox; pbox++, pptSrc++, nbox--) + I128SubsequentScreenToScreenCopy(pScrn, pptSrc->x, pptSrc->y, + pbox->x1, pbox->y1, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + ENG_DONE(); +} + + +Bool +I128AccelInit(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoPtr; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I128Ptr pI128 = I128PTR(pScrn); + BoxRec AvailFBArea; + CARD32 buf_ctrl; + int maxlines; + + pI128->AccelInfoRec = infoPtr = XAACreateInfoRec(); + if (!infoPtr) return FALSE; + + infoPtr->Flags = PIXMAP_CACHE | + OFFSCREEN_PIXMAPS | + LINEAR_FRAMEBUFFER ; + + infoPtr->Sync = I128EngineDone; + + /* screen to screen copy */ + infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; + if (pI128->Chipset == PCI_CHIP_I128_T2R) + infoPtr->ScreenToScreenCopyFlags |= ONLY_LEFT_TO_RIGHT_BITBLT; + + infoPtr->SetupForScreenToScreenCopy = I128SetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = + I128SubsequentScreenToScreenCopy; + +#if 0 + /* screen to screen color expansion */ + if (pI128->Chipset == PCI_CHIP_I128_T2R) + infoPtr->ScreenToScreenColorExpandFillFlags |= + ONLY_LEFT_TO_RIGHT_BITBLT; + + infoPtr->SetupForScreenToScreenColorExpandFill = + I128SetupForScreenToScreenColorExpandFill; + infoPtr->SubsequentScreenToScreenColorExpandFill = + I128SubsequentScreenToScreenColorExpandFill; +#endif + + /* solid fills */ + infoPtr->SetupForSolidFill = I128SetupForSolidFill; + infoPtr->SubsequentSolidFillRect = I128SubsequentSolidFillRect; + + infoPtr->FillSolidRects = I128FillSolidRects; + + /* solid lines */ + infoPtr->SubsequentSolidTwoPointLine = I128SubsequentSolidTwoPointLine; + + /* clipping */ + infoPtr->ClippingFlags = HARDWARE_CLIP_LINE; + infoPtr->SetClippingRectangle = I128SetClippingRectangle; + + infoPtr->PolyFillRectSolidFlags = 0; + + maxlines = ((pI128->MemorySize * 1024) - 1024) / + (pScrn->displayWidth * pI128->bitsPerPixel / 8); + AvailFBArea.x1 = 0; + AvailFBArea.x2 = pI128->displayWidth; + AvailFBArea.y1 = 0; + AvailFBArea.y2 = maxlines; + xf86InitFBManager(pScreen, &AvailFBArea); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %d lines for offscreen memory\n", + maxlines - pScrn->virtualY); + + switch (pI128->bitsPerPixel) { + case 8: buf_ctrl = BC_PSIZ_8B; break; + case 16: buf_ctrl = BC_PSIZ_16B; break; + case 24: + case 32: buf_ctrl = BC_PSIZ_32B; break; + default: buf_ctrl = 0; break; /* error */ + } + if (pI128->Chipset == PCI_CHIP_I128_T2R) { + if (pI128->MemoryType == I128_MEMORY_SGRAM) + buf_ctrl |= BC_MDM_PLN; + else + buf_ctrl |= BC_BLK_ENA; + } + pI128->mem.rbase_a[BUF_CTRL] = buf_ctrl; + + pI128->mem.rbase_a[DE_PGE] = 0x00; + pI128->mem.rbase_a[DE_SORG] = pI128->displayOffset; + pI128->mem.rbase_a[DE_DORG] = pI128->displayOffset; + pI128->mem.rbase_a[DE_MSRC] = 0x00; + pI128->mem.rbase_a[DE_WKEY] = 0x00; + pI128->mem.rbase_a[DE_SPTCH] = pI128->mem.rbase_g[DB_PTCH]; + pI128->mem.rbase_a[DE_DPTCH] = pI128->mem.rbase_g[DB_PTCH]; + if (pI128->Chipset == PCI_CHIP_I128_T2R4) + pI128->mem.rbase_a[DE_ZPTCH] = pI128->mem.rbase_g[DB_PTCH]; + pI128->mem.rbase_a[RMSK] = 0x00000000; + pI128->mem.rbase_a[XY4_ZM] = ZOOM_NONE; + pI128->mem.rbase_a[LPAT] = 0xffffffff; /* for lines */ + pI128->mem.rbase_a[PCTRL] = 0x00000000; /* for lines */ + pI128->mem.rbase_a[CLPTL] = 0x00000000; + pI128->mem.rbase_a[CLPBR] = (4095<<16) | 2047 ; + pI128->mem.rbase_a[ACNTRL] = 0x00000000; + pI128->mem.rbase_a[INTM] = 0x03; + + if (pI128->Debug) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I128AccelInit done\n"); + I128DumpActiveRegisters(pScrn); + } + + return(XAAInit(pScreen, infoPtr)); +} Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128dga.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128dga.c:1.1 --- /dev/null Mon Dec 18 14:30:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128dga.c Sun Dec 10 20:53:01 2000 @@ -0,0 +1,272 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128dga.c,v 1.1 2000/12/11 01:53:01 robin Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xaa.h" +#include "xaalocal.h" +#include "i128.h" +#include "dgaproc.h" + + +static Bool I128_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool I128_SetMode(ScrnInfoPtr, DGAModePtr); +static int I128_GetViewport(ScrnInfoPtr); +static void I128_SetViewport(ScrnInfoPtr, int, int, int); +static void I128_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void I128_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +static void I128_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); + +static +DGAFunctionRec I128_DGAFuncs = { + I128_OpenFramebuffer, + NULL, + I128_SetMode, + I128_SetViewport, + I128_GetViewport, + I128EngineDone, + I128_FillRect, + I128_BlitRect, +#if 0 + I128_BlitTransRect +#else + NULL +#endif +}; + + +Bool +I128DGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I128Ptr pI128 = I128PTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while(pMode) { + + if(0 /*pScrn->displayWidth != pMode->HDisplay*/) { + newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if(!newmodes) { + xfree(modes); + return FALSE; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + num; + num++; + + currentMode->mode = pMode; + currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if(pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if(pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 1; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = pI128->MemoryPtr; + + if(oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = + ((pScrn->displayWidth * Bpp) + 3) & ~3L; + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + + pMode = pMode->next; + if(pMode == firstMode) + break; + } + + pI128->numDGAModes = num; + pI128->DGAModes = modes; + + return DGAInit(pScreen, &I128_DGAFuncs, modes, num); +} + + +static Bool +I128_SetMode( + ScrnInfoPtr pScrn, + DGAModePtr pMode +){ + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + + I128Ptr pI128 = I128PTR(pScrn); + + if(!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + + pScrn->displayWidth = OldDisplayWidth[index]; + + I128SwitchMode(index, pScrn->currentMode, 0); + pI128->DGAactive = FALSE; + } else { + if(!pI128->DGAactive) { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + + pI128->DGAactive = TRUE; + } + + pScrn->displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + + I128SwitchMode(index, pMode->mode, 0); + } + + return TRUE; +} + + + +static int +I128_GetViewport( + ScrnInfoPtr pScrn +){ + I128Ptr pI128 = I128PTR(pScrn); + + return pI128->DGAViewportStatus; +} + +static void +I128_SetViewport( + ScrnInfoPtr pScrn, + int x, int y, + int flags +){ + I128Ptr pI128 = I128PTR(pScrn); + + I128AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pI128->DGAViewportStatus = 0; /* I128AdjustFrame loops until finished */ +} + +static void +I128_FillRect ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color +){ + I128Ptr pI128 = I128PTR(pScrn); + + if(pI128->AccelInfoRec) { + (*pI128->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*pI128->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(pI128->AccelInfoRec); + } +} + +static void +I128_BlitRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + I128Ptr pI128 = I128PTR(pScrn); + + if(pI128->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pI128->AccelInfoRec->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, ~0, -1); + (*pI128->AccelInfoRec->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(pI128->AccelInfoRec); + } +} + + +static void +I128_BlitTransRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +){ + I128Ptr pI128 = I128PTR(pScrn); + + if(pI128->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pI128->AccelInfoRec->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, ~0, color); + (*pI128->AccelInfoRec->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(pI128->AccelInfoRec); + } +} + + +static Bool +I128_OpenFramebuffer( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + I128Ptr pI128 = I128PTR(pScrn); + CARD32 FbAddress = pI128->PciInfo->memBase[0] & 0xFFC00000; + + *name = NULL; /* no special device */ + *mem = (unsigned char*)FbAddress; + *size = pI128->MemorySize*1024; + *offset = 0; + *flags = DGA_NEED_ROOT; + + return TRUE; +} Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c:1.5 --- /dev/null Mon Dec 18 14:30:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c Thu Nov 2 19:50:53 2000 @@ -0,0 +1,576 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128init.c,v 1.5 2000/11/03 00:50:53 robin Exp $ */ +/* + * Copyright 1995-2000 by Robin Cutshaw <robin@XFree86.Org> + * Copyright 1998 by Number Nine Visual Technology, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw and Number Nine make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ROBIN CUTSHAW AND NUMBER NINE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL ROBIN CUTSHAW OR NUMBER NINE BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XConsortium: $ */ + + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +#include "i128.h" +#include "i128reg.h" +#include "Ti302X.h" +#include "IBMRGB.h" + +void I128SavePalette(I128Ptr pI128); +void I128RestorePalette(I128Ptr pI128); + + +void +I128SaveState(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + I128RegPtr iR = &pI128->RegRec; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128SaveState start\n"); + + if (pI128->Debug) { + unsigned long tmp1 = inl(iR->iobase + 0x1C); + unsigned long tmp2 = inl(iR->iobase + 0x20); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128SaveState saving, config1/2 = 0x%x/0x%x\n", tmp1, tmp2); + I128DumpActiveRegisters(pScrn); + } + + /* iobase is filled in during the device probe (as well as config 1&2)*/ + + if ((pI128->io.id&0x7) > 0) { + iR->vga_ctl = inl(iR->iobase + 0x30); + } + + iR->i128_base_g[INT_VCNT] = pI128->mem.rbase_g[INT_VCNT]; /* 0x0020 */ + iR->i128_base_g[INT_HCNT] = pI128->mem.rbase_g[INT_HCNT]; /* 0x0024 */ + iR->i128_base_g[DB_ADR] = pI128->mem.rbase_g[DB_ADR]; /* 0x0028 */ + iR->i128_base_g[DB_PTCH] = pI128->mem.rbase_g[DB_PTCH]; /* 0x002C */ + iR->i128_base_g[CRT_HAC] = pI128->mem.rbase_g[CRT_HAC]; /* 0x0030 */ + iR->i128_base_g[CRT_HBL] = pI128->mem.rbase_g[CRT_HBL]; /* 0x0034 */ + iR->i128_base_g[CRT_HFP] = pI128->mem.rbase_g[CRT_HFP]; /* 0x0038 */ + iR->i128_base_g[CRT_HS] = pI128->mem.rbase_g[CRT_HS]; /* 0x003C */ + iR->i128_base_g[CRT_VAC] = pI128->mem.rbase_g[CRT_VAC]; /* 0x0040 */ + iR->i128_base_g[CRT_VBL] = pI128->mem.rbase_g[CRT_VBL]; /* 0x0044 */ + iR->i128_base_g[CRT_VFP] = pI128->mem.rbase_g[CRT_VFP]; /* 0x0048 */ + iR->i128_base_g[CRT_VS] = pI128->mem.rbase_g[CRT_VS]; /* 0x004C */ + iR->i128_base_g[CRT_LCNT] = pI128->mem.rbase_g[CRT_LCNT]; /* 0x0050 */ + iR->i128_base_g[CRT_ZOOM] = pI128->mem.rbase_g[CRT_ZOOM]; /* 0x0054 */ + iR->i128_base_g[CRT_1CON] = pI128->mem.rbase_g[CRT_1CON]; /* 0x0058 */ + iR->i128_base_g[CRT_2CON] = pI128->mem.rbase_g[CRT_2CON]; /* 0x005C */ + + iR->i128_base_w[MW0_CTRL] = pI128->mem.rbase_w[MW0_CTRL]; /* 0x0000 */ + iR->i128_base_w[MW0_SZ] = pI128->mem.rbase_w[MW0_SZ]; /* 0x0008 */ + iR->i128_base_w[MW0_PGE] = pI128->mem.rbase_w[MW0_PGE]; /* 0x000C */ + iR->i128_base_w[MW0_ORG] = pI128->mem.rbase_w[MW0_ORG]; /* 0x0010 */ + iR->i128_base_w[MW0_MSRC] = pI128->mem.rbase_w[MW0_MSRC]; /* 0x0018 */ + iR->i128_base_w[MW0_WKEY] = pI128->mem.rbase_w[MW0_WKEY]; /* 0x001C */ + iR->i128_base_w[MW0_KDAT] = pI128->mem.rbase_w[MW0_KDAT]; /* 0x0020 */ + iR->i128_base_w[MW0_MASK] = pI128->mem.rbase_w[MW0_MASK]; /* 0x0024 */ + + if (pI128->RamdacType == TI3025_DAC) { + pI128->mem.rbase_g[INDEX_TI] = TI_CURS_CONTROL; MB; + iR->Ti302X[TI_CURS_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_TRUE_COLOR_CONTROL; MB; + iR->Ti302X[TI_TRUE_COLOR_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_VGA_SWITCH_CONTROL; MB; + iR->Ti302X[TI_VGA_SWITCH_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_MUX_CONTROL_1; MB; + iR->Ti302X[TI_MUX_CONTROL_1] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_MUX_CONTROL_2; MB; + iR->Ti302X[TI_MUX_CONTROL_2] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_INPUT_CLOCK_SELECT; MB; + iR->Ti302X[TI_INPUT_CLOCK_SELECT] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_OUTPUT_CLOCK_SELECT; MB; + iR->Ti302X[TI_OUTPUT_CLOCK_SELECT] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_PALETTE_PAGE; MB; + iR->Ti302X[TI_PALETTE_PAGE] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_CONTROL; MB; + iR->Ti302X[TI_GENERAL_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_MISC_CONTROL; MB; + iR->Ti302X[TI_MISC_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_AUXILIARY_CONTROL; MB; + iR->Ti302X[TI_AUXILIARY_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_IO_CONTROL; MB; + iR->Ti302X[TI_GENERAL_IO_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_IO_DATA; MB; + iR->Ti302X[TI_GENERAL_IO_DATA] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_DCLK_CONTROL; MB; + iR->Ti302X[TI_MCLK_DCLK_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + pI128->mem.rbase_g[INDEX_TI] = TI_COLOR_KEY_CONTROL; MB; + iR->Ti302X[TI_COLOR_KEY_CONTROL] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + iR->Ti3025[0] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + iR->Ti3025[1] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + iR->Ti3025[2] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + iR->Ti3025[3] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + iR->Ti3025[4] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + iR->Ti3025[5] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + iR->Ti3025[6] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + iR->Ti3025[7] = pI128->mem.rbase_g[DATA_TI]; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + iR->Ti3025[8] = pI128->mem.rbase_g[DATA_TI]; + } else if ((pI128->RamdacType == IBM526_DAC) || + (pI128->RamdacType == IBM528_DAC) || + (pI128->RamdacType == SILVER_HAMMER_DAC)) { + CARD32 i; + + for (i=0; i<0x94; i++) { + pI128->mem.rbase_g[IDXL_I] = i; MB; + iR->IBMRGB[i] = pI128->mem.rbase_g[DATA_I]; + } + } + + I128SavePalette(pI128); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128SaveState complete\n"); + +} + + +void +I128RestoreState(ScrnInfoPtr pScrn) +{ + I128Ptr pI128 = I128PTR(pScrn); + I128RegPtr iR = &pI128->RegRec; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128RestoreState start\n"); + + if (pI128->RamdacType == TI3025_DAC) { + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[0]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[1]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PIXEL_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[2]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[3]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[4]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[5]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x00; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[6]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x01; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[7]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_PLL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = 0x02; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_LOOP_CLOCK_PLL_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti3025[8]; MB; + + pI128->mem.rbase_g[INDEX_TI] = TI_CURS_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_CURS_CONTROL];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_TRUE_COLOR_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_TRUE_COLOR_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_VGA_SWITCH_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_VGA_SWITCH_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MUX_CONTROL_1; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_MUX_CONTROL_1];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MUX_CONTROL_2; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_MUX_CONTROL_2];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_INPUT_CLOCK_SELECT; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_INPUT_CLOCK_SELECT]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_OUTPUT_CLOCK_SELECT; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_OUTPUT_CLOCK_SELECT];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_PALETTE_PAGE; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_PALETTE_PAGE];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_GENERAL_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MISC_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_MISC_CONTROL];MB; + pI128->mem.rbase_g[INDEX_TI] = TI_AUXILIARY_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_AUXILIARY_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_IO_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_GENERAL_IO_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_GENERAL_IO_DATA; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_GENERAL_IO_DATA]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_MCLK_DCLK_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_MCLK_DCLK_CONTROL]; MB; + pI128->mem.rbase_g[INDEX_TI] = TI_COLOR_KEY_CONTROL; MB; + pI128->mem.rbase_g[DATA_TI] = iR->Ti302X[TI_COLOR_KEY_CONTROL]; MB; + } else if ((pI128->RamdacType == IBM526_DAC) || + (pI128->RamdacType == IBM528_DAC) || + (pI128->RamdacType == SILVER_HAMMER_DAC)) { + CARD32 i; + + if (pI128->Debug) { + unsigned long tmp1 = inl(iR->iobase + 0x1C); + unsigned long tmp2 = inl(iR->iobase + 0x20); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128RestoreState restoring, config1/2 = 0x%x/0x%x\n", tmp1, tmp2); + I128DumpActiveRegisters(pScrn); + } + + for (i=0; i<0x94; i++) { + if ((i == IBMRGB_sysclk_vco_div) || + (i == IBMRGB_sysclk_ref_div)) + continue; + pI128->mem.rbase_g[IDXL_I] = i; MB; + pI128->mem.rbase_g[DATA_I] = iR->IBMRGB[i]; MB; + } + + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_ref_div; MB; + pI128->mem.rbase_g[DATA_I] = + iR->IBMRGB[IBMRGB_sysclk_ref_div]; MB; + pI128->mem.rbase_g[IDXL_I] = IBMRGB_sysclk_vco_div; MB; + pI128->mem.rbase_g[DATA_I] = + iR->IBMRGB[IBMRGB_sysclk_vco_div]; MB; + usleep(50000); + } + + /* iobase is filled in during the device probe (as well as config 1&2)*/ + + if (((pI128->io.id&0x7) > 0) || + (pI128->Chipset == PCI_CHIP_I128_T2R) || + (pI128->Chipset == PCI_CHIP_I128_T2R4)) { + outl(iR->iobase + 0x30, iR->vga_ctl); + } + + I128RestorePalette(pI128); + + pI128->mem.rbase_w[MW0_CTRL] = iR->i128_base_w[MW0_CTRL]; /* 0x0000 */ + pI128->mem.rbase_w[MW0_SZ] = iR->i128_base_w[MW0_SZ]; /* 0x0008 */ + pI128->mem.rbase_w[MW0_PGE] = iR->i128_base_w[MW0_PGE]; /* 0x000C */ + pI128->mem.rbase_w[MW0_ORG] = iR->i128_base_w[MW0_ORG]; /* 0x0010 */ + pI128->mem.rbase_w[MW0_MSRC] = iR->i128_base_w[MW0_MSRC]; /* 0x0018 */ + pI128->mem.rbase_w[MW0_WKEY] = iR->i128_base_w[MW0_WKEY]; /* 0x001C */ + pI128->mem.rbase_w[MW0_KDAT] = iR->i128_base_w[MW0_KDAT]; /* 0x0020 */ + pI128->mem.rbase_w[MW0_MASK] = iR->i128_base_w[MW0_MASK]; /* 0x0024 */ + MB; + + pI128->mem.rbase_g[INT_VCNT] = iR->i128_base_g[INT_VCNT]; /* 0x0020 */ + pI128->mem.rbase_g[INT_HCNT] = iR->i128_base_g[INT_HCNT]; /* 0x0024 */ + pI128->mem.rbase_g[DB_ADR] = iR->i128_base_g[DB_ADR]; /* 0x0028 */ + pI128->mem.rbase_g[DB_PTCH] = iR->i128_base_g[DB_PTCH]; /* 0x002C */ + pI128->mem.rbase_g[CRT_HAC] = iR->i128_base_g[CRT_HAC]; /* 0x0030 */ + pI128->mem.rbase_g[CRT_HBL] = iR->i128_base_g[CRT_HBL]; /* 0x0034 */ + pI128->mem.rbase_g[CRT_HFP] = iR->i128_base_g[CRT_HFP]; /* 0x0038 */ + pI128->mem.rbase_g[CRT_HS] = iR->i128_base_g[CRT_HS]; /* 0x003C */ + pI128->mem.rbase_g[CRT_VAC] = iR->i128_base_g[CRT_VAC]; /* 0x0040 */ + pI128->mem.rbase_g[CRT_VBL] = iR->i128_base_g[CRT_VBL]; /* 0x0044 */ + pI128->mem.rbase_g[CRT_VFP] = iR->i128_base_g[CRT_VFP]; /* 0x0048 */ + pI128->mem.rbase_g[CRT_VS] = iR->i128_base_g[CRT_VS]; /* 0x004C */ + pI128->mem.rbase_g[CRT_LCNT] = iR->i128_base_g[CRT_LCNT]; /* 0x0050 */ + pI128->mem.rbase_g[CRT_ZOOM] = iR->i128_base_g[CRT_ZOOM]; /* 0x0054 */ + pI128->mem.rbase_g[CRT_1CON] = iR->i128_base_g[CRT_1CON]; /* 0x0058 */ + pI128->mem.rbase_g[CRT_2CON] = iR->i128_base_g[CRT_2CON]; /* 0x005C */ + MB; + + if (pI128->Debug) { + unsigned long tmp1 = inl(iR->iobase + 0x1C); + unsigned long tmp2 = inl(iR->iobase + 0x20); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128RestoreState resetting config1/2 from 0x%x/0x%x to 0x%x/0x%x\n", tmp1, tmp2, iR->config1, iR->config2); + I128DumpActiveRegisters(pScrn); + } + + if (pI128->MemoryType == I128_MEMORY_SGRAM) { + outl(iR->iobase + 0x24, iR->sgram & 0x7FFFFFFF); + outl(iR->iobase + 0x24, iR->sgram | 0x80000000); + } + + outl(iR->iobase + 0x20, iR->config2); + outl(iR->iobase + 0x1C, iR->config1); + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128RestoreState complete\n"); +} + + +Bool +I128Init(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + I128Ptr pI128; + I128RegPtr iR; + int pitch_multiplier, iclock; + Bool ret; + CARD32 tmp; + int doubled = 1; + + if (mode->Flags & V_DBLSCAN) + doubled = 2; + + pI128 = I128PTR(pScrn); + iR = &pI128->RegRec; + pI128->HDisplay = mode->HDisplay; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128Init start\n"); + + /* config 1 and 2 were saved in Probe() + * we reset here again in case there was a VT switch + */ + + outl(iR->iobase + 0x1C, pI128->io.config1); + outl(iR->iobase + 0x20, pI128->io.config2); + + if (pI128->MemoryType == I128_MEMORY_SGRAM) { + outl(iR->iobase + 0x24, pI128->io.sgram & 0x7FFFFFFF); + outl(iR->iobase + 0x24, pI128->io.sgram | 0x80000000); + } + + + if (pI128->bitsPerPixel == 32) pitch_multiplier = 4; + else if (pI128->bitsPerPixel == 16) pitch_multiplier = 2; + else pitch_multiplier = 1; + + if (pI128->RamdacType == TI3025_DAC) + iclock = 4; + else if (pI128->RamdacType == IBM528_DAC) + iclock = 128 / pI128->bitsPerPixel; + else if (pI128->RamdacType == SILVER_HAMMER_DAC) + iclock = 64 / pI128->bitsPerPixel; + else if ((pI128->MemoryType == I128_MEMORY_DRAM) || + (pI128->MemoryType == I128_MEMORY_SGRAM)) + iclock = 32 / pI128->bitsPerPixel; /* IBM526 DAC 32b bus */ + else + iclock = 64 / pI128->bitsPerPixel; /* IBM524/526 DAC */ + + pI128->mem.rbase_g[INT_VCNT] = 0x00; + pI128->mem.rbase_g[INT_HCNT] = 0x00; + pI128->mem.rbase_g[DB_ADR] = pI128->displayOffset; + pI128->mem.rbase_g[DB_PTCH] = pI128->displayWidth * pitch_multiplier; + pI128->mem.rbase_g[CRT_HAC] = mode->HDisplay/iclock; + pI128->mem.rbase_g[CRT_HBL] = (mode->HTotal - mode->HDisplay)/iclock; + pI128->mem.rbase_g[CRT_HFP] = (mode->HSyncStart - mode->HDisplay)/iclock; + pI128->mem.rbase_g[CRT_HS] = (mode->HSyncEnd - mode->HSyncStart)/iclock; + pI128->mem.rbase_g[CRT_VAC] = mode->VDisplay * doubled; + pI128->mem.rbase_g[CRT_VBL] = (mode->VTotal - mode->VDisplay) * doubled; + pI128->mem.rbase_g[CRT_VFP] = (mode->VSyncStart - mode->VDisplay)* doubled; + pI128->mem.rbase_g[CRT_VS] = (mode->VSyncEnd - mode->VSyncStart) * doubled; + tmp = 0x00000070; + if (pI128->Chipset == PCI_CHIP_I128_T2R) + tmp |= 0x00000100; + if (pI128->Chipset == PCI_CHIP_I128_T2R4) { + if (pI128->FlatPanel) + tmp |= 0x00000100; /* Turn on digital flat panel */ + else + tmp &= 0xfffffeff; /* Turn off digital flat panel */ + } + if (pI128->DACSyncOnGreen || (mode->Flags & V_CSYNC)) + tmp |= 0x00000004; + pI128->mem.rbase_g[CRT_1CON] = tmp; + if ((pI128->MemoryType == I128_MEMORY_DRAM) || + (pI128->MemoryType == I128_MEMORY_SGRAM)) + tmp = 0x20000100; + else if (pI128->MemoryType == I128_MEMORY_WRAM) + tmp = 0x00040100; + else { + tmp = 0x00040101; + if (pI128->MemorySize == 2048) + tmp |= 0x00000002; + if ((pI128->displayWidth & (pI128->displayWidth-1)) || + ((pI128->displayWidth * pI128->bitsPerPixel) > 32768L)) + tmp |= 0x01000000; /* split transfer */ + } + pI128->mem.rbase_g[CRT_2CON] = tmp; + if (mode->Flags & V_DBLSCAN) + pI128->DoubleScan = TRUE; + else + pI128->DoubleScan = FALSE; + pI128->mem.rbase_g[CRT_ZOOM] = (pI128->DoubleScan ? 0x00000001 : 0x00000000); + + pI128->mem.rbase_w[MW0_CTRL] = 0x00000000; + switch (pI128->MemorySize) { + case 2048: + pI128->mem.rbase_w[MW0_SZ] = 0x00000009; + break; + case 8192: + pI128->mem.rbase_w[MW0_SZ] = 0x0000000B; + break; + case 8192+4096: + /* no break */ + case 16384: + pI128->mem.rbase_w[MW0_SZ] = 0x0000000C; + break; + case 16384+4096: + /* no break */ + case 16384+8192: + /* no break */ + case 16384+8192+4096: + /* no break */ + case 32768: + pI128->mem.rbase_w[MW0_SZ] = 0x0000000D; + break; + case 4096: + /* no break */ + default: + pI128->mem.rbase_w[MW0_SZ] = 0x0000000A;/* default 4MB */ + break; + } + pI128->mem.rbase_w[MW0_PGE] = 0x00000000; + pI128->mem.rbase_w[MW0_ORG] = 0x00000000; + pI128->mem.rbase_w[MW0_MSRC] = 0x00000000; + pI128->mem.rbase_w[MW0_WKEY] = 0x00000000; + pI128->mem.rbase_w[MW0_KDAT] = 0x00000000; + pI128->mem.rbase_w[MW0_MASK] = 0xFFFFFFFF; + MB; + + if ((pI128->io.id&0x7) > 0 || pI128->Chipset == PCI_CHIP_I128_T2R + || pI128->Chipset == PCI_CHIP_I128_T2R4) { + + pI128->io.vga_ctl &= 0x0000FF00; + pI128->io.vga_ctl |= 0x00000082; + if (pI128->FlatPanel && (mode->Flags & V_DBLSCAN)) + pI128->io.vga_ctl |= 0x00000020; /* Stretch horizontally */ + outl(iR->iobase + 0x30, pI128->io.vga_ctl); + + if (pI128->Chipset == PCI_CHIP_I128_T2R4) { + outl(iR->iobase + 0x24, 0x211BF030); + usleep(5000); + outl(iR->iobase + 0x24, 0xA11BF030); + } else if (pI128->MemoryType == I128_MEMORY_SGRAM) { + outl(iR->iobase + 0x24, 0x21089030); + usleep(5000); + outl(iR->iobase + 0x24, 0xA1089030); + } + } + + ret = pI128->ProgramDAC(pScrn, mode); + + pI128->InitCursorFlag = TRUE; + pI128->Initialized = 1; + + if (pI128->Debug) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "I128Init complete\n"); + + return(ret); +} + + +void +I128SavePalette(I128Ptr pI128) +{ + short i; + + pI128->mem.rbase_g[PEL_MASK] = 0xff; MB; + + if (!pI128->LUTSaved) { + pI128->mem.rbase_g[RD_ADR] = 0x00; MB; + for (i=0; i<256; i++) { + pI128->lutorig[i].r = pI128->mem.rbase_g[PAL_DAT]; MB; + pI128->lutorig[i].g = pI128->mem.rbase_g[PAL_DAT]; MB; + pI128->lutorig[i].b = pI128->mem.rbase_g[PAL_DAT]; MB; + } + pI128->LUTSaved = TRUE; + } + +} + + +void +I128RestorePalette(I128Ptr pI128) +{ + int i; + /* restore the LUT */ + + pI128->mem.rbase_g[PEL_MASK] = 0xff; MB; + pI128->mem.rbase_g[WR_ADR] = 0x00; MB; + + for (i=0; i<256; i++) { + pI128->mem.rbase_g[PAL_DAT] = pI128->lutorig[i].r; MB; + pI128->mem.rbase_g[PAL_DAT] = pI128->lutorig[i].g; MB; + pI128->mem.rbase_g[PAL_DAT] = pI128->lutorig[i].b; MB; + } +} + + +void +I128LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, + VisualPtr pVisual) +{ + I128Ptr pI128; + + if (pVisual->nplanes != 8) + return; + + pI128 = I128PTR(pScrn); + + pI128->mem.rbase_g[PEL_MASK] = 0xff; MB; + + while (numColors--) { + pI128->mem.rbase_g[WR_ADR] = *indices; MB; + pI128->mem.rbase_g[PAL_DAT] = colors[*indices].red; MB; + pI128->mem.rbase_g[PAL_DAT] = colors[*indices].green; MB; + pI128->mem.rbase_g[PAL_DAT] = colors[*indices].blue; MB; + indices++; + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h:1.2 --- /dev/null Mon Dec 18 14:30:42 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h Mon Oct 23 10:11:39 2000 @@ -0,0 +1,577 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128reg.h,v 1.2 2000/10/23 14:11:39 robin Exp $ */ +/* + * Copyright 1994 by Robin Cutshaw <robin@XFree86.Org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Robin Cutshaw not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Robin Cutshaw makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ROBIN CUTSHAW BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: i128reg.h /main/4 1996/05/12 20:56:19 kaleb $ */ + +#ifndef I128REG_H +#define I128REG_H + + +struct i128pci { + CARD32 devicevendor; + CARD32 statuscommand; + CARD32 classrev; + CARD32 bhlc; + CARD32 base0; + CARD32 base1; + CARD32 base2; + CARD32 base3; + CARD32 base4; + CARD32 base5; + CARD32 rsvd0; + CARD32 rsvd1; + CARD32 baserom; + CARD32 rsvd2; + CARD32 rsvd3; + CARD32 lgii; +}; + +struct i128io { + CARD32 rbase_g; + CARD32 rbase_w; + CARD32 rbase_a; + CARD32 rbase_b; + CARD32 rbase_i; + CARD32 rbase_e; + CARD32 id; + CARD32 config1; + CARD32 config2; + CARD32 sgram; + CARD32 soft_sw; + CARD32 vga_ctl; +}; + +struct i128mem { + unsigned char *mw0_ad; + unsigned char *mw1_ad; + unsigned char *xyw_ada; + unsigned char *xyw_adb; + CARD32 *rbase_g; + CARD32 *rbase_w; + CARD32 *rbase_a; + CARD32 *rbase_b; + CARD32 *rbase_i; +}; + +/* save the registers needed for restoration in this structure */ +typedef struct { + unsigned short iobase; /* saved only for iobase indexing */ + CARD32 config1; /* iobase+0x1C register */ + CARD32 config2; /* iobase+0x20 register */ + CARD32 sgram; /* iobase+0x24 register */ + CARD32 vga_ctl; /* iobase+0x30 register */ + CARD32 i128_base_g[0x60/4]; /* base g registers */ + CARD32 i128_base_w[0x28/4]; /* base w registers */ + CARD32 intm; /* base a+0x04 register */ + unsigned char Ti302X[0x40]; /* Ti302[05] registers */ + unsigned char Ti3025[9]; /* Ti3025 N,M,P for PCLK, MCLK, LCLK */ + unsigned char IBMRGB[0x101]; /* IBMRGB registers */ +} I128RegRec, *I128RegPtr; + + +/* display list processor instruction formats */ +typedef union { + struct { + CARD8 aad; + CARD8 bad; + CARD8 cad; + CARD8 control; + CARD32 rad; + CARD32 rbd; + CARD32 rcd; + } f0; + struct { + CARD32 xy0; + CARD32 xy2; + CARD32 xy3; + CARD32 xy1; + } f1; + CARD32 f4[4]; +} I128dlpu; + +#define UNKNOWN_DAC -1 +#define TI3025_DAC 0 +#define IBM524_DAC 1 +#define IBM526_DAC 2 +#define IBM528_DAC 3 +#define SILVER_HAMMER_DAC 4 + +#define I128_MEMORY_UNKNOWN 0x01 +#define I128_MEMORY_DRAM 0x02 +#define I128_MEMORY_WRAM 0x04 +#define I128_MEMORY_SGRAM 0x08 + +/* RBASE_I register offsets */ + +#define GINTP 0x0000 +#define GINTM 0x0004 +#define SGRAM 0x00A4 + +/* RBASE_G register offsets (divided by four for double word indexing */ + +#define WR_ADR 0x0000/4 +#define PAL_DAT 0x0004/4 +#define PEL_MASK 0x0008/4 +#define RD_ADR 0x000C/4 +#define INDEX_TI 0x0018/4 /* TI ramdac */ +#define DATA_TI 0x001C/4 /* TI ramdac */ +#define IDXL_I 0x0010/4 /* IBM ramdac */ +#define IDXH_I 0x0014/4 /* IBM ramdac */ +#define DATA_I 0x0018/4 /* IBM ramdac */ +#define IDXCTL_I 0x001C/4 /* IBM ramdac */ +#define INT_VCNT 0x0020/4 +#define INT_HCNT 0x0024/4 +#define DB_ADR 0x0028/4 +#define DB_PTCH 0x002C/4 +#define CRT_HAC 0x0030/4 +#define CRT_HBL 0x0034/4 +#define CRT_HFP 0x0038/4 +#define CRT_HS 0x003C/4 +#define CRT_VAC 0x0040/4 +#define CRT_VBL 0x0044/4 +#define CRT_VFP 0x0048/4 +#define CRT_VS 0x004C/4 +#define CRT_LCNT 0x0050/4 +#define CRT_ZOOM 0x0054/4 +#define CRT_1CON 0x0058/4 +#define CRT_2CON 0x005C/4 + + +/* RBASE_W register offsets (divided by four for double word indexing */ + +#define MW0_CTRL 0x0000/4 +#define MW0_AD 0x0004/4 +#define MW0_SZ 0x0008/4 /* 2MB = 0x9, 4MB = 0xA, 8MB = 0xB */ +#define MW0_PGE 0x000C/4 +#define MW0_ORG 0x0010/4 +#define MW0_MSRC 0x0018/4 +#define MW0_WKEY 0x001C/4 +#define MW0_KDAT 0x0020/4 +#define MW0_MASK 0x0024/4 + + +/* RBASE_[AB] register offsets (divided by four for double word indexing */ + +#define INTP 0x0000/4 +#define INTP_DD_INT 0x01 /* drawing op completed */ +#define INTP_CL_INT 0x02 +#define INTM 0x0004/4 +#define INTM_DD_MSK 0x01 +#define INTM_CL_MSK 0x02 +#define FLOW 0x0008/4 +#define FLOW_DEB 0x01 /* drawing engine busy */ +#define FLOW_MCB 0x02 /* mem controller busy */ +#define FLOW_CLP 0x04 +#define FLOW_PRV 0x08 /* prev cmd still running or cache ready */ +#define BUSY 0x000C/4 +#define BUSY_BUSY 0x01 /* command pipeline busy */ +#define XYW_AD 0x0010/4 +#define Z_CTRL 0x0018/4 +#define BUF_CTRL 0x0020/4 +#define BC_AMV 0x02 +#define BC_MP 0x04 +#define BC_AMD 0x08 +#define BC_SEN_MSK 0x0300 +#define BC_SEN_DB 0x0000 +#define BC_SEN_VB 0x0100 +#define BC_SEN_MB 0x0200 +#define BC_SEN_CB 0x0300 +#define BC_DEN_MSK 0x0C00 +#define BC_DEN_DB 0x0000 +#define BC_DEN_VB 0x0400 +#define BC_DEN_MB 0x0800 +#define BC_DEN_CB 0x0C00 +#define BC_DSE 0x1000 +#define BC_VSE 0x2000 +#define BC_MSE 0x4000 +#define BC_PS_MSK 0x001F0000 +#define BC_MDM_MSK 0x00600000 +#define BC_MDM_KEY 0x00200000 +#define BC_MDM_PLN 0x00400000 +#define BC_BLK_ENA 0x00800000 +#define BC_PSIZ_MSK 0x03000000 +#define BC_PSIZ_8B 0x00000000 +#define BC_PSIZ_16B 0x01000000 +#define BC_PSIZ_32B 0x02000000 +#define BC_PSIZ_NOB 0x03000000 +#define BC_CO 0x40000000 +#define BC_CR 0x80000000 +#define DE_PGE 0x0024/4 +#define DP_DVP_MSK 0x0000001F +#define DP_MP_MSK 0x000F0000 +#define DE_SORG 0x0028/4 +#define DE_DORG 0x002C/4 +#define DE_MSRC 0x0030/4 +#define DE_WKEY 0x0038/4 +#define DE_KYDAT 0x003C/4 +#define DE_ZPTCH 0x003C/4 +#define DE_SPTCH 0x0040/4 +#define DE_DPTCH 0x0044/4 +#define CMD 0x0048/4 +#define CMD_OPC_MSK 0x000000FF +#define CMD_ROP_MSK 0x0000FF00 +#define CMD_STL_MSK 0x001F0000 +#define CMD_CLP_MSK 0x00E00000 +#define CMD_PAT_MSK 0x0F000000 +#define CMD_HDF_MSK 0x70000000 +#define CMD_OPC 0x0050/4 +#define CO_NOOP 0x00 +#define CO_BITBLT 0x01 +#define CO_LINE 0x02 +#define CO_ELINE 0x03 +#define CO_TRIAN 0x04 +#define CO_RXFER 0x06 +#define CO_WXFER 0x07 +#define CMD_ROP 0x0054/4 +#define CR_CLEAR 0x00 +#define CR_NOR 0x01 +#define CR_AND_INV 0x02 +#define CR_COPY_INV 0x03 +#define CR_AND_REV 0x04 +#define CR_INVERT 0x05 +#define CR_XOR 0x06 +#define CR_NAND 0x07 +#define CR_AND 0x08 +#define CR_EQUIV 0x09 +#define CR_NOOP 0x0A +#define CR_OR_INV 0x0B +#define CR_COPY 0x0C +#define CR_OR_REV 0x0D +#define CR_OR 0x0E +#define CR_SET 0x0F +#define CMD_STYLE 0x0058/4 +#define CS_SOLID 0x01 +#define CS_TRNSP 0x02 +#define CS_STP_NO 0x00 +#define CS_STP_PL 0x04 +#define CS_STP_PA32 0x08 +#define CS_STP_PA8 0x0C +#define CS_EDI 0x10 +#define CMD_PATRN 0x005C/4 +#define CP_APAT_NO 0x00 +#define CP_APAT_8X 0x01 +#define CP_APAT_32X 0x02 +#define CP_NLST 0x04 +#define CP_PRST 0x08 +#define CMD_CLP 0x0060/4 +#define CC_NOCLP 0x00 +#define CC_CLPRECI 0x02 +#define CC_CLPRECO 0x03 +#define CC_CLPSTOP 0x04 +#define CMD_HDF 0x0064/4 +#define CH_BIT_SWP 0x01 +#define CH_BYT_SWP 0x02 +#define CH_WRD_SWP 0x04 +#define FORE 0x0068/4 +#define BACK 0x006C/4 +#define MASK 0x0070/4 +#define RMSK 0x0074/4 +#define LPAT 0x0078/4 +#define PCTRL 0x007C/4 +#define PC_PLEN_MSK 0x0000001F +#define PC_PSCL_MSK 0x000000E0 +#define PC_SPTR_MSK 0x00001F00 +#define PC_SSCL_MSK 0x0000E000 +#define PC_STATE_MSK 0xFFFF0000 +#define CLPTL 0x0080/4 +#define CLPTLY_MSK 0x0000FFFF +#define CLPTLX_MSK 0xFFFF0000 +#define CLPBR 0x0084/4 +#define CLPBRY_MSK 0x0000FFFF +#define CLPBRX_MSK 0xFFFF0000 +#define XY0_SRC 0x0088/4 +#define XY1_DST 0x008C/4 /* trigger */ +#define XY2_WH 0x0090/4 +#define XY3_DIR 0x0094/4 +#define DIR_LR_TB 0x00000000 +#define DIR_LR_BT 0x00000001 +#define DIR_RL_TB 0x00000002 +#define DIR_RL_BT 0x00000003 +#define XY4_ZM 0x0098/4 +#define ZOOM_NONE 0x00000000 +#define XY_Y_DATA 0x0000FFFF +#define XY_X_DATA 0xFFFF0000 +#define XY_I_DATA1 0x0000FFFF +#define XY_I_DATA2 0xFFFF0000 +#define DL_ADR 0x00F8/4 +#define DL_CNTRL 0x00FC/4 +#define ACNTRL 0x016C/4 + +#define I128_WAIT_READY 1 +#define I128_WAIT_DONE 2 + +typedef struct { + unsigned char r, b, g; +} LUTENTRY; + +#define RGB8_PSEUDO (-1) +#define RGB16_565 0 +#define RGB16_555 1 +#define RGB32_888 2 + +#define MB mem_barrier() + + +/* TI ramdac indirect indexed registers */ + +#define TI_CURS_X_LOW 0x00 +#define TI_CURS_X_HIGH 0x01 /* only lower 4 bits are used */ +#define TI_CURS_Y_LOW 0x02 +#define TI_CURS_Y_HIGH 0x03 /* only lower 4 bits are used */ +#define TI_SPRITE_ORIGIN_X 0x04 +#define TI_SPRITE_ORIGIN_Y 0x05 +#define TI_CURS_CONTROL 0x06 +#define TI_PLANAR_ACCESS 0x80 /* 3025 only - 80 == BT485 mode */ +#define TI_CURS_SPRITE_ENABLE 0x40 +#define TI_CURS_X_WINDOW_MODE 0x10 +#define TI_CURS_CTRL_MASK (TI_CURS_SPRITE_ENABLE | TI_CURS_X_WINDOW_MODE) +#define TI_CURS_RAM_ADDR_LOW 0x08 +#define TI_CURS_RAM_ADDR_HIGH 0x09 +#define TI_CURS_RAM_DATA 0x0A +#define TI_TRUE_COLOR_CONTROL 0x0E /* 3025 only */ +#define TI_TC_BTMODE 0x04 /* on = BT485 mode, off = TI3020 mode */ +#define TI_TC_NONVGAMODE 0x02 /* on = nonvgamode, off = vgamode */ +#define TI_TC_8BIT 0x01 /* on = 8/4bit, off = 16/32bit */ +#define TI_VGA_SWITCH_CONTROL 0x0F /* 3025 only */ +#define TI_LATCH_CONTROL 0x0F /* 3026 only */ +#define TI_WINDOW_START_X_LOW 0x10 +#define TI_WINDOW_START_X_HIGH 0x11 +#define TI_WINDOW_STOP_X_LOW 0x12 +#define TI_WINDOW_STOP_X_HIGH 0x13 +#define TI_WINDOW_START_Y_LOW 0x14 +#define TI_WINDOW_START_Y_HIGH 0x15 +#define TI_WINDOW_STOP_Y_LOW 0x16 +#define TI_WINDOW_STOP_Y_HIGH 0x17 +#define TI_MUX_CONTROL_1 0x18 +#define TI_MUX1_PSEUDO_COLOR 0x80 +#define TI_MUX1_DIRECT_888 0x06 +#define TI_MUX1_DIRECT_565 0x05 +#define TI_MUX1_DIRECT_555 0x04 +#define TI_MUX1_DIRECT_664 0x03 +#define TI_MUX1_TRUE_888 0x46 +#define TI_MUX1_TRUE_565 0x45 +#define TI_MUX1_TRUE_555 0x44 +#define TI_MUX1_TRUE_664 0x43 +#define TI_MUX1_3025D_888 0x0E /* 3025 only */ +#define TI_MUX1_3025D_565 0x0D /* 3025 only */ +#define TI_MUX1_3025D_555 0x0C /* 3025 only */ +#define TI_MUX1_3025T_888 0x4E /* 3025 only */ +#define TI_MUX1_3025T_565 0x4D /* 3025 only */ +#define TI_MUX1_3025T_555 0x4C /* 3025 only */ +#define TI_MUX1_3026D_888 0x06 /* 3026 only */ +#define TI_MUX1_3026D_565 0x05 /* 3026 only */ +#define TI_MUX1_3026D_555 0x04 /* 3026 only */ +#define TI_MUX1_3026D_888_P8 0x16 /* 3026 only */ +#define TI_MUX1_3026D_888_P5 0x1e /* 3026 only */ +#define TI_MUX1_3026T_888 0x46 /* 3026 only */ +#define TI_MUX1_3026T_565 0x45 /* 3026 only */ +#define TI_MUX1_3026T_555 0x44 /* 3026 only */ +#define TI_MUX1_3026T_888_P8 0x56 /* 3026 only */ +#define TI_MUX1_3026T_888_P5 0x5e /* 3026 only */ +#define TI_MUX_CONTROL_2 0x19 +#define TI_MUX2_BUS_VGA 0x98 +#define TI_MUX2_BUS_PC_D8P64 0x1C +#define TI_MUX2_BUS_DC_D24P64 0x1C +#define TI_MUX2_BUS_DC_D16P64 0x04 +#define TI_MUX2_BUS_DC_D15P64 0x04 +#define TI_MUX2_BUS_TC_D24P64 0x04 +#define TI_MUX2_BUS_TC_D16P64 0x04 +#define TI_MUX2_BUS_TC_D15P64 0x04 +#define TI_MUX2_BUS_3026PC_D8P64 0x4C +#define TI_MUX2_BUS_3026DC_D24P64 0x5C +#define TI_MUX2_BUS_3026DC_D16P64 0x54 +#define TI_MUX2_BUS_3026DC_D15P64 0x54 +#define TI_MUX2_BUS_3026TC_D24P64 0x5c +#define TI_MUX2_BUS_3026TC_D16P64 0x54 +#define TI_MUX2_BUS_3026TC_D15P64 0x54 +#define TI_MUX2_BUS_3030PC_D8P128 0x4d +#define TI_MUX2_BUS_3030DC_D24P128 0x5d +#define TI_MUX2_BUS_3030DC_D16P128 0x55 +#define TI_MUX2_BUS_3030DC_D15P128 0x55 +#define TI_MUX2_BUS_3030TC_D24P128 0x5d +#define TI_MUX2_BUS_3030TC_D16P128 0x55 +#define TI_MUX2_BUS_3030TC_D15P128 0x55 +#define TI_INPUT_CLOCK_SELECT 0x1A +#define TI_ICLK_CLK0 0x00 +#define TI_ICLK_CLK0_DOUBLE 0x10 +#define TI_ICLK_CLK1 0x01 +#define TI_ICLK_CLK1_DOUBLE 0x11 +#define TI_ICLK_CLK2 0x02 /* 3025 only */ +#define TI_ICLK_CLK2_DOUBLE 0x12 /* 3025 only */ +#define TI_ICLK_CLK2_I 0x03 /* 3025 only */ +#define TI_ICLK_CLK2_I_DOUBLE 0x13 /* 3025 only */ +#define TI_ICLK_CLK2_E 0x04 /* 3025 only */ +#define TI_ICLK_CLK2_E_DOUBLE 0x14 /* 3025 only */ +#define TI_ICLK_PLL 0x05 /* 3025 only */ +#define TI_OUTPUT_CLOCK_SELECT 0x1B +#define TI_OCLK_VGA 0x3E +#define TI_OCLK_S 0x40 +#define TI_OCLK_NS 0x80 /* 3025 only */ +#define TI_OCLK_V1 0x00 +#define TI_OCLK_V2 0x08 +#define TI_OCLK_V4 0x10 +#define TI_OCLK_V8 0x18 +#define TI_OCLK_R1 0x00 +#define TI_OCLK_R2 0x01 +#define TI_OCLK_R4 0x02 +#define TI_OCLK_R8 0x03 +#define TI_OCLK_S_V1_R8 (TI_OCLK_S | TI_OCLK_V1 | TI_OCLK_R8) +#define TI_OCLK_S_V2_R8 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R8) +#define TI_OCLK_S_V4_R8 (TI_OCLK_S | TI_OCLK_V4 | TI_OCLK_R8) +#define TI_OCLK_S_V8_R8 (TI_OCLK_S | TI_OCLK_V8 | TI_OCLK_R8) +#define TI_OCLK_S_V2_R4 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R4) +#define TI_OCLK_S_V4_R4 (TI_OCLK_S | TI_OCLK_V4 | TI_OCLK_R4) +#define TI_OCLK_S_V1_R2 (TI_OCLK_S | TI_OCLK_V1 | TI_OCLK_R2) +#define TI_OCLK_S_V2_R2 (TI_OCLK_S | TI_OCLK_V2 | TI_OCLK_R2) +#define TI_OCLK_NS_V1_R1 (TI_OCLK_NS | TI_OCLK_V1 | TI_OCLK_R1) +#define TI_OCLK_NS_V2_R2 (TI_OCLK_NS | TI_OCLK_V2 | TI_OCLK_R2) +#define TI_OCLK_NS_V4_R4 (TI_OCLK_NS | TI_OCLK_V4 | TI_OCLK_R4) +#define TI_PALETTE_PAGE 0x1C +#define TI_GENERAL_CONTROL 0x1D +#define TI_MISC_CONTROL 0x1E /* 3025 only */ +#define TI_MC_POWER_DOWN 0x01 +#define TI_MC_DOTCLK_DISABLE 0x02 +#define TI_MC_INT_6_8_CONTROL 0x04 /* 00 == external 6/8 pin */ +#define TI_MC_8_BPP 0x08 /* 00 == 6bpp */ +#define TI_MC_PSEL_POLARITY 0x20 /* 3026 only, PSEL polarity select */ +#define TI_MC_VCLK_POLARITY 0x20 +#define TI_MC_LCLK_LATCH 0x40 /* VCLK == 00, default */ +#define TI_MC_LOOP_PLL_RCLK 0x80 +#define TI_OVERSCAN_COLOR_RED 0x20 +#define TI_OVERSCAN_COLOR_GREEN 0x21 +#define TI_OVERSCAN_COLOR_BLUE 0x22 +#define TI_CURSOR_COLOR_0_RED 0x23 +#define TI_CURSOR_COLOR_0_GREEN 0x24 +#define TI_CURSOR_COLOR_0_BLUE 0x25 +#define TI_CURSOR_COLOR_1_RED 0x26 +#define TI_CURSOR_COLOR_1_GREEN 0x27 +#define TI_CURSOR_COLOR_1_BLUE 0x28 +#define TI_AUXILIARY_CONTROL 0x29 +#define TI_AUX_SELF_CLOCK 0x08 +#define TI_AUX_W_CMPL 0x01 +#define TI_GENERAL_IO_CONTROL 0x2A +#define TI_GIC_ALL_BITS 0x1F +#define TI_GENERAL_IO_DATA 0x2B +#define TI_GID_W2000_6BIT 0x00 +#define TI_GID_N9_964 0x01 +#define TI_GID_ELSA_SOG 0x04 +#define TI_GID_W2000_8BIT 0x08 +#define TI_GID_S3_DAC_6BIT 0x1C +#define TI_GID_S3_DAC_8BIT 0x1E +#define TI_GID_TI_DAC_6BIT 0x1D +#define TI_GID_TI_DAC_8BIT 0x1F +#define TI_PLL_CONTROL 0x2C /* 3025 only */ +#define TI_PIXEL_CLOCK_PLL_DATA 0x2D /* 3025 only */ +#define TI_PLL_ENABLE 0x08 /* 3025 only */ +#define TI_MCLK_PLL_DATA 0x2E /* 3025 only */ +#define TI_LOOP_CLOCK_PLL_DATA 0x2F /* 3025 only */ +#define TI_COLOR_KEY_OLVGA_LOW 0x30 +#define TI_COLOR_KEY_OLVGA_HIGH 0x31 +#define TI_COLOR_KEY_RED_LOW 0x32 +#define TI_COLOR_KEY_RED_HIGH 0x33 +#define TI_COLOR_KEY_GREEN_LOW 0x34 +#define TI_COLOR_KEY_GREEN_HIGH 0x35 +#define TI_COLOR_KEY_BLUE_LOW 0x36 +#define TI_COLOR_KEY_BLUE_HIGH 0x37 +#define TI_COLOR_KEY_CONTROL 0x38 +#define TI_COLOR_KEY_CMPL 0x10 +#define TI_MCLK_DCLK_CONTROL 0x39 /* 3025 only */ +#define TI_MCLK_LCLK_CONTROL 0x39 /* 3026 only */ +#define TI_SENSE_TEST 0x3A +#define TI_TEST_DATA 0x3B +#define TI_CRC_LOW 0x3C +#define TI_CRC_HIGH 0x3D +#define TI_CRC_CONTROL 0x3E +#define TI_ID 0x3F +#define TI_VIEWPOINT20_ID 0x20 +#define TI_VIEWPOINT25_ID 0x25 +#define TI_MODE_85_CONTROL 0xD5 /* 3025 only */ + +#define TI_REF_FREQ 14.31818 /* 3025 only */ + +/* + * which clocks should be set (just flags...) + */ +#define TI_BOTH_CLOCKS 1 +#define TI_LOOP_CLOCK 2 + +/* IBM ramdac registers */ + +#define IBMRGB_rev 0x00 +#define IBMRGB_id 0x01 +#define IBMRGB_misc_clock 0x02 +#define IBMRGB_sync 0x03 +#define IBMRGB_hsync_pos 0x04 +#define IBMRGB_pwr_mgmt 0x05 +#define IBMRGB_dac_op 0x06 +#define IBMRGB_pal_ctrl 0x07 +#define IBMRGB_sysclk 0x08 /* not RGB525 */ +#define IBMRGB_pix_fmt 0x0a +#define IBMRGB_8bpp 0x0b +#define IBMRGB_16bpp 0x0c +#define IBMRGB_24bpp 0x0d +#define IBMRGB_32bpp 0x0e +#define IBMRGB_pll_ctrl1 0x10 +#define IBMRGB_pll_ctrl2 0x11 +#define IBMRGB_pll_ref_div_fix 0x14 +#define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */ +#define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */ +#define IBMRGB_f0 0x20 +#define IBMRGB_m0 0x20 +#define IBMRGB_n0 0x21 +#define IBMRGB_curs 0x30 +#define IBMRGB_curs_xl 0x31 +#define IBMRGB_curs_xh 0x32 +#define IBMRGB_curs_yl 0x33 +#define IBMRGB_curs_yh 0x34 +#define IBMRGB_curs_hot_x 0x35 +#define IBMRGB_curs_hot_y 0x36 +#define IBMRGB_curs_col1_r 0x40 +#define IBMRGB_curs_col1_g 0x41 +#define IBMRGB_curs_col1_b 0x42 +#define IBMRGB_curs_col2_r 0x43 +#define IBMRGB_curs_col2_g 0x44 +#define IBMRGB_curs_col2_b 0x45 +#define IBMRGB_curs_col3_r 0x46 +#define IBMRGB_curs_col3_g 0x47 +#define IBMRGB_curs_col3_b 0x48 +#define IBMRGB_border_col_r 0x60 +#define IBMRGB_border_col_g 0x61 +#define IBMRGB_botder_col_b 0x62 +#define IBMRGB_misc1 0x70 +#define IBMRGB_misc2 0x71 +#define IBMRGB_misc3 0x72 +#define IBMRGB_misc4 0x73 /* not RGB525 */ +#define IBMRGB_dac_sense 0x82 +#define IBMRGB_misr_r 0x84 +#define IBMRGB_misr_g 0x86 +#define IBMRGB_misr_b 0x88 +#define IBMRGB_pll_vco_div_in 0x8e +#define IBMRGB_pll_ref_div_in 0x8f +#define IBMRGB_vram_mask_0 0x90 +#define IBMRGB_vram_mask_1 0x91 +#define IBMRGB_vram_mask_2 0x92 +#define IBMRGB_vram_mask_3 0x93 +#define IBMRGB_curs_array 0x100 + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile:1.5 xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile:1.5 Thu Mar 2 20:05:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile Wed Oct 11 12:18:32 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile,v 1.5 2000/03/03 01:05:38 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/Imakefile,v 1.6 2000/10/11 16:18:32 mvojkovi Exp $ XCOMM XCOMM This is the Imakefile for the i740 driver. XCOMM @@ -20,7 +20,7 @@ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(SERVERSRC)/Xext -I$(XF86OSSRC)/vbe \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(EXTINCSRC) -I$(XF86SRC)/int10 + -I$(EXTINCSRC) -I$(XF86SRC)/int10 -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp:1.4 Tue Jun 13 22:13:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp Mon Dec 11 15:18:15 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp,v 1.4 2000/06/14 02:13:10 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp,v 1.5 2000/12/11 20:18:15 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH I740 __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH I740 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME i740 \- Intel i740 video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c:1.21 xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c:1.26 --- xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c:1.21 Wed Jun 21 13:28:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c Sat Dec 2 10:30:41 2000 @@ -25,7 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c,v 1.21 2000/06/21 17:28:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c,v 1.26 2000/12/02 15:30:41 tsi Exp $ */ /* * Authors: @@ -291,8 +291,8 @@ */ LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, xf8_32bppSymbols, ramdacSymbols, vbeSymbols, - 0 /* ddcsymbols */, 0 /* i2csymbols */, 0 /* shadowSymbols */, - 0 /* fbdevsymbols */, NULL); + NULL /* ddcsymbols */, NULL /* i2csymbols */, NULL /* shadowSymbols */, + NULL /* fbdevsymbols */, NULL); /* * The return value must be non-NULL on success even though there @@ -359,7 +359,7 @@ static Bool I740Probe(DriverPtr drv, int flags) { int i, numUsed, numDevSections, *usedChips; - GDevPtr *devSections = NULL; + GDevPtr *devSections; Bool foundScreen = FALSE; /* @@ -439,8 +439,8 @@ } } - if (devSections) - xfree(devSections); + xfree(devSections); + xfree(usedChips); return foundScreen; } @@ -1447,7 +1447,7 @@ hwp = VGAHWPTR(pScrn); if (!I740MapMem(pScrn)) return FALSE; - pScrn->memPhysBase = (int)pI740->FbBase; + pScrn->memPhysBase = (unsigned long)pI740->FbBase; pScrn->fbOffset = 0; if (!pI740->usePIO) @@ -1521,6 +1521,7 @@ miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); @@ -1664,8 +1665,11 @@ hwp = VGAHWPTR(pScrn); pI740 = I740PTR(pScrn); - I740Restore(pScrn); - vgaHWLock(hwp); + if (pScrn->vtSema) { + I740Restore(pScrn); + vgaHWLock(hwp); + } + I740UnmapMem(pScrn); vgaHWUnmapMem(pScrn); if (pI740->AccelInfoRec) Index: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile:1.9 xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile:1.9 Fri Jun 30 13:15:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile Tue Sep 19 20:09:21 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.9 2000/06/30 17:15:11 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.13 2000/09/20 00:09:21 keithp Exp $ XCOMM XCOMM This is the Imakefile for the i810 driver. XCOMM @@ -15,10 +15,10 @@ #endif SRCS = i810_driver.c i810_cursor.c i810_accel.c i810_io.c \ - i810_memory.c i810_wmark.c i810_dga.c $(DRISRCS) + i810_memory.c i810_wmark.c i810_dga.c i810_video.c $(DRISRCS) OBJS = i810_driver.o i810_cursor.o i810_accel.o i810_io.o \ - i810_memory.o i810_wmark.o i810_dga.o $(DRIOBJS) + i810_memory.o i810_wmark.o i810_dga.o i810_video.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -26,11 +26,12 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86OSSRC)/vbe -I$(XF86SRC)/int10 \ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(EXTINCSRC) \ + -I$(EXTINCSRC) -I$(SERVERSRC)/render \ $(DRIINCLUDES) #endif DEFINES = $(DRIDEFINES) Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp:1.4 Tue Jun 13 22:13:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp Mon Dec 11 15:18:17 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp,v 1.4 2000/06/14 02:13:10 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp,v 1.6 2000/12/11 20:18:17 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH I810 __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH I810 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME i810 \- Intel i810 video driver .SH SYNOPSIS @@ -14,17 +14,58 @@ .fi .SH DESCRIPTION .B i810 -is an XFree86 driver for Intel i810 video cards. -THIS MAN PAGE NEEDS TO BE FILLED IN. +is an XFree86 driver for the Intel i810 family of graphics chipsets. +The driver supports depths 8, 15, 16 and 24. All visual types are +supported in depth 8, other depths only support TrueColor. The driver +supports hardware accelerated 3D via the Direct Rendering Infrastructure (DRI), +but only in depth 16. .SH SUPPORTED HARDWARE -The .B i810 -driver supports... +supports the i810, i810-DC100, i810e and i815 chipsets. + .SH CONFIGURATION DETAILS Please refer to XF86Config(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this driver. +.PP +The i810 has a unified memory architecture and uses system memory +for video ram. By default 8 Megabytes of system memory are used +for graphics. This amount may be changed with the +.B VideoRam +entry in the config file +.B "Device" +section. It may be set to any power of two between 4 and 32 Megabytes +inclusive to allow the user to customize the balance between main +memory usage and graphics performance. Too little memory reserved for +graphics can result in decreased 3D and 2D graphics performance and +features. +.PP +The following driver +.B Options +are supported +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Disable or enable acceleration. Default: acceleration is enabled. +.TP +.BI "Option \*qSWCursor\*q \*q" boolean \*q +Disable or enable software cursor. Default: software cursor is disable +and a hardware cursor is used. +.TP +.BI "Option \*qColorKey\*q \*q" integer \*q +This sets the default pixel value for the YUV video overlay key. +Default: undefined. +.TP +.BI "Option \*qCacheLines\*q \*q" integer \*q +This allows the user to change the amount of graphics memory used for +2D acceleration and video. Decreasing this amount leaves more for 3D +textures. Increasing it can improve 2D performance at the expense of +3D performance. +Default: 256 to 768 depending on the resolution and depth. + + + .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) .SH AUTHORS -Authors include: ... +Authors include: Keith Whitwell, and also Jonathan Bian, Matthew J Sottek, +Jeff Hartmann, Mark Vojkovich, Alan Hourihane, H. J. Lu. Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h:1.9 xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h:1.9 Thu Jun 22 13:44:03 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h Fri Dec 1 09:28:56 2000 @@ -25,7 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v 1.9 2000/06/22 17:44:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v 1.19 2000/12/01 14:28:56 dawes Exp $ */ /* * Authors: @@ -36,12 +36,14 @@ #ifndef _I810_H_ #define _I810_H_ +#include "xf86_ansic.h" #include "compiler.h" #include "xf86PciInfo.h" #include "xf86Pci.h" #include "i810_reg.h" #include "xaa.h" #include "xf86Cursor.h" +#include "xf86xv.h" #ifdef XF86DRI #include "xf86drm.h" @@ -124,6 +126,10 @@ unsigned int Fence[8]; + unsigned short OverlayActiveStart; + unsigned short OverlayActiveEnd; + + } I810RegRec, *I810RegPtr; typedef struct _I810Rec { @@ -142,14 +148,17 @@ I810MemRange TexMem; I810MemRange Scratch; I810MemRange BufferMem; - + int auxPitch; int auxPitchBits; int CursorOffset; - int CursorPhysical; - int CursorStart; + unsigned long CursorPhysical; + unsigned long CursorStart; + unsigned long OverlayPhysical; + unsigned long OverlayStart; + int colorKey; DGAModePtr DGAModes; int numDGAModes; @@ -157,8 +166,8 @@ int DGAViewportStatus; int Chipset; - int LinearAddr; - int MMIOAddr; + unsigned long LinearAddr; + unsigned long MMIOAddr; EntityInfoPtr pEnt; pciVideoPtr PciInfo; PCITAG PciTag; @@ -166,8 +175,16 @@ I810RingBuffer LpRing; unsigned int BR[20]; - int gartfd; int LmFreqSel; + + int VramKey; + unsigned long VramOffset; + int DcacheKey; + unsigned long DcacheOffset; + int HwcursKey; + unsigned long HwcursOffset; + + int GttBound; I810MemRange DcacheMem; I810MemRange SysMem; @@ -184,7 +201,8 @@ XAAInfoRecPtr AccelInfoRec; xf86CursorInfoPtr CursorInfoRec; CloseScreenProcPtr CloseScreen; - + ScreenBlockHandlerProcPtr BlockHandler; + I810WriteIndexedByteFunc writeControl; I810ReadIndexedByteFunc readControl; I810WriteByteFunc writeStandard; @@ -207,8 +225,11 @@ Bool agpAcquired; drmHandle buffer_map; drmHandle ring_map; + drmHandle overlay_map; #endif Bool agpAcquired2d; + + XF86VideoAdaptorPtr adaptor; } I810Rec; #define I810PTR(p) ((I810Ptr)((p)->driverPrivate)) @@ -246,6 +267,11 @@ extern int I810AllocateGARTMemory( ScrnInfoPtr pScrn ); extern void I810FreeGARTMemory( ScrnInfoPtr pScrn ); +extern Bool I810BindGARTMemory( ScrnInfoPtr pScrn ); +extern Bool I810UnbindGARTMemory( ScrnInfoPtr pScrn ); + +extern int I810CheckAvailableMemory(ScrnInfoPtr pScrn); + extern Bool I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); extern void I810AdjustFrame(int scrnIndex, int x, int y, int flags); @@ -267,7 +293,10 @@ extern void I810EmitFlush(ScrnInfoPtr pScrn); extern void I810EmitInvarientState(ScrnInfoPtr pScrn); +extern Bool I810DGAInit(ScreenPtr pScreen); +extern void I810InitVideo(ScreenPtr pScreen); + #define minb(p) *(volatile CARD8 *)(pI810->MMIOBase + (p)) #define moutb(p,v) *(volatile CARD8 *)(pI810->MMIOBase + (p)) = (v) @@ -284,6 +313,14 @@ OUTREG(LP_RING + RING_TAIL, outring); \ } +#ifdef __GNUC__ +#define LP_RING_MESSAGE(n) \ + ErrorF("BEGIN_LP_RING %d in %s\n", n, __FUNCTION__) +#else +#define LP_RING_MESSAGE(n) \ + ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__) +#endif + #define BEGIN_LP_RING(n) \ unsigned int outring, ringmask; \ volatile unsigned char *virt; \ @@ -291,7 +328,7 @@ if (pI810->LpRing.space < n*4) I810WaitLpRing( pScrn, n*4, 0); \ pI810->LpRing.space -= n*4; \ if (I810_DEBUG & DEBUG_VERBOSE_RING) \ - ErrorF( "BEGIN_LP_RING %d in %s\n", n, __FUNCTION__); \ + LP_RING_MESSAGE(n); \ outring = pI810->LpRing.tail; \ ringmask = pI810->LpRing.tail_mask; \ virt = pI810->LpRing.virtual_start; Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c:1.5 Sat Jun 17 14:23:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c Fri Sep 15 19:25:48 2000 @@ -25,7 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c,v 1.5 2000/06/17 18:23:23 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c,v 1.11 2000/09/15 23:25:48 mvojkovi Exp $ */ /* * Authors: @@ -99,8 +99,6 @@ static void I810SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); - - /* The following function sets up the supported acceleration. Call it * from the FbInit() function in the SVGA driver, or before ScreenInit * in a monolithic server. @@ -115,20 +113,15 @@ if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) ErrorF( "I810AccelInit\n"); - if (pScrn->depth == 32) - return FALSE; - pI810->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; pI810->bufferOffset = 0; - infoPtr->Flags = LINEAR_FRAMEBUFFER; - - /* In 24bpp mode, XAA seems to want to manage offscreen pixmaps as - * 32bpp even though we've said we can't support that format. - */ - if (pScrn->depth != 24) - infoPtr->Flags |= (PIXMAP_CACHE | OFFSCREEN_PIXMAPS); + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; + /* There is a bit blt bug in 24 bpp. This is a problem, but + at least without the pixmap cache we can pass the test suite */ + if(pScrn->depth != 24) + infoPtr->Flags |= PIXMAP_CACHE; /* Sync */ @@ -193,7 +186,6 @@ NO_PLANEMASK | ROP_NEEDS_SOURCE | BIT_ORDER_IN_BYTE_MSBFIRST | - HARDWARE_PATTERN_SCREEN_ORIGIN | 0); infoPtr->ScanlineColorExpandBuffers = (unsigned char **) @@ -523,7 +515,6 @@ } - static void I810SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, @@ -537,7 +528,8 @@ "I810SubsequentScanlineCPUToScreenColorExpandFill " "%d,%d %dx%x %d\n", x,y,w,h,skipleft); - + + pI810->BR[0] = BR00_BITBLT_CLIENT | BR00_OP_MONO_SRC_COPY_BLT | 0x06; pI810->BR[9] = (pI810->bufferOffset + (y * pScrn->displayWidth + x) * pI810->cpp); pI810->BR[14] = ( (1 << 16) | (w * pI810->cpp)); @@ -561,10 +553,7 @@ { BEGIN_LP_RING( 8 ); - OUT_RING( BR00_BITBLT_CLIENT | - BR00_OP_MONO_SRC_COPY_BLT | - 0x6 ); - + OUT_RING( pI810->BR[0]); OUT_RING( pI810->BR[13]); OUT_RING( pI810->BR[14] ); OUT_RING( pI810->BR[9] ); Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c:1.1 Thu Jun 22 13:44:03 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c Sun Sep 17 19:18:19 2000 @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c,v 1.1 2000/06/22 17:44:03 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c,v 1.2 2000/09/17 23:18:19 mvojkovi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -33,6 +33,7 @@ #include "i810.h" #include "i810_reg.h" #include "dgaproc.h" +#include "vgaHW.h" static Bool I810_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, int *, int *, int *); @@ -71,34 +72,26 @@ DisplayModePtr pMode, firstMode; int Bpp = pScrn->bitsPerPixel >> 3; int num = 0; - Bool oneMore; pMode = firstMode = pScrn->modes; while(pMode) { - if(0 /*pScrn->displayWidth != pMode->HDisplay*/) { - newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec)); - oneMore = TRUE; - } else { - newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - } + newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); - if(!newmodes) { + if(!newmodes) { xfree(modes); return FALSE; } modes = newmodes; -SECOND_PASS: - currentMode = modes + num; num++; currentMode->mode = pMode; currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; + if(pI810->AccelInfoRec) + currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; if(pMode->Flags & V_DBLSCAN) currentMode->flags |= DGA_DOUBLESCAN; if(pMode->Flags & V_INTERLACE) @@ -112,38 +105,23 @@ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; currentMode->viewportWidth = pMode->HDisplay; currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = 1; + currentMode->xViewportStep = (Bpp == 3) ? 2 : 1; currentMode->yViewportStep = 1; currentMode->viewportFlags = DGA_FLIP_RETRACE; currentMode->offset = 0; currentMode->address = pI810->FbBase; - if(oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = + currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 3) & ~3L; - currentMode->imageWidth = pScrn->displayWidth; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - + currentMode->imageWidth = pI810->FbMemBox.x2; + currentMode->imageHeight = pI810->FbMemBox.y2; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - currentMode->viewportHeight; - } pMode = pMode->next; if(pMode == firstMode) @@ -157,32 +135,29 @@ } +static DisplayModePtr I810SavedDGAModes[MAXSCREENS]; + static Bool I810_SetMode( ScrnInfoPtr pScrn, DGAModePtr pMode ){ - static int OldDisplayWidth[MAXSCREENS]; int index = pScrn->pScreen->myNum; I810Ptr pI810 = I810PTR(pScrn); if(!pMode) { /* restore the original mode */ - /* put the ScreenParameters back */ - - pScrn->displayWidth = OldDisplayWidth[index]; - - I810SwitchMode(index, pScrn->currentMode, 0); - pI810->DGAactive = FALSE; + if(pI810->DGAactive) { + pScrn->currentMode = I810SavedDGAModes[index]; + I810SwitchMode(index, pScrn->currentMode, 0); + I810AdjustFrame(index, 0, 0, 0); + pI810->DGAactive = FALSE; + } } else { - if(!pI810->DGAactive) { /* save the old parameters */ - OldDisplayWidth[index] = pScrn->displayWidth; - + if(!pI810->DGAactive) { + I810SavedDGAModes[index] = pScrn->currentMode; pI810->DGAactive = TRUE; } - pScrn->displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - I810SwitchMode(index, pMode->mode, 0); } @@ -205,9 +180,15 @@ int flags ){ I810Ptr pI810 = I810PTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); I810AdjustFrame(pScrn->pScreen->myNum, x, y, flags); - pI810->DGAViewportStatus = 0; /* I810AdjustFrame loops until finished */ + + /* wait for retrace */ + while((hwp->readST01(hwp) & 0x08)); + while(!(hwp->readST01(hwp) & 0x08)); + + pI810->DGAViewportStatus = 0; } static void Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c:1.6 Fri Jun 23 19:43:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c Fri Dec 1 09:28:56 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.6 2000/06/23 23:43:44 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.13 2000/12/01 14:28:56 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -7,13 +7,8 @@ #include "xf86PciInfo.h" #include "xf86Pci.h" -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb32.h" -#include "miline.h" +#include "windowstr.h" #include "GL/glxtokens.h" @@ -140,7 +135,7 @@ depth = 1; for (accum = 0; accum <= 1; accum++) { for (stencil = 0; stencil <= 1; stencil++) { - for (db = 0; db <= 1; db++) { + for (db = 1; db >= 0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; @@ -176,7 +171,7 @@ pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil) + if (stencil || accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -226,7 +221,8 @@ int i; /* Hardware 3D rendering only implemented for 16bpp */ - if (pScrn->bitsPerPixel != 16) + /* And it only works for 5:6:5 (Mark) */ + if (pScrn->depth != 16) return FALSE; /* Check that the GLX, DRI, and DRM modules have been loaded by testing @@ -332,7 +328,7 @@ drmVersionPtr version = drmGetVersion(pI810->drmSubFD); if (version) { if (version->version_major != 1 || - version->version_minor != 0 || + version->version_minor != 1 || version->version_patchlevel < 0) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, @@ -562,6 +558,16 @@ pI810->CursorPhysical = 0; } + /* Steal some of the excess cursor space for the overlay regs, + * then allocate 202*2 pages for the overlay buffers. + */ + pI810->OverlayPhysical = pI810->CursorPhysical + 1024; + pI810->OverlayStart = pI810->CursorStart + 1024; + + /* drmAddMap happens later to preserve index order */ + + + I810SetTiledMemory(pScrn, 1, pI810->DepthBuffer.Start, i810_pitches[pitch_idx], @@ -595,7 +601,10 @@ } /* Allocate FrontBuffer etc. */ - I810AllocateFront(pScrn); + if (!I810AllocateFront(pScrn)) { + DRICloseScreen(pScreen); + return FALSE; + } /* Allocate buffer memory */ I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem), @@ -674,6 +683,7 @@ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] added %d %d byte DMA buffers\n", bufs, I810_DMA_BUF_SZ); + I810InitDma(pScrn); /* Okay now initialize the dma engine */ @@ -843,9 +853,6 @@ I810SetupForSolidFill(pScrn, 0, GXcopy, -1); while (nbox--) { - I810SelectBuffer(pScrn, I810_FRONT); - I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, - pbox->x2-pbox->x1, pbox->y2-pbox->y1); I810SelectBuffer(pScrn, I810_BACK); I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, pbox->x2-pbox->x1, pbox->y2-pbox->y1); Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c:1.15 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c:1.39 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c:1.15 Thu Jun 22 13:44:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c Sat Dec 2 10:30:42 2000 @@ -25,7 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v 1.15 2000/06/22 17:44:04 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v 1.39 2000/12/02 15:30:42 tsi Exp $ */ /* * Authors: @@ -57,17 +57,11 @@ #include "micmap.h" -#define PSZ 8 -#include "cfb.h" -#undef PSZ - -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" #include "miscstruct.h" #include "xf86xv.h" #include "Xv.h" +#include "vbe.h" #include "i810.h" @@ -78,6 +72,7 @@ /* Required Functions: */ static void I810Identify(int flags); +static OptionInfoPtr I810AvailableOptions(int chipid, int busid); static Bool I810Probe(DriverPtr drv, int flags); static Bool I810PreInit(ScrnInfoPtr pScrn, int flags); static Bool I810ScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); @@ -100,6 +95,7 @@ "Accelerated driver for Intel i810 cards", I810Identify, I810Probe, + I810AvailableOptions, NULL, 0 }; @@ -124,13 +120,19 @@ typedef enum { OPTION_NOACCEL, OPTION_SW_CURSOR, - OPTION_DAC_6BIT + OPTION_COLOR_KEY, + OPTION_CACHE_LINES, + OPTION_DAC_6BIT, + OPTION_DRI } I810Opts; static OptionInfoRec I810Options[] = { { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE }, + { OPTION_CACHE_LINES, "CacheLines", OPTV_INTEGER, {0}, FALSE}, { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE}, + { OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE}, { -1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -151,20 +153,11 @@ 0 }; -static const char *cfbSymbols[] = { - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", - "cfb8_32ScreenInit", - "cfb24_32ScreenInit", +static const char *fbSymbols[] = { + "fbScreenInit", NULL }; -static const char *xf8_32bppSymbols[] = { - "xf86Overlay8Plus32Init", - NULL -}; static const char *miscSymbols[] = { "GetTimeInMillis", @@ -190,12 +183,6 @@ NULL }; -/* - * This is intentionally screen-independent. It indicates the binding - * choice made in the first PreInit. - */ -static int pix24bpp = 0; - #ifdef XF86DRI static const char *drmSymbols[] = { "drmAvailable", @@ -295,19 +282,18 @@ * might refer to. */ LoaderRefSymLists(vgahwSymbols, - cfbSymbols, + fbSymbols, xaaSymbols, - xf8_32bppSymbols, ramdacSymbols, miscSymbols, #ifdef XF86DRI drmSymbols, driSymbols, #endif - 0 /* ddcsymbols */, - 0 /* i2csymbols */, - 0 /* shadowSymbols */, - 0 /* fbdevsymbols */, + NULL /* ddcsymbols */, + NULL /* i2csymbols */, + NULL /* shadowSymbols */, + NULL /* fbdevsymbols */, NULL); /* @@ -358,6 +344,12 @@ xf86PrintChipsets(I810_NAME, "Driver for Intel i810 chipset", I810Chipsets); } +static +OptionInfoPtr +I810AvailableOptions(int chipid, int busid) +{ + return I810Options; +} /* * I810Probe -- * @@ -369,7 +361,7 @@ I810Probe(DriverPtr drv, int flags) { int i, numUsed, numDevSections, *usedChips; GDevPtr *devSections; - Bool foundScreen = 0; + Bool foundScreen = FALSE; /* Find the config file Device sections that match this @@ -391,6 +383,10 @@ devSections, numDevSections, drv, &usedChips); + if (flags & PROBE_DETECT) { + if (numUsed > 0) + foundScreen = TRUE; + } else for (i=0; i<numUsed; i++) { ScrnInfoPtr pScrn = NULL; /* Allocate new ScrnInfoRec and claim the slot */ @@ -411,13 +407,23 @@ foundScreen = TRUE; } } - if (numUsed) xfree(usedChips); + xfree(usedChips); xfree(devSections); return foundScreen; } +static void +I810ProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + /* * I810PreInit -- * @@ -432,9 +438,9 @@ ClockRangePtr clockRanges; int i; MessageType from; - char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; + int mem; if (pScrn->numEntities != 1) return FALSE; @@ -454,6 +460,11 @@ pI810->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pI810->pEnt->location.type != BUS_PCI) return FALSE; + if (flags & PROBE_DETECT) { + I810ProbeDDC(pScrn, pI810->pEnt->index); + return TRUE; + } + pI810->PciInfo = xf86GetPciInfoForEntity(pI810->pEnt->index); pI810->PciTag = pciTag(pI810->PciInfo->bus, pI810->PciInfo->device, pI810->PciInfo->func); @@ -465,14 +476,13 @@ /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; - /* No support for 32bpp. - */ flags24=Support24bppFb | PreferConvert32to24 | SupportConvert32to24; if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) { return FALSE; } else { switch (pScrn->depth) { case 8: + case 15: case 16: case 24: break; @@ -485,9 +495,17 @@ } xf86PrintDepthBpp(pScrn); - /* Get the depth24 pixmap format */ - if (pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); + switch (pScrn->bitsPerPixel) { + case 8: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given bpp (%d) is not supported by i810 driver\n", + pScrn->bitsPerPixel); + return FALSE; + } pScrn->rgbBits=8; if (xf86ReturnOptValBool(I810Options, OPTION_DAC_6BIT, FALSE)) @@ -500,7 +518,7 @@ return FALSE; /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + if ((pScrn->depth > 8) && (pScrn->defaultVisual != TrueColor)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" " (%s) is not supported at depth %d\n", xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); @@ -608,14 +626,34 @@ /* Default to 4MB framebuffer, which is sufficient for all * supported 2d resolutions. If the user has specified a different * size in the XF86Config, use that amount instead. + * + * Changed to 8 Meg so we can have acceleration by default (Mark). */ - pScrn->videoRam = 4096; - from = X_PROBED; + pScrn->videoRam = 8192; + from = X_DEFAULT; if (pI810->pEnt->device->videoRam) { pScrn->videoRam = pI810->pEnt->device->videoRam; from = X_CONFIG; } + mem = I810CheckAvailableMemory(pScrn); + if (mem > 0 && mem < pScrn->videoRam) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "%dk of memory was requested," + " but the\n\t maximum AGP memory available is %dk.\n", + pScrn->videoRam, mem); + from = X_PROBED; + if (mem > (6 * 1024)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Reducing video memory to 4MB\n"); + pScrn->videoRam = 4096; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Less than 6MB of AGP memory" + "is available. Cannot proceed.\n"); + I810FreeRec(pScrn); + return FALSE; + } + } + xf86DrvMsg(pScrn->scrnIndex, from, "Will alloc AGP framebuffer: %d kByte\n", pScrn->videoRam); @@ -647,7 +685,7 @@ case 24: pI810->MaxClock = pI810->pEnt->device->dacSpeeds[DAC_BPP24]; break; - case 32: + case 32: /* not supported */ pI810->MaxClock = pI810->pEnt->device->dacSpeeds[DAC_BPP32]; break; } @@ -665,7 +703,7 @@ case 24: pI810->MaxClock = 136000; break; - case 32: + case 32: /* not supported */ pI810->MaxClock = 86000; } } @@ -709,34 +747,11 @@ xf86SetDpi(pScrn, 0, 0); - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - break; - case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - reqSym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - reqSym = "cfb24_32ScreenInit"; - } - break; - case 32: - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - break; - } - if (mod && !xf86LoadSubModule(pScrn, mod)) { + if (!xf86LoadSubModule(pScrn, "fb")) { I810FreeRec(pScrn); return FALSE; } - xf86LoaderReqSymbols(reqSym, NULL); + xf86LoaderReqSymbols("fbScreenInit", NULL); if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE)) { if (!xf86LoadSubModule(pScrn, "xaa")) { @@ -753,6 +768,16 @@ xf86LoaderReqSymLists(ramdacSymbols, NULL); } + if (xf86GetOptValInteger(I810Options, OPTION_COLOR_KEY, &(pI810->colorKey))) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video overlay key set to 0x%x\n", + pI810->colorKey); + } else { + pI810->colorKey = (1 << pScrn->offset.red) | + (1 << pScrn->offset.green) | + (((pScrn->mask.blue >> pScrn->offset.blue) - 1) << pScrn->offset.blue); + } + /* We wont be using the VGA access after the probe */ { resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB}, @@ -1101,6 +1126,10 @@ pI810->writeControl(pI810, GRX, ADDRESS_MAPPING, temp); + /* Setting the OVRACT Register for video overlay*/ + OUTREG(0x6001C, (i810Reg->OverlayActiveEnd << 16) | i810Reg->OverlayActiveStart); + + /* Turn on DRAM Refresh */ @@ -1132,6 +1161,7 @@ temp = INREG8( PIXPIPE_CONFIG_1 ); temp &= ~DISPLAY_COLOR_MODE; + temp &= 0xEF; /* Restore the CRT control bit */ temp |= i810Reg->PixelPipeCfg1; OUTREG8( PIXPIPE_CONFIG_1, temp ); @@ -1278,7 +1308,7 @@ i810Reg->VideoClk2_N = (n_best-2) & 0x3FF; i810Reg->VideoClk2_DivisorSel = (p_best << 4); - ErrorF("Setting dot clock to %.1lf MHz " + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting dot clock to %.1lf MHz " "[ 0x%x 0x%x 0x%x ] " "[ %d %d %d ]\n", CALC_VCLK(m_best,n_best,p_best), @@ -1296,7 +1326,7 @@ vgaRegPtr pVga = &VGAHWPTR(pScrn)->ModeReg; double dclk = mode->Clock/1000.0; - switch (pScrn->depth) { + switch (pScrn->bitsPerPixel) { case 8: pVga->CRTC[0x13] = pScrn->displayWidth >> 3; i810Reg->ExtOffset = pScrn->displayWidth >> 11; @@ -1314,24 +1344,12 @@ i810Reg->BitBLTControl = COLEXP_16BPP; break; case 24: - if (pScrn->bitsPerPixel == 24) { - pVga->CRTC[0x13] = (pScrn->displayWidth * 3) >> 3; - i810Reg->ExtOffset = (pScrn->displayWidth * 3) >> 11; - } else { - /* never happens */ - pVga->CRTC[0x13] = pScrn->displayWidth >> 1; - i810Reg->ExtOffset = pScrn->displayWidth >> 9; - } + pVga->CRTC[0x13] = (pScrn->displayWidth * 3) >> 3; + i810Reg->ExtOffset = (pScrn->displayWidth * 3) >> 11; + i810Reg->PixelPipeCfg1 = DISPLAY_24BPP_MODE; i810Reg->BitBLTControl = COLEXP_24BPP; break; - case 32: - /* never happens */ - pVga->CRTC[0x13] = pScrn->displayWidth >> 1; - i810Reg->ExtOffset = pScrn->displayWidth >> 9; - i810Reg->PixelPipeCfg1 = DISPLAY_32BPP_MODE; - i810Reg->BitBLTControl = COLEXP_RESERVED; /* Not implemented on i810 */ - break; default: break; } @@ -1342,6 +1360,8 @@ else i810Reg->PixelPipeCfg0 = DAC_8_BIT; + /* Do not delay CRT Blank: needed for video overlay */ + i810Reg->PixelPipeCfg1 |= 0x10; /* Turn on Extended VGA Interpretation */ i810Reg->IOControl = EXTENDED_CRTC_CNTL; @@ -1362,6 +1382,24 @@ i810Reg->ExtHorizTotal = ((mode->CrtcHTotal >> 3) - 5) >> 8; i810Reg->ExtHorizBlank = (((mode->CrtcHBlankEnd >> 3) - 1) & 0x40) >> 6; + /* + * The following workarounds are needed to get video overlay working + * at 1024x768 and 1280x1024 display resolutions. + */ + if ((mode->CrtcVDisplay == 768) && (i810Reg->ExtVertBlankStart == 3)) + { + i810Reg->ExtVertBlankStart = 2; + } + if ((mode->CrtcVDisplay == 1024) && (i810Reg->ExtVertBlankStart == 4)) + { + i810Reg->ExtVertBlankStart = 3; + } + + /* OVRACT Register */ + i810Reg->OverlayActiveStart = mode->CrtcHTotal - 32; + i810Reg->OverlayActiveEnd = mode->CrtcHDisplay - 32; + + /* Turn on interlaced mode if necessary */ if (mode->Flags & V_INTERLACE) i810Reg->InterlaceControl = INTERLACE_ENABLE; @@ -1505,6 +1543,7 @@ Bool I810AllocateFront(ScrnInfoPtr pScrn) { I810Ptr pI810 = I810PTR(pScrn); + int cache_lines = -1; if(pI810->DoneFrontAlloc) return TRUE; @@ -1515,22 +1554,44 @@ pI810->FbMemBox.x2=pScrn->displayWidth; pI810->FbMemBox.y1=0; pI810->FbMemBox.y2=pScrn->virtualY; - - /* Make sure there is room for pixcache either beside or below - * the screen. - */ - if (pScrn->displayWidth < pScrn->virtualX + 64) - pI810->FbMemBox.y2 += 64; + xf86GetOptValInteger(I810Options, OPTION_CACHE_LINES, &cache_lines); + + if (cache_lines < 0) { + /* make sure there is enough for two DVD sized YUV buffers */ + cache_lines = (pScrn->depth == 24) ? 256 : 384; + if (pScrn->displayWidth <= 1024) + cache_lines *= 2; + } + /* Make sure there's enough space for cache_lines. */ + { + int maxCacheLines; + + maxCacheLines = ((pScrn->videoRam - 256) * 1024 / + (pScrn->bitsPerPixel / 8) / + pScrn->displayWidth) - pScrn->virtualY; + if (maxCacheLines >= 0 && cache_lines > maxCacheLines) + cache_lines = maxCacheLines; + } + pI810->FbMemBox.y2 += cache_lines; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Adding %i scanlines for pixmap caching\n", cache_lines); + /* Reserve room for the framebuffer and pixcache. Put at the top * of memory so we can have nice alignment for the tiled regions at * the start of memory. */ - I810AllocLow( &(pI810->FrontBuffer), + + if (!I810AllocLow( &(pI810->FrontBuffer), &(pI810->SysMem), ((pI810->FbMemBox.x2 * pI810->FbMemBox.y2 * - pI810->cpp) + 4095) & ~4095); + pI810->cpp) + 4095) & ~4095)) { + xf86DrvMsg(pScrn->scrnIndex, + X_WARNING, "Framebuffer allocation failed\n"); + return FALSE; + } memset( &(pI810->LpRing), 0, sizeof( I810RingBuffer ) ); if(I810AllocLow( &(pI810->LpRing.mem), &(pI810->SysMem), 16*4096 )) { @@ -1570,9 +1631,18 @@ miClearVisualTypes(); - if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), +#if 1 /* disable DirectColor */ + if(pScrn->depth > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } else +#endif + { + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + return FALSE; + } { I810RegPtr i810Reg = &pI810->ModeReg; @@ -1595,21 +1665,24 @@ * InitGLXVisuals call back. */ - if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE)) { + if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE) && + xf86ReturnOptValBool(I810Options, OPTION_DRI, TRUE)) { pI810->directRenderingEnabled = I810DRIScreenInit(pScreen); } else { pI810->directRenderingEnabled = FALSE; } #else + pI810->directRenderingEnabled = FALSE; if (!I810AllocateGARTMemory( pScrn )) - return FALSE; - I810AllocateFront(pScrn); + return FALSE; + if (!I810AllocateFront(pScrn)) + return FALSE; #endif if (!I810MapMem(pScrn)) return FALSE; - pScrn->memPhysBase = (int)pI810->FbBase; + pScrn->memPhysBase = (unsigned long)pI810->FbBase; pScrn->fbOffset = 0; vgaHWSetMmioFuncs(hwp, pI810->MMIOBase, 0); @@ -1622,75 +1695,80 @@ I810SaveScreen(pScreen, FALSE); I810AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - switch (pScrn->bitsPerPixel) { - case 8: - if (!cfbScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - break; - case 16: - if (!cfb16ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - break; - case 24: - if (pix24bpp == 24) { - if (!cfb24ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, - pScrn->virtualX, pScrn->virtualY, + if(!fbScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, + pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - } else { - if (!cfb24_32ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - } - break; - case 32: - if (!cfb32ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in I810ScrnInit\n", - pScrn->bitsPerPixel); - return FALSE; + pScrn->displayWidth, pScrn->bitsPerPixel)) + return FALSE; + + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } } xf86SetBlackWhitePixels(pScreen); +#ifdef XF86DRI + if (pI810->LpRing.mem.Start == 0 && pI810->directRenderingEnabled) { + pI810->directRenderingEnabled = 0; + I810DRICloseScreen(pScreen); + } + + if (!pI810->directRenderingEnabled) { + pI810->DoneFrontAlloc = FALSE; + if (!I810AllocateGARTMemory( pScrn )) + return FALSE; + if (!I810AllocateFront(pScrn)) + return FALSE; + } +#endif + I810DGAInit(pScreen); + + if (!xf86InitFBManager(pScreen, &(pI810->FbMemBox))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to init memory manager\n"); + return FALSE; + } + + if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE)) { + if (pI810->LpRing.mem.Size != 0) { + I810SetRingRegs( pScrn ); - if (pScrn->bitsPerPixel>8) { - visual = pScreen->visuals + pScreen->numVisuals; - while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } + if (!I810AccelInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware acceleration initialization failed\n"); + } } } miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + if (!xf86ReturnOptValBool(I810Options, OPTION_SW_CURSOR, FALSE)) { + if (!I810CursorInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + } + } + if (!miCreateDefColormap(pScreen)) return FALSE; +#if 0 /* palettes do not work */ if (pScrn->bitsPerPixel==16) { if (!xf86HandleColormaps(pScreen, 256, 8, I810LoadPalette16, 0, CMAP_PALETTED_TRUECOLOR| @@ -1702,65 +1780,18 @@ CMAP_RELOAD_ON_MODE_SWITCH)) return FALSE; } +#else + if (!vgaHWHandleColormaps(pScreen)) + return FALSE; +#endif #ifdef DPMSExtension xf86DPMSInit(pScreen, I810DisplayPowerManagementSet, 0); #endif - - - -#ifdef XvExtension - { - XF86VideoAdaptorPtr *ptr; - int n; - - n = xf86XVListGenericAdaptors(pScrn, &ptr); - if (n) { - xf86XVScreenInit(pScreen, ptr, n); - } - } -#endif - -#ifdef XF86DRI - if (!pI810->directRenderingEnabled) { - pI810->DoneFrontAlloc = FALSE; - if (!I810AllocateGARTMemory( pScrn )) - return FALSE; - I810AllocateFront(pScrn); - } -#endif - - - if (!xf86InitFBManager(pScreen, &(pI810->FbMemBox))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Failed to init memory manager\n"); - return FALSE; - } - - if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE)) { - if (pI810->LpRing.mem.Size != 0) { - I810SetRingRegs( pScrn ); - - if (!I810AccelInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Hardware acceleration initialization failed\n"); - } - } - } - if (!xf86ReturnOptValBool(I810Options, OPTION_SW_CURSOR, FALSE)) { - if (!I810CursorInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - } - } + I810InitVideo(pScreen); #ifdef XF86DRI - if (pI810->LpRing.mem.Start == 0) { - pI810->directRenderingEnabled = 0; - I810DRICloseScreen(pScreen); - } - if (pI810->directRenderingEnabled) { /* Now that mi, cfb, drm and others have done their thing, * complete the DRI setup. @@ -1852,6 +1883,9 @@ if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("\n\nENTER VT\n"); + if (! I810BindGARTMemory(pScrn)) + return FALSE; + #ifdef XF86DRI if (pI810->directRenderingEnabled) { if (I810_DEBUG & DEBUG_VERBOSE_DRI) @@ -1889,6 +1923,10 @@ I810Sync( pScrn ); } I810Restore(pScrn); + + if (! I810UnbindGARTMemory(pScrn)) + return; + vgaHWLock(hwp); } @@ -1900,19 +1938,26 @@ I810Ptr pI810 = I810PTR(pScrn); XAAInfoRecPtr infoPtr = pI810->AccelInfoRec; - + if (pScrn->vtSema == TRUE) { + I810Restore(pScrn); + vgaHWLock(hwp); + } #ifdef XF86DRI - if (pI810->directRenderingEnabled) { - I810DRICloseScreen(pScreen); - pI810->directRenderingEnabled=FALSE; - } + if (pI810->directRenderingEnabled) { + I810DRICloseScreen(pScreen); + pI810->directRenderingEnabled=FALSE; + } #endif - I810Restore(pScrn); - vgaHWLock(hwp); + if(pScrn->vtSema == TRUE) { + I810UnbindGARTMemory(pScrn); + I810Restore(pScrn); + vgaHWLock(hwp); + } + I810UnmapMem(pScrn); vgaHWUnmapMem(pScrn); - + if (pI810->ScanlineColorExpandBuffers) { xfree(pI810->ScanlineColorExpandBuffers); pI810->ScanlineColorExpandBuffers = 0; @@ -1934,6 +1979,7 @@ */ pI810->SysMem = pI810->SavedSysMem; pI810->DcacheMem = pI810->SavedDcacheMem; + pI810->DoneFrontAlloc = FALSE; pScrn->vtSema=FALSE; pScreen->CloseScreen = pI810->CloseScreen; @@ -1943,7 +1989,7 @@ static void I810FreeScreen(int scrnIndex, int flags) { I810FreeRec(xf86Screens[scrnIndex]); - if (vgaHWFreeHWRec) + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) vgaHWFreeHWRec(xf86Screens[scrnIndex]); } Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c:1.9 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c:1.9 Tue Jun 20 01:08:46 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c Sat Dec 2 10:25:38 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.9 2000/06/20 05:08:46 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.18 2000/12/02 15:25:38 dawes Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -32,21 +32,10 @@ * */ -#ifndef XFree86LOADER #include "xf86.h" #include "xf86_ansic.h" -#endif +#include "xf86_OSproc.h" -#ifdef linux -#include <asm/ioctl.h> -#include <linux/agpgart.h> -#endif - -#ifdef XFree86LOADER -#include "xf86.h" -#include "xf86_ansic.h" -#endif - #include "i810.h" #include "i810_reg.h" @@ -61,7 +50,6 @@ return 1; } - int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) { if (size > pool->Size) return 0; @@ -73,78 +61,41 @@ return 1; } - int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) { -#ifdef linux - struct _agp_info agpinf; - struct _agp_bind bind; - struct _agp_allocate alloc; - int pages = pScrn->videoRam / 4; + unsigned long size = pScrn->videoRam * 1024; I810Ptr pI810 = I810PTR(pScrn); + int key; long tom = 0; - int gartfd = -1; - - gartfd = open("/dev/agpgart", O_RDWR, 0); + unsigned long physical; - if (gartfd == -1) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "unable to open /dev/agpgart\n"); + if (!xf86AgpGARTSupported()) return FALSE; - } - if (ioctl(gartfd, AGPIOC_ACQUIRE, 0) != 0) { - if(pI810->agpAcquired2d == TRUE) { - close(gartfd); - return TRUE; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AGPIOC_ACQUIRE failed\n"); + if (!xf86AcquireGART(pScrn->scrnIndex)) return FALSE; - } /* This allows the 2d only Xserver to regen */ pI810->agpAcquired2d = TRUE; - pI810->gartfd = gartfd; - if (ioctl(pI810->gartfd, AGPIOC_INFO, &agpinf) != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "error doing ioctl(AGPIOC_INFO)\n"); - return FALSE; - } - - if (agpinf.version.major != 0 || - agpinf.version.minor != 99) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Agp kernel driver version not correct\n"); - return FALSE; - } - - /* Treat the gart like video memory - we assume we own all that is * there, so ignore EBUSY errors. Don't try to remove it on * failure, either, as other X server may be using it. */ - alloc.pg_count = pages; - alloc.type = 0; - if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "AGPGART: allocation of %d pages failed\n", pages); + if ((key = xf86AllocateGARTMemory(pScrn->scrnIndex, size, 0, NULL)) == -1) return FALSE; - } - bind.pg_start = 0; - bind.key = alloc.key; + pI810->VramOffset = 0; + pI810->VramKey = key; - if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: allocation of %d pages failed\n", pages); + if (!xf86BindGARTMemory(pScrn->scrnIndex, key, 0)) return FALSE; - } pI810->SysMem.Start = 0; - pI810->SysMem.Size = pages * 4096; - pI810->SysMem.End = pages * 4096; + pI810->SysMem.Size = size; + pI810->SysMem.End = size; pI810->SavedSysMem = pI810->SysMem; tom = pI810->SysMem.End; @@ -158,69 +109,80 @@ * a 2d server. Don't bother reporting its presence. This is * mapped in addition to the requested amount of system ram. */ - alloc.pg_count = 1024; - alloc.type = 1; - + size = 1024 * 4096; /* Keep it 512K aligned for the sake of tiled regions. */ tom += 0x7ffff; tom &= ~0x7ffff; - if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) == 0) { - bind.pg_start = tom / 4096; - bind.key = alloc.key; - - if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) { + if ((key = xf86AllocateGARTMemory(pScrn->scrnIndex, size, 1, NULL)) != -1) { + pI810->DcacheOffset= tom; + pI810->DcacheKey = key; + if (!xf86BindGARTMemory(pScrn->scrnIndex, key, tom)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: allocation of %d DCACHE pages failed\n", - alloc.pg_count); + "Allocation of %d bytes for DCACHE failed\n", size); + pI810->DcacheKey = -1; } else { pI810->DcacheMem.Start = tom; - pI810->DcacheMem.Size = 1024 * 4096; + pI810->DcacheMem.Size = size; pI810->DcacheMem.End = pI810->DcacheMem.Start + pI810->DcacheMem.Size; tom = pI810->DcacheMem.End; } + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No physical memory available for %d bytes of DCACHE\n", + size); + pI810->DcacheKey = -1; } + /* Mouse cursor -- The i810 (crazy) needs a physical address in * system memory from which to upload the cursor. We get this from * the agpgart module using a special memory type. */ - alloc.pg_count = 1; - alloc.type = 2; + /* 4k for the cursor is excessive, I'm going to steal 3k for + * overlay registers later + */ - if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: No physical memory available for mouse\n", - alloc.pg_count); - } else { - bind.pg_start = tom / 4096; - bind.key = alloc.key; + size = 4096; - if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) { + if ((key = xf86AllocateGARTMemory(pScrn->scrnIndex, size, 2, + &physical)) == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No physical memory available for HW cursor\n"); + pI810->HwcursKey = -1; + } else { + pI810->HwcursOffset= tom; + pI810->HwcursKey = key; + if (!xf86BindGARTMemory(pScrn->scrnIndex, key, tom)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: allocation of %d physical pages failed\n", - alloc.pg_count); + "Allocation of %d bytes for HW cursor failed\n", + size); + pI810->HwcursKey = -1; } else { - pI810->CursorPhysical = alloc.physical; + pI810->CursorPhysical = physical; pI810->CursorStart = tom; - - tom += 4096; + tom += size; } } + /* Overlay register buffer -- Just like the cursor, the i810 needs a + * physical address in system memory from which to upload the overlay + * registers. + */ + if (pI810->CursorStart != 0) { + pI810->OverlayPhysical = pI810->CursorPhysical + 1024; + pI810->OverlayStart = pI810->CursorStart + 1024; + } + pI810->GttBound = 1; return TRUE; -#else - return FALSE; -#endif } - - +#if 0 void I810FreeGARTMemory( ScrnInfoPtr pScrn ) { #ifdef linux @@ -232,6 +194,7 @@ } #endif } +#endif @@ -253,26 +216,30 @@ CARD32 val; if (nr < 0 || nr > 7) { - ErrorF("I810SetTiledMemory - fence %d out of range\n", nr); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "I810SetTiledMemory - fence %d out of range\n", nr); return; } i810Reg->Fence[nr] = 0; if (start & ~FENCE_START_MASK) { - ErrorF("I810SetTiledMemory %d: start (%x) is not 512k aligned\n", - nr, start); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "I810SetTiledMemory %d: start (%x) is not 512k aligned\n", + nr, start); return; } if (start % size) { - ErrorF("I810SetTiledMemory %d: start (%x) is not size (%x) aligned\n", - nr, start, size); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "I810SetTiledMemory %d: start (%x) is not size (%x) aligned\n", + nr, start, size); return; } if (pitch & 127) { - ErrorF("I810SetTiledMemory %d: pitch (%x) not a multiple of 128 bytes\n", - nr, pitch); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "I810SetTiledMemory %d: pitch (%x) not a multiple of 128 bytes\n", + nr, pitch); return; } @@ -287,7 +254,8 @@ case (16*1024*1024): val |= FENCE_SIZE_16M; break; case (32*1024*1024): val |= FENCE_SIZE_32M; break; default: - ErrorF("I810SetTiledMemory %d: illegal size (%x)\n"); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "I810SetTiledMemory %d: illegal size (0x%x)\n", size); return; } @@ -299,9 +267,87 @@ case 16: val |= FENCE_PITCH_16; break; case 32: val |= FENCE_PITCH_32; break; default: - ErrorF("I810SetTiledMemory %d: illegal size (%x)\n"); + xf86DrvMsg(X_WARNING, pScrn->scrnIndex, + "%d: illegal size (0x%x)\n", size); return; } i810Reg->Fence[nr] = val; } + +Bool +I810BindGARTMemory( ScrnInfoPtr pScrn ) +{ + I810Ptr pI810 = I810PTR(pScrn); + + if (xf86AgpGARTSupported() && !pI810->directRenderingEnabled && + !pI810->GttBound) { + if (!xf86AcquireGART(pScrn->scrnIndex)) + return FALSE; + if (!xf86BindGARTMemory(pScrn->scrnIndex, pI810->VramKey, + pI810->VramOffset)) + return FALSE; + if (pI810->DcacheKey != -1) { + if (!xf86BindGARTMemory(pScrn->scrnIndex, pI810->DcacheKey, + pI810->DcacheOffset)) + return FALSE; + } + if (pI810->HwcursKey != -1) { + if (!xf86BindGARTMemory(pScrn->scrnIndex, pI810->HwcursKey, + pI810->HwcursOffset)) + return FALSE; + } + pI810->GttBound = 1; + } + return TRUE; +} + +Bool +I810UnbindGARTMemory( ScrnInfoPtr pScrn ) +{ + I810Ptr pI810 = I810PTR(pScrn); + + if (xf86AgpGARTSupported() && !pI810->directRenderingEnabled && + pI810->GttBound) { + if (!xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->VramKey)) + return FALSE; + if (pI810->DcacheKey != -1) { + if (!xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->DcacheKey)) + return FALSE; + } + if (pI810->HwcursKey != -1) { + if (!xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->HwcursKey)) + return FALSE; + } + if (!xf86ReleaseGART(pScrn->scrnIndex)) + return FALSE; + pI810->GttBound = 0; + } + return TRUE; +} + +int +I810CheckAvailableMemory(ScrnInfoPtr pScrn) +{ + AgpInfoPtr agpinf; + int maxPages; + + if (!xf86AgpGARTSupported()) + return -1; + + if (!xf86AcquireGART(pScrn->scrnIndex)) + return -1; + + if ((agpinf = xf86GetAGPInfo(pScrn->scrnIndex)) == NULL) + return -1; + + if (!xf86ReleaseGART(pScrn->scrnIndex)) + return -1; + + maxPages = agpinf->totalPages - agpinf->usedPages; + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, + "I810CheckAvailableMemory: %dk available\n", maxPages * 4); + + return maxPages * 4; +} + Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h:1.2 Tue Feb 22 23:47:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h Tue Sep 26 11:57:12 2000 @@ -25,6 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h,v 1.4 2000/09/26 15:57:12 tsi Exp $ */ /* * Authors: @@ -415,7 +416,7 @@ #define BR00_OP_MONO_SRC_BLT 0x11800000 #define BR00_OP_MONO_SRC_COPY_BLT 0x11000000 #define BR00_OP_MONO_PAT_BLT 0x11C00000 -#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT 0x18400000 +#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22) #define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000 Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c:1.14 --- /dev/null Mon Dec 18 14:30:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c Tue Dec 5 20:40:49 2000 @@ -0,0 +1,1128 @@ +/*************************************************************************** + +Copyright 2000 Intel Corporation. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c,v 1.14 2000/12/06 01:40:49 mvojkovi Exp $ */ + +/* + * i810_video.c: i810 Xv driver. Based on the mga Xv driver by Mark Vojkovich. + * + * Authors: + * Jonathan Bian <jonathan.bian@intel.com> + * + * Notes: + * This module currently allocates 810*2KB out of "SysMem" for the YUV + * buffers. This may not be the best solution ... + * + */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "i810.h" +#include "xf86xv.h" +#include "Xv.h" +#include "xaa.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" + +#define OFF_DELAY 250 /* milliseconds */ +#define FREE_DELAY 15000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 + +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +static XF86VideoAdaptorPtr I810SetupImageVideo(ScreenPtr); +static void I810StopVideo(ScrnInfoPtr, pointer, Bool); +static int I810SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int I810GetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +static void I810QueryBestSize(ScrnInfoPtr, Bool, + short, short, short, short, unsigned int *, unsigned int *, pointer); +static int I810PutImage( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, pointer); +static int I810QueryImageAttributes(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); + +static void I810BlockHandler(int, pointer, pointer, pointer); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvContrast, xvColorKey; + +#define IMAGE_MAX_WIDTH 720 +#define IMAGE_MAX_HEIGHT 576 +#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT) + +#define OVERLAY_UPDATE(p) OUTREG(0x30000, p | 0x80000000); + +/* + * OV0CMD - Overlay Command Register + */ +#define VERTICAL_CHROMINANCE_FILTER 0x70000000 +#define VC_SCALING_OFF 0x00000000 +#define VC_LINE_REPLICATION 0x10000000 +#define VC_UP_INTERPOLATION 0x20000000 +#define VC_PIXEL_DROPPING 0x50000000 +#define VC_DOWN_INTERPOLATION 0x60000000 +#define VERTICAL_LUMINANCE_FILTER 0x0E000000 +#define VL_SCALING_OFF 0x00000000 +#define VL_LINE_REPLICATION 0x02000000 +#define VL_UP_INTERPOLATION 0x04000000 +#define VL_PIXEL_DROPPING 0x0A000000 +#define VL_DOWN_INTERPOLATION 0x0C000000 +#define HORIZONTAL_CHROMINANCE_FILTER 0x01C00000 +#define HC_SCALING_OFF 0x00000000 +#define HC_LINE_REPLICATION 0x00400000 +#define HC_UP_INTERPOLATION 0x00800000 +#define HC_PIXEL_DROPPING 0x01400000 +#define HC_DOWN_INTERPOLATION 0x01800000 +#define HORIZONTAL_LUMINANCE_FILTER 0x00380000 +#define HL_SCALING_OFF 0x00000000 +#define HL_LINE_REPLICATION 0x00080000 +#define HL_UP_INTERPOLATION 0x00100000 +#define HL_PIXEL_DROPPING 0x00280000 +#define HL_DOWN_INTERPOLATION 0x00300000 + +#define Y_ADJUST 0x00010000 +#define OV_BYTE_ORDER 0x0000C000 +#define UV_SWAP 0x00004000 +#define Y_SWAP 0x00008000 +#define Y_AND_UV_SWAP 0x0000C000 +#define SOURCE_FORMAT 0x00003C00 +#define RGB_555 0x00000800 +#define RGB_565 0x00000C00 +#define YUV_422 0x00002000 +#define YUV_411 0x00002400 +#define YUV_420 0x00003000 +#define YUV_410 0x00003800 +#define BUFFER_AND_FIELD 0x00000006 +#define BUFFER0_FIELD0 0x00000000 +#define BUFFER1_FIELD0 0x00000004 +#define OVERLAY_ENABLE 0x00000001 + +/* + * DOV0STA - Display/Overlay 0 Status Register + */ +#define DOV0STA 0x30008 + +#define MINUV_SCALE 0x1 + +#define RGB16ToColorKey(c) \ + (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3)) + +#define RGB15ToColorKey(c) \ + (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3)) + +void I810InitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + if (pScrn->bitsPerPixel != 8) + { + newAdaptor = I810SetupImageVideo(pScreen); + } + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 3 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {15, TrueColor}, {16, TrueColor}, {24, TrueColor} +}; + +#define NUM_ATTRIBUTES 3 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, + {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} +}; + +#define NUM_IMAGES 4 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_I420, + XVIMAGE_UYVY +}; + +typedef struct { + CARD32 OBUF_0Y; + CARD32 OBUF_1Y; + CARD32 OBUF_0U; + CARD32 OBUF_0V; + CARD32 OBUF_1U; + CARD32 OBUF_1V; + CARD32 OV0STRIDE; + CARD32 YRGB_VPH; + CARD32 UV_VPH; + CARD32 HORZ_PH; + CARD32 INIT_PH; + CARD32 DWINPOS; + CARD32 DWINSZ; + CARD32 SWID; + CARD32 SWIDQW; + CARD32 SHEIGHT; + CARD32 YRGBSCALE; + CARD32 UVSCALE; + CARD32 OV0CLRC0; + CARD32 OV0CLRC1; + CARD32 DCLRKV; + CARD32 DCLRKM; + CARD32 SCLRKVH; + CARD32 SCLRKVL; + CARD32 SCLRKM; + CARD32 OV0CONF; + CARD32 OV0CMD; +} I810OverlayRegRec, *I810OverlayRegPtr; + +typedef struct { + CARD32 YBuf0offset; + CARD32 UBuf0offset; + CARD32 VBuf0offset; + + CARD32 YBuf1offset; + CARD32 UBuf1offset; + CARD32 VBuf1offset; + + unsigned char currentBuf; + + int brightness; + int contrast; + + RegionRec clip; + CARD32 colorKey; + + CARD32 videoStatus; + Time offTime; + Time freeTime; + FBLinearPtr linear; +} I810PortPrivRec, *I810PortPrivPtr; + +#define GET_PORT_PRIVATE(pScrn) \ + (I810PortPrivPtr)((I810PTR(pScrn))->adaptor->pPortPrivates[0].ptr) + +static void I810ResetVideo(ScrnInfoPtr pScrn) +{ + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = pI810->adaptor->pPortPrivates[0].ptr; + I810OverlayRegPtr overlay = (I810OverlayRegPtr) (pI810->FbBase + pI810->OverlayStart); + + /* + * Default to maximum image size in YV12 + */ + + overlay->YRGB_VPH = 0; + overlay->UV_VPH = 0; + overlay->HORZ_PH = 0; + overlay->INIT_PH = 0; + overlay->DWINPOS = 0; + overlay->DWINSZ = (IMAGE_MAX_HEIGHT << 16) | IMAGE_MAX_WIDTH; + overlay->SWID = IMAGE_MAX_WIDTH | (IMAGE_MAX_WIDTH << 15); + overlay->SWIDQW = (IMAGE_MAX_WIDTH >> 3) | (IMAGE_MAX_WIDTH << 12); + overlay->SHEIGHT = IMAGE_MAX_HEIGHT | (IMAGE_MAX_HEIGHT << 15); + overlay->YRGBSCALE = 0x80004000; /* scale factor 1 */ + overlay->UVSCALE = 0x80004000; /* scale factor 1 */ + overlay->OV0CLRC0 = 0x4000; /* brightness: 0 contrast: 1.0 */ + overlay->OV0CLRC1 = 0x80; /* saturation: bypass */ + + /* + * Enable destination color keying + */ + switch(pScrn->depth) { + case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); + overlay->DCLRKM = 0x80070307; + break; + case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); + overlay->DCLRKM = 0x80070707; + break; + default: overlay->DCLRKV = pPriv->colorKey; + overlay->DCLRKM = 0x80000000; + break; + } + + overlay->SCLRKVH = 0; + overlay->SCLRKVL = 0; + overlay->SCLRKM = 0; /* source color key disable */ + overlay->OV0CONF = 0; /* two 720 pixel line buffers */ + + overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST | + YUV_420; + + OVERLAY_UPDATE(pI810->OverlayPhysical); +} + + +static XF86VideoAdaptorPtr +I810SetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + I810Ptr pI810 = I810PTR(pScrn); + XF86VideoAdaptorPtr adapt; + I810PortPrivPtr pPriv; + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(I810PortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "I810 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (I810PortPrivPtr)(&adapt->pPortPrivates[1]); + + adapt->pPortPrivates[0].ptr = (pointer)(pPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = I810StopVideo; + adapt->SetPortAttribute = I810SetPortAttribute; + adapt->GetPortAttribute = I810GetPortAttribute; + adapt->QueryBestSize = I810QueryBestSize; + adapt->PutImage = I810PutImage; + adapt->QueryImageAttributes = I810QueryImageAttributes; + + pPriv->colorKey = pI810->colorKey & ((1 << pScrn->depth) - 1); + pPriv->videoStatus = 0; + pPriv->brightness = 0; + pPriv->contrast = 64; + pPriv->linear = NULL; + pPriv->currentBuf = 0; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + pI810->adaptor = adapt; + + pI810->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = I810BlockHandler; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvContrast = MAKE_ATOM("XV_CONTRAST"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + I810ResetVideo(pScrn); + + return adapt; +} + + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + + +/* I810ClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (x1, y1 + inclusive, x2, y2 exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +static void +I810ClipVideo( + BoxPtr dst, + INT32 *x1, + INT32 *x2, + INT32 *y1, + INT32 *y2, + BoxPtr extents, /* extents of the clip region */ + INT32 width, + INT32 height +){ + INT32 vscale, hscale, delta; + int diff; + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *x2 <<= 16; + *y1 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *x2 -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if(*x1 < 0) { + diff = (- *x1 + hscale - 1)/ hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + delta = *x2 - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + if(*y1 < 0) { + diff = (- *y1 + vscale - 1)/ vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + delta = *y2 - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } +} + +static void +I810StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + I810PortPrivPtr pPriv = (I810PortPrivPtr)data; + I810Ptr pI810 = I810PTR(pScrn); + + I810OverlayRegPtr overlay = (I810OverlayRegPtr) (pI810->FbBase + pI810->OverlayStart); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + overlay->OV0CMD &= 0xFFFFFFFE; + OVERLAY_UPDATE(pI810->OverlayPhysical); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } + +} + +static int +I810SetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ + I810PortPrivPtr pPriv = (I810PortPrivPtr)data; + I810Ptr pI810 = I810PTR(pScrn); + I810OverlayRegPtr overlay = (I810OverlayRegPtr) (pI810->FbBase + pI810->OverlayStart); + + if(attribute == xvBrightness) { + if((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; + overlay->OV0CLRC0 = (pPriv->contrast << 8) | (pPriv->brightness & 0xff); + OVERLAY_UPDATE(pI810->OverlayPhysical); + } else + if(attribute == xvContrast) { + if((value < 0) || (value > 255)) + return BadValue; + pPriv->contrast = value; + overlay->OV0CLRC0 = (pPriv->contrast << 8) | (pPriv->brightness & 0xff); + OVERLAY_UPDATE(pI810->OverlayPhysical); + } else + if(attribute == xvColorKey) { + pPriv->colorKey = value; + switch(pScrn->depth) { + case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); + break; + case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); + break; + default: overlay->DCLRKV = pPriv->colorKey; + break; + } + OVERLAY_UPDATE(pI810->OverlayPhysical); + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else return BadMatch; + + return Success; +} + +static int +I810GetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ + I810PortPrivPtr pPriv = (I810PortPrivPtr)data; + + if(attribute == xvBrightness) { + *value = pPriv->brightness; + } else + if(attribute == xvContrast) { + *value = pPriv->contrast; + } else + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else return BadMatch; + + return Success; +} + +static void +I810QueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; +} + + +static void +I810CopyPackedData( + ScrnInfoPtr pScrn, + unsigned char *buf, + int srcPitch, + int dstPitch, + int top, + int left, + int h, + int w + ) +{ + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = pI810->adaptor->pPortPrivates[0].ptr; + unsigned char *src, *dst; + + src = buf + (top*srcPitch) + (left<<1); + + if (pPriv->currentBuf == 0) + dst = pI810->FbBase + pPriv->YBuf0offset; + else + dst = pI810->FbBase + pPriv->YBuf1offset; + + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +I810CopyPlanarData( + ScrnInfoPtr pScrn, + unsigned char *buf, + int srcPitch, + int dstPitch, /* of chroma */ + int srcH, + int top, + int left, + int h, + int w, + int id + ) +{ + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = pI810->adaptor->pPortPrivates[0].ptr; + int i; + unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3; + + /* Copy Y data */ + src1 = buf + (top*srcPitch) + left; + if (pPriv->currentBuf == 0) + dst1 = pI810->FbBase + pPriv->YBuf0offset; + else + dst1 = pI810->FbBase + pPriv->YBuf1offset; + + for (i = 0; i < h; i++) { + memcpy(dst1, src1, w); + src1 += srcPitch; + dst1 += dstPitch << 1; + } + + /* Copy V data for YV12, or U data for I420 */ + src2 = buf + (srcH*srcPitch) + ((top*srcPitch)>>2) + (left>>1); + if (pPriv->currentBuf == 0) { + if (id == FOURCC_I420) + dst2 = pI810->FbBase + pPriv->UBuf0offset; + else + dst2 = pI810->FbBase + pPriv->VBuf0offset; + } else { + if (id == FOURCC_I420) + dst2 = pI810->FbBase + pPriv->UBuf1offset; + else + dst2 = pI810->FbBase + pPriv->VBuf1offset; + } + + for (i = 0; i < h/2; i++) { + memcpy(dst2, src2, w/2); + src2 += srcPitch>>1; + dst2 += dstPitch; + } + + /* Copy U data for YV12, or V data for I420 */ + src3 = buf + (srcH*srcPitch) + ((srcH*srcPitch)>>2) + ((top*srcPitch)>>2) + (left>>1); + if (pPriv->currentBuf == 0) { + if (id == FOURCC_I420) + dst3 = pI810->FbBase + pPriv->VBuf0offset; + else + dst3 = pI810->FbBase + pPriv->UBuf0offset; + } else { + if (id == FOURCC_I420) + dst3 = pI810->FbBase + pPriv->VBuf1offset; + else + dst3 = pI810->FbBase + pPriv->UBuf1offset; + } + + for (i = 0; i < h/2; i++) { + memcpy(dst3, src3, w/2); + src3 += srcPitch>>1; + dst3 += dstPitch; + } +} + +static void +I810DisplayVideo( + ScrnInfoPtr pScrn, + int id, + short width, short height, + int dstPitch, /* of chroma for 4:2:0 */ + int x1, int y1, int x2, int y2, + BoxPtr dstBox, + short src_w, short src_h, + short drw_w, short drw_h +){ + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = pI810->adaptor->pPortPrivates[0].ptr; + I810OverlayRegPtr overlay = (I810OverlayRegPtr) (pI810->FbBase + pI810->OverlayStart); + int xscaleInt, xscaleFract, yscaleInt, yscaleFract; + int xscaleIntUV = 0, xscaleFractUV = 0, yscaleIntUV = 0, yscaleFractUV = 0; + unsigned int swidth; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + swidth = (width + 7) & ~7; + overlay->SWID = (swidth << 15) | swidth; + overlay->SWIDQW = (swidth << 12) | (swidth >> 3); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + swidth = ((width + 3) & ~3) << 1; + overlay->SWID = swidth; + overlay->SWIDQW = swidth >> 3; + break; + } + + overlay->SHEIGHT = height | (height << 15); + overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1; + overlay->DWINSZ = ((dstBox->y2 - dstBox->y1) << 16) | + (dstBox->x2 - dstBox->x1); + + /* buffer locations */ + overlay->OBUF_0Y = pPriv->YBuf0offset; + overlay->OBUF_1Y = pPriv->YBuf1offset; + overlay->OBUF_0U = pPriv->UBuf0offset; + overlay->OBUF_0V = pPriv->VBuf0offset; + overlay->OBUF_1U = pPriv->UBuf1offset; + overlay->OBUF_1V = pPriv->VBuf1offset; + + /* + * Calculate horizontal and vertical scaling factors, default to 1:1 + */ + overlay->YRGBSCALE = 0x80004000; + overlay->UVSCALE = 0x80004000; + + /* + * Initially, YCbCr and Overlay Enable and + * vertical chrominance up interpolation and horozontal chrominance + * up interpolation + */ + overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST | + OVERLAY_ENABLE; + + if ((drw_w != src_w) || (drw_h != src_h)) + { + xscaleInt = (src_w / drw_w) & 0x3; + xscaleFract = (src_w << 12) / drw_w; + yscaleInt = (src_h / drw_h) & 0x3; + yscaleFract = (src_h << 12) / drw_h; + + overlay->YRGBSCALE = (xscaleInt << 15) | + ((xscaleFract & 0xFFF) << 3) | + (yscaleInt) | + ((yscaleFract & 0xFFF) << 20); + + if (drw_w > src_w) + { + /* horizontal up-scaling */ + overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER; + overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER; + overlay->OV0CMD |= (HC_UP_INTERPOLATION | HL_UP_INTERPOLATION); + } + + if (drw_h > src_h) + { + /* vertical up-scaling */ + overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER; + overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER; + overlay->OV0CMD |= (VC_UP_INTERPOLATION | VL_UP_INTERPOLATION); + } + + if (drw_w < src_w) + { + /* horizontal down-scaling */ + overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER; + overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER; + overlay->OV0CMD |= (HC_DOWN_INTERPOLATION | HL_DOWN_INTERPOLATION); + } + + if (drw_h < src_h) + { + /* vertical down-scaling */ + overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER; + overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER; + overlay->OV0CMD |= (VC_DOWN_INTERPOLATION | VL_DOWN_INTERPOLATION); + } + + /* now calculate the UV scaling factor */ + + if (xscaleFract) + { + xscaleFractUV = xscaleFract >> MINUV_SCALE; + overlay->OV0CMD &= ~HC_DOWN_INTERPOLATION; + overlay->OV0CMD |= HC_UP_INTERPOLATION; + } + + if (xscaleInt) + { + xscaleIntUV = xscaleInt >> MINUV_SCALE; + if (xscaleIntUV) + { + overlay->OV0CMD &= ~HC_UP_INTERPOLATION; + } + } + + if (yscaleFract) + { + yscaleFractUV = yscaleFract >> MINUV_SCALE; + overlay->OV0CMD &= ~VC_DOWN_INTERPOLATION; + overlay->OV0CMD |= VC_UP_INTERPOLATION; + } + + if (yscaleInt) + { + yscaleIntUV = yscaleInt >> MINUV_SCALE; + if (yscaleIntUV) + { + overlay->OV0CMD &= ~VC_UP_INTERPOLATION; + overlay->OV0CMD |= VC_DOWN_INTERPOLATION; + } + } + + overlay->UVSCALE = yscaleIntUV | ((xscaleFractUV & 0xFFF) << 3) | + ((yscaleFractUV & 0xFFF) << 20); + } + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + overlay->OV0STRIDE = (dstPitch << 1) | (dstPitch << 16); + overlay->OV0CMD &= ~SOURCE_FORMAT; + overlay->OV0CMD |= YUV_420; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + overlay->OV0STRIDE = dstPitch; + overlay->OV0CMD &= ~SOURCE_FORMAT; + overlay->OV0CMD |= YUV_422; + overlay->OV0CMD &= ~OV_BYTE_ORDER; + if (id == FOURCC_UYVY) + overlay->OV0CMD |= Y_SWAP; + break; + } + + overlay->OV0CMD &= ~BUFFER_AND_FIELD; + if (pPriv->currentBuf == 0) + overlay->OV0CMD |= BUFFER0_FIELD0; + else + overlay->OV0CMD |= BUFFER1_FIELD0; + + OVERLAY_UPDATE(pI810->OverlayPhysical); + +} + +static FBLinearPtr +I810AllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +){ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 4, + PRIORITY_EXTREME); + + if(max_size < size) return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 4, + NULL, NULL, NULL); + } + + return new_linear; +} + +static int +I810PutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data +){ + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = (I810PortPrivPtr)data; + INT32 x1, x2, y1, y2; + int srcPitch, dstPitch; + int top, left, npixels, nlines, size; + BoxRec dstBox; + + /* Clip */ + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + I810ClipVideo(&dstBox, &x1, &x2, &y1, &y2, + REGION_EXTENTS(pScreen, clipBoxes), width, height); + + if((x1 >= x2) || (y1 >= y2)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + srcPitch = (width + 3) & ~3; + dstPitch = ((width >> 1) + 7) & ~7; /* of chroma */ + size = dstPitch * height * 3; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + srcPitch = (width << 1); + dstPitch = (srcPitch + 7) & ~7; + size = dstPitch * height; + break; + } + + if(!(pPriv->linear = I810AllocateMemory(pScrn, pPriv->linear, + (pScrn->bitsPerPixel == 16) ? size : (size >> 1)))) + return BadAlloc; + + /* fixup pointers */ + pPriv->YBuf0offset = pPriv->linear->offset * pI810->cpp; + pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height); + pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height >> 1); + + pPriv->YBuf1offset = (pPriv->linear->offset * pI810->cpp) + size; + pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height); + pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height >> 1); + + + /* wait for the last rendered buffer to be flipped in */ + while (((INREG(DOV0STA)&0x00100000)>>20) != pPriv->currentBuf); + + /* buffer swap */ + if (pPriv->currentBuf == 0) + pPriv->currentBuf = 1; + else + pPriv->currentBuf = 0; + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + I810CopyPlanarData(pScrn, buf, srcPitch, dstPitch, height, top, left, + nlines, npixels, id); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + nlines = ((y2 + 0xffff) >> 16) - top; + I810CopyPackedData(pScrn, buf, srcPitch, dstPitch, top, left, nlines, + npixels); + break; + } + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + + I810DisplayVideo(pScrn, id, width, height, dstPitch, + x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + + pPriv->videoStatus = CLIENT_VIDEO_ON; + + return Success; +} + + +static int +I810QueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int size, tmp; + + if(*w > 720) *w = 720; + if(*h > 576) *h = 576; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) pitches[0] = size; + size *= *h; + if(offsets) offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} + +static void +I810BlockHandler ( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask +){ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + I810Ptr pI810 = I810PTR(pScrn); + I810PortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + I810OverlayRegPtr overlay = (I810OverlayRegPtr) (pI810->FbBase + pI810->OverlayStart); + + pScreen->BlockHandler = pI810->BlockHandler; + + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + + pScreen->BlockHandler = I810BlockHandler; + + if(pPriv->videoStatus & TIMER_MASK) { + UpdateCurrentTime(); + if(pPriv->videoStatus & OFF_TIMER) { + if(pPriv->offTime < currentTime.milliseconds) { + /* Turn off the overlay */ + overlay->OV0CMD &= 0xFFFFFFFE; + OVERLAY_UPDATE(pI810->OverlayPhysical); + + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + } else { /* FREE_TIMER */ + if(pPriv->freeTime < currentTime.milliseconds) { + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } + } + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c diff -u xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c:1.1 Fri Feb 11 12:25:53 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c Fri Sep 8 18:43:06 2000 @@ -25,12 +25,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_wmark.c,v 1.4 2000/09/08 22:43:06 mvojkovi Exp $ */ /* * Authors: * Keith Whitwell <keithw@precisioninsight.com> */ +#include "xf86.h" #include "i810.h" struct wm_info { @@ -253,7 +255,7 @@ int i; if (pI810->LmFreqSel == 100) { - switch(pScrn->depth) { + switch(pScrn->bitsPerPixel) { case 8: tab = i810_wm_8_100; nr = Elements(i810_wm_8_100); @@ -263,7 +265,6 @@ nr = Elements(i810_wm_16_100); break; case 24: - case 32: tab = i810_wm_24_100; nr = Elements(i810_wm_24_100); break; @@ -271,7 +272,7 @@ return 0; } } else { - switch(pScrn->depth) { + switch(pScrn->bitsPerPixel) { case 8: tab = i810_wm_8_133; nr = Elements(i810_wm_8_133); @@ -281,7 +282,6 @@ nr = Elements(i810_wm_16_133); break; case 24: - case 32: tab = i810_wm_24_133; nr = Elements(i810_wm_24_133); break; @@ -295,8 +295,9 @@ if (i == nr) i--; - ErrorF("%s %s: chose watermark 0x%x: (tab.freq %.1f)\n", - XCONFIG_PROBED, NAME, tab[i].wm, tab[i].freq); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "chose watermark 0x%x: (tab.freq %.1f)\n", + tab[i].wm, tab[i].freq); /* None of these values (sourced from intel) have watermarks for * the dcache memory. Fake it for now by using the same watermark Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile:1.2 xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile:1.2 Tue Jun 13 21:56:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile Wed Oct 11 12:21:21 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile,v 1.2 2000/06/14 01:56:08 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile,v 1.3 2000/10/11 16:21:21 mvojkovi Exp $ /* * * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> @@ -22,7 +22,7 @@ -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ - -I$(XF86SRC)/fbdevhw \ + -I$(XF86SRC)/fbdevhw -I$(SERVERSRC)/render \ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ -I$(EXTINCSRC) #endif Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp:1.2 xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp:1.2 Tue Jun 13 22:13:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp Mon Dec 11 15:18:18 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp,v 1.2 2000/06/14 02:13:11 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp,v 1.3 2000/12/11 20:18:18 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH IMSTT __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH IMSTT __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME imstt \- Integrated Micro Solutions Twin Turbo 128 driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h:1.1 Tue Jun 13 20:16:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h Wed Aug 2 19:50:49 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h,v 1.1 2000/06/14 00:16:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h,v 1.3 2000/08/02 23:50:49 dawes Exp $ */ #ifndef _IMSTT_H #define _IMSTT_H @@ -22,6 +22,7 @@ long FBMapSize; unsigned long videoRam; unsigned long ramdac; + int rev; OptionInfoPtr Options; unsigned int Flags; CARD32 Bus; @@ -32,8 +33,13 @@ Bool InitDAC; Bool FBDev; int Chipset, ChipRev; + int ydir; unsigned long pitch; unsigned long ll; + unsigned long screen_width; + unsigned long sp; + unsigned long dp; + unsigned long cnt; unsigned long bltctl; unsigned short hes; unsigned short heb; @@ -51,6 +57,11 @@ unsigned char lckl_p[3]; } IMSTTRec, *IMSTTPtr; +#if 0 +#define IMSTTTRACE ErrorF +#else +#define IMSTTTRACE +#endif #define IMSTTPTR(p) ((IMSTTPtr)((p)->driverPrivate)) Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c:1.2 Tue Jun 13 22:36:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c Tue Aug 1 16:05:43 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c,v 1.2 2000/06/14 02:36:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c,v 1.4 2000/08/01 20:05:43 dawes Exp $ */ /* * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> @@ -25,10 +25,10 @@ */ -#include "compiler.h" #include "Xarch.h" #include "xf86.h" #include "xf86_ansic.h" +#include "compiler.h" #include "xf86_OSproc.h" #include "xaa.h" #include "xf86PciInfo.h" @@ -55,10 +55,11 @@ IMSTTPtr iptr = IMSTTPTR(pScrn); IMSTTMMIO_VARS(); + OUTREG(IMSTT_DP_OCTL, iptr->ll); + OUTREG(IMSTT_SP, iptr->ll); OUTREG(IMSTT_BI, 0xffffffff); OUTREG(IMSTT_MBC, 0xffffffff); OUTREG(IMSTT_CLR, color); - OUTREG(IMSTT_DP_OCTL, (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3))); } @@ -68,9 +69,13 @@ IMSTTPtr iptr = IMSTTPTR(pScrn); IMSTTMMIO_VARS(); - OUTREG(IMSTT_DSA, y + x); - OUTREG(IMSTT_CNT, (h << 16) | w); - OUTREG(IMSTT_BLTCTL, 0x840); + OUTREG(IMSTT_DSA, y * iptr->ll + x * (pScrn->bitsPerPixel >> 3)); + OUTREG(IMSTT_S1SA, y * iptr->ll + x * (pScrn->bitsPerPixel >> 3)); + OUTREG(IMSTT_CNT, ((h - 1) << 16) | (w * (pScrn->bitsPerPixel >> 3) - 1)); + if (iptr->rev == 2) + OUTREG(IMSTT_BLTCTL, 0x200000); + else + OUTREG(IMSTT_BLTCTL, 0x840); } @@ -83,24 +88,28 @@ unsigned long sp, dp, ll, cnt; iptr->bltctl = 0x05; - ll = pScrn->displayWidth * (pScrn->bitsPerPixel >> 3); - iptr->ll = ll; + ll = iptr->ll; sp = ll << 16; - cnt = pScrn->virtualY << 16; - if (xdir >= 0) { - dp = -(ll) & 0xffff; - sp |= dp; - } - if (ydir >= 0) { + + if (xdir > 0) { iptr->bltctl |= 0x80; - cnt |= -(pScrn->displayWidth) & 0xffff; + iptr->cnt = 1; } else { - cnt |= pScrn->displayWidth; + iptr->cnt = 0; } - OUTREG(IMSTT_SP, sp); - OUTREG(IMSTT_CNT, cnt); - OUTREG(IMSTT_DP_OCTL, dp); + if (ydir > 0) { + sp |= -(ll) & 0xffff; + dp = -(ll) & 0xffff; + iptr->ydir = 1; + } else { + sp |= ll; + dp = ll; + iptr->ydir = 0; + } + + iptr->sp = sp; + iptr->dp = dp; } @@ -111,15 +120,35 @@ { IMSTTPtr iptr = IMSTTPTR(pScrn); IMSTTMMIO_VARS(); + unsigned long cnt; - OUTREG(IMSTT_S1SA, x1 * iptr->ll * y1); - OUTREG(IMSTT_DSA, x2 * iptr->ll * y2); + w--; + h--; + cnt = h << 16; + + if (iptr->cnt) { + x1 += w; + x2 += w; + cnt |= -(w) & 0xffff; + } + else + cnt |= w; + + if (iptr->ydir) { + y1 += h; + y2 += h; + } + + OUTREG(IMSTT_S1SA, y1 * iptr->ll + x1); + OUTREG(IMSTT_SP, iptr->sp); + OUTREG(IMSTT_DSA, y2 * iptr->ll + x2); + OUTREG(IMSTT_CNT, cnt); + OUTREG(IMSTT_DP_OCTL, iptr->dp); OUTREG(IMSTT_BLTCTL, iptr->bltctl); } - Bool IMSTTAccelInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -129,12 +158,18 @@ if (!(xaaptr = iptr->AccelInfoRec = XAACreateInfoRec())) return FALSE; + iptr->ll = pScrn->displayWidth * (pScrn->bitsPerPixel >> 3); + + iptr->screen_width = iptr->pitch = iptr->ll; + xaaptr->Flags = (PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER); xaaptr->Sync = IMSTTSync; + xaaptr->SetupForSolidFill = IMSTTSetupForSolidFill; xaaptr->SubsequentSolidFillRect = IMSTTSubsequentSolidFillRect; - xaaptr->ScreenToScreenCopyFlags = 0; + + xaaptr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; xaaptr->SetupForScreenToScreenCopy = IMSTTSetupForScreenToScreenCopy; xaaptr->SubsequentScreenToScreenCopy = IMSTTSubsequentScreenToScreenCopy; Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c:1.6 Thu Jun 22 12:59:28 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c Sat Dec 2 10:30:43 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c,v 1.6 2000/06/22 16:59:28 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c,v 1.10 2000/12/02 15:30:43 tsi Exp $ */ /* * Copyright 2000 Ani Joshi <ajoshi@unixbox.com> @@ -6,10 +6,6 @@ * XFree86 4.0 driver for the Integrated Micro Solutions * Twin Turbo 128 chipset * - * Credits: - * Sigurdur Asgeirsson, Jeffrey Kuskin, Ryan Nielsen - * for their work on imsttfb - * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright @@ -28,11 +24,13 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * + * Credits: + * Sigurdur Asgeirsson, Jeffrey Kuskin, Ryan Nielsen + * for their work on imsttfb * */ -#include "compiler.h" #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" @@ -41,6 +39,7 @@ #include "xf86Version.h" #include "xf86Resources.h" #include "xf86fbman.h" +#include "compiler.h" #include "xaa.h" #include "mipointer.h" #include "micmap.h" @@ -86,8 +85,8 @@ static void IMSTTUnmapMem(ScrnInfoPtr pScrn); static Bool IMSTTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static void IMSTTAdjustFrame(int scrnIndex, int x, int y, int flags); -static Bool IMSTTCloseScreen(int scrnIndex, ScreenPtr pScreen); -static Bool IMSTTSaveSCreen(ScreenPtr pScreen, int mode); +Bool IMSTTCloseScreen(int scrnIndex, ScreenPtr pScreen); +Bool IMSTTSaveScreen(ScreenPtr pScreen, int mode); static void IMSTTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); @@ -158,6 +157,11 @@ }; +static const char *fbSymbols[] = { + "fbScreenInit", + NULL +}; + static const char *xaaSymbols[] = { "XAADestroyInfoRec", "XAACreateInfoRec", @@ -189,8 +193,13 @@ #ifdef XFree86LOADER -static pointer IMSTTSetup(pointer module, pointer opts, int *errmaj, + +MODULESETUPPROTO(IMSTTSetup); + +/* +pointer IMSTTSetup(pointer module, pointer opts, int *errmaj, int *errmin); +*/ static XF86ModuleVersionInfo IMSTTVersRec = { "imstt", @@ -205,23 +214,25 @@ {0, 0, 0, 0} }; -XF86ModuleData IMSTTModuleData = { &IMSTTVersRec, IMSTTSetup, NULL }; +XF86ModuleData imsttModuleData = { &IMSTTVersRec, IMSTTSetup, NULL }; -static pointer IMSTTSetup(pointer module, pointer opts, int *errmaj, +pointer IMSTTSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; + IMSTTTRACE("IMSTTSetup -- begin\n"); if (!setupDone) { setupDone = TRUE; xf86AddDriver(&IMSTT, module, 0); - LoaderRefSymLists(0, cfbSymbols, xaaSymbols, 0, 9, fbdevHWSymbols, 0, 0, 0, NULL); + LoaderRefSymLists(cfbSymbols, xaaSymbols, fbdevHWSymbols, NULL); return (pointer) 1; } else { if (errmaj) *errmaj = LDR_ONCEONLY; return NULL; } + IMSTTTRACE("IMSTTSetup -- end\n"); } @@ -265,12 +276,13 @@ static Bool IMSTTProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; Bool foundScreen = FALSE; + IMSTTTRACE("IMSTTProbe begin\n"); /* sanity checks */ if ((numDevSections = xf86MatchDevice("imstt", &devSections)) <= 0) return FALSE; @@ -282,9 +294,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -311,6 +321,9 @@ NULL, NULL, NULL, NULL, NULL); } + + IMSTTTRACE("IMSTTProbe end\n"); + xfree(usedChips); return foundScreen; } @@ -364,6 +377,9 @@ if (pScrn->depth == 8) pScrn->rgbBits = 8; + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + pScrn->progClock = TRUE; if (!IMSTTGetRec(pScrn)) @@ -481,15 +497,19 @@ return FALSE; } + iptr->rev = (INREG(IMSTT_SSTATUS) & 0x0f00) >> 8; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "revision %d\n", iptr->rev); + if (!pScrn->videoRam) { + pScrn->videoRam = iptr->videoRam / 1024; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "probed videoram = %dk\n", - (iptr->videoRam / 1024)); - pScrn->videoRam = (iptr->videoRam / 1024); + pScrn->videoRam); } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "videoram = %dk\n", - pScrn->videoRam); + pScrn->videoRam / 1024); } /* XXX this is sorta a guess, got some info from the TVP3030 manual */ @@ -537,31 +557,16 @@ xf86PrintModes(pScrn); xf86SetDpi(pScrn, 0, 0); - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - break; - case 32: - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - IMSTTFreeRec(pScrn); + xf86LoadSubModule(pScrn, "fb"); +/* xf86LoaderReqSymbols(fbSymbols, NULL); */ + xf86LoaderReqSymbols("fbScreenInit", NULL); + + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; - } - xf86LoaderReqSymbols(reqSym, NULL); + xf86LoaderReqSymLists(xaaSymbols, NULL); - if (!iptr->NoAccel) { - if (!xf86LoadSubModule(pScrn, "xaa")) - return FALSE; - } + IMSTTTRACE("PreInit -- END\n"); return TRUE; } @@ -574,19 +579,17 @@ iptr = IMSTTPTR(pScrn); - if (iptr->FBDev) { - iptr->MMIOBase = fbdevHWMapMMIO(pScrn); - } else { - iptr->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, iptr->PciTag, - iptr->PciInfo->memBase[0] + 0x800000, - 0x1000); - } + iptr->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, iptr->PciTag, + iptr->PciInfo->memBase[0] + 0x800000, + 0x41000); if (!iptr->MMIOBase) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: could not map MMIO\n"); return FALSE; } + IMSTTTRACE("Mapped MMIO @ 0x%x with size 0x1000\n", iptr->PciInfo->memBase[0] + 0x800000); + IMSTTGetVideoMemSize(pScrn); if (iptr->FBDev) { @@ -655,6 +658,11 @@ IMSTTMMIO_VARS(); unsigned long tmp; + if (iptr->FBDev) { + iptr->videoRam = fbdevHWGetVidmem(pScrn); + return; + } + tmp = INREG(IMSTT_PRC); if (iptr->ramdac == RAMDAC_IBM) iptr->videoRam = (tmp & 0x0004) ? 0x400000 : 0x200000; @@ -675,86 +683,92 @@ VisualPtr visual; int r = TRUE; + IMSTTTRACE("ScreenInit -- Begin\n"); + pScrn = xf86Screens[pScreen->myNum]; - iptr = IMSTTPTR(pScrn); - /* initialize the card */ - tmp = INREG(IMSTT_STGCTL); - OUTREG(IMSTT_STGCTL, tmp & ~0x1); - OUTREG(IMSTT_SSR, 0); + iptr = IMSTTPTR(pScrn); - if (iptr->InitDAC) { - /* set default values for DAC registers */ - if (iptr->ramdac == RAMDAC_IBM) { - iptr->CMAPBase[IBM624_PPMASK] = 0xff; eieio(); - iptr->CMAPBase[IBM624_PIDXHI] = 0; eieio(); - OUTREGPI(IBM624_CLKCTL, 0x21); - OUTREGPI(IBM624_SYNCCTL, 0x00); - OUTREGPI(IBM624_HSYNCPOS, 0x00); - OUTREGPI(IBM624_PWRMNGMT, 0x00); - OUTREGPI(IBM624_DACOP, 0x02); - OUTREGPI(IBM624_PALETCTL, 0x00); - OUTREGPI(IBM624_SYSCLKCTL, 0x01); - OUTREGPI(IBM624_BPP8, 0x00); - OUTREGPI(IBM624_BPP16, 0x01); - OUTREGPI(IBM624_BPP24, 0x00); - OUTREGPI(IBM624_BPP32, 0x00); - OUTREGPI(IBM624_PIXCTL1, 0x05); - OUTREGPI(IBM624_PIXCTL2, 0x00); - OUTREGPI(IBM624_SYSCLKN, 0x08); - OUTREGPI(IBM624_SYSCLKM, 0x4f); - OUTREGPI(IBM624_SYSCLKP, 0x00); - OUTREGPI(IBM624_SYSCLKC, 0x00); - OUTREGPI(IBM624_CURSCTL, 0x00); - OUTREGPI(IBM624_CURSACCTL, 0x01); - OUTREGPI(IBM624_CURSACATTR, 0xa8); - OUTREGPI(IBM624_CURS1R, 0xff); - OUTREGPI(IBM624_CURS1G, 0xff); - OUTREGPI(IBM624_CURS1B, 0xff); - OUTREGPI(IBM624_CURS2R, 0xff); - OUTREGPI(IBM624_CURS2G, 0xff); - OUTREGPI(IBM624_CURS2B, 0xff); - OUTREGPI(IBM624_CURS3R, 0xff); - OUTREGPI(IBM624_CURS3G, 0xff); - OUTREGPI(IBM624_CURS3B, 0xff); - OUTREGPI(IBM624_BORDR, 0xff); - OUTREGPI(IBM624_BORDG, 0xff); - OUTREGPI(IBM624_BORDB, 0xff); - OUTREGPI(IBM624_MISCTL1, 0x01); - OUTREGPI(IBM624_MISCTL2, 0x45); - OUTREGPI(IBM624_MISCTL3, 0x00); - OUTREGPI(IBM624_KEYCTL, 0x00); - } else { - OUTREGPT(TVP_IRICC, 0x00); - OUTREGPT(TVP_IRBRC, 0xe4); - OUTREGPT(TVP_IRLAC, 0x06); - OUTREGPT(TVP_IRTCC, 0x80); - OUTREGPT(TVP_IRMXC, 0x4d); - OUTREGPT(TVP_IRCLS, 0x05); - OUTREGPT(TVP_IRPPG, 0x00); - OUTREGPT(TVP_IRGEC, 0x00); - OUTREGPT(TVP_IRMIC, 0x08); - OUTREGPT(TVP_IRCKL, 0xff); - OUTREGPT(TVP_IRCKH, 0xff); - OUTREGPT(TVP_IRCRL, 0xff); - OUTREGPT(TVP_IRCRH, 0xff); - OUTREGPT(TVP_IRCGL, 0xff); - OUTREGPT(TVP_IRCGH, 0xff); - OUTREGPT(TVP_IRCBL, 0xff); - OUTREGPT(TVP_IRCBH, 0xff); - OUTREGPT(TVP_IRCKC, 0x00); - OUTREGPT(TVP_IRPLA, 0x00); - OUTREGPT(TVP_IRPPD, 0xc0); - OUTREGPT(TVP_IRPPD, 0xd5); - OUTREGPT(TVP_IRPPD, 0xea); - OUTREGPT(TVP_IRPLA, 0x00); - OUTREGPT(TVP_IRMPD, 0xb9); - OUTREGPT(TVP_IRMPD, 0x3a); - OUTREGPT(TVP_IRMPD, 0xb1); - OUTREGPT(TVP_IRPLA, 0x00); - OUTREGPT(TVP_IRLPD, 0xc1); - OUTREGPT(TVP_IRLPD, 0x3d); - OUTREGPT(TVP_IRLPD, 0xf3); + if (!iptr->FBDev) { + /* initialize the card */ + tmp = INREG(IMSTT_STGCTL); + + OUTREG(IMSTT_STGCTL, tmp & ~0x1); + OUTREG(IMSTT_SSR, 0); + + if (iptr->InitDAC) { + /* set default values for DAC registers */ + if (iptr->ramdac == RAMDAC_IBM) { + iptr->CMAPBase[IBM624_PPMASK] = 0xff; eieio(); + iptr->CMAPBase[IBM624_PIDXHI] = 0; eieio(); + OUTREGPI(IBM624_CLKCTL, 0x21); + OUTREGPI(IBM624_SYNCCTL, 0x00); + OUTREGPI(IBM624_HSYNCPOS, 0x00); + OUTREGPI(IBM624_PWRMNGMT, 0x00); + OUTREGPI(IBM624_DACOP, 0x02); + OUTREGPI(IBM624_PALETCTL, 0x00); + OUTREGPI(IBM624_SYSCLKCTL, 0x01); + OUTREGPI(IBM624_BPP8, 0x00); + OUTREGPI(IBM624_BPP16, 0x01); + OUTREGPI(IBM624_BPP24, 0x00); + OUTREGPI(IBM624_BPP32, 0x00); + OUTREGPI(IBM624_PIXCTL1, 0x05); + OUTREGPI(IBM624_PIXCTL2, 0x00); + OUTREGPI(IBM624_SYSCLKN, 0x08); + OUTREGPI(IBM624_SYSCLKM, 0x4f); + OUTREGPI(IBM624_SYSCLKP, 0x00); + OUTREGPI(IBM624_SYSCLKC, 0x00); + OUTREGPI(IBM624_CURSCTL, 0x00); + OUTREGPI(IBM624_CURSACCTL, 0x01); + OUTREGPI(IBM624_CURSACATTR, 0xa8); + OUTREGPI(IBM624_CURS1R, 0xff); + OUTREGPI(IBM624_CURS1G, 0xff); + OUTREGPI(IBM624_CURS1B, 0xff); + OUTREGPI(IBM624_CURS2R, 0xff); + OUTREGPI(IBM624_CURS2G, 0xff); + OUTREGPI(IBM624_CURS2B, 0xff); + OUTREGPI(IBM624_CURS3R, 0xff); + OUTREGPI(IBM624_CURS3G, 0xff); + OUTREGPI(IBM624_CURS3B, 0xff); + OUTREGPI(IBM624_BORDR, 0xff); + OUTREGPI(IBM624_BORDG, 0xff); + OUTREGPI(IBM624_BORDB, 0xff); + OUTREGPI(IBM624_MISCTL1, 0x01); + OUTREGPI(IBM624_MISCTL2, 0x45); + OUTREGPI(IBM624_MISCTL3, 0x00); + OUTREGPI(IBM624_KEYCTL, 0x00); + } else { + OUTREGPT(TVP_IRICC, 0x00); + OUTREGPT(TVP_IRBRC, 0xe4); + OUTREGPT(TVP_IRLAC, 0x06); + OUTREGPT(TVP_IRTCC, 0x80); + OUTREGPT(TVP_IRMXC, 0x4d); + OUTREGPT(TVP_IRCLS, 0x05); + OUTREGPT(TVP_IRPPG, 0x00); + OUTREGPT(TVP_IRGEC, 0x00); + OUTREGPT(TVP_IRMIC, 0x08); + OUTREGPT(TVP_IRCKL, 0xff); + OUTREGPT(TVP_IRCKH, 0xff); + OUTREGPT(TVP_IRCRL, 0xff); + OUTREGPT(TVP_IRCRH, 0xff); + OUTREGPT(TVP_IRCGL, 0xff); + OUTREGPT(TVP_IRCGH, 0xff); + OUTREGPT(TVP_IRCBL, 0xff); + OUTREGPT(TVP_IRCBH, 0xff); + OUTREGPT(TVP_IRCKC, 0x00); + OUTREGPT(TVP_IRPLA, 0x00); + OUTREGPT(TVP_IRPPD, 0xc0); + OUTREGPT(TVP_IRPPD, 0xd5); + OUTREGPT(TVP_IRPPD, 0xea); + OUTREGPT(TVP_IRPLA, 0x00); + OUTREGPT(TVP_IRMPD, 0xb9); + OUTREGPT(TVP_IRMPD, 0x3a); + OUTREGPT(TVP_IRMPD, 0xb1); + OUTREGPT(TVP_IRPLA, 0x00); + OUTREGPT(TVP_IRLPD, 0xc1); + OUTREGPT(TVP_IRLPD, 0x3d); + OUTREGPT(TVP_IRLPD, 0xf3); + } } } @@ -782,28 +796,16 @@ switch (pScrn->bitsPerPixel) { case 8: - r = cfbScreenInit(pScreen, iptr->FBBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 16: - r = cfb16ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 24: - r = cfb24ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 32: - r = cfb32ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX, + r = fbScreenInit(pScreen, iptr->FBBase, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); + pScrn->displayWidth, pScrn->bitsPerPixel); break; default: - r = FALSE; - break; + ErrorF("invalid bpp %d\n", pScrn->bitsPerPixel); + return FALSE; } if (!r) { @@ -853,6 +855,12 @@ if (serverGeneration == 1) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + pScreen->SaveScreen = IMSTTSaveScreen; + pScreen->CloseScreen = IMSTTCloseScreen; + + IMSTTTRACE("ScreenInit -- End\n"); + + return TRUE; } @@ -1289,4 +1297,24 @@ OUTREG(IMSTT_SSR, offset); return; +} + + +Bool IMSTTCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + IMSTTPtr iptr = IMSTTPTR(pScrn); + + if (iptr->FBDev) + fbdevHWSave(pScrn); + + return TRUE; +} + + +Bool IMSTTSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + return TRUE; } Index: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h diff -u xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h:1.2 Mon Jun 19 11:01:02 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h Wed Aug 2 17:36:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h,v 1.2 2000/06/19 15:01:02 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h,v 1.4 2000/08/02 21:36:32 dawes Exp $ */ #ifndef _IMSTT_REG_H #define _IMSTT_REG_H @@ -28,13 +28,13 @@ } -#define INREG(addr) regr(((unsigned long)IMSTTMMIO), (addr)) -#define OUTREG(addr, val) regw(((unsigned long)IMSTTMMIO), (addr), (val)) +#define INREG(addr) regr(((unsigned long)(iptr->MMIOBase)), (addr)) +#define OUTREG(addr, val) regw(((unsigned long)(iptr->MMIOBase)), (addr), (val)) #else -#define INREG(addr) MMIO_IN32(IMSTTMMIO, addr) -#define OUTREG(addr, val) MMIO_OUT32(IMSTTMMIO, addr, val) +#define INREG(addr) MMIO_IN32(iptr->MMIOBase, addr) +#define OUTREG(addr, val) MMIO_OUT32(iptr->MMIOBase, addr, val) #endif Index: xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile:1.33 xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile:1.39 --- xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile:1.33 Fri Jun 16 20:03:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile Thu Dec 14 11:38:49 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile,v 1.33 2000/06/17 00:03:19 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile,v 1.39 2000/12/14 16:38:49 dawes Exp $ XCOMM XCOMM This is an Imakefile for the MGA driver. XCOMM @@ -6,25 +6,70 @@ #define IHaveModules #include <Server.tmpl> +#if BuildMatroxHal +#define IHaveSubdirs +SUBDIRS=hallib +#endif + #if BuildXF86DRI DRISRCS = mga_dri.c mga_warp.c mga_wrap.c DRIOBJS = mga_dri.o mga_warp.o mga_wrap.o DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \ - -I$(XF86OSSRC)/linux/drm/kernel -I$(TOP)/include + -I$(TOP)/include DRIDEFINES = $(GLX_DEFINES) #endif + +#if DoLoadableServer && (HaveMatroxHal || BuildMatroxHal) +#define BuildHalModule YES +#else +#define BuildHalModule NO +#endif + +#if !DoLoadableServer && UseMatroxHal && (HaveMatroxHal || BuildMatroxHal) +#define BuildHalStatic YES +#else +#define BuildHalStatic NO +#endif + +#if BuildHalModule +MGAHALMODSRC = mga_halmod.c +MGAHALMODOBJ = mga_halmod.o +#endif + +#if UseMatroxHal +MGAHALDEFINES = -DUSEMGAHAL +#if BuildMatroxHal +MGAHALINCLUDES = -Ihallib +#else +MGAHALINCLUDES = -IHALlib +#endif +#endif -SRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \ +#if BuildHalModule || BuildHalStatic +MGAHALSRCS = $(MGAHALMODSRC) clientlx.c +#if !BuildMatroxHal +MGAHALOBJS = $(MGAHALMODOBJ) clientlx.o HALlib/mgaHALlib.a +#else +MGAHALOBJS = $(MGAHALMODOBJ) clientlx.o hallib/libmga_hal.a +hallib/libmga_hal.a: $(SUBDIRS) +#endif +#endif + +MGASRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \ mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \ - mga_dga.c mga_shadow.c mga_video.c $(DRISRCS) -OBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \ + mga_dga.c mga_shadow.c mga_video.c $(DRISRCS) +MGAOBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \ mga_storm8.o mga_storm16.o mga_storm24.o mga_storm32.o mga_arc.o \ - mga_dga.o mga_shadow.o mga_video.o $(DRIOBJS) + mga_dga.o mga_shadow.o mga_video.o $(DRIOBJS) + +SRCS = $(MGASRCS) $(MGAHALSRCS) +OBJS = $(MGAOBJS) $(MGAHALOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else -INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ +INCLUDES = -I. $(MGAHALINCLUDES) -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/fb \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(XF86SRC)/int10 \ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ @@ -32,10 +77,11 @@ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf8_32bpp\ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) \ + -I$(SERVERSRC)/render \ -I$(XF86OSSRC)/vbe $(DRIINCLUDES) #endif -DEFINES = $(DRIDEFINES) +DEFINES = $(MGAHALDEFINES) $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -43,7 +89,14 @@ ModuleObjectRule() +#if BuildHalStatic ObjectModuleTarget(mga,$(OBJS)) +#else +ObjectModuleTarget(mga,$(MGAOBJS)) +#endif +#if BuildHalModule +ObjectModuleTarget(mga_hal,$(MGAHALOBJS)) +#endif ObjectFromSpecialSource(mga_storm8, mga_storm, -DPSZ=8) ObjectFromSpecialSource(mga_storm16, mga_storm, -DPSZ=16) @@ -51,6 +104,9 @@ ObjectFromSpecialSource(mga_storm32, mga_storm, -DPSZ=32) InstallObjectModule(mga,$(MODULEDIR),drivers) +#if BuildHalModule +InstallObjectModule(mga_hal,$(MODULEDIR),drivers) +#endif #if !defined(XF86DriverSDK) CppManTarget(mga,) @@ -74,6 +130,16 @@ InstallDriverSDKNonExecFile(mga_shadow.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_storm.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKNonExecFile(mga_video.c,$(DRIVERSDKDIR)/drivers/mga) +InstallDriverSDKNonExecFile(mga_halmod.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKObjectModule(mga,$(DRIVERSDKMODULEDIR),drivers) +#if BuildMatroxHal +InstallDriverSDKObjectModule(mga_hal,$(DRIVERSDKMODULEDIR),drivers) +#endif + +#if BuildMatroxHal +MakeSubdirs($(SUBDIRS)) +ForceSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/mga/README diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/README:1.6 xc/programs/Xserver/hw/xfree86/drivers/mga/README:removed --- xc/programs/Xserver/hw/xfree86/drivers/mga/README:1.6 Fri Nov 19 08:54:39 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/README Mon Dec 18 14:30:48 2000 @@ -1,182 +0,0 @@ -$XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/README,v 1.6 1999/11/19 13:54:39 hohndel Exp $ - -MGA Millennium (MGA2064W) with TVP3026 RAMDAC Driver v1.3 -========================================================= -MGA Mystique (MGA1064W) with integrated RAMDAC Driver v1.3 -========================================================= -MGA Millennium II (MGA2164W) with TVP3026 RAMDAC Driver v1.3 - -NOTE: This driver is fairly new, and not everything works like you expect -it to. It shouldn't crash your machine, and there are problems with 24 bpp, -but it should work pretty well. Please report any and all problems to -XFree86@Xfree86.org using the appropriate bug report sheet. - -Features: ---------- - -* Supports the Matrox Millennium, Mystique and Millennium II adapters -* Can only use a linear frame buffer -* It should be possible to reach resolutions up to 1920x1024 or 1600x1200 -* It should be possible to use pixel depths of: - - 8 bits per pixel (256 pseudo colour) - - 16 bits per pixel (high colour) - - 24 bits per pixel (packed true colour) ** - - 32 bits per pixel (true colour) - -There are some 24 bpp mode problems - tiling doesn't work properly, so for some -programs, notably Netscape, gimp, xsetroot, etc, you may see corrupted images. - -Planned Features ----------------- - -In order from highest to lowest priority: - -* More accurate rendering at all speeds -* More reliability, especially in autodetection -* 3D acceleration - -Technical Notes: ----------------- - -Hardware Supported: -------------------- - -Matrox Millennium I rev 1 and 2 -- with TVP3026 RAMDAC at 175, 220, 250 MHz -Matrox Millennium II rev 1 -- with TVP3026 RAMDAC at 220 MHz -Matrox Mystique rev 1 -- with internal RAMDAC at 135 (rare), 170, and 220 MHz - -The driver autodetects the amount of video memory availble (for both SGRAM -and WRAM models), so it is unnecessary to specify the VideoMem option. - -Support for other Matrox cards is planned, pending the receipt of documentation -from Matrox. - -Configuration: --------------- - -The driver auto-detects all device info included memory size, so use the following device -section in your XF86Config file: - -- for Millenium board: ----------------------- - Section "Device" - Identifier "Matrox Millennium" - VendorName "Matrox" - BoardName "Millennium" - EndSection - -- for Mystique board: -- - - - - - - - - - - - Section "Device" - Identifier "Mystique" - VendorName "Matrox" - BoardName "mga1064sg" - EndSection - -or let xf86config or XF86Setup do this for you. - -But if you have problems with auto-detection, you can specify: - - VideoRam - in kilobytes - DacSpeed - in MHz - MemBase - physical address of the linear framebuffer - IoBase - physical address of the memory mapped IO registers - BiosBase - physical address of BIOS - - -Driver Options: ---------------- - -"noaccel" - turns off Drawing Engine (mandatory for Mystique) -"sw_cursor" - turns hardware cursor off -"xaa_benchmark" - do some benchmarks during startup - -- for Mystique board: -- - - - - - - - - - - -Interleaved features are not available - -Memory Clock Hack ------------------ - -- for Millenium and Millennium II adapter: -- - - - - - - - - - - - -It seems some Millenniums have a BIOS that defines the memory clock -for 2 MB and 4 MB cards to be 50 MHz, while others define it to be -60 MHz. Using the faster clock speeds up drawing operations a good -amount, so a hack has been put in place to set MCLK from XF86Config. - -In the file mga_dac3026.c, simply change the following line: - #define MCLK_FROM_XCONFIG 0 -to this: - #define MCLK_FROM_XCONFIG 1 - -and specify in XF86Config: - - Set_Mclk - in MHz - -USE THIS HACK ENTIRELY AT YOUR OWN RISK!!!!!!!!!!!! - -Using memory clocks from 40 to 50 MHz should be completely safe. Setting -the memory clock higher than 50 MHz, up to 65 MHz has been tested, and -seems to work. DO NOT EXCEED 65 MHz, or the video memory contents will -become corrupted and you may damage the card! - -The Millennium II is automatically set to 60 MHz, so this hack is of limited -use. It also has the ability to tune itself for 4, 8, 12 and 16 MB of WRAM -installed. We recommend against using this option on the Millennium II at -this time. - -- for Mystique board: -- - - - - - - - - - - -MCLK_FROM_XCONFIG flag has no effect. - -Main author: ------------- - -Radoslaw Kapitan, Tarnow, Poland -kapitan@student.uci.agh.edu.pl - -Code, Additions and Testing: ----------------------------- - -Andrew E. Mileski, Ottawa, Canada -aem@ott.hookup.net - -Andrew van der Stock, Melbourne, Australia -Andrew.van.der.Stock@member.sage-au.org.au - -Angsar Hockmann -Ansgar.Hockmann@hrz.uni-dortmund.de - -A Joseph Koshy, Tester -koshy@india.hp.com - -Leonard N. Zubkoff -lnz@dandelion.com - -Mark Vojkovich -mvojkovi@sdcc10.ucsd.edu - -Michael Will -zxmgv07@student.uni-tuebingen.de - -Guy DESBIEF -g.desbief@aix.pacwan.net - -XAA ---- - -Harm Hanemaayer -mailto:H.Hanemaayer@inter.nl.net - -Various hacks, features and patcher ------------------------------------ - -Dirk Hohndel -hohndel@XFree86.Org - - Index: xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB:1.1 --- /dev/null Mon Dec 18 14:30:48 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/README_HALLIB Tue Oct 24 18:45:06 2000 @@ -0,0 +1,209 @@ +HAL Documentation + +This documentation provides preliminary explaination of the HAL library, a +more detailed version of this document is in the process of being written +and will be released with future driver builds. + +------------------------------------------------------------ +MGAOpenLibrary + +Description: Link Client functions with HAL Librery + +Input: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +LPBARDHANDLElpClient: Pointer to the client stucture + +ulClientSize: Size of the client structure + +Error: +return 0 on success + +------------------------------------------------------------- +MGAGetHardwareInfo + +Description: + +Fills MGAWINFO structure. + +struct { +ULONG UlCapsFirstOutput; +ULONG ulCapsSecondOutput; +ULONG ulVideoMemory; +} FAR *LPMGAHWINFO; + +#define MGAHWINFOCAPS_CRTC1_DIGITAL (1L << 1) +#define MGAHWINFOCAPS_CRTC1_TV (1L << 2) +#define MGAHWINFOCAPS_CRTC2_ANALOG (1L << 3) +#define MGAHWINFOCAPS_CRTC2_DIGITAL (1L << 4) +#define MGAHWINFOCAPS_CRTC2_TV (1L << 5) +#define MGAHWINFOCAPS_OUTPUT_VGA (1L << 6) +#define MGAHWINFOCAPS_CRTC2 (MGAHWINFOCAPS_CRTC2_ANALOG | MGAHWINFOCAPS_CRTC2_DIGITAL | MGAHWINFOCAPS_CRTC2_TV) +#define MGAHWINFOCAPS_OUTPUT_ANALOG (MGAHWINFOCAPS_CRTC1_ANALOG | MGAHWINFOCAPS_CRTC2_ANALOG) +#define MGAHWINFOCAPS_OUTPUT_DIGITAL (MGAHWINFOCAPS_CRTC1_DIGITAL | MGAHWINFOCAPS_CRTC2_DIGITAL) +#define MGAHWINFOCAPS_OUTPUT_TV (MGAHWINFOCAPS_CRTC1_TV | MGAHWINFOCAPS_CRTC2_TV) + +example: + +if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_TV ) +{ + ErrorF("TV detected\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TV detected\n "); +} +if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_DIGITAL) +{ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Digital Screen detected\n "); +} + +Inputs: + +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +LPMGAHWINFO pMgaHwInfo: Handle to the board structure containing all +the information about the specific Board. + +Error: +Returns 0 on success +------------------------------------------------------------ +MGAValidateMode + +Description: + +Validates the mode given by client. + +Here are the different options for pMgaModeInfo->flOutput: + +MGAMODEINFO_FORCE_PITCH +MGAMODEINFO_FORCE_DISPLAYORG +MGAMODEINFO_SECOND_CRTC +MGAMODEINFO_ANALOG1 +MGAMODEINFO_ANALOG2 +MGAMODEINFO_DIGITAL1 +MGAMODEINFO_DIGITAL2 +MGAMODEINFO_TV + +These options can be combined together to set different combinations. +Example: + +/*The second crtc outputs to a digital screen*/ +pMgaModeInfo->flOutput= MGAMODEINFO_DIGITAL2 | MGAMODEINFO_SECOND_CRTC +| MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +- or - + +/*The second crtc outputs to an analog screen*/ +pMgaModeInfo-> flOutput = MGAMODEINFO_ANALOG2| MGAMODEINFO_SECOND_CRTC +| MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +- or - + +/*The second crtc outputs to a tv*/ +pMga->pMgaModeInfo->flOutput = MGAMODEINFO_TV | MGAMODEINFO_SECOND_CRTC | MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +LPMGAMODEINFO pMgaModeInfo: Pointer to structure containing information about a specific display mode. (You need to fill the structure except the video parameters part which will be filled by the function). + +Error: +Returns 0 on success + +------------------------------------------------------------- +MGASetMode + +Description: + +Initializes the board. + +Here are the different options for pMgaModeInfo->flOutput: + +MGAMODEINFO_FORCE_PITCH +MGAMODEINFO_FORCE_DISPLAYORG +MGAMODEINFO_SECOND_CRTC +MGAMODEINFO_ANALOG1 +MGAMODEINFO_ANALOG2 +MGAMODEINFO_DIGITAL1 +MGAMODEINFO_DIGITAL2 +MGAMODEINFO_TV + +These options can be combined together to set different combinations. +Example: + +/*The second crtc outputs to a digital screen*/ +pMgaModeInfo->flOutput= MGAMODEINFO_DIGITAL2 | MGAMODEINFO_SECOND_CRTC +| MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +- or - + +/*The second crtc outputs to an analog screen*/ +pMgaModeInfo-> flOutput = MGAMODEINFO_ANALOG2| MGAMODEINFO_SECOND_CRTC +| MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +- or - + +/*The second crtc outputs to a tv*/ +pMga->pMgaModeInfo->flOutput = MGAMODEINFO_TV | MGAMODEINFO_SECOND_CRTC | MGAMODEINFO_FORCE_PITCH | MGAMODEINFO_FORCE_DISPLAYORG; + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +LPMGAMODEINFO pMgaModeInfo: Pointer to structure containing information about a specific display mode. (You need to fill the structure except the video parameters part which will be filled by the function). + +Error: +Returns 0 on success + +------------------------------------------------------------ + +MGASetVgaMode + +Description: + +Switchs the VGA mode + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +Error: +Returns 0 on success + +------------------------------------------------------------ + +MGARestoreVgaState + +Description: + +Restores the VGA State + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +Error: +Returns 0 on success + +------------------------------------------------------------ + +MGASaveVgaState + +Description: + +Saves the VGA state + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +Error: +Returns 0 on success + +------------------------------------------------------------ + +MGACloseLibrary + +Description: + +Closes the library + +Inputs: +LPBOARDHANDLE pBoard: Handle to the board structure containing all the information about the board. + +Error: +Returns 0 on success Index: xc/programs/Xserver/hw/xfree86/drivers/mga/client.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/mga/client.h:1.1 --- /dev/null Mon Dec 18 14:30:48 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/client.h Tue Oct 24 18:45:06 2000 @@ -0,0 +1,68 @@ +#ifndef _CLIENT +#define _CLIENT + +#include "binding.h" + +#if defined(__cplusplus) + extern "C" { +#endif + +typedef void* LPBIOSREGS; +#define ASSERT_HANDLER(pBoard) + +typedef struct TAGCLIENTDATA +{ + ULONG ulFrameBufferBase; + ULONG ulRegisterBase; + pointer pMga; +} CLIENTDATA, *LPCLIENTDATA; + +extern ULONG DECL ClientReadConfigSpaceByte(LPBOARDHANDLE, ULONG, LPUCHAR); +extern ULONG DECL ClientReadConfigSpaceDword(LPBOARDHANDLE , ULONG, LPULONG ); +extern ULONG DECL ClientWriteConfigSpaceByte (LPBOARDHANDLE , ULONG, UCHAR); +extern ULONG DECL ClientWriteConfigSpaceDword(LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientOpenRegisterBase(LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientCloseRegisterBase (LPBOARDHANDLE ); +extern ULONG DECL ClientReadRegisterByte(LPBOARDHANDLE , ULONG, LPUCHAR ); +extern ULONG DECL ClientReadRegisterDword(LPBOARDHANDLE , ULONG, LPULONG ); +extern ULONG DECL ClientWriteRegisterByte (LPBOARDHANDLE , ULONG, UCHAR); +extern ULONG DECL ClientWriteRegisterDword(LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientOpenMemoryBase(LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientCloseMemoryBase(LPBOARDHANDLE ); +extern ULONG DECL ClientReadMemoryByte(LPBOARDHANDLE , ULONG, LPUCHAR ); +extern ULONG DECL ClientReadMemoryDword (LPBOARDHANDLE , ULONG, LPULONG ); +extern ULONG DECL ClientWriteMemoryByte(LPBOARDHANDLE , ULONG, UCHAR); +extern ULONG DECL ClientWriteMemoryDword (LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientOpenSystemDevice (LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientCloseSystemDevice (LPBOARDHANDLE ); +extern ULONG DECL ClientReadSystemDeviceByte(LPBOARDHANDLE , ULONG, LPUCHAR ); +extern ULONG DECL ClientReadSystemDeviceDword(LPBOARDHANDLE , ULONG, LPULONG ); +extern ULONG DECL ClientWriteSystemDeviceByte(LPBOARDHANDLE , ULONG, UCHAR); +extern ULONG DECL ClientWriteSystemDeviceDword (LPBOARDHANDLE , ULONG, ULONG); +extern ULONG DECL ClientWait (LPBOARDHANDLE , ULONG); +extern ULONG DECL ClientLocateFirstTwisterOfQuad(ULONG); +extern ULONG DECL ClientSearchDevNode(ULONG, UCHAR, UCHAR); +extern ULONG DECL ClientGetBiosInfo(LPBOARDHANDLE, LPUCHAR, LPULONG ); +extern ULONG DECL ClientDebug (LPBOARDHANDLE , ULONG, LPUCHAR, ULONG, LPVOID); +extern ULONG DECL ClientCallBiosInt10(LPBOARDHANDLE, LPBIOSREGS); +extern ULONG DECL ClientReadDDCEdid(LPBOARDHANDLE, LPUCHAR, ULONG); +extern ULONG DECL ClientCustomCall(LPBOARDHANDLE, ULONG, LPVOID, LPVOID); +extern ULONG DECL ClientApplyEpromPatch(LPBOARDHANDLE); +extern ULONG DECL ClientDetectHostInterface(LPBOARDHANDLE, LPULONG); +extern ULONG DECL ClientHSLPatchFunction(LPBOARDHANDLE, ULONG, ULONG, LPUCHAR); +extern ULONG DECL InitClientFunctions(LPBOARDHANDLE, ULONG); +extern ULONG DECL ClientInitTimeBase(LPBOARDHANDLE); +extern ULONG DECL ClientOpenDMABase(LPBOARDHANDLE, ULONG, ULONG); +extern ULONG DECL ClientReadDMAByte(LPBOARDHANDLE, ULONG, LPUCHAR); +extern ULONG DECL ClientReadBIOS(LPBOARDHANDLE, ULONG, ULONG, ULONG, ULONG, LPUCHAR); +extern ULONG DECL ClientWriteBIOS(LPBOARDHANDLE, ULONG, ULONG, ULONG, ULONG); + +#if defined(__cplusplus) + } +#endif + +#define ESC_CUSTOM_SET_FUNCTION_PTR 0x80000200 +#define ESC_CUSTOM_GET_FUNCTION_PTR 0x80000201 +#define ESC_CUSTOM_PATCH_HSL 0x80000202 + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/mga/clientlx.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/mga/clientlx.c:1.1 --- /dev/null Mon Dec 18 14:30:48 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/clientlx.c Tue Oct 24 18:45:06 2000 @@ -0,0 +1,829 @@ +/******************************************************************************\ + + clientlx.c + + Copyright © 1997, Matrox Graphics Inc. + + All Rights Reserved. + +\******************************************************************************/ +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "xf86_ansic.h" +#include "client.h" +#include "mga.h" + +CLIENTTABLE ClientFunctions = { + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadConfigSpaceByte, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadConfigSpaceDword, + (ULONG (DECL *)(LPVOID,ULONG,UCHAR)) ClientWriteConfigSpaceByte, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientWriteConfigSpaceDword, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientOpenRegisterBase, + (ULONG (DECL *)(LPVOID)) ClientCloseRegisterBase, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadRegisterByte, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadRegisterDword, + (ULONG (DECL *)(LPVOID,ULONG,UCHAR)) ClientWriteRegisterByte, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientWriteRegisterDword, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientOpenMemoryBase, + (ULONG (DECL *)(LPVOID)) ClientCloseMemoryBase, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadMemoryByte, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadMemoryDword, + (ULONG (DECL *)(LPVOID,ULONG,UCHAR)) ClientWriteMemoryByte, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientWriteMemoryDword, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientOpenSystemDevice, + (ULONG (DECL *)(LPVOID)) ClientCloseSystemDevice, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadSystemDeviceByte, + (ULONG (DECL *)(LPVOID,ULONG,LPVOID)) ClientReadSystemDeviceDword, + (ULONG (DECL *)(LPVOID,ULONG,UCHAR)) ClientWriteSystemDeviceByte, + (ULONG (DECL *)(LPVOID,ULONG,ULONG)) ClientWriteSystemDeviceDword, + (ULONG (DECL *)(LPVOID,ULONG)) ClientWait, + (ULONG (DECL *)(LPVOID,LPVOID,LPVOID)) ClientGetBiosInfo, + (ULONG (DECL *)(LPVOID,LPVOID,ULONG)) ClientReadDDCEdid +}; + +/******************************************************************************\ + + Function : ClientReadConfigSpaceByte + + Description : Read a Byte from the configuration space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specifib board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR *pucByte | pointer to a byte that will receive + the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR *pucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr)pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + *pucByte = pciReadByte(pMga->PciTag,ulOffset); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientReadConfigSpaceDword + + Description : Read a Dword from the configuration space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG *pulDword | Dword to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG *pulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr)pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + *pulDword = pciReadLong(pMga->PciTag,ulOffset); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteConfigSpaceByte + + Description : Write a Byte from the configuration space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR ucByte | Byte to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR ucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr)pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + pciWriteByte(pMga->PciTag,ulOffset, ucByte); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteConfigSpaceDword + + Description : Write a Dword from the configuration space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG ulDword | Dword containing the data to be written + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG ulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr)pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + pciWriteLong(pMga->PciTag,ulOffset, ulDword); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientOpenRegisterBase + + Description : Map the register base for future call to ClientReadRegisterX + and ClientWriteRegisterX. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulAddress | Physical address of the Register aperture + ULONG ulSize | Size in Byte of the Register Aperture + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientOpenRegisterBase(LPBOARDHANDLE pBoard, ULONG ulAddress, ULONG ulSize) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr)pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + pClientStruct->ulRegisterBase = (ULONG) pMga->IOBase; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientCloseRegisterBase + + Description : Unmap the register base address and free resources needed + to address it. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientCloseRegisterBase(LPBOARDHANDLE pBoard) +{ + ASSERT_HANDLER(pBoard); + return 0; +} + + +/******************************************************************************\ + + Function : ClientReadRegisterByte + + Description : Read a byte from the Register space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure. + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR *pucByte | pointer to the byte that will receive + the data. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadRegisterByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR *pucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *pucByte = *((UCHAR *)(pClientStruct->ulRegisterBase + ulOffset)); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientReadRegisterDword + + Description : Read a Dword from the Register space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG *pulDword | pointer to the dword that will receive + the data. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadRegisterDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG *pulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *pulDword = *((ULONG *)(pClientStruct->ulRegisterBase + ulOffset)); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteRegisterByte + + Description : Write a Byte from the Register space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR ucByte | CHAR to receive the data. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteRegisterByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR ucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *((UCHAR *)(pClientStruct->ulRegisterBase + ulOffset)) = ucByte; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteRegisterSpaceDword + + Description : Write a Dword from the Register space. + + I/O Desc. : LPBOARDHANDLE *| pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG ulDword | Dword to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteRegisterDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG ulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *((ULONG *)(pClientStruct->ulRegisterBase + ulOffset)) = ulDword; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientOpenMemoryBase + + Description : Map the Memory base for future call to ClientReadMemoryX + and ClientWriteMemoryX. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulAddress | Physical address of the Register aperture + ULONG ulSize | Size in Byte of the Register Aperture + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientOpenMemoryBase(LPBOARDHANDLE pBoard, ULONG ulAddress, ULONG ulSize) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + MGAPtr pMga = (MGAPtr) pClientStruct->pMga; + + ASSERT_HANDLER(pBoard); + + pClientStruct->ulFrameBufferBase = (ULONG) pMga->FbBase; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientCloseMemoryBase + + Description : Unmap the Frame Buffer aperture and free resources + needed to address it. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientCloseMemoryBase(LPBOARDHANDLE pBoard) +{ + ASSERT_HANDLER(pBoard); + return 0; +} + + +/******************************************************************************\ + + Function : ClientReadMemoryByte + + Description : Read a Byte from the Frame Buffer space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR *ucByte | CHAR to receive the data + + Return Val : ULONG +\******************************************************************************/ +ULONG ClientReadMemoryByte(LPBOARDHANDLE pBoard, ULONG ulOffset, UCHAR *pucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *pucByte = *((UCHAR *)(pClientStruct->ulFrameBufferBase + ulOffset)); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientReadMemoryDword + + Description : Read a Dword from the Frame Buffer Space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG *uDword | Dword to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadMemoryDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG *pulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *pulDword = *((ULONG *)(pClientStruct->ulFrameBufferBase + ulOffset)); + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteMemoryByte + + Description : Write a Byte from the Frame Buffer space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR ucByte | CHAR to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteMemoryByte(LPBOARDHANDLE pBoard, ULONG ulOffset, UCHAR ucByte) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *((UCHAR *)(pClientStruct->ulFrameBufferBase + ulOffset)) = ucByte; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientWriteMemoryDword + + Description : Write a Dword from the Frame Buffer space. + + I/O desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG ulDword | Dword to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteMemoryDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG ulDword) +{ + LPCLIENTDATA pClientStruct = MGAGetClientPointer(pBoard); + + ASSERT_HANDLER(pBoard); + + *((ULONG *)(pClientStruct->ulFrameBufferBase + ulOffset)) = ulDword; + + return 0; +} + + +/******************************************************************************\ + + Function : ClientOpenSystemDevice + + Description : Map a System device aperture for future call to + ClientReadSystemDeviceX and ClientWriteSystemDeviceX. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulAddress | Physical address of the Register aperture + ULONG ulSize | Size in Byte of the Register Aperture + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientOpenSystemDevice(LPBOARDHANDLE pBoard, ULONG ulAddress, + ULONG ulSize) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientCloseSystemDevice + + Description : Unmap the System Device aperture address and free + resources needed to address it. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientCloseSystemDevice (LPBOARDHANDLE pBoard) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientReadSystemDeviceByte + + Description : Read a Byte from the device Space. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG pucByte | Byte to read the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadSystemDeviceByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR *pucByte) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientReadSystemDeviceDword + + Description : Read a Dword from the Frame Buffer Space + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG ulDword | Dword to Read the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadSystemDeviceDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG *pulDword) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientWriteSystemByte + + Description : Write a Byte from the System Device Aperture + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + UCHAR ucByte | Byte to receive the data + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteSystemDeviceByte(LPBOARDHANDLE pBoard, ULONG ulOffset, + UCHAR ucByte) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientWriteSystemDword + + Description : Write a Dword from the System Device Aperture. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulOffset | Offset of the Byte to be read. + ULONG uDword | Dword to receive the data + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWriteSystemDeviceDword(LPBOARDHANDLE pBoard, ULONG ulOffset, + ULONG ulDword) +{ + return 1; +} + + +/******************************************************************************\ + + Function : ClientWait + + Description : Wait for ulDelayus micro-seconds. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + ULONG ulDelayus | Delay in uSec + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientWait (LPBOARDHANDLE pBoard, ULONG ulDelayus) +{ + int i; + ULONG ulTmp; + + ASSERT_HANDLER(pBoard); + + for(i = 0; i < ulDelayus * 3; i++) + { + ClientReadRegisterDword(pBoard,0x1e14,&ulTmp); + } + + return 0; +} + + +/******************************************************************************\ + + Function : ClientGetBiosInfo + + Description : This function will be call if no PINS can be found + in physical EEPROM. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPUCHAR | Buffer where we copy bios pins. + ULONG | Bios version + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientGetBiosInfo(LPBOARDHANDLE pBoard, LPUCHAR pucPins,LPULONG pulBIOSVersion) +{ + Bool bNotFound = TRUE; + UCHAR ucBIOS[32768]; + UCHAR ucTmpByte; + UCHAR ucCheckSum; + UCHAR ucPinsIndex; + UCHAR ucPinsSize; + ULONG ulTmpDword; + ULONG ulPinsOffset = 0; + ULONG ulPCIINFOffset; + + ASSERT_HANDLER(pBoard); + + xf86ReadBIOS(0xc0000,0,ucBIOS,32768); + + if(ucBIOS[0] == 0x55) + { + if(ucBIOS[1] == 0xaa) + { + while((ulPinsOffset < 0x10000) && bNotFound) + { + ulTmpDword = *(ULONG *)(ucBIOS + ulPinsOffset); + ucPinsSize = (UCHAR) (ulTmpDword >> 16); + if(((ulTmpDword & 0x0000ffff) == 0x0000412e) + && ucPinsSize <= 128) + { + ucCheckSum = 0; + for(ucPinsIndex = 0;ucPinsIndex < ucPinsSize; ucPinsIndex++) + { + pucPins[ucPinsIndex] = ucBIOS[ulPinsOffset + + ucPinsIndex]; + ucCheckSum += pucPins[ucPinsIndex]; + } + if(ucCheckSum == 0) + { + bNotFound = FALSE; + } + } + ulPinsOffset++; + } + + if(bNotFound) + { + return 1; + } + + ulPCIINFOffset = *(ULONG *)(ucBIOS + 0x18); + ulPCIINFOffset &= 0x0000ffff; + ulTmpDword = *(ULONG *)(ucBIOS + ulPCIINFOffset); + + if(ulTmpDword == 0x52494350) /* "PCIR" */ + { + ulPCIINFOffset += 0x12; + ulTmpDword = *(ULONG *)(ucBIOS + ulPCIINFOffset); + *pulBIOSVersion = ((ULONG) ((ulTmpDword & 0xf0) >> 4) << 16) | + ((ulTmpDword &0xf) << 12) | ((ulTmpDword >> 8) + & 0xff); + } + else + { + return 1; + } + } + else + { + return 1; + } + } + else + { + return 1; + } + + if(!*pulBIOSVersion) + { + ucTmpByte = ucBIOS[5]; + *pulBIOSVersion = ((ULONG) (ucTmpByte >> 4) << 16) | ((ULONG) + (ucTmpByte & 0x0f) << 12); + } + + return 0; +} + +/******************************************************************************\ + + Function : ClientCallBiosInt10 + + Description : Call the BIOS Int10h with specified parameters. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPBIOSREGS pBiosRegs | Pointor to the Bios register + structure. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientCallBiosInt10(LPBOARDHANDLE pBoard, LPBIOSREGS pBiosRegs) +{ + ASSERT_HANDLER(pBoard); + + return 1; +} + + +/******************************************************************************\ + + Function : ClientReadDDCEdid + + Description : Not implemented. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPBIOSREGS pBiosRegs | Pointor to the Bios register + structure. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientReadDDCEdid(LPBOARDHANDLE pBoard, LPUCHAR pEdid, + ULONG ulMonitorIndex) +{ + ASSERT_HANDLER(pBoard); + + return 1; +} + + +/******************************************************************************\ + + Function : ClientCustomCall + + Description : Not implemented. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPBIOSREGS pBiosRegs | Pointor to the Bios register + structure. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientCustomCall(LPBOARDHANDLE pBoard, ULONG ulServiceNumber, + LPVOID pInData, LPVOID pOutData) +{ + ASSERT_HANDLER(pBoard); + + return 1; +} + + +/******************************************************************************\ + + Function : ClientApplyEpromPatch + + Description : Not implemented. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPBIOSREGS pBiosRegs | Pointor to the Bios register + structure. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientApplyEpromPatch(LPBOARDHANDLE pBoard) +{ + ASSERT_HANDLER(pBoard); + + return 1; +} + + +/******************************************************************************\ + + Function : ClientDetectHostInterface + + Description : Not implemented. + + I/O Desc. : LPBOARDHANDLE pBoard | Handle to the board structure + containing all the information about a specific board. + LPBIOSREGS pBiosRegs | Pointor to the Bios register + structure. + + Return Val : ULONG + +\******************************************************************************/ +ULONG ClientDetectHostInterface(LPBOARDHANDLE pBoard, LPULONG pulData) +{ + ASSERT_HANDLER(pBoard); + + return 1; +} + Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp:1.17 xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp:1.17 Tue Jun 13 22:13:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp Tue Dec 12 13:54:30 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp,v 1.17 2000/06/14 02:13:11 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp,v 1.20 2000/12/12 18:54:30 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH MGA __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH MGA __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME mga \- Matrox video driver .SH SYNOPSIS @@ -79,10 +79,11 @@ Enable or disable the HW cursor. Default: on. .TP .BI "Option \*qMGASDRAM\*q \*q" boolean \*q -Specify whether G100 and G200 cards have SDRAM. The driver attempts to +Specify whether G100, G200 or G400 cards have SDRAM. The driver attempts to auto-detect this based on the card's PCI subsystem ID. This option may be used to override that auto-detection. The mga driver is not able to -auto-detect the prescence SDRAM on secondary heads in multihead configurations. +auto-detect the presence of of SDRAM on secondary heads in multihead configurations +so this option will often need to be specified in multihead configurations. Default: auto-detected. .TP .BI "Option \*qNoAccel\*q \*q" boolean \*q Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h:1.59 xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h:1.70 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h:1.59 Fri Jun 16 20:03:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h Wed Dec 6 10:35:19 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.59 2000/06/17 00:03:19 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.70 2000/12/06 15:35:19 eich Exp $ */ /* * MGA Millennium (MGA2064W) functions * @@ -32,6 +32,11 @@ #include "mga_dri.h" #endif +#ifdef USEMGAHAL +#include "client.h" +#endif +#include "mga_bios.h" + #if !defined(EXTRADEBUG) #define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) #define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) @@ -58,6 +63,8 @@ #define MGA_VERSION 4000 #define MGA_NAME "MGA" +#define MGA_C_NAME MGA +#define MGA_MODULE_DATA mgaModuleData #define MGA_DRIVER_NAME "mga" #define MGA_MAJOR_VERSION 1 #define MGA_MINOR_VERSION 0 @@ -73,9 +80,9 @@ } MGARegRec, *MGARegPtr; typedef struct { - unsigned char brightness; - unsigned char contrast; - FBAreaPtr area; + int brightness; + int contrast; + FBLinearPtr linear; RegionRec clip; CARD32 colorKey; CARD32 videoStatus; @@ -120,6 +127,13 @@ /* Card-specific driver information */ +typedef struct { + Bool update; + unsigned char red; + unsigned char green; + unsigned char blue; +} MGAPaletteInfo; + #define MGAPTR(p) ((MGAPtr)((p)->driverPrivate)) #ifdef DISABLE_VGA_IO @@ -130,6 +144,31 @@ #endif typedef struct { + int lastInstance; +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAHWINFO pMgaHwInfo; +#endif + int refCount; + CARD32 masterFbAddress; + long masterFbMapSize; + CARD32 slaveFbAddress; + long slaveFbMapSize; + int mastervideoRam; + int slavevideoRam; + Bool directRenderingEnabled; + ScrnInfoPtr pScrn_1; + ScrnInfoPtr pScrn_2; +} MGAEntRec, *MGAEntPtr; + +typedef struct { +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAMODEINFO pMgaModeInfo; + LPMGAHWINFO pMgaHwInfo; +#endif EntityInfoPtr pEnt; MGABiosInfo Bios; MGABios2Info Bios2; @@ -148,11 +187,11 @@ int YDstOrg; int DstOrg; int SrcOrg; - CARD32 IOAddress; - CARD32 FbAddress; - CARD32 ILOADAddress; + unsigned long IOAddress; + unsigned long FbAddress; + unsigned long ILOADAddress; int FbBaseReg; - CARD32 BiosAddress; + unsigned long BiosAddress; MessageType BiosFrom; unsigned char * IOBase; unsigned char * IOBaseDense; @@ -223,7 +262,16 @@ Bool TexturedVideo; MGAPortPrivPtr portPrivate; int numXAALines; + unsigned char *ScratchBuffer; + unsigned char *ColorExpandBase; + int expandRows; + int expandDWORDs; + int expandRemaining; + int expandHeight; + int expandY; #ifdef XF86DRI + int agp_mode; + Bool ReallyUseIrqZero; Bool have_quiescense; Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -233,8 +281,30 @@ MGAConfigPrivPtr pVisualConfigsPriv; MGARegRec DRContextRegs; MGADRIServerPrivatePtr DRIServerInfo; + void (*GetQuiescence)(ScrnInfoPtr pScrn); #endif XF86VideoAdaptorPtr adaptor; + Bool SecondCrtc; + GDevPtr device; + /* The hardware's real SrcOrg */ + int realSrcOrg; + MGAEntPtr entityPrivate; + void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, + int rop, unsigned int planemask); + void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn, + int x, int y, int w, int h); + void (*RestoreAccelState)(ScrnInfoPtr pScrn); + int allowedWidth; + void (*VideoTimerCallback)(ScrnInfoPtr, Time); + void (*PaletteLoadCallback)(ScrnInfoPtr); + void (*RenderCallback)(ScrnInfoPtr); + Time RenderTime; + MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */ + FBLinearPtr LinearScratch; + Bool softbooted; +#ifdef USEMGAHAL + Bool HALLoaded; +#endif } MGARec, *MGAPtr; #ifdef XF86DRI @@ -256,6 +326,7 @@ #define MGA_NO_PLANEMASK 0x00000080 #define USE_LINEAR_EXPANSION 0x00000100 #define LARGE_ADDRESSES 0x00000200 + #define MGAIOMAPSIZE 0x00004000 #define MGAILOADMAPSIZE 0x00400000 @@ -285,6 +356,11 @@ Bool Mga24AccelInit(ScreenPtr pScreen); Bool Mga32AccelInit(ScreenPtr pScreen); +void Mga8InitSolidFillRectFuncs(MGAPtr pMga); +void Mga16InitSolidFillRectFuncs(MGAPtr pMga); +void Mga24InitSolidFillRectFuncs(MGAPtr pMga); +void Mga32InitSolidFillRectFuncs(MGAPtr pMga); + void MGAPolyArcThinSolid(DrawablePtr, GCPtr, int, xArc*); Bool MGADGAInit(ScreenPtr pScreen); @@ -293,6 +369,7 @@ void MGADRICloseScreen(ScreenPtr pScreen); Bool MGADRIFinishScreenInit(ScreenPtr pScreen); void MGASwapContext(ScreenPtr pScreen); +void MGASwapContext_shared(ScreenPtr pScreen); Bool mgaConfigureWarp(ScrnInfoPtr pScrn); unsigned int mgaInstallMicrocode(ScreenPtr pScreen, int agp_offset); unsigned int mgaGetMicrocodeSize(ScreenPtr pScreen); @@ -301,6 +378,8 @@ Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); #ifdef XF86DRI Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags); +void mgaGetQuiescence(ScrnInfoPtr pScrn); +void mgaGetQuiescence_shared(ScrnInfoPtr pScrn); #endif void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c:1.52 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c:1.55 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c:1.52 Thu Jan 20 20:12:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c Wed Nov 1 21:51:19 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c,v 1.52 2000/01/21 01:12:20 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dac3026.c,v 1.55 2000/11/02 02:51:19 dawes Exp $ */ /* * Copyright 1994 by Robin Cutshaw <robin@XFree86.org> * @@ -50,12 +50,10 @@ #include "mga_bios.h" #include "mga_reg.h" #include "mga.h" +#include "mga_macros.h" #include "xf86DDC.h" -/* Set to 1 if you want to set MCLK from XF86Config - AT YOUR OWN RISK! */ -#define MCLK_FROM_XCONFIG 0 - /* * Only change these bits in the Option register. Make sure that the * vgaioen bit is never in this mask because it is controlled elsewhere @@ -715,7 +713,8 @@ mgaReg->ModeReg and letting Restore write to the hardware but that's no big deal since we will Restore right after this function */ - MGATi3026SetMCLK( pScrn, MGAdac->MemoryClock ); + + MGA_NOT_HAL(MGATi3026SetMCLK(pScrn, MGAdac->MemoryClock)); #ifdef DEBUG ErrorF("%6ld: %02X %02X %02X %02X %02X %02X %08lX\n", mode->Clock, @@ -753,6 +752,7 @@ pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, OPTION_MASK, mgaReg->Option); + MGA_NOT_HAL( /* select pixel clock PLL as clock source */ outTi3026(TVP3026_CLK_SEL, 0, mgaReg->DacRegs[3]); @@ -760,6 +760,7 @@ outTi3026(TVP3026_PLL_ADDR, 0, 0x2A); outTi3026(TVP3026_LOAD_CLK_DATA, 0, 0); outTi3026(TVP3026_PIX_CLK_DATA, 0, 0); + ); /* MGA_NOT_HAL */ /* * This function handles restoring the generic VGA registers. @@ -773,30 +774,35 @@ * goes here. */ + MGA_NOT_HAL( /* program pixel clock PLL */ outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 0; i < 3; i++) outTi3026(TVP3026_PIX_CLK_DATA, 0, mgaReg->DacClk[i]); - + if (vgaReg->MiscOutReg & 0x08) { /* poll until pixel clock PLL LOCK bit is set */ outTi3026(TVP3026_PLL_ADDR, 0, 0x3F); while ( ! (inTi3026(TVP3026_PIX_CLK_DATA) & 0x40) ); } + /* set Q divider for loop clock PLL */ outTi3026(TVP3026_MCLK_CTL, 0, mgaReg->DacRegs[18]); + ); /* MGA_NOT_HAL */ /* program loop PLL */ outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 3; i < 6; i++) outTi3026(TVP3026_LOAD_CLK_DATA, 0, mgaReg->DacClk[i]); - + + MGA_NOT_HAL( if ((vgaReg->MiscOutReg & 0x08) && ((mgaReg->DacClk[3] & 0xC0) == 0xC0) ) { /* poll until loop PLL LOCK bit is set */ outTi3026(TVP3026_PLL_ADDR, 0, 0x3F); while ( ! (inTi3026(TVP3026_LOAD_CLK_DATA) & 0x40) ); } - + ); /* MGA_NOT_HAL */ + /* * restore other DAC registers */ @@ -847,7 +853,8 @@ OUTREG8(0x1FDE, i); mgaReg->ExtVga[i] = INREG8(0x1FDF); } - + + MGA_NOT_HAL( outTi3026(TVP3026_PLL_ADDR, 0, 0x00); for (i = 0; i < 3; i++) outTi3026(TVP3026_PIX_CLK_DATA, 0, mgaReg->DacClk[i] = @@ -857,6 +864,7 @@ for (i = 3; i < 6; i++) outTi3026(TVP3026_LOAD_CLK_DATA, 0, mgaReg->DacClk[i] = inTi3026(TVP3026_LOAD_CLK_DATA)); + ); /* MGA_NOT_HAL */ for (i = 0; i < DACREGSIZE; i++) mgaReg->DacRegs[i] = inTi3026(MGADACregs[i]); Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c:1.36 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c:1.42 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c:1.36 Fri Jun 16 20:03:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c Wed Dec 6 10:35:20 2000 @@ -2,7 +2,7 @@ * MGA-1064, MGA-G100, MGA-G200, MGA-G400 RAMDAC driver */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.36 2000/06/17 00:03:19 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.42 2000/12/06 15:35:20 eich Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -24,8 +24,8 @@ #include "mga_bios.h" #include "mga_reg.h" -#include "mga_macros.h" #include "mga.h" +#include "mga_macros.h" #include "xf86DDC.h" @@ -145,6 +145,7 @@ post_div_max = 7; break; case PCI_CHIP_MGAG100: + case PCI_CHIP_MGAG100_PCI: case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: default: @@ -221,7 +222,6 @@ return f_pll; } - /* * MGAGSetPCLK - Set the pixel (PCLK) clock. */ @@ -268,13 +268,13 @@ /* 0x48: */ 0, 0, 0, 0, 0, 0, 0, 0 }; + int i, weight555 = FALSE; int hd, hs, he, ht, vd, vs, ve, vt, wd; - int i, BppShift; + int BppShift; MGAPtr pMga; MGARegPtr pReg; vgaRegPtr pVga; MGAFBLayout *pLayout; - int weight555 = FALSE; pMga = MGAPTR(pScrn); pReg = &pMga->ModeReg; @@ -283,6 +283,7 @@ BppShift = pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]; + MGA_NOT_HAL( /* Allocate the DacRegs space if not done already */ if (pReg->DacRegs == NULL) { pReg->DacRegs = xnfcalloc(DACREGSIZE, 1); @@ -290,6 +291,7 @@ for (i = 0; i < DACREGSIZE; i++) { pReg->DacRegs[i] = initDAC[i]; } + ); /* MGA_NOT_HAL */ switch(pMga->Chipset) { @@ -333,6 +335,9 @@ pReg->Option2 = 0x0000007; break; case PCI_CHIP_MGAG400: +#ifdef USEMGAHAL + MGA_HAL(break;); +#endif if(pMga->Dac.maxPixelClock == 360000) { /* G400 MAX */ if(pMga->OverclockMem) { /* 150/200 */ @@ -373,6 +378,9 @@ case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: default: +#ifdef USEMGAHAL + MGA_HAL(break;); +#endif if(pMga->OverclockMem) { /* 143 Mhz */ pReg->DacRegs[ MGA1064_SYS_PLL_M ] = 0x06; @@ -392,6 +400,7 @@ break; } + MGA_NOT_HAL( /* must always have the pci retries on but rely on polling to keep them from occuring */ pReg->Option &= ~0x20000000; @@ -423,6 +432,7 @@ default: FatalError("MGA: unsupported depth\n"); } + ); /* MGA_NOT_HAL */ /* * This will initialize all of the generic VGA registers. @@ -503,24 +513,24 @@ pVga->CRTC[21] = vd & 0xFF; pVga->CRTC[22] = (vt + 1) & 0xFF; - if (mode->Flags & V_DBLSCAN) - pVga->CRTC[9] |= 0x80; - - pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_LOW ] = - pMga->FbCursorOffset >> 10; - pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_HI ] = - pMga->FbCursorOffset >> 18; + MGA_NOT_HAL(pReg->DacRegs[MGA1064_CURSOR_BASE_ADR_LOW] = pMga->FbCursorOffset >> 10); + MGA_NOT_HAL(pReg->DacRegs[MGA1064_CURSOR_BASE_ADR_HI] = pMga->FbCursorOffset >> 18); if (pMga->SyncOnGreen) { - pReg->DacRegs[ MGA1064_GEN_CTL ] &= ~0x20; + MGA_NOT_HAL(pReg->DacRegs[MGA1064_GEN_CTL] &= ~0x20); pReg->ExtVga[3] |= 0x40; } /* select external clock */ pVga->MiscOutReg |= 0x0C; - - MGAGSetPCLK( pScrn, mode->Clock ); + MGA_NOT_HAL( + if (mode->Flags & V_DBLSCAN) + pVga->CRTC[9] |= 0x80; + + MGAGSetPCLK(pScrn, mode->Clock); + ); /* MGA_NOT_HAL */ + /* This disables the VGA memory aperture */ pVga->MiscOutReg &= ~0x02; return(TRUE); @@ -530,6 +540,29 @@ * MGAGLoadPalette */ +static void +MGAPaletteLoadCallback(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGAPaletteInfo *pal = pMga->palinfo; + int i; + + while (!(INREG8(0x1FDA) & 0x08)); + + for(i = 0; i < 256; i++) { + if(pal->update) { + outMGAdreg(MGA1064_WADR_PAL, i); + outMGAdreg(MGA1064_COL_PAL, pal->red); + outMGAdreg(MGA1064_COL_PAL, pal->green); + outMGAdreg(MGA1064_COL_PAL, pal->blue); + pal->update = FALSE; + } + pal++; + } + + pMga->PaletteLoadCallback = NULL; +} + void MGAGLoadPalette( ScrnInfoPtr pScrn, int numColors, @@ -538,17 +571,30 @@ VisualPtr pVisual ){ MGAPtr pMga = MGAPTR(pScrn); - int i, index; - if(pMga->CurrentLayout.Overlay8Plus24 && (pVisual->nplanes != 8)) + if((pMga->CurrentLayout.Overlay8Plus24) && (pVisual->nplanes != 8)) return; - for(i = 0; i < numColors; i++) { - index = indices[i]; - outMGAdreg(MGA1064_WADR_PAL, index); - outMGAdreg(MGA1064_COL_PAL, colors[index].red); - outMGAdreg(MGA1064_COL_PAL, colors[index].green); - outMGAdreg(MGA1064_COL_PAL, colors[index].blue); + if(pMga->Chipset == PCI_CHIP_MGAG400){ + /* load them at the retrace in the block handler instead to + work around some problems with static on the screen */ + while(numColors--) { + pMga->palinfo[*indices].update = TRUE; + pMga->palinfo[*indices].red = colors[*indices].red; + pMga->palinfo[*indices].green = colors[*indices].green; + pMga->palinfo[*indices].blue = colors[*indices].blue; + indices++; + } + pMga->PaletteLoadCallback = MGAPaletteLoadCallback; + return; + } else { + while(numColors--) { + outMGAdreg(MGA1064_WADR_PAL, *indices); + outMGAdreg(MGA1064_COL_PAL, colors[*indices].red); + outMGAdreg(MGA1064_COL_PAL, colors[*indices].green); + outMGAdreg(MGA1064_COL_PAL, colors[*indices].blue); + indices++; + } } } @@ -591,10 +637,10 @@ Bool restoreFonts) { int i; - CARD32 optionMask; MGAPtr pMga = MGAPTR(pScrn); + CARD32 optionMask; - CHECK_DMA_QUIESCENT( pMga, pScrn ); + MGA_NOT_HAL( /* * Code is needed to get things back to bank zero. */ @@ -628,6 +674,7 @@ if (pMga->Chipset == PCI_CHIP_MGAG400) pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK, mgaReg->Option3); + ); /* MGA_NOT_HAL */ /* restore CRTCEXT regs */ for (i = 0; i < 6; i++) @@ -675,13 +722,14 @@ { int i; MGAPtr pMga = MGAPTR(pScrn); - - CHECK_DMA_QUIESCENT( pMga, pScrn ); + if(pMga->SecondCrtc == TRUE) return; + MGA_NOT_HAL( /* Allocate the DacRegs space if not done already */ if (mgaReg->DacRegs == NULL) { mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1); } + ); /* MGA_NOT_HAL */ /* * Code is needed to get back to bank zero. @@ -695,6 +743,7 @@ vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0)); MGAGSavePalette(pScrn, vgaReg->DAC); + MGA_NOT_HAL( /* * The port I/O code necessary to read in the extended registers. */ @@ -706,6 +755,7 @@ mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2); if (pMga->Chipset == PCI_CHIP_MGAG400) mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3); + ); /* MGA_NOT_HAL */ for (i = 0; i < 6; i++) { @@ -797,8 +847,12 @@ static Bool MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) { + MGAPtr pMga = MGAPTR(xf86Screens[pScrn->myNum]); + /* This needs to detect if its on the second dac */ if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN ) return FALSE; + if( pMga->SecondCrtc == TRUE ) + return FALSE; return TRUE; } Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c:1.5 Fri Jun 23 19:43:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c Mon Dec 11 17:34:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.5 2000/06/23 23:43:44 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.14 2000/12/11 22:34:55 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -38,6 +38,11 @@ void *readContextStore, DRIContextType writeContextType, void *writeContextStore); +static void MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); extern void Mga8DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); extern void Mga8DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); @@ -96,12 +101,10 @@ init.chipset = MGA_CARD_TYPE_G400; break; case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: init.chipset = MGA_CARD_TYPE_G200; break; - case PCI_CHIP_MGAG200_PCI: default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] Direct rendering not supported on this card/chipset\n"); return FALSE; } @@ -143,10 +146,9 @@ switch (pScrn->bitsPerPixel) { case 8: case 24: - case 32: break; case 16: - numConfigs = 4; + numConfigs = 8; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -169,14 +171,15 @@ i = 0; depth = 1; for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ - for (db=0; db<=1; db++) { + for (stencil = 0; stencil <= 1; stencil++) { /* no stencil for now */ + for (db=1; db>=0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; pConfigs[i].redSize = 5; pConfigs[i].greenSize = 6; pConfigs[i].blueSize = 5; + pConfigs[i].alphaSize = 0; pConfigs[i].redMask = 0x0000F800; pConfigs[i].greenMask = 0x000007E0; pConfigs[i].blueMask = 0x0000001F; @@ -208,7 +211,91 @@ pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil) + if (stencil || accum) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + if (i != numConfigs) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Incorrect initialization of visuals\n"); + return FALSE; + } + break; + + case 32: + numConfigs = 8; + + if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pMGAConfigs = (MGAConfigPrivPtr)xnfcalloc(sizeof(MGAConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pMGAConfigPtrs = (MGAConfigPrivPtr*)xnfcalloc(sizeof(MGAConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pMGAConfigs); + return FALSE; + } + for (i=0; i<numConfigs; i++) + pMGAConfigPtrs[i] = &pMGAConfigs[i]; + + i = 0; + for (accum = 0; accum <= 1; accum++) { + for (depth = 0; depth <= 1; depth++) { /* and stencil */ + for (db=1; db>=0; db--) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].alphaSize = 0; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 32; + if (depth) { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + } + else { + pConfigs[i].depthSize = 0; + pConfigs[i].stencilSize = 0; + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -228,6 +315,7 @@ return FALSE; } break; + default: ; /* unexpected bits/pixelx */ } @@ -245,7 +333,40 @@ return log2; } +static unsigned long MGAParseAgpMode(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + unsigned long mode_mask; + + switch(pMga->agp_mode) { + case 4: + mode_mask = ~0x00000003; + break; + case 2: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Enabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_enable); + } + mode_mask = ~0x00000005; + break; + default: + /* Default to 1X agp mode */ + case 1: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Disabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_disable); + } + pMga->agp_mode = 1; + mode_mask = ~0x00000006; + break; + } + return mode_mask; +} + Bool MGADRIScreenInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -257,7 +378,20 @@ int prim_size; int init_offset; int i; + unsigned long mode_mask; + switch(pMGA->Chipset) { + case PCI_CHIP_MGAG400: + case PCI_CHIP_MGAG200: +#if 0 + case PCI_CHIP_MGAG200_PCI: +#endif + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Direct rendering only supported with G200/G400 AGP\n"); + return FALSE; + } + /* Check that the GLX, DRI, and DRM modules have been loaded by testing * for canonical symbols in each module. */ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; @@ -265,7 +399,7 @@ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "TDFXDRIScreenInit failed (libdri.a too old)\n"); + "MGADRIScreenInit failed (libdri.a too old)\n"); return FALSE; } @@ -281,9 +415,12 @@ } } - if ((pScrn->bitsPerPixel / 8) != 2) { + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] bpp: %d depth: %d\n", pScrn->bitsPerPixel, pScrn->depth); + + if ((pScrn->bitsPerPixel / 8) != 2 && + (pScrn->bitsPerPixel / 8) != 4) { xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Direct Rendering only supported in 16 bpp mode\n"); + "[drm] Direct rendering only supported in 16 and 32 bpp modes\n"); return FALSE; } @@ -352,7 +489,10 @@ pDRIInfo->CreateContext = MGACreateContext; pDRIInfo->DestroyContext = MGADestroyContext; - pDRIInfo->SwapContext = MGADRISwapContext; + if (xf86IsEntityShared(pScrn->entityList[0])) + pDRIInfo->SwapContext = MGADRISwapContext_shared; + else + pDRIInfo->SwapContext = MGADRISwapContext; switch( pScrn->bitsPerPixel ) { case 8: @@ -386,16 +526,17 @@ { drmVersionPtr version = drmGetVersion(pMGA->drmSubFD); if (version) { - if (version->version_major != 1 || + if (version->version_major != 2 || version->version_minor != 0 || version->version_patchlevel < 0) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 2.0.x). Disabling DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); - MGADRICloseScreen(pScreen); +/* MGADRICloseScreen(pScreen); */ + drmFreeVersion(version); return FALSE; } @@ -434,16 +575,17 @@ DRICloseScreen(pScreen); return FALSE; } - + + mode_mask = MGAParseAgpMode(pScreen); + pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD); - /* Default to 1X agp mode */ - pMGADRIServer->agpMode &= ~0x00000002; + pMGADRIServer->agpMode &= mode_mask; if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } - ErrorF("[drm] drmAgpEnabled succeeded\n"); + ErrorF("[drm] drmAgpEnabled succeeded for AGP mode %dx\n", pMGA->agp_mode); prim_size = 65536; init_offset = ((prim_size + pMGADRIServer->warp_ucode_size + @@ -505,12 +647,10 @@ pMGADRI->chipset = MGA_CARD_TYPE_G400; break; case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: pMGADRI->chipset = MGA_CARD_TYPE_G200; break; - case PCI_CHIP_MGAG200_PCI: default: - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Direct rendering not supported on this card/chipset\n"); return FALSE; } @@ -524,20 +664,14 @@ pMGADRI->frontOffset = 0; /* pMGA->YDstOrg * (pScrn->bitsPerPixel / 8) */ pMGADRI->backOffset = ((pScrn->virtualY + pMGA->numXAALines + 1) * pScrn->displayWidth * - (pScrn->bitsPerPixel / 8) + 4095) & ~0xFFF; + pMGADRI->cpp + 4095) & ~0xFFF; xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] calced backoffset: 0x%x\n", pMGADRI->backOffset); -#if 0 - size = 2 * pScrn->virtualX * pScrn->virtualY; - pMGADRI->depthOffset = (pMGADRI->backOffset + size + 4095) & ~0xFFF; - pMGADRI->textureOffset = pMGADRI->depthOffset + size; - pMGADRI->textureSize = pMGA->FbUsableSize - pMGADRI->textureOffset; -#else - size = 2 * pScrn->virtualX * pScrn->virtualY; + size = pMGADRI->cpp * pScrn->virtualX * pScrn->virtualY; size += 4095; size &= ~4095; pMGADRI->depthOffset = pMGA->FbUsableSize - size; @@ -551,7 +685,6 @@ DRICloseScreen(pScreen); return FALSE; } -#endif pMGADRI->mAccess = pMGA->MAccess; @@ -617,6 +750,25 @@ ->thisCard)->devnum, ((pciConfigPtr)pMGA->PciInfo ->thisCard)->funcnum); + + if(!pMGADRIServer->irq && !pMGA->ReallyUseIrqZero) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] Your graphics card has Interrupt zero" + " assigned to it.\n" + "This is highly unlikely so I'm disabling the DRI.\n" + "If your graphics card really has Interrupt zero, please" + "add the config option UseIrqZero\n" + "to the device section in your XF86Config file.\n" + "Please be warned that Interrupt zero is normally " + "the timer interrupt on X86 systems.\n" + "Using this option could make your system unusable.\n" + "The more likely solution is that your graphics card has" + " no interrupt assigned to it.\nPlease consult your" + " system BIOS manual for instructions on how to enable " + "an interrupt for your graphics card.\n"); + MGADRICloseScreen(pScreen); + return FALSE; + } drmCtlInstHandler(pMGA->drmSubFD, pMGADRIServer->irq); } @@ -640,23 +792,17 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; - - MgaCleanupDma(pScrn); +/* The DRI will automagically clean these up when driFD is closed */ if(pMGADRIServer->agp_map) { - ErrorF("Unmapped agp region\n"); drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep); pMGADRIServer->agp_map = 0; } if(pMGADRIServer->agpHandle) { - ErrorF("Freeing agp memory\n"); - drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle); pMGADRIServer->agpHandle = 0; pMGADRIServer->agpSizep = 0; } if(pMGADRIServer->agpAcquired == TRUE) { - ErrorF("releasing agp module\n"); - drmAgpRelease(pMGA->drmSubFD); pMGADRIServer->agpAcquired = FALSE; } @@ -714,7 +860,8 @@ } -void mgaGetQuiescence( ScrnInfoPtr pScrn ) +void +mgaGetQuiescence( ScrnInfoPtr pScrn ) { MGAPtr pMga = MGAPTR(pScrn); @@ -725,15 +872,17 @@ MgaLockUpdate(pScrn, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH)); - WAITFIFO(12); + WAITFIFO(11); OUTREG(MGAREG_MACCESS, pMga->MAccess); OUTREG(MGAREG_PITCH, pLayout->displayWidth); - OUTREG(MGAREG_YDSTORG, pMga->YDstOrg); + pMga->PlaneMask = ~0; OUTREG(MGAREG_PLNWT, pMga->PlaneMask); + pMga->BgColor = 0; + pMga->FgColor = 0; OUTREG(MGAREG_BCOL, pMga->BgColor); OUTREG(MGAREG_FCOL, pMga->FgColor); + OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); pMga->SrcOrg = 0; - OUTREG(MGAREG_SRCORG, 0); OUTREG(MGAREG_DSTORG, pMga->DstOrg); OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ @@ -744,8 +893,27 @@ } +void +mgaGetQuiescence_shared( ScrnInfoPtr pScrn ) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); -void MGASwapContext(ScreenPtr pScreen) + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 1; + pMga2->have_quiescense = 1; + + if (pMgaEnt->directRenderingEnabled) { + MgaLockUpdate(pMgaEnt->pScrn_1, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH)); + pMga->RestoreAccelState(pScrn); + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + } +} + + +void +MGASwapContext(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); @@ -757,8 +925,22 @@ pMga->AccelInfoRec->NeedToSync = TRUE; } +void +MGASwapContext_shared(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 0; + pMga->AccelInfoRec->NeedToSync = TRUE; + pMga2->have_quiescense = 0; + pMga2->AccelInfoRec->NeedToSync = TRUE; +} + /* This is really only called from validate/postvalidate as we * override the dri lock/unlock. Want to remove validate/postvalidate * processing, but need to remove all client-side use of drawable lock @@ -789,6 +971,18 @@ } } +static void +MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if (syncType == DRI_3D_SYNC && + oldContextType == DRI_2D_CONTEXT && + newContextType == DRI_2D_CONTEXT) + { + MGASwapContext_shared(pScreen); + } +} void MGASelectBuffer(ScrnInfoPtr pScrn, int which) Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c:1.163 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c:1.185 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c:1.163 Thu Jun 29 17:03:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c Thu Dec 7 15:26:21 2000 @@ -43,7 +43,7 @@ * Fixed 32bpp hires 8MB horizontal line glitch at middle right */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.163 2000/06/29 21:03:11 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.185 2000/12/07 20:26:21 dawes Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -79,21 +79,10 @@ #include "xf86RAC.h" #include "vbe.h" - -/* - * If using cfb, cfb.h is required. Select the others for the bpp values - * the driver supports. - */ -#define PSZ 8 /* needed for cfb.h */ -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" #include "cfb8_32.h" +#include "dixstruct.h" -#include "mga_bios.h" #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" @@ -108,6 +97,10 @@ #endif +#ifdef RENDER +#include "picturestr.h" +#endif + /* * Forward definitions for the functions that make up the driver. */ @@ -124,6 +117,7 @@ static void MGALeaveVT(int scrnIndex, int flags); static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool MGASaveScreen(ScreenPtr pScreen, int mode); +static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode); /* This shouldn't be needed since RAC will disable all I/O for MGA cards. */ #ifdef DISABLE_VGA_IO @@ -147,7 +141,10 @@ static void MGASave(ScrnInfoPtr pScrn); static void MGARestore(ScrnInfoPtr pScrn); static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags); +static void MGABlockHandler(int, pointer, pointer, pointer); +static int MGAEntityIndex = -1; /* * This contains the functions needed by the server after loading the @@ -157,7 +154,7 @@ * this DriverRec be an upper-case version of the driver name. */ -DriverRec MGA = { +DriverRec MGA_C_NAME = { MGA_VERSION, MGA_DRIVER_NAME, #if 0 @@ -177,6 +174,7 @@ { PCI_CHIP_MGA2164, "mga2164w" }, { PCI_CHIP_MGA2164_AGP, "mga2164w AGP" }, { PCI_CHIP_MGAG100, "mgag100" }, + { PCI_CHIP_MGAG100_PCI, "mgag100 PCI" }, { PCI_CHIP_MGAG200, "mgag200" }, { PCI_CHIP_MGAG200_PCI, "mgag200 PCI" }, { PCI_CHIP_MGAG400, "mgag400" }, @@ -189,6 +187,7 @@ { PCI_CHIP_MGA2164, PCI_CHIP_MGA2164, RES_SHARED_VGA }, { PCI_CHIP_MGA2164_AGP, PCI_CHIP_MGA2164_AGP, RES_SHARED_VGA }, { PCI_CHIP_MGAG100, PCI_CHIP_MGAG100, RES_SHARED_VGA }, + { PCI_CHIP_MGAG100_PCI, PCI_CHIP_MGAG100_PCI, RES_SHARED_VGA }, { PCI_CHIP_MGAG200, PCI_CHIP_MGAG200, RES_SHARED_VGA }, { PCI_CHIP_MGAG200_PCI, PCI_CHIP_MGAG200_PCI, RES_SHARED_VGA }, { PCI_CHIP_MGAG400, PCI_CHIP_MGAG400, RES_SHARED_VGA }, @@ -212,7 +211,17 @@ OPTION_VIDEO_KEY, OPTION_ROTATE, OPTION_TEXTURED_VIDEO, - OPTION_XAALINES + OPTION_XAALINES, + OPTION_CRTC2HALF, + OPTION_INT10, + OPTION_AGP_MODE_2X, + OPTION_AGP_MODE_4X, + OPTION_DIGITAL, + OPTION_TV, + OPTION_TVSTANDARD, + OPTION_CABLETYPE, + OPTION_USEIRQZERO, + OPTION_NOHAL } MGAOpts; static OptionInfoRec MGAOptions[] = { @@ -233,6 +242,16 @@ { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, { OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE }, { OPTION_XAALINES, "XAALines", OPTV_INTEGER, {0}, FALSE }, + { OPTION_CRTC2HALF, "Crtc2Half", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_INT10, "Int10", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_2X, "AGPMode2x", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_4X, "AGPMode4x", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DIGITAL, "DigitalScreen",OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_TV, "TV", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_TVSTANDARD, "TVStandard", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_CABLETYPE, "CableType", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_USEIRQZERO, "UseIrqZero", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOHAL, "NoHal", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -262,12 +281,12 @@ }; static const char *cfbSymbols[] = { - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", "cfb8_32ScreenInit", - "cfb24_32ScreenInit", + NULL +}; + +static const char *fbSymbols[] = { + "fbScreenInit", NULL }; @@ -284,6 +303,9 @@ "XAAOverlayFBfuncs", "XAACachePlanarMonoStipple", "XAAScreenIndex", + "XAAFallbackOps", + "XAAFillSolidRects", + "XAAMoveDWORDS", NULL }; @@ -332,6 +354,9 @@ "DRIGetSAREAPrivate", "DRIGetContext", "DRIQueryVersion", + "DRIAdjustFrame", + "DRIOpenFullScreen", + "DRICloseFullScreen", "GlxSetVisualConfigs", NULL }; @@ -365,6 +390,12 @@ NULL }; +static const char *int10Symbols[] = { + "xf86InitInt10", + "xf86FreeInt10", + NULL +}; + static const char *fbdevHWSymbols[] = { "fbdevHWInit", "fbdevHWUseBuildinMode", @@ -392,15 +423,29 @@ NULL }; - +#ifdef USEMGAHAL +static const char *halSymbols[] = { + "MGACloseLibrary", + "MGASaveVgaState", + "MGARestoreVgaState", + "MGASetVgaMode", + "MGASetMode", + "MGAValidateMode", + "MGAValidateVideoParameters", + "MGAGetBOARDHANDLESize", + "MGAGetHardwareInfo", + "MGAOpenLibrary", + NULL +}; +#endif #ifdef XFree86LOADER static MODULESETUPPROTO(mgaSetup); static XF86ModuleVersionInfo mgaVersRec = { - "mga", + MGA_DRIVER_NAME, MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, @@ -412,7 +457,7 @@ {0,0,0,0} }; -XF86ModuleData mgaModuleData = { &mgaVersRec, mgaSetup, NULL }; +XF86ModuleData MGA_MODULE_DATA = { &mgaVersRec, mgaSetup, NULL }; static pointer mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) @@ -423,7 +468,7 @@ if (!setupDone) { setupDone = TRUE; - xf86AddDriver(&MGA, module, 0); + xf86AddDriver(&MGA_C_NAME, module, 0); /* * Modules that this driver always requires may be loaded here @@ -434,14 +479,17 @@ * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, xf8_32bppSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, shadowSymbols, fbdevHWSymbols, vbeSymbols, + fbSymbols, int10Symbols, #ifdef XF86DRI drmSymbols, driSymbols, +#endif +#ifdef USEMGAHAL + halSymbols, #endif - NULL); /* @@ -458,12 +506,6 @@ #endif /* XFree86LOADER */ -/* - * This is intentionally screen-independent. It indicates the binding - * choice made in the first PreInit. - */ -static int pix24bpp = 0; - /* * ramdac info structure initialization */ @@ -520,7 +562,7 @@ MGAProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips = NULL; int numDevSections; int numUsed; @@ -576,9 +618,7 @@ MGAChipsets, MGAPciChipsets, devSections, numDevSections, drv, &usedChips); /* Free it since we don't need that list after this */ - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -586,6 +626,7 @@ foundScreen = TRUE; else for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn; + EntityInfoPtr pEnt; #ifdef DISABLE_VGA_IO MgaSavePtr smga; #endif @@ -621,9 +662,40 @@ pScrn->ValidMode = MGAValidMode; foundScreen = TRUE; } + + /* + * For cards that can do dual head per entity, mark the entity + * as sharable. + */ + pEnt = xf86GetEntityInfo(usedChips[i]); + if (pEnt->chipset == PCI_CHIP_MGAG400) { + MGAEntPtr pMgaEnt = NULL; + DevUnion *pPriv; + + xf86SetEntitySharable(usedChips[i]); + /* Allocate an entity private if necessary */ + if (MGAEntityIndex < 0) + MGAEntityIndex = xf86AllocateEntityPrivateIndex(); + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + if (!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(MGAEntRec), 1); + pMgaEnt = pPriv->ptr; + pMgaEnt->lastInstance = -1; + } else { + pMgaEnt = pPriv->ptr; + } + /* + * Set the entity instance for this instance of the driver. For + * dual head per card, instance 0 is the "master" instance, driving + * the primary head, and instance 1 is the "slave". + */ + pMgaEnt->lastInstance++; + xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0], + pMgaEnt->lastInstance); + } } - if (usedChips) - xfree(usedChips); + + xfree(usedChips); return foundScreen; } @@ -882,6 +954,7 @@ ProbeSize = 16384; break; case PCI_CHIP_MGAG100: + case PCI_CHIP_MGAG100_PCI: if(biosInfo) /* I'm not sure if the docs are correct */ return (biosInfo & (1 << 12)) ? 16384 : 8192; case PCI_CHIP_MGA1064: @@ -1062,7 +1135,7 @@ } #endif /* DISABLE_VGA_IO */ -void +static void MGAProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -1082,10 +1155,15 @@ double real; int bytesPerPixel; ClockRangePtr clockRanges; - char *mod = NULL; const char *reqSym = NULL; const char *s; int flags24; + MGAEntPtr pMgaEnt = NULL; +#ifdef USEMGAHAL + MGAMODEINFO mgaModeInfo = {0}; + Bool digital = FALSE; + Bool tv = FALSE; +#endif /* * Note: This function is only called once at server startup, and @@ -1110,12 +1188,26 @@ } pMga = MGAPTR(pScrn); - + /* Set here until dri is enabled */ +#ifdef XF86DRI + pMga->have_quiescense = 1; +#endif /* Get the entity, and make sure it is PCI. */ pMga->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pMga->pEnt->location.type != BUS_PCI) return FALSE; + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt = xf86GetEntityPrivate(pScrn->entityList[0], + MGAEntityIndex)->ptr; + pMga->entityPrivate = pMgaEnt; + } + + /* Set pMga->device to the relevant Device section */ + pMga->device = xf86GetDevFromEntity(pScrn->entityList[0], + pScrn->entityInstanceList[0]); + if (flags & PROBE_DETECT) { MGAProbeDDC(pScrn, pMga->pEnt->index); return TRUE; @@ -1133,20 +1225,6 @@ if (!vgaHWGetHWRec(pScrn)) return FALSE; -#if 0 - /* This is causing problems with restoring the card to it's - original state. If this is to be done, it needs to happen - after we've saved the original state */ - /* Initialize the card through int10 interface if needed */ - if ( xf86LoadSubModule(pScrn, "int10")){ - xf86Int10InfoPtr pInt; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); - pInt = xf86InitInt10(pMga->pEnt->index); - xf86FreeInt10(pInt); - } -#endif - /* Find the PCI info for this screen */ pMga->PciInfo = xf86GetPciInfoForEntity(pMga->pEnt->index); pMga->PciTag = pciTag(pMga->PciInfo->bus, pMga->PciInfo->device, @@ -1186,6 +1264,55 @@ /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; +#if 1 + /* + * XXX This assumes that the lower number screen is always the "master" + * head, and that the "master" is the first CRTC. This can result in + * unexpected behaviour when the config file marks the primary CRTC + * as the second screen. + */ + if(xf86IsEntityShared(pScrn->entityList[0]) && + xf86IsPrimInitDone(pScrn->entityList[0])) { + /* This is the second crtc */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + pMgaEnt->pScrn_2 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pScrn_1 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence; +#endif + } + } +#else + /* + * This is an alternative version that determines which is the secondary + * CRTC from the screen field in pMga->device. It doesn't currently + * work becasue there are things that assume the primary CRTC is + * initialised first. + */ + if (pMga->device->screen == 1) { + /* This is the second CRTC */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + } +#endif + /* * The first thing we should figure out is the depth, bpp, etc. * Our default depth is 8, so pass it to the helper function. @@ -1196,10 +1323,13 @@ flags24 = Support24bppFb | Support32bppFb | SupportConvert32to24; s = xf86TokenToOptName(MGAOptions, OPTION_OVERLAY); if (!(xf86FindOption(pScrn->confScreen->options, s) || - xf86FindOption(pMga->pEnt->device->options, s))) { + xf86FindOption(pMga->device->options, s))) { flags24 |= PreferConvert32to24; } + if (pMga->SecondCrtc) + flags24 = Support32bppFb; + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) { return FALSE; } else { @@ -1220,10 +1350,6 @@ } xf86PrintDepthBpp(pScrn); - /* Get the depth24 pixmap format */ - if (pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); - /* * This must happen after pScrn->display has been set because * xf86SetWeight references it. @@ -1240,9 +1366,6 @@ } } - if (!xf86SetDefaultVisual(pScrn, -1)) - return FALSE; - bytesPerPixel = pScrn->bitsPerPixel / 8; /* We use a programamble clock */ @@ -1254,6 +1377,18 @@ /* Process the options */ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, MGAOptions); + pMga->softbooted = FALSE; + if (xf86ReturnOptValBool(MGAOptions, OPTION_INT10, FALSE) && + xf86LoadSubModule(pScrn, "int10")) + { + xf86Int10InfoPtr pInt; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); + pInt = xf86InitInt10(pMga->pEnt->index); + if (pInt) pMga->softbooted = TRUE; + xf86FreeInt10(pInt); + } + /* Set the bits per RGB for 8bpp mode */ if (pScrn->depth == 8) pScrn->rgbBits = 8; @@ -1263,12 +1398,12 @@ * Set the Chipset and ChipRev, allowing config file entries to * override. */ - if (pMga->pEnt->device->chipset && *pMga->pEnt->device->chipset) { - pScrn->chipset = pMga->pEnt->device->chipset; + if (pMga->device->chipset && *pMga->device->chipset) { + pScrn->chipset = pMga->device->chipset; pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset); from = X_CONFIG; - } else if (pMga->pEnt->device->chipID >= 0) { - pMga->Chipset = pMga->pEnt->device->chipID; + } else if (pMga->device->chipID >= 0) { + pMga->Chipset = pMga->device->chipID; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); from = X_CONFIG; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", @@ -1278,14 +1413,24 @@ pMga->Chipset = pMga->PciInfo->chipType; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); } - if (pMga->pEnt->device->chipRev >= 0) { - pMga->ChipRev = pMga->pEnt->device->chipRev; + if (pMga->device->chipRev >= 0) { + pMga->ChipRev = pMga->device->chipRev; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", pMga->ChipRev); } else { pMga->ChipRev = pMga->PciInfo->chipRev; } +#ifdef USEMGAHAL + if (HAL_CHIPSETS && !xf86ReturnOptValBool(MGAOptions, OPTION_NOHAL, FALSE) + && xf86LoadSubModule(pScrn, "mga_hal")) { + xf86LoaderReqSymLists(halSymbols, NULL); + xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Matrox HAL module used\n"); + pMga->HALLoaded = TRUE; + } else + pMga->HALLoaded = FALSE; +#endif + /* * This shouldn't happen because such problems should be caught in * MGAProbe(), but check it just in case. @@ -1325,8 +1470,42 @@ pMga->numXAALines); } +#ifdef XF86DRI + { + Bool temp; + + from = X_DEFAULT; + + pMga->agp_mode = 1; + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_2X, + &temp)) { + pMga->agp_mode = 2; + from = X_CONFIG; + } + + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_4X, + &temp)) { + pMga->agp_mode = 4; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP Mode %dx\n", + pMga->agp_mode); + + pMga->ReallyUseIrqZero = 0; + + if (xf86GetOptValBool(MGAOptions, OPTION_USEIRQZERO, + &temp)) { + pMga->ReallyUseIrqZero = 1; + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, from, "Enabling use of IRQ " + "Zero (Dangerous)\n"); + } + + } +#endif + from = X_DEFAULT; - pMga->HWCursor = TRUE; + /* * The preferred method is to use the "hw cursor" option as a tri-state * option, with the default set above. @@ -1334,13 +1513,19 @@ if (xf86GetOptValBool(MGAOptions, OPTION_HW_CURSOR, &pMga->HWCursor)) { from = X_CONFIG; } - /* For compatibility, accept this too (as an override) */ - if (xf86ReturnOptValBool(MGAOptions, OPTION_SW_CURSOR, FALSE)) { - from = X_CONFIG; - pMga->HWCursor = FALSE; +#ifdef USEMGAHAL + if (pMga->HALLoaded) { + xf86GetOptValBool(MGAOptions, OPTION_TV, &tv); + if (tv == TRUE) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "TV Support\n"); + } + xf86GetOptValBool(MGAOptions, OPTION_DIGITAL, &digital); + if (digital == TRUE) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Digital Screen Support\n"); + } } - xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", - pMga->HWCursor ? "HW" : "SW"); +#endif + /* For compatibility, accept this too (as an override) */ if (xf86ReturnOptValBool(MGAOptions, OPTION_NOACCEL, FALSE)) { pMga->NoAccel = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); @@ -1366,7 +1551,7 @@ } if ((s = xf86GetOptValString(MGAOptions, OPTION_OVERLAY))) { if (!*s || !xf86NameCmp(s, "8,24") || !xf86NameCmp(s, "24,8")) { - if(pScrn->bitsPerPixel == 32) { + if(pScrn->bitsPerPixel == 32 && pMga->SecondCrtc == FALSE) { pMga->Overlay8Plus24 = TRUE; if(!xf86GetOptValInteger( MGAOptions, OPTION_COLOR_KEY,&(pMga->colorKey))) @@ -1377,13 +1562,15 @@ "PseudoColor overlay enabled\n"); } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Option \"Overlay\" is only supported in 32 bits per pixel\n"); + "Option \"Overlay\" is only supported in 32 bits per pixel on" + "the first CRTC\n"); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid value for Option \"Overlay\"\n", s); } } + if(xf86GetOptValInteger(MGAOptions, OPTION_VIDEO_KEY, &(pMga->videoKey))) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", pMga->videoKey); @@ -1448,23 +1635,6 @@ } } - if(pMga->HasSDRAM) { /* don't bother checking */ } - else if ((pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SD) || - (pMga->PciInfo->subsysCard == PCI_CARD_MARV_G200_SD) || - (pMga->PciInfo->subsysCard == PCI_CARD_MYST_G200_SD) || - (pMga->PciInfo->subsysCard == PCI_CARD_PROD_G100_SD)) { - pMga->HasSDRAM = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n"); - } - else if (pMga->Primary && (pMga->Chipset != PCI_CHIP_MGA2064) && - (pMga->Chipset != PCI_CHIP_MGA2164) && - (pMga->Chipset != PCI_CHIP_MGA2164_AGP)) { - if(!(pciReadLong(pMga->PciTag, PCI_OPTION_REG) & (1 << 14))) { - pMga->HasSDRAM = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n"); - } - } - switch (pMga->Chipset) { case PCI_CHIP_MGA2064: case PCI_CHIP_MGA2164: @@ -1473,6 +1643,7 @@ break; case PCI_CHIP_MGA1064: case PCI_CHIP_MGAG100: + case PCI_CHIP_MGAG100_PCI: case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: case PCI_CHIP_MGAG400: @@ -1487,16 +1658,16 @@ * For the 2064 and older rev 1064, base0 is the MMIO and base0 is * the framebuffer is base1. Let the config file override these. */ - if (pMga->pEnt->device->MemBase != 0) { + if (pMga->device->MemBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->MemBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->MemBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MemBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->MemBase); + pMga->device->MemBase); MGAFreeRec(pScrn); return FALSE; } - pMga->FbAddress = pMga->pEnt->device->MemBase; + pMga->FbAddress = pMga->device->MemBase; from = X_CONFIG; } else { /* details: mgabase2 sdk pp 4-12 */ @@ -1513,19 +1684,20 @@ return FALSE; } } + xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", (unsigned long)pMga->FbAddress); - if (pMga->pEnt->device->IOBase != 0) { + if (pMga->device->IOBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->IOBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->IOBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "IOBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->IOBase); + pMga->device->IOBase); MGAFreeRec(pScrn); return FALSE; } - pMga->IOAddress = pMga->pEnt->device->IOBase; + pMga->IOAddress = pMga->device->IOBase; from = X_CONFIG; } else { /* details: mgabase1 sdk pp 4-11 */ @@ -1562,9 +1734,9 @@ */ pMga->BiosFrom = X_NONE; - if (pMga->pEnt->device->BiosBase != 0) { + if (pMga->device->BiosBase != 0) { /* XXX This isn't used */ - pMga->BiosAddress = pMga->pEnt->device->BiosBase; + pMga->BiosAddress = pMga->device->BiosBase; pMga->BiosFrom = X_CONFIG; } else { /* details: rombase sdk pp 4-15 */ @@ -1611,20 +1783,73 @@ * file, we respect that setting. */ from = X_PROBED; - if (pMga->pEnt->device->videoRam != 0) { - pScrn->videoRam = pMga->pEnt->device->videoRam; + if (pMga->device->videoRam != 0) { + pScrn->videoRam = pMga->device->videoRam; from = X_CONFIG; } else if (pMga->FBDev) { pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024; } else { pScrn->videoRam = MGACountRam(pScrn); } + + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* This takes gives either half or 8 meg to the second head + * whichever is less. */ + if(pMga->SecondCrtc == FALSE) { + Bool UseHalf = FALSE; + int adjust; + + xf86GetOptValBool(MGAOptions, OPTION_CRTC2HALF, &UseHalf); + adjust = pScrn->videoRam / 2; + + if (UseHalf == TRUE) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } else { + adjust = min(adjust, 8192); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } + pMgaEnt->mastervideoRam = pScrn->videoRam - adjust; + pScrn->videoRam = pMgaEnt->mastervideoRam; + pMgaEnt->slavevideoRam = adjust; + pMgaEnt->masterFbAddress = pMga->FbAddress; + pMga->FbMapSize = + pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024; + pMgaEnt->slaveFbAddress = pMga->FbAddress + + pMgaEnt->masterFbMapSize; + pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024; + pMga->realSrcOrg = pMga->SrcOrg = 0; + pMga->DstOrg = 0; + } else { + pMga->FbAddress = pMgaEnt->slaveFbAddress; + pMga->FbMapSize = pMgaEnt->slaveFbMapSize; + pScrn->videoRam = pMgaEnt->slavevideoRam; + pMga->DstOrg = pMga->realSrcOrg = + pMgaEnt->slaveFbAddress - pMgaEnt->masterFbAddress; + pMga->SrcOrg = 0; /* This is not stored in hw format!! */ + } + pMgaEnt->refCount++; + } else { + /* Normal Handling of video ram etc */ + pMga->FbMapSize = pScrn->videoRam * 1024; + switch(pMga->Chipset) { + case PCI_CHIP_MGAG400: + case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: + pMga->SrcOrg = 0; + pMga->DstOrg = 0; + break; + default: + break; + } + } xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", pScrn->videoRam); - - pMga->FbMapSize = pScrn->videoRam * 1024; - - /* Set the bpp shift value */ + + /* Set the bpp shift value */ pMga->BppShifts[0] = 0; pMga->BppShifts[1] = 1; pMga->BppShifts[2] = 0; @@ -1690,25 +1915,25 @@ * If the user has specified ramdac speed in the XF86Config * file, we respect that setting. */ - if (pMga->pEnt->device->dacSpeeds[0]) { + if (pMga->device->dacSpeeds[0]) { int speed = 0; switch (pScrn->bitsPerPixel) { case 8: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP8]; + speed = pMga->device->dacSpeeds[DAC_BPP8]; break; case 16: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP16]; + speed = pMga->device->dacSpeeds[DAC_BPP16]; break; case 24: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP24]; + speed = pMga->device->dacSpeeds[DAC_BPP24]; break; case 32: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP32]; + speed = pMga->device->dacSpeeds[DAC_BPP32]; break; } if (speed == 0) - pMga->MaxClock = pMga->pEnt->device->dacSpeeds[0]; + pMga->MaxClock = pMga->device->dacSpeeds[0]; else pMga->MaxClock = speed; from = X_CONFIG; @@ -1716,10 +1941,13 @@ pMga->MaxClock = pMga->Dac.maxPixelClock; from = pMga->Dac.ClockFrom; } + if(pMga->SecondCrtc == TRUE) { + /* Override on 2nd crtc */ + pMga->MaxClock = 112000; + } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", pMga->MaxClock / 1000); - - /* + /* * Setup the ClockRanges, which describe what clock ranges are available, * and what sort of modes they can be used for. */ @@ -1730,6 +1958,13 @@ clockRanges->clockIndex = -1; /* programmable */ clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; +#ifdef USEMGAHAL + MGA_HAL(clockRanges->interlaceAllowed = FALSE); + MGA_HAL(clockRanges->doubleScanAllowed = FALSE); +#endif + if (pMga->SecondCrtc == TRUE) + clockRanges->interlaceAllowed = FALSE; + clockRanges->ClockMulFactor = 1; clockRanges->ClockDivFactor = 1; @@ -1778,6 +2013,7 @@ } break; case PCI_CHIP_MGAG100: + case PCI_CHIP_MGAG100_PCI: maxPitch = 2048; break; case PCI_CHIP_MGAG200: @@ -1808,6 +2044,7 @@ i = 1; } if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Validate Modes Failed\n"); MGAFreeRec(pScrn); return FALSE; } @@ -1820,7 +2057,85 @@ MGAFreeRec(pScrn); return FALSE; } +#ifdef USEMGAHAL + MGA_HAL( + if(pMga->SecondCrtc == FALSE) { + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAMapMem(pScrn); + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + MGAUnmapMem(pScrn); + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + + /* copy the board handles */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1; + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + } else { /* Second CRTC && entity is shared */ + if (digital == TRUE) { + mgaModeInfo.flOutput = MGAMODEINFO_DIGITAL2 | + MGAMODEINFO_SECOND_CRTC; + } else if (tv == TRUE) { + mgaModeInfo.flOutput = MGAMODEINFO_TV | + MGAMODEINFO_SECOND_CRTC; + } else { + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC; + } + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pMgaHwInfo = pMga->pMgaHwInfo; + } + if(MGAValidateMode(pMga->pBoard,&mgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MGAValidateMode from HALlib found the mode to be invalid\n"); + return FALSE; + } + pScrn->displayWidth = mgaModeInfo.ulFBPitch; + ); /* MGA_HAL */ +#endif + if(pMga->HasSDRAM) { /* don't bother checking */ } + else if ((pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SD) || + (pMga->PciInfo->subsysCard == PCI_CARD_MARV_G200_SD) || + (pMga->PciInfo->subsysCard == PCI_CARD_MYST_G200_SD) || + (pMga->PciInfo->subsysCard == PCI_CARD_PROD_G100_SD)) { + pMga->HasSDRAM = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n"); + } + /* + * Can we trust HALlib to set the memory configuration + * registers correctly? + */ + else if ((pMga->softbooted || pMga->Primary /*|| pMga->HALLoaded*/ ) && + (pMga->Chipset != PCI_CHIP_MGA2064) && + (pMga->Chipset != PCI_CHIP_MGA2164) && + (pMga->Chipset != PCI_CHIP_MGA2164_AGP)) { + CARD32 option_reg = pciReadLong(pMga->PciTag, PCI_OPTION_REG); + if(!(option_reg & (1 << 14))) { + pMga->HasSDRAM = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n"); + } + } + /* * Set the CRTC parameters for all of the modes based on the type * of mode, and the chipset's interlace requirements. @@ -1829,7 +2144,12 @@ * driver and if the driver doesn't provide code to set them. They * are not pre-initialised at all. */ +#ifdef USEMGAHAL + MGA_HAL(xf86SetCrtcForModes(pScrn, 0)); + MGA_NOT_HAL(xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V)); +#else xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); +#endif /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -1889,64 +2209,73 @@ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n", pMga->YDstOrg); - pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMga->SecondCrtc == FALSE) { + pMga->FbUsableSize = pMgaEnt->masterFbMapSize; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMgaEnt->masterFbMapSize - + pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } else { /* Second CRTC */ + pMga->FbUsableSize = pMgaEnt->slaveFbMapSize; + pMga->HWCursor = FALSE; + } + } else { + pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } /* * XXX This should be taken into account in some way in the mode valdation * section. */ - /* Allocate HW cursor buffer at the end of video ram */ - if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { - if( pScrn->virtualY * pScrn->displayWidth * pScrn->bitsPerPixel / 8 <= - pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { - pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; - pMga->FbCursorOffset = - pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; - } else { - pMga->HWCursor = FALSE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Too little offscreen memory for HW cursor; using SW cursor\n"); - } - } - /* Load bpp-specific modules */ - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - break; - case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - reqSym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - reqSym = "cfb24_32ScreenInit"; + /* Load the required framebuffer */ + if (pMga->Overlay8Plus24) { + if (!xf86LoadSubModule(pScrn, "xf8_32bpp")) { + MGAFreeRec(pScrn); + return FALSE; } - break; - case 32: - if (pMga->Overlay8Plus24) { - mod = "xf8_32bpp"; - reqSym = "cfb8_32ScreenInit"; - xf86LoaderReqSymLists(xf8_32bppSymbols, NULL); - } else { - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - + reqSym = "cfb8_32ScreenInit"; + } else { + if (!xf86LoadSubModule(pScrn, "fb")) { + MGAFreeRec(pScrn); + return FALSE; } - break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - MGAFreeRec(pScrn); - return FALSE; + reqSym = "fbScreenInit"; +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif } - xf86LoaderReqSymbols(reqSym, NULL); + /* Load XAA if needed */ if (!pMga->NoAccel) { if (!xf86LoadSubModule(pScrn, "xaa")) { @@ -1982,7 +2311,45 @@ pMga->CurrentLayout.weight.blue = pScrn->weight.blue; pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24; pMga->CurrentLayout.mode = pScrn->currentMode; +#ifdef USEMGAHAL + MGA_HAL( + /* Close the library after preinit */ + /* This needs to only happen after this board has completed preinit + * both times + */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* Entity is shared make sure refcount == 2 */ + /* If ref count is 2 then reset it to 0 */ + if(pMgaEnt->refCount == 2) { + /* Both boards have done there initialization */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + pMgaEnt->refCount = 0; + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } + ); /* MGA_HAL */ +#endif + xf86SetPrimInitDone(pScrn->entityList[0]); return TRUE; } @@ -2129,10 +2496,80 @@ MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; + if(pMga->SecondCrtc == TRUE) return; +#ifdef USEMGAHAL + if (pMga->HALLoaded) + MGA_HAL(if (pMga->pBoard != NULL) MGASaveVgaState(pMga->pBoard)); +#endif + /* Only save text mode fonts/text for the primary card */ (*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary); } +#ifdef USEMGAHAL +/* Convert DisplayModeRec parameters in MGAMODEINFO parameters. */ +static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + const char *s; + MGAPtr pMga = MGAPTR(pScrn); + + pMga->pMgaModeInfo = (LPMGAMODEINFO) xalloc (sizeof(MGAMODEINFO)); + pMga->pMgaModeInfo->flOutput = 0; + pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay; + pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay; + pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX; + pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY; + pMga->pMgaModeInfo->ulFBPitch = 0; + pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel; + pMga->pMgaModeInfo->ulZoom = 1; + pMga->pMgaModeInfo->flSignalMode = 0x10; + + /* Set TV standard */ + if ((s = xf86GetOptValString(MGAOptions, OPTION_TVSTANDARD))) { + if (!xf86NameCmp(s, "PAL")) { + pMga->pMgaModeInfo->flSignalMode = 0x00; + pMga->pMgaModeInfo->ulRefreshRate = 50; + pMga->pMgaModeInfo->ulTVStandard = TV_PAL; + } else { + pMga->pMgaModeInfo->ulRefreshRate = 60; + pMga->pMgaModeInfo->ulTVStandard = TV_NTSC; + } + } else { + pMga->pMgaModeInfo->ulRefreshRate = 60; + pMga->pMgaModeInfo->ulTVStandard = TV_NTSC; + } + + /* Set Cable Type */ + if ((s = xf86GetOptValString(MGAOptions, OPTION_CABLETYPE))) { + if (!xf86NameCmp(s, "SCART_RGB")) { + pMga->pMgaModeInfo->ulCableType = TV_SCART_RGB; + } else if (!xf86NameCmp(s, "SCART_COMPOSITE")) { + pMga->pMgaModeInfo->ulCableType = TV_SCART_COMPOSITE; + } else if (!xf86NameCmp(s, "SCART_TYPE2")) { + pMga->pMgaModeInfo->ulCableType = TV_SCART_TYPE2; + } else { + pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE; + } + } else { + pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE; + } + + pMga->pMgaModeInfo->ulHorizRate = 0; + pMga->pMgaModeInfo->ulPixClock = mode->Clock; + pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay; + pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart; + pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd; + pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay; + pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart; + pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd; + /* Use DstOrg directly */ + /* This is an offset in pixels not memory */ + pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulPanXGran = 0; + pMga->pMgaModeInfo->ulPanYGran = 0; +} +#endif /* * Initialise a new mode. This is currently still using the old @@ -2147,6 +2584,18 @@ vgaRegPtr vgaReg; MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg; +#ifdef USEMGAHAL + Bool digital = FALSE; + Bool tv = FALSE; + ULONG status; + + if (pMga->HALLoaded) { + /* Verify if user wants digital screen output */ + xf86GetOptValBool(MGAOptions, OPTION_DIGITAL, &digital); + /* Verify if user wants TV output */ + xf86GetOptValBool(MGAOptions, OPTION_TV, &tv); + } +#endif vgaHWUnlock(hwp); @@ -2163,13 +2612,76 @@ vgaReg = &hwp->ModeReg; mgaReg = &pMga->ModeReg; +#ifdef USEMGAHAL + MGA_HAL( + FillModeInfoStruct(pScrn,mode); + + if(pMga->SecondCrtc == TRUE) { + if (digital == TRUE) { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_DIGITAL2 | + MGAMODEINFO_SECOND_CRTC | + MGAMODEINFO_FORCE_PITCH | + MGAMODEINFO_FORCE_DISPLAYORG; + } else if (tv == TRUE) { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_TV | + MGAMODEINFO_SECOND_CRTC | + MGAMODEINFO_FORCE_PITCH | + MGAMODEINFO_FORCE_DISPLAYORG; + } else { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC | + MGAMODEINFO_FORCE_PITCH | + MGAMODEINFO_FORCE_DISPLAYORG; + } + } else { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG1 | + MGAMODEINFO_FORCE_PITCH; + } + + pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth; + /* Validate the parameters */ + if ((status = MGAValidateMode(pMga->pBoard, pMga->pMgaModeInfo)) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MGAValidateMode from HALlib found the mode to be invalid. Error: %lx\n", status); + return FALSE; + } + + /* Validates the Video parameters */ + if ((status = MGAValidateVideoParameters(pMga->pBoard, pMga->pMgaModeInfo)) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MGAValidateVideoParameters from HALlib found the mode to be invalid. Error: %lx\n", status); + return FALSE; + } + ); /* MGA_HAL */ +#endif + #ifdef XF86DRI if (pMga->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); } #endif - + +#ifdef USEMGAHAL + MGA_HAL( + /* Initialize the board */ + if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MGASetMode returned an error. Make sure to validate the mode before.\n"); + return FALSE; + } + ); /* MGA_HAL */ + +#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val) +#define outMGAdac(reg, val) (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) + + MGA_HAL( + if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) { + outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW, pMga->FbCursorOffset >> 10); + outMGAdac(MGA1064_CURSOR_BASE_ADR_HI, pMga->FbCursorOffset >> 18); + } + ); /* MGA_HAL */ + MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE)); +#else (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); +#endif MGAStormSync(pScrn); MGAStormEngineInit(pScrn); @@ -2202,20 +2714,53 @@ vgaRegPtr vgaReg = &hwp->SavedReg; MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; + + if (pScrn->pScreen != NULL) + MGAStormSync(pScrn); - if (pScrn->pScreen != NULL) - MGAStormSync(pScrn); + if(pMga->SecondCrtc == TRUE) return; /* Only restore text mode fonts/text for the primary card */ vgaHWProtect(pScrn, TRUE); - if (pMga->Primary) + if (pMga->Primary) { +#ifdef USEMGAHAL + MGA_HAL( + if(pMga->pBoard != NULL) { + MGASetVgaMode(pMga->pBoard); + MGARestoreVgaState(pMga->pBoard); + } + ); /* MGA_HAL */ +#endif (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE); - else + } else { vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + } vgaHWProtect(pScrn, FALSE); } +/* Workaround for a G400 CRTC2 display problem */ +static void +MGACrtc2FillStrip(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if (pMga->NoAccel) { + /* Clears the whole screen, but ... */ + bzero(pMga->FbStart, + (pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY); + } else { + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + pMga->RestoreAccelState(pScrn); + pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0x00000000); + pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0, + pScrn->displayWidth - pScrn->virtualX, + pScrn->virtualY); + MGAStormSync(pScrn); + } +} + + /* Mandatory */ /* This gets called at the start of each server generation */ @@ -2231,6 +2776,8 @@ VisualPtr visual; unsigned char *FBStart; int width, height, displayWidth; + MGAEntPtr pMgaEnt = NULL; + int f; /* * First get the ScrnInfoRec @@ -2240,7 +2787,7 @@ hwp = VGAHWPTR(pScrn); pMga = MGAPTR(pScrn); MGAdac = &pMga->Dac; - + /* Map the MGA memory and MMIO areas */ if (pMga->FBDev) { if (!MGAMapMemFBDev(pScrn)) @@ -2250,6 +2797,66 @@ return FALSE; } + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount++; +#ifdef USEMGAHAL + MGA_HAL( + if(pMgaEnt->refCount == 1) { + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + + /* Detecting for type of display */ + if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_TV) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "TV detected\n"); + } + if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_DIGITAL) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Digital Screen detected\n"); + } + + /* Now copy these to the entitystructure */ + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } else { /* Ref count is 2 */ + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo; + } + ); +#endif + } else { +#ifdef USEMGAHAL + MGA_HAL( + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + ); /* MGA_HAL */ +#endif + } +#ifdef USEMGAHAL + MGA_HAL( + /* There is a problem in the HALlib: set soft reset bit */ + if ( !pMga->Primary && !pMga->FBDev && + (pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SG) ) { + OUTREG(MGAREG_Reset, 1); + usleep(200); + OUTREG(MGAREG_Reset, 0); + } + ) +#endif + /* Initialise the MMIO vgahw functions */ vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET); vgaHWGetIOBase(hwp); @@ -2276,9 +2883,12 @@ return FALSE; } - /* Darken the screen for aesthetic reasons and set the viewport */ - MGASaveScreen(pScreen, SCREEN_SAVER_ON); + if (pMga->SecondCrtc == TRUE) { + MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON); + } else { + MGASaveScreen(pScreen, SCREEN_SAVER_ON); + } pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); /* @@ -2307,11 +2917,23 @@ return FALSE; if (!miSetVisualTypes(24, TrueColorMask, pScrn->rgbBits, TrueColor)) return FALSE; + } else if (pMga->SecondCrtc) { + /* No DirectColor on the second head */ + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + TrueColor)) + return FALSE; + if (!miSetPixmapDepths ()) + return FALSE; } else { + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; + if (!miSetPixmapDepths ()) + return FALSE; } @@ -2348,57 +2970,29 @@ * The DRI does not work when textured video is enabled at this time. */ - if (!pMga->NoAccel && pMga->TexturedVideo != TRUE) + if (!pMga->NoAccel && pMga->TexturedVideo != TRUE && + pMga->SecondCrtc == FALSE) pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); else pMga->directRenderingEnabled = FALSE; #endif - switch (pScrn->bitsPerPixel) { - case 8: - ret = cfbScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 16: - ret = cfb16ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 32: - if(pMga->Overlay8Plus24) - ret = cfb8_32ScreenInit(pScreen, FBStart, - width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb32ScreenInit(pScreen, FBStart, + if (pMga->Overlay8Plus24) { + ret = cfb8_32ScreenInit(pScreen, FBStart, width, height, pScrn->xDpi, pScrn->yDpi, displayWidth); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in MGAScreenInit\n", - pScrn->bitsPerPixel); - ret = FALSE; - break; + } else { + ret = fbScreenInit(pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif } + if (!ret) return FALSE; @@ -2420,6 +3014,9 @@ xf86SetBlackWhitePixels(pScreen); + pMga->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = MGABlockHandler; + if(!pMga->ShadowFB) /* hardware cursor needs to wrap this layer */ MGADGAInit(pScreen); @@ -2448,9 +3045,12 @@ /* Initialize colormap layer. Must follow initialization of the default colormap */ + if (!pMga->SecondCrtc) + f = CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH; + else + f = CMAP_RELOAD_ON_MODE_SWITCH; if(!xf86HandleColormaps(pScreen, 256, 8, - (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, - CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) + (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f)) return FALSE; if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */ @@ -2482,6 +3082,16 @@ xf86DPMSInit(pScreen, MGADisplayPowerManagementSet, 0); #endif + pScrn->memPhysBase = pMga->FbAddress; + pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8); + + if(pMga->SecondCrtc == TRUE) { + pScreen->SaveScreen = MGASaveScreenCrtc2; + } else { + pScreen->SaveScreen = MGASaveScreen; + } + MGAInitVideo(pScreen); + #ifdef XF86DRI /* Initialize the Warp engine */ if (pMga->directRenderingEnabled) { @@ -2498,15 +3108,11 @@ } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } + if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE) + pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled; + pMga->have_quiescense = 1; #endif - pScrn->memPhysBase = pMga->FbAddress; - pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8); - - MGAInitVideo(pScreen); - - pScreen->SaveScreen = MGASaveScreen; - /* Wrap the current CloseScreen function */ pMga->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = MGACloseScreen; @@ -2516,6 +3122,11 @@ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + /* Done */ return TRUE; } @@ -2574,7 +3185,34 @@ } +#define C2STARTADD0 0x3C28 + +void +MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn; + int Base; + MGAFBLayout *pLayout; + MGAPtr pMga; + pScrn = xf86Screens[scrnIndex]; + pMga = MGAPTR(pScrn); + pLayout = &pMga->CurrentLayout; + + if(pMga->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + /* 3-85 c2offset + * 3-93 c2startadd0 + * 3-96 c2vcount + */ + + Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3; + Base += pMga->DstOrg; + Base &= 0x01ffffc0; + OUTREG(C2STARTADD0, Base); +} + /* * This is called when VT switching back to the X server. Its job is * to reinitialise the video mode. @@ -2587,12 +3225,15 @@ MGAEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga; #ifdef XF86DRI ScreenPtr pScreen; - MGAPtr pMGA; +#endif - pMGA = MGAPTR(pScrn); - if (pMGA->directRenderingEnabled) { + pMga = MGAPTR(pScrn); + +#ifdef XF86DRI + if (pMga->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); } @@ -2601,6 +3242,12 @@ if (!MGAModeInit(pScrn, pScrn->currentMode)) return FALSE; MGAAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + return TRUE; } @@ -2672,7 +3319,8 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; vgaHWPtr hwp = VGAHWPTR(pScrn); MGAPtr pMga = MGAPTR(pScrn); - + MGAEntPtr pMgaEnt = NULL; + if (pScrn->vtSema) { if (pMga->FBDev) { fbdevHWRestore(pScrn); @@ -2690,7 +3338,45 @@ pMga->directRenderingEnabled=FALSE; } #endif - + + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount--; + } + +#ifdef USEMGAHAL + MGA_HAL( + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMgaEnt->refCount == 0) { + /* Both boards have closed there screen */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } + ); /* MGA_HAL */ +#endif + if (pMga->AccelInfoRec) XAADestroyInfoRec(pMga->AccelInfoRec); if (pMga->CursorInfoRec) @@ -2703,12 +3389,16 @@ xfree(pMga->adaptor); if (pMga->portPrivate) xfree(pMga->portPrivate); + if (pMga->ScratchBuffer) + xfree(pMga->ScratchBuffer); pScrn->vtSema = FALSE; if (xf86IsPc98()) outb(0xfac, 0x00); + xf86ClearPrimInitDone(pScrn->entityList[0]); + if(pMga->BlockHandler) pScreen->BlockHandler = pMga->BlockHandler; @@ -2740,6 +3430,8 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { int lace; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga = MGAPTR(pScrn); lace = 1 + ((mode->Flags & V_INTERLACE) != 0); @@ -2751,6 +3443,17 @@ (mode->CrtcVSyncStart <= 4096 * lace) && (mode->CrtcVSyncEnd <= 4096 * lace) && (mode->CrtcVTotal <= 4096 * lace)) { + + /* Can't have horizontal panning for second head of G400 */ + if (pMga->SecondCrtc) { + if (flags == MODECHECK_FINAL) { + if (pMga->allowedWidth == 0) + pMga->allowedWidth = pScrn->virtualX; + if (mode->HDisplay != pMga->allowedWidth) + return(MODE_ONE_WIDTH); + } + } + return(MODE_OK); } else { return(MODE_BAD); @@ -2761,6 +3464,36 @@ /* Do screen blanking */ /* Mandatory */ +#define MGAREG_C2CTL 0x3c10 + +static Bool +MGASaveScreenCrtc2(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + MGAPtr pMga = NULL; + Bool on; + CARD32 tmp; + + on = xf86IsUnblank(mode); + + if (on) + SetTimeSinceLastInputEvent(); + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn != NULL) + pMga = MGAPTR(pScrn); + + if(pMga != NULL && pScrn->vtSema) { + tmp = INREG(MGAREG_C2CTL); + tmp &= ~0x00000008; + if (!on) tmp |= 0x0000008; + OUTREG(MGAREG_C2CTL, tmp); + } + + return TRUE; +} + static Bool MGASaveScreen(ScreenPtr pScreen, int mode) { @@ -2781,8 +3514,6 @@ MGAPtr pMga = MGAPTR(pScrn); unsigned char seq1 = 0, crtcext1 = 0; -ErrorF("MGADisplayPowerManagementSet: %d\n", PowerManagementMode); - switch (PowerManagementMode) { case DPMSModeOn: @@ -2815,6 +3546,34 @@ OUTREG8(0x1FDF, crtcext1); } #endif + + +static void +MGABlockHandler ( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask +){ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + MGAPtr pMga = MGAPTR(pScrn); + + if(pMga->PaletteLoadCallback) + (*pMga->PaletteLoadCallback)(pScrn); + + pScreen->BlockHandler = pMga->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = MGABlockHandler; + + if(pMga->VideoTimerCallback) { + UpdateCurrentTime(); + (*pMga->VideoTimerCallback)(pScrn, currentTime.milliseconds); + } + + if(pMga->RenderCallback) + (*pMga->RenderCallback)(pScrn); +} #if defined (DEBUG) /* Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_halmod.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/mga/mga_halmod.c:1.1 --- /dev/null Mon Dec 18 14:30:50 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_halmod.c Wed Dec 6 10:35:21 2000 @@ -0,0 +1,38 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_halmod.c,v 1.1 2000/12/06 15:35:21 eich Exp $ */ +#include "xf86Module.h" + +#ifdef XFree86LOADER + +#define HAL_MAJOR_VERSION 1 +#define HAL_MINOR_VERSION 0 +#define HAL_PATCHLEVEL 0 + +static MODULESETUPPROTO(halSetup); + +static XF86ModuleVersionInfo halVersRec = +{ + "mga_hal", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + HAL_MAJOR_VERSION, HAL_MINOR_VERSION, HAL_PATCHLEVEL, + ABI_CLASS_VIDEODRV, /* This is a video driver */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_NONE, + {0,0,0,0} +}; + +/* + * This is the module init data. + * Its name has to be the driver name followed by ModuleData. + */ +XF86ModuleData mga_halModuleData = { &halVersRec, halSetup, NULL }; + +static pointer +halSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + return (pointer)1; +} + +#endif /* XFree86LOADER */ Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h:1.14 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h:1.14 Fri Jun 16 20:03:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h Wed Dec 6 10:35:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.14 2000/06/17 00:03:20 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.18 2000/12/06 15:35:21 eich Exp $ */ #ifndef _MGA_MACROS_H_ #define _MGA_MACROS_H_ @@ -17,7 +17,7 @@ #define REPLICATE(r) /* */ #endif -#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) +#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) #ifdef XF86DRI #define MGA_SYNC_XTAG 0x275f4200 @@ -49,9 +49,8 @@ ( MAKEDMAINDEX(one) | \ (MAKEDMAINDEX(two) << 8) | \ (MAKEDMAINDEX(three) << 16) | \ - (MAKEDMAINDEX(four) << 24) ) + (MAKEDMAINDEX(four) << 24) ) - #if PSZ == 24 #define SET_PLANEMASK(p) /**/ #else @@ -63,7 +62,6 @@ } #endif - #define SET_FOREGROUND(c) \ if((c) != pMga->FgColor) { \ pMga->FgColor = (c); \ @@ -84,16 +82,29 @@ OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); } #ifdef XF86DRI -extern void mgaGetQuiescence( ScrnInfoPtr pScrn ); - #define CHECK_DMA_QUIESCENT(pMGA, pScrn) { \ if (!pMGA->have_quiescense) { \ - mgaGetQuiescence( pScrn ); \ + pMGA->GetQuiescence( pScrn ); \ } \ } #else #define CHECK_DMA_QUIESCENT(pMGA, pScrn) #endif +#ifdef USEMGAHAL +#define HAL_CHIPSETS ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || \ + (pMga->Chipset == PCI_CHIP_MGAG200) || \ + (pMga->Chipset == PCI_CHIP_MGAG400)) +#define MGA_HAL(x) { \ + MGAPtr pMga = MGAPTR(pScrn); \ + if (pMga->HALLoaded && HAL_CHIPSETS) { x; } \ +} +#define MGA_NOT_HAL(x) { \ + MGAPtr pMga = MGAPTR(pScrn); \ + if (!pMga->HALLoaded || !HAL_CHIPSETS) { x; } \ +} +#else +#define MGA_NOT_HAL(x) { x; } +#endif #endif /* _MGA_MACROS_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h:1.12 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h:1.12 Fri Jun 9 18:43:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h Wed Nov 8 00:03:04 2000 @@ -2,7 +2,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.12 2000/06/09 22:43:38 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.14 2000/11/08 05:03:04 dawes Exp $ */ @@ -425,10 +425,15 @@ #define MGAREG_TEXTRANS 0x2c34 #define MGAREG_TEXTRANSHIGH 0x2c38 #define MGAREG_TEXFILTER 0x2c58 +#define MGAREG_ALPHASTART 0x2c70 +#define MGAREG_ALPHAXINC 0x2c74 +#define MGAREG_ALPHAYINC 0x2c78 #define MGAREG_ALPHACTRL 0x2c7c - #define MGAREG_DWGSYNC 0x2c4c +#define MGAREG_AGP_PLL 0x1e4c +#define AGP_PLL_agp2xpllen_enable 0x1 +#define AGP_PLL_agp2xpllen_disable 0x0 #endif Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c:1.69 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c:1.81 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c:1.69 Thu Jun 29 16:56:59 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c Thu Dec 14 11:33:09 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.69 2000/06/29 20:56:59 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.81 2000/12/14 16:33:09 eich Exp $ */ /* All drivers should typically include these */ @@ -43,10 +43,16 @@ static void MGANAME(SubsequentScreenToScreenCopy_FastBlit)(ScrnInfoPtr pScrn, int srcX, int srcY, int dstX, int dstY, int w, int h); -static void MGANAME(SetupForCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, int fg, +static void MGANAME(SetupForScanlineCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); -static void MGANAME(SubsequentCPUToScreenColorExpandFill)(ScrnInfoPtr pScrn, +static void MGANAME(SubsequentScanlineCPUToScreenColorExpandFill)( + ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); +static void MGANAME(SubsequentColorExpandScanline)(ScrnInfoPtr pScrn, + int bufno); +static void MGANAME(SubsequentColorExpandScanlineIndirect)(ScrnInfoPtr pScrn, + int bufno); static void MGANAME(SubsequentSolidFillRect)(ScrnInfoPtr pScrn, int x, int y, int w, int h); static void MGANAME(SubsequentSolidFillTrap)(ScrnInfoPtr pScrn, int y, int h, @@ -69,11 +75,12 @@ int patx, int paty, int y, int h, int left, int dxL, int dyL, int eL, int right, int dxR, int dyR, int eR); -static void MGANAME(SetupForImageWrite)(ScrnInfoPtr pScrn, int rop, +static void MGANAME(SetupForScanlineImageWrite)(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int transparency_color, int bpp, int depth); -static void MGANAME(SubsequentImageWriteRect)(ScrnInfoPtr pScrn, +static void MGANAME(SubsequentScanlineImageWriteRect)(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); +static void MGANAME(SubsequentImageWriteScanline)(ScrnInfoPtr pScrn, int num); #if PSZ != 24 static void MGANAME(SetupForPlanarScreenToScreenColorExpandFill)( ScrnInfoPtr pScrn, int fg, int bg, int rop, @@ -95,6 +102,12 @@ static void MGANAME(SubsequentDashedTwoPointLine)(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int flags, int phase); +void MGANAME(RestoreAccelState)(ScrnInfoPtr pScrn); +#if PSZ == 8 +void Mga16RestoreAccelState(ScrnInfoPtr pScrn); +void Mga24RestoreAccelState(ScrnInfoPtr pScrn); +void Mga32RestoreAccelState(ScrnInfoPtr pScrn); +#endif #ifdef XF86DRI void MGANAME(DRIInitBuffers)(WindowPtr pWin, @@ -104,13 +117,6 @@ #endif -extern void MGAWriteBitmapColorExpand(ScrnInfoPtr pScrn, int x, int y, - int w, int h, unsigned char *src, int srcwidth, - int skipleft, int fg, int bg, int rop, - unsigned int planemask); -extern void MGAFillColorExpandRects(ScrnInfoPtr pScrn, int fg, int bg, int rop, - unsigned int planemask, int nBox, BoxPtr pBox, - int xorg, int yorg, PixmapPtr pPix); extern void MGASetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2); extern void MGADisableClipping(ScrnInfoPtr pScrn); @@ -123,16 +129,436 @@ int rop, unsigned int planemask, int nBox, BoxPtr pBox, int pattern0, int pattern1, int xorigin, int yorigin); -extern void MGANonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, - NonTEGlyphPtr glyphs, BoxPtr pbox, - int fg, int rop, unsigned int planemask); extern void MGAValidatePolyArc(GCPtr, unsigned long, DrawablePtr); extern void MGAValidatePolyPoint(GCPtr, unsigned long, DrawablePtr); extern void MGAFillCacheBltRects(ScrnInfoPtr, int, unsigned int, int, BoxPtr, int, int, XAACacheInfoPtr); -extern void MGATEGlyphRenderer(ScrnInfoPtr, int, int, int, int, int, int, - unsigned int **glyphs, int, int, int, int, - unsigned planemask); + +#ifdef RENDER + +extern Bool +MGASetupForCPUToScreenAlphaTexture ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +); + +extern Bool +MGASetupForCPUToScreenAlphaTextureFaked ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +); + + +extern Bool +MGASetupForCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int op, + int texType, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags +); + +extern void +MGASubsequentCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height +); + +extern CARD32 MGAAlphaTextureFormats[2]; +extern CARD32 MGATextureFormats[2]; + +#if PSZ == 8 +#include "mipict.h" +#include "dixstruct.h" + +CARD32 MGAAlphaTextureFormats[2] = {PICT_a8, 0}; +CARD32 MGATextureFormats[2] = {PICT_a8r8g8b8, 0}; + +static void +RemoveLinear (FBLinearPtr linear) +{ + MGAPtr pMga = (MGAPtr)(linear->devPrivate.ptr); + + pMga->LinearScratch = NULL; /* just lost our scratch */ +} + +static void +RenderCallback (ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if((currentTime.milliseconds > pMga->RenderTime) && pMga->LinearScratch) { + xf86FreeOffscreenLinear(pMga->LinearScratch); + pMga->LinearScratch = NULL; + } + + if(!pMga->LinearScratch) + pMga->RenderCallback = NULL; +} + +#define RENDER_DELAY 15000 + +static Bool +AllocateLinear ( + ScrnInfoPtr pScrn, + int sizeNeeded +){ + MGAPtr pMga = MGAPTR(pScrn); + + pMga->RenderTime = currentTime.milliseconds + RENDER_DELAY; + pMga->RenderCallback = RenderCallback; + + if(pMga->LinearScratch) { + if(pMga->LinearScratch->size >= sizeNeeded) + return TRUE; + else { + if(xf86ResizeOffscreenLinear(pMga->LinearScratch, sizeNeeded)) + return TRUE; + + xf86FreeOffscreenLinear(pMga->LinearScratch); + pMga->LinearScratch = NULL; + } + } + + pMga->LinearScratch = xf86AllocateOffscreenLinear( + pScrn->pScreen, sizeNeeded, 32, + NULL, RemoveLinear, pMga); + + return (pMga->LinearScratch != NULL); +} + +static int +GetPowerOfTwo(int w) +{ + int Pof2; + int i = 12; + + while(--i) { + if(w & (1 << i)) { + Pof2 = i; + if(w & ((1 << i) - 1)) + Pof2++; + break; + } + } + return Pof2; +} + + +static int tex_padw, tex_padh; + +Bool +MGASetupForCPUToScreenAlphaTextureFaked ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + MGAPtr pMga = MGAPTR(pScrn); + + if(op != PictOpOver) /* only one tested */ + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) + sizeNeeded <<= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + XAA_888_plus_PICT_a8_to_8888( + (blue >> 8) | (green & 0xff00) | ((red & 0xff00) << 8), + alphaPtr, alphaPitch, (CARD32*)(pMga->FbStart + offset), + pitch, width, height); + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, 0x1A000106 | ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, 0x00000014); + OUTREG(MGAREG_DWGCTL, 0x000c7076); + OUTREG(MGAREG_TEXFILTER, 0x01e00020); + OUTREG(MGAREG_ALPHACTRL, 0x00000154); + + return TRUE; +} + +Bool +MGASetupForCPUToScreenAlphaTexture ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + CARD8 *dst; + MGAPtr pMga = MGAPTR(pScrn); + + if(op != PictOpOver) /* only one tested */ + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = (pitch * height) >> 1; + if(pScrn->bitsPerPixel == 32) + sizeNeeded >>= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + i = height; + dst = pMga->FbStart + offset; + while(i--) { + memcpy(dst, alphaPtr, width); + dst += pitch; + alphaPtr += alphaPitch; + } + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + + WAITFIFO(12); + OUTREG(MGAREG_DR4, red << 7); /* red start */ + OUTREG(MGAREG_DR6, 0); + OUTREG(MGAREG_DR7, 0); + OUTREG(MGAREG_DR8, green << 7); /* green start */ + OUTREG(MGAREG_DR10, 0); + OUTREG(MGAREG_DR11, 0); + OUTREG(MGAREG_DR12, blue << 7); /* blue start */ + OUTREG(MGAREG_DR14, 0); + OUTREG(MGAREG_DR15, 0); + OUTREG(MGAREG_ALPHASTART, alpha << 7); /* alpha start */ + OUTREG(MGAREG_ALPHAXINC, 0); + OUTREG(MGAREG_ALPHAYINC, 0); + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, 0x3A000107 | ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, 0x00000014); + OUTREG(MGAREG_DWGCTL, 0x000c7076); + OUTREG(MGAREG_TEXFILTER, 0x01e00020); + OUTREG(MGAREG_ALPHACTRL, 0x02000151); + + return TRUE; +} + + +Bool +MGASetupForCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int op, + int texType, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags +){ + int log2w, log2h, i, pitch, sizeNeeded, offset; + MGAPtr pMga = MGAPTR(pScrn); + + if(op != PictOpOver) /* only one tested */ + return FALSE; + + if((width > 2048) || (height > 2048)) + return FALSE; + + log2w = GetPowerOfTwo(width); + log2h = GetPowerOfTwo(height); + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(pMga->Overlay8Plus24) { + i = 0x00ffffff; + WAITFIFO(1); + SET_PLANEMASK(i); + } + + pitch = (width + 15) & ~15; + sizeNeeded = pitch * height; + if(pScrn->bitsPerPixel == 16) + sizeNeeded <<= 1; + + if(!AllocateLinear(pScrn, sizeNeeded)) + return FALSE; + + offset = pMga->LinearScratch->offset << 1; + if(pScrn->bitsPerPixel == 32) + offset <<= 1; + + if(pMga->AccelInfoRec->NeedToSync) + MGAStormSync(pScrn); + + { + CARD8 *dst = (CARD8*)(pMga->FbStart + offset); + i = height; + while(i--) { + memcpy(dst, texPtr, width << 2); + texPtr += texPitch; + dst += pitch << 2; + } + } + + tex_padw = 1 << log2w; + tex_padh = 1 << log2h; + + WAITFIFO(15); + OUTREG(MGAREG_TMR0, (1 << 20) / tex_padw); /* sx inc */ + OUTREG(MGAREG_TMR1, 0); /* sy inc */ + OUTREG(MGAREG_TMR2, 0); /* tx inc */ + OUTREG(MGAREG_TMR3, (1 << 20) / tex_padh); /* ty inc */ + OUTREG(MGAREG_TMR4, 0x00000000); + OUTREG(MGAREG_TMR5, 0x00000000); + OUTREG(MGAREG_TMR8, 0x00010000); + OUTREG(MGAREG_TEXORG, offset); + OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) | + ((width - 1) << 18)); + OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) | + ((height - 1) << 18)); + OUTREG(MGAREG_TEXCTL, 0x1A000106 | ((pitch & 0x07FF) << 9)); + OUTREG(MGAREG_TEXCTL2, 0x00000014); + OUTREG(MGAREG_DWGCTL, 0x000c7076); + OUTREG(MGAREG_TEXFILTER, 0x01e00020); + OUTREG(MGAREG_ALPHACTRL, 0x00000151); + + return TRUE; +} +void +MGASubsequentCPUToScreenTexture ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height +){ + MGAPtr pMga = MGAPTR(pScrn); + + WAITFIFO(4); + OUTREG(MGAREG_TMR6, (srcx << 20) / tex_padw); + OUTREG(MGAREG_TMR7, (srcy << 20) / tex_padh); + OUTREG(MGAREG_FXBNDRY, ((dstx + width) << 16) | (dstx & 0xffff)); + OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (dsty << 16) | height); + + pMga->AccelInfoRec->NeedToSync = TRUE; +} + + +#endif +#endif Bool MGANAME(AccelInit)(ScreenPtr pScreen) @@ -141,8 +567,12 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); int maxFastBlitMem, maxlines; + Bool doRender = FALSE; BoxRec AvailFBArea; + pMga->ScratchBuffer = xalloc(((pScrn->displayWidth * PSZ) + 127) >> 3); + if(!pMga->ScratchBuffer) return FALSE; + pMga->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; @@ -160,19 +590,27 @@ USE_RECTS_FOR_LINES; break; case PCI_CHIP_MGAG400: - pMga->MaxBlitDWORDS = 0x400000 >> 5; + if(pMga->SecondCrtc == TRUE) { + pMga->HasFBitBlt = FALSE; + } + pMga->MaxBlitDWORDS = 0x400000 >> 5; + /* fallthrough */ case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: + doRender = TRUE; pMga->AccelFlags = TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND; - if(pMga->FbMapSize > 8*1024*1024) +#if 1 + if((pMga->FbMapSize > 8*1024*1024) && (pScrn->depth == 8)) pMga->AccelFlags |= LARGE_ADDRESSES; +#endif break; case PCI_CHIP_MGA1064: pMga->AccelFlags = 0; break; case PCI_CHIP_MGAG100: + case PCI_CHIP_MGAG100_PCI: default: pMga->AccelFlags = MGA_NO_PLANEMASK; break; @@ -213,7 +651,6 @@ infoPtr->FillCacheBltRects = MGAFillCacheBltRects; infoPtr->FillCacheBltRectsFlags = NO_TRANSPARENCY; } - /* solid fills */ infoPtr->SetupForSolidFill = MGANAME(SetupForSolidFill); infoPtr->SubsequentSolidFillRect = MGANAME(SubsequentSolidFillRect); @@ -254,28 +691,30 @@ MGANAME(SubsequentMono8x8PatternFillTrap); /* cpu to screen color expansion */ - infoPtr->CPUToScreenColorExpandFillFlags = CPU_TRANSFER_PAD_DWORD | + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | BIT_ORDER_IN_BYTE_LSBFIRST | LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | - SYNC_AFTER_COLOR_EXPAND; + LEFT_EDGE_CLIPPING_NEGATIVE_X; + if(pMga->ILOADBase) { - infoPtr->ColorExpandRange = 0x800000; - infoPtr->ColorExpandBase = pMga->ILOADBase; + pMga->ColorExpandBase = pMga->ILOADBase; } else { - infoPtr->ColorExpandRange = 0x1C00; #ifdef __alpha__ - infoPtr->ColorExpandBase = pMga->IOBaseDense; + pMga->ColorExpandBase = pMga->IOBaseDense; #else - infoPtr->ColorExpandBase = pMga->IOBase; + pMga->ColorExpandBase = pMga->IOBase; #endif } - infoPtr->SetupForCPUToScreenColorExpandFill = - MGANAME(SetupForCPUToScreenColorExpandFill); - infoPtr->SubsequentCPUToScreenColorExpandFill = - MGANAME(SubsequentCPUToScreenColorExpandFill); - + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + MGANAME(SetupForScanlineCPUToScreenColorExpandFill); + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + MGANAME(SubsequentScanlineCPUToScreenColorExpandFill); + infoPtr->SubsequentColorExpandScanline = + MGANAME(SubsequentColorExpandScanline); + infoPtr->NumScanlineColorExpandBuffers = 1; + infoPtr->ScanlineColorExpandBuffers = &(pMga->ColorExpandBase); /* screen to screen color expansion */ if(pMga->AccelFlags & USE_LINEAR_EXPANSION) { @@ -301,37 +740,25 @@ } /* image writes */ - infoPtr->ImageWriteFlags = CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD | - LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | - SYNC_AFTER_IMAGE_WRITE; - - /* if we're write combining */ - infoPtr->ImageWriteFlags |= NO_GXCOPY; - - if(pMga->ILOADBase) { - infoPtr->ImageWriteRange = 0x800000; - infoPtr->ImageWriteBase = pMga->ILOADBase; - } else { - infoPtr->ImageWriteRange = 0x1C00; - infoPtr->ImageWriteBase = pMga->IOBase; - } - infoPtr->SetupForImageWrite = MGANAME(SetupForImageWrite); - infoPtr->SubsequentImageWriteRect = MGANAME(SubsequentImageWriteRect); + infoPtr->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + LEFT_EDGE_CLIPPING | + LEFT_EDGE_CLIPPING_NEGATIVE_X | + NO_TRANSPARENCY | + NO_GXCOPY; + infoPtr->SetupForScanlineImageWrite = + MGANAME(SetupForScanlineImageWrite); + infoPtr->SubsequentScanlineImageWriteRect = + MGANAME(SubsequentScanlineImageWriteRect); + infoPtr->SubsequentImageWriteScanline = + MGANAME(SubsequentImageWriteScanline); + infoPtr->NumScanlineImageWriteBuffers = 1; + infoPtr->ScanlineImageWriteBuffers = &(pMga->ScratchBuffer); + /* midrange replacements */ - if(infoPtr->SetupForCPUToScreenColorExpandFill && - infoPtr->SubsequentCPUToScreenColorExpandFill) { - infoPtr->FillColorExpandRects = MGAFillColorExpandRects; - infoPtr->WriteBitmap = MGAWriteBitmapColorExpand; - infoPtr->TEGlyphRenderer = MGATEGlyphRenderer; - if(BITMAP_SCANLINE_PAD == 32) - infoPtr->NonTEGlyphRenderer = MGANonTEGlyphRenderer; - } - if(pMga->ILOADBase && pMga->UsePCIRetry && infoPtr->SetupForSolidFill) { infoPtr->FillSolidRects = MGAFillSolidRectsDMA; infoPtr->FillSolidSpans = MGAFillSolidSpansDMA; @@ -350,23 +777,18 @@ infoPtr->ValidatePolyPoint = MGAValidatePolyPoint; infoPtr->PolyPointMask = GCFunction | GCPlaneMask; } - if(pMga->AccelFlags & MGA_NO_PLANEMASK) { - infoPtr->ImageWriteFlags |= NO_PLANEMASK; + infoPtr->ScanlineImageWriteFlags |= NO_PLANEMASK; infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK; - infoPtr->CPUToScreenColorExpandFillFlags |= NO_PLANEMASK; - infoPtr->WriteBitmapFlags |= NO_PLANEMASK; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags |= NO_PLANEMASK; infoPtr->SolidFillFlags |= NO_PLANEMASK; infoPtr->SolidLineFlags |= NO_PLANEMASK; infoPtr->DashedLineFlags |= NO_PLANEMASK; infoPtr->Mono8x8PatternFillFlags |= NO_PLANEMASK; - infoPtr->FillColorExpandRectsFlags |= NO_PLANEMASK; infoPtr->ScreenToScreenColorExpandFillFlags |= NO_PLANEMASK; infoPtr->FillSolidRectsFlags |= NO_PLANEMASK; infoPtr->FillSolidSpansFlags |= NO_PLANEMASK; infoPtr->FillMono8x8PatternRectsFlags |= NO_PLANEMASK; - infoPtr->NonTEGlyphRendererFlags |= NO_PLANEMASK; - infoPtr->TEGlyphRendererFlags |= NO_PLANEMASK; infoPtr->FillCacheBltRectsFlags |= NO_PLANEMASK; } @@ -379,7 +801,6 @@ maxlines = (min(pMga->FbUsableSize, 16*1024*1024)) / (pScrn->displayWidth * PSZ / 8); - #ifdef XF86DRI if (pMga->directRenderingEnabled) { if(maxlines > (pMga->numXAALines + pScrn->virtualY)) @@ -398,14 +819,97 @@ AvailFBArea.x2 = pScrn->displayWidth; AvailFBArea.y1 = 0; AvailFBArea.y2 = maxlines; + + /* + * Need to keep a strip of memory to the right of screen to workaround + * a display problem with the second CRTC. + */ + if (pMga->SecondCrtc) + AvailFBArea.x2 = pScrn->virtualX; + xf86InitFBManager(pScreen, &AvailFBArea); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %d lines for offscreen " "memory.\n", maxlines - pScrn->virtualY); + { + Bool shared_accel = FALSE; + int i; + + for(i = 0; i < pScrn->numEntities; i++) { + if(xf86IsEntityShared(pScrn->entityList[i])) + shared_accel = TRUE; + } + if(shared_accel == TRUE) + infoPtr->RestoreAccelState = MGANAME(RestoreAccelState); + } + +#ifdef RENDER + if(doRender && ((pScrn->bitsPerPixel == 32) || (pScrn->bitsPerPixel == 16))) + { + if(pMga->Chipset == PCI_CHIP_MGAG400) { + infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE; + infoPtr->SetupForCPUToScreenAlphaTexture = + MGASetupForCPUToScreenAlphaTexture; + } else { + infoPtr->CPUToScreenAlphaTextureFlags = XAA_RENDER_NO_TILE | + XAA_RENDER_NO_SRC_ALPHA; + infoPtr->SetupForCPUToScreenAlphaTexture = + MGASetupForCPUToScreenAlphaTextureFaked; + } + infoPtr->SubsequentCPUToScreenAlphaTexture = + MGASubsequentCPUToScreenTexture; + infoPtr->CPUToScreenAlphaTextureFormats = MGAAlphaTextureFormats; + + infoPtr->SetupForCPUToScreenTexture = MGASetupForCPUToScreenTexture; + infoPtr->SubsequentCPUToScreenTexture = MGASubsequentCPUToScreenTexture; + infoPtr->CPUToScreenTextureFlags = XAA_RENDER_NO_TILE; + infoPtr->CPUToScreenTextureFormats = MGATextureFormats; + } +#endif + return(XAAInit(pScreen, infoPtr)); } +void +MGANAME(InitSolidFillRectFuncs)(MGAPtr pMga) +{ + pMga->SetupForSolidFill = MGANAME(SetupForSolidFill); + pMga->SubsequentSolidFillRect = MGANAME(SubsequentSolidFillRect); +} + +/* Support for multiscreen */ +void +MGANAME(RestoreAccelState)(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGAFBLayout *pLayout = &pMga->CurrentLayout; + CARD32 tmp; + + MGAStormSync(pScrn); + WAITFIFO(12); + pMga->SrcOrg = 0; + OUTREG(MGAREG_MACCESS, pMga->MAccess); + OUTREG(MGAREG_PITCH, pLayout->displayWidth); + OUTREG(MGAREG_YDSTORG, pMga->YDstOrg); + tmp = pMga->PlaneMask; + pMga->PlaneMask = ~tmp; + SET_PLANEMASK(tmp); + tmp = pMga->BgColor; + pMga->BgColor = ~tmp; + SET_BACKGROUND(tmp); + tmp = pMga->FgColor; + pMga->FgColor = ~tmp; + SET_FOREGROUND(tmp); + OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); + OUTREG(MGAREG_DSTORG, pMga->DstOrg); + OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); + OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ + OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */ + OUTREG(MGAREG_YBOT, 0x007FFFFF); /* maxPixelPointer */ + pMga->AccelFlags &= ~CLIPPER_ON; +} + #if PSZ == 8 CARD32 MGAAtype[16] = { @@ -469,7 +973,8 @@ } } -void MGAStormEngineInit(ScrnInfoPtr pScrn) +void +MGAStormEngineInit(ScrnInfoPtr pScrn) { long maccess = 0; MGAPtr pMga = MGAPTR(pScrn); @@ -477,23 +982,31 @@ CHECK_DMA_QUIESCENT(pMga, pScrn); - if (pMga->Chipset == PCI_CHIP_MGAG100) + if ((pMga->Chipset == PCI_CHIP_MGAG100) + || (pMga->Chipset == PCI_CHIP_MGAG100_PCI)) maccess = 1 << 14; switch( pLayout->bitsPerPixel ) { case 8: + pMga->RestoreAccelState = Mga8RestoreAccelState; break; case 16: maccess |= 1; if(pLayout->depth == 15) maccess |= (1 << 31); + Mga16InitSolidFillRectFuncs(pMga); + pMga->RestoreAccelState = Mga16RestoreAccelState; break; case 24: maccess |= 3; + Mga24InitSolidFillRectFuncs(pMga); + pMga->RestoreAccelState = Mga24RestoreAccelState; break; case 32: maccess |= 2; + Mga32InitSolidFillRectFuncs(pMga); + pMga->RestoreAccelState = Mga32RestoreAccelState; break; } @@ -512,7 +1025,8 @@ OUTREG(MGAREG_MACCESS, maccess); pMga->MAccess = maccess; pMga->PlaneMask = ~0; - if(pMga->Chipset != PCI_CHIP_MGAG100) + /* looks like this doesn't apply to mga g100 pci */ + if (pMga->Chipset != PCI_CHIP_MGAG100) OUTREG(MGAREG_PLNWT, pMga->PlaneMask); pMga->FgColor = 0; OUTREG(MGAREG_FCOL, pMga->FgColor); @@ -530,14 +1044,14 @@ case PCI_CHIP_MGAG400: case PCI_CHIP_MGAG200: case PCI_CHIP_MGAG200_PCI: - pMga->SrcOrg = 0; - pMga->DstOrg = 0; - OUTREG(MGAREG_SRCORG, 0); - OUTREG(MGAREG_DSTORG, 0); + OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); + OUTREG(MGAREG_DSTORG, pMga->DstOrg); break; default: break; } + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + } void MGASetClippingRectangle( @@ -568,7 +1082,6 @@ pMga->AccelFlags &= ~CLIPPER_ON; } - #endif @@ -648,10 +1161,10 @@ if (pMga->AccelFlags & LARGE_ADDRESSES) { WAITFIFO(7); if(DstOrg) - OUTREG(MGAREG_DSTORG, DstOrg << 6); + OUTREG(MGAREG_DSTORG, (DstOrg << 6) + pMga->DstOrg); if(SrcOrg != pMga->SrcOrg) { pMga->SrcOrg = SrcOrg; - OUTREG(MGAREG_SRCORG, SrcOrg << 6); + OUTREG(MGAREG_SRCORG, (SrcOrg << 6) + pMga->realSrcOrg); } if(SrcOrg) { SrcOrg = (SrcOrg << 9) / PSZ; @@ -663,7 +1176,7 @@ OUTREG(MGAREG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff)); OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (dstY << 16) | h); if(DstOrg) - OUTREG(MGAREG_DSTORG, 0); + OUTREG(MGAREG_DSTORG, pMga->DstOrg); } else { WAITFIFO(4); OUTREG(MGAREG_AR0, end); @@ -1013,7 +1526,7 @@ static void -MGANAME(SetupForCPUToScreenColorExpandFill)( +MGANAME(SetupForScanlineCPUToScreenColorExpandFill)( ScrnInfoPtr pScrn, int fg, int bg, int rop, @@ -1054,7 +1567,7 @@ } static void -MGANAME(SubsequentCPUToScreenColorExpandFill)( +MGANAME(SubsequentScanlineCPUToScreenColorExpandFill)( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft @@ -1062,21 +1575,107 @@ MGAPtr pMga = MGAPTR(pScrn); pMga->AccelFlags |= CLIPPER_ON; + pMga->expandDWORDs = (w + 31) >> 5; + if((pMga->expandDWORDs * h) > pMga->MaxBlitDWORDS) { + pMga->expandHeight = pMga->MaxBlitDWORDS / pMga->expandDWORDs; + pMga->expandRemaining = h / pMga->expandHeight; + if(!(h = h % pMga->expandHeight)) { + pMga->expandRemaining--; + h = pMga->expandHeight; + } + pMga->expandY = y + h; + } else + pMga->expandRemaining = 0; + pMga->expandRows = h; + WAITFIFO(5); OUTREG(MGAREG_CXBNDRY, ((x + w - 1) << 16) | ((x + skipleft) & 0xFFFF)); - w = (w + 31) & ~31; /* source is dword padded */ + w = pMga->expandDWORDs << 5; /* source is dword padded */ OUTREG(MGAREG_AR0, (w * h) - 1); OUTREG(MGAREG_AR3, 0); /* crashes occasionally without this */ OUTREG(MGAREG_FXBNDRY, ((x + w - 1) << 16) | (x & 0xFFFF)); OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y << 16) | h); + + if(pMga->expandDWORDs > pMga->FifoSize) { + pMga->AccelInfoRec->SubsequentColorExpandScanline = + MGANAME(SubsequentColorExpandScanlineIndirect); + pMga->AccelInfoRec->ScanlineColorExpandBuffers = + (unsigned char**)(&pMga->ScratchBuffer); + } else { + pMga->AccelInfoRec->SubsequentColorExpandScanline = + MGANAME(SubsequentColorExpandScanline); + pMga->AccelInfoRec->ScanlineColorExpandBuffers = + (unsigned char**)(&pMga->ColorExpandBase); + WAITFIFO(pMga->expandDWORDs); + } +} + +static void +MGANAME(SubsequentColorExpandScanlineIndirect)( + ScrnInfoPtr pScrn, + int bufno +){ + MGAPtr pMga = MGAPTR(pScrn); + int dwords = pMga->expandDWORDs; + CARD32 *src = (CARD32*)(pMga->ScratchBuffer); + + while(dwords > pMga->FifoSize) { + WAITFIFO(pMga->FifoSize); + XAAMoveDWORDS((CARD32*)(pMga->ColorExpandBase), src, pMga->FifoSize); + src += pMga->FifoSize; + dwords -= pMga->FifoSize; + } + + WAITFIFO(dwords); + XAAMoveDWORDS((CARD32*)(pMga->ColorExpandBase), src, dwords); + + if(!(--pMga->expandRows)) { + if(pMga->expandRemaining) { + WAITFIFO(3); + OUTREG(MGAREG_AR0,((pMga->expandDWORDs<< 5)*pMga->expandHeight)-1); + OUTREG(MGAREG_AR3, 0); /* crashes occasionally without this */ + OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (pMga->expandY << 16) | + pMga->expandHeight); + pMga->expandY += pMga->expandHeight; + pMga->expandRows = pMga->expandHeight; + pMga->expandRemaining--; + } else { + DISABLE_CLIP(); + } + } +} + +static void +MGANAME(SubsequentColorExpandScanline)( + ScrnInfoPtr pScrn, + int bufno +){ + MGAPtr pMga = MGAPTR(pScrn); + + if(--pMga->expandRows) { + WAITFIFO(pMga->expandDWORDs); + } else if(pMga->expandRemaining) { + WAITFIFO(3); + OUTREG(MGAREG_AR0,((pMga->expandDWORDs<<5)*pMga->expandHeight)-1); + OUTREG(MGAREG_AR3, 0); /* crashes occasionally without this */ + OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (pMga->expandY << 16) | + pMga->expandHeight); + pMga->expandY += pMga->expandHeight; + pMga->expandRows = pMga->expandHeight; + pMga->expandRemaining--; + WAITFIFO(pMga->expandDWORDs); + } else { + DISABLE_CLIP(); + } } + /*******************\ | Image Writes | \*******************/ -static void MGANAME(SetupForImageWrite)( +static void MGANAME(SetupForScanlineImageWrite)( ScrnInfoPtr pScrn, int rop, unsigned int planemask, @@ -1095,7 +1694,7 @@ } -static void MGANAME(SubsequentImageWriteRect)( +static void MGANAME(SubsequentScanlineImageWriteRect)( ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft @@ -1103,6 +1702,8 @@ MGAPtr pMga = MGAPTR(pScrn); pMga->AccelFlags |= CLIPPER_ON; + pMga->expandRows = h; + pMga->expandDWORDs = ((w * PSZ) + 31) >> 5; WAITFIFO(5); OUTREG(MGAREG_CXBNDRY, 0xFFFF0000 | ((x + skipleft) & 0xFFFF)); @@ -1112,6 +1713,29 @@ OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y << 16) | h); } +static void MGANAME(SubsequentImageWriteScanline)( + ScrnInfoPtr pScrn, + int bufno +){ + MGAPtr pMga = MGAPTR(pScrn); + int dwords = pMga->expandDWORDs; + CARD32 *src = (CARD32*)(pMga->ScratchBuffer); + + while(dwords > pMga->FifoSize) { + WAITFIFO(pMga->FifoSize); + XAAMoveDWORDS((CARD32*)(pMga->ColorExpandBase), src, pMga->FifoSize); + src += pMga->FifoSize; + dwords -= pMga->FifoSize; + } + + WAITFIFO(dwords); + XAAMoveDWORDS((CARD32*)(pMga->ColorExpandBase), src, dwords); + + if(!(--pMga->expandRows)) { + DISABLE_CLIP(); + } +} + /***************************\ | Dashed Lines | @@ -1346,12 +1970,12 @@ WAITFIFO(2); if(DstOrg) { - OUTREG(MGAREG_DSTORG, DstOrg << 6); + OUTREG(MGAREG_DSTORG, (DstOrg << 6) + pMga->DstOrg); resetDstOrg = TRUE; } if(SrcOrg != pMga->SrcOrg) { pMga->SrcOrg = SrcOrg; - OUTREG(MGAREG_SRCORG, SrcOrg << 6); + OUTREG(MGAREG_SRCORG, (SrcOrg << 6) + pMga->realSrcOrg); } } @@ -1402,7 +2026,7 @@ if(resetDstOrg) { WAITFIFO(1); - OUTREG(MGAREG_DSTORG, 0); + OUTREG(MGAREG_DSTORG, pMga->DstOrg); } } @@ -1410,183 +2034,6 @@ #if PSZ == 8 - -static __inline__ CARD32* MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords -) -{ - while(dwords & ~0x03) { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; - dest[3] = src[3]; - src += 4; - dest += 4; - dwords -= 4; - } - - if(!dwords) return(dest); - dest[0] = src[0]; - if(dwords == 1) return(dest+1); - dest[1] = src[1]; - if(dwords == 2) return(dest+2); - dest[2] = src[2]; - return(dest+3); -} - -void -MGAWriteBitmapColorExpand( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int skipleft, - int fg, int bg, - int rop, - unsigned int planemask -) -{ - MGAPtr pMga = MGAPTR(pScrn); - XAAInfoRecPtr infoRec = pMga->AccelInfoRec; - CARD32* destptr = (CARD32*)infoRec->ColorExpandBase; - CARD32* maxptr; - int dwords, maxlines, count; - - CHECK_DMA_QUIESCENT(pMga, pScrn); - - (*infoRec->SetupForCPUToScreenColorExpandFill)( - pScrn, fg, bg, rop, planemask); - - w += skipleft; - x -= skipleft; - dwords = (w + 31) >> 5; - maxlines = pMga->MaxBlitDWORDS / dwords; - maxptr = destptr + infoRec->ColorExpandRange - dwords; - - while(h > maxlines) { - (*infoRec->SubsequentCPUToScreenColorExpandFill) - (pScrn, x, y, w, maxlines, skipleft); - count = maxlines; - while(count--) { - WAITFIFO(dwords); - destptr = MoveDWORDS(destptr, (CARD32*)src, dwords); - src += srcwidth; - if(destptr > maxptr) - destptr = (CARD32*)infoRec->ColorExpandBase; - } - h -= maxlines; - y += maxlines; - } - - (*infoRec->SubsequentCPUToScreenColorExpandFill)( - pScrn, x, y, w, h, skipleft); - - while(h--) { - WAITFIFO(dwords); - destptr = MoveDWORDS(destptr, (CARD32*)src, dwords); - src += srcwidth; - if(destptr > maxptr) - destptr = (CARD32*)infoRec->ColorExpandBase; - } - DISABLE_CLIP(); - SET_SYNC_FLAG(infoRec); -} - - -void -MGAFillColorExpandRects( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - PixmapPtr pPix -){ - MGAPtr pMga = MGAPTR(pScrn); - XAAInfoRecPtr infoRec = pMga->AccelInfoRec; - CARD32 *destptr, *maxptr; - StippleScanlineProcPtr StippleFunc; - unsigned char *src = (unsigned char*)pPix->devPrivate.ptr; - int stipplewidth = pPix->drawable.width; - int stippleheight = pPix->drawable.height; - int srcwidth = pPix->devKind; - int dwords, h, y, maxlines, count, srcx, srcy; - unsigned char *srcp; - - if(stipplewidth <= 32) { - if(stipplewidth & (stipplewidth - 1)) - StippleFunc = XAAStippleScanlineFuncLSBFirst[1]; - else - StippleFunc = XAAStippleScanlineFuncLSBFirst[0]; - } else - StippleFunc = XAAStippleScanlineFuncLSBFirst[2]; - - (*infoRec->SetupForCPUToScreenColorExpandFill)( - pScrn, fg, bg, rop, planemask); - - while(nBox--) { - dwords = (pBox->x2 - pBox->x1 + 31) >> 5; - destptr = (CARD32*)infoRec->ColorExpandBase; - maxptr = destptr + infoRec->ColorExpandRange - dwords; - maxlines = pMga->MaxBlitDWORDS / dwords; - y = pBox->y1; - h = pBox->y2 - y; - - srcy = (pBox->y1 - yorg) % stippleheight; - if(srcy < 0) srcy += stippleheight; - srcx = (pBox->x1 - xorg) % stipplewidth; - if(srcx < 0) srcx += stipplewidth; - - srcp = (srcwidth * srcy) + src; - - while(h > maxlines) { - (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, - pBox->x1, y, pBox->x2 - pBox->x1, maxlines, 0); - count = maxlines; - while(count--) { - WAITFIFO(dwords); - destptr = (*StippleFunc)( - destptr, (CARD32*)srcp, srcx, stipplewidth, dwords); - if(destptr > maxptr) - destptr = (CARD32*)infoRec->ColorExpandBase; - srcy++; - srcp += srcwidth; - if (srcy >= stippleheight) { - srcy = 0; - srcp = src; - } - } - h -= maxlines; - y += maxlines; - } - - (*infoRec->SubsequentCPUToScreenColorExpandFill)(pScrn, - pBox->x1, y , pBox->x2 - pBox->x1, h, 0); - - while(h--) { - WAITFIFO(dwords); - destptr = (*StippleFunc)( - destptr, (CARD32*)srcp, srcx, stipplewidth, dwords); - if(destptr > maxptr) - destptr = (CARD32*)infoRec->ColorExpandBase; - srcy++; - srcp += srcwidth; - if (srcy >= stippleheight) { - srcy = 0; - srcp = src; - } - } - - pBox++; - } - DISABLE_CLIP(); - SET_SYNC_FLAG(infoRec); -} - - void MGAFillSolidRectsDMA( ScrnInfoPtr pScrn, @@ -1739,76 +2186,6 @@ SET_SYNC_FLAG(infoRec); } -void MGANonTEGlyphRenderer( - ScrnInfoPtr pScrn, - int x, int y, int n, - NonTEGlyphPtr glyphs, - BoxPtr pbox, - int fg, int rop, - unsigned int planemask -){ - MGAPtr pMga = MGAPTR(pScrn); - XAAInfoRecPtr infoRec = pMga->AccelInfoRec; - int x1, x2, y1, y2, i, h, skiptop, dwords, maxlines; - unsigned char *src; - - CHECK_DMA_QUIESCENT(pMga, pScrn); - (*infoRec->SetupForCPUToScreenColorExpandFill)( - pScrn, fg, -1, rop, planemask); - WAITFIFO(1); - OUTREG(MGAREG_CXBNDRY, ((pbox->x2 - 1) << 16) | pbox->x1); - pMga->AccelFlags |= CLIPPER_ON; - - for(i = 0; i < n; i++, glyphs++) { - if(!glyphs->srcwidth) continue; - - y1 = y - glyphs->yoff; - y2 = y1 + glyphs->height; - if(y1 < pbox->y1) { - skiptop = pbox->y1 - y1; - y1 = pbox->y1; - } else skiptop = 0; - if(y2 > pbox->y2) y2 = pbox->y2; - - h = y2 - y1; - if(h <= 0) continue; - - src = glyphs->bits + (skiptop * glyphs->srcwidth); - - dwords = glyphs->srcwidth >> 2; /* dwords per line */ - x1 = x + glyphs->start; - x2 = x1 + (dwords << 5); - - maxlines = min(pMga->MaxBlitDWORDS, infoRec->ColorExpandRange); - maxlines /= dwords; - - while(h > maxlines) { - WAITFIFO(4); - OUTREG(MGAREG_AR0, (dwords * maxlines << 5) - 1); - OUTREG(MGAREG_AR3, 0); - OUTREG(MGAREG_FXBNDRY, ((x2 - 1) << 16) | (x1 & 0xFFFF)); - OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y1 << 16) | h); - WAITFIFO(dwords * maxlines); - MoveDWORDS((CARD32*)infoRec->ColorExpandBase, - (CARD32*)src, dwords * maxlines); - src += dwords * maxlines << 2; - h -= maxlines; - y1 += maxlines; - } - - dwords *= h; /* total dwords */ - WAITFIFO(4); - OUTREG(MGAREG_AR0, (dwords << 5) - 1); - OUTREG(MGAREG_AR3, 0); - OUTREG(MGAREG_FXBNDRY, ((x2 - 1) << 16) | (x1 & 0xFFFF)); - OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y1 << 16) | h); - WAITFIFO(dwords); - MoveDWORDS((CARD32*)infoRec->ColorExpandBase, (CARD32*)src, dwords); - } - - DISABLE_CLIP(); - SET_SYNC_FLAG(infoRec); -} void MGAValidatePolyArc( @@ -1818,15 +2195,20 @@ ){ ScrnInfoPtr pScrn = xf86Screens[pGC->pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); + Bool fullPlanemask = TRUE; - if((pMga->AccelFlags & MGA_NO_PLANEMASK) && (pGC->planemask != ~0)) - return; + if((pGC->planemask & pMga->AccelInfoRec->FullPlanemask) != + pMga->AccelInfoRec->FullPlanemask) + { + if(pMga->AccelFlags & MGA_NO_PLANEMASK) return; + fullPlanemask = FALSE; + } if(!pGC->lineWidth && (pGC->fillStyle == FillSolid) && (pGC->lineStyle == LineSolid) && - ((pGC->alu != GXcopy) || (pGC->planemask != ~0) || - (pScrn->bitsPerPixel == 24))) { + ((pGC->alu != GXcopy) || !fullPlanemask)) + { pGC->ops->PolyArc = MGAPolyArcThinSolid; } } @@ -1898,14 +2280,18 @@ ){ ScrnInfoPtr pScrn = xf86Screens[pGC->pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); + Bool fullPlanemask = TRUE; pGC->ops->PolyPoint = XAAFallbackOps.PolyPoint; - if((pMga->AccelFlags & MGA_NO_PLANEMASK) && (pGC->planemask != ~0)) - return; + if((pGC->planemask & pMga->AccelInfoRec->FullPlanemask) != + pMga->AccelInfoRec->FullPlanemask) + { + if(pMga->AccelFlags & MGA_NO_PLANEMASK) return; + fullPlanemask = FALSE; + } - if((pGC->alu != GXcopy) || (pGC->planemask != ~0) || - (pScrn->bitsPerPixel == 24)) + if((pGC->alu != GXcopy) || !fullPlanemask) pGC->ops->PolyPoint = MGAPolyPoint; } @@ -2003,49 +2389,6 @@ SET_SYNC_FLAG(infoRec); } -void -MGATEGlyphRenderer( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft, int startline, - unsigned int **glyphs, int glyphWidth, - int fg, int bg, int rop, unsigned planemask -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - GlyphScanlineFuncPtr GlyphFunc = - XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1]; - MGAPtr pMga = MGAPTR(pScrn); - CARD32* base; - int dwords; - - CHECK_DMA_QUIESCENT(pMga, pScrn); - - (*infoRec->SetupForCPUToScreenColorExpandFill)( - pScrn, fg, bg, rop, planemask); - - w += skipleft; - x -= skipleft; - dwords = (w + 31) >> 5; - - (*infoRec->SubsequentCPUToScreenColorExpandFill)( - pScrn, x, y, w, h, skipleft); - - base = (CARD32*)infoRec->ColorExpandBase; - - if((dwords * h) <= infoRec->ColorExpandRange) - while(h--) { - WAITFIFO(dwords); - base = (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth); - } - else - while(h--) { - WAITFIFO(dwords); - (*GlyphFunc)(base, glyphs, startline++, w, glyphWidth); - } - - DISABLE_CLIP(); - SET_SYNC_FLAG(infoRec); -} - #endif #ifdef XF86DRI @@ -2225,3 +2568,4 @@ } #endif /* XF86DRI */ + Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c:1.15 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c:1.21 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c:1.15 Fri Jun 16 20:03:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c Tue Dec 5 15:03:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.15 2000/06/17 00:03:20 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.21 2000/12/05 20:03:45 mvojkovi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -30,7 +30,7 @@ #define TIMER_MASK (OFF_TIMER | FREE_TIMER) -#define MGA_MAX_PORTS 16 +#define MGA_MAX_PORTS 32 #ifndef XvExtension void MGAInitVideo(ScreenPtr pScreen) {} @@ -55,11 +55,12 @@ static int MGAQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, unsigned short *, int *, int *); -static void MGABlockHandler(int, pointer, pointer, pointer); static void MGAResetVideoOverlay(ScrnInfoPtr); +static void MGAVideoTimerCallback(ScrnInfoPtr pScrn, Time time); + #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) static Atom xvBrightness, xvContrast, xvColorKey; @@ -73,12 +74,12 @@ int num_adaptors; if((pScrn->bitsPerPixel != 8) && !pMga->NoAccel && + (pMga->SecondCrtc == FALSE) && ((pMga->Chipset == PCI_CHIP_MGAG200) || (pMga->Chipset == PCI_CHIP_MGAG200_PCI) || (pMga->Chipset == PCI_CHIP_MGAG400))) { - - if((pMga->Overlay8Plus24 /* || dualhead */ || pMga->TexturedVideo) && + if((pMga->Overlay8Plus24 || pMga->TexturedVideo) && (pScrn->bitsPerPixel != 24)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using texture video\n"); @@ -89,14 +90,9 @@ newAdaptor = MGASetupImageVideoOverlay(pScreen); pMga->TexturedVideo = FALSE; } - - if(!pMga->Overlay8Plus24 /* && !dualhead */) + if(!pMga->Overlay8Plus24) MGAInitOffscreenImages(pScreen); - - pMga->BlockHandler = pScreen->BlockHandler; - pScreen->BlockHandler = MGABlockHandler; } - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); @@ -141,10 +137,9 @@ } }; -#define NUM_FORMATS_OVERLAY 3 -#define NUM_FORMATS_TEXTURE 6 +#define NUM_FORMATS 6 -static XF86VideoFormatRec Formats[NUM_FORMATS_TEXTURE] = +static XF86VideoFormatRec Formats[NUM_FORMATS] = { {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, {15, DirectColor}, {16, DirectColor}, {24, DirectColor} @@ -251,7 +246,7 @@ adapt->name = "Matrox G-Series Backend Scaler"; adapt->nEncodings = 1; adapt->pEncodings = &DummyEncoding[0]; - adapt->nFormats = NUM_FORMATS_OVERLAY; + adapt->nFormats = NUM_FORMATS; adapt->pFormats = Formats; adapt->nPorts = 1; adapt->pAttributes = Attributes; @@ -297,7 +292,7 @@ adapt->name = "Matrox G-Series Texture Engine"; adapt->nEncodings = 1; adapt->pEncodings = &DummyEncoding[1]; - adapt->nFormats = NUM_FORMATS_TEXTURE; + adapt->nFormats = NUM_FORMATS; adapt->pFormats = Formats; adapt->nPorts = MGA_MAX_PORTS; adapt->pAttributes = NULL; @@ -444,7 +439,7 @@ } static void -MGAStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +MGAStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) { MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; @@ -453,12 +448,12 @@ REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - if(exit) { + if(shutdown) { if(pPriv->videoStatus & CLIENT_VIDEO_ON) OUTREG(MGAREG_BESCTL, 0); - if(pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; } pPriv->videoStatus = 0; } else { @@ -597,66 +592,80 @@ int h, int w ){ - CARD32 *dst = (CARD32*)dst1; + CARD32 *dst; + CARD8 *s1, *s2, *s3; int i, j; - dstPitch >>= 2; w >>= 1; for(j = 0; j < h; j++) { - for(i = 0; i < w; i++) { - dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | - (src3[i] << 8) | (src2[i] << 24); - } - dst += dstPitch; - src1 += srcPitch; - if(j & 1) { - src2 += srcPitch2; - src3 += srcPitch2; - } + dst = (CARD32*)dst1; + s1 = src1; s2 = src2; s3 = src3; + i = w; + while(i > 4) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24); + dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24); + dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24); + dst += 4; s2 += 4; s3 += 4; s1 += 8; + i -= 4; + } + + while(i--) { + dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24); + dst++; s2++; s3++; + s1 += 2; + } + + dst1 += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } } } -static FBAreaPtr +static FBLinearPtr MGAAllocateMemory( ScrnInfoPtr pScrn, - FBAreaPtr area, - int numlines + FBLinearPtr linear, + int size ){ ScreenPtr pScreen; - FBAreaPtr new_area; + FBLinearPtr new_linear; - if(area) { - if((area->box.y2 - area->box.y1) >= numlines) - return area; + if(linear) { + if(linear->size >= size) + return linear; - if(xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) - return area; + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; - xf86FreeOffscreenArea(area); + xf86FreeOffscreenLinear(linear); } pScreen = screenInfo.screens[pScrn->scrnIndex]; - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); - if(!new_area) { - int max_w, max_h; + if(!new_linear) { + int max_size; - xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, - FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16, + PRIORITY_EXTREME); - if((max_w < pScrn->displayWidth) || (max_h < numlines)) + if(max_size < size) return NULL; xf86PurgeUnlockedOffscreenAreas(pScreen); - new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - numlines, 0, NULL, NULL, NULL); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); } - return new_area; + return new_linear; } static void @@ -734,7 +743,7 @@ short drw_w, short drw_h ){ MGAPtr pMga = MGAPTR(pScrn); - int log2w, log2h, i, incx, incy, padw, padh; + int log2w = 0, log2h = 0, i, incx, incy, padw, padh; pitch >>= 1; @@ -818,16 +827,16 @@ short drw_w, short drw_h, int id, unsigned char* buf, short width, short height, - Bool sync, + Bool Sync, RegionPtr clipBoxes, pointer data ){ MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; INT32 x1, x2, y1, y2; unsigned char *dst_start; - int pitch, new_h, offset, offset2, offset3; - int srcPitch, srcPitch2, dstPitch; - int top, left, npixels, nlines; + int pitch, new_size, offset, offset2 = 0, offset3 = 0; + int srcPitch, srcPitch2 = 0, dstPitch; + int top, left, npixels, nlines, bpp; BoxRec dstBox; CARD32 tmp; @@ -852,11 +861,12 @@ dstBox.y2 -= pScrn->frameY0; } - pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; + bpp = pScrn->bitsPerPixel >> 3; + pitch = bpp * pScrn->displayWidth; dstPitch = ((width << 1) + 15) & ~15; - new_h = ((dstPitch * height) + pitch - 1) / pitch; - + new_size = ((dstPitch * height) + bpp - 1) / bpp; + switch(id) { case FOURCC_YV12: case FOURCC_I420: @@ -872,26 +882,25 @@ break; } - if(!(pPriv->area = MGAAllocateMemory(pScrn, pPriv->area, new_h))) + if(!(pPriv->linear = MGAAllocateMemory(pScrn, pPriv->linear, new_size))) return BadAlloc; /* copy data */ - top = y1 >> 16; - left = (x1 >> 16) & ~1; - npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; - left <<= 1; + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + left <<= 1; - offset = pPriv->area->box.y1 * pitch; - dst_start = pMga->FbStart + offset + left + (top * dstPitch); + offset = pPriv->linear->offset * bpp; + dst_start = pMga->FbStart + offset + left + (top * dstPitch); - if(pMga->TexturedVideo && pMga->AccelInfoRec->NeedToSync && + if(pMga->TexturedVideo && pMga->AccelInfoRec->NeedToSync && ((long)data != pPriv->lastPort)) - { + { MGAStormSync(pScrn); - pMga->AccelInfoRec->NeedToSync = FALSE; - } + } - switch(id) { + switch(id) { case FOURCC_YV12: case FOURCC_I420: top &= ~1; @@ -940,7 +949,8 @@ x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); pPriv->videoStatus = CLIENT_VIDEO_ON; - } + } + pMga->VideoTimerCallback = MGAVideoTimerCallback; return Success; } @@ -995,48 +1005,37 @@ } static void -MGABlockHandler ( - int i, - pointer blockData, - pointer pTimeout, - pointer pReadmask -){ - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; - MGAPtr pMga = MGAPTR(pScrn); +MGAVideoTimerCallback(ScrnInfoPtr pScrn, Time time) +{ + MGAPtr pMga = MGAPTR(pScrn); MGAPortPrivPtr pPriv = pMga->portPrivate; - pScreen->BlockHandler = pMga->BlockHandler; - - (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); - - pScreen->BlockHandler = MGABlockHandler; - if(pPriv->videoStatus & TIMER_MASK) { - UpdateCurrentTime(); if(pPriv->videoStatus & OFF_TIMER) { - if(pPriv->offTime < currentTime.milliseconds) { + if(pPriv->offTime < time) { OUTREG(MGAREG_BESCTL, 0); pPriv->videoStatus = FREE_TIMER; - pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + pPriv->freeTime = time + FREE_DELAY; } } else { /* FREE_TIMER */ - if(pPriv->freeTime < currentTime.milliseconds) { - if(pPriv->area) { - xf86FreeOffscreenArea(pPriv->area); - pPriv->area = NULL; + if(pPriv->freeTime < time) { + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; } pPriv->videoStatus = 0; + pMga->VideoTimerCallback = NULL; } } - } + } else /* shouldn't get here */ + pMga->VideoTimerCallback = NULL; } /****************** Offscreen stuff ***************/ typedef struct { - FBAreaPtr area; + FBLinearPtr linear; Bool isOn; } OffscreenPrivRec, * OffscreenPrivPtr; @@ -1048,8 +1047,8 @@ unsigned short h, XF86SurfacePtr surface ){ - FBAreaPtr area; - int pitch, fbpitch, numlines; + FBLinearPtr linear; + int pitch, fbpitch, size, bpp; OffscreenPrivPtr pPriv; if((w > 1024) || (h > 1024)) @@ -1057,38 +1056,39 @@ w = (w + 1) & ~1; pitch = ((w << 1) + 15) & ~15; - fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; - numlines = ((pitch * h) + fbpitch - 1) / fbpitch; + bpp = pScrn->bitsPerPixel >> 3; + fbpitch = bpp * pScrn->displayWidth; + size = ((pitch * h) + bpp - 1) / bpp; - if(!(area = MGAAllocateMemory(pScrn, NULL, numlines))) + if(!(linear = MGAAllocateMemory(pScrn, NULL, size))) return BadAlloc; surface->width = w; surface->height = h; if(!(surface->pitches = xalloc(sizeof(int)))) { - xf86FreeOffscreenArea(area); + xf86FreeOffscreenLinear(linear); return BadAlloc; } if(!(surface->offsets = xalloc(sizeof(int)))) { xfree(surface->pitches); - xf86FreeOffscreenArea(area); + xf86FreeOffscreenLinear(linear); return BadAlloc; } if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) { xfree(surface->pitches); xfree(surface->offsets); - xf86FreeOffscreenArea(area); + xf86FreeOffscreenLinear(linear); return BadAlloc; } - pPriv->area = area; + pPriv->linear = linear; pPriv->isOn = FALSE; surface->pScrn = pScrn; surface->id = id; surface->pitches[0] = pitch; - surface->offsets[0] = area->box.y1 * fbpitch; + surface->offsets[0] = linear->offset * bpp; surface->devPrivate.ptr = (pointer)pPriv; return Success; @@ -1118,7 +1118,7 @@ if(pPriv->isOn) MGAStopSurface(surface); - xf86FreeOffscreenArea(pPriv->area); + xf86FreeOffscreenLinear(pPriv->linear); xfree(surface->pitches); xfree(surface->offsets); xfree(surface->devPrivate.ptr); @@ -1199,6 +1199,7 @@ UpdateCurrentTime(); portPriv->videoStatus = FREE_TIMER; portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + pMga->VideoTimerCallback = MGAVideoTimerCallback; } return Success; Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c:1.3 Sat Jun 17 14:23:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c Thu Nov 2 14:10:53 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c,v 1.3 2000/06/17 18:23:23 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c,v 1.5 2000/11/02 19:10:53 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -19,11 +19,10 @@ { MGAPtr pMga = MGAPTR(pScrn); int wmisc; - - CHECK_DMA_QUIESCENT( pMga, pScrn ); + CHECK_DMA_QUIESCENT(pMga, pScrn); WAITFIFO(3); - + switch(pMga->Chipset) { case PCI_CHIP_MGAG400: OUTREG(MGAREG_WIADDR2, WIA_wmode_suspend); @@ -31,41 +30,34 @@ OUTREG(MGAREG_WVRTXSZ, 0x00001807); OUTREG(MGAREG_WACCEPTSEQ, 0x18000000); break; - case PCI_CHIP_MGAG200: -#if 0 case PCI_CHIP_MGAG200_PCI: -#endif OUTREG(MGAREG_WIADDR, WIA_wmode_suspend); OUTREG(MGAREG_WGETMSB, 0x1606); - OUTREG(MGAREG_WVRTXSZ, 7); /* may be set on something else later on*/ + OUTREG(MGAREG_WVRTXSZ, 7); /* may be set on something else later on */ break; - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); return FALSE; } - + WAITFIFO(1); - OUTREG(MGAREG_WMISC, WM_wucodecache_enable | - WM_wmaster_enable | + OUTREG(MGAREG_WMISC, WM_wucodecache_enable | + WM_wmaster_enable | WM_wcacheflush_enable); wmisc = INREG(MGAREG_WMISC); - if(wmisc != (WM_wucodecache_enable | WM_wmaster_enable)) { + if (wmisc != (WM_wucodecache_enable | WM_wmaster_enable)) { FatalError("[mga] WARP engine wrongly configured (%d != %d)." - " Switch off your PC and try again.\n", wmisc, + " Switch off your PC and try again.\n", wmisc, WM_wmaster_enable | WM_wucodecache_enable); } - - return TRUE; + return TRUE; } static unsigned int mgaG400GetMicrocodeSize(MGAPtr pMGA) { #define CODESIZE(which) ((sizeof(which)/256 + 1)*256) - unsigned int microcode_size = 0; - + microcode_size = CODESIZE(WARP_G400_t2gz) + CODESIZE(WARP_G400_t2gza) + CODESIZE(WARP_G400_t2gzaf) + CODESIZE(WARP_G400_t2gzf) + CODESIZE(WARP_G400_t2gzs) + CODESIZE(WARP_G400_t2gzsa) + @@ -76,25 +68,24 @@ CODESIZE(WARP_G400_tgzsaf) + CODESIZE(WARP_G400_tgzsf); microcode_size = ((microcode_size + 4096 - 1) / 4096) * 4096; return(microcode_size); - #undef CODESIZE } static unsigned int mgaG200GetMicrocodeSize(MGAPtr pMGA) { #define CODESIZE(which) ((sizeof(which)/256 + 1)*256) - unsigned int microcode_size; - + microcode_size = CODESIZE(WARP_G200_tgz) + CODESIZE(WARP_G200_tgza) + CODESIZE(WARP_G200_tgzaf) + CODESIZE(WARP_G200_tgzf) + CODESIZE(WARP_G200_tgzs) + CODESIZE(WARP_G200_tgzsa) + CODESIZE(WARP_G200_tgzsaf) + CODESIZE(WARP_G200_tgzsf); microcode_size = ((microcode_size + 4096 - 1) / 4096) * 4096; - return(microcode_size); + return(microcode_size); #undef CODESIZE } + static unsigned int mgaG400InstallMicrocode(MGAPtr pMGA, int agp_offset) { #define mgaWarpInstallCode(which, where) {\ @@ -105,16 +96,15 @@ pcbase += (sizeof(WARP_G400_ ## which) / 256 + 1) * 256; \ vcbase += (sizeof(WARP_G400_ ## which) / 256 + 1) * 256; \ } - MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; CARD8 *vcbase = pMGADRIServer->agp_map + agp_offset; - CARD32 pcbase = (CARD32)pMGADRIServer->agpBase + agp_offset; + unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; unsigned int microcode_size = 0; - memset(pMGADRIServer->WarpIndex, 0, + memset(pMGADRIServer->WarpIndex, 0, sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES); - microcode_size = mgaG400GetMicrocodeSize(pMGA); + microcode_size = mgaG400GetMicrocodeSize(pMGA); mgaWarpInstallCode(tgz, MGA_WARP_TGZ); mgaWarpInstallCode(tgzf, MGA_WARP_TGZF); mgaWarpInstallCode(tgza, MGA_WARP_TGZA); @@ -131,9 +121,7 @@ mgaWarpInstallCode(t2gzsf, MGA_WARP_T2GZSF); mgaWarpInstallCode(t2gzsa, MGA_WARP_T2GZSA); mgaWarpInstallCode(t2gzsaf, MGA_WARP_T2GZSAF); - #undef mgaWarpInstallCode - return microcode_size; } @@ -147,16 +135,15 @@ pcbase += (sizeof(WARP_G200_ ## which) / 256 + 1) * 256; \ vcbase += (sizeof(WARP_G200_ ## which) / 256 + 1) * 256; \ } - MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; CARD8 *vcbase = pMGADRIServer->agp_map + agp_offset; - CARD32 pcbase = (CARD32)pMGADRIServer->agpBase + agp_offset; + unsigned long pcbase = (unsigned long)pMGADRIServer->agpBase + agp_offset; unsigned int microcode_size = 0; - memset(pMGADRIServer->WarpIndex, 0, + memset(pMGADRIServer->WarpIndex, 0, sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES); - microcode_size = mgaG400GetMicrocodeSize(pMGA); + microcode_size = mgaG400GetMicrocodeSize(pMGA); mgaWarpInstallCode(tgz, MGA_WARP_TGZ); mgaWarpInstallCode(tgza, MGA_WARP_TGZA); mgaWarpInstallCode(tgzaf, MGA_WARP_TGZAF); @@ -165,9 +152,7 @@ mgaWarpInstallCode(tgzsa, MGA_WARP_TGZSA); mgaWarpInstallCode(tgzsaf, MGA_WARP_TGZSAF); mgaWarpInstallCode(tgzsf, MGA_WARP_TGZSF); - #undef mgaWarpInstallCode - return microcode_size; } @@ -176,25 +161,18 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); int retval; - + switch(pMGA->Chipset) { case PCI_CHIP_MGAG400: retval = mgaG400GetMicrocodeSize(pMGA); break; case PCI_CHIP_MGAG200: - retval = mgaG200GetMicrocodeSize(pMGA); - break; -#if 0 case PCI_CHIP_MGAG200_PCI: retval = mgaG200GetMicrocodeSize(pMGA); break; -#endif - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); retval = 0; } - return(retval); } @@ -203,26 +181,20 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); int retval; - + switch(pMGA->Chipset) { case PCI_CHIP_MGAG400: retval = mgaG400InstallMicrocode(pMGA, agp_offset); break; case PCI_CHIP_MGAG200: - retval = mgaG200InstallMicrocode(pMGA, agp_offset); - break; -#if 0 case PCI_CHIP_MGAG200_PCI: - retval = mgaG200InstallMicrocode(pMGA); + retval = mgaG200InstallMicrocode(pMGA, agp_offset); break; -#endif - default: - ErrorF("Only Matrox G200 and G400 work correctly under the DRI\n"); retval = 0; } - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "WARP Microcode Loaded\n"); - + + if (retval) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "WARP Microcode Loaded\n"); return retval; } Index: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c diff -u xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c:1.1 Fri Jun 16 20:03:20 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c Sun Sep 24 09:51:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c,v 1.1 2000/06/17 00:03:20 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c,v 1.2 2000/09/24 13:51:28 alanh Exp $ */ /************************************************************************** Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -65,6 +65,7 @@ pointer pReadmask) { ScreenPtr pScreen = screenInfo.screens[screenNum]; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/ if (0) ErrorF("MGAWakeupHandler (in)\n"); @@ -73,8 +74,10 @@ * to restore state. */ DRILock(pScreen, 0); - MGASwapContext( pScreen ); - + if (xf86IsEntityShared(pScrn->entityList[0])) + MGASwapContext_shared(pScreen); + else + MGASwapContext(pScreen); } static void MGABlockHandler(int screenNum, @@ -84,6 +87,8 @@ { ScreenPtr pScreen = screenInfo.screens[screenNum]; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/ MGASAREAPtr sa = (MGASAREAPtr)DRIGetSAREAPrivate( pScreen ); @@ -177,6 +182,12 @@ } finished: + if (xf86IsEntityShared(pScrn->entityList[0])) { + /* Restore to first screen */ + pMga->RestoreAccelState(pScrn); + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + } + DRIUnlock(pScreen); } Index: xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/binding.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/binding.h:1.5 --- /dev/null Mon Dec 18 14:30:53 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/binding.h Wed Dec 6 15:39:52 2000 @@ -0,0 +1,253 @@ +/************************************************************************************** + + @doc MGA MGA_STRUCT + + @module MGA Structures | Structure of The MGA Layer + @normal Copyright © 1997, Matrox Graphics Inc. + + All Rights Reserved. + + @head3 MGA Structures | + @index struct | MGA_STRUCT + + @end + +***************************************************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/binding.h,v 1.5 2000/12/06 20:39:52 dawes Exp $ */ + +#ifndef _BINDING +#define _BINDING + +#ifndef _INTERNALBINDING + +#define BINDING_NOERROR 0x00000000 +#define BINDING_ERROR 0x90000000 +#define FAR +#define DECL + +typedef void VOID; +typedef void FAR *LPVOID; +typedef void FAR *LPBOARDHANDLE; + +typedef long LONG; +typedef unsigned long ULONG; +typedef unsigned long FLONG; +typedef unsigned long FAR *LPULONG; + +typedef char CHAR; +typedef unsigned char UCHAR; +typedef unsigned char FAR*LPUCHAR; + +typedef struct TAGCLIENTTABLE{ + ULONG (DECL *ClientReadConfigSpaceByte )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientReadConfigSpaceDword )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientWriteConfigSpaceByte )(LPVOID , ULONG, UCHAR); + ULONG (DECL *ClientWriteConfigSpaceDword )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientOpenRegisterBase )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientCloseRegisterBase )(LPVOID ); + ULONG (DECL *ClientReadRegisterByte )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientReadRegisterDword )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientWriteRegisterByte )(LPVOID , ULONG, UCHAR); + ULONG (DECL *ClientWriteRegisterDword )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientOpenMemoryBase )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientCloseMemoryBase )(LPVOID ); + ULONG (DECL *ClientReadMemoryByte )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientReadMemoryDword )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientWriteMemoryByte )(LPVOID , ULONG, UCHAR); + ULONG (DECL *ClientWriteMemoryDword )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientOpenSystemDevice )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientCloseSystemDevice )(LPVOID ); + ULONG (DECL *ClientReadSystemDeviceByte )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientReadSystemDeviceDword )(LPVOID , ULONG, LPVOID ); + ULONG (DECL *ClientWriteSystemDeviceByte )(LPVOID , ULONG, UCHAR); + ULONG (DECL *ClientWriteSystemDeviceDword )(LPVOID , ULONG, ULONG); + ULONG (DECL *ClientWait )(LPVOID , ULONG); + ULONG (DECL *ClientGetBiosInfo ) (LPVOID, LPVOID, LPVOID); + ULONG (DECL *ClientReadDDCEdid ) (LPVOID, LPVOID, ULONG); +#ifdef DEBUG + ULONG (DECL *ClientDebug ) (LPVOID, ULONG, LPVOID, ULONG, LPVOID); +#endif +} CLIENTTABLE, FAR *LPCLIENTTABLE; + +#endif /* _INTERNALBINDING */ + +/*************************************************************************************************** + MGAHWINFO STRUCTURE + *************************************************************************************************** + @struct MGAHWINFO | Public MGA Board Information + @field OUT ULONG | ulCapsFirstOutput | Capabilities of firts output + @flag Bit 0 | Analog output supported on primary CRTC + @flag Bit 1 | Digital output supported on primary CRTC + @flag Bit 2 | TV output supported on primary CRTC + @flag Bit 3 | Analog output supported on second CRTC + @flag Bit 4 | Digital output supported on second CRTC + @flag Bit 5 | TV output supported on second CRTC + @flag Bit 6 | VGA output supported + @field OUT ULONG | ulCapsSecondOutput | Capabilities of second output + @flag Bit 0 | Analog output supported on primary CRTC + @flag Bit 1 | Digital output supported on primary CRTC + @flag Bit 2 | TV output supported on primary CRTC + @flag Bit 3 | Analog output supported on second CRTC + @flag Bit 4 | Digital output supported on second CRTC + @flag Bit 5 | TV output supported on second CRTC + @flag Bit 6 | VGA output supported + @field OUT ULONG | ulVideoMemory | Total number of video memory in bytes + @end + **************************************************************************************************/ +typedef struct TAGMGAHWINFO { + ULONG ulCapsFirstOutput; + ULONG ulCapsSecondOutput; + ULONG ulVideoMemory; +} MGAHWINFO, FAR *LPMGAHWINFO; + +/*************************************************************************************************** + MGAMODEINFO STRUCTURE + *************************************************************************************************** + @struct MGAMODEINFO | Mode Information + @field IN FLONG | flOutput | Where we want to apply this parameters + @flag Bit 0 | Use second CRTC + @flag Bit 1 | Use primary analog output + @flag Bit 2 | Use secondary analog output + @flag Bit 3 | Use primary digital output + @flag Bit 4 | Use secondary digital output + @flag Bit 5 | Force a particular frame buffer pitch + @flag Bit 6 | Force a particular display origin + @flag Bit 7-31 | Reserved + @field IN ULONG | ulDispWidth | Display Width in pixels + @field IN ULONG | ulDispHeight | Display Height in pixels + @field IN ULONG | ulDeskWidth | Desktop Width in pixels + @field IN ULONG | ulDeskHeight | Desktop Height in pixels + @field IN OUT ULONG | ulFBPitch | Frame Buffer Pitch in pixel + @field IN ULONG | ulBpp | Bits Per Pixels and input format + @flag lower 16 bit | Bits per pixel + <nl><tab> 8, 15, 16, 24 or 32 + @flag upper 16 bit | Input format + <nl><tab> 0 RGB + <nl><tab> 1 RGBA + <nl><tab> 2 YcbCr 4:2:0 3 Planes + <nl><tab> 3 YcbCr 4:2:0 4 Planes + <nl><tab> 4 YcbCr 4:2:2-UYVY + <nl><tab> 5 YcbCr 4:2:2-YUY2 + <nl><tab> 6-10 none interleave mode + <nl><tab> 6 NI RGBA + <nl><tab> 7 NI YcbCr 4:2:0 3 Planes + <nl><tab> 8 NI YcbCr 4:2:0 4 Planes + <nl><tab> 9 NI YcbCr 4:2:2-UYVY + <nl><tab> 10 NI YcbCr 4:2:2-YUY2 + @field IN ULONG | ulZoom | Zoom factor + @flag 1x (1), 2x (2) or 4x (4)| + @field IN OUT FLONG | flSignalMode | Signal Mode + @flag Bit 0 | Interlace (0 : Non-interlace / 1: Interlace) + @flag Bit 1 | Overscan (0 : No Overscan / 1 : Overscan) + @flag Bit 2 | Horizontal Sync Polarity (0 : Negative / 1 : Positive) + @flag Bit 3 | Vertical Sync Polarity (0 : Negative / 1 : Positive) + @flag Bit 4-7 | Standard TV output + <nl><tab>000 - PAL B G H + <nl><tab>001 - NTSC M + <nl><tab>010..111 - Reserved + @flag Bit 8-31 | Reserved for future use + @field IN OUT ULONG | ulRefreshRate | Vertical Refresh Rate in Hz + @field IN OUT ULONG | ulHorizRate | Horizontal Refresh Rate in KHz + @field IN OUT ULONG | ulPixClock | Pixel Clock in kHz + @field IN OUT ULONG | ulHFPorch | Horizontal front porch in pixels + @field IN OUT ULONG | ulHSync | Horizontal Sync in pixels + @field IN OUT ULONG | ulHBPorch | Horizontal back porch in pixels + @field IN OUT ULONG | ulVFPorch | Vertical front porch in lines + @field IN OUT ULONG | ulVSync | Vertical Sync in lines + @field IN OUT ULONG | ulVBPorch | Vertical back Porch in lines + @field IN OUT ULONG | ulDisplayOrg | Origin of the display Offset(pixels) + @field IN OUT ULONG | ulDstOrg | Origin of the drawing Offset in the frame (pixels) + @field IN OUT ULONG | ulPanXGran | Panning in X granularity in pixel + @field IN OUT ULONG | ulPanYGran | Panning in Y granularity in pixel + @field IN OUT ULONG | ulTVStandard | TV Standard + @field IN OUT ULONG | ulCableType | Cable Type + @end + **************************************************************************************************/ +typedef struct TAGMAGMODEINFO { + FLONG flOutput; /* Where we want to apply this parameters */ + ULONG ulDispWidth; /* Display Width in pixels */ + ULONG ulDispHeight; /* Display Height in pixels */ + ULONG ulDeskWidth; /* Desktop Width in pixels */ + ULONG ulDeskHeight; /* Desktop Height in pixels */ + ULONG ulFBPitch; /* Frame Buffer Pitch in pixel */ + ULONG ulBpp; /* Bits Per Pixels / input format */ + ULONG ulZoom; /* Zoom factor */ + FLONG flSignalMode; /* Signal Mode */ + ULONG ulRefreshRate; /* Vertical Refresh Rate in Hz */ + ULONG ulHorizRate; /* Horizontal Refresh Rate in KHz */ + ULONG ulPixClock; /* Pixel Clock in kHz */ + ULONG ulHFPorch; /* Horizontal front porch in pixels */ + ULONG ulHSync; /* Horizontal Sync in pixels */ + ULONG ulHBPorch; /* Horizontal back porch in pixels */ + ULONG ulVFPorch; /* Vertical front porch in lines */ + ULONG ulVSync; /* Vertical Sync in lines */ + ULONG ulVBPorch; /* Vertical back Porch in lines */ + ULONG ulDisplayOrg; /* Origin of the display Offset(bytes) */ + ULONG ulDstOrg; /* Origin of the drawing Offset in the frame (bytes) */ + ULONG ulPanXGran; /* Panning in X granularity in pixel */ + ULONG ulPanYGran; /* Panning in Y granularity in pixel */ + ULONG ulTVStandard; /* TV Standard */ + ULONG ulCableType; /* Cable Type */ +} MGAMODEINFO, FAR *LPMGAMODEINFO; + +#define MGAHWINFOCAPS_CRTC1_ANALOG 1L +#define MGAHWINFOCAPS_CRTC1_DIGITAL (1L << 1) +#define MGAHWINFOCAPS_CRTC1_TV (1L << 2) +#define MGAHWINFOCAPS_CRTC2_ANALOG (1L << 3) +#define MGAHWINFOCAPS_CRTC2_DIGITAL (1L << 4) +#define MGAHWINFOCAPS_CRTC2_TV (1L << 5) +#define MGAHWINFOCAPS_OUTPUT_VGA (1L << 6) +#define MGAHWINFOCAPS_CRTC2 (MGAHWINFOCAPS_CRTC2_ANALOG | MGAHWINFOCAPS_CRTC2_DIGITAL | MGAHWINFOCAPS_CRTC2_TV) +#define MGAHWINFOCAPS_OUTPUT_ANALOG (MGAHWINFOCAPS_CRTC1_ANALOG | MGAHWINFOCAPS_CRTC2_ANALOG) +#define MGAHWINFOCAPS_OUTPUT_DIGITAL (MGAHWINFOCAPS_CRTC1_DIGITAL | MGAHWINFOCAPS_CRTC2_DIGITAL) +#define MGAHWINFOCAPS_OUTPUT_TV (MGAHWINFOCAPS_CRTC1_TV | MGAHWINFOCAPS_CRTC2_TV) + +#define MGAMODEINFO_SECOND_CRTC 1L +#define MGAMODEINFO_ANALOG1 (1L << 1) +#define MGAMODEINFO_ANALOG2 (1L << 2) +#define MGAMODEINFO_DIGITAL1 (1L << 3) +#define MGAMODEINFO_DIGITAL2 (1L << 4) +#define MGAMODEINFO_FORCE_PITCH (1L << 5) +#define MGAMODEINFO_FORCE_DISPLAYORG (1L << 6) +#define MGAMODEINFO_TV (1L << 7) +#define MGAMODEINFO_TESTONLY 0x80000000 + +/* Cable Type */ +#define TV_YC_COMPOSITE 0 +#define TV_SCART_RGB 1 +#define TV_SCART_COMPOSITE 2 +#define TV_SCART_TYPE2 3 + +/* TV Standard */ + +#define TV_PAL 0 +#define TV_NTSC 1 + +#if defined(__cplusplus) + extern "C" { +#endif + +ULONG MGACloseLibrary(LPBOARDHANDLE pBoard); +ULONG MGAValidateMode(LPBOARDHANDLE pBoard, LPMGAMODEINFO pMgaModeInfo); +ULONG MGAValidateVideoParameters(LPBOARDHANDLE pBoard, LPMGAMODEINFO pMgaModeInfo); +ULONG MGASetMode(LPBOARDHANDLE pBoard, LPMGAMODEINFO pMgaModeInfo); +ULONG MGASetTVMode(LPBOARDHANDLE pBoard, LPMGAMODEINFO pMgaModeInfo); +ULONG MGASetVgaMode(LPBOARDHANDLE pBoard); +ULONG MGASaveVgaState(LPBOARDHANDLE pBoard); +ULONG MGARestoreVgaState(LPBOARDHANDLE pBoard); +ULONG MGAInitHardware(LPBOARDHANDLE pBoard); +ULONG MGAGetVideoParameters(LPBOARDHANDLE pBoard, LPMGAMODEINFO pMgaModeInfo, ULONG ulRefresh); +ULONG MGAGetHardwareInfo(LPBOARDHANDLE pBoard, LPMGAHWINFO pMgaHwInfo); +LPVOID MGAGetClientPointer(LPBOARDHANDLE pBoard); +ULONG MGAOpenLibrary(LPBOARDHANDLE pBoard, LPVOID lpClient, ULONG ulClientSize); +ULONG MGAGetBOARDHANDLESize(void); +ULONG MGASetTVStandard(LPBOARDHANDLE pBoard, ULONG ulTVStandard); +ULONG MGASetTVCableType(LPBOARDHANDLE pBoard, ULONG ulCableType); + +#if defined(__cplusplus) + } +#endif + +#endif /* _BINDING */ + + Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile:1.7 xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile:1.10 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile:1.7 Fri Jun 30 13:15:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile Fri Nov 3 13:46:11 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.7 2000/06/30 17:15:12 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.10 2000/11/03 18:46:11 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -16,12 +16,13 @@ #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(XF86SRC)/vgafb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \ - -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \ + -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb -I$(SERVERSRC)/mfb \ + -I$(SERVERSRC)/miext/shadow \ -I$(XINCLUDESRC) -I$(XF86SRC)/xaa -I$(FONTINCSRC) \ -I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \ -I$(XF86SRC)/i2c -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xf24_32bpp \ - -I$(SERVERSRC)/Xext \ - -I$(XF86SRC)/int10 -I$(XF86OSSRC)/vbe + -I$(SERVERSRC)/Xext -I$(EXTINCSRC) \ + -I$(XF86SRC)/int10 -I$(XF86OSSRC)/vbe -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h:1.11 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h:1.11 Fri Jun 30 13:15:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h Fri Nov 3 13:46:11 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.11 2000/06/30 17:15:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.17 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -48,6 +48,8 @@ #include "xaalocal.h" /* XAA internals as we replace some of XAA */ #include "xf86Cursor.h" +#include "shadowfb.h" + #include "vbe.h" /* Drivers that need to access the PCI config space directly need this */ @@ -69,6 +71,7 @@ NM2097, NM2160, NM2200, + NM2230, NM2360, NM2380 } NEOType; @@ -104,6 +107,7 @@ extern Bool neo_I2CInit(ScrnInfoPtr pScrn); /* in neo_shadow.c */ +void neoShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage); void neoPointerMoved(int index, int x, int y); void neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void neoRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); @@ -111,6 +115,9 @@ void neoRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void neoRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +/* in neo_dga.c */ +Bool NEODGAInit(ScreenPtr pScreen); + /* shadow regs */ #define NEO_EXT_CR_MAX 0x85 @@ -130,6 +137,7 @@ unsigned char ExtColorModeSelect; unsigned char SingleAddrPage; unsigned char DualAddrPage; + unsigned char biosMode; unsigned char PanelDispCntlReg1; unsigned char PanelDispCntlReg2; unsigned char PanelDispCntlReg3; @@ -155,6 +163,7 @@ /* Hardware cursor address */ unsigned int CursorAddress; Bool UseHWCursor; + Bool NoCursorMode; unsigned char CursTemp[1024]; /* Boundaries of the pixmap cache */ unsigned int cacheStart; @@ -167,6 +176,11 @@ unsigned int Pitch; unsigned int PixelWidth; unsigned int PlaneMask; + int CPUToScreenColorExpandFill_x; + int CPUToScreenColorExpandFill_y; + int CPUToScreenColorExpandFill_w; + int CPUToScreenColorExpandFill_h; + int CPUToScreenColorExpandFill_skipleft; } NEOACLRec, *NEOACLPtr; #define NEOACLPTR(p) &((NEOPtr)((p)->driverPrivate))->Accel @@ -179,12 +193,12 @@ EntityInfoPtr pEnt; XAAInfoRecPtr AccelInfoRec; NEOACLRec Accel; - unsigned int NeoMMIOAddr; - unsigned int NeoLinearAddr; + unsigned long NeoMMIOAddr; + unsigned long NeoLinearAddr; unsigned char* NeoMMIOBase; unsigned char* NeoFbBase; long NeoFbMapSize; - unsigned int vgaIOBase; + unsigned long vgaIOBase; DGAModePtr DGAModes; int numDGAModes; Bool DGAactive; @@ -217,7 +231,7 @@ Bool onPciBurst; Bool progLcdRegs; Bool progLcdStretch; - Bool progLcdStrechOpt; + Bool progLcdStretchOpt; Bool overrideValidate; /* registers */ NeoRegRec NeoModeReg; @@ -228,10 +242,17 @@ vbeInfoPtr pVbe; unsigned char * ShadowPtr; int ShadowPitch; + RefreshAreaFuncPtr refreshArea; void (*PointerMoved)(int index, int x, int y); int rotate; } NEORec, *NEOPtr; +typedef struct { + int x_res; + int y_res; + int mode; +} biosMode; + /* The privates of the NEO driver */ #define NEOPTR(p) ((NEOPtr)((p)->driverPrivate)) @@ -245,12 +266,12 @@ #define VGAwGR(index,val) hwp->writeGr(hwp,index,val) /* memory mapped register access macros */ -#define INREG8(addr) *(volatile CARD8 *)(nPtr->NeoMMIOBase + (addr)) -#define INREG16(addr) *(volatile CARD16 *)(nPtr->NeoMMIOBase + (addr)) -#define INREG(addr) *(volatile CARD32 *)(nPtr->NeoMMIOBase + (addr)) -#define OUTREG8(addr, val) *(volatile CARD8 *)(nPtr->NeoMMIOBase + (addr)) = (val) -#define OUTREG16(addr, val) *(volatile CARD16 *)(nPtr->NeoMMIOBase + (addr)) = (val) -#define OUTREG(addr, val) *(volatile CARD32 *)(nPtr->NeoMMIOBase + (addr)) = (val) +#define INREG8(addr) MMIO_IN8(nPtr->NeoMMIOBase, (addr)) +#define INREG16(addr) MMIO_IN16(nPtr->NeoMMIOBase, (addr)) +#define INREG(addr) MMIO_IN32(nPtr->NeoMMIOBase, (addr)) +#define OUTREG8(addr, val) MMIO_OUT8(nPtr->NeoMMIOBase, (addr), (val)) +#define OUTREG16(addr, val) MMIO_OUT16(nPtr->NeoMMIOBase, (addr), (val)) +#define OUTREG(addr, val) MMIO_OUT32(nPtr->NeoMMIOBase, (addr), (val)) /* This swizzle macro is to support the manipulation of cursor masks when * the sprite moves off the left edge of the display. This code is Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c:1.2 Sun Jun 27 10:08:08 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c Mon Sep 25 19:57:08 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c,v 1.2 1999/06/27 14:08:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c,v 1.3 2000/09/25 23:57:08 mvojkovi Exp $ */ /* * The original Precision Insight driver for @@ -105,6 +105,7 @@ NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); BoxRec AvailFBArea; + int lines; nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; @@ -112,8 +113,8 @@ /* * Set up the main acceleration flags. */ - infoPtr->Flags |= LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; - if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags = PIXMAP_CACHE; + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; + if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags |= PIXMAP_CACHE; #if 0 infoPtr->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES; #endif @@ -160,13 +161,19 @@ /* Initialize for widths */ nAcl->Pitch = pScrn->displayWidth * nAcl->PixelWidth; + lines = nAcl->cacheEnd / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + if(lines > 1024) lines = 1024; AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = nAcl->cacheEnd / - (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + AvailFBArea.y2 = lines; xf86InitFBManager(pScreen, &AvailFBArea); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %i scanlines of offscreen memory for pixmap caching\n", + lines - pScrn->virtualY); return(XAAInit(pScreen, infoPtr)); Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c:1.2 Sun Jun 27 10:08:08 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c Mon Sep 25 19:57:08 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c,v 1.2 1999/06/27 14:08:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c,v 1.4 2000/09/25 23:57:08 mvojkovi Exp $ */ /* * The original Precision Insight driver for @@ -40,6 +40,7 @@ #include "xf86_OSproc.h" #include "xf86_ansic.h" #include "compiler.h" +#include "xf86PciInfo.h" /* Drivers that use XAA need this */ #include "xf86fbman.h" @@ -81,16 +82,17 @@ unsigned int planemask); static void Neo2090SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h); -#ifdef colorexpandfill -static void Neo2090SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2093SetupForScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); -static void Neo2093SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2093SubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); -#endif +static void Neo2093SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); Bool Neo2090AccelInit(ScreenPtr pScreen) @@ -100,6 +102,7 @@ NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); BoxRec AvailFBArea; + int lines; nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; @@ -107,8 +110,8 @@ /* * Set up the main acceleration flags. */ - infoPtr->Flags |= LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; - if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags = PIXMAP_CACHE; + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; + if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags |= PIXMAP_CACHE; #if 0 infoPtr->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES; #endif @@ -128,29 +131,34 @@ Neo2090SetupForSolidFillRect; infoPtr->SubsequentSolidFillRect = Neo2090SubsequentSolidFillRect; -#ifdef colorexpandfill - /* We need byte scanline padding before we can use this - * or does anyone know how to switch the chip to dword - * padding? if we could do right edge clipping this would - * help also. Left edge clipping cannot be used since it - * allows only clipping of up to 8 pixels :-(( - */ /*§§§*/ - if (NeoChipset == PCI_CHIP_NM2093) { + + if (nPtr->NeoChipset == PCI_CHIP_NM2093) { + /* + * We do CPUToScreenColorExpand (ab)using the Scanline functions: + * the neo chipsets need byte padding however we can only do dword + * padding. Fortunately the graphics engine doesn't choke if we + * transfer up to 3 bytes more than it wants. + */ + /* cpu to screen color expansion */ - infoPtr->CPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | - SCANLINE_PAD_BYTE | - CPU_TRANSFER_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST ); - infoPtr->ColorExpandBase = + infoPtr->ScanlineColorExpandBuffers = + (unsigned char **)xnfalloc(sizeof(char*)); + infoPtr->ScanlineColorExpandBuffers[0] = (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); - infoPtr->ColorExpandRange = 0x100000; + infoPtr->NumScanlineColorExpandBuffers = 1; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | + SCANLINE_PAD_DWORD | + CPU_TRANSFER_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST ); - infoPtr->SetupForCPUToScreenColorExpandFill = - Neo2093SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Neo2093SubsequentCPUToScreenColorExpandFill; + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + Neo2093SetupForScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + Neo2093SubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = + Neo2093SubsequentColorExpandScanline; } -#endif + /* * Setup some global variables */ @@ -189,15 +197,21 @@ nAcl->BltCntlFlags |= NEO_BC3_FIFO_EN; + lines = nAcl->cacheEnd / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + if(lines > 1024) lines = 1024; + AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = nAcl->cacheEnd / - (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + AvailFBArea.y2 = lines; xf86InitFBManager(pScreen, &AvailFBArea); - return(XAAInit(pScreen, infoPtr)); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %i scanlines of offscreen memory for pixmap caching\n", + lines - pScrn->virtualY); + return(XAAInit(pScreen, infoPtr)); } static void @@ -289,9 +303,9 @@ } -#ifdef colorexpandfill static void -Neo2093SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, +Neo2093SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, unsigned int planemask) { @@ -325,19 +339,44 @@ } static void -Neo2093SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +Neo2093SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) { NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + nAcl->CPUToScreenColorExpandFill_x = x; + nAcl->CPUToScreenColorExpandFill_y = y; + nAcl->CPUToScreenColorExpandFill_w = w; + nAcl->CPUToScreenColorExpandFill_h = h; + nAcl->CPUToScreenColorExpandFill_skipleft = skipleft; WAIT_FIFO(4); OUTREG(NEOREG_SRCBITOFF, skipleft); OUTREG(NEOREG_SRCSTARTOFF, 0); OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff)); - OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); + OUTREG(NEOREG_XYEXT, (1<<16) | (w & 0xffff)); } -#endif + +static void +Neo2093SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + if (!(--nAcl->CPUToScreenColorExpandFill_h)) + return; + + WAIT_FIFO(4); + OUTREG(NEOREG_SRCBITOFF, nAcl->CPUToScreenColorExpandFill_skipleft); + OUTREG(NEOREG_SRCSTARTOFF, 0); + OUTREG(NEOREG_DSTSTARTOFF, ((++nAcl->CPUToScreenColorExpandFill_y)<<16) + | (nAcl->CPUToScreenColorExpandFill_x & 0xffff)); + OUTREG(NEOREG_XYEXT, (1<<16) + | (nAcl->CPUToScreenColorExpandFill_w & 0xffff)); +} + Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c:1.2 Sun Jun 27 10:08:08 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c Fri Oct 6 08:31:02 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c,v 1.2 1999/06/27 14:08:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c,v 1.7 2000/10/06 12:31:02 eich Exp $ */ /* * The original Precision Insight driver for @@ -66,16 +66,17 @@ unsigned int planemask); static void Neo2097SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h); -#ifdef colorexpandfill -static void Neo2097SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2097SetupScanlineForCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); -static void Neo2097SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2097SubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); -#endif +static void Neo2097SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); static void Neo2097SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, @@ -86,6 +87,12 @@ int patterny, int x, int y, int w, int h); +static void Neo2097SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, + unsigned int planemask, + int transparency_color, int bpp, int depth); +static void Neo2097SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, + int x, int y, int w, int h, int skipleft); +static void Neo2097SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int num); @@ -116,6 +123,7 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); + int lines; BoxRec AvailFBArea; nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec(); @@ -124,11 +132,11 @@ /* * Set up the main acceleration flags. */ - infoPtr->Flags |= LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; - if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags = PIXMAP_CACHE; -#if 0 - infoPtr->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES; -#endif + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; + if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags |= PIXMAP_CACHE; + + infoPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; + /* sync */ infoPtr->Sync = Neo2097Sync; @@ -146,37 +154,58 @@ infoPtr->SubsequentSolidFillRect = Neo2097SubsequentSolidFillRect; -#ifdef colorexpandfill - /* We need byte scanline padding before we can use this - * or does anyone know how to switch the chip to dword - * padding? if we could do right edge clipping this would - * help also. Left edge clipping cannot be used since it - * allows only clipping of up to 8 pixels :-(( - */ /*§§§*/ - /* cpu to screen color expansion */ - infoPtr->CPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | - CPU_TRANSFER_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST ); - infoPtr->ColorExpandBase = - (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); - infoPtr->ColorExpandRange = 0x100000; - - infoPtr->SetupForCPUToScreenColorExpandFill = - Neo2097SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Neo2097SubsequentCPUToScreenColorExpandFill; + /* + * We do CPUToScreenColorExpand (ab)using the Scanline functions: + * the neo chipsets need byte padding however we can only do dword + * padding. Fortunately the graphics engine doesn't choke if we + * transfer up to 3 bytes more than it wants. + */ + infoPtr->ScanlineColorExpandBuffers = + (unsigned char **)xnfalloc(sizeof(char*)); + infoPtr->ScanlineColorExpandBuffers[0] = (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); + infoPtr->NumScanlineColorExpandBuffers = 1; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | +#ifdef NEO_DO_CLIPPING + LEFT_EDGE_CLIPPING | #endif + CPU_TRANSFER_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST ); + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + Neo2097SetupScanlineForCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + Neo2097SubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = + Neo2097SubsequentColorExpandScanline; + +#if 0 /* 8x8 pattern fills */ infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_ORIGIN - |BIT_ORDER_IN_BYTE_MSBFIRST; + | BIT_ORDER_IN_BYTE_MSBFIRST; infoPtr->SetupForMono8x8PatternFill = Neo2097SetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = Neo2097SubsequentMono8x8PatternFill; +#endif + + /* image writes */ + infoPtr->ScanlineImageWriteFlags = CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + NO_TRANSPARENCY | + NO_PLANEMASK; + + infoPtr->SetupForScanlineImageWrite = + Neo2097SetupForScanlineImageWrite; + infoPtr->SubsequentScanlineImageWriteRect = + Neo2097SubsequentScanlineImageWriteRect; + infoPtr->SubsequentImageWriteScanline = + Neo2097SubsequentImageWriteScanline; + infoPtr->NumScanlineImageWriteBuffers = 1; + infoPtr->ScanlineImageWriteBuffers = infoPtr->ScanlineColorExpandBuffers; + /* * Setup some global variables */ @@ -213,15 +242,21 @@ return FALSE; } + lines = nAcl->cacheEnd / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + if(lines > 1024) lines = 1024; + AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = nAcl->cacheEnd / - (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + AvailFBArea.y2 = lines; xf86InitFBManager(pScreen, &AvailFBArea); - return(XAAInit(pScreen, infoPtr)); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %i scanlines of offscreen memory for pixmap caching\n", + lines - pScrn->virtualY); + return(XAAInit(pScreen, infoPtr)); } static void @@ -238,17 +273,12 @@ unsigned int planemask, int trans_color) { - NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); nAcl->tmpBltCntlFlags = (nAcl->BltCntlFlags | NEO_BC3_SKIP_MAPPING | NEO_BC3_DST_XY_ADDR | NEO_BC3_SRC_XY_ADDR | neo2097Rop[rop]); - - /* set blt control */ - WAIT_ENGINE_IDLE(); - OUTREG(NEOREG_BLTCNTL, nAcl->BltCntlFlags); } static void @@ -312,12 +342,11 @@ OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); } - -#ifdef colorexpandfill static void -Neo2097SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, - int rop, - unsigned int planemask) +Neo2097SetupScanlineForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) { NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); @@ -325,44 +354,101 @@ if (bg == -1) { /* transparent setup */ WAIT_ENGINE_IDLE(); +#ifdef NEO_DO_CLIPPING OUTREG(NEOREG_BLTCNTL, nAcl->BltCntlFlags | NEO_BC0_SYS_TO_VID | NEO_BC0_SRC_MONO | NEO_BC0_SRC_TRANS | NEO_BC3_SKIP_MAPPING | - NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); + NEO_BC3_CLIP_ON | + NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); +#else + OUTREG(NEOREG_BLTCNTL, nAcl->BltCntlFlags | + NEO_BC0_SYS_TO_VID | + NEO_BC0_SRC_MONO | + NEO_BC0_SRC_TRANS | + NEO_BC3_SKIP_MAPPING | + NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); +#endif OUTREG(NEOREG_FGCOLOR, fg |= (fg << nAcl->ColorShiftAmt)); } else { /* opaque setup */ WAIT_ENGINE_IDLE(); +#ifdef NEO_DO_CLIPPING OUTREG(NEOREG_BLTCNTL, nAcl->BltCntlFlags | NEO_BC0_SYS_TO_VID | NEO_BC0_SRC_MONO | NEO_BC3_SKIP_MAPPING | + NEO_BC3_CLIP_ON | NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); +#else + OUTREG(NEOREG_BLTCNTL, nAcl->BltCntlFlags | + NEO_BC0_SYS_TO_VID | + NEO_BC0_SRC_MONO | + NEO_BC3_SKIP_MAPPING | + NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); +#endif OUTREG(NEOREG_FGCOLOR, fg |= (fg << nAcl->ColorShiftAmt)); OUTREG(NEOREG_BGCOLOR, bg |= (bg << nAcl->ColorShiftAmt)); } } -#endif -#ifdef colorexpandfill + static void -Neo2097SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +Neo2097SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) { NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); +#ifdef NEO_DO_CLIPPING + w = (w + 31) & ~31; +#else + nAcl->CPUToScreenColorExpandFill_x = x; + nAcl->CPUToScreenColorExpandFill_y = y; + nAcl->CPUToScreenColorExpandFill_w = w; + nAcl->CPUToScreenColorExpandFill_h = h; +#endif WAIT_ENGINE_IDLE(); +#ifdef NEO_DO_CLIPPING + OUTREG(NEOREG_CLIPLT, (y << 16) | (x + skipleft)); + OUTREG(NEOREG_CLIPRB, ((y + h) << 16) | (x + w)); + WAIT_ENGINE_IDLE(); +#endif OUTREG(NEOREG_SRCSTARTOFF, 0); OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff)); +#ifdef NEO_DO_CLIPPING OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); +#else + OUTREG(NEOREG_XYEXT, (1<<16) | (w & 0xffff)); +#endif } + +static void +Neo2097SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ +#ifdef NEO_DO_CLIPPING + /* Should I be waiting for fifo slots to prevent retries ? + How do I do that on this engine ? */ +#else + NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + if (!(--nAcl->CPUToScreenColorExpandFill_h)) + return; + + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_SRCSTARTOFF, 0); + OUTREG(NEOREG_DSTSTARTOFF, ((++nAcl->CPUToScreenColorExpandFill_y)<<16) + | (nAcl->CPUToScreenColorExpandFill_x & 0xffff)); + OUTREG(NEOREG_XYEXT, (1<<16) + | (nAcl->CPUToScreenColorExpandFill_w & 0xffff)); #endif +} static void Neo2097SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, @@ -376,33 +462,31 @@ if (bg == -1) { /* transparent setup */ - nAcl->tmpBltCntlFlags = ( nAcl->BltCntlFlags | + nAcl->tmpBltCntlFlags = ( nAcl->BltCntlFlags | NEO_BC0_SRC_MONO | NEO_BC0_FILL_PAT | NEO_BC0_SRC_TRANS | NEO_BC3_SKIP_MAPPING | + NEO_BC3_SRC_XY_ADDR | NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); WAIT_ENGINE_IDLE(); OUTREG(NEOREG_FGCOLOR, fg |= (fg << nAcl->ColorShiftAmt)); - OUTREG(NEOREG_SRCSTARTOFF, - (patterny*pScrn->displayWidth*pScrn->bitsPerPixel + patternx) - >> 3); + OUTREG(NEOREG_SRCSTARTOFF, (patterny << 16) | patternx); } else { /* opaque setup */ - nAcl->tmpBltCntlFlags = ( nAcl->BltCntlFlags | + nAcl->tmpBltCntlFlags = ( nAcl->BltCntlFlags | NEO_BC0_SRC_MONO | NEO_BC0_FILL_PAT | NEO_BC3_SKIP_MAPPING | + NEO_BC3_SRC_XY_ADDR | NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); WAIT_ENGINE_IDLE(); OUTREG(NEOREG_FGCOLOR, fg |= (fg << nAcl->ColorShiftAmt)); OUTREG(NEOREG_BGCOLOR, bg |= (bg << nAcl->ColorShiftAmt)); - OUTREG(NEOREG_SRCSTARTOFF, - (patterny*pScrn->displayWidth*pScrn->bitsPerPixel + patternx) - >> 3); + OUTREG(NEOREG_SRCSTARTOFF, (patterny << 16) | patternx); } } @@ -421,10 +505,51 @@ WAIT_ENGINE_IDLE(); OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags | (patterny << 20)); - OUTREG(NEOREG_SRCBITOFF, patternx); +/* OUTREG(NEOREG_SRCBITOFF, patternx); Bad Register */ OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff)); OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); } + +static void +Neo2097SetupForScanlineImageWrite( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, int depth +){ + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + nAcl->tmpBltCntlFlags = (nAcl->BltCntlFlags | + NEO_BC0_SYS_TO_VID | + NEO_BC3_SKIP_MAPPING | + NEO_BC3_DST_XY_ADDR | neo2097Rop[rop]); +} + + +static void +Neo2097SubsequentScanlineImageWriteRect( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft +){ + NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags); + OUTREG(NEOREG_SRCSTARTOFF, 0); + OUTREG(NEOREG_DSTSTARTOFF, (y << 16) | (x & 0xffff)); + OUTREG(NEOREG_XYEXT, (h << 16) | w); +} + +static void +Neo2097SubsequentImageWriteScanline( + ScrnInfoPtr pScrn, + int bufno +){ + /* should I be checking for fifo slots here ? */ +} Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c:1.6 Thu Jun 15 21:50:21 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c Tue Oct 17 17:36:15 2000 @@ -1,4 +1,4 @@ -/********************************************************************** +/******************************************************************** Copyright 1998, 1999 by Precision Insight, Inc., Cedar Park, Texas. All Rights Reserved @@ -22,8 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c,v 1.6 2000/06/16 01:50:21 dawes Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c,v 1.12 2000/10/17 21:36:15 mvojkovi Exp $ */ /* * The original Precision Insight driver for * XFree86 v.3.3 has been sponsored by Red Hat. @@ -58,20 +57,24 @@ static void Neo2200SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX, int srcY, int dstX, int dstY, int w, int h); +static void Neo2200SubsequentScreenToScreenCopyBroken(ScrnInfoPtr pScrn, int srcX, + int srcY, int dstX, int dstY, + int w, int h); static void Neo2200SetupForSolidFillRect(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask); static void Neo2200SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h); -#ifdef colorexpandfill -static void Neo2200SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2200SetupForScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); -static void Neo2200SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +static void Neo2200SubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); -#endif +static void Neo2200SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); static void Neo2200SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, @@ -115,6 +118,7 @@ NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); BoxRec AvailFBArea; + int lines; nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; @@ -122,8 +126,8 @@ /* * Set up the main acceleration flags. */ - infoPtr->Flags |= LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; - if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags = PIXMAP_CACHE; + infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; + if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags |= PIXMAP_CACHE; #if 0 infoPtr->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES; #endif @@ -134,8 +138,8 @@ infoPtr->ScreenToScreenCopyFlags = (NO_TRANSPARENCY | NO_PLANEMASK); infoPtr->SetupForScreenToScreenCopy = Neo2200SetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = - Neo2200SubsequentScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy + = Neo2200SubsequentScreenToScreenCopyBroken; /* solid filled rectangles */ infoPtr->SolidFillFlags = NO_PLANEMASK; @@ -144,28 +148,35 @@ infoPtr->SubsequentSolidFillRect = Neo2200SubsequentSolidFillRect; -#ifdef colorexpandfill - /* We need byte scanline padding before we can use this - * or does anyone know how to switch the chip to dword - * padding? if we could do right edge clipping this would - * help also. Left edge clipping cannot be used since it - * allows only clipping of up to 8 pixels :-(( - */ /*§§§*/ - /* cpu to screen color expansion */ - infoPtr->CPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | - /* SCANLINE_PAD_BYTE | */ - CPU_TRANSFER_PAD_DWORD | - BIT_ORDER_IN_BYTE_MSBFIRST ); - infoPtr->ColorExpandBase = - (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); - infoPtr->ColorExpandRange = 0x100000; + /* + * We do CPUToScreenColorExpand (ab)using the Scanline functions: + * the neo chipsets need byte padding however we can only do dword + * padding. Fortunately the graphics engine doesn't choke if we + * transfer up to 3 bytes more than it wants. + */ - infoPtr->SetupForCPUToScreenColorExpandFill = - Neo2200SetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - Neo2200SubsequentCPUToScreenColorExpandFill; + + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | +#ifdef NEO_DO_CLIPPING + LEFT_EDGE_CLIPPING | #endif + SCANLINE_PAD_DWORD | + CPU_TRANSFER_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST ); + infoPtr->ScanlineColorExpandBuffers = + (unsigned char **)xnfalloc(sizeof(char*)); + infoPtr->ScanlineColorExpandBuffers[0] = + (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); + infoPtr->NumScanlineColorExpandBuffers = 1; + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = + Neo2200SetupForScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = + Neo2200SubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = + Neo2200SubsequentColorExpandScanline; + +#if 0 /* 8x8 pattern fills */ infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_ORIGIN @@ -175,6 +186,7 @@ Neo2200SetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = Neo2200SubsequentMono8x8PatternFill; +#endif /* * Setup some global variables @@ -230,15 +242,21 @@ return FALSE; } + lines = nAcl->cacheEnd / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + if(lines > 1024) lines = 1024; + AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = nAcl->cacheEnd / - (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + AvailFBArea.y2 = lines; xf86InitFBManager(pScreen, &AvailFBArea); - return(XAAInit(pScreen, infoPtr)); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using %i scanlines of offscreen memory for pixmap caching\n", + lines - pScrn->virtualY); + return(XAAInit(pScreen, infoPtr)); } static void @@ -259,7 +277,7 @@ NEOACLPtr nAcl = NEOACLPTR(pScrn); nAcl->tmpBltCntlFlags = (NEO_BC3_SKIP_MAPPING | neo2200Rop[rop]); - + /* set blt control */ WAIT_ENGINE_IDLE(); /*OUTREG16(NEOREG_BLTMODE, nAcl->BltModeFlags);*/ @@ -281,7 +299,9 @@ if ((dstY < srcY) || ((dstY == srcY) && (dstX < srcX))) { /* start with upper left corner */ WAIT_ENGINE_IDLE(); +#if 0 OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags); +#endif OUTREG(NEOREG_SRCSTARTOFF, (srcY * nAcl->Pitch) + (srcX * nAcl->PixelWidth)); OUTREG(NEOREG_DSTSTARTOFF, @@ -291,10 +311,12 @@ else { /* start with lower right corner */ WAIT_ENGINE_IDLE(); +#if 0 OUTREG(NEOREG_BLTCNTL, (nAcl->tmpBltCntlFlags | NEO_BC0_X_DEC | NEO_BC0_DST_Y_DEC | NEO_BC0_SRC_Y_DEC)); +#endif OUTREG(NEOREG_SRCSTARTOFF, ((srcY+h-1) * nAcl->Pitch) + ((srcX+w-1) * nAcl->PixelWidth)); @@ -305,6 +327,96 @@ } } +static void +Neo2200SubsequentScreenToScreenCopyBroken(ScrnInfoPtr pScrn, + int srcX, int srcY, + int dstX, int dstY, + int w, int h) +{ + NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + + if ((dstY < srcY) || ((dstY == srcY) && (dstX < srcX))) { + if (((dstX < 64) && ((srcX + w) == pScrn->displayWidth)) || + ((dstX == 0) && (w > (pScrn->displayWidth - 64)))) { + + int srcX1 = srcX + 64; + int dstX1 = dstX + 64; + w -= 64; + /* start with upper left corner */ + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags); + OUTREG(NEOREG_SRCSTARTOFF, + (srcY * nAcl->Pitch) + (srcX * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + (dstY * nAcl->Pitch) + (dstX * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (64)); + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_SRCSTARTOFF, + (srcY * nAcl->Pitch) + (srcX1 * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + (dstY * nAcl->Pitch) + (dstX1 * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); + } else { + /* start with upper left corner */ + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags); + OUTREG(NEOREG_SRCSTARTOFF, + (srcY * nAcl->Pitch) + (srcX * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + (dstY * nAcl->Pitch) + (dstX * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); + } + } else { + if ((((dstX + w) > (pScrn->displayWidth - 64)) && (srcX == 0)) + || (((dstX + w) == pScrn->displayWidth) + && (w > (pScrn->displayWidth - 64)))) { + int srcX1, dstX1; + + w -= 64; + srcX1 = srcX + w; + dstX1 = dstX + w; + /* start with lower right corner */ +#if 1 + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, (nAcl->tmpBltCntlFlags + | NEO_BC0_X_DEC + | NEO_BC0_DST_Y_DEC + | NEO_BC0_SRC_Y_DEC)); + OUTREG(NEOREG_SRCSTARTOFF, + ((srcY+h-1) * nAcl->Pitch) + ((srcX1+64-1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + ((dstY+h-1) * nAcl->Pitch) + ((dstX1+64-1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (64 & 0xffff)); +#endif + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_SRCSTARTOFF, + ((srcY+h-1) * nAcl->Pitch) + ((srcX + w -1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + ((dstY+h-1) * nAcl->Pitch) + ((dstX + w -1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); + } else { + /* start with lower right corner */ + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, (nAcl->tmpBltCntlFlags + | NEO_BC0_X_DEC + | NEO_BC0_DST_Y_DEC + | NEO_BC0_SRC_Y_DEC)); + OUTREG(NEOREG_SRCSTARTOFF, + ((srcY+h-1) * nAcl->Pitch) + ((srcX+w-1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_DSTSTARTOFF, + ((dstY+h-1) * nAcl->Pitch) + ((dstX+w-1) + * nAcl->PixelWidth)); + OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); + } + } +} + static void Neo2200SetupForSolidFillRect(ScrnInfoPtr pScrn, int color, int rop, @@ -338,10 +450,9 @@ OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); } - -#ifdef colorexpandfill static void -Neo2200SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, +Neo2200SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, int rop, unsigned int planemask) { @@ -355,7 +466,10 @@ NEO_BC0_SRC_TRANS | NEO_BC3_SKIP_MAPPING | NEO_BC3_DST_XY_ADDR | - neo2200Rop[rop]); +#ifdef NEO_DO_CLIPPING + NEO_BC3_CLIP_ON | +#endif + neo2200Rop[rop]); WAIT_ENGINE_IDLE(); /*OUTREG16(NEOREG_BLTMODE, nAcl->BltModeFlags);*/ @@ -369,12 +483,14 @@ NEO_BC0_SRC_MONO | NEO_BC3_SKIP_MAPPING | NEO_BC3_DST_XY_ADDR | +#ifdef NEO_DO_CLIPPING + NEO_BC3_CLIP_ON | +#endif neo2200Rop[rop]); WAIT_ENGINE_IDLE(); /*OUTREG16(NEOREG_BLTMODE, nAcl->BltModeFlags);*/ OUTREG(NEOREG_BLTSTAT, nAcl->BltModeFlags << 16); - OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags); OUTREG(NEOREG_FGCOLOR, fg); OUTREG(NEOREG_BGCOLOR, bg); } @@ -382,21 +498,60 @@ static void -Neo2200SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, +Neo2200SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) { NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); - +#ifdef NEO_DO_CLIPPING + w = (w + 31) & ~31; +#else + nAcl->CPUToScreenColorExpandFill_x = x; + nAcl->CPUToScreenColorExpandFill_y = y; + nAcl->CPUToScreenColorExpandFill_w = w; + nAcl->CPUToScreenColorExpandFill_h = h; + nAcl->CPUToScreenColorExpandFill_skipleft = skipleft; +#endif OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags | ((skipleft << 2) & 0x1C)); + #ifdef NEO_DO_CLIPPING + OUTREG(NEOREG_CLIPLT, (y << 16) | (x + skipleft)); + OUTREG(NEOREG_CLIPRB, ((y + h) << 16) | (x + w)); +#endif OUTREG(NEOREG_SRCSTARTOFF, 0); OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff)); +#ifdef NEO_DO_CLIPPING OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); +#else + OUTREG(NEOREG_XYEXT, (1<<16) | (w & 0xffff)); +#endif } + +static void +Neo2200SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + NEOPtr nPtr = NEOPTR(pScrn); + NEOACLPtr nAcl = NEOACLPTR(pScrn); + +#ifdef NEO_DO_CLIPPING + /* Should I be waiting for fifo slots to prevent retries ? + How do I do that on this engine ? */ +#else + if (!(--nAcl->CPUToScreenColorExpandFill_h)) + return; + + WAIT_ENGINE_IDLE(); + OUTREG(NEOREG_BLTCNTL, nAcl->tmpBltCntlFlags + | ((nAcl->CPUToScreenColorExpandFill_skipleft << 2) & 0x1C)); + OUTREG(NEOREG_SRCSTARTOFF, 0); + OUTREG(NEOREG_DSTSTARTOFF, ((++nAcl->CPUToScreenColorExpandFill_y)<<16) + | (nAcl->CPUToScreenColorExpandFill_x & 0xffff)); + OUTREG(NEOREG_XYEXT, (1<<16) + | (nAcl->CPUToScreenColorExpandFill_w & 0xffff)); #endif +} static void Neo2200SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, @@ -465,3 +620,5 @@ OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff)); OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff)); } + + Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c:1.4 Tue Feb 8 08:13:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c Fri Nov 3 13:46:11 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c,v 1.4 2000/02/08 13:13:18 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_cursor.c,v 1.7 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -200,52 +200,27 @@ unsigned char *_dest, *_src; int _width, _fill; - if (!nPtr->noLinear) { - for (i = 0; i< nPtr->CursorInfo->MaxHeight - yoff; i++) { - _dest = ((unsigned char *)nPtr->NeoFbBase - + nAcl->CursorAddress - + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _width = (nPtr->CursorInfo->MaxWidth - - (xoff & 0x38)) >> 3; - _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _fill = (xoff & 0x38) >> 3; - - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - - _dest += (nPtr->CursorInfo->MaxWidth >> 3); - _src += (nPtr->CursorInfo->MaxWidth >> 3); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - } - memset(nPtr->NeoFbBase + nAcl->CursorAddress - + ((nPtr->CursorInfo->MaxWidth >> 2) * i), - 0, (nPtr->CursorInfo->MaxHeight - i) - * (nPtr->CursorInfo->MaxWidth >> 2)); - } else { - /* - * The cursor can only be in the last 16K of video memory, - * which fits in the last banking window. - */ - for (i = 0; i<nPtr->CursorInfo->MaxHeight; i++) { - _dest = ((unsigned char *)nPtr->NeoFbBase - + (nAcl->CursorAddress & 0xFFFF) - + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _width = (nPtr->CursorInfo->MaxWidth - - ((xoff & 0x38) >> 3)); - _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); - _fill = (xoff & 0x38) >> 3; - - NEOSetWrite(pScrn->pScreen, (int)(nAcl->CursorAddress >> 16)); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - - _dest += (nPtr->CursorInfo->MaxWidth >> 3); - _src += (nPtr->CursorInfo->MaxWidth >> 3); - memcpy(_dest,_src,_width); - memset(_dest + _width, 0, _fill); - } + for (i = 0; i< nPtr->CursorInfo->MaxHeight - yoff; i++) { + _dest = ((unsigned char *)nPtr->NeoFbBase + + nAcl->CursorAddress + + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); + _width = (nPtr->CursorInfo->MaxWidth + - (xoff & 0x38)) >> 3; + _src = (src + ((nPtr->CursorInfo->MaxWidth >> 2) * i)); + _fill = (xoff & 0x38) >> 3; + + memcpy(_dest,_src,_width); + memset(_dest + _width, 0, _fill); + + _dest += (nPtr->CursorInfo->MaxWidth >> 3); + _src += (nPtr->CursorInfo->MaxWidth >> 3); + memcpy(_dest,_src,_width); + memset(_dest + _width, 0, _fill); } + memset(nPtr->NeoFbBase + nAcl->CursorAddress + + ((nPtr->CursorInfo->MaxWidth >> 2) * i), + 0, (nPtr->CursorInfo->MaxHeight - i) + * (nPtr->CursorInfo->MaxWidth >> 2)); /* set cursor address here or we loose the cursor on video mode change */ /* Load storage location. */ OUTREG(NEOREG_CURSMEMPOS, ((0x000f & (nAcl->CursorAddress >> 10)) << 8) | @@ -269,12 +244,8 @@ { NEOACLPtr nAcl = NEOACLPTR(xf86Screens[pScr->myNum]); NEOPtr nPtr = NEOPTR(xf86Screens[pScr->myNum]); - - if(!nPtr->noLinear) { - return(nAcl->UseHWCursor); - } - - return (FALSE); + + return(nAcl->UseHWCursor && !nAcl->NoCursorMode); } static unsigned char* @@ -323,7 +294,6 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; NEOPtr nPtr = NEOPTR(pScrn); xf86CursorInfoPtr infoPtr; - infoPtr = xf86CreateCursorInfoRec(); if(!infoPtr) return FALSE; Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c:1.1 Thu Jun 22 14:09:37 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c Tue Oct 17 17:36:15 2000 @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c,v 1.1 2000/06/22 18:09:37 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c,v 1.3 2000/10/17 21:36:15 mvojkovi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -33,6 +33,7 @@ #include "neo.h" #include "neo_reg.h" #include "dgaproc.h" +#include "vgaHW.h" static Bool NEO_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, int *, int *, int *); @@ -70,20 +71,18 @@ DGAModePtr modes = NULL, newmodes = NULL, currentMode; DisplayModePtr pMode, firstMode; int Bpp = pScrn->bitsPerPixel >> 3; - int num = 0; - Bool oneMore; + int num = 0, imlines, pixlines; + imlines = (pScrn->videoRam * 1024) / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + + pixlines = (imlines > 1024) ? 1024 : imlines; + pMode = firstMode = pScrn->modes; while(pMode) { - if(0 /*pScrn->displayWidth != pMode->HDisplay*/) { - newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec)); - oneMore = TRUE; - } else { - newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - } + newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); if(!newmodes) { xfree(modes); @@ -91,8 +90,6 @@ } modes = newmodes; -SECOND_PASS: - currentMode = modes + num; num++; @@ -118,32 +115,16 @@ currentMode->offset = 0; currentMode->address = pNEO->NeoFbBase; - if(oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = + currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 3) & ~3L; - currentMode->imageWidth = pScrn->displayWidth; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = imlines; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = pixlines; + currentMode->maxViewportX = currentMode->imageWidth - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - + currentMode->maxViewportY = currentMode->imageHeight - currentMode->viewportHeight; - } pMode = pMode->next; if(pMode == firstMode) @@ -156,33 +137,29 @@ return DGAInit(pScreen, &NEODGAFuncs, modes, num); } +static DisplayModePtr NEOSavedDGAModes[MAXSCREENS]; static Bool NEO_SetMode( ScrnInfoPtr pScrn, DGAModePtr pMode ){ - static int OldDisplayWidth[MAXSCREENS]; int index = pScrn->pScreen->myNum; NEOPtr pNEO = NEOPTR(pScrn); if(!pMode) { /* restore the original mode */ - /* put the ScreenParameters back */ - - pScrn->displayWidth = OldDisplayWidth[index]; - - NEOSwitchMode(index, pScrn->currentMode, 0); - pNEO->DGAactive = FALSE; + if(pNEO->DGAactive) { + pScrn->currentMode = NEOSavedDGAModes[index]; + NEOSwitchMode(index, pScrn->currentMode, 0); + NEOAdjustFrame(index, 0, 0, 0); + pNEO->DGAactive = FALSE; + } } else { if(!pNEO->DGAactive) { /* save the old parameters */ - OldDisplayWidth[index] = pScrn->displayWidth; - + NEOSavedDGAModes[index] = pScrn->currentMode; pNEO->DGAactive = TRUE; } - pScrn->displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - NEOSwitchMode(index, pMode->mode, 0); } @@ -205,9 +182,14 @@ int flags ){ NEOPtr pNEO = NEOPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); NEOAdjustFrame(pScrn->pScreen->myNum, x, y, flags); - pNEO->DGAViewportStatus = 0; /* NEOAdjustFrame loops until finished */ + /* wait for retrace */ + while((hwp->readST01(hwp) & 0x08)); + while(!(hwp->readST01(hwp) & 0x08)); + + pNEO->DGAViewportStatus = 0; } static void Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c:1.29 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c:1.46 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c:1.29 Fri Jun 30 13:15:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c Wed Dec 6 13:08:54 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c,v 1.29 2000/06/30 17:15:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c,v 1.46 2000/12/06 18:08:54 eich Exp $ */ /* * The original Precision Insight driver for @@ -70,20 +70,15 @@ /* All drivers using the mi colormap manipulation need this */ #include "micmap.h" -/* If using cfb, cfb.h is required. */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "xf86cmap.h" +#include "fb.h" + /* Needed by Resources Access Control (RAC) */ #include "xf86RAC.h" /* Needed by the Shadow Framebuffer */ -#include "shadowfb.h" +#include "shadow.h" /* int10 */ #include "xf86int10.h" @@ -92,6 +87,10 @@ /* Needed for Device Data Channel (DDC) support */ #include "xf86DDC.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* * Driver data structures. */ @@ -100,7 +99,6 @@ #include "neo_macros.h" /* These need to be checked */ -#if 0 #ifdef XFreeXDGA #include "X.h" #include "Xproto.h" @@ -109,7 +107,6 @@ #define _XF86DGA_SERVER_ #include "extensions/xf86dgastr.h" #endif -#endif /* Mandatory functions */ static OptionInfoPtr NEOAvailableOptions(int chipid, int busid); @@ -138,9 +135,14 @@ static void neoProgramShadowRegs(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore); static void neoCalcVCLK(ScrnInfoPtr pScrn, long freq); -static void neo_ddc1(int scrnIndex); +static xf86MonPtr neo_ddc1(int scrnIndex); +static Bool neoDoDDC1(ScrnInfoPtr pScrn); +static Bool neoDoDDC2(ScrnInfoPtr pScrn); +static Bool neoDoDDCVBE(ScrnInfoPtr pScrn); +static void neoProbeDDC(ScrnInfoPtr pScrn, int index); static void NeoDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); +static int neoFindMode(int xres, int yres, int depth); #define VERSION 4000 #define NEO_NAME "NEOMAGIC" @@ -156,6 +158,39 @@ */ static int pix24bpp = 0; + +static biosMode bios8[] = { + { 320, 240, 0x40 }, + { 300, 400, 0x42 }, + { 640, 400, 0x20 }, + { 640, 480, 0x21 }, + { 800, 600, 0x23 }, + { 1024, 768, 0x25 }, +}; + +static biosMode bios15[] = { + { 320, 200, 0x2D }, + { 640, 480, 0x30 }, + { 800, 600, 0x33 }, + { 1024, 768, 0x36 }, +}; + +static biosMode bios16[] = { + { 320, 200, 0x2e }, + { 320, 240, 0x41 }, + { 300, 400, 0x43 }, + { 640, 480, 0x31 }, + { 800, 600, 0x34 }, + { 1024, 768, 0x37 }, +}; + +static biosMode bios24[] = { + { 640, 480, 0x32 }, + { 800, 600, 0x35 }, + { 1024, 768, 0x38 } +}; + + /* * This contains the functions needed by the server after loading the driver * module. It must be supplied, and gets passed back by the SetupProc @@ -184,6 +219,7 @@ { NM2097, "neo2097" }, { NM2160, "neo2160" }, { NM2200, "neo2200" }, + { NM2230, "neo2230" }, { NM2360, "neo2360" }, { NM2380, "neo2380" }, { -1, NULL } @@ -197,6 +233,7 @@ { NM2097, PCI_CHIP_NM2097, RES_SHARED_VGA }, { NM2160, PCI_CHIP_NM2160, RES_SHARED_VGA }, { NM2200, PCI_CHIP_NM2200, RES_SHARED_VGA }, + { NM2230, PCI_CHIP_NM2230, RES_SHARED_VGA }, { NM2360, PCI_CHIP_NM2360, RES_SHARED_VGA }, { NM2380, PCI_CHIP_NM2380, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED} @@ -293,11 +330,8 @@ NULL }; -static const char *cfbSymbols[] = { - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb24_32ScreenInit", +static const char *fbSymbols[] = { + "fbScreenInit", NULL }; @@ -316,7 +350,10 @@ }; static const char *shadowSymbols[] = { + "shadowInit", +#if 0 "ShadowFBInit", +#endif NULL }; @@ -380,7 +417,7 @@ * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols, ramdacSymbols, shadowSymbols, ddcSymbols, vbeSymbols, i2cSymbols, NULL); /* @@ -427,8 +464,7 @@ OptionInfoPtr NEOAvailableOptions(int chipid, int busid) { - int vendor = ((chipid & 0xffff0000) >> 16); - int chip = (chip & 0x0000ffff); + int chip = (chipid & 0x0000ffff); if (chip == PCI_CHIP_NM2070) return NEO_2070_Options; @@ -450,7 +486,7 @@ { Bool foundScreen = FALSE; int numDevSections, numUsed; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int i; @@ -566,11 +602,9 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags) { ClockRangePtr clockRanges; - char *mod = NULL; int i; NEOPtr nPtr; vgaHWPtr hwp; - const char *reqSym = NULL; int bppSupport = NoDepth24Support; int videoRam = 896; int maxClock = 65000; @@ -578,13 +612,16 @@ int CursorOff = 0x100; int linearSize = 1024; int maxWidth = 1024; + int maxHeight = 1024; unsigned char type, display; int w; int apertureSize; char *s; - Bool ddc_done = FALSE; - if (flags & PROBE_DETECT) return FALSE; + if (flags & PROBE_DETECT) { + neoProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index ); + return TRUE; + } /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) @@ -598,7 +635,7 @@ if (!vgaHWGetHWRec(pScrn)) return FALSE; hwp = VGAHWPTR(pScrn); - + /* Allocate the NeoRec driverPrivate */ if (!NEOGetRec(pScrn)) { return FALSE; @@ -652,6 +689,9 @@ case NM2200 : xf86ErrorF("MagicMedia 256AV (NM2200)"); break; + case NM2230 : + xf86ErrorF("MagicMedia 256AV+ (NM2230)"); + break; case NM2360 : xf86ErrorF("MagicMedia 256ZX (NM2360)"); break; @@ -661,14 +701,10 @@ } xf86ErrorF("\n"); - if (xf86LoadSubModule(pScrn, "vbe")) { - nPtr->pVbe = VBEInit(NULL,nPtr->pEnt->index); - } - vgaHWGetIOBase(hwp); nPtr->vgaIOBase = hwp->IOBase; vgaHWSetStdFuncs(hwp); - + /* Determine the panel type */ VGAwGR(0x09,0x26); type = VGArGR(0x21); @@ -723,6 +759,7 @@ CursorOff = 0x100; linearSize = 1024; maxWidth = 1024; + maxHeight = 1024; break; case NM2090: case NM2093: @@ -734,16 +771,18 @@ CursorOff = 0x100; linearSize = 2048; maxWidth = 1024; + maxHeight = 1024; break; case NM2097: bppSupport = Support24bppFb | Support32bppFb | - SupportConvert32to24 | PreferConvert32to24; + SupportConvert32to24 | PreferConvert32to24; videoRam = 1152; maxClock = 80000; CursorMem = 1024; CursorOff = 0x100; linearSize = 2048; maxWidth = 1024; + maxHeight = 1024; break; case NM2160: bppSupport = Support24bppFb | Support32bppFb | @@ -754,6 +793,7 @@ CursorOff = 0x100; linearSize = 2048; maxWidth = 1024; + maxHeight = 1024; break; case NM2200: bppSupport = Support24bppFb | Support32bppFb | @@ -764,6 +804,18 @@ CursorOff = 0x1000; linearSize = 4096; maxWidth = 1280; + maxHeight = 1024; /* ???? */ + break; + case NM2230: + bppSupport = Support24bppFb | Support32bppFb | + SupportConvert32to24 | PreferConvert32to24; + videoRam = 3008; + maxClock = 110000; + CursorMem = 1024; + CursorOff = 0x1000; + linearSize = 4096; + maxWidth = 1280; + maxHeight = 1024; /* ???? */ break; case NM2360: bppSupport = Support24bppFb | Support32bppFb | @@ -774,6 +826,7 @@ CursorOff = 0x1000; linearSize = 4096; maxWidth = 1280; + maxHeight = 1024; /* ???? */ break; case NM2380: bppSupport = Support24bppFb | Support32bppFb | @@ -784,46 +837,28 @@ CursorOff = 0x1000; linearSize = 4096; maxWidth = 1280; + maxHeight = 1024; /* ???? */ break; } pScrn->monitor = pScrn->confScreen->monitor; - if (!xf86LoadSubModule(pScrn, "ddc")) - return FALSE; - xf86LoaderReqSymLists(ddcSymbols, NULL); -#if 0 - VGAwGR(0x09,0x26); - neo_ddc1(pScrn->scrnIndex); - VGAwGR(0x09,0x00); + if (xf86LoadSubModule(pScrn, "ddc")) { + xf86LoaderReqSymLists(ddcSymbols, NULL); +#if 1 /* for DDC1 testing */ + if (!neoDoDDCVBE(pScrn)) + if (!neoDoDDC2(pScrn)) #endif - if (!xf86LoadSubModule(pScrn, "i2c")) - return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - if (!neo_I2CInit(pScrn)) - return FALSE; - - VGAwGR(0x09,0x26); - - if (nPtr->pVbe) { - xf86MonPtr pMon; - if ((pMon = xf86PrintEDID(vbeDoEDID(nPtr->pVbe,NULL))) != NULL) - ddc_done = TRUE; - xf86SetDDCproperties(pScrn,pMon); + neoDoDDC1(pScrn); } - if (ddc_done) - xf86SetDDCproperties( - pScrn,xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex,nPtr->I2C))); - - VGAwGR(0x09,0x00); - if (!xf86SetDepthBpp(pScrn, 8, 8, 8, bppSupport )) return FALSE; else { /* Check that the returned depth is one we support */ switch (pScrn->depth) { case 8: + case 15: case 16: break; case 24: @@ -860,17 +895,8 @@ } } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } if (pScrn->depth > 1) { Gamma zeros = {0.0, 0.0, 0.0}; @@ -898,12 +924,13 @@ xf86GetOptValBool(nPtr->Options, OPTION_LCD_CENTER,&nPtr->lcdCenter); xf86GetOptValBool(nPtr->Options, OPTION_LCD_STRETCH,&nPtr->noLcdStretch); xf86GetOptValBool(nPtr->Options, OPTION_SHADOW_FB,&nPtr->shadowFB); + nPtr->onPciBurst = TRUE; xf86GetOptValBool(nPtr->Options, OPTION_PCI_BURST,&nPtr->onPciBurst); xf86GetOptValBool(nPtr->Options, OPTION_PROG_LCD_MODE_REGS,&nPtr->progLcdRegs); if (xf86GetOptValBool(nPtr->Options, OPTION_PROG_LCD_MODE_STRETCH,&nPtr->progLcdStretch)) - nPtr->progLcdStrechOpt = TRUE; + nPtr->progLcdStretchOpt = TRUE; xf86GetOptValBool(nPtr->Options, OPTION_OVERRIDE_VALIDATE_MODE, &nPtr->overrideValidate); nPtr->rotate = 0; @@ -957,7 +984,7 @@ "Internal LCD only display mode\n"); } } - + if (nPtr->noLcdStretch) xf86DrvMsg(pScrn->scrnIndex,X_CONFIG, "Low resolution video modes are not stretched\n"); @@ -1001,7 +1028,7 @@ nPtr->NeoLinearAddr = 0; } - if (nPtr->pEnt->device->IOBase) { + if (nPtr->pEnt->device->IOBase && !nPtr->noMMIO) { /* XXX Check this matches a PCI base address */ nPtr->NeoMMIOAddr = nPtr->pEnt->device->IOBase; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, @@ -1030,6 +1057,7 @@ case NM2160: case NM2097: case NM2200: + case NM2230: case NM2360: case NM2380: nPtr->NeoMMIOAddr = nPtr->PciInfo->memBase[1]; @@ -1115,15 +1143,17 @@ /* * For external displays, limit the width to 1024 pixels or less. */ - i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + { + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, NULL, 256, maxWidth,(8 * pScrn->bitsPerPixel),/*§§§*/ - 128, 2048, pScrn->display->virtualX, + 128, maxHeight, pScrn->display->virtualX, pScrn->display->virtualY, apertureSize, LOOKUP_BEST_REFRESH); - if (i == -1) - RETURN; + if (i == -1) + RETURN; + } /* Prune the modes marked as invalid */ xf86PruneDriverModes(pScrn); @@ -1152,31 +1182,14 @@ /* If monitor resolution is set on the command line, use it */ xf86SetDpi(pScrn, 0, 0); - /* Load bpp-specific modules */ - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - break; - case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - reqSym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - reqSym = "cfb24_32ScreenInit"; - } - break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { + if (xf86LoadSubModule(pScrn, "fb") == NULL) { RETURN; } - xf86LoaderReqSymbols(reqSym, NULL); + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif if (!nPtr->noLinear) { if (!xf86LoadSubModule(pScrn, "xaa")) @@ -1185,7 +1198,7 @@ } if (nPtr->shadowFB) { - if (!xf86LoadSubModule(pScrn, "shadowfb")) { + if (!xf86LoadSubModule(pScrn, "shadow")) { RETURN; } xf86LoaderReqSymLists(shadowSymbols, NULL); @@ -1224,26 +1237,49 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; NEOPtr nPtr = NEOPTR(pScrn); -#if 0 -#ifdef XFreeXDGA - if (vga256InfoRec.directMode&XF86DGADirectGraphics && !enter) { - /* - * Disable HW cursor. I hope DGA can't call this function twice - * in a row, without calling EnterVT in between. Otherwise the - * effect will be to hide the cursor, perhaps permanently!! - */ - if (nPtr->NeoHWCursorShown) - NeoHideCursor(pScrn); - return; - } -#endif -#endif - /* Invalidate the cached acceleration registers */ if (nPtr->NeoHWCursorShown) NeoHideCursor(pScrn); neoRestore(pScrn, &(VGAHWPTR(pScrn))->SavedReg, &nPtr->NeoSavedReg, TRUE); neoLock(pScrn); + +} + +static void +NEOLoadPalette( + ScrnInfoPtr pScrn, + int numColors, + int *indices, + LOCO *colors, + VisualPtr pVisual +){ + int i, index, shift, Gshift; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + switch(pScrn->depth) { + case 15: + shift = Gshift = 1; + break; + case 16: + shift = 0; + Gshift = 0; + break; + default: + shift = Gshift = 0; + break; + } + + for(i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].red << shift); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].green << Gshift); + DACDelay(hwp); + hwp->writeDacData(hwp, colors[index].blue << shift); + DACDelay(hwp); + } } /* Mandatory */ @@ -1288,18 +1324,6 @@ return FALSE; vgaHWSaveScreen(pScreen,SCREEN_SAVER_ON); NEOAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - - /* - * The next step is to setup the screen's visuals, and initialise the - * framebuffer code. In cases where the framebuffer's default - * choices for things like visual layouts and bits per RGB are OK, - * this may be as simple as calling the framebuffer's ScreenInit() - * function. If not, the visuals will need to be setup before calling - * a fb ScreenInit() function and fixed up after. - * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. - */ /* * Reset visual list. @@ -1308,31 +1332,12 @@ /* Setup the visuals we support. */ - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. To deal with this, call - * miSetVisualTypes for each visual supported. - */ - - if (pScrn->depth > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; - /* - * Temporarily set the global defaultColorVisualClass to make - * cfbInitVisuals do what we want. - */ -#if 0 - savedDefaultVisualClass = xf86GetDefaultColorVisualClass(); - xf86SetDefaultColorVisualClass(pScrn->defaultVisual); -#endif + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -1357,41 +1362,13 @@ FBStart = nPtr->NeoFbBase; } - switch (pScrn->bitsPerPixel) { - case 8: - ret = cfbScreenInit(pScreen, FBStart, - width,height, + ret = fbScreenInit(pScreen, FBStart, + width, height, pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 16: - ret = cfb16ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, FBStart, - width,height, - pScrn->xDpi, pScrn->yDpi, - displayWidth); - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in NEOScreenInit\n", - pScrn->bitsPerPixel); - ret = FALSE; - break; - } - -#if 0 - xf86SetDefaultColorVisualClass(savedDefaultVisualClass); + displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); #endif if (!ret) return FALSE; @@ -1419,6 +1396,7 @@ nPtr->NeoHWCursorShown = FALSE; nPtr->NeoHWCursorInitialized = FALSE; nAcl->UseHWCursor = FALSE; + nAcl->CursorAddress = -1; if (nPtr->noLinear) { miBankInfoPtr pBankInfo; @@ -1429,7 +1407,7 @@ return FALSE; pBankInfo->pBankA = hwp->Base; - pBankInfo->pBankB = (unsigned char *)hwp->Base + 0x10000; + pBankInfo->pBankB = (unsigned char *)hwp->Base; pBankInfo->BankSize = 0x10000; pBankInfo->nBankDepth = pScrn->depth; @@ -1445,16 +1423,16 @@ return FALSE; } xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using nonlinear mode\n"); - xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using software cursor\n"); - + xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Using software cursor in " + "nonlinear mode\n"); miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); } else { - nAcl->CursorAddress = -1; nAcl->cacheStart = -1; nAcl->cacheEnd = -1; xf86DrvMsg(pScrn->scrnIndex,X_INFO, @@ -1483,8 +1461,12 @@ } else xf86DrvMsg(scrnIndex, X_ERROR, "Too little space for H/W cursor.\n"); + if (!nPtr->noAccel && nPtr->noMMIO) + xf86DrvMsg(pScrn->scrnIndex,X_INFO, + "Acceleration disabled when not using MMIO\n"); + /* Setup the acceleration primitives */ - if (!nPtr->noAccel) { + if (!nPtr->noAccel && !nPtr->noMMIO) { nAcl->cacheStart = currentaddr - freespace; nAcl->cacheEnd = currentaddr; freespace = 0; @@ -1505,6 +1487,7 @@ Neo2097AccelInit(pScreen); break; case NM2200 : + case NM2230 : case NM2360 : case NM2380 : Neo2200AccelInit(pScreen); @@ -1512,27 +1495,30 @@ } xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Acceleration Initialized\n"); } - + miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); - if (nAcl->CursorAddress != -1) { - /* HW cursor functions */ - if (!NeoCursorInit(pScreen)) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - return FALSE; - } - nAcl->UseHWCursor = TRUE; - nPtr->NeoHWCursorInitialized = TRUE; - } } + if (nAcl->CursorAddress != -1) { + /* HW cursor functions */ + if (!NeoCursorInit(pScreen)) { + xf86DrvMsg(scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + return FALSE; + } + nAcl->UseHWCursor = TRUE; + nPtr->NeoHWCursorInitialized = TRUE; + } else + nAcl->UseHWCursor = FALSE; + if (nPtr->shadowFB) { - RefreshAreaFuncPtr refreshArea = neoRefreshArea; + nPtr->refreshArea = neoRefreshArea; if(nPtr->rotate) { if (!nPtr->PointerMoved) { @@ -1541,25 +1527,29 @@ } switch(pScrn->bitsPerPixel) { - case 8: refreshArea = neoRefreshArea8; break; - case 16: refreshArea = neoRefreshArea16; break; - case 24: refreshArea = neoRefreshArea24; break; - case 32: refreshArea = neoRefreshArea32; break; + case 8: nPtr->refreshArea = neoRefreshArea8; break; + case 16: nPtr->refreshArea = neoRefreshArea16; break; + case 24: nPtr->refreshArea = neoRefreshArea24; break; + case 32: nPtr->refreshArea = neoRefreshArea32; break; } } - - ShadowFBInit(pScreen, refreshArea); +#if 0 + ShadowFBInit(pScreen, nPtr->refreshArea); +#else + shadowInit (pScreen, neoShadowUpdate, 0); +#endif } /* Initialise default colourmap */ if(!miCreateDefColormap(pScreen)) return FALSE; - if (!vgaHWHandleColormaps(pScreen)) + if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, + NEOLoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) return FALSE; - if (pScrn->bitsPerPixel == 8) - racflag |= RAC_COLORMAP; + racflag |= RAC_COLORMAP; if (nPtr->NeoHWCursorInitialized) racflag |= RAC_CURSOR; @@ -1609,7 +1599,7 @@ nPtr = NEOPTR(pScrn); /* Scale Base by the number of bytes per pixel. */ - switch (pScrn->bitsPerPixel) { + switch (pScrn->depth) { case 8 : break; case 15 : @@ -1780,9 +1770,9 @@ xf86MapVidMem(pScrn->scrnIndex, VIDMEM_MMIO, nPtr->NeoMMIOAddr, 0x200000L); + if (nPtr->NeoMMIOBase == NULL) + return FALSE; } - if (nPtr->NeoMMIOBase == NULL) - return FALSE; if (nPtr->pEnt->location.type == BUS_PCI) nPtr->NeoFbBase = @@ -1874,25 +1864,27 @@ if (nPtr->NeoChipset == NM2160) { save->PanelHorizCenterReg4 = VGArGR(0x36); } - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) { + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) { save->PanelHorizCenterReg4 = VGArGR(0x36); save->PanelVertCenterReg5 = VGArGR(0x37); save->PanelHorizCenterReg5 = VGArGR(0x38); } save->ExtColorModeSelect = VGArGR(0x90); save->VCLK3NumeratorLow = VGArGR(0x9B); - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) save->VCLK3NumeratorHigh = VGArGR(0x8F); save->VCLK3Denominator = VGArGR(0x9F); - + save->ProgramVCLK = TRUE; + if (save->reg == NULL) save->reg = (regSavePtr)xnfcalloc(sizeof(regSaveRec), 1); else xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Non-NULL reg in NeoSave: reg=0x%08X\n", save->reg); + save->reg->CR[0x23] = VGArCR(0x23); save->reg->CR[0x25] = VGArCR(0x25); save->reg->CR[0x2F] = VGArCR(0x2F); for (i = 0x40; i <= 0x59; i++) { @@ -1940,7 +1932,7 @@ if (restore->PanelDispCntlReg2 & 0x84) { /* Don't program by default if in stretch mode */ noProgramShadowRegs = TRUE; - if (nPtr->progLcdStretch) + if (nPtr->progLcdStretch) noProgramShadowRegs = FALSE; } break; @@ -1949,6 +1941,7 @@ case NM2097: case NM2160: case NM2200: + case NM2230: case NM2360: case NM2380: default: @@ -1959,13 +1952,14 @@ if (restore->PanelDispCntlReg2 & 0x84) { /* Only change the behavior if an option is set */ - if (nPtr->progLcdStrechOpt) + if (nPtr->progLcdStretchOpt) noProgramShadowRegs = !nPtr->progLcdStretch; } break; } if (noProgramShadowRegs) { + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Not programming shadow registers\n"); if (nPtr->NeoSavedReg.reg){ for (i = 0x40; i <= 0x59; i++) { VGAwCR(i, nPtr->NeoSavedReg.reg->CR[i]); @@ -2086,9 +2080,10 @@ vgaHWPtr hwp = VGAHWPTR(pScrn); unsigned char temp; int i; - + Bool clock_hi = FALSE; + vgaHWProtect(pScrn,TRUE); /* Blank the screen */ - + VGAwGR(0x09,0x26); /* Init the shadow registers if necessary */ @@ -2116,6 +2111,7 @@ case NM2097 : case NM2160 : case NM2200 : + case NM2230 : case NM2360 : case NM2380 : temp &= 0x70; /* Save bits 6:4 */ @@ -2136,12 +2132,12 @@ * Sleep for 200ms to make sure that the two operations above have * had time to take effect. */ - usleep(200000); + xf86UDelay(200000); /* * This function handles restoring the generic VGA registers. */ vgaHWRestore(pScrn, VgaReg, - VGA_SR_MODE | VGA_SR_CMAP | (restoreFonts ? VGA_SR_FONTS : 0)); + VGA_SR_MODE | (restoreFonts ? VGA_SR_FONTS : 0)); VGAwGR(0x0E, restore->ExtCRTDispAddr); VGAwGR(0x0F, restore->ExtCRTOffset); @@ -2167,6 +2163,7 @@ temp |= (restore->PanelDispCntlReg1 & ~0xDC); break; case NM2200 : + case NM2230 : case NM2360 : case NM2380 : temp &= 0x98; /* Save bits 7,4:3 */ @@ -2201,18 +2198,24 @@ VGAwGR(0x36, restore->PanelHorizCenterReg4); } - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) { + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) { VGAwGR(0x36, restore->PanelHorizCenterReg4); VGAwGR(0x37, restore->PanelVertCenterReg5); VGAwGR(0x38, restore->PanelHorizCenterReg5); } - + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) + clock_hi = TRUE; + /* Program VCLK3 if needed. */ - if (restore->ProgramVCLK) { + if (restore->ProgramVCLK + && ((VGArGR(0x9B) != restore->VCLK3NumeratorLow) + || (VGArGR(0x9F) != restore->VCLK3Denominator) + || (clock_hi && ((VGArGR(0x8F) & ~0x0f) + != (restore->VCLK3NumeratorHigh & ~0x0F))))) { VGAwGR(0x9B, restore->VCLK3NumeratorLow); - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) { + if (clock_hi) { temp = VGArGR(0x8F); temp &= 0x0F; /* Save bits 3:0 */ temp |= (restore->VCLK3NumeratorHigh & ~0x0F); @@ -2220,8 +2223,11 @@ } VGAwGR(0x9F, restore->VCLK3Denominator); } - + if (restore->biosMode) + VGAwCR(0x23,restore->biosMode); + if (restore->reg) { + VGAwCR(0x23,restore->reg->CR[0x23]); VGAwCR(0x25,restore->reg->CR[0x25]); VGAwCR(0x2F,restore->reg->CR[0x2F]); for (i = 0x40; i <= 0x59; i++) { @@ -2240,12 +2246,10 @@ for (i = 0x90; i <= NEO_EXT_GR_MAX; i++) { VGAwGR(i, restore->reg->GR[i]); } - xfree(restore->reg); - restore->reg = NULL; } /* Program vertical extension register */ - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) { + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) { VGAwCR(0x70, restore->VerticalExt); } @@ -2259,11 +2263,11 @@ { NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); - int i; int hoffset, voffset; vgaHWPtr hwp = VGAHWPTR(pScrn); NeoRegPtr NeoNew = &nPtr->NeoModeReg; vgaRegPtr NeoStd = &hwp->ModeReg; + Bool noLcdStretch = nPtr->noLcdStretch; neoUnlock(pScrn); @@ -2271,6 +2275,7 @@ * This will allocate the datastructure and initialize all of the * generic VGA registers. */ + if (!vgaHWInit(pScrn, mode)) return(FALSE); @@ -2286,43 +2291,23 @@ */ NeoStd->Attribute[16] = 0x01; - switch (pScrn->bitsPerPixel) { + switch (pScrn->depth) { case 8 : NeoStd->CRTC[0x13] = pScrn->displayWidth >> 3; NeoNew->ExtCRTOffset = pScrn->displayWidth >> 11; NeoNew->ExtColorModeSelect = 0x11; break; case 15 : + NeoNew->ExtColorModeSelect = 0x12; + NeoStd->CRTC[0x13] = pScrn->displayWidth >> 2; + NeoNew->ExtCRTOffset = pScrn->displayWidth >> 10; + break; case 16 : - if ((pScrn->weight.red == 5) && - (pScrn->weight.green == 5) && - (pScrn->weight.blue == 5)) { - /* 15bpp */ - for (i = 0; i < 64; i++) { - NeoStd->DAC[i*3+0] = i << 1; - NeoStd->DAC[i*3+1] = i << 1; - NeoStd->DAC[i*3+2] = i << 1; - } - NeoNew->ExtColorModeSelect = 0x12; - } else { - /* 16bpp */ - for (i = 0; i < 64; i++) { - NeoStd->DAC[i*3+0] = i << 1; - NeoStd->DAC[i*3+1] = i; - NeoStd->DAC[i*3+2] = i << 1; - } - NeoNew->ExtColorModeSelect = 0x13; - } - /* 15bpp & 16bpp */ + NeoNew->ExtColorModeSelect = 0x13; NeoStd->CRTC[0x13] = pScrn->displayWidth >> 2; NeoNew->ExtCRTOffset = pScrn->displayWidth >> 10; break; case 24 : - for (i = 0; i < 256; i++) { - NeoStd->DAC[i*3+0] = i; - NeoStd->DAC[i*3+1] = i; - NeoStd->DAC[i*3+2] = i; - } NeoStd->CRTC[0x13] = (pScrn->displayWidth * 3) >> 3; NeoNew->ExtCRTOffset = (pScrn->displayWidth * 3) >> 11; NeoNew->ExtColorModeSelect = 0x14; @@ -2339,7 +2324,7 @@ | (((mode->CrtcVSyncStart) & 0x400) >> 8 ) | (((mode->CrtcVSyncStart) & 0x400) >> 7 ); - /* Disable read/write bursts if requested. */ + /* Fast write bursts on unless disabled. */ if (nPtr->onPciBurst) { NeoNew->SysIfaceCntl1 = 0x30; } else { @@ -2361,6 +2346,7 @@ if (nPtr->externDisp) { NeoNew->PanelDispCntlReg1 |= 0x01; } + #if 0 /* * This was replaced: if no devices are specified take the @@ -2412,15 +2398,23 @@ */ NeoNew->PanelDispCntlReg2 = 0x00; NeoNew->PanelDispCntlReg3 = 0x00; - if ((!nPtr->noLcdStretch) && + nAcl->NoCursorMode = FALSE; + + if ((!noLcdStretch) && (NeoNew->PanelDispCntlReg1 & 0x02)) { if (mode->HDisplay == nPtr->NeoPanelWidth) { /* + * Don't disable the flag. It will be needed if another mode + * is selected. + */ + /* * No stretching required when the requested display width * equals the panel width. */ - if (nPtr->NeoHWCursorInitialized) nAcl->UseHWCursor = TRUE; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Stretching disabled\n"); + noLcdStretch = TRUE; } else { + switch (mode->HDisplay) { case 320 : /* Needs testing. KEM -- 24 May 98 */ case 400 : /* Needs testing. KEM -- 24 May 98 */ @@ -2428,18 +2422,18 @@ case 800 : case 1024 : NeoNew->PanelDispCntlReg2 |= 0xC6; - if (nPtr->NeoHWCursorInitialized) nAcl->UseHWCursor = FALSE; + nAcl->NoCursorMode = TRUE; break; default : /* No stretching in these modes. */ - if (nPtr->NeoHWCursorInitialized) nAcl->UseHWCursor = TRUE; + xf86DrvMsg(pScrn->scrnIndex,X_INFO, + "Stretching disabled not supported in this mode\n"); + noLcdStretch = TRUE; break; } } } else if (mode->Flags & V_DBLSCAN) { - if (nPtr->NeoHWCursorInitialized) nAcl->UseHWCursor = FALSE; - } else { - if (nPtr->NeoHWCursorInitialized) nAcl->UseHWCursor = TRUE; + nAcl->NoCursorMode = TRUE; } /* @@ -2469,7 +2463,7 @@ NeoNew->PanelDispCntlReg3 |= 0x10; /* Calculate the horizontal and vertical offsets. */ - if (nPtr->noLcdStretch) { + if (noLcdStretch) { hoffset = ((nPtr->NeoPanelWidth - mode->HDisplay) >> 4) - 1; voffset = ((nPtr->NeoPanelHeight - mode->VDisplay) >> 1) - 2; } else { @@ -2506,7 +2500,8 @@ } } } - + NeoNew->biosMode = neoFindMode(mode->HDisplay,mode->VDisplay,pScrn->depth); + /* * New->reg should be empty. Just in * case it isn't, warn us and clear it anyway. @@ -2567,8 +2562,8 @@ } } - if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360 - || nPtr->NeoChipset == NM2380) { + if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230 + || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) { /* NOT_DONE: We are trying the full range of the 2200 clock. We should be able to try n up to 2047 */ nPtr->NeoModeReg.VCLK3NumeratorLow = n_best; @@ -2578,6 +2573,14 @@ nPtr->NeoModeReg.VCLK3NumeratorLow = n_best | (f_best << 7); } nPtr->NeoModeReg.VCLK3Denominator = d_best; +#ifdef DEBUG + ErrorF("neoVCLK: f:%f NumLow=%i NumHi=%i Den=%i Df=%f\n", + f_target, + nPtr->NeoModeReg.VCLK3NumeratorLow, + nPtr->NeoModeReg.VCLK3NumeratorHigh, + nPtr->NeoModeReg.VCLK3Denominator, + f_best_diff); +#endif } /* @@ -2596,7 +2599,7 @@ unsigned char LogicPowerMgmt = 0; unsigned char LCD_on = 0; - if (pScrn->vtSema) + if (!pScrn->vtSema) return; switch (PowerManagementMode) { @@ -2649,29 +2652,23 @@ neo_ddc1Read(ScrnInfoPtr pScrn) { register vgaHWPtr hwp = VGAHWPTR(pScrn); -#if 0 - register unsigned int ST01reg = ((NEOPtr)pScrn->driverPrivate)->vgaIOBase - + 0x0A; -#endif register unsigned int tmp; -#if 0 - while(inb(ST01reg)&0x8){}; - while(!(inb(ST01reg)&0x8)) {}; -#endif + /* This needs to be investigated: we may have to swap this around */ + while (!(hwp->readST01(hwp)&0x8)) {}; while (hwp->readST01(hwp)&0x8) {}; - while (!hwp->readST01(hwp)&0x8) {}; tmp = (VGArGR(0xA1) & 0x08); return (tmp); } -static void +static xf86MonPtr neo_ddc1(int scrnIndex) { vgaHWPtr hwp = VGAHWPTR(xf86Screens[scrnIndex]); unsigned int reg1, reg2, reg3; + xf86MonPtr ret; /* initialize chipset */ reg1 = VGArCR(0x21); @@ -2680,10 +2677,117 @@ VGAwCR(0x21,0x00); VGAwCR(0x1D,0x01); /* some Voodoo */ VGAwGR(0xA1,0x2F); - xf86SetDDCproperties(xf86Screens[scrnIndex],xf86PrintEDID( - xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeed,neo_ddc1Read))); + ret = xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeed,neo_ddc1Read); /* undo initialization */ VGAwCR(0x21,reg1); VGAwCR(0x1D,reg2); + return ret; } +static Bool +neoDoDDC1(ScrnInfoPtr pScrn) +{ + Bool ret = FALSE; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + VGAwGR(0x09,0x26); + ret = xf86SetDDCproperties(pScrn, + xf86PrintEDID(neo_ddc1(pScrn->scrnIndex))); + VGAwGR(0x09,0x00); + + return ret; +} + +static Bool +neoDoDDC2(ScrnInfoPtr pScrn) +{ + NEOPtr nPtr = NEOPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + Bool ret = FALSE; + + VGAwGR(0x09,0x26); + if (xf86LoadSubModule(pScrn, "i2c")) { + xf86LoaderReqSymLists(i2cSymbols, NULL); + if (neo_I2CInit(pScrn)) { + ret = xf86SetDDCproperties(pScrn,xf86PrintEDID(xf86DoEDID_DDC2( + pScrn->scrnIndex,nPtr->I2C))); + } + } + VGAwGR(0x09,0x00); + + return ret; +} + +static Bool +neoDoDDCVBE(ScrnInfoPtr pScrn) +{ + NEOPtr nPtr = NEOPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + vbeInfoPtr pVbe; + Bool ret = FALSE; + + VGAwGR(0x09,0x26); + if (xf86LoadSubModule(pScrn, "vbe")) { + if ((pVbe = VBEInit(NULL,nPtr->pEnt->index))) { + ret = xf86SetDDCproperties( + pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + vbeFree(pVbe); + } + } + VGAwGR(0x09,0x00); + return ret; +} + +static int +neoFindMode(int xres, int yres, int depth) +{ + int xres_s; + int i, size; + biosMode *mode; + + switch (depth) { + case 8: + size = sizeof(bios8) / sizeof(biosMode); + mode = bios8; + break; + case 15: + size = sizeof(bios15) / sizeof(biosMode); + mode = bios15; + break; + case 16: + size = sizeof(bios16) / sizeof(biosMode); + mode = bios16; + break; + case 24: + size = sizeof(bios24) / sizeof(biosMode); + mode = bios24; + break; + default: + return 0; + } + + for (i = 0; i < size; i++) { + if (xres <= mode[i].x_res) { + xres_s = mode[i].x_res; + for (; i < size; i++) { + if (mode[i].x_res != xres_s) + return mode[i-1].mode; + if (yres <= mode[i].y_res) + return mode[i].mode; + } + } + } + return mode[size - 1].mode; + +} + +static void +neoProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c:1.2 Sun Jun 27 10:08:10 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c Fri Nov 3 13:46:11 2000 @@ -22,7 +22,7 @@ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **********************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c,v 1.2 1999/06/27 14:08:10 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c,v 1.3 2000/11/03 18:46:11 eich Exp $ */ /* * The original Precision Insight driver for @@ -89,6 +89,9 @@ I2CPtr->scrnIndex = pScrn->scrnIndex; I2CPtr->I2CPutBits = neo_I2CPutBits; I2CPtr->I2CGetBits = neo_I2CGetBits; + /* increase these as the defaults are too low */ + I2CPtr->RiseFallTime = 2; + I2CPtr->HoldTime = 40; if (!xf86I2CBusInit(I2CPtr)) return FALSE; Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c:1.1 Tue Feb 8 08:13:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c Fri Nov 3 13:46:11 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c,v 1.1 2000/02/08 13:13:18 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_shadow.c,v 1.2 2000/11/03 18:46:11 eich Exp $ */ /* Copyright (c) 1999, 2000 The XFree86 Project Inc. @@ -15,6 +15,15 @@ #include "servermd.h" #include "neo.h" +void +neoShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage) +{ + ScrnInfoPtr pScrn; + pScrn = xf86Screens[pScreen->myNum]; + + (NEOPTR(pScrn))->refreshArea (pScrn, REGION_NUM_RECTS(damage), + REGION_RECTS(damage)); +} void neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) Index: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp:1.4 Tue Jun 13 22:13:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp Thu Dec 14 03:11:15 2000 @@ -1,9 +1,9 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp,v 1.4 2000/06/14 02:13:12 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp,v 1.7 2000/12/14 08:11:15 herrb Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH NEOMAGIC __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH NEOMAGIC __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME -neomagic \- NeoMagic video driver +neomagic \- Neomagic video driver .SH SYNOPSIS .nf .B "Section \*qDevice\*q" @@ -14,17 +14,77 @@ .fi .SH DESCRIPTION .B neomagic -is an XFree86 driver for NeoMagic video chips. -THIS MAN PAGE NEEDS TO BE FILLED IN. +is an XFree86 driver for the Neomagic graphics chipsets found in many +laptop computers. .SH SUPPORTED HARDWARE -The .B neomagic -driver supports... +supports the following chipsets: +.PP +.TP +MagicGraph 128 (NM2070) +.TP +MagicGraph 128V (NM2090) +.TP +MagicGraph 128ZV (NM2093) +.TP +MagicGraph 128ZV+ (NM2097) +.TP +MagicGraph 128XD (NM2160) +.TP +MagicGraph 256AV (NM2200) +.TP +MagicGraph 256AV+ (NM2230) +.TP +MagicGraph 256ZX (NM2360) +.TP +MagicGraph 256XL+ (NM2380) +.PP +The driver supports depths 8, 15, 16 and 24 for all chipsets except the +NM2070 which does not support depth 24. All depths are accelerated except for +depth 24 which is only accelerated on NM2200 +and newer models. All visuals are supported in depth 8. TrueColor and +DirectColor visuals are supported in the other depths. + .SH CONFIGURATION DETAILS Please refer to XF86Config(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this driver. +.PP +The following driver +.B Options +are supported +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Disable or enable acceleration. Default: acceleration is enabled. +.TP +.BI "Option \*qSWCursor\*q \*q" boolean \*q +Disable or enable software cursor. Default: software cursor is disable +and a hardware cursor is used. +.TP +.BI "Option \*qPCIBurst\*q \*q" boolean \*q +Disable or enable PCI burst modes. Default: enabled. +.TP +.BI "Option \*qRotate\*q \*qCW\*q" +.TP +.BI "Option \*qRotate\*q \*qCCW\*q" +Rotate the display clockwise or counterclockwise. This mode is unaccelerated. +Default: no rotation. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. See +shadowfb(__drivermansuffix__) for further information. Default: off. +.PP +.B Note +.br +On some laptops using the 2160 chipset (MagicGraph 128XD) the +following options are needed to avoid a lock-up of the graphic engine: +.nf + Option "XaaNoScanlineImageWriteRect" + Option "XaaNoScanlineCPUToScreenColorExpandFill" +.fi + .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) .SH AUTHORS -Authors include: ... +Authors include: Jens Owen, Kevin E. Martin, and also Egbert Eich, +Mark Vojkovich, Alan Hourihane. Index: xc/programs/Xserver/hw/xfree86/drivers/newport/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/Imakefile:1.2 --- /dev/null Mon Dec 18 14:30:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/Imakefile Thu Dec 14 15:59:12 2000 @@ -0,0 +1,52 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/Imakefile,v 1.2 2000/12/14 20:59:12 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = newport_driver.c newport_regs.c newport_cmap.c newport_shadow.c + +OBJS = newport_driver.o newport_regs.o newport_cmap.o newport_shadow.o + +XF86CONFIG = XF86Config.indy + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. \ + -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb \ + -I$(SERVERSRC)/mfb -I$(XF86SRC)/shadowfb \ + -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \ + -I$(XF86SRC)/xf24_32bpp \ + -I$(EXTINCSRC) -I$(SERVERSRC)/Xext -I$(SERVERSRC)/render \ + -I$(SERVERSRC)/include -I$(FONTINCSRC) -I$(XINCLUDESRC) +#endif + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget(newport,$(OBJS)) + +InstallObjectModule(newport,$(MODULEDIR),drivers) +InstallNamedNonExec($(XF86CONFIG),$(XF86CONFIG),$(LIBDIR)) + +#if !defined(XF86DriverSDK) +CppManTarget(newport,) +InstallModuleManPage(newport) +#endif + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport_driver.c,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport_regs.c,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport_cmap.c,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport_shadow.c,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport_regs.h,$(DRIVERSDKDIR)/drivers/newport) +InstallDriverSDKNonExecFile(newport.h,$(DRIVERSDKDIR)/drivers/newport) + +InstallDriverSDKObjectModule(newport,$(DRIVERSDKMODULEDIR),drivers) + Index: xc/programs/Xserver/hw/xfree86/drivers/newport/XF86Config.indy diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/XF86Config.indy:1.2 --- /dev/null Mon Dec 18 14:30:56 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/XF86Config.indy Thu Dec 14 15:59:12 2000 @@ -0,0 +1,319 @@ +# Id: XF86Config.indy,v 1.2 2000/08/14 17:07:37 agx Exp $ +# +# Copyright (c) 1994-1998 by The XFree86 Project, Inc. +# +# modified for the SGI Indy by Guido Guenther <guido.guenther@gmx.net> +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# Except as contained in this notice, the name of the XFree86 Project shall +# not be used in advertising or otherwise to promote the sale, use or other +# dealings in this Software without prior written authorization from the +# XFree86 Project. +# +# $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/XF86Config.indy,v 1.2 2000/12/14 20:59:12 dawes Exp $ + +# ********************************************************************** +# This is a configuration file for the Indy's Newport Graphics and the +# SGI GDM17E11 Monitor +# ********************************************************************** + +# The ordering of sections is not important in version 4.0 and later. + +# ********************************************************************** +# Files section. This allows default font and rgb paths to be set +# ********************************************************************** + +Section "Files" + +# The location of the RGB database. Note, this is the name of the +# file minus the extension (like ".txt" or ".db"). There is normally +# no need to change the default. + + RgbPath "/usr/X11R6/lib/X11/rgb" + +# Multiple FontPath entries are allowed (which are concatenated together), +# as well as specifying multiple comma-separated entries in one FontPath +# command (or a combination of both methods) + + FontPath "/usr/X11R6/lib/X11/fonts/local/" + FontPath "/usr/X11R6/lib/X11/fonts/misc/" + FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled" + FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled" + FontPath "/usr/X11R6/lib/X11/fonts/Type1/" + FontPath "/usr/X11R6/lib/X11/fonts/CID/" + FontPath "/usr/X11R6/lib/X11/fonts/Speedo/" + FontPath "/usr/X11R6/lib/X11/fonts/75dpi/" + FontPath "/usr/X11R6/lib/X11/fonts/100dpi/" + +# ModulePath can be used to set a search path for the X server modules. +# The default path is shown here. + +# ModulePath "/usr/X11R6/lib/modules" + +EndSection + +# ********************************************************************** +# Module section -- this is an optional section which is used to specify +# which run-time loadable modules to load when the X server starts up. +# ********************************************************************** + +Section "Module" + +# This loads the DBE extension module. + + Load "dbe" + +# This loads the miscellaneous extensions module, and disables +# initialisation of the XFree86-DGA extension within that module. + + SubSection "extmod" + Option "omit xfree86-dga" + EndSubSection + +# This loads the Type1 and FreeType font modules + + Load "type1" + Load "freetype" + +EndSection + + +# ********************************************************************** +# Server flags section. This contains various server-wide Options. +# ********************************************************************** + +Section "ServerFlags" + +# Uncomment this to cause a core dump at the spot where a signal is +# received. This may leave the console in an unusable state, but may +# provide a better stack trace in the core dump to aid in debugging + +# Option "NoTrapSignals" + +# Uncomment this to disable the <Crtl><Alt><BS> server abort sequence +# This allows clients to receive this key event. + +# Option "DontZap" + +# Uncomment this to disable the <Crtl><Alt><KP_+>/<KP_-> mode switching +# sequences. This allows clients to receive these key events. + +# Option "DontZoom" + +# Uncomment this to disable tuning with the xvidtune client. With +# it the client can still run and fetch card and monitor attributes, +# but it will not be allowed to change them. If it tries it will +# receive a protocol error. + +# Option "DisableVidModeExtension" + +# Uncomment this to enable the use of a non-local xvidtune client. + +# Option "AllowNonLocalXvidtune" + +# Uncomment this to disable dynamically modifying the input device +# (mouse and keyboard) settings. + +# Option "DisableModInDev" + +# Uncomment this to enable the use of a non-local client to +# change the keyboard or mouse settings (currently only xset). + +# Option "AllowNonLocalModInDev" + +# Set the basic blanking screen saver timeout. + + Option "blank time" "10" # 10 minutes + +# Set the DPMS timeouts. These are set here because they are global +# rather than screen-specific. These settings alone don't enable DPMS. +# It is enabled per-screen (or per-monitor), and even then only when +# the driver supports it. + + Option "standby time" "20" + Option "suspend time" "30" + Option "off time" "60" + +# On some platform the server needs to estimate the sizes of PCI +# memory and pio ranges. This is done by assuming that PCI ranges +# don't overlap. Some broken BIOSes tend to set ranges of inactive +# devices wrong. Here one can adjust how aggressive the assumptions +# should be. Default is 0. + +# Option "EstimateSizesAggresively" "0" + +EndSection + +# ********************************************************************** +# Input devices +# ********************************************************************** + +# ********************************************************************** +# Core keyboard's InputDevice section +# ********************************************************************** + +Section "InputDevice" + + Identifier "Keyboard1" + Driver "keyboard" + +# For most OSs the protocol can be omitted (it defaults to "Standard"). +# When using XQUEUE (only for SVR3 and SVR4, but not Solaris), comment +# out the above line, and uncomment the following line. + +# Option "Protocol" "Xqueue" + +# Set the keyboard auto repeat parameters. Not all platforms implement +# this. + + Option "AutoRepeat" "500 5" + +# Specifiy which keyboard LEDs can be user-controlled (eg, with xset(1)). + +# Option "Xleds" "1 2 3" + +# To disable the XKEYBOARD extension, uncomment XkbDisable. + +# Option "XkbDisable" + +# To customise the XKB settings to suit your keyboard, modify the +# lines below (which are the defaults). For example, for a European +# keyboard, you will probably want to use one of: +# +# Option "XkbModel" "pc102" +# Option "XkbModel" "pc105" +# +# If you have a Microsoft Natural keyboard, you can use: +# +# Option "XkbModel" "microsoft" +# +# If you have a US "windows" keyboard you will want: +# +# Option "XkbModel" "pc104" +# +# Then to change the language, change the Layout setting. +# For example, a german layout can be obtained with: +# +# Option "XkbLayout" "de" +# +# or: +# +# Option "XkbLayout" "de" +# Option "XkbVariant" "nodeadkeys" +# +# If you'd like to switch the positions of your capslock and +# control keys, use: +# +# Option "XkbOptions" "ctrl:swapcaps" + + +# These are the default XKB settings for XFree86 +# +# Option "XkbRules" "xfree86" +# Option "XkbModel" "pc101" +# Option "XkbLayout" "us" +# Option "XkbVariant" "" +# Option "XkbOptions" "" + +EndSection + + +# ********************************************************************** +# Core Pointer's InputDevice section +# ********************************************************************** + +Section "InputDevice" + +# Identifier and driver + + Identifier "Mouse1" + Driver "mouse" + + Option "Protocol" "PS/2" + Option "Device" "/dev/psaux" +# Option "SampleRate" "80" + +EndSection + +# ********************************************************************** +# Monitor section +# ********************************************************************** + +# Any number of monitor sections may be present + +Section "Monitor" + +# The identifier line must be present. + + Identifier "SGI GDM17e11" + +# This Information can be found at http://www.si87.com/ + + HorizSync 30-82 # multiple ranges of sync frequencies + VertRefresh 50-120 # typical for a single frequency fixed-sync monitor + +# A single modeline is sufficient, we don't use it at all: + ModeLine "1280x1024@70Hz" 130 1280 1320 1480 1728 1024 1029 1036 1077 + +EndSection + +# ********************************************************************** +# Graphics device section +# ********************************************************************** + +Section "Device" + Identifier "Newport Graphics" + Driver "newport" + +# Option "bitplanes" "24" +EndSection + +# ********************************************************************** +# Screen sections. +# ********************************************************************** + +# Any number of screen sections may be present. Each describes +# the configuration of a single screen. A single specific screen section +# may be specified from the X server command line with the "-screen" +# option. + +Section "Screen" + Identifier "Screen 1" + Device "Newport Graphics" + Monitor "SGI GDM17e11" + DefaultDepth 8 + + SubSection "Display" + Depth 8 + Modes "1280x1024" + EndSubSection +EndSection + +# ********************************************************************** +# ServerLayout sections. +# ********************************************************************** + +Section "ServerLayout" + Identifier "simple layout" + Screen "Screen 1" + InputDevice "Mouse1" "CorePointer" + InputDevice "Keyboard1" "CoreKeyboard" +EndSection + Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport.cpp:1.1 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport.cpp Thu Dec 14 15:59:12 2000 @@ -0,0 +1,40 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport.cpp,v 1.1 2000/12/14 20:59:12 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH NEWPORT __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +newport \- Newport video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qnewport\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B newport +is an XFree86 driver for the SGI Indy's newport video cards. +.SH SUPPORTED HARDWARE +The +.B newport +driver supports the Newport(sometimes called XL) cards found in SGI Indys. It +does not support the XZ boards. The driver is currently limited to 8bit only. +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The driver auto-detects all device information necessary to initialize +the card. However, if you have problems with auto-detection, you can +specify: +.br +.TP +.BI "Option \*qbitplanes\*q \*q" integer \*q +number of bitplanes of the board (8 or 24) +Default: auto-detected. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +Authors: +Guido Guenther \fIguido.guenther@gmx.net\fP Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport.h:1.2 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport.h Wed Dec 6 17:00:46 2000 @@ -0,0 +1,74 @@ +/* + * Id: newport.h,v 1.4 2000/11/29 20:58:10 agx Exp $ + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport.h,v 1.2 2000/12/06 22:00:46 dawes Exp $ */ + +#ifndef __NEWPORT_H__ +#define __NEWPORT_H__ + +/* + * All drivers should include these: + */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Resources.h" + +#include "xf86cmap.h" + +/* xaa & hardware cursor */ +#include "xaa.h" +#include "xf86Cursor.h" + +/* register definitions of the Newport card */ +#include "newport_regs.h" + +#define NEWPORT_BASE_ADDR0 0x1f0f0000 +#define NEWPORT_BASE_OFFSET 0x0040000 +#define NEWPORT_MAX_BOARDS 4 + +typedef struct { + unsigned busID; + int bitplanes; + /* revision numbers of the various pieces of silicon */ + unsigned int board_rev, cmap_rev, rex3_rev, xmap9_rev, bt445_rev; + NewportRegsPtr pNewportRegs; /* Pointer to REX3 registers */ + npireg_t drawmode1; /* REX3 drawmode1 common to all drawing operations */ + + /* ShadowFB stuff: */ + pointer ShadowPtr; + unsigned long int ShadowPitch; + unsigned int Bpp; /* Bytes per pixel */ + + /* wrapped funtions: */ + CloseScreenProcPtr CloseScreen; + + /* newport register backups: */ + npireg_t txt_drawmode1; /* Rex3 drawmode1 register */ + unsigned short txt_vc2ctrl; /* VC2 control register */ + CARD8 txt_xmap9_cfg0; /* 0. Xmap9's control register */ + CARD8 txt_xmap9_cfg1; /* 1. Xmap9's control register */ + CARD8 txt_xmap9_mi; /* Xmap9's mode index register */ + LOCO txt_colormap[256]; +} NewportRec, *NewportPtr; + +#define NEWPORTPTR(p) ((NewportPtr)((p)->driverPrivate)) +#define NEWPORTREGSPTR(p) ((NEWPORTPTR(p))->pNewportRegs) + +/* Newport_regs.c */ +unsigned short NewportVc2Get(NewportRegsPtr, unsigned char vc2Ireg); +void NewportVc2Set(NewportRegsPtr pNewportRegs, unsigned char vc2Ireg, unsigned short val); +void NewportWait(NewportRegsPtr pNewportRegs); +void NewportBfwait(NewportRegsPtr pNewportRegs); +void NewportXmap9SetModeRegister(NewportRegsPtr pNewportRegs, CARD8 address, CARD32 mode); + +/* newort_cmap.c */ +void NewportLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO* colors, VisualPtr pVisual); +void NewportRestorePalette(ScrnInfoPtr pScrn); +void NewportBackupPalette(ScrnInfoPtr pScrn); + +/* newport_shadow.c */ +void NewportRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); + +#endif /* __NEWPORT_H__ */ Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_cmap.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport_cmap.c:1.1 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport_cmap.c Fri Dec 1 14:47:59 2000 @@ -0,0 +1,80 @@ +/* + * Id: newport_cmap.c,v 1.1 2000/11/29 20:58:10 agx Exp $ + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_cmap.c,v 1.1 2000/12/01 19:47:59 dawes Exp $ */ + +#include "newport.h" + +static void NewportCmapSetRGB( NewportRegsPtr pNewportRegs, unsigned short addr, LOCO color); +static void NewportCmapGetRGB( NewportRegsPtr pNewportRegs, unsigned short addr, LOCO *color); + +/* Load a colormap into the hardware */ +void NewportLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, \ + LOCO* colors, VisualPtr pVisual) +{ + int i,index; + NewportRegsPtr pNewportRegs = NEWPORTPTR(pScrn)->pNewportRegs; + + for(i = 0; i < numColors; i++) { + index=indices[i]; + NewportBfwait(pNewportRegs); + NewportCmapSetRGB(pNewportRegs, index, colors[index]); + } +} + +void NewportBackupPalette(ScrnInfoPtr pScrn) +{ + int i; + NewportPtr pNewport = NEWPORTPTR(pScrn); + + NewportWait(pNewport->pNewportRegs); + for(i = 0; i < 256; i++) { + NewportCmapGetRGB(pNewport->pNewportRegs, i, &(pNewport->txt_colormap[i])); + } +} + +/* restore the default colormap */ +void NewportRestorePalette(ScrnInfoPtr pScrn) +{ + int i; + NewportPtr pNewport = NEWPORTPTR(pScrn); + + for(i = 0; i < 256; i++) { + NewportCmapSetRGB(pNewport->pNewportRegs, i, pNewport->txt_colormap[i]); + } +} + +/* set the colormap entry at addr to color */ +static void NewportCmapSetRGB( NewportRegsPtr pNewportRegs, unsigned short addr, LOCO color) +{ + NewportWait(pNewportRegs); /* this one should not be necessary */ + NewportBfwait(pNewportRegs); + pNewportRegs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL | + NPORT_DMODE_SENDIAN | NPORT_DMODE_ECINC | + NCMAP_REGADDR_AREG | NPORT_DMODE_W2); + pNewportRegs->set.dcbdata0.hwords.s1 = addr; + pNewportRegs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL | + NCMAP_REGADDR_PBUF | NPORT_DMODE_W3); + pNewportRegs->set.dcbdata0.all = (color.red << 24) | + (color.green << 16) | + (color.blue << 8); +} + +/* get the colormap entry at addr */ +static void NewportCmapGetRGB( NewportRegsPtr pNewportRegs, unsigned short addr, LOCO* color) +{ + npireg_t tmp; + + NewportBfwait(pNewportRegs); + pNewportRegs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL | + NPORT_DMODE_SENDIAN | NPORT_DMODE_ECINC | + NCMAP_REGADDR_AREG | NPORT_DMODE_W2); + pNewportRegs->set.dcbdata0.hwords.s1 = addr; + pNewportRegs->set.dcbmode = (NPORT_DMODE_ACMALL | NCMAP_PROTOCOL | + NCMAP_REGADDR_PBUF | NPORT_DMODE_W3); + tmp = pNewportRegs->set.dcbdata0.all; + color->red = (tmp >> 24) & 0xff; + color->green = (tmp >> 16) & 0xff; + color->blue = (tmp >> 8) & 0xff; +} + Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport_driver.c:1.6 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport_driver.c Thu Dec 14 15:59:12 2000 @@ -0,0 +1,762 @@ +/* + * Id: newport_driver.c,v 1.2 2000/11/29 20:58:10 agx Exp $ + * + * Driver for the SGI Indy's Newport graphics card + * + * This driver is based on the newport.c & newport_con.c kernel code + * + * (c) 2000 Guido Guenther <guido.guenther@gmx.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is fur- + * nished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- + * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + * ings in this Software without prior written authorization from the XFree86 + * Project. + * + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_driver.c,v 1.6 2000/12/14 20:59:12 dawes Exp $ */ + +/* function prototypes, common data structures & generic includes */ +#include "newport.h" + +/* Drivers using the mi SW cursor need: */ +#include "mipointer.h" +/* Drivers using the mi implementation of backing store need: */ +#include "mibstore.h" +/* Drivers using the mi colourmap code need: */ +#include "micmap.h" + +/* Drivers using cfb need: */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb24.h" +#include "cfb24_32.h" + +/* Drivers using the shadow frame buffer need: */ +#include "shadowfb.h" + +/* Xv Extension */ +#include "xf86xv.h" +#include "Xv.h" + +/* Temporary workaround. A module really shouldn't need this */ +#ifndef XFree86LOADER +# include "xf86_OSlib.h" +# ifndef MAP_FAILED +# define MAP_FAILED ((pointer)(-1)) +# endif +#endif + +#define VERSION 4000 +#define NEWPORT_NAME "Newport" +#define NEWPORT_DRIVER_NAME "newport" +#define NEWPORT_MAJOR_VERSION 0 +#define NEWPORT_MINOR_VERSION 1 +#define NEWPORT_PATCHLEVEL 1 + + +/* Prototypes ------------------------------------------------------- */ +static void NewportIdentify(int flags); +static OptionInfoPtr NewportAvailableOptions(int chipid, int busid); +static Bool NewportProbe(DriverPtr drv, int flags); +static Bool NewportPreInit(ScrnInfoPtr pScrn, int flags); +static Bool NewportScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); +static Bool NewportEnterVT(int scrnIndex, int flags); +static void NewportLeaveVT(int scrnIndex, int flags); +static Bool NewportCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool NewportSaveScreen(ScreenPtr pScreen, int mode); +static unsigned NewportHWProbe(unsigned probedIDs[]); /* return number of found boards */ +static Bool NewportModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void NewportRestore(ScrnInfoPtr pScrn, Bool Closing); +static Bool NewportGetRec(ScrnInfoPtr pScrn); +static Bool NewportFreeRec(ScrnInfoPtr pScrn); +static Bool NewportMapRegs(ScrnInfoPtr pScrn); +static void NewportUnmapRegs(ScrnInfoPtr pScrn); +static Bool NewportProbeCardInfo(ScrnInfoPtr pScrn); +/* ------------------------------------------------------------------ */ + +DriverRec NEWPORT = { + VERSION, + NEWPORT_DRIVER_NAME, + NewportIdentify, + NewportProbe, + NewportAvailableOptions, + NULL, + 0 +}; + +/* Supported "chipsets" */ +#define CHIP_XL 0x1 + +static SymTabRec NewportChipsets[] = { + { CHIP_XL, "XL" }, + {-1, NULL } +}; + +/* List of Symbols from other modules that this module references */ + +static const char *cfbSymbols[] = { + "cfbScreenInit", + NULL +}; + +static const char *shadowSymbols[] = { + "ShadowFBInit", + NULL +}; + +#ifdef XFree86LOADER + +static MODULESETUPPROTO(newportSetup); + +static XF86ModuleVersionInfo newportVersRec = +{ + "newport", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + NEWPORT_MAJOR_VERSION, NEWPORT_MINOR_VERSION, NEWPORT_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} +}; + +XF86ModuleData newportModuleData = { &newportVersRec, newportSetup, NULL }; + +static pointer +newportSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + +/* This module should be loaded only once, but check to be sure. */ + if (!setupDone) { + /* + * Modules that this driver always requires may be loaded + * here by calling LoadSubModule(). + */ + setupDone = TRUE; + xf86AddDriver(&NEWPORT, module, 0); + + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + * + */ + LoaderRefSymLists( cfbSymbols, shadowSymbols, NULL); + + + /* + * The return value must be non-NULL on success even though + * there is no TearDownProc. + */ + return (pointer)1; + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + +typedef enum { + OPTION_BITPLANES, + OPTION_BUS_ID +} NewportOpts; + +/* Supported options */ +static OptionInfoRec NewportOptions [] = { + { OPTION_BITPLANES, "bitplanes", OPTV_INTEGER, {0}, FALSE }, + { OPTION_BUS_ID, "BusID", OPTV_INTEGER, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +/* ------------------------------------------------------------------ */ + +static Bool +NewportGetRec(ScrnInfoPtr pScrn) +{ + NewportPtr pNewport; + if (pScrn->driverPrivate != NULL) + return TRUE; + pScrn->driverPrivate = xnfcalloc(sizeof(NewportRec), 1); + + pNewport = NEWPORTPTR(pScrn); + pNewport->pNewportRegs = NULL; + + return TRUE; +} + +static Bool +NewportFreeRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate == NULL) + return TRUE; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; + return TRUE; +} + +static void +NewportIdentify(int flags) +{ + xf86PrintChipsets( NEWPORT_NAME, "driver for Newport Graphics Card", NewportChipsets); +} + +static Bool +NewportProbe(DriverPtr drv, int flags) +{ + int numDevSections, numUsed, i, j, busID; + Bool foundScreen = FALSE; + GDevPtr *devSections; + GDevPtr dev = NULL; + resRange range[] = { {ResExcMemBlock ,0,0}, _END }; + unsigned probedIDs[NEWPORT_MAX_BOARDS]; + memType base; + + if ((numDevSections = xf86MatchDevice(NEWPORT_DRIVER_NAME, &devSections)) <= 0) + return FALSE; + numUsed = NewportHWProbe(probedIDs); + if ( numUsed <= 0 ) + return FALSE; + + if(flags & PROBE_DETECT) + foundScreen = TRUE; + else { + for (i = 0; i < numDevSections; i++) { + dev = devSections[i]; + busID = xf86SetIntOption(dev->options, "BusID", 0); + + for( j = 0; j < numUsed; j++) { + if ( busID == probedIDs[j] ) { + int entity; + ScrnInfoPtr pScrn = NULL; + + /* This is a hack because don't have the RAC info(and don't want it). + * Set it as an ISA entity to get the entity field set up right. + */ + entity = xf86ClaimIsaSlot(drv, 0, dev, TRUE); + base = (NEWPORT_BASE_ADDR0 + busID * NEWPORT_BASE_OFFSET); + RANGE(range[0], base, base + sizeof(NewportRegs),\ + ResExcMemBlock); + pScrn = xf86ConfigIsaEntity(pScrn, 0, entity, NULL, range, \ + NULL, NULL, NULL, NULL); + /* Allocate a ScrnInfoRec */ + pScrn->driverVersion = VERSION; + pScrn->driverName = NEWPORT_DRIVER_NAME; + pScrn->name = NEWPORT_NAME; + pScrn->Probe = NewportProbe; + pScrn->PreInit = NewportPreInit; + pScrn->ScreenInit = NewportScreenInit; + pScrn->EnterVT = NewportEnterVT; + pScrn->LeaveVT = NewportLeaveVT; + pScrn->driverPrivate = (void*)busID; + foundScreen = TRUE; + break; + } + } + } + } + xfree(devSections); + return foundScreen; +} + +/* most of this is from DESIGN.TXT s20.3.6 */ +static Bool +NewportPreInit(ScrnInfoPtr pScrn, int flags) +{ + int i, busID; + NewportPtr pNewport; + MessageType from; + ClockRangePtr clockRanges; + char *mod=0, *reqSym=0; + + if (flags & PROBE_DETECT) return FALSE; + + if (pScrn->numEntities != 1) + return FALSE; + + busID = (int)(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; + + /* Fill in the monitor field */ + pScrn->monitor = pScrn->confScreen->monitor; + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, + Support24bppFb | SupportConvert32to24 | + PreferConvert32to24 )) + return FALSE; + + switch( pScrn->depth ) { + /* check if the returned depth is one we support */ + case 8: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by Newport driver\n", + pScrn->depth); + return FALSE; + } + xf86PrintDepthBpp(pScrn); + + /* Set bits per RGB for 8bpp */ + if( pScrn->depth == 8) + pScrn->rgbBits = 8; + + /* Set Default Weight */ + if( pScrn->depth > 8 ) { + rgb zeros = {0, 0, 0}; + if (!xf86SetWeight(pScrn, zeros, zeros)) + return FALSE; + } + + if (!xf86SetDefaultVisual(pScrn, -1)) { + return FALSE; + } else { + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" + " (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + } + + { /* Set default Gamma */ + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } + } + + /* Allocate the NewportRec driverPrivate */ + if (!NewportGetRec(pScrn)) { + return FALSE; + } + pNewport = NEWPORTPTR(pScrn); + pNewport->busID = busID; + + /* We use a programamble clock */ + pScrn->progClock = TRUE; + + /* Fill in pScrn->options) */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NewportOptions); + + /* Set fields in ScreenInfoRec && NewportRec */ + pScrn->videoRam = 1280 * (pScrn->bitsPerPixel >> 3); + + /* get revisions of REX3, etc. */ + if( ! NewportMapRegs(pScrn)) + return FALSE; + NewportProbeCardInfo(pScrn); + NewportUnmapRegs(pScrn); + + from=X_PROBED; + xf86DrvMsg(pScrn->scrnIndex, from, + "Newport Graphics Revisions: Board: %d, Rex3: %d, Cmap: %c, Xmap9: %d\n", + pNewport->board_rev, pNewport->rex3_rev, + pNewport->cmap_rev, pNewport->xmap9_rev); + + if ( (xf86GetOptValInteger(NewportOptions, OPTION_BITPLANES, &pNewport->bitplanes))) + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, from, "Newport has %d bitplanes\n", pNewport->bitplanes); + + if ( pScrn->depth > pNewport->bitplanes ) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "Display depth(%d) > number of bitplanes on Newport board(%d)\n", \ + pScrn->depth, pNewport->bitplanes); + return FALSE; + } + if ( ( pNewport->bitplanes != 8 ) && ( pNewport->bitplanes != 24 ) ) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "Number of bitplanes on newport must be either 8 or 24 not %d\n", \ + pNewport->bitplanes); + return FALSE; + } + + /* Set up clock ranges that are alway ok */ + /* XXX: Should use the correct data from the specs(which specs?) here */ + clockRanges = xnfalloc(sizeof(ClockRange)); + clockRanges->next = NULL; + clockRanges->minClock = 10000; + clockRanges->maxClock = 300000; + clockRanges->clockIndex = -1; /* programmable */ + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = TRUE; + + /* see above note */ + /* There is currently only an 1280x1024 mode */ + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, + NULL, 256, 2048, + pScrn->bitsPerPixel, 128, 2048, + pScrn->display->virtualX, + pScrn->display->virtualY, + pScrn->videoRam * 1024, + LOOKUP_BEST_REFRESH); + + if (i == -1) { + NewportFreeRec(pScrn); + return FALSE; + } + + xf86PruneDriverModes(pScrn); + if( i == 0 || pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + NewportFreeRec(pScrn); + return FALSE; + } + + /* unnecessary, but do it to get a valid ScrnInfoRec */ + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); + + /* Set the current mode to the first in the list */ + pScrn->currentMode = pScrn->modes; + + /* Print the list of modes being used */ + xf86PrintModes(pScrn); + xf86SetDpi (pScrn, 0, 0); + + switch(pScrn->bitsPerPixel) { + case 8: + mod = "cfb"; + reqSym = "cfbScreenInit"; + break; + } + if ( mod && (!xf86LoadSubModule(pScrn, mod))) { + NewportFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols( reqSym, NULL); + + /* Load ShadowFB module */ + if (!xf86LoadSubModule(pScrn, "shadowfb")) { + NewportFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(shadowSymbols, NULL); + + return TRUE; +} + +static Bool +NewportScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn; + NewportPtr pNewport; + VisualPtr visual; + BOOL ret; + int i; + + /* First get a pointer to our private info */ + pScrn = xf86Screens[pScreen->myNum]; + pNewport = NEWPORTPTR(pScrn); + + /* map the Newportregs until the server dies */ + if( ! NewportMapRegs(pScrn)) + return FALSE; + + /* Reset visual list. */ + miClearVisualTypes(); + + if (!miSetVisualTypes(pScrn->depth, pScrn->depth != 8 ? TrueColorMask : + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + pNewport->Bpp = pScrn->bitsPerPixel >> 3; + /* Setup the stuff for the shadow framebuffer */ + pNewport->ShadowPitch = (( pScrn->virtualX * pNewport->Bpp ) + 3) & ~3L; + pNewport->ShadowPtr = xnfalloc(pNewport->ShadowPitch * pScrn->virtualY); + + if (!NewportModeInit(pScrn, pScrn->currentMode)) + return FALSE; + + switch( pScrn->bitsPerPixel) { + case 8: + ret=cfbScreenInit(pScreen, pNewport->ShadowPtr, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; + default: + xf86Msg(X_ERROR, + "Internal Error: Display depth not supported in NewportScreenInit.\n"); + ret=FALSE; + break; + } + + if(!ret) + return FALSE; + + /* we need rgb ordering if bitsPerPixel > 8 */ + if (pScrn->bitsPerPixel > 8) { + for (i = 0, visual = pScreen->visuals; + i < pScreen->numVisuals; i++, visual++) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + xf86SetBlackWhitePixels(pScreen); + + /* Initialize software cursor */ + if(!miDCInitialize(pScreen, xf86GetPointerScreenFuncs())) + return FALSE; + + /* Initialise default colourmap */ + if (!miCreateDefColormap(pScreen)) + return FALSE; + + /* Install our LoadPalette funciton */ + if(!xf86HandleColormaps(pScreen, 256, 8, NewportLoadPalette, 0, + CMAP_RELOAD_ON_MODE_SWITCH )) + return FALSE; + + /* Initialise shadow frame buffer */ + ShadowFBInit(pScreen, &NewportRefreshArea8); + +#ifdef XvExtension + { + XF86VideoAdaptorPtr *ptr; + int n; + + n = xf86XVListGenericAdaptors(pScrn,&ptr); + if (n) { + xf86XVScreenInit(pScreen, ptr, n); + } + } +#endif + + + pScreen->SaveScreen = NewportSaveScreen; + /* Wrap the current CloseScreen function */ + pNewport->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = NewportCloseScreen; + + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + } + + return TRUE; +} + +/* called when switching away from a VT */ +static Bool +NewportEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + return NewportModeInit(pScrn, pScrn->currentMode); +} + +/* called when switching to a VT */ +static void +NewportLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NewportRestore(pScrn, FALSE); +} + +/* called at the end of each server generation */ +static Bool +NewportCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NewportPtr pNewport = NEWPORTPTR(pScrn); + + NewportRestore(pScrn, TRUE); + if (pNewport->ShadowPtr) + xfree(pNewport->ShadowPtr); + + /* unmap the Newport's registers from memory */ + NewportUnmapRegs(pScrn); + pScrn->vtSema = FALSE; + + pScreen->CloseScreen = pNewport->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + +/* Blank or unblank the screen */ +static Bool +NewportSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn; + NewportRegsPtr pNewportRegs; + Bool unblank; + unsigned short treg; + + unblank = xf86IsUnblank(mode); + pScrn = xf86Screens[pScreen->myNum]; + pNewportRegs = NEWPORTPTR(pScrn)->pNewportRegs; + + if (unblank) { + treg = NewportVc2Get(pNewportRegs, VC2_IREG_CONTROL); + NewportVc2Set( pNewportRegs, VC2_IREG_CONTROL, (treg | VC2_CTRL_EDISP)); + } else { + treg = NewportVc2Get(pNewportRegs, VC2_IREG_CONTROL); + NewportVc2Set( pNewportRegs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_EDISP))); + } + return TRUE; +} + + +static OptionInfoPtr +NewportAvailableOptions(int chipid, int busid) +{ + return NewportOptions; +} + + +/* This sets up the actual mode on the Newport */ +static Bool +NewportModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + int width, height; + NewportPtr pNewport = NEWPORTPTR(pScrn); + NewportRegsPtr pNewportRegs = NEWPORTREGSPTR(pScrn); + + width = mode->HDisplay; + height = mode->VDisplay; + if (width != 1280 || height != 1024) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \ + "Width = %d and height = %d is not supported by by this driver\n", width, height); + } + + pScrn->vtSema=TRUE; + /* first backup the necessary registers... */ + pNewport->txt_drawmode1 = pNewportRegs->set.drawmode1; + pNewport->txt_vc2ctrl = NewportVc2Get( pNewportRegs, VC2_IREG_CONTROL); + NewportBackupPalette(pScrn); + + /* ...then setup the hardware */ + /* + * XXX: set the frambuffer layout to either 24 or 8 bpp here - more specs needed + * XXX: Lazy mode on: simply rely on the prom since it does such a good job + */ + if( pNewport->Bpp == 1) { + pNewport->drawmode1 = pNewport->txt_drawmode1; + } + + return TRUE; +} + + +/* + * This will acutally restore the saved state + * (either when switching back to a VT or when the server is going down) + * Closing is true if the X server is really going down + */ +static void +NewportRestore(ScrnInfoPtr pScrn, Bool Closing) +{ + NewportPtr pNewport = NEWPORTPTR(pScrn); + NewportRegsPtr pNewportRegs = pNewport->pNewportRegs; + + /* Restore backed up registers */ + pNewportRegs->set.drawmode1 = pNewport->txt_drawmode1; + NewportVc2Set( pNewportRegs, VC2_IREG_CONTROL, pNewport->txt_vc2ctrl); + NewportRestorePalette(pScrn); +} + + +/* Probe for the Newport card ;) */ +/* XXX: we need a better probe here in order to support multihead! */ +static unsigned +NewportHWProbe(unsigned probedIDs[]) +{ + FILE* cpuinfo; + char line[80]; + unsigned hasNewport = 0; + cpuinfo = fopen("/proc/cpuinfo","r"); + while(fgets(line,80,cpuinfo) != NULL) { + if(strstr(line, "SGI Indy") != NULL) { + hasNewport = 1; + break; + } + } + fclose(cpuinfo); + + probedIDs[0] = 0; + return hasNewport; +} + +/* Probe for Chipset revisions */ +static Bool NewportProbeCardInfo(ScrnInfoPtr pScrn) +{ + unsigned int tmp,cmap_rev; + NewportPtr pNewport = NEWPORTPTR(pScrn); + NewportRegsPtr pNewportRegs = pNewport->pNewportRegs; + + NewportWait(pNewportRegs); + pNewportRegs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL | + NCMAP_REGADDR_RREG | NPORT_DMODE_W1); + tmp = pNewportRegs->set.dcbdata0.bytes.b3; + pNewport->board_rev = (tmp >> 4) & 7; + pNewport->bitplanes = ((pNewport->board_rev > 1) && (tmp & 0x80)) ? 8 : 24; + cmap_rev = tmp & 7; + pNewport->cmap_rev = (char)('A'+(cmap_rev ? (cmap_rev+1):0)); + pNewport->rex3_rev = (pNewportRegs->cset.ustat) & 7; + + pNewportRegs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL | + XM9_CRS_REVISION | NPORT_DMODE_W1); + pNewport->xmap9_rev = (pNewportRegs->set.dcbdata0.bytes.b3) & 7; + + return TRUE; +} + + +/* map NewportRegs */ +static Bool +NewportMapRegs(ScrnInfoPtr pScrn) +{ + NewportPtr pNewport = NEWPORTPTR(pScrn); + + pNewport->pNewportRegs = xf86MapVidMem(pScrn->scrnIndex, + VIDMEM_MMIO, + NEWPORT_BASE_ADDR0 + pNewport->busID * NEWPORT_BASE_OFFSET, + sizeof(NewportRegs)); + if ( ! pNewport->pNewportRegs ) + return FALSE; + return TRUE; +} + +/* unmap NewportRegs */ +static void +NewportUnmapRegs(ScrnInfoPtr pScrn) +{ + NewportPtr pNewport = NEWPORTPTR(pScrn); + + xf86UnMapVidMem( pScrn->scrnIndex, pNewport->pNewportRegs, + sizeof(NewportRegs)); + pNewport->pNewportRegs = NULL; +} Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.c:1.1 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.c Fri Dec 1 14:48:01 2000 @@ -0,0 +1,69 @@ +/* + * Id: newport_regs.c,v 1.3 2000/11/29 20:58:10 agx Exp $ + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.c,v 1.1 2000/12/01 19:48:01 dawes Exp $ */ + +#include "newport.h" + +static void NewportXmap9FifoWait(NewportRegsPtr pNewportRegs, unsigned long xmapChip); + +void +NewportVc2Set(NewportRegsPtr pNewportRegs, unsigned char vc2Ireg, unsigned short val) +{ + pNewportRegs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_INDEX | NPORT_DMODE_W3 | + NPORT_DMODE_ECINC | VC2_PROTOCOL); + pNewportRegs->set.dcbdata0.all = (vc2Ireg << 24) | (val << 8); +} + +unsigned short +NewportVc2Get(NewportRegsPtr pNewportRegs, unsigned char vc2Ireg) +{ + pNewportRegs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_INDEX | NPORT_DMODE_W1 | + NPORT_DMODE_ECINC | VC2_PROTOCOL); + pNewportRegs->set.dcbdata0.bytes.b3 = vc2Ireg; + pNewportRegs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_IREG | NPORT_DMODE_W2 | + NPORT_DMODE_ECINC | VC2_PROTOCOL); + return pNewportRegs->set.dcbdata0.hwords.s1; +} + + +/* Sometimes we just have to wait until we can do anything */ +void +NewportWait(NewportRegsPtr pNewportRegs) +{ + while(1) + if(!(pNewportRegs->cset.stat & NPORT_STAT_GBUSY)) + break; +} + +void +NewportBfwait(NewportRegsPtr pNewportRegs) +{ + while(1) + if(!(pNewportRegs->cset.stat & NPORT_STAT_BBUSY)) + break; +} + +/* wait til an entry in the Xmap9's Mode Fifo is free (xmapChip = DCB_XMAP0 | DCB_XMAP1) */ +static void +NewportXmap9FifoWait(NewportRegsPtr pNewportRegs, unsigned long xmapChip) +{ + while(1) { + NewportBfwait( pNewportRegs); + pNewportRegs->set.dcbmode = (xmapChip | R_DCB_XMAP9_PROTOCOL | + XM9_CRS_FIFO_AVAIL | NPORT_DMODE_W1); + if( (pNewportRegs->set.dcbdata0.bytes.b3) & 7 ) + break; + } +} + +void +NewportXmap9SetModeRegister(NewportRegsPtr pNewportRegs, CARD8 address, CARD32 mode) +{ + NewportXmap9FifoWait( pNewportRegs, DCB_XMAP0); + NewportXmap9FifoWait( pNewportRegs, DCB_XMAP1); + + pNewportRegs->set.dcbmode = (DCB_XMAP_ALL | W_DCB_XMAP9_PROTOCOL | + XM9_CRS_MODE_REG_DATA | NPORT_DMODE_W4 ); + pNewportRegs->set.dcbdata0.all = (address << 24) | ( mode & 0xffffff ); +} Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.h:1.1 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.h Fri Dec 1 14:48:01 2000 @@ -0,0 +1,453 @@ +/* + * Id: newport_regs.h,v 1.5 2000/11/18 23:23:14 agx Exp $ + * + * Register Layouts of the various newport chips + * mostly as found in linux/include/asm/newport.h + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_regs.h,v 1.1 2000/12/01 19:48:01 dawes Exp $ */ + +typedef volatile unsigned long npireg_t; + +union npfloat { + volatile float f; + npireg_t i; +}; + +typedef union npfloat npfreg_t; + +union np_dcb { + npireg_t all; + struct { volatile unsigned short s0, s1; } hwords; + struct { volatile unsigned char b0, b1, b2, b3; } bytes; +}; + +struct Newport_rexregs { + npireg_t drawmode1; /* GL extra mode bits */ + +#define DM1_PLANES 0x00000007 +#define DM1_NOPLANES 0x00000000 +#define DM1_RGBPLANES 0x00000001 +#define DM1_RGBAPLANES 0x00000002 +#define DM1_OLAYPLANES 0x00000004 +#define DM1_PUPPLANES 0x00000005 +#define DM1_CIDPLANES 0x00000006 + +#define NPORT_DMODE1_DDMASK 0x00000018 +#define NPORT_DMODE1_DD4 0x00000000 +#define NPORT_DMODE1_DD8 0x00000008 +#define NPORT_DMODE1_DD12 0x00000010 +#define NPORT_DMODE1_DD24 0x00000018 +#define NPORT_DMODE1_DSRC 0x00000020 +#define NPORT_DMODE1_YFLIP 0x00000040 +#define NPORT_DMODE1_RWPCKD 0x00000080 +#define NPORT_DMODE1_HDMASK 0x00000300 +#define NPORT_DMODE1_HD4 0x00000000 +#define NPORT_DMODE1_HD8 0x00000100 +#define NPORT_DMODE1_HD12 0x00000200 +#define NPORT_DMODE1_HD32 0x00000300 +#define NPORT_DMODE1_RWDBL 0x00000400 +#define NPORT_DMODE1_ESWAP 0x00000800 /* Endian swap */ +#define NPORT_DMODE1_CCMASK 0x00007000 +#define NPORT_DMODE1_CCLT 0x00001000 +#define NPORT_DMODE1_CCEQ 0x00002000 +#define NPORT_DMODE1_CCGT 0x00004000 +#define NPORT_DMODE1_RGBMD 0x00008000 +#define NPORT_DMODE1_DENAB 0x00010000 /* Dither enable */ +#define NPORT_DMODE1_FCLR 0x00020000 /* Fast clear */ +#define NPORT_DMODE1_BENAB 0x00040000 /* Blend enable */ +#define NPORT_DMODE1_SFMASK 0x00380000 +#define NPORT_DMODE1_SF0 0x00000000 +#define NPORT_DMODE1_SF1 0x00080000 +#define NPORT_DMODE1_SFDC 0x00100000 +#define NPORT_DMODE1_SFMDC 0x00180000 +#define NPORT_DMODE1_SFSA 0x00200000 +#define NPORT_DMODE1_SFMSA 0x00280000 +#define NPORT_DMODE1_DFMASK 0x01c00000 +#define NPORT_DMODE1_DF0 0x00000000 +#define NPORT_DMODE1_DF1 0x00400000 +#define NPORT_DMODE1_DFSC 0x00800000 +#define NPORT_DMODE1_DFMSC 0x00c00000 +#define NPORT_DMODE1_DFSA 0x01000000 +#define NPORT_DMODE1_DFMSA 0x01400000 +#define NPORT_DMODE1_BBENAB 0x02000000 /* Back blend enable */ +#define NPORT_DMODE1_PFENAB 0x04000000 /* Pre-fetch enable */ +#define NPORT_DMODE1_ABLEND 0x08000000 /* Alpha blend */ +#define NPORT_DMODE1_LOMASK 0xf0000000 +#define NPORT_DMODE1_LOZERO 0x00000000 +#define NPORT_DMODE1_LOAND 0x10000000 +#define NPORT_DMODE1_LOANDR 0x20000000 +#define NPORT_DMODE1_LOSRC 0x30000000 +#define NPORT_DMODE1_LOANDI 0x40000000 +#define NPORT_DMODE1_LODST 0x50000000 +#define NPORT_DMODE1_LOXOR 0x60000000 +#define NPORT_DMODE1_LOOR 0x70000000 +#define NPORT_DMODE1_LONOR 0x80000000 +#define NPORT_DMODE1_LOXNOR 0x90000000 +#define NPORT_DMODE1_LONDST 0xa0000000 +#define NPORT_DMODE1_LOORR 0xb0000000 +#define NPORT_DMODE1_LONSRC 0xc0000000 +#define NPORT_DMODE1_LOORI 0xd0000000 +#define NPORT_DMODE1_LONAND 0xe0000000 +#define NPORT_DMODE1_LOONE 0xf0000000 + + npireg_t drawmode0; /* REX command register */ + + /* These bits define the graphics opcode being performed. */ +#define NPORT_DMODE0_OPMASK 0x00000003 /* Opcode mask */ +#define NPORT_DMODE0_NOP 0x00000000 /* No operation */ +#define NPORT_DMODE0_RD 0x00000001 /* Read operation */ +#define NPORT_DMODE0_DRAW 0x00000002 /* Draw operation */ +#define NPORT_DMODE0_S2S 0x00000003 /* Screen to screen operation */ + + /* The following decide what addressing mode(s) are to be used */ +#define NPORT_DMODE0_AMMASK 0x0000001c /* Address mode mask */ +#define NPORT_DMODE0_SPAN 0x00000000 /* Spanning address mode */ +#define NPORT_DMODE0_BLOCK 0x00000004 /* Block address mode */ +#define NPORT_DMODE0_ILINE 0x00000008 /* Iline address mode */ +#define NPORT_DMODE0_FLINE 0x0000000c /* Fline address mode */ +#define NPORT_DMODE0_ALINE 0x00000010 /* Aline address mode */ +#define NPORT_DMODE0_TLINE 0x00000014 /* Tline address mode */ +#define NPORT_DMODE0_BLINE 0x00000018 /* Bline address mode */ + + /* And now some misc. operation control bits. */ +#define NPORT_DMODE0_DOSETUP 0x00000020 +#define NPORT_DMODE0_CHOST 0x00000040 +#define NPORT_DMODE0_AHOST 0x00000080 +#define NPORT_DMODE0_STOPX 0x00000100 +#define NPORT_DMODE0_STOPY 0x00000200 +#define NPORT_DMODE0_SK1ST 0x00000400 +#define NPORT_DMODE0_SKLST 0x00000800 +#define NPORT_DMODE0_ZPENAB 0x00001000 +#define NPORT_DMODE0_LISPENAB 0x00002000 +#define NPORT_DMODE0_LISLST 0x00004000 +#define NPORT_DMODE0_L32 0x00008000 +#define NPORT_DMODE0_ZOPQ 0x00010000 +#define NPORT_DMODE0_LISOPQ 0x00020000 +#define NPORT_DMODE0_SHADE 0x00040000 +#define NPORT_DMODE0_LRONLY 0x00080000 +#define NPORT_DMODE0_XYOFF 0x00100000 +#define NPORT_DMODE0_CLAMP 0x00200000 +#define NPORT_DMODE0_ENDPF 0x00400000 +#define NPORT_DMODE0_YSTR 0x00800000 + + npireg_t lsmode; /* Mode for line stipple ops */ + npireg_t lspattern; /* Pattern for line stipple ops */ + npireg_t lspatsave; /* Backup save pattern */ + npireg_t zpattern; /* Pixel zpattern */ + npireg_t colorback; /* Background color */ + npireg_t colorvram; /* Clear color for fast vram */ + npireg_t alpharef; /* Reference value for afunctions */ + unsigned long pad0; + npireg_t smask0x; /* Window GL relative screen mask 0 */ + npireg_t smask0y; /* Window GL relative screen mask 0 */ + npireg_t _setup; + npireg_t _stepz; + npireg_t _lsrestore; + npireg_t _lssave; + + unsigned long _pad1[0x30]; + + /* Iterators, full state for context switch */ + npfreg_t _xstart; /* X-start point (current) */ + npfreg_t _ystart; /* Y-start point (current) */ + npfreg_t _xend; /* x-end point */ + npfreg_t _yend; /* y-end point */ + npireg_t xsave; /* copy of xstart integer value for BLOCk addressing MODE */ + npireg_t xymove; /* x.y offset from xstart, ystart for relative operations */ + npfreg_t bresd; + npfreg_t bress1; + npireg_t bresoctinc1; + volatile int bresrndinc2; + npireg_t brese1; + npireg_t bress2; + npireg_t aweight0; + npireg_t aweight1; + npfreg_t xstartf; + npfreg_t ystartf; + npfreg_t xendf; + npfreg_t yendf; + npireg_t xstarti; + npfreg_t xendf1; + npireg_t xystarti; + npireg_t xyendi; + npireg_t xstartendi; + + unsigned long _unused2[0x29]; + + npfreg_t colorred; + npfreg_t coloralpha; + npfreg_t colorgrn; + npfreg_t colorblue; + npfreg_t slopered; + npfreg_t slopealpha; + npfreg_t slopegrn; + npfreg_t slopeblue; + npireg_t wrmask; + npireg_t colori; + npfreg_t colorx; + npfreg_t slopered1; + npireg_t hostrw0; + npireg_t hostrw1; + npireg_t dcbmode; +#define NPORT_DMODE_WMASK 0x00000003 +#define NPORT_DMODE_W4 0x00000000 +#define NPORT_DMODE_W1 0x00000001 +#define NPORT_DMODE_W2 0x00000002 +#define NPORT_DMODE_W3 0x00000003 +#define NPORT_DMODE_EDPACK 0x00000004 +#define NPORT_DMODE_ECINC 0x00000008 +#define NPORT_DMODE_CMASK 0x00000070 +#define NPORT_DMODE_AMASK 0x00000780 +#define NPORT_DMODE_AVC2 0x00000000 +#define NPORT_DMODE_ACMALL 0x00000080 +#define NPORT_DMODE_ACM0 0x00000100 +#define NPORT_DMODE_ACM1 0x00000180 +#define NPORT_DMODE_AXMALL 0x00000200 +#define NPORT_DMODE_AXM0 0x00000280 +#define NPORT_DMODE_AXM1 0x00000300 +#define NPORT_DMODE_ABT 0x00000380 +#define NPORT_DMODE_AVCC1 0x00000400 +#define NPORT_DMODE_AVAB1 0x00000480 +#define NPORT_DMODE_ALG3V0 0x00000500 +#define NPORT_DMODE_A1562 0x00000580 +#define NPORT_DMODE_ESACK 0x00000800 +#define NPORT_DMODE_EASACK 0x00001000 +#define NPORT_DMODE_CWMASK 0x0003e000 +#define NPORT_DMODE_CHMASK 0x007c0000 +#define NPORT_DMODE_CSMASK 0x0f800000 +#define NPORT_DMODE_SENDIAN 0x10000000 + + unsigned long _unused3; + + union np_dcb dcbdata0; + npireg_t dcbdata1; +}; + +struct Newport_cregs { + npireg_t smask1x; + npireg_t smask1y; + npireg_t smask2x; + npireg_t smask2y; + npireg_t smask3x; + npireg_t smask3y; + npireg_t smask4x; + npireg_t smask4y; + npireg_t topscan; + npireg_t xywin; + npireg_t clipmode; +#define NPORT_CMODE_SM0 0x00000001 +#define NPORT_CMODE_SM1 0x00000002 +#define NPORT_CMODE_SM2 0x00000004 +#define NPORT_CMODE_SM3 0x00000008 +#define NPORT_CMODE_SM4 0x00000010 +#define NPORT_CMODE_CMSK 0x00001e00 + + unsigned long _unused0; + unsigned long config; +#define NPORT_CFG_G32MD 0x00000001 +#define NPORT_CFG_BWIDTH 0x00000002 +#define NPORT_CFG_ERCVR 0x00000004 +#define NPORT_CFG_BDMSK 0x00000078 +#define NPORT_CFG_GDMSK 0x00000f80 +#define NPORT_CFG_GD0 0x00000080 +#define NPORT_CFG_GD1 0x00000100 +#define NPORT_CFG_GD2 0x00000200 +#define NPORT_CFG_GD3 0x00000400 +#define NPORT_CFG_GD4 0x00000800 +#define NPORT_CFG_GFAINT 0x00001000 +#define NPORT_CFG_TOMSK 0x0000e000 +#define NPORT_CFG_VRMSK 0x00070000 +#define NPORT_CFG_FBTYP 0x00080000 + + npireg_t _unused1; + npireg_t stat; +#define NPORT_STAT_VERS 0x00000007 +#define NPORT_STAT_GBUSY 0x00000008 +#define NPORT_STAT_BBUSY 0x00000010 +#define NPORT_STAT_VRINT 0x00000020 +#define NPORT_STAT_VIDINT 0x00000040 +#define NPORT_STAT_GLMSK 0x00001f80 +#define NPORT_STAT_BLMSK 0x0007e000 +#define NPORT_STAT_BFIRQ 0x00080000 +#define NPORT_STAT_GFIRQ 0x00100000 + + npireg_t ustat; + npireg_t dreset; +}; + +typedef +struct Newport_regs { + struct Newport_rexregs set; + unsigned long _unused0[0x16e]; + struct Newport_rexregs go; + unsigned long _unused1[0x22e]; + struct Newport_cregs cset; + unsigned long _unused2[0x1ef]; + struct Newport_cregs cgo; +} NewportRegs, *NewportRegsPtr; + +/* Reading/writing VC2 registers. */ +#define VC2_REGADDR_INDEX 0x00000000 +#define VC2_REGADDR_IREG 0x00000010 +#define VC2_REGADDR_RAM 0x00000030 +#define VC2_PROTOCOL (NPORT_DMODE_EASACK | 0x00800000 | 0x00040000) + +#define VC2_VLINET_ADDR 0x000 +#define VC2_VFRAMET_ADDR 0x400 +#define VC2_CGLYPH_ADDR 0x500 + +/* Now the Indexed registers of the VC2. */ +#define VC2_IREG_VENTRY 0x00 +#define VC2_IREG_CENTRY 0x01 +#define VC2_IREG_CURSX 0x02 +#define VC2_IREG_CURSY 0x03 +#define VC2_IREG_CCURSX 0x04 +#define VC2_IREG_DENTRY 0x05 +#define VC2_IREG_SLEN 0x06 +#define VC2_IREG_RADDR 0x07 +#define VC2_IREG_VFPTR 0x08 +#define VC2_IREG_VLSPTR 0x09 +#define VC2_IREG_VLIR 0x0a +#define VC2_IREG_VLCTR 0x0b +#define VC2_IREG_CTPTR 0x0c +#define VC2_IREG_WCURSY 0x0d +#define VC2_IREG_DFPTR 0x0e +#define VC2_IREG_DLTPTR 0x0f +#define VC2_IREG_CONTROL 0x10 +#define VC2_IREG_CONFIG 0x20 + +/* VC2 Control register bits */ +#define VC2_CTRL_EVIRQ 0x0001 +#define VC2_CTRL_EDISP 0x0002 +#define VC2_CTRL_EVIDEO 0x0004 +#define VC2_CTRL_EDIDS 0x0008 +#define VC2_CTRL_ECURS 0x0010 +#define VC2_CTRL_EGSYNC 0x0020 +#define VC2_CTRL_EILACE 0x0040 +#define VC2_CTRL_ECDISP 0x0080 +#define VC2_CTRL_ECCURS 0x0100 +#define VC2_CTRL_ECG64 0x0200 +#define VC2_CTRL_GLSEL 0x0400 + +/* Controlling the color map on Newport. */ +#define NCMAP_REGADDR_AREG 0x00000000 +#define NCMAP_REGADDR_ALO 0x00000000 +#define NCMAP_REGADDR_AHI 0x00000010 +#define NCMAP_REGADDR_PBUF 0x00000020 +#define NCMAP_REGADDR_CREG 0x00000030 +#define NCMAP_REGADDR_SREG 0x00000040 +#define NCMAP_REGADDR_RREG 0x00000060 +#define NCMAP_PROTOCOL (0x00008000 | 0x00040000 | 0x00800000) + +/* + * DCBMODE register defines: + */ + +/* Widht of the data being transfered for each DCBDATA[01] word */ +#define DCB_DATAWIDTH_4 0x0 +#define DCB_DATAWIDTH_1 0x1 +#define DCB_DATAWIDTH_2 0x2 +#define DCB_DATAWIDTH_3 0x3 + +/* If set, all of DCBDATA will be moved, otherwise only DATAWIDTH bytes */ +#define DCB_ENDATAPACK (1 << 2) + +/* Enables DCBCRS auto increment after each DCB transfer */ +#define DCB_ENCRSINC (1 << 3) + +/* shift for accessing the control register select address (DBCCRS, 3 bits) */ +#define DCB_CRS_SHIFT 4 + +/* DCBADDR (4 bits): display bus slave address */ +#define DCB_ADDR_SHIFT 7 +#define DCB_VC2 (0 << DCB_ADDR_SHIFT) +#define DCB_CMAP_ALL (1 << DCB_ADDR_SHIFT) +#define DCB_CMAP0 (2 << DCB_ADDR_SHIFT) +#define DCB_CMAP1 (3 << DCB_ADDR_SHIFT) +#define DCB_XMAP_ALL (4 << DCB_ADDR_SHIFT) +#define DCB_XMAP0 (5 << DCB_ADDR_SHIFT) +#define DCB_XMAP1 (6 << DCB_ADDR_SHIFT) +#define DCB_BT445 (7 << DCB_ADDR_SHIFT) +#define DCB_VCC1 (8 << DCB_ADDR_SHIFT) +#define DCB_VAB1 (9 << DCB_ADDR_SHIFT) +#define DCB_LG3_BDVERS0 (10 << DCB_ADDR_SHIFT) +#define DCB_LG3_ICS1562 (11 << DCB_ADDR_SHIFT) +#define DCB_RESERVED (15 << DCB_ADDR_SHIFT) + +/* DCB protocol ack types */ +#define DCB_ENSYNCACK (1 << 11) +#define DCB_ENASYNCACK (1 << 12) + +#define DCB_CSWIDTH_SHIFT 13 +#define DCB_CSHOLD_SHIFT 18 +#define DCB_CSSETUP_SHIFT 23 + +/* XMAP9 specific defines */ +/* XMAP9 -- registers as seen on the DCBMODE register*/ +# define XM9_CRS_CONFIG (0 << DCB_CRS_SHIFT) +# define XM9_PUPMODE (1 << 0) +# define XM9_ODD_PIXEL (1 << 1) +# define XM9_8_BITPLANES (1 << 2) +# define XM9_SLOW_DCB (1 << 3) +# define XM9_VIDEO_RGBMAP_MASK (3 << 4) +# define XM9_VIDEO_RGBMAP_M0 (1 << 4) +# define XM9_VIDEO_RGMPAP_M1 (1 << 5) +# define XM9_VIDEO_RGBMAP_M2 (3 << 4) +# define XM9_EXPRESS_VIDEO (1 << 6) +# define XM9_VIDEO_OPTION (1 << 7) +# define XM9_CRS_REVISION (1 << DCB_CRS_SHIFT) +# define XM9_CRS_FIFO_AVAIL (2 << DCB_CRS_SHIFT) +# define XM9_FIFO_0_AVAIL 0 +# define XM9_FIFO_1_AVAIL 1 +# define XM9_FIFO_2_AVAIL 3 +# define XM9_FIFO_3_AVAIL 2 +# define XM9_FIFO_FULL XM9_FIFO_0_AVAIL +# define XM9_FIFO_EMPTY XM9_FIFO_3_AVAIL +# define XM9_CRS_CURS_CMAP_MSB (3 << DCB_CRS_SHIFT) +# define XM9_CRS_PUP_CMAP_MSB (4 << DCB_CRS_SHIFT) +# define XM9_CRS_MODE_REG_DATA (5 << DCB_CRS_SHIFT) +# define XM9_CRS_MODE_REG_INDEX (7 << DCB_CRS_SHIFT) + + +#define DCB_CYCLES(setup,hold,width) \ + ((hold << DCB_CSHOLD_SHIFT) | \ + (setup << DCB_CSSETUP_SHIFT)| \ + (width << DCB_CSWIDTH_SHIFT)) + +#define W_DCB_XMAP9_PROTOCOL DCB_CYCLES (2, 1, 0) +#define WSLOW_DCB_XMAP9_PROTOCOL DCB_CYCLES (5, 5, 0) +#define WAYSLOW_DCB_XMAP9_PROTOCOL DCB_CYCLES (12, 12, 0) +#define R_DCB_XMAP9_PROTOCOL DCB_CYCLES (2, 1, 3) + +/* xmap9 mode register layout */ +#define XM9_MREG_BUF_SEL (1 << 0) +#define XM9_MREG_OVL_BUF_SEL (1 << 1) +#define XM9_MREG_GAMMA_BYPASS (1 << 2) +#define XM9_MREG_MSB_CMAP (31 << 3 +#define XM9_MREG_PIX_MODE_MASK (3 << 8) +#define XM9_MREG_PIX_MODE_RGB0 (1 << 8) +#define XM9_MREG_PIX_MODE_RGB1 (1 << 9) +#define XM9_MREG_PIX_MODE_RGB2 (3 << 8) +#define XM9_MREG_PIX_SIZE_MASK (3 << 10) +#define XM9_MREG_PIX_SIZE_8BPP (1 << 10) +#define XM9_MREG_PIX_SIZE_12BPP (1 << 11) +#define XM9_MREG_PIX_SIZE_24BPP (3 << 10) +#define XM9_MREG_VID_MODE_MASK (3 << 12) +#define XM9_MREG_VID_MODE_OVL (1 << 12) +#define XM9_MREG_VID_MODE_UDL (1 << 13) +#define XM9_MREG_VID_MODE_RPL (3 << 12) +#define XM9_MREG_BUF_VID_ALPHA (1 << 15) +#define XM9_MREG_APIX_MODE_MASK (7 << 16) +#define XM9_MREG_APIX_MODE_FUDL (1 << 16) +#define XM9_MREG_APIX_MODE_FOVL (1 << 17) +#define XM9_MREG_APIX_MODE_ODB (3 << 17) +#define XM9_MREG_APIX_MODE_BOTH (7 << 16) +#define XM9_MREG_AMSB_CMAP_MASK (31 << 19) + + +#define BT445_PROTOCOL DCB_CYCLES(1,1,3) + +#define BT445_CSR_ADDR_REG (0 << DCB_CRS_SHIFT) +#define BT445_CSR_REVISION (2 << DCB_CRS_SHIFT) + +#define BT445_REVISION_REG 0x01 Index: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_shadow.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/newport/newport_shadow.c:1.1 --- /dev/null Mon Dec 18 14:30:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/newport/newport_shadow.c Fri Dec 1 14:48:02 2000 @@ -0,0 +1,47 @@ +/* + * Id: newport_shadow.c,v 1.3 2000/11/29 20:58:10 agx Exp $ + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_shadow.c,v 1.1 2000/12/01 19:48:02 dawes Exp $ */ + +#include "newport.h" + +void +NewportRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + unsigned long *base, *src; + int dx, dy, x; + NewportPtr pNewport = NEWPORTPTR(pScrn); + NewportRegsPtr pNewportRegs = pNewport->pNewportRegs; + +#define RA8_PIXELS 4 /* burst 4 pixels each time */ +#define RA8_PIXEL_SHIFT 2 /* 4 Pixels on each burst */ +#define RA8_MASK 0xffc /* move to 4Byte boundary */ + + NewportWait(pNewportRegs); + pNewportRegs->set.drawmode1 = pNewport->drawmode1 | (NPORT_DMODE1_RWPCKD | \ + (NPORT_DMODE1_HDMASK & NPORT_DMODE1_HD8)); + pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | \ + NPORT_DMODE0_CHOST); + while(num--) { + NewportWait(pNewportRegs); + x = pbox->x1 & RA8_MASK; /* move x to 4 byte boundary */ + base = (unsigned long*)pNewport->ShadowPtr + + (pbox->y1 * (pNewport->ShadowPitch >> RA8_PIXEL_SHIFT) ) + + ( x >> RA8_PIXEL_SHIFT); + + pNewportRegs->set.xystarti = (x << 16) | pbox->y1; + pNewportRegs->set.xyendi = (pbox->x2 << 16) | pbox->y2; + + for ( dy = pbox->y1; dy <= pbox->y2; dy++) { + + src = base; + for ( dx = x; dx <= pbox->x2; dx += RA8_PIXELS) { + pNewportRegs->go.hostrw0 = *src; + src++; + } + base += ( pNewport->ShadowPitch >> RA8_PIXEL_SHIFT ); + } + pbox++; + } +} + Index: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile:1.12 xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile:1.12 Fri Mar 31 17:55:46 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile Fri Oct 6 08:31:03 2000 @@ -1,10 +1,10 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.12 2000/03/31 22:55:46 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.14 2000/10/06 12:31:03 eich Exp $ XCOMM XCOMM This is an Imakefile for the NVIDIA driver. XCOMM -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.12 2000/03/31 22:55:46 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.14 2000/10/06 12:31:03 eich Exp $ #define IHaveModules #include <Server.tmpl> @@ -26,7 +26,8 @@ -I$(XF86SRC)/ramdac -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(SERVERSRC)/Xext -I$(XF86SRC)/int10 \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) -I$(SERVERSRC)/fb + -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) -I$(SERVERSRC)/fb \ + -I$(SERVERSRC)/render -I$(XF86OSSRC)/vbe #endif DEFINES = -DPSZ=8 Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp:1.10 xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp:1.10 Tue Jun 13 22:13:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp Mon Dec 11 15:18:21 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp,v 1.10 2000/06/14 02:13:12 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp,v 1.11 2000/12/11 20:18:21 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH NV __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH NV __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME nv \- NVIDIA video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h:1.3 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h:1.3 Fri Feb 25 16:02:55 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h Tue Oct 24 18:45:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h,v 1.3 2000/02/25 21:02:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_const.h,v 1.4 2000/10/24 22:45:08 dawes Exp $ */ #ifndef __NV_CONST_H__ #define __NV_CONST_H__ @@ -10,7 +10,7 @@ #define NV_MINOR_VERSION 0 #define NV_PATCHLEVEL 0 -/*#define NV_USE_FB*/ +#define NV_USE_FB #ifdef DEBUG_PRINT #define DEBUG(x) x Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c:1.7 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c:1.7 Tue Feb 8 12:19:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c Fri Nov 3 13:46:12 2000 @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.7 2000/02/08 17:19:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.8 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" @@ -202,12 +202,12 @@ unsigned char val; /* wait for Vsync */ - while(pNv->riva.PCIO[0x3da] & 0x08); - while(!(pNv->riva.PCIO[0x3da] & 0x08)); + while(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08); + while(!(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08)); /* Get the result */ - pNv->riva.PCIO[0x3d4] = 0x3e; - val = pNv->riva.PCIO[0x3d5]; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3e); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5); DEBUG(ErrorF("NV_ddc1Read(%p,...) returns %d\n", pScrn, val)); return (val & DDC_SDA_READ_MASK) != 0; @@ -220,8 +220,8 @@ unsigned char val; /* Get the result. */ - pNv->riva.PCIO[0x3d4] = 0x3e; - val = pNv->riva.PCIO[0x3d5]; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3e); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5); *clock = (val & DDC_SCL_READ_MASK) != 0; *data = (val & DDC_SDA_READ_MASK) != 0; @@ -235,8 +235,8 @@ NVPtr pNv = NVPTR(xf86Screens[b->scrnIndex]); unsigned char val; - pNv->riva.PCIO[0x3d4] = 0x3f; - val = pNv->riva.PCIO[0x3d5] & 0xf0; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3f); + val = VGA_RD08(pNv->riva.PCIO, 0x3d5) & 0xf0; if (clock) val |= DDC_SCL_WRITE_MASK; else @@ -247,8 +247,8 @@ else val &= ~DDC_SDA_WRITE_MASK; - pNv->riva.PCIO[0x3d4] = 0x3f; - pNv->riva.PCIO[0x3d5] = val | 0x1; + VGA_WR08(pNv->riva.PCIO, 0x3d4, 0x3f); + VGA_WR08(pNv->riva.PCIO, 0x3d5, val | 0x1); DEBUG(ErrorF("NV_I2CPutBits(%p, %d, %d) val=0x%x\n", b, clock, data, val)); } Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c:1.44 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c:1.53 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c:1.44 Wed Jun 21 13:28:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c Thu Dec 14 11:33:09 2000 @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.44 2000/06/21 17:28:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.53 2000/12/14 16:33:09 eich Exp $ */ #include "nv_include.h" @@ -35,6 +35,10 @@ #include "nvvga.h" #include "xf86int10.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* * Forward definitions for the functions that make up the driver. */ @@ -99,6 +103,14 @@ { NV_CHIP_GEFORCE256, "GeForce 256" }, { NV_CHIP_GEFORCEDDR, "GeForce DDR" }, { NV_CHIP_QUADRO, "Quadro" }, + { NV_CHIP_GEFORCE2GTS, "GeForce2 GTS"}, + { NV_CHIP_GEFORCE2GTS_1,"GeForce2 GTS (rev 1)"}, + { NV_CHIP_GEFORCE2ULTRA,"GeForce2 ultra"}, + { NV_CHIP_QUADRO2PRO, "Quadro 2 Pro"}, + { NV_CHIP_GEFORCE2MX, "GeForce2 MX"}, + { NV_CHIP_GEFORCE2MXDDR, "GeForce2 MX DDR"}, + { NV_CHIP_QUADRO2MXR, "Quadro 2 MXR"}, + { NV_CHIP_GEFORCE2GO, "GeForce 2 Go"}, {-1, NULL } }; @@ -113,7 +125,15 @@ { NV_CHIP_GEFORCE256, NV_CHIP_GEFORCE256, RES_SHARED_VGA }, { NV_CHIP_GEFORCEDDR, NV_CHIP_GEFORCEDDR, RES_SHARED_VGA }, { NV_CHIP_QUADRO, NV_CHIP_QUADRO, RES_SHARED_VGA }, - { -1, -1, RES_UNDEFINED } + { NV_CHIP_GEFORCE2GTS, NV_CHIP_GEFORCE2GTS, RES_SHARED_VGA }, + { NV_CHIP_GEFORCE2GTS_1, NV_CHIP_GEFORCE2GTS_1, RES_SHARED_VGA }, + { NV_CHIP_GEFORCE2ULTRA, NV_CHIP_GEFORCE2ULTRA, RES_SHARED_VGA }, + { NV_CHIP_QUADRO2PRO, NV_CHIP_QUADRO2PRO, RES_SHARED_VGA }, + { NV_CHIP_GEFORCE2MX, NV_CHIP_GEFORCE2MX, RES_SHARED_VGA }, + { NV_CHIP_GEFORCE2MXDDR, NV_CHIP_GEFORCE2MXDDR, RES_SHARED_VGA }, + { NV_CHIP_QUADRO2MXR, NV_CHIP_QUADRO2MXR, RES_SHARED_VGA }, + { NV_CHIP_GEFORCE2GO, NV_CHIP_GEFORCE2GO, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } }; /* @@ -157,6 +177,9 @@ static const char *fbSymbols[] = { "fbScreenInit", "fbBres", +#ifdef RENDER + "fbPictureInit", +#endif NULL }; #endif @@ -186,6 +209,13 @@ NULL }; +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + "vbeFree", + NULL +}; + static const char *i2cSymbols[] = { "xf86CreateI2CBusRec", "xf86I2CBusInit", @@ -352,7 +382,7 @@ fbSymbols, #endif ramdacSymbols, shadowSymbols, - i2cSymbols, ddcSymbols, + i2cSymbols, ddcSymbols, vbeSymbols, fbdevHWSymbols, int10Symbols, NULL); /* @@ -389,7 +419,7 @@ NVProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -448,9 +478,7 @@ &usedChips); /* Free it since we don't need that list after this */ - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -527,10 +555,13 @@ NVEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NVPtr pNv = NVPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "NVEnterVT\n")); - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); if (!NVModeInit(pScrn, pScrn->currentMode)) return FALSE; NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); @@ -558,10 +589,14 @@ NVLeaveVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + NVPtr pNv = NVPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "NVLeaveVT\n")); NVRestore(pScrn); - RivaEnterLeave(pScrn, FALSE); + pNv->riva.LockUnlock(&pNv->riva, 1); + vgaHWLock(hwp); } /* @@ -583,11 +618,12 @@ if (pScrn->vtSema) { NVRestore(pScrn); + pNv->riva.LockUnlock(&pNv->riva, 1); vgaHWLock(hwp); - NVUnmapMem(pScrn); - vgaHWUnmapMem(pScrn); } + NVUnmapMem(pScrn); + vgaHWUnmapMem(pScrn); if (pNv->AccelInfoRec) XAADestroyInfoRec(pNv->AccelInfoRec); if (pNv->CursorInfoRec) @@ -632,6 +668,81 @@ return (MODE_OK); } +static xf86MonPtr +nvDoDDC2(ScrnInfoPtr pScrn) +{ + NVPtr pNv = NVPTR(pScrn); + xf86MonPtr MonInfo = NULL; + + if (!pNv->i2cInit) return NULL; + + /* - DDC can use I2C bus */ + /* Load I2C if we have the code to use it */ + if ( xf86LoadSubModule(pScrn, "i2c") ) { + xf86LoaderReqSymLists(i2cSymbols,NULL); + if (pNv->i2cInit(pScrn)) { + DEBUG(ErrorF("I2C initialized on %p\n",pNv->I2C)); + if ((MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pNv->I2C))) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", + MonInfo); + xf86PrintEDID( MonInfo ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor " + "info\n\n"); + xf86SetDDCproperties(pScrn,MonInfo); + } + } + } + return MonInfo; +} + +static xf86MonPtr +nvDoDDC1(ScrnInfoPtr pScrn) +{ + NVPtr pNv = NVPTR(pScrn); + xf86MonPtr MonInfo = NULL; + + if (!pNv->ddc1Read || !pNv->DDC1SetSpeed) return NULL; + if (!pNv->Primary + && (pNv->DDC1SetSpeed == vgaHWddc1SetSpeed)) return NULL; + + if ((MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, pNv->DDC1SetSpeed, + pNv->ddc1Read ))) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", + MonInfo); + xf86PrintEDID( MonInfo ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n"); + xf86SetDDCproperties(pScrn,MonInfo); + } + return MonInfo; +} + +static xf86MonPtr +nvDoDDCVBE(ScrnInfoPtr pScrn) +{ + NVPtr pNv = NVPTR(pScrn); + xf86MonPtr MonInfo = NULL; + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + xf86LoaderReqSymLists(vbeSymbols,NULL); + pVbe = VBEInit(pNv->pInt,pNv->pEnt->index); + if (pVbe) { + if ((MonInfo = vbeDoEDID(pVbe,NULL))) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", + MonInfo); + xf86PrintEDID( MonInfo ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n"); + xf86SetDDCproperties(pScrn,MonInfo); + } + vbeFree(pVbe); + } else + xf86FreeInt10(pNv->pInt); + pNv->pInt = NULL; + } + return MonInfo; +} + + /* Internally used */ static xf86MonPtr NVdoDDC(ScrnInfoPtr pScrn) @@ -645,58 +756,45 @@ pNv = NVPTR(pScrn); NVdac = &pNv->Dac; - if (!pNv->Primary) { - /* XXX Need to write an NV mode ddc1SetSpeed */ - if (pNv->DDC1SetSpeed == vgaHWddc1SetSpeed) { - pNv->DDC1SetSpeed = NULL; - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, - "DDC1 disabled - chip not in VGA mode\n"); - } - } + /* Load DDC if we have the code to use it */ - /* Save the current state */ - NVSave(pScrn); + if (!xf86LoadSubModule(pScrn, "ddc")) return NULL; + + xf86LoaderReqSymLists(ddcSymbols, NULL); + + /* if ((MonInfo = nvDoDDCVBE(pScrn))) return MonInfo; */ /* Enable access to extended registers */ - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); + /* Save the current state */ + NVSave(pScrn); - /* It is now safe to talk to the card */ -#if NVuseI2C - /* Initialize I2C bus - used by DDC if available */ - if (pNv->i2cInit) { - pNv->i2cInit(pScrn); -#if 0 - ErrorF("I2C initialized on %p\n",pNv->I2C); + if ((MonInfo = nvDoDDC2(pScrn))) goto done; +#if 0 /* disable for now - causes problems on AXP */ + if ((MonInfo = nvDoDDC1(pScrn))) goto done; #endif - } - /* Read and output monitor info using DDC2 over I2C bus */ - if (pNv->I2C) { - MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pNv->I2C); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", MonInfo); - - xf86PrintEDID(MonInfo); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n\n"); - } - if (!MonInfo) -#endif /* NVuseI2C */ - /* Read and output monitor info using DDC1 */ - if (pNv->ddc1Read && pNv->DDC1SetSpeed) { - MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, pNv->DDC1SetSpeed, - pNv->ddc1Read ); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", - MonInfo); - xf86PrintEDID( MonInfo ); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n"); - } + done: /* Restore previous state */ NVRestore(pScrn); - - xf86SetDDCproperties(pScrn, MonInfo); + pNv->riva.LockUnlock(&pNv->riva, 1); + vgaHWLock(hwp); return MonInfo; } +static void +nvProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + /* Mandatory */ Bool NVPreInit(ScrnInfoPtr pScrn, int flags) @@ -709,8 +807,12 @@ char *mod = NULL; const char *reqSym = NULL; const char *s; + + if (flags & PROBE_DETECT) { + nvProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index ); + return TRUE; + } - if (flags & PROBE_DETECT) return FALSE; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVPreInit\n")); /* @@ -741,17 +843,6 @@ if (pNv->pEnt->location.type != BUS_PCI) return FALSE; - /* Initialize the card through int10 interface if needed */ - if ( xf86LoadSubModule(pScrn, "int10")){ - xf86Int10InfoPtr pInt; - - xf86LoaderReqSymLists(int10Symbols, NULL); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); - pInt = xf86InitInt10(pNv->pEnt->index); - xf86FreeInt10(pInt); - } - /* Find the PCI info for this screen */ pNv->PciInfo = xf86GetPciInfoForEntity(pNv->pEnt->index); pNv->PciTag = pciTag(pNv->PciInfo->bus, pNv->PciInfo->device, @@ -759,6 +850,18 @@ pNv->Primary = xf86IsPrimaryPci(pNv->PciInfo); + /* Initialize the card through int10 interface if needed */ +#if 0 + if ( !pNv->Primary &&) +#endif + if (xf86LoadSubModule(pScrn, "int10")){ + + xf86LoaderReqSymLists(int10Symbols, NULL); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n"); + pNv->pInt = xf86InitInt10(pNv->pEnt->index); + } + { resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB}, {ResShrIoBlock,0x3C0,0x3DF}, @@ -1056,6 +1159,14 @@ case NV_CHIP_GEFORCE256: case NV_CHIP_GEFORCEDDR: case NV_CHIP_QUADRO: + case NV_CHIP_GEFORCE2GTS: + case NV_CHIP_GEFORCE2GTS_1: + case NV_CHIP_GEFORCE2ULTRA: + case NV_CHIP_QUADRO2PRO: + case NV_CHIP_GEFORCE2MX: + case NV_CHIP_GEFORCE2MXDDR: + case NV_CHIP_QUADRO2MXR: + case NV_CHIP_GEFORCE2GO: NV10Setup(pScrn); break; } @@ -1086,36 +1197,39 @@ pNv->FbMapSize = pScrn->videoRam * 1024; - /* Load DDC if we have the code to use it */ - /* This gives us DDC1 */ - if (pNv->ddc1Read || pNv->i2cInit) { - if (xf86LoadSubModule(pScrn, "ddc")) { - xf86LoaderReqSymLists(ddcSymbols, NULL); - } else { - /* ddc module not found, we can do without it */ - pNv->ddc1Read = NULL; - - /* Without DDC, we have no use for the I2C bus */ - pNv->i2cInit = NULL; - } - } -#if NVuseI2C - /* - DDC can use I2C bus */ - /* Load I2C if we have the code to use it */ - if (pNv->i2cInit) { - if ( xf86LoadSubModule(pScrn, "i2c") ) { - xf86LoaderReqSymLists(i2cSymbols,NULL); - } else { - /* i2c module not found, we can do without it */ - pNv->i2cInit = NULL; - pNv->I2C = NULL; - } - } -#endif /* NVuseI2C */ - /* Read and print the Monitor DDC info */ pScrn->monitor->DDC = NVdoDDC(pScrn); - +#if 0 + /* + * This code was for testing. It will be removed as soon + * as this is integrated into the common level. + */ + if ((!pScrn->monitor->nHsync || !pScrn->monitor->nVrefresh) + && pScrn->monitor->DDC) { + int i; + int h = (!pScrn->monitor->nHsync) ? 0 : -1; + int v = (!pScrn->monitor->nVrefresh) ? 0 : -1; + xf86MonPtr pMon = (xf86MonPtr)pScrn->monitor->DDC; + for (i = 0; i < DET_TIMINGS; i++) { + if (pMon->det_mon[i].type == DS_RANGES) { + if (h != -1) { + pScrn->monitor->hsync[h].lo + = pMon->det_mon[i].section.ranges.min_h; + pScrn->monitor->hsync[h++].hi + = pMon->det_mon[i].section.ranges.max_h; + } + if (v != -1) { + pScrn->monitor->vrefresh[v].lo + = pMon->det_mon[i].section.ranges.min_v; + pScrn->monitor->vrefresh[v++].hi + = pMon->det_mon[i].section.ranges.max_v; + } + } + } + if (h != -1) pScrn->monitor->nHsync = h; + if (v != -1) pScrn->monitor->nVrefresh = v; + } +#endif /* * If the driver can do gamma correction, it should call xf86SetGamma() * here. @@ -1394,7 +1508,7 @@ if (!(*pNv->ModeInit)(pScrn, mode)) return FALSE; } - + /* Program the registers */ vgaHWProtect(pScrn, TRUE); vgaReg = &hwp->ModeReg; @@ -1483,6 +1597,8 @@ return FALSE; } else { /* Save the current state */ + vgaHWUnlock(hwp); + pNv->riva.LockUnlock(&pNv->riva, 0); NVSave(pScrn); /* Initialise the first mode */ if (!NVModeInit(pScrn, pScrn->currentMode)) @@ -1516,16 +1632,22 @@ /* Setup the visuals we support. */ - if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } +#ifndef NV_USE_FB + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + pScrn->defaultVisual)) + return FALSE; + } else +#endif + { + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } +#ifdef NV_USE_FB + if (!miSetPixmapDepths ()) return FALSE; +#endif DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Visuals set up\n")); @@ -1575,6 +1697,10 @@ ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif break; #endif default: Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h:1.8 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h:1.8 Tue Apr 4 15:25:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h Fri Oct 6 08:31:03 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h,v 1.8 2000/04/04 19:25:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h,v 1.9 2000/10/06 12:31:03 eich Exp $ */ #ifndef __NV_INCLUDE_H__ #define __NV_INCLUDE_H__ @@ -25,6 +25,8 @@ #include "micmap.h" #include "xf86DDC.h" + +#include "vbe.h" #include "xf86RAC.h" Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h:1.3 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h:1.3 Wed Feb 9 15:57:10 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h Fri Nov 3 13:46:12 2000 @@ -36,7 +36,7 @@ |* those rights set forth herein. *| |* *| \***************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h,v 1.2 2000/02/09 17:10:26 dawes Exp */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_local.h,v 1.6 2000/11/03 18:46:12 eich Exp $ */ #ifndef __NV_LOCAL_H__ #define __NV_LOCAL_H__ @@ -45,6 +45,7 @@ * Put all affected includes, typdefs, etc. here so the riva_hw.* files can stay * generic in nature. */ +#include "xf86_ansic.h" #include "compiler.h" /* * Typedefs to force certain sized values. @@ -55,12 +56,14 @@ /* * HW access macros. */ -#define NV_WR08(p,i,d) (((U008 *)(p))[i]=(d)) -#define NV_RD08(p,i) (((U008 *)(p))[i]) -#define NV_WR16(p,i,d) (((U016 *)(p))[(i)/2]=(d)) -#define NV_RD16(p,i) (((U016 *)(p))[(i)/2]) -#define NV_WR32(p,i,d) (((U032 *)(p))[(i)/4]=(d)) -#define NV_RD32(p,i) (((U032 *)(p))[(i)/4]) +#include "xf86_OSproc.h" +/* these assume memory-mapped I/O, and not normal I/O space */ +#define NV_WR08(p,i,d) MMIO_OUT8((volatile pointer)(p), (i), (d)) +#define NV_RD08(p,i) MMIO_IN8((volatile pointer)(p), (i)) +#define NV_WR16(p,i,d) MMIO_OUT16((volatile pointer)(p), (i), (d)) +#define NV_RD16(p,i) MMIO_IN16((volatile pointer)(p), (i)) +#define NV_WR32(p,i,d) MMIO_OUT32((volatile pointer)(p), (i), (d)) +#define NV_RD32(p,i) MMIO_IN32((volatile pointer)(p), (i)) #if 1 #define VGA_WR08(p,i,d) NV_WR08(p,i,d) #define VGA_RD08(p,i) NV_RD08(p,i) Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c:1.6 Thu Feb 10 13:59:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c Fri Nov 3 13:46:12 2000 @@ -24,7 +24,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.6 2000/02/10 18:59:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.7 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" @@ -32,26 +32,6 @@ #include "nvvga.h" /* - * Lock and unlock VGA and SVGA registers. - */ -void RivaEnterLeave(ScrnInfoPtr pScrn, Bool enter) -{ - vgaHWPtr hwp = VGAHWPTR(pScrn); - NVPtr pNv = NVPTR(pScrn); - - if (enter) - { - vgaHWUnlock(hwp); - pNv->riva.LockUnlock(&pNv->riva, 0); - } - else - { - pNv->riva.LockUnlock(&pNv->riva, 1); - vgaHWLock(hwp); - } -} - -/* * Override VGA I/O routines. */ static void NVWriteCrtc(vgaHWPtr pVga, CARD8 index, CARD8 value) @@ -279,7 +259,8 @@ pNv->Dac.maxPixelClock = pNv->riva.MaxVClockFreqKHz; - RivaEnterLeave(pScrn, TRUE); + vgaHWUnlock(VGAHWPTR(pScrn)); + pNv->riva.LockUnlock(&pNv->riva, 0); } void Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h:1.12 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h:1.12 Mon Mar 13 13:49:29 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h Thu Dec 7 16:42:17 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.12 2000/03/13 18:49:29 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.18 2000/12/07 21:42:17 mvojkovi Exp $ */ #ifndef __NV_STRUCT_H__ #define __NV_STRUCT_H__ @@ -8,6 +8,7 @@ #include "vgaHW.h" #include "xaa.h" #include "xf86Cursor.h" +#include "xf86int10.h" #define SetBitField(value,from,to) SetBF(to, GetBF(value,from)) #define SetBit(n) (1<<(n)) @@ -57,7 +58,7 @@ int ChipRev; Bool Primary; CARD32 IOAddress; - CARD32 FbAddress; + unsigned long FbAddress; int FbBaseReg; unsigned char * IOBase; unsigned char * FbBase; @@ -111,6 +112,7 @@ void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed); Bool (*i2cInit)(ScrnInfoPtr); I2CBusPtr I2C; + xf86Int10InfoPtr pInt; } NVRec, *NVPtr; #define NVPTR(p) ((NVPtr)((p)->driverPrivate)) @@ -131,5 +133,13 @@ #define NV_CHIP_GEFORCE256 ((PCI_VENDOR_NVIDIA << 16)| PCI_CHIP_GEFORCE256) #define NV_CHIP_GEFORCEDDR ((PCI_VENDOR_NVIDIA << 16)| PCI_CHIP_GEFORCEDDR) #define NV_CHIP_QUADRO ((PCI_VENDOR_NVIDIA << 16)| PCI_CHIP_QUADRO) +#define NV_CHIP_GEFORCE2MX ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2MX) +#define NV_CHIP_GEFORCE2MXDDR ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2MXDDR) +#define NV_CHIP_QUADRO2MXR ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_QUADRO2MXR) +#define NV_CHIP_GEFORCE2GO ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2GO) +#define NV_CHIP_GEFORCE2GTS ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2GTS) +#define NV_CHIP_GEFORCE2GTS_1 ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2GTS_1) +#define NV_CHIP_GEFORCE2ULTRA ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_GEFORCE2ULTRA) +#define NV_CHIP_QUADRO2PRO ((PCI_VENDOR_NVIDIA << 16) | PCI_CHIP_QUADRO2PRO) #endif /* __NV_STRUCT_H__ */ Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c:1.14 xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c:1.14 Fri Feb 25 16:02:57 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c Fri Nov 3 13:46:12 2000 @@ -41,7 +41,7 @@ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen <jpaana@s2.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.14 2000/02/25 21:02:57 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.18 2000/11/03 18:46:12 eich Exp $ */ #include "nv_include.h" #include "xaalocal.h" @@ -52,6 +52,8 @@ #include "miline.h" +#define DOLINES + /* * Macro to define valid rectangle. */ @@ -67,9 +69,16 @@ RIVA_FIFO_FREE(pNv->riva, Clip, 2); pNv->riva.Clip->TopLeft = (y1 << 16) | (x1 & 0xffff); pNv->riva.Clip->WidthHeight = (height << 16) | width; + mem_barrier(); } +static void +NVDisableClipping(ScrnInfoPtr pScrn) +{ + NVSetClippingRectangle(pScrn, 0, 0, 0x7fff, 0x7fff); +} + /* * Set pattern. Internal routine. The upper bits of the colors * are the ALPHA bits. 0 == transparency. @@ -134,6 +143,7 @@ RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } /* @@ -152,10 +162,14 @@ { NVPtr pNv = NVPTR(pScrn); +/* ErrorF("E SubseqSS\n"); */ RIVA_FIFO_FREE(pNv->riva, Blt, 3); pNv->riva.Blt->TopLeftSrc = (y1 << 16) | x1; pNv->riva.Blt->TopLeftDst = (y2 << 16) | x2; pNv->riva.Blt->WidthHeight = (h << 16) | w; + mem_barrier(); +/* ErrorF("L SubseqSS\n"); */ + } @@ -191,6 +205,7 @@ bg = (bg == -1) ? 0 : bg | pNv->opaqueMonochrome; }; NVSetPattern(pNv, bg, fg, patternx, patterny); + mem_barrier(); RIVA_FIFO_FREE(pNv->riva, Bitmap, 1); pNv->riva.Bitmap->Color1A = fg; } @@ -205,6 +220,7 @@ RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } @@ -216,8 +232,9 @@ void NVSync(ScrnInfoPtr pScrn) { NVPtr pNv = NVPTR(pScrn); - +/* ErrorF("sync enter\n"); */ while (pNv->riva.Busy(&pNv->riva)); +/* ErrorF("sync leave\n"); */ } /* Color expansion */ @@ -441,10 +458,8 @@ } } - -#if 0 -/* Broken at the moment */ +#ifdef DOLINES static void NVSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned planemask) @@ -452,8 +467,9 @@ NVPtr pNv = NVPTR(pScrn); NVSetRopSolid(pNv, rop); + mem_barrier(); RIVA_FIFO_FREE(pNv->riva, Line, 1); - pNv->riva.Line->Color = color; + pNv->FgColor = color; } static void @@ -461,12 +477,14 @@ { NVPtr pNv = NVPTR(pScrn); - RIVA_FIFO_FREE(pNv->riva, Line, 2); - pNv->riva.Line->Lin[0].point0 = (y << 16) | ( x & 0xffff); + RIVA_FIFO_FREE(pNv->riva, Line, 3); + pNv->riva.Line->Color = pNv->FgColor; + pNv->riva.Line->Lin[0].point0 = ((y << 16) | ( x & 0xffff)); if ( dir ==DEGREES_0 ) - pNv->riva.Line->Lin[0].point1 = (y << 16) | (( x + len ) & 0xffff); + pNv->riva.Line->Lin[0].point1 = ((y << 16) | (( x + len ) & 0xffff)); else - pNv->riva.Line->Lin[0].point1 = ((y + len) << 16) | ( x & 0xffff); + pNv->riva.Line->Lin[0].point1 = (((y + len) << 16) | ( x & 0xffff)); + mem_barrier(); } static void @@ -474,18 +492,18 @@ int x2, int y2, int flags) { NVPtr pNv = NVPTR(pScrn); + Bool lastPoint = !(flags & OMIT_LAST); - RIVA_FIFO_FREE(pNv->riva, Line, 2); - if ( flags & OMIT_LAST ) + RIVA_FIFO_FREE(pNv->riva, Line, lastPoint ? 5 : 3); + pNv->riva.Line->Color = pNv->FgColor; + pNv->riva.Line->Lin[0].point0 = ((y1 << 16) | (x1 & 0xffff)); + pNv->riva.Line->Lin[0].point1 = ((y2 << 16) | (x2 & 0xffff)); + if (lastPoint) { - pNv->riva.Line->Lin[0].point1 = (y1 << 16) | ( x1 & 0xffff); - pNv->riva.Line->PolyLin[0] = (y2 << 16) | ( x2 & 0xffff); + pNv->riva.Line->Lin[1].point0 = ((y2 << 16) | (x2 & 0xffff)); + pNv->riva.Line->Lin[1].point1 = (((y2 + 1) << 16) | (x2 & 0xffff)); } - else - { - pNv->riva.Line->Lin[0].point0 = (y1 << 16) | ( x1 & 0xffff); - pNv->riva.Line->Lin[0].point1 = (y2 << 16) | ( x2 & 0xffff); - } + mem_barrier(); } #else @@ -548,6 +566,7 @@ RIVA_FIFO_FREE(pNv->riva, Bitmap, 2); pNv->riva.Bitmap->UnclippedRectangle[0].TopLeft = (x << 16) | y; pNv->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (w << 16) | h; + mem_barrier(); } #ifndef NV_USE_FB @@ -720,19 +739,22 @@ infoPtr->ScanlineImageWriteBuffers = &pNv->expandBuffer; } -#if 0 - /* Solid lines, don't work yet */ +#ifdef DOLINES infoPtr->SolidLineFlags = NO_PLANEMASK; - infoPtr->PolySegmentThinSolidFlags = NO_PLANEMASK; - infoPtr->PolylinesThinSolidFlags = NO_PLANEMASK; infoPtr->SetupForSolidLine = NVSetupForSolidLine; infoPtr->SubsequentSolidHorVertLine = NVSubsequentSolidHorVertLine; infoPtr->SubsequentSolidTwoPointLine = NVSubsequentSolidTwoPointLine; + infoPtr->SetClippingRectangle = NVSetClippingRectangle; + infoPtr->DisableClipping = NVDisableClipping; + infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_LINE; + miSetZeroLineBias(pScreen, OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6); #else infoPtr->SolidLineFlags = NO_PLANEMASK; infoPtr->SetupForSolidLine = NVSetupForSolidLine; + infoPtr->PolySegmentThinSolidFlags = NO_PLANEMASK; + infoPtr->PolylinesThinSolidFlags = NO_PLANEMASK; infoPtr->SubsequentSolidHorVertLine = NVSubsequentSolidHorVertLine; infoPtr->SubsequentSolidBresenhamLine = @@ -747,8 +769,9 @@ infoPtr->PolyArcMask = GCFunction | GCLineWidth | GCPlaneMask; infoPtr->ValidatePolyPoint = NVValidatePolyPoint; infoPtr->PolyPointMask = GCFunction | GCPlaneMask; + + NVDisableClipping(pScrn); - NVSetClippingRectangle(pScrn, 0, 0, 0x7fff, 0x7fff); return(XAAInit(pScreen, infoPtr)); } Index: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h:1.6 Tue Feb 8 12:19:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h Fri Nov 3 13:46:12 2000 @@ -36,7 +36,7 @@ |* those rights set forth herein. *| |* *| \***************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.6 2000/02/08 17:19:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.7 2000/11/03 18:46:12 eich Exp $ */ #ifndef __RIVA_HW_H__ #define __RIVA_HW_H__ #define RIVA_SW_VERSION 0x00010003 @@ -425,8 +425,10 @@ #define RIVA_FIFO_FREE(hwinst,hwptr,cnt) \ { \ - while ((hwinst).FifoFreeCount < (cnt)) \ + while ((hwinst).FifoFreeCount < (cnt)) { \ + mem_barrier(); \ (hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2; \ + } \ (hwinst).FifoFreeCount -= (cnt); \ } #endif /* __RIVA_HW_H__ */ Index: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h diff -u xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h:1.5 Tue Feb 8 12:19:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h Fri Aug 11 01:04:08 2000 @@ -36,7 +36,10 @@ |* those rights set forth herein. *| |* *| \***************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h,v 1.5 2000/02/08 17:19:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h,v 1.6 2000/08/11 05:04:08 mvojkovi Exp $ */ + +#define NV_NEW + /* * RIVA Fixed Functionality Init Tables. */ @@ -61,6 +64,9 @@ {0x00001800, 0x80000010}, {0x00002000, 0x80000011}, {0x00002800, 0x80000012}, +#ifdef NV_NEW + {0x00003000, 0x80000016}, +#endif {0x00003800, 0x80000013} }; static unsigned nv3TablePFIFO[][2] = @@ -166,6 +172,10 @@ {0x00000249, 0x00CC0346}, {0x0000024C, 0x80000013}, {0x0000024D, 0x00D70347}, +#ifdef NV_NEW + {0x00000258, 0x80000016}, + {0x00000259, 0x00CA034C}, +#endif {0x00000D05, 0x00000000}, {0x00000D06, 0x00000000}, {0x00000D07, 0x00000000}, @@ -202,7 +212,13 @@ {0x00000D2C, 0x10830200}, {0x00000D2D, 0x00000000}, {0x00000D2E, 0x00000000}, - {0x00000D2F, 0x00000000} + {0x00000D2F, 0x00000000} +#ifdef NV_NEW + , + {0x00000D31, 0x00000000}, + {0x00000D32, 0x00000000}, + {0x00000D33, 0x00000000} +#endif }; static unsigned nv3TablePRAMIN_8BPP[][2] = { @@ -215,6 +231,10 @@ {0x00000D14, 0x10110203}, {0x00000D18, 0x10110203}, {0x00000D1C, 0x10419208} +#ifdef NV_NEW + , + {0x00000D30, 0x10118203} +#endif }; static unsigned nv3TablePRAMIN_15BPP[][2] = { @@ -227,6 +247,10 @@ {0x00000D14, 0x10110200}, {0x00000D18, 0x10110200}, {0x00000D1C, 0x10419208} +#ifdef NV_NEW + , + {0x00000D30, 0x10118200} +#endif }; static unsigned nv3TablePRAMIN_32BPP[][2] = { @@ -239,6 +263,10 @@ {0x00000D14, 0x10110201}, {0x00000D18, 0x10110201}, {0x00000D1C, 0x10419208} +#ifdef NV_NEW + , + {0x00000D30, 0x10118201} +#endif }; static unsigned nv4TableFIFO[][2] = { @@ -362,6 +390,10 @@ {0x00000009, 0x80011149}, {0x0000000A, 0x80000015}, {0x0000000B, 0x8001114A}, +#ifdef NV_NEW + {0x0000000C, 0x80000016}, + {0x0000000D, 0x8001114F}, +#endif {0x00000020, 0x80000000}, {0x00000021, 0x80011142}, {0x00000022, 0x80000001}, @@ -430,6 +462,12 @@ {0x00000538, 0x0000005B}, {0x0000053A, 0x11401140}, {0x0000053B, 0x00000000} +#ifdef NV_NEW + , + {0x0000053C, 0x0300A01C}, + {0x0000053E, 0x11401140}, + {0x0000053F, 0x00000000} +#endif }; static unsigned nv4TablePRAMIN_8BPP[][2] = { @@ -444,7 +482,11 @@ {0x0000052D, 0x00000302}, {0x0000052E, 0x00000302}, {0x00000535, 0x00000000}, - {0x00000539, 0x00000000} + {0x00000539, 0x00000000} +#ifdef NV_NEW + , + {0x0000053D, 0x00000302} +#endif }; static unsigned nv4TablePRAMIN_15BPP[][2] = { @@ -460,6 +502,10 @@ {0x0000052E, 0x00000902}, {0x00000535, 0x00000702}, {0x00000539, 0x00000702} +#ifdef NV_NEW + , + {0x0000053D, 0x00000902} +#endif }; static unsigned nv4TablePRAMIN_16BPP[][2] = { @@ -475,6 +521,10 @@ {0x0000052E, 0x00000C02}, {0x00000535, 0x00000702}, {0x00000539, 0x00000702} +#ifdef NV_NEW + , + {0x0000053D, 0x00000C02} +#endif }; static unsigned nv4TablePRAMIN_32BPP[][2] = { @@ -490,6 +540,10 @@ {0x0000052E, 0x00000E02}, {0x00000535, 0x00000E02}, {0x00000539, 0x00000E02} +#ifdef NV_NEW + , + {0x0000053D, 0x00000E02} +#endif }; static unsigned nv10TableFIFO[][2] = { @@ -802,6 +856,10 @@ {0x00000009, 0x80011149}, {0x0000000A, 0x80000015}, {0x0000000B, 0x8001114A}, +#ifdef NV_NEW + {0x0000000C, 0x80000016}, + {0x0000000D, 0x80011150}, +#endif {0x00000020, 0x80000000}, {0x00000021, 0x80011142}, {0x00000022, 0x80000001}, @@ -875,6 +933,12 @@ {0x0000053C, 0x00000093}, {0x0000053E, 0x11401140}, {0x0000053F, 0x00000000} +#ifdef NV_NEW + , + {0x00000540, 0x0300A01C}, + {0x00000542, 0x11401140}, + {0x00000543, 0x00000000} +#endif }; static unsigned nv10TablePRAMIN_8BPP[][2] = { @@ -891,6 +955,10 @@ {0x00000535, 0x00000000}, {0x00000539, 0x00000000}, {0x0000053D, 0x00000000} +#ifdef NV_NEW + , + {0x00000541, 0x00000302} +#endif }; static unsigned nv10TablePRAMIN_15BPP[][2] = { @@ -907,6 +975,10 @@ {0x00000535, 0x00000902}, {0x00000539, 0x00000902}, {0x0000053D, 0x00000902} +#ifdef NV_NEW + , + {0x00000541, 0x00000902} +#endif }; static unsigned nv10TablePRAMIN_16BPP[][2] = { @@ -923,6 +995,10 @@ {0x00000535, 0x00000C02}, {0x00000539, 0x00000C02}, {0x0000053D, 0x00000C02} +#ifdef NV_NEW + , + {0x00000541, 0x00000C02} +#endif }; static unsigned nv10TablePRAMIN_32BPP[][2] = { @@ -939,5 +1015,9 @@ {0x00000535, 0x00000E02}, {0x00000539, 0x00000E02}, {0x0000053D, 0x00000E02} +#ifdef NV_NEW + , + {0x00000541, 0x00000E02} +#endif }; Index: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile:1.8 xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile:1.8 Fri Jun 16 20:03:21 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile Mon Dec 18 14:30:59 2000 @@ -1,69 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.8 2000/06/17 00:03:21 martin Exp $ -XCOMM -XCOMM This is the Imakefile for the ATI Rage 128 (r128) driver. -XCOMM - -#define IHaveModules -#include <Server.tmpl> - -#if BuildXF86DRI -DRISRCS = r128_dri.c -DRIOBJS = r128_dri.o -DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include -DRIDEFINES = $(GLX_DEFINES) -#endif - -SRCS = r128_driver.c r128_cursor.c r128_accel.c r128_dga.c $(DRISRCS) # r128_i2c.c - -OBJS = r128_driver.o r128_cursor.o r128_accel.o r128_dga.o $(DRIOBJS) # r128_i2c.o - -#if defined(XF86DriverSDK) -INCLUDES = -I. -I../../include -#else -INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ - -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ - -I$(SERVERSRC)/fb \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \ - -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ - -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86OSSRC)/vbe \ - -I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \ - -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \ - $(DRIINCLUDES) -#endif - -DEFINES = $(DRIDEFINES) - -#if MakeHasPosixVariableSubstitutions -SubdirLibraryRule($(OBJS)) -#endif - -ModuleObjectRule() - -ObjectModuleTarget(r128,$(OBJS)) - -InstallObjectModule(r128,$(MODULEDIR),drivers) - -#if !defined(XF86DriverSDK) -CppManTarget(r128,) -InstallModuleManPage(r128) -#endif - -DependTarget() - -InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128.h,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_accel.c,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_cursor.c,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_driver.c,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_dga.c,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_reg.h,$(DRIVERSDKDIR)/drivers/r128) - -InstallDriverSDKNonExecFile(r128_dri.c,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_dri.h,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_dripriv.h,$(DRIVERSDKDIR)/drivers/r128) -InstallDriverSDKNonExecFile(r128_sarea.h,$(DRIVERSDKDIR)/drivers/r128) - -InstallDriverSDKObjectModule(r128,$(DRIVERSDKMODULEDIR),drivers) - Index: xc/programs/Xserver/hw/xfree86/drivers/r128/README diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/README:1.4 xc/programs/Xserver/hw/xfree86/drivers/r128/README:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/README:1.4 Tue Jun 13 20:16:11 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/README Mon Dec 18 14:30:59 2000 @@ -1,114 +0,0 @@ - Information for ATI Rage 128 Users - - Precision Insight, Inc. - - 12 November 1999 - - r128 Driver Version 3.0.0 - - - -1. Supported Hardware - - * ATI Rage 128 based cards - - -2. Features - - * Full support (including hardware accelerated 2D drawing) for 8, 15, - 16, 24, and 32 bit per pixel depths. - * Hardware cursor support to reduce sprite flicker. - * Support for high resolution video modes up to 1800x1440 @ 70Hz. - * Support for doublescan video modes (e.g., 320x200 and 320x240). - * Support for gamma correction at all pixel depths. - * Fully programmable clock supported. - * Robust text mode restore for VT switching. - - -3. Technical Notes - - * None - - -4. Reported Working Video Cards - - * Rage Fury AGP 32MB - * XPERT 128 AGP 16MB - * XPERT 99 AGP 8MB - - -5. Configuration - - The driver auto-detects all device information necessary to - initialize the card. The only lines you need in the "Device" - section of your XF86Config file are: - - Section "Device" - Identifier "Rage 128" - Driver "r128" - EndSection - - or let xf86config or XF86Setup do this for you. - - However, if you have problems with auto-detection, you can specify: - - VideoRam - in kilobytes - MemBase - physical address of the linear framebuffer - IOBase - physical address of the memory mapped IO registers - ChipID - PCI DEVICE ID - - -6. Driver Options - - "hw_cursor" - request hardware cursor (default) - "sw_cursor" - software cursor only - "noaccel" - software rendering only (no hardware acceleration) - "dac_8_bit" - use color weight 888 in 8 bpp mode (default) - "dac_6_bit" - use color weight 666 in 8 bpp mode (VGA emulation) - - -7. Known Limitations - - * None - - -8. Authors - - The XFree86 3.9 driver was ported from XFree86 3.3 and enhanced by: - - * Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - - The XFree86 3.9 driver was funded by ATI and was donated to The - XFree86 Project by: - - Precision Insight, Inc. - Cedar Park, TX - USA - - http://www.precisioninsight.com - - - The XFree86 3.3 driver used for the port was written by: - - * Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - - The XFree86 3.3 driver was funded by ATI and was donated to The - XFree86 Project by Precision Insight, Inc. It was based in part on - an earlier driver that was written by: - - * Alan Hourihane alanh@fairlite.demon.co.uk - * Dirk Hohndel <hohndel@suse.de> - - This early driver was funded and donated to The XFree86 Project by: - - SuSE GmbH - Schanzaekerstr. 10 - 90443 Nuernberg - Germany - - http://www.suse.com - - -$XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/README,v 1.4 2000/06/14 00:16:11 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp:1.6 xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp:1.6 Tue Jun 13 22:13:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp Mon Dec 18 14:31:00 2000 @@ -1,70 +0,0 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp,v 1.6 2000/06/14 02:13:13 dawes Exp $ -.\" shorthand for double quote that works everywhere. -.ds q \N'34' -.TH R128 __drivermansuffix__ "Version 4.0.1" "XFree86" -.SH NAME -r128 \- ATI Rage 128 video driver -.SH SYNOPSIS -.nf -.B "Section \*qDevice\*q" -.BI " Identifier \*q" devname \*q -.B " Driver \*qr128\*q" -\ \ ... -.B EndSection -.fi -.SH DESCRIPTION -.B r128 -is an XFree86 driver for ATI Rage 128 based video cards. It contains -full support for 8, 15, 16 and 24 bit pixel depths, hardware -acceleration of drawing primitives, hardware cursor, video modes up to -1800x1440 @ 70Hz, doublescan modes (e.g., 320x200 and 320x240), gamma -correction at all pixel depths, a fully programming dot clock and robust -text mode restoration for VT switching. -.SH SUPPORTED HARDWARE -The -.B r128 -driver supports all ATI Rage 128 based video cards including the Rage -Fury AGP 32MB, the XPERT 128 AGP 16MB and the XPERT 99 AGP 8MB. -.SH CONFIGURATION DETAILS -Please refer to XF86Config(__filemansuffix__) for general configuration -details. This section only covers configuration details specific to this -driver. -.PP -The driver auto-detects all device information necessary to initialize -the card. However, if you have problems with auto-detection, you can -specify: -.PP -.RS 4 -VideoRam - in kilobytes -.br -MemBase - physical address of the linear framebuffer -.br -IOBase - physical address of the MMIO registers -.br -ChipID - PCI DEVICE ID -.RE -.PP -In addition, the following driver -.B Options -are supported: -.TP -.BI "Option \*qSWcursor\*q \*q" boolean \*q -Selects software cursor. The default is -.B off. -.TP -.BI "Option \*qNoAccel\*q \*q" boolean \*q -Enables or disables all hardware acceleration. The default is to -.B enable -hardware acceleration. -.TP -.BI "Option \*qDac6Bit\*q \*q" boolean \*q -Enables or disables the use of 6 bits per color component when in 8 bpp -mode (emulates VGA mode). By default, all 8 bits per color component -are used. The default is -.B off. -.SH "SEE ALSO" -XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) -.SH AUTHORS -.nf -Rickard E. (Rik) Faith \fIfaith@precisioninsight.com\fP -Kevin E. Martin \fIkevin@precisioninsight.com\fP Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h:1.10 xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h:1.10 Fri Jun 16 20:03:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h Mon Dec 18 14:31:00 2000 @@ -1,363 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.10 2000/06/17 00:03:22 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - */ - -#ifndef _R128_H_ -#define _R128_H_ - -#define R128_DEBUG 0 /* Turn off debugging output */ -#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ -#define R128_MMIOSIZE 0x80000 - - /* R128_NAME is used for the server-side - ddx driver, the client-side DRI driver, - and the kernel-level DRM driver. */ -#define R128_NAME "r128" -#define R128_VERSION_MAJOR 3 -#define R128_VERSION_MINOR 1 -#define R128_VERSION_PATCH 1 -#define R128_VERSION ((R128_VERSION_MAJOR << 16) \ - | (R128_VERSION_MINOR << 8) \ - | R128_VERSION_PATCH) - -#if R128_DEBUG -#define R128TRACE(x) \ - do { \ - ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ - ErrorF x; \ - } while (0); -#else -#define R128TRACE(x) -#endif - - -/* Other macros */ -#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1)) -#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate) - -typedef struct { /* All values in XCLKS */ - int ML; /* Memory Read Latency */ - int MB; /* Memory Burst Length */ - int Trcd; /* RAS to CAS delay */ - int Trp; /* RAS percentage */ - int Twr; /* Write Recovery */ - int CL; /* CAS Latency */ - int Tr2w; /* Read to Write Delay */ - int Rloop; /* Loop Latency */ - int Rloop_fudge; /* Add to ML to get Rloop */ - char *name; -} R128RAMRec, *R128RAMPtr; - -typedef struct { - /* Common registers */ - CARD32 ovr_clr; - CARD32 ovr_wid_left_right; - CARD32 ovr_wid_top_bottom; - CARD32 ov0_scale_cntl; - CARD32 mpp_tb_config; - CARD32 mpp_gp_config; - CARD32 subpic_cntl; - CARD32 viph_control; - CARD32 i2c_cntl_1; - CARD32 gen_int_cntl; - CARD32 cap0_trig_cntl; - CARD32 cap1_trig_cntl; - CARD32 bus_cntl; - - /* Other registers to save for VT switches */ - CARD32 dp_datatype; - CARD32 gen_reset_cntl; - CARD32 clock_cntl_index; - CARD32 amcgpio_en_reg; - CARD32 amcgpio_mask; - - /* CRTC registers */ - CARD32 crtc_gen_cntl; - CARD32 crtc_ext_cntl; - CARD32 dac_cntl; - CARD32 crtc_h_total_disp; - CARD32 crtc_h_sync_strt_wid; - CARD32 crtc_v_total_disp; - CARD32 crtc_v_sync_strt_wid; - CARD32 crtc_offset; - CARD32 crtc_offset_cntl; - CARD32 crtc_pitch; - - /* CRTC2 registers */ - CARD32 crtc2_gen_cntl; - - /* Flat panel registers */ - CARD32 fp_crtc_h_total_disp; - CARD32 fp_crtc_v_total_disp; - CARD32 fp_gen_cntl; - CARD32 fp_h_sync_strt_wid; - CARD32 fp_horz_stretch; - CARD32 fp_panel_cntl; - CARD32 fp_v_sync_strt_wid; - CARD32 fp_vert_stretch; - CARD32 lvds_gen_cntl; - CARD32 tmds_crc; - - /* Computed values for PLL */ - int dot_clock_freq; - int pll_output_freq; - int feedback_div; - int post_div; - - /* PLL registers */ - CARD32 ppll_ref_div; - CARD32 ppll_div_3; - CARD32 htotal_cntl; - - /* DDA register */ - CARD32 dda_config; - CARD32 dda_on_off; - - /* Pallet */ - Bool palette_valid; - CARD32 palette[256]; -} R128SaveRec, *R128SavePtr; - -typedef struct { - CARD16 reference_freq; - CARD16 reference_div; - CARD32 min_pll_freq; - CARD32 max_pll_freq; - CARD16 xclk; -} R128PLLRec, *R128PLLPtr; - -typedef struct { - int bitsPerPixel; - int depth; - int displayWidth; - int pixel_code; - int pixel_bytes; - DisplayModePtr mode; -} R128FBLayout; - -typedef struct { - EntityInfoPtr pEnt; - pciVideoPtr PciInfo; - PCITAG PciTag; - int Chipset; - Bool Primary; - - Bool FBDev; - - unsigned long LinearAddr; /* Frame buffer physical address */ - unsigned long MMIOAddr; /* MMIO region physical address */ - unsigned long BIOSAddr; /* BIOS physical address */ - - unsigned char *MMIO; /* Map of MMIO region */ - unsigned char *FB; /* Map of frame buffer */ - - CARD32 MemCntl; - CARD32 BusCntl; - unsigned long FbMapSize; /* Size of frame buffer, in bytes */ - int Flags; /* Saved copy of mode flags */ - - Bool EnableFP; /* Enable use of FP registers */ - Bool CRTOnly; /* Only use External CRT instead of FP */ - Bool HasPanelRegs; /* Current chip can connect to a FP */ - - /* Computed values for FPs */ - int PanelXRes; - int PanelYRes; - int PanelHNonVis; - int PanelHOverPlus; - int PanelHSyncWidth; - int PanelVNonVis; - int PanelVOverPlus; - int PanelVSyncWidth; - - R128PLLRec pll; - R128RAMPtr ram; - - R128SaveRec SavedReg; /* Original (text) mode */ - R128SaveRec ModeReg; /* Current mode */ - Bool (*CloseScreen)(int, ScreenPtr); - - Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ - - I2CBusPtr i2c; - XAAInfoRecPtr accel; - xf86CursorInfoPtr cursor; - unsigned long cursor_start; - unsigned long cursor_end; - - int fifo_slots; /* Free slots in the FIFO (64 max) */ - int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ - Bool dac6bits; /* Use 6 bit DAC? */ - - /* Computed values for Rage 128 */ - int pitch; - int datatype; - CARD32 dp_gui_master_cntl; - - /* Saved values for ScreenToScreenCopy */ - int xdir; - int ydir; - - /* ScanlineScreenToScreenColorExpand support */ - unsigned char *scratch_buffer[1]; - unsigned char *scratch_save; - int scanline_x; - int scanline_y; - int scanline_h; - int scanline_h_w; - int scanline_words; - int scanline_direct; - int scanline_bpp; /* Only used for ImageWrite */ - - DGAModePtr DGAModes; - int numDGAModes; - Bool DGAactive; - int DGAViewportStatus; - - R128FBLayout CurrentLayout; -#ifdef XF86DRI - Bool directRenderingEnabled; - DRIInfoPtr pDRIInfo; - int drmFD; - int numVisualConfigs; - __GLXvisualConfig *pVisualConfigs; - R128ConfigPrivPtr pVisualConfigsPriv; - - drmHandle fbHandle; - - drmSize registerSize; - drmHandle registerHandle; - - Bool IsPCI; /* Current card is a PCI card */ - - drmSize agpSize; - drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ - unsigned long agpOffset; - unsigned char *AGP; /* Map */ - int agpMode; - - Bool CCEInUse; /* CCE is currently active */ - int CCEMode; /* CCE mode that server/clients use */ - int CCEFifoSize; /* Size of the CCE command FIFO */ - Bool CCESecure; /* CCE security enabled */ - int CCEusecTimeout; /* CCE timeout in usecs */ - Bool CCE2D; /* CCE is used for X server 2D prims */ - - /* CCE ring buffer data */ - unsigned long ringStart; /* Offset into AGP space */ - drmHandle ringHandle; /* Handle from drmAddMap */ - drmSize ringMapSize; /* Size of map */ - int ringSize; /* Size of ring (in MB) */ - unsigned char *ring; /* Map */ - int ringSizeLog2QW; - - unsigned long ringReadOffset; /* Offset into AGP space */ - drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ - drmSize ringReadMapSize; /* Size of map */ - unsigned char *ringReadPtr; /* Map */ - - /* CCE vertex buffer data */ - unsigned long vbStart; /* Offset into AGP space */ - drmHandle vbHandle; /* Handle from drmAddMap */ - drmSize vbMapSize; /* Size of map */ - int vbSize; /* Size of vert bufs (in MB) */ - unsigned char *vb; /* Map */ - int vbBufSize; /* Size of individual vert buf */ - int vbNumBufs; /* Number of vert bufs */ - drmBufMapPtr vbBufs; /* Buffer map */ - - /* CCE indirect buffer data */ - unsigned long indStart; /* Offset into AGP space */ - drmHandle indHandle; /* Handle from drmAddMap */ - drmSize indMapSize; /* Size of map */ - int indSize; /* Size of indirect bufs (in MB) */ - unsigned char *ind; /* Map */ - - /* CCE AGP Texture data */ - unsigned long agpTexStart; /* Offset into AGP space */ - drmHandle agpTexHandle; /* Handle from drmAddMap */ - drmSize agpTexMapSize; /* Size of map */ - int agpTexSize; /* Size of AGP tex space (in MB) */ - unsigned char *agpTex; /* Map */ - int log2AGPTexGran; - - /* DRI screen private data */ - int fbX; - int fbY; - int backX; - int backY; - int depthX; - int depthY; - int textureX; - int textureY; - int textureSize; - int log2TexGran; -#endif -} R128InfoRec, *R128InfoPtr; - -#define R128WaitForFifo(pScrn, entries) \ -do { \ - if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ - info->fifo_slots -= entries; \ -} while (0) - -extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); -extern void R128WaitForIdle(ScrnInfoPtr pScrn); -extern void R128EngineReset(ScrnInfoPtr pScrn); -extern void R128EngineFlush(ScrnInfoPtr pScrn); - -extern int INPLL(ScrnInfoPtr pScrn, int addr); -extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); -extern void R128AdjustFrame(int scrnIndex, int x, int y, int flags); -extern Bool R128SwitchMode(int ScrnIndex, DisplayModePtr mode, int flags); - -extern Bool R128AccelInit(ScreenPtr pScreen); -extern void R128EngineInit(ScrnInfoPtr pScrn); -extern Bool R128CursorInit(ScreenPtr pScreen); -extern Bool R128DGAInit(ScreenPtr pScreen); - -extern int R128MinBits(int val); - -#ifdef XF86DRI -extern Bool R128DRIScreenInit(ScreenPtr pScreen); -extern void R128DRICloseScreen(ScreenPtr pScreen); -extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen); -extern void R128CCEStart(ScrnInfoPtr pScrn); -extern void R128CCEStop(ScrnInfoPtr pScrn); -extern void R128CCEResetRing(ScrnInfoPtr pScrn); -extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn); -#endif - -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c:1.13 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c:1.13 Mon Jun 26 01:41:32 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c Mon Dec 18 14:31:00 2000 @@ -1,1132 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.13 2000/06/26 05:41:32 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - * Credits: - * - * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for - * providing source code to their 3.3.x Rage 128 driver. Portions of - * this file are based on the acceleration code for that driver. - * - * References: - * - * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical - * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April - * 1999. - * - * RAGE 128 Software Development Manual (Technical Reference Manual P/N - * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. - * - * Notes on unimplemented XAA optimizations: - * - * SolidFillTrap: This will probably work if we can compute the correct - * Bresenham error values. - * TwoPointLine: The Rage 128 supports Bresenham lines instead. - * DashedLine with non-power-of-two pattern length: Apparently, there is - * no way to set the length of the pattern -- it is always - * assumed to be 8 or 32 (or 1024?). - * ScreenToScreenColorExpandFill: See p. 4-17 of the Technical Reference - * Manual where it states that monochrome expansion of frame - * buffer data is not supported. - * CPUToScreenColorExpandFill, direct: The implementation here uses a hybrid - * direct/indirect method. If we had more data registers, - * then we could do better. If XAA supported a trigger write - * address, the code would be simpler. - * Color8x8PatternFill: Apparently, an 8x8 color brush cannot take an 8x8 - * pattern from frame buffer memory. - * ImageWrites: The direct method isn't supported because XAA does not - * support a final trigger register write. The indirect - * method slows down common operations. Perhaps additional - * XAA flags to use this only for some operations would help. - * - */ - -#define R128_CLIPPING 1 -#define R128_IMAGEWRITE 0 /* Indirect image write is slow */ -#define R128_TRAPEZOIDS 0 /* Trapezoids don't work */ - - /* X and server generic header files */ -#include "Xarch.h" -#include "xf86.h" -#include "xf86_ansic.h" -#include "xf86_OSproc.h" -#include "xf86fbman.h" - - /* Line support */ -#include "miline.h" - - /* XAA and cursor support */ -#include "xaa.h" -#include "xf86Cursor.h" - - /* PCI support */ -#include "xf86PciInfo.h" -#include "xf86Pci.h" - - /* DDC support */ -#include "xf86DDC.h" - - /* DRI support */ -#ifdef XF86DRI -#include "GL/glxint.h" -#include "xf86drm.h" -#include "sarea.h" -#define _XF86DRI_SERVER_ -#include "xf86dri.h" -#include "dri.h" -#include "r128_dri.h" -#include "r128_dripriv.h" -#include "r128_sarea.h" -#endif - - /* Driver data structures */ -#include "r128.h" -#include "r128_reg.h" - -static struct { - int rop; - int pattern; -} R128_ROP[] = { - { R128_ROP3_ZERO, R128_ROP3_ZERO }, /* GXclear */ - { R128_ROP3_DSa, R128_ROP3_DPa }, /* Gxand */ - { R128_ROP3_SDna, R128_ROP3_PDna }, /* GXandReverse */ - { R128_ROP3_S, R128_ROP3_P }, /* GXcopy */ - { R128_ROP3_DSna, R128_ROP3_DPna }, /* GXandInverted */ - { R128_ROP3_D, R128_ROP3_D }, /* GXnoop */ - { R128_ROP3_DSx, R128_ROP3_DPx }, /* GXxor */ - { R128_ROP3_DSo, R128_ROP3_DPo }, /* GXor */ - { R128_ROP3_DSon, R128_ROP3_DPon }, /* GXnor */ - { R128_ROP3_DSxn, R128_ROP3_PDxn }, /* GXequiv */ - { R128_ROP3_Dn, R128_ROP3_Dn }, /* GXinvert */ - { R128_ROP3_SDno, R128_ROP3_PDno }, /* GXorReverse */ - { R128_ROP3_Sn, R128_ROP3_Pn }, /* GXcopyInverted */ - { R128_ROP3_DSno, R128_ROP3_DPno }, /* GXorInverted */ - { R128_ROP3_DSan, R128_ROP3_DPan }, /* GXnand */ - { R128_ROP3_ONE, R128_ROP3_ONE } /* GXset */ -}; - -/* Flush all dirty data in the Pixel Cache to memory. */ -void R128EngineFlush(ScrnInfoPtr pScrn) -{ - int i; - R128MMIO_VARS(); - - OUTREGP(R128_PC_NGUI_CTLSTAT, R128_PC_FLUSH_ALL, ~R128_PC_FLUSH_ALL); - for (i = 0; i < R128_TIMEOUT; i++) { - if (!(INREG(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) break; - } -} - -/* Reset graphics card to known state. */ -void R128EngineReset(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - CARD32 clock_cntl_index; - CARD32 mclk_cntl; - CARD32 gen_reset_cntl; - R128MMIO_VARS(); - - R128EngineFlush(pScrn); - - clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); - mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL); - - OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP); - - gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); - - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); - INREG(R128_GEN_RESET_CNTL); - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); - INREG(R128_GEN_RESET_CNTL); - - OUTPLL(R128_MCLK_CNTL, mclk_cntl); - OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index); - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl); - -#ifdef XF86DRI - if (R128CCE_USE_RING_BUFFER(info->CCEMode)) R128CCEResetRing(pScrn); -#endif -} - -/* The FIFO has 64 slots. This routines waits until at least `entries' of - these slots are empty. */ -void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries) -{ - R128InfoPtr info = R128PTR(pScrn); - int i; - R128MMIO_VARS(); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - info->fifo_slots = INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; - if (info->fifo_slots >= entries) return; - } - R128TRACE(("FIFO timed out: %d entries, stat=0x%08x, probe=0x%08x\n", - INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, - INREG(R128_GUI_STAT), - INREG(R128_GUI_PROBE))); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "FIFO timed out, resetting engine...\n"); - R128EngineReset(pScrn); -#ifdef XF86DRI - if (info->CCE2D) R128CCEStart(pScrn); -#endif - } -} - -/* Wait for the graphics engine to be completely idle: the FIFO has - drained, the Pixel Cache is flushed, and the engine is idle. This is a - standard "sync" function that will make the hardware "quiescent". */ -void R128WaitForIdle(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - int i; - R128MMIO_VARS(); - - R128WaitForFifoFunction(pScrn, 64); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - if (!(INREG(R128_GUI_STAT) & R128_GUI_ACTIVE)) { - R128EngineFlush(pScrn); - return; - } - } - R128TRACE(("Idle timed out: %d entries, stat=0x%08x, probe=0x%08x\n", - INREG(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK, - INREG(R128_GUI_STAT), - INREG(R128_GUI_PROBE))); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Idle timed out, resetting engine...\n"); - R128EngineReset(pScrn); -#ifdef XF86DRI - if (info->CCE2D) R128CCEStart(pScrn); -#endif - } -} - -/* Setup for XAA SolidFill. */ -static void R128SetupForSolidFill(ScrnInfoPtr pScrn, - int color, int rop, unsigned int planemask) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 4); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | R128_ROP[rop].pattern)); - OUTREG(R128_DP_BRUSH_FRGD_CLR, color); - OUTREG(R128_DP_WRITE_MASK, planemask); - OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT - | R128_DST_Y_TOP_TO_BOTTOM)); -} - -/* Subsequent XAA SolidFillRect. - - Tests: xtest CH06/fllrctngl, xterm -*/ -static void R128SubsequentSolidFillRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DST_Y_X, (y << 16) | x); - OUTREG(R128_DST_WIDTH_HEIGHT, (w << 16) | h); -} - -/* Setup for XAA solid lines. */ -static void R128SetupForSolidLine(ScrnInfoPtr pScrn, - int color, int rop, unsigned int planemask) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 3); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | R128_ROP[rop].pattern)); - OUTREG(R128_DP_BRUSH_FRGD_CLR, color); - OUTREG(R128_DP_WRITE_MASK, planemask); -} - - -/* Subsequent XAA solid Bresenham line. - - Tests: xtest CH06/drwln, ico, Mark Vojkovich's linetest program - - [See http://www.xfree86.org/devel/archives/devel/1999-Jun/0102.shtml for - Mark Vojkovich's linetest program, posted 2Jun99 to devel@xfree86.org.] - - x11perf -line500 - 1024x768@76Hz 1024x768@76Hz - 8bpp 32bpp - not used: 39700.0/sec 34100.0/sec - used: 47600.0/sec 36800.0/sec -*/ -static void R128SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, - int x, int y, - int major, int minor, - int err, int len, int octant) -{ - R128InfoPtr info = R128PTR(pScrn); - int flags = 0; - R128MMIO_VARS(); - - if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; - if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; - if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; - - R128WaitForFifo(pScrn, 6); - OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); - OUTREG(R128_DST_Y_X, (y << 16) | x); - OUTREG(R128_DST_BRES_ERR, err); - OUTREG(R128_DST_BRES_INC, minor); - OUTREG(R128_DST_BRES_DEC, -major); - OUTREG(R128_DST_BRES_LNTH, len); -} - -/* Subsequent XAA solid horizontal and vertical lines - - 1024x768@76Hz 8bpp - Without With - x11perf -hseg500 87600.0/sec 798000.0/sec - x11perf -vseg500 38100.0/sec 38000.0/sec -*/ -static void R128SubsequentSolidHorVertLine(ScrnInfoPtr pScrn, - int x, int y, int len, int dir ) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 1); - OUTREG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT - | R128_DST_Y_TOP_TO_BOTTOM)); - - if (dir == DEGREES_0) { - R128SubsequentSolidFillRect(pScrn, x, y, len, 1); - } else { - R128SubsequentSolidFillRect(pScrn, x, y, 1, len); - } -} - -/* Setup for XAA dashed lines. - - Tests: xtest CH05/stdshs, XFree86/drwln - - NOTE: Since we can only accelerate lines with power-of-2 patterns of - length <= 32, these x11perf numbers are not representative of the - speed-up on appropriately-sized patterns. - - 1024x768@76Hz 8bpp - Without With - x11perf -dseg100 218000.0/sec 222000.0/sec - x11perf -dline100 215000.0/sec 221000.0/sec - x11perf -ddline100 178000.0/sec 180000.0/sec -*/ -static void R128SetupForDashedLine(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, unsigned int planemask, - int length, unsigned char *pattern) -{ - R128InfoPtr info = R128PTR(pScrn); - CARD32 pat = *(CARD32 *)pattern; - R128MMIO_VARS(); - - switch (length) { - case 2: pat |= pat << 2; /* fall through */ - case 4: pat |= pat << 4; /* fall through */ - case 8: pat |= pat << 8; /* fall through */ - case 16: pat |= pat << 16; - } - - R128WaitForFifo(pScrn, 5); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | (bg == -1 - ? R128_GMC_BRUSH_32x1_MONO_FG_LA - : R128_GMC_BRUSH_32x1_MONO_FG_BG) - | R128_ROP[rop].pattern - | R128_GMC_BYTE_LSB_TO_MSB)); - OUTREG(R128_DP_WRITE_MASK, planemask); - OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); - OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); - OUTREG(R128_BRUSH_DATA0, pat); -} - -/* Subsequent XAA dashed line. */ -static void R128SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, - int x1, int y1, - int major, int minor, - int err, int len, int octant, - int phase) -{ - R128InfoPtr info = R128PTR(pScrn); - int flags = 0; - R128MMIO_VARS(); - - if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; - if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; - if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; - - R128WaitForFifo(pScrn, 7); - OUTREG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); - OUTREG(R128_DST_Y_X, (y1 << 16) | x1); - OUTREG(R128_BRUSH_Y_X, (phase << 16) | phase); - OUTREG(R128_DST_BRES_ERR, err); - OUTREG(R128_DST_BRES_INC, minor); - OUTREG(R128_DST_BRES_DEC, -major); - OUTREG(R128_DST_BRES_LNTH, len); -} - -#if R128_TRAPEZOIDS - /* This doesn't work. Except in the - lower-left quadrant, all of the pixel - errors appear to be because eL and eR - are not correct. Drawing from right to - left doesn't help. Be aware that the - non-_SUB registers set the sub-pixel - values to 0.5 (0x08), which isn't what - XAA wants. */ -/* Subsequent XAA SolidFillTrap. XAA always passes data that assumes we - fill from top to bottom, so dyL and dyR are always non-negative. */ -static void R128SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, - int left, int dxL, int dyL, int eL, - int right, int dxR, int dyR, int eR) -{ - int flags = 0; - int Lymajor = 0; - int Rymajor = 0; - int origdxL = dxL; - int origdxR = dxR; - R128MMIO_VARS(); - - R128TRACE(("Trap %d %d; L %d %d %d %d; R %d %d %d %d\n", - y, h, - left, dxL, dyL, eL, - right, dxR, dyR, eR)); - - if (dxL < 0) dxL = -dxL; else flags |= (1 << 0) /* | (1 << 8) */; - if (dxR < 0) dxR = -dxR; else flags |= (1 << 6); - - R128WaitForFifo(pScrn, 11); - -#if 1 - OUTREG(R128_DP_CNTL, flags | (1 << 1) | (1 << 7)); - OUTREG(R128_DST_Y_SUB, ((y) << 4) | 0x0 ); - OUTREG(R128_DST_X_SUB, ((left) << 4)|0x0); - OUTREG(R128_TRAIL_BRES_ERR, eR-dxR); - OUTREG(R128_TRAIL_BRES_INC, dxR); - OUTREG(R128_TRAIL_BRES_DEC, -dyR); - OUTREG(R128_TRAIL_X_SUB, ((right) << 4) | 0x0); - OUTREG(R128_LEAD_BRES_ERR, eL-dxL); - OUTREG(R128_LEAD_BRES_INC, dxL); - OUTREG(R128_LEAD_BRES_DEC, -dyL); - OUTREG(R128_LEAD_BRES_LNTH_SUB, ((h) << 4) | 0x00); -#else - OUTREG(R128_DP_CNTL, flags | (1 << 1) ); - OUTREG(R128_DST_Y_SUB, (y << 4)); - OUTREG(R128_DST_X_SUB, (right << 4)); - OUTREG(R128_TRAIL_BRES_ERR, eL); - OUTREG(R128_TRAIL_BRES_INC, dxL); - OUTREG(R128_TRAIL_BRES_DEC, -dyL); - OUTREG(R128_TRAIL_X_SUB, (left << 4) | 0); - OUTREG(R128_LEAD_BRES_ERR, eR); - OUTREG(R128_LEAD_BRES_INC, dxR); - OUTREG(R128_LEAD_BRES_DEC, -dyR); - OUTREG(R128_LEAD_BRES_LNTH_SUB, h << 4); -#endif -} -#endif - -#if R128_CLIPPING -/* Setup for XAA clipping rectangle. - - Tests: xtest CH06/drwrctngl - - These x11perf data show why we don't use clipping for lines. Clipping - can improve performance for other functions. - - 1024x768@76 8bpp - Without With - x11perf -seg100c1 241000.0/sec 185000.0/sec - x11perf -seg100c2 238000.0/sec 154000.0/sec - x11perf -seg100c3 194000.0/sec 132000.0/sec - -*/ -static void R128SetClippingRectangle(ScrnInfoPtr pScrn, - int left, int top, int right, int bottom) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - if (left > 8191 || top > 8191 || right > 8191 || bottom > 8191 - || left < 0 || top < 0 || right < 0 || bottom < 0 - || left > 4000 || right > 4000 || top > 4000 || bottom > 4000 - || left >= right || top >= bottom) - R128TRACE(("Clip %d %d %d %d *************************************\n", - left, top, right, bottom)); - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_SC_TOP_LEFT, (top << 16) | left); - OUTREG(R128_SC_BOTTOM_RIGHT, (bottom << 16) | right); -} - -static void R128DisableClipping (ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_SC_TOP_LEFT, 0); - OUTREG(R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX - | R128_DEFAULT_SC_BOTTOM_MAX)); -} -#endif - - -/* Setup for XAA screen-to-screen copy. - - Tests: xtest CH06/fllrctngl (also tests transparency). -*/ -static void R128SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, - int trans_color) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - info->xdir = xdir; - info->ydir = ydir; - R128WaitForFifo(pScrn, 3); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | R128_ROP[rop].rop - | R128_DP_SRC_SOURCE_MEMORY)); - OUTREG(R128_DP_WRITE_MASK, planemask); - OUTREG(R128_DP_CNTL, ((xdir >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) - | (ydir >= 0 - ? R128_DST_Y_TOP_TO_BOTTOM - : 0))); - - if (trans_color != -1) { - /* Set up for transparency */ - R128WaitForFifo(pScrn, 3); - OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); - OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); - OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR - | R128_CLR_CMP_SRC_SOURCE)); - } -} - -/* Subsequent XAA screen-to-screen copy. */ -static void R128SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, - int x1, int y1, - int x2, int y2, - int w, int h) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - if (info->xdir < 0) x1 += w - 1, x2 += w - 1; - if (info->ydir < 0) y1 += h - 1, y2 += h - 1; - - R128WaitForFifo(pScrn, 3); - OUTREG(R128_SRC_Y_X, (y1 << 16) | x1); - OUTREG(R128_DST_Y_X, (y2 << 16) | x2); - OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); -} - -/* Setup for XAA mono 8x8 pattern color expansion. Patterns with - transparency use `bg == -1'. This routine is only used if the XAA - pixmap cache is turned on. - - Tests: xtest XFree86/fllrctngl (no other test will test this routine with - both transparency and non-transparency) - - 1024x768@76Hz 8bpp - Without With - x11perf -srect100 38600.0/sec 85700.0/sec - x11perf -osrect100 38600.0/sec 85700.0/sec -*/ -static void R128SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, - int patternx, int patterny, - int fg, int bg, int rop, - unsigned int planemask) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 6); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | (bg == -1 - ? R128_GMC_BRUSH_8X8_MONO_FG_LA - : R128_GMC_BRUSH_8X8_MONO_FG_BG) - | R128_ROP[rop].pattern - | R128_GMC_BYTE_LSB_TO_MSB)); - OUTREG(R128_DP_WRITE_MASK, planemask); - OUTREG(R128_DP_BRUSH_FRGD_CLR, fg); - OUTREG(R128_DP_BRUSH_BKGD_CLR, bg); - OUTREG(R128_BRUSH_DATA0, patternx); - OUTREG(R128_BRUSH_DATA1, patterny); -} - -/* Subsequent XAA 8x8 pattern color expansion. Because they are used in - the setup function, `patternx' and `patterny' are not used here. */ -static void R128SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, - int patternx, int patterny, - int x, int y, int w, int h) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 3); - OUTREG(R128_BRUSH_Y_X, (patterny << 8) | patternx); - OUTREG(R128_DST_Y_X, (y << 16) | x); - OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); -} - -#if 0 -/* Setup for XAA color 8x8 pattern fill. - - Tests: xtest XFree86/fllrctngl (with Mono8x8PatternFill off) -*/ -static void R128SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int rop, unsigned int planemask, - int trans_color) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128TRACE(("Color8x8 %d %d %d\n", trans_color, patx, paty)); - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_8x8_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | R128_ROP[rop].rop - | R128_DP_SRC_SOURCE_MEMORY)); - OUTREG(R128_DP_WRITE_MASK, planemask); - - if (trans_color != -1) { - /* Set up for transparency */ - R128WaitForFifo(pScrn, 3); - OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); - OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); - OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR - | R128_CLR_CMP_SRC_SOURCE)); - } -} - -/* Subsequent XAA 8x8 pattern color expansion. */ -static void R128SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h) -{ - R128MMIO_VARS(); - - R128TRACE(("Color8x8 %d,%d %d,%d %d %d\n", patx, paty, x, y, w, h)); - R128WaitForFifo(pScrn, 3); - OUTREG(R128_SRC_Y_X, (paty << 16) | patx); - OUTREG(R128_DST_Y_X, (y << 16) | x); - OUTREG(R128_DST_HEIGHT_WIDTH, (h << 16) | w); -} -#endif - -/* Setup for XAA indirect CPU-to-screen color expansion (indirect). - Because of how the scratch buffer is initialized, this is really a - mainstore-to-screen color expansion. Transparency is supported when `bg - == -1'. - - x11perf -ftext (pure indirect): - 1024x768@76Hz 1024x768@76Hz - 8bpp 32bpp - not used: 685000.0/sec 794000.0/sec - used: 1070000.0/sec 1080000.0/sec - - We could improve this indirect routine by about 10% if the hardware - could accept DWORD padded scanlines, or if XAA could provide bit-packed - data. We might also be able to move to a direct routine if there were - more HOST_DATA registers. - - Implementing the hybrid indirect/direct scheme improved performance in a - few areas: - - 1024x768@76 8bpp - Indirect Hybrid - x11perf -oddsrect10 50100.0/sec 71700.0/sec - x11perf -oddsrect100 4240.0/sec 6660.0/sec - x11perf -bigsrect10 50300.0/sec 71100.0/sec - x11perf -bigsrect100 4190.0/sec 6800.0/sec - x11perf -polytext 584000.0/sec 714000.0/sec - x11perf -polytext16 154000.0/sec 172000.0/sec - x11perf -seg1 1780000.0/sec 1880000.0/sec - x11perf -copyplane10 42900.0/sec 58300.0/sec - x11perf -copyplane100 4400.0/sec 6710.0/sec - x11perf -putimagexy10 5090.0/sec 6670.0/sec - x11perf -putimagexy100 424.0/sec 575.0/sec - - 1024x768@76 -depth 24 -fbbpp 32 - Indirect Hybrid - x11perf -oddsrect100 4240.0/sec 6670.0/sec - x11perf -bigsrect100 4190.0/sec 6800.0/sec - x11perf -polytext 585000.0/sec 719000.0/sec - x11perf -seg1 2960000.0/sec 2990000.0/sec - x11perf -copyplane100 4400.0/sec 6700.0/sec - x11perf -putimagexy100 138.0/sec 191.0/sec - -*/ -static void R128SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, - unsigned int - planemask) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128WaitForFifo(pScrn, 4); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_1X8_COLOR - | (bg == -1 - ? R128_GMC_SRC_DATATYPE_MONO_FG_LA - : R128_GMC_SRC_DATATYPE_MONO_FG_BG) - | R128_ROP[rop].rop - | R128_GMC_BYTE_LSB_TO_MSB - | R128_DP_SRC_SOURCE_HOST_DATA)); - OUTREG(R128_DP_WRITE_MASK, planemask); - OUTREG(R128_DP_SRC_FRGD_CLR, fg); - OUTREG(R128_DP_SRC_BKGD_CLR, bg); -} - -/* Subsequent XAA indirect CPU-to-screen color expansion. This is only - called once for each rectangle. */ -static void R128SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, - int x, int y, - int w, int h, - int skipleft) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - info->scanline_y = y; - info->scanline_x = x; - info->scanline_h = h; - info->scanline_h_w = (1 << 16) | w; - info->scanline_words = (w + 31) / 32; - info->scanline_direct = 0; - - if (info->scanline_words <= 9 && info->scanline_h > 1) { - /* Turn on direct for next set of scan lines */ - info->scratch_buffer[0] - = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) - - (info->scanline_words - 1)); - info->scanline_direct = 1; - - /* Make engine ready for next line */ - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DST_Y_X, ((info->scanline_y++ << 16) - | info->scanline_x)); - OUTREG(R128_DST_HEIGHT_WIDTH, info->scanline_h_w); - } -} - -/* Subsequent XAA indirect CPU-to-screen color expandion. This is called - once for each scanline. */ -static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) -{ - R128InfoPtr info = R128PTR(pScrn); - CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; - int i; - int left = info->scanline_words; - volatile CARD32 *d; - R128MMIO_VARS(); - - --info->scanline_h; - if (info->scanline_direct) { - if (info->scanline_h <= 1) { - /* Turn off direct for last scan line */ - info->scratch_buffer[0] = info->scratch_save; - info->scanline_direct = 0; - return; - } - } - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DST_Y_X, ((info->scanline_y++ << 16) - | info->scanline_x)); - OUTREG(R128_DST_HEIGHT_WIDTH, info->scanline_h_w); - - if (info->scanline_direct) return; - - while (left) { - if (left <= 9) { - R128WaitForFifo(pScrn, left); - /* Unrolling doesn't improve performance */ - for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) - *d++ = *p++; - } else { - R128WaitForFifo(pScrn, 8); - /* Unrolling doesn't improve performance */ - for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) - *d++ = *p++; - left -= 8; - } - } -} - -#if R128_IMAGEWRITE -/* Setup for XAA indirect image write. - - - 1024x768@76Hz 8bpp - Without With - x11perf -putimage10 37500.0/sec 39300.0/sec - x11perf -putimage100 2150.0/sec 1170.0/sec - x11perf -putimage500 108.0/sec 49.8/sec - */ -static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int trans_color, - int bpp, - int depth) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - info->scanline_bpp = bpp; - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR - | R128_ROP[rop].rop - | R128_GMC_BYTE_LSB_TO_MSB - | R128_DP_SRC_SOURCE_HOST_DATA)); - OUTREG(R128_DP_WRITE_MASK, planemask); - - if (trans_color != -1) { - /* Set up for transparency */ - R128WaitForFifo(pScrn, 3); - OUTREG(R128_CLR_CMP_CLR_SRC, trans_color); - OUTREG(R128_CLR_CMP_MASK, R128_CLR_CMP_MSK); - OUTREG(R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR - | R128_CLR_CMP_SRC_SOURCE)); - } -} - -/* Subsequent XAA indirect image write. This is only called once for each - rectangle. */ -static void R128SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, - int x, int y, - int w, int h, - int skipleft) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - info->scanline_y = y; - info->scanline_x = x; - info->scanline_h = h; - info->scanline_h_w = (1 << 16) | w; - info->scanline_words = (w * info->scanline_bpp + 31) / 32; - info->scanline_direct = 0; - - if (info->scanline_words <= 9 && info->scanline_h > 1) { - /* Turn on direct for next set of scan lines */ - info->scratch_buffer[0] - = (unsigned char *)(ADDRREG(R128_HOST_DATA_LAST) - - (info->scanline_words - 1)); - info->scanline_direct = 1; - - /* Make engine ready for next line */ - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DST_Y_X, ((info->scanline_y++ << 16) - | info->scanline_x)); - OUTREG(R128_DST_HEIGHT_WIDTH, info->scanline_h_w); - } -} - -/* Subsequent XAA indirect iamge write. This is called once for each - scanline. */ -static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) -{ - R128InfoPtr info = R128PTR(pScrn); - CARD32 *p = (CARD32 *)info->scratch_buffer[bufno]; - int i; - int left = info->scanline_words; - volatile CARD32 *d; - R128MMIO_VARS(); - - --info->scanline_h; - if (info->scanline_direct) { - if (info->scanline_h <= 1) { - /* Turn off direct for last scan line */ - info->scratch_buffer[0] = info->scratch_save; - info->scanline_direct = 0; - return; - } - } - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DST_Y_X, ((info->scanline_y++ << 16) - | info->scanline_x)); - OUTREG(R128_DST_HEIGHT_WIDTH, info->scanline_h_w); - - if (info->scanline_direct) return; - - while (left) { - if (left <= 9) { - R128WaitForFifo(pScrn, left); - /* Unrolling doesn't improve performance */ - for (d = ADDRREG(R128_HOST_DATA_LAST) - (left - 1); left; --left) - *d++ = *p++; - } else { - R128WaitForFifo(pScrn, 8); - /* Unrolling doesn't improve performance */ - for (d = ADDRREG(R128_HOST_DATA0), i = 0; i < 8; i++) - *d++ = *p++; - left -= 8; - } - } -} -#endif - -/* Initialize the acceleration hardware. */ -void R128EngineInit(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - R128MMIO_VARS(); - - R128TRACE(("EngineInit (%d/%d)\n", info->CurrentLayout.pixel_code, info->CurrentLayout.bitsPerPixel)); - - OUTREG(R128_SCALE_3D_CNTL, 0); - R128EngineReset(pScrn); - - switch (info->CurrentLayout.pixel_code) { - case 8: info->datatype = 2; break; - case 15: info->datatype = 3; break; - case 16: info->datatype = 4; break; - case 24: info->datatype = 5; break; - case 32: info->datatype = 6; break; - default: - R128TRACE(("Unknown depth/bpp = %d/%d (code = %d)\n", - info->CurrentLayout.depth, info->CurrentLayout.bitsPerPixel, - info->CurrentLayout.pixel_code)); - } - info->pitch = (info->CurrentLayout.displayWidth / 8) * (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1); - - R128TRACE(("Pitch for acceleration = %d\n", info->pitch)); - - R128WaitForFifo(pScrn, 2); - OUTREG(R128_DEFAULT_OFFSET, 0); - OUTREG(R128_DEFAULT_PITCH, info->pitch); - - R128WaitForFifo(pScrn, 4); - OUTREG(R128_AUX_SC_CNTL, 0); - OUTREG(R128_DEFAULT_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX - | R128_DEFAULT_SC_BOTTOM_MAX)); - OUTREG(R128_SC_TOP_LEFT, 0); - OUTREG(R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX - | R128_DEFAULT_SC_BOTTOM_MAX)); - - info->dp_gui_master_cntl = ((info->datatype << R128_GMC_DST_DATATYPE_SHIFT) - | R128_GMC_CLR_CMP_CNTL_DIS - | R128_GMC_AUX_CLIP_DIS - | R128_GMC_DST_CLIPPING); - R128WaitForFifo(pScrn, 1); - OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl - | R128_GMC_BRUSH_SOLID_COLOR - | R128_GMC_SRC_DATATYPE_COLOR)); - - R128WaitForFifo(pScrn, 8); - OUTREG(R128_DST_BRES_ERR, 0); - OUTREG(R128_DST_BRES_INC, 0); - OUTREG(R128_DST_BRES_DEC, 0); - OUTREG(R128_DP_BRUSH_FRGD_CLR, 0xffffffff); - OUTREG(R128_DP_BRUSH_BKGD_CLR, 0x00000000); - OUTREG(R128_DP_SRC_FRGD_CLR, 0xffffffff); - OUTREG(R128_DP_SRC_BKGD_CLR, 0x00000000); - OUTREG(R128_DP_WRITE_MASK, 0xffffffff); - -#if X_BYTE_ORDER == X_BIG_ENDIAN - OUTREGP(R128_DP_DATATYPE, - R128_HOST_BIG_ENDIAN_EN, ~R128_HOST_BIG_ENDIAN_EN); -#else - OUTREGP(R128_DP_DATATYPE, 0, ~R128_HOST_BIG_ENDIAN_EN); -#endif - - R128WaitForIdle(pScrn); -} - -#ifdef XF86DRI - /* FIXME: When direct rendering is enabled, we should use the CCE to - draw 2D commands */ -static void R128CCEAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) -{ - a->Flags = 0; - - /* Sync */ - a->Sync = R128CCEWaitForIdle; - -} -#endif - -static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) -{ - R128InfoPtr info = R128PTR(pScrn); - - a->Flags = (PIXMAP_CACHE - | OFFSCREEN_PIXMAPS - | LINEAR_FRAMEBUFFER); - - /* Sync */ - a->Sync = R128WaitForIdle; - - /* Solid Filled Rectangle */ - a->PolyFillRectSolidFlags = 0; - a->SetupForSolidFill = R128SetupForSolidFill; - a->SubsequentSolidFillRect = R128SubsequentSolidFillRect; - - /* Screen-to-screen Copy */ - /* Transparency uses the wrong colors for - 24 bpp mode -- the transparent part is - correct, but the opaque color is wrong. - This can be seen with netscape's I-bar - cursor when editing in the URL location - box. */ - a->ScreenToScreenCopyFlags = ((pScrn->bitsPerPixel == 24) - ? NO_TRANSPARENCY - : 0); - a->SetupForScreenToScreenCopy = R128SetupForScreenToScreenCopy; - a->SubsequentScreenToScreenCopy = R128SubsequentScreenToScreenCopy; - - /* Mono 8x8 Pattern Fill (Color Expand) */ - a->SetupForMono8x8PatternFill = R128SetupForMono8x8PatternFill; - a->SubsequentMono8x8PatternFillRect = R128SubsequentMono8x8PatternFillRect; - a->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS - | HARDWARE_PATTERN_PROGRAMMED_ORIGIN - | HARDWARE_PATTERN_SCREEN_ORIGIN - | BIT_ORDER_IN_BYTE_LSBFIRST); - - /* Indirect CPU-To-Screen Color Expand */ -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - a->ScanlineCPUToScreenColorExpandFillFlags = 0; -#else - a->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST; -#endif - a->NumScanlineColorExpandBuffers = 1; - a->ScanlineColorExpandBuffers = info->scratch_buffer; -#if R128_IMAGEWRITE - info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4) - + (pScrn->virtualX - * info->pixel_bytes)); -#else - info->scratch_save = xalloc(((pScrn->virtualX+31)/32*4)); -#endif - info->scratch_buffer[0] = info->scratch_save; - a->SetupForScanlineCPUToScreenColorExpandFill - = R128SetupForScanlineCPUToScreenColorExpandFill; - a->SubsequentScanlineCPUToScreenColorExpandFill - = R128SubsequentScanlineCPUToScreenColorExpandFill; - a->SubsequentColorExpandScanline = R128SubsequentColorExpandScanline; - - /* Bresenham Solid Lines */ - a->SetupForSolidLine = R128SetupForSolidLine; - a->SubsequentSolidBresenhamLine = R128SubsequentSolidBresenhamLine; - a->SubsequentSolidHorVertLine = R128SubsequentSolidHorVertLine; - - /* Bresenham Dashed Lines*/ - a->SetupForDashedLine = R128SetupForDashedLine; - a->SubsequentDashedBresenhamLine = R128SubsequentDashedBresenhamLine; - a->DashPatternMaxLength = 32; - a->DashedLineFlags = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED - | LINE_PATTERN_POWER_OF_2_ONLY); -#if R128_CLIPPING - /* Clipping. */ - if (info->CurrentLayout.depth != 8 && info->CurrentLayout.pixel_code != 24) { - /* There is one xtest error in 8bpp and - many xtest errors in 24/24 that do not - appear at other depths. */ - a->SetClippingRectangle = R128SetClippingRectangle; - a->DisableClipping = R128DisableClipping; - a->ClippingFlags - = (HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY - | HARDWARE_CLIP_MONO_8x8_FILL - | HARDWARE_CLIP_COLOR_8x8_FILL - | HARDWARE_CLIP_SOLID_FILL); - } -#endif - -#if R128_IMAGEWRITE - /* ImageWrite */ - a->NumScanlineImageWriteBuffers = 1; - a->ScanlineImageWriteBuffers = info->scratch_buffer; - info->scratch_buffer[0] = info->scratch_save; - a->SetupForScanlineImageWrite = R128SetupForScanlineImageWrite; - a->SubsequentScanlineImageWriteRect= R128SubsequentScanlineImageWriteRect; - a->SubsequentImageWriteScanline = R128SubsequentImageWriteScanline; - a->ImageWriteFlags = (CPU_TRANSFER_PAD_DWORD - | SCANLINE_PAD_DWORD - | SYNC_AFTER_IMAGE_WRITE); -#endif -} - -/* Initialize XAA for supported acceleration and also initialize the - graphics hardware for acceleration. */ -Bool R128AccelInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr info = R128PTR(pScrn); - XAAInfoRecPtr a; - - if (!(a = info->accel = XAACreateInfoRec())) return FALSE; - -#ifdef XF86DRI - /* FIXME: When direct rendering is enabled, we should use the CCE to - draw 2D commands */ - if (info->CCE2D) R128CCEAccelInit(pScrn, a); - else -#endif - R128MMIOAccelInit(pScrn, a); - - R128EngineInit(pScrn); - return XAAInit(pScreen, a); -} Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c:1.9 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c:1.9 Fri Jun 16 20:27:32 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c Mon Dec 18 14:31:00 2000 @@ -1,285 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c,v 1.9 2000/06/17 00:27:32 dawes Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - * References: - * - * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical - * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April - * 1999. - * - * RAGE 128 Software Development Manual (Technical Reference Manual P/N - * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. - * - */ - - /* X and server generic header files */ -#include "Xarch.h" -#include "xf86.h" -#include "xf86_ansic.h" -#include "xf86_OSproc.h" -#include "xf86fbman.h" - - /* XAA and Cursor Support */ -#include "xaa.h" -#include "xf86Cursor.h" - - /* PCI support */ -#include "xf86PciInfo.h" -#include "xf86Pci.h" - - /* DDC support */ -#include "xf86DDC.h" - - /* DRI support */ -#ifdef XF86DRI -#include "GL/glxint.h" -#include "xf86drm.h" -#include "sarea.h" -#define _XF86DRI_SERVER_ -#include "xf86dri.h" -#include "dri.h" -#include "r128_dri.h" -#include "r128_dripriv.h" -#include "r128_sarea.h" -#endif - - /* Driver data structures */ -#include "r128.h" -#include "r128_reg.h" - -#if X_BYTE_ORDER == X_BIG_ENDIAN -#define P_SWAP32( a , b ) \ - ((char *)a)[0] = ((char *)b)[3]; \ - ((char *)a)[1] = ((char *)b)[2]; \ - ((char *)a)[2] = ((char *)b)[1]; \ - ((char *)a)[3] = ((char *)b)[0] - -#define P_SWAP16( a , b ) \ - ((char *)a)[0] = ((char *)b)[1]; \ - ((char *)a)[1] = ((char *)b)[0]; \ - ((char *)a)[2] = ((char *)b)[3]; \ - ((char *)a)[3] = ((char *)b)[2] -#endif - - -/* Set cursor foreground and background colors. */ -static void R128SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) -{ - R128MMIO_VARS(); - - OUTREG(R128_CUR_CLR0, bg); - OUTREG(R128_CUR_CLR1, fg); -} - -/* Set cursor position to (x,y) with offset into cursor bitmap at - (xorigin,yorigin). */ -static void R128SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) -{ - R128InfoPtr info = R128PTR(pScrn); - xf86CursorInfoPtr cursor = info->cursor; - int xorigin = 0; - int yorigin = 0; - int total_y = pScrn->frameY1 - pScrn->frameY0; - R128MMIO_VARS(); - - if (x < 0) xorigin = -x; - if (y < 0) yorigin = -y; - if (y > total_y) y = total_y; - if (info->Flags & V_DBLSCAN) y *= 2; - if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1; - if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1; - - OUTREG(R128_CUR_HORZ_VERT_OFF, R128_CUR_LOCK | (xorigin << 16) | yorigin); - OUTREG(R128_CUR_HORZ_VERT_POSN, (R128_CUR_LOCK - | ((xorigin ? 0 : x) << 16) - | (yorigin ? 0 : y))); - OUTREG(R128_CUR_OFFSET, info->cursor_start + yorigin * 16); -} - -/* Copy cursor image from `image' to video memory. R128SetCursorPosition - will be called after this, so we can ignore xorigin and yorigin. */ -static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image) -{ - R128InfoPtr info = R128PTR(pScrn); - CARD32 *s = (CARD32 *)image; - CARD32 *d = (CARD32 *)(info->FB + info->cursor_start); - int y; - CARD32 save; - R128MMIO_VARS(); - - save = INREG(R128_CRTC_GEN_CNTL); - OUTREG(R128_CRTC_GEN_CNTL, save & ~R128_CRTC_CUR_EN); - -#if X_BYTE_ORDER == X_BIG_ENDIAN - switch(info->CurrentLayout.pixel_bytes) { - case 4: - case 3: - for (y = 0; y < 64; y++) { - P_SWAP32(d,s); - d++; s++; - P_SWAP32(d,s); - d++; s++; - P_SWAP32(d,s); - d++; s++; - P_SWAP32(d,s); - d++; s++; - } - break; - case 2: - for (y = 0; y < 64; y++) { - P_SWAP16(d,s); - d++; s++; - P_SWAP16(d,s); - d++; s++; - P_SWAP16(d,s); - d++; s++; - P_SWAP16(d,s); - d++; s++; - } - break; - default: - for (y = 0; y < 64; y++) { - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - } - } -#else - for (y = 0; y < 64; y++) { - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - } -#endif - - /* Set the area after the cursor to be all transparent so that we - won't display corrupted cursors on the screen */ - for (y = 0; y < 64; y++) { - *d++ = 0xffffffff; /* The AND bits */ - *d++ = 0xffffffff; - *d++ = 0x00000000; /* The XOR bits */ - *d++ = 0x00000000; - } - - - OUTREG(R128_CRTC_GEN_CNTL, save); -} - -/* Hide hardware cursor. */ -static void R128HideCursor(ScrnInfoPtr pScrn) -{ - R128MMIO_VARS(); - - OUTREGP(R128_CRTC_GEN_CNTL, 0, ~R128_CRTC_CUR_EN); -} - -/* Show hardware cursor. */ -static void R128ShowCursor(ScrnInfoPtr pScrn) -{ - R128MMIO_VARS(); - - OUTREGP(R128_CRTC_GEN_CNTL, R128_CRTC_CUR_EN, ~R128_CRTC_CUR_EN); -} - -/* Determine if hardware cursor is in use. */ -static Bool R128UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr info = R128PTR(pScrn); - - return info->cursor_start ? TRUE : FALSE; -} - -/* Initialize hardware cursor support. */ -Bool R128CursorInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr info = R128PTR(pScrn); - xf86CursorInfoPtr cursor; - FBAreaPtr fbarea; - int width; - int height; - int size; - - - if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; - - cursor->MaxWidth = 64; - cursor->MaxHeight = 64; - cursor->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP - -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST -#endif - | HARDWARE_CURSOR_INVERT_MASK - | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK - | HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 - | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK); - - cursor->SetCursorColors = R128SetCursorColors; - cursor->SetCursorPosition = R128SetCursorPosition; - cursor->LoadCursorImage = R128LoadCursorImage; - cursor->HideCursor = R128HideCursor; - cursor->ShowCursor = R128ShowCursor; - cursor->UseHWCursor = R128UseHWCursor; - - size = (cursor->MaxWidth/4) * cursor->MaxHeight; - width = pScrn->displayWidth; - height = (size*2 + 1023) / pScrn->displayWidth; - fbarea = xf86AllocateOffscreenArea(pScreen, - width, - height, - 16, - NULL, - NULL, - NULL); - - if (!fbarea) { - info->cursor_start = 0; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Hardware cursor disabled" - " due to insufficient offscreen memory\n"); - } else { - info->cursor_start = R128_ALIGN((fbarea->box.x1 - + width * fbarea->box.y1) - * info->CurrentLayout.pixel_bytes, 16); - info->cursor_end = info->cursor_start + size; - } - - R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n", - info->cursor_start, info->cursor_end)); - - return xf86InitCursor(pScreen, cursor); -} Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c:1.2 Fri Jun 16 20:03:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c Mon Dec 18 14:31:00 2000 @@ -1,378 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c,v 1.2 2000/06/17 00:03:22 martin Exp $ */ -/* - * Authors: - * Ove Kåven <ovek@transgaming.com>, - * borrowing some code from the Chips and MGA drivers. - */ - - /* X and server generic header files */ -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86_ansic.h" - - /* PCI support */ -#include "xf86Pci.h" -#include "xf86PciInfo.h" - - /* DDC support */ -#include "xf86DDC.h" - - /* XAA and Cursor Support */ -#include "xaa.h" -#include "xaalocal.h" -#include "xf86Cursor.h" - - /* DRI support */ -#ifdef XF86DRI -#include "GL/glxint.h" -#include "xf86drm.h" -#include "sarea.h" -#define _XF86DRI_SERVER_ -#include "xf86dri.h" -#include "dri.h" -#include "r128_dri.h" -#include "r128_dripriv.h" -#include "r128_sarea.h" -#endif - - /* Driver data structures */ -#include "r128.h" - - /* DGA support */ -#include "dgaproc.h" - - -static Bool R128_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, - int *, int *, int *); -static Bool R128_SetMode(ScrnInfoPtr, DGAModePtr); -static int R128_GetViewport(ScrnInfoPtr); -static void R128_SetViewport(ScrnInfoPtr, int, int, int); -static void R128_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); -static void R128_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); -static void R128_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, - unsigned long); - -static -DGAFunctionRec R128_DGAFuncs = { - R128_OpenFramebuffer, - NULL, - R128_SetMode, - R128_SetViewport, - R128_GetViewport, - R128WaitForIdle, - R128_FillRect, - R128_BlitRect, -#if 0 - R128_BlitTransRect -#else - NULL -#endif -}; - - -static DGAModePtr -R128SetupDGAMode( - ScrnInfoPtr pScrn, - DGAModePtr modes, - int *num, - int bitsPerPixel, - int depth, - Bool pixmap, - int secondPitch, - unsigned long red, - unsigned long green, - unsigned long blue, - short visualClass -){ - R128InfoPtr info = R128PTR(pScrn); - DGAModePtr newmodes = NULL, currentMode; - DisplayModePtr pMode, firstMode; - int otherPitch, Bpp = bitsPerPixel >> 3; - Bool oneMore; - - pMode = firstMode = pScrn->modes; - - while(pMode) { - - otherPitch = secondPitch ? secondPitch : pMode->HDisplay; - - if(pMode->HDisplay != otherPitch) { - newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec)); - oneMore = TRUE; - } else { - newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - } - - if(!newmodes) { - xfree(modes); - return NULL; - } - modes = newmodes; - -SECOND_PASS: - - currentMode = modes + *num; - (*num)++; - - currentMode->mode = pMode; - /* FIXME: is concurrent access really possible? */ - currentMode->flags = DGA_CONCURRENT_ACCESS; - if(pixmap) - currentMode->flags |= DGA_PIXMAP_AVAILABLE; - if(info->accel) - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if(pMode->Flags & V_DBLSCAN) - currentMode->flags |= DGA_DOUBLESCAN; - if(pMode->Flags & V_INTERLACE) - currentMode->flags |= DGA_INTERLACED; - currentMode->byteOrder = pScrn->imageByteOrder; - currentMode->depth = depth; - currentMode->bitsPerPixel = bitsPerPixel; - currentMode->red_mask = red; - currentMode->green_mask = green; - currentMode->blue_mask = blue; - currentMode->visualClass = visualClass; - currentMode->viewportWidth = pMode->HDisplay; - currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = 8; - currentMode->yViewportStep = 1; - currentMode->viewportFlags = DGA_FLIP_RETRACE; - currentMode->offset = 0; - currentMode->address = (unsigned char*)info->LinearAddr; - - if(oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; - currentMode->imageWidth = otherPitch; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - } - - pMode = pMode->next; - if(pMode == firstMode) - break; - } - - return modes; -} - - -Bool -R128DGAInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr info = R128PTR(pScrn); - DGAModePtr modes = NULL; - int num = 0; - - /* 8 */ - modes = R128SetupDGAMode (pScrn, modes, &num, 8, 8, - (pScrn->bitsPerPixel == 8), - (pScrn->bitsPerPixel != 8) ? 0 : pScrn->displayWidth, - 0, 0, 0, PseudoColor); - - /* 15 */ - modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, - (pScrn->bitsPerPixel == 16), - (pScrn->depth != 15) ? 0 : pScrn->displayWidth, - 0x7c00, 0x03e0, 0x001f, TrueColor); - - modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15, - (pScrn->bitsPerPixel == 16), - (pScrn->depth != 15) ? 0 : pScrn->displayWidth, - 0x7c00, 0x03e0, 0x001f, DirectColor); - - /* 16 */ - modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, - (pScrn->bitsPerPixel == 16), - (pScrn->depth != 16) ? 0 : pScrn->displayWidth, - 0xf800, 0x07e0, 0x001f, TrueColor); - - modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16, - (pScrn->bitsPerPixel == 16), - (pScrn->depth != 16) ? 0 : pScrn->displayWidth, - 0xf800, 0x07e0, 0x001f, DirectColor); - - /* 24 */ - modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, - (pScrn->bitsPerPixel == 24), - (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, - 0xff0000, 0x00ff00, 0x0000ff, TrueColor); - - modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24, - (pScrn->bitsPerPixel == 24), - (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth, - 0xff0000, 0x00ff00, 0x0000ff, DirectColor); - - /* 32 */ - modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, - (pScrn->bitsPerPixel == 32), - (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, - 0xff0000, 0x00ff00, 0x0000ff, TrueColor); - - modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24, - (pScrn->bitsPerPixel == 32), - (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth, - 0xff0000, 0x00ff00, 0x0000ff, DirectColor); - - info->numDGAModes = num; - info->DGAModes = modes; - - return DGAInit(pScreen, &R128_DGAFuncs, modes, num); -} - - -static Bool -R128_SetMode( - ScrnInfoPtr pScrn, - DGAModePtr pMode -){ - static R128FBLayout SavedLayouts[MAXSCREENS]; - int index = pScrn->pScreen->myNum; - R128InfoPtr info = R128PTR(pScrn); - - if(!pMode) { /* restore the original mode */ - /* put the ScreenParameters back */ - if(info->DGAactive) - memcpy(&info->CurrentLayout, &SavedLayouts[index], sizeof(R128FBLayout)); - - pScrn->currentMode = info->CurrentLayout.mode; - - R128SwitchMode(index, pScrn->currentMode, 0); - R128AdjustFrame(index, 0, 0, 0); - info->DGAactive = FALSE; - } else { - if(!info->DGAactive) { /* save the old parameters */ - memcpy(&SavedLayouts[index], &info->CurrentLayout, sizeof(R128FBLayout)); - info->DGAactive = TRUE; - } - - info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel; - info->CurrentLayout.depth = pMode->depth; - info->CurrentLayout.displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8; - info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16 - ? pMode->bitsPerPixel - : pMode->depth); - /* R128ModeInit() will set the mode field */ - - R128SwitchMode(index, pMode->mode, 0); - } - - return TRUE; -} - - - -static int -R128_GetViewport( - ScrnInfoPtr pScrn -){ - R128InfoPtr info = R128PTR(pScrn); - - return info->DGAViewportStatus; -} - - -static void -R128_SetViewport( - ScrnInfoPtr pScrn, - int x, int y, - int flags -){ - R128InfoPtr info = R128PTR(pScrn); - - R128AdjustFrame(pScrn->pScreen->myNum, x, y, flags); - info->DGAViewportStatus = 0; /* FIXME */ -} - - -static void -R128_FillRect ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned long color -){ - R128InfoPtr info = R128PTR(pScrn); - - if(info->accel) { - (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, ~0); - (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h); - SET_SYNC_FLAG(info->accel); - } -} - -static void -R128_BlitRect( - ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, - int dstx, int dsty -){ - R128InfoPtr info = R128PTR(pScrn); - - if(info->accel) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; - - (*info->accel->SetupForScreenToScreenCopy)( - pScrn, xdir, ydir, GXcopy, ~0, -1); - (*info->accel->SubsequentScreenToScreenCopy)( - pScrn, srcx, srcy, dstx, dsty, w, h); - SET_SYNC_FLAG(info->accel); - } -} - - -static void -R128_BlitTransRect( - ScrnInfoPtr pScrn, - int srcx, int srcy, - int w, int h, - int dstx, int dsty, - unsigned long color -){ - /* this one should be separate since the XAA function would - prohibit usage of ~0 as the key */ -} - - -static Bool -R128_OpenFramebuffer( - ScrnInfoPtr pScrn, - char **name, - unsigned char **mem, - int *size, - int *offset, - int *flags -){ - R128InfoPtr info = R128PTR(pScrn); - - *name = NULL; /* no special device */ - *mem = (unsigned char*)info->LinearAddr; - *size = info->FbMapSize; - *offset = 0; - *flags = /* DGA_NEED_ROOT */ 0; /* don't need root, just /dev/mem access */ - - return TRUE; -} Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c:1.4 Mon Jun 26 01:41:32 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c Mon Dec 18 14:31:00 2000 @@ -1,1289 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <kevin@precisioninsight.com> - * Rickard E. Faith <faith@precisioninsight.com> - * Daryll Strauss <daryll@precisioninsight.com> - * - */ - - - /* X and server generic header files */ -#include "xf86.h" -#include "xf86_ansic.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "xf86RAC.h" -#include "xf86cmap.h" -#include "xf86fbman.h" - - /* Backing store, software cursor, and - colormap initialization */ -#include "mibstore.h" -#include "mipointer.h" -#include "micmap.h" - - /* CFB support */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" - - /* XAA and Cursor Support */ -#include "xaa.h" -#include "xf86Cursor.h" - - /* PCI support */ -#include "xf86PciInfo.h" -#include "xf86Pci.h" - - /* DDC support */ -#include "xf86DDC.h" - - /* DRI support */ -#include "GL/glxint.h" -#include "GL/glxtokens.h" -#include "xf86drm.h" -#include "xf86drmR128.h" -#include "sarea.h" -#define _XF86DRI_SERVER_ -#include "xf86dri.h" -#include "dri.h" -#include "r128_dri.h" -#include "r128_sarea.h" -#include "r128_dripriv.h" - - /* Driver data structures */ -#include "r128.h" -#include "r128_reg.h" - -#define R128_WATERMARK_L 16 -#define R128_WATERMARK_M 8 -#define R128_WATERMARK_N 8 -#define R128_WATERMARK_K 128 - -static int CCEFifoSlots = 0; - -#define R128CCEWaitForFifo(pScrn, entries) \ -do { \ - if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \ - CCEFifoSlots -= entries; \ -} while (0) - -/* Wait for at least `entries' slots are free. The actual number of - slots available is stored in info->CCEFifoSize. */ -static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - int i; - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; - if (CCEFifoSlots >= entries) return; - } - R128EngineReset(pScrn); - if (info->CCE2D) R128CCEStart(pScrn); - } -} - -/* Wait until the CCE is completely idle: the FIFO has drained and the - CCE is idle. */ -void R128CCEWaitForIdle(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - int i; - - if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; - - if (R128CCE_USE_RING_BUFFER(info->CCEMode)) { - volatile CARD32 *r128RingReadPtr = - (volatile CARD32 *)(info->ringReadPtr); - R128SAREAPrivPtr pSAREAPriv; - - OUTREGP(R128_PM4_BUFFER_DL_WPTR, - R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE); - - pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - if (*r128RingReadPtr == pSAREAPriv->ringWrite) { - int pm4stat = INREG(R128_PM4_STAT); - if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize - && !(pm4stat & (R128_PM4_BUSY|R128_PM4_GUI_ACTIVE))) { - R128EngineFlush(pScrn); - return; - } - } - } - R128EngineReset(pScrn); - if (info->CCE2D) R128CCEStart(pScrn); - } - } else { - R128CCEWaitForFifoFunction(pScrn, info->CCEFifoSize); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - if (!(INREG(R128_PM4_STAT) - & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { - R128EngineFlush(pScrn); - return; - } - } - R128EngineReset(pScrn); - if (info->CCE2D) R128CCEStart(pScrn); - } - } -} - -/* Reset the ring buffer status, if the engine was reset */ -void R128CCEResetRing(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - R128SAREAPrivPtr pSAREAPriv; - volatile CARD32 *r128RingReadPtr; - - if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; - - r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr); - pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); - - OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); - OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); - pSAREAPriv->ringWrite = 0; - *r128RingReadPtr = 0; - - /* Resetting the ring turns off the CCE */ - info->CCEInUse = FALSE; -} - -/* Start the CCE, but only if it is not already in use and the requested - mode is a CCE mode. The mode is stored in info->CCEMode. */ -void R128CCEStart(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; - - R128WaitForIdle(pScrn); - OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode | info->ringSizeLog2QW); - (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */ - OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); - info->CCEInUse = TRUE; -} - -/* Stop the CCE, but only if it is in use and the requested mode is not - the non-CCE mode. This function also flushes any outstanding - requests before switching modes.*/ -void R128CCEStop(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; - - R128CCEWaitForIdle(pScrn); - OUTREG(R128_PM4_MICRO_CNTL, 0); - OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); - R128EngineReset(pScrn); - info->CCEInUse = FALSE; -} - -/* Initialize the visual configs that are supported by the hardware. - These are combined with the visual configs that the indirect - rendering core supports, and the intersection is exported to the - client. */ -static Bool R128InitVisualConfigs(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - int numConfigs = 0; - __GLXvisualConfig *pConfigs = 0; - R128ConfigPrivPtr pR128Configs = 0; - R128ConfigPrivPtr *pR128ConfigPtrs = 0; - int i, accum, stencil; - - switch (pR128->CurrentLayout.pixel_code) { - case 8: /* 8bpp mode is not support */ - case 15: /* FIXME?? */ - case 24: /* FIXME?? */ - return FALSE; - -#define R128_USE_ACCUM 1 -#define R128_USE_STENCIL 1 - - case 16: - numConfigs = 1; - if (R128_USE_ACCUM) numConfigs *= 2; - if (R128_USE_STENCIL) numConfigs *= 2; - - if (!(pConfigs - = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), - numConfigs))) { - return FALSE; - } - if (!(pR128Configs - = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), - numConfigs))) { - xfree(pConfigs); - return FALSE; - } - if (!(pR128ConfigPtrs - = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), - numConfigs))) { - xfree(pConfigs); - xfree(pR128Configs); - return FALSE; - } - - i = 0; - for (accum = 0; accum <= R128_USE_ACCUM; accum++) { - for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { - pR128ConfigPtrs[i] = &pR128Configs[i]; - - pConfigs[i].vid = -1; - pConfigs[i].class = -1; - pConfigs[i].rgba = TRUE; - pConfigs[i].redSize = 5; - pConfigs[i].greenSize = 6; - pConfigs[i].blueSize = 5; - pConfigs[i].alphaSize = 0; - pConfigs[i].redMask = 0x0000F800; - pConfigs[i].greenMask = 0x000007E0; - pConfigs[i].blueMask = 0x0000001F; - pConfigs[i].alphaMask = 0x00000000; - if (accum) { /* Simulated in software */ - pConfigs[i].accumRedSize = 16; - pConfigs[i].accumGreenSize = 16; - pConfigs[i].accumBlueSize = 16; - pConfigs[i].accumAlphaSize = 0; - } else { - pConfigs[i].accumRedSize = 0; - pConfigs[i].accumGreenSize = 0; - pConfigs[i].accumBlueSize = 0; - pConfigs[i].accumAlphaSize = 0; - } - pConfigs[i].doubleBuffer = TRUE; - pConfigs[i].stereo = FALSE; - pConfigs[i].bufferSize = 16; - pConfigs[i].depthSize = 16; - if (stencil) - pConfigs[i].stencilSize = 8; /* Simulated in software */ - else - pConfigs[i].stencilSize = 0; - pConfigs[i].auxBuffers = 0; - pConfigs[i].level = 0; - pConfigs[i].visualRating = GLX_NONE_EXT; - pConfigs[i].transparentPixel = GLX_NONE; - pConfigs[i].transparentRed = 0; - pConfigs[i].transparentGreen = 0; - pConfigs[i].transparentBlue = 0; - pConfigs[i].transparentAlpha = 0; - pConfigs[i].transparentIndex = 0; - i++; - } - } - break; - case 32: - numConfigs = 1; - if (R128_USE_ACCUM) numConfigs *= 2; - if (R128_USE_STENCIL) numConfigs *= 2; - - if (!(pConfigs - = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), - numConfigs))) { - return FALSE; - } - if (!(pR128Configs - = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), - numConfigs))) { - xfree(pConfigs); - return FALSE; - } - if (!(pR128ConfigPtrs - = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), - numConfigs))) { - xfree(pConfigs); - xfree(pR128Configs); - return FALSE; - } - - i = 0; - for (accum = 0; accum <= R128_USE_ACCUM; accum++) { - for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { - pR128ConfigPtrs[i] = &pR128Configs[i]; - - pConfigs[i].vid = -1; - pConfigs[i].class = -1; - pConfigs[i].rgba = TRUE; - pConfigs[i].redSize = 8; - pConfigs[i].greenSize = 8; - pConfigs[i].blueSize = 8; - pConfigs[i].alphaSize = 8; - pConfigs[i].redMask = 0x00FF0000; - pConfigs[i].greenMask = 0x0000FF00; - pConfigs[i].blueMask = 0x000000FF; - pConfigs[i].alphaMask = 0xFF000000; - if (accum) { /* Simulated in software */ - pConfigs[i].accumRedSize = 16; - pConfigs[i].accumGreenSize = 16; - pConfigs[i].accumBlueSize = 16; - pConfigs[i].accumAlphaSize = 16; - } else { - pConfigs[i].accumRedSize = 0; - pConfigs[i].accumGreenSize = 0; - pConfigs[i].accumBlueSize = 0; - pConfigs[i].accumAlphaSize = 0; - } - pConfigs[i].doubleBuffer = TRUE; - pConfigs[i].stereo = FALSE; - pConfigs[i].bufferSize = 24; - if (stencil) { - pConfigs[i].depthSize = 24; - pConfigs[i].stencilSize = 8; - } else { - pConfigs[i].depthSize = 32; - pConfigs[i].stencilSize = 0; - } - pConfigs[i].auxBuffers = 0; - pConfigs[i].level = 0; - pConfigs[i].visualRating = GLX_NONE_EXT; - pConfigs[i].transparentPixel = GLX_NONE; - pConfigs[i].transparentRed = 0; - pConfigs[i].transparentGreen = 0; - pConfigs[i].transparentBlue = 0; - pConfigs[i].transparentAlpha = 0; - pConfigs[i].transparentIndex = 0; - i++; - } - } - break; - } - - pR128->numVisualConfigs = numConfigs; - pR128->pVisualConfigs = pConfigs; - pR128->pVisualConfigsPriv = pR128Configs; - GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs); - return TRUE; -} - -/* Create the Rage 128-specific context information */ -static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual, - drmContext hwContext, void *pVisualConfigPriv, - DRIContextType contextStore) -{ - /* Nothing yet */ - return TRUE; -} - -/* Destroy the Rage 128-specific context information */ -static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext, - DRIContextType contextStore) -{ - /* Nothing yet */ -} - -/* Called when the X server is woken up to allow the last client's - context to be saved and the X server's context to be loaded. This is - not necessary for the Rage 128 since the client detects when it's - context is not currently loaded and then load's it itself. Since the - registers to start and stop the CCE are privileged, only the X server - can start/stop the engine. */ -static void R128EnterServer(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - - if (pR128->accel) pR128->accel->NeedToSync = TRUE; - -#if 1 - if (!pR128->CCE2D) R128CCEStop(pScrn); -#else - if (pR128->CCE2D) R128CCEWaitForIdle(pScrn); - else R128CCEStop(pScrn); -#endif -} - -/* Called when the X server goes to sleep to allow the X server's - context to be saved and the last client's context to be loaded. This - is not necessary for the Rage 128 since the client detects when it's - context is not currently loaded and then load's it itself. Since the - registers to start and stop the CCE are privileged, only the X server - can start/stop the engine. */ -static void R128LeaveServer(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - -#if 1 - if (!pR128->CCE2D) R128CCEStart(pScrn); -#else - if (pR128->CCE2D) R128CCEWaitForIdle(pScrn); - else R128CCEStart(pScrn); -#endif -} - -/* Contexts can be swapped by the X server if necessary. This callback - is currently only used to perform any functions necessary when - entering or leaving the X server, and in the future might not be - necessary. */ -static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, - DRIContextType oldContextType, void *oldContext, - DRIContextType newContextType, void *newContext) -{ - if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ - R128EnterServer(pScreen); - } - if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ - R128LeaveServer(pScreen); - } -} - -/* Initialize the state of the back and depth buffers. */ -static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) -{ - /* FIXME: This routine needs to have acceleration turned on */ - ScreenPtr pScreen = pWin->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - BoxPtr pbox; - int nbox; - int depth; - - /* FIXME: Use accel when CCE 2D code is written */ - if (pR128->CCE2D) return; - - /* FIXME: This should be based on the __GLXvisualConfig info */ - switch (pScrn->bitsPerPixel) { - case 8: depth = 0x000000ff; break; - case 16: depth = 0x0000ffff; break; - case 24: depth = 0x00ffffff; break; - case 32: depth = 0xffffffff; break; - default: depth = 0x00000000; break; - } - - /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */ - /* FIXME: Only initialize the back and depth buffers for contexts - that request them */ - - pbox = REGION_RECTS(prgn); - nbox = REGION_NUM_RECTS(prgn); - - (*pR128->accel->SetupForSolidFill)(pScrn, 0, GXcopy, -1); - for (; nbox; nbox--, pbox++) { - (*pR128->accel->SubsequentSolidFillRect)(pScrn, - pbox->x1 + pR128->fbX, - pbox->y1 + pR128->fbY, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - (*pR128->accel->SubsequentSolidFillRect)(pScrn, - pbox->x1 + pR128->backX, - pbox->y1 + pR128->backY, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - } - - (*pR128->accel->SetupForSolidFill)(pScrn, depth, GXcopy, -1); - for (; nbox; nbox--, pbox++) - (*pR128->accel->SubsequentSolidFillRect)(pScrn, - pbox->x1 + pR128->depthX, - pbox->y1 + pR128->depthY, - pbox->x2 - pbox->x1, - pbox->y2 - pbox->y1); - - pR128->accel->NeedToSync = TRUE; -} - -/* Copy the back and depth buffers when the X server moves a window. */ -static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg, - RegionPtr prgnSrc, CARD32 index) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - - /* FIXME: This routine needs to have acceleration turned on */ - /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */ - /* FIXME: Only initialize the back and depth buffers for contexts - that request them */ - - /* FIXME: Use accel when CCE 2D code is written */ - if (pR128->CCE2D) return; -} - -/* Initialize the AGP state. Request memory for use in AGP space, and - initialize the Rage 128 registers to point to that memory. */ -static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen) -{ - unsigned char *R128MMIO = pR128->MMIO; - unsigned long mode; - unsigned int vendor, device; - int ret; - unsigned long cntl; - int s, l; - int flags; - - if (drmAgpAcquire(pR128->drmFD) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n"); - return FALSE; - } - - /* Modify the mode if the default mode is - not appropriate for this particular - combination of graphics card and AGP - chipset. */ - - mode = drmAgpGetMode(pR128->drmFD); /* Default mode */ - vendor = drmAgpVendorId(pR128->drmFD); - device = drmAgpDeviceId(pR128->drmFD); - - mode &= ~R128_AGP_MODE_MASK; - switch (pR128->agpMode) { - case 2: mode |= R128_AGP_2X_MODE; - case 1: default: mode |= R128_AGP_1X_MODE; - } - - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", - mode, vendor, device, - pR128->PciInfo->vendor, - pR128->PciInfo->chipType); - - if (drmAgpEnable(pR128->drmFD, mode) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n"); - drmAgpRelease(pR128->drmFD); - return FALSE; - } - - pR128->agpOffset = 0; - - if ((ret = drmAgpAlloc(pR128->drmFD, pR128->agpSize*1024*1024, 0, NULL, - &pR128->agpMemHandle)) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret); - drmAgpRelease(pR128->drmFD); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] %d kB allocated with handle 0x%08x\n", - pR128->agpSize*1024, pR128->agpMemHandle); - - if (drmAgpBind(pR128->drmFD, pR128->agpMemHandle, pR128->agpOffset) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n"); - drmAgpFree(pR128->drmFD, pR128->agpMemHandle); - drmAgpRelease(pR128->drmFD); - return FALSE; - } - - /* Initialize the CCE ring buffer data */ - pR128->ringStart = pR128->agpOffset; - pR128->ringMapSize = pR128->ringSize*1024*1024 + 4096; - pR128->ringSizeLog2QW = R128MinBits(pR128->ringSize*1024*1024/8) - 1; - - pR128->ringReadOffset = pR128->ringStart + pR128->ringMapSize; - pR128->ringReadMapSize = 4096; - - /* Reserve space for the vertex buffer */ - pR128->vbStart = pR128->ringReadOffset + pR128->ringReadMapSize; - pR128->vbMapSize = pR128->vbSize*1024*1024; - - /* Reserve space for the indirect buffer */ - pR128->indStart = pR128->vbStart + pR128->vbMapSize; - pR128->indMapSize = pR128->indSize*1024*1024; - - /* Reserve the rest for AGP textures */ - pR128->agpTexStart = pR128->indStart + pR128->indMapSize; - s = (pR128->agpSize*1024*1024 - pR128->agpTexStart); - l = R128MinBits((s-1) / R128_NR_TEX_REGIONS); - if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; - pR128->agpTexMapSize = (s >> l) << l; - pR128->log2AGPTexGran = l; - - if (pR128->CCESecure) flags = DRM_READ_ONLY; - else flags = 0; - - if (drmAddMap(pR128->drmFD, pR128->ringStart, pR128->ringMapSize, - DRM_AGP, flags, &pR128->ringHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not add ring mapping\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] ring handle = 0x%08lx\n", pR128->ringHandle); - - if (drmMap(pR128->drmFD, pR128->ringHandle, pR128->ringMapSize, - (drmAddressPtr)&pR128->ring) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] Ring mapped at 0x%08lx\n", - (unsigned long)pR128->ring); - - if (drmAddMap(pR128->drmFD, pR128->ringReadOffset, pR128->ringReadMapSize, - DRM_AGP, flags, &pR128->ringReadPtrHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not add ring read ptr mapping\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] ring read ptr handle = 0x%08lx\n", - pR128->ringReadPtrHandle); - - if (drmMap(pR128->drmFD, pR128->ringReadPtrHandle, pR128->ringReadMapSize, - (drmAddressPtr)&pR128->ringReadPtr) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not map ring read ptr\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] Ring read ptr mapped at 0x%08lx\n", - (unsigned long)pR128->ringReadPtr); - - if (drmAddMap(pR128->drmFD, pR128->vbStart, pR128->vbMapSize, - DRM_AGP, 0, &pR128->vbHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not add vertex buffers mapping\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] vertex buffers handle = 0x%08lx\n", pR128->vbHandle); - - if (drmMap(pR128->drmFD, pR128->vbHandle, pR128->vbMapSize, - (drmAddressPtr)&pR128->vb) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not map vertex buffers\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] Vertex buffers mapped at 0x%08lx\n", - (unsigned long)pR128->vb); - - if (drmAddMap(pR128->drmFD, pR128->indStart, pR128->indMapSize, - DRM_AGP, flags, &pR128->indHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not add indirect buffers mapping\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] indirect buffers handle = 0x%08lx\n", pR128->indHandle); - - if (drmMap(pR128->drmFD, pR128->indHandle, pR128->indMapSize, - (drmAddressPtr)&pR128->ind) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not map indirect buffers\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] Indirect buffers mapped at 0x%08lx\n", - (unsigned long)pR128->ind); - - if (drmAddMap(pR128->drmFD, pR128->agpTexStart, pR128->agpTexMapSize, - DRM_AGP, 0, &pR128->agpTexHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not add AGP texture map mapping\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] AGP texture map handle = 0x%08lx\n", - pR128->agpTexHandle); - - if (drmMap(pR128->drmFD, pR128->agpTexHandle, pR128->agpTexMapSize, - (drmAddressPtr)&pR128->agpTex) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Could not map AGP texture map\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[agp] AGP Texture map mapped at 0x%08lx\n", - (unsigned long)pR128->agpTex); - - /* Initialize Rage 128's AGP registers */ - cntl = INREG(R128_AGP_CNTL); - cntl &= ~R128_AGP_APER_SIZE_MASK; - switch (pR128->agpSize) { - case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; - case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; - case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; - case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; - case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; - case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; - case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; - default: - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[agp] Illegal aperture size %d kB\n", - pR128->agpSize*1024); - return FALSE; - } - OUTREG(R128_AGP_BASE, pR128->ringHandle); /* Ring buf is at AGP offset 0 */ - OUTREG(R128_AGP_CNTL, cntl); - - return TRUE; -} - -/* Add a map for the MMIO registers that will be accessed by any - DRI-based clients. */ -static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen) -{ - int flags; - - if (pR128->CCESecure) flags = DRM_READ_ONLY; - else flags = 0; - - /* Map registers */ - pR128->registerSize = R128_MMIOSIZE; - if (drmAddMap(pR128->drmFD, pR128->MMIOAddr, pR128->registerSize, - DRM_REGISTERS, flags, &pR128->registerHandle) < 0) { - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] register handle = 0x%08lx\n", pR128->registerHandle); - - return TRUE; -} - -/* Initialize the ring buffer state for use in the X server and any - DRI-based clients. */ -static void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - unsigned long addr; - - /* FIXME: When we use the CCE for the X server, we should move this - function (and the support functions above) to r128_accel.c */ - - /* The manual (p. 2) says this address is - in "VM space". This means it's an - offset from the start of AGP space. */ - OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000); - - OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); - OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); - - /* DL_RPTR_ADDR is a physical address. - This should be in the SAREA. */ - *(volatile long unsigned *)(info->ringReadPtr) = 0; - OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle)); - - /* Set watermark control */ - OUTREG(R128_PM4_BUFFER_WM_CNTL, - ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) - | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) - | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) - | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT)); - - addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's - in the examples... */ - -#if 0 - R128CCEWaitForIdle(pScrn); -#endif - - /* Turn on bus mastering */ - info->BusCntl &= ~R128_BUS_MASTER_DIS; - OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS); -} - -/* Initialize the kernel data structures. */ -static int R128DRIKernelInit(R128InfoPtr pR128, ScreenPtr pScreen) -{ - drmR128Init drmInfo; - - drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); - drmInfo.is_pci = pR128->IsPCI; - drmInfo.cce_mode = pR128->CCEMode; - drmInfo.cce_fifo_size = pR128->CCEFifoSize; - drmInfo.cce_secure = pR128->CCESecure; - drmInfo.ring_size = pR128->ringSize*1024*1024; - drmInfo.usec_timeout = pR128->CCEusecTimeout; - - drmInfo.fb_offset = pR128->LinearAddr; - drmInfo.agp_ring_offset = pR128->ringHandle; - drmInfo.agp_read_ptr_offset = pR128->ringReadPtrHandle; - drmInfo.agp_vertbufs_offset = pR128->vbHandle; - drmInfo.agp_indbufs_offset = pR128->indHandle; - drmInfo.agp_textures_offset = pR128->agpTexHandle; - drmInfo.mmio_offset = pR128->registerHandle; - - if (drmR128InitCCE(pR128->drmFD, &drmInfo) < 0) return FALSE; - - return TRUE; -} - -/* Add a map for the vertex buffers that will be accessed by any - DRI-based clients. */ -static Bool R128DRIBufInit(R128InfoPtr pR128, ScreenPtr pScreen) -{ - /* Initialize vertex buffers */ - if ((pR128->vbNumBufs = drmAddBufs(pR128->drmFD, - pR128->vbMapSize / pR128->vbBufSize, - pR128->vbBufSize, - DRM_AGP_BUFFER, - pR128->vbStart)) <= 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Could not create vertex buffers list\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Added %d %d byte vertex buffers\n", - pR128->vbNumBufs, pR128->vbBufSize); - - if (drmMarkBufs(pR128->drmFD, 0.133333, 0.266666)) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to mark vertex buffers list\n"); - return FALSE; - } - - if (!(pR128->vbBufs = drmMapBufs(pR128->drmFD))) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to map vertex buffers list\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Mapped %d vertex buffers\n", - pR128->vbBufs->count); - - return TRUE; -} - -/* Load the microcode for the CCE */ -static void R128DRILoadMicrocode(ScrnInfoPtr pScrn) -{ - unsigned char *R128MMIO = R128PTR(pScrn)->MMIO; - int i; - unsigned long R128Microcode[] = { - /* CCE microcode (from ATI) */ - 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951, - 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0, - 596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2, - 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, - 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1, - 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200, - 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1, - 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1, - 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, - 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1, - 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1, - 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12, - 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16, - 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, - 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, - 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0, - 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1, - 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12, - 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3, - 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1, - 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, - 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1, - 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14, - 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1, - 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672, - 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, - 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, - 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1, - 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0, - 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0 - }; - - R128WaitForIdle(pScrn); - - OUTREG(R128_PM4_MICROCODE_ADDR, 0); - for (i = 0; i < 256; i += 1) { - OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]); - OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]); - } -} - -/* Initialize the CCE state, and start the CCE (if used by the X server) */ -static void R128DRICCEInit(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - /* CCEMode is initialized in r128_driver.c */ - switch (info->CCEMode) { - case R128_PM4_NONPM4: info->CCEFifoSize = 0; break; - case R128_PM4_192PIO: info->CCEFifoSize = 192; break; - case R128_PM4_192BM: info->CCEFifoSize = 192; break; - case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break; - case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break; - case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break; - } - - if (info->CCE2D) { - /* Make sure the CCE is on for the X server */ - R128CCEStart(pScrn); - } else { - /* Make sure the CCE is off for the X server */ - OUTREG(R128_PM4_MICRO_CNTL, 0); - OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); - } -} - -/* Initialize the screen-specific data structures for the DRI and the - Rage 128. This is the main entry point to the device-specific - initialization code. It calls device-independent DRI functions to - create the DRI data structures and initialize the DRI state. */ -Bool R128DRIScreenInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - DRIInfoPtr pDRIInfo; - R128DRIPtr pR128DRI; - int major, minor, patch; - drmVersionPtr version; - - /* Check that the GLX, DRI, and DRM modules have been loaded by testing - * for known symbols in each module. */ - if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; - if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; - if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; - if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "R128DRIScreenInit failed (libdri.a too old)\n"); - return FALSE; - } - - /* Check the DRI version */ - DRIQueryVersion(&major, &minor, &patch); - if (major != 3 || minor != 0 || patch < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "R128DRIScreenInit failed " - "(DRI version = %d.%d.%d, expected 3.0.x). " - "Disabling DRI.\n", - major, minor, patch); - return FALSE; - } - - switch (pR128->CurrentLayout.pixel_code) { - case 8: - /* These modes are not supported (yet). */ - case 15: - case 24: - return FALSE; - - /* Only 16 and 32 color depths are supports currently. */ - case 16: - case 32: - break; - } - - /* Create the DRI data structure, and fill it in before calling the - DRIScreenInit(). */ - if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; - - pR128->pDRIInfo = pDRIInfo; - pDRIInfo->drmDriverName = R128_NAME; - pDRIInfo->clientDriverName = R128_NAME; - pDRIInfo->busIdString = xalloc(64); - sprintf(pDRIInfo->busIdString, - "PCI:%d:%d:%d", - pR128->PciInfo->bus, - pR128->PciInfo->device, - pR128->PciInfo->func); - pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR; - pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR; - pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH; - pDRIInfo->frameBufferPhysicalAddress = pR128->LinearAddr; - pDRIInfo->frameBufferSize = pR128->FbMapSize; - pDRIInfo->frameBufferStride = (pScrn->displayWidth * - pR128->CurrentLayout.pixel_bytes); - pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES; - pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES - < R128_MAX_DRAWABLES - ? SAREA_MAX_DRAWABLES - : R128_MAX_DRAWABLES); - -#ifdef NOT_DONE - /* FIXME: Need to extend DRI protocol to pass this size back to - * client for SAREA mapping that includes a device private record - */ - pDRIInfo->SAREASize = - ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ - /* + shared memory device private rec */ -#else - /* For now the mapping works by using a fixed size defined - * in the SAREA header - */ - if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) { - ErrorF("Data does not fit in SAREA\n"); - return FALSE; - } - pDRIInfo->SAREASize = SAREA_MAX; -#endif - - if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) { - DRIDestroyInfoRec(pR128->pDRIInfo); - pR128->pDRIInfo = NULL; - return FALSE; - } - pDRIInfo->devPrivate = pR128DRI; - pDRIInfo->devPrivateSize = sizeof(R128DRIRec); - pDRIInfo->contextSize = sizeof(R128DRIContextRec); - - pDRIInfo->CreateContext = R128CreateContext; - pDRIInfo->DestroyContext = R128DestroyContext; - pDRIInfo->SwapContext = R128DRISwapContext; - pDRIInfo->InitBuffers = R128DRIInitBuffers; - pDRIInfo->MoveBuffers = R128DRIMoveBuffers; - pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; - - if (!DRIScreenInit(pScreen, pDRIInfo, &pR128->drmFD)) { - xfree(pDRIInfo->devPrivate); - pDRIInfo->devPrivate = NULL; - DRIDestroyInfoRec(pDRIInfo); - pDRIInfo = NULL; - return FALSE; - } - - /* Check the r128 DRM version */ - version = drmGetVersion(pR128->drmFD); - if (version) { - if (version->version_major != 1 || - version->version_minor != 0 || - version->version_patchlevel < 0) { - /* incompatible drm version */ - xf86DrvMsg(pScreen->myNum, X_ERROR, - "R128DRIScreenInit failed " - "(DRM version = %d.%d.%d, expected 1.0.x). " - "Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel); - drmFreeVersion(version); - R128DRICloseScreen(pScreen); - return FALSE; - } - drmFreeVersion(version); - } - - /* Initialize AGP */ - if (!pR128->IsPCI && !R128DRIAgpInit(pR128, pScreen)) { - R128DRICloseScreen(pScreen); - return FALSE; - } - - /* DRIScreenInit doesn't add all the - common mappings. Add additional - mappings here. */ - if (!R128DRIMapInit(pR128, pScreen)) { - R128DRICloseScreen(pScreen); - return FALSE; - } - - /* Initialize the ring buffer */ - if (!pR128->IsPCI) R128DRICCEInitRingBuffer(pScrn); - - /* Initialize the kernel data structures */ - if (!R128DRIKernelInit(pR128, pScreen)) { - R128DRICloseScreen(pScreen); - return FALSE; - } - - /* Initialize vertex buffers list */ - if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) { - R128DRICloseScreen(pScreen); - return FALSE; - } - - /* FIXME: When are these mappings unmapped? */ - - if (!R128InitVisualConfigs(pScreen)) { - R128DRICloseScreen(pScreen); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n"); - - /* Load the CCE Microcode */ - R128DRILoadMicrocode(pScrn); - - /* Reset the Graphics Engine */ - R128EngineReset(pScrn); - - return TRUE; -} - -/* Finish initializing the device-dependent DRI state, and call - DRIFinishScreenInit() to complete the device-independent DRI - initialization. */ -Bool R128DRIFinishScreenInit(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - R128SAREAPrivPtr pSAREAPriv; - R128DRIPtr pR128DRI; - - /* Init and start the CCE */ - R128DRICCEInit(pScrn); - - pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - - pR128->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; - /* pR128->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ - - pR128DRI = (R128DRIPtr)pR128->pDRIInfo->devPrivate; - pR128DRI->registerHandle = pR128->registerHandle; - pR128DRI->registerSize = pR128->registerSize; - - pR128DRI->ringHandle = pR128->ringHandle; - pR128DRI->ringMapSize = pR128->ringMapSize; - pR128DRI->ringSize = pR128->ringSize*1024*1024; - - pR128DRI->ringReadPtrHandle = pR128->ringReadPtrHandle; - pR128DRI->ringReadMapSize = pR128->ringReadMapSize; - - pR128DRI->vbHandle = pR128->vbHandle; - pR128DRI->vbMapSize = pR128->vbMapSize; - pR128DRI->vbOffset = pR128->vbStart; - pR128DRI->vbBufSize = pR128->vbBufSize; - - pR128DRI->indHandle = pR128->indHandle; - pR128DRI->indMapSize = pR128->indMapSize; - - pR128DRI->agpTexHandle = pR128->agpTexHandle; - pR128DRI->agpTexMapSize = pR128->agpTexMapSize; - pR128DRI->log2AGPTexGran = pR128->log2AGPTexGran; - pR128DRI->agpTexOffset = pR128->agpTexStart; - - pR128DRI->deviceID = pR128->Chipset; - pR128DRI->width = pScrn->virtualX; - pR128DRI->height = pScrn->virtualY; - pR128DRI->depth = pScrn->depth; - pR128DRI->bpp = pScrn->bitsPerPixel; - - pR128DRI->fbX = pR128->fbX; - pR128DRI->fbY = pR128->fbY; - pR128DRI->backX = pR128->backX; - pR128DRI->backY = pR128->backY; - pR128DRI->depthX = pR128->depthX; - pR128DRI->depthY = pR128->depthY; - pR128DRI->textureX = pR128->textureX; - pR128DRI->textureY = pR128->textureY; - pR128DRI->textureSize = pR128->textureSize; - pR128DRI->log2TexGran = pR128->log2TexGran; - - pR128DRI->IsPCI = pR128->IsPCI; - - pR128DRI->CCEMode = pR128->CCEMode; - pR128DRI->CCEFifoSize = pR128->CCEFifoSize; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n", - pR128DRI->registerHandle, pR128DRI->registerSize); - return DRIFinishScreenInit(pScreen); -} - -/* The screen is being closed, so clean up any state and free any - resources used by the DRI. */ -void R128DRICloseScreen(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr pR128 = R128PTR(pScrn); - - /* Stop the CCE if it is still in use */ - if (pR128->CCE2D) R128CCEStop(pScrn); - - /* De-allocate vertex buffers */ - if (pR128->vbBufs) { - drmUnmapBufs(pR128->vbBufs); - pR128->vbBufs = NULL; - } - - /* De-allocate all kernel resources */ - drmR128CleanupCCE(pR128->drmFD); - - /* De-allocate all AGP resources */ - if (pR128->agpTex) { - drmUnmap(pR128->agpTex, pR128->agpTexMapSize); - pR128->agpTex = NULL; - } - if (pR128->ind) { - drmUnmap(pR128->ind, pR128->indMapSize); - pR128->ind = NULL; - } - if (pR128->vb) { - drmUnmap(pR128->vb, pR128->vbMapSize); - pR128->vb = NULL; - } - if (pR128->ringReadPtr) { - drmUnmap(pR128->ringReadPtr, pR128->ringReadMapSize); - pR128->ringReadPtr = NULL; - } - if (pR128->ring) { - drmUnmap(pR128->ring, pR128->ringMapSize); - pR128->ring = NULL; - } - if (pR128->agpMemHandle) { - drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle); - drmAgpFree(pR128->drmFD, pR128->agpMemHandle); - pR128->agpMemHandle = 0; - drmAgpRelease(pR128->drmFD); - } - - /* De-allocate all DRI resources */ - DRICloseScreen(pScreen); - - /* De-allocate all DRI data structures */ - if (pR128->pDRIInfo) { - if (pR128->pDRIInfo->devPrivate) { - xfree(pR128->pDRIInfo->devPrivate); - pR128->pDRIInfo->devPrivate = NULL; - } - DRIDestroyInfoRec(pR128->pDRIInfo); - pR128->pDRIInfo = NULL; - } - if (pR128->pVisualConfigs) { - xfree(pR128->pVisualConfigs); - pR128->pVisualConfigs = NULL; - } - if (pR128->pVisualConfigsPriv) { - xfree(pR128->pVisualConfigsPriv); - pR128->pVisualConfigsPriv = NULL; - } -} Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h:1.1 Fri Jun 16 20:03:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h Mon Dec 18 14:31:00 2000 @@ -1,116 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h,v 1.1 2000/06/17 00:03:22 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <kevin@precisioninsight.com> - * Rickard E. Faith <faith@precisioninsight.com> - * - */ - -#ifndef _R128_DRI_ -#define _R128_DRI_ - -#include <xf86drm.h> - -/* DRI Driver defaults */ -#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM -#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM -#define R128_DEFAULT_AGP_MODE 2 -#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */ -#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */ -#define R128_DEFAULT_VB_SIZE 1 /* MB (must be page aligned) */ -#define R128_DEFAULT_IND_SIZE 1 /* MB (must be page aligned) */ -#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */ - -#define R128_DEFAULT_VB_BUF_SIZE 16384 /* bytes */ -#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */ - -#define R128_AGP_MAX_MODE 2 - -#define R128CCE_USE_RING_BUFFER(m) \ -(((m) == R128_PM4_192BM) || \ - ((m) == R128_PM4_128BM_64INDBM) || \ - ((m) == R128_PM4_64BM_128INDBM) || \ - ((m) == R128_PM4_64BM_64VCBM_64INDBM)) - -typedef struct { - /* MMIO register data */ - drmHandle registerHandle; - drmSize registerSize; - - /* CCE ring buffer data */ - drmHandle ringHandle; - drmSize ringMapSize; - int ringSize; - - /* CCE ring read pointer data */ - drmHandle ringReadPtrHandle; - drmSize ringReadMapSize; - - /* CCE vertex buffer data */ - drmHandle vbHandle; - drmSize vbMapSize; - int vbOffset; - int vbBufSize; - - /* CCE indirect buffer data */ - drmHandle indHandle; - drmSize indMapSize; - - /* CCE AGP Texture data */ - drmHandle agpTexHandle; - drmSize agpTexMapSize; - int log2AGPTexGran; - int agpTexOffset; - - /* DRI screen private data */ - int deviceID; /* PCI device ID */ - int width; /* Width in pixels of display */ - int height; /* Height in scanlines of display */ - int depth; /* Depth of display (8, 15, 16, 24) */ - int bpp; /* Bit depth of display (8, 16, 24, 32) */ - - int fbX; /* Start of frame buffer */ - int fbY; - int backX; /* Start of shared back buffer */ - int backY; - int depthX; /* Start of shared depth buffer */ - int depthY; - int textureX; /* Start of texture data in frame buffer */ - int textureY; - int textureSize; - int log2TexGran; - - int IsPCI; /* Current card is a PCI card */ - - int CCEMode; /* CCE mode that server/clients use */ - int CCEFifoSize; /* Size of the CCE command FIFO */ -} R128DRIRec, *R128DRIPtr; - -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h:1.1 Fri Jun 16 20:03:22 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h Mon Dec 18 14:31:00 2000 @@ -1,54 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h,v 1.1 2000/06/17 00:03:22 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - */ - -#ifndef _R128_DRIPRIV_H_ -#define _R128_DRIPRIV_H_ - -#define R128_MAX_DRAWABLES 256 - -extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **configprivs); - -typedef struct { - /* Nothing here yet */ - int dummy; -} R128ConfigPrivRec, *R128ConfigPrivPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} R128DRIContextRec, *R128DRIContextPtr; - -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c:1.38 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c:1.38 Fri Jun 30 21:40:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c Mon Dec 18 14:31:00 2000 @@ -1,2870 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.38 2000/07/01 01:40:45 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - * Credits: - * - * Thanks to Alan Hourihane <alanh@fairlite.demon..co.uk> and SuSE for - * providing source code to their 3.3.x Rage 128 driver. Portions of - * this file are based on the initialization code for that driver. - * - * References: - * - * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical - * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April - * 1999. - * - * RAGE 128 Software Development Manual (Technical Reference Manual P/N - * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. - * - * This server does not yet support these XFree86 4.0 features: - * DDC1 & DDC2 - * shadowfb - * overlay planes - * DGA - * - */ - - - /* X and server generic header files */ -#include "xf86.h" -#include "xf86_ansic.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "xf86RAC.h" -#include "xf86cmap.h" -#include "xf86fbman.h" -#include "xf86int10.h" - /* Backing store, software cursor, and - colormap initialization */ -#include "mibstore.h" -#include "mipointer.h" -#include "micmap.h" - -#define USE_FB /* not until overlays and 24->32 code added */ -#ifdef USE_FB -#include "fb.h" -#else - /* CFB support */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" -#endif - /* Xv support */ -#include "xf86xv.h" -#include "Xv.h" - - /* vgahw module (for VC save/restore only) */ -#include "vgaHW.h" - -#include "fbdevhw.h" - - /* XAA and Cursor Support */ -#include "xaa.h" -#include "xf86Cursor.h" - - - /* PCI support */ -#include "xf86PciInfo.h" -#include "xf86Pci.h" - - /* DDC support */ -#include "xf86DDC.h" - - /* VESA support */ -#include "vbe.h" - - /* DRI support */ -#ifdef XF86DRI -#include "GL/glxint.h" -#include "xf86drm.h" -#include "sarea.h" -#define _XF86DRI_SERVER_ -#include "xf86dri.h" -#include "dri.h" -#include "r128_dri.h" -#include "r128_dripriv.h" -#include "r128_sarea.h" -#endif - - /* Driver data structures */ -#include "r128.h" -#include "r128_reg.h" - -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - - - /* Forward definitions for driver functions */ -static OptionInfoPtr R128AvailableOptions(int chipid, int busid); -static Bool R128Probe(DriverPtr drv, int flags); -static void R128Identify(int flags); -static Bool R128PreInit(ScrnInfoPtr pScrn, int flags); -static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, - int argc, char **argv); - -static int R128ValidMode(int scrnIndex, DisplayModePtr mode, - Bool verbose, int flag); -static Bool R128EnterVT(int scrnIndex, int flags); -static void R128LeaveVT(int scrnIndex, int flags); -static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen); -static void R128FreeScreen(int scrnIndex, int flags); -static Bool R128SaveScreen(ScreenPtr pScreen, int mode); -static void R128Save(ScrnInfoPtr pScrn); -static void R128Restore(ScrnInfoPtr pScrn); -static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, - int PowerManagementMode, int flags); -static Bool R128EnterVTFBDev(int scrnIndex, int flags); -static void R128LeaveVTFBDev(int scrnIndex, int flags); - - /* Define driver */ -DriverRec R128 = { - R128_VERSION, - "ATI Rage 128", - R128Identify, - R128Probe, - R128AvailableOptions, - NULL -}; - - /* Chipsets */ -static SymTabRec R128Chipsets[] = { - { PCI_CHIP_RAGE128RE, "ATI Rage 128 RE (PCI)" }, - { PCI_CHIP_RAGE128RF, "ATI Rage 128 RF (AGP)" }, - { PCI_CHIP_RAGE128RK, "ATI Rage 128 RK (PCI)" }, - { PCI_CHIP_RAGE128RL, "ATI Rage 128 RL (AGP)" }, - { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro PF (AGP)" }, - { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility LE (PCI)" }, - { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility LF (AGP)" }, - { -1, NULL } -}; - -static PciChipsets R128PciChipsets[] = { - { PCI_CHIP_RAGE128RE, PCI_CHIP_RAGE128RE, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128RF, PCI_CHIP_RAGE128RF, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128RK, PCI_CHIP_RAGE128RK, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128RL, PCI_CHIP_RAGE128RL, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128PF, PCI_CHIP_RAGE128PF, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA }, - { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA }, - { -1, -1, RES_UNDEFINED } -}; - -typedef enum { - OPTION_NOACCEL, - OPTION_SW_CURSOR, - OPTION_HW_CURSOR, - OPTION_DAC_6BIT, - OPTION_DAC_8BIT, -#ifdef XF86DRI - OPTION_IS_PCI, - OPTION_CCE_PIO, - OPTION_NO_SECURITY, - OPTION_USEC_TIMEOUT, - OPTION_AGP_MODE, - OPTION_AGP_SIZE, - OPTION_RING_SIZE, - OPTION_VERT_SIZE, - OPTION_VBUF_SIZE, - OPTION_USE_CCE_2D, -#endif - OPTION_ENABLE_FP, - OPTION_CRT, - OPTION_FBDEV -} R128Opts; - -static OptionInfoRec R128Options[] = { - { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE }, - { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, -#ifdef XF86DRI - { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE }, - { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, - { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, - { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, - { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE }, - { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE }, - { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE }, -#endif - { OPTION_ENABLE_FP, "EnableFP", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, - { -1, NULL, OPTV_NONE, {0}, FALSE } -}; - -R128RAMRec R128RAM[] = { /* Memory Specifications - From RAGE 128 Software Development - Manual (Technical Reference Manual P/N - SDK-G04000 Rev 0.01), page 3-21. */ - { 4, 4, 3, 3, 1, 3, 1, 16, 12, "128-bit SDR SGRAM 1:1" }, - { 4, 8, 3, 3, 1, 3, 1, 17, 13, "64-bit SDR SGRAM 1:1" }, - { 4, 4, 1, 2, 1, 2, 1, 16, 12, "64-bit SDR SGRAM 2:1" }, - { 4, 4, 3, 3, 2, 3, 1, 16, 12, "64-bit DDR SGRAM" }, -}; - -static const char *vgahwSymbols[] = { - "vgaHWGetHWRec", - "vgaHWFreeHWRec", - "vgaHWLock", - "vgaHWUnlock", - "vgaHWSave", - "vgaHWRestore", - NULL -}; - -static const char *fbdevHWSymbols[] = { - "fbdevHWInit", - "fbdevHWUseBuildinMode", - - "fbdevHWGetDepth", - "fbdevHWGetVidmem", - - /* colormap */ - "fbdevHWLoadPalette", - - /* ScrnInfo hooks */ - "fbdevHWSwitchMode", - "fbdevHWAdjustFrame", - "fbdevHWEnterVT", - "fbdevHWLeaveVT", - "fbdevHWValidMode", - "fbdevHWRestore", - "fbdevHWModeInit", - "fbdevHWSave", - - "fbdevHWUnmapMMIO", - "fbdevHWUnmapVidmem", - "fbdevHWMapMMIO", - "fbdevHWMapVidmem", - - NULL -}; - -static const char *vbeSymbols[] = { - "VBEInit", - "vbeDoEDID", - NULL -}; - -#if 0 - /* Not used until DDC is supported. */ -static const char *ddcSymbols[] = { - "xf86PrintEDID", - "xf86DoEDID_DDC1", - "xf86DoEDID_DDC2", - NULL -}; - -static const char *i2cSymbols[] = { - "xf86CreateI2CBusRec", - "xf86I2CBusInit", - NULL -}; -#endif - -#ifdef XFree86LOADER -#ifdef USE_FB -static const char *fbSymbols[] = { - "fbScreenInit", - NULL -}; -#else -static const char *cfbSymbols[] = { - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb32ScreenInit", - "cfb24_32ScreenInit", - NULL -}; -#endif - -static const char *xf8_32bppSymbols[] = { - "xf86Overlay8Plus32Init", - NULL -}; - -static const char *xaaSymbols[] = { - "XAADestroyInfoRec", - "XAACreateInfoRec", - "XAAInit", - "XAAStippleScanlineFuncLSBFirst", - "XAAOverlayFBfuncs", - "XAACachePlanarMonoStipple", - "XAAScreenIndex", - NULL -}; - -static const char *ramdacSymbols[] = { - "xf86InitCursor", - "xf86CreateCursorInfoRec", - "xf86DestroyCursorInfoRec", - NULL -}; - -#ifdef XF86DRI -static const char *drmSymbols[] = { - "drmAddBufs", - "drmAddMap", - "drmAvailable", - "drmCtlAddCommand", - "drmCtlInstHandler", - "drmGetInterruptFromBusID", - "drmMapBufs", - "drmMarkBufs", - "drmUnmapBufs", - "drmFreeVersion", - "drmGetVersion", - NULL -}; - -static const char *driSymbols[] = { - "DRIGetDrawableIndex", - "DRIFinishScreenInit", - "DRIDestroyInfoRec", - "DRICloseScreen", - "DRIDestroyInfoRec", - "DRIScreenInit", - "DRIDestroyInfoRec", - "DRICreateInfoRec", - "DRILock", - "DRIUnlock", - "DRIGetSAREAPrivate", - "DRIGetContext", - "DRIQueryVersion", - "GlxSetVisualConfigs", - NULL -}; -#endif - -static MODULESETUPPROTO(R128Setup); - -static XF86ModuleVersionInfo R128VersRec = -{ - R128_NAME, - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XF86_VERSION_CURRENT, - R128_VERSION_MAJOR, R128_VERSION_MINOR, R128_VERSION_PATCH, - ABI_CLASS_VIDEODRV, - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - { 0, 0, 0, 0 } -}; - -XF86ModuleData r128ModuleData = { &R128VersRec, R128Setup, 0 }; - -static pointer R128Setup(pointer module, pointer opts, int *errmaj, - int *errmin) -{ - static Bool setupDone = FALSE; - - /* This module should be loaded only once, but check to be sure. */ - - if (!setupDone) { - setupDone = TRUE; - xf86AddDriver(&R128, module, 0); - - /* - * Modules that this driver always requires may be loaded here - * by calling LoadSubModule(). - */ - /* FIXME: add DRI support here */ - - /* - * Tell the loader about symbols from other modules that this module - * might refer to. - */ - LoaderRefSymLists(vgahwSymbols, -#ifdef USE_FB - fbSymbols, -#else - cfbSymbols, -#endif - xaaSymbols, - xf8_32bppSymbols, - ramdacSymbols, -#ifdef XF86DRI - drmSymbols, - driSymbols, -#endif - fbdevHWSymbols, - vbeSymbols, - 0 /* ddcsymbols */, - 0 /* i2csymbols */, - 0 /* shadowSymbols */, - NULL); - - /* - * The return value must be non-NULL on success even though there - * is no TearDownProc. - */ - return (pointer)1; - } else { - if (errmaj) *errmaj = LDR_ONCEONLY; - return NULL; - } -} - -#endif - -/* Allocate our private R128InfoRec. */ -static Bool R128GetRec(ScrnInfoPtr pScrn) -{ - if (pScrn->driverPrivate) return TRUE; - - pScrn->driverPrivate = xnfcalloc(sizeof(R128InfoRec), 1); - return TRUE; -} - -/* Free our private R128InfoRec. */ -static void R128FreeRec(ScrnInfoPtr pScrn) -{ - if (!pScrn || !pScrn->driverPrivate) return; - xfree(pScrn->driverPrivate); - pScrn->driverPrivate = NULL; -} - -/* Memory map the MMIO region. Used during pre-init and by R128MapMem, - below. */ -static Bool R128MapMMIO(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (info->FBDev) { - info->MMIO = fbdevHWMapMMIO(pScrn); - } else { - info->MMIO = xf86MapPciMem(pScrn->scrnIndex, - VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, - info->PciTag, - info->MMIOAddr, - R128_MMIOSIZE); - } - - if (!info->MMIO) return FALSE; - return TRUE; -} - -/* Unmap the MMIO region. Used during pre-init and by R128UnmapMem, - below. */ -static Bool R128UnmapMMIO(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (info->FBDev) - fbdevHWUnmapMMIO(pScrn); - else { - xf86UnMapVidMem(pScrn->scrnIndex, info->MMIO, R128_MMIOSIZE); - } - info->MMIO = NULL; - return TRUE; -} - -/* Memory map the frame buffer. Used by R128MapMem, below. */ -static Bool R128MapFB(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (info->FBDev) { - info->FB = fbdevHWMapVidmem(pScrn); - } else { - info->FB = xf86MapPciMem(pScrn->scrnIndex, - VIDMEM_FRAMEBUFFER, - info->PciTag, - info->LinearAddr, - info->FbMapSize); - } - - if (!info->FB) return FALSE; - return TRUE; -} - -/* Unmap the frame buffer. Used by R128UnmapMem, below. */ -static Bool R128UnmapFB(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if(info->FBDev) - fbdevHWUnmapVidmem(pScrn); - else - xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize); - info->FB = NULL; - return TRUE; -} - -/* Memory map the MMIO region and the frame buffer. */ -static Bool R128MapMem(ScrnInfoPtr pScrn) -{ - if (!R128MapMMIO(pScrn)) return FALSE; - if (!R128MapFB(pScrn)) { - R128UnmapMMIO(pScrn); - return FALSE; - } - return TRUE; -} - -/* Unmap the MMIO region and the frame buffer. */ -static Bool R128UnmapMem(ScrnInfoPtr pScrn) -{ - if (!R128UnmapMMIO(pScrn) || !R128UnmapFB(pScrn)) return FALSE; - return TRUE; -} - -/* Read PLL information */ -int INPLL(ScrnInfoPtr pScrn, int addr) -{ - R128MMIO_VARS(); - - OUTREG8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); - return INREG(R128_CLOCK_CNTL_DATA); -} - -#if 0 -/* Read PAL information (only used for debugging). */ -static int INPAL(int idx) -{ - R128MMIO_VARS(); - - OUTREG(R128_PALETTE_INDEX, idx << 16); - return INREG(R128_PALETTE_DATA); -} -#endif - -/* Wait for vertical sync. */ -void R128WaitForVerticalSync(ScrnInfoPtr pScrn) -{ - int i; - R128MMIO_VARS(); - - OUTREG(R128_GEN_INT_STATUS, R128_VSYNC_INT_AK); - for (i = 0; i < R128_TIMEOUT; i++) { - if (INREG(R128_GEN_INT_STATUS) & R128_VSYNC_INT) break; - } -} - -/* Blank screen. */ -static void R128Blank(ScrnInfoPtr pScrn) -{ - R128MMIO_VARS(); - - OUTREGP(R128_CRTC_EXT_CNTL, R128_CRTC_DISPLAY_DIS, ~R128_CRTC_DISPLAY_DIS); -} - -/* Unblank screen. */ -static void R128Unblank(ScrnInfoPtr pScrn) -{ - R128MMIO_VARS(); - - OUTREGP(R128_CRTC_EXT_CNTL, 0, ~R128_CRTC_DISPLAY_DIS); -} - -/* Compute log base 2 of val. */ -int R128MinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - -/* Compute n/d with rounding. */ -static int R128Div(int n, int d) -{ - return (n + (d / 2)) / d; -} - -/* Read PLL parameters from BIOS block. Default to typical values if there - is no BIOS. */ -static Bool R128GetPLLParameters(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - R128PLLPtr pll = &info->pll; - CARD16 bios_header; - CARD16 pll_info_block; - CARD8 tmp[64]; - Bool BIOSFromPCI = TRUE; - -#define R128ReadBIOS(offset, buffer, length) \ - (BIOSFromPCI ? \ - xf86ReadPciBIOS(offset, info->PciTag, 0, buffer, length) : \ - xf86ReadBIOS(info->BIOSAddr, offset, buffer, length)) - - R128ReadBIOS(0, tmp, sizeof(tmp)); - if (tmp[0] != 0x55 || tmp[1] != 0xaa) - { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Video BIOS not detected in PCI space!\n"); - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Attempting to read Video BIOS from legacy ISA space!\n"); - BIOSFromPCI = FALSE; - info->BIOSAddr = 0x000c0000; - R128ReadBIOS(0, tmp, sizeof(tmp)); - } - if (tmp[0] != 0x55 || tmp[1] != 0xaa) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Video BIOS not detected, using default PLL parameters!\n"); - /* These probably aren't going to work for - the card you are using. Specifically, - reference freq can be 29.50MHz, - 28.63MHz, or 14.32MHz. YMMV. */ - pll->reference_freq = 2950; - pll->reference_div = 65; - pll->min_pll_freq = 12500; - pll->max_pll_freq = 25000; - pll->xclk = 10300; - } else { - R128ReadBIOS(0x48, - (CARD8 *)&bios_header, sizeof(bios_header)); - R128ReadBIOS(bios_header + 0x30, - (CARD8 *)&pll_info_block, sizeof(pll_info_block)); - R128TRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", - bios_header, pll_info_block)); - - R128ReadBIOS(pll_info_block + 0x0e, - (CARD8 *)&pll->reference_freq, - sizeof(pll->reference_freq)); - R128ReadBIOS(pll_info_block + 0x10, - (CARD8 *)&pll->reference_div, - sizeof(pll->reference_div)); - R128ReadBIOS(pll_info_block + 0x12, - (CARD8 *)&pll->min_pll_freq, - sizeof(pll->min_pll_freq)); - R128ReadBIOS(pll_info_block + 0x16, - (CARD8 *)&pll->max_pll_freq, - sizeof(pll->max_pll_freq)); - R128ReadBIOS(pll_info_block + 0x08, - (CARD8 *)&pll->xclk, sizeof(pll->xclk)); - } - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PLL parameters: rf=%d rd=%d min=%d max=%d; xclk=%d\n", - pll->reference_freq, - pll->reference_div, - pll->min_pll_freq, - pll->max_pll_freq, - pll->xclk); - - return TRUE; -} - -static -OptionInfoPtr -R128AvailableOptions(int chipid, int busid) -{ - return R128Options; -} - -/* Return the string name for supported chipset 'n'; NULL otherwise. */ -static void R128Identify(int flags) -{ - xf86PrintChipsets(R128_NAME, - "Driver for ATI Rage 128 chipset", - R128Chipsets); -} - -/* Return TRUE if chipset is present; FALSE otherwise. */ -static Bool R128Probe(DriverPtr drv, int flags) -{ - int numUsed; - int numDevSections; - int *usedChips; - GDevPtr *devSections; - EntityInfoPtr pEnt; - Bool foundScreen = FALSE; - int i; - - if ((numDevSections = xf86MatchDevice(R128_NAME, &devSections)) <= 0) - return FALSE; - - if (!xf86GetPciVideoInfo()) return FALSE; - - numUsed = xf86MatchPciInstances(R128_NAME, - PCI_VENDOR_ATI, - R128Chipsets, - R128PciChipsets, - devSections, - numDevSections, - drv, - &usedChips); - - if (numUsed<=0) return FALSE; - - if (flags & PROBE_DETECT) - foundScreen = TRUE; - else for (i = 0; i < numUsed; i++) { - pEnt = xf86GetEntityInfo(usedChips[i]); - - if (pEnt->active) { - ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); - - pScrn->driverVersion = R128_VERSION; - pScrn->driverName = R128_NAME; - pScrn->name = R128_NAME; - pScrn->Probe = R128Probe; - pScrn->PreInit = R128PreInit; - pScrn->ScreenInit = R128ScreenInit; - pScrn->SwitchMode = R128SwitchMode; - pScrn->AdjustFrame = R128AdjustFrame; - pScrn->EnterVT = R128EnterVT; - pScrn->LeaveVT = R128LeaveVT; - pScrn->FreeScreen = R128FreeScreen; - pScrn->ValidMode = R128ValidMode; - - foundScreen = TRUE; - - xf86ConfigActivePciEntity(pScrn, usedChips[i], R128PciChipsets, - 0, 0, 0, 0, 0); - } - xfree(pEnt); - } - - if (numUsed) xfree(usedChips); - xfree(devSections); - - return foundScreen; -} - -/* This is called by R128PreInit to set up the default visual. */ -static Bool R128PreInitVisual(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (!xf86SetDepthBpp(pScrn, 8, 8, 8, (Support24bppFb - | Support32bppFb -#ifndef USE_FB - | SupportConvert32to24 -#endif - ))) - return FALSE; - - switch (pScrn->depth) { - case 8: - case 15: - case 16: - case 24: - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by %s driver\n", - pScrn->depth, R128_NAME); - return FALSE; - } - - xf86PrintDepthBpp(pScrn); - - info->fifo_slots = 0; - info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); - info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; - info->CurrentLayout.depth = pScrn->depth; - info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; - info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 - ? pScrn->bitsPerPixel - : pScrn->depth); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", - pScrn->depth, - info->CurrentLayout.pixel_bytes, - info->CurrentLayout.pixel_bytes > 1 ? "s" : "", - info->pix24bpp); - - - if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Default visual (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - return TRUE; - -} - -/* This is called by R128PreInit to handle all color weight issues. */ -static Bool R128PreInitWeight(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - /* Save flag for 6 bit DAC to use for - setting CRTC registers. Otherwise use - an 8 bit DAC, even if xf86SetWeight sets - pScrn->rgbBits to some value other than - 8. */ - info->dac6bits = FALSE; - if (pScrn->depth > 8) { - rgb defaultWeight = { 0, 0, 0 }; - if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; - } else { - pScrn->rgbBits = 8; - if (xf86ReturnOptValBool(R128Options, OPTION_DAC_6BIT, FALSE)) { - pScrn->rgbBits = 6; - info->dac6bits = TRUE; - } - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using %d bits per RGB (%d bit DAC)\n", - pScrn->rgbBits, info->dac6bits ? 6 : 8); - - return TRUE; - -} - -/* This is called by R128PreInit to handle config file overrides for things - like chipset and memory regions. Also determine memory size and type. - If memory type ever needs an override, put it in this routine. */ -static Bool R128PreInitConfig(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - EntityInfoPtr pEnt = info->pEnt; - GDevPtr dev = pEnt->device; - int offset = 0; /* RAM Type */ - MessageType from; - unsigned char *R128MMIO; - CARD32 fp_horz_stretch = 0, fp_vert_stretch = 0; - CARD32 crtc_h_total_disp = 0, crtc_v_total_disp = 0; - CARD32 crtc_h_sync_strt_wid = 0, crtc_v_sync_strt_wid = 0; - - /* Chipset */ - from = X_PROBED; - if (dev->chipset && *dev->chipset) { - info->Chipset = xf86StringToToken(R128Chipsets, dev->chipset); - from = X_CONFIG; - } else if (dev->chipID >= 0) { - info->Chipset = dev->chipID; - from = X_CONFIG; - } else { - info->Chipset = info->PciInfo->chipType; - } - pScrn->chipset = (char *)xf86TokenToString(R128Chipsets, info->Chipset); - - if (!pScrn->chipset) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ChipID 0x%04x is not recognized\n", info->Chipset); - return FALSE; - } - - if (info->Chipset < 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognized\n", pScrn->chipset); - return FALSE; - } - - xf86DrvMsg(pScrn->scrnIndex, from, - "Chipset: \"%s\" (ChipID = 0x%04x)\n", - pScrn->chipset, - info->Chipset); - - /* Framebuffer */ - - from = X_PROBED; - info->LinearAddr = info->PciInfo->memBase[0] & 0xfc000000; - if (dev->MemBase) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Linear address override, using 0x%08x instead of 0x%08x\n", - dev->MemBase, - info->LinearAddr); - info->LinearAddr = dev->MemBase; - from = X_CONFIG; - } else if (!info->LinearAddr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "No valid linear framebuffer address\n"); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, from, - "Linear framebuffer at 0x%08lx\n", info->LinearAddr); - - /* MMIO registers */ - from = X_PROBED; - info->MMIOAddr = info->PciInfo->memBase[2] & 0xffffff00; - if (dev->IOBase) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "MMIO address override, using 0x%08x instead of 0x%08x\n", - dev->IOBase, - info->MMIOAddr); - info->MMIOAddr = dev->IOBase; - from = X_CONFIG; - } else if (!info->MMIOAddr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid MMIO address\n"); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, from, - "MMIO registers at 0x%08lx\n", info->MMIOAddr); - - /* BIOS */ - from = X_PROBED; - info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000; - if (dev->BiosBase) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "BIOS address override, using 0x%08x instead of 0x%08x\n", - dev->BiosBase, - info->BIOSAddr); - info->BIOSAddr = dev->BiosBase; - from = X_CONFIG; - } - if (info->BIOSAddr) { - xf86DrvMsg(pScrn->scrnIndex, from, - "BIOS at 0x%08lx\n", info->BIOSAddr); - } - - /* Flat panel (part 1) */ - /* FIXME: Make this an option */ - switch (info->Chipset) { - case PCI_CHIP_RAGE128LE: - case PCI_CHIP_RAGE128LF: info->HasPanelRegs = TRUE; break; - case PCI_CHIP_RAGE128RE: - case PCI_CHIP_RAGE128RF: - case PCI_CHIP_RAGE128RK: - case PCI_CHIP_RAGE128RL: - case PCI_CHIP_RAGE128PF: - default: info->HasPanelRegs = FALSE; break; - } - - /* Read registers used to determine options */ - from = X_PROBED; - R128MapMMIO(pScrn); - R128MMIO = info->MMIO; - if (info->FBDev) - pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; - else - pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024; - info->MemCntl = INREG(R128_MEM_CNTL); - info->BusCntl = INREG(R128_BUS_CNTL); - if (info->HasPanelRegs) { - fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); - fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); - crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP); - crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP); - crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID); - crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID); - } - R128MMIO = NULL; - R128UnmapMMIO(pScrn); - - /* RAM */ - switch (info->MemCntl & 0x3) { - case 0: /* SDR SGRAM 1:1 */ - switch (info->Chipset) { - case PCI_CHIP_RAGE128LE: - case PCI_CHIP_RAGE128LF: - case PCI_CHIP_RAGE128RE: - case PCI_CHIP_RAGE128RF: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */ - case PCI_CHIP_RAGE128RK: - case PCI_CHIP_RAGE128RL: - default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ - } - break; - case 1: offset = 2; break; /* 64-bit SDR SGRAM 2:1 */ - case 2: offset = 3; break; /* 64-bit DDR SGRAM */ - default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */ - } - info->ram = &R128RAM[offset]; - - if (dev->videoRam) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Video RAM override, using %d kB instead of %d kB\n", - dev->videoRam, - pScrn->videoRam); - from = X_CONFIG; - pScrn->videoRam = dev->videoRam; - } - pScrn->videoRam &= ~1023; - info->FbMapSize = pScrn->videoRam * 1024; - xf86DrvMsg(pScrn->scrnIndex, from, - "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); - - /* Flat panel (part 2) */ - if ((info->EnableFP = xf86ReturnOptValBool(R128Options, - OPTION_ENABLE_FP, FALSE))) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Enabling use of flat panel registers\n"); - if ((info->CRTOnly = xf86ReturnOptValBool(R128Options, - OPTION_CRT, FALSE))) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using external CRT instead of " - "flat panel for display\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using flat panel for display\n"); - } - } - - if (info->HasPanelRegs) { - int tmp; - - info->PanelXRes = - (fp_horz_stretch & R128_HORZ_PANEL_SIZE) >> R128_HORZ_PANEL_SHIFT; - info->PanelXRes = (info->PanelXRes + 1) * 8; - info->PanelYRes = - (fp_vert_stretch & R128_VERT_PANEL_SIZE) >> R128_VERT_PANEL_SHIFT; - info->PanelYRes += 1; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel dimensions: %dx%d\n", - info->PanelXRes, info->PanelYRes); - - info->PanelHNonVis = - (crtc_h_total_disp & R128_CRTC_H_TOTAL) >> R128_CRTC_H_TOTAL_SHIFT; - info->PanelHNonVis += 4; /* Add 4 since we are in VGA mode */ - tmp = - (crtc_h_total_disp & R128_CRTC_H_DISP) >> R128_CRTC_H_DISP_SHIFT; - info->PanelHNonVis -= tmp; - info->PanelHOverPlus = - (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_STRT_CHAR) - >> R128_CRTC_H_SYNC_STRT_CHAR_SHIFT; - info->PanelHOverPlus -= tmp; - switch (info->CurrentLayout.pixel_code) { - /* Adjustments are from ATI */ - case 8: info->PanelHOverPlus += 2; break; - case 15: - case 16: info->PanelHOverPlus += 1; break; - case 24: - case 32: info->PanelHOverPlus += 0; break; - } - info->PanelHSyncWidth = - (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_WID) - >> R128_CRTC_H_SYNC_WID_SHIFT; - info->PanelHSyncWidth += 14; /* ??? */ - - info->PanelVNonVis = - (crtc_v_total_disp & R128_CRTC_V_TOTAL) >> R128_CRTC_V_TOTAL_SHIFT; - info->PanelVNonVis += 1; /* Add 1 since we are in VGA mode */ - tmp = - (crtc_v_total_disp & R128_CRTC_V_DISP) >> R128_CRTC_V_DISP_SHIFT; - info->PanelVNonVis -= tmp; - info->PanelVOverPlus = - (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_STRT) - >> R128_CRTC_V_SYNC_STRT_SHIFT; - info->PanelVOverPlus -= tmp + 1; - info->PanelVSyncWidth = - (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_WID) - >> R128_CRTC_V_SYNC_WID_SHIFT; - info->PanelVSyncWidth -= 2; /* ??? */ - } - -#ifdef XF86DRI - /* AGP/PCI */ - if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) { - info->IsPCI = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); - } else { - switch (info->Chipset) { - case PCI_CHIP_RAGE128LE: - case PCI_CHIP_RAGE128RE: - case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break; - case PCI_CHIP_RAGE128LF: - case PCI_CHIP_RAGE128RF: - case PCI_CHIP_RAGE128RL: - case PCI_CHIP_RAGE128PF: - default: info->IsPCI = FALSE; break; - } - } -#endif - - return TRUE; -} - -static Bool R128PreInitDDC(ScrnInfoPtr pScrn) -{ - /* FIXME: DDC support goes here. */ -#if 0 - /* Using the GPIO_MONID register for DDC2 - does not appear to work as expected. - Hence, the implementation of DDC is - deferred. */ - R128InfoPtr info = R128PTR(pScrn); - Bool ret = TRUE; - - if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; - xf86LoaderReqSymLists(ddcSymbols, NULL); - if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - - R128MapMMIO(pScrn); - if (!R128I2CInit(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n"); - ret = FALSE; - } else { - xf86SetDDCProperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c))); - } - R128UnmapMMIO(pScrn); - return ret; -#else - return TRUE; -#endif -} - -/* This is called by R128PreInit to initialize gamma correction. */ -static Bool R128PreInitGamma(ScrnInfoPtr pScrn) -{ - Gamma zeros = { 0.0, 0.0, 0.0 }; - - if (!xf86SetGamma(pScrn, zeros)) return FALSE; - return TRUE; -} - -/* This is called by R128PreInit to validate modes and compute parameters - for all of the valid modes. */ -static Bool R128PreInitModes(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - ClockRangePtr clockRanges; - int modesFound; - char *mod = NULL; - const char *Sym = NULL; - - /* Get mode information */ - pScrn->progClock = TRUE; - clockRanges = xnfcalloc(sizeof(*clockRanges), 1); - clockRanges->next = NULL; - clockRanges->minClock = info->pll.min_pll_freq; - clockRanges->maxClock = info->pll.max_pll_freq * 10; - clockRanges->clockIndex = -1; - clockRanges->interlaceAllowed = TRUE; - clockRanges->doubleScanAllowed = TRUE; - - modesFound = xf86ValidateModes(pScrn, - pScrn->monitor->Modes, - pScrn->display->modes, - clockRanges, - NULL, /* linePitches */ - 8 * 64, /* minPitch */ - 8 * 1024, /* maxPitch */ - 64 * pScrn->bitsPerPixel, /* pitchInc */ - 128, /* minHeight */ - 2048, /* maxHeight */ - pScrn->virtualX, - pScrn->virtualY, - info->FbMapSize, - LOOKUP_BEST_REFRESH); - - if (modesFound < 1 && info->FBDev) { - fbdevHWUseBuildinMode(pScrn); - pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */ - modesFound = 1; - } - - if (modesFound == -1) return FALSE; - xf86PruneDriverModes(pScrn); - if (!modesFound || !pScrn->modes) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); - return FALSE; - } - xf86SetCrtcForModes(pScrn, 0); - pScrn->currentMode = pScrn->modes; - xf86PrintModes(pScrn); - - /* Set DPI */ - xf86SetDpi(pScrn, 0, 0); - - /* Get ScreenInit function */ -#ifdef USE_FB - mod = "fb"; - Sym = "fbScreenInit"; -#else - switch (pScrn->bitsPerPixel) { - case 8: mod = "cfb"; Sym = "cfbScreenInit"; break; - case 16: mod = "cfb16"; Sym = "cfb16ScreenInit"; break; - case 24: - if (info->pix24bpp == 24) { - mod = "cfb24"; Sym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; Sym = "cfb24_32ScreenInit"; - } - break; - case 32: mod = "cfb32"; Sym = "cfb32ScreenInit"; break; - } -#endif - if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; - xf86LoaderReqSymbols(Sym, NULL); - - info->CurrentLayout.displayWidth = pScrn->displayWidth; - info->CurrentLayout.mode = pScrn->currentMode; - - return TRUE; -} - -/* This is called by R128PreInit to initialize the hardware cursor. */ -static Bool R128PreInitCursor(ScrnInfoPtr pScrn) -{ - if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { - if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; - } - return TRUE; -} - -/* This is called by R128PreInit to initialize hardware acceleration. */ -static Bool R128PreInitAccel(ScrnInfoPtr pScrn) -{ - if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { - if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; - } - return TRUE; -} - -static Bool R128PreInitInt10(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); -#if 1 - if (xf86LoadSubModule(pScrn, "int10")) { - xf86Int10InfoPtr pInt; - xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); - pInt = xf86InitInt10(info->pEnt->index); - xf86FreeInt10(pInt); - } -#endif - return TRUE; -} - -#ifdef XF86DRI -static Bool R128PreInitDRI(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (info->IsPCI) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n"); - info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; - } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n"); - info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in BM mode\n"); - info->CCEMode = R128_DEFAULT_CCE_BM_MODE; - } - - if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n"); - info->CCE2D = TRUE; - } else { - info->CCE2D = FALSE; - } - - if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "WARNING!!! CCE Security checks disabled!!! **********\n"); - info->CCESecure = FALSE; - } else { - info->CCESecure = TRUE; - } - - info->agpMode = R128_DEFAULT_AGP_MODE; - info->agpSize = R128_DEFAULT_AGP_SIZE; - info->ringSize = R128_DEFAULT_RING_SIZE; - info->vbSize = R128_DEFAULT_VB_SIZE; - info->indSize = R128_DEFAULT_IND_SIZE; - info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; - - info->vbBufSize = R128_DEFAULT_VB_BUF_SIZE; - - info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; - - if (!info->IsPCI) { - if (xf86GetOptValInteger(R128Options, - OPTION_AGP_MODE, &(info->agpMode))) { - if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Illegal AGP Mode: %d\n", info->agpMode); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using AGP %dx mode\n", info->agpMode); - } - - if (xf86GetOptValInteger(R128Options, - OPTION_AGP_SIZE, (int *)&(info->agpSize))) { - switch (info->agpSize) { - case 4: - case 8: - case 16: - case 32: - case 64: - case 128: - case 256: - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Illegal AGP size: %d MB\n", info->agpSize); - return FALSE; - } - } - - if (xf86GetOptValInteger(R128Options, - OPTION_RING_SIZE, &(info->ringSize))) { - if (info->ringSize < 1 || info->ringSize >= info->agpSize) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Illegal ring buffer size: %d MB\n", - info->ringSize); - return FALSE; - } - } - - if (xf86GetOptValInteger(R128Options, - OPTION_VERT_SIZE, &(info->vbSize))) { - if (info->vbSize < 1 || info->vbSize >= info->agpSize) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Illegal vertex buffers list size: %d MB\n", - info->vbSize); - return FALSE; - } - } - - if (xf86GetOptValInteger(R128Options, - OPTION_VBUF_SIZE, &(info->vbBufSize))) { - int numBufs = info->vbSize*1024*1024/info->vbBufSize; - if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */ - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Illegal individual vertex buffer size: %d bytes\n", - info->vbBufSize); - return FALSE; - } - } - - if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize > - info->agpSize) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Buffers are too big for requested AGP space\n"); - return FALSE; - } - - info->agpTexSize = info->agpSize - (info->ringSize + - info->vbSize + - info->indSize); - - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d MB AGP aperture\n", info->agpSize); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d MB for the ring buffer\n", info->ringSize); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d MB for vertex buffers\n", info->vbSize); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d MB for indirect buffers\n", info->indSize); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d MB for AGP textures\n", info->agpTexSize); - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using %d byte vertex buffers\n", info->vbBufSize); - } - - if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT, - &(info->CCEusecTimeout))) { - /* This option checked by the R128 DRM kernel module */ - } - - return TRUE; -} -#endif - -static void -R128ProbeDDC(ScrnInfoPtr pScrn, int index) -{ - vbeInfoPtr pVbe; - if (xf86LoadSubModule(pScrn, "vbe")) { - pVbe = VBEInit(NULL,index); - ConfiguredMonitor = vbeDoEDID(pVbe, NULL); - } -} - -/* R128PreInit is called once at server startup. */ -static Bool R128PreInit(ScrnInfoPtr pScrn, int flags) -{ - R128InfoPtr info; - - R128TRACE(("R128PreInit\n")); - if (pScrn->numEntities != 1) return FALSE; - - if (!R128GetRec(pScrn)) return FALSE; - - info = R128PTR(pScrn); - - info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); - if (info->pEnt->location.type != BUS_PCI) goto fail; - - if (flags & PROBE_DETECT) { - R128ProbeDDC(pScrn, info->pEnt->index); - return TRUE; - } - - if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - xf86LoaderReqSymLists(vgahwSymbols, NULL); - if (!vgaHWGetHWRec(pScrn)) { - R128FreeRec(pScrn); - return FALSE; - } - - info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); - info->PciTag = pciTag(info->PciInfo->bus, - info->PciInfo->device, - info->PciInfo->func); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "PCI bus %d card %d func %d\n", - info->PciInfo->bus, - info->PciInfo->device, - info->PciInfo->func); - - if (xf86RegisterResources(info->pEnt->index, 0, ResNone)) goto fail; - - pScrn->racMemFlags = RAC_FB | RAC_COLORMAP; - pScrn->monitor = pScrn->confScreen->monitor; - - if (!R128PreInitVisual(pScrn)) goto fail; - - /* We can't do this until we have a - pScrn->display. */ - xf86CollectOptions(pScrn, NULL); - xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, R128Options); - - if (!R128PreInitWeight(pScrn)) goto fail; - - if (xf86ReturnOptValBool(R128Options, OPTION_FBDEV, FALSE)) { - info->FBDev = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using framebuffer device\n"); - } - - if (info->FBDev) { - /* check for linux framebuffer device */ - if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; - xf86LoaderReqSymLists(fbdevHWSymbols, NULL); - if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; - pScrn->SwitchMode = fbdevHWSwitchMode; - pScrn->AdjustFrame = fbdevHWAdjustFrame; - pScrn->EnterVT = R128EnterVTFBDev; - pScrn->LeaveVT = R128LeaveVTFBDev; - pScrn->ValidMode = fbdevHWValidMode; - } - - if (!info->FBDev) - if (!R128PreInitInt10(pScrn)) goto fail; - - if (!R128PreInitConfig(pScrn)) goto fail; - - if (!R128GetPLLParameters(pScrn)) goto fail; - - if (!R128PreInitDDC(pScrn)) goto fail; - - if (!R128PreInitGamma(pScrn)) goto fail; - - if (!R128PreInitModes(pScrn)) goto fail; - - if (!R128PreInitCursor(pScrn)) goto fail; - - if (!R128PreInitAccel(pScrn)) goto fail; - -#ifdef XF86DRI - if (!R128PreInitDRI(pScrn)) goto fail; -#endif - - return TRUE; - - fail: - /* Pre-init failed. */ - vgaHWFreeHWRec(pScrn); - R128FreeRec(pScrn); - return FALSE; -} - -/* Load a palette. */ -static void R128LoadPalette(ScrnInfoPtr pScrn, int numColors, - int *indices, LOCO *colors, VisualPtr pVisual) -{ - R128InfoPtr info = R128PTR(pScrn); - int i; - int idx; - unsigned char r, g, b; - R128MMIO_VARS(); - - /* Select palette 0 (main CRTC) if using FP-enabled chip */ - if (info->HasPanelRegs) PAL_SELECT(0); - - if (info->CurrentLayout.depth == 15) { - /* 15bpp mode. This sends 32 values. */ - for (i = 0; i < numColors; i++) { - idx = indices[i]; - r = colors[idx].red; - g = colors[idx].green; - b = colors[idx].blue; - OUTPAL(idx * 8, r, g, b); - } - } - else if (info->CurrentLayout.depth == 16) { - /* 16bpp mode. This sends 64 values. */ - /* There are twice as many green values as - there are values for red and blue. So, - we take each red and blue pair, and - combine it with each of the two green - values. */ - for (i = 0; i < numColors; i++) { - idx = indices[i]; - r = colors[idx / 2].red; - g = colors[idx].green; - b = colors[idx / 2].blue; - OUTPAL(idx * 4, r, g, b); - } - } - else { - /* 8bpp mode. This sends 256 values. */ - for (i = 0; i < numColors; i++) { - idx = indices[i]; - r = colors[idx].red; - b = colors[idx].blue; - g = colors[idx].green; - OUTPAL(idx, r, g, b); - } - } -} - -/* Called at the start of each server generation. */ -static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, - int argc, char **argv) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - R128InfoPtr info = R128PTR(pScrn); - BoxRec MemBox; - int y2; - - R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); - -#ifdef XF86DRI - /* Turn off the CCE for now. */ - info->CCEInUse = FALSE; -#endif - - if (!R128MapMem(pScrn)) return FALSE; - pScrn->fbOffset = 0; -#ifdef XF86DRI - info->fbX = 0; - info->fbY = 0; -#endif - - info->PaletteSavedOnVT = FALSE; - - R128Save(pScrn); - if (info->FBDev) { - if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; - } else { - if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; - } - - R128SaveScreen(pScreen, SCREEN_SAVER_ON); - pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - - /* Visual setup */ - miClearVisualTypes(); - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, - pScrn->defaultVisual)) return FALSE; - -#ifdef XF86DRI - /* Setup DRI after visuals have been - established, but before cfbScreenInit is - called. cfbScreenInit will eventually - call the driver's InitGLXVisuals call - back. */ - if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) - info->directRenderingEnabled = R128DRIScreenInit(pScreen); - else - info->directRenderingEnabled = FALSE; -#endif - -#ifdef USE_FB - if (!fbScreenInit (pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, - pScrn->bitsPerPixel)) - return FALSE; -#else - switch (pScrn->bitsPerPixel) { - case 8: - if (!cfbScreenInit(pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) - return FALSE; - break; - case 16: - if (!cfb16ScreenInit(pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) - return FALSE; - break; - case 24: - if (info->pix24bpp == 24) { - if (!cfb24ScreenInit(pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - } else { - if (!cfb24_32ScreenInit(pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth)) - return FALSE; - } - break; - case 32: - if (!cfb32ScreenInit(pScreen, info->FB, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) - return FALSE; - break; - default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Invalid bpp (%d)\n", pScrn->bitsPerPixel); - return FALSE; - } -#endif - xf86SetBlackWhitePixels(pScreen); - - if (pScrn->bitsPerPixel > 8) { - VisualPtr visual; - - for (visual = pScreen->visuals + pScreen->numVisuals; - visual >= pScreen->visuals; - visual--) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } - } - } - - R128DGAInit(pScreen); - - /* Memory manager setup */ - MemBox.x1 = 0; - MemBox.y1 = 0; - MemBox.x2 = pScrn->displayWidth; - y2 = info->FbMapSize / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes); - if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */ - MemBox.y2 = y2; - - /* The acceleration engine uses 14 bit - signed coordinates, so we can't have any - drawable caches beyond this region. */ - if (MemBox.y2 > 8191) MemBox.y2 = 8191; - - if (!xf86InitFBManager(pScreen, &MemBox)) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Memory manager initialization to (%d,%d) (%d,%d) failed\n", - MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); - return FALSE; - } else { - int width, height; - FBAreaPtr fbarea; - - xf86DrvMsg(scrnIndex, X_INFO, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); - if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, - 2, 0, NULL, NULL, NULL))) { - xf86DrvMsg(scrnIndex, X_INFO, - "Reserved area from (%d,%d) to (%d,%d)\n", - fbarea->box.x1, fbarea->box.y1, - fbarea->box.x2, fbarea->box.y2); - } else { - xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n"); - } - if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { - xf86DrvMsg(scrnIndex, X_INFO, - "Largest offscreen area available: %d x %d\n", - width, height); - } - } - -#ifdef XF86DRI - /* Allocate frame buffer space for the - shared back and depth buffers as well - as for local textures. */ - if (info->directRenderingEnabled) { - FBAreaPtr fbarea; - int width_bytes = (pScrn->displayWidth * - info->CurrentLayout.pixel_bytes); - int maxy = info->FbMapSize / width_bytes; - int l; - - /* Allocate the shared back buffer */ - if ((fbarea = xf86AllocateOffscreenArea(pScreen, - pScrn->virtualX, - pScrn->virtualY, - 32, NULL, NULL, NULL))) { - xf86DrvMsg(scrnIndex, X_INFO, - "Reserved back buffer from (%d,%d) to (%d,%d)\n", - fbarea->box.x1, fbarea->box.y1, - fbarea->box.x2, fbarea->box.y2); - - info->backX = fbarea->box.x1; - info->backY = fbarea->box.y1; - } else { - xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); - info->backX = -1; - info->backY = -1; - } - - /* Allocate the shared depth buffer */ - if ((fbarea = xf86AllocateOffscreenArea(pScreen, - pScrn->virtualX, - pScrn->virtualY, - 32, NULL, NULL, NULL))) { - xf86DrvMsg(scrnIndex, X_INFO, - "Reserved depth buffer from (%d,%d) to (%d,%d)\n", - fbarea->box.x1, fbarea->box.y1, - fbarea->box.x2, fbarea->box.y2); - - info->depthX = fbarea->box.x1; - info->depthY = fbarea->box.y1; - } else { - xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); - info->depthX = -1; - info->depthY = -1; - } - - /* Allocate local texture space */ - if (((maxy - MemBox.y2 - 1) * width_bytes) > - (pScrn->virtualX * pScrn->virtualY * 2 * - info->CurrentLayout.pixel_bytes)) { - info->textureX = 0; - info->textureY = MemBox.y2 + 1; - info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes; - - l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); - if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; - - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - xf86DrvMsg(scrnIndex, X_INFO, - "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", - info->textureSize/1024, - info->textureX, info->textureY, - pScrn->displayWidth, maxy); - } else if ((fbarea = xf86AllocateOffscreenArea(pScreen, - pScrn->virtualX, - pScrn->virtualY * 2, - 32, - NULL, NULL, NULL))) { - info->textureX = fbarea->box.x1; - info->textureY = fbarea->box.y1; - info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) * - (fbarea->box.x2 - fbarea->box.x1) * - info->CurrentLayout.pixel_bytes); - - l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); - if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; - - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - xf86DrvMsg(scrnIndex, X_INFO, - "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", - info->textureSize/1024, - fbarea->box.x1, fbarea->box.y1, - fbarea->box.x2, fbarea->box.y2); - } else { - xf86DrvMsg(scrnIndex, X_ERROR, - "Unable to reserve texture space in frame buffer\n"); - info->textureX = -1; - info->textureY = -1; - } - } -#endif - - /* Backing store setup */ - miInitializeBackingStore(pScreen); - xf86SetBackingStore(pScreen); - - /* Acceleration setup */ - if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) { - if (R128AccelInit(pScreen)) { - xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n"); - } else { - xf86DrvMsg(scrnIndex, X_ERROR, - "Acceleration initialization failed\n"); - xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); - } - } else { - xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n"); - } - - /* Cursor setup */ - miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); - - /* Hardware cursor setup */ - if (!xf86ReturnOptValBool(R128Options, OPTION_SW_CURSOR, FALSE)) { - if (R128CursorInit(pScreen)) { - int width, height; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using hardware cursor (scanline %d)\n", - info->cursor_start / pScrn->displayWidth); - if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, - 0, 0, 0)) { - xf86DrvMsg(scrnIndex, X_INFO, - "Largest offscreen area available: %d x %d\n", - width, height); - } - } else { - xf86DrvMsg(scrnIndex, X_ERROR, - "Hardware cursor initialization failed\n"); - xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); - } - } else { - xf86DrvMsg(scrnIndex, X_INFO, "Using software cursor\n"); - } - - /* Colormap setup */ - if (!miCreateDefColormap(pScreen)) return FALSE; - if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8, - (info->FBDev ? fbdevHWLoadPalette : - R128LoadPalette), NULL, - CMAP_PALETTED_TRUECOLOR - | CMAP_RELOAD_ON_MODE_SWITCH - | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE; - - /* DPMS setup */ -#ifdef DPMSExtension - xf86DPMSInit(pScreen, R128DisplayPowerManagementSet, 0); -#endif - - /* Xv setup */ -#ifdef XvExtension - { - XF86VideoAdaptorPtr *ptr; - int n; - - if ((n = xf86XVListGenericAdaptors(pScrn, &ptr))) - xf86XVScreenInit(pScreen, ptr, n); - } -#endif - - /* Provide SaveScreen */ - pScreen->SaveScreen = R128SaveScreen; - - /* Wrap CloseScreen */ - info->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = R128CloseScreen; - - /* Note unused options */ - if (serverGeneration == 1) - xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); - -#ifdef XF86DRI - /* DRI finalization */ - if (info->directRenderingEnabled) { - /* Now that mi, cfb, drm and others have - done their thing, complete the DRI - setup. */ - info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen); - } - if (info->directRenderingEnabled) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); - } -#endif - - return TRUE; -} - -/* Write common registers (initialized to 0). */ -static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128MMIO_VARS(); - - OUTREG(R128_OVR_CLR, restore->ovr_clr); - OUTREG(R128_OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right); - OUTREG(R128_OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom); - OUTREG(R128_OV0_SCALE_CNTL, restore->ov0_scale_cntl); - OUTREG(R128_MPP_TB_CONFIG, restore->mpp_tb_config ); - OUTREG(R128_MPP_GP_CONFIG, restore->mpp_gp_config ); - OUTREG(R128_SUBPIC_CNTL, restore->subpic_cntl); - OUTREG(R128_VIPH_CONTROL, restore->viph_control); - OUTREG(R128_I2C_CNTL_1, restore->i2c_cntl_1); - OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl); - OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); - OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); - OUTREG(R128_BUS_CNTL, restore->bus_cntl); -} - -/* Write CRTC registers. */ -static void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128MMIO_VARS(); - - OUTREG(R128_CRTC_GEN_CNTL, restore->crtc_gen_cntl); - - OUTREGP(R128_CRTC_EXT_CNTL, restore->crtc_ext_cntl, - R128_CRTC_VSYNC_DIS | R128_CRTC_HSYNC_DIS | R128_CRTC_DISPLAY_DIS); - - OUTREGP(R128_DAC_CNTL, restore->dac_cntl, - R128_DAC_RANGE_CNTL | R128_DAC_BLANKING); - - OUTREG(R128_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); - OUTREG(R128_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); - OUTREG(R128_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); - OUTREG(R128_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); - OUTREG(R128_CRTC_OFFSET, restore->crtc_offset); - OUTREG(R128_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); - OUTREG(R128_CRTC_PITCH, restore->crtc_pitch); -} - -/* Write flat panel registers */ -static void R128RestoreFPRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128MMIO_VARS(); - - OUTREG(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); - OUTREG(R128_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); - OUTREG(R128_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); - OUTREG(R128_FP_GEN_CNTL, restore->fp_gen_cntl); - OUTREG(R128_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); - OUTREG(R128_FP_HORZ_STRETCH, restore->fp_horz_stretch); - OUTREG(R128_FP_PANEL_CNTL, restore->fp_panel_cntl); - OUTREG(R128_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); - OUTREG(R128_FP_VERT_STRETCH, restore->fp_vert_stretch); - OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); - OUTREG(R128_TMDS_CRC, restore->tmds_crc); -} - -static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) -{ - while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); -} - -static void R128PLLWriteUpdate(ScrnInfoPtr pScrn) -{ - R128MMIO_VARS(); - - OUTPLLP(pScrn, R128_PPLL_REF_DIV, R128_PPLL_ATOMIC_UPDATE_W, 0xffff); -} - -/* Write PLL registers. */ -static void R128RestorePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128MMIO_VARS(); - - OUTREGP(R128_CLOCK_CNTL_INDEX, R128_PLL_DIV_SEL, 0xffff); - - OUTPLLP(pScrn, - R128_PPLL_CNTL, - R128_PPLL_RESET - | R128_PPLL_ATOMIC_UPDATE_EN - | R128_PPLL_VGA_ATOMIC_UPDATE_EN, - 0xffff); - - R128PLLWaitForReadUpdateComplete(pScrn); - OUTPLLP(pScrn, R128_PPLL_REF_DIV, - restore->ppll_ref_div, ~R128_PPLL_REF_DIV_MASK); - R128PLLWriteUpdate(pScrn); - - R128PLLWaitForReadUpdateComplete(pScrn); - OUTPLLP(pScrn, R128_PPLL_DIV_3, - restore->ppll_div_3, ~R128_PPLL_FB3_DIV_MASK); - R128PLLWriteUpdate(pScrn); - OUTPLLP(pScrn, R128_PPLL_DIV_3, - restore->ppll_div_3, ~R128_PPLL_POST3_DIV_MASK); - R128PLLWriteUpdate(pScrn); - - R128PLLWaitForReadUpdateComplete(pScrn); - OUTPLL(R128_HTOTAL_CNTL, restore->htotal_cntl); - R128PLLWriteUpdate(pScrn); - - OUTPLLP(pScrn, R128_PPLL_CNTL, 0, ~R128_PPLL_RESET); - - R128TRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", - restore->ppll_ref_div, - restore->ppll_div_3, - restore->htotal_cntl, - INPLL(pScrn, R128_PPLL_CNTL))); - R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", - restore->ppll_ref_div & R128_PPLL_REF_DIV_MASK, - restore->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, - (restore->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); -} - -/* Write DDA registers. */ -static void R128RestoreDDARegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128MMIO_VARS(); - - OUTREG(R128_DDA_CONFIG, restore->dda_config); - OUTREG(R128_DDA_ON_OFF, restore->dda_on_off); -} - -/* Write palette data. */ -static void R128RestorePalette(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - int i; - R128MMIO_VARS(); - - if (!restore->palette_valid) return; - - /* Select palette 0 (main CRTC) if using FP-enabled chip */ - if (info->HasPanelRegs) PAL_SELECT(0); - - OUTPAL_START(0); - for (i = 0; i < 256; i++) OUTPAL_NEXT_CARD32(restore->palette[i]); -} - -/* Write out state to define a new video mode. */ -static void R128RestoreMode(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128TRACE(("R128RestoreMode(%p)\n", restore)); - R128RestoreCommonRegisters(pScrn, restore); - R128RestoreCrtcRegisters(pScrn, restore); - if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP) - R128RestoreFPRegisters(pScrn, restore); - R128RestorePLLRegisters(pScrn, restore); - R128RestoreDDARegisters(pScrn, restore); - R128RestorePalette(pScrn, restore); -} - -/* Read common registers. */ -static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128MMIO_VARS(); - - save->ovr_clr = INREG(R128_OVR_CLR); - save->ovr_wid_left_right = INREG(R128_OVR_WID_LEFT_RIGHT); - save->ovr_wid_top_bottom = INREG(R128_OVR_WID_TOP_BOTTOM); - save->ov0_scale_cntl = INREG(R128_OV0_SCALE_CNTL); - save->mpp_tb_config = INREG(R128_MPP_TB_CONFIG); - save->mpp_gp_config = INREG(R128_MPP_GP_CONFIG); - save->subpic_cntl = INREG(R128_SUBPIC_CNTL); - save->viph_control = INREG(R128_VIPH_CONTROL); - save->i2c_cntl_1 = INREG(R128_I2C_CNTL_1); - save->gen_int_cntl = INREG(R128_GEN_INT_CNTL); - save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL); - save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL); - save->bus_cntl = INREG(R128_BUS_CNTL); -} - -/* Read CRTC registers. */ -static void R128SaveCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128MMIO_VARS(); - - save->crtc_gen_cntl = INREG(R128_CRTC_GEN_CNTL); - save->crtc_ext_cntl = INREG(R128_CRTC_EXT_CNTL); - save->dac_cntl = INREG(R128_DAC_CNTL); - save->crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP); - save->crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID); - save->crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP); - save->crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID); - save->crtc_offset = INREG(R128_CRTC_OFFSET); - save->crtc_offset_cntl = INREG(R128_CRTC_OFFSET_CNTL); - save->crtc_pitch = INREG(R128_CRTC_PITCH); -} - -/* Read flat panel registers */ -static void R128SaveFPRegisters(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128MMIO_VARS(); - - save->crtc2_gen_cntl = INREG(R128_CRTC2_GEN_CNTL); - save->fp_crtc_h_total_disp = INREG(R128_FP_CRTC_H_TOTAL_DISP); - save->fp_crtc_v_total_disp = INREG(R128_FP_CRTC_V_TOTAL_DISP); - save->fp_gen_cntl = INREG(R128_FP_GEN_CNTL); - save->fp_h_sync_strt_wid = INREG(R128_FP_H_SYNC_STRT_WID); - save->fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); - save->fp_panel_cntl = INREG(R128_FP_PANEL_CNTL); - save->fp_v_sync_strt_wid = INREG(R128_FP_V_SYNC_STRT_WID); - save->fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); - save->lvds_gen_cntl = INREG(R128_LVDS_GEN_CNTL); - save->tmds_crc = INREG(R128_TMDS_CRC); -} - -/* Read PLL registers. */ -static void R128SavePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save) -{ - save->ppll_ref_div = INPLL(pScrn, R128_PPLL_REF_DIV); - save->ppll_div_3 = INPLL(pScrn, R128_PPLL_DIV_3); - save->htotal_cntl = INPLL(pScrn, R128_HTOTAL_CNTL); - - R128TRACE(("Read: 0x%08x 0x%08x 0x%08x\n", - save->ppll_ref_div, - save->ppll_div_3, - save->htotal_cntl)); - R128TRACE(("Read: rd=%d, fd=%d, pd=%d\n", - save->ppll_ref_div & R128_PPLL_REF_DIV_MASK, - save->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, - (save->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); -} - -/* Read DDA registers. */ -static void R128SaveDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128MMIO_VARS(); - - save->dda_config = INREG(R128_DDA_CONFIG); - save->dda_on_off = INREG(R128_DDA_ON_OFF); -} - -/* Read palette data. */ -static void R128SavePalette(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128InfoPtr info = R128PTR(pScrn); - int i; - R128MMIO_VARS(); - - /* Select palette 0 (main CRTC) if using FP-enabled chip */ - if (info->HasPanelRegs) PAL_SELECT(0); - - INPAL_START(0); - for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT(); - save->palette_valid = TRUE; -} - -/* Save state that defines current video mode. */ -static void R128SaveMode(ScrnInfoPtr pScrn, R128SavePtr save) -{ - R128TRACE(("R128SaveMode(%p)\n", save)); - - R128SaveCommonRegisters(pScrn, save); - R128SaveCrtcRegisters(pScrn, save); - if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP) - R128SaveFPRegisters(pScrn, save); - R128SavePLLRegisters(pScrn, save); - R128SaveDDARegisters(pScrn, save); - R128SavePalette(pScrn, save); - - R128TRACE(("R128SaveMode returns %p\n", save)); -} - -/* Save everything needed to restore the original VC state. */ -static void R128Save(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - R128SavePtr save = &info->SavedReg; - vgaHWPtr hwp = VGAHWPTR(pScrn); - R128MMIO_VARS(); - - R128TRACE(("R128Save\n")); - if (info->FBDev) { - fbdevHWSave(pScrn); - return; - } - vgaHWUnlock(hwp); - vgaHWSave(pScrn, &hwp->SavedReg, VGA_SR_ALL); /* save mode, fonts, cmap */ - vgaHWLock(hwp); - - R128SaveMode(pScrn, save); - - save->dp_datatype = INREG(R128_DP_DATATYPE); - save->gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); - save->clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); - save->amcgpio_en_reg = INREG(R128_AMCGPIO_EN_REG); - save->amcgpio_mask = INREG(R128_AMCGPIO_MASK); -} - -/* Restore the original (text) mode. */ -static void R128Restore(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - R128SavePtr restore = &info->SavedReg; - vgaHWPtr hwp = VGAHWPTR(pScrn); - R128MMIO_VARS(); - - R128TRACE(("R128Restore\n")); - if (info->FBDev) { - fbdevHWRestore(pScrn); - return; - } - - R128Blank(pScrn); - OUTREG(R128_AMCGPIO_MASK, restore->amcgpio_mask); - OUTREG(R128_AMCGPIO_EN_REG, restore->amcgpio_en_reg); - OUTREG(R128_CLOCK_CNTL_INDEX, restore->clock_cntl_index); - OUTREG(R128_GEN_RESET_CNTL, restore->gen_reset_cntl); - OUTREG(R128_DP_DATATYPE, restore->dp_datatype); - - R128RestoreMode(pScrn, restore); - vgaHWUnlock(hwp); - vgaHWRestore(pScrn, &hwp->SavedReg, VGA_SR_MODE | VGA_SR_FONTS ); - vgaHWLock(hwp); - - R128WaitForVerticalSync(pScrn); - R128Unblank(pScrn); -} - -/* Define common registers for requested video mode. */ -static void R128InitCommonRegisters(R128SavePtr save, DisplayModePtr mode, - R128InfoPtr info) -{ - save->ovr_clr = 0; - save->ovr_wid_left_right = 0; - save->ovr_wid_top_bottom = 0; - save->ov0_scale_cntl = 0; - save->mpp_tb_config = 0; - save->mpp_gp_config = 0; - save->subpic_cntl = 0; - save->viph_control = 0; - save->i2c_cntl_1 = 0; - save->gen_int_cntl = 0; - save->cap0_trig_cntl = 0; - save->cap1_trig_cntl = 0; - save->bus_cntl = info->BusCntl; - /* - * If bursts are enabled, turn on discards and aborts - */ - if (save->bus_cntl & (R128_BUS_WRT_BURST|R128_BUS_READ_BURST)) - save->bus_cntl |= R128_BUS_RD_DISCARD_EN | R128_BUS_RD_ABORT_EN; -} - -/* Define CRTC registers for requested video mode. */ -static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save, - DisplayModePtr mode, R128InfoPtr info) -{ - int format; - int hsync_start; - int hsync_wid; - int hsync_fudge; - int vsync_wid; - int bytpp; - - switch (info->CurrentLayout.pixel_code) { - case 4: format = 1; bytpp = 0; hsync_fudge = 0; break; - case 8: format = 2; bytpp = 1; hsync_fudge = 18; break; - case 15: format = 3; bytpp = 2; hsync_fudge = 9; break; /* 555 */ - case 16: format = 4; bytpp = 2; hsync_fudge = 9; break; /* 565 */ - case 24: format = 5; bytpp = 3; hsync_fudge = 6; break; /* RGB */ - case 32: format = 6; bytpp = 4; hsync_fudge = 5; break; /* xRGB */ - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); - return FALSE; - } - R128TRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp)); - - - save->crtc_gen_cntl = (R128_CRTC_EXT_DISP_EN - | R128_CRTC_EN - | (format << 8) - | ((mode->Flags & V_DBLSCAN) - ? R128_CRTC_DBL_SCAN_EN - : 0) - | ((mode->Flags & V_INTERLACE) - ? R128_CRTC_INTERLACE_EN - : 0)); - - save->crtc_ext_cntl = R128_VGA_ATI_LINEAR | R128_XCRT_CNT_EN; - save->dac_cntl = (R128_DAC_MASK_ALL - | R128_DAC_VGA_ADR_EN - | (info->dac6bits ? 0 : R128_DAC_8BIT_EN)); - - save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) - | (((mode->CrtcHDisplay / 8) - 1) << 16)); - - hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; - if (!hsync_wid) hsync_wid = 1; - if (hsync_wid > 0x3f) hsync_wid = 0x3f; - - hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; - - save->crtc_h_sync_strt_wid = ((hsync_start & 0xfff) - | (hsync_wid << 16) - | ((mode->Flags & V_NHSYNC) - ? R128_CRTC_H_SYNC_POL - : 0)); - -#if 1 - /* This works for double scan mode. */ - save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - 1) << 16)); -#else - /* This is what cce/nbmode.c example code - does -- is this correct? */ - save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) - << 16)); -#endif - - vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; - if (!vsync_wid) vsync_wid = 1; - if (vsync_wid > 0x1f) vsync_wid = 0x1f; - - save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) - | (vsync_wid << 16) - | ((mode->Flags & V_NVSYNC) - ? R128_CRTC_V_SYNC_POL - : 0)); - save->crtc_offset = 0; - save->crtc_offset_cntl = 0; - save->crtc_pitch = info->CurrentLayout.displayWidth / 8; - - R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", - save->crtc_pitch, pScrn->virtualX, info->CurrentLayout.displayWidth)); - return TRUE; -} - -/* Define CRTC registers for requested video mode. */ -static void R128InitFPRegisters(ScrnInfoPtr pScrn, R128SavePtr orig, - R128SavePtr save, DisplayModePtr mode, - R128InfoPtr info) -{ - int xres = mode->CrtcHDisplay; - int yres = mode->CrtcVDisplay; - float Hratio, Vratio; - int disp_end; - - if (info->CRTOnly) { - save->crtc_ext_cntl |= R128_CRTC_CRT_ON; - save->crtc2_gen_cntl = 0; - save->fp_gen_cntl = orig->fp_gen_cntl; - save->fp_gen_cntl &= ~(R128_FP_FPON | - R128_FP_CRTC_USE_SHADOW_VEND | - R128_FP_CRTC_HORZ_DIV2_EN | - R128_FP_CRTC_HOR_CRT_DIV2_DIS | - R128_FP_USE_SHADOW_EN); - save->fp_gen_cntl |= (R128_FP_SEL_CRTC2 | - R128_FP_CRTC_DONT_SHADOW_VPAR); - save->fp_panel_cntl = orig->fp_panel_cntl & ~R128_FP_DIGON; - save->lvds_gen_cntl = orig->lvds_gen_cntl & ~R128_LVDS_ON; - return; - } - - if (xres > info->PanelXRes) xres = info->PanelXRes; - if (yres > info->PanelYRes) yres = info->PanelYRes; - - Hratio = (float)xres/(float)info->PanelXRes; - Vratio = (float)yres/(float)info->PanelYRes; - - save->fp_horz_stretch = - (((((int)(Hratio * R128_HORZ_STRETCH_RATIO_MAX)) - & R128_HORZ_STRETCH_RATIO_MASK) << R128_HORZ_STRETCH_RATIO_SHIFT) | - (orig->fp_horz_stretch & (R128_HORZ_PANEL_SIZE | - R128_HORZ_FP_LOOP_STRETCH | - R128_HORZ_STRETCH_RESERVED))); - if (Hratio != 1.0) save->fp_horz_stretch |= (R128_HORZ_STRETCH_BLEND | - R128_HORZ_STRETCH_ENABLE); - - save->fp_vert_stretch = - (((((int)(Vratio * R128_VERT_STRETCH_RATIO_MAX)) - & R128_VERT_STRETCH_RATIO_MASK) << R128_VERT_STRETCH_RATIO_SHIFT) | - (orig->fp_vert_stretch & (R128_VERT_PANEL_SIZE | - R128_VERT_STRETCH_RESERVED | - R128_VERT_STRETCH_BLEND))); - if (Vratio == 1.0) save->fp_vert_stretch &= ~R128_VERT_STRETCH_ENABLE; - else save->fp_vert_stretch |= R128_VERT_STRETCH_ENABLE; - - save->fp_gen_cntl = ((orig->fp_gen_cntl & ~(R128_FP_SEL_CRTC2 | - R128_FP_CRTC_USE_SHADOW_VEND | - R128_FP_CRTC_HORZ_DIV2_EN | - R128_FP_CRTC_HOR_CRT_DIV2_DIS | - R128_FP_USE_SHADOW_EN)) | - R128_FP_CRTC_DONT_SHADOW_VPAR | - R128_FP_TDMS_EN); - save->fp_panel_cntl = orig->fp_panel_cntl; - save->fp_crtc_h_total_disp = orig->fp_crtc_h_total_disp; - save->fp_crtc_v_total_disp = orig->fp_crtc_v_total_disp; - save->fp_h_sync_strt_wid = orig->fp_h_sync_strt_wid; - save->fp_v_sync_strt_wid = orig->fp_v_sync_strt_wid; - save->lvds_gen_cntl = orig->lvds_gen_cntl; - - save->tmds_crc = orig->tmds_crc; - - /* Disable CRT output by disabling CRT output and setting the CRT - DAC to use CRTC2, which we set to 0's. In the future, we will - want to use the dual CRTC capabilities of the R128 to allow both - the flat panel and external CRT to either simultaneously display - the same image or display two different images. */ - save->crtc_ext_cntl &= ~R128_CRTC_CRT_ON; - save->dac_cntl |= R128_DAC_CRT_SEL_CRTC2; - save->crtc2_gen_cntl = 0; - - save->fp_panel_cntl |= (R128_FP_DIGON | R128_FP_BLON); - save->fp_gen_cntl |= (R128_FP_FPON); - - save->crtc_gen_cntl &= ~(R128_CRTC_DBL_SCAN_EN | - R128_CRTC_INTERLACE_EN | - R128_CRTC_CSYNC_EN | - R128_CRTC_CUR_EN | - R128_CRTC_CUR_MODE_MASK | - R128_CRTC_ICON_EN | - R128_CRTC_EXT_DISP_EN | - R128_CRTC_EN | - R128_CRTC_DISP_REQ_EN_B); - save->crtc_gen_cntl |= R128_CRTC_EXT_DISP_EN | R128_CRTC_EN; - - disp_end = xres/8 - 1; - save->crtc_h_total_disp = ((disp_end << R128_CRTC_H_DISP_SHIFT) | - (disp_end + info->PanelHNonVis)); - - save->crtc_h_sync_strt_wid &= ~(R128_CRTC_H_SYNC_STRT_PIX | - R128_CRTC_H_SYNC_STRT_CHAR | - R128_CRTC_H_SYNC_WID); - save->crtc_h_sync_strt_wid |= - (disp_end + info->PanelHOverPlus) << R128_CRTC_H_SYNC_STRT_CHAR_SHIFT; - switch (info->CurrentLayout.pixel_code) { - /* Adjustments are from ATI */ - case 8: save->crtc_h_sync_strt_wid |= 2; break; - case 15: - case 16: save->crtc_h_sync_strt_wid |= 1; break; - case 24: save->crtc_h_sync_strt_wid |= 6; break; - case 32: save->crtc_h_sync_strt_wid |= 5; break; - } - save->crtc_h_sync_strt_wid |= - info->PanelHSyncWidth << R128_CRTC_H_SYNC_WID_SHIFT; - save->crtc_h_sync_strt_wid |= R128_CRTC_H_SYNC_POL; - - disp_end = yres - 1; - save->crtc_v_total_disp = ((disp_end << R128_CRTC_V_DISP_SHIFT) | - (disp_end + info->PanelVNonVis)); - - save->crtc_v_sync_strt_wid &= ~(R128_CRTC_V_SYNC_STRT | - R128_CRTC_V_SYNC_WID); - save->crtc_v_sync_strt_wid |= (disp_end + info->PanelVOverPlus); - save->crtc_v_sync_strt_wid |= - info->PanelVSyncWidth << R128_CRTC_V_SYNC_WID_SHIFT; - save->crtc_v_sync_strt_wid |= R128_CRTC_V_SYNC_POL; -} - -/* Define PLL registers for requested video mode. */ -static void R128InitPLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save, - DisplayModePtr mode, R128PLLPtr pll, - double dot_clock) -{ - int freq = dot_clock * 100; - struct { - int divider; - int bitvalue; - } *post_div, - post_divs[] = { - /* From RAGE 128 VR/RAGE 128 GL Register - Reference Manual (Technical Reference - Manual P/N RRG-G04100-C Rev. 0.04), page - 3-17 (PLL_DIV_[3:0]). */ - { 1, 0 }, /* VCLK_SRC */ - { 2, 1 }, /* VCLK_SRC/2 */ - { 4, 2 }, /* VCLK_SRC/4 */ - { 8, 3 }, /* VCLK_SRC/8 */ - - { 3, 4 }, /* VCLK_SRC/3 */ - /* bitvalue = 5 is reserved */ - { 6, 6 }, /* VCLK_SRC/6 */ - { 12, 7 }, /* VCLK_SRC/12 */ - { 0, 0 } - }; - - if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; - if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; - - for (post_div = &post_divs[0]; post_div->divider; ++post_div) { - save->pll_output_freq = post_div->divider * freq; - if (save->pll_output_freq >= pll->min_pll_freq - && save->pll_output_freq <= pll->max_pll_freq) break; - } - - save->dot_clock_freq = freq; - save->feedback_div = R128Div(pll->reference_div * save->pll_output_freq, - pll->reference_freq); - save->post_div = post_div->divider; - - R128TRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", - save->dot_clock_freq, - save->pll_output_freq, - save->feedback_div, - save->post_div)); - - save->ppll_ref_div = pll->reference_div; - save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); - save->htotal_cntl = 0; -} - -/* Define DDA registers for requested video mode. */ -static Bool R128InitDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save, - DisplayModePtr mode, R128PLLPtr pll, - R128InfoPtr info) -{ - int DisplayFifoWidth = 128; - int DisplayFifoDepth = 32; - int XclkFreq; - int VclkFreq; - int XclksPerTransfer; - int XclksPerTransferPrecise; - int UseablePrecision; - int Roff; - int Ron; - - XclkFreq = pll->xclk; - - VclkFreq = R128Div(pll->reference_freq * save->feedback_div, - pll->reference_div * save->post_div); - - XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth, - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - UseablePrecision = R128MinBits(XclksPerTransfer) + 1; - - XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth) - << (11 - UseablePrecision), - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); - - Ron = (4 * info->ram->MB - + 3 * MAX(info->ram->Trcd - 2, 0) - + 2 * info->ram->Trp - + info->ram->Twr - + info->ram->CL - + info->ram->Tr2w - + XclksPerTransfer) << (11 - UseablePrecision); - - if (Ron + info->ram->Rloop >= Roff) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", - Ron, info->ram->Rloop, Roff); - return FALSE; - } - - save->dda_config = (XclksPerTransferPrecise - | (UseablePrecision << 16) - | (info->ram->Rloop << 20)); - - save->dda_on_off = (Ron << 16) | Roff; - - R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", - XclkFreq, - VclkFreq, - XclksPerTransfer, - XclksPerTransferPrecise, - UseablePrecision)); - R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n", - Roff, Ron, info->ram->Rloop)); - - return TRUE; -} - - -/* Define initial palette for requested video mode. This doesn't do - anything for XFree86 4.0. */ -static void R128InitPalette(R128SavePtr save, R128InfoPtr info) -{ - save->palette_valid = FALSE; -} - -/* Define registers for a requested video mode. */ -static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save) -{ - R128InfoPtr info = R128PTR(pScrn); - double dot_clock = mode->Clock/1000.0; - -#if R128_DEBUG - ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", - mode->name, - dot_clock, - - mode->HDisplay, - mode->HSyncStart, - mode->HSyncEnd, - mode->HTotal, - - mode->VDisplay, - mode->VSyncStart, - mode->VSyncEnd, - mode->VTotal, - pScrn->depth, - pScrn->bitsPerPixel); - if (mode->Flags & V_DBLSCAN) ErrorF(" D"); - if (mode->Flags & V_INTERLACE) ErrorF(" I"); - if (mode->Flags & V_PHSYNC) ErrorF(" +H"); - if (mode->Flags & V_NHSYNC) ErrorF(" -H"); - if (mode->Flags & V_PVSYNC) ErrorF(" +V"); - if (mode->Flags & V_NVSYNC) ErrorF(" -V"); - ErrorF("\n"); - ErrorF("%-12.12s %7.2f %4d %4d %4d %4d %4d %4d %4d %4d (%d,%d)", - mode->name, - dot_clock, - - mode->CrtcHDisplay, - mode->CrtcHSyncStart, - mode->CrtcHSyncEnd, - mode->CrtcHTotal, - - mode->CrtcVDisplay, - mode->CrtcVSyncStart, - mode->CrtcVSyncEnd, - mode->CrtcVTotal, - pScrn->depth, - pScrn->bitsPerPixel); - if (mode->Flags & V_DBLSCAN) ErrorF(" D"); - if (mode->Flags & V_INTERLACE) ErrorF(" I"); - if (mode->Flags & V_PHSYNC) ErrorF(" +H"); - if (mode->Flags & V_NHSYNC) ErrorF(" -H"); - if (mode->Flags & V_PVSYNC) ErrorF(" +V"); - if (mode->Flags & V_NVSYNC) ErrorF(" -V"); - ErrorF("\n"); -#endif - - info->Flags = mode->Flags; - - R128InitCommonRegisters(save, mode, info); - if (!R128InitCrtcRegisters(pScrn, save, mode, info)) return FALSE; - if (info->HasPanelRegs && info->EnableFP) - R128InitFPRegisters(pScrn, &info->SavedReg, save, mode, info); - R128InitPLLRegisters(pScrn, save, mode, &info->pll, dot_clock); - if (!R128InitDDARegisters(pScrn, save, mode, &info->pll, info)) - return FALSE; - if (!info->PaletteSavedOnVT) R128InitPalette(save, info); - - R128TRACE(("R128Init returns %p\n", save)); - return TRUE; -} - -/* Initialize a new mode. */ -static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - R128InfoPtr info = R128PTR(pScrn); - - if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE; - /* FIXME? DRILock/DRIUnlock here? */ - R128Blank(pScrn); - R128RestoreMode(pScrn, &info->ModeReg); - R128Unblank(pScrn); - - info->CurrentLayout.mode = mode; - - return TRUE; -} - -static Bool R128SaveScreen(ScreenPtr pScreen, int mode) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - Bool unblank; - - unblank = xf86IsUnblank(mode); - - if (unblank) R128Unblank(pScrn); else R128Blank(pScrn); - return TRUE; -} - -Bool R128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) -{ - return R128ModeInit(xf86Screens[scrnIndex], mode); -} - -/* Used to disallow modes that are not supported by the hardware. */ -static int R128ValidMode(int scrnIndex, DisplayModePtr mode, - Bool verbose, int flag) -{ - return MODE_OK; -} - -/* Adjust viewport into virtual desktop such that (0,0) in viewport space - is (x,y) in virtual space. */ -void R128AdjustFrame(int scrnIndex, int x, int y, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - int Base; - R128MMIO_VARS(); - - Base = y * info->CurrentLayout.displayWidth + x; - - switch (info->CurrentLayout.pixel_code) { - case 15: - case 16: Base *= 2; break; - case 24: Base *= 3; break; - case 32: Base *= 4; break; - } - - Base &= ~7; /* 3 lower bits are always 0 */ - - if (info->CurrentLayout.pixel_code == 24) - Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */ - - OUTREG(R128_CRTC_OFFSET, Base); -} - -/* Called when VT switching back to the X server. Reinitialize the video - mode. */ -static Bool R128EnterVT(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - - R128TRACE(("R128EnterVT\n")); -#ifdef XF86DRI - if (R128PTR(pScrn)->directRenderingEnabled) { - R128CCEStart(pScrn); - DRIUnlock(pScrn->pScreen); - } -#endif - if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; - info->PaletteSavedOnVT = FALSE; - R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); - - return TRUE; -} - -/* Called when VT switching away from the X server. Restore the original - text mode. */ -static void R128LeaveVT(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - R128SavePtr save = &info->ModeReg; - - R128TRACE(("R128LeaveVT\n")); -#ifdef XF86DRI - if (R128PTR(pScrn)->directRenderingEnabled) { - DRILock(pScrn->pScreen, 0); - R128CCEStop(pScrn); - } -#endif - R128SavePalette(pScrn, save); - info->PaletteSavedOnVT = TRUE; - R128Restore(pScrn); -} - -static Bool -R128EnterVTFBDev(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - R128SavePtr restore = &info->SavedReg; - fbdevHWEnterVT(scrnIndex,flags); - R128RestorePalette(pScrn,restore); - R128EngineInit(pScrn); - return TRUE; -} - -static void R128LeaveVTFBDev(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - R128SavePtr save = &info->SavedReg; - R128SavePalette(pScrn,save); - fbdevHWLeaveVT(scrnIndex,flags); -} - -/* Called at the end of each server generation. Restore the original text - mode, unmap video memory, and unwrap and call the saved CloseScreen - function. */ -static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - R128InfoPtr info = R128PTR(pScrn); - - R128TRACE(("R128CloseScreen\n")); - -#ifdef XF86DRI - /* Disable direct rendering */ - if (info->directRenderingEnabled) { - R128DRICloseScreen(pScreen); - info->directRenderingEnabled = FALSE; - } -#endif - - if (pScrn->vtSema) { - R128Restore(pScrn); - R128UnmapMem(pScrn); - } - - if (info->accel) XAADestroyInfoRec(info->accel); - info->accel = NULL; - - if (info->scratch_buffer[0]) xfree(info->scratch_buffer[0]); - info->scratch_buffer[0] = NULL; - - if (info->cursor) xf86DestroyCursorInfoRec(info->cursor); - info->cursor = NULL; - - if (info->DGAModes) xfree(info->DGAModes); - info->DGAModes = NULL; - - pScrn->vtSema = FALSE; - - pScreen->CloseScreen = info->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); -} - -static void R128FreeScreen(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - - R128TRACE(("R128FreeScreen\n")); - if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) - vgaHWFreeHWRec(pScrn); - R128FreeRec(pScrn); -} - -#ifdef DPMSExtension -/* Sets VESA Display Power Management Signaling (DPMS) Mode. */ -static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn, - int PowerManagementMode, int flags) -{ - int mask = (R128_CRTC_DISPLAY_DIS - | R128_CRTC_HSYNC_DIS - | R128_CRTC_VSYNC_DIS); - R128MMIO_VARS(); - - switch (PowerManagementMode) { - case DPMSModeOn: - /* Screen: On; HSync: On, VSync: On */ - OUTREGP(R128_CRTC_EXT_CNTL, 0, ~mask); - break; - case DPMSModeStandby: - /* Screen: Off; HSync: Off, VSync: On */ - OUTREGP(R128_CRTC_EXT_CNTL, - R128_CRTC_DISPLAY_DIS | R128_CRTC_HSYNC_DIS, ~mask); - break; - case DPMSModeSuspend: - /* Screen: Off; HSync: On, VSync: Off */ - OUTREGP(R128_CRTC_EXT_CNTL, - R128_CRTC_DISPLAY_DIS | R128_CRTC_VSYNC_DIS, ~mask); - break; - case DPMSModeOff: - /* Screen: Off; HSync: Off, VSync: Off */ - OUTREGP(R128_CRTC_EXT_CNTL, mask, ~mask); - break; - } -} -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h:1.11 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h:1.11 Fri Jun 30 21:40:46 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h Mon Dec 18 14:31:00 2000 @@ -1,1341 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.11 2000/07/01 01:40:46 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Rickard E. Faith <faith@precisioninsight.com> - * Kevin E. Martin <kevin@precisioninsight.com> - * - * References: - * - * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical - * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April - * 1999. - * - * RAGE 128 Software Development Manual (Technical Reference Manual P/N - * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999. - * - */ - -#ifndef _R128_REG_H_ -#define _R128_REG_H_ -#include <compiler.h> - - /* Memory mapped register access macros */ -#define INREG8(addr) MMIO_IN8(R128MMIO, addr) -#define INREG16(addr) MMIO_IN16(R128MMIO, addr) -#define INREG(addr) MMIO_IN32(R128MMIO, addr) -#define OUTREG8(addr, val) MMIO_OUT8(R128MMIO, addr, val) -#define OUTREG16(addr, val) MMIO_OUT16(R128MMIO, addr, val) -#define OUTREG(addr, val) MMIO_OUT32(R128MMIO, addr, val) - -#define ADDRREG(addr) ((volatile CARD32 *)(R128MMIO + (addr))) - -#define R128MMIO_VARS() \ - unsigned char *R128MMIO = R128PTR(pScrn)->MMIO - - -#define OUTREGP(addr, val, mask) \ - do { \ - CARD32 tmp = INREG(addr); \ - tmp &= (mask); \ - tmp |= (val); \ - OUTREG(addr, tmp); \ - } while (0) - -#define OUTPLL(addr, val) \ - do { \ - OUTREG8(R128_CLOCK_CNTL_INDEX, ((addr) & 0x1f) | R128_PLL_WR_EN); \ - OUTREG(R128_CLOCK_CNTL_DATA, val); \ - } while (0) - -#define OUTPLLP(pScrn, addr, val, mask) \ - do { \ - CARD32 tmp = INPLL(pScrn, addr); \ - tmp &= (mask); \ - tmp |= (val); \ - OUTPLL(addr, tmp); \ - } while (0) - -#define OUTPAL_START(idx) \ - do { \ - OUTREG8(R128_PALETTE_INDEX, (idx)); \ - } while (0) - -#define OUTPAL_NEXT(r, g, b) \ - do { \ - OUTREG(R128_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \ - } while (0) - -#define OUTPAL_NEXT_CARD32(v) \ - do { \ - OUTREG(R128_PALETTE_DATA, (v & 0x00ffffff)); \ - } while (0) - -#define OUTPAL(idx, r, g, b) \ - do { \ - OUTPAL_START((idx)); \ - OUTPAL_NEXT((r), (g), (b)); \ - } while (0) - -#define INPAL_START(idx) \ - do { \ - OUTREG(R128_PALETTE_INDEX, (idx) << 16); \ - } while (0) - -#define INPAL_NEXT() INREG(R128_PALETTE_DATA) - -#define PAL_SELECT(idx) \ - do { \ - if (idx) { \ - OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) | \ - R128_DAC_PALETTE_ACC_CTL); \ - } else { \ - OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) & \ - ~R128_DAC_PALETTE_ACC_CTL); \ - } \ - } while (0) - -#define R128_ADAPTER_ID 0x0f2c /* PCI */ -#define R128_AGP_APER_OFFSET 0x0178 -#define R128_AGP_BASE 0x0170 -#define R128_AGP_CNTL 0x0174 -# define R128_AGP_APER_SIZE_256MB (0x00 << 0) -# define R128_AGP_APER_SIZE_128MB (0x20 << 0) -# define R128_AGP_APER_SIZE_64MB (0x30 << 0) -# define R128_AGP_APER_SIZE_32MB (0x38 << 0) -# define R128_AGP_APER_SIZE_16MB (0x3c << 0) -# define R128_AGP_APER_SIZE_8MB (0x3e << 0) -# define R128_AGP_APER_SIZE_4MB (0x3f << 0) -# define R128_AGP_APER_SIZE_MASK (0x3f << 0) -#define R128_AGP_CNTL_B 0x0b44 -#define R128_AGP_COMMAND 0x0f58 /* PCI */ -#define R128_AGP_PLL_CNTL 0x0010 /* PLL */ -#define R128_AGP_STATUS 0x0f54 /* PCI */ -# define R128_AGP_1X_MODE 0x01 -# define R128_AGP_2X_MODE 0x02 -# define R128_AGP_4X_MODE 0x04 -# define R128_AGP_MODE_MASK 0x07 -#define R128_AMCGPIO_A_REG 0x01a0 -#define R128_AMCGPIO_EN_REG 0x01a8 -#define R128_AMCGPIO_MASK 0x0194 -#define R128_AMCGPIO_Y_REG 0x01a4 -#define R128_ATTRDR 0x03c1 /* VGA */ -#define R128_ATTRDW 0x03c0 /* VGA */ -#define R128_ATTRX 0x03c0 /* VGA */ -# define R128_AUX1_SC_EN (1 << 0) -# define R128_AUX1_SC_MODE_OR (0 << 1) -# define R128_AUX1_SC_MODE_NAND (1 << 1) -# define R128_AUX2_SC_EN (1 << 2) -# define R128_AUX2_SC_MODE_OR (0 << 3) -# define R128_AUX2_SC_MODE_NAND (1 << 3) -# define R128_AUX3_SC_EN (1 << 4) -# define R128_AUX3_SC_MODE_OR (0 << 5) -# define R128_AUX3_SC_MODE_NAND (1 << 5) -#define R128_AUX_SC_CNTL 0x1660 -#define R128_AUX1_SC_BOTTOM 0x1670 -#define R128_AUX1_SC_LEFT 0x1664 -#define R128_AUX1_SC_RIGHT 0x1668 -#define R128_AUX1_SC_TOP 0x166c -#define R128_AUX2_SC_BOTTOM 0x1680 -#define R128_AUX2_SC_LEFT 0x1674 -#define R128_AUX2_SC_RIGHT 0x1678 -#define R128_AUX2_SC_TOP 0x167c -#define R128_AUX3_SC_BOTTOM 0x1690 -#define R128_AUX3_SC_LEFT 0x1684 -#define R128_AUX3_SC_RIGHT 0x1688 -#define R128_AUX3_SC_TOP 0x168c -#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8 -#define R128_AUX_WINDOW_VERT_CNTL 0x02dc - -#define R128_BASE_CODE 0x0f0b -#define R128_BIOS_0_SCRATCH 0x0010 -#define R128_BIOS_1_SCRATCH 0x0014 -#define R128_BIOS_2_SCRATCH 0x0018 -#define R128_BIOS_3_SCRATCH 0x001c -#define R128_BIOS_ROM 0x0f30 /* PCI */ -#define R128_BIST 0x0f0f /* PCI */ -#define R128_BRUSH_DATA0 0x1480 -#define R128_BRUSH_DATA1 0x1484 -#define R128_BRUSH_DATA10 0x14a8 -#define R128_BRUSH_DATA11 0x14ac -#define R128_BRUSH_DATA12 0x14b0 -#define R128_BRUSH_DATA13 0x14b4 -#define R128_BRUSH_DATA14 0x14b8 -#define R128_BRUSH_DATA15 0x14bc -#define R128_BRUSH_DATA16 0x14c0 -#define R128_BRUSH_DATA17 0x14c4 -#define R128_BRUSH_DATA18 0x14c8 -#define R128_BRUSH_DATA19 0x14cc -#define R128_BRUSH_DATA2 0x1488 -#define R128_BRUSH_DATA20 0x14d0 -#define R128_BRUSH_DATA21 0x14d4 -#define R128_BRUSH_DATA22 0x14d8 -#define R128_BRUSH_DATA23 0x14dc -#define R128_BRUSH_DATA24 0x14e0 -#define R128_BRUSH_DATA25 0x14e4 -#define R128_BRUSH_DATA26 0x14e8 -#define R128_BRUSH_DATA27 0x14ec -#define R128_BRUSH_DATA28 0x14f0 -#define R128_BRUSH_DATA29 0x14f4 -#define R128_BRUSH_DATA3 0x148c -#define R128_BRUSH_DATA30 0x14f8 -#define R128_BRUSH_DATA31 0x14fc -#define R128_BRUSH_DATA32 0x1500 -#define R128_BRUSH_DATA33 0x1504 -#define R128_BRUSH_DATA34 0x1508 -#define R128_BRUSH_DATA35 0x150c -#define R128_BRUSH_DATA36 0x1510 -#define R128_BRUSH_DATA37 0x1514 -#define R128_BRUSH_DATA38 0x1518 -#define R128_BRUSH_DATA39 0x151c -#define R128_BRUSH_DATA4 0x1490 -#define R128_BRUSH_DATA40 0x1520 -#define R128_BRUSH_DATA41 0x1524 -#define R128_BRUSH_DATA42 0x1528 -#define R128_BRUSH_DATA43 0x152c -#define R128_BRUSH_DATA44 0x1530 -#define R128_BRUSH_DATA45 0x1534 -#define R128_BRUSH_DATA46 0x1538 -#define R128_BRUSH_DATA47 0x153c -#define R128_BRUSH_DATA48 0x1540 -#define R128_BRUSH_DATA49 0x1544 -#define R128_BRUSH_DATA5 0x1494 -#define R128_BRUSH_DATA50 0x1548 -#define R128_BRUSH_DATA51 0x154c -#define R128_BRUSH_DATA52 0x1550 -#define R128_BRUSH_DATA53 0x1554 -#define R128_BRUSH_DATA54 0x1558 -#define R128_BRUSH_DATA55 0x155c -#define R128_BRUSH_DATA56 0x1560 -#define R128_BRUSH_DATA57 0x1564 -#define R128_BRUSH_DATA58 0x1568 -#define R128_BRUSH_DATA59 0x156c -#define R128_BRUSH_DATA6 0x1498 -#define R128_BRUSH_DATA60 0x1570 -#define R128_BRUSH_DATA61 0x1574 -#define R128_BRUSH_DATA62 0x1578 -#define R128_BRUSH_DATA63 0x157c -#define R128_BRUSH_DATA7 0x149c -#define R128_BRUSH_DATA8 0x14a0 -#define R128_BRUSH_DATA9 0x14a4 -#define R128_BRUSH_SCALE 0x1470 -#define R128_BRUSH_Y_X 0x1474 -#define R128_BUS_CNTL 0x0030 -# define R128_BUS_MASTER_DIS (1 << 6) -# define R128_BUS_RD_DISCARD_EN (1 << 24) -# define R128_BUS_RD_ABORT_EN (1 << 25) -# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) -# define R128_BUS_WRT_BURST (1 << 29) -# define R128_BUS_READ_BURST (1 << 30) -#define R128_BUS_CNTL1 0x0034 -# define R128_BUS_WAIT_ON_LOCK_EN (1 << 4) - -#define R128_CACHE_CNTL 0x1724 -#define R128_CACHE_LINE 0x0f0c /* PCI */ -#define R128_CAP0_TRIG_CNTL 0x0950 /* ? */ -#define R128_CAP1_TRIG_CNTL 0x09c0 /* ? */ -#define R128_CAPABILITIES_ID 0x0f50 /* PCI */ -#define R128_CAPABILITIES_PTR 0x0f34 /* PCI */ -#define R128_CLK_PIN_CNTL 0x0001 /* PLL */ -#define R128_CLOCK_CNTL_DATA 0x000c -#define R128_CLOCK_CNTL_INDEX 0x0008 -# define R128_PLL_WR_EN (1 << 7) -# define R128_PLL_DIV_SEL (3 << 8) -#define R128_CLR_CMP_CLR_3D 0x1a24 -#define R128_CLR_CMP_CLR_DST 0x15c8 -#define R128_CLR_CMP_CLR_SRC 0x15c4 -#define R128_CLR_CMP_CNTL 0x15c0 -# define R128_SRC_CMP_NEQ_COLOR (5 << 0) -# define R128_CLR_CMP_SRC_SOURCE (1 << 24) -#define R128_CLR_CMP_MASK 0x15cc -# define R128_CLR_CMP_MSK 0xffffffff -#define R128_CLR_CMP_MASK_3D 0x1A28 -#define R128_COMMAND 0x0f04 /* PCI */ -#define R128_COMPOSITE_SHADOW_ID 0x1a0c -#define R128_CONFIG_APER_0_BASE 0x0100 -#define R128_CONFIG_APER_1_BASE 0x0104 -#define R128_CONFIG_APER_SIZE 0x0108 -#define R128_CONFIG_BONDS 0x00e8 -#define R128_CONFIG_CNTL 0x00e0 -#define R128_CONFIG_MEMSIZE 0x00f8 -#define R128_CONFIG_MEMSIZE_EMBEDDED 0x0114 -#define R128_CONFIG_REG_1_BASE 0x010c -#define R128_CONFIG_REG_APER_SIZE 0x0110 -#define R128_CONFIG_XSTRAP 0x00e4 -#define R128_CONSTANT_COLOR_C 0x1d34 -# define R128_CONSTANT_COLOR_MASK 0x00ffffff -# define R128_CONSTANT_COLOR_ONE 0x00ffffff -# define R128_CONSTANT_COLOR_ZERO 0x00000000 -#define R128_CRC_CMDFIFO_ADDR 0x0740 -#define R128_CRC_CMDFIFO_DOUT 0x0744 -#define R128_CRTC_CRNT_FRAME 0x0214 -#define R128_CRTC_DEBUG 0x021c -#define R128_CRTC_EXT_CNTL 0x0054 -# define R128_CRTC_VGA_XOVERSCAN (1 << 0) -# define R128_VGA_ATI_LINEAR (1 << 3) -# define R128_XCRT_CNT_EN (1 << 6) -# define R128_CRTC_HSYNC_DIS (1 << 8) -# define R128_CRTC_VSYNC_DIS (1 << 9) -# define R128_CRTC_DISPLAY_DIS (1 << 10) -# define R128_CRTC_CRT_ON (1 << 15) -#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 -# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0) -# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1) -# define R128_CRTC_DISPLAY_DIS_BYTE (1 << 2) -#define R128_CRTC_GEN_CNTL 0x0050 -# define R128_CRTC_DBL_SCAN_EN (1 << 0) -# define R128_CRTC_INTERLACE_EN (1 << 1) -# define R128_CRTC_CSYNC_EN (1 << 4) -# define R128_CRTC_CUR_EN (1 << 16) -# define R128_CRTC_CUR_MODE_MASK (7 << 17) -# define R128_CRTC_ICON_EN (1 << 20) -# define R128_CRTC_EXT_DISP_EN (1 << 24) -# define R128_CRTC_EN (1 << 25) -# define R128_CRTC_DISP_REQ_EN_B (1 << 26) -#define R128_CRTC_GUI_TRIG_VLINE 0x0218 -#define R128_CRTC_H_SYNC_STRT_WID 0x0204 -# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0) -# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) -# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 -# define R128_CRTC_H_SYNC_WID (0x3f << 16) -# define R128_CRTC_H_SYNC_WID_SHIFT 16 -# define R128_CRTC_H_SYNC_POL (1 << 23) -#define R128_CRTC_H_TOTAL_DISP 0x0200 -# define R128_CRTC_H_TOTAL (0x01ff << 0) -# define R128_CRTC_H_TOTAL_SHIFT 0 -# define R128_CRTC_H_DISP (0x00ff << 16) -# define R128_CRTC_H_DISP_SHIFT 16 -#define R128_CRTC_OFFSET 0x0224 -#define R128_CRTC_OFFSET_CNTL 0x0228 -#define R128_CRTC_PITCH 0x022c -#define R128_CRTC_STATUS 0x005c -# define R128_CRTC_VBLANK_SAVE (1 << 1) -#define R128_CRTC_V_SYNC_STRT_WID 0x020c -# define R128_CRTC_V_SYNC_STRT (0x7ff << 0) -# define R128_CRTC_V_SYNC_STRT_SHIFT 0 -# define R128_CRTC_V_SYNC_WID (0x1f << 16) -# define R128_CRTC_V_SYNC_WID_SHIFT 16 -# define R128_CRTC_V_SYNC_POL (1 << 23) -#define R128_CRTC_V_TOTAL_DISP 0x0208 -# define R128_CRTC_V_TOTAL (0x07ff << 0) -# define R128_CRTC_V_TOTAL_SHIFT 0 -# define R128_CRTC_V_DISP (0x07ff << 16) -# define R128_CRTC_V_DISP_SHIFT 16 -#define R128_CRTC_VLINE_CRNT_VLINE 0x0210 -# define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16) -#define R128_CRTC2_CRNT_FRAME 0x0314 -#define R128_CRTC2_DEBUG 0x031c -#define R128_CRTC2_GEN_CNTL 0x03f8 -#define R128_CRTC2_GUI_TRIG_VLINE 0x0318 -#define R128_CRTC2_H_SYNC_STRT_WID 0x0304 -#define R128_CRTC2_H_TOTAL_DISP 0x0300 -#define R128_CRTC2_OFFSET 0x0324 -#define R128_CRTC2_OFFSET_CNTL 0x0328 -#define R128_CRTC2_PITCH 0x032c -#define R128_CRTC2_STATUS 0x03fc -#define R128_CRTC2_V_SYNC_STRT_WID 0x030c -#define R128_CRTC2_V_TOTAL_DISP 0x0308 -#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310 -#define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ -#define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ -#define R128_CUR_CLR0 0x026c -#define R128_CUR_CLR1 0x0270 -#define R128_CUR_HORZ_VERT_OFF 0x0268 -#define R128_CUR_HORZ_VERT_POSN 0x0264 -#define R128_CUR_OFFSET 0x0260 -# define R128_CUR_LOCK (1 << 31) - -#define R128_DAC_CNTL 0x0058 -# define R128_DAC_RANGE_CNTL (3 << 0) -# define R128_DAC_BLANKING (1 << 2) -# define R128_DAC_CRT_SEL_CRTC2 (1 << 4) -# define R128_DAC_PALETTE_ACC_CTL (1 << 5) -# define R128_DAC_8BIT_EN (1 << 8) -# define R128_DAC_VGA_ADR_EN (1 << 13) -# define R128_DAC_MASK_ALL (0xff << 24) -#define R128_DAC_CRC_SIG 0x02cc -#define R128_DAC_DATA 0x03c9 /* VGA */ -#define R128_DAC_MASK 0x03c6 /* VGA */ -#define R128_DAC_R_INDEX 0x03c7 /* VGA */ -#define R128_DAC_W_INDEX 0x03c8 /* VGA */ -#define R128_DDA_CONFIG 0x02e0 -#define R128_DDA_ON_OFF 0x02e4 -#define R128_DEFAULT_OFFSET 0x16e0 -#define R128_DEFAULT_PITCH 0x16e4 -#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 -# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) -# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) -#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820 -#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 -#define R128_DEVICE_ID 0x0f02 /* PCI */ -#define R128_DP_BRUSH_BKGD_CLR 0x1478 -#define R128_DP_BRUSH_FRGD_CLR 0x147c -#define R128_DP_CNTL 0x16c0 -# define R128_DST_X_LEFT_TO_RIGHT (1 << 0) -# define R128_DST_Y_TOP_TO_BOTTOM (1 << 1) -#define R128_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0 -# define R128_DST_Y_MAJOR (1 << 2) -# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) -# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) -#define R128_DP_DATATYPE 0x16c4 -# define R128_HOST_BIG_ENDIAN_EN (1 << 29) -#define R128_DP_GUI_MASTER_CNTL 0x146c -# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) -# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) -# define R128_GMC_SRC_CLIPPING (1 << 2) -# define R128_GMC_DST_CLIPPING (1 << 3) -# define R128_GMC_BRUSH_DATATYPE_MASK (0x0f << 4) -# define R128_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4) -# define R128_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4) -# define R128_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4) -# define R128_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4) -# define R128_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4) -# define R128_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4) -# define R128_GMC_BRUSH_8x8_COLOR (10 << 4) -# define R128_GMC_BRUSH_1X8_COLOR (12 << 4) -# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) -# define R128_GMC_BRUSH_NONE (15 << 4) -# define R128_GMC_DST_8BPP_CI (2 << 8) -# define R128_GMC_DST_15BPP (3 << 8) -# define R128_GMC_DST_16BPP (4 << 8) -# define R128_GMC_DST_24BPP (5 << 8) -# define R128_GMC_DST_32BPP (6 << 8) -# define R128_GMC_DST_8BPP_RGB (7 << 8) -# define R128_GMC_DST_Y8 (8 << 8) -# define R128_GMC_DST_RGB8 (9 << 8) -# define R128_GMC_DST_VYUY (11 << 8) -# define R128_GMC_DST_YVYU (12 << 8) -# define R128_GMC_DST_AYUV444 (14 << 8) -# define R128_GMC_DST_ARGB4444 (15 << 8) -# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8) -# define R128_GMC_DST_DATATYPE_SHIFT 8 -# define R128_GMC_SRC_DATATYPE_MASK (3 << 12) -# define R128_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12) -# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) -# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) -# define R128_GMC_BYTE_PIX_ORDER (1 << 14) -# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14) -# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14) -# define R128_GMC_CONVERSION_TEMP (1 << 15) -# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15) -# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15) -# define R128_GMC_ROP3_MASK (0xff << 16) -# define R128_DP_SRC_SOURCE_MASK (7 << 24) -# define R128_DP_SRC_SOURCE_MEMORY (2 << 24) -# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24) -# define R128_GMC_3D_FCN_EN (1 << 27) -# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) -# define R128_GMC_AUX_CLIP_DIS (1 << 29) -# define R128_GMC_WR_MSK_DIS (1 << 30) -# define R128_GMC_LD_BRUSH_Y_X (1 << 31) -# define R128_ROP3_ZERO 0x00000000 -# define R128_ROP3_DSa 0x00880000 -# define R128_ROP3_SDna 0x00440000 -# define R128_ROP3_S 0x00cc0000 -# define R128_ROP3_DSna 0x00220000 -# define R128_ROP3_D 0x00aa0000 -# define R128_ROP3_DSx 0x00660000 -# define R128_ROP3_DSo 0x00ee0000 -# define R128_ROP3_DSon 0x00110000 -# define R128_ROP3_DSxn 0x00990000 -# define R128_ROP3_Dn 0x00550000 -# define R128_ROP3_SDno 0x00dd0000 -# define R128_ROP3_Sn 0x00330000 -# define R128_ROP3_DSno 0x00bb0000 -# define R128_ROP3_DSan 0x00770000 -# define R128_ROP3_ONE 0x00ff0000 -# define R128_ROP3_DPa 0x00a00000 -# define R128_ROP3_PDna 0x00500000 -# define R128_ROP3_P 0x00f00000 -# define R128_ROP3_DPna 0x000a0000 -# define R128_ROP3_D 0x00aa0000 -# define R128_ROP3_DPx 0x005a0000 -# define R128_ROP3_DPo 0x00fa0000 -# define R128_ROP3_DPon 0x00050000 -# define R128_ROP3_PDxn 0x00a50000 -# define R128_ROP3_PDno 0x00f50000 -# define R128_ROP3_Pn 0x000f0000 -# define R128_ROP3_DPno 0x00af0000 -# define R128_ROP3_DPan 0x005f0000 - - -#define R128_DP_GUI_MASTER_CNTL_C 0x1c84 -#define R128_DP_MIX 0x16c8 -#define R128_DP_SRC_BKGD_CLR 0x15dc -#define R128_DP_SRC_FRGD_CLR 0x15d8 -#define R128_DP_WRITE_MASK 0x16cc -#define R128_DST_BRES_DEC 0x1630 -#define R128_DST_BRES_ERR 0x1628 -#define R128_DST_BRES_INC 0x162c -#define R128_DST_BRES_LNTH 0x1634 -#define R128_DST_BRES_LNTH_SUB 0x1638 -#define R128_DST_HEIGHT 0x1410 -#define R128_DST_HEIGHT_WIDTH 0x143c -#define R128_DST_HEIGHT_WIDTH_8 0x158c -#define R128_DST_HEIGHT_WIDTH_BW 0x15b4 -#define R128_DST_HEIGHT_Y 0x15a0 -#define R128_DST_OFFSET 0x1404 -#define R128_DST_PITCH 0x1408 -#define R128_DST_PITCH_OFFSET 0x142c -#define R128_DST_PITCH_OFFSET_C 0x1c80 -# define R128_PITCH_SHIFT 21 -#define R128_DST_WIDTH 0x140c -#define R128_DST_WIDTH_HEIGHT 0x1598 -#define R128_DST_WIDTH_X 0x1588 -#define R128_DST_WIDTH_X_INCY 0x159c -#define R128_DST_X 0x141c -#define R128_DST_X_SUB 0x15a4 -#define R128_DST_X_Y 0x1594 -#define R128_DST_Y 0x1420 -#define R128_DST_Y_SUB 0x15a8 -#define R128_DST_Y_X 0x1438 - -#define R128_EXT_MEM_CNTL 0x0144 - -#define R128_FCP_CNTL 0x0012 /* PLL */ -#define R128_FLUSH_1 0x1704 -#define R128_FLUSH_2 0x1708 -#define R128_FLUSH_3 0x170c -#define R128_FLUSH_4 0x1710 -#define R128_FLUSH_5 0x1714 -#define R128_FLUSH_6 0x1718 -#define R128_FLUSH_7 0x171c -#define R128_FOG_3D_TABLE_START 0x1810 -#define R128_FOG_3D_TABLE_END 0x1814 -#define R128_FOG_3D_TABLE_DENSITY 0x181c -#define R128_FOG_TABLE_INDEX 0x1a14 -#define R128_FOG_TABLE_DATA 0x1a18 -#define R128_FP_CRTC_H_TOTAL_DISP 0x0250 -#define R128_FP_CRTC_V_TOTAL_DISP 0x0254 -#define R128_FP_GEN_CNTL 0x0284 -# define R128_FP_FPON (1 << 0) -# define R128_FP_TDMS_EN (1 << 2) -# define R128_FP_SEL_CRTC2 (1 << 13) -# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) -# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18) -# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20) -# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) -# define R128_FP_USE_SHADOW_EN (1 << 24) -#define R128_FP_H_SYNC_STRT_WID 0x02c4 -#define R128_FP_HORZ_STRETCH 0x028c -# define R128_HORZ_STRETCH_RATIO_MASK 0xffff -# define R128_HORZ_STRETCH_RATIO_SHIFT 0 -# define R128_HORZ_STRETCH_RATIO_MAX 4096 -# define R128_HORZ_PANEL_SIZE (0xff << 16) -# define R128_HORZ_PANEL_SHIFT 16 -# define R128_HORZ_STRETCH_PIXREP (0 << 25) -# define R128_HORZ_STRETCH_BLEND (1 << 25) -# define R128_HORZ_STRETCH_ENABLE (1 << 26) -# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27) -# define R128_HORZ_STRETCH_RESERVED 0xc0000000 - -#define R128_FP_PANEL_CNTL 0x0288 -# define R128_FP_DIGON (1 << 0) -# define R128_FP_BLON (1 << 1) -#define R128_FP_V_SYNC_STRT_WID 0x02c8 -#define R128_FP_VERT_STRETCH 0x0290 -# define R128_VERT_PANEL_SIZE (0x7ff << 0) -# define R128_VERT_PANEL_SHIFT 0 -# define R128_VERT_STRETCH_RATIO_MASK 0x3ff -# define R128_VERT_STRETCH_RATIO_SHIFT 11 -# define R128_VERT_STRETCH_RATIO_MAX 1024 -# define R128_VERT_STRETCH_ENABLE (1 << 24) -# define R128_VERT_STRETCH_LINEREP (0 << 25) -# define R128_VERT_STRETCH_BLEND (1 << 25) -# define R128_VERT_STRETCH_RESERVED 0xf8e00000 - -#define R128_GEN_INT_CNTL 0x0040 -#define R128_GEN_INT_STATUS 0x0044 -# define R128_VSYNC_INT_AK (1 << 2) -# define R128_VSYNC_INT (1 << 2) -#define R128_GEN_RESET_CNTL 0x00f0 -# define R128_SOFT_RESET_GUI (1 << 0) -# define R128_SOFT_RESET_VCLK (1 << 8) -# define R128_SOFT_RESET_PCLK (1 << 9) -# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11) -# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12) -#define R128_GENENB 0x03c3 /* VGA */ -#define R128_GENFC_RD 0x03ca /* VGA */ -#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */ -#define R128_GENMO_RD 0x03cc /* VGA */ -#define R128_GENMO_WT 0x03c2 /* VGA */ -#define R128_GENS0 0x03c2 /* VGA */ -#define R128_GENS1 0x03da /* VGA, 0x03ba */ -#define R128_GPIO_MONID 0x0068 -# define R128_GPIO_MONID_A_0 (1 << 0) -# define R128_GPIO_MONID_A_1 (1 << 1) -# define R128_GPIO_MONID_A_2 (1 << 2) -# define R128_GPIO_MONID_A_3 (1 << 3) -# define R128_GPIO_MONID_Y_0 (1 << 8) -# define R128_GPIO_MONID_Y_1 (1 << 9) -# define R128_GPIO_MONID_Y_2 (1 << 10) -# define R128_GPIO_MONID_Y_3 (1 << 11) -# define R128_GPIO_MONID_EN_0 (1 << 16) -# define R128_GPIO_MONID_EN_1 (1 << 17) -# define R128_GPIO_MONID_EN_2 (1 << 18) -# define R128_GPIO_MONID_EN_3 (1 << 19) -# define R128_GPIO_MONID_MASK_0 (1 << 24) -# define R128_GPIO_MONID_MASK_1 (1 << 25) -# define R128_GPIO_MONID_MASK_2 (1 << 26) -# define R128_GPIO_MONID_MASK_3 (1 << 27) -#define R128_GPIO_MONIDB 0x006c -#define R128_GRPH8_DATA 0x03cf /* VGA */ -#define R128_GRPH8_IDX 0x03ce /* VGA */ -#define R128_GUI_DEBUG0 0x16a0 -#define R128_GUI_DEBUG1 0x16a4 -#define R128_GUI_DEBUG2 0x16a8 -#define R128_GUI_DEBUG3 0x16ac -#define R128_GUI_DEBUG4 0x16b0 -#define R128_GUI_DEBUG5 0x16b4 -#define R128_GUI_DEBUG6 0x16b8 -#define R128_GUI_PROBE 0x16bc -#define R128_GUI_SCRATCH_REG0 0x15e0 -#define R128_GUI_SCRATCH_REG1 0x15e4 -#define R128_GUI_SCRATCH_REG2 0x15e8 -#define R128_GUI_SCRATCH_REG3 0x15ec -#define R128_GUI_SCRATCH_REG4 0x15f0 -#define R128_GUI_SCRATCH_REG5 0x15f4 -#define R128_GUI_STAT 0x1740 -# define R128_GUI_FIFOCNT_MASK 0x0fff -# define R128_GUI_ACTIVE (1 << 31) - -#define R128_HEADER 0x0f0e /* PCI */ -#define R128_HOST_DATA0 0x17c0 -#define R128_HOST_DATA1 0x17c4 -#define R128_HOST_DATA2 0x17c8 -#define R128_HOST_DATA3 0x17cc -#define R128_HOST_DATA4 0x17d0 -#define R128_HOST_DATA5 0x17d4 -#define R128_HOST_DATA6 0x17d8 -#define R128_HOST_DATA7 0x17dc -#define R128_HOST_DATA_LAST 0x17e0 -#define R128_HOST_PATH_CNTL 0x0130 -#define R128_HTOTAL_CNTL 0x0009 /* PLL */ -#define R128_HW_DEBUG 0x0128 -#define R128_HW_DEBUG2 0x011c - -#define R128_I2C_CNTL_1 0x0094 /* ? */ -#define R128_INTERRUPT_LINE 0x0f3c /* PCI */ -#define R128_INTERRUPT_PIN 0x0f3d /* PCI */ -#define R128_IO_BASE 0x0f14 /* PCI */ - -#define R128_LATENCY 0x0f0d /* PCI */ -#define R128_LEAD_BRES_DEC 0x1608 -#define R128_LEAD_BRES_ERR 0x1600 -#define R128_LEAD_BRES_INC 0x1604 -#define R128_LEAD_BRES_LNTH 0x161c -#define R128_LEAD_BRES_LNTH_SUB 0x1624 -#define R128_LVDS_GEN_CNTL 0x02d0 -# define R128_LVDS_ON (1 << 0) -# define R128_LVDS_SEL_CRTC2 (1 << 23) - -#define R128_MAX_LATENCY 0x0f3f /* PCI */ -#define R128_MCLK_CNTL 0x000f /* PLL */ -# define R128_FORCE_GCP (1 << 16) -# define R128_FORCE_PIPE3D_CP (1 << 17) -# define R128_FORCE_RCP (1 << 18) -#define R128_MDGPIO_A_REG 0x01ac -#define R128_MDGPIO_EN_REG 0x01b0 -#define R128_MDGPIO_MASK 0x0198 -#define R128_MDGPIO_Y_REG 0x01b4 -#define R128_MEM_ADDR_CONFIG 0x0148 -#define R128_MEM_BASE 0x0f10 /* PCI */ -#define R128_MEM_CNTL 0x0140 -#define R128_MEM_INIT_LAT_TIMER 0x0154 -#define R128_MEM_INTF_CNTL 0x014c -#define R128_MEM_SDRAM_MODE_REG 0x0158 -#define R128_MEM_STR_CNTL 0x0150 -#define R128_MEM_VGA_RP_SEL 0x003c -#define R128_MEM_VGA_WP_SEL 0x0038 -#define R128_MIN_GRANT 0x0f3e /* PCI */ -#define R128_MM_DATA 0x0004 -#define R128_MM_INDEX 0x0000 -#define R128_MPLL_CNTL 0x000e /* PLL */ -#define R128_MPP_TB_CONFIG 0x01c0 /* ? */ -#define R128_MPP_GP_CONFIG 0x01c8 /* ? */ - -#define R128_N_VIF_COUNT 0x0248 - -#define R128_OV0_SCALE_CNTL 0x0420 /* ? */ -#define R128_OVR_CLR 0x0230 -#define R128_OVR_WID_LEFT_RIGHT 0x0234 -#define R128_OVR_WID_TOP_BOTTOM 0x0238 - -#define R128_PALETTE_DATA 0x00b4 -#define R128_PALETTE_INDEX 0x00b0 -#define R128_PC_DEBUG_MODE 0x1760 -#define R128_PC_GUI_CTLSTAT 0x1748 -#define R128_PC_GUI_MODE 0x1744 -# define R128_PC_IGNORE_UNIFY (1 << 5) -#define R128_PC_MISC_CNTL 0x0188 -#define R128_PC_NGUI_CTLSTAT 0x0184 -# define R128_PC_FLUSH_GUI (3 << 0) -# define R128_PC_RI_GUI (1 << 2) -# define R128_PC_FLUSH_ALL 0x00ff -# define R128_PC_BUSY (1 << 31) -#define R128_PC_NGUI_MODE 0x0180 -#define R128_PCI_GART_PAGE 0x017c -#define R128_PLANE_3D_MASK_C 0x1d44 -#define R128_PLL_TEST_CNTL 0x0013 /* PLL */ -#define R128_PMI_CAP_ID 0x0f5c /* PCI */ -#define R128_PMI_DATA 0x0f63 /* PCI */ -#define R128_PMI_NXT_CAP_PTR 0x0f5d /* PCI */ -#define R128_PMI_PMC_REG 0x0f5e /* PCI */ -#define R128_PMI_PMCSR_REG 0x0f60 /* PCI */ -#define R128_PMI_REGISTER 0x0f5c /* PCI */ -#define R128_PPLL_CNTL 0x0002 /* PLL */ -# define R128_PPLL_RESET (1 << 0) -# define R128_PPLL_SLEEP (1 << 1) -# define R128_PPLL_ATOMIC_UPDATE_EN (1 << 16) -# define R128_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17) -#define R128_PPLL_DIV_0 0x0004 /* PLL */ -#define R128_PPLL_DIV_1 0x0005 /* PLL */ -#define R128_PPLL_DIV_2 0x0006 /* PLL */ -#define R128_PPLL_DIV_3 0x0007 /* PLL */ -# define R128_PPLL_FB3_DIV_MASK 0x07ff -# define R128_PPLL_POST3_DIV_MASK 0x00070000 -#define R128_PPLL_REF_DIV 0x0003 /* PLL */ -# define R128_PPLL_REF_DIV_MASK 0x03ff -# define R128_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */ -# define R128_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */ -#define R128_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */ -#define R128_REG_BASE 0x0f18 /* PCI */ -#define R128_REGPROG_INF 0x0f09 /* PCI */ -#define R128_REVISION_ID 0x0f08 /* PCI */ - -#define R128_SC_BOTTOM 0x164c -#define R128_SC_BOTTOM_RIGHT 0x16f0 -#define R128_SC_BOTTOM_RIGHT_C 0x1c8c -#define R128_SC_LEFT 0x1640 -#define R128_SC_RIGHT 0x1644 -#define R128_SC_TOP 0x1648 -#define R128_SC_TOP_LEFT 0x16ec -#define R128_SC_TOP_LEFT_C 0x1c88 -#define R128_SEQ8_DATA 0x03c5 /* VGA */ -#define R128_SEQ8_IDX 0x03c4 /* VGA */ -#define R128_SNAPSHOT_F_COUNT 0x0244 -#define R128_SNAPSHOT_VH_COUNTS 0x0240 -#define R128_SNAPSHOT_VIF_COUNT 0x024c -#define R128_SRC_OFFSET 0x15ac -#define R128_SRC_PITCH 0x15b0 -#define R128_SRC_PITCH_OFFSET 0x1428 -#define R128_SRC_SC_BOTTOM 0x165c -#define R128_SRC_SC_BOTTOM_RIGHT 0x16f4 -#define R128_SRC_SC_RIGHT 0x1654 -#define R128_SRC_X 0x1414 -#define R128_SRC_X_Y 0x1590 -#define R128_SRC_Y 0x1418 -#define R128_SRC_Y_X 0x1434 -#define R128_STATUS 0x0f06 /* PCI */ -#define R128_SUBPIC_CNTL 0x0540 /* ? */ -#define R128_SUB_CLASS 0x0f0a /* PCI */ -#define R128_SURFACE_DELAY 0x0b00 -#define R128_SURFACE0_INFO 0x0b0c -#define R128_SURFACE0_LOWER_BOUND 0x0b04 -#define R128_SURFACE0_UPPER_BOUND 0x0b08 -#define R128_SURFACE1_INFO 0x0b1c -#define R128_SURFACE1_LOWER_BOUND 0x0b14 -#define R128_SURFACE1_UPPER_BOUND 0x0b18 -#define R128_SURFACE2_INFO 0x0b2c -#define R128_SURFACE2_LOWER_BOUND 0x0b24 -#define R128_SURFACE2_UPPER_BOUND 0x0b28 -#define R128_SURFACE3_INFO 0x0b3c -#define R128_SURFACE3_LOWER_BOUND 0x0b34 -#define R128_SURFACE3_UPPER_BOUND 0x0b38 -#define R128_SW_SEMAPHORE 0x013c - -#define R128_TEST_DEBUG_CNTL 0x0120 -#define R128_TEST_DEBUG_MUX 0x0124 -#define R128_TEST_DEBUG_OUT 0x012c -#define R128_TMDS_CRC 0x02a0 -#define R128_TRAIL_BRES_DEC 0x1614 -#define R128_TRAIL_BRES_ERR 0x160c -#define R128_TRAIL_BRES_INC 0x1610 -#define R128_TRAIL_X 0x1618 -#define R128_TRAIL_X_SUB 0x1620 - -#define R128_VCLK_ECP_CNTL 0x0008 /* PLL */ -#define R128_VENDOR_ID 0x0f00 /* PCI */ -#define R128_VGA_DDA_CONFIG 0x02e8 -#define R128_VGA_DDA_ON_OFF 0x02ec -#define R128_VID_BUFFER_CONTROL 0x0900 -#define R128_VIDEOMUX_CNTL 0x0190 -#define R128_VIPH_CONTROL 0x01D0 /* ? */ - -#define R128_WAIT_UNTIL 0x1720 - -#define R128_X_MPLL_REF_FB_DIV 0x000a /* PLL */ -#define R128_XCLK_CNTL 0x000d /* PLL */ -#define R128_XDLL_CNTL 0x000c /* PLL */ -#define R128_XPLL_CNTL 0x000b /* PLL */ - - /* Registers for CCE and Microcode Engine */ -#define R128_PM4_MICROCODE_ADDR 0x07d4 -#define R128_PM4_MICROCODE_RADDR 0x07d8 -#define R128_PM4_MICROCODE_DATAH 0x07dc -#define R128_PM4_MICROCODE_DATAL 0x07e0 - -#define R128_PM4_BUFFER_OFFSET 0x0700 -#define R128_PM4_BUFFER_CNTL 0x0704 -# define R128_PM4_NONPM4 (0 << 28) -# define R128_PM4_192PIO (1 << 28) -# define R128_PM4_192BM (2 << 28) -# define R128_PM4_128PIO_64INDBM (3 << 28) -# define R128_PM4_128BM_64INDBM (4 << 28) -# define R128_PM4_64PIO_128INDBM (5 << 28) -# define R128_PM4_64BM_128INDBM (6 << 28) -# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) -# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) -# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) -#define R128_PM4_BUFFER_WM_CNTL 0x0708 -# define R128_WMA_SHIFT 0 -# define R128_WMB_SHIFT 8 -# define R128_WMC_SHIFT 16 -# define R128_WB_WM_SHIFT 24 -#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c -#define R128_PM4_BUFFER_DL_RPTR 0x0710 -#define R128_PM4_BUFFER_DL_WPTR 0x0714 -# define R128_PM4_BUFFER_DL_DONE (1 << 31) -#define R128_PM4_BUFFER_DL_WPTR_DELAY 0x0718 -# define R128_PRE_WRITE_TIMER_SHIFT 0 -# define R128_PRE_WRITE_LIMIT_SHIFT 23 -#define R128_PM4_VC_FPU_SETUP 0x071c -# define R128_FRONT_DIR_CW (0 << 0) -# define R128_FRONT_DIR_CCW (1 << 0) -# define R128_FRONT_DIR_MASK (1 << 0) -# define R128_BACKFACE_CULL (0 << 1) -# define R128_BACKFACE_POINTS (1 << 1) -# define R128_BACKFACE_LINES (2 << 1) -# define R128_BACKFACE_SOLID (3 << 1) -# define R128_BACKFACE_MASK (3 << 1) -# define R128_FRONTFACE_CULL (0 << 3) -# define R128_FRONTFACE_POINTS (1 << 3) -# define R128_FRONTFACE_LINES (2 << 3) -# define R128_FRONTFACE_SOLID (3 << 3) -# define R128_FRONTFACE_MASK (3 << 3) -# define R128_FPU_COLOR_SOLID (0 << 5) -# define R128_FPU_COLOR_FLAT (1 << 5) -# define R128_FPU_COLOR_GOURAUD (2 << 5) -# define R128_FPU_COLOR_GOURAUD2 (3 << 5) -# define R128_FPU_SUB_PIX_2BITS (0 << 7) -# define R128_FPU_SUB_PIX_4BITS (1 << 7) -# define R128_FPU_MODE_2D (0 << 8) -# define R128_FPU_MODE_3D (1 << 8) -# define R128_TRAP_BITS_DISABLE (1 << 9) -# define R128_EDGE_ANTIALIAS (1 << 10) -# define R128_SUPERSAMPLE (1 << 11) -# define R128_XFACTOR_2 (0 << 12) -# define R128_XFACTOR_4 (1 << 12) -# define R128_YFACTOR_2 (0 << 13) -# define R128_YFACTOR_4 (1 << 13) -# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14) -# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14) -# define R128_FPU_ROUND_TRUNCATE (0 << 15) -# define R128_FPU_ROUND_NEAREST (1 << 15) -# define R128_WM_SEL_8DW (0 << 16) -# define R128_WM_SEL_16DW (1 << 16) -# define R128_WM_SEL_32DW (2 << 16) -#define R128_PM4_VC_DEBUG_CONFIG 0x07a4 -#define R128_PM4_VC_STAT 0x07a8 -#define R128_PM4_VC_TIMESTAMP0 0x07b0 -#define R128_PM4_VC_TIMESTAMP1 0x07b4 -#define R128_PM4_STAT 0x07b8 -# define R128_PM4_FIFOCNT_MASK 0x0fff -# define R128_PM4_BUSY (1 << 16) -# define R128_PM4_GUI_ACTIVE (1 << 31) -#define R128_PM4_BUFFER_ADDR 0x07f0 -#define R128_PM4_MICRO_CNTL 0x07fc -# define R128_PM4_MICRO_FREERUN (1 << 30) -#define R128_PM4_FIFO_DATA_EVEN 0x1000 -#define R128_PM4_FIFO_DATA_ODD 0x1004 - -#define R128_SCALE_3D_CNTL 0x1a00 -# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) -# define R128_SCALE_DITHER_TABLE (1 << 1) -# define R128_TEX_CACHE_SIZE_FULL (0 << 2) -# define R128_TEX_CACHE_SIZE_HALF (1 << 2) -# define R128_DITHER_INIT_CURR (0 << 3) -# define R128_DITHER_INIT_RESET (1 << 3) -# define R128_ROUND_24BIT (1 << 4) -# define R128_TEX_CACHE_DISABLE (1 << 5) -# define R128_SCALE_3D_NOOP (0 << 6) -# define R128_SCALE_3D_SCALE (1 << 6) -# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) -# define R128_SCALE_PIX_BLEND (0 << 8) -# define R128_SCALE_PIX_REPLICATE (1 << 8) -# define R128_TEX_CACHE_SPLIT (1 << 9) -# define R128_APPLE_YUV_MODE (1 << 10) -# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) -# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) -# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) -# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) -# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) -# define R128_FOG_TABLE (1 << 14) -# define R128_SIGNED_DST_CLAMP (1 << 15) -# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) -# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) -# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) -# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) -# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) -# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) -# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) -# define R128_ALPHA_BLEND_SRC_SAT (10 << 16) -# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16) -# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16) -# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) -# define R128_ALPHA_BLEND_DST_ONE (1 << 20) -# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) -# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20) -# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) -# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) -# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) -# define R128_ALPHA_TEST_NEVER (0 << 24) -# define R128_ALPHA_TEST_LESS (1 << 24) -# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) -# define R128_ALPHA_TEST_EQUAL (3 << 24) -# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) -# define R128_ALPHA_TEST_GREATER (5 << 24) -# define R128_ALPHA_TEST_NEQUAL (6 << 24) -# define R128_ALPHA_TEST_ALWAYS (7 << 24) -# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) -# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) -# define R128_COMPOSITE_SHADOW (1 << 29) -# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) -# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31) -# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31) -#define R128_SCALE_3D_DATATYPE 0x1a20 - -#define R128_SETUP_CNTL 0x1bc4 -# define R128_DONT_START_TRIANGLE (1 << 0) -# define R128_Z_BIAS (0 << 1) -# define R128_DONT_START_ANY_ON (1 << 2) -# define R128_COLOR_SOLID_COLOR (0 << 3) -# define R128_COLOR_FLAT_VERT_1 (1 << 3) -# define R128_COLOR_FLAT_VERT_2 (2 << 3) -# define R128_COLOR_FLAT_VERT_3 (3 << 3) -# define R128_COLOR_GOURAUD (4 << 3) -# define R128_PRIM_TYPE_TRI (0 << 7) -# define R128_PRIM_TYPE_LINE (1 << 7) -# define R128_PRIM_TYPE_POINT (2 << 7) -# define R128_PRIM_TYPE_POLY_EDGE (3 << 7) -# define R128_TEXTURE_ST_MULT_W (0 << 9) -# define R128_TEXTURE_ST_DIRECT (1 << 9) -# define R128_STARTING_VERTEX_1 (1 << 14) -# define R128_STARTING_VERTEX_2 (2 << 14) -# define R128_STARTING_VERTEX_3 (3 << 14) -# define R128_ENDING_VERTEX_1 (1 << 16) -# define R128_ENDING_VERTEX_2 (2 << 16) -# define R128_ENDING_VERTEX_3 (3 << 16) -# define R128_SU_POLY_LINE_LAST (0 << 18) -# define R128_SU_POLY_LINE_NOT_LAST (1 << 18) -# define R128_SUB_PIX_2BITS (0 << 19) -# define R128_SUB_PIX_4BITS (1 << 19) -# define R128_SET_UP_CONTINUE (1 << 31) - -#define R128_WINDOW_XY_OFFSET 0x1bcc -# define R128_WINDOW_Y_SHIFT 4 -# define R128_WINDOW_X_SHIFT 20 - -#define R128_Z_OFFSET_C 0x1c90 -#define R128_Z_PITCH_C 0x1c94 -#define R128_Z_STEN_CNTL_C 0x1c98 -# define R128_Z_PIX_WIDTH_16 (0 << 1) -# define R128_Z_PIX_WIDTH_24 (1 << 1) -# define R128_Z_PIX_WIDTH_32 (2 << 1) -# define R128_Z_PIX_WIDTH_MASK (3 << 1) -# define R128_Z_TEST_NEVER (0 << 4) -# define R128_Z_TEST_LESS (1 << 4) -# define R128_Z_TEST_LESSEQUAL (2 << 4) -# define R128_Z_TEST_EQUAL (3 << 4) -# define R128_Z_TEST_GREATEREQUAL (4 << 4) -# define R128_Z_TEST_GREATER (5 << 4) -# define R128_Z_TEST_NEQUAL (6 << 4) -# define R128_Z_TEST_ALWAYS (7 << 4) -# define R128_Z_TEST_MASK (7 << 4) -# define R128_STENCIL_TEST_NEVER (0 << 12) -# define R128_STENCIL_TEST_LESS (1 << 12) -# define R128_STENCIL_TEST_LESSEQUAL (2 << 12) -# define R128_STENCIL_TEST_EQUAL (3 << 12) -# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12) -# define R128_STENCIL_TEST_GREATER (5 << 12) -# define R128_STENCIL_TEST_NEQUAL (6 << 12) -# define R128_STENCIL_TEST_ALWAYS (7 << 12) -# define R128_STENCIL_S_FAIL_KEEP (0 << 16) -# define R128_STENCIL_S_FAIL_ZERO (1 << 16) -# define R128_STENCIL_S_FAIL_REPLACE (2 << 16) -# define R128_STENCIL_S_FAIL_INC (3 << 16) -# define R128_STENCIL_S_FAIL_DEC (4 << 16) -# define R128_STENCIL_S_FAIL_INV (5 << 16) -# define R128_STENCIL_ZPASS_KEEP (0 << 20) -# define R128_STENCIL_ZPASS_ZERO (1 << 20) -# define R128_STENCIL_ZPASS_REPLACE (2 << 20) -# define R128_STENCIL_ZPASS_INC (3 << 20) -# define R128_STENCIL_ZPASS_DEC (4 << 20) -# define R128_STENCIL_ZPASS_INV (5 << 20) -# define R128_STENCIL_ZFAIL_KEEP (0 << 24) -# define R128_STENCIL_ZFAIL_ZERO (1 << 24) -# define R128_STENCIL_ZFAIL_REPLACE (2 << 24) -# define R128_STENCIL_ZFAIL_INC (3 << 24) -# define R128_STENCIL_ZFAIL_DEC (4 << 24) -# define R128_STENCIL_ZFAIL_INV (5 << 24) -#define R128_TEX_CNTL_C 0x1c9c -# define R128_Z_ENABLE (1 << 0) -# define R128_Z_WRITE_ENABLE (1 << 1) -# define R128_STENCIL_ENABLE (1 << 3) -# define R128_SHADE_ENABLE (0 << 4) -# define R128_TEXMAP_ENABLE (1 << 4) -# define R128_SEC_TEXMAP_ENABLE (1 << 5) -# define R128_FOG_ENABLE (1 << 7) -# define R128_DITHER_ENABLE (1 << 8) -# define R128_ALPHA_ENABLE (1 << 9) -# define R128_ALPHA_TEST_ENABLE (1 << 10) -# define R128_SPEC_LIGHT_ENABLE (1 << 11) -# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) -# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) -# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) -# define R128_LIGHT_DIS (0 << 14) -# define R128_LIGHT_COPY (1 << 14) -# define R128_LIGHT_MODULATE (2 << 14) -# define R128_LIGHT_ADD (3 << 14) -# define R128_LIGHT_BLEND_CONSTANT (4 << 14) -# define R128_LIGHT_BLEND_TEXTURE (5 << 14) -# define R128_LIGHT_BLEND_VERTEX (6 << 14) -# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) -# define R128_ALPHA_LIGHT_DIS (0 << 18) -# define R128_ALPHA_LIGHT_COPY (1 << 18) -# define R128_ALPHA_LIGHT_MODULATE (2 << 18) -# define R128_ALPHA_LIGHT_ADD (3 << 18) -# define R128_ANTI_ALIAS (1 << 21) -# define R128_TEX_CACHE_FLUSH (1 << 23) -# define R128_LOD_BIAS_SHIFT 24 -#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0 -# define R128_REF_ALPHA_MASK 0xff -# define R128_MISC_SCALE_3D_NOOP (0 << 8) -# define R128_MISC_SCALE_3D_SCALE (1 << 8) -# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) -# define R128_MISC_SCALE_PIX_BLEND (0 << 10) -# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) -# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) -# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) -# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) -# define R128_FOG_VERTEX (0 << 14) -# define R128_FOG_TABLE (1 << 14) -# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) -# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) -# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) -# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) -# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) -# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) -# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) -# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) -# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) -# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) -# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) -# define R128_ALPHA_BLEND_SRC_MASK (15 << 16) -# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) -# define R128_ALPHA_BLEND_DST_ONE (1 << 20) -# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) -# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) -# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20) -# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) -# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) -# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) -# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) -# define R128_ALPHA_BLEND_DST_MASK (15 << 20) -# define R128_ALPHA_TEST_NEVER (0 << 24) -# define R128_ALPHA_TEST_LESS (1 << 24) -# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) -# define R128_ALPHA_TEST_EQUAL (3 << 24) -# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) -# define R128_ALPHA_TEST_GREATER (5 << 24) -# define R128_ALPHA_TEST_NEQUAL (6 << 24) -# define R128_ALPHA_TEST_ALWAYS (7 << 24) -# define R128_ALPHA_TEST_MASK (7 << 24) -#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 -#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 -#define R128_FOG_COLOR_C 0x1cac -# define R128_FOG_BLUE_SHIFT 0 -# define R128_FOG_GREEN_SHIFT 8 -# define R128_FOG_RED_SHIFT 16 -#define R128_PRIM_TEX_CNTL_C 0x1cb0 -# define R128_MIN_BLEND_NEAREST (0 << 1) -# define R128_MIN_BLEND_LINEAR (1 << 1) -# define R128_MIN_BLEND_MIPNEAREST (2 << 1) -# define R128_MIN_BLEND_MIPLINEAR (3 << 1) -# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1) -# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1) -# define R128_MIN_BLEND_MASK (7 << 1) -# define R128_MAG_BLEND_NEAREST (0 << 4) -# define R128_MAG_BLEND_LINEAR (1 << 4) -# define R128_MAG_BLEND_MASK (7 << 4) -# define R128_MIP_MAP_DISABLE (1 << 7) -# define R128_TEX_CLAMP_S_WRAP (0 << 8) -# define R128_TEX_CLAMP_S_MIRROR (1 << 8) -# define R128_TEX_CLAMP_S_CLAMP (2 << 8) -# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8) -# define R128_TEX_CLAMP_S_MASK (3 << 8) -# define R128_TEX_WRAP_S (1 << 10) -# define R128_TEX_CLAMP_T_WRAP (0 << 11) -# define R128_TEX_CLAMP_T_MIRROR (1 << 11) -# define R128_TEX_CLAMP_T_CLAMP (2 << 11) -# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11) -# define R128_TEX_CLAMP_T_MASK (3 << 11) -# define R128_TEX_WRAP_T (1 << 13) -# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14) -# define R128_DATATYPE_VQ (0 << 16) -# define R128_DATATYPE_CI4 (1 << 16) -# define R128_DATATYPE_CI8 (2 << 16) -# define R128_DATATYPE_ARGB1555 (3 << 16) -# define R128_DATATYPE_RGB565 (4 << 16) -# define R128_DATATYPE_RGB888 (5 << 16) -# define R128_DATATYPE_ARGB8888 (6 << 16) -# define R128_DATATYPE_RGB332 (7 << 16) -# define R128_DATATYPE_Y8 (8 << 16) -# define R128_DATATYPE_RGB8 (9 << 16) -# define R128_DATATYPE_CI16 (10 << 16) -# define R128_DATATYPE_YUV422 (11 << 16) -# define R128_DATATYPE_YUV422_2 (12 << 16) -# define R128_DATATYPE_AYUV444 (14 << 16) -# define R128_DATATYPE_ARGB4444 (15 << 16) -# define R128_PALLETE_EITHER (0 << 20) -# define R128_PALLETE_1 (1 << 20) -# define R128_PALLETE_2 (2 << 20) -# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24) -# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) -# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) -#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 -# define R128_COMB_DIS (0 << 0) -# define R128_COMB_COPY (1 << 0) -# define R128_COMB_COPY_INP (2 << 0) -# define R128_COMB_MODULATE (3 << 0) -# define R128_COMB_MODULATE2X (4 << 0) -# define R128_COMB_MODULATE4X (5 << 0) -# define R128_COMB_ADD (6 << 0) -# define R128_COMB_ADD_SIGNED (7 << 0) -# define R128_COMB_BLEND_VERTEX (8 << 0) -# define R128_COMB_BLEND_TEXTURE (9 << 0) -# define R128_COMB_BLEND_CONST (10 << 0) -# define R128_COMB_BLEND_PREMULT (11 << 0) -# define R128_COMB_BLEND_PREV (12 << 0) -# define R128_COMB_BLEND_PREMULT_INV (13 << 0) -# define R128_COMB_ADD_SIGNED2X (14 << 0) -# define R128_COMB_BLEND_CONST_COLOR (15 << 0) -# define R128_COMB_MASK (15 << 0) -# define R128_COLOR_FACTOR_TEX (4 << 4) -# define R128_COLOR_FACTOR_NTEX (5 << 4) -# define R128_COLOR_FACTOR_ALPHA (6 << 4) -# define R128_COLOR_FACTOR_NALPHA (7 << 4) -# define R128_COLOR_FACTOR_MASK (15 << 4) -# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10) -# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10) -# define R128_INPUT_FACTOR_INT_COLOR (4 << 10) -# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10) -# define R128_INPUT_FACTOR_MASK (15 << 10) -# define R128_COMB_ALPHA_DIS (0 << 14) -# define R128_COMB_ALPHA_COPY (1 << 14) -# define R128_COMB_ALPHA_COPY_INP (2 << 14) -# define R128_COMB_ALPHA_MODULATE (3 << 14) -# define R128_COMB_ALPHA_MODULATE2X (4 << 14) -# define R128_COMB_ALPHA_MODULATE4X (5 << 14) -# define R128_COMB_ALPHA_ADD (6 << 14) -# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14) -# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14) -# define R128_COMB_ALPHA_MASK (15 << 14) -# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18) -# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) -# define R128_ALPHA_FACTOR_MASK (15 << 18) -# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25) -# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25) -# define R128_INP_FACTOR_A_MASK (7 << 25) -#define R128_TEX_SIZE_PITCH_C 0x1cb8 -# define R128_TEX_PITCH_SHIFT 0 -# define R128_TEX_SIZE_SHIFT 4 -# define R128_TEX_HEIGHT_SHIFT 8 -# define R128_TEX_MIN_SIZE_SHIFT 12 -# define R128_SEC_TEX_PITCH_SHIFT 16 -# define R128_SEC_TEX_SIZE_SHIFT 20 -# define R128_SEC_TEX_HEIGHT_SHIFT 24 -# define R128_SEC_TEX_MIN_SIZE_SHIFT 28 -# define R128_TEX_PITCH_MASK (0x0f << 0) -# define R128_TEX_SIZE_MASK (0x0f << 4) -# define R128_TEX_HEIGHT_MASK (0x0f << 8) -# define R128_TEX_MIN_SIZE_MASK (0x0f << 12) -# define R128_SEC_TEX_PITCH_MASK (0x0f << 16) -# define R128_SEC_TEX_SIZE_MASK (0x0f << 20) -# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24) -# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) -# define R128_TEX_SIZE_PITCH_SHIFT 0 -# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16 -# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0) -# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) -#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc -#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0 -#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4 -#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8 -#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc -#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0 -#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4 -#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8 -#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc -#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0 -#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4 -# define R128_TEX_NO_TILE (0 << 30) -# define R128_TEX_TILED_BY_HOST (1 << 30) -# define R128_TEX_TILED_BY_STORAGE (2 << 30) -# define R128_TEX_TILED_BY_STORAGE2 (3 << 30) - -#define R128_SEC_TEX_CNTL_C 0x1d00 -# define R128_SEC_SELECT_PRIM_ST (0 << 0) -# define R128_SEC_SELECT_SEC_ST (1 << 0) -#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04 -# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) -# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) -# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) -#define R128_SEC_TEX_0_OFFSET_C 0x1d08 -#define R128_SEC_TEX_1_OFFSET_C 0x1d0c -#define R128_SEC_TEX_2_OFFSET_C 0x1d10 -#define R128_SEC_TEX_3_OFFSET_C 0x1d14 -#define R128_SEC_TEX_4_OFFSET_C 0x1d18 -#define R128_SEC_TEX_5_OFFSET_C 0x1d1c -#define R128_SEC_TEX_6_OFFSET_C 0x1d20 -#define R128_SEC_TEX_7_OFFSET_C 0x1d24 -#define R128_SEC_TEX_8_OFFSET_C 0x1d28 -#define R128_SEC_TEX_9_OFFSET_C 0x1d2c -#define R128_SEC_TEX_10_OFFSET_C 0x1d30 -#define R128_CONSTANT_COLOR_C 0x1d34 -# define R128_CONSTANT_BLUE_SHIFT 0 -# define R128_CONSTANT_GREEN_SHIFT 8 -# define R128_CONSTANT_RED_SHIFT 16 -# define R128_CONSTANT_ALPHA_SHIFT 24 -#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 -# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0 -# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8 -# define R128_PRIM_TEX_BORDER_RED_SHIFT 16 -# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24 -#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c -# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0 -# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8 -# define R128_SEC_TEX_BORDER_RED_SHIFT 16 -# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24 -#define R128_STEN_REF_MASK_C 0x1d40 -# define R128_STEN_REFERENCE_SHIFT 0 -# define R128_STEN_MASK_SHIFT 16 -# define R128_STEN_WRITE_MASK_SHIFT 24 -#define R128_PLANE_3D_MASK_C 0x1d44 -#define R128_TEX_CACHE_STAT_COUNT 0x1974 - - - /* Constants */ -#define R128_AGP_TEX_OFFSET 0x02000000 - -#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0 -#define R128_SWAP_AGE_REG R128_GUI_SCRATCH_REG1 - - /* CCE packet types */ -#define R128_CCE_PACKET0 0x00000000 -#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000 -#define R128_CCE_PACKET1 0x40000000 -#define R128_CCE_PACKET2 0x80000000 -#define R128_CCE_PACKET3_NOP 0xC0001000 -#define R128_CCE_PACKET3_PAINT 0xC0001100 -#define R128_CCE_PACKET3_BITBLT 0xC0001200 -#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300 -#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 -#define R128_CCE_PACKET3_POLYLINE 0xC0001500 -#define R128_CCE_PACKET3_SCALING 0xC0001600 -#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700 -#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800 -#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900 -#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00 -#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 -#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 -#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00 -#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 -#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100 -#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200 -#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 -#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 -#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 -#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600 -#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 -#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 -#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 -#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 -#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 -#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 -#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 -#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 -#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 -#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 -#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 -#define R128_CCE_PACKET3_PURGE 0xC0002D00 -#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 -# define R128_CCE_PACKET_MASK 0xC0000000 -# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 -# define R128_CCE_PACKET_MAX_DWORDS (1 << 14) -# define R128_CCE_PACKET0_REG_MASK 0x000007ff -# define R128_CCE_PACKET1_REG0_MASK 0x000007ff -# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 - -#define R128_CCE_VC_FRMT_RHW 0x00000001 -#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 -#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004 -#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 -#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010 -#define R128_CCE_VC_FRMT_SPEC_F 0x00000020 -#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040 -#define R128_CCE_VC_FRMT_S_T 0x00000080 -#define R128_CCE_VC_FRMT_S2_T2 0x00000100 -#define R128_CCE_VC_FRMT_RHW2 0x00000200 - -#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 -#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 -#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 -#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 -#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 -#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 -#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 -#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 -#define R128_CCE_VC_CNTL_NUM_SHIFT 16 - -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h diff -u xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h:1.1 Fri Jun 16 20:03:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h Mon Dec 18 14:31:00 2000 @@ -1,77 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h,v 1.1 2000/06/17 00:03:23 martin Exp $ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <kevin@precisioninsight.com> - * - */ - -#ifndef _R128_SAREA_H_ -#define _R128_SAREA_H_ - -/* There are 2 heaps (local/AGP). Each region within a heap is a - minimum of 64k, and there are at most 64 of them per heap. */ -#define R128_LOCAL_TEX_HEAP 0 -#define R128_AGP_TEX_HEAP 1 -#define R128_NR_TEX_HEAPS 2 -#define R128_NR_TEX_REGIONS 64 -#define R128_LOG_TEX_GRANULARITY 16 - -typedef struct { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} R128TexRegion; - -typedef struct { - /* Maintain an LRU of contiguous regions of texture space. If you - * think you own a region of texture memory, and it has an age - * different to the one you set, then you are mistaken and it has - * been stolen by another client. If global texAge hasn't changed, - * there is no need to walk the list. - * - * These regions can be used as a proxy for the fine-grained texture - * information of other clients - by maintaining them in the same - * lru which is used to age their own textures, clients have an - * approximate lru for the whole of global texture space, and can - * make informed decisions as to which areas to kick out. There is - * no need to choose whether to kick out your own texture or someone - * else's - simply eject them all in LRU order. - */ - /* Last elt is sentinal */ - R128TexRegion texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; - /* last time texture was uploaded */ - int texAge[R128_NR_TEX_HEAPS]; - - int ctxOwner; /* last context to upload state */ - - int ringWrite; /* current ring buffer write index */ -} R128SAREAPriv, *R128SAREAPrivPtr; - -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile:1.16 xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile:1.16 Fri Mar 31 15:13:24 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile Tue Sep 19 20:09:27 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile,v 1.16 2000/03/31 20:13:24 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile,v 1.17 2000/09/20 00:09:27 keithp Exp $ XCOMM XCOMM This is an Imakefile for the Rendition driver. @@ -25,7 +25,8 @@ -I$(SERVERSRC)/include -I$(XF86SRC)/xaa \ -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/xf8_32bpp \ -I$(XF86SRC)/ramdac -I$(SERVERSRC)/Xext \ - -I$(XF86SRC)/shadowfb -I$(XF86SRC)/rac -I$(XF86SRC)/loader + -I$(XF86SRC)/shadowfb -I$(XF86SRC)/rac -I$(XF86SRC)/loader \ + -I$(SERVERSRC)/render -I$(EXTINCSRC) #endif XCOMM Index: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c diff -u xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c:1.34 xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c:1.38 --- xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c:1.34 Mon Jun 12 22:28:33 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c Thu Dec 14 11:33:10 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c,v 1.34 2000/06/13 02:28:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c,v 1.38 2000/12/14 16:33:10 eich Exp $ */ /* * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. * @@ -121,7 +121,7 @@ DriverRec RENDITION={ RENDITION_VERSION_CURRENT, - "rendition driver", + "rendition", renditionIdentify, renditionProbe, renditionAvailableOptions, @@ -314,9 +314,7 @@ renditionChipsets, renditionPCIchipsets, devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -646,7 +644,9 @@ pRendition->board.mem_base); /* First of all get a "clean" starting state */ +#if 1 verite_resetboard(pScreenInfo); +#endif /* determine video ram -- to do so, we assume a full size memory of 16M, * then map it and use verite_getmemorysize() to determine the real amount of @@ -1102,8 +1102,9 @@ prenditionPriv->CloseScreen = NULL; Closed = (*pScreen->CloseScreen)(scrnIndex, pScreen); } - - renditionLeaveGraphics(pScreenInfo); + + if (pScreenInfo->vtSema) + renditionLeaveGraphics(pScreenInfo); pScreenInfo->vtSema = FALSE; #ifdef DEBUG Index: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp:1.5 xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp:1.5 Tue Jun 13 22:13:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp Tue Dec 12 13:54:31 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp,v 1.5 2000/06/14 02:13:13 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp,v 1.7 2000/12/12 18:54:31 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH RENDITION __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH RENDITION __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME rendition \- Rendition video driver .SH SYNOPSIS @@ -105,7 +105,7 @@ For the moment the driver defaults to not request write-combine for any chipset as there has been indications of problems with it. Use .B "Option \*qMTRR\*q" -to let the driver request write-combining of memory access on the videoboard. +to let the driver request write-combining of memory access on the video board. .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) .SH AUTHORS Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile:1.17 xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile:1.17 Fri Mar 31 17:55:46 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile Mon Oct 23 08:10:15 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile,v 1.17 2000/03/31 22:55:46 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile,v 1.19 2000/10/23 12:10:15 alanh Exp $ /* * * Copyright 1995-1998 The XFree86 Project, Inc. @@ -9,10 +9,10 @@ #include <Server.tmpl> SRCS = s3v_driver.c s3v_accel.c s3v_dac.c s3v_hwcurs.c s3v_dga.c s3v_i2c.c \ - s3v_shadow.c + s3v_shadow.c s3v_xv.c OBJS = s3v_driver.o s3v_accel.o s3v_dac.o s3v_hwcurs.o s3v_dga.o s3v_i2c.o \ - s3v_shadow.o + s3v_shadow.o s3v_xv.o DEFINES = -DPSZ=8 @@ -22,13 +22,15 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(SERVERSRC)/fb \ -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ - -I$(EXTINCSRC) -I$(XF86OSSRC)/vbe -I$(XF86SRC)/shadowfb + -I$(EXTINCSRC) -I$(XF86OSSRC)/vbe -I$(XF86SRC)/shadowfb \ + -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES:1.15 xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES:1.15 Fri Jun 30 13:15:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES Tue Nov 28 15:59:17 2000 @@ -1,7 +1,7 @@ S3 ViRGE 4.0 devel notes rev: -26 Jun 2000 KJB +27 Nov 2000 KJB Function Implemented @@ -23,6 +23,57 @@ Status ------ +11/27/00 KJB +Ver 1.5.0 +Clean up, bump version for 4.0.2 submission. +CR3A, bit 0x40 (reserved) cleared for MX/GX2. Update man page. + +11/24/00 KJB +Disable CPU to screen color expansion on GX2, causes lockups on GX2 with +'locate html' in an xterm. Add WaitCmd code to prevent accelerator and +reg command path activity at the same time on GX2. +XVideo fixes, left side clipping fixed for video windows extending off left +side of screen. Add horizontal filtering modes for 1-2x and >3x scaling. + +11/7/00 KJB +Ver 1.4.0 +Enable MX fixes, testing with accel BLT_BUG set is worse on GX2, so left +it out. BLT_BUG wasn't being enabled on ViRGE & VX because of case usage, +enabled now. Re-enable silken mouse for GX2. Add Render/fbPicture support. +Fix a few compiler warnings. + +11/5/00 KJB +Continued work on GX2, much stabler now, but I think there is a lockup case +left if you enable pci_burst and pci_retry with accel. I still see screen +flashes with vertical bars once in a while, and the log reports a GEReset. +Added fbPicture (render) support, untested. XV code for GX2 is added, +but not working yet. + +10/29/00 KJB +Much work on GX2, now SWCursor locks up but HWCursor is stable, go figure. +Loading Netscape a couple times with the mail window was enough to lock it +up twice in a row. Server was locked but not a box (PCI) lock. Also, +vertical barring still occurred a couple times, so HW cursor wasn't causing +that. Try blt_bug flag again for lock up case. And attach to debug server +and bt... Sleep now... + +10/21/00 KJB +Ver 1.3.0 +Depth 16 Xv support added. Testing on ViRGE DX. 1280x1024x24 is noisy, so +needs FIFO tuning. + +9/27/00 KJB +Initial Xv support in depth 24. + +9/10/00 KJB +Convert to FB. Add option "UseFB", default true. Added +VerticalRetraceWait timeout back as default. #if0 out the line accel +code in s3v_accel.c. The Subsequent...Bresenham line code causes a lockup +when used with fb. We didn't have any hardware accel in there anyway... + +7/25/00 KJB +Started Xv additions. + 6/26/00 KJB GX2 seems to have an accel bug. I see the entire screen go solid color or a wide stripe pattern for about 1 second. The S3VGEReset gets called twice, @@ -208,4 +259,4 @@ -$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES,v 1.15 2000/06/30 17:15:12 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES,v 1.18 2000/11/28 20:59:17 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h:1.22 xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h:1.26 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h:1.22 Tue Apr 4 15:25:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h Tue Nov 28 15:59:17 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.22 2000/04/04 19:25:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.26 2000/11/28 20:59:17 dawes Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -69,13 +69,22 @@ #include "cfb32.h" #include "cfb24_32.h" +/* fb support */ + +#include "fb.h" + /* Drivers using the XAA interface ... */ #include "xaa.h" +#include "xaalocal.h" #include "xf86cmap.h" #include "xf86i2c.h" #include "vbe.h" +#include "xf86xv.h" +#include "Xv.h" +#include "fourcc.h" + #ifndef _S3V_VGAHWMMIO_H #define _S3V_VGAHWMMIO_H @@ -131,18 +140,37 @@ unsigned char CR40, CR41, CR42, CR43, CR45; unsigned char CR51, CR53, CR54, CR55, CR58, CR5D, CR5E; unsigned char CR63, CR65, CR66, CR67, CR68, CR69, CR6D; /* Video attrib. */ - unsigned char CR85, CR86; - unsigned char CR90, CR91; + unsigned char CR7B, CR7D; + unsigned char CR85, CR86, CR87; + unsigned char CR90, CR91, CR92, CR93; unsigned char ColorStack[8]; /* S3 hw cursor color stack CR4A/CR4B */ unsigned int STREAMS[22]; /* Streams regs */ unsigned int MMPR0, MMPR1, MMPR2, MMPR3; /* MIU regs */ } S3VRegRec, *S3VRegPtr; - /*************************/ - /* S3VRec */ - /*************************/ +/*********************************/ +/* S3VPortPrivRec */ +/*********************************/ + typedef struct { + unsigned char brightness; + unsigned char contrast; + FBAreaPtr area; + RegionRec clip; + CARD32 colorKey; + CARD32 videoStatus; + Time offTime; + Time freeTime; + int lastPort; +} S3VPortPrivRec, *S3VPortPrivPtr; + + +/*************************/ +/* S3VRec */ +/*************************/ + +typedef struct tagS3VRec { /* accel additions */ CARD32 AccelFlags; CARD32 AccelCmd; @@ -151,8 +179,14 @@ CARD32 CommonCmd; CARD32 FullPlaneMask; GCPtr CurrentGC; + /* fb support */ + DrawablePtr CurrentDrawable; /* end accel stuff */ - /* ViRGE specifics -start- */ + /* ViRGE specifics -start- */ + /* Xv support */ + XF86VideoAdaptorPtr adaptor; + S3VPortPrivPtr portPrivate; + /* S3V console saved mode registers */ S3VRegRec SavedReg; /* XServer video state mode registers */ @@ -215,9 +249,14 @@ /* Limit the number of errors */ /* printed using a counter */ int GEResetCnt; + /* Accel WaitFifo function */ + void (*pWaitFifo)(struct tagS3VRec *, int); + /* Accel WaitCmd function */ + void (*pWaitCmd)(struct tagS3VRec *); + /*************************/ /* ViRGE options -start- */ - + /*************************/ /* Enable PCI burst mode for reads? */ Bool pci_burst; /* Diasable PCI retries */ @@ -242,6 +281,7 @@ Bool lcd_center; /* hardware cursor enabled */ Bool hwcursor; + Bool UseFB; /* ViRGE options -end- */ /***********************/ /* ViRGE specifics -end- */ @@ -295,6 +335,9 @@ /******************* regs3v *******************************/ +/* cep kjb */ +#define VertDebug 1 + /* #ifndef MetroLink */ #if !defined (MetroLink) && !defined (VertDebug) #define VerticalRetraceWait() do { \ @@ -316,17 +359,17 @@ ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) && _spin_me <= SPIN_LIMIT; \ _spin_me++) ; \ if (_spin_me > SPIN_LIMIT) \ - ErrorF("s3v: warning: VerticalRetraceWait timed out.\n"); \ + ErrorF("s3v: warning: VerticalRetraceWait timed out(1:3).\n"); \ for (_spin_me = 0; \ ((inb(vgaIOBase + 0x0A) & 0x08) == 0x08) && _spin_me <= SPIN_LIMIT; \ _spin_me++) ; \ if (_spin_me > SPIN_LIMIT) \ - ErrorF("s3v: warning: VerticalRetraceWait timed out.\n"); \ + ErrorF("s3v: warning: VerticalRetraceWait timed out(2:3).\n"); \ for (_spin_me = 0; \ ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) && _spin_me <= SPIN_LIMIT; \ _spin_me++) ; \ if (_spin_me > SPIN_LIMIT) \ - ErrorF("s3v: warning: VerticalRetraceWait timed out.\n"); \ + ErrorF("s3v: warning: VerticalRetraceWait timed out(3:3).\n"); \ } \ } while (0) #endif @@ -353,6 +396,10 @@ extern Bool S3VAccelInit(ScreenPtr pScreen); extern Bool S3VAccelInit32(ScreenPtr pScreen); void S3VAccelSync(ScrnInfoPtr); +void S3VWaitFifoGX2(S3VPtr ps3v, int slots ); +void S3VWaitFifoMain(S3VPtr ps3v, int slots ); +void S3VWaitCmdGX2(S3VPtr ps3v); +void S3VWaitDummy(S3VPtr ps3v); /* s3v_hwcurs.c */ extern Bool S3VHWCursorInit(ScreenPtr pScreen); @@ -371,6 +418,9 @@ void s3vRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void s3vRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void s3vRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); + +/* s3v_xv.c X Video Extension support */ +void S3VInitVideo(ScreenPtr pScreen); #endif /*_S3V_H*/ Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c:1.18 xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c:1.21 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c:1.18 Mon Mar 6 17:59:27 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c Tue Nov 28 15:59:17 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c,v 1.18 2000/03/06 22:59:27 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_accel.c,v 1.21 2000/11/28 20:59:17 dawes Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -63,12 +63,16 @@ static void S3VSubsequentSolidHorVertLine(ScrnInfoPtr, int, int, int, int); static void S3VSubsequentSolidHorVertLinePlaneMask(ScrnInfoPtr, int, int, int, int); +#if 0 static void S3VSubsequentSolidBresenhamLine(ScrnInfoPtr, int, int, int, int, int, int, int); static void S3VPolylinesThinSolidWrapper(DrawablePtr, GCPtr, int, int, DDXPointPtr); static void S3VPolySegmentThinSolidWrapper(DrawablePtr, GCPtr, int, xSegment*); +#endif +static void S3VNopAllCmdSets(ScrnInfoPtr pScrn); + Bool S3VAccelInit(ScreenPtr pScreen) { @@ -79,16 +83,17 @@ ps3v->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; - - switch(ps3v->Chipset) { - case S3_ViRGE: - case S3_ViRGE_VX: + switch(ps3v->Chipset) + { + case S3_ViRGE: + case S3_ViRGE_VX: ps3v->AccelFlags = BLT_BUG; - default: + break; + default: ps3v->AccelFlags = 0; break; - } + } ps3v->AccelFlags |= MONO_TRANS_BUG; /* which aren't broken ? */ @@ -124,24 +129,34 @@ #ifndef __alpha__ - /* CPU to screen color expansion */ - infoPtr->CPUToScreenColorExpandFillFlags = ROP_NEEDS_SOURCE | + + /* disable color expand on GX2 until we trace down */ + /* lockups. locate 'html' in an xterm is a good */ + /* test case for an AGP GX2. */ + if (!S3_ViRGE_GX2_SERIES(ps3v->Chipset)) + { + + + /* CPU to screen color expansion */ + infoPtr->CPUToScreenColorExpandFillFlags = ROP_NEEDS_SOURCE | CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING; - if(ps3v->AccelFlags & MONO_TRANS_BUG) - infoPtr->CPUToScreenColorExpandFillFlags |= NO_TRANSPARENCY; + if(ps3v->AccelFlags & MONO_TRANS_BUG) + infoPtr->CPUToScreenColorExpandFillFlags |= NO_TRANSPARENCY; - infoPtr->ColorExpandRange = 0x8000; - infoPtr->ColorExpandBase = ps3v->MapBaseDense; - infoPtr->SetupForCPUToScreenColorExpandFill = + infoPtr->ColorExpandRange = 0x8000; + infoPtr->ColorExpandBase = ps3v->MapBaseDense; + infoPtr->SetupForCPUToScreenColorExpandFill = S3VSetupForCPUToScreenColorExpand; - infoPtr->SubsequentCPUToScreenColorExpandFill = + infoPtr->SubsequentCPUToScreenColorExpandFill = S3VSubsequentCPUToScreenColorExpand; - + } /* if(!GX2...) */ + + /* Image Writes */ infoPtr->ImageWriteFlags = ROP_NEEDS_SOURCE | NO_TRANSPARENCY | @@ -160,11 +175,20 @@ disable it on alphas */ /* Lines */ +#if 0 + /* Bresenham lines are broken when passed through fb to xaa + so I pulled all the line functions. This shouldn't hurt us + a whole lot, since the Subsequent..Bresen stuff doesn't have + any hardware accel yet anyway... And xaa will do horiz/vert + lines with the rect fill (like we are doing here) anyway. + KJB 9/11/00 + */ infoPtr->SetupForSolidLine = S3VSetupForSolidFill; infoPtr->SubsequentSolidHorVertLine = S3VSubsequentSolidHorVertLine; infoPtr->SubsequentSolidBresenhamLine = S3VSubsequentSolidBresenhamLine; infoPtr->PolySegmentThinSolid = S3VPolySegmentThinSolidWrapper; infoPtr->PolylinesThinSolid = S3VPolylinesThinSolidWrapper; +#endif #endif /* !__alpha__ */ @@ -563,6 +587,7 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); } @@ -582,6 +607,7 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); S3VWriteMask((CARD32*)ps3v->MapBaseDense, dwords); } @@ -644,6 +670,7 @@ WAITFIFO(3); OUTREG(RWIDTH_HEIGHT, (w << 16) | h); OUTREG(RSRC_XY, (x1 << 16) | y1); + WAITCMD(); OUTREG(RDEST_XY, (x2 << 16) | y2); } @@ -704,6 +731,7 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); } @@ -723,6 +751,7 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); S3VWriteMask((CARD32*)ps3v->MapBaseDense, dwords); @@ -779,10 +808,10 @@ S3VPtr ps3v = S3VPTR(pScrn); CHECK_DEST_BASE(y,h); - WAITFIFO(3); OUTREG(CLIP_L_R, ((x + skipleft) << 16) | 0xffff); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); } @@ -833,6 +862,7 @@ WAITFIFO(3); OUTREG(CLIP_L_R, ((x + skipleft) << 16) | 0xffff); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); } @@ -841,6 +871,9 @@ | Lines | \***********/ + +#if 0 /* Some line funcs are disabled at the moment */ + static void S3VPolylinesThinSolidWrapper( DrawablePtr pDraw, @@ -852,6 +885,8 @@ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); S3VPtr ps3v = S3VPTR(infoRec->pScrn); ps3v->CurrentGC = pGC; + /* fb support */ + ps3v->CurrentDrawable = pDraw; if(infoRec->NeedToSync) S3VAccelSync(infoRec->pScrn); XAAPolyLines(pDraw, pGC, mode, npt, pPts); @@ -867,11 +902,15 @@ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); S3VPtr ps3v = S3VPTR(infoRec->pScrn); ps3v->CurrentGC = pGC; + /* fb support */ + ps3v->CurrentDrawable = pDraw; if(infoRec->NeedToSync) S3VAccelSync(infoRec->pScrn); XAAPolySegment(pDraw, pGC, nseg, pSeg); } +#endif + static void S3VSubsequentSolidHorVertLine( ScrnInfoPtr pScrn, @@ -891,6 +930,7 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); } @@ -913,19 +953,21 @@ WAITFIFO(2); OUTREG(RWIDTH_HEIGHT, ((w - 1) << 16) | h); + WAITCMD(); OUTREG(RDEST_XY, (x << 16) | y); S3VWriteMask((CARD32*)ps3v->MapBaseDense, dwords); } +#if 0 /* Line funcs are disabled at the moment */ + static void (*LineFuncs[3])() = { cfbBresS, cfb16BresS, cfb24BresS }; - static void S3VSubsequentSolidBresenhamLine( ScrnInfoPtr pScrn, @@ -936,12 +978,59 @@ S3VPtr ps3v = S3VPTR(pScrn); cfbPrivGCPtr devPriv; int Bpp = pScrn->bitsPerPixel >> 3; + + if( ps3v->UseFB ) + { +#if 1 + /* +void +fbBres (DrawablePtr pDrawable, + GCPtr pGC, + int dashOffset, + int signdx, + int signdy, + int axis, + int x1, + int y1, + int e, + int e1, + int e3, + int len) + + from cfb, e3 = e2-e1. + for the cfb call e2 = dmin - dmaj + e1 = dmin + e3 = e2-e1 = dmin-dmaj-dmin + */ + + + fbBres(ps3v->CurrentDrawable, ps3v->CurrentGC, 0, + (octant & XDECREASING) ? -1 : 1, + (octant & YDECREASING) ? -1 : 1, + (octant & YMAJOR) ? Y_AXIS : X_AXIS, + /* x, y, dmin + e, dmin, dmin-dmaj, len); */ + x, y, dmin + e, dmin, -dmaj, len); +#endif +#if 0 + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Bresenham dmaj=%i, -dmaj=%i, -1*dmaj=%i.\n", + dmaj, -dmaj, -1*dmaj ); +#endif + + } + else + { + devPriv = cfbGetGCPrivate(ps3v->CurrentGC); - devPriv = cfbGetGCPrivate(ps3v->CurrentGC); + /* you could trap for lines you could do here and accelerate them */ - /* you could trap for lines you could do here and accelerate them */ + /* + * void + * cfbBresS(rop, and, xor, addrl, nlwidth, signdx, signdy, axis, + * x1, y1, e, e1, e2, len) + */ - (*LineFuncs[Bpp - 1]) + (*LineFuncs[Bpp - 1]) (devPriv->rop, devPriv->and, devPriv->xor, (unsigned long*)ps3v->FBBase, (pScrn->displayWidth * Bpp) >> LOG2_BYTES_PER_SCANLINE_PAD, @@ -949,8 +1038,41 @@ (octant & YDECREASING) ? -1 : 1, (octant & YMAJOR) ? Y_AXIS : X_AXIS, x, y, dmin + e, dmin, dmin - dmaj, len); + } /*if(fb)*/ } +#endif +void +S3VWaitFifoGX2(S3VPtr ps3v, int slots ) +{ + if(ps3v->NoPCIRetry) + while(((INREG(SUBSYS_STAT_REG) >> 9) & 0x60) < slots){} +} + + + +void +S3VWaitFifoMain(S3VPtr ps3v, int slots ) +{ + if(ps3v->NoPCIRetry) + while(((INREG(SUBSYS_STAT_REG) >> 8) & 0x1f) < slots){} +} + + +void +S3VWaitCmdGX2(S3VPtr ps3v) +{ + while(((INREG(ADV_FUNC_CNTR) >> 6) & 0x1f) != 16){} +} + + +void +S3VWaitDummy(S3VPtr ps3v) +{ + /* do nothing */ +} + +/*EOF*/ Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c:1.62 xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c:1.70 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c:1.62 Fri Jun 30 13:15:12 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c Wed Dec 13 19:55:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.62 2000/06/30 17:15:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.70 2000/12/14 00:55:25 dawes Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -29,9 +29,6 @@ #include "xf86RAC.h" #include "xf86DDC.h" -#if 0 -#include "xf86int10.h" -#endif #include "vbe.h" /* Needed by the Shadow Framebuffer */ @@ -61,10 +58,6 @@ #include "extensions/dpms.h" #endif /* DPMSExtension */ -#ifdef XvExtension -#include "xf86xv.h" -#endif - /* * Internals */ @@ -110,6 +103,8 @@ int flags); #endif static Bool S3Vddc1(int scrnIndex); +static Bool S3Vddc2(int scrnIndex); + static unsigned int S3Vddc1Read(ScrnInfoPtr pScrn); static void S3VProbeDDC(ScrnInfoPtr pScrn, int index); @@ -121,9 +116,9 @@ #define S3VIRGE_NAME "S3VIRGE" #define S3VIRGE_DRIVER_NAME "s3virge" -#define S3VIRGE_VERSION_NAME "1.2.0" +#define S3VIRGE_VERSION_NAME "1.5.0" #define S3VIRGE_VERSION_MAJOR 1 -#define S3VIRGE_VERSION_MINOR 2 +#define S3VIRGE_VERSION_MINOR 5 #define S3VIRGE_PATCHLEVEL 0 #define S3VIRGE_DRIVER_VERSION ((S3VIRGE_VERSION_MAJOR << 24) | \ (S3VIRGE_VERSION_MINOR << 16) | \ @@ -215,7 +210,8 @@ OPTION_SWCURSOR, OPTION_HWCURSOR, OPTION_SHADOW_FB, - OPTION_ROTATE + OPTION_ROTATE, + OPTION_FB_DRAW } S3VOpts; static OptionInfoRec S3VOptions[] = @@ -241,6 +237,7 @@ { OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_FB_DRAW, "UseFB", OPTV_BOOLEAN, {0}, TRUE }, {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -319,6 +316,15 @@ NULL }; +static const char *fbSymbols[] = { + "fbScreenInit", + "fbBres", +#ifdef RENDER + "fbPictureInit", +#endif + NULL +}; + #ifdef XFree86LOADER static const char *int10Symbols[] = { @@ -328,19 +334,18 @@ }; static const char *cfbSymbols[] = { -#if 1 "cfbScreenInit", "cfb16ScreenInit", "cfb24ScreenInit", "cfb24_32ScreenInit", "cfb32ScreenInit", + "cfBresS", "cfb16BresS", "cfb24BresS", -#endif + "cfb32BresS", NULL }; - static MODULESETUPPROTO(s3virgeSetup); static XF86ModuleVersionInfo S3VVersRec = @@ -385,7 +390,8 @@ */ LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, - int10Symbols, vbeSymbols, shadowSymbols, NULL); + int10Symbols, vbeSymbols, shadowSymbols, + fbSymbols, NULL); /* * The return value must be non-NULL on success even though there @@ -490,7 +496,7 @@ S3VProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -515,9 +521,7 @@ numDevSections, drv, &usedChips); /* Free it since we don't need that list after this */ - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -852,7 +856,19 @@ "HW cursor not supported with \"rotate\".\n"); ps3v->hwcursor = FALSE; } - + + if (xf86IsOptionSet(S3VOptions, OPTION_FB_DRAW)) + { + if (xf86GetOptValBool(S3VOptions, OPTION_FB_DRAW ,&ps3v->UseFB)) + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using %s.\n", + ps3v->UseFB ? "fb (not cfb)" : "cfb (not fb)"); + } + else + { + ps3v->UseFB = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Using fb.\n"); + } + /* Find the PCI slot for this screen */ /* * XXX Ignoring the Type list for now. It might be needed when @@ -974,16 +990,7 @@ && ((pMon = xf86PrintEDID(vbeDoEDID(ps3v->pVbe, NULL))) != NULL)) xf86SetDDCproperties(pScrn,pMon); else if (!S3Vddc1(pScrn->scrnIndex)) { - if ( xf86LoadSubModule(pScrn, "i2c") ) { - xf86LoaderReqSymLists(i2cSymbols,NULL); - if (S3V_I2CInit(pScrn)) { - CARD32 tmp = (INREG(DDC_REG)); - OUTREG(DDC_REG,(tmp | 0x13)); - xf86SetDDCproperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex,ps3v->I2C))); - OUTREG(DDC_REG,tmp); - } - } + S3Vddc2(pScrn->scrnIndex); } } if (ps3v->pVbe) @@ -1431,7 +1438,7 @@ /* (all depth 24 modes) */ /* This should never happen... we */ /* checked it before ValidateModes */ - if ( (pScrn->depth == 24) && + if ( ((pScrn->depth == 24) || (pScrn->depth == 16)) && ((pScrn->bitsPerPixel/8) * pScrn->virtualX > 4095) ) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Virtual width to large for ViRGE\n"); S3VFreeRec(pScrn); @@ -1439,36 +1446,48 @@ } /* Load bpp-specific modules */ - switch (pScrn->bitsPerPixel) { - case 8: - mod = "cfb"; - reqSym = "cfbScreenInit"; - break; - case 16: - mod = "cfb16"; - reqSym = "cfb16ScreenInit"; - break; - case 24: - if (pix24bpp == 24) { + if( ps3v->UseFB ) + { + if( xf86LoadSubModule(pScrn, "fb") == NULL ) + { + S3VFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(fbSymbols, NULL); + } + else + { + switch (pScrn->bitsPerPixel) { + case 8: + mod = "cfb"; + reqSym = "cfbScreenInit"; + break; + case 16: + mod = "cfb16"; + reqSym = "cfb16ScreenInit"; + break; + case 24: + if (pix24bpp == 24) { mod = "cfb24"; reqSym = "cfb24ScreenInit"; - } else { + } else { mod = "xf24_32bpp"; reqSym = "cfb24_32ScreenInit"; + } + break; + case 32: + mod = "cfb32"; + reqSym = "cfb32ScreenInit"; + break; } - break; - case 32: - mod = "cfb32"; - reqSym = "cfb32ScreenInit"; - break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - S3VFreeRec(pScrn); - return FALSE; - } + if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { + S3VFreeRec(pScrn); + return FALSE; + } - xf86LoaderReqSymbols(reqSym, NULL); - + xf86LoaderReqSymbols(reqSym, NULL); + } + /* Load XAA if needed */ if (!ps3v->NoAccel || ps3v->hwcursor ) { if (!xf86LoadSubModule(pScrn, "xaa")) { @@ -1494,7 +1513,27 @@ } xf86LoaderReqSymLists(shadowSymbols, NULL); } - + + /* Setup WAITFIFO() for accel and ModeInit() */ + /* Needs to be done prior to first ModeInit call */ + /* and any accel activity. */ + switch(ps3v->Chipset) + { + /* GX2_SERIES chips, GX2 & TRIO_3D_2X */ + case S3_ViRGE_GX2: + case S3_TRIO_3D_2X: + ps3v->pWaitFifo = S3VWaitFifoGX2; + ps3v->pWaitCmd = S3VWaitCmdGX2; + break; + case S3_ViRGE: + case S3_ViRGE_VX: + default: + ps3v->pWaitFifo = S3VWaitFifoMain; + /* Do nothing... */ + ps3v->pWaitCmd = S3VWaitDummy; + break; + } + return TRUE; } @@ -1521,14 +1560,6 @@ #ifdef unmap_always S3VMapMem(pScrn); #endif - #if 0 - /* todo - KJB - cep */ - /* New pointer mapping means we need to call */ - /* cfb...Init again and anything else required */ - /* to notify the upper layers of the change. */ - if( !S3VInternalScreenInit(scrnIndex, pScreen) ) - return FALSE; - #endif S3VSave(pScrn); return S3VModeInit(pScrn, pScrn->currentMode); } @@ -1671,7 +1702,7 @@ VGAOUT8(vgaCRIndex, 0x33); save->CR33 = VGAIN8(vgaCRReg); if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { VGAOUT8(vgaCRIndex, 0x85); save->CR85 = VGAIN8(vgaCRReg); @@ -1680,6 +1711,19 @@ VGAOUT8(vgaCRIndex, 0x86); save->CR86 = VGAIN8(vgaCRReg); } + if (S3_ViRGE_GX2_SERIES(ps3v->Chipset) || + S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { + VGAOUT8(vgaCRIndex, 0x7B); + save->CR7B = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x7D); + save->CR7D = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x87); + save->CR87 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x92); + save->CR92 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x93); + save->CR93 = VGAIN8(vgaCRReg); + } if (ps3v->Chipset == S3_ViRGE_DXGX || S3_ViRGE_GX2_SERIES(ps3v->Chipset) || S3_ViRGE_MX_SERIES(ps3v->Chipset)) { VGAOUT8(vgaCRIndex, 0x90); @@ -1757,7 +1801,7 @@ /* Now save Memory Interface Unit registers */ if( S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { /* No MMPR regs on MX & GX2 */ } @@ -1912,7 +1956,6 @@ VGAOUT8(vgaCRIndex, 0x6d); VGAOUT8(vgaCRReg, restore->CR6D); - /* Restore the desired video mode with CR67 */ VGAOUT8(vgaCRIndex, 0x67); @@ -1953,7 +1996,7 @@ VGAOUT8(vgaCRIndex, 0x33); VGAOUT8(vgaCRReg, restore->CR33); if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { VGAOUT8(vgaCRIndex, 0x85); VGAOUT8(vgaCRReg, restore->CR85); @@ -1962,6 +2005,18 @@ VGAOUT8(vgaCRIndex, 0x86); VGAOUT8(vgaCRReg, restore->CR86); } + if (ps3v->Chipset == S3_ViRGE_GX2) { + VGAOUT8(vgaCRIndex, 0x7B); + VGAOUT8(vgaCRReg, restore->CR7B); + VGAOUT8(vgaCRIndex, 0x7D); + VGAOUT8(vgaCRReg, restore->CR7D); + VGAOUT8(vgaCRIndex, 0x87); + VGAOUT8(vgaCRReg, restore->CR87); + VGAOUT8(vgaCRIndex, 0x92); + VGAOUT8(vgaCRReg, restore->CR92); + VGAOUT8(vgaCRIndex, 0x93); + VGAOUT8(vgaCRReg, restore->CR93); + } if (ps3v->Chipset == S3_ViRGE_DXGX || S3_ViRGE_GX2_SERIES(ps3v->Chipset) || S3_ViRGE_MX_SERIES(ps3v->Chipset)) { VGAOUT8(vgaCRIndex, 0x90); @@ -2069,7 +2124,7 @@ VerticalRetraceWait(); if (S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { VGAOUT8(vgaCRIndex, 0x85); /* primary stream threshold */ @@ -2080,7 +2135,7 @@ OUTREG(FIFO_CONTROL_REG, restore->MMPR0); } if( !( S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) )) { WaitIdle(); /* Don't ask... */ OUTREG(MIU_CONTROL_REG, restore->MMPR1); @@ -2112,7 +2167,7 @@ } vgaHWProtect(pScrn, FALSE); - + return; } @@ -2378,11 +2433,17 @@ if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; + + if (!miSetPixmapDepths ()) + return FALSE; } else { if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; + + if (!miSetPixmapDepths ()) + return FALSE; } ret = S3VInternalScreenInit(scrnIndex, pScreen); @@ -2422,14 +2483,7 @@ miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); - /* Problem with accel appears to crash GX2 on mouse moves */ - /* re-enable this when fixed. */ - if( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) - {} - else - { - xf86SetSilkenMouse(pScreen); - } + xf86SetSilkenMouse(pScreen); /* hardware cursor needs to wrap this layer */ S3VDGAInit(pScreen); @@ -2495,7 +2549,7 @@ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DPMS initialization failed!\n"); #endif -#ifdef XvExtension +#ifndef XvExtension { XF86VideoAdaptorPtr *ptr; int n; @@ -2505,6 +2559,8 @@ xf86XVScreenInit(pScreen, ptr, n); } } +#else + S3VInitVideo(pScreen); #endif /* Report any unused options (only for the first generation) */ @@ -2557,46 +2613,74 @@ * pScreen fields. */ - switch (pScrn->bitsPerPixel) { - case 8: + if( ps3v->UseFB ) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using FB\n"); + + switch (pScrn->bitsPerPixel) + { + case 8: + case 16: + case 24: + ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Internal error: invalid bpp (%d) in S3VScreenInit\n", + pScrn->bitsPerPixel); + ret = FALSE; + break; + } +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using CFB\n"); + switch (pScrn->bitsPerPixel) { + case 8: ret = cfbScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth); break; - case 16: + case 16: ret = cfb16ScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth); break; - case 24: - if (pix24bpp ==24) { - ret = cfb24ScreenInit(pScreen, FBStart, + case 24: + if (pix24bpp ==24) { + ret = cfb24ScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth); - } else { - ret = cfb24_32ScreenInit(pScreen, FBStart, + } else { + ret = cfb24_32ScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth); - } + } break; - case 32: + case 32: ret = cfb32ScreenInit(pScreen, FBStart, width,height, pScrn->xDpi, pScrn->yDpi, displayWidth); break; - default: + default: xf86DrvMsg(scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) in S3VScreenInit\n", pScrn->bitsPerPixel); ret = FALSE; break; - } /*switch*/ - + } /*switch*/ + } /*if(fb)*/ return ret; } @@ -2674,10 +2758,10 @@ VGAOUT8(vgaCRIndex, 0x3a); tmp = VGAIN8(vgaCRReg); if( S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { if(ps3v->pci_burst) - new->CR3A = (tmp & 0x78) | 0x10; /* ENH 256, PCI burst */ + new->CR3A = (tmp & 0x38) | 0x10; /* ENH 256, PCI burst */ else new->CR3A = tmp | 0x90; /* ENH 256, no PCI burst! */ } @@ -2707,8 +2791,17 @@ new->CR63 = 0x09; } else { - new->CR66 = 0x89; - new->CR63 = 0; + new->CR66 = 0x89; + /* Set display fifo */ + if( S3_ViRGE_GX2_SERIES(ps3v->Chipset) || + S3_ViRGE_MX_SERIES(ps3v->Chipset) ) + { + new->CR63 = 0x08; + } + else + { + new->CR63 = 0; + } } /* Now set linear addr. registers */ @@ -2831,6 +2924,7 @@ /* most modes don't need STREAMS */ /* processor, preset FALSE */ + /* support for XVideo needs streams, so added it to some modes */ ps3v->NeedSTREAMS = FALSE; if(ps3v->Chipset == S3_ViRGE_VX){ @@ -2856,24 +2950,24 @@ S3VCommonCalcClock(dclk, 1, 1, 31, 0, 4, 220000, 440000, &new->SR13, &new->SR12); - } + } /* end VX if() */ else if (S3_ViRGE_GX2_SERIES(ps3v->Chipset) || S3_ViRGE_MX_SERIES(ps3v->Chipset)) { if (pScrn->bitsPerPixel == 8) new->CR67 = 0x00; else if (pScrn->bitsPerPixel == 16) { + /* XV support needs STREAMS in depth 16 */ + ps3v->NeedSTREAMS = TRUE; + S3VInitSTREAMS(pScrn, new->STREAMS, mode); if (pScrn->weight.green == 5) - new->CR67 = 0x30; /* 15bpp */ + new->CR67 = 0x30 | 0x4; /* 15bpp */ else - new->CR67 = 0x50; /* 16bpp */ + new->CR67 = 0x50 | 0x4; /* 16bpp */ } - else if ((pScrn->bitsPerPixel == 24) /* || (pScrn->bitsPerPixel == 32) */ ) { - new->CR67 = 0x74; /* 24bpp, STREAMS */ + else if ((pScrn->bitsPerPixel == 24) ) { + new->CR67 = 0x74; /* 24bpp, STREAMS */ /* Flag STREAMS proc. required */ ps3v->NeedSTREAMS = TRUE; S3VInitSTREAMS(pScrn, new->STREAMS, mode); - /* MXTESTME - remove the next 2 lines completely */ - if( S3_ViRGE_MX_SERIES(ps3v->Chipset) ) - new->MMPR0 = 0xc098; /* Adjust FIFO slots */ } else if (pScrn->bitsPerPixel == 32) { new->CR67 = 0xd0; /* 32bpp */ @@ -2933,7 +3027,7 @@ new->SR29 = ndiv >> 7; new->SR12 = (ndiv & 0x1f) | ((ndiv & 0x60) << 1); } - } + } /* end GX2 or MX if() */ else if(S3_TRIO_3D_SERIES(ps3v->Chipset)) { new->SR0F = 0x00; if (pScrn->bitsPerPixel == 8) { @@ -2978,7 +3072,7 @@ } S3VCommonCalcClock(dclk, 1, 1, 31, 0, 4, 230000, 460000, &new->SR13, &new->SR12); - } + } /* end TRIO_3D if() */ else { /* Is this correct for DX/GX as well? */ if (pScrn->bitsPerPixel == 8) { if(dclk > 80000) { /* We need pixmux */ @@ -2991,14 +3085,21 @@ new->CR67 = 0x30; /* 15bpp */ } else if (pScrn->bitsPerPixel == 16) { - new->CR67 = 0x50; + new->CR67 = 0x50 | 0x0c; + /* Flag STREAMS proc. required */ + /* XV support needs STREAMS in depth 16 */ + ps3v->NeedSTREAMS = TRUE; + S3VInitSTREAMS(pScrn, new->STREAMS, mode); + /*new->MMPR0 = 0xc000; / Adjust FIFO slots */ + new->MMPR0 = 0x107c02; /* Adjust FIFO slots, overlay */ } else if (pScrn->bitsPerPixel == 24) { new->CR67 = 0xd0 | 0x0c; /* Flag STREAMS proc. required */ ps3v->NeedSTREAMS = TRUE; S3VInitSTREAMS(pScrn, new->STREAMS, mode); - new->MMPR0 = 0xc000; /* Adjust FIFO slots */ + /*new->MMPR0 = 0xc000; / Adjust FIFO slots */ + new->MMPR0 = 0x107c02; /* Adjust FIFO slots, overlay */ } else if (pScrn->bitsPerPixel == 32) { new->CR67 = 0xd0 | 0x0c; @@ -3034,10 +3135,17 @@ else { new->CR42 = 0x00; } - - /* Set display fifo */ - new->CR34 = 0x10; + if(S3_ViRGE_GX2_SERIES(ps3v->Chipset) || + S3_ViRGE_MX_SERIES(ps3v->Chipset) ) + { + new->CR34 = 0; + } + else + { + /* Set display fifo */ + new->CR34 = 0x10; + } /* Now we adjust registers for extended mode timings */ /* This is taken without change from the accel/s3_virge code */ @@ -3082,11 +3190,20 @@ new->CR33 = 0x20; if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset) - /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ) + /* MXTESTME */ || S3_ViRGE_MX_SERIES(ps3v->Chipset) ) { - new->CR85 = 0x1f; /* avoid sreen flickering */ + new->CR85 = 0x12; /* avoid sreen flickering */ /* by increasing FIFO filling, larger # fills FIFO from memory earlier */ /* on GX2 this affects all depths, not just those running STREAMS. */ + /* new, secondary stream settings. */ + new->CR87 = 0x10; + /* gx2 - set up in XV init code */ + new->CR92 = 0x00; + new->CR93 = 0x00; + /* gx2 primary mclk timeout, def=0xb */ + new->CR7B = 0xb; + /* gx2 secondary mclk timeout, def=0xb */ + new->CR7D = 0xb; } if (ps3v->Chipset == S3_ViRGE_DXGX || S3_TRIO_3D_SERIES(ps3v->Chipset)) { new->CR86 = 0x80; /* disable DAC power saving to avoid bright left edge */ @@ -3262,14 +3379,22 @@ static void S3VInitSTREAMS(ScrnInfoPtr pScrn, unsigned int *streams, DisplayModePtr mode) { - if ( pScrn->bitsPerPixel == 24 ) { + PVERB5(" S3VInitSTREAMS\n"); + + switch (pScrn->bitsPerPixel) + { + case 16: + streams[0] = 0x05000000; + break; + case 24: /* data format 8.8.8 (24 bpp) */ streams[0] = 0x06000000; - } - else if (pScrn->bitsPerPixel == 32) { + break; + case 32: /* one more bit for X.8.8.8, 32 bpp */ streams[0] = 0x07000000; - } + break; + } /* NO chroma keying... */ streams[1] = 0x0; /* Secondary stream format KRGB-16 */ @@ -3288,14 +3413,21 @@ streams[7] = 0x0; /* Stride is 3 bytes for 24 bpp mode and */ /* 4 bytes for 32 bpp. */ - if ( pScrn->bitsPerPixel == 24 ) { - streams[8] = - pScrn->displayWidth * 3; - } - else { - streams[8] = - pScrn->displayWidth * 4; - } + switch(pScrn->bitsPerPixel) + { + case 16: + streams[8] = + pScrn->displayWidth * 2; + break; + case 24: + streams[8] = + pScrn->displayWidth * 3; + break; + case 32: + streams[8] = + pScrn->displayWidth * 4; + break; + } /* Choose fbaddr0 as stream source. */ streams[9] = 0x0; streams[10] = 0x0; @@ -3683,6 +3815,25 @@ return success; } +static Bool +S3Vddc2(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + S3VPtr ps3v = S3VPTR(pScrn); + + if ( xf86LoadSubModule(pScrn, "i2c") ) { + xf86LoaderReqSymLists(i2cSymbols,NULL); + if (S3V_I2CInit(pScrn)) { + CARD32 tmp = (INREG(DDC_REG)); + OUTREG(DDC_REG,(tmp | 0x13)); + xf86SetDDCproperties(pScrn,xf86PrintEDID( + xf86DoEDID_DDC2(pScrn->scrnIndex,ps3v->I2C))); + OUTREG(DDC_REG,tmp); + return TRUE; + } + } + return FALSE; +} static void S3VProbeDDC(ScrnInfoPtr pScrn, int index) Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h:1.9 xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h:1.9 Fri Mar 31 15:13:33 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h Tue Nov 28 15:59:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h,v 1.9 2000/03/31 20:13:33 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h,v 1.11 2000/11/28 20:59:18 dawes Exp $ */ /* Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. @@ -33,6 +33,7 @@ /* miscellaneous registers */ #define SUBSYS_STAT_REG 0x8504 +#define ADV_FUNC_CNTR 0x850c /* memory port controller registers */ #define FIFO_CONTROL_REG 0x8200 @@ -95,9 +96,10 @@ #define MAXLOOP 0x0fffff /* timeout value for engine waits, 0.5 secs */ - -#define WAITFIFO(n) if(ps3v->NoPCIRetry) \ - while(((INREG(SUBSYS_STAT_REG) >> 8) & 0x1f) < n){} +/* Switchable per chipset, must be initialized prior to a mode */ +/* switch! */ +#define WAITFIFO(n) ((*ps3v->pWaitFifo)(ps3v,n)) +#define WAITCMD() ((*ps3v->pWaitCmd)(ps3v)) #define WAITIDLE()\ do { int loop=0; mem_barrier(); \ Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c:1.2 --- /dev/null Mon Dec 18 14:31:03 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c Tue Nov 28 15:59:18 2000 @@ -0,0 +1,1154 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_xv.c,v 1.2 2000/11/28 20:59:18 dawes Exp $ */ +/* +Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the XFree86 Project shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from the XFree86 Project. +*/ + +/* + * s3v_xv.c + * X Video Extension support + * + * S3 ViRGE driver + * + * 7/2000 Kevin Brosius + * + * Useful references: + * X Video extension support -> xc/programs/hw/xfree86/common/xf86xv.c + * + */ + + + /* Most xf86 commons are already in s3v.h */ +#include "s3v.h" + +#if 0 +#define OFF_DELAY 250 /* milliseconds */ +#define FREE_DELAY 15000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#endif +#define CLIENT_VIDEO_ON 0x04 + +#define S3V_MAX_PORTS 1 + + +#ifndef XvExtension +void S3VInitVideo(ScreenPtr pScreen) {} +#else + +#if 0 +static void S3VInitOffscreenImages(ScreenPtr); +#endif + +static XF86VideoAdaptorPtr S3VAllocAdaptor(ScrnInfoPtr pScrn); +static XF86VideoAdaptorPtr S3VSetupImageVideoOverlay(ScreenPtr); +static int S3VSetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32, pointer); +static int S3VGetPortAttributeOverlay(ScrnInfoPtr, Atom ,INT32 *, pointer); + +#if 0 +static XF86VideoAdaptorPtr MGASetupImageVideoTexture(ScreenPtr); +static int MGASetPortAttributeTexture(ScrnInfoPtr, Atom, INT32, pointer); +static int MGAGetPortAttributeTexture(ScrnInfoPtr, Atom ,INT32 *, pointer); +#endif +static void S3VStopVideo(ScrnInfoPtr, pointer, Bool); +static void S3VQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, + unsigned int *, unsigned int *, pointer); +static int S3VPutImage(ScrnInfoPtr, short, short, short, short, short, + short, short, short, int, unsigned char*, short, + short, Bool, RegionPtr, pointer); +static int S3VQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, + unsigned short *, int *, int *); + +#if 0 +static void MGABlockHandler(int, pointer, pointer, pointer); +#endif + +static void S3VResetVideoOverlay(ScrnInfoPtr); + +#if 0 +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvContrast, xvColorKey; + +#endif /* 0 */ + +void S3VInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + S3VPtr ps3v = S3VPTR(pScrn); + int num_adaptors; + + if( + ((pScrn->bitsPerPixel == 24) || + (pScrn->bitsPerPixel == 16) + ) + && + ((ps3v->Chipset == S3_ViRGE_DXGX) || + /* S3_ViRGE_GX2_SERIES(ps3v->Chipset) || */ + (ps3v->Chipset == S3_ViRGE) + ) + && !ps3v->NoAccel + ) + { + #if 0 + if((pMga->Overlay8Plus24 /* || dualhead */ || pMga->TexturedVideo) && + (pScrn->bitsPerPixel != 24)) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using texture video\n"); + newAdaptor = MGASetupImageVideoTexture(pScreen); + pMga->TexturedVideo = TRUE; + } else { + #endif + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using overlay video\n"); + newAdaptor = S3VSetupImageVideoOverlay(pScreen); + + #if 0 + pMga->TexturedVideo = FALSE; + }*/ + + if(!pMga->Overlay8Plus24 /* && !dualhead */) + S3VInitOffscreenImages(pScreen); + pMga->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = MGABlockHandler; + #endif + } + + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[2] = +{ + { /* overlay limit */ + 0, + "XV_IMAGE", + 1024, 1024, + {1, 1} + }, + { /* texture limit */ + 0, + "XV_IMAGE", + 2046, 2046, + {1, 1} + } +}; + +#define NUM_FORMATS_OVERLAY 4 +#define NUM_FORMATS_TEXTURE 4 + +static XF86VideoFormatRec Formats[NUM_FORMATS_TEXTURE] = +{ + /*{15, TrueColor},*/ {16, TrueColor}, {24, TrueColor} /* , + {15, DirectColor}*/, {16, DirectColor}, {24, DirectColor} +}; + +#if 0 +#define NUM_ATTRIBUTES_OVERLAY 3 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES_OVERLAY] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, + {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} +}; +#endif + +#define NUM_IMAGES 3 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + /* As in mga, YV12 & I420 are converted to YUY2 on the fly by */ + /* copy over conversion. */ + XVIMAGE_YV12, + XVIMAGE_I420 + /* XVIMAGE_UYVY */ +}; + + + +static int +S3VSetPortAttributeOverlay( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ +#if 0 + MGAPtr pMga = MGAPTR(pScrn); + MGAPortPrivPtr pPriv = pMga->portPrivate; + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + if(attribute == xvBrightness) { + if((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; + OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | + (pPriv->contrast & 0xff)); + } else + if(attribute == xvContrast) { + if((value < 0) || (value > 255)) + return BadValue; + pPriv->contrast = value; + OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | + (pPriv->contrast & 0xff)); + } else + if(attribute == xvColorKey) { + pPriv->colorKey = value; + outMGAdac(0x55, (pPriv->colorKey & pScrn->mask.red) >> + pScrn->offset.red); + outMGAdac(0x56, (pPriv->colorKey & pScrn->mask.green) >> + pScrn->offset.green); + outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >> + pScrn->offset.blue); + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else +#endif + +return BadMatch; + +#if 0 + return Success; +#endif +} + +static int +S3VGetPortAttributeOverlay( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ +#if 0 + MGAPtr pMga = MGAPTR(pScrn); + MGAPortPrivPtr pPriv = pMga->portPrivate; + + if(attribute == xvBrightness) { + *value = pPriv->brightness; + } else + if(attribute == xvContrast) { + *value = pPriv->contrast; + } else + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else +#endif + +return BadMatch; + +#if 0 + return Success; +#endif +} + + + +static void +S3VQueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; + +#if 0 + /* Only support scaling up, no down scaling. */ + /* This doesn't seem to work (at least for XMovie) */ + /* and the DESIGN doc says this is illegal anyway... */ + if( drw_w < vid_w ) *p_w = vid_w; + if( drw_h < vid_h ) *p_h = vid_h; +#endif +} + + + +static void +S3VCopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w +){ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + + +static void +S3VCopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w +){ + CARD32 *dst = (CARD32*)dst1; + int i, j; + + dstPitch >>= 2; + w >>= 1; + + for(j = 0; j < h; j++) { + for(i = 0; i < w; i++) { + dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + dst += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + + + +static void +S3VResetVideoOverlay(ScrnInfoPtr pScrn) +{ + /* empty for ViRGE at the moment... */ +#if 0 + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + + MGAPtr pMga = MGAPTR(pScrn); + MGAPortPrivPtr pPriv = pMga->portPrivate; + + CHECK_DMA_QUIESCENT(pMga, pScrn); + + outMGAdac(0x51, 0x01); /* keying on */ + outMGAdac(0x52, 0xff); /* full mask */ + outMGAdac(0x53, 0xff); + outMGAdac(0x54, 0xff); + + outMGAdac(0x55, (pPriv->colorKey & pScrn->mask.red) >> + pScrn->offset.red); + outMGAdac(0x56, (pPriv->colorKey & pScrn->mask.green) >> + pScrn->offset.green); + outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >> + pScrn->offset.blue); +#endif + +#if 0 + OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) | + (pPriv->contrast & 0xff)); +#endif /*0*/ +} + + + +static XF86VideoAdaptorPtr +S3VAllocAdaptor(ScrnInfoPtr pScrn) +{ + XF86VideoAdaptorPtr adapt; + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv; + int i; + + if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) + return NULL; + + if(!(pPriv = xcalloc(1, sizeof(S3VPortPrivRec) + + (sizeof(DevUnion) * S3V_MAX_PORTS)))) + { + xfree(adapt); + return NULL; + } + + adapt->pPortPrivates = (DevUnion*)(&pPriv[1]); + + for(i = 0; i < S3V_MAX_PORTS; i++) + adapt->pPortPrivates[i].val = i; + +#if 0 + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvContrast = MAKE_ATOM("XV_CONTRAST"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); +#endif + + pPriv->colorKey = + (1 << pScrn->offset.red) | + (1 << pScrn->offset.green) | + (((pScrn->mask.blue >> pScrn->offset.blue) - 1) << pScrn->offset.blue); + +#if 0 + pPriv->brightness = 0; + pPriv->contrast = 128; +#endif + + pPriv->videoStatus = 0; + pPriv->lastPort = -1; + + ps3v->adaptor = adapt; + ps3v->portPrivate = pPriv; + + return adapt; +} + + + + + +static XF86VideoAdaptorPtr +S3VSetupImageVideoOverlay(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + S3VPtr ps3v = S3VPTR(pScrn); + XF86VideoAdaptorPtr adapt; + + adapt = S3VAllocAdaptor(pScrn); + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "S3 ViRGE Backend Scaler"; + adapt->nEncodings = 1; + adapt->pEncodings = &DummyEncoding[0]; + adapt->nFormats = NUM_FORMATS_OVERLAY; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pAttributes = NULL /*Attributes*/; +#if 0 + if (pMga->Chipset == PCI_CHIP_MGAG400) { + adapt->nImages = 4; + adapt->nAttributes = 3; + } else { +#endif + adapt->nImages = 3; + adapt->nAttributes = 0; + /* }*/ + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = S3VStopVideo; + /* Empty Attrib functions - required anyway */ + adapt->SetPortAttribute = S3VSetPortAttributeOverlay; + adapt->GetPortAttribute = S3VGetPortAttributeOverlay; + adapt->QueryBestSize = S3VQueryBestSize; + adapt->PutImage = S3VPutImage; + adapt->QueryImageAttributes = S3VQueryImageAttributes; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &(ps3v->portPrivate->clip), NullBox, 0); + + S3VResetVideoOverlay(pScrn); + + return adapt; +} + + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + + +/* S3VClipVideo - copied from MGAClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (x1, y1 + inclusive, x2, y2 exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +#define DummyScreen screenInfo.screens[0] + +static Bool +S3VClipVideo( + BoxPtr dst, + INT32 *x1, + INT32 *x2, + INT32 *y1, + INT32 *y2, + RegionPtr reg, + INT32 width, + INT32 height +){ + INT32 vscale, hscale, delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *x2 <<= 16; + *y1 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *x2 -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if(*x1 < 0) { + diff = (- *x1 + hscale - 1)/ hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + delta = *x2 - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + if(*x1 >= *x2) return FALSE; + + if(*y1 < 0) { + diff = (- *y1 + vscale - 1)/ vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + delta = *y2 - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } + if(*y1 >= *y2) return FALSE; + + if((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || + (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) + { + RegionRec clipReg; + REGION_INIT(DummyScreen, &clipReg, dst, 1); + REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); + REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; +} + + + +static void +S3VStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + + vgaHWPtr hwp = VGAHWPTR(pScrn); + /* S3VPtr ps3v = S3VPTR(pScrn);*/ + int vgaCRIndex, vgaCRReg, vgaIOBase; + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + +#if 0 + MGAPtr pMga = MGAPTR(pScrn); + MGAPortPrivPtr pPriv = pMga->portPrivate; + + if(pMga->TexturedVideo) return; +#endif + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) + { +#if 0 + /*OUTREG(MGAREG_BESCTL, 0);*/ + /*OUTREG(SSTREAM_CONTROL_REG, 0x02000000);*/ + + OUTREG(SSTREAM_CONTROL_REG, 0); + /*OUTREG(SSTREAM_STRIDE_REG, 0 );*/ + + /*OUTREG(K1_VSCALE_REG, 0 ); + OUTREG(K2_VSCALE_REG, 0 ); + */ + OUTREG(DDA_VERT_REG, 0 ); + + /*OUTREG(SSTREAM_START_REG, ((dstBox->x1 +1) << 16) | (dstBox->y1 +1)); + OUTREG(SSTREAM_WINDOW_SIZE_REG, 0); + */ +#endif + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + OUTREG(SSTREAM_CONTROL_REG, 0); + } + else + { + /* Primary over secondary */ + OUTREG(BLEND_CONTROL_REG, 0x01000000); + } + } + + if(pPriv->area) { + xf86FreeOffscreenArea(pPriv->area); + pPriv->area = NULL; + } + pPriv->videoStatus = 0; + } else { +#if 0 + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } +#endif + } +} + + + +static FBAreaPtr +S3VAllocateMemory( + ScrnInfoPtr pScrn, + FBAreaPtr area, + int numlines +){ + ScreenPtr pScreen; + FBAreaPtr new_area; + + if(area) { + if((area->box.y2 - area->box.y1) >= numlines) + return area; + + if(xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines)) + return area; + + xf86FreeOffscreenArea(area); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); + + if(!new_area) { + int max_w, max_h; + + xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0, + FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); + + if((max_w < pScrn->displayWidth) || (max_h < numlines)) + return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, + numlines, 0, NULL, NULL, NULL); + } + + return new_area; +} + + + +static void +S3VDisplayVideoOverlay( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, short height, + int pitch, + /* x,y src co-ordinates */ + int x1, int y1, int x2, int y2, + /* dst in BoxPtr format */ + BoxPtr dstBox, + /* src width and height */ + short src_w, short src_h, + /* dst width and height */ + short drw_w, short drw_h +){ + int tmp; + +#if 0 + CHECK_DMA_QUIESCENT(pMga, pScrn); +#endif + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + + vgaHWPtr hwp = VGAHWPTR(pScrn); + /* S3VPtr ps3v = S3VPTR(pScrn);*/ + int vgaCRIndex, vgaCRReg, vgaIOBase; + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + +#if 0 + /* got 64 scanlines to do it in */ + tmp = INREG(MGAREG_VCOUNT) + 64; + if(tmp > pScrn->currentMode->VDisplay) + tmp -= pScrn->currentMode->VDisplay; +#endif + + /* Reference at http://www.webartz.com/fourcc/ */ + /* Looks like ViRGE only supports YUY2 and Y211?, */ + /* listed as YUV-16 (4.2.2) and YUV (2.1.1) in manual. */ + +#if 0 + /* Only supporting modes we listed for the time being, */ + /* No, switching required... #if 0'd this out */ + + switch(id) { + case FOURCC_UYVY: + /* + FOURCC=0x59565955 + bpp=16 + YUV 4:2:2 (Y sample at every + pixel, U and V sampled at + every second pixel + horizontally on each line). A + macropixel contains 2 pixels + in 1 u_int32. + */ + + /* OUTREG(MGAREG_BESGLOBCTL, 0x000000c3 | (tmp << 16));*/ + break; + case FOURCC_YUY2: + /* + FOURCC=0x32595559 + bpp=16 + YUV 4:2:2 as for UYVY but + with different component + ordering within the u_int32 + macropixel. + + Supports YV12 & I420 by copy over conversion of formats to YUY2, + copied from mga driver. Thanks Mark! + */ + default: + /*OUTREG(MGAREG_BESGLOBCTL, 0x00000083 | (tmp << 16));*/ + /* YUV-16 (4.2.2) Secondary stream */ + /* temp ... add DDA Horiz Accum. */ + /*OUTREG(SSTREAM_CONTROL_REG, 0x02000000); / YUV-16 */ + /* works for xvtest and suzi */ + /* OUTREG(SSTREAM_CONTROL_REG, 0x01000000); * YCbCr-16 * no scaling */ + + /* calc horizontal scale factor */ + tmp = drw_w / src_w; + if (drw_w == src_w) tmp = 0; + else if (tmp>=4) tmp =3; + else if (tmp>=2) tmp =2; + else tmp =1; + + /* YCbCr-16 */ + OUTREG(SSTREAM_CONTROL_REG, + tmp << 28 | 0x01000000 | + ((((src_w-1)<<1)-(drw_w-1)) & 0xfff) + ); + break; + } +#endif + + /* calc horizontal scale factor */ + if (drw_w == src_w) + tmp = 0; + else + tmp =2; + /* YCbCr-16 */ + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + OUTREG(SSTREAM_CONTROL_REG, + tmp << 28 | 0x05000000 | 0x800000 | + ((((src_w-1)<<1)-(drw_w-1)) & 0xfff) + ); + } + else + { + OUTREG(SSTREAM_CONTROL_REG, + tmp << 28 | 0x01000000 | + ((((src_w-1)<<1)-(drw_w-1)) & 0xfff) + ); + } + + OUTREG(SSTREAM_STRETCH_REG, + ((src_w - 1) & 0x7ff) | (((src_w-drw_w) & 0x7ff) << 16) + ); + + /* Color key on primary */ + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + /*OUTREG(BLEND_CONTROL_REG, 0x00000000)*/ + ; + } + else + { + OUTREG(BLEND_CONTROL_REG, 0x05000000); + } + + OUTREG(SSTREAM_FBADDR0_REG, offset & 0x3fffff ); + OUTREG(SSTREAM_STRIDE_REG, pitch & 0xfff ); + + OUTREG(K1_VSCALE_REG, src_h-1 ); + OUTREG(K2_VSCALE_REG, (src_h - drw_h) & 0x7ff ); + + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + /* enable vert interp. & bandwidth saving - gx2 */ + OUTREG(DDA_VERT_REG, (((~drw_h)-1) & 0xfff ) | + /* bw & vert interp */ + 0xc000 + /* no bw save 0x8000*/ + ); + } + else + { + OUTREG(DDA_VERT_REG, (((~drw_h)-1)) & 0xfff ); + } + + OUTREG(SSTREAM_START_REG, ((dstBox->x1 +1) << 16) | (dstBox->y1 +1)); + OUTREG(SSTREAM_WINDOW_SIZE_REG, + ( ((drw_w-1) << 16) | (drw_h ) ) & 0x7ff07ff + ); + + /*cep*/ + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + OUTREG(COL_CHROMA_KEY_CONTROL_REG, + /* color key ON */ + /*0xc0000000 | */ + /*0x40000000 | */ + 0x40000000 | + /* # bits to compare */ + ((pScrn->weight.red-1) << 24) | + + ((pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red) << + (16 + 8-pScrn->weight.red) | + + ((pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green) << + (8 + 8-pScrn->weight.green) | + + ((pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue) << + (8-pScrn->weight.blue) + ); + } + else + { + OUTREG(COL_CHROMA_KEY_CONTROL_REG, + /* color key ON */ + 0x10000000 | + /* # bits to compare */ + ((pScrn->weight.red-1) << 24) | + + ((pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red) << + (16 + 8-pScrn->weight.red) | + + ((pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green) << + (8 + 8-pScrn->weight.green) | + + ((pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue) << + (8-pScrn->weight.blue) + ); + } + + if ( S3_ViRGE_GX2_SERIES(ps3v->Chipset) ) + { + VGAOUT8(vgaCRIndex, 0x92); + VGAOUT8(vgaCRReg, (((pitch + 7) / 8) >> 8) | 0x80); + VGAOUT8(vgaCRIndex, 0x93); + VGAOUT8(vgaCRReg, (pitch + 7) / 8); + } + +} + + +static int +S3VPutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data +){ + S3VPtr ps3v = S3VPTR(pScrn); + S3VPortPrivPtr pPriv = ps3v->portPrivate; + INT32 x1, x2, y1, y2; + unsigned char *dst_start; + int pitch, new_h, offset, offset2=0, offset3=0; + int srcPitch, srcPitch2=0, dstPitch; + int top, left, npixels, nlines; + BoxRec dstBox; + CARD32 tmp; + static int once = 1; + static int once2 = 1; + + /* Clip */ + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if(!S3VClipVideo(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height)) + return Success; + + /*if(!pMga->TexturedVideo) {*/ + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + /*}*/ + + pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3; + + dstPitch = ((width << 1) + 15) & ~15; + new_h = ((dstPitch * height) + pitch - 1) / pitch; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + srcPitch = (width << 1); + break; + } + + if(!(pPriv->area = S3VAllocateMemory(pScrn, pPriv->area, new_h))) + return BadAlloc; + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + left <<= 1; + + offset = pPriv->area->box.y1 * pitch; + dst_start = ps3v->FBStart + offset + left + (top * dstPitch); + /*dst_start = pMga->FbStart + offset + left + (top * dstPitch);*/ + +#if 0 + if(pMga->TexturedVideo && pMga->AccelInfoRec->NeedToSync && + ((long)data != pPriv->lastPort)) + { + MGAStormSync(pScrn); + pMga->AccelInfoRec->NeedToSync = FALSE; + } +#endif + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + tmp = ((top >> 1) * srcPitch2) + (left >> 2); + offset2 += tmp; + offset3 += tmp; + if(id == FOURCC_I420) { + tmp = offset2; + offset2 = offset3; + offset3 = tmp; + } + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + S3VCopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, dst_start, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + once2 = 0; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((y2 + 0xffff) >> 16) - top; + S3VCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + once = 0; + break; + } + +#if 0 + if(pMga->TexturedVideo) { + pPriv->lastPort = (long)data; + MGADisplayVideoTexture(pScrn, id, offset, + REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes), + width, height, dstPitch, src_x, src_y, src_w, src_h, + drw_x, drw_y, drw_w, drw_h); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } else { +#endif + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + offset += left + (top * dstPitch); + S3VDisplayVideoOverlay(pScrn, id, offset, width, height, dstPitch, + x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + + pPriv->videoStatus = CLIENT_VIDEO_ON; +#if 0 + } + pMga->VideoTimerCallback = MGAVideoTimerCallback; +#endif + + return Success; +} + + +static int +S3VQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ +#if 0 + MGAPtr pMga = MGAPTR(pScrn); +#endif + int size, tmp; + +#if 0 + if(pMga->TexturedVideo) { + if(*w > 2046) *w = 2046; + if(*h > 2046) *h = 2046; + } else { +#endif + if(*w > 1024) *w = 1024; + if(*h > 1024) *h = 1024; +#if 0 + } +#endif + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) pitches[0] = size; + size *= *h; + if(offsets) offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} + + + +#endif /* !XvExtension */ + Index: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp:1.9 xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp:1.9 Tue Jun 13 22:13:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp Tue Dec 12 13:54:31 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp,v 1.9 2000/06/14 02:13:13 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp,v 1.12 2000/12/12 18:54:31 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH s3virge __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH s3virge __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME s3virge \- S3 ViRGE video driver .SH SYNOPSIS @@ -60,7 +60,7 @@ Please refer to XF86Config(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this driver. All options names are case and white space insensitive when -parsed by the server, for exmaple, "virge vx" and "VIRGEvx" are equivalent. +parsed by the server, for example, "virge vx" and "VIRGEvx" are equivalent. .PP The driver auto-detects the chipset type, but the following .B ChipSet @@ -147,6 +147,12 @@ Using it decreases performance, as it uses software emulation for drawing operations the video driver can accelerate with hardware. Default: acceleration is enabled. +.TP +.B "Option \*qUseFB\*q" +There are two framebuffer rendering methods. fb and cfb. Both are +available in the driver. fb is the newer and default method. To switch +back to cfb use this option with no, off or other negative parameter. +Default: on. .TP .BR "Option \*qfifo_aggressive " | " fifo_moderate " | " fifo_conservative\*q" alter the settings Index: xc/programs/Xserver/hw/xfree86/drivers/savage/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/Imakefile:1.2 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/Imakefile Sat Dec 2 10:30:48 2000 @@ -0,0 +1,73 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/Imakefile,v 1.2 2000/12/02 15:30:48 tsi Exp $ +/* + * + * Copyright 1995-1998 The XFree86 Project, Inc. + * + */ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = savage_driver.c \ + savage_accel.c \ + savage_cursor.c \ + savage_image.c \ + savage_shadow.c \ + savage_vbe.c + +OBJS = savage_driver.o \ + savage_accel.o \ + savage_cursor.o \ + savage_image.o \ + savage_shadow.o \ + savage_vbe.o + +DEFINES = -DPSZ=8 + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ + -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ + -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/rac -I$(XF86SRC)/int10 -I$(SERVERSRC)/render \ + -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ + -I$(EXTINCSRC) -I$(XF86OSSRC)/vbe -I$(XF86SRC)/shadowfb +#endif + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +NormalAsmObjectRule() + +ModuleObjectRule() +ObjectModuleTarget(savage, $(OBJS)) + +InstallObjectModule(savage,$(MODULEDIR),drivers) + +#if !defined(XF86DriverSDK) +CppManTarget(savage,) +InstallModuleManPage(savage) +#endif + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_accel.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_bci.h,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_cursor.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_driver.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_driver.h,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_image.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_regs.h,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_shadow.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_vbe.c,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage_vbe.h,$(DRIVERSDKDIR)/drivers/savage) +InstallDriverSDKNonExecFile(savage.cpp,$(DRIVERSDKDIR)/drivers/savage) + +InstallDriverSDKObjectModule(savage,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage.cpp:1.2 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage.cpp Mon Dec 11 15:18:25 2000 @@ -0,0 +1,96 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage.cpp,v 1.2 2000/12/11 20:18:25 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH SAVAGE __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +savage \- S3 Savage video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qsavage\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B savage +is an XFree86 driver for the S3 Savage family video accelerator chips. The +.B savage +driver supports PCI and AGP boards with the following chips: +.TP 16 +.BI Savage3D +(8a20 and 8a21) +.TP 16 +.B Savage4 +(8a22) +.TP 16 +.B Savage2000 +(9102) +.TP 16 +.B Savage/MX +(8c10 and 8c11) +.TP 16 +.B Savage/IX +(8c12 and 8c13) +.TP 16 +.B ProSavage PM133 +(8a25) +.TP 16 +.B ProSavage KM133 +(8a26) +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qHWCursor\*q \*q" boolean \*q +.TP +.BI "Option \*qSWCursor\*q \*q" boolean \*q +These two options interact to specify hardware or software cursor. If the +SWCursor option is specified, any HWCursor setting is ignored. Thus, either +\*qHWCursor off\*q or \*qSWCursor on\*q will force the use of the software +cursor. On Savage/MX and Savage/IX chips which are connected to LCDs, a +software cursor will be forced, because the Savage hardware cursor does not +correctly track the automatic panel expansion feature. +Default: hardware cursor. +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Disable or enable acceleration. Default: acceleration is enabled. +.TP +.BI "Option \*qRotate\*q \*qCW\*q" +.TP +.BI "Option \*qRotate\*q \*qCCW\*q" +Rotate the desktop 90 degrees clockwise or counterclockwise. This option +forces the ShadowFB option on, and disables acceleration. +Default: no rotation. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. See +shadowfb(__drivermansuffix__) for further information. This option +disables acceleration. Default: off. +.TP +.BI "Option \*qUseBIOS\*q \*q" boolean \*q +Enable or disable use of the video BIOS to change modes. Ordinarily, the +.B savage +driver tries to use the video BIOS to do mode switches. This generally +produces the best results with the mobile chips (/MX and /IX), since the BIOS +knows how to handle the critical but unusual timing requirements of the +various LCD panels supported by the chip. To do this, the driver searches +through the BIOS mode list, looking for the mode which most closely matches +the XF86Config mode line. Some purists find this scheme objectionable. If +you would rather have the +.B savage +driver use your mode line timing exactly, turn off the UseBios option. +Default: on (use the BIOS). +.SH FILES +savage_drv.o +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +Authors include Tim Roberts (timr@probo.com) and Ani Joshi (ajoshi@unixbox.com) +for the 4.0 version, and Tim Roberts and S. Marineau for the 3.3 driver from +which this was derived. Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_accel.c:1.4 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_accel.c Thu Dec 7 15:26:22 2000 @@ -0,0 +1,1260 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_accel.c,v 1.4 2000/12/07 20:26:22 dawes Exp $ */ + +/* + * + * Copyright 1995-1997 The XFree86 Project, Inc. + * + */ + +/* + * The accel file for the Savage driver. + * + * Created 20/03/97 by Sebastien Marineau for 3.3.6 + * Modified 17-Nov-2000 by Tim Roberts for 4.0.1 + * Revision: + * + */ + +#include "Xarch.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#include "xaalocal.h" +#include "xaarop.h" +#include "xf86PciInfo.h" +#include "miline.h" + +#include "savage_driver.h" +#include "savage_regs.h" +#include "savage_bci.h" + + +/* Globals used in driver */ +extern pointer s3savMmioMem; +#ifdef __alpha__ +extern pointer s3savMmioMemSparse; +#endif + +/* Forward declaration of functions used in the driver */ + +static void SavageAccelSync( ScrnInfoPtr ); + +static void SavageSetupForScreenToScreenCopy( + ScrnInfoPtr pScrn, + int xdir, + int ydir, + int rop, + unsigned planemask, + int transparency_color); + +static void SavageSubsequentScreenToScreenCopy( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2, + int w, + int h); + +static void SavageSetupForSolidFill( + ScrnInfoPtr pScrn, + int color, + int rop, + unsigned planemask); + +static void SavageSubsequentSolidFillRect( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h); + +static void SavageSubsequentSolidBresenhamLine( + ScrnInfoPtr pScrn, + int x1, + int y1, + int e1, + int e2, + int err, + int length, + int octant); + +static void SavageSubsequentSolidTwoPointLine( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2, + int bias); + +#if 0 +static void SavageSetupForScreenToScreenColorExpand( + ScrnInfoPtr pScrn, + int bg, + int fg, + int rop, + unsigned planemask); + +static void SavageSubsequentScreenToScreenColorExpand( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft); +#endif + +static void SavageSetupForCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int fg, + int bg, + int rop, + unsigned planemask); + +static void SavageSubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft); + +static void SavageSubsequentColorExpandScanline( + ScrnInfoPtr pScrn, + int buffer_no); + +static void SavageSetupForMono8x8PatternFill( + ScrnInfoPtr pScrn, + int patternx, + int patterny, + int fg, + int bg, + int rop, + unsigned planemask); + +static void SavageSubsequentMono8x8PatternFillRect( + ScrnInfoPtr pScrn, + int pattern0, + int pattern1, + int x, + int y, + int w, + int h); + +static void SavageSetupForColor8x8PatternFill( + ScrnInfoPtr pScrn, + int patternx, + int patterny, + int rop, + unsigned planemask, + int trans_col); + +static void SavageSubsequentColor8x8PatternFillRect( + ScrnInfoPtr pScrn, + int pattern0, + int pattern1, + int x, + int y, + int w, + int h); + +static void SavageSetClippingRectangle( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2); + +static void SavageDisableClipping( ScrnInfoPtr ); + +#if 0 +static void SavageSubsequentSolidFillTrap( + ScrnInfoPtr pScrn, + int y, + int h, + int left, + int dxl, + int dyl, + int el, + int right, + int dxr, + int dyr, + int er); +#endif + +/* from savage_image.c: */ + +void SavageSetupForImageWrite( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int transparency_color, + int bpp, + int depth); + +void SavageSubsequentImageWriteRect( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft); + +void SavageWriteBitmapCPUToScreenColorExpand ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char * src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +); + + +void SavageSetGBD( ScrnInfoPtr ); + +/* + * This is used to cache the last known value for routines we want to + * call from the debugger. + */ + +static ScrnInfoPtr gpScrn = 0; + + + + +void +SavageInitialize2DEngine(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + unsigned int vgaCRIndex = hwp->IOBase + 4; + unsigned int vgaCRReg = hwp->IOBase + 5; + + gpScrn = pScrn; + + VGAOUT16(vgaCRIndex, 0x0140); + VGAOUT8(vgaCRIndex, 0x31); + VGAOUT8(vgaCRReg, 0x0c); + + /* Setup plane masks */ + OUTREG(0x8128, ~0); /* enable all write planes */ + OUTREG(0x812C, ~0); /* enable all read planes */ + OUTREG16(0x8134, 0x27); + OUTREG16(0x8136, 0x07); + + switch( psav->Chipset ) { + + case S3_SAVAGE3D: + case S3_SAVAGE_MX: + /* Disable BCI */ + OUTREG(0x48C18, INREG(0x48C18) & 0x3FF0); + /* Disable shadow status update */ + OUTREG(0x48C0C, 0); + /* Setup BCI command overflow buffer */ + OUTREG(0x48C14, (psav->cobOffset >> 11) | (psav->cobIndex << 29)); + /* Enable BCI and command overflow buffer */ + OUTREG(0x48C18, INREG(0x48C18) | 0x0C); + break; + + case S3_SAVAGE4: + case S3_PROSAVAGE: + /* Disable BCI */ + OUTREG(0x48C18, INREG(0x48C18) & 0x3FF0); + /* Disable shadow status update */ + OUTREG(0x48C0C, 0); + /* Enabel BCI without the COB */ + OUTREG(0x48C18, INREG(0x48C18) | 0x08); + break; + + case S3_SAVAGE2000: + /* Disable BCI */ + OUTREG(0x48C18, 0); + /* Disable shadow status update */ + OUTREG(0x48A30, 0); + /* Setup BCI command overflow buffer */ + OUTREG(0x48C18, (psav->cobOffset >> 7) | (psav->cobIndex)); + /* Enable BCI and command overflow buffer */ + OUTREG(0x48C18, INREG(0x48C18) | 0x00280000 ); + break; + } + + /* Use and set global bitmap descriptor. */ + + /* For reasons I do not fully understand yet, on the Savage4, the */ + /* write to the GBD register, MM816C, does not "take" at this time. */ + /* Only the low-order byte is acknowledged, resulting in an incorrect */ + /* stride. Writing the register later, after the mode switch, works */ + /* correctly. This needs to get resolved. */ + + psav->SavedGbd = 1 | 8 | BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP(psav->SavedGbd, pScrn->bitsPerPixel); + BCI_BD_SET_STRIDE(psav->SavedGbd, pScrn->displayWidth); + + SavageSetGBD(pScrn); +} + + +void +SavageSetGBD( ScrnInfoPtr pScrn ) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + unsigned int vgaCRIndex = hwp->IOBase + 4; + unsigned int vgaCRReg = hwp->IOBase + 5; + + if( !psav->SavedGbd ) + { + psav->SavedGbd = 1 | 8 | BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP(psav->SavedGbd, pScrn->bitsPerPixel); + BCI_BD_SET_STRIDE(psav->SavedGbd, pScrn->displayWidth); + } + + /* Turn on 16-bit register access. */ + + VGAOUT8(vgaCRIndex, 0x31); + VGAOUT8(vgaCRReg, 0x0c); + + /* Set stride to use GBD. */ + + VGAOUT8(vgaCRIndex, 0x50); + VGAOUT8(vgaCRReg, VGAIN8(vgaCRReg) | 0xC1); + + /* Enable 2D engine. */ + + VGAOUT16(vgaCRIndex, 0x0140); + + /* Now set the GBD and SBDs. */ + + OUTREG(0x8168,0); + OUTREG(0x816C,psav->SavedGbd); + OUTREG(0x8170,0); + OUTREG(0x8174,psav->SavedGbd); + OUTREG(0x8178,0); + OUTREG(0x817C,psav->SavedGbd); + + OUTREG(0x81C8, pScrn->displayWidth << 4); + OUTREG(0x81D8, pScrn->displayWidth << 4); +} + + +/* Acceleration init function, sets up pointers to our accelerated functions */ + +Bool +SavageInitAccel(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SavagePtr psav = SAVPTR(pScrn); + XAAInfoRecPtr xaaptr; + BoxRec AvailFBArea; + + /* Set-up our GE command primitive */ + + if (pScrn->bitsPerPixel == 8) { + psav->PlaneMask = 0xFF; + } + else if (pScrn->bitsPerPixel == 16) { + psav->PlaneMask = 0xFFFF; + } + else if (pScrn->bitsPerPixel == 24) { + psav->PlaneMask = 0xFFFFFF; + } + else if (pScrn->bitsPerPixel == 32) { + psav->PlaneMask = 0xFFFFFFFF; + } + + /* General acceleration flags */ + + if (!(xaaptr = psav->AccelInfoRec = XAACreateInfoRec())) + return FALSE; + + xaaptr->Flags = 0 + | PIXMAP_CACHE + | OFFSCREEN_PIXMAPS + | LINEAR_FRAMEBUFFER + ; + + /* Clipping */ + + xaaptr->SetClippingRectangle = SavageSetClippingRectangle; + xaaptr->DisableClipping = SavageDisableClipping; + xaaptr->ClippingFlags = 0 + | HARDWARE_CLIP_SOLID_FILL + | HARDWARE_CLIP_SOLID_LINE + | HARDWARE_CLIP_DASHED_LINE + | HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY + | HARDWARE_CLIP_MONO_8x8_FILL + | HARDWARE_CLIP_COLOR_8x8_FILL + ; + + xaaptr->Sync = SavageAccelSync; + + + /* ScreenToScreen copies */ + +#if 1 + xaaptr->SetupForScreenToScreenCopy = SavageSetupForScreenToScreenCopy; + xaaptr->SubsequentScreenToScreenCopy = SavageSubsequentScreenToScreenCopy; + xaaptr->ScreenToScreenCopyFlags = NO_TRANSPARENCY; +#endif + + + /* Solid filled rectangles */ + +#if 1 + xaaptr->SetupForSolidFill = SavageSetupForSolidFill; + xaaptr->SubsequentSolidFillRect = SavageSubsequentSolidFillRect; + xaaptr->SolidFillFlags = NO_PLANEMASK; +#endif + + /* Mono 8x8 pattern fills */ + +#if 1 + xaaptr->SetupForMono8x8PatternFill = SavageSetupForMono8x8PatternFill; + xaaptr->SubsequentMono8x8PatternFillRect + = SavageSubsequentMono8x8PatternFillRect; + xaaptr->Mono8x8PatternFillFlags = 0 + | HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_LSBFIRST + ; +#endif + + /* Color 8x8 pattern fills */ + +#if 1 + xaaptr->SetupForColor8x8PatternFill = + SavageSetupForColor8x8PatternFill; + xaaptr->SubsequentColor8x8PatternFillRect = + SavageSubsequentColor8x8PatternFillRect; + xaaptr->Color8x8PatternFillFlags = 0 + | NO_TRANSPARENCY + | HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_PROGRAMMED_ORIGIN + ; +#endif + + /* Solid lines */ + +#if 1 + xaaptr->SolidLineFlags = NO_PLANEMASK; + xaaptr->SetupForSolidLine = SavageSetupForSolidFill; + xaaptr->SubsequentSolidBresenhamLine = SavageSubsequentSolidBresenhamLine; + xaaptr->SubsequentSolidTwoPointLine = SavageSubsequentSolidTwoPointLine; +#if 0 + xaaptr->SubsequentSolidFillTrap = SavageSubsequentSolidFillTrap; +#endif + + xaaptr->SolidBresenhamLineErrorTermBits = 16; +#endif + + /* ImageWrite */ + + xaaptr->ImageWriteFlags = 0 + | NO_PLANEMASK + | CPU_TRANSFER_PAD_DWORD + | SCANLINE_PAD_DWORD + | BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + ; + xaaptr->SetupForImageWrite = SavageSetupForImageWrite; + xaaptr->SubsequentImageWriteRect = SavageSubsequentImageWriteRect; + xaaptr->NumScanlineImageWriteBuffers = 1; + xaaptr->ImageWriteBase = psav->BciMem; + xaaptr->ImageWriteRange = 120 * 1024; + + /* WriteBitmap color expand */ + +#if 0 + xaaptr->WriteBitmapFlags = NO_PLANEMASK; + xaaptr->WriteBitmap = SavageWriteBitmapCPUToScreenColorExpand; +#endif + + /* Screen to Screen color expansion. Not implemented. */ + +#if 0 + xaaptr->SetupForScreenToScreenColorExpand = + SavageSetupForScreenToScreenColorExpand; + xaaptr->SubsequentScreenToScreenColorExpand = + SavageSubsequentCPUToScreenColorExpand; +#endif + + /* CPU to Screen color expansion */ + + xaaptr->ScanlineCPUToScreenColorExpandFillFlags = 0 + | NO_PLANEMASK + | CPU_TRANSFER_PAD_DWORD + | SCANLINE_PAD_DWORD + | BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + ; + xaaptr->SetupForScanlineCPUToScreenColorExpandFill = + SavageSetupForCPUToScreenColorExpandFill; + xaaptr->SubsequentScanlineCPUToScreenColorExpandFill = + SavageSubsequentScanlineCPUToScreenColorExpandFill; + xaaptr->SubsequentColorExpandScanline = + SavageSubsequentColorExpandScanline; + xaaptr->ColorExpandBase = psav->BciMem; + xaaptr->ScanlineColorExpandBuffers = &xaaptr->ColorExpandBase; + xaaptr->NumScanlineColorExpandBuffers = 1; + + /* Set up screen parameters. */ + + psav->Bpp = pScrn->bitsPerPixel / 8; + psav->Bpl = pScrn->displayWidth * psav->Bpp; + psav->ScissB = psav->CursorKByte / psav->Bpl; + if (psav->ScissB > 2047) + psav->ScissB = 2047; + + /* + * Finally, we set up the video memory space available to the pixmap + * cache. In this case, all memory from the end of the virtual screen + * to the end of the command overflow buffer can be used. If you haven't + * enabled the PIXMAP_CACHE flag, then these lines can be omitted. + */ + + AvailFBArea.x1 = 0; + AvailFBArea.y1 = 0; + AvailFBArea.x2 = pScrn->displayWidth; + AvailFBArea.y2 = psav->ScissB; + xf86InitFBManager(pScreen, &AvailFBArea); + + return XAAInit(pScreen, xaaptr); +} + + + + +/* The sync function for the GE */ +void +SavageAccelSync(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + WaitIdleEmpty(); +} + + +/* + * The XAA ROP helper routines all assume that a solid color is a + * "pattern". The Savage chips, however, apply a non-stippled solid + * color as "source". Thus, we use a slightly customized version. + */ + +static int +SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int ret = 0; + + pm &= infoRec->FullPlanemask; + + if(pm == infoRec->FullPlanemask) { + if(!NO_SRC_ROP(*rop)) + ret |= ROP_PAT; + *rop = XAACopyROP[*rop]; + } else { + switch(*rop) { + case GXnoop: + break; + case GXset: + case GXclear: + case GXinvert: + ret |= ROP_PAT; + *fg = pm; + if(*bg != -1) + *bg = pm; + break; + default: + ret |= ROP_PAT | ROP_SRC; + break; + } + *rop = XAACopyROP_PM[*rop]; + } + + return ret; +} + + +static int +SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int ret = 0; + + pm &= infoRec->FullPlanemask; + + if(pm == infoRec->FullPlanemask) { + if(!NO_SRC_ROP(*rop)) + ret |= ROP_PAT; + *rop = XAACopyROP[*rop]; + } else { + switch(*rop) { + case GXnoop: + break; + case GXset: + case GXclear: + case GXinvert: + ret |= ROP_PAT; + *fg = pm; + break; + default: + ret |= ROP_PAT | ROP_SRC; + break; + } + *rop = XAACopyROP_PM[*rop]; + } + + return ret; +} + + + +/* These are the ScreenToScreen bitblt functions. We support all ROPs, all + * directions, and a planemask by adjusting the ROP and using the mono pattern + * registers. + * + * (That's a lie; we don't really support planemask.) + */ + +static void +SavageSetupForScreenToScreenCopy( + ScrnInfoPtr pScrn, + int xdir, + int ydir, + int rop, + unsigned planemask, + int transparency_color) +{ + SavagePtr psav = SAVPTR(pScrn); + int cmd; + + cmd = BCI_CMD_RECT | BCI_CMD_DEST_GBD | BCI_CMD_SRC_GBD; + BCI_CMD_SET_ROP( cmd, XAACopyROP[rop] ); + if (transparency_color != -1) + cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_SRC_TRANSPARENT; + + if (xdir == 1 ) cmd |= BCI_CMD_RECT_XP; + if (ydir == 1 ) cmd |= BCI_CMD_RECT_YP; + + psav->SavedBciCmd = cmd; + psav->SavedBgColor = transparency_color; +} + +static void +SavageSubsequentScreenToScreenCopy( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2, + int w, + int h) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + if (!w || !h) return; + if (!(psav->SavedBciCmd & BCI_CMD_RECT_XP)) { + w --; + x1 += w; + x2 += w; + w ++; + } + if (!(psav->SavedBciCmd & BCI_CMD_RECT_YP)) { + h --; + y1 += h; + y2 += h; + h ++; + } + + WaitQueue(6); + BCI_SEND(psav->SavedBciCmd); + if (psav->SavedBgColor != -1) + BCI_SEND(psav->SavedBgColor); + BCI_SEND(BCI_X_Y(x1, y1)); + BCI_SEND(BCI_X_Y(x2, y2)); + BCI_SEND(BCI_W_H(w, h)); +} + + +/* + * SetupForSolidFill is also called to set up for lines. + */ + +static void +SavageSetupForSolidFill( + ScrnInfoPtr pScrn, + int color, + int rop, + unsigned planemask) +{ + SavagePtr psav = SAVPTR(pScrn); + XAAInfoRecPtr xaaptr = GET_XAAINFORECPTR_FROM_SCRNINFOPTR( pScrn ); + int cmd; + int mix; + + cmd = BCI_CMD_RECT + | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID; + + /* Don't send a color if we don't have to. */ + + if( rop == GXcopy ) + { + if( color == 0 ) + rop = GXclear; + else if( color == xaaptr->FullPlanemask ) + rop = GXset; + } + + mix = SavageHelpSolidROP( pScrn, &color, planemask, &rop ); + + if( mix & ROP_PAT ) + cmd |= BCI_CMD_SEND_COLOR; + + BCI_CMD_SET_ROP( cmd, rop ); + + psav->SavedBciCmd = cmd; + psav->SavedFgColor = color; +} + + +static void +SavageSubsequentSolidFillRect( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + WaitQueue(5); + + BCI_SEND(psav->SavedBciCmd); + if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR ) + BCI_SEND(psav->SavedFgColor); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, h)); +} + +#if 0 +static void +SavageSetupForScreenToScreenColorExpand( + ScrnInfoPtr pScrn, + int bg, + int fg, + int rop, + unsigned planemask) +{ +/* SavagePtr psav = SAVPTR(pScrn); */ +} + +static void +SavageSubsequentScreenToScreenColorExpand( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft) +{ +/* SavagePtr psav = SAVPTR(pScrn); */ +} +#endif + + +static void +SavageSetupForCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int fg, + int bg, + int rop, + unsigned planemask) +{ + SavagePtr psav = SAVPTR(pScrn); + int cmd; + int mix; + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_CLIP_LR + | BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO; + + mix = SavageHelpPatternROP( pScrn, &fg, &bg, planemask, &rop ); + + if( mix & ROP_PAT ) + cmd |= BCI_CMD_SEND_COLOR; + + BCI_CMD_SET_ROP( cmd, rop ); + + if (bg != -1) + cmd |= BCI_CMD_SEND_COLOR; + else + cmd |= BCI_CMD_SRC_TRANSPARENT; + + psav->SavedBciCmd = cmd; + psav->SavedFgColor = fg; + psav->SavedBgColor = bg; +} + + +static void +SavageSubsequentScanlineCPUToScreenColorExpandFill( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + /* XAA will be sending bitmap data next. */ + /* We should probably wait for empty/idle here. */ + + WaitQueue(20); + + BCI_SEND(psav->SavedBciCmd); + BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1)); + w = (w + 31) & ~31; + if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR ) + BCI_SEND(psav->SavedFgColor); + if( psav->SavedBgColor != -1 ) + BCI_SEND(psav->SavedBgColor); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, 1)); + + psav->Rect.x = x; + psav->Rect.y = y + 1; + psav->Rect.width = w; + psav->Rect.height = h - 1; +} + +static void +SavageSubsequentColorExpandScanline( + ScrnInfoPtr pScrn, + int buffer_no) +{ + /* This gets call after each scanline's image data has been sent. */ + SavagePtr psav = SAVPTR(pScrn); + xRectangle xr = psav->Rect; + BCI_GET_PTR; + + if( xr.height ) + { + WaitQueue(20); + BCI_SEND(BCI_X_Y( xr.x, xr.y)); + BCI_SEND(BCI_W_H( xr.width, 1 )); + psav->Rect.height--; + psav->Rect.y++; + } +} + + +/* + * The meaning of the two pattern paremeters to Setup & Subsequent for + * Mono8x8Patterns varies depending on the flag bits. We specify + * HW_PROGRAMMED_BITS, which means our hardware can handle 8x8 patterns + * without caching in the frame buffer. Thus, Setup gets the pattern bits. + * There is no way with BCI to rotate an 8x8 pattern, so we do NOT specify + * HW_PROGRAMMED_ORIGIN. XAA wil rotate it for us and pass the rotated + * pattern to both Setup and Subsequent. If we DID specify PROGRAMMED_ORIGIN, + * then Setup would get the unrotated pattern, and Subsequent gets the + * origin values. + */ + +static void +SavageSetupForMono8x8PatternFill( + ScrnInfoPtr pScrn, + int patternx, + int patterny, + int fg, + int bg, + int rop, + unsigned planemask) +{ + SavagePtr psav = SAVPTR(pScrn); + int cmd; + int mix; + + mix = XAAHelpPatternROP( pScrn, &fg, &bg, planemask, &rop ); + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_DEST_GBD | BCI_CMD_PAT_MONO; + + if( mix & ROP_PAT ) + cmd |= BCI_CMD_SEND_COLOR; + + if (bg == -1) + cmd |= BCI_CMD_PAT_TRANSPARENT; + + BCI_CMD_SET_ROP(cmd, rop); + + psav->SavedBciCmd = cmd; + psav->SavedFgColor = fg; + psav->SavedBgColor = bg; +} + + +static void +SavageSubsequentMono8x8PatternFillRect( + ScrnInfoPtr pScrn, + int pattern0, + int pattern1, + int x, + int y, + int w, + int h) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + WaitQueue(7); + BCI_SEND(psav->SavedBciCmd); + if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR ) + BCI_SEND(psav->SavedFgColor); + if( psav->SavedBgColor != -1 ) + BCI_SEND(psav->SavedBgColor); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, h)); + BCI_SEND(pattern0); + BCI_SEND(pattern1); +} + + +static void +SavageSetupForColor8x8PatternFill( + ScrnInfoPtr pScrn, + int patternx, + int patterny, + int rop, + unsigned planemask, + int trans_col) +{ + SavagePtr psav = SAVPTR(pScrn); + + int cmd; + int mix; + unsigned int bd; + int pat_offset; + + /* ViRGEs and Savages do not support transparent color patterns. */ + /* We set the NO_TRANSPARENCY bit, so we should never receive one. */ + + pat_offset = (int) (patternx * psav->Bpp + patterny * psav->Bpl); + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_DEST_GBD | BCI_CMD_PAT_SBD_COLOR_NEW; + + mix = SavageHelpSolidROP( pScrn, &trans_col, planemask, &rop ); + + BCI_CMD_SET_ROP(cmd, rop); + bd = BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP(bd, pScrn->bitsPerPixel); + BCI_BD_SET_STRIDE(bd, 8); + + psav->SavedBciCmd = cmd; + psav->SavedSbdOffset = pat_offset; + psav->SavedSbd = bd; + psav->SavedBgColor = trans_col; +} + + +static void +SavageSubsequentColor8x8PatternFillRect( + ScrnInfoPtr pScrn, + int patternx, + int patterny, + int x, + int y, + int w, + int h) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + WaitQueue(5); + BCI_SEND(psav->SavedBciCmd); + BCI_SEND(psav->SavedSbdOffset); + BCI_SEND(psav->SavedSbd); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, h)); +} + + +static void +SavageSubsequentSolidBresenhamLine( + ScrnInfoPtr pScrn, + int x1, + int y1, + int e1, + int e2, + int err, + int length, + int octant) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + int cmd; + + cmd = (psav->SavedBciCmd & 0x00ffffff); + cmd |= BCI_CMD_LINE_LAST_PIXEL; + +#ifdef DEBUG_EXTRA + ErrorF("BresenhamLine, (%4d,%4d), len %4d, oct %d, err %4d,%4d, clr %08x\n", + x1, y1, length, octant, e2, e1, psav->SavedFgColor ); +#endif + + WaitQueue( 5 ); + BCI_SEND(cmd); + if( cmd & BCI_CMD_SEND_COLOR ) + BCI_SEND( psav->SavedFgColor ); + BCI_SEND(BCI_LINE_X_Y(x1, y1)); + BCI_SEND(BCI_LINE_STEPS(e2-e1, e2)); + BCI_SEND(BCI_LINE_MISC(length, + !!(octant & YMAJOR), + !(octant & XDECREASING), + !(octant & YDECREASING), + e2+err)); +} + + +static void +SavageSubsequentSolidTwoPointLine( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2, + int bias) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + + int cmd; + int dx, dy; + int min, max, xp, yp, ym; + + dx = x2 - x1; + dy = y2 - y1; + +#ifdef DEBUG_EXTRA + ErrorF("TwoPointLine, (%4d,%4d)-(%4d,%4d), clr %08x, last pt %s\n", + x1, y1, x2, y2, psav->SavedFgColor, (bias & 0x100)?"NO ":"YES"); +#endif + + xp = (dx >= 0); + if( !xp ) { + dx = -dx; + } + + yp = (dy >= 0); + if( !yp ) { + dy = -dy; + } + + ym = (dy > dx); + if( ym ) { + max = dy; + min = dx; + } + else { + max = dx; + min = dy; + } + + if( !(bias & 0x100) ) { + max++; + } + + cmd = (psav->SavedBciCmd & 0x00ffffff); + cmd |= BCI_CMD_LINE_LAST_PIXEL; + + WaitQueue(5); + BCI_SEND( cmd ); + if( cmd & BCI_CMD_SEND_COLOR ) + BCI_SEND( psav->SavedFgColor ); + BCI_SEND( BCI_LINE_X_Y( x1, y1 ) ); + BCI_SEND( BCI_LINE_STEPS( 2 * (min - max), 2 * min ) ); + BCI_SEND( BCI_LINE_MISC( max, ym, xp, yp, 2 * min - max ) ); +} + + + +static void +SavageSetClippingRectangle( + ScrnInfoPtr pScrn, + int x1, + int y1, + int x2, + int y2) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + int cmd; + +#ifdef DEBUG_EXTRA + ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2 ); +#endif + + cmd = BCI_CMD_NOP | BCI_CMD_CLIP_NEW; + WaitQueue(3); + BCI_SEND(cmd); + BCI_SEND(BCI_CLIP_TL(y1, x1)); + BCI_SEND(BCI_CLIP_BR(y2, x2)); + psav->SavedBciCmd |= BCI_CMD_CLIP_CURRENT; +} + + +static void SavageDisableClipping( ScrnInfoPtr pScrn ) +{ + SavagePtr psav = SAVPTR(pScrn); +#ifdef DEBUG_EXTRA + ErrorF("Kill ClipRect\n"); +#endif + psav->SavedBciCmd &= ~BCI_CMD_CLIP_NEW; +} + + +/* Trapezoid solid fills. XAA passes the coordinates of the top start + * and end points, and the slopes of the left and right vertexes. We + * use this info to generate the bottom points. We use a mixture of + * floating-point and fixed point logic; the biases are done in fixed + * point. Essentially, these were determined experimentally. The function + * passes xtest, but I suspect that it will not match cfb for large polygons. + * + * This code is from the ViRGE. We need to modify it for Savage if we ever + * decide to turn it on. + */ + +#if 0 +void +SavageSubsequentSolidFillTrap( + ScrnInfoPtr pScrn, + int y, + int h, + int left, + int dxl, + int dyl, + int el, + int right, + int dxr, + int dyr, + int er) +{ + int l_xdelta, r_xdelta; + double lendx, rendx, dl_delta, dr_delta; + int lbias, rbias; + unsigned int cmd; + double l_sgn = -1.0, r_sgn = -1.0; + + cmd |= (CMD_POLYFILL | CMD_AUTOEXEC | MIX_MONO_PATT) ; + cmd |= (psav->SavedRectCmdForLine & (0xff << 17)); + + l_xdelta = -(dxl << 20)/ dyl; + r_xdelta = -(dxr << 20)/ dyr; + + dl_delta = -(double) dxl / (double) dyl; + dr_delta = -(double) dxr / (double) dyr; + if (dl_delta < 0.0) l_sgn = 1.0; + if (dr_delta < 0.0) r_sgn = 1.0; + + lendx = l_sgn * ((double) el / (double) dyl) + left + ((h - 1) * dxl) / (double) dyl; + rendx = r_sgn * ((double) er / (double) dyr) + right + ((h - 1) * dxr) / (double) dyr; + + /* We now have four cases */ + + if (fabs(dl_delta) > 1.0) { /* XMAJOR line */ + if (dxl > 0) { lbias = ((1 << 20) - h); } + else { lbias = 0; } + } + else { + if (dxl > 0) { lbias = ((1 << 20) - 1) + l_xdelta / 2; } + else { lbias = 0; } + } + + if (fabs(dr_delta) > 1.0) { /* XMAJOR line */ + if (dxr > 0) { rbias = (1 << 20); } + else { rbias = ((1 << 20) - 1); } + } + else { + if (dxr > 0) { rbias = (1 << 20); } + else { rbias = ((1 << 20) - 1); } + } + + WaitQueue(8); + CACHE_SETP_CMD_SET(cmd); + SETP_PRDX(r_xdelta); + SETP_PLDX(l_xdelta); + SETP_PRXSTART(((int) (rendx * (double) (1 << 20))) + rbias); + SETP_PLXSTART(((int) (lendx * (double) (1 << 20))) + lbias); + + SETP_PYSTART(y + h - 1); + SETP_PYCNT((h) | 0x30000000); + + CACHE_SETB_CMD_SET(psav->SavedRectCmdForLine); + +} +#endif + +/* Routines for debugging. */ + +unsigned long +writedw( unsigned long addr, unsigned long value ) +{ + SavagePtr psav = SAVPTR(gpScrn); + OUTREG( addr, value ); + return INREG( addr ); +} + +unsigned long +readdw( unsigned long addr ) +{ + SavagePtr psav = SAVPTR(gpScrn); + return INREG( addr ); +} + +unsigned long +readfb( unsigned long addr ) +{ + SavagePtr psav = SAVPTR(gpScrn); + char * videobuffer = (char *) psav->FBBase; + return *(volatile unsigned long*)(videobuffer + (addr & ~3) ); +} + +unsigned long +writefb( unsigned long addr, unsigned long value ) +{ + SavagePtr psav = SAVPTR(gpScrn); + char * videobuffer = (char *) psav->FBBase; + *(unsigned long*)(videobuffer + (addr & ~3)) = value; + return *(volatile unsigned long*)(videobuffer + (addr & ~3) ); +} + +void +writescan( unsigned long scan, unsigned long color ) +{ + SavagePtr psav = SAVPTR(gpScrn); + int i; + char * videobuffer = (char *)psav->FBBase; + videobuffer += scan * gpScrn->displayWidth * gpScrn->bitsPerPixel >> 3; + for( i = gpScrn->displayWidth; --i; ) { + switch( gpScrn->bitsPerPixel ) { + case 8: + *videobuffer++ = color; + break; + case 16: + *(unsigned short*)videobuffer = color; + videobuffer += 2; + break; + case 32: + *(unsigned long*)videobuffer = color; + videobuffer += 4; + break; + } + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h:1.1 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h Fri Dec 1 20:16:11 2000 @@ -0,0 +1,95 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h,v 1.1 2000/12/02 01:16:11 dawes Exp $ */ + +#ifndef _S3BCI_H_ +#define _S3BCI_H_ + +#define REVERSE_BYTE_ORDER32(dword) {\ + unsigned int temp; \ + dword = (temp & 0xFF) << 24; \ + dword |= (temp & 0xFF00) << 8; \ + dword |= (temp & 0xFF0000) >> 8; \ + dword |= (temp & 0xFF000000) >> 24; } + +#define BCI_GET_PTR volatile unsigned int * bci_ptr = (unsigned int *) psav->BciMem +#define BCI_RESET bci_ptr = (unsigned int *) psav->BciMem + +#define BCI_SEND(dw) (*bci_ptr++ = (unsigned int)(dw)) + +#define BCI_CMD_NOP 0x40000000 +#define BCI_CMD_RECT 0x48000000 +#define BCI_CMD_RECT_XP 0x01000000 +#define BCI_CMD_RECT_YP 0x02000000 +#define BCI_CMD_SCANLINE 0x50000000 +#define BCI_CMD_LINE 0x5C000000 +#define BCI_CMD_LINE_LAST_PIXEL 0x58000000 +#define BCI_CMD_BYTE_TEXT 0x63000000 +#define BCI_CMD_NT_BYTE_TEXT 0x67000000 +#define BCI_CMD_BIT_TEXT 0x6C000000 +#define BCI_CMD_GET_ROP(cmd) (((cmd) >> 16) & 0xFF) +#define BCI_CMD_SET_ROP(cmd, rop) ((cmd) |= ((rop & 0xFF) << 16)) +#define BCI_CMD_SEND_COLOR 0x00008000 + +#define BCI_CMD_CLIP_NONE 0x00000000 +#define BCI_CMD_CLIP_CURRENT 0x00002000 +#define BCI_CMD_CLIP_LR 0x00004000 +#define BCI_CMD_CLIP_NEW 0x00006000 + +#define BCI_CMD_DEST_GBD 0x00000000 +#define BCI_CMD_DEST_PBD 0x00000800 +#define BCI_CMD_DEST_PBD_NEW 0x00000C00 +#define BCI_CMD_DEST_SBD 0x00001000 +#define BCI_CMD_DEST_SBD_NEW 0x00001400 + +#define BCI_CMD_SRC_TRANSPARENT 0x00000200 +#define BCI_CMD_SRC_SOLID 0x00000000 +#define BCI_CMD_SRC_GBD 0x00000020 +#define BCI_CMD_SRC_COLOR 0x00000040 +#define BCI_CMD_SRC_MONO 0x00000060 +#define BCI_CMD_SRC_PBD_COLOR 0x00000080 +#define BCI_CMD_SRC_PBD_MONO 0x000000A0 +#define BCI_CMD_SRC_PBD_COLOR_NEW 0x000000C0 +#define BCI_CMD_SRC_PBD_MONO_NEW 0x000000E0 +#define BCI_CMD_SRC_SBD_COLOR 0x00000100 +#define BCI_CMD_SRC_SBD_MONO 0x00000120 +#define BCI_CMD_SRC_SBD_COLOR_NEW 0x00000140 +#define BCI_CMD_SRC_SBD_MONO_NEW 0x00000160 + +#define BCI_CMD_PAT_TRANSPARENT 0x00000010 +#define BCI_CMD_PAT_NONE 0x00000000 +#define BCI_CMD_PAT_COLOR 0x00000002 +#define BCI_CMD_PAT_MONO 0x00000003 +#define BCI_CMD_PAT_PBD_COLOR 0x00000004 +#define BCI_CMD_PAT_PBD_MONO 0x00000005 +#define BCI_CMD_PAT_PBD_COLOR_NEW 0x00000006 +#define BCI_CMD_PAT_PBD_MONO_NEW 0x00000007 +#define BCI_CMD_PAT_SBD_COLOR 0x00000008 +#define BCI_CMD_PAT_SBD_MONO 0x00000009 +#define BCI_CMD_PAT_SBD_COLOR_NEW 0x0000000A +#define BCI_CMD_PAT_SBD_MONO_NEW 0x0000000B + +#define BCI_BD_BW_DISABLE 0x10000000 +#define BCI_BD_TILE_MASK 0x03000000 +#define BCI_BD_TILE_NONE 0x00000000 +#define BCI_BD_TILE_16 0x02000000 +#define BCI_BD_TILE_32 0x04000000 +#define BCI_BD_GET_BPP(bd) (((bd) >> 16) & 0xFF) +#define BCI_BD_SET_BPP(bd, bpp) ((bd) |= (((bpp) & 0xFF) << 16)) +#define BCI_BD_GET_STRIDE(bd) ((bd) & 0xFFFF) +#define BCI_BD_SET_STRIDE(bd, st) ((bd) |= ((st) & 0xFFFF)) + +#define BCI_W_H(w, h) (((h) << 16) | ((w) & 0xFFF)) +#define BCI_X_Y(x, y) (((y) << 16) | ((x) & 0xFFF)) +#define BCI_X_W(x, y) (((w) << 16) | ((x) & 0xFFF)) +#define BCI_CLIP_LR(l, r) (((r) << 16) | ((l) & 0xFFF)) +#define BCI_CLIP_TL(t, l) (((t) << 16) | ((l) & 0xFFF)) +#define BCI_CLIP_BR(b, r) (((b) << 16) | ((r) & 0xFFF)) + +#define BCI_LINE_X_Y(x, y) (((y) << 16) | ((x) & 0xFFFF)) +#define BCI_LINE_STEPS(diag, axi) (((axi) << 16) | ((diag) & 0xFFFF)) +#define BCI_LINE_MISC(maj, ym, xp, yp, err) \ +(((maj) & 0xFFF) | (((ym) & 1) << 13) | \ +(((xp) & 1) << 14) | (((yp) & 1) << 15) | \ +((err) << 16)) + + +#endif /* _S3BCI_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c:1.1 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c Fri Dec 1 20:16:11 2000 @@ -0,0 +1,255 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c,v 1.1 2000/12/02 01:16:11 dawes Exp $ */ + +/* + * Hardware cursor support for S3 Savage 4.0 driver. Taken with + * very few changes from the s3virge cursor file. + * + * S. Marineau, 19/04/97. + * Modified by Amancio Hasty and Jon Tombs + * Ported to 4.0 by Tim Roberts. + */ + +#include "savage_driver.h" + +static void SavageLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); +static void SavageShowCursor(ScrnInfoPtr pScrn); +static void SavageHideCursor(ScrnInfoPtr pScrn); +static void SavageSetCursorPosition(ScrnInfoPtr pScrn, int x, int y); +static void SavageSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); + + +/* + * Read/write to the DAC via MMIO + */ + +#define inCRReg(reg) (VGAHWPTR(pScrn))->readCrtc( VGAHWPTR(pScrn), reg ) +#define outCRReg(reg, val) (VGAHWPTR(pScrn))->writeCrtc( VGAHWPTR(pScrn), reg, val ) + + +#define MAX_CURS 64 + + +Bool +SavageHWCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SavagePtr psav = SAVPTR(pScrn); + xf86CursorInfoPtr infoPtr; + + infoPtr = xf86CreateCursorInfoRec(); + if(!infoPtr) + return FALSE; + + psav->CursorInfoRec = infoPtr; + + infoPtr->MaxWidth = MAX_CURS; + infoPtr->MaxHeight = MAX_CURS; + infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 | + HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | + HARDWARE_CURSOR_INVERT_MASK; + + /* + * The /MX family is apparently unique among the Savages, in that + * the cursor color is always straight RGB. The rest of the Savages + * use palettized values at 8-bit when not clock doubled. + */ + + if( + ( (inCRReg(0x18) & 0x80) && (inCRReg(0x15) & 0x50) ) + || + (psav->Chipset == S3_SAVAGE_MX) + ) + infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; + + infoPtr->SetCursorColors = SavageSetCursorColors; + infoPtr->SetCursorPosition = SavageSetCursorPosition; + infoPtr->LoadCursorImage = SavageLoadCursorImage; + infoPtr->HideCursor = SavageHideCursor; + infoPtr->ShowCursor = SavageShowCursor; + infoPtr->UseHWCursor = NULL; + + if( !psav->CursorKByte ) + psav->CursorKByte = pScrn->videoRam - 4; + + return xf86InitCursor(pScreen, infoPtr); +} + + + +void +SavageShowCursor(ScrnInfoPtr pScrn) +{ + /* Turn cursor on. */ + outCRReg( 0x45, inCRReg(0x45) | 0x01 ); +} + + +void +SavageHideCursor(ScrnInfoPtr pScrn) +{ + /* Turn cursor off. */ + outCRReg( 0x45, inCRReg(0x45) & 0xfe ); +} + + +static void +SavageLoadCursorImage( + ScrnInfoPtr pScrn, + unsigned char* src) +{ + SavagePtr psav = SAVPTR(pScrn); + + /* Set cursor location in frame buffer. */ + outCRReg( 0x4d, (0xff & psav->CursorKByte)); + outCRReg( 0x4c, (0xff00 & psav->CursorKByte) >> 8); + + /* Upload the cursor image to the frame buffer. */ + memcpy(psav->FBBase + psav->CursorKByte * 1024, src, 1024); + + if( S3_SAVAGE4_SERIES( psav->Chipset ) ) { + /* + * Bug in Savage4 Rev B requires us to do an MMIO read after + * loading the cursor. + */ + volatile unsigned int i = ALT_STATUS_WORD0; + } +} + + +static void +SavageSetCursorPosition( + ScrnInfoPtr pScrn, + int x, + int y) +{ + unsigned char xoff, yoff; + + /* adjust for frame buffer base address granularity */ + if (pScrn->bitsPerPixel == 8) + x += ((pScrn->frameX0) & 3); + else if (pScrn->bitsPerPixel == 16) + x += ((pScrn->frameX0) & 1); + else if (pScrn->bitsPerPixel == 32) + x += ((pScrn->frameX0+2) & 3) - 2; + + /* + * Make these even when used. There is a bug/feature on at least + * some chipsets that causes a "shadow" of the cursor in interlaced + * mode. Making this even seems to have no visible effect, so just + * do it for the generic case. + */ + + if (x < 0) { + xoff = ((-x) & 0xFE); + x = 0; + } else { + xoff = 0; + } + + if (y < 0) { + yoff = ((-y) & 0xFE); + y = 0; + } else { + yoff = 0; + } + + /* This is the recomended order to move the cursor */ + outCRReg( 0x46, (x & 0xff00)>>8 ); + outCRReg( 0x47, (x & 0xff) ); + outCRReg( 0x49, (y & 0xff) ); + outCRReg( 0x4e, xoff ); + outCRReg( 0x4f, yoff ); + outCRReg( 0x48, (y & 0xff00)>>8 ); +} + + +static void +SavageSetCursorColors( + ScrnInfoPtr pScrn, + int bg, + int fg) +{ + SavagePtr psav = SAVPTR(pScrn); + Bool bNeedExtra = FALSE; + + /* Clock doubled modes need an extra cursor stack write. */ + bNeedExtra = + (psav->CursorInfoRec->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP); + + if( psav->Chipset == S3_SAVAGE_MX ) + bNeedExtra = TRUE; + + switch (pScrn->bitsPerPixel) { + case 16: + if (pScrn->weight.green == 5) { + fg = ((fg & 0xf80000) >> 9) | + ((fg & 0xf800) >> 6) | + ((fg & 0xf8) >> 3); + bg = ((bg & 0xf80000) >> 9) | + ((bg & 0xf800) >> 6) | + ((bg & 0xf8) >> 3); + } else { + fg = ((fg & 0xf80000) >> 8) | + ((fg & 0xfc00) >> 5) | + ((fg & 0xf8) >> 3); + bg = ((bg & 0xf80000) >> 8) | + ((bg & 0xfc00) >> 5) | + ((bg & 0xf8) >> 3); + } + /* Reset the cursor color stack pointer */ + inCRReg( 0x45 ); + outCRReg( 0x4a, fg ); + outCRReg( 0x4a, fg>>8 ); + if( bNeedExtra ) + { + outCRReg( 0x4a, fg ); + outCRReg( 0x4a, fg>>8 ); + } + /* Reset the cursor color stack pointer */ + inCRReg( 0x45 ); + outCRReg( 0x4b, bg ); + outCRReg( 0x4b, bg>>8 ); + if( bNeedExtra ) + { + outCRReg( 0x4b, bg ); + outCRReg( 0x4b, bg>>8 ); + } + break; + case 8: + if( !bNeedExtra ) + { + /* Reset the cursor color stack pointer */ + inCRReg(0x45); + /* Write foreground */ + outCRReg(0x4a, fg); + outCRReg(0x4a, fg); + /* Reset the cursor color stack pointer */ + inCRReg(0x45); + /* Write background */ + outCRReg(0x4b, bg); + outCRReg(0x4b, bg); + break; + } + /* else */ + /* FALLTHROUGH */ + case 24: + case 32: + /* Do it straight, full 24 bit color. */ + + /* Reset the cursor color stack pointer */ + inCRReg(0x45); + /* Write low, mid, high bytes - foreground */ + outCRReg(0x4a, fg); + outCRReg(0x4a, fg >> 8); + outCRReg(0x4a, fg >> 16); + /* Reset the cursor color stack pointer */ + inCRReg(0x45); + /* Write low, mid, high bytes - background */ + outCRReg(0x4b, bg); + outCRReg(0x4b, bg >> 8); + outCRReg(0x4b, bg >> 16); + break; + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c:1.6 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c Tue Dec 12 11:50:48 2000 @@ -0,0 +1,2741 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c,v 1.6 2000/12/12 16:50:48 dawes Exp $ */ +/* + * vim: sw=4 ts=8 ai ic: + * + * XFree86 4.0 S3 Savage driver + * + * Tim Roberts <timr@probo.com> + * Ani Joshi <ajoshi@unixbox.com> + * + * TODO: add credits for the 3.3.x authors... + * + */ + + +#include "xf86RAC.h" +#include "shadowfb.h" + +#ifdef DPMSExtension +#include "globals.h" +#define DPMS_SERVER +#include "extensions/dpms.h" +#endif /* DPMSExtension */ + +#include "savage_driver.h" +#include "savage_bci.h" + + + + +/* + * prototypes + */ +static void SavageEnableMMIO(ScrnInfoPtr pScrn); +static void SavageDisableMMIO(ScrnInfoPtr pScrn); + +static OptionInfoPtr SavageAvailableOptions(int chipid, int busid); +static void SavageIdentify(int flags); +static Bool SavageProbe(DriverPtr drv, int flags); +static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags); + +static Bool SavageEnterVT(int scrnIndex, int flags); +static void SavageLeaveVT(int scrnIndex, int flags); +static void SavageSave(ScrnInfoPtr pScrn); +static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr, SavageRegPtr); + +static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv); +static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen); +static ModeStatus SavageValidMode(int index, DisplayModePtr mode, + Bool verbose, int flags); + +static Bool SavageMapMMIO(ScrnInfoPtr pScrn); +static Bool SavageMapFB(ScrnInfoPtr pScrn); +static void SavageUnmapMem(ScrnInfoPtr pScrn); +static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SavageSaveScreen(ScreenPtr pScreen, int mode); +static void SavageLoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indicies, LOCO *colors, + VisualPtr pVisual); +static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1, + int min_n2, int max_n2, long freq_min, + long freq_max, unsigned int *mdiv, + unsigned int *ndiv, unsigned int *r); +void SavageGEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file); +void SavagePrintRegs(ScrnInfoPtr pScrn); +#ifdef DPMSExtension +static void SavageDPMS(ScrnInfoPtr pScrn, int mode, int flags); +#endif + +static int pix24bpp = 0; + +#define iabs(a) ((int)(a)>0?(a):(-(a))) + +#define DRIVER_NAME "savage" +#define DRIVER_VERSION "1.1.0" +#define VERSION_MAJOR 1 +#define VERSION_MINOR 1 +#define PATCHLEVEL 0 +#define SAVAGE_VERSION ((VERSION_MAJOR << 24) | \ + (VERSION_MINOR << 16) | \ + PATCHLEVEL) + + +DriverRec SAVAGE = +{ + SAVAGE_VERSION, + DRIVER_NAME, + SavageIdentify, + SavageProbe, + SavageAvailableOptions, + NULL, + 0 +}; + + +/* Supported chipsets */ + +static SymTabRec SavageChips[] = { + { PCI_CHIP_SAVAGE4, "Savage4" }, + { PCI_CHIP_SAVAGE3D, "Savage3D" }, + { PCI_CHIP_SAVAGE3D_MV, "Savage3D-MV" }, + { PCI_CHIP_SAVAGE2000, "Savage2000" }, + { PCI_CHIP_SAVAGE_MX_MV, "Savage/MX-MV" }, + { PCI_CHIP_SAVAGE_MX, "Savage/MX" }, + { PCI_CHIP_SAVAGE_IX_MV, "Savage/IX-MV" }, + { PCI_CHIP_SAVAGE_IX, "Savage/IX" }, + { PCI_CHIP_PROSAVAGE_PM, "ProSavage PM133" }, + { PCI_CHIP_PROSAVAGE_KM, "ProSavage KM133" }, + { -1, NULL } +}; + +static SymTabRec SavageChipsets[] = { + { S3_SAVAGE3D, "Savage3D" }, + { S3_SAVAGE4, "Savage4" }, + { S3_SAVAGE2000, "Savage2000" }, + { S3_SAVAGE_MX, "Savage/MX or /IX" }, + { S3_PROSAVAGE, "ProSavage PM133" }, + { -1, NULL } +}; + +/* This table maps a PCI device ID to a chipset family identifier. */ + +static PciChipsets SavagePciChipsets[] = { + { S3_SAVAGE3D, PCI_CHIP_SAVAGE3D, RES_SHARED_VGA }, + { S3_SAVAGE3D, PCI_CHIP_SAVAGE3D_MV, RES_SHARED_VGA }, + { S3_SAVAGE4, PCI_CHIP_SAVAGE4, RES_SHARED_VGA }, + { S3_SAVAGE2000, PCI_CHIP_SAVAGE2000, RES_SHARED_VGA }, + { S3_SAVAGE_MX, PCI_CHIP_SAVAGE_MX_MV, RES_SHARED_VGA }, + { S3_SAVAGE_MX, PCI_CHIP_SAVAGE_MX, RES_SHARED_VGA }, + { S3_SAVAGE_MX, PCI_CHIP_SAVAGE_IX_MV, RES_SHARED_VGA }, + { S3_SAVAGE_MX, PCI_CHIP_SAVAGE_IX, RES_SHARED_VGA }, + { S3_PROSAVAGE, PCI_CHIP_PROSAVAGE_PM, RES_SHARED_VGA }, + { S3_PROSAVAGE, PCI_CHIP_PROSAVAGE_KM, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +typedef enum { + OPTION_SLOW_EDODRAM, + OPTION_SLOW_DRAM, + OPTION_FAST_DRAM, + OPTION_FPM_VRAM, + OPTION_PCI_BURST, + OPTION_FIFO_CONSERV, + OPTION_FIFO_MODERATE, + OPTION_FIFO_AGGRESSIVE, + OPTION_PCI_RETRY, + OPTION_NOACCEL, + OPTION_EARLY_RAS_PRECHARGE, + OPTION_LATE_RAS_PRECHARGE, + OPTION_LCD_CENTER, + OPTION_LCDCLOCK, + OPTION_MCLK, + OPTION_REFCLK, + OPTION_SHOWCACHE, + OPTION_SWCURSOR, + OPTION_HWCURSOR, + OPTION_SHADOW_FB, + OPTION_ROTATE, + OPTION_USEBIOS +} SavageOpts; + + +static OptionInfoRec SavageOptions[] = +{ + { OPTION_SLOW_EDODRAM, "slow_edodram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SLOW_DRAM, "slow_dram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FAST_DRAM, "fast_dram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FPM_VRAM, "fpm_vram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_USEBIOS, "UseBIOS", OPTV_BOOLEAN, {0}, FALSE }, + /* finish later... */ + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + + +static const char *vgaHWSymbols[] = { + "vgaHWGetHWRec", + "vgaHWSetMmioFuncs", + "vgaHWGetIOBase", + "vgaHWSave", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWMapMem", + "vgaHWUnmapMem", + "vgaHWInit", + "vgaHWSaveScreen", + "vgaHWLock", +#if 0 + "vgaHWUnlock", + "vgaHWFreeHWRec", +#endif + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +static const char *vbeSymbols[] = { + "VBEInit", + "vbeDoEDID", + "vbeFree", + NULL +}; + +static const char *ddcSymbols[] = { + "xf86InterpretEDID", + NULL +}; + +static const char *xaaSymbols[] = { + "XAACopyROP", + "XAACopyROP_PM", + "XAACreateInfoRec", + "XAADestroyInfoRec", + "XAAHelpPatternROP", + "XAAHelpSolidROP", + "XAAInit", + "XAAScreenIndex", + NULL +}; + +static const char *shadowSymbols[] = { + "ShadowFBInit", + NULL +}; + +static const char *int10Symbols[] = { + "xf86ExecX86int10", + "xf86FreeInt10", + "xf86InitInt10", + "xf86Int10AllocPages", + "xf86Int10FreePages", + NULL +}; + +static const char *cfbSymbols[] = { + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb24_32ScreenInit", + "cfb32ScreenInit", + "cfb16BresS", + "cfb24BresS", + NULL +}; + +#ifdef XFree86LOADER + +static MODULESETUPPROTO(SavageSetup); + +static XF86ModuleVersionInfo SavageVersRec = { + "savage", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +XF86ModuleData savageModuleData = { &SavageVersRec, SavageSetup, NULL }; + +static pointer SavageSetup(pointer module, pointer opts, int *errmaj, + int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&SAVAGE, module, 0); + LoaderRefSymLists(vgaHWSymbols, cfbSymbols, ramdacSymbols, + xaaSymbols, shadowSymbols, vbeSymbols, + ddcSymbols, NULL); + return (pointer) 1; + } else { + if (errmaj) + *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + + +/* + * I'd rather have these wait macros be inline, but S3 has made it + * darned near impossible. The bit fields are in a different place in + * all three families, the status register has a different address in the + * three families, and even the idle vs busy sense flipped in the Sav2K. + */ + +static void +ResetBCI2K( SavagePtr psav ) +{ + CARD32 cob = INREG( 0x48c18 ); + /* if BCI is enabled and BCI is busy... */ + + if( + (cob & 0x00000008) && + ! (ALT_STATUS_WORD0 & 0x00200000) + ) + { + ErrorF( "Resetting BCI, stat = %08x...\n", ALT_STATUS_WORD0); + /* Turn off BCI */ + OUTREG( 0x48c18, cob & ~8 ); + usleep(10000); + /* Turn it back on */ + OUTREG( 0x48c18, cob ); + usleep(10000); + } +} + +/* Wait until "v" queue entries are free */ + +static int +WaitQueue3D( SavagePtr psav, int v ) +{ + int loop = 0; + int slots = MAXFIFO - v; + + mem_barrier(); + loop &= STATUS_WORD0; + while( ((STATUS_WORD0 & 0x0000ffff) > slots) && (loop++ < MAXLOOP)) + ; + return loop >= MAXLOOP; +} + +static int +WaitQueue4( SavagePtr psav, int v ) +{ + int loop = 0; + int slots = MAXFIFO - v; + + if( !psav->NoPCIRetry ) + return 0; + mem_barrier(); + while( ((ALT_STATUS_WORD0 & 0x001fffff) > slots) && (loop++ < MAXLOOP)) + ; + return loop >= MAXLOOP; +} + +static int +WaitQueue2K( SavagePtr psav, int v ) +{ + int loop = 0; + int slots = MAXFIFO - v; + + if( !psav->NoPCIRetry ) + return 0; + mem_barrier(); + while( ((ALT_STATUS_WORD0 & 0x000fffff) > slots) && (loop++ < MAXLOOP)) + ; + if( loop >= MAXLOOP ) + ResetBCI2K(psav); + return loop >= MAXLOOP; +} + +/* Wait until GP is idle and queue is empty */ + +static int +WaitIdleEmpty3D(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + loop &= STATUS_WORD0; + while( ((STATUS_WORD0 & 0x0008ffff) != 0x80000) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitIdleEmpty4(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + while( ((ALT_STATUS_WORD0 & 0x00a1ffff) != 0x00a00000) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitIdleEmpty2K(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + /* CAUTION! How do we insure this read isn't optimized away? */ + /* Is the "volatile" enough to do that? */ + loop &= ALT_STATUS_WORD0; + while( ((ALT_STATUS_WORD0 & 0x009fffff) != 0) && (loop++ < MAXLOOP) ) + ; + if( loop >= MAXLOOP ) + ResetBCI2K(psav); + return loop >= MAXLOOP; +} + +/* Wait until GP is idle */ + +static int +WaitIdle3D(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + while( (!(STATUS_WORD0 & 0x00080000)) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitIdle4(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + while( (!(ALT_STATUS_WORD0 & 0x00800000)) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitIdle2K(SavagePtr psav) +{ + int loop = 0; + mem_barrier(); + loop &= ALT_STATUS_WORD0; + while( (ALT_STATUS_WORD0 & 0x00900000) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +/* Wait until Command FIFO is empty */ + + +static int +WaitCommandEmpty3D(SavagePtr psav) { + int loop = 0; + mem_barrier(); + while( (STATUS_WORD0 & 0x0000ffff) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitCommandEmpty4(SavagePtr psav) { + int loop = 0; + mem_barrier(); + while( (ALT_STATUS_WORD0 & 0x0001ffff) && (loop++ < MAXLOOP) ) + ; + return loop >= MAXLOOP; +} + +static int +WaitCommandEmpty2K(SavagePtr psav) { + int loop = 0; + mem_barrier(); + while( (ALT_STATUS_WORD0 & 0x001fffff) && (loop++ < MAXLOOP) ) + ; + if( loop >= MAXLOOP ) + ResetBCI2K(psav); + return loop >= MAXLOOP; +} + +static Bool SavageGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(SavageRec), 1); + return TRUE; +} + + +static void SavageFreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn->driverPrivate) + return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; + SavageUnmapMem(pScrn); +} + + +static OptionInfoPtr SavageAvailableOptions(int chipid, int busid) +{ + return SavageOptions; +} + + +static void SavageIdentify(int flags) +{ + xf86PrintChipsets("SAVAGE", + "driver (version " DRIVER_VERSION " for S3 Savage chipsets", + SavageChips); +} + + +static Bool SavageProbe(DriverPtr drv, int flags) +{ + int i; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool foundScreen = FALSE; + + /* sanity checks */ + if ((numDevSections = xf86MatchDevice("savage", &devSections)) <= 0) + return FALSE; + if (xf86GetPciVideoInfo() == NULL) + return FALSE; + + numUsed = xf86MatchPciInstances("SAVAGE", PCI_VENDOR_S3, + SavageChipsets, SavagePciChipsets, + devSections, numDevSections, drv, + &usedChips); + xfree(devSections); + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else + for (i=0; i<numUsed; i++) { + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + + pScrn->driverVersion = (int)DRIVER_VERSION; + pScrn->driverName = DRIVER_NAME; + pScrn->name = "SAVAGE"; + pScrn->Probe = SavageProbe; + pScrn->PreInit = SavagePreInit; + pScrn->ScreenInit = SavageScreenInit; + pScrn->SwitchMode = SavageSwitchMode; + pScrn->AdjustFrame = SavageAdjustFrame; + pScrn->EnterVT = SavageEnterVT; + pScrn->LeaveVT = SavageLeaveVT; + pScrn->FreeScreen = NULL; + pScrn->ValidMode = SavageValidMode; + foundScreen = TRUE; + xf86ConfigActivePciEntity(pScrn, usedChips[i], SavagePciChipsets, + NULL, NULL, NULL, NULL, NULL); + } + + xfree(usedChips); + return foundScreen; +} + +static int LookupChipID( PciChipsets* pset, int ChipID ) +{ + /* Is there a function to do this for me? */ + while( pset->numChipset >= 0 ) + { + if( pset->PCIid == ChipID ) + return pset->numChipset; + pset++; + } + + return -1; +} + +static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) +{ + EntityInfoPtr pEnt; + SavagePtr psav; + MessageType from = X_DEFAULT; + int i; + ClockRangePtr clockRanges; + char *mod = NULL; + char *s = NULL; + const char *reqSym = NULL; + unsigned char config1, m, n, n1, n2, sr8, cr66 = 0, tmp; + int mclk; + vgaHWPtr hwp; + int vgaCRIndex, vgaCRReg, vgaIOBase; + + if (flags & PROBE_DETECT) + return FALSE; + + if (!xf86LoadSubModule(pScrn, "vgahw")) + return FALSE; + + xf86LoaderReqSymLists(vgaHWSymbols, NULL); + if (!vgaHWGetHWRec(pScrn)) + return FALSE; + +#if 0 + /* Here we can alter the number of registers saved and restored by the + * standard vgaHWSave and Restore routines. + */ + vgaHWSetRegCounts( pScrn, VGA_NUM_CRTC, VGA_NUM_SEQ, VGA_NUM_GFX, VGA_NUM_ATTR ); +#endif + + pScrn->monitor = pScrn->confScreen->monitor; + + /* + * We support depths of 8, 15, 16 and 24. + * We support bpp of 8, 16, and 32. + */ + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support32bppFb)) + return FALSE; + else { + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + return FALSE; + } + } + xf86PrintDepthBpp(pScrn); + + if (pScrn->depth == 24 && pix24bpp == 0) + pix24bpp = xf86GetBppFromDepth(pScrn, 24); + + if (pScrn->depth > 8) { + rgb zeros = {0, 0, 0}; + + if (!xf86SetWeight(pScrn, zeros, zeros)) + return FALSE; + else { + /* TODO check weight returned is supported */ + ; + } + } + + if (!xf86SetDefaultVisual(pScrn, -1)) { + return FALSE; + } else { + /* We don't currently support DirectColor at > 8bpp */ + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" + " (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + } + + pScrn->progClock = TRUE; + + if (!SavageGetRec(pScrn)) + return FALSE; + psav = SAVPTR(pScrn); + + xf86CollectOptions(pScrn, NULL); + + if (pScrn->depth == 8) + pScrn->rgbBits = 6; + + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, SavageOptions); + + if (xf86ReturnOptValBool(SavageOptions, OPTION_PCI_BURST, FALSE)) { + psav->pci_burst = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: pci_burst - PCI burst read enabled\n"); + } else + psav->pci_burst = FALSE; + psav->NoPCIRetry = 1; /* default */ + if (xf86ReturnOptValBool(SavageOptions, OPTION_PCI_RETRY, FALSE)) { + if (xf86ReturnOptValBool(SavageOptions, OPTION_PCI_BURST, FALSE)) { + psav->NoPCIRetry = 0; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: pci_retry\n"); + } else + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"pci_retry\" option requires \"pci_burst\"\n"); + } + if (xf86IsOptionSet(SavageOptions, OPTION_FIFO_CONSERV)) { + psav->fifo_conservative = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo conservative set\n"); + } else + psav->fifo_conservative = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_FIFO_MODERATE)) { + psav->fifo_moderate = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo_moderate set\n"); + } else + psav->fifo_moderate = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_FIFO_AGGRESSIVE)) { + psav->fifo_aggressive = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo_aggressive set\n"); + } else + psav->fifo_aggressive = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_SLOW_EDODRAM)) { + psav->slow_edodram = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: slow_edodram_set\n"); + } else + psav->slow_edodram = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_SLOW_DRAM)) { + psav->slow_dram = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: slow_dram set\n"); + } else + psav->slow_dram = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_FAST_DRAM)) { + psav->fast_dram = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fast_dram set\n"); + } else + psav->fast_dram = FALSE; + if (xf86IsOptionSet(SavageOptions, OPTION_FPM_VRAM)) { + psav->fpm_vram = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fpm_vram set\n"); + } else + psav->fpm_vram = FALSE; + + if (xf86IsOptionSet(SavageOptions, OPTION_SHADOW_FB)) { + psav->shadowFB = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: ShadowFB %s.\n", + psav->shadowFB ? "enabled" : "disabled"); + } else + psav->shadowFB = FALSE; + + if ((s = xf86GetOptValString(SavageOptions, OPTION_ROTATE))) { + if(!xf86NameCmp(s, "CW")) { + /* accel is disabled below for shadowFB */ + psav->shadowFB = TRUE; + psav->rotate = 1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Rotating screen clockwise - acceleration disabled\n"); + } else if(!xf86NameCmp(s, "CCW")) { + psav->shadowFB = TRUE; + psav->rotate = -1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen" + "counter clockwise - acceleration disabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid" + "value for Option \"Rotate\"\n", s); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid options are \"CW\" or \"CCW\"\n"); + } + } + + if (xf86ReturnOptValBool(SavageOptions, OPTION_NOACCEL, FALSE)) { + psav->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: NoAccel - Acceleration Disabled\n"); + } else + psav->NoAccel = FALSE; + + if (psav->shadowFB && !psav->NoAccel) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "HW acceleration not supported with \"shadowFB\".\n"); + psav->NoAccel = TRUE; + } + + if (xf86ReturnOptValBool(SavageOptions, OPTION_EARLY_RAS_PRECHARGE, FALSE)) { + psav->early_ras_precharge = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: early_ras_precharge set\n"); + } else + psav->early_ras_precharge = FALSE; + + /* + * The SWCursor setting takes priority over HWCursor. The default + * if neither is specified is HW. + */ + + from = X_DEFAULT; + psav->hwcursor = TRUE; + if (xf86GetOptValBool(SavageOptions, OPTION_HWCURSOR, &psav->hwcursor)) + from = X_CONFIG; + if (xf86ReturnOptValBool(SavageOptions, OPTION_SWCURSOR, FALSE)) { + psav->hwcursor = FALSE; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", + psav->hwcursor ? "HW" : "SW"); + + from = X_DEFAULT; + psav->UseBIOS = TRUE; + if (xf86IsOptionSet(SavageOptions, OPTION_USEBIOS) ) + { + from = X_CONFIG; + xf86GetOptValBool(SavageOptions, OPTION_USEBIOS, &psav->UseBIOS); + } + xf86DrvMsg(pScrn->scrnIndex, from, "%ssing video BIOS to set modes\n", + psav->UseBIOS ? "U" : "Not u" ); + + + /* DO OTHERS HERE LATER!!!!!!!!!!!!!! */ + + from = X_DEFAULT; + + + + if (pScrn->numEntities > 1) { + SavageFreeRec(pScrn); + return FALSE; + } + + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if (pEnt->resources) { + xfree(pEnt); + SavageFreeRec(pScrn); + return FALSE; + } + psav->EntityIndex = pEnt->index; + + if (psav->UseBIOS) { + if (xf86LoadSubModule(pScrn, "int10")) { + xf86LoaderReqSymLists(int10Symbols, NULL); + psav->pInt10 = xf86InitInt10(pEnt->index); + } + + if (xf86LoadSubModule(pScrn, "vbe")) { + xf86LoaderReqSymLists(vbeSymbols, NULL); + psav->pVbe = VBEInit(psav->pInt10, pEnt->index); + } + } + + psav->PciInfo = xf86GetPciInfoForEntity(pEnt->index); + xf86RegisterResources(pEnt->index, NULL, ResNone); + xf86SetOperatingState(RES_SHARED_VGA, pEnt->index, ResUnusedOpr); + xf86SetOperatingState(resVgaMemShared, pEnt->index, ResDisableOpr); + + if (pEnt->device->chipset && *pEnt->device->chipset) { + pScrn->chipset = pEnt->device->chipset; + psav->ChipId = pEnt->device->chipID; + psav->Chipset = xf86StringToToken(SavageChipsets, pScrn->chipset); + from = X_CONFIG; + } else if (pEnt->device->chipID >= 0) { + psav->ChipId = pEnt->device->chipID; + psav->Chipset = LookupChipID(SavagePciChipsets, psav->ChipId); + pScrn->chipset = (char *)xf86TokenToString(SavageChipsets, + psav->Chipset); + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pEnt->device->chipID); + } else { + from = X_PROBED; + psav->ChipId = psav->PciInfo->chipType; + psav->Chipset = LookupChipID(SavagePciChipsets, psav->ChipId); + pScrn->chipset = (char *)xf86TokenToString(SavageChipsets, + psav->Chipset); + } + + if (pEnt->device->chipRev >= 0) { + psav->ChipRev = pEnt->device->chipRev; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + psav->ChipRev); + } else + psav->ChipRev = psav->PciInfo->chipRev; + + xfree(pEnt); + + /* maybe throw in some more sanity checks here */ + + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); + + psav->PciTag = pciTag(psav->PciInfo->bus, psav->PciInfo->device, + psav->PciInfo->func); + + hwp = VGAHWPTR(pScrn); + + if (!SavageMapMMIO(pScrn)) + return FALSE; + + vgaHWGetIOBase(hwp); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + xf86EnableIO(); + /* unprotect CRTC[0-7] */ + VGAOUT8(vgaCRIndex, 0x11); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp & 0x7f); + + /* unlock extended regs */ + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xa539); + VGAOUT16(0x3c4, 0x0608); + + VGAOUT8(vgaCRIndex, 0x40); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp & ~0x01); + + /* unlock sys regs */ + VGAOUT8(vgaCRIndex, 0x38); + VGAOUT8(vgaCRReg, 0x48); + + { + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn, zeros)) + return FALSE; + } + + /* Unlock system registers. */ + VGAOUT16(vgaCRIndex, 0x4838); + + /* Next go on to detect amount of installed ram */ + + VGAOUT8(vgaCRIndex, 0x36); /* for register CR36 (CONFG_REG1), */ + config1 = VGAIN8(vgaCRReg); /* get amount of vram installed */ + + /* Compute the amount of video memory and offscreen memory. */ + + psav->MemOffScreen = 0; + if (!pScrn->videoRam) { + static unsigned char RamSavage3D[] = { 8, 4, 4, 2 }; + static unsigned char RamSavage4[] = { 2, 4, 8, 12, 16, 32, 64, 2 }; + static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 }; + static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 2, 2 }; + + switch( psav->Chipset ) { + case S3_SAVAGE3D: + pScrn->videoRam = RamSavage3D[ (config1 & 0xC0) >> 6 ] * 1024; + break; + + case S3_SAVAGE4: + case S3_SAVAGE2000: + pScrn->videoRam = RamSavage4[ (config1 & 0xE0) >> 5 ] * 1024; + break; + + case S3_SAVAGE_MX: + pScrn->videoRam = RamSavageMX[ (config1 & 0x0E) >> 1 ] * 1024; + break; + + case S3_PROSAVAGE: + pScrn->videoRam = RamSavageNB[ (config1 & 0xE0) >> 5 ] * 1024; + break; + + default: + /* How did we get here? */ + pScrn->videoRam = 0; + break; + } + + psav->videoRambytes = pScrn->videoRam * 1024; + + if (psav->MemOffScreen) + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "probed videoram: %dk plus %dk offscreen\n", + pScrn->videoRam, + psav->MemOffScreen); + else + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "probed videoram: %dk\n", + pScrn->videoRam); + } else { + psav->videoRambytes = pScrn->videoRam * 1024; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "videoram = %dk\n", + pScrn->videoRam); + } + + /* + * If we're running with acceleration, compute the command overflow + * buffer location. The command overflow buffer must END at a + * 4MB boundary; for all practical purposes, that means the very + * end of the frame buffer. + */ + + if( psav->NoAccel ) { + psav->CursorKByte = pScrn->videoRam - 4; + psav->cobIndex = 0; + psav->cobSize = 0; + psav->cobOffset = psav->videoRambytes; + } + else if( S3_SAVAGE4_SERIES(psav->Chipset) ) { + /* + * The Savage4 and ProSavage have COB coherency bugs which render + * the buffer useless. We disable it. + */ + psav->CursorKByte = pScrn->videoRam - 4; + psav->cobIndex = 2; + psav->cobSize = 0x8000 << psav->cobIndex; + psav->cobOffset = psav->videoRambytes; + } + else + { + /* We use 128kB for the COB on all chips. */ + + psav->cobIndex = 7; + psav->cobSize = 0x400 << psav->cobIndex; + psav->cobOffset = psav->videoRambytes - psav->cobSize; + } + + /* + * We place the cursor in high memory, just before the command overflow + * buffer. The cursor must be aligned on a 4k boundary. + */ + + psav->CursorKByte = (psav->cobOffset >> 10) - 4; + + /* reset graphics engine to avoid memory corruption */ + VGAOUT8(vgaCRIndex, 0x66); + cr66 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr66 | 0x02); + usleep(10000); + + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, cr66 & ~0x02); /* clear reset flag */ + usleep(10000); + + /* Set status word positions based on chip type. */ + + switch( psav->Chipset ) { + case S3_SAVAGE3D: + case S3_SAVAGE_MX: + psav->myWaitQueue = WaitQueue3D; + psav->myWaitIdle = WaitIdle3D; + psav->myWaitIdleEmpty = WaitIdleEmpty3D; + psav->myWaitCommandEmpty = WaitCommandEmpty3D; + break; + + case S3_SAVAGE4: + case S3_PROSAVAGE: + psav->myWaitQueue = WaitQueue4; + psav->myWaitIdle = WaitIdle4; + psav->myWaitIdleEmpty = WaitIdleEmpty4; + psav->myWaitCommandEmpty = WaitCommandEmpty4; + break; + + case S3_SAVAGE2000: + psav->myWaitQueue = WaitQueue2K; + psav->myWaitIdle = WaitIdle2K; + psav->myWaitIdleEmpty = WaitIdleEmpty2K; + psav->myWaitCommandEmpty = WaitCommandEmpty2K; + break; + } + + /* savage ramdac speeds */ + pScrn->numClocks = 4; + pScrn->clock[0] = 250000; + pScrn->clock[1] = 250000; + pScrn->clock[2] = 220000; + pScrn->clock[3] = 220000; + + if (psav->dacSpeedBpp <= 0) { + if (pScrn->bitsPerPixel > 24) + psav->dacSpeedBpp = pScrn->clock[3]; + else if (pScrn->bitsPerPixel >= 24) + psav->dacSpeedBpp = pScrn->clock[2]; + else if ((pScrn->bitsPerPixel > 8) && (pScrn->bitsPerPixel < 24)) + psav->dacSpeedBpp = pScrn->clock[1]; + else if (pScrn->bitsPerPixel <= 8) + psav->dacSpeedBpp = pScrn->clock[0]; + } + + /* set ramdac limits */ + psav->maxClock = psav->dacSpeedBpp; + + /* detect current mclk */ + VGAOUT8(0x3c4, 0x08); + sr8 = VGAIN8(0x3c5); + VGAOUT8(0x3c5, 0x06); + VGAOUT8(0x3c4, 0x10); + n = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x11); + m = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x08); + VGAOUT8(0x3c5, sr8); + m &= 0x7f; + n1 = n & 0x1f; + n2 = (n >> 5) & 0x03; + mclk = ((1431818 * (m+2)) / (n1+2) / (1 << n2) + 50) / 100; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected current MCLK value of %1.3f MHz\n", + mclk / 1000.0); + + psav->minClock = 20000; + + pScrn->maxHValue = 2048; + pScrn->maxVValue = 2048; + pScrn->virtualX = pScrn->display->virtualX; + + clockRanges = xnfalloc(sizeof(ClockRange)); + clockRanges->next = NULL; + clockRanges->minClock = psav->minClock; + clockRanges->maxClock = psav->maxClock; + clockRanges->clockIndex = -1; + clockRanges->interlaceAllowed = TRUE; + clockRanges->doubleScanAllowed = FALSE; + + i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, + pScrn->display->modes, clockRanges, NULL, + 256, 2048, 16 * pScrn->bitsPerPixel, + 128, 2048, + pScrn->virtualX, pScrn->display->virtualY, + psav->videoRambytes, LOOKUP_BEST_REFRESH); + + if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86ValidateModes failure\n"); + SavageFreeRec(pScrn); + return FALSE; + } + + xf86PruneDriverModes(pScrn); + + if (i == 0 || pScrn->modes == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + SavageFreeRec(pScrn); + return FALSE; + } + + if( psav->UseBIOS ) + { + /* Go probe the BIOS for all the modes and refreshes at this depth. */ + + if( psav->ModeTable ) + { + SavageFreeBIOSModeTable( psav, &psav->ModeTable ); + } + + psav->ModeTable = SavageGetBIOSModeTable( psav, pScrn->depth ); + + if( !psav->ModeTable || !psav->ModeTable->NumModes ) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to fetch any BIOS modes.\n"); + SavageFreeRec(pScrn); + return FALSE; + } + + /*if( xf86Verbose )*/ + { + int i; + SavageModeEntryPtr pmt; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Found %d modes at this depth:\n", + psav->ModeTable->NumModes); + + for( + i = 0, pmt = psav->ModeTable->Modes; + i < psav->ModeTable->NumModes; + i++, pmt++ ) + { + int j; + ErrorF( " [%03x] %d x %d", + pmt->VesaMode, pmt->Width, pmt->Height ); + for( j = 0; j < pmt->RefreshCount; j++ ) + { + ErrorF( ", %dHz", pmt->RefreshRate[j] ); + } + ErrorF( "\n"); + } + } + } + + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + xf86SetDpi(pScrn, 0, 0); + + /* load bpp-specific modules */ + switch (pScrn->bitsPerPixel) { + case 8: + mod = "cfb"; + reqSym = "cfbScreenInit"; + break; + case 16: + mod = "cfb16"; + reqSym = "cfb16ScreenInit"; + break; + case 32: + mod = "cfb32"; + reqSym = "cfb32ScreenInit"; + break; + } + + if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { + SavageFreeRec(pScrn); + return FALSE; + } + + xf86LoaderReqSymbols(reqSym, NULL); + + if( !psav->NoAccel ) { + if( !xf86LoadSubModule(pScrn, "xaa") ) { + SavageFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(xaaSymbols, NULL ); + } + + if (psav->hwcursor) { + if (!xf86LoadSubModule(pScrn, "ramdac")) { + SavageFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + } + + if (psav->shadowFB) { + if (!xf86LoadSubModule(pScrn, "shadowfb")) { + SavageFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(shadowSymbols, NULL); + } + + return TRUE; +} + + +static Bool SavageEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + SavageSave(pScrn); + return SavageModeInit(pScrn, pScrn->currentMode); +} + + +static void SavageLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SavageRegPtr SavageSavePtr = &psav->SavedReg; + + SavageWriteMode(pScrn, vgaSavePtr, SavageSavePtr); +} + + +static void SavageSave(ScrnInfoPtr pScrn) +{ + unsigned char cr3a, cr53, cr66; + vgaHWPtr hwp = VGAHWPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SavagePtr psav = SAVPTR(pScrn); + SavageRegPtr save = &psav->SavedReg; + int vgaCRIndex, vgaCRReg, vgaIOBase; + vgaIOBase = hwp->IOBase; + vgaCRReg = vgaIOBase + 5; + vgaCRIndex = vgaIOBase + 4; + + + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xa539); + VGAOUT16(0x3c4, 0x0608); + + VGAOUT8(vgaCRIndex, 0x66); + cr66 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr66 | 0x80); + VGAOUT8(vgaCRIndex, 0x3a); + cr3a = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr3a | 0x80); + VGAOUT8(vgaCRIndex, 0x53); + cr53 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr53 & 0x7f); + + if (xf86IsPrimaryPci(psav->PciInfo)) + vgaHWSave(pScrn, vgaSavePtr, VGA_SR_ALL); + else + vgaHWSave(pScrn, vgaSavePtr, VGA_SR_MODE); + + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, cr66); + VGAOUT8(vgaCRIndex, 0x3a); + VGAOUT8(vgaCRReg, cr3a); + + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, cr66); + VGAOUT8(vgaCRIndex, 0x3a); + VGAOUT8(vgaCRReg, cr3a); + + /* unlock extended seq regs */ + VGAOUT8(0x3c4, 0x08); + save->SR08 = VGAIN8(0x3c5); + VGAOUT8(0x3c5, 0x06); + + /* now save all the extended regs we need */ + VGAOUT8(vgaCRIndex, 0x31); + save->CR31 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x32); + save->CR32 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x34); + save->CR34 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x36); + save->CR36 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x3a); + save->CR3A = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x40); + save->CR40 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x42); + save->CR42 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x45); + save->CR45 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x50); + save->CR50 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x51); + save->CR51 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x53); + save->CR53 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x58); + save->CR58 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x60); + save->CR60 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x66); + save->CR66 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x67); + save->CR67 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x68); + save->CR68 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x69); + save->CR69 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x6f); + save->CR6F = VGAIN8(vgaCRReg); + + VGAOUT8(vgaCRIndex, 0x33); + save->CR33 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x86); + save->CR86 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x88); + save->CR88 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x90); + save->CR90 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x91); + save->CR91 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0xb0); + save->CRB0 = VGAIN8(vgaCRReg) | 0x80; + + /* extended mode timing regs */ + VGAOUT8(vgaCRIndex, 0x3b); + save->CR3B = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x3c); + save->CR3C = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x43); + save->CR43 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x5d); + save->CR5D = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x5e); + save->CR5E = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x65); + save->CR65 = VGAIN8(vgaCRReg); + + /* save seq extended regs for DCLK PLL programming */ + VGAOUT8(0x3c4, 0x10); + save->SR10 = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x11); + save->SR11 = VGAIN8(0x3c5); + + VGAOUT8(0x3c4, 0x12); + save->SR12 = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x13); + save->SR13 = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x29); + save->SR29 = VGAIN8(0x3c5); + + VGAOUT8(0x3c4, 0x15); + save->SR15 = VGAIN8(0x3c5); + VGAOUT8(0x3c4, 0x18); + save->SR18 = VGAIN8(0x3c5); + + /* Save flat panel expansion regsters. */ + + if( psav->Chipset == S3_SAVAGE_MX ) { + int i; + for( i = 0; i < 8; i++ ) { + VGAOUT8(0x3c4, 0x54+i); + save->SR54[i] = VGAIN8(0x3c5); + } + } + + VGAOUT8(vgaCRIndex, 0x66); + cr66 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr66 | 0x80); + VGAOUT8(vgaCRIndex, 0x3a); + cr3a = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr3a | 0x80); + + /* now save MIU regs */ + save->MMPR0 = INREG(FIFO_CONTROL_REG); + save->MMPR1 = INREG(MIU_CONTROL_REG); + save->MMPR2 = INREG(STREAMS_TIMEOUT_REG); + save->MMPR3 = INREG(MISC_TIMEOUT_REG); + + VGAOUT8(vgaCRIndex, 0x3a); + VGAOUT8(vgaCRReg, cr3a); + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, cr66); + + if (!psav->ModeStructInit) { + vgaHWCopyReg(&hwp->ModeReg, vgaSavePtr); + memcpy(&psav->ModeReg, save, sizeof(SavageRegRec)); + psav->ModeStructInit = TRUE; + } + +#if 0 + if (xf86GetVerbosity() > 1) + SavagePrintRegs(pScrn); +#endif + + return; +} + + +static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, + SavageRegPtr restore) +{ + unsigned char tmp, cr3a, cr66, cr67; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int vgaCRIndex, vgaCRReg, vgaIOBase; + Bool graphicsMode = FALSE; + + + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + /* + * If we figured out a VESA mode number for this timing, just use + * the S3 BIOS to do the switching, with a few additional tweaks. + */ + + if( psav->UseBIOS && restore->mode > 0x13 ) + { + int width; + unsigned short cr6d; + unsigned short cr79 = 0; + + /* Set up the mode. Don't clear video RAM. */ + SavageSetVESAMode( psav, restore->mode | 0x8000, restore->refresh ); + + /* Restore the DAC. */ + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_CMAP); + + /* Unlock the extended registers. */ + +#if 0 + /* Which way is better? */ + hwp->writeCrtc( hwp, 0x38, 0x48 ); + hwp->writeCrtc( hwp, 0x39, 0xa0 ); + hwp->writeSeq( hwp, 0x08, 0x06 ); +#endif + + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xA039); + VGAOUT16(0x3c4, 0x0608); + + /* Enable linear addressing. */ + + VGAOUT16(vgaCRIndex, 0x1358); + + /* Disable old MMIO. */ + + VGAOUT8(vgaCRIndex, 0x53); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp & ~0x10); + + /* We may need TV/panel fixups here. See s3bios.c line 2904. */ + + /* Set FIFO fetch delay. */ + VGAOUT8(vgaCRIndex, 0x85); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, (tmp & 0xf8) | 0x03); + + /* Patch CR79. These values are magical. */ + + if( psav->Chipset != S3_SAVAGE_MX ) + { + VGAOUT8(vgaCRIndex, 0x6d); + cr6d = VGAIN8(vgaCRReg); + + cr79 = 0x04; + + if( pScrn->displayWidth >= 1024 ) + { + if(pScrn->bitsPerPixel == 32 ) + { + if( restore->refresh >= 130 ) + cr79 = 0x03; + else if( pScrn->displayWidth >= 1280 ) + cr79 = 0x02; + else if( + (pScrn->displayWidth == 1024) && + (restore->refresh >= 75) + ) + { + if( cr6d && LCD_ACTIVE ) + cr79 = 0x05; + else + cr79 = 0x08; + } + } + else if( pScrn->bitsPerPixel == 16) + { + +/* The windows driver uses 0x13 for 16-bit 130Hz, but I see terrible + * screen artifacts with that value. Let's keep it low for now. + * if( restore->refresh >= 130 ) + * cr79 = 0x13; + * else + */ + if( pScrn->displayWidth == 1024 ) + { + if( cr6d && LCD_ACTIVE ) + cr79 = 0x08; + else + cr79 = 0x0e; + } + } + } + } + + if( (psav->Chipset != S3_SAVAGE2000) && + (psav->Chipset != S3_SAVAGE_MX) ) + VGAOUT16(vgaCRIndex, (cr79 << 8) | 0x79); + + /* Make sure 16-bit memory access is enabled. */ + + VGAOUT16(vgaCRIndex, 0x0c31); + + /* Enable the graphics engine. */ + + VGAOUT16(vgaCRIndex, 0x0140); + #if 0 + if( !psav->NoAccel ) + S3SAVInitialize2DEngine(); + #endif + + /* Handle the pitch. */ + + VGAOUT8(vgaCRIndex, 0x50); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp | 0xC1); + + width = (pScrn->displayWidth * (pScrn->bitsPerPixel / 8)) >> 3; + VGAOUT16(vgaCRIndex, ((width & 0xff) << 8) | 0x13 ); + VGAOUT16(vgaCRIndex, ((width & 0x300) << 4) | 0x51 ); + + /* Some non-S3 BIOSes enable block write even on non-SGRAM devices. */ + + if( psav->Chipset == S3_SAVAGE2000 ) + { + VGAOUT8(vgaCRIndex, 0x73); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp & 0xdf ); + } + else if( psav->Chipset != S3_SAVAGE_MX ) + { + VGAOUT8(vgaCRIndex, 0x68); + if( !(VGAIN8(vgaCRReg) & 0x80) ) + { + /* Not SGRAM; disable block write. */ + VGAOUT8(vgaCRIndex, 0x88); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp | 0x10); + } + } + + if( !psav->NoAccel ) + SavageInitialize2DEngine(pScrn); + + VGAOUT16(vgaCRIndex, 0x0140); + + SavageSetGBD(pScrn); + + return; + } + + VGAOUT8(0x3c2, 0x23); + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xa539); + VGAOUT16(0x3c4, 0x0608); + + vgaHWProtect(pScrn, TRUE); + + /* will we be reenabling STREAMS for the new mode? */ + psav->STREAMSRunning = 0; + + graphicsMode = (restore->CR31 & 0x0a) ? TRUE : FALSE; + + /* reset GE to make sure nothing is going on */ + VGAOUT8(vgaCRIndex, 0x66); + if(VGAIN8(vgaCRReg) & 0x01) + SavageGEReset(pScrn,0,__LINE__,__FILE__); + + /* + * Some Savage/MX and /IX systems go nuts when trying to exit the + * server after WindowMaker has displayed a gradient background. I + * haven't been able to find what causes it, but a non-destructive + * switch to mode 3 here seems to eliminate the issue. + */ + +#define CLEAR_X86_REGS(pi) \ + (pi)->ax = (pi)->bx = (pi)->cx = (pi)->dx = (pi)->si = (pi)->di = 0 + + if( !graphicsMode && psav->pInt10 ) { + CLEAR_X86_REGS( psav->pInt10 ); + psav->pInt10->num = 0x10; + psav->pInt10->ax = 0x0083; + xf86ExecX86int10( psav->pInt10 ); + } + + VGAOUT8(vgaCRIndex, 0x67); + cr67 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, restore->CR67 & ~0x0c); /* no STREAMS yet */ + + /* restore extended regs */ + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, restore->CR66); + VGAOUT8(vgaCRIndex, 0x3a); + VGAOUT8(vgaCRReg, restore->CR3A); + VGAOUT8(vgaCRIndex, 0x31); + VGAOUT8(vgaCRReg, restore->CR31); + VGAOUT8(vgaCRIndex, 0x32); + VGAOUT8(vgaCRReg, restore->CR32); + VGAOUT8(vgaCRIndex, 0x58); + VGAOUT8(vgaCRReg, restore->CR58); + VGAOUT8(vgaCRIndex, 0x53); + VGAOUT8(vgaCRReg, restore->CR53 & 0x7f); + + VGAOUT8(0x3c4, 0x08); + VGAOUT8(0x3c5, 0x06); + VGAOUT8(0x3c4, 0x12); + VGAOUT8(0x3c5, restore->SR12); + VGAOUT8(0x3c4, 0x13); + VGAOUT8(0x3c5, restore->SR13); + VGAOUT8(0x3c4, 0x29); + VGAOUT8(0x3c5, restore->SR29); + VGAOUT8(0x3c4, 0x15); + VGAOUT8(0x3c5, restore->SR15); + + /* Restore flat panel expansion regsters. */ + if( psav->Chipset == S3_SAVAGE_MX ) { + int i; + for( i = 0; i < 8; i++ ) { + VGAOUT8(0x3c4, 0x54+i); + VGAOUT8(0x3c5, restore->SR54[i]); + } + } + + /* restore the standard vga regs */ + if (xf86IsPrimaryPci(psav->PciInfo)) + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_ALL); + else + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_MODE); + + /* extended mode timing registers */ + VGAOUT8(vgaCRIndex, 0x53); + VGAOUT8(vgaCRReg, restore->CR53); + VGAOUT8(vgaCRIndex, 0x5d); + VGAOUT8(vgaCRReg, restore->CR5D); + VGAOUT8(vgaCRIndex, 0x5e); + VGAOUT8(vgaCRReg, restore->CR5E); + VGAOUT8(vgaCRIndex, 0x3b); + VGAOUT8(vgaCRReg, restore->CR3B); + VGAOUT8(vgaCRIndex, 0x3c); + VGAOUT8(vgaCRReg, restore->CR3C); + VGAOUT8(vgaCRIndex, 0x43); + VGAOUT8(vgaCRReg, restore->CR43); + VGAOUT8(vgaCRIndex, 0x65); + VGAOUT8(vgaCRReg, restore->CR65); + + /* restore the desired video mode with cr67 */ + VGAOUT8(vgaCRIndex, 0x67); + VGAOUT8(vgaCRReg, restore->CR67 & ~0x0c); /* no STREAMS yet */ + + /* other mode timing and extended regs */ + VGAOUT8(vgaCRIndex, 0x34); + VGAOUT8(vgaCRReg, restore->CR34); + VGAOUT8(vgaCRIndex, 0x40); + VGAOUT8(vgaCRReg, restore->CR40); + VGAOUT8(vgaCRIndex, 0x42); + VGAOUT8(vgaCRReg, restore->CR42); + VGAOUT8(vgaCRIndex, 0x45); + VGAOUT8(vgaCRReg, restore->CR45); + VGAOUT8(vgaCRIndex, 0x50); + VGAOUT8(vgaCRReg, restore->CR50); + VGAOUT8(vgaCRIndex, 0x51); + VGAOUT8(vgaCRReg, restore->CR51); + + /* memory timings */ + VGAOUT8(vgaCRIndex, 0x36); + VGAOUT8(vgaCRReg, restore->CR36); + VGAOUT8(vgaCRIndex, 0x60); + VGAOUT8(vgaCRReg, restore->CR60); + VGAOUT8(vgaCRIndex, 0x68); + VGAOUT8(vgaCRReg, restore->CR68); + VGAOUT8(vgaCRIndex, 0x69); + VGAOUT8(vgaCRReg, restore->CR69); + VGAOUT8(vgaCRIndex, 0x6f); + VGAOUT8(vgaCRReg, restore->CR6F); + + VGAOUT8(vgaCRIndex, 0x33); + VGAOUT8(vgaCRReg, restore->CR33); + VGAOUT8(vgaCRIndex, 0x86); + VGAOUT8(vgaCRReg, restore->CR86); + VGAOUT8(vgaCRIndex, 0x88); + VGAOUT8(vgaCRReg, restore->CR88); + VGAOUT8(vgaCRIndex, 0x90); + VGAOUT8(vgaCRReg, restore->CR90); + VGAOUT8(vgaCRIndex, 0x91); + VGAOUT8(vgaCRReg, restore->CR91); + if( psav->Chipset == S3_SAVAGE4 ) + { + VGAOUT8(vgaCRIndex, 0xb0); + VGAOUT8(vgaCRReg, restore->CRB0); + } + + VGAOUT8(vgaCRIndex, 0x32); + VGAOUT8(vgaCRReg, restore->CR32); + + /* unlock extended seq regs */ + VGAOUT8(0x3c4, 0x08); + VGAOUT8(0x3c5, 0x06); + + /* Restore extended sequencer regs for MCLK. SR10 == 255 indicates that + * we should leave the default SR10 and SR11 values there. + */ + if (restore->SR10 != 255) { + VGAOUT8(0x3c4, 0x10); + VGAOUT8(0x3c5, restore->SR10); + VGAOUT8(0x3c4, 0x11); + VGAOUT8(0x3c5, restore->SR11); + } + + /* restore extended seq regs for dclk */ + VGAOUT8(0x3c4, 0x12); + VGAOUT8(0x3c5, restore->SR12); + VGAOUT8(0x3c4, 0x13); + VGAOUT8(0x3c5, restore->SR13); + VGAOUT8(0x3c4, 0x29); + VGAOUT8(0x3c5, restore->SR29); + + VGAOUT8(0x3c4, 0x18); + VGAOUT8(0x3c5, restore->SR18); + + /* load new m, n pll values for dclk & mclk */ + VGAOUT8(0x3c4, 0x15); + tmp = VGAIN8(0x3c5) & ~0x21; + + VGAOUT8(0x3c5, tmp | 0x03); + VGAOUT8(0x3c5, tmp | 0x23); + VGAOUT8(0x3c5, tmp | 0x03); + VGAOUT8(0x3c5, restore->SR15); + + VGAOUT8(0x3c4, 0x08); + VGAOUT8(0x3c5, restore->SR08); + + /* now write out cr67 in full, possibly starting STREAMS */ + VerticalRetraceWait(); + VGAOUT8(vgaCRIndex, 0x67); +#if 0 + VGAOUT8(vgaCRReg, 0x50); + usleep(10000); + VGAOUT8(vgaCRIndex, 0x67); +#endif + VGAOUT8(vgaCRReg, restore->CR67); + + VGAOUT8(vgaCRIndex, 0x66); + cr66 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr66 | 0x80); + VGAOUT8(vgaCRIndex, 0x3a); + cr3a = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, cr3a | 0x80); + + if (graphicsMode) + SavageGEReset(pScrn,0,__LINE__,__FILE__); + + VerticalRetraceWait(); + OUTREG(FIFO_CONTROL_REG, restore->MMPR0); + WaitIdle(); + OUTREG(MIU_CONTROL_REG, restore->MMPR1); + WaitIdle(); + OUTREG(STREAMS_TIMEOUT_REG, restore->MMPR2); + WaitIdle(); + OUTREG(MISC_TIMEOUT_REG, restore->MMPR3); + + /* If we're going into graphics mode and acceleration was enabled, */ + /* go set up the BCI buffer and the global bitmap descriptor. */ + + if( graphicsMode && (!psav->NoAccel) ) + { + VGAOUT8(vgaCRIndex, 0x50); + tmp = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, tmp | 0xC1); + SavageInitialize2DEngine(pScrn); + } + + VGAOUT8(vgaCRIndex, 0x66); + VGAOUT8(vgaCRReg, cr66); + VGAOUT8(vgaCRIndex, 0x3a); + VGAOUT8(vgaCRReg, cr3a); + + if( graphicsMode ) + SavageSetGBD(pScrn); + + vgaHWProtect(pScrn, FALSE); + + return; +} + + +static Bool SavageMapMMIO(ScrnInfoPtr pScrn) +{ + SavagePtr psav; + vgaHWPtr hwp; + + psav = SAVPTR(pScrn); + + if( S3_SAVAGE3D_SERIES(psav->Chipset) ) { + psav->MmioBase = psav->PciInfo->memBase[0] + SAVAGE_NEWMMIO_REGBASE_S3; + psav->FrameBufferBase = psav->PciInfo->memBase[0]; + } + else { + psav->MmioBase = psav->PciInfo->memBase[0] + SAVAGE_NEWMMIO_REGBASE_S4; + psav->FrameBufferBase = psav->PciInfo->memBase[1]; + } + + xf86DrvMsg( pScrn->scrnIndex, X_PROBED, + "mapping MMIO @ 0x%x with size 0x%x\n", + psav->MmioBase, SAVAGE_NEWMMIO_REGSIZE); + + psav->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, psav->PciTag, + psav->MmioBase, + SAVAGE_NEWMMIO_REGSIZE); +#if 0 + psav->MapBaseDense = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, + psav->PciTag, + psav->PciInfo->memBase[0], + 0x8000); +#endif + if (!psav->MapBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Internal error: cound not map registers\n"); + return FALSE; + } + + psav->BciMem = psav->MapBase + 0x10000; + + SavageEnableMMIO(pScrn); + hwp = VGAHWPTR(pScrn); + vgaHWGetIOBase(hwp); + + return TRUE; +} + + + +static Bool SavageMapFB(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + + xf86DrvMsg( pScrn->scrnIndex, X_PROBED, + "mapping framebuffer @ 0x%x with size 0x%x\n", + psav->FrameBufferBase, psav->videoRambytes); + + if (psav->videoRambytes) { + psav->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, + psav->PciTag, psav->FrameBufferBase, + psav->videoRambytes); + if (!psav->FBBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Internal error: could not map framebuffer\n"); + return FALSE; + } + psav->FBStart = psav->FBBase; + } + pScrn->memPhysBase = psav->PciInfo->memBase[0]; + pScrn->fbOffset = 0; +/* psav->FBCursorOffset = psav->videoRambytes - 1024; */ + + return TRUE; +} + + +static void SavageUnmapMem(ScrnInfoPtr pScrn) +{ + SavagePtr psav; + + psav = SAVPTR(pScrn); + + if (psav->PrimaryVidMapped) { + vgaHWUnmapMem(pScrn); + psav->PrimaryVidMapped = FALSE; + } + + SavageDisableMMIO(pScrn); + if (psav->MapBase) + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->MapBase, + SAVAGE_NEWMMIO_REGSIZE); + if (psav->FBBase) + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->FBBase, + psav->videoRambytes); +#if 0 + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->MapBaseDense, + 0x8000); +#endif + + return; +} + + +static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, + int argc, char **argv) +{ + ScrnInfoPtr pScrn; + SavagePtr psav; + int ret; + + pScrn = xf86Screens[pScreen->myNum]; + psav = SAVPTR(pScrn); + + if (!SavageMapFB(pScrn)) + return FALSE; + + SavageSave(pScrn); + + vgaHWBlankScreen(pScrn, TRUE); + + if (!SavageModeInit(pScrn, pScrn->currentMode)) + return FALSE; + + miClearVisualTypes(); + + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } else { + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + } + + ret = SavageInternalScreenInit(scrnIndex, pScreen); + if (!ret) + return FALSE; + + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) { + VisualPtr visual; + + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + if( !psav->NoAccel ) { + SavageInitAccel(pScreen); + } + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + +#if 0 + SavageDGAInit(pScreen); +#endif + + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + if (psav->hwcursor) + if (!SavageHWCursorInit(pScreen)) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + + if (psav->shadowFB) { + RefreshAreaFuncPtr refreshArea = SavageRefreshArea; + +#if 1 + if(psav->rotate) { + if (!psav->PointerMoved) { + psav->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = SavagePointerMoved; + } + + switch(pScrn->bitsPerPixel) { + case 8: refreshArea = SavageRefreshArea8; break; + case 16: refreshArea = SavageRefreshArea16; break; + case 24: refreshArea = SavageRefreshArea24; break; + case 32: refreshArea = SavageRefreshArea32; break; + } + } +#endif + + ShadowFBInit(pScreen, refreshArea); + } + + if (!miCreateDefColormap(pScreen)) + return FALSE; + + if (!xf86HandleColormaps(pScreen, 256, 6, SavageLoadPalette, NULL, + CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; + + vgaHWBlankScreen(pScrn, FALSE); + + psav->CloseScreen = pScreen->CloseScreen; + pScreen->SaveScreen = SavageSaveScreen; + pScreen->CloseScreen = SavageCloseScreen; + +#ifdef DPMSExtension + if (xf86DPMSInit(pScreen, SavageDPMS, 0) == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DPMS initialization failed\n"); +#endif + + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + + return TRUE; +} + + +static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen) +{ + int ret = TRUE; + ScrnInfoPtr pScrn; + SavagePtr psav; + int width, height, displayWidth; + unsigned char *FBStart; + + pScrn = xf86Screens[pScreen->myNum]; + psav = SAVPTR(pScrn); + + displayWidth = pScrn->displayWidth; + + if (psav->rotate) { + height = pScrn->virtualX; + width = pScrn->virtualY; + } else { + width = pScrn->virtualX; + height = pScrn->virtualY; + } + + + if(psav->shadowFB) { + psav->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width); + psav->ShadowPtr = xalloc(psav->ShadowPitch * height); + displayWidth = psav->ShadowPitch / (pScrn->bitsPerPixel >> 3); + FBStart = psav->ShadowPtr; + } else { + psav->ShadowPtr = NULL; + FBStart = psav->FBStart; + } + + switch (pScrn->bitsPerPixel) { + case 8: + ret = cfbScreenInit(pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth); + break; + case 16: + ret = cfb16ScreenInit(pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth); + break; + case 32: + ret = cfb32ScreenInit(pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth); + break; + default: + xf86DrvMsg(scrnIndex, X_ERROR, + "Internal error: invalid bpp (%d) in SavageScreenInit\n", + pScrn->bitsPerPixel); + ret = FALSE; + break; + } + + return ret; +} + + +static ModeStatus SavageValidMode(int index, DisplayModePtr mode, + Bool verbose, int flags) +{ + /* TODO check modes */ + return MODE_OK; +} + +static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int width, dclk, i, j; /*, refresh; */ + unsigned int m, n, r; + unsigned char tmp = 0; + SavageRegPtr new = &psav->ModeReg; + vgaRegPtr vganew = &hwp->ModeReg; + int vgaCRIndex, vgaCRReg, vgaIOBase; + + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + +#if 0 + ErrorF("Clock = %d, HDisplay = %d, HSStart = %d\n", + mode->Clock, mode->HDisplay, mode->HSyncStart); + ErrorF("HSEnd = %d, HSkew = %d\n", + mode->HSyncEnd, mode->HSkew); + ErrorF("VDisplay - %d, VSStart = %d, VSEnd = %d\n", + mode->VDisplay, mode->VSyncStart, mode->VSyncEnd); + ErrorF("VTotal = %d\n", + mode->VTotal); + ErrorF("HDisplay = %d, HSStart = %d\n", + mode->CrtcHDisplay, mode->CrtcHSyncStart); + ErrorF("HSEnd = %d, HSkey = %d\n", + mode->CrtcHSyncEnd, mode->CrtcHSkew); + ErrorF("VDisplay - %d, VSStart = %d, VSEnd = %d\n", + mode->CrtcVDisplay, mode->CrtcVSyncStart, mode->CrtcVSyncEnd); + ErrorF("VTotal = %d\n", + mode->CrtcVTotal); +#endif + + + + if (pScrn->bitsPerPixel == 8) + psav->HorizScaleFactor = 1; + else if (pScrn->bitsPerPixel == 16) + psav->HorizScaleFactor = 1; /* I don't think we ever want 2 */ + else + psav->HorizScaleFactor = 1; + + if (psav->HorizScaleFactor == 2) + if (!mode->CrtcHAdjusted) { + mode->CrtcHDisplay *= 2; + mode->CrtcHSyncStart *= 2; + mode->CrtcHSyncEnd *= 2; + mode->CrtcHTotal *= 2; + mode->CrtcHSkew *= 2; + mode->CrtcHAdjusted = TRUE; + } + + if (!vgaHWInit(pScrn, mode)) + return FALSE; + + new->mode = 0; + + if( psav->UseBIOS ) { + int refresh; + SavageModeEntryPtr pmt; + + /* Scan through our BIOS list to locate the closest valid mode. */ + + /* If we ever break 4GHz clocks on video boards, we'll need to + * change this. + */ + + refresh = (mode->Clock * 1000) / (mode->HTotal * mode->VTotal); + +#ifdef EXTENDED_DEBUG + ErrorF( "Desired refresh rate = %dHz\n", refresh ); +#endif + + for( i = 0, pmt = psav->ModeTable->Modes; + i < psav->ModeTable->NumModes; + i++, pmt++ ) + { + if( (pmt->Width == mode->HDisplay) && + (pmt->Height == mode->VDisplay) ) + { + int j; + int jDelta = 99; + int jBest = 0; + + /* We have an acceptable mode. Find a refresh rate. */ + + new->mode = pmt->VesaMode; + for( j = 0; j < pmt->RefreshCount; j++ ) + { + if( pmt->RefreshRate[j] == refresh ) + { + /* Exact match. */ + jBest = j; + break; + } + else if( iabs(pmt->RefreshRate[j] - refresh) < jDelta ) + { + jDelta = iabs(pmt->RefreshRate[j] - refresh); + jBest = j; + } + } + + new->refresh = pmt->RefreshRate[jBest]; + break; + } + } + } + + if( new->mode ) { + /* Success: we found a match in the BIOS. */ + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Chose mode %x at %dHz.\n", new->mode, new->refresh ); + } + else { + + /* We failed to find a match in the BIOS. */ + /* Fallthrough to the traditional register-crunching. */ + + VGAOUT8(vgaCRIndex, 0x3a); + tmp = VGAIN8(vgaCRReg); + if (psav->pci_burst) + new->CR3A = (tmp & 0x7f) | 0x15; + else + new->CR3A = tmp | 0x95; + + new->CR53 = 0x00; + new->CR31 = 0x8c; + new->CR66 = 0x89; + + VGAOUT8(vgaCRIndex, 0x58); + new->CR58 = VGAIN8(vgaCRReg) & 0x80; + new->CR58 |= 0x13; + +#if 0 + VGAOUT8(vgaCRIndex, 0x55); + new->CR55 = VGAIN8(vgaCRReg); + if (psav->hwcursor) + new->CR55 |= 0x10; +#endif + + dclk = mode->Clock; + new->CR67 = 0x00; + new->SR15 = 0x03 | 0x80; + new->SR18 = 0x00; + new->CR43 = new->CR45 = new->CR65 = 0x00; + + VGAOUT8(vgaCRIndex, 0x40); + new->CR40 = VGAIN8(vgaCRReg) & ~0x01; + + new->MMPR0 = 0x010400; + new->MMPR1 = 0x00; + new->MMPR2 = 0x0808; + new->MMPR3 = 0x08080810; + + if (psav->fifo_aggressive || psav->fifo_moderate || + psav->fifo_conservative) { + new->MMPR1 = 0x0200; + new->MMPR2 = 0x1808; + new->MMPR3 = 0x08081810; + } + + if (psav->MCLK <= 0) { + new->SR10 = 255; + new->SR11 = 255; + } + + psav->NeedSTREAMS = FALSE; + + /**** + * TODO + * old code uses the "dclk<=110000" path for all non-MX/IX, and the + * >110000 path for MX/IX. What does this mean? + ****/ + + if (pScrn->bitsPerPixel == 8) { + if (dclk <= 110000) + new->CR67 = 0x00; /* 8bpp, 135Mhz */ + else + new->CR67 = 0x10; /* 8bpp, 220Mhz */ + } else if ((pScrn->bitsPerPixel == 16) && (pScrn->weight.green == 5)) { + if (dclk <= 110000) + new->CR67 = 0x20; /* 15bpp, 135Mhz */ + else + new->CR67 = 0x30; /* 15bpp, 220Mhz */ + } else if (pScrn->bitsPerPixel == 16) { + if (dclk <= 110000) + new->CR67 = 0x40; /* 16bpp, 135Mhz */ + else + new->CR67 = 0x50; /* 16bpp, 220Mhz */ + } else if (pScrn->bitsPerPixel == 32) { + new->CR67 = 0xd0; + } + + SavageCalcClock(dclk, 1, 1, 127, 0, 4, 180000, 360000, + &m, &n, &r); + new->SR12 = (r << 6) | (n & 0x3f); + new->SR13 = m & 0xff; + new->SR29 = (r & 4) | (m & 0x100) >> 5 | (n & 0x40) >> 2; + + if (psav->fifo_moderate) { + if (pScrn->bitsPerPixel < 24) + new->MMPR0 -= 0x8000; + else + new->MMPR0 -= 0x4000; + } else if (psav->fifo_aggressive) { + if (pScrn->bitsPerPixel < 24) + new->MMPR0 -= 0xc000; + else + new->MMPR0 -= 0x6000; + } + + if (mode->Flags & V_INTERLACE) + new->CR42 = 0x20; + else + new->CR42 = 0x00; + + new->CR34 = 0x10; + + i = ((((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8) | + ((((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7) | + ((((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6) | + ((mode->CrtcHSyncStart & 0x800) >> 7); + + if ((mode->CrtcHSyncEnd >> 3) - (mode->CrtcHSyncStart >> 3) > 64) + i |= 0x08; + if ((mode->CrtcHSyncEnd >> 3) - (mode->CrtcHSyncStart >> 3) > 32) + i |= 0x20; + j = (vganew->CRTC[0] + ((i & 0x01) << 8) + + vganew->CRTC[4] + ((i & 0x10) << 4) + 1) / 2; + if (j - (vganew->CRTC[4] + ((i & 0x10) << 4)) < 4) { + if (vganew->CRTC[4] + ((i & 0x10) << 4) + 4 <= + vganew->CRTC[0] + ((i & 0x01) << 8)) + j = vganew->CRTC[4] + ((i & 0x10) << 4) + 4; + else + j = vganew->CRTC[0] + ((i & 0x01) << 8) + 1; + } + + new->CR3B = j & 0xff; + i |= (j & 0x100) >> 2; + new->CR3C = (vganew->CRTC[0] + ((i & 0x01) << 8)) / 2; + new->CR5D = i; + new->CR5E = (((mode->CrtcVTotal - 2) & 0x400) >> 10) | + (((mode->CrtcVDisplay - 1) & 0x400) >> 9) | + (((mode->CrtcVSyncStart) & 0x400) >> 8) | + (((mode->CrtcVSyncStart) & 0x400) >> 6) | 0x40; + width = (pScrn->displayWidth * (pScrn->bitsPerPixel / 8)) >> 3; + new->CR91 = vganew->CRTC[19] = 0xff & width; + new->CR51 = (0x300 & width) >> 4; + new->CR90 = 0x80 | (width >> 8); + vganew->MiscOutReg |= 0x0c; + + /* Set frame buffer description. */ + + if (pScrn->bitsPerPixel <= 8) + new->CR50 = 0; + else if (pScrn->bitsPerPixel <= 16) + new->CR50 = 0x10; + else + new->CR50 = 0x30; + + if (pScrn->displayWidth <= 640) + new->CR50 |= 0x40; + else if (pScrn->displayWidth <= 800) + new->CR50 |= 0x80; + else if (pScrn->displayWidth <= 1024) + new->CR50 |= 0x00; + else if (pScrn->displayWidth <= 1152) + new->CR50 |= 0x01; + else if (pScrn->displayWidth <= 1280) + new->CR50 |= 0xc0; + else if (pScrn->displayWidth <= 1600) + new->CR50 |= 0x81; + else + new->CR50 |= 0xc1; /* Use GBD */ + + if( psav->Chipset == S3_SAVAGE2000 ) + new->CR33 = 0x08; + else + new->CR33 = 0x20; + + vganew->CRTC[0x17] = 0xeb; + + new->CR67 |= 1; + + VGAOUT8(vgaCRIndex, 0x36); + new->CR36 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x68); + new->CR68 = VGAIN8(vgaCRReg); + new->CR69 = 0; + VGAOUT8(vgaCRIndex, 0x6f); + new->CR6F = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRIndex, 0x88); + new->CR86 = VGAIN8(vgaCRReg) | 0x08; + VGAOUT8(vgaCRIndex, 0xb0); + new->CRB0 = VGAIN8(vgaCRReg) | 0x80; + } + + pScrn->vtSema = TRUE; + + /* do it! */ + SavageWriteMode(pScrn, vganew, new); + SavageAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + + +static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SavageRegPtr SavageSavePtr = &psav->SavedReg; + + if( psav->AccelInfoRec ) { + XAADestroyInfoRec( psav->AccelInfoRec ); + psav->AccelInfoRec = NULL; + } + +#if 0 + if( psav->pInt10 ) { + xf86FreeInt10( psav->pInt10 ); + psav->pInt10 = NULL; + } + + if (psav->pVbe) + { + vbeFree(psav->pVbe); + psav->pVbe = NULL; + } +#endif + + if (pScrn->vtSema) { + SavageWriteMode(pScrn, vgaSavePtr, SavageSavePtr); + vgaHWLock(hwp); + SavageUnmapMem(pScrn); + } + + pScrn->vtSema = FALSE; + pScreen->CloseScreen = psav->CloseScreen; + + return (*pScreen->CloseScreen)(scrnIndex, pScreen); +} + + +static Bool SavageSaveScreen(ScreenPtr pScreen, int mode) +{ + return vgaHWSaveScreen(pScreen, mode); +} + + +void SavageAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int Base; + int vgaCRIndex, vgaCRReg, vgaIOBase; + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + if (psav->ShowCache && y) + y += pScrn->virtualY - 1; + + Base = ((y * pScrn->displayWidth + x) * + (pScrn->bitsPerPixel / 8)) >> 2; + /* now program the start address registers */ + VGAOUT16(vgaCRIndex, (Base & 0x00ff00) | 0x0c); + VGAOUT16(vgaCRIndex, ((Base & 0x00ff) << 8) | 0x0d); + VGAOUT8(vgaCRIndex, 0x69); + VGAOUT8(vgaCRReg, (Base & 0x7f0000) >> 16); + + return; +} + + +Bool SavageSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return SavageModeInit(xf86Screens[scrnIndex], mode); +} + + +void SavageEnableMMIO(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int vgaCRIndex, vgaCRReg; + unsigned char val; + + vgaHWSetMmioFuncs(hwp, psav->MapBase, 0x8000); + val = VGAIN8(0x3c3); + VGAOUT8(0x3c3, val | 0x01); + val = VGAIN8(VGA_MISC_OUT_R); + VGAOUT8(VGA_MISC_OUT_W, val | 0x01); + vgaHWGetIOBase(hwp); + vgaCRIndex = hwp->IOBase + 4; + vgaCRReg = hwp->IOBase + 5; + + VGAOUT8(vgaCRIndex, 0x40); + val = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, val | 1); + + return; +} + + +void SavageDisableMMIO(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int vgaCRIndex, vgaCRReg; + unsigned char val; + + vgaHWGetIOBase(hwp); + vgaCRIndex = hwp->IOBase + 4; + vgaCRReg = hwp->IOBase + 5; + + VGAOUT8(vgaCRIndex, 0x40); + val = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, val | 1); + + return; +} + + +void SavageLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, + LOCO *colors, VisualPtr pVisual) +{ + SavagePtr psav = SAVPTR(pScrn); + int i, index; + + for (i=0; i<numColors; i++) { + index = indicies[i]; + VGAOUT8(0x3c8, index); + VGAOUT8(0x3c9, colors[index].red); + VGAOUT8(0x3c9, colors[index].green); + VGAOUT8(0x3c9, colors[index].blue); + } +} + + + +static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1, + int min_n2, int max_n2, long freq_min, + long freq_max, unsigned int *mdiv, + unsigned int *ndiv, unsigned int *r) +{ + double ffreq, ffreq_min, ffreq_max; + double div, diff, best_diff; + unsigned int m; + unsigned char n1, n2, best_n1=16+2, best_n2=2, best_m=125+2; + + ffreq = freq / 1000.0 / BASE_FREQ; + ffreq_max = freq_max / 1000.0 / BASE_FREQ; + ffreq_min = freq_min / 1000.0 / BASE_FREQ; + + if (ffreq < ffreq_min / (1 << max_n2)) { + ErrorF("invalid frequency %1.3f Mhz\n", + ffreq*BASE_FREQ); + ffreq = ffreq_min / (1 << max_n2); + } + if (ffreq > ffreq_max / (1 << min_n2)) { + ErrorF("invalid frequency %1.3f Mhz\n", + ffreq*BASE_FREQ); + ffreq = ffreq_max / (1 << min_n2); + } + + /* work out suitable timings */ + + best_diff = ffreq; + + for (n2=min_n2; n2<=max_n2; n2++) { + for (n1=min_n1+2; n1<=max_n1+2; n1++) { + m = (int)(ffreq * n1 * (1 << n2) + 0.5); + if (m < min_m+2 || m > 127+2) + continue; + div = (double)(m) / (double)(n1); + if ((div >= ffreq_min) && + (div <= ffreq_max)) { + diff = ffreq - div / (1 << n2); + if (diff < 0.0) + diff = -diff; + if (diff < best_diff) { + best_diff = diff; + best_m = m; + best_n1 = n1; + best_n2 = n2; + } + } + } + } + + *ndiv = best_n1 - 2; + *r = best_n2; + *mdiv = best_m - 2; +} + + +void SavageGEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file) +{ + unsigned char cr66; + int r, success = 0; + CARD32 fifo_control = 0, miu_control = 0; + CARD32 streams_timeout = 0, misc_timeout = 0; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SavagePtr psav = SAVPTR(pScrn); + int vgaCRIndex, vgaCRReg, vgaIOBase; + + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + if (from_timeout) { + if (psav->GEResetCnt++ < 10 || xf86GetVerbosity() > 1) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "SavageGEReset called from %s line %d\n", file, line); + } else + WaitIdleEmpty(); + + if (from_timeout) { + fifo_control = INREG(FIFO_CONTROL_REG); + miu_control = INREG(MIU_CONTROL_REG); + streams_timeout = INREG(STREAMS_TIMEOUT_REG); + misc_timeout = INREG(MISC_TIMEOUT_REG); + } + + VGAOUT8(vgaCRIndex, 0x66); + cr66 = VGAIN8(vgaCRReg); + + usleep(10000); + for (r=1; r<10; r++) { + VGAOUT8(vgaCRReg, cr66 | 0x02); + usleep(10000); + VGAOUT8(vgaCRReg, cr66 & ~0x02); + usleep(10000); + + if (!from_timeout) + WaitIdleEmpty(); + OUTREG(DEST_SRC_STR, psav->Bpl << 16 | psav->Bpl); + + usleep(10000); + switch(psav->Chipset) { + case S3_SAVAGE3D: + case S3_SAVAGE_MX: + success = (STATUS_WORD0 & 0x0008ffff) == 0x00080000; + break; + case S3_SAVAGE4: + case S3_PROSAVAGE: + success = (ALT_STATUS_WORD0 & 0x0081ffff) == 0x00800000; + break; + case S3_SAVAGE2000: + success = (ALT_STATUS_WORD0 & 0x008fffff) == 0; + break; + } + if(!success) { + usleep(10000); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "restarting S3 graphics engine reset %2d ...\n", r); + } + else + break; + } + + if (from_timeout) { + OUTREG(FIFO_CONTROL_REG, fifo_control); + OUTREG(MIU_CONTROL_REG, miu_control); + OUTREG(STREAMS_TIMEOUT_REG, streams_timeout); + OUTREG(MISC_TIMEOUT_REG, misc_timeout); + } + + WaitQueue(2); + OUTREG(SRC_BASE, 0); + OUTREG(DEST_BASE, 0); + + WaitQueue(4); + OUTREG(CLIP_L_R, ((0) << 16) | pScrn->displayWidth); + OUTREG(CLIP_T_B, ((0) << 16) | psav->ScissB); + OUTREG(MONO_PAT_0, ~0); + OUTREG(MONO_PAT_1, ~0); + SavageSetGBD(pScrn); +} + + + +/* This function is used to debug, it prints out the contents of s3 regs */ + +void +SavagePrintRegs(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned char i; + int vgaCRIndex = 0x3d4; + int vgaCRReg = 0x3d5; + + ErrorF( "SR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF" ); + + for( i = 0; i < 0x70; i++ ) { + if( !(i % 16) ) + ErrorF( "\nSR%xx ", i >> 4 ); + VGAOUT8( 0x3c4, i ); + ErrorF( " %02x", VGAIN8(0x3c5) ); + } + + ErrorF( "\n\nCR x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF" ); + + for( i = 0; i < 0xB7; i++ ) { + if( !(i % 16) ) + ErrorF( "\nCR%xx ", i >> 4 ); + VGAOUT8( vgaCRIndex, i ); + ErrorF( " %02x", VGAIN8(vgaCRReg) ); + } + + ErrorF("\n\n"); +} + + +#ifdef DPMSExtension +static void SavageDPMS(ScrnInfoPtr pScrn, int mode, int flags) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned char sr8 = 0x00, srd = 0x00; + + VGAOUT8(0x3c4, 0x08); + sr8 = VGAIN8(0x3c5); + sr8 |= 0x06; + VGAOUT8(0x3c5, sr8); + + VGAOUT8(0x3c4, 0x0d); + srd = VGAIN8(0x3c5); + + srd &= 0x03; + + switch (mode) { + case DPMSModeOn: + break; + case DPMSModeStandby: + srd |= 0x10; + break; + case DPMSModeSuspend: + srd |= 0x40; + break; + case DPMSModeOff: + srd |= 0x50; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid DPMS mode %d\n", mode); + break; + } + + VGAOUT8(0x3c4, 0x0d); + VGAOUT8(0x3c5, srd); + + return; +} +#endif /* DPMSExtension */ Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h:1.3 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h Thu Dec 7 15:26:22 2000 @@ -0,0 +1,219 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h,v 1.3 2000/12/07 20:26:22 dawes Exp $ */ + +#ifndef SAVAGE_VGAHWMMIO_H +#define SAVAGE_VGAHWMMIO_H + +#include "vgaHW.h" +#include "xf86.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#include "xf86Cursor.h" +#include "mipointer.h" +#include "micmap.h" +#include "cfb.h" +#include "cfb16.h" +#include "cfb32.h" +#include "xf86cmap.h" +#include "vbe.h" +#include "xaa.h" + +#include "savage_regs.h" + +#define VGAIN8(addr) MMIO_IN8(psav->MapBase+0x8000, addr) +#define VGAIN16(addr) MMIO_IN16(psav->MapBase+0x8000, addr) +#define VGAIN(addr) MMIO_IN32(psav->MapBase+0x8000, addr) + +#define VGAOUT8(addr,val) MMIO_OUT8(psav->MapBase+0x8000, addr, val) +#define VGAOUT16(addr,val) MMIO_OUT16(psav->MapBase+0x8000, addr, val) +#define VGAOUT(addr,val) MMIO_OUT32(psav->MapBase+0x8000, addr, val) + +#define INREG(addr) MMIO_IN32(psav->MapBase, addr) +#define OUTREG(addr,val) MMIO_OUT32(psav->MapBase, addr, val) +#define INREG16(addr) MMIO_IN16(psav->MapBase, addr) +#define OUTREG16(addr,val) MMIO_OUT16(psav->MapBase, addr, val) + + +typedef struct _S3VMODEENTRY { + unsigned short Width; + unsigned short Height; + unsigned short VesaMode; + unsigned char RefreshCount; + unsigned char * RefreshRate; +} SavageModeEntry, *SavageModeEntryPtr; + + +typedef struct _S3VMODETABLE { + unsigned short NumModes; + SavageModeEntry Modes[1]; +} SavageModeTableRec, *SavageModeTablePtr; + + +typedef struct { + unsigned int mode, refresh; + unsigned char SR08, SR0A, SR0F; + unsigned char SR10, SR11, SR12, SR13, SR15, SR18, SR29; + unsigned char SR54[8]; + unsigned char Clock; + unsigned char CR31, CR32, CR33, CR34, CR36, CR3A, CR3B, CR3C; + unsigned char CR40, CR41, CR42, CR43, CR45; + unsigned char CR50, CR51, CR53, CR55, CR58, CR5B, CR5D, CR5E; + unsigned char CR60, CR63, CR65, CR66, CR67, CR68, CR69, CR6D, CR6F; + unsigned char CR86, CR88; + unsigned char CR90, CR91, CRB0; + unsigned char ColorStack[8]; + unsigned int STREAMS[22]; /* yuck, streams regs */ + unsigned int MMPR0, MMPR1, MMPR2, MMPR3; +} SavageRegRec, *SavageRegPtr; + + +typedef struct _Savage { + SavageRegRec SavedReg; + SavageRegRec ModeReg; + xf86CursorInfoPtr CursorInfoRec; + Bool ModeStructInit; + Bool NeedSTREAMS; + Bool STREAMSRunning; + int Bpp, Bpl, ScissB; + unsigned PlaneMask; + + int videoRambytes; + int videoRamKbytes; + int MemOffScreen; + CARD32 CursorKByte; + + /* These are physical addresses. */ + unsigned long FrameBufferBase; + unsigned long MmioBase; + + /* These are linear addresses. */ + unsigned char* MapBase; + unsigned char* BciMem; + unsigned char* MapBaseDense; + unsigned char* FBBase; + unsigned char* FBStart; + + Bool PrimaryVidMapped; + int dacSpeedBpp; + int minClock, maxClock; + int HorizScaleFactor; + int MCLK, REFCLK, LCDclk; + double refclk_fact; + int GEResetCnt; + + /* Here are all the Options */ + + Bool ShowCache; + Bool pci_burst; + Bool NoPCIRetry; + Bool fifo_conservative; + Bool fifo_moderate; + Bool fifo_aggressive; + Bool slow_edodram; + Bool slow_dram; + Bool fast_dram; + Bool fpm_vram; + Bool early_ras_precharge; + Bool hwcursor; + Bool NoAccel; + Bool shadowFB; + Bool UseBIOS; + int rotate; + + CloseScreenProcPtr CloseScreen; + pciVideoPtr PciInfo; + PCITAG PciTag; + int Chipset; + int ChipId; + int ChipRev; + vbeInfoPtr pVbe; + int EntityIndex; + + /* The various Savage wait handlers. */ + int (*myWaitQueue)(struct _Savage *, int); + int (*myWaitIdle)(struct _Savage *); + int (*myWaitIdleEmpty)(struct _Savage *); + int (*myWaitCommandEmpty)(struct _Savage *); + + /* Support for shadowFB and rotation */ + unsigned char * ShadowPtr; + int ShadowPitch; + void (*PointerMoved)(int index, int x, int y); + + /* Support for XAA acceleration */ + XAAInfoRecPtr AccelInfoRec; + xRectangle Rect; + unsigned int SavedBciCmd; + unsigned int SavedFgColor; + unsigned int SavedBgColor; + unsigned int SavedGbdOffset; + unsigned int SavedGbd; + unsigned int SavedSbdOffset; + unsigned int SavedSbd; + + /* Support for Int10 processing */ + xf86Int10InfoPtr pInt10; + SavageModeTablePtr ModeTable; + + /* Support for the Savage command overflow buffer. */ + unsigned long cobIndex; /* size index */ + unsigned long cobSize; /* size in bytes */ + unsigned long cobOffset; /* offset in frame buffer */ + +} SavageRec, *SavagePtr; + +/* Shortcuts. These depend on a local symbol "psav". */ + +#define WaitIdle() psav->myWaitIdle(psav) +#define WaitIdleEmpty() psav->myWaitIdleEmpty(psav) +#define WaitQueue(k) psav->myWaitQueue(psav,k) +#define WaitCommandEmpty() psav->myWaitCommandEmpty(psav) + +#define SAVPTR(p) ((SavagePtr)((p)->driverPrivate)) + +/* Prototypes. */ + +extern void SavageCommonCalcClock(long freq, int min_m, int min_n1, + int max_n1, int min_n2, int max_n2, + long freq_min, long freq_max, + unsigned char *mdiv, unsigned char *ndiv); +void SavageAdjustFrame(int scrnIndex, int y, int x, int flags); +Bool SavageSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); + +/* In savage_cursor.c. */ + +Bool SavageHWCursorInit(ScreenPtr pScreen); + +/* In savage_accel.c. */ + +Bool SavageInitAccel(ScreenPtr); +void SavageInitialize2DEngine(ScrnInfoPtr); +void SavageSetGBD(ScrnInfoPtr); + +/* In savage_shadow.c */ + +void SavagePointerMoved(int index, int x, int y); +void SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void SavageRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void SavageRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void SavageRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void SavageRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); + +/* In savage_vbe.c */ + +void SavageSetTextMode( SavagePtr psav ); +void SavageSetVESAMode( SavagePtr psav, int n, int Refresh ); +void SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ); +SavageModeTablePtr SavageGetBIOSModeTable( SavagePtr psav, int iDepth ); + +unsigned short SavageGetBIOSModes( + SavagePtr psav, + int iDepth, + SavageModeEntryPtr s3vModeTable ); + + +#endif /* SAVAGE_VGAHWMMIO_H */ + Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_image.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_image.c:1.2 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_image.c Mon Dec 4 13:50:00 2000 @@ -0,0 +1,168 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_image.c,v 1.2 2000/12/04 18:50:00 dawes Exp $ */ + +#include "savage_driver.h" +#include "xaarop.h" +#include "savage_bci.h" + +#if 0 +void SavageWriteBitmapScreenToScreenColorExpand( + ScrnPtr pScrn, + int x, + int y, + int w, + int h, + unsigned char * src, + int srcwidth, + int srcx, + int srcy, + int bg, + int fg, + int rop, + unsigned int planemask +) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + unsigned int cmd; + unsigned char * bd_offset; + unsigned int bd; + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_SEND_COLOR + | BCI_CMD_DEST_GBD | BCI_CMD_SRC_SBD_MONO_NEW; + cmd |= (bg != -1) ? BCI_CMD_SEND_COLOR : BCI_CMD_SRC_TRANSPARENT; + cmd |= s3vAlu[rop]; + + bd |= BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP(bd, 1); + BCI_BD_SET_STRIDE(bd, srcwidth); + bd_offset = srcwidth * srcy + (srcx >> 3) + src; + + WaitQueue(10); + BCI_SEND(cmd); + BCI_SEND((unsigned int)bd_offset); + BCI_SEND(bd); + BCI_SEND(fg); + BCI_SEND((bg != -1) ? bg : 0); + BCI_SEND(BCI_X_Y(srcx, srcy)); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, h)); +} +#endif + +void +SavageWriteBitmapCPUToScreenColorExpand ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char * src, + int srcwidth, + int skipleft, + int fg, int bg, + int rop, + unsigned int planemask +) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + int i, j, count, reset; + unsigned int cmd; + unsigned int * srcp; + +/* We aren't using planemask at all here... */ + + if( !srcwidth ) + return; + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_SEND_COLOR | BCI_CMD_CLIP_LR + | BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO; + cmd |= XAACopyROP[rop] << 16; + + if( bg == -1 ) + cmd |= BCI_CMD_SRC_TRANSPARENT; + + BCI_SEND(cmd); + BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1)); + BCI_SEND(fg); + if( bg != -1 ) + BCI_SEND(bg); + + /* Bitmaps come in in units of DWORDS, LSBFirst. This is exactly */ + /* reversed of what we expect. */ + + count = (w + 31) / 32; +/* src += ((srcx & ~31) / 8); */ + + /* The BCI region is 128k bytes. A screen-sized mono bitmap can */ + /* exceed that. */ + + reset = 65536 / count; + + for (j = 0; j < h; j ++) { + BCI_SEND(BCI_X_Y(x, y+j)); + BCI_SEND(BCI_W_H(w, 1)); + srcp = (unsigned int*) src; + for (i = count; i > 0; srcp ++, i --) { + /* We have to invert the bits in each byte. */ + unsigned long u = *srcp; + u = ((u & 0x0f0f0f0f) << 4) | ((u & 0xf0f0f0f0) >> 4); + u = ((u & 0x33333333) << 2) | ((u & 0xcccccccc) >> 2); + u = ((u & 0x55555555) << 1) | ((u & 0xaaaaaaaa) >> 1); + BCI_SEND(u); + } + src += srcwidth; + if( !--reset ) { + BCI_RESET; + reset = 65536 / count; + } + } +} + +void +SavageSetupForImageWrite( + ScrnInfoPtr pScrn, + int rop, + unsigned planemask, + int transparency_color, + int bpp, + int depth) +{ + SavagePtr psav = SAVPTR(pScrn); + int cmd; + + cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP + | BCI_CMD_CLIP_LR + | BCI_CMD_DEST_GBD | BCI_CMD_SRC_COLOR; + + cmd |= XAACopyROP[rop] << 16; + + if( transparency_color != -1 ) + cmd |= BCI_CMD_SRC_TRANSPARENT; + + psav->SavedBciCmd = cmd; + psav->SavedBgColor = transparency_color; +} + + +void SavageSubsequentImageWriteRect +( + ScrnInfoPtr pScrn, + int x, + int y, + int w, + int h, + int skipleft) +{ + SavagePtr psav = SAVPTR(pScrn); + BCI_GET_PTR; + int count; + + count = ((w * pScrn->bitsPerPixel + 31) / 32) * h; + WaitQueue( count ); + BCI_SEND(psav->SavedBciCmd); + BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1)); + if( psav->SavedBgColor != -1 ) + BCI_SEND(psav->SavedBgColor); + BCI_SEND(BCI_X_Y(x, y)); + BCI_SEND(BCI_W_H(w, h)); +} Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h:1.4 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h Thu Dec 7 15:26:22 2000 @@ -0,0 +1,108 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h,v 1.4 2000/12/07 20:26:22 dawes Exp $ */ + +#ifndef _SAVAGE_REGS_H +#define _SAVAGE_REGS_H + +#include "savage_driver.h" + +#define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) + +#define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) || (chip==S3_PROSAVAGE)) + +#define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000)) + + +/* Chip tags. These are used to group the adapters into + * related families. + */ + +enum S3CHIPTAGS { + S3_UNKNOWN = 0, + S3_SAVAGE3D, + S3_SAVAGE_MX, + S3_SAVAGE4, + S3_PROSAVAGE, + S3_SAVAGE2000, + S3_LAST +}; + +#define BIOS_BSIZE 1024 +#define BIOS_BASE 0xc0000 + +#define SAVAGE_NEWMMIO_REGBASE_S3 0x1000000 /* 16MB */ +#define SAVAGE_NEWMMIO_REGBASE_S4 0x0000000 +#define SAVAGE_NEWMMIO_REGSIZE 0x0080000 /* 512kb */ +#define SAVAGE_NEWMMIO_VGABASE 0x8000 + +#define BASE_FREQ 14.31818 + +#define FIFO_CONTROL_REG 0x8200 +#define MIU_CONTROL_REG 0x8204 +#define STREAMS_TIMEOUT_REG 0x8208 +#define MISC_TIMEOUT_REG 0x820c + +#define PSTREAM_CONTROL_REG 0x8180 +#define COL_CHROMA_KEY_CONTROL_REG 0x8184 +#define SSTREAM_CONTROL_REG 0x8190 +#define CHROMA_KEY_UPPER_BOUND_REG 0x8194 +#define SSTREAM_STRETCH_REG 0x8198 +#define BLEND_CONTROL_REG 0x81a0 +#define PSTREAM_FBADDR0_REG 0x81c0 +#define PSTREAM_FBADDR1_REG 0x81c4 +#define PSTREAM_STRIDE_REG 0x81c8 +#define DOUBLE_BUFFER_REG 0x81cc +#define SSTREAM_FBADDR0_REG 0x81d0 +#define SSTREAM_FBADDR1_REG 0x81d4 +#define SSTREAM_STRIDE_REG 0x81d8 +#define OPAQUE_OVERLAY_CONTROL_REG 0x81dc +#define K1_VSCALE_REG 0x81e0 +#define K2_VSCALE_REG 0x81e4 +#define DDA_VERT_REG 0x81e8 +#define STREAMS_FIFO_REG 0x81ec +#define PSTREAM_START_REG 0x81f0 +#define PSTREAM_WINDOW_SIZE_REG 0x81f4 +#define SSTREAM_START_REG 0x81f8 +#define SSTREAM_WINDOW_SIZE_REG 0x81fC + +#define SUBSYS_STAT_REG 0x8504 + +#define SRC_BASE 0xa4d4 +#define DEST_BASE 0xa4d8 +#define CLIP_L_R 0xa4dc +#define CLIP_T_B 0xa4e0 +#define DEST_SRC_STR 0xa4e4 +#define MONO_PAT_0 0xa4e8 +#define MONO_PAT_1 0xa4ec + + +/* Constants for CR69. */ + +#define CRT_ACTIVE 0x01 +#define LCD_ACTIVE 0x02 +#define TV_ACTIVE 0x04 +#define CRT_ATTACHED 0x10 +#define LCD_ATTACHED 0x20 +#define TV_ATTACHED 0x40 + + +/* + * reads from SUBSYS_STAT + */ +#define STATUS_WORD0 (INREG(0x48C00)) +#define ALT_STATUS_WORD0 (INREG(0x48C60)) +#define MAXLOOP 0xffffff +#define IN_SUBSYS_STAT() (INREG(SUBSYS_STAT_REG)) + +#define MAXFIFO 0x7f00 + +#define VerticalRetraceWait() \ +{ \ + VGAOUT8(vgaCRIndex, 0x17); \ + if (VGAIN8(vgaCRReg) & 0x80) { \ + while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \ + while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x08) ; \ + while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \ + } \ +} + +#endif /* _SAVAGE_REGS_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_shadow.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_shadow.c:1.1 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_shadow.c Fri Dec 1 20:16:14 2000 @@ -0,0 +1,244 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_shadow.c,v 1.1 2000/12/02 01:16:14 dawes Exp $ */ + +/* + Copyright (c) 1999,2000 The XFree86 Project Inc. + based on code written by Mark Vojkovich <markv@valinux.com> +*/ + +#include "savage_driver.h" +#include "shadowfb.h" +#include "servermd.h" + + +void +SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; + + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + + while(num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = psav->ShadowPtr + (pbox->y1 * psav->ShadowPitch) + + (pbox->x1 * Bpp); + dst = psav->FBStart + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += psav->ShadowPitch; + } + + pbox++; + } +} + + +void +SavagePointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + SavagePtr psav = SAVPTR(pScrn); + int newX, newY; + + if(psav->rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + + (*psav->PointerMoved)(index, newX, newY); +} + +void +SavageRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(psav->rotate == 1) { + dstPtr = psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = psav->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = psav->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch * 2] << 16) | + (src[srcPitch * 3] << 24); + src += srcPitch * 4; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +void +SavageRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch >> 1; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(psav->rotate == 1) { + dstPtr = (CARD16*)psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16*)psav->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16*)psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16*)psav->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch * 2; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +/* this one could be faster */ +void +SavageRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -psav->rotate * psav->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(psav->rotate == 1) { + dstPtr = psav->FBStart + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = psav->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = psav->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch * 2] << 16) | + (src[(srcPitch * 2) + 1] << 24); + dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | + (src[(srcPitch * 3) + 1] << 16) | + (src[(srcPitch * 3) + 2] << 24); + dst += 3; + src += srcPitch * 4; + } + srcPtr += psav->rotate * 3; + dstPtr += dstPitch; + } + + pbox++; + } +} + +void +SavageRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch >> 2; + + while(num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(psav->rotate == 1) { + dstPtr = (CARD32*)psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32*)psav->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32*)psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32*)psav->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c:1.1 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c Fri Dec 1 20:16:15 2000 @@ -0,0 +1,257 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c,v 1.1 2000/12/02 01:16:15 dawes Exp $ */ + +#include "savage_driver.h" +#include "savage_vbe.h" + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define B_O16(x) (x) +#define B_O32(x) (x) +#else +#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) +#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ + | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) +#endif +#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) + +static void +SavageClearVM86Regs( xf86Int10InfoPtr pInt ) +{ + pInt->ax = 0; + pInt->bx = 0; + pInt->cx = 0; + pInt->dx = 0; + pInt->si = 0; + pInt->di = 0; + pInt->es = 0xc000; + pInt->num = 0x10; +} + +void +SavageSetTextMode( SavagePtr psav ) +{ +#if 0 + ioperm( 0x80, 1, 1 ); + ioperm( 0x61, 1, 1 ); + ioperm( 0x40, 4, 1 ); +#endif + + SavageClearVM86Regs( psav->pInt10 ); + + psav->pInt10->ax = 0x83; + + xf86ExecX86int10( psav->pInt10 ); + +#if 0 + ioperm( 0x40, 4, 0 ); + ioperm( 0x61, 1, 0 ); + ioperm( 0x80, 1, 1 ); +#endif +} + + +void +SavageSetVESAMode( SavagePtr psav, int n, int Refresh ) +{ +#if 0 + /* + * The Savage BIOS writes to a debug card on port 80h and to the + * timer chip at port 61. + */ + ioperm( 0x80, 1, 1 ); + ioperm( 0x61, 1, 1 ); + ioperm( 0x40, 4, 1 ); +#endif + + /* First, establish the refresh rate for this mode. */ + + SavageClearVM86Regs( psav->pInt10 ); + + xf86ExecX86int10( psav->pInt10 ); + + psav->pInt10->ax = 0x4f14; /* S3 extensions */ + psav->pInt10->bx = 0x0001; /* Set default refresh rate */ + psav->pInt10->cx = n; + psav->pInt10->di = Refresh; + + xf86ExecX86int10( psav->pInt10 ); + + /* Now, make this mode current. */ + + SavageClearVM86Regs( psav->pInt10 ); + psav->pInt10->ax = 0x4f02; /* Set vesa mode extensions */ + psav->pInt10->bx = n; /* Mode number */ + + xf86ExecX86int10( psav->pInt10 ); + + if ( (psav->pInt10->ax & 0xff) != 0x4f) + { + ErrorF("Set video mode failed\n"); + } + +#if 0 + ioperm( 0x40, 4, 0 ); + ioperm( 0x61, 1, 0 ); + ioperm( 0x80, 1, 1 ); +#endif +} + + +void +SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ) +{ + int i; + SavageModeEntryPtr pMode = (*ppTable)->Modes; + + for( i = (*ppTable)->NumModes; i--; ) + { + if( pMode->RefreshRate ) + { + xfree( pMode->RefreshRate ); + pMode->RefreshRate = NULL; + } + } + + xfree( *ppTable ); +} + + +SavageModeTablePtr +SavageGetBIOSModeTable( SavagePtr psav, int iDepth ) +{ + int nModes = SavageGetBIOSModes( psav, iDepth, NULL ); + SavageModeTablePtr pTable; + + pTable = (SavageModeTablePtr) + xcalloc( 1, sizeof(SavageModeTableRec) + + (nModes-1) * sizeof(SavageModeEntry) ); + if( pTable ) { + pTable->NumModes = nModes; + SavageGetBIOSModes( psav, iDepth, pTable->Modes ); + } + + return pTable; +} + + +unsigned short +SavageGetBIOSModes( + SavagePtr psav, + int iDepth, + SavageModeEntryPtr s3vModeTable ) +{ + unsigned short iModeCount = 0; + short int *mode_list; + pointer vbeLinear = NULL; + vbeControllerInfoPtr vbe = NULL; + int vbeReal; + struct vbe_mode_info_block * vmib; + + if( !psav->pVbe ) + return 0; + + vbe = (vbeControllerInfoPtr) psav->pVbe->memory; + + mode_list = xf86int10Addr( psav->pInt10, L_ADD(vbe->VideoModePtr) ); + + vbeLinear = xf86Int10AllocPages( psav->pInt10, 1, &vbeReal ); + vmib = (struct vbe_mode_info_block *) vbeLinear; + + while (*mode_list != -1) + { + /* + * This is a HACK to work around what I believe is a BUG in the + * Toshiba Satellite BIOSes in 08/2000 and 09/2000. The BIOS + * table for 1024x600 says it has six refresh rates, when in fact + * it only has 3. This causes the BIOS to go into an infinite + * loop until the user interrupts it, usually by pressing + * Ctrl-Alt-F1. For now, we'll just punt everything with a VESA + * number greater than or equal to 0200. + */ + if( *mode_list >= 0x0200 ) + { + mode_list++; + continue; + } + + SavageClearVM86Regs( psav->pInt10 ); + + psav->pInt10->ax = 0x4f01; + psav->pInt10->cx = *mode_list; + psav->pInt10->es = SEG_ADDR(vbeReal); + psav->pInt10->di = SEG_OFF(vbeReal); + psav->pInt10->num = 0x10; + + xf86ExecX86int10( psav->pInt10 ); + + if( + (vmib->bits_per_pixel == iDepth) && + ( + (vmib->memory_model == VBE_MODEL_256) || + (vmib->memory_model == VBE_MODEL_PACKED) || + (vmib->memory_model == VBE_MODEL_RGB) + ) + ) + { + /* This mode is a match. */ + + iModeCount++; + + /* If we're supposed to fetch information, do it now. */ + + if( s3vModeTable ) + { + int iRefresh = 0; + + s3vModeTable->Width = vmib->x_resolution; + s3vModeTable->Height = vmib->y_resolution; + s3vModeTable->VesaMode = *mode_list; + + /* Query the refresh rates at this mode. */ + + psav->pInt10->cx = *mode_list; + psav->pInt10->dx = 0; + + do + { + if( (iRefresh % 8) == 0 ) + { + if( s3vModeTable->RefreshRate ) + { + s3vModeTable->RefreshRate = (unsigned char *) + xrealloc( + s3vModeTable->RefreshRate, + (iRefresh+8) * sizeof(unsigned char) + ); + } + else + { + s3vModeTable->RefreshRate = (unsigned char *) + xcalloc( + sizeof(unsigned char), + (iRefresh+8) + ); + } + } + + psav->pInt10->ax = 0x4f14; /* S3 extended functions */ + psav->pInt10->bx = 0x0201; /* query refresh rates */ + psav->pInt10->num = 0x10; + xf86ExecX86int10( psav->pInt10 ); + + s3vModeTable->RefreshRate[iRefresh++] = psav->pInt10->di; + } + while( psav->pInt10->dx ); + + s3vModeTable->RefreshCount = iRefresh; + + s3vModeTable++; + } + } + + mode_list++; + } + + xf86Int10FreePages( psav->pInt10, vbeLinear, 1 ); + + return iModeCount; +} Index: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.h:1.2 --- /dev/null Mon Dec 18 14:31:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.h Mon Dec 4 17:41:54 2000 @@ -0,0 +1,113 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.h,v 1.2 2000/12/04 22:41:54 dawes Exp $ */ + +/* +This file was originally part of the Linux Real-Mode Interface, or LRMI. +There is nothing LRMI-specific here; this is all good, general VBE info. + +Copyright (C) 1996 by Josh Vanderhoof + +You are free to distribute and modify this file, as long as you +do not remove this copyright notice and clearly label modified +versions as being modified. + +This software has NO WARRANTY. Use it at your own risk. +*/ + +#ifndef _SAVAGEVBE_H +#define _SAVAGEVBE_H + +/* structures for vbe 2.0 */ + +#ifndef __GNUC__ +#define __attribute__(a) +#endif + +struct vbe_info_block + { + char vbe_signature[4]; + short vbe_version; + unsigned short oem_string_off; + unsigned short oem_string_seg; + int capabilities; + unsigned short video_mode_list_off; + unsigned short video_mode_list_seg; + short total_memory; + short oem_software_rev; + unsigned short oem_vendor_name_off; + unsigned short oem_vendor_name_seg; + unsigned short oem_product_name_off; + unsigned short oem_product_name_seg; + unsigned short oem_product_rev_off; + unsigned short oem_product_rev_seg; + char reserved[222]; + char oem_data[256]; + } __attribute__ ((packed)); + +#define VBE_ATTR_MODE_SUPPORTED (1 << 0) +#define VBE_ATTR_TTY (1 << 2) +#define VBE_ATTR_COLOR (1 << 3) +#define VBE_ATTR_GRAPHICS (1 << 4) +#define VBE_ATTR_NOT_VGA (1 << 5) +#define VBE_ATTR_NOT_WINDOWED (1 << 6) +#define VBE_ATTR_LINEAR (1 << 7) + +#define VBE_WIN_RELOCATABLE (1 << 0) +#define VBE_WIN_READABLE (1 << 1) +#define VBE_WIN_WRITEABLE (1 << 2) + +#define VBE_MODEL_TEXT 0 +#define VBE_MODEL_CGA 1 +#define VBE_MODEL_HERCULES 2 +#define VBE_MODEL_PLANAR 3 +#define VBE_MODEL_PACKED 4 +#define VBE_MODEL_256 5 +#define VBE_MODEL_RGB 6 +#define VBE_MODEL_YUV 7 + +struct vbe_mode_info_block + { + unsigned short mode_attributes; + unsigned char win_a_attributes; + unsigned char win_b_attributes; + unsigned short win_granularity; + unsigned short win_size; + unsigned short win_a_segment; + unsigned short win_b_segment; + unsigned short win_func_ptr_off; + unsigned short win_func_ptr_seg; + unsigned short bytes_per_scanline; + unsigned short x_resolution; + unsigned short y_resolution; + unsigned char x_char_size; + unsigned char y_char_size; + unsigned char number_of_planes; + unsigned char bits_per_pixel; + unsigned char number_of_banks; + unsigned char memory_model; + unsigned char bank_size; + unsigned char number_of_image_pages; + unsigned char res1; + unsigned char red_mask_size; + unsigned char red_field_position; + unsigned char green_mask_size; + unsigned char green_field_position; + unsigned char blue_mask_size; + unsigned char blue_field_position; + unsigned char rsvd_mask_size; + unsigned char rsvd_field_position; + unsigned char direct_color_mode_info; + unsigned int phys_base_ptr; + unsigned int offscreen_mem_offset; + unsigned short offscreen_mem_size; + unsigned char res2[206]; + } __attribute__ ((packed)); + +struct vbe_palette_entry + { + unsigned char blue; + unsigned char green; + unsigned char red; + unsigned char align; + } __attribute__ ((packed)); + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/CALLMAP diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/CALLMAP:1.1 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/CALLMAP Tue Nov 28 15:59:18 2000 @@ -0,0 +1,22 @@ +-- Only Once, calling order -- +ChipIdentify (SMIIdentify) +ChipProbe (SMIProbe) + Passive only, no ram determination, no writing + +-- For each ScrnInfoRec, still calling order -- +ChipPreInit (SMIPreInit) + Allows probing and mapping, hardware must remain unchanged + ChipGetRec + +ChipScreenInit + ChipMapMem + ChipSave + vgaHWSaveMMIO + ChipModeInit + vtSema=TRUE + ChipWriteMode + vgaHWRestoreMMIO + +Header: \\Mercury\Projects\archives\XFree86 4.0\CALLMAP.-arc 1.1 13 Jul 2000 18:16:58 Frido $ + +$XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/CALLMAP,v 1.1 2000/11/28 20:59:18 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Imakefile:1.1 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Imakefile Tue Nov 28 15:59:18 2000 @@ -0,0 +1,60 @@ +XCOMM Header: //Mercury/Projects/archives/XFree86/4.0/Imakefile.-arc 1.4 02 Aug 2000 13:17:16 Frido $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Imakefile,v 1.1 2000/11/28 20:59:18 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = smi_driver.c smi_accel.c smi_dac.c smi_hwcurs.c smi_dga.c smi_i2c.c \ + smi_shadow.c smi_video.c + +OBJS = smi_driver.o smi_accel.o smi_dac.o smi_hwcurs.o smi_dga.o smi_i2c.o \ + smi_shadow.o smi_video.o + +DEFINES = -DPSZ=8 + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ + -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ + -I$(XF86SRC)/ramdac -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(SERVERSRC)/Xext -I$(XF86SRC)/int10 \ + -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ + -I$(XF86SRC)/shadowfb -I$(EXTINCSRC) -I$(SERVERSRC)/fb \ + -I$(SERVERSRC)/render -I$(XF86OSSRC)/vbe +#endif + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +NormalAsmObjectRule() + +ModuleObjectRule() +ObjectModuleTarget(siliconmotion, $(OBJS)) + +InstallObjectModule(siliconmotion,$(MODULEDIR),drivers) + +#if !defined(XF86DriverSDK) +CppManTarget(siliconmotion,) +InstallModuleManPage(siliconmotion) +#endif + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_accel.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_dac.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_dga.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_driver.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_hwcurs.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_i2c.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_shadow.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_video.c,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(regsmi.h,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi.h,$(DRIVERSDKDIR)/drivers/siliconmotion) +InstallDriverSDKNonExecFile(smi_video.h,$(DRIVERSDKDIR)/drivers/siliconmotion) + +InstallDriverSDKObjectModule(siliconmotion,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/README diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/README:1.2 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/README Tue Dec 5 16:18:37 2000 @@ -0,0 +1,75 @@ +What works: +- Supports 8bpp, 16bpp and 24bpp. Heavy testing on SM720. + +XCONFIG options: + +The driver supports quite a few different XConfig options, which can +be used to tune the driver and improve performance. Without any options, +the driver will use conservative settings which should work on most +hardware. Large improvements in performance are possible by selecting +the proper options, which will probably work on most systems. + +Cursor: + +- "hwcursor" "off" behaves exactly like "swcursor". Default: "on" +- "swcursor" will disable the HW Cursor. HW Cursor is used by default and + no option is needed to enable it. + +Display: + +- "ShadowFB" Use shadow framebuffer. Default: off. +- "Rotate" "cw" | "ccw" Rotate the screen CW - clockwise or CCW - counter + clockwise. Uses ShadowFB. Default: no rotation. +- "UseBIOS" Use BIOS to set modes. Default: on. + +Overlays: + +- "VideoKey" Set chroma key for video. Default: Off blue. +- "ByteSwap" Turn on YUV byte swapping. Defaul: off. + +Video memory: + +- "set_mclk" sets the memory clock, format is: + Option "set_mclk" "50000" + in the XF86Config file. Valid values are any + integer <= 100000, where 100000 == 100 MHz. + +Acceleration and graphic engine: + +- "NoAccel" turns off all acceleration +- "fifo_aggressive", "fifo_moderate" and "fifo_conservative" alter the settings + for the threshold at which the pixel FIFO takes over the internal + memory bus to refill itself. The smaller this threshold, the better + the acceleration performance of the card. You may try the fastest + setting ("aggressive") and move down if you encounter pixel corruption. + The optimal setting will probably depend on dot-clock and on color + depth. Note that specifying any of these options will also alter other + memory settings which should increase performance, so you should at + least use "fifo_conservative" (this uses the chip defaults). +- Common XAA acceleration options to disable primitives for test purposes: + "XaaNoScreenToScreenCopy" + "XaaNoSolidFillRect" + "XaaNoColor8x8PatternFillRect" + "XaaNoImageWriteRect" + "XaaNoPixmapCache" + +PCI bus: + +- "pci_burst" will enable PCI burst mode. This should work on all but a + few "broken" PCI chipsets, and will increase performance. Option may + take a parameter "on", "off", "yes", etc... +- "pci_retry" will allow the driver to rely on PCI Retry to program the + ViRGE registers. "pci_burst" must be enabled for this to work. + This will increase performance, especially for small fills/blits, + because the driver does not have to poll the ViRGE before sending it + commands to make sure it is ready. It should work on most + recent PCI chipsets. + +Debug: + +- "ShowCache" Enable or disable viewing offscreen cache memory. A + development debug option. Default: off. + +Header: //Mercury/Projects/archives/XFree86/4.0/README.-arc 1.2 14 Sep 2000 12:28:36 Frido $ + +$XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/README,v 1.2 2000/12/05 21:18:37 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Release.txt diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Release.txt:1.3 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Release.txt Wed Dec 13 20:05:43 2000 @@ -0,0 +1,153 @@ +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.2.0, 12/13/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +- When restoring from VESAFB graphics mode, the screen did not update with the + UseBIOS switch on. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.9, 11/30/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#581 - Need Linux driver to support zooming via ctrl+alt++ & ctrl+alt+-. +#670 - Screen broken occurs when switch back to the Xwindow during in Rotation + mode. +#671 - Very slow to pop up the Exit menu from X windows during in Rotation mode. +#672 - It doesn't redraw properly in X windows during in Rotation mode. +#689 - Screen broken when toggle between terminal and desktop during playing in + MPEG. +#705 - Linux CRT only 800x600 or 1024x768 there is no display. +#864 - Lockup when video is playing and switching to full-screen command shell. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.8, 11/27/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#640 - X Windows shift to the right when start X Windows or apply Rotation. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.7, 11/17/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#676 - Green color only shown in window when run Xlive in Linux. +#835 - Screen black after DPMS on. + + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.6, 11/03/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#687 - Blue rectangle appears when video is clipped on thr right edge of screen. +#735 - When resume from sleep, X Windows does not wake up. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.5, 10/06/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#578 - Don't check for CRT-only when validating modes. +#579 - Corrected DPI issue when DDC monitor is not attached. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.4, 09/20/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#521 - Screen corruption after return from X Server when vesafb is used. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.3, 09/18/2000 +-------------------------------------------------------------------------------- + +New features: + +- Added live video capture. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.2, 09/14/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#486 - Video scaling wrong on SM720. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.1, 08/23/2000 +-------------------------------------------------------------------------------- + +New features: + +- Added support for overlays. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0.1 + Alpha Release 1.1.0, 08/11/2000 +-------------------------------------------------------------------------------- + +New features: + +- Added support for XFree86 4.0.1 server. This implies that support for the 4.0 + server has gone. Hence the change in the alpha version number from 1.0.x to + 1.1.x. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0 + Alpha Release 1.0.2, 08/02/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#161, Corruption when moving windows with a wallpaper background. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0 + Alpha Release 1.0.1, 07/27/2000 +-------------------------------------------------------------------------------- + +Fixed bugs: + +#160, Mouse pointer sometimes in bad location. +#258, Temporary corruption starting X. + +-------------------------------------------------------------------------------- + Silicon Motion Driver for XFree86 4.0 + Alpha Release 1.0.0, 06/05/2000 +-------------------------------------------------------------------------------- + +This is alpha version 1.0.0 of the Silicon Motion drivers for the XFree86 4.0 +server. See the README file for general information. + +This ALPHA version has the following known problems: + +- During mode initialization, the screen shows temporary garbage. +- Image Transfers are disabled in the hardware for now. + +This driver has been tested on the LynxEM+ 712 chip under 16-bit mode. Any other +mode might still show lock-ups and/or garbage. Please report any problems to +frido@siliconmotion.com. + +Header: //Mercury/Projects/archives/XFree86/4.0/Release.txt-arc 1.30 30 Nov 2000 17:00:58 Frido $ + +$XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/Release.txt,v 1.3 2000/12/14 01:05:43 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h:1.1 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h Tue Nov 28 15:59:19 2000 @@ -0,0 +1,207 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/regsmi.h-arc 1.11 14 Sep 2000 11:17:30 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and SIlicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h,v 1.1 2000/11/28 20:59:19 dawes Exp $ */ + +#ifndef _REGSMI_H +#define _REGSMI_H + +#define SMI_LYNX_SERIES(chip) ((chip & 0xF0F0) == 0x0010) +#define SMI_LYNX3D_SERIES(chip) ((chip & 0xF0F0) == 0x0020) +#define SMI_LYNXEM_SERIES(chip) ((chip & 0xFFF0) == 0x0710) +#define SMI_LYNXM_SERIES(chip) ((chip & 0xFF00) == 0x0700) + +/* Chip tags */ +#define PCI_SMI_VENDOR_ID PCI_VENDOR_SMI +#define SMI_UNKNOWN 0 +#define SMI_LYNX PCI_CHIP_SMI910 +#define SMI_LYNXE PCI_CHIP_SMI810 +#define SMI_LYNX3D PCI_CHIP_SMI820 +#define SMI_LYNXEM PCI_CHIP_SMI710 +#define SMI_LYNXEMplus PCI_CHIP_SMI712 +#define SMI_LYNX3DM PCI_CHIP_SMI720 + +/* I/O Functions */ +static __inline__ CARD8 +VGAIN8_INDEX(SMIPtr pSmi, int indexPort, int dataPort, CARD8 index) +{ + if (pSmi->IOBase) + { + MMIO_OUT8(pSmi->IOBase, indexPort, index); + return(MMIO_IN8(pSmi->IOBase, dataPort)); + } + else + { + outb(indexPort, index); + return(inb(dataPort)); + } +} + +static __inline__ void +VGAOUT8_INDEX(SMIPtr pSmi, int indexPort, int dataPort, CARD8 index, CARD8 data) +{ + if (pSmi->IOBase) + { + MMIO_OUT8(pSmi->IOBase, indexPort, index); + MMIO_OUT8(pSmi->IOBase, dataPort, data); + } + else + { + outb(indexPort, index); + outb(dataPort, data); + } +} + +static __inline__ CARD8 +VGAIN8(SMIPtr pSmi, int port) +{ + if (pSmi->IOBase) + { + return(MMIO_IN8(pSmi->IOBase, port)); + } + else + { + return(inb(port)); + } +} + +static __inline__ void +VGAOUT8(SMIPtr pSmi, int port, CARD8 data) +{ + if (pSmi->IOBase) + { + MMIO_OUT8(pSmi->IOBase, port, data); + } + else + { + outb(port, data); + } +} + +#define OUT_SEQ(pSmi, index, data) \ + VGAOUT8_INDEX((pSmi), VGA_SEQ_INDEX, VGA_SEQ_DATA, (index), (data)) +#define IN_SEQ(pSmi, index) \ + VGAIN8_INDEX((pSmi), VGA_SEQ_INDEX, VGA_SEQ_DATA, (index)) + +#define WRITE_DPR(pSmi, dpr, data) MMIO_OUT32(pSmi->DPRBase, dpr, data); DEBUG((VERBLEV, "DPR%02X = %08X\n", dpr, data)) +#define READ_DPR(pSmi, dpr) MMIO_IN32(pSmi->DPRBase, dpr) +#define WRITE_VPR(pSmi, vpr, data) MMIO_OUT32(pSmi->VPRBase, vpr, data); DEBUG((VERBLEV, "VPR%02X = %08X\n", vpr, data)) +#define READ_VPR(pSmi, vpr) MMIO_IN32(pSmi->VPRBase, vpr) +#define WRITE_CPR(pSmi, cpr, data) MMIO_OUT32(pSmi->CPRBase, cpr, data); DEBUG((VERBLEV, "CPR%02X = %08X\n", cpr, data)) +#define READ_CPR(pSmi, cpr) MMIO_IN32(pSmi->CPRBase, cpr) + +/* 2D Engine commands */ +#define SMI_TRANSPARENT_SRC 0x00000100 +#define SMI_TRANSPARENT_DEST 0x00000300 + +#define SMI_OPAQUE_PXL 0x00000000 +#define SMI_TRANSPARENT_PXL 0x00000400 + +#define SMI_MONO_PACK_8 0x00001000 +#define SMI_MONO_PACK_16 0x00002000 +#define SMI_MONO_PACK_32 0x00003000 + +#define SMI_ROP2_SRC 0x00008000 +#define SMI_ROP2_PAT 0x0000C000 +#define SMI_ROP3 0x00000000 + +#define SMI_BITBLT 0x00000000 +#define SMI_RECT_FILL 0x00010000 +#define SMI_TRAPEZOID_FILL 0x00030000 +#define SMI_SHORT_STROKE 0x00060000 +#define SMI_BRESENHAM_LINE 0x00070000 +#define SMI_HOSTBLT_WRITE 0x00080000 +#define SMI_HOSTBLT_READ 0x00090000 +#define SMI_ROTATE_BLT 0x000B0000 + +#define SMI_SRC_COLOR 0x00000000 +#define SMI_SRC_MONOCHROME 0x00400000 + +#define SMI_GRAPHICS_STRETCH 0x00800000 + +#define SMI_ROTATE_CW 0x01000000 +#define SMI_ROTATE_CCW 0x02000000 + +#define SMI_MAJOR_X 0x00000000 +#define SMI_MAJOR_Y 0x04000000 + +#define SMI_LEFT_TO_RIGHT 0x00000000 +#define SMI_RIGHT_TO_LEFT 0x08000000 + +#define SMI_COLOR_PATTERN 0x40000000 +#define SMI_MONO_PATTERN 0x00000000 + +#define SMI_QUICK_START 0x10000000 +#define SMI_START_ENGINE 0x80000000 + +#define MAXLOOP 0x100000 /* timeout value for engine waits */ + +#define ENGINE_IDLE() \ + ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x08) == 0) +#define FIFO_EMPTY() \ + ((VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16) & 0x10) != 0) + +/* Wait until "v" queue entries are free */ +#define WaitQueue(v) \ + do \ + { \ + if (pSmi->NoPCIRetry) \ + { \ + int loop = MAXLOOP; mem_barrier(); \ + while (!FIFO_EMPTY()) \ + if (loop-- == 0) break; \ + if (loop <= 0) SMI_GEReset(pScrn, 1, __LINE__, __FILE__); \ + } \ + } while (0) + +/* Wait until GP is idle */ +#define WaitIdle() \ + do \ + { \ + int loop = MAXLOOP; mem_barrier(); \ + while (!ENGINE_IDLE()) \ + if (loop-- == 0) break; \ + if (loop <= 0) SMI_GEReset(pScrn, 1, __LINE__, __FILE__); \ + } \ + while (0) + +/* Wait until GP is idle and queue is empty */ +#define WaitIdleEmpty() \ + do \ + { \ + WaitQueue(MAXFIFO); \ + WaitIdle(); \ + } \ + while (0) + +#define RGB8_PSEUDO (-1) +#define RGB16_565 0 +#define RGB16_555 1 +#define RGB32_888 2 + +#endif /* _REGSMI_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/siliconmotion.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/siliconmotion.cpp:1.4 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/siliconmotion.cpp Tue Dec 12 13:54:31 2000 @@ -0,0 +1,195 @@ +.\" Header: //Mercury/Projects/archives/XFree86/4.0/siliconmotion.cpp-arc 1.4 29 Nov 2000 14:12:56 Frido $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/siliconmotion.cpp,v 1.4 2000/12/12 18:54:31 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH siliconmotion __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +siliconmotion \- Silicon Motion video driver +.SH SYNOPSIS +.B "Section \*qDevice\*q" +.br +.BI " Identifier \*q" devname \*q +.br +.B " Driver \*qsiliconmotion\*q" +.br +\ \ ... +.br +\ \ [ +.B "Option" +"optionname" ["optionvalue"]] +.br +.B EndSection +.SH DESCRIPTION +.B siliconmotion +is an XFree86 driver for Silicon Motion based video cards. The driver is fully +accelerated, and provides support for the following framebuffer depths: +8, 16, and 24. All +visual types are supported for depth 8, and TrueColor +visuals are supported for the other depths. +.SH SUPPORTED HARDWARE +The +.B siliconmotion +driver supports PCI and AGP video cards based on the following Silicon Motion chips: +.TP 12 +.B Lynx +SM910 +.TP 12 +.B LynxE +SM810 +.TP 12 +.B Lynx3D +SM820 +.TP 12 +.B LynxEM +SM710 +.TP 12 +.B LynxEM+ +SM712 +.TP 12 +.B Lynx3DM +SM720 +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. All options names are case and white space insensitive when +parsed by the server, for example, "lynxe" and "LynxE" are equivalent. +.PP +The driver auto-detects the chipset type, but the following +.B ChipSet +names may optionally be specified in the config file +.B \*qDevice\*q +section, and will override the auto-detection: +.PP +.RS 4 +"lynx", "lynxe", "lynx3d", "lynxem", "lynxem+", "lynx3dm". +.RE + +.PP +The following Cursor +.B Options +are supported: +.TP +.BI "Option \*qHWCursor\*q \*q" boolean \*q +Enable or disable the HW cursor. Default: on. +.TP +.BI "Option \*qSWCursor\*q \*q" boolean \*q +Inverse of "HWCursor". Default: off. + +.PP +The following display +.B Options +are supported: +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Use shadow framebuffer. Default: off. +.TP +.BI "Option \*qRotate\*q \*qCW\*q" +.TP +.BI "Option \*qRotate\*q \*qCCW\*q" +Rotate the screen CW - clockwise or CCW - counter clockwise. +Uses ShadowFB. Default: no rotation. +.TP +.BI "Option \*qVideoKey\*q \*q" integer \*q +Set the video color key. Default: a little off full blue. +.TP +.BI "Option \*qByteSwap\*q \*q" boolean \*q +Turn on byte swapping for capturing using SMI demo board. Default: off. +.TP +.BI "Option \*qUseBIOS\*q \*q" boolean \*q +Use the BIOS to set the modes. This is used for custom panel timings. +Default: on. + +.PP +The following video memory +.B Options +are supported: +.TP +.BI "Option \*qset_mclk\*q \*q" integer \*q +sets the memory clock, where +.I integer +is in kHz, and +.I integer +<= 100000. Default: probe the memory clock value, +and use it at server start. + + +.PP +The following acceleration and graphics engine +.B Options +are supported: +.TP +.B "Option \*qNoAccel\*q" +Disable acceleration. Very useful for determining if the +driver has problems with drawing and acceleration routines. This is the first +option to try if your server runs but you see graphic corruption on the screen. +Using it decreases performance, as it uses software emulation for drawing +operations the video driver can accelerate with hardware. +Default: acceleration is enabled. +.TP +.B "Option \*qfifo_aggressive\*q" +.TP +.B "Option \*qfifo_moderate\*q" +.TP +.B "Option \*qfifo_conservative\*q" +alter the settings +for the threshold at which the pixel FIFO takes over the internal +memory bus to refill itself. The smaller this threshold, the better +the acceleration performance of the card. You may try the fastest +setting +.RB ( "fifo_aggressive" ) +and move down if you encounter pixel corruption. +The optimal setting will probably depend on dot-clock and on color +depth. Note that specifying any of these options will also alter other +memory settings which may increase performance, so trying +.B "fifo_conservative" +will in most cases be a slight benefit (this uses the chip defaults). +If pixel corruption or transient streaking is observed during drawing +operations then removing any fifo options is recommended. Default: none. + +.PP +The following PCI bus +.B Options +are supported: +.TP +.BI "Option \*qpci_burst\*q \*q" boolean \*q +will enable PCI burst mode. This should work on all but a +few broken PCI chipsets, and will increase performance. Default: off. +.TP +.BI "Option \*qpci_retry\*q \*q" boolean \*q +will allow the driver to rely on PCI Retry to program the +ViRGE registers. +.B "pci_burst" +must be enabled for this to work. +This will increase performance, especially for small fills/blits, +because the driver does not have to poll the ViRGE before sending it +commands to make sure it is ready. It should work on most +recent PCI chipsets. Default: off. + +.PP +The following additional +.B Options +are supported: +.TP +.BI "Option \*qShowCache\*q \*q" boolean \*q +Enable or disable viewing offscreen cache memory. A +development debug option. Default: off. + +.SH SEE ALSO +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) + +.SH SUPPORT +For assistance with this driver, or XFree86 in general, check the XFree86 web +site at http://www.xfree86.org. A FAQ is available on the web site at +http://www.xfree86.org/FAQ/. If you find a problem with XFree86 or have a +question not answered in the FAQ please use our bug report form available on +the web site or send mail to XFree86@XFree86.org. When reporting problems +with the driver send as much detail as possible, including chipset type, a +server output log, and operating system specifics. + +.SH AUTHORS +Kevin Brosius, +Matt Grossman, +Harald Koenig, +Sebastien Marineau, +Mark Vojkovich, +Frido Garritsen. Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h:1.2 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h Tue Dec 5 16:18:37 2000 @@ -0,0 +1,315 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi.h-arc 1.51 29 Nov 2000 17:45:16 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h,v 1.2 2000/12/05 21:18:37 dawes Exp $ */ + +#ifndef _SMI_H +#define _SMI_H + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86Cursor.h" +#include "vgaHW.h" + +#include "compiler.h" + +#include "mipointer.h" +#include "micmap.h" + +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" + +#include "xaa.h" +#include "xf86cmap.h" +#include "xf86i2c.h" + +#include "xf86int10.h" +#include "vbe.h" + +#ifdef XvExtension + #include "xf86xv.h" + #include "Xv.h" +#endif + +/******************************************************************************/ +/* D E F I N I T O N S */ +/******************************************************************************/ + +#ifndef SMI_DEBUG + #define SMI_DEBUG 0 +#endif + +#define SMI_USE_IMAGE_WRITES 0 +#define SMI_USE_VIDEO 1 +#define SMI_USE_CAPTURE 1 + +/******************************************************************************/ +/* S T R U C T U R E S */ +/******************************************************************************/ + +/* Driver data structure; this should contain all needed info for a mode */ +typedef struct +{ + CARD16 mode; + CARD8 SR17, SR18, SR21, SR31, SR32, SR6A, SR6B, SR81, SRA0; + CARD8 CR33, CR33_2, CR3A; + CARD8 CR40[14], CR40_2[14]; + CARD8 CR90[16], CR9F_2; + CARD8 CRA0[14]; + CARD8 smiDACMask, smiDacRegs[256][3]; + CARD8 smiFont[8192]; + CARD32 DPR10, DPR1C, DPR20, DPR24, DPR28, DPR2C, DPR30, DPR3C, DPR40, + DPR44; + CARD32 VPR00, VPR0C, VPR10; + CARD32 CPR00; + +} SMIRegRec, *SMIRegPtr; + +/* Global PDEV structure. */ +typedef struct +{ + /* accel additions */ + CARD32 AccelCmd; /* Value for DPR0C */ + CARD32 Stride; /* Stride of frame buffer */ + CARD32 ScissorsLeft; /* Left/top of current scissors */ + CARD32 ScissorsRight; /* Right/bottom of current scissors */ + Bool ClipTurnedOn; /* Clipping was turned on by the + previous command */ + + CARD8 SR18Value; /* PDR#521: original SR18 value */ + CARD8 SR21Value; /* PDR#521: original SR21 value */ + SMIRegRec SavedReg; /* console saved mode registers */ + SMIRegRec ModeReg; /* XServer video state mode registers */ + xf86CursorInfoPtr CursorInfoRec; /* HW Cursor info */ + + Bool ModeStructInit; /* Flag indicating ModeReg has been * + * duped from console state */ + int vgaCRIndex, vgaCRReg; + int width, height; /* Width and height of the screen */ + int Bpp; /* Bytes per pixel */ + + /* XAA */ + int videoRAMBytes; /* In units as noted, set in PreInit */ + int videoRAMKBytes; /* In units as noted, set in PreInit */ + unsigned char * MapBase; /* Base of mapped memory */ + int MapSize; /* Size of mapped memory */ + CARD8 * DPRBase; /* Base of DPR registers */ + CARD8 * VPRBase; /* Base of VPR registers */ + CARD8 * CPRBase; /* Base of CPR registers */ + CARD8 * DataPortBase; /* Base of data port */ + int DataPortSize; /* Size of data port */ + volatile CARD8 *IOBase; /* Base of MMIO VGA ports */ + unsigned char * FBBase; /* Base of FB */ + CARD32 FBOffset; /* Current visual FB starting * + * location */ + CARD32 FBCursorOffset; /* Cursor storage location */ + CARD32 FBReserved; /* Reserved memory in frame buffer */ + + Bool PrimaryVidMapped; /* Flag indicating if vgaHWMapMem was * + * used successfully for this screen */ + int dacSpeedBpp; /* Clock value */ + int minClock; /* Mimimum clock */ + int maxClock; /* Maximum clock */ + int MCLK; /* Memory Clock */ + int GEResetCnt; /* Limit the number of errors printed * + * using a counter */ + + Bool pci_burst; /* Enable PCI burst mode for reads? */ + Bool NoPCIRetry; /* Diasable PCI retries */ + Bool fifo_conservative; /* Adjust fifo for acceleration? */ + Bool fifo_moderate; /* Adjust fifo for acceleration? */ + Bool fifo_aggressive; /* Adjust fifo for acceleration? */ + Bool NoAccel; /* Disable Acceleration */ + Bool hwcursor; /* hardware cursor enabled */ + Bool ShowCache; /* Debugging option */ + Bool useBIOS; /* USe BIOS for mode sets */ + + CloseScreenProcPtr CloseScreen; /* Pointer used to save wrapped * + * CloseScreen function. */ + XAAInfoRecPtr AccelInfoRec; /* XAA info Rec */ + pciVideoPtr PciInfo; /* PCI info vars. */ + PCITAG PciTag; + int Chipset; /* Chip info, set using PCI above. */ + int ChipRev; + + /* DGA */ + DGAModePtr DGAModes; /* Pointer to DGA modes */ + int numDGAModes; /* Number of DGA modes */ + Bool DGAactive; /* Flag if DGA is active */ + int DGAViewportStatus; /* DGA Viewport status */ + + /* DPMS */ + int CurrentDPMS; /* Current DPMS state */ + unsigned char DPMS_SR20; /* Saved DPMS SR20 register */ + unsigned char DPMS_SR21; /* Saved DPMS SR21 register */ + unsigned char DPMS_SR31; /* Saved DPMS SR31 register */ + unsigned char DPMS_SR34; /* Saved DPMS SR34 register */ + + /* Panel information */ + Bool lcd; /* LCD active, 1=DSTN, 2=TFT */ + int lcdWidth; /* LCD width */ + int lcdHeight; /* LCD height */ + + I2CBusPtr I2C; /* Pointer to I2C module */ + xf86Int10InfoPtr pInt; /* Pointer to INT10 module */ + vbeInfoPtr pVbe; /* Pointer to VBE module */ + + /* Shadow frame buffer (rotation) */ + Bool shadowFB; /* Flag if shadow buffer is used */ + int rotate; /* Rotation flags */ + int ShadowPitch; /* Pitch of shadow buffer */ + int ShadowWidthBytes; /* Width of shadow buffer in bytes */ + int ShadowWidth; /* Width of shadow buffer in pixels */ + int ShadowHeight; /* Height of shadow buffer in pixels */ + CARD32 saveBufferSize; /* #670 - FB save buffer size */ + void * pSaveBuffer; /* #670 - FB save buffer */ + CARD32 savedFBOffset; /* #670 - Saved FBOffset value */ + CARD32 savedFBReserved; /* #670 - Saved FBReserved value */ + + /* Polylines - #671 */ + ValidateGCProcPtr ValidatePolylines;/* Org. ValidatePolylines function */ + Bool polyLines; /* Our polylines patch is active */ + + void (*PointerMoved)(int index, int x, int y); + +#ifdef XvExtension + int videoKey; /* Video chroma key */ + Bool ByteSwap; /* Byte swap for ZV port */ + /* XvExtension */ + XF86VideoAdaptorPtr ptrAdaptor; /* Pointer to VideoAdapter structure */ + void (*BlockHandler)(int i, pointer blockData, pointer pTimeout, + pointer pReadMask); +#endif + +} SMIRec, *SMIPtr; + +#define SMIPTR(p) ((SMIPtr)((p)->driverPrivate)) + +/******************************************************************************/ +/* M A C R O S */ +/******************************************************************************/ + +#if SMI_DEBUG + #define VERBLEV 1 + #define ENTER_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "ENTER\t" PROCNAME \ + "(%d)\n", __LINE__); xf86Break1() + #define DEBUG_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "DEBUG\t" PROCNAME \ + "(%d)\n", __LINE__); xf86Break2() + #define LEAVE_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "LEAVE\t" PROCNAME \ + "(%d)\n", __LINE__); xf86Break1() + #define DEBUG(arg) xf86ErrorFVerb arg +#else + #define VERBLEV 2 + #define ENTER_PROC(PROCNAME) + #define DEBUG_PROC(PROCNAME) + #define LEAVE_PROC(PROCNAME) + #define DEBUG(arg) +#endif + +/* Some Silicon Motion structs & registers */ +#include "regsmi.h" + +#if !defined (MetroLink) && !defined (VertDebug) +#define VerticalRetraceWait() \ +do \ +{ \ + if (VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x17) & 0x80) \ + { \ + while ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x00) ; \ + while ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x08) ; \ + while ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x00) ; \ + } \ +} while (0) +#else +#define SPIN_LIMIT 1000000 +#define VerticalRetraceWait() +do \ +{ \ + if (VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x17) & 0x80) \ + { \ + volatile unsigned long _spin_me; \ + for (_spin_me = SPIN_LIMIT; \ + ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x00) && _spin_me; \ + _spin_me--) ; \ + if (!_spin_me) \ + ErrorF("smi: warning: VerticalRetraceWait timed out.\n"); \ + for (_spin_me = SPIN_LIMIT; \ + ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x08) && _spin_me; \ + _spin_me--) ; \ + if (!_spin_me) \ + ErrorF("smi: warning: VerticalRetraceWait timed out.\n"); \ + for (_spin_me = SPIN_LIMIT; \ + ((VGAIN8(pSmi, vgaIOBase + 0x0A) & 0x08) == 0x00) && _spin_me; \ + _spin_me--) ; \ + if (!_spin_me) \ + ErrorF("smi: warning: VerticalRetraceWait timed out.\n"); \ + } \ +} while (0) +#endif + +/******************************************************************************/ +/* F U N C T I O N P R O T O T Y P E S */ +/******************************************************************************/ + +/* smi_dac.c */ +void SMI_CommonCalcClock(long freq, int min_m, int min_n1, int max_n1, + int min_n2, int max_n2, long freq_min, long freq_max, + unsigned char * mdiv, unsigned char * ndiv); + +/* smi_i2c */ +Bool SMI_I2CInit(ScrnInfoPtr pScrn); + +/* smi_accel.c */ +Bool SMI_AccelInit(ScreenPtr pScrn); +void SMI_AccelSync(ScrnInfoPtr pScrn); +void SMI_GEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file); + +/* smi_hwcurs.c */ +Bool SMI_HWCursorInit(ScreenPtr pScrn); + +/* smi_driver.c */ +void SMI_AdjustFrame(int scrnIndex, int x, int y, int flags); +Bool SMI_SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); + +/* smi_dga.c */ +Bool SMI_DGAInit(ScreenPtr pScrn); + +/* smi_shadow.c */ +void SMI_PointerMoved(int index, int x, int y); +void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); + +/* smi_video.c */ +void SMI_InitVideo(ScreenPtr pScreen); + +#endif /*_SMI_H*/ Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c:1.2 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c Tue Dec 5 16:18:37 2000 @@ -0,0 +1,1101 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_accel.c-arc 1.15 29 Nov 2000 12:12:04 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c,v 1.2 2000/12/05 21:18:37 dawes Exp $ */ + +#include "smi.h" + +#include "miline.h" +#include "xaalocal.h" +#include "xaarop.h" +#include "servermd.h" + +static void SMI_EngineReset(ScrnInfoPtr); + +static void SMI_SetupForScreenToScreenCopy(ScrnInfoPtr, int, int, int, + unsigned int, int); +static void SMI_SubsequentScreenToScreenCopy(ScrnInfoPtr, int, int, int, int, + int, int); +static void SMI_SetupForSolidFill(ScrnInfoPtr, int, int, unsigned); +static void SMI_SubsequentSolidFillRect(ScrnInfoPtr, int, int, int, int); +static void SMI_SubsequentSolidHorVertLine(ScrnInfoPtr, int, int, int, int); +static void SMI_SetupForCPUToScreenColorExpandFill(ScrnInfoPtr, int, int, int, + unsigned int); +static void SMI_SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr, int, int, int, + int, int); +static void SMI_SetupForMono8x8PatternFill(ScrnInfoPtr, int, int, int, int, int, + unsigned int); +static void SMI_SubsequentMono8x8PatternFillRect(ScrnInfoPtr, int, int, int, + int, int, int); +static void SMI_SetupForColor8x8PatternFill(ScrnInfoPtr, int, int, int, + unsigned int, int); +static void SMI_SubsequentColor8x8PatternFillRect(ScrnInfoPtr, int, int, int, + int, int, int); +#if SMI_USE_IMAGE_WRITES +static void SMI_SetupForImageWrite(ScrnInfoPtr, int, unsigned int, int, int, + int); +static void SMI_SubsequentImageWriteRect(ScrnInfoPtr, int, int, int, int, int); +#endif +static void SMI_SetClippingRectangle(ScrnInfoPtr, int, int, int, int); +static void SMI_DisableClipping(ScrnInfoPtr); +/* #671 */ +static void SMI_ValidatePolylines(GCPtr, unsigned long, DrawablePtr); +static void SMI_Polylines(DrawablePtr, GCPtr, int, int, DDXPointPtr); + +Bool +SMI_AccelInit(ScreenPtr pScreen) +{ + XAAInfoRecPtr infoPtr; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + BoxRec AvailFBArea; + Bool ret; + int numLines, maxLines; + + ENTER_PROC("SMI_AccelInit"); + + pSmi->AccelInfoRec = infoPtr = XAACreateInfoRec(); + if (infoPtr == NULL) + { + LEAVE_PROC("SMI_AccelInit"); + return FALSE; + } + + infoPtr->Flags = PIXMAP_CACHE + | LINEAR_FRAMEBUFFER + | OFFSCREEN_PIXMAPS; + + infoPtr->Sync = SMI_AccelSync; + + /* Screen to screen copies */ + infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK + | ONLY_TWO_BITBLT_DIRECTIONS; + infoPtr->SetupForScreenToScreenCopy = SMI_SetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = SMI_SubsequentScreenToScreenCopy; + if (pScrn->bitsPerPixel == 24) + { + infoPtr->ScreenToScreenCopyFlags |= NO_TRANSPARENCY; + } + if ((pSmi->Chipset == SMI_LYNX3D) && (pScrn->bitsPerPixel == 8)) + { + infoPtr->ScreenToScreenCopyFlags |= GXCOPY_ONLY; + } + + /* Solid Fills */ + infoPtr->SolidFillFlags = NO_PLANEMASK; + infoPtr->SetupForSolidFill = SMI_SetupForSolidFill; + infoPtr->SubsequentSolidFillRect = SMI_SubsequentSolidFillRect; + + /* Solid Lines */ + infoPtr->SolidLineFlags = NO_PLANEMASK; + infoPtr->SetupForSolidLine = SMI_SetupForSolidFill; + infoPtr->SubsequentSolidHorVertLine = SMI_SubsequentSolidHorVertLine; + + /* Color Expansion Fills */ + infoPtr->CPUToScreenColorExpandFillFlags = ROP_NEEDS_SOURCE + | NO_PLANEMASK + | BIT_ORDER_IN_BYTE_MSBFIRST + | LEFT_EDGE_CLIPPING + | CPU_TRANSFER_PAD_DWORD + | SCANLINE_PAD_DWORD; + infoPtr->ColorExpandBase = pSmi->DataPortBase; + infoPtr->ColorExpandRange = pSmi->DataPortSize; + infoPtr->SetupForCPUToScreenColorExpandFill = + SMI_SetupForCPUToScreenColorExpandFill; + infoPtr->SubsequentCPUToScreenColorExpandFill = + SMI_SubsequentCPUToScreenColorExpandFill; + + /* 8x8 Mono Pattern Fills */ + infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK + | HARDWARE_PATTERN_PROGRAMMED_BITS + | HARDWARE_PATTERN_SCREEN_ORIGIN + | BIT_ORDER_IN_BYTE_MSBFIRST; + infoPtr->SetupForMono8x8PatternFill = SMI_SetupForMono8x8PatternFill; + infoPtr->SubsequentMono8x8PatternFillRect = + SMI_SubsequentMono8x8PatternFillRect; + + /* 8x8 Color Pattern Fills */ + if (!SMI_LYNX3D_SERIES(pSmi->Chipset) || (pScrn->bitsPerPixel != 24)) + { + infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK + | HARDWARE_PATTERN_SCREEN_ORIGIN; + infoPtr->SetupForColor8x8PatternFill = + SMI_SetupForColor8x8PatternFill; + infoPtr->SubsequentColor8x8PatternFillRect = + SMI_SubsequentColor8x8PatternFillRect; + } + +#if SMI_USE_IMAGE_WRITES + /* Image Writes */ + infoPtr->ImageWriteFlags = ROP_NEEDS_SOURCE + | NO_PLANEMASK + | CPU_TRANSFER_PAD_DWORD + | SCANLINE_PAD_DWORD; + infoPtr->ImageWriteBase = pSmi->DataPortBase; + infoPtr->ImageWriteRange = pSmi->DataPortSize; + infoPtr->SetupForImageWrite = SMI_SetupForImageWrite; + infoPtr->SubsequentImageWriteRect = SMI_SubsequentImageWriteRect; +#endif + + /* Clipping */ + infoPtr->ClippingFlags = HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY + | HARDWARE_CLIP_MONO_8x8_FILL + | HARDWARE_CLIP_COLOR_8x8_FILL + | HARDWARE_CLIP_SOLID_FILL + | HARDWARE_CLIP_SOLID_LINE + | HARDWARE_CLIP_DASHED_LINE; + infoPtr->SetClippingRectangle = SMI_SetClippingRectangle; + infoPtr->DisableClipping = SMI_DisableClipping; + + /* Pixmap Cache */ + if (pScrn->bitsPerPixel == 24) + { + infoPtr->CachePixelGranularity = 16; + } + else + { + infoPtr->CachePixelGranularity = 128 / pScrn->bitsPerPixel; + } + + /* Offscreen Pixmaps */ + infoPtr->maxOffPixWidth = 4096; + infoPtr->maxOffPixHeight = 4096; + if (pScrn->bitsPerPixel == 24) + { + infoPtr->maxOffPixWidth = 4096 / 3; + + if (pSmi->Chipset == SMI_LYNX) + { + infoPtr->maxOffPixHeight = 4096 / 3; + } + } + + SMI_EngineReset(pScrn); + + maxLines = pSmi->FBReserved / (pSmi->width * pSmi->Bpp); + if (pSmi->rotate) + { + numLines = maxLines; + } + else + { + #if defined(XvExtension) && SMI_USE_VIDEO + numLines = ((pSmi->FBReserved - pSmi->width * pSmi->Bpp * pSmi->height) + * 25 / 100 + pSmi->width * pSmi->Bpp - 1) + / (pSmi->width * pSmi->Bpp); + numLines += pSmi->height; + #else + numLines = maxLines; + #endif + } + + AvailFBArea.x1 = 0; + AvailFBArea.y1 = 0; + AvailFBArea.x2 = pSmi->width; + AvailFBArea.y2 = numLines; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "FrameBuffer Box: %d,%d - %d,%d\n", + AvailFBArea.x1, AvailFBArea.y1, AvailFBArea.x2, AvailFBArea.y2); + xf86InitFBManager(pScreen, &AvailFBArea); + + ret = XAAInit(pScreen, infoPtr); + if (ret && pSmi->shadowFB) /* #671 */ + { + pSmi->ValidatePolylines = infoPtr->ValidatePolylines; + infoPtr->ValidatePolylines = SMI_ValidatePolylines; + } + + LEAVE_PROC("SMI_AccelInit"); + return(ret); +} + +void +SMI_GEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD8 tmp; + + ENTER_PROC("SMI_GEReset"); + + if (from_timeout) + { + if (pSmi->GEResetCnt++ < 10 || xf86GetVerbosity() > 1) + { + ErrorF("\tSMI_GEReset called from %s line %d\n", file, line); + } + } + else + { + WaitIdleEmpty(); + } + + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp | 0x30); + + WaitIdleEmpty(); + + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x15, tmp); + SMI_EngineReset(pScrn); + + LEAVE_PROC("SMI_GEReset"); +} + +/* The sync function for the GE */ +void +SMI_AccelSync(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_AccelSync"); + + WaitIdleEmpty(); /* #161 */ + + LEAVE_PROC("SMI_AccelSync"); +} + +static void +SMI_EngineReset(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 DEDataFormat = 0; + int i; + int xyAddress[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 }; + + ENTER_PROC("SMI_EngineReset"); + + pSmi->Stride = (pSmi->width * pSmi->Bpp + 15) & ~15; + + switch (pScrn->bitsPerPixel) + { + case 8: + DEDataFormat = 0x00000000; + break; + + case 16: + pSmi->Stride >>= 1; + DEDataFormat = 0x00100000; + break; + + case 24: + DEDataFormat = 0x00300000; + break; + + case 32: + pSmi->Stride >>= 2; + DEDataFormat = 0x00200000; + break; + } + for (i = 0; i < sizeof(xyAddress) / sizeof(xyAddress[0]); i++) + { + if (pSmi->rotate) + { + if (xyAddress[i] == pSmi->height) + { + DEDataFormat |= i << 16; + break; + } + } + else + { + if (xyAddress[i] == pSmi->width) + { + DEDataFormat |= i << 16; + break; + } + } + } + + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x1C, DEDataFormat); + WRITE_DPR(pSmi, 0x24, 0xFFFFFFFF); + WRITE_DPR(pSmi, 0x28, 0xFFFFFFFF); + WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x40, 0); + WRITE_DPR(pSmi, 0x44, 0); + + SMI_DisableClipping(pScrn); + + LEAVE_PROC("SMI_EngineReset"); +} + +/******************************************************************************/ +/* Screen to Screen Copies */ +/******************************************************************************/ + +static void +SMI_SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, + unsigned int planemask, int trans) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForScreenToScreenCopy"); + DEBUG((VERBLEV, "xdir=%d ydir=%d rop=%02X trans=%08X\n", xdir, ydir, + rop, trans)); + + pSmi->AccelCmd = XAACopyROP[rop] + | SMI_BITBLT + | SMI_START_ENGINE; + + if ((xdir == -1) || (ydir == -1)) + { + pSmi->AccelCmd |= SMI_RIGHT_TO_LEFT; + } + + if (trans != -1) + { + pSmi->AccelCmd |= SMI_TRANSPARENT_SRC | SMI_TRANSPARENT_PXL; + WaitQueue(1); + WRITE_DPR(pSmi, 0x20, trans); + } + + if (pSmi->ClipTurnedOn) + { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + + LEAVE_PROC("SMI_SetupForScreenToScreenCopy"); +} + +static void +SMI_SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2, + int y2, int w, int h) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentScreenToScreenCopy"); + DEBUG((VERBLEV, "x1=%d y1=%d x2=%d y2=%d w=%d h=%d\n", x1, y1, x2, y2, w, + h)); + + if (pSmi->AccelCmd & SMI_RIGHT_TO_LEFT) + { + x1 += w - 1; + y1 += h - 1; + x2 += w - 1; + y2 += h - 1; + } + + if (pScrn->bitsPerPixel == 24) + { + x1 *= 3; + x2 *= 2; + w *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y1 *= 3; + y2 *= 3; + } + + if (pSmi->AccelCmd & SMI_RIGHT_TO_LEFT) + { + x1 += 2; + x2 += 2; + } + } + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (x1 << 16) + (y1 & 0xFFFF)); + WRITE_DPR(pSmi, 0x04, (x2 << 16) + (y2 & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) + (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentScreenToScreenCopy"); +} + +/******************************************************************************/ +/* Solid Fills */ +/******************************************************************************/ + +static void +SMI_SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, + unsigned int planemask) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForSolidFill"); + DEBUG((VERBLEV, "color=%08X rop=%02X\n", color, rop)); + + pSmi->AccelCmd = XAAPatternROP[rop] + | SMI_BITBLT + | SMI_START_ENGINE; + + if (pSmi->ClipTurnedOn) + { + WaitQueue(4); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + else + { + WaitQueue(3); + } + WRITE_DPR(pSmi, 0x14, color); + WRITE_DPR(pSmi, 0x34, 0xFFFFFFFF); + WRITE_DPR(pSmi, 0x38, 0xFFFFFFFF); + + LEAVE_PROC("SMI_SetupForSolidFill"); +} + +void +SMI_SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentSolidFillRect"); + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", x, y, w, h)); + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + WaitQueue(3); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentSolidFillRect"); +} + +/******************************************************************************/ +/* Solid Lines */ +/******************************************************************************/ + +static void +SMI_SubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, + int dir) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int w, h; + + ENTER_PROC("SMI_SubsequentSolidHorVertLine"); + DEBUG((VERBLEV, "x=%d y=%d len=%d dir=%d\n", x, y, len, dir)); + + if (dir == DEGREES_0) + { + w = len; + h = 1; + } + else + { + w = 1; + h = len; + } + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + WaitQueue(3); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentSolidHorVertLine"); +} + +/******************************************************************************/ +/* Color Expansion Fills */ +/******************************************************************************/ + +static void +SMI_SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, + int rop, unsigned int planemask) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForCPUToScreenColorExpandFill"); + DEBUG((VERBLEV, "fg=%08X bg=%08X rop=%02X\n", fg, bg, rop)); + + pSmi->AccelCmd = XAACopyROP[rop] + | SMI_HOSTBLT_WRITE + | SMI_SRC_MONOCHROME + | SMI_START_ENGINE; + + if (bg == -1) + { + pSmi->AccelCmd |= SMI_TRANSPARENT_SRC; + + WaitQueue(3); + WRITE_DPR(pSmi, 0x14, fg); + WRITE_DPR(pSmi, 0x18, ~fg); + WRITE_DPR(pSmi, 0x20, fg); + } + else + { + WaitQueue(2); + WRITE_DPR(pSmi, 0x14, fg); + WRITE_DPR(pSmi, 0x18, bg); + } + + LEAVE_PROC("SMI_SetupForCPUToScreenColorExpandFill"); +} + +void +SMI_SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, + int h, int skipleft) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentCPUToScreenColorExpandFill"); + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d skipleft=%d\n", x, y, w, h, skipleft)); + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + skipleft *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + if (skipleft) + { + WaitQueue(5); + WRITE_DPR(pSmi, 0x2C, (pSmi->ScissorsLeft & 0xFFFF0000) + | (x + skipleft) | 0x2000); + pSmi->ClipTurnedOn = TRUE; + } + else + { + if (pSmi->ClipTurnedOn) + { + WaitQueue(5); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + else + { + WaitQueue(4); + } + } + WRITE_DPR(pSmi, 0x00, 0); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentCPUToScreenColorExpandFill"); +} + +/******************************************************************************/ +/* 8x8 Mono Pattern Fills */ +/******************************************************************************/ + +static void +SMI_SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, int fg, + int bg, int rop, unsigned int planemask) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForMono8x8PatternFill"); + DEBUG((VERBLEV, "patx=%08X paty=%08X fg=%08X bg=%08X rop=%02X\n", patx, + paty, fg, bg, rop)); + + pSmi->AccelCmd = XAAPatternROP[rop] + | SMI_BITBLT + | SMI_START_ENGINE; + + if (pSmi->ClipTurnedOn) + { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + + if (bg == -1) + { + WaitQueue(5); + WRITE_DPR(pSmi, 0x14, fg); + WRITE_DPR(pSmi, 0x18, ~fg); + WRITE_DPR(pSmi, 0x20, fg); + WRITE_DPR(pSmi, 0x34, patx); + WRITE_DPR(pSmi, 0x38, paty); + } + else + { + WaitQueue(4); + WRITE_DPR(pSmi, 0x14, fg); + WRITE_DPR(pSmi, 0x18, bg); + WRITE_DPR(pSmi, 0x34, patx); + WRITE_DPR(pSmi, 0x38, paty); + } + + LEAVE_PROC("SMI_SetupForMono8x8PatternFill"); +} + +static void +SMI_SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty, + int x, int y, int w, int h) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentMono8x8PatternFillRect"); + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", x, y, w, h)); + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + WaitQueue(3); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentMono8x8PatternFillRect"); +} + +/******************************************************************************/ +/* 8x8 Color Pattern Fills */ +/******************************************************************************/ + +static void +SMI_SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, int rop, + unsigned int planemask, int trans_color) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForColor8x8PatternFill"); + DEBUG((VERBLEV, "patx=%d paty=%d rop=%02X trans_color=%08X\n", patx, paty, + rop, trans_color)); + + pSmi->AccelCmd = XAAPatternROP[rop] + | SMI_BITBLT + | SMI_COLOR_PATTERN + | SMI_START_ENGINE; + + if (pScrn->bitsPerPixel <= 16) + { + unsigned char * pattern = pSmi->FBBase + patx * pSmi->Bpp + + paty * pSmi->Stride; + + WaitQueue(1); + WRITE_DPR(pSmi, 0x0C, SMI_BITBLT | SMI_COLOR_PATTERN); + memcpy(pSmi->DataPortBase, pattern, 8 * pSmi->Bpp * 8); + } + else + { + if (pScrn->bitsPerPixel == 24) + { + patx *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + paty *= 3; + } + } + + WaitQueue(1); + WRITE_DPR(pSmi, 0x00, (patx << 16) | (paty & 0xFFFF)); + } + + if (trans_color == -1) + { + pSmi->AccelCmd |= SMI_TRANSPARENT_SRC | SMI_TRANSPARENT_PXL; + + WaitQueue(1); + WRITE_DPR(pSmi, 0x20, trans_color); + } + + if (pSmi->ClipTurnedOn) + { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + + LEAVE_PROC("SMI_SetupForColor8x8PatternFill"); +} + +static void +SMI_SubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty, + int x, int y, int w, int h) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentColor8x8PatternFillRect"); + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", x, y, w, h)); + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + WaitQueue(3); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (y & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentColor8x8PatternFillRect"); +} + +#if SMI_USE_IMAGE_WRITES +/******************************************************************************/ +/* Image Writes */ +/******************************************************************************/ + +static void +SMI_SetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, + int trans_color, int bpp, int depth) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetupForImageWrite"); + DEBUG((VERBLEV, "rop=%02X trans_color=%08X bpp=%d depth=%d\n", rop, + trans_color, bpp, depth)); + + pSmi->AccelCmd = XAACopyROP[rop] + | SMI_HOSTBLT_WRITE + | SMI_START_ENGINE; + + if (trans_color != -1) + { + pSmi->AccelCmd |= SMI_TRANSPARENT_SRC | SMI_TRANSPARENT_PXL; + + WaitQueue(1); + WRITE_DPR(pSmi, 0x20, trans_color); + } + + LEAVE_PROC("SMI_SetupForImageWrite"); +} + +static void +SMI_SubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, + int skipleft) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SubsequentImageWriteRect"); + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d skipleft=%d\n", x, y, w, h, skipleft)); + + if (pScrn->bitsPerPixel == 24) + { + x *= 3; + w *= 3; + skipleft *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + y *= 3; + } + } + + if (skipleft) + { + WaitQueue(5); + WRITE_DPR(pSmi, 0x2C, (pSmi->ScissorsLeft & 0xFFFF0000) | + (x + skipleft) | 0x2000); + pSmi->ClipTurnedOn = TRUE; + } + else + { + if (pSmi->ClipTurnedOn) + { + WaitQueue(5); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + else + { + WaitQueue(4); + } + } + WRITE_DPR(pSmi, 0x00, 0); + WRITE_DPR(pSmi, 0x04, (x << 16) | (y * 0xFFFF)); + WRITE_DPR(pSmi, 0x08, (w << 16) | (h & 0xFFFF)); + WRITE_DPR(pSmi, 0x0C, pSmi->AccelCmd); + + LEAVE_PROC("SMI_SubsequentImageWriteRect"); +} +#endif + +/******************************************************************************/ +/* Clipping */ +/******************************************************************************/ + +static void +SMI_SetClippingRectangle(ScrnInfoPtr pScrn, int left, int top, int right, + int bottom) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetClippingRectangle"); + DEBUG((VERBLEV, "left=%d top=%d right=%d bottom=%d\n", left, top, right, + bottom)); + + left = max(left, 0); + top = max(top, 0); + right = min(right, pSmi->width); + bottom = min(bottom, pSmi->height); + + if (pScrn->bitsPerPixel == 24) + { + left *= 3; + right *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + top *= 3; + bottom *= 3; + } + } + + pSmi->ScissorsLeft = (top << 16) | (left & 0xFFFF) | 0x2000; + pSmi->ScissorsRight = (bottom << 16) | (right & 0xFFFF); + + pSmi->ClipTurnedOn = FALSE; + + WaitQueue(2); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + WRITE_DPR(pSmi, 0x30, pSmi->ScissorsRight); + + LEAVE_PROC("SMI_SetClippingRectangle"); +} + +static void +SMI_DisableClipping(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_DisableClipping"); + + pSmi->ScissorsLeft = 0; + if (pScrn->bitsPerPixel == 24) + { + if (pSmi->Chipset == SMI_LYNX) + { + pSmi->ScissorsRight = ((pSmi->height * 3) << 16) + | (pSmi->width * 3); + } + else + { + pSmi->ScissorsRight = (pSmi->height << 16) | (pSmi->width * 3); + } + } + else + { + pSmi->ScissorsRight = (pSmi->height << 16) | pSmi->width; + } + + pSmi->ClipTurnedOn = FALSE; + + WaitQueue(2); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + WRITE_DPR(pSmi, 0x30, pSmi->ScissorsRight); + + LEAVE_PROC("SMI_DisableClipping"); +} + +/******************************************************************************/ +/* Polylines #671 */ +/******************************************************************************/ + +/* + +In order to speed up the "logout" screen in rotated modes, we need to intercept +the Polylines function. Normally, the polylines are drawn and the shadowFB is +then sending a request of the bounding rectangle of those poylines. This should +be okay, if it weren't for the fact that the Gnome logout screen is drawing +polylines in rectangles and this asks for a rotation of the entire rectangle. +This is very slow. + +To circumvent this slowness, we intercept the ValidatePolylines function and +override the default "Fallback" Polylines with our own Polylines function. Our +Polylines function first draws the polylines through the original Fallback +function and then rotates the lines, line by line. We then set a flag and +return control to the shadowFB which will try to rotate the bounding rectangle. +However, the flag has been set and the RefreshArea function does nothing but +clear the flag so the next Refresh that comes in shoiuld be handled correctly. + +All this code improves the speed quite a bit. + +*/ + +#define IS_VISIBLE(pWin) \ +( \ + pScrn->vtSema \ + && (((WindowPtr) pWin)->visibility != VisibilityFullyObscured) \ +) + +#define TRIM_BOX(box, pGC) \ +{ \ + BoxPtr extents = &pGC->pCompositeClip->extents; \ + if (box.x1 < extents->x1) box.x1 = extents->x1; \ + if (box.y1 < extents->y1) box.y1 = extents->y1; \ + if (box.x2 > extents->x2) box.x2 = extents->x2; \ + if (box.y2 > extents->y2) box.y2 = extents->y2; \ +} + +#define TRANSLATE_BOX(box, pDraw) \ +{ \ + box.x1 += pDraw->x; \ + box.y1 += pDraw->y; \ + box.x2 += pDraw->x; \ + box.y2 += pDraw->y; \ +} + +#define BOX_NOT_EMPTY(box) \ + ((box.x2 > box.x1) && (box.y2 > box.y1)) + +static void +SMI_ValidatePolylines(GCPtr pGC, unsigned long changes, DrawablePtr pDraw) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + SMIPtr pSmi = SMIPTR(infoRec->pScrn); + + ENTER_PROC("SMI_ValidatePolylines"); + + pSmi->ValidatePolylines(pGC, changes, pDraw); + if (pGC->ops->Polylines == XAAFallbackOps.Polylines) + { + /* Override the Polylines function with our own Polylines function. */ + pGC->ops->Polylines = SMI_Polylines; + } + + LEAVE_PROC("SMI_ValidatePolylines"); +} + +static void +SMI_Polylines(DrawablePtr pDraw, GCPtr pGC, int mode, int npt, + DDXPointPtr pptInit) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + ScrnInfoPtr pScrn = infoRec->pScrn; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_Polylines"); + + /* Call the original Polylines function. */ + pGC->ops->Polylines = XAAFallbackOps.Polylines; + (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit); + pGC->ops->Polylines = SMI_Polylines; + + if (IS_VISIBLE(pDraw) && npt) + { + /* Allocate a temporary buffer for all segments of the polyline. */ + BoxPtr pBox = xnfcalloc(sizeof(BoxRec), npt); + int extra = pGC->lineWidth >> 1, box; + + if (npt > 1) + { + /* Adjust the extra space required per polyline segment. */ + if (pGC->joinStyle == JoinMiter) + { + extra = 6 * pGC->lineWidth; + } + else if (pGC->capStyle == CapProjecting) + { + extra = pGC->lineWidth; + } + } + + for (box = 0; --npt;) + { + /* Setup the bounding box for one polyline segment. */ + pBox[box].x1 = pptInit->x; + pBox[box].y1 = pptInit->y; + pptInit++; + pBox[box].x2 = pptInit->x; + pBox[box].y2 = pptInit->y; + if (mode == CoordModePrevious) + { + pBox[box].x2 += pBox[box].x1; + pBox[box].y2 += pBox[box].y1; + } + + /* Sort coordinates. */ + if (pBox[box].x1 > pBox[box].x2) + { + int tmp = pBox[box].x1; + pBox[box].x1 = pBox[box].x2; + pBox[box].x2 = tmp; + } + if (pBox[box].y1 > pBox[box].y2) + { + int tmp = pBox[box].y1; + pBox[box].y1 = pBox[box].y2; + pBox[box].y2 = tmp; + } + + /* Add extra space required for each polyline segment. */ + pBox[box].x1 -= extra; + pBox[box].y1 -= extra; + pBox[box].x2 += extra + 1; + pBox[box].y2 += extra + 1; + + /* See if we need to draw this polyline segment. */ + TRANSLATE_BOX(pBox[box], pDraw); + TRIM_BOX(pBox[box], pGC); + if (BOX_NOT_EMPTY(pBox[box])) + { + box++; + } + } + + if (box) + { + /* Refresh all polyline segments now. */ + SMI_RefreshArea(pScrn, box, pBox); + } + + /* Free the temporary buffer. */ + xfree(pBox); + } + + pSmi->polyLines = TRUE; + LEAVE_PROC("SMI_Polylines"); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dac.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dac.c:1.1 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dac.c Tue Nov 28 15:59:19 2000 @@ -0,0 +1,99 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_dac.c-arc 1.8 27 Nov 2000 15:47:08 Frido $ */ + +/* +Copyright (C) 1994-1998 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dac.c,v 1.1 2000/11/28 20:59:19 dawes Exp $ */ + +#include "smi.h" + +#define BASE_FREQ 14.31818 /* MHz */ + +void +SMI_CommonCalcClock(long freq, int min_m, int min_n1, int max_n1, int min_n2, + int max_n2, long freq_min, long freq_max, + unsigned char *mdiv, unsigned char *ndiv) +{ + double div, diff, best_diff; + unsigned int m; + unsigned char n1, n2; + unsigned char best_n1 = 63, best_n2 = 3, best_m = 255; + + double ffreq = freq / 1000.0 / BASE_FREQ; + double ffreq_min = freq_min / 1000.0 / BASE_FREQ; + double ffreq_max = freq_max / 1000.0 / BASE_FREQ; + + if (ffreq < ffreq_min / (1 << max_n2)) + { + ErrorF("invalid frequency %1.3f MHz [freq >= %1.3f MHz]\n", + ffreq * BASE_FREQ, ffreq_min * BASE_FREQ / (1 << max_n2)); + ffreq = ffreq_min / (1 << max_n2); + } + if (ffreq > ffreq_max / (1 << min_n2)) + { + ErrorF("invalid frequency %1.3f MHz [freq <= %1.3f MHz]\n", + ffreq * BASE_FREQ, ffreq_max * BASE_FREQ / (1 << min_n2)); + ffreq = ffreq_max / (1 << min_n2); + } + + /* work out suitable timings */ + best_diff = ffreq; + + for (n2 = min_n2; n2 <= max_n2; n2++) + { + for (n1 = min_n1; n1 <= max_n1; n1++) + { + m = (int)(ffreq * n1 * (1 << n2) + 0.5); + if ( (m < min_m) || (m > 255) ) + { + continue; + } + div = (double)(m) / (double)(n1); + if ( (div >= ffreq_min) && (div <= ffreq_max) ) + { + diff = ffreq - div / (1 << n2); + if (diff < 0.0) + { + diff = -diff; + } + if (diff < best_diff) + { + best_diff = diff; + best_m = m; + best_n1 = n1; + best_n2 = n2; + } + } + } + } + + DEBUG((VERBLEV, "Clock parameters for %1.6f MHz: m=%d, n1=%d, n2=%d\n", + ((double)(best_m) / (double)(best_n1) / (1 << best_n2)) * BASE_FREQ, + best_m, best_n1, best_n2)); + + *ndiv = best_n1 | (best_n2 << 6); + *mdiv = best_m; +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dga.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dga.c:1.1 --- /dev/null Mon Dec 18 14:31:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dga.c Tue Nov 28 15:59:19 2000 @@ -0,0 +1,301 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_dga.c-arc 1.5 27 Nov 2000 15:47:18 Frido $ */ + +/* +Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_dga.c,v 1.1 2000/11/28 20:59:19 dawes Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xaa.h" +#include "xaalocal.h" + +#include "smi.h" +#include "dgaproc.h" + +static Bool SMI_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, int *, + int *, int *); +static Bool SMI_SetMode(ScrnInfoPtr, DGAModePtr); +static int SMI_GetViewport(ScrnInfoPtr); +static void SMI_SetViewport(ScrnInfoPtr, int, int, int); +static void SMI_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void SMI_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +static void SMI_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); + +static +DGAFunctionRec SMI_DGAFuncs = +{ + SMI_OpenFramebuffer, + NULL, + SMI_SetMode, + SMI_SetViewport, + SMI_GetViewport, + SMI_AccelSync, + SMI_FillRect, + SMI_BlitRect, + SMI_BlitTransRect +}; + +Bool +SMI_DGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + Bool ret; + + ENTER_PROC("SMI_DGAInit"); + + pMode = firstMode = pScrn->modes; + + while (pMode) + { + newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); + if (newmodes == NULL) + { + xfree(modes); + LEAVE_PROC("SMI_DGAInit"); + return(FALSE); + } + + modes = newmodes; + + currentMode = modes + num; + num++; + + currentMode->mode = pMode; + currentMode->flags = DGA_PIXMAP_AVAILABLE; + if (!pSmi->NoAccel) + { + currentMode->flags |= DGA_FILL_RECT + | DGA_BLIT_RECT + | DGA_BLIT_RECT_TRANS; + } + if (pMode->Flags & V_DBLSCAN) + { + currentMode->flags |= DGA_DOUBLESCAN; + } + if (pMode->Flags & V_INTERLACE) + { + currentMode->flags |= DGA_INTERLACED; + } + + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = (Bpp == 3) ? 8 : (8 / Bpp); + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = pSmi->FBBase; + + xf86ErrorFVerb(VERBLEV, "\tSMI_DGAInit %dx%d @ %d bpp\n", + currentMode->viewportWidth, currentMode->viewportHeight, + currentMode->bitsPerPixel); + + currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 15) + & ~15L; + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = (pSmi->videoRAMBytes - pSmi->FBReserved) + / currentMode->bytesPerScanline; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth + - currentMode->viewportWidth; + currentMode->maxViewportY = currentMode->imageHeight + - currentMode->viewportHeight; + + pMode = pMode->next; + if (pMode == firstMode) + { + break; + } + } + + pSmi->numDGAModes = num; + pSmi->DGAModes = modes; + + ret = DGAInit(pScreen, &SMI_DGAFuncs, modes, num); + LEAVE_PROC("SMI_DGAInit"); + return(ret); +} + +static Bool +SMI_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) +{ + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetMode"); + + if (pMode == NULL) + { /* restore the original mode */ + + /* put the ScreenParameters back */ + pScrn->displayWidth = OldDisplayWidth[index]; + + SMI_SwitchMode(index, pScrn->currentMode, 0); + pSmi->DGAactive = FALSE; + } + else + { + if (!pSmi->DGAactive) + { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + + pSmi->DGAactive = TRUE; + } + + pScrn->displayWidth = pMode->bytesPerScanline + / (pMode->bitsPerPixel >> 3); + + SMI_SwitchMode(index, pMode->mode, 0); + } + + LEAVE_PROC("SMI_SetMode"); + return(TRUE); +} + + +static int +SMI_GetViewport(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_GetViewport"); + + LEAVE_PROC("SMI_GetViewport"); + + return(pSmi->DGAViewportStatus); +} + +static void +SMI_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetViewport"); + + SMI_AdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pSmi->DGAViewportStatus = 0; + + LEAVE_PROC("SMI_SetViewport"); +} + +static void +SMI_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_FillRect"); + + if (pSmi->AccelInfoRec) + { + (*pSmi->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*pSmi->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(pSmi->AccelInfoRec); + } + + LEAVE_PROC("SMI_FillRect"); +} + +static void +SMI_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, + int dsty) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_BlitRect"); + + if (pSmi->AccelInfoRec) + { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pSmi->AccelInfoRec->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, + GXcopy, ~0, -1); + (*pSmi->AccelInfoRec->SubsequentScreenToScreenCopy)(pScrn, srcx, srcy, + dstx, dsty, w, h); + SET_SYNC_FLAG(pSmi->AccelInfoRec); + } + + LEAVE_PROC("SMI_BlitRect"); +} + +static void +SMI_BlitTransRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, + int dsty, unsigned long color) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_BlitTraneRect"); + + if (pSmi->AccelInfoRec) + { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pSmi->AccelInfoRec->SetupForScreenToScreenCopy)(pScrn, xdir, ydir, + GXcopy, ~0, color); + (*pSmi->AccelInfoRec->SubsequentScreenToScreenCopy)(pScrn, srcx, srcy, + dstx, dsty, w, h); + SET_SYNC_FLAG(pSmi->AccelInfoRec); + } + + LEAVE_PROC("SMI_BlitTraneRect"); +} + +static Bool +SMI_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem, + int *size, int *offset, int *flags) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_OpenFrameBuffer"); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)pSmi->FBBase; + *size = pSmi->videoRAMBytes; + *offset = 0; + *flags = DGA_NEED_ROOT; + + LEAVE_PROC("SMI_OpenFrameBuffer"); + return(TRUE); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c:1.6 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c Wed Dec 13 20:05:43 2000 @@ -0,0 +1,3040 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_driver.c-arc 1.40 06 Dec 2000 15:35:00 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of The XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from The XFree86 Project or Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c,v 1.6 2000/12/14 01:05:43 dawes Exp $ */ + +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86DDC.h" +#include "xf86int10.h" +#include "vbe.h" +#include "shadowfb.h" + +#include "smi.h" + +#ifdef DPMSExtension + #include "globals.h" + #define DPMS_SERVER + #include "extensions/dpms.h" +#endif + +/* + * Internals + */ +static void SMI_EnableMmio(ScrnInfoPtr pScrn); +static void SMI_DisableMmio(ScrnInfoPtr pScrn); + +/* + * Forward definitions for the functions that make up the driver. + */ + +static OptionInfoPtr SMI_AvailableOptions(int chipid, int busid); +static void SMI_Identify(int flags); +static Bool SMI_Probe(DriverPtr drv, int flags); +static Bool SMI_PreInit(ScrnInfoPtr pScrn, int flags); +static Bool SMI_EnterVT(int scrnIndex, int flags); +static void SMI_LeaveVT(int scrnIndex, int flags); +static void SMI_Save (ScrnInfoPtr pScrn); +static void SMI_WriteMode (ScrnInfoPtr pScrn, vgaRegPtr, SMIRegPtr); +static Bool SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, + char **argv); +static int SMI_InternalScreenInit(int scrnIndex, ScreenPtr pScreen); +static void SMI_PrintRegs(ScrnInfoPtr); +static ModeStatus SMI_ValidMode(int scrnIndex, DisplayModePtr mode, + Bool verbose, int flags); +static Bool SMI_MapMem(ScrnInfoPtr pScrn); +static void SMI_UnmapMem(ScrnInfoPtr pScrn); +static Bool SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static Bool SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SMI_SaveScreen(ScreenPtr pScreen, int mode); +static void SMI_LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, + LOCO *colors, VisualPtr pVisual); +#ifdef DPMSExtension +static void SMI_DisplayPowerManagementSet(ScrnInfoPtr pScrn, + int PowerManagementMode, int flags); +#endif +static Bool SMI_ddc1(int scrnIndex); +static unsigned int SMI_ddc1Read(ScrnInfoPtr pScrn); +static void SMI_FreeScreen(int ScrnIndex, int flags); +static void SMI_ProbeDDC(ScrnInfoPtr pScrn, int index); + + +#define SILICONMOTION_NAME "Silicon Motion" +#define SILICONMOTION_DRIVER_NAME "siliconmotion" +#define SILICONMOTION_VERSION_NAME "1.2.0" +#define SILICONMOTION_VERSION_MAJOR 1 +#define SILICONMOTION_VERSION_MINOR 2 +#define SILICONMOTION_PATCHLEVEL 0 +#define SILICONMOTION_DRIVER_VERSION ( (SILICONMOTION_VERSION_MAJOR << 24) \ + | (SILICONMOTION_VERSION_MINOR << 16) \ + | (SILICONMOTION_PATCHLEVEL) \ + ) + +/* + * This contains the functions needed by the server after loading the + * driver module. It must be supplied, and gets added the driver list by + * the Module Setup funtion in the dynamic case. In the static case a + * reference to this is compiled in, and this requires that the name of + * this DriverRec be an upper-case version of the driver name. + */ + +DriverRec SILICONMOTION = +{ + SILICONMOTION_DRIVER_VERSION, + SILICONMOTION_DRIVER_NAME, + SMI_Identify, + SMI_Probe, + SMI_AvailableOptions, + NULL, + 0 +}; + +/* Supported chipsets */ +static SymTabRec SMIChipsets[] = +{ + { PCI_CHIP_SMI910, "Lynx" }, + { PCI_CHIP_SMI810, "LynxE" }, + { PCI_CHIP_SMI820, "Lynx3D" }, + { PCI_CHIP_SMI710, "LynxEM" }, + { PCI_CHIP_SMI712, "LynxEM+" }, + { PCI_CHIP_SMI720, "Lynx3DM" }, + { -1, NULL } +}; + +static PciChipsets SMIPciChipsets[] = +{ + /* numChipset, PciID, Resource */ + { PCI_CHIP_SMI910, PCI_CHIP_SMI910, RES_SHARED_VGA }, + { PCI_CHIP_SMI810, PCI_CHIP_SMI810, RES_SHARED_VGA }, + { PCI_CHIP_SMI820, PCI_CHIP_SMI820, RES_SHARED_VGA }, + { PCI_CHIP_SMI710, PCI_CHIP_SMI710, RES_SHARED_VGA }, + { PCI_CHIP_SMI712, PCI_CHIP_SMI712, RES_SHARED_VGA }, + { PCI_CHIP_SMI720, PCI_CHIP_SMI720, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } +}; + +typedef enum +{ + OPTION_PCI_BURST, + OPTION_FIFO_CONSERV, + OPTION_FIFO_MODERATE, + OPTION_FIFO_AGGRESSIVE, + OPTION_PCI_RETRY, + OPTION_NOACCEL, + OPTION_MCLK, + OPTION_SHOWCACHE, + OPTION_SWCURSOR, + OPTION_HWCURSOR, + OPTION_SHADOW_FB, + OPTION_ROTATE, +#ifdef XvExtension + OPTION_VIDEOKEY, + OPTION_BYTESWAP, +#endif + OPTION_USEBIOS, + NUMBER_OF_OPTIONS + +} SMIOpts; + +static OptionInfoRec SMIOptions[] = +{ + { OPTION_PCI_BURST, "pci_burst", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FIFO_CONSERV, "fifo_conservative", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FIFO_MODERATE, "fifo_moderate", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FIFO_AGGRESSIVE, "fifo_aggressive", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_PCI_RETRY, "pci_retry", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_MCLK, "set_mclk", OPTV_FREQ, {0}, FALSE }, + { OPTION_SHOWCACHE, "show_cache", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, +#ifdef XvExtension + { OPTION_VIDEOKEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, + { OPTION_BYTESWAP, "ByteSwap", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_USEBIOS, "UseBIOS", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +/* + * Lists of symbols that may/may not be required by this driver. + * This allows the loader to know which ones to issue warnings for. + * + * Note that vgahwSymbols and xaaSymbols are referenced outside the + * XFree86LOADER define in later code, so are defined outside of that + * define here also. + * cfbSymbols and ramdacSymbols are only referenced from within the + * ...LOADER define. + */ + +static const char *vgahwSymbols[] = +{ + "vgaHWGetHWRec", + "vgaHWSetMmioFuncs", + "vgaHWGetIOBase", + "vgaHWSave", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWMapMem", + "vgaHWUnmapMem", + "vgaHWInit", + "vgaHWSaveScreen", + "vgaHWLock", + NULL +}; + +static const char *xaaSymbols[] = +{ + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + "XAAOverlayFBfuncs", + NULL +}; + +static const char *ramdacSymbols[] = +{ + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + "xf86CursorScreenIndex", + NULL +}; + +static const char *ddcSymbols[] = +{ + "xf86PrintEDID", + "xf86DoEDID_DDC1", + "xf86DoEDID_DDC2", + NULL +}; + +static const char *i2cSymbols[] = +{ + "xf86CreateI2CBusRec", + "xf86DestroyI2CBusRec", + "xf86I2CBusInit", + "xf86CreateI2CDevRec", + "xf86I2CWriteByte", + "xf86DestroyI2CDevRec", + NULL +}; + +static const char *shadowSymbols[] = +{ + "ShadowFBInit", + NULL +}; + +static const char *int10Symbols[] = +{ + "xf86InitInt10", + "xf86ExecX86int10", + "xf86FreeInt10", + NULL +}; + +static const char *vbeSymbols[] = +{ + "VBEInit", + "vbeDoEDID", + "vbeFree", + NULL +}; + +#ifdef XFree86LOADER + +static const char *cfbSymbols[] = +{ + "cfbScreenInit", + "cfb16ScreenInit", + "cfb24ScreenInit", + "cfb24_32ScreenInit", + "cfb32ScreenInit", + "cfb16BresS", + "cfb24BresS", + NULL +}; + +static MODULESETUPPROTO(siliconmotionSetup); + +static XF86ModuleVersionInfo SMIVersRec = +{ + "siliconmotion", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + SILICONMOTION_VERSION_MAJOR, + SILICONMOTION_VERSION_MINOR, + SILICONMOTION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * This is the module init data for XFree86 modules. + * + * Its name has to be the driver name followed by ModuleData. + */ +XF86ModuleData siliconmotionModuleData = +{ + &SMIVersRec, + siliconmotionSetup, + NULL +}; + +static pointer +siliconmotionSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) + { + setupDone = TRUE; + xf86AddDriver(&SILICONMOTION, module, 0); + + /* + * Modules that this driver always requires can be loaded here + * by calling LoadSubModule(). + */ + + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, ramdacSymbols, + ddcSymbols, i2cSymbols, int10Symbols, vbeSymbols, + shadowSymbols, NULL); + + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer) 1; + } + else + { + if (errmaj) + { + *errmaj = LDR_ONCEONLY; + } + return(NULL); + } +} + +#endif /* XFree86LOADER */ + +static Bool +SMI_GetRec(ScrnInfoPtr pScrn) +{ + ENTER_PROC("SMI_GetRec"); + + /* + * Allocate an 'Chip'Rec, and hook it into pScrn->driverPrivate. + * pScrn->driverPrivate is initialised to NULL, so we can check if + * the allocation has already been done. + */ + if (pScrn->driverPrivate == NULL) + { + pScrn->driverPrivate = xnfcalloc(sizeof(SMIRec), 1); + } + + LEAVE_PROC("SMI_GetRec"); + return(TRUE); +} + +static void +SMI_FreeRec(ScrnInfoPtr pScrn) +{ + ENTER_PROC("SMI_FreeRec"); + + if (pScrn->driverPrivate != NULL) + { + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; + } + + LEAVE_PROC("SMI_FreeRec"); +} + +static OptionInfoPtr +SMI_AvailableOptions(int chipid, int busid) +{ + ENTER_PROC("SMI_AvailableOptions"); + LEAVE_PROC("SMI_AvailableOptions"); + return(SMIOptions); +} + +static void +SMI_Identify(int flags) +{ + ENTER_PROC("SMI_Identify"); + + xf86PrintChipsets(SILICONMOTION_NAME, "driver (version " + SILICONMOTION_VERSION_NAME ") for Silicon Motion Lynx chipsets", + SMIChipsets); + + LEAVE_PROC("SMI_Identify"); +} + +static Bool +SMI_Probe(DriverPtr drv, int flags) +{ + int i; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool foundScreen = FALSE; + + ENTER_PROC("SMI_Probe"); + + numDevSections = xf86MatchDevice(SILICONMOTION_DRIVER_NAME, &devSections); + if (numDevSections <= 0) + { + /* There's no matching device section in the config file, so quit now. + */ + LEAVE_PROC("SMI_Probe"); + return(FALSE); + } + + if (xf86GetPciVideoInfo() == NULL) + { + LEAVE_PROC("SMI_Probe"); + return(FALSE); + } + + numUsed = xf86MatchPciInstances(SILICONMOTION_NAME, PCI_SMI_VENDOR_ID, + SMIChipsets, SMIPciChipsets, devSections, + numDevSections, drv, &usedChips); + + /* Free it since we don't need that list after this */ + xfree(devSections); + if (numUsed <= 0) + { + LEAVE_PROC("SMI_Probe"); + return(FALSE); + } + + if (flags & PROBE_DETECT) + { + foundScreen = TRUE; + } + else + { + for (i = 0; i < numUsed; i++) + { + /* Allocate a ScrnInfoRec and claim the slot */ + ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0); + + /* Fill in what we can of the ScrnInfoRec */ + pScrn->driverVersion = SILICONMOTION_DRIVER_VERSION; + pScrn->driverName = SILICONMOTION_DRIVER_NAME; + pScrn->name = SILICONMOTION_NAME; + pScrn->Probe = SMI_Probe; + pScrn->PreInit = SMI_PreInit; + pScrn->ScreenInit = SMI_ScreenInit; + pScrn->SwitchMode = SMI_SwitchMode; + pScrn->AdjustFrame = SMI_AdjustFrame; + pScrn->EnterVT = SMI_EnterVT; + pScrn->LeaveVT = SMI_LeaveVT; + pScrn->FreeScreen = SMI_FreeScreen; + pScrn->ValidMode = SMI_ValidMode; + foundScreen = TRUE; + + xf86ConfigActivePciEntity(pScrn, usedChips[i], SMIPciChipsets, NULL, + NULL, NULL, NULL, NULL); + } + } + xfree(usedChips); + + LEAVE_PROC("SMI_Probe"); + return(foundScreen); +} + +static Bool +SMI_PreInit(ScrnInfoPtr pScrn, int flags) +{ + EntityInfoPtr pEnt; + SMIPtr pSmi; + MessageType from; + int i; + double real; + ClockRangePtr clockRanges; + char *mod = NULL; + const char *reqSym = NULL; + char *s; + unsigned char config, m, n, shift; + int mclk; + vgaHWPtr hwp; + int vgaCRIndex, vgaCRReg, vgaIOBase; + + ENTER_PROC("SMI_PreInit"); + + if (flags & PROBE_DETECT) + { + SMI_ProbeDDC(pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index); + LEAVE_PROC("SMI_PreInit"); + return(TRUE); + } + + /* Ignoring the Type list for now. It might be needed when multiple cards + * are supported. + */ + if (pScrn->numEntities > 1) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* The vgahw module should be loaded here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* + * Allocate a vgaHWRec + */ + if (!vgaHWGetHWRec(pScrn)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* Allocate the SMIRec driverPrivate */ + if (!SMI_GetRec(pScrn)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + pSmi = SMIPTR(pScrn); + + /* Set pScrn->monitor */ + pScrn->monitor = pScrn->confScreen->monitor; + + /* + * The first thing we should figure out is the depth, bpp, etc. Our + * default depth is 8, so pass it to the helper function. We support + * only 24bpp layouts, so indicate that. + */ + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* Check that the returned depth is one we support */ + switch (pScrn->depth) + { + case 8: + case 16: + case 24: + /* OK */ + break; + + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + xf86PrintDepthBpp(pScrn); + + /* + * This must happen after pScrn->display has been set because + * xf86SetWeight references it. + */ + if (pScrn->depth > 8) + { + /* The defaults are OK for us */ + rgb zeros = {0, 0, 0}; + + if (!xf86SetWeight(pScrn, zeros, zeros)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + } + + if (!xf86SetDefaultVisual(pScrn, -1)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* We don't currently support DirectColor at > 8bpp */ + if ((pScrn->depth > 8) && (pScrn->defaultVisual != TrueColor)) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual (%s) " + "is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* We use a programamble clock */ + pScrn->progClock = TRUE; + + /* Collect all of the relevant option flags (fill in pScrn->options) */ + xf86CollectOptions(pScrn, NULL); + + /* Set the bits per RGB for 8bpp mode */ + if (pScrn->depth == 8) + { + pScrn->rgbBits = 6; + } + + /* Process the options */ + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, SMIOptions); + + if (xf86ReturnOptValBool(SMIOptions, OPTION_PCI_BURST, FALSE)) + { + pSmi->pci_burst = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: pci_burst - PCI burst " + "read enabled\n"); + } + else + { + pSmi->pci_burst = FALSE; + } + + pSmi->NoPCIRetry = TRUE; + if (xf86ReturnOptValBool(SMIOptions, OPTION_PCI_RETRY, FALSE)) + { + if (xf86ReturnOptValBool(SMIOptions, OPTION_PCI_BURST, FALSE)) + { + pSmi->NoPCIRetry = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: pci_retry\n"); + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"pci_retry\" option " + "requires \"pci_burst\".\n"); + } + } + + if (xf86IsOptionSet(SMIOptions, OPTION_FIFO_CONSERV)) + { + pSmi->fifo_conservative = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo_conservative " + "set\n"); + } + else + { + pSmi->fifo_conservative = FALSE; + } + + if (xf86IsOptionSet(SMIOptions, OPTION_FIFO_MODERATE)) + { + pSmi->fifo_moderate = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo_moderate set\n"); + } + else + { + pSmi->fifo_moderate = FALSE; + } + + if (xf86IsOptionSet(SMIOptions, OPTION_FIFO_AGGRESSIVE)) + { + pSmi->fifo_aggressive = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: fifo_aggressive set\n"); + } + else + { + pSmi->fifo_aggressive = FALSE; + } + + if (xf86ReturnOptValBool(SMIOptions, OPTION_NOACCEL, FALSE)) + { + pSmi->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: NoAccel - Acceleration " + "disabled\n"); + } + else + { + pSmi->NoAccel = FALSE; + } + + if (xf86ReturnOptValBool(SMIOptions, OPTION_SHOWCACHE, FALSE)) + { + pSmi->ShowCache = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: show_cache set\n"); + } + else + { + pSmi->ShowCache = FALSE; + } + + if (xf86GetOptValFreq(SMIOptions, OPTION_MCLK, OPTUNITS_MHZ, &real)) + { + pSmi->MCLK = (int)(real * 1000.0); + if (pSmi->MCLK <= 120000) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: set_mclk set to " + "%1.3f MHz\n", pSmi->MCLK / 1000.0); + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Memory Clock value of " + "%1.3f MHz is larger than limit of 120 MHz\n", + pSmi->MCLK / 1000.0); + pSmi->MCLK = 0; + } + } + else + { + pSmi->MCLK = 0; + } + + from = X_DEFAULT; + pSmi->hwcursor = TRUE; + if (xf86GetOptValBool(SMIOptions, OPTION_HWCURSOR, &pSmi->hwcursor)) + { + from = X_CONFIG; + } + if (xf86ReturnOptValBool(SMIOptions, OPTION_SWCURSOR, FALSE)) + { + pSmi->hwcursor = FALSE; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s Cursor\n", + pSmi->hwcursor ? "Hardware" : "Software"); + + if (xf86GetOptValBool(SMIOptions, OPTION_SHADOW_FB, &pSmi->shadowFB)) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShadowFB %s.\n", + pSmi->shadowFB ? "enabled" : "disabled"); + } + + if ((s = xf86GetOptValString(SMIOptions, OPTION_ROTATE))) + { + if(!xf86NameCmp(s, "CW")) + { + pSmi->shadowFB = TRUE; + pSmi->rotate = SMI_ROTATE_CCW; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen " + "clockwise\n"); + } + else if (!xf86NameCmp(s, "CCW")) + { + pSmi->shadowFB = TRUE; + pSmi->rotate = SMI_ROTATE_CW; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen counter " + "clockwise\n"); + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid " + "value for Option \"Rotate\"\n", s); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Valid options are \"CW\" or " + "\"CCW\"\n"); + } + } + +#ifdef XvExtension + if (xf86GetOptValInteger(SMIOptions, OPTION_VIDEOKEY, &pSmi->videoKey)) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: Video key set to " + "0x%08X\n", pSmi->videoKey); + } + else + { + pSmi->videoKey = (1 << pScrn->offset.red) | (1 << pScrn->offset.green) + | (((pScrn->mask.blue >> pScrn->offset.blue) - 1) + << pScrn->offset.blue); + } + + if (xf86ReturnOptValBool(SMIOptions, OPTION_BYTESWAP, FALSE)) + { + pSmi->ByteSwap = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: ByteSwap enabled.\n"); + } + else + { + pSmi->ByteSwap = FALSE; + } +#endif + + if (xf86GetOptValBool(SMIOptions, OPTION_USEBIOS, &pSmi->useBIOS)) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: UseBIOS %s.\n", + pSmi->useBIOS ? "enabled" : "disabled"); + } + else + { + /* Default to UseBIOS enabled. */ + pSmi->useBIOS = TRUE; + } + + /* Find the PCI slot for this screen */ + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + if ((pEnt->location.type != BUS_PCI) || (pEnt->resources)) + { + xfree(pEnt); + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + if (xf86LoadSubModule(pScrn, "int10")) + { + xf86LoaderReqSymLists(int10Symbols, NULL); + pSmi->pInt = xf86InitInt10(pEnt->index); + } + + if (xf86LoadSubModule(pScrn, "vbe")) + { + xf86LoaderReqSymLists(vbeSymbols, NULL); + pSmi->pVbe = VBEInit(NULL, pEnt->index); + } + + pSmi->PciInfo = xf86GetPciInfoForEntity(pEnt->index); + xf86RegisterResources(pEnt->index, NULL, ResExclusive); +/* xf86SetOperatingState(RES_SHARED_VGA, pEnt->index, ResUnusedOpr);*/ +/* xf86SetOperatingState(resVgaMemShared, pEnt->index, ResDisableOpr);*/ + + /* + * Set the Chipset and ChipRev, allowing config file entries to + * override. + */ + if (pEnt->device->chipset && *pEnt->device->chipset) + { + pScrn->chipset = pEnt->device->chipset; + pSmi->Chipset = xf86StringToToken(SMIChipsets, pScrn->chipset); + from = X_CONFIG; + } + else if (pEnt->device->chipID >= 0) + { + pSmi->Chipset = pEnt->device->chipID; + pScrn->chipset = (char *) xf86TokenToString(SMIChipsets, pSmi->Chipset); + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pSmi->Chipset); + } + else + { + from = X_PROBED; + pSmi->Chipset = pSmi->PciInfo->chipType; + pScrn->chipset = (char *) xf86TokenToString(SMIChipsets, pSmi->Chipset); + } + + if (pEnt->device->chipRev >= 0) + { + pSmi->ChipRev = pEnt->device->chipRev; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + pSmi->ChipRev); + } + else + { + pSmi->ChipRev = pSmi->PciInfo->chipRev; + } + xfree(pEnt); + + /* + * This shouldn't happen because such problems should be caught in + * SMI_Probe(), but check it just in case. + */ + if (pScrn->chipset == NULL) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ChipID 0x%04X is not " + "recognised\n", pSmi->Chipset); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + if (pSmi->Chipset < 0) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Chipset \"%s\" is not " + "recognised\n", pScrn->chipset); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); + + pSmi->PciTag = pciTag(pSmi->PciInfo->bus, pSmi->PciInfo->device, + pSmi->PciInfo->func); + + SMI_MapMem(pScrn); + hwp = VGAHWPTR(pScrn); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; + vgaCRReg = vgaIOBase + VGA_CRTC_DATA_OFFSET; + + xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, " + "MMIOBase=%x\n", vgaCRIndex, vgaIOBase, hwp->MMIOBase); + + /* Next go on to detect amount of installed ram */ + config = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x71); + + if (xf86LoadSubModule(pScrn, "i2c")) + { + xf86LoaderReqSymLists(i2cSymbols, NULL); + SMI_I2CInit(pScrn); + } + if (xf86LoadSubModule(pScrn, "ddc")) + { + xf86MonPtr pMon = NULL; + + xf86LoaderReqSymLists(ddcSymbols, NULL); +#if 1 /* PDR#579 */ + if (pSmi->pVbe) + { + pMon = vbeDoEDID(pSmi->pVbe, NULL); + if (pMon != NULL) + { + if ( (pMon->rawData[0] == 0x00) + && (pMon->rawData[1] == 0xFF) + && (pMon->rawData[2] == 0xFF) + && (pMon->rawData[3] == 0xFF) + && (pMon->rawData[4] == 0xFF) + && (pMon->rawData[5] == 0xFF) + && (pMon->rawData[6] == 0xFF) + && (pMon->rawData[7] == 0x00) + ) + { + pMon = xf86PrintEDID(pMon); + if (pMon != NULL) + { + xf86SetDDCproperties(pScrn, pMon); + } + } + } + } +#else + if ( (pSmi->pVbe) + && ((pMon = xf86PrintEDID(vbeDoEDID(pSmi->pVbe, NULL))) != NULL) + ) + { + xf86SetDDCproperties(pScrn, pMon); + } +#endif + else if (!SMI_ddc1(pScrn->scrnIndex)) + { + if (pSmi->I2C) + { + xf86SetDDCproperties(pScrn, + xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex, + pSmi->I2C))); + } + } + } + if (pSmi->pVbe) + { + vbeFree(pSmi->pVbe); + } + + /* + * If the driver can do gamma correction, it should call xf86SetGamma() + * here. (from MGA, no ViRGE gamma support yet, but needed for + * xf86HandleColormaps support.) + */ + { + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) + { + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + } + + /* And compute the amount of video memory and offscreen memory */ + pSmi->videoRAMKBytes = 0; + + if (!pScrn->videoRam) + { + switch (pSmi->Chipset) + { + default: + { + int mem_table[4] = { 1, 2, 4, 0 }; + pSmi->videoRAMKBytes = mem_table[(config >> 6)] * 1024; + break; + } + + case SMI_LYNX3D: + { + int mem_table[4] = { 0, 2, 4, 6 }; + pSmi->videoRAMKBytes = mem_table[(config >> 6)] * 1024 + 512; + break; + } + + case SMI_LYNX3DM: + { + int mem_table[4] = { 16, 2, 4, 8 }; + pSmi->videoRAMKBytes = mem_table[(config >> 6)] * 1024; + break; + } + } + pSmi->videoRAMBytes = pSmi->videoRAMKBytes * 1024; + pScrn->videoRam = pSmi->videoRAMKBytes; + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "videoram: %dkB\n", + pSmi->videoRAMKBytes); + } + else + { + pSmi->videoRAMKBytes = pScrn->videoRam; + pSmi->videoRAMBytes = pScrn->videoRam * 1024; + + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "videoram: %dk\n", + pSmi->videoRAMKBytes); + } + + /* Lynx built-in ramdac speeds */ + pScrn->numClocks = 4; + + if ((pScrn->clock[3] <= 0) && (pScrn->clock[2] > 0)) + { + pScrn->clock[3] = pScrn->clock[2]; + } + + if (pSmi->Chipset == SMI_LYNX3DM) + { + if (pScrn->clock[0] <= 0) pScrn->clock[0] = 200000; + if (pScrn->clock[1] <= 0) pScrn->clock[1] = 200000; + if (pScrn->clock[2] <= 0) pScrn->clock[2] = 200000; + if (pScrn->clock[3] <= 0) pScrn->clock[3] = 200000; + } + else + { + if (pScrn->clock[0] <= 0) pScrn->clock[0] = 135000; + if (pScrn->clock[1] <= 0) pScrn->clock[1] = 135000; + if (pScrn->clock[2] <= 0) pScrn->clock[2] = 135000; + if (pScrn->clock[3] <= 0) pScrn->clock[3] = 135000; + } + + /* Now set RAMDAC limits */ + switch (pSmi->Chipset) + { + default: + pSmi->minClock = 20000; + pSmi->maxClock = 135000; + break; + } + xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit minClock=%d, maxClock=%d\n", + pSmi->minClock, pSmi->maxClock); + + /* Detect current MCLK and print it for user */ + m = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); + n = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); + switch (n >> 6) + { + default: + shift = 1; + break; + + case 1: + shift = 4; + break; + + case 2: + shift = 2; + break; + } + n &= 0x3F; + mclk = ((1431818 * m) / n / shift + 50) / 100; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected current MCLK value of " + "%1.3f MHz\n", mclk / 1000.0); + + SMI_UnmapMem(pScrn); + + pScrn->virtualX = pScrn->display->virtualX; + + /* + * Setup the ClockRanges, which describe what clock ranges are available, + * and what sort of modes they can be used for. + */ + clockRanges = xnfalloc(sizeof(ClockRange)); + clockRanges->next = NULL; + clockRanges->minClock = pSmi->minClock; + clockRanges->maxClock = pSmi->maxClock; + clockRanges->clockIndex = -1; + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; + + + i = xf86ValidateModes( + pScrn, /* Screen pointer */ + pScrn->monitor->Modes, /* Available monitor modes */ + pScrn->display->modes, /* req mode names for screen */ + clockRanges, /* list of clock ranges allowed */ + NULL, /* use min/max below */ + 128, /* min line pitch (width) */ + 4096, /* maximum line pitch (width) */ + 128, /* bits of granularity for line pitch */ + /* (width) above */ + 128, /* min virtual height */ + 4096, /* max virtual height */ + pScrn->display->virtualX, /* force virtual x */ + pScrn->display->virtualY, /* force virtual Y */ + pSmi->videoRAMBytes, /* size of aperture used to access */ + /* video memory */ + LOOKUP_BEST_REFRESH); /* how to pick modes */ + + if (i == -1) + { + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + /* Prune the modes marked as invalid */ + xf86PruneDriverModes(pScrn); + + if ((i == 0) || (pScrn->modes == NULL)) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + xf86SetCrtcForModes(pScrn, 0); + + /* Set the current mode to the first in the list */ + pScrn->currentMode = pScrn->modes; + + /* Print the list of modes being used */ + xf86PrintModes(pScrn); + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + /* Load bpp-specific modules */ + switch (pScrn->bitsPerPixel) + { + case 8: + mod = "cfb"; + reqSym = "cfbScreenInit"; + break; + + case 16: + mod = "cfb16"; + reqSym = "cfb16ScreenInit"; + break; + + case 24: + mod = "cfb24"; + reqSym = "cfb24ScreenInit"; + break; + } + + if (mod && (xf86LoadSubModule(pScrn, mod) == NULL)) + { + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + + xf86LoaderReqSymbols(reqSym, NULL); + + /* Load XAA if needed */ + if (!pSmi->NoAccel || pSmi->hwcursor) + { + if (!xf86LoadSubModule(pScrn, "xaa")) + { + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + xf86LoaderReqSymLists(xaaSymbols, NULL); + } + + /* Load ramdac if needed */ + if (pSmi->hwcursor) + { + if (!xf86LoadSubModule(pScrn, "ramdac")) + { + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + } + + if (pSmi->shadowFB) + { + if (!xf86LoadSubModule(pScrn, "shadowfb")) + { + SMI_FreeRec(pScrn); + LEAVE_PROC("SMI_PreInit"); + return(FALSE); + } + xf86LoaderReqSymLists(shadowSymbols, NULL); + } + + LEAVE_PROC("SMI_PreInit"); + return(TRUE); +} + +/* + * This is called when VT switching back to the X server. Its job is to + * reinitialise the video mode. We may wish to unmap video/MMIO memory too. + */ + +static Bool +SMI_EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SMIPtr pSmi = SMIPTR(pScrn); + Bool ret; + + ENTER_PROC("SMI_EnterVT"); + + /* Enable MMIO and map memory */ + SMI_MapMem(pScrn); + SMI_Save(pScrn); + + /* #670 */ + if (pSmi->shadowFB) + { + pSmi->FBOffset = pSmi->savedFBOffset; + pSmi->FBReserved = pSmi->savedFBReserved; + } + + ret = SMI_ModeInit(pScrn, pScrn->currentMode); + + /* #670 */ + if (ret && pSmi->shadowFB) + { + BoxRec box; + + if (pSmi->pSaveBuffer) + { + memcpy(pSmi->FBBase, pSmi->pSaveBuffer, pSmi->saveBufferSize); + xfree(pSmi->pSaveBuffer); + pSmi->pSaveBuffer = NULL; + } + + box.x1 = 0; + box.y1 = 0; + box.x2 = pScrn->virtualY; + box.y2 = pScrn->virtualX; + SMI_RefreshArea(pScrn, 1, &box); + } + + LEAVE_PROC("SMI_EnterVT"); + return(ret); +} + +/* + * This is called when VT switching away from the X server. Its job is to + * restore the previous (text) mode. We may wish to remap video/MMIO memory + * too. + */ + +static void +SMI_LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SMIRegPtr SMISavePtr = &pSmi->SavedReg; + + ENTER_PROC("SMI_LeaveVT"); + + /* #670 */ + if (pSmi->shadowFB) + { + pSmi->pSaveBuffer = xnfalloc(pSmi->saveBufferSize); + if (pSmi->pSaveBuffer) + { + memcpy(pSmi->pSaveBuffer, pSmi->FBBase, pSmi->saveBufferSize); + } + + pSmi->savedFBOffset = pSmi->FBOffset; + pSmi->savedFBReserved = pSmi->FBReserved; + } + + memset(pSmi->FBBase, 0, 256 * 1024); /* #689 */ + SMI_WriteMode(pScrn, vgaSavePtr, SMISavePtr); + SMI_UnmapMem(pScrn); + + LEAVE_PROC("SMI_LeaveVT"); +} + +/* + * This function performs the inverse of the restore function: It saves all the + * standard and extended registers that we are going to modify to set up a video + * mode. + */ + +static void +SMI_Save(ScrnInfoPtr pScrn) +{ + int i; + CARD32 offset; + + vgaHWPtr hwp = VGAHWPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SMIPtr pSmi = SMIPTR(pScrn); + SMIRegPtr save = &pSmi->SavedReg; + + int vgaIOBase = hwp->IOBase; + int vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; + int vgaCRData = vgaIOBase + VGA_CRTC_DATA_OFFSET; + + ENTER_PROC("SMI_Save"); + + /* Save the standard VGA registers */ + vgaHWSave(pScrn, vgaSavePtr, VGA_SR_MODE); + save->smiDACMask = VGAIN8(pSmi, VGA_DAC_MASK); + VGAOUT8(pSmi, VGA_DAC_READ_ADDR, 0); + for (i = 0; i < 256; i++) + { + save->smiDacRegs[i][0] = VGAIN8(pSmi, VGA_DAC_DATA); + save->smiDacRegs[i][1] = VGAIN8(pSmi, VGA_DAC_DATA); + save->smiDacRegs[i][2] = VGAIN8(pSmi, VGA_DAC_DATA); + } + for (i = 0, offset = 2; i < 8192; i++, offset += 8) + { + save->smiFont[i] = *(pSmi->FBBase + offset); + } + + /* Now we save all the extended registers we need. */ + save->SR17 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17); + save->SR18 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18); + save->SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + save->SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31); + save->SR32 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32); + save->SR6A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A); + save->SR6B = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B); + save->SR81 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + save->SRA0 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0); + + if (SMI_LYNXM_SERIES(pSmi->Chipset)) + { + /* Save primary registers */ + save->CR90[14] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E); + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, + save->CR90[14] & ~0x20); + + for (i = 0; i < 16; i++) + { + save->CR90[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i); + } + save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); + for (i = 0; i < 14; i++) + { + save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + } + + /* Save secondary registers */ + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14] | 0x20); + save->CR33_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + for (i = 0; i < 14; i++) + { + save->CR40_2[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, + 0x40 + i); + } + save->CR9F_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F); + + /* Save common registers */ + for (i = 0; i < 14; i++) + { + save->CRA0[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i); + } + } + else + { + save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33); + save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A); + for (i = 0; i < 14; i++) + { + save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i); + } + } + + save->DPR10 = READ_DPR(pSmi, 0x10); + save->DPR1C = READ_DPR(pSmi, 0x1C); + save->DPR20 = READ_DPR(pSmi, 0x20); + save->DPR24 = READ_DPR(pSmi, 0x24); + save->DPR28 = READ_DPR(pSmi, 0x28); + save->DPR2C = READ_DPR(pSmi, 0x2C); + save->DPR30 = READ_DPR(pSmi, 0x30); + save->DPR3C = READ_DPR(pSmi, 0x3C); + save->DPR40 = READ_DPR(pSmi, 0x40); + save->DPR44 = READ_DPR(pSmi, 0x44); + + save->VPR00 = READ_VPR(pSmi, 0x00); + save->VPR0C = READ_VPR(pSmi, 0x0C); + save->VPR10 = READ_VPR(pSmi, 0x10); + + save->CPR00 = READ_CPR(pSmi, 0x00); + + if (!pSmi->ModeStructInit) + { + /* XXX Should check the return value of vgaHWCopyReg() */ + vgaHWCopyReg(&hwp->ModeReg, vgaSavePtr); + memcpy(&pSmi->ModeReg, save, sizeof(SMIRegRec)); + pSmi->ModeStructInit = TRUE; + } + + if (pSmi->useBIOS && (pSmi->pInt != NULL)) + { + pSmi->pInt->num = 0x10; + pSmi->pInt->ax = 0x0F00; + xf86ExecX86int10(pSmi->pInt); + save->mode = pSmi->pInt->ax & 0x007F; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Current mode 0x%02X.\n", + save->mode); + } + + if (xf86GetVerbosity() > 1) + { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Saved current video mode. Register dump:\n"); + SMI_PrintRegs(pScrn); + } + + LEAVE_PROC("SMI_Save"); +} + +/* + * This function is used to restore a video mode. It writes out all of the + * standard VGA and extended registers needed to setup a video mode. + */ + +static void +SMI_WriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, SMIRegPtr restore) +{ + int i; + CARD8 tmp; + CARD32 offset; + + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + int vgaIOBase = hwp->IOBase; + int vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; + int vgaCRData = vgaIOBase + VGA_CRTC_DATA_OFFSET; + + ENTER_PROC("SMI_WriteMode"); + + vgaHWProtect(pScrn, TRUE); + + /* Wait for engine to become idle */ + WaitIdle(); + + if (pSmi->useBIOS && (pSmi->pInt != NULL) && (restore->mode != 0)) + { + pSmi->pInt->num = 0x10; + pSmi->pInt->ax = restore->mode | 0x80; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting mode 0x%02X\n", + restore->mode); + xf86ExecX86int10(pSmi->pInt); + + /* Enable linear mode. */ + outb(VGA_SEQ_INDEX, 0x18); + tmp = inb(VGA_SEQ_DATA); + outb(VGA_SEQ_DATA, tmp | 0x01); + + /* Enable DPR/VPR registers. */ + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, tmp & ~0x03); + } + else + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17, restore->SR17); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18) & ~0x1F; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18, tmp | + (restore->SR18 & 0x1F)); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, tmp & ~0x03); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31) & ~0xC0; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31, tmp | + (restore->SR31 & 0xC0)); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32) & ~0x07; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32, tmp | + (restore->SR32 & 0x07)); + if (restore->SR6B != 0xFF) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A, + restore->SR6A); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B, + restore->SR6B); + } + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, restore->SR81); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0, restore->SRA0); + + /* Restore the standard VGA registers */ + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_MODE); + if (restore->smiDACMask) + { + VGAOUT8(pSmi, VGA_DAC_MASK, restore->smiDACMask); + } + else + { + VGAOUT8(pSmi, VGA_DAC_MASK, 0xFF); + } + VGAOUT8(pSmi, VGA_DAC_WRITE_ADDR, 0); + for (i = 0; i < 256; i++) + { + VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][0]); + VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][1]); + VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][2]); + } + for (i = 0, offset = 2; i < 8192; i++, offset += 8) + { + *(pSmi->FBBase + offset) = restore->smiFont[i]; + } + + if (SMI_LYNXM_SERIES(pSmi->Chipset)) + { + /* Restore secondary registers */ + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, + restore->CR90[14] | 0x20); + + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33_2); + for (i = 0; i < 14; i++) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i, + restore->CR40_2[i]); + } + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F, restore->CR9F_2); + + /* Restore primary registers */ + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, + restore->CR90[14] & ~0x20); + + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33_2); + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A, restore->CR3A); + for (i = 0; i < 14; i++) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i, + restore->CR40[i]); + } + for (i = 0; i < 16; i++) + { + if (i != 14) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i, + restore->CR90[i]); + } + } + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, restore->CR90[14]); + + /* Restore common registers */ + for (i = 0; i < 14; i++) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i, + restore->CRA0[i]); + } + } + + /* Restore the standard VGA registers */ + if (xf86IsPrimaryPci(pSmi->PciInfo)) + { + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_ALL); + } + else + { + vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_MODE); + } + + if (!SMI_LYNXM_SERIES(pSmi->Chipset)) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33); + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A, restore->CR3A); + for (i = 0; i < 14; i++) + { + VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i, + restore->CR40[i]); + } + } + } + + WRITE_DPR(pSmi, 0x10, restore->DPR10); + WRITE_DPR(pSmi, 0x1C, restore->DPR1C); + WRITE_DPR(pSmi, 0x20, restore->DPR20); + WRITE_DPR(pSmi, 0x24, restore->DPR24); + WRITE_DPR(pSmi, 0x28, restore->DPR28); + WRITE_DPR(pSmi, 0x2C, restore->DPR2C); + WRITE_DPR(pSmi, 0x30, restore->DPR30); + WRITE_DPR(pSmi, 0x3C, restore->DPR3C); + WRITE_DPR(pSmi, 0x40, restore->DPR40); + WRITE_DPR(pSmi, 0x44, restore->DPR44); + + WRITE_VPR(pSmi, 0x00, restore->VPR00); + WRITE_VPR(pSmi, 0x0C, restore->VPR0C); + WRITE_VPR(pSmi, 0x10, restore->VPR10); + + WRITE_CPR(pSmi, 0x00, restore->CPR00); + + if (xf86GetVerbosity() > 1) + { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Done restoring mode. Register dump:\n"); + SMI_PrintRegs(pScrn); + } + + vgaHWProtect(pScrn, FALSE); + + LEAVE_PROC("SMI_WriteMode"); +} + +static Bool +SMI_MapMem(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + vgaHWPtr hwp; + CARD32 memBase; + + ENTER_PROC("SMI_MapMem"); + + /* Map the Lynx register space */ + switch (pSmi->Chipset) + { + default: + memBase = pSmi->PciInfo->memBase[0] + 0x400000; + pSmi->MapSize = 0x10000; + break; + + case SMI_LYNX3D: + memBase = pSmi->PciInfo->memBase[0] + 0x680000; + pSmi->MapSize = 0x180000; + break; + + case SMI_LYNXEM: + case SMI_LYNXEMplus: + memBase = pSmi->PciInfo->memBase[0] + 0x400000; + pSmi->MapSize = 0x400000; + break; + + case SMI_LYNX3DM: + memBase = pSmi->PciInfo->memBase[0]; + pSmi->MapSize = 0x200000; + break; + } + pSmi->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pSmi->PciTag, + memBase, pSmi->MapSize); + + if (pSmi->MapBase == NULL) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: could not map " + "MMIO registers.\n"); + LEAVE_PROC("SMI_MapMem"); + return(FALSE); + } + + switch (pSmi->Chipset) + { + default: + pSmi->DPRBase = pSmi->MapBase + 0x8000; + pSmi->VPRBase = pSmi->MapBase + 0xC000; + pSmi->CPRBase = pSmi->MapBase + 0xE000; + pSmi->IOBase = NULL; + pSmi->DataPortBase = pSmi->MapBase; + pSmi->DataPortSize = 0x8000; + break; + + case SMI_LYNX3D: + pSmi->DPRBase = pSmi->MapBase + 0x000000; + pSmi->VPRBase = pSmi->MapBase + 0x000800; + pSmi->CPRBase = pSmi->MapBase + 0x001000; + pSmi->IOBase = pSmi->MapBase + 0x040000; + pSmi->DataPortBase = pSmi->MapBase + 0x080000; + pSmi->DataPortSize = 0x100000; + break; + + case SMI_LYNXEM: + case SMI_LYNXEMplus: + pSmi->DPRBase = pSmi->MapBase + 0x008000; + pSmi->VPRBase = pSmi->MapBase + 0x00C000; + pSmi->CPRBase = pSmi->MapBase + 0x00E000; + pSmi->IOBase = pSmi->MapBase + 0x300000; + pSmi->DataPortBase = pSmi->MapBase /*+ 0x100000*/; + pSmi->DataPortSize = 0x8000 /*0x200000*/; + break; + + case SMI_LYNX3DM: + pSmi->DPRBase = pSmi->MapBase + 0x000000; + pSmi->VPRBase = pSmi->MapBase + 0x000800; + pSmi->CPRBase = pSmi->MapBase + 0x001000; + pSmi->IOBase = pSmi->MapBase + 0x0C0000; + pSmi->DataPortBase = pSmi->MapBase + 0x100000; + pSmi->DataPortSize = 0x100000; + break; + } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Physical MMIO at 0x%08X\n", memBase); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Logical MMIO at 0x%08X - 0x%08X\n", pSmi->MapBase, + pSmi->MapBase + pSmi->MapSize - 1); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "DPR=0x%08X, VPR=0x%08X, IOBase=0x%08X\n", pSmi->DPRBase, + pSmi->VPRBase, pSmi->IOBase); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "DataPort=0x%08X - 0x%08X\n", pSmi->DataPortBase, + pSmi->DataPortBase + pSmi->DataPortSize - 1); + + /* Map the frame buffer */ + if (pSmi->Chipset == SMI_LYNX3DM) + { + pScrn->memPhysBase = pSmi->PciInfo->memBase[0] + 0x200000; + } + else + { + pScrn->memPhysBase = pSmi->PciInfo->memBase[0]; + } + if (pSmi->videoRAMBytes) + { + pSmi->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, + pSmi->PciTag, pScrn->memPhysBase, pSmi->videoRAMBytes); + + if (pSmi->FBBase == NULL) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: could not " + "map framebuffer.\n"); + LEAVE_PROC("SMI_MapMem"); + return(FALSE); + } + } + pSmi->FBOffset = pScrn->fbOffset = 0; + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Physical frame buffer at 0x%08X\n", pScrn->memPhysBase); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "Logical frame buffer at 0x%08X - 0x%08X\n", pSmi->FBBase, + pSmi->FBBase + pSmi->videoRAMBytes - 1); + + SMI_EnableMmio(pScrn); + + /* Set up offset to hwcursor memory area. It's a 1K chunk at the end of + * the frame buffer. Also set up the reserved memory space. + */ + pSmi->FBCursorOffset = pSmi->videoRAMBytes - 1024; + if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_INDEX, 0x30) & 0x01) + { + CARD32 fifiOffset = 0; + fifiOffset |= VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x46) + << 3; + fifiOffset |= VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x47) + << 11; + fifiOffset |= (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x49) + & 0x1C) << 17; + pSmi->FBReserved = pSmi->videoRAMBytes - fifiOffset; + } + else + { + pSmi->FBReserved = pSmi->videoRAMBytes - 2048; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Cursor Offset: %08X Reserved: %08X\n", + pSmi->FBCursorOffset, pSmi->FBReserved); + + pSmi->lcd = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31) & 0x01; + if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x01) + { + pSmi->lcd <<= 1; + } + switch (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x0C) + { + case 0x00: + pSmi->lcdWidth = 640; + pSmi->lcdHeight = 480; + break; + + case 0x04: + pSmi->lcdWidth = 800; + pSmi->lcdHeight = 600; + break; + + case 0x08: + if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x74) & 0x02) + { + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 600; + } + else + { + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 768; + } + break; + + case 0x0C: + pSmi->lcdWidth = 1280; + pSmi->lcdHeight = 1024; + break; + } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "%s Panel Size = %dx%d\n", + (pSmi->lcd == 0) ? "OFF" : (pSmi->lcd == 1) ? "TFT" : "DSTN", + pSmi->lcdWidth, pSmi->lcdHeight); + + /* Assign hwp->MemBase & IOBase here */ + hwp = VGAHWPTR(pScrn); + if (pSmi->IOBase != NULL) + { + vgaHWSetMmioFuncs(hwp, pSmi->MapBase, pSmi->IOBase - pSmi->MapBase); + } + vgaHWGetIOBase(hwp); + + /* Map the VGA memory when the primary video */ + if (xf86IsPrimaryPci(pSmi->PciInfo)) + { + hwp->MapSize = 0x10000; + if (!vgaHWMapMem(pScrn)) + { + LEAVE_PROC("SMI_MapMem"); + return(FALSE); + } + pSmi->PrimaryVidMapped = TRUE; + } + + LEAVE_PROC("SMI_MapMem"); + return(TRUE); +} + +/* UnMapMem - contains half of pre-4.0 EnterLeave function. The EnterLeave + * function which en/disable access to IO ports and ext. regs + */ + +static void +SMI_UnmapMem(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_UnmapMem"); + + /* Unmap VGA mem if mapped. */ + if (pSmi->PrimaryVidMapped) + { + vgaHWUnmapMem(pScrn); + pSmi->PrimaryVidMapped = FALSE; + } + + SMI_DisableMmio(pScrn); + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pSmi->MapBase, pSmi->MapSize); + if (pSmi->FBBase != NULL) + { + xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pSmi->FBBase, + pSmi->videoRAMBytes); + } + + LEAVE_PROC("SMI_UnmapMem"); +} + +/* This gets called at the start of each server generation. */ + +static Bool +SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_ScreenInit"); + + /* Map MMIO regs and framebuffer */ + if (!SMI_MapMem(pScrn)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + + /* Save the chip/graphics state */ + SMI_Save(pScrn); + + /* Zero the frame buffer, #258 */ + memset(pSmi->FBBase, 0, pSmi->videoRAMBytes); + + /* Initialize the first mode */ + if (!SMI_ModeInit(pScrn, pScrn->currentMode)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + + /* + * The next step is to setup the screen's visuals, and initialise the + * framebuffer code. In cases where the framebuffer's default choises for + * things like visual layouts and bits per RGB are OK, this may be as simple + * as calling the framebuffer's ScreenInit() function. If not, the visuals + * will need to be setup before calling a fb ScreenInit() function and fixed + * up after. + * + * For most PC hardware at depths >= 8, the defaults that cfb uses are not + * appropriate. In this driver, we fixup the visuals after. + */ + + /* + * Reset the visual list. + */ + miClearVisualTypes(); + + /* Setup the visuals we support. */ + + /* + * For bpp > 8, the default visuals are not acceptable because we only + * support TrueColor and not DirectColor. To deal with this, call + * miSetVisualTypes with the appropriate visual mask. + */ + + if (pScrn->bitsPerPixel > 8) + { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + pScrn->defaultVisual)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + } + else + { + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, + pScrn->defaultVisual)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + } + + if (!SMI_InternalScreenInit(scrnIndex, pScreen)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + + xf86SetBlackWhitePixels(pScreen); + + if (pScrn->bitsPerPixel > 8) + { + VisualPtr visual; + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) + { + if ((visual->class | DynamicClass) == DirectColor) + { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + /* Initialize acceleration layer */ + if (!pSmi->NoAccel) + { + if (!SMI_AccelInit(pScreen)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + } + miInitializeBackingStore(pScreen); + + /* hardware cursor needs to wrap this layer */ + SMI_DGAInit(pScreen); + + /* Initialise cursor functions */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* Initialize HW cursor layer. Must follow software cursor + * initialization. + */ + if (pSmi->hwcursor) + { + if (!SMI_HWCursorInit(pScreen)) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Hardware cursor " + "initialization failed\n"); + } + } + + if (pSmi->shadowFB) + { + RefreshAreaFuncPtr refreshArea = SMI_RefreshArea; + + if (pSmi->rotate) + { + if (pSmi->PointerMoved == NULL) + { + pSmi->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = SMI_PointerMoved; + } + } + + ShadowFBInit(pScreen, refreshArea); + } + + /* Initialise default colormap */ + if (!miCreateDefColormap(pScreen)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + + /* Initialize colormap layer. Must follow initialization of the default + * colormap. And SetGamma call, else it will load palette with solid white. + */ + if (!xf86HandleColormaps(pScreen, 256, 6, SMI_LoadPalette, NULL, + CMAP_RELOAD_ON_MODE_SWITCH)) + { + LEAVE_PROC("SMI_ScreenInit"); + return(FALSE); + } + + pScreen->SaveScreen = SMI_SaveScreen; + pSmi->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = SMI_CloseScreen; + +#ifdef DPMSExtension + if (!xf86DPMSInit(pScreen, SMI_DisplayPowerManagementSet, 0)) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DPMS initialization failed!\n"); + } +#endif + + SMI_InitVideo(pScreen); + + /* Report any unused options (only for the first generation) */ + if (serverGeneration == 1) + { + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + } + + LEAVE_PROC("SMI_ScreenInit"); + return(TRUE); +} + +/* Common init routines needed in EnterVT and ScreenInit */ + +static int +SMI_InternalScreenInit(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + int width, height, displayWidth; + int bytesPerPixel = pScrn->bitsPerPixel / 8; + int xDpi, yDpi; + int ret; + + ENTER_PROC("SMI_InternalScreenInit"); + + if (pSmi->rotate) + { + width = pScrn->virtualY; + height = pScrn->virtualX; + xDpi = pScrn->yDpi; + yDpi = pScrn->xDpi; + displayWidth = ((width * bytesPerPixel + 15) & ~15) / bytesPerPixel; + } + else + { + width = pScrn->virtualX; + height = pScrn->virtualY; + xDpi = pScrn->xDpi; + yDpi = pScrn->yDpi; + displayWidth = pScrn->displayWidth; + } + + if (pSmi->shadowFB) + { + pSmi->ShadowWidth = width; + pSmi->ShadowHeight = height; + pSmi->ShadowWidthBytes = (width * bytesPerPixel + 15) & ~15; + if (bytesPerPixel == 3) + { + pSmi->ShadowPitch = ((height * 3) << 16) + | pSmi->ShadowWidthBytes; + } + else + { + pSmi->ShadowPitch = (height << 16) + | (pSmi->ShadowWidthBytes / bytesPerPixel); + } + + pSmi->saveBufferSize = pSmi->ShadowWidthBytes * pSmi->ShadowHeight; + pSmi->FBReserved -= pSmi->saveBufferSize; + pSmi->FBReserved &= ~0x15; + WRITE_VPR(pSmi, 0x0C, (pSmi->FBOffset = pSmi->FBReserved) >> 3); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Shadow: width=%d height=%d " + "offset=0x%08X pitch=0x%08X\n", pSmi->ShadowWidth, + pSmi->ShadowHeight, pSmi->FBOffset, pSmi->ShadowPitch); + } + else + { + pSmi->FBOffset = 0; + } + + /* + * Call the framebuffer layer's ScreenInit function, and fill in other + * pScreen fields. + */ + + DEBUG((VERBLEV, "\tInitializing FB @ 0x%08X for %dx%d (%d)\n", + pSmi->FBBase, width, height, displayWidth)); + switch (pScrn->bitsPerPixel) + { + case 8: + ret = cfbScreenInit(pScreen, pSmi->FBBase, width, height, xDpi, + yDpi, displayWidth); + break; + + case 16: + ret = cfb16ScreenInit(pScreen, pSmi->FBBase, width, height, xDpi, + yDpi, displayWidth); + break; + + case 24: + ret = cfb24ScreenInit(pScreen, pSmi->FBBase, width, height, xDpi, + yDpi, displayWidth); + break; + + default: + xf86DrvMsg(scrnIndex, X_ERROR, "Internal error: invalid bpp (%d) " + "in SMI_InternalScreenInit\n", pScrn->bitsPerPixel); + LEAVE_PROC("SMI_InternalScreenInit"); + return(FALSE); + } + + LEAVE_PROC("SMI_InternalScreenInit"); + return(ret); +} + +/* Checks if a mode is suitable for the selected configuration. */ +static ModeStatus +SMI_ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_ValidMode"); + + xf86DrvMsg(scrnIndex, X_INFO, "Mode: %dx%d %d-bpp, %fHz\n", mode->HDisplay, + mode->VDisplay, pScrn->bitsPerPixel, mode->VRefresh); + + if (pSmi->shadowFB) + { + int mem; + + if (pScrn->bitsPerPixel == 24) + { + LEAVE_PROC("SMI_ValidMode"); + return(MODE_BAD); + } + + mem = (pScrn->virtualX * pScrn->bitsPerPixel / 8 + 15) & ~15; + mem *= pScrn->virtualY * 2; + + if (mem > pSmi->videoRAMBytes - pSmi->FBReserved) + { + LEAVE_PROC("SMI_ValidMode"); + return(MODE_MEM); + } + } + + if (!pSmi->useBIOS || pSmi->lcd) + { + if ( (mode->HDisplay != pSmi->lcdWidth) + || (mode->VDisplay != pSmi->lcdHeight) + ) + { + LEAVE_PROC("SMI_ValidMode"); + return(MODE_PANEL); + } + + if (pSmi->rotate) + { + if ( (mode->HDisplay > pSmi->lcdWidth) + || (mode->VDisplay > pSmi->lcdHeight) + ) + { + LEAVE_PROC("SMI_ValidMode"); + return(MODE_PANEL); + } + } + } + + LEAVE_PROC("SMI_ValidMode"); + return(MODE_OK); +} + +static Bool +SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + unsigned char tmp; + int panelIndex, modeIndex, i; + int xyAddress[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 }; + CARD32 DEDataFormat = 0; + + /* Store values to current mode register structs */ + SMIRegPtr new = &pSmi->ModeReg; + vgaRegPtr vganew = &hwp->ModeReg; + + ENTER_PROC("SMI_ModeInit"); + + if(!vgaHWInit(pScrn, mode)) + { + LEAVE_PROC("SMI_ModeInit"); + return(FALSE); + } + + if (pSmi->rotate) + { + pSmi->width = pScrn->virtualY; + pSmi->height = pScrn->virtualX; + } + else + { + pSmi->width = pScrn->virtualX; + pSmi->height = pScrn->virtualY; + } + pSmi->Bpp = pScrn->bitsPerPixel / 8; + + outb(VGA_SEQ_INDEX, 0x17); + tmp = inb(VGA_SEQ_DATA); + if (pSmi->pci_burst) + { + new->SR17 = tmp | 0x20; + } + else + { + new->SR17 = tmp & ~0x20; + } + + outb(VGA_SEQ_INDEX, 0x18); + new->SR18 = inb(VGA_SEQ_DATA) | 0x11; + + outb(VGA_SEQ_INDEX, 0x21); + new->SR21 = inb(VGA_SEQ_DATA) & ~0x03; + + outb(VGA_SEQ_INDEX, 0x31); + new->SR31 = inb(VGA_SEQ_DATA) & ~0xC0; + + outb(VGA_SEQ_INDEX, 0x32); + new->SR32 = inb(VGA_SEQ_DATA) & ~0x07; + if (SMI_LYNXM_SERIES(pSmi->Chipset)) + { + new->SR32 |= 0x04; + } + + new->SRA0 = new->CR33 = new->CR3A = 0x00; + + if (pSmi->lcdWidth == 640) + { + panelIndex = 0; + } + else if (pSmi->lcdWidth == 800) + { + panelIndex = 1; + } + else + { + panelIndex = 2; + } + + if (mode->HDisplay == 640) + { + modeIndex = 0; + } + else if (mode->HDisplay == 800) + { + modeIndex = 1; + } + else + { + modeIndex = 2; + } + + if (SMI_LYNXM_SERIES(pSmi->Chipset)) + { + static unsigned char PanelTable[3][14] = + { + { 0x5F, 0x4F, 0x00, 0x52, 0x1E, 0x0B, 0xDF, 0x00, 0xE9, 0x0B, 0x2E, + 0x00, 0x4F, 0xDF }, + { 0x7F, 0x63, 0x00, 0x69, 0x19, 0x72, 0x57, 0x00, 0x58, 0x0C, 0xA2, + 0x20, 0x4F, 0xDF }, + { 0xA3, 0x7F, 0x00, 0x83, 0x14, 0x24, 0xFF, 0x00, 0x02, 0x08, 0xA7, + 0xE0, 0x4F, 0xDF }, + }; + + for (i = 0; i < 14; i++) + { + new->CR40[i] = PanelTable[panelIndex][i]; + } + new->CR90[14] = 0x03; + new->CR90[15] = 0x00; + if (mode->VDisplay < pSmi->lcdHeight) + { + new->CRA0[6] = (pSmi->lcdHeight - mode->VDisplay) / 8; + } + else + { + new->CRA0[6] = 0; + } + + if (mode->HDisplay < pSmi->lcdWidth) + { + new->CRA0[7] = (pSmi->lcdWidth - mode->HDisplay) / 16; + } + else + { + new->CRA0[7] = 0; + } + } + else + { + static unsigned char PanelTable[3][3][14] = + { + { /* 640x480 panel */ + { 0x5F, 0x4F, 0x00, 0x53, 0x00, 0x0B, 0xDF, 0x00, 0xEA, 0x0C, + 0x2E, 0x00, 0x4F, 0xDF }, + { 0x5F, 0x4F, 0x00, 0x53, 0x00, 0x0B, 0xDF, 0x00, 0xEA, 0x0C, + 0x2E, 0x00, 0x4F, 0xDF }, + { 0x5F, 0x4F, 0x00, 0x53, 0x00, 0x0B, 0xDF, 0x00, 0xEA, 0x0C, + 0x2E, 0x00, 0x4F, 0xDF }, + }, + { /* 800x600 panel */ + { 0x7F, 0x59, 0x19, 0x5E, 0x8E, 0x72, 0x1C, 0x37, 0x1D, 0x00, + 0xA2, 0x20, 0x4F, 0xDF }, + { 0x7F, 0x63, 0x00, 0x68, 0x18, 0x72, 0x58, 0x00, 0x59, 0x0C, + 0xE0, 0x20, 0x63, 0x57 }, + { 0x7F, 0x63, 0x00, 0x68, 0x18, 0x72, 0x58, 0x00, 0x59, 0x0C, + 0xE0, 0x20, 0x63, 0x57 }, + }, + { /* 1024x768 panel */ + { 0xA3, 0x67, 0x0F, 0x6D, 0x1D, 0x24, 0x70, 0x95, 0x72, 0x07, + 0xA3, 0x20, 0x4F, 0xDF }, + { 0xA3, 0x71, 0x19, 0x77, 0x07, 0x24, 0xAC, 0xD1, 0xAE, 0x03, + 0xE1, 0x20, 0x63, 0x57 }, + { 0xA3, 0x7F, 0x00, 0x85, 0x15, 0x24, 0xFF, 0x00, 0x01, 0x07, + 0xE5, 0x20, 0x7F, 0xFF }, + }, + }; + + for (i = 0; i < 14; i++) + { + new->CR40[i] = PanelTable[panelIndex][modeIndex][i]; + } + } + + outb(VGA_SEQ_INDEX, 0x30); + if (inb(VGA_SEQ_DATA) & 0x01) + { + new->SR21 = 0x00; + } + + if (pSmi->MCLK > 0) + { + SMI_CommonCalcClock(pSmi->MCLK, 1, 1, 31, 0, 2, pSmi->minClock, + pSmi->maxClock, &new->SR6A, &new->SR6B); + } + else + { + new->SR6B = 0xFF; + } + + if ((mode->HDisplay == 640) && SMI_LYNXM_SERIES(pSmi->Chipset)) + { + vganew->MiscOutReg &= ~0x0C; + } + else + { + vganew->MiscOutReg |= 0x0C; + } + vganew->MiscOutReg |= 0xE0; + if (mode->HDisplay == 800) + { + vganew->MiscOutReg &= ~0xC0; + } + if ((mode->HDisplay == 1024) && SMI_LYNXM_SERIES(pSmi->Chipset)) + { + vganew->MiscOutReg &= ~0xC0; + } + + /* Set DPR registers */ + pSmi->Stride = (pSmi->width * pSmi->Bpp + 15) & ~15; + switch (pScrn->bitsPerPixel) + { + case 8: + DEDataFormat = 0x00000000; + break; + + case 16: + pSmi->Stride >>= 1; + DEDataFormat = 0x00100000; + break; + + case 24: + DEDataFormat = 0x00300000; + break; + + case 32: + pSmi->Stride >>= 2; + DEDataFormat = 0x00200000; + break; + } + for (i = 0; i < sizeof(xyAddress) / sizeof(xyAddress[0]); i++) + { + if (pSmi->rotate) + { + if (xyAddress[i] == pSmi->height) + { + DEDataFormat |= i << 16; + break; + } + } + else + { + if (xyAddress[i] == pSmi->width) + { + DEDataFormat |= i << 16; + break; + } + } + } + new->DPR10 = (pSmi->Stride << 16) | pSmi->Stride; + new->DPR1C = DEDataFormat; + new->DPR20 = 0; + new->DPR24 = 0xFFFFFFFF; + new->DPR28 = 0xFFFFFFFF; + new->DPR2C = 0; + new->DPR30 = 0; + new->DPR3C = (pSmi->Stride << 16) | pSmi->Stride; + new->DPR40 = 0; + new->DPR44 = 0; + + /* Set VPR registers */ + switch (pScrn->bitsPerPixel) + { + case 8: + new->VPR00 = 0x00000000; + break; + + case 16: + new->VPR00 = 0x00020000; + break; + + case 24: + new->VPR00 = 0x00040000; + break; + + case 32: + new->VPR00 = 0x00030000; + break; + } + new->VPR0C = pSmi->FBOffset >> 3; + if (pSmi->rotate) + { + new->VPR10 = ((((min(pSmi->lcdWidth, pSmi->height) * pSmi->Bpp) >> 3) + + 2) << 16) | ((pSmi->height * pSmi->Bpp) >> 3); + } + else + { + new->VPR10 = ((((min(pSmi->lcdWidth, pSmi->width) * pSmi->Bpp) >> 3) + + 2) << 16) | ((pSmi->width * pSmi->Bpp) >> 3); + } + + /* Set CPR registers */ + new->CPR00 = 0x00000000; + + pScrn->vtSema = TRUE; + + /* Find the INT 10 mode number */ + { + static struct + { + int x, y, bpp; + CARD16 mode; + + } modeTable[] = + { + { 640, 480, 8, 0x50 }, + { 640, 480, 16, 0x52 }, + { 640, 480, 24, 0x53 }, + { 640, 480, 32, 0x54 }, + { 800, 600, 8, 0x55 }, + { 800, 600, 16, 0x57 }, + { 800, 600, 24, 0x58 }, + { 800, 600, 32, 0x59 }, + { 1024, 768, 8, 0x60 }, + { 1024, 768, 16, 0x62 }, + { 1024, 768, 24, 0x63 }, + { 1024, 768, 32, 0x64 }, + { 1280, 1024, 8, 0x65 }, + { 1280, 1024, 16, 0x67 }, + { 1280, 1024, 24, 0x68 }, + { 1280, 1024, 32, 0x69 }, + }; + + new->mode = 0; + for (i = 0; i < sizeof(modeTable) / sizeof(modeTable[0]); i++) + { + if ( (modeTable[i].x == mode->HDisplay) + && (modeTable[i].y == mode->VDisplay) + && (modeTable[i].bpp == pScrn->bitsPerPixel) + ) + { + new->mode = modeTable[i].mode; + break; + } + } + } + + /* Zero the font memory */ + memset(new->smiFont, 0, sizeof(new->smiFont)); + + /* Write the mode registers to hardware */ + SMI_WriteMode(pScrn, vganew, new); + + /* Adjust the viewport */ + SMI_AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + LEAVE_PROC("SMI_ModeInit"); + return(TRUE); +} + +/* + * This is called at the end of each server generation. It restores the + * original (text) mode. It should also unmap the video memory, and free any + * per-generation data allocated by the driver. It should finish by unwrapping + * and calling the saved CloseScreen function. + */ + +static Bool +SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + vgaRegPtr vgaSavePtr = &hwp->SavedReg; + SMIRegPtr SMISavePtr = &pSmi->SavedReg; + Bool ret; + + ENTER_PROC("SMI_CloseScreen"); + + if (pScrn->vtSema) + { + SMI_WriteMode(pScrn, vgaSavePtr, SMISavePtr); + vgaHWLock(hwp); + SMI_UnmapMem(pScrn); + } + + if (pSmi->AccelInfoRec != NULL) + { + XAADestroyInfoRec(pSmi->AccelInfoRec); + } + if (pSmi->CursorInfoRec != NULL) + { + xf86DestroyCursorInfoRec(pSmi->CursorInfoRec); + } + if (pSmi->DGAModes != NULL) + { + xfree(pSmi->DGAModes); + } + if (pSmi->pInt != NULL) + { + xf86FreeInt10(pSmi->pInt); + } +#ifdef XvExtension + if (pSmi->ptrAdaptor != NULL) + { + xfree(pSmi->ptrAdaptor); + } + if (pSmi->BlockHandler != NULL) + { + pScreen->BlockHandler = pSmi->BlockHandler; + } +#endif + if (pSmi->I2C != NULL) + { + xf86DestroyI2CBusRec(pSmi->I2C, TRUE, TRUE); + } + /* #670 */ + if (pSmi->pSaveBuffer) + { + xfree(pSmi->pSaveBuffer); + } + + pScrn->vtSema = FALSE; + pScreen->CloseScreen = pSmi->CloseScreen; + ret = (*pScreen->CloseScreen)(scrnIndex, pScreen); + + LEAVE_PROC("SMI_CloseScreen"); + return(ret); +} + +static void +SMI_FreeScreen(int scrnIndex, int flags) +{ + SMI_FreeRec(xf86Screens[scrnIndex]); +} + +static Bool +SMI_SaveScreen(ScreenPtr pScreen, int mode) +{ + Bool ret; + + ENTER_PROC("SMI_SaveScreen"); + + ret = vgaHWSaveScreen(pScreen, mode); + + LEAVE_PROC("SMI_SaveScreen"); + return(ret); +} + +void +SMI_AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 Base; + + ENTER_PROC("SMI_AdjustFrame"); + + if (pSmi->ShowCache && y) + { + y += pScrn->virtualY - 1; + } + + Base = pSmi->FBOffset + (x + y * pScrn->virtualX) * pSmi->Bpp; + if (SMI_LYNX3D_SERIES(pSmi->Chipset)) + { + Base = (Base + 15) & ~15; + } + else + { + Base = (Base + 7) & ~7; + } + + WRITE_VPR(pSmi, 0x0C, Base >> 3); + + LEAVE_PROC("SMI_AdjustFrame"); +} + +Bool +SMI_SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + Bool ret; + + ENTER_PROC("SMI_SwitchMode"); + + ret = SMI_ModeInit(xf86Screens[scrnIndex], mode); + + LEAVE_PROC("SMI_SwitchMode"); + return(ret); +} + +void +SMI_LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, + VisualPtr pVisual) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int i; + + ENTER_PROC("SMI_LoadPalette"); + + for(i = 0; i < numColors; i++) + { + VGAOUT8(pSmi, VGA_DAC_WRITE_ADDR, indicies[i]); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].red); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].green); + VGAOUT8(pSmi, VGA_DAC_DATA, colors[indicies[i]].blue); + } + + LEAVE_PROC("SMI_LoadPalette"); +} + +void +SMI_EnableMmio(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + CARD8 tmp; + + ENTER_PROC("SMI_EnableMmio"); + + /* + * Enable chipset (seen on uninitialized secondary cards) might not be + * needed once we use the VGA softbooter + */ + vgaHWSetStdFuncs(hwp); + + /* Disable video output */ + outb(VGA_DAC_MASK, 0x00); + + /* Enable linear mode */ + outb(VGA_SEQ_INDEX, 0x18); + tmp = inb(VGA_SEQ_DATA); + pSmi->SR18Value = tmp; /* PDR#521 */ + outb(VGA_SEQ_DATA, tmp | 0x11); + + /* Enable 2D/3D Engine and Video Processor */ + outb(VGA_SEQ_INDEX, 0x21); + tmp = inb(VGA_SEQ_DATA); + pSmi->SR21Value = tmp; /* PDR#521 */ + outb(VGA_SEQ_DATA, tmp & ~0x03); + + LEAVE_PROC("SMI_EnableMmio"); +} + +void +SMI_DisableMmio(ScrnInfoPtr pScrn) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_DisableMmio"); + + vgaHWSetStdFuncs(hwp); + + /* Disable 2D/3D Engine and Video Processor */ + outb(VGA_SEQ_INDEX, 0x21); + outb(VGA_SEQ_DATA, pSmi->SR21Value); /* PDR#521 */ + + /* Disable linear mode */ + outb(VGA_SEQ_INDEX, 0x18); + outb(VGA_SEQ_DATA, pSmi->SR18Value); /* PDR#521 */ + + LEAVE_PROC("SMI_DisableMmio"); +} + +/* This function is used to debug, it prints out the contents of Lynx regs */ +static void +SMI_PrintRegs(ScrnInfoPtr pScrn) +{ + unsigned char i, tmp; + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + int vgaCRIndex = hwp->IOBase + VGA_CRTC_INDEX_OFFSET; + int vgaCRReg = hwp->IOBase + VGA_CRTC_DATA_OFFSET; + int vgaStatus = hwp->IOBase + VGA_IN_STAT_1_OFFSET; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "START register dump ------------------\n"); + + xf86ErrorFVerb(VERBLEV, "MISCELLANEOUS OUTPUT\n %02X\n", + VGAIN8(pSmi, VGA_MISC_OUT_R)); + + xf86ErrorFVerb(VERBLEV, "\nSEQUENCER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0xAF; i++) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nCRT CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0xAD; i++) + { + if (i == 0x20) i = 0x30; + if (i == 0x50) i = 0x90; + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRReg, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nGRAPHICS CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0x08; i++) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_GRAPH_INDEX, VGA_GRAPH_DATA, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nATTRIBUTE 0CONTROLLER\n" + " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); + for (i = 0x00; i <= 0x14; i++) + { + tmp = VGAIN8(pSmi, vgaStatus); + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); + xf86ErrorFVerb(VERBLEV, "%02X ", + VGAIN8_INDEX(pSmi, VGA_ATTR_INDEX, VGA_ATTR_DATA_R, i)); + } + tmp = VGAIN8(pSmi, vgaStatus); + VGAOUT8(pSmi, VGA_ATTR_INDEX, 0x20); + + xf86ErrorFVerb(VERBLEV, "\n\nDPR x0 x4 x8 xC"); + for (i = 0x00; i <= 0x44; i += 4) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + xf86ErrorFVerb(VERBLEV, " %08X", READ_DPR(pSmi, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nVPR x0 x4 x8 xC"); + for (i = 0x00; i <= 0x60; i += 4) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + xf86ErrorFVerb(VERBLEV, " %08X", READ_VPR(pSmi, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\nCPR x0 x4 x8 xC"); + for (i = 0x00; i <= 0x18; i += 4) + { + if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); + xf86ErrorFVerb(VERBLEV, " %08X", READ_CPR(pSmi, i)); + } + + xf86ErrorFVerb(VERBLEV, "\n\n"); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, + "END register dump --------------------\n"); +} + +/* + * SMI_DisplayPowerManagementSet -- Sets VESA Display Power Management + * Signaling (DPMS) Mode. + */ +#ifdef DPMSExtension +static void +SMI_DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, + int flags) +{ + vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + CARD8 SR01, SR20, SR21, SR22, SR23, SR24, SR31, SR34; + + ENTER_PROC("SMI_DisplayPowerManagementSet"); + + /* If we already are in the requested DPMS mode, just return */ + if (pSmi->CurrentDPMS == PowerManagementMode) + { + LEAVE_PROC("SMI_DisplayPowerManagementSet"); + return; + } + + #if 1 /* PDR#735 */ + if (pSmi->pInt != NULL) + { + pSmi->pInt->ax = 0x4F10; + switch (PowerManagementMode) + { + case DPMSModeOn: + pSmi->pInt->bx = 0x0001; + break; + + case DPMSModeStandby: + pSmi->pInt->bx = 0x0101; + break; + + case DPMSModeSuspend: + pSmi->pInt->bx = 0x0201; + break; + + case DPMSModeOff: + pSmi->pInt->bx = 0x0401; + break; + } + pSmi->pInt->cx = 0x0000; + pSmi->pInt->num = 0x10; + xf86ExecX86int10(pSmi->pInt); + if (pSmi->pInt->ax == 0x004F) + { + pSmi->CurrentDPMS = PowerManagementMode; + #if 1 /* PDR#835 */ + if (PowerManagementMode == DPMSModeOn) + { + SR01 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01, + SR01 & ~0x20); + } + #endif + LEAVE_PROC("SMI_DisplayPowerManagementSet"); + return; + } + } + #endif + + /* Save the current SR registers */ + if (pSmi->CurrentDPMS == DPMSModeOn) + { + pSmi->DPMS_SR20 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20); + pSmi->DPMS_SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + pSmi->DPMS_SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31); + pSmi->DPMS_SR34 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x34); + } + + /* Read the required SR registers for the DPMS handler */ + SR01 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01); + SR20 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20); + SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21); + SR22 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x22); + SR23 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x23); + SR24 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x24); + SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31); + SR34 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x34); + + switch (PowerManagementMode) + { + case DPMSModeOn: + /* Screen On: HSync: On, VSync : On */ + SR01 &= ~0x20; + SR20 = pSmi->DPMS_SR20; + SR21 = pSmi->DPMS_SR21; + SR22 &= ~0x30; + SR23 &= ~0xC0; + SR24 |= 0x01; + SR31 = pSmi->DPMS_SR31; + SR34 = pSmi->DPMS_SR34; + break; + + case DPMSModeStandby: + /* Screen: Off; HSync: Off, VSync: On */ + SR01 |= 0x20; + SR20 = (SR20 & ~0xB0) | 0x10; + SR21 |= 0x88; + SR22 = (SR22 & ~0x30) | 0x10; + SR23 = (SR23 & ~0x07) | 0xD8; + SR24 &= ~0x01; + SR31 = (SR31 & ~0x07) | 0x00; + SR34 |= 0x80; + break; + + case DPMSModeSuspend: + /* Screen: Off; HSync: On, VSync: Off */ + SR01 |= 0x20; + SR20 = (SR20 & ~0xB0) | 0x10; + SR21 |= 0x88; + SR22 = (SR22 & ~0x30) | 0x20; + SR23 = (SR23 & ~0x07) | 0xD8; + SR24 &= ~0x01; + SR31 = (SR31 & ~0x07) | 0x00; + SR34 |= 0x80; + break; + + case DPMSModeOff: + /* Screen: Off; HSync: Off, VSync: Off */ + SR01 |= 0x20; + SR20 = (SR20 & ~0xB0) | 0x10; + SR21 |= 0x88; + SR22 = (SR22 & ~0x30) | 0x30; + SR23 = (SR23 & ~0x07) | 0xD8; + SR24 &= ~0x01; + SR31 = (SR31 & ~0x07) | 0x00; + SR34 |= 0x80; + break; + + default: + xf86ErrorFVerb(VERBLEV, "Invalid PowerManagementMode %d passed to " + "SMI_DisplayPowerManagementSet\n", PowerManagementMode); + LEAVE_PROC("SMI_DisplayPowerManagementSet"); + return; + } + + /* Wait for vertical retrace */ + while (hwp->readST01(hwp) & 0x8) ; + while (!(hwp->readST01(hwp) & 0x8)) ; + + /* Write the registers */ + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01, SR01); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x34, SR34); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31, SR31); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20, SR20); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x22, SR22); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x23, SR23); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, SR21); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x24, SR24); + + /* Save the current power state */ + pSmi->CurrentDPMS = PowerManagementMode; + + LEAVE_PROC("SMI_DisplayPowerManagementSet"); +} +#endif + +static void +SMI_ProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + if (xf86LoadSubModule(pScrn, "vbe")) + { + pVbe = VBEInit(NULL, index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + } +} + +static unsigned int +SMI_ddc1Read(ScrnInfoPtr pScrn) +{ + register vgaHWPtr hwp = VGAHWPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); + unsigned int ret; + + ENTER_PROC("SMI_ddc1Read"); + + while (hwp->readST01(hwp) & 0x8) ; + while (!(hwp->readST01(hwp) & 0x8)) ; + + ret = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72) & 0x08; + + LEAVE_PROC("SMI_ddc1Read"); + return(ret); +} + +static Bool +SMI_ddc1(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SMIPtr pSmi = SMIPTR(pScrn); + Bool success = FALSE; + xf86MonPtr pMon; + unsigned char tmp; + + ENTER_PROC("SMI_ddc1"); + + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp | 0x20); + + pMon = xf86PrintEDID(xf86DoEDID_DDC1(scrnIndex, vgaHWddc1SetSpeed, + SMI_ddc1Read)); + if (pMon != NULL) + { + success = TRUE; + } + xf86SetDDCproperties(pScrn, pMon); + + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp); + + LEAVE_PROC("SMI_ddc1"); + return(success); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c:1.1 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c Tue Nov 28 15:59:20 2000 @@ -0,0 +1,375 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_hwcurs.c-arc 1.12 27 Nov 2000 15:47:48 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c,v 1.1 2000/11/28 20:59:20 dawes Exp $ */ + +#include <cursorstr.h> +#include "smi.h" + +#define MAX_CURSOR 32 + +static unsigned char * +SMI_RealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs) +{ + SMIPtr pSmi = SMIPTR(infoPtr->pScrn); + CursorBitsPtr bits = pCurs->bits; + unsigned char * ram; + unsigned char * psource = bits->source; + unsigned char * pmask = bits->mask; + int x, y, srcwidth, i; + + ENTER_PROC("SMI_RealizeCursor"); + + /* Allocate memory */ + ram = (unsigned char *) xcalloc(1, 1024); + if (ram == NULL) + { + LEAVE_PROC("SMI_RealizeCursor"); + return(NULL); + } + + /* Calculate cursor information */ + srcwidth = ((bits->width + 31) / 8) & ~3; + i = 0; + + switch (pSmi->rotate) + { + default: + /* Copy cursor image */ + for (y = 0; y < min(MAX_CURSOR, bits->height); y++) + { + for (x = 0; x < min(MAX_CURSOR / 8, srcwidth); x++) + { + unsigned char mask = byte_reversed[*pmask++]; + unsigned char source = byte_reversed[*psource++] & mask; + + ram[i++] = ~mask; + ram[i++] = source; + if (i & 4) i += 4; + } + + pmask += srcwidth - x; + psource += srcwidth - x; + + /* Fill remaining part of line with no shape */ + for (; x < MAX_CURSOR / 8; x++) + { + ram[i++] = 0xFF; + ram[i++] = 0x00; + if (i & 4) i += 4; + } + } + + /* Fill remaining part of memory with no shape */ + for (; y < MAX_CURSOR; y++) + { + for (x = 0; x < MAX_CURSOR / 8; x++) + { + ram[i++] = 0xFF; + ram[i++] = 0x00; + if (i & 4) i += 4; + } + } + break; + + case SMI_ROTATE_CW: + /* Initialize cursor memory */ + for (i = 0; i < 1024;) + { + ram[i++] = 0xFF; + ram[i++] = 0x00; + if (i & 4) i += 4; + } + + /* Rotate cursor image */ + for (y = 0; y < min(MAX_CURSOR, bits->height); y++) + { + unsigned char bitmask = 0x01 << (y & 7); + int index = ((MAX_CURSOR - y - 1) / 8) * 2; + if (index & 4) index += 4; + + for (x = 0; x < min(MAX_CURSOR / 8, srcwidth); x++) + { + unsigned char mask = *pmask++; + unsigned char source = *psource++ & mask; + + i = index + (x * 8) * 16; + if (mask || (source & mask)) + { + unsigned char bit; + for (bit = 0x01; bit; bit <<= 1) + { + if (mask & bit) + { + ram[i + 0] &= ~bitmask; + } + + if (source & bit) + { + ram[i + 1] |= bitmask; + } + + i += 16; + } + } + } + + pmask += srcwidth - x; + psource += srcwidth - x; + } + break; + + case SMI_ROTATE_CCW: + /* Initialize cursor memory */ + for (i = 0; i < 1024;) + { + ram[i++] = 0xFF; + ram[i++] = 0x00; + if (i & 4) i += 4; + } + + /* Rotate cursor image */ + for (y = 0; y < min(MAX_CURSOR, bits->height); y++) + { + unsigned char bitmask = 0x80 >> (y & 7); + int index = (y >> 3) * 2; + if (index & 4) index += 4; + + for (x = 0; x < min(MAX_CURSOR / 8, srcwidth); x++) + { + unsigned char mask = *pmask++; + unsigned char source = *psource++ & mask; + + i = index + (MAX_CURSOR - x * 8 - 1) * 16; + if (mask || (source & mask)) + { + unsigned char bit; + for (bit = 0x01; bit; bit <<= 1) + { + if (mask & bit) + { + ram[i + 0] &= ~bitmask; + } + + if (source & bit) + { + ram[i + 1] |= bitmask; + } + + i -= 16; + } + } + } + + pmask += srcwidth - x; + psource += srcwidth - x; + } + break; + } + + LEAVE_PROC("SMI_RealizeCursor"); + return(ram); +} + +static void +SMI_LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD8 tmp; + + ENTER_PROC("SMI_LoadCursorImage"); + + /* Load storage location. */ + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x80, + pSmi->FBCursorOffset / 2048); + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81) & 0x80; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, + tmp | ((pSmi->FBCursorOffset / 2048) >> 8)); + + /* Copy cursor image to framebuffer storage */ + memcpy(pSmi->FBBase + pSmi->FBCursorOffset, src, 1024); + + LEAVE_PROC("SMI_LoadCursorImage"); +} + +static void +SMI_ShowCursor(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + char tmp; + + ENTER_PROC("SMI_ShowCursor"); + + /* Show cursor */ + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp | 0x80); + + LEAVE_PROC("SMI_ShowCursor"); +} + +static void +SMI_HideCursor(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + char tmp; + + ENTER_PROC("SMI_HideCursor"); + + /* Hide cursor */ + tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp & ~0x80); + + LEAVE_PROC("SMI_HideCursor"); +} + +static void +SMI_SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int xoff, yoff; + + ENTER_PROC("SMI_SetCursorPosition"); + + /* Calculate coordinates for rotation */ + switch (pSmi->rotate) + { + default: + xoff = x; + yoff = y; + break; + + case SMI_ROTATE_CW: + xoff = pSmi->ShadowHeight - y - MAX_CURSOR; + yoff = x; + break; + + case SMI_ROTATE_CCW: + xoff = y; + yoff = pSmi->ShadowWidth - x - MAX_CURSOR; + break; + } + + /* Program coordinates */ + if (xoff >= 0) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, xoff & 0xFF); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, + (xoff >> 8) & 0x07); + } + else + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x88, + (-xoff) & (MAX_CURSOR - 1)); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x89, 0x08); + } + + if (yoff >= 0) + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, yoff & 0xFF); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, + (yoff >> 8) & 0x07); + } + else + { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8A, + (-yoff) & (MAX_CURSOR - 1)); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, 0x08); + } + + LEAVE_PROC("SMI_SetCursorPosition"); +} + +static void +SMI_SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + SMIPtr pSmi = SMIPTR(pScrn); + unsigned char packedFG, packedBG; + + ENTER_PROC("SMI_SetCursorColors"); + + /* Pack the true color into 8 bit */ + packedFG = (fg & 0xE00000) >> 16 + | (fg & 0x00E000) >> 11 + | (fg & 0x0000C0) >> 6 + ; + packedBG = (bg & 0xE00000) >> 16 + | (bg & 0x00E000) >> 11 + | (bg & 0x0000C0) >> 6 + ; + + /* Program the colors */ + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8C, packedFG); + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8D, packedBG); + + LEAVE_PROC("SMI_SetCursorColors"); +} + +Bool +SMI_HWCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + xf86CursorInfoPtr infoPtr; + Bool ret; + + ENTER_PROC("SMI_HWCursorInit"); + + /* Create cursor infor record */ + infoPtr = xf86CreateCursorInfoRec(); + if (infoPtr == NULL) + { + LEAVE_PROC("SMI_HWCursorInit"); + return(FALSE); + } + + pSmi->CursorInfoRec = infoPtr; + + /* Fill in the information */ + infoPtr->MaxWidth = MAX_CURSOR; + infoPtr->MaxHeight = MAX_CURSOR; + infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 + | HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK + | HARDWARE_CURSOR_AND_SOURCE_WITH_MASK + | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST + | HARDWARE_CURSOR_TRUECOLOR_AT_8BPP + | HARDWARE_CURSOR_INVERT_MASK; + + infoPtr->SetCursorColors = SMI_SetCursorColors; + infoPtr->SetCursorPosition = SMI_SetCursorPosition; + infoPtr->LoadCursorImage = SMI_LoadCursorImage; + infoPtr->HideCursor = SMI_HideCursor; + infoPtr->ShowCursor = SMI_ShowCursor; + infoPtr->RealizeCursor = SMI_RealizeCursor; + infoPtr->UseHWCursor = NULL; + + /* Proceed with cursor initialization */ + ret = xf86InitCursor(pScreen, infoPtr); + + LEAVE_PROC("SMI_HWCursorInit"); + return(ret); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_i2c.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_i2c.c:1.1 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_i2c.c Tue Nov 28 15:59:20 2000 @@ -0,0 +1,104 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_i2c.c-arc 1.10 27 Nov 2000 15:47:58 Frido $ */ + +/* +Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_i2c.c,v 1.1 2000/11/28 20:59:20 dawes Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "vgaHW.h" + +#include "smi.h" + +static void +SMI_I2CPutBits(I2CBusPtr b, int clock, int data) +{ + SMIPtr pSmi = SMIPTR(xf86Screens[b->scrnIndex]); + unsigned int reg = 0x30; + + ENTER_PROC("SMI_I2CPutBits"); + + if (clock) reg |= 0x01; + if (data) reg |= 0x02; + + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, reg); + + LEAVE_PROC("SMI_I2CPutBits"); +} + +static void +SMI_I2CGetBits(I2CBusPtr b, int *clock, int *data) +{ + SMIPtr pSmi = SMIPTR(xf86Screens[b->scrnIndex]); + unsigned int reg = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72); + + ENTER_PROC("SMI_I2CGetBits"); + + *clock = reg & 0x04; + *data = reg & 0x08; + + LEAVE_PROC("SMI_I2CGetBits"); +} + +Bool +SMI_I2CInit(ScrnInfoPtr pScrn) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_I2CInit"); + + if (pSmi->I2C == NULL) + { + I2CBusPtr I2CPtr = xf86CreateI2CBusRec(); + if (I2CPtr == NULL) + { + LEAVE_PROC("SMI_I2CInit"); + return(FALSE); + } + + I2CPtr->BusName = "I2C bus"; + I2CPtr->scrnIndex = pScrn->scrnIndex; + I2CPtr->I2CPutBits = SMI_I2CPutBits; + I2CPtr->I2CGetBits = SMI_I2CGetBits; + + if (!xf86I2CBusInit(I2CPtr)) + { + xf86DestroyI2CBusRec(I2CPtr, TRUE, TRUE); + LEAVE_PROC("SMI_I2CInit"); + return(FALSE); + } + + pSmi->I2C = I2CPtr; + } + + LEAVE_PROC("SMI_I2CInit"); + return(TRUE); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c:1.2 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c Tue Dec 5 16:18:37 2000 @@ -0,0 +1,226 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_shadow.c-arc 1.10 30 Nov 2000 11:40:38 Frido $ */ + +/* +Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and Silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c,v 1.2 2000/12/05 21:18:37 dawes Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "shadowfb.h" +#include "servermd.h" + +#include "smi.h" + +/******************************************************************************\ +|* SMI_RefreshArea +|*============================================================================= +|* +|* PARAMETERS: pScrn Pointer to ScrnInfo structure. +|* num Number of boxes to refresh. +|* pbox Pointer to an array of boxes to refresh. +|* +|* DESCRIPTION: Refresh a portion of the shadow buffer to the visual screen +|* buffer. This is mainly used for rotation purposes. +|* y +|* RETURNS: Nothing. +|* +\******************************************************************************/ +void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int width, height, srcX, srcY, destX, destY; + + ENTER_PROC("SMI_RefreshArea"); + + /* #671 */ + if (pSmi->polyLines) + { + pSmi->polyLines = FALSE; + return; + } + + if (pSmi->rotate) + { + /* IF we need to do rotation, setup the hardware here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + } + + /* #672 */ + if (pSmi->ClipTurnedOn) + { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + + while (num--) + { + /* Get coordinates of the box to refresh. */ + srcX = pbox->x1; + srcY = pbox->y1; + width = pbox->x2 - srcX; + height = pbox->y2 - srcY; + + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); + + if ((width > 0) && (height > 0)) + { + switch (pSmi->rotate) + { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. Calculate destination + coordinates: + + *---+ + | | +-----* + | | | | destX = shadowHeight - srcY - 1 + | | --> | | destY = srcX + | | | | + | | +-----+ + +---+ + */ + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + break; + + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotatation. Calculate destination + coordinates: + + *---+ + | | +-----+ + | | | | destX = srcY + | | --> | | destY = shadowWidth - srcX - 1 + | | | | + | | *-----+ + +---+ + */ + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + break; + + default: + /* No rotation, perform a normal copy. */ + if (pScrn->bitsPerPixel == 24) + { + srcX *= 3; + width *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + srcY *= 3; + } + } + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, SMI_BITBLT + SMI_START_ENGINE + 0xCC); + break; + } + } + + pbox++; + } + + if (pSmi->rotate) + { + /* If we did a rotation, we need to restore the hardware state here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x44, 0); + } + + LEAVE_PROC("SMI_RefreshArea"); +} + +/******************************************************************************\ +|* SMI_PointerMoved +|*============================================================================= +|* +|* PARAMETERS: index Index of current screen. +|* x X location of pointer. +|* y Y location of pointer. +|* +|* DESCRIPTION: Adjust the pointer location if we are in rotation mode. +|* +|* RETURNS: Nothing. +|* +\******************************************************************************/ +void SMI_PointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + SMIPtr pSmi = SMIPTR(pScrn); + int newX, newY; + + switch (pSmi->rotate) + { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. */ + newX = pScrn->pScreen->height - y - 1; + newY = x; + break; + + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotation. */ + newX = y; + newY = pScrn->pScreen->width - x - 1; + break; + + default: + /* No rotation. */ + newX = x; + newY = y; + break; + } + + /* Pass adjusted pointer coordinates original PointerMoved function. */ + (*pSmi->PointerMoved)(index, newX, newY); +} Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c:1.2 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c Tue Dec 5 16:18:37 2000 @@ -0,0 +1,1822 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_video.c.-arc 1.14 30 Nov 2000 16:51:40 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c,v 1.2 2000/12/05 21:18:37 dawes Exp $ */ + +#include "smi.h" +#include "smi_video.h" + +#define nElems(x) (sizeof(x) / sizeof(x[0])) +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +#if defined(XvExtension) && SMI_USE_VIDEO + +#include <dixstruct.h> +#include <xaa.h> +#include <xaalocal.h> + +static XF86VideoAdaptorPtr SMI_SetupVideo(ScreenPtr pScreen); +static void SMI_ResetVideo(ScrnInfoPtr pScrn); + +#if SMI_USE_CAPTURE +static int SMI_GetVideo(ScrnInfoPtr pScrn, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes, pointer data); +#endif +static void SMI_StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit); +static int SMI_SetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, + INT32 value, pointer data); +static int SMI_GetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, + INT32 *value, pointer data); +static void SMI_QueryBestSize(ScrnInfoPtr pScrn, Bool motion, + short vid_w, short vid_h, short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, pointer data); +static int SMI_PutImage(ScrnInfoPtr pScrn, + short src_x, short src_y, short drw_x, short drw_y, + short src_w, short src_h, short drw_w, short drw_h, + int id, unsigned char *buf, short width, short height, Bool sync, + RegionPtr clipBoxes, pointer data); +static int SMI_QueryImageAttributes(ScrnInfoPtr pScrn, + int id, unsigned short *width, unsigned short *height, + int *picthes, int *offsets); + +static Bool RegionsEqual(RegionPtr A, RegionPtr B); +static Bool SMI_ClipVideo(ScrnInfoPtr pScrn, BoxPtr dst, + INT32 *x1, INT32 *y1, INT32 *x2, INT32 *y2, + RegionPtr reg, INT32 width, INT32 height); +static void SMI_DisplayVideo(ScrnInfoPtr pScrn, int id, int offset, + short width, short height, int pitch, int x1, int y1, int x2, int y2, + BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); +static void SMI_BlockHandler(int i, pointer blockData, pointer pTimeout, + pointer pReadMask); +static void SMI_WaitForSync(ScrnInfoPtr pScrn); +static int SMI_SendI2C(ScrnInfoPtr pScrn, CARD8 device, char *devName, + SMI_I2CDataPtr i2cData); + +static void SMI_InitOffscreenImages(ScreenPtr pScreen); +static FBAreaPtr SMI_AllocateMemory(ScrnInfoPtr pScrn, FBAreaPtr area, + int numLines); +static void SMI_CopyData(unsigned char *src, unsigned char *dst, int srcPitch, + int dstPitch, int height, int width); +static void SMI_CopyYV12Data(unsigned char *src1, unsigned char *src2, + unsigned char *src3, unsigned char *dst, int srcPitch1, int srcPitch2, + int dstPitch, int height, int width); + +static int SMI_AllocSurface(ScrnInfoPtr pScrn, + int id, unsigned short width, unsigned short height, + XF86SurfacePtr surface); +static int SMI_FreeSurface(XF86SurfacePtr surface); +static int SMI_DisplaySurface(XF86SurfacePtr surface, + short vid_x, short vid_y, short drw_x, short drw_y, + short vid_w, short vid_h, short drw_w, short drw_h, + RegionPtr clipBoxes); +static int SMI_StopSurface(XF86SurfacePtr surface); +static int SMI_GetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attr, INT32 *value); +static int SMI_SetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attr, INT32 value); + +static Atom xvColorKey, xvBrightness; + +/******************************************************************************\ +** ** +** X V E X T E N S I O N I N T E R F A C E ** +** ** +\******************************************************************************/ + +void SMI_InitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr psmi = SMIPTR(pScrn); + XF86VideoAdaptorPtr *ptrAdaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int numAdaptors; + + ENTER_PROC("SMI_InitVideo"); + + numAdaptors = xf86XVListGenericAdaptors(pScrn, &ptrAdaptors); + + if ( (psmi->rotate == 0) + && !psmi->NoAccel + && (pScrn->bitsPerPixel != 8) + ) + { + newAdaptor = SMI_SetupVideo(pScreen); + SMI_InitOffscreenImages(pScreen); + } + + if (newAdaptor != NULL) + { + if (numAdaptors == 0) + { + numAdaptors = 1; + ptrAdaptors = &newAdaptor; + } + else + { + newAdaptors = xalloc((numAdaptors + 1) * + sizeof(XF86VideoAdaptorPtr*)); + if (newAdaptors != NULL) + { + memcpy(newAdaptors, ptrAdaptors, + numAdaptors * sizeof(XF86VideoAdaptorPtr)); + newAdaptors[numAdaptors++] = newAdaptor; + ptrAdaptors = newAdaptors; + } + } + } + + if (numAdaptors != 0) + { + xf86XVScreenInit(pScreen, ptrAdaptors, numAdaptors); + } + + if (newAdaptors != NULL) + { + xfree(newAdaptors); + } + + LEAVE_PROC("SMI_InitVideo"); +} + +/******************************************************************************\ +** ** +** C A P A B I L I T I E S ** +** ** +\******************************************************************************/ + +static XF86VideoEncodingRec SMI_VideoEncodings[] = +{ +#if SMI_USE_CAPTURE + { + SMI_VIDEO_VIDEO, /* id */ + "XV_VIDEO", /* name */ + 1024, 1024, /* width, height */ + {1, 1} /* rate */ + }, +#endif + { + SMI_VIDEO_IMAGE, /* id */ + "XV_IMAGE", /* name */ + 1024, 1024, /* width, height */ + {1, 1} /* rate */ + }, +}; + +static XF86VideoFormatRec SMI_VideoFormats[] = +{ + { 8, PseudoColor }, /* depth, class */ + { 15, TrueColor }, /* depth, class */ + { 16, TrueColor }, /* depth, class */ + { 24, TrueColor }, /* depth, class */ +}; + +static XF86AttributeRec SMI_VideoAttributes[] = +{ + { + XvSettable | XvGettable, /* flags */ + 0x000000, 0xFFFFFF, /* min_value, max_value */ + "XV_COLORKEY" /* name */ + }, + { + XvSettable | XvGettable, /* flags */ + -128, 127, /* min_value, max_value */ + "XV_BRIGHTNESS" /* name */ + }, +}; + +static XF86ImageRec SMI_VideoImages[] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + { + FOURCC_RV15, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'1', '5', + 0x00, '5', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 16, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 15, /* depth */ + 0x001F, 0x03E0, 0x7C00, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV16, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'1', '6', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 16, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 16, /* depth */ + 0x001F, 0x07E0, 0xF800, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV24, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'2', '4', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 24, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 24, /* depth */ + 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV32, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'3', '2', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 32, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 24, /* depth */ + 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, +}; + +SMI_I2CDataRec data_SAA7110[] = +{ + /* Configuration */ + { 0x00, 0x4C }, { 0x01, 0x3C }, { 0x02, 0x00 }, { 0x03, 0xEF }, + { 0x04, 0xBD }, { 0x05, 0xE2 }, { 0x06, 0x00 }, { 0x07, 0x00 }, + { 0x08, 0xF8 }, { 0x09, 0xF8 }, { 0x0A, 0x60 }, { 0x0B, 0x60 }, + { 0x0C, 0x00 }, { 0x0D, 0x80 }, { 0x0E, 0x18 }, { 0x0F, 0xD9 }, + { 0x10, 0x00 }, { 0x11, 0x2B }, { 0x12, 0x40 }, { 0x13, 0x40 }, + { 0x14, 0x42 }, { 0x15, 0x1A }, { 0x16, 0xFF }, { 0x17, 0xDA }, + { 0x18, 0xE6 }, { 0x19, 0x90 }, { 0x20, 0xD9 }, { 0x21, 0x16 }, + { 0x22, 0x40 }, { 0x23, 0x40 }, { 0x24, 0x80 }, { 0x25, 0x40 }, + { 0x26, 0x80 }, { 0x27, 0x4F }, { 0x28, 0xFE }, { 0x29, 0x01 }, + { 0x2A, 0xCF }, { 0x2B, 0x0F }, { 0x2C, 0x03 }, { 0x2D, 0x01 }, + { 0x2E, 0x83 }, { 0x2F, 0x03 }, { 0x30, 0x40 }, { 0x31, 0x35 }, + { 0x32, 0x02 }, { 0x33, 0x8C }, { 0x34, 0x03 }, + + /* NTSC */ + { 0x11, 0x2B }, { 0x0F, 0xD9 }, + + /* RCA input connector */ + { 0x06, 0x00 }, { 0x0E, 0x18 }, { 0x20, 0xD9 }, { 0x21, 0x16 }, + { 0x22, 0x40 }, { 0x2C, 0x03 }, + + { 0xFF, 0xFF } +}; + +/******************************************************************************\ +** ** +** V I D E O M A N A G E M E N T ** +** ** +\******************************************************************************/ + +static XF86VideoAdaptorPtr +SMI_SetupVideo( + ScreenPtr pScreen +) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr smiPortPtr; + XF86VideoAdaptorPtr ptrAdaptor; + int i; + + ENTER_PROC("SMI_SetupVideo"); + + ptrAdaptor = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(DevUnion) + sizeof(SMI_PortRec)); + if (ptrAdaptor == NULL) + { + LEAVE_PROC("SMI_SetupVideo"); + return(NULL); + } + + ptrAdaptor->type = XvInputMask +#if SMI_USE_CAPTURE + | XvOutputMask + | XvVideoMask +#endif + | XvImageMask + | XvWindowMask + ; + + ptrAdaptor->flags = VIDEO_OVERLAID_IMAGES + | VIDEO_CLIP_TO_VIEWPORT + ; + + ptrAdaptor->name = "Silicon Motion Lynx Series Video Engine"; + + ptrAdaptor->nEncodings = nElems(SMI_VideoEncodings); + ptrAdaptor->pEncodings = SMI_VideoEncodings; + for (i = 0; i < nElems(SMI_VideoEncodings); i++) + { + SMI_VideoEncodings[i].width = pSmi->lcdWidth; + SMI_VideoEncodings[i].height = pSmi->lcdHeight; + } + + ptrAdaptor->nFormats = nElems(SMI_VideoFormats); + ptrAdaptor->pFormats = SMI_VideoFormats; + + ptrAdaptor->nPorts = 1; + ptrAdaptor->pPortPrivates = (DevUnion*) &ptrAdaptor[1]; + ptrAdaptor->pPortPrivates[0].ptr = (pointer) &ptrAdaptor->pPortPrivates[1]; + + ptrAdaptor->nAttributes = nElems(SMI_VideoAttributes); + ptrAdaptor->pAttributes = SMI_VideoAttributes; + + ptrAdaptor->nImages = nElems(SMI_VideoImages); + ptrAdaptor->pImages = SMI_VideoImages; + +#if SMI_USE_CAPTURE + ptrAdaptor->PutVideo = NULL; + ptrAdaptor->PutStill = NULL; + ptrAdaptor->GetVideo = SMI_GetVideo; + ptrAdaptor->GetStill = NULL; +#else + ptrAdaptor->PutVideo = NULL; + ptrAdaptor->PutStill = NULL; + ptrAdaptor->GetVideo = NULL; + ptrAdaptor->GetStill = NULL; +#endif + ptrAdaptor->StopVideo = SMI_StopVideo; + ptrAdaptor->SetPortAttribute = SMI_SetPortAttribute; + ptrAdaptor->GetPortAttribute = SMI_GetPortAttribute; + ptrAdaptor->QueryBestSize = SMI_QueryBestSize; + ptrAdaptor->PutImage = SMI_PutImage; + ptrAdaptor->QueryImageAttributes = SMI_QueryImageAttributes; + + smiPortPtr = (SMI_PortPtr) ptrAdaptor->pPortPrivates[0].ptr; + smiPortPtr->colorKey = pSmi->videoKey; + smiPortPtr->videoStatus = 0; + smiPortPtr->brightness = 0; + REGION_INIT(pScreen, &smiPortPtr->clip, NullBox, 0); + + pSmi->ptrAdaptor = ptrAdaptor; + pSmi->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = SMI_BlockHandler; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + SMI_ResetVideo(pScrn); + + LEAVE_PROC("SMI_SetupVideo"); + return(ptrAdaptor); +} + +static void +SMI_ResetVideo( + ScrnInfoPtr pScrn +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr ptrPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + int r, g, b; + + ENTER_PROC("SMI_ResetVideo"); + + switch (pScrn->depth) + { + case 8: + WRITE_VPR(pSmi, 0x04, ptrPort->colorKey & 0x00FF); + WRITE_VPR(pSmi, 0x08, 0); + break; + + case 15: + case 16: + WRITE_VPR(pSmi, 0x04, ptrPort->colorKey & 0xFFFF); + WRITE_VPR(pSmi, 0x08, 0); + break; + + default: + r = (ptrPort->colorKey & pScrn->mask.red) >> pScrn->offset.red; + g = (ptrPort->colorKey & pScrn->mask.green) >> pScrn->offset.green; + b = (ptrPort->colorKey & pScrn->mask.blue) >> pScrn->offset.blue; + WRITE_VPR(pSmi, 0x04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); + WRITE_VPR(pSmi, 0x08, 0); + break; + } + + WRITE_VPR(pSmi, 0x5C, 0xEDEDED | (ptrPort->brightness << 24)); + + LEAVE_PROC("SMI_ResetVideo"); +} + +#if SMI_USE_CAPTURE +static int +SMI_GetVideo( + ScrnInfoPtr pScrn, + short vid_x, + short vid_y, + short drw_x, + short drw_y, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + RegionPtr clipBoxes, + pointer data +) +{ + SMI_PortPtr ptrPort = (SMI_PortPtr) data; + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 vid_pitch, vid_address; + CARD32 vpr00, cpr00; + int xscale, yscale; + BoxRec dstBox; + INT32 x1, y1, x2, y2; + int areaHeight, width, height, fbPitch; + int top, left; + + ENTER_PROC("SMI_GetVideo"); + + x1 = vid_x; + y1 = vid_y; + x2 = vid_x + vid_w; + y2 = vid_y + vid_h; + + width = vid_w; + height = vid_h; + + dstBox.x1 = drw_x; + dstBox.y1 = drw_y; + dstBox.x2 = drw_x + drw_w; + dstBox.y2 = drw_y + drw_h; + + if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, + height)) + { + LEAVE_PROC("SMI_GetVideo"); + return(Success); + } + + dstBox.x1 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y2 -= pScrn->frameY0; + + if (ptrPort->i2cDevice == 0) + { + if (SMI_SendI2C(pScrn, SAA7110, "SAA7110", data_SAA7110) == Success) + { + ptrPort->i2cDevice = SAA7110; + } + else + { + xf86FreeOffscreenArea(ptrPort->area); + ptrPort->area = NULL; + LEAVE_PROC("SMI_GetVideo"); + return(BadAlloc); + } + } + + vid_pitch = (vid_w * 2 + 7) & ~7; + + vpr00 = READ_VPR(pSmi, 0x00) & ~0x0FF000FF; + cpr00 = READ_CPR(pSmi, 0x00) & ~0x000FFF00; + + vpr00 |= 0x0110000E; + cpr00 |= 0x00000001; + if (pSmi->ByteSwap) + cpr00 |= 0x00004000; + + fbPitch = pSmi->Stride; + if (pSmi->Bpp != 3) + { + fbPitch *= pSmi->Bpp; + } + + if (vid_w <= drw_w) + { + xscale = (256 * vid_w / drw_w) & 0xFF; + } + else if (vid_w / 2 <= drw_w) + { + xscale = (128 * vid_w / drw_w) & 0xFF; + width /= 2; + vid_pitch /= 2; + cpr00 |= 0x00010000; + } + else if (vid_w / 4 <= drw_w) + { + xscale = (64 * vid_w / drw_w) & 0xFF; + width /= 4; + vid_pitch /= 4; + cpr00 |= 0x00020000; + } + else + { + xscale = 0; + width /= 4; + vid_pitch /= 4; + cpr00 |= 0x00020000; + } + + if (vid_h <= drw_h) + { + yscale = (256 * vid_h / drw_h) & 0xFF; + } + else if (vid_h / 2 <= drw_h) + { + yscale = (128 * vid_h / drw_h) & 0xFF; + height /= 2; + cpr00 |= 0x00040000; + } + else if (vid_h / 4 <= drw_h) + { + yscale = (64 * vid_h / drw_h) & 0xFF; + height /= 4; + cpr00 |= 0x00080000; + } + else + { + yscale = 0; + height /= 4; + cpr00 |= 0x00080000; + } + + do + { + areaHeight = (vid_pitch * height + fbPitch - 1) / fbPitch; + ptrPort->area = SMI_AllocateMemory(pScrn, ptrPort->area, areaHeight); + if (ptrPort->area == NULL) + { + if ((cpr00 & 0x000C0000) == 0) + { + /* height -> 1/2 height */ + yscale = (128 * vid_h / drw_h) & 0xFF; + height = vid_h / 2; + cpr00 |= 0x00040000; + } + else if (cpr00 & 0x00040000) + { + /* 1/2 height -> 1/4 height */ + yscale = (64 * vid_h / drw_h) & 0xFF; + height = vid_h / 4; + cpr00 ^= 0x000C0000; + } + else + { + /* 1/4 height */ + if ((cpr00 & 0x00030000) == 0) + { + /* width -> 1/2 width */ + xscale = (128 * vid_w / drw_w) & 0xFF; + width = vid_w / 2; + cpr00 |= 0x00010000; + } + else if (cpr00 & 0x00010000) + { + /* 1/2 width -> 1/4 width */ + xscale = (64 * vid_w / drw_w) & 0xFF; + width = vid_w / 4; + cpr00 ^= 0x00030000; + } + else + { + LEAVE_PROC("SMI_GetVideo"); + return(BadAlloc); + } + } + } + } + while (ptrPort->area == NULL); + + vid_address = (ptrPort->area->box.y1 * fbPitch) + ((y1 >> 16) * vid_pitch); + + if (!RegionsEqual(&ptrPort->clip, clipBoxes)) + { + REGION_COPY(pScreen, &ptrPort->clip, clipBoxes); + XAAFillSolidRects(pScrn, ptrPort->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); + } + + left = x1 >> 16; + top = y1 >> 16; + width = (x2 - x1) >> 16; + height = (y2 - y1) >> 16; + if (ptrPort->i2cDevice == SAA7110) + { + left += 79; + top += 12; + } + + OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) & ~0x04); + WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) | 0x00200000); + + SMI_WaitForSync(pScrn); + + WRITE_VPR(pSmi, 0x14, dstBox.x1 + (dstBox.y1 << 16)); + WRITE_VPR(pSmi, 0x18, dstBox.x2 + (dstBox.y2 << 16)); + WRITE_VPR(pSmi, 0x20, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); + WRITE_VPR(pSmi, 0x24, (xscale << 8) + yscale); + + WRITE_CPR(pSmi, 0x04, left + (top << 16)); + WRITE_CPR(pSmi, 0x08, width + (height << 16)); + WRITE_CPR(pSmi, 0x0C, vid_address / 8); + WRITE_CPR(pSmi, 0x10, vid_address / 8); + WRITE_CPR(pSmi, 0x14, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); + + WRITE_CPR(pSmi, 0x00, cpr00); + WRITE_VPR(pSmi, 0x00, vpr00); + + ptrPort->videoStatus = CLIENT_VIDEO_ON; + LEAVE_PROC("SMI_GetVideo"); + return(Success); +} +#endif + +static void +SMI_StopVideo( + ScrnInfoPtr pScrn, + pointer data, + Bool exit +) +{ + SMI_PortPtr ptrPort = (SMI_PortPtr) data; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_StopVideo"); + + REGION_EMPTY(pScrn->pScreen, &ptrPort->clip); + + if (exit) + { + if (ptrPort->videoStatus & CLIENT_VIDEO_ON) + { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); + #if SMI_USE_CAPTURE + WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); + WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); +/* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ + #endif + } + if (ptrPort->area != NULL) + { + xf86FreeOffscreenArea(ptrPort->area); + ptrPort->area = NULL; + } + ptrPort->videoStatus = 0; + ptrPort->i2cDevice = 0; + } + else + { + if (ptrPort->videoStatus & CLIENT_VIDEO_ON) + { + ptrPort->videoStatus |= OFF_TIMER; + ptrPort->offTime = currentTime.milliseconds + OFF_DELAY; + } + } + + LEAVE_PROC("SMI_StopVideo"); +} + +static int +SMI_SetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +) +{ + SMI_PortPtr ptrPort = (SMI_PortPtr) data; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_SetPortAttribute"); + + if (attribute == xvColorKey) + { + int r, g, b; + + ptrPort->colorKey = value; + switch (pScrn->depth) + { + case 8: + WRITE_VPR(pSmi, 0x04, value & 0x00FF); + break; + + case 15: + case 16: + WRITE_VPR(pSmi, 0x04, value & 0xFFFF); + break; + + default: + r = (value & pScrn->mask.red) >> pScrn->offset.red; + g = (value & pScrn->mask.green) >> pScrn->offset.green; + b = (value & pScrn->mask.blue) >> pScrn->offset.blue; + WRITE_VPR(pSmi, 0x04, + ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); + break; + } + } + + else if (attribute == xvBrightness) + { + if ((value < -128) || (value > 127)) + { + LEAVE_PROC("SMI_SetPortAttribute"); + return(BadValue); + } + ptrPort->brightness = value; + WRITE_VPR(pSmi, 0x5C, 0xEDEDED | (value << 24)); + } + + else + { + LEAVE_PROC("SMI_SetPortAttribute"); + return(BadMatch); + } + + LEAVE_PROC("SMI_SetPortAttribute"); + return(Success); +} + +static int +SMI_GetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +) +{ + SMI_PortPtr ptrPort = (SMI_PortPtr) data; + + ENTER_PROC("SMI_GetPortAttribute"); + + if (attribute == xvColorKey) + { + *value = ptrPort->colorKey; + } + + else if (attribute == xvBrightness) + { + *value = ptrPort->brightness; + } + + else + { + LEAVE_PROC("SMI_GetPortAttribute"); + return(BadMatch); + } + + LEAVE_PROC("SMI_GetPortAttribute"); + return(Success); +} + +static void +SMI_QueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + unsigned int *p_w, + unsigned int *p_h, + pointer data +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_QueryBestSize"); + + *p_w = min(drw_w, pSmi->lcdWidth); + *p_h = min(drw_h, pSmi->lcdHeight); + + LEAVE_PROC("SMI_QueryBestSize"); +} + +static int +SMI_PutImage( + ScrnInfoPtr pScrn, + short src_x, + short src_y, + short drw_x, + short drw_y, + short src_w, + short src_h, + short drw_w, + short drw_h, + int id, + unsigned char *buf, + short width, + short height, + Bool sync, + RegionPtr clipBoxes, + pointer data +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr ptrPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + INT32 x1, y1, x2, y2; + int bpp = 0; + int fbPitch, srcPitch, srcPitch2 = 0, dstPitch, areaHeight; + BoxRec dstBox; + CARD32 offset, offset2 = 0, offset3 = 0, tmp; + int left, top, nPixels, nLines; + unsigned char *dstStart; + + ENTER_PROC("SMI_PutImage"); + + x1 = src_x; + y1 = src_y; + x2 = src_x + src_w; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.y1 = drw_y; + dstBox.x2 = drw_x + drw_w; + dstBox.y2 = drw_y + drw_h; + + if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, + height)) + { + LEAVE_PROC("SMI_PutImage"); + return(Success); + } + + dstBox.x1 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y2 -= pScrn->frameY0; + + if (pSmi->Bpp == 3) + { + fbPitch = pSmi->Stride; + } + else + { + fbPitch = pSmi->Stride * pSmi->Bpp; + } + + switch (id) + { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = offset2 + (srcPitch2 * (height >> 1)); + dstPitch = ((width << 1) + 15) & ~15; + break; + + case FOURCC_RV24: + bpp = 3; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + + case FOURCC_RV32: + bpp = 4; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + default: + bpp = 2; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + } + + areaHeight = ((dstPitch * height) + fbPitch - 1) / fbPitch; + ptrPort->area = SMI_AllocateMemory(pScrn, ptrPort->area, areaHeight); + if (ptrPort->area == NULL) + { + LEAVE_PROC("SMI_PutImage"); + return(BadAlloc); + } + + top = y1 >> 16; + left = (x1 >> 16) & ~1; + nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left; + left *= bpp; + + offset = (ptrPort->area->box.y1 * fbPitch) + (top * dstPitch); + dstStart = pSmi->FBBase + offset + left; + + switch (id) + { + case FOURCC_YV12: + top &= ~1; + tmp = ((top >> 1) * srcPitch2) + (left >> 2); + offset2 += tmp; + offset3 += tmp; + nLines = ((((y2 + 0xFFFF) >> 16) + 1) & ~1) - top; + SMI_CopyYV12Data(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, dstStart, srcPitch, srcPitch2, + dstPitch, nLines, nPixels); + break; + + default: + buf += (top * srcPitch) + left; + nLines = ((y2 + 0xFFFF) >> 16) - top; + SMI_CopyData(buf, dstStart, srcPitch, dstPitch, nLines, + nPixels * bpp); + break; + } + + if (!RegionsEqual(&ptrPort->clip, clipBoxes)) + { + REGION_COPY(pScreen, &ptrPort->clip, clipBoxes); + XAAFillSolidRects(pScrn, ptrPort->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); + } + + SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); + + ptrPort->videoStatus = CLIENT_VIDEO_ON; + LEAVE_PROC("SMI_PutImage"); + return(Success); + +} + +static int +SMI_QueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *width, + unsigned short *height, + int *pitches, + int *offsets +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int size, tmp; + + ENTER_PROC("SMI_QueryImageAttributes"); + + if (*width > pSmi->lcdWidth) + { + *width = pSmi->lcdWidth; + } + if (*height > pSmi->lcdHeight) + { + *height = pSmi->lcdHeight; + } + + *width = (*width + 1) & ~1; + if (offsets != NULL) + { + offsets[0] = 0; + } + + switch (id) + { + case FOURCC_YV12: + *height = (*height + 1) & ~1; + size = (*width + 3) & ~3; + if (pitches != NULL) + { + pitches[0] = size; + } + size *= *height; + if (offsets != NULL) + { + offsets[1] = size; + } + tmp = ((*width >> 1) + 3) & ~3; + if (pitches != NULL) + { + pitches[1] = pitches[2] = tmp; + } + tmp *= (*height >> 1); + size += tmp; + if (offsets != NULL) + { + offsets[2] = size; + } + size += tmp; + break; + + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + default: + size = *width * 2; + if (pitches != NULL) + { + pitches[0] = size; + } + size *= *height; + break; + + case FOURCC_RV24: + size = *width * 3; + if (pitches != NULL) + { + pitches[0] = size; + } + size *= *height; + break; + + case FOURCC_RV32: + size = *width * 4; + if (pitches != NULL) + { + pitches[0] = size; + } + size *= *height; + break; + } + + LEAVE_PROC("SMI_QueryImageAttributes"); + return(size); +} + +/******************************************************************************\ +** ** +** S U P P O R T F U N C T I O N S ** +** ** +\******************************************************************************/ + +static void +SMI_WaitForSync( + ScrnInfoPtr pScrn +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + int vgaIOBase = hwp->IOBase; + int vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; + int vgaCRData = vgaIOBase + VGA_CRTC_DATA_OFFSET; + + VerticalRetraceWait(); +} + +static Bool +RegionsEqual( + RegionPtr A, + RegionPtr B +) +{ + int *dataA, *dataB; + int num; + + ENTER_PROC("RegionsEqual"); + + num = REGION_NUM_RECTS(A); + if (num != REGION_NUM_RECTS(B)) + { + LEAVE_PROC("RegionsEqual"); + return(FALSE); + } + + if ( (A->extents.x1 != B->extents.x1) + || (A->extents.y1 != B->extents.y1) + || (A->extents.x2 != B->extents.x2) + || (A->extents.y2 != B->extents.y2) + ) + { + LEAVE_PROC("RegionsEqual"); + return(FALSE); + } + + dataA = (int*) REGION_RECTS(A); + dataB = (int*) REGION_RECTS(B); + + while (num--) + { + if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + { + return(FALSE); + } + dataA += 2; + dataB += 2; + } + + LEAVE_PROC("RegionsEqual"); + return(TRUE); +} + +static Bool +SMI_ClipVideo( + ScrnInfoPtr pScrn, + BoxPtr dst, + INT32 *x1, + INT32 *y1, + INT32 *x2, + INT32 *y2, + RegionPtr reg, + INT32 width, + INT32 height +) +{ + INT32 vscale, hscale, delta; + BoxPtr extents = REGION_EXTENTS(pScrn, reg); + int diff; + + ENTER_PROC("SMI_ClipVideo"); + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *y1 <<= 16; + *x2 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if (diff > 0) + { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + + diff = extents->y1 - dst->y1; + if (diff > 0) + { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + + diff = dst->x2 - extents->x2; + if (diff > 0) + { + dst->x2 = extents->x2; /* PDR#687 */ + *x2 -= diff * hscale; + } + + diff = dst->y2 - extents->y2; + if (diff > 0) + { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if (*x1 < 0) + { + diff = (-*x1 + hscale - 1) / hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + + if (*y1 < 0) + { + diff = (-*y1 + vscale - 1) / vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + + delta = *x2 - (width << 16); + if (delta > 0) + { + diff = (delta + hscale - 1) / hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + + delta = *y2 - (height << 16); + if (delta > 0) + { + diff = (delta + vscale - 1) / vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } + + if ((*x1 >= *x2) || (*y1 >= *y2)) + { + LEAVE_PROC("SMI_ClipVideo"); + return(FALSE); + } + + if ( (dst->x1 != extents->x1) || (dst->y1 != extents->y1) + || (dst->x2 != extents->x2) || (dst->y2 != extents->y2) + ) + { + RegionRec clipReg; + REGION_INIT(pScrn, &clipReg, dst, 1); + REGION_INTERSECT(pScrn, reg, reg, &clipReg); + REGION_UNINIT(pScrn, &clipReg); + } + + LEAVE_PROC("SMI_ClipVideo"); + return(TRUE); +} + +static void +SMI_DisplayVideo( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, + short height, + int pitch, + int x1, + int y1, + int x2, + int y2, + BoxPtr dstBox, + short vid_w, + short vid_h, + short drw_w, + short drw_h +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 vpr00; + int hstretch, vstretch; + + ENTER_PROC("SMI_DisplayVideo"); + + vpr00 = READ_VPR(pSmi, 0x00) & ~0x0CB800FF; + + switch (id) + { + case FOURCC_YV12: + case FOURCC_YUY2: + vpr00 |= 0x6; + break; + + case FOURCC_RV15: + vpr00 |= 0x1; + break; + + case FOURCC_RV16: + vpr00 |= 0x2; + break; + + case FOURCC_RV24: + vpr00 |= 0x4; + break; + + case FOURCC_RV32: + vpr00 |= 0x3; + break; + } + + + if (drw_w > vid_w) + { + hstretch = (2560 * vid_w / drw_w + 5) / 10; + } + else + { + hstretch = 0; + } + + if (drw_h > vid_h) + { + vstretch = (2560 * vid_h / drw_h + 5) / 10; + vpr00 |= 1 << 21; + } + else + { + vstretch = 0; + } + + SMI_WaitForSync(pScrn); + + WRITE_VPR(pSmi, 0x00, vpr00 | (1 << 3) | (1 << 20)); + WRITE_VPR(pSmi, 0x14, (dstBox->x1) | (dstBox->y1 << 16)); + WRITE_VPR(pSmi, 0x18, (dstBox->x2) | (dstBox->y2 << 16)); + WRITE_VPR(pSmi, 0x1C, offset >> 3); + WRITE_VPR(pSmi, 0x20, (pitch >> 3) | ((pitch >> 3) << 16)); + WRITE_VPR(pSmi, 0x24, (hstretch << 8) | vstretch); + + LEAVE_PROC("SMI_DisplayVideo"); +} + +static void +SMI_BlockHandler( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadMask +) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr ptrPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + + pScreen->BlockHandler = pSmi->BlockHandler; + (*pScreen->BlockHandler)(i, blockData, pTimeout, pReadMask); + pScreen->BlockHandler = SMI_BlockHandler; + + if (ptrPort->videoStatus & TIMER_MASK) + { + UpdateCurrentTime(); + if (ptrPort->videoStatus & OFF_TIMER) + { + if (ptrPort->offTime < currentTime.milliseconds) + { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + ptrPort->videoStatus = FREE_TIMER; + ptrPort->freeTime = currentTime.milliseconds + FREE_DELAY; + } + } + else + { + if (ptrPort->freeTime < currentTime.milliseconds) + { + xf86FreeOffscreenArea(ptrPort->area); + ptrPort->area = NULL; + } + ptrPort->videoStatus = 0; + } + } +} + +static int +SMI_SendI2C( + ScrnInfoPtr pScrn, + CARD8 device, + char *devName, + SMI_I2CDataPtr i2cData +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + I2CDevPtr dev; + int status = Success; + + ENTER_PROC("SMI_SendI2C"); + + if (pSmi->I2C == NULL) + { + LEAVE_PROC("SMI_SendI2C"); + return(BadAlloc); + } + + dev = xf86CreateI2CDevRec(); + if (dev == NULL) + { + LEAVE_PROC("SMI_SendI2C"); + return(BadAlloc); + } + dev->DevName = devName; + dev->SlaveAddr = device; + dev->pI2CBus = pSmi->I2C; + + if (!xf86I2CDevInit(dev)) + { + status = BadAlloc; + } + else + { + while (i2cData->address != 0xFF || i2cData->data != 0xFF) /* PDR#676 */ + { + if (!xf86I2CWriteByte(dev, i2cData->address, i2cData->data)) + { + status = BadAlloc; + break; + } + i2cData++; + } + } + + xf86DestroyI2CDevRec(dev, TRUE); + LEAVE_PROC("SMI_SendI2C"); + return(status); +} + +/******************************************************************************\ +** ** +** O F F S C R E E N M E M O R Y M A N A G E R ** +** ** +\******************************************************************************/ + +static void +SMI_InitOffscreenImages( + ScreenPtr pScreen +) +{ + XF86OffscreenImagePtr offscreenImages; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI_InitOffscreenImages"); + + offscreenImages = xalloc(sizeof(XF86OffscreenImageRec)); + if (offscreenImages == NULL) + { + LEAVE_PROC("SMI_InitOffscreenImages"); + return; + } + + offscreenImages->image = SMI_VideoImages; + offscreenImages->flags = VIDEO_OVERLAID_IMAGES + | VIDEO_CLIP_TO_VIEWPORT; + offscreenImages->alloc_surface = SMI_AllocSurface; + offscreenImages->free_surface = SMI_FreeSurface; + offscreenImages->display = SMI_DisplaySurface; + offscreenImages->stop = SMI_StopSurface; + offscreenImages->getAttribute = SMI_GetSurfaceAttribute; + offscreenImages->setAttribute = SMI_SetSurfaceAttribute; + offscreenImages->max_width = pSmi->lcdWidth; + offscreenImages->max_height = pSmi->lcdHeight; + offscreenImages->num_attributes = nElems(SMI_VideoAttributes); + offscreenImages->attributes = SMI_VideoAttributes; + + xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); + + LEAVE_PROC("SMI_InitOffscreenImages"); +} + +static FBAreaPtr +SMI_AllocateMemory( + ScrnInfoPtr pScrn, + FBAreaPtr area, + int numLines +) +{ + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + + ENTER_PROC("SMI_AllocateMemory"); + + if (area != NULL) + { + if ((area->box.y2 - area->box.y1) >= numLines) + { + LEAVE_PROC("SMI_AllocateMemory"); + return(area); + } + + if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numLines)) + { + LEAVE_PROC("SMI_AllocateMemory"); + return(area); + } + + xf86FreeOffscreenArea(area); + } + + area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, 0, + NULL, NULL, NULL); + + if (area == NULL) + { + int maxW, maxH; + + xf86QueryLargestOffscreenArea(pScreen, &maxW, &maxH, 0, + FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); + + if ((maxW < pScrn->displayWidth) || (maxH < numLines)) + { + LEAVE_PROC("SMI_AllocateMemory"); + return(NULL); + } + + xf86PurgeUnlockedOffscreenAreas(pScreen); + area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, + 0, NULL, NULL, NULL); + } + + LEAVE_PROC("SMI_AllocateMemory"); + return(area); +} + +static void +SMI_CopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int height, + int width +) +{ + ENTER_PROC("SMI_CopyData"); + + while (height-- > 0) + { + memcpy(dst, src, width); + src += srcPitch; + dst += dstPitch; + } + + LEAVE_PROC("SMI_CopyData"); +} + +static void +SMI_CopyYV12Data( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst, + int srcPitch1, + int srcPitch2, + int dstPitch, + int height, + int width +) +{ + CARD32 *pDst = (CARD32 *) dst; + int i, j; + + ENTER_PROC("SMI_CopyYV12Data"); + + for (j = 0; j < height; j++) + { + for (i =0; i < width; i++) + { + pDst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + pDst += dstPitch >> 2; + src1 += srcPitch1; + if (j & 1) + { + src2 += srcPitch2; + src3 += srcPitch2; + } + } + + LEAVE_PROC("SMI_CopyYV12Data"); +} + +static int +SMI_AllocSurface( + ScrnInfoPtr pScrn, + int id, + unsigned short width, + unsigned short height, + XF86SurfacePtr surface +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int numLines, pitch, fbPitch, bpp; + SMI_OffscreenPtr ptrOffscreen; + FBAreaPtr area; + + ENTER_PROC("SMI_AllocSurface"); + + if ((width > pSmi->lcdWidth) || (height > pSmi->lcdHeight)) + { + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + + if (pSmi->Bpp == 3) + { + fbPitch = pSmi->Stride; + } + else + { + fbPitch = pSmi->Stride * pSmi->Bpp; + } + + width = (width + 1) & ~1; + switch (id) + { + case FOURCC_YV12: + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + bpp = 2; + break; + + case FOURCC_RV24: + bpp = 3; + break; + + case FOURCC_RV32: + bpp = 4; + break; + + default: + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + pitch = (width * bpp + 15) & ~15; + + numLines = ((height * pitch) + fbPitch - 1) / fbPitch; + + area = SMI_AllocateMemory(pScrn, NULL, numLines); + if (area == NULL) + { + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + + surface->pitches = xalloc(sizeof(int)); + if (surface->pitches == NULL) + { + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + surface->offsets = xalloc(sizeof(int)); + if (surface->offsets == NULL) + { + xfree(surface->pitches); + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + + ptrOffscreen = xalloc(sizeof(SMI_OffscreenRec)); + if (ptrOffscreen == NULL) + { + xfree(surface->offsets); + xfree(surface->pitches); + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return(BadAlloc); + } + + surface->pScrn = pScrn; + surface->id = id; + surface->width = width; + surface->height = height; + surface->pitches[0] = pitch; + surface->offsets[0] = area->box.y1 * fbPitch; + surface->devPrivate.ptr = (pointer) ptrOffscreen; + + ptrOffscreen->area = area; + ptrOffscreen->isOn = FALSE; + + LEAVE_PROC("SMI_AllocSurface"); + return(Success); +} + +static int +SMI_FreeSurface( + XF86SurfacePtr surface +) +{ + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + + ENTER_PROC("SMI_FreeSurface"); + + if (ptrOffscreen->isOn) + { + SMI_StopSurface(surface); + } + + xf86FreeOffscreenArea(ptrOffscreen->area); + xfree(surface->pitches); + xfree(surface->offsets); + xfree(surface->devPrivate.ptr); + + LEAVE_PROC("SMI_FreeSurface"); + return(Success); +} + +static int +SMI_DisplaySurface( + XF86SurfacePtr surface, + short vid_x, + short vid_y, + short drw_x, + short drw_y, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + RegionPtr clipBoxes +) +{ + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + SMIPtr pSmi = SMIPTR(surface->pScrn); + SMI_PortPtr ptrPort = pSmi->ptrAdaptor->pPortPrivates[0].ptr; + INT32 x1, y1, x2, y2; + BoxRec dstBox; + + ENTER_PROC("SMI_DisplaySurface"); + + x1 = vid_x; + x2 = vid_x + vid_w; + y1 = vid_y; + y2 = vid_y + vid_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if (!SMI_ClipVideo(surface->pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, + surface->width, surface->height)) + { + LEAVE_PROC("SMI_DisplaySurface"); + return(Success); + } + + dstBox.x1 -= surface->pScrn->frameX0; + dstBox.y1 -= surface->pScrn->frameY0; + dstBox.x2 -= surface->pScrn->frameX0; + dstBox.y2 -= surface->pScrn->frameY0; + + XAAFillSolidRects(surface->pScrn, ptrPort->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); + + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + + ptrOffscreen->isOn = TRUE; + if (ptrPort->videoStatus & CLIENT_VIDEO_ON) + { + REGION_EMPTY(pScrn->pScreen, &ptrPort->clip); + UpdateCurrentTime(); + ptrPort->videoStatus = FREE_TIMER; + ptrPort->freeTime = currentTime.milliseconds + FREE_DELAY; + } + + LEAVE_PROC("SMI_DisplaySurface"); + return(Success); +} + +static int +SMI_StopSurface( + XF86SurfacePtr surface +) +{ + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + + ENTER_PROC("SMI_StopSurface"); + + if (ptrOffscreen->isOn) + { + SMIPtr pSmi = SMIPTR(surface->pScrn); + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + ptrOffscreen->isOn = FALSE; + } + + LEAVE_PROC("SMI_StopSurface"); + return(Success); +} + +static int +SMI_GetSurfaceAttribute( + ScrnInfoPtr pScrn, + Atom attr, + INT32 *value +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + return(SMI_GetPortAttribute(pScrn, attr, value, + (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr)); +} + +static int +SMI_SetSurfaceAttribute( + ScrnInfoPtr pScrn, + Atom attr, + INT32 value +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + return(SMI_SetPortAttribute(pScrn, attr, value, + (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr)); +} +#else /* XvExtension */ +void SMI_InitVideo(ScreenPtr pScreen) {} +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.h:1.1 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.h Tue Nov 28 15:59:20 2000 @@ -0,0 +1,81 @@ +/* Header: //Mercury/Projects/archives/XFree86/4.0/smi_video.h.-arc 1.8 27 Nov 2000 15:46:06 Frido $ */ + +/* +Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. +Copyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the XFree86 Project and +Silicon Motion shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the XFree86 Project and silicon Motion. +*/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.h,v 1.1 2000/11/28 20:59:20 dawes Exp $ */ + +#ifndef _SMI_VIDEO_H +#define _SMI_VIDEO_H + +#include <fourcc.h> + +#define SMI_VIDEO_VIDEO 0 +#define SMI_VIDEO_IMAGE 1 + +#define FOURCC_RV15 0x35315652 +#define FOURCC_RV16 0x36315652 +#define FOURCC_RV24 0x34325652 +#define FOURCC_RV32 0x32335652 + +#define OFF_DELAY 200 /* milliseconds */ +#define FREE_DELAY 60000 /* milliseconds */ + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +#define SAA7110 0x9C + +typedef struct +{ + FBAreaPtr area; + RegionRec clip; + CARD32 colorKey; + CARD32 brightness; + CARD32 videoStatus; + Time offTime; + Time freeTime; + int i2cDevice; + +} SMI_PortRec, *SMI_PortPtr; + +typedef struct +{ + FBAreaPtr area; + Bool isOn; + +} SMI_OffscreenRec, *SMI_OffscreenPtr; + +typedef struct +{ + CARD8 address; + CARD8 data; + +} SMI_I2CDataRec, *SMI_I2CDataPtr; + +#endif /* _SMI_VIDEO_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile:1.16 xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile:1.22 --- xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile:1.16 Fri Jun 30 13:15:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile Fri Dec 1 20:16:16 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile,v 1.16 2000/06/30 17:15:13 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile,v 1.22 2000/12/02 01:16:16 dawes Exp $ XCOMM XCOMM This is an Imakefile for the SIS driver. XCOMM @@ -6,28 +6,40 @@ #define IHaveModules #include <Server.tmpl> +#if BuildXF86DRI +DRISRCS = sis_dri.c +DRIOBJS = sis_dri.o +DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \ + -I$(XTOP)/include +DRIDEFINES = $(GLX_DEFINES) +#endif + SRCS = sis_driver.c sis_dac.c sis_cursor.c sis_accel.c sis_setup.c\ - sis530_accel.c sis300_accel.c sis_vga.c sis_tv.c sis_lcd.c\ - sis_opt.c sis_bios.c sis_dga.c + sis530_accel.c sis300_accel.c sis_vga.c sis_vb.c sis_video.c\ + sis_opt.c init300.c init301.c sis_dga.c $(DRISRCS) OBJS = sis_driver.o sis_dac.o sis_cursor.o sis_accel.o sis_setup.o\ - sis530_accel.o sis300_accel.o sis_vga.o sis_tv.o sis_lcd.o\ - sis_opt.o sis_bios.o sis_dga.o + sis530_accel.o sis300_accel.o sis_vga.o sis_vb.o sis_video.o\ + sis_opt.o init300.o init301.o sis_dga.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ - -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ - -I$(XF86SRC)/xf24_32bpp \ + -I$(SERVERSRC)/fb -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ + -I$(XF86SRC)/xf24_32bpp \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ - -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ - -I$(XF86SRC)/rac \ + -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/rac \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(XTOP)/include/extensions + -I$(XTOP)/include/extensions \ + -I$(SERVERSRC)/render \ + $(DRIINCLUDES) #endif +DEFINES = $(DRIDEFINES) + #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) #endif @@ -47,27 +59,24 @@ InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/sis) +InstallDriverSDKNonExecFile(init300.c,$(DRIVERSDKDIR)/drivers/sis) +InstallDriverSDKNonExecFile(init301.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis300_accel.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis300_accel.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis530_accel.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_accel.c,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_bios.c,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_bios.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_cursor.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_cursor.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_dac.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_dga.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_driver.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_driver.h,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_lcd.c,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_lcd.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_opt.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_regs.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_regs2.h,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_setup.c,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_tv.c,$(DRIVERSDKDIR)/drivers/sis) -InstallDriverSDKNonExecFile(sis_tv.h,$(DRIVERSDKDIR)/drivers/sis) +InstallDriverSDKNonExecFile(sis_vb.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKNonExecFile(sis_vga.c,$(DRIVERSDKDIR)/drivers/sis) InstallDriverSDKObjectModule(sis,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/sis/init300.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/init300.c:1.6 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/init300.c Sat Dec 2 10:30:50 2000 @@ -0,0 +1,1119 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init300.c,v 1.6 2000/12/02 15:30:50 tsi Exp $ */ + +#include "xf86.h" +#include "xf86PciInfo.h" + +#include "sis.h" +#include "sis_regs.h" +#include "init300.h" + +VOID SetReg1(USHORT, USHORT, USHORT); +VOID SetReg3(USHORT, USHORT); +VOID SetReg4(USHORT, ULONG); +USHORT GetReg1(USHORT, USHORT); +USHORT GetReg2(USHORT); +ULONG GetReg3(USHORT); +Bool SiSSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + SISPtr pSiS = SISPTR(pScrn); + ULONG temp; + USHORT cr30flag,cr31flag; + ULONG ROMAddr = (ULONG) SISPTR(pScrn)->BIOS; + USHORT BaseAddr = (USHORT) (SISPTR(pScrn)->RelIO +0x30); + USHORT ModeNo=0; + USHORT Rate; + USHORT tempal,i,Part1Port; + + P3c4=BaseAddr+0x14; + P3d4=BaseAddr+0x24; + P3c0=BaseAddr+0x10; + P3ce=BaseAddr+0x1e; + P3c2=BaseAddr+0x12; + P3ca=BaseAddr+0x1a; + P3c6=BaseAddr+0x16; + P3c7=BaseAddr+0x17; + P3c8=BaseAddr+0x18; + P3c9=BaseAddr+0x19; + P3da=BaseAddr+0x2A; + + ModeNo = CalcModeIndex(pScrn, mode); + Rate = CalcRefreshRate(pScrn, mode); + SetReg1(P3d4, 0x33, Rate); + + SetReg1(P3c4, 0x20, 0xa1); + SetReg1(P3c4, 0x1E, 0x5A); + + if(pSiS->VBFlags & VB_LVDS) + IF_DEF_LVDS = 1; + else + IF_DEF_LVDS = 0; + if(pSiS->VBFlags & VB_CHRONTEL) + IF_DEF_CH7005 = 1; + else + IF_DEF_CH7005 = 0; + + +/* ynlai begin */ + IF_DEF_HiVision=0; +/* ynlai end */ + + PresetScratchregister(P3d4); /* add for CRT2 */ + /* replace GetSenseStatus,SetTVSystem,SetDisplayInfo */ + + DisplayOff(); + SetReg1(P3c4,0x05,0x86); /* 1.Openkey */ + temp=SearchModeID(ROMAddr,ModeNo); /* 2.Get ModeID Table */ + if(temp==0) return(0); + + /* SetTVSystem(); */ /* add for CRT2 */ + /*GetLCDDDCInfo(pScrn);*/ /* add for CRT2 */ + GetVBInfo(BaseAddr,ROMAddr); /* add for CRT2 */ + GetLCDResInfo(ROMAddr, P3d4); /* add for CRT2 */ + + temp=CheckMemorySize(ROMAddr); /* 3.Check memory size */ + if(temp==0) return(0); + cr30flag=(UCHAR)GetReg1(P3d4,0x30); + if(((cr30flag&0x01)==1)||((cr30flag&0x02)==0)){ + /* if cr30 d[0]=1 or d[1]=0 set crt1 */ + SetReg1(P3d4,0x34,ModeNo); + /* set CR34->CRT1 ModeNofor CRT2 FIFO */ + GetModePtr(ROMAddr,ModeNo); /* 4.GetModePtr */ + SetSeqRegs(ROMAddr); /* 5.SetSeqRegs */ + SetMiscRegs(ROMAddr); /* 6.SetMiscRegs */ + SetCRTCRegs(ROMAddr); /* 7.SetCRTCRegs */ + SetATTRegs(ROMAddr); /* 8.SetATTRegs */ + SetGRCRegs(ROMAddr); /* 9.SetGRCRegs */ + ClearExt1Regs(); /* 10.Clear Ext1Regs */ + temp=GetRatePtr(ROMAddr,ModeNo); /* 11.GetRatePtr */ + if(temp) { + SetSync(ROMAddr); /* 12.SetSync */ + SetCRT1CRTC(ROMAddr); /* 13.SetCRT1CRTC */ + SetCRT1Offset(ROMAddr); /* 14.SetCRT1Offset */ + SetCRT1VCLK(ROMAddr); /* 15.SetCRT1VCLK */ + SetVCLKState(ROMAddr, ModeNo); + if( (pSiS->Chipset == PCI_CHIP_SIS630) || (pSiS->Chipset == PCI_CHIP_SIS540) ) + SetCRT1FIFO2(ROMAddr); + else + SetCRT1FIFO(ROMAddr); + } + SetCRT1ModeRegs(ROMAddr, ModeNo); + if( (pSiS->Chipset == PCI_CHIP_SIS630) || (pSiS->Chipset == PCI_CHIP_SIS540) ) + SetInterlace(ROMAddr,ModeNo); + LoadDAC(ROMAddr); + } + cr31flag=(UCHAR)GetReg1(P3d4,0x31); + if(((cr30flag&0x01)==1)||((cr30flag&0x03)==0x02)|| + (((cr30flag&0x03)==0x00)&&((cr31flag&0x20)==0x20))) { + /* if CR30 d[0]=1 or d[1:0]=10, set CRT2 or cr30 cr31== 0x00 0x20 */ + SetCRT2Group(BaseAddr,ROMAddr,ModeNo, pScrn); /* add for CRT2 */ + } + +/* ynlai begin test */ +/* ynlai end test */ + + SetPitch(pScrn, BaseAddr); /* 16.SetPitch */ + WaitVertical(); + DisplayOn(); /* 17.DisplayOn */ + return TRUE; +} + +BOOLEAN SearchModeID(ULONG ROMAddr, USHORT ModeNo) +{ + UCHAR ModeID; + USHORT usIDLength; + + ModeIDOffset=*((USHORT *)(ROMAddr+0x20A)); /* Get EModeIDTable */ + ModeID=*((UCHAR *)(ROMAddr+ModeIDOffset)); /* Offset 0x20A */ + usIDLength = GetModeIDLength(ROMAddr, ModeNo); + while(ModeID!=0xff && ModeID!=ModeNo) { +/* ModeIDOffset=ModeIDOffset+10; */ /*StructSize */ + ModeIDOffset=ModeIDOffset+usIDLength; + ModeID=*((UCHAR *)(ROMAddr+ModeIDOffset)); + } + if(ModeID==0xff) return(FALSE); + else return(TRUE); +} + +BOOLEAN CheckMemorySize(ULONG ROMAddr) +{ + USHORT memorysize; + USHORT modeflag; + USHORT temp; + + modeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + ModeType=modeflag&ModeInfoFlag; /* Get mode type */ + + memorysize=modeflag&MemoryInfoFlag; + memorysize=memorysize>MemorySizeShift; + memorysize++; /* Get memory size */ + + temp=GetReg1(P3c4,0x14); /* Get DRAM Size */ + temp=temp&0x3F; + temp++; + + if(temp<memorysize) return(FALSE); + else return(TRUE); +} + +VOID GetModePtr(ULONG ROMAddr, USHORT ModeNo) +{ + UCHAR index; + + StandTable=*((USHORT *)(ROMAddr+0x202)); /* Get First 0x202 */ + /* StandTable Offset */ + if(ModeNo<=13) { + index=*((UCHAR *)(ROMAddr+ModeIDOffset+0x03)); /* si+St_ModeFlag */ + } + else { + if(ModeType <= 0x02) index=0x1B; /* 02 -> ModeEGA */ + else index=0x0F; + } + StandTable=StandTable+64*index; +} + +VOID SetSeqRegs(ULONG ROMAddr) +{ + UCHAR SRdata; + USHORT i; + + SetReg1(P3c4,0x00,0x03); /* Set SR0 */ + StandTable=StandTable+0x05; + SRdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get SR01 from file */ + if(IF_DEF_LVDS==1){ + if(IF_DEF_CH7005==1) { + if(VBInfo&SetCRT2ToTV) { + if(VBInfo&SetInSlaveMode) { + SRdata=SRdata|0x01; + } + } + } + if(VBInfo&SetCRT2ToLCD){ + if(VBInfo&SetInSlaveMode){ + if(LCDInfo&LCDNonExpanding){ + SRdata=SRdata|0x01; + } + } + } + } + SRdata=SRdata|0x20; + SetReg1(P3c4,0x01,SRdata); /* Set SR1 */ + for(i=02;i<=04;i++) { + StandTable++; + SRdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get SR2,3,4 from file */ + SetReg1(P3c4,i,SRdata); /* Set SR2 3 4 */ + } +} + +VOID SetMiscRegs(ULONG ROMAddr) +{ + UCHAR Miscdata; + + StandTable++; + Miscdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get Misc from file */ + SetReg3(P3c2,Miscdata); /* Set Misc(3c2) */ +} + +VOID SetCRTCRegs(ULONG ROMAddr) +{ + UCHAR CRTCdata; + USHORT i; + + CRTCdata=(UCHAR)GetReg1(P3d4,0x11); + CRTCdata=CRTCdata&0x7f; + SetReg1(P3d4,0x11,CRTCdata); /* Unlock CRTC */ + + for(i=0;i<=0x18;i++) { + StandTable++; + CRTCdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get CRTC from file */ + SetReg1(P3d4,i,CRTCdata); /* Set CRTC(3d4) */ + } +} + +VOID SetATTRegs(ULONG ROMAddr) +{ + UCHAR ARdata; + USHORT i; + + for(i=0;i<=0x13;i++) { + StandTable++; + ARdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get AR for file */ + if(IF_DEF_LVDS==1){ /*for LVDS*/ + if(IF_DEF_CH7005==1) { + if(VBInfo&SetCRT2ToTV) { + if(VBInfo&SetInSlaveMode) { + if(i==0x13) ARdata=0; + } + } + } + if(VBInfo&SetCRT2ToLCD){ + if(VBInfo&SetInSlaveMode){ + if(i==0x13) ARdata=0; + } + } + } + GetReg2(P3da); /* reset 3da */ + SetReg3(P3c0,i); /* set index */ + SetReg3(P3c0,ARdata); /* set data */ + } + + GetReg2(P3da); /* reset 3da */ + SetReg3(P3c0,0x14); /* set index */ + SetReg3(P3c0,0x00); /* set data */ + GetReg2(P3da); /* Enable Attribute */ + SetReg3(P3c0,0x20); +} + +VOID SetGRCRegs(ULONG ROMAddr) +{ + UCHAR GRdata; + USHORT i; + + for(i=0;i<=0x08;i++) { + StandTable++; + GRdata=*((UCHAR *)(ROMAddr+StandTable)); /* Get GR from file */ + SetReg1(P3ce,i,GRdata); /* Set GR(3ce) */ + } + if(ModeType>ModeVGA){ + GRdata=(UCHAR)GetReg1(P3ce,0x05); + GRdata=GRdata&0xBF; + SetReg1(P3ce,0x05,GRdata); + } +} + +VOID ClearExt1Regs() +{ + USHORT i; + + for(i=0x0A;i<=0x0E;i++) SetReg1(P3c4,i,0x00); /* Clear SR0A-SR0E */ +} + + +BOOLEAN GetRatePtr(ULONG ROMAddr, USHORT ModeNo) +{ + SHORT index; + USHORT temp; + USHORT ulRefIndexLength; + + if(ModeNo<0x14) return(FALSE); /* Mode No <= 13h then return */ + + index=GetReg1(P3d4,0x33); /* Get 3d4 CRTC33 */ + index=index&0x0F; /* Frame rate index */ + if(index!=0) index--; + REFIndex=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); /* si+Ext_point */ + + ulRefIndexLength = GetRefindexLength(ROMAddr, ModeNo); + do { + temp=*((USHORT *)(ROMAddr+REFIndex)); /* di => REFIndex */ + if(temp==0xFFFF) break; + temp=temp&ModeInfoFlag; + if(temp<ModeType) break; + + REFIndex=REFIndex+ulRefIndexLength; /* rate size */ + index--; + } while(index>=0); + + REFIndex=REFIndex-ulRefIndexLength; /* rate size */ + return(TRUE); +} + +VOID SetSync(ULONG ROMAddr) +{ + USHORT sync; + USHORT temp; + + sync=*((USHORT *)(ROMAddr+REFIndex)); /* di+0x00 */ + sync=sync&0xC0; + temp=0x2F; + temp=temp|sync; + SetReg3(P3c2,temp); /* Set Misc(3c2) */ +} + +VOID SetCRT1CRTC(ULONG ROMAddr) +{ + UCHAR index; + UCHAR data; + USHORT i; + + index=*((UCHAR *)(ROMAddr+REFIndex+0x02)) & 0x3F; /* Get index */ + CRT1Table=*((USHORT *)(ROMAddr+0x204)); /* Get CRT1Table */ + CRT1Table=CRT1Table+index*CRT1Len; + + data=(UCHAR)GetReg1(P3d4,0x11); + data=data&0x7F; + SetReg1(P3d4,0x11,data); /* Unlock CRTC */ + + CRT1Table--; + for(i=0;i<=0x05;i++) { + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + SetReg1(P3d4,i,data); + } + for(i=0x06;i<=0x07;i++) { + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + SetReg1(P3d4,i,data); + } + for(i=0x10;i<=0x12;i++) { + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + SetReg1(P3d4,i,data); + } + for(i=0x15;i<=0x16;i++) { + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + SetReg1(P3d4,i,data); + } + for(i=0x0A;i<=0x0C;i++) { + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + SetReg1(P3c4,i,data); + } + + CRT1Table++; + data=*((UCHAR *)(ROMAddr+CRT1Table)); + data=data&0xE0; + SetReg1(P3c4,0x0E,data); + + data=(UCHAR)GetReg1(P3d4,0x09); + data=data&0xDF; + i=*((UCHAR *)(ROMAddr+CRT1Table)); + i=i&0x01; + i=i<<5; + data=data|i; + i=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + i=i&DoubleScanMode; + if(i) data=data|0x80; + SetReg1(P3d4,0x09,data); + + if(ModeType>0x03) SetReg1(P3d4,0x14,0x4F); +} + +VOID SetCRT1Offset(ULONG ROMAddr) +{ + USHORT temp,ah,al; + USHORT temp2,i; + USHORT DisplayUnit; + + temp=*((UCHAR *)(ROMAddr+ModeIDOffset+0x03)); /* si+Ext_ModeInfo */ + temp=temp>>4; /* index */ + ScreenOffset=*((USHORT *)(ROMAddr+0x206)); /* ScreenOffset */ + temp=*((UCHAR *)(ROMAddr+ScreenOffset+temp)); /* data */ + + temp2=*((USHORT *)(ROMAddr+REFIndex+0x00)); + temp2=temp2&InterlaceMode; + if(temp2) temp=temp<<1; + temp2=ModeType-ModeEGA; + switch (temp2) { + case 0 : temp2=1; break; + case 1 : temp2=2; break; + case 2 : temp2=4; break; + case 3 : temp2=4; break; + case 4 : temp2=6; break; + case 5 : temp2=8; break; + } + temp=temp*temp2; + DisplayUnit=temp; + + temp2=temp; + temp=temp>>8; /* ah */ + temp=temp&0x0F; + i=GetReg1(P3c4,0x0E); + i=i&0xF0; + i=i|temp; + SetReg1(P3c4,0x0E,i); + + temp=(UCHAR)temp2; + temp=temp&0xFF; /* al */ + SetReg1(P3d4,0x13,temp); + + temp2=*((USHORT *)(ROMAddr+REFIndex+0x00)); + temp2=temp2&InterlaceMode; + if(temp2) DisplayUnit>>=1; + + DisplayUnit=DisplayUnit<<5; + ah=(DisplayUnit&0xff00)>>8; + al=DisplayUnit&0x00ff; + if(al==0) ah=ah+1; + else ah=ah+2; + SetReg1(P3c4,0x10,ah); +} + +VOID SetCRT1VCLK(ULONG ROMAddr) +{ + USHORT i; + UCHAR index,data; + + index=*((UCHAR *)(ROMAddr+REFIndex+0x03)) & 0x3F; + CRT1VCLKLen=GetVCLKLen(ROMAddr); + data=index*CRT1VCLKLen; + VCLKData=*((USHORT *)(ROMAddr+0x208)); + VCLKData=VCLKData+data; + + SetReg1(P3c4,0x31,0); + for(i=0x2B;i<=0x2C;i++) { + data=*((UCHAR *)(ROMAddr+VCLKData)); + SetReg1(P3c4,i,data); + VCLKData++; + } + SetReg1(P3c4,0x2D,0x80); +} + + +VOID SetCRT1ModeRegs(ULONG ROMAddr, USHORT ModeNo) +{ + USHORT data,data2,data3; + + if(ModeNo>0x13) data=*((USHORT *)(ROMAddr+REFIndex+0x00)); + else data=0; + data2=0; + if(ModeNo>0x13) + if(ModeType>0x02) { + data2=data2|0x02; + data3=ModeType-ModeVGA; + data3=data3<<2; + data2=data2|data3; + } + + data=data&InterlaceMode; + if(data) data2=data2|0x20; + SetReg1(P3c4,0x06,data2); + + data=GetReg1(P3c4,0x01); + data=data&0xF7; + data2=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + data2=data2&HalfDCLK; + if(data2) data=data|0x08; + SetReg1(P3c4,0x01,data); + + data=GetReg1(P3c4,0x0F); + data=data&0xF7; + data2=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + data2=data2&LineCompareOff; + if(data2) data=data|0x08; + SetReg1(P3c4,0x0F,data); + + data=GetReg1(P3c4,0x21); + data=data&0x1F; + if(ModeType==0x00) data=data|0x60; /* Text Mode */ + else if(ModeType<=0x02) data=data|0x00; /* EGA Mode */ + else data=data|0xA0; /* VGA Mode */ + SetReg1(P3c4,0x21,data); +} + +VOID SetVCLKState(ULONG ROMAddr, USHORT ModeNo) +{ + USHORT data,data2; + USHORT VCLK; + UCHAR index; + + index=*((UCHAR *)(ROMAddr+REFIndex+0x03)); + CRT1VCLKLen=GetVCLKLen(ROMAddr); + data=index*CRT1VCLKLen; + VCLKData=*((USHORT *)(ROMAddr+0x208)); + VCLKData=VCLKData+data+(CRT1VCLKLen-2); + VCLK=*((USHORT *)(ROMAddr+VCLKData)); + if(ModeNo<=0x13) VCLK=0; + + data=GetReg1(P3c4,0x07); + data=data&0x7B; + if(VCLK>=150) data=data|0x80; /* VCLK > 150 */ + SetReg1(P3c4,0x07,data); + + data=GetReg1(P3c4,0x32); + data=data&0xD7; + if(VCLK>=150) data=data|0x08; /* VCLK > 150 */ + SetReg1(P3c4,0x32,data); + + data2=0x03; + if(VCLK>135) data2=0x02; + if(VCLK>160) data2=0x01; + if(VCLK>260) data2=0x00; + data=GetReg1(P3c4,0x07); + data=data&0xFC; + data=data|data2; + SetReg1(P3c4,0x07,data); +} + +VOID LoadDAC(ULONG ROMAddr) +{ + USHORT data,data2; + USHORT time,i,j,k; + USHORT m,n,o; + USHORT si,di,bx,dl; + USHORT al,ah,dh; + USHORT *table=0; + + data=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + data=data&DACInfoFlag; + time=64; + if(data==0x00) table=MDA_DAC; + if(data==0x08) table=CGA_DAC; + if(data==0x10) table=EGA_DAC; + if(data==0x18) { + time=256; + table=VGA_DAC; + } + if(time==256) j=16; + else j=time; + + SetReg3(P3c6,0xFF); + SetReg3(P3c8,0x00); + + for(i=0;i<j;i++) { + data=table[i]; + for(k=0;k<3;k++) { + data2=0; + if(data&0x01) data2=0x2A; + if(data&0x02) data2=data2+0x15; + SetReg3(P3c9,data2); + data=data>>2; + } + } + + if(time==256) { + for(i=16;i<32;i++) { + data=table[i]; + for(k=0;k<3;k++) SetReg3(P3c9,data); + } + si=32; + for(m=0;m<9;m++) { + di=si; + bx=si+0x04; + dl=0; + for(n=0;n<3;n++) { + for(o=0;o<5;o++) { + dh=table[si]; + ah=table[di]; + al=table[bx]; + si++; + WriteDAC(dl,ah,al,dh); + } /* for 5 */ + si=si-2; + for(o=0;o<3;o++) { + dh=table[bx]; + ah=table[di]; + al=table[si]; + si--; + WriteDAC(dl,ah,al,dh); + } /* for 3 */ + dl++; + } /* for 3 */ + si=si+5; + } /* for 9 */ + } +} + +VOID WriteDAC(USHORT dl, USHORT ah, USHORT al, USHORT dh) +{ + USHORT temp; + USHORT bh,bl; + + bh=ah; + bl=al; + if(dl!=0) { + temp=bh; + bh=dh; + dh=temp; + if(dl==1) { + temp=bl; + bl=dh; + dh=temp; + } + else { + temp=bl; + bl=bh; + bh=temp; + } + } + SetReg3(P3c9,(USHORT)dh); + SetReg3(P3c9,(USHORT)bh); + SetReg3(P3c9,(USHORT)bl); +} + +VOID DisplayOn() +{ + USHORT data; + + data=GetReg1(P3c4,0x01); + data=data&0xDF; + SetReg1(P3c4,0x01,data); +} + +VOID DisplayOff() +{ + USHORT data; + + data=GetReg1(P3c4,0x01); + data=data|0x20; + SetReg1(P3c4,0x01,data); +} + +VOID SetReg1(USHORT port, USHORT index, USHORT data) +{ + outb(port ,(UCHAR)(index & 0xff)); + port++; + outb(port ,(UCHAR)(data & 0xff)); +} + +VOID SetReg3(USHORT port, USHORT data) +{ + outb(port, (UCHAR)(data & 0xff)); +} + +USHORT GetReg1(USHORT port, USHORT index) +{ + UCHAR data; + + outb(port, (UCHAR)(index & 0xff)); + port += 1; + data = inb(port); + return(data); +} + +USHORT GetReg2(USHORT port) +{ + UCHAR data; + + data = inb(port); + + return(data); +} + +USHORT GetModeIDLength(ULONG ROMAddr, USHORT ModeNo) +{ + UCHAR ModeID; + USHORT modeidlength; + USHORT usModeIDOffset; + + return(10); + modeidlength=0; + usModeIDOffset=*((USHORT *)(ROMAddr+0x20A)); /* Get EModeIDTable */ + ModeID=*((UCHAR *)(ROMAddr+usModeIDOffset)); /* Offset 0x20A */ + while(ModeID!=0x2E) { + modeidlength++; + usModeIDOffset=usModeIDOffset+1; /* 10 <= ExtStructSize */ + ModeID=*((UCHAR *)(ROMAddr+usModeIDOffset)); + } + return(modeidlength); +} + +USHORT GetRefindexLength(ULONG ROMAddr, USHORT ModeNo) +{ + UCHAR ModeID; + UCHAR temp; + USHORT refindexlength; + USHORT usModeIDOffset; + USHORT usREFIndex; + USHORT usIDLength; + + usModeIDOffset=*((USHORT *)(ROMAddr+0x20A)); /* Get EModeIDTable */ + ModeID=*((UCHAR *)(ROMAddr+usModeIDOffset)); /* Offset 0x20A */ + usIDLength = GetModeIDLength(ROMAddr, ModeNo); + while(ModeID!=0x40) { + usModeIDOffset=usModeIDOffset+usIDLength; /*10 <= ExtStructSize */ + ModeID=*((UCHAR *)(ROMAddr+usModeIDOffset)); + } + + refindexlength=1; + usREFIndex=*((USHORT *)(ROMAddr+usModeIDOffset+0x04)); /* si+Ext_point */ + usREFIndex++; + temp=*((UCHAR *)(ROMAddr+usREFIndex)); /* di => REFIndex */ + while(temp!=0xFF) { + refindexlength++; + usREFIndex++; + temp=*((UCHAR *)(ROMAddr+usREFIndex)); /* di => REFIndex */ + } + return(refindexlength); +} + +VOID SetInterlace(ULONG ROMAddr, USHORT ModeNo) +{ + ULONG Temp; + USHORT data,Temp2; + + Temp = (ULONG)GetReg1(P3d4, 0x01); + Temp++; + Temp=Temp*8; + + if(Temp==1024) data=0x0035; + else if(Temp==1280) data=0x0048; + else data=0x0000; + + Temp2=*((USHORT *)(ROMAddr+REFIndex+0x00)); + Temp2 &= InterlaceMode; + if(Temp2 == 0) data=0x0000; + + SetReg1(P3d4,0x19,data); + + Temp = (ULONG)GetReg1(P3d4, 0x1A); + Temp2= (USHORT)(Temp & 0xFC); + SetReg1(P3d4,0x1A,(USHORT)Temp); + + Temp = (ULONG)GetReg1(P3c4, 0x0f); + Temp2= (USHORT)Temp & 0xBF; + if(ModeNo==0x37) Temp2=Temp2|0x40; + SetReg1(P3d4,0x1A,(USHORT)Temp2); +} + +VOID SetCRT1FIFO(ULONG ROMAddr) +{ + USHORT index,data,VCLK,data2,MCLKOffset,MCLK,colorth=0; + USHORT ah,bl,A,B; + + index=*((UCHAR *)(ROMAddr+REFIndex+0x03)); + CRT1VCLKLen=GetVCLKLen(ROMAddr); + data=index*CRT1VCLKLen; + VCLKData=*((USHORT *)(ROMAddr+0x208)); + VCLKData=VCLKData+data+(CRT1VCLKLen-2); + VCLK=*((USHORT *)(ROMAddr+VCLKData)); /* Get VCLK */ + + MCLKOffset=*((USHORT *)(ROMAddr+0x20C)); + index=GetReg1(P3c4,0x3A); + index=index&07; + MCLKOffset=MCLKOffset+index*5; + MCLK=*((UCHAR *)(ROMAddr+MCLKOffset+0x03)); /* Get MCLK */ + + data2=ModeType-0x02; + switch (data2) { + case 0 : colorth=1; break; + case 1 : colorth=2; break; + case 2 : colorth=4; break; + case 3 : colorth=4; break; + case 4 : colorth=6; break; + case 5 : colorth=8; break; + } + + do{ +/*==============*/ + B=(USHORT)(CalcDelay(ROMAddr,0)*VCLK*colorth); + B=B/(16*MCLK); + B++; + + A=(CalcDelay(ROMAddr,1)*VCLK*colorth); + A=A/(16*MCLK); + A++; + + if(A<4) A=0; + else A=A-4; + + if(A>B) bl=A; + else bl=B; + + bl++; + if(bl>0x13) { + data=GetReg1(P3c4,0x16); + data=data>>6; + if(data!=0) { + data--; + data=data<<6; + data2=GetReg1(P3c4,0x16); + data2=(data2&0x3f)|data; + SetReg1(P3c4,0x16,data2); + } + else bl=0x13; + } +/*==============*/ + } while(bl>0x13); + + ah=bl; + ah=ah<<4; + ah=ah|0x0f; + SetReg1(P3c4,0x08,ah); + + data=bl; + data=data&0x10; + data=data<<1; + data2=GetReg1(P3c4,0x0F); + data2=data2&0x9f; + data2=data2|data; + SetReg1(P3c4,0x0F,data2); + + data=bl+3; + if(data>0x0f) data=0x0f; + SetReg1(P3c4,0x3b,0x00); + data2=GetReg1(P3c4,0x09); + data2=data2&0xF0; + data2=data2|data; + SetReg1(P3c4,0x09,data2); +} + +USHORT CalcDelay(ULONG ROMAddr,USHORT key) +{ + USHORT data,data2,temp0,temp1; + UCHAR ThLowA[]= {61,3,52,5,68,7,100,11, + 43,3,42,5,54,7, 78,11, + 34,3,37,5,47,7, 67,11}; + UCHAR ThLowB[]= {81,4,72,6,88,8,120,12, + 55,4,54,6,66,8, 90,12, + 42,4,45,6,55,8, 75,12}; + UCHAR ThTiming[]= {1,2,2,3,0,1,1,2}; + + data=GetReg1(P3c4,0x16); + data=data>>6; + data2=GetReg1(P3c4,0x14); + data2=(data2>>4)&0x0C; + data=data|data2; + data=data<1; + if(key==0) { + temp0=(USHORT)ThLowA[data]; + temp1=(USHORT)ThLowA[data+1]; + } + else { + temp0=(USHORT)ThLowB[data]; + temp1=(USHORT)ThLowB[data+1]; + } + + data2=0; + data=GetReg1(P3c4,0x18); + if(data&0x02) data2=data2|0x01; + if(data&0x20) data2=data2|0x02; + if(data&0x40) data2=data2|0x04; + + data=temp1*ThTiming[data2]+temp0; + return(data); +} + +VOID SetCRT1FIFO2(ULONG ROMAddr) +{ + USHORT index,data,VCLK,data2,MCLKOffset,MCLK,colorth=0; + USHORT ah,bl,B; + ULONG eax; + + index=*((UCHAR *)(ROMAddr+REFIndex+0x03)); + CRT1VCLKLen=GetVCLKLen(ROMAddr); + data=index*CRT1VCLKLen; + VCLKData=*((USHORT *)(ROMAddr+0x208)); + VCLKData=VCLKData+data+(CRT1VCLKLen-2); + VCLK=*((USHORT *)(ROMAddr+VCLKData)); /* Get VCLK */ + + MCLKOffset=*((USHORT *)(ROMAddr+0x20C)); + index=GetReg1(P3c4,0x1A); + index=index&07; + MCLKOffset=MCLKOffset+index*5; + MCLK=*((USHORT *)(ROMAddr+MCLKOffset+0x03)); /* Get MCLK */ + + data2=ModeType-0x02; + switch (data2) { + case 0 : colorth=1; break; + case 1 : colorth=1; break; + case 2 : colorth=2; break; + case 3 : colorth=2; break; + case 4 : colorth=3; break; + case 5 : colorth=4; break; + } + + do{ +/*==============*/ + B=(CalcDelay2(ROMAddr,0)*VCLK*colorth); + if (B%(16*MCLK) == 0) + { + B=B/(16*MCLK); + bl=B+1; + } + else + { + B=B/(16*MCLK); + bl=B+2; + } + + if(bl>0x13) { + data=GetReg1(P3c4,0x15); + data=data&0xf0; + if(data!=0xb0) { + data=data+0x20; + if(data==0xa0) data=0x30; + + data2=GetReg1(P3c4,0x15); + data2=(data2&0x0f)|data; + SetReg1(P3c4,0x15,data2); + } + else bl=0x13; + } +/*==============*/ + } while(bl>0x13); + + data2=GetReg1(P3c4,0x15); + data2=(data2&0xf0)>>4; + data2=data2<<24; + +/* ========================*/ + SetReg4(0xcf8,0x80000050); + eax=GetReg3(0xcfc); + eax=eax&0x0f0ffffff; + eax=eax|data2; + SetReg4(0xcfc,eax); +/* ========================*/ + + ah=bl; + ah=ah<<4; + ah=ah|0x0f; + SetReg1(P3c4,0x08,ah); + + data=bl; + data=data&0x10; + data=data<<1; + data2=GetReg1(P3c4,0x0F); + data2=data2&0x9f; + data2=data2|data; + SetReg1(P3c4,0x0F,data2); + + data=bl+3; + if(data>0x0f) data=0x0f; + SetReg1(P3c4,0x3b,0x00); + data2=GetReg1(P3c4,0x09); + data2=data2&0xF0; + data2=data2|data; + SetReg1(P3c4,0x09,data2); +} + +USHORT CalcDelay2(ULONG ROMAddr,USHORT key) +{ + USHORT data,index; + UCHAR LatencyFactor[]={88,80,78,72,70,00, + 00,79,77,71,69,49, + 88,80,78,72,70,00, + 00,72,70,64,62,44}; + + index=0; + data=GetReg1(P3c4,0x14); + if(data&0x80) index=index+12; + + data=GetReg1(P3c4,0x15); + data=(data&0xf0)>>4; + if(data&0x01) index=index+6; + + data=data>>1; + index=index+data; + data=LatencyFactor[index]; + + return(data); +} + +VOID SetReg4(USHORT port, ULONG data) +{ + outl(port, (ULONG)(data & 0xffffffff)); +} + +ULONG GetReg3(USHORT port) +{ + ULONG data; + + data = inl(port); + return(data); +} + +VOID SetPitch(ScrnInfoPtr pScrn, USHORT BaseAddr) +{ + SISPtr pSiS = SISPTR(pScrn); + ULONG HDisplay; + ULONG temp; + USHORT Port = BaseAddr + IND_SIS_CRT2_PORT_04; + + HDisplay = pSiS->scrnOffset / 8; + SetReg1(P3d4, 0x13, HDisplay); + temp = (GetReg1(P3c4, 0x0E) & 0xF0) | (HDisplay>>8); + SetReg1(P3c4, 0x0E, temp); + + SetReg1(Port, 0x24, 1); + SetReg1(Port, 0x07, HDisplay); + temp = (GetReg1(Port, 0x09) & 0xF0) | (HDisplay>>8); + SetReg1(Port, 0x09, temp); + + +} +USHORT CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + USHORT i = (pScrn->bitsPerPixel+7)/8 - 1; + USHORT ModeIndex = 0; + switch(mode->HDisplay) + { + case 640: + ModeIndex = ModeIndex_640x480[i]; + break; + case 720: + if(mode->VDisplay == 480) + ModeIndex = ModeIndex_720x480[i]; + else + ModeIndex = ModeIndex_720x576[i]; + break; + case 800: + ModeIndex = ModeIndex_800x600[i]; + break; + case 1024: + ModeIndex = ModeIndex_1024x768[i]; + break; + case 1280: + ModeIndex = ModeIndex_1280x1024[i]; + break; + case 1600: + ModeIndex = ModeIndex_1600x1200[i]; + break; + } + + return(ModeIndex); +} +USHORT CalcRefreshRate(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + SISPtr pSiS = SISPTR(pScrn); + USHORT Index=0; + USHORT i=0; + USHORT Rate=1; + USHORT temp = (int)(mode->VRefresh+0.5); + + switch(mode->HDisplay) + { + case 640: + Index = 0; + break; + case 800: + Index = 1; + break; + case 1024: + Index = 2; + Rate = 2; + break; + case 1280: + Index = 3; + Rate = 2; + break; + case 1600: + Index = 4; + break; + case 720: + if(mode->VDisplay == 480) + Index = 5; + else + Index = 6; + break; + + } + while(RefreshRate[Index][i] != 0) + { + if(temp == RefreshRate[Index][i]) + { + Rate=i+1; + break; + } + else + i++; + } + if(pSiS->VBFlags & CRT2_VGA) + Rate |= Rate << 4; + return(Rate); +} + +VOID WaitVertical(VOID) +{ + USHORT tempax,tempdx; + +/* tempdx=0x3da; + do { + tempax=GetReg2(tempdx); + } while(!(tempax&01)); + + do { + tempax=GetReg2(tempdx); + } while(!(tempax&01)); +*/ + +} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/init300.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/init300.h:1.4 --- /dev/null Mon Dec 18 14:31:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/init300.h Fri Dec 1 20:16:16 2000 @@ -0,0 +1,120 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init300.h,v 1.4 2000/12/02 01:16:16 dawes Exp $ */ + +#include "initdef.h" + +USHORT DRAMType[17][5]={{0x0C,0x0A,0x02,0x40,0x39},{0x0D,0x0A,0x01,0x40,0x48}, + {0x0C,0x09,0x02,0x20,0x35},{0x0D,0x09,0x01,0x20,0x44}, + {0x0C,0x08,0x02,0x10,0x31},{0x0D,0x08,0x01,0x10,0x40}, + {0x0C,0x0A,0x01,0x20,0x34},{0x0C,0x09,0x01,0x08,0x32}, + {0x0B,0x08,0x02,0x08,0x21},{0x0C,0x08,0x01,0x08,0x30}, + {0x0A,0x08,0x02,0x04,0x11},{0x0B,0x0A,0x01,0x10,0x28}, + {0x09,0x08,0x02,0x02,0x01},{0x0B,0x09,0x01,0x08,0x24}, + {0x0B,0x08,0x01,0x04,0x20},{0x0A,0x08,0x01,0x02,0x10}, + {0x09,0x08,0x01,0x01,0x00}}; + +USHORT MDA_DAC[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15, + 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}; + +USHORT CGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, + 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F, + 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, + 0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F}; + +USHORT EGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x05,0x15, + 0x20,0x30,0x24,0x34,0x21,0x31,0x25,0x35, + 0x08,0x18,0x0C,0x1C,0x09,0x19,0x0D,0x1D, + 0x28,0x38,0x2C,0x3C,0x29,0x39,0x2D,0x3D, + 0x02,0x12,0x06,0x16,0x03,0x13,0x07,0x17, + 0x22,0x32,0x26,0x36,0x23,0x33,0x27,0x37, + 0x0A,0x1A,0x0E,0x1E,0x0B,0x1B,0x0F,0x1F, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F}; + +USHORT VGA_DAC[]={0x00,0x10,0x04,0x14,0x01,0x11,0x09,0x15, + 0x2A,0x3A,0x2E,0x3E,0x2B,0x3B,0x2F,0x3F, + 0x00,0x05,0x08,0x0B,0x0E,0x11,0x14,0x18, + 0x1C,0x20,0x24,0x28,0x2D,0x32,0x38,0x3F, + + 0x00,0x10,0x1F,0x2F,0x3F,0x1F,0x27,0x2F, + 0x37,0x3F,0x2D,0x31,0x36,0x3A,0x3F,0x00, + 0x07,0x0E,0x15,0x1C,0x0E,0x11,0x15,0x18, + 0x1C,0x14,0x16,0x18,0x1A,0x1C,0x00,0x04, + 0x08,0x0C,0x10,0x08,0x0A,0x0C,0x0E,0x10, + 0x0B,0x0C,0x0D,0x0F,0x10}; + +USHORT ModeIndex_640x480[] = {0x2E, 0x44, 0x45, 0x62}; +USHORT ModeIndex_720x480[] = {0x31, 0x33, 0x00, 0x35}; +USHORT ModeIndex_720x576[] = {0x32, 0x34, 0x00, 0x36}; +USHORT ModeIndex_800x600[] = {0x30, 0x47, 0x48, 0x63}; +USHORT ModeIndex_1024x768[] = {0x38, 0x4A, 0x4B, 0x64}; +USHORT ModeIndex_1280x1024[] = {0x3A, 0x4D, 0x4E, 0x65}; +USHORT ModeIndex_1600x1200[] = {0x3C, 0x3D, 0x3E, 0x66}; +USHORT RefreshRate[7][8] = { + {60, 72, 75, 85, 100, 120, 160, 200}, + {56, 60, 72, 75, 85, 100, 120, 160}, + {43, 60, 70, 75, 85, 100, 120, 0}, + {43, 60, 75, 85, 0, 0, 0, 0}, + {60, 65, 70, 75, 85, 0, 0, 0}, + {60, 0 , 0 , 0 , 0 , 0 , 0 , 0 }, + {60, 0 , 0 , 0 , 0 , 0 , 0 , 0 }}; + +USHORT P3c4,P3d4,P3c0,P3ce,P3c2,P3ca,P3c6,P3c7,P3c8,P3c9,P3da; +USHORT CRT1VCLKLen; /*VCLKData table length of bytes of each entry*/ +USHORT flag_clearbuffer; /*0: no clear frame buffer 1:clear frame buffer*/ +int RAMType; +int ModeIDOffset,StandTable,CRT1Table,ScreenOffset,VCLKData,MCLKData, ECLKData; +int REFIndex,ModeType; +USHORT IF_DEF_LVDS; +USHORT IF_DEF_HiVision; +USHORT IF_DEF_CH7005; +USHORT VBInfo,LCDResInfo,LCDTypeInfo,LCDInfo; + +USHORT CalcRefreshRate(ScrnInfoPtr, DisplayModePtr); +USHORT CalcModeIndex(ScrnInfoPtr, DisplayModePtr); +BOOLEAN SearchModeID(ULONG, USHORT); +BOOLEAN CheckMemorySize(ULONG); +VOID GetModePtr(ULONG, USHORT); +BOOLEAN GetRatePtr(ULONG, USHORT); +VOID SetSeqRegs(ULONG); +VOID SetMiscRegs(ULONG); +VOID SetCRTCRegs(ULONG); +VOID SetATTRegs(ULONG); +VOID SetGRCRegs(ULONG); +VOID ClearExt1Regs(VOID); +VOID SetSync(ULONG); +VOID SetCRT1CRTC(ULONG); +VOID SetCRT1Offset(ULONG); +VOID SetCRT1FIFO(ULONG); +VOID SetCRT1FIFO2(ULONG); +VOID SetCRT1VCLK(ULONG); +VOID LoadDAC(ULONG); +VOID DisplayOn(); +VOID DisplayOff(); +VOID SetPitch(ScrnInfoPtr, USHORT); +VOID SetCRT1ModeRegs(ULONG, USHORT); +VOID SetVCLKState(ULONG, USHORT); +VOID WriteDAC(USHORT, USHORT, USHORT, USHORT); +USHORT GetModeIDLength(ULONG, USHORT); +USHORT GetRefindexLength(ULONG, USHORT); +VOID SetInterlace(ULONG, USHORT); +USHORT CalcDelay2(ULONG ,USHORT); +USHORT CalcDelay(ULONG ,USHORT); +VOID WaitVertical(VOID); + +extern BOOLEAN SetCRT2Group(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +extern VOID GetVBInfo(USHORT BaseAddr,ULONG ROMAddr); +extern VOID PresetScratchregister(USHORT P3d4); +extern BOOLEAN GetLCDResInfo(ULONG ROMAddr, USHORT P3d4); +extern VOID SetTVSystem(); +extern BOOLEAN GetLCDDDCInfo(ScrnInfoPtr pScrn); +extern USHORT GetVCLKLen(ULONG ROMAddr); +extern USHORT Part1[]; Index: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c:1.3 --- /dev/null Mon Dec 18 14:31:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c Fri Dec 1 20:16:16 2000 @@ -0,0 +1,3150 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.3 2000/12/02 01:16:16 dawes Exp $ */ + +#include "xf86.h" +#include "xf86PciInfo.h" + +#include "sis.h" +#include "sis_regs.h" + +#include "init301.h" + +BOOLEAN SetCRT2Group(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo, ScrnInfoPtr pScrn) +{ + USHORT temp; + + SetFlag=SetFlag|ProgrammingCRT2; + SearchModeID(ROMAddr,ModeNo); + temp=GetRatePtrCRT2(ROMAddr,ModeNo); + if(((temp&0x02)==0) && ((VBInfo&CRT2DisplayFlag)==0)) + return(FALSE); + SaveCRT2Info(ModeNo); + DisableBridge(BaseAddr); + UnLockCRT2(BaseAddr); + SetDefCRT2ExtRegs(BaseAddr); + SetCRT2ModeRegs(BaseAddr,ModeNo); + if(IF_DEF_LVDS==0) { + if(VBInfo&CRT2DisplayFlag){ + LockCRT2(BaseAddr); + return 0; + } + } + GetCRT2Data(ROMAddr,ModeNo); + if(IF_DEF_LVDS==1) { + GetLVDSDesData(ROMAddr,ModeNo); + } + SetGroup1(BaseAddr,ROMAddr,ModeNo,pScrn); + if(IF_DEF_LVDS==0) { + SetGroup2(BaseAddr,ROMAddr,ModeNo); + SetGroup3(BaseAddr,ROMAddr); + SetGroup4(BaseAddr,ROMAddr,ModeNo); + SetGroup5(BaseAddr,ROMAddr); + } + else { + if(IF_DEF_CH7005==1) SetCHTVReg(ROMAddr,ModeNo); + ModCRT1CRTC(ROMAddr,ModeNo); + SetCRT2ECLK(ROMAddr,ModeNo); + } + EnableCRT2(); + EnableBridge(BaseAddr); + if(IF_DEF_LVDS==0) { + /* SetLockRegs(); */ + } + LockCRT2(BaseAddr); + return 1; +} + +VOID SetDefCRT2ExtRegs(USHORT BaseAddr) +{ + USHORT Part1Port,Part2Port,Part4Port; + USHORT temp; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; + Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; + if(IF_DEF_LVDS==0) { + SetReg1(Part1Port,0x02,0x40); + SetReg1(Part4Port,0x10,0x80); + temp=(UCHAR)GetReg1(P3c4,0x16); + temp=temp&0xC3; + SetReg1(P3d4,0x35,temp); + } + else { + SetReg1(P3d4,0x32,0x02); + SetReg1(Part1Port,0x02,0x00); + } +} + +USHORT GetRatePtrCRT2(ULONG ROMAddr, USHORT ModeNo) +{ /* return bit0=>0:standard mode 1:extended mode */ + SHORT index; /* bit1=>0:crt2 no support this mode */ + USHORT temp; /* 1:crt2 support this mode */ + USHORT ulRefIndexLength; + USHORT temp1,modeflag1,Flag; + SHORT LCDRefreshIndex[2]={0x03,0x01}; + + if(IF_DEF_CH7005==1) { + if(VBInfo&SetCRT2ToTV) { + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&HalfDCLK) return(0); + } + } + if(ModeNo<0x14) return(0); /* Mode No <= 13h then return */ + + index=GetReg1(P3d4,0x33); /* Get 3d4 CRTC33 */ + index=index>>SelectCRT2Rate; /* For CRT2,cl=SelectCRT2Rate=4, shr ah,cl */ + index=index&0x0F; /* Frame rate index */ + if(index!=0) index--; + + if(SetFlag&ProgrammingCRT2){ + Flag=1; + if(IF_DEF_CH7005==1) { + if(VBInfo&SetCRT2ToTV) { + index=0; + Flag=0; + } + } + if((Flag)&&(VBInfo&SetCRT2ToLCD)){ + if(IF_DEF_LVDS==0) { + temp=LCDResInfo; + temp1=LCDRefreshIndex[temp]; + if(index>temp1){ + index=temp1; + } + } + else { + index=0; + } + } + } + + REFIndex=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); /* si+Ext_point */ + + ulRefIndexLength =Ext2StructSize; + do { + temp=*((USHORT *)(ROMAddr+REFIndex)); /* di => REFIndex */ + if(temp==0xFFFF) break; + temp=temp&ModeInfoFlag; + if(temp<ModeType) break; + + REFIndex=REFIndex+ulRefIndexLength; /* rate size */ + index--; + if(index<0){ + if(!(VBInfo&SetCRT2ToRAMDAC)){ + if(VBInfo&SetInSlaveMode){ + temp1=*((USHORT *)(ROMAddr+REFIndex+0-Ext2StructSize)); + if(temp1&InterlaceMode){ + index=0; + } + } + } + } + } while(index>=0); + REFIndex=REFIndex-ulRefIndexLength; /* rate size */ + + if((SetFlag&ProgrammingCRT2)){ + temp1=AjustCRT2Rate(ROMAddr); + }else{ + temp1=0; + } + + return(0x01|(temp1<<1)); +} + +BOOLEAN AjustCRT2Rate(ULONG ROMAddr) +{ + USHORT tempax,tempbx=0,temp,resinfo; + USHORT tempextinfoflag,Flag; + tempax=0; + if(IF_DEF_LVDS==0) { + if(VBInfo&SetCRT2ToRAMDAC){ + tempax=tempax|SupportRAMDAC2; + } + if(VBInfo&SetCRT2ToLCD){ + tempax=tempax|SupportLCD; + if(LCDResInfo!=Panel1280x1024){ + temp=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); /* si+Ext_ResInfo */ + if(temp>=9) tempax=0; + } + } +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + tempax=tempax|SupportHiVisionTV; + if(VBInfo&SetInSlaveMode){ + resinfo=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); /*si+Ext_ResInfo */ + if(resinfo==4) return(0); + if(resinfo==3) { + if(SetFlag&TVSimuMode) return(0); + } + if(resinfo>7) return(0); + } + } + else { + if(VBInfo&(SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)){ + tempax=tempax|SupportTV; + if(!(VBInfo&SetPALTV)){ + tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); /* di+Ext_InfoFlag */ + if(tempextinfoflag&NoSupportSimuTV){ + if(VBInfo&SetInSlaveMode){ + if(!(VBInfo&SetNotSimuMode)){ + return 0; + } + } + } + } + } + } +/* ynlai end */ + tempbx=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); /* si+Ext_point */ + } + else { /* for LVDS */ + Flag=1; + if(IF_DEF_CH7005==1) { + if(VBInfo&SetCRT2ToTV) { + tempax=tempax|SupportCHTV; + Flag=0; + } + } + tempbx=*((USHORT *)(ROMAddr+ModeIDOffset+0x04)); + if((Flag)&&(VBInfo&SetCRT2ToLCD)){ + tempax=tempax|SupportLCD; + temp=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); /*si+Ext_ResInfo */ + if(temp>0x08) return(0); /*1024x768 */ + if(LCDResInfo<Panel1024x768){ + if(temp>0x07) return(0); /*800x600 */ + if(temp==0x04) return(0); /*512x384 */ + } + } + } + for(;REFIndex>tempbx;REFIndex-=Ext2StructSize){ + tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); /* di+Ext_InfoFlag */ + if(tempextinfoflag&tempax){ + return 1; + } + } + for(REFIndex=tempbx;;REFIndex+=Ext2StructSize){ + tempextinfoflag=*((USHORT *)(ROMAddr+REFIndex+0x0)); /* di+Ext_InfoFlag */ + if(tempextinfoflag==0x0FFFF){ + return 0; + } + if(tempextinfoflag&tempax){ + return 1; + } + } + return(FALSE); +} + +VOID SaveCRT2Info(USHORT ModeNo) +{ + USHORT temp1,temp2,temp3; + temp1=(VBInfo&SetInSlaveMode)>>8; + temp2=~(SetInSlaveMode>>8); + temp3=(UCHAR)GetReg1(P3d4,0x31); + temp3=((temp3&temp2)|temp1); + SetReg1(P3d4,0x31,(USHORT)temp3); + temp3=(UCHAR)GetReg1(P3d4,0x35); + temp3=temp3&0xF3; + SetReg1(P3d4,0x35,(USHORT)temp3); +} + +VOID DisableLockRegs(){ + UCHAR temp3; + temp3=(UCHAR)GetReg1(P3c4,0x32); + temp3=temp3&0xDF; + SetReg1(P3c4,0x32,(USHORT)temp3); +} + +VOID DisableCRT2(){ + UCHAR temp3; + temp3=(UCHAR)GetReg1(P3c4,0x1E); + temp3=temp3&0xDF; + SetReg1(P3c4,0x1E,(USHORT)temp3); +} + +VOID DisableBridge(USHORT BaseAddr) +{ + UCHAR temp3,part2_02,part2_05; + USHORT Part2Port,Part1Port=0; + Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; + + if(IF_DEF_LVDS==0) { + part2_02=(UCHAR)GetReg1(Part2Port,0x02); + part2_05=(UCHAR)GetReg1(Part2Port,0x05); +/* if(!WaitVBRetrace(BaseAddr)) */ /* return 0:no enable read dram */ + { + LongWait(); + DisableLockRegs(); + } + SetReg1(Part2Port,0x02,0x38); + SetReg1(Part2Port,0x05,0xFF); + temp3=(UCHAR)GetReg1(Part2Port,0x00); + temp3=temp3&0xDF; + SetReg1(Part2Port,0x00,(USHORT)temp3); + SetReg1(Part2Port,0x02,part2_02); + SetReg1(Part2Port,0x05,part2_05); + DisableCRT2(); + } + else { + DisableLockRegs(); + DisableCRT2(); + UnLockCRT2(BaseAddr); + SetRegANDOR(Part1Port,0x02,0xFF,0x40); /*et Part1Port ,index 2, D6=1, */ + } +} + +VOID GetCRT2Data(ULONG ROMAddr,USHORT ModeNo) +{ + if(IF_DEF_LVDS==0){ /*301 */ + GetCRT2Data301(ROMAddr,ModeNo); + return; + }else{ /*LVDS */ + GetCRT2DataLVDS(ROMAddr,ModeNo); + return; + } +} + +VOID GetCRT2DataLVDS(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempax,tempbx,OldREFIndex; + + OldREFIndex=(USHORT)REFIndex; /*push di */ + GetResInfo(ROMAddr,ModeNo); + GetCRT2Ptr(ROMAddr,ModeNo); + + tempax=*((USHORT *)(ROMAddr+REFIndex)); + tempax=tempax&0x0FFF; + VGAHT=tempax; + + tempax=*((USHORT *)(ROMAddr+REFIndex+1)); + tempax=tempax>>4; + tempax=tempax&0x07FF; + VGAVT=tempax; +/* VGAVT=518; */ + + tempax=*((USHORT *)(ROMAddr+REFIndex+3)); + tempax=tempax&0x0FFF; + tempbx=*((USHORT *)(ROMAddr+REFIndex+4)); + tempbx=tempbx>>4; + tempbx=tempbx&0x07FF; + + HT=tempax; + VT=tempbx; + + if(IF_DEF_TRUMPION==0){ + if(VBInfo&SetCRT2ToLCD){ + if(!(LCDInfo&LCDNonExpanding)){ + if(LCDResInfo==Panel800x600){ + tempax=800; + tempbx=600; + }else if(LCDResInfo==Panel1024x768){ + tempax=1024; + tempbx=768; + }else{ + tempax=1280; + tempbx=1024; + } + HDE=tempax; + VDE=tempbx; + } + } + } + REFIndex=OldREFIndex; /*pop di */ + return; +} + +VOID GetCRT2Data301(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempax,tempbx,modeflag1,OldREFIndex; + USHORT tempal,tempah,tempbl,resinfo; + + OldREFIndex=REFIndex; /* push di */ + RVBHRS=50;NewFlickerMode=0;RY1COE=0; + RY2COE=0;RY3COE=0;RY4COE=0; + + GetResInfo(ROMAddr,ModeNo); + if(VBInfo&SetCRT2ToRAMDAC){ + GetRAMDAC2DATA(ROMAddr,ModeNo); + REFIndex=OldREFIndex; /* pop di */ + return; + } + GetCRT2Ptr(ROMAddr,ModeNo); + + tempal=*((UCHAR *)(ROMAddr+REFIndex)); + tempah=*((UCHAR *)(ROMAddr+REFIndex+4)); + tempax=tempal|(((tempah<<8)>>7)&0xFF00); + RVBHCMAX=tempax; + + tempal=*((UCHAR *)(ROMAddr+REFIndex+1)); + RVBHCFACT=tempal; + + tempax=*((USHORT *)(ROMAddr+REFIndex+2)); + VGAHT=(tempax&0x0FFF); + + tempax=*((USHORT *)(ROMAddr+REFIndex+3)); + VGAVT=((tempax>>4)&0x07FF); + + tempax=*((USHORT *)(ROMAddr+REFIndex+5)); + tempax=(tempax&0x0FFF); + tempbx=*((USHORT *)(ROMAddr+REFIndex+6)); + tempbx=((tempbx>>4)&0x07FF); + tempbl=tempbx&0x00FF; + + if(VBInfo&SetCRT2ToTV){ + tempax=*((USHORT *)(ROMAddr+REFIndex+5)); + tempax=(tempax&0x0FFF); + HDE=tempax; + tempax=*((USHORT *)(ROMAddr+REFIndex+6)); + tempax=((tempax>>4)&0x07FF); + VDE=tempax; + tempax=*((USHORT *)(ROMAddr+REFIndex+8)); + tempbl=(tempax>>8); + tempax=tempax&0x0FFF; + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&HalfDCLK){ + tempax=*((USHORT *)(ROMAddr+REFIndex+10)); + } + RVBHRS=tempax; +/* ynlai begin */ + tempbl=tempbl&0x80; + if(IF_DEF_HiVision==1) { + resinfo=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); /* si+Ext_ResInfo */ + if(resinfo==8) tempbl=0x40; + else if(resinfo==9) tempbl=0x40; + else if(resinfo==10) tempbl=0x40; + } +/* ynlai end */ + NewFlickerMode=tempbl; + +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + if(VGAVDE==350) SetFlag=SetFlag|TVSimuMode; + tempax=ExtHiTVHT; + tempbx=ExtHiTVVT; + if(VBInfo&SetInSlaveMode) { + if(SetFlag&TVSimuMode) { + tempax=StHiTVHT; + tempbx=StHiTVVT; + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(!(modeflag1&Charx8Dot)){ + tempax=StHiTextTVHT; + tempbx=StHiTextTVVT; + } + } + } + } + else { + tempax=*((USHORT *)(ROMAddr+REFIndex+12)); + RY1COE=(tempax&0x00FF); + RY2COE=((tempax&0xFF00)>>8); + tempax=*((USHORT *)(ROMAddr+REFIndex+14)); + RY3COE=(tempax&0x00FF); + RY4COE=((tempax&0xFF00)>>8); + if(!(VBInfo&SetPALTV)){ + tempax=NTSCHT; + tempbx=NTSCVT; + }else{ + tempax=PALHT; + tempbx=PALVT; + } + } +/* ynlai end */ + } + HT=tempax; + VT=tempbx; + if(!(VBInfo&SetCRT2ToLCD)){ + REFIndex=OldREFIndex; /* pop di */ + return; + } + + tempax=1024; + if(VGAVDE==350){ /* cx->VGAVDE */ + tempbx=560; + }else if(VGAVDE==400){ + tempbx=640; + }else{ + tempbx=768; + } + + if(LCDResInfo==Panel1280x1024){ + tempax=1280; + if(VGAVDE==360){ + tempbx=768; + }else if(VGAVDE==375){ + tempbx=800; + }else if(VGAVDE==405){ + tempbx=864; + }else{ + tempbx=1024; + } + } + + HDE=tempax; + VDE=tempbx; + REFIndex=OldREFIndex; /* pop di */ + return; +} + +VOID GetResInfo(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT temp,xres,yres,modeflag1; + if(ModeNo<=0x13){ + temp=(USHORT)*((UCHAR *)(ROMAddr+ModeIDOffset+0x05)); /* si+St_ResInfo */ + xres=StResInfo[temp][0]; + yres=StResInfo[temp][1]; + }else{ + temp=(USHORT)*((UCHAR *)(ROMAddr+ModeIDOffset+0x09)); /* si+Ext_ResInfo */ + xres=ModeResInfo[temp][0]; /* xres->ax */ + yres=ModeResInfo[temp][1]; /* yres->bx */ + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&HalfDCLK){ xres=xres*2;} + if(modeflag1&DoubleScanMode){yres=yres*2;} + } + if(!(LCDResInfo==Panel1024x768)){ + if(yres==400) yres=405; + if(yres==350) yres=360; + if(SetFlag&LCDVESATiming){ + if(yres==360) yres=375; + } + } + if(IF_DEF_LVDS==1) { + if(xres==720) xres=640; + } + VGAHDE=xres; + HDE=xres; + VGAVDE=yres; + VDE=yres; +} + +VOID GetLVDSDesData(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT old_REFIndex,tempax; + + old_REFIndex=(USHORT)REFIndex; /*push di */ + REFIndex=GetLVDSDesPtr(ROMAddr,ModeNo); + + tempax=*((USHORT *)(ROMAddr+REFIndex)); + tempax=tempax&0x0FFF; + LCDHDES=tempax; + + if(LCDInfo&LCDNonExpanding){ /*hw walk-a-round */ + if(LCDResInfo>=Panel1024x768){ + if(ModeNo<=0x13){ + LCDHDES=320; + } + } + } + + tempax=*((USHORT *)(ROMAddr+REFIndex+1)); + tempax=tempax>>4; + tempax=tempax&0x07FF; + LCDVDES=tempax; + + REFIndex=old_REFIndex; /*pop di */ + return; +} + + +VOID GetRAMDAC2DATA(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempax,tempbx,tempbh,modeflag1,t1=0,t2; + RVBHCMAX=1;RVBHCFACT=1; + if(ModeNo<=0x13){ + tempax=*((UCHAR *)(ROMAddr+REFIndex+10)); + tempbx=*((USHORT *)(ROMAddr+REFIndex+16)); + }else{ + t1=*((UCHAR *)(ROMAddr+REFIndex+0x2)); /* Ext_CRT1CRTC=2 */ + t1=t1*CRT1Len; + REFIndex=*((USHORT *)(ROMAddr+0x204)); /* Get CRT1Table */ + REFIndex=REFIndex+t1; + t1=*((UCHAR *)(ROMAddr+REFIndex+0)); + t2=*((UCHAR *)(ROMAddr+REFIndex+14)); + tempax=(t1&0xFF)|((t2&0x03)<<8); + tempbx=*((USHORT *)(ROMAddr+REFIndex+6)); + t1=*((UCHAR *)(ROMAddr+REFIndex+13)); + t1=(t1&0x01)<<2; + } + + tempbh=tempbx>>8; + tempbh=((tempbh&0x20)>>4)|(tempbh&0x01); + tempbh=tempbh|t1; + tempbx=(tempbx&0xFF)|(tempbh<<8); + tempax=tempax+5; + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&Charx8Dot){ + tempax=tempax*8; + }else{ + tempax=tempax*9; + } + + VGAHT=tempax; + HT=tempax; + tempbx++; + VGAVT=tempbx; + VT=tempbx; + +} + +VOID GetCRT2Ptr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempcl,tempbx,tempal,tempax,CRT2PtrData=0; + USHORT Flag; + + if(IF_DEF_LVDS==0) { + if(VBInfo&SetCRT2ToLCD){ /* LCD */ + tempbx=LCDResInfo; + tempcl=LCDDataLen; + tempbx=tempbx-Panel1024x768; + if(!(SetFlag&LCDVESATiming)) tempbx+=5; + } +/* ynlai begin */ + else { + if(IF_DEF_HiVision==1) { + if(VGAVDE>480) SetFlag=SetFlag&(!TVSimuMode); + tempcl=HiTVDataLen; + tempbx=2; + if(VBInfo&SetInSlaveMode) { + if(!(SetFlag&TVSimuMode)) tempbx=10; + } + } + else { + if(VBInfo&SetPALTV){ + tempcl=TVDataLen; + tempbx=3; + } + else{ + tempbx=4; + tempcl=TVDataLen; + } + } + } +/* ynlai end */ + if(SetFlag&TVSimuMode){ + tempbx=tempbx+4; + } + if(ModeNo<=0x13){ + tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + }else{ + tempal=*((UCHAR *)(ROMAddr+REFIndex+4)); /* di+Ext_CRT2CRTC */ + } + tempal=tempal&0x1F; + + tempax=tempal*tempcl; + REFIndex=*((USHORT *)(ROMAddr + 0x20E + tempbx*2)); + REFIndex+=tempax; + } + else { /* LVDS */ + Flag=1; + tempbx=0; + if(IF_DEF_CH7005==1) { + if(!(VBInfo&SetCRT2ToLCD)) { + Flag=0; + tempbx=7; + if(VBInfo&SetPALTV) tempbx=tempbx+2; + if(VBInfo&SetCHTVOverScan) tempbx=tempbx+1; + } + } + tempcl=LVDSDataLen; + if(Flag==1) { + tempbx=LCDResInfo-Panel800x600; + if(LCDInfo&LCDNonExpanding){ + tempbx=tempbx+3; + } + } + if(ModeNo<=0x13) tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + else tempal=*((UCHAR *)(ROMAddr+REFIndex+0x04)); /* di+Ext_CRT2CRTC */ + tempal=tempal&0x1F; + tempax=tempal*tempcl; + CRT2PtrData=*((USHORT *)(ROMAddr+ADR_CRT2PtrData)); /*ADR_CRT2PtrData is defined in init.def */ + REFIndex=*((USHORT *)(ROMAddr+CRT2PtrData+tempbx*2)); + REFIndex+=tempax; + } +} + +VOID UnLockCRT2(USHORT BaseAddr) +{ + UCHAR temp3; + USHORT Part1Port; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + temp3=(UCHAR)GetReg1(Part1Port,0x24); + temp3=temp3|0x01; + SetReg1(Part1Port,0x24,(USHORT)temp3); +} + +VOID SetCRT2ModeRegs(USHORT BaseAddr,USHORT ModeNo) +{ + USHORT i,j; + USHORT tempcl,tempah,temp3; + USHORT Part4Port; + USHORT Part1Port; + Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + for(i=0,j=4;i<3;i++,j++){ + SetReg1(Part1Port,j,0); + } + + tempcl=ModeType; + if(ModeNo>0x13){ + tempcl=tempcl-ModeVGA; + if((tempcl>0)||(tempcl==0)){ + tempah=((0x010>>tempcl)|0x080); + } + }else{ + tempah=0x080; + } + + if(VBInfo&SetInSlaveMode){ + tempah=(tempah^0x0A0); + } + if(VBInfo&CRT2DisplayFlag){ + tempah=0; + } + SetReg1(Part1Port,0,tempah); + + + if(IF_DEF_LVDS==0) { + tempah=0x01; + if(!(VBInfo&SetInSlaveMode)){ + tempah=(tempah|0x02); + } + if(!(VBInfo&SetCRT2ToRAMDAC)){ + tempah=(tempah^0x05); + if(!(VBInfo&SetCRT2ToLCD)){ + tempah=(tempah^0x01); + } + } + tempah=(tempah<<5)&0xFF; + if(VBInfo&CRT2DisplayFlag){ + tempah=0; + } + SetReg1(Part1Port,0x01,tempah); + + tempah=tempah>>5; + if((ModeType==ModeVGA)&&(!(VBInfo&SetInSlaveMode))){ + tempah=tempah|0x010; + } + if(LCDResInfo!=Panel1024x768){ + tempah=tempah|0x080; + } + if(VBInfo&SetCRT2ToTV){ + if(VBInfo&SetInSlaveMode){ + tempah=tempah|0x020; + } + } + + temp3=(UCHAR)GetReg1(Part4Port,0x0D); + temp3=temp3&(~0x0BF); + temp3=temp3|tempah; + SetReg1(Part4Port,0x0D,(USHORT)temp3); + +/* ynlai begin */ + tempah=0; + if(VBInfo&SetCRT2ToTV) { + if(VBInfo&SetInSlaveMode) { + if(!(SetFlag&TVSimuMode)) { + if(IF_DEF_HiVision==0) { + SetFlag=SetFlag|RPLLDIV2XO; + tempah=tempah|0x40; + } + } + } + else { + SetFlag=SetFlag|RPLLDIV2XO; + tempah=tempah|0x40; + } + } + if(LCDResInfo==Panel1280x1024) tempah=tempah|0x80; + if(LCDResInfo==Panel1280x960) tempah=tempah|0x80; + SetReg1(Part4Port,0x0C,(USHORT)temp3); +/* ynlai end */ + } + else { + tempah=0; + if(!(VBInfo&SetInSlaveMode)){ + tempah=tempah|0x02; + } + tempah=(tempah<<5)&0x0FF; + if(VBInfo&CRT2DisplayFlag){ + tempah=0; + } + SetReg1(Part1Port,0x01,tempah); + } +} + +VOID SetGroup1(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo, + ScrnInfoPtr pScrn) +{ + if(IF_DEF_LVDS==0){ /*301 */ + SetGroup1_301(BaseAddr,ROMAddr,ModeNo,pScrn); + }else{ /*LVDS */ + SetGroup1_LVDS(BaseAddr,ROMAddr,ModeNo,pScrn); + } +} + +VOID SetGroup1_LVDS(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo, + ScrnInfoPtr pScrn) +{ + USHORT temp1,temp2,tempcl,tempch,tempbh,tempal,tempah,tempax,tempbx; + USHORT tempcx,OldREFIndex,lcdhdee; + USHORT Part1Port; + USHORT temppush1,temppush2; + unsigned long int tempeax,tempebx,tempecx,templong; + + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + OldREFIndex=(USHORT)REFIndex; /*push di */ + + SetCRT2Offset(Part1Port,ROMAddr); + SetCRT2FIFO(Part1Port,ROMAddr,ModeNo,pScrn); + SetCRT2Sync(BaseAddr,ROMAddr,ModeNo); + + temp1=(VGAHT-1)&0x0FF; /*BTVGA2HT 0x08,0x09 */ + SetReg1(Part1Port,0x08,temp1); + temp1=(((VGAHT-1)&0xFF00)>>8)<<4; + SetRegANDOR(Part1Port,0x09,~0x0F0,temp1); + + + temp1=(VGAHDE+12)&0x0FF; /*BTVGA2HDEE 0x0A,0x0C */ + SetReg1(Part1Port,0x0A,temp1); + /*temp1=((VGAHDE+12)&0xFF00)>>8; Wrong */ + /*SetReg1(Part1Port,0x0C,temp1); */ + + temp1=VGAHDE+12; /*bx BTVGA@HRS 0x0B,0x0C */ + temp2=(VGAHT-VGAHDE)>>2; /* */ + temp1=temp1+temp2; + temp2=(temp2<<1)+temp1; + tempcl=temp2&0x0FF; + + SetReg1(Part1Port,0x0B,(USHORT)(temp1&0x0FF)); + tempah=(temp1&0xFF00)>>8; + tempbh=((((VGAHDE+12)&0xFF00)>>8)<<4)&0x0FF; + tempah=tempah|tempbh; + SetReg1(Part1Port,0x0C,tempah); + SetReg1(Part1Port,0x0D,tempcl); /*BTVGA2HRE 0x0D */ + tempcx=(VGAVT-1); + tempah=tempcx&0x0FF; + if(IF_DEF_CH7005==1) { + if(VBInfo&0x0C) tempah=tempah-1; + } + SetReg1(Part1Port,0x0E,tempah); /*BTVGA2TV 0x0E,0x12 */ + tempbx=VGAVDE-1; + tempah=tempbx&0x0FF; + if(IF_DEF_CH7005==1) { + if(VBInfo&0x0C) tempah=tempah-1; + } + SetReg1(Part1Port,0x0F,tempah); /*BTVGA2VDEE 0x0F,0x12 */ + tempah=((tempbx&0xFF00)<<3)>>8; + tempah=tempah|((tempcx&0xFF00)>>8); + SetReg1(Part1Port,0x12,tempah); + + tempbx=(VGAVT+VGAVDE)>>1; /*BTVGA2VRS 0x10,0x11 */ + tempcx=((VGAVT-VGAVDE)>>4)+tempbx+1; /*BTVGA2VRE 0x11 */ + + tempah=tempbx&0x0FF; + SetReg1(Part1Port,0x10,tempah); + tempbh=(tempbx&0xFF00)>>8; + tempah=((tempbh<<4)&0x0FF)|(tempcx&0x0F); + SetReg1(Part1Port,0x11,tempah); + + SetRegANDOR(Part1Port,0x13,~0x03C,tempah); + + /*lines below are newly added for LVDS */ + tempax=LCDHDES; + tempbx=HDE; + tempcx=HT; + tempcx=tempcx-tempbx; /*HT-HDE */ + /*push ax lcdhdes */ + tempax=tempax+tempbx; /*lcdhdee */ + tempbx=HT; + if(tempax>=tempbx){ + tempax=tempax-tempbx; + } + /*push ax lcdhdee */ + lcdhdee=tempax; + tempcx=tempcx>>2; /*temp */ + tempcx=tempcx+tempax; /*lcdhrs */ + if(tempcx>=tempbx){ + tempcx=tempcx-tempbx; + } + /* v ah,cl */ + tempax=tempcx; + tempax=tempax>>3; /*BPLHRS */ + tempah=tempax&0x0FF; + SetReg1(Part1Port,0x14,tempah); /*Part1_14h */ + tempah=tempah+2; + tempah=tempah+0x01F; + tempcl=tempcx&0x0FF; + tempcl=tempcl&0x07; + tempcl=(tempcl<<5)&0xFF; /* PHLHSKEW */ + tempah=tempah|tempcl; + SetReg1(Part1Port,0x15,tempah); /*Part1_15h */ + tempbx=lcdhdee; /*lcdhdee */ + tempcx=LCDHDES; /*lcdhdes */ + tempah=(tempcx&0xFF); + tempah=tempah&0x07; /*BPLHDESKEW */ + SetReg1(Part1Port,0x1A,tempah); /*Part1_1Ah */ + tempcx=tempcx>>3; /*BPLHDES */ + tempah=(tempcx&0xFF); + SetReg1(Part1Port,0x16,tempah); /*Part1_16h */ + tempbx=tempbx>>3; /*BPLHDEE */ + tempah=tempbx&0xFF; + SetReg1(Part1Port,0x17,tempah); /*Part1_17h */ + + tempcx=VGAVT; + tempbx=VGAVDE; + tempcx=tempcx-tempbx; /* GAVT-VGAVDE */ + tempbx=LCDVDES; /*VGAVDES */ + temppush1=tempbx; /*push bx temppush1 */ + if(IF_DEF_TRUMPION==0){ + if(IF_DEF_CH7005==1) tempax=VGAVDE; + if(VBInfo&SetCRT2ToLCD) { + if(LCDResInfo==Panel800x600) tempax=600; + else tempax=768; + } + } + else tempax=VGAVDE; + tempbx=tempbx+tempax; + tempax=VT; /*VT */ + if(tempbx>=VT){ + tempbx=tempbx-tempax; + } + temppush2=tempbx; /*push bx temppush2 */ + tempcx=tempcx>>1; + tempbx=tempbx+tempcx; + tempbx++; /*BPLVRS */ + if(tempbx>=tempax){ + tempbx=tempbx-tempax; + } + tempah=tempbx&0xFF; + SetReg1(Part1Port,0x18,tempah); /*Part1_18h */ + tempcx=tempcx>>3; + tempcx=tempcx+tempbx; + tempcx++; /*BPLVRE */ + tempah=tempcx&0xFF; + tempah=tempah&0x0F; + tempah=tempah|0x030; + SetRegANDOR(Part1Port,0x19,~0x03F,tempah); /*Part1_19h */ + tempbh=(tempbx&0xFF00)>>8; + tempbh=tempbh&0x07; + tempah=tempbh; + tempah=(tempah<<3)&0xFF; /*BPLDESKEW =0 */ + /*movzx */ + tempbx=VGAVDE; + if(tempbx!=VDE){ + tempah=tempah|0x40; + } + SetRegANDOR(Part1Port,0x1A,0x07,tempah); /*Part1_1Ah */ + tempecx=VGAVT; + tempebx=VDE; + tempeax=VGAVDE; + tempecx=tempecx-tempeax; /*VGAVT-VGAVDE */ + tempeax=tempeax*64; + templong=tempeax/tempebx; + if(templong*tempebx<tempeax){ + templong++; + } + tempebx=templong; /*BPLVCFACT */ + if(SetFlag&EnableLVDSDDA){ + tempebx=tempebx&0x03F; + } + tempah=(USHORT)(tempebx&0x0FF); + SetReg1(Part1Port,0x1E,tempah); /*Part1_1Eh */ + tempbx=temppush2; /* p bx temppush2 BPLVDEE */ + tempcx=temppush1; /*pop cx temppush1 NPLVDES */ + tempbh=(tempbx&0xFF00)>>8; + tempah=tempah&0x07; + tempah=tempbh; + tempah=tempah<<3; + tempch=(tempcx&0xFF00)>>8; + tempch=tempch&0x07; + tempah=tempah|tempch; + SetReg1(Part1Port,0x1D,tempah); /*Part1_1Dh */ + tempah=tempbx&0xFF; + SetReg1(Part1Port,0x1C,tempah); /*Part1_1Ch */ + tempah=tempcx&0xFF; + SetReg1(Part1Port,0x1B,tempah); /*Part1_1Bh */ + + tempecx=VGAHDE; + tempebx=HDE; + tempeax=tempecx; + tempeax=tempeax<<6; + tempeax=tempeax<<10; + tempeax=tempeax/tempebx; + if(tempebx==tempecx){ + tempeax=65535; + } + tempecx=tempeax; + tempeax=VGAHT; + tempeax=tempeax<<6; + tempeax=tempeax<<10; + tempeax=tempeax/tempecx; + tempecx=tempecx<<16; + tempeax=tempeax-1; + tempax=(USHORT)(tempeax&0x00FFFF); + tempcx=tempax; + tempah=tempcx&0x0FF; + SetReg1(Part1Port,0x1F,tempah); /*Part1_1Fh */ + tempbx=VDE; + tempbx--; /*BENPLACCEND */ + if(SetFlag&EnableLVDSDDA){ + tempbx=1; + } + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<3)&0xFF; + tempch=(tempcx&0xFF00)>>8; + tempch=tempch&0x07; + tempah=tempah|tempch; + SetReg1(Part1Port,0x20,tempah); /*Part1_20h */ + tempah=tempbx&0xFF; + SetReg1(Part1Port,0x21,tempah); /*Part1_21h */ + tempecx=tempecx>>16; /*BPLHCFACT */ + temp1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(temp1&HalfDCLK){ + tempecx=tempecx>>1; + } + tempcx=(USHORT)(tempecx&0x0FFFF); + tempah=(tempcx&0xFF00)>>8; + SetReg1(Part1Port,0x22,tempah); /*Part1_22h */ + tempah=tempcx&0x0FF; + SetReg1(Part1Port,0x23,tempah); /*Part1_23h */ + if(IF_DEF_TRUMPION==1){ + tempal=(USHORT)*((UCHAR *)(ROMAddr+ModeIDOffset+0x05)); /* si+St_ResInfo */ + if(ModeNo>0x13){ + SetFlag=SetFlag|ProgrammingCRT2; + GetRatePtrCRT2(ROMAddr,ModeNo); + tempal=*((UCHAR *)(ROMAddr+REFIndex+0x04)); /* di+Ext_CRT2CRTC */ + tempal=tempal&0x1F; + } + tempah=0x80; + tempal=tempal*tempah; + REFIndex= offset_Zurac; /*offset Zurac need added in rompost.asm */ + REFIndex=REFIndex+tempal; + SetTPData(); /*this function not implemented yet */ + SetTPData(); + SetTPData(); + SetTPData(); + SetTPData(); + SetTPData(); + SetTPData(); + SetTPData(); + SetTPData(); + } + + REFIndex=OldREFIndex; /*pop di */ + + return; +} + +VOID SetTPData() +{ + return; +} + + +VOID SetGroup1_301(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + USHORT temp1,temp2,tempcl,tempch,tempbl,tempbh,tempal,tempah,tempax,tempbx; + USHORT tempcx,OldREFIndex; + USHORT Part1Port,resinfo,modeflag; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + OldREFIndex=REFIndex; /* push di */ + + SetCRT2Offset(Part1Port,ROMAddr); + SetCRT2FIFO(Part1Port,ROMAddr,ModeNo,pScrn); + SetCRT2Sync(BaseAddr,ROMAddr,ModeNo); + + GetCRT1Ptr(ROMAddr); + + temp1=(VGAHT-1)&0x0FF; /* BTVGA2HT 0x08,0x09 */ + SetReg1(Part1Port,0x08,temp1); + temp1=(((VGAHT-1)&0xFF00)>>8)<<4; + SetRegANDOR(Part1Port,0x09,~0x0F0,temp1); + + temp1=(VGAHDE+12)&0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ + SetReg1(Part1Port,0x0A,temp1); + + temp1=VGAHDE+12; /* bx BTVGA@HRS 0x0B,0x0C */ + temp2=(VGAHT-VGAHDE)>>2; /* cx */ + temp1=temp1+temp2; + temp2=(temp2<<1)+temp1; + tempcl=temp2&0x0FF; + if(VBInfo&SetCRT2ToRAMDAC){ + tempbl=*((UCHAR *)(ROMAddr+REFIndex+4)); /* di+4 */ + tempbh=*((UCHAR *)(ROMAddr+REFIndex+14)); /* di+14 */ + temp1=((tempbh>>6)<<8)|tempbl; /* temp1->bx */ + temp1=(temp1-1)<<3; + tempcl=*((UCHAR *)(ROMAddr+REFIndex+5)); /* di+5 */ + tempch=*((UCHAR *)(ROMAddr+REFIndex+15)); /* di+15 */ + tempcl=tempcl&0x01F; + tempch=(tempch&0x04)<<(6-2); + tempcl=((tempcl|tempch)-1)<<3; + } + SetReg1(Part1Port,0x0B,(USHORT)(temp1&0x0FF)); + tempah=(temp1&0xFF00)>>8; + tempbh=((((VGAHDE+12)&0xFF00)>>8)<<4)&0x0FF; + tempah=tempah|tempbh; + SetReg1(Part1Port,0x0C,tempah); + SetReg1(Part1Port,0x0D,tempcl); /* BTVGA2HRE 0x0D */ + tempcx=(VGAVT-1); + tempah=tempcx&0x0FF; + SetReg1(Part1Port,0x0E,tempah); /* BTVGA2TV 0x0E,0x12 */ + tempbx=VGAVDE-1; + tempah=tempbx&0x0FF; + SetReg1(Part1Port,0x0F,tempah); /* BTVGA2VDEE 0x0F,0x12 */ + tempah=((tempbx&0xFF00)<<3)>>8; + tempah=tempah|((tempcx&0xFF00)>>8); + SetReg1(Part1Port,0x12,tempah); + + tempbx=(VGAVT+VGAVDE)>>1; /* BTVGA2VRS 0x10,0x11 */ + tempcx=((VGAVT-VGAVDE)>>4)+tempbx+1; /* BTVGA2VRE 0x11 */ + if(VBInfo&SetCRT2ToRAMDAC){ + tempbx=*((UCHAR *)(ROMAddr+REFIndex+8)); /* di+8 */ + temp1=*((UCHAR *)(ROMAddr+REFIndex+7)); /* di+7 */ + if(temp1&0x04){ + tempbx=tempbx|0x0100; + } + if(temp1&0x080){ + tempbx=tempbx|0x0200; + } + temp1=*((UCHAR *)(ROMAddr+REFIndex+13)); /* di+13 */ + if(temp1&0x08){ + tempbx=tempbx|0x0400; + } + tempcl= *((UCHAR *)(ROMAddr+REFIndex+9)); /* di+9 */ + tempcx=(tempcx&0xFF00)|(tempcl&0x00FF); + } + tempah=tempbx&0x0FF; + SetReg1(Part1Port,0x10,tempah); + tempbh=(tempbx&0xFF00)>>8; + tempah=((tempbh<<4)&0x0FF)|(tempcx&0x0F); + SetReg1(Part1Port,0x11,tempah); + + if( pSiS->Chipset == PCI_CHIP_SIS300 ){ + tempah=0x10; + if((LCDResInfo!=Panel1024x768)&&(LCDResInfo==Panel1280x1024)) tempah=0x20; + } + else tempah=0x20; + if(VBInfo&SetCRT2ToTV) tempah=0x08; +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + if(VBInfo&SetInSlaveMode) tempah=0x2c; + else tempah=0x20; + } +/* ynlai end */ + SetRegANDOR(Part1Port,0x13,~0x03C,tempah); + + if(!(VBInfo&SetInSlaveMode)){ + REFIndex=OldREFIndex; + return; + } + if(VBInfo&SetCRT2ToTV){ + tempax=0xFFFF; + }else{ + tempax=GetVGAHT2(); + } + tempcl=0x08; /* Reg 0x03 Horozontal Total */ + temp1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(!(temp1&Charx8Dot)){ /* temp1->St_ModeFlag */ + tempcl=0x09; + } + if(tempax>=VGAHT){ + tempax=VGAHT; + } + if(temp1&HalfDCLK){ + tempax=tempax>>1; + } + tempax=(tempax/tempcl)-5; + tempbl=tempax; + tempah=0xFF; /* set MAX HT */ + SetReg1(Part1Port,0x03,tempah); + + tempax=VGAHDE; /* 0x04 Horizontal Display End */ + if(temp1&HalfDCLK){ + tempax=tempax>>1; + } + tempax=(tempax/tempcl)-1; + tempbh=tempax; + SetReg1(Part1Port,0x04,tempax); + + tempah=tempbh; + if(VBInfo&SetCRT2ToTV){ + tempah=tempah+2; + } +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + resinfo=*(USHORT *)(ROMAddr+ModeIDOffset+0x09); /* si+Ext_ResInfo */ + if(resinfo==7) tempah=tempah-2; + } +/* ynlai end */ + SetReg1(Part1Port,0x05,tempah); /* 0x05 Horizontal Display Start */ + SetReg1(Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */ + /* 0x07 horizontal Retrace Start */ +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + tempah=tempbl-1; + modeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(!(modeflag&HalfDCLK)) { + tempah=tempah-6; + if(SetFlag&TVSimuMode) { + tempah=tempah-4; + if(ModeNo>0x13) tempah=tempah-10; + } + } + } +/* ynlai end */ + else { + tempcx=(tempbl+tempbh)>>1; + tempah=(tempcx&0xFF)+2; + + if(VBInfo&SetCRT2ToTV){ + tempah=tempah-1; + if(!(temp1&HalfDCLK)){ + if((temp1&Charx8Dot)){ + tempah=tempah+4; + if(VGAHDE>=800){ + tempah=tempah-6; + } + } + } + }else{ + if(!(temp1&HalfDCLK)){ + tempah=tempah-4; + if(VGAHDE>=800){ + tempah=tempah-7; + if(ModeType==ModeEGA){ + if(VGAVDE==1024){ + tempah=tempah+15; + if(LCDResInfo!=Panel1280x1024){ + tempah=tempah+7; + } + } + } + if(VGAHDE>=1280){ + tempah=tempah+28; + } + } + } + } + } + SetReg1(Part1Port,0x07,tempah); /* 0x07 Horizontal Retrace Start */ + + SetReg1(Part1Port,0x08,0); /* 0x08 Horizontal Retrace End */ + SetReg1(Part1Port,0x18,0x03); /* 0x18 SR08 */ + SetReg1(Part1Port,0x19,0); /* 0x19 SR0C */ + SetReg1(Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ + + tempcx=0x121; + tempcl=0x21; + tempch=0x01; + tempbx=VGAVDE; /* 0x0E Virtical Display End */ + if(tempbx==360) tempbx=350; + if(tempbx==375) tempbx=350; + if(tempbx==405) tempbx=400; + tempbx--; + tempah=tempbx&0x0FF; + SetReg1(Part1Port,0x0E,tempah); + SetReg1(Part1Port,0x10,tempah); /* 0x10 vertical Blank Start */ + tempbh=(tempbx&0xFF00)>>8; + if(tempbh&0x01){ + tempcl=tempcl|0x0A; + } + tempah=0;tempal=0x0B; + if(temp1&DoubleScanMode){ + tempah=tempah|0x080; + } + if(tempbh&0x02){ + tempcl=tempcl|0x040; + tempah=tempah|0x020; + } + SetReg1(Part1Port,0x0B,tempah); + if(tempbh&0x04){ + tempch=tempch|0x06; + } + + SetReg1(Part1Port,0x11,0); /* 0x11 Vertival Blank End */ + + tempax=VGAVT-tempbx; /* 0x0C Vertical Retrace Start */ + tempax=tempax>>2; + temp2=tempax; /* push ax */ + tempax=tempax<<1; + tempbx=tempax+tempbx; +/* ynlai begin */ +/* ynlai end */ + if((SetFlag&TVSimuMode)&&(VBInfo&SetPALTV)&&(VGAHDE==800)){ + tempbx=tempbx+40; + } + tempah=(tempbx&0x0FF); + SetReg1(Part1Port,0x0C,tempah); + tempbh=(tempbx&0xFF00)>>8; + if(tempbh&0x01){ + tempcl=tempcl|0x04; + } + if(tempbh&0x02){ + tempcl=tempcl|0x080; + } + if(tempbh&0x04){ + tempch=tempch|0x08; + } + + tempax=temp2; /* pop ax */ + tempax=(tempax>>2)+1; + tempbx=tempbx+tempax; + tempah=(tempbx&0x0FF)&0x0F; + SetReg1(Part1Port,0x0D,tempah); /* 0x0D vertical Retrace End */ + tempbl=tempbx&0x0FF; + if(tempbl&0x10){ + tempch=tempch|0x020; + } + + tempah=tempcl; + SetReg1(Part1Port,0x0A,tempah); /* 0x0A CR07 */ + tempah=tempch; + SetReg1(Part1Port,0x17,tempah); /* 0x17 SR0A */ + tempax=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + tempah=(tempax&0xFF00)>>8; + tempah=(tempah>>1)&0x09; + SetReg1(Part1Port,0x16,tempah); /* 0x16 SR01 */ + SetReg1(Part1Port,0x0F,0); /* 0x0F CR14 */ + SetReg1(Part1Port,0x12,0); /* 0x12 CR17 */ + SetReg1(Part1Port,0x1A,0); /* 0x1A SR0E */ + + REFIndex=OldREFIndex; /* pop di */ +} + +VOID SetCRT2Offset(USHORT Part1Port,ULONG ROMAddr) +{ + USHORT offset; + if(VBInfo&SetInSlaveMode){ + return; + } + offset=GetOffset(ROMAddr); + SetReg1(Part1Port,0x07,(USHORT)(offset&0xFF)); + SetReg1(Part1Port,0x09,(USHORT)((offset&0xFF00)>>8)); + SetReg1(Part1Port,0x03,(USHORT)(((offset>>3)&0xFF)+1)); +} + +USHORT GetOffset(ULONG ROMAddr) +{ + USHORT tempal,temp1,colordepth; + tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x03)); /* si+Ext_ModeInfo */ + tempal=(tempal>>4)&0xFF; + ScreenOffset=*((USHORT *)(ROMAddr+0x206)); /* Get ScreeOffset table */ + tempal=*((UCHAR *)(ROMAddr+ScreenOffset+tempal)); /* get ScreenOffset */ + tempal=tempal&0xFF; + temp1=*((UCHAR *)(ROMAddr+REFIndex)); /* di+Ext_InfoFlag */ + if(temp1&InterlaceMode){ + tempal=tempal<<1; + } + colordepth=GetColorDepth(ROMAddr); + return(tempal*colordepth); +} + +USHORT GetColorDepth(ULONG ROMAddr) +{ + USHORT ColorDepth[6]={1,2,4,4,6,8}; + USHORT temp; + int temp1; + temp=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + temp1=(temp&ModeInfoFlag)-ModeEGA; + if(temp1<0) temp1=0; + return(ColorDepth[temp1]); +} + +VOID SetCRT2FIFO(USHORT Part1Port,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + USHORT temp,temp1,temp2,temp3,flag; + USHORT vclk2ptr,latencyindex; + USHORT oldREFIndex,CRT1ModeNo,oldModeIDOffset; + long int longtemp; + + USHORT LatencyFactor[48]={ 88, 80, 78, 72, 70, 00, /* 64 bit BQ=2 */ + 00, 79, 77, 71, 69, 49, /* 64 bit BQ=1 */ + 88, 80, 78, 72, 70, 00, /* 128 bit BQ=2 */ + 00, 72, 70, 64, 62, 44, /* 128 bit BQ=1 */ + 73, 65, 63, 57, 55, 00, /* 64 bit BQ=2 */ + 00, 64, 62, 56, 54, 34, /* 64 bit BQ=1 */ + 78, 70, 68, 62, 60, 00, /* 128 bit BQ=2 */ + 00, 62, 60, 54, 52, 34}; /* 128 bit BQ=1 */ + + oldREFIndex=REFIndex; /* push REFIndex(CRT2 now) */ + oldModeIDOffset=ModeIDOffset; /* push ModeIDOffset */ + + CRT1ModeNo=(UCHAR)GetReg1(P3d4,0x34); /* get CRT1 ModeNo */ + SearchModeID(ROMAddr,CRT1ModeNo); /* Get ModeID Table */ + + GetRatePtr(ROMAddr,CRT1ModeNo); /* Set REFIndex-> for crt1 refreshrate */ + temp1=GetVCLK(ROMAddr,CRT1ModeNo); + temp2=GetColorTh(ROMAddr); + temp3=GetMCLK(ROMAddr); + temp=((USHORT)(temp1*temp2)/temp3); /* temp->bx */ + temp1=(UCHAR)GetReg1(P3c4,0x14); /* SR_14 */ + temp1=temp1>>6; + temp1=temp1<<1; + if(temp1==0) temp1=1; + temp1=temp1<<2; /* temp1->ax */ + + longtemp=temp1-temp; + + temp2=(USHORT)((28*16)/(int)longtemp); /* temp2->cx */ + if(!((temp2*(int)longtemp)==(28*16))) temp2++; + + if( pSiS->Chipset == PCI_CHIP_SIS300 ){ + temp1=CalcDelayVB(); + }else{ /* for Trojan and Spartan */ + flag=(UCHAR)GetReg1(P3c4,0x14); /* SR_14 */ + if(flag&0x80){ + latencyindex=12; /* 128 bit */ + }else{ + latencyindex=0; /* 64 bit */ + } + flag=GetQueueConfig(); + if(!(flag&0x01)){ + latencyindex+=24; /* GUI timing =0 */ + } + if(flag&0x10){ + latencyindex+=6; /* BQ =2 */ + } + latencyindex=latencyindex + (flag>>5); + temp1= LatencyFactor[latencyindex]; + temp1=temp1+15; + flag=(UCHAR)GetReg1(P3c4,0x14); /* SR_14 */ + if(!(flag&0x80)){ + temp1=temp1+5; /* 64 bit */ + } + } + + temp2=temp2+temp1; + REFIndex=oldREFIndex; /* pop REFIndex(CRT2) */ + ModeIDOffset=oldModeIDOffset; /* pop ModeIDOffset */ + + vclk2ptr=GetVCLK2Ptr(ROMAddr,ModeNo); + temp1=*((USHORT *)(ROMAddr+vclk2ptr+(VCLKLen-2))); + temp3=GetColorTh(ROMAddr); + longtemp=temp1*temp2*temp3; + temp3=GetMCLK(ROMAddr); + temp3=temp3<<4; + temp2=(int)(longtemp/temp3); + if((long int)temp2*(long int)temp3<(long int)longtemp) + temp2++; /* temp2->cx */ + + temp1=(UCHAR)GetReg1(Part1Port,0x01); /* part1port index 01 */ + temp1=(temp1&(~0x1F))|0x16; + SetReg1(Part1Port,0x01,temp1); + +/* ynlai begin */ + if(IF_DEF_HiVision==1) { if(temp2<=10) temp2=10; } + else { if(temp2<=6) temp2=6; } +/* ynlai end */ + if(temp2>0x14) temp2=0x14; + temp1=(UCHAR)GetReg1(Part1Port,0x02); /* part1port index 02 */ + temp1=(temp1&(~0x1F))|temp2; + SetReg1(Part1Port,0x02,temp1); +} + +USHORT GetVCLK(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempptr; + USHORT temp1; + tempptr=GetVCLKPtr(ROMAddr,ModeNo); + temp1=*((USHORT *)(ROMAddr+tempptr+(VCLKLen-2))); + return temp1; +} + +USHORT GetQueueConfig() +{ + USHORT tempal,tempbl; + ULONG tempeax; + + SetReg4(0xcf8,0x80000050); + tempeax=GetReg3(0xcfc); + tempeax=(tempeax>>24)&0x0f; + tempbl=(USHORT)tempeax; + tempbl=tempbl<<4; + + SetReg4(0xcf8,0x800000A0); + tempeax=GetReg3(0xcfc); + tempeax=(tempeax>>24)&0x0f; + tempal=(USHORT)tempeax; + tempbl=tempbl|tempal; + + return(tempbl); +} + +USHORT GetVCLKPtr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempal=0; + if(IF_DEF_LVDS==0) { + tempal=(UCHAR)GetReg2((USHORT)(P3ca+0x02)); /* Port 3cch */ + tempal=((tempal>>2)&0x03); + if(ModeNo>0x13){ + tempal=*((UCHAR *)(ROMAddr+REFIndex+0x03)); /* di+Ext_CRTVCLK */ + } + VCLKLen=GetVCLKLen(ROMAddr); + tempal=tempal*VCLKLen; + tempal=tempal+(*((USHORT *)(ROMAddr+0x208))); /* VCLKData */ + return ((USHORT)tempal); + } else { + if(LCDResInfo==Panel800x600) { + tempal=VCLK40; + } else if(LCDResInfo==Panel1024x768) { + tempal=VCLK65; + } + VCLKLen=GetVCLKLen(ROMAddr); + tempal=tempal*VCLKLen; + tempal=tempal+(*((USHORT *)(ROMAddr+0x208))); + return((USHORT)tempal); + } +} + +USHORT GetColorTh(ULONG ROMAddr) +{ + USHORT temp; + temp=GetColorDepth(ROMAddr); + temp=temp>>1; + if(temp==0) temp++; + return temp; +} + +USHORT GetMCLK(ULONG ROMAddr) +{ + USHORT tempmclkptr; + USHORT tempmclk; + tempmclkptr=GetMCLKPtr(ROMAddr); + tempmclk=*((USHORT *)(ROMAddr+tempmclkptr+0x03)); /* di+3 */ + return tempmclk; +} + +USHORT GetMCLKPtr(ULONG ROMAddr) +{ + USHORT tempdi; + USHORT tempdramtype,tempax; + + tempdi=*((USHORT *)(ROMAddr+0x20C)); /* MCLKData */ + tempdramtype=GetDRAMType(ROMAddr); + tempax=5*tempdramtype; + tempdi=tempdi+tempax; + return (tempdi); +} + +USHORT GetDRAMType(ULONG ROMAddr) +{ + USHORT tsoftsetting,temp3; + tsoftsetting=*((UCHAR *)(ROMAddr+0x52)); + if(!(tsoftsetting&SoftDramType)){ + temp3=(UCHAR)GetReg1(P3c4,0x3A); + tsoftsetting=temp3; + } + tsoftsetting=tsoftsetting&0x07; + return(tsoftsetting); +} + +USHORT CalcDelayVB() +{ + USHORT tempal,tempah,temp1,tempbx; + USHORT ThTiming[8]={1,2,2,3,0,1,1,2}; + USHORT ThLowB[24]={81,4,72,6,88,8,120,12, + 55,4,54,6,66,8,90,12, + 42,4,45,6,55,8,75,12}; + + tempah=(UCHAR)GetReg1(P3c4,0x18); /* SR_18 */ + tempah=tempah&0x62; + tempah=tempah>>1; + tempal=tempah; + tempah=tempah>>3; + tempal=tempal|tempah; + tempal=tempal&0x07; + + temp1=ThTiming[tempal]; /* temp1->cl */ + + tempbx=(UCHAR)GetReg1(P3c4,0x16); /* SR_16 */ + tempbx=tempbx>>6; + tempah=(UCHAR)GetReg1(P3c4,0x14); /* SR_14 */ + tempah=((tempah>>4)&0x0C); + tempbx=((tempbx|tempah)<<1); + + tempal=ThLowB[tempbx+1]*temp1; + tempbx=ThLowB[tempbx]; + tempbx=tempal+tempbx; + + return(tempbx); +} + +USHORT GetVCLK2Ptr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempal,tempbx,temp; + USHORT LCDXlat1VCLK[4]={VCLK65,VCLK65,VCLK65,VCLK65}; + USHORT LCDXlat2VCLK[4]={VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2}; + USHORT LVDSXlat1VCLK[4]={VCLK40,VCLK40,VCLK40,VCLK40}; + USHORT LVDSXlat2VCLK[4]={VCLK65,VCLK65,VCLK65,VCLK65}; + USHORT LVDSXlat3VCLK[4]={VCLK65,VCLK65,VCLK65,VCLK65}; + + if(IF_DEF_LVDS==0) { + if(ModeNo<=0x13){ + tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + }else{ + tempal=*((UCHAR *)(ROMAddr+REFIndex+0x04)); /* di+Ext_CRT2CRTC */ + } + tempal=tempal>>6; + if(LCDResInfo!=Panel1024x768){ + tempal=LCDXlat2VCLK[tempal]; + }else{ + tempal=LCDXlat1VCLK[tempal]; + } + + if(VBInfo&SetCRT2ToLCD){ + tempal=tempal; + } +/* ynlai begin */ + else { /* for TV */ + if(VBInfo&SetCRT2ToTV) { + if(IF_DEF_HiVision==1) { + if(SetFlag&RPLLDIV2XO) tempal=HiTVVCLKDIV2; + else tempal=HiTVVCLK; + if(SetFlag&TVSimuMode){ + temp=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(temp&Charx8Dot) tempal=HiTVSimuVCLK; + else tempal=HiTVTextVCLK; + } + } + else { + if(VBInfo&SetCRT2ToTV){ + if(SetFlag&RPLLDIV2XO) tempal=TVVCLKDIV2; + else tempal=TVVCLK; + } + else { + tempal=(UCHAR)GetReg2((USHORT)(P3ca+0x02)); /* Port 3cch */ + tempal=((tempal>>2)&0x03); + if(ModeNo>0x13) tempal=*((UCHAR *)(ROMAddr+REFIndex+0x03)); /* di+Ext_CRTVCLK */ + } + } + } + } + } +/* ynlai end */ + else { /* LVDS */ + if(ModeNo<=0x13) tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); + else tempal=*((UCHAR *)(ROMAddr+REFIndex+0x04)); + if(IF_DEF_CH7005==1) { + if(!(VBInfo&SetCRT2ToLCD)) { + tempal=tempal&0x1f; + tempbx=0; + if(VBInfo&SetPALTV) tempbx=tempbx+2; + if(VBInfo&SetCHTVOverScan) tempbx=tempbx+1; + tempbx=tempbx<<1; + temp=(*((USHORT *)(ROMAddr+ADR_CHTVVCLKPtr))); + tempbx=(*((USHORT *)(ROMAddr+temp+tempbx))); + tempal=(*((USHORT *)(ROMAddr+tempbx+tempal))); + tempal=tempal&0x00FF; + } + } + else { + tempal=tempal>>6; + if(LCDResInfo==Panel800x600) tempal=LVDSXlat1VCLK[tempal]; + else if(LCDResInfo==Panel1024x768) tempal=LVDSXlat2VCLK[tempal]; + else tempal=LVDSXlat3VCLK[tempal]; + } + } + VCLKLen=GetVCLKLen(ROMAddr); + tempal=tempal*VCLKLen; + tempal=tempal+(*((USHORT *)(ROMAddr+0x208))); /* VCLKData */ + return ((USHORT)tempal); +} + +USHORT GetVCLKLen(ULONG ROMAddr) +{ + USHORT VCLKDataStart,vclklabel,temp; + VCLKDataStart=*((USHORT *)(ROMAddr+0x208)); + for(temp=0;;temp++){ + vclklabel=*((USHORT *)(ROMAddr+VCLKDataStart+temp)); + if(vclklabel==VCLKStartFreq){ + temp=temp+2; + return(temp); + } + } + return(0); +} + + +VOID SetCRT2Sync(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo) +{ + USHORT temp1,tempah=0; + USHORT temp; + USHORT Part1Port; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + if(IF_DEF_LVDS==1){ + if(VBInfo&SetCRT2ToLCD){ + tempah=LCDInfo; + if(!(tempah&LCDSync)){ + temp=*((USHORT *)(ROMAddr+REFIndex)); /*di+Ext_InfoFlag */ + tempah=(temp>>8)&0x0C0; + }else{ + tempah=tempah&0x0C0; + } + } + } + else { + temp=*((USHORT *)(ROMAddr+REFIndex)); /* di+Ext_InfoFlag */ + tempah=(temp>>8)&0x0C0; + } + temp1=(UCHAR)GetReg1(Part1Port,0x19); /* part1port index 02 */ + temp1=(temp1&(~0x0C0))|tempah; + SetReg1(Part1Port,0x19,temp1); +} + +VOID GetCRT1Ptr(ULONG ROMAddr) +{ + USHORT temprefcrt1; + USHORT temp; + temp=*((UCHAR *)(ROMAddr+REFIndex+0x02)); /* di+Ext_CRT1CRTC */ + temp=temp*CRT1Len; + temprefcrt1=*((USHORT *)(ROMAddr+0x204)); /* Get CRT1Table */ + REFIndex=temprefcrt1+temp; /* di->CRT1Table+Ext_CRT1CRTC*CRT1Len */ +} + +VOID SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR) +{ + USHORT temp1; + temp1=GetReg1(Port,Index); /* part1port index 02 */ + temp1=(temp1&(DataAND))|DataOR; + SetReg1(Port,Index,temp1); +} + +USHORT GetVGAHT2() +{ + long int temp1,temp2; + temp1=(VGAVT-VGAVDE)*RVBHCMAX; + temp1=temp1&0x0FFFF; + temp2=(VT-VDE)*RVBHCFACT; + temp2=temp2&0x0FFFF; + temp2=temp2*HT; + temp2=temp2/temp1; + return((USHORT)temp2); +} + +VOID SetGroup2(USHORT BaseAddr,ULONG ROMAddr, USHORT ModeNo) +{ + USHORT tempah,tempbl,tempbh,tempcl,i,j,tempcx,pushcx,tempbx,tempax; + USHORT tempmodeflag,tempflowflag; + UCHAR *temp1; + USHORT *temp2; + USHORT pushbx; + USHORT Part2Port; + USHORT modeflag; + long int longtemp; + + Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; + tempcx=VBInfo; + tempah=VBInfo&0x0FF; + tempbl=VBInfo&0x0FF; + tempbh=VBInfo&0x0FF; + tempbx=(tempbl&0xFF)|(tempbh<<8); + tempbl=tempbl&0x10; + tempbh=(tempbh&0x04)<<1; + tempah=(tempah&0x08)>>1; + tempah=tempah|tempbh; + tempbl=tempbl>>3; + tempah=tempah|tempbl; + tempah=tempah^0x0C; + + if(IF_DEF_HiVision==1) { + temp1=(UCHAR *)(ROMAddr+0x0F1); /* PALPhase */ + tempah=tempah^0x01; + if(VBInfo&SetInSlaveMode) { + temp2=HiTVSt2Timing; + if(SetFlag&TVSimuMode) { + modeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + if(modeflag&Charx8Dot) temp2=HiTVSt1Timing; + else temp2=HiTVTextTiming; + } + } + else temp2=HiTVExtTiming; + } + else { + if(VBInfo&SetPALTV){ + temp1=(UCHAR *)(ROMAddr+0x0F1); /* PALPhase */ + temp2=PALTiming; + }else{ + tempah=tempah|0x10; + temp1=(UCHAR *)(ROMAddr+0x0ED); /* NTSCPhase */ + temp2=NTSCTiming; + } + } + SetReg1(Part2Port,0x0,tempah); + for(i=0x31;i<=0x34;i++,temp1++){ + SetReg1(Part2Port,i,*(UCHAR *)temp1); + } + for(i=0x01,j=0;i<=0x2D;i++,j++){ + SetReg1(Part2Port,i,temp2[j]); + } + for(i=0x39;i<=0x45;i++,j++){ + SetReg1(Part2Port,i,temp2[j]); /* di->temp2[j] */ + } + + tempah=GetReg1(Part2Port,0x0A); + tempah=tempah|NewFlickerMode; + SetReg1(Part2Port,0x0A,tempah); + + SetReg1(Part2Port,0x35,RY1COE); + SetReg1(Part2Port,0x36,RY2COE); + SetReg1(Part2Port,0x37,RY3COE); + SetReg1(Part2Port,0x38,RY4COE); + +/* ynlai begin */ + if(IF_DEF_HiVision==1) tempax=950; + else { + if(VBInfo&SetPALTV) tempax=520; + else tempax=440; + } + if(VDE<=tempax) { + tempax=tempax-VDE; + tempax=tempax>>2; + tempah=(tempax&0xFF00)>>8; + tempah=tempah+temp2[0]; + SetReg1(Part2Port,0x01,tempah); + tempah=tempax&0x00FF; + tempah=tempah+temp2[1]; + SetReg1(Part2Port,0x02,tempah); + } +/* begin end */ + + tempcx=HT-1; + tempah=tempcx&0xFF; + SetReg1(Part2Port,0x1B,tempah); + tempah=(tempcx&0xFF00)>>8; + SetRegANDOR(Part2Port,0x1D,~0x0F,(UCHAR)tempah); + + tempcx=HT>>1; + pushcx=tempcx; /* push cx */ + + tempcx=tempcx+7; +/* ynlai begin */ + if(IF_DEF_HiVision==1) tempcx=tempcx-4; +/* ynlai end */ + tempah=(tempcx&0xFF); + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x22,~0x0F0,tempah); + + + tempbx=temp2[j]; + tempbx=tempbx+tempcx; + tempah=tempbx&0xFF; + SetReg1(Part2Port,0x24,tempah); + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x25,~0x0F0,tempah); + + tempbx=tempbx+8; +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + tempbx=tempbx-4; + tempcx=tempbx; + } +/* ynlai end */ + tempah=((tempbx&0xFF)<<4)&0xFF; + SetRegANDOR(Part2Port,0x29,~0x0F0,tempah); + + tempcx=tempcx+temp2[++j]; + tempah=tempcx&0xFF; + SetReg1(Part2Port,0x27,tempah); + tempah=(((tempcx&0xFF00)>>8)<<4)&0xFF; + SetRegANDOR(Part2Port,0x28,~0x0F0,tempah); + + tempcx=tempcx+8; +/* ynlai begin */ + if(IF_DEF_HiVision==1) tempcx=tempcx-4; +/* ynlai end */ + tempah=tempcx&0xFF; + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x2A,~0x0F0,tempah); + + tempcx=pushcx; /* pop cx */ + tempcx=tempcx-temp2[++j]; + tempah=tempcx&0xFF; + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x2D,~0x0F0,tempah); + + tempcx=tempcx-11; + if(!(VBInfo&SetCRT2ToTV)){ + tempax=GetVGAHT2(); + tempcx=tempax-1; + } + tempah=tempcx&0xFF; + SetReg1(Part2Port,0x2E,tempah); + + tempbx=VDE; + if(VGAVDE==360){ + tempbx=746; + } + if(VGAVDE==375){ + tempbx=746; + } + if(VGAVDE==405){ + tempbx=853; + } + /* assuming <<ifndef>> HivisionTV */ + if((VBInfo&SetCRT2ToTV)){ + tempbx=tempbx>>1; + } + + tempbx=tempbx-2; + tempah=tempbx&0xFF; +/* ynlai begin */ + if(IF_DEF_HiVision==1) + if(VBInfo&SetInSlaveMode) + if(ModeNo==0x2f) tempah=tempah+1; +/* ynlai end */ + SetReg1(Part2Port,0x2F,tempah); + + tempah=(tempcx&0xFF00)>>8; + tempbh=(tempbx&0xFF00)>>8; + tempbh=(tempbh<<6)&0xFF; + tempah=tempah|tempbh; + /* assuming <<ifndef>> hivisiontv */ +/* ynlai begin */ + if(IF_DEF_HiVision==0) { + tempah=tempah|0x10; + if(!(VBInfo&SetCRT2ToSVIDEO)){ + tempah=tempah|0x20; + } + } +/* ynlai end */ + SetReg1(Part2Port,0x30,tempah); + + tempbh=0; + tempbx=tempbx&0xFF; + + tempmodeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + tempflowflag=0; + if(!(tempmodeflag&HalfDCLK)){ + tempcx=VGAHDE; + if(tempcx>=HDE){ + tempbh=tempbh|0x20; + tempbx=(tempbh<<8)|(tempbx&0xFF); + tempah=0; + } + } + tempcx=0x0101; +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + if(VGAHDE>=1024) { + tempcx=0x1920; + if(VGAHDE>=1280) tempcx=0x1420; + } + } +/* ynlai end */ + if(!(tempbh&0x20)){ + if(tempmodeflag&HalfDCLK){ + tempcl=((tempcx&0xFF)<<1)&0xFF; + tempcx=(tempcx&0xFF00)|tempcl; + } + pushbx=tempbx; + tempax=VGAHDE; + tempbx=(tempcx&0xFF00)>>8; + longtemp=tempax*tempbx; + tempcx=tempcx&0xFF; + longtemp=longtemp/tempcx; + longtemp=longtemp*8*1024; + tempax=(longtemp)/HDE; + if(tempax*HDE<longtemp){ + tempax=tempax+1; + }else{ + tempax=tempax; + } + tempbx=pushbx; + tempah=((tempax&0xFF00)>>8)&0x01F; + tempbh=tempbh|tempah; + tempah=tempax&0xFF; + } + + SetReg1(Part2Port,0x44,tempah); + tempah=tempbh; + SetRegANDOR(Part2Port,0x45,~0x03F,tempah); + + if(IF_DEF_HiVision==1) { + if(!(VBInfo&SetInSlaveMode)) { + SetReg1(Part2Port,0x0B,0x00); + } + } + + if(VBInfo&SetCRT2ToTV){ + return; + } + tempah=0x01; + if(LCDResInfo==Panel1280x1024){ + if(ModeType==ModeEGA){ + if(VGAHDE>=1024){ + tempah=0x02; + } + } + } + SetReg1(Part2Port,0x0B,tempah); + + tempbx=HDE-1; /* RHACTE=HDE-1 */ + tempah=tempbx&0xFF; + SetReg1(Part2Port,0x2C,tempah); + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x2B,~0x0F0,tempah); + + tempbx=VDE-1; /* RTVACTEO=(VDE-1)&0xFF */ + tempah=tempbx&0xFF; + SetReg1(Part2Port,0x03,tempah); + tempah=((tempbx&0xFF00)>>8)&0x07; + SetRegANDOR(Part2Port,0x0C,~0x07,tempah); + + tempcx=VT-1; + tempah=tempcx&0xFF; /* RVTVT=VT-1 */ + SetReg1(Part2Port,0x19,tempah); + tempah=(tempcx&0xFF00)>>8; + tempah=(tempah<<5)&0xFF; + if(LCDInfo&LCDRGB18Bit){ + tempah=tempah|0x10; + } + SetReg1(Part2Port,0x1A,tempah); + + tempcx++; + if(LCDResInfo==Panel1024x768){ + tempbx=768; + }else{ + tempbx=1024; + } + + if(tempbx==VDE){ + tempax=1; + }else{ + tempax=tempbx; + tempax=(tempax-VDE)>>1; + } + tempcx=tempcx-tempax; /* lcdvdes */ + tempbx=tempbx-tempax; /* lcdvdee */ + + tempah=tempcx&0xFF; /* RVEQ1EQ=lcdvdes */ + SetReg1(Part2Port,0x05,tempah); + tempah=tempbx&0xFF; /* RVEQ2EQ=lcdvdee */ + SetReg1(Part2Port,0x06,tempah); + + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<3)&0xFF; + tempah=tempah|((tempcx&0xFF00)>>8); + SetReg1(Part2Port,0x02,tempah); + + tempcx=(VT-VDE)>>4; /* (VT-VDE)>>4 */ + tempbx=(VT+VDE)>>1; + tempah=tempbx&0xFF; /* RTVACTEE=lcdvrs */ + SetReg1(Part2Port,0x04,tempah); + + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<4)&0xFF; + tempbx=tempbx+tempcx+1; + tempbl=(tempbx&0x0F); + tempah=tempah|tempbl; /* RTVACTSO=lcdvrs&0x700>>4+lcdvre */ + SetReg1(Part2Port,0x01,tempah); + + tempah=GetReg1(Part2Port,0x09); + tempah=tempah&0xF0; + SetReg1(Part2Port,0x09,tempah); + + tempah=GetReg1(Part2Port,0x0A); + tempah=tempah&0xF0; + SetReg1(Part2Port,0x0A,tempah); + + tempcx=(HT-HDE)>>2; /* (HT-HDE)>>2 */ + tempbx=(HDE+7); /* lcdhdee */ + tempah=tempbx&0xFF; /* RHEQPLE=lcdhdee */ + SetReg1(Part2Port,0x23,tempah); + tempah=(tempbx&0xFF00)>>8; + SetRegANDOR(Part2Port,0x25,~0x0F,tempah); + + SetReg1(Part2Port,0x1F,0x07); /* RHBLKE=lcdhdes */ + tempah=GetReg1(Part2Port,0x20); + tempah=tempah&0x0F; + SetReg1(Part2Port,0x20,tempah); + + tempbx=tempbx+tempcx; + tempah=tempbx&0xFF; /* RHBURSTS=lcdhrs */ + SetReg1(Part2Port,0x1C,tempah); + tempah=(tempbx&0xFF00)>>8; + tempah=(tempah<<4)&0xFF; + SetRegANDOR(Part2Port,0x1D,~0x0F0,tempah); + + tempbx=tempbx+tempcx; + tempah=tempbx&0xFF; /* RHSYEXP2S=lcdhre */ + SetReg1(Part2Port,0x21,tempah); + + tempah=GetReg1(Part2Port,0x17); + tempah=tempah&0xFB; + SetReg1(Part2Port,0x17,tempah); + + tempah=GetReg1(Part2Port,0x18); + tempah=tempah&0xDF; + SetReg1(Part2Port,0x18,tempah); + return; +} + +VOID SetGroup3(USHORT BaseAddr,ULONG ROMAddr) +{ + USHORT i; + USHORT *tempdi; + USHORT Part3Port; + USHORT modeflag; + Part3Port=BaseAddr+IND_SIS_CRT2_PORT_12; +/* ynlai begin */ + SetReg1(Part3Port,0x00,0x00); + if(VBInfo&SetPALTV){ + SetReg1(Part3Port,0x13,0xFA); + SetReg1(Part3Port,0x14,0xC8); + } + else { + SetReg1(Part3Port,0x13,0xF6); + SetReg1(Part3Port,0x14,0xBF); + } + if(IF_DEF_HiVision==1) { + tempdi=HiTVGroup3Data; + if(SetFlag&TVSimuMode) { + tempdi=HiTVGroup3Simu; + modeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + if(!(modeflag&Charx8Dot)) { + tempdi=HiTVGroup3Text; + } + } + for(i=0;i<=0x3E;i++){ + SetReg1(Part3Port,i,tempdi[i]); + } + } +/* ynlai end */ + return; +} + +VOID SetGroup4(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo) +{ + USHORT Part4Port; + USHORT tempax,tempah,tempcx,tempbx,tempbh,tempch,tempmodeflag; + long int tempebx,tempeax,templong; + Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; + + tempax=0x0c; + if(VBInfo&SetCRT2ToTV){ + if(VBInfo&SetInSlaveMode){ + if(!(SetFlag&TVSimuMode)){ + SetFlag=SetFlag|RPLLDIV2XO; + tempax=tempax|0x04000; + } + }else{ + SetFlag=SetFlag|RPLLDIV2XO; + tempax=tempax|0x04000; + } + } + + if(LCDResInfo!=Panel1024x768){ + tempax=tempax|0x08000; + } + tempah=(tempax&0xFF00)>>8; + SetReg1(Part4Port,0x0C,tempah); + + tempah=RVBHCFACT; + SetReg1(Part4Port,0x13,tempah); + + tempbx=RVBHCMAX; + tempah=tempbx&0xFF; + SetReg1(Part4Port,0x14,tempah); + tempbh=(((tempbx&0xFF00)>>8)<<7)&0xFF; + + tempcx=VGAHT-1; + tempah=tempcx&0xFF; + SetReg1(Part4Port,0x16,tempah); + tempch=(((tempcx&0xFF00)>>8)<<3)&0xFF; + tempbh=tempbh|tempch; + + tempcx=VGAVT-1; + if(!(VBInfo&SetCRT2ToTV)){ + tempcx=tempcx-5; + } + tempah=tempcx&0xFF; + SetReg1(Part4Port,0x17,tempah); + tempbh=tempbh|((tempcx&0xFF00)>>8); + tempah=tempbh; + SetReg1(Part4Port,0x15,tempah); + + tempcx=VBInfo; + tempbx=VGAHDE; + tempmodeflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(tempmodeflag&HalfDCLK){ + tempbx=tempbx>>1; + } + +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + tempah=0xA0; + if(tempbx!=1024) { + tempah=0xC0; + if(tempbx!=1280) tempah=0; + } + } + else { + if(VBInfo&SetCRT2ToLCD){ + tempah=0; + if(tempbx>800){ + tempah=0x60; + } + }else{ + tempah=0x080; + } + } +/* ynlai end */ + if(LCDResInfo!=Panel1280x1024){ + tempah=tempah|0x0A; + } + + SetRegANDOR(Part4Port,0x0E,~0xEF,tempah); + + tempebx=VDE; + +/* ynlai begin */ + if(IF_DEF_HiVision==1) { + if(!(tempah&0xE0)) tempbx=tempbx>>1; + } +/* ynlai end */ + + tempcx=RVBHRS; + tempah=tempcx&0xFF; + SetReg1(Part4Port,0x18,tempah); + + tempeax=VGAVDE; + tempcx=tempcx|0x04000; + tempeax=tempeax-tempebx; + if(tempeax<0){ + tempcx=tempcx^(0x04000); + tempeax=VGAVDE; + } + + templong=(tempeax*256*1024)/tempebx; + if(tempeax*256*1024-templong*tempebx>0){ + tempebx=templong+1; + }else{ + tempebx=templong; + } + + + tempah=tempebx&0xFF; + SetReg1(Part4Port,0x1B,tempah); + tempah=(tempebx&0xFF00)>>8; + SetReg1(Part4Port,0x1A,tempah); + tempebx=tempebx>>16; + tempah=tempebx&0xFF; + tempah=(tempah<<4)&0xFF; + tempah=tempah|((tempcx&0xFF00)>>8); + SetReg1(Part4Port,0x19,tempah); + + SetCRT2VCLK(BaseAddr,ROMAddr,ModeNo); +} + +VOID SetCRT2VCLK(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo) +{ + USHORT vclk2ptr; + USHORT tempah,temp1; + USHORT Part4Port; + + Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; + vclk2ptr=GetVCLK2Ptr(ROMAddr,ModeNo); + SetReg1(Part4Port,0x0A,0x01); + tempah=*((UCHAR *)(ROMAddr+vclk2ptr+0x01)); /* di+1 */ + SetReg1(Part4Port,0x0B,tempah); + tempah=*((UCHAR *)(ROMAddr+vclk2ptr+0x00)); /* di */ + SetReg1(Part4Port,0x0A,tempah); + SetReg1(Part4Port,0x12,0x00); + tempah=0x08; + if(VBInfo&SetCRT2ToRAMDAC){ + tempah=tempah|0x020; + } + temp1=GetReg1(Part4Port,0x12); + tempah=tempah|temp1; + SetReg1(Part4Port,0x12,tempah); +} + +VOID SetGroup5(USHORT BaseAddr,ULONG ROMAddr) +{ + USHORT Part5Port; + USHORT Pindex,Pdata; + Part5Port=BaseAddr+IND_SIS_CRT2_PORT_14+2; + Pindex=Part5Port; + Pdata=Part5Port+1; + if(ModeType==ModeVGA){ + if(!(VBInfo&(SetInSlaveMode|LoadDACFlag|CRT2DisplayFlag))){ + EnableCRT2(); + LoadDAC2(ROMAddr,Part5Port); + } + } + return; +} + +VOID EnableCRT2() +{ + USHORT temp1; + temp1=GetReg1(P3c4,0x1E); + temp1=temp1|0x20; + SetReg1(P3c4,0x1E,temp1); /* SR 1E */ +} + +VOID LoadDAC2(ULONG ROMAddr,USHORT Part5Port) +{ + USHORT data,data2; + USHORT time,i,j,k; + USHORT m,n,o; + USHORT si,di,bx,dl; + USHORT al,ah,dh; + USHORT *table=0; + USHORT Pindex,Pdata; + Pindex=Part5Port; + Pdata=Part5Port+1; + data=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); + data=data&DACInfoFlag; + time=64; + if(data==0x00) table=MDA_DAC; + if(data==0x08) table=CGA_DAC; + if(data==0x10) table=EGA_DAC; + if(data==0x18) { + time=256; + table=VGA_DAC; + } + if(time==256) j=16; + else j=time; + + SetReg3(Pindex,0x00); + + for(i=0;i<j;i++) { + data=table[i]; + for(k=0;k<3;k++) { + data2=0; + if(data&0x01) data2=0x2A; + if(data&0x02) data2=data2+0x15; + SetReg3(Pdata,data2); + data=data>>2; + } + } + + if(time==256) { + for(i=16;i<32;i++) { + data=table[i]; + for(k=0;k<3;k++) SetReg3(Pdata,data); + } + si=32; + for(m=0;m<9;m++) { + di=si; + bx=si+0x04; + dl=0; + for(n=0;n<3;n++) { + for(o=0;o<5;o++) { + dh=table[si]; + ah=table[di]; + al=table[bx]; + si++; + WriteDAC2(Pdata,dl,ah,al,dh); + } /* for 5 */ + si=si-2; + for(o=0;o<3;o++) { + dh=table[bx]; + ah=table[di]; + al=table[si]; + si--; + WriteDAC2(Pdata,dl,ah,al,dh); + } /* for 3 */ + dl++; + } /* for 3 */ + si=si+5; + } /* for 9 */ + } +} + +VOID WriteDAC2(USHORT Pdata,USHORT dl, USHORT ah, USHORT al, USHORT dh) +{ + USHORT temp; + USHORT bh,bl; + + bh=ah; + bl=al; + if(dl!=0) { + temp=bh; + bh=dh; + dh=temp; + if(dl==1) { + temp=bl; + bl=dh; + dh=temp; + } + else { + temp=bl; + bl=bh; + bh=temp; + } + } + SetReg3(Pdata,(USHORT)dh); + SetReg3(Pdata,(USHORT)bh); + SetReg3(Pdata,(USHORT)bl); +} + +VOID LockCRT2(USHORT BaseAddr) +{ + USHORT Part1Port; + USHORT Part4Port; + USHORT temp1; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + Part4Port=BaseAddr+IND_SIS_CRT2_PORT_14; + temp1=GetReg1(Part1Port,0x24); + temp1=temp1&0xFE; + SetReg1(Part1Port,0x24,temp1); +} + +VOID SetLockRegs() +{ + USHORT temp1; + + if((VBInfo&SetInSlaveMode)&&(!(VBInfo&SetCRT2ToRAMDAC))){ + VBLongWait(); + temp1=GetReg1(P3c4,0x32); + temp1=temp1|0x20; + SetReg1(P3c4,0x32,temp1); + VBLongWait(); + } +} + +VOID EnableBridge(USHORT BaseAddr) +{ + USHORT part2_02,part2_05; + USHORT Part2Port; + Part2Port=BaseAddr+IND_SIS_CRT2_PORT_10; + + if(IF_DEF_LVDS==0) { + part2_02=(UCHAR)GetReg1(Part2Port,0x02); + part2_05=(UCHAR)GetReg1(Part2Port,0x05); + SetReg1(Part2Port,0x02,0x38); + SetReg1(Part2Port,0x05,0xFF); + LongWait(); + SetRegANDOR(Part2Port,0x00,~0x0E0,0x020); + /* WaitVBRetrace(BaseAddr); */ + SetReg1(Part2Port,0x02,part2_02); + SetReg1(Part2Port,0x05,part2_05); + } + else { + EnableCRT2(); + UnLockCRT2(BaseAddr); +/* SetRegANDOR(Part1Port,0x02,~0x040,0x0); */ + } +} + +VOID GetVBInfo(USHORT BaseAddr,ULONG ROMAddr) +{ + USHORT flag1,tempbx,tempbl,tempbh,tempah,temp; + + SetFlag=0; + tempbx=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + tempbl=tempbx&ModeInfoFlag; + ModeType=tempbl; + tempbx=0; + flag1=GetReg1(P3c4,0x38); /* call BridgeisOn */ + if(IF_DEF_LVDS==0) { /* for 301 */ + if(!(flag1&0x20)){ + VBInfo=CRT2DisplayFlag; + return; + } + } + tempbl=GetReg1(P3d4,0x30); + tempbh=GetReg1(P3d4,0x31); + + tempah=((SetCHTVOverScan>>8)|(SetInSlaveMode>>8)|(DisableCRT2Display>>8)); + tempah=tempah^0xFF; + tempbh=tempbh&tempah; +/* ynlai begin */ + if(IF_DEF_LVDS==1){ /* for LVDS */ + if(IF_DEF_CH7005==1) temp=SetCRT2ToLCD|SetCRT2ToTV; + else temp=SetCRT2ToLCD; + } + else { + if(IF_DEF_HiVision==1) temp=0xFC; + else temp=0x7C; + } + if(!(tempbl&temp)) { + VBInfo=DisableCRT2Display; + return; + } +/* ynlai end */ + if(IF_DEF_LVDS==0) { + if(tempbl&SetCRT2ToRAMDAC){ + tempbl=tempbl&(SetCRT2ToRAMDAC|SwitchToCRT2|SetSimuScanMode); + }else if(tempbl&SetCRT2ToLCD){ + tempbl=tempbl&(SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode); + }else if(tempbl&SetCRT2ToSCART){ + tempbl=tempbl&(SetCRT2ToSCART|SwitchToCRT2|SetSimuScanMode); + tempbh=tempbh|(SetPALTV>>8); + }else if(tempbl&SetCRT2ToHiVisionTV){ + tempbl=tempbl&(SetCRT2ToHiVisionTV|SwitchToCRT2|SetSimuScanMode); +/* ynlai begin */ + tempbh=tempbh|(SetPALTV>>8); +/* ynlai end */ + } + } + else { + if(IF_DEF_CH7005==1) { + if(tempbl&SetCRT2ToTV) + tempbl=tempbl&(SetCRT2ToTV|SwitchToCRT2|SetSimuScanMode); + } + if(tempbl&SetCRT2ToLCD) + tempbl=tempbl&(SetCRT2ToLCD|SwitchToCRT2|SetSimuScanMode); + } + tempah=GetReg1(P3d4,0x31); + if(tempah&(CRT2DisplayFlag>>8)){ + if(!(tempbl&(SwitchToCRT2|SetSimuScanMode))){ + tempbx=SetSimuScanMode|CRT2DisplayFlag; + tempbh=((tempbx&0xFF00)>>8); + tempbl=tempbx&0xFF; + } + } + if(!(tempbh&(DriverMode>>8))){ + tempbl=tempbl|SetSimuScanMode; + } + VBInfo=tempbl|(tempbh<<8); + if(!(VBInfo&SetSimuScanMode)){ + if(!(VBInfo&SwitchToCRT2)){ + if(BridgeIsEnable(BaseAddr)){ + if(BridgeInSlave()){ + VBInfo=VBInfo|SetSimuScanMode; + } + } + } + else { + flag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(!(flag1&CRT2Mode)) { + VBInfo=VBInfo|SetSimuScanMode; + } + } + } + if(!(VBInfo&DisableCRT2Display)) { + if(VBInfo&DriverMode) { + if(VBInfo&SetSimuScanMode) { + flag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(!(flag1&CRT2Mode)) { + VBInfo=VBInfo|SetInSlaveMode; + } + } + } + else { + VBInfo=VBInfo|SetSimuScanMode; + if(IF_DEF_LVDS==0) { + if(VBInfo&SetCRT2ToTV) { + if(!(VBInfo&SetNotSimuMode)) SetFlag=SetFlag|TVSimuMode; + } + } + } + } + if(IF_DEF_CH7005==1) { + tempah=GetReg1(P3d4,0x35); + if(tempah&TVOverScan) VBInfo=VBInfo|SetCHTVOverScan; + } +} + +BOOLEAN BridgeIsEnable(USHORT BaseAddr) +{ + USHORT flag1; + USHORT Part1Port; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + + if(IF_DEF_LVDS==1){ + return 1; + } + flag1=GetReg1(P3c4,0x38); /* call BridgeisOn */ + if(!(flag1&0x20)){ return 0;} + flag1=GetReg1(Part1Port,0x0); + if(flag1&0x0a0){ + return 1; + }else{ + return 0; + } +} + +BOOLEAN BridgeInSlave() +{ + USHORT flag1; + flag1=GetReg1(P3d4,0x31); + if(flag1&(SetInSlaveMode>>8)){ + return 1; + }else{ + return 0; + } +} + +BOOLEAN GetLCDResInfo(ULONG ROMAddr,USHORT P3d4) +{ + USHORT tempah,tempbh,tempflag; + + tempah=(UCHAR)GetReg1(P3d4,0x36); + tempbh=tempah; + tempah=tempah&0x0F; +/* if(tempah!=0) tempah--; */ + if(tempah>Panel1280x1024) tempah=0; + LCDResInfo=tempah; + tempbh=tempbh>>4; + LCDTypeInfo=tempbh; + + tempah=(UCHAR)GetReg1(P3d4,0x37); + LCDInfo=tempah; + + if(IF_DEF_LVDS==1){ + tempflag=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(tempflag&HalfDCLK){ + if(IF_DEF_TRUMPION==0){ + if(!(LCDInfo&LCDNonExpanding)){ + if(LCDResInfo==Panel1024x768){ + tempflag=*((UCHAR *)(ROMAddr+ModeIDOffset+0x09));/*si+Ext_ResInfo*/ + if(tempflag==4){ /*512x384 */ + SetFlag=SetFlag|EnableLVDSDDA; + } + }else{ + if(LCDResInfo==Panel800x600){ + tempflag=*((UCHAR*)(ROMAddr+ModeIDOffset+0x09));/*si+Ext_ResInfo*/ + if(tempflag==3){ /*400x300 */ + SetFlag=SetFlag|EnableLVDSDDA; + } + } + } + }else{ + SetFlag=SetFlag|EnableLVDSDDA; + } + }else{ + SetFlag=SetFlag|EnableLVDSDDA; + } + } + } + + if(!(VBInfo&SetCRT2ToLCD)){ + return 1; + } + if(!(VBInfo&(SetSimuScanMode|SwitchToCRT2))){ + return 1; + } + if(VBInfo&SetInSlaveMode){ + if(VBInfo&SetNotSimuMode){ + SetFlag=SetFlag|LCDVESATiming; + } + }else{ + SetFlag=SetFlag|LCDVESATiming; + } + return 1; +} + +VOID PresetScratchregister(USHORT P3d4) +{ + SetReg1(P3d4,0x37,0x00); +} + +BOOLEAN GetLCDDDCInfo(ScrnInfoPtr pScrn) +{ + USHORT tempah; +/*tempah=(HwDeviceExtension->usLCDType);// set in sisv.c */ + tempah=1; + SetReg1(P3d4,0x36,tempah); /* cr 36 0:no LCD 1:1024x768 2:1280x1024 */ + if(tempah>0) return 1; + else return 0; +} + +VOID SetTVSystem() +{ + USHORT tempah; + tempah=GetReg1(P3c4,0x38); /* SR 38 */ + tempah=tempah&0x01; /* get SR 38 D0 TV Type Selection */ + /* 0:NTSC 1:PAL */ + SetRegANDOR(P3d4,0x31,~0x01,tempah); /* set CR 31 D0= SR 38 D0 */ + return; +} + +VOID LongWait() +{ + USHORT i; + for(i=0; i<0xFFFF; i++) { + if(!(inSISREG(P3da) & 0x08)) + break; + } + for(i=0; i<0xFFFF; i++) { + if((inSISREG(P3da) & 0x09) == 9) + break; + } +} + +VOID VBLongWait() +{ + USHORT regsr1f,tempah,temp; + + regsr1f=GetReg1(P3c4,0x1F); + tempah=regsr1f&(~0xC0); + SetReg1(P3c4,0x1F,tempah); + + for(temp=1;temp>0;){ + temp=GetReg2(P3da); + temp=temp&0x08; + } + for(;temp==0;){ + temp=GetReg2(P3da); + temp=temp&0x08; + } + + SetReg1(P3c4,0x1F,regsr1f); + return; +} + +BOOLEAN WaitVBRetrace(USHORT BaseAddr) +{ + USHORT temp; + USHORT Part1Port; + Part1Port=BaseAddr+IND_SIS_CRT2_PORT_04; + temp=GetReg1(Part1Port,0x00); + if(!(temp&0x80)){ + return 0; + } + + for(temp=0;temp==0;){ + temp=GetReg1(Part1Port,0x25); + temp=temp&0x01; + } + for(;temp>0;){ + temp=GetReg1(Part1Port,0x25); + temp=temp&0x01; + } + return 1; +} + + +VOID ModCRT1CRTC(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT OldREFIndex,temp,tempah,i,modeflag1; + + OldREFIndex=(USHORT)REFIndex; + temp=GetLVDSCRT1Ptr(ROMAddr,ModeNo); + if(temp==0){ + REFIndex=OldREFIndex; + return; + } + tempah=(UCHAR)GetReg1(P3d4,0x11);/*unlock cr0-7 */ + tempah=tempah&0x7F; + SetReg1(P3d4,0x11,tempah); + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3d4,0x0,tempah); + REFIndex++; + for(i=0x02;i<=0x05;REFIndex++,i++){ + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3d4,i,tempah); + } + for(i=0x06;i<=0x07;REFIndex++,i++){ + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3d4,i,tempah); + } + for(i=0x10;i<=0x11;REFIndex++,i++){ + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3d4,i,tempah); + } + for(i=0x15;i<=0x16;REFIndex++,i++){ + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3d4,i,tempah); + } + + for(i=0x0A;i<=0x0C;REFIndex++,i++){ + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3c4,i,tempah); + } + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + tempah=tempah&0x0E0; + SetReg1(P3c4,0x0E,tempah); + + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + tempah=tempah&0x01; + tempah=tempah<<5; + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&DoubleScanMode){ + tempah=tempah|0x080; + } + SetRegANDOR(P3d4,0x09,~0x020,tempah); + REFIndex=OldREFIndex; + return; +} + +VOID SetCRT2ECLK(ULONG ROMAddr, USHORT ModeNo) +{ + USHORT OldREFIndex,tempah,tempal; + USHORT P3cc=P3c9+3; + + OldREFIndex=(USHORT)REFIndex; + if(IF_DEF_TRUMPION==0){ /*no trumpion */ + tempal=GetReg2(P3cc); + tempal=tempal&0x0C; + REFIndex=GetVCLK2Ptr(ROMAddr,ModeNo); + }else{ /*trumpion */ + SetFlag=SetFlag&(~ProgrammingCRT2); + tempal=*((UCHAR *)(ROMAddr+REFIndex+0x03)); /*&di+Ext_CRTVCLK */ + tempal=tempal&0x03F; + if(tempal==0x02){ /*31.5MHz */ + REFIndex=REFIndex-Ext2StructSize; + } + REFIndex=GetVCLKPtr(ROMAddr,ModeNo); + SetFlag=SetFlag|ProgrammingCRT2; + } + tempal=0x02B; + if(!(VBInfo&SetInSlaveMode)){ + tempal=tempal+3; + } + SetReg1(P3c4,0x05,0x86); + tempah=*((UCHAR *)(ROMAddr+REFIndex)); + SetReg1(P3c4,tempal,tempah); + tempah=*((UCHAR *)(ROMAddr+REFIndex+1)); + tempal++; + SetReg1(P3c4,tempal,tempah); + tempal++; + SetReg1(P3c4,tempal,0x80); + REFIndex=OldREFIndex; + return; +} + +USHORT GetLVDSDesPtr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempcl,tempbx,tempal,tempptr,LVDSDesPtrData; + USHORT Flag; + + Flag=1; + tempbx=0; + if(IF_DEF_CH7005==1) { + if(!(VBInfo&SetCRT2ToLCD)) { + Flag=0; + tempbx=32; + if(VBInfo&SetPALTV) tempbx=tempbx+2; + if(VBInfo&SetCHTVOverScan) tempbx=tempbx+1; + } + } + tempcl=LVDSDesDataLen; + if(Flag) { + tempbx=LCDTypeInfo; + if(LCDInfo&LCDNonExpanding){ + tempbx=tempbx+16; + } + } + if(ModeNo<=0x13) tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + else tempal=*((UCHAR *)(ROMAddr+REFIndex+4)); /*di+Ext_CRT2CRTC */ + tempal=tempal&0x1F; + tempal=tempal*tempcl; + tempbx=tempbx<<1; + LVDSDesPtrData=*((USHORT *)(ROMAddr+ADR_LVDSDesPtrData)); + tempptr=*((USHORT *)(ROMAddr+LVDSDesPtrData+tempbx)); + tempptr=tempptr+tempal; + return(tempptr); + +} + +BOOLEAN GetLVDSCRT1Ptr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempal,tempbx,modeflag1; + USHORT LVDSCRT1DataPtr,Flag; + + if(!(VBInfo&SetInSlaveMode)){ +/* return 0; */ + } + Flag=1; + tempbx=0; + if(IF_DEF_CH7005==1) { + if(!(VBInfo&SetCRT2ToLCD)) { + Flag=0; + tempbx=12; + if(VBInfo&SetPALTV) tempbx=tempbx+2; + if(VBInfo&SetCHTVOverScan) tempbx=tempbx+1; + } + } + if(Flag) { + tempbx=LCDResInfo; + tempbx=tempbx-Panel800x600; + if(LCDInfo&LCDNonExpanding) tempbx=tempbx+6; + modeflag1=*((USHORT *)(ROMAddr+ModeIDOffset+0x01)); /* si+St_ModeFlag */ + if(modeflag1&HalfDCLK) tempbx=tempbx+3; + } + if(ModeNo<=0x13) tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + else tempal=*((UCHAR *)(ROMAddr+REFIndex+4)); /*di+Ext_CRT2CRTC */ + tempal=tempal&0x3F; + + tempbx=tempbx<<1; + LVDSCRT1DataPtr=*((USHORT *)(ROMAddr+ADR_LVDSCRT1DataPtr)); + REFIndex=*((USHORT *)(ROMAddr+LVDSCRT1DataPtr+tempbx)); + tempal=tempal*LVDSCRT1Len; + REFIndex=REFIndex+tempal; + return 1; + +} + +VOID SetCHTVReg(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT old_REFIndex,temp,tempbx,tempcl; + + old_REFIndex=(USHORT)REFIndex; /*push di */ + GetCHTVRegPtr(ROMAddr,ModeNo); + + if(VBInfo&SetPALTV) { + SetCH7005(0x4304); + SetCH7005(0x6909); + } + else { + SetCH7005(0x0304); + SetCH7005(0x7109); + } + + temp=*((USHORT *)(ROMAddr+REFIndex+0x00)); + tempbx=((temp&0x00FF)<<8)|0x00; + SetCH7005(tempbx); + temp=*((USHORT *)(ROMAddr+REFIndex+0x01)); + tempbx=((temp&0x00FF)<<8)|0x07; + SetCH7005(tempbx); + temp=*((USHORT *)(ROMAddr+REFIndex+0x02)); + tempbx=((temp&0x00FF)<<8)|0x08; + SetCH7005(tempbx); + temp=*((USHORT *)(ROMAddr+REFIndex+0x03)); + tempbx=((temp&0x00FF)<<8)|0x0A; + SetCH7005(tempbx); + temp=*((USHORT *)(ROMAddr+REFIndex+0x04)); + tempbx=((temp&0x00FF)<<8)|0x0B; + SetCH7005(tempbx); + + SetCH7005(0x2801); + SetCH7005(0x3103); + SetCH7005(0x003D); + SetCHTVRegANDOR(0x0010,0x1F); + SetCHTVRegANDOR(0x0211,0xF8); + SetCHTVRegANDOR(0x001C,0xEF); + + if(!(VBInfo&SetPALTV)) { + if(ModeNo<=0x13) tempcl=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + else tempcl=*((UCHAR *)(ROMAddr+REFIndex+4)); /* di+Ext_CRT2CRTC */ + tempcl=tempcl&0x3F; + if(VBInfo&SetCHTVOverScan) { + if(tempcl==0x04) { /* 640x480 underscan */ + SetCHTVRegANDOR(0x0020,0xEF); + SetCHTVRegANDOR(0x0121,0xFE); + } + else { + if(tempcl==0x05) { /* 800x600 underscan */ + SetCHTVRegANDOR(0x0118,0xF0); + SetCHTVRegANDOR(0x0C19,0xF0); + SetCHTVRegANDOR(0x001A,0xF0); + SetCHTVRegANDOR(0x001B,0xF0); + SetCHTVRegANDOR(0x001C,0xF0); + SetCHTVRegANDOR(0x001D,0xF0); + SetCHTVRegANDOR(0x001E,0xF0); + SetCHTVRegANDOR(0x001F,0xF0); + SetCHTVRegANDOR(0x0120,0xEF); + SetCHTVRegANDOR(0x0021,0xFE); + } + } + } + else { + if(tempcl==0x04) { /* 640x480 overscan */ + SetCHTVRegANDOR(0x0020,0xEF); + SetCHTVRegANDOR(0x0121,0xFE); + } + else { + if(tempcl==0x05) { /* 800x600 overscan */ + SetCHTVRegANDOR(0x0118,0xF0); + SetCHTVRegANDOR(0x0F19,0xF0); + SetCHTVRegANDOR(0x011A,0xF0); + SetCHTVRegANDOR(0x0C1B,0xF0); + SetCHTVRegANDOR(0x071C,0xF0); + SetCHTVRegANDOR(0x011D,0xF0); + SetCHTVRegANDOR(0x0C1E,0xF0); + SetCHTVRegANDOR(0x071F,0xF0); + SetCHTVRegANDOR(0x0120,0xEF); + SetCHTVRegANDOR(0x0021,0xFE); + } + } + } + } + + REFIndex=old_REFIndex; +} + +VOID SetCHTVRegANDOR(USHORT tempax,USHORT tempbh) +{ + USHORT tempal,tempah,tempbl; + + tempal=tempax&0x00FF; + tempah=(tempax>>8)&0x00FF; + tempbl=GetCH7005(tempal); + tempbl=(((tempbl&tempbh)|tempah)<<8|tempal); + SetCH7005(tempbl); +} + +VOID GetCHTVRegPtr(ULONG ROMAddr,USHORT ModeNo) +{ + USHORT tempbx,tempal,tempcl,CHTVRegDataPtr; + + if(VBInfo&SetCRT2ToTV) { + tempbx=0; + if(VBInfo&SetPALTV) tempbx=tempbx+2; + if(VBInfo&SetCHTVOverScan) tempbx=tempbx+1; + + if(ModeNo<=0x13) tempal=*((UCHAR *)(ROMAddr+ModeIDOffset+0x04)); /* si+St_CRT2CRTC */ + else tempal=*((UCHAR *)(ROMAddr+REFIndex+4)); /* di+Ext_CRT2CRTC */ + tempal=tempal&0x3F; + + tempcl=CHTVRegDataLen; + tempal=tempal*tempcl; + tempbx=tempbx<<1; + + CHTVRegDataPtr=*((USHORT *)(ROMAddr+ADR_CHTVRegDataPtr)); + REFIndex=*((USHORT *)(ROMAddr+CHTVRegDataPtr+tempbx)); + REFIndex=REFIndex+tempal; + } +} + +VOID SetCH7005(USHORT tempbx) +{ + USHORT tempah,temp; + + DDC_Port=0x3c4; + DDC_Index=0x11; + DDC_DataShift=0x00; + DDC_DeviceAddr=0xEA; + + SetSwitchDDC2(); + SetStart(); + tempah=DDC_DeviceAddr; + temp=WriteDDC2Data(tempah); + tempah=tempbx&0x00FF; + temp=WriteDDC2Data(tempah); + tempah=(tempbx&0xFF00)>>8; + temp=WriteDDC2Data(tempah); + SetStop(); +} + +USHORT GetCH7005(USHORT tempbx) +{ + USHORT tempah; + + DDC_Port=0x3c4; + DDC_Index=0x11; + DDC_DataShift=0x00; + DDC_DeviceAddr=0xEA; + DDC_ReadAddr=tempbx; + + SetSwitchDDC2(); + SetStart(); + tempah=DDC_DeviceAddr; + WriteDDC2Data(tempah); + tempah=DDC_ReadAddr; + WriteDDC2Data(tempah); + + SetStart(); + tempah=DDC_DeviceAddr; + tempah=tempah|0x01; + if(WriteDDC2Data(tempah)) { + } + tempah=ReadDDC2Data(tempah); + SetStop(); + return(tempah); +} + +VOID SetSwitchDDC2(VOID) +{ + USHORT i; + + SetSCLKHigh(); + for(i=0;i<1000;i++) { + GetReg1(DDC_Port,0x05); + } + SetSCLKLow(); + for(i=0;i<1000;i++) { + GetReg1(DDC_Port,0x05); + } +} + + +VOID SetStart(VOID) +{ + USHORT temp; + + SetSCLKLow(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x02); /* SetSDA(0x01); */ + SetSCLKHigh(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x00); /* SetSDA(0x00); */ + SetSCLKHigh(); +} + +VOID SetStop(VOID) +{ + SetSCLKLow(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x00); /* SetSDA(0x00); */ + SetSCLKHigh(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x02); /* SetSDA(0x01); */ + SetSCLKHigh(); +} + +USHORT WriteDDC2Data(USHORT tempax) +{ + USHORT i,flag,temp; + + flag=0x80; + for(i=0;i<8;i++) { + SetSCLKLow(); + if(tempax&flag) { + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x02); + } + else { + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x00); + } + SetSCLKHigh(); + flag=flag>>1; + } + return(CheckACK()); +} + +USHORT ReadDDC2Data(USHORT tempax) +{ + USHORT i,temp,getdata; + + getdata=0; + for(i=0;i<8;i++) { + getdata=getdata<<1; + SetSCLKLow(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x02); + SetSCLKHigh(); + temp=GetReg1(DDC_Port,DDC_Index); + if(temp&0x02) getdata=getdata|0x01; + } + return(getdata); +} + +VOID SetSCLKLow(VOID) +{ + SetRegANDOR(DDC_Port,DDC_Index,0xFE,0x00); /* SetSCLKLow() */ + DDC2Delay(); +} + + +VOID SetSCLKHigh(VOID) +{ + USHORT temp; + + SetRegANDOR(DDC_Port,DDC_Index,0xFE,0x01); /* SetSCLKLow() */ + do { + temp=GetReg1(DDC_Port,DDC_Index); + } while(!(temp&0x01)); + DDC2Delay(); +} + +VOID DDC2Delay(VOID) +{ + USHORT i; + + for(i=0;i<DDC2DelayTime;i++) { + GetReg1(P3c4,0x05); + } +} + +USHORT CheckACK(VOID) +{ + USHORT tempah; + + SetSCLKLow(); + SetRegANDOR(DDC_Port,DDC_Index,0xFD,0x02); + SetSCLKHigh(); + tempah=GetReg1(DDC_Port,DDC_Index); + SetSCLKLow(); + if(tempah&0x01) return(1); + else return(0); +} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h:1.4 --- /dev/null Mon Dec 18 14:31:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h Fri Dec 1 20:16:17 2000 @@ -0,0 +1,241 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */ + +#include "initdef.h" + +USHORT VBInfo,SetFlag,RVBHCFACT,RVBHCMAX,VGAVT,VGAHT,VT,HT,VGAVDE,VGAHDE; +USHORT VDE,HDE,RVBHRS,NewFlickerMode,RY1COE,RY2COE,RY3COE,RY4COE; +USHORT LCDResInfo,LCDTypeInfo,LCDInfo,VCLKLen; +USHORT LCDHDES,LCDVDES; +USHORT DDC_Port; +USHORT DDC_Index; +USHORT DDC_DataShift; +USHORT DDC_DeviceAddr; +USHORT DDC_Flag; +USHORT DDC_ReadAddr; +USHORT DDC_Buffer; + +USHORT StResInfo[5][2]={{640,400},{640,350},{720,400},{720,350},{640,480}}; +USHORT ModeResInfo[15][4]={{320,200,8,8},{320,240,8,8},{320,400,8,8}, + {400,300,8,8},{512,384,8,8},{640,400,8,16}, + {640,480,8,16},{800,600,8,16},{1024,768,8,16}, + {1280,1024,8,16},{1600,1200,8,16},{1920,1440,8,16}, + {720,480,8,16},{720,576,8,16},{1280,960,8,16}}; + +USHORT HiTVExtTiming[61]={0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x64, + 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, + 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, + 0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13, + 0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40, + 0x8E,0x8E,0x82,0x07,0x0B, + 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, + 0x60,0x14,0x3D,0x63,0x4F, + 0x027,0xFFFC,0x6A}; + +USHORT HiTVSt1Timing[61]={0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65, + 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, + 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, + 0x65,0x90,0x7B,0xA8,0x03,0xF0,0x87,0x03, + 0x11,0x15,0x11,0xCF,0x10,0x11,0xCF,0x10, + 0x35,0x35,0x3B,0x69,0x1D, + 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, + 0x60,0x04,0x86,0xAF,0x5D, + 0xE,0xFFFC,0x2D}; + +USHORT HiTVSt2Timing[61]={0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x64, + 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, + 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, + 0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13, + 0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40, + 0x8E,0x8E,0x82,0x07,0x0B, + 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, + 0x60,0x14,0x3D,0x63,0x4F, + 0x27,0xFFFC,0x6A}; + +USHORT HiTVTextTiming[61]={0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65, + 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, + 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, + 0x65,0x90,0xE7,0xBC,0x03,0x0C,0x97,0x03, + 0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20, + 0xC8,0xC8,0x3B,0xD2,0x26, + 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, + 0x60,0x04,0x96,0x72,0x5C, + 0x11,0xFFFC,0x32}; + +USHORT HiTVGroup3Data[63]={0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x5F, + 0x05,0x21,0xB2,0xB2,0x55,0x77,0x2A,0xA6, + 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, + 0x8C,0x6E,0x60,0x2E,0x58,0x48,0x72,0x44, + 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80, + 0x4F,0x7F,0x03,0xA8,0x7D,0x20,0x1A,0xA9, + 0x14,0x05,0x03,0x7E,0x64,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; + +USHORT HiTVGroup3Simu[63]={0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x95, + 0xDB,0x20,0xB8,0xB8,0x55,0x47,0x2A,0xA6, + 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, + 0x8C,0x6E,0x60,0x15,0x26,0xD3,0xE4,0x11, + 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80, + 0x67,0x36,0x01,0x47,0x0E,0x10,0xBE,0xB4, + 0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; + +USHORT HiTVGroup3Text[63]={0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0xA7, + 0xF5,0x20,0xCE,0xCE,0x55,0x47,0x2A,0xA6, + 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, + 0x8C,0x6E,0x60,0x18,0x2C,0x0C,0x20,0x22, + 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80, + 0x93,0x3C,0x01,0x50,0x2F,0x10,0xF4,0xCA, + 0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75, + 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; + + +USHORT NTSCTiming[61]={0x017,0x01D,0x003,0x009,0x005,0x006,0x00C,0x00C, + 0x094,0x049,0x001,0x00A,0x006,0x00D,0x004,0x00A, + 0x006,0x014,0x00D,0x004,0x00A,0x000,0x085,0x01B, + 0x00C,0x050,0x000,0x099,0x000,0x0EC,0x04A,0x017, + 0x088,0x000,0x04B,0x000,0x000,0x0E2,0x000,0x002, + 0x003,0x00A,0x065,0x09D,0x008, + 0x092,0x08F,0x040,0x060,0x080,0x014,0x090,0x08C, + 0x060,0x014,0x050,0x000,0x040, + 0x00044,0x002DB,0x0003B}; /* Ajust xxx */ + +USHORT PALTiming[61]={ 0x019,0x052,0x035,0x06E,0x004,0x038,0x03D,0x070, + 0x094,0x049,0x001,0x012,0x006,0x03E,0x035,0x06D, + 0x006,0x014,0x03E,0x035,0x06D,0x000,0x045,0x02B, + 0x070,0x050,0x000,0x097,0x000,0x0D7,0x05D,0x017, + 0x088,0x000,0x045,0x000,0x000,0x0E8,0x000,0x002, + 0x00D,0x000,0x068,0x0B0,0x00B, + 0x092,0x08F,0x040,0x060,0x080,0x014,0x090,0x08C, + 0x060,0x014,0x063,0x000,0x040, + 0x0003E,0x002E1,0x00028}; /* Ajust xxx */ + +USHORT NTSCGroup3Data[63]= {0x000,0x014,0x015,0x025,0x055,0x015,0x00B,0x089, + 0x0D7,0x040,0x0B0,0x0B0,0x0FF,0x0C4,0x045,0x0A6, + 0x025,0x02F,0x067,0x0F6,0x0BF,0x0FF,0x08E,0x020, + 0x08C,0x0DA,0x060,0x092,0x0C8,0x055,0x08B,0x000, + 0x051,0x004,0x018,0x00A,0x0F8,0x087,0x000,0x080, + 0x03B,0x03B,0x000,0x0F0,0x0F0,0x000,0x0F0,0x0F0, + 0x000,0x051,0x00F,0x00F,0x008,0x00F,0x008,0x06F, + 0x018,0x005,0x005,0x005,0x04C,0x0AA,0x001}; + +USHORT PALGroup3Data[63]={0x000,0x01A,0x022,0x063,0x062,0x022,0x008,0x085, + 0x0C3,0x020,0x0A4,0x0A4,0x055,0x047,0x02A,0x0A6, + 0x025,0x02F,0x047,0x0FA,0x0C8,0x0FF,0x08E,0x020, + 0x08C,0x0DC,0x060,0x092,0x0C8,0x04F,0x085,0x000, + 0x056,0x036,0x04F,0x06E,0x0FE,0x083,0x054,0x081, + 0x030,0x030,0x000,0x0F3,0x0F3,0x000,0x0A2,0x0A2, + 0x000,0x048,0x0FE,0x07E,0x008,0x040,0x008,0x091, + 0x018,0x005,0x018,0x005,0x04C,0x0A8,0x001}; +USHORT Part1[41]={0x30, 0x16, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3f, 0x30, 0x8c, 0xbc, 0x22, 0x1c, 0x05, 0xdf, + 0xf3, 0x16, 0x0a, 0x20, 0x89, 0x93, 0x00, 0x80, + 0x14, 0xf7, 0x58, 0x00, 0x00, 0x18, 0x28, 0x32, + 0x15, 0xff, 0xa0, 0x00, 0x01, 0x03, 0x2c, 0x11, + 0x92}; + +VOID SetDefCRT2ExtRegs(USHORT BaseAddr); +BOOLEAN SetCRT2Group(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo, ScrnInfoPtr pScrn); +USHORT GetRatePtrCRT2(ULONG ROMAddr, USHORT ModeNo); +BOOLEAN AjustCRT2Rate(ULONG ROMAddr); +VOID SaveCRT2Info(USHORT ModeNo); +VOID DisableLockRegs(VOID); +VOID DisableCRT2(VOID); +VOID DisableBridge(USHORT BaseAddr); +VOID GetCRT2Data(ULONG ROMAddr,USHORT ModeNo); +VOID GetCRT2DataLVDS(ULONG ROMAddr,USHORT ModeNo); +VOID GetCRT2Data301(ULONG ROMAddr,USHORT ModeNo); +VOID GetResInfo(ULONG ROMAddr,USHORT ModeNo); +VOID GetRAMDAC2DATA(ULONG ROMAddr,USHORT ModeNo); +VOID GetCRT2Ptr(ULONG ROMAddr,USHORT ModeNo); +VOID UnLockCRT2(USHORT BaseAddr); +VOID SetCRT2ModeRegs(USHORT BaseAddr,USHORT ModeNo); +VOID SetGroup1(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +VOID SetGroup1_LVDS(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +VOID SetGroup1301(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +VOID GetLVDSDesData(ULONG ROMAddr,USHORT ModeNo); +VOID SetCRT2Offset(USHORT Part1Port,ULONG ROMAddr); +USHORT GetOffset(ULONG ROMAddr); +USHORT GetColorDepth(ULONG ROMAddr); +VOID SetCRT2FIFO(USHORT Part1Port,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +USHORT GetVCLK(ULONG ROMAddr,USHORT ModeNo); +USHORT GetVCLKPtr(ULONG ROMAddr,USHORT ModeNo); +USHORT GetColorTh(ULONG ROMAddr); +USHORT GetMCLK(ULONG ROMAddr); +USHORT GetMCLKPtr(ULONG ROMAddr); +USHORT GetDRAMType(ULONG ROMAddr); +USHORT CalcDelayVB(VOID); +USHORT GetVCLK2Ptr(ULONG ROMAddr,USHORT ModeNo); +VOID SetCRT2Sync(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo); +VOID GetCRT1Ptr(ULONG ROMAddr); +VOID SetRegANDOR(USHORT Port,USHORT Index,USHORT DataAND,USHORT DataOR); +USHORT GetVGAHT2(VOID); +VOID SetGroup2(USHORT BaseAddr,ULONG ROMAddr, USHORT ModeNo); +VOID SetGroup3(USHORT BaseAddr,ULONG ROMAddr); +VOID SetGroup4(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo); +VOID SetCRT2VCLK(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo); +VOID SetGroup5(USHORT BaseAddr,ULONG ROMAddr); +VOID EnableCRT2(VOID); +VOID LoadDAC2(ULONG ROMAddr,USHORT Part5Port); +VOID WriteDAC2(USHORT Pdata,USHORT dl, USHORT ah, USHORT al, USHORT dh); +VOID LockCRT2(USHORT BaseAddr); +VOID SetLockRegs(VOID); +VOID EnableBridge(USHORT BaseAddr); +VOID GetVBInfo(USHORT BaseAddr,ULONG ROMAddr); +BOOLEAN BridgeIsEnable(USHORT BaseAddr); +BOOLEAN BridgeInSlave(VOID); +BOOLEAN GetLCDResInfo(ULONG ROMAddr,USHORT P3d4); +VOID PresetScratchregister(USHORT P3d4); +BOOLEAN GetLCDDDCInfo(ScrnInfoPtr pScrn); +VOID SetTVSystem(); +VOID LongWait(); +USHORT GetQueueConfig(); +VOID VBLongWait(); +USHORT GetVCLKLen(ULONG ROMAddr); +BOOLEAN WaitVBRetrace(USHORT BaseAddr); +VOID ModCRT1CRTC(ULONG ROMAddr,USHORT ModeNo); +VOID SetCRT2ECLK(ULONG ROMAddr, USHORT ModeNo); +USHORT GetLVDSDesPtr(ULONG ROMAddr,USHORT ModeNo); +BOOLEAN GetLVDSCRT1Ptr(ULONG ROMAddr,USHORT ModeNo); +VOID SetGroup1_301(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +VOID SetGroup1_LVDS(USHORT BaseAddr,ULONG ROMAddr,USHORT ModeNo,ScrnInfoPtr pScrn); +VOID SetTPData(); +BOOLEAN GetPanelID(); +BOOLEAN GetLVDSCRT1Ptr(ULONG ROMAddr,USHORT ModeNo); +VOID SetCHTVReg(ULONG ROMAddr,USHORT ModeNo); +VOID SetCHTVRegANDOR(USHORT tempax,USHORT tempbh); +VOID GetCHTVRegPtr(ULONG ROMAddr,USHORT ModeNo); +VOID SetCH7005(USHORT tempax); +USHORT GetCH7005(USHORT tempax); +VOID SetSwitchDDC2(VOID); +VOID SetStart(VOID); +VOID SetStop(VOID); +VOID DDC2Delay(VOID); +VOID SetSCLKLow(VOID); +VOID SetSCLKHigh(VOID); +USHORT ReadDDC2Data(USHORT tempax); +USHORT WriteDDC2Data(USHORT tempax); +USHORT CheckACK(VOID); + +extern USHORT MDA_DAC[]; +extern USHORT CGA_DAC[]; +extern USHORT EGA_DAC[]; +extern USHORT VGA_DAC[]; + +extern USHORT P3c4,P3d4,P3c0,P3ce,P3c2,P3ca,P3c6,P3c7,P3c8,P3c9,P3da; +extern USHORT flag_clearbuffer; /* 0:no clear frame buffer 1:clear frame buffer */ +extern int RAMType; +extern int ModeIDOffset,StandTable,CRT1Table,ScreenOffset,VCLKData,MCLKData, ECLKData; +extern int REFIndex,ModeType; +extern USHORT VBInfo,LCDResInfo,LCDTypeInfo,LCDInfo; +extern USHORT IF_DEF_LVDS; +extern USHORT IF_DEF_HiVision; +extern USHORT IF_DEF_CH7005; + +extern VOID SetReg1(USHORT, USHORT, USHORT); +extern VOID SetReg3(USHORT, USHORT); +extern USHORT GetReg1(USHORT, USHORT); +extern USHORT GetReg2(USHORT); +extern BOOLEAN SearchModeID(ULONG, USHORT); +extern BOOLEAN GetRatePtr(ULONG, USHORT); +extern VOID SetReg4(USHORT, ULONG); +extern ULONG GetReg3(USHORT); Index: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h:1.4 --- /dev/null Mon Dec 18 14:31:07 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h Fri Dec 1 20:16:17 2000 @@ -0,0 +1,202 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */ + +#define ULONG unsigned long +#define USHORT unsigned short +#define SHORT short +#define UCHAR unsigned char +#define VOID void +#define BOOLEAN Bool + +#define CRT1Len 17 +#define LVDSCRT1Len 15 +#define CHTVRegDataLen 5 + +#define ModeInfoFlag 0x07 +#define IsTextMode 0x07 +#define ModeText 0x00 +#define ModeCGA 0x01 +#define ModeEGA 0x02 +#define ModeVGA 0x03 +#define Mode15Bpp 0x04 +#define Mode16Bpp 0x05 +#define Mode24Bpp 0x06 +#define Mode32Bpp 0x07 + +#define DACInfoFlag 0x18 +#define MemoryInfoFlag 0x1E0 +#define MemorySizeShift 0x05 + +#define Charx8Dot 0x0200 +#define LineCompareOff 0x0400 +#define CRT2Mode 0x0800 +#define HalfDCLK 0x1000 +#define NoSupportSimuTV 0x2000 +#define DoubleScanMode 0x8000 + +#define SupportAllCRT2 0x0078 +#define SupportTV 0x0008 +#define SupportHiVisionTV 0x0010 +#define SupportLCD 0x0020 +#define SupportRAMDAC2 0x0040 +#define NoSupportTV 0x0070 +#define NoSupportHiVisionTV 0x0060 +#define NoSupportLCD 0x0058 +#define SupportCHTV 0x0800 +#define InterlaceMode 0x0080 +#define SyncPP 0x0000 +#define SyncPN 0x4000 +#define SyncNP 0x8000 +#define SyncNN 0xc000 +#define ECLKindex0 0x0000 +#define ECLKindex1 0x0100 +#define ECLKindex2 0x0200 +#define ECLKindex3 0x0300 +#define ECLKindex4 0x0400 + +#define SetSimuScanMode 0x0001 +#define SwitchToCRT2 0x0002 +#define SetCRT2ToTV 0x009C +#define SetCRT2ToAVIDEO 0x0004 +#define SetCRT2ToSVIDEO 0x0008 +#define SetCRT2ToSCART 0x0010 +#define SetCRT2ToLCD 0x0020 +#define SetCRT2ToRAMDAC 0x0040 +#define SetCRT2ToHiVisionTV 0x0080 +#define SetNTSCTV 0x0000 +#define SetPALTV 0x0100 +#define SetInSlaveMode 0x0200 +#define SetNotSimuMode 0x0400 +#define SetDispDevSwitch 0x0800 +#define LoadDACFlag 0x1000 +#define DisableCRT2Display 0x2000 +#define DriverMode 0x4000 +#define HotKeySwitch 0x8000 +#define SetCHTVOverScan 0x8000 + +#define TVOverScan 0x10 +#define TVOverScanShift 4 +#define ClearBufferFlag 0x20 + +#define SetSCARTOutput 0x01 +#define BoardTVType 0x02 + +#define ProgrammingCRT2 0x01 +#define TVSimuMode 0x02 +#define RPLLDIV2XO 0x04 +#define LCDVESATiming 0x08 +#define EnableLVDSDDA 0x10 +#define SetDispDevSwitchFlag 0x20 +#define CheckWinDos 0x40 +#define SetJDOSMode 0x80 + +#define Panel800x600 0x01 +#define Panel1024x768 0x02 +#define Panel1280x1024 0x03 +#define Panel1280x960 0x04 +#define Panel640x480 0x05 +#define LCDRGB18Bit 0x01 +#define ExtChipType 0x0e +#define ExtChip301 0x02 +#define ExtChipLVDS 0x04 +#define ExtChipTrumpion 0x06 +#define ExtChipCH7005 0x08 +#define ExtChipMitacTV 0x0a +#define LCDNonExpanding 0x10 +#define LCDNonExpandingShift 4 +#define LCDSync 0x20 +#define LCDSyncBit 0xe0 +#define LCDSyncshift 6 + +#define DDC2DelayTime 10 + +#define CRT2DisplayFlag 0x2000 +#define LCDDataLen 8 +#define HiTVDataLen 12 +#define TVDataLen 16 +#define SetPALTV 0x0100 +#define HalfDCLK 0x1000 +#define NTSCHT 1716 +#define NTSCVT 525 +#define PALHT 1728 +#define PALVT 625 +#define StHiTVHT 892 +#define StHiTVVT 1126 +#define StHiTextTVHT 1000 +#define StHiTextTVVT 1126 +#define ExtHiTVHT 2100 +#define ExtHiTVVT 1125 + +#define SelectCRT2Rate 0x4 +#define VCLKStartFreq 25 +#define SoftDramType 0x80 +#define VCLK40 0x04 +#define VCLK65 0x09 +#define VCLK108_2 0x14 +#define LCDRGB18Bit 0x01 +#define LoadDACFlag 0x1000 +#define AfterLockCRT2 0x4000 +#define SetCRT2ToAVIDEO 0x0004 +#define SetCRT2ToSCART 0x0010 +#define Ext2StructSize 5 +#define TVVCLKDIV2 0x021 +#define TVVCLK 0x022 +#define HiTVVCLKDIV2 0x023 +#define HiTVVCLK 0x024 +#define HiTVSimuVCLK 0x025 +#define HiTVTextVCLK 0x026 +#define SwitchToCRT2 0x0002 +#define LCDVESATiming 0x08 +#define SetSCARTOutput 0x01 +#define SCARTSense 0x04 +#define Monitor1Sense 0x20 +#define Monitor2Sense 0x10 +#define SVIDEOSense 0x02 +#define AVIDEOSense 0x01 +#define LCDSense 0x08 +#define BoardTVType 0x02 +#define HotPlugFunction 0x08 +#define StStructSize 0x06 + +#define IND_SIS_CRT2_PORT_04 0x04 - 0x030 +#define IND_SIS_CRT2_PORT_10 0x10 - 0x30 +#define IND_SIS_CRT2_PORT_12 0x12 - 0x30 +#define IND_SIS_CRT2_PORT_14 0x14 - 0x30 + +#define IF_DEF_TRUMPION 0 +#define LCDNonExpanding 0x10 +#define ADR_CRT2PtrData 0x20E +#define offset_Zurac 0x210 +#define ADR_LVDSDesPtrData 0x212 +#define ADR_LVDSCRT1DataPtr 0x214 +#define ADR_CHTVVCLKPtr 0x216 +#define ADR_CHTVRegDataPtr 0x218 + +#define LVDSDataLen 6 +#define EnableLVDSDDA 0x10 +#define LVDSDesDataLen 3 +#define ActiveNonExpanding 0x40 +#define ActiveNonExpandingShift 6 +#define ModeSwitchStatus 0x0F +#define SoftTVType 0x40 + +#define SelectCRT1Rate 0x4 +#define SelectCRT2Rate 0x4 + +#define PanelType00 0x00 +#define PanelType01 0x08 +#define PanelType02 0x10 +#define PanelType03 0x18 +#define PanelType04 0x20 +#define PanelType05 0x28 +#define PanelType06 0x30 +#define PanelType07 0x38 +#define PanelType08 0x40 +#define PanelType09 0x48 +#define PanelType0A 0x50 +#define PanelType0B 0x58 +#define PanelType0C 0x60 +#define PanelType0D 0x68 +#define PanelType0E 0x70 +#define PanelType0F 0x78 + + Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp:1.4 Tue Jun 13 22:13:13 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp Mon Dec 11 15:18:26 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp,v 1.4 2000/06/14 02:13:13 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp,v 1.5 2000/12/11 20:18:26 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SIS __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH SIS __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME sis \- SiS video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h:1.14 xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h:1.14 Mon Jun 26 18:27:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h Fri Dec 1 20:16:17 2000 @@ -25,7 +25,7 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.14 2000/06/26 22:27:45 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.19 2000/12/02 01:16:17 dawes Exp $ */ #ifndef _SIS_H #define _SIS_H_ @@ -33,158 +33,213 @@ #include "xf86Pci.h" #include "xf86Cursor.h" +#include "xf86_ansic.h" #include "compiler.h" #include "xaa.h" #include "vgaHW.h" -#define SIS_NAME "SIS" -#define SIS_DRIVER_NAME "sis" -#define SIS_MAJOR_VERSION 0 -#define SIS_MINOR_VERSION 6 -#define SIS_PATCHLEVEL 0 -#define SIS_CURRENT_VERSION ((SIS_MAJOR_VERSION << 16) | \ - (SIS_MINOR_VERSION << 8) | SIS_PATCHLEVEL ) - -#define UMA 0x00000001 -#define MMIOMODE 0x00000001 -#define LFBQMODE 0x00000002 -#define AGPQMODE 0x00000004 - -#define BIOS_BASE 0xC0000 -#define BIOS_SIZE 0x10000 - -#define CRT2_LCD 0x00000010 -#define CRT2_TV 0x00000020 -#define CRT2_VGA 0x00000040 -#define CRT2_ENABLE 0x00000070 -#define LCD_800x600 0x00000100 -#define LCD_1024x768 0x00000200 -#define LCD_1280x1024 0x00000400 -#define LCD_TYPE 0x00000700 -#define TV_NTSC 0x00001000 -#define TV_PAL 0x00002000 -#define TV_HIVISION 0x00004000 -#define TV_TYPE 0x00007000 -#define TV_AVIDEO 0x00010000 -#define TV_SVIDEO 0x00020000 -#define TV_SCART 0x00040000 -#define TV_INTERFACE 0x00070000 -#define SIS301 0x00100000 -#define SIS302 0x00200000 -#define LVDS 0x01000000 -#define CHRONTEL_TV 0x02000000 -#define SINGLE_MODE 0x00000000 -#define SIMU_MODE 0x10000000 -#define MM_MODE 0x20000000 -#define DISPLAY_MODE 0x30000000 +#ifdef XF86DRI +#include "xf86drm.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "GL/glxint.h" +#include "sis_dri.h" +#endif + +#include "xf86xv.h" +#define SIS_NAME "SIS" +#define SIS_DRIVER_NAME "sis" +#define SIS_MAJOR_VERSION 0 +#define SIS_MINOR_VERSION 6 +#define SIS_PATCHLEVEL 0 +#define SIS_CURRENT_VERSION ((SIS_MAJOR_VERSION << 16) | \ + (SIS_MINOR_VERSION << 8) | SIS_PATCHLEVEL ) + +#define UMA 0x00000001 +#define MMIOMODE 0x00000001 +#define LFBQMODE 0x00000002 +#define AGPQMODE 0x00000004 + +#define BIOS_BASE 0xC0000 +#define BIOS_SIZE 0x10000 + +#define CRT2_DEFAULT 0x00000001 +#define CRT2_LCD 0x00000010 +#define CRT2_TV 0x00000020 +#define CRT2_VGA 0x00000040 +#define CRT2_ENABLE 0x00000070 +#define LCD_800x600 0x00000100 +#define LCD_1024x768 0x00000200 +#define LCD_1280x1024 0x00000400 +#define LCD_TYPE 0x00000700 +#define TV_NTSC 0x00001000 +#define TV_PAL 0x00002000 +#define TV_HIVISION 0x00004000 +#define TV_TYPE 0x00007000 +#define TV_AVIDEO 0x00010000 +#define TV_SVIDEO 0x00020000 +#define TV_SCART 0x00040000 +#define TV_INTERFACE 0x00070000 +#define VB_301 0x00100000 +#define VB_302 0x00200000 +#define VB_303 0x00400000 +#define VB_LVDS 0x01000000 +#define VB_CHRONTEL 0x02000000 +#define SINGLE_MODE 0x00000000 +#define SIMU_MODE 0x10000000 +#define MM_MODE 0x20000000 +#define DISPLAY_MODE 0x30000000 + +#define MASK_DISPTYPE_CRT2 0x04 /* Connect LCD */ +#define MASK_DISPTYPE_LCD 0x02 /* Connect LCD */ +#define MASK_DISPTYPE_TV 0x01 /* Connect TV */ +#define MASK_DISPTYPE_DISP2 (MASK_DISPTYPE_LCD | MASK_DISPTYPE_TV | MASK_DISPTYPE_CRT2) -#ifdef DEBUG -#define PDEBUG(p) p +#ifdef DEBUG +#define PDEBUG(p) p #else -#define PDEBUG(p) +#define PDEBUG(p) #endif typedef struct { - unsigned char sisRegs3C4[0x50]; - unsigned char sisRegs3D4[0x40]; - unsigned char sisRegs3C2; - unsigned char VBPart1[0x29]; - unsigned char VBPart2[0x46]; - unsigned char VBPart3[0x3F]; - unsigned char VBPart4[0x1C]; + unsigned char sisRegs3C4[0x50]; + unsigned char sisRegs3D4[0x40]; + unsigned char sisRegs3C2; + unsigned char VBPart1[0x29]; + unsigned char VBPart2[0x46]; + unsigned char VBPart3[0x3F]; + unsigned char VBPart4[0x1C]; + unsigned short ch7005[0x11]; } SISRegRec, *SISRegPtr; -#define SISPTR(p) ((SISPtr)((p)->driverPrivate)) -#define XAAPTR(p) ((XAAInfoRecPtr)(SISPTR(p)->AccelInfoPtr)) +#define SISPTR(p) ((SISPtr)((p)->driverPrivate)) +#define XAAPTR(p) ((XAAInfoRecPtr)(SISPTR(p)->AccelInfoPtr)) typedef struct { - ScrnInfoPtr pScrn; - pciVideoPtr PciInfo; - PCITAG PciTag; - EntityInfoPtr pEnt; - int Chipset; - int ChipRev; - CARD32 FbAddress; /* VRAM physical address */ - unsigned char * FbBase; /* VRAM linear address */ - CARD32 IOAddress; /* MMIO physical address */ - unsigned char * IOBase; /* MMIO linear address */ + ScrnInfoPtr pScrn; + pciVideoPtr PciInfo; + PCITAG PciTag; + EntityInfoPtr pEnt; + int Chipset; + int ChipRev; + unsigned long FbAddress; /* VRAM physical address */ + unsigned char * FbBase; /* VRAM linear address */ + CARD32 IOAddress; /* MMIO physical address */ + unsigned char * IOBase; /* MMIO linear address */ #ifdef __alpha__ - unsigned char * IOBaseDense; /* MMIO for Alpha platform */ + unsigned char * IOBaseDense; /* MMIO for Alpha platform */ #endif - CARD16 RelIO; /* Relocate IO Base */ - unsigned char * BIOS; - int MemClock; - int BusWidth; - int MinClock; - int MaxClock; - int Flags; /* HW config flags */ - long FbMapSize; - DGAModePtr DGAModes; - int numDGAModes; - Bool DGAactive; - int DGAViewportStatus; - Bool NoAccel; - Bool HWCursor; - Bool UsePCIRetry; - Bool TurboQueue; - Bool ValidWidth; - Bool FastVram; - int VBFlags; - int LCDFlags; - int TVFlags; - short scrnOffset; - short DstColor; - int Xdirection; - int Ydirection; - int sisPatternReg[4]; - int ROPReg; - int CommandReg; - int MaxCMDQueueLen; - int CurCMDQueueLen; - int MinCMDQueueLen; - int DstX; - int DstY; - unsigned char * XAAScanlineColorExpandBuffers[2]; - CARD32 AccelFlags; - Bool ClipEnabled; - Bool DoColorExpand; - SISRegRec SavedReg; - SISRegRec ModeReg; - xf86CursorInfoPtr CursorInfoPtr; - XAAInfoRecPtr AccelInfoPtr; - CloseScreenProcPtr CloseScreen; - unsigned int (*ddc1Read)(ScrnInfoPtr); - Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode); - Bool (*ModeInit2)(ScrnInfoPtr pScrn, DisplayModePtr mode); - void (*SiSSave)(ScrnInfoPtr pScrn, SISRegPtr sisreg); - void (*SiSSave2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); - void (*SiSRestore)(ScrnInfoPtr pScrn, SISRegPtr sisreg); - void (*SiSRestore2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); - void (*SetThreshold)(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); - void (*SetThreshold2)(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); - void (*LoadCRT2Palette)(ScrnInfoPtr pScrn, int numColors, - int *indicies, LOCO *colors, VisualPtr pVisual); + CARD16 RelIO; /* Relocate IO Base */ + unsigned char * BIOS; + int MemClock; + int BusWidth; + int MinClock; + int MaxClock; + int Flags; /* HW config flags */ + long FbMapSize; + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; + Bool NoAccel; + Bool HWCursor; + Bool UsePCIRetry; + Bool TurboQueue; + int ForceCRT2Type; + Bool ValidWidth; + Bool FastVram; + int VBFlags; + short scrnOffset; + short DstColor; + int Xdirection; + int Ydirection; + int sisPatternReg[4]; + int ROPReg; + int CommandReg; + int MaxCMDQueueLen; + int CurCMDQueueLen; + int MinCMDQueueLen; + int DstX; + int DstY; + unsigned char * XAAScanlineColorExpandBuffers[2]; + CARD32 AccelFlags; + Bool ClipEnabled; + Bool DoColorExpand; + SISRegRec SavedReg; + SISRegRec ModeReg; + xf86CursorInfoPtr CursorInfoPtr; + XAAInfoRecPtr AccelInfoPtr; + CloseScreenProcPtr CloseScreen; + unsigned int (*ddc1Read)(ScrnInfoPtr); + Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode); + void (*SiSSave)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSSave2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSSaveLVDS)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSSaveChrontel)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSRestore)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSRestore2)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSRestoreLVDS)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SiSRestoreChrontel)(ScrnInfoPtr pScrn, SISRegPtr sisreg); + void (*SetThreshold)(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned short *Low, unsigned short *High); + void (*LoadCRT2Palette)(ScrnInfoPtr pScrn, int numColors, + int *indicies, LOCO *colors, VisualPtr pVisual); + + int *cmdQueueLenPtr; + unsigned long agpHandle; + CARD32 agpAddr; + unsigned char *agpBase; + unsigned int agpSize; + CARD32 agpCmdBufAddr; + unsigned char *agpCmdBufBase; + unsigned int agpCmdBufSize; + unsigned int agpCmdBufFree; + Bool irqEnabled; + int irq; + int ColorExpandRingHead; + int ColorExpandRingTail; + int PerColorExpandBufferSize; + int ColorExpandBufferNumber; + int ColorExpandBufferCountMask; + unsigned char *ColorExpandBufferAddr[32]; + int ColorExpandBufferScreenOffset[32]; + int ImageWriteBufferSize; + unsigned char *ImageWriteBufferAddr; + +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmSubFD; + int numVisualConfigs; + __GLXvisualConfig* pVisualConfigs; + SISConfigPrivPtr pVisualConfigsPriv; + SISRegRec DRContextRegs; +#endif + + XF86VideoAdaptorPtr adaptor; + ScreenBlockHandlerProcPtr BlockHandler; } SISRec, *SISPtr; /* Prototypes */ void SiSOptions(ScrnInfoPtr pScrn); -void SISVGAPreInit(ScrnInfoPtr pScrn); -void SISLCDPreInit(ScrnInfoPtr pScrn); -void SISTVPreInit(ScrnInfoPtr pScrn); +void SISVGAPreInit(ScrnInfoPtr pScrn); +void SISLCDPreInit(ScrnInfoPtr pScrn); +void SISTVPreInit(ScrnInfoPtr pScrn); +void SISCRT2PreInit(ScrnInfoPtr pScrn); OptionInfoPtr SISAvailableOptions(int chipid, int busid); -void SISDACPreInit(ScrnInfoPtr pScrn); -void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, - LOCO *colors, VisualPtr pVisual); +void SISDACPreInit(ScrnInfoPtr pScrn); +void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, + LOCO *colors, VisualPtr pVisual); int compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, - int *out_sbit, int *out_scale); + int *out_sbit, int *out_scale); void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, - unsigned int *vclk); + unsigned int *vclk); unsigned int SiSddc1Read(ScrnInfoPtr pScrn); Bool SiSAccelInit(ScreenPtr pScreen); Bool SiS530AccelInit(ScreenPtr pScreen); @@ -196,8 +251,19 @@ void SiSIODump(ScrnInfoPtr pScreen); void SiSInitializeAccelerator(ScrnInfoPtr pScrn); void SiSSetup(ScrnInfoPtr pScrn); +void SiSPreSetMode(ScrnInfoPtr pScrn); -extern Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -extern void SISAdjustFrame(int scrnIndex, int x, int y, int flags); +extern void SetReg1(unsigned short, unsigned short, unsigned short); +extern unsigned short GetReg1(unsigned short, unsigned short); + +extern Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +extern void SISAdjustFrame(int scrnIndex, int x, int y, int flags); + +#ifdef XF86DRI +extern void FillPrivateDRI(SISPtr pSIS, SISDRIPtr pSISDRI); +extern Bool SISDRIScreenInit(ScreenPtr pScreen); +extern void SISDRICloseScreen(ScreenPtr pScreen); +Bool SISDRIFinishScreenInit(ScreenPtr pScreen); +#endif #endif Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c:1.3 Fri Mar 31 15:13:35 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c Wed Dec 13 21:51:40 2000 @@ -1,14 +1,14 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.3 2000/03/31 20:13:35 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.5 2000/12/14 02:51:40 dawes Exp $ */ /* * - * Acceleration for SiS300 SiS630 SiS540. - * It is done in a separate file because the register formats are + * Acceleration for SiS300 SiS630 SiS540. + * It is done in a separate file because the register formats are * very different from the previous chips. * * - * - * Xavier Ducoin <x.ducoin@lectra.com> + * + * Xavier Ducoin <x.ducoin@lectra.com> */ #if 0 #define DEBUG @@ -17,6 +17,7 @@ #include <xf86.h> #include <xf86_OSproc.h> #include <xf86_ansic.h> +#include <xf86_libc.h> #include <xf86PciInfo.h> #include <xf86Pci.h> @@ -32,612 +33,783 @@ #include "sis.h" #include "sis300_accel.h" - -#ifdef DEBUG +#ifdef DEBUG static void MMIODump(ScrnInfoPtr pScrn); #endif static void SiSSync(ScrnInfoPtr pScrn); static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, int trans_color); + int xdir, int ydir, int rop, + unsigned int planemask, int trans_color); static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, - int x1, int y1, int x2, int y2, - int width, int height); + int x1, int y1, int x2, int y2, + int width, int height); static void SiSSetupForSolidFill(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask); + int rop, unsigned int planemask); static void SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h); + int x, int y, int w, int h); static void SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, - int rop, unsigned int planemask); + int rop, unsigned int planemask); static void SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, - int y1, int x2, int y2, int flags); + int y1, int x2, int y2, int flags); static void SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, - int x, int y, int len, int dir); + int x, int y, int len, int dir); static void SiSSetupForDashedLine(ScrnInfoPtr pScrn, - int fg, int bg, int rop, unsigned int planemask, - int length, unsigned char *pattern); + int fg, int bg, int rop, unsigned int planemask, + int length, unsigned char *pattern); static void SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, - int x1, int y1, int x2, int y2, - int flags, int phase); + int x1, int y1, int x2, int y2, + int flags, int phase); static void SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, int fg, int bg, - int rop, unsigned int planemask); + int patx, int paty, int fg, int bg, + int rop, unsigned int planemask); static void SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h); + int patx, int paty, + int x, int y, int w, int h); static void SiSSetupForColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, int rop, - unsigned int planemask, - int trans_color); + int patx, int paty, int rop, + unsigned int planemask, + int trans_color); static void SiSSubsequentColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h); + int patx, int paty, + int x, int y, int w, int h); static void SiSSetupForCPUToScreenColorExpand(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, unsigned int planemask); + int fg, int bg, + int rop, unsigned int planemask); static void SiSSubsequentCPUToScreenColorExpand(ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft); + int x, int y, int w, int h, int skipleft); static void SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, unsigned int planemask); + int fg, int bg, + int rop, unsigned int planemask); static void SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int srcx, int srcy, int skipleft); + int x, int y, int w, int h, + int srcx, int srcy, int skipleft); + +static void SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask); +static void SiSSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); +static void SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); + + +static void SiSSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int trans_color, int bpp, int depth); +static void SiSSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); + +static void SiSSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int trans_color, int bpp, int depth) {} +static void SiSSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) {} void SiSInitializeAccelerator(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - pSiS->DoColorExpand = FALSE; + pSiS->DoColorExpand = FALSE; } Bool SiS300AccelInit(ScreenPtr pScreen) { - XAAInfoRecPtr infoPtr; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SISPtr pSiS = SISPTR(pScrn); - int reservedFbSize, UsableFbSize; - BoxRec Avail; - - pSiS->AccelInfoPtr = infoPtr = XAACreateInfoRec(); - if (!infoPtr) return FALSE; - - SiSInitializeAccelerator(pScrn); - - infoPtr->Flags = LINEAR_FRAMEBUFFER | - OFFSCREEN_PIXMAPS | - PIXMAP_CACHE; - - /* sync */ - infoPtr->Sync = SiSSync; - - if ((pScrn->bitsPerPixel != 8) && (pScrn->bitsPerPixel != 16) && - (pScrn->bitsPerPixel != 32)) return FALSE; - - /* BitBlt */ - infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; - infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; - infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY; - - /* solid fills */ - infoPtr->SetupForSolidFill = SiSSetupForSolidFill; - infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; - infoPtr->SolidFillFlags = NO_PLANEMASK; - - /* solid line */ - infoPtr->SetupForSolidLine = SiSSetupForSolidLine; - infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine; - infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorzVertLine; - infoPtr->SolidFillFlags = NO_PLANEMASK; - - /* dashed line */ - infoPtr->SetupForDashedLine = SiSSetupForDashedLine; - infoPtr->SubsequentDashedTwoPointLine = SiSSubsequentDashedTwoPointLine; - infoPtr->DashPatternMaxLength = 64; - infoPtr->DashedLineFlags = NO_PLANEMASK | - LINE_PATTERN_MSBFIRST_LSBJUSTIFIED; - - /* 8x8 mono pattern fill - infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = - SiSSubsequentMonoPatternFill; - infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS | - NO_TRANSPARENCY | - BIT_ORDER_IN_BYTE_MSBFIRST ; + XAAInfoRecPtr infoPtr; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSiS = SISPTR(pScrn); + int reservedFbSize; + int UsableFbSize; + unsigned char *AvailBufBase; + BoxRec Avail; + int i, divider; + + pSiS->AccelInfoPtr = infoPtr = XAACreateInfoRec(); + if (!infoPtr) return FALSE; + + SiSInitializeAccelerator(pScrn); + + infoPtr->Flags = LINEAR_FRAMEBUFFER | + OFFSCREEN_PIXMAPS | + PIXMAP_CACHE; + + /* sync */ + infoPtr->Sync = SiSSync; + + if ((pScrn->bitsPerPixel != 8) && (pScrn->bitsPerPixel != 16) && + (pScrn->bitsPerPixel != 32)) return FALSE; + + /* BitBlt */ + infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; + infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; + infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY; + + /* solid fills */ + infoPtr->SetupForSolidFill = SiSSetupForSolidFill; + infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect; + infoPtr->SolidFillFlags = NO_PLANEMASK; + + /* solid line */ + infoPtr->SetupForSolidLine = SiSSetupForSolidLine; + infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine; + infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorzVertLine; + infoPtr->SolidFillFlags = NO_PLANEMASK; + + /* dashed line */ + infoPtr->SetupForDashedLine = SiSSetupForDashedLine; + infoPtr->SubsequentDashedTwoPointLine = SiSSubsequentDashedTwoPointLine; + infoPtr->DashPatternMaxLength = 64; + infoPtr->DashedLineFlags = NO_PLANEMASK | + LINE_PATTERN_MSBFIRST_LSBJUSTIFIED; + + /* 8x8 mono pattern fill */ + infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill; + infoPtr->SubsequentMono8x8PatternFillRect = + SiSSubsequentMonoPatternFill; + infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS | + NO_TRANSPARENCY | + BIT_ORDER_IN_BYTE_MSBFIRST ; + +/* 8x8 color pattern fill ---seems not useful by xaa + infoPtr->SetupForColor8x8PatternFill = + SiSSetupForColorPatternFill; + infoPtr->SubsequentColor8x8PatternFillRect = + SiSSubsequentColorPatternFill; + infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS ; */ - /* 8x8 color pattern fill - infoPtr->SetupForColor8x8PatternFill = - SiSSetupForColorPatternFill; - infoPtr->SubsequentColor8x8PatternFillRect = - SiSSubsequentColorPatternFill; - infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS ; + /* Screen To Screen Color Expand */ +/* infoPtr->SetupForScreenToScreenColorExpandFill = + SiSSetupForScreenToScreenColorExpand; + infoPtr->SubsequentScreenToScreenColorExpandFill = + SiSSubsequentScreenToScreenColorExpand; */ - /* CPU To Screen Color Expand - infoPtr->SetupForCPUToScreenColorExpandFill = - SiSSetupForCPUToScreenColorExpand; - infoPtr->SubsequentCPUToScreenColorExpandFill = - SiSSubsequentCPUToScreenColorExpand; - infoPtr->SetupForScreenToScreenColorExpandFill = - SiSSetupForScreenToScreenColorExpand; - infoPtr->ColorExpandRange = PATREGSIZE; - infoPtr->ColorExpandBase = pSiS->IOBase+PBR(0); - infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | - BIT_ORDER_IN_BYTE_MSBFIRST | - NO_TRANSPARENCY | - SYNC_AFTER_COLOR_EXPAND | - HARDWARE_PATTERN_SCREEN_ORIGIN | - HARDWARE_PATTERN_PROGRAMMED_BITS ; +/* CPU To Screen Color Expand ---implement another instead of this one! + infoPtr->SetupForCPUToScreenColorExpandFill = + SiSSetupForCPUToScreenColorExpand; + infoPtr->SubsequentCPUToScreenColorExpandFill = + SiSSubsequentCPUToScreenColorExpand; + infoPtr->ColorExpandRange = PATREGSIZE; + infoPtr->ColorExpandBase = pSiS->IOBase+PBR(0); + infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | + BIT_ORDER_IN_BYTE_MSBFIRST | + NO_TRANSPARENCY | + SYNC_AFTER_COLOR_EXPAND | + HARDWARE_PATTERN_SCREEN_ORIGIN | + HARDWARE_PATTERN_PROGRAMMED_BITS ; */ - /* Screen To Screen Color Expand - infoPtr->SetupForScreenToScreenColorExpandFill = - SiSSetupForScreenToScreenColorExpand; - infoPtr->SubsequentScreenToScreenColorExpandFill = - SiSSubsequentScreenToScreenColorExpand; - infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK | - BIT_ORDER_IN_BYTE_MSBFIRST | - SYNC_AFTER_COLOR_EXPAND | - NO_TRANSPARENCY; +/* per-scanline color expansion*/ + pSiS->ColorExpandBufferNumber = 16; + pSiS->ColorExpandBufferCountMask = 0x0F; + pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31)/32) * 4; + infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; + infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; + infoPtr->SetupForScanlineCPUToScreenColorExpandFill = SiSSetupForScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = SiSSubsequentScanlineCPUToScreenColorExpandFill; + infoPtr->SubsequentColorExpandScanline = SiSSubsequentColorExpandScanline; + infoPtr->ScanlineCPUToScreenColorExpandFillFlags = + NO_PLANEMASK | + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + BIT_ORDER_IN_BYTE_MSBFIRST | + LEFT_EDGE_CLIPPING; + +/* divider = ((pScrn->virtualX*pScrn->bitsPerPixel)/8)+8; + pSiS->ImageWriteBufferSize = (((12*1024)+divider-1)/divider)*divider; + infoPtr->SetupForImageWrite = SiSSetupForImageWrite; + infoPtr->SubsequentImageWriteRect = SiSSubsequentImageWriteRect; + infoPtr->ImageWriteFlags = CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + LEFT_EDGE_CLIPPING | + NO_PLANEMASK| + NO_TRANSPARENCY | + NO_GXCOPY | + SYNC_AFTER_IMAGE_WRITE; */ + /* init Frame Buffer Manager */ + reservedFbSize = 0; + if (pSiS->TurboQueue) reservedFbSize += 1024*512; + if (pSiS->HWCursor) reservedFbSize += 4096; + reservedFbSize += (pSiS->ColorExpandBufferNumber * pSiS->PerColorExpandBufferSize); + UsableFbSize = pSiS->FbMapSize - reservedFbSize; + AvailBufBase = pSiS->FbBase + UsableFbSize; + for (i=0; i<pSiS->ColorExpandBufferNumber; i++) + { pSiS->ColorExpandBufferAddr[i] = AvailBufBase + i*pSiS->PerColorExpandBufferSize; + pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + i*pSiS->PerColorExpandBufferSize; + } +/* reservedFbSize += pSiS->ImageWriteBufferSize; + UsableFbSize = pSiS->FbMapSize - reservedFbSize; + pSiS->ImageWriteBufferAddr = AvailBufBase = pSiS->FbBase + UsableFbSize; + infoPtr->ImageWriteRange = pSiS->ImageWriteBufferAddr; +*/ + Avail.x1 = 0; + Avail.y1 = 0; + Avail.x2 = pScrn->displayWidth; + Avail.y2 = UsableFbSize / (pScrn->displayWidth * pScrn->bitsPerPixel/8) - 1; + if (Avail.y2 < 0) Avail.y2 = 32767; - /* init Frame Buffer Manager */ - reservedFbSize = 0; - if (pSiS->TurboQueue) reservedFbSize += 1024*512; - if (pSiS->HWCursor) reservedFbSize += 4096; - reservedFbSize = 4096*1024; - UsableFbSize = pSiS->FbMapSize - reservedFbSize; - Avail.x1 = 0; - Avail.y1 = 0; - Avail.x2 = pScrn->displayWidth; - Avail.y2 = UsableFbSize / (pScrn->displayWidth * pScrn->bitsPerPixel/8); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Frame Buffer From (%d,%d) To (%d,%d)\n", - Avail.x1, Avail.y1, Avail.x2, Avail.y2); -/* xf86InitFBManager(pScreen, &Avail); */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Frame Buffer From (%d,%d) To (%d,%d)\n", + Avail.x1, Avail.y1, Avail.x2, Avail.y2); + xf86InitFBManager(pScreen, &Avail); - return(XAAInit(pScreen, infoPtr)); + return(XAAInit(pScreen, infoPtr)); } static void SiSSync(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("SiSSync()\n")); + PDEBUG(ErrorF("SiSSync()\n")); + pSiS->DoColorExpand = FALSE; + SiSIdle - if (pSiS->DoColorExpand) - SiSDoCMD - pSiS->DoColorExpand = FALSE; - SiSIdle } static int sisALUConv[] = { - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0x88, /* dest &= src; DSa, GXand, 0x1 */ - 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ - 0xCC, /* dest = src; S, GXcopy, 0x3 */ - 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ - 0xEE, /* dest |= src; DSo, GXor, 0x7 */ - 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ - 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ - 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ - 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ - 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ + 0x00, /* dest = 0; 0, GXclear, 0 */ + 0x88, /* dest &= src; DSa, GXand, 0x1 */ + 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ + 0xCC, /* dest = src; S, GXcopy, 0x3 */ + 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ + 0xAA, /* dest = dest; D, GXnoop, 0x5 */ + 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ + 0xEE, /* dest |= src; DSo, GXor, 0x7 */ + 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ + 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ + 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ + 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ + 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ + 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ + 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ + 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ }; /* same ROP but with Pattern as Source */ static int sisPatALUConv[] = { - 0x00, /* dest = 0; 0, GXclear, 0 */ - 0xA0, /* dest &= src; DPa, GXand, 0x1 */ - 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ - 0xF0, /* dest = src; P, GXcopy, 0x3 */ - 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ - 0xAA, /* dest = dest; D, GXnoop, 0x5 */ - 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ - 0xFA, /* dest |= src; DPo, GXor, 0x7 */ - 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ - 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ - 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ - 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ - 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ - 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ - 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ - 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ + 0x00, /* dest = 0; 0, GXclear, 0 */ + 0xA0, /* dest &= src; DPa, GXand, 0x1 */ + 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ + 0xF0, /* dest = src; P, GXcopy, 0x3 */ + 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ + 0xAA, /* dest = dest; D, GXnoop, 0x5 */ + 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ + 0xFA, /* dest |= src; DPo, GXor, 0x7 */ + 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ + 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ + 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ + 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ + 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ + 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ + 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ + 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ }; static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, - int xdir, int ydir, int rop, - unsigned int planemask, int trans_color) + int xdir, int ydir, int rop, + unsigned int planemask, int trans_color) { - SISPtr pSiS = SISPTR(pScrn); -/* XAAInfoRecPtr pXAA = XAAPTR(pScrn);*/ + SISPtr pSiS = SISPTR(pScrn); +/* XAAInfoRecPtr pXAA = XAAPTR(pScrn);*/ + PDEBUG(ErrorF("Setup ScreenCopy(%d, %d, 0x%x, 0x%x, 0x%x)\n", + xdir, ydir, rop, planemask, trans_color)); - PDEBUG(ErrorF("Setup ScreenCopy(%d, %d, 0x%x, 0x%x, 0x%x)\n", - xdir, ydir, rop, planemask, trans_color)); /* - ErrorF("XAAInfoPtr->UsingPixmapCache = %s\n" - "XAAInfoPtr->CanDoMono8x8 = %s\n" - "XAAInfoPtr->CanDoColor8x8 = %s\n" - "XAAInfoPtr->CachePixelGranularity = %d\n" - "XAAInfoPtr->MaxCacheableTileWidth = %d\n" - "XAAInfoPtr->MaxCacheableTileHeight = %d\n" - "XAAInfoPtr->MaxCacheableStippleWidth = %d\n" - "XAAInfoPtr->MaxCacheableStippleHeight = %d\n" - "XAAInfoPtr->MonoPatternPitch = %d\n" - "XAAInfoPtr->CacheWidthMono8x8Pattern = %d\n" - "XAAInfoPtr->CacheHeightMono8x8Pattern = %d\n" - "XAAInfoPtr->ColorPatternPitch = %d\n" - "XAAInfoPtr->CacheWidthColor8x8Pattern = %d\n" - "XAAInfoPtr->CacheHeightColor8x8Pattern = %d\n" - "XAAInfoPtr->CacheColorExpandDensity = %d\n" - "XAAInfoPtr->maxOffPixWidth = %d\n" - "XAAInfoPtr->maxOffPixHeight= %d\n" - "XAAInfoPtr->NeedToSync = %s\n" - "\n", - pXAA->UsingPixmapCache ? "True" : "False", - pXAA->CanDoMono8x8 ? "True" : "False", - pXAA->CanDoColor8x8 ? "True" : "False", - pXAA->CachePixelGranularity, - pXAA->MaxCacheableTileWidth, - pXAA->MaxCacheableTileHeight, - pXAA->MaxCacheableStippleWidth, - pXAA->MaxCacheableStippleHeight, - pXAA->MonoPatternPitch, - pXAA->CacheWidthMono8x8Pattern, - pXAA->CacheHeightMono8x8Pattern, - pXAA->ColorPatternPitch, - pXAA->CacheWidthColor8x8Pattern, - pXAA->CacheHeightColor8x8Pattern, - pXAA->CacheColorExpandDensity, - pXAA->maxOffPixWidth, - pXAA->maxOffPixHeight, - pXAA->NeedToSync ? "True" : "False"); + ErrorF("XAAInfoPtr->UsingPixmapCache = %s\n" + "XAAInfoPtr->CanDoMono8x8 = %s\n" + "XAAInfoPtr->CanDoColor8x8 = %s\n" + "XAAInfoPtr->CachePixelGranularity = %d\n" + "XAAInfoPtr->MaxCacheableTileWidth = %d\n" + "XAAInfoPtr->MaxCacheableTileHeight = %d\n" + "XAAInfoPtr->MaxCacheableStippleWidth = %d\n" + "XAAInfoPtr->MaxCacheableStippleHeight = %d\n" + "XAAInfoPtr->MonoPatternPitch = %d\n" + "XAAInfoPtr->CacheWidthMono8x8Pattern = %d\n" + "XAAInfoPtr->CacheHeightMono8x8Pattern = %d\n" + "XAAInfoPtr->ColorPatternPitch = %d\n" + "XAAInfoPtr->CacheWidthColor8x8Pattern = %d\n" + "XAAInfoPtr->CacheHeightColor8x8Pattern = %d\n" + "XAAInfoPtr->CacheColorExpandDensity = %d\n" + "XAAInfoPtr->maxOffPixWidth = %d\n" + "XAAInfoPtr->maxOffPixHeight= %d\n" + "XAAInfoPtr->NeedToSync = %s\n" + "\n", + pXAA->UsingPixmapCache ? "True" : "False", + pXAA->CanDoMono8x8 ? "True" : "False", + pXAA->CanDoColor8x8 ? "True" : "False", + pXAA->CachePixelGranularity, + pXAA->MaxCacheableTileWidth, + pXAA->MaxCacheableTileHeight, + pXAA->MaxCacheableStippleWidth, + pXAA->MaxCacheableStippleHeight, + pXAA->MonoPatternPitch, + pXAA->CacheWidthMono8x8Pattern, + pXAA->CacheHeightMono8x8Pattern, + pXAA->ColorPatternPitch, + pXAA->CacheWidthColor8x8Pattern, + pXAA->CacheHeightColor8x8Pattern, + pXAA->CacheColorExpandDensity, + pXAA->maxOffPixWidth, + pXAA->maxOffPixHeight, + pXAA->NeedToSync ? "True" : "False"); */ - - SiSSetupSRCBase(0) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupSRCPitch(pSiS->scrnOffset) - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupROP(sisALUConv[rop]) - if (xdir > 0) SiSSetupCMDFlag(X_INC) - if (ydir > 0) SiSSetupCMDFlag(Y_INC) + + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupSRCPitch(pSiS->scrnOffset) + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupROP(sisALUConv[rop]) + if (xdir > 0) SiSSetupCMDFlag(X_INC) + if (ydir > 0) SiSSetupCMDFlag(Y_INC) } static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, - int src_x, int src_y, int dst_x, int dst_y, - int width, int height) + int src_x, int src_y, int dst_x, int dst_y, + int width, int height) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long srcbase, dstbase; - PDEBUG(ErrorF("Subsequent ScreenCopy(%d,%d, %d,%d, %d,%d)\n", - src_x, src_y, dst_x, dst_y, width, height)); + PDEBUG(ErrorF("Subsequent ScreenCopy(%d,%d, %d,%d, %d,%d)\n", + src_x, src_y, dst_x, dst_y, width, height)); - if (!(pSiS->CommandReg & X_INC)) { - src_x += width-1; - dst_x += width-1; - } - if (!(pSiS->CommandReg & Y_INC)) { - src_y += height-1; - dst_y += height-1; - } - SiSSetupRect(width, height) - SiSSetupSRCXY(src_x,src_y) - SiSSetupDSTXY(dst_x,dst_y) - SiSDoCMD + srcbase=dstbase=0; + if (src_y >= 2048) + { srcbase=pSiS->scrnOffset*src_y; + src_y=0; + } + if (dst_y >= pScrn->virtualY) + { dstbase=pSiS->scrnOffset*dst_y; + dst_y=0; + } + SiSSetupSRCBase(srcbase); + SiSSetupDSTBase(dstbase); + if (!(pSiS->CommandReg & X_INC)) { + src_x += width-1; + dst_x += width-1; + } + if (!(pSiS->CommandReg & Y_INC)) { + src_y += height-1; + dst_y += height-1; + } + SiSSetupRect(width, height) + SiSSetupSRCXY(src_x,src_y) + SiSSetupDSTXY(dst_x,dst_y) + SiSDoCMD } static void SiSSetupForSolidFill(ScrnInfoPtr pScrn, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("Setup SolidFill(0x%x, 0x%x, 0x%x)\n", - color, rop, planemask)); + PDEBUG(ErrorF("Setup SolidFill(0x%x, 0x%x, 0x%x)\n", + color, rop, planemask)); - SiSSetupPATFG(color) - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(X_INC | Y_INC | PATFG | BITBLT) + SiSSetupPATFG(color) +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(X_INC | Y_INC | PATFG | BITBLT) } static void SiSSubsequentSolidFillRect(ScrnInfoPtr pScrn, - int x, int y, int w, int h) + int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); - - PDEBUG(ErrorF("Subsequent SolidFillRect(%d, %d, %d, %d)\n", - x, y, w, h)); + SISPtr pSiS = SISPTR(pScrn); + long dstbase; - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) - SiSDoCMD + PDEBUG(ErrorF("Subsequent SolidFillRect(%d, %d, %d, %d)\n", + x, y, w, h)); + dstbase=0; + if (y>=2048) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + SiSSetupDSTBase(dstbase) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) + SiSDoCMD } static void SiSSetupForSolidLine(ScrnInfoPtr pScrn, - int color, int rop, unsigned int planemask) + int color, int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("Setup SolidLine(0x%x, 0x%x, 0x%x)\n", - color, rop, planemask)); + PDEBUG(ErrorF("Setup SolidLine(0x%x, 0x%x, 0x%x)\n", + color, rop, planemask)); - SiSSetupLineCount(1) - SiSSetupPATFG(color) - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(PATFG | LINE) + SiSSetupLineCount(1) + SiSSetupPATFG(color) +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(PATFG | LINE) } static void SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, - int x1, int y1, int x2, int y2, int flags) + int x1, int y1, int x2, int y2, int flags) { - SISPtr pSiS = SISPTR(pScrn); - - PDEBUG(ErrorF("Subsequent SolidLine(%d, %d, %d, %d, 0x%x)\n", - x1, y1, x2, y2, flags)); + SISPtr pSiS = SISPTR(pScrn); + long dstbase,miny,maxy; - SiSSetupX0Y0(x1,y1) - SiSSetupX1Y1(x2,y2) - if (flags & OMIT_LAST) - SiSSetupCMDFlag(NO_LAST_PIXEL) - SiSDoCMD + PDEBUG(ErrorF("Subsequent SolidLine(%d, %d, %d, %d, 0x%x)\n", + x1, y1, x2, y2, flags)); + dstbase=0; + miny=(y1>y2)?y2:y1; + maxy=(y1>y2)?y1:y2; + if (maxy>=2048) + { dstbase=pSiS->scrnOffset*miny; + y1-=miny; + y2-=miny; + } + SiSSetupDSTBase(dstbase) + + SiSSetupX0Y0(x1,y1) + SiSSetupX1Y1(x2,y2) + if (flags & OMIT_LAST) + SiSSetupCMDFlag(NO_LAST_PIXEL) + SiSDoCMD } static void SiSSubsequentSolidHorzVertLine(ScrnInfoPtr pScrn, - int x, int y, int len, int dir) + int x, int y, int len, int dir) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long dstbase; - PDEBUG(ErrorF("Subsequent SolidHorzVertLine(%d, %d, %d, %d)\n", - x, y, len, dir)); + PDEBUG(ErrorF("Subsequent SolidHorzVertLine(%d, %d, %d, %d)\n", + x, y, len, dir)); - SiSSetupX0Y0(x,y) - if (dir==DEGREES_0) - SiSSetupX1Y1(x+len,y) - else - SiSSetupX1Y1(x,y+len) - SiSDoCMD + dstbase=0; + if ((y>=2048) || ((y+len)>=2048)) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + SiSSetupDSTBase(dstbase) + + SiSSetupX0Y0(x,y) + if (dir==DEGREES_0) + { SiSSetupX1Y1(x+len,y);} + else + { SiSSetupX1Y1(x,y+len);} + SiSDoCMD } static void SiSSetupForDashedLine(ScrnInfoPtr pScrn, - int fg, int bg, int rop, unsigned int planemask, - int length, unsigned char *pattern) + int fg, int bg, int rop, unsigned int planemask, + int length, unsigned char *pattern) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("Setup DashedLine(0x%x, 0x%x, 0x%x, 0x%x, %d, 0x%x:%x)\n", - fg, bg, rop, planemask, length, *(pattern+4), *pattern)); + PDEBUG(ErrorF("Setup DashedLine(0x%x, 0x%x, 0x%x, 0x%x, %d, 0x%x:%x)\n", + fg, bg, rop, planemask, length, *(pattern+4), *pattern)); - SiSSetupLineCount(1) - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupStyleLow(*pattern) - SiSSetupStyleHigh(*(pattern+4)) - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupPATFG(fg) - if (bg != -1) SiSSetupPATBG(bg) + SiSSetupLineCount(1) +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupStyleLow(*pattern) + SiSSetupStyleHigh(*(pattern+4)) + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupPATFG(fg) + if (bg != -1) SiSSetupPATBG(bg) } static void SiSSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, - int x1, int y1, int x2, int y2, - int flags, int phase) + int x1, int y1, int x2, int y2, + int flags, int phase) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long dstbase,miny,maxy; - PDEBUG(ErrorF("Subsequent DashedLine(%d,%d, %d,%d, 0x%x,0x%x)\n", - x1, y1, x2, y2, flags, phase)); + PDEBUG(ErrorF("Subsequent DashedLine(%d,%d, %d,%d, 0x%x,0x%x)\n", + x1, y1, x2, y2, flags, phase)); - SiSSetupX0Y0(x1,y1) - SiSSetupX1Y1(x2,y2) - if (flags & OMIT_LAST) - SiSSetupCMDFlag(NO_LAST_PIXEL) - SiSDoCMD + dstbase=0; + miny=(y1>y2)?y2:y1; + maxy=(y1>y2)?y1:y2; + if (maxy>=2048) + { dstbase=pSiS->scrnOffset*miny; + y1-=miny; + y2-=miny; + } + SiSSetupDSTBase(dstbase) + + SiSSetupX0Y0(x1,y1) + SiSSetupX1Y1(x2,y2) + if (flags & OMIT_LAST) + SiSSetupCMDFlag(NO_LAST_PIXEL) + SiSDoCMD } + + static void SiSSetupForMonoPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, int fg, int bg, - int rop, unsigned int planemask) + int patx, int paty, int fg, int bg, + int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("Setup MonoPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x, 0x%x)\n", - patx, paty, fg, bg, rop, planemask)); + PDEBUG(ErrorF("Setup MonoPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x, 0x%x)\n", + patx, paty, fg, bg, rop, planemask)); - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupMONOPAT(patx,paty) - SiSSetupPATFG(fg) - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(PATMONO | X_INC | Y_INC) -/* if (bg==-1) - SiSSetupCMDFlag(TRANSPARENT) - else*/ - SiSSetupPATBG(bg) + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupMONOPAT(patx,paty) + SiSSetupPATFG(fg) + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(PATMONO | X_INC | Y_INC) + SiSSetupPATBG(bg) } static void SiSSubsequentMonoPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h) + int patx, int paty, + int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long dstbase; - PDEBUG(ErrorF("Subsequent MonoPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", - patx, paty, x, y, w, h)); - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) - SiSDoCMD + PDEBUG(ErrorF("Subsequent MonoPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", + patx, paty, x, y, w, h)); + dstbase=0; + if (y>=2048) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + + SiSSetupDSTBase(dstbase) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) + SiSDoCMD } static void SiSSetupForColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, int rop, - unsigned int planemask, - int trans_color) -{ - SISPtr pSiS = SISPTR(pScrn); - - PDEBUG(ErrorF("Setup ColorPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x)\n", - patx, paty, rop, planemask, trans_color)); - - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(PATPATREG | X_INC | Y_INC) + int patx, int paty, int rop, + unsigned int planemask, + int trans_color) +{ + SISPtr pSiS = SISPTR(pScrn); + + PDEBUG(ErrorF("Setup ColorPatFill(0x%x,0x%x, 0x%x,0x%x, 0x%x)\n", + patx, paty, rop, planemask, trans_color)); + +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(PATPATREG | X_INC | Y_INC) } static void SiSSubsequentColorPatternFill(ScrnInfoPtr pScrn, - int patx, int paty, - int x, int y, int w, int h) + int patx, int paty, + int x, int y, int w, int h) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long dstbase; - PDEBUG(ErrorF("Subsequent ColorPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", - patx, paty, x, y, w, h)); - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) - SiSDoCMD + PDEBUG(ErrorF("Subsequent ColorPatFill(0x%x,0x%x, %d,%d, %d,%d)\n", + patx, paty, x, y, w, h)); + + dstbase=0; + if (y>=2048) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + SiSSetupDSTBase(dstbase) + + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) + SiSDoCMD } static void SiSSetupForCPUToScreenColorExpand(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, unsigned int planemask) + int fg, int bg, + int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); - XAAInfoRecPtr pXAA = XAAPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); +/* XAAInfoRecPtr pXAA = XAAPTR(pScrn); */ - PDEBUG(ErrorF("Setup CPUToScreen ColorExpand(0x%x,0x%x, 0x%x,0x%x)\n", - fg, bg, rop, planemask)); + PDEBUG(ErrorF("Setup CPUToScreen ColorExpand(0x%x,0x%x, 0x%x,0x%x)\n", + fg, bg, rop, planemask)); - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupSRCXY(0,0) - SiSSetupSRCFG(fg) - SiSSetupROP(sisPatALUConv[rop]) - SiSSetupCMDFlag(X_INC | Y_INC | COLOREXP) - if (bg==-1) - SiSSetupCMDFlag(TRANSPARENT) - else - SiSSetupSRCBG(bg) +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupSRCXY(0,0) + SiSSetupSRCFG(fg) + SiSSetupROP(sisPatALUConv[rop]) + SiSSetupCMDFlag(X_INC | Y_INC | COLOREXP) + if (bg==-1) + SiSSetupCMDFlag(TRANSPARENT) + else + SiSSetupSRCBG(bg) } static void SiSSubsequentCPUToScreenColorExpand(ScrnInfoPtr pScrn, - int x, int y, int w, int h, int skipleft) + int x, int y, int w, int h, int skipleft) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); + long dstbase; - PDEBUG(ErrorF("Subsequent CPUToScreen ColorExpand(%d,%d, %d,%d, %d)\n", - x, y, w, h, skipleft)); + PDEBUG(ErrorF("Subsequent CPUToScreen ColorExpand(%d,%d, %d,%d, %d)\n", + x, y, w, h, skipleft)); -/* SiSSetupSRCPitch(((w+31)&0xFFE0)/8)*/ - SiSSetupSRCPitch((w+7)/8) - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) -/* SiSDoCMD*/ - pSiS->DoColorExpand = TRUE; + dstbase=0; + if (y>=2048) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + SiSSetupDSTBase(dstbase) + +/* SiSSetupSRCPitch(((w+31)&0xFFE0)/8)*/ + SiSSetupSRCPitch((w+7)/8) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) +/* SiSDoCMD*/ + pSiS->DoColorExpand = TRUE; } +#if 0 static void SiSSetupForScreenToScreenColorExpand(ScrnInfoPtr pScrn, - int fg, int bg, - int rop, unsigned int planemask) + int fg, int bg, + int rop, unsigned int planemask) { - SISPtr pSiS = SISPTR(pScrn); - - PDEBUG(ErrorF("Setup ScreenToScreen ColorExp(0x%x,0x%x, 0x%x)\n", - fg, bg, rop)); - - SiSSetupDSTBase(0) -/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ - SiSSetupDSTRect(pSiS->scrnOffset, -1) - SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); - SiSSetupSRCFG(fg) - SiSSetupSRCBG(bg) - SiSSetupSRCXY(0,0) - SiSSetupROP(sisALUConv[rop]) - SiSSetupCMDFlag(X_INC | Y_INC | ENCOLOREXP) + SISPtr pSiS = SISPTR(pScrn); + PDEBUG(ErrorF("Setup ScreenToScreen ColorExp(0x%x,0x%x, 0x%x)\n", + fg, bg, rop)); + + SiSSetupDSTBase(0) +/* SiSSetupDSTRect(pSiS->scrnOffset, pScrn->virtualY)*/ + SiSSetupDSTRect(pSiS->scrnOffset, -1) + SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor); + SiSSetupSRCFG(fg) + SiSSetupSRCBG(bg) + SiSSetupSRCXY(0,0) + SiSSetupROP(sisALUConv[rop]) + SiSSetupCMDFlag(X_INC | Y_INC | ENCOLOREXP) } static void SiSSubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int srcx, int srcy, int skipleft) + int x, int y, int w, int h, + int srcx, int srcy, int skipleft) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - PDEBUG(ErrorF("Sub ScreenToScreen ColorExp(%d,%d, %d,%d, %d,%d, %d)\n", - x, y, w, h, srcx, srcy, skipleft)); + PDEBUG(ErrorF("Sub ScreenToScreen ColorExp(%d,%d, %d,%d, %d,%d, %d)\n", + x, y, w, h, srcx, srcy, skipleft)); - SiSSetupSRCPitch(((w+31)&0xFFE0)/8) - SiSSetupDSTXY(x,y) - SiSSetupRect(w,h) - SiSDoCMD + SiSSetupSRCPitch(((w+31)&0xFFE0)/8) + SiSSetupDSTXY(x,y) + SiSSetupRect(w,h) + SiSDoCMD } +#endif +static void +SiSSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask) +{ + SISPtr pSiS=SISPTR(pScrn); + + while ((MMIO_IN16(pSiS->IOBase, 0x8242) & 0x1F00)!=0) {} + pSiS->ColorExpandRingHead = 0; + pSiS->ColorExpandRingTail = pSiS->ColorExpandBufferNumber - 1; + SiSSetupSRCXY(0,0); + SiSSetupROP(sisALUConv[rop]); + SiSSetupSRCFG(fg); + SiSSetupDSTRect(pSiS->scrnOffset, -1); + SiSSetupDSTColorDepth(pSiS->DstColor); + if (bg==-1) + { SiSSetupCMDFlag(TRANSPARENT|ENCOLOREXP|X_INC|Y_INC|SRCSYSTEM); + } + else + { SiSSetupSRCBG(bg); + SiSSetupCMDFlag(ENCOLOREXP|X_INC|Y_INC|SRCSYSTEM); + }; +} + +int srcpitch; +int xcurrent, ycurrent; +static void SiSSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) +{ + SISPtr pSiS=SISPTR(pScrn); + int _x0,_y0,_x1,_y1; + long dstbase; + + dstbase=0; + if (y>=2048) + { dstbase=pSiS->scrnOffset*y; + y=0; + } + SiSSetupDSTBase(dstbase) + + if (skipleft > 0) + { _x0=x+skipleft; + _y0=y; + _x1=x+w; + _y1=y+h; + SiSSetupClipLT(_x0,_y0); + SiSSetupClipRB(_x1,_y1); + SiSSetupCMDFlag(CLIPENABLE); + } + SiSSetupRect(w,1); + srcpitch = ((((w+7)/8)+3)>>2)*4; + SiSSetupSRCPitch(srcpitch); + ycurrent=y; + xcurrent=x; +} + +static void SiSSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + SISPtr pSiS=SISPTR(pScrn); + int newhead,bltbufstage,newtail; + + SiSSetupSRCBase(pSiS->ColorExpandBufferScreenOffset[bufno]); + SiSSetupDSTXY(xcurrent,ycurrent); + ycurrent++; + SiSDoCMD + newhead = pSiS->ColorExpandRingHead = (bufno + 1) & pSiS->ColorExpandBufferCountMask; + while (newhead == pSiS->ColorExpandRingTail) + { bltbufstage = (int)((MMIO_IN16(pSiS->IOBase,0x8242) & 0x1F00)>>8); + newtail = newhead - (bltbufstage + 1); + pSiS->ColorExpandRingTail = (newtail>=0)? newtail: (pSiS->ColorExpandBufferNumber+newtail); + } +} -#ifdef DEBUG static void MMIODump(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); - int i; + SISPtr pSiS = SISPTR(pScrn); + int i; - SiSIdle - for (i=0x8200; i<0x8250; i+=16) { - ErrorF("MMIO %x: %0X %0X %0X %0X\n", i, - MMIO_IN32(pSiS->IOBase, i ), - MMIO_IN32(pSiS->IOBase, i+ 4), - MMIO_IN32(pSiS->IOBase, i+ 8), - MMIO_IN32(pSiS->IOBase, i+12)); - } + SiSIdle + for (i=0x8200; i<=0x823c; i+=4) { + ErrorF("[%x] %0X \n", i, + MMIO_IN32(pSiS->IOBase,i)); + } + } -#endif Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h:1.1 Sat Feb 12 15:45:32 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h Fri Dec 1 20:16:17 2000 @@ -26,52 +26,52 @@ * David Thomas <davtom@dream.org.uk>. * Xavier Ducoin <x.ducoin@lectra.com> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.1 2000/02/12 20:45:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.h,v 1.2 2000/12/02 01:16:17 dawes Exp $ */ /* Definitions for the SIS engine communication. */ -#define PATREGSIZE 384 -#define BR(x) (0x8200 | (x) << 2) -#define PBR(x) (0x8300 | (x) << 2) +#define PATREGSIZE 384 +#define BR(x) (0x8200 | (x) << 2) +#define PBR(x) (0x8300 | (x) << 2) /* Definitions for the SiS300 engine command */ #define BITBLT 0x00000000 #define COLOREXP 0x00000001 -#define ENCOLOREXP 0x00000002 +#define ENCOLOREXP 0x00000002 #define MULTIPLE_SCANLINE 0x00000003 #define LINE 0x00000004 #define TRAPAZOID_FILL 0x00000005 #define TRANSPARENT_BITBLT 0x00000006 -#define SRCVIDEO 0x00000000 -#define SRCSYSTEM 0x00000010 +#define SRCVIDEO 0x00000000 +#define SRCSYSTEM 0x00000010 #define SRCAGP 0x00000020 -#define PATFG 0x00000000 -#define PATPATREG 0x00000040 -#define PATMONO 0x00000080 +#define PATFG 0x00000000 +#define PATPATREG 0x00000040 +#define PATMONO 0x00000080 #define X_INC 0x00010000 #define X_DEC 0x00000000 #define Y_INC 0x00020000 #define Y_DEC 0x00000000 -#define NOCLIP 0x00000000 -#define NOMERGECLIP 0x04000000 -#define CLIPENABLE 0x00040000 -#define CLIPWITHOUTMERGE 0x04040000 +#define NOCLIP 0x00000000 +#define NOMERGECLIP 0x04000000 +#define CLIPENABLE 0x00040000 +#define CLIPWITHOUTMERGE 0x04040000 #define OPAQUE 0x00000000 -#define TRANSPARENT 0x00100000 +#define TRANSPARENT 0x00100000 -#define DSTAGP 0x02000000 +#define DSTAGP 0x02000000 #define DSTVIDEO 0x02000000 /* Line */ -#define LINE_STYLE 0x00800000 -#define NO_RESET_COUNTER 0x00400000 -#define NO_LAST_PIXEL 0x00200000 +#define LINE_STYLE 0x00800000 +#define NO_RESET_COUNTER 0x00400000 +#define NO_LAST_PIXEL 0x00200000 /* Macros to do useful things with the SIS BitBLT engine */ @@ -81,80 +81,130 @@ bit 29 Command queue: 1 is empty */ +int CmdQueLen; + #define SiSIdle \ - while( (MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; + while( (MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \ + while( (MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \ + CmdQueLen=MMIO_IN16(pSiS->IOBase, 0x8240); + #define SiSSetupSRCBase(base) \ - MMIO_OUT32(pSiS->IOBase, BR(0), base); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(0), base);\ + CmdQueLen --; + #define SiSSetupSRCPitch(pitch) \ - MMIO_OUT16(pSiS->IOBase, BR(1), pitch); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT16(pSiS->IOBase, BR(1), pitch);\ + CmdQueLen --; #define SiSSetupSRCXY(x,y) \ - MMIO_OUT32(pSiS->IOBase, BR(2), (x)<<16 | (y) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(2), (x)<<16 | (y) );\ + CmdQueLen --; #define SiSSetupDSTBase(base) \ - MMIO_OUT32(pSiS->IOBase, BR(4), base); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(4), base);\ + CmdQueLen --; #define SiSSetupDSTXY(x,y) \ - MMIO_OUT32(pSiS->IOBase, BR(3), (x)<<16 | (y) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(3), (x)<<16 | (y) );\ + CmdQueLen --; #define SiSSetupDSTRect(x,y) \ - MMIO_OUT32(pSiS->IOBase, BR(5), (y)<<16 | (x) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(5), (y)<<16 | (x) );\ + CmdQueLen --; #define SiSSetupDSTColorDepth(bpp) \ - MMIO_OUT16(pSiS->IOBase, BR(1)+2, bpp); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT16(pSiS->IOBase, BR(1)+2, bpp);\ + CmdQueLen --; #define SiSSetupRect(w,h) \ - MMIO_OUT32(pSiS->IOBase, BR(6), (h)<<16 | (w) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(6), (h)<<16 | (w) );\ + CmdQueLen --; #define SiSSetupPATFG(color) \ - MMIO_OUT32(pSiS->IOBase, BR(7), color); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(7), color);\ + CmdQueLen --; #define SiSSetupPATBG(color) \ - MMIO_OUT32(pSiS->IOBase, BR(8), color); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(8), color);\ + CmdQueLen --; #define SiSSetupSRCFG(color) \ - MMIO_OUT32(pSiS->IOBase, BR(9), color); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(9), color);\ + CmdQueLen --; #define SiSSetupSRCBG(color) \ - MMIO_OUT32(pSiS->IOBase, BR(10), color); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(10), color);\ + CmdQueLen --; #define SiSSetupMONOPAT(p0,p1) \ - MMIO_OUT32(pSiS->IOBase, BR(11), p0); \ - MMIO_OUT32(pSiS->IOBase, BR(12), p1); + if (CmdQueLen <= 1) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(11), p0);\ + MMIO_OUT32(pSiS->IOBase, BR(12), p1);\ + CmdQueLen =CmdQueLen-2; #define SiSSetupClipLT(left,top) \ - MMIO_OUT32(pSiS->IOBase, BR(13), ((left) & 0xFFFF) | (top)<<16 ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(13), ((left) & 0xFFFF) | (top)<<16 );\ + CmdQueLen--; #define SiSSetupClipRB(right,bottom) \ - MMIO_OUT32(pSiS->IOBase, BR(14), ((right) & 0xFFFF) | (bottom)<<16 ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(14), ((right) & 0xFFFF) | (bottom)<<16 );\ + CmdQueLen --; #define SiSSetupROP(rop) \ - pSiS->CommandReg = (rop) << 8; + pSiS->CommandReg = (rop) << 8; #define SiSSetupCMDFlag(flags) \ - pSiS->CommandReg |= (flags); + pSiS->CommandReg |= (flags); #define SiSDoCMD \ - MMIO_OUT32(pSiS->IOBase, BR(15), pSiS->CommandReg); \ - MMIO_OUT32(pSiS->IOBase, BR(16), 0); + if (CmdQueLen <= 1) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(15), pSiS->CommandReg); \ + MMIO_OUT32(pSiS->IOBase, BR(16), 0);\ + CmdQueLen =CmdQueLen-2; #define SiSSetupX0Y0(x,y) \ - MMIO_OUT32(pSiS->IOBase, BR(2), (y)<<16 | (x) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(2), (y)<<16 | (x) );\ + CmdQueLen --; #define SiSSetupX1Y1(x,y) \ - MMIO_OUT32(pSiS->IOBase, BR(3), (y)<<16 | (x) ); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(3), (y)<<16 | (x) );\ + CmdQueLen --; #define SiSSetupLineCount(c) \ - MMIO_OUT16(pSiS->IOBase, BR(6), c); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT16(pSiS->IOBase, BR(6), c);\ + CmdQueLen --; #define SiSSetupStylePeriod(p) \ - MMIO_OUT16(pSiS->IOBase, BR(6)+2, p); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT16(pSiS->IOBase, BR(6)+2, p);\ + CmdQueLen --; #define SiSSetupStyleLow(ls) \ - MMIO_OUT32(pSiS->IOBase, BR(11), ls); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(11), ls);\ + CmdQueLen --; #define SiSSetupStyleHigh(ls) \ - MMIO_OUT32(pSiS->IOBase, BR(12), ls); + if (CmdQueLen <= 0) SiSIdle;\ + MMIO_OUT32(pSiS->IOBase, BR(12), ls);\ + CmdQueLen --; Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c:1.17 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c:1.17 Thu Jun 15 16:50:03 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c Fri Dec 1 20:16:17 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.17 2000/06/15 20:50:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.19 2000/12/02 01:16:17 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -138,14 +138,15 @@ #endif AvailFBArea.x1 = 0; - AvailFBArea.y1 = 0; + AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; if (pSiS->HWCursor || pSiS->TurboQueue) offset = 262144; else offset = 0; AvailFBArea.y2 = (pSiS->FbMapSize - offset) / (pScrn->displayWidth * pScrn->bitsPerPixel / 8); - if (AvailFBArea.y2 > 2047) AvailFBArea.y2 = 2047; + if (AvailFBArea.y2 < 0) AvailFBArea.y2 = 32767; + xf86InitFBManager(pScreen, &AvailFBArea); return(XAAInit(pScreen, infoPtr)); @@ -260,8 +261,8 @@ int isTransparent = ( bg == -1 ); dstpitch = pScrn->displayWidth * pScrn->bitsPerPixel / 8 ; - sisSETBGCOLOR(bg); sisSETFGCOLOR(fg); + sisSETBGCOLOR(bg); sisSETROPFG(rop); if (!isTransparent) { sisSETROPBG(0xcc); /* copy */ Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c:1.5 Thu Apr 6 23:57:52 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c Mon Dec 18 14:31:08 2000 @@ -1,1434 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c,v 1.5 2000/04/07 03:57:52 tsi Exp $ */ - -#include "xf86.h" -#include "xf86PciInfo.h" - -#include "sis.h" -#include "sis_regs.h" -#include "sis_bios.h" - - -static unsigned short ModeIDOffset, FRateOffset, - CRTC1Offset, VCLKOffset; -static unsigned char * CRTC2Ptr; -static unsigned short VBInfo, SetFlag, ModeType; -static unsigned char LCDResInfo, LCDTypeInfo, LCDInfo; -static unsigned short RVBHRS; -static unsigned short HDE, VGAHDE, VDE, VGAVDE; -static unsigned short HT, VGAHT, VT, VGAVT; -static unsigned char NewFlickerMode, RY1COE, RY2COE, RY3COE, RY4COE; -static unsigned short RVBHCMAX; -static unsigned char RVBHCFACT; - - - - - - - - - - -static unsigned short StResInfo[][2] = {{640,400},{640,350},{720,400}, - {720,350},{640,480}}; -static unsigned short ModeResInfo[][4] = { - { 320, 200,8, 8},{ 320, 240,8, 8},{ 320, 400,8, 8}, - { 400, 300,8, 8},{ 512, 384,8, 8},{ 640, 400,8,16}, - { 640, 480,8,16},{ 800, 600,8,16},{1024, 768,8,16}, - {1280,1024,8,16},{1600,1200,8,16},{1920,1440,8,16}, - { 720, 480,8,16},{ 720, 576,8,16},{2048,1536,8,16}}; - -static unsigned char StLCD1Data[][8] = { - LCDDATA(66, 31, 992, 510, 1320, 816), - LCDDATA(66, 31, 992, 510, 1320, 816), - LCDDATA(176, 75, 900, 510, 1320, 816), - LCDDATA(176, 75, 900, 510, 1320, 816), - LCDDATA(66, 31, 992, 510, 1320, 816), - LCDDATA(27, 16, 1024, 650, 1350, 832), - LCDDATA(1, 1, 1344, 806, 1344, 806)}; -static unsigned char ExtLCD1Data[][8] = { - LCDDATA(12,5,896,512,1344,806), - LCDDATA(12,5,896,510,1344,806), - LCDDATA(32,15,1008,505,1344,806), - LCDDATA(32,15,1008,514,1344,806), - LCDDATA(12,5,896,500,1344,806), - LCDDATA(42,25,1024,625,1344,806), - LCDDATA(1,1,1344,806,1344,806), - LCDDATA(12,5,896,500,1344,806), - LCDDATA(42,25,1024,625,1344,806), - LCDDATA(1,1,1344,806,1344,806), - LCDDATA(12,5,896,500,1344,806), - LCDDATA(42,25,1024,625,1344,806), - LCDDATA(1,1,1344,806,1344,806)}; - -static unsigned char StLCD2Data[][8] = { - LCDDATA(4,1,880,510,1650,1088), - LCDDATA(4,1,880,510,1650,1088), - LCDDATA(176,45,900,510,1650,1088), - LCDDATA(176,45,900,510,1650,1088), - LCDDATA(4,1,880,510,1650,1088), - LCDDATA(13,5,1024,675,1560,1152), - LCDDATA(16,9,1266,804,1688,1072), - LCDDATA(1,1,1688,1066,1688,1066)}; -static unsigned char ExtLCD2Data[][8] = { - LCDDATA(211,60,1024,501,1688,1066), - LCDDATA(211,60,1024,508,1688,1066), - LCDDATA(211,60,1024,501,1688,1066), - LCDDATA(211,60,1024,508,1688,1066), - LCDDATA(211,60,1024,500,1688,1066), - LCDDATA(211,75,1024,625,1688,1066), - LCDDATA(211,120,1280,798,1688,1066), - LCDDATA(1,1,1688,1066,1688,1066)}; - -static unsigned char StPALData[][16] = { - TVDATA(1,1,864,525,1270,400,100,0,760,0xF4,0xFF,0x1C,0x22), - TVDATA(1,1,864,525,1270,350,100,0,760,0xF4,0xFF,0x1C,0x22), - TVDATA(1,1,864,525,1270,400,0,0,720,0xF4,0x0B,0x1C,0x0A), - TVDATA(1,1,864,525,1270,350,0,0,720,0xF4,0x0B,0x1C,0x0A), - TVDATA(1,1,864,525,1270,480,50,0,760,0xF4,0xFF,0x1C,0x22), - TVDATA(1,1,864,525,1270,600,50,0,0,0xF4,0xFF,0x1C,0x22)}; -static unsigned char ExtPALData[][16] = { - TVDATA(27,10,848,448,1270,530,50,0,50,0xF4,0xFF,0x1C,0x22), - TVDATA(108,35,848,398,1270,530,50,0,50,0xF4,0xFF,0x1C,0x22), - TVDATA(12,5,954,448,1270,530,50,0,50,0xF4,0x0B,0x1C,0x0A), - TVDATA(9,4,960,463,1644,438,50,0,50,0xF4,0x0B,0x1C,0x0A), - TVDATA(9,4,848,528,1270,530,0,0,50,0xF5,0xFB,0x1B,0x2A), - TVDATA(36,25,1060,648,1316,530,438,0,438,0xEB,0x05,0x25,0x16), - TVDATA(3,2,1080,619,1270,540,438,0,438,0xF3,0x02,0x1D,0x1C)}; - -static unsigned char StNTSCData[][16] = { - TVDATA(1,1,858,525,1270,400,50,0,760,0xF1,0x04,0x1F,0x18), - TVDATA(1,1,858,525,1270,350,50,0,640,0xF1,0x04,0x1F,0x18), - TVDATA(1,1,858,525,1270,400,0,0,720,0xF4,0x0B,0x1C,0x0A), - TVDATA(1,1,858,525,1270,350,0,0,720,0xF4,0x0B,0x1C,0x0A), - TVDATA(1,1,858,525,1270,480,0,0,760,0xF1,0x04,0x1F,0x18)}; -static unsigned char ExtNTSCData[][16] = { - TVDATA(143,65,858,443,1270,440,171,0,171,0xF1,0x04,0x1F,0x18), - TVDATA(88,35,858,393,1270,440,171,0,171,0xF1,0x04,0x1F,0x18), - TVDATA(143,70,924,443,1270,440,92,0,92,0xF4,0x0B,0x1C,0x0A), - TVDATA(143,70,924,393,1270,440,92,0,92,0xF4,0x0B,0x1C,0x0A), - TVDATA(143,76,836,523,1270,440,224,0,0,0xF1,0x05,0x1F,0x16), - TVDATA(143,120,1056,643,1288,440,0,1,0,0xF4,0x10,0x1C,0x00), - TVDATA(143,76,836,523,1270,440,0,1,0,0xE7,0x0E,0x29,0x04)}; - -static unsigned char StHiTVData[][12] = { - HITVDATA(1,1,892,563,720,800,0,0,0), - HITVDATA(1,1,892,563,720,700,0,0,0), - HITVDATA(1,1,892,563,721,800,0,0,0), - HITVDATA(1,1,892,563,720,700,0,0,0), - HITVDATA(1,1,892,563,720,960,0,0,0), - HITVDATA(10,3,1008,625,1632,960,0x143,1,0), - HITVDATA(25,12,1260,851,1632,960,0x032,0,0), - HITVDATA(5,4,1575,1124,1632,960,0x128,0,0)}; -static unsigned char ExtHiTVData[][12] = { - HITVDATA(3,1,840,563,1632,960,0,0,0), - HITVDATA(3,1,960,563,1632,960,0,0,0), - HITVDATA(3,1,840,483,1632,960,0,0,0), - HITVDATA(3,1,960,563,1632,960,0,0,0), - HITVDATA(3,1,1400,563,1632,960,0x166,1,0), - HITVDATA(10,3,1008,625,1632,960,0x143,1,0), - HITVDATA(25,12,1260,851,1632,960,0x032,0,0), - HITVDATA(5,4,1575,1124,1632,960,0x128,0,0)}; - -/* for group2 */ -static unsigned char HiTVTiming1[] = { - 0x20,0x53,0x2C,0x5F,0x08,0x31,0x3A,0x64, - 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, - 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, - 0x64,0x90,0x33,0x8C,0x18,0x36,0x1B,0x13, - 0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40, - 0x8E,0x8E,0x8F,0x07,0x0B}; -static unsigned char HiTVTiming2[] = { - 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, - 0x60,0x14,0x1A,0xB0,0x4F}; -static unsigned short HiTVTiming3[] = {0x0027,0xFFFC,0x006A}; - -static unsigned char HiTVTimingSimu1[] = { - 0x20,0x53,0x2C,0x5F,0x08,0x31,0x3A,0x65, - 0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D, - 0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F, - 0x65,0x90,0x7B,0xA8,0x03,0xF0,0x78,0x03, - 0x11,0x15,0x11,0xCF,0x10,0x11,0xCF,0x10, - 0x35,0x35,0x3C,0x69,0x1D}; -static unsigned char HiTVTimingSimu2[] = { - 0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C, - 0x60,0x04,0x77,0x72,0x5C}; -static unsigned short HiTVTimingSimu3[] = {0x000E,0xFFFC,0x002D}; - -static unsigned char NTSCTiming1[] = { - 0x17,0x1D,0x03,0x09,0x05,0x06,0x0C,0x0C, - 0x94,0x49,0x01,0x0A,0x06,0x0D,0x04,0x0A, - 0x06,0x14,0x0D,0x04,0x0A,0x00,0x85,0x1B, - 0x0C,0x50,0x00,0x99,0x00,0xEC,0x4A,0x17, - 0x88,0x00,0x4B,0x00,0x00,0xE2,0x00,0x02, - 0x03,0x0A,0x65,0x9D,0x08}; -static unsigned char NTSCTiming2[] = { - 0x92,0x8F,0x40,0x60,0x80,0x14,0x90,0x8C, - 0x60,0x14,0x50,0x00,0x40}; -static unsigned short NTSCTiming3[] = {0x0044,0x02DB,0x003B}; - -static unsigned char PALTiming1[] = { - 0x19,0x52,0x35,0x6E,0x04,0x38,0x3D,0x70, - 0x94,0x49,0x01,0x12,0x06,0x3E,0x35,0x6D, - 0x06,0x14,0x3E,0x35,0x6D,0x00,0x45,0x2B, - 0x70,0x50,0x00,0x97,0x00,0xD7,0x5D,0x17, - 0x88,0x00,0x45,0x00,0x00,0xE8,0x00,0x02, - 0x0D,0x00,0x68,0xB0,0x0B}; -static unsigned char PALTiming2[] = { - 0x92,0x8F,0x40,0x60,0x80,0x14,0x90,0x8C, - 0x60,0x14,0x63,0x00,0x40}; -static unsigned short PALTiming3[] = {0x003E,0x02E1,0x0028}; - -/* for group3 */ -static unsigned char HiTVGroup3Data[] = { - 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x5F, - 0x05,0x21,0xB2,0xB2,0x55,0x77,0x2A,0xA6, - 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, - 0x8C,0x6E,0x60,0x2E,0x58,0x48,0x72,0x44, - 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80, - 0x4F,0x7F,0x03,0xA8,0x7D,0x20,0x1A,0xA9, - 0x14,0x05,0x03,0x7E,0x64,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; -static unsigned char HiTVGroup3Simu[] = { - 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x95, - 0xDB,0x20,0xB8,0xB8,0x55,0x47,0x2A,0xA6, - 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, - 0x8C,0x6E,0x60,0x15,0x26,0xD3,0xE4,0x11, - 0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80, - 0x67,0x36,0x01,0x47,0x0E,0x10,0xBE,0xB4, - 0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75, - 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; -static unsigned char NTSCGroup3Data[] = { - 0x00,0x14,0x15,0x25,0x55,0x15,0x0B,0x89, - 0xD7,0x40,0xB0,0xB0,0xFF,0xC4,0x45,0xA6, - 0x25,0x2F,0x67,0xF6,0xBF,0xFF,0x8E,0x20, - 0x8C,0xDA,0x60,0x92,0xC8,0x55,0x8B,0x00, - 0x51,0x04,0x18,0x0A,0xF8,0x87,0x00,0x80, - 0x3B,0x3B,0x00,0xF0,0xF0,0x00,0xF0,0xF0, - 0x00,0x51,0x0F,0x0F,0x08,0x0F,0x08,0x6F, - 0x18,0x05,0x05,0x05,0x4C,0xAA,0x01}; -static unsigned char PALGroup3Data[] = { - 0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x85, - 0xC3,0x20,0xA4,0xA4,0x55,0x47,0x2A,0xA6, - 0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20, - 0x8C,0xDC,0x60,0x92,0xC8,0x4F,0x85,0x00, - 0x56,0x36,0x4F,0x6E,0xFE,0x83,0x54,0x81, - 0x30,0x30,0x00,0xF3,0xF3,0x00,0xA2,0xA2, - 0x00,0x48,0xFE,0x7E,0x08,0x40,0x08,0x91, - 0x18,0x05,0x18,0x05,0x4C,0xA8,0x01}; - - - - -Bool -SiSSetMode(ScrnInfoPtr pScrn, unsigned short ModeNo) -{ - unsigned long temp; - unsigned char * ROMAddr = SISPTR(pScrn)->BIOS; - unsigned short BaseAddr = SISPTR(pScrn)->RelIO; - - temp=SearchModeID(ROMAddr,ModeNo); /* 2.Get ModeID Table */ - if(temp==0) return(0); - - GetVBInfo(BaseAddr,ROMAddr); /* add for CRT2 */ - ErrorF("VBInfo=0x%0X\nSetFlag=0x%0X\nModeType=0x%0X\n", - VBInfo, SetFlag, ModeType); - GetLCDResInfo(BaseAddr+CROFFSET); /* add for CRT2 */ - - if (VBInfo & (SET_SIMU_SCAN_MODE | SWITCH_TO_CRT2)) - SetFlag |= PROGRAMMING_CRT2; - - /* Skip Set CRT1 Regs */ - - if ((VBInfo & SET_SIMU_SCAN_MODE) || (VBInfo & SWITCH_TO_CRT2)) - SetCRT2Group(pScrn,ModeNo); /* add for CRT2 */ - - return TRUE; -} - -Bool -SearchModeID(unsigned char *ROMAddr, unsigned short ModeNo) -{ - unsigned char ModeID; - unsigned short ModeIDLen; - - if (ModeNo <= 0x13) { - ModeIDOffset=*(unsigned short *)(ROMAddr+0x200); - ModeIDLen = STMODE_SIZE; - } else { - ModeIDOffset=*(unsigned short *)(ROMAddr+0x20A); - ModeIDLen = EMODE_SIZE; - } - - ModeID=*(ROMAddr+ModeIDOffset); - while (ModeID!=0xff && ModeID!=ModeNo) { - ModeIDOffset += ModeIDLen; - ModeID=*(ROMAddr+ModeIDOffset); - } - if(ModeID==0xff) - return(FALSE); - else - return(TRUE); -} - -void -GetVBInfo(unsigned short BaseAddr, unsigned char *ROMAddr) -{ - unsigned short flag; - unsigned short tempbx; - unsigned short tempbl,tempbh; - unsigned short p3c4 = BaseAddr + SROFFSET; - unsigned short p3d4 = BaseAddr + CROFFSET; - - SetFlag=0; - tempbx = *(CARD16 *)(ROMAddr+ModeIDOffset+1); /* si+St_ModeFlag */ - ModeType = tempbx & MODE_INFO_FLAG; - - inSISIDXREG(p3c4,0x38,flag); /* call BridgeisOn */ - if(!(flag & 0x20)){ - VBInfo = 0; - return; - } - inSISIDXREG(p3d4,0x30,tempbl); - inSISIDXREG(p3d4,0x31,tempbh); - tempbx = tempbh << 8 | tempbl; - tempbx &= (~(SET_IN_SLAVE_MODE | DISABLE_CRT2_DISPLAY) ); - if(!(tempbx & 0x07C)) { - VBInfo=SET_SIMU_SCAN_MODE | DISABLE_CRT2_DISPLAY; - return; - } - if (tempbx & SET_CRT2_TO_RAMDAC) { - tempbx &= (0xFF00 | SET_CRT2_TO_RAMDAC | SWITCH_TO_CRT2 | - SET_SIMU_SCAN_MODE); - } else if (tempbx & SET_CRT2_TO_LCD) { - tempbx &= (0xFF00 | SET_CRT2_TO_LCD | SWITCH_TO_CRT2 | - SET_SIMU_SCAN_MODE); - } else if (tempbl & SET_CRT2_TO_SCART) { - tempbx &=(0xFF00 | SET_CRT2_TO_SCART |SWITCH_TO_CRT2 | - SET_SIMU_SCAN_MODE); - } else if (tempbl & SET_CRT2_TO_HIVISION_TV) { - tempbx &= (0xFF00 | SET_CRT2_TO_HIVISION_TV | SWITCH_TO_CRT2 | - SET_SIMU_SCAN_MODE); - } - if ((tempbl & (DISABLE_CRT2_DISPLAY >> 8)) && - (tempbl & (SWITCH_TO_CRT2 | SET_SIMU_SCAN_MODE))==0) - tempbx = SET_SIMU_SCAN_MODE | DISABLE_CRT2_DISPLAY; - - if(!(tempbx & DRIVER_MODE)) - tempbx |= SET_SIMU_SCAN_MODE; - - if (!(tempbx & SET_SIMU_SCAN_MODE)) { - if (tempbx & SWITCH_TO_CRT2) { - flag = *(CARD16 *)(ROMAddr+ModeIDOffset+1); - if (!(flag & CRT2_MODE)) - tempbx |= SET_SIMU_SCAN_MODE; - } else { - if (BridgeIsEnable(BaseAddr) && BridgeInSlave(BaseAddr)) - tempbx |= SET_SIMU_SCAN_MODE; - } - } - /* GetVBInfoCnt */ - if (tempbx & DISABLE_CRT2_DISPLAY) { - VBInfo = tempbx; - return; - } - if (tempbx & DRIVER_MODE) { - if (!(tempbx & SET_SIMU_SCAN_MODE)) { - VBInfo = tempbx; - return; - } - flag = *(CARD16 *)(ROMAddr+ModeIDOffset+1); - if (flag & CRT2_MODE) { - VBInfo = tempbx; - return; - } - } - tempbx |= SET_IN_SLAVE_MODE; - if ((tempbx & SET_CRT2_TO_TV) && (!(tempbx & SET_NO_SIMU_TV_ON_LOCK))) - SetFlag |= TV_SIMU_MODE; - - VBInfo = tempbx; - return; -} - -Bool -BridgeIsEnable(CARD16 BaseAddr) -{ - unsigned char temp; - - if (!BridgeIsOn(BaseAddr)) - return FALSE; - inSISIDXREG(BaseAddr+P1_INDEX, 0, temp); - if (temp & 0xA0) - return TRUE; - else - return FALSE; -} - -Bool -BridgeIsOn(CARD16 BaseAddr) -{ - unsigned char temp; - - inSISIDXREG(BaseAddr+SROFFSET, 0x38, temp); - if (temp & 0x20) - return TRUE; - else - return FALSE; -} - -Bool -BridgeInSlave(CARD16 BaseAddr) -{ - unsigned char temp; - - inSISIDXREG(BaseAddr+CROFFSET, 0x31, temp); - if (temp & SET_IN_SLAVE_MODE) - return TRUE; - else - return FALSE; -} - -void -GetLCDResInfo(unsigned short p3d4) -{ - unsigned short tempah,tempbh; - - inSISIDXREG(p3d4, 0x36, tempbh); - tempah = tempbh & 0x0F; - - if (tempah > PANEL_1280x1024) - tempah = 0; - LCDResInfo = tempah; - LCDTypeInfo = tempbh >> 4; - inSISIDXREG(p3d4, 0x37, LCDInfo); - if(!(VBInfo & SET_CRT2_TO_LCD)) - return; - if (!(VBInfo & (SET_SIMU_SCAN_MODE | SWITCH_TO_CRT2))) - return; - if (VBInfo & SET_IN_SLAVE_MODE) { - if (VBInfo & SET_NO_SIMU_ON_LOCK) - SetFlag |= LCDVESA_TIMING; - } else - SetFlag |= LCDVESA_TIMING; -} - -void -SetCRT2Group(ScrnInfoPtr pScrn, CARD16 ModeNo) -{ - unsigned short temp; - SISPtr pSiS = SISPTR(pScrn); - unsigned short BaseAddr = pSiS->RelIO; - unsigned char * ROMAddr = pSiS->BIOS; - - - SetFlag |= PROGRAMMING_CRT2; - - GetRatePtr(pScrn, ModeNo, SELECT_CRT2); - SaveCRT2Info(pSiS->RelIO+CROFFSET, ModeNo); - DisableBridge(BaseAddr); - UnLockCRT2(BaseAddr); - SetCRT2ModeRegs(BaseAddr,ModeNo); - if(VBInfo & DISABLE_CRT2_DISPLAY) { - LockCRT2(BaseAddr); - return; - } - GetCRT2Data(ROMAddr,ModeNo); -#if 0 - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - ModifyDotClock(); -#endif - - SetGroup1(pScrn,ModeNo); - SetGroup2(BaseAddr,ROMAddr); - SetGroup3(BaseAddr); - SetGroup4(BaseAddr,ROMAddr,ModeNo); - - LockCRT2(BaseAddr); - if (SetFlag & TV_SIMU_MODE) { - temp = *(CARD16 *)(ROMAddr+ModeIDOffset+1); - if (!(temp & AFTER_LOCK_CRT2)) - SetLockRegs(BaseAddr, 0x04); - } - if (!(VBInfo & SET_IN_SLAVE_MODE)) - EnableCRT2(BaseAddr); - EnableBridge(BaseAddr); - if (!GetLockInfo(pSiS->RelIO+CROFFSET, 0x04)) - SetLockRegs(BaseAddr, 0x08); - - return; -} - - - -unsigned short -GetRatePtr(ScrnInfoPtr pScrn, unsigned short ModeNo, CARD8 CRTx) -{ - short index; - unsigned char LCDFRateIndexMax[2] = { 1, 3}; - unsigned short temp; - unsigned short p3d4 = SISPTR(pScrn)->RelIO+CROFFSET; - unsigned char * ROMAddr = SISPTR(pScrn)->BIOS; - - if (ModeNo <= 0x13) /* Mode No <= 13h then return */ - return (STANDARD_MODE | CRT2_SUPPORT); - - inSISIDXREG(p3d4,0x33,index); /* Get 3d4 CRTC33 */ - if (CRTx == SELECT_CRT1) - index &= 0x0F; /* Frame rate index */ - else - index = (index & 0xF0) >> 4; - - if(index != 0) index--; - - if (SetFlag & PROGRAMMING_CRT2) { - if (VBInfo & SET_CRT2_TO_LCD) { - if (index > LCDFRateIndexMax[LCDResInfo]) - index = LCDFRateIndexMax[LCDResInfo]; - } - } - FRateOffset = *(CARD16 *)(ROMAddr+ModeIDOffset+4); - do { - temp=*(CARD16 *)(ROMAddr+FRateOffset); - if (temp==0xFFFF) - break; - if ((temp & MODE_INFO_MASK) < ModeType) - break; - FRateOffset += EMODE2_SIZE; - index--; - if (index < 0) { - if (!(VBInfo & SET_CRT2_TO_RAMDAC) && - (VBInfo & SET_IN_SLAVE_MODE)) { - index = 0; - if (!(temp & INTERLACE_MODE)) - break; - } - } - } while(index>=0); - - FRateOffset -= EMODE2_SIZE; - if (SetFlag & PROGRAMMING_CRT2) - return AdjustCRT2Rate(ROMAddr) | ENHANCED_MODE; - return (ENHANCED_MODE+CRT2_NO_SUPPORT); -} - -unsigned short -AdjustCRT2Rate(CARD8 *ROMAddr) -{ - unsigned short tempax; - unsigned short temp; - - tempax = 0; - if (VBInfo & SET_CRT2_TO_RAMDAC) - tempax |= SUPPORT_RAMDAC2; - if (VBInfo & SET_CRT2_TO_LCD) { - tempax |= SUPPORT_LCD; - temp = *(ROMAddr+ModeIDOffset+9); - if ((LCDResInfo != PANEL_1280x1024) && (temp >= 9)) - tempax = 0; - } - if (VBInfo & (SET_CRT2_TO_AVIDEO|SET_CRT2_TO_SVIDEO|SET_CRT2_TO_SCART)) - tempax |= SUPPORT_TV; - temp = *(CARD16 *)(ROMAddr+ModeIDOffset+1); - if (!(VBInfo & SET_PAL_TV) && (temp & NO_SUPPORT_SIMU_TV) && - (VBInfo & SET_IN_SLAVE_MODE) && !(VBInfo & SET_NO_SIMU_ON_LOCK)) { - return CRT2_NO_SUPPORT; - } - do { - temp = *(CARD16 *)(ROMAddr+FRateOffset); - if (temp & tempax) - return CRT2_SUPPORT; - temp = *(CARD16 *)(ROMAddr+ModeIDOffset+4); - if (FRateOffset == temp) - break; - FRateOffset -= EMODE2_SIZE; - } while (1); - FRateOffset = *(CARD16 *)(ROMAddr+ModeIDOffset+4); - do { - FRateOffset += EMODE2_SIZE; - temp = *(CARD16 *)(ROMAddr+FRateOffset); - if (temp == 0xFFFF) - return CRT2_NO_SUPPORT; - if (temp & tempax) - return CRT2_SUPPORT; - } while (1); -} - -void -SaveCRT2Info(CARD16 p3d4, CARD16 ModeNo) -{ - outSISIDXREG(p3d4, 0x34, ModeNo); - setSISIDXREG(p3d4, 0x31, ~SET_IN_SLAVE_MODE, - (VBInfo & SET_IN_SLAVE_MODE) >> 8); - andSISIDXREG(p3d4, 0x35, 0xF3); -} - -void -DisableBridge(CARD16 BaseAddr) -{ - unsigned short part2_base = BaseAddr+0x10; - - andSISIDXREG(part2_base, 0, 0xDF); - LongWait(BaseAddr+0x5A); - orSISIDXREG(BaseAddr+SROFFSET, 1, 0x20); /* DisplayOff */ - andSISIDXREG(BaseAddr+SROFFSET, 0x32, 0xDF); - andSISIDXREG(BaseAddr+SROFFSET, 0x1E, 0xDF); -} - -void -LongWait(CARD16 p3da) -{ - unsigned short i; - - for (i=0; i<0xFFFF; i++) { - if (!(inSISREG(p3da) & 0x08)) break; - } - for (i=0; i<0xFFFF; i++) { - if (inSISREG(p3da) & 0x09 == 9) break; - } -} - -Bool -WaitVBRetrace(CARD16 BaseAddr) -{ - unsigned short part1_base = BaseAddr+4; - unsigned short i; - unsigned char temp; - - inSISIDXREG(part1_base, 0, temp); - if (!(temp & 0x80)) - return FALSE; - - outSISREG(part1_base, 0x25); - part1_base++; - for (i=0; i<0xFFFF; i++) { - temp = inSISREG(part1_base); - if (temp & 0x01) break; - } - for (i=0; i<0xFFFF; i++) { - temp = inSISREG(part1_base); - if (!(temp & 0x01)) break; - } - return TRUE; -} - -void -VBLongWait(CARD16 p3da) -{ - unsigned int i, j; - - for (i=0; i<3; i++) { - if (i & 1) { /* VBWaitMode 2 */ - for (j=0; j<0x640000; j++) { - if (!(inSISREG(p3da) & 0x08)) break; - } - } else { /* VBWaitMode 1 */ - for (j=0; j<0x640000; j++) { - if ((inSISREG(p3da) & 0x08)) break; - } - } - } -} - -void -UnLockCRT2(CARD16 BaseAddr) -{ - orSISIDXREG(BaseAddr+4, 0x24, 1); -} - -void -LockCRT2(CARD16 BaseAddr) -{ - andSISIDXREG(BaseAddr+4, 0x24, 0xFE); -} - -void -EnableCRT2(CARD16 BaseAddr) -{ - orSISIDXREG(BaseAddr+SROFFSET, 0x1E, 0x20); -} - -void -EnableBridge(CARD16 BaseAddr) -{ - unsigned short part2_base = BaseAddr+0x10; - unsigned char temp, temp1; - - temp1 = 0; - inSISIDXREG(BaseAddr+CROFFSET, 0x31, temp); - if (temp & (SET_IN_SLAVE_MODE >> 8)) { - inSISIDXREG(BaseAddr+CROFFSET, 0x30, temp); - if (!(temp & (SET_CRT2_TO_RAMDAC >> 8))) { - temp1 = 0x20; - } - } - LongWait(BaseAddr+0x5A); - setSISIDXREG(BaseAddr+SROFFSET, 0x32, ~0x20, temp1); - - LongWait(BaseAddr+0x5A); - orSISIDXREG(BaseAddr+SROFFSET, 0x1E, 0x20); - - LongWait(BaseAddr+0x5A); - setSISIDXREG(part2_base, 0, ~0xE0, 0x20); - - LongWait(BaseAddr+0x5A); - andSISIDXREG(BaseAddr+SROFFSET, 1, ~0x20); /* DisplayOn */ - - LongWait(BaseAddr+0x5A); - andSISIDXREG(part2_base, 0, ~0xE0); - LongWait(BaseAddr+0x5A); - setSISIDXREG(part2_base, 0, ~0xE0, 0x20); - -/* - LongWait(BaseAddr+0x5A); - LongWait(BaseAddr+0x5A); - VBLongWait(BaseAddr); -*/ -} - -void -SetCRT2ModeRegs(CARD16 BaseAddr, CARD16 ModeNo) -{ - CARD16 part1_base = BaseAddr+4; - CARD16 part4_base = BaseAddr+0x14; - CARD8 tempah; - - outSISIDXREG(part1_base, 4, 0); - outSISIDXREG(part1_base, 5, 0); - outSISIDXREG(part1_base, 6, 0); - - /* set index 0 register */ - tempah = 0x80; - if (ModeNo > 0x13) - if (ModeType >= MODE_VGA) - tempah = (0x10 >> (ModeType-MODE_VGA)) | 0x80; - if (VBInfo & SET_IN_SLAVE_MODE) - tempah ^= 0xA0; - if (VBInfo & DISABLE_CRT2_DISPLAY) - tempah = 0; - outSISIDXREG(part1_base, 0, tempah); - - /* set index 1 register */ - tempah = 0x01; - if (!(VBInfo & SET_IN_SLAVE_MODE)) - tempah |= 0x02; - if (!(VBInfo & SET_CRT2_TO_RAMDAC)) { - tempah ^= 0x05; - if (!(VBInfo & SET_CRT2_TO_LCD)) - tempah ^= 0x01; - } - tempah <<= 5; - if (VBInfo & DISABLE_CRT2_DISPLAY) - tempah = 0; - outSISIDXREG(part1_base, 1, tempah); - - tempah >>= 5; - if ((ModeType == MODE_VGA) && (!(VBInfo & SET_IN_SLAVE_MODE))) - tempah |= 0x10; - if (LCDResInfo != PANEL_1024x768) - tempah |= 0x80; - if ((VBInfo & SET_CRT2_TO_TV) && (VBInfo & SET_IN_SLAVE_MODE)) - tempah |= 0x20; - setSISIDXREG(part4_base, 0x0D, ~(0xBF), tempah); - - tempah = 0; - if (VBInfo & SET_CRT2_TO_TV) { - if (!(VBInfo & SET_IN_SLAVE_MODE) || - !(SetFlag & TV_SIMU_MODE)) { - SetFlag |= RPLLDIV2XO; - tempah |= 0x40; - } - } - if (LCDResInfo != PANEL_1024x768) - tempah |= 0x80; - outSISIDXREG(part4_base, 0x0C, tempah); -} - -void -GetCRT2Data(CARD8 *ROMAddr, CARD16 ModeNo) -{ - unsigned short tempax, tempbx; - - RVBHRS = 50; - NewFlickerMode = 0; - RY1COE = RY2COE = RY3COE = RY4COE = 0; - - GetResInfo(ROMAddr, ModeNo); - if (VBInfo & SET_CRT2_TO_RAMDAC) { - GetRAMDAC2Data(ROMAddr, ModeNo); - return; - } - GetCRT2Ptr(ROMAddr, ModeNo); - RVBHCMAX = *CRTC2Ptr | GETBITSTR(*(CRTC2Ptr+4), 7:7, 8:8); - RVBHCFACT = *(CRTC2Ptr+1); - VGAHT = *((CARD16 *)(CRTC2Ptr+2)) & 0xFFF; - VGAVT = (*((CARD16 *)(CRTC2Ptr+3)) >> 4) & 0x7FF; - if (VBInfo & SET_CRT2_TO_LCD) { - HT = *((CARD16 *)(CRTC2Ptr+5)) & 0xFFF; - VT = (*((CARD16 *)(CRTC2Ptr+6)) >> 4) & 0x7FF; - tempax = 1024; - tempbx = 560; - if (VGAVDE != 350) - tempbx = 640; - if (VGAVDE != 400) - tempbx = 768; - if (LCDResInfo == PANEL_1280x1024) { - tempax = 1280; - tempbx = 768; - if (VGAVDE != 360) - tempbx = 800; - if (VGAVDE != 375) - tempbx = 864; - if (VGAVDE != 405) - tempbx = 1024; - } - HDE = tempax; - VDE = tempbx; - } else { /* CRT2ToTV */ - HDE = *(CARD16 *)(CRTC2Ptr+5) & 0xFFF; - VDE =(*(CARD16 *)(CRTC2Ptr+6) >> 4) & 0x7FF; - if (*(CARD16 *)(ROMAddr+ModeIDOffset+1) & HALF_DCLK) - RVBHRS = *(CARD16 *)(CRTC2Ptr+10); - else - RVBHRS = *(CARD16 *)(CRTC2Ptr+8) & 0xFFF; - NewFlickerMode = *(CRTC2Ptr+9) & 0x80; - if (VBInfo & SET_CRT2_TO_HIVISION_TV) { - if (VGAVDE > 480) - SetFlag &= (~TV_SIMU_MODE); - if (SetFlag & TV_SIMU_MODE) { - HT = ST_HIVISION_TV_HT; - VT = ST_HIVISION_TV_VT; - } else { - HT = EXT_HIVISION_TV_HT; - VT = EXT_HIVISION_TV_VT; - } - } else { - RY1COE = *(CRTC2Ptr+12); - RY2COE = *(CRTC2Ptr+13); - RY3COE = *(CRTC2Ptr+14); - RY4COE = *(CRTC2Ptr+15); - if (VBInfo & SET_PAL_TV) { - HT = PAL_HT; - VT = PAL_VT; - } else { - HT = NTSC_HT; - VT = NTSC_VT; - } - } - } /* end of LCD/TV */ -} - -void -GetResInfo(CARD8 *ROMAddr, CARD16 ModeNo) -{ - unsigned char tempal; - unsigned short resX, resY; - unsigned short mode_flag; - - if (ModeNo <= 0x13) { - tempal = *(ROMAddr+ModeIDOffset+5); - resX = StResInfo[tempal][0]; - resY = StResInfo[tempal][1]; - } else { - tempal = *(ROMAddr+ModeIDOffset+9); - resX = ModeResInfo[tempal][0]; - resY = ModeResInfo[tempal][1]; - } - if (ModeNo > 0x13) { - mode_flag = *(CARD16 *)(ROMAddr+ModeIDOffset+1); - if (mode_flag & HALF_DCLK) - resX *= 2; - if (mode_flag & DOUBLE_SCAN) - resY *= 2; - } - if (LCDResInfo != PANEL_1024x768) { - if (resY == 400) resY = 405; - if (resY == 350) resY = 360; - if (SetFlag & LCDVESA_TIMING) - if (resY == 360) resY = 375; - } - HDE = VGAHDE = resX; - VDE = VGAVDE = resY; -} - -void -GetRAMDAC2Data(CARD8 *ROMAddr, CARD16 ModeNo) -{ - unsigned short tempax, /* horizontal total */ - tempbx; /* vertical total */ - unsigned char cr0, cr6, cr7, sra, srb; - - RVBHCMAX=1; - RVBHCFACT=1; - if (ModeNo <= 0x13) { - /* unused */ - ErrorF("Current we do not support STD mode for LCD/TV\n"); - } else { - GetCRT1Ptr(ROMAddr); - cr0 = *(ROMAddr+CRTC1Offset); - cr6 = *(ROMAddr+CRTC1Offset+6); - cr7 = *(ROMAddr+CRTC1Offset+7); - sra = *(ROMAddr+CRTC1Offset+13); - srb = *(ROMAddr+CRTC1Offset+14); - tempax = cr0 | GETBITSTR(srb, 1:0, 9:8); - tempbx = cr6 | GETBITSTR(cr7, 0:0, 8:8) | - GETBITSTR(cr7, 5:5, 9:9) | GETBITSTR(sra, 0:0, 10:10); - if (*(CARD16 *)(ROMAddr+ModeIDOffset+1) & CHAR_8DOT) - HT = VGAHT = tempax * 8; - else - HT = VGAHT = tempax * 9; - VT = VGAVT = tempbx + 1; - } -} - -Bool -GetLockInfo(CARD16 p3d4, CARD8 info) -{ - unsigned char temp; - - inSISIDXREG(p3d4, 0x35, temp); - return ((temp & info)!=0); -} - -void -SetLockRegs(CARD16 BaseAddr, CARD8 info) -{ - if (!(VBInfo & SET_IN_SLAVE_MODE)) - return; - if (VBInfo & SET_CRT2_TO_RAMDAC) - return; - orSISIDXREG(BaseAddr+CROFFSET, 0x35, info); - LongWait(BaseAddr+0x5a); - orSISIDXREG(BaseAddr+SROFFSET, 0x32, 0x20); -} - -void -GetCRT1Ptr(CARD8 *ROMAddr) -{ - CRTC1Offset = *((CARD16 *)(ROMAddr+0x204)) + - *(ROMAddr+FRateOffset+2) * 17; -} - -void -GetCRT2Ptr(CARD8 *ROMAddr, CARD16 ModeNo) -{ - unsigned char index; - if (ModeNo <= 0x13) - index = *(ROMAddr+ModeIDOffset+4); - else - index = *(ROMAddr+FRateOffset+4) & 0x1F; - - if (VBInfo & SET_CRT2_TO_LCD) { - if (LCDResInfo == PANEL_1024x768) - if (SetFlag & LCDVESA_TIMING) - CRTC2Ptr = ExtLCD1Data[index]; - else - CRTC2Ptr = StLCD1Data[index]; - else - if (SetFlag & LCDVESA_TIMING) - CRTC2Ptr = ExtLCD2Data[index]; - else - CRTC2Ptr = StLCD2Data[index]; - } else if (VBInfo & SET_CRT2_TO_HIVISION_TV) { - if (SetFlag & TV_SIMU_MODE) - CRTC2Ptr = StHiTVData[index]; - else - CRTC2Ptr = ExtHiTVData[index]; - } else { - if (VBInfo & SET_PAL_TV) { - if (SetFlag & TV_SIMU_MODE) - CRTC2Ptr = StPALData[index]; - else - CRTC2Ptr = ExtPALData[index]; - } else { - if (SetFlag & TV_SIMU_MODE) - CRTC2Ptr = StNTSCData[index]; - else - CRTC2Ptr = ExtNTSCData[index]; - } - } -} - -void -SetGroup1(ScrnInfoPtr pScrn, CARD16 ModeNo) -{ - CARD16 part1_base = SISPTR(pScrn)->RelIO+4; - CARD8 * ROMAddr = SISPTR(pScrn)->BIOS; - CARD8 * CRTC1Ptr = ROMAddr+CRTC1Offset; - CARD16 tempax, tempbx, tempcx, temp; - - ErrorF("Enter SetGroup1()\n"); - SetCRT2Offset(pScrn); - SetCRT2FIFO(pScrn); - SetCRT2Sync(ROMAddr, part1_base); - GetCRT1Ptr(ROMAddr); - - outSISIDXREG(part1_base, 8, GETVAR8(VGAHT-1)); - setSISIDXREG(part1_base, 9, GENMASK(3:0), GETBITSTR(VGAHT-1,11:8,7:4)); - outSISIDXREG(part1_base, 0x0A, GETVAR8(VGAHDE+12)); - - tempcx = (VGAHT - VGAHDE) >> 2; - tempbx = VGAHDE + 12; - tempbx += tempcx; - tempcx = tempbx + (tempcx << 1); - if (VBInfo & SET_CRT2_TO_RAMDAC) { - tempbx = *(CRTC1Ptr+4) | GETBITSTR(*(CRTC1Ptr+14), 7:6, 9:8); - tempbx = (tempbx-1) << 3; - tempcx = (*(CRTC1Ptr+5) & 0x1F) | ((*(CRTC1Ptr+15) & 4) << 3); - tempcx = (tempcx-1) << 3; - } - outSISIDXREG(part1_base, 0x0B, GETVAR8(tempbx)); - outSISIDXREG(part1_base, 0x0C, GETBITSTR(VGAHDE+12,11:8,7:4) | - GETBITSTR(tempbx,11:8,3:0)); - outSISIDXREG(part1_base, 0x0D, GETVAR8(tempcx)); - outSISIDXREG(part1_base, 0x0E, GETVAR8(VGAVT-1)); - outSISIDXREG(part1_base, 0x0F, GETVAR8(VGAVDE-1)); - outSISIDXREG(part1_base, 0x12, GETBITSTR(VGAVT-1,10:8, 2:0) | - GETBITSTR(VGAVDE-1, 10:8, 5:3)); - tempbx = (VGAVDE + VGAVT) >> 1; - tempcx = ((VGAVT - VGAVDE) >> 4) + tempbx + 1; - if (VBInfo & SET_CRT2_TO_RAMDAC) { - tempbx = *(CRTC1Ptr+8); - if (*(CRTC1Ptr+7) & 4) - tempbx |= 0x100; - if (*(CRTC1Ptr+7) & 0x80) - tempbx |= 0x200; - if (*(CRTC1Ptr+13) & 8) - tempbx |= 0x400; - tempcx = *(CRTC1Ptr+9); - } - outSISIDXREG(part1_base, 0x10, GETVAR8(tempbx)); - outSISIDXREG(part1_base, 0x11, GETBITS(tempcx, 3:0) | - GETBITSTR(tempbx,10:8, 6:4)); - temp = 0x10; - if (LCDResInfo != PANEL_1024x768) - temp = 0x20; - if (VBInfo & SET_CRT2_TO_TV) { - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - temp = 0x20; - else - temp = 8; - } - setSISIDXREG(part1_base, 0x13, ~0x3C, temp); - - if (!(VBInfo & SET_IN_SLAVE_MODE)) - return; - - /* skip set in slave/lock mode */ - - ErrorF("Leave SetGroup1()\n"); -} - -void -SetGroup2(CARD16 BaseAddr, CARD8 *ROMAddr) -{ - CARD16 part2_base = BaseAddr+0x10; - CARD8 temp; - CARD16 tempax, tempcx, tempbx, *Data16Ptr; - - ErrorF("Enter SetGroup2()\n"); - temp = (VBInfo & SET_CRT2_TO_AVIDEO) << 1 | - (VBInfo & SET_CRT2_TO_SVIDEO) >> 1 | - (VBInfo & SET_CRT2_TO_SCART) >> 3 | - (VBInfo & SET_CRT2_TO_HIVISION_TV) >> 7 ; - temp ^= 0x0C; - if (!(VBInfo & (SET_CRT2_TO_HIVISION_TV | SET_PAL_TV))) - temp |= 0x10; - outSISIDXREG(part2_base, 0, temp); - - if (VBInfo & (SET_CRT2_TO_HIVISION_TV | SET_PAL_TV)) - SetBlock(part2_base, 0x31, 0x34, ROMAddr+0xF1); - else - SetBlock(part2_base, 0x31, 0x34, ROMAddr+0xED); - - if (VBInfo & SET_CRT2_TO_HIVISION_TV) { - if (SetFlag & TV_SIMU_MODE) { - SetBlock(part2_base, 0x01, 0x2D, HiTVTimingSimu1); - SetBlock(part2_base, 0x39, 0x45, HiTVTimingSimu2); - Data16Ptr = HiTVTimingSimu3; - } else { - SetBlock(part2_base, 0x01, 0x2D, HiTVTiming1); - SetBlock(part2_base, 0x39, 0x45, HiTVTiming2); - Data16Ptr = HiTVTiming3; - } - } else { - if (VBInfo & SET_PAL_TV) { - SetBlock(part2_base, 0x01, 0x2D, PALTiming1); - SetBlock(part2_base, 0x39, 0x45, PALTiming2); - Data16Ptr = PALTiming3; - } else { - SetBlock(part2_base, 0x01, 0x2D, NTSCTiming1); - SetBlock(part2_base, 0x39, 0x45, NTSCTiming2); - Data16Ptr = NTSCTiming3; - } - } - - orSISIDXREG(part2_base, 0x0A, NewFlickerMode); - outSISIDXREG(part2_base, 0x35, RY1COE); - outSISIDXREG(part2_base, 0x36, RY2COE); - outSISIDXREG(part2_base, 0x37, RY3COE); - outSISIDXREG(part2_base, 0x38, RY4COE); - outSISIDXREG(part2_base, 0x1B, GETVAR8(HT-1)); - setSISIDXREG(part2_base, 0x1D, ~0x0F, GETBITS(HT-1,11:8)); - - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - tempcx = (HT >> 1) + 3; - else - tempcx = (HT >> 1) + 7; - setSISIDXREG(part2_base, 0x22, ~0xF0, GETBITSTR(tempcx, 3:0, 7:4)); - - tempbx = Data16Ptr[0] + tempcx; - outSISIDXREG(part2_base, 0x24, GETVAR8(tempbx)); - setSISIDXREG(part2_base, 0x25, ~0xF0, GETBITSTR(tempbx, 11:8, 7:4)); - - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - tempcx = tempbx += 4; - else - tempbx += 8; - setSISIDXREG(part2_base, 0x29, ~0xF0, GETBITSTR(tempbx, 3:0, 7:4)); - - tempcx += Data16Ptr[1]; - outSISIDXREG(part2_base, 0x27, GETVAR8(tempcx)); - setSISIDXREG(part2_base, 0x28, ~0xF0, GETBITSTR(tempcx, 11:8, 7:4)); - - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - tempcx += 4; - else - tempcx += 8; - setSISIDXREG(part2_base, 0x2A, ~0xF0, GETBITSTR(tempcx, 3:0, 7:4)); - tempcx = (HT >> 1) - Data16Ptr[2]; - setSISIDXREG(part2_base, 0x2D, ~0xF0, GETBITSTR(tempcx, 3:0, 7:4)); - tempcx -= 11; - if (!(VBInfo & SET_CRT2_TO_TV)) - tempcx = GetVGAHT2()-1; - outSISIDXREG(part2_base, 0x2E, GETVAR8(tempcx)); - switch (VGAVDE) { - case 360: - case 375: - tempbx = 746; - break; - case 405: - tempbx = 853; - break; - default: - tempbx = VDE; - } - if (VBInfo & SET_CRT2_TO_TV) - tempbx >>= 1; - tempbx -= 2; - outSISIDXREG(part2_base, 0x2F, GETVAR8(tempbx)); - - temp = GETBITS(tempcx, 11:8) | GETBITSTR(tempbx, 9:8, 7:6); - temp |= 0x10; - if (!(VBInfo & SET_CRT2_TO_SVIDEO)) - temp |= 0x20; - outSISIDXREG(part2_base, 0x30, temp); - - tempbx = 0; - temp = 0; - if ( !(*(CARD16 *)(ROMAddr+ModeIDOffset+1) & HALF_DCLK) ) { - tempcx = VGAHDE; - if (tempcx >= HDE) { - temp |= 0x20; - } - } - tempcx = 0x0101; - if (VBInfo & SET_CRT2_TO_HIVISION_TV) { - if (VGAHDE >= 1024) { - tempcx = 0x1920; - if (VGAHDE >= 1280) { - tempcx = 0x1420; - temp &= (~0x20); - } - } - } - if (!(temp & 0x20)) { - if (*(CARD16 *)(ROMAddr+ModeIDOffset+1) & HALF_DCLK) - tempcx = (tempcx & 0xFF00) | GETVAR8(tempcx << 1); - tempbx = (VGAHDE * (tempcx >> 8) / GETVAR8(tempcx) * - 8*1024 + (HDE-1)) / HDE; - } - outSISIDXREG(part2_base, 0x44, GETVAR8(tempbx)); - setSISIDXREG(part2_base, 0x45, ~0x3F, temp | GETBITS(tempbx, 12:8)); - - if (VBInfo & SET_CRT2_TO_TV) - return; - - outSISIDXREG(part2_base, 0x2C, GETVAR8(HDE-1)); - setSISIDXREG(part2_base, 0x2B, ~0xF0, GETBITSTR(HDE-1, 11:8, 7:4)); - if ((LCDResInfo == PANEL_1280x1024) && - (ModeType == MODE_EGA) && (VGAHDE >= 1024)) { - outSISIDXREG(part2_base, 0x0B, 2); - } else { - outSISIDXREG(part2_base, 0x0B, 1); - } - - outSISIDXREG(part2_base, 0x03, GETVAR8(VDE-1)); - setSISIDXREG(part2_base, 0x0C, ~0x07, GETBITS(VDE-1, 10:8)); - - outSISIDXREG(part2_base, 0x19, GETVAR8(VT-1)); - if (LCDInfo & LCDRGB18BIT) - temp = 0; - else - temp = 0x10; - setSISIDXREG(part2_base, 0x1A, ~0xF0, GETBITSTR(VT-1, 10:8,7:5) | temp); - - tempbx = 768; - if (LCDResInfo != PANEL_1024x768) - tempbx = 1024; - tempax = 1; - if (tempbx != VDE) - tempax = (tempbx-VDE) >> 1; - tempcx = VT - tempax; - tempbx -= tempax; - outSISIDXREG(part2_base, 5, GETVAR8(tempcx)); - outSISIDXREG(part2_base, 6, GETVAR8(tempbx)); - outSISIDXREG(part2_base, 2, GETBITS(tempcx, 2:0) | - GETBITSTR(tempbx, 4:0, 7:3)); - tempbx = VT; - tempax = VDE; - - tempcx = (VT-VDE) >> 4; - tempbx = (tempbx+tempax) >> 1; - outSISIDXREG(part2_base, 4, GETVAR8(tempbx)); - outSISIDXREG(part2_base, 1, GETBITSTR(tempbx, 11:8, 7:4) | - GETBITS(tempbx+tempcx+1, 3:0)); - - andSISIDXREG(part2_base, 0x09, 0xF0); - andSISIDXREG(part2_base, 0x0A, 0xF0); - - tempcx = (HT-HDE) >> 2; - tempbx = HDE+7; - outSISIDXREG(part2_base, 0x23, GETVAR8(tempbx)); - setSISIDXREG(part2_base, 0x25, ~0x0F, GETBITS(tempbx, 11:8)); - - outSISIDXREG(part2_base, 0x1F, 0x07); - andSISIDXREG(part2_base, 0x20, 0x0F); - - tempbx += tempcx; - outSISIDXREG(part2_base, 0x1C, GETVAR8(tempbx)); - setSISIDXREG(part2_base, 0x1D, ~0xF0, GETBITSTR(tempbx, 11:8, 7:4)); - - tempbx += tempcx; - outSISIDXREG(part2_base, 0x21, GETVAR8(tempbx)); - - andSISIDXREG(part2_base, 0x17, 0xFB); - andSISIDXREG(part2_base, 0x18, 0xDF); - - ErrorF("Leave SetGroup2()\n"); -} - -void -SetCRT2Offset(ScrnInfoPtr pScrn) -{ - unsigned short offset; - SISPtr pSiS; - CARD16 part1_base; - - if (VBInfo & SET_IN_SLAVE_MODE) - return; - - pSiS = SISPTR(pScrn); - part1_base = pSiS->RelIO+4; - offset = pSiS->scrnOffset >> 3; - - outSISIDXREG(part1_base, 7, GETVAR8(offset)); - setSISIDXREG(part1_base, 9, - ~GENMASK(3:0), GETBITSTR(offset, 11:8, 3:0)); - - offset = (offset >> 3)+1; /* SetFIFOStop */ - outSISIDXREG(part1_base, 3, GETVAR8(offset)); -} - -static char timing[8] = {1, 2, 2, 3, 0, 1, 1, 2}; -static short factor[12][2] = {{81, 4}, {72, 6}, {88, 8}, {120, 12}, - {55, 4}, {54, 6}, {66, 8}, { 90, 12}, - {42, 4}, {45, 6}, {55, 8}, { 75, 12}}; -void -SetCRT2FIFO(ScrnInfoPtr pScrn) -{ - unsigned int Low; - unsigned int High; - SISPtr pSiS = SISPTR(pScrn); -#if 0 - unsigned int temp, dclk, vclk; -#endif - unsigned short part1_base = pSiS->RelIO+4; - - Low = 0x14; - High = 0x17; - if (pSiS->Chipset == PCI_CHIP_SIS300) { - if (Low > 0x0F) - High = 0x16; - else - High = 0x13; - } - setSISIDXREG(part1_base, 2, ~0x1F, Low); - setSISIDXREG(part1_base, 1, ~0x1F, High); -} - -void -SetCRT2Sync(CARD8 * ROMAddr, CARD16 part1_base) -{ - setSISIDXREG(part1_base, 0x19, ~0xC0, - (*(CARD16 *)(ROMAddr+FRateOffset) >> 8) & 0xC0); -} - -void -SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr) -{ - CARD8 index; - - for (index=from; index <= to; index++, DataPtr++) { - outSISIDXREG(port, index, *DataPtr); - } -} -unsigned short -GetVGAHT2() -{ - return ((VT-VDE)*RVBHCFACT*HT) / ((VGAVT-VGAVDE)*RVBHCMAX); -} - -void -SetGroup3(CARD16 BaseAddr) -{ - ErrorF("Enter SetGroup3()\n"); - if (VBInfo & SET_CRT2_TO_HIVISION_TV) - if (SetFlag & TV_SIMU_MODE) - SetBlock(BaseAddr+0x12, 0, 0x3E, HiTVGroup3Simu); - else - SetBlock(BaseAddr+0x12, 0, 0x3E, HiTVGroup3Data); - else - if (VBInfo & SET_PAL_TV) - SetBlock(BaseAddr+0x12, 0, 0x3E, PALGroup3Data); - else - SetBlock(BaseAddr+0x12, 0, 0x3E, NTSCGroup3Data); - ErrorF("Leave SetGroup3()\n"); -} - -void -SetGroup4(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo) -{ - CARD16 part4_base = BaseAddr+0x14; - CARD8 temp; - CARD16 tempax, tempbx, tempcx; - CARD32 temp32; - - ErrorF("Enter SetGroup4()\n"); - outSISIDXREG(part4_base, 0x13, RVBHCFACT); - outSISIDXREG(part4_base, 0x14, GETVAR8(RVBHCMAX)); - outSISIDXREG(part4_base, 0x16, GETVAR8(VGAHT-1)); - tempcx = VGAVT-1; - if (!(VBInfo & SET_CRT2_TO_TV)) - tempcx -= 5; - outSISIDXREG(part4_base, 0x17, GETVAR8(tempcx)); - outSISIDXREG(part4_base, 0x15, GETBITSTR(RVBHCMAX, 7:7, 8:8) | - GETBITSTR(VGAHT-1, 11:8, 6:3) | - GETBITS(tempcx, 10:8)); - - tempbx = VGAHDE; - if (*(CARD16 *)(ROMAddr+ModeIDOffset+1) & HALF_DCLK) - tempbx >>= 1; - switch (VBInfo & (SET_CRT2_TO_TV | SET_CRT2_TO_LCD)) { - case SET_CRT2_TO_HIVISION_TV: - if (tempbx == 1024) - temp = 0xA0; - if (tempbx == 1280) - temp = 0xC0; - else - temp = 0; - break; - case SET_CRT2_TO_LCD: - if (tempbx <= 800) - temp = 0; - else - temp = 0x60; - break; - default: - temp = 0x80; - } - if (LCDResInfo != PANEL_1280x1024) - temp |= 0x0A; - setSISIDXREG(part4_base, 0x0E, ~0xEF, temp); - - if ((VBInfo & SET_CRT2_TO_HIVISION_TV) && !(temp & 0xE0)) - tempbx = VDE >> 1; - else - tempbx = VDE; - outSISIDXREG(part4_base, 0x18, GETVAR8(RVBHRS)); - if (VGAVDE >= tempbx) { - tempax = VGAVDE - tempbx; - temp = 0x40; - } else { - tempax = VGAVDE; - temp = 0; - } - temp32 = (tempax * 256*1024 + (tempbx-1)) / tempbx; - outSISIDXREG(part4_base, 0x1B, GETVAR8(temp32)); - outSISIDXREG(part4_base, 0x1A, GETBITS(temp32, 15:8)); - outSISIDXREG(part4_base, 0x19, GETBITS(RVBHRS, 11:8) | - GETBITSTR(temp32, 17:16, 5:4) | temp); - SetCRT2VCLK(BaseAddr, ROMAddr, ModeNo); - ErrorF("Leave SetGroup4()\n"); -} - -void -SetCRT2VCLK(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo) -{ - CARD8 *VCLK2Ptr; - CARD16 part4_base = BaseAddr + 0x14; - - VCLK2Ptr = GetVCLK2Ptr(BaseAddr, ROMAddr, ModeNo); - outSISIDXREG(part4_base, 0x0A, 1); - outSISIDXREG(part4_base, 0x0B, *(VCLK2Ptr+1)); - outSISIDXREG(part4_base, 0x0A, *(VCLK2Ptr)); - outSISIDXREG(part4_base, 0x12, 0); - if (VBInfo & SET_CRT2_TO_RAMDAC) { - orSISIDXREG(part4_base, 0x12, 0x28); - } else { - orSISIDXREG(part4_base, 0x12, 0x08); - } -} - -CARD8 * -GetVCLK2Ptr(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo) -{ - CARD8 index; - CARD16 VCLKTableBase; - - if (ModeNo <= 0x13) - index = *(ROMAddr+ModeIDOffset+4); - else - index = *(ROMAddr+FRateOffset+4); - - switch (VBInfo & 0xFC) { - case SET_CRT2_TO_HIVISION_TV: - if (SetFlag & RPLLDIV2XO) - index = HITVVCLKDIV2; - else - index = HITVVCLK; - if (SetFlag & TV_SIMU_MODE) - index = HITVSIMUVCLK; - break; - case SET_CRT2_TO_LCD: - if (LCDResInfo == PANEL_1024x768) - index = VCLK65; - else - index = VCLK108_2; - break; - case SET_CRT2_TO_RAMDAC: - if (ModeNo <= 0x13) { - index = GETBITS(inSISREG(BaseAddr+0x4C), 3:2); - } else { - index = *(ROMAddr+FRateOffset+3); - } - break; - default: - if (SetFlag & RPLLDIV2XO) - index = TVVCLKDIV2; - else - index = TVVCLK; - } - VCLKTableBase = *(CARD16 *)(ROMAddr+0x208); - return (ROMAddr + VCLKTableBase + index*4); -} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.h:1.1 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.h:removed --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.h:1.1 Sat Feb 12 15:45:34 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.h Mon Dec 18 14:31:08 2000 @@ -1,199 +0,0 @@ -#define P1_INDEX 0x04 -#define P2_INDEX 0x10 -#define P3_INDEX 0x12 -#define P4_INDEX 0x14 -#define P5_INDEX 0x16 - -/* CR30 VBInfo = CR31:CR30 */ -#define SET_SIMU_SCAN_MODE 0x0001 -#define SWITCH_TO_CRT2 0x0002 -#define SET_CRT2_TO_AVIDEO 0x0004 /* Composite */ -#define SET_CRT2_TO_SVIDEO 0x0008 -#define SET_CRT2_TO_SCART 0x0010 -#define SET_CRT2_TO_LCD 0x0020 -#define SET_CRT2_TO_RAMDAC 0x0040 -#define SET_CRT2_TO_HIVISION_TV 0x0080 -#define SET_CRT2_TO_TV (SET_CRT2_TO_AVIDEO | SET_CRT2_TO_SVIDEO | \ - SET_CRT2_TO_SCART | SET_CRT2_TO_HIVISION_TV) -/* CR31 */ -#define SET_PAL_TV 0x0100 -#define SET_IN_SLAVE_MODE 0x0200 -#define SET_NO_SIMU_ON_LOCK 0x0400 -#define SET_NO_SIMU_TV_ON_LOCK SET_NO_SIMU_ON_LOCK -#define DISABLE_LOAD_CRT2DAC 0x1000 -#define DISABLE_CRT2_DISPLAY 0x2000 -#define DRIVER_MODE 0x4000 - -/* CR36 */ -#define PANEL_1024x768 0x00 -#define PANEL_1280x1024 0x01 - -/* Set Flag */ -#define PROGRAMMING_CRT2 0x0001 -#define TV_SIMU_MODE 0x0002 -#define RPLLDIV2XO 0x0004 - -/* Mode Flag */ -#define MODE_INFO_FLAG 0x0007 -#define MODE_CGA 0x0001 -#define MODE_EGA 0x0002 -#define MODE_VGA 0x0003 -#define MODE_15BPP 0x0004 -#define MODE_16BPP 0x0005 -#define MODE_24BPP 0x0006 -#define MODE_32BPP 0x0007 - -#define DAC_INFO_FLAG 0x0018 -#define MONO_DAC 0x0000 -#define CGA_DAC 0x0008 -#define EGA_DAC 0x0010 -#define VGA_DAC 0x0018 - -#define CHAR_8DOT 0x0200 -#define LINE_COMPARE_OFF 0x0400 -#define CRT2_MODE 0x0800 -#define HALF_DCLK 0x1000 -#define NO_SUPPORT_SIMU_TV 0x2000 -#define AFTER_LOCK_CRT2 0x4000 -#define DOUBLE_SCAN 0x8000 - -/* LCD Res Info */ -#define LCDVESA_TIMING 0x08 - -/* LCD Type Info */ -/* LCD Info */ -#define LCDRGB18BIT 0x01 - -/* Misc definition */ -#define SELECT_CRT1 0x01 -#define SELECT_CRT2 0x02 - -#define MODE_INFO_MASK 0x0007 -#define AFTER_LOCK_CRT2 0x4000 - -#define SUPPORT_TV 0x0008 -#define SUPPORT_LCD 0x0020 -#define SUPPORT_RAMDAC2 0x0040 - -/* GetRatePtr */ -#define STANDARD_MODE 0x0000 -#define ENHANCED_MODE 0x0001 -#define CRT2_SUPPORT 0x0002 -#define CRT2_NO_SUPPORT 0x0000 - -#define INTERLACE_MODE 0x0080 - -/* VCLK index */ -#define VCLK65 0x09 -#define VCLK108_2 0x14 - -/* TV resolution info */ -#define ST_HIVISION_TV_HT 892 -#define ST_HIVISION_TV_VT 1126 -#define EXT_HIVISION_TV_HT 2100 -#define EXT_HIVISION_TV_VT 1125 -#define PAL_HT 1728 -#define PAL_VT 625 -#define NTSC_HT 1716 -#define NTSC_VT 525 - -#define TVVCLKDIV2 0x21 -#define TVVCLK 0x22 -#define HITVVCLKDIV2 0x23 -#define HITVVCLK 0x24 -#define HITVSIMUVCLK 0x25 - -#define LCDDATA(p0,p1,p2,p3,p4,p5) {p0&0xFF, p1&0xFF, p2&0xFF,\ - (p2>>8)|((p3&0xF)<<4), (p3>>4)|((p0&0x100)>>1), p4&0xFF,\ - (p4>>8)|((p5&0xF)<<4), p5>>4} -#define TVDATA(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12) {p0&0xFF,\ - p1&0xFF, p2&0xFF, (p2>>8)|((p3&0xF)<<4),\ - (p3>>4)|((p0&0x100)>>1), p4&0xFF, (p4>>8)|((p5&0xF)<<4),\ - p5>>4, p6&0xFF, (p6>>8)|(p7<<7), p8&0xFF, p8>>8, p9&0xFF,\ - p10&0xFF, p11&0xFF, p12&0xFF} -#define HITVDATA(p0,p1,p2,p3,p4,p5,p6,p7,p8) {p0&0xFF, p1&0xFF, p2&0xFF,\ - (p2>>8)|((p3&0xF)<<4), (p3>>4)|((p0&0x100)>>1), p4&0xFF,\ - (p4>>8)|((p5&0xF)<<4), p5>>4, p6&0xFF, (p6>>8)|(p7<<7),\ - p8&0xFF, p8>>8} - -#define STMODE_SIZE 6 -#define EMODE_SIZE 10 -#define EMODE2_SIZE 5 - -typedef struct _STMode { - unsigned char ModeID; - unsigned short ModeFlag; - unsigned char StModeTableIndex; - unsigned char CRTC2Index; - unsigned char ResInfo; -} STModeRec, *STModePtr; - -typedef struct _EMode { - unsigned char ModeID; - unsigned short ModeFlag; - unsigned char ModeInfo; - unsigned short EMode2Offset; - unsigned short VESAModeID; - unsigned char MemSize; - unsigned char ResInfo; -} EModeRec, *EModePtr; - -typedef struct _EMode2 { - unsigned short InfoFlag; - unsigned char CRTC1Index; - unsigned char VCLKIndex; - unsigned char CRTC2Index; -} EMode2Rec, *EMode2Ptr; - -typedef struct _CRTCInfoBlock { - unsigned short HTotal; - unsigned short HSyncStart; - unsigned short HSyncEnd; - unsigned short VTotal; - unsigned short VSyncStart; - unsigned short VSyncEnd; - unsigned char Flag; - unsigned long PixelClock; - unsigned short RefreshRate; -} CRTCInfo, *CRTCInfoPtr; - -Bool SiSSetMode(ScrnInfoPtr pScrn, CARD16 ModeNo); -Bool SearchModeID(CARD8 *ROMAddr, CARD16 ModeNo); -void GetVBInfo(CARD16 BaseAddr, CARD8 *ROMAddr); -Bool BridgeIsOn(CARD16 BaseAddr); -Bool BridgeIsEnable(CARD16 BaseAddr); -Bool BridgeInSlave(CARD16 BaseAddr); -void GetLCDResInfo(CARD16 p3d4); -Bool CheckVBInfo(CARD16 BaseAddr); -CARD16 GetRatePtr(ScrnInfoPtr pScrn, CARD16 ModeNo, CARD8 CRTx); -CARD16 AdjustCRT2Rate(CARD8 *ROMAddr); -void SaveCRT2Info(CARD16 p3d4, CARD16 ModeNo); -void SetCRT2Group(ScrnInfoPtr pScrn, CARD16 ModeNo); -void LongWait(CARD16 p3da); -void VBLongWait(CARD16 p3da); -Bool WaitVBRetrace(CARD16 BaseAddr); -void EnableBridge(CARD16 BaseAddr); -void DisableBridge(CARD16 BaseAddr); -void LockCRT2(CARD16 BaseAddr); -void UnLockCRT2(CARD16 BaseAddr); -void EnableCRT2(CARD16 BaseAddr); -void SetCRT2ModeRegs(CARD16 BaseAddr, CARD16 ModeNo); -void GetResInfo(CARD8 *ROMAddr, CARD16 ModeNo); -Bool GetLockInfo(CARD16 p3d4, CARD8 info); -void SetLockRegs(CARD16 BaseAddr, CARD8 info); -void GetCRT1Ptr(CARD8 *ROMAddr); -void GetCRT2Ptr(CARD8 *ROMAddr, CARD16 ModeNo); -void GetRAMDAC2Data(CARD8 *ROMAddr, CARD16 ModeNo); -void GetCRT2Data(CARD8 *ROMAddr, CARD16 ModeNo); -void SetCRT2Offset(ScrnInfoPtr pScrn); -void SetCRT2FIFO(ScrnInfoPtr pScrn); -void SetCRT2Sync(CARD8 *ROMAddr, CARD16 part1_base); -void SetGroup1(ScrnInfoPtr pScrn, CARD16 ModeNo); -void SetGroup2(CARD16 BaseAddr, CARD8 *ROMAddr); -void SetGroup3(CARD16 BaseAddr); -void SetGroup4(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo); -void SetGroup5(CARD16 BaseAddr, CARD8 *ROMAddr); -void SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr); -CARD16 GetVGAHT2(void); -void SetCRT2VCLK(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo); -CARD8 * GetVCLK2Ptr(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo); Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c:1.14 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c:1.14 Fri Mar 31 15:13:36 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c Sat Dec 2 10:30:50 2000 @@ -25,7 +25,7 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.14 2000/03/31 20:13:36 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.18 2000/12/02 15:30:50 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -38,32 +38,34 @@ #include "sis.h" #include "sis_regs.h" -#include "sis_bios.h" +#include "sis_vb.h" -static void SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); -static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); - -static void SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, - int *indicies, LOCO *colors, VisualPtr pVisual); - -static void SiS300Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); -static void SiS301Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); -static void SiS630Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); -static void SiS530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); -static void SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High); +static void SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiSLVDSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiSLVDSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg); +static void SiSChrontelSave(ScrnInfoPtr pScrn, SISRegPtr sisReg); + +static void SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, + int *indicies, LOCO *colors, VisualPtr pVisual); + +static void SiS300Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned short *Low, unsigned short *High); +static void SiS630Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned short *Low, unsigned short *High); +static void SiS530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned short *Low, unsigned short *High); +static void SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode, + unsigned short *Low, unsigned short *High); -static unsigned int GetClock(int Num, int DeNum, int PostScale, int Div); +unsigned short ch7005idx[0x11]={0x00,0x07,0x08,0x0a,0x0b,0x04,0x09,0x20,0x21,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f}; + int compute_vclk( int Clock, @@ -74,7 +76,7 @@ int *out_scale) { float f,x,y,t, error, min_error; - int n, dn, best_n, best_dn; + int n, dn, best_n=0, best_dn=0; /* * Rules @@ -162,9 +164,9 @@ } *out_n = best_n; *out_dn = best_dn; - PDEBUG(ErrorF("compute_vclk: Clock=%d, n=%d, dn=%d, div=%d, sbit=%d," - " scale=%d\n", Clock, best_n, best_dn, *out_div, - *out_sbit, *out_scale)); + PDEBUG(ErrorF("compute_vclk: Clock=%d, n=%d, dn=%d, div=%d, sbit=%d," + " scale=%d\n", Clock, best_n, best_dn, *out_div, + *out_sbit, *out_scale)); return 1; } @@ -174,28 +176,28 @@ { SISPtr pSiS = SISPTR(pScrn); int M, N, P , PSN, VLD , PSNx ; - int bestM, bestN, bestP, bestPSN, bestVLD; + int bestM=0, bestN=0, bestP=0, bestPSN=0, bestVLD=0; double bestError, abest = 42.0, bestFout; double target; double Fvco, Fout; double error, aerror; /* - * fd = fref*(Numerator/Denumerator)*(Divider/PostScaler) + * fd = fref*(Numerator/Denumerator)*(Divider/PostScaler) * - * M = Numerator [1:128] - * N = DeNumerator [1:32] - * VLD = Divider (Vco Loop Divider) : divide by 1, 2 - * P = Post Scaler : divide by 1, 2, 3, 4 + * M = Numerator [1:128] + * N = DeNumerator [1:32] + * VLD = Divider (Vco Loop Divider) : divide by 1, 2 + * P = Post Scaler : divide by 1, 2, 3, 4 * PSN = Pre Scaler (Reference Divisor Select) * * result in vclk[] */ -#define Midx 0 -#define Nidx 1 -#define VLDidx 2 -#define Pidx 3 -#define PSNidx 4 +#define Midx 0 +#define Nidx 1 +#define VLDidx 2 +#define Pidx 3 +#define PSNidx 4 #define Fref 14318180 /* stability constraints for internal VCO -- MAX_VCO also determines * the maximum Video pixel clock */ @@ -203,7 +205,7 @@ #define MAX_VCO 135000000 #define MAX_VCO_5597 353000000 #define MAX_PSN 0 /* no pre scaler for this chip */ -#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ +#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ int M_min = 2; int M_max = 128; @@ -214,117 +216,117 @@ if (pSiS->Chipset == PCI_CHIP_SIS5597 || pSiS->Chipset == PCI_CHIP_SIS6326){ - int low_N = 2; - int high_N = 5; - int PSN = 1; + int low_N = 2; + int high_N = 5; + int PSN = 1; - P = 1; - if (target < MAX_VCO_5597 / 2) - P = 2; - if (target < MAX_VCO_5597 / 3) - P = 3; - if (target < MAX_VCO_5597 / 4) - P = 4; - if (target < MAX_VCO_5597 / 6) - P = 6; - if (target < MAX_VCO_5597 / 8) - P = 8; + P = 1; + if (target < MAX_VCO_5597 / 2) + P = 2; + if (target < MAX_VCO_5597 / 3) + P = 3; + if (target < MAX_VCO_5597 / 4) + P = 4; + if (target < MAX_VCO_5597 / 6) + P = 6; + if (target < MAX_VCO_5597 / 8) + P = 8; - Fvco = P * target; + Fvco = P * target; - for (N = low_N; N <= high_N; N++){ - double M_desired = Fvco / Fref * N; - if (M_desired > M_max * max_VLD) - continue; + for (N = low_N; N <= high_N; N++){ + double M_desired = Fvco / Fref * N; + if (M_desired > M_max * max_VLD) + continue; - if ( M_desired > M_max ) { - M = M_desired / 2 + 0.5; - VLD = 2; - } else { - M = Fvco / Fref * N + 0.5; - VLD = 1; - } + if ( M_desired > M_max ) { + M = M_desired / 2 + 0.5; + VLD = 2; + } else { + M = Fvco / Fref * N + 0.5; + VLD = 1; + } - Fout = (double)Fref * (M * VLD)/(N * P); + Fout = (double)Fref * (M * VLD)/(N * P); - error = (target - Fout) / target; - aerror = (error < 0) ? -error : error; -/* if (aerror < abest && abest > TOLERANCE) {*/ - if (aerror < abest) { - abest = aerror; - bestError = error; - bestM = M; - bestN = N; - bestP = P; - bestPSN = PSN; - bestVLD = VLD; - bestFout = Fout; - } - } + error = (target - Fout) / target; + aerror = (error < 0) ? -error : error; +/* if (aerror < abest && abest > TOLERANCE) {*/ + if (aerror < abest) { + abest = aerror; + bestError = error; + bestM = M; + bestN = N; + bestP = P; + bestPSN = PSN; + bestVLD = VLD; + bestFout = Fout; + } + } } else { for (PSNx = 0; PSNx <= MAX_PSN ; PSNx++) { - int low_N, high_N; - double FrefVLDPSN; + int low_N, high_N; + double FrefVLDPSN; - PSN = !PSNx ? 1 : 4; + PSN = !PSNx ? 1 : 4; - low_N = 2; - high_N = 32; + low_N = 2; + high_N = 32; - for ( VLD = 1 ; VLD <= max_VLD ; VLD++ ) { + for ( VLD = 1 ; VLD <= max_VLD ; VLD++ ) { - FrefVLDPSN = (double)Fref * VLD / PSN; - for (N = low_N; N <= high_N; N++) { - double tmp = FrefVLDPSN / N; + FrefVLDPSN = (double)Fref * VLD / PSN; + for (N = low_N; N <= high_N; N++) { + double tmp = FrefVLDPSN / N; - for (P = 1; P <= 4; P++) { - double Fvco_desired = target * ( P ); - double M_desired = Fvco_desired / tmp; + for (P = 1; P <= 4; P++) { + double Fvco_desired = target * ( P ); + double M_desired = Fvco_desired / tmp; - /* Which way will M_desired be rounded? - * Do all three just to be safe. - */ - int M_low = M_desired - 1; - int M_hi = M_desired + 1; + /* Which way will M_desired be rounded? + * Do all three just to be safe. + */ + int M_low = M_desired - 1; + int M_hi = M_desired + 1; - if (M_hi < M_min || M_low > M_max) - continue; + if (M_hi < M_min || M_low > M_max) + continue; - if (M_low < M_min) - M_low = M_min; - if (M_hi > M_max) - M_hi = M_max; + if (M_low < M_min) + M_low = M_min; + if (M_hi > M_max) + M_hi = M_max; - for (M = M_low; M <= M_hi; M++) { - Fvco = tmp * M; - if (Fvco <= MIN_VCO) - continue; - if (Fvco > MAX_VCO) - break; + for (M = M_low; M <= M_hi; M++) { + Fvco = tmp * M; + if (Fvco <= MIN_VCO) + continue; + if (Fvco > MAX_VCO) + break; - Fout = Fvco / ( P ); + Fout = Fvco / ( P ); - error = (target - Fout) / target; - aerror = (error < 0) ? -error : error; - if (aerror < abest) { - abest = aerror; - bestError = error; - bestM = M; - bestN = N; - bestP = P; - bestPSN = PSN; - bestVLD = VLD; - bestFout = Fout; - } - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3,"Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d," - " P=%d, PSN=%d\n", - (float)(clock / 1000.), M, N, P, VLD, PSN); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3,"Freq. set: %.2f MHz\n", Fout / 1.0e6); - } - } - } - } + error = (target - Fout) / target; + aerror = (error < 0) ? -error : error; + if (aerror < abest) { + abest = aerror; + bestError = error; + bestM = M; + bestN = N; + bestP = P; + bestPSN = PSN; + bestVLD = VLD; + bestFout = Fout; + } + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3,"Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d," + " P=%d, PSN=%d\n", + (float)(clock / 1000.), M, N, P, VLD, PSN); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,3,"Freq. set: %.2f MHz\n", Fout / 1.0e6); + } + } + } + } } } @@ -334,14 +336,14 @@ vclk[Pidx] = bestP; vclk[PSNidx] = bestPSN; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d, P=%d, PSN=%d\n", - (float)(clock / 1000.), vclk[Midx], vclk[Nidx], vclk[VLDidx], - vclk[Pidx], vclk[PSNidx])); - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "Freq. set: %.2f MHz\n", bestFout / 1.0e6)); - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "VCO Freq.: %.2f MHz\n", bestFout*bestP / 1.0e6)); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Freq. selected: %.2f MHz, M=%d, N=%d, VLD=%d, P=%d, PSN=%d\n", + (float)(clock / 1000.), vclk[Midx], vclk[Nidx], vclk[VLDidx], + vclk[Pidx], vclk[PSNidx])); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "Freq. set: %.2f MHz\n", bestFout / 1.0e6)); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "VCO Freq.: %.2f MHz\n", bestFout*bestP / 1.0e6)); } @@ -352,8 +354,8 @@ int vgaIOBase; int i,max; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; @@ -361,26 +363,27 @@ outw(VGA_SEQ_INDEX, 0x8605); switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS5597: max=0x39; break; - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: max=0x3F; break; - default: + default: max=0x37; break; - } + } for (i = 0x06; i <= max; i++) { outb(VGA_SEQ_INDEX, i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA)); - sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA)); + sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA); } - sisReg->sisRegs3C2 = inb(0x3CC); + /*sisReg->sisRegs3C2 = inb(0x3CC);*/ + sisReg->sisRegs3C2 = inb(pSiS->RelIO+0x4c); } static void @@ -391,7 +394,7 @@ int i,max; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); + "SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; @@ -399,38 +402,39 @@ outw(VGA_SEQ_INDEX, 0x8605); switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS5597: max=0x39; break; - case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS6326: max=0x3F; break; case PCI_CHIP_SIS530: - max=0x3F; + max=0x3F; break; - default: + default: max=0x37; break; } for (i = 0x06; i <= max; i++) { - outb(VGA_SEQ_INDEX,i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, - "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA)); - - outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]); - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, - "Restore to - %02X Read after - %02X\n", - sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA)); + outb(VGA_SEQ_INDEX,i); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA)); + + outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]); + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "Restore to - %02X Read after - %02X\n", + sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA)); } - outb(0x3C2, sisReg->sisRegs3C2); + /*outb(0x3C2, sisReg->sisRegs3C2);*/ + outb(pSiS->RelIO+0x42, sisReg->sisRegs3C2); /* MemClock needs this to take effect */ - outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ - outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ + outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ + outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ } @@ -441,8 +445,8 @@ int vgaIOBase; int i,max; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n")); vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; @@ -453,19 +457,24 @@ for (i = 0x06; i <= max; i++) { outb(VGA_SEQ_INDEX, i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA)); - sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA)); + sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA); } for (i=0x19; i<0x40; i++) { - inSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]); + inSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]); } - sisReg->sisRegs3C2 = inb(0x3CC); + /*sisReg->sisRegs3C2 = inb(0x3CC);*/ + sisReg->sisRegs3C2 = inb(pSiS->RelIO+0x4c); - if (pSiS->VBFlags & CRT2_ENABLE) - (*pSiS->SiSSave2)(pScrn, sisReg); + if ((pSiS->VBFlags & (VB_LVDS | CRT2_LCD))==(VB_LVDS|CRT2_LCD)) + (*pSiS->SiSSaveLVDS)(pScrn, sisReg); + if ((pSiS->VBFlags & (VB_CHRONTEL | CRT2_TV))==(VB_CHRONTEL|CRT2_TV)) + (*pSiS->SiSSaveChrontel)(pScrn,sisReg); + if ((pSiS->VBFlags & (VB_301|VB_302|VB_303)) && (pSiS->VBFlags & (CRT2_LCD|CRT2_TV|CRT2_VGA))) + (*pSiS->SiSSave2)(pScrn, sisReg); } static void @@ -476,7 +485,7 @@ int i,max, temp; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); + "SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"); vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; @@ -484,103 +493,220 @@ outw(VGA_SEQ_INDEX, 0x8605); inSISIDXREG(VGA_SEQ_INDEX, 0x1E, temp); if (temp & 0x42) { - while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; + while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){}; } max=0x3D; for (i = 0x19; i < 0x40; i++) { - outSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]); + outSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]); } if (pSiS->Chipset != PCI_CHIP_SIS300) { - outSISIDXREG(pSiS->RelIO+CROFFSET, 0x1A, sisReg->sisRegs3D4[0x19]); - outSISIDXREG(pSiS->RelIO+CROFFSET, 0x19, sisReg->sisRegs3D4[0x1A]); + outSISIDXREG(pSiS->RelIO+CROFFSET, 0x1A, sisReg->sisRegs3D4[0x19]); + outSISIDXREG(pSiS->RelIO+CROFFSET, 0x19, sisReg->sisRegs3D4[0x1A]); } if ((pSiS->Chipset == PCI_CHIP_SIS630) && (sisReg->sisRegs3C4[0x1e] & 0x40)) - outw(VGA_SEQ_INDEX, sisReg->sisRegs3C4[0x20] << 8 | 0x20); + outw(VGA_SEQ_INDEX, sisReg->sisRegs3C4[0x20] << 8 | 0x20); for (i = 0x06; i <= max; i++) { - outb(VGA_SEQ_INDEX,i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, - "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA)); - - outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]); - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, - "Restore to - %02X Read after - %02X\n", - sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA)); - } - if (pSiS->VBFlags & CRT2_ENABLE) { /* For SiS301 */ - (*pSiS->SiSRestore2)(pScrn, sisReg); + outb(VGA_SEQ_INDEX,i); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA)); + + outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]); + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "Restore to - %02X Read after - %02X\n", + sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA)); } - outb(0x3C2, sisReg->sisRegs3C2); + if ((pSiS->VBFlags & (VB_LVDS | CRT2_LCD))==(VB_LVDS|CRT2_LCD)) + (*pSiS->SiSRestoreLVDS)(pScrn, sisReg); + if ((pSiS->VBFlags & (VB_CHRONTEL | CRT2_TV))==(VB_CHRONTEL|CRT2_TV)) + (*pSiS->SiSRestoreChrontel)(pScrn,sisReg); + if ((pSiS->VBFlags & (VB_301|VB_302|VB_303)) && (pSiS->VBFlags & (CRT2_LCD|CRT2_TV|CRT2_VGA))) + (*pSiS->SiSRestore2)(pScrn, sisReg); + + /*outb(0x3C2, sisReg->sisRegs3C2);*/ + outb(pSiS->RelIO+0x42, sisReg->sisRegs3C2); + /* MemClock needs this to take effect */ - outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ - outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ + outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ + outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ } static void SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg) { - SISPtr pSiS = SISPTR(pScrn); - int i; + SISPtr pSiS = SISPTR(pScrn); + int i; - /* for SiS301 only */ - for (i=0; i<0x29; i++) { - inSISIDXREG(pSiS->RelIO+4, i, sisReg->VBPart1[i]); - } - for (i=0; i<0x46; i++) { - inSISIDXREG(pSiS->RelIO+0x10, i, sisReg->VBPart2[i]); - } - for (i=0; i<0x3F; i++) { - inSISIDXREG(pSiS->RelIO+0x12, i, sisReg->VBPart3[i]); - } - for (i=0; i<0x1C; i++) { - inSISIDXREG(pSiS->RelIO+0x14, i, sisReg->VBPart4[i]); - } - sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ - sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ + /* for SiS301 only */ + for (i=0; i<0x29; i++) { + inSISIDXREG(pSiS->RelIO+4, i, sisReg->VBPart1[i]); + } + for (i=0; i<0x46; i++) { + inSISIDXREG(pSiS->RelIO+0x10, i, sisReg->VBPart2[i]); + } + for (i=0; i<0x3F; i++) { + inSISIDXREG(pSiS->RelIO+0x12, i, sisReg->VBPart3[i]); + } + for (i=0; i<0x1C; i++) { + inSISIDXREG(pSiS->RelIO+0x14, i, sisReg->VBPart4[i]); + } + sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */ + sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ } static void +SiSLVDSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; + + /* for SiS LVDS only */ + for (i=0; i<0x29; i++) { + inSISIDXREG(pSiS->RelIO+4, i, sisReg->VBPart1[i]); + } + sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ +} + +static void +SiSChrontelSave(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; + + /* for SiS Chrontel TV */ + for (i=0; i<0x29; i++) { + inSISIDXREG(pSiS->RelIO+4, i, sisReg->VBPart1[i]); + } + for (i=0; i<0x11; i++) + sisReg->ch7005[i]=GetCH7005(ch7005idx[i]); + + sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */ +} + + +static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned char temp, temp1; + + DisableBridge(pSiS->RelIO+0x30); + UnLockCRT2(pSiS->RelIO+0x30); + + /* SetCRT2ModeRegs() */ + outSISIDXREG(pSiS->RelIO+0x04, 4, 0); + outSISIDXREG(pSiS->RelIO+0x04, 5, 0); + outSISIDXREG(pSiS->RelIO+0x04, 6, 0); + outSISIDXREG(pSiS->RelIO+0x04, 0, sisReg->VBPart1[0]); + outSISIDXREG(pSiS->RelIO+0x04, 1, sisReg->VBPart1[1]); + outSISIDXREG(pSiS->RelIO+0x14, 0x0D, sisReg->VBPart4[0x0D]); + outSISIDXREG(pSiS->RelIO+0x14, 0x0C, sisReg->VBPart4[0x0C]); + + if (!(sisReg->sisRegs3D4[0x30] & 0x03) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + LockCRT2(pSiS->RelIO+0x30); + return; + } + SetBlock(pSiS->RelIO+0x04, 0x02, 0x23, &(sisReg->VBPart1[0x02])); + SetBlock(pSiS->RelIO+0x10, 0x00, 0x45, &(sisReg->VBPart2[0x00])); + SetBlock(pSiS->RelIO+0x12, 0x00, 0x3E, &(sisReg->VBPart3[0x00])); + SetBlock(pSiS->RelIO+0x14, 0x0E, 0x11, &(sisReg->VBPart4[0x0E])); + SetBlock(pSiS->RelIO+0x14, 0x13, 0x1B, &(sisReg->VBPart4[0x13])); + + outSISIDXREG(pSiS->RelIO+0x14, 0x0A, 1); + outSISIDXREG(pSiS->RelIO+0x14, 0x0B, sisReg->VBPart4[0x0B]); + outSISIDXREG(pSiS->RelIO+0x14, 0x0A, sisReg->VBPart4[0x0A]); + outSISIDXREG(pSiS->RelIO+0x14, 0x12, 0); + outSISIDXREG(pSiS->RelIO+0x14, 0x12, sisReg->VBPart4[0x12]); + + + temp1 = 0; + if(!(pSiS->VBFlags & CRT2_VGA)) { + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp); + if (temp & (SET_IN_SLAVE_MODE >> 8)) { + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, temp); + if (!(temp & (SET_CRT2_TO_RAMDAC >> 8))) { + temp1 = 0x20; + } + } + } + setSISIDXREG(pSiS->RelIO+SROFFSET, 0x32, ~0x20, temp1); + orSISIDXREG(pSiS->RelIO+SROFFSET, 0x1E, 0x20); + andSISIDXREG(pSiS->RelIO+SROFFSET, 1, ~0x20); /* DisplayOn */ + + EnableBridge(pSiS->RelIO+0x30); + LockCRT2(pSiS->RelIO+0x30); +} + +static void +SiSLVDSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - DisableBridge(pSiS->RelIO); - UnLockCRT2(pSiS->RelIO); + DisableBridge(pSiS->RelIO+0x30); + UnLockCRT2(pSiS->RelIO+0x30); + + /* SetCRT2ModeRegs() */ + outSISIDXREG(pSiS->RelIO+0x04, 4, 0); + outSISIDXREG(pSiS->RelIO+0x04, 5, 0); + outSISIDXREG(pSiS->RelIO+0x04, 6, 0); + outSISIDXREG(pSiS->RelIO+0x04, 0, sisReg->VBPart1[0]); + outSISIDXREG(pSiS->RelIO+0x04, 1, sisReg->VBPart1[1]); + + if (!(sisReg->sisRegs3D4[0x30] & 0x03) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + LockCRT2(pSiS->RelIO+0x30); + return; + } + SetBlock(pSiS->RelIO+0x04, 0x02, 0x23, &(sisReg->VBPart1[0x02])); + + orSISIDXREG(pSiS->RelIO+SROFFSET, 0x1E, 0x20); + andSISIDXREG(pSiS->RelIO+SROFFSET, 1, ~0x20); /* DisplayOn */ + + EnableBridge(pSiS->RelIO+0x30); + LockCRT2(pSiS->RelIO+0x30); +} - /* SetCRT2ModeRegs() */ - outSISIDXREG(pSiS->RelIO+0x04, 4, 0); - outSISIDXREG(pSiS->RelIO+0x04, 5, 0); - outSISIDXREG(pSiS->RelIO+0x04, 6, 0); - outSISIDXREG(pSiS->RelIO+0x04, 0, sisReg->VBPart1[0]); - outSISIDXREG(pSiS->RelIO+0x04, 1, sisReg->VBPart1[1]); - outSISIDXREG(pSiS->RelIO+0x14, 0x0D, sisReg->VBPart4[0x0D]); - outSISIDXREG(pSiS->RelIO+0x14, 0x0C, sisReg->VBPart4[0x0C]); - - if (!(sisReg->sisRegs3D4[0x30] & 0x03) && - (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ - LockCRT2(pSiS->RelIO); - return; +static void +SiSChrontelRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg) +{ + SISPtr pSiS = SISPTR(pScrn); + int i; + unsigned short wtemp; + + DisableBridge(pSiS->RelIO+0x30); + UnLockCRT2(pSiS->RelIO+0x30); + + for (i=0; i<0x11; i++) + { wtemp = ((sisReg->ch7005[i]) << 8) + (ch7005idx[i] & 0x00FF); + SetCH7005(wtemp); } - SetBlock(pSiS->RelIO+0x04, 0x02, 0x23, &(sisReg->VBPart1[0x02])); - SetBlock(pSiS->RelIO+0x10, 0x00, 0x45, &(sisReg->VBPart2[0x00])); - SetBlock(pSiS->RelIO+0x12, 0x00, 0x3E, &(sisReg->VBPart3[0x00])); - SetBlock(pSiS->RelIO+0x14, 0x0E, 0x11, &(sisReg->VBPart4[0x0E])); - SetBlock(pSiS->RelIO+0x14, 0x13, 0x1B, &(sisReg->VBPart4[0x13])); - - outSISIDXREG(pSiS->RelIO+0x14, 0x0A, 1); - outSISIDXREG(pSiS->RelIO+0x14, 0x0B, sisReg->VBPart4[0x0B]); - outSISIDXREG(pSiS->RelIO+0x14, 0x0A, sisReg->VBPart4[0x0A]); - outSISIDXREG(pSiS->RelIO+0x14, 0x12, 0); - outSISIDXREG(pSiS->RelIO+0x14, 0x12, sisReg->VBPart4[0x12]); + + /* SetCRT2ModeRegs() */ + outSISIDXREG(pSiS->RelIO+0x04, 4, 0); + outSISIDXREG(pSiS->RelIO+0x04, 5, 0); + outSISIDXREG(pSiS->RelIO+0x04, 6, 0); + outSISIDXREG(pSiS->RelIO+0x04, 0, sisReg->VBPart1[0]); + outSISIDXREG(pSiS->RelIO+0x04, 1, sisReg->VBPart1[1]); + + if (!(sisReg->sisRegs3D4[0x30] & 0x03) && + (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */ + LockCRT2(pSiS->RelIO+0x30); + return; + } + SetBlock(pSiS->RelIO+0x04, 0x02, 0x23, &(sisReg->VBPart1[0x02])); + + orSISIDXREG(pSiS->RelIO+SROFFSET, 0x1E, 0x20); + andSISIDXREG(pSiS->RelIO+SROFFSET, 1, ~0x20); /* DisplayOn */ - EnableBridge(pSiS->RelIO); - LockCRT2(pSiS->RelIO); + EnableBridge(pSiS->RelIO+0x30); + LockCRT2(pSiS->RelIO+0x30); } unsigned int @@ -624,57 +750,57 @@ case PCI_CHIP_SIS5597: case PCI_CHIP_SIS6326: case PCI_CHIP_SIS530: - read_xr(MemClock0,Num); - mclk=14318*((Num & 0x7f)+1); + read_xr(MemClock0,Num); + mclk=14318*((Num & 0x7f)+1); - /* Denumerator */ - read_xr(MemClock1,Denum); - mclk=mclk/((Denum & 0x1f)+1); - - /* Divider. Don't seems to work for mclk */ - if ( (Num & 0x80)!=0 ) { - mclk = mclk*2; - } + /* Denumerator */ + read_xr(MemClock1,Denum); + mclk=mclk/((Denum & 0x1f)+1); + + /* Divider. Don't seems to work for mclk */ + if ( (Num & 0x80)!=0 ) { + mclk = mclk*2; + } - /* Post-scaler. Values depends on SR13 bit 7 */ - outb(VGA_SEQ_INDEX, ClockBase); - Base = inb(VGA_SEQ_DATA); + /* Post-scaler. Values depends on SR13 bit 7 */ + outb(VGA_SEQ_INDEX, ClockBase); + Base = inb(VGA_SEQ_DATA); - if ( (Base & 0x80)==0 ) { - mclk = mclk / (((Denum & 0x60) >> 5)+1); - } - else { - /* Values 00 and 01 are reserved */ - if ((Denum & 0x60) == 0x40) { mclk=mclk/6; } - if ((Denum & 0x60) == 0x60) { mclk=mclk/8; } - } - break; + if ( (Base & 0x80)==0 ) { + mclk = mclk / (((Denum & 0x60) >> 5)+1); + } + else { + /* Values 00 and 01 are reserved */ + if ((Denum & 0x60) == 0x40) { mclk=mclk/6; } + if ((Denum & 0x60) == 0x60) { mclk=mclk/8; } + } + break; case PCI_CHIP_SIS300: case PCI_CHIP_SIS540: case PCI_CHIP_SIS630: - /* Numerator */ - read_xr(0x28, Num); - mclk = 14318*((Num &0x7f)+1); - - /* Denumerator */ - read_xr(0x29, Denum); - mclk = mclk/((Denum & 0x1f)+1); - - /* Divider */ - if ((Num & 0x80)!=0) { - mclk = mclk * 2; - } + /* Numerator */ + read_xr(0x28, Num); + mclk = 14318*((Num &0x7f)+1); + + /* Denumerator */ + read_xr(0x29, Denum); + mclk = mclk/((Denum & 0x1f)+1); + + /* Divider */ + if ((Num & 0x80)!=0) { + mclk = mclk * 2; + } - /* Post-Scaler */ - if ((Denum & 0x80)==0) { - mclk = mclk / (((Denum & 0x60) >> 5) + 1); - } - else { - mclk = mclk / ((((Denum & 0x60) >> 5) + 1) * 2); - } - break; + /* Post-Scaler */ + if ((Denum & 0x80)==0) { + mclk = mclk / (((Denum & 0x60) >> 5) + 1); + } + else { + mclk = mclk / ((((Denum & 0x60) >> 5) + 1) * 2); + } + break; default: - mclk = 0; + mclk = 0; } return(mclk); @@ -700,368 +826,307 @@ return(band); } -const float magic300[4] = { 1.2, 1.368421, 2.263158, 1.2}; -const float magic630[4] = { 1.441177, 1.441177, 2.588235, 1.441177 }; +const float magic300[4] = { 1.2, 1.368421, 2.263158, 1.2}; +const float magic630[4] = { 1.441177, 1.441177, 2.588235, 1.441177 }; int sis300MemBandWidth(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); - int bus = pSiS->BusWidth; - int mclk = pSiS->MemClock; - int bpp = pScrn->bitsPerPixel; - float magic, total; - - if (pSiS->Chipset==PCI_CHIP_SIS300) - magic = magic300[bus/64]; - else - magic = magic630[bus/64]; - - PDEBUG(ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n", - mclk, bus, magic, bpp)); - - total = mclk*bus/bpp; - ErrorF("Total Adapter Bandwidth is %gM\n", total/1000); - if (pSiS->VBFlags & CRT2_ENABLE) { - if (total/2 > 540000) - total = total - 540000; - else - total = total/2; - ErrorF("CRT1 Used Bandwidth is %gM\n", total/1000); - } + SISPtr pSiS = SISPTR(pScrn); + int bus = pSiS->BusWidth; + int mclk = pSiS->MemClock; + int bpp = pScrn->bitsPerPixel; + float magic, total; + + if (pSiS->Chipset==PCI_CHIP_SIS300) + magic = magic300[bus/64]; + else + magic = magic630[bus/64]; + + PDEBUG(ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n", + mclk, bus, magic, bpp)); + + total = mclk*bus/bpp; + ErrorF("Total Adapter Bandwidth is %gM\n", total/1000); + if (pSiS->VBFlags & CRT2_ENABLE) { + if (total/2 > 540000) + total = total - 540000; + else + total = total/2; + ErrorF("CRT1 Used Bandwidth is %gM\n", total/1000); + } - return (int)(total/magic); + return (int)(total/magic); } void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, - VisualPtr pVisual) + VisualPtr pVisual) { - SISPtr pSiS = SISPTR(pScrn); - int i, index; + SISPtr pSiS = SISPTR(pScrn); + int i, index; - PDEBUG(ErrorF("SISLoadPalette(%d)\n", numColors)); - for (i=0; i<numColors; i++) { - index = indicies[i]; - outSISREG(0x3c8, index); - outSISREG(0x3c9, colors[index].red >> 2); - outSISREG(0x3c9, colors[index].green >> 2); - outSISREG(0x3c9, colors[index].blue >> 2); - } - if (pSiS->VBFlags & CRT2_ENABLE) { - (*pSiS->LoadCRT2Palette)(pScrn, numColors, indicies, - colors, pVisual); - } + PDEBUG(ErrorF("SISLoadPalette(%d)\n", numColors)); + for (i=0; i<numColors; i++) { + index = indicies[i]; + /*outSISREG(0x3c8, index); + outSISREG(0x3c9, colors[index].red >> 2); + outSISREG(0x3c9, colors[index].green >> 2); + outSISREG(0x3c9, colors[index].blue >> 2);*/ + outSISREG(pSiS->RelIO+0x48, index); + outSISREG(pSiS->RelIO+0x49, colors[index].red >> 2); + outSISREG(pSiS->RelIO+0x49, colors[index].green >> 2); + outSISREG(pSiS->RelIO+0x49, colors[index].blue >> 2); + } + if (pSiS->VBFlags & CRT2_ENABLE) { + (*pSiS->LoadCRT2Palette)(pScrn, numColors, indicies, + colors, pVisual); + } } -static void +static void SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, - LOCO *colors, VisualPtr pVisual) + LOCO *colors, VisualPtr pVisual) { - SISPtr pSiS = SISPTR(pScrn); - int i, index; + SISPtr pSiS = SISPTR(pScrn); + int i, index; - PDEBUG(ErrorF("SiS301LoadPalette(%d)\n", numColors)); - for (i=0; i<numColors; i++) { - index = indicies[i]; - outSISREG(pSiS->RelIO+0x16, index); - outSISREG(pSiS->RelIO+0x17, colors[index].red); - outSISREG(pSiS->RelIO+0x17, colors[index].green); - outSISREG(pSiS->RelIO+0x17, colors[index].blue); - } + PDEBUG(ErrorF("SiS301LoadPalette(%d)\n", numColors)); + for (i=0; i<numColors; i++) { + index = indicies[i]; + outSISREG(pSiS->RelIO+0x16, index); + outSISREG(pSiS->RelIO+0x17, colors[index].red); + outSISREG(pSiS->RelIO+0x17, colors[index].green); + outSISREG(pSiS->RelIO+0x17, colors[index].blue); + } } struct QConfig { - int GT; - int QC; + int GT; + int QC; }; -static struct QConfig qconfig[20] = { - {1, 0x0}, {1, 0x2}, {1, 0x4}, {1, 0x6}, {1, 0x8}, - {1, 0x3}, {1, 0x5}, {1, 0x7}, {1, 0x9}, {1, 0xb}, - {0, 0x0}, {0, 0x2}, {0, 0x4}, {0, 0x6}, {0, 0x8}, - {0, 0x3}, {0, 0x5}, {0, 0x7}, {0, 0x9}, {0, 0xb}}; - -static int cycleA[20][2] = { - {88,88}, {80,80}, {78,78}, {72,72}, {70,70}, - {79,72}, {77,70}, {71,64}, {69,62}, {49,44}, - {73,78}, {65,70}, {63,68}, {57,62}, {55,60}, - {64,62}, {62,60}, {56,54}, {54,52}, {34,34}}; +static struct QConfig qconfig[20] = { + {1, 0x0}, {1, 0x2}, {1, 0x4}, {1, 0x6}, {1, 0x8}, + {1, 0x3}, {1, 0x5}, {1, 0x7}, {1, 0x9}, {1, 0xb}, + {0, 0x0}, {0, 0x2}, {0, 0x4}, {0, 0x6}, {0, 0x8}, + {0, 0x3}, {0, 0x5}, {0, 0x7}, {0, 0x9}, {0, 0xb}}; + +static int cycleA[20][2] = { + {88,88}, {80,80}, {78,78}, {72,72}, {70,70}, + {79,72}, {77,70}, {71,64}, {69,62}, {49,44}, + {73,78}, {65,70}, {63,68}, {57,62}, {55,60}, + {64,62}, {62,60}, {56,54}, {54,52}, {34,34}}; -static void +static void SiS630Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) + unsigned short *Low, unsigned short *High) { - SISPtr pSiS = SISPTR(pScrn); - int mclk = pSiS->MemClock; - int vclk = mode->Clock; - int bpp = pScrn->bitsPerPixel/8; - int buswidth = pSiS->BusWidth; - CARD32 temp; - PCITAG NBridge; - int cyclea; - int low, lowa; - - int i, j; - - - if (!bpp) bpp = 1; - - i = 0; - j = buswidth/128; - - while (1) { -#ifdef DEBUG - ErrorF("Config %d GT = %d, QC = %x, CycleA = %d\n", - i, qconfig[i].GT, qconfig[i].QC, cycleA[i][j]); + SISPtr pSiS = SISPTR(pScrn); + int mclk = pSiS->MemClock; + int vclk = mode->Clock; + int bpp = pScrn->bitsPerPixel/8; + int buswidth = pSiS->BusWidth; + CARD32 temp; + PCITAG NBridge; + int cyclea; + int low, lowa; + + int i, j; + + + if (!bpp) bpp = 1; + + i = 0; + j = buswidth/128; + + while (1) { +#ifdef DEBUG + ErrorF("Config %d GT = %d, QC = %x, CycleA = %d\n", + i, qconfig[i].GT, qconfig[i].QC, cycleA[i][j]); #endif - cyclea = cycleA[i][j]; - lowa = cyclea * vclk * bpp; - lowa = (lowa + (mclk-1)) / mclk; - lowa = (lowa + 15) / 16; - low = lowa + 1; - if (low <= 0x13) - break; - else - if (i < 19) - i++; - else { - low = 0x13; - PDEBUG(ErrorF("This mode may has threshold " - "problem and had better removed\n")); - break; - } - } - PDEBUG(ErrorF("Using Config %d with CycleA = %d\n", i, cyclea)); - *Low = low; - if (lowa+4 > 15) - *High = 0x0F; - else - *High = lowa+4; - - /* write PCI configuration space */ - NBridge = pciTag(0, 0, 0); - temp = pciReadLong(NBridge, 0x50); - temp &= 0xF0FFFFFF; - temp |= qconfig[i].QC << 24; - pciWriteLong(NBridge, 0x50, temp); - - temp = pciReadLong(NBridge, 0xA0); - temp &= 0xF0FFFFFF; - temp |= qconfig[i].GT << 24; - pciWriteLong(NBridge, 0xA0, temp); + cyclea = cycleA[i][j]; + lowa = cyclea * vclk * bpp; + lowa = (lowa + (mclk-1)) / mclk; + lowa = (lowa + 15) / 16; + low = lowa + 1; + if (low <= 0x13) + break; + else + if (i < 19) + i++; + else { + low = 0x13; + PDEBUG(ErrorF("This mode may has threshold " + "problem and had better removed\n")); + break; + } + } + PDEBUG(ErrorF("Using Config %d with CycleA = %d\n", i, cyclea)); + *Low = low; + if (lowa+4 > 15) + *High = 0x0F; + else + *High = lowa+4; + + /* write PCI configuration space */ + NBridge = pciTag(0, 0, 0); + temp = pciReadLong(NBridge, 0x50); + temp &= 0xF0FFFFFF; + temp |= qconfig[i].QC << 24; + pciWriteLong(NBridge, 0x50, temp); + + temp = pciReadLong(NBridge, 0xA0); + temp &= 0xF0FFFFFF; + temp |= qconfig[i].GT << 24; + pciWriteLong(NBridge, 0xA0, temp); } struct funcargc { - char base; - char inc; + char base; + char inc; }; -static struct funcargc funca[12] = { - {61, 3}, {52, 5}, {68, 7}, {100, 11}, - {43, 3}, {42, 5}, {54, 7}, {78, 11}, - {34, 3}, {37, 5}, {47, 7}, {67, 11}}; -static struct funcargc funcb[12] = { - {81, 4}, {72, 6}, {88, 8}, {120, 12}, - {55, 4}, {54, 6}, {66, 8}, {90, 12}, - {42, 4}, {45, 6}, {55, 8}, {75, 12}}; -static char timing[8] = {1, 2, 2, 3, 0, 1, 1, 2}; +static struct funcargc funca[12] = { + {61, 3}, {52, 5}, {68, 7}, {100, 11}, + {43, 3}, {42, 5}, {54, 7}, {78, 11}, + {34, 3}, {37, 5}, {47, 7}, {67, 11}}; +static struct funcargc funcb[12] = { + {81, 4}, {72, 6}, {88, 8}, {120, 12}, + {55, 4}, {54, 6}, {66, 8}, {90, 12}, + {42, 4}, {45, 6}, {55, 8}, {75, 12}}; +static char timing[8] = {1, 2, 2, 3, 0, 1, 1, 2}; -static void +static void SiS300Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) + unsigned short *Low, unsigned short *High) { - SISPtr pSiS = SISPTR(pScrn); - SISRegPtr pReg = &pSiS->ModeReg; - int mclk = pSiS->MemClock; - int vclk = mode->Clock; - int bpp = pScrn->bitsPerPixel/8; - int lowa, lowb, low; - struct funcargc *p; - unsigned int i, j; - - pReg->sisRegs3C4[0x16] = pSiS->SavedReg.sisRegs3C4[0x16]; - - if (!bpp) bpp = 1; - - do { - i = GETBITSTR(pReg->sisRegs3C4[0x18], 6:5, 2:1) | - GETBITS(pReg->sisRegs3C4[0x18], 1:1); - j = GETBITSTR(pReg->sisRegs3C4[0x14], 7:6, 3:2) | - GETBITS(pReg->sisRegs3C4[0x16], 7:6); - p = &funca[j]; - - lowa = (p->base + p->inc*timing[i])*vclk*bpp; - lowa = (lowa + (mclk-1)) / mclk; - lowa = (lowa + 15)/16; - - p = &funcb[j]; - lowb = (p->base + p->inc*timing[i])*vclk*bpp; - lowb = (lowb + (mclk-1)) / mclk; - lowb = (lowb + 15)/16; - - if (lowb < 4) - lowb = 0; - else - lowb -= 4; - - low = (lowa > lowb)? lowa: lowb; - - low++; - - if (low <= 0x13) { - break; - } else { - i = GETBITS(pReg->sisRegs3C4[0x16], 7:6); - if (!i) { - low = 0x13; - break; - } else { - i--; - pReg->sisRegs3C4[0x16] &= 0x3C; - pReg->sisRegs3C4[0x16] |= (i << 6); - } - } - } while (1); - - *Low = low; - if (low+3 > 15) - *High = 0x0F; - else - *High = low+3; -} - -static void -SiS301Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) -{ - SISPtr pSiS = SISPTR(pScrn); - SISRegPtr sisReg = &pSiS->ModeReg; - unsigned int delay; - unsigned int mclk = pSiS->MemClock/1000; - unsigned int dclk = mode->Clock/1000; - unsigned int buswidth = pSiS->BusWidth/8; - unsigned int bpp = (pScrn->bitsPerPixel+7)/8; - unsigned int tclk; - int i, GT, QC, idx, timing_idx, CRT1RP; - int Num, DeNum, PostScale, Div; /* for clock gen */ - PCITAG NBridge; - - /* Get Delay */ - if (pSiS->Chipset == PCI_CHIP_SIS300) { - idx = GETBITS(sisReg->sisRegs3C4[0x16], 7:6) | - GETBITSTR(sisReg->sisRegs3C4[0x14], 7:6, 3:2); - timing_idx = GETBITS(sisReg->sisRegs3C4[0x18], 0:0) | - GETBITSTR(sisReg->sisRegs3C4[0x18], 6:5, 2:1); - delay = funcb[idx].base + funcb[idx].inc * timing[timing_idx]; - } else { - NBridge = pciTag(0,0,0); - QC = GETBITS(pciReadLong(NBridge, 0x50), 27:24); - GT = GETBITS(pciReadLong(NBridge, 0xA0), 27:24); - for (i=0; i<20; i++) { - if ((qconfig[i].QC == QC) && (qconfig[i].GT==GT)) - break; - } - if (buswidth == 8) /* 64-bits */ - delay = cycleA[i][0]+20; - else - delay = cycleA[i][1]+15; - } - /* Get TCLK */ - Num = GETBITS(sisReg->VBPart4[0x0A], 6:0); - DeNum = GETBITS(sisReg->VBPart4[0x0B], 4:0); - PostScale = GETBITS(sisReg->VBPart4[0x0B], 7:5); - Div = GETBITS(sisReg->VBPart4[0x0A], 7:7); - tclk = GetClock(Num, DeNum, PostScale, Div); - - CRT1RP = delay + - (int)(28*16/(buswidth - 1.0*dclk*bpp/mclk) + 0.9999); - *Low = 1.0*CRT1RP*tclk*bpp/(16*mclk) + 0.9999; /* Roundup */ - - if (*Low < 6) *Low = 6; - if (*Low > 0x14) *Low = 0x14; - - *High = 0x16; - if (pSiS->Chipset == PCI_CHIP_SIS300) { - if (*Low <= 0x0F) - *High = 0x13; - } + SISPtr pSiS = SISPTR(pScrn); + SISRegPtr pReg = &pSiS->ModeReg; + int mclk = pSiS->MemClock; + int vclk = mode->Clock; + int bpp = pScrn->bitsPerPixel/8; + int lowa, lowb, low; + struct funcargc *p; + unsigned int i, j; + + pReg->sisRegs3C4[0x16] = pSiS->SavedReg.sisRegs3C4[0x16]; + + if (!bpp) bpp = 1; + + do { + i = GETBITSTR(pReg->sisRegs3C4[0x18], 6:5, 2:1) | + GETBITS(pReg->sisRegs3C4[0x18], 1:1); + j = GETBITSTR(pReg->sisRegs3C4[0x14], 7:6, 3:2) | + GETBITS(pReg->sisRegs3C4[0x16], 7:6); + p = &funca[j]; + + lowa = (p->base + p->inc*timing[i])*vclk*bpp; + lowa = (lowa + (mclk-1)) / mclk; + lowa = (lowa + 15)/16; + + p = &funcb[j]; + lowb = (p->base + p->inc*timing[i])*vclk*bpp; + lowb = (lowb + (mclk-1)) / mclk; + lowb = (lowb + 15)/16; + + if (lowb < 4) + lowb = 0; + else + lowb -= 4; + + low = (lowa > lowb)? lowa: lowb; + + low++; + + if (low <= 0x13) { + break; + } else { + i = GETBITS(pReg->sisRegs3C4[0x16], 7:6); + if (!i) { + low = 0x13; + break; + } else { + i--; + pReg->sisRegs3C4[0x16] &= 0x3C; + pReg->sisRegs3C4[0x16] |= (i << 6); + } + } + } while (1); + + *Low = low; + if (low+3 > 15) + *High = 0x0F; + else + *High = low+3; } -static void +static void SiS530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) + unsigned short *Low, unsigned short *High) { - SISPtr pSiS = SISPTR(pScrn); - unsigned int factor, z; - unsigned int vclk = mode->Clock, - bpp = pScrn->bitsPerPixel, - mclk = pSiS->MemClock, - buswidth = pSiS->BusWidth; - - if (pSiS->Flags & UMA) - factor = 0x60; - else - factor = 0x30; - z = factor * vclk * bpp; - z = z / mclk / buswidth; - *Low = (z+1)/2 + 4; - if (*Low > 0x1F) - *Low = 0x1F; + SISPtr pSiS = SISPTR(pScrn); + unsigned int factor, z; + unsigned int vclk = mode->Clock, + bpp = pScrn->bitsPerPixel, + mclk = pSiS->MemClock, + buswidth = pSiS->BusWidth; + + if (pSiS->Flags & UMA) + factor = 0x60; + else + factor = 0x30; + z = factor * vclk * bpp; + z = z / mclk / buswidth; + *Low = (z+1)/2 + 4; + if (*Low > 0x1F) + *Low = 0x1F; - *High = 0x1F; + *High = 0x1F; } -static void +static void SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode, - unsigned short *Low, unsigned short *High) + unsigned short *Low, unsigned short *High) { } -static unsigned int -GetClock(int Num, int DeNum, int PostScale, int Div) -{ - Num++; - DeNum++; - Div++; - PostScale = (GETBITS(PostScale, 1:0)+1) * (GETBITS(PostScale, 2:2)+1); - return 14318.18*Num*Div/(DeNum*PostScale); -} - void SiSIODump(ScrnInfoPtr pScrn) -{ SISPtr pSiS = SISPTR(pScrn); - int i, max3c4, min3d4, max3d4; - int SR5State; - unsigned char temp; +{ SISPtr pSiS = SISPTR(pScrn); + int i, max3c4, min3d4, max3d4; + int SR5State; + unsigned char temp; switch (pSiS->Chipset) { - case PCI_CHIP_SIS6326: - max3c4 = 0x3F; - max3d4 = 0x19; - min3d4 = 0x26; - break; - case PCI_CHIP_SIS530: - max3c4 = 0x3F; - max3d4 = 0x19; - min3d4 = 0x26; - break; - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - max3c4 = 0x3D; - max3d4 = 0x37; - min3d4 = 0x30; - break; - default: - max3c4 = 0x38; - max3d4 = 0x19; - min3d4 = 0x26; + case PCI_CHIP_SIS6326: + max3c4 = 0x3F; + max3d4 = 0x19; + min3d4 = 0x26; + break; + case PCI_CHIP_SIS530: + max3c4 = 0x3F; + max3d4 = 0x19; + min3d4 = 0x26; + break; + case PCI_CHIP_SIS300: + case PCI_CHIP_SIS630: + case PCI_CHIP_SIS540: + max3c4 = 0x3D; + max3d4 = 0x37; + min3d4 = 0x30; + break; + default: + max3c4 = 0x38; + max3d4 = 0x19; + min3d4 = 0x26; } /* dump Misc Registers */ - temp = inb(0x3CC); + /*temp = inb(0x3CC);*/ + temp = inb(pSiS->RelIO+0x4c); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Misc Output 3CC=%x\n", temp); - temp = inb(0x3CA); + /*temp = inb(0x3CA);*/ + temp = inb(pSiS->RelIO+0x4a); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Feature Control 3CA=%x\n", temp); /* Dump GR */ @@ -1069,9 +1134,11 @@ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3CE\n"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); for (i=0; i<=8; i++) { - outb(0x3ce, i); - temp = inb(0x3cf); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); + /*outb(0x3ce, i); + temp = inb(0x3cf);*/ + outb(pSiS->RelIO+0x4e, i); + temp = inb(pSiS->RelIO+0x4f); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); } /* dump SR0 ~ SR4 */ @@ -1079,20 +1146,27 @@ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3C4\n"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); for (i=0; i<=4; i++) { - outb(0x3c4, i); - temp = inb(0x3c5); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); + /*outb(0x3c4, i); + temp = inb(0x3c5);*/ + outb(pSiS->RelIO+0x44, i); + temp = inb(pSiS->RelIO+0x45); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); } /* dump extended SR */ - outb(0x3c4, 5); - SR5State = inb(0x3c5); + /*outb(0x3c4, 5); + SR5State = inb(0x3c5);*/ + outb(pSiS->RelIO+0x44, 5); + SR5State = inb(pSiS->RelIO+0x45); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[05]=%2x\n", SR5State); - outw(0x3c4, 0x8605); + /*outw(0x3c4, 0x8605);*/ + outw(pSiS->RelIO+0x44, 0x8605); for (i=6; i<=max3c4; i++) { - outb(0x3c4, i); - temp = inb(0x3c5); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); + /*outb(0x3c4, i); + temp = inb(0x3c5);*/ + outb(pSiS->RelIO+0x44, i); + temp = inb(pSiS->RelIO+0x45); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); } /* dump CR0 ~ CR18 */ @@ -1100,61 +1174,78 @@ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Registers 3D4\n"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "-------------\n"); for (i=0; i<=0x18; i++) { - outb(0x3d4, i); - temp = inb(0x3d5); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); + outb(0x3d4, i); + temp = inb(0x3d5); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); } - for (i=min3d4; i<=max3d4; i++) { /* dump extended CR */ - outb(0x3d4, i); - temp = inb(0x3d5); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); + for (i=min3d4; i<=max3d4; i++) { /* dump extended CR */ + outb(0x3d4, i); + temp = inb(0x3d5); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[%2x]=%2x\n", i, temp); } - outw(0x3c4, SR5State << 8 | 0x05); + /*outw(0x3c4, SR5State << 8 | 0x05);*/ + outw(pSiS->RelIO+0x44, SR5State << 8 | 0x05); } void SISDACPreInit(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); + SISPtr pSiS = SISPTR(pScrn); - switch (pSiS->Chipset) { - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - pSiS->MaxClock = sis300MemBandWidth(pScrn); - pSiS->SiSSave = SiS300Save; - pSiS->SiSSave2 = SiS301Save; - pSiS->SiSRestore = SiS300Restore; - pSiS->SiSRestore2 = SiS301Restore; - pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiS630Threshold; - pSiS->SetThreshold2 = SiS301Threshold; - break; - case PCI_CHIP_SIS300: - pSiS->MaxClock = sis300MemBandWidth(pScrn); - pSiS->SiSSave = SiS300Save; - pSiS->SiSSave2 = SiS301Save; - pSiS->SiSRestore = SiS300Restore; - pSiS->SiSRestore2 = SiS301Restore; - pSiS->LoadCRT2Palette = SiS301LoadPalette; - pSiS->SetThreshold = SiS300Threshold; - pSiS->SetThreshold2 = SiS301Threshold; - break; - case PCI_CHIP_SIS530: - pSiS->MaxClock = 230000; /* Guest */ - pSiS->SiSRestore = SiSRestore; - pSiS->SiSSave = SiSSave; - pSiS->SetThreshold = SiS530Threshold; - break; - case PCI_CHIP_SIS6326: - pSiS->MaxClock = 175000; /* Guest */ - pSiS->SiSRestore = SiSRestore; - pSiS->SiSSave = SiSSave; - pSiS->SetThreshold = SiSThreshold; - break; - default: - pSiS->MaxClock = 135000; /* Guest */ - pSiS->SiSRestore = SiSRestore; - pSiS->SiSSave = SiSSave; - pSiS->SetThreshold = SiSThreshold; - } + switch (pSiS->Chipset) { + case PCI_CHIP_SIS630: + case PCI_CHIP_SIS540: + pSiS->MaxClock = sis300MemBandWidth(pScrn); + pSiS->SiSSave = SiS300Save; + pSiS->SiSSave2 = SiS301Save; + pSiS->SiSSaveLVDS = SiSLVDSSave; + pSiS->SiSSaveChrontel = SiSChrontelSave; + pSiS->SiSRestore = SiS300Restore; + pSiS->SiSRestore2 = SiS301Restore; + pSiS->SiSRestoreLVDS = SiSLVDSRestore; + pSiS->SiSRestoreChrontel= SiSChrontelRestore; + pSiS->LoadCRT2Palette = SiS301LoadPalette; + pSiS->SetThreshold = SiS630Threshold; + break; + case PCI_CHIP_SIS300: + pSiS->MaxClock = sis300MemBandWidth(pScrn); + pSiS->SiSSave = SiS300Save; + pSiS->SiSSave2 = SiS301Save; + pSiS->SiSSaveLVDS = SiSLVDSSave; + pSiS->SiSSaveChrontel = SiSChrontelSave; + pSiS->SiSRestore = SiS300Restore; + pSiS->SiSRestore2 = SiS301Restore; + pSiS->SiSRestoreLVDS = SiSLVDSRestore; + pSiS->SiSRestoreChrontel= SiSChrontelRestore; + pSiS->LoadCRT2Palette = SiS301LoadPalette; + pSiS->SetThreshold = SiS300Threshold; + break; + case PCI_CHIP_SIS530: + pSiS->MaxClock = 230000; /* Guest */ + pSiS->SiSRestore = SiSRestore; + pSiS->SiSSave = SiSSave; + pSiS->SetThreshold = SiS530Threshold; + break; + case PCI_CHIP_SIS6326: + pSiS->MaxClock = 175000; /* Guest */ + pSiS->SiSRestore = SiSRestore; + pSiS->SiSSave = SiSSave; + pSiS->SetThreshold = SiSThreshold; + break; + default: + pSiS->MaxClock = 135000; /* Guest */ + pSiS->SiSRestore = SiSRestore; + pSiS->SiSSave = SiSSave; + pSiS->SetThreshold = SiSThreshold; + } +} + +void +SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr) +{ + CARD8 index; + + for (index=from; index <= to; index++, DataPtr++) { + outSISIDXREG(port, index, *DataPtr); + } } Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c:1.8 --- /dev/null Mon Dec 18 14:31:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c Fri Dec 1 20:16:17 2000 @@ -0,0 +1,529 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.8 2000/12/02 01:16:17 dawes Exp $ */ + +/* modified from tdfx_dri.c, mga_dri.c */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Priv.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "fb.h" + +#include "miline.h" + +#include "GL/glxtokens.h" + +#include "sis.h" +#include "sis_dri.h" + +#include "sis300_accel.h" + +extern void GlxSetVisualConfigs( + int nconfigs, + __GLXvisualConfig *configs, + void **configprivs +); + +#define AGP_PAGE_SIZE 4096 +#define AGP_PAGES 2048 +#define AGP_SIZE (AGP_PAGE_SIZE * AGP_PAGES) +#define AGP_CMDBUF_PAGES 256 +#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES) + +static char SISKernelDriverName[] = "sis"; +static char SISClientDriverName[] = "sis"; + +static Bool SISInitVisualConfigs(ScreenPtr pScreen); +static Bool SISCreateContext(ScreenPtr pScreen, VisualPtr visual, + drmContext hwContext, void *pVisualConfigPriv, + DRIContextType contextStore); +static void SISDestroyContext(ScreenPtr pScreen, drmContext hwContext, + DRIContextType contextStore); +static void SISDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); +static void SISDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); +static void SISDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, + RegionPtr prgnSrc, CARD32 index); + +void SISLostContext(ScreenPtr pScreen); + +static Bool +SISInitVisualConfigs(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSIS = SISPTR(pScrn); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = 0; + SISConfigPrivPtr pSISConfigs = 0; + SISConfigPrivPtr *pSISConfigPtrs = 0; + int i, db, z_stencil, accum; + Bool useZ16 = FALSE; + + if(getenv("SIS_FORCE_Z16")){ + useZ16 = TRUE; + } + + switch (pScrn->bitsPerPixel) { + case 8: + case 24: + break; + case 16: + case 32: + numConfigs = (useZ16)?8:16; + + if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pSISConfigs = (SISConfigPrivPtr)xnfcalloc(sizeof(SISConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pSISConfigPtrs = (SISConfigPrivPtr*)xnfcalloc(sizeof(SISConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pSISConfigs); + return FALSE; + } + for (i=0; i<numConfigs; i++) + pSISConfigPtrs[i] = &pSISConfigs[i]; + + i = 0; + for (accum = 0; accum <= 1; accum++) { + for (z_stencil=0; z_stencil<(useZ16?2:4); z_stencil++) { + for (db = 0; db <= 1; db++) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = -1; + pConfigs[i].greenSize = -1; + pConfigs[i].blueSize = -1; + pConfigs[i].redMask = -1; + pConfigs[i].greenMask = -1; + pConfigs[i].blueMask = -1; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 16; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = -1; + switch (z_stencil){ + case 0: + pConfigs[i].depthSize = 0; + pConfigs[i].stencilSize = 0; + break; + case 1: + pConfigs[i].depthSize = 16; + pConfigs[i].stencilSize = 0; + break; + case 2: + pConfigs[i].depthSize = 32; + pConfigs[i].stencilSize = 0; + break; + case 3: + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + break; + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + if (i != numConfigs) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Incorrect initialization of visuals\n"); + return FALSE; + } + break; + } + + pSIS->numVisualConfigs = numConfigs; + pSIS->pVisualConfigs = pConfigs; + pSIS->pVisualConfigsPriv = pSISConfigs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pSISConfigPtrs); + + return TRUE; +} + +Bool SISDRIScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSIS = SISPTR(pScrn); + DRIInfoPtr pDRIInfo; + SISDRIPtr pSISDRI; + + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for canonical symbols in each module. */ + if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE; + if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; + if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "SISDRIScreenInit failed (libdri.a too old)\n"); + return FALSE; + } + + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] SISDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } + + pDRIInfo = DRICreateInfoRec(); + if (!pDRIInfo) return FALSE; + pSIS->pDRIInfo = pDRIInfo; + + pDRIInfo->drmDriverName = SISKernelDriverName; + pDRIInfo->clientDriverName = SISClientDriverName; + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", + ((pciConfigPtr)pSIS->PciInfo->thisCard)->busnum, + ((pciConfigPtr)pSIS->PciInfo->thisCard)->devnum, + ((pciConfigPtr)pSIS->PciInfo->thisCard)->funcnum); + pDRIInfo->ddxDriverMajorVersion = 0; + pDRIInfo->ddxDriverMinorVersion = 1; + pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->frameBufferPhysicalAddress = pSIS->FbAddress; + pDRIInfo->frameBufferSize = pSIS->FbMapSize; + + /* ?? */ + pDRIInfo->frameBufferStride = pSIS->scrnOffset; + pDRIInfo->ddxDrawableTableEntry = SIS_MAX_DRAWABLES; + + if (SAREA_MAX_DRAWABLES < SIS_MAX_DRAWABLES) + pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; + else + pDRIInfo->maxDrawableTableEntry = SIS_MAX_DRAWABLES; + +#ifdef NOT_DONE + /* FIXME need to extend DRI protocol to pass this size back to client + * for SAREA mapping that includes a device private record + */ + pDRIInfo->SAREASize = + ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ + /* + shared memory device private rec */ +#else + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + if (sizeof(XF86DRISAREARec)+sizeof(SISSAREAPriv)>SAREA_MAX) { + ErrorF("Data does not fit in SAREA\n"); + return FALSE; + } + pDRIInfo->SAREASize = SAREA_MAX; +#endif + + if (!(pSISDRI = (SISDRIPtr)xnfcalloc(sizeof(SISDRIRec),1))) { + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo=0; + return FALSE; + } + pDRIInfo->devPrivate = pSISDRI; + pDRIInfo->devPrivateSize = sizeof(SISDRIRec); + pDRIInfo->contextSize = sizeof(SISDRIContextRec); + + pDRIInfo->CreateContext = SISCreateContext; + pDRIInfo->DestroyContext = SISDestroyContext; + pDRIInfo->SwapContext = SISDRISwapContext; + pDRIInfo->InitBuffers = SISDRIInitBuffers; + pDRIInfo->MoveBuffers = SISDRIMoveBuffers; + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + + if (!DRIScreenInit(pScreen, pDRIInfo, &pSIS->drmSubFD)) { + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate=0; + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo=0; + pSIS->drmSubFD = -1; + return FALSE; + } + + pSISDRI->regs.size = SISIOMAPSIZE; + pSISDRI->regs.map = 0; + if (drmAddMap(pSIS->drmSubFD, (drmHandle)pSIS->IOAddress, + pSISDRI->regs.size, DRM_REGISTERS, 0, + &pSISDRI->regs.handle)<0) + { + SISDRICloseScreen(pScreen); + return FALSE; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", + pSISDRI->regs.handle); + + /* AGP */ + do{ + pSIS->agpSize = 0; + pSIS->agpCmdBufSize = 0; + pSISDRI->AGPCmdBufSize = 0; + + if (drmAgpAcquire(pSIS->drmSubFD) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed\n"); + break; + } + + /* TODO: default value is 2x? */ + if (drmAgpEnable(pSIS->drmSubFD, drmAgpGetMode(pSIS->drmSubFD)&~0x0) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); + break; + } + ErrorF("[drm] drmAgpEnabled succeeded\n"); + + if (drmAgpAlloc(pSIS->drmSubFD, AGP_SIZE, 0, NULL, &pSIS->agpHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAgpAlloc failed\n"); + drmAgpRelease(pSIS->drmSubFD); + break; + } + + if (drmAgpBind(pSIS->drmSubFD, pSIS->agpHandle, 0) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAgpBind failed\n"); + drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); + drmAgpRelease(pSIS->drmSubFD); + + break; + } + + pSIS->agpSize = AGP_SIZE; + pSIS->agpAddr = drmAgpBase(pSIS->drmSubFD); + /* pSIS->agpBase = */ + + pSISDRI->agp.size = pSIS->agpSize; + if (drmAddMap(pSIS->drmSubFD, (drmHandle)0, + pSISDRI->agp.size, DRM_AGP, 0, + &pSISDRI->agp.handle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to map public agp area\n"); + pSISDRI->agp.size = 0; + break; + } + + pSIS->agpCmdBufSize = AGP_CMDBUF_SIZE; + pSIS->agpCmdBufAddr = pSIS->agpAddr; + pSIS->agpCmdBufBase = pSIS->agpCmdBufAddr - pSIS->agpAddr + + pSIS->agpBase; + pSIS->agpCmdBufFree = 0; + + pSISDRI->AGPCmdBufOffset = pSIS->agpCmdBufAddr - pSIS->agpAddr; + pSISDRI->AGPCmdBufSize = pSIS->agpCmdBufSize; + + drmSiSAgpInit(pSIS->drmSubFD, AGP_CMDBUF_SIZE,(AGP_SIZE - AGP_CMDBUF_SIZE)); + } + while(0); + + /* enable IRQ */ + pSIS->irq = drmGetInterruptFromBusID(pSIS->drmSubFD, + ((pciConfigPtr)pSIS->PciInfo->thisCard)->busnum, + ((pciConfigPtr)pSIS->PciInfo->thisCard)->devnum, + ((pciConfigPtr)pSIS->PciInfo->thisCard)->funcnum); + + if((drmCtlInstHandler(pSIS->drmSubFD, pSIS->irq)) != 0) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] failure adding irq %d handler, stereo disabled\n", + pSIS->irq); + pSIS->irqEnabled = FALSE; + } + else + { + pSIS->irqEnabled = TRUE; + } + + pSISDRI->irqEnabled = pSIS->irqEnabled; + + if (!(SISInitVisualConfigs(pScreen))) { + SISDRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" ); + + return TRUE; +} + +void +SISDRICloseScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSIS = SISPTR(pScrn); + + DRICloseScreen(pScreen); + + if (pSIS->pDRIInfo) { + if (pSIS->pDRIInfo->devPrivate) { + xfree(pSIS->pDRIInfo->devPrivate); + pSIS->pDRIInfo->devPrivate=0; + } + DRIDestroyInfoRec(pSIS->pDRIInfo); + pSIS->pDRIInfo=0; + } + if (pSIS->pVisualConfigs) xfree(pSIS->pVisualConfigs); + if (pSIS->pVisualConfigsPriv) xfree(pSIS->pVisualConfigsPriv); + + if(pSIS->agpSize){ + ErrorF("Freeing agp memory\n"); + drmAgpFree(pSIS->drmSubFD, pSIS->agpHandle); + ErrorF("releasing agp module\n"); + drmAgpRelease(pSIS->drmSubFD); + } +} + +/* TODO: xserver receives driver's swapping event and do something + * according the data initialized in this function + */ +static Bool +SISCreateContext(ScreenPtr pScreen, VisualPtr visual, + drmContext hwContext, void *pVisualConfigPriv, + DRIContextType contextStore) +{ + return TRUE; +} + +static void +SISDestroyContext(ScreenPtr pScreen, drmContext hwContext, + DRIContextType contextStore) +{ +} + +Bool +SISDRIFinishScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSiS = SISPTR(pScrn); + SISDRIPtr pSISDRI; + + pSiS->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; + /* pSiS->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ + + pSISDRI=(SISDRIPtr)pSiS->pDRIInfo->devPrivate; + pSISDRI->deviceID=pSiS->Chipset; + pSISDRI->width=pScrn->virtualX; + pSISDRI->height=pScrn->virtualY; + pSISDRI->mem=pScrn->videoRam*1024; + pSISDRI->bytesPerPixel= (pScrn->bitsPerPixel+7) / 8; + /* TODO */ + pSISDRI->scrnX=pSISDRI->width; + pSISDRI->scrnY=pSISDRI->height; + +/* + pSISDRI->textureOffset=pSiS->texOffset; + pSISDRI->textureSize=pSiS->texSize; + pSISDRI->fbOffset=pSiS->fbOffset; + pSISDRI->backOffset=pSiS->backOffset; + pSISDRI->depthOffset=pSiS->depthOffset; +*/ + + /* set SAREA value */ + { + SISSAREAPriv *saPriv; + + saPriv=(SISSAREAPriv*)DRIGetSAREAPrivate(pScreen); + + assert(saPriv); + + saPriv->CtxOwner = -1; + saPriv->QueueLength = 0; + pSiS->cmdQueueLenPtr = &(saPriv->QueueLength); + saPriv->AGPCmdBufNext = 0; + + /* frame control */ + saPriv->FrameCount = 0; + *(unsigned long *)(pSiS->IOBase+0x8a2c) = 0; + SiSIdle + } + + return DRIFinishScreenInit(pScreen); +} + +static void +SISDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSIS = SISPTR(pScrn); + +#if 0 + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ + SISSwapContextPrivate(pScreen); + } + if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ + SISLostContext(pScreen); + } +#endif + + /* mEndPrimitive */ + /* + * TODO: do this only if X-Server get lock. If kernel supports delayed + * signal, needless to do this + */ + *(pSIS->IOBase + 0X8B50) = 0xff; + *(unsigned int *)(pSIS->IOBase + 0x8B60) = -1; + +} + +static void +SISDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSiS = SISPTR(pScrn); + + SiSIdle +} + +static void +SISDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, + RegionPtr prgnSrc, CARD32 index) +{ + ScreenPtr pScreen = pParent->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSiS = SISPTR(pScrn); + + SiSIdle +} + +#if 0 +void SISLostContext(ScreenPtr pScreen) +{ +} + +void SISSwapContextPrivate(ScreenPtr pScreen) +{ +} +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h:1.2 --- /dev/null Mon Dec 18 14:31:08 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h Thu Aug 3 23:51:46 2000 @@ -0,0 +1,60 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v 1.2 2000/08/04 03:51:46 tsi Exp $ */ + +/* modified from tdfx_dri.h */ + +#ifndef _SIS_DRI_ +#define _SIS_DRI_ + +#include <xf86drm.h> + +#define SIS_MAX_DRAWABLES 256 +#define SISIOMAPSIZE (64*1024) + +typedef struct { + int CtxOwner; + int QueueLength; + unsigned int AGPCmdBufNext; + unsigned int FrameCount; +} SISSAREAPriv; + +#define SIS_FRONT 0 +#define SIS_BACK 1 +#define SIS_DEPTH 2 + +typedef struct { + drmHandle handle; + drmSize size; + drmAddress map; +} sisRegion, *sisRegionPtr; + +typedef struct { + sisRegion regs, agp; + int deviceID; + int width; + int height; + int mem; + int bytesPerPixel; + int priv1; + int priv2; + int fbOffset; + int backOffset; + int depthOffset; + int textureOffset; + int textureSize; + unsigned int AGPCmdBufOffset; + unsigned int AGPCmdBufSize; + int irqEnabled; + unsigned int scrnX, scrnY; +} SISDRIRec, *SISDRIPtr; + +typedef struct { + /* Nothing here yet */ + int dummy; +} SISConfigPrivRec, *SISConfigPrivPtr; + +typedef struct { + /* Nothing here yet */ + int dummy; +} SISDRIContextRec, *SISDRIContextPtr; + +#endif Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c:1.47 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c:1.55 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c:1.47 Mon Jun 26 06:26:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c Sat Dec 2 10:30:51 2000 @@ -25,16 +25,10 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.47 2000/06/26 10:26:16 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.55 2000/12/02 15:30:51 tsi Exp $ */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" #include "xf1bpp.h" #include "xf4bpp.h" #include "mibank.h" @@ -56,7 +50,7 @@ #include "sis.h" #include "sis_regs.h" -#include "sis_bios.h" +#include "sis_vb.h" #ifdef XFreeXDGA #define _XF86DGA_SERVER_ @@ -69,31 +63,40 @@ #include "extensions/dpms.h" #endif -static void SISIdentify(int flags); -static Bool SISProbe(DriverPtr drv, int flags); -static Bool SISPreInit(ScrnInfoPtr pScrn, int flags); -static Bool SISScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool SISEnterVT(int scrnIndex, int flags); -static void SISLeaveVT(int scrnIndex, int flags); -static Bool SISCloseScreen(int scrnIndex, ScreenPtr pScreen); -static Bool SISSaveScreen(ScreenPtr pScreen, int mode); +#ifdef XvExtension +#include "xf86xv.h" +#include "Xv.h" +#endif + +#ifdef XF86DRI +#include "dri.h" +#endif +static void SISIdentify(int flags); +static Bool SISProbe(DriverPtr drv, int flags); +static Bool SISPreInit(ScrnInfoPtr pScrn, int flags); +static Bool SISScreenInit(int Index, ScreenPtr pScreen, int argc, + char **argv); +static Bool SISEnterVT(int scrnIndex, int flags); +static void SISLeaveVT(int scrnIndex, int flags); +static Bool SISCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SISSaveScreen(ScreenPtr pScreen, int mode); + /* Optional functions */ -static void SISFreeScreen(int scrnIndex, int flags); -static int SISValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, - int flags); +static void SISFreeScreen(int scrnIndex, int flags); +static int SISValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, + int flags); /* Internally used functions */ -static Bool SISMapMem(ScrnInfoPtr pScrn); -static Bool SISUnmapMem(ScrnInfoPtr pScrn); -static void SISSave(ScrnInfoPtr pScrn); -static void SISRestore(ScrnInfoPtr pScrn); -static Bool SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -static void SISModifyModeInfo(DisplayModePtr mode); +static Bool SISMapMem(ScrnInfoPtr pScrn); +static Bool SISUnmapMem(ScrnInfoPtr pScrn); +static void SISSave(ScrnInfoPtr pScrn); +static void SISRestore(ScrnInfoPtr pScrn); +static Bool SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void SISModifyModeInfo(DisplayModePtr mode); -#ifdef DEBUG -static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode); +#ifdef DEBUG +static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode); #endif @@ -124,46 +127,46 @@ static SymTabRec SISChipsets[] = { #if 0 - { PCI_CHIP_SG86C201, "SIS86c201" }, - { PCI_CHIP_SG86C202, "SIS86c202" }, - { PCI_CHIP_SG86C205, "SIS86c205" }, - { PCI_CHIP_SG86C215, "SIS86c215" }, - { PCI_CHIP_SG86C225, "SIS86c225" }, -#endif - { PCI_CHIP_SIS5597, "SIS5597" }, - { PCI_CHIP_SIS5597, "SIS5598" }, - { PCI_CHIP_SIS530, "SIS530" }, - { PCI_CHIP_SIS6326, "SIS6326" }, - { PCI_CHIP_SIS300, "SIS300" }, - { PCI_CHIP_SIS630, "SIS630" }, - { PCI_CHIP_SIS540, "SIS540" }, - { -1, NULL } + { PCI_CHIP_SG86C201, "SIS86c201" }, + { PCI_CHIP_SG86C202, "SIS86c202" }, + { PCI_CHIP_SG86C205, "SIS86c205" }, + { PCI_CHIP_SG86C215, "SIS86c215" }, + { PCI_CHIP_SG86C225, "SIS86c225" }, +#endif + { PCI_CHIP_SIS5597, "SIS5597" }, + { PCI_CHIP_SIS5597, "SIS5598" }, + { PCI_CHIP_SIS530, "SIS530" }, + { PCI_CHIP_SIS6326, "SIS6326" }, + { PCI_CHIP_SIS300, "SIS300" }, + { PCI_CHIP_SIS630, "SIS630" }, + { PCI_CHIP_SIS540, "SIS540" }, + { -1, NULL } }; static PciChipsets SISPciChipsets[] = { #if 0 - { PCI_CHIP_SG86C201, PCI_CHIP_SG86C201, RES_SHARED_VGA }, - { PCI_CHIP_SG86C202, PCI_CHIP_SG86C202, RES_SHARED_VGA }, - { PCI_CHIP_SG86C205, PCI_CHIP_SG86C205, RES_SHARED_VGA }, - { PCI_CHIP_SG86C205, PCI_CHIP_SG86C205, RES_SHARED_VGA }, -#endif - { PCI_CHIP_SIS5597, PCI_CHIP_SIS5597, RES_SHARED_VGA }, - { PCI_CHIP_SIS530, PCI_CHIP_SIS530, RES_SHARED_VGA }, - { PCI_CHIP_SIS6326, PCI_CHIP_SIS6326, RES_SHARED_VGA }, - { PCI_CHIP_SIS300, PCI_CHIP_SIS300, RES_SHARED_VGA }, - { PCI_CHIP_SIS630, PCI_CHIP_SIS630, RES_SHARED_VGA }, - { PCI_CHIP_SIS540, PCI_CHIP_SIS540, RES_SHARED_VGA }, - { -1, -1, RES_UNDEFINED } + { PCI_CHIP_SG86C201, PCI_CHIP_SG86C201, RES_SHARED_VGA }, + { PCI_CHIP_SG86C202, PCI_CHIP_SG86C202, RES_SHARED_VGA }, + { PCI_CHIP_SG86C205, PCI_CHIP_SG86C205, RES_SHARED_VGA }, + { PCI_CHIP_SG86C205, PCI_CHIP_SG86C205, RES_SHARED_VGA }, +#endif + { PCI_CHIP_SIS5597, PCI_CHIP_SIS5597, RES_SHARED_VGA }, + { PCI_CHIP_SIS530, PCI_CHIP_SIS530, RES_SHARED_VGA }, + { PCI_CHIP_SIS6326, PCI_CHIP_SIS6326, RES_SHARED_VGA }, + { PCI_CHIP_SIS300, PCI_CHIP_SIS300, RES_SHARED_VGA }, + { PCI_CHIP_SIS630, PCI_CHIP_SIS630, RES_SHARED_VGA }, + { PCI_CHIP_SIS540, PCI_CHIP_SIS540, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED } }; int sisReg32MMIO[]={0x8280,0x8284,0x8288,0x828C,0x8290,0x8294,0x8298,0x829C, - 0x82A0,0x82A4,0x82A8,0x82AC}; + 0x82A0,0x82A4,0x82A8,0x82AC}; /* Engine Register for the 2nd Generation Graphics Engine */ int sis2Reg32MMIO[]={0x8200,0x8204,0x8208,0x820C,0x8210,0x8214,0x8218,0x821C, - 0x8220,0x8224,0x8228,0x822C,0x8230,0x8234,0x8238,0x823C, - 0x8240, 0x8300}; + 0x8220,0x8224,0x8228,0x822C,0x8230,0x8234,0x8238,0x823C, + 0x8240, 0x8300}; static const char *xaaSymbols[] = { "XAADestroyInfoRec", @@ -173,6 +176,8 @@ "XAAOverlayFBfuncs", "XAACachePlanarMonoStipple", "XAAScreenIndex", + "XAACopyROP", + "XAAHelpPatternROP", NULL }; @@ -194,11 +199,7 @@ static const char *fbSymbols[] = { "xf1bppScreenInit", "xf4bppScreenInit", - "cfbScreenInit", - "cfb16ScreenInit", - "cfb24ScreenInit", - "cfb24_32ScreenInit", - "cfb32ScreenInit", + "fbScreenInit", NULL }; @@ -214,22 +215,63 @@ NULL }; +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmGetInterruptFromBusID", + "drmMapBufs", + "drmMarkBufs", + "drmUnmapBufs", + "drmAgpAcquire", + "drmAgpRelease", + "drmAgpEnable", + "drmAgpAlloc", + "drmAgpFree", + "drmAgpBind", + "drmAgpGetMode", + "drmAgpBase", + "drmAgpSize", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "GlxSetVisualConfigs", + NULL +}; +#endif + #ifdef XFree86LOADER static MODULESETUPPROTO(sisSetup); static XF86ModuleVersionInfo sisVersRec = { - "sis", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XF86_VERSION_CURRENT, - SIS_MAJOR_VERSION, SIS_MINOR_VERSION, SIS_PATCHLEVEL, - ABI_CLASS_VIDEODRV, /* This is a video driver */ - ABI_VIDEODRV_VERSION, - MOD_CLASS_VIDEODRV, - {0,0,0,0} + "sis", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + SIS_MAJOR_VERSION, SIS_MINOR_VERSION, SIS_PATCHLEVEL, + ABI_CLASS_VIDEODRV, /* This is a video driver */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} }; XF86ModuleData sisModuleData = { &sisVersRec, sisSetup, NULL }; @@ -240,13 +282,15 @@ static Bool setupDone = FALSE; if (!setupDone) { - setupDone = TRUE; - xf86AddDriver(&SIS, module, 0); - LoaderRefSymLists(vgahwSymbols, fbSymbols, i2cSymbols, - NULL); - return (pointer)TRUE; + setupDone = TRUE; + xf86AddDriver(&SIS, module, 0); + LoaderRefSymLists(vgahwSymbols, fbSymbols, i2cSymbols, xaaSymbols, +#ifdef XF86DRI + drmSymbols, driSymbols, +#endif + NULL); + return (pointer)TRUE; } -ErrorF("sisSetup\n"); if (errmaj) *errmaj = LDR_ONCEONLY; return NULL; @@ -263,7 +307,7 @@ * the allocation has already been done. */ if (pScrn->driverPrivate != NULL) - return TRUE; + return TRUE; pScrn->driverPrivate = xnfcalloc(sizeof(SISRec), 1); /* Initialise it */ @@ -275,7 +319,7 @@ SISFreeRec(ScrnInfoPtr pScrn) { if (pScrn->driverPrivate == NULL) - return; + return; xfree(pScrn->driverPrivate); pScrn->driverPrivate = NULL; } @@ -284,52 +328,52 @@ static void SISDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags) { - unsigned char extDDC_PCR; - unsigned char crtc17 = 0; - unsigned char seq1 = 0 ; + unsigned char extDDC_PCR; + unsigned char crtc17 = 0; + unsigned char seq1 = 0 ; int vgaIOBase = VGAHWPTR(pScrn)->IOBase; - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,"SISDisplayPowerManagementSet(%d)\n",PowerManagementMode); - outb(vgaIOBase + 4, 0x17); - crtc17 = inb(vgaIOBase + 5); - outb(VGA_SEQ_INDEX, 0x11); - extDDC_PCR = inb(VGA_SEQ_DATA) & ~0xC0; - switch (PowerManagementMode) - { - case DPMSModeOn: - /* HSync: On, VSync: On */ - seq1 = 0x00 ; - crtc17 |= 0x80; - break; - case DPMSModeStandby: - /* HSync: Off, VSync: On */ - seq1 = 0x20 ; - extDDC_PCR |= 0x40; - break; - case DPMSModeSuspend: - /* HSync: On, VSync: Off */ - seq1 = 0x20 ; - extDDC_PCR |= 0x80; - break; - case DPMSModeOff: - /* HSync: Off, VSync: Off */ - seq1 = 0x20 ; - extDDC_PCR |= 0xC0; - /* DPMSModeOff is not supported with ModeStandby | ModeSuspend */ + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,"SISDisplayPowerManagementSet(%d)\n",PowerManagementMode); + outb(vgaIOBase + 4, 0x17); + crtc17 = inb(vgaIOBase + 5); + outb(VGA_SEQ_INDEX, 0x11); + extDDC_PCR = inb(VGA_SEQ_DATA) & ~0xC0; + switch (PowerManagementMode) + { + case DPMSModeOn: + /* HSync: On, VSync: On */ + seq1 = 0x00 ; + crtc17 |= 0x80; + break; + case DPMSModeStandby: + /* HSync: Off, VSync: On */ + seq1 = 0x20 ; + extDDC_PCR |= 0x40; + break; + case DPMSModeSuspend: + /* HSync: On, VSync: Off */ + seq1 = 0x20 ; + extDDC_PCR |= 0x80; + break; + case DPMSModeOff: + /* HSync: Off, VSync: Off */ + seq1 = 0x20 ; + extDDC_PCR |= 0xC0; + /* DPMSModeOff is not supported with ModeStandby | ModeSuspend */ /* need same as the generic VGA function */ - crtc17 &= ~0x80; - break; - } - outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ - outb(VGA_SEQ_INDEX, 0x01); /* Select SEQ1 */ - seq1 |= inb(VGA_SEQ_DATA) & ~0x20; - outb(VGA_SEQ_DATA, seq1); - usleep(10000); - outb(vgaIOBase + 4, 0x17); - outb(vgaIOBase + 5, crtc17); - outb(VGA_SEQ_INDEX, 0x11); - outb(VGA_SEQ_DATA, extDDC_PCR); - outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ + crtc17 &= ~0x80; + break; + } + outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ + outb(VGA_SEQ_INDEX, 0x01); /* Select SEQ1 */ + seq1 |= inb(VGA_SEQ_DATA) & ~0x20; + outb(VGA_SEQ_DATA, seq1); + usleep(10000); + outb(vgaIOBase + 4, 0x17); + outb(vgaIOBase + 5, crtc17); + outb(VGA_SEQ_INDEX, 0x11); + outb(VGA_SEQ_DATA, extDDC_PCR); + outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */ } #endif @@ -338,7 +382,7 @@ static void SISIdentify(int flags) { - xf86PrintChipsets(SIS_NAME, "driver for SiS chipsets", SISChipsets); + xf86PrintChipsets(SIS_NAME, "driver for SiS chipsets", SISChipsets); } static void @@ -347,9 +391,21 @@ This makes white and black look right (otherwise they were both black. I'm sure there's a better way to do that, just lazy to search the docs. */ + + SISPtr pSiS = SISPTR(pScrn); - outb(0x3C8, 0x00); outb(0x3C9, 0x00); outb(0x3C9, 0x00); outb(0x3C9, 0x00); - outb(0x3C8, 0x3F); outb(0x3C9, 0x3F); outb(0x3C9, 0x3F); outb(0x3C9, 0x3F); + /*outb(0x3C8, 0x00); outb(0x3C9, 0x00); outb(0x3C9, 0x00); outb(0x3C9, 0x00); + outb(0x3C8, 0x3F); outb(0x3C9, 0x3F); outb(0x3C9, 0x3F); outb(0x3C9, 0x3F);*/ + + outb(pSiS->RelIO+0x48, 0x00); + outb(pSiS->RelIO+0x49, 0x00); + outb(pSiS->RelIO+0x49, 0x00); + outb(pSiS->RelIO+0x49, 0x00); + + outb(pSiS->RelIO+0x48, 0x3F); + outb(pSiS->RelIO+0x49, 0x3F); + outb(pSiS->RelIO+0x49, 0x3F); + outb(pSiS->RelIO+0x49, 0x3F); } /* Mandatory */ @@ -386,12 +442,12 @@ */ if ((numDevSections = xf86MatchDevice(SIS_DRIVER_NAME, - &devSections)) <= 0) { - /* - * There's no matching device section in the config file, so quit - * now. - */ - return FALSE; + &devSections)) <= 0) { + /* + * There's no matching device section in the config file, so quit + * now. + */ + return FALSE; } /* @@ -410,50 +466,48 @@ * amounts to checking the PCI data that the server has already collected. */ if (xf86GetPciVideoInfo() == NULL) { - /* - * We won't let anything in the config file override finding no - * PCI video cards at all. This seems reasonable now, but we'll see. - */ - return FALSE; + /* + * We won't let anything in the config file override finding no + * PCI video cards at all. This seems reasonable now, but we'll see. + */ + return FALSE; } numUsed = xf86MatchPciInstances(SIS_NAME, PCI_VENDOR_SIS, - SISChipsets, SISPciChipsets, devSections, - numDevSections, drv, &usedChips); + SISChipsets, SISPciChipsets, devSections, + numDevSections, drv, &usedChips); /* Free it since we don't need that list after this */ - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) - return FALSE; + return FALSE; if (flags & PROBE_DETECT) foundScreen = TRUE; else for (i = 0; i < numUsed; i++) { - ScrnInfoPtr pScrn; + ScrnInfoPtr pScrn; - /* Allocate a ScrnInfoRec and claim the slot */ - pScrn = NULL; + /* Allocate a ScrnInfoRec and claim the slot */ + pScrn = NULL; - if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], - SISPciChipsets, NULL, NULL, - NULL, NULL, NULL))) { - /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = SIS_CURRENT_VERSION; - pScrn->driverName = SIS_DRIVER_NAME; - pScrn->name = SIS_NAME; - pScrn->Probe = SISProbe; - pScrn->PreInit = SISPreInit; - pScrn->ScreenInit = SISScreenInit; - pScrn->SwitchMode = SISSwitchMode; - pScrn->AdjustFrame = SISAdjustFrame; - pScrn->EnterVT = SISEnterVT; - pScrn->LeaveVT = SISLeaveVT; - pScrn->FreeScreen = SISFreeScreen; - pScrn->ValidMode = SISValidMode; - foundScreen = TRUE; - } + if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], + SISPciChipsets, NULL, NULL, + NULL, NULL, NULL))) { + /* Fill in what we can of the ScrnInfoRec */ + pScrn->driverVersion = SIS_CURRENT_VERSION; + pScrn->driverName = SIS_DRIVER_NAME; + pScrn->name = SIS_NAME; + pScrn->Probe = SISProbe; + pScrn->PreInit = SISPreInit; + pScrn->ScreenInit = SISScreenInit; + pScrn->SwitchMode = SISSwitchMode; + pScrn->AdjustFrame = SISAdjustFrame; + pScrn->EnterVT = SISEnterVT; + pScrn->LeaveVT = SISLeaveVT; + pScrn->FreeScreen = SISFreeScreen; + pScrn->ValidMode = SISValidMode; + foundScreen = TRUE; + } } xfree(usedChips); return foundScreen; @@ -486,7 +540,7 @@ ClockRangePtr clockRanges; char *mod = NULL; const char *Sym = NULL; - int pix24flags; + int pix24flags; if (flags & PROBE_DETECT) return FALSE; @@ -505,11 +559,11 @@ /* Check the number of entities, and fail if it isn't one. */ if (pScrn->numEntities != 1) - return FALSE; + return FALSE; /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) - return FALSE; + return FALSE; xf86LoaderReqSymLists(vgahwSymbols, NULL); @@ -517,18 +571,18 @@ * Allocate a vgaHWRec */ if (!vgaHWGetHWRec(pScrn)) - return FALSE; + return FALSE; - VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */ + VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */ if (!vgaHWMapMem(pScrn)) - return FALSE; + return FALSE; vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; /* Allocate the SISRec driverPrivate */ if (!SISGetRec(pScrn)) { - return FALSE; + return FALSE; } pSiS = SISPTR(pScrn); pSiS->pScrn = pScrn; @@ -536,23 +590,23 @@ /* Get the entity, and make sure it is PCI. */ pSiS->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pSiS->pEnt->location.type != BUS_PCI) - return FALSE; + return FALSE; /* Find the PCI info for this screen */ pSiS->PciInfo = xf86GetPciInfoForEntity(pSiS->pEnt->index); pSiS->PciTag = pciTag(pSiS->PciInfo->bus, pSiS->PciInfo->device, - pSiS->PciInfo->func); + pSiS->PciInfo->func); /* * XXX This could be refined if some VGA memory resources are not * decoded in operating mode. */ { - resRange vgamem[] = { {ResShrMemBlock,0xA0000,0xAFFFF}, - {ResShrMemBlock,0xB0000,0xB7FFF}, - {ResShrMemBlock,0xB8000,0xBFFFF}, - _END }; - xf86SetOperatingState(vgamem, pSiS->pEnt->index, ResUnusedOpr); + resRange vgamem[] = { {ResShrMemBlock,0xA0000,0xAFFFF}, + {ResShrMemBlock,0xB0000,0xB7FFF}, + {ResShrMemBlock,0xB8000,0xBFFFF}, + _END }; + xf86SetOperatingState(vgamem, pSiS->pEnt->index, ResUnusedOpr); } /* Operations for which memory access is required */ @@ -562,7 +616,7 @@ /* The ramdac module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "ramdac")) - return FALSE; + return FALSE; /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; @@ -573,59 +627,59 @@ * Our preference for depth 24 is 24bpp, so tell it that too. */ pix24flags = Support32bppFb | Support24bppFb | - SupportConvert24to32 | SupportConvert32to24; + SupportConvert24to32 | SupportConvert32to24; if (!xf86SetDepthBpp(pScrn, 8, 8, 8, pix24flags)) { - return FALSE; + return FALSE; } else { - /* Check that the returned depth is one we support */ - switch (pScrn->depth) { - case 8: - case 15: - case 16: - case 24: - /* OK */ - break; - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Given depth (%d) is not supported by this driver\n", - pScrn->depth); - return FALSE; - } + /* Check that the returned depth is one we support */ + switch (pScrn->depth) { + case 8: + case 15: + case 16: + case 24: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + return FALSE; + } } xf86PrintDepthBpp(pScrn); /* Get the depth24 pixmap format */ if (pScrn->depth == 24 && pix24bpp == 0) - pix24bpp = xf86GetBppFromDepth(pScrn, 24); + pix24bpp = xf86GetBppFromDepth(pScrn, 24); /* * This must happen after pScrn->display has been set because * xf86SetWeight references it. */ if (pScrn->depth > 8) { - /* The defaults are OK for us */ - rgb zeros = {0, 0, 0}; + /* The defaults are OK for us */ + rgb zeros = {0, 0, 0}; - if (!xf86SetWeight(pScrn, zeros, zeros)) { - return FALSE; - } else { - /* XXX check that weight returned is supported */ + if (!xf86SetWeight(pScrn, zeros, zeros)) { + return FALSE; + } else { + /* XXX check that weight returned is supported */ ; } } if (!xf86SetDefaultVisual(pScrn, -1)) { - return FALSE; + return FALSE; } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } + /* We don't currently support DirectColor at > 8bpp */ + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" + " (%s) is not supported at depth %d\n", + xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } } /* @@ -633,11 +687,11 @@ */ { - Gamma zeros = {0.0, 0.0, 0.0}; + Gamma zeros = {0.0, 0.0, 0.0}; - if (!xf86SetGamma(pScrn, zeros)) { - return FALSE; - } + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } } /* We use a programamble clock */ @@ -645,11 +699,11 @@ /* Set the bits per RGB for 8bpp mode */ if (pScrn->depth == 8) { - pScrn->rgbBits = 6; + pScrn->rgbBits = 6; } - pSiS->ddc1Read = SiSddc1Read; /* this cap will be modified */ + pSiS->ddc1Read = SiSddc1Read; /* this cap will be modified */ from = X_DEFAULT; /* @@ -657,27 +711,27 @@ * override. */ if (pSiS->pEnt->device->chipset && *pSiS->pEnt->device->chipset) { - pScrn->chipset = pSiS->pEnt->device->chipset; - pSiS->Chipset = xf86StringToToken(SISChipsets, pScrn->chipset); - from = X_CONFIG; + pScrn->chipset = pSiS->pEnt->device->chipset; + pSiS->Chipset = xf86StringToToken(SISChipsets, pScrn->chipset); + from = X_CONFIG; } else if (pSiS->pEnt->device->chipID >= 0) { - pSiS->Chipset = pSiS->pEnt->device->chipID; - pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); + pSiS->Chipset = pSiS->pEnt->device->chipID; + pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); - from = X_CONFIG; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", - pSiS->Chipset); + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pSiS->Chipset); } else { - from = X_PROBED; - pSiS->Chipset = pSiS->PciInfo->chipType; - pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); + from = X_PROBED; + pSiS->Chipset = pSiS->PciInfo->chipType; + pScrn->chipset = (char *)xf86TokenToString(SISChipsets, pSiS->Chipset); } if (pSiS->pEnt->device->chipRev >= 0) { - pSiS->ChipRev = pSiS->pEnt->device->chipRev; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", - pSiS->ChipRev); + pSiS->ChipRev = pSiS->pEnt->device->chipRev; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + pSiS->ChipRev); } else { - pSiS->ChipRev = pSiS->PciInfo->chipRev; + pSiS->ChipRev = pSiS->PciInfo->chipRev; } /* @@ -685,14 +739,14 @@ * SISProbe(), but check it just in case. */ if (pScrn->chipset == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ChipID 0x%04X is not recognised\n", pSiS->Chipset); - return FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "ChipID 0x%04X is not recognised\n", pSiS->Chipset); + return FALSE; } if (pSiS->Chipset < 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognised\n", pScrn->chipset); - return FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Chipset \"%s\" is not recognised\n", pScrn->chipset); + return FALSE; } @@ -701,13 +755,13 @@ /* get VBIOS image */ if (!(pSiS->BIOS=xcalloc(1, BIOS_SIZE))) { - ErrorF("Allocate memory fail !!\n"); - return FALSE; + ErrorF("Allocate memory fail !!\n"); + return FALSE; } if (xf86ReadBIOS(BIOS_BASE, 0, pSiS->BIOS, BIOS_SIZE) != BIOS_SIZE) { - xfree(pSiS->BIOS); - ErrorF("Read VBIOS image fail !!\n"); - return FALSE; + xfree(pSiS->BIOS); + ErrorF("Read VBIOS image fail !!\n"); + return FALSE; } SiSOptions(pScrn); @@ -715,67 +769,100 @@ from = X_PROBED; if (pSiS->pEnt->device->MemBase != 0) { - /* - * XXX Should check that the config file value matches one of the - * PCI base address values. - */ - pSiS->FbAddress = pSiS->pEnt->device->MemBase; - from = X_CONFIG; + /* + * XXX Should check that the config file value matches one of the + * PCI base address values. + */ + pSiS->FbAddress = pSiS->pEnt->device->MemBase; + from = X_CONFIG; } else { - pSiS->FbAddress = pSiS->PciInfo->memBase[0] & 0xFFFFFFF0; + pSiS->FbAddress = pSiS->PciInfo->memBase[0] & 0xFFFFFFF0; } xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", - (unsigned long)pSiS->FbAddress); + (unsigned long)pSiS->FbAddress); if (pSiS->pEnt->device->IOBase != 0) { - /* - * XXX Should check that the config file value matches one of the - * PCI base address values. - */ - pSiS->IOAddress = pSiS->pEnt->device->IOBase; - from = X_CONFIG; + /* + * XXX Should check that the config file value matches one of the + * PCI base address values. + */ + pSiS->IOAddress = pSiS->pEnt->device->IOBase; + from = X_CONFIG; } else { - pSiS->IOAddress = pSiS->PciInfo->memBase[1] & 0xFFFFFFF0; + pSiS->IOAddress = pSiS->PciInfo->memBase[1] & 0xFFFFFFF0; } xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n", - (unsigned long)pSiS->IOAddress); + (unsigned long)pSiS->IOAddress); pSiS->RelIO = pSiS->PciInfo->ioBase[2] & 0xFFFC; xf86DrvMsg(pScrn->scrnIndex, from, "Relocate IO registers at 0x%lX\n", - (unsigned long)pSiS->RelIO); + (unsigned long)pSiS->RelIO); /* Register the PCI-assigned resources. */ if (xf86RegisterResources(pSiS->pEnt->index, NULL, ResExclusive)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "xf86RegisterResources() found resource conflicts\n"); - return FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "xf86RegisterResources() found resource conflicts\n"); + return FALSE; } from = X_PROBED; if ((pSiS->pEnt->device->videoRam != 0) && - (pSiS->pEnt->device->videoRam < pScrn->videoRam)) { - pScrn->videoRam = pSiS->pEnt->device->videoRam; - from = X_CONFIG; + (pSiS->pEnt->device->videoRam < pScrn->videoRam)) { + pScrn->videoRam = pSiS->pEnt->device->videoRam; + from = X_CONFIG; } xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", pScrn->videoRam); pSiS->FbMapSize = pScrn->videoRam * 1024; - + SISVGAPreInit(pScrn); - SISLCDPreInit(pScrn); - SISTVPreInit(pScrn); + SISLCDPreInit(pScrn); + SISTVPreInit(pScrn); + SISCRT2PreInit(pScrn); + if (pSiS->ForceCRT2Type == CRT2_DEFAULT) + { if (pSiS->VBFlags & CRT2_VGA) + pSiS->ForceCRT2Type = CRT2_VGA; + else if (pSiS->VBFlags & CRT2_LCD) + pSiS->ForceCRT2Type = CRT2_LCD; + else if (pSiS->VBFlags & CRT2_TV) + pSiS->ForceCRT2Type = CRT2_TV; + } + switch (pSiS->ForceCRT2Type) + { case CRT2_TV: + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_LCD | CRT2_VGA); + if (pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL)) + pSiS->VBFlags = pSiS->VBFlags | CRT2_TV; + else + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV); + break; + case CRT2_LCD: + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV | CRT2_VGA); + if (pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL)) + pSiS->VBFlags = pSiS->VBFlags | CRT2_LCD; + else + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_LCD); + break; + case CRT2_VGA: + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_TV | CRT2_LCD); + if (pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL)) + pSiS->VBFlags = pSiS->VBFlags | CRT2_VGA; + else + pSiS->VBFlags = pSiS->VBFlags & ~(CRT2_VGA); + break; + } + SISDACPreInit(pScrn); outw(VGA_SEQ_INDEX, (unlock << 8) | 0x05); /* Set the min pixel clock */ - pSiS->MinClock = 16250; /* XXX Guess, need to check this */ + pSiS->MinClock = 16250; /* XXX Guess, need to check this */ xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Min pixel clock is %d MHz\n", - pSiS->MinClock / 1000); + pSiS->MinClock / 1000); from = X_PROBED; /* @@ -783,30 +870,30 @@ * file, we respect that setting. */ if (pSiS->pEnt->device->dacSpeeds[0]) { - int speed = 0; + int speed = 0; - switch (pScrn->bitsPerPixel) { - case 8: - speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP8]; - break; - case 16: - speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP16]; - break; - case 24: - speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP24]; - break; - case 32: - speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP32]; - break; - } - if (speed == 0) - pSiS->MaxClock = pSiS->pEnt->device->dacSpeeds[0]; - else - pSiS->MaxClock = speed; - from = X_CONFIG; + switch (pScrn->bitsPerPixel) { + case 8: + speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP8]; + break; + case 16: + speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP16]; + break; + case 24: + speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP24]; + break; + case 32: + speed = pSiS->pEnt->device->dacSpeeds[DAC_BPP32]; + break; + } + if (speed == 0) + pSiS->MaxClock = pSiS->pEnt->device->dacSpeeds[0]; + else + pSiS->MaxClock = speed; + from = X_CONFIG; } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", - pSiS->MaxClock / 1000); + pSiS->MaxClock / 1000); /* * Setup the ClockRanges, which describe what clock ranges are available, @@ -816,9 +903,9 @@ clockRanges->next = NULL; clockRanges->minClock = pSiS->MinClock; clockRanges->maxClock = pSiS->MaxClock; - clockRanges->clockIndex = -1; /* programmable */ + clockRanges->clockIndex = -1; /* programmable */ clockRanges->interlaceAllowed = TRUE; - clockRanges->doubleScanAllowed = TRUE; /* XXX check this */ + clockRanges->doubleScanAllowed = TRUE; /* XXX check this */ /* * xf86ValidateModes will check that the mode HTotal and VTotal values @@ -833,26 +920,26 @@ * XXX Assuming min height 128, max 4096 */ i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, - pScrn->display->modes, clockRanges, - NULL, 256, 8192, - pScrn->bitsPerPixel * 8, 128, 4096, - pScrn->display->virtualX, - pScrn->display->virtualY, - pSiS->FbMapSize, - LOOKUP_BEST_REFRESH); + pScrn->display->modes, clockRanges, + NULL, 256, 8192, + pScrn->bitsPerPixel * 8, 128, 4096, + pScrn->display->virtualX, + pScrn->display->virtualY, + pSiS->FbMapSize, + LOOKUP_BEST_REFRESH); if (i == -1) { - SISFreeRec(pScrn); - return FALSE; + SISFreeRec(pScrn); + return FALSE; } /* Prune the modes marked as invalid */ xf86PruneDriverModes(pScrn); if (i == 0 || pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); - SISFreeRec(pScrn); - return FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + SISFreeRec(pScrn); + return FALSE; } xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); @@ -869,57 +956,43 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: - mod = "xf1bpp"; - Sym = "xf1bppScreenInit"; - break; + mod = "xf1bpp"; + Sym = "xf1bppScreenInit"; + break; case 4: - mod = "xf4bpp"; - Sym = "xf4bppScreenInit"; - break; + mod = "xf4bpp"; + Sym = "xf4bppScreenInit"; + break; case 8: - mod = "cfb"; - Sym = "cfbScreenInit"; - break; case 16: - mod = "cfb16"; - Sym = "cfb16ScreenInit"; - break; case 24: - if (pix24bpp == 24) { - mod = "cfb24"; - Sym = "cfb24ScreenInit"; - } else { - mod = "xf24_32bpp"; - Sym = "cfb24_32ScreenInit"; - } - break; case 32: - mod = "cfb32"; - Sym = "cfb32ScreenInit"; - break; + mod = "fb"; + Sym = "fbScreenInit"; + break; } if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - SISFreeRec(pScrn); - return FALSE; + SISFreeRec(pScrn); + return FALSE; } xf86LoaderReqSymbols(Sym, NULL); if (!xf86LoadSubModule(pScrn, "i2c")) { - SISFreeRec(pScrn); - return FALSE; + SISFreeRec(pScrn); + return FALSE; } xf86LoaderReqSymLists(i2cSymbols, NULL); /* Load XAA if needed */ if (!pSiS->NoAccel) { - xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Accel Enable\n"); - if (!xf86LoadSubModule(pScrn, "xaa")) { - SISFreeRec(pScrn); - return FALSE; - } + xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Accel Enable\n"); + if (!xf86LoadSubModule(pScrn, "xaa")) { + SISFreeRec(pScrn); + return FALSE; + } xf86LoaderReqSymLists(xaaSymbols, NULL); } @@ -927,14 +1000,14 @@ /* Load DDC if needed */ /* This gives us DDC1 - we should be able to get DDC2B using i2c */ if (!xf86LoadSubModule(pScrn, "ddc")) { - SISFreeRec(pScrn); - return FALSE; + SISFreeRec(pScrn); + return FALSE; } xf86LoaderReqSymLists(ddcSymbols, NULL); /* Initialize DDC1 if possible */ - if (pSiS->ddc1Read) - xf86PrintEDID(xf86DoEDID_DDC1(pScrn->scrnIndex,vgaHWddc1SetSpeed,pSiS->ddc1Read ) ); +/* if (pSiS->ddc1Read) + xf86PrintEDID(xf86DoEDID_DDC1(pScrn->scrnIndex,vgaHWddc1SetSpeed,pSiS->ddc1Read ) ); */ return TRUE; @@ -966,9 +1039,9 @@ mmioFlags = VIDMEM_MMIO | VIDMEM_SPARSE; #endif pSiS->IOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, - pSiS->PciTag, pSiS->IOAddress, 0x10000); + pSiS->PciTag, pSiS->IOAddress, 0x10000); if (pSiS->IOBase == NULL) - return FALSE; + return FALSE; #ifdef __alpha__ /* @@ -976,18 +1049,18 @@ * setting CPUToScreenColorExpandBase. */ pSiS->IOBaseDense = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, - pSiS->PciTag, pSiS->IOAddress, 0x10000); + pSiS->PciTag, pSiS->IOAddress, 0x10000); if (pSiS->IOBaseDense == NULL) - return FALSE; + return FALSE; #endif /* __alpha__ */ pSiS->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - pSiS->PciTag, - (unsigned long)pSiS->FbAddress, - pSiS->FbMapSize); + pSiS->PciTag, + (unsigned long)pSiS->FbAddress, + pSiS->FbMapSize); if (pSiS->FbBase == NULL) - return FALSE; + return FALSE; return TRUE; } @@ -1055,41 +1128,45 @@ SISRegPtr sisReg; vgaHWUnlock(hwp); - - SISModifyModeInfo(mode); + + SISModifyModeInfo(mode); /* Initialise the ModeReg values */ if (!vgaHWInit(pScrn, mode)) - return FALSE; - pScrn->vtSema = TRUE; + return FALSE; + pScrn->vtSema = TRUE; if (!(*pSiS->ModeInit)(pScrn, mode)) - return FALSE; + return FALSE; - if (pSiS->VBFlags & CRT2_ENABLE) - if (!(*pSiS->ModeInit2)(pScrn, mode)) { /* Disable VB */ - pSiS->ModeReg.sisRegs3D4[0x31] |= 0x60; - pSiS->ModeReg.sisRegs3D4[0x30] &= 0xFC; - } - PDEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "HDisplay: %d, VDisplay: %d \n", - mode->HDisplay, mode->VDisplay)); + "HDisplay: %d, VDisplay: %d \n", + mode->HDisplay, mode->VDisplay)); /* Program the registers */ vgaHWProtect(pScrn, TRUE); vgaReg = &hwp->ModeReg; - sisReg = &pSiS->ModeReg; + sisReg = &pSiS->ModeReg; vgaReg->Attribute[0x10] = 0x01; if (pScrn->bitsPerPixel > 8) - vgaReg->Graphics[0x05] = 0x00; + vgaReg->Graphics[0x05] = 0x00; - vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); - (*pSiS->SiSRestore)(pScrn, sisReg); + if( (pSiS->Chipset == PCI_CHIP_SIS300) || + (pSiS->Chipset == PCI_CHIP_SIS630) || + (pSiS->Chipset == PCI_CHIP_SIS540) ) + { + SiSPreSetMode(pScrn); + SiSSetMode(pScrn, pScrn->currentMode); + } + else + { + (*pSiS->SiSRestore)(pScrn, sisReg); + } - vgaHWProtect(pScrn, FALSE); + vgaHWProtect(pScrn, FALSE); /* Reserved for debug * @@ -1117,9 +1194,9 @@ sisReg = &pSiS->SavedReg; vgaHWProtect(pScrn, TRUE); - - (*pSiS->SiSRestore)(pScrn, sisReg); + (*pSiS->SiSRestore)(pScrn, sisReg); + vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); vgaHWProtect(pScrn, FALSE); @@ -1139,6 +1216,7 @@ SISPtr pSiS; int ret; VisualPtr visual; + unsigned long OnScreenSize; /* * First get the ScrnInfoRec @@ -1147,18 +1225,18 @@ hwp = VGAHWPTR(pScrn); - hwp->MapSize = 0x10000; /* Standard 64k VGA window */ + hwp->MapSize = 0x10000; /* Standard 64k VGA window */ pSiS = SISPTR(pScrn); /* Map the VGA memory and get the VGA IO base */ if (!vgaHWMapMem(pScrn)) - return FALSE; + return FALSE; vgaHWGetIOBase(hwp); /* Map the SIS memory and MMIO areas */ if (!SISMapMem(pScrn)) - return FALSE; + return FALSE; /* Save the current state */ SISSave(pScrn); @@ -1168,7 +1246,11 @@ /* Initialise the first mode */ if (!SISModeInit(pScrn, pScrn->currentMode)) - return FALSE; + return FALSE; + + /* Clear frame buffer */ + OnScreenSize = pScrn->displayWidth * pScrn->currentMode->VDisplay * (pScrn->bitsPerPixel / 8); + memset(pSiS->FbBase, 0, OnScreenSize); /* Darken the screen for aesthetic reasons and set the viewport */ SISSaveScreen(pScreen, SCREEN_SAVER_ON); @@ -1199,16 +1281,35 @@ */ if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + pScrn->defaultVisual)) + return FALSE; } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; } + { + static int GlobalHWQueueLength = 0; + + pSiS->cmdQueueLenPtr = &(GlobalHWQueueLength); + } + +#ifdef XF86DRI + /* + * Setup DRI after visuals have been established, but before cfbScreenInit + * is called. cfbScreenInit will eventually call into the drivers + * InitGLXVisuals call back. + */ + pSiS->directRenderingEnabled = SISDRIScreenInit(pScreen); + /* Force the initialization of the context */ +#if 0 + SISLostContext(pScreen); +#endif +#endif + /* * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. @@ -1216,51 +1317,34 @@ switch (pScrn->bitsPerPixel) { case 1: - ret = xf1bppScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; + ret = xf1bppScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; case 4: - ret = xf4bppScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; + ret = xf4bppScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth); + break; case 8: - ret = cfbScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 16: - ret = cfb16ScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; case 32: - ret = cfb32ScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; + ret = fbScreenInit(pScreen, pSiS->FbBase, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel); + break; default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in SISScrnInit\n", - pScrn->bitsPerPixel); - ret = FALSE; - break; + xf86DrvMsg(scrnIndex, X_ERROR, + "Internal error: invalid bpp (%d) in SISScrnInit\n", + pScrn->bitsPerPixel); + ret = FALSE; + break; } if (!ret) { - ErrorF ("SetMode Error@!\n"); - return FALSE; + ErrorF ("SetMode Error@!\n"); + return FALSE; } xf86SetBlackWhitePixels(pScreen); @@ -1271,62 +1355,94 @@ /* Fixup RGB ordering */ visual = pScreen->visuals + pScreen->numVisuals; while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; - } - } + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } } else if (pScrn->depth == 1) { - SIS1bppColorMap(pScrn); + SIS1bppColorMap(pScrn); } if (!pSiS->NoAccel) { if ( pSiS->Chipset == PCI_CHIP_SIS300 || - pSiS->Chipset == PCI_CHIP_SIS630 || - pSiS->Chipset == PCI_CHIP_SIS540) - SiS300AccelInit(pScreen); - else if (pSiS->Chipset == PCI_CHIP_SIS530) - SiS530AccelInit(pScreen); - else - SiSAccelInit(pScreen); + pSiS->Chipset == PCI_CHIP_SIS630 || + pSiS->Chipset == PCI_CHIP_SIS540) + SiS300AccelInit(pScreen); + else if (pSiS->Chipset == PCI_CHIP_SIS530) + SiS530AccelInit(pScreen); + else + SiSAccelInit(pScreen); } miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); if (pSiS->HWCursor) - SiSHWCursorInit(pScreen); + SiSHWCursorInit(pScreen); /* Initialise default colourmap */ if (!miCreateDefColormap(pScreen)) - return FALSE; + return FALSE; -/* marked by archer for adding VB palette +/* marked by archer for adding VB palette if (!vgaHWHandleColormaps(pScreen)) - return FALSE; + return FALSE; */ if (!xf86HandleColormaps(pScreen, 256, 8, SISLoadPalette, NULL, - CMAP_RELOAD_ON_MODE_SWITCH)) - return FALSE; + CMAP_RELOAD_ON_MODE_SWITCH)) + return FALSE; #ifdef DPMSExtension xf86DPMSInit(pScreen, (DPMSSetProcPtr)SISDisplayPowerManagementSet, 0); #endif +#ifdef XvExtension + { + XF86VideoAdaptorPtr *ptr; + int n; + + n = xf86XVListGenericAdaptors(pScrn, &ptr); + if (n) { + xf86XVScreenInit(pScreen, ptr, n); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "use generic Xv\n" ); + } + } +#endif + +#ifdef XF86DRI + if (pSiS->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have done their thing, + * complete the DRI setup. + */ + pSiS->directRenderingEnabled = SISDRIFinishScreenInit(pScreen); + } + if (pSiS->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n"); + /* TODO */ + /* SISSetLFBConfig(pSiS); */ + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); + } +#endif + + SISInitVideo(pScreen); + pSiS->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = SISCloseScreen; pScreen->SaveScreen = SISSaveScreen; /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) { - xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } /* Turn on the screen now */ @@ -1340,7 +1456,18 @@ Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { - return SISModeInit(xf86Screens[scrnIndex], mode); + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn); + if( (pSiS->Chipset == PCI_CHIP_SIS300) || + (pSiS->Chipset == PCI_CHIP_SIS630) || + (pSiS->Chipset == PCI_CHIP_SIS540) ) + { + return SiSSetMode(xf86Screens[scrnIndex], mode); + } + else + { + return SISModeInit(xf86Screens[scrnIndex], mode); + } } @@ -1349,7 +1476,7 @@ * displayed location in the video memory. */ /* Usually mandatory */ -void +void SISAdjustFrame(int scrnIndex, int x, int y, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; @@ -1368,52 +1495,54 @@ outw(VGA_SEQ_INDEX, 0x8605); if (pScrn->bitsPerPixel < 8) { - base = (y * pScrn->displayWidth + x + 3) >> 3; + base = (y * pScrn->displayWidth + x + 3) >> 3; } else { - base = y * pScrn->displayWidth + x ; - /* calculate base bpp dep. */ - switch (pScrn->bitsPerPixel) { - case 16: - base >>= 1; - break; - case 24: - base = ((base * 3)) >> 2; - base -= base % 6; - break; - case 32: - break; - default: /* 8bpp */ - base >>= 2; - break; - } + base = y * pScrn->displayWidth + x ; + /* calculate base bpp dep. */ + switch (pScrn->bitsPerPixel) { + case 16: + base >>= 1; + break; + case 24: + base = ((base * 3)) >> 2; + base -= base % 6; + break; + case 32: + break; + default: /* 8bpp */ + base >>= 2; + break; + } } outw(vgaIOBase + 4, (base & 0x00FF00) | 0x0C); outw(vgaIOBase + 4, ((base & 0x00FF) << 8) | 0x0D); switch (pSiS->Chipset) { - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - outb(VGA_SEQ_INDEX, 0x0D); - temp = (base & 0xFF0000) >> 16; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "3C5/0Dh set to hex %2X, base 0x%x\n", temp, base)); - outb(VGA_SEQ_DATA, temp); - if (pSiS->VBFlags) { - UnLockCRT2(pSiS->RelIO); - outSISIDXREG(pSiS->RelIO+4, 6, GETVAR8(base)); - outSISIDXREG(pSiS->RelIO+4, 5, GETBITS(base, 15:8)); - outSISIDXREG(pSiS->RelIO+4, 4, GETBITS(base, 23:16)); - LockCRT2(pSiS->RelIO); - } - break; - default: - outb(VGA_SEQ_INDEX, 0x27); - temp = inb(VGA_SEQ_DATA) & 0xF0; - temp |= (base & 0x0F0000) >> 16; - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "3C5/27h set to hex %2X, base %d\n", temp, base)); - outb(VGA_SEQ_DATA, temp); + case PCI_CHIP_SIS300: + case PCI_CHIP_SIS630: + case PCI_CHIP_SIS540: + outb(VGA_SEQ_INDEX, 0x0D); + temp = (base & 0xFF0000) >> 16; + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "3C5/0Dh set to hex %2X, base 0x%x\n", temp, base)); + outb(VGA_SEQ_DATA, temp); + if (pSiS->VBFlags) { +/* UnLockCRT2VB(pSiS->RelIO); */ + UnLockCRT2(pSiS->RelIO+0x30); + outSISIDXREG(pSiS->RelIO+4, 6, GETVAR8(base)); + outSISIDXREG(pSiS->RelIO+4, 5, GETBITS(base, 15:8)); + outSISIDXREG(pSiS->RelIO+4, 4, GETBITS(base, 23:16)); +/* LockCRT2VB(pSiS->RelIO); */ + LockCRT2(pSiS->RelIO+0x30); + } + break; + default: + outb(VGA_SEQ_INDEX, 0x27); + temp = inb(VGA_SEQ_DATA) & 0xF0; + temp |= (base & 0x0F0000) >> 16; + PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, + "3C5/27h set to hex %2X, base %d\n", temp, base)); + outb(VGA_SEQ_DATA, temp); } outw(VGA_SEQ_INDEX, (SR5State << 8) | 0x05); /* Relock Registers */ @@ -1431,10 +1560,33 @@ SISEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SISPtr pSiS = SISPTR(pScrn); + +#ifdef XF86DRI + ScreenPtr pScreen; +#endif +#ifdef XF86DRI + if (pSiS->directRenderingEnabled) { + pScreen = screenInfo.screens[scrnIndex]; + DRIUnlock(pScreen); + } +#endif + /* Should we re-save the text mode on each VT enter? */ - if (!SISModeInit(pScrn, pScrn->currentMode)) - return FALSE; + if( (pSiS->Chipset == PCI_CHIP_SIS300) || + (pSiS->Chipset == PCI_CHIP_SIS630) || + (pSiS->Chipset == PCI_CHIP_SIS540) ) + { + SiSPreSetMode(pScrn); + if (!SiSSetMode(pScrn, pScrn->currentMode)) + return FALSE; + } + else + { + if (!SISModeInit(pScrn, pScrn->currentMode)) + return FALSE; + } SISAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); @@ -1455,9 +1607,23 @@ { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; vgaHWPtr hwp = VGAHWPTR(pScrn); + +#ifdef XF86DRI + ScreenPtr pScreen; + SISPtr pSiS; +#endif SISRestore(pScrn); vgaHWLock(hwp); + +#ifdef XF86DRI + pSiS = SISPTR(pScrn); + if (pSiS->directRenderingEnabled) { + pScreen = screenInfo.screens[scrnIndex]; + DRILock(pScreen, 0); + } +#endif + } @@ -1473,20 +1639,26 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; vgaHWPtr hwp = VGAHWPTR(pScrn); SISPtr pSiS = SISPTR(pScrn); - xf86CursorInfoPtr pCursorInfo = pSiS->CursorInfoPtr; + xf86CursorInfoPtr pCursorInfo = pSiS->CursorInfoPtr; - if (pCursorInfo) - pCursorInfo->HideCursor(pScrn); +#ifdef XF86DRI + if (pSiS->directRenderingEnabled) { + SISDRICloseScreen(pScreen); + pSiS->directRenderingEnabled=FALSE; + } +#endif if (pScrn->vtSema) { - SISRestore(pScrn); - vgaHWLock(hwp); - SISUnmapMem(pScrn); + if (pCursorInfo) + pCursorInfo->HideCursor(pScrn); + SISRestore(pScrn); + vgaHWLock(hwp); + SISUnmapMem(pScrn); } if(pSiS->AccelInfoPtr) - XAADestroyInfoRec(pSiS->AccelInfoPtr); + XAADestroyInfoRec(pSiS->AccelInfoPtr); if(pCursorInfo) - xf86DestroyCursorInfoRec(pCursorInfo); + xf86DestroyCursorInfoRec(pCursorInfo); pScrn->vtSema = FALSE; pScreen->CloseScreen = pSiS->CloseScreen; @@ -1524,7 +1696,7 @@ return vgaHWSaveScreen(pScreen, mode); } -#ifdef DEBUG +#ifdef DEBUG /* local used for debug */ static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode) @@ -1566,27 +1738,77 @@ SISModifyModeInfo(DisplayModePtr mode) { /* - mode->Clock = 31500; - mode->CrtcHTotal = 832; - mode->CrtcHDisplay = 640; - mode->CrtcHBlankStart = 648; - mode->CrtcHSyncStart = 664; - mode->CrtcHSyncEnd = 704; - mode->CrtcHBlankEnd = 824; - - mode->CrtcVTotal = 520; - mode->CrtcVDisplay = 480; - mode->CrtcVBlankStart = 488; - mode->CrtcVSyncStart = 489; - mode->CrtcVSyncEnd = 492; - mode->CrtcVBlankEnd = 512; + mode->Clock = 31500; + mode->CrtcHTotal = 832; + mode->CrtcHDisplay = 640; + mode->CrtcHBlankStart = 648; + mode->CrtcHSyncStart = 664; + mode->CrtcHSyncEnd = 704; + mode->CrtcHBlankEnd = 824; + + mode->CrtcVTotal = 520; + mode->CrtcVDisplay = 480; + mode->CrtcVBlankStart = 488; + mode->CrtcVSyncStart = 489; + mode->CrtcVSyncEnd = 492; + mode->CrtcVBlankEnd = 512; */ - if (mode->CrtcHBlankStart == mode->CrtcHDisplay) - mode->CrtcHBlankStart++; - if (mode->CrtcHBlankEnd == mode->CrtcHTotal) - mode->CrtcHBlankEnd--; - if (mode->CrtcVBlankStart == mode->CrtcVDisplay) - mode->CrtcVBlankStart++; - if (mode->CrtcVBlankEnd == mode->CrtcVTotal) - mode->CrtcVBlankEnd--; + if (mode->CrtcHBlankStart == mode->CrtcHDisplay) + mode->CrtcHBlankStart++; + if (mode->CrtcHBlankEnd == mode->CrtcHTotal) + mode->CrtcHBlankEnd--; + if (mode->CrtcVBlankStart == mode->CrtcVDisplay) + mode->CrtcVBlankStart++; + if (mode->CrtcVBlankEnd == mode->CrtcVTotal) + mode->CrtcVBlankEnd--; +} + +void SiSPreSetMode(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + unsigned char usScratchCR30, usScratchCR31; + unsigned short SR26, SR27; + unsigned long temp; + int vbflag; + + usScratchCR30 = usScratchCR31 = 0; + outb(SISCR, 0x31); + usScratchCR31 = inb(SISCR+1) & 0x06; + vbflag=pSiS->VBFlags; + switch (vbflag & (CRT2_TV|CRT2_LCD|CRT2_VGA)) + { case CRT2_TV: + if (vbflag & TV_HIVISION) usScratchCR30 |= 0x80; + else if (vbflag & TV_PAL) usScratchCR31 |= 0x01; + + if (vbflag & TV_AVIDEO) usScratchCR30 |= 0x04; + else if (vbflag & TV_SVIDEO) usScratchCR30 |= 0x08; + else if (vbflag & TV_SCART) usScratchCR30 |= 0x10; + usScratchCR30 |= 0x01; + usScratchCR31 |= 0x40; + break; + case CRT2_LCD: + usScratchCR30 |= 0x21; + usScratchCR31 |= 0x40; + break; + case CRT2_VGA: + usScratchCR30 |= 0x41; + usScratchCR31 |= 0x40; + break; + default: + usScratchCR30 |= 0x00; + usScratchCR31 |= 0x60; + } + SetReg1(SISCR, 0x30, usScratchCR30); + SetReg1(SISCR, 0x31, usScratchCR31); + + /* Set Turbo Queue as 512K */ + if (!pSiS->NoAccel) { + if (pSiS->TurboQueue) { + temp = (pScrn->videoRam/64) - 8; + SR26 = temp & 0xFF; + SR27 = ((temp >> 8) & 3) | 0xF0; + SetReg1(SISSR, 0x26, SR26); + SetReg1(SISSR, 0x27, SR27); + } + } } Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c:1.3 Tue Apr 4 15:25:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c Mon Dec 18 14:31:08 2000 @@ -1,176 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c,v 1.3 2000/04/04 19:25:16 dawes Exp $ */ - -#include "xf86.h" -#include "xf86_ansic.h" -#include "compiler.h" -#include "xf86PciInfo.h" - -#include "sis.h" -#include "sis_regs.h" -#include "sis_lcd.h" - - - -static Bool SIS301LCDInit(ScrnInfoPtr pScrn, DisplayModePtr mode); - - -static int XYToRes(int x, int y); -static int BppToColor(int bpp); - -static Bool -SIS301LCDInit(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - SISPtr pSiS = SISPTR(pScrn); - SISRegPtr sisReg = &pSiS->ModeReg; - int res, color; - unsigned short offset, Threshold_Low, Threshold_High; - - if (mode->Flags & V_INTERLACE) - res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay*2); - else - res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay); - color = BppToColor(pScrn->bitsPerPixel); - if ((res == -1) || (color == -1)) - return FALSE; - - switch (pSiS->VBFlags & LCD_TYPE) { - case LCD_1024x768: - if (mode->CrtcHDisplay > 1024) - return FALSE; - memcpy(sisReg->VBPart1, sis301_PANEL_1024[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_PANEL_1024[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_PANEL_1024[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_PANEL_1024[res].VBPart4, 0x1C); - break; - case LCD_1280x1024: - if (mode->CrtcHDisplay > 1280) - return FALSE; -/* - memcpy(sisReg->VBPart1, sis301_PANEL_1024[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_PANEL_1024[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_PANEL_1024[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_PANEL_1024[res].VBPart4, 0x1C); -*/ - break; - case LCD_800x600: - default: - if (mode->CrtcHDisplay > 800) - return FALSE; -/* - memcpy(sisReg->VBPart1, sis301_VESA[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_VESA[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_VESA[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_VESA[res].VBPart4, 0x1C); -*/ - } - sisReg->VBPart2[0x00] &= ~0x20; /* Temp Disable VB Processor */ - - sisReg->VBPart1[0x00] &= ~GENMASK(4:0); - sisReg->VBPart4[0x0d] &= ~GENMASK(4:3); - switch (pScrn->bitsPerPixel) { - case 8: - sisReg->VBPart4[0x0d] |=0x10; - sisReg->VBPart1[0] |= 0x10; - break; - case 16: - if (pScrn->depth==15) - sisReg->VBPart1[0] |= 0x08; - else - sisReg->VBPart1[0] |= 0x04; - break; - case 24: - sisReg->VBPart1[0] |= 0x02; - break; - case 32: - sisReg->VBPart1[0] |= 0x01; - break; - default: - return FALSE; - } - offset = pSiS->scrnOffset >> 3; /* Scrn Offset */ - sisReg->VBPart1[0x07] = GETVAR8(offset); - sisReg->VBPart1[0x09] &= 0xF0; - sisReg->VBPart1[0x09] |= GETBITS(offset, 11:8); - - sisReg->VBPart1[3] = (offset >> 3)+1; /* CRT2 FIFO Stop */ - - (*pSiS->SetThreshold2)(pScrn, mode, &Threshold_Low, &Threshold_High); - sisReg->VBPart1[1] &= ~GENMASK(4:0); - sisReg->VBPart1[1] |= GETBITS(Threshold_High, 4:0); - sisReg->VBPart1[2] &= ~GENMASK(4:0); - sisReg->VBPart1[2] |= GETBITS(Threshold_Low, 4:0); - - sisReg->sisRegs3D4[0x30] |= 0x01; /* Set Needed Scratch Regs */ - sisReg->sisRegs3D4[0x31] &= ~0x02; - sisReg->sisRegs3D4[0x31] |= 0x40; - - return TRUE; -} - -static int -BppToColor(int bpp) -{ - if (bpp == 8) return 0; - if (bpp == 15) return 1; - if (bpp == 16) return 2; - if (bpp == 24) return 3; - if (bpp == 32) return 4; - return -1; -} - -static int -XYToRes(int x, int y) -{ - if (x==640 && y==480) { - return 0; - } - if (x==800 && y==600) { - return 1; - } - if (x==1024 && y==768) { - return 2; - } - if (x==1280 && y==1024) { - return 3; - } - return -1; -} - -static void -SIS300_LCDPreInit(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - int temp; - - - inSISIDXREG(pSiS->RelIO+SROFFSET, 0x38, temp); - if (!(temp & 0x20)) - return; - - inSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, temp); - if (!(temp & 0x20)) - return; - - inSISIDXREG(pSiS->RelIO+CROFFSET, 0x36, temp); - if (temp == 1) - pSiS->VBFlags = CRT2_LCD | LCD_800x600; - if (temp == 2) - pSiS->VBFlags = CRT2_LCD | LCD_1024x768; - if (temp == 3) - pSiS->VBFlags = CRT2_LCD | LCD_1280x1024; - pSiS->ModeInit2 = SIS301LCDInit; -} - -void -SISLCDPreInit(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - - switch (pSiS->Chipset) { - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - SIS300_LCDPreInit(pScrn); - break; - } -} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c:1.2 Sat Feb 12 18:08:06 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c Fri Dec 1 20:16:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.2 2000/02/12 23:08:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_opt.c,v 1.4 2000/12/02 01:16:18 dawes Exp $ */ #include "xf86.h" @@ -12,7 +12,8 @@ OPTION_NOACCEL, OPTION_TURBOQUEUE, OPTION_FAST_VRAM, - OPTION_SET_MEMCLOCK + OPTION_SET_MEMCLOCK, + OPTION_FORCE_CRT2TYPE } SISOpts; static OptionInfoRec SISOptions[] = { @@ -24,6 +25,7 @@ { OPTION_TURBOQUEUE, "TurboQueue", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SET_MEMCLOCK, "SetMClk", OPTV_FREQ, {0}, -1 }, { OPTION_FAST_VRAM, "FastVram", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FORCE_CRT2TYPE, "ForceCRT2Type",OPTV_ANYSTR, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -33,6 +35,7 @@ SISPtr pSiS = SISPTR(pScrn); MessageType from; double temp; + char *strptr; /* Collect all of the relevant option flags (fill in pScrn->options) */ xf86CollectOptions(pScrn, NULL); @@ -79,11 +82,24 @@ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Fast VRAM enabled\n"); } - if (xf86ReturnOptValBool(SISOptions, OPTION_TURBOQUEUE, FALSE)) { +/* if (xf86ReturnOptValBool(SISOptions, OPTION_TURBOQUEUE, FALSE)) { pSiS->TurboQueue = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Enabling TurboQueue\n"); - } + } */ + pSiS->TurboQueue = TRUE; + + pSiS->ForceCRT2Type= CRT2_DEFAULT; + strptr = (char *)xf86GetOptValString(SISOptions,OPTION_FORCE_CRT2TYPE); + if (strptr != 0) + { + if (!xf86strcmp(strptr,"TV")) + pSiS->ForceCRT2Type = CRT2_TV; + if (!xf86strcmp(strptr,"LCD")) + pSiS->ForceCRT2Type = CRT2_LCD; + if (!xf86strcmp(strptr,"VGA")) + pSiS->ForceCRT2Type = CRT2_VGA; + } } OptionInfoPtr Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h:1.13 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h:1.13 Mon Feb 14 14:20:52 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h Fri Dec 1 20:16:18 2000 @@ -25,7 +25,7 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.13 2000/02/14 19:20:52 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_regs.h,v 1.14 2000/12/02 01:16:18 dawes Exp $ */ #include "vgaHW.h" @@ -98,6 +98,12 @@ #define SISCR pSiS->RelIO+CROFFSET #define SISMISCR pSiS->RelIO+MISCROFFSET #define SISMISCW pSiS->RelIO+MISCWOFFSET +#define SISPART1 pSiS->RelIO+0x04 +#define SISPART2 pSiS->RelIO+0x10 +#define SISPART3 pSiS->RelIO+0x12 +#define SISPART4 pSiS->RelIO+0x14 +#define SISPART5 pSiS->RelIO+0x16 + /* 3C4 */ #define BankReg 0x06 Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c:1.2 Fri Mar 31 15:13:37 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c Thu Nov 9 06:32:22 2000 @@ -25,16 +25,10 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.2 2000/03/31 20:13:37 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.3 2000/11/09 11:32:22 alanh Exp $ */ -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" #include "xf1bpp.h" #include "xf4bpp.h" #include "mibank.h" Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c:removed --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c:1.3 Tue Apr 4 15:25:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c Mon Dec 18 14:31:09 2000 @@ -1,190 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c,v 1.3 2000/04/04 19:25:16 dawes Exp $ */ - -#include "xf86.h" -#include "xf86_ansic.h" -#include "compiler.h" -#include "xf86PciInfo.h" - -#include "sis.h" -#include "sis_regs.h" -#include "sis_tv.h" - - - -static Bool SIS301TVInit(ScrnInfoPtr pScrn, DisplayModePtr mode); - -static int XYToRes(int x, int y); -static int BppToColor(int bpp); - - -static Bool -SIS301TVInit(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - SISPtr pSiS = SISPTR(pScrn); - SISRegPtr sisReg = &pSiS->ModeReg; - int res, color; - unsigned short offset, Threshold_Low, Threshold_High; - - if (mode->Flags & V_INTERLACE) - res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay*2); - else - res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay); - color = BppToColor(pScrn->bitsPerPixel); - if ((res == -1) || (color == -1)) - return FALSE; - - switch (pSiS->VBFlags & TV_TYPE) { - case TV_PAL: - if (mode->CrtcHDisplay > 800) - return FALSE; - memcpy(sisReg->VBPart1, sis301_PAL[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_PAL[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_PAL[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_PAL[res].VBPart4, 0x1C); - break; - case TV_HIVISION: - if (mode->CrtcHDisplay > 1280) - return FALSE; -/* - memcpy(sisReg->VBPart1, sis301_2[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_2[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_2[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_2[res].VBPart4, 0x1C); -*/ - break; - case TV_NTSC: - default: - if (mode->CrtcHDisplay > 800) - return FALSE; - memcpy(sisReg->VBPart1, sis301_NTSC[res].VBPart1, 0x29); - memcpy(sisReg->VBPart2, sis301_NTSC[res].VBPart2, 0x46); - memcpy(sisReg->VBPart3, sis301_NTSC[res].VBPart3, 0x3F); - memcpy(sisReg->VBPart4, sis301_NTSC[res].VBPart4, 0x1C); - break; - } - sisReg->VBPart1[0x00] &= ~GENMASK(4:0); - sisReg->VBPart4[0x0d] &= ~GENMASK(4:3); - switch (pScrn->bitsPerPixel) { - case 8: - sisReg->VBPart4[0x0d] |=0x10; - sisReg->VBPart1[0] |= 0x10; - break; - case 16: - if (pScrn->depth==15) - sisReg->VBPart1[0] |= 0x08; - else - sisReg->VBPart1[0] |= 0x04; - break; - case 24: - sisReg->VBPart1[0] |= 0x02; - break; - case 32: - sisReg->VBPart1[0] |= 0x01; - break; - default: - return FALSE; - } - /* Set TV Interface */ - sisReg->VBPart2[0] &= GENMASK(4:4) | GENMASK(0:0); - switch (pSiS->VBFlags & TV_INTERFACE) { - case TV_SVIDEO: - sisReg->VBPart2[0] |= 0x08; - break; - case TV_SCART: - sisReg->VBPart2[0] |= 0x02; - break; - case TV_AVIDEO: /* Composite */ - default: - sisReg->VBPart2[0] |= 0x04; - } - - offset = pSiS->scrnOffset >> 3; /* Scrn Offset */ - sisReg->VBPart1[0x07] = GETVAR8(offset); - sisReg->VBPart1[0x09] &= 0xF0; - sisReg->VBPart1[0x09] |= GETBITS(offset, 11:8); - - sisReg->VBPart1[3] = (offset >> 3)+1; /* CRT2 FIFO Stop */ - - (*pSiS->SetThreshold2)(pScrn, mode, &Threshold_Low, &Threshold_High); - sisReg->VBPart1[1] &= ~GENMASK(4:0); - sisReg->VBPart1[1] |= GETBITS(Threshold_High, 4:0); - sisReg->VBPart1[2] &= ~GENMASK(4:0); - sisReg->VBPart1[2] |= GETBITS(Threshold_Low, 4:0); - - sisReg->sisRegs3D4[0x30] |= 0x01; /* Set Needed Scratch Regs */ - sisReg->sisRegs3D4[0x31] &= ~0x02; - sisReg->sisRegs3D4[0x31] |= 0x40; - - return TRUE; -} - -static int -BppToColor(int bpp) -{ - if (bpp == 8) return 0; - if (bpp == 15) return 1; - if (bpp == 16) return 2; - if (bpp == 24) return 3; - if (bpp == 32) return 4; - return -1; -} - -static int -XYToRes(int x, int y) -{ - if (x==640 && y==480) { - return 0; - } - if (x==800 && y==600) { - return 1; - } - if (x==1024 && y==768) { - return 2; - } - if (x==1280 && y==1024) { - return 3; - } - return -1; -} - -static void -SIS300_TVPreInit(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - int temp; - - inSISIDXREG(pSiS->RelIO+SROFFSET, 0x38, temp); - if (!(temp & 0x20)) - return; - - inSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, temp); - if (temp & 0x10) - pSiS->VBFlags = CRT2_TV | TV_SCART; - else if (temp & 0x08) - pSiS->VBFlags = CRT2_TV | TV_SVIDEO; - else if (temp & 0x04) - pSiS->VBFlags = CRT2_TV | TV_AVIDEO; - else - return; - - inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp); - if (temp & 0x01) - pSiS->VBFlags |= TV_PAL; - else - pSiS->VBFlags |= TV_NTSC; - pSiS->ModeInit2 = SIS301TVInit; -} - -void -SISTVPreInit(ScrnInfoPtr pScrn) -{ - SISPtr pSiS = SISPTR(pScrn); - - switch (pSiS->Chipset) { - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - SIS300_TVPreInit(pScrn); - break; - } -} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c:1.2 --- /dev/null Mon Dec 18 14:31:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c Fri Dec 1 20:16:18 2000 @@ -0,0 +1,74 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.c,v 1.2 2000/12/02 01:16:18 dawes Exp $ */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" + +#include "sis.h" +#include "sis_regs.h" +#include "sis_vb.h" + +void SISLCDPreInit(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + int temp; + + + if (!(pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL))) + return; + + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x32, temp); + if (temp & 0x08) + pSiS->VBFlags |= CRT2_LCD; + + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x36, temp); + if (temp == 1) + pSiS->VBFlags |= LCD_800x600; + if (temp == 2) + pSiS->VBFlags |= LCD_1024x768; + if (temp == 3) + pSiS->VBFlags |= LCD_1280x1024; +} + +void SISTVPreInit(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + int temp; + + if (!(pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL))) + return; + + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x32, temp); + if (temp & 0x04) + pSiS->VBFlags |= (CRT2_TV | TV_SCART); + else if (temp & 0x02) + pSiS->VBFlags |= (CRT2_TV | TV_SVIDEO); + else if (temp & 0x01) + pSiS->VBFlags |= (CRT2_TV | TV_AVIDEO); + else if (temp & 0x40) + pSiS->VBFlags |= (CRT2_TV | TV_HIVISION); + return; + + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp); + if (temp & 0x01) + pSiS->VBFlags |= TV_PAL; + else + pSiS->VBFlags |= TV_NTSC; +} + +void SISCRT2PreInit(ScrnInfoPtr pScrn) +{ + SISPtr pSiS = SISPTR(pScrn); + int temp; + + if (!(pSiS->VBFlags & (VB_301|VB_302|VB_303|VB_LVDS|VB_CHRONTEL))) + return; + + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x32, temp); + if (temp & 0x10) + pSiS->VBFlags |= CRT2_VGA; + + return; + +} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h:1.3 --- /dev/null Mon Dec 18 14:31:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h Fri Dec 1 20:16:18 2000 @@ -0,0 +1,39 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vb.h,v 1.3 2000/12/02 01:16:18 dawes Exp $ */ + +/* CR30 VBInfo = CR31:CR30 */ +#define SET_SIMU_SCAN_MODE 0x0001 +#define SWITCH_TO_CRT2 0x0002 +#define SET_CRT2_TO_AVIDEO 0x0004 /* Composite */ +#define SET_CRT2_TO_SVIDEO 0x0008 +#define SET_CRT2_TO_SCART 0x0010 +#define SET_CRT2_TO_LCD 0x0020 +#define SET_CRT2_TO_RAMDAC 0x0040 +#define SET_CRT2_TO_HIVISION_TV 0x0080 +#define SET_CRT2_TO_TV (SET_CRT2_TO_AVIDEO | SET_CRT2_TO_SVIDEO | \ + SET_CRT2_TO_SCART | SET_CRT2_TO_HIVISION_TV) +/* CR31 */ +#define SET_PAL_TV 0x0100 +#define SET_IN_SLAVE_MODE 0x0200 +#define SET_NO_SIMU_ON_LOCK 0x0400 +#define SET_NO_SIMU_TV_ON_LOCK SET_NO_SIMU_ON_LOCK +#define DISABLE_LOAD_CRT2DAC 0x1000 +#define DISABLE_CRT2_DISPLAY 0x2000 +#define DRIVER_MODE 0x4000 + +Bool SiSSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); +void SetBlock(CARD16 port, CARD8 from, CARD8 to, CARD8 *DataPtr); + +extern void EnableBridge(unsigned short); +extern void DisableBridge(unsigned short); +extern void LockCRT2(unsigned short); +extern void UnLockCRT2(unsigned short); +extern void SetCH7005(unsigned short); +extern unsigned short GetCH7005(unsigned short); + +typedef struct _SiS301Reg { + CARD8 *VBPart1; + CARD8 *VBPart2; + CARD8 *VBPart3; + CARD8 *VBPart4; +} SiS301RegRec, SiS301RegPtr; + Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c:1.3 Fri Mar 31 15:13:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c Fri Dec 1 20:16:18 2000 @@ -25,7 +25,7 @@ * Mitani Hiroshi <hmitani@drl.mei.co.jp> * David Thomas <davtom@dream.org.uk>. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.3 2000/03/31 20:13:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.6 2000/12/02 01:16:18 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -38,14 +38,14 @@ #include "sis.h" #include "sis_regs.h" -#include "sis_bios.h" +#include "sis_vb.h" -#define Midx 0 -#define Nidx 1 -#define VLDidx 2 -#define Pidx 3 -#define PSNidx 4 +#define Midx 0 +#define Nidx 1 +#define VLDidx 2 +#define Pidx 3 +#define PSNidx 4 #define Fref 14318180 /* stability constraints for internal VCO -- MAX_VCO also determines * the maximum Video pixel clock */ @@ -53,11 +53,11 @@ #define MAX_VCO 135000000 #define MAX_VCO_5597 353000000 #define MAX_PSN 0 /* no pre scaler for this chip */ -#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ +#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ -static Bool SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -static Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode); +static Bool SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode); static Bool @@ -65,7 +65,7 @@ { SISPtr pSiS = SISPTR(pScrn); SISRegPtr pReg = &pSiS->ModeReg; - vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg; + vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg; int gap, safetymargin, MemBand; int vgaIOBase; unsigned char temp; @@ -90,11 +90,11 @@ pSiS->scrnOffset = pScrn->displayWidth * pScrn->bitsPerPixel / 8; if ((mode->Flags & V_INTERLACE)==0) { - offset = pScrn->displayWidth >> 3; - pReg->sisRegs3C4[0x06] &= 0xDF; + offset = pScrn->displayWidth >> 3; + pReg->sisRegs3C4[0x06] &= 0xDF; } else { - offset = pScrn->displayWidth >> 2; - pReg->sisRegs3C4[0x06] |= 0x20; + offset = pScrn->displayWidth >> 2; + pReg->sisRegs3C4[0x06] |= 0x20; } /* Enable Linear */ @@ -102,218 +102,219 @@ case PCI_CHIP_SIS5597: case PCI_CHIP_SIS6326: case PCI_CHIP_SIS530: - pReg->sisRegs3C4[BankReg] |= 0x82; - pReg->sisRegs3C4[0x0C] |= 0xA0; - pReg->sisRegs3C4[0x0B] |= 0x60; - break; + pReg->sisRegs3C4[BankReg] |= 0x82; + pReg->sisRegs3C4[0x0C] |= 0xA0; + pReg->sisRegs3C4[0x0B] |= 0x60; + break; default: - pReg->sisRegs3C4[BankReg] |= 0x82; + pReg->sisRegs3C4[BankReg] |= 0x82; } switch (pScrn->bitsPerPixel) { - case 8: - break; - case 15: - offset <<= 1; - pReg->sisRegs3C4[BankReg] |= 0x04; - break; - case 16: - offset <<= 1; - pReg->sisRegs3C4[BankReg] |= 0x08; - break; - case 24: - offset += (offset << 1); - pReg->sisRegs3C4[BankReg] |= 0x10; - pReg->sisRegs3C4[MMIOEnable] |= 0x90; - break; - case 32: - offset <<= 2; - if (pSiS->Chipset == PCI_CHIP_SIS530) { - pReg->sisRegs3C4[BankReg] |= 0x10; - pReg->sisRegs3C4[MMIOEnable] |= 0x90; - pReg->sisRegs3C4[0x09] |= 0x80; - } else { - return FALSE; - } - break; + case 8: + break; + case 15: + offset <<= 1; + pReg->sisRegs3C4[BankReg] |= 0x04; + break; + case 16: + offset <<= 1; + pReg->sisRegs3C4[BankReg] |= 0x08; + break; + case 24: + offset += (offset << 1); + pReg->sisRegs3C4[BankReg] |= 0x10; + pReg->sisRegs3C4[MMIOEnable] |= 0x90; + break; + case 32: + offset <<= 2; + if (pSiS->Chipset == PCI_CHIP_SIS530) { + pReg->sisRegs3C4[BankReg] |= 0x10; + pReg->sisRegs3C4[MMIOEnable] |= 0x90; + pReg->sisRegs3C4[0x09] |= 0x80; + } else { + return FALSE; + } + break; } switch (pScrn->videoRam) { - case 512: - temp = 0x00; - break; - case 1024: - temp = 0x20; - break; - case 2048: - temp = 0x40; - break; - case 4096: - temp = 0x60; - break; - case 8192: - temp = 0x80; - break; - default: - temp = 0x20; + case 512: + temp = 0x00; + break; + case 1024: + temp = 0x20; + break; + case 2048: + temp = 0x40; + break; + case 4096: + temp = 0x60; + break; + case 8192: + temp = 0x80; + break; + default: + temp = 0x20; } switch (pSiS->Chipset) { - case PCI_CHIP_SG86C225: - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - pReg->sisRegs3C4[LinearAdd0] = (pSiS->FbAddress & 0x07F80000) >> 19; - pReg->sisRegs3C4[LinearAdd1] =((pSiS->FbAddress & 0xF8000000) >> 27) - | temp; /* Enable linear with max 4M */ - break; - case PCI_CHIP_SIS530: - pReg->sisRegs3C4[LinearAdd0] = (pSiS->FbAddress & 0x07F80000) >> 19; - pReg->sisRegs3C4[LinearAdd1] =((pSiS->FbAddress & 0xF8000000) >> 27) - | temp; /* Enable linear with max 8M */ - break; - } - - /* Screen Offset */ - vgaReg->CRTC[0x13] = offset & 0xFF; - pReg->sisRegs3C4[CRTCOff] = ((offset & 0xF00) >> 4) | - (((mode->CrtcVTotal-2) & 0x400) >> 10 ) | - (((mode->CrtcVDisplay-1) & 0x400) >> 9 ) | - (((mode->CrtcVSyncStart-1) & 0x400) >> 8 ) | - (((mode->CrtcVSyncStart) & 0x400) >> 7 ) ; - - /* Extended Horizontal Overflow Register */ - pReg->sisRegs3C4[0x12] &= 0xE0; - pReg->sisRegs3C4[0x12] |= ( - (((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8 | - (((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7 | - (((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6 | - ((mode->CrtcHSyncStart >> 3) & 0x100) >> 5 | - (((mode->CrtcHBlankEnd >> 3) -1) & 0x40) >> 2); -/* ((mode->CrtcHSyncEnd >> 3) & 0x40) >> 2); */ - - if (mode->CrtcVDisplay > 1024) - /* disable line compare */ - pReg->sisRegs3C4[0x38] |= 0x04; - else - pReg->sisRegs3C4[0x38] &= 0xFB; - - if (( pScrn->depth == 24) || (pScrn->depth == 32) || - (mode->CrtcHDisplay >= 1280)) - /* Enable high speed DCLK */ - pReg->sisRegs3C4[0x3E] |= 1; - else - pReg->sisRegs3C4[0x3E] &= 0xFE; + case PCI_CHIP_SG86C225: + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + pReg->sisRegs3C4[LinearAdd0] = (pSiS->FbAddress & 0x07F80000) >> 19; + pReg->sisRegs3C4[LinearAdd1] =((pSiS->FbAddress & 0xF8000000) >> 27) + | temp; /* Enable linear with max 4M */ + break; + case PCI_CHIP_SIS530: + pReg->sisRegs3C4[LinearAdd0] = (pSiS->FbAddress & 0x07F80000) >> 19; + pReg->sisRegs3C4[LinearAdd1] =((pSiS->FbAddress & 0xF8000000) >> 27) + | temp; /* Enable linear with max 8M */ + break; + } + + /* Screen Offset */ + vgaReg->CRTC[0x13] = offset & 0xFF; + pReg->sisRegs3C4[CRTCOff] = ((offset & 0xF00) >> 4) | + (((mode->CrtcVTotal-2) & 0x400) >> 10 ) | + (((mode->CrtcVDisplay-1) & 0x400) >> 9 ) | + (((mode->CrtcVSyncStart-1) & 0x400) >> 8 ) | + (((mode->CrtcVSyncStart) & 0x400) >> 7 ) ; + + /* Extended Horizontal Overflow Register */ + pReg->sisRegs3C4[0x12] &= 0xE0; + pReg->sisRegs3C4[0x12] |= ( + (((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8 | + (((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7 | + (((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6 | + ((mode->CrtcHSyncStart >> 3) & 0x100) >> 5 | + (((mode->CrtcHBlankEnd >> 3) -1) & 0x40) >> 2); +/* ((mode->CrtcHSyncEnd >> 3) & 0x40) >> 2); */ + + if (mode->CrtcVDisplay > 1024) + /* disable line compare */ + pReg->sisRegs3C4[0x38] |= 0x04; + else + pReg->sisRegs3C4[0x38] &= 0xFB; + + if (( pScrn->depth == 24) || (pScrn->depth == 32) || + (mode->CrtcHDisplay >= 1280)) + /* Enable high speed DCLK */ + pReg->sisRegs3C4[0x3E] |= 1; + else + pReg->sisRegs3C4[0x3E] &= 0xFE; - /* Set vclk */ + /* Set vclk */ if (compute_vclk(clock, &num, &denum, &div, &sbit, &scale)) { - switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - pReg->sisRegs3C4[XR2A] = (num - 1) & 0x7f ; - pReg->sisRegs3C4[XR2A] |= (div == 2) ? 0x80 : 0; - pReg->sisRegs3C4[XR2B] = ((denum -1) & 0x1f); - pReg->sisRegs3C4[XR2B] |= (((scale -1)&3) << 5); - /* When set VCLK, you should set SR13 first */ - if (sbit) - pReg->sisRegs3C4[ClockBase] |= 0x40; - else - pReg->sisRegs3C4[ClockBase] &= 0xBF; + switch (pSiS->Chipset) { + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: + pReg->sisRegs3C4[XR2A] = (num - 1) & 0x7f ; + pReg->sisRegs3C4[XR2A] |= (div == 2) ? 0x80 : 0; + pReg->sisRegs3C4[XR2B] = ((denum -1) & 0x1f); + pReg->sisRegs3C4[XR2B] |= (((scale -1)&3) << 5); + /* When set VCLK, you should set SR13 first */ + if (sbit) + pReg->sisRegs3C4[ClockBase] |= 0x40; + else + pReg->sisRegs3C4[ClockBase] &= 0xBF; - break; - } + break; + } } else { /* if compute_vclk cannot handle the request clock try sisCalcClock! */ - SiSCalcClock(pScrn, clock, 2, vclk); - switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - pReg->sisRegs3C4[XR2A] = (vclk[Midx] - 1) & 0x7f ; - pReg->sisRegs3C4[XR2A] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; - - /* bits [4:0] contain denumerator -MC */ - pReg->sisRegs3C4[XR2B] = (vclk[Nidx] -1) & 0x1f ; - - if (vclk[Pidx] <= 4){ - /* postscale 1,2,3,4 */ - pReg->sisRegs3C4[XR2B] |= (vclk[Pidx] -1 ) << 5 ; - pReg->sisRegs3C4[ClockBase] &= 0xBF; - } else { - /* postscale 6,8 */ - pReg->sisRegs3C4[XR2B] |= ((vclk[Pidx] / 2) -1 ) << 5 ; - pReg->sisRegs3C4[ClockBase] |= 0x40; - } - pReg->sisRegs3C4[XR2B] |= 0x80 ; /* gain for high frequency */ - break; - } + SiSCalcClock(pScrn, clock, 2, vclk); + switch (pSiS->Chipset) { + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: + pReg->sisRegs3C4[XR2A] = (vclk[Midx] - 1) & 0x7f ; + pReg->sisRegs3C4[XR2A] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; + + /* bits [4:0] contain denumerator -MC */ + pReg->sisRegs3C4[XR2B] = (vclk[Nidx] -1) & 0x1f ; + + if (vclk[Pidx] <= 4){ + /* postscale 1,2,3,4 */ + pReg->sisRegs3C4[XR2B] |= (vclk[Pidx] -1 ) << 5 ; + pReg->sisRegs3C4[ClockBase] &= 0xBF; + } else { + /* postscale 6,8 */ + pReg->sisRegs3C4[XR2B] |= ((vclk[Pidx] / 2) -1 ) << 5 ; + pReg->sisRegs3C4[ClockBase] |= 0x40; + } + pReg->sisRegs3C4[XR2B] |= 0x80 ; /* gain for high frequency */ + break; + } } /* end of set vclk */ - if (clock > 135000) - pReg->sisRegs3C4[ClockReg] |= 0x02; + if (clock > 135000) + pReg->sisRegs3C4[ClockReg] |= 0x02; - pReg->sisRegs3C2 = inb(0x3CC) | 0x0C; /* Programmable Clock */ + /*pReg->sisRegs3C2 = inb(0x3CC) | 0x0C;*/ /* Programmable Clock */ + pReg->sisRegs3C2 = inb(pSiS->RelIO+0x4c) | 0x0C; /* Programmable Clock */ if (pSiS->FastVram && ((pSiS->Chipset == PCI_CHIP_SIS530) || - (pSiS->Chipset == PCI_CHIP_SIS6326) || - (pSiS->Chipset == PCI_CHIP_SIS5597))) - pReg->sisRegs3C4[ExtMiscCont5]|= 0xC0; + (pSiS->Chipset == PCI_CHIP_SIS6326) || + (pSiS->Chipset == PCI_CHIP_SIS5597))) + pReg->sisRegs3C4[ExtMiscCont5]|= 0xC0; else - pReg->sisRegs3C4[ExtMiscCont5]&= ~0xC0; + pReg->sisRegs3C4[ExtMiscCont5]&= ~0xC0; pSiS->ValidWidth = TRUE; if ((pSiS->Chipset == PCI_CHIP_SIS5597) || - (pSiS->Chipset == PCI_CHIP_SIS6326) || - (pSiS->Chipset == PCI_CHIP_SIS530)) + (pSiS->Chipset == PCI_CHIP_SIS6326) || + (pSiS->Chipset == PCI_CHIP_SIS530)) { - pReg->sisRegs3C4[GraphEng] &= 0xCF; /* Clear logical width bits */ - if (pScrn->bitsPerPixel == 24) { - pReg->sisRegs3C4[GraphEng] |= 0x30; /* Invalid logical width */ - pSiS->ValidWidth = FALSE; - } - else { - switch ( pScrn->virtualX * (pScrn->bitsPerPixel >> 3) ) { - case 1024: - pReg->sisRegs3C4[GraphEng] |= 0x00; /* | 00 = No change */ - break; - case 2048: - pReg->sisRegs3C4[GraphEng] |= 0x10; - break; - case 4096: - pReg->sisRegs3C4[GraphEng] |= 0x20; - break; - default: - /* Invalid logical width */ - pReg->sisRegs3C4[GraphEng] = 0x30; - pSiS->ValidWidth = FALSE; - break; - } - } + pReg->sisRegs3C4[GraphEng] &= 0xCF; /* Clear logical width bits */ + if (pScrn->bitsPerPixel == 24) { + pReg->sisRegs3C4[GraphEng] |= 0x30; /* Invalid logical width */ + pSiS->ValidWidth = FALSE; + } + else { + switch ( pScrn->virtualX * (pScrn->bitsPerPixel >> 3) ) { + case 1024: + pReg->sisRegs3C4[GraphEng] |= 0x00; /* | 00 = No change */ + break; + case 2048: + pReg->sisRegs3C4[GraphEng] |= 0x10; + break; + case 4096: + pReg->sisRegs3C4[GraphEng] |= 0x20; + break; + default: + /* Invalid logical width */ + pReg->sisRegs3C4[GraphEng] = 0x30; + pSiS->ValidWidth = FALSE; + break; + } + } } PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, - "virtualX = %d depth = %d Logical width = %d\n", - pScrn->virtualX, pScrn->bitsPerPixel, - pScrn->virtualX * pScrn->bitsPerPixel/8)); + "virtualX = %d depth = %d Logical width = %d\n", + pScrn->virtualX, pScrn->bitsPerPixel, + pScrn->virtualX * pScrn->bitsPerPixel/8)); if (!pSiS->NoAccel) { - switch (pSiS->Chipset) { - case PCI_CHIP_SIS5597: - case PCI_CHIP_SIS6326: - case PCI_CHIP_SIS530: - pReg->sisRegs3C4[GraphEng] |= 0x40; - if (pSiS->TurboQueue) { - pReg->sisRegs3C4[GraphEng] |= 0x80; - /* All Queue for 2D */ - pReg->sisRegs3C4[ExtMiscCont9] &= 0xFC; - if (pSiS->HWCursor) - pReg->sisRegs3C4[TurboQueueBase] = (pScrn->videoRam/32) - 2; - else - pReg->sisRegs3C4[TurboQueueBase] = (pScrn->videoRam/32) - 1; - } - pReg->sisRegs3C4[MMIOEnable] |= 0x60; /* At PCI base */ - pReg->sisRegs3C4[Mode64] |= 0x80; - break; - } + switch (pSiS->Chipset) { + case PCI_CHIP_SIS5597: + case PCI_CHIP_SIS6326: + case PCI_CHIP_SIS530: + pReg->sisRegs3C4[GraphEng] |= 0x40; + if (pSiS->TurboQueue) { + pReg->sisRegs3C4[GraphEng] |= 0x80; + /* All Queue for 2D */ + pReg->sisRegs3C4[ExtMiscCont9] &= 0xFC; + if (pSiS->HWCursor) + pReg->sisRegs3C4[TurboQueueBase] = (pScrn->videoRam/32) - 2; + else + pReg->sisRegs3C4[TurboQueueBase] = (pScrn->videoRam/32) - 1; + } + pReg->sisRegs3C4[MMIOEnable] |= 0x60; /* At PCI base */ + pReg->sisRegs3C4[Mode64] |= 0x80; + break; + } } /* Set memclock */ @@ -323,14 +324,14 @@ pReg->sisRegs3C4[MemClock0] = (vclk[Midx] - 1) & 0x7f ; pReg->sisRegs3C4[MemClock0] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; - pReg->sisRegs3C4[MemClock1] = (vclk[Nidx] -1) & 0x1f ; /* bits [4:0] contain denumerator -MC */ + pReg->sisRegs3C4[MemClock1] = (vclk[Nidx] -1) & 0x1f ; /* bits [4:0] contain denumerator -MC */ if (vclk[Pidx] <= 4){ - pReg->sisRegs3C4[MemClock1] |= (vclk[Pidx] -1 ) << 5 ; /* postscale 1,2,3,4 */ - pReg->sisRegs3C4[ClockBase] &= 0x7F; - } else { + pReg->sisRegs3C4[MemClock1] |= (vclk[Pidx] -1 ) << 5 ; /* postscale 1,2,3,4 */ + pReg->sisRegs3C4[ClockBase] &= 0x7F; + } else { pReg->sisRegs3C4[MemClock1] |= ((vclk[Pidx] / 2) -1 ) << 5 ; /* postscale 6,8 */ - pReg->sisRegs3C4[ClockBase] |= 0x80; - } + pReg->sisRegs3C4[ClockBase] |= 0x80; + } #if 1 /* Check programmed memory clock. Enable only to check the above code */ mclk=14318*((pReg->sisRegs3C4[MemClock0] & 0x7f)+1); @@ -344,7 +345,7 @@ } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,2, "Setting memory clock to %.3f MHz\n", - mclk/1000.0); + mclk/1000.0); #endif } } @@ -353,38 +354,39 @@ switch (pSiS->Chipset) { case PCI_CHIP_SIS5597: case PCI_CHIP_SIS6326: - MemBand = sisMemBandWidth(pScrn) / 10 ; - safetymargin = 1; - gap = 4; - - CRT_ENGthreshold = 0x0F; - CRT_CPUthresholdLow = ((pScrn->depth*clock) / MemBand)+safetymargin; - CRT_CPUthresholdHigh =((pScrn->depth*clock) / MemBand)+gap+safetymargin; - - if ( CRT_CPUthresholdLow > (pScrn->depth < 24 ? 0xe:0x0d) ) { - CRT_CPUthresholdLow = (pScrn->depth < 24 ? 0xe:0x0d); - } - - if ( CRT_CPUthresholdHigh > (pScrn->depth < 24 ? 0x10:0x0f) ) { - CRT_CPUthresholdHigh = (pScrn->depth < 24 ? 0x10:0x0f); - } - - pReg->sisRegs3C4[CPUThreshold] = (CRT_ENGthreshold & 0x0F) | - (CRT_CPUthresholdLow & 0x0F)<<4 ; - pReg->sisRegs3C4[CRTThreshold] = CRT_CPUthresholdHigh & 0x0F; + MemBand = sisMemBandWidth(pScrn) / 10 ; + safetymargin = 1; + gap = 4; + + CRT_ENGthreshold = 0x0F; + CRT_CPUthresholdLow = ((pScrn->depth*clock) / MemBand)+safetymargin; + CRT_CPUthresholdHigh =((pScrn->depth*clock) / MemBand)+gap+safetymargin; + + if ( CRT_CPUthresholdLow > (pScrn->depth < 24 ? 0xe:0x0d) ) { + CRT_CPUthresholdLow = (pScrn->depth < 24 ? 0xe:0x0d); + } + + if ( CRT_CPUthresholdHigh > (pScrn->depth < 24 ? 0x10:0x0f) ) { + CRT_CPUthresholdHigh = (pScrn->depth < 24 ? 0x10:0x0f); + } + + pReg->sisRegs3C4[CPUThreshold] = (CRT_ENGthreshold & 0x0F) | + (CRT_CPUthresholdLow & 0x0F)<<4 ; + pReg->sisRegs3C4[CRTThreshold] = CRT_CPUthresholdHigh & 0x0F; - break; + break; case PCI_CHIP_SIS530: - (*pSiS->SetThreshold)(pScrn, mode, &CRT_CPUthresholdLow, - &CRT_CPUthresholdHigh); - pReg->sisRegs3C4[8] = (CRT_CPUthresholdLow & 0xf) << 4 | 0xF; - pReg->sisRegs3C4[9] &= 0xF0; - pReg->sisRegs3C4[9] |= (CRT_CPUthresholdHigh & 0xF); - pReg->sisRegs3C4[0x3F] &= 0xE3; - pReg->sisRegs3C4[0x3F] |= (CRT_CPUthresholdHigh & 0x10) | - (CRT_CPUthresholdLow & 0x10) >> 2 | - 0x08; - break; + (*pSiS->SetThreshold)(pScrn, mode, &CRT_CPUthresholdLow, + &CRT_CPUthresholdHigh); + pReg->sisRegs3C4[8] = (CRT_CPUthresholdLow & 0xf) << 4 | 0xF; + pReg->sisRegs3C4[9] &= 0xF0; + pReg->sisRegs3C4[9] |= (CRT_CPUthresholdHigh & 0xF); + /*pReg->sisRegs3C4[0x3F] &= 0xE3;*/ + pReg->sisRegs3C4[0x3F] &= 0xE3; + pReg->sisRegs3C4[0x3F] |= (CRT_CPUthresholdHigh & 0x10) | + (CRT_CPUthresholdLow & 0x10) >> 2 | + 0x08; + break; } return(TRUE); @@ -393,197 +395,227 @@ Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode) { - SISPtr pSiS = SISPTR(pScrn); - SISRegPtr pReg = &pSiS->ModeReg; - vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg; - int vgaIOBase; - unsigned short temp; - int offset; - int clock = mode->Clock; - unsigned int vclk[5]; - - int num, denum, div, sbit, scale; - unsigned short Threshold_Low, Threshold_High; - - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SIS300Init()\n"); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, - "virtualX = %d depth = %d Logical width = %d\n", - pScrn->virtualX, pScrn->bitsPerPixel, - pScrn->virtualX * pScrn->bitsPerPixel/8); - - vgaHWGetIOBase(VGAHWPTR(pScrn)); - vgaIOBase = VGAHWPTR(pScrn)->IOBase; - - (*pSiS->SiSSave)(pScrn, pReg); - - outw(VGA_SEQ_INDEX, 0x8605); - - pReg->sisRegs3C4[6] &= ~GENMASK(4:2); - - switch (pScrn->bitsPerPixel) { - case 8: - pSiS->DstColor = 0x0000; - pReg->sisRegs3C4[6] |= 0x03; - break; - case 16: - if (pScrn->depth==15) { - pSiS->DstColor = 0x4000; - pReg->sisRegs3C4[6] |= ((1 << 2) | 0x03); - } else { - pSiS->DstColor = (short) 0x8000; - pReg->sisRegs3C4[6] |= ((2 << 2) | 0x03); - } - break; - case 24: - pReg->sisRegs3C4[6] |= ((3 << 2) | 0x03); - break; - case 32: - pSiS->DstColor = (short) 0xC000; - pReg->sisRegs3C4[6] |= ((4 << 2) | 0x03); - break; - } - - pSiS->scrnOffset = pScrn->displayWidth * ((pScrn->bitsPerPixel+7)/8); - - pReg->sisRegs3D4[0x19] = 0; - pReg->sisRegs3D4[0x1A] &= 0xFC; - - if (mode->Flags & V_INTERLACE) { - offset = pSiS->scrnOffset >> 2; - pReg->sisRegs3C4[0x06] |= 0x20; - if (pSiS->Chipset != PCI_CHIP_SIS300) { - temp = (mode->CrtcHSyncStart >> 3) - - (mode->CrtcHTotal >> 3)/2; - pReg->sisRegs3D4[0x19] = GETVAR8(temp); - pReg->sisRegs3D4[0x1A] |= GETBITS(temp, 9:8); - } - } else { - offset = pSiS->scrnOffset >> 3; - pReg->sisRegs3C4[0x06] &= ~0x20; - } - - pReg->sisRegs3C4[0x07] |= 0x10; /* enable High Speed DAC */ - pReg->sisRegs3C4[0x07] &= 0xFC; - if (clock < 100000) - pReg->sisRegs3C4[0x07] |= 0x03; - else if (clock < 200000) - pReg->sisRegs3C4[0x07] |= 0x02; - else if (clock < 250000) - pReg->sisRegs3C4[0x07] |= 0x01; - - /* Extended Vertical Overflow */ - pReg->sisRegs3C4[0x0A] = - GETBITSTR(mode->CrtcVTotal -2, 10:10, 0:0) | - GETBITSTR(mode->CrtcVDisplay -1, 10:10, 1:1) | - GETBITSTR(mode->CrtcVBlankStart , 10:10, 2:2) | - GETBITSTR(mode->CrtcVSyncStart , 10:10, 3:3) | - GETBITSTR(mode->CrtcVBlankEnd , 8:8, 4:4) | - GETBITSTR(mode->CrtcVSyncEnd , 4:4, 5:5) ; - - /* Extended Horizontal Overflow */ - pReg->sisRegs3C4[0x0B] = - GETBITSTR((mode->CrtcHTotal >> 3) - 5, 9:8, 1:0) | - GETBITSTR((mode->CrtcHDisplay >> 3) - 1, 9:8, 3:2) | - GETBITSTR((mode->CrtcHBlankStart >> 3) , 9:8, 5:4) | - GETBITSTR((mode->CrtcHSyncStart >> 3) , 9:8, 7:6) ; - - pReg->sisRegs3C4[0x0C] &= 0xF8; - pReg->sisRegs3C4[0x0C] |= - GETBITSTR(mode->CrtcHBlankEnd >> 3, 7:6, 1:0) | - GETBITSTR(mode->CrtcHSyncEnd >> 3, 5:5, 2:2) ; - - /* Screen Offset */ - vgaReg->CRTC[0x13] = GETVAR8(offset); - pReg->sisRegs3C4[0x0E] &= 0xF0; - pReg->sisRegs3C4[0x0E] |= GETBITS(offset, 11:8); - - /* line compare */ - if (mode->CrtcHDisplay > 0) - pReg->sisRegs3C4[0x0F] |= 0x08; - else - pReg->sisRegs3C4[0x0F] &= 0xF7; + SISPtr pSiS = SISPTR(pScrn); + SISRegPtr pReg = &pSiS->ModeReg; + vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg; + int vgaIOBase; + unsigned short temp; + int offset; + int clock = mode->Clock; + unsigned int vclk[5]; + + int num, denum, div, sbit, scale; + unsigned short Threshold_Low, Threshold_High; + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SIS300Init()\n"); + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "virtualX = %d depth = %d Logical width = %d\n", + pScrn->virtualX, pScrn->bitsPerPixel, + pScrn->virtualX * pScrn->bitsPerPixel/8); + + vgaHWGetIOBase(VGAHWPTR(pScrn)); + vgaIOBase = VGAHWPTR(pScrn)->IOBase; + + (*pSiS->SiSSave)(pScrn, pReg); + + outw(VGA_SEQ_INDEX, 0x8605); + + pReg->sisRegs3C4[6] &= ~GENMASK(4:2); + + switch (pScrn->bitsPerPixel) { + case 8: + pSiS->DstColor = 0x0000; + pReg->sisRegs3C4[6] |= 0x03; + break; + case 16: + if (pScrn->depth==15) { + pSiS->DstColor = 0x4000; + pReg->sisRegs3C4[6] |= ((1 << 2) | 0x03); + } else { + pSiS->DstColor = (short) 0x8000; + pReg->sisRegs3C4[6] |= ((2 << 2) | 0x03); + } + break; + case 24: + pReg->sisRegs3C4[6] |= ((3 << 2) | 0x03); + break; + case 32: + pSiS->DstColor = (short) 0xC000; + pReg->sisRegs3C4[6] |= ((4 << 2) | 0x03); + break; + } + + pSiS->scrnOffset = pScrn->displayWidth * ((pScrn->bitsPerPixel+7)/8); + + pReg->sisRegs3D4[0x19] = 0; + pReg->sisRegs3D4[0x1A] &= 0xFC; + + if (mode->Flags & V_INTERLACE) { + offset = pSiS->scrnOffset >> 2; + pReg->sisRegs3C4[0x06] |= 0x20; + if (pSiS->Chipset != PCI_CHIP_SIS300) { + temp = (mode->CrtcHSyncStart >> 3) - + (mode->CrtcHTotal >> 3)/2; + pReg->sisRegs3D4[0x19] = GETVAR8(temp); + pReg->sisRegs3D4[0x1A] |= GETBITS(temp, 9:8); + } + } else { + offset = pSiS->scrnOffset >> 3; + pReg->sisRegs3C4[0x06] &= ~0x20; + } + + pReg->sisRegs3C4[0x07] |= 0x10; /* enable High Speed DAC */ + pReg->sisRegs3C4[0x07] &= 0xFC; + if (clock < 100000) + pReg->sisRegs3C4[0x07] |= 0x03; + else if (clock < 200000) + pReg->sisRegs3C4[0x07] |= 0x02; + else if (clock < 250000) + pReg->sisRegs3C4[0x07] |= 0x01; + + /* Extended Vertical Overflow */ + pReg->sisRegs3C4[0x0A] = + GETBITSTR(mode->CrtcVTotal -2, 10:10, 0:0) | + GETBITSTR(mode->CrtcVDisplay -1, 10:10, 1:1) | + GETBITSTR(mode->CrtcVBlankStart , 10:10, 2:2) | + GETBITSTR(mode->CrtcVSyncStart , 10:10, 3:3) | + GETBITSTR(mode->CrtcVBlankEnd , 8:8, 4:4) | + GETBITSTR(mode->CrtcVSyncEnd , 4:4, 5:5) ; + + /* Extended Horizontal Overflow */ + pReg->sisRegs3C4[0x0B] = + GETBITSTR((mode->CrtcHTotal >> 3) - 5, 9:8, 1:0) | + GETBITSTR((mode->CrtcHDisplay >> 3) - 1, 9:8, 3:2) | + GETBITSTR((mode->CrtcHBlankStart >> 3) , 9:8, 5:4) | + GETBITSTR((mode->CrtcHSyncStart >> 3) , 9:8, 7:6) ; + + pReg->sisRegs3C4[0x0C] &= 0xF8; + pReg->sisRegs3C4[0x0C] |= + GETBITSTR(mode->CrtcHBlankEnd >> 3, 7:6, 1:0) | + GETBITSTR(mode->CrtcHSyncEnd >> 3, 5:5, 2:2) ; + + /* Screen Offset */ + vgaReg->CRTC[0x13] = GETVAR8(offset); + pReg->sisRegs3C4[0x0E] &= 0xF0; + pReg->sisRegs3C4[0x0E] |= GETBITS(offset, 11:8); + + /* line compare */ + if (mode->CrtcHDisplay > 0) + pReg->sisRegs3C4[0x0F] |= 0x08; + else + pReg->sisRegs3C4[0x0F] &= 0xF7; - pReg->sisRegs3C4[0x10] = - ((mode->CrtcHDisplay *((pScrn->bitsPerPixel+7)/8) + 63) >> 6)+1; + pReg->sisRegs3C4[0x10] = + ((mode->CrtcHDisplay *((pScrn->bitsPerPixel+7)/8) + 63) >> 6)+1; - /* Enable Linear */ - pReg->sisRegs3C4[0x20] |= 0x81; + /* Enable Linear */ + pReg->sisRegs3C4[0x20] |= 0x81; - /* Set vclk */ + /* Set vclk */ if (compute_vclk(clock, &num, &denum, &div, &sbit, &scale)) { - pReg->sisRegs3C4[0x2B] = (num -1) & 0x7f; - if (div == 2) - pReg->sisRegs3C4[0x2B] |= 0x80; - pReg->sisRegs3C4[0x2C] = ((denum -1) & 0x1f); - pReg->sisRegs3C4[0x2C] |= (((scale-1)&3) << 5); - if (sbit) - pReg->sisRegs3C4[0x2C] |= 0x80; - pReg->sisRegs3C4[0x2D] = 0x80; + pReg->sisRegs3C4[0x2B] = (num -1) & 0x7f; + if (div == 2) + pReg->sisRegs3C4[0x2B] |= 0x80; + pReg->sisRegs3C4[0x2C] = ((denum -1) & 0x1f); + pReg->sisRegs3C4[0x2C] |= (((scale-1)&3) << 5); + if (sbit) + pReg->sisRegs3C4[0x2C] |= 0x80; + pReg->sisRegs3C4[0x2D] = 0x80; } - else { + else { /* if compute_vclk cannot handle the request clock try sisCalcClock! */ - SiSCalcClock(pScrn, clock, 2, vclk); - pReg->sisRegs3C4[0x2B] = (vclk[Midx] - 1) & 0x7f ; - pReg->sisRegs3C4[0x2B] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; - - /* bits [4:0] contain denumerator -MC */ - pReg->sisRegs3C4[0x2C] = (vclk[Nidx] -1) & 0x1f ; - - if (vclk[Pidx] <= 4) { - /* postscale 1,2,3,4 */ - pReg->sisRegs3C4[0x2C] |= (vclk[Pidx] -1 ) << 5 ; - pReg->sisRegs3C4[0x2C] &= 0x7F; - } else { - /* postscale 6,8 */ - pReg->sisRegs3C4[0x2C] |= ((vclk[Pidx] / 2) -1 ) << 5 ; - pReg->sisRegs3C4[0x2C] |= 0x80; - } - pReg->sisRegs3C4[0x2D] = 0x80; + SiSCalcClock(pScrn, clock, 2, vclk); + pReg->sisRegs3C4[0x2B] = (vclk[Midx] - 1) & 0x7f ; + pReg->sisRegs3C4[0x2B] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ; + + /* bits [4:0] contain denumerator -MC */ + pReg->sisRegs3C4[0x2C] = (vclk[Nidx] -1) & 0x1f ; + + if (vclk[Pidx] <= 4) { + /* postscale 1,2,3,4 */ + pReg->sisRegs3C4[0x2C] |= (vclk[Pidx] -1 ) << 5 ; + pReg->sisRegs3C4[0x2C] &= 0x7F; + } else { + /* postscale 6,8 */ + pReg->sisRegs3C4[0x2C] |= ((vclk[Pidx] / 2) -1 ) << 5 ; + pReg->sisRegs3C4[0x2C] |= 0x80; + } + pReg->sisRegs3C4[0x2D] = 0x80; } /* end of set vclk */ - if (clock > 150000) { /* enable two-pixel mode */ - pReg->sisRegs3C4[0x07] |= 0x80; - pReg->sisRegs3C4[0x32] |= 0x08; - } else { - pReg->sisRegs3C4[0x07] &= 0x7F; - pReg->sisRegs3C4[0x32] &= 0xF7; - } - - - pReg->sisRegs3C2 = inb(0x3CC) | 0x0C; /* Programmable Clock */ - - if (!pSiS->NoAccel) { - pReg->sisRegs3C4[0x1E] |= 0x42; - if (pSiS->TurboQueue) { /* set Turbo Queue as 512k */ - temp = ((pScrn->videoRam/64)-4); - pReg->sisRegs3C4[0x26] = temp & 0xFF; - pReg->sisRegs3C4[0x27] = ((temp >> 8) & 3) || 0xF0; - } - } - - /* set threshold value */ - (*pSiS->SetThreshold)(pScrn, mode, &Threshold_Low, &Threshold_High); - pReg->sisRegs3C4[0x08] = GETBITSTR(Threshold_Low, 3:0, 7:4) | 0xF; - pReg->sisRegs3C4[0x0F] &= ~GENMASK(5:5); - pReg->sisRegs3C4[0x0F] |= GETBITSTR(Threshold_Low, 4:4, 5:5); - pReg->sisRegs3C4[0x09] &= ~GENMASK(3:0); - pReg->sisRegs3C4[0x09] |= GETBITS(Threshold_High, 3:0); + if (clock > 150000) { /* enable two-pixel mode */ + pReg->sisRegs3C4[0x07] |= 0x80; + pReg->sisRegs3C4[0x32] |= 0x08; + } else { + pReg->sisRegs3C4[0x07] &= 0x7F; + pReg->sisRegs3C4[0x32] &= 0xF7; + } + + /*pReg->sisRegs3C2 = inb(0x3CC) | 0x0C;*/ /* Programmable Clock */ + pReg->sisRegs3C2 = inb(pSiS->RelIO+0x4c) | 0x0C; /*Programmable Clock*/ + + if (!pSiS->NoAccel) { + pReg->sisRegs3C4[0x1E] |= 0x42; + if (pSiS->TurboQueue) { /* set Turbo Queue as 512k */ + temp = ((pScrn->videoRam/64)-4); + pReg->sisRegs3C4[0x26] = temp & 0xFF; + pReg->sisRegs3C4[0x27] = ((temp >> 8) & 3) || 0xF0; + } + } + + /* set threshold value */ + (*pSiS->SetThreshold)(pScrn, mode, &Threshold_Low, &Threshold_High); + pReg->sisRegs3C4[0x08] = GETBITSTR(Threshold_Low, 3:0, 7:4) | 0xF; + pReg->sisRegs3C4[0x0F] &= ~GENMASK(5:5); + pReg->sisRegs3C4[0x0F] |= GETBITSTR(Threshold_Low, 4:4, 5:5); + pReg->sisRegs3C4[0x09] &= ~GENMASK(3:0); + pReg->sisRegs3C4[0x09] |= GETBITS(Threshold_High, 3:0); - return(TRUE); + return(TRUE); } void SISVGAPreInit(ScrnInfoPtr pScrn) { - SISPtr pSiS = SISPTR(pScrn); - - switch (pSiS->Chipset) { - case PCI_CHIP_SIS300: - case PCI_CHIP_SIS630: - case PCI_CHIP_SIS540: - pSiS->ModeInit = SIS300Init; - break; - default: - pSiS->ModeInit = SISInit; - } + SISPtr pSiS = SISPTR(pScrn); + int temp; + unsigned short usOffsetHigh, usOffsetLow, vBiosVersion; + unsigned long ROMAddr = (unsigned long) SISPTR(pScrn)->BIOS; + + usOffsetHigh = *((unsigned char *)(ROMAddr+0x08)) - 0x30; + usOffsetLow = *((unsigned char *)(ROMAddr+0x09)) - 0x30; + vBiosVersion = usOffsetHigh << 4 | usOffsetLow; + if(vBiosVersion < 0x02) + { + outSISIDXREG(pSiS->RelIO+CROFFSET, 0x37, 0); + inSISIDXREG(pSiS->RelIO+CROFFSET, 0x36, temp); + temp &= 0x07; + outSISIDXREG(pSiS->RelIO+CROFFSET, 0x36, temp); + } + outb(SISPART4, 0x00); + temp = inb(SISPART4+1) & 0x0F; + pSiS->VBFlags = 0; /*reset*/ + if (temp == 1) + pSiS->VBFlags|=VB_301; /*301*/ + else if (temp == 2) + pSiS->VBFlags|=VB_302; /*302*/ + else if (temp == 3) + pSiS->VBFlags|=VB_303; /*303*/ + else + { + outb(SISCR, 0x37); + temp = ((inb(SISCR+1))>>1) & 0x07; + if ((temp==2) || (temp==3) || (temp==4)) pSiS->VBFlags|=VB_LVDS; + if (temp==4) pSiS->VBFlags |= VB_CHRONTEL; + } + + switch (pSiS->Chipset) { + case PCI_CHIP_SIS300: + case PCI_CHIP_SIS630: + case PCI_CHIP_SIS540: + pSiS->ModeInit = SIS300Init; + break; + default: + pSiS->ModeInit = SISInit; + } } Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c:1.1 --- /dev/null Mon Dec 18 14:31:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c Fri Dec 1 20:16:19 2000 @@ -0,0 +1,1270 @@ +/*************************************************************************** + +Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_video.c,v 1.1 2000/12/02 01:16:19 dawes Exp $ */ + +/* + * sis_video.c: SIS Xv driver. Based on the mga Xv driver by Mark Vojkovich + * and i810 Xv driver by Jonathan Bian <jonathan.bian@intel.com>. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + * Notes: + * + */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "sis.h" +#include "xf86xv.h" +#include "Xv.h" +#include "xaa.h" +#include "xaalocal.h" +#include "dixstruct.h" + +/* TODO: move to sis_regs.h */ +#include "sis_vidregs.h" + +#define OFF_DELAY 200 /* milliseconds */ +#define FREE_DELAY 60000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 + +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +static XF86VideoAdaptorPtr SISSetupImageVideo(ScreenPtr); +static void SISStopVideo(ScrnInfoPtr, pointer, Bool); +static int SISSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int SISGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +static void SISQueryBestSize(ScrnInfoPtr, Bool, + short, short, short, short, unsigned int *, unsigned int *, pointer); +static int SISPutImage( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, pointer); +static int SISQueryImageAttributes(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); + +static void SISBlockHandler(int, pointer, pointer, pointer); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvContrast, xvColorKey; + +#define IMAGE_MIN_WIDTH 32 +#define IMAGE_MIN_HEIGHT 24 +#define IMAGE_MAX_WIDTH 720 +#define IMAGE_MAX_HEIGHT 576 + +#define DISPMODE_SINGLE1 0x1 +#define DISPMODE_SINGLE2 0x2 +#define DISPMODE_MIRROR 0x4 + +/**************************************************************************** +* raw register access : these routines directly interact with the sis's +* control aperature. must not be called until after +* the board's pci memory has been mapped. +****************************************************************************/ + +static CARD32 _sisread(SISPtr pSIS, CARD32 reg) +{ + return *(pSIS->IOBase + reg); +} + +static void _siswrite(SISPtr pSIS, CARD32 reg, CARD32 data) +{ + *(pSIS->IOBase + reg) = data; +} + +static CARD8 getvideoreg(SISPtr pSIS, CARD8 reg) +{ + outb (pSIS->RelIO + vi_index_offset, reg); + return inb(pSIS->RelIO + vi_data_offset); +} + +static void setvideoreg(SISPtr pSIS, CARD8 reg, CARD8 data) +{ + outb (pSIS->RelIO + vi_index_offset, reg); + outb (pSIS->RelIO + vi_data_offset, data); +} + +static void setvideoregmask(SISPtr pSIS, CARD8 reg, CARD8 data, CARD8 mask) +{ + CARD8 old; + + outb (pSIS->RelIO + vi_index_offset, reg); + old = inb(pSIS->RelIO + vi_data_offset); + data = (data & mask) | (old & (~mask)); + outb (pSIS->RelIO + vi_data_offset, data); +} + +static CARD8 getsrreg(SISPtr pSIS, CARD8 reg) +{ + outb (pSIS->RelIO + sr_index_offset, 0x05); + if (inb (pSIS->RelIO + sr_data_offset) != 0xa1) + outb (pSIS->RelIO + sr_data_offset, 0x86); + outb (pSIS->RelIO + sr_index_offset, reg); + return inb(pSIS->RelIO + sr_data_offset); +} + +static void setsrreg(SISPtr pSIS, CARD8 reg, CARD8 data) +{ + outb (pSIS->RelIO + sr_index_offset, 0x05); + if (inb (pSIS->RelIO + sr_data_offset) != 0xa1) + outb (pSIS->RelIO + sr_data_offset, 0x86); + outb (pSIS->RelIO + sr_index_offset, reg); + outb (pSIS->RelIO + sr_data_offset, data); +} + +static void setsrregmask(SISPtr pSIS, CARD8 reg, CARD8 data, CARD8 mask) +{ + CARD8 old; + + outb (pSIS->RelIO + sr_index_offset, 0x05); + if (inb (pSIS->RelIO + sr_data_offset) != 0xa1) + outb (pSIS->RelIO + sr_data_offset, 0x86); + outb (pSIS->RelIO + sr_index_offset, reg); + old = inb(pSIS->RelIO + sr_data_offset); + data = (data & mask) | (old & (~mask)); + outb (pSIS->RelIO + sr_data_offset, data); +} + +static CARD8 getsisreg(SISPtr pSIS, CARD8 index_offset, CARD8 reg) +{ + outb (pSIS->RelIO + index_offset, reg); + return inb(pSIS->RelIO + index_offset+1); +} + +static void setsisreg(SISPtr pSIS, CARD8 index_offset, CARD8 reg, CARD8 data) +{ + outb (pSIS->RelIO + index_offset, reg); + outb (pSIS->RelIO + index_offset+1, data); +} + +/* VBlank */ +static CARD8 vblank_active_CRT1(SISPtr pSIS) +{ + return (inb(pSIS->RelIO + input_stat) & 0x08); +} + +static CARD8 vblank_active_CRT2(SISPtr pSIS) +{ + return (getsisreg(pSIS, crt2_index_offset, Index_CRT2_FC_VR) & 0x02); +} + +/* Scanline */ +static CARD32 get_scanline_CRT1(SISPtr pSIS) +{ + CARD32 line; + + _siswrite (pSIS, REG_PRIM_CRT_COUNTER, 0x00000001); + line = _sisread (pSIS, REG_PRIM_CRT_COUNTER); + + return ((line >> 16) & 0x07FF); +} + +static CARD32 get_scanline_CRT2(SISPtr pSIS) +{ + CARD32 line; + + line = (CARD32)(getsisreg(pSIS, crt2_index_offset, Index_CRT2_FC_VCount1) & 0x70) * 16 + + getsisreg(pSIS, crt2_index_offset, Index_CRT2_FC_VCount); + + return line; +} + +void SISInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + + if (pScrn->bitsPerPixel != 8) + { + newAdaptor = SISSetupImageVideo(pScreen); + } + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 2 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {16, TrueColor}, {24, TrueColor} +}; + +#define NUM_ATTRIBUTES 3 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}, + {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} +}; + +#define NUM_IMAGES 2 +#define PIXEL_FMT_YV12 0x32315659 +#define PIXEL_FMT_YUY2 0x32595559 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + { + PIXEL_FMT_YUY2, + XvYUV, + LSBFirst, + {'Y','U','Y','2', + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, + 16, + XvPacked, + 1, + 0, 0, 0, 0 , + 8, 8, 8, + 1, 2, 2, + 1, 1, 1, + {'Y','U','Y','V', + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + }, + { + PIXEL_FMT_YV12, + XvYUV, + LSBFirst, + {'Y','V','1','2', + 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, + 12, + XvPlanar, + 3, + 0, 0, 0, 0 , + 8, 8, 8, + 1, 2, 2, + 1, 2, 2, + {'Y','V','U', + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + } +}; + +typedef struct { + int pixelFormat; + + CARD16 pitch; + + CARD8 keyOP; + CARD16 HUSF; + CARD16 VUSF; + CARD8 IntBit; + CARD8 wHPre; + + CARD16 srcW; + CARD16 srcH; + + BoxRec dstBox; + + CARD32 PSY; + CARD32 PSV; + CARD32 PSU; + CARD8 bobEnable; + + CARD8 contrastCtrl; + CARD8 contrastFactor; + + CARD8 lineBufSize; + + CARD8 (*VBlankActiveFunc)(SISPtr); + CARD32 (*GetScanLineFunc)(SISPtr pSIS); +} SISOverlayRec, *SISOverlayPtr; + +typedef struct { + FBAreaPtr fbAreaPtr; + int fbSize; + CARD32 bufAddr[2]; + + unsigned char currentBuf; + + short drw_x, drw_y, drw_w, drw_h; + short src_x, src_y, src_w, src_h; + int id; + short srcPitch, height; + + unsigned char brightness; + unsigned char contrast; + + RegionRec clip; + CARD32 colorKey; + + CARD32 videoStatus; + Time offTime; + Time freeTime; + + CARD32 displayMode; +} SISPortPrivRec, *SISPortPrivPtr; + +#define GET_PORT_PRIVATE(pScrn) \ + (SISPortPrivPtr)((SISPTR(pScrn))->adaptor->pPortPrivates[0].ptr) + + +static void +SISResetVideo(ScrnInfoPtr pScrn) +{ + SISPtr pSIS = SISPTR(pScrn); + + if (getsrreg (pSIS, 0x05) != 0xa1) + { + setsrreg (pSIS, 0x05, 0x86); + if (getsrreg (pSIS, 0x05) != 0xa1) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Standard password not initialize\n"); + } + if (getvideoreg (pSIS, Index_VI_Passwd) != 0xa1) + { + setvideoreg (pSIS, Index_VI_Passwd, 0x86); + if (getvideoreg (pSIS, Index_VI_Passwd) != 0xa1) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Video password not initialize\n"); + } + + /* Initial first set */ + setvideoregmask (pSIS, Index_VI_Control_Misc2, 0x80, 0x81); + setvideoregmask(pSIS, Index_VI_Control_Misc0, 0x00, 0x02); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x02, 0x02); + setvideoregmask(pSIS, Index_VI_Scale_Control, 0x60, 0x60); + setvideoregmask(pSIS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F); + + setvideoreg(pSIS, Index_VI_Disp_Y_Buf_Preset_Low, 0x00); + setvideoreg(pSIS, Index_VI_Disp_Y_Buf_Preset_Middle, 0x00); + setvideoreg(pSIS, Index_VI_UV_Buf_Preset_Low, 0x00); + setvideoreg(pSIS, Index_VI_UV_Buf_Preset_Middle, 0x00); + setvideoreg(pSIS, Index_VI_Disp_Y_UV_Buf_Preset_High, 0x00); + setvideoreg(pSIS, Index_VI_Play_Threshold_Low, 0x00); + setvideoreg(pSIS, Index_VI_Play_Threshold_High, 0x00); + + /* Initial second set */ + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x81, 0x81); + setvideoregmask(pSIS, Index_VI_Control_Misc0, 0x00, 0x02); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x02, 0x02); + setvideoregmask(pSIS, Index_VI_Scale_Control, 0x60, 0x60); + setvideoregmask(pSIS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x1F); + + setvideoreg(pSIS, Index_VI_Disp_Y_Buf_Preset_Low, 0x00); + setvideoreg(pSIS, Index_VI_Disp_Y_Buf_Preset_Middle, 0x00); + setvideoreg(pSIS, Index_VI_UV_Buf_Preset_Low, 0x00); + setvideoreg(pSIS, Index_VI_UV_Buf_Preset_Middle, 0x00); + setvideoreg(pSIS, Index_VI_Disp_Y_UV_Buf_Preset_High, 0x00); + setvideoreg(pSIS, Index_VI_Play_Threshold_Low, 0x00); + setvideoreg(pSIS, Index_VI_Play_Threshold_High, 0x00); + + /* set default contrast */ + setvideoregmask (pSIS, Index_VI_Control_Misc2, 0x00, 0x01); + setvideoregmask (pSIS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07); + setvideoreg (pSIS, Index_VI_Brightness, 0x20); + + setvideoregmask (pSIS, Index_VI_Control_Misc2, 0x01, 0x01); + setvideoregmask (pSIS, Index_VI_Contrast_Enh_Ctrl, 0x04, 0x07); + setvideoreg (pSIS, Index_VI_Brightness, 0x20); + +} + + +static XF86VideoAdaptorPtr +SISSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SISPtr pSIS = SISPTR(pScrn); + XF86VideoAdaptorPtr adapt; + SISPortPrivPtr pPriv; + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(SISPortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "SIS Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPriv = (SISPortPrivPtr)(&adapt->pPortPrivates[1]); + + adapt->pPortPrivates[0].ptr = (pointer)(pPriv); + adapt->pAttributes = Attributes; + adapt->nImages = 2; + adapt->nAttributes = 3; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = SISStopVideo; + adapt->SetPortAttribute = SISSetPortAttribute; + adapt->GetPortAttribute = SISGetPortAttribute; + adapt->QueryBestSize = SISQueryBestSize; + adapt->PutImage = SISPutImage; + adapt->QueryImageAttributes = SISQueryImageAttributes; + + pPriv->colorKey = 0x000101fe; + pPriv->videoStatus = 0; + pPriv->brightness = 0; + pPriv->contrast = 128; + + pPriv->currentBuf = 0; + + pPriv->fbAreaPtr = NULL; + pPriv->fbSize = 0; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + pSIS->adaptor = adapt; + + pSIS->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = SISBlockHandler; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvContrast = MAKE_ATOM("XV_CONTRAST"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + /* set display mode */ + /* TODO: support CRT2-only mode */ + if(pSIS->VBFlags) { + pPriv->displayMode = DISPMODE_MIRROR; + setsrregmask (pSIS, 0x06, 0x80, 0xc0); + setsrregmask (pSIS, 0x32, 0x80, 0xc0); + } + else { + pPriv->displayMode = DISPMODE_SINGLE1; + setsrregmask (pSIS, 0x06, 0x00, 0xc0); + setsrregmask (pSIS, 0x32, 0x00, 0xc0); + } + + SISResetVideo(pScrn); + + return adapt; +} + + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + + + +static int +SISSetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ + SISPortPrivPtr pPriv = (SISPortPrivPtr)data; + + if(attribute == xvBrightness) { + if((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; + } else + if(attribute == xvContrast) { + if((value < 0) || (value > 255)) + return BadValue; + pPriv->contrast = value; + } else + if(attribute == xvColorKey) { + pPriv->colorKey = value; + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else return BadMatch; + + return Success; +} + +static int +SISGetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ + SISPortPrivPtr pPriv = (SISPortPrivPtr)data; + + if(attribute == xvBrightness) { + *value = pPriv->brightness; + } else + if(attribute == xvContrast) { + *value = pPriv->contrast; + } else + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else return BadMatch; + + return Success; +} + +static void +SISQueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; + + /* TODO: report the HW limitation */ +} + + +static void +set_scale_factor(SISOverlayPtr pOverlay) +{ + CARD32 I=0; + + int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; + int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; + int srcW = pOverlay->srcW; + int srcH = pOverlay->srcH; + + int srcPitch = pOverlay->pitch; + + if (dstW == srcW) { + pOverlay->HUSF = 0x00; + pOverlay->IntBit = 0x05; + } + else if (dstW > srcW) { + dstW += 2; + pOverlay->HUSF = (srcW << 16) / dstW; + pOverlay->IntBit = 0x04; + } + else { + int tmpW = dstW; + + I = 0x00; + pOverlay->IntBit = 0x01; + while (srcW >= tmpW) + { + tmpW <<= 1; + I++; + } + pOverlay->wHPre = (CARD8)(I - 1); + dstW <<= (I - 1); + if ((srcW % dstW)) + pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; + else + pOverlay->HUSF = 0x00; + } + + if (dstH == srcH) { + pOverlay->VUSF = 0x00; + pOverlay->IntBit |= 0x0A; + } + else if (dstH > srcH) { + dstH += 0x02; + pOverlay->VUSF = (srcH << 16) / dstH; + pOverlay->IntBit |= 0x08; + } + else { + CARD32 realI; + + I = realI = srcH / dstH; + pOverlay->IntBit |= 0x02; + + if (I < 2) + { + pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; + } + else + { +#if 0 + if (((pOverlay->bobEnable & 0x08) == 0x00) && + (((srcPitch * I)>>2) > 0xFFF)) + { + pOverlay->bobEnable |= 0x08; + srcPitch >>= 1; + } +#endif + if (((srcPitch * I)>>2) > 0xFFF) + { + I = (0xFFF*2/srcPitch); + pOverlay->VUSF = 0xFFFF; + } + else + { + dstH = I * dstH; + if (srcH % dstH) + pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; + else + pOverlay->VUSF = 0x00; + } + /* set video frame buffer offset */ + pOverlay->pitch = (CARD16)(srcPitch*I); + } + } +} + + +static void +set_line_buf_size(SISOverlayPtr pOverlay) +{ + CARD8 preHIDF; + CARD32 I; + CARD32 line = pOverlay->srcW; + + if (pOverlay->pixelFormat == PIXEL_FMT_YV12) + { + preHIDF = pOverlay->wHPre & 0x07; + switch (preHIDF) + { + case 3 : + if ((line & 0xffffff00) == line) + I = (line >> 8); + else + I = (line >> 8) + 1; + pOverlay->lineBufSize = (CARD8)(I * 32 - 1); + break; + case 4 : + if ((line & 0xfffffe00) == line) + I = (line >> 9); + else + I = (line >> 9) + 1; + pOverlay->lineBufSize = (CARD8)(I * 64 - 1); + break; + case 5 : + if ((line & 0xfffffc00) == line) + I = (line >> 10); + else + I = (line >> 10) + 1; + pOverlay->lineBufSize = (CARD8)(I * 128 - 1); + break; + case 6 : + if ((line & 0xfffff800) == line) + I = (line >> 11); + else + I = (line >> 11) + 1; + pOverlay->lineBufSize = (CARD8)(I * 256 - 1); + break; + default : + if ((line & 0xffffff80) == line) + I = (line >> 7); + else + I = (line >> 7) + 1; + pOverlay->lineBufSize = (CARD8)(I * 16 - 1); + break; + } + } + else + { + if ((line & 0xffffff8) == line) + I = (line >> 3); + else + I = (line >> 3) + 1; + pOverlay->lineBufSize = (CARD8)(I - 1); + } +} + +static void +merge_line_buf(SISPtr pSIS, SISPortPrivPtr pPriv, Bool enable) +{ + if(enable) { + if(pPriv->displayMode == DISPMODE_MIRROR) { + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x00, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x04, 0x04); + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x01, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x04, 0x04); + } + else { + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x10, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x00, 0x04); + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x11, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x00, 0x04); + } + } + else { + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x00, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x00, 0x04); + setvideoregmask(pSIS, Index_VI_Control_Misc2, 0x01, 0x11); + setvideoregmask(pSIS, Index_VI_Control_Misc1, 0x00, 0x04); + } +} + + +static void +set_format(SISPtr pSIS, SISOverlayPtr pOverlay) +{ + CARD8 fmt; + + switch (pOverlay->pixelFormat) + { + case PIXEL_FMT_YV12: + fmt = 0x0c; + break; + case PIXEL_FMT_YUY2: + fmt = 0x28; + break; + default: + fmt = 0x00; + break; + } + setvideoregmask(pSIS, Index_VI_Control_Misc0, fmt, 0x7c); +} + +static void +set_colorkey(SISPtr pSIS, CARD32 colorkey) +{ + CARD8 r, g, b; + + b = (CARD8)(colorkey & 0xFF); + g = (CARD8)((colorkey>>8) & 0xFF); + r = (CARD8)((colorkey>>16) & 0xFF); + + /* Activate the colorkey mode */ + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Blue_Min ,(CARD8)b); + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Green_Min ,(CARD8)g); + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Red_Min ,(CARD8)r); + + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Blue_Max ,(CARD8)b); + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Green_Max ,(CARD8)g); + setvideoreg(pSIS, Index_VI_Overlay_ColorKey_Red_Max ,(CARD8)r); +} + + +static void +set_brightness(SISPtr pSIS, CARD8 brightness) +{ + setvideoreg(pSIS, Index_VI_Brightness ,brightness); +} + + +static void +set_overlay(SISPtr pSIS, SISOverlayPtr pOverlay) +{ + ScrnInfoPtr pScrn = pSIS->pScrn; + + CARD16 pitch=0; + CARD8 h_over=0, v_over=0; + CARD16 bottom, right; + CARD16 screenX = pScrn->currentMode->HDisplay; + CARD16 screenY = pScrn->currentMode->VDisplay; + + bottom = pOverlay->dstBox.y2; + if (bottom > screenY) + bottom = screenY; + + right = pOverlay->dstBox.x2; + if (right > screenX) + right = screenX; + + h_over = (((pOverlay->dstBox.x1>>8) & 0x0f) | ((right>>4) & 0xf0)); + v_over = (((pOverlay->dstBox.y1>>8) & 0x0f) | ((bottom>>4) & 0xf0)); + + pitch = pOverlay->pitch; + + /* set line buffer size */ + setvideoreg(pSIS, Index_VI_Line_Buffer_Size, pOverlay->lineBufSize); + + setvideoregmask (pSIS, Index_VI_Key_Overlay_OP, pOverlay->keyOP, 0x0f); + + while (pOverlay->VBlankActiveFunc(pSIS)); + while (!pOverlay->VBlankActiveFunc(pSIS)); + + setvideoreg (pSIS, Index_VI_Disp_Y_Buf_Pitch_Low, (CARD8)(pitch>>2)); + setvideoregmask (pSIS, Index_VI_Disp_Y_UV_Buf_Pitch_High, (CARD8)(pitch >> 10), 0x0f); + + setvideoregmask (pSIS, Index_VI_Control_Misc1, 0x20, 0x20); + if (pOverlay->pixelFormat == PIXEL_FMT_YV12) + { + CARD32 PSU=0, PSV=0; + + PSU = pOverlay->PSU; + PSV = pOverlay->PSV; + + setvideoreg (pSIS, Index_VI_Disp_UV_Buf_Pitch_Low, (CARD8)(pitch >> 3)); + setvideoregmask (pSIS, Index_VI_Disp_Y_UV_Buf_Pitch_High, (CARD8)(pitch >> 7), 0xf0); + /* set U/V start address */ + setvideoreg (pSIS, Index_VI_U_Buf_Start_Low, (CARD8)PSU); + setvideoreg (pSIS, Index_VI_U_Buf_Start_Middle,(CARD8)(PSU>>8)); + setvideoreg (pSIS, Index_VI_U_Buf_Start_High, (CARD8)(PSU>>16)); + + setvideoreg (pSIS, Index_VI_V_Buf_Start_Low, (CARD8)PSV); + setvideoreg (pSIS, Index_VI_V_Buf_Start_Middle,(CARD8)(PSV>>8)); + setvideoreg (pSIS, Index_VI_V_Buf_Start_High, (CARD8)(PSV>>16)); + } + /* set scale factor */ + setvideoreg (pSIS, Index_VI_Hor_Post_Up_Scale_Low, (CARD8)(pOverlay->HUSF)); + setvideoreg (pSIS, Index_VI_Hor_Post_Up_Scale_High,(CARD8)((pOverlay->HUSF)>>8)); + setvideoreg (pSIS, Index_VI_Ver_Up_Scale_Low, (CARD8)(pOverlay->VUSF)); + setvideoreg (pSIS, Index_VI_Ver_Up_Scale_High, (CARD8)((pOverlay->VUSF)>>8)); + + setvideoregmask (pSIS, Index_VI_Scale_Control, (pOverlay->IntBit << 3)|(pOverlay->wHPre), 0x7f); + + /* set destination position */ + setvideoreg(pSIS, Index_VI_Win_Hor_Disp_Start_Low, (CARD8)pOverlay->dstBox.x1); + setvideoreg(pSIS, Index_VI_Win_Hor_Disp_End_Low, (CARD8)right); + setvideoreg(pSIS, Index_VI_Win_Hor_Over, (CARD8)h_over); + + setvideoreg(pSIS, Index_VI_Win_Ver_Disp_Start_Low, (CARD8)pOverlay->dstBox.y1); + setvideoreg(pSIS, Index_VI_Win_Ver_Disp_End_Low, (CARD8)bottom); + setvideoreg(pSIS, Index_VI_Win_Ver_Over, (CARD8)v_over); + + /* set display start address */ + setvideoreg (pSIS, Index_VI_Disp_Y_Buf_Start_Low, (CARD8)(pOverlay->PSY)); + setvideoreg (pSIS, Index_VI_Disp_Y_Buf_Start_Middle, (CARD8)((pOverlay->PSY)>>8)); + setvideoreg (pSIS, Index_VI_Disp_Y_Buf_Start_High, (CARD8)((pOverlay->PSY)>>16)); + setvideoregmask(pSIS, Index_VI_Control_Misc1, pOverlay->bobEnable, 0x1a); + setvideoregmask (pSIS, Index_VI_Control_Misc1, 0x00, 0x20); + + /* set contrast factor */ +/* + setvideoregmask(pSIS, Index_VI_Contrast_Enh_Ctrl, pOverlay->contrastCtrl<<6, 0xc0); + setvideoreg (pSIS, Index_VI_Contrast_Factor, pOverlay->contrastFactor); +*/ +} + + +static void +close_overlay(SISPtr pSIS, SISPortPrivPtr pPriv) +{ + setvideoregmask (pSIS, Index_VI_Control_Misc2, 0, 0x01); + setvideoregmask(pSIS, Index_VI_Control_Misc0, 0x00, 0x02); + setvideoregmask (pSIS, Index_VI_Control_Misc2, 1, 0x01); + setvideoregmask(pSIS, Index_VI_Control_Misc0, 0x00, 0x02); +} + + +static void +SISDisplayVideo(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) +{ + SISPtr pSIS = SISPTR(pScrn); + + short srcPitch = pPriv->srcPitch; + short height = pPriv->height; + SISOverlayRec overlay; + int srcOffsetX=0, srcOffsetY=0; + int sx, sy; + int index = 0; + + memset(&overlay, 0, sizeof(overlay)); + overlay.pixelFormat = pPriv->id; + overlay.pitch = srcPitch; + overlay.keyOP = 0x03; + /* overlay.bobEnable = 0x02; */ + overlay.bobEnable = 0x00; + + overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; + overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; + overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; + overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; + + /* FIXME: assume (x2 > x1), (y2 > y1) */ + if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) + return; + + if(overlay.dstBox.x1 < 0) { + srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; + overlay.dstBox.x1 = 0; + } + if(overlay.dstBox.y1 < 0) { + srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; + overlay.dstBox.y1 = 0; + } + + switch(pPriv->id){ + case PIXEL_FMT_YV12: + sx = (pPriv->src_x + srcOffsetX) & ~7; + sy = (pPriv->src_y + srcOffsetY) & ~1; + overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; + overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); + overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); + overlay.PSY >>= 2; + overlay.PSV >>= 2; + overlay.PSU >>= 2; + break; + case PIXEL_FMT_YUY2: + default: + sx = (pPriv->src_x + srcOffsetX) & ~1; + sy = (pPriv->src_y + srcOffsetY); + overlay.PSY = (pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch) >> 2; + break; + } + + /* FIXME: is it possible that srcW < 0 */ + overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); + overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); + + /* merge line buffer */ + /* TODO: unnecessay to do it several times */ + merge_line_buf (pSIS, pPriv, (overlay.srcW > 384)); + + /* set line buffer length */ + set_line_buf_size (&overlay); + + /* set scale factor */ + set_scale_factor (&overlay); + + if(pPriv->displayMode == DISPMODE_SINGLE2) { + index = 1; + overlay.VBlankActiveFunc = vblank_active_CRT2; + overlay.GetScanLineFunc = get_scanline_CRT2; + } + else { + index = 0; + overlay.VBlankActiveFunc = vblank_active_CRT1; + overlay.GetScanLineFunc = get_scanline_CRT1; + } + +MIRROR: + + setvideoregmask (pSIS, Index_VI_Control_Misc2, index, 0x01); + + /* set scale temporarily */ + { + int dstW = overlay.dstBox.x2 - overlay.dstBox.x1; + int srcW = overlay.srcW; + unsigned char i = 0; + + dstW <<= 1; + while(srcW > dstW) { + dstW <<= 1; + i++; + } + setvideoregmask (pSIS, Index_VI_Scale_Control, i, 0x07); + } + + /* set format */ + set_format(pSIS, &overlay); + + /* set color key */ + /* TODO: update only when colorkey changed */ + /* FIXME, is the RGB order correct? */ + set_colorkey(pSIS, pPriv->colorKey); + + /* set brightness */ + set_brightness(pSIS, pPriv->brightness); + + /* set overlay */ + set_overlay(pSIS, &overlay); + + /* enable overlay */ + setvideoregmask (pSIS, Index_VI_Control_Misc0, 0x02, 0x02); + + if((pPriv->displayMode == DISPMODE_MIRROR) && (index == 0)) { + index = 1; + overlay.VBlankActiveFunc = vblank_active_CRT2; + overlay.GetScanLineFunc = get_scanline_CRT2; + goto MIRROR; + } +} + + +static void +SISStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + SISPortPrivPtr pPriv = (SISPortPrivPtr)data; + SISPtr pSIS = SISPTR(pScrn); + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + close_overlay(pSIS, pPriv); + } + if(pPriv->fbAreaPtr) { + xf86FreeOffscreenArea(pPriv->fbAreaPtr); + pPriv->fbAreaPtr = NULL; + pPriv->fbSize = 0; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + /* FIXME */ +/* SISDisplayVideo(pScrn, pPriv); */ + } + } +} + + +static int +SISPutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data +){ + SISPtr pSIS = SISPTR(pScrn); + SISPortPrivPtr pPriv = (SISPortPrivPtr)data; + + int totalSize=0; + + pPriv->drw_x = drw_x; + pPriv->drw_y = drw_y; + pPriv->drw_w = drw_w; + pPriv->drw_h = drw_h; + pPriv->src_x = src_x; + pPriv->src_y = src_y; + pPriv->src_w = src_w; + pPriv->src_h = src_h; + pPriv->id = id; + pPriv->height = height; + + switch(id){ + case PIXEL_FMT_YV12: + pPriv->srcPitch = (width + 7) & ~7; + totalSize = (pPriv->srcPitch * height * 3) >> 1; + break; + case PIXEL_FMT_YUY2: + default: + pPriv->srcPitch = (width*2 + 3) & ~3; + totalSize = pPriv->srcPitch * height; + } + + /* allocate memory */ + do { + int lines, pitch, depth; + BoxPtr pBox; + + if(totalSize == pPriv->fbSize) + break; + + pPriv->fbSize = totalSize; + + /* TODO: use xf86AllocateOffscreenLinear is better */ + if(pPriv->fbAreaPtr) { + /* TODO: resize */ + xf86FreeOffscreenArea(pPriv->fbAreaPtr); + } + depth = (pScrn->bitsPerPixel + 7 ) / 8; + pitch = pScrn->displayWidth * depth; + lines = ((totalSize * 2) / pitch) + 1; + pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, + pScrn->displayWidth, + lines, 0, NULL, NULL, NULL); + + if(!pPriv->fbAreaPtr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Allocate video memory fails\n"); + return BadAlloc; + } + pBox = &(pPriv->fbAreaPtr->box); + pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); + pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; + } while(0); + + /* copy data */ + /* TODO: subimage */ + memcpy(pSIS->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); + + SISDisplayVideo(pScrn, pPriv); + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + if (pPriv->currentBuf == 0) + pPriv->currentBuf = 1; + else + pPriv->currentBuf = 0; + + pPriv->videoStatus = CLIENT_VIDEO_ON; + + return Success; +} + + +static int +SISQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int pitchY, pitchUV; + int size, sizeY, sizeUV; + + if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; + if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; + + if(*w > IMAGE_MAX_WIDTH) *w = IMAGE_MAX_WIDTH; + if(*h > IMAGE_MAX_HEIGHT) *h = IMAGE_MAX_HEIGHT; + + switch(id) { + case PIXEL_FMT_YV12: + *w = (*w + 7) & ~7; + *h = (*h + 1) & ~1; + pitchY = *w; + pitchUV = *w >> 1; + if(pitches) { + pitches[0] = pitchY; + pitches[1] = pitches[2] = pitchUV; + } + sizeY = pitchY * (*h); + sizeUV = pitchUV * ((*h) >> 1); + if(offsets) { + offsets[0] = 0; + offsets[1] = sizeY; + offsets[2] = sizeY + sizeUV; + } + size = sizeY + (sizeUV << 1); + break; + case PIXEL_FMT_YUY2: + default: + *w = (*w + 1) & ~1; + pitchY = *w << 1; + if(pitches) pitches[0] = pitchY; + if(offsets) offsets[0] = 0; + size = pitchY * (*h); + break; + } + + return size; +} + +static void +SISBlockHandler ( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask +){ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + SISPtr pSIS = SISPTR(pScrn); + SISPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); + + pScreen->BlockHandler = pSIS->BlockHandler; + + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + + pScreen->BlockHandler = SISBlockHandler; + + if(pPriv->videoStatus & TIMER_MASK) { + UpdateCurrentTime(); + if(pPriv->videoStatus & OFF_TIMER) { + if(pPriv->offTime < currentTime.milliseconds) { + /* Turn off the overlay */ + close_overlay(pSIS, pPriv); + + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + } + } else { /* FREE_TIMER */ + if(pPriv->freeTime < currentTime.milliseconds) { + if(pPriv->fbAreaPtr) { + xf86FreeOffscreenArea(pPriv->fbAreaPtr); + pPriv->fbAreaPtr = NULL; + pPriv->fbSize = 0; + } + pPriv->videoStatus = 0; + } + } + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vidregs.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vidregs.h:1.2 --- /dev/null Mon Dec 18 14:31:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vidregs.h Mon Dec 4 13:50:01 2000 @@ -0,0 +1,156 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vidregs.h,v 1.2 2000/12/04 18:50:01 dawes Exp $ */ + +#ifndef SISREG_H +#define SISREG_H + +/* VGA standard register */ +#define Index_SR_Graphic_Mode 0x06 +#define Index_SR_RAMDAC_Ctrl 0x07 +#define Index_SR_Threshold_Ctrl1 0x08 +#define Index_SR_Threshold_Ctrl2 0x09 +#define Index_SR_Misc_Ctrl 0x0F +#define Index_SR_DDC 0x11 +#define Index_SR_Feature_Connector_Ctrl 0x12 +#define Index_SR_DRAM_Sizing 0x14 +#define Index_SR_DRAM_State_Machine_Ctrl 0x15 +#define Index_SR_AGP_PCI_State_Machine 0x21 +#define Index_SR_Internal_MCLK0 0x28 +#define Index_SR_Internal_MCLK1 0x29 +#define Index_SR_Internal_DCLK1 0x2B +#define Index_SR_Internal_DCLK2 0x2C +#define Index_SR_Internal_DCLK3 0x2D +#define Index_SR_Ext_Clock_Sel 0x32 +#define Index_SR_Int_Status 0x34 +#define Index_SR_Int_Enable 0x35 +#define Index_SR_Int_Reset 0x36 +#define Index_SR_Power_On_Trap 0x38 +#define Index_SR_Power_On_Trap2 0x39 +#define Index_SR_Power_On_Trap3 0x3A + +/* video registers */ +#define Index_VI_Passwd 0x00 +#define Index_VI_Win_Hor_Disp_Start_Low 0x01 +#define Index_VI_Win_Hor_Disp_End_Low 0x02 +#define Index_VI_Win_Hor_Over 0x03 + +#define Index_VI_Win_Ver_Disp_Start_Low 0x04 +#define Index_VI_Win_Ver_Disp_End_Low 0x05 +#define Index_VI_Win_Ver_Over 0x06 + +#define Index_VI_Disp_Y_Buf_Start_Low 0x07 +#define Index_VI_Disp_Y_Buf_Start_Middle 0x08 +#define Index_VI_Disp_Y_Buf_Start_High 0x09 + +#define Index_VI_U_Buf_Start_Low 0x0A +#define Index_VI_U_Buf_Start_Middle 0x0B +#define Index_VI_U_Buf_Start_High 0x0C + +#define Index_VI_V_Buf_Start_Low 0x0D +#define Index_VI_V_Buf_Start_Middle 0x0E +#define Index_VI_V_Buf_Start_High 0x0F + +#define Index_VI_Disp_Y_Buf_Pitch_Low 0x10 +#define Index_VI_Disp_UV_Buf_Pitch_Low 0x11 +#define Index_VI_Disp_Y_UV_Buf_Pitch_High 0x12 + +#define Index_VI_Disp_Y_Buf_Preset_Low 0x13 +#define Index_VI_Disp_Y_Buf_Preset_Middle 0x14 +#define Index_VI_UV_Buf_Preset_Low 0x15 +#define Index_VI_UV_Buf_Preset_Middle 0x16 +#define Index_VI_Disp_Y_UV_Buf_Preset_High 0x17 + +#define Index_VI_Hor_Post_Up_Scale_Low 0x18 +#define Index_VI_Hor_Post_Up_Scale_High 0x19 +#define Index_VI_Ver_Up_Scale_Low 0x1A +#define Index_VI_Ver_Up_Scale_High 0x1B +#define Index_VI_Scale_Control 0x1C + +#define Index_VI_Play_Threshold_Low 0x1D +#define Index_VI_Play_Threshold_High 0x1E +#define Index_VI_Line_Buffer_Size 0x1F + +/* Destination color key */ +#define Index_VI_Overlay_ColorKey_Red_Min 0x20 +#define Index_VI_Overlay_ColorKey_Green_Min 0x21 +#define Index_VI_Overlay_ColorKey_Blue_Min 0x22 +#define Index_VI_Overlay_ColorKey_Red_Max 0x23 +#define Index_VI_Overlay_ColorKey_Green_Max 0x24 +#define Index_VI_Overlay_ColorKey_Blue_Max 0x25 + +/* Source color key */ +#define Index_VI_Overlay_ChromaKey_Red_Y_Min 0x26 +#define Index_VI_Overlay_ChromaKey_Green_U_Min 0x27 +#define Index_VI_Overlay_ChromaKey_Blue_V_Min 0x28 +#define Index_VI_Overlay_ChromaKey_Red_Y_Max 0x29 +#define Index_VI_Overlay_ChromaKey_Green_U_Max 0x2A +#define Index_VI_Overlay_ChromaKey_Blue_V_Max 0x2B + +#define Index_VI_Contrast_Factor 0x2C + +#define Index_VI_Brightness 0x2D +#define Index_VI_Contrast_Enh_Ctrl 0x2E + +#define Index_VI_Key_Overlay_OP 0x2F + +#define Index_VI_Control_Misc0 0x30 +#define Index_VI_Control_Misc1 0x31 +#define Index_VI_Control_Misc2 0x32 + +#define Index_MPEG_Read_Ctrl0 0x60 +#define Index_MPEG_Read_Ctrl1 0x61 +#define Index_MPEG_Read_Ctrl2 0x62 +#define Index_MPEG_Read_Ctrl3 0x63 +#define Index_MPEG_Ver_Up_Scale_Low 0x64 +#define Index_MPEG_Ver_Up_Scale_High 0x65 + +/* + CRT_2 function control register + */ +#define Index_CRT2_FC_CONTROL 0x00 +#define Index_CRT2_FC_SCREEN_HIGH 0x04 +#define Index_CRT2_FC_SCREEN_MID 0x05 +#define Index_CRT2_FC_SCREEN_LOW 0x06 +#define Index_CRT2_FC_ENABLE_WRITE 0x24 +#define Index_CRT2_FC_VR 0x25 +#define Index_CRT2_FC_VCount 0x27 +#define Index_CRT2_FC_VCount1 0x28 + +/* video attributes - these should probably be configurable on the fly + * so users with different desktop sizes can keep + * captured data off the desktop + */ +#define _VINWID 704 +#define _VINHGT _VINHGT_NTSC +#define _VINHGT_NTSC 240 +#define _VINHGT_PAL 290 +#define _VIN_WINDOW (704 * 291 * 2) +#define _VBI_WINDOW (704 * 64 * 2) + +#define _VIN_FIELD_EVEN 1 +#define _VIN_FIELD_ODD 2 +#define _VIN_FIELD_BOTH 4 + +#define vc_index_offset 0x00 +#define vc_data_offset 0x01 +#define vi_index_offset 0x02 +#define vi_data_offset 0x03 +#define crt2_index_offset 0x04 +#define crt2_port_offset 0x05 +#define sr_index_offset 0x44 +#define sr_data_offset 0x45 +#define cr_index_offset 0x54 +#define cr_data_offset 0x55 +#define input_stat 0x5A + +/* i2c registers */ +#define X_INDEXREG 0x14 +#define X_PORTREG 0x15 +#define X_DATA 0x0f +#define I2C_SCL 0x00 +#define I2C_SDA 0x01 +#define I2C_DELAY 10 + +/* mmio registers */ +#define REG_PRIM_CRT_COUNTER 0x8514 + +#endif /* SISREG_H */ Index: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c:1.1 Fri Jun 30 13:15:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c Sat Dec 2 10:30:52 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c,v 1.1 2000/06/30 17:15:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c,v 1.2 2000/12/02 15:30:52 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -184,7 +184,7 @@ BW2Probe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -229,9 +229,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -267,6 +265,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } Index: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp:1.1 xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp:1.1 Fri Jun 30 13:15:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp Mon Dec 11 15:18:27 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp,v 1.1 2000/06/30 17:15:14 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp,v 1.2 2000/12/11 20:18:27 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNBW2 __drivermansuffix__ "Version 4.0" "XFree86" +.TH SUNBW2 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME sunbw2 \- BW2 video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c:1.1 Fri Jun 30 13:15:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c Sat Dec 2 10:30:53 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c,v 1.1 2000/06/30 17:15:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c,v 1.2 2000/12/02 15:30:53 tsi Exp $ */ #define PSZ 8 #include "xf86.h" @@ -189,7 +189,7 @@ CG14Probe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -234,9 +234,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -272,6 +270,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } Index: xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp:1.1 xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp:1.1 Fri Jun 30 13:15:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp Mon Dec 11 15:18:29 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp,v 1.1 2000/06/30 17:15:14 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp,v 1.2 2000/12/11 20:18:29 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNCG14 __drivermansuffix__ "Version 4.0" "XFree86" +.TH SUNCG14 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME suncg14 \- CG14 video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c:1.1 Fri Jun 30 13:15:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c Sat Dec 2 10:30:54 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c,v 1.1 2000/06/30 17:15:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c,v 1.2 2000/12/02 15:30:54 tsi Exp $ */ #define PSZ 8 #include "xf86.h" @@ -185,7 +185,7 @@ CG3Probe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -230,9 +230,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -268,6 +266,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } Index: xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp:1.1 xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp:1.1 Fri Jun 30 13:15:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp Mon Dec 11 15:18:31 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp,v 1.1 2000/06/30 17:15:15 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp,v 1.2 2000/12/11 20:18:31 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNCG3 __drivermansuffix__ "Version 4.0" "XFree86" +.TH SUNCG3 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME suncg3 \- CG3 video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c:1.2 Fri Jun 30 13:15:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c Sat Dec 2 10:30:54 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c,v 1.2 2000/06/30 17:15:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c,v 1.4 2000/12/02 15:30:54 tsi Exp $ */ #define PSZ 8 #include "xf86.h" @@ -194,7 +194,7 @@ CG6Probe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -239,9 +239,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -277,6 +275,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } @@ -611,10 +610,14 @@ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); pScrn->vtSema = FALSE; + xf86UnmapSbusMem(pCg6->psdp, pCg6->fbc, CG6_RAM_VOFF - CG6_FBC_VOFF + (pCg6->psdp->width * pCg6->psdp->height)); + if (pCg6->HWCursor) + xf86SbusHideOsHwCursor(pCg6->psdp); + pScreen->CloseScreen = pCg6->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); return FALSE; Index: xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp:1.2 xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp:1.2 Tue Jun 13 22:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp Mon Dec 11 15:18:32 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp,v 1.2 2000/06/14 02:13:14 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp,v 1.3 2000/12/11 20:18:32 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNCG6 __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH SUNCG6 __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME suncg6 \- GX/Turbo GX video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h:1.4 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h:1.4 Fri Jun 23 15:29:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h Thu Nov 30 19:24:34 2000 @@ -24,7 +24,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h,v 1.4 2000/06/23 19:29:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h,v 1.5 2000/12/01 00:24:34 dawes Exp $ */ #ifndef FFB_H #define FFB_H @@ -192,6 +192,7 @@ sbusDevicePtr psdp; Bool HWCursor; Bool NoAccel; + Bool vtSema; CloseScreenProcPtr CloseScreen; xf86CursorInfoPtr CursorInfoRec; unsigned char CursorShiftX, CursorShiftY; Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c:1.3 Fri Jun 23 15:29:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c Thu Nov 30 19:24:34 2000 @@ -24,7 +24,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c,v 1.3 2000/06/23 19:29:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c,v 1.4 2000/12/01 00:24:34 dawes Exp $ */ #include <asm/types.h> #include <math.h> @@ -328,6 +328,9 @@ WindowPtr pBgWin; int depth = pWin->drawable.depth; + if (pFfb->vtSema) + return; + FFBLOG(("CreatorPaintWindow: WIN(%p) what(%d)\n", pWin, what)); pPrivWin = cfbGetWindowPrivate(pWin); pFfbPrivWin = CreatorGetWindowPrivate(pWin); @@ -452,6 +455,9 @@ int i, nbox; WindowPtr pwinRoot; + if (pFfb->vtSema) + return; + FFBLOG(("CreatorCopyWindow: WIN(%p)\n", pWin)); REGION_INIT(pScreen, &rgnDst, NullBox, 0); @@ -510,7 +516,10 @@ register BoxPtr pBox; register int i; PixmapPtr pScrPix; - + + if (pFfb->vtSema) + return; + FFBLOG(("CreatorSaveAreas: WIN(%p)\n", pWin)); i = REGION_NUM_RECTS(prgnSave); pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec)); @@ -556,7 +565,11 @@ cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); PixmapPtr pScrPix; - + + pFfb = GET_FFB_FROM_SCREEN(pScreen); + if (pFfb->vtSema) + return; + FFBLOG(("CreatorRestoreAreas: WIN(%p)\n", pWin)); i = REGION_NUM_RECTS(prgnRestore); pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec)); Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c:1.1 Tue May 23 00:47:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c Tue Oct 17 12:53:17 2000 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c,v 1.1 2000/05/23 04:47:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c,v 1.2 2000/10/17 16:53:17 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -153,7 +153,7 @@ { FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); - *name = &pFfb->psdp->device; + *name = pFfb->psdp->device; /* We give the user the dumb frame buffer. */ *mem = (unsigned char *)FFB_DFB24_VOFF; Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c:1.5 Fri Jun 30 13:15:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c Sat Dec 2 10:30:54 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c,v 1.5 2000/06/30 17:15:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c,v 1.7 2000/12/02 15:30:54 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -202,7 +202,7 @@ FFBProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -247,9 +247,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -285,6 +283,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } @@ -979,6 +978,7 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + pFfb->vtSema = FALSE; if (!pFfb->NoAccel) CreatorVtChange (pScrn->pScreen, TRUE); if (pFfb->HWCursor) @@ -1005,6 +1005,11 @@ if (!pFfb->NoAccel) CreatorVtChange (pScrn->pScreen, FALSE); + + if (pFfb->HWCursor) + xf86SbusHideOsHwCursor (pFfb->psdp); + + pFfb->vtSema = TRUE; return; } @@ -1040,6 +1045,9 @@ xf86UnmapSbusMem(pFfb->psdp, pFfb->regs, 16384); xf86UnmapSbusMem(pFfb->psdp, pFfb->dac, 8192); xf86UnmapSbusMem(pFfb->psdp, (void *)pFfb->strapping_bits, 8192); + + if (pFfb->HWCursor) + xf86SbusHideOsHwCursor (pFfb->psdp); pScreen->CloseScreen = pFfb->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c:1.2 Tue May 23 00:47:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c Thu Nov 30 19:24:34 2000 @@ -24,7 +24,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c,v 1.3 2000/12/01 00:24:34 dawes Exp $ */ #include "ffb.h" #include "ffb_regs.h" @@ -454,11 +454,13 @@ /* flags for changing the proc vector */ cfbPrivGCPtr devPriv; CreatorPrivGCPtr gcPriv; - int oneRect; + int oneRect, type; int accel, drawableChanged; + FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen); gcPriv = CreatorGetGCPrivate (pGC); - if (pDrawable->type != DRAWABLE_WINDOW) { + type = pFfb->vtSema ? -1 : pDrawable->type; + if (type != DRAWABLE_WINDOW) { if (gcPriv->type == DRAWABLE_WINDOW) { extern GCOps cfbNonTEOps; extern GCOps cfb32NonTEOps; @@ -472,7 +474,7 @@ changes = (1 << (GCLastBit+1)) - 1; pGC->stateChanges = changes; - gcPriv->type = pDrawable->type; + gcPriv->type = type; } if (pGC->depth == 8) cfbValidateGC (pGC, changes, pDrawable); Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c:1.2 Tue Jun 20 01:08:48 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c Thu Nov 30 19:24:34 2000 @@ -21,7 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c,v 1.2 2000/06/20 05:08:48 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c,v 1.3 2000/12/01 00:24:34 dawes Exp $ */ #include "ffb.h" @@ -203,6 +203,9 @@ ffb_dacPtr dac = pFfb->dac; unsigned int base; int limit; + + if (pFfb->vtSema) + return; if (p->flags & FFB_DAC_PAC1) base = FFBDAC_PAC1_SPWLUT(index); Index: xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp:1.2 xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp:1.2 Tue Jun 13 22:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp Mon Dec 11 15:18:33 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp,v 1.2 2000/06/14 02:13:14 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp,v 1.3 2000/12/11 20:18:33 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH FFB __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH FFB __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME ffb \- SUNFFB video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h diff -u xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h:1.2 xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h:1.2 Fri Jun 30 13:15:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h Thu Nov 30 19:24:35 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h,v 1.2 2000/06/30 17:15:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h,v 1.3 2000/12/01 00:24:35 dawes Exp $ */ #ifndef LEO_H #define LEO_H @@ -77,6 +77,7 @@ sbusDevicePtr psdp; Bool HWCursor; Bool NoAccel; + Bool vtSema; CloseScreenProcPtr CloseScreen; xf86CursorInfoPtr CursorInfoRec; unsigned char CursorShiftX, CursorShiftY; Index: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c:1.1 Thu May 18 19:21:38 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c Thu Nov 30 19:24:35 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.1 2000/05/18 23:21:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.2 2000/12/01 00:24:35 dawes Exp $ */ #define PSZ 32 #include <asm/types.h> @@ -73,6 +73,8 @@ static void LeoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { + ScreenPtr pScreen = pWin->drawable.pScreen; + LeoPtr pLeo = LeoGetScreenPrivate (pScreen); DDXPointPtr pptSrc; DDXPointPtr ppt; RegionPtr prgnDst; @@ -80,7 +82,9 @@ int dx, dy; int i, nbox; WindowPtr pwinRoot; - extern WindowPtr *WindowTable; + + if (pLeo->vtSema) + return; dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; Index: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c:1.2 Tue May 23 00:47:46 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c Sat Dec 2 10:30:56 2000 @@ -1,3 +1,4 @@ + /* * Leo (ZX) framebuffer driver. * @@ -20,7 +21,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c,v 1.2 2000/05/23 04:47:46 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c,v 1.4 2000/12/02 15:30:56 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -195,7 +196,7 @@ LeoProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -240,9 +241,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -278,6 +277,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } @@ -604,6 +604,7 @@ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn); + pLeo->vtSema = FALSE; LeoVtChange (pScrn->pScreen, TRUE); if (pLeo->HWCursor) xf86SbusHideOsHwCursor (pLeo->psdp); @@ -620,8 +621,10 @@ LeoLeaveVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn); LeoVtChange (pScrn->pScreen, FALSE); + pLeo->vtSema = TRUE; } @@ -639,6 +642,9 @@ pScrn->vtSema = FALSE; xf86UnmapSbusMem(pLeo->psdp, pLeo->fb, 0x803000); + + if (pLeo->HWCursor) + xf86SbusHideOsHwCursor (pLeo->psdp); pScreen->CloseScreen = pLeo->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); Index: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c diff -u xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c:1.1 Thu May 18 19:21:40 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c Thu Nov 30 19:24:35 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c,v 1.2 2000/12/01 00:24:35 dawes Exp $ */ #define PSZ 32 @@ -233,10 +233,12 @@ /* flags for changing the proc vector */ LeoPrivGCPtr gcPriv; cfbPrivGCPtr devPriv; - int oneRect; + int oneRect, type; + LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen); gcPriv = LeoGetGCPrivate (pGC); - if (pDrawable->type != DRAWABLE_WINDOW) { + type = pLeo->vtSema ? -1 : pDrawable->type; + if (type != DRAWABLE_WINDOW) { if (gcPriv->type == DRAWABLE_WINDOW) { extern GCOps cfbNonTEOps; @@ -244,7 +246,7 @@ pGC->ops = &cfbNonTEOps; changes = (1 << (GCLastBit+1)) - 1; pGC->stateChanges = changes; - gcPriv->type = pDrawable->type; + gcPriv->type = type; } cfbValidateGC (pGC, changes, pDrawable); return; Index: xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp:1.3 xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp:1.3 Tue Jun 13 22:13:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp Mon Dec 11 15:18:34 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp,v 1.3 2000/06/14 02:13:14 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp,v 1.4 2000/12/11 20:18:34 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNLEO __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH SUNLEO __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME sunleo \- Leo video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp:1.1 xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp:1.1 Fri Jun 30 13:15:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp Mon Dec 11 15:18:35 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp,v 1.1 2000/06/30 17:15:16 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp,v 1.2 2000/12/11 20:18:35 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH SUNTCX __drivermansuffix__ "Version 4.0" "XFree86" +.TH SUNTCX __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME suntcx \- TCX video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c:1.3 --- xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c:1.1 Fri Jun 30 13:15:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c Sat Dec 2 10:30:57 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c,v 1.1 2000/06/30 17:15:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c,v 1.3 2000/12/02 15:30:57 tsi Exp $ */ #define PSZ 8 #include "xf86.h" @@ -195,7 +195,7 @@ TCXProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; @@ -240,9 +240,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -278,6 +276,7 @@ } xfree(pEnt); } + xfree(usedChips); return foundScreen; } @@ -699,6 +698,9 @@ if (pTcx->thc) xf86UnmapSbusMem(pTcx->psdp, pTcx->fb, 8192); + if (pTcx->HWCursor) + xf86SbusHideOsHwCursor (pTcx->psdp); + pScreen->CloseScreen = pTcx->CloseScreen; return (*pScreen->CloseScreen)(scrnIndex, pScreen); return FALSE; Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile:1.16 xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile:1.16 Fri Jun 30 13:15:17 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile Fri Dec 15 10:19:35 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile,v 1.16 2000/06/30 17:15:17 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile,v 1.19 2000/12/15 15:19:35 dawes Exp $ XCOMM XCOMM This is the Imakefile for the TDFX driver. XCOMM @@ -18,10 +18,10 @@ #endif SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \ - tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS) + tdfx_dga.c tdfx_priv.c tdfx_sli.c tdfx_video.c $(DRISRCS) OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \ - tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS) + tdfx_dga.o tdfx_priv.o tdfx_sli.o tdfx_video.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -33,11 +33,11 @@ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(XF86SRC)/ddc -I$(XF86OSSRC)/vbe -I$(SERVERSRC)/Xext \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ - -I$(EXTINCSRC) \ + -I$(EXTINCSRC) -I$(SERVERSRC)/render \ $(DRIINCLUDES) #endif -DEFINES = -DPROP_3DFX $(DRIDEFINES) +DEFINES = $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -71,5 +71,6 @@ InstallDriverSDKNonExecFile(tdfx_priv.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_priv.h,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_sli.c,$(DRIVERSDKDIR)/drivers/tdfx) +InstallDriverSDKNonExecFile(tdfx_video.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKObjectModule(tdfx,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp:1.4 Tue Jun 13 22:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp Mon Dec 11 15:18:36 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.6 2000/12/11 20:18:36 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH TDFX __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH TDFX __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME tdfx \- 3Dfx video driver .SH SYNOPSIS @@ -15,7 +15,7 @@ .SH DESCRIPTION .B tdfx is an XFree86 driver for 3Dfx video cards. -THIS MAN PAGE NEEDS TO BE FILLED IN. +It supports the Voodoo Banshee, Voodoo3, Voodoo4 and Voodoo5 cards. .SH SUPPORTED HARDWARE The .B tdfx Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h:1.10 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h:1.10 Fri Jun 16 20:03:24 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h Fri Dec 15 10:19:35 2000 @@ -5,7 +5,7 @@ Copyright: 1998,1999 */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h,v 1.10 2000/06/17 00:03:24 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h,v 1.17 2000/12/15 15:19:35 dawes Exp $ */ #ifndef _TDFX_H_ #define _TDFX_H_ @@ -41,15 +41,8 @@ #define PIXMAP_CACHE_LINES 512 #endif -#ifdef PROP_3DFX #include "tdfx_priv.h" -#else -#define PROPDATA -#define PROPSAREADATA -#endif -extern Bool TDFXInitPrivate(ScreenPtr pScreen); -extern void TDFXShutdownPrivate(ScreenPtr pScreen); -extern void TDFXSwapContextPrivate(ScreenPtr pScreen); +extern void TDFXSwapContextFifo(ScreenPtr pScreen); extern void TDFXLostContext(ScreenPtr pScreen); #ifdef XF86DRI @@ -126,6 +119,7 @@ unsigned int srcbaseaddr; unsigned int dstbaseaddr; unsigned char ExtVga[2]; + unsigned int dactable[512]; } TDFXRegRec, *TDFXRegPtr; typedef struct TextureData_t { @@ -149,8 +143,8 @@ int MaxClock; int ChipType; pciVideoPtr PciInfo; - int LinearAddr[MAXCHIPS]; - int MMIOAddr[MAXCHIPS]; + unsigned long LinearAddr[MAXCHIPS]; + unsigned long MMIOAddr[MAXCHIPS]; EntityInfoPtr pEnt; int numChips; PCITAG PciTag[MAXCHIPS]; @@ -198,6 +192,19 @@ TDFXConfigPrivPtr pVisualConfigsPriv; TDFXRegRec DRContextRegs; #endif + /* State for video */ + FBAreaPtr offscreenYUVBuf; + int offscreenYUVBufWidth; + int offscreenYUVBufHeight; + + /* This is a small register shadow. I'm only shadowing + * sst2dDstFmt + * sst2dSrcFmt + * If a real register shadow is ever needed we should probably + * shadow everything and make it happen automatically for every write. */ + INT32 sst2DSrcFmtShadow; + INT32 sst2DDstFmtShadow; + int pixmapCacheLines; } TDFXRec; typedef struct { @@ -232,7 +239,7 @@ extern Bool TDFXDGAInit(ScreenPtr pScreen); extern void TDFXCursorGrabMemory(ScreenPtr pScreen); extern void TDFXSetLFBConfig(TDFXPtr pTDFX); -extern void TDFXSendNOPPrivate(ScrnInfoPtr pScrn); +extern void TDFXSendNOPFifo(ScrnInfoPtr pScrn); extern Bool TDFXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); extern void TDFXAdjustFrame(int scrnIndex, int x, int y, int flags); @@ -259,33 +266,6 @@ extern void TDFXSelectBuffer(TDFXPtr pTDFX, int which); - -#ifndef PROP_3DFX -#define DECLARE(a) -#define DECLARE_LAUNCH(size, x) -#ifdef TDFX_DEBUG_CMDS -#define TDFXMakeRoom(p, n) \ - do { \ - if (cmdCnt) \ - ErrorF("Previous TDFXMakeRoom passed incorrect size\n"); \ - cmdCnt=n; \ - lastAddr=0; - TDFXMakeRoomNoProp(p, n); \ - } while(0) -#define TDFXWriteLong(p, a, v) \ - do { \ - if (lastAddr && a<lastAddr) \ - ErrorF("TDFXWriteLong not ordered\n"); \ - lastAddr=a; \ - cmdCnt--; \ - TDFXWriteLongMMIO(p, a, v); \ - while (0) -#else -#define TDFXMakeRoom(p, n) TDFXMakeRoomNoProp(p, n) -#define TDFXWriteLong(p, a, v) TDFXWriteLongMMIO(p, a, v) -#endif -#define TDFXSendNOP TDFXSendNOPNoProp -#endif #endif Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c:1.12 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c:1.17 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c:1.12 Sat Jun 17 13:44:25 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c Fri Dec 15 10:19:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c,v 1.12 2000/06/17 17:44:25 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c,v 1.17 2000/12/15 15:19:35 dawes Exp $ */ /* All drivers should typically include these */ #include "xf86.h" @@ -73,8 +73,6 @@ int skipleft); static void TDFXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); -void TDFXSelectBuffer(TDFXPtr pTDFX, int which); - void TDFXNeedSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); @@ -90,7 +88,7 @@ #ifdef XF86DRI if (pTDFX->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); - TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + TDFXSwapContextFifo(screenInfo.screens[pScrn->scrnIndex]); } #endif pTDFX->syncDone=TRUE; @@ -163,12 +161,22 @@ } else { int chip; int stride, bits; + int TileAperturePitch, lg2TileAperturePitch; if (pTDFX->cpp==2) stride=pTDFX->stride; else stride=4*pTDFX->stride/pTDFX->cpp; bits=pTDFX->backOffset>>12; + for (lg2TileAperturePitch = 0, TileAperturePitch = 1024; + (lg2TileAperturePitch < 5) && + TileAperturePitch < stride; + lg2TileAperturePitch += 1, TileAperturePitch <<= 1); +#if 0 + fprintf(stderr, "Using %d (== lg2(%d)-10) for tile aperture pitch\n", + lg2TileAperturePitch, TileAperturePitch); + fprintf(stderr, "stride == %d\n", stride); +#endif for (chip=0; chip<pTDFX->numChips; chip++) { TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) | - SST_RAW_LFB_ADDR_STRIDE_4K | + SST_RAW_LFB_ADDR_STRIDE(lg2TileAperturePitch) | ((bits&0x6000)<<10) | ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); } @@ -225,21 +233,7 @@ infoPtr->SubsequentScreenToScreenCopy = TDFXSubsequentScreenToScreenCopy; infoPtr->ScreenToScreenCopyFlags = commonFlags; -#ifndef PROP_3DFX - /* We can use direct method because we're writing straight to the board */ - infoPtr->SetupForCPUToScreenColorExpandFill = - TDFXSetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - TDFXSubsequentCPUToScreenColorExpandFill; - infoPtr->ColorExpandBase = pTDFX->MMIOBase+SST_2D_LAUNCH; - infoPtr->ColorExpandRange = 128; - infoPtr->CPUToScreenColorExpandFillFlags = commonFlags | - CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | - LEFT_EDGE_CLIPPING; /* | LEFT_EDGE_CLIPPING_NEGATIVE_X; */ - pTDFX->scanlineColorExpandBuffers[0]=0; - pTDFX->scanlineColorExpandBuffers[1]=0; -#else - /* When we're using the proprietary interface we have to use indirect */ + /* When we're using the fifo interface we have to use indirect */ pTDFX->scanlineColorExpandBuffers[0] = xalloc((pScrn->virtualX+62)/32*4); pTDFX->scanlineColorExpandBuffers[1] = xalloc((pScrn->virtualX+62)/32*4); infoPtr->NumScanlineColorExpandBuffers=2; @@ -253,7 +247,6 @@ infoPtr->ScanlineCPUToScreenColorExpandFillFlags = commonFlags | CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | LEFT_EDGE_CLIPPING; /* | LEFT_EDGE_CLIPPING_NEGATIVE_X; */ -#endif infoPtr->SetupForMono8x8PatternFill = TDFXSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c:1.10 Fri Jun 23 19:43:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c Thu Dec 7 15:26:23 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c,v 1.10 2000/06/23 23:43:45 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c,v 1.14 2000/12/07 20:26:23 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -26,6 +26,8 @@ void *readContextStore, DRIContextType writeContextType, void *writeContextStore); +static Bool TDFXDRIOpenFullScreen(ScreenPtr pScreen); +static Bool TDFXDRICloseFullScreen(ScreenPtr pScreen); static void TDFXDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); static void TDFXDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); @@ -127,9 +129,10 @@ } } if (i!=numConfigs) { - ErrorF("Incorrect initialization of visuals\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "Incorrect initialization of visuals\n"); return FALSE; - } else ErrorF("Created %d visuals\n", numConfigs); + } break; /* 16bpp */ case 24: @@ -224,7 +227,7 @@ xf86DrvMsg(pScreen->myNum, X_ERROR, "Incorrect initialization of visuals\n"); return FALSE; - } else ErrorF("Created %d visuals\n", numConfigs); + } break; } pTDFX->numVisualConfigs = numConfigs; @@ -263,12 +266,21 @@ switch (pScrn->bitsPerPixel) { case 8: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "DRI not supported in 8 bpp mode, disabling DRI.\n"); return FALSE; case 16: break; case 24: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "DRI not supported in 24 bpp mode, disabling DRI.\n"); + return FALSE; case 32: - if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) return FALSE; + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "DRI requires Voodoo3 or later, disabling DRI.\n"); + return FALSE; + } } /* Check that the GLX, DRI, and DRM modules have been loaded by testing @@ -295,8 +307,12 @@ } pDRIInfo = DRICreateInfoRec(); - if (!pDRIInfo) - return FALSE; + if (!pDRIInfo) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "DRICreateInfoRect() failed, disabling DRI.\n"); + return FALSE; + } + pTDFX->pDRIInfo = pDRIInfo; pDRIInfo->drmDriverName = TDFXKernelDriverName; @@ -336,13 +352,14 @@ * in the SAREA header */ if (sizeof(XF86DRISAREARec)+sizeof(TDFXSAREAPriv)>SAREA_MAX) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; #endif if (!(pTDFXDRI = (TDFXDRIPtr)xnfcalloc(sizeof(TDFXDRIRec),1))) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRI memory allocation failed, disabling DRI.\n"); DRIDestroyInfoRec(pTDFX->pDRIInfo); pTDFX->pDRIInfo=0; return FALSE; @@ -356,6 +373,8 @@ pDRIInfo->SwapContext = TDFXDRISwapContext; pDRIInfo->InitBuffers = TDFXDRIInitBuffers; pDRIInfo->MoveBuffers = TDFXDRIMoveBuffers; + pDRIInfo->OpenFullScreen = TDFXDRIOpenFullScreen; + pDRIInfo->CloseFullScreen = TDFXDRICloseFullScreen; pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; if (!DRIScreenInit(pScreen, pDRIInfo, &pTDFX->drmSubFD)) { @@ -363,6 +382,8 @@ pDRIInfo->devPrivate=0; DRIDestroyInfoRec(pTDFX->pDRIInfo); pTDFX->pDRIInfo=0; + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed, disabling DRI.\n"); + return FALSE; } @@ -391,6 +412,7 @@ if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr[0], pTDFXDRI->regsSize, DRM_REGISTERS, 0, &pTDFXDRI->regs)<0) { TDFXDRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap failed, disabling DRI.\n"); return FALSE; } xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", @@ -398,6 +420,7 @@ if (!(TDFXInitVisualConfigs(pScreen))) { TDFXDRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, "TDFXInitVisualConfigs failed, disabling DRI.\n"); return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" ); @@ -430,10 +453,6 @@ drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore) { - TDFXConfigPrivPtr pTDFXConfig = (TDFXConfigPrivPtr)pVisualConfigPriv; - TDFXDRIContextPtr ctx; - - ctx=(TDFXDRIContextPtr)contextStore; return TRUE; } @@ -441,8 +460,6 @@ TDFXDestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType contextStore) { - TDFXDRIContextPtr ctx; - ctx=(TDFXDRIContextPtr)contextStore; } Bool @@ -476,21 +493,6 @@ DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext) { -#if 0 - ScrnInfoPtr pScrn; - - pScrn = xf86Screens[pScreen->myNum]; - if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ - TDFXCheckSync(pScrn); - TDFXLostContext(pScreen); - } - if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ - TDFXSwapContextPrivate(pScreen); - TDFXNeedSync(pScrn); - } -#endif } static void @@ -671,3 +673,34 @@ pTDFX->AccelInfoRec->NeedToSync = TRUE; } + +static Bool +TDFXDRIOpenFullScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + TDFXPtr pTDFX; + + xf86DrvMsg(pScreen->myNum, X_INFO, "OpenFullScreen\n"); +#if 0 + pScrn = xf86Screens[pScreen->myNum]; + pTDFX=TDFXPTR(pScrn); + if (pTDFX->numChips>1) { + TDFXSetupSLI(pScrn); + } +#endif + return TRUE; +} + +static Bool +TDFXDRICloseFullScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + + xf86DrvMsg(pScreen->myNum, X_INFO, "CloseFullScreen\n"); +#if 0 + pScrn = xf86Screens[pScreen->myNum]; + TDFXDisableSLI(pScrn); +#endif + return TRUE; +} + Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c:1.39 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c:1.59 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c:1.39 Fri Jun 23 19:43:45 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c Mon Dec 18 10:50:04 2000 @@ -25,7 +25,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c,v 1.39 2000/06/23 23:43:45 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c,v 1.59 2000/12/18 15:50:04 dawes Exp $ */ /* * Authors: @@ -97,6 +97,10 @@ #include "dri.h" #endif +#ifdef RENDER +#include "picturestr.h" +#endif + /* Required Functions: */ static OptionInfoPtr TDFXAvailableOptions(int chipid, int busid); @@ -203,8 +207,25 @@ 0 }; +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +static const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86DoEDID_DDC1", + NULL +}; + +#ifdef XFree86LOADER static const char *fbSymbols[] = { "fbScreenInit", +#ifdef RENDER + "fbPictureInit", +#endif NULL }; @@ -225,19 +246,6 @@ NULL }; -static const char *ramdacSymbols[] = { - "xf86InitCursor", - "xf86CreateCursorInfoRec", - "xf86DestroyCursorInfoRec", - NULL -}; - -static const char *ddcSymbols[] = { - "xf86PrintEDID", - "xf86DoEDID_DDC1", - NULL -}; - static const char *vbeSymbols[] = { "VBEInit", "vbeDoEDID", @@ -274,14 +282,15 @@ "DRIGetSAREAPrivate", "DRIGetContext", "DRIQueryVersion", + "DRIAdjustFrame", + "DRIOpenFullScreen", + "DRICloseFullScreen", "GlxSetVisualConfigs", NULL }; #endif -#ifdef XFree86LOADER - static MODULESETUPPROTO(tdfxSetup); static XF86ModuleVersionInfo tdfxVersRec = @@ -382,7 +391,7 @@ return TDFXOptions; } -void +static void TDFXProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -391,7 +400,7 @@ #endif { pVbe = VBEInit(NULL,index); - vbeDoEDID(pVbe, NULL); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); } } @@ -405,7 +414,7 @@ static Bool TDFXProbe(DriverPtr drv, int flags) { int i, numUsed, numDevSections, *usedChips; - GDevPtr *devSections = NULL; + GDevPtr *devSections; Bool foundScreen = FALSE; TDFXTRACE("TDFXProbe start\n"); @@ -428,8 +437,7 @@ devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); + xfree(devSections); if (numUsed<=0) return FALSE; if (flags & PROBE_DETECT) @@ -636,7 +644,6 @@ ClockRangePtr clockRanges; int i; MessageType from; - char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; pciVideoPtr match; @@ -655,17 +662,12 @@ pTDFX->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (flags & PROBE_DETECT) { - TDFXProbeDDC(pScrn, pTDFX->pEnt->index); - return TRUE; + TDFXProbeDDC(pScrn, pTDFX->pEnt->index); + return TRUE; } if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; - if (flags & PROBE_DETECT) { - TDFXProbeDDC(pScrn, pTDFX->pEnt->index); - return FALSE; - } - /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; @@ -695,8 +697,11 @@ match=pTDFX->PciInfo=xf86GetPciInfoForEntity(pTDFX->pEnt->index); TDFXFindChips(pScrn, match); - if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResNone)) + if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResExclusive)) { + TDFXFreeRec(pScrn); return FALSE; + } + if (pTDFX->usePIO) pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; else @@ -729,17 +734,9 @@ return FALSE; } - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual (pScrn, -1)) { return FALSE; - } else { - /* We don't currently support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } + } /* We use a programamble clock */ pScrn->progClock = TRUE; @@ -805,7 +802,7 @@ } } xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at addr 0x%lX\n", - (unsigned long)pTDFX->MMIOAddr); + (unsigned long)pTDFX->MMIOAddr[0]); if (match->ioBase[2]) { pTDFX->PIOBase[0] = match->ioBase[2]&0xFFFFFFFC; @@ -928,8 +925,12 @@ return FALSE; } xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif - if (!xf86ReturnOptValBool(TDFXOptions, OPTION_NOACCEL, FALSE)) { + pTDFX->NoAccel=xf86ReturnOptValBool(TDFXOptions, OPTION_NOACCEL, FALSE); + if (!pTDFX->NoAccel) { if (!xf86LoadSubModule(pScrn, "xaa")) { TDFXFreeRec(pScrn); return FALSE; @@ -1195,7 +1196,10 @@ maxm=24; } else { minm=1; - maxm=64; + maxm=57; /* This used to be 64, alas it seems the last 8 (funny that ?) + * values cause jittering at lower resolutions. I've not done + * any calculations to what the adjustment affects clock ranges, + * but I can still run at 1600x1200@75Hz */ } for (n=1; n<256; n++) { f_cur=REFFREQ*(n+2); @@ -1448,7 +1452,7 @@ #ifdef XF86DRI if (pTDFX->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); - TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + TDFXSwapContextFifo(screenInfo.screens[pScrn->scrnIndex]); } #endif DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE); @@ -1604,15 +1608,6 @@ pTDFX = TDFXPTR(pScrn); pTDFX->stride = pScrn->displayWidth*pTDFX->cpp; - /* Layout the memory. Start with all the ram */ - memRemaining=pScrn->videoRam<<10; - /* Remove the cursor space */ - memRemaining-=4096; - /* Remove the main screen and offscreen pixmaps */ - memRemaining-=pTDFX->stride*(pScrn->virtualY+128); - /* Remove one scanline for page alignment */ - memRemaining-=4095; - /* Remove the back and Z buffers */ if (pTDFX->cpp!=3) { screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, pTDFX->cpp); @@ -1622,43 +1617,88 @@ screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, 4); } - memRemaining-=screenSizeInTiles*2; - - /* Give all the rest to textures, rounded down to a page */ - texSize=memRemaining&~0xFFF; - - /* Make sure fifo has CMDFIFO_PAGES<fifoSize<255 pages */ - if (memRemaining-texSize<CMDFIFO_PAGES<<12) - texSize=(memRemaining-(CMDFIFO_PAGES<<12))&~0xFFF; - /* Fifo uses the remaining space up to 255 pages */ - fifoSize = (memRemaining-texSize)&~0xFFF; - if (fifoSize>255<<12) fifoSize=255<<12; - - /* Assign the variables */ - /* Cursor */ - pTDFX->cursorOffset=0; /* Size 1024 bytes */ - - /* Point the fifo at the first page */ + memRemaining=((pScrn->videoRam<<10) - 1) &~ 0xFFF; + /* Note that a page is 4096 bytes, and a */ + /* tile is 32 x 128 = 4096 bytes. So, */ + /* page and tile boundaries are the same */ + /* Place the depth offset first, forcing */ + /* it to be on an *odd* page boundary. */ + pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF; + if ((pTDFX->depthOffset & (0x1 << 12)) == 0) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing depth offset from 0x%08x to 0x%08x\n", + pTDFX->depthOffset, + pTDFX->depthOffset - (0x1 << 12)); +#endif + pTDFX->depthOffset -= (0x1 << 12); + } + /* Now, place the back buffer, forcing it */ + /* to be on an *even* page boundary. */ + pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF; + if (pTDFX->backOffset & (0x1 << 12)) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing back offset from 0x%08x to 0x%08x\n", + pTDFX->backOffset, + pTDFX->backOffset - (0x1 << 12)); +#endif + pTDFX->backOffset -= (0x1 << 12); + } + /* Now, place the front buffer, forcing */ + /* it to be on a page boundary too, just */ + /* for giggles. */ + pTDFX->fbOffset + = (pTDFX->backOffset - + (pScrn->virtualY+PIXMAP_CACHE_LINES)*pTDFX->stride) &~ 0xFFF; + /* Give the cmd fifo at least */ + /* CMDFIFO_PAGES pages, but no more than */ + /* 255. */ + fifoSize = ((255 <= CMDFIFO_PAGES) ? 255 : CMDFIFO_PAGES) << 12; + /* We give 4096 bytes to the cursor, fifoSize to the */ + /* FIFO, and everything to textures. */ + texSize = (pTDFX->fbOffset - fifoSize - 4096); + pTDFX->texOffset = pTDFX->fbOffset - texSize; + pTDFX->texSize = texSize; pTDFX->fifoOffset = 4096; pTDFX->fifoSize = fifoSize; - - /* Textures */ - pTDFX->texOffset = pTDFX->fifoOffset+fifoSize; - pTDFX->texSize = texSize; - - /* Frame buffer */ - pTDFX->fbOffset=pTDFX->texOffset+pTDFX->texSize; - - /* Back buffer */ - pTDFX->backOffset=pTDFX->fbOffset+(pScrn->virtualY+128)*pTDFX->stride; - /* Round off to a page */ - pTDFX->backOffset=(pTDFX->backOffset+4095)&~0xFFF; - - /* Depth buffer */ - pTDFX->depthOffset=pTDFX->backOffset+screenSizeInTiles; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n", - (float)texSize/1024.0/1024.0); + pTDFX->cursorOffset = 0; + if (texSize < 0) { + pTDFX->backOffset = -1; + pTDFX->depthOffset = -1; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No Texture Memory available." + " Disabling direct rendering.\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n", + (float)texSize/1024.0/1024.0); + } +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Cursor Offset: [0x%08X,0x%08X)\n", + pTDFX->cursorOffset, + pTDFX->cursorOffset+1024); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Fifo Offset: [0x%08X, 0x%08X)\n", + pTDFX->fifoOffset, + pTDFX->fifoOffset+fifoSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Texture Offset: [0x%08X, 0x%08X)\n", + pTDFX->texOffset, + pTDFX->texOffset + texSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Front Buffer Offset: [0x%08X, 0x%08X)\n", + pTDFX->fbOffset, + pTDFX->fbOffset + + (pScrn->virtualY+PIXMAP_CACHE_LINES)*pTDFX->stride); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BackOffset: [0x%08X, 0x%08X)\n", + pTDFX->backOffset, + pTDFX->backOffset+screenSizeInTiles); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "DepthOffset: [0x%08X, 0x%08X)\n", + pTDFX->depthOffset, + pTDFX->depthOffset+screenSizeInTiles); +#endif /* 0/1 */ } static Bool @@ -1697,16 +1737,12 @@ /* We initialize in the state that our FIFO is up to date */ pTDFX->syncDone=TRUE; -#ifdef PROP_3DFX - if (!TDFXInitPrivate(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n"); + if (!TDFXInitFifo(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize fifo\n"); return FALSE; } -#else - pTDFX->sync=TDFXSync; -#endif - maxy=pScrn->virtualY+128; + maxy=pScrn->virtualY+PIXMAP_CACHE_LINES; MemBox.y1 = pScrn->virtualY; MemBox.x1 = 0; MemBox.x2 = pScrn->displayWidth; @@ -1723,16 +1759,22 @@ pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; + miSetPixmapDepths (); + #ifdef XF86DRI /* * Setup DRI after visuals have been established, but before fbScreenInit * is called. fbScreenInit will eventually call into the drivers * InitGLXVisuals call back. */ - pTDFX->directRenderingEnabled = TDFXDRIScreenInit(pScreen); - /* Force the initialization of the context */ - if (pTDFX->directRenderingEnabled) - TDFXLostContext(pScreen); + if (!pTDFX->NoAccel) { + if ( !((pTDFX->backOffset == -1) && (pTDFX->depthOffset == -1))) { + pTDFX->directRenderingEnabled = TDFXDRIScreenInit(pScreen); + } + /* Force the initialization of the context */ + if (pTDFX->directRenderingEnabled) + TDFXLostContext(pScreen); + } #endif switch (pScrn->bitsPerPixel) { @@ -1745,6 +1787,9 @@ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -1779,7 +1824,6 @@ } REGION_UNINIT(pScreen, &MemRegion); - pTDFX->NoAccel=xf86ReturnOptValBool(TDFXOptions, OPTION_NOACCEL, FALSE); if (!pTDFX->NoAccel) { if (!TDFXAccelInit(pScreen)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -1819,29 +1863,24 @@ #endif #ifdef XF86DRI + if (!pTDFX->NoAccel) { if (pTDFX->directRenderingEnabled) { /* Now that mi, fb, drm and others have done their thing, * complete the DRI setup. */ pTDFX->directRenderingEnabled = TDFXDRIFinishScreenInit(pScreen); } - if (pTDFX->directRenderingEnabled) { + } + if (pTDFX->directRenderingEnabled) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n"); - } else { + } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); - } + } #endif #ifdef XvExtension - { - XF86VideoAdaptorPtr *ptr; - int n; - - n = xf86XVListGenericAdaptors(pScrn,&ptr); - if (n) { - xf86XVScreenInit(pScreen, ptr, n); - } - } + /* Initialize Xv support */ + TDFXInitVideo (pScreen); #endif pScreen->SaveScreen = TDFXSaveScreen; @@ -1920,7 +1959,7 @@ pTDFX = TDFXPTR(pScrn); if (pTDFX->directRenderingEnabled) { DRILock(pScreen, 0); - TDFXSwapContextPrivate(pScreen); + TDFXSwapContextFifo(pScreen); } #endif } @@ -1944,14 +1983,15 @@ } #endif -#ifdef PROP_3DFX - TDFXShutdownPrivate(pScreen); -#endif + TDFXShutdownFifo(pScreen); - TDFXRestore(pScrn); - vgaHWLock(hwp); - TDFXUnmapMem(pScrn); - vgaHWUnmapMem(pScrn); + if (pScrn->vtSema) { + TDFXRestore(pScrn); + vgaHWLock(hwp); + TDFXUnmapMem(pScrn); + vgaHWUnmapMem(pScrn); + } + if (pTDFX->AccelInfoRec) XAADestroyInfoRec(pTDFX->AccelInfoRec); pTDFX->AccelInfoRec=0; if (pTDFX->DGAModes) xfree(pTDFX->DGAModes); Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c:1.5 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c:1.5 Fri Jun 16 20:03:25 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c Fri Aug 25 12:25:36 2000 @@ -24,7 +24,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c,v 1.5 2000/06/17 00:03:25 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c,v 1.6 2000/08/25 16:25:36 tsi Exp $ */ /* * Authors: @@ -71,8 +71,8 @@ } void TDFXSetPIOAccess(TDFXPtr pTDFX) { - if (!pTDFX->PIOBase) - ErrorF("Can not set PIO Access before PIOBase\n"); + if (!pTDFX->PIOBase[0]) + ErrorF("Can not set PIO Access before PIOBase[0]\n"); pTDFX->writeControl=TDFXWriteControlPIO; pTDFX->readControl=TDFXReadControlPIO; pTDFX->writeLong=TDFXWriteLongPIO; @@ -108,8 +108,8 @@ } void TDFXSetMMIOAccess(TDFXPtr pTDFX) { - if (!pTDFX->MMIOBase) - ErrorF("Can not set MMIO access before MMIOBase\n"); + if (!pTDFX->MMIOBase[0]) + ErrorF("Can not set MMIO access before MMIOBase[0]\n"); pTDFX->writeControl=TDFXWriteControlMMIO; pTDFX->readControl=TDFXReadControlMMIO; pTDFX->writeLong=TDFXWriteLongMMIO; Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c:1.10 Wed Jun 21 17:40:04 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c Fri Dec 15 10:19:35 2000 @@ -1,9 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c,v 1.10 2000/06/21 21:40:04 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c,v 1.13 2000/12/15 15:19:35 dawes Exp $ */ -#if 0 -#include <sys/time.h> -#endif #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" @@ -23,7 +20,7 @@ C - D-1 : Z buffer */ -void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo3D(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; @@ -33,7 +30,7 @@ WRITE_FIFO(pTDFX, 0, 0); } -void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo2D(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; @@ -47,10 +44,10 @@ WRITE_FIFO(pTDFX, SST_2D_COMMAND, SST_2D_NOP|SST_2D_GO); } -void TDFXSendNOPPrivate(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo(ScrnInfoPtr pScrn) { - TDFXSendNOPPrivate2D(pScrn); - TDFXSendNOPPrivate3D(pScrn); + TDFXSendNOPFifo2D(pScrn); + TDFXSendNOPFifo3D(pScrn); } void InstallFifo(ScrnInfoPtr pScrn) @@ -78,7 +75,7 @@ pTDFX->fifoPtr = pTDFX->fifoBase; pTDFX->fifoSlots = (pTDFX->fifoSize>>2) - 1; pTDFX->fifoEnd = pTDFX->fifoBase+pTDFX->fifoSlots; - TDFXSendNOPPrivate(pScrn); + TDFXSendNOPFifo(pScrn); } void TDFXResetFifo(ScrnInfoPtr pScrn) @@ -126,7 +123,7 @@ TDFXTRACEACCEL("TDFXSyncFifo start\n"); pTDFX=TDFXPTR(pScrn); - TDFXSendNOPPrivate(pScrn); + TDFXSendNOPFifo(pScrn); i=0; cnt=0; start_sec=0; @@ -152,7 +149,7 @@ pTDFX->prevBlitDest.x2=pTDFX->prevBlitDest.y2=0; } -Bool TDFXInitPrivate(ScreenPtr pScreen) +Bool TDFXInitFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; @@ -172,7 +169,7 @@ return TRUE; } -void TDFXShutdownPrivate(ScreenPtr pScreen) +void TDFXShutdownFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; @@ -200,7 +197,7 @@ } #ifdef XF86DRI -void TDFXSwapContextPrivate(ScreenPtr pScreen) +void TDFXSwapContextFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h:1.5 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h:1.5 Fri Feb 18 07:20:05 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h Fri Dec 15 10:19:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h,v 1.5 2000/02/18 12:20:05 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h,v 1.7 2000/12/15 15:19:35 dawes Exp $ */ #ifndef _TDFX_FIFO_H_ @@ -58,7 +58,7 @@ #endif #define DECLARE SET_PKT2_HEADER #define DECLARE_LAUNCH SET_PK1_HEADER_LAUNCH -#define TDFXSendNOP TDFXSendNOPPrivate +#define TDFXSendNOP TDFXSendNOPFifo /* ** Structures for Banshee AGP/CMD Transfer/MISC registers. Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c:1.2 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c:1.2 Sat Jun 17 14:23:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c Fri Dec 15 10:19:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c,v 1.2 2000/06/17 18:23:23 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c,v 1.6 2000/12/15 15:19:35 dawes Exp $ */ #include "xf86.h" #include "xf86_ansic.h" Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_video.c:1.5 --- /dev/null Mon Dec 18 14:31:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_video.c Fri Dec 8 16:53:37 2000 @@ -0,0 +1,771 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_video.c,v 1.5 2000/12/08 21:53:37 mvojkovi Exp $ */ + +/* Adapted from ../mga/mga_video.c */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "tdfx.h" + +#include "xf86xv.h" +#include "Xv.h" +#include "xaa.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" + +/* These should move into tdfxdefs.h with better names */ +#define YUV_Y_BASE 0xC00000 +#define YUV_U_BASE 0xD00000 +#define YUV_V_BASE 0xE00000 + +#define SST_2D_FORMAT_YUYV 0x8 +#define SST_2D_FORMAT_UYVY 0x9 + +#define YUVBASEADDR 0x80100 +/* This should move to tdfx.h + * Only one port for now due to need for better memory allocation. */ +#define TDFX_MAX_PORTS 1 + +#define YUVSTRIDE 0x80104 + +#ifndef XvExtension +void TDFXInitVideo(ScreenPtr pScreen) {} +#else + + +void TDFXInitVideo(ScreenPtr pScreen); +void TDFXCloseVideo (ScreenPtr pScreen); + +static XF86VideoAdaptorPtr TDFXSetupImageVideo(ScreenPtr); +static int TDFXSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int TDFXGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); + +static void TDFXStopVideo(ScrnInfoPtr, pointer, Bool); +static void TDFXQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, + unsigned int *, unsigned int *, pointer); +static int TDFXPutImage(ScrnInfoPtr, short, short, short, short, short, + short, short, short, int, unsigned char*, short, + short, Bool, RegionPtr, pointer); +#if 0 +/* This isn't done yet, but eventually it will put images to the + * video overlay. */ +static int TDFXPutImageOverlay(ScrnInfoPtr pScrn, short, short, + short, short, short, short, + short, short, int, unsigned char*, + short, short, Bool, RegionPtr , pointer); +#endif + +static int TDFXQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, + unsigned short *, int *, int *); + +/* These function is from tdfx_accel.c */ +extern void TDFXFirstSync(ScrnInfoPtr pScrn); + +static FBAreaPtr +TDFXAllocateOffscreenBuffer (ScrnInfoPtr pScrn, int id, int width, int height); + +static void +TDFXDeallocateOffscreenBuffer (ScrnInfoPtr pScrn, int id); + +void TDFXInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + TDFXPtr pTDFX = TDFXPTR(pScrn); + int num_adaptors; + + /* The hardware can't convert YUV->8 bit color */ + if(pTDFX->cpp == 1) + return; + + newAdaptor = TDFXSetupImageVideo(pScreen); + + /* Initialize the offscreen buffer */ + pTDFX->offscreenYUVBuf = 0; + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + { + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + } + + if(newAdaptors) + xfree(newAdaptors); +} + +void TDFXCloseVideo (ScreenPtr pScreen) +{ + +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { /* blit limit */ + 0, + "XV_IMAGE", + 1024, 0, /* Height is a limitation of pixmap space, and filled in later. */ + {1, 1} + } +}; + +#define NUM_FORMATS_OVERLAY 3 + +static XF86VideoFormatRec Formats[NUM_FORMATS_OVERLAY] = +{ + {15, TrueColor}, {16, TrueColor}, {24, TrueColor}, +}; + +/* #define NUM_IMAGES 4*/ +#define NUM_IMAGES 2 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YV12, /* YVU planar */ + XVIMAGE_I420 /* YUV planar */ +#if 0 + /* These could be supported (without a temp bufer) using the + * host-to-screen-stretch */ + XVIMAGE_YUY2, /* YUYV packed */ + XVIMAGE_UYVY /* UYVY packed */ +#endif +}; + + +static XF86VideoAdaptorPtr +TDFXAllocAdaptor(ScrnInfoPtr pScrn) +{ + DevUnion *devUnions; + int i; + XF86VideoAdaptorPtr adapt; + + if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn))) + return NULL; + /* Allocate a TDFX private structure */ + /* There is no need for a TDFX private structure at this time. But a + * DevUnion has to be provided to the core Xv code. */ + if (!(devUnions = xcalloc (1, sizeof (DevUnion) * TDFX_MAX_PORTS))) + { + xfree (adapt); + return NULL; + } + adapt->pPortPrivates = &devUnions[0]; + + /* Fill in some of the DevUnion */ + for (i = 0; i < TDFX_MAX_PORTS; i++) + { + adapt->pPortPrivates[i].val = i; + adapt->pPortPrivates[i].ptr = NULL; /* No private data */ + } + + return adapt; +} + + + +static XF86VideoAdaptorPtr +TDFXSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr adapt; + TDFXPtr pTDFX = TDFXPTR(pScrn); + + DummyEncoding[0].height = pTDFX->pixmapCacheLines; + + adapt = TDFXAllocAdaptor(pScrn); + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + /* Add VIDEO_OVERLAID_IMAGES if using the overlay */ + adapt->flags = 0; + adapt->name = "3dfx Accelerated Video Engine"; + adapt->nEncodings = 1; + adapt->pEncodings = &DummyEncoding[0]; + adapt->nFormats = NUM_FORMATS_OVERLAY; + adapt->pFormats = Formats; + adapt->nPorts = TDFX_MAX_PORTS; + adapt->nAttributes = 0; + adapt->pAttributes = NULL; + adapt->nImages = NUM_IMAGES; + adapt->pImages = Images; + + /* XXX For now all I'm implementing is PutImage so that programs like OMS + * will work. More will follow as I have time and need. */ + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = TDFXStopVideo; + adapt->SetPortAttribute = TDFXSetPortAttribute; + adapt->GetPortAttribute = TDFXGetPortAttribute; + adapt->QueryBestSize = TDFXQueryBestSize; + adapt->PutImage = TDFXPutImage; + /*adapt->PutImage = TDFXPutImageOverlay; */ + adapt->QueryImageAttributes = TDFXQueryImageAttributes; + + return adapt; +} + + +static void +TDFXStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) +{ + if (cleanup) + { + /* Deallocate the offscreen temporary buffer. */ + TDFXDeallocateOffscreenBuffer (pScrn, 0); + } +} + + +static int +TDFXSetPortAttribute (ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data) +{ + return BadMatch; +} + + +static int +TDFXGetPortAttribute(ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data) +{ + return BadMatch; +} + + + +static void +TDFXQueryBestSize(ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data) +{ + /* No alignment restrictions */ + *p_w = drw_w; + *p_h = drw_h; +} + + + +/* This performs a screen to screen stretch blit. All coordinates are + * in screen memory. This function assumes that the src and dst format + * registers have been setup already. This function does not save + * the registers it trashes. */ +static void +TDFXScreenToScreenYUVStretchBlit (ScrnInfoPtr pScrn, + short src_x1, short src_y1, + short src_x2, short src_y2, + short dst_x1, short dst_y1, + short dst_x2, short dst_y2) +{ + TDFXPtr pTDFX = TDFXPTR(pScrn); + + /* reformulate the paramaters the way the hardware wants them */ + INT32 + src_x = src_x1 & 0x1FFF, + src_y = src_y1 & 0x1FFF, + dst_x = dst_x1 & 0x1FFF, + dst_y = dst_y1 & 0x1FFF, + src_w = (src_x2 - src_x) & 0x1FFF, + src_h = (src_y2 - src_y) & 0x1FFF, + dst_w = (dst_x2 - dst_x) & 0x1FFF, + dst_h = (dst_y2 - dst_y) & 0x1FFF; + + /* Setup for blit src and dest */ + TDFXMakeRoom(pTDFX, 5); + DECLARE(SSTCP_DSTSIZE|SSTCP_SRCSIZE|SSTCP_DSTXY| + SSTCP_COMMAND|SSTCP_COMMANDEXTRA); + /* We want the blit to wait for vsync. */ + TDFXWriteLong(pTDFX, SST_2D_COMMANDEXTRA, 4); + TDFXWriteLong(pTDFX, SST_2D_SRCSIZE, src_w | (src_h<<16)); + TDFXWriteLong(pTDFX, SST_2D_DSTSIZE, dst_w | (dst_h<<16)); + TDFXWriteLong(pTDFX, SST_2D_DSTXY, dst_x | (dst_y<<16)); + /* XXX find the ROP table and figure out why CC is the right choice. */ + TDFXWriteLong(pTDFX, SST_2D_COMMAND, + (0xCC<<24)|SST_2D_SCRNTOSCRNSTRETCH); + /* Write to the launch area to start the blit */ + TDFXMakeRoom(pTDFX, 1); + DECLARE_LAUNCH (1, 0); + TDFXWriteLong(pTDFX, SST_2D_LAUNCH, src_x | (src_y<<16)); +} + +static void +YUVPlanarToPacked (ScrnInfoPtr pScrn, + short src_x, short src_y, + short src_h, short src_w, + int id, char *buf, + short width, short height, + FBAreaPtr fbarea) +{ + TDFXPtr pTDFX = TDFXPTR(pScrn); + + INT32 y; + void *dst; + char *psrc = buf, + *pdst = 0; + int count = 0; + + /* Register saves */ + INT32 + yuvBaseAddr, + yuvStride; + + /* Save these registers so I can restore them when we are done. */ + yuvBaseAddr = TDFXReadLongMMIO(pTDFX, YUVBASEADDR); + yuvStride = TDFXReadLongMMIO(pTDFX, YUVSTRIDE); + + + dst = 0; + + /* Set yuvBaseAddress register to point to the buffer. */ + TDFXWriteLongMMIO (pTDFX, YUVBASEADDR, pTDFX->fbOffset + + pTDFX->stride * (fbarea->box.y1 + pScrn->virtualY) + + fbarea->box.x1); + /* Set yuvStride register to reflect stride of U and V planes */ + /* There is a subtle issue involved with copying the Y plane. Y is + * sampled at twice the rate of the U and V data, in both + * directions. But when packing their needs to be two Y values for + * each U,V pair. So if src_x is odd we will end up missing on + * of the Y values. To correct for this we will always adjust the src + * x value. This adjust is done both in computing the address of the + * pixels to copy and when determining the amount of pixels to copy. + * Note that care needs to be taken to insure that the offscreen + * temporary buffer is allocated with enough space to hold the possible + * extra column of data. + */ + TDFXWriteLongMMIO (pTDFX, YUVSTRIDE, pTDFX->stride); + psrc = (char*)buf; + + /* psrc points to the base of the Y plane, move out to src_x, src_y */ + psrc += (src_x & ~0x1) + src_y * width; + pdst = (char *)pTDFX->MMIOBase[0] + YUV_Y_BASE; + for (y = 0; y < src_h; y++) + { + memcpy (pdst, psrc, src_w + (src_x & 0x1)); + psrc += width; + /* YUV planar region is always 1024 bytes wide */ + pdst += 1024; + } + + /* The difference between FOURCC_YV12 and FOURCC_I420 is the order + * that the U and V planes appear in the buffer. But at this point + * I just send the second buffer as V and the third buffer as U. + * Depending on the format, the packing will be different and we + * handle it in the the way we pick the source format for the blit + * later on. */ + + pdst = (char *)pTDFX->MMIOBase[0] + YUV_V_BASE; + psrc = (char*)buf + width * height; + /* psrc now points to the base of the V plane, move out to src_x/2, + * src_y/2 */ + psrc += (src_x >> 1) + (src_y >> 1) * (width >> 1); + for (y = 0; y < src_h >> 1; y++) + { + /* YUV planar region is always 1024 bytes wide */ + memcpy (pdst, psrc, src_w >> 1); + psrc += width >> 1; + pdst += 1024; + } + pdst = (char *)pTDFX->MMIOBase[0] + YUV_U_BASE; + psrc = (char*)buf + width * height + (width >> 1) * (height >> 1); + /* psrc now points to the base of the U plane, move out to src_x/2, + * src_y/2 */ + psrc += (src_x >> 1) + (src_y >> 1) * (width >> 1); + for (y = 0; y < src_h >> 1; y++) + { + /* YUV planar region is always 1024 bytes wide */ + memcpy (pdst, psrc, src_w >> 1); + psrc += width >> 1; + pdst += 1024; + } + + /* Before restoring trashed registers we have to wait for the conversion + * to finish. We aren't using the FIFO for this but the hardware can + * take a little extra time even after we finish all the writes. If we + * restore the registers before it finishes it can store some of the YUV + * data to the wrong place. One particular wrong place is often on top + * of the hardware cursor data. So we wait for the status register + * to go idle. */ + /* XXX Right now wait for the whole chip to go idle. This is more than + * is required. Find out which subsystem is handles the YUV packing and + * wait only on that status bit. */ + count = 0; + do + { + count++; + } while ((TDFXReadLongMMIO(pTDFX, 0) & SST_BUSY) && count < 1000); + + /* Restore trashed registers */ + TDFXWriteLongMMIO(pTDFX, YUVBASEADDR, yuvBaseAddr); + TDFXWriteLongMMIO(pTDFX, YUVSTRIDE, yuvStride); +} + +static int +TDFXPutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data + ) +{ + TDFXPtr pTDFX = TDFXPTR(pScrn); + + BoxPtr pbox; + int nbox; + + FBAreaPtr fbarea; + + /* Make sure we are synced up (this really means, lock and find the + * fifo pointer. */ + TDFXFirstSync (pScrn); + + /* Do the right thing for the given format */ + switch (id) + { + case FOURCC_YV12: + case FOURCC_I420: + /* Get a buffer to use to store the packed YUV data */ + fbarea = TDFXAllocateOffscreenBuffer (pScrn, id, src_w, src_h); + + if (!fbarea) + { + return Success; + } + + YUVPlanarToPacked (pScrn, src_x, src_y, src_h, src_w, + id, (char *)buf, width, height, + fbarea); + /* Don't know what executed last so we need to send a NOP */ + TDFXSendNOP(pScrn); + + /* Setup the dst and src format once, they don't change for all the + * blits. */ + TDFXMakeRoom(pTDFX, 2); + DECLARE(SSTCP_SRCFORMAT|SSTCP_DSTFORMAT); + TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, + pTDFX->stride|((pTDFX->cpp+1)<<16)); + if (id == FOURCC_YV12) + { + /* Packed format is YUYV */ + TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, + pTDFX->stride|((SST_2D_FORMAT_YUYV)<<16)); + } + else + { + /* Packed format is UYVY */ + TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, + pTDFX->stride|((SST_2D_FORMAT_UYVY)<<16)); + } + + /* Traverse the clip boxes */ + nbox = REGION_NUM_RECTS(clipBoxes); + pbox = REGION_RECTS(clipBoxes); + + while (nbox--) + { + /* The destination clip regions come with the clip boxes, but + * the src coordinates have to be computed because we are doing + * a stretch blit. These macros perform that compuation, but + * they could use some work. When testing with still images these + * computations caused some jitter in the resulting output, but + * with actual video playback I haven't noticed any problems. */ +#define SRC_X1 (fbarea->box.x1) +#define SRC_Y1 (fbarea->box.y1 + pScrn->virtualY) +#define SCALEX(dx) ((int)(((dx) * src_w + (drw_w>>1)) / drw_w)) +#define SCALEY(dy) ((int)(((dy) * src_h + (drw_h>>1)) / drw_h)) + + /* Do the screen-to-screen blit clipped to the clip boxes. */ + TDFXScreenToScreenYUVStretchBlit + (pScrn, + SRC_X1 + SCALEX(pbox->x1 - drw_x), + SRC_Y1 + SCALEY(pbox->y1 - drw_y), + SRC_X1 + SCALEX(pbox->x2 - drw_x), + SRC_Y1 + SCALEY(pbox->y2 - drw_y), + /* these destination coordinates come + * right from the clip box. */ + pbox->x1, pbox->y1, + pbox->x2, pbox->y2); + pbox++; + } + + /* Restore the WAX registers we trashed */ + TDFXMakeRoom(pTDFX, 2); + DECLARE(SSTCP_SRCFORMAT|SSTCP_DSTFORMAT); + TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, pTDFX->sst2DDstFmtShadow); + TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, pTDFX->sst2DSrcFmtShadow); + + /* The rest of the driver won't know what I have done so I do a stall to + * make sure the next command sent will work. */ + TDFXSendNOP(pScrn); + break; + /* XXX What am I supposed to do about the sync flag? */ + + } + + return Success; +} + +/* This code doesn't work yet. Eventually this should use the video overlay + * instead of the YUV-stretch-blit. The overlay is better because it uses + * bilinear filtering when scaling. */ +#if 0 +static int +TDFXPutImageOverlay( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data + ) +{ + TDFXPtr pTDFX = TDFXPTR(pScrn); + + BoxPtr pbox; + int nbox; + + /* Computed Register values */ + INT32 + vidInFormat; + + static FBAreaPtr fbarea; + + /* Do the right thing for the given format */ + switch (id) + { + case FOURCC_YV12: + case FOURCC_I420: + + + /* Get a buffer to use to store the packed YUV data */ + fbarea = TDFXAllocateOffscreenBuffer (pScrn, id, src_w, src_h); + + if (!fbarea) + return Success; + + YUVPlanarToPacked (pScrn, + src_x, src_y, src_h, src_w, + id, buf, width, height, + fbarea); + + /* Setup the overlay */ + TDFXWriteLongMMIO(pTDFX, VIDOVERLAYSTARTCOORDS, + (drw_x&0x7FF) | ((drw_y & 0x7FF) << 12) + /* XXX Lower 2 bits of X and Y? */); + TDFXWriteLongMMIO(pTDFX, VIDOVERLAYENDSCREENCOORDS, + ((drw_x+drw_w)&0x7FF) | (((drw_y+drw_h)&0x7FF) << 12)); + + /* Set the Video in format */ + vidInFormat = 0; + /* These magic numbers come from the spec on page 151 */ + if (id == FOURCC_YV12) + { + /* Packed format is YUYV */ + vidInFormat = 0x9 << 1; + } + else + { + /* Packed format is UYVY */ + vidInFormat = 0xA << 1; + } + + TDFXWriteLongMMIO (pTDFX, VIDINFORMAT, vidInFormat); + TDFXWriteLongMMIO (pTDFX, VIDINSTRIDE, src_w); + + /* Use magenta as the chroma color */ + if (pTDFX->cpp == 2) + { + TDFXWriteLongMMIO(pTDFX, VIDCHROMAMIN, + 0x0000F71F); + TDFXWriteLongMMIO(pTDFX, VIDCHROMAMAX, + 0x0000F71F); + } + else /* (pTDFX->cpp == 3) */ + { + TDFXWriteLongMMIO(pTDFX, VIDCHROMAMIN, + 0x00FF00FF); + TDFXWriteLongMMIO(pTDFX, VIDCHROMAMAX, + 0x00FF00FF); + } + + /* Set the src address */ + TDFXWriteLongMMIO (pTDFX, VIDINADDR0, + pTDFX->fbOffset + + pTDFX->stride * (fbarea->box.y1 + pScrn->virtualY) + + fbarea->box.x1); + + /* Traverse the clip boxes */ + nbox = REGION_NUM_RECTS(clipBoxes); + pbox = REGION_RECTS(clipBoxes); + + while (nbox--) + { + pbox++; + } + break; + } + return Success; +} + +#endif + +static void +TDFXDeallocateOffscreenBuffer (ScrnInfoPtr pScrn, int id) +{ + TDFXPtr pTDFX = TDFXPTR(pScrn); + + /* There is only one buffer so just deallocate it */ + if (pTDFX->offscreenYUVBuf) + xf86FreeOffscreenArea (pTDFX->offscreenYUVBuf); +} + +static FBAreaPtr +TDFXAllocateOffscreenBuffer (ScrnInfoPtr pScrn, int id, int width, int height) +{ + int myWidth; + TDFXPtr pTDFX = TDFXPTR(pScrn); + + if (!pTDFX) + return NULL; + + /* We tweak the width slightly */ + myWidth = width; + /* We tweak the width slightly */ + myWidth = width; + + /* width is measured in pixels. The pixels in the YUV image are alway + * 8 bit YUV data. But, the xf86 offscreen manager allocates in terms of + * desktop pixels, so we adjust. */ + myWidth = myWidth / pTDFX->cpp; + if (width % pTDFX->cpp) + myWidth++; + + /* If we are putting up a subimage then we need an extra column of data + * if the source width is odd, instead of checkin the width just always + * allocate an extra column. */ + /* XXX is this really necessary? */ + myWidth++; + + if (pTDFX->offscreenYUVBuf != NULL && + myWidth == pTDFX->offscreenYUVBufWidth && + height == pTDFX->offscreenYUVBufHeight) + { + /* we already have a buffer, don't do anything. */ + return pTDFX->offscreenYUVBuf; + } + + /* We have a buffer, but its not the right size so resize it */ + if (pTDFX->offscreenYUVBuf != NULL) + { + if (!xf86ResizeOffscreenArea (pTDFX->offscreenYUVBuf, + myWidth, + height)) + { + return (NULL); + } + } + else + { + /* Allocate a brand new buffer */ + pTDFX->offscreenYUVBuf = + xf86AllocateOffscreenArea (pScrn->pScreen, + myWidth, + height, + 0, + NULL, NULL, NULL); + } + + /* Return the buffer */ + pTDFX->offscreenYUVBufWidth = myWidth; + pTDFX->offscreenYUVBufHeight = height; + return (pTDFX->offscreenYUVBuf); +} + + +static int +TDFXQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets) +{ + + int size; + TDFXPtr pTDFX = TDFXPTR(pScrn); + + /* The Maximum size for 3dfx YUV planar space + * but our temporary buffer has to fit in the pixmap region which + * is the same width as the desktop and pTDFX->pixmapCacheLines + * pixels high. + */ + if(*w > 1024) *w = 1024; + if (*w > pTDFX->stride) *w = pTDFX->stride; + if(*h > pTDFX->pixmapCacheLines) *h = pTDFX->pixmapCacheLines; + + + + if (offsets) offsets[0] = 0; + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + if (pitches) pitches[0] = *w; + /* Size of Y plane plus the size of U and V planes */ + size = *w * *h; + if (offsets) offsets[1] = size; + size += ((*w >> 1) * (*h >> 1)); + if (offsets) offsets[2] = size; + size += ((*w >> 1) * (*h >> 1)); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + return size; +} + +#endif /* !XvExtension */ Index: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h:1.6 Fri Jun 16 20:03:25 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h Fri Dec 15 10:19:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h,v 1.6 2000/06/17 00:03:25 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h,v 1.9 2000/12/15 15:19:35 dawes Exp $ */ /* Voodoo Banshee driver version 1.0.1 @@ -52,8 +52,26 @@ #define MEM_TYPE_SGRAM 0 #define MEM_TYPE_SDRAM 1 +/* + * SST_RAW_LFB_ADDR_STRIDE(Lg2SizeInK) takes the + * lfbMemoryConfig value for SGRAMStrideInTiles. This + * is given by this table: + * SGRAMStrideInBytes lfbMemoryConfig Value + * ================== ===================== + * 1k 0 + * 2k 1 + * 4k 2 + * 8k 3 + * 16k 4 + * + * FWIW, the right hand column is log2(left hand column)-10 + */ #define SST_RAW_LFB_ADDR_STRIDE_SHIFT 13 -#define SST_RAW_LFB_ADDR_STRIDE_4K 0x2<<SST_RAW_LFB_ADDR_STRIDE_SHIFT +#define SST_RAW_LFB_ADDR_STRIDE(Lg2SizeInK) \ + ((Lg2SizeInK)<<SST_RAW_LFB_ADDR_STRIDE_SHIFT) +#define SST_RAW_LFB_ADDR_STRIDE_4K SST_RAW_LFB_ADDR_STRIDE(2) +#define SST_RAW_LFB_ADDR_STRIDE_8K SST_RAW_LFB_ADDR_STRIDE(3) +#define SST_RAW_LFB_ADDR_STRIDE_16K SST_RAW_LFB_ADDR_STRIDE(4) #define SST_RAW_LFB_TILE_STRIDE_SHIFT 16 #define BLIT_LEFT 1 Index: xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c:1.4 xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c:1.4 Sun Feb 7 06:11:14 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c Fri Oct 20 08:57:26 2000 @@ -24,7 +24,7 @@ * tgaBTOutIndReg() and tgaBTInIndReg() are used to access * the indirect TGA BT RAMDAC registers only. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c,v 1.4 1999/02/07 11:11:14 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/BTramdac.c,v 1.5 2000/10/20 12:57:26 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -114,4 +114,65 @@ pTga = TGAPTR(pScrn); return(TGA_READ_REG(TGA_RAMDAC_REG)>>16); +} + +/********************* TGA2 stuff below here ********************/ + +void +tga2BTOutIndReg(ScrnInfoPtr pScrn, + CARD32 reg, unsigned char mask, unsigned char data) +{ + TGAPtr pTga; + unsigned char tmp = 0x00; + unsigned int addr = 0xe000U | (reg << 8); + + pTga = TGAPTR(pScrn); + + if (mask != 0x00) + tmp = TGA2_READ_RAMDAC_REG(addr) & mask; + +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "tga2OutIndReg: reg 0x%x data 0x%x\n", + reg, tmp|data); +#endif + TGA2_WRITE_RAMDAC_REG ((tmp | data), addr); +} + +unsigned char +tga2BTInIndReg (ScrnInfoPtr pScrn, CARD32 reg) +{ + TGAPtr pTga; + unsigned char ret; + unsigned int addr = 0xe000U | (reg << 8); + + pTga = TGAPTR(pScrn); + + ret = TGA2_READ_RAMDAC_REG(addr); + + return (ret); +} + +void +tga2BTWriteAddress (ScrnInfoPtr pScrn, CARD32 index) +{ + tga2BTOutIndReg(pScrn, BT_WRITE_ADDR, 0, index); +} + +void +tga2BTWriteData (ScrnInfoPtr pScrn, unsigned char data) +{ + tga2BTOutIndReg(pScrn, BT_RAMDAC_DATA, 0, data); +} + +void +tga2BTReadAddress (ScrnInfoPtr pScrn, CARD32 index) +{ + tga2BTOutIndReg(pScrn, BT_PIXEL_MASK, 0, 0xff); + tga2BTOutIndReg(pScrn, BT_READ_ADDR, 0, index); +} + +unsigned char +tga2BTReadData (ScrnInfoPtr pScrn) +{ + return tga2BTInIndReg(pScrn, BT_RAMDAC_DATA); } Index: xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c:1.2 --- /dev/null Mon Dec 18 14:31:14 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c Mon Oct 23 17:16:50 2000 @@ -0,0 +1,736 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/IBM561ramdac.c,v 1.2 2000/10/23 21:16:50 tsi Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +#include "tga_regs.h" +#include "tga.h" + +/* + * useful defines for managing the IBM561 on the 24-plane TGA2s + */ + +#define IBM561_HEAD_MASK 0x01 +#define IBM561_READ 0x02 +#define IBM561_WRITE 0x00 + +#define RAMDAC_ONE_BYTE 0x0E000 +#define RAMDAC_TWO_BYTES 0x0c000 +#define RAMDAC_THREE_BYTES 0x08000 +#define RAMDAC_FOUR_BYTES 0x00000 + +#define IBM561_ADDR_LOW 0x0000 +#define IBM561_ADDR_HIGH 0x0100 +#define IBM561_CMD_REGS 0x0200 + +#define IBM561_CMD_CURS_PIX 0x0200 +#define IBM561_CMD_CURS_LUT 0x0300 +#define IBM561_CMD_FB_WAT 0x0300 +#define IBM561_CMD_AUXFB_WAT 0x0200 +#define IBM561_CMD_OL_WAT 0x0300 +#define IBM561_CMD_AUXOL_WAT 0x0200 +#define IBM561_CMD_GAMMA 0x0300 +#define IBM561_CMD_CMAP 0x0300 + +#define IBM561_ADDR_EPSR_SHIFT 0 +#define IBM561_ADDR_EPDR_SHIFT 8 + +#define IBM561_CONFIG_REG_1 0x0001 +#define IBM561_CONFIG_REG_2 0x0002 +#define IBM561_CONFIG_REG_1 0x0001 +#define IBM561_CONFIG_REG_2 0x0002 +#define IBM561_CONFIG_REG_3 0x0003 +#define IBM561_CONFIG_REG_4 0x0004 +#define IBM561_WAT_SEG_REG 0x0006 +#define IBM561_OL_SEG_REG 0x0007 +#define IBM561_CHROMA_KEY_REG0 0x0010 +#define IBM561_CHROMA_KEY_REG1 0x0011 +#define IBM561_CHROMA_MASK_REG0 0x0012 +#define IBM561_CHROMA_MASK_REG1 0x0013 +#define IBM561_SYNC_CONTROL 0x0020 +#define IBM561_PLL_VCO_DIV_REG 0x0021 +#define IBM561_PLL_REF_REG 0x0022 +#define IBM561_CURSOR_CTRL_REG 0x0030 +#define IBM561_CURSOR_HS_REG 0x0034 +#define IBM561_VRAM_MASK_REG 0x0050 +#define IBM561_DAC_CTRL 0x005f +#define IBM561_DIV_DOT_CLK_REG 0x0082 + +#define IBM561_READ_MASK 0x0205 +#define IBM561_BLINK_MASK 0x0209 +#define IBM561_FB_WINDOW_TYPE_TABLE 0x1000 +#define IBM561_AUXFB_WINDOW_TYPE_TABLE 0x0E00 +#define IBM561_OL_WINDOW_TYPE_TABLE 0x1400 +#define IBM561_AUXOL_WINDOW_TYPE_TABLE 0x0F00 +#define IBM561_RED_GAMMA_TABLE 0x3000 +#define IBM561_GREEN_GAMMA_TABLE 0x3400 +#define IBM561_BLUE_GAMMA_TABLE 0x3800 +#define IBM561_COLOR_LOOKUP_TABLE 0x4000 +#define IBM561_CURSOR_LOOKUP_TABLE 0x0a11 +#define IBM561_CURSOR_BLINK_TABLE 0x0a15 +#define IBM561_CROSS_LOOKUP_TABLE 0x0a19 +#define IBM561_CROSS_BLINK_TABLE 0x0a1d +#define IBM561_CURSOR_PIXMAP 0x2000 +#define IBM561_CURSOR_X_LOW 0x0036 +#define IBM561_CURSOR_X_HIGH 0x0037 +#define IBM561_CURSOR_Y_LOW 0x0038 +#define IBM561_CURSOR_Y_HIGH 0x0039 + +#define LO_ADDR (IBM561_ADDR_LOW | RAMDAC_ONE_BYTE) +#define HI_ADDR (IBM561_ADDR_HIGH | RAMDAC_ONE_BYTE) + +#define REGS_ADDR (IBM561_CMD_REGS | RAMDAC_ONE_BYTE) +#define FBWAT_ADDR (IBM561_CMD_FB_WAT | RAMDAC_ONE_BYTE) +#define AUXFBWAT_ADDR (IBM561_CMD_AUXFB_WAT | RAMDAC_ONE_BYTE) +#define OLWAT_ADDR (IBM561_CMD_OL_WAT | RAMDAC_ONE_BYTE) +#define AUXOLWAT_ADDR (IBM561_CMD_AUXOL_WAT | RAMDAC_ONE_BYTE) +#define CMAP_ADDR (IBM561_CMD_CMAP | RAMDAC_ONE_BYTE) +#define GAMMA_ADDR (IBM561_CMD_GAMMA | RAMDAC_ONE_BYTE) + +#define IBM561LoadAddr(reg) \ +do { \ + TGA2_WRITE_RAMDAC_REG((reg), LO_ADDR); \ + TGA2_WRITE_RAMDAC_REG((reg) >> 8, HI_ADDR); \ +} while (0) + +unsigned char +IBM561ReadReg(ScrnInfoPtr pScrn, CARD32 reg) +{ + TGAPtr pTga; + unsigned char ret; + + pTga = TGAPTR(pScrn); + + TGA2_WRITE_RAMDAC_REG(reg, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(reg >> 8, HI_ADDR); + + ret = TGA2_READ_RAMDAC_REG(REGS_ADDR); + +#if 1 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "IBM561ReadReg: reg 0x%x data 0x%x\n", + reg, ret); +#endif + return (ret); +} + +void +IBM561WriteReg(ScrnInfoPtr pScrn, CARD32 reg, +#if 0 + unsigned char mask, unsigned char data) +#else + unsigned char data) +#endif +{ + TGAPtr pTga; + unsigned char tmp = 0x00; + + pTga = TGAPTR(pScrn); + +#if 0 + if (mask != 0x00) { + TGA2_WRITE_RAMDAC_REG(reg, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(reg >> 8, HI_ADDR); + tmp = TGA2_READ_RAMDAC_REG(REGS_ADDR) & mask; + } +#endif + +#if 1 + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "IBM561WriteReg: reg 0x%x data 0x%x\n", + reg, tmp | data); +#endif + + TGA2_WRITE_RAMDAC_REG(reg, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(reg >> 8, HI_ADDR); + TGA2_WRITE_RAMDAC_REG ((tmp | data), REGS_ADDR); +} + +void +IBM561ramdacSave(ScrnInfoPtr pScrn, unsigned char *Ibm561) +{ +#if 0 + TGAPtr pTga = TGAPTR(pScrn); + int i, j; + + /* ?? FIXME OR NOT this is from BT463ramdacSave ?? */ + Ibm561[0] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_CMD_REG_0); + Ibm561[1] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_CMD_REG_1); + Ibm561[2] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_CMD_REG_2); + + Ibm561[3] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_READ_MASK_0); + Ibm561[4] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_READ_MASK_1); + Ibm561[5] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_READ_MASK_2); + Ibm561[6] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_READ_MASK_3); + + Ibm561[7] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_BLINK_MASK_0); + Ibm561[8] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_BLINK_MASK_1); + Ibm561[9] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_BLINK_MASK_2); + Ibm561[10] = IBM561_READ(pTga, IBM561_REG_ACC, IBM561_BLINK_MASK_3); + + IBM561_LOAD_ADDR(IBM561_WINDOW_TYPE_BASE); + TGA_WRITE_REG((IBM561_REG_ACC<<2)|0x2, TGA_RAMDAC_SETUP_REG); + + for (i = 0, j = 11; i < 16; i++) { + Ibm561[j++] = (TGA_READ_REG(TGA_RAMDAC_REG)>>16)&0xff; + Ibm561[j++] = (TGA_READ_REG(TGA_RAMDAC_REG)>>16)&0xff; + Ibm561[j++] = (TGA_READ_REG(TGA_RAMDAC_REG)>>16)&0xff; + } +#endif + +/* + fprintf(stderr, "IBM561ramdacSave (%p)\n", Ibm561); + for (i=0; i<58; i++) + fprintf(stderr, "%2d: 0x%02x\n", i, (unsigned)Ibm561[i]); +*/ +} + +static void +IBM561WindowTagsInit(ScrnInfoPtr pScrn) +{ + TGAPtr pTga = TGAPTR(pScrn); + unsigned char low, high; + int i; + +/* + tga.h defines fb_wid_cell_t as a structure containing two bytes, + low and high in order. The 561 has 10 bit window tags so only + part of the high byte is used (actually only 2 bits). Pixel C for + 8-plane indexes uses 16bpp indexing per IBM's application notes + which describe quad bufering. Note, this array is arranged as + low byte followed by high byte which will apppear backwards + relative to the 561 spec( a value of 0x01 in the high byte + really represents a color table starting address of 256). + ex (entry 4): + {0x28, 0x01}, *4 8-plane index (PIXEL C 561 H/W screw-up) * + low byte = 0x28 + high byte = 0x01 + wat entry = 0x0128 + + from the spec: 8 in the low nibble selects buffer 1 + 2 in the next nibble selects pixformat of 16 bpp + 1 in the next nibble indicates a start addr of 256 +*/ +typedef struct { + unsigned char low_byte; + unsigned char high_byte; +}fb_wid_cell_t; + +typedef struct { + unsigned char aux_fbwat; +} aux_fb_wid_cell_t; + +typedef struct { + unsigned char low_byte; + unsigned char high_byte; +} ol_wid_cell_t; + +typedef struct { + unsigned char aux_olwat; +} aux_ol_wid_cell_t; + +/* + * There are actually 256 window tag entries in the FB and OL WAT tables. + * We will use only 16 for compatability with the BT463 and more importantly + * to implement the virtual ramdac interface. This requires us to only + * report the smallest WAT table size, in this case its the auxillary wat + * tables which are 16 entries. + */ + +#define TGA_RAMDAC_561_FB_WINDOW_TAG_COUNT 256 +#define TGA_RAMDAC_561_FB_WINDOW_TAG_MAX_COUNT 16 +#define TGA_RAMDAC_561_AUXFB_WINDOW_TAG_COUNT 16 +#define TGA_RAMDAC_561_OL_WINDOW_TAG_COUNT 256 +#define TGA_RAMDAC_561_OL_WINDOW_TAG_MAX_COUNT 16 +#define TGA_RAMDAC_561_AUXOL_WINDOW_TAG_COUNT 16 +#define TGA_RAMDAC_561_CMAP_ENTRY_COUNT 1024 +#define TGA_RAMDAC_561_GAM_ENTRY_COUNT 256 + + static fb_wid_cell_t + fb_wids_561[TGA_RAMDAC_561_FB_WINDOW_TAG_COUNT] = { +#if 0 + {0x28, 0x00}, /*0 8-plane index (PIXEL C 561 H/W screw-up) */ +#else + {0x36, 0x00}, /*c 24-plane true */ +#endif + {0x08, 0x00}, /*1 8-plane index (PIXEL B) */ + {0x00, 0x00}, /*2 8-plane index (PIXEL A) */ + {0x34, 0x00}, /*3 24-plane direct, cmap 0 */ + {0x28, 0x01}, /*4 8-plane index (PIXEL C 561 H/W screw-up) */ + {0x08, 0x01}, /*5 8-plane index (PIXEL B) */ + {0x00, 0x01}, /*6 8-plane index (PIXLE A) */ + {0x34, 0x01}, /*7 24-plane direct, cmap 1 */ + {0x1e, 0x00}, /*8 12-plane true */ + /*{0x16, 0x00}, 9 12-plane true */ + {0x14, 0x00}, /*9 12-plane true(direct) */ + {0x1e, 0x01}, /*a 12-plane true */ + {0x16, 0x01}, /*b 12-plane true */ + {0x36, 0x00}, /*c 24-plane true */ + {0x36, 0x00}, /*d 24-plane true */ + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0} + }; + + static aux_fb_wid_cell_t + auxfb_wids_561[TGA_RAMDAC_561_AUXFB_WINDOW_TAG_COUNT] = { + {0x04}, /*0 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*1 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*2 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*3 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*4 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*5 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*6 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*7 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*8 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*9 GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*a GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*b GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*c GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*d GMA=bypass, XH=disable, PT=dc */ + {0x04}, /*e old cursor colors for 463 don't use*/ + {0x04}, /*f old cursor colors for 463 don't use*/ + }; + + static ol_wid_cell_t + ol_wids_561[TGA_RAMDAC_561_OL_WINDOW_TAG_COUNT] = { + {0x31, 0x02}, /*0 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*1 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*2 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*3 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*4 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*5 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*6 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*7 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*8 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*9 PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*a PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*b PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*c PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*d PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*e PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0x31, 0x02}, /*f PX=4bpp, BS=0, MODE=index, TR=OPAQ */ + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0} + }; + + static aux_ol_wid_cell_t + auxol_wids_561[TGA_RAMDAC_561_AUXOL_WINDOW_TAG_COUNT] = { + {0x0c}, /*0 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*1 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*2 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*3 CK/OT=dc, UL=disabled, OL=enabled, GB=use */ + {0x0c}, /*4 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*5 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*6 CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*7 CK/OT=dc, UL=disabled, OL=enabled, GB=use */ + {0x0c}, /*8 CK/OT=dc, UL=disabled, OL=disabled, GB=use */ + {0x0c}, /*9 CK/OT=dc, UL=disabled, OL=enabled, GB=use */ + {0x0c}, /*a CK/OT=dc, UL=disabled, OL=enabled, GB=use */ + {0x0c}, /*b CK/OT=dc, UL=disabled, OL=enabled, GB=use */ + {0x0c}, /*c CK/OT=dc, UL=disabled, OL=enabled, GB=bypass */ + {0x0c}, /*d CK/OT=dc, UL=disabled, OL=disabled, GB=bypass */ + {0x0c}, /*e old cursor color for 463, don't use */ + {0x0c}, /*f old cursor color for 463, don't use */ + }; + + /* ibm561 so init the window tags's via interrupt. It must be + * done either during the vsync interrupt or by blanking, We will + * actually do both. ??????? + */ + + IBM561LoadAddr(IBM561_FB_WINDOW_TYPE_TABLE); + for ( i = 0; i < TGA_RAMDAC_561_FB_WINDOW_TAG_COUNT; i++ ) { + low = ((fb_wids_561[i].low_byte & 0xfc) >> 2); + high =((fb_wids_561[i].high_byte & 0x03) << 6) & 0xff; + TGA2_WRITE_RAMDAC_REG (low | high, FBWAT_ADDR); + + low = (fb_wids_561[i].low_byte & 0x03) << 6; + TGA2_WRITE_RAMDAC_REG (low, FBWAT_ADDR); + } + + IBM561LoadAddr(IBM561_AUXFB_WINDOW_TYPE_TABLE); + for ( i = 0; i < TGA_RAMDAC_561_AUXFB_WINDOW_TAG_COUNT; i++ ) { + TGA2_WRITE_RAMDAC_REG (auxfb_wids_561[i].aux_fbwat, AUXFBWAT_ADDR); + } + + + IBM561LoadAddr(IBM561_OL_WINDOW_TYPE_TABLE); + for ( i = 0; i < TGA_RAMDAC_561_OL_WINDOW_TAG_COUNT; i++ ) { + low = ((ol_wids_561[i].low_byte & 0xfc) >> 2); + high =((ol_wids_561[i].high_byte & 0x03) << 6) & 0xff; + TGA2_WRITE_RAMDAC_REG (low | high, OLWAT_ADDR); + + low = (ol_wids_561[i].low_byte & 0x03) << 6; + TGA2_WRITE_RAMDAC_REG (low, OLWAT_ADDR); + } + + + IBM561LoadAddr(IBM561_AUXOL_WINDOW_TYPE_TABLE); + for ( i = 0; i < TGA_RAMDAC_561_AUXOL_WINDOW_TAG_COUNT; i++ ) { + TGA2_WRITE_RAMDAC_REG (auxol_wids_561[i].aux_olwat, AUXOLWAT_ADDR); + } +} + +/* + * ibm561_init_color_map + * + * Initialize color map in 561. Note the entire + * color map is initialized, both the 8-bit and the 24-bit + * portions. + */ +static int +IBM561InitColormap(ScrnInfoPtr pScrn) +{ + TGAPtr pTga = TGAPTR(pScrn); +#if 0 + tga_ibm561_info_t *bti = (tga_ibm561_info_t *) closure; + tga_info_t *tgap = tga_softc[bti->unit]; +#endif + int i; + + TGA2_WRITE_RAMDAC_REG(IBM561_COLOR_LOOKUP_TABLE, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_COLOR_LOOKUP_TABLE >> 8, HI_ADDR); + + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + } + + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + } + + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + } + + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, CMAP_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + TGA2_WRITE_RAMDAC_REG (i, CMAP_ADDR); + } + + /* + * The ddx layer views the gamma table as an extension of the + * color pallettes, therefore the gamma table is initialized here. + * Note, each entry in the table is 10 bits, requiring two writes + * per entry!! The table are initialized the same way as color tables, + * a zero entry followed by mulitple ff's. NOTE, the gamma tables are + * loaded in a strange manner, DO NOT use this code as a guide (we are + * writing all zero's or all ones). See the tga_ibm561_load_color_map + * _entry code above. + */ + + TGA2_WRITE_RAMDAC_REG(IBM561_RED_GAMMA_TABLE, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_RED_GAMMA_TABLE >> 8, HI_ADDR); + + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + } + + TGA2_WRITE_RAMDAC_REG(IBM561_GREEN_GAMMA_TABLE, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_GREEN_GAMMA_TABLE >> 8, HI_ADDR); + + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + } + + TGA2_WRITE_RAMDAC_REG(IBM561_BLUE_GAMMA_TABLE, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_BLUE_GAMMA_TABLE >> 8, HI_ADDR); + + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0x00, GAMMA_ADDR); + + for ( i = 1; i <256; i++ ) { + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + TGA2_WRITE_RAMDAC_REG (0xff, GAMMA_ADDR); + } + + +#if 0 + /* ?? no cursor support yet */ + bti->cursor_fg.red = bti->cursor_fg.green = bti->cursor_fg.blue + = 0xffff; + bti->cursor_bg.red = bti->cursor_bg.green = bti->cursor_bg.blue + = 0x0000; + tga_ibm561_restore_cursor_color( closure, 0 ); +#endif + + return 0; +} + +void +IBM561ramdacHWInit(ScrnInfoPtr pScrn) +{ + TGAPtr pTga = TGAPTR(pScrn); + + unsigned int temp1[6] = {0,0,0,0,0,0}; + struct monitor_data * c_table = &crystal_table; + + /* + * Set-up av9110 to 14.3 Mhz as reference for 561's PLL + */ + temp1[0] = 0x00000101; + temp1[1] = 0x01000000; + temp1[2] = 0x00000001; + temp1[3] = 0x00010000; + temp1[4] = 0x01010100; + temp1[5] = 0x01000000; + + write_av9110(pScrn, temp1); + + /* + * Initialize IBM561 RAMDAC + */ + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_1, 0x2a ); + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_3, 0x41 ); + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_4, 0x20 ); + +/* IBM561WriteReg(pScrn, IBM561_PLL_VCO_DIV_REG, 0xc8 ); */ + IBM561WriteReg(pScrn, IBM561_PLL_VCO_DIV_REG, c_table->ibm561_vco_div); + +/* IBM561WriteReg(pScrn, IBM561_PLL_REF_REG, 0x08 ); */ + IBM561WriteReg(pScrn, IBM561_PLL_REF_REG, c_table->ibm561_ref ); + + IBM561WriteReg(pScrn, IBM561_DIV_DOT_CLK_REG, 0xb0 ); + + IBM561WriteReg(pScrn, IBM561_SYNC_CONTROL, 0x01 ); + + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_2, 0x19 ); + + TGA_WRITE_REG(0xFFFFFFFF, TGA_PLANEMASK_REG); + + /* Configure the RAMDAC, note registers not set either depend on the + * previous setting (ie what firmaware programmed to be) or what the + * X-server will set them to + */ + + + /* + * Config Register 1: MUX=4:1 BASIC, OVLY=8 bits, WID=8 bits (bits 4-7 of the + * overlay and window ID's are tied to ground in the hardware). + */ + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_1, 0x2a ); + + /* SKIP Config Register 2-3 (use Diag settings at least for now) */ + + /* + * Config Register 4: FB_WID=4 bits, SWE=Common, AOW=LSB, AFW=LSB + */ + IBM561WriteReg(pScrn, IBM561_CONFIG_REG_4, 0x20 ); + + /* + * SKIP Interleave Register (use Diag settings at least for now) + */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* + * WAT/OL Segement Registers + */ + /* ?? we setup the address registers first, then stream the data out ?? */ + TGA2_WRITE_RAMDAC_REG(IBM561_WAT_SEG_REG, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_WAT_SEG_REG >> 8, HI_ADDR); + + /* WAT Segment Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* OL Segment Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* AUX WAT Segment Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* AUX OL Segment Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* + * Chroma Key Registers and Masks + */ + /* ?? we setup the address registers first, then stream the data out ?? */ + TGA2_WRITE_RAMDAC_REG(IBM561_CHROMA_KEY_REG0, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_CHROMA_KEY_REG0 >> 8, HI_ADDR); + + /* Chroma key register 0 */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Chroma key register 1 */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Chroma key mask register 0 */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Chroma key mask register 1 */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* + * Cursor Control Register + */ + IBM561WriteReg(pScrn, IBM561_CURSOR_CTRL_REG, /*pScrn->cursor_on_off*/0); + + /* + * Cursor Hot Spot X/Y Registers + */ + TGA2_WRITE_RAMDAC_REG(IBM561_CURSOR_HS_REG, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_CURSOR_HS_REG >> 8, HI_ADDR); + + /* Cursor "x" Hot Spot Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Cursor "y" Hot Spot Register */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Cursor "x" Location Register (low byte) */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* Cursor "x" Location Register (high byte) */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* Cursor "y" Location Register (low byte) */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* Cursor "y" Location Register (high byte) */ + TGA2_WRITE_RAMDAC_REG (0x00, REGS_ADDR); + + /* + * VRAM Mask regs (used for diag purposes, reset them just in case) + */ + TGA2_WRITE_RAMDAC_REG(IBM561_VRAM_MASK_REG, LO_ADDR); + TGA2_WRITE_RAMDAC_REG(IBM561_VRAM_MASK_REG >> 8, HI_ADDR); + + /* VRAM mask register 1 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 2 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 3 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 4 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 5 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 6 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* VRAM mask register 7 */ + TGA2_WRITE_RAMDAC_REG (0xff, REGS_ADDR); + + /* Finally, do colormaps and windowtags */ + IBM561InitColormap(pScrn); + IBM561WindowTagsInit(pScrn); +} + +void +IBM561ramdacRestore(ScrnInfoPtr pScrn, unsigned char *Ibm561) +{ +#if 0 + TGAPtr pTga = TGAPTR(pScrn); +#endif + +#if 0 + /* ?? finally the stock stuff ?? */ + int i, j; + /* ?? FIXME OR NOT this is currently copied from the BT463 */ + IBM561_WRITE(IBM561_REG_ACC, IBM561_CMD_REG_0, Ibm561[0]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_CMD_REG_1, Ibm561[1]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_CMD_REG_2, Ibm561[2]); + + IBM561_WRITE(IBM561_REG_ACC, IBM561_READ_MASK_0, Ibm561[3]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_READ_MASK_1, Ibm561[4]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_READ_MASK_2, Ibm561[5]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_READ_MASK_3, Ibm561[6]); + + IBM561_WRITE(IBM561_REG_ACC, IBM561_BLINK_MASK_0, Ibm561[7]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_BLINK_MASK_1, Ibm561[8]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_BLINK_MASK_2, Ibm561[9]); + IBM561_WRITE(IBM561_REG_ACC, IBM561_BLINK_MASK_3, Ibm561[10]); + + IBM561_LOAD_ADDR(IBM561_WINDOW_TYPE_BASE); + TGA_WRITE_REG((IBM561_REG_ACC<<2), TGA_RAMDAC_SETUP_REG); + + for (i = 0, j = 11; i < 16; i++) { + TGA_WRITE_REG(Ibm561[j++]|(IBM561_REG_ACC<<10), TGA_RAMDAC_REG); + TGA_WRITE_REG(Ibm561[j++]|(IBM561_REG_ACC<<10), TGA_RAMDAC_REG); + TGA_WRITE_REG(Ibm561[j++]|(IBM561_REG_ACC<<10), TGA_RAMDAC_REG); + } +#endif + +/* + fprintf(stderr, "IBM561ramdacRestore (%p)\n", Ibm561); + for (i=0; i<58; i++) + fprintf(stderr, "%2d: 0x%02x\n", i, (unsigned)Ibm561[i]); +*/ + +} + Index: xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile:1.12 xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile:1.15 --- xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile:1.12 Mon Dec 13 21:55:37 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile Sat Oct 21 14:40:13 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile,v 1.12 1999/12/14 02:55:37 robin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/Imakefile,v 1.15 2000/10/21 18:40:13 dawes Exp $ XCOMM XCOMM This is an Imakefile for the TGA driver. XCOMM @@ -6,8 +6,8 @@ #define IHaveModules #include <Server.tmpl> -SRCS = tga_driver.c tga_dac.c tga_accel.c BTramdac.c ICS1562.c BT463ramdac.c tga_cursor.c tga_line.c tga_seg.c -OBJS = tga_driver.o tga_dac.o tga_accel.o BTramdac.o ICS1562.o BT463ramdac.o tga_cursor.o tga_line.o tga_seg.o +SRCS = tga_driver.c tga_dac.c tga_accel.c BTramdac.c ICS1562.c BT463ramdac.c tga_cursor.c tga_line.c tga_seg.c IBM561ramdac.c +OBJS = tga_driver.o tga_dac.o tga_accel.o BTramdac.o ICS1562.o BT463ramdac.o tga_cursor.o tga_line.o tga_seg.o IBM561ramdac.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -17,7 +17,8 @@ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/rac -I$(EXTINCSRC) \ - -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) + -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ + -I$(SERVERSRC)/render #endif #if MakeHasPosixVariableSubstitutions @@ -36,6 +37,7 @@ InstallDriverSDKNonExecFile(BT463ramdac.c,$(DRIVERSDKDIR)/drivers/tga) InstallDriverSDKNonExecFile(BTramdac.c,$(DRIVERSDKDIR)/drivers/tga) +InstallDriverSDKNonExecFile(IBM561ramdac.c,$(DRIVERSDKDIR)/drivers/tga) InstallDriverSDKNonExecFile(ICS1562.c,$(DRIVERSDKDIR)/drivers/tga) InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/tga) InstallDriverSDKNonExecFile(tga.h,$(DRIVERSDKDIR)/drivers/tga) Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h:1.14 xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h:1.15 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h:1.14 Mon Mar 6 17:59:31 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h Fri Oct 20 08:57:26 2000 @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h,v 1.14 2000/03/06 22:59:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h,v 1.15 2000/10/20 12:57:26 alanh Exp $ */ #ifndef _TGA_H_ #define _TGA_H_ @@ -45,10 +45,13 @@ int HwBpp; int BppShift; int pprod; + CARD32 CardAddress; CARD32 IOAddress; CARD32 FbAddress; unsigned char * FbBase; unsigned char * IOBase; + unsigned char * ClkBase; /* TGA2 */ + unsigned char * DACBase; /* TGA2 */ long FbMapSize; unsigned long regOffset; Bool NoAccel; @@ -69,6 +72,8 @@ int CardType; unsigned char Bt463modeReg[59]; unsigned char Bt463saveReg[59]; + unsigned char Ibm561modeReg[59]; + unsigned char Ibm561saveReg[59]; EntityInfoPtr pEnt; CARD32 *buffers[1]; unsigned int current_rop; @@ -87,6 +92,36 @@ int depthflag; /* either BPP8PACKED or BPP24 */ } TGARec, *TGAPtr; +/* ?? this is a hack for initial TGA2 support */ +struct monitor_data { + unsigned int max_rows; /* Monitor setup */ + unsigned int max_cols; + unsigned int pixel_freq; + unsigned int refresh_rate; + unsigned int vert_slines; + unsigned int vert_fp; + unsigned int vert_sync; + unsigned int vert_bp; + unsigned int horz_pix; + unsigned int horz_fp; + unsigned int horz_sync; + unsigned int horz_bp; + unsigned int vco_div; /* ICS setup */ + unsigned int ref_div; + unsigned int vco_pre; + unsigned int clk_div; + unsigned int vco_out_div; + unsigned int clk_out_en; + unsigned int clk_out_enX; + unsigned int res0; + unsigned int clk_sel; + unsigned int res1; + unsigned int ibm561_vco_div; /* IBM561 PLL setup */ + unsigned int ibm561_ref; +}; + +extern struct monitor_data crystal_table; + /* Prototypes */ /* tga_dac.c */ @@ -95,6 +130,7 @@ void DEC21030Save(ScrnInfoPtr pScrn, /*vgaRegPtr vgaReg,*/ TGARegPtr tgaReg/*, Bool saveFonts*/); Bool DEC21030Init(ScrnInfoPtr pScrn, DisplayModePtr mode); +void write_av9110(ScrnInfoPtr pScrn, unsigned int *); /* tga_accel.c */ Bool DEC21030AccelInit(ScreenPtr pScreen); @@ -108,9 +144,22 @@ void tgaBTWriteData(ScrnInfoPtr pScrn, unsigned char data); unsigned char tgaBTReadData(ScrnInfoPtr pScrn); +void tga2BTOutIndReg(ScrnInfoPtr pScrn, + CARD32 reg, unsigned char mask, unsigned char data); +unsigned char tga2BTInIndReg(ScrnInfoPtr pScrn, CARD32 reg); +void tga2BTWriteAddress(ScrnInfoPtr pScrn, CARD32 index); +void tga2BTReadAddress(ScrnInfoPtr pScrn, CARD32 index); +void tga2BTWriteData(ScrnInfoPtr pScrn, unsigned char data); +unsigned char tga2BTReadData(ScrnInfoPtr pScrn); + /* BT463ramdac.c */ void BT463ramdacSave(ScrnInfoPtr pScrn, unsigned char *data); void BT463ramdacRestore(ScrnInfoPtr pScrn, unsigned char *data); + +/* IBM561ramdac.c */ +void IBM561ramdacSave(ScrnInfoPtr pScrn, unsigned char *data); +void IBM561ramdacHWInit(ScrnInfoPtr pScrn); +void IBM561ramdacRestore(ScrnInfoPtr pScrn, unsigned char *data); /* tga_cursor.c */ Bool TGAHWCursorInit(ScreenPtr pScreen); Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c:1.10 Mon Mar 6 17:59:31 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c Fri Oct 20 08:57:26 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c,v 1.10 2000/03/06 22:59:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_accel.c,v 1.11 2000/10/20 12:57:26 alanh Exp $ */ /* * Copyright 1996,1997 by Alan Hourihane, Wigan, England. @@ -135,14 +135,11 @@ TGA_AccelInfoRec->SubsequentSolidFillRect = TGASubsequentSolidFillRect; /* screen to screen copy */ - if(pTga->depthflag == BPP8PACKED) { /* screen to screen copy apparently doesn't work - for 32bpp tga */ - TGA_AccelInfoRec->ScreenToScreenCopyFlags = NO_TRANSPARENCY; - TGA_AccelInfoRec->SetupForScreenToScreenCopy = - TGASetupForScreenToScreenCopy; - TGA_AccelInfoRec->SubsequentScreenToScreenCopy = - TGASubsequentScreenToScreenCopy; - } + TGA_AccelInfoRec->ScreenToScreenCopyFlags = NO_TRANSPARENCY; + TGA_AccelInfoRec->SetupForScreenToScreenCopy = + TGASetupForScreenToScreenCopy; + TGA_AccelInfoRec->SubsequentScreenToScreenCopy = + TGASubsequentScreenToScreenCopy; /* mono 8x8 pattern fill */ @@ -155,22 +152,20 @@ /* color expand */ /* does not work for 32bpp (yet) */ - if(pTga->depthflag == BPP8PACKED) { - TGA_AccelInfoRec->ScanlineCPUToScreenColorExpandFillFlags = - BIT_ORDER_IN_BYTE_LSBFIRST; - - TGA_AccelInfoRec->NumScanlineColorExpandBuffers = 1; - pTga->buffers[0] = (CARD32 *)malloc(CE_BUFSIZE); - TGA_AccelInfoRec->ScanlineColorExpandBuffers = - (unsigned char **)pTga->buffers; - TGA_AccelInfoRec->SetupForScanlineCPUToScreenColorExpandFill = - TGASetupForScanlineCPUToScreenColorExpandFill; - TGA_AccelInfoRec->SubsequentScanlineCPUToScreenColorExpandFill = - TGASubsequentScanlineCPUToScreenColorExpandFill; - TGA_AccelInfoRec->SubsequentColorExpandScanline = - TGASubsequentColorExpandScanline; - } + TGA_AccelInfoRec->ScanlineCPUToScreenColorExpandFillFlags = + BIT_ORDER_IN_BYTE_LSBFIRST; + TGA_AccelInfoRec->NumScanlineColorExpandBuffers = 1; + pTga->buffers[0] = (CARD32 *)malloc(CE_BUFSIZE); + TGA_AccelInfoRec->ScanlineColorExpandBuffers = + (unsigned char **)pTga->buffers; + TGA_AccelInfoRec->SetupForScanlineCPUToScreenColorExpandFill = + TGASetupForScanlineCPUToScreenColorExpandFill; + TGA_AccelInfoRec->SubsequentScanlineCPUToScreenColorExpandFill = + TGASubsequentScanlineCPUToScreenColorExpandFill; + TGA_AccelInfoRec->SubsequentColorExpandScanline = + TGASubsequentColorExpandScanline; + /* lines */ TGA_AccelInfoRec->PolylinesThinSolid = TGAPolyLines; @@ -210,9 +205,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; unsigned int fgcolor = 0, bgcolor = 0, pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -274,8 +269,8 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -315,27 +310,32 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; unsigned char *p = NULL; int width = 0; unsigned int addr; unsigned int pixelmask = 0; unsigned int stipple; + unsigned int align_mask; int align = 0; int skipleft; CARD32 c = 0, d = 0; CARD32 *e = NULL; int i = 0, num_dwords = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); TGA_GET_OFFSET(); + + align_mask = (pTga->depthflag == BPP24) ? 0x0f : 0x03; -/* ErrorF("TGASubsequentColorExpandScanline called\n"); */ -/* if(pTga->transparent_pattern_p) */ -/* ErrorF("transparent color expand\n"); */ +#if 0 + ErrorF("TGASubsequentColorExpandScanline called\n"); + if(pTga->transparent_pattern_p) + ErrorF("transparent color expand\n"); +#endif p = (unsigned char *)pTga->buffers[0]; addr = FB_OFFSET(pTga->ce_x, pTga->ce_y); @@ -345,12 +345,13 @@ while(width > 0) { if(!pTga->transparent_pattern_p) pixelmask = 0xFFFFFFFF; - if(addr & 0x3) { - align = addr & 0x3; - if(!pTga->transparent_pattern_p) + + align = (addr & align_mask) / pTga->Bpp; /* no. pixels out of align */ + if (align) { + if (!pTga->transparent_pattern_p) pixelmask <<= align; -/* ErrorF("aligment is %d\n", align); */ - addr -= align; +/* ErrorF("alignment is %d\n", align); */ + addr -= align * pTga->Bpp; width += align; e = (CARD32 *)p; @@ -368,42 +369,44 @@ d = c; } } - - if(!pTga->transparent_pattern_p) { - if(skipleft) { + if (!pTga->transparent_pattern_p) { + if (skipleft) { pixelmask <<= skipleft; skipleft = 0; } - if(width < 32) + if (width < 32) { pixelmask &= (0xFFFFFFFF >> (32 - width)); + } + TGA_FAST_WRITE_REG(pixelmask, TGA_PIXELMASK_REG); } else { unsigned int *i = NULL; /* ErrorF("transparent scanline with x = %d, y = %d, w = %d, h = %d\n", pTga->ce_x, pTga->ce_y, pTga->ce_width, pTga->ce_height); */ - if(skipleft) { + if (skipleft) { i = (unsigned int *)p; *i &= (0xFFFFFFFF << skipleft); skipleft = 0; } - if(width < 32) { + if (width < 32) { i = (unsigned int *)p; *i &= (0xFFFFFFFF >> (32 - width)); } } - if(!pTga->transparent_pattern_p) - TGA_FAST_WRITE_REG(pixelmask, TGA_PIXELMASK_REG); - TGA_FAST_WRITE_REG(addr, TGA_ADDRESS_REG); stipple = *((unsigned int *)p); - TGA_FAST_WRITE_REG(stipple, TGA_CONTINUE_REG); - addr += 32; + switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + *(unsigned int *)(pTga->FbBase + addr) = stipple; WMB; + break; + case PCI_CHIP_DEC21030: + TGA_FAST_WRITE_REG(addr, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(stipple, TGA_CONTINUE_REG); + } + addr += 32 * pTga->Bpp; p += 4; width -= 32; - if(align) { - align = 0; - } } pTga->ce_height--; if(pTga->ce_height == 0) { @@ -430,9 +433,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; unsigned int fgcolor = 0, pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -487,8 +490,8 @@ #ifdef PROFILE unsigned int stop, start; #endif - register unsigned long iobase, offset; TGAPtr pTga; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -547,9 +550,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; unsigned int pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -557,9 +560,7 @@ /* see section 6.2.9 */ - /* ErrorF("TGASetupForScreenToScreenCopy called\n"); */ - - if(pTga->depthflag == BPP8PACKED) { + if (pTga->depthflag == BPP8PACKED) { pmask = planemask | (planemask << 8) | (planemask << 16) | (planemask << 24); } @@ -572,7 +573,7 @@ pTga->current_rop = rop | pTga->depthflag; /* do we copy a rectangle from top to bottom or bottom to top? */ - if(ydir == -1) { + if (ydir == -1) { pTga->blitdir = BLIT_FORWARDS; } else { @@ -581,6 +582,7 @@ TGA_SAVE_OFFSET(); return; } + /* * This is the implementation of the SubsequentForScreenToScreenCopy * that sends commands to the coprocessor to perform a screen-to-screen @@ -601,23 +603,32 @@ #ifdef PROFILE unsigned int stop, start; #endif - register unsigned long iobase, offset; TGAPtr pTga; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); TGA_GET_OFFSET(); - - /* ErrorF("TGASubsequentScreenToScreenCopy called\n"); */ - +#if 0 + ErrorF("TGASubsequentScreenToScreenCopy(,%d,%d,%d,%d,%d,%d):" + " COPY %s BLIT %s\n", + x1, y1, x2, y2, w, h, (x2 > x1 && (x1 + w) > x2)?"BWD":"FWD", + (pTga->blitdir == BLIT_FORWARDS)?"FWD":"BWD"); +#endif + TGASync(pScrn); /* ?? */ + TGA_FAST_WRITE_REG(COPY | X11 | pTga->depthflag, TGA_MODE_REG); TGA_FAST_WRITE_REG(pTga->current_rop, TGA_RASTEROP_REG); TGA_FAST_WRITE_REG(pTga->current_planemask, TGA_PLANEMASK_REG); +#if 1 if(x2 > x1 && (x1 + w) > x2) copy_func = TGACopyLineBackwards; else copy_func = TGACopyLineForwards; +#else + copy_func = TGACopyLineForwards; +#endif TGA_SAVE_OFFSET(); if(pTga->blitdir == BLIT_FORWARDS) { @@ -631,6 +642,8 @@ } } + TGASync(pScrn); /* ?? */ + TGA_GET_OFFSET(); TGA_FAST_WRITE_REG(SIMPLE | X11 | pTga->depthflag, TGA_MODE_REG); TGA_FAST_WRITE_REG(MIX_SRC | pTga->depthflag, TGA_RASTEROP_REG); @@ -648,59 +661,84 @@ int read; unsigned long source_address, destination_address; unsigned int mask_source, mask_destination; + unsigned int cando, cando_mask; int source_align, destination_align; int pixel_shift; - register unsigned long iobase, offset; #ifdef PROFILE unsigned int start, stop; #endif TGAPtr pTga; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); TGA_GET_OFFSET(); + cando = 32; + cando_mask = 0xFFFFFFFFU; + if (pTga->Chipset == PCI_CHIP_DEC21030 && pTga->depthflag == BPP24) { + cando = 16; + cando_mask = 0x0000FFFFU; + } + source_address = FB_OFFSET(x1, y1); destination_address = FB_OFFSET(x2, y2); - +#if 0 + ErrorF("CPY-FWD(,%d,%d,%d,%d,%d): sadr = 0x%lx, dadr = 0x%lx\n", + x1, y1, x2, y2, w, source_address, destination_address); +#endif read = 0; - while(read < w) { - mask_source = 0xFFFFFFFF; - if((w - read) >= 32) - mask_destination = 0xFFFFFFFF; + while (read < w) { + + mask_source = cando_mask; + if ((w - read) >= cando) + mask_destination = cando_mask; else - mask_destination = ((unsigned int)0xFFFFFFFF) >> (32 - (w - read)); + mask_destination = cando_mask >> (cando - (w - read)); + source_align = source_address & 0x07; + source_address -= source_align; + mask_source <<= source_align / pTga->Bpp; + /* mask_source &= cando_mask; */ + destination_align = destination_address & 0x07; - source_address = source_address - source_align; - mask_source <<= source_align; - destination_address = destination_address - destination_align; - mask_destination <<= destination_align; + destination_address -= destination_align; + mask_destination <<= destination_align / pTga->Bpp; + /* mask_destination &= cando_mask; */ - if(destination_align >= source_align) + if (destination_align >= source_align) pixel_shift = destination_align - source_align; else { pixel_shift = 8 - (source_align - destination_align); /* we need to prime the residue register in this case */ - destination_address = destination_address - 8; - mask_destination <<= 8; + destination_address -= 8; + mask_destination <<= 8 / pTga->Bpp; + mask_destination &= cando_mask;/* ?? */ } - + TGA_FAST_WRITE_REG(pixel_shift, TGA_PIXELSHIFT_REG); - /* use GADR and GCTR */ - TGA_FAST_WRITE_REG(source_address, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(mask_source, TGA_CONTINUE_REG); - TGA_FAST_WRITE_REG(destination_address, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(mask_destination, TGA_CONTINUE_REG); + switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + *(unsigned int *)(pTga->FbBase + source_address) = mask_source; WMB; + *(unsigned int *)(pTga->FbBase + destination_address) = mask_destination; WMB; + break; + case PCI_CHIP_DEC21030: + /* use GADR and GCTR */ + TGA_FAST_WRITE_REG(source_address, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(mask_source, TGA_CONTINUE_REG); + TGA_FAST_WRITE_REG(destination_address, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(mask_destination, TGA_CONTINUE_REG); + break; + } - source_address = source_address + (32 - pixel_shift); - destination_address += 32; + source_address += (cando - (pixel_shift / pTga->Bpp)) * pTga->Bpp; + destination_address += cando * pTga->Bpp; - read += 32; - read -= destination_align; /* "read" is perhaps better + read += cando; + read -= destination_align / pTga->Bpp; /* "read" is perhaps better called "written"... */ - if(destination_align < source_align) { - read -= 8; + if (destination_align < source_align) { + read -= 8 / pTga->Bpp; } } @@ -720,124 +758,166 @@ unsigned long a1, a2; unsigned long source_address, destination_address; unsigned int mask_source, mask_destination; + unsigned int cando, cando_mask; int source_align, destination_align; int pixel_shift; int read; #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); TGA_GET_OFFSET(); + cando = 32; + cando_mask = 0xFFFFFFFFU; + if (pTga->Chipset == PCI_CHIP_DEC21030 && pTga->depthflag == BPP24) { + cando = 16; + cando_mask = 0x0000FFFFU; + } + a1 = FB_OFFSET(x1, y1); a2 = FB_OFFSET(x2, y2); - source_address = FB_OFFSET((x1 + w) - 32, y1); - destination_address = FB_OFFSET((x2 + w) - 32, y2); - + source_address = FB_OFFSET((x1 + w) - cando, y1); + destination_address = FB_OFFSET((x2 + w) - cando, y2); + +#if 0 + ErrorF("CPY-BWD(,%d,%d,%d,%d,%d): sadr = 0x%lx, dadr = 0x%lx" + " a1 0x%lx a2 0x%lx\n", + x1, y1, x2, y2, w, source_address, destination_address, a1, a2); +#endif + read = 0; - while(read < w) { - mask_source = 0xFFFFFFFF; - if((w - read) >= 32) - mask_destination = 0xFFFFFFFF; - else - mask_destination = ((unsigned int)0xFFFFFFFF) << (32 - (w - read)); + while (read < w) { + mask_source = cando_mask; + if ((w - read) >= cando) + mask_destination = cando_mask; + else { + mask_destination = ((unsigned int)cando_mask) << (cando - (w - read)); + mask_destination &= cando_mask; /* esp. for cando==16 */ + } source_align = source_address & 0x07; destination_align = destination_address & 0x07; - if(read == 0 && destination_align && + if (read == 0 && destination_align && (source_align > destination_align)) { /* we want to take out all the destination_align pixels in one little copy first, then move on to the main stuff */ unsigned long tmp_src, tmp_dest; unsigned int tmp_src_mask, tmp_dest_mask; - tmp_src = (a1 + w) - source_align; - tmp_dest = ((a2 + w) - destination_align) - 8; - tmp_src_mask = 0xFFFFFFFF; - tmp_dest_mask = ((unsigned int)0x000000FF) >> (8 - destination_align); - tmp_dest_mask <<= 8; + tmp_src = a1 + (w - (source_align / pTga->Bpp)) * pTga->Bpp; + tmp_dest = a2 + (w - (destination_align / pTga->Bpp) - (8 / pTga->Bpp)) * pTga->Bpp; + tmp_src_mask = cando_mask; + tmp_dest_mask = ((unsigned int)0x000000FF) >> (8 - destination_align) / pTga->Bpp; + tmp_dest_mask <<= 8 / pTga->Bpp; pixel_shift = (8 - source_align) + destination_align; - +#if 0 + ErrorF("CPY-BWD - premature copy: sa = %d, da = %d, ps =%d\n", + source_align, destination_align, pixel_shift); +#endif TGA_FAST_WRITE_REG(pixel_shift, TGA_PIXELSHIFT_REG); - TGA_FAST_WRITE_REG(tmp_src, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(tmp_src_mask, TGA_CONTINUE_REG); - TGA_FAST_WRITE_REG(tmp_dest, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(tmp_dest_mask, TGA_CONTINUE_REG); - -/* ErrorF("premature copy: sa = %d, da = %d, ps =%d\n", source_align, */ -/* destination_align, pixel_shift); */ + switch (pTga->Chipset) + { + case PCI_CHIP_TGA2: + *(unsigned int *)(pTga->FbBase + tmp_src) = tmp_src_mask; WMB; + *(unsigned int *)(pTga->FbBase + tmp_dest) = tmp_dest_mask; WMB; + break; + case PCI_CHIP_DEC21030: + /* use GADR and GCTR */ + TGA_FAST_WRITE_REG(tmp_src, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(tmp_src_mask, TGA_CONTINUE_REG); + TGA_FAST_WRITE_REG(tmp_dest, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(tmp_dest_mask, TGA_CONTINUE_REG); + break; + } source_address += (8 - source_align); - mask_source >>= (8 - source_align); - mask_source >>= destination_align; - mask_destination >>= destination_align; + mask_source >>= (8 - source_align) / pTga->Bpp; + mask_source >>= destination_align / pTga->Bpp; + mask_destination >>= destination_align / pTga->Bpp; } - else if(read == 0 && (source_align != destination_align)) { + else if (read == 0 && (source_align != destination_align)) { source_address += (8 - source_align); /* mask_source >>= (8 - source_align); */ - /* if we comment this out, it breaks...TGA tries to + /* if we uncomment this, it breaks...TGA tries to optimize away a read of our last pixels... */ } - else if(source_align) { + else if (source_align) { source_address += (8 - source_align); - mask_source >>= (8 - source_align); + mask_source >>= (8 - source_align) / pTga->Bpp; } - if(destination_align) { + + if (destination_align) { destination_address += (8 - destination_align); - mask_destination >>= (8 - destination_align); + mask_destination >>= (8 - destination_align) / pTga->Bpp; } - if(destination_align >= source_align) + if (destination_align >= source_align) pixel_shift = destination_align - source_align; else { pixel_shift = (8 - source_align) + destination_align; - if(destination_align) { + if (destination_align) { source_address += 8; - mask_source >>= 8; + mask_source >>= 8 / pTga->Bpp; } } +#if 0 + ErrorF("CPY-BWD - normal: sadr 0x%lx sm 0x%x dadr 0x%lx dm 0x%x" + " sa %d da %d ps %d read %d\n", + source_address, mask_source, + destination_address, mask_destination, + source_align, destination_align, pixel_shift, read); +#endif TGA_FAST_WRITE_REG(pixel_shift, TGA_PIXELSHIFT_REG); - /* use GADR and GCTR */ - TGA_FAST_WRITE_REG(source_address, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(mask_source, TGA_CONTINUE_REG); - TGA_FAST_WRITE_REG(destination_address, TGA_ADDRESS_REG); - TGA_FAST_WRITE_REG(mask_destination, TGA_CONTINUE_REG); + switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + *(unsigned int *)(pTga->FbBase + source_address) = mask_source; WMB; + *(unsigned int *)(pTga->FbBase + destination_address) = mask_destination; WMB; + break; + case PCI_CHIP_DEC21030: + /* use GADR and GCTR */ + TGA_FAST_WRITE_REG(source_address, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(mask_source, TGA_CONTINUE_REG); + TGA_FAST_WRITE_REG(destination_address, TGA_ADDRESS_REG); + TGA_FAST_WRITE_REG(mask_destination, TGA_CONTINUE_REG); + break; + } /* if(read == 0) */ /* ErrorF("sa = %d, da = %d, ps = %d\n", source_align, destination_align, */ /* pixel_shift); */ - if(destination_align > source_align) { - source_address -= 24; - destination_address -= (32 - pixel_shift); - if(read == 0) - read += 24 + source_align; + if (destination_align > source_align) { + source_address -= cando * pTga->Bpp - 8; + destination_address -= (cando - (pixel_shift / pTga->Bpp)) * pTga->Bpp; + if (read == 0) + read += (cando - 8 / pTga->Bpp) + source_align / pTga->Bpp; else - read += 24; + read += cando - 8 / pTga->Bpp; } - else if(destination_align == source_align) { - source_address -= 32; - destination_address -= 32; - if(read == 0 && destination_align) - read += (32 - (8 - destination_align)); + else if (destination_align == source_align) { + source_address -= cando * pTga->Bpp; + destination_address -= cando * pTga->Bpp; + if (read == 0 && destination_align) + read += (cando - (8 - destination_align) / pTga->Bpp); else - read += 32; + read += cando; } - else if(source_align > destination_align) { - source_address -= 24; - destination_address -= (32 - pixel_shift); + else if (source_align > destination_align) { + source_address -= cando * pTga->Bpp - 8; + destination_address -= (cando - (pixel_shift / pTga->Bpp)) * pTga->Bpp; /* only happens when read == 0 */ - if(destination_align) - read += 16 + source_align; + if (destination_align) + read += (cando - 16 / pTga->Bpp) + source_align / pTga->Bpp; else - read += 32 - pixel_shift; + read += cando - pixel_shift / pTga->Bpp; } } @@ -852,9 +932,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga; unsigned int fgcolor = 0, bgcolor = 0, pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -925,7 +1005,7 @@ #ifdef PROFILE register unsigned int stop, start; #endif - register unsigned long iobase, offset; + TGA_DECL(); /* ErrorF("TGASubsequentMono8x8PatternFillRect called with x = %d, y = %d, w = %d, h = %d\n", x, y, w, h); */ @@ -1005,9 +1085,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; unsigned int fgcolor = 0, pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1056,10 +1136,10 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; CARD32 abs_dx = 0, abs_dy = 0, address = 0, octant_reg = 0; int length = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1136,10 +1216,9 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; CARD32 abs_dx = 0, abs_dy = 0, octant_reg = 0; - + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1200,10 +1279,10 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; CARD32 address = 0; int length = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1246,9 +1325,9 @@ #ifdef PROFILE unsigned int start = 0, stop = 0; #endif - register unsigned long iobase = 0, offset = 0; TGAPtr pTga = NULL; unsigned int color1 = 0, color2 = 0, pmask = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1293,13 +1372,13 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; CARD32 abs_dx = 0, abs_dy = 0, address = 0, octant_reg = 0; int length = 0; CARD16 line_mask = 0; int pattern_overflow = 0; int l = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); @@ -1418,13 +1497,13 @@ #ifdef PROFILE unsigned int start, stop; #endif - register unsigned long iobase, offset; TGAPtr pTga = NULL; CARD32 address = 0; int length = 0; CARD16 line_mask = 0; int pattern_overflow = 0; int l = 0; + TGA_DECL(); pTga = TGAPTR(pScrn); TGA_GET_IOBASE(); Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c:1.1 xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c:1.2 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c:1.1 Sat Apr 17 03:06:58 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c Fri Oct 20 08:57:26 2000 @@ -25,7 +25,7 @@ * * DEC TGA hardware cursor using BT485 ramdac */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c,v 1.1 1999/04/17 07:06:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_cursor.c,v 1.2 2000/10/20 12:57:26 alanh Exp $ */ /* tga_cursor.c */ @@ -53,25 +53,26 @@ static void TGALoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) { + TGAPtr pTga = TGAPTR(pScrn); int i; /* set 64 bit cursor */ - tgaBTOutIndReg(pScrn, BT_COMMAND_REG_0, 0x7F, 0x80); - tgaBTOutIndReg(pScrn, BT_WRITE_ADDR, 0x00, 0x01); - tgaBTOutIndReg(pScrn, BT_STATUS_REG, 0xF8, 0x04); + pTga->RamDacRec->WriteDAC(pScrn, BT_COMMAND_REG_0, 0x7F, 0x80); + pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0x00, 0x01); + pTga->RamDacRec->WriteDAC(pScrn, BT_STATUS_REG, 0xF8, 0x04); /* first write address reg @ 0x0, then write 0xb with the data (for 32 bit cursor) */ - tgaBTOutIndReg(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); for(i = 0; i < ((CURSOR_SIZE * CURSOR_SIZE) / 8); i++) - tgaBTOutIndReg(pScrn, BT_CURS_RAM_DATA, 0x00, *src++); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_RAM_DATA, 0x00, *src++); for(i = 0; i < ((CURSOR_SIZE * CURSOR_SIZE) / 8); i++) - tgaBTOutIndReg(pScrn, BT_CURS_RAM_DATA, 0x00, *src++); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_RAM_DATA, 0x00, *src++); -/* tgaBTOutIndReg(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); */ +/* pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); */ return; } @@ -80,8 +81,10 @@ static void TGAShowCursor(ScrnInfoPtr pScrn) { + TGAPtr pTga = TGAPTR(pScrn); + /* enable BT485 X11 cursor */ - tgaBTOutIndReg(pScrn, BT_COMMAND_REG_2, 0xFC, 0x03); + pTga->RamDacRec->WriteDAC(pScrn, BT_COMMAND_REG_2, 0xFC, 0x03); return; } @@ -90,7 +93,9 @@ static void TGAHideCursor(ScrnInfoPtr pScrn) { - tgaBTOutIndReg(pScrn, BT_COMMAND_REG_2, 0xFC, 0x00); + TGAPtr pTga = TGAPTR(pScrn); + + pTga->RamDacRec->WriteDAC(pScrn, BT_COMMAND_REG_2, 0xFC, 0x00); return; } @@ -98,6 +103,7 @@ static void TGASetCursorPosition(ScrnInfoPtr pScrn, int x, int y) { + TGAPtr pTga = TGAPTR(pScrn); unsigned int tmp_x, tmp_y; /* translate x && y to BT485 cursor addresses */ @@ -109,11 +115,11 @@ tmp_y &= 0x0FFF; /* write out the addresses */ - tgaBTOutIndReg(pScrn, BT_CURS_X_LOW, 0x00, (tmp_x & 0xFF)); - tgaBTOutIndReg(pScrn, BT_CURS_X_HIGH, 0xF0, (tmp_x >> 8)); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_X_LOW, 0x00, (tmp_x & 0xFF)); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_X_HIGH, 0xF0, (tmp_x >> 8)); - tgaBTOutIndReg(pScrn, BT_CURS_Y_LOW, 0x00, (tmp_y & 0xFF)); - tgaBTOutIndReg(pScrn, BT_CURS_Y_HIGH, 0xF0, (tmp_y >> 8)); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_Y_LOW, 0x00, (tmp_y & 0xFF)); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_Y_HIGH, 0xF0, (tmp_y >> 8)); return; } @@ -123,23 +129,25 @@ TGASetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) /* set pScrn->cursor_fg and pScrn->cursor_bg */ { + TGAPtr pTga = TGAPTR(pScrn); + /* first, load address register at 0x4 with 0x1, then write 3 color octets RGB to 0x5 (background), then write three octets to 0x5 (foreground), then write to address register 0xFC */ - tgaBTOutIndReg(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x01); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x01); /* we don't seem to support the 6 bit DAC option as of 4.0, and why would we? */ - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (bg & 0x00FF0000) >> 16); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (bg & 0x0000FF00) >> 8); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (bg & 0x000000FF)); - - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (fg & 0x00FF0000) >> 16); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (fg & 0x0000FF00) >> 8); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, (fg & 0x000000FF)); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (bg & 0x00FF0000) >> 16); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (bg & 0x0000FF00) >> 8); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (bg & 0x000000FF)); + + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (fg & 0x00FF0000) >> 16); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (fg & 0x0000FF00) >> 8); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, (fg & 0x000000FF)); -/* tgaBTOutIndReg(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x00); */ +/* pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x00); */ return; } Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c:1.10 Mon Mar 6 17:59:31 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c Fri Oct 20 08:57:26 2000 @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c,v 1.10 2000/03/06 22:59:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_dac.c,v 1.11 2000/10/20 12:57:26 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -35,22 +35,45 @@ #include "tga.h" static void ICS1562ClockSelect(ScrnInfoPtr pScrn, int freq); +static void ICS9110ClockSelect(ScrnInfoPtr pScrn, int freq); extern void ICS1562_CalcClockBits(long f, unsigned char *bits); static void ICS1562ClockSelect(ScrnInfoPtr pScrn, int freq) { - TGAPtr pTga = TGAPTR(pScrn); - unsigned char pll_bits[7]; - unsigned long temp; - int i, j; + TGAPtr pTga = TGAPTR(pScrn); + unsigned char pll_bits[7]; + unsigned long temp; + int i, j; + + /* There lies an ICS1562 Clock Generator. */ + ICS1562_CalcClockBits(freq, pll_bits); + + switch (pTga->Chipset) { + case PCI_CHIP_DEC21030: + /* + * For the DEC 21030 TGA: + * This requires the 55 clock bits be written in a serial manner to + * bit 0 of the CLOCK register and on the 56th bit set the hold flag. + */ + for (i = 0;i <= 6; i++) { + for (j = 0; j <= 7; j++) { + temp = (pll_bits[i] >> (7-j)) & 1; + if (i == 6 && j == 7) + temp |= 2; + TGA_WRITE_REG(temp, TGA_CLOCK_REG); + } + } + break; + case PCI_CHIP_TGA2: /* - * For the DEC 21030 TGA, There lies an ICS1562 Clock Generator. + * For the DEC TGA2: * This requires the 55 clock bits be written in a serial manner to * bit 0 of the CLOCK register and on the 56th bit set the hold flag. */ - ICS1562_CalcClockBits(freq, pll_bits); +#if 0 + /* ?? FIXME FIXME FIXME ?? */ for (i = 0;i <= 6; i++) { for (j = 0; j <= 7; j++) { temp = (pll_bits[i] >> (7-j)) & 1; @@ -59,47 +82,192 @@ TGA_WRITE_REG(temp, TGA_CLOCK_REG); } } +#endif + break; + } } +struct monitor_data crystal_table = +{ +/* Option 5 Monitor Info 75.00 Mhz */ +768, /* rows */ +1024, /* columns */ +75, /* 74 Mhz */ +70, /* refresh rate */ +768, /* v scanlines */ +3, /* v front porch */ +6, /* v sync */ +29, /* v back porch */ +1024, /* h pixels */ +24, /* h front porch */ +136, /* h sync */ +144, /* h back porch */ +/* 75.00 MHz AV9110 clock serial load information */ +0x6e, /* 0:6 VCO frequency divider N */ +0x15, /* 7:13 Reference frequency divide M */ +0x0, /* 14 VCO pre-scale divide V (0=div.by 1,1=by 8) +*/ +0x1, /* 15:16 CLK/X output divide X */ +0x1, /* 17:18 VCO output divide R */ +1, /* 19 CLK Output enable. */ +1, /* 20 CLK/X Output enable */ +0, /* reserved, should be set to 0 */ +0, /* Reference clock select on CLK 1=ref */ +1, /* reserved, should be set to 1 */ +/* 75.00 MHz IBM561 PLL setup data */ +0x93, /* VCO Div: PFR=2, M=0x54 */ +0x8 /* REF: N=0x8 */ +}; + +/* ICS av9110 is only used on TGA2 */ + +void +write_av9110(ScrnInfoPtr pScrn, unsigned int *temp) +{ + TGAPtr pTga = TGAPTR(pScrn); + + /* the following is based on write_av9110() from the + TRU64 kernel TGA driver */ + + TGA2_WRITE_CLOCK_REG(0x0, 0xf800); + TGA2_WRITE_CLOCK_REG(0x0, 0xf000); + + TGA2_WRITE_CLOCK_REG(temp[0], 0x0000); + TGA2_WRITE_CLOCK_REG(temp[1], 0x0000); + TGA2_WRITE_CLOCK_REG(temp[2], 0x0000); + TGA2_WRITE_CLOCK_REG(temp[3], 0x0000); + TGA2_WRITE_CLOCK_REG(temp[4], 0x0000); + TGA2_WRITE_CLOCK_REG(temp[5], 0x0000); + + TGA2_WRITE_CLOCK_REG(0x0, 0xf800); +} + +static void +ICS9110ClockSelect(ScrnInfoPtr pScrn, int freq) +{ + unsigned int temp, temp1[6]; + struct monitor_data *c_table; + + /* There lies an ICS9110 Clock Generator. */ + /* ICS9110_CalcClockBits(freq, pll_bits); */ + + c_table = &crystal_table; + + /* the following is based on munge_ics() from the + TRU64 kernel TGA driver */ + + temp = (unsigned int)(c_table->vco_div | + (c_table->ref_div << 7) | + (c_table->vco_pre << 14) | + (c_table->clk_div << 15) | + (c_table->vco_out_div << 17) | + (c_table->clk_out_en << 19) | + (c_table->clk_out_enX << 20) | + (c_table->res0 << 21) | + (c_table->clk_sel << 22) | + (c_table->res1 << 23)); + + temp1[0] = (temp & 0x00000001) | ((temp & 0x00000002) << 7) | + ((temp & 0x00000004) << 14) | ((temp & 0x00000008) << 21); + temp1[1] = ((temp & 0x00000010) >> 4) | ((temp & 0x00000020) << 3) | + ((temp & 0x00000040) << 10) | ((temp & 0x00000080) << 17); + + temp1[2] = ((temp & 0x00000100) >> 8) | ((temp & 0x00000200) >> 1) | + ((temp & 0x00000400) << 6) | ((temp & 0x00000800) << 13); + + temp1[3] = ((temp & 0x00001000) >> 12) | ((temp & 0x00002000) >> 5) | + ((temp & 0x00004000) << 2) | ((temp & 0x00008000) << 9); + + temp1[4] = ((temp & 0x00010000) >> 16) | ((temp & 0x00020000) >> 9) | + ((temp & 0x00040000) >> 2) | ((temp & 0x00080000) << 5); + + temp1[5] = ((temp & 0x00100000) >> 20) | ((temp & 0x00200000) >> 13) | + ((temp & 0x00400000) >> 6) | ((temp & 0x00800000) << 1); + + write_av9110(pScrn, temp1); + +} + +void +Ibm561Init(TGAPtr pTga) +{ + unsigned char *Ibm561 = pTga->Ibm561modeReg; + int i, j; + +/* ?? FIXME FIXME FIXME FIXME */ + + /* Command registers */ + Ibm561[0] = 0x40; Ibm561[1] = 0x08; + Ibm561[2] = (pTga->SyncOnGreen ? 0x80 : 0x00); + + /* Read mask */ + Ibm561[3] = 0xff; Ibm561[4] = 0xff; Ibm561[5] = 0xff; Ibm561[6] = 0x0f; + + /* Blink mask */ + Ibm561[7] = 0x00; Ibm561[8] = 0x00; Ibm561[9] = 0x00; Ibm561[10] = 0x00; + + /* Window attributes */ + for (i = 0, j=11; i < 16; i++) { + Ibm561[j++] = 0x00; Ibm561[j++] = 0x01; Ibm561[j++] = 0x80; + } +} + +void +Bt463Init(TGAPtr pTga) +{ + unsigned char *Bt463 = pTga->Bt463modeReg; + int i, j; + + /* Command registers */ + Bt463[0] = 0x40; Bt463[1] = 0x08; + Bt463[2] = (pTga->SyncOnGreen ? 0x80 : 0x00); + + /* Read mask */ + Bt463[3] = 0xff; Bt463[4] = 0xff; Bt463[5] = 0xff; Bt463[6] = 0x0f; + + /* Blink mask */ + Bt463[7] = 0x00; Bt463[8] = 0x00; Bt463[9] = 0x00; Bt463[10] = 0x00; + + /* Window attributes */ + for (i = 0, j=11; i < 16; i++) { + Bt463[j++] = 0x00; Bt463[j++] = 0x01; Bt463[j++] = 0x80; + } +} + Bool DEC21030Init(ScrnInfoPtr pScrn, DisplayModePtr mode) { TGAPtr pTga = TGAPTR(pScrn); TGARegPtr pReg = &pTga->ModeReg; - if (pTga->RamDac != NULL) { + if (pTga->RamDac != NULL) { /* this really means 8-bit and BT485 */ RamDacHWRecPtr pBT = RAMDACHWPTR(pScrn); RamDacRegRecPtr ramdacReg = &pBT->ModeReg; ramdacReg->DacRegs[BT_COMMAND_REG_0] = 0xA0 | (!pTga->Dac6Bit ? 0x2 : 0x0) | (pTga->SyncOnGreen ? 0x8 : 0x0); +#if 1 ramdacReg->DacRegs[BT_COMMAND_REG_2] = 0x20; +#else + ramdacReg->DacRegs[BT_COMMAND_REG_2] = 0x27; /* ?? was 0x20 */ +#endif ramdacReg->DacRegs[BT_STATUS_REG] = 0x14; (*pTga->RamDac->SetBpp)(pScrn, ramdacReg); } else { - unsigned char *Bt463 = pTga->Bt463modeReg; - int i, j; - - /* Command registers */ - Bt463[0] = 0x40; Bt463[1] = 0x08; - Bt463[2] = (pTga->SyncOnGreen ? 0x80 : 0x00); - - /* Read mask */ - Bt463[3] = 0xff; Bt463[4] = 0xff; Bt463[5] = 0xff; Bt463[6] = 0x0f; - - /* Blink mask */ - Bt463[7] = 0x00; Bt463[8] = 0x00; Bt463[9] = 0x00; Bt463[10] = 0x00; - - /* Window attributes */ - for (i = 0, j=11; i < 16; i++) { - Bt463[j++] = 0x00; Bt463[j++] = 0x01; Bt463[j++] = 0x80; + switch (pTga->Chipset) { + case PCI_CHIP_DEC21030: /* always BT463 */ + Bt463Init(pTga); + break; + case PCI_CHIP_TGA2: /* always IBM 561 */ + Ibm561Init(pTga); + break; } } pReg->tgaRegs[0x00] = mode->CrtcHDisplay; - pReg->tgaRegs[0x01] = (mode->CrtcHSyncStart - mode->CrtcHDisplay) / 4; + pReg->tgaRegs[0x01] = mode->CrtcHSyncStart - mode->CrtcHDisplay; pReg->tgaRegs[0x02] = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 4; pReg->tgaRegs[0x03] = (mode->CrtcHTotal - mode->CrtcHSyncEnd) / 4; pReg->tgaRegs[0x04] = mode->CrtcVDisplay; @@ -124,11 +292,14 @@ pReg->tgaRegs[0x0A] = mode->Clock; - pReg->tgaRegs[0x10] = ((pReg->tgaRegs[0x00] / 4) & 0x1FF) | - (((pReg->tgaRegs[0x00] / 4) & 0x600) << 19) | - (pReg->tgaRegs[0x01] << 9) | + pReg->tgaRegs[0x10] = (((pReg->tgaRegs[0x00]) / 4) & 0x1FF) | + ((((pReg->tgaRegs[0x00]) / 4) & 0x600) << 19) | + (((pReg->tgaRegs[0x01]) / 4) << 9) | (pReg->tgaRegs[0x02] << 14) | (pReg->tgaRegs[0x03] << 21) | +#if 0 + (1 << 31) | /* ?? */ +#endif (pReg->tgaRegs[0x08] << 30); pReg->tgaRegs[0x11] = pReg->tgaRegs[0x04] | (pReg->tgaRegs[0x05] << 11) | @@ -162,7 +333,14 @@ TGA_WRITE_REG(0x00, TGA_VALID_REG); /* Disable Video */ - ICS1562ClockSelect(pScrn, tgaReg->tgaRegs[0x0A]); + switch (pTga->Chipset) { + case PCI_CHIP_DEC21030: + ICS1562ClockSelect(pScrn, tgaReg->tgaRegs[0x0A]); + break; + case PCI_CHIP_TGA2: + ICS9110ClockSelect(pScrn, tgaReg->tgaRegs[0x0A]); + break; + } TGA_WRITE_REG(tgaReg->tgaRegs[0x10], TGA_HORIZ_REG); TGA_WRITE_REG(tgaReg->tgaRegs[0x11], TGA_VERT_REG); Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c:1.45 xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c:1.49 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c:1.45 Wed Jun 21 13:28:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c Sat Dec 2 10:30:57 2000 @@ -22,7 +22,7 @@ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> * Matthew Grossman, <mattg@oz.net> - acceleration and misc fixes */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c,v 1.45 2000/06/21 17:28:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c,v 1.49 2000/12/02 15:30:57 tsi Exp $ */ /* everybody includes these */ #include "xf86.h" @@ -151,11 +151,13 @@ static SymTabRec TGAChipsets[] = { { PCI_CHIP_DEC21030, "tga" }, + { PCI_CHIP_TGA2, "tga2" }, { -1, NULL } }; static PciChipsets TGAPciChipsets[] = { { PCI_CHIP_DEC21030, PCI_CHIP_DEC21030, NULL }, + { PCI_CHIP_TGA2, PCI_CHIP_TGA2, NULL }, { -1, -1, RES_UNDEFINED } }; @@ -306,14 +308,11 @@ TGAProbe(DriverPtr drv, int flags) { int i; - pciVideoPtr pPci; - GDevPtr *devSections = NULL; -/* GDevPtr *usedDevs; */ + GDevPtr *devSections; int *usedChips; int numDevSections; int numUsed; Bool foundScreen = FALSE; - EntityInfoPtr pEnt; /* * The aim here is to find all cards that this driver can handle, @@ -365,9 +364,7 @@ TGAChipsets, TGAPciChipsets, devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections = NULL; + xfree(devSections); if (numUsed <= 0) return FALSE; @@ -380,7 +377,7 @@ ScrnInfoPtr pScrn = NULL; /* Allocate a ScrnInfoRec and claim the slot */ - if ((pScrn = xf86ConfigPciEntity(pScrn, 0, pEnt->index, + if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], TGAPciChipsets, NULL, NULL, NULL, NULL, NULL))) { /* Fill in what we can of the ScrnInfoRec */ @@ -399,6 +396,7 @@ foundScreen = TRUE; } } + xfree(usedChips); return foundScreen; } @@ -648,14 +646,15 @@ } if (pTga->pEnt->device->MemBase != 0) { - pTga->FbAddress = pTga->pEnt->device->MemBase; + pTga->CardAddress = pTga->pEnt->device->MemBase; from = X_CONFIG; } else { - pTga->FbAddress = pTga->PciInfo->memBase[0] & 0xFF800000; + pTga->CardAddress = pTga->PciInfo->memBase[0] & 0xFFC00000;/*??*/ } + pTga->FbAddress = pTga->CardAddress; /* Adjust MMIO region */ - pTga->IOAddress = pTga->FbAddress + TGA_REGS_OFFSET; + pTga->IOAddress = pTga->CardAddress + TGA_REGS_OFFSET; /********************* @@ -683,10 +682,22 @@ } } else { /* try to divine the amount of RAM */ - Base = xf86MapPciMem(pScrn->scrnIndex, 0x0, - pTga->PciTag, pTga->FbAddress, 4); - pTga->CardType = (*(unsigned int *)Base >> 12) & 0xf; - xf86UnMapVidMem(pScrn->scrnIndex, Base, 4); + switch (pTga->Chipset) + { + case PCI_CHIP_TGA2: + Base = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, + pTga->PciTag, pTga->IOAddress, 0x1000); + pTga->CardType = (*(unsigned int *)((char *)Base+TGA_REVISION_REG) >> 21) & 0x3; + pTga->CardType ^= (pTga->CardType == 1) ? 0 : 3; + xf86UnMapVidMem(pScrn->scrnIndex, Base, 0x1000); + break; + case PCI_CHIP_DEC21030: + Base = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, + pTga->PciTag, pTga->FbAddress, 4); + pTga->CardType = (*(unsigned int *)Base >> 12) & 0xf; + xf86UnMapVidMem(pScrn->scrnIndex, Base, 4); + break; + } } switch (pTga->CardType) { @@ -787,37 +798,46 @@ pTga->RamDac = NULL; - switch (pTga->Chipset) - { + if (pTga->CardType != TYPE_TGA_8PLANE) { + pTga->RamDacRec = NULL; + pTga->RamDac = NULL; + } else { + + pTga->RamDacRec = RamDacCreateInfoRec(); + switch (pTga->Chipset) + { case PCI_CHIP_DEC21030: - if (pTga->CardType != TYPE_TGA_8PLANE) { - pTga->RamDacRec = NULL; - pTga->RamDac = NULL; - break; - } - pTga->RamDacRec = RamDacCreateInfoRec(); pTga->RamDacRec->ReadDAC = tgaBTInIndReg; pTga->RamDacRec->WriteDAC = tgaBTOutIndReg; pTga->RamDacRec->ReadAddress = tgaBTReadAddress; pTga->RamDacRec->WriteAddress = tgaBTWriteAddress; pTga->RamDacRec->ReadData = tgaBTReadData; pTga->RamDacRec->WriteData = tgaBTWriteData; - if(!RamDacInit(pScrn, pTga->RamDacRec)) { - RamDacDestroyInfoRec(pTga->RamDacRec); - return FALSE; - } + break; + case PCI_CHIP_TGA2: + pTga->RamDacRec->ReadDAC = tga2BTInIndReg; + pTga->RamDacRec->WriteDAC = tga2BTOutIndReg; + pTga->RamDacRec->ReadAddress = tga2BTReadAddress; + pTga->RamDacRec->WriteAddress = tga2BTWriteAddress; + pTga->RamDacRec->ReadData = tga2BTReadData; + pTga->RamDacRec->WriteData = tga2BTWriteData; + break; + } + + if (!RamDacInit(pScrn, pTga->RamDacRec)) { + RamDacDestroyInfoRec(pTga->RamDacRec); + return FALSE; + } - TGAMapMem(pScrn); + TGAMapMem(pScrn); - pTga->RamDac = BTramdacProbe(pScrn, BTramdacs); + pTga->RamDac = BTramdacProbe(pScrn, BTramdacs); - TGAUnmapMem(pScrn); + TGAUnmapMem(pScrn); - if (pTga->RamDac == NULL) - return FALSE; - break; + if (pTga->RamDac == NULL) + return FALSE; } - /********************* set up clock and mode stuff @@ -851,8 +871,14 @@ pTga->MaxClock = speed; from = X_CONFIG; } else { - if (pTga->Chipset == PCI_CHIP_DEC21030) + switch (pTga->Chipset) { + case PCI_CHIP_DEC21030: pTga->MaxClock = 135000; + break; + case PCI_CHIP_TGA2: + pTga->MaxClock = 170000; + break; + } } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", pTga->MaxClock / 1000); @@ -956,7 +982,7 @@ /* TGA doesn't need a sparse memory mapping, because all register accesses are doublewords */ - pTga->IOBase = xf86MapPciMem(pScrn->scrnIndex, 0x0, + pTga->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, pTga->IOAddress, 0x100000); if (pTga->IOBase == NULL) @@ -969,6 +995,23 @@ if (pTga->FbBase == NULL) return FALSE; + if (pTga->Chipset == PCI_CHIP_DEC21030) + return TRUE; + + pTga->ClkBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, + pTga->PciTag, + (unsigned long)pTga->CardAddress + TGA2_CLOCK_OFFSET, + 0x10000); + if (pTga->ClkBase == NULL) + return FALSE; + + pTga->DACBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, + pTga->PciTag, + (unsigned long)pTga->CardAddress + TGA2_RAMDAC_OFFSET, + 0x10000); + if (pTga->DACBase == NULL) + return FALSE; + return TRUE; } @@ -990,6 +1033,15 @@ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->FbBase, pTga->FbMapSize); pTga->FbBase = NULL; + if (pTga->Chipset == PCI_CHIP_DEC21030) + return TRUE; + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->ClkBase, 0x10000); + pTga->ClkBase = NULL; + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->DACBase, 0x10000); + pTga->DACBase = NULL; + return TRUE; } @@ -1008,17 +1060,18 @@ pTga = TGAPTR(pScrn); tgaReg = &pTga->SavedReg; - switch (pTga->Chipset) + DEC21030Save(pScrn, tgaReg); + if (pTga->RamDac) { /* must be BT485... */ + pBT = RAMDACHWPTR(pScrn); + BTreg = &pBT->SavedReg; + (*pTga->RamDac->Save)(pScrn, pTga->RamDacRec, BTreg); + } else switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + IBM561ramdacSave(pScrn, pTga->Ibm561saveReg); + break; case PCI_CHIP_DEC21030: - DEC21030Save(pScrn, tgaReg); - if (pTga->RamDac) { - pBT = RAMDACHWPTR(pScrn); - BTreg = &pBT->SavedReg; - (*pTga->RamDac->Save)(pScrn, pTga->RamDacRec, BTreg); - } else { - BT463ramdacSave(pScrn, pTga->Bt463saveReg); - } + BT463ramdacSave(pScrn, pTga->Bt463saveReg); break; } } @@ -1043,31 +1096,38 @@ pScrn->vtSema = TRUE; - switch (pTga->Chipset) { - case PCI_CHIP_DEC21030: - ret = DEC21030Init(pScrn, mode); - break; - } + ret = DEC21030Init(pScrn, mode); + if (pTga->Chipset == PCI_CHIP_TGA2 && pTga->RamDac == NULL) + IBM561ramdacHWInit(pScrn); + if (!ret) return FALSE; /* Program the registers */ tgaReg = &pTga->ModeReg; - switch (pTga->Chipset) { - case PCI_CHIP_DEC21030: - DEC21030Restore(pScrn, tgaReg); - if (pTga->RamDac != NULL) { - pBT = RAMDACHWPTR(pScrn); - BTreg = &pBT->ModeReg; - (*pTga->RamDac->Restore)(pScrn, pTga->RamDacRec, BTreg); - } else { + DEC21030Restore(pScrn, tgaReg); + + if (pTga->RamDac != NULL) { + pBT = RAMDACHWPTR(pScrn); + BTreg = &pBT->ModeReg; + (*pTga->RamDac->Restore)(pScrn, pTga->RamDacRec, BTreg); + if (pTga->Chipset == PCI_CHIP_TGA2) { + pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0x00, 0x01); + pTga->RamDacRec->WriteDAC(pScrn, BT_STATUS_REG, 0x00, 0x0c); + } + pTga->RamDacRec->WriteDAC(pScrn, BT_PIXEL_MASK, 0x00, 0xff); + } else { + switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + IBM561ramdacRestore(pScrn, pTga->Ibm561modeReg); + break; + case PCI_CHIP_DEC21030: BT463ramdacRestore(pScrn, pTga->Bt463modeReg); + break; } - break; } - return TRUE; } @@ -1088,20 +1148,28 @@ /* Initial Text mode clock */ tgaReg->tgaRegs[0x0A] = 25175; - switch (pTga->Chipset) { - case PCI_CHIP_DEC21030: - DEC21030Restore(pScrn, tgaReg); - if (pTga->RamDac != NULL) { - pBT = RAMDACHWPTR(pScrn); - BTreg = &pBT->SavedReg; - (*pTga->RamDac->Restore)(pScrn, pTga->RamDacRec, BTreg); - if(pTga->HWCursor) - TGARestoreHWCursor(pScrn); - } else { - BT463ramdacRestore(pScrn, pTga->Bt463saveReg); + DEC21030Restore(pScrn, tgaReg); + + if (pTga->RamDac != NULL) { + pBT = RAMDACHWPTR(pScrn); + BTreg = &pBT->SavedReg; + (*pTga->RamDac->Restore)(pScrn, pTga->RamDacRec, BTreg); + if (pTga->Chipset == PCI_CHIP_TGA2) { + pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0x00, 0x01); + pTga->RamDacRec->WriteDAC(pScrn, BT_STATUS_REG, 0x00, 0x00); } + pTga->RamDacRec->WriteDAC(pScrn, BT_PIXEL_MASK, 0x00, 0xff); + } else switch (pTga->Chipset) { + case PCI_CHIP_TGA2: + IBM561ramdacRestore(pScrn, pTga->Ibm561saveReg); + break; + case PCI_CHIP_DEC21030: + BT463ramdacRestore(pScrn, pTga->Bt463saveReg); break; } + + if (pTga->HWCursor) + TGARestoreHWCursor(pScrn); } @@ -1121,13 +1189,36 @@ * First get the ScrnInfoRec */ pScrn = xf86Screens[pScreen->myNum]; - pTga = TGAPTR(pScrn); /* Map the TGA memory and MMIO areas */ if (!TGAMapMem(pScrn)) return FALSE; +#if 1 + /* dump original register contents */ + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MODE 0x%x\n", + TGA_READ_REG(TGA_MODE_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VALID 0x%x\n", + TGA_READ_REG(TGA_VALID_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DEEP 0x%x\n", + TGA_READ_REG(TGA_DEEP_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PIXSH 0x%x\n", + TGA_READ_REG(TGA_PIXELSHIFT_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ROP 0x%x\n", + TGA_READ_REG(TGA_RASTEROP_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "HORIZ 0x%x\n", + TGA_READ_REG(TGA_HORIZ_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VERT 0x%x\n", + TGA_READ_REG(TGA_VERT_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PIXMSK 0x%x\n", + TGA_READ_REG(TGA_PIXELMASK_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "REV 0x%x\n", + TGA_READ_REG(TGA_REVISION_REG)); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VADDR 0x%x\n", + TGA_READ_REG(TGA_BASE_ADDR_REG)); +#endif + /* Save the current state */ TGASave(pScrn); @@ -1220,14 +1311,30 @@ } } + /* we should ALWAYS do this */ + if (pScrn->bitsPerPixel == 8) { + TGA_WRITE_REG(SIMPLE | X11 | BPP8PACKED, TGA_MODE_REG); + TGA_WRITE_REG(0x3 | BPP8PACKED, TGA_RASTEROP_REG); + if (pTga->Chipset == PCI_CHIP_TGA2) + TGA_WRITE_REG(2 << 28, TGA_DEEP_REG); + } else { + TGA_WRITE_REG(SIMPLE | X11 | BPP24, TGA_MODE_REG); + TGA_WRITE_REG(0x3 | BPP24, TGA_RASTEROP_REG); + if (pTga->Chipset == PCI_CHIP_TGA2) + TGA_WRITE_REG((7 << 2) | 1 | (2 << 28), TGA_DEEP_REG); + } + TGA_WRITE_REG(0xFFFFFFFF, TGA_PLANEMASK_REG); + TGA_WRITE_REG(0xFFFFFFFF, TGA_PIXELMASK_REG); + if (!pTga->NoAccel) { switch (pTga->Chipset) { + case PCI_CHIP_TGA2: case PCI_CHIP_DEC21030: if(DEC21030AccelInit(pScreen) == FALSE) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "XAA Initialization failed\n"); - return(FALSE); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "XAA Initialization failed\n"); + return(FALSE); } break; } @@ -1349,7 +1456,7 @@ static void TGALeaveVT(int scrnIndex, int flags) { - TGAPtr pTga; + TGAPtr pTga; ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; pTga = TGAPTR(pScrn); @@ -1363,7 +1470,7 @@ /* * This is called at the end of each server generation. It restores the - * original (text) mode. It should really also unmap the video memory too. + * original (text) mode. */ /* Mandatory */ @@ -1374,8 +1481,10 @@ TGAPtr pTga = TGAPTR(pScrn); TGARestore(pScrn); - memset(pTga->FbBase, 0, pScrn->videoRam * 1024); + /* memset(pTga->FbBase, 0, pScrn->videoRam * 1024); */ + TGASync(pScrn); TGAUnmapMem(pScrn); + if(pTga->AccelInfoRec) XAADestroyInfoRec(pTga->AccelInfoRec); pScrn->vtSema = FALSE; @@ -1484,7 +1593,6 @@ #endif /* DPMSExtension */ - static void TGARestoreHWCursor(ScrnInfoPtr pScrn) /* @@ -1500,9 +1608,10 @@ unsigned char *p = NULL; int i = 0; TGAPtr pTga; - /* this is the linux console hw cursor...what about the bsd console? */ - /* what about tgafb? */ - const CARD32 cursor_source[128] = { + + /* Making this static prevents EGCS from compiling memset code + to initialize it, which was causing a problem. */ + static const CARD32 tga_cursor_source[128] = { 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, 0x00000000, 0x000000ff, @@ -1518,52 +1627,55 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + /* this is the linux console hw cursor...what about the bsd console? */ + /* what about tgafb? */ pTga = TGAPTR(pScrn); /* we want to move the cursor off the screen before we do anything with it otherwise, there is a "ghost cursor" that shows up */ - tgaBTOutIndReg(pScrn, BT_CURS_X_LOW, 0x00, 0); - tgaBTOutIndReg(pScrn, BT_CURS_X_HIGH, 0xF0, 0); - tgaBTOutIndReg(pScrn, BT_CURS_Y_LOW, 0x00, 0); - tgaBTOutIndReg(pScrn, BT_CURS_Y_HIGH, 0xF0, 0); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_X_LOW, 0x00, 0); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_X_HIGH, 0xF0, 0); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_Y_LOW, 0x00, 0); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_Y_HIGH, 0xF0, 0); + /* set a windows cursor -- oddly, this doesn't seem necessary */ - tgaBTOutIndReg(pScrn, BT_COMMAND_REG_2, 0xFC, 0x02); + pTga->RamDacRec->WriteDAC(pScrn, BT_COMMAND_REG_2, 0xFC, 0x02); /* set a 64 bit cursor */ -/* tgaBTOutIndReg(pScrn, BT_COMMAND_REG_0, 0x7F, 0x80); */ -/* tgaBTOutIndReg(pScrn, BT_WRITE_ADDR, 0x00, 0x01); */ -/* tgaBTOutIndReg(pScrn, BT_STATUS_REG, 0xF8, 0x04); */ +/* pTga->RamDacRec->WriteDAC(pScrn, BT_COMMAND_REG_0, 0x7F, 0x80); */ +/* pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0x00, 0x01); */ +/* pTga->RamDacRec->WriteDAC(pScrn, BT_STATUS_REG, 0xF8, 0x04); */ /* set the colors */ - tgaBTOutIndReg(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x01); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_WR_ADDR, 0xFC, 0x01); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0xaa); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0xaa); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0xaa); - - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); - tgaBTOutIndReg(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0xaa); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0xaa); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0xaa); + + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_DATA, 0x00, 0x00); /* load the console cursor */ - tgaBTOutIndReg(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); - p = (unsigned char *)cursor_source; + pTga->RamDacRec->WriteDAC(pScrn, BT_WRITE_ADDR, 0xFC, 0x00); + p = (unsigned char *)tga_cursor_source; for(i = 0; i < 512; i++) - tgaBTOutIndReg(pScrn, BT_CURS_RAM_DATA, 0x00, *p++); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_RAM_DATA, 0x00, *p++); for(i = 0; i < 512; i++) - tgaBTOutIndReg(pScrn, BT_CURS_RAM_DATA, 0x00, 0xff); + pTga->RamDacRec->WriteDAC(pScrn, BT_CURS_RAM_DATA, 0x00, 0xff); return; } @@ -1575,16 +1687,36 @@ void TGASync(ScrnInfoPtr pScrn) { + TGAPtr pTga = TGAPTR(pScrn); + unsigned int stat; + + switch (pTga->Chipset) + { + case PCI_CHIP_TGA2: + /* This code is weird, but then so is TGA2... ;-} */ + mem_barrier(); + while((stat = TGA_READ_REG(TGA_CMD_STAT_REG))) { + if (((stat >> 8) & 0xff) == ((stat >> 16) & 0xff)) { + TGA_WRITE_REG(0, TGA_CMD_STAT_REG); + mem_barrier(); #if 0 - /* I'm experiencing lockups which could be due to this function. - We don't seem to need it anyway... - */ - TGAPtr pTga = NULL; - - pTga = TGAPTR(pScrn); +ErrorF("TGASync: writing CMD_STATUS\n"); +#endif + } + usleep(1000); + } + break; - while (TGA_READ_REG(TGA_CMD_STAT_REG) & 0x01); + case PCI_CHIP_DEC21030: +#if 0 + /* I'm experiencing lockups which could be due to this function. + We don't seem to need it anyway... + */ + while (TGA_READ_REG(TGA_CMD_STAT_REG) & 0x01); #endif + break; + } + return; } Index: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h:1.9 xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h:1.11 --- xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h:1.9 Mon Dec 13 18:48:22 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h Fri Oct 20 08:57:26 2000 @@ -21,7 +21,7 @@ * * Author: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h,v 1.9 1999/12/13 23:48:22 robin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_regs.h,v 1.11 2000/10/20 12:57:26 alanh Exp $ */ /* TGA hardware description (minimal) * @@ -34,26 +34,50 @@ #ifndef TGA_REGS_H #define TGA_REGS_H +#include "xf86_ansic.h" #include "compiler.h" #define TYPE_TGA_8PLANE 0 #define TYPE_TGA_24PLANE 1 #define TYPE_TGA_24PLUSZ 3 +#if 1 +#define WMB mem_barrier() +#else +#define WMB write_mem_barrier() +#endif + #define TGA_WRITE_REG(v,r) \ do {\ - *(unsigned int *)((char*)(pTga->IOBase)+(r)) = v;\ - mem_barrier();\ + *(unsigned int *)((char*)(pTga->IOBase)+(r)) = (v);\ + WMB;\ } while (0) + #define TGA_READ_REG(r) \ ( *(unsigned int *)((char*)(pTga->IOBase)+(r))) + +#define TGA2_WRITE_CLOCK_REG(v,r) \ + do {\ + *(unsigned int *)((char*)(pTga->ClkBase)+(r)) = (v);\ + WMB;\ + } while (0) + +#define TGA2_WRITE_RAMDAC_REG(v,r) \ + do {\ + *(unsigned int *)((char*)(pTga->DACBase)+(r)) = (v);\ + WMB;\ + } while (0) + +#define TGA2_READ_RAMDAC_REG(r) \ + ( *(unsigned int *)((char*)(pTga->DACBase)+(r))) -#ifdef __alpha__ +#if defined(__alpha__) && 0 /* ?? disable this for now ?? */ /* we can avoid an mb() if we write to an alternate register space each time */ #define MAX_OFFSET 8192 #define OFFSET_INC 1024 +#define TGA_DECL() register unsigned long iobase, offset #define TGA_GET_IOBASE() iobase = (unsigned long)pTga->IOBase; #define TGA_GET_OFFSET() offset = pTga->regOffset; #define TGA_SAVE_OFFSET() pTga->regOffset = offset; @@ -91,6 +115,7 @@ #else /* __alpha__ */ +#define TGA_DECL() #define TGA_GET_IOBASE() ; #define TGA_GET_OFFSET() ; #define TGA_SAVE_OFFSET() ; @@ -98,15 +123,13 @@ #endif /* __alpha__ */ -#define BT485_WRITE(v,r) \ - TGA_WRITE_REG((r),TGA_RAMDAC_SETUP_REG); \ - TGA_WRITE_REG(((v)&0xff)|((r)<<8),TGA_RAMDAC_REG); - -#define TGA_ROM_OFFSET 0x0000000 -#define TGA_REGS_OFFSET 0x0100000 -#define TGA_8PLANE_FB_OFFSET 0x0200000 -#define TGA_24PLANE_FB_OFFSET 0x0800000 -#define TGA_24PLUSZ_FB_OFFSET 0x1000000 +#define TGA_ROM_OFFSET 0x00000000 +#define TGA2_CLOCK_OFFSET 0x00060000 +#define TGA2_RAMDAC_OFFSET 0x00080000 +#define TGA_REGS_OFFSET 0x00100000 +#define TGA_8PLANE_FB_OFFSET 0x00200000 +#define TGA_24PLANE_FB_OFFSET 0x00800000 +#define TGA_24PLUSZ_FB_OFFSET 0x01000000 #define TGA_FOREGROUND_REG 0x0020 #define TGA_BACKGROUND_REG 0x0024 @@ -139,7 +162,9 @@ #define TGA_ADDRESS_REG 0x003c #define TGA_CONTINUE_REG 0x004c #define TGA_DEEP_REG 0x0050 +#define TGA_REVISION_REG 0x0054 /* TGA2 */ #define TGA_PIXELMASK_REG 0x002c +#define TGA_PIXELMASK_PERS_REG 0x005c #define TGA_CURSOR_BASE_REG 0x0060 #define TGA_HORIZ_REG 0x0064 #define TGA_VERT_REG 0x0068 Index: xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile:1.23 xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile:1.27 --- xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile:1.23 Thu Mar 2 20:05:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile Thu Dec 7 11:48:04 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile,v 1.23 2000/03/03 01:05:44 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/Imakefile,v 1.27 2000/12/07 16:48:04 alanh Exp $ XCOMM XCOMM This is an Imakefile for the TRIDENT driver. XCOMM @@ -8,17 +8,21 @@ SRCS = trident_driver.c trident_dac.c tridenthelper.c \ trident_accel.c trident_i2c.c trident_bank.c \ - image_accel.c blade_accel.c tvga_dac.c trident_dga.c + image_accel.c blade_accel.c tvga_dac.c trident_dga.c \ + trident_shadow.c trident_video.c OBJS = trident_driver.o trident_dac.o tridenthelper.o \ trident_accel.o trident_i2c.o trident_bank.o \ - image_accel.o blade_accel.o tvga_dac.o trident_dga.o + image_accel.o blade_accel.o tvga_dac.o trident_dga.o \ + trident_shadow.o trident_video.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/mi -I$(XF86SRC)/xaa -I$(SERVERSRC)/fb \ - -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb \ + -I$(XF86SRC)/xf1bpp -I$(SERVERSRC)/miext/shadow \ + -I$(SERVERSRC)/render -I$(XF86SRC)/shadowfb \ + -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/mfb \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ @@ -53,9 +57,11 @@ InstallDriverSDKNonExecFile(trident_dga.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_driver.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_i2c.c,$(DRIVERSDKDIR)/drivers/trident) +InstallDriverSDKNonExecFile(trident_shadow.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(trident_regs.h,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(tridenthelper.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(tridentramdac.c,$(DRIVERSDKDIR)/drivers/trident) +InstallDriverSDKNonExecFile(trident_video.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKNonExecFile(tvga_dac.c,$(DRIVERSDKDIR)/drivers/trident) InstallDriverSDKObjectModule(trident,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c:1.6 xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c:1.14 --- xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c:1.6 Thu Oct 14 13:20:26 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c Wed Dec 6 09:33:59 2000 @@ -23,7 +23,7 @@ * * Trident Blade3D accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c,v 1.6 1999/10/14 17:20:26 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c,v 1.14 2000/12/06 14:33:59 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -94,15 +94,15 @@ static void BladeSetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, int transparency_color, int bpp, int depth); -static void BladeSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, int y, - int w, int h, int skipleft); +static void BladeSubsequentImageWriteRect(ScrnInfoPtr pScrn, int x, + int y, int w, int h, int skipleft); static void BladeInitializeAccelerator(ScrnInfoPtr pScrn) { TRIDENTPtr pTrident = TRIDENTPTR(pScrn); CARD32 stride; - + stride = (pScrn->displayWidth >> 3) << 20; BLADE_OUT(0x21C8, stride); @@ -128,10 +128,14 @@ BLADE_OUT(0x21BC, stride); BLADE_OUT(0x21C0, stride); BLADE_OUT(0x21C4, stride); +#if 0 + /* It appears that the driver sometimes misdetects the RAM type, so we + * don't force this for now */ if (pTrident->HasSGRAM) BLADE_OUT(0x2168, 1<<26); /* Enables Block Write if available (SGRAM) */ else BLADE_OUT(0x2168, 0); +#endif BLADE_OUT(0x216C, 0); } @@ -146,6 +150,7 @@ pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = BladeInitializeAccelerator; BladeInitializeAccelerator(pScrn); infoPtr->Flags = PIXMAP_CACHE | @@ -156,9 +161,6 @@ infoPtr->SetClippingRectangle = BladeSetClippingRectangle; infoPtr->DisableClipping = BladeDisableClipping; - infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_FILL | - HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | - HARDWARE_CLIP_MONO_8x8_FILL; #if 0 infoPtr->SolidLineFlags = 0; @@ -214,8 +216,8 @@ infoPtr->CPUToScreenColorExpandFillFlags = CPU_TRANSFER_PAD_DWORD | LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | SYNC_AFTER_COLOR_EXPAND | + NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST | SCANLINE_PAD_DWORD; infoPtr->ColorExpandRange = 0x10000; @@ -226,10 +228,9 @@ BladeSubsequentCPUToScreenColorExpand; infoPtr->SetupForImageWrite = BladeSetupForImageWrite; - infoPtr->SubsequentImageWriteRect = BladeSubsequentImageWriteRect; + infoPtr->SubsequentImageWriteRect = + BladeSubsequentImageWriteRect; infoPtr->ImageWriteFlags = NO_PLANEMASK | - NO_TRANSPARENCY | - LEFT_EDGE_CLIPPING_NEGATIVE_X | LEFT_EDGE_CLIPPING | CPU_TRANSFER_PAD_DWORD | SYNC_AFTER_IMAGE_WRITE; @@ -249,25 +250,6 @@ } static void -BladeSyncClip(ScrnInfoPtr pScrn) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - int busy; - int cnt = 10000000; - - BLADEBUSY(busy); - while (busy != 0) { - if (--cnt < 0) { - ErrorF("GE timeout\n"); - BLADE_OUT(0x2124, 1<<7); - BLADE_OUT(0x2124, 0); - break; - } - BLADEBUSY(busy); - } -} - -static void BladeSync(ScrnInfoPtr pScrn) { TRIDENTPtr pTrident = TRIDENTPTR(pScrn); @@ -306,8 +288,8 @@ } #endif + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -336,8 +318,6 @@ BLADE_OUT(0x2108, y2<<16 | x2); BLADE_OUT(0x210C, ((y2+h-1)&0xfff)<<16 | ((x2+w-1)&0xfff)); } - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } static void @@ -367,8 +347,8 @@ BLADE_OUT(0x2160, color); BLADE_OUT(0x2148, XAACopyROP[rop]); pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -411,9 +391,6 @@ BLADE_OUT(0x2140, E<<30 | (y&0xfff)<<20 | ((x&0xfff)<<4)); BLADE_OUT(0x2144, D<<30 | (((dmaj-dmin)&0xfff) << 16) | (-dmin&0xfff)); BLADE_OUT(0x2148, ((-(dmin+e)&0xfff) << 16)); - - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } @@ -437,9 +414,6 @@ if (flags & OMIT_LAST) BladeDisableClipping(pScrn); #endif - - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } static void @@ -464,8 +438,8 @@ BLADE_OUT(0x2164, bg); BLADE_OUT(0x2148, XAACopyROP[rop]); pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -487,9 +461,6 @@ if (flags & OMIT_LAST) BladeDisableClipping(pScrn); - - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } static void @@ -502,8 +473,8 @@ BLADE_OUT(0x2160, color); BLADE_OUT(0x2148, XAACopyROP[rop]); pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -517,8 +488,6 @@ BLADE_OUT(0x2144, 0x20000000 | pTrident->BltScanDirection | 1<<19 | 1<<4 | 2<<2 | (pTrident->Clipping ? 1:0)); BLADE_OUT(0x2108, y<<16 | x); BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff)); - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } static void @@ -536,8 +505,8 @@ IMAGE_OUT(0x48, bg); IMAGE_OUT(0x20, 0x90000000 | XAACopyROP[rop]); pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -578,8 +547,8 @@ BLADE_OUT(0x2160, fg); BLADE_OUT(0x2164, bg); } + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -597,34 +566,6 @@ BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff)); } -static void MoveDWORDS( - register CARD32* dest, - register CARD32* src, - register int dwords ) -{ - while(dwords & ~0x03) { - *dest = *src; - *(dest + 1) = *(src + 1); - *(dest + 2) = *(src + 2); - *(dest + 3) = *(src + 3); - src += 4; - dest += 4; - dwords -= 4; - } - if (!dwords) return; - *dest = *src; - dest += 1; - src += 1; - if (dwords == 1) return; - *dest = *src; - dest += 1; - src += 1; - if (dwords == 2) return; - *dest = *src; - dest += 1; - src += 1; -} - static void BladeSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, @@ -656,8 +597,8 @@ BLADE_OUT(0x2178, bg); } pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -676,8 +617,6 @@ BLADE_OUT(0x2144, 0x20000000 | pTrident->BltScanDirection | 7<<12 | 1<<4 | 1<<19 | 2<<2 | clip); BLADE_OUT(0x2108, y<<16 | x); BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff)); - if (!pTrident->UsePCIRetry) - BladeSyncClip(pScrn); } static void @@ -697,8 +636,8 @@ pTrident->BltScanDirection |= 1<<6; } TGUI_FMIX(XAAPatternROP[rop]); + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -729,8 +668,8 @@ BLADE_OUT(0x2148, XAACopyROP[rop]); pTrident->BltScanDirection = 0; + REPLICATE(planemask); if (planemask != -1) { - REPLICATE(planemask); BLADE_OUT(0x2184, ~planemask); pTrident->BltScanDirection |= 1<<5; } @@ -745,6 +684,6 @@ if (skipleft) BladeSetClippingRectangle(pScrn,x+skipleft,y,(x+w-1),(y+h-1)); BLADE_OUT(0x2144, 0xE0000000 | 1<<19 | 1<<4 | pTrident->BltScanDirection | (skipleft ? 1 : 0)); - BLADE_OUT(0x2108, y<<16 | x); + BLADE_OUT(0x2108, y<<16 | (x&0xfff)); BLADE_OUT(0x210C, ((y+h-1)&0xfff)<<16 | ((x+w-1)&0xfff)); } Index: xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c:1.14 xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c:1.21 --- xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c:1.14 Wed Oct 13 16:02:30 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c Tue Dec 12 04:07:45 2000 @@ -23,7 +23,7 @@ * * Trident 3DImage' accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c,v 1.14 1999/10/13 20:02:30 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/image_accel.c,v 1.21 2000/12/12 09:07:45 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -107,27 +107,19 @@ pTrident->EngineOperation = 2; break; } - IMAGE_OUT(0x2120, 0x10000000); - IMAGE_OUT(0x2130, 2047 << 16 | 2047); - IMAGE_OUT(0x2120, 0x20000000); + IMAGE_OUT(0x2120, 0xF0000000); IMAGE_OUT(0x2120, 0x40000000 | pTrident->EngineOperation); - IMAGE_OUT(0x2120, 0x50000000); - IMAGE_OUT(0x2120, 0x60000000 |pScrn->displayWidth<<16 |pScrn->displayWidth); - IMAGE_OUT(0x2120, 0x70000000); IMAGE_OUT(0x2120, 0x80000000); - IMAGE_OUT(0x2120, 0xA0000000); - IMAGE_OUT(0x2120, 0xB0000000); - IMAGE_OUT(0x2120, 0xD0000000); - IMAGE_OUT(0x2120, 0xE0000000); - IMAGE_OUT(0x2130, 0x00000000); - IMAGE_OUT(0x2120, 0xF0000000); IMAGE_OUT(0x2144, 0x00000000); IMAGE_OUT(0x2148, 0x00000000); IMAGE_OUT(0x2150, 0x00000000); IMAGE_OUT(0x2154, 0x00000000); + IMAGE_OUT(0x2120, 0x60000000 |pScrn->displayWidth<<16 |pScrn->displayWidth); IMAGE_OUT(0x216C, 0x00000000); IMAGE_OUT(0x2170, 0x00000000); IMAGE_OUT(0x217C, 0x00000000); + IMAGE_OUT(0x2120, 0x10000000); + IMAGE_OUT(0x2130, 2047 << 16 | 2047); pTrident->Clipping = FALSE; pTrident->DstEnable = FALSE; } @@ -143,6 +135,7 @@ pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = ImageInitializeAccelerator; ImageInitializeAccelerator(pScrn); infoPtr->Flags = PIXMAP_CACHE | @@ -201,9 +194,13 @@ infoPtr->ClippingFlags |= HARDWARE_CLIP_COLOR_8x8_FILL; #endif + if (pTrident->Chipset != CYBER9397DVD) { + /* It seems as though the 9397DVD doesn't like the transfer window */ + /* But then, I've also tried at the two port addresses too, with */ + /* no luck. Disable for this chipset for now. I'd guess there's some */ + /* extra setup needed for this chipset. */ infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | LEFT_EDGE_CLIPPING | - LEFT_EDGE_CLIPPING_NEGATIVE_X | BIT_ORDER_IN_BYTE_MSBFIRST; pTrident->XAAScanlineColorExpandBuffers[0] = @@ -221,7 +218,6 @@ ImageSubsequentColorExpandScanline; infoPtr->ScanlineImageWriteFlags = NO_PLANEMASK | - LEFT_EDGE_CLIPPING_NEGATIVE_X | LEFT_EDGE_CLIPPING; infoPtr->SetupForScanlineImageWrite = ImageSetupForScanlineImageWrite; @@ -236,6 +232,7 @@ xnfalloc(pScrn->virtualX * pScrn->bitsPerPixel / 8); infoPtr->ImageWriteBase = pTrident->IOBase + 0x10000; + } AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; @@ -417,6 +414,9 @@ { TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + if ((w<=0) || (h<=0)) + return; + IMAGE_OUT(0x2108, ((y&0xfff)<<16) | (x&0xfff)); IMAGE_OUT(0x210C, (((y+h-1)&0xfff)<<16) | ((x+w-1)&0xfff)); IMAGE_OUT(0x2124, 0x80000000| 3<<22| 1<<10| 1<<9| (pTrident->Clipping?1:0)); @@ -572,7 +572,7 @@ IMAGE_OUT(0x210C, (((y+h-1)&0xfff)<<16) | ((x+w-1)&0xfff)); IMAGE_OUT(0x2124, 0x80000000 | pTrident->ROP | 1<<10 | 1); pTrident->dwords = (w + 31) >> 5; - pTrident->height = h; + pTrident->h = h; } static void @@ -585,8 +585,8 @@ MoveDWORDS((CARD32*)infoRec->ImageWriteBase, (CARD32*)pTrident->XAAScanlineColorExpandBuffers[bufno], pTrident->dwords); - pTrident->height--; - if (!pTrident->height) + pTrident->h--; + if (!pTrident->h) ImageSync(pScrn); } @@ -614,7 +614,7 @@ IMAGE_OUT(0x210C, (((y+h-1)&0xfff)<<16) | ((x+w-1)&0xfff)); IMAGE_OUT(0x2124, 0x80000000 | 1<<22 | 1<<10 | 1); pTrident->dwords = ((w * (pScrn->bitsPerPixel/8)) + 3) >> 2; - pTrident->height = h; + pTrident->h = h; } @@ -628,7 +628,7 @@ MoveDWORDS((CARD32*)infoRec->ImageWriteBase, (CARD32*)pTrident->XAAImageScanlineBuffer[bufno], pTrident->dwords); - pTrident->height--; - if (!pTrident->height) + pTrident->h--; + if (!pTrident->h) ImageSync(pScrn); } Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp:1.4 Tue Jun 13 22:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp Mon Dec 11 15:18:37 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp,v 1.8 2000/12/11 20:18:37 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH TRIDENT __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH TRIDENT __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME trident \- Trident video driver .SH SYNOPSIS @@ -13,18 +13,69 @@ .B EndSection .fi .SH DESCRIPTION -.B trident -is an XFree86 driver for Trident video chips. -THIS MAN PAGE NEEDS TO BE FILLED IN. +.B trident +is an XFree86 driver for Trident video cards. The driver is fully +accelerated, and provides support for the following framebuffer depths: +1, 4, 8, 15, 16, and 24. Multi-head configurations +are supported. The XvImage extension is supported on all Blade and Image +series cards. Currently the ZOOM feature doesn't work properly on the Image +series. .SH SUPPORTED HARDWARE The .B trident -driver supports... +driver supports PCI,AGP and ISA video cards based on the following +Trident chips: +.TP 12 +.B Blade +Blade3D, CyberBlade series i1, i7 (DSTN), i1, i1 (DSTN), Ai1, Ai1 (DSTN), +CyberBlade/e4 +.TP 12 +.B Image +3DImage975, 3DImage985, Cyber9520, Cyber9525, Cyber9397, Cyber9397DVD +.TP 12 +.B ProVidia +9682, 9685, Cyber9382, Cyber9385, Cyber9388 +.TP 12 +.B TGUI +9440AGi, 9660, 9680 +.TP 12 +.B 8900 +8900D (ISA) .SH CONFIGURATION DETAILS Please refer to XF86Config(__filemansuffix__) for general configuration details. This section only covers configuration details specific to this driver. +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qSWCursor\*q \*q" boolean \*q +Enable or disable the SW cursor. Default: off. +.TP +.BI "Option \*qNoAccel\*q \*q" boolean \*q +Disable or enable acceleration. Default: acceleration is enabled. +.TP +.BI "Option \*qPciRetry\*q \*q" boolean \*q +Enable or disable PCI retries. Default: off. +.TP +.BI "Option \*qCyberShadow\*q \*q" boolean \*q +For Cyber chipsets only, turn off shadow registers. If you only see +a partial display - this may be the option for you. Default: on. +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. See +shadowfb(__drivermansuffix__) for further information. Default: off. +.TP +.BI "Option \*qVideoKey\*q \*q" integer \*q +This sets the default pixel value for the YUV video overlay key. +NOTE: Default is 0 for depth 15 and 24. This needs fixing. +Default: undefined. +.TP +.BI "Option \*qNoPciBurst\*q \*q" boolean \*q +Turn off PCI burst mode, PCI Bursting is on by default. +Default: off. .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) -.SH AUTHORS -Authors include: ... +.SH AUTHOR +Author: Alan Hourihane Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h:1.24 xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h:1.33 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h:1.24 Mon Jun 12 22:28:34 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h Fri Dec 8 04:05:16 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1998 by Alan Hourihane <alanh@fairlite.demon.co.uk> + * Copyright 1992-2000 by Alan Hourihane <alanh@fairlite.demon.co.uk> * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ * * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.24 2000/06/13 02:28:34 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.33 2000/12/08 09:05:16 alanh Exp $ */ #ifndef _TRIDENT_H_ #define _TRIDENT_H_ @@ -33,6 +33,8 @@ #include "vgaHW.h" #include "xf86i2c.h" #include "xf86int10.h" +#include "shadowfb.h" +#include "xf86xv.h" typedef struct { unsigned char tridentRegs3x4[0x100]; @@ -57,7 +59,7 @@ int HwBpp; int BppShift; CARD32 IOAddress; - CARD32 FbAddress; + unsigned long FbAddress; unsigned char * IOBase; #ifdef __alpha__ unsigned char * IOBaseDense; @@ -68,7 +70,6 @@ Bool HWCursor; Bool UsePCIRetry; Bool UsePCIBurst; - Bool UseGERetry; Bool NewClockCode; Bool Clipping; Bool DstEnable; @@ -76,10 +77,6 @@ Bool HasSGRAM; Bool MUX; Bool IsCyber; -#if 0 - /* obsolete */ - Bool CyberShadowSet; -#endif Bool CyberShadow; Bool NoMMIO; Bool MMIOonly; @@ -91,6 +88,9 @@ int DGAViewportStatus; unsigned char * ShadowPtr; int ShadowPitch; + RefreshAreaFuncPtr RefreshArea; + void (*PointerMoved)(int index, int x, int y); + int Rotate; float frequency; unsigned char REGPCIReg; unsigned char REGNewMode1; @@ -100,10 +100,17 @@ int MinClock; int MaxClock; int MUXThreshold; + int currentClock; int MCLK; int dwords; - int height; + int h; + int x; + int w; + int y; int lcdMode; +#ifdef READOUT + Bool DontSetClock; +#endif TRIDENTRegRec SavedReg; TRIDENTRegRec ModeReg; I2CBusPtr DDC; @@ -117,11 +124,20 @@ xf86Int10InfoPtr Int10; XAAInfoRecPtr AccelInfoRec; CloseScreenProcPtr CloseScreen; + ScreenBlockHandlerProcPtr BlockHandler; int panelWidth; int panelHeight; unsigned int (*ddc1Read)(ScrnInfoPtr); CARD8* XAAScanlineColorExpandBuffers[2]; CARD8* XAAImageScanlineBuffer[1]; + void (*InitializeAccelerator)(ScrnInfoPtr); +#ifdef XvExtension + void (*VideoTimerCallback)(ScrnInfoPtr, Time); + XF86VideoAdaptorPtr adaptor; + int videoKey; + int hsync; + int vsync; +#endif } TRIDENTRec, *TRIDENTPtr; typedef struct { @@ -137,8 +153,11 @@ int shadow_10; int shadow_11; int shadow_16; + int shadow_HiOrd; } tridentLCD; +extern tridentLCD LCD[]; + typedef struct { int x_res; int y_res; @@ -163,6 +182,7 @@ Bool ImageAccelInit(ScreenPtr pScreen); Bool BladeAccelInit(ScreenPtr pScreen); Bool TridentHWCursorInit(ScreenPtr pScreen); +int TridentFindMode(int xres, int yres, int depth); void TGUISetClock(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); void TGUISetMCLK(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); void TridentOutIndReg(ScrnInfoPtr pScrn, @@ -180,8 +200,16 @@ int TVGA8900SetRead(ScreenPtr pScreen, int bank); int TVGA8900SetWrite(ScreenPtr pScreen, int bank); int TVGA8900SetReadWrite(ScreenPtr pScreen, int bank); - +void TridentFindClock(ScrnInfoPtr pScrn, int clock); float CalculateMCLK(ScrnInfoPtr pScrn); +void TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, + RegionPtr damage); +void TRIDENTPointerMoved(int index, int x, int y); +void TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); /* * Trident Chipset Definitions @@ -216,14 +244,16 @@ CYBER9397DVD, CYBER9520, CYBER9525DVD, - CYBER9540, IMAGE975, IMAGE985, BLADE3D, CYBERBLADEI7, CYBERBLADEI7D, CYBERBLADEI1, - CYBERBLADEI1D + CYBERBLADEI1D, + CYBERBLADEAI1, + CYBERBLADEAI1D, + CYBERBLADEE4 } TRIDENTType; #define UseMMIO (pTrident->NoMMIO == FALSE) @@ -241,12 +271,15 @@ (pTrident->Chipset == CYBER9397DVD) || \ (pTrident->Chipset == CYBER9520) || \ (pTrident->Chipset == CYBER9525DVD) || \ + (pTrident->Chipset == CYBERBLADEE4) || \ (pTrident->Chipset == IMAGE975) || \ (pTrident->Chipset == IMAGE985) || \ (pTrident->Chipset == CYBERBLADEI7) || \ (pTrident->Chipset == CYBERBLADEI7D) || \ (pTrident->Chipset == CYBERBLADEI1) || \ (pTrident->Chipset == CYBERBLADEI1D) || \ + (pTrident->Chipset == CYBERBLADEAI1) || \ + (pTrident->Chipset == CYBERBLADEAI1D) || \ (pTrident->Chipset == BLADE3D)) /* Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c:1.19 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c:1.10 Wed Jan 26 20:13:23 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c Thu Dec 7 11:48:04 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1997,1998 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -23,7 +23,7 @@ * * Trident accelerated options. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c,v 1.10 2000/01/27 01:13:23 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_accel.c,v 1.19 2000/12/07 16:48:04 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -65,13 +65,6 @@ int xdir, int ydir, int rop, unsigned int planemask, int transparency_color); -static void TridentSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, - int x2, int y2); -static void TridentDisableClipping(ScrnInfoPtr pScrn); -static void TridentWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h, - unsigned char *src, int srcwidth, int rop, - unsigned int planemask, int transparency_color, - int bpp, int depth); static void TridentSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, int fg, int bg, int rop, unsigned int planemask); @@ -99,14 +92,19 @@ { TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + /* This forces updating the clipper */ + pTrident->Clipping = TRUE; + CHECKCLIPPING; - if (pTrident->Chipset == PROVIDIA9682) + + if ( (pTrident->Chipset == PROVIDIA9682) || + (pTrident->Chipset == CYBER9385) || + (pTrident->Chipset == CYBER9382) ) pTrident->EngineOperation |= 0x100; /* Disable Clipping */ + TGUI_OPERMODE(pTrident->EngineOperation); - if (pTrident->Chipset == PROVIDIA9685 && pScrn->bitsPerPixel == 16) - pTrident->PatternLocation = pScrn->displayWidth; - else - pTrident->PatternLocation = pScrn->displayWidth*pScrn->bitsPerPixel/8; + + pTrident->PatternLocation = pScrn->displayWidth*pScrn->bitsPerPixel/8; } Bool @@ -120,6 +118,7 @@ pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; + pTrident->InitializeAccelerator = TridentInitializeAccelerator; TridentInitializeAccelerator(pScrn); if (!(pTrident->Chipset == TGUI9440AGi && pScrn->bitsPerPixel > 8)) @@ -131,17 +130,6 @@ infoPtr->Sync = TridentSync; - if (pTrident->Chipset >= TGUI9660) { - infoPtr->SetClippingRectangle = TridentSetClippingRectangle; - infoPtr->DisableClipping = TridentDisableClipping; - infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_FILL | - HARDWARE_CLIP_SOLID_LINE | - HARDWARE_CLIP_DASHED_LINE | - HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | - HARDWARE_CLIP_MONO_8x8_FILL | - HARDWARE_CLIP_COLOR_8x8_FILL; - } - infoPtr->SolidLineFlags = NO_PLANEMASK; infoPtr->SetupForSolidLine = TridentSetupForSolidLine; infoPtr->SolidBresenhamLineErrorTermBits = 12; @@ -170,15 +158,17 @@ infoPtr->SubsequentScreenToScreenCopy = TridentSubsequentScreenToScreenCopy; - infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | + if (!(pTrident->Chipset == PROVIDIA9685 && pScrn->bitsPerPixel > 8)) { + infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; - infoPtr->SetupForMono8x8PatternFill = + infoPtr->SetupForMono8x8PatternFill = TridentSetupForMono8x8PatternFill; - infoPtr->SubsequentMono8x8PatternFillRect = + infoPtr->SubsequentMono8x8PatternFillRect = TridentSubsequentMono8x8PatternFillRect; - infoPtr->MonoPatternPitch = 64; + infoPtr->MonoPatternPitch = 64; + } #if 0 /* Not convinced this works 100% yet */ infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK | @@ -194,13 +184,9 @@ #endif infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | + NO_TRANSPARENCY | BIT_ORDER_IN_BYTE_MSBFIRST; - if (pTrident->Chipset >= TGUI9660) - infoPtr->ScanlineCPUToScreenColorExpandFillFlags |= - LEFT_EDGE_CLIPPING_NEGATIVE_X | - LEFT_EDGE_CLIPPING; - pTrident->XAAScanlineColorExpandBuffers[0] = xnfalloc(((pScrn->virtualX + 63)) *4* (pScrn->bitsPerPixel / 8)); @@ -215,14 +201,6 @@ infoPtr->SubsequentColorExpandScanline = TridentSubsequentColorExpandScanline; - /* Requires clipping, therefore only 9660's or above */ - if (pTrident->Chipset >= TGUI9660) { - infoPtr->WritePixmap = TridentWritePixmap; - infoPtr->WritePixmapFlags = NO_PLANEMASK; - - if (!HAS_DST_TRANS) infoPtr->WritePixmapFlags |= NO_TRANSPARENCY; - } - AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; @@ -302,13 +280,13 @@ if (xdir < 0) pTrident->BltScanDirection |= XNEG; if (ydir < 0) pTrident->BltScanDirection |= YNEG; + REPLICATE(transparency_color); if (transparency_color != -1) { if (pTrident->Chipset == PROVIDIA9685) { dst |= 1<<16; } else { TGUI_OPERMODE(pTrident->EngineOperation | DST_ENABLE); } - REPLICATE(transparency_color); TGUI_CKEY(transparency_color); } @@ -342,37 +320,7 @@ TGUI_DEST_XY(x2,y2); TGUI_DIM_XY(w,h); TGUI_COMMAND(GE_BLT); - if (!pTrident->UseGERetry) - TridentClearSync(pScrn); -} - -static void -TridentSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - - TGUI_SRCCLIP_XY(x1, y1); - TGUI_DSTCLIP_XY(x2, y2); - pTrident->Clipping = TRUE; - if (pTrident->Chipset == PROVIDIA9682) - pTrident->EngineOperation &= 0xFEFF; /* Enable Clipping */ - if (pTrident->Chipset == PROVIDIA9685) - pTrident->DrawFlag = 1<<30; - else - pTrident->DrawFlag = 0; - TGUI_OPERMODE(pTrident->EngineOperation & 0xFEFF); -} - -static void -TridentDisableClipping(ScrnInfoPtr pScrn) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - if (pTrident->Chipset == PROVIDIA9682) - pTrident->EngineOperation |= 0x100; /* Disable Clipping */ - if (pTrident->Chipset == PROVIDIA9685) - pTrident->DrawFlag = 0; - TGUI_OPERMODE(pTrident->EngineOperation); - CHECKCLIPPING; + TridentClearSync(pScrn); } static void @@ -411,8 +359,7 @@ TGUI_DEST_XY(x,y); TGUI_DIM_XY(dmin+e,len); TGUI_COMMAND(GE_BRESLINE); - if (!pTrident->UseGERetry) - TridentSync(pScrn); + TridentSync(pScrn); } static void @@ -423,7 +370,7 @@ ){ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - TGUI_DRAWFLAG(pTrident->DrawFlag | SOLIDFILL | PATMONO); + TGUI_DRAWFLAG(pTrident->DrawFlag | SOLIDFILL); if (dir == DEGREES_0) { TGUI_DIM_XY(len,1); TGUI_DEST_XY(x,y); @@ -432,8 +379,7 @@ TGUI_DEST_XY(x,y); } TGUI_COMMAND(GE_BLT); - if (!pTrident->UseGERetry) - TridentSync(pScrn); + TridentSync(pScrn); } void @@ -503,8 +449,7 @@ TGUI_DEST_XY(x,y); TGUI_DIM_XY(e+dmin,len); TGUI_COMMAND(GE_BRESLINE); - if (!pTrident->UseGERetry) - TridentSync(pScrn); + TridentSync(pScrn); } static void @@ -522,9 +467,10 @@ if (rop == GXcopy) drawflag |= 1<<21; TGUI_FPATCOL(color); } else { + drawflag |= PATMONO; TGUI_FCOLOUR(color); } - TGUI_DRAWFLAG(pTrident->DrawFlag | SOLIDFILL | PATMONO | drawflag); + TGUI_DRAWFLAG(pTrident->DrawFlag | SOLIDFILL | drawflag); } static void @@ -535,8 +481,7 @@ TGUI_DIM_XY(w,h); TGUI_DEST_XY(x,y); TGUI_COMMAND(GE_BLT); - if (!pTrident->UseGERetry) - TridentSync(pScrn); + TridentSync(pScrn); } static void MoveDWORDS( @@ -567,70 +512,6 @@ src += 1; } -static void -TridentWritePixmap( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - unsigned char *src, - int srcwidth, - int rop, - unsigned int planemask, - int transparency_color, - int bpp, int depth -) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int dst = 0; - - TridentSetClippingRectangle(pScrn,(x*(bpp>>3)),y,((w+x)*(bpp>>3))-1,y+h-1); - - if (w & 7) - w += 8 - (w & 7); - - if (transparency_color != -1) { - if (pTrident->Chipset == PROVIDIA9685) { - dst |= 1<<16; - } else { - TGUI_OPERMODE(pTrident->EngineOperation | DST_ENABLE); - } - REPLICATE(transparency_color); - TGUI_CKEY(transparency_color); - } - TGUI_SRC_XY(0,0); - TGUI_FMIX(XAACopyROP[rop]); - TGUI_DEST_XY(x,y); - TGUI_DIM_XY(w,h); - if (rop == GXcopy) { - if (pTrident->Chipset == PROVIDIA9685) - dst |= 1<<30 | 1<<21; - if ((pTrident->Chipset == PROVIDIA9682) || - (pTrident->Chipset == TGUI9680)) - dst |= FASTMODE; - } - - TGUI_DRAWFLAG(dst); - TGUI_COMMAND(GE_BLT); - - if (pScrn->bitsPerPixel == 8) - w >>= 2; - if (pScrn->bitsPerPixel == 16) - w >>= 1; - - while (h--) { - MoveDWORDS((CARD32*)pTrident->FbBase,(CARD32*)src,w); - src += srcwidth; - } - - if (pTrident->UseGERetry) - SET_SYNC_FLAG(infoRec); - else - TridentSync(pScrn); - - TGUI_OPERMODE(pTrident->EngineOperation); - TridentDisableClipping(pScrn); -} - static void TridentSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, @@ -638,7 +519,7 @@ unsigned int planemask) { TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - int drawflag = SRCMONO; + int drawflag = 0; REPLICATE(fg); if (pTrident->Chipset == PROVIDIA9685) @@ -684,8 +565,7 @@ TGUI_DEST_XY(x,y); TGUI_DIM_XY(w,h); TGUI_COMMAND(GE_BLT); - if (!pTrident->UseGERetry) - TridentSync(pScrn); + TridentSync(pScrn); } static void @@ -702,13 +582,13 @@ pTrident->Chipset == TGUI9680) && rop == GXcopy) drawflag |= FASTMODE; + REPLICATE(transparency_color); if (transparency_color != -1) { if (pTrident->Chipset == PROVIDIA9685) { drawflag |= 1<<16; } else { TGUI_OPERMODE(pTrident->EngineOperation | DST_ENABLE); } - REPLICATE(transparency_color); TGUI_CKEY(transparency_color); } @@ -729,8 +609,7 @@ TGUI_DEST_XY(x,y); TGUI_DIM_XY(w,h); TGUI_COMMAND(GE_BLT); - if (!pTrident->UseGERetry) - TridentClearSync(pScrn); + TridentClearSync(pScrn); } static void @@ -753,9 +632,6 @@ TGUI_BCOLOUR(bg); } - if (pTrident->Chipset == PROVIDIA9685) - drawflag |= 1<<30; - if ((pTrident->Chipset == PROVIDIA9682 || pTrident->Chipset == TGUI9680) && rop == GXcopy) drawflag |= FASTMODE; @@ -771,16 +647,14 @@ int skipleft ){ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - int bpp = pScrn->bitsPerPixel >> 3; pTrident->dwords = (w + 31) >> 5; - pTrident->height = h; - - if (pTrident->Chipset >= TGUI9660) - TridentSetClippingRectangle(pScrn,((x+skipleft)*bpp),y, - ((w+x)*bpp)-1,y+h-1); + pTrident->h = h; + pTrident->y = y; + pTrident->x = x; + pTrident->w = w; - TGUI_DEST_XY(x,y); - TGUI_DIM_XY(w,h); + TGUI_DEST_XY(x,pTrident->y++); + TGUI_DIM_XY(w,1); TGUI_COMMAND(GE_BLT); } @@ -795,10 +669,11 @@ (CARD32 *)pTrident->XAAScanlineColorExpandBuffers[0], pTrident->dwords); - pTrident->height--; - if (!pTrident->height) { - if (!pTrident->UseGERetry) - TridentSync(pScrn); - TridentDisableClipping(pScrn); + pTrident->h--; + TridentSync(pScrn); + if (pTrident->h) { + TGUI_DEST_XY(pTrident->x,pTrident->y++); + TGUI_DIM_XY(pTrident->w,1); + TGUI_COMMAND(GE_BLT); } } Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c:1.3 Wed Oct 13 16:02:30 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c Thu Dec 7 11:48:04 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1998 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ * * Author: Alan Hourihane, alanh@fairlite.demon.co.uk */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c,v 1.3 1999/10/13 20:02:30 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_bank.c,v 1.4 2000/12/07 16:48:04 alanh Exp $ */ /* All drivers should typically include these */ #include "xf86.h" Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c:1.23 xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c:1.37 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c:1.23 Fri Jun 23 14:25:58 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c Thu Dec 14 14:29:44 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1992-1999 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ * * Author: Alan Hourihane, alanh@fairlite.demon.co.uk */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.23 2000/06/23 18:25:58 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.37 2000/12/14 19:29:44 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -35,13 +35,12 @@ #include "trident.h" #include "trident_regs.h" -extern tridentLCD LCD[]; -biosMode bios1[] = { +static biosMode bios1[] = { { 640, 480, 0x11 } }; -biosMode bios4[] = { +static biosMode bios4[] = { { 320, 200, 0xd }, { 640, 200, 0xe }, { 640, 350, 0x11 }, @@ -52,33 +51,38 @@ { 1600, 1200, 0x65 } }; -biosMode bios8[] = { +static biosMode bios8[] = { { 320, 200, 0x13 }, - { 640, 400, 0x52 }, + { 640, 400, 0x5c }, { 640, 480, 0x5d }, { 720, 480, 0x60 }, + { 800, 600, 0x5e }, { 1024, 768, 0x62 }, { 1280, 1024, 0x64 }, { 1600, 1200, 0x66 } }; -biosMode bios15[] = { +static biosMode bios15[] = { { 640, 400, 0x72 }, { 640, 480, 0x74 }, { 720, 480, 0x70 }, { 800, 600, 0x76 }, - { 1024, 768, 0x78 } + { 1024, 768, 0x78 }, + { 1280, 1024, 0x7a }, + { 1600, 1200, 0x7c } }; -biosMode bios16[] = { +static biosMode bios16[] = { { 640, 400, 0x73 }, { 640, 480, 0x75 }, { 720, 480, 0x71 }, { 800, 600, 0x77 }, - { 1024, 768, 0x79 } + { 1024, 768, 0x79 }, + { 1280, 1024, 0x7b }, + { 1600, 1200, 0x7d } }; -biosMode bios24[] = { +static biosMode bios24[] = { { 640, 400, 0x6b }, { 640, 480, 0x6c }, { 720, 480, 0x61 }, @@ -87,8 +91,8 @@ }; -static int -findMode(int xres, int yres, int depth) +int +TridentFindMode(int xres, int yres, int depth) { int xres_s; int i, size; @@ -145,7 +149,7 @@ TRIDENTRegPtr pReg = &pTrident->ModeReg; int vgaIOBase; int offset = 0; - int clock = mode->Clock; + int clock = pTrident->currentClock; CARD8 protect; vgaHWPtr hwp = VGAHWPTR(pScrn); @@ -153,7 +157,6 @@ vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; - /* Unprotect */ OUTB(0x3C4, 0x11); protect = INB(0x3C4); @@ -167,60 +170,25 @@ OUTB(0x3CE, MiscExtFunc); pReg->tridentRegs3CE[MiscExtFunc] = INB(0x3CF) & 0xF0; pReg->tridentRegs3x4[GraphEngReg] = 0x00; + pReg->tridentRegs3x4[PreEndControl] = 0; + pReg->tridentRegs3x4[PreEndFetch] = 0; - /* Enable Chipset specific options */ - switch (pTrident->Chipset) { - case CYBERBLADEI7: - case CYBERBLADEI7D: - case CYBERBLADEI1: - case CYBERBLADEI1D: - case BLADE3D: - OUTB(vgaIOBase + 4, RAMDACTiming); - pReg->tridentRegs3x4[RAMDACTiming] |= 0x0F; - pReg->tridentRegs3x4[GraphEngReg] |= 0x10; - /* Fall Through */ - case CYBER9520: - case CYBER9525DVD: - case CYBER9540: - case CYBER9397DVD: - case CYBER9397: - case CYBER9388: - case IMAGE975: - case IMAGE985: - if (pScrn->bitsPerPixel >= 8) - pReg->tridentRegs3CE[MiscExtFunc] |= 0x10; - /* Fall Through */ - case PROVIDIA9685: - if (pTrident->UsePCIRetry) { - pTrident->UseGERetry = TRUE; - pReg->tridentRegs3x4[Enhancement0] = 0x50; - } else { - pTrident->UseGERetry = FALSE; - pReg->tridentRegs3x4[Enhancement0] = 0x00; - } - /* Fall Through */ - case PROVIDIA9682: - if (pTrident->UsePCIRetry) - pReg->tridentRegs3x4[PCIRetry] = 0xDF; - else - pReg->tridentRegs3x4[PCIRetry] = 0x00; - /* Fall Through */ - case TGUI9660: - case TGUI9680: - if (pTrident->MUX && pScrn->bitsPerPixel == 8 && mode->CrtcHAdjusted) { - pReg->tridentRegs3x4[PixelBusReg] |= 0x01; /* 16bit bus */ - pReg->tridentRegs3C4[NewMode2] |= 0x02; /* half clock */ - pReg->tridentRegsDAC[0x00] |= 0x20; /* mux mode */ - } - } + pReg->tridentRegs3x4[CRTHiOrd] = (((mode->CrtcVBlankEnd-1) & 0x400)>>4) | + (((mode->CrtcVTotal - 2) & 0x400) >> 3) | + ((mode->CrtcVSyncStart & 0x400) >> 5) | + (((mode->CrtcVDisplay - 1) & 0x400) >> 6)| + 0x08; if (pTrident->IsCyber) { Bool LCDActive; +#ifdef READOUT Bool ShadowModeActive; - int i; - +#endif + int i = pTrident->lcdMode; +#ifdef READOUT OUTB(0x3CE, CyberControl); ShadowModeActive = ((INB(0x3CF) & 0x81) == 0x81); +#endif OUTB(0x3CE, FPConfig); LCDActive = (INB(0x3CF) & 0x10); @@ -243,6 +211,7 @@ OUTB(0x3CE,VertStretch); pReg->tridentRegs3CE[VertStretch] = INB(0x3CF); +#ifdef READOUT if ((!((pReg->tridentRegs3CE[VertStretch] & 1) || (pReg->tridentRegs3CE[HorStretch] & 1))) && (!LCDActive || ShadowModeActive)) { @@ -256,44 +225,46 @@ OUTB(vgaIOBase + 4,4); pReg->tridentRegs3x4[0x4] = INB(vgaIOBase + 5); OUTB(vgaIOBase + 4,5); - pReg->tridentRegs3x4[0x5] = INB(vgaIOBase + 5); - OUTB(vgaIOBase + 4,0x6); - pReg->tridentRegs3x4[0x6] = INB(vgaIOBase + 5); - OUTB(vgaIOBase + 4,0x7); - pReg->tridentRegs3x4[0x7] = INB(vgaIOBase + 5); - OUTB(vgaIOBase + 4,0x10); - pReg->tridentRegs3x4[0x10] = INB(vgaIOBase + 5); - OUTB(vgaIOBase + 4,0x11); - pReg->tridentRegs3x4[0x11] = INB(vgaIOBase + 5); - OUTB(vgaIOBase + 4,0x16); - pReg->tridentRegs3x4[0x16] = INB(vgaIOBase + 5); - SHADOW_RESTORE(tmp); - xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Timing shadow registers:" - "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x " - "0x%2.2x 0x%2.2x 0x%2.2x\n",pReg->tridentRegs3x4[0], - pReg->tridentRegs3x4[3], pReg->tridentRegs3x4[4], - pReg->tridentRegs3x4[5], pReg->tridentRegs3x4[6], - pReg->tridentRegs3x4[7], pReg->tridentRegs3x4[0x10], - pReg->tridentRegs3x4[0x11], - pReg->tridentRegs3x4[0x16]); - } else { - if ((i = pTrident->lcdMode)) { - pReg->tridentRegs3x4[0x0] = LCD[i].shadow_0; - pReg->tridentRegs3x4[0x3] = LCD[i].shadow_3; - pReg->tridentRegs3x4[0x4] = LCD[i].shadow_4; - pReg->tridentRegs3x4[0x5] = LCD[i].shadow_5; - pReg->tridentRegs3x4[0x6] = LCD[i].shadow_6; - pReg->tridentRegs3x4[0x7] = LCD[i].shadow_7; - pReg->tridentRegs3x4[0x10] = LCD[i].shadow_10; - pReg->tridentRegs3x4[0x11] = LCD[i].shadow_11; - pReg->tridentRegs3x4[0x16] = LCD[i].shadow_16; - /* Not yet implemented */ - clock = LCD[i].clock; - } - } - /* copy over common bits from normal VGA */ - - pReg->tridentRegs3x4[0x7] &= ~0x52; + pReg->tridentRegs3x4[0x5] = INB(vgaIOBase + 5); + OUTB(vgaIOBase + 4,0x6); + pReg->tridentRegs3x4[0x6] = INB(vgaIOBase + 5); + SHADOW_RESTORE(tmp); + } else +#endif + { + if (i != 0xff) { + pReg->tridentRegs3x4[0x0] = LCD[i].shadow_0; + pReg->tridentRegs3x4[0x3] = LCD[i].shadow_3; + pReg->tridentRegs3x4[0x4] = LCD[i].shadow_4; + pReg->tridentRegs3x4[0x5] = LCD[i].shadow_5; + pReg->tridentRegs3x4[0x6] = LCD[i].shadow_6; + xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1, + "Overriding Horizontal timings.\n"); + } + } + + if (i != 0xff) { + pReg->tridentRegs3x4[0x7] = LCD[i].shadow_7; + pReg->tridentRegs3x4[0x10] = LCD[i].shadow_10; + pReg->tridentRegs3x4[0x11] = LCD[i].shadow_11; + pReg->tridentRegs3x4[0x16] = LCD[i].shadow_16; + if (LCDActive) + pReg->tridentRegs3x4[CRTHiOrd] = LCD[i].shadow_HiOrd; + } + + xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Timing shadow registers:" + "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x " + "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n", + pReg->tridentRegs3x4[0], pReg->tridentRegs3x4[3], + pReg->tridentRegs3x4[4], pReg->tridentRegs3x4[5], + pReg->tridentRegs3x4[6], pReg->tridentRegs3x4[7], + pReg->tridentRegs3x4[0x10],pReg->tridentRegs3x4[0x11], + pReg->tridentRegs3x4[0x16], + pReg->tridentRegs3x4[CRTHiOrd]); + + /* copy over common bits from normal VGA */ + + pReg->tridentRegs3x4[0x7] &= ~0x52; pReg->tridentRegs3x4[0x7] |= (vgaReg->CRTC[0x7] & 0x52); /* disable stretching, enable centering */ @@ -321,26 +292,76 @@ pReg->tridentRegs3x4[PreEndFetch] = INB(vgaIOBase + 5); #endif /* set mode */ - pReg->tridentRegs3CE[BiosMode] = findMode(pScrn->currentMode->HDisplay, - pScrn->currentMode->VDisplay, - pScrn->depth); + pReg->tridentRegs3CE[BiosMode] = TridentFindMode( + pScrn->currentMode->HDisplay, + pScrn->currentMode->VDisplay, + pScrn->depth); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Setting BIOS Mode: %x\n", pReg->tridentRegs3CE[BiosMode]); /* no stretch */ pReg->tridentRegs3CE[BiosReg] = 0; -#if 0 - /* obsolete */ - if (pTrident->CyberShadowSet) { - if (pTrident->CyberShadow) { - pReg->tridentRegs3CE[CyberControl] |= 0x81; - } else - pReg->tridentRegs3CE[CyberControl] &= 0x7E; + if (LCDActive) { + pReg->tridentRegs3CE[CyberControl] |= 0x81; + xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Shadow on\n"); + } else { + pReg->tridentRegs3CE[CyberControl] &= 0x7E; + xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Shadow off\n"); } -#endif + + if (pTrident->CyberShadow) { + pReg->tridentRegs3CE[CyberControl] &= 0x7E; + xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Forcing Shadow off\n"); + } + } + + /* Enable Chipset specific options */ + switch (pTrident->Chipset) { + case CYBERBLADEI7: + case CYBERBLADEI7D: + case CYBERBLADEI1: + case CYBERBLADEI1D: + case CYBERBLADEAI1: + case CYBERBLADEAI1D: + case CYBERBLADEE4: + case BLADE3D: + OUTB(vgaIOBase + 4, RAMDACTiming); + pReg->tridentRegs3x4[RAMDACTiming] = INB(vgaIOBase + 5) | 0x0F; + /* Fall Through */ + case CYBER9520: + case CYBER9525DVD: + case CYBER9397DVD: + case CYBER9397: + case CYBER9388: + case IMAGE975: + case IMAGE985: + if (pScrn->bitsPerPixel >= 8) + pReg->tridentRegs3CE[MiscExtFunc] |= 0x10; + if (!pReg->tridentRegs3x4[PreEndControl]) + pReg->tridentRegs3x4[PreEndControl] = 0x01; + if (!pReg->tridentRegs3x4[PreEndFetch]) + pReg->tridentRegs3x4[PreEndFetch] = 0xFF; + /* Fall Through */ + case PROVIDIA9685: + pReg->tridentRegs3x4[Enhancement0] = 0x40; + /* Fall Through */ + case PROVIDIA9682: + if (pTrident->UsePCIRetry) + pReg->tridentRegs3x4[PCIRetry] = 0xDF; + else + pReg->tridentRegs3x4[PCIRetry] = 0x1F; + /* Fall Through */ + case TGUI9660: + case TGUI9680: + if (pTrident->MUX && pScrn->bitsPerPixel == 8 && mode->CrtcHAdjusted) { + pReg->tridentRegs3x4[PixelBusReg] |= 0x01; /* 16bit bus */ + pReg->tridentRegs3C4[NewMode2] |= 0x02; /* half clock */ + pReg->tridentRegsDAC[0x00] |= 0x20; /* mux mode */ + } } + /* Defaults for all trident chipsets follows */ switch (pScrn->bitsPerPixel) { case 1: @@ -372,6 +393,10 @@ offset = (pScrn->displayWidth * 3) >> 3; pReg->tridentRegs3x4[PixelBusReg] = 0x29; pReg->tridentRegsDAC[0x00] = 0xD0; + if (pTrident->Chipset == CYBERBLADEE4) { + OUTB(vgaIOBase+ 4, New32); + pReg->tridentRegs3x4[New32] = INB(vgaIOBase + 5) & 0x7F; + } break; case 32: pReg->tridentRegs3CE[MiscExtFunc] |= 0x02; @@ -380,13 +405,18 @@ offset = pScrn->displayWidth >> 1; pReg->tridentRegs3x4[PixelBusReg] = 0x09; pReg->tridentRegsDAC[0x00] = 0xD0; + if (pTrident->Chipset == CYBERBLADEE4) { + OUTB(vgaIOBase+ 4, New32); + pReg->tridentRegs3x4[New32] = INB(vgaIOBase + 5) | 0x80; + /* With new mode 32bpp we set the packed flag */ + pReg->tridentRegs3x4[PixelBusReg] |= 0x20; + } break; } pReg->tridentRegs3x4[Offset] = offset & 0xFF; { CARD8 a, b; - TGUISetClock(pScrn, clock, &a, &b); pReg->tridentRegsClock[0x00] = (INB(0x3CC) & 0xF3) | 0x08; pReg->tridentRegsClock[0x01] = a; @@ -401,21 +431,19 @@ pReg->tridentRegs3C4[NewMode1] = 0xC0; pReg->tridentRegs3C4[Protection] = 0x92; - if (pTrident->Linear) - pReg->tridentRegs3x4[LinearAddReg] = ((pTrident->FbAddress >> 24) << 6)| - ((pTrident->FbAddress >> 20) & 0x0F)| - 0x20; - else { + pReg->tridentRegs3x4[LinearAddReg] = 0; + if (pTrident->Linear) { + /* This is used for VLB, when we support it again in 4.0 */ + if (pTrident->Chipset < PROVIDIA9685) + pReg->tridentRegs3x4[LinearAddReg] |= + ((pTrident->FbAddress >> 24) << 6)| + ((pTrident->FbAddress >> 20) & 0x0F); + /* Turn on linear mapping */ + pReg->tridentRegs3x4[LinearAddReg] |= 0x20; + } else { pReg->tridentRegs3CE[MiscExtFunc] |= 0x04; - pReg->tridentRegs3x4[LinearAddReg] = 0; } - - pReg->tridentRegs3x4[CRTHiOrd] = (((mode->CrtcVBlankEnd-1) & 0x400)>>4) | - (((mode->CrtcVTotal - 2) & 0x400) >> 3) | - ((mode->CrtcVSyncStart & 0x400) >> 5) | - (((mode->CrtcVDisplay - 1) & 0x400) >> 6) | - 0x08; - + pReg->tridentRegs3x4[CRTCModuleTest] = (mode->Flags & V_INTERLACE ? 0x84 : 0x80); OUTB(vgaIOBase+ 4, InterfaceSel); @@ -446,11 +474,16 @@ OUTB(0x3CE, MiscIntContReg); pReg->tridentRegs3CE[MiscIntContReg] = INB(0x3CF) | 0x04; + /* Fix hashing problem in > 8bpp on 9320 chipset */ + if (pTrident->Chipset == CYBER9320 && pScrn->bitsPerPixel > 8) + pReg->tridentRegs3CE[MiscIntContReg] &= ~0x80; + OUTB(vgaIOBase+ 4, PCIReg); if (IsPciCard && UseMMIO) pReg->tridentRegs3x4[PCIReg] = INB(vgaIOBase + 5) & 0xF9; else pReg->tridentRegs3x4[PCIReg] = INB(vgaIOBase + 5) & 0xF8; + /* Enable PCI Bursting on capable chips */ if (pTrident->Chipset >= TGUI9660) { if(pTrident->UsePCIBurst) { @@ -475,8 +508,11 @@ vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; - OUTB(0x3C4, Protection); - OUTB(0x3C5, 0x92); + if (pTrident->Chipset > PROVIDIA9685) { + OUTB(0x3C4, Protection); + OUTB(0x3C5, 0x92); + } + /* Goto New Mode */ OUTB(0x3C4, 0x0B); temp = INB(0x3C5); @@ -508,11 +544,14 @@ OUTW_3CE(MiscIntContReg); OUTW_3CE(MiscExtFunc); OUTW_3x4(Offset); + OUTW_3x4(PreEndControl); + OUTW_3x4(PreEndFetch); if (pTrident->Chipset >= PROVIDIA9685) OUTW_3x4(Enhancement0); - if (pTrident->Chipset >= BLADE3D) OUTW_3x4(RAMDACTiming); + if (pTrident->Chipset >= BLADE3D) OUTW_3x4(RAMDACTiming); + if (pTrident->Chipset == CYBERBLADEE4) OUTW_3x4(New32); if (pTrident->IsCyber) { CARD8 tmp; - + OUTW_3CE(VertStretch); OUTW_3CE(HorStretch); OUTW_3CE(BiosMode); @@ -528,31 +567,47 @@ OUTW_3x4(0x7); OUTW_3x4(0x10); OUTW_3x4(0x11); - OUTW_3x4(0x96); + OUTW_3x4(0x16); SHADOW_RESTORE(tmp); - OUTW_3x4(PreEndControl); - OUTW_3x4(PreEndFetch); } if (Is3Dchip) { - OUTW(0x3C4, (tridentReg->tridentRegsClock[0x01])<<8 | ClockLow); - OUTW(0x3C4, (tridentReg->tridentRegsClock[0x02])<<8 | ClockHigh); +#ifdef READOUT + if (!pTrident->DontSetClock) +#endif + { + OUTW(0x3C4, (tridentReg->tridentRegsClock[0x01])<<8 | ClockLow); + OUTW(0x3C4, (tridentReg->tridentRegsClock[0x02])<<8 | ClockHigh); + } if (pTrident->MCLK > 0) { OUTW(0x3C4,(tridentReg->tridentRegsClock[0x03])<<8 | MCLKLow); OUTW(0x3C4,(tridentReg->tridentRegsClock[0x04])<<8 | MCLKHigh); } } else { - OUTB(0x43C8, tridentReg->tridentRegsClock[0x01]); - OUTB(0x43C9, tridentReg->tridentRegsClock[0x02]); +#ifdef READOUT + if (!pTrident->DontSetClock) +#endif + { + OUTB(0x43C8, tridentReg->tridentRegsClock[0x01]); + OUTB(0x43C9, tridentReg->tridentRegsClock[0x02]); + } if (pTrident->MCLK > 0) { OUTB(0x43C6, tridentReg->tridentRegsClock[0x03]); OUTB(0x43C7, tridentReg->tridentRegsClock[0x04]); } } - OUTB(0x3C2, tridentReg->tridentRegsClock[0x00]); +#ifdef READOUT + if (!pTrident->DontSetClock) +#endif + { + OUTB(0x3C2, tridentReg->tridentRegsClock[0x00]); + } + + if (pTrident->Chipset > PROVIDIA9685) { + OUTB(0x3C4, Protection); + OUTB(0x3C5, tridentReg->tridentRegs3C4[Protection]); + } - OUTB(0x3C4, Protection); - OUTB(0x3C5, tridentReg->tridentRegs3C4[Protection]); OUTW(0x3C4, ((tridentReg->tridentRegs3C4[NewMode1] ^ 0x02) << 8)| NewMode1); } @@ -570,7 +625,8 @@ temp = INB(0x3C5); INB_3C4(NewMode1); - INB_3C4(Protection); + if (pTrident->Chipset > PROVIDIA9685) + INB_3C4(Protection); /* Unprotect registers */ OUTW(0x3C4, ((0xC0 ^ 0x02) << 8) | NewMode1); @@ -588,8 +644,11 @@ INB_3x4(GraphEngReg); INB_3x4(PCIReg); INB_3x4(PCIRetry); + INB_3x4(PreEndControl); + INB_3x4(PreEndFetch); if (pTrident->Chipset >= PROVIDIA9685) INB_3x4(Enhancement0); - if (pTrident->Chipset >= BLADE3D) INB_3x4(RAMDACTiming); + if (pTrident->Chipset >= BLADE3D) INB_3x4(RAMDACTiming); + if (pTrident->Chipset == CYBERBLADEE4) INB_3x4(New32); if (pTrident->IsCyber) { CARD8 tmp; INB_3CE(VertStretch); @@ -609,8 +668,6 @@ INB_3x4(0x11); INB_3x4(0x16); SHADOW_RESTORE(tmp); - INB_3x4(PreEndControl); - INB_3x4(PreEndFetch); } /* save cursor registers */ @@ -683,7 +740,6 @@ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; - if (x < 0) { OUTW(vgaIOBase + 4, (-x)<<8 | 0x46); x = 0; @@ -747,6 +803,8 @@ if (pTrident->MUX && pScrn->bitsPerPixel == 8) return FALSE; + if (!pTrident->HWCursor) return FALSE; + return TRUE; } @@ -761,7 +819,7 @@ if (memory > (pScrn->videoRam * 1024 - 4096)) return FALSE; infoPtr = xf86CreateCursorInfoRec(); if(!infoPtr) return FALSE; - + pTrident->CursorInfoRec = infoPtr; infoPtr->MaxWidth = 64; @@ -811,7 +869,6 @@ ScrnInfoPtr pScrn, int overscan ){ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); if (overscan < 0 || overscan > 255) @@ -832,7 +889,10 @@ vgaHWPtr hwp = VGAHWPTR(pScrn); TRIDENTPtr pTrident = TRIDENTPTR(pScrn); int i, index; - + int sig; +#if 0 + sig = xf86BlockSIGIO (); +#endif for(i = 0; i < numColors; i++) { index = indicies[i]; OUTB(0x3C6, 0xFF); @@ -846,4 +906,8 @@ OUTB(0x3c9, colors[index].blue); DACDelay(hwp); } +#if 0 + xf86UnblockSIGIO (sig); +#endif } + Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c:1.100 xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c:1.119 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c:1.100 Wed Jun 21 13:28:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c Fri Dec 8 04:05:16 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1992-1998 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -28,10 +28,10 @@ * Massimiliano Ghilardi, max@Linuz.sns.it, some fixes to the * clockchip programming code. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.100 2000/06/21 17:28:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.119 2000/12/08 09:05:16 alanh Exp $ */ -#include "cfb24_32.h" - +#include "xf1bpp.h" +#include "xf4bpp.h" #include "fb.h" #include "mibank.h" @@ -47,13 +47,13 @@ #include "vgaHW.h" #include "xf86RAC.h" #include "vbe.h" - +#include "dixstruct.h" #include "compiler.h" #include "mipointer.h" #include "mibstore.h" -#include "shadowfb.h" +#include "shadow.h" #include "trident.h" #include "trident_regs.h" @@ -94,12 +94,14 @@ static void TRIDENTSave(ScrnInfoPtr pScrn); static void TRIDENTRestore(ScrnInfoPtr pScrn); static Bool TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +static void TRIDENTBlockHandler(int, pointer, pointer, pointer); static void TRIDENTEnableMMIO(ScrnInfoPtr pScrn); static void TRIDENTDisableMMIO(ScrnInfoPtr pScrn); static void PC98TRIDENTInit(ScrnInfoPtr pScrn); static void PC98TRIDENTEnable(ScrnInfoPtr pScrn); static void PC98TRIDENTDisable(ScrnInfoPtr pScrn); + /* * This is intentionally screen-independent. It indicates the binding * choice made in the first PreInit. @@ -124,9 +126,6 @@ DriverRec TRIDENT = { VERSION, TRIDENT_DRIVER_NAME, -#if 0 - "accelerated driver for Trident chipsets", -#endif TRIDENTIdentify, TRIDENTProbe, TRIDENTAvailableOptions, @@ -142,7 +141,7 @@ { CYBER9397DVD, "cyber9397dvd" }, { CYBER9520, "cyber9520" }, { CYBER9525DVD, "cyber9525dvd" }, - { CYBER9540, "cyber9540" }, + { CYBERBLADEE4, "cyberblade/e4" }, { TGUI9420DGi, "tgui9420dgi" }, { TGUI9440AGi, "tgui9440agi" }, { TGUI9660, "tgui9660" }, @@ -158,6 +157,8 @@ { CYBERBLADEI7D, "cyberbladei7d" }, { CYBERBLADEI1, "cyberbladei1" }, { CYBERBLADEI1D, "cyberbladei1d" }, + { CYBERBLADEAI1, "cyberbladeAi1" }, + { CYBERBLADEAI1D, "cyberbladeAi1d" }, { -1, NULL } }; @@ -173,7 +174,7 @@ { CYBER9397DVD, PCI_CHIP_939A, RES_SHARED_VGA }, { CYBER9520, PCI_CHIP_9520, RES_SHARED_VGA }, { CYBER9525DVD, PCI_CHIP_9525, RES_SHARED_VGA }, - { CYBER9540, PCI_CHIP_9540, RES_SHARED_VGA }, + { CYBERBLADEE4, PCI_CHIP_9540, RES_SHARED_VGA }, { TGUI9420DGi, PCI_CHIP_9420, RES_SHARED_VGA }, { TGUI9440AGi, PCI_CHIP_9440, RES_SHARED_VGA }, { TGUI9660, PCI_CHIP_9660, RES_SHARED_VGA }, @@ -189,77 +190,43 @@ { CYBERBLADEI7D, PCI_CHIP_8420, RES_SHARED_VGA }, { CYBERBLADEI1, PCI_CHIP_8500, RES_SHARED_VGA }, { CYBERBLADEI1D, PCI_CHIP_8520, RES_SHARED_VGA }, + { CYBERBLADEAI1, PCI_CHIP_8600, RES_SHARED_VGA }, + { CYBERBLADEAI1D, PCI_CHIP_8620, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; typedef enum { OPTION_SW_CURSOR, - OPTION_HW_CURSOR, OPTION_PCI_RETRY, OPTION_RGB_BITS, OPTION_NOACCEL, OPTION_SETMCLK, OPTION_MUX_THRESHOLD, OPTION_SHADOW_FB, + OPTION_ROTATE, OPTION_MMIO_ONLY, -#if 0 - /* obsolete */ - OPTION_CYBER_SHADOW, -#endif + OPTION_VIDEO_KEY, OPTION_NOMMIO, - OPTION_NOPCIBURST + OPTION_NOPCIBURST, + OPTION_CYBER_SHADOW } TRIDENTOpts; static OptionInfoRec TRIDENTOptions[] = { { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SETMCLK, "SetMClk", OPTV_FREQ, {0}, FALSE }, { OPTION_MUX_THRESHOLD, "MUXThreshold", OPTV_INTEGER, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, -#if 0 - /* obsolete */ - { OPTION_CYBER_SHADOW, "CyberShadow", OPTV_BOOLEAN, {0}, FALSE }, -#endif + { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, { OPTION_NOMMIO, "NoMMIO", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NOPCIBURST, "NoPciBurst", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_MMIO_ONLY, "MMIOonly", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CYBER_SHADOW, "CyberShadow", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; -#if 0 -static int AvailablePitches[] = { - { 0 }, /* 8200LX */ - { 0 }, /* 8800CS */ - { 0 }, /* 8900B */ - { 0 }, /* 8900C */ - { 0 }, /* 8900CL */ - { 0 }, /* 8900D */ - { 0 }, /* 9000 */ - { 0 }, /* 9000i */ - { 0 }, /* 9100B */ - { 0 }, /* 9200CXr */ - { 0 }, /* 9400CXi */ - { 0 }, /* 9420 */ - { 0 }, /* 9420DGi */ - { 0 }, /* 9430DGi */ - { 512, 1024, 2048, 4096 }, /* 9440AGi */ - { 512, 640, 800, 1024, 1280, 2048, 4096 }, /* 9320 */ - { 512, 640, 832, 1024, 1280, 2048, 4096 }, /* 9660 */ - { 512, 640, 800, 1024, 1280, 2048, 4096 }, /* 9680 */ - { 512, 640, 800, 832, 1024, 1280, 1600, 2048, 4096 }, /* 9682 */ - { 512, 640, 800, 832, 1024, 1280, 1600, 2048, 4096 }, /* 9685 */ - { 512, 640, 800, 832, 1024, 1280, 1600, 2048, 4096 }, /* 9685 */ - { 512, 640, 800, 832, 1024, 1280, 1600, 2048, 4096 }, /* 9685 */ - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, -}; -#endif - /* Clock Limits */ static int ClockLimit[] = { 80000, @@ -286,6 +253,10 @@ 135000, 170000, 170000, + 170000, + 230000, + 230000, + 230000, 230000, 230000, 230000, @@ -294,6 +265,7 @@ 230000, 230000, 230000, + 230000, }; static int ClockLimit16bpp[] = { @@ -321,6 +293,11 @@ 135000, 170000, 170000, + 170000, + 230000, + 230000, + 230000, + 230000, 230000, 230000, 230000, @@ -356,6 +333,9 @@ 70000, 85000, 85000, + 85000, + 115000, + 115000, 115000, 115000, 115000, @@ -364,6 +344,8 @@ 115000, 115000, 115000, + 115000, + 115000, }; static int ClockLimit32bpp[] = { @@ -392,6 +374,10 @@ 85000, 85000, 115000, + 85000, + 115000, + 115000, + 115000, 115000, 115000, 115000, @@ -399,23 +385,35 @@ 115000, 115000, 115000, + 115000, + 115000, }; /* * These are fixed modelines for all physical display dimensions the * chipsets supports on FPs. Most of them are not tested yet. */ +#if 0 +tridentLCD LCD[] = { /* 0 3 4 5 6 7 10 11 16 */ + { 0,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb,0x08}, + { 1,"800x600",40000,0x7f,0x99,0x69,0x99,0x72,0xf0,0x59,0x2d,0x5e,0x08}, + { 2,"1024x768",65000,0xa3,/*0x6*/ 0x98,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, + { 3,"1024x768",65000,0xa3,/*0x6*/ 0x98,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, /*0x96*/ + { 4,"1280x1024",108000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96,0x08}, + { 5,"1024x600",50500 ,0xa3,0x6,0x8f,0xa0,0xb,0x3e,0xea,0x8c,0xb,0x08}, + { 0xff,"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; +#else tridentLCD LCD[] = { - { 0,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb}, - { 1,"800x600",40000,0x7f,0x82,0x6b,0x1b,0x72,0xf8,0x58,0x8c,0x72}, - { 2,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96}, - { 3,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96}, - { 4,"1280x1024",108000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96}, - { 5,"1024x600",50500 ,0xa3,0x6,0x8f,0xa0,0xb,0x3e,0xea,0x8c,0xb}, + { 1,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb,0x08}, + { 3,"800x600",40000,0x7f,0x82,0x6b,0x1b,0x72,0xf8,0x58,0x8c,0x72,0x08}, + { 2,"1024x768",65000,0xa3,/*0x6*/0x98,0x8f,0xa0,0x24,0xf5,0x0f,0x24,0x0a,0x08}, + { 0,"1280x1024",108000,0xce,0x81,0xa6,0x9a,0x27,0x50,0x00,0x03,0x26,0xa8}, { 0xff,"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; +#endif - static const char *xaaSymbols[] = { +static const char *xaaSymbols[] = { "XAADestroyInfoRec", "XAACreateInfoRec", "XAAHelpPatternROP", @@ -445,7 +443,11 @@ static const char *fbSymbols[] = { "fbScreenInit", - "cfb24_32ScreenInit", +#ifdef RENDER + "fbPictureInit", +#endif + "xf1bppScreenInit", + "xf4bppScreenInit", NULL }; @@ -462,7 +464,7 @@ }; static const char *shadowSymbols[] = { - "ShadowFBInit", + "shadowInit", NULL }; @@ -544,6 +546,9 @@ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); CARD8 DPMSCont, PMCont, temp; + if (!pScrn->vtSema) + return; + OUTB(0x3C4, 0x0E); temp = INB(0x3C5); OUTB(0x3C5, 0xC2); @@ -581,6 +586,27 @@ } #endif +static void +TRIDENTBlockHandler ( + int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask +){ + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + pScreen->BlockHandler = pTrident->BlockHandler; + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + pScreen->BlockHandler = TRIDENTBlockHandler; + + if(pTrident->VideoTimerCallback) { + UpdateCurrentTime(); + (*pTrident->VideoTimerCallback)(pScrn, currentTime.milliseconds); + } +} + static OptionInfoPtr TRIDENTAvailableOptions(int chipid, int busid) @@ -804,7 +830,7 @@ TRIDENTProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips = NULL; int numDevSections; int numUsed; @@ -864,6 +890,7 @@ foundScreen = TRUE; } } + xfree(usedChips); } } @@ -898,8 +925,7 @@ xfree(usedChips); } - if (devSections) - xfree(devSections); + xfree(devSections); return foundScreen; } @@ -937,34 +963,7 @@ return linePitches; } -void -TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) -{ - TRIDENTPtr pTrident = TRIDENTPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; - - Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); - - while(num--) { - width = (pbox->x2 - pbox->x1) * Bpp; - height = pbox->y2 - pbox->y1; - src = pTrident->ShadowPtr + (pbox->y1 * pTrident->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pTrident->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - - while(height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pTrident->ShadowPitch; - } - - pbox++; - } -} - -void +static void TRIDENTProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -992,7 +991,8 @@ char *mod = NULL; const char *Sym = ""; Bool ddcLoaded = FALSE; - + char *s; + /* Allocate the TRIDENTRec driverPrivate */ if (!TRIDENTGetRec(pScrn)) { return FALSE; @@ -1043,9 +1043,29 @@ case 1: case 4: case 8: + if (pScrn->bitsPerPixel != pScrn->depth) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d)/ fbbpp (%d) is not supported by this driver\n", + pScrn->depth, pScrn->bitsPerPixel); + return FALSE; + } + break; case 15: case 16: + if (pScrn->bitsPerPixel != 16) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d)/ fbbpp (%d) is not supported by this driver\n", + pScrn->depth, pScrn->bitsPerPixel); + return FALSE; + } + break; case 24: + if ((pScrn->bitsPerPixel != 24) && (pScrn->bitsPerPixel != 32)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d)/ fbbpp (%d) is not supported by this driver\n", + pScrn->depth, pScrn->bitsPerPixel); + return FALSE; + } /* OK */ break; default: @@ -1149,8 +1169,6 @@ } from = X_DEFAULT; pTrident->HWCursor = TRUE; - if (xf86GetOptValBool(TRIDENTOptions, OPTION_HW_CURSOR, &pTrident->HWCursor)) - from = X_CONFIG; if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_SW_CURSOR, FALSE)) { from = X_CONFIG; pTrident->HWCursor = FALSE; @@ -1170,14 +1188,16 @@ pTrident->UsePCIBurst = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI Burst disbled\n"); } -#if 0 - /* obsolete */ - if ((pTrident->CyberShadowSet = xf86GetOptValBool(TRIDENTOptions, - OPTION_CYBER_SHADOW, - &pTrident->CyberShadow))) - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Cyber Shadow Registers %s\n", - pTrident->CyberShadow?"enabled":"disabled"); -#endif + if(xf86GetOptValInteger(TRIDENTOptions, OPTION_VIDEO_KEY, + &(pTrident->videoKey))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", + pTrident->videoKey); + } else { + pTrident->videoKey = (1 << pScrn->offset.red) | + (1 << pScrn->offset.green) | + (((pScrn->mask.blue >> pScrn->offset.blue) - 1) + << pScrn->offset.blue); + } if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_NOMMIO, FALSE)) { pTrident->NoMMIO = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MMIO Disabled\n"); @@ -1191,40 +1211,67 @@ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MMIO Disabled\n"); } } + if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_CYBER_SHADOW, FALSE)) { + pTrident->CyberShadow = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Cyber Shadow enabled\n"); + } - pTrident->MUXThreshold = 80000; /* 100MHz */ + pTrident->MUXThreshold = 160000; /* 160MHz */ if (xf86GetOptValInteger(TRIDENTOptions, OPTION_MUX_THRESHOLD, &pTrident->MUXThreshold)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MUX Threshold set to %d\n", pTrident->MUXThreshold); } if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_SHADOW_FB, FALSE)) { - pTrident->ShadowFB = TRUE; - pTrident->NoAccel = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using \"Shadow Framebuffer\" - acceleration disabled\n"); + if (!pTrident->Linear) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring Option SHADOW_FB" + " in non-Linear Mode\n"); + else if (pScrn->depth < 8) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Tgnoring Option SHADOW_FB" + " when depth < 8"); + else { + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using \"Shadow Framebuffer\" - acceleration disabled\n"); + } + } + pTrident->Rotate = 0; + if ((s = xf86GetOptValString(TRIDENTOptions, OPTION_ROTATE))) { + if (!pTrident->Linear) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring Option ROTATE " + "in non-Linear Mode\n"); + else if (pScrn->depth < 8) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Tgnoring Option ROTATE " + "when depth < 8"); + else { + if(!xf86NameCmp(s, "CW")) { + /* accel is disabled below for shadowFB */ + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + pTrident->HWCursor = FALSE; + pTrident->Rotate = 1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Rotating screen clockwise - acceleration disabled\n"); + } else if(!xf86NameCmp(s, "CCW")) { + pTrident->ShadowFB = TRUE; + pTrident->NoAccel = TRUE; + pTrident->HWCursor = FALSE; + pTrident->Rotate = -1; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen" + "counter clockwise - acceleration disabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid" + "value for Option \"Rotate\"\n", s); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Valid options are \"CW\" or \"CCW\"\n"); + } + } } /* FIXME ACCELERATION */ if (!UseMMIO) pTrident->NoAccel = TRUE; -#if 0 - /* - * This shouldn't happen because such problems should be caught in - * TRIDENTProbe(), but check it just in case. - */ - if (pScrn->chipset == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "ChipID 0x%04X is not recognised\n", pTrident->Chipset); - return FALSE; - } - if (pTrident->Chipset < 0) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Chipset \"%s\" is not recognised\n", pScrn->chipset); - return FALSE; - } -#endif - if (pTrident->Linear) { if (pTrident->pEnt->device->MemBase != 0) { /* @@ -1311,7 +1358,6 @@ pScrn->progClock = TRUE; pTrident->EngineOperation = 0x00; - pTrident->UseGERetry = FALSE; pTrident->IsCyber = FALSE; pTrident->HasSGRAM = FALSE; pTrident->NewClockCode = FALSE; @@ -1537,19 +1583,12 @@ chipset = "Cyber 9525/DVD"; pTrident->NewClockCode = TRUE; break; - case CYBER9540: + case CYBERBLADEE4: pTrident->ddc1Read = Tridentddc1Read; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x04) - ramtype = "EDO Ram"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x08) - ramtype = "SDRAM"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) { - pTrident->HasSGRAM = TRUE; - ramtype = "SGRAM"; - } + ramtype = "SDRAM"; pTrident->IsCyber = TRUE; Support24bpp = TRUE; - chipset = "Cyber 9540"; + chipset = "CyberBlade e4/128"; pTrident->NewClockCode = TRUE; break; case IMAGE975: @@ -1595,12 +1634,7 @@ break; case CYBERBLADEI7: pTrident->ddc1Read = Tridentddc1Read; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x08) - ramtype = "SDRAM"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) { - pTrident->HasSGRAM = TRUE; - ramtype = "SGRAM"; - } + ramtype = "SDRAM"; pTrident->IsCyber = TRUE; Support24bpp = TRUE; chipset = "CyberBlade/i7"; @@ -1609,12 +1643,7 @@ break; case CYBERBLADEI7D: pTrident->ddc1Read = Tridentddc1Read; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x08) - ramtype = "SDRAM"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) { - pTrident->HasSGRAM = TRUE; - ramtype = "SGRAM"; - } + ramtype = "SDRAM"; pTrident->IsCyber = TRUE; Support24bpp = TRUE; chipset = "CyberBlade/DSTN/i7"; @@ -1623,12 +1652,7 @@ break; case CYBERBLADEI1: pTrident->ddc1Read = Tridentddc1Read; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x08) - ramtype = "SDRAM"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) { - pTrident->HasSGRAM = TRUE; - ramtype = "SGRAM"; - } + ramtype = "SDRAM"; pTrident->IsCyber = TRUE; Support24bpp = TRUE; chipset = "CyberBlade/i1"; @@ -1637,18 +1661,31 @@ break; case CYBERBLADEI1D: pTrident->ddc1Read = Tridentddc1Read; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x08) - ramtype = "SDRAM"; - if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) { - pTrident->HasSGRAM = TRUE; - ramtype = "SGRAM"; - } + ramtype = "SDRAM"; pTrident->IsCyber = TRUE; Support24bpp = TRUE; chipset = "CyberBlade/DSTN/i1"; pTrident->NewClockCode = TRUE; pTrident->frequency = NTSC; break; + case CYBERBLADEAI1: + pTrident->ddc1Read = Tridentddc1Read; + ramtype = "SDRAM"; + pTrident->IsCyber = TRUE; + Support24bpp = TRUE; + chipset = "CyberBlade/Ai1"; + pTrident->NewClockCode = TRUE; + pTrident->frequency = NTSC; + break; + case CYBERBLADEAI1D: + pTrident->ddc1Read = Tridentddc1Read; + ramtype = "SDRAM"; + pTrident->IsCyber = TRUE; + Support24bpp = TRUE; + chipset = "CyberBlade/DSTN/Ai1"; + pTrident->NewClockCode = TRUE; + pTrident->frequency = NTSC; + break; } if (!pScrn->progClock) { @@ -1703,9 +1740,13 @@ case 0x04: /* 8MB, but - hw cursor can't store above 4MB */ /* So, we force to 4MB for now */ /* pScrn->videoRam = 8192; */ + + if (pTrident->HWCursor) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Found 8MB board, using 4MB\n"); + "Found 8MB board, using 4MB\n"); pScrn->videoRam = 4096; + } else + pScrn->videoRam = 8192; break; case 0x07: pScrn->videoRam = 2048; @@ -1728,16 +1769,22 @@ pScrn->videoRam); if (pTrident->IsCyber) { - unsigned char tmp; + unsigned char mod, dsp, dsp1; pTrident->lcdMode = 0xff; - OUTB(0x3CE,0x41); - tmp = INB(0x3CF); + + OUTB(0x3CE,0x42); + dsp = INB(0x3CF); + OUTB(0x3CE,0x43); + dsp1 = INB(0x3CF); + OUTB(0x3CE,0x52); + mod = INB(0x3CF); for (i = 0; LCD[i].mode != 0xff; i++) { - if (LCD[i].mode == (tmp & 0x7)) { + if (LCD[i].mode == ((mod >> 4) & 3)) { pTrident->lcdMode = i; xf86DrvMsg(pScrn->scrnIndex, X_PROBED,"%s Panel %s found\n", - (tmp & 0x8) ? "DSTN" : "TFT", LCD[i].display); + (dsp & 0x80) ? "TFT" : + ((dsp1 & 0x20) ? "DSTN" : "STN"), LCD[i].display); } } } @@ -1896,7 +1943,15 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: + pTrident->EngineOperation |= 0x00; + mod = "xf1bpp"; + Sym = "xf1bppScreenInit"; + break; case 4: + pTrident->EngineOperation |= 0x00; + mod = "xf4bpp"; + Sym = "xf4bppScreenInit"; + break; case 8: pTrident->EngineOperation |= 0x00; mod = "fb"; @@ -1909,13 +1964,8 @@ break; case 24: pTrident->EngineOperation |= 0x03; - if (pix24bpp == 24) { - mod = "fb"; - Sym = "fbScreenInit"; - } else { - mod = "xf24_32bpp"; - Sym = "cfb24_32ScreenInit"; - } + mod = "fb"; + Sym = "fbScreenInit"; break; case 32: pTrident->EngineOperation |= 0x02; @@ -1934,6 +1984,10 @@ } xf86LoaderReqSymbols(Sym, NULL); +#ifdef RENDER + if (pScrn->depth > 8) + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif if (!xf86LoadSubModule(pScrn, "i2c")) { if (IsPciCard && UseMMIO) { @@ -1946,9 +2000,9 @@ xf86LoaderReqSymLists(i2cSymbols, NULL); - /* Load shadowfb if needed */ + /* Load shadow if needed */ if (pTrident->ShadowFB) { - if (!xf86LoadSubModule(pScrn, "shadowfb")) { + if (!xf86LoadSubModule(pScrn, "shadow")) { TRIDENTFreeRec(pScrn); return FALSE; } @@ -2123,9 +2177,11 @@ vgaRegPtr vgaReg; TRIDENTPtr pTrident = TRIDENTPTR(pScrn); TRIDENTRegPtr tridentReg; + int clock; + + TridentFindClock(pScrn,mode->Clock); - if (mode->Clock > pTrident->MUXThreshold) pTrident->MUX = TRUE; - else pTrident->MUX = FALSE; + clock = pTrident->currentClock; switch (pTrident->Chipset) { case TGUI9660: @@ -2139,9 +2195,11 @@ case CYBERBLADEI7D: case CYBERBLADEI1: case CYBERBLADEI1D: + case CYBERBLADEAI1: + case CYBERBLADEAI1D: case CYBER9520: case CYBER9525DVD: - case CYBER9540: + case CYBERBLADEE4: case CYBER9397: case CYBER9397DVD: /* Get ready for MUX mode */ @@ -2159,6 +2217,10 @@ break; } + /* Calculate skew offsets for video overlay */ + pTrident->hsync = (mode->CrtcHTotal - mode->CrtcHSyncStart) - 23; + pTrident->vsync = (mode->CrtcVTotal - mode->CrtcVSyncStart) - 4; + vgaHWUnlock(hwp); /* Initialise the ModeReg values */ @@ -2200,6 +2262,18 @@ return TRUE; } +#if 0 +Bool +TridentCyberBIOSModeInit(ScrnInfoPtr pScrn) +{ + int mode = TridentFindMode(pScrn->currentMode->HDisplay, + pScrn->currentMode->VDisplay, + pScrn->depth); + TridentUnstretch(); + +} +#endif + /* * Restore the initial (text) mode. */ @@ -2244,6 +2318,7 @@ int ret; VisualPtr visual; unsigned char *FBStart; + int width, height, displayWidth; /* * First get the ScrnInfoRec @@ -2302,27 +2377,27 @@ /* Setup the visuals we support. */ - /* - * For bpp > 8, the default visuals are not acceptable because we only - * support TrueColor and not DirectColor. - */ + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; - if (pScrn->bitsPerPixel > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; + miSetPixmapDepths (); + + /* FIXME - we don't do shadowfb for < 4 */ + displayWidth = pScrn->displayWidth; + if (pTrident->Rotate) { + height = pScrn->virtualX; + width = pScrn->virtualY; } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; + width = pScrn->virtualX; + height = pScrn->virtualY; } - /* FIXME - we don't do shadowfb for < 4 */ - if(pTrident->ShadowFB && (pScrn->bitsPerPixel >= 8)) { - pTrident->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * pScrn->virtualX); - pTrident->ShadowPtr = xalloc(pTrident->ShadowPitch * pScrn->virtualY); - pScrn->displayWidth = pTrident->ShadowPitch / (pScrn->bitsPerPixel >> 3); + if(pTrident->ShadowFB) { + pTrident->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width); + pTrident->ShadowPtr = xalloc(pTrident->ShadowPitch * height); + displayWidth = pTrident->ShadowPitch / (pScrn->bitsPerPixel >> 3); FBStart = pTrident->ShadowPtr; } else { pTrident->ShadowFB = FALSE; @@ -2337,23 +2412,27 @@ switch (pScrn->bitsPerPixel) { case 1: + ret = xf1bppScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth); + break; case 4: + ret = xf4bppScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth); + break; case 8: case 16: - case 32: - ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth, pScrn->bitsPerPixel); - break; case 24: - if (pix24bpp == 24) - ret = fbScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth, pScrn->bitsPerPixel); - else - ret = cfb24_32ScreenInit(pScreen, FBStart, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); + case 32: + ret = fbScreenInit(pScreen, FBStart, width, + height, pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit (pScreen, 0, 0); +#endif + break; default: xf86DrvMsg(scrnIndex, X_ERROR, @@ -2386,6 +2465,9 @@ xf86SetBlackWhitePixels(pScreen); + pTrident->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = TRIDENTBlockHandler; + if (!pTrident->ShadowFB) TRIDENTDGAInit(pScreen); @@ -2422,6 +2504,9 @@ (pTrident->Chipset == CYBERBLADEI7D) || (pTrident->Chipset == CYBERBLADEI1) || (pTrident->Chipset == CYBERBLADEI1D) || + (pTrident->Chipset == CYBERBLADEAI1) || + (pTrident->Chipset == CYBERBLADEAI1D) || + (pTrident->Chipset == CYBERBLADEE4) || (pTrident->Chipset == BLADE3D)) BladeAccelInit(pScreen); else @@ -2441,8 +2526,8 @@ pTrident->HWCursor = FALSE; if (pTrident->HWCursor) { - TridentHWCursorInit(pScreen); xf86SetSilkenMouse(pScreen); + TridentHWCursorInit(pScreen); } /* Initialise default colourmap */ @@ -2454,8 +2539,36 @@ return FALSE; if(pTrident->ShadowFB) { - RefreshAreaFuncPtr refreshArea = TRIDENTRefreshArea; - ShadowFBInit(pScreen, refreshArea); + if(pTrident->Rotate) { + if (!pTrident->PointerMoved) { + pTrident->PointerMoved = pScrn->PointerMoved; + pScrn->PointerMoved = TRIDENTPointerMoved; + } + switch (pScrn->bitsPerPixel) { +#if 1 + case 8: pTrident->RefreshArea = TRIDENTRefreshArea8; break; + case 16: pTrident->RefreshArea = TRIDENTRefreshArea16; break; + case 24: pTrident->RefreshArea = TRIDENTRefreshArea24; break; + case 32: pTrident->RefreshArea = TRIDENTRefreshArea32; break; +#else + case 8: shadowInit (pScreen, shadowUpdateRotate8, 0); break; + case 16: shadowInit (pScreen, shadowUpdateRotate16, 0); break; + case 24: shadowInit (pScreen, shadowUpdateRotate32, 0); break; +#endif + } + } else { + pTrident->RefreshArea = TRIDENTRefreshArea; +#if 0 + shadowInit (pScreen, shadowUpdatePacked, 0); +#endif + } +#if 1 +#if 0 + ShadowFBInit(pScreen, pTrident->RefreshArea); +#else + shadowInit (pScreen, TRIDENTShadowUpdate, 0); +#endif +#endif } #ifdef DPMSExtension @@ -2466,17 +2579,13 @@ pScrn->fbOffset = 0; #ifdef XvExtension - { - XF86VideoAdaptorPtr *ptr; - int n; - - n = xf86XVListGenericAdaptors(pScrn,&ptr); - if (n) { - xf86XVScreenInit(pScreen, ptr, n); - } - } + if (pTrident->Chipset >= CYBER9397) + TRIDENTInitVideo(pScreen); #endif + if(pTrident->BlockHandler) + pScreen->BlockHandler = pTrident->BlockHandler; + pTrident->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = TRIDENTCloseScreen; pScreen->SaveScreen = TRIDENTSaveScreen; @@ -2571,6 +2680,9 @@ /* Should we re-save the text mode on each VT enter? */ if (!TRIDENTModeInit(pScrn, pScrn->currentMode)) return FALSE; + + if (pTrident->InitializeAccelerator) + pTrident->InitializeAccelerator(pScrn); return TRUE; } Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h:1.12 xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h:1.18 --- xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h:1.12 Tue Jun 6 14:07:37 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h Thu Dec 7 14:03:40 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1992-1998 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -21,7 +21,7 @@ * * Author: Alan Hourihane, alanh@fairlite.demon.co.uk */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h,v 1.12 2000/06/06 18:07:37 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h,v 1.18 2000/12/07 19:03:40 alanh Exp $ */ #define DEBUG 1 @@ -53,6 +53,7 @@ #define FIFOControl 0x20 #define LinearAddReg 0x21 #define DRAMTiming 0x23 +#define New32 0x23 #define RAMDACTiming 0x25 #define CRTHiOrd 0x27 #define AddColReg 0x29 @@ -83,14 +84,14 @@ #define CursorBG4 0x4F #define CursorControl 0x50 #define PCIRetry 0x55 +#define PreEndControl 0x56 +#define PreEndFetch 0x57 #define PCIMaster 0x60 #define Enhancement0 0x62 #define NewEDO 0x64 #define TVinterface 0xC0 #define TVMode 0xC1 #define ClockControl 0xCF -#define PreEndControl 0x56 -#define PreEndFetch 0x57 /* 3CE */ @@ -98,7 +99,7 @@ #define MiscIntContReg 0x2F #define CyberControl 0x30 #define CyberEnhance 0x31 -#define FPConfig 0x34 +#define FPConfig 0x33 #define VertStretch 0x52 #define HorStretch 0x53 #define BiosMode 0x5c @@ -324,7 +325,7 @@ #define IMAGEBUSY(b) \ (b = MMIO_IN32(pTrident->IOBase,IMAGE_GE_STATUS) & 0xF0000000) #define BLADEBUSY(b) \ - (b = MMIO_IN32(pTrident->IOBase,BLADE_GE_STATUS) & 0xFE800000) + (b = MMIO_IN32(pTrident->IOBase,BLADE_GE_STATUS) & 0xFA800000) #define IMAGE_OUT(addr, c) \ MMIO_OUT32(pTrident->IOBase, addr, (c)) #define BLADE_OUT(addr, c) \ Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c:1.2 --- /dev/null Mon Dec 18 14:31:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c Thu Nov 16 14:45:01 2000 @@ -0,0 +1,259 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_shadow.c,v 1.2 2000/11/16 19:45:01 eich Exp $ */ + +/* + Copyright (c) 1999, 2000 The XFree86 Project Inc. + based on code written by Mark Vojkovich <markv@valinux.com> +*/ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "shadowfb.h" +#include "servermd.h" +#include "trident.h" + +void +TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; + + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + + while(num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pTrident->ShadowPtr + (pbox->y1 * pTrident->ShadowPitch) + + (pbox->x1 * Bpp); + dst = pTrident->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pTrident->ShadowPitch; + } + + pbox++; + } +} + +void +TRIDENTShadowUpdate (ScreenPtr pScreen, PixmapPtr pShadow, RegionPtr damage) +{ + ScrnInfoPtr pScrn; + pScrn = xf86Screens[pScreen->myNum]; + + (TRIDENTPTR(pScrn))->RefreshArea (pScrn, REGION_NUM_RECTS(damage), + REGION_RECTS(damage)); +} + +void +TRIDENTPointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int newX, newY; + + if(pTrident->Rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + + (*pTrident->PointerMoved)(index, newX, newY); +} + +void +TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pTrident->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pTrident->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch * 2] << 16) | + (src[srcPitch * 3] << 24); + src += srcPitch * 4; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +void +TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch >> 1; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = (CARD16*)pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16*)pTrident->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16*)pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16*)pTrident->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch * 2; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +/* this one could be faster */ +void +TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(pTrident->Rotate == 1) { + dstPtr = pTrident->FbBase + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pTrident->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pTrident->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch * 2] << 16) | + (src[(srcPitch * 2) + 1] << 24); + dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | + (src[(srcPitch * 3) + 1] << 16) | + (src[(srcPitch * 3) + 2] << 24); + dst += 3; + src += srcPitch * 4; + } + srcPtr += pTrident->Rotate * 3; + dstPtr += dstPitch; + } + + pbox++; + } +} + +void +TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -pTrident->Rotate * pTrident->ShadowPitch >> 2; + + while(num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(pTrident->Rotate == 1) { + dstPtr = (CARD32*)pTrident->FbBase + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32*)pTrident->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32*)pTrident->FbBase + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32*)pTrident->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pTrident->Rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + Index: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/trident/trident_video.c:1.2 --- /dev/null Mon Dec 18 14:31:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/trident_video.c Thu Dec 14 14:29:44 2000 @@ -0,0 +1,1127 @@ +/* + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Alan Hourihane, alanh@fairlite.demon.co.uk + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_video.c,v 1.2 2000/12/14 19:29:44 dawes Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86_ansic.h" +#include "compiler.h" +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#include "xf86fbman.h" +#include "regionstr.h" + +#include "trident.h" +#include "trident_regs.h" +#include "Xv.h" +#include "xaa.h" +#include "xaalocal.h" +#include "dixstruct.h" +#include "fourcc.h" + +#define OFF_DELAY 200 /* milliseconds */ +#define FREE_DELAY 60000 + +#define OFF_TIMER 0x01 +#define FREE_TIMER 0x02 +#define CLIENT_VIDEO_ON 0x04 + +#define TIMER_MASK (OFF_TIMER | FREE_TIMER) + +#ifndef XvExtension +void TRIDENTInitVideo(ScreenPtr pScreen) {} +void TRIDENTResetVideo(ScrnInfoPtr pScrn) {} +#else + +static XF86VideoAdaptorPtr TRIDENTSetupImageVideo(ScreenPtr); +static void TRIDENTInitOffscreenImages(ScreenPtr); +static void TRIDENTStopVideo(ScrnInfoPtr, pointer, Bool); +static int TRIDENTSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int TRIDENTGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +static void TRIDENTQueryBestSize(ScrnInfoPtr, Bool, + short, short, short, short, unsigned int *, unsigned int *, pointer); +static int TRIDENTPutImage( ScrnInfoPtr, + short, short, short, short, short, short, short, short, + int, unsigned char*, short, short, Bool, RegionPtr, pointer); +static int TRIDENTQueryImageAttributes(ScrnInfoPtr, + int, unsigned short *, unsigned short *, int *, int *); +static void TRIDENTVideoTimerCallback(ScrnInfoPtr pScrn, Time time); + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvColorKey; + +void TRIDENTInitVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; + XF86VideoAdaptorPtr newAdaptor = NULL; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int num_adaptors; + + if (!pTrident->NoAccel) { + newAdaptor = TRIDENTSetupImageVideo(pScreen); + TRIDENTInitOffscreenImages(pScreen); + } + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if(newAdaptor) { + if(!num_adaptors) { + num_adaptors = 1; + adaptors = &newAdaptor; + } else { + newAdaptors = /* need to free this someplace */ + xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); + if(newAdaptors) { + memcpy(newAdaptors, adaptors, num_adaptors * + sizeof(XF86VideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + xf86XVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); +} + +/* client libraries expect an encoding */ +static XF86VideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + 1024, 1024, + {1, 1} + } +}; + +#define NUM_FORMATS 4 + +static XF86VideoFormatRec Formats[NUM_FORMATS] = +{ + {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor} +}; + +#define NUM_ATTRIBUTES 1 + +static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"} +}; + +#define NUM_IMAGES 4 + +static XF86ImageRec Images[NUM_IMAGES] = +{ + { + 0x35315652, + XvRGB, + LSBFirst, + {'R','V','1','5', + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + 16, + XvPacked, + 1, + 15, 0x001F, 0x03E0, 0x7C00, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + {'R','V','B',0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + }, + { + 0x36315652, + XvRGB, + LSBFirst, + {'R','V','1','6', + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, + 16, + XvPacked, + 1, + 16, 0x001F, 0x07E0, 0xF800, + 0, 0, 0, + 0, 0, 0, + 0, 0, 0, + {'R','V','B',0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + XvTopToBottom + }, + XVIMAGE_YV12, + XVIMAGE_YUY2 +}; + +typedef struct { + FBLinearPtr linear; + RegionRec clip; + CARD32 colorKey; + CARD32 videoStatus; + Time offTime; + Time freeTime; +} TRIDENTPortPrivRec, *TRIDENTPortPrivPtr; + + +#define GET_PORT_PRIVATE(pScrn) \ + (TRIDENTPortPrivPtr)((TRIDENTPTR(pScrn))->adaptor->pPortPrivates[0].ptr) + +void TRIDENTResetVideo(ScrnInfoPtr pScrn) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + TRIDENTPortPrivPtr pPriv = pTrident->adaptor->pPortPrivates[0].ptr; + int vgaIOBase = VGAHWPTR(pScrn)->IOBase; + int red, green, blue; + int tmp; + + OUTW(vgaIOBase + 4, 0x008E); + OUTW(vgaIOBase + 4, 0x008F); + + OUTW(vgaIOBase + 4, 0x80B9); + + OUTW(0x3C4, 0x3037); + OUTW(0x3C4, 0xC057); + OUTW(0x3C4, 0x3420); + + switch (pScrn->depth) { + case 8: + OUTW(0x3C4, (pPriv->colorKey<<8) | 0x50); + OUTW(0x3C4, 0x0051); + OUTW(0x3C4, 0x0052); + OUTW(0x3C4, 0xFF54); + OUTW(0x3C4, 0x0055); + OUTW(0x3C4, 0x0056); + break; + default: + red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red; + green = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green; + blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue; + switch (pScrn->depth) { + case 15: + tmp = (red << 11) | (green << 6) | (blue); + OUTW(0x3C4, (tmp & 0xff) << 8 | 0x50); + OUTW(0x3C4, (tmp & 0xff00) | 0x51); + OUTW(0x3C4, 0x0052); + OUTW(0x3C4, 0xFF54); + OUTW(0x3C4, 0xFF55); + OUTW(0x3C4, 0x0056); + break; + case 16: + tmp = (red << 11) | (green << 5) | (blue); + OUTW(0x3C4, (tmp & 0xff) << 8 | 0x50); + OUTW(0x3C4, (tmp & 0xff00) | 0x51); + OUTW(0x3C4, 0x0052); + OUTW(0x3C4, 0xFF54); + OUTW(0x3C4, 0xFF55); + OUTW(0x3C4, 0x0056); + break; + case 24: + OUTW(0x3C4, (red<<8) | 0x50); + OUTW(0x3C4, (green<<8) | 0x51); + OUTW(0x3C4, (blue<<8) | 0x52); + OUTW(0x3C4, 0xFF54); + OUTW(0x3C4, 0xFF55); + OUTW(0x3C4, 0xFF56); + break; + } + } +} + + +static XF86VideoAdaptorPtr +TRIDENTSetupImageVideo(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + XF86VideoAdaptorPtr adapt; + TRIDENTPortPrivPtr pPriv; + + if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(TRIDENTPortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "Trident Backend Scaler"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + pPriv = (TRIDENTPortPrivPtr)(&adapt->pPortPrivates[1]); + adapt->pPortPrivates[0].ptr = (pointer)(pPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = TRIDENTStopVideo; + adapt->SetPortAttribute = TRIDENTSetPortAttribute; + adapt->GetPortAttribute = TRIDENTGetPortAttribute; + adapt->QueryBestSize = TRIDENTQueryBestSize; + adapt->PutImage = TRIDENTPutImage; + adapt->QueryImageAttributes = TRIDENTQueryImageAttributes; + + if ((pScrn->depth == 15) || (pScrn->depth == 24)) + pPriv->colorKey = 0; /* FIXME */ + else + pPriv->colorKey = pTrident->videoKey; + pPriv->videoStatus = 0; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + + pTrident->adaptor = adapt; + + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + TRIDENTResetVideo(pScrn); + + return adapt; +} + + +static Bool +RegionsEqual(RegionPtr A, RegionPtr B) +{ + int *dataA, *dataB; + int num; + + num = REGION_NUM_RECTS(A); + if(num != REGION_NUM_RECTS(B)) + return FALSE; + + if((A->extents.x1 != B->extents.x1) || + (A->extents.x2 != B->extents.x2) || + (A->extents.y1 != B->extents.y1) || + (A->extents.y2 != B->extents.y2)) + return FALSE; + + dataA = (int*)REGION_RECTS(A); + dataB = (int*)REGION_RECTS(B); + + while(num--) { + if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + return FALSE; + dataA += 2; + dataB += 2; + } + + return TRUE; +} + +/* TRIDENTClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (x1, y1 + inclusive, x2, y2 exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +#define DummyScreen screenInfo.screens[0] + +static Bool +TRIDENTClipVideo( + BoxPtr dst, + INT32 *x1, + INT32 *x2, + INT32 *y1, + INT32 *y2, + RegionPtr reg, + INT32 width, + INT32 height +){ + INT32 vscale, hscale, delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *x2 <<= 16; + *y1 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *x2 -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if(*x1 < 0) { + diff = (- *x1 + hscale - 1)/ hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + delta = *x2 - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + if(*x1 >= *x2) return FALSE; + + if(*y1 < 0) { + diff = (- *y1 + vscale - 1)/ vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + delta = *y2 - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } + if(*y1 >= *y2) return FALSE; + + if((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || + (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) + { + RegionRec clipReg; + REGION_INIT(DummyScreen, &clipReg, dst, 1); + REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); + REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; +} + + +static void +TRIDENTStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + TRIDENTPortPrivPtr pPriv = (TRIDENTPortPrivPtr)data; + int vgaIOBase = VGAHWPTR(pScrn)->IOBase; + + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + + if(exit) { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + OUTW(vgaIOBase + 4, 0x008E); + OUTW(vgaIOBase + 4, 0x008F); + } + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + } else { + if(pPriv->videoStatus & CLIENT_VIDEO_ON) { + pPriv->videoStatus |= OFF_TIMER; + pPriv->offTime = currentTime.milliseconds + OFF_DELAY; + } + } +} + +static int +TRIDENTSetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value, + pointer data +){ + TRIDENTPortPrivPtr pPriv = (TRIDENTPortPrivPtr)data; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + if(attribute == xvColorKey) { + int red, green, blue; + int tmp; + pPriv->colorKey = value; + switch (pScrn->depth) { + case 8: + OUTW(0x3C4, (pPriv->colorKey<<8) | 0x50); + OUTW(0x3C4, 0x0051); + OUTW(0x3C4, 0x0052); + break; + default: + red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red; + green = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green; + blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue; + switch (pScrn->depth) { + case 15: + tmp = (red << 11) | (green << 6) | (blue); + OUTW(0x3C4, (tmp&0xff)<<8 | 0x50); + OUTW(0x3C4, (tmp&0xff00) | 0x51); + OUTW(0x3C4, 0x0052); + break; + case 16: + tmp = (red << 11) | (green << 5) | (blue); + OUTW(0x3C4, (tmp&0xff)<<8 | 0x50); + OUTW(0x3C4, (tmp&0xff00) | 0x51); + OUTW(0x3C4, 0x0052); + break; + case 24: + OUTW(0x3C4, (red<<8) | 0x50); + OUTW(0x3C4, (green<<8) | 0x51); + OUTW(0x3C4, (blue<<8) | 0x52); + break; + } + } + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + } else return BadMatch; + + return Success; +} + +static int +TRIDENTGetPortAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value, + pointer data +){ + TRIDENTPortPrivPtr pPriv = (TRIDENTPortPrivPtr)data; + + if(attribute == xvColorKey) { + *value = pPriv->colorKey; + } else return BadMatch; + + return Success; +} + +static void +TRIDENTQueryBestSize( + ScrnInfoPtr pScrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, + unsigned int *p_w, unsigned int *p_h, + pointer data +){ + *p_w = drw_w; + *p_h = drw_h; + + if(*p_w > 16384) *p_w = 16384; +} + + +static void +TRIDENTCopyData( + unsigned char *src, + unsigned char *dst, + int srcPitch, + int dstPitch, + int h, + int w +){ + w <<= 1; + while(h--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } +} + +static void +TRIDENTCopyMungedData( + unsigned char *src1, + unsigned char *src2, + unsigned char *src3, + unsigned char *dst1, + int srcPitch, + int srcPitch2, + int dstPitch, + int h, + int w +){ + CARD32 *dst = (CARD32*)dst1; + int i, j; + + dstPitch >>= 2; + w >>= 1; + + for(j = 0; j < h; j++) { + for(i = 0; i < w; i++) { + dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | + (src3[i] << 8) | (src2[i] << 24); + } + dst += dstPitch; + src1 += srcPitch; + if(j & 1) { + src2 += srcPitch2; + src3 += srcPitch2; + } + } +} + +static FBLinearPtr +TRIDENTAllocateMemory( + ScrnInfoPtr pScrn, + FBLinearPtr linear, + int size +){ + ScreenPtr pScreen; + FBLinearPtr new_linear; + + if(linear) { + if(linear->size >= size) + return linear; + + if(xf86ResizeOffscreenLinear(linear, size)) + return linear; + + xf86FreeOffscreenLinear(linear); + } + + pScreen = screenInfo.screens[pScrn->scrnIndex]; + + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + + if(!new_linear) { + int max_size; + + xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16, + PRIORITY_EXTREME); + + if(max_size < size) + return NULL; + + xf86PurgeUnlockedOffscreenAreas(pScreen); + new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, + NULL, NULL, NULL); + } + + return new_linear; +} + +static void +TRIDENTDisplayVideo( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, short height, + int pitch, + int x1, int y1, int x2, int y2, + BoxPtr dstBox, + short src_w, short src_h, + short drw_w, short drw_h +){ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + int vgaIOBase = VGAHWPTR(pScrn)->IOBase; + int zoomx1, zoomx2, zoomy1, zoomy2; + int tx1,tx2; + int ty1,ty2; + + switch(id) { + case 0x35315652: /* RGB15 */ + case 0x36315652: /* RGB16 */ + OUTW(vgaIOBase + 4, 0x22BF); + break; + case FOURCC_YV12: /* YV12 */ + case FOURCC_YUY2: /* YUY2 */ + default: + OUTW(vgaIOBase + 4, 0x00BF); + break; + } + + tx1 = dstBox->x1 + pTrident->hsync; + tx2 = dstBox->x2 + pTrident->hsync; + ty1 = dstBox->y1 + pTrident->vsync - 2; + ty2 = dstBox->y2 + pTrident->vsync + 2; + + /* Crude way to deal with off the left edge - FIXME - doesn't work well */ + tx1 -= (x1 >> 16); + + OUTW(vgaIOBase + 4, (tx1 & 0xff) <<8 | 0x86); + OUTW(vgaIOBase + 4, (tx1 & 0xff00) | 0x87); + OUTW(vgaIOBase + 4, (ty1 & 0xff) <<8 | 0x88); + OUTW(vgaIOBase + 4, (ty1 & 0xff00) | 0x89); + OUTW(vgaIOBase + 4, (tx2 & 0xff) <<8 | 0x8A); + OUTW(vgaIOBase + 4, (tx2 & 0xff00) | 0x8B); + OUTW(vgaIOBase + 4, (ty2 & 0xff) <<8 | 0x8C); + OUTW(vgaIOBase + 4, (ty2 & 0xff00) | 0x8D); + + OUTW(vgaIOBase + 4, (((width<<1) & 0xff)<<8) | 0x90); + OUTW(vgaIOBase + 4, ((width<<1) & 0xff00) | 0x91); + OUTW(vgaIOBase + 4, ((offset>>3) & 0xff) << 8 | 0x92); + OUTW(vgaIOBase + 4, ((offset>>3) & 0xff00) | 0x93); + OUTW(vgaIOBase + 4, ((offset>>3) & 0xff0000) >> 8 | 0x94); + + /* Horizontal Zoom */ + if (drw_w == src_w) { + OUTW(vgaIOBase + 4, 0x0080); + OUTW(vgaIOBase + 4, 0x0081); + } else + if (drw_w > src_w) { + zoomx1 = ((float)src_w/(float)drw_w); + zoomx2 = ( ((float)src_w/(float)drw_w) - (int)zoomx1 ) * 1024; + OUTW(vgaIOBase + 4, (zoomx2&0xff)<<8 | 0x80); + OUTW(vgaIOBase + 4, (zoomx1&0x0f)<<10 | (zoomx2&0x0300) | 0x81); + } else { + zoomx1 = ((float)drw_w/(float)src_w); + zoomx2 = ( ((float)drw_w/(float)src_w) - (int)zoomx1 ) * 1024; + OUTW(vgaIOBase + 4, (zoomx2&0xff)<<8 | 0x80); + OUTW(vgaIOBase + 4, (zoomx2&0x0300)| + (((int)((float)src_w/(float)drw_w)-1)&7)<<10 | 0x8081); + } + + /* Vertical Zoom */ + if (drw_h == src_h) { + OUTW(vgaIOBase + 4, 0x0082); + OUTW(vgaIOBase + 4, 0x0083); + } else + if (drw_h > src_h) { + zoomy1 = ((float)src_h/(float)drw_h); + zoomy2 = ( ((float)src_h/(float)drw_h) - (int)zoomy1 ) * 1024; + OUTW(vgaIOBase + 4, (zoomy2&0xff)<<8 | 0x82); + OUTW(vgaIOBase + 4, (zoomy1&0x0f)<<10 | (zoomy2&0x0300) | 0x83); + } else { + zoomy1 = ((float)drw_h/(float)src_h); + zoomy2 = ( ((float)drw_h/(float)src_h) - (int)zoomy1 ) * 1024; + OUTW(vgaIOBase + 4, (zoomy2&0xff)<<8 | 0x82); + OUTW(vgaIOBase + 4, (zoomy2&0x0300)| + (((int)((float)src_h/(float)drw_h)-1)&7)<<10 | 0x8083); + } + + OUTW(vgaIOBase + 4, 0x0895); + OUTW(vgaIOBase + 4, ((width+2)>>2)<<8 | 0x96); + + OUTW(vgaIOBase + 4, 0x0097); + OUTW(vgaIOBase + 4, 0x00BA); + OUTW(vgaIOBase + 4, 0x00BB); + OUTW(vgaIOBase + 4, 0xFFBC); + OUTW(vgaIOBase + 4, 0xFFBD); + OUTW(vgaIOBase + 4, 0x04BE); + + OUTW(vgaIOBase + 4, 0xD48E); + OUTW(vgaIOBase + 4, 0x208F); +} + +static int +TRIDENTPutImage( + ScrnInfoPtr pScrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char* buf, + short width, short height, + Bool sync, + RegionPtr clipBoxes, pointer data +){ + TRIDENTPortPrivPtr pPriv = (TRIDENTPortPrivPtr)data; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + INT32 x1, x2, y1, y2; + unsigned char *dst_start; + int pitch, new_size, offset, offset2 = 0, offset3 = 0; + int srcPitch, srcPitch2 = 0, dstPitch; + int top, left, npixels, nlines, bpp; + BoxRec dstBox; + CARD32 tmp; + + /* Clip */ + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if(!TRIDENTClipVideo(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height)) + return Success; + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + bpp = pScrn->bitsPerPixel >> 3; + pitch = bpp * pScrn->displayWidth; + + dstPitch = ((width << 1) + 15) & ~15; + new_size = ((dstPitch * height) + bpp - 1) / bpp; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = (srcPitch2 * (height >> 1)) + offset2; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + srcPitch = (width << 1); + break; + } + + if(!(pPriv->linear = TRIDENTAllocateMemory(pScrn, pPriv->linear, new_size))) + return BadAlloc; + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + left <<= 1; + + offset = pPriv->linear->offset * bpp; + dst_start = pTrident->FbBase + offset + left + (top * dstPitch); + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + tmp = ((top >> 1) * srcPitch2) + (left >> 2); + offset2 += tmp; + offset3 += tmp; + if(id == FOURCC_I420) { + tmp = offset2; + offset2 = offset3; + offset3 = tmp; + } + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + TRIDENTCopyMungedData(buf + (top * srcPitch) + (left >> 1), + buf + offset2, buf + offset3, dst_start, + srcPitch, srcPitch2, dstPitch, nlines, npixels); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + buf += (top * srcPitch) + left; + nlines = ((y2 + 0xffff) >> 16) - top; + TRIDENTCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels); + break; + } + + /* update cliplist */ + if(!RegionsEqual(&pPriv->clip, clipBoxes)) { + REGION_COPY(pScreen, &pPriv->clip, clipBoxes); + /* draw these */ + XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + } + + offset += top * dstPitch; + TRIDENTDisplayVideo(pScrn, id, offset, width, height, dstPitch, + x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + + pPriv->videoStatus = CLIENT_VIDEO_ON; + + pTrident->VideoTimerCallback = TRIDENTVideoTimerCallback; + + return Success; +} + +static int +TRIDENTQueryImageAttributes( + ScrnInfoPtr pScrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets +){ + int size, tmp; + + if(*w > 1024) *w = 1024; + if(*h > 1024) *h = 1024; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: /* YV12 */ + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) pitches[0] = size; + size *= *h; + if(offsets) offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) offsets[2] = size; + size += tmp; + break; + default: /* RGB15, RGB16, YUY2 */ + size = *w << 1; + if(pitches) pitches[0] = size; + size *= *h; + break; + } + + return size; +} + +/****************** Offscreen stuff ***************/ + +typedef struct { + FBLinearPtr linear; + Bool isOn; +} OffscreenPrivRec, * OffscreenPrivPtr; + +static int +TRIDENTAllocateSurface( + ScrnInfoPtr pScrn, + int id, + unsigned short w, + unsigned short h, + XF86SurfacePtr surface +){ + FBLinearPtr linear; + int pitch, fbpitch, size, bpp; + OffscreenPrivPtr pPriv; + + if((w > 1024) || (h > 1024)) + return BadAlloc; + + w = (w + 1) & ~1; + pitch = ((w << 1) + 15) & ~15; + bpp = pScrn->bitsPerPixel >> 3; + fbpitch = bpp * pScrn->displayWidth; + size = ((pitch * h) + bpp - 1) / bpp; + + if(!(linear = TRIDENTAllocateMemory(pScrn, NULL, size))) + return BadAlloc; + + surface->width = w; + surface->height = h; + + if(!(surface->pitches = xalloc(sizeof(int)))) { + xf86FreeOffscreenLinear(linear); + return BadAlloc; + } + if(!(surface->offsets = xalloc(sizeof(int)))) { + xfree(surface->pitches); + xf86FreeOffscreenLinear(linear); + return BadAlloc; + } + if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) { + xfree(surface->pitches); + xfree(surface->offsets); + xf86FreeOffscreenLinear(linear); + return BadAlloc; + } + + pPriv->linear = linear; + pPriv->isOn = FALSE; + + surface->pScrn = pScrn; + surface->id = id; + surface->pitches[0] = pitch; + surface->offsets[0] = linear->offset * bpp; + surface->devPrivate.ptr = (pointer)pPriv; + + return Success; +} + +static int +TRIDENTStopSurface( + XF86SurfacePtr surface +){ + OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr; + + if(pPriv->isOn) { + TRIDENTPtr pTrident = TRIDENTPTR(surface->pScrn); + int vgaIOBase = VGAHWPTR(surface->pScrn)->IOBase; + OUTW(vgaIOBase + 4, 0x008E); + OUTW(vgaIOBase + 4, 0x008F); + pPriv->isOn = FALSE; + } + + return Success; +} + + +static int +TRIDENTFreeSurface( + XF86SurfacePtr surface +){ + OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr; + + if(pPriv->isOn) + TRIDENTStopSurface(surface); + xf86FreeOffscreenLinear(pPriv->linear); + xfree(surface->pitches); + xfree(surface->offsets); + xfree(surface->devPrivate.ptr); + + return Success; +} + +static int +TRIDENTGetSurfaceAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 *value +){ + return TRIDENTGetPortAttribute(pScrn, attribute, value, + (pointer)(GET_PORT_PRIVATE(pScrn))); +} + +static int +TRIDENTSetSurfaceAttribute( + ScrnInfoPtr pScrn, + Atom attribute, + INT32 value +){ + return TRIDENTSetPortAttribute(pScrn, attribute, value, + (pointer)(GET_PORT_PRIVATE(pScrn))); +} + +static int +TRIDENTDisplaySurface( + XF86SurfacePtr surface, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + RegionPtr clipBoxes +){ + OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr; + ScrnInfoPtr pScrn = surface->pScrn; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + TRIDENTPortPrivPtr portPriv = pTrident->adaptor->pPortPrivates[0].ptr; + INT32 x1, y1, x2, y2; + BoxRec dstBox; + + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + if(!TRIDENTClipVideo(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, + surface->width, surface->height)) + { + return Success; + } + + dstBox.x1 -= pScrn->frameX0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.y2 -= pScrn->frameY0; + + TRIDENTResetVideo(pScrn); + + TRIDENTDisplayVideo(pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], + x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); + + XAAFillSolidRects(pScrn, portPriv->colorKey, GXcopy, ~0, + REGION_NUM_RECTS(clipBoxes), + REGION_RECTS(clipBoxes)); + + pPriv->isOn = TRUE; + /* we've prempted the XvImage stream so set its free timer */ + if(portPriv->videoStatus & CLIENT_VIDEO_ON) { + REGION_EMPTY(pScrn->pScreen, &portPriv->clip); + UpdateCurrentTime(); + portPriv->videoStatus = FREE_TIMER; + portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; + pTrident->VideoTimerCallback = TRIDENTVideoTimerCallback; + } + + return Success; +} + +static void +TRIDENTInitOffscreenImages(ScreenPtr pScreen) +{ + XF86OffscreenImagePtr offscreenImages; + + /* need to free this someplace */ + if(!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec)))) + return; + + offscreenImages[0].image = &Images[0]; + offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | + VIDEO_CLIP_TO_VIEWPORT; + offscreenImages[0].alloc_surface = TRIDENTAllocateSurface; + offscreenImages[0].free_surface = TRIDENTFreeSurface; + offscreenImages[0].display = TRIDENTDisplaySurface; + offscreenImages[0].stop = TRIDENTStopSurface; + offscreenImages[0].setAttribute = TRIDENTSetSurfaceAttribute; + offscreenImages[0].getAttribute = TRIDENTGetSurfaceAttribute; + offscreenImages[0].max_width = 1024; + offscreenImages[0].max_height = 1024; + offscreenImages[0].num_attributes = NUM_ATTRIBUTES; + offscreenImages[0].attributes = Attributes; + + xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); +} + +static void +TRIDENTVideoTimerCallback(ScrnInfoPtr pScrn, Time time) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + TRIDENTPortPrivPtr pPriv = pTrident->adaptor->pPortPrivates[0].ptr; + int vgaIOBase = VGAHWPTR(pScrn)->IOBase; + + if(pPriv->videoStatus & TIMER_MASK) { + if(pPriv->videoStatus & OFF_TIMER) { + if(pPriv->offTime < time) { + OUTW(vgaIOBase + 4, 0x008E); + OUTW(vgaIOBase + 4, 0x008F); + pPriv->videoStatus = FREE_TIMER; + pPriv->freeTime = time + FREE_DELAY; + } + } else { /* FREE_TIMER */ + if(pPriv->freeTime < time) { + if(pPriv->linear) { + xf86FreeOffscreenLinear(pPriv->linear); + pPriv->linear = NULL; + } + pPriv->videoStatus = 0; + pTrident->VideoTimerCallback = NULL; + } + } + } else /* shouldn't get here */ + pTrident->VideoTimerCallback = NULL; +} + +#endif /* !XvExtension */ Index: xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c:1.11 xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c:1.15 --- xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c:1.11 Wed Oct 13 16:02:30 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c Thu Dec 14 14:29:45 2000 @@ -1,4 +1,27 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c,v 1.11 1999/10/13 20:02:30 alanh Exp $ */ +/* + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Alan Hourihane, alanh@fairlite.demon.co.uk + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/tridenthelper.c,v 1.15 2000/12/14 19:29:45 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -47,7 +70,7 @@ freq = clock; - for (k=0;k<=endk;k++) + for (k=endk;k>=0;k--) for (n=startn;n<=endn;n++) for (m=1;m<=endm;m++) { @@ -109,6 +132,60 @@ pTrident->frequency = PAL; else pTrident->frequency = NTSC; +} + +void +TridentFindClock(ScrnInfoPtr pScrn, int clock) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + pTrident->MUX = FALSE; +#ifdef READOUT + pTrident->DontSetClock = FALSE; +#endif + pTrident->currentClock = clock; + + if (pTrident->IsCyber) { + Bool LCDActive; +#ifdef READOUT + Bool ShadowModeActive; + Bool HStretch; + Bool VStretch; +#endif + OUTB(0x3CE, FPConfig); + LCDActive = (INB(0x3CF) & 0x10); +#ifdef READOUT + OUTB(0x3CE,HorStretch); + HStretch = (INB(0x3CF) & 0x01); + OUTB(0x3CE,VertStretch); + VStretch = (INB(0x3CF) & 0x01); + + if (!(VStretch || HStretch) && LCDActive) { + CARD8 temp; + temp = INB(0x3C8); + temp = INB(0x3C6); + temp = INB(0x3C6); + temp = INB(0x3C6); + temp = INB(0x3C6); + pTrident->MUX = ((INB(0x3C6) & 0x20) == 0x20); + temp = INB(0x3C8); + pTrident->DontSetClock = TRUE; + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Keeping Clock for LCD Mode\n"); + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"MUX is %s\n",pTrident->MUX? + "on":"off"); + return; + + } else +#endif + { + if (pTrident->lcdMode != 0xff && LCDActive) + pTrident->currentClock = clock = LCD[pTrident->lcdMode].clock; + } + + } + if (clock > pTrident->MUXThreshold) pTrident->MUX = TRUE; + else pTrident->MUX = FALSE; + } float Index: xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c:1.3 Sun Apr 25 06:02:32 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c Thu Dec 7 11:48:06 2000 @@ -1,5 +1,5 @@ /* - * Copyright 1998 by Alan Hourihane, Wigan, England. + * Copyright 1992-2000 by Alan Hourihane, Wigan, England. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -24,7 +24,7 @@ * TridentOutIndReg() and TridentInIndReg() are used to access * the indirect Trident RAMDAC registers only. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c,v 1.3 1999/04/25 10:02:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/tridentramdac.c,v 1.4 2000/12/07 16:48:06 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile:1.16 xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile:1.16 Thu Mar 2 20:05:44 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile Wed Dec 6 10:35:24 2000 @@ -4,31 +4,32 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile,v 1.16 2000/03/03 01:05:44 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/Imakefile,v 1.20 2000/12/06 15:35:24 eich Exp $ #define IHaveModules #include <Server.tmpl> SRCS = tseng_driver.c tseng_ramdac.c tseng_bank.c tseng_clock.c \ tseng_accel.c tseng_acl.c tseng_colexp.c tseng_cursor.c \ - tseng_dpms.c + tseng_dpms.c tseng_dga.c OBJS = tseng_driver.o tseng_ramdac.o tseng_bank.o tseng_clock.o \ tseng_accel.o tseng_acl.o tseng_colexp.o tseng_cursor.o \ - tseng_dpms.o + tseng_dpms.o tseng_dga.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \ + -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa \ -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \ - -I$(XF86SRC)/xf24_32bpp \ + -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \ - -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) + -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ + -I$(EXTINCSRC) -I$(SERVERSRC)/render #endif DEFINES = -DPSZ=8 @@ -64,5 +65,6 @@ InstallDriverSDKNonExecFile(tseng_driver.c,$(DRIVERSDKDIR)/drivers/tseng) InstallDriverSDKNonExecFile(tseng_inline.h,$(DRIVERSDKDIR)/drivers/tseng) InstallDriverSDKNonExecFile(tseng_ramdac.c,$(DRIVERSDKDIR)/drivers/tseng) +InstallDriverSDKNonExecFile(tseng_dga.c,$(DRIVERSDKDIR)/drivers/tseng) InstallDriverSDKObjectModule(tseng,$(DRIVERSDKMODULEDIR),drivers) Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/README diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/README:1.11 xc/programs/Xserver/hw/xfree86/drivers/tseng/README:1.12 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/README:1.11 Sat Jul 25 12:55:59 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/README Tue Aug 8 04:58:06 2000 @@ -261,4 +261,4 @@ -$XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/README,v 1.11 1998/07/25 16:55:59 dawes Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/README,v 1.12 2000/08/08 08:58:06 eich Exp $ Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp:1.6 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp:1.4 Tue Jun 13 22:13:15 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp Mon Dec 11 15:18:39 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp,v 1.6 2000/12/11 20:18:39 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH TSENG __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH TSENG __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME tseng \- Tseng Labs video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h:1.27 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h:1.33 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h:1.27 Sat Jun 12 03:18:57 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h Wed Dec 6 10:35:24 2000 @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h,v 1.27 1999/06/12 07:18:57 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.h,v 1.33 2000/12/06 15:35:24 eich Exp $ */ @@ -8,9 +8,6 @@ #ifndef _TSENG_H #define _TSENG_H -/* Everything using inb/outb, etc needs "compiler.h" */ -#include "compiler.h" - /* All drivers should typically include these */ #include "xf86.h" #include "xf86_OSproc.h" @@ -18,6 +15,9 @@ /* All drivers need this */ #include "xf86_ansic.h" +/* Everything using inb/outb, etc needs "compiler.h" */ +#include "compiler.h" + /* This is used for module versioning */ #include "xf86Version.h" @@ -40,19 +40,8 @@ /* Needed for the 1 and 4 bpp framebuffers */ #include "xf1bpp.h" #include "xf4bpp.h" +#include "fb.h" -/* Drivers using cfb need this */ - -#define PSZ 8 -#include "cfb.h" -#undef PSZ - -/* Drivers supporting bpp 16, 24 or 32 with cfb need these */ - -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" - /* Drivers using the XAA interface ... */ #include "xaa.h" #include "xaalocal.h" @@ -211,9 +200,9 @@ t_tseng_bus Bustype; /* W32 bus type (currently used for lin mem on W32i) */ t_tseng_type ChipType; /* "Chipset" causes confusion with pScrn->chipset */ int ChipRev; - CARD32 LinFbAddress; + memType LinFbAddress; unsigned char *FbBase; - CARD32 LinFbAddressMask; + memType LinFbAddressMask; long FbMapSize; miBankInfoRec BankInfo; CARD32 IOAddress; /* PCI config space base address for ET6000 */ @@ -240,6 +229,20 @@ unsigned char * XAAScanlineColorExpandBuffers[1]; CARD32* ColExpLUT; EntityInfoPtr pEnt; + char * MMioBase; + pointer scratchMemBase; + pointer tsengCPU2ACLBase; + /* These will hold the ping-pong registers. */ + int tsengFg; + int tsengBg; + int tsengPat; + int tseng_old_dir; + int old_x; + int old_y; + int DGAnumModes; + Bool DGAactive; + DGAModePtr DGAModes; + int DGAViewportStatus; } TsengRec, *TsengPtr; #define TsengPTR(p) ((TsengPtr)((p)->driverPrivate)) @@ -292,6 +295,18 @@ #define ET6000_programmable_clock \ ( pScrn->progClock && (pTseng->ClockChip == CLOCKCHIP_ET6000) ) + + +/* + * tseng_driver.c for DGA + */ +Bool TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void TsengAdjustFrame(int scrnIndex, int x, int y, int flags); + +/* + * tseng_dga.c + */ +Bool TsengDGAInit(ScreenPtr pScreen); /* * From tseng_bank.c Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c:1.30 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c:1.32 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c:1.30 Sat Sep 25 10:37:31 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c Tue Aug 8 04:58:06 2000 @@ -1,10 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c,v 1.30 1999/09/25 14:37:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_accel.c,v 1.32 2000/08/08 08:58:06 eich Exp $ */ - - - - - /* * ET4/6K acceleration interface. * @@ -100,7 +95,6 @@ TsengPtr pTseng = TsengPTR(pScrn); XAAInfoRecPtr pXAAinfo; BoxRec AvailFBArea; - int i; PDEBUG(" TsengXAAInit\n"); pTseng->AccelInfoRec = pXAAinfo = XAACreateInfoRec(); @@ -253,7 +247,7 @@ } #endif -#if 1 +#if 0 /*1*/ /* * SolidLine. * @@ -369,12 +363,14 @@ * Init ping-pong registers. * This might be obsoleted by the BACKGROUND_OPERATIONS flag. */ - tsengMemFg = MemW32ForegroundPing; - tsengFg = W32ForegroundPing; - tsengMemBg = MemW32BackgroundPing; - tsengBg = W32BackgroundPing; - tsengMemPat = MemW32PatternPing; - tsengPat = W32PatternPing; + pTseng->tsengFg = 0; + pTseng->tsengBg = 16; + pTseng->tsengPat = 32; + + /* for register write optimisation */ + pTseng->tseng_old_dir = -1; + pTseng->old_x = 0; + pTseng->old_y = 0; /* * Finally, we set up the video memory space available to the pixmap @@ -431,7 +427,7 @@ /* ErrorF("S"); */ - PINGPONG(); + PINGPONG(pTseng); wait_acl_queue(pTseng); @@ -482,7 +478,7 @@ * here without calling the SetupFor... code again, and the * ACL_SOURCE_ADDRESS will be wrong. */ - *ACL_SOURCE_ADDRESS = tsengFg; + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengFg); SET_XYDIR(0); /* FIXME: not needed with separate setupforsolidline */ @@ -515,7 +511,7 @@ wait_acl_queue(pTseng); /* see comment in TsengW32pSubsequentFillRectSolid */ - *ACL_SOURCE_ADDRESS = tsengFg; + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengFg); /* if XYDIR is not reset here, drawing a hardware line in between * blitting, with the same ROP, color, etc will not cause a call to @@ -589,8 +585,8 @@ Tseng_setup_screencopy(pTseng, rop, planemask, trans_color, blit_dir); - *ACL_SOURCE_WRAP = 0x77; /* no wrap */ - *ACL_SOURCE_Y_OFFSET = pTseng->line_width - 1; + ACL_SOURCE_WRAP(0x77); /* no wrap */ + ACL_SOURCE_Y_OFFSET(pTseng->line_width - 1); } /* @@ -655,7 +651,7 @@ wait_acl_queue(pTseng); SET_XY(pTseng, w, h); - *ACL_SOURCE_ADDRESS = srcaddr; + ACL_SOURCE_ADDRESS(srcaddr); START_ACL(pTseng, destaddr); } @@ -675,20 +671,20 @@ switch (pTseng->Bytesperpixel) { case 1: - *ACL_SOURCE_WRAP = 0x33; /* 8x8 wrap */ - *ACL_SOURCE_Y_OFFSET = 8 - 1; + ACL_SOURCE_WRAP(0x33); /* 8x8 wrap */ + ACL_SOURCE_Y_OFFSET(8 - 1); break; case 2: - *ACL_SOURCE_WRAP = 0x34; /* 16x8 wrap */ - *ACL_SOURCE_Y_OFFSET = 16 - 1; + ACL_SOURCE_WRAP(0x34); /* 16x8 wrap */ + ACL_SOURCE_Y_OFFSET(16 - 1); break; case 3: - *ACL_SOURCE_WRAP = 0x3D; /* 24x8 wrap --- only for ET6000 !!! */ - *ACL_SOURCE_Y_OFFSET = 32 - 1; /* this is no error -- see databook */ + ACL_SOURCE_WRAP(0x3D); /* 24x8 wrap --- only for ET6000 !!! */ + ACL_SOURCE_Y_OFFSET(32 - 1); /* this is no error -- see databook */ break; case 4: - *ACL_SOURCE_WRAP = 0x35; /* 32x8 wrap */ - *ACL_SOURCE_Y_OFFSET = 32 - 1; + ACL_SOURCE_WRAP(0x35); /* 32x8 wrap */ + ACL_SOURCE_Y_OFFSET(32 - 1); } } @@ -702,7 +698,7 @@ wait_acl_queue(pTseng); - *ACL_SOURCE_ADDRESS = srcaddr; + ACL_SOURCE_ADDRESS(srcaddr); SET_XY(pTseng, w, h); START_ACL(pTseng, destaddr); @@ -722,8 +718,8 @@ Tseng_setup_screencopy(pTseng, rop, planemask, trans_color, 0); - *ACL_SOURCE_WRAP = 0x77; /* no wrap */ - *ACL_SOURCE_Y_OFFSET = pTseng->line_width - 1; + ACL_SOURCE_WRAP(0x77); /* no wrap */ + ACL_SOURCE_Y_OFFSET(pTseng->line_width - 1); } static CARD32 iw_dest, iw_skipleft; @@ -753,7 +749,7 @@ wait_acl_queue(pTseng); - *ACL_SOURCE_ADDRESS = pTseng->AccelImageWriteBufferOffsets[bufno] + iw_skipleft; + ACL_SOURCE_ADDRESS(pTseng->AccelImageWriteBufferOffsets[bufno] + iw_skipleft); START_ACL(pTseng, iw_dest); iw_dest += pTseng->line_width; } @@ -800,18 +796,19 @@ if (!(octant & YMAJOR)) { SET_X_YRAW(pTseng, len, 0xFFF); } else { - SET_XY_RAW(0xFFF, len - 1); + SET_XY_RAW(pTseng,0xFFF, len - 1); } SET_DELTA(minor, major); - *ACL_ERROR_TERM = -err; /* error term from XAA is NEGATIVE */ + ACL_ERROR_TERM(-err); /* error term from XAA is NEGATIVE */ /* make sure colors are rendered correctly if >8bpp */ if (octant & XDECREASING) { destaddr += pTseng->Bytesperpixel - 1; - *ACL_SOURCE_ADDRESS = tsengFg + pTseng->neg_x_pixel_offset; + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + + pTseng->tsengFg + pTseng->neg_x_pixel_offset); } else - *ACL_SOURCE_ADDRESS = tsengFg; + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengFg); SET_XYDIR(xydir); @@ -900,7 +897,7 @@ SetYMajorOctant(octant); SET_DELTA(dxL, dyL); } - *ACL_ERROR_TERM = eL; + ACL_ERROR_TERM(eL); /* select "linedraw algorithm" (=bias) and load direction register */ /* ErrorF(" o=%d ", octant); */ @@ -924,7 +921,7 @@ } else { /* Y is major axis */ SET_SECONDARY_DELTA(dxR, dyR); } - *ACL_SECONDARY_ERROR_TERM = eR; + ACL_SECONDARY_ERROR_TERM(eR); /* ErrorF("%02x", sec_dir_reg); */ SET_SECONDARY_XYDIR(sec_dir_reg); Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c:1.21 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c:1.25 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c:1.21 Sat Sep 5 02:36:55 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c Thu Dec 14 11:33:10 2000 @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c,v 1.21 1998/09/05 06:36:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.c,v 1.25 2000/12/14 16:33:10 eich Exp $ */ @@ -7,53 +7,10 @@ #include "tseng.h" #include "tseng_acl.h" +#include "compiler.h" void tseng_terminate_acl(TsengPtr pTseng); -ByteP W32Buffer; - -LongP MBP0, MBP1, MBP2; -ByteP MMU_CONTROL; - -ByteP ACL_SUSPEND_TERMINATE, ACL_OPERATION_STATE, ACL_SYNC_ENABLE, ACL_WRITE_INTERFACE_VALID, - ACL_INTERRUPT_MASK, ACL_INTERRUPT_STATUS, ACL_ACCELERATOR_STATUS; - -WordP ACL_X_POSITION, ACL_Y_POSITION; - -WordP ACL_NQ_X_POSITION, ACL_NQ_Y_POSITION; - -LongP ACL_PATTERN_ADDRESS, ACL_SOURCE_ADDRESS; - -WordP ACL_PATTERN_Y_OFFSET, ACL_SOURCE_Y_OFFSET, ACL_DESTINATION_Y_OFFSET; - -ByteP ACL_VIRTUAL_BUS_SIZE, /* only for w32 and w32i */ - ACL_XY_DIRECTION, /* only for w32 and w32i */ - ACL_PIXEL_DEPTH; /* only for w32p_rev_A and w32p_rev_B */ - -ByteP ACL_PATTERN_WRAP, ACL_SOURCE_WRAP; - -WordP ACL_X_COUNT, ACL_Y_COUNT; -LongP ACL_XY_COUNT; /* for combined writes to X and Y count registers */ - -ByteP ACL_ROUTING_CONTROL, ACL_RELOAD_CONTROL, ACL_BACKGROUND_RASTER_OPERATION, - ACL_FOREGROUND_RASTER_OPERATION; - -LongP ACL_DESTINATION_ADDRESS, /* only for w32p_rev_A and w32p_rev_B */ - ACL_MIX_ADDRESS; - -WordP ACL_MIX_Y_OFFSET, ACL_ERROR_TERM, ACL_DELTA_MINOR, ACL_DELTA_MAJOR; - -/* for ET6000 only */ -ByteP ACL_POWER_CONTROL; - -ByteP ACL_SECONDARY_EDGE; -WordP ACL_SECONDARY_ERROR_TERM, ACL_SECONDARY_DELTA_MINOR, ACL_SECONDARY_DELTA_MAJOR; -ByteP ACL_TRANSFER_DISABLE; - -ByteP W32BytePtr; -WordP W32WordPtr; -LongP W32LongPtr; - /* * conversion from X ROPs to Microsoft ROPs. */ @@ -118,40 +75,8 @@ 0xff /* Xset 1 */ }; -long W32ForegroundPing; -long W32ForegroundPong; -long W32BackgroundPing; -long W32BackgroundPong; -long W32PatternPing; -long W32PatternPong; - -LongP MemW32ForegroundPing; -LongP MemW32ForegroundPong; -LongP MemW32BackgroundPing; -LongP MemW32BackgroundPong; -LongP MemW32PatternPing; -LongP MemW32PatternPong; - -unsigned char * tsengCPU2ACLBase; - -/* used for optimisation of direction-register writing */ -int tseng_old_dir = -1; -int old_x = 0, old_y = 0; - -/* These will hold the ping-pong registers. - * Note that ping-pong registers might not be needed when using - * BACKGROUND_OPERATIONS (because of the WAIT()-ing involved) - */ -LongP tsengMemFg; -long tsengFg; -LongP tsengMemBg; -long tsengBg; - -LongP tsengMemPat; -long tsengPat; - /**********************************************************************/ void @@ -160,15 +85,15 @@ /* only terminate when needed */ /* if (*(volatile unsigned char *)ACL_ACCELERATOR_STATUS & 0x06) */ { - *ACL_SUSPEND_TERMINATE = 0x00; + ACL_SUSPEND_TERMINATE(0x00); /* suspend any running operation */ - *ACL_SUSPEND_TERMINATE = 0x01; + ACL_SUSPEND_TERMINATE(0x01); WAIT_ACL; - *ACL_SUSPEND_TERMINATE = 0x00; + ACL_SUSPEND_TERMINATE(0x00); /* ... and now terminate it */ - *ACL_SUSPEND_TERMINATE = 0x10; + ACL_SUSPEND_TERMINATE(0x10); WAIT_ACL; - *ACL_SUSPEND_TERMINATE = 0x00; + ACL_SUSPEND_TERMINATE(0x00); } } @@ -177,23 +102,19 @@ { if (!Is_ET6K) { ErrorF("trying to unlock......................................\n"); - *tsengCPU2ACLBase = 0L; /* try unlocking the bus when CPU-to-accel gets stuck */ + MMIO_OUT32(pTseng->tsengCPU2ACLBase,0,0L); /* try unlocking the bus when CPU-to-accel gets stuck */ } if (Is_W32p) { /* flush the accelerator pipeline */ - *ACL_SUSPEND_TERMINATE = 0x00; - *ACL_SUSPEND_TERMINATE = 0x02; - *ACL_SUSPEND_TERMINATE = 0x00; + ACL_SUSPEND_TERMINATE(0x00); + ACL_SUSPEND_TERMINATE(0x02); + ACL_SUSPEND_TERMINATE(0x00); } } -long MMioBase; - void -tseng_init_acl(ScreenPtr pScreen) +tseng_init_acl(ScrnInfoPtr pScrn) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; TsengPtr pTseng = TsengPTR(pScrn); - long scratchMemBase; PDEBUG(" tseng_init_acl\n"); /* @@ -201,17 +122,15 @@ */ if (pTseng->UseLinMem) { - MMioBase = (long)pTseng->FbBase + 0x3FFF00; - scratchMemBase = (long)pTseng->FbBase + pTseng->AccelColorBufferOffset; + pTseng->scratchMemBase = pTseng->FbBase + pTseng->AccelColorBufferOffset; /* * we won't be using tsengCPU2ACLBase in linear memory mode anyway, since * using the MMU apertures restricts the amount of useable video memory * to only 2MB, supposing we ONLY redirect MMU aperture 2 to the CPU. * (see data book W32p, page 207) */ - tsengCPU2ACLBase = (unsigned char*) ((long)pTseng->FbBase + 0x200000); /* MMU aperture 2 */ + pTseng->tsengCPU2ACLBase = pTseng->FbBase + 0x200000; /* MMU aperture 2 */ } else { - MMioBase = (long)pTseng->FbBase + 0x1FF00L; /* * MMU 0 is used for the scratchpad (i.e. FG and BG colors). * @@ -220,107 +139,18 @@ * being the first, and don't exceed 8kb (aperture size) in total * length. */ - scratchMemBase = (long)pTseng->FbBase + 0x18000L; - *((LongP) (MMioBase + 0x00)) = pTseng->AccelColorBufferOffset; - *((LongP) (MMioBase + 0x04)) = pTseng->AccelImageWriteBufferOffsets[0]; + pTseng->scratchMemBase = pTseng->FbBase + 0x18000L; + MMIO_OUT32(pTseng->MMioBase, 0x00<<0, pTseng->AccelColorBufferOffset); + MMIO_OUT32(pTseng->MMioBase, 0x04<<0, pTseng->AccelImageWriteBufferOffsets[0]); /* * tsengCPU2ACLBase is used for CPUtoSCreen...() operations on < ET6000 devices */ - tsengCPU2ACLBase = (unsigned char*) ((long)pTseng->FbBase + 0x1C000L); /* MMU aperture 2 */ - /* *((LongP) (MMioBase + 0x08)) = 200000; *//* TEST */ + pTseng->tsengCPU2ACLBase = pTseng->FbBase + 0x1C000L; /* MMU aperture 2 */ + /* MMIO_IN32(pTseng->MMioBase, 0x08<<0) = 200000; *//* TEST */ } - - /* ErrorF("MMioBase = 0x%x, scratchMemBase = 0x%x\n", MMioBase, scratchMemBase); */ - - MMU_CONTROL = (ByteP) (MMioBase + 0x13); - - ACL_SUSPEND_TERMINATE = (ByteP) (MMioBase + 0x30); - ACL_OPERATION_STATE = (ByteP) (MMioBase + 0x31); - - ACL_SYNC_ENABLE = (ByteP) (MMioBase + 0x32); - /* for ET6000, ACL_SYNC_ENABLE becomes ACL_6K_CONFIG */ - - ACL_WRITE_INTERFACE_VALID = (ByteP) (MMioBase + 0x33); - ACL_INTERRUPT_MASK = (ByteP) (MMioBase + 0x34); - ACL_INTERRUPT_STATUS = (ByteP) (MMioBase + 0x35); - ACL_ACCELERATOR_STATUS = (ByteP) (MMioBase + 0x36); - - /* and this is only for the ET6000 */ - ACL_POWER_CONTROL = (ByteP) (MMioBase + 0x37); - - /* non-queued for w32p's and ET6000 */ - ACL_NQ_X_POSITION = (WordP) (MMioBase + 0x38); - ACL_NQ_Y_POSITION = (WordP) (MMioBase + 0x3A); - /* queued for w32 and w32i */ - ACL_X_POSITION = (WordP) (MMioBase + 0x94); - ACL_Y_POSITION = (WordP) (MMioBase + 0x96); - - ACL_PATTERN_ADDRESS = (LongP) (MMioBase + 0x80); - ACL_SOURCE_ADDRESS = (LongP) (MMioBase + 0x84); - - ACL_PATTERN_Y_OFFSET = (WordP) (MMioBase + 0x88); - ACL_SOURCE_Y_OFFSET = (WordP) (MMioBase + 0x8A); - ACL_DESTINATION_Y_OFFSET = (WordP) (MMioBase + 0x8C); - - /* W32i */ - ACL_VIRTUAL_BUS_SIZE = (ByteP) (MMioBase + 0x8E); - /* w32p */ - ACL_PIXEL_DEPTH = (ByteP) (MMioBase + 0x8E); - - /* w32 and w32i */ - ACL_XY_DIRECTION = (ByteP) (MMioBase + 0x8F); - - ACL_PATTERN_WRAP = (ByteP) (MMioBase + 0x90); - ACL_TRANSFER_DISABLE = (ByteP) (MMioBase + 0x91); /* ET6000 only */ - ACL_SOURCE_WRAP = (ByteP) (MMioBase + 0x92); - - ACL_X_COUNT = (WordP) (MMioBase + 0x98); - ACL_Y_COUNT = (WordP) (MMioBase + 0x9A); - ACL_XY_COUNT = (LongP) (ACL_X_COUNT); /* shortcut. not a real register */ - - ACL_ROUTING_CONTROL = (ByteP) (MMioBase + 0x9C); - /* for ET6000, ACL_ROUTING_CONTROL becomes ACL_MIX_CONTROL */ - ACL_RELOAD_CONTROL = (ByteP) (MMioBase + 0x9D); - /* for ET6000, ACL_RELOAD_CONTROL becomes ACL_STEPPING_INHIBIT */ - - ACL_BACKGROUND_RASTER_OPERATION = (ByteP) (MMioBase + 0x9E); - ACL_FOREGROUND_RASTER_OPERATION = (ByteP) (MMioBase + 0x9F); - - ACL_DESTINATION_ADDRESS = (LongP) (MMioBase + 0xA0); - - /* the following is for the w32p's only */ - ACL_MIX_ADDRESS = (LongP) (MMioBase + 0xA4); - - ACL_MIX_Y_OFFSET = (WordP) (MMioBase + 0xA8); - ACL_ERROR_TERM = (WordP) (MMioBase + 0xAA); - ACL_DELTA_MINOR = (WordP) (MMioBase + 0xAC); - ACL_DELTA_MAJOR = (WordP) (MMioBase + 0xAE); - - /* ET6000 only (trapezoids) */ - ACL_SECONDARY_EDGE = (ByteP) (MMioBase + 0x93); - ACL_SECONDARY_ERROR_TERM = (WordP) (MMioBase + 0xB2); - ACL_SECONDARY_DELTA_MINOR = (WordP) (MMioBase + 0xB4); - ACL_SECONDARY_DELTA_MAJOR = (WordP) (MMioBase + 0xB6); - - /* addresses in video memory (i.e. "0" = first byte in video memory) */ - W32ForegroundPing = pTseng->AccelColorBufferOffset + 0; - W32ForegroundPong = pTseng->AccelColorBufferOffset + 8; - - W32BackgroundPing = pTseng->AccelColorBufferOffset + 16; - W32BackgroundPong = pTseng->AccelColorBufferOffset + 24; - - W32PatternPing = pTseng->AccelColorBufferOffset + 32; - W32PatternPong = pTseng->AccelColorBufferOffset + 40; - - /* addresses in the memory map */ - MemW32ForegroundPing = (LongP) (scratchMemBase + 0); - MemW32ForegroundPong = (LongP) (scratchMemBase + 8); - - MemW32BackgroundPing = (LongP) (scratchMemBase + 16); - MemW32BackgroundPong = (LongP) (scratchMemBase + 24); - - MemW32PatternPing = (LongP) (scratchMemBase + 32); - MemW32PatternPong = (LongP) (scratchMemBase + 40); +#ifdef DEBUG + ErrorF("MMioBase = 0x%x, scratchMemBase = 0x%x\n", pTseng->MMioBase, pTseng->scratchMemBase); +#endif /* * prepare the accelerator for some real work @@ -328,35 +158,35 @@ tseng_terminate_acl(pTseng); - *ACL_INTERRUPT_STATUS = 0xe; /* clear interrupts */ - *ACL_INTERRUPT_MASK = 0x04; /* disable interrupts, but enable deadlock exit */ - *ACL_INTERRUPT_STATUS = 0x0; - *ACL_ACCELERATOR_STATUS = 0x0; + ACL_INTERRUPT_STATUS(0xe); /* clear interrupts */ + ACL_INTERRUPT_MASK(0x04); /* disable interrupts, but enable deadlock exit */ + ACL_INTERRUPT_STATUS(0x0); + ACL_ACCELERATOR_STATUS_SET(0x0); if (Is_ET6K) { - *ACL_STEPPING_INHIBIT = 0x0; /* Undefined at power-on, let all maps (Src, Dst, Mix, Pat) step */ - *ACL_6K_CONFIG = 0x00; /* maximum performance -- what did you think? */ - *ACL_POWER_CONTROL = 0x01; /* conserve power when ACL is idle */ - *ACL_MIX_CONTROL = 0x33; - *ACL_TRANSFER_DISABLE = 0x00; /* Undefined at power-on, enable all transfers */ + ACL_STEPPING_INHIBIT(0x0); /* Undefined at power-on, let all maps (Src, Dst, Mix, Pat) step */ + ACL_6K_CONFIG(0x00); /* maximum performance -- what did you think? */ + ACL_POWER_CONTROL(0x01); /* conserve power when ACL is idle */ + ACL_MIX_CONTROL(0x33); + ACL_TRANSFER_DISABLE(0x00); /* Undefined at power-on, enable all transfers */ } else { /* W32i/W32p */ - *ACL_RELOAD_CONTROL = 0x0; - *ACL_SYNC_ENABLE = 0x1; /* | 0x2 = 0WS ACL read. Yields up to 10% faster operation for small blits */ - *ACL_ROUTING_CONTROL = 0x00; + ACL_RELOAD_CONTROL(0x0); + ACL_SYNC_ENABLE(0x1); /* | 0x2 = 0WS ACL read. Yields up to 10% faster operation for small blits */ + ACL_ROUTING_CONTROL(0x00); } if (Is_W32p || Is_ET6K) { /* Enable the W32p startup bit and set use an eight-bit pixel depth */ - *ACL_NQ_X_POSITION = 0; - *ACL_NQ_Y_POSITION = 0; - *ACL_PIXEL_DEPTH = (pScrn->bitsPerPixel - 8) << 1; + ACL_NQ_X_POSITION(0); + ACL_NQ_Y_POSITION(0); + ACL_PIXEL_DEPTH((pScrn->bitsPerPixel - 8) << 1); /* writing destination address will start ACL */ - *ACL_OPERATION_STATE = 0x10; + ACL_OPERATION_STATE(0x10); } else { /* X, Y positions set to zero's for w32 and w32i */ - *ACL_X_POSITION = 0; - *ACL_Y_POSITION = 0; - *ACL_OPERATION_STATE = 0x0; + ACL_X_POSITION(0); + ACL_Y_POSITION(0); + ACL_OPERATION_STATE(0x0); /* if we ever use CPU-to-screen pixmap uploading on W32I or W32, * ACL_VIRTUAL_BUS_SIZE will need to be made dynamic (i.e. moved to * Setup() functions). @@ -364,12 +194,12 @@ * VBS = 1 byte is faster than VBS = 4 bytes, since the ACL can * start processing as soon as the first byte arrives. */ - *ACL_VIRTUAL_BUS_SIZE = 0x00; + ACL_VIRTUAL_BUS_SIZE(0x00); } - *ACL_DESTINATION_Y_OFFSET = pScrn->displayWidth * pTseng->Bytesperpixel - 1; - *ACL_XY_DIRECTION = 0; + ACL_DESTINATION_Y_OFFSET(pScrn->displayWidth * pTseng->Bytesperpixel - 1); + ACL_XY_DIRECTION(0); - *MMU_CONTROL = 0x74; + MMU_CONTROL(0x74); if (Is_W32p && pTseng->UseLinMem) { /* @@ -392,11 +222,11 @@ * linear memory when the accelerator is enabled. */ if (Is_W32p_ab) { - *((LongP) (MMioBase + 0x00)) = 0x200000L; - *((LongP) (MMioBase + 0x04)) = 0x280000L; + MMIO_OUT32(pTseng->MMioBase, 0x00<<0, 0x200000L); + MMIO_OUT32(pTseng->MMioBase, 0x04<<0, 0x280000L); } else { /* rev C & D */ - *((LongP) (MMioBase + 0x00)) = 0x0L; - *((LongP) (MMioBase + 0x04)) = 0x100000L; + MMIO_OUT32(pTseng->MMioBase, 0x00<<0, 0x0L); + MMIO_OUT32 (pTseng->MMioBase, 0x04<<0, 0x100000L); } } } Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h:1.17 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h:1.20 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h:1.17 Sat Sep 5 02:36:55 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h Thu Dec 14 11:33:10 2000 @@ -1,10 +1,7 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h,v 1.17 1998/09/05 06:36:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_acl.h,v 1.20 2000/12/14 16:33:10 eich Exp $ */ - - - #ifndef _TSENG_ACL_H #define _TSENG_ACL_H @@ -28,64 +25,93 @@ * Shortcuts to Tseng memory-mapped accelerator-control registers */ -extern -ByteP MMU_CONTROL; +#if 0 +#endif -extern -ByteP ACL_SUSPEND_TERMINATE, ACL_OPERATION_STATE, ACL_SYNC_ENABLE, ACL_WRITE_INTERFACE_VALID, - ACL_INTERRUPT_MASK, ACL_INTERRUPT_STATUS, ACL_ACCELERATOR_STATUS; +#define MMU_CONTROL(x) MMIO_OUT8(pTseng->MMioBase, 0x13<<0, x) +#define ACL_SUSPEND_TERMINATE(x) MMIO_OUT8(pTseng->MMioBase, 0x30<<0, x) +#define ACL_OPERATION_STATE(x) MMIO_OUT8(pTseng->MMioBase, 0x31<<0, x) + +#define ACL_SYNC_ENABLE(x) MMIO_OUT8(pTseng->MMioBase, 0x32<<0, x) + /* for ET6000, ACL_SYNC_ENABLE becomes ACL_6K_CONFIG */ + +#define ACL_INTERRUPT_STATUS(x) \ + MMIO_OUT8(pTseng->MMioBase, 0x35<<0, x) +#define ACL_INTERRUPT_MASK(x) MMIO_OUT8(pTseng->MMioBase, 0x34<<0, x) +#define ACL_ACCELERATOR_STATUS (0x36 << 0) +#define ACL_ACCELERATOR_STATUS_SET(x) \ + MMIO_OUT8(pTseng->MMioBase, ACL_ACCELERATOR_STATUS, x) +#define ACL_WRITE_INTERFACE_VALID (0x33 << 0) + + /* and this is only for the ET6000 */ +#define ACL_POWER_CONTROL(x) MMIO_OUT8(pTseng->MMioBase, 0x37<<0, x) + + /* non-queued for w32p's and ET6000 */ +#define ACL_NQ_X_POSITION(x) MMIO_OUT16(pTseng->MMioBase, 0x38<<0, x) +#define ACL_NQ_Y_POSITION(x) MMIO_OUT16(pTseng->MMioBase, 0x3A<<0, x) + /* queued for w32 and w32i */ +#define ACL_X_POSITION(x) MMIO_OUT16(pTseng->MMioBase, 0x94<<0, x) +#define ACL_Y_POSITION(x) MMIO_OUT16(pTseng->MMioBase, 0x96<<0, x) + +#define ACL_PATTERN_ADDRESS(x) MMIO_OUT32(pTseng->MMioBase, 0x80<<0, x) +#define ACL_SOURCE_ADDRESS(x) MMIO_OUT32(pTseng->MMioBase, 0x84<<0, x) + +#define ACL_PATTERN_Y_OFFSET(x) MMIO_OUT16(pTseng->MMioBase, 0x88<<0, x) +#define ACL_PATTERN_Y_OFFSET32(x) MMIO_OUT32(pTseng->MMioBase, 0x88<<0, x) +#define ACL_SOURCE_Y_OFFSET(x) MMIO_OUT16(pTseng->MMioBase, 0x8A<<0, x) +#define ACL_DESTINATION_Y_OFFSET(x) MMIO_OUT16(pTseng->MMioBase, 0x8C<<0, x) + + /* W32i */ +#define ACL_VIRTUAL_BUS_SIZE(x) MMIO_OUT8(pTseng->MMioBase, 0x8E<<0, x) + /* w32p */ +#define ACL_PIXEL_DEPTH(x) MMIO_OUT8(pTseng->MMioBase, 0x8E<<0, x) + + /* w32 and w32i */ +#define ACL_XY_DIRECTION(x) MMIO_OUT8(pTseng->MMioBase, 0x8F<<0, x) + +#define ACL_PATTERN_WRAP(x) MMIO_OUT8(pTseng->MMioBase, 0x90<<0, x) +#define ACL_PATTERN_WRAP32(x) MMIO_OUT32(pTseng->MMioBase, 0x90<<0, x) +#define ACL_TRANSFER_DISABLE(x) MMIO_OUT8(pTseng->MMioBase, 0x91<<0, x) /* ET6000 only */ +#define ACL_SOURCE_WRAP(x) MMIO_OUT8(pTseng->MMioBase, 0x92<<0, x) + +#define ACL_X_COUNT(x) MMIO_OUT16(pTseng->MMioBase, 0x98<<0, x) +#define ACL_Y_COUNT(x) MMIO_OUT16(pTseng->MMioBase, 0x9A<<0, x) +/* shortcut. not a real register */ +#define ACL_XY_COUNT(x) MMIO_OUT32(pTseng->MMioBase, 0x98<<0, x) + +#define ACL_ROUTING_CONTROL(x) MMIO_OUT8(pTseng->MMioBase, 0x9C<<0, x) + /* for ET6000, ACL_ROUTING_CONTROL becomes ACL_MIX_CONTROL */ +#define ACL_RELOAD_CONTROL(x) MMIO_OUT8(pTseng->MMioBase, 0x9D<<0, x) + /* for ET6000, ACL_RELOAD_CONTROL becomes ACL_STEPPING_INHIBIT */ + +#define ACL_BACKGROUND_RASTER_OPERATION(x) MMIO_OUT8(pTseng->MMioBase, 0x9E<<0, x) +#define ACL_FOREGROUND_RASTER_OPERATION(x) MMIO_OUT8(pTseng->MMioBase, 0x9F<<0, x) + +#define ACL_DESTINATION_ADDRESS(x) MMIO_OUT32(pTseng->MMioBase, 0xA0<<0, x) + + /* the following is for the w32p's only */ +#define ACL_MIX_ADDRESS(x) MMIO_OUT32(pTseng->MMioBase, 0xA4<<0, x) + +#define ACL_MIX_Y_OFFSET(x) MMIO_OUT16(pTseng->MMioBase, 0xA8<<0, x) +#define ACL_ERROR_TERM(x) MMIO_OUT16(pTseng->MMioBase, 0xAA<<0, x) +#define ACL_DELTA_MINOR(x) MMIO_OUT16(pTseng->MMioBase, 0xAC<<0, x) +#define ACL_DELTA_MINOR32(x) MMIO_OUT32(pTseng->MMioBase, 0xAC<<0, x) +#define ACL_DELTA_MAJOR(x) MMIO_OUT16(pTseng->MMioBase, 0xAE<<0, x) + + /* ET6000 only (trapezoids) */ +#define ACL_SECONDARY_EDGE(x) MMIO_OUT8(pTseng->MMioBase, 0x93<<0, x) +#define ACL_SECONDARY_ERROR_TERM(x) MMIO_OUT16(pTseng->MMioBase, 0xB2<<0, x) +#define ACL_SECONDARY_DELTA_MINOR(x) MMIO_OUT16(pTseng->MMioBase, 0xB4<<0, x) +#define ACL_SECONDARY_DELTA_MINOR32(x) MMIO_OUT32(pTseng->MMioBase, 0xB4<<0, x) +#define ACL_SECONDARY_DELTA_MAJOR(x) MMIO_OUT16(pTseng->MMioBase, 0xB6<<0, x) /* for ET6000: */ #define ACL_6K_CONFIG ACL_SYNC_ENABLE -extern -WordP ACL_X_POSITION, ACL_Y_POSITION; - -extern -WordP ACL_NQ_X_POSITION, ACL_NQ_Y_POSITION; - -extern -LongP ACL_PATTERN_ADDRESS, ACL_SOURCE_ADDRESS; - -extern -WordP ACL_PATTERN_Y_OFFSET, ACL_SOURCE_Y_OFFSET, ACL_DESTINATION_Y_OFFSET; - -extern -ByteP ACL_VIRTUAL_BUS_SIZE, /* only for w32 and w32i */ - ACL_XY_DIRECTION, ACL_PIXEL_DEPTH; /* only for w32p_rev_A and w32p_rev_B */ - -extern -ByteP ACL_PATTERN_WRAP, ACL_SOURCE_WRAP; - -extern -WordP ACL_X_COUNT, ACL_Y_COUNT; -extern -LongP ACL_XY_COUNT; /* for combined writes to X and Y count registers */ - -extern -ByteP ACL_ROUTING_CONTROL, ACL_RELOAD_CONTROL, ACL_BACKGROUND_RASTER_OPERATION, - ACL_FOREGROUND_RASTER_OPERATION; - /* for ET6000: */ #define ACL_MIX_CONTROL ACL_ROUTING_CONTROL #define ACL_STEPPING_INHIBIT ACL_RELOAD_CONTROL -extern -LongP ACL_DESTINATION_ADDRESS, /* only for w32p_rev_A and w32p_rev_B */ - ACL_MIX_ADDRESS; - -extern -WordP ACL_MIX_Y_OFFSET, ACL_ERROR_TERM, ACL_DELTA_MINOR, ACL_DELTA_MAJOR; - -/* for ET6000 only */ -extern -ByteP ACL_POWER_CONTROL; -extern -ByteP ACL_SECONDARY_EDGE; -extern -WordP ACL_SECONDARY_ERROR_TERM, ACL_SECONDARY_DELTA_MINOR, ACL_SECONDARY_DELTA_MAJOR; -extern -ByteP ACL_TRANSFER_DISABLE; /* * Some data structures for faster accelerator programming. @@ -96,43 +122,6 @@ extern int W32PatternOpTable[16]; /* - * The ping-pong registers. Probably too much hassle for too little gain. "TODO". - */ - -extern long W32ForegroundPing; -extern long W32ForegroundPong; -extern long W32BackgroundPing; -extern long W32BackgroundPong; -extern long W32PatternPing; -extern long W32PatternPong; - -extern LongP MemW32ForegroundPing; -extern LongP MemW32ForegroundPong; -extern LongP MemW32BackgroundPing; -extern LongP MemW32BackgroundPong; -extern LongP MemW32PatternPing; -extern LongP MemW32PatternPong; - -extern unsigned char * tsengCPU2ACLBase; - -/* - * These will hold the ping-pong registers. - */ - -extern LongP tsengMemFg; -extern long tsengFg; - -extern LongP tsengMemBg; -extern long tsengBg; - -extern LongP tsengMemPat; -extern long tsengPat; - -/* for register write optimisation */ -extern int old_x, old_y; -extern int tseng_old_dir; - -/* * Some shortcuts. */ @@ -140,11 +129,11 @@ #undef WAIT_VERBOSE /* if defined: print out how long we waited */ static __inline__ void -tseng_wait(TsengPtr pTseng, ByteP reg, char *name, unsigned char mask) +tseng_wait(TsengPtr pTseng, int reg, char *name, unsigned char mask) { int cnt = MAX_WAIT_CNT; - while (*reg & mask) + while ((MMIO_IN32(pTseng->MMioBase,reg)) & mask) if (--cnt < 0) { ErrorF("WAIT_%s: timeout.\n", name); tseng_recover_timeout(pTseng); @@ -166,39 +155,39 @@ #define SET_FUNCTION_BLT \ if (Is_ET6K) \ - *ACL_MIX_CONTROL = 0x33; \ + ACL_MIX_CONTROL(0x33); \ else \ - *ACL_ROUTING_CONTROL = 0x00; + ACL_ROUTING_CONTROL(0x00); #define SET_FUNCTION_BLT_TR \ - *ACL_MIX_CONTROL = 0x13; + ACL_MIX_CONTROL(0x13); #define FBADDR(pTseng, x,y) ( (y) * pTseng->line_width + MULBPP(pTseng, x) ) #define SET_FG_ROP(rop) \ - *ACL_FOREGROUND_RASTER_OPERATION = W32OpTable[rop]; + ACL_FOREGROUND_RASTER_OPERATION(W32OpTable[rop]); #define SET_FG_ROP_PLANEMASK(rop) \ - *ACL_FOREGROUND_RASTER_OPERATION = W32OpTable_planemask[rop]; + ACL_FOREGROUND_RASTER_OPERATION(W32OpTable_planemask[rop]); #define SET_BG_ROP(rop) \ - *ACL_BACKGROUND_RASTER_OPERATION = W32PatternOpTable[rop]; + ACL_BACKGROUND_RASTER_OPERATION(W32PatternOpTable[rop]); #define SET_BG_ROP_TR(rop, bg_color) \ if ((bg_color) == -1) /* transparent color expansion */ \ - *ACL_BACKGROUND_RASTER_OPERATION = 0xaa; \ + ACL_BACKGROUND_RASTER_OPERATION(0xaa); \ else \ - *ACL_BACKGROUND_RASTER_OPERATION = W32PatternOpTable[rop]; + ACL_BACKGROUND_RASTER_OPERATION(W32PatternOpTable[rop]); #define SET_DELTA(Min, Maj) \ - *((LongP) ACL_DELTA_MINOR) = ((Maj) << 16) + (Min) + ACL_DELTA_MINOR32(((Maj) << 16) + (Min)) #define SET_SECONDARY_DELTA(Min, Maj) \ - *((LongP) ACL_SECONDARY_DELTA_MINOR) = ((Maj) << 16) + (Min) + ACL_SECONDARY_DELTA_MINOR(((Maj) << 16) + (Min)) #ifdef NO_OPTIMIZE #define SET_XYDIR(dir) \ - *ACL_XY_DIRECTION = (dir); + ACL_XY_DIRECTION(dir); #else /* * only changing ACL_XY_DIRECTION when it needs to be changed avoids @@ -206,36 +195,38 @@ * on consecutive small fills. */ #define SET_XYDIR(dir) \ - if ((dir) != tseng_old_dir) \ - *ACL_XY_DIRECTION = tseng_old_dir = (dir); + if ((dir) != pTseng->tseng_old_dir) \ + pTseng->tseng_old_dir = (dir); \ + ACL_XY_DIRECTION(pTseng->tseng_old_dir); #endif #define SET_SECONDARY_XYDIR(dir) \ - *ACL_SECONDARY_EDGE = (dir); + ACL_SECONDARY_EDGE(dir); /* Must do 0x09 (in one operation) for the W32 */ #define START_ACL(pTseng, dst) \ - *(ACL_DESTINATION_ADDRESS) = dst; \ - if (Is_W32 || Is_W32i) *ACL_OPERATION_STATE = 0x09; + ACL_DESTINATION_ADDRESS(dst); \ + if (Is_W32 || Is_W32i) ACL_OPERATION_STATE(0x09); /* START_ACL for the ET6000 */ #define START_ACL_6(dst) \ - *(ACL_DESTINATION_ADDRESS) = dst; + ACL_DESTINATION_ADDRESS(dst); #define START_ACL_CPU(pTseng, dst) \ if (Is_W32 || Is_W32i) \ - *((LongP) (MMioBase + 0x08)) = (CARD32)dst; /* writing to MMU2 will trigger accel at this address */ \ + MMIO_OUT32(pTseng->MMioBase, 0x08<<8,(CARD32)dst); /* writing to MMU2 will trigger accel at this address */ \ else \ - *(ACL_DESTINATION_ADDRESS) = dst; + ACL_DESTINATION_ADDRESS(dst); -/* *(ACL_DESTINATION_ADDRESS) = dst; should be enough for START_ACL_CPU */ +/* ACL_DESTINATION_ADDRESS(dst); should be enough for START_ACL_CPU */ /***********************************************************************/ -void tseng_init_acl(ScreenPtr pScreen); +void tseng_init_acl(ScrnInfoPtr pScrn); Bool TsengXAAInit(ScreenPtr pScreen); Bool TsengXAAInit_Colexp(ScrnInfoPtr pScrn); #endif + Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c:1.3 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c:1.4 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c:1.3 Sun Aug 2 01:17:01 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c Tue Aug 8 04:58:06 2000 @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c,v 1.3 1998/08/02 05:17:01 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_bank.c,v 1.4 2000/08/08 08:58:06 eich Exp $ */ Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c:1.15 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c:1.16 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c:1.15 Wed Jun 21 13:28:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c Tue Aug 8 04:58:06 2000 @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c,v 1.15 2000/06/21 17:28:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c,v 1.16 2000/08/08 08:58:06 eich Exp $ */ Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c:1.10 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c:1.13 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c:1.10 Sat Sep 25 10:37:32 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c Tue Oct 17 12:53:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c,v 1.10 1999/09/25 14:37:32 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_colexp.c,v 1.13 2000/10/17 16:53:18 tsi Exp $ */ @@ -237,8 +237,8 @@ TsengSubsequentCPUToScreenColorExpandFill; /* we'll be using MMU aperture 2 */ - pXAAInfo->ColorExpandBase = tsengCPU2ACLBase; - /* ErrorF("tsengCPU2ACLBase = 0x%x\n", tsengCPU2ACLBase); */ + pXAAInfo->ColorExpandBase = (CARD8 *)pTseng->tsengCPU2ACLBase; + /* ErrorF("tsengCPU2ACLBase = 0x%x\n", pTseng->tsengCPU2ACLBase); */ /* aperture size is 8kb in banked mode. Larger in linear mode, but 8kb is enough */ pXAAInfo->ColorExpandRange = 8192; } @@ -248,22 +248,19 @@ #define SET_FUNCTION_COLOREXPAND \ if (Is_ET6K) \ - *ACL_MIX_CONTROL = 0x32; \ + ACL_MIX_CONTROL(0x32); \ else \ - *ACL_ROUTING_CONTROL = 0x08; + ACL_ROUTING_CONTROL(0x08); #define SET_FUNCTION_COLOREXPAND_CPU \ - *ACL_ROUTING_CONTROL = 0x02; + ACL_ROUTING_CONTROL(0x02); static CARD32 ColorExpandDst; static int ce_skipleft; static int colexp_width_dwords; static int colexp_width_bytes; -extern long MMioBase; - - void TsengSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft) @@ -282,7 +279,7 @@ wait_acl_queue(pTseng); #if 0 - *ACL_MIX_Y_OFFSET = w - 1; + ACL_MIX_Y_OFFSET(w - 1); ErrorF(" W=%d", w); #endif @@ -297,7 +294,7 @@ wait_acl_queue(pTseng); - *ACL_MIX_ADDRESS = (pTseng->AccelColorExpandBufferOffsets[bufno] << 3) + ce_skipleft; + ACL_MIX_ADDRESS((pTseng->AccelColorExpandBufferOffsets[bufno] << 3) + ce_skipleft); START_ACL(pTseng, ColorExpandDst); /* move to next scanline */ @@ -326,8 +323,8 @@ void TsengSubsequentColorExpandScanline_8bpp(ScrnInfoPtr pScrn, int bufno) { TsengPtr pTseng = TsengPTR(pScrn); - CARD8 *dest = (CARD8 *) tsengCPU2ACLBase; - int i; + pointer dest = pTseng->tsengCPU2ACLBase; + int i,j; CARD8 *bufptr; i = colexp_width_bytes; @@ -337,11 +334,11 @@ START_ACL (pTseng, ColorExpandDst); /* *((LongP) (MMioBase + 0x08)) = (CARD32) ColorExpandDst;*/ -/* *(CARD32*)tsengCPU2ACLBase = (CARD32)ColorExpandDst; */ - +/* MMIO_OUT32(tsengCPU2ACLBase,0, (CARD32)ColorExpandDst); */ + j = 0; /* Copy scanline data to accelerator MMU aperture byte by byte */ while (i--) { /* FIXME: we need to take care of PCI bursting and MMU overflow here! */ - *dest++ = *bufptr++; + MMIO_OUT8(dest,j++, *bufptr++); } /* move to next scanline */ @@ -357,21 +354,22 @@ void TsengSubsequentColorExpandScanline_16bpp(ScrnInfoPtr pScrn, int bufno) { TsengPtr pTseng = TsengPTR(pScrn); - CARD8 *dest = (CARD8 *) tsengCPU2ACLBase; - int i; + pointer dest = pTseng->tsengCPU2ACLBase; + int i,j; CARD8 *bufptr; register CARD32 bits16; - + i = colexp_width_dwords * 2; bufptr = (CARD8 *) (pTseng->XAAScanlineColorExpandBuffers[bufno]); wait_acl_queue(pTseng); START_ACL(pTseng, ColorExpandDst); + j = 0; while (i--) { bits16 = pTseng->ColExpLUT[*bufptr++]; - *dest++ = bits16 & 0xFF; - *dest++ = (bits16 >> 8) & 0xFF; + MMIO_OUT8(dest,j++,bits16 & 0xFF); + MMIO_OUT8(dest,j++,(bits16 >> 8) & 0xFF); } /* move to next scanline */ @@ -387,8 +385,8 @@ void TsengSubsequentColorExpandScanline_24bpp(ScrnInfoPtr pScrn, int bufno) { TsengPtr pTseng = TsengPTR(pScrn); - CARD8 *dest = (CARD8 *) tsengCPU2ACLBase; - int i, j = -1; + pointer dest = pTseng->tsengCPU2ACLBase; + int i, k, j = -1; CARD8 *bufptr; register CARD32 bits24; @@ -400,12 +398,13 @@ /* take 8 input bits, expand to 3 output bytes */ bits24 = pTseng->ColExpLUT[*bufptr++]; + k = 0; while (i--) { if ((j++) == 2) { /* "i % 3" operation is much to expensive */ j = 0; bits24 = pTseng->ColExpLUT[*bufptr++]; } - *dest++ = bits24 & 0xFF; + MMIO_OUT8(dest,k++,bits24 & 0xFF); bits24 >>= 8; } @@ -422,8 +421,8 @@ void TsengSubsequentColorExpandScanline_32bpp(ScrnInfoPtr pScrn, int bufno) { TsengPtr pTseng = TsengPTR(pScrn); - CARD8 *dest = (CARD8 *) tsengCPU2ACLBase; - int i; + pointer dest = pTseng->tsengCPU2ACLBase; + int i,j; CARD8 *bufptr; register CARD32 bits32; @@ -433,12 +432,13 @@ wait_acl_queue(pTseng); START_ACL(pTseng, ColorExpandDst); + j = 0; while (i--) { bits32 = pTseng->ColExpLUT[*bufptr++]; - *dest++ = bits32 & 0xFF; - *dest++ = (bits32 >> 8) & 0xFF; - *dest++ = (bits32 >> 16) & 0xFF; - *dest++ = (bits32 >> 24) & 0xFF; + MMIO_OUT8(dest,j++,bits32 & 0xFF); + MMIO_OUT8(dest,j++,(bits32 >> 8) & 0xFF); + MMIO_OUT8(dest,j++,(bits32 >> 16) & 0xFF); + MMIO_OUT8(dest,j++,(bits32 >> 24) & 0xFF); } /* move to next scanline */ @@ -457,7 +457,7 @@ /* ErrorF("X"); */ - PINGPONG(); + PINGPONG(pTseng); wait_acl_queue(pTseng); @@ -471,7 +471,7 @@ SET_FUNCTION_COLOREXPAND_CPU; /* assure correct alignment of MIX address (ACL needs same alignment here as in MMU aperture) */ - *ACL_MIX_ADDRESS = 0; + ACL_MIX_ADDRESS(0); } /* @@ -498,7 +498,7 @@ ErrorF("=========WAIT FIXME!\n"); WAIT_INTERFACE; - *ACL_MIX_Y_OFFSET = w - 1; + ACL_MIX_Y_OFFSET(w - 1); SET_XY(pTseng, w, h); START_ACL(pTseng, destaddr); } @@ -512,7 +512,7 @@ /* ErrorF("SSC "); */ - PINGPONG(); + PINGPONG(pTseng); wait_acl_queue(pTseng); @@ -538,10 +538,10 @@ wait_acl_queue(pTseng); SET_XY(pTseng, w, h); - *ACL_MIX_ADDRESS = /* MIX address is in BITS */ - (((srcy * pScrn->displayWidth) + srcx) * pScrn->bitsPerPixel) + skipleft; + ACL_MIX_ADDRESS( /* MIX address is in BITS */ + (((srcy * pScrn->displayWidth) + srcx) * pScrn->bitsPerPixel) + skipleft); - *ACL_MIX_Y_OFFSET = pTseng->line_width << 3; + ACL_MIX_Y_OFFSET(pTseng->line_width << 3); START_ACL(pTseng, destaddr); } Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c:1.14 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c:1.16 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c:1.14 Sat Aug 29 10:34:39 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c Tue Sep 19 08:46:19 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c,v 1.14 1998/08/29 14:34:39 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_cursor.c,v 1.16 2000/09/19 12:46:19 eich Exp $ */ @@ -20,8 +20,6 @@ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; TsengPtr pTseng = TsengPTR(pScrn); xf86CursorInfoPtr infoPtr; - int iobase = VGAHW_GET_IOBASE(); - unsigned char tmp; PDEBUG(" TsengHWCursorInit\n"); @@ -53,44 +51,6 @@ ErrorF("banked HW cursor not implemented yet!\n"); #endif } - /* - * Program the cursor image address in video memory. This never changes - * once the server has started, so we can set it here, once. The adress - * is given in doublewords. - */ - if (Is_ET6K) { - /* bits 19:16 */ - outb(iobase + 0x04, 0x0E); - tmp = inb(iobase + 0x05) & 0xF0; - outb(iobase + 0x05, tmp | (((pTseng->HWCursorBufferOffset / 4) >> 16) & 0x0F)); - /* bits 15:8 */ - outb(iobase + 0x04, 0x0F); - outb(iobase + 0x05, ((pTseng->HWCursorBufferOffset / 4) >> 8) & 0xFF); - /* on the ET6000, bits (7:0) are always 0 */ - } else { - /* bits 19:16 */ - outb(0x217A, 0xEA); - tmp = inb(0x217B) & 0xF0; - outb(0x217B, tmp | (((pTseng->HWCursorBufferOffset / 4) >> 16) & 0x0F)); - /* bits 15:8 */ - outb(0x217A, 0xE9); - outb(0x217B, ((pTseng->HWCursorBufferOffset / 4) >> 8) & 0xFF); - /* bits 7:0 */ - outb(0x217A, 0xE8); - outb(0x217B, (pTseng->HWCursorBufferOffset / 4) & 0xFF); - - /* this needs to be set for the sprite */ - outb(0x217A, 0xEB); - outb(0x217B, 2); - outb(0x217A, 0xEC); - tmp = inb(0x217B); - outb(0x217B, tmp & 0xFE); - outb(0x217A, 0xEF); - tmp = inb(0x217B); - outb(0x217B, (tmp & 0xF8) | 0x02); - outb(0x217A, 0xEE); - outb(0x217B, 1); - } /* set up the XAA HW cursor structure */ infoPtr->MaxWidth = 64; @@ -250,6 +210,8 @@ { TsengPtr pTseng = TsengPTR(pScrn); + int iobase = VGAHW_GET_IOBASE(); + unsigned char tmp; #ifdef DEBUG_HWC int i; int d; @@ -261,6 +223,49 @@ ErrorF("\n"); } #endif + /* + * Program the cursor image address in video memory. + * We need to set it here or we might loose it on mode/vt switches. + */ + + if (Is_ET6K) { + /* bits 19:16 */ + outb(iobase + 0x04, 0x0E); + tmp = inb(iobase + 0x05) & 0xF0; + outb(iobase + 0x05, tmp | (((pTseng->HWCursorBufferOffset / 4) >> 16) & 0x0F)); + /* bits 15:8 */ + outb(iobase + 0x04, 0x0F); + outb(iobase + 0x05, ((pTseng->HWCursorBufferOffset / 4) >> 8) & 0xFF); + /* on the ET6000, bits (7:0) are always 0 */ + } else { + /* bits 19:16 */ + outb(0x217A, 0xEA); + tmp = inb(0x217B) & 0xF0; + outb(0x217B, tmp | (((pTseng->HWCursorBufferOffset / 4) >> 16) & 0x0F)); + /* bits 15:8 */ + outb(0x217A, 0xE9); + outb(0x217B, ((pTseng->HWCursorBufferOffset / 4) >> 8) & 0xFF); + /* bits 7:0 */ + outb(0x217A, 0xE8); + outb(0x217B, (pTseng->HWCursorBufferOffset / 4) & 0xFF); + + /* this needs to be set for the sprite */ + outb(0x217A, 0xEB); + outb(0x217B, 2); + outb(0x217A, 0xEC); + tmp = inb(0x217B); + outb(0x217B, tmp & 0xFE); + outb(0x217A, 0xEF); + tmp = inb(0x217B); + outb(0x217B, (tmp & 0xF8) | 0x02); + outb(0x217A, 0xEE); + outb(0x217B, 1); + } /* this assumes the apertures have been set up correctly for banked mode */ memcpy(pTseng->HWCursorBuffer, bits, 1024); } + + + + + Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dga.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dga.c:1.1 --- /dev/null Mon Dec 18 14:31:18 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dga.c Wed Dec 6 10:35:24 2000 @@ -0,0 +1,250 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dga.c,v 1.1 2000/12/06 15:35:24 eich Exp $ */ +/* + * Copyright 2000 by Rainer Keller, <Rainer.Keller@studmail.uni-stuttgart.de>. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Adapted from: Alan Hourihane, <alanh@fairlite.demon.co.uk> + * by: Rainer Keller, <Rainer.Keller@studmail.uni-stuttgart.de> + */ + +#include "tseng.h" +#include "dgaproc.h" + +static Bool Tseng_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool Tseng_SetMode(ScrnInfoPtr, DGAModePtr); +static void Tseng_Sync(ScrnInfoPtr); +static int Tseng_GetViewport(ScrnInfoPtr); +static void Tseng_SetViewport(ScrnInfoPtr, int, int, int); +static void Tseng_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void Tseng_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +/* +static void Tseng_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); +*/ + +static +DGAFunctionRec TsengDGAFuncs = { + Tseng_OpenFramebuffer, + NULL, /* Tseng_CloseFramebuffer */ + Tseng_SetMode, + Tseng_SetViewport, + Tseng_GetViewport, + Tseng_Sync, + Tseng_FillRect, + Tseng_BlitRect, + NULL /* Tseng_BlitTransRect */ +}; + + + + +Bool +TsengDGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + TsengPtr pTseng = TsengPTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + int imlines = (pScrn->videoRam * 1024) / + (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); + + + if (!pTseng->UseLinMem) + return FALSE; + + if (!pTseng->DGAnumModes) { + ErrorF("DGAINIT\n"); + pMode = firstMode = pScrn->modes; + while (pMode) { + newmodes = xrealloc(modes, (num + 1) * sizeof (DGAModeRec)); + if (!newmodes) { + xfree(modes); + return FALSE; + } + modes = newmodes; + currentMode = modes + num; + num++; + (void)memset(currentMode, 1, sizeof(DGAModeRec)); + currentMode->mode = pMode; + currentMode->flags = DGA_PIXMAP_AVAILABLE + | ((pTseng->UseAccel) ? (DGA_FILL_RECT | DGA_BLIT_RECT) : 0); + if (pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if(pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 1; /* The granularity of x and y pos. */ + currentMode->yViewportStep = 1; + currentMode->viewportFlags = 0 /*DGA_FLIP_RETRACE*/; + currentMode->offset = 0; + currentMode->address = pTseng->FbBase; + currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 3) & ~3L; + currentMode->pixmapWidth = currentMode->imageWidth = pScrn->displayWidth; + currentMode->pixmapHeight = currentMode->imageHeight = imlines; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + + pMode = pMode->next; + if(pMode == firstMode) + break; + } + pTseng->DGAnumModes = num; + pTseng->DGAModes = modes; + } + return DGAInit(pScreen, &TsengDGAFuncs, pTseng->DGAModes, pTseng->DGAnumModes); +} + +static Bool +Tseng_OpenFramebuffer( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + TsengPtr pTseng = TsengPTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)pTseng->LinFbAddress; + *size = pTseng->FbMapSize; + *offset = 0; /* Always */ + *flags = 0; /* Root permissions OS-dependent */ + + return TRUE; +} + + +static Bool +Tseng_SetMode( + ScrnInfoPtr pScrn, + DGAModePtr pMode +){ + TsengPtr pTseng = TsengPTR(pScrn); + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + Bool ret; + + if(!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + pScrn->displayWidth = OldDisplayWidth[index]; + ret = TsengModeInit(xf86Screens[index], pScrn->currentMode); + pTseng->DGAactive = FALSE; + } else { + if(!pTseng->DGAactive) { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + + pTseng->DGAactive = TRUE; + } + pScrn->displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + + ret = TsengModeInit(xf86Screens[index], pMode->mode); + } + return ret; +} + +static void +Tseng_SetViewport( + ScrnInfoPtr pScrn, + int x, int y, + int flags +){ + TsengPtr pTseng = TsengPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); + + TsengAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + while((hwp->readST01(hwp) & 0x08)); + while(!(hwp->readST01(hwp) & 0x08)); + + pTseng->DGAViewportStatus = 0; /* TsengAdjustFrame loops until finished */ +} + +static int +Tseng_GetViewport( + ScrnInfoPtr pScrn +){ + TsengPtr pTseng = TsengPTR(pScrn); + + return pTseng->DGAViewportStatus; +} + + + +static void +Tseng_Sync( + ScrnInfoPtr pScrn +){ + TsengPtr pTseng = TsengPTR(pScrn); + + if(pTseng->AccelInfoRec) { + (*pTseng->AccelInfoRec->Sync)(pScrn); + } +} + +static void +Tseng_FillRect ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color +){ + TsengPtr pTseng = TsengPTR(pScrn); + + if(pTseng->AccelInfoRec) { + (*pTseng->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*pTseng->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(pTseng->AccelInfoRec); + } +} + +static void +Tseng_BlitRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + TsengPtr pTseng = TsengPTR(pScrn); + + if(pTseng->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pTseng->AccelInfoRec->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, ~0, -1); + (*pTseng->AccelInfoRec->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(pTseng->AccelInfoRec); + } +} Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c:1.8 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c:1.9 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c:1.8 Sat Jun 12 03:18:58 1999 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c Tue Aug 8 04:58:06 2000 @@ -1,5 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c,v 1.8 1999/06/12 07:18:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_dpms.c,v 1.9 2000/08/08 08:58:06 eich Exp $ */ Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c:1.69 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c:1.79 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c:1.69 Mon Apr 17 12:30:09 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c Thu Dec 14 11:33:10 2000 @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.69 2000/04/17 16:30:09 eich Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.79 2000/12/14 16:33:10 eich Exp $ * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -43,17 +43,11 @@ /* All drivers implementing backing store need this */ #include "mibstore.h" -/* - * If using cfb, cfb.h is required. Select the others for the bpp values - * the driver supports. - */ -#define PSZ 8 /* needed for cfb.h */ -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb24.h" -#include "cfb32.h" -#include "cfb24_32.h" +#include "fb.h" +#ifdef RENDER +#include "picturestr.h" +#endif + #include "xf86RAC.h" #include "xf86Resources.h" #include "xf86int10.h" @@ -81,9 +75,6 @@ /* Required if the driver supports mode switching */ static Bool TsengSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); -/* Required if the driver supports moving the viewport */ -static void TsengAdjustFrame(int scrnIndex, int x, int y, int flags); - /* Optional functions */ static void TsengFreeScreen(int scrnIndex, int flags); static ModeStatus TsengValidMode(int scrnIndex, DisplayModePtr mode, @@ -97,7 +88,6 @@ static Bool TsengUnmapMem(ScrnInfoPtr pScrn); static void TsengSave(ScrnInfoPtr pScrn); static void TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg, int flags); -static Bool TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static void TsengUnlock(void); static void TsengLock(void); @@ -226,6 +216,53 @@ {0}, FALSE} }; +static const char *int10Symbols[] = { + "xf86InitInt10", + "xf86FreeInt10", + NULL +}; + +static const char *vgaHWSymbols[] = { + "vgaHWMapMem", + "vgaHWUnmapMem", + "vgaHWGetHWRec", + "vgaHWGetIOBase", + "vgaHWHandleColormaps", + "vgaHWUnlock", + "vgaHWLock", + "vgaHWSaveScreen", + "vgaHWInit", + "vgaHWSave", + "vgaHWRestore", + "vgaHWBlankScreen", + "vgaHWSeqReset", + "vgaHWProtect", + NULL +}; + +static const char* fbSymbols[] = { + "xf1bppScreenInit", + "xf4bppScreenInit", + "fbScreenInit", + "fbScreenInit", + "fbPictureInit", + NULL +}; + +static const char *ramdacSymbols[] = { + "xf86InitCursor", + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + NULL +}; + +static const char *xaaSymbols[] = { + "XAADestroyInfoRec", + "XAACreateInfoRec", + "XAAInit", + NULL +}; + #ifdef XFree86LOADER static MODULESETUPPROTO(tsengSetup); @@ -264,6 +301,12 @@ * Modules that this driver always requires can be loaded here * by calling LoadSubModule(). */ + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(vgaHWSymbols, fbSymbols, xaaSymbols, + ramdacSymbols, NULL); /* * The return value must be non-NULL on success even though there @@ -411,6 +454,7 @@ * This code is only called when the chipset is not given beforehand, * and if the PCI code hasn't detected one previously. */ +#if 0 static Bool ET4000MinimalProbe(void) { @@ -450,6 +494,7 @@ } return TRUE; } +#endif static int TsengFindIsaDevice(GDevPtr dev) @@ -462,7 +507,7 @@ TsengProbe(DriverPtr drv, int flags) { int i; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int numDevSections; int numUsed; int *usedChips = NULL; @@ -523,8 +568,8 @@ TsengAssignFPtr(pScrn); foundScreen = TRUE; } - xfree(usedChips); } + xfree(usedChips); } } @@ -546,8 +591,7 @@ } xfree(usedChips); } - if (devSections) - xfree(devSections); + xfree(devSections); return foundScreen; } @@ -1218,11 +1262,13 @@ "Hardware Cursor not supported on this chipset\n"); pTseng->HWCursor = FALSE; } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", pTseng->HWCursor ? "HW" : "SW"); if (pScrn->bitsPerPixel >= 8) { - pTseng->UseAccel = TRUE; + if (pTseng->ChipType != TYPE_ET4000) + pTseng->UseAccel = TRUE; if (xf86ReturnOptValBool(TsengOptions, OPTION_NOACCEL, FALSE)) { pTseng->UseAccel = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); @@ -1457,7 +1503,6 @@ TsengPtr pTseng; MessageType from; int i; - char *mod = NULL; if (flags & PROBE_DETECT) return FALSE; @@ -1494,6 +1539,7 @@ #if 1 if (xf86LoadSubModule(pScrn, "int10")) { xf86Int10InfoPtr pInt; + xf86LoaderReqSymLists(int10Symbols, NULL); #if 1 xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); pInt = xf86InitInt10(pTseng->pEnt->index); @@ -1504,7 +1550,7 @@ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - + xf86LoaderReqSymLists(vgaHWSymbols, NULL); /* * Allocate a vgaHWRec */ @@ -1655,17 +1701,8 @@ } } /* Set the default visual. */ - if (!xf86SetDefaultVisual(pScrn, -1)) { + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; - } else { - /* Tseng doesn't support DirectColor at > 8bpp */ - if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" - " (%s) is not supported at depth %d\n", - xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - return FALSE; - } - } /* The gamma fields must be initialised when using the new cmap code */ if (pScrn->depth > 1) { @@ -1779,43 +1816,47 @@ /* Load bpp-specific modules */ switch (pScrn->bitsPerPixel) { case 1: - mod = "xf1bpp"; + if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf1bppScreenInit", NULL); break; case 4: - mod = "xf4bpp"; - break; - case 8: - mod = "cfb"; - break; - case 16: - mod = "cfb16"; - break; - case 24: - if (pix24bpp == 24) - mod = "cfb24"; - else - mod = "xf24_32bpp"; - break; - case 32: - mod = "cfb32"; + if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("xf4bppScreenInit", NULL); break; - } - if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { - TsengFreeRec(pScrn); - return FALSE; + default: + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + TsengFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymbols("fbScreenInit", NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + break; } + /* Load XAA if needed */ - if (pTseng->UseAccel) + if (pTseng->UseAccel) { if (!xf86LoadSubModule(pScrn, "xaa")) { TsengFreeRec(pScrn); return FALSE; } + xf86LoaderReqSymLists(xaaSymbols, NULL); + } /* Load ramdac if needed */ - if (pTseng->HWCursor) + if (pTseng->HWCursor) { if (!xf86LoadSubModule(pScrn, "ramdac")) { TsengFreeRec(pScrn); return FALSE; } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + } /* TsengLock(); */ return TRUE; @@ -1960,11 +2001,10 @@ pScrn = xf86Screens[pScreen->myNum]; pTseng = TsengPTR(pScrn); - /* Map the Tseng memory areas */ if (!TsengMapMem(pScrn)) return FALSE; - + /* Save the current state */ TsengSave(pScrn); @@ -1978,18 +2018,6 @@ /* XXX Fill the screen with black */ /* - * The next step is to setup the screen's visuals, and initialise the - * framebuffer code. In cases where the framebuffer's default - * choices for things like visual layouts and bits per RGB are OK, - * this may be as simple as calling the framebuffer's ScreenInit() - * function. If not, the visuals will need to be setup before calling - * a fb ScreenInit() function and fixed up after. - * - * For most PC hardware at depths >= 8, the defaults that cfb uses - * are not appropriate. In this driver, we fixup the visuals after. - */ - - /* * Reset visual list. */ miClearVisualTypes(); @@ -2001,17 +2029,11 @@ * support TrueColor and not DirectColor. To deal with this, call * miSetVisualTypes for each visual supported. */ + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + pScrn->defaultVisual)) + return FALSE; - if (pScrn->depth > 8) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, - pScrn->defaultVisual)) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, - miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - } + miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other @@ -2031,43 +2053,26 @@ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth); break; - case 8: - ret = cfbScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 16: - ret = cfb16ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 24: - if (pix24bpp == 24) - ret = cfb24ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - else - ret = cfb24_32ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; - case 32: - ret = cfb32ScreenInit(pScreen, pTseng->FbBase, pScrn->virtualX, - pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, - pScrn->displayWidth); - break; default: - xf86DrvMsg(scrnIndex, X_ERROR, - "Internal error: invalid bpp (%d) in TsengScrnInit\n", - pScrn->bitsPerPixel); - ret = FALSE; + ret = fbScreenInit(pScreen, pTseng->FbBase, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel); +#ifdef RENDER + if (ret) + fbPictureInit(pScreen, 0, 0); +#endif break; } + if (!ret) return FALSE; xf86SetBlackWhitePixels(pScreen); + if (pScrn->depth >= 8) + TsengDGAInit(pScreen); + if (pScrn->bitsPerPixel > 8) { /* Fixup RGB ordering */ visual = pScreen->visuals + pScreen->numVisuals; @@ -2114,13 +2119,14 @@ */ TsengSetupAccelMemory(scrnIndex, pScreen); if (pTseng->UseAccel) { - tseng_init_acl(pScreen); /* set up accelerator */ + tseng_init_acl(pScrn); /* set up accelerator */ if (!TsengXAAInit(pScreen)) { /* set up XAA interface */ return FALSE; } } miInitializeBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); @@ -2135,7 +2141,7 @@ if (!miCreateDefColormap(pScreen)) return FALSE; - if (pScrn->depth == 4 || pScrn->depth == 8) { /* cfb and xf4bpp */ + if (pScrn->depth == 4 || pScrn->depth == 8) { /* fb and xf4bpp */ vgaHWHandleColormaps(pScreen); } pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; @@ -2170,13 +2176,19 @@ TsengEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + TsengPtr pTseng = TsengPTR(pScrn); PDEBUG(" TsengEnterVT\n"); vgaHWUnlock(VGAHWPTR(pScrn)); TsengUnlock(); - return TsengModeInit(pScrn, pScrn->currentMode); + if (!TsengModeInit(pScrn, pScrn->currentMode)) + return FALSE; + if (pTseng->UseAccel) { + tseng_init_acl(pScrn); /* set up accelerator */ + } + return TRUE; } static void @@ -2297,10 +2309,37 @@ "Could not mmap linear video memory.\n"); return FALSE; } + if (pTseng->UseAccel) { + pTseng->MMioBase = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO, + pTseng->PciTag, + (unsigned long)pTseng->LinFbAddress, + pTseng->FbMapSize); + if (!pTseng->MMioBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Could not mmap mmio memory.\n"); + return FALSE; + } + pTseng->MMioBase += 0x3FFF00L; + } } else { - pTseng->FbBase = VGAHWPTR(pScrn)->Base; + vgaHWPtr hwp = VGAHWPTR(pScrn); + pTseng->FbBase = hwp->Base; + if (pTseng->UseAccel) { + pTseng->MMioBase = xf86MapPciMem(pScrn->scrnIndex, + VIDMEM_MMIO, + pTseng->PciTag, + (unsigned long)hwp->MapPhys, + hwp->MapSize); + if (!pTseng->MMioBase) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Could not mmap mmio memory.\n"); + return FALSE; + } + pTseng->MMioBase += 0x1FF00L; + } } - + if (pTseng->FbBase == NULL) return FALSE; @@ -2333,7 +2372,7 @@ TsengFreeRec(xf86Screens[scrnIndex]); } -static Bool +Bool TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { vgaHWPtr hwp; @@ -2677,7 +2716,7 @@ /* * adjust the current video frame (viewport) to display the mousecursor. */ -static void +void TsengAdjustFrame(int scrnIndex, int x, int y, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h:1.6 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h:1.8 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h:1.6 Sat Sep 5 02:36:56 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h Tue Aug 8 04:58:07 2000 @@ -1,9 +1,5 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h,v 1.6 1998/09/05 06:36:56 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_inline.h,v 1.8 2000/08/08 08:58:07 eich Exp $ */ - - - - #include "tseng.h" /* @@ -36,30 +32,31 @@ static __inline__ void SET_FG_COLOR(TsengPtr pTseng, int color) { - *ACL_SOURCE_ADDRESS = tsengFg; - *ACL_SOURCE_Y_OFFSET = 3; + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengFg); + ACL_SOURCE_Y_OFFSET(3); color = COLOR_REPLICATE_DWORD(pTseng, color); - *tsengMemFg = color; + MMIO_OUT32(pTseng->scratchMemBase, pTseng->tsengFg, color); + if (Is_W32p || Is_ET6K) { - *ACL_SOURCE_WRAP = 0x02; + ACL_SOURCE_WRAP(0x02); } else { - *(tsengMemFg + 1) = color; - *ACL_SOURCE_WRAP = 0x12; + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengFg + 4, color); + ACL_SOURCE_WRAP(0x12); } } static __inline__ void SET_BG_COLOR(TsengPtr pTseng, int color) { - *ACL_PATTERN_ADDRESS = tsengPat; - *ACL_PATTERN_Y_OFFSET = 3; + ACL_PATTERN_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengPat); + ACL_PATTERN_Y_OFFSET(3); color = COLOR_REPLICATE_DWORD(pTseng, color); - *tsengMemPat = color; + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengPat, color); if (Is_W32p || Is_ET6K) { - *ACL_PATTERN_WRAP = 0x02; + ACL_PATTERN_WRAP(0x02); } else { - *(tsengMemPat + 1) = color; - *ACL_PATTERN_WRAP = 0x12; + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengPat + 4, color); + ACL_PATTERN_WRAP(0x12); } } @@ -72,19 +69,19 @@ static __inline__ void SET_FG_BG_COLOR(TsengPtr pTseng, int fgcolor, int bgcolor) { - *ACL_PATTERN_ADDRESS = tsengPat; - *ACL_SOURCE_ADDRESS = tsengFg; - *((LongP) ACL_PATTERN_Y_OFFSET) = 0x00030003; + ACL_PATTERN_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengPat); + ACL_SOURCE_ADDRESS(pTseng->AccelColorBufferOffset + pTseng->tsengFg); + ACL_PATTERN_Y_OFFSET32(0x00030003); fgcolor = COLOR_REPLICATE_DWORD(pTseng, fgcolor); bgcolor = COLOR_REPLICATE_DWORD(pTseng, bgcolor); - *tsengMemFg = fgcolor; - *tsengMemPat = bgcolor; + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengFg, fgcolor); + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengPat, bgcolor); if (Is_W32p || Is_ET6K) { - *((LongP) ACL_PATTERN_WRAP) = 0x00020002; + ACL_PATTERN_WRAP32(0x00020002); } else { - *(tsengMemFg + 1) = fgcolor; - *(tsengMemPat + 1) = bgcolor; - *((LongP) ACL_PATTERN_WRAP) = 0x00120012; + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengFg + 4, fgcolor); + MMIO_OUT32(pTseng->scratchMemBase,pTseng->tsengPat + 4, bgcolor); + ACL_PATTERN_WRAP32(0x00120012); } } @@ -115,7 +112,7 @@ { int new_x, xy; - if ((old_y == y) && (old_x == x)) + if ((pTseng->old_y == y) && (pTseng->old_x == x)) return -1; if (Is_W32p) @@ -123,8 +120,8 @@ else new_x = MULBPP(pTseng, x) - 1; xy = ((y - 1) << 16) + new_x; - old_x = x; - old_y = y; + pTseng->old_x = x; + pTseng->old_y = y; return xy; } @@ -138,9 +135,9 @@ new_x = MULBPP(pTseng, x - 1); else new_x = MULBPP(pTseng, x) - 1; - *ACL_XY_COUNT = ((y - 1) << 16) + new_x; - old_x = x; - old_y = y; + ACL_XY_COUNT(((y - 1) << 16) + new_x); + pTseng->old_x = x; + pTseng->old_y = y; } static __inline__ void @@ -152,9 +149,9 @@ new_x = MULBPP(pTseng, x - 1); else new_x = MULBPP(pTseng, x) - 1; - *ACL_XY_COUNT = (y << 16) + new_x; - old_x = x; - old_y = y - 1; /* old_y is invalid (raw transfer) */ + ACL_XY_COUNT((y << 16) + new_x); + pTseng->old_x = x; + pTseng->old_y = y - 1; /* old_y is invalid (raw transfer) */ } /* @@ -172,11 +169,11 @@ { int new_xy; - if ((old_y != y) || (old_x != x)) { + if ((pTseng->old_y != y) || (pTseng->old_x != x)) { new_xy = ((y - 1) << 16) + MULBPP(pTseng, x - 1); - *ACL_XY_COUNT = new_xy; - old_x = x; - old_y = y; + ACL_XY_COUNT(new_xy); + pTseng->old_x = x; + pTseng->old_y = y; } } @@ -185,45 +182,39 @@ { int new_xy; /* using this intermediate variable is faster */ - if ((old_y != y) || (old_x != x)) { + if ((pTseng->old_y != y) || (pTseng->old_x != x)) { new_xy = ((y - 1) << 16) + MULBPP(pTseng, x) - 1; - *ACL_XY_COUNT = new_xy; - old_x = x; - old_y = y; + ACL_XY_COUNT(new_xy); + pTseng->old_x = x; + pTseng->old_y = y; } } /* generic SET_XY_RAW */ static __inline__ void -SET_XY_RAW(int x, int y) +SET_XY_RAW(TsengPtr pTseng,int x, int y) { - *ACL_XY_COUNT = (y << 16) + x; - old_x = old_y = -1; /* invalidate old_x/old_y (raw transfers) */ + ACL_XY_COUNT((y << 16) + x); + pTseng->old_x = pTseng->old_y = -1; /* invalidate old_x/old_y (raw transfers) */ } static __inline__ void -PINGPONG(void) +PINGPONG(TsengPtr pTseng) { - if (tsengFg == W32ForegroundPing) { - tsengMemFg = MemW32ForegroundPong; - tsengFg = W32ForegroundPong; - tsengMemBg = MemW32BackgroundPong; - tsengBg = W32BackgroundPong; - tsengMemPat = MemW32PatternPong; - tsengPat = W32PatternPong; + if (pTseng->tsengFg == 0) { + pTseng->tsengFg = 8; + pTseng->tsengBg = 24; + pTseng->tsengPat = 40; } else { - tsengMemFg = MemW32ForegroundPing; - tsengFg = W32ForegroundPing; - tsengMemBg = MemW32BackgroundPing; - tsengBg = W32BackgroundPing; - tsengMemPat = MemW32PatternPing; - tsengPat = W32PatternPing; + pTseng->tsengFg = 0; + pTseng->tsengBg = 16; + pTseng->tsengPat = 32; } } /* * This is called in each ACL function just before the first ACL register is - * written to. It waits for the accelerator to finish on cards that don't +x * written to. It waits for the accelerator to finish on cards that don't * support hardware-wait-state locking, and waits for a free queue entry on * others, if hardware-wait-states are not enabled. */ @@ -235,4 +226,3 @@ if (pTseng->need_wait_acl) WAIT_ACL; } - Index: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c diff -u xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c:1.22 xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c:1.24 --- xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c:1.22 Wed Aug 19 10:05:04 1998 +++ xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c Wed Dec 6 10:35:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c,v 1.22 1998/08/19 14:05:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_ramdac.c,v 1.24 2000/12/06 15:35:25 eich Exp $ */ @@ -618,6 +618,8 @@ cmd_array = CMD_MU4910; cmd_dest = &(pTseng->ModeReg.ATTdac_cmd); break; + default: + break; } if (cmd_array != NULL) { Index: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp:1.4 xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp:1.4 Tue Jun 13 22:13:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp Mon Dec 11 15:18:40 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp,v 1.4 2000/06/14 02:13:16 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp,v 1.5 2000/12/11 20:18:40 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH V4L __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH V4L __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME v4l \- Video 4 Linux driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile:1.2 --- /dev/null Mon Dec 18 14:31:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile Fri Oct 27 14:31:04 2000 @@ -0,0 +1,45 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/Imakefile,v 1.2 2000/10/27 18:31:04 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = vesa.c + +OBJS = vesa.o + +#if defined(XF86DriverSDK) +INCLUDES = -I. -I../../include +#else +INCLUDES = -I. -I$(SERVERSRC)/fb -I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \ + -I$(SERVERSRC)/mfb -I$(SERVERSRC)/afb -I$(SERVERSRC)/mi \ + -I$(SERVERSRC)/miext/shadow -I$(SERVERSRC)/render \ + -I$(XF86SRC)/vgahw \ + -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \ + -I$(SERVERSRC)/include -I$(FONTINCSRC) -I$(XINCLUDESRC)\ + -I$(XF86SRC)/rac -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/os-support/vbe -I$(XF86SRC)/int10 \ + -I$(XTOP)/include/extensions +#endif + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget(vesa,$(OBJS)) + +InstallObjectModule(vesa,$(MODULEDIR),drivers) + +#if !defined(XF86DriverSDK) +CppManTarget(vesa,) +InstallModuleManPage(vesa) +#endif + +DependTarget() + +InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/vesa) +InstallDriverSDKNonExecFile(vesa.c,$(DRIVERSDKDIR)/drivers/vesa) + +InstallDriverSDKObjectModule(vesa,$(DRIVERSDKMODULEDIR),drivers) + Index: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c:1.8 --- /dev/null Mon Dec 18 14:31:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c Sat Dec 2 10:31:00 2000 @@ -0,0 +1,2464 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c,v 1.8 2000/12/02 15:31:00 tsi Exp $ + */ + +#include "vesa.h" + +/* All drivers initialising the SW cursor need this */ +#include "mipointer.h" + +/* All drivers implementing backing store need this */ +#include "mibstore.h" + +/* Colormap handling */ +#include "micmap.h" +#include "xf86cmap.h" + +/* Mandatory functions */ +static OptionInfoPtr VESAAvailableOptions(int chipid, int busid); +static void VESAIdentify(int flags); +static Bool VESAProbe(DriverPtr drv, int flags); +static Bool VESAPreInit(ScrnInfoPtr pScrn, int flags); +static Bool VESAScreenInit(int Index, ScreenPtr pScreen, int argc, + char **argv); +static Bool VESAEnterVT(int scrnIndex, int flags); +static void VESALeaveVT(int scrnIndex, int flags); +static Bool VESACloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool VESASaveScreen(ScreenPtr pScreen, int mode); + +static Bool VESASwitchMode(int scrnIndex, DisplayModePtr pMode, int flags); +static Bool VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode); +static void VESAAdjustFrame(int scrnIndex, int x, int y, int flags); +static void VESAFreeScreen(int scrnIndex, int flags); +static void VESAFreeRec(ScrnInfoPtr pScrn); + +/* locally used functions */ +static int VESAFindIsaDevice(GDevPtr dev); +static Bool VESAMapVidMem(ScrnInfoPtr pScrn); +static void VESAUnmapVidMem(ScrnInfoPtr pScrn); +static int VESABankSwitch(ScreenPtr pScreen, unsigned int iBank); +static void VESALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual); +static void SaveFonts(ScrnInfoPtr pScrn); +static void RestoreFonts(ScrnInfoPtr pScrn); + +static void *VESAWindowPlanar(ScreenPtr pScrn, CARD32 row, CARD32 offset, + int mode, CARD32 *size); +static void *VESAWindowLinear(ScreenPtr pScrn, CARD32 row, CARD32 offset, + int mode, CARD32 *size); +static void *VESAWindowWindowed(ScreenPtr pScrn, CARD32 row, CARD32 offset, + int mode, CARD32 *size); + +static Bool VESADGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen); + +/* + * This contains the functions needed by the server after loading the + * driver module. It must be supplied, and gets added the driver list by + * the Module Setup funtion in the dynamic case. In the static case a + * reference to this is compiled in, and this requires that the name of + * this DriverRec be an upper-case version of the driver name. + */ +DriverRec VESA = { + VESA_VERSION, + VESA_DRIVER_NAME, + VESAIdentify, + VESAProbe, + VESAAvailableOptions, + NULL, + 0 +}; + +enum GenericTypes +{ + CHIP_VESA_GENERIC +}; + +/* Supported chipsets */ +static SymTabRec VESAChipsets[] = +{ + {CHIP_VESA_GENERIC, "vesa"}, + {-1, NULL} +}; + +static PciChipsets VESAPCIchipsets[] = { + { CHIP_VESA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA }, + { -1, -1, RES_UNDEFINED }, +}; + +static IsaChipsets VESAISAchipsets[] = { + {CHIP_VESA_GENERIC, RES_EXCLUSIVE_VGA}, + {-1, 0 } +}; + +typedef enum { + OPTION_SHADOW_FB +} VESAOpts; + +static OptionInfoRec VESAOptions[] = { + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +/* + * List of symbols from other modules that this module references. This + * list is used to tell the loader that it is OK for symbols here to be + * unresolved providing that it hasn't been told that they haven't been + * told that they are essential via a call to xf86LoaderReqSymbols() or + * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about + * unresolved symbols that are not required. + */ +static const char *fbSymbols[] = { + "xf1bppScreenInit", + "xf4bppScreenInit", + "afbScreenInit", + "fbScreenInit", +#ifdef RENDER + "fbPictureInit", +#endif + "cfbScreenInit", + "mfbScreenInit", + NULL +}; + +static const char *shadowSymbols[] = { + "ShadowInit", + NULL +}; + +#ifdef XFree86LOADER + +/* Module loader interface */ +static MODULESETUPPROTO(vesaSetup); + +static XF86ModuleVersionInfo vesaVersionRec = +{ + VESA_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + VESA_MAJOR_VERSION, VESA_MINOR_VERSION, VESA_PATCHLEVEL, + ABI_CLASS_VIDEODRV, /* This is a video driver */ + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +/* + * This data is accessed by the loader. The name must be the module name + * followed by "ModuleInit". + */ +XF86ModuleData vesaModuleData = { &vesaVersionRec, vesaSetup, NULL }; + +static pointer +vesaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) +{ + static Bool Initialised = FALSE; + + if (!Initialised) + { + Initialised = TRUE; + xf86AddDriver(&VESA, Module, 0); + LoaderRefSymLists(fbSymbols, shadowSymbols, NULL); + return (pointer)TRUE; + } + + if (ErrorMajor) + *ErrorMajor = LDR_ONCEONLY; + return (NULL); +} + +#endif + +static +OptionInfoPtr +VESAAvailableOptions(int chipid, int busid) +{ + return (VESAOptions); +} + +static void +VESAIdentify(int flags) +{ + xf86PrintChipsets(VESA_NAME, "driver for VESA chipsets", VESAChipsets); +} + +/* + * This function is called once, at the start of the first server generation to + * do a minimal probe for supported hardware. + */ + +static Bool +VESAProbe(DriverPtr drv, int flags) +{ + Bool foundScreen = FALSE; + int numDevSections, numUsed; + GDevPtr *devSections; + int *usedChips; + int i; + + /* + * Find the config file Device sections that match this + * driver, and return if there are none. + */ + if ((numDevSections = xf86MatchDevice(VESA_NAME, + &devSections)) <= 0) + return (FALSE); + + /* PCI BUS */ + if (xf86GetPciVideoInfo()) { + numUsed = xf86MatchPciInstances(VESA_NAME, PCI_VENDOR_GENERIC, + VESAChipsets, VESAPCIchipsets, + devSections, numDevSections, + drv, &usedChips); + if (numUsed > 0) { + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else { + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + /* Allocate a ScrnInfoRec */ + if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i], + VESAPCIchipsets,NULL, + NULL,NULL,NULL,NULL))) { + pScrn->driverVersion = VESA_VERSION; + pScrn->driverName = VESA_DRIVER_NAME; + pScrn->name = VESA_NAME; + pScrn->Probe = VESAProbe; + pScrn->PreInit = VESAPreInit; + pScrn->ScreenInit = VESAScreenInit; + pScrn->SwitchMode = VESASwitchMode; + pScrn->AdjustFrame = VESAAdjustFrame; + pScrn->EnterVT = VESAEnterVT; + pScrn->LeaveVT = VESALeaveVT; + pScrn->FreeScreen = VESAFreeScreen; + foundScreen = TRUE; + } + } + } + xfree(usedChips); + } + } + + /* Isa Bus */ + numUsed = xf86MatchIsaInstances(VESA_NAME,VESAChipsets, + VESAISAchipsets, drv, + VESAFindIsaDevice, devSections, + numDevSections, &usedChips); + if(numUsed > 0) { + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + if ((pScrn = xf86ConfigIsaEntity(pScrn, 0,usedChips[i], + VESAISAchipsets, NULL, + NULL, NULL, NULL, NULL))) { + + pScrn->driverVersion = VESA_VERSION; + pScrn->driverName = VESA_DRIVER_NAME; + pScrn->name = VESA_NAME; + pScrn->Probe = VESAProbe; + pScrn->PreInit = VESAPreInit; + pScrn->ScreenInit = VESAScreenInit; + pScrn->SwitchMode = VESASwitchMode; + pScrn->AdjustFrame = VESAAdjustFrame; + pScrn->EnterVT = VESAEnterVT; + pScrn->LeaveVT = VESALeaveVT; + pScrn->FreeScreen = VESAFreeScreen; + foundScreen = TRUE; + } + } + xfree(usedChips); + } + + xfree(devSections); + + return (foundScreen); +} + +static int +VESAFindIsaDevice(GDevPtr dev) +{ +#ifndef PC98_EGC + CARD16 GenericIOBase = VGAHW_GET_IOBASE(); + CARD8 CurrentValue, TestValue; + + /* There's no need to unlock VGA CRTC registers here */ + + /* VGA has one more read/write attribute register than EGA */ + (void) inb(GenericIOBase + 0x0AU); /* Reset flip-flop */ + outb(0x3C0, 0x14 | 0x20); + CurrentValue = inb(0x3C1); + outb(0x3C0, CurrentValue ^ 0x0F); + outb(0x3C0, 0x14 | 0x20); + TestValue = inb(0x3C1); + outb(0x3C0, CurrentValue); + + /* Quit now if no VGA is present */ + if ((CurrentValue ^ 0x0F) != TestValue) + return -1; +#endif + return (int)CHIP_VESA_GENERIC; +} + +static VESAPtr +VESAGetRec(ScrnInfoPtr pScrn) +{ + if (!pScrn->driverPrivate) + pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1); + + return ((VESAPtr)pScrn->driverPrivate); +} + +static void +VESAFreeRec(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + DisplayModePtr mode = pScrn->modes; + + /* I am not sure if the modes will ever get freed. + * Anyway, the data unknown to other modules is being freed here. + */ + if (mode) { + do { + if (mode->Private) { + ModeInfoData *data = (ModeInfoData*)mode->Private; + + if (data->block) + xfree(data->block); + + xfree(data); + + mode->Private = NULL; + } + mode = mode->next; + } while (mode && mode != pScrn->modes); + } + xfree(pVesa->monitor); + xfree(pVesa->vbeInfo); + xfree(pVesa->pal); + xfree(pVesa->savedPal); + xfree(pVesa->fonts); + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +/* + * This function is called once for each screen at the start of the first + * server generation to initialise the screen for all server generations. + */ +static Bool +VESAPreInit(ScrnInfoPtr pScrn, int flags) +{ + VESAPtr pVesa; + VBEInfoBlock *vbe; + DisplayModePtr pMode, tmp; + ModeInfoBlock *mode; + ModeInfoData *data = NULL; + char *mod = NULL; + const char *reqSym = NULL; + Gamma gzeros = {0.0, 0.0, 0.0}; + rgb rzeros = {0, 0, 0}; + vbeInfoPtr pVbe; + pointer pVbeModule, pDDCModule; + int i; + + if (flags & PROBE_DETECT) + return (FALSE); + + /* Load int10 module */ + if (!xf86LoadSubModule(pScrn, "int10")) + return (FALSE); + + pVesa = VESAGetRec(pScrn); + pVesa->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + pVesa->device = xf86GetDevFromEntity(pScrn->entityList[0], + pScrn->entityInstanceList[0]); + if (pVesa->pEnt->location.type == BUS_PCI) { + pVesa->pciInfo = xf86GetPciInfoForEntity(pVesa->pEnt->index); + pVesa->pciTag = pciTag(pVesa->pciInfo->bus, pVesa->pciInfo->device, + pVesa->pciInfo->func); + pVesa->primary = xf86IsPrimaryPci(pVesa->pciInfo); + } + else + pVesa->primary = TRUE; + + pScrn->chipset = "vesa"; + pScrn->monitor = pScrn->confScreen->monitor; + pScrn->progClock = TRUE; + pScrn->rgbBits = 8; + + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb)) + return (FALSE); + xf86PrintDepthBpp(pScrn); + + /* Get the depth24 pixmap format */ + if (pScrn->depth == 24 && pVesa->pix24bpp == 0) + pVesa->pix24bpp = xf86GetBppFromDepth(pScrn, 24); + + /* color weight */ + if (pScrn->depth > 8 && !xf86SetWeight(pScrn, rzeros, rzeros)) + return (FALSE); + + /* visual init */ + if (!xf86SetDefaultVisual(pScrn, -1)) + return (FALSE); + + xf86SetGamma(pScrn, gzeros); + + if ((pVesa->pInt = xf86InitInt10(pVesa->pEnt->index)) == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Int10 initialization failed.\n"); + return (FALSE); + } + + if ((pVesa->block = xf86Int10AllocPages(pVesa->pInt, 1, &pVesa->page)) == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate one scratch page in real mode memory.\n"); + return (FALSE); + } + + vbe = VESAGetVBEInfo(pScrn); + pVesa->major = (unsigned)(vbe->VESAVersion >> 8); + pVesa->minor = vbe->VESAVersion & 0xff; + pVesa->vbeInfo = vbe; + pScrn->videoRam = vbe->TotalMemory * 64 * 1024; + + if (pVesa->major >= 2) { + /* Load vbe module */ + if ((pVbeModule = xf86LoadSubModule(pScrn, "vbe")) == NULL) + return (FALSE); + if ((pVbe = VBEInit(pVesa->pInt, pVesa->pEnt->index)) == NULL) + return (FALSE); + + /* Load ddc module */ + if ((pDDCModule = xf86LoadSubModule(pScrn, "ddc")) == NULL) + return (FALSE); + + if ((pVesa->monitor = vbeDoEDID(pVbe, pDDCModule)) != NULL) { + xf86PrintEDID(pVesa->monitor); +#ifdef DEBUG + ErrorF("Monitor data blocks:\n"); + ErrorF("VENDOR: name %s - id %d - serial %d - week %d - year %d\n", + pVesa->monitor->vendor.name, pVesa->monitor->vendor.prod_id, + pVesa->monitor->vendor.serial, pVesa->monitor->vendor.week, + pVesa->monitor->vendor.year); + ErrorF("EDID: Version %d - Revision %d\n", + pVesa->monitor->ver.version, + pVesa->monitor->ver.revision); + ErrorF("FEATURES:\n input: type %d - voltage %d - setup %d - sync %d\n" + " size: %d x %d\n gamma: %f\n dpms: %d\n type: %d\n" + " misc: %d\n redx %d - redy %d\n greenx %d - greeny %d\n" + " bluex: %d - bluey %d\n whitex %d - whitey\n" + "ESTABLISHED TIMES: %d %d %d\n" + "STD TIMINGS:\n", + pVesa->monitor->features.input_type, + pVesa->monitor->features.input_voltage, + pVesa->monitor->features.input_setup, + pVesa->monitor->features.input_sync, + pVesa->monitor->features.hsize, pVesa->monitor->features.vsize, + pVesa->monitor->features.gamma, + pVesa->monitor->features.dpms, + pVesa->monitor->features.display_type, + pVesa->monitor->features.msc, pVesa->monitor->features.redx, + pVesa->monitor->features.redy, + pVesa->monitor->features.greenx, pVesa->monitor->features.greeny, + pVesa->monitor->features.bluex, pVesa->monitor->features.bluey, + pVesa->monitor->features.whitex, pVesa->monitor->features.whitey, + pVesa->monitor->timings1.t1, + pVesa->monitor->timings1.t2, + pVesa->monitor->timings1.t_manu); + for (i = 0; i < 8; i++) { + ErrorF(" %d %d %d %d\n", + pVesa->monitor->timings2[i].hsize, + pVesa->monitor->timings2[i].vsize, + pVesa->monitor->timings2[i].refresh, + pVesa->monitor->timings2[i].id); + } + ErrorF("DETAILED MONITOR SECTION:\n"); + for (i = 0; i < 4; i++) { + int j; + + ErrorF(" type "); + switch (pVesa->monitor->det_mon[i].type) { + case DT: + ErrorF("DT\n"); + ErrorF(" clock: %d\n" + " hactive: %d\n hblanking: %d\n" + " vactive: %d\n vblanking: %d\n" + " hsyncoff: %d\n hsyncwidth: %d\n" + " vsyncoff: %d\n vsyncwidth: %d\n" + " hsize: %d\n vsize: %d\n" + " hborder: %d\n vborder: %d\n" + " interlaced: %d\n stereo: %d\n" + " sync: %d\n misc: %d\n", + pVesa->monitor->det_mon[i].section.d_timings.clock, + pVesa->monitor->det_mon[i].section.d_timings.h_active, + pVesa->monitor->det_mon[i].section.d_timings.h_blanking, + pVesa->monitor->det_mon[i].section.d_timings.v_active, + pVesa->monitor->det_mon[i].section.d_timings.v_blanking, + pVesa->monitor->det_mon[i].section.d_timings.h_sync_off, + pVesa->monitor->det_mon[i].section.d_timings.h_sync_width, + pVesa->monitor->det_mon[i].section.d_timings.v_sync_off, + pVesa->monitor->det_mon[i].section.d_timings.v_sync_width, + pVesa->monitor->det_mon[i].section.d_timings.h_size, + pVesa->monitor->det_mon[i].section.d_timings.v_size, + pVesa->monitor->det_mon[i].section.d_timings.h_border, + pVesa->monitor->det_mon[i].section.d_timings.v_border, + pVesa->monitor->det_mon[i].section.d_timings.interlaced, + pVesa->monitor->det_mon[i].section.d_timings.stereo, + pVesa->monitor->det_mon[i].section.d_timings.sync, + pVesa->monitor->det_mon[i].section.d_timings.misc); + break; + case DS_SERIAL: + ErrorF("SERIAL\n"); + ErrorF(" serial: %s\n", pVesa->monitor->det_mon[i].section.serial); + break; + case DS_ASCII_STR: + ErrorF("ASCII_STR\n"); + ErrorF(" ascii_str: %s\n", pVesa->monitor->det_mon[i].section.ascii_data); + break; + case DS_NAME: + ErrorF("NAME\n"); + ErrorF(" name: %s\n", pVesa->monitor->det_mon[i].section.name); + break; + case DS_RANGES: + ErrorF("RANGES\n"); + ErrorF(" ranges: minv %d - maxv %d - minh %d - maxh %d - maxclock %d\n", + pVesa->monitor->det_mon[i].section.ranges.min_v, + pVesa->monitor->det_mon[i].section.ranges.max_v, + pVesa->monitor->det_mon[i].section.ranges.min_h, + pVesa->monitor->det_mon[i].section.ranges.min_h, + pVesa->monitor->det_mon[i].section.ranges.max_clock); + break; + case DS_WHITE_P: + ErrorF("WHITE_P\n"); + for (j = 0; j < 2; j++) + ErrorF(" index %d - whitex %d - whitey %d - whitegamma %d\n", + pVesa->monitor->det_mon[i].section.wp[j].index, + pVesa->monitor->det_mon[i].section.wp[j].white_x, + pVesa->monitor->det_mon[i].section.wp[j].white_y, + pVesa->monitor->det_mon[i].section.wp[j].white_gamma); + break; + case DS_STD_TIMINGS: + ErrorF("STD_TIMINGS\n"); + for (j = 0; j < 5; j++) + ErrorF(" %d %d %d %d\n", + pVesa->monitor->det_mon[i].section.std_t[j].hsize, + pVesa->monitor->det_mon[i].section.std_t[j].vsize, + pVesa->monitor->det_mon[i].section.std_t[j].refresh, + pVesa->monitor->det_mon[i].section.std_t[j].id); + break; + default: + ErrorF(" UNKNOWN\n"); + break; + } + } +#endif + } + + /* unload modules */ + xf86UnloadSubModule(pVbeModule); + xf86UnloadSubModule(pDDCModule); + } + +#ifdef DEBUG + ErrorF("%c%c%c%c %d.%d - %s\n", + vbe->VESASignature[0], vbe->VESASignature[1], + vbe->VESASignature[2], vbe->VESASignature[3], + pVesa->major, pVesa->minor, vbe->OEMStringPtr); + + if (pVesa->major >= 2) + ErrorF("Vendor: %s\nProduct: %s\nProductRev: %s\nSoftware Rev: %d.%d\n", + vbe->OemVendorNamePtr, vbe->OemProductNamePtr, + vbe->OemProductRevPtr, (unsigned)vbe->OemSoftwareRev >> 8, + vbe->OemSoftwareRev & 0xff); +#endif + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + if ((pScrn->monitor->DDC = pVesa->monitor) != NULL) + xf86SetDDCproperties(pScrn, pVesa->monitor); + +#ifdef DEBUG + ErrorF("Searching for matching VESA mode(s):\n"); +#endif + + i = 0; + while (vbe->VideoModePtr[i] != 0xffff) { + int id = vbe->VideoModePtr[i++]; + + if ((mode = VESAGetModeInfo(pScrn, id)) == NULL) + continue; + + if (!(mode->ModeAttributes & (1 << 0)) || /* supported in the configured hardware */ + !(mode->ModeAttributes & (1 << 4)) || /* text mode */ + (pScrn->bitsPerPixel != 1 && !(mode->ModeAttributes & (1 << 3))) || /* monochrome */ + (mode->BitsPerPixel > 8 && + (mode->RedMaskSize + mode->GreenMaskSize + + mode->BlueMaskSize != pScrn->depth)) || + /* only linear mode, but no PhysBasePtr */ + ((mode->ModeAttributes & (1 << 6)) && + (mode->ModeAttributes & (1 << 7)) && !mode->PhysBasePtr) || + ((mode->ModeAttributes & (1 << 6)) && + !(mode->ModeAttributes & (1 << 7))) || + mode->BitsPerPixel != pScrn->bitsPerPixel) { + VESAFreeModeInfo(mode); + continue; + } + + pMode = xcalloc(sizeof(DisplayModeRec), 1); + pMode->prev = pMode->next = NULL; + + pMode->status = MODE_OK; + pMode->type = M_T_DEFAULT;/*M_T_BUILTIN;*/ + + /* for adjust frame */ + pMode->HDisplay = mode->XResolution; + pMode->VDisplay = mode->YResolution; + + data = xcalloc(sizeof(ModeInfoData), 1); + data->mode = id; + data->data = mode; + pMode->PrivSize = sizeof(ModeInfoData); + pMode->Private = (INT32*)data; + + if (pScrn->modePool == NULL) { + pScrn->modePool = pMode; + pMode->next = pMode->prev = pMode; + } + else { + tmp = pScrn->modePool; + + tmp->prev = pMode; + while (tmp->next != pScrn->modePool) + tmp = tmp->next; + tmp->next = pMode; + pMode->prev = tmp; + pMode->next = pScrn->modePool; + } + +#ifdef DEBUG + ErrorF("Mode: %x (%dx%d)\n", id, mode->XResolution, mode->YResolution); + ErrorF(" ModeAttributes: 0x%x\n", mode->ModeAttributes); + ErrorF(" WinAAttributes: 0x%x\n", mode->WinAAttributes); + ErrorF(" WinBAttributes: 0x%x\n", mode->WinBAttributes); + ErrorF(" WinGranularity: %d\n", mode->WinGranularity); + ErrorF(" WinSize: %d\n", mode->WinSize); + ErrorF(" WinASegment: 0x%x\n", mode->WinASegment); + ErrorF(" WinBSegment: 0x%x\n", mode->WinBSegment); + ErrorF(" WinFuncPtr: 0x%x\n", mode->WinFuncPtr); + ErrorF(" BytesPerScanline: %d\n", mode->BytesPerScanline); + ErrorF(" XResolution: %d\n", mode->XResolution); + ErrorF(" YResolution: %d\n", mode->YResolution); + ErrorF(" XCharSize: %d\n", mode->XCharSize); + ErrorF(" YCharSize: %d\n", mode->YCharSize); + ErrorF(" NumberOfPlanes: %d\n", mode->NumberOfPlanes); + ErrorF(" BitsPerPixel: %d\n", mode->BitsPerPixel); + ErrorF(" NumberOfBanks: %d\n", mode->NumberOfBanks); + ErrorF(" MemoryModel: %d\n", mode->MemoryModel); + ErrorF(" BankSize: %d\n", mode->BankSize); + ErrorF(" NumberOfImages: %d\n", mode->NumberOfImages); + ErrorF(" RedMaskSize: %d\n", mode->RedMaskSize); + ErrorF(" RedFieldPosition: %d\n", mode->RedFieldPosition); + ErrorF(" GreenMaskSize: %d\n", mode->GreenMaskSize); + ErrorF(" GreenFieldPosition: %d\n", mode->GreenFieldPosition); + ErrorF(" BlueMaskSize: %d\n", mode->BlueMaskSize); + ErrorF(" BlueFieldPosition: %d\n", mode->BlueFieldPosition); + ErrorF(" RsvdMaskSize: %d\n", mode->RsvdMaskSize); + ErrorF(" RsvdFieldPosition: %d\n", mode->RsvdFieldPosition); + ErrorF(" DirectColorModeInfo: %d\n", mode->DirectColorModeInfo); + if (pVesa->major >= 2) { + ErrorF(" PhysBasePtr: 0x%x\n", mode->PhysBasePtr); + if (pVesa->major >= 3) { + ErrorF(" LinBytesPerScanLine: %d\n", mode->LinBytesPerScanLine); + ErrorF(" BnkNumberOfImagePages: %d\n", mode->BnkNumberOfImagePages); + ErrorF(" LinNumberOfImagePages: %d\n", mode->LinNumberOfImagePages); + ErrorF(" LinRedMaskSize: %d\n", mode->LinRedMaskSize); + ErrorF(" LinRedFieldPosition: %d\n", mode->LinRedFieldPosition); + ErrorF(" LinGreenMaskSize: %d\n", mode->LinGreenMaskSize); + ErrorF(" LinGreenFieldPosition: %d\n", mode->LinGreenFieldPosition); + ErrorF(" LinBlueMaskSize: %d\n", mode->LinBlueMaskSize); + ErrorF(" LinBlueFieldPosition: %d\n", mode->LinBlueFieldPosition); + ErrorF(" LinRsvdMaskSize: %d\n", mode->LinRsvdMaskSize); + ErrorF(" LinRsvdFieldPosition: %d\n", mode->LinRsvdFieldPosition); + ErrorF(" MaxPixelClock: %d\n", mode->MaxPixelClock); + } + } +#endif + } + +#ifdef DEBUG + ErrorF("\n"); + ErrorF("Total Memory: %d 64Kb banks (%dM)\n", vbe->TotalMemory, + (vbe->TotalMemory * 65536) / (1024 * 1024)); +#endif + + pVesa->mapSize = vbe->TotalMemory * 65536; + if (pScrn->modePool == NULL) + return (FALSE); + for (i = 0; pScrn->modePool != NULL && pScrn->display->modes[i] != NULL; i++) { + pMode = pScrn->modePool; + + do { + DisplayModePtr next = pMode->next; + int width, height; + + if (sscanf(pScrn->display->modes[i], "%dx%d", &width, &height) == 2 && + width == pMode->HDisplay && height == pMode->VDisplay) { + pMode->name = strdup(pScrn->display->modes[i]); + + pMode->prev->next = pMode->next; + pMode->next->prev = pMode->prev; + + if (pScrn->modes == NULL) { + pScrn->modes = pMode; + pMode->next = pMode->prev = pMode; + } + else { + tmp = pScrn->modes; + + tmp->prev = pMode; + while (tmp->next != pScrn->modes) + tmp = tmp->next; + pMode->prev = tmp; + tmp->next = pMode; + pMode->next = pScrn->modes; + } + if (pMode == pScrn->modePool) + pScrn->modePool = (next == pMode) ? NULL : next; + break; + } + pMode = next; + } while (pMode != pScrn->modePool && pScrn->modePool != NULL); + } + + if (pScrn->modes == NULL) + pScrn->modes = pScrn->modePool; + tmp = pScrn->modes; + do { + mode = ((ModeInfoData*)tmp->Private)->data; + if (mode->XResolution > pScrn->virtualX) { + pScrn->virtualX = mode->XResolution; + pVesa->maxBytesPerScanline = mode->BytesPerScanline; + } + if (mode->YResolution > pScrn->virtualY) + pScrn->virtualY = mode->YResolution; + } while ((tmp = tmp->next) != pScrn->modes); + + if (pVesa->monitor != NULL) { + pMode = pScrn->modes; + + do { + int maxClock = 0; + DisplayModePtr last = pScrn->monitor->Modes; + + for (i = 0; i < 4; i++) + if (pVesa->monitor->det_mon[i].type == DT && + pVesa->monitor->det_mon[i].section.d_timings.h_active == + pMode->HDisplay && + pVesa->monitor->det_mon[i].section.d_timings.v_active == + pMode->VDisplay) { + maxClock = pVesa->monitor-> + det_mon[i].section.d_timings.clock / 1000; + break; + } + + tmp = NULL; + if (maxClock) { + for (; last != NULL; last = last->next) { + if (pMode->name != NULL && + strcmp(pMode->name, last->name) == 0 && + last->Clock <= maxClock) { + tmp = last; + /* keep looping to find the best refresh */ + } + } + } + + if (tmp != NULL) { + int from = (int)(&((DisplayModePtr)0)->Clock); + int to = (int)(&((DisplayModePtr)0)->ClockIndex); + + data->mode |= (1 << 11); + + /* copy the "interesting" information */ + memcpy((char*)pMode + from, (char*)tmp + from, to - from); + data = (ModeInfoData*)pMode->Private; + data->block = xcalloc(sizeof(CRTCInfoBlock), 1); + data->block->HorizontalTotal = pMode->HTotal; + data->block->HorizontalSyncStart = pMode->HSyncStart; + data->block->HorizontalSyncEnd = pMode->HSyncEnd; + data->block->VerticalTotal = pMode->VTotal; + data->block->VerticalSyncStart = pMode->VSyncStart; + data->block->VerticalSyncEnd = pMode->VSyncEnd; + data->block->Flags = ((pMode->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) | + ((pMode->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0); + data->block->PixelClock = pMode->Clock * 1000; + data->block->RefreshRate = ((double)(pMode->Clock * 1000) / + (double)(pMode->HTotal * pMode->VTotal)) * 100; + } + pMode = pMode->next; + } while (pMode != pScrn->modes); + } + + pScrn->currentMode = pScrn->modes; + pScrn->displayWidth = pScrn->virtualX; + + if (pScrn->modes == NULL) + return (FALSE); + + /* options */ + xf86CollectOptions(pScrn, NULL); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, VESAOptions); + + /* Use shadow by default */ + if (xf86ReturnOptValBool(VESAOptions, OPTION_SHADOW_FB, TRUE)) + pVesa->shadowFB = TRUE; + + mode = ((ModeInfoData*)pScrn->modes->Private)->data; + switch (mode->MemoryModel) { + case 0x0: /* Text mode */ + case 0x1: /* CGA graphics */ + case 0x2: /* Hercules graphics */ + case 0x5: /* Non-chain 4, 256 color */ + case 0x7: /* YUV */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported Memory Model: %d", mode->MemoryModel); + break; + case 0x3: /* Planar */ + if (pVesa->shadowFB) { + mod = "fb"; + reqSym = "fbScreenInit"; + } + else { + switch (pScrn->bitsPerPixel) { + case 1: + mod = "xf1bpp"; + reqSym = "xf1bppScreenInit"; + break; + case 4: + mod = "xf4bpp"; + reqSym = "xf4bppScreenInit"; + break; + default: + mod = "afb"; + reqSym = "afbScreenInit"; + break; + } + } + break; + case 0x4: /* Packed pixel */ + mod = "fb"; + reqSym = "fbScreenInit"; + + switch (pScrn->bitsPerPixel) { + case 8: + case 16: + case 32: + break; + case 24: + if (pVesa->pix24bpp == 32) { + mod = "xf24_32bpp"; + reqSym = "cfb24_32ScreenInit"; + } + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported bpp: %d", pScrn->bitsPerPixel); + return FALSE; + } + break; + case 0x6: /* Direct Color */ + mod = "fb"; + reqSym = "fbScreenInit"; + + switch (pScrn->bitsPerPixel) { + case 8: + case 16: + case 32: + break; + case 24: + if (pVesa->pix24bpp == 32) { + mod = "xf24_32bpp"; + reqSym = "cfb24_32ScreenInit"; + } + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported bpp: %d", pScrn->bitsPerPixel); + return FALSE; + } + break; + } + + if (pVesa->shadowFB) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using \"Shadow Framebuffer\"\n"); + if (pScrn->depth == 1) { + mod = "mfb"; + reqSym = "mfbScreenInit"; + } + if (!xf86LoadSubModule(pScrn, "shadow")) + return (FALSE); + xf86LoaderReqSymLists(shadowSymbols, NULL); + } + + if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { + VESAFreeRec(pScrn); + return (FALSE); + } + xf86LoaderReqSymbols(reqSym, NULL); +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif + + return (TRUE); +} + +static Bool +VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + VESAPtr pVesa = VESAGetRec(pScrn); + VisualPtr visual; + ModeInfoBlock *mode; + int flags; + + if (pVesa->mapPhys == 0) { + mode = ((ModeInfoData*)(pScrn->currentMode->Private))->data; + pScrn->videoRam = pVesa->mapSize; + pVesa->mapPhys = mode->PhysBasePtr; + pVesa->mapOff = 0; + } + + if ((void*)pVesa->mapPhys == NULL) { + pVesa->mapPhys = 0xa0000; + pVesa->mapSize = 0x10000; + } + + if (!VESAMapVidMem(pScrn)) { + if (pVesa->mapPhys != 0xa0000) { + pVesa->mapPhys = 0xa0000; + pVesa->mapSize = 0x10000; + if (!VESAMapVidMem(pScrn)) + return (FALSE); + } + else + return (FALSE); + } + + if (pVesa->shadowFB && (pVesa->shadowPtr = + shadowAlloc(pScrn->virtualX, pScrn->virtualY, + pScrn->bitsPerPixel)) == NULL) + return (FALSE); + + /* save current video state */ + VESASaveRestore(pScrn, MODE_SAVE); + pVesa->savedPal = VESASetGetPaletteData(pScrn, FALSE, 0, 256, + NULL, FALSE, FALSE); + + /* set first video mode */ + if (!VESASetMode(pScrn, pScrn->currentMode)) + return (FALSE); + + /* mi layer */ + miClearVisualTypes(); + if (!xf86SetDefaultVisual(pScrn, -1)) + return (FALSE); + if (pScrn->bitsPerPixel > 8) { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, + pScrn->rgbBits, TrueColor)) + return (FALSE); + } + else { + if (!miSetVisualTypes(pScrn->depth, + miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return (FALSE); + } + if (!miSetPixmapDepths()) + return (FALSE); + + mode = ((ModeInfoData*)pScrn->modes->Private)->data; + switch (mode->MemoryModel) { + case 0x0: /* Text mode */ + case 0x1: /* CGA graphics */ + case 0x2: /* Hercules graphics */ + case 0x5: /* Non-chain 4, 256 color */ + case 0x7: /* YUV */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported Memory Model: %d", mode->MemoryModel); + return (FALSE); + case 0x3: /* Planar */ + if (pVesa->shadowFB) { + if (!fbScreenInit(pScreen, + pVesa->shadowPtr, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return (FALSE); + } + else { + switch (pScrn->bitsPerPixel) { + case 1: + if (!xf1bppScreenInit(pScreen, pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return (FALSE); + break; + case 4: + if (!xf4bppScreenInit(pScreen, pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return (FALSE); + break; + default: + if (!afbScreenInit(pScreen, pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth)) + return (FALSE); + break; + } + } + break; + case 0x4: /* Packed pixel */ + switch (pScrn->bitsPerPixel) { + case 24: + if (pVesa->pix24bpp == 32) { + if (!cfb24_32ScreenInit(pScreen, + pVesa->shadowFB ? pVesa->shadowPtr : pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return (FALSE); + break; + } + case 8: + case 16: + case 32: + if (!fbScreenInit(pScreen, + pVesa->shadowFB ? pVesa->shadowPtr : pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return (FALSE); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported bpp: %d", pScrn->bitsPerPixel); + return FALSE; + } + break; + case 0x6: /* Direct Color */ + switch (pScrn->bitsPerPixel) { + case 24: + if (pVesa->pix24bpp == 32) { + if (!cfb24_32ScreenInit(pScreen, + pVesa->shadowFB ? pVesa->shadowPtr : pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth)) + return (FALSE); + break; + } + case 8: + case 16: + case 32: + if (!fbScreenInit(pScreen, + pVesa->shadowFB ? pVesa->shadowPtr : pVesa->base, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return (FALSE); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Unsupported bpp: %d", pScrn->bitsPerPixel); + return (FALSE); + } + break; + } + +#ifdef RENDER + fbPictureInit(pScreen, 0, 0); +#endif + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + if (pVesa->shadowFB) { + ShadowUpdateProc update; + ShadowWindowProc window; + + if (mode->MemoryModel == 3) { /* Planar */ + if (pScrn->bitsPerPixel == 8) + update = shadowUpdatePlanar4x8; + else + update = shadowUpdatePlanar4; + window = VESAWindowPlanar; + } + else if (pVesa->mapPhys == 0xa0000) { /* Windowed */ + update = shadowUpdatePacked; + window = VESAWindowWindowed; + } + else { /* Linear */ + update = shadowUpdatePacked; + window = VESAWindowLinear; + } + + if (!shadowInit(pScreen, update, window)) + return (FALSE); + } + else if (pVesa->mapPhys == 0xa0000 && mode->MemoryModel != 0x3) { + unsigned int bankShift = 0; + while ((unsigned)(64 >> bankShift) != mode->WinGranularity) + bankShift++; + pVesa->curBank = -1; + pVesa->bank.SetSourceBank = + pVesa->bank.SetDestinationBank = + pVesa->bank.SetSourceAndDestinationBanks = VESABankSwitch; + pVesa->bank.pBankA = pVesa->bank.pBankB = pVesa->base; + pVesa->bank.BankSize = (mode->WinSize * 1024) >> bankShift; + pVesa->bank.nBankDepth = pScrn->depth; + if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY, + pScrn->virtualX, &pVesa->bank)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Bank switch initialization failed!\n"); + return (FALSE); + } + } + + VESADGAInit(pScrn, pScreen); + + xf86SetBlackWhitePixels(pScreen); + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + + /* software cursor */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + /* colormap */ + if (!miCreateDefColormap(pScreen)) + return (FALSE); + + flags = CMAP_RELOAD_ON_MODE_SWITCH; + + if(!xf86HandleColormaps(pScreen, 256, + pVesa->vbeInfo->Capabilities[0] & 0x01 ? 8 : 6, + VESALoadPalette, NULL, flags)) + return (FALSE); + + pScreen->CloseScreen = VESACloseScreen; + pScreen->SaveScreen = VESASaveScreen; + + return (TRUE); +} + +static Bool +VESAEnterVT(int scrnIndex, int flags) +{ + return (VESASetMode(xf86Screens[scrnIndex], + xf86Screens[scrnIndex]->currentMode)); +} + +static void +VESALeaveVT(int scrnIndex, int flags) +{ + VESASaveRestore(xf86Screens[scrnIndex], MODE_RESTORE); +} + +static Bool +VESACloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + VESAPtr pVesa = VESAGetRec(pScrn); + + VESASaveRestore(xf86Screens[scrnIndex], MODE_RESTORE); + VESASetGetPaletteData(pScrn, TRUE, 0, 256, + pVesa->savedPal, FALSE, TRUE); + + VESAUnmapVidMem(pScrn); + if (pVesa->shadowPtr) { + xfree(pVesa->shadowPtr); + pVesa->shadowPtr = NULL; + } + if (pVesa->pDGAMode) + xfree(pVesa->pDGAMode); + pScrn->vtSema = FALSE; + + return (TRUE); +} + +static Bool +VESASwitchMode(int scrnIndex, DisplayModePtr pMode, int flags) +{ + return VESASetMode(xf86Screens[scrnIndex], pMode); +} + +/* Set a graphics mode */ +static Bool +VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) +{ + VESAPtr pVesa; + ModeInfoData *data; + int mode; + + pVesa = VESAGetRec(pScrn); + + data = (ModeInfoData*)pMode->Private; + + mode = data->mode | (1 << 15); + + /* enable linear addressing */ + if (pVesa->mapPhys != 0xa0000) + mode |= 1 << 14; + + if (VESASetVBEMode(pScrn, mode, data->block) == FALSE) { + if ((data->block || (data->mode & (1 << 11))) && + VESASetVBEMode(pScrn, (mode & ~(1 << 11)), NULL) == TRUE) { + /* Some cards do not like setting the clock. + * Free it as it will not be any longer useful + */ + xfree(data->block); + data->block = NULL; + data->mode &= ~(1 << 11); + } + else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Set VBE Mode failed!\n"); + return (FALSE); + } + } + + pVesa->bankSwitchWindowB = + !((data->data->WinBSegment == 0) && (data->data->WinBAttributes == 0)); + + if (data->data->XResolution != pScrn->virtualX) + VESASetLogicalScanline(pScrn, pScrn->virtualX); + + if (pScrn->bitsPerPixel >= 8 && pVesa->vbeInfo->Capabilities[0] & 0x01) + VESASetGetDACPaletteFormat(pScrn, 8); + + pScrn->vtSema = TRUE; + + return (TRUE); +} + +static void +VESAAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn; + + pScrn = xf86Screens[scrnIndex]; + VESASetDisplayStart(pScrn, x, y, TRUE); +} + +static void +VESAFreeScreen(int scrnIndex, int flags) +{ + VESAFreeRec(xf86Screens[scrnIndex]); +} + +static Bool +VESAMapVidMem(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + if (pVesa->base != NULL) + return (TRUE); + + pScrn->memPhysBase = pVesa->mapPhys; + pScrn->fbOffset = pVesa->mapOff; + + pVesa->base = xf86MapVidMem(pScrn->scrnIndex, 0, + pScrn->memPhysBase, pVesa->mapSize); + if (pVesa->base) { + if (pVesa->mapPhys != 0xa0000) + pVesa->VGAbase = xf86MapVidMem(pScrn->scrnIndex, 0, + 0xa0000, 0x10000); + else + pVesa->VGAbase = pVesa->base; + } +#ifdef DEBUG + ErrorF("virtual address = %p - physical address = %p - size = %d\n", + pVesa->base, pScrn->memPhysBase, pVesa->mapSize); +#endif + + return (pVesa->base != NULL); +} + +static void +VESAUnmapVidMem(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + if (pVesa->base == NULL) + return; + + xf86UnMapVidMem(pScrn->scrnIndex, pVesa->base, pVesa->mapSize); + if (pVesa->mapPhys != 0xa0000) + xf86UnMapVidMem(pScrn->scrnIndex, pVesa->VGAbase, 0x10000); + pVesa->base = NULL; +} + +void * +VESAWindowPlanar(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, + CARD32 *size) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VESAPtr pVesa = VESAGetRec(pScrn); + ModeInfoBlock *data = ((ModeInfoData*)(pScrn->currentMode->Private))->data; + int window; + int mask = 1 << (offset & 3); + + outb(0x3c4, 2); + outb(0x3c5, mask); + + offset = (offset >> 2) + pVesa->maxBytesPerScanline * row; + window = offset / (data->WinGranularity * 1024); + pVesa->windowAoffset = window * data->WinGranularity * 1024; + VESABankSwitch(pScreen, window); + *size = data->WinSize * 1024 - (offset - pVesa->windowAoffset); + + return (void *)((unsigned long)pVesa->base + + (offset - pVesa->windowAoffset)); +} + +static void * +VESAWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, + CARD32 *size) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VESAPtr pVesa = VESAGetRec(pScrn); + + *size = pVesa->maxBytesPerScanline; + return ((CARD8 *)pVesa->base + row * pVesa->maxBytesPerScanline + offset); +} + +static void * +VESAWindowWindowed(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, + CARD32 *size) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VESAPtr pVesa = VESAGetRec(pScrn); + ModeInfoBlock *data = ((ModeInfoData*)(pScrn->currentMode->Private))->data; + int window; + + offset += pVesa->maxBytesPerScanline * row; + window = offset / (data->WinGranularity * 1024); + pVesa->windowAoffset = window * data->WinGranularity * 1024; + VESABankSwitch(pScreen, window); + *size = data->WinSize * 1024 - (offset - pVesa->windowAoffset); + + return (void *)((unsigned long)pVesa->base + + (offset - pVesa->windowAoffset)); +} + +static void +VESALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + LOCO *colors, VisualPtr pVisual) +{ +#if 0 + /* This code works, but is very slow for programs that use it intensively */ + VESAPtr pVesa = VESAGetRec(pScrn); + int i, idx, base; + + if (pVesa->pal == NULL) + pVesa->pal = xcalloc(1, sizeof(CARD32) * 256); + + for (i = 0, base = idx = indices[i]; i < numColors; i++, idx++) { + int j = indices[i]; + + if (j < 0 || j >= 256) + continue; + pVesa->pal[j] = colors[j].blue | + (colors[j].green << 8) | + (colors[j].red << 16); + if (j != idx) { + VESASetGetPaletteData(pScrn, TRUE, base, idx - base, + pVesa->pal + base, FALSE, TRUE); + idx = base = j; + } + } + + if (idx - 1 == indices[i - 1]) + VESASetGetPaletteData(pScrn, TRUE, base, idx - base, + pVesa->pal + base, FALSE, TRUE); +#else +#define WriteDacWriteAddr(value) outb(VGA_DAC_WRITE_ADDR, value) +#define WriteDacData(value) outb(VGA_DAC_DATA, value); +#undef DACDelay +#define DACDelay() \ + do { \ + unsigned char temp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \ + temp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \ + } while (0) + int i, idx; + + for (i = 0; i < numColors; i++) { + idx = indices[i]; + WriteDacWriteAddr(idx); + DACDelay(); + WriteDacData(colors[idx].red); + DACDelay(); + WriteDacData(colors[idx].green); + DACDelay(); + WriteDacData(colors[idx].blue); + DACDelay(); + } +#endif +} + +/* + * Just adapted from the std* functions in vgaHW.c + */ +static void +WriteAttr(int index, int value) +{ + CARD8 tmp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); + + index |= 0x20; + outb(VGA_ATTR_INDEX, index); + outb(VGA_ATTR_DATA_W, value); +} + +static int +ReadAttr(int index) +{ + CARD8 tmp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); + + index |= 0x20; + outb(VGA_ATTR_INDEX, index); + return (inb(VGA_ATTR_DATA_R)); +} + +#define WriteMiscOut(value) outb(VGA_MISC_OUT_W, value) +#define ReadMiscOut() inb(VGA_MISC_OUT_R) +#define WriteSeq(index, value) outb(VGA_SEQ_INDEX, index);\ + outb(VGA_SEQ_DATA, value) + +static int +ReadSeq(int index) +{ + outb(VGA_SEQ_INDEX, index); + + return (inb(VGA_SEQ_DATA)); +} + +#define WriteGr(index, value) outb(VGA_GRAPH_INDEX, index);\ + outb(VGA_GRAPH_DATA, value) +static int +ReadGr(int index) +{ + outb(VGA_GRAPH_INDEX, index); + + return (inb(VGA_GRAPH_DATA)); +} + +static void +SeqReset(Bool start) +{ + if (start) { + WriteSeq(0x00, 0x01); /* Synchronous Reset */ + } + else { + WriteSeq(0x00, 0x03); /* End Reset */ + } +} + +static void +SaveFonts(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4, scrn; + + if (pVesa->fonts != NULL) + return; + + /* If in graphics mode, don't save anything */ + attr10 = ReadAttr(0x10); + if (attr10 & 0x01) + return; + + pVesa->fonts = xalloc(16384); + + /* save the registers that are needed here */ + miscOut = ReadMiscOut(); + gr4 = ReadGr(0x04); + gr5 = ReadGr(0x05); + gr6 = ReadGr(0x06); + seq2 = ReadSeq(0x02); + seq4 = ReadSeq(0x04); + + /* Force into colour mode */ + WriteMiscOut(miscOut | 0x01); + + scrn = ReadSeq(0x01) | 0x20; + SeqReset(TRUE); + WriteSeq(0x01, scrn); + SeqReset(FALSE); + + WriteAttr(0x10, 0x01); /* graphics mode */ + + /*font1 */ + WriteSeq(0x02, 0x04); /* write to plane 2 */ + WriteSeq(0x04, 0x06); /* enable plane graphics */ + WriteGr(0x04, 0x02); /* read plane 2 */ + WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ + WriteGr(0x06, 0x05); /* set graphics */ + slowbcopy_frombus(pVesa->VGAbase, pVesa->fonts, 8192); + + /* font2 */ + WriteSeq(0x02, 0x08); /* write to plane 3 */ + WriteSeq(0x04, 0x06); /* enable plane graphics */ + WriteGr(0x04, 0x03); /* read plane 3 */ + WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ + WriteGr(0x06, 0x05); /* set graphics */ + slowbcopy_frombus(pVesa->VGAbase, pVesa->fonts + 8192, 8192); + + scrn = ReadSeq(0x01) & ~0x20; + SeqReset(TRUE); + WriteSeq(0x01, scrn); + SeqReset(FALSE); + + /* Restore clobbered registers */ + WriteAttr(0x10, attr10); + WriteSeq(0x02, seq2); + WriteSeq(0x04, seq4); + WriteGr(0x04, gr4); + WriteGr(0x05, gr5); + WriteGr(0x06, gr6); + WriteMiscOut(miscOut); +} + +static void +RestoreFonts(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4, scrn; + + if (pVesa->fonts == NULL) + return; + + if (pVesa->mapPhys == 0xa0000 && pVesa->curBank != 0) + VESABankSwitch(pScrn->pScreen, 0); + + /* save the registers that are needed here */ + miscOut = ReadMiscOut(); + attr10 = ReadAttr(0x10); + gr1 = ReadGr(0x01); + gr3 = ReadGr(0x03); + gr4 = ReadGr(0x04); + gr5 = ReadGr(0x05); + gr6 = ReadGr(0x06); + gr8 = ReadGr(0x08); + seq2 = ReadSeq(0x02); + seq4 = ReadSeq(0x04); + + /* Force into colour mode */ + WriteMiscOut(miscOut | 0x01); + + scrn = ReadSeq(0x01) | 0x20; + SeqReset(TRUE); + WriteSeq(0x01, scrn); + SeqReset(FALSE); + + WriteAttr(0x10, 0x01); /* graphics mode */ + if (pScrn->depth == 4) { + /* GJA */ + WriteGr(0x03, 0x00); /* don't rotate, write unmodified */ + WriteGr(0x08, 0xFF); /* write all bits in a byte */ + WriteGr(0x01, 0x00); /* all planes come from CPU */ + } + + WriteSeq(0x02, 0x04); /* write to plane 2 */ + WriteSeq(0x04, 0x06); /* enable plane graphics */ + WriteGr(0x04, 0x02); /* read plane 2 */ + WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ + WriteGr(0x06, 0x05); /* set graphics */ + slowbcopy_tobus(pVesa->fonts, pVesa->VGAbase, 8192); + + WriteSeq(0x02, 0x08); /* write to plane 3 */ + WriteSeq(0x04, 0x06); /* enable plane graphics */ + WriteGr(0x04, 0x03); /* read plane 3 */ + WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ + WriteGr(0x06, 0x05); /* set graphics */ + slowbcopy_tobus(pVesa->fonts + 8192, pVesa->VGAbase, 8192); + + scrn = ReadSeq(0x01) & ~0x20; + SeqReset(TRUE); + WriteSeq(0x01, scrn); + SeqReset(FALSE); + + /* restore the registers that were changed */ + WriteMiscOut(miscOut); + WriteAttr(0x10, attr10); + WriteGr(0x01, gr1); + WriteGr(0x03, gr3); + WriteGr(0x04, gr4); + WriteGr(0x05, gr5); + WriteGr(0x06, gr6); + WriteGr(0x08, gr8); + WriteSeq(0x02, seq2); + WriteSeq(0x04, seq4); +} + +static Bool +VESASaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Bool on = xf86IsUnblank(mode); + + if (on) + SetTimeSinceLastInputEvent(); + + if (pScrn->vtSema) { + unsigned char scrn = ReadSeq(0x01); + + if (on) + scrn &= ~0x20; + else + scrn |= 0x20; + SeqReset(TRUE); + WriteSeq(0x01, scrn); + SeqReset(FALSE); + } + + return (TRUE); +} + +VBEInfoBlock * +VESAGetVBEInfo(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa; + VBEInfoBlock *block = NULL; + int i, pStr, pModes; + char *str; + CARD16 major, minor, *modes; + + pVesa = VESAGetRec(pScrn); + bzero(pVesa->block, sizeof(VBEInfoBlock)); + + /* + Input: + AH := 4Fh Super VGA support + AL := 00h Return Super VGA information + ES:DI := Pointer to buffer + + Output: + AX := status + (All other registers are preserved) + */ + + pVesa->block[0] = 'V'; + pVesa->block[1] = 'B'; + pVesa->block[2] = 'E'; + pVesa->block[3] = '2'; + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f00; + pVesa->pInt->es = SEG_ADDR(pVesa->page); + pVesa->pInt->di = SEG_OFF(pVesa->page); + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (NULL); + + block = xcalloc(sizeof(VBEInfoBlock), 1); + block->VESASignature[0] = pVesa->block[0]; + block->VESASignature[1] = pVesa->block[1]; + block->VESASignature[2] = pVesa->block[2]; + block->VESASignature[3] = pVesa->block[3]; + + block->VESAVersion = *(CARD16*)(pVesa->block + 4); + major = (unsigned)block->VESAVersion >> 8; + minor = block->VESAVersion & 0xff; + + pStr = *(CARD32*)(pVesa->block + 6); + str = xf86int10Addr(pVesa->pInt, FARP(pStr)); + block->OEMStringPtr = strdup(str); + + block->Capabilities[0] = pVesa->block[10]; + block->Capabilities[1] = pVesa->block[11]; + block->Capabilities[2] = pVesa->block[12]; + block->Capabilities[3] = pVesa->block[13]; + + pModes = *(CARD32*)(pVesa->block + 14); + modes = xf86int10Addr(pVesa->pInt, FARP(pModes)); + i = 0; + while (modes[i] != 0xffff) + i++; + block->VideoModePtr = xalloc(sizeof(CARD16) * i + 1); + memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i); + block->VideoModePtr[i] = 0xffff; + + block->TotalMemory = *(CARD16*)(pVesa->block + 18); + + if (major < 2) + memcpy(&block->OemSoftwareRev, pVesa->block + 20, 236); + else { + block->OemSoftwareRev = *(CARD16*)(pVesa->block + 20); + pStr = *(CARD32*)(pVesa->block + 22); + str = xf86int10Addr(pVesa->pInt, FARP(pStr)); + block->OemVendorNamePtr = strdup(str); + pStr = *(CARD32*)(pVesa->block + 26); + str = xf86int10Addr(pVesa->pInt, FARP(pStr)); + block->OemProductNamePtr = strdup(str); + pStr = *(CARD32*)(pVesa->block + 30); + str = xf86int10Addr(pVesa->pInt, FARP(pStr)); + block->OemProductRevPtr = strdup(str); + memcpy(&block->Reserved, pVesa->block + 34, 222); + memcpy(&block->OemData, pVesa->block + 256, 256); + } + + return (block); +} + +void +VESAFreeVBEInfo(VBEInfoBlock *block) +{ + xfree(block->OEMStringPtr); + xfree(block->VideoModePtr); + if (((unsigned)block->VESAVersion >> 8) >= 2) { + xfree(block->OemVendorNamePtr); + xfree(block->OemProductNamePtr); + xfree(block->OemProductRevPtr); + } + xfree(block); +} + +Bool +VESASetVBEMode(ScrnInfoPtr pScrn, int mode, CRTCInfoBlock *block) +{ + VESAPtr pVesa; + + pVesa = VESAGetRec(pScrn); + /* + Input: + AH := 4Fh Super VGA support + AL := 02h Set Super VGA video mode + BX := Video mode + D0-D8 := Mode number + D9-D10 := Reserved (must be 0) + D11 := 0 Use current default refresh rate + := 1 Use user specified CRTC values for refresh rate + D12-13 Reserved for VBE/AF (must be 0) + D14 := 0 Use windowed frame buffer model + := 1 Use linear/flat frame buffer model + D15 := 0 Clear video memory + := 1 Don't clear video memory + ES:DI := Pointer to CRTCInfoBlock structure + + Output: AX = Status + (All other registers are preserved) + */ + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f02; + pVesa->pInt->bx = mode; + if (block) { + pVesa->pInt->bx |= 1 << 11; + memcpy(pVesa->block, block, sizeof(CRTCInfoBlock)); + pVesa->pInt->es = SEG_ADDR(pVesa->page); + pVesa->pInt->di = SEG_OFF(pVesa->page); + } + + xf86ExecX86int10(pVesa->pInt); + + return (pVesa->pInt->ax == 0x4f); +} + +Bool +VESAGetVBEMode(ScrnInfoPtr pScrn, int *mode) +{ + VESAPtr pVesa; + + pVesa = VESAGetRec(pScrn); + /* + Input: + AH := 4Fh Super VGA support + AL := 03h Return current video mode + + Output: + AX := Status + BX := Current video mode + (All other registers are preserved) + */ + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f03; + + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax == 0x4f) { + *mode = pVesa->pInt->bx; + + return (TRUE); + } + + return (FALSE); +} + +ModeInfoBlock * +VESAGetModeInfo(ScrnInfoPtr pScrn, int mode) +{ + VESAPtr pVesa; + ModeInfoBlock *block = NULL; + + pVesa = VESAGetRec(pScrn); + bzero(pVesa->block, sizeof(ModeInfoBlock)); + + /* + Input: + AH := 4Fh Super VGA support + AL := 01h Return Super VGA mode information + CX := Super VGA video mode + (mode number must be one of those returned by Function 0) + ES:DI := Pointer to buffer + + Output: + AX := status + (All other registers are preserved) + */ + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f01; + pVesa->pInt->cx = mode; + pVesa->pInt->es = SEG_ADDR(pVesa->page); + pVesa->pInt->di = SEG_OFF(pVesa->page); + xf86ExecX86int10(pVesa->pInt); + if (pVesa->pInt->ax != 0x4f) + return (NULL); + + block = xcalloc(sizeof(ModeInfoBlock), 1); + + block->ModeAttributes = *(CARD16*)pVesa->block; + block->WinAAttributes = pVesa->block[2]; + block->WinBAttributes = pVesa->block[3]; + block->WinGranularity = *(CARD16*)(pVesa->block + 4); + block->WinSize = *(CARD16*)(pVesa->block + 6); + block->WinASegment = *(CARD16*)(pVesa->block + 8); + block->WinBSegment = *(CARD16*)(pVesa->block + 10); + block->WinFuncPtr = *(CARD32*)(pVesa->block + 12); + block->BytesPerScanline = *(CARD16*)(pVesa->block + 16); + + /* mandatory information for VBE 1.2 and above */ + block->XResolution = *(CARD16*)(pVesa->block + 18); + block->YResolution = *(CARD16*)(pVesa->block + 20); + block->XCharSize = pVesa->block[22]; + block->YCharSize = pVesa->block[23]; + block->NumberOfPlanes = pVesa->block[24]; + block->BitsPerPixel = pVesa->block[25]; + block->NumberOfBanks = pVesa->block[26]; + block->MemoryModel = pVesa->block[27]; + block->BankSize = pVesa->block[28]; + block->NumberOfImages = pVesa->block[29]; + block->Reserved = pVesa->block[30]; + + /* Direct color fields (required for direct/6 and YUV/7 memory models) */ + block->RedMaskSize = pVesa->block[31]; + block->RedFieldPosition = pVesa->block[32]; + block->GreenMaskSize = pVesa->block[33]; + block->GreenFieldPosition = pVesa->block[34]; + block->BlueMaskSize = pVesa->block[35]; + block->BlueFieldPosition = pVesa->block[36]; + block->RsvdMaskSize = pVesa->block[37]; + block->RsvdFieldPosition = pVesa->block[38]; + block->DirectColorModeInfo = pVesa->block[39]; + + /* Mandatory information for VBE 2.0 and above */ + if (pVesa->major >= 2) { + block->PhysBasePtr = *(CARD32*)(pVesa->block + 40); + block->Reserved32 = *(CARD32*)(pVesa->block + 44); + block->Reserved16 = *(CARD16*)(pVesa->block + 48); + + /* Mandatory information for VBE 3.0 and above */ + if (pVesa->major >= 3) { + block->LinBytesPerScanLine = *(CARD16*)(pVesa->block + 50); + block->BnkNumberOfImagePages = pVesa->block[52]; + block->LinNumberOfImagePages = pVesa->block[53]; + block->LinRedMaskSize = pVesa->block[54]; + block->LinRedFieldPosition = pVesa->block[55]; + block->LinGreenMaskSize = pVesa->block[56]; + block->LinGreenFieldPosition = pVesa->block[57]; + block->LinBlueMaskSize = pVesa->block[58]; + block->LinBlueFieldPosition = pVesa->block[59]; + block->LinRsvdMaskSize = pVesa->block[60]; + block->LinRsvdFieldPosition = pVesa->block[61]; + block->MaxPixelClock = *(CARD32*)(pVesa->block + 62); + memcpy(&block->Reserved2, pVesa->block + 66, 188); + } + else + memcpy(&block->LinBytesPerScanLine, pVesa->block + 50, 206); + } + else + memcpy(&block->PhysBasePtr, pVesa->block + 40, 216); + + return (block); +} + +void +VESAFreeModeInfo(ModeInfoBlock *block) +{ + xfree(block); +} + +Bool +VESASaveRestore(ScrnInfoPtr pScrn, int function) +{ + VESAPtr pVesa; + + if (MODE_QUERY < 0 || function > MODE_RESTORE) + return (FALSE); + + pVesa = VESAGetRec(pScrn); + + /* + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 00h Return save/restore state buffer size + CX := Requested states + D0 = Save/restore video hardware state + D1 = Save/restore video BIOS data state + D2 = Save/restore video DAC state + D3 = Save/restore Super VGA state + + Output: + AX = Status + BX = Number of 64-byte blocks to hold the state buffer + (All other registers are preserved) + + + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 01h Save Super VGA video state + CX := Requested states (see above) + ES:BX := Pointer to buffer + + Output: + AX := Status + (All other registers are preserved) + + + Input: + AH := 4Fh Super VGA support + AL := 04h Save/restore Super VGA video state + DL := 02h Restore Super VGA video state + CX := Requested states (see above) + ES:BX := Pointer to buffer + + Output: + AX := Status + (All other registers are preserved) + */ + + /* Query amount of memory to save state */ + if (function == MODE_QUERY || + (function == MODE_SAVE && pVesa->state == NULL)) { + int npages; + + /* Make sure we save at least this information in case of failure */ + (void)VESAGetVBEMode(pScrn, &pVesa->stateMode); + SaveFonts(pScrn); + + if (pVesa->major > 1) { + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f04; + pVesa->pInt->dx = 0; + pVesa->pInt->cx = 0x000f; + xf86ExecX86int10(pVesa->pInt); + if (pVesa->pInt->ax != 0x4f) + return (FALSE); + + npages = (pVesa->pInt->bx * 64) / 4096 + 1; + if ((pVesa->state = xf86Int10AllocPages(pVesa->pInt, npages, + &pVesa->statePage)) == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Cannot allocate memory to save SVGA state.\n"); + return (FALSE); + } + } + } + + /* Save/Restore Super VGA state */ + if (function != MODE_QUERY) { + int ax_reg = 0; + + if (pVesa->major > 1) { + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f04; + pVesa->pInt->dx = function; + pVesa->pInt->cx = 0x000f; + + if (function == MODE_RESTORE) + memcpy(pVesa->state, pVesa->pstate, pVesa->stateSize); + + pVesa->pInt->es = SEG_ADDR(pVesa->statePage); + pVesa->pInt->bx = SEG_OFF(pVesa->statePage); + xf86ExecX86int10(pVesa->pInt); + ax_reg = pVesa->pInt->ax; + } + + if (function == MODE_RESTORE) { + VESASetVBEMode(pScrn, pVesa->stateMode, NULL); + RestoreFonts(pScrn); + } + + if (pVesa->major > 1) { + if (ax_reg != 0x4f) + return (FALSE); + + if (function == MODE_SAVE && pVesa->pstate == NULL) { + /* don't rely on the memory not being touched */ + pVesa->stateSize = pVesa->pInt->bx * 64; + pVesa->pstate = xalloc(pVesa->stateSize); + memcpy(pVesa->pstate, pVesa->state, pVesa->stateSize); + } + } + } + + return (TRUE); +} + +int +VESABankSwitch(ScreenPtr pScreen, unsigned int iBank) +{ + VESAPtr pVesa; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + pVesa = VESAGetRec(pScrn); + if (pVesa->curBank == iBank) + return (0); + pVesa->curBank = iBank; + + /* + Input: + AH := 4Fh Super VGA support + AL := 05h + + Output: + */ + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f05; + pVesa->pInt->bx = 0; + pVesa->pInt->dx = iBank; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (1); + + if (pVesa->bankSwitchWindowB) { + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f05; + pVesa->pInt->bx = 1; + pVesa->pInt->dx = iBank; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (1); + } + + return (0); +} + +Bool +VESASetGetLogicalScanlineLength(ScrnInfoPtr pScrn, int command, int width, + int *pixels, int *bytes, int *max) +{ + VESAPtr pVesa; + + if (command < SCANWID_SET || command > SCANWID_GET_MAX) + return (FALSE); + + pVesa = VESAGetRec(pScrn); + /* + Input: + AX := 4F06h VBE Set/Get Logical Scan Line Length + BL := 00h Set Scan Line Length in Pixels + := 01h Get Scan Line Length + := 02h Set Scan Line Length in Bytes + := 03h Get Maximum Scan Line Length + CX := If BL=00h Desired Width in Pixels + If BL=02h Desired Width in Bytes + (Ignored for Get Functions) + + Output: + AX := VBE Return Status + BX := Bytes Per Scan Line + CX := Actual Pixels Per Scan Line + (truncated to nearest complete pixel) + DX := Maximum Number of Scan Lines + */ + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f06; + pVesa->pInt->bx = command; + if (command == SCANWID_SET || command == SCANWID_SET_BYTES) + pVesa->pInt->cx = width; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (FALSE); + + if (command == SCANWID_GET || command == SCANWID_GET_MAX) { + if (pixels) + *pixels = pVesa->pInt->cx; + if (bytes) + *bytes = pVesa->pInt->bx; + if (max) + *max = pVesa->pInt->dx; + } + + return (TRUE); +} + +Bool +VESASetDisplayStart(ScrnInfoPtr pScrn, int x, int y, Bool wait_retrace) +{ + VESAPtr pVesa; + + pVesa = VESAGetRec(pScrn); + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f07; + pVesa->pInt->bx = wait_retrace ? 0x80 : 0x00; + pVesa->pInt->cx = x; + pVesa->pInt->dx = y; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (FALSE); + + return (TRUE); +} + +Bool +VESAGetDisplayStart(ScrnInfoPtr pScrn, int *x, int *y) +{ + VESAPtr pVesa; + + pVesa = VESAGetRec(pScrn); + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f07; + pVesa->pInt->bx = 0x01; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (FALSE); + + *x = pVesa->pInt->cx; + *y = pVesa->pInt->dx; + + return (TRUE); +} + +int +VESASetGetDACPaletteFormat(ScrnInfoPtr pScrn, int bits) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + /* + Input: + AX := 4F08h VBE Set/Get Palette Format + BL := 00h Set DAC Palette Format + := 01h Get DAC Palette Format + BH := Desired bits of color per primary + (Set DAC Palette Format only) + + Output: + AX := VBE Return Status + BH := Current number of bits of color per primary + */ + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f08; + if (!bits) + pVesa->pInt->bx = 0x01; + else + pVesa->pInt->bx = (bits & 0x00ff) << 8; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (0); + + return (bits != 0 ? bits : (pVesa->pInt->bx >> 8) & 0x00ff); +} + +CARD32 * +VESASetGetPaletteData(ScrnInfoPtr pScrn, Bool set, int first, int num, + CARD32 *data, Bool secondary, Bool wait_retrace) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + /* + Input: + (16-bit) + AX := 4F09h VBE Load/Unload Palette Data + BL := 00h Set Palette Data + := 01h Get Palette Data + := 02h Set Secondary Palette Data + := 03h Get Secondary Palette Data + := 80h Set Palette Data during Vertical Retrace + CX := Number of palette registers to update (to a maximum of 256) + DX := First of the palette registers to update (start) + ES:DI := Table of palette values (see below for format) + + Output: + AX := VBE Return Status + + + Input: + (32-bit) + BL := 00h Set Palette Data + := 80h Set Palette Data during Vertical Retrace + CX := Number of palette registers to update (to a maximum of 256) + DX := First of the palette registers to update (start) + ES:EDI := Table of palette values (see below for format) + DS := Selector for memory mapped registers + */ + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f09; + if (!secondary) + pVesa->pInt->bx = set && wait_retrace ? 0x80 : set ? 0 : 1; + else + pVesa->pInt->bx = set ? 2 : 3; + pVesa->pInt->cx = num; + pVesa->pInt->dx = first; + pVesa->pInt->es = SEG_ADDR(pVesa->page); + pVesa->pInt->di = SEG_OFF(pVesa->page); + if (set) + memcpy(pVesa->block, data, num * sizeof(CARD32)); + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (NULL); + + if (set) + return (data); + + data = xalloc(num * sizeof(CARD32)); + memcpy(data, pVesa->block, num * sizeof(CARD32)); + + return (data); +} + +VESApmi * +VESAGetVBEpmi(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa; + VESApmi *pmi; + + pVesa = VESAGetRec(pScrn); + /* + Input: + AH := 4Fh Super VGA support + AL := 0Ah Protected Mode Interface + BL := 00h Return Protected Mode Table + + Output: + AX := Status + ES := Real Mode Segment of Table + DI := Offset of Table + CX := Lenght of Table including protected mode code in bytes (for copying purposes) + (All other registers are preserved) + */ + + pVesa->pInt->num = 0x10; + pVesa->pInt->ax = 0x4f0a; + pVesa->pInt->bx = 0; + pVesa->pInt->di = 0; + xf86ExecX86int10(pVesa->pInt); + + if (pVesa->pInt->ax != 0x4f) + return (NULL); + + pmi = xalloc(sizeof(VESApmi)); + pmi->seg_tbl = pVesa->pInt->es; + pmi->tbl_off = pVesa->pInt->di; + pmi->tbl_len = pVesa->pInt->cx; + + return (pmi); +} + +/*********************************************************************** + * DGA stuff + ***********************************************************************/ +static Bool VESADGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, + unsigned char **ApertureBase, + int *ApertureSize, int *ApertureOffset, + int *flags); +static Bool VESADGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode); +static void VESADGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags); + +static Bool +VESADGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, + unsigned char **ApertureBase, int *ApertureSize, + int *ApertureOffset, int *flags) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + *DeviceName = NULL; /* No special device */ + *ApertureBase = (unsigned char *)(pVesa->mapPhys); + *ApertureSize = pVesa->mapSize; + *ApertureOffset = pVesa->mapOff; + *flags = DGA_NEED_ROOT; + + return (TRUE); +} + +static Bool +VESADGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode) +{ + DisplayModePtr pMode; + int scrnIdx = pScrn->pScreen->myNum; + int frameX0, frameY0; + + if (pDGAMode) { + pMode = pDGAMode->mode; + frameX0 = frameY0 = 0; + } + else { + if (!(pMode = pScrn->currentMode)) + return (TRUE); + + frameX0 = pScrn->frameX0; + frameY0 = pScrn->frameY0; + } + + if (!(*pScrn->SwitchMode)(scrnIdx, pMode, 0)) + return (FALSE); + (*pScrn->AdjustFrame)(scrnIdx, frameX0, frameY0, 0); + + return (TRUE); +} + +static void +VESADGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) +{ + (*pScrn->AdjustFrame)(pScrn->pScreen->myNum, x, y, flags); +} + +static int +VESADGAGetViewport(ScrnInfoPtr pScrn) +{ + return (0); +} + +static DGAFunctionRec VESADGAFunctions = +{ + VESADGAOpenFramebuffer, + NULL, /* CloseFramebuffer */ + VESADGASetMode, + VESADGASetViewport, + VESADGAGetViewport, + NULL, /* Sync */ + NULL, /* FillRect */ + NULL, /* BlitRect */ + NULL, /* BlitTransRect */ +}; + +static void +VESADGAAddModes(ScrnInfoPtr pScrn) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + DisplayModePtr pMode = pScrn->modes; + DGAModePtr pDGAMode; + + do { + pDGAMode = xrealloc(pVesa->pDGAMode, + (pVesa->nDGAMode + 1) * sizeof(DGAModeRec)); + if (!pDGAMode) + break; + + pVesa->pDGAMode = pDGAMode; + pDGAMode += pVesa->nDGAMode; + (void)memset(pDGAMode, 0, sizeof(DGAModeRec)); + + ++pVesa->nDGAMode; + pDGAMode->mode = pMode; + pDGAMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; + pDGAMode->byteOrder = pScrn->imageByteOrder; + pDGAMode->depth = pScrn->depth; + pDGAMode->bitsPerPixel = pScrn->bitsPerPixel; + pDGAMode->red_mask = pScrn->mask.red; + pDGAMode->green_mask = pScrn->mask.green; + pDGAMode->blue_mask = pScrn->mask.blue; + pDGAMode->visualClass = pScrn->bitsPerPixel > 8 ? + TrueColor : PseudoColor; + pDGAMode->xViewportStep = 1; + pDGAMode->yViewportStep = 1; + pDGAMode->viewportWidth = pMode->HDisplay; + pDGAMode->viewportHeight = pMode->VDisplay; + + pDGAMode->bytesPerScanline = pVesa->maxBytesPerScanline; + pDGAMode->imageWidth = pMode->HDisplay; + pDGAMode->imageHeight = pMode->VDisplay; + pDGAMode->pixmapWidth = pDGAMode->imageWidth; + pDGAMode->pixmapHeight = pDGAMode->imageHeight; + pDGAMode->maxViewportX = pScrn->virtualX - + pDGAMode->viewportWidth; + pDGAMode->maxViewportY = pScrn->virtualY - + pDGAMode->viewportHeight; + + pDGAMode->address = pVesa->base; + + pMode = pMode->next; + } while (pMode != pScrn->modes); +} + +static Bool +VESADGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) +{ + VESAPtr pVesa = VESAGetRec(pScrn); + + if (pScrn->depth < 8 || pVesa->mapPhys == 0xa0000L) + return (FALSE); + + if (!pVesa->nDGAMode) + VESADGAAddModes(pScrn); + + return (DGAInit(pScreen, &VESADGAFunctions, + pVesa->pDGAMode, pVesa->nDGAMode)); +} Index: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp:1.2 --- /dev/null Mon Dec 18 14:31:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp Mon Dec 11 15:18:42 2000 @@ -0,0 +1,53 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.cpp,v 1.2 2000/12/11 20:18:42 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH VESA __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +vesa \- Generic VESA video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qvesa\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B vesa +is an XFree86 driver for generic VESA video cards. It can drive most +VESA-compatible video cards, but only makes use of the basic standard +VESA core that is common to these cards. The driver supports depths 8, 15 +16 and 24. +.SH SUPPORTED HARDWARE +The +.B vesa +driver supports most VESA-compatible video cards. There are some known +exceptions, and those should be listed here. +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.PP +The driver auto-detects the presence of VESA-compatible hardware. The +.B ChipSet +name may optionally be specified in the config file +.B \*qDevice\*q +section, and will override the auto-detection: +.PP +.RS 4 +"vesa" +.RE +.PP +The following driver +.B Options +are supported: +.TP +.BI "Option \*qShadowFB\*q \*q" boolean \*q +Enable or disable use of the shadow framebuffer layer. See +shadowfb(__drivermansuffix__) for further information. Default: on. + +This option is recommended for performance reasons. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86cfg(1), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +Authors include: Paulo César Pereira de Andrade. Index: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h:1.5 --- /dev/null Mon Dec 18 14:31:19 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h Fri Dec 1 14:56:01 2000 @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h,v 1.5 2000/12/01 19:56:01 paulo Exp $ + */ + +#ifndef _VESA_H_ +#define _VESA_H_ + +/* All drivers should typically include these */ +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" + +/* All drivers need this */ +#include "xf86_ansic.h" + +#include "compiler.h" + +/* Drivers for PCI hardware need this */ +#include "xf86PciInfo.h" + +#include "vgaHW.h" + +/* Drivers that need to access the PCI config space directly need this */ +#include "xf86Pci.h" + +/* VBE/DDC support */ +#include "vbe.h" +#include "xf86DDC.h" + +/* ShadowFB support */ +#include "shadow.h" + +/* Int 10 support */ +#include "xf86int10.h" + +/* bank switching */ +#include "mibank.h" + +/* Dga definitions */ +#include "dgaproc.h" + +#ifdef RENDER +#include "picturestr.h" +#endif + +#include "xf86Resources.h" +#include "xf86RAC.h" + +#include "xf1bpp.h" +#include "xf4bpp.h" +#include "fb.h" +#include "afb.h" + +#define VESA_VERSION 4000 +#define VESA_NAME "VESA" +#define VESA_DRIVER_NAME "vesa" +#define VESA_MAJOR_VERSION 1 +#define VESA_MINOR_VERSION 0 +#define VESA_PATCHLEVEL 0 + +typedef struct _VBEInfoBlock VBEInfoBlock; +typedef struct _ModeInfoBlock ModeInfoBlock; +typedef struct _CRTCInfoBlock CRTCInfoBlock; + +typedef struct _VESARec +{ + xf86Int10InfoPtr pInt; + EntityInfoPtr pEnt; + CARD16 major, minor; + VBEInfoBlock *vbeInfo; + GDevPtr device; + pciVideoPtr pciInfo; + PCITAG pciTag; + miBankInfoRec bank; + int curBank, bankSwitchWindowB; + CARD16 maxBytesPerScanline; + int mapPhys, mapOff, mapSize; /* video memory */ + void *base, *VGAbase; + CARD8 *state, *pstate; /* SVGA state */ + int statePage, stateSize, stateMode; + int page; + CARD8 *block; + int pix24bpp; + CARD32 *pal, *savedPal; + CARD8 *fonts; + xf86MonPtr monitor; + Bool shadowFB, primary; + CARD8 *shadowPtr; + CARD32 windowAoffset; + /* DGA info */ + DGAModePtr pDGAMode; + int nDGAMode; +} VESARec, *VESAPtr; + +#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff)) + +#ifndef __GNUC__ +#define __attribute__(a) +#endif + +typedef struct _ModeInfoData { + int mode; + ModeInfoBlock *data; + CRTCInfoBlock *block; +} ModeInfoData; + +/* + * INT 0 + */ +struct _VBEInfoBlock { + /* VESA 1.2 fields */ + CARD8 VESASignature[4]; /* VESA */ + CARD16 VESAVersion; /* Higher byte major, lower byte minor */ + /*CARD32*/char *OEMStringPtr; /* Pointer to OEM string */ + CARD8 Capabilities[4]; /* Capabilities of the video environment */ + + /*CARD32*/CARD16 *VideoModePtr; /* pointer to supported Super VGA modes */ + + CARD16 TotalMemory; /* Number of 64kb memory blocks on board */ + /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */ + + /* VESA 2 fields */ + CARD16 OemSoftwareRev; /* VBE implementation Software revision */ + /*CARD32*/char *OemVendorNamePtr; /* Pointer to Vendor Name String */ + /*CARD32*/char *OemProductNamePtr; /* Pointer to Product Name String */ + /*CARD32*/char *OemProductRevPtr; /* Pointer to Product Revision String */ + CARD8 Reserved[222]; /* Reserved for VBE implementation */ + CARD8 OemData[256]; /* Data Area for OEM Strings */ +} __attribute__((packed)); + +/* Return Super VGA Information */ +VBEInfoBlock *VESAGetVBEInfo(ScrnInfoPtr pScrn); +void VESAFreeVBEInfo(VBEInfoBlock *block); + +/* + * INT 1 + */ +struct _ModeInfoBlock { + CARD16 ModeAttributes; /* mode attributes */ + CARD8 WinAAttributes; /* window A attributes */ + CARD8 WinBAttributes; /* window B attributes */ + CARD16 WinGranularity; /* window granularity */ + CARD16 WinSize; /* window size */ + CARD16 WinASegment; /* window A start segment */ + CARD16 WinBSegment; /* window B start segment */ + CARD32 WinFuncPtr; /* real mode pointer to window function */ + CARD16 BytesPerScanline; /* bytes per scanline */ + + /* Mandatory information for VBE 1.2 and above */ + CARD16 XResolution; /* horizontal resolution in pixels or characters */ + CARD16 YResolution; /* vertical resolution in pixels or characters */ + CARD8 XCharSize; /* character cell width in pixels */ + CARD8 YCharSize; /* character cell height in pixels */ + CARD8 NumberOfPlanes; /* number of memory planes */ + CARD8 BitsPerPixel; /* bits per pixel */ + CARD8 NumberOfBanks; /* number of banks */ + CARD8 MemoryModel; /* memory model type */ + CARD8 BankSize; /* bank size in KB */ + CARD8 NumberOfImages; /* number of images */ + CARD8 Reserved; /* 1 */ /* reserved for page function */ + + /* Direct color fields (required for direct/6 and YUV/7 memory models) */ + CARD8 RedMaskSize; /* size of direct color red mask in bits */ + CARD8 RedFieldPosition; /* bit position of lsb of red mask */ + CARD8 GreenMaskSize; /* size of direct color green mask in bits */ + CARD8 GreenFieldPosition; /* bit position of lsb of green mask */ + CARD8 BlueMaskSize; /* size of direct color blue mask in bits */ + CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */ + CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */ + CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */ + CARD8 DirectColorModeInfo; /* direct color mode attributes */ + + /* Mandatory information for VBE 2.0 and above */ + CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */ + CARD32 Reserved32; /* 0 */ /* Reserved - always set to 0 */ + CARD16 Reserved16; /* 0 */ /* Reserved - always set to 0 */ + + /* Mandatory information for VBE 3.0 and above */ + CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */ + CARD8 BnkNumberOfImagePages; /* number of images for banked modes */ + CARD8 LinNumberOfImagePages; /* number of images for linear modes */ + CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */ + CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */ + CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */ + CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */ + CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */ + CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */ + CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */ + CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */ + CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */ + CARD8 Reserved2[189]; /* remainder of ModeInfoBlock */ +} __attribute__((packed)); + +/* Return VBE Mode Information */ +ModeInfoBlock *VESAGetModeInfo(ScrnInfoPtr pScrn, int mode); +void VESAFreeModeInfo(ModeInfoBlock *block); + +/* + * INT2 + */ +#define CRTC_DBLSCAN (1<<0) +#define CRTC_INTERLACE (1<<1) +#define CRTC_NHSYNC (1<<2) +#define CRTC_NVSYNC (1<<3) + +struct _CRTCInfoBlock { + CARD16 HorizontalTotal; /* Horizontal total in pixels */ + CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */ + CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */ + CARD16 VerticalTotal; /* Vertical total in lines */ + CARD16 VerticalSyncStart; /* Vertical sync start in lines */ + CARD16 VerticalSyncEnd; /* Vertical sync end in lines */ + CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */ + CARD32 PixelClock; /* Pixel clock in units of Hz */ + CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */ + CARD8 Reserved[40]; /* remainder of ModeInfoBlock */ +} __attribute__((packed)); +/* CRTCInfoBlock is in the VESA 3.0 specs */ + +Bool VESASetVBEMode(ScrnInfoPtr pScrn, int mode, CRTCInfoBlock *crtc); + +/* + * INT 3 + */ +Bool VESAGetVBEMode(ScrnInfoPtr pScrn, int *mode); + +/* + * INT 4 + */ +/* Save/Restore Super VGA video state */ +/* function values are (values stored in VESAPtr): + * 0 := query & allocate amount of memory to save state + * 1 := save state + * 2 := restore state + * + * function 0 called automatically if function 1 called without + * a previous call to function 0. + */ +#define MODE_QUERY 0 +#define MODE_SAVE 1 +#define MODE_RESTORE 2 +Bool VESASaveRestore(ScrnInfoPtr pScrn, int function); + +/* + * INT 6 + */ +#define SCANWID_SET 0 +#define SCANWID_GET 1 +#define SCANWID_SET_BYTES 2 +#define SCANWID_GET_MAX 3 +#define VESASetLogicalScanline(pScrn, width) \ + VESASetGetLogicalScanlineLength(pScrn, SCANWID_SET, \ + width, NULL, NULL, NULL) +#define VESASetLogicalScanlineBytes(pScrn, width) \ + VESASetGetLogicalScanlineLength(pScrn, width, SCANWID_SET_BYTES, \ + NULL, NULL, NULL) +#define VESAGetLogicalScanline(pScrn, pixels, bytes, max) \ + VESASetGetLogicalScanlineLength(pScrn, SCANWID_GET, NULL, \ + pixels, bytes, max) +#define VESAGetMaxLogicalScanline(pScrn, pixels, bytes, max) \ + VESASetGetLogicalScanlineLength(pScrn, SCANWID_GET_MAX, \ + NULL, pixels, bytes, max) +Bool VESASetGetLogicalScanlineLength(ScrnInfoPtr pScrn, int command, int width, + int *pixels, int *bytes, int *max); + +/* + * INT 7 + */ +/* 16 bit code */ +Bool VESASetDisplayStart(ScrnInfoPtr pScrn, int x, int y, Bool wait_retrace); +Bool VESAGetDisplayStart(ScrnInfoPtr pScrn, int *x, int *y); + +/* + * INT 8 + */ +/* if bits is 0, then it is a GET */ +int VESASetGetDACPaletteFormat(ScrnInfoPtr pScrn, int bits); + +/* + * INT 9 + */ +/* + * If getting a palette, the data argument is not used. It will return + * the data. + * If setting a palette, it will return the pointer received on success, + * NULL on failure. + */ +CARD32 *VESASetGetPaletteData(ScrnInfoPtr pScrn, Bool set, int first, int num, + CARD32 *data, Bool secondary, Bool wait_retrace); +#define VESAFreePaletteData(data) xfree(data) + +/* + * INT A + */ +typedef struct _VESApmi { + int seg_tbl; + int tbl_off; + int tbl_len; +} VESApmi; + +VESApmi *VESAGetVBEpmi(ScrnInfoPtr pScrn); +#define VESAFreeVBEpmi(pmi) xfree(pmi) + +#endif /* _VESA_H_ */ Index: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c diff -u xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c:1.44 xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c:1.48 --- xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c:1.44 Thu Apr 27 12:26:49 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c Sat Dec 2 10:31:00 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.44 2000/04/27 16:26:49 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.48 2000/12/02 15:31:00 tsi Exp $ */ /* * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved. * @@ -235,7 +235,7 @@ { Bool foundScreen = FALSE; int numDevSections, numUsed; - GDevPtr *devSections = NULL; + GDevPtr *devSections; int *usedChips; int i; @@ -278,9 +278,9 @@ pScrn->ValidMode = GenericValidMode; foundScreen = TRUE; } - xfree(usedChips); } } + xfree(usedChips); } } @@ -291,8 +291,8 @@ numDevSections,&usedChips); if(numUsed > 0) { if (flags & PROBE_DETECT) - return TRUE; - for (i = 0; i < numUsed; i++) { + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn = NULL; if ((pScrn = xf86ConfigIsaEntity(pScrn,0,usedChips[i], GenericISAchipsets,NULL, @@ -312,12 +312,11 @@ pScrn->ValidMode = GenericValidMode; foundScreen = TRUE; } - xfree(usedChips); } + xfree(usedChips); } - if (devSections) - xfree(devSections); + xfree(devSections); return foundScreen; } @@ -776,10 +775,6 @@ { vgaHWPtr pvgaHW = VGAHWPTR(pScreenInfo); - /* Map VGA aperture */ - if (!vgaHWMapMem(pScreenInfo)) - return FALSE; - /* Unlock VGA registers */ vgaHWUnlock(pvgaHW); @@ -804,7 +799,6 @@ { GenericRestore(pScreenInfo); vgaHWLock(VGAHWPTR(pScreenInfo)); - vgaHWUnmapMem(pScreenInfo); } @@ -825,8 +819,11 @@ Closed = (*pScreen->CloseScreen)(scrnIndex, pScreen); } - GenericLeaveGraphics(pScreenInfo); - pScreenInfo->vtSema = FALSE; + if (pScreenInfo->vtSema) { + GenericLeaveGraphics(pScreenInfo); + pScreenInfo->vtSema = FALSE; + } + vgaHWUnmapMem(pScreenInfo); return Closed; } @@ -1064,6 +1061,9 @@ /* Get driver private */ pGenericPriv = GenericGetRec(pScreenInfo); + /* Map VGA aperture */ + if (!vgaHWMapMem(pScreenInfo)) + return FALSE; /* Initialise graphics mode */ if (!GenericEnterGraphics(pScreen, pScreenInfo)) Index: xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp diff -u xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp:1.6 xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp:1.7 --- xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp:1.6 Tue Jun 13 22:13:16 2000 +++ xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp Mon Dec 11 15:18:43 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp,v 1.6 2000/06/14 02:13:16 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp,v 1.7 2000/12/11 20:18:43 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH VGA __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH VGA __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME vga \- Generic VGA video driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/dummylib/Imakefile diff -u xc/programs/Xserver/hw/xfree86/dummylib/Imakefile:1.1 xc/programs/Xserver/hw/xfree86/dummylib/Imakefile:1.2 --- xc/programs/Xserver/hw/xfree86/dummylib/Imakefile:1.1 Sat Feb 12 22:06:38 2000 +++ xc/programs/Xserver/hw/xfree86/dummylib/Imakefile Thu Nov 16 14:45:02 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/Imakefile,v 1.1 2000/02/13 03:06:38 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/Imakefile,v 1.2 2000/11/16 19:45:02 eich Exp $ #include <Server.tmpl> @@ -25,7 +25,8 @@ xf86opt.c \ xf86screens.c \ xf86servisinit.c \ - xf86verbose.c + xf86verbose.c \ + sigiostubs.c OBJS = \ fatalerror.o \ @@ -47,8 +48,10 @@ xf86opt.o \ xf86screens.o \ xf86servisinit.o \ - xf86verbose.o + xf86verbose.o \ + sigiostubs.o +LinkSourceFile(sigiostubs.c,../os-support/shared) NormalLibraryObjectRule() NormalLibraryTarget(dummy,$(OBJS)) Index: xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c diff -u xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c:1.1 xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c:1.2 --- xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c:1.1 Sat Feb 12 22:06:38 2000 +++ xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c Thu Dec 7 10:43:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c,v 1.1 2000/02/13 03:06:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/getvalidbios.c,v 1.2 2000/12/07 15:43:45 tsi Exp $ */ #include "X.h" #include "os.h" @@ -10,7 +10,7 @@ */ memType -getValidBIOSBase(PCITAG tag, int num) +getValidBIOSBase(PCITAG tag, int *num) { return 0; } Index: xc/programs/Xserver/hw/xfree86/etc/Imakefile diff -u xc/programs/Xserver/hw/xfree86/etc/Imakefile:3.36 xc/programs/Xserver/hw/xfree86/etc/Imakefile:3.37 --- xc/programs/Xserver/hw/xfree86/etc/Imakefile:3.36 Thu Feb 24 13:50:44 2000 +++ xc/programs/Xserver/hw/xfree86/etc/Imakefile Sun Jul 30 13:12:21 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/etc/Imakefile,v 3.36 2000/02/24 18:50:44 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/etc/Imakefile,v 3.37 2000/07/30 17:12:21 dawes Exp $ #include <Server.tmpl> #if SystemV @@ -92,6 +92,7 @@ NormalProgramTarget(scanpci,scanpci.o,NullParameter,-L../os-support -lxf86_os -L../scanpci -lscanpci -L../dummylib -ldummy $(SERVEREXTRASYSLIBS),NullParameter) InstallProgram(scanpci,$(BINDIR)) +InstallManPage(scanpci,$(MANDIR)) #endif #if JoystickSupport || Joystick2Support @@ -108,6 +109,7 @@ AllTarget(ProgramTargetName(pcitweak)) NormalProgramTarget(pcitweak,pcitweak.o,NullParameter,-L../os-support -lxf86_os -L../dummylib -ldummy $(SERVEREXTRASYSLIBS),NullParameter) InstallProgram(pcitweak,$(BINDIR)) +InstallManPage(pcitweak,$(MANDIR)) SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) Index: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh diff -u xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.13 xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.18 --- xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.13 Fri Jun 30 17:44:37 2000 +++ xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh Thu Dec 14 22:01:45 2000 @@ -1,13 +1,13 @@ #!/bin/sh # -# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.13 2000/06/30 21:44:37 dawes Exp $ +# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.18 2000/12/15 03:01:45 dawes Exp $ # # Copyright © 2000 by Precision Insight, Inc. # Copyright © 2000 by VA Linux Systems, Inc. # Portions Copyright © 1996-2000 by The XFree86 Project, Inc. # -# This script should be used to install XFree86 4.0.1. +# This script should be used to install XFree86 4.0.2. # # Parts of this script are based on the old preinst.sh and postinst.sh # scripts. @@ -17,7 +17,7 @@ # Authors: David Dawes <dawes@xfree86.org> # -VERSION=4.0.1 +VERSION=4.0.2 RUNDIR=/usr/X11R6 ETCDIR=/etc/X11 @@ -267,6 +267,7 @@ tmp="`strings $LibcPath | grep -i 'c library'`" OsLibcMajor=`expr "$tmp" : '.* \([0-9][0-9]*\)'` OsLibcMinor=`expr "$tmp" : '.* [0-9][0-9]*\.\([0-9][0-9]*\)'` + OsLibcTeeny=`expr "$tmp" : '.* [0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)'` case "$OsLibcMajor" in 2) # 2 is the glibc version @@ -279,15 +280,23 @@ if [ X"$OsLibcMajor" != X ]; then Echo "libc version is '$OsLibcMajor" if [ X"$OsLibcMinor" != X ]; then - Echo ".$OsLibcMinor'." + Echo ".$OsLibcMinor" + if [ X"$OsLibcTeeny" != X ]; then + Echo ".$OsLibcTeeny" + if [ $OsLibcTeeny -gt 80 ]; then + OsLibcMinor=`expr $OsLibcMinor + 1` + fi + fi + Echo "'" + Echo " ($OsLibcMajor.$OsLibcMinor)" else - Echo "'." + Echo "'" fi - needNL=YES - fi - if [ X"$needNL" = XYES ]; then - echo "" + echo "." fi +# if [ X"$needNL" = XYES ]; then +# echo "" +# fi echo "" } @@ -301,6 +310,10 @@ ELF) # Check ldconfig LDSO=`/sbin/ldconfig -v -n | awk '{ print $3 }'` + # if LDSO is empty ldconfig may be Version 2 + if [ X"$LDSO" = X ]; then + LDSO=`/sbin/ldconfig -V | awk 'NR == 1 { print $4 }'` + fi LDSOMIN=`echo $LDSO | awk -F[.-] '{ print $3 }'` LDSOMID=`echo $LDSO | awk -F[.-] '{ print $2 }'` LDSOMAJ=`echo $LDSO | awk -F[.-] '{ print $1 }'` @@ -332,6 +345,23 @@ FindDistName() { case "$OsName" in + Darwin) + case "$OsArch" in + Power*) + case "$OsVersion" in + 1.[2-9]) + DistName="Darwin" + ;; + *) + Message="No Darwin binaries available for this OS version" + ;; + esac + ;; + *) + Message="Darwin binaries are only available for Power Mac platforms" + ;; + esac + ;; DGUX) # Check this string case "$OsArch" in i*86) @@ -400,8 +430,11 @@ 1) DistName="Linux-ix86-glibc21" ;; + 2) + DistName="Linux-ix86-glibc22" + ;; *) - Message="No dist available for glibc 2.$OsLibcMinor. Try Linux-ix86-glibc21" + Message="No dist available for glibc 2.$OsLibcMinor. Try Linux-ix86-glibc22" ;; esac ;; @@ -452,13 +485,13 @@ case "$OsArch" in i386) case "$OsVersion" in - 1.[3-9]*) # Check this + 1.[4-9]*) # Check this case "$OsObjFormat" in a.out) DistName="NetBSD-1.4.1" ;; *) - DistName="NetBSD-current-ELF" + DistName="NetBSD-1.5" ;; esac ;; @@ -476,8 +509,8 @@ case "$OsArch" in i386) case "$OsVersion" in - 2.[6-9]*) # Check this - DistName="OpenBSD-2.6" + 2.[89]*) # Check this + DistName="OpenBSD-2.8" ;; *) Message="No OpenBSD/i386 binaries available for this version" @@ -583,6 +616,9 @@ # Make OS-specific adjustments case "$OsName" in +Darwin) + SERVDIST="Xxserv.tgz" + ;; FreeBSD|NetBSD|OpenBSD) VARDIST="Xvar.tgz" XKBDIR="/var/db/xkb" @@ -1155,3 +1191,6 @@ echo "Installation complete." exit 0 +### Local Variables: *** +### tab-width: 4 *** +### End: *** Index: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar diff -u xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar:3.12 xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar:3.13 --- xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar:3.12 Thu May 11 14:14:36 2000 +++ xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar Tue Oct 24 14:07:51 2000 @@ -28,7 +28,7 @@ # xf86test/Makefile # xf86test/xf86test.c # -# $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.12 2000/05/11 18:14:36 tsi Exp $ +# $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.13 2000/10/24 18:07:51 dawes Exp $ # echo x - COPYRIGHT sed 's/^X//' >COPYRIGHT << 'END-of-COPYRIGHT' @@ -830,11 +830,20 @@ X * allow only section in the vga framebuffer and above main memory X * to be mapped X */ +X#if !defined(__NetBSD_Version__) || \ +X (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105000000)) Xint Xxf86mmap(dev, offset, length) X dev_t dev; X int offset; X int length; +X#else +Xpaddr_t +Xxf86mmap(dev, offset, length) +X dev_t dev; +X off_t offset; +X int length; +X#endif /* __NetBSD_Version__ */ X{ X X#ifdef XF86_DEBUG @@ -2040,7 +2049,7 @@ X/* X * Copyright (C) 1999, The XFree86 Project Inc. X * -X * $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.12 2000/05/11 18:14:36 tsi Exp $ +X * $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.13 2000/10/24 18:07:51 dawes Exp $ X */ X#ifndef _XF86_MOD_H X#define _XF86_MOD_H Index: xc/programs/Xserver/hw/xfree86/etc/pcitweak.c diff -u xc/programs/Xserver/hw/xfree86/etc/pcitweak.c:1.13 xc/programs/Xserver/hw/xfree86/etc/pcitweak.c:1.14 --- xc/programs/Xserver/hw/xfree86/etc/pcitweak.c:1.13 Sat Feb 12 22:06:44 2000 +++ xc/programs/Xserver/hw/xfree86/etc/pcitweak.c Thu Aug 10 13:40:34 2000 @@ -5,7 +5,7 @@ * * Author: David Dawes <dawes@xfree86.org> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/pcitweak.c,v 1.13 2000/02/13 03:06:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/pcitweak.c,v 1.14 2000/08/10 17:40:34 dawes Exp $ */ #include "X.h" #include "os.h" @@ -13,6 +13,10 @@ #include "xf86Priv.h" #include "xf86_OSproc.h" #include "xf86Pci.h" + +#ifdef __CYGWIN__ +#include <getopt.h> +#endif #include <stdarg.h> #include <stdlib.h> Index: xc/programs/Xserver/hw/xfree86/etc/pcitweak.man diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/pcitweak.man:3.2 --- /dev/null Mon Dec 18 14:31:22 2000 +++ xc/programs/Xserver/hw/xfree86/etc/pcitweak.man Mon Dec 11 15:18:44 2000 @@ -0,0 +1,64 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/pcitweak.man,v 3.2 2000/12/11 20:18:44 dawes Exp $ +.TH PCITWEAK 1 "Version 4.0.2" "XFree86" +.SH NAME +pcitweak - read/write PCI config space +.SH SYNOPSIS +.B pcitweak +.B \-l +.br +.B pcitweak +.B \-r +.I PCI-ID +.RB [ \-b | \-h ] +.I offset +.br +.B pcitweak +.B \-w +.I PCI-ID +.RB [ \-b | \-h ] +.I offset +.I value +.SH DESCRIPTION +.I Pcitweak +is a utility that can be used to examine or change registers in the PCI +configuration space. On most platfoms +.I pcitweak +can only be run by the root user. +.SH OPTIONS +.TP 8 +.B \-l +Probe the PCI buses and print a line for each detected device. Each line +contains the bus location (bus:device:function), chip vendor/device, card +(subsystem) vendor/card, revision, class and header type. All values +printed are in hexadecimal. +.TP 8 +.BI "\-r " PCI-ID +Read the PCI configuration space register at +.I offset +for the PCI device at bus location +.IR PCI-ID . +.I PCI-ID +should be given in the form bus:device:function, with each value in +hexadecimal. By default, a 32-bit register is read. +.TP 8 +.BI "\-w " PCI-ID +Write +.I value +to the PCI configuration space register at +.I offset +for the PCI device at bus location +.IR PCI-ID . +.I PCI-ID +should be given in the form bus:device:function, with each value in +hexadecimal. By default, a 32-bit register is written. +.TP 8 +.B \-b +Read or write an 8-bit value (byte). +.TP 8 +.B \-h +Read or write a 16-bit value (halfword). +.SH "SEE ALSO" +scanpci(1) +.SH AUTHORS +David Dawes +.RI ( dawes@xfree86.org ). Index: xc/programs/Xserver/hw/xfree86/etc/scanpci.man diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/scanpci.man:3.2 --- /dev/null Mon Dec 18 14:31:22 2000 +++ xc/programs/Xserver/hw/xfree86/etc/scanpci.man Mon Dec 11 15:18:45 2000 @@ -0,0 +1,42 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.man,v 3.2 2000/12/11 20:18:45 dawes Exp $ +.TH SCANPCI 1 "Version 4.0.2" "XFree86" +.SH NAME +scanpci - scan/probe PCI buses +.SH SYNOPSIS +.B scanpci +.RB [ \-v12OfV ] +.SH DESCRIPTION +.I Scanpci +is a utility that can be used to scan PCI buses and report information +about the configuration space settings for each PCI device. +On most platforms, +.I scanpci +can only be run by the root user. +.SH OPTIONS +.TP 8 +.B \-v +Print the configuration space information for each device in a verbose +format. Without this option, only a brief description is printed for +each device. +.TP 8 +.B \-1 +Use PCI config type 1. +.TP 8 +.B \-2 +Use PCI config type 2. +.TP 8 +.B \-f +Used in conjunction with the above two options, this forces the specified +configuration type to be used for config space access. +.TP 8 +.B \-O +Use the OS's PCI config space access mechanism to access the PCI config +space (when available). +.TP 8 +.BI "\-V " n +Set the verbosity level to +.I n +for the internal PCI scanner. This is primarily for debugging use. +.SH "SEE ALSO" +pcitweak(1) +.SH AUTHORS Index: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.3 xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.4 --- xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.3 Tue Feb 22 12:11:41 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist Thu Dec 14 16:50:09 2000 @@ -1,6 +1,6 @@ #!/bin/sh # -# $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist,v 1.3 2000/02/22 17:11:41 dawes Exp $ +# $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist,v 1.4 2000/12/14 21:50:09 dawes Exp $ # Usage() @@ -9,11 +9,11 @@ exit 1 } -listonly=NO +createlist=NO case $1 in -l) - listonly=YES + createlist=YES shift ;; esac @@ -81,7 +81,7 @@ mkdir $TODIR/$BINDIR fi -if [ $listonly = YES ]; then +if [ $createlist = YES ]; then GenList exit 0; fi @@ -126,6 +126,6 @@ ) done -GenList +# GenList exit 0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-excl:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-excl Sat Dec 9 19:06:17 2000 @@ -0,0 +1,6 @@ +bin/Xnest +bin/Xprt +bin/Xvfb +bin/X +bin/xfs +bin/Xdarwin Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/bin-list Sat Dec 9 19:06:18 2000 @@ -0,0 +1 @@ +bin Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/dir diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/dir:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/dir Sat Dec 9 19:06:18 2000 @@ -0,0 +1 @@ +usr/X11R6 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-dir diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-dir:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-dir Sat Dec 9 19:06:19 2000 @@ -0,0 +1 @@ +etc/X11 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/etc-list Sat Dec 9 19:06:20 2000 @@ -0,0 +1 @@ +. Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/fsrv-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/fsrv-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/fsrv-list Sat Dec 9 19:06:20 2000 @@ -0,0 +1,2 @@ +bin/xfs +man/cat1/xfs.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/host.def diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/host.def:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/host.def Sat Dec 9 19:06:21 2000 @@ -0,0 +1,8 @@ +/* + * Host.def for building Darwin bindists + * + * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/host.def,v 1.1 2000/12/10 00:06:21 herrb Exp $ + */ + +#define InstallEmptyHostDef + Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-excl:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-excl Sat Dec 9 19:06:21 2000 @@ -0,0 +1,14 @@ +lib/X11/XF86Setup +lib/X11/app-defaults +lib/X11/config +lib/X11/doc +lib/X11/fonts +lib/X11/fs +lib/X11/lbxproxy +lib/X11/proxymngr +lib/X11/rstart +lib/X11/twm +lib/X11/xdm +lib/X11/xinit +lib/X11/xsm +lib/X11/xserver Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/lib-list Sat Dec 9 19:06:22 2000 @@ -0,0 +1,2 @@ +lib/X11 +include/X11/bitmaps Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-excl:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-excl Sat Dec 9 19:06:23 2000 @@ -0,0 +1,3 @@ +man/cat1/XF86Setup.0 +man/cat1/xfs.0 +man/cat1/xmseconfig.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/man-list Sat Dec 9 19:06:23 2000 @@ -0,0 +1 @@ +man Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/nest-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/nest-list:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/nest-list Sat Dec 9 19:06:24 2000 @@ -0,0 +1 @@ +bin/Xnest Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-excl:1.1 --- /dev/null Mon Dec 18 14:31:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-excl Sat Dec 9 19:06:25 2000 @@ -0,0 +1,5 @@ +lib/Server +lib/X11 +lib/lib*.so* +lib/modules +include/X11/bitmaps Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-list:1.1 --- /dev/null Mon Dec 18 14:31:24 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prog-list Sat Dec 9 19:06:25 2000 @@ -0,0 +1,3 @@ +lib +include +lib/X11/config Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prt-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prt-list:1.1 --- /dev/null Mon Dec 18 14:31:24 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/prt-list Sat Dec 9 19:06:26 2000 @@ -0,0 +1 @@ +bin/Xprt Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/vfb-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/vfb-list:1.1 --- /dev/null Mon Dec 18 14:31:24 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/vfb-list Sat Dec 9 19:06:28 2000 @@ -0,0 +1 @@ +bin/Xvfb Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/xserv-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/xserv-list:1.1 --- /dev/null Mon Dec 18 14:31:24 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Darwin/xserv-list Sat Dec 9 19:06:28 2000 @@ -0,0 +1,2 @@ +bin/Xdarwin +bin/X Index: xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD/bin-list:1.7 xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD/bin-list:1.9 --- xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD/bin-list:1.7 Sat Feb 26 20:01:55 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD/bin-list Thu Dec 14 17:06:34 2000 @@ -4,6 +4,8 @@ lib/libGL.so lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6 @@ -21,6 +23,8 @@ lib/libXext.so lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6 lib/libXi.so lib/libXmu.so.6 @@ -29,6 +33,8 @@ lib/libXp.so lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6 lib/libXt.so lib/libXtst.so.6 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD-aout/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD-aout/bin-list:1.3 xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD-aout/bin-list:1.7 --- xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD-aout/bin-list:1.3 Sat Feb 26 20:01:55 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/FreeBSD-aout/bin-list Thu Dec 14 21:06:06 2000 @@ -3,17 +3,19 @@ lib/libICE.so.6.3 lib/libPEX5.so.6.0 lib/libSM.so.6.0 -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libXIE.so.6.0 lib/libXThrStub.so.6.0 lib/libXaw.so.6.1 lib/libXaw.so.7.0 lib/libXext.so.6.4 lib/libXfont.so.1.3 +lib/libXft.so.1.0 lib/libXi.so.6.0 -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXp.so.6.2 lib/libXpm.so.4.11 +lib/libXrender.so.1.0 lib/libXt.so.6.0 lib/libXtst.so.6.1 lib/libdps.so.1.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/bin-list:1.5 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/bin-list:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/bin-list:1.5 Sat Feb 26 20:01:55 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/bin-list Thu Dec 14 17:06:35 2000 @@ -5,13 +5,16 @@ lib/libICE.so.6.3 lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3.3 +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6.0 lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so.6 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so.6 lib/libX11.so lib/libXIE.so.6.0 @@ -28,10 +31,13 @@ lib/libXfont.so.1.3 lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so.6 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so.6 lib/libXmu.so lib/libXp.so.6.2 @@ -40,6 +46,9 @@ lib/libXpm.so.4.11 lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so.6 lib/libXt.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def:1.5 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def:1.4 Tue Mar 7 09:47:32 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def Mon Dec 18 09:34:58 2000 @@ -1,8 +1,16 @@ /* * Host.def for building Linux/alpha bindists * - * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def,v 1.4 2000/03/07 14:47:32 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/host.def,v 1.5 2000/12/18 14:34:58 dawes Exp $ */ #define InstallEmptyHostDef + +/* Need to have glide 3 installed, where available */ + +#if LinuxCLibMajorVersion > 5 +#define HasGlide3 YES +#endif + +#define BuildXF86DRI YES Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/var-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/var-list:1.2 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/var-list:1.3 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/var-list:1.2 Sat Feb 26 19:58:15 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-axp/var-list Thu Dec 14 16:45:12 2000 @@ -1 +1 @@ -state +lib Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/bin-list:1.5 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/bin-list:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/bin-list:1.5 Sat Feb 26 20:08:29 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/bin-list Thu Dec 14 17:06:35 2000 @@ -5,13 +5,16 @@ lib/libICE.so.6.3 lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3.3 +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6.0 lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so.6 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so.6 lib/libX11.so lib/libXIE.so.6.0 @@ -28,10 +31,13 @@ lib/libXfont.so.1.3 lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so.6 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so.6 lib/libXmu.so lib/libXp.so.6.2 @@ -40,6 +46,9 @@ lib/libXpm.so.4.11 lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so.6 lib/libXt.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/var-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/var-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/var-list:1.2 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/var-list:1.1 Sat Feb 26 20:08:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/var-list Thu Dec 14 16:45:13 2000 @@ -1 +1 @@ -state +lib Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/bin-list:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/bin-list:1.7 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/bin-list:1.4 Sat Feb 26 20:11:47 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/bin-list Thu Dec 14 17:06:35 2000 @@ -5,13 +5,16 @@ lib/libICE.so.6.3 lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3.3 +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6.0 lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so.6 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so.6 lib/libX11.so lib/libXIE.so.6.0 @@ -28,10 +31,13 @@ lib/libXfont.so.1.3 lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so.6 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so.6 lib/libXmu.so lib/libXp.so.6.2 @@ -40,6 +46,9 @@ lib/libXpm.so.4.11 lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so.6 lib/libXt.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/var-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/var-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/var-list:1.2 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/var-list:1.1 Sat Feb 26 20:11:48 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-m68k/var-list Thu Dec 14 16:45:14 2000 @@ -1 +1 @@ -state +lib Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list:1.4 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list:1.1 Fri Jun 23 18:42:03 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list Thu Dec 14 17:06:36 2000 @@ -5,13 +5,16 @@ lib/libICE.so.6.3 lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3.3 +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6.0 lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so.6 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so.6 lib/libX11.so lib/libXIE.so.6.0 @@ -28,10 +31,13 @@ lib/libXfont.so.1.3 lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so.6 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so.6 lib/libXmu.so lib/libXp.so.6.2 @@ -40,6 +46,9 @@ lib/libXpm.so.4.11 lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so.6 lib/libXt.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list:removed --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list:1.1 Fri Jun 23 18:42:05 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list Mon Dec 18 14:31:29 2000 @@ -1,5 +0,0 @@ -bin/XF86Setup -bin/xmseconfig -lib/X11/XF86Setup -man/man1/XF86Setup.1x -man/man1/xmseconfig.1x Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list:1.2 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list:1.1 Fri Jun 23 18:42:05 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list Thu Dec 14 16:45:14 2000 @@ -1 +1 @@ -state +lib Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/bin-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/bin-list:1.4 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/bin-list:1.1 Sat Feb 26 20:15:11 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/bin-list Thu Dec 14 17:06:37 2000 @@ -5,13 +5,16 @@ lib/libICE.so.6.3 lib/libICE.so.6 lib/libICE.so +lib/libOSMesa.so.3.3 +lib/libOSMesa.so.3 +lib/libOSMesa.so lib/libPEX5.so.6.0 lib/libPEX5.so.6 lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so.6 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so.6 lib/libX11.so lib/libXIE.so.6.0 @@ -28,10 +31,13 @@ lib/libXfont.so.1.3 lib/libXfont.so.1 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so.1 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so.6 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so.6 lib/libXmu.so lib/libXp.so.6.2 @@ -40,6 +46,9 @@ lib/libXpm.so.4.11 lib/libXpm.so.4 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so.1 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so.6 lib/libXt.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/var-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/var-list:1.1 xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/var-list:1.2 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/var-list:1.1 Sat Feb 26 20:15:14 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ppc/var-list Thu Dec 14 16:45:15 2000 @@ -1 +1 @@ -state +lib Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-excl:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-excl Sat Dec 9 16:46:25 2000 @@ -0,0 +1,6 @@ +bin/Xnest +bin/Xprt +bin/Xvfb +bin/X +bin/xfs +bin/XFree86 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-list:1.4 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/bin-list Thu Dec 14 21:06:11 2000 @@ -0,0 +1,23 @@ +bin +lib/libGL.so.1.2 +lib/libICE.so.6.3 +lib/libPEX5.so.6.0 +lib/libSM.so.6.0 +lib/libX11.so.6.2 +lib/libXIE.so.6.0 +lib/libXaw.so.6.1 +lib/libXaw.so.7.0 +lib/libXext.so.6.4 +lib/libXfont.so.1.3 +lib/libXft.so.1.0 +lib/libXi.so.6.0 +lib/libXmu.so.6.2 +lib/libXp.so.6.2 +lib/libXpm.so.4.11 +lib/libXrender.so.1.0 +lib/libXt.so.6.0 +lib/libXtst.so.6.1 +lib/libdps.so.1.0 +lib/libdpstk.so.1.0 +lib/liboldX.so.6.0 +lib/libpsres.so.1.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/dir diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/dir:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/dir Sat Dec 9 16:46:26 2000 @@ -0,0 +1 @@ +usr/X11R6 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-dir diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-dir:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-dir Sat Dec 9 16:46:26 2000 @@ -0,0 +1 @@ +etc/X11 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-list:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/etc-list Sat Dec 9 16:46:26 2000 @@ -0,0 +1 @@ +. Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/fsrv-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/fsrv-list:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/fsrv-list Sat Dec 9 16:46:26 2000 @@ -0,0 +1,2 @@ +bin/xfs +man/cat1/xfs.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/host.def diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/host.def:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/host.def Sat Dec 9 16:46:27 2000 @@ -0,0 +1,8 @@ +/* + * Host.def for building NetBSD bindists + * + * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/host.def,v 1.1 2000/12/09 21:46:27 herrb Exp $ + */ + +#define InstallEmptyHostDef + Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-excl:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-excl Sat Dec 9 16:46:27 2000 @@ -0,0 +1,14 @@ +lib/X11/XF86Setup +lib/X11/app-defaults +lib/X11/config +lib/X11/doc +lib/X11/fonts +lib/X11/fs +lib/X11/lbxproxy +lib/X11/proxymngr +lib/X11/rstart +lib/X11/twm +lib/X11/xdm +lib/X11/xinit +lib/X11/xsm +lib/X11/xserver Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-list:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/lib-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1,2 @@ +lib/X11 +include/X11/bitmaps Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-excl:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-excl Sat Dec 9 16:46:27 2000 @@ -0,0 +1,3 @@ +man/cat1/XF86Setup.0 +man/cat1/xfs.0 +man/cat1/xmseconfig.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-list:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/man-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1 @@ +man Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/mod-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/mod-list:1.1 --- /dev/null Mon Dec 18 14:31:30 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/mod-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1 @@ +lib/modules Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/nest-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/nest-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/nest-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1 @@ +bin/Xnest Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-excl diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-excl:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-excl Sat Dec 9 16:46:27 2000 @@ -0,0 +1,5 @@ +lib/Server +lib/X11 +lib/lib*.so* +lib/modules +include/X11/bitmaps Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prog-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1,3 @@ +lib +include +lib/X11/config Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prt-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prt-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/prt-list Sat Dec 9 16:46:27 2000 @@ -0,0 +1 @@ +bin/Xprt Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-dir diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-dir:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-dir Sat Dec 9 16:46:28 2000 @@ -0,0 +1 @@ +var Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/var-list Sat Dec 9 16:46:28 2000 @@ -0,0 +1 @@ +db Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/vfb-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/vfb-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/vfb-list Sat Dec 9 16:46:28 2000 @@ -0,0 +1 @@ +bin/Xvfb Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/xserv-list diff -u /dev/null xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/xserv-list:1.1 --- /dev/null Mon Dec 18 14:31:31 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-aout-ix86/xserv-list Sat Dec 9 16:46:28 2000 @@ -0,0 +1,2 @@ +bin/XFree86 +bin/X Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-excl diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-excl:1.2 xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-excl:1.3 --- xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-excl:1.2 Sat Feb 26 20:26:48 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-excl Sat Dec 9 16:47:18 2000 @@ -1,10 +1,6 @@ -bin/XF86_* -bin/XF98_* -bin/XF86Setup bin/Xnest bin/Xprt bin/Xvfb bin/X bin/xfs -bin/xmseconfig bin/XFree86 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-list:1.5 xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-list:1.9 --- xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-list:1.5 Mon Feb 28 22:09:23 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/NetBSD-ix86/bin-list Thu Dec 14 21:06:12 2000 @@ -1,21 +1,66 @@ bin +lib/libGL.so +lib/libGL.so.1 lib/libGL.so.1.2 +lib/libICE.so +lib/libICE.so.6 lib/libICE.so.6.3 +lib/libPEX5.so +lib/libPEX5.so.6 lib/libPEX5.so.6.0 +lib/libSM.so +lib/libSM.so.6 lib/libSM.so.6.0 -lib/libX11.so.6.1 +lib/libX11.so +lib/libX11.so.6 +lib/libX11.so.6.2 +lib/libXIE.so +lib/libXIE.so.6 lib/libXIE.so.6.0 +lib/libXaw.so +lib/libXaw.so.6 lib/libXaw.so.6.1 +lib/libXaw.so.7 lib/libXaw.so.7.0 +lib/libXext.so +lib/libXext.so.6 lib/libXext.so.6.4 +lib/libXfont.so +lib/libXfont.so.1 lib/libXfont.so.1.3 +lib/libXft.so +lib/libXft.so.1 +lib/libXft.so.1.0 +lib/libXi.so +lib/libXi.so.6 lib/libXi.so.6.0 -lib/libXmu.so.6.1 +lib/libXmu.so +lib/libXmu.so.6 +lib/libXmu.so.6.2 +lib/libXp.so +lib/libXp.so.6 lib/libXp.so.6.2 +lib/libXpm.so +lib/libXpm.so.4 lib/libXpm.so.4.11 +lib/libXrender.so +lib/libXrender.so.1 +lib/libXrender.so.1.0 +lib/libXt.so +lib/libXt.so.6 lib/libXt.so.6.0 +lib/libXtst.so +lib/libXtst.so.6 lib/libXtst.so.6.1 +lib/libdps.so +lib/libdps.so.1 lib/libdps.so.1.0 +lib/libdpstk.so +lib/libdpstk.so.1 lib/libdpstk.so.1.0 +lib/liboldX.so +lib/liboldX.so.6 lib/liboldX.so.6.0 +lib/libpsres.so +lib/libpsres.so.1 lib/libpsres.so.1.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-excl diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-excl:1.3 xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-excl:1.4 --- xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-excl:1.3 Sat Feb 26 20:29:02 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-excl Sat Dec 9 16:48:09 2000 @@ -1,10 +1,6 @@ -bin/XF86_* -bin/XF98_* -bin/XF86Setup bin/Xnest bin/Xprt bin/Xvfb bin/X bin/xfs -bin/xmseconfig bin/XFree86 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-list:1.6 xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-list:1.11 --- xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-list:1.6 Mon Feb 28 22:09:24 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/OpenBSD-ix86/bin-list Thu Dec 14 21:06:14 2000 @@ -3,17 +3,19 @@ lib/libICE.so.6.3 lib/libPEX5.so.6.0 lib/libSM.so.6.0 -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libXIE.so.6.0 lib/libXThrStub.so.6.0 lib/libXaw.so.6.1 lib/libXaw.so.7.0 lib/libXext.so.6.4 lib/libXfont.so.1.3 +lib/libXft.so.1.0 lib/libXi.so.6.0 -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXp.so.6.2 lib/libXpm.so.4.11 +lib/libXrender.so.1.0 lib/libXt.so.6.0 lib/libXtst.so.6.1 lib/libdps.so.1.0 Index: xc/programs/Xserver/hw/xfree86/etc/bindist/SVR4.0/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/SVR4.0/bin-list:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/SVR4.0/bin-list:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/SVR4.0/bin-list:1.4 Sat Feb 26 20:34:12 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/SVR4.0/bin-list Thu Dec 14 21:06:15 2000 @@ -7,7 +7,7 @@ lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so lib/libXIE.so.6.0 lib/libXIE.so @@ -18,14 +18,18 @@ lib/libXext.so lib/libXfont.so.1.3 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so lib/libXp.so.6.2 lib/libXp.so lib/libXpm.so.4.11 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so lib/libXtst.so.6.1 @@ -36,3 +40,5 @@ lib/libdpstk.so lib/libpsres.so.1.0 lib/libpsres.so +lib/liboldX.so.6.0 +lib/liboldX.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/Solaris/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/Solaris/bin-list:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/Solaris/bin-list:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/Solaris/bin-list:1.4 Sat Feb 26 20:36:39 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/Solaris/bin-list Thu Dec 14 21:06:16 2000 @@ -7,7 +7,7 @@ lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so lib/libXIE.so.6.0 lib/libXIE.so @@ -18,14 +18,18 @@ lib/libXext.so lib/libXfont.so.1.3 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so lib/libXp.so.6.2 lib/libXp.so lib/libXpm.so.4.11 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so lib/libXtst.so.6.1 @@ -36,3 +40,5 @@ lib/libdpstk.so lib/libpsres.so.1.0 lib/libpsres.so +lib/liboldX.so.6.0 +lib/liboldX.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/UnixWare/bin-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/UnixWare/bin-list:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/UnixWare/bin-list:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/UnixWare/bin-list:1.4 Sat Feb 26 20:38:34 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/UnixWare/bin-list Thu Dec 14 21:06:17 2000 @@ -7,7 +7,7 @@ lib/libPEX5.so lib/libSM.so.6.0 lib/libSM.so -lib/libX11.so.6.1 +lib/libX11.so.6.2 lib/libX11.so lib/libXIE.so.6.0 lib/libXIE.so @@ -18,14 +18,18 @@ lib/libXext.so lib/libXfont.so.1.3 lib/libXfont.so +lib/libXft.so.1.0 +lib/libXft.so lib/libXi.so.6.0 lib/libXi.so -lib/libXmu.so.6.1 +lib/libXmu.so.6.2 lib/libXmu.so lib/libXp.so.6.2 lib/libXp.so lib/libXpm.so.4.11 lib/libXpm.so +lib/libXrender.so.1.0 +lib/libXrender.so lib/libXt.so.6.0 lib/libXt.so lib/libXtst.so.6.1 @@ -36,3 +40,5 @@ lib/libdpstk.so lib/libpsres.so.1.0 lib/libpsres.so +lib/liboldX.so.6.0 +lib/liboldX.so Index: xc/programs/Xserver/hw/xfree86/etc/bindist/common/fnts-list diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/common/fnts-list:1.2 xc/programs/Xserver/hw/xfree86/etc/bindist/common/fnts-list:1.3 --- xc/programs/Xserver/hw/xfree86/etc/bindist/common/fnts-list:1.2 Sat Aug 28 05:01:16 1999 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/common/fnts-list Thu Dec 14 16:59:51 2000 @@ -3,3 +3,4 @@ lib/X11/fonts/PEX lib/X11/fonts/CID lib/X11/fonts/local +lib/X11/fonts/util Index: xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def:1.4 xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def:1.8 --- xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def:1.4 Fri Mar 3 18:16:25 2000 +++ xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def Fri Dec 15 16:54:37 2000 @@ -6,7 +6,7 @@ * - XFree86 doctools package (requires groff) * - nroff/troff or groff * - * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def,v 1.4 2000/03/03 23:16:25 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/common/host.def,v 1.8 2000/12/15 21:54:37 dawes Exp $ */ #define HasSgmlFmt YES @@ -14,6 +14,12 @@ #define InstallJapaneseDocs YES #define BuildSpecsDocs YES -#define SpecsDocDirs GL Xext Xv xterm +#define SpecsDocDirs BDF CTEXT FSProtocol GL ICCCM ICE \ + /*PEX5*/ PM Render SM X11 XDMCP XIM XLFD \ + XProtocol Xaw Xext Xi Xmu Xserver Xt Xv \ + i18n programs rstart xfs xterm xtrans + +#define InstallHardcopyDocs YES +#define HardcopyDocDirs RX XIE XKB XPRINT Index: xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile:1.6 xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile:1.9 --- xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile:1.6 Sat Aug 14 06:49:58 1999 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile Sun Dec 17 17:23:37 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile,v 1.6 1999/08/14 10:49:58 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/Imakefile,v 1.9 2000/12/17 22:23:37 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -25,9 +25,9 @@ #ifdef LinuxArchitecture InstallLibraryModule(fbdevhw,$(MODULEDIR),linux) +#endif CppManTarget(fbdevhw,) InstallModuleManPage(fbdevhw) -#endif #ifndef OS2Architecture DependTarget() Index: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c:1.15 xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c:1.21 --- xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c:1.15 Fri Jun 30 21:40:46 2000 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c Tue Oct 24 18:45:09 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c,v 1.15 2000/07/01 01:40:46 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c,v 1.21 2000/10/24 22:45:09 dawes Exp $ */ /* all driver need this */ #include "xf86.h" @@ -16,6 +16,12 @@ #include "asm/page.h" /* #define for PAGE_* */ +#ifdef DPMSExtension +#include "globals.h" +#define DPMS_SERVER +#include "extensions/dpms.h" +#endif + #define DEBUG 0 #if DEBUG @@ -37,7 +43,7 @@ MODINFOSTRING1, MODINFOSTRING2, XF86_VERSION_CURRENT, - 0, 0, 1, + 0, 0, 2, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, MOD_CLASS_NONE, @@ -86,8 +92,10 @@ char* device; int fd; void* fbmem; - int fboff; - void* mmio; + unsigned int fbmem_len; + unsigned int fboff; + char* mmio; + unsigned int mmio_len; /* current hardware state */ struct fb_fix_screeninfo fix; @@ -95,6 +103,8 @@ /* saved video mode */ struct fb_var_screeninfo saved_var; + + /* FIXME: unused??? [geert] */ struct fb_cmap saved_cmap; unsigned short *saved_red; unsigned short *saved_green; @@ -165,12 +175,9 @@ var->xres_virtual = pScrn->virtualX; var->yres_virtual = pScrn->virtualY; var->bits_per_pixel = pScrn->bitsPerPixel; - var->red.length = 0; - var->red.offset = 0; - var->green.length = 0; - var->green.offset = 0; - var->blue.length = 0; - var->blue.offset = 0; + var->red.length = pScrn->weight.red; + var->green.length = pScrn->weight.green; + var->blue.length = pScrn->weight.blue; } static void @@ -197,7 +204,7 @@ var->sync |= FB_SYNC_VERT_HIGH_ACT; if (mode->Flags & V_PCSYNC) var->sync |= FB_SYNC_COMP_HIGH_ACT; -#if 0 +#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ if (mode->Flags & V_BCAST) var->sync |= FB_SYNC_BROADCAST; #endif @@ -225,7 +232,7 @@ mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC; mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC; mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC; -#if 0 +#if 1 /* Badly needed for PAL/NTSC on Amiga (amifb)!! [geert] */ if (var->sync & FB_SYNC_BROADCAST) mode->Flags |= V_BCAST; #endif @@ -250,28 +257,6 @@ /* -------------------------------------------------------------------- */ /* open correct framebuffer device */ -static struct fb2pci_entry { - CARD32 id; - CARD32 vendor; - CARD32 chip; -} fb2pci_map[] = { - { FB_ACCEL_MATROX_MGA2064W, PCI_VENDOR_MATROX, PCI_CHIP_MGA2064 }, - { FB_ACCEL_MATROX_MGA1064SG, PCI_VENDOR_MATROX, PCI_CHIP_MGA1064 }, - { FB_ACCEL_MATROX_MGA2164W, PCI_VENDOR_MATROX, PCI_CHIP_MGA2164 }, - { FB_ACCEL_MATROX_MGA2164W_AGP, PCI_VENDOR_MATROX, PCI_CHIP_MGA2164_AGP }, - { FB_ACCEL_MATROX_MGAG100, PCI_VENDOR_MATROX, PCI_CHIP_MGAG100 }, - { FB_ACCEL_MATROX_MGAG200, PCI_VENDOR_MATROX, PCI_CHIP_MGAG200 }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RE }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RF }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RK }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RL }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128PF }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128LE }, - { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128LF }, - { FB_ACCEL_3DFX_BANSHEE, PCI_VENDOR_3DFX, PCI_CHIP_VOODOO3 }, -}; -#define FB2PCICOUNT (sizeof(fb2pci_map)/sizeof(struct fb2pci_entry)) - /* try to find the framebuffer device for a given PCI device */ static int fbdev_open_pci(pciVideoPtr pPci, char **namep) @@ -279,8 +264,9 @@ struct fb_fix_screeninfo fix; char filename[16]; int fd,i,j; + memType res_start, res_end; - for (i = 0; i < 4; i++) { + for (i = 0; i < 8; i++) { sprintf(filename,"/dev/fb%d",i); if (-1 == (fd = open(filename,O_RDWR,0))) { continue; @@ -289,15 +275,18 @@ close(fd); continue; } - /* FIXME: better ask the fbdev driver for bus/device/func, - but there is no way to to this yet. */ - for (j = 0; j < FB2PCICOUNT; j++) { - if (pPci->vendor == fb2pci_map[j].vendor && - pPci->chipType == fb2pci_map[j].chip && - fix.accel == fb2pci_map[j].id) + for (j = 0; j < 6; j++) { + res_start = pPci->memBase[j]; + res_end = res_start+pPci->size[j]; + if ((0 != fix.smem_len && + (memType) fix.smem_start >= res_start && + (memType) fix.smem_start < res_end) || + (0 != fix.mmio_len && + (memType) fix.mmio_start >= res_start && + (memType) fix.mmio_start < res_end)) break; } - if (j == FB2PCICOUNT) { + if (j == 6) { close(fd); continue; } @@ -415,10 +404,27 @@ fbdevHWGetDepth(ScrnInfoPtr pScrn) { fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); - return fPtr->var.bits_per_pixel; + + if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR || + fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR) + return fPtr->var.red.length+fPtr->var.green.length+ + fPtr->var.blue.length; + else + return fPtr->var.bits_per_pixel; } int +fbdevHWGetLineLength(ScrnInfoPtr pScrn) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + + if (fPtr->fix.line_length) + return fPtr->fix.line_length; + else + return fPtr->var.xres_virtual*fPtr->var.bits_per_pixel/8; +} + +int fbdevHWGetType(ScrnInfoPtr pScrn) { fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); @@ -459,7 +465,11 @@ xfree2fbdev_timing(mode,&var); var.xres_virtual = virtX; var.yres_virtual = virtY; - var.bits_per_pixel = pScrn->depth; + var.bits_per_pixel = pScrn->bitsPerPixel; + var.red.length = pScrn->weight.red; + var.green.length = pScrn->weight.green; + var.blue.length = pScrn->weight.blue; + var.activate = FB_ACTIVATE_TEST; if (var.xres_virtual < var.xres) var.xres_virtual = var.xres; if (var.yres_virtual < var.yres) var.yres_virtual = var.yres; @@ -516,6 +526,15 @@ /* -------------------------------------------------------------------- */ +void +calculateFbmem_len(fbdevHWPtr fPtr) +{ + fPtr->fboff = (unsigned int) fPtr->fix.smem_start & ~PAGE_MASK; + fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) & + PAGE_MASK; +} + + void* fbdevHWMapVidmem(ScrnInfoPtr pScrn) { @@ -523,12 +542,17 @@ TRACE_ENTER("MapVidmem"); if (NULL == fPtr->fbmem) { - fPtr->fboff = fPtr->fix.smem_len & (PAGE_SIZE-1); - fPtr->fbmem = mmap(NULL, fPtr->fix.smem_len, PROT_READ | PROT_WRITE, + calculateFbmem_len(fPtr); + fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fPtr->fd, 0); - if (-1 == (int)fPtr->fbmem) { + if (-1 == (long)fPtr->fbmem) { perror("mmap fbmem"); fPtr->fbmem = NULL; + } else { + /* Perhaps we'd better add fboff to fbmem and return 0 in + fbdevHWLinearOffset()? Of course we then need to mask + fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as + well. [geert] */ } } pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK); @@ -552,7 +576,7 @@ TRACE_ENTER("UnmapVidmem"); if (NULL != fPtr->fbmem) { - if (-1 == munmap(fPtr->fbmem, fPtr->fix.smem_len)) + if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len)) perror("munmap fbmem"); fPtr->fbmem = NULL; } @@ -562,6 +586,8 @@ void* fbdevHWMapMMIO(ScrnInfoPtr pScrn) { + unsigned int mmio_off; + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); TRACE_ENTER("MapMMIO"); @@ -572,12 +598,18 @@ perror("FBIOPUT_VSCREENINFO"); return FALSE; } - fPtr->mmio = mmap(NULL, fPtr->fix.mmio_len, PROT_READ | PROT_WRITE, - MAP_SHARED, fPtr->fd, fPtr->fix.smem_len); - if (-1 == (int)fPtr->mmio) { + mmio_off = (unsigned int) fPtr->fix.mmio_start & ~PAGE_MASK; + fPtr->mmio_len = (mmio_off+fPtr->fix.mmio_len+~PAGE_MASK) & + PAGE_MASK; + if (NULL == fPtr->fbmem) + calculateFbmem_len(fPtr); + fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE, + MAP_SHARED, fPtr->fd, fPtr->fbmem_len); + if (-1 == (long)fPtr->mmio) { perror("mmap mmio"); fPtr->mmio = NULL; - } + } else + fPtr->mmio += mmio_off; } return fPtr->mmio; } @@ -589,9 +621,10 @@ TRACE_ENTER("UnmapMMIO"); if (NULL != fPtr->mmio) { - if (-1 == munmap(fPtr->mmio, fPtr->fix.mmio_len)) + if (-1 == munmap((void *)((unsigned long)fPtr->mmio & PAGE_MASK), fPtr->mmio_len)) perror("munmap mmio"); fPtr->mmio = NULL; + /* FIXME: restore var.accel_flags [geert] */ } return TRUE; } @@ -673,9 +706,12 @@ cmap.transp = NULL; for (i = 0; i < numColors; i++) { cmap.start = indices[i]; - red = colors[indices[i]].red << 8; - green = colors[indices[i]].green << 8; - blue = colors[indices[i]].blue << 8; + red = (colors[indices[i]].red << 8) | + colors[indices[i]].red; + green = (colors[indices[i]].green << 8) | + colors[indices[i]].green; + blue = (colors[indices[i]].blue << 8) | + colors[indices[i]].blue; if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap)) perror("ioctl FBIOPUTCMAP"); } @@ -751,3 +787,32 @@ fbdevHWRestore(pScrn); } +void +fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ +#ifdef DPMSExtension + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + unsigned long fbmode; + + if (!pScrn->vtSema) + return; + + switch (mode) { + case DPMSModeOn: + fbmode = 0; + break; + case DPMSModeStandby: + fbmode = 2; + break; + case DPMSModeSuspend: + fbmode = 3; + break; + case DPMSModeOff: + fbmode = 4; + break; + } + + if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode)) + perror("ioctl FBIOBLANK"); +#endif /* DPMSExtension */ +} Index: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp:1.2 xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp:1.4 --- xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp:1.2 Tue Jun 13 22:13:16 2000 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp Mon Dec 11 15:29:50 2000 @@ -1,5 +1,5 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp,v 1.2 2000/06/14 02:13:16 dawes Exp $ -.TH FBDEVHW __drivermansuffix__ "Version 4.0.1" "XFree86" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp,v 1.4 2000/12/11 20:29:50 dawes Exp $ +.TH FBDEVHW __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME fbdevhw \- os-specific submodule for framebuffer device access .SH DESCRIPTION @@ -14,7 +14,7 @@ fbdevhw module. fbdevhw can be used by other drivers too, this is usually activated with `Option "UseFBDev"' in the device section. .SH "SEE ALSO" -XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1), +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__), fbdev(__drivermansuffix__) .SH AUTHORS Authors include: Gerd Knorr, based on the XF68_FBDev Server code Index: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h:1.6 xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h:1.9 --- xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h:1.6 Mon Apr 17 12:30:10 2000 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h Sat Nov 18 14:37:14 2000 @@ -1,5 +1,11 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h,v 1.6 2000/04/17 16:30:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h,v 1.9 2000/11/18 19:37:14 tsi Exp $ */ +#ifndef _FBDEVHW_H_ +#define _FBDEVHW_H_ + +#include "xf86str.h" +#include "colormapst.h" + #define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ #define FBDEVHW_PLANES 1 /* Non interleaved planes */ #define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ @@ -14,6 +20,7 @@ char* fbdevHWGetName(ScrnInfoPtr pScrn); int fbdevHWGetDepth(ScrnInfoPtr pScrn); +int fbdevHWGetLineLength(ScrnInfoPtr pScrn); int fbdevHWGetType(ScrnInfoPtr pScrn); int fbdevHWGetVidmem(ScrnInfoPtr pScrn); @@ -38,3 +45,6 @@ void fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags); Bool fbdevHWEnterVT(int scrnIndex, int flags); void fbdevHWLeaveVT(int scrnIndex, int flags); +void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); + +#endif Index: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c:1.7 xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c:1.9 --- xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c:1.7 Thu May 18 12:29:58 2000 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c Fri Oct 20 10:59:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c,v 1.7 2000/05/18 16:29:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c,v 1.9 2000/10/20 14:59:01 alanh Exp $ */ #include "xf86.h" #include "xf86cmap.h" @@ -45,6 +45,11 @@ } int +fbdevHWGetLineLength(ScrnInfoPtr pScrn) +{ +} + +int fbdevHWGetType(ScrnInfoPtr pScrn) { return -1; @@ -152,3 +157,7 @@ { } +void +fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ +} Index: xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h diff -u xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h:1.2 xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h:1.3 --- xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h:1.2 Thu Jan 20 21:30:02 2000 +++ xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h Fri Aug 11 13:27:14 2000 @@ -2,7 +2,7 @@ * copyed from from linux kernel 2.2.4 * removed internal stuff (#ifdef __KERNEL__) */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h,v 1.2 2000/01/21 02:30:02 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbpriv.h,v 1.3 2000/08/11 17:27:14 dawes Exp $ */ #ifndef _LINUX_FB_H #define _LINUX_FB_H @@ -32,6 +32,7 @@ /* #define FBIOSWITCH_MONIBIT 0x460E */ #define FBIOGET_CON2FBMAP 0x460F #define FBIOPUT_CON2FBMAP 0x4610 +#define FBIOBLANK 0x4611 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ #define FB_TYPE_PLANES 1 /* Non interleaved planes */ Index: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c diff -u xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c:1.7 xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c:1.8 --- xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c:1.7 Mon Jun 12 22:28:35 2000 +++ xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c Fri Nov 3 13:46:15 2000 @@ -6,7 +6,7 @@ * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.7 2000/06/13 02:28:35 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.8 2000/11/03 18:46:15 eich Exp $ */ #if 1 #include "misc.h" @@ -35,8 +35,8 @@ #include "xf86i2c.h" -#define I2C_TIMEOUT(x) /* (x) */ /* Report timeouts */ -#define I2C_TRACE(x) /* (x) */ /* Report progress */ +#define I2C_TIMEOUT(x) /*(x)*/ /* Report timeouts */ +#define I2C_TRACE(x) /*(x)*/ /* Report progress */ /* Set which OSs have bad gettimeofday resolution. */ #if defined(SVR4) && !defined(sun) @@ -87,7 +87,7 @@ d_secs = (a_secs - b_secs); d_usecs = (a_usecs - b_usecs); diff = d_secs*1000000 + d_usecs; - } while (diff>0 && diff<usec); + } while (diff>0 && diff< (usec + 1)); } } #endif @@ -101,7 +101,7 @@ * there is no explicit test for conflits. */ -#define RISEFALLTIME 1 /* usec, actually 300 to 1000 ns according to the i2c specs */ +#define RISEFALLTIME 2 /* usec, actually 300 to 1000 ns according to the i2c specs */ /* Some devices will hold SCL low to slow down the bus or until * ready for transmission. @@ -117,12 +117,12 @@ int i, scl; b->I2CPutBits(b, 1, sda); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); - for (i = timeout; i > 0; i -= RISEFALLTIME) { + for (i = timeout; i > 0; i -= b->RiseFallTime) { b->I2CGetBits(b, &scl, &sda); if (scl) break; - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); } if (i <= 0) { @@ -158,12 +158,12 @@ int i, scl, sda; b->I2CPutBits(b, 1, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); - for (i = timeout; i > 0; i -= RISEFALLTIME) { + for (i = timeout; i > 0; i -= b->RiseFallTime) { b->I2CGetBits(b, &scl, &sda); if (scl) break; - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); } if (i <= 0) { @@ -194,7 +194,7 @@ I2CBusPtr b = d->pI2CBus; b->I2CPutBits(b, 0, 0); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); b->I2CPutBits(b, 1, 0); b->I2CUDelay(b, b->HoldTime); @@ -214,7 +214,7 @@ Bool r; b->I2CPutBits(b, 0, sda); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); r = I2CRaiseSCL(b, sda, timeout); b->I2CUDelay(b, b->HoldTime); @@ -273,7 +273,7 @@ return FALSE; b->I2CPutBits(b, 0, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); r = I2CRaiseSCL(b, 1, b->HoldTime); @@ -324,7 +324,7 @@ I2CBusPtr b = d->pI2CBus; b->I2CPutBits(b, 0, 1); - b->I2CUDelay(b, RISEFALLTIME); + b->I2CUDelay(b, b->RiseFallTime); if (!I2CReadBit(b, &sda, d->ByteTimeout)) return FALSE; @@ -741,6 +741,7 @@ b->ByteTimeout = 5; b->AcknTimeout = 5; b->StartTimeout = 5; + b->RiseFallTime = RISEFALLTIME; } return b; Index: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h diff -u xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h:1.5 xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h:1.6 --- xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h:1.5 Fri Apr 14 08:16:06 2000 +++ xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h Fri Nov 3 13:46:16 2000 @@ -2,7 +2,7 @@ * Copyright (C) 1998 Itai Nahshon, Michael Schimek */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.5 2000/04/14 12:16:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.6 2000/11/03 18:46:16 eich Exp $ */ #ifndef _XF86I2C_H #define _XF86I2C_H @@ -40,6 +40,7 @@ int ByteTimeout; /* usec */ int AcknTimeout; /* usec */ int StartTimeout; /* usec */ + int RiseFallTime; /* usec */ I2CDevPtr FirstDev; I2CBusPtr NextBus; Index: xc/programs/Xserver/hw/xfree86/input/citron/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/citron/Imakefile:1.1 --- /dev/null Mon Dec 18 14:31:35 2000 +++ xc/programs/Xserver/hw/xfree86/input/citron/Imakefile Wed Nov 1 21:51:20 2000 @@ -0,0 +1,31 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/Imakefile,v 1.1 2000/11/02 02:51:20 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = citron.c +OBJS = citron.o + +DRIVER = citron + +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ + -I$(SERVERSRC)/include -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC) + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget($(DRIVER),$(OBJS)) + +InstallObjectModule($(DRIVER),$(MODULEDIR),input) + +#if !defined(XF86DriverSDK) +CppManTarget($(DRIVER),) +InstallModuleManPage($(DRIVER)) +#endif + +DependTarget() + +InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input) Index: xc/programs/Xserver/hw/xfree86/input/citron/citron.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/citron/citron.c:1.5 --- /dev/null Mon Dec 18 14:31:35 2000 +++ xc/programs/Xserver/hw/xfree86/input/citron/citron.c Tue Nov 21 18:10:37 2000 @@ -0,0 +1,2415 @@ +/* + * Copyright (c) 1998 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, cpy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.c,v 1.5 2000/11/21 23:10:37 tsi Exp $ */ + +/* + * Based, in part, on code with the following copyright notice: + * + * Copyright 1999-2000 by Thomas Thanner, Citron GmbH, Germany. <support@citron.de> + * Copyright 1999-2000 by Peter Kunzmann, Citron GmbH, Germany. <support@citron.de> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and that + * the name of Thomas Thanner and Citron GmbH not be used in advertising or + * publicity pertaining to distribution of the software without specific, written + * prior permission. Thomas Thanner and Citron GmbH makes no representations about + * the suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * THOMAS THANNER AND CITRON GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL THOMAS THANNER OR CITRON GMBH BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RSULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Citron specific extensions: + * + * 1) Configuration file entries: + * a) "SleepTime" Touch idle time in seconds before sleep mode + * (reduced scanning) is entered. + * 0 = immediately; 65535=never; + * default=65535 + * b) "ActivePWM" PWM duty cycle during regular operation. + * default=255 + * c) "SleepPWM" PWM duty cycle during sleep mode. + * default=255 + * d) "ClickMode" Button click emulation mode; + * 1 = Enter Mode + * 2 = Dual Touch Mode + * 3 = Dual Exit Mode + * 4 = Z-Press Mode + * 5 = Z-Press Exit Mode + * default = 1 + * + * 2) Additional modes in SetMode() function: + * (These modes are only activated if the CIT_MODE_EXT macro is defined + * at compile time. Until now the mode values are not defined, yet) + * a) ClickMode_Enter set the button click emulation mode to 1 + * b) ClickMode_Dual set the button click emulation mode to 2 + * c) ClickMode_DualExit set the button click emulation mode to 3 + * d) ClickMode_ZPress set the button click emulation mode to 4 + * e) ClickMode_ZPressExit set the button click emulation mode to 5 + * + *!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ +/* + --------------------------------------------------------------------------- + Revision history: + + Ver Date Description of changes Name + --------------------------------------------------------------------------- + 2.03 17.09.00 Reconnect when getting breaks changed, changes + when powering off the system and reconnecting + parser for commands from "xcit" added + "cit_ParseCommand" to set the variables not + only on the touch side but also in the priv rec pk + 2.04 19.10.00 reconnect enhanced pk + ============================================================================ + +*/ + + +#define _citron_C_ +#define PK 0 +#define INITT 0 /* Initialisation of touch in first loop */ + +/* ODD version number enables the debug macros */ +/* EVEN version number is for release */ +#define CITOUCH_VERSION 0x204 +char version[]="Touch Driver V2.04 (c) 1999-2000 Citron GmbH"; + + + +/***************************************************************************** + * Standard Headers + ****************************************************************************/ + +#include <misc.h> +#include <xf86.h> +#define NEED_XF86_TYPES +/*#include <xf86Version.h>*/ +#include <xf86_ansic.h> +#include <xf86_OSproc.h> +#include <xf86Optrec.h> +#include <xf86Xinput.h> +#include <xisb.h> +#include <exevents.h> /* Needed for InitValuator/Proximity stuff*/ + + +/* #define CI_TIM */ /* Enable timer */ +#define CIT_BEEP /* enable beep feature */ + +/***************************************************************************** + * Local Headers + ****************************************************************************/ +#include "citron.h" + +/***************************************************************************** + * Variables without includable headers + ****************************************************************************/ + +/***************************************************************************** + * defines + ****************************************************************************/ +#define CIT_DEF_MIN_X 0 +#define CIT_DEF_MAX_X 0xFFFF +#define CIT_DEF_MIN_Y 0 +#define CIT_DEF_MAX_Y 0xFFFF + +#define CIT_BUFFER_SIZE 1024 + + + +/****************************************************************************** + * debugging macro + *****************************************************************************/ +#ifdef DBG +#undef DBG +#endif +#ifdef DEBUG +#undef DEBUG +#endif + +static int debug_level = 0; +#if CITOUCH_VERSION & 0x0001 +#define DEBUG +#endif +#ifdef DEBUG +#define DBG(lvl, f) {if ((lvl) <= debug_level) f;} +#else +#define DBG(lvl, f) +#endif + +/* Debugging levels for various routines */ +#define PP 5 /* cit_ProcessPacket */ +#define RI 6 /* cit_ReadInput */ +#define GP 6 /* cit_GetPacket */ +#define DDS 5 /* DDS package */ +#define DC 5 /* cit_DriverComm */ + +#define XFREE86_V4 + +#ifdef XFREE86_V4 +#define WAIT(t) \ + err = xf86WaitForInput(-1, ((t) * 1000)); \ + if (err == -1) { \ + ErrorF("Citron select error\n"); \ + return !Success; \ + } +#else +#define WAIT(t) \ + timeout.tv_sec = 0; \ + timeout.tv_usec = (t) * 1000; \ + SYSCALL(err = select(0, NULL, NULL, NULL, &timeout)); \ + if (err == -1) { \ + ErrorF("Citron select error : %s\n", strerror(errno)); \ + return !Success; \ + } +#endif + + + + +/***************************************************************************** + * Local Variables + ****************************************************************************/ + + +static InputInfoPtr CitronPreInit(InputDriverPtr drv, IDevPtr dev, int flags); + + +InputDriverRec CITRON = { + 1, + "citron", + NULL, + CitronPreInit, + /*CitronUnInit*/ NULL, + NULL, + 0 +}; + +#ifdef XFree86LOADER + + +/* + *************************************************************************** + * + * Dynamic loading functions + * + *************************************************************************** + */ + + +static XF86ModuleVersionInfo VersionRec = +{ + "citron", /* name of module */ + MODULEVENDORSTRING, /* vendor specific string */ + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, /* Module-specific current version */ + 0, /* Module-specific major version */ + 1, /* Module-specific minor version */ + 1, /* Module-specific patch level */ + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} /* signature of the version info structure */ +}; + + +/* ************************************************************************ + * [SetupProc] -- + * + * called when the module subsection is found in XF86Config + * + * ************************************************************************/ + +static pointer +SetupProc( pointer module, + pointer options, + int *errmaj, + int *errmin ) +{ +/* xf86LoaderReqSymLists(reqSymbols, NULL); */ + xf86AddInputDriver(&CITRON, module, 0); + DBG(5, ErrorF ("%sSetupProc called\n", CI_INFO)); + + return (pointer) 1; +} + +/***************************************************************************** + * [TearDownProc] + ****************************************************************************/ +static void +TearDownProc (pointer p) +{ + DBG(5, ErrorF ("%sTearDownProc Called\n", CI_INFO)); +} + + +XF86ModuleData citronModuleData = { &VersionRec, SetupProc, TearDownProc}; + +#endif /* XFree86LOADER */ + + + + + +/* + * Be sure to set vmin appropriately for your device's protocol. You want to + * read a full packet before returning + */ +static const char *default_options[] = +{ + + "BaudRate", "19200", + "StopBits", "1", + "DataBits", "8", + "Parity", "None", + "Vmin", "3", + "Vtime", "1", + "FlowControl", "None", + "ClearDTR", "" +}; + + +/***************************************************************************** + * Function Definitions + ****************************************************************************/ + + + +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* [xf86CitronFeedback] */ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* Online driver parameter change */ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ + +static void +cit_SendtoTouch(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i,j; + unsigned char buf[MAX_BYTES_TO_TRANSFER*2+2]; + + DBG(DDS, ErrorF("%scit_SendtoTouch(numbytes=0x%02X, data[0]=%02x, data[1]=%02x, data[2]=%02x, data[3]=%02x, ...)\n", CI_INFO, priv->dds.numbytes, + priv->dds.data[0], priv->dds.data[1], priv->dds.data[2], priv->dds.data[3],)); + + j=0; + buf[j++] = CTS_STX; /* transmit start of packet */ + + for(i=0; i<priv->dds.numbytes; i++) + { + if (priv->dds.data[i] >= CTS_CTRLMIN && priv->dds.data[i] <= CTS_CTRLMAX) + { /* data has to be encoded */ + buf[j++] = CTS_ESC; + buf[j++] = priv->dds.data[i] | CTS_ENCODE; + } + else buf[j++] = priv->dds.data[i]; + } + buf[j++] = CTS_ETX; /* end of packet */ + + XisbWrite(priv->buffer, buf, j); + + + for(i=0; i<j; i++) + { + if(i%16 == 0) DBG(DDS, ErrorF("\n")); + DBG(DDS, ErrorF("%02x ",buf[i])); + } + + + DBG(DDS, ErrorF("\n")); +} + + +static void +cit_ParseCommand(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i; + + DBG(DDS, ErrorF("%scit_ParseCommand(numbytes=0x%02X, data= ", CI_INFO, priv->dds.numbytes)); + + for(i=0; i<priv->dds.numbytes; i++) + DBG(DDS, ErrorF("%02x ", priv->dds.data[i])); + + DBG(DDS,ErrorF("\n")); + + switch(priv->dds.data[0]&0xff) + { + case C_SETPWM: + priv->pwm_active = priv->dds.data[1]; + priv->pwm_sleep = priv->dds.data[2]; + DBG(DDS, ErrorF("%scit_ParseCommand(PWM Active:%d PWM Sleep:%d \n", CI_INFO, priv->pwm_active, priv->pwm_sleep)); + break; + + case C_SETSLEEPMODE: + if(priv->dds.data[1] == 0) + { + priv->sleep_time_act = priv->dds.data[2] | (priv->dds.data[3] << 8); + } + DBG(DDS, ErrorF("%scit_ParseCommand(Sleep Time act:%d \n", CI_INFO, priv->sleep_time_act)); + break; + + case C_SETDOZEMODE: + if(priv->dds.data[1] == 0) + { + priv->doze_time_act = priv->dds.data[2] | (priv->dds.data[3] << 8); + } + DBG(DDS, ErrorF("%scit_ParseCommand(Doze Time act:%d \n", CI_INFO, priv->doze_time_act)); + break; + + case C_SETAREAPRESSURE: + priv->button_threshold = priv->dds.data[1]; + DBG(DDS, ErrorF("%scit_ParseCommand(Button Threshold:%d \n", CI_INFO, priv->button_threshold)); + break; + } +} + + + +static void +cit_DriverComm(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + int i; + unsigned short tmp; + + DBG(DC, ErrorF("%scit_DriverComm(numbytes=0x%02X, data[1]=%02x, ...)\n", CI_INFO, priv->dds.numbytes, priv->dds.data[1])); + + i=1; + switch(priv->dds.data[i++]) /* command word */ + { + case D_SETCLICKMODE: + priv->click_mode = priv->dds.data[i++]; + ErrorF("%sClick Mode: %d\n", CI_INFO, priv->click_mode); + break; + + case D_BEEP: + priv->beep = priv->dds.data[i++]; + ErrorF("%sBeep: %s\n", CI_INFO, (priv->beep > 0) ? "activated":"not activated"); + break; + + case D_SETBEEP: + priv->press_vol = priv->dds.data[i++]; + ErrorF("%sBeep Pressure Volume: %d\n", CI_INFO, priv->press_vol); + tmp = priv->dds.data[i++]; + tmp += priv->dds.data[i++] << 8; + priv->press_pitch = tmp; + ErrorF("%sBeep Pressure Pitch: %d\n", CI_INFO, priv->press_pitch); + priv->press_dur = priv->dds.data[i++]; + ErrorF("%sBeep Pressure Duration: %d\n", CI_INFO, priv->press_dur); + priv->rel_vol = priv->dds.data[i++]; + ErrorF("%sBeep Release Volume: %d\n", CI_INFO, priv->rel_vol); + tmp = priv->dds.data[i++]; + tmp += priv->dds.data[i++] << 8; + priv->rel_pitch = tmp; + ErrorF("%sBeep Release Pitch: %d\n", CI_INFO, priv->rel_pitch); + priv->rel_dur = priv->dds.data[i++]; + ErrorF("%sBeep Release Duration: %d\n", CI_INFO, priv->rel_dur); + break; + + default: + ErrorF("%sNot known command: %d\n", CI_WARNING, priv->dds.data[1]); + + } +} + + +static void +xf86CitronPrint (int nr, LedCtrl *ctrl) +{ + DBG(8, ErrorF("%s------------------------------------------\n", CI_INFO)); + DBG(8, ErrorF("%sxf86CitronFeedback%d(dev, ctrl)\n", CI_INFO, nr)); + DBG(8, ErrorF("%s ctrl->led_values.......:%d [0x%08lX]\n", CI_INFO, ctrl->led_values, ctrl->led_values)); + DBG(8, ErrorF("%s ctrl->led_mask.........:%d [0x%08lX]\n", CI_INFO, ctrl->led_mask, ctrl->led_mask)); + DBG(8, ErrorF("%s ctrl->id...............:%d\n", CI_INFO, ctrl->id)); +} + + +static void +xf86CitronFeedback0 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr)(local->private); + COMMAND *cmd; + + DBG(DDS, ErrorF("%sEntering xf86CitronFeedback0()...\n",CI_INFO)); + + cmd = (COMMAND *)&ctrl->led_values; + + DBG(DDS, ErrorF("%scmd->packet = %d\n", CI_INFO, cmd->packet)); + + + if(cmd->packet == 0) /* test if first packet has come (with number of bytes in first byte) */ + { + if(cmd->par[0] == 0) /* test if something is to do at all */ + return; + priv->dds.curbyte = 2; + priv->dds.numbytes = cmd->par[0]; + priv->dds.data[0] = cmd->par[1]; + priv->dds.data[1] = cmd->par[2]; + priv->dds.packet = 1; + } + else + { + if(priv->dds.packet == cmd->packet) + { + priv->dds.data[priv->dds.packet*3-1] = cmd->par[0]; + priv->dds.data[priv->dds.packet*3] = cmd->par[1]; + priv->dds.data[priv->dds.packet*3+1] = cmd->par[2]; + priv->dds.packet++; + priv->dds.curbyte += 3; + } + else + DBG(DDS, ErrorF("%sPacket error: should be %d is %d\n", CI_WARNING, priv->dds.packet, cmd->packet)); + + } + DBG(DDS, ErrorF("%snumbytes = %d curbyte=%d\n", CI_INFO, priv->dds.numbytes, priv->dds.curbyte)); + if(priv->dds.curbyte >= priv->dds.numbytes) + { + if(priv->dds.data[0] == DRIVCOMM) + cit_DriverComm(dev); /* process command in the driver */ + else + { + cit_ParseCommand(dev); /* First parse command and set parameters in priv rec */ + cit_SendtoTouch(dev); /* send message to the touch and execute command there */ + } + } + + DBG(DDS, ErrorF("%s 1 led_values = %08x\n", CI_INFO, ctrl->led_values)); + ctrl->led_values = 0x12345678; + DBG(DDS, ErrorF("%s 2 led_values = %08x\n", CI_INFO, ctrl->led_values)); + +} + + +static void +xf86CitronFeedback1 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + static int test = 0; + xf86CitronPrint (1, ctrl); + ctrl->led_values = 0x8765432; + ctrl->led_mask = test++; +} + +static void +xf86CitronFeedback2 (DeviceIntPtr dev, LedCtrl *ctrl) +{ + xf86CitronPrint (2, ctrl); + ctrl->led_values = (unsigned long)GetTimeInMillis(); + ctrl->led_mask = (unsigned long)GetTimeInMillis()&0xff; +} + + + +#if(PK) +/* Hexdump a number of Words */ +/* len is number of words to dump */ +static void hexdump (void *ioaddr, int len) +{ + int i; + unsigned long *ptr = (unsigned long *)ioaddr; + + ErrorF(" ADDR 0-3 4-7 8-B C-F\n"); + ErrorF("---------+-----+----+----+----+----+----+----+----\n"); + + while (len > 0) + { + ErrorF ("%08X: ", (unsigned long)ptr); + + for (i=0;i < ( (len>4)?4:len);i++) + ErrorF (" %08x", *ptr++); + ErrorF ("\n"); + len -= 8; + } + + ErrorF("---------+-----+----+----+----+----+----+----+----\n"); +} +#endif + +#ifdef CIT_TIM +/***************************************************************************** + * [cit_StartTimer] + ****************************************************************************/ + +static void +cit_StartTimer(cit_PrivatePtr priv) +{ + priv->timer_ptr = TimerSet(priv->timer_ptr, 0, priv->timer_val1, + priv->timer_callback, (pointer)priv); + DBG(5, ErrorF ("%scit_StartTimer called PTR=%08x\n", CI_INFO, priv->timer_ptr)); +} + + +/***************************************************************************** + * [cit_CloseTimer] + ****************************************************************************/ +static void +cit_CloseTimer(cit_PrivatePtr priv) +{ + + DBG(5, ErrorF ("%scit_CloseTimer called PTR=%08x\n", CI_INFO, priv->timer_ptr)); + if(priv->timer_ptr) + { + TimerFree(priv->timer_ptr); + priv->timer_ptr = NULL; + } + else + DBG(5, ErrorF ("%scit_CloseTimer: Nothing to close\n", CI_WARNING)); +} + + + +/***************************************************************************** + * [cit_DualTouchTimer] + ****************************************************************************/ +static CARD32 +cit_DualTouchTimer(OsTimerPtr timer, CARD32 now, pointer arg) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) arg; + int sigstate; + + DBG(5, ErrorF ("%scit_DualTouchTimer called %d\n", CI_INFO, GetTimeInMillis())); + + priv->packet[0] = R_EXIT; /* build a exit message */ + priv->packet[1] = LOBYTE(priv->raw_x); + priv->packet[2] = HIBYTE(priv->raw_x); + priv->packet[3] = LOBYTE(priv->raw_y); + priv->packet[4] = HIBYTE(priv->raw_y); + priv->packeti = 5; + priv->fake_exit = TRUE; + sigstate = xf86BlockSIGIO (); + + + priv->local->read_input(priv->local); /* faking up an exit message */ + xf86UnblockSIGIO (sigstate); + + DBG(3, ErrorF ("%scit_DualTouchTimer: Faking Exit Message Sent\n", CI_INFO)); + + return (0); /* stop timer */ +} + +#endif + +/***************************************************************************** + * [CitronPreInit] + ****************************************************************************/ +static InputInfoPtr +CitronPreInit (InputDriverPtr drv, IDevPtr dev, int flags) +{ + LocalDevicePtr local = xf86AllocateInput(drv, 0); + cit_PrivatePtr priv = (cit_PrivatePtr) xcalloc (1, sizeof (cit_PrivateRec)); + char *s; +#if(INITT) + int errmaj, errmin; +#endif + + ErrorF ("%sCitronPreInit called - xcalloc=%d\n", CI_INFO, sizeof(cit_PrivateRec)); +/* DBG(2, ErrorF("\txf86Verbose=%d\n", xf86Verbose));*/ + if ((!local) || (!priv)) + { + ErrorF("%s\t- unable to allocate structures!\n", CI_ERROR); + goto SetupProc_fail; + } + + + /* this results in an xf86strdup that must be freed later */ + local->name = xf86SetStrOption(local->options, "DeviceName", "CiTouch"); + ErrorF("%sDevice name: %s\n", CI_INFO, local->name); + + local->type_name = XI_TOUCHSCREEN; + + /* + * Standard setup for the local device record + */ + local->device_control = DeviceControl; + local->read_input = ReadInput; + local->control_proc = ControlProc; + local->close_proc = CloseProc; + local->switch_mode = SwitchMode; + local->conversion_proc = ConvertProc; + local->dev = NULL; + local->private = priv; + local->private_flags = 0; + local->history_size = xf86SetIntOption(local->options, "HistorySize", 0); + local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; + local->conf_idev = dev; + + xf86CollectInputOptions(local, default_options, NULL); + +/* xf86OptionListReport(local->options); */ + + + + debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); + if(debug_level) + { +#ifdef DEBUG + ErrorF("%sDebug level set to %d\n", CI_CONFIG, debug_level); +#else + ErrorF("%sDebug not available\n", CI_INFO); +#endif + } + + +#if(INITT) + + + DBG(5, ErrorF ("%sOpenSerial will be called\n", CI_INFO)); + + local->fd = xf86OpenSerial (local->options); + if (local->fd == -1) + { + ErrorF ("%s\t- unable to open device %s\n", CI_ERROR, xf86FindOptionValue (local->options, "Device")); + goto SetupProc_fail; + } + + DBG(6, ErrorF("%s\t+ %s opened successfully.\n", CI_INFO, xf86FindOptionValue (local->options, "Device"))); +#endif + + /* + * Process the options for the IRT + */ + priv->screen_num = xf86SetIntOption(local->options, "ScreenNumber", 0); + ErrorF("%sAssociated screen: %d\n", CI_CONFIG, priv->screen_num); + priv->min_x = xf86SetIntOption(local->options, "MinX", CIT_DEF_MIN_X); + ErrorF("%sMinimum x position: %d\n", CI_CONFIG, priv->min_x); + priv->max_x = xf86SetIntOption(local->options, "MaxX", CIT_DEF_MAX_X); + ErrorF("%sMaximum x position: %d\n", CI_CONFIG, priv->max_x); + priv->min_y = xf86SetIntOption(local->options, "MinY", CIT_DEF_MIN_Y); + ErrorF("%sMinimum y position: %d\n", CI_CONFIG, priv->min_y); + priv->max_y = xf86SetIntOption(local->options, "MaxY", CIT_DEF_MAX_Y); + ErrorF("%sMaximum y position: %d\n", CI_CONFIG, priv->max_y); + priv->button_number = xf86SetIntOption(local->options, "ButtonNumber", 1); + ErrorF("%sButton Number: %d\n", CI_CONFIG, priv->button_number); + priv->button_threshold = xf86SetIntOption(local->options, "ButtonThreshold", 10); + ErrorF("%sButton Threshold: %d\n", CI_CONFIG, priv->button_threshold); + priv->sleep_mode = xf86SetIntOption(local->options, "SleepMode", 0); + ErrorF("%sSleep Mode: %d\n", CI_CONFIG, priv->sleep_mode); + priv->sleep_time_act = xf86SetIntOption(local->options, "SleepTime", 65535); + ErrorF("%sSleep Time: %d\n", CI_CONFIG, priv->sleep_time_act); + priv->sleep_time_scan = xf86SetIntOption(local->options, "SleepScan", 65535); + ErrorF("%sSleep Scan: %d\n", CI_CONFIG, priv->sleep_time_scan); + priv->pwm_active = xf86SetIntOption(local->options, "PWMActive", 255); + ErrorF("%sPWM Active: %d\n", CI_CONFIG, priv->pwm_active); + priv->pwm_sleep = xf86SetIntOption(local->options, "PWMSleep", 255); + ErrorF("%sPWM Sleep: %d\n", CI_CONFIG, priv->pwm_sleep); + priv->click_mode = xf86SetIntOption(local->options, "ClickMode", NO_CLICK_MODE); + ErrorF("%sClick Mode: %d\n", CI_CONFIG, priv->click_mode); + priv->origin = xf86SetIntOption(local->options, "Origin", 0); + ErrorF("%sOrigin: %d\n", CI_CONFIG, priv->origin); + priv->doze_mode = xf86SetIntOption(local->options, "DozeMode", 0); + ErrorF("%sDoze Mode: %d\n", CI_CONFIG, priv->doze_mode); + priv->doze_time_act = xf86SetIntOption(local->options, "DozeTime", 10); + ErrorF("%sDoze Time: %d\n", CI_CONFIG, priv->doze_time_act); + priv->doze_time_scan = xf86SetIntOption(local->options, "DozeScan", 25); + ErrorF("%sDoze Scan: %d\n", CI_CONFIG, priv->doze_time_scan); + priv->delta_x = xf86SetIntOption(local->options, "DeltaX", 0) & 0xff; + ErrorF("%sDelta X: %d\n", CI_CONFIG, priv->delta_x); + priv->delta_y = xf86SetIntOption(local->options, "DeltaY", 0) & 0xff; + ErrorF("%sDelta Y: %d\n", CI_CONFIG, priv->delta_y); + priv->beep = xf86SetIntOption(local->options, "Beep", 0); + ErrorF("%sBeep: %s\n", CI_CONFIG, (priv->beep > 0) ? "activated":"not activated"); + priv->press_vol = xf86SetIntOption(local->options, "PressVol", 100); + ErrorF("%sBeep Pressure Volume: %d\n", CI_CONFIG, priv->press_vol); + priv->press_pitch = xf86SetIntOption(local->options, "PressPitch", 880); + ErrorF("%sBeep Pressure Pitch: %d\n", CI_CONFIG, priv->press_pitch); + priv->press_dur = xf86SetIntOption(local->options, "PressDur", 15) & 0xff; + ErrorF("%sBeep Pressure Duration: %d\n", CI_CONFIG, priv->press_dur); + priv->rel_vol = xf86SetIntOption(local->options, "ReleaseVol", 100); + ErrorF("%sBeep Release Volume: %d\n", CI_CONFIG, priv->rel_vol); + priv->rel_pitch = xf86SetIntOption(local->options, "ReleasePitch", 1200); + ErrorF("%sBeep Release Pitch: %d\n", CI_CONFIG, priv->rel_pitch); + priv->rel_dur = xf86SetIntOption(local->options, "ReleaseDur", 10) & 0xff; + ErrorF("%sBeep Release Duration: %d\n", CI_CONFIG, priv->rel_dur); + priv->beam_timeout = xf86SetIntOption(local->options, "BeamTimeout", 30) & 0xffff; + ErrorF("%sBeam Timeout: %d\n", CI_CONFIG, priv->beam_timeout); + priv->touch_time = xf86SetIntOption(local->options, "TouchTime", 0) & 0xff; + ErrorF("%sTouch Time: %d\n", CI_CONFIG, priv->touch_time); + priv->enter_count = xf86SetIntOption(local->options, "EnterCount", 3); + ErrorF("%sEnter Count: %d\n", CI_CONFIG, priv->enter_count); + priv->max_dual_count = xf86SetIntOption(local->options, "DualCount", MAX_DUAL_TOUCH_COUNT); + ErrorF("%sDual Count: %d\n", CI_CONFIG, priv->max_dual_count); + +/* trace the min and max values */ + priv->raw_min_x = CIT_DEF_MAX_X; + priv->raw_max_x = 0; + priv->raw_min_y = CIT_DEF_MAX_Y; + priv->raw_max_y = 0; + +#ifdef CIT_TIM +/* preset timer values */ + priv->timer_ptr = NULL; + priv->timer_val1 = 0; + priv->timer_val2 = 0; + priv->timer_callback = NULL; +#endif + + priv->fake_exit = FALSE; + priv->enter_touched = 0; /* preset */ + priv->local = local; /* save local device pointer */ + + DBG(6, ErrorF("%s\t+ options read\n", CI_INFO)); + s = xf86FindOptionValue (local->options, "ReportingMode"); + if ((s) && (xf86NameCmp (s, "raw") == 0)) + priv->reporting_mode = TS_Raw; + else + priv->reporting_mode = TS_Scaled; + +#if(INITT) + /* + * Create an X Input Serial Buffer, because IRT is connected to a serial port + */ + priv->buffer = XisbNew (local->fd, CIT_BUFFER_SIZE); +#endif + priv->proximity = FALSE; + priv->button_down = FALSE; + priv->dual_touch_count = 0; + priv->dual_flg = 0; + priv->state = 0; + priv->lex_mode = cit_idle; + priv->last_x = 0; + priv->last_y = 0; + priv->query_state = 0; /* first query */ + + +#if(INITT) + DBG (8, XisbTrace (priv->buffer, 1)); + + + /* + * Verify that the IRT is attached and functional + */ + if (QueryHardware (local, &errmaj, &errmin) != Success) + { + ErrorF ("%s\t- Unable to query/initialize Citron hardware.\n", CI_INFO); + goto SetupProc_fail; + } +#endif + + xf86ProcessCommonOptions(local, local->options); + local->flags |= XI86_CONFIGURED; +#if(PK) + if (xf86FindOption (local->options, "DemandLoaded")) + { + DBG (5, ErrorF ("%s\tCitron module was demand loaded\n", CI_INFO)); + xf86AddLocalDevice (local, TRUE); + } + else + xf86AddLocalDevice (local, FALSE); +#endif + + if (local->fd >= 0) + { + RemoveEnabledDevice (local->fd); +#if(INITT) + if (priv->buffer) + { + XisbFree(priv->buffer); + priv->buffer = NULL; + } + xf86CloseSerial(local->fd); +#endif + } + + + /* return the LocalDevice */ + DBG(5, ErrorF ("%sCitronPreInit success\n", CI_INFO)); + return (local); + + + /* + * If something went wrong, cleanup and return NULL + */ + SetupProc_fail: +#if(INITT) + if ((local) && (local->fd)) + xf86CloseSerial (local->fd); +#endif + if ((local) && (local->name)) + xfree (local->name); + if (local) + xfree (local); +#if(INITT) + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); +#endif + if (priv) + xfree (priv); + ErrorF ("%sCitronPreInit returning NULL\n", CI_ERROR); + return (NULL); +} + + + +/***************************************************************************** + * [DeviceControl] + ****************************************************************************/ +static Bool +DeviceControl (DeviceIntPtr dev, int mode) +{ + Bool RetVal; + + DBG(5, ErrorF ("%sDeviceControl called; mode = %d\n", CI_INFO, mode)); + switch (mode) + { + case DEVICE_INIT: + DBG(6, ErrorF ("%s\tINIT\n", CI_INFO)); + DeviceInit (dev); + RetVal = Success; + break; + case DEVICE_ON: + DBG(6, ErrorF ("%s\tON\n", CI_INFO)); + RetVal = DeviceOn (dev); + break; + case DEVICE_OFF: + DBG(6, ErrorF ("%s\tOFF\n", CI_INFO)); + RetVal = DeviceOff (dev); + break; + case DEVICE_CLOSE: + DBG(6, ErrorF ("%s\tCLOSE\n", CI_INFO)); + RetVal = DeviceClose (dev); + break; + default: + ErrorF ("%sDeviceControl Mode (%d) not found\n", CI_ERROR, mode); + RetVal = BadValue; + } + return(RetVal); +} + +/***************************************************************************** + * [DeviceOn] + ****************************************************************************/ +static Bool +DeviceOn (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + int errmaj, errmin; + + DBG(5, ErrorF ("%sDeviceOn called\n", CI_INFO)); + + local->fd = xf86OpenSerial(local->options); + if (local->fd == -1) + { + xf86Msg(X_WARNING, "%s%s: cannot open input device\n", CI_ERROR, local->name); + goto DeviceOn_fail; + } + priv->buffer = XisbNew (local->fd, CIT_BUFFER_SIZE); + if (!priv->buffer) + goto DeviceOn_fail; + + xf86FlushInput(local->fd); + + if (QueryHardware (local, &errmaj, &errmin) != Success) + { + ErrorF ("%s\t- Unable to query/initialize Citron hardware.\n", CI_ERROR); + goto DeviceOn_fail; + } + + AddEnabledDevice (local->fd); + dev->public.on = TRUE; + return (Success); + + /* + * If something went wrong, cleanup + */ + DeviceOn_fail: + if ((local) && (local->fd)) + xf86CloseSerial (local->fd); + + if ((local) && (local->name)) + xfree (local->name); + if (local) + { + xfree (local); + local = NULL; + } + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); + if (priv) + { + xfree (priv); + priv = NULL; + } + ErrorF ("%sDeviceOn failed\n", CI_ERROR); + return (!Success); + + + +} + +/***************************************************************************** + * [DeviceOff] + ****************************************************************************/ +static Bool +DeviceOff (DeviceIntPtr dev) +{ + DBG(5, ErrorF ("%sDeviceOff called\n", CI_INFO)); + return DeviceClose(dev); +} + +/***************************************************************************** + * [DeviceClose] + ****************************************************************************/ +static Bool +DeviceClose (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + int c; + + DBG(5, ErrorF ("%sDeviceClose called\n",CI_INFO)); + + cit_Flush(priv->buffer); + + cit_SendCommand(priv->buffer, C_SOFTRESET, 0); +#ifdef CIT_TIM + cit_CloseTimer(priv); /* Close timer if started */ +#endif + XisbTrace(priv->buffer, 1); /* trace on */ + XisbBlockDuration (priv->buffer, 500000); + c = XisbRead (priv->buffer); + if(c == CTS_NAK) + { + DBG(6, ErrorF ("%sTouch Reset executed\n",CI_INFO)); + } + else + { + DBG(6, ErrorF ("%sTouch Reset not executed\n",CI_ERROR)); + } + + +/* Now free all allocated memory */ + if (local->fd >= 0) + { + RemoveEnabledDevice (local->fd); + if (priv->buffer) + { + XisbFree(priv->buffer); + priv->buffer = NULL; + } + xf86CloseSerial(local->fd); + local->fd = 0; + } + + dev->public.on = FALSE; + ErrorF("%sx-range = [%d..%d]\n", CI_INFO, priv->raw_min_x, priv->raw_max_x); + ErrorF("%sy-range = [%d..%d]\n", CI_INFO, priv->raw_min_y, priv->raw_max_y); + + return (Success); +} + + +/***************************************************************************** + * [DeviceInit] + ****************************************************************************/ +static Bool +DeviceInit (DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + unsigned char map[] = + {0, 1}; + + DBG (5, ErrorF("%sDeviceInit called\n", CI_INFO)); + /* + * these have to be here instead of in the SetupProc, because when the + * SetupProc is run and server startup, screenInfo is not setup yet + */ + priv->screen_width = screenInfo.screens[priv->screen_num]->width; + priv->screen_height = screenInfo.screens[priv->screen_num]->height; + + DBG (5, ErrorF("%sScreen Number: %d Screen Width: %d Screen Height: %d\n", CI_INFO, + priv->screen_num, priv->screen_width, priv->screen_height)); + + /* + * Device reports button press for up to 1 button. + */ + if (InitButtonClassDeviceStruct (dev, 1, map) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ButtonClassDeviceStruct\n", CI_ERROR); + return !Success; + } + + /* + * Device reports motions on 2 axes in absolute coordinates. + * Axes min and max values are reported in raw coordinates. + * Resolution is computed roughly by the difference between + * max and min values scaled from the approximate size of the + * screen to fit one meter. + * Device may reports touch pressure on the 3rd axis. + */ + if (InitValuatorClassDeviceStruct (dev, 2, xf86GetMotionEvents, + local->history_size, Absolute) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ValuatorClassDeviceStruct\n", CI_ERROR); + return !Success; + } + else + { + InitValuatorAxisStruct (dev, 0, priv->min_x, priv->max_x, + CIT_DEF_MAX_X, + CIT_DEF_MIN_X /* min_res */ , + CIT_DEF_MAX_X /* max_res */ ); + InitValuatorAxisStruct (dev, 1, priv->min_y, priv->max_y, + CIT_DEF_MAX_Y, + CIT_DEF_MIN_Y /* min_res */ , + CIT_DEF_MAX_Y /* max_res */ ); + } + + if (InitProximityClassDeviceStruct (dev) == FALSE) + { + ErrorF ("%sUnable to allocate Citron touchscreen ProximityClassDeviceStruct\n", CI_ERROR); + return !Success; + } + + + /* + * Use the LedFeedbackClass to set some driver parameters + */ + + /* ID=0 --> Return driver version (RO) */ + + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback0) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=0\n"); + return !Success; + } + /* ID=1 --> ENTER_COUNT */ + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback1) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=1\n"); + return !Success; + } + + /* ID=2 --> */ + if (InitLedFeedbackClassDeviceStruct(dev, xf86CitronFeedback2) == FALSE) + { + ErrorF("Unable to allocate CITRON touchscreen LedFeedbackClassDeviceStruct, id=2\n"); + return !Success; + } + + + /* + * Allocate the motion events buffer. + */ + xf86MotionHistoryAllocate (local); + return (Success); +} + +/***************************************************************************** + * [ReadInput] + ****************************************************************************/ +static void +ReadInput (LocalDevicePtr local) +{ + int x, y; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(RI, ErrorF("%sReadInput called\n", CI_INFO)); + + /* + * set blocking to -1 on the first call because we know there is data to + * read. Xisb automatically clears it after one successful read so that + * succeeding reads are preceeded by a select with a 0 timeout to prevent + * read from blocking indefinately. + */ + if(!priv->fake_exit) + { + XisbBlockDuration (priv->buffer, -1); + DBG(RI, ErrorF("%sXisbBlockDuration = -1\n", CI_INFO)); + } + while ( +#ifdef CIT_TIM + priv->fake_exit || +#endif + (cit_GetPacket (priv) == Success)) + { + cit_ProcessPacket(priv); + + + + if (priv->reporting_mode == TS_Scaled) + { + x = xf86ScaleAxis (priv->raw_x, 0, priv->screen_width, priv->min_x, + priv->max_x); + y = xf86ScaleAxis (priv->raw_y, 0, priv->screen_height, priv->min_y, + priv->max_y); + DBG(RI, ErrorF("%s\tscaled coordinates: (%d, %d)\n", CI_INFO, x, y)); + } + else + { + x = priv->raw_x; + y = priv->raw_y; + } + + xf86XInputSetScreen (local, priv->screen_num, x, y); + + if ((priv->proximity == FALSE) && (priv->state & CIT_TOUCHED)) + { + priv->proximity = TRUE; + xf86PostProximityEvent (local->dev, 1, 0, 2, x, y); + DBG(RI, ErrorF("%s\tproximity(TRUE, x=%d, y=%d)\n", CI_INFO, x, y)); + } + + /* + * Send events. + * + * We *must* generate a motion before a button change if pointer + * location has changed as DIX assumes this. This is why we always + * emit a motion, regardless of the kind of packet processed. + * First test if coordinates have changed a predefined amount of pixels + */ + + if ( ((x >= (priv->last_x + priv->delta_x)) || + (x <= (priv->last_x - priv->delta_x)) || + (y >= (priv->last_y + priv->delta_y)) || + (y <= (priv->last_y - priv->delta_y))) || + ( ((x < priv->delta_x) || + (x > (priv->screen_width - priv->delta_x))) || + ((y < priv->delta_x) || + (y > (priv->screen_height - priv->delta_y)))) ) + { + xf86PostMotionEvent (local->dev, TRUE, 0, 2, x, y); + DBG(RI, ErrorF("%s\tPostMotionEvent(x=%d, y=%d, last_x=%d, last_y=%d)\n", CI_INFO, + x, y, priv->last_x, priv->last_y)); + + priv->last_x = x; /* save cooked data */ + priv->last_y = y; + } + + /* + * Emit a button press or release. + */ + + if ((priv->button_down == FALSE) && (priv->state & CIT_BUTTON)) + { + if(priv->enter_touched < priv->enter_count) + priv->enter_touched++; + + if(priv->enter_touched == priv->enter_count) + { + priv->enter_touched++; /* increment count one more time to prevent further enter events */ + xf86PostButtonEvent (local->dev, TRUE, + priv->button_number, 1, 0, 2, x, y); + cit_Beep(priv, 1); + + DBG(RI, ErrorF("%s\tPostButtonEvent(DOWN, x=%d, y=%d)\n", CI_INFO, x, y)); + + priv->button_down = TRUE; + } + } + + if ((priv->button_down == TRUE) && !(priv->state & CIT_BUTTON)) + { + xf86PostButtonEvent (local->dev, TRUE, + priv->button_number, 0, 0, 2, x, y); + cit_Beep(priv, 0); + priv->enter_touched = 0; /* reset coordinate report counter */ + DBG(RI, ErrorF("%s\tPostButtonEvent(UP, x=%d, y=%d)\n", CI_INFO, x, y)); + priv->button_down = FALSE; + } + /* + * the untouch should always come after the button release + */ + if ((priv->proximity == TRUE) && !(priv->state & CIT_TOUCHED)) + { + priv->proximity = FALSE; + xf86PostProximityEvent (local->dev, 0, 0, 2, x, y); + DBG(RI, ErrorF("%s\tproximity(FALSE, x=%d, y=%d)\n", CI_INFO, x, y)); + } + + + DBG (RI, ErrorF ("%sTouchScreen: x(%d), y(%d), %s\n", + CI_INFO, x, y, + (priv->state == CIT_TOUCHED) ? "Touched" : "Released")); + +#ifdef CIT_TIM + if(priv->fake_exit) + { + priv->fake_exit = FALSE; /* do not sent any further faked exit messages */ + return; + } +#endif + } + DBG(RI, ErrorF("%sExit ReadInput\n", CI_INFO)); +} + +/***************************************************************************** + * [ControlProc] + ****************************************************************************/ +static int +ControlProc (LocalDevicePtr local, xDeviceCtl * control) +{ + xDeviceTSCalibrationCtl *c = (xDeviceTSCalibrationCtl *) control; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(5, ErrorF("%sControlProc called\n", CI_INFO)); + + priv->min_x = c->min_x; + priv->max_x = c->max_x; + priv->min_y = c->min_y; + priv->max_y = c->max_y; + + + return (Success); +} + +/***************************************************************************** + * [CloseProc] + ****************************************************************************/ +static void +CloseProc (LocalDevicePtr local) +{ + DBG(5, ErrorF("%sCloseProc called\n", CI_INFO)); +} + +/***************************************************************************** + * [SwitchMode] + ****************************************************************************/ +static int +SwitchMode (ClientPtr client, DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + DBG(5, ErrorF("%sSwitchMode called; mode = %d\n", CI_INFO, mode)); + if ((mode == TS_Raw) || (mode == TS_Scaled)) + { + priv->reporting_mode = mode; + DBG(6, ErrorF("%s\treporting mode = %s\n", CI_INFO, mode==TS_Raw?"raw":"scaled")); + return (Success); + } + else if ((mode == SendCoreEvents) || (mode == DontSendCoreEvents)) + { + xf86XInputSetSendCoreEvents (local, (mode == SendCoreEvents)); + DBG(6, ErrorF("%s\tmode = %sSend Core Events\n", CI_INFO, mode==DontSendCoreEvents?"Don\'t ":"")); + return (Success); + } +#ifdef CIT_MODE_EXT + else if (mode == ClickMode_Enter) + { + priv->click_mode = CM_ENTER; + DBG(6, ErrorF("%s\tset click mode to ENTER\n", CI_INFO)); + return (Success); + } + else if (mode == ClickMode_Dual) + { + priv->click_mode = CM_DUAL; + DBG(6, ErrorF("%s\tset click mode to DUAL TOUCH\n", CI_INFO)); + return (Success); + } + else if (mode == ClickMode_ZPress) + { + priv->click_mode = CM_ZPRESS; + DBG(6, ErrorF("%s\tset click mode to Z-Press\n", CI_INFO)); + return (Success); + } +#endif + else + { + ErrorF("%sUnknown mode for Citron Touchscreen Switchmode Function: 0x%02x!\n", CI_ERROR, mode); + return (!Success); + } +} + +/***************************************************************************** + * [ConvertProc] + ****************************************************************************/ +static Bool +ConvertProc (LocalDevicePtr local, + int first, + int num, + int v0, + int v1, + int v2, + int v3, + int v4, + int v5, + int *x, + int *y) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + + DBG(5, ErrorF("%sConvertProc called(first=%d, num=%d, v0=%d, v1=%d, v2=%d, v3=%d\n", + CI_INFO, first, num, v0, v1, v2, v3)); + if (priv->reporting_mode == TS_Raw) + { + *x = xf86ScaleAxis (v0, 0, priv->screen_width, priv->min_x, + priv->max_x); + *y = xf86ScaleAxis (v1, 0, priv->screen_height, priv->min_y, + priv->max_y); + } + else + { + *x = v0; + *y = v1; + } + DBG(6, ErrorF("%s\t+ x=%d, y=%d\n",CI_INFO, *x, *y)); + return (TRUE); +} + +/***************************************************************************** + * [QueryHardware] + ****************************************************************************/ +static Bool +QueryHardware (LocalDevicePtr local, int *errmaj, int *errmin) +{ + cit_PrivatePtr priv = (cit_PrivatePtr) (local->private); + unsigned char x; + int i, cnt; + int err; /* for WAIT */ + int init = FALSE; + + /* Reset the IRT from any mode and wait for end of warmstart */ + DBG(5, ErrorF("%sQueryHardware called\n", CI_INFO)); + +/* Will not work with XFree86 4.0 */ +/* xf86SerialSendBreak (local->fd, 2); */ + cit_Flush(priv->buffer); + +/* Test if touch is already initialized */ + cit_SendCommand(priv->buffer, C_GETORIGIN, 0); + + /* wait max. 0.5 seconds for acknowledge */ + DBG(6, ErrorF("%s\t* waiting for acknowledge\n", CI_INFO)); +/* WAIT(50); */ + XisbBlockDuration (priv->buffer, 500000); + cnt = 0; + err = FALSE; + + while ((i=XisbRead(priv->buffer)) != -1) + { + DBG(7, ErrorF("%s\t* 0x%02X received - cnt %d\n",CI_INFO, i, cnt)); + { + switch (cnt) + { + + case 0: + if ((unsigned char)i != CTS_STX) + init = TRUE; + break; + + case 1: + if ((unsigned char)i != (CMD_REP_CONV & C_GETORIGIN)) + init = TRUE; + break; + + case 2: + if ((unsigned char)i > 3) + init = TRUE; + break; + + case 3: + if ((unsigned char)i != CTS_ETX) + init = TRUE; + break; + } + } + cnt++; + if(init) + break; + } + /* Touch is physically not connected or sio problem or break */ + cit_Flush(priv->buffer); /* flush the buffer and wait for break */ + if(cnt < 3) + { + WAIT(150); + /* if we have 0 in the buffer I assume we got a break */ + if (XisbRead(priv->buffer) == 0) + { + + DBG(6, ErrorF("%s+ BREAK detected - cnt=%d\n", CI_INFO, cnt)); + init = TRUE; + } + else /* if nothing is in the buffer I assume the touch is not connected */ + { + ErrorF("%sTouch not connected - please connect - cnt=%d\n", CI_ERROR, cnt); + return(Success); /* If success is returned we can later connect */ + } /* the touch again when it was reconnected without */ + } /* restarting X */ + + /* if init is true, we have to (re)initialize the touch */ + if (init) + { + ErrorF("%sTouch not initialized yet\n",CI_INFO); + + /* + * IRT signals end of startup by sending BREAKS with 100 ms length. + * wait a maximum of 2 seconds for at least 2 consecutive breaks + * to be sure the IRT is really initialized + */ + cit_Flush(priv->buffer); /* clear the buffer and wait for break */ + DBG(6, ErrorF("%s\t* waiting for BREAKS...\n", CI_INFO)); + for (i=0, cnt=0; (i<20) && (cnt<2); i++) + { +/* millisleep (105); */ + WAIT(120); /* wait a little bit longer than 100 ms */ + DBG(7, ErrorF("%s\t (loop %d)\n", CI_INFO, i)); + if (XisbRead(priv->buffer) == 0) + { + cnt++; + DBG(6, ErrorF("%s\t+ BREAK %d detected\n", CI_INFO, cnt)); + } + else + { + cnt = 0; + } + } + if (cnt < 2) + { + ErrorF("%sCannot reset Citron Infrared Touch!\n", CI_ERROR); +/* *errmaj = LDR_NOHARDWARE; */ + return (!Success); + } + /* Now initialize IRT to CTS Protocol */ + DBG(6, ErrorF("%s\t* initializing to CTS mode\n", CI_INFO)); + x = 0x0d; + for (i=0; i<2; i++) + { + XisbWrite(priv->buffer, &x, 1); +/* millisleep (50); */ + WAIT(50); + } + x = MODE_D; + XisbWrite(priv->buffer, &x, 1); + + /* wait max. 0.5 seconds for acknowledge */ + DBG(6, ErrorF("%s\t* waiting for acknowledge\n", CI_INFO)); + XisbBlockDuration (priv->buffer, 500000); + cnt = 0; + while ((i=XisbRead(priv->buffer)) != -1) + { + DBG(7, ErrorF("%s\t* 0x%02X received - waiting for CTS_XON\n",CI_INFO, i)); + if ((unsigned char)i == CTS_XON) + break; + if(cnt++ > 100) return (Success); /* emergency stop */ + } + if ((unsigned char)i != CTS_XON) + { + ErrorF("%sNo acknowledge from Citron Infrared Touch!\n", CI_ERROR); +/* *errmaj = LDR_NOHARDWARE; */ + return (!Success); + } + } + /* now we have the touch connected, do the initialization stuff */ + DBG(6, ErrorF("%s\t+ Touch connected!\n",CI_INFO)); + cit_Flush(priv->buffer); + + DBG(6, ErrorF("%s\t+ requesting pressure sensors report\n",CI_INFO)); + if (cit_GetPressureSensors(priv)!=Success) + { + ErrorF("%sNo pressure sensors report received from Citron Touchscreen!\n",CI_ERROR); + } + + DBG(5, ErrorF("%s ClickMode is %d\n",CI_INFO, priv->click_mode)); + if(priv->click_mode == NO_CLICK_MODE) /* no click mode set in XF86Config */ + { + priv->click_mode = (priv->pressure_sensors > 0) ? CM_ZPRESS : CM_ENTER; + DBG(5, ErrorF("%sClickMode set to %d\n",CI_INFO, priv->click_mode)); + } + + cit_SendCommand(priv->buffer, C_SETAREAFLAGS, 1, AOF_ADDEXIT + | AOF_ADDCOORD + | AOF_ACTIVE + | AOF_ADDPRESS); + + cit_SendCommand(priv->buffer, C_SETAREAMODE, 1, AOM_CONT); + + cit_SendCommand(priv->buffer, C_SETCONTTIME, 1, 20); + + cit_SendCommand(priv->buffer, C_SETDUALTOUCHING, 1, DT_ERROR); + + cit_SendCommand(priv->buffer, C_SETAREAPRESSURE, 1, LOBYTE(priv->button_threshold)); + + cit_SendCommand(priv->buffer, C_SETRESOLUTION, 4, + LOBYTE(CIT_DEF_MAX_X), + HIBYTE(CIT_DEF_MAX_X), + LOBYTE(CIT_DEF_MAX_Y), + HIBYTE(CIT_DEF_MAX_Y)); + + cit_SendCommand(priv->buffer, C_SETPWM, 2, + LOBYTE(priv->pwm_active), + LOBYTE(priv->pwm_sleep)); + + cit_SendCommand(priv->buffer, C_SETBEAMTIMEOUT, 2, + LOBYTE(priv->beam_timeout), + HIBYTE(priv->beam_timeout)); + + cit_SendCommand(priv->buffer, C_SETORIGIN, 1, LOBYTE(priv->origin)); + cit_SendCommand(priv->buffer, C_SETTOUCHTIME, 1, LOBYTE(priv->touch_time)); + + cit_SendCommand(priv->buffer, C_SETSLEEPMODE, 5, + LOBYTE(priv->sleep_mode), + LOBYTE(priv->sleep_time_act), + HIBYTE(priv->sleep_time_act), + LOBYTE(priv->sleep_time_scan), + HIBYTE(priv->sleep_time_scan)); + + cit_SendCommand(priv->buffer, C_SETDOZEMODE, 5, + LOBYTE(priv->doze_mode), + LOBYTE(priv->doze_time_act), + HIBYTE(priv->doze_time_act), + LOBYTE(priv->doze_time_scan), + HIBYTE(priv->doze_time_scan)); + + cit_SendCommand(priv->buffer, C_SETTRANSMISSION, 1, TM_TRANSMIT); + cit_SendCommand(priv->buffer, C_SETSCANNING, 1, 1); + + + if(priv->query_state == 0) /* do error reporting only 1 time */ + { + priv->query_state++; + + DBG(6, ErrorF("%s\t+ requesting initial errors report\n",CI_INFO)); + if (cit_GetInitialErrors(priv)!=Success) + { + ErrorF("%sNo initial error report received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + DBG(6, ErrorF("\t+ requesting defective beams report\n")); + if (cit_GetDefectiveBeams(priv)!=Success) + { + ErrorF("%sNo defective beams report received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + DBG(6, ErrorF("\t+ requesting touch revisions\n")); + if (cit_GetDesignator(priv)!=Success) + { + ErrorF("%sNo designator received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_SYSMGR)!=Success) + { + ErrorF("%sNo system manager module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_HARDWARE)!=Success) + { + ErrorF("%sNo hardware module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_PROCESS)!=Success) + { + ErrorF("%sNo process module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_PROTOCOL)!=Success) + { + ErrorF("%sNo protocol module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + if (cit_GetRevision(priv, GR_HWPARAM)!=Success) + { + ErrorF("%sNo hardware parameter module revision received from Citron Touchscreen!\n",CI_ERROR); + *errmaj = LDR_NOHARDWARE; + return (!Success); + } + } + + DBG(6, ErrorF("%s\t+ Touch initialized - %d\n",CI_INFO, priv->query_state)); + + return (Success); +} + + +/***************************************************************************** + * [cit_GetPacket] + ****************************************************************************/ +static Bool +cit_GetPacket (cit_PrivatePtr priv) +{ + int c; + int errmaj, errmin; + + DBG(GP, ErrorF("%scit_GetPacket called\n", CI_INFO)); + DBG(GP, ErrorF("%s\t* initial lex_mode =%d (%s)\n", CI_INFO, priv->lex_mode, + priv->lex_mode==cit_idle ?"idle": + priv->lex_mode==cit_getID ?"getID": + priv->lex_mode==cit_collect ?"collect": + priv->lex_mode==cit_escape ?"escape": + "???")); + while ((c = XisbRead (priv->buffer)) >= 0) + { +#if(0) + DBG(GP, ErrorF("%s c=%d\n",CI_INFO, c)); +#endif + if (c == CTS_STX) + { + DBG(GP, ErrorF("%s\t+ STX detected\n", CI_INFO)); + /* start of report received */ + if (priv->lex_mode != cit_idle) + DBG(7, ErrorF("%s\t- no ETX received before this STX!\n", CI_WARNING)); + priv->lex_mode = cit_getID; + DBG(GP, ErrorF("%s\t+ new lex_mode == getID\n", CI_INFO)); + } + else if (c == CTS_ETX) + { + DBG(GP, ErrorF("%s\t+ ETX detected\n", CI_INFO)); + /* end of command received */ + /* always IDLE after report completion */ + DBG(GP, ErrorF("%s\t+ new lex_mode == idle\n", CI_INFO)); + if (priv->lex_mode == cit_collect) + { + DBG(GP, ErrorF("%s\t+ Good report received\n", CI_INFO)); + priv->lex_mode = cit_idle; + return (Success); + } + DBG(GP, ErrorF("%s\t- unexpected ETX received!\n", CI_WARNING)); + priv->lex_mode = cit_idle; + } + else if (c == CTS_ESC) + { + DBG(GP, ErrorF("%s\t+ escape detected\n", CI_INFO)); + /* next character is encoded */ + if (priv->lex_mode != cit_collect) + { + DBG(GP, ErrorF("%s\t- unexpected control character received\n", CI_WARNING)); + } + else + { + priv->lex_mode = cit_escape; + DBG(GP, ErrorF("%s\t+ new lex_mode == escape\n", CI_INFO)); + } + } + else if ((c < CTS_CTRLMIN) || (c > CTS_CTRLMAX)) + { + /* regular report data received */ + if (priv->lex_mode == cit_getID) + { /* receive report ID */ + priv->packeti = 0; + priv->packet[priv->packeti++] = (unsigned char)c; + priv->lex_mode = cit_collect; + DBG(GP, ErrorF("%s\t+ identifier captured, new lex_mode == collect\n", CI_INFO)); + } + else if ((priv->lex_mode == cit_collect) || (priv->lex_mode == cit_escape)) + { /* receive command data */ + if (priv->lex_mode == cit_escape) + { /* decode encoded data byte */ + c &= CTS_DECODE; /* decode data */ + priv->lex_mode = cit_collect; + DBG(GP, ErrorF("%s\t+ decoded character = 0x%02X\n", CI_INFO, c)); + DBG(GP, ErrorF("%s\t+ new lex_mode = collect\n", CI_INFO)); + } + if (priv->packeti < CTS_PACKET_SIZE) + { /* add data bytes to buffer */ + priv->packet[priv->packeti++] = (unsigned char)c; + } + else + { + DBG(GP, ErrorF("%s\t- command buffer overrun\n", CI_ERROR)); + /* let's reinitialize the touch - maybe it sends breaks */ + cit_Flush(priv->buffer); + + } + } + else + { + /* this happens e.g. when the touch sends breaks, so we try to reconnect */ + DBG(GP, ErrorF("%s\t- unexpected non control received!\n", CI_WARNING)); + DBG(GP, ErrorF("%s\t- Device not connected - trying to reconnect ...\n", CI_WARNING)); + if (QueryHardware (priv->local, &errmaj, &errmin) != Success) + ErrorF ("%s\t- Unable to query/initialize Citron Touch hardware.\n", CI_ERROR); + else + ErrorF ("%s\t- Citron Touch reconnected\n", CI_INFO); + + } + } + else if (c != CTS_XON && c != CTS_XOFF) + { + DBG(GP, ErrorF("%s\t- unhandled control character received!\n", CI_WARNING)); + } + } + DBG(GP, ErrorF("%scit_GetPacket exit !Success\n", CI_INFO)); + return (!Success); +} + + +/***************************************************************************** + * [cit_Flush] + ****************************************************************************/ +static void +cit_Flush (XISBuffer *b) +{ + DBG(7, ErrorF("%scit_Flush called\n", CI_INFO)); + XisbBlockDuration(b, 0); + while (XisbRead(b) > 0); +} + + + +/***************************************************************************** + * [cit_Beep] + ****************************************************************************/ +static void +cit_Beep(cit_PrivatePtr priv, int press) +{ +#ifdef CIT_BEEP + if(priv->beep == 0) + return; + + /* ring release bell */ + if(press == 0) + + /* [0]: volume, [1]: pitch, [2]: duration */ + /* formula is: ((1193190 / freq) & 0xffff) | */ + /* (((unsigned long)duration * loudness / 50) << 16)) */ + /* .. whatever the inventor wants to intend by it, I don't know (PK) */ + + xf86SoundKbdBell(priv->rel_vol, priv->rel_pitch, priv->rel_dur); + + else + /* ring press bell */ + xf86SoundKbdBell(priv->press_vol,priv->press_pitch, priv->press_dur); + + DBG(7, ErrorF("%scit_Beep called - %s\n", CI_INFO, (press == 0) ? "release" : "press")); +#endif +} + + +/***************************************************************************** + * [cit_SendCommand] + ****************************************************************************/ +static void +cit_SendCommand (XISBuffer *b, unsigned char cmd, int cnt, ...) +{ + va_list ap; + unsigned char data, x; + + va_start(ap, cnt); + + DBG(7, ErrorF("%scit_SendCommand(cmd=0x%02X, cnt=%d, ...)\n", CI_INFO, cmd, cnt)); + x = CTS_STX; + XisbWrite(b, &x, 1); /* transmit start of packet */ + XisbWrite(b, &cmd, 1); /* transmit command code */ + x = CTS_ESC; + while (cnt-- > 0) + { /* encode and transmit optional parameters */ + data = va_arg(ap, int); + if (data >= CTS_CTRLMIN && data <= CTS_CTRLMAX) + { /* data has to be encoded */ + data |= CTS_ENCODE; + XisbWrite(b, &x, 1); /* mark coded data */ + } + XisbWrite(b, &data, 1); /* transmit data */ + } + x = CTS_ETX; + XisbWrite(b, &x, 1); /* transmit end of packet */ + va_end(ap); +} + + +/***************************************************************************** + * [cit_GetInitialErrors] + ****************************************************************************/ +static Bool cit_GetInitialErrors(cit_PrivatePtr priv) +{ + unsigned long errors; + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETERRORS, 1, GE_INITIAL); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti != 6) + { + DBG(5, ErrorF("%sWrong packet length (expected 6, received %d bytes)\n", CI_NOTICE, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETERRORS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETERRORS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GE_INITIAL) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GE_INITIAL, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + errors = 0x00000001UL * (unsigned long)priv->packet[2] + + 0x00000100UL * (unsigned long)priv->packet[3] + + 0x00010000UL * (unsigned long)priv->packet[4] + + 0x10000000UL * (unsigned long)priv->packet[5]; + DBG(6, ErrorF("%sinitial errors = 0x%08lX\n", CI_NOTICE, errors)); + if (errors == 0x00000000UL) + { + ErrorF("%sNo initialization errors detected.\n", CI_INFO); + } + if (errors & IE_SMCHKSUM) + { + ErrorF("%sSystem Manager Module checksum error!\n", CI_ERROR); + } + if (errors & IE_SMINIT) + { + ErrorF("%sSystem Manager Module initialization error!\n", CI_ERROR); + } + if (errors & IE_HWCHKSUM) + { + ErrorF("%sHardware Module checksum error!\n", CI_ERROR); + } + if (errors & IE_HWINIT) + { + ErrorF("%sHardware Module initialization error!\n", CI_ERROR); + } + if (errors & IE_HW_BEAMS) + { + ErrorF("%s broken beams during initialization detected!\n", CI_ERROR); + } + if (errors & IE_HW_PSU) + { + ErrorF("%s force sensors not operating!\n", CI_ERROR); + } + if (errors & IE_HW_CPU) + { + ErrorF("%s CPU integrity test failed!\n", CI_ERROR); + } + if (errors & IE_HW_IRAM) + { + ErrorF("%s internal RAM error!\n", CI_ERROR); + } + if (errors & IE_HW_XRAM) + { + ErrorF("%s external SRAM error!\n", CI_ERROR); + } + if (errors & IE_PCCHKSUM) + { + ErrorF("%sProcess Module checksum error!\n", CI_ERROR); + } + if (errors & IE_PCINIT) + { + ErrorF("%sProcess Module initialization error!\n", CI_ERROR); + } + if (errors & IE_PTCHKSUM) + { + ErrorF("%sProtocol Module checksum error!\n", CI_ERROR); + } + if (errors & IE_PTINIT) + { + ErrorF("%sProtocol Module initialization error!\n", CI_ERROR); + } + if (errors & IE_BICHK) + { + ErrorF("%sBurnIn Module checksum error!\n", CI_ERROR); + } + if (errors & IE_BIINIT) + { + ErrorF("%sBurnIn Module initialization error!\n", CI_ERROR); + } + if (errors & IE_FPGACHK) + { + ErrorF("%sFPGA configuration checksum error!\n", CI_ERROR); + } + if (errors & IE_HWPCHK) + { + ErrorF("%sHardware Parameter checksum error!\n", CI_ERROR); + } + return (Success); +} + + +/***************************************************************************** + * [cit_GetDefectiveBeams] + ****************************************************************************/ +static Bool cit_GetDefectiveBeams(cit_PrivatePtr priv) +{ + unsigned nx, ny; + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETERRORS, 1, GE_DEFECTBEAMS); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 6) + { + DBG(5, ErrorF("%sWrong packet length (expected >= 6, received %d bytes)\n", CI_NOTICE, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETERRORS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETERRORS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GE_DEFECTBEAMS) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GE_DEFECTBEAMS, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + nx = 0x0001U * (unsigned)priv->packet[2] + + 0x0100U * (unsigned)priv->packet[3]; + + ny = 0x0001U * (unsigned)priv->packet[4] + + 0x0100U * (unsigned)priv->packet[5]; + /* list defective X-beams */ + if (nx > 0) + { + ErrorF("%s%u defective X-Beams detected:\n", CI_ERROR, nx); + for (i=0; i<nx; i++) + { + ErrorF("%s\tX%02u\n", CI_ERROR, (unsigned)priv->packet[6+i]); + } + } + else + { + ErrorF("%sNo defective X-beams detected.\n", CI_INFO); + } + + /* list defective Y-beams */ + if (ny > 0) + { + ErrorF("%s%u defective Y-Beams detected:\n", CI_ERROR, ny); + for (i=0; i<ny; i++) + { + ErrorF("%s\tY%02u\n", CI_ERROR, (unsigned)priv->packet[6+nx+i]); + } + } + else + { + ErrorF("%sNo defective Y-beams detected.\n", CI_INFO); + } + return (Success); +} + + +/***************************************************************************** + * [cit_GetDesignator] + ****************************************************************************/ +static Bool cit_GetDesignator(cit_PrivatePtr priv) +{ + int i,n; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETREVISIONS, 1, GR_DESIGNATOR); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2+CTS_DESIGNATOR_LEN+CTS_ASSY_LEN) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2+CTS_DESIGNATOR_LEN+CTS_ASSY_LEN, + priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETREVISIONS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETREVISIONS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GR_DESIGNATOR) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GR_DESIGNATOR, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + ErrorF("%sDesignator \"", CI_INFO); + i = 2; + n = 0; + while (n++ < CTS_DESIGNATOR_LEN && priv->packet[i]!=0) + { + ErrorF("%c", priv->packet[i++]); + } + ErrorF("\"\n%sAssembly \"", CI_INFO); + i = 2 + CTS_DESIGNATOR_LEN; + n = 0; + while (n++ < CTS_ASSY_LEN && priv->packet[i]!=0) + { + ErrorF("%c", priv->packet[i++]); + } + ErrorF("\"\n"); + return (Success); +} + + +/***************************************************************************** + * [cit_GetRevision] + ****************************************************************************/ +static Bool cit_GetRevision(cit_PrivatePtr priv, int selection) +{ + int i,n; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETREVISIONS, 1, (unsigned char)selection); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + XisbBlockDuration(priv->buffer, 500000); + while (((res = cit_GetPacket(priv)) != Success) && (priv->lex_mode != cit_idle)); + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2, priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETREVISIONS & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETREVISIONS & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != selection) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + selection, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + DBG(5, ErrorF("%s%s module revision ", CI_INFO, + selection == GR_SYSMGR ? "SysMgr " : + selection == GR_HARDWARE ? "Hardware" : + selection == GR_PROCESS ? "Process " : + selection == GR_PROTOCOL ? "Protocol" : + selection == GR_HWPARAM ? "HWParam " : + "???")); + i = 2; + n = 0; + DBG(5, ErrorF("\"")); + while (n < priv->packeti && priv->packet[i]!=0) + { + DBG(5, ErrorF("%c", priv->packet[i])); + i++; + } + DBG(5, ErrorF("\"\n")); + return (Success); +} + + +/***************************************************************************** + * [cit_ProcessPacket] + ****************************************************************************/ +static void cit_ProcessPacket(cit_PrivatePtr priv) +{ + int i; + + DBG(PP, ErrorF("%scit_ProcessPacket called\n", CI_INFO)); + DBG(PP, ErrorF("%s\t+ enter state = 0x%04X, dual touch count=%d\n", CI_INFO, priv->state, priv->dual_touch_count)); + /* examine message identifier */ + + priv->dual_flg = TRUE; /* Dual Touch Error occurred */ +#ifdef CIT_TIM + priv->timer_val1 = 1000; /* Timer delay [ms]*/ + priv->timer_callback = (OsTimerCallback)cit_DualTouchTimer; /* timer callback routine */ + cit_StartTimer(priv); +#endif + + switch (priv->packet[0]) + { + case R_COORD: /* new touch coordinates received */ + if (priv->packeti < 5) + { + DBG(PP, ErrorF("%s\t- coordinate message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + + + if (priv->dual_touch_count > 0) + priv->dual_touch_count--; + + priv->raw_x = 0x0001U * priv->packet[1] + + 0x0100U * priv->packet[2]; + priv->raw_y = 0x0001U * priv->packet[3] + + 0x0100U * priv->packet[4]; + + priv->raw_min_x = min(priv->raw_min_x, priv->raw_x); + priv->raw_max_x = max(priv->raw_max_x, priv->raw_x); + priv->raw_min_y = min(priv->raw_min_y, priv->raw_y); + priv->raw_max_y = max(priv->raw_max_y, priv->raw_y); + + priv->state |= CIT_TOUCHED; + + DBG(PP, ErrorF("%s\t+ COORD message raw (%d,%d)\n", CI_INFO, priv->raw_x, priv->raw_y)); + break; + + case R_EXIT: /* touch area no longer interrupted */ + if (priv->packeti < 5) + { + DBG(PP, ErrorF("%s\t- exit message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + + priv->state &= ~(CIT_TOUCHED | CIT_PRESSED); + priv->dual_touch_count = 0; + priv->raw_x = 0x0001U * priv->packet[1] + + 0x0100U * priv->packet[2]; + priv->raw_y = 0x0001U * priv->packet[3] + + 0x0100U * priv->packet[4]; +#ifdef CIT_TIM + cit_CloseTimer(priv); /* close timer if exit message was received */ +#endif + DBG(PP, ErrorF("%s\t+ EXIT message (%d,%d)\n", CI_INFO, priv->raw_x, priv->raw_y)); + break; + + case R_DUALTOUCHERROR: + if (priv->dual_touch_count < priv->max_dual_count) + priv->dual_touch_count++; + DBG(PP, ErrorF("%s\t+ DUAL TOUCH ERROR message received\n", CI_INFO)); + break; + + case R_PRESSURE: /* pressure message received */ + if (priv->packeti < 2) + { + DBG(PP, ErrorF("%s\t- pressure message packet too short (%d bytes)\n", CI_ERROR, priv->packeti)); + break; + } + priv->state |= CIT_TOUCHED; + if (priv->packet[1] == PRESS_EXCEED) + priv->state |= CIT_PRESSED; + else if(priv->packet[1] == PRESS_BELOW) + { + priv->state &= ~CIT_PRESSED; + } + else + DBG(PP, ErrorF("%sPressure Message Error\n", CI_ERROR)); + + DBG(PP, ErrorF("%s\t+ pressure %s message\n", CI_INFO, priv->packet[1] ? "enter":"exit")); + break; + + default: + DBG(PP, ErrorF("%s\t* unhandled message:", CI_ERROR)); + for (i=0; i<priv->packeti; i++) + { + DBG(PP, ErrorF(" 0x%02X", priv->packet[i])); + } + DBG(PP, ErrorF("\n")); + } + /* generate button state */ + switch (priv->click_mode) + { + case CM_ZPRESS: + DBG(PP, ErrorF("%s\t+ ZPress, button ", CI_INFO)); + if (priv->state & CIT_PRESSED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + + break; + + case CM_ZPRESSEXIT: + DBG(PP, ErrorF("%s\t+ ZPressExit, button ", CI_INFO)); + if (priv->state & CIT_PRESSED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (!(priv->state & CIT_TOUCHED)) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + case CM_DUAL: + DBG(PP, ErrorF("%s\t+ Dual Touch, button ", CI_INFO)); + if ((priv->dual_touch_count == priv->max_dual_count) && (priv->state & CIT_TOUCHED)) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (priv->dual_touch_count == 0) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + case CM_DUALEXIT: + DBG(PP, ErrorF("%s\t+ Dual Exit, button ", CI_INFO)); + if ((priv->dual_touch_count == priv->max_dual_count) && (priv->state & CIT_TOUCHED)) + { + priv->dual_flg = TRUE; + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else if (!(priv->state & CIT_TOUCHED)) + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + + default: /* default to enter mode */ + DBG(PP, ErrorF("%s\t+ Enter Mode, button ", CI_INFO)); + if (priv->state & CIT_TOUCHED) + { + priv->state |= CIT_BUTTON; + DBG(PP, ErrorF("down")); + } + else + { + priv->state &= ~CIT_BUTTON; + DBG(PP, ErrorF("up")); + } + break; + } + DBG(PP, ErrorF("\n")); + DBG(PP, ErrorF("%s\t+ Click Mode=%d\n", CI_INFO, priv->click_mode)); + DBG(PP+1, ErrorF("%s\t+ exit state = 0x%04X, dual touch count=%d\n", CI_INFO, priv->state, priv->dual_touch_count)); + DBG(PP+1, ErrorF("%s\t raw_x=%d, raw_y=%d\n", CI_INFO, priv->raw_x, priv->raw_y)); +} + + + +/***************************************************************************** + * [cit_GetPressureSensors] + ****************************************************************************/ +static Bool cit_GetPressureSensors(cit_PrivatePtr priv) +{ + int i; + Bool res; + + cit_Flush(priv->buffer); + cit_SendCommand(priv->buffer, C_GETHARDWARE, 1, GH_SENSORCOUNT); + /* + touch responds within 1 millisecond, + but it takes some time, until the command is sent and received! + */ + for (i=0; i<5; i++) + { + XisbBlockDuration(priv->buffer, 500000); + res = cit_GetPacket(priv); + if ((res == Success) || (priv->lex_mode == cit_idle)); + break; + } + if (res != Success) + { + DBG(5, ErrorF("%sNo packet received!\n", CI_NOTICE)); + return (!Success); + } + /* examine packet */ + if (priv->packeti < 2+CTS_SENSORCOUNT_LEN) + { + DBG(5, ErrorF("%sWrong packet length (expected >= %d, received %d bytes)\n", CI_NOTICE, + 2+CTS_SENSORCOUNT_LEN, + priv->packeti)); + return (!Success); + } + if (priv->packet[0] != (C_GETHARDWARE & CMD_REP_CONV)) + { + DBG(5, ErrorF("%sWrong packet identifier (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + (C_GETHARDWARE & CMD_REP_CONV), priv->packet[0])); + return (!Success); + } + if (priv->packet[1] != GH_SENSORCOUNT) + { + DBG(5, ErrorF("%sWrong packet selector (expected 0x%02X, received 0x%02X)\n", CI_NOTICE, + GH_SENSORCOUNT, priv->packet[1])); + return (!Success); + } + /* this is our packet! check contents */ + ErrorF("%sPressureSensors: \"%d\"\n", CI_INFO, priv->packet[2]); + priv->pressure_sensors = priv->packet[2]; + return (Success); +} + + Index: xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp:1.4 --- /dev/null Mon Dec 18 14:31:35 2000 +++ xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp Sun Dec 17 17:27:40 2000 @@ -0,0 +1,629 @@ +.\" Copyright (c) 2000 Peter Kunzmann <support@@citron.de> +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.cpp,v 1.4 2000/12/17 22:27:40 dawes Exp $ +.\" +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH CITRON __drivermansuffix__ "Version 4.0.2" "XFREE86" +.SH NAME +citron \- Citron Infrared Touch Driver (CiTouch) +.SH SYNOPSIS +.nf +.B "Section \*qInputDevice\*q" +.BI " Identifier \*q" idevname \*q +.B " Driver \*qcitron\*q" +.BI " Option \*qDevice\*q \*q" devpath \*q +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B citron +is a XFree86 input driver for +.I Citron Infrared Touch +devices. +.PP +The +.B citron +driver acts as a pointer input device, and may be used as the +X server's core pointer. It is connected via a "RS232" with the host. +.SH SUPPORTED HARDWARE +At the moment the following touches are supported. They are also +available as +.I ZPress +touches. + +.B IRT6I5-V2.x + 6.5 inch Infrared Touch + +.B IRT10I4-V4.x + 10.4 inch Infrared Touch + +.B IRT12I1-V2.x + 12.1 inch Infrared Touch + +.B IRT15I1-V1.x + 15.1 inch Infrared Touch + +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details and for options that can be used with all input drivers. This +section only covers configuration details specific to this driver. +For better understanding please read also the +.B CTS +and various +.B IRT +manuals which are available in "pdf" format from Citron web page +.B www.citron.de +or directly from Citron. + +.PP +.PP +The following driver +.B Options +are supported: +.TP 7 +.BI "Option \*qDevice\*q \*q" devpath \*q +Specify the device path for the citron touch. Valid devices are: +.PP +.RS 12 +/dev/ttyS0, /dev/ttyS1, ... +.RE +.RS 7 +This option is mandatory. +.PP +It's important to specify the right device Note: com1 -> /dev/ttyS0, com2 -> /dev/ttyS1, ... + +.RE +.TP 7 +.BI "Option \*qScreenNumber\*q \*q" screennumber \*q +sets the +.I screennumber +for the +.B citron +InputDevice. +.PP +.RS 7 +.I Default: +ScreenNumber: "0" + +.RE +.TP 7 +.BI "Option \*qMinX\*q \*q" value \*q +.TP 7 +.BI "Option \*qMinY\*q \*q" value \*q +These are the minimum X and Y values for the +.B citron +input device. +.PP +.RS 7 +Note: MinX, MinY must be less than MaxX, MaxY. +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +MinX: "0" MinY: "0" + + +.RE +.TP 7 +.BI "Option \*qMaxX\*q \*q" value \*q +.TP 7 +.BI "Option \*qMaxY\*q \*q" value \*q +These are the maximum X and Y values for the +.B citron +input device. +.PP +.RS 7 +Note: MaxX, MaxY must be greater than MinX, MinY. +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +MaxX: "65535" MaxY: "65535" + + +.RE +.TP 7 +.BI "Option \*qButtonNumber\*q \*q" value \*q +This value is responsible for the +.I button number +that is returned within the xf86PostButton event message +.PP +.RS 7 +.I Range: +"0" - "255" +.PP +.I Default: +"1" + +.RE +.TP 7 +.BI "Option \*qButtonThreshold\*q \*q" value \*q +This value is responsible for the +.I button threshold. +It changes the pressure sensitivity of the touch. A higher number +corresponds to a higher pressure. +.PP +.RS 7 +Note: This feature is only available with pressure sensitive hardware. +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"20" + +.RE +.TP 7 +.B Sleep-Mode +If the IRT is in +.I Doze-Mode +and Touch Zone is not interrupted for another +certain span of time, the so-called +.I Sleep-Mode +is activated. The +.I Sleep-Mode +decreases the scan rate of the beams even further than +the +.I Doze-Mode +does (see below). This way the life expectancy of the beams is +prolonged and the power consumption of the IRT is reduced. +As soon as an interruption of the Touch Zone is detected, the +.I Sleep-Mode +is deactivated and the Touch Zone will again be scanned with +the maximum speed. With the Sleep-Mode activated, +depending on the set scan rate the IRT's response time can be +considerably longer as in normal operation. If, for example, +a scan rate of 500 ms / scan is set, it may last up to a half +of a second until the IRT detects the interruption and deactivates +the +.I Sleep-Mode. + +.PP +.RE +.TP 7 +.BI "Option \*qSleepMode\*q \*q" mode \*q +This value is responsible for the +.I sleep-mode +of the touch. +.RS 7 +Determines the behaviour of the Sleep-Mode. + +.B 0x00 + No message at either activation or deactivation + +.B 0x01 + Message at activation + +.B 0x02 + Message at deactivation + +.B 0x03 + Message at activation and deactivation + +.B 0x10 +GP_OUT output set according to the Sleep-Mode status + +.I Values: +"0" "1" "2" "3" "16" + +.I Default: +"0" + +.RE +.TP 7 +.BI "Option \*qSleepTime\*q \*q" time \*q +This value is responsible for the +.I sleep-time +of the touch. It is the activation time in seconds +("0" = immediately activated, "65535" = always deactivated). +.RS 7 +.PP +.I Range: +"0" - "65535" [s] +.PP +.I Default: +"65535" => deactivated + +.RE +.TP 7 +.BI "Option \*qSleepScan\*q \*q" scan \*q +This value is responsible for the +.I scan-time +of the touch. This is the time interval between two scan operations +while in Sleep-Mode. The time interval is set in steps +of milliseconds. +.RS 7 +.PP +.I Range: +"0" - "65535" [ms] +.PP +.I Default: +"500" + +.RE +.TP 7 +.BI "Option \*qPWMActive\*q \*q" value \*q +This value determines the mark-to-space ratio of the +.I PWM +output while in normal operation (sleep-mode not active). +Higher values result in longer pulse widths. This output +signal can be used in conjunction with the +.I Citron AWBI +to do backlight-dimming via the touch. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"255" (max. brightness) + + +.RE +.TP 7 +.BI "Option \*qPWMSleep\*q \*q" value \*q +This value determines the mark-to-space ratio of the +.I PWM +output while in sleep-mode (-> +.I SleepMode, SleepScan, SleepTime +) operation (sleep-mode active). +Higher values result in longer pulse widths. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"255" (max. brightness) + +.RE +.TP 7 +.BI "Option \*qClickMode\*q \*q" mode \*q +With mode one can select between 5 +.I ClickModes + +.B \*q1\*q += ClickMode Enter + +With this mode every interruption of the infrared beams will +activate a ButtonPress event and after the interruption a +ButtonRelease event will be sent. + +.B \*q2\*q += ClickMode Dual + +With this mode every interruption will sent a Proximity event and +every second interruption a ButtonPress event. With the release of +the interruption (while one interruption is still active) a +ButtonRelease event will be sent. + +.B \*q3\*q += ClickMode Dual Exit + +With this mode every interruption will sent a ProximityIn event and +every second interruption a ButtonPress event. With the release of +the interruption (while one interruption is still active) no +ButtonRelease event will be sent. Only if all interruptions are released +a ButtonRelease followed by a ProximityOut event will be sent. + +.B \*q4\*q += ClickMode ZPress + +With this mode every interruption will sent a ProximityIn event. Only if +a certain pressure is exceeded a ButtonPress event will occur. If the +pressure falls below a certain limit a ButtonRelease event will be sent. +After also the interruption is released a ProximityOut event is generated. + +.B \*q5\*q += ClickMode ZPress Exit + +This mode is similar to "Clickmode Dual Exit". +The first interruption of the beams will sent a ProximityIn event. Only if +a certain pressure is exceeded a ButtonPress event will occur. If the +pressure falls below a certain limit no ButtonRelease event will be sent. +After the interruption is also released a ButtonRelease followed by +a ProximityOut event is generated. +.RS 7 +.PP +.I Range: +"1" - "5" +.PP +.I Default: +"1" (ClickMode Enter) + +.RE +.TP 7 +.BI "Option \*qOrigin\*q \*q" value \*q +This value sets the coordinates origin to one of the four corners of +the screen. +The following values are accepted: +"0" TOPLEFT: Origin set to the left-hand side top corner. +"1" TOPRIGHT: Origin set to the right-hand side top corner. +"2" BOTTOMRIGHT: Origin set to the right-hand side bottom corner. +"3" BOTTOMLEFT: Origin set to the left-hand side bottom corner. +.RS 7 +.PP +.I Range: +"0" - "3" +.PP +.I Default: +"0" (TOPLEFT) + +.RE +.TP 7 +.B "Doze-Mode" +If for a certain span of time the Touch Zone is not interrupted, +the so-called Doze-Mode is automatically activated. The activated +Doze-Mode slightly decreases the scan rate of the beams. This way +the power consumption of the IRT is reduced. As soon as an +interruption of the Touch Zone is detected, the Doze-Mode +is deactivated and the Touch Zone will again be scanned with +the maximum speed. + +.RE +.TP 7 +.BI "Option \*qDozeMode\*q \*q" mode \*q +This value is responsible for the +.I doze-mode +of the touch. +.RS 7 +.PP +Determines the behaviour of the Doze-Mode. +.PP +.B 0x00 +No message at either activation or deactivation + +.B 0x01 +Message at activation + +.B 0x02 +Message at deactivation + +.B 0x03 +Message at activation and deactivation + +.B 0x10 +GP_OUT output set according to the Doze-Mode status + +If the GP_OUT output is already controlled by the +.I Sleep-Mode +it is no longer available as an output port anymore. +.PP +.I Values: +"0" "1" "2" "3" "16" +.PP +.I Default: +"0" + + + +.RE +.TP 7 +.BI "Option \*qDozeTime\*q \*q" time \*q +This value is responsible for the +.I doze-time +of the touch. It is the activation time in seconds +("0" = immediately activated, "65535" = always deactivated). +.RS 7 +.PP +.I Range: +"0" - "65535" [s] +.PP +.I Default: +"65535" => deactivated + + +.RE +.TP 7 +.BI "Option \*qDozeScan\*q \*q" scan \*q +This value is responsible for the +.I scan-time +of the touch. This is the time interval between two scan operations +while in Doze-Mode. The time interval is set in steps +of milliseconds. +.RS 7 +.PP +.I Range: +"0" - "65535" [ms] +.PP +.I Default: +"500" + +.RE +.TP 7 +.BI "Option \*qDeltaX\*q \*q" value \*q +This value determines a virtual area at the left and right +side of the current cursor position where the cursor didn't move. +Within this area no "MotionNotify" event will be sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (no deltaX) + + +.RE +.TP 7 +.BI "Option \*qDeltaY\*q \*q" value \*q +This value determines a virtual area at the top and bottom +of the current cursor position where the cursor didn't move. +Within this area no "MotionNotify" event will be sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (no deltaY) + +.RE +.TP 7 +.BI "Option \*qBeep\*q \*q" value \*q +This value determines if a "ButtonPress" and/or a "ButtonRelease" +event should sound the buzzer. "0" deactivates the buzzer while +every other value will activate it. +.RS 7 +.PP +.I Range: +"0" - "1" +.PP +.I Default: +"0" (deactivated) + +.RE +.TP 7 +.BI "Option \*qPressVol\*q \*q" value \*q +This value determines the volume of the buzzer (0-100%) +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "100" +.PP +.I Default: +"100" + + +.RE +.TP 7 +.BI "Option \*qPressPitch\*q \*q" value \*q +This value determines the pitch of the tone +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "3000" +.PP +.I Default: +"880" + + + +.RE +.TP 7 +.BI "Option \*qPressDur\*q \*q" value \*q +This value determines the duration of the tone in ms +when a "ButtonPress" event is sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"15" + +.RE +.TP 7 +.BI "Option \*qReleaseVol\*q \*q" value \*q +This value determines the volume of the buzzer (0-100%) +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "100" +.PP +.I Default: +"100" + + +.RE +.TP 7 +.BI "Option \*qReleasePitch\*q \*q" value \*q +This value determines the pitch of the tone when +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "3000" +.PP +.I Default: +"1200" + + + +.RE +.TP 7 +.BI "Option \*qReleseDur\*q \*q" value \*q +This value determines the duration of the tone in ms when +when a "ButtonRelease" event is sent. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"10" + + + +.RE +.TP 7 +.BI "Option \*qBeamTimeout\*q \*q" value \*q +Determines the time span in seconds, that has to elapse before a beam is +considered defective, blanked-out and excluded from the coordinates +evaluation. +.RS 7 +.PP +.I Range: +"0" - "65535" +.PP +.I Default: +"30" (30 seconds) + + + + +.RE +.TP 7 +.BI "Option \*qTouchTime\*q \*q" value \*q +Determines the minimum time span in steps of 10ms for a valid +interruption. In order for an interruption to be +reported to the host computer as valid, it needs to remain at +the same spot for at least the time span declared here. +.RS 7 +.PP +.I Range: +"0" - "255" +.PP +.I Default: +"0" (=6,5 ms) + + +.RE +.TP 7 +.BI "Option \*qEnterCount\*q \*q" count \*q +Number of skipped "enter reports". Reports are sent approx. +every 20ms. +.RS 7 +.PP +.I Range: +"0" - "31" +.PP +.I Default: +"3" (3 skipped messages = 60ms) + + +.RE +.TP 7 +.BI "Option \*qDualCount\*q \*q" count \*q +Number of skipped "dual touch error". Reports are sent approx. +every 20ms. This option is only available for "ZPress" and +"ZPress Exit" modes. +.RS 7 +.PP +.I Range: +"0" - "31" +.PP +.I Default: +"2" (2 skipped messages = 40ms) + + +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__). +.SH AUTHORS +2000 - written by Citron GmbH (support@citron.de) Index: xc/programs/Xserver/hw/xfree86/input/citron/citron.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/citron/citron.h:1.1 --- /dev/null Mon Dec 18 14:31:35 2000 +++ xc/programs/Xserver/hw/xfree86/input/citron/citron.h Wed Nov 1 21:51:21 2000 @@ -0,0 +1,522 @@ +/* + * Copyright (c) 1998 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/citron/citron.h,v 1.1 2000/11/02 02:51:21 dawes Exp $ */ + +/* + * Based, in part, on code with the following copyright notice: + * + * Copyright 1999-2000 by Thomas Thanner, Citron GmbH, Germany. <support@citron.de> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and that + * the name of Thomas Thanner and Citron GmbH not be used in advertising or + * publicity pertaining to distribution of the software without specific, written + * prior permission. Thomas Thanner and Citron GmbH makes no representations about + * the suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * THOMAS THANNER AND CITRON GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL THOMAS THANNER OR CITRON GMBH BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef _citron_H_ +#define _citron_H_ + +/****************************************************************************** + * Definitions + * structs, typedefs, #defines, enums + *****************************************************************************/ + +/* CTS (Citron Touch Software) protocol constants */ +#define CTS_CTRLMIN 0x10 /* Lower end of the control character range */ +#define CTS_XON 0x11 /* Start serial transmission character */ +#define CTS_STX 0x12 /* Start of message delimiter */ +#define CTS_XOFF 0x13 /* Stop serial transmission character */ +#define CTS_ETX 0x14 /* End of message delimiter */ +#define CTS_NAK 0x15 /* Not Acknowledge, send by the IRT just before it resets itself */ +#define CTS_ESC 0x16 /* Escape character to encode non control characters with a value inside the control character range */ +#define CTS_CTRLMAX 0x16 /* Upper end of the control character range */ + +#define CTS_ENCODE 0x40 /* Use this constant to encode non control character with a value inside the control character range */ +#define CTS_DECODE (~0x40) /* Use this constant to decode previously encoded characters. These characters are marked by a leading CTS_ESC. */ + +#define CTS_MSG_MIN 0x18 /* First usable character for message and report identifiers */ +#define CTS_MSG_MAX 0x7F /* Last usable character for message and report identifiers */ + +#define CTS_DESIGNATOR_LEN 32 /* Length of the designator part in the HardwareRevision report */ +#define CTS_ASSY_LEN 16 /* Length of the ASSY part in the HardwareRevision report */ +#define CTS_OEMSTRING_LEN 256 /* Length of the OEM string */ +#define CTS_FPGA_LEN 28 /* Length of the FPGA version string */ +#define CTS_SENSORCOUNT_LEN 1 /* Length of sensorcount report */ + +#define CTS_MAX_HWASSY 32 /* Maximum number of hardware codeable assy numbers */ + +#define CTS_MAX_POLYEDGE 64 /* Maximum number of polygonal area edges */ + +#define CMD_REP_CONV 0x7f /* Use this bit mask to convert a command into a report identifier */ + +#define CTS_PACKET_SIZE (1+CTS_OEMSTRING_LEN) + +/* Area operating modes */ +#define AOM_OFF 0x00 /* No coordinate messages will be generated by this area */ +#define AOM_ENTER 0x01 /* Only the area entry point will be reported in a coordinate message */ +#define AOM_TRACK 0x02 /* Every movement inside the area will be reported in a coordinate message */ +#define AOM_CONT 0x03 /* If the area is touched, coordinate messages will be created in fixed time intervals */ + +/* Modification flags for the area operating mode */ +#define AOF_ADDEXIT 0x01 /* Exit messages will be generated for this area */ +#define AOF_ADDCOORD 0x02 /* The coordinate of the touch point will be reported in addition to the area number */ +#define AOF_ADDPRESS 0x04 /* Pressure messages will be generated for this area */ +#define AOF_PRESSALWAYS 0x08 /* This area requires a permanent pressure to generate coordinate messages */ +#define AOF_PRESSENTER 0x10 /* This area requires only pressure to generate the first coordinate message. */ +#define AOF_PRESSLOCAL 0x20 /* This area has a locally defined pressure sensitivity, If this flag is not set, the pressure sensivity of area0 is used. */ +#define AOF_EXTENDED 0x40 /* This area must be leaved, before any other area will generate coordinate messages */ +#define AOF_ACTIVE 0x80 /* This area is active. Only active areas will generate messages. */ + +/* group ClearArea command parameter values */ +#define CA_ALL 0x00 /* Clear all areas on all pages */ +#define CA_PAGE 0x01 /* Clear all areas of a certain page */ +#define CA_AREA 0x02 /* Clear a single area, however area0 cannot be cleared. area0 will only be reset to its power up default state. */ + +/* SetTransmission command parameter values */ +#define TM_TRANSMIT 0x01 /* Enable the transmission of messages (report will be transmitted always) */ +#define TM_NONE 0x00 /* Disable transmission of messages and disable the XON/XOFF protocol */ +#define TM_RXDFLOW 0x10 /* Enable the XON/XOFF protocol for the transmitter (IRT will send XON/XOFF to the host) */ +#define TM_TXDFLOW 0x20 /* Enable the XON/XOFF protocol for the receiver (host will sned XON/XOFF to the IRT) */ + +/* Sleep- and Doze-Mode command parameters */ +#define TS_QUIET 0x00 /* Disable the generation of TouchSaver messages */ +#define TS_ACTIMSG 0x01 /* Enable the generation of messages on sleep- or doze-mode activation */ +#define TS_PASIMSG 0x02 /* Enable the generation of messages on sleep- or doze-mode deactivation */ +#define TS_SETOUT 0x10 /* The /GP_OUT output of the IRT will reflect the sleep- or doze-mode state, if this flag is set. */ +#define TS_ACTIVE 0x80 /* This is a read only flag to decode the current sleep- or doze-mode state in SleepModeState and DozeModeState reports. */ + +/* SetDualTouching command parameters */ +#define DT_IGNORE 0x00 /* Multiple touches are ignored, no DualTouchError messages will be generated */ +#define DT_ERROR 0x01 /* Multiple touches will be reported by a DualTouchError message */ +#define DT_COORD 0x02 /* The coordinate of the second touch point will be reported in a separate coordinate message. More than 2 touch points will be reported by DualTouchError messages. */ + +/* SetOrigin command parameters */ +#define OR_TOPLEFT 0x00 /* The coordinate origin is in the top left corner of the touch */ +#define OR_TOPRIGHT 0x01 /* The coordinate origin is in the top right corner of the touch */ +#define OR_BOTTOMRIGHT 0x02 /* The coordinate origin is in the bottom right corner of the touch */ +#define OR_BOTTOMLEFT 0x03 /* The coordinate origin is in the bottom left corner of the touch */ + +/* GetSignalValues command parameters */ +#define GS_NOREPORT 0x00 /* Don't report the signal values */ +#define GS_SIGNAL 0x01 /* Report the beam values as used for coordinate generation */ +#define GS_REFERENCE 0x02 /* Report the reference beam values */ +#define GS_BROKEN 0x03 /* Report the results of the broken/not broken beam detection */ +#define GS_RESCAN 0x80 /* Add this flag to rescan the touch before generating the SignalValues report */ + +/* GetPressureValues command parameters */ +#define GP_NOREPORT 0x00 /* Don't report the pressure values */ +#define GP_SIGNAL 0x01 /* Report the signals of the active pressure sensors */ +#define GP_REFERENCE 0x02 /* Report the signals of the calibration sensors */ +#define GP_INTERNAL 0x04 /* Report the internal state of the pressure sensitive unit */ + +/* SetPort/GetPort command parameters */ +#define GP_OCOUT0 0x01 /* Get/Set the /OC_OUT0 port of the IRT */ +#define GP_BIJMP 0x02 /* Get the state of the BurnIn jumper on the IRT */ +#define GP_OCSSAVER 0x04 /* Get/Set the /OC_SSAVER port of the IRT */ +#define GP_OCIN0 0x08 /* Get the state of the /OC_IN0 port of the IRT */ + +/* GetRevisions command parameters */ +#define GR_SYSMGR 0x01 /* Get the version number of the System Manager module */ +#define GR_HARDWARE 0x02 /* Get the version number of the Hardware module */ +#define GR_PROCESS 0x04 /* Get the version number of the Process module */ +#define GR_PROTOCOL 0x08 /* Get the version number of the Protocol module */ +#define GR_HWPARAM 0x10 /* Get the version number of the Hardware Parameters module */ +#define GR_DESIGNATOR 0x20 /* Get the IRT designator and ASSY number */ +#define GR_BURNIN 0x40 /* Get the version number of the Burn-In module */ +#define GR_FPGA 0x80 /* Get the version number of the FPGA module */ + +/* GetErrors command parameters */ +#define GE_INITIAL 0x01 /* Report the errors detected during IRT startup */ +#define GE_DEFECTBEAMS 0x02 /* Report the beams that are marked defect and are therefore excluded from the coordinate calculations */ +#define GE_COMMUNICATION 0x04 /* Report communication errors on the serial link */ +#define GE_COMMAND 0x08 /* Report command errors (invalid parameters, unknown commands, ...) */ +#define GE_CLEAR 0x80 /* Add this flag to clear the errors after reporting */ + +/* GetHardware command parameters */ +#define GH_BEAMCOUNT 0x01 /* Report the number of x and y beams */ +#define GH_SENSORCOUNT 0x02 /* Report the number of pressure sensors */ +#define GH_PERIPHERALS 0x04 /* Report a bit vector that identifies all assembled peripherals on the IRT */ + +/* GetHWVersion command parameters */ +#define HV_SSNO 0x01 /* Report the silicon serial number */ +#define HV_ASSY 0x02 /* Report the hard wired assembly number */ +#define HV_FPGA 0x04 /* Report the FPGA version string */ + +/* InitialError decoding bit masks */ +#define IE_SMCHKSUM 0x00000001UL /* The system manager module has a checksum error */ +#define IE_SMINIT 0x00000002UL /* The system manager module reported an error during initialisation */ +#define IE_HWCHKSUM 0x00000004UL /* The hardware module has a checksum error */ +#define IE_HWINIT 0x00000008UL /* The hardware module reported an error during initialisation */ +#define IE_PCCHKSUM 0x00000010UL /* The process module has a checksum error */ +#define IE_PCINIT 0x00000020UL /* The process module reported an error during initialisation */ +#define IE_PTCHKSUM 0x00000040UL /* The protocol module has a checksum error */ +#define IE_PTINIT 0x00000080UL /* The protocol module reported an error during initialisation */ +#define IE_HW_BEAMS 0x00000100UL /* There were broken beams during hardware initialisation */ +#define IE_HW_PSU 0x00000200UL /* There pressure sensitive unit could not be initialised */ +#define IE_HW_CPU 0x00000400UL /* There was an error in the CPU core detected during startup */ +#define IE_HW_IRAM 0x00000800UL /* There was an error in the initial internal ram check */ +#define IE_HW_XRAM 0x00001000UL /* There was an error in the initial external ram check */ +#define IE_BICHK 0x00002000UL /* The burnin module has a checksum error */ +#define IE_BIINIT 0x00004000UL /* The burnin module reported an error during initialisation */ +#define IE_FPGACHK 0x00008000UL /* The fpga module has a checksum error */ +#define IE_HWPCHK 0x00010000UL /* The hardware parameter module has a checksum error */ + +/* CommunicationError decoding bit masks */ +#define CE_DC2GTDC4 0x00000001UL /* There were more CTS_STX received than CTS_ETX */ +#define CE_DC4GTDC2 0x00000002UL /* There were more CTS_ETX received than CTS_STX */ +#define CE_UNXNONCTRL 0x00000004UL /* Non control character received outside a CTS_STX/CTS_ETX sequence */ +#define CE_UNXCONTROL 0x00000008UL /* Unexpected control character received */ +#define CE_OVERFLOW 0x00000010UL /* The hardware receiver buffer had an overflow */ +#define CE_FRAMING 0x00000020UL /* There were characters with framing errors received */ +#define CE_PARITY 0x00000040UL /* There were characters with invalid parity received */ +#define CE_XOFFTO 0x00000080UL /* No XON was received within the defined timeout after a XOFF */ +#define CE_CMDOVER 0x00000100UL /* The command buffer had an overflow */ +#define CE_RCVROVER 0x00000200UL /* The receiver ring buffer had an overflow */ + +/* CommandError decoding bit masks */ +#define CE_UNKNOWN 0x00000001UL /* Unknown command received */ +#define CE_PARAMCNT 0x00000002UL /* Too much or too less parameters received */ +#define CE_RANGE 0x00000004UL /* One or more parameters were out of range */ + +/* Peripheral indentification bit masks */ +#define PERI_OCOUT0 0x00000001UL /* The /OC_OUT0 port is available */ +#define PERI_BURNIN 0x00000002UL /* The BurnIn jumper is available */ +#define PERI_GP_OUT 0x00000004UL /* The /GP_OUT port is available */ +#define PERI_OCPWM 0x00000008UL /* The /OC_PWM port is available */ +#define PERI_SPEAKER 0x00000010UL /* The speaker port is available */ +#define PERI_GP_IN 0x00000020UL /* The /GP_IN port is available */ +#define PERI_RUNLED 0x00000040UL /* The red blinking indication LED is available */ + +/* SaveSetup/ReadSetup command parameters */ +#define SUP_SERIAL 0x01 /* Save/Read the serial port setup */ +#define SUP_MACRO 0x02 /* Save/Read the macro definitions */ +#define SUP_AREAS 0x04 /* Save/Read the area definitions */ +#define SUP_PERI 0x08 /* Save/Read the peripheral settings */ +#define SUP_COORD 0x10 /* Save/Read the coordinate settings */ + +/* IRT initialisation modes for <f cts_Connect> */ + +#define MODE_A 0x7b /* Initialise the IRT to AFE-Mode A emulation */ +#define MODE_B 0x3c /* Initialise the IRT to Carroll emulation */ +#define MODE_C 0x6f /* Another entry point for Mode-D (for backwards compatibility) */ +#define MODE_D 0x81 /* Initialise the IRT to the CTS protocol */ + +/* Command is for the driver */ +#define DRIVCOMM 0x00 /* Command for driver */ + +/* Command Identifiers for the driver */ +#define D_SETCLICKMODE 0x00 +#define D_BEEP 0x01 +#define D_SETBEEP 0x02 + + +/* Message identifiers */ +#define R_DUALTOUCHERROR 0x18 /* Invalid multiple touches are detected */ +#define R_COORD 0x19 /* Regular coordinate report */ +#define R_EXIT 0x1a /* An area was leaved */ +#define R_PRESSURE 0x1b /* An area was pressed or released */ +#define PRESS_BELOW 0x00 /* Pressure below a certain threshold */ +#define PRESS_EXCEED 0x01 /* Pressure higher than a certain threshold */ + +#define R_SLEEPMODE 0x1c /* The sleep-mode was activated or deactivated */ +#define R_DOZEMODE 0x1d /* The doze-mode was activated or deactivated */ + +/* Special report identifiers */ +#define R_POLYAREADEF 0x2a +#define R_IDLE 0x34 +#define R_SCANTIMING 0x56 + +/* Command identifiers */ +#define C_SOFTRESET 0x80 +#define C_RESETCTS 0x81 +#define C_SAVESETUP 0x83 +#define C_DESTROYSETUP 0x84 +#define C_SETSCANTIMING 0x85 +#define C_GETSCANTIMING 0x86 + +#define C_CLEARAREA 0xa0 +#define C_DEFINEAREA 0xa1 +#define C_GETAREADEF 0xa2 +#define C_GETAREAPAGE 0xa3 +#define C_GETFREEAREASPACE 0xa4 +#define C_SELECTAREAPAGE 0xa5 +#define C_SETAREASTATE 0xa6 +#define C_SETAREAMODE 0xa7 +#define C_SETAREAFLAGS 0xa8 +#define C_SETAREAPRESSURE 0xa9 +#define C_DEFINEPOLYAREA 0xaa + +#define C_GETERRORS 0xb0 +#define C_GETHARDWARE 0xb1 +#define C_GETREVISIONS 0xb2 +#define C_GETSETUP 0xb3 +#define C_GETSINGLEMESSAGE 0xb4 +#define C_GETSINGLESCAN 0xb5 +#define C_GETSIGNALVALUES 0xb6 +#define C_GETPRESSUREVALUES 0xb7 +#define C_GETOEMSTRING 0xb8 +#define C_GETHWVERSIONS 0xb9 +#define C_BIGETFIRSTSESSION 0xba +#define C_BIGETNEXTSESSION 0xbb +#define C_BIGETRECORD 0xbc +#define C_BIERASEDATA 0xbd +#define C_BIGETTICKUNIT 0xbe + +#define C_GETBEAMMINMAX 0xc0 +#define C_GETBEAMTIMEOUT 0xc1 +#define C_GETCONTTIME 0xc2 +#define C_GETDUALTOUCHING 0xc3 +#define C_GETORIGIN 0xc4 +#define C_GETRESOLUTION 0xc5 +#define C_GETSCANNING 0xc6 +#define C_GETTRANSMISSION 0xc7 +#define C_SETBEAMMINMAX 0xc8 +#define C_SETBEAMTIMEOUT 0xc9 +#define C_SETCONTTIME 0xca +#define C_SETDUALTOUCHING 0xcb +#define C_SETORIGIN 0xcc +#define C_SETRESOLUTION 0xcd +#define C_SETSCANNING 0xce +#define C_SETTRANSMISSION 0xcf + +#define C_GETTOUCHTIME 0xd0 +#define C_SETTOUCHTIME 0xd1 + +#define C_CLEARMACRO 0xe0 +#define C_ENDMACRORECORD 0xe1 +#define C_EXECMACRO 0xe2 +#define C_GETFREEMACROSPACE 0xe3 +#define C_STARTMACRORECORD 0xe5 + +#define C_GETPORT 0xf0 +#define C_GETPWM 0xf1 +#define C_GETSOUND 0xf2 +#define C_GETSLEEPMODE 0xf3 +#define C_SETPORT 0xf4 +#define C_SETPWM 0xf5 +#define C_SETSOUND 0xf6 +#define C_SETSLEEPMODE 0xf7 +#define C_GETDOZEMODE 0xf8 +#define C_SETDOZEMODE 0xf9 + +/* touch states */ +#define CIT_TOUCHED 0x01 +#define CIT_PRESSED 0x02 +#define CIT_BUTTON 0x04 + +/* click modes */ +#define CM_ENTER 1 +#define CM_DUAL 2 +#define CM_DUALEXIT 3 +#define CM_ZPRESS 4 +#define CM_ZPRESSEXIT 5 + +#define MAX_DUAL_TOUCH_COUNT 2 + +#define NO_CLICK_MODE 255 /* no click mode set in xf86Config */ + +/* command structure for Feedback Functions */ +typedef struct { + unsigned char par[3]; /* byte parameter */ + char packet; /* packet number 00 - 7F */ +} COMMAND; + + +/* Data exchange with driver (Driver Data Structure) */ +#define MAX_BYTES_TO_TRANSFER 0x20 +#define LAST_PACKET 0x7f + +typedef struct { + short curbyte; /* current byte number */ + short numbytes; /* number of bytes to transmit */ + short packet; /* packet number */ + unsigned char data[MAX_BYTES_TO_TRANSFER]; /* pointer to data area */ +} CitronDDS; + + + + +/***************************************************************************** + * X-Header + ****************************************************************************/ + +#define X_CITOUCH " CiTouch: " +const char *CI_PROBED = {"(--)" X_CITOUCH}; /* Value was probed */ +const char *CI_CONFIG = {"(**)" X_CITOUCH}; /* Value was given in the config file */ +const char *CI_DEFAULT = {"(==)" X_CITOUCH}; /* Value is a default */ +const char *CI_CMDLINE = {"(++)" X_CITOUCH}; /* Value was given on the command line */ +const char *CI_NOTICE = {"(!!)" X_CITOUCH}; /* Notice */ +const char *CI_INFO = {"(II)" X_CITOUCH}; /* Informational message */ +const char *CI_WARNING = {"(WW)" X_CITOUCH}; /* Warning message */ +const char *CI_ERROR = {"(EE)" X_CITOUCH}; /* Error message */ +const char *CI_UNKNOWN = {"(?\?)" X_CITOUCH}; /* Unknown message */ + + + +/***************************************************************************** + * macros + ****************************************************************************/ +#define millisleep(ms) xf86usleep((ms) * 1000) + +#define HIBYTE(x) ( (unsigned char) ( (x) >> 8 ) ) +#define LOBYTE(x) ( (unsigned char) ( (x) & 0xff ) ) + + +/***************************************************************************** + * typedefs + ****************************************************************************/ +typedef enum +{ + cit_idle, cit_getID, cit_collect, cit_escape +} +cit_State; /* Citron Infrared Touch Driver State */ + +typedef struct _cit_privateRec +{ + int min_x; /* Minimum x reported by calibration */ + int max_x; /* Maximum x */ + int min_y; /* Minimum y reported by calibration */ + int max_y; /* Maximum y */ + int button_threshold; /* Z > button threshold = button click */ + int axes; + int dual_touch_count; /* counter for dual touch error events */ + int click_mode; /* one of the CM_ constants */ + int button_number; /* which button to report */ + int reporting_mode; /* TS_Raw or TS_Scaled */ + int screen_num; /* Screen associated with the device */ + int screen_width; /* Width of the associated X screen */ + int screen_height; /* Height of the screen */ + int packeti; /* index into packet */ + int raw_x; /* Raw Coordinates */ + int raw_y; + int sleep_mode; /* sleep mode: 0x00=no message, 0x01=m at activation, 0x02=m at deactivation, */ + /* 0x03= message at act. + deact., 0x10= GP_OUT set */ + int sleep_time_act; /* time until touchsaver gets activate */ + int sleep_time_scan; /* time interval between two scans */ + int pwm_sleep; /* PWM duty cycle during touch saver mode */ + int pwm_active; /* PWM duty cycle during regular operation */ + int state; +/* additional parameters */ + int last_x; /* last cooked data */ + int last_y; + int doze_mode; /* doze mode: 0x00=no message, 0x01=m at activation, 0x02=m at deactivation, */ + /* 0x03= message at act. + deact., 0x10= GP_OUT set */ + int doze_time_act; /* time until touchsaver gets activate */ + int doze_time_scan; /* time interval between scans */ + int origin; /* Coordinates origin */ + int delta_x; /* Delta x - if coordinate changed less than delta x no motion event */ + int delta_y; + int beep; /* 0= no beep, 1=beep enabled */ + int press_vol; /* volume of beep (press event) */ + int press_pitch; /* pitch of beep (press event) */ + int press_dur; /* length of beep in 10ms (press event) */ + int rel_vol; /* volume of beep (release event) */ + int rel_pitch; /* pitch of beep (release event) */ + int rel_dur; /* length of beep in 10ms (release event) */ + int beam_timeout; /* Beam timeout 0= no beam timeout */ + int touch_time; /* minimum time span for a valid interruption */ + int enter_touched; /* button is down due to an enter event */ + int enter_count; /* number of jumed coord reports before a ButtonPress event is sent */ + int max_dual_count; /* number of jumed dualtouch error reports before a ButtonPress event is sent */ + int dual_flg; /* Flag set if dualtouch error report is received , reset by counter */ + int raw_min_x; /* min x,y max x,y value accumulated over the whole session */ + int query_state; /* test if query was already started */ + int raw_max_x; + int raw_min_y; + int raw_max_y; + int pressure_sensors; /* number of pressure sensors */ + OsTimerPtr timer_ptr; /* Timer for general purposes */ + CARD32 timer_val1; /* Timer 1st delay */ + CARD32 timer_val2; /* Timer second delay */ + OsTimerCallback timer_callback; /* timer callback routine */ + int fake_exit; /* tell the ReadInput function there is a exit message (from timer) */ +/* end additional parameters */ + LocalDevicePtr local; /* Pointer to local device */ + Bool button_down; /* is the "button" currently down */ + Bool proximity; + cit_State lex_mode; + XISBuffer *buffer; + unsigned char packet[CTS_PACKET_SIZE]; /* packet being/just read */ + CitronDDS dds; /* Structure for Byte transfer to the driver via LedFeedbackControl */ +} +cit_PrivateRec, *cit_PrivatePtr; + +/****************************************************************************** + * Declarations + *****************************************************************************/ +/*extern void ModuleInit (pointer *, INT32 *);*/ +static MODULESETUPPROTO (SetupProc); +static void TearDownProc (pointer p); +/*static void *SetupProc (XF86OptionPtr, int *, int *);*/ +static Bool DeviceControl (DeviceIntPtr def, int mode); +static Bool DeviceOn (DeviceIntPtr); +static Bool DeviceOff (DeviceIntPtr); +static Bool DeviceClose (DeviceIntPtr); +static Bool DeviceInit (DeviceIntPtr); +static void ReadInput (LocalDevicePtr); +static int ControlProc (LocalDevicePtr, xDeviceCtl *); +static void CloseProc (LocalDevicePtr); +static int SwitchMode (ClientPtr, DeviceIntPtr, int); +static Bool ConvertProc (LocalDevicePtr, int, int, int, int, int, int, int, int, int *, int *); +static Bool QueryHardware (LocalDevicePtr, int *, int *); +static Bool cit_GetPacket (cit_PrivatePtr); +static void cit_Flush(XISBuffer *); +static void cit_SendCommand(XISBuffer *, unsigned char, int, ...); +static Bool cit_GetInitialErrors(cit_PrivatePtr); +static Bool cit_GetDefectiveBeams(cit_PrivatePtr); +static Bool cit_GetDesignator(cit_PrivatePtr); +static Bool cit_GetPressureSensors(cit_PrivatePtr); +static Bool cit_GetRevision(cit_PrivatePtr, int); +static void cit_ProcessPacket(cit_PrivatePtr); +static void cit_Beep(cit_PrivatePtr priv, int press); +#ifdef CIT_TIM +static void cit_StartTimer(cit_PrivatePtr priv); +static void cit_CloseTimer(cit_PrivatePtr priv); +static CARD32 cit_DualTouchTimer(OsTimerPtr timer, CARD32 now, pointer arg); +#endif + + + +/* + * DO NOT PUT ANYTHING AFTER THIS ENDIF + */ +#endif Index: xc/programs/Xserver/hw/xfree86/input/digitaledge/DigitalEdge.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/digitaledge/DigitalEdge.c:1.1 --- /dev/null Mon Dec 18 14:31:36 2000 +++ xc/programs/Xserver/hw/xfree86/input/digitaledge/DigitalEdge.c Fri Aug 11 15:10:41 2000 @@ -0,0 +1,1489 @@ +/* + * Copyright 1996 by Steven Lang <tiger@tyger.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Steven Lang not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. Steven Lang makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * STEVEN LANG DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL STEVEN LANG BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTIONS, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Steve Harris <steve@totl.net>, 2000-02-23 + * Southampton, UK + * + * Based on the xf86Summa driver, exensively hacked. Most of the bad + * indenting is not my fault, dammit! + * + * Probably buggy as hell, no idea what the initialisation strings are, + * no idea how to ack it. If the tablet stops responding power cycle it. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/digitaledge/DigitalEdge.c,v 1.1 2000/08/11 19:10:41 dawes Exp $ */ + +#include <xf86Version.h> + +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(3,9,0,0,0) +#define XFREE86_V4 1 +#endif + +#ifdef XFREE86_V4 +/* post 3.9 headers */ + +#ifndef XFree86LOADER +#include <unistd.h> +#include <errno.h> +#endif + +#include <misc.h> +#include <xf86.h> +#define NEED_XF86_TYPES +#if !defined(DGUX) +#include <xf86_ansic.h> +#include <xisb.h> +#endif +#include <xf86_OSproc.h> +#include <xf86Xinput.h> +#include <exevents.h> /* Needed for InitValuator/Proximity stuff */ +#include <keysym.h> +#include <mipointer.h> + +#ifdef XFree86LOADER +#include <xf86Module.h> +#endif + +#undef memset +#define memset xf86memset +#undef sleep +#define sleep(t) xf86WaitForInput(-1, 1000 * (t)) +#define wait_for_fd(fd) xf86WaitForInput((fd), 1000) +#define tcflush(fd, n) xf86FlushInput((fd)) +#undef read +#define read(a,b,c) xf86ReadSerial((a),(b),(c)) +#undef write +#define write(a,b,c) xf86WriteSerial((a),(char*)(b),(c)) +#undef close +#define close(a) xf86CloseSerial((a)) +#define XCONFIG_PROBED "(==)" +#define XCONFIG_GIVEN "(**)" +#define xf86Verbose 1 +#undef PRIVATE +#define PRIVATE(x) XI_PRIVATE(x) + +/* + * Be sure to set vmin appropriately for your device's protocol. You want to + * read a full packet before returning + */ + +static const char *default_options[] = +{ + "BaudRate", "9600", + "DataBits", "8", + "StopBits", "1", + "Parity", "Odd", + "FlowControl", "Xoff", + "VTime", "10", + "VMin", "1", + NULL +}; + +static InputDriverPtr dedgeDrv; + +#else /* pre 3.9 headers */ + +#include "Xos.h" +#include <signal.h> +#include <stdio.h> + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "XI.h" +#include "XIproto.h" + +#if defined(sun) && !defined(i386) +#define POSIX_TTY +#include <errno.h> +#include <termio.h> +#include <fcntl.h> +#include <ctype.h> + +#include "extio.h" +#else +#include "compiler.h" + +#ifdef XFree86LOADER +#include "xf86_libc.h" +#endif +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" +#include "xf86Xinput.h" +#include "atKeynames.h" +#include "xf86Version.h" +#endif + +#if !defined(sun) || defined(i386) +#include "osdep.h" +#include "exevents.h" + +#include "extnsionst.h" +#include "extinit.h" +#endif + +#if defined(__QNX__) || defined(__QNXNTO__) +#define POSIX_TTY +#endif +#endif /* pre 3.9 headers */ + +/* +** Debugging macros +*/ +#ifdef DBG +#undef DBG +#endif +#ifdef DEBUG +#undef DEBUG +#endif + +static int debug_level = 10; +#define DEBUG 1 +#if DEBUG +#define DBG(lvl, f) {if ((lvl) <= debug_level) f;} +#else +#define DBG(lvl, f) +#endif + +/* +** Device records +*/ +#define ABSOLUTE_FLAG 1 +#define STYLUS_FLAG 2 +#define COMPATIBLE_FLAG 4 + +typedef struct { + char *dedgeDevice; /* device file name */ + int dedgeInc; /* increment between transmits */ + int dedgeButTrans; /* button translation flags */ + int dedgeOldX; /* previous X position */ + int dedgeOldY; /* previous Y position */ + int dedgeOldProximity; /* previous proximity */ + int dedgeOldPush; /* previous buttons state */ + int dedgeOldBarrel; /* previous buttons state */ + int dedgeOldPressure; /* previous pen pressure */ + int dedgeMaxX; /* max X value */ + int dedgeMaxY; /* max Y value */ + int dedgeXSize; /* active area X size */ + int dedgeXOffset; /* active area X offset */ + int dedgeYSize; /* active area Y size */ + int dedgeYOffset; /* active area Y offset */ + int dedgeRes; /* resolution in lines per inch */ + int dedgeClickThresh; /* Click threshold in arbitary units */ + int flags; /* various flags */ + int dedgeIndex; /* number of bytes read */ + unsigned char dedgeData[5]; /* data read on the device */ +} DigitalEdgeDeviceRec, *DigitalEdgeDevicePtr; + +/* +** Configuration data +*/ +#define DEDGE_SECTION_NAME "DigitalEdge" + +#ifndef XFREE86_V4 + +#define PORT 1 +#define DEVICENAME 2 +#define THE_MODE 3 +#define CURSOR 4 +#define INCREMENT 5 +#define BORDER 6 +#define DEBUG_LEVEL 7 +#define HISTORY_SIZE 8 +#define ALWAYS_CORE 9 +#define ACTIVE_AREA 10 +#define ACTIVE_OFFSET 11 +#define COMPATIBLE 12 +#define CLICK_THRESHOLD 13 + +#if !defined(sun) || defined(i386) +static SymTabRec SumTab[] = { + {ENDSUBSECTION, "endsubsection"}, + {PORT, "port"}, + {DEVICENAME, "devicename"}, + {THE_MODE, "mode"}, + {CURSOR, "cursor"}, + {INCREMENT, "increment"}, + {BORDER, "border"}, + {DEBUG_LEVEL, "debuglevel"}, + {HISTORY_SIZE, "historysize"}, + {ALWAYS_CORE, "alwayscore"}, + {ACTIVE_AREA, "activearea"}, + {ACTIVE_OFFSET, "activeoffset"}, + {COMPATIBLE, "compatible"}, + {CLICK_THRESHOLD, "clickthreshold"}, + {-1, ""} +}; + +#define RELATIVE 1 +#define ABSOLUTE 2 + +static SymTabRec SumModeTabRec[] = { + {RELATIVE, "relative"}, + {ABSOLUTE, "absolute"}, + {-1, ""} +}; + +#define PUCK 1 +#define STYLUS 2 + +static SymTabRec SumPointTabRec[] = { + {PUCK, "puck"}, + {STYLUS, "stylus"}, + {-1, ""} +}; + +#endif +#endif /* Pre 3.9 headers */ + +/* +** Contants and macro +*/ +#define BUFFER_SIZE 256 /* size of reception buffer */ +#define XI_NAME "DIGITALEDGE" /* X device name for the stylus */ + +#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) + +#define SS_TABID0 "0" /* Tablet ID 0 */ +#define SS_FIRMID "z?" /* Request firmware ID string */ +#define SS_CONFIG "a" /* Send configuration (max coords) */ + +#define SS_ABSOLUTE 'F' /* Absolute mode */ +#define SS_RELATIVE 'E' /* Relative mode */ + +#define SS_UPPER_ORIGIN "b" /* Origin upper left */ +#define SS_500LPI "h" /* 500 lines per inch */ + +#define SS_PROMPT_MODE "B" /* Prompt mode */ +#define SS_STREAM_MODE "@" /* Stream mode */ +#define SS_INCREMENT 'I' /* Set increment */ +#define SS_BINARY_FMT "zb" /* Binary reporting */ + +#define SS_PROMPT "P" /* Prompt for current position */ + +static const char *ss_initstr = + SS_TABID0 SS_UPPER_ORIGIN SS_BINARY_FMT SS_STREAM_MODE; + +#define PHASING_BIT 0x80 +#define PROXIMITY_BIT 0x01 +#define TABID_BIT 0x20 +#define XSIGN_BIT 0x10 +#define YSIGN_BIT 0x08 +#define BUTTON_BITS 0x02 +#define COORD_BITS 0x7f + +/* +** External declarations +*/ + +#ifndef XFREE86_V4 + +#if defined(sun) && !defined(i386) +#define ENQUEUE suneqEnqueue +#else +#define ENQUEUE xf86eqEnqueue + +extern void xf86eqEnqueue( +#if NeedFunctionPrototypes + xEventPtr /*e */ +#endif + ); +#endif + +extern void miPointerDeltaCursor( +#if NeedFunctionPrototypes + int /*dx */ , + int /*dy */ , + unsigned long /*time */ +#endif + ); + +#if !defined(sun) || defined(i386) +/* +** xf86SumConfig +** Reads the DigitalEdge section from the XF86Config file +*/ +static Bool +xf86SumConfig(LocalDevicePtr * array, int inx, int max, LexPtr val) +{ + LocalDevicePtr dev = array[inx]; + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) (dev->private); + int token; + int mtoken; + + DBG(1, ErrorF("xf86SumConfig\n")); + + while ((token = xf86GetToken(SumTab)) != ENDSUBSECTION) { + switch (token) { + case DEVICENAME: + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Option string expected"); + else { + dev->name = strdup(val->str); + if (xf86Verbose) + ErrorF("%s DigitalEdge X device name is %s\n", + XCONFIG_GIVEN, dev->name); + } + break; + + case PORT: + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Option string expected"); + else { + priv->dedgeDevice = strdup(val->str); + if (xf86Verbose) + ErrorF("%s DigitalEdge port is %s\n", XCONFIG_GIVEN, + priv->dedgeDevice); + } + break; + + case THE_MODE: + mtoken = xf86GetToken(SumModeTabRec); + if ((mtoken == EOF) || (mtoken == STRING) + || (mtoken == + NUMBER)) xf86ConfigError("Mode type token expected"); + else { + switch (mtoken) { + case ABSOLUTE: + priv->flags |= ABSOLUTE_FLAG; + break; + case RELATIVE: + priv->flags &= ~ABSOLUTE_FLAG; + break; + default: + xf86ConfigError("Illegal Mode type"); + break; + } + } + break; + + case CURSOR: + mtoken = xf86GetToken(SumPointTabRec); + if ((mtoken == EOF) || (mtoken == STRING) + || (mtoken == + NUMBER)) xf86ConfigError("Cursor token expected"); + else { + switch (mtoken) { + case STYLUS: + priv->flags |= STYLUS_FLAG; + break; + case PUCK: + priv->flags &= ~STYLUS_FLAG; + break; + default: + xf86ConfigError("Illegal cursor type"); + break; + } + } + break; + + case INCREMENT: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeInc = val->num; + if (xf86Verbose) + ErrorF("%s DigitalEdge increment value is %d\n", + XCONFIG_GIVEN, priv->dedgeInc); + break; + + case CLICK_THRESHOLD: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeClickThresh = val->num; + if (xf86Verbose) + ErrorF("%s DigitalEdge click threshold is %d\n", + XCONFIG_GIVEN, priv->dedgeClickThresh); + break; + + case DEBUG_LEVEL: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + debug_level = val->num; + if (xf86Verbose) { +#if DEBUG + ErrorF("%s DigitalEdge debug level sets to %d\n", + XCONFIG_GIVEN, debug_level); +#else + ErrorF("%s DigitalEdge debug level not sets to %d because" + " debugging is not compiled\n", XCONFIG_GIVEN, + debug_level); +#endif + } + break; + + case HISTORY_SIZE: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + dev->history_size = val->num; + if (xf86Verbose) + ErrorF("%s DigitalEdge Motion history size is %d\n", + XCONFIG_GIVEN, dev->history_size); + break; + case COMPATIBLE: + priv->flags |= COMPATIBLE_FLAG; + if (xf86Verbose) + ErrorF + ("DigitalEdge compatible - will not query firmware ID\n"); + break; + + case ALWAYS_CORE: + xf86AlwaysCore(dev, TRUE); + if (xf86Verbose) + ErrorF("%s DigitalEdge device always stays core pointer\n", + XCONFIG_GIVEN); + break; + + case ACTIVE_AREA: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeXSize = val->num; + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeYSize = val->num; + ErrorF("%s DigitalEdge active area set to %d.%1dx%d.%1d" + " inches\n", XCONFIG_GIVEN, priv->dedgeXSize / 10, + priv->dedgeXSize % 10, priv->dedgeYSize / 10, + priv->dedgeYSize % 10); + break; + + case ACTIVE_OFFSET: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeXOffset = val->num; + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Option number expected"); + priv->dedgeYOffset = val->num; + if (xf86Verbose) + ErrorF + ("%s DigitalEdge active area offset set to %d.%1dx%d.%1d" + " inches\n", XCONFIG_GIVEN, priv->dedgeXOffset / 10, + priv->dedgeXOffset % 10, priv->dedgeYOffset / 10, + priv->dedgeYOffset % 10); + break; + + case EOF: + FatalError("Unexpected EOF (missing EndSubSection)"); + break; + + default: + xf86ConfigError("DigitalEdge subsection keyword expected"); + break; + } + } + + DBG(1, ErrorF("xf86SumConfig name=%s\n", priv->dedgeDevice)); + + return Success; +} +#endif +#endif /* pre 3.9 headers */ + +/* +** xf86SumConvert +** Convert valuators to X and Y. +*/ +static Bool +xf86SumConvert(LocalDevicePtr local, + int first, + int num, + int v0, + int v1, int v2, int v3, int v4, int v5, int *x, int *y) +{ + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private; + + if (first != 0 || num == 1) + return FALSE; + + *x = v0 * screenInfo.screens[0]->width / 2430; + *y = v1 * screenInfo.screens[0]->height / 1950; + + DBG(6, ErrorF("Adjusted coords x=%d y=%d\n", *x, *y)); + + return TRUE; +} + +/* +** xf86SumReverseConvert +** Convert X and Y to valuators. +*/ +static Bool +xf86SumReverseConvert(LocalDevicePtr local, int x, int y, int *valuators) +{ + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private; + + valuators[0] = ((x * 2430) / screenInfo.screens[0]->width) + priv->dedgeXOffset; + valuators[1] = ((y * 1950) / screenInfo.screens[0]->height) + priv->dedgeYOffset; + + + DBG(6, + ErrorF("Adjusted valuators v0=%d v1=%d\n", valuators[0], + valuators[1])); + + return TRUE; +} + +/* +** xf86SumReadInput +** Reads from the DigitalEdge and posts any new events to the server. +*/ +static void xf86SumReadInput(LocalDevicePtr local) +{ + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private; + int len, loop; + int is_absolute; + int x, y, push, barrel, prox, pressure; + DeviceIntPtr device; + unsigned char buffer[BUFFER_SIZE]; + + DBG(7, ErrorF("xf86SumReadInput BEGIN device=%s fd=%d\n", + priv->dedgeDevice, local->fd)); + + SYSCALL(len = read(local->fd, buffer, sizeof(buffer))); + + if (len <= 0) { + Error("error reading DigitalEdge device"); + return; + } + + for (loop = 0; loop < len; loop++) { + +/* Format of 5 bytes data packet for DigitalEdge Tablets + Byte 1 + bit 7 Phasing bit always 1 + bit 6 Proximity bit + bit 5 Tablet ID + bit 4 X sign (Always 1 for absolute) + bit 3 Y sign (Always 1 for absolute) + bit 2-0 Button status + + Byte 2 + bit 7 Always 0 + bits 6-0 = X6 - X0 + + Byte 3 (Absolute mode only) + bit 7 Always 0 + bits 6-0 = X13 - X7 + + Byte 4 + bit 7 Always 0 + bits 6-0 = Y6 - Y0 + + Byte 5 (Absolute mode only) + bit 7 Always 0 + bits 6-0 = Y13 - Y7 +*/ + + if ((priv->dedgeIndex == 0) && !(buffer[loop] & PHASING_BIT)) { /* magic bit is not OK */ + DBG(6, + ErrorF("xf86SumReadInput bad magic number 0x%x\n", + buffer[loop]));; + continue; + } + + priv->dedgeData[priv->dedgeIndex++] = buffer[loop]; + + if (priv->dedgeIndex == 7) { +/* the packet is OK */ +/* reset char count for next read */ + priv->dedgeIndex = 0; + + if (priv->flags & ABSOLUTE_FLAG) { + x = (int) priv->dedgeData[1] + ((int) priv->dedgeData[2] << 7); + y = 1950 - ((int) priv->dedgeData[3] + ((int) priv->dedgeData[4] << 7)); + } else { + x = + priv->dedgeData[0] & XSIGN_BIT ? priv-> + dedgeData[1] : -priv->dedgeData[1]; + y = + priv->dedgeData[0] & YSIGN_BIT ? priv-> + dedgeData[2] : -priv->dedgeData[2]; + } + prox = (priv->dedgeData[0] & PROXIMITY_BIT) ? 1 : 0; + + pressure = priv->dedgeData[6] + (priv->dedgeData[5] >> 4) * 128; + push = pressure > priv->dedgeClickThresh?1:0; + if ((priv->dedgeOldPressure) < priv->dedgeClickThresh && pressure == 1022) { + push = 0; + } else { + priv->dedgeOldPressure = pressure; + } + if (priv->dedgeData[0] & BUTTON_BITS) { + barrel = 1; + } else { + barrel = 0; + } + + device = local->dev; + + DBG(6, ErrorF("prox=%s\tx=%d\ty=%d\tbarrel=%d\tpressure=%d\n", + prox ? "true" : "false", x, y, barrel, + pressure)); + + is_absolute = (priv->flags & ABSOLUTE_FLAG); + +/* coordonates are ready we can send events */ + if (prox) { + if (!(priv->dedgeOldProximity)) + xf86PostProximityEvent(device, 1, 0, 3, x, y, pressure); + + if ( + (is_absolute + && ((priv->dedgeOldX != x) || (priv->dedgeOldY != y))) + || (!is_absolute && (x || y))) { + if (is_absolute || priv->dedgeOldProximity) { + xf86PostMotionEvent(device, is_absolute, 0, 3, x, + y, pressure); + } + } + if (priv->dedgeOldPush != push) { + int delta; + + delta = push - priv->dedgeOldPush; + + if (priv->dedgeOldPush != push) { + DBG(6, + ErrorF("xf86SumReadInput push delta=%d\n", delta)); + xf86PostButtonEvent(device, is_absolute, 1, + (delta > 0), 0, 3, x, y, pressure); + } + } + + if (priv->dedgeOldBarrel != barrel) { + int delta; + + delta = barrel - priv->dedgeOldBarrel; + + if (priv->dedgeOldBarrel != barrel) { + DBG(6, + ErrorF("xf86SumReadInput barrel delta=%d\n", delta)); + xf86PostButtonEvent(device, is_absolute, 2, + (delta > 0), 0, 3, x, y, pressure); + } + } + + priv->dedgeOldPush = push; + priv->dedgeOldBarrel = barrel; + priv->dedgeOldX = x; + priv->dedgeOldY = y; + priv->dedgeOldProximity = prox; + + } else { /* !PROXIMITY */ +/* Any changes in buttons are ignored when !proximity */ + if (priv->dedgeOldProximity) + xf86PostProximityEvent(device, 0, 0, 3, x, y, pressure); + priv->dedgeOldProximity = 0; + } + } + } + DBG(7, ErrorF("xf86Sum(priv->dedgeData[0] & BUTTON_BITS)iReadInput END device=0x%x priv=0x%x\n", + local->dev, priv)); +} + +/* +** xf86SumControlProc +** It really does do something. Honest! +*/ +static void xf86SumControlProc(DeviceIntPtr device, PtrCtrl * ctrl) +{ + DBG(2, ErrorF("xf86SumControlProc\n")); +} + +/* +** xf86SumWriteAndRead +** Write data, and get the response. +*/ +static char *xf86SumWriteAndRead(int fd, char *data, char *buffer, int len, + int cr_term) +{ + int err, numread = 0; +#ifndef XFREE86_V4 + fd_set readfds; + struct timeval timeout; +#endif + + SYSCALL(err = write(fd, data, strlen(data))); + if (err == -1) { + Error("DigitalEdge write"); + return NULL; + } +#ifndef XFREE86_V4 + FD_ZERO(&readfds); + FD_SET(fd, &readfds); +#endif + while (numread < len) { +#ifndef XFREE86_V4 + timeout.tv_sec = 0; + timeout.tv_usec = 200000; + + SYSCALL(err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout)); +#else + err = xf86WaitForInput(fd, 1000); +#endif + if (err == -1) { + Error("DigitalEdge select"); + return NULL; + } + if (!err) { + ErrorF + ("Timeout while reading DigitalEdge tablet. No tablet connected ???\n"); + return NULL; + } + + SYSCALL(err = read(fd, buffer + numread++, 1)); + if (err == -1) { + Error("DigitalEdge read"); + return NULL; + } + if (!err) { + --numread; + break; + } + if (cr_term && buffer[numread - 1] == '\r') { + buffer[numread - 1] = 0; + break; + } + } + buffer[numread] = 0; + return buffer; +} + +/* +** xf86SumOpen +** Open and initialize the tablet, as well as probe for any needed data. +*/ +static Bool xf86SumOpen(LocalDevicePtr local) +{ +#ifndef XFREE86_V4 + struct termios termios_tty; + struct timeval timeout; +#endif + char buffer[256]; + int err, idx; + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private; + + DBG(1, ErrorF("opening %s\n", priv->dedgeDevice)); + +#ifdef XFREE86_V4 + local->fd = xf86OpenSerial(local->options); +#else + SYSCALL(local->fd = open(priv->dedgeDevice, O_RDWR | O_NDELAY, 0)); +#endif + if (local->fd == -1) { + Error(priv->dedgeDevice); + return !Success; + } + DBG(2, ErrorF("%s opened as fd %d\n", priv->dedgeDevice, local->fd)); + +#ifndef XFREE86_V4 +#ifdef POSIX_TTY + err = tcgetattr(local->fd, &termios_tty); + if (err == -1) { + Error("DigitalEdge tcgetattr"); + return !Success; + } + termios_tty.c_iflag = IXOFF; + termios_tty.c_cflag = + B9600 | CS8 | CREAD | CLOCAL | HUPCL | PARENB | PARODD; + termios_tty.c_lflag = 0; + +/* I wonder what these all do, anyway */ + termios_tty.c_cc[VINTR] = 0; + termios_tty.c_cc[VQUIT] = 0; + termios_tty.c_cc[VERASE] = 0; +#ifdef VWERASE + termios_tty.c_cc[VWERASE] = 0; +#endif +#ifdef VREPRINT + termios_tty.c_cc[VREPRINT] = 0; +#endif + termios_tty.c_cc[VKILL] = 0; + termios_tty.c_cc[VEOF] = 0; + termios_tty.c_cc[VEOL] = 0; +#ifdef VEOL2 + termios_tty.c_cc[VEOL2] = 0; +#endif + termios_tty.c_cc[VSUSP] = 0; +#ifdef VDISCARD + termios_tty.c_cc[VDISCARD] = 0; +#endif +#ifdef VLNEXT + termios_tty.c_cc[VLNEXT] = 0; +#endif + + termios_tty.c_cc[VMIN] = 1; + termios_tty.c_cc[VTIME] = 10; + + err = tcsetattr(local->fd, TCSANOW, &termios_tty); + if (err == -1) { + Error("DigitalEdge tcsetattr TCSANOW"); + return !Success; + } +#else + Code for someone + else + to write to handle OSs without POSIX tty functions +#endif +#endif + DBG(1, ErrorF("initializing DigitalEdge tablet\n")); + +/* Send reset (NULL) to the tablet */ + SYSCALL(err = write(local->fd, "", 1)); + if (err == -1) { + Error("DigitalEdge write"); + return !Success; + } + +/* wait 200 mSecs, just in case */ +#ifndef XFREE86_V4 + timeout.tv_sec = 0; + timeout.tv_usec = 200000; + SYSCALL(err = select(0, NULL, NULL, NULL, &timeout)); +#else + err = xf86WaitForInput(-1, 200); +#endif + if (err == -1) { + Error("DigitalEdge select"); + return !Success; + } + +/* Put it in prompt mode so it doens't say anything before we're ready */ + SYSCALL(err = + write(local->fd, SS_PROMPT_MODE, strlen(SS_PROMPT_MODE))); + if (err == -1) { + Error("DigitalEdge write"); + return !Success; + } +/* Clear any pending input */ +#ifndef XFREE86_V4 + tcflush(local->fd, TCIFLUSH); +#else + xf86FlushInput(local->fd); +#endif + + if (priv->dedgeXOffset > 0 && priv->dedgeYOffset > 0) { + if (priv->dedgeXSize * 50 < priv->dedgeMaxX - priv->dedgeXOffset && + priv->dedgeYSize * 50 < priv->dedgeMaxY - priv->dedgeYOffset) { + priv->dedgeXOffset *= 50; + priv->dedgeYOffset *= 50; + } else { + ErrorF("%s DigitalEdge offset sets active area off tablet, " + "centering\n", XCONFIG_PROBED); + priv->dedgeXOffset = (priv->dedgeMaxX - priv->dedgeXSize) / 2; + priv->dedgeYOffset = (priv->dedgeMaxY - priv->dedgeYSize) / 2; + } + } else { + priv->dedgeXOffset = (priv->dedgeMaxX - priv->dedgeXSize) / 2; + priv->dedgeYOffset = (priv->dedgeMaxY - priv->dedgeYSize) / 2; + } + + if (priv->dedgeInc > 95) + priv->dedgeInc = 95; + if (priv->dedgeInc < 1) { +/* Make a guess as to the best increment value given video mode */ + if (priv->dedgeXSize / screenInfo.screens[0]->width < + priv->dedgeYSize / screenInfo.screens[0]->height) + priv->dedgeInc = priv->dedgeXSize / screenInfo.screens[0]->width; + else + priv->dedgeInc = priv->dedgeYSize / screenInfo.screens[0]->height; + if (priv->dedgeInc < 1) + priv->dedgeInc = 1; + if (xf86Verbose) + ErrorF("%s Using increment value of %d\n", XCONFIG_PROBED, + priv->dedgeInc); + } + +/* Sets up the tablet mode to increment, stream, and such */ + for (idx = 0; ss_initstr[idx]; idx++) { + buffer[idx] = ss_initstr[idx]; + } + buffer[idx++] = SS_INCREMENT; + buffer[idx++] = 32 + priv->dedgeInc; + buffer[idx++] = + (priv->flags & ABSOLUTE_FLAG) ? SS_ABSOLUTE : SS_RELATIVE; + buffer[idx] = 0; + + SYSCALL(err = write(local->fd, buffer, idx)); + if (err == -1) { + Error("DigitalEdge write"); + return !Success; + } + + if (err <= 0) { + SYSCALL(close(local->fd)); + return !Success; + } + + if (priv->dedgeClickThresh <= 0) { + /* Make up a value */ + priv->dedgeClickThresh = 700; + } + + return Success; +} + +/* +** xf86SumOpenDevice +** Opens and initializes the device driver stuff or dedgepthin. +*/ +static int xf86SumOpenDevice(DeviceIntPtr pSum) +{ + LocalDevicePtr local = (LocalDevicePtr) pSum->public.devicePrivate; + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) PRIVATE(pSum); + + if (xf86SumOpen(local) != Success) { + if (local->fd >= 0) { + SYSCALL(close(local->fd)); + } + local->fd = -1; + } + +/* Set the real values */ + InitValuatorAxisStruct(pSum, 0, 0, /* min val */ + 2430, /* max val */ + 500, /* resolution */ + 0, /* min_res */ + 500); /* max_res */ + InitValuatorAxisStruct(pSum, 1, 0, /* min val */ + 1950, /* max val */ + 500, /* resolution */ + 0, /* min_res */ + 500); /* max_res */ + InitValuatorAxisStruct(pSum, 2, priv->dedgeClickThresh, /* min val */ + 1022, /* max val */ + 500, /* resolution */ + 0, /* min_res */ + 500); /* max_res */ + return (local->fd != -1); +} + +/* +** xf86SumProc +** Handle requests to do stuff to the driver. +*/ +static int xf86SumProc(DeviceIntPtr pSum, int what) +{ + CARD8 map[25]; + int nbaxes; + int nbbuttons; + int loop; + LocalDevicePtr local = (LocalDevicePtr) pSum->public.devicePrivate; + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) PRIVATE(pSum); + + DBG(2, + ErrorF("BEGIN xf86SumProc dev=0x%x priv=0x%x what=%d\n", pSum, + priv, what)); + + switch (what) { + case DEVICE_INIT: + DBG(1, ErrorF("xf86SumProc pSum=0x%x what=INIT\n", pSum)); + + nbaxes = 3; /* X, Y, pressure */ + nbbuttons = (priv->flags & STYLUS_FLAG) ? 2 : 4; + + for (loop = 1; loop <= nbbuttons; loop++) + map[loop] = loop; + + if (InitButtonClassDeviceStruct(pSum, nbbuttons, map) == FALSE) { + ErrorF("unable to allocate Button class device\n"); + return !Success; + } + + if (InitFocusClassDeviceStruct(pSum) == FALSE) { + ErrorF("unable to init Focus class device\n"); + return !Success; + } + + if (InitPtrFeedbackClassDeviceStruct(pSum, xf86SumControlProc) == + FALSE) { + ErrorF("unable to init ptr feedback\n"); + return !Success; + } + + if (InitProximityClassDeviceStruct(pSum) == FALSE) { + ErrorF("unable to init proximity class device\n"); + return !Success; + } + + if (InitValuatorClassDeviceStruct(pSum, + nbaxes, + xf86GetMotionEvents, + local->history_size, + (priv->flags & ABSOLUTE_FLAG) ? + Absolute : Relative) == FALSE) { + ErrorF("unable to allocate Valuator class device\n"); + return !Success; + } +/* allocate the motion history buffer if needed */ + xf86MotionHistoryAllocate(local); +#ifndef XFREE86_V4 + AssignTypeAndName(pSum, local->atom, local->name); +#endif + +/* open the device to gather informations */ + xf86SumOpenDevice(pSum); + break; + + case DEVICE_ON: + DBG(1, ErrorF("xf86SumProc pSum=0x%x what=ON\n", pSum)); + + if ((local->fd < 0) && (!xf86SumOpenDevice(pSum))) { + return !Success; + } + SYSCALL(write(local->fd, SS_PROMPT, strlen(SS_PROMPT))); +#ifdef XFREE86_V4 + xf86AddEnabledDevice(local); +#else + AddEnabledDevice(local->fd); +#endif + pSum->public.on = TRUE; + break; + + case DEVICE_OFF: + DBG(1, ErrorF("xf86SumProc pSum=0x%x what=%s\n", pSum, + (what == DEVICE_CLOSE) ? "CLOSE" : "OFF")); + if (local->fd >= 0) +#ifdef XFREE86_V4 + xf86RemoveEnabledDevice(local); +#else + RemoveEnabledDevice(local->fd); +#endif + pSum->public.on = FALSE; + break; + + case DEVICE_CLOSE: + DBG(1, ErrorF("xf86SumProc pSum=0x%x what=%s\n", pSum, + (what == DEVICE_CLOSE) ? "CLOSE" : "OFF")); + SYSCALL(close(local->fd)); + local->fd = -1; + break; + + default: + ErrorF("unsupported mode=%d\n", what); + return !Success; + break; + } + DBG(2, ErrorF("END xf86SumProc Success what=%d dev=0x%x priv=0x%x\n", + what, pSum, priv)); + return Success; +} + +/* +** xf86SumClose +** It... Uh... Closes the physical device? +*/ +static void xf86SumClose(LocalDevicePtr local) +{ + if (local->fd >= 0) { + SYSCALL(close(local->fd)); + } + local->fd = -1; +} + +/* +** xf86SumChangeControl +** When I figure out what it does, it will do it. +*/ +static int xf86SumChangeControl(LocalDevicePtr local, xDeviceCtl * control) +{ + xDeviceResolutionCtl *res; + + res = (xDeviceResolutionCtl *) control; + + if ((control->control != DEVICE_RESOLUTION) + || (res->num_valuators < 1)) return (BadMatch); + + return (Success); +} + +/* +** xf86SumSwitchMode +** Switches the mode. For now just absolute or relative, hopefully +** more on the way. +*/ +static int xf86SumSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) (local->private); + char newmode; + + DBG(3, ErrorF("xf86SumSwitchMode dev=0x%x mode=%d\n", dev, mode)); + + switch (mode) { + case Absolute: + priv->flags |= ABSOLUTE_FLAG; + newmode = SS_ABSOLUTE; + break; + + case Relative: + priv->flags &= ~ABSOLUTE_FLAG; + newmode = SS_RELATIVE; + break; + + default: + DBG(1, ErrorF("xf86SumSwitchMode dev=0x%x invalid mode=%d\n", + dev, mode)); + return BadMatch; + } + SYSCALL(write(local->fd, &newmode, 1)); + return Success; +} + +/* +** xf86SumAllocate +** Allocates the device structures for the DigitalEdge. +*/ +static LocalDevicePtr xf86SumAllocate() +{ +#ifdef XFREE86_V4 + LocalDevicePtr local = xf86AllocateInput(dedgeDrv, 0); +#else + LocalDevicePtr local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); +#endif + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) xalloc(sizeof(DigitalEdgeDeviceRec)); +#if defined (sun) && !defined(i386) + char *dev_name = getenv("DEDGESKETCH_DEV"); +#endif + + local->name = XI_NAME; + local->type_name = "DigitalEdge Tablet"; + local->flags = 0; /*XI86_NO_OPEN_ON_INIT; */ +#ifndef XFREE86_V4 +#if !defined(sun) || defined(i386) + local->device_config = xf86SumConfig; +#endif +#endif + local->device_control = xf86SumProc; + local->read_input = xf86SumReadInput; + local->control_proc = xf86SumChangeControl; + local->close_proc = xf86SumClose; + local->switch_mode = xf86SumSwitchMode; + local->conversion_proc = xf86SumConvert; + local->reverse_conversion_proc = xf86SumReverseConvert; + local->fd = -1; + local->atom = 0; + local->dev = NULL; + local->private = priv; + local->private_flags = 0; + local->history_size = 0; + +#if defined(sun) && !defined(i386) + if (def_name) { + priv->dedgeDevice = (char *) xalloc(strlen(dev_name) + 1); + strcpy(priv->dedgeDevice, device_name); + ErrorF("xf86SumOpen port changed to '%s'\n", priv->dedgeDevice); + } else { + priv->dedgeDevice = ""; + } +#else + priv->dedgeDevice = ""; /* device file name */ +#endif + priv->dedgeInc = -1; /* re-transmit position on increment */ + priv->dedgeOldX = -1; /* previous X position */ + priv->dedgeOldY = -1; /* previous Y position */ + priv->dedgeOldProximity = 0; /* previous proximity */ + priv->dedgeOldPush = 0; /* previous buttons state */ + priv->dedgeOldBarrel = 0; /* previous buttons state */ + priv->dedgeMaxX = -1; /* max X value */ + priv->dedgeMaxY = -1; /* max Y value */ + priv->dedgeXSize = -1; /* active area X */ + priv->dedgeXOffset = -1; /* active area X offset */ + priv->dedgeYSize = -1; /* active area Y */ + priv->dedgeYOffset = -1; /* active area U offset */ + priv->flags = 0; /* various flags */ + priv->dedgeIndex = 0; /* number of bytes read */ + + return local; +} + +#ifndef XFREE86_V4 + +/* +** DigitalEdge device association +** Device section name and allocation function. +*/ +DeviceAssocRec dedgemasketch_assoc = { + DEDGE_SECTION_NAME, /* config_section_name */ + xf86SumAllocate /* device_allocate */ +}; + +#ifdef DYNAMIC_MODULE +/* +** init_module +** Entry point for dynamic module. +*/ +int +#ifndef DLSYM_BUG +init_module(unsigned long server_version) +#else +init_xf86DigitalEdge(unsigned long server_version) +#endif +{ + xf86AddDeviceAssoc(&dedgemasketch_assoc); + + if (server_version != XF86_VERSION_CURRENT) { + ErrorF("Warning: DigitalEdgeKetch module compiled for version%s\n", + XF86_VERSION); + return 0; + } else { + return 1; + } +} +#endif + +#else + +/* + * xf86SumUninit -- + * + * called when the driver is unloaded. + */ +static void +xf86SumUninit(InputDriverPtr drv, + LocalDevicePtr local, + int flags) +{ + DigitalEdgeDevicePtr priv = (DigitalEdgeDevicePtr) local->private; + + DBG(1, ErrorF("xf86DedgeUninit\n")); + + xf86SumProc(local->dev, DEVICE_OFF); + + xfree (priv); + xf86DeleteInput(local, 0); +} + + +/* + * xf86SumInit -- + * + * called when the module subsection is found in XF86Config + */ +static InputInfoPtr +xf86SumInit(InputDriverPtr drv, + IDevPtr dev, + int flags) +{ + LocalDevicePtr local = NULL; + DigitalEdgeDevicePtr priv = NULL; + char *s; + + dedgeDrv = drv; + + local = xf86SumAllocate(); + local->conf_idev = dev; + + xf86CollectInputOptions(local, default_options, NULL); + xf86OptionListReport( local->options ); + + if (local) + priv = (DigitalEdgeDevicePtr) local->private; + + if (!local || !priv) { + goto SetupProc_fail; + } + + local->name = dev->identifier; + + /* Serial Device is mandatory */ + priv->dedgeDevice = xf86FindOptionValue(local->options, "Device"); + + if (!priv->dedgeDevice) { + xf86Msg (X_ERROR, "%s: No Device specified.\n", dev->identifier); + goto SetupProc_fail; + } + + /* Process the common options. */ + xf86ProcessCommonOptions(local, local->options); + + /* Optional configuration */ + + xf86Msg(X_CONFIG, "%s serial device is %s\n", dev->identifier, + priv->dedgeDevice); + + debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); + if (debug_level > 0) { + xf86Msg(X_CONFIG, "Summa: debug level set to %d\n", debug_level); + } + + + + s = xf86FindOptionValue(local->options, "Mode"); + + if (s && (xf86NameCmp(s, "absolute") == 0)) { + priv->flags = priv->flags | ABSOLUTE_FLAG; + } + else if (s && (xf86NameCmp(s, "relative") == 0)) { + priv->flags = priv->flags & ~ABSOLUTE_FLAG; + } + else if (s) { + xf86Msg(X_ERROR, "%s: invalid Mode (should be absolute or relative). " + "Using default.\n", dev->identifier); + } + xf86Msg(X_CONFIG, "%s is in %s mode\n", local->name, + (priv->flags & ABSOLUTE_FLAG) ? "absolute" : "relative"); + + + s = xf86FindOptionValue(local->options, "Cursor"); + + if (s && (xf86NameCmp(s, "stylus") == 0)) { + priv->flags = priv->flags | STYLUS_FLAG; + } + else if (s && (xf86NameCmp(s, "puck") == 0)) { + priv->flags = priv->flags & ~STYLUS_FLAG; + } + else if (s) { + xf86Msg(X_ERROR, "%s: invalid Cursor (should be stylus or puck). " + "Using default.\n", dev->identifier); + } + xf86Msg(X_CONFIG, "%s is in cursor-mode %s\n", local->name, + (priv->flags & STYLUS_FLAG) ? "cursor" : "puck"); + + priv->dedgeInc = xf86SetIntOption(local->options, "increment", 0); + if (priv->dedgeInc != 0) { + xf86Msg(X_CONFIG, "%s: Increment = %d\n", + dev->identifier, priv->dedgeInc); + } + + priv->dedgeClickThresh = xf86SetIntOption(local->options, + "clickthreshold", 0); + if (priv->dedgeClickThresh != 0) { + xf86Msg(X_CONFIG, "%s: click threshold is %d\n", + dev->identifier, priv->dedgeClickThresh); + } + + priv->dedgeXSize = xf86SetIntOption(local->options, "XSize", 0); + if (priv->dedgeXSize != 0) { + xf86Msg(X_CONFIG, "%s: XSize = %d\n", + dev->identifier, priv->dedgeXSize); + } + + priv->dedgeYSize = xf86SetIntOption(local->options, "YSize", 0); + if (priv->dedgeYSize != 0) { + xf86Msg(X_CONFIG, "%s: YSize = %d\n", + dev->identifier, priv->dedgeYSize); + } + + priv->dedgeXOffset = xf86SetIntOption(local->options, "XOffset", 0); + if (priv->dedgeXOffset != 0) { + xf86Msg(X_CONFIG, "%s: XOffset = %d\n", + dev->identifier, priv->dedgeXOffset); + } + + priv->dedgeYOffset = xf86SetIntOption(local->options, "YOffset", 0); + if (priv->dedgeYOffset != 0) { + xf86Msg(X_CONFIG, "%s: YOffset = %d\n", + dev->identifier, priv->dedgeYOffset); + } + + + + /* mark the device configured */ + local->flags |= XI86_POINTER_CAPABLE | XI86_CONFIGURED; + + /* return the LocalDevice */ + return local; + + SetupProc_fail: + if (priv) + xfree(priv); + return local; +} + +#ifdef XFree86LOADER +static +#endif +InputDriverRec DIGITALEDGE = { + 1, /* driver version */ + "digitaledge", /* driver name */ + NULL, /* identify */ + xf86SumInit, /* pre-init */ + xf86SumUninit, /* un-init */ + NULL, /* module */ + 0 /* ref count */ +}; + + +/* + *************************************************************************** + * + * Dynamic loading functions + * + *************************************************************************** + */ +#ifdef XFree86LOADER +/* + * xf86SumUnplug -- + * + * called when the module subsection is found in XF86Config + */ +static void +xf86SumUnplug(pointer p) +{ + DBG(1, ErrorF("xf86SumUnplug\n")); +} + +/* + * xf86SumPlug -- + * + * called when the module subsection is found in XF86Config + */ +static pointer +xf86SumPlug(pointer module, + pointer options, + int *errmaj, + int *errmin) +{ + DBG(1, ErrorF("xf86SumPlug\n")); + + xf86AddInputDriver(&DIGITALEDGE, module, 0); + + return module; +} + +static XF86ModuleVersionInfo xf86SumVersionRec = +{ + "digitaledge", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} /* signature, to be patched into the file by */ + /* a tool */ +}; + +XF86ModuleData digitaledgeModuleData = {&xf86SumVersionRec, + xf86SumPlug, + xf86SumUnplug}; + +#endif /* XFree86LOADER */ +#endif /* XFREE86_V4 */ + +/* end of xf86DigitalEdge.c */ Index: xc/programs/Xserver/hw/xfree86/input/digitaledge/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/digitaledge/Imakefile:1.1 --- /dev/null Mon Dec 18 14:31:36 2000 +++ xc/programs/Xserver/hw/xfree86/input/digitaledge/Imakefile Fri Aug 11 15:10:42 2000 @@ -0,0 +1,26 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/digitaledge/Imakefile,v 1.1 2000/08/11 19:10:42 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = DigitalEdge.c +OBJS = DigitalEdge.o + +DRIVER = digitaledge + +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ + -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget($(DRIVER),$(OBJS)) + +InstallObjectModule($(DRIVER),$(MODULEDIR),input) + +DependTarget() + +InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input) Index: xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp diff -u xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp:1.4 Tue Jun 13 22:13:17 2000 +++ xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp Mon Dec 11 15:18:48 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp,v 1.4 2000/06/14 02:13:17 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp,v 1.5 2000/12/11 20:18:48 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH DYNAPRO __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH DYNAPRO __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME dynapro \- Dynapro input driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c diff -u xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c:1.2 xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c:1.3 --- xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c:1.2 Sun Aug 22 01:57:37 1999 +++ xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c Fri Aug 11 15:10:43 2000 @@ -27,7 +27,7 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c,v 1.2 1999/08/22 05:57:37 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/xf86Dyna.c,v 1.3 2000/08/11 19:10:43 dawes Exp $ */ #define _DYNAPRO_C_ @@ -166,12 +166,14 @@ DynaproPrivatePtr priv = xcalloc (1, sizeof (DynaproPrivateRec)); char *s; - if (!(pInfo = xf86AllocateInput(drv, 0))) + if (!priv) return NULL; - - if ((!drv) || (!priv)) - goto SetupProc_fail; + if (!(pInfo = xf86AllocateInput(drv, 0))) { + xfree(priv); + return NULL; + } + priv->min_x = 1000; priv->max_x = 0; priv->min_y = 0; @@ -249,14 +251,12 @@ xf86CloseSerial (pInfo->fd); if ((pInfo) && (pInfo->name)) xfree (pInfo->name); - if (pInfo) - xfree (pInfo); if ((priv) && (priv->buffer)) XisbFree (priv->buffer); if (priv) xfree (priv); - return (NULL); + return (pInfo); } static Bool Index: xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c diff -u xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c:1.9 xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c:1.10 --- xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c:1.9 Sat Jun 5 11:55:24 1999 +++ xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c Fri Aug 11 15:10:44 2000 @@ -48,7 +48,7 @@ * PERFORMANCE OF THIS SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c,v 1.9 1999/06/05 15:55:24 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elo2300/elo.c,v 1.10 2000/08/11 19:10:44 dawes Exp $ */ #define _elo_C_ /***************************************************************************** @@ -211,14 +211,12 @@ xf86CloseSerial (local->fd); if ((local) && (local->name)) xfree (local->name); - if (local) - xfree (local); if ((priv) && (priv->buffer)) XisbFree (priv->buffer); if (priv) xfree (priv); - return (NULL); + return (local); } static Bool Index: xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp diff -u xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp:1.2 xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp:1.3 --- xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp:1.2 Tue Jun 13 22:13:17 2000 +++ xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp Mon Dec 11 15:18:49 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp,v 1.2 2000/06/14 02:13:17 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp,v 1.3 2000/12/11 20:18:49 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH ELOGRAPHICS __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH ELOGRAPHICS __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME elographics \- Elographics input driver .SH SYNOPSIS @@ -34,7 +34,7 @@ .PP Config details... .SH "SEE ALSO" -XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1). +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__). .SH AUTHORS Authors include... Patrick Lecoanet Index: xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c diff -u xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c:1.10 xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c:1.11 --- xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c:1.10 Wed Jun 7 18:03:09 2000 +++ xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c Fri Aug 11 15:10:45 2000 @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c,v 1.10 2000/06/07 22:03:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c,v 1.11 2000/08/11 19:10:45 dawes Exp $ */ /* ******************************************************************************* @@ -1494,25 +1494,23 @@ xf86EloAllocate(InputDriverPtr drv) #endif { + LocalDevicePtr local; + EloPrivatePtr priv; + + priv = xalloc(sizeof(EloPrivateRec)); + if (!priv) + return NULL; + #ifndef XFREE86_V4 - LocalDevicePtr local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); + local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); #else - LocalDevicePtr local = xf86AllocateInput(drv, 0); + local = xf86AllocateInput(drv, 0); #endif - EloPrivatePtr priv = (EloPrivatePtr) xalloc(sizeof(EloPrivateRec)); if (!local) { - if (priv) { - xfree(priv); - } + xfree(priv); return NULL; } - if (!priv) { - if (local) { - xfree(local); - } - return NULL; - } #ifdef XFREE86_V4 priv->input_dev = strdup(ELO_PORT); @@ -1661,8 +1659,7 @@ } xfree(priv); } - xfree(local); - return NULL; + return local; } priv->input_dev = strdup(str); Index: xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile diff -u xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile:1.5 xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile:1.6 --- xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile:1.5 Sat Aug 14 06:50:00 1999 +++ xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile Mon Nov 6 14:24:07 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile,v 1.5 1999/08/14 10:50:00 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/joystick/Imakefile,v 1.6 2000/11/06 19:24:07 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -12,11 +12,11 @@ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) #ifdef LinuxArchitecture - ARCH_JSTK = ../os-support/linux/lnx_jstk.o + ARCH_JSTK = ../os-support/linux/lnx_jstk.o #endif #if defined(FreeBSDArchitecture) || defined(NetBSDArchitecture) || defined(OpenBSDArchitecture) - ARCH_JSTK = ../os-support/bsd/bsd_jstk.o + ARCH_JSTK = ../os-support/bsd/bsd_jstk.o #endif #if MakeHasPosixVariableSubstitutions Index: xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp diff -u xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp:1.4 Tue Jun 13 22:13:17 2000 +++ xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp Mon Dec 11 15:18:50 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp,v 1.4 2000/06/14 02:13:17 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp,v 1.5 2000/12/11 20:18:50 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH KEYBOARD __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH KEYBOARD __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME keyboard \- Keyboard input driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c diff -u xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c:1.11 xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c:1.12 --- xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c:1.11 Sat Aug 28 06:43:36 1999 +++ xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c Fri Aug 11 15:10:45 2000 @@ -48,7 +48,7 @@ * PERFORMANCE OF THIS SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c,v 1.11 1999/08/28 10:43:36 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.c,v 1.12 2000/08/11 19:10:45 dawes Exp $ */ #define _microtouch_C_ /***************************************************************************** @@ -209,13 +209,20 @@ static InputInfoPtr MuTouchPreInit(InputDriverPtr drv, IDevPtr dev, int flags) { - LocalDevicePtr local = xf86AllocateInput(drv, 0); - MuTPrivatePtr priv = xcalloc (1, sizeof (MuTPrivateRec)); + LocalDevicePtr local; + MuTPrivatePtr priv; char *s; - if ((!local) || (!priv)) - goto SetupProc_fail; + priv = xcalloc (1, sizeof (MuTPrivateRec)); + if (!priv) + return NULL; + + local = xf86AllocateInput(drv, 0); + if (!local) { + xfree(priv); + return NULL; + } local->type_name = XI_TOUCHSCREEN; local->device_control = DeviceControl; @@ -298,14 +305,12 @@ xf86CloseSerial (local->fd); if ((local) && (local->name)) xfree (local->name); - if (local) - xfree (local); if ((priv) && (priv->buffer)) XisbFree (priv->buffer); if (priv) xfree (priv); - return (NULL); + return (local); } static Bool Index: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp diff -u xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp:1.4 Tue Jun 13 22:13:18 2000 +++ xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp Mon Dec 11 15:18:51 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp,v 1.4 2000/06/14 02:13:18 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp,v 1.5 2000/12/11 20:18:51 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH MICROTOUCH __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH MICROTOUCH __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME microtouch \- MicroTouch input driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c diff -u xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c:1.33 xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c:1.38 --- xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c:1.33 Wed Jun 28 03:51:50 2000 +++ xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c Mon Dec 18 10:52:22 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c,v 1.33 2000/06/28 07:51:50 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c,v 1.38 2000/12/18 15:52:22 dawes Exp $ */ /* * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. @@ -40,8 +40,6 @@ #include "X.h" #include "Xproto.h" -#include "compiler.h" - #include "xf86.h" #ifdef XINPUT @@ -58,6 +56,8 @@ #include "xf86OSmouse.h" #define NEED_XF86_TYPES /* for xisb.h when !XFree86LOADER */ #include "xf86_ansic.h" +#include "compiler.h" + #include "xisb.h" #include "mouse.h" #include "mousePriv.h" @@ -448,6 +448,10 @@ pInfo->conf_idev = dev; /* Allocate the MouseDevRec and initialise it. */ + /* + * XXX This should be done by a function in the core server since the + * MouseDevRec is defined in the os-support layer. + */ if (!(pMse = xcalloc(sizeof(MouseDevRec), 1))) return pInfo; pInfo->private = pMse; @@ -496,6 +500,9 @@ pMse->protocol = protocol; pMse->protocolID = protocolID; + pMse->oldProtocolID = protocolID; /* hack */ + pMse->origProtocolID = protocolID; + pMse->origProtocol = protocol; pMse->class = ProtocolIDToClass(protocolID); /* Collect the options, and process the common options. */ @@ -529,7 +536,11 @@ xf86Msg(X_CONFIG, "%s: SampleRate: %d\n", pInfo->name, pMse->sampleRate); } - + pMse->baudRate = xf86SetIntOption(pInfo->options, "BaudRate", 0); + if (pMse->baudRate) { + xf86Msg(X_CONFIG, "%s: BaudRate: %d\n", pInfo->name, + pMse->baudRate); + } pMse->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0); if (pMse->resolution) { xf86Msg(X_CONFIG, "%s: Resolution: %d\n", pInfo->name, @@ -584,8 +595,8 @@ { 0xc0, 0x00, 0x00, 0x00, 6, 0x00, 0xff, MPF_NONE }, /* NetScroll */ /* Bus Mouse */ { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* BusMouse */ - /* Auto */ - { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* dummy entry */ + { 0xf8, 0x80, 0x00, 0x00, 5, 0x00, 0xff, MPF_NONE }, /* Auto (dummy) */ + { 0xf8, 0x80, 0x00, 0x00, 8, 0x00, 0xff, MPF_NONE }, /* SysMouse */ }; /* @@ -650,7 +661,7 @@ pMse = pInfo->private; /* Handle the "Auto" protocol. */ - if (pMse->protocolID == PROT_AUTO) { + if (pMse->origProtocolID == PROT_AUTO) { MouseProtocolID protocolID = PROT_UNKNOWN; automatic = TRUE; @@ -706,9 +717,31 @@ return FALSE; } } - + /* + * If protocol has changed fetch the default options + * for the new protocol. + */ + if (pMse->oldProtocolID != pMse->protocolID) { + pointer tmp = NULL; + if (mouseProtocols[pMse->protocolID].defaults) + tmp = xf86OptionListCreate( + mouseProtocols[pMse->protocolID].defaults, -1, 0); + pInfo->options = xf86OptionListMerge(pInfo->options, tmp); + /* baudrate is not explicitely set: fetch the default one */ + if (!pMse->baudRate) + pMse->baudRate = xf86SetIntOption(pInfo->options, "BaudRate", 0); + pMse->oldProtocolID = pMse->protocolID; /* hack */ + } + /* + * Write the baudrate back th the option list so that the serial + * interface code can access the new value. + */ + if (pMse->baudRate) + xf86ReplaceIntOption(pInfo->options, "BaudRate", pMse->baudRate); + /* Set the port parameters. */ - xf86SetSerial(pInfo->fd, pInfo->options); + if (!automatic) + xf86SetSerial(pInfo->fd, pInfo->options); param = NULL; paramlen = 0; switch (pMse->protocolID) { @@ -717,7 +750,7 @@ * The baud rate selection command must be sent at the current * baud rate; try all likely settings. */ - speed = xf86SetIntOption(pInfo->options, "BaudRate", 0); + speed = pMse->baudRate; switch (speed) { case 9600: s = "*q"; @@ -772,7 +805,7 @@ break; case PROT_LOGIMAN: - speed = xf86SetIntOption(pInfo->options, "BaudRate", 0); + speed = pMse->baudRate; switch (speed) { case 9600: s = "*q"; @@ -1012,12 +1045,6 @@ */ XisbBlockDuration(pMse->buffer, -1); -#ifdef EXTMOUSEDEBUG2 - ErrorF("received %d bytes",nBytes); - for ( i=0; i < nBytes; i++) - ErrorF(" %02x",pMse->buffer[i]); - ErrorF("\n"); -#endif while ((c = XisbRead(pMse->buffer)) >= 0) { u = (unsigned char)c; if (pBufP >= pMse->protoPara[4]) { @@ -1113,6 +1140,15 @@ */ pBuf[pBufP++] = u; if (pBufP != pMse->protoPara[4]) continue; +#ifdef EXTMOUSEDEBUG2 + { + int i; + ErrorF("received %d bytes",pBufP); + for ( i=0; i < pBufP; i++) + ErrorF(" %02x",pBuf[i]); + ErrorF("\n"); + } +#endif /* * Hack for resyncing: We check here for a package that is: Index: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp diff -u xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp:1.6 --- xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp:1.4 Tue Jun 13 22:13:18 2000 +++ xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp Tue Dec 12 13:54:32 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp,v 1.4 2000/06/14 02:13:18 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp,v 1.6 2000/12/12 18:54:32 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH MOUSE __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH MOUSE __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME mouse \- Mouse input driver .SH SYNOPSIS @@ -81,7 +81,7 @@ pressing both buttons simultaneously. Default: off .TP 7 .BI "Option \*qEmulate3Timeout\*q \*q" integer \*q -Sets the timeout (in milliseconds) that the driver waits before decicing +Sets the timeout (in milliseconds) that the driver waits before deciding if two buttons where pressed "simultaneously" when 3 button emulation is enabled. Default: 50. .TP 7 Index: xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c diff -u xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c:1.9 xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c:1.10 --- xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c:1.9 Thu Feb 10 17:33:43 2000 +++ xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c Tue Oct 24 14:07:51 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c,v 1.9 2000/02/10 22:33:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/pnp.c,v 1.10 2000/10/24 18:07:51 dawes Exp $ */ /* * Copyright 1998 by Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> @@ -148,9 +148,9 @@ if (((len = pnpgets(pInfo, buf)) <= 0) || !pnpparse(pInfo, &pnpid, buf, len)) - return -1; + return PROT_UNKNOWN; if ((t = pnpproto(&pnpid)) == NULL) - return -1; + return PROT_UNKNOWN; xf86MsgVerb(X_INFO, 2, "%s: PnP-detected protocol ID: %d\n", pInfo->name, t->val); return (t->val); Index: xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp diff -u xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp:1.2 xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp:1.3 --- xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp:1.2 Tue Jun 13 22:13:18 2000 +++ xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp Mon Dec 11 15:18:54 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp,v 1.2 2000/06/14 02:13:18 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp,v 1.3 2000/12/11 20:18:54 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH MUTOUCH __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH MUTOUCH __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME mutouch \- Microtouch input driver .SH SYNOPSIS @@ -34,7 +34,7 @@ .PP Config details... .SH "SEE ALSO" -XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1). +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__). .SH AUTHORS Authors include... Patrick Lecoanet Index: xc/programs/Xserver/hw/xfree86/input/penmount/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/penmount/Imakefile:1.1 --- /dev/null Mon Dec 18 14:31:37 2000 +++ xc/programs/Xserver/hw/xfree86/input/penmount/Imakefile Tue Aug 1 14:59:58 2000 @@ -0,0 +1,31 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/penmount/Imakefile,v 1.1 2000/08/01 18:59:58 dawes Exp $ + +#define IHaveModules +#include <Server.tmpl> + +SRCS = xf86PM.c +OBJS = xf86PM.o + +DRIVER = penmount + +INCLUDES = -I. -I$(XF86COMSRC) -I../../loader -I$(XF86OSSRC) \ + -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) + +#if MakeHasPosixVariableSubstitutions +SubdirLibraryRule($(OBJS)) +#endif + +ModuleObjectRule() + +ObjectModuleTarget($(DRIVER),$(OBJS)) + +InstallObjectModule($(DRIVER),$(MODULEDIR),input) + +#if !defined(XF86DriverSDK) +CppManTarget($(DRIVER),) +InstallModuleManPage($(DRIVER)) +#endif + +DependTarget() + +InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input) Index: xc/programs/Xserver/hw/xfree86/input/penmount/penmount.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/penmount/penmount.cpp:1.2 --- /dev/null Mon Dec 18 14:31:37 2000 +++ xc/programs/Xserver/hw/xfree86/input/penmount/penmount.cpp Mon Dec 11 15:18:55 2000 @@ -0,0 +1,37 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/penmount/penmount.cpp,v 1.2 2000/12/11 20:18:55 dawes Exp $ +.TH PENNMOUNT __drivermansuffix__ "Version 4.0.2" "XFree86" +.SH NAME +penmount \- PenMount input driver +.SH SYNOPSIS +.B "Section ""InputDevice""" +.br +.BI " Identifier """ idevname """" +.br +.B " Driver ""penmount""" +.br +.BI " Option ""Device"" """ devpath """" +.br +\ \ ... +.br +.B EndSection +.SH DESCRIPTION +.B penmount +is an XFree86 input driver for PenMount devices... +.PP +The +.B penmount +driver functions as a pointer input device, and may be used as the +X server's core pointer. +THIS MAN PAGE NEEDS TO BE FILLED IN. +.SH SUPPORTED HARDWARE +What is supported... +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details and for options that can be used with all input drivers. This +section only covers configuration details specific to this driver. +.PP +Config details... +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__). +.SH AUTHORS +Authors include... Index: xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.c:1.2 --- /dev/null Mon Dec 18 14:31:39 2000 +++ xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.c Fri Aug 11 15:10:46 2000 @@ -0,0 +1,760 @@ +/* + * Copyright (c) 1999 Machine Vision Holdings Incorporated + * Author: David Woodhouse <David.Woodhouse@mvhi.com> + * CoAuthor: Mayk Langer <langer@vsys.de> + * + * Template driver used: Copyright (c) 1998 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, cpy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.c,v 1.2 2000/08/11 19:10:46 dawes Exp $ */ + +#define _PENMOUNT_C_ + +#include <misc.h> +#include <xf86.h> +#define NEED_XF86_TYPES +#include <xf86_ansic.h> +#include <xf86_OSproc.h> +#include <xf86Xinput.h> +#include <xisb.h> +#include <exevents.h> + +#include "xf86PM.h" + +InputDriverRec PENMOUNT = { + 1, + "penmount", + NULL, + PenMountPreInit, + /*PenMountUnInit*/NULL, + NULL, + 0 +}; + + + +#ifdef XFree86LOADER + +static XF86ModuleVersionInfo VersionRec = +{ + "penmount", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} /* signature, to be patched into the file by + * a tool */ +}; + + +static const char *reqSymbols[] = { + "AddEnabledDevice", + "ErrorF", + "InitButtonClassDeviceStruct", + "InitProximityClassDeviceStruct", + "InitValuatorAxisStruct", + "InitValuatorClassDeviceStruct", + "InitPtrFeedbackClassDeviceStruct", + "RemoveEnabledDevice", + "Xcalloc", + "Xfree", + "XisbBlockDuration", + "XisbFree", + "XisbNew", + "XisbRead", + "XisbTrace", + "screenInfo", + "xf86AddInputDriver", + "xf86AllocateInput", + "xf86CloseSerial", /* first one */ + "xf86CollectInputOptions", + "xf86ErrorFVerb", + "xf86FindOptionValue", + "xf86GetMotionEvents", + "xf86GetVerbosity", + "xf86MotionHistoryAllocate", + "xf86NameCmp", + "xf86OpenSerial", + "xf86CloseSerial", /* second one ? */ + "xf86OptionListCreate", + "xf86OptionListMerge", + "xf86OptionListReport", + "xf86PostButtonEvent", + "xf86PostMotionEvent", + "xf86PostProximityEvent", + "xf86ProcessCommonOptions", + "xf86RemoveLocalDevice", + "xf86ScaleAxis", + "xf86SetIntOption", + "xf86SetStrOption", + "xf86XInputSetScreen", + "xf86XInputSetSendCoreEvents", + NULL +}; + + +static pointer +PenMountSetupProc( pointer module, + pointer options, + int *errmaj, + int *errmin ) +{ + xf86LoaderReqSymLists(reqSymbols, NULL); + xf86AddInputDriver(&PENMOUNT, module, 0); + return (pointer) 1; +} + +XF86ModuleData penmountModuleData = { &VersionRec, PenMountSetupProc, NULL }; + + +#endif /* XFree86LOADER */ + + +/* + * Be sure to set vmin appropriately for your device's protocol. You want to + * read a full packet before returning + */ +static const char *default_options[] = +{ + /* "Device", "/dev/ttyS1",*/ + "BaudRate", "19200", + "StopBits", "1", + "DataBits", "8", + "Parity", "None", + "Vmin", "3", + "Vtime", "1", + "FlowControl", "None", + NULL, +}; + + +/***************************************************************************** + * Function Definitions + ****************************************************************************/ + + + +static InputInfoPtr +PenMountPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +{ + InputInfoPtr pInfo; + PenMountPrivatePtr priv = xcalloc (1, sizeof (PenMountPrivateRec)); + char *s; + + if (!priv) + return NULL; + + if (!(pInfo = xf86AllocateInput(drv, 0))) { + xfree(priv); + return NULL; + } + + priv->min_x = 0; + priv->max_x = 1024; + priv->min_y = 768; + priv->max_y = 0; + priv->screen_num = 0; + priv->screen_width = -1; + priv->screen_height = -1; + priv->lex_mode = PenMount_byte0; + priv->swap_xy = 0; + priv->button_down = FALSE; + priv->button_number = 1; + priv->proximity = FALSE; + priv->chip = CHIP_UNKNOWN; + priv->pen_down = 0; + + pInfo->type_name = XI_TOUCHSCREEN; + pInfo->device_control = DeviceControl; + pInfo->read_input = ReadInput; + pInfo->control_proc = ControlProc; + pInfo->close_proc = CloseProc; + pInfo->switch_mode = SwitchMode; + pInfo->conversion_proc = ConvertProc; + pInfo->dev = NULL; + pInfo->private = priv; + pInfo->private_flags = 0; + pInfo->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; + pInfo->conf_idev = dev; + + xf86CollectInputOptions(pInfo, default_options, NULL); + + xf86OptionListReport( pInfo->options ); + + pInfo->fd = xf86OpenSerial (pInfo->options); + if (pInfo->fd == -1) + { + ErrorF ("PenMount driver unable to open device\n"); + goto SetupProc_fail; + } + xf86CloseSerial(pInfo->fd); + /* + * Process the options for your device like this + */ + priv->min_x = xf86SetIntOption( pInfo->options, "MinX", 0 ); + priv->max_x = xf86SetIntOption( pInfo->options, "MaxX", 1024 ); + priv->min_y = xf86SetIntOption( pInfo->options, "MinY", 768 ); + priv->max_y = xf86SetIntOption( pInfo->options, "MaxY", 0 ); + priv->screen_num = xf86SetIntOption( pInfo->options, "ScreenNumber", 0 ); + priv->button_number = xf86SetIntOption( pInfo->options, "ButtonNumber", 1 ); + priv->swap_xy = xf86SetIntOption( pInfo->options, "SwapXY", 0 ); + priv->buffer = NULL; + s = xf86FindOptionValue (pInfo->options, "ReportingMode"); + if ((s) && (xf86NameCmp (s, "raw") == 0)) + priv->reporting_mode = TS_Raw; + else + priv->reporting_mode = TS_Scaled; + + priv->proximity = FALSE; + priv->button_down = FALSE; + priv->lex_mode = PenMount_byte0; + + if (QueryHardware (priv) != Success) + { + ErrorF ("Unable to query/initialize PenMount hardware.\n"); + goto SetupProc_fail; + } + + /* this results in an xstrdup that must be freed later */ + pInfo->name = xf86SetStrOption( pInfo->options, "DeviceName", "PenMount"); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + pInfo->flags |= XI86_CONFIGURED; + return (pInfo); + + SetupProc_fail: + if ((pInfo) && (pInfo->fd)) + xf86CloseSerial (pInfo->fd); + if ((pInfo) && (pInfo->name)) + xfree (pInfo->name); + + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); + if (priv) + xfree (priv); + return (pInfo); +} + +static Bool +DeviceControl (DeviceIntPtr dev, int mode) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + PenMountPrivatePtr priv = (PenMountPrivatePtr) (pInfo->private); + unsigned char map[] = + {0, 1}; + + switch (mode) + { + case DEVICE_INIT: + /* + * these have to be here instead of in the SetupProc, because when the + * SetupProc is run at server startup, screenInfo is not setup yet + */ + priv->screen_width = screenInfo.screens[priv->screen_num]->width; + priv->screen_height = screenInfo.screens[priv->screen_num]->height; + + /* + * Device reports button press for 1 button. + */ + if (InitButtonClassDeviceStruct (dev, 1, map) == FALSE) + { + ErrorF ("Unable to allocate PenMount ButtonClassDeviceStruct\n"); + return !Success; + } + + /* + * Device reports motions on 2 axes in absolute coordinates. + * Axes min and max values are reported in raw coordinates. + */ + if (InitValuatorClassDeviceStruct (dev, 2, xf86GetMotionEvents, + pInfo->history_size, Absolute) == FALSE) + { + ErrorF ("Unable to allocate PenMount ValuatorClassDeviceStruct\n"); + return !Success; + } + else + { + InitValuatorAxisStruct (dev, 0, priv->min_x, priv->max_x, + 9500, + 0 /* min_res */ , + 9500 /* max_res */ ); + InitValuatorAxisStruct (dev, 1, priv->min_y, priv->max_y, + 10500, + 0 /* min_res */ , + 10500 /* max_res */ ); + } + + if (InitProximityClassDeviceStruct (dev) == FALSE) + { + ErrorF ("unable to allocate PenMount ProximityClassDeviceStruct\n"); + return !Success; + } + + if (InitPtrFeedbackClassDeviceStruct(dev, PenMountPtrCtrl) == FALSE) + { + ErrorF ("unable to allocate PenMount PtrFeedbackClassDeviceStruct\n"); + return !Success; + } + + /* + * Allocate the motion events buffer. + */ + xf86MotionHistoryAllocate (pInfo); + return (Success); + + case DEVICE_ON: + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) + { + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + return (!Success); + } + else + { + priv->buffer = XisbNew(pInfo->fd, 64); + if (!priv->buffer) + { + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + return (!Success); + } +/* if (isatty (pInfo->fd)) check if DMC8910 is found */ + { +/* echo Success Code */ + unsigned char buf[5] = { 'D', 'G', 0x02, 0x80, 0x00 }; + + XisbBlockDuration (priv->buffer, 500000); + if ( PenMountSendPacket(priv, buf, 5) == Success ) + { + /* wait for right response */ + priv->lex_mode = PenMount_Response0; + if (PenMountGetPacket (priv) == Success ) + { + if (( priv->packet[0] == 0xff ) && + ( priv->packet[1] == 0x70 ) ) + { + priv->chip = DMC8910; + /* disable DMC8910 */ + buf[2] = 0x0b; + buf[3] = 0x00; + buf[4] = 0x00; + PenMountSendPacket(priv,buf,5); + priv->lex_mode = PenMount_Response0; + PenMountGetPacket(priv); + /* set screen width */ + buf[2] = 0x02; + buf[3] = (priv->screen_width & 0x0fff) >> 8; + buf[4] = priv->screen_width & 0xff; + PenMountSendPacket(priv,buf,5); + priv->lex_mode = PenMount_Response0; + PenMountGetPacket(priv); + /* set screen height */ + buf[2] = 0x02; + buf[3] = (priv->screen_height & 0x0fff) >> 8; + buf[4] = priv->screen_height & 0xff; + buf[3] |= 0x10; + PenMountSendPacket(priv,buf,5); + priv->lex_mode = PenMount_Response0; + PenMountGetPacket(priv); + /* enable DMC8910 */ + buf[2] = 0x0a; + buf[3] = 0x01; + buf[4] = 0x00; + PenMountSendPacket(priv,buf,5); + priv->lex_mode = PenMount_Response0; + PenMountGetPacket(priv); + } + } + } + } + } + + XisbBlockDuration (priv->buffer, -1); + priv->lex_mode = PenMount_byte0; + + xf86FlushInput(pInfo->fd); + AddEnabledDevice (pInfo->fd); + dev->public.on = TRUE; + return (Success); + + case DEVICE_OFF: + case DEVICE_CLOSE: + if (pInfo->fd != -1) + { + RemoveEnabledDevice (pInfo->fd); + if (priv->buffer) + { + XisbFree(priv->buffer); + priv->buffer = NULL; + } + xf86CloseSerial(pInfo->fd); + } + dev->public.on = FALSE; + return (Success); + default: + return (BadValue); + } + +} + + +/* + * The ReadInput function will have to be tailored to your device + */ +static void +ReadInput (InputInfoPtr pInfo) +{ + PenMountPrivatePtr priv = (PenMountPrivatePtr) (pInfo->private); + int x,y; + unsigned char opck[ PENMOUNT_PACKET_SIZE ]; + + /* + * set blocking to -1 on the first call because we know there is data to + * read. Xisb automatically clears it after one successful read so that + * succeeding reads are preceeded buy a select with a 0 timeout to prevent + * read from blocking indefinately. + */ + XisbBlockDuration (priv->buffer, -1); + while (1) + { + if ( priv->chip != DMC8910 ) + { + if ( PenMountGetPacket (priv) != Success) + break; + if (( priv->packet[0] & 0x0C ) != 0x0C ) + break; + if (priv->swap_xy) { + y = priv->packet[1]; + y |= (priv->packet[0] & 0x10) ? 0x100 : 0; + y |= (priv->packet[0] & 0x40) ? 0x200 : 0; + x = priv->packet[2]; + x |= (priv->packet[0] & 0x20) ? 0x100 : 0; + x |= (priv->packet[0] & 0x80) ? 0x200 : 0; + } else { + x = priv->packet[1]; + x |= (priv->packet[0] & 0x10) ? 0x100 : 0; + x |= (priv->packet[0] & 0x40) ? 0x200 : 0; + y = priv->packet[2]; + y |= (priv->packet[0] & 0x20) ? 0x100 : 0; + y |= (priv->packet[0] & 0x80) ? 0x200 : 0; + } + } + else + { + memcpy(opck,priv->packet,5); + if ( PenMountGetPacket (priv) != Success ) + break; + if (( priv->packet[1] == 0xfd ) && ( priv->packet[2] == 0xfd )) + { + priv->pen_down = 1; + continue; + } + if (( priv->packet[1] == 0xfe ) && ( priv->packet[2] == 0xfe )) + { + memcpy(priv->packet,opck,5); + if ( !priv->pen_down ) + continue; + priv->pen_down = 0; + } + if ( priv->swap_xy) + { + y = priv->packet[1]*256+priv->packet[2]; + x = priv->packet[3]*256+priv->packet[4]; + } + else + { + x = priv->packet[1]*256+priv->packet[2]; + y = priv->packet[3]*256+priv->packet[4]; + } + priv->packet[0] = priv->pen_down ? 0x01 : 0x00; + } + + if (priv->reporting_mode == TS_Scaled) + { + x = xf86ScaleAxis (x, 0, priv->screen_width, priv->min_x, + priv->max_x); + y = xf86ScaleAxis (y, 0, priv->screen_height, priv->min_y, + priv->max_y); + } + + xf86XInputSetScreen (pInfo, priv->screen_num, x, y); + + if ((priv->proximity == FALSE) && (priv->packet[0] & 0x01)) + { + priv->proximity = TRUE; + xf86PostProximityEvent (pInfo->dev, 1, 0, 2, x, y); + } + + /* + * Send events. + * + * We *must* generate a motion before a button change if pointer + * location has changed as DIX assumes this. This is why we always + * emit a motion, regardless of the kind of packet processed. + */ + + xf86PostMotionEvent (pInfo->dev, TRUE, 0, 2, x, y); + + /* + * Emit a button press or release. + */ + if ((priv->button_down == FALSE) && (priv->packet[0] & 0x01)) + + { + xf86PostButtonEvent (pInfo->dev, TRUE, + priv->button_number, 1, 0, 2, x, y); + priv->button_down = TRUE; + } + if ((priv->button_down == TRUE) && !(priv->packet[0] & 0x01)) + { + xf86PostButtonEvent (pInfo->dev, TRUE, + priv->button_number, 0, 0, 2, x, y); + priv->button_down = FALSE; + } + /* + * the untouch should always come after the button release + */ + if ((priv->proximity == TRUE) && !(priv->packet[0] & 0x01)) + { + priv->proximity = FALSE; + xf86PostProximityEvent (pInfo->dev, 0, 0, 2, x, y); + } + } +} + +/* + * The ControlProc function may need to be tailored for your device + */ +static int +ControlProc (InputInfoPtr pInfo, xDeviceCtl * control) +{ + xDeviceTSCalibrationCtl *c = (xDeviceTSCalibrationCtl *) control; + PenMountPrivatePtr priv = (PenMountPrivatePtr) (pInfo->private); + + priv->min_x = c->min_x; + priv->max_x = c->max_x; + priv->min_y = c->min_y; + priv->max_y = c->max_y; + + return (Success); +} + +/* + * the CloseProc should not need to be tailored to your device + */ +static void +CloseProc (InputInfoPtr pInfo) +{ + +} + +/* + * The SwitchMode function may need to be tailored for your device + */ +static int +SwitchMode (ClientPtr client, DeviceIntPtr dev, int mode) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + PenMountPrivatePtr priv = (PenMountPrivatePtr) (pInfo->private); + + + if ((mode == TS_Raw) || (mode == TS_Scaled)) + { + priv->reporting_mode = mode; + return (Success); + } + else if ((mode == SendCoreEvents) || (mode == DontSendCoreEvents)) + { + xf86XInputSetSendCoreEvents (pInfo, (mode == SendCoreEvents)); + return (Success); + } + else + return (!Success); +} + +/* + * The ConvertProc function may need to be tailored for your device. + * This function converts the device's valuator outputs to x and y coordinates + * to simulate mouse events. + */ +static Bool +ConvertProc (InputInfoPtr pInfo, + int first, + int num, + int v0, + int v1, + int v2, + int v3, + int v4, + int v5, + int *x, + int *y) +{ + PenMountPrivatePtr priv = (PenMountPrivatePtr) (pInfo->private); + + if (priv->reporting_mode == TS_Raw) + { + *x = xf86ScaleAxis (v0, 0, priv->screen_width, priv->min_x, + priv->max_x); + *y = xf86ScaleAxis (v1, 0, priv->screen_height, priv->min_y, + priv->max_y); + } + else + { + *x = v0; + *y = v1; + } + return (TRUE); +} + +/* + * the QueryHardware fuction should be tailored to your device to + * verify the device is attached and functional and perform any + * needed initialization. + */ +static Bool +QueryHardware (PenMountPrivatePtr priv) +{ + /* Maybe once we get the hardware to actually respond correctly to its + configuration 'packets' */ + + return (Success); +} + +/* + * This function should be renamed for your device and tailored to handle + * your device's protocol. + */ +static Bool +PenMountGetPacket (PenMountPrivatePtr priv) +{ + int count = 0; + int c; + + while ((c = XisbRead (priv->buffer)) >= 0) + { + /* + * fail after 500 bytes so the server doesn't hang forever if a + * device sends bad data. + */ + if (count++ > 500) + return (!Success); + + switch (priv->lex_mode) + { + case PenMount_byte0: + if ( priv->chip != DMC8910 ) + { + if (!(c & 0x08) ) + return (!Success); + } + else + { + if ( c != 0xff ) + return (!Success); + } + priv->packet[0] = (unsigned char) c; + priv->lex_mode = PenMount_byte1; + break; + + case PenMount_byte1: + priv->packet[1] = (unsigned char) c; + priv->lex_mode = PenMount_byte2; + break; + + case PenMount_byte2: + priv->packet[2] = (unsigned char) c; + priv->lex_mode = PenMount_byte0; + if ( priv->chip != DMC8910 ) + return (Success); + if (( priv->packet[2] == 0xfe ) && ( priv->packet[1] == 0xfe )) + return (Success); + if (( priv->packet[2] == 0xfd ) && ( priv->packet[1] == 0xfd )) + return (Success); + priv->lex_mode = PenMount_byte3; + break; + + case PenMount_byte3: + priv->packet[3] = (unsigned char) c; + priv->lex_mode = PenMount_byte4; + break; + + case PenMount_byte4: + priv->packet[4] = (unsigned char) c; + priv->lex_mode = PenMount_byte0; + return (Success); + break; + + case PenMount_Response0: + if ( c == 0xff ) + priv->lex_mode = PenMount_Response1; + priv->packet[0] = (unsigned char) c; + break; + + case PenMount_Response1: + priv->packet[1] = (unsigned char) c; + priv->lex_mode = PenMount_Response2; + break; + case PenMount_Response2: + priv->packet[2] = (unsigned char) c; + priv->lex_mode = PenMount_byte0; + return (Success); + break; + } + } + return (!Success); +} + +static Bool +PenMountSendPacket (PenMountPrivatePtr priv, unsigned char *buf, int len) +{ + int count = 0; + + while ( len > 0 ) + { + if ( XisbWrite(priv->buffer, buf, 1) == 1 ) + { + buf++; + len--; + continue; + } + if ( count++ > 500 ) + break; + } + return (len ? !Success : Success); +} + +static void +PenMountPtrCtrl(DeviceIntPtr device, PtrCtrl *ctrl) +{ + /* I have no clue what this does, except that registering it stops the + X server segfaulting in ProcGetPointerMapping() + Ho Hum. + */ +} Index: xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.h:1.1 --- /dev/null Mon Dec 18 14:31:39 2000 +++ xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.h Tue Aug 1 14:59:58 2000 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999 Machine Vision Holdings Incorporated + * Author: David Woodhouse <David.Woodhouse@mvhi.com> + * + * Template driver used: Copyright (c) 1998 Metro Link Incorporated + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of the Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/penmount/xf86PM.h,v 1.1 2000/08/01 18:59:58 dawes Exp $ */ + +#ifndef _PENMOUNT_H_ +#define _PENMOUNT_H_ + +/****************************************************************************** + * Definitions + * structs, typedefs, #defines, enums + *****************************************************************************/ + +#define PENMOUNT_PACKET_SIZE 5 + +typedef enum +{ + PenMount_byte0, PenMount_byte1, PenMount_byte2, PenMount_byte3, PenMount_byte4, + PenMount_Response0, PenMount_Response1, PenMount_Response2 +} +PenMountState; + + +typedef struct _PenMountPrivateRec +{ + int min_x; /* Minimum x reported by calibration */ + int max_x; /* Maximum x */ + int min_y; /* Minimum y reported by calibration */ + int max_y; /* Maximum y */ + Bool button_down; /* is the "button" currently down */ + int button_number; /* which button to report */ + int reporting_mode; /* TS_Raw or TS_Scaled */ + + int screen_num; /* Screen associated with the device */ + int screen_width; /* Width of the associated X screen */ + int screen_height; /* Height of the screen */ + int proximity; + int swap_xy; + XISBuffer *buffer; + unsigned char packet[PENMOUNT_PACKET_SIZE]; /* packet being/just read */ + PenMountState lex_mode; + char chip; + char pen_down; +} +PenMountPrivateRec, *PenMountPrivatePtr; + +#define CHIP_UNKNOWN 0 +#define DMC8910 1 + + +/****************************************************************************** + * Declarations + *****************************************************************************/ + +static Bool DeviceControl (DeviceIntPtr, int); +static void ReadInput (InputInfoPtr); +static int ControlProc (InputInfoPtr, xDeviceCtl *); +static void CloseProc (InputInfoPtr); +static int SwitchMode (ClientPtr, DeviceIntPtr, int); +static Bool ConvertProc (InputInfoPtr, int, int, int, int, int, int, int, int, int *, int *); +static Bool QueryHardware (PenMountPrivatePtr); +static Bool PenMountGetPacket (PenMountPrivatePtr priv); +static Bool PenMountSendPacket (PenMountPrivatePtr priv, unsigned char *buf, int len ); + +static InputInfoPtr +PenMountPreInit(InputDriverPtr drv, IDevPtr dev, int flags); + +static void +PenMountPtrCtrl(DeviceIntPtr device, PtrCtrl *ctrl); + + +#endif /* _PENMOUNT_H_ */ Index: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c diff -u xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c:1.9 xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c:1.10 --- xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c:1.9 Sat Jun 5 11:55:29 1999 +++ xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c Fri Aug 11 15:10:47 2000 @@ -24,7 +24,7 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c,v 1.9 1999/06/05 15:55:29 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.c,v 1.10 2000/08/11 19:10:47 dawes Exp $ */ #define _SPACEORB_C_ /***************************************************************************** @@ -49,9 +49,23 @@ * Variables without includable headers ****************************************************************************/ + /***************************************************************************** * Local Variables ****************************************************************************/ +/** @added by Guido Heumer */ +InputDriverRec SPACEORB = { + 1, + "spaceorb", + NULL, + SpaceorbPreInit, + /*DynaproUnInit*/NULL, + NULL, + 0 +}; + +#ifdef XFree86LOADER + static XF86ModuleVersionInfo VersionRec = { "spaceorb", @@ -67,6 +81,67 @@ * a tool */ }; +static const char *reqSymbols[] = { + "AddEnabledDevice", + "ErrorF", + "InitButtonClassDeviceStruct", + "InitProximityClassDeviceStruct", + "InitValuatorAxisStruct", + "InitValuatorClassDeviceStruct", + "InitPtrFeedbackClassDeviceStruct", + "RemoveEnabledDevice", + "Xcalloc", + "Xfree", + "XisbBlockDuration", + "XisbFree", + "XisbNew", + "XisbRead", + "XisbTrace", + "screenInfo", + "xf86AddInputDriver", + "xf86AllocateInput", + "xf86CloseSerial", + "xf86CollectInputOptions", + "xf86ErrorFVerb", + "xf86FindOptionValue", + "xf86GetMotionEvents", + "xf86GetVerbosity", + "xf86MotionHistoryAllocate", + "xf86NameCmp", + "xf86OpenSerial", + "xf86CloseSerial", + "xf86OptionListCreate", + "xf86OptionListMerge", + "xf86OptionListReport", + "xf86PostButtonEvent", + "xf86PostMotionEvent", + "xf86PostProximityEvent", + "xf86ProcessCommonOptions", + "xf86RemoveLocalDevice", + "xf86ScaleAxis", + "xf86SetIntOption", + "xf86SetStrOption", + "xf86XInputSetScreen", + "xf86XInputSetSendCoreEvents", + NULL +}; + +static pointer +SPACEORBSetupProc(pointer module, + pointer options, + int *errmaj, + int *errmin ) { + xf86LoaderReqSymLists(reqSymbols, NULL); + xf86AddInputDriver(&SPACEORB, module, 0); + return (pointer) 1; +} + +/* was before: XF86ModuleData spaceorbModuleData = { &VersionRec, SetupProc, TearDownProc }; */ +XF86ModuleData spaceorbModuleData = { &VersionRec, SPACEORBSetupProc, TearDownProc }; + +#endif /* XFree86LOADER */ + + /* * Be sure to set vmin appropriately for your device's protocol. You want to * read a full packet before returning @@ -79,120 +154,111 @@ "Parity", "None", "Vmin", "5", "Vtime", "1", - "FlowControl", "None" + "FlowControl", "None", + NULL, }; static char spaceware[] = "0SpaceWare!"; -XF86ModuleData spaceorbModuleData = { &VersionRec, SetupProc, TearDownProc }; - /***************************************************************************** * Function Definitions ****************************************************************************/ - - -static void -TearDownProc( pointer p ) -{ - LocalDevicePtr local = (LocalDevicePtr) p; - SPACEORBPrivatePtr priv = (SPACEORBPrivatePtr) local->private; - - DeviceOff (local->dev); - - xf86RemoveLocalDevice (local); - - xf86CloseSerial (local->fd); - XisbFree (priv->buffer); - xfree (priv); - xfree (local->name); - xfree (local); -} - -static pointer -SetupProc( pointer module, - pointer options, - int *errmaj, - int *errmin ) -{ - LocalDevicePtr local = - xcalloc (1, sizeof (LocalDeviceRec)); - SPACEORBPrivatePtr priv = - xcalloc (1, sizeof (SPACEORBPrivateRec)); - pointer defaults, - merged; - - if ((!local) || (!priv)) - goto SetupProc_fail; - - defaults = xf86OptionListCreate (default_options, - (sizeof (default_options) / sizeof (default_options[0])), 0); - merged = xf86OptionListMerge (defaults, options); - xf86OptionListReport( merged ); - - local->fd = xf86OpenSerial (merged); - if (local->fd == -1) - { - ErrorF ("SPACEORB driver unable to open device\n"); - *errmaj = LDR_NOPORTOPEN; - *errmin = xf86GetErrno (); - goto SetupProc_fail; +static InputInfoPtr +SpaceorbPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +{ + InputInfoPtr pInfo; + SPACEORBPrivatePtr priv = xcalloc (1, sizeof (SPACEORBPrivateRec)); + + if (!priv) + return NULL; + + if (!(pInfo = xf86AllocateInput(drv, 0))) { + xfree(priv); + return NULL; } - - priv->buffer = XisbNew (local->fd, 200); - + + priv->lex_mode = SPACEORB_normal; + priv->packeti = 0; + priv->old_buttons=0; + priv->buffer= NULL; + + pInfo->type_name = XI_SPACEBALL; + pInfo->device_control = DeviceControl; + pInfo->read_input = ReadInput; + pInfo->control_proc = ControlProc; + pInfo->close_proc = CloseProc; + pInfo->switch_mode = SwitchMode; + pInfo->conversion_proc = ConvertProc; + pInfo->dev = NULL; + pInfo->private = priv; + pInfo->private_flags = 0; + pInfo->flags = 0; + pInfo->conf_idev = dev; + + xf86CollectInputOptions(pInfo, default_options, NULL); + + xf86OptionListReport( pInfo->options ); + + pInfo->fd = xf86OpenSerial (pInfo->options); + if (pInfo->fd == -1) + { + ErrorF ("SPACEORB driver unable to open device\n"); + goto SetupProc_fail; + } + + priv->buffer = XisbNew (pInfo->fd, 200); DBG (9, XisbTrace (priv->buffer, 1)); /* * Verify the hardware is attached and functional - */ - if (QueryHardware (priv, errmaj, errmin) != Success) - { - ErrorF ("Unable to query/initialize SpaceOrb hardware.\n"); - goto SetupProc_fail; - } - - /* this results in an xstrdup that must be freed later */ - local->name = xf86SetStrOption( merged, "DeviceName", "SpaceOrb XInput Device" ); - - local->type_name = XI_SPACEBALL; - /* - * Standard setup for the local device record */ - local->device_control = DeviceControl; - local->read_input = ReadInput; - local->control_proc = ControlProc; - local->close_proc = CloseProc; - local->switch_mode = SwitchMode; - local->conversion_proc = ConvertProc; - local->dev = NULL; - local->private = priv; - local->private_flags = 0; - local->history_size = xf86SetIntOption( merged, "HistorySize", 0 ); - - xf86AddLocalDevice( local, merged ); - - /* return the LocalDevice */ - return (local); + if (QueryHardware (priv) != Success) + { + ErrorF ("Unable to query/initialize SpaceOrb hardware.\n"); + goto SetupProc_fail; + } + + /* this results in an xstrdup that must be freed later */ + pInfo->name = xf86SetStrOption( pInfo->options, "DeviceName", "SpaceOrb XInput Device"); + pInfo->history_size = xf86SetIntOption( pInfo->options, "HistorySize", 0 ); + + xf86ProcessCommonOptions(pInfo, pInfo->options); + + pInfo->flags |= XI86_CONFIGURED; + return (pInfo); /* * If something went wrong, cleanup and return NULL */ SetupProc_fail: - if ((local) && (local->fd)) - xf86CloseSerial (local->fd); - if ((local) && (local->name)) - xfree (local->name); - if (local) - xfree (local); + if ((pInfo) && (pInfo->fd)) + xf86CloseSerial (pInfo->fd); + if ((pInfo) && (pInfo->name)) + xfree (pInfo->name); - if ((priv) && (priv->buffer)) - XisbFree (priv->buffer); + if ((priv) && (priv->buffer)) + XisbFree (priv->buffer); if (priv) - xfree (priv); - return (NULL); + xfree (priv); + return (pInfo); } +static void +TearDownProc( pointer p ) +{ + InputInfoPtr pInfo = (InputInfoPtr) p; + SPACEORBPrivatePtr priv = (SPACEORBPrivatePtr) pInfo->private; + + DeviceOff (pInfo->dev); + + xf86CloseSerial (pInfo->fd); + XisbFree (priv->buffer); + xfree (priv); + xfree (pInfo->name); + xfree (pInfo); +} + static Bool DeviceControl (DeviceIntPtr dev, int mode) { @@ -223,150 +289,159 @@ static Bool DeviceOn (DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + InputInfoPtr pInfo = dev->public.devicePrivate; - AddEnabledDevice (local->fd); - dev->public.on = TRUE; - return (Success); + AddEnabledDevice (pInfo->fd); + dev->public.on = TRUE; + return (Success); } static Bool DeviceOff (DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; + InputInfoPtr pInfo = dev->public.devicePrivate; - RemoveEnabledDevice (local->fd); - dev->public.on = FALSE; - return (Success); + RemoveEnabledDevice (pInfo->fd); + dev->public.on = FALSE; + return (Success); } + static Bool DeviceClose (DeviceIntPtr dev) { - return (Success); + return (Success); } static Bool DeviceInit (DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - unsigned char map[] = - {0, 1, 2, 3, 4, 5, 6, 7}; - - if (InitButtonClassDeviceStruct (dev, 7, map) == FALSE) - { - ErrorF ("Unable to allocate SPACEORB ButtonClassDeviceStruct\n"); - return !Success; - } + InputInfoPtr pInfo = dev->public.devicePrivate; - if (InitFocusClassDeviceStruct (dev) == FALSE) - { - ErrorF("Unable to allocate SPACEORB FocusClassDeviceStruct\n"); - return !Success; + unsigned char map[] = {0, 1, 2, 3, 4, 5, 6, 7}; + + if (InitButtonClassDeviceStruct (dev, 7, map) == FALSE) { + ErrorF ("Unable to allocate SPACEORB ButtonClassDeviceStruct\n"); + return !Success; + } + + if (InitFocusClassDeviceStruct (dev) == FALSE) { + ErrorF("Unable to allocate SPACEORB FocusClassDeviceStruct\n"); + return !Success; + } + + if (InitValuatorClassDeviceStruct (dev, 6, xf86GetMotionEvents, + pInfo->history_size, Absolute) == FALSE) + { + ErrorF ("Unable to allocate SPACEORB ValuatorClassDeviceStruct\n"); + return !Success; } - - - - if (InitValuatorClassDeviceStruct (dev, 6, xf86GetMotionEvents, - local->history_size, Absolute) == FALSE) - { - ErrorF ("Unable to allocate SPACEORB ValuatorClassDeviceStruct\n"); - return !Success; - } - else - { - InitValuatorAxisStruct(dev, 0, -512, 511, 9600,0,9600); - InitValuatorAxisStruct(dev, 1, -512, 511, 9600,0,9600); - InitValuatorAxisStruct(dev, 2, -512, 511, 9600,0,9600); - InitValuatorAxisStruct(dev, 3, -512, 511, 9600,0,9600); - InitValuatorAxisStruct(dev, 4, -512, 511, 9600,0,9600); - InitValuatorAxisStruct(dev, 5, -512, 511, 9600,0,9600); - } + else + { + InitValuatorAxisStruct(dev, 0, -512, 511, 9600,0,9600); + InitValuatorAxisStruct(dev, 1, -512, 511, 9600,0,9600); + InitValuatorAxisStruct(dev, 2, -512, 511, 9600,0,9600); + InitValuatorAxisStruct(dev, 3, -512, 511, 9600,0,9600); + InitValuatorAxisStruct(dev, 4, -512, 511, 9600,0,9600); + InitValuatorAxisStruct(dev, 5, -512, 511, 9600,0,9600); + } - /* - * Allocate the motion events buffer. - */ - xf86MotionHistoryAllocate (local); - return (Success); + /* + * Allocate the motion events buffer. + */ + xf86MotionHistoryAllocate (pInfo); + return (Success); } +/* + * The ReadInput function will have to be tailored to your device + */ static void ReadInput (LocalDevicePtr local) { - int x, y, z, u, v, r; - int buttons; - int i; - SPACEORBPrivatePtr priv = (SPACEORBPrivatePtr) (local->private); - - /* - * set blocking to -1 on the first call because we know there is data to - * read. Xisb automatically clears it after one successful read so that - * succeeding reads are preceeded buy a select with a 0 timeout to prevent - * read from blocking indefinately. - */ - XisbBlockDuration (priv->buffer, -1); - while (SPACEORBGetPacket (priv) == Success) + int x, y, z, u, v, r; + int buttons; + int i; + SPACEORBPrivatePtr priv = (SPACEORBPrivatePtr) (local->private); + + /* + * set blocking to -1 on the first call because we know there is data to + * read. Xisb automatically clears it after one successful read so that + * succeeding reads are preceeded buy a select with a 0 timeout to prevent + * read from blocking indefinately. + */ + XisbBlockDuration (priv->buffer, -1); + while (SPACEORBGetPacket (priv) == Success) + { + /* + * Examine priv->packet and call these functions as appropriate: + * + xf86PostMotionEvent + xf86PostButtonEvent + */ + switch (priv->packet_type) { - /* - * Examine priv->packet and call these functions as appropriate: - * - xf86PostMotionEvent - xf86PostButtonEvent - */ - switch (priv->packet_type) - { - case SPACEORB_D_PACKET: - /* Turn chars into 10 bit integers */ - x = ((priv->packet[1] & 0177)<<3)|((priv->packet[2] & 0160)>>4); - y = ((priv->packet[2] & 0017)<<6)|((priv->packet[3] & 0176)>>1); - z = ((priv->packet[3] & 0001)<<9)|((priv->packet[4] & 0177)<<2)|((priv->packet[5] & 0140)>>5); - u = ((priv->packet[5] & 0037)<<5)|((priv->packet[6] & 0174)>>2); - v = ((priv->packet[6] & 0003)<<8)|((priv->packet[7] & 0177)<<1)|((priv->packet[8] & 0100)>>6); - r = ((priv->packet[8] & 0077)<<4)|((priv->packet[9] & 0170)>>3); - - /* Get the sign right. */ - if (x > 511) x -= 1024; - if (y > 511) y -= 1024; - if (z > 511) z -= 1024; - if (u > 511) u -= 1024; - if (v > 511) v -= 1024; - if (r > 511) r -= 1024; - - xf86ErrorFVerb( 9, "SpaceOrb motion %d %d %d -- %d %d %d\n", - x, y, z, u, v, r ); - xf86PostMotionEvent(local->dev, TRUE, 0, 6, x, y, z, u, v, r); - break; - - case SPACEORB_K_PACKET: - buttons = priv->packet[1]; - if (priv->old_buttons != buttons) - for (i = 0; i < 7; i++) - { - if ((priv->old_buttons&(1<<i)) != (buttons&(1<<i))) - { - xf86PostButtonEvent(local->dev, FALSE, i+1, - (buttons&(1<<i)), 0, 0); - xf86ErrorFVerb( 9, "SpaceOrb setting button %d to %d\n", - i+1, (buttons&(1<<i)) ); - } - } - priv->old_buttons = buttons; - break; - } + case SPACEORB_D_PACKET: + /* Turn chars into 10 bit integers */ + x = ((priv->packet[1] & 0177)<<3)|((priv->packet[2] & 0160)>>4); + y = ((priv->packet[2] & 0017)<<6)|((priv->packet[3] & 0176)>>1); + z = ((priv->packet[3] & 0001)<<9)|((priv->packet[4] & 0177)<<2)|((priv->packet[5] & 0140)>>5); + u = ((priv->packet[5] & 0037)<<5)|((priv->packet[6] & 0174)>>2); + v = ((priv->packet[6] & 0003)<<8)|((priv->packet[7] & 0177)<<1)|((priv->packet[8] & 0100)>>6); + r = ((priv->packet[8] & 0077)<<4)|((priv->packet[9] & 0170)>>3); + + /* Get the sign right. */ + if (x > 511) x -= 1024; + if (y > 511) y -= 1024; + if (z > 511) z -= 1024; + if (u > 511) u -= 1024; + if (v > 511) v -= 1024; + if (r > 511) r -= 1024; + + xf86ErrorFVerb( 9, "SpaceOrb motion %d %d %d -- %d %d %d\n", + x, y, z, u, v, r ); + xf86PostMotionEvent(local->dev, TRUE, 0, 6, x, y, z, u, v, r); + break; + + case SPACEORB_K_PACKET: + buttons = priv->packet[1]; + if (priv->old_buttons != buttons) + for (i = 0; i < 7; i++) + { + if ((priv->old_buttons&(1<<i)) != (buttons&(1<<i))) + { + xf86PostButtonEvent(local->dev, FALSE, i+1, + (buttons&(1<<i)), 0, 0); + xf86ErrorFVerb( 9, "SpaceOrb setting button %d to %d\n", + i+1, (buttons&(1<<i)) ); + } + } + priv->old_buttons = buttons; + break; } + } } +/* + * The ControlProc function may need to be tailored for your device + */ static int ControlProc (LocalDevicePtr local, xDeviceCtl * control) { return (Success); } +/* + * the CloseProc should not need to be tailored to your device + */ static void CloseProc (LocalDevicePtr local) { } +/* + * The SwitchMode function may need to be tailored for your device + */ static int SwitchMode (ClientPtr client, DeviceIntPtr dev, int mode) { @@ -389,36 +464,40 @@ int *x, int *y) { - *x = v0; - *y = v1; + *x = v3; + *y = v4; return (Success); } +/* + * the QueryHardware fuction should be tailored to your device to + * verify the device is attached and functional and perform any + * needed initialization. + */ static Bool -QueryHardware (SPACEORBPrivatePtr priv, int *errmaj, int *errmin) +QueryHardware (SPACEORBPrivatePtr priv) { - /* - * When you open the serial port, the spaceorb sends a greeting packet - * make sure we got it to verify that the device is present. - * block for up to a second to make sure the data is there. - */ - XisbBlockDuration (priv->buffer, 1000000); - if ((SPACEORBGetPacket (priv) == Success) && - (priv->packet_type == SPACEORB_R_PACKET)) - return (Success); - else - { - ErrorF ("No response from SpaceOrb hardware.\n"); - *errmaj = LDR_NOHARDWARE; - return (!Success); - } + /* + * When you open the serial port, the spaceorb sends a greeting packet + * make sure we got it to verify that the device is present. + * block for up to a second to make sure the data is there. + */ + XisbBlockDuration (priv->buffer, 1000000); + if ((SPACEORBGetPacket (priv) == Success) && + (priv->packet_type == SPACEORB_R_PACKET)) + return (Success); + else + { + ErrorF ("No response from SpaceOrb hardware.\n"); + return (!Success); + } } static void NewPacket (SPACEORBPrivatePtr priv) { - priv->lex_mode = SPACEORB_normal; - priv->packeti = 0; + priv->lex_mode = SPACEORB_normal; + priv->packeti = 0; } static Bool @@ -429,79 +508,88 @@ while ((c = XisbRead (priv->buffer)) >= 0) { - /* - * fail after 500 bytes so the server doesn't hang forever if a - * device sends bad data. - */ - if (count++ > 500) + /* + * fail after 500 bytes so the server doesn't hang forever if a + * device sends bad data. + */ + if (count++ > 500) + { + NewPacket (priv); + return (!Success); + } + if (c == '\r') + continue; + + switch (priv->lex_mode) + { + case SPACEORB_normal: + if (c == SPACEORB_R_PACKET) { - NewPacket (priv); - return (!Success); + xf86ErrorFVerb( 9, "SpaceOrb got an R packet\n" ); + priv->packet_type = SPACEORB_R_PACKET; + priv->lex_mode = SPACEORB_body; + priv->expected_len = SPACEORB_R_BODY_LEN; } - if (c == '\r') - continue; - - switch (priv->lex_mode) + else if (c == SPACEORB_K_PACKET) { - case SPACEORB_normal: - if (c == SPACEORB_R_PACKET) - { - xf86ErrorFVerb( 9, "SpaceOrb got an R packet\n" ); - priv->packet_type = SPACEORB_R_PACKET; - priv->lex_mode = SPACEORB_body; - priv->expected_len = SPACEORB_R_BODY_LEN; - } - else if (c == 'K') - { - priv->packet_type = SPACEORB_K_PACKET; - priv->lex_mode = SPACEORB_body; - priv->expected_len = SPACEORB_K_BODY_LEN; - } - else if (c == 'D') - { - xf86ErrorFVerb( 9, "SpaceOrb got a D packet\n" ); - priv->packet_type = SPACEORB_D_PACKET; - priv->lex_mode = SPACEORB_Dbody; - priv->expected_len = SPACEORB_D_BODY_LEN; - } - break; - case SPACEORB_Dbody: - if (priv->packeti < priv->expected_len) - { - xf86ErrorFVerb( 9, "\t%d = %c data = %c %d\n", - priv->packeti, spaceware[priv->packeti], - (c & 0x7F), (c & 0x7F) ); - priv->packet[priv->packeti] = - (unsigned char) (c & 0x7F) ^ spaceware[priv->packeti]; - priv->packeti++; - } - if (priv->packeti == priv->expected_len) - { + priv->packet_type = SPACEORB_K_PACKET; + priv->lex_mode = SPACEORB_body; + priv->expected_len = SPACEORB_K_BODY_LEN; + } + else if (c == SPACEORB_D_PACKET) + { + xf86ErrorFVerb( 9, "SpaceOrb got a D packet\n" ); + priv->packet_type = SPACEORB_D_PACKET; + priv->lex_mode = SPACEORB_Dbody; + priv->expected_len = SPACEORB_D_BODY_LEN; + } + break; + case SPACEORB_Dbody: + if (priv->packeti < priv->expected_len) + { + xf86ErrorFVerb( 9, "\t%d = %c data = %c %d\n", + priv->packeti, spaceware[priv->packeti], + (c & 0x7F), (c & 0x7F) ); + priv->packet[priv->packeti] = + (unsigned char) (c & 0x7F) ^ spaceware[priv->packeti]; + priv->packeti++; + } + if (priv->packeti == priv->expected_len) + { #ifdef DEBUG ErrorF ("returning packet <"); -{ + { int i; for (i = 0; i < priv->expected_len; i++) ErrorF ("%c", priv->packet[i]); ErrorF (">\n"); } #endif - NewPacket (priv); + NewPacket (priv); return (Success); } break; - case SPACEORB_body: - if (priv->packeti < priv->expected_len) - priv->packet[priv->packeti++] = (unsigned char) c & 0x7F; - if (priv->packeti == priv->expected_len) - { - NewPacket (priv); - return (Success); - } - break; - + case SPACEORB_body: + if (priv->packeti < priv->expected_len) + priv->packet[priv->packeti++] = (unsigned char) c & 0x7F; + if (priv->packeti == priv->expected_len) + { + NewPacket (priv); + return (Success); } + break; + + } } return (!Success); } + + + + + + + + + Index: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h diff -u xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h:1.2 xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h:1.3 --- xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h:1.2 Mon Feb 1 07:13:00 1999 +++ xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h Fri Aug 11 15:10:47 2000 @@ -1,6 +1,8 @@ /* - * Copyright (c) 1998 Metro Link Incorporated + * Author: Guido Heumer <gheumer@hons.cs.usyd.edu.au> * + * Template driver used: Copyright (c) 1998 Metro Link Incorporated + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation @@ -24,12 +26,14 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h,v 1.2 1999/02/01 12:13:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/spaceorb/spaceorb.h,v 1.3 2000/08/11 19:10:47 dawes Exp $ */ #ifndef _SPACEORB_H_ #define _SPACEORB_H_ + +/* check if it works without -#include <xf86Module.h> +#include <xf86Module.h> */ /****************************************************************************** * Definitions @@ -66,7 +70,7 @@ /****************************************************************************** * Declarations *****************************************************************************/ -static MODULESETUPPROTO( SetupProc ); +static MODULESETUPPROTO(SPACEORBSetupProc); static void TearDownProc (pointer p); static Bool DeviceControl (DeviceIntPtr, int); static Bool DeviceOn (DeviceIntPtr); @@ -78,8 +82,12 @@ static void CloseProc (LocalDevicePtr); static int SwitchMode (ClientPtr, DeviceIntPtr, int); static Bool ConvertProc (LocalDevicePtr, int, int, int, int, int, int, int, int, int *, int *); -static Bool QueryHardware (SPACEORBPrivatePtr, int *, int *); +static Bool QueryHardware (SPACEORBPrivatePtr); +static void NewPacket (SPACEORBPrivatePtr priv); static Bool SPACEORBGetPacket (SPACEORBPrivatePtr priv); + +static InputInfoPtr +SpaceorbPreInit(InputDriverPtr drv, IDevPtr dev, int flags); /* * DO NOT PUT ANYTHING AFTER THIS ENDIF */ Index: xc/programs/Xserver/hw/xfree86/input/summa/Imakefile diff -u xc/programs/Xserver/hw/xfree86/input/summa/Imakefile:1.4 xc/programs/Xserver/hw/xfree86/input/summa/Imakefile:1.5 --- xc/programs/Xserver/hw/xfree86/input/summa/Imakefile:1.4 Sat Aug 14 06:50:03 1999 +++ xc/programs/Xserver/hw/xfree86/input/summa/Imakefile Fri Aug 11 15:10:47 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/summa/Imakefile,v 1.4 1999/08/14 10:50:03 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/summa/Imakefile,v 1.5 2000/08/11 19:10:47 dawes Exp $ #define IHaveModules #include <Server.tmpl> @@ -6,10 +6,10 @@ SRCS = xf86Summa.c OBJS = xf86Summa.o -DRIVER = xf86Summa +DRIVER = summa INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ - -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) + -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) Index: xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c diff -u xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c:1.3 xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c:1.4 --- xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c:1.3 Sun Jun 13 01:18:56 1999 +++ xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c Fri Aug 11 15:10:48 2000 @@ -20,8 +20,80 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c,v 1.3 1999/06/13 05:18:56 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/summa/xf86Summa.c,v 1.4 2000/08/11 19:10:48 dawes Exp $ */ +static const char identification[] = "$Identification: 18 $"; + +#include <xf86Version.h> + +#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(3,9,0,0,0) +#define XFREE86_V4 1 +#endif + +#ifdef XFREE86_V4 +/* post 3.9 headers */ + +#ifndef XFree86LOADER +#include <unistd.h> +#include <errno.h> +#endif + +#include <misc.h> +#include <xf86.h> +#define NEED_XF86_TYPES +#if !defined(DGUX) +#include <xf86_ansic.h> +#include <xisb.h> +#endif +#include <xf86_OSproc.h> +#include <xf86Xinput.h> +#include <exevents.h> /* Needed for InitValuator/Proximity stuff */ +#include <keysym.h> +#include <mipointer.h> + +#ifdef XFree86LOADER +#include <xf86Module.h> +#endif + +#undef memset +#define memset xf86memset +#undef sleep +#define sleep(t) xf86WaitForInput(-1, 1000 * (t)) +#define wait_for_fd(fd) xf86WaitForInput((fd), 1000) +#define tcflush(fd, n) xf86FlushInput((fd)) +#undef read +#define read(a,b,c) xf86ReadSerial((a),(b),(c)) +#undef write +#define write(a,b,c) xf86WriteSerial((a),(char*)(b),(c)) +#undef close +#define close(a) xf86CloseSerial((a)) +#define XCONFIG_PROBED "(==)" +#define XCONFIG_GIVEN "(**)" +#define xf86Verbose 1 +#undef PRIVATE +#define PRIVATE(x) XI_PRIVATE(x) + +/* + * Be sure to set vmin appropriately for your device's protocol. You want to + * read a full packet before returning + */ + +static const char *default_options[] = +{ + "BaudRate", "9600", + "DataBits", "8", + "StopBits", "1", + "Parity", "Odd", + "FlowControl", "Xoff", + "VTime", "10", + "VMin", "1", + NULL +}; + +static InputDriverPtr sumDrv; + +#else /* pre 3.9 headers */ + #define NEED_EVENTS #include "X.h" #include "Xproto.h" @@ -61,6 +133,7 @@ #include "extnsionst.h" #include "extinit.h" #endif +#endif /* ** Debugging macros @@ -72,7 +145,7 @@ #undef DEBUG #endif -static int debug_level = 0; +static int debug_level = 5; #define DEBUG 1 #if DEBUG #define DBG(lvl, f) {if ((lvl) <= debug_level) f;} @@ -111,6 +184,9 @@ ** Configuration data */ #define SUMMA_SECTION_NAME "SummaSketch" + +#ifndef XFREE86_V4 + #define PORT 1 #define DEVICENAME 2 #define THE_MODE 3 @@ -160,6 +236,8 @@ #endif +#endif /* Pre 3.9 headers */ + /* ** Contants and macro */ @@ -198,6 +276,9 @@ /* ** External declarations */ + +#ifndef XFREE86_V4 + #if defined(sun) && !defined(i386) #define ENQUEUE suneqEnqueue #else @@ -218,6 +299,10 @@ #endif ); +#endif + +#ifndef XFREE86_V4 + #if !defined(sun) || defined(i386) /* ** xf86SumConfig @@ -379,6 +464,7 @@ return Success; } #endif +#endif /* ** xf86SumConvert @@ -561,8 +647,10 @@ xf86SumWriteAndRead(int fd, char *data, char *buffer, int len, int cr_term) { int err, numread = 0; +#ifndef XFREE86_V4 fd_set readfds; struct timeval timeout; +#endif SYSCALL(err = write(fd, data, strlen(data))); if (err == -1) { @@ -570,17 +658,24 @@ return NULL; } +#ifndef XFREE86_V4 FD_ZERO(&readfds); FD_SET(fd, &readfds); +#endif while (numread < len) { +#ifndef XFREE86_V4 timeout.tv_sec = 0; timeout.tv_usec = 200000; SYSCALL(err = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout)); +#else + err = xf86WaitForInput(fd, 1000); +#endif if (err == -1) { Error("SummaSketch select"); return NULL; } + if (!err) { ErrorF("Timeout while reading SummaSketch tablet. No tablet connected ???\n"); return NULL; @@ -604,6 +699,7 @@ return buffer; } + /* ** xf86SumOpen ** Open and initialize the tablet, as well as probe for any needed data. @@ -611,21 +707,27 @@ static Bool xf86SumOpen(LocalDevicePtr local) { +#ifndef XFREE86_V4 struct termios termios_tty; struct timeval timeout; +#endif char buffer[256]; int err, idx; SummaDevicePtr priv = (SummaDevicePtr)local->private; DBG(1, ErrorF("opening %s\n", priv->sumDevice)); - +#ifdef XFREE86_V4 + local->fd = xf86OpenSerial(local->options); +#else SYSCALL(local->fd = open(priv->sumDevice, O_RDWR|O_NDELAY, 0)); +#endif if (local->fd == -1) { Error(priv->sumDevice); return !Success; } DBG(2, ErrorF("%s opened as fd %d\n", priv->sumDevice, local->fd)); +#ifndef XFREE86_V4 #ifdef POSIX_TTY err = tcgetattr(local->fd, &termios_tty); if (err == -1) { @@ -669,8 +771,14 @@ return !Success; } #else - Code for someone else to write to handle OSs without POSIX tty functions +#error Code for someone else to write to handle OSs without POSIX tty functions #endif +#else +/* if (xf86SetSerialSpeed(local->fd, 9600) < 0) { + return !Success; + } +*/ +#endif DBG(1, ErrorF("initializing SummaSketch tablet\n")); @@ -682,9 +790,13 @@ } /* wait 200 mSecs, just in case */ +#ifndef XFREE86_V4 timeout.tv_sec = 0; timeout.tv_usec = 200000; SYSCALL(err = select(0, NULL, NULL, NULL, &timeout)); +#else + err = xf86WaitForInput(-1, 200); +#endif if (err == -1) { Error("SummaSketch select"); return !Success; @@ -696,9 +808,12 @@ Error("SummaSketch write"); return !Success; } +#ifndef XFREE86_V4 /* Clear any pending input */ tcflush(local->fd, TCIFLUSH); - +#else + xf86FlushInput(local->fd); +#endif DBG(2, ErrorF("reading firmware ID\n")); if (!xf86SumWriteAndRead(local->fd, SS_FIRMID, buffer, 255, 1)) return !Success; @@ -887,8 +1002,9 @@ } /* allocate the motion history buffer if needed */ xf86MotionHistoryAllocate(local); - +#ifndef XFREE86_V4 AssignTypeAndName(pSum, local->atom, local->name); +#endif /* open the device to gather informations */ xf86SumOpenDevice(pSum); break; @@ -900,7 +1016,11 @@ return !Success; } SYSCALL(write(local->fd, SS_PROMPT, strlen(SS_PROMPT))); +#ifdef XFREE86_V4 + xf86AddEnabledDevice(local); +#else AddEnabledDevice(local->fd); +#endif pSum->public.on = TRUE; break; @@ -908,7 +1028,11 @@ DBG(1, ErrorF("xf86SumProc pSum=0x%x what=%s\n", pSum, (what == DEVICE_CLOSE) ? "CLOSE" : "OFF")); if (local->fd >= 0) - RemoveEnabledDevice(local->fd); +#ifdef XFREE86_V4 + xf86RemoveEnabledDevice(local); +#else + RemoveEnabledDevice(local->fd); +#endif pSum->public.on = FALSE; break; @@ -947,7 +1071,7 @@ ** When I figure out what it does, it will do it. */ static int -xf86SumChangeControl(LocalDevicePtr local, pointer control) +xf86SumChangeControl(LocalDevicePtr local, xDeviceCtl* control) { xDeviceResolutionCtl *res; @@ -1001,18 +1125,34 @@ static LocalDevicePtr xf86SumAllocate() { - LocalDevicePtr local = xalloc(sizeof(LocalDeviceRec)); - SummaDevicePtr priv = xalloc(sizeof(SummaDeviceRec)); + LocalDevicePtr local; + SummaDevicePtr priv; #if defined (sun) && !defined(i386) char *dev_name = getenv("SUMMASKETCH_DEV"); #endif + priv = xalloc(sizeof(SummaDeviceRec)); + if (!priv) + return NULL; + +#ifdef XFREE86_V4 + local = xf86AllocateInput(sumDrv, 0); +#else + local = xalloc(sizeof(LocalDeviceRec)); +#endif + if (!local) { + xfree(priv); + return NULL; + } + local->name = XI_NAME; local->type_name = "SummaSketch Tablet"; local->flags = 0; +#ifndef XFREE86_V4 #if !defined(sun) || defined(i386) local->device_config = xf86SumConfig; #endif +#endif local->device_control = xf86SumProc; local->read_input = xf86SumReadInput; local->control_proc = xf86SumChangeControl; @@ -1025,6 +1165,8 @@ local->private = priv; local->private_flags = 0; local->history_size = 0; + local->old_x = -1; + local->old_y = -1; #if defined(sun) && !defined(i386) if (def_name) { @@ -1048,13 +1190,13 @@ priv->sumXOffset = -1; /* active area X offset */ priv->sumYSize = -1; /* active area Y */ priv->sumYOffset = -1; /* active area U offset */ - priv->flags = 0; /* various flags */ + priv->flags = 0; /* various flags */ priv->sumIndex = 0; /* number of bytes read */ return local; } - +#ifndef XFREE86_V4 /* ** SummaSketch device association ** Device section name and allocation function. @@ -1089,45 +1231,224 @@ } #endif +#else + +/* + * xf86SumUninit -- + * + * called when the driver is unloaded. + */ +static void +xf86SumUninit(InputDriverPtr drv, + LocalDevicePtr local, + int flags) +{ + SummaDevicePtr priv = (SummaDevicePtr) local->private; + + DBG(1, ErrorF("xf86SumUninit\n")); + + xf86SumProc(local->dev, DEVICE_OFF); + + xfree (priv); + xf86DeleteInput(local, 0); +} + +/* + * xf86SumInit -- + * + * called when the module subsection is found in XF86Config + */ +static InputInfoPtr +xf86SumInit(InputDriverPtr drv, + IDevPtr dev, + int flags) +{ + LocalDevicePtr local = NULL; + SummaDevicePtr priv = NULL; + char *s; + + sumDrv = drv; + + DBG(1, ErrorF("xf86SumInit allocating...\n")); + + local = xf86SumAllocate(); + if (!local) + return NULL; + + local->conf_idev = dev; + + DBG(1, ErrorF("xf86SumInit CollectInputOptions...\n")); + xf86CollectInputOptions(local, default_options, NULL); + DBG(1, ErrorF("done.\n")); + xf86OptionListReport( local->options ); + + + priv = (SummaDevicePtr) local->private; + + local->name = dev->identifier; + + /* Serial Device is mandatory */ + priv->sumDevice = xf86FindOptionValue(local->options, "Device"); + + if (!priv->sumDevice) { + xf86Msg (X_ERROR, "%s: No Device specified.\n", dev->identifier); + goto SetupProc_fail; + } + + /* Process the common options. */ + xf86ProcessCommonOptions(local, local->options); + + /* Optional configuration */ + + xf86Msg(X_CONFIG, "%s serial device is %s\n", dev->identifier, + priv->sumDevice); + + debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); + if (debug_level > 0) { + xf86Msg(X_CONFIG, "Summa: debug level set to %d\n", debug_level); + } + + + + s = xf86FindOptionValue(local->options, "Mode"); + + if (s && (xf86NameCmp(s, "absolute") == 0)) { + priv->flags = priv->flags | ABSOLUTE_FLAG; + } + else if (s && (xf86NameCmp(s, "relative") == 0)) { + priv->flags = priv->flags & ~ABSOLUTE_FLAG; + } + else if (s) { + xf86Msg(X_ERROR, "%s: invalid Mode (should be absolute or relative). " + "Using default.\n", dev->identifier); + } + xf86Msg(X_CONFIG, "%s is in %s mode\n", local->name, + (priv->flags & ABSOLUTE_FLAG) ? "absolute" : "relative"); + + + s = xf86FindOptionValue(local->options, "Cursor"); + + if (s && (xf86NameCmp(s, "stylus") == 0)) { + priv->flags = priv->flags | STYLUS_FLAG; + } + else if (s && (xf86NameCmp(s, "puck") == 0)) { + priv->flags = priv->flags & ~STYLUS_FLAG; + } + else if (s) { + xf86Msg(X_ERROR, "%s: invalid Cursor (should be stylus or puck). " + "Using default.\n", dev->identifier); + } + xf86Msg(X_CONFIG, "%s is in cursor-mode %s\n", local->name, + (priv->flags & STYLUS_FLAG) ? "cursor" : "puck"); + + priv->sumXSize = xf86SetIntOption(local->options, "XSize", 0); + if (priv->sumXSize != 0) { + xf86Msg(X_CONFIG, "%s: XSize = %d\n", + dev->identifier, priv->sumXSize); + } + + priv->sumYSize = xf86SetIntOption(local->options, "YSize", 0); + if (priv->sumYSize != 0) { + xf86Msg(X_CONFIG, "%s: YSize = %d\n", + dev->identifier, priv->sumYSize); + } + + priv->sumXOffset = xf86SetIntOption(local->options, "XOffset", 0); + if (priv->sumXOffset != 0) { + xf86Msg(X_CONFIG, "%s: XOffset = %d\n", + dev->identifier, priv->sumXOffset); + } + + priv->sumYOffset = xf86SetIntOption(local->options, "YOffset", 0); + if (priv->sumYOffset != 0) { + xf86Msg(X_CONFIG, "%s: YOffset = %d\n", + dev->identifier, priv->sumYOffset); + } + + /* mark the device configured */ + local->flags |= XI86_POINTER_CAPABLE | XI86_CONFIGURED; + + /* return the LocalDevice */ + return local; + + SetupProc_fail: + if (priv) + xfree(priv); + return local; +} + +#ifdef XFree86LOADER +static +#endif +InputDriverRec SUMMA = { + 1, /* driver version */ + "summa", /* driver name */ + NULL, /* identify */ + xf86SumInit, /* pre-init */ + xf86SumUninit, /* un-init */ + NULL, /* module */ + 0 /* ref count */ +}; + + +/* + *************************************************************************** + * + * Dynamic loading functions + * + *************************************************************************** + */ #ifdef XFree86LOADER /* - * Entry point for the loader code + * xf86SumUnplug -- + * + * called when the module subsection is found in XF86Config */ -XF86ModuleVersionInfo xf86SummaVersion = { - "xf86Summa", +static void +xf86SumUnplug(pointer p) +{ + DBG(1, ErrorF("xf86SumUnplug\n")); +} + +/* + * xf86SumPlug -- + * + * called when the module subsection is found in XF86Config + */ +static pointer +xf86SumPlug(pointer module, + pointer options, + int *errmaj, + int *errmin) +{ + DBG(1, ErrorF("xf86SumPlug\n")); + + xf86AddInputDriver(&SUMMA, module, 0); + + return module; +} + +static XF86ModuleVersionInfo xf86SumVersionRec = +{ + "summa", MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XF86_VERSION_CURRENT, - 0x00010000, - {0,0,0,0} + 1, 0, 0, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + {0, 0, 0, 0} /* signature, to be patched into the file by */ + /* a tool */ }; -void -xf86SummaModuleInit(data, magic) - pointer *data; - INT32 *magic; -{ - static int cnt = 0; - - switch (cnt) { - case 0: - *magic = MAGIC_VERSION; - *data = &xf86SummaVersion; - cnt++; - break; - - case 1: - *magic = MAGIC_ADD_XINPUT_DEVICE; - *data = &summasketch_assoc; - cnt++; - break; - - default: - *magic = MAGIC_DONE; - *data = NULL; - break; - } -} -#endif +XF86ModuleData summaModuleData = {&xf86SumVersionRec, + xf86SumPlug, + xf86SumUnplug}; + +#endif /* XFree86LOADER */ +#endif /* XFREE86_V4 */ + + /* end of xf86Summa.c */ Index: xc/programs/Xserver/hw/xfree86/input/void/void.c diff -u xc/programs/Xserver/hw/xfree86/input/void/void.c:1.1 xc/programs/Xserver/hw/xfree86/input/void/void.c:1.2 --- xc/programs/Xserver/hw/xfree86/input/void/void.c:1.1 Fri Nov 19 08:54:57 1999 +++ xc/programs/Xserver/hw/xfree86/input/void/void.c Fri Aug 11 15:10:48 2000 @@ -1,4 +1,3 @@ -/* $XConsortium$ */ /* * Copyright 1999 by Frederic Lepied, France. <Lepied@XFree86.org> * @@ -22,7 +21,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.c,v 1.1 1999/11/19 13:54:57 hohndel Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.c,v 1.2 2000/08/11 19:10:48 dawes Exp $ */ /* Input device which doesn't output any event. This device can be used * as a core pointer or as a core keyboard. Index: xc/programs/Xserver/hw/xfree86/input/void/void.cpp diff -u xc/programs/Xserver/hw/xfree86/input/void/void.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/void/void.cpp:1.5 --- xc/programs/Xserver/hw/xfree86/input/void/void.cpp:1.4 Tue Jun 13 22:13:19 2000 +++ xc/programs/Xserver/hw/xfree86/input/void/void.cpp Mon Dec 11 15:18:56 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.cpp,v 1.4 2000/06/14 02:13:19 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.cpp,v 1.5 2000/12/11 20:18:56 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH VOID __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH VOID __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME void \- null input driver .SH SYNOPSIS Index: xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile diff -u xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile:1.6 xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile:1.7 --- xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile:1.6 Thu Mar 2 20:05:51 2000 +++ xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile Fri Dec 1 12:43:06 2000 @@ -1,8 +1,12 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile,v 1.6 2000/03/03 01:05:51 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/Imakefile,v 1.7 2000/12/01 17:43:06 dawes Exp $ #define IHaveModules #include <Server.tmpl> +#if HasLinuxInput +DEFINES = -DLINUX_INPUT +#endif + SRCS = xf86Wacom.c OBJS = xf86Wacom.o @@ -25,6 +29,11 @@ CppManTarget($(DRIVER),) InstallModuleManPage($(DRIVER)) #endif + +XCOMM Build a standalone executable to be able to test the driver without +XCOMM a running X server. +LinkFile(testwacom.c,xf86Wacom.c) +SpecialCObjectRule(testwacom,NullParameter,-DTEST) DependTarget() Index: xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp diff -u xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp:1.4 xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp:1.9 --- xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp:1.4 Tue Jun 13 22:13:19 2000 +++ xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp Sun Dec 17 19:17:18 2000 @@ -1,7 +1,7 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp,v 1.4 2000/06/14 02:13:19 dawes Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp,v 1.9 2000/12/18 00:17:18 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' -.TH WACOM __drivermansuffix__ "Version 4.0.1" "XFree86" +.TH WACOM __drivermansuffix__ "Version 4.0.2" "XFree86" .SH NAME wacom \- Wacom input driver .SH SYNOPSIS @@ -15,22 +15,102 @@ .fi .SH DESCRIPTION .B wacom -is an XFree86 input driver for Wacom devices... +is an XFree86 input driver for Wacom devices. .PP The .B wacom driver functions as a pointer input device, and may be used as the X server's core pointer. -THIS MAN PAGE NEEDS TO BE FILLED IN. .SH SUPPORTED HARDWARE -What is supported... +This driver supports the Wacom IV and Wacom V protocols. +Preliminary support is available for USB devices on some Linux platforms. .SH CONFIGURATION DETAILS Please refer to XF86Config(__filemansuffix__) for general configuration details and for options that can be used with all input drivers. This section only covers configuration details specific to this driver. .PP -Config details... +Multiple instances of the Wacom devices can cohabit. It can be useful +to define multiple devices with different active zones. Each device +supports the following entries: +.RS 8 +.TP 4 +.B Option \fI"Type"\fP \fI"stylus"|"eraser"|"cursor"\fP +sets the type of tool the device represent. This option is mandatory. +.TP 4 +.B Option \fI"Device"\fP \fI"path"\fP +sets the path to the special file which represents serial line where +the tablet is plugged. You have to specify it for each subsection with +the same value if you want to have multiple devices with the same tablet. +This option is mandatory. +.TP 4 +.B Option \fI"USB"\fP \fI"on"\fP +tells the driver to dialog with the tablet the USB way. This option is +only available on some Linux platforms. +.TP 4 +.B Option \fI"DeviceName"\fP \fI"name"\fP +sets the name of the X device. +.TP 4 +.B Option \fI"Suppress"\fP \fI"Inumber"\fP +sets the position increment under which not to transmit coordinates. +This entry must be specified only in the first Wacom subsection if you have +multiple devices for one tablet. If you don't specify this entry, the default value +is computed to +.TP 4 +.B Option \fI"Mode"\fP \fI"Relative"|"Absolute"\fP +sets the mode of the device. +.TP 4 +.B Option \fI"Tilt"\fP \fI"on"\fP +enables tilt report if your tablet supports it (ROM version 1.4 and above). +If this is enabled, multiple devices at the same time will not be reported. +.TP 4 +.B Option \fI"HistorySize"\fP \fI"number"\fP +sets the motion history size. By default the value is zero. +.TP 4 +.B Option \fI"AlwaysCore"\fP \fI"on"\fP +enables the sharing of the core pointer. When this feature is enabled, the +device will take control of the core pointer (and thus will emit core events) +and at the same time will be able, when asked so, to report extended events. +You can use the last available integer feedback to control this feature. When +the value of the feedback is zero, the feature is disabled. The feature is +enabled for any other value. +.TP 4 +.B Option \fI"TopX"\fP \fI"number"\fP +X coordinate of the top corner of the active zone. +.TP 4 +.B Option \fI"TopY"\fP \fI"number"\fP +Y coordinate of the top corner of the active zone. +.TP 4 +.B Option \fI"BottomX"\fP \fI"Inumber"\fP +X coordinate of the bottom corner of the active zone. +.TP 4 +.B Option \fI"BottomY"\fP \fI"number"\fP +Y coordinate of the bottom corner of the active zone. +.TP 4 +.B Option \fI"KeepShape"\fP \fI"on"\fP +When this option is enabled, the active zone begins according to TopX +and TopY. The bottom corner is adjusted to keep the ratio width/height +of the active zone the same as the screen while maximizing the area +described by TopX, TopY, BottomX, BottomY. +.TP 4 +.B Option \fI"DebugLevel"\fP \fInumber \fP +sets the level of debugging info reported. +.TP 4 +.B Option \fI"BaudRate"\fP \fI"38400"\fP, \fI"19200"\fP or \fI"9600"\fP (default) +changes the serial link speed. This option is only available for +wacom V models (Intuos). +.TP 4 +.B Option \fI"Serial"\fP \fI"number"\fP +sets the serial number associated with the physical device. This allows +to have multiple devices of the same type (i.e. multiple pens). This +option is only available on wacom V devices (Intuos). To see which +serial number belongs to a device, you have to set the DebugLevel to 6 and +watch the output of the X server. +.TP 4 +.B Option \fI"Threshold"\fP \fI"number"\fP +sets the pressure threshold used to generate a button 1 events of stylus +devices for some models of tablets (Intuos and Graphire). +.RE .SH "SEE ALSO" XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__). .SH AUTHORS -Authors include... +Frederic Lepied <lepied@xfree86.org> Index: xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c diff -u xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c:1.18 xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c:1.24 --- xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c:1.18 Fri Mar 3 15:36:42 2000 +++ xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c Thu Dec 7 15:26:24 2000 @@ -1,6 +1,6 @@ /* $XConsortium: xf86Wacom.c /main/20 1996/10/27 11:05:20 kaleb $ */ /* - * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org> + * Copyright 1995-2000 by Frederic Lepied, France. <Lepied@XFree86.org> * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c,v 1.18 2000/03/03 20:36:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/xf86Wacom.c,v 1.24 2000/12/07 20:26:24 dawes Exp $ */ /* * This driver is only able to handle the Wacom IV and Wacom V protocols. @@ -32,6 +32,13 @@ * * Many thanks to Dave Fleck from Wacom for the help provided to * build this driver. + * + * Modified for Linux USB by MATSUMURA Namihiko. + * Daniel Egger, Germany. <egger@suse.de>, + * Frederic Lepied <lepied@xfree86.org>. + * Brion Vibber <brion@pobox.com>, + * Aaron Optimizer Digulla <digulla@hepe.com> + * */ /* @@ -49,7 +56,7 @@ * */ -static const char identification[] = "$Identification: 18 $"; +static const char identification[] = "$Identification: 20 $"; #include <xf86Version.h> @@ -57,6 +64,19 @@ #define XFREE86_V4 1 #endif +#ifdef LINUX_INPUT +#include <asm/types.h> +#include <linux/input.h> + +/* keithp - a hack to avoid redefinitions of these in xf86str.h */ +#ifdef BUS_PCI +#undef BUS_PCI +#endif +#ifdef BUS_ISA +#undef BUS_ISA +#endif +#endif + #ifdef XFREE86_V4 /* post 3.9 headers */ @@ -82,8 +102,6 @@ #include <xf86Module.h> #endif -#undef memset -#define memset xf86memset #undef sleep #define sleep(t) xf86WaitForInput(-1, 1000 * (t)) #define wait_for_fd(fd) xf86WaitForInput((fd), 1000) @@ -290,6 +308,9 @@ int wcmThreshold; /* Threshold for counting pressure as a button */ WacomDeviceState wcmDevStat[2]; /* device state for each tool */ int wcmInitNumber; /* magic number for the init phasis */ + unsigned int wcmLinkSpeed; /* serial link speed */ + Bool (*wcmOpen)(LocalDevicePtr /*local*/); /* function used to open the line (serial or USB) */ + unsigned int wcmLastSerial; /* last device (used by the USB part) */ } WacomCommonRec, *WacomCommonPtr; /****************************************************************************** @@ -323,6 +344,7 @@ #define RESOLUTION_X 20 #define RESOLUTION_Y 21 #define RESOLUTION_Z 22 +#define USB 23 #if !defined(sun) || defined(i386) static SymTabRec WcmTab[] = { @@ -349,6 +371,7 @@ { RESOLUTION_X, "resolutionx" }, { RESOLUTION_Y, "resolutiony" }, { RESOLUTION_Z, "resolutionz" }, + { USB, "usb" }, { -1, "" } }; @@ -368,6 +391,7 @@ /****************************************************************************** * constant and macros declarations *****************************************************************************/ +#define DEFAULT_MAXZ 240 /* default value of MaxZ when nothing is configured */ #define BUFFER_SIZE 256 /* size of reception buffer */ #define XI_STYLUS "STYLUS" /* X device name for the stylus */ #define XI_CURSOR "CURSOR" /* X device name for the cursor */ @@ -410,6 +434,7 @@ #define WC_V_MULTI "MT1\r" #define WC_V_ID "ID1\r" #define WC_V_19200 "BA19\r" +#define WC_V_38400 "BA38\r" /* #define WC_V_9600 "BA96\r" */ #define WC_V_9600 "$\r" @@ -530,7 +555,6 @@ #endif #ifndef XFREE86_V4 -#if !defined(sun) || defined(i386) /* *************************************************************************** * @@ -717,11 +741,14 @@ if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Option number expected"); switch(val->num) { + case 38400: + common->wcmLinkSpeed = 38400; + break; case 19200: - common->wcmFlags = common->wcmFlags | BAUD_19200_FLAG; + common->wcmLinkSpeed = 19200; break; case 9600: - common->wcmFlags = common->wcmFlags & ~BAUD_19200_FLAG; + common->wcmLinkSpeed = 9600; break; default: xf86ConfigError("Illegal speed value"); @@ -791,6 +818,16 @@ ErrorF("%s Wacom resolution y = %d\n", XCONFIG_GIVEN, common->wcmResolZ); break; + case USB: +#ifdef LINUX_INPUT + local->read_input=xf86WcmReadUSBInput; + common->wcmOpen=xf86WcmUSBOpen; + ErrorF("%s Wacom reading USB link\n", XCONFIG_GIVEN); +#else + ErrorF("The USB version of the driver isn't available for your platform\n"); +#endif + break; + case EOF: FatalError("Unexpected EOF (missing EndSubSection)"); break; @@ -805,7 +842,6 @@ return Success; } -#endif #endif /* Pre 3.9 stuff */ #if 0 @@ -1721,17 +1757,17 @@ ((common->wcmData[3] & ZAXIS_BIT) >> 2); if (common->wcmMaxZ == 512) { - z = z*2 + ((common->wcmData[0] & ZAXIS_BIT) >> 2); + z = z*4 + ((common->wcmData[0] & ZAXIS_BIT) >> 1); - if (common->wcmData[6] & ZAXIS_SIGN_BIT) { - z -= 256; + if (!(common->wcmData[6] & ZAXIS_SIGN_BIT)) { + z += 256; } DBG(10, ErrorF("graphire pressure(%c)=%d\n", (common->wcmData[6] & ZAXIS_SIGN_BIT) ? '-' : '+', z)); } else { - if (common->wcmData[6] & ZAXIS_SIGN_BIT) { - z -= 128; + if (!(common->wcmData[6] & ZAXIS_SIGN_BIT)) { + z += (common->wcmMaxZ / 2); } } @@ -1939,7 +1975,7 @@ ((common->wcmData[5] & 0x78) >> 3)); if ((common->wcmData[0] & 0xb8) == 0xa0) { ds->pressure = (((common->wcmData[5] & 0x07) << 7) | - (common->wcmData[6] & 0x7f)) - 512; + (common->wcmData[6] & 0x7f)); ds->buttons = (((common->wcmData[0]) & 0x06) | (ds->pressure >= common->wcmThreshold)); } @@ -2044,6 +2080,246 @@ local, priv, common->wcmIndex)); } +#ifdef LINUX_INPUT +/* + *************************************************************************** + * + * xf86WcmReadUSBInput -- + * Read the new events from the device, and enqueue them. + * + *************************************************************************** + */ +static void +xf86WcmReadUSBInput(LocalDevicePtr local) +{ + WacomDevicePtr priv = (WacomDevicePtr) local->private; + WacomCommonPtr common = priv->common; + int serial = common->wcmLastSerial; + int is_proximity = priv->oldProximity; + int x = priv->oldX; + int y = priv->oldY; + int pressure = priv->oldZ; + int buttons = priv->oldButtons; + int tilt_x = priv->oldTiltX; + int tilt_y = priv->oldTiltY; + int wheel = priv->oldWheel; + + ssize_t len; + int idx; + struct input_event * event; + char eventbuf[BUFFER_SIZE]; +#define MOD_BUTTONS(bit, value) \ + { int _b=bit, _v=value; buttons = (((_v) != 0) ? (buttons | _b) : (buttons & ~ _b)); } + + SYSCALL(len = read(local->fd, eventbuf, BUFFER_SIZE)); + + if (len <= 0) { + ErrorF("Error reading wacom device : %s\n", strerror(errno)); + return; + } + + for (event=(struct input_event *)eventbuf; + event<(struct input_event *)(eventbuf+len); event++) { + DBG(10, ErrorF("event->type=%d\n", event->type)); + + switch (event->type) { + case EV_ABS: + DBG(10, ErrorF("event->code=%d\n", event->code)); + switch (event->code) { + case ABS_X: + x = event->value; + break; + + case ABS_Y: + y = event->value; + break; + + case ABS_TILT_X: + tilt_x = event->value; + break; + + case ABS_TILT_Y: + tilt_y = event->value; + break; + + case ABS_PRESSURE: + pressure = event->value; + break; + + case ABS_DISTANCE: + /* This is not sent by the driver */ + break; + } + break; /* EV_ABS */ + + case EV_REL: + switch (event->code) { + case REL_WHEEL: + /* FIXME */ + break; + default: + ErrorF("wacom: relative event received (%d)!!!\n", event->code); + break; + } + break; /* EV_REL */ + + case EV_KEY: + switch (event->code) { + case BTN_TOOL_PEN: + common->wcmIndex = STYLUS_ID; + is_proximity = (event->value != 0); + break; + + case BTN_TOOL_RUBBER: + common->wcmIndex = ERASER_ID; + is_proximity = (event->value != 0); + break; + + case BTN_TOOL_MOUSE: + common->wcmIndex = CURSOR_ID; + is_proximity = (event->value != 0); + break; + + case BTN_TOUCH: + MOD_BUTTONS (1, event->value); + break; + + case BTN_STYLUS: + MOD_BUTTONS (2, event->value); + break; + + case BTN_STYLUS2: + MOD_BUTTONS (4, event->value); + break; + + case BTN_LEFT: + MOD_BUTTONS (1, event->value); + break; + + case BTN_RIGHT: + MOD_BUTTONS (2, event->value); + break; + + case BTN_MIDDLE: + MOD_BUTTONS (4, event->value); + break; + } + break; /* EV_KEY */ + } + + if ((is_proximity == priv->oldProximity) && + (buttons == priv->oldButtons) && + (ABS(x - priv->oldX) <= common->wcmSuppress) && + (ABS(y - priv->oldY) <= common->wcmSuppress) && + (ABS(pressure - priv->oldZ) < 3) && + (ABS(tilt_x - priv->oldTiltX) < 3) && + (ABS(tilt_y - priv->oldTiltY) < 3)) { + DBG(10, ErrorF("filtered\n")); + continue; + } + + for (idx=0; idx<common->wcmNumDevices; idx++) { + WacomDevicePtr dev = common->wcmDevices[idx]->private; + int id; + + id = DEVICE_ID (dev->flags); + + /* Find the device the current events are meant for */ + if (id == common->wcmIndex) { + xf86WcmSendEvents(common->wcmDevices[idx], + common->wcmIndex, + serial, + (common->wcmIndex == STYLUS_ID || common->wcmIndex == ERASER_ID), + !!(buttons), + is_proximity, + x, y, pressure, buttons, + tilt_x, tilt_y, wheel + ); + } + } + priv->oldX = x; + priv->oldY = y; + priv->oldZ = pressure; + priv->oldTiltX = tilt_x; + priv->oldTiltY = tilt_y; + priv->oldProximity = is_proximity; + priv->oldButtons = buttons; + priv->oldWheel = wheel; + common->wcmLastSerial = serial; + } +} + +/* + *************************************************************************** + * + * xf86WcmUSBOpen -- + * + *************************************************************************** + */ +static Bool +xf86WcmUSBOpen(LocalDevicePtr local) +{ + int err = 0; + WacomDevicePtr priv = (WacomDevicePtr)local->private; + WacomCommonPtr common = priv->common; + +#ifdef XFREE86_V4 + local->fd = xf86OpenSerial(local->options); +#else + SYSCALL(local->fd = open(common->wcmDevice, O_RDONLY|O_NDELAY, 0)); +#endif + if (local->fd == -1) { + ErrorF("Error opening %s : %s\n", common->wcmDevice, strerror(errno)); + return !Success; + } + + DBG(2, ErrorF("setup is max X=%d max Y=%d resol X=%d resol Y=%d\n", + common->wcmMaxX, common->wcmMaxY, common->wcmResolX, + common->wcmResolY)); + + /* send the tilt mode command after setup because it must be enabled */ + /* after multi-mode to take precedence */ + if (HANDLE_TILT(common)) { + /* Unfortunately, the USB driver doesn't allow to send this + * command to the tablet. Any other solutions ? */ + DBG(2, ErrorF("Sending tilt mode order\n")); + } + + { + if (common->wcmSuppress < 0) { + common->wcmSuppress = 0; + } else { + if (common->wcmSuppress > 100) { + common->wcmSuppress = 99; + } + } + /* Cannot send WC_SUPPRESS to the table. Will have to do + * this manually. */ + } + + priv->topX = 0; + priv->bottomX = common->wcmMaxX; + priv->topY = 0; + priv->bottomY = common->wcmMaxY; + + if (xf86Verbose) + ErrorF("%s Wacom tablet maximum X=%d maximum Y=%d " + "X resolution=%d Y resolution=%d suppress=%d%s\n", + XCONFIG_PROBED, common->wcmMaxX, common->wcmMaxY, + common->wcmResolX, common->wcmResolY, common->wcmSuppress, + HANDLE_TILT(common) ? " Tilt" : ""); + + if (err < 0) { + ErrorF("ERROR: %d\n", err); + SYSCALL(close(local->fd)); + return !Success; + } + + return Success; +} + +#endif /* LINUX_INPUT */ + /* *************************************************************************** * @@ -2113,6 +2389,36 @@ DBG(1, ErrorF("initializing tablet\n")); + /* Set the speed of the serial link to 38400 */ +#ifdef XFREE86_V4 + if (xf86SetSerialSpeed(local->fd, 38400) < 0) { + return !Success; + } +#else + if (set_serial_speed(local->fd, B38400) == !Success) + return !Success; +#endif + + /* Send reset to the tablet */ + SYSCALL(err = write(local->fd, WC_RESET_BAUD, strlen(WC_RESET_BAUD))); + if (err == -1) { + ErrorF("Wacom write error : %s\n", strerror(errno)); + return !Success; + } + + /* Wait 250 mSecs */ + WAIT(250); + + /* Send reset to the tablet */ + SYSCALL(err = write(local->fd, WC_RESET, strlen(WC_RESET))); + if (err == -1) { + ErrorF("Wacom write error : %s\n", strerror(errno)); + return !Success; + } + + /* Wait 75 mSecs */ + WAIT(75); + /* Set the speed of the serial link to 19200 */ #ifdef XFREE86_V4 if (xf86SetSerialSpeed(local->fd, 19200) < 0) { @@ -2201,7 +2507,7 @@ if (buffer[2] == 'G' && buffer[3] == 'D') { DBG(2, ErrorF("detected an Intuos model\n")); common->wcmProtocolLevel = 5; - common->wcmMaxZ = 1024; /* max Z value */ + common->wcmMaxZ = 1023; /* max Z value */ common->wcmResolX = 2540; /* X resolution in points/inch */ common->wcmResolY = 2540; /* Y resolution in points/inch */ common->wcmResolZ = 2540; /* Z resolution in points/inch */ @@ -2264,7 +2570,6 @@ ErrorF("WACOM: unable to read resolution. Using default.\n"); common->wcmResolX = common->wcmResolY = 1270; } - } if (!(common->wcmFlags & GRAPHIRE_FLAG) && !(common->wcmMaxX && common->wcmMaxY)) { @@ -2396,12 +2701,37 @@ } /* change the serial speed if requested */ - if (common->wcmFlags & BAUD_19200_FLAG) { + if (common->wcmLinkSpeed > 9600) { if (common->wcmProtocolLevel == 5) { - DBG(1, ErrorF("Switching serial link to 19200\n")); - - /* Switch the tablet to 19200 */ - SYSCALL(err = write(local->fd, WC_V_19200, strlen(WC_V_19200))); + char *speed_init_string = WC_V_19200; +#ifndef XFREE86_V4 + int speed = B19200; +#endif + DBG(1, ErrorF("Switching serial link to %d\n", common->wcmLinkSpeed)); + + if (common->wcmLinkSpeed == 38400 && version < 2.0) { + ErrorF("Wacom: 38400 speed not supported with this Intuos firmware (%f)\n", version); + ErrorF("Switching to 19200\n"); + common->wcmLinkSpeed = 19200; + } + + switch (common->wcmLinkSpeed) { + case 38400: + speed_init_string = WC_V_38400; +#ifndef XFREE86_V4 + speed = B38400; +#endif + break; + + case 19200: + speed_init_string = WC_V_19200; +#ifndef XFREE86_V4 + speed = B19200; +#endif + break; + } + /* Switch the tablet to the requested speed */ + SYSCALL(err = write(local->fd, speed_init_string, strlen(speed_init_string))); if (err == -1) { ErrorF("Wacom write error : %s\n", strerror(errno)); return !Success; @@ -2410,13 +2740,13 @@ /* Wait 75 mSecs */ WAIT(75); - /* Set the speed of the serial link to 19200 */ + /* Set the speed of the serial link to requested speed */ #ifdef XFREE86_V4 - if (xf86SetSerialSpeed(local->fd, 19200) < 0) { + if (xf86SetSerialSpeed(local->fd, common->wcmLinkSpeed) < 0) { return !Success; } #else - if (set_serial_speed(local->fd, B19200) == !Success) + if (set_serial_speed(local->fd, speed) == !Success) return !Success; #endif } @@ -2457,7 +2787,7 @@ if (local->fd < 0) { if (common->wcmInitNumber > 2 || priv->initNumber == common->wcmInitNumber) { - if (xf86WcmOpen(local) != Success) { + if (common->wcmOpen(local) != Success) { if (local->fd >= 0) { SYSCALL(close(local->fd)); } @@ -2552,39 +2882,39 @@ /* Check threshold correctness */ DBG(2, ErrorF("Threshold=%d\n", common->wcmThreshold)); - if (common->wcmThreshold > ((common->wcmMaxZ / 2) - 1) || - common->wcmThreshold < - (common->wcmMaxZ / 2)) { + if (common->wcmThreshold > common->wcmMaxZ || + common->wcmThreshold < 0) { if (((common->wcmProtocolLevel == 5) || (common->wcmFlags & GRAPHIRE_FLAG)) && xf86Verbose && common->wcmThreshold != INVALID_THRESHOLD) ErrorF("%s Wacom invalid threshold %d. Reset to %d\n", - XCONFIG_PROBED, common->wcmThreshold, - (common->wcmMaxZ / 3)); - common->wcmThreshold = - (common->wcmMaxZ / 3); + XCONFIG_PROBED, common->wcmThreshold, common->wcmMaxZ / 3); + common->wcmThreshold = common->wcmMaxZ / 3; } DBG(2, ErrorF("New threshold=%d\n", common->wcmThreshold)); /* Set the real values */ InitValuatorAxisStruct(pWcm, 0, - 0, /* min val */ + 0, /* min val */ priv->bottomX - priv->topX, /* max val */ mils(common->wcmResolX), /* resolution */ - 0, /* min_res */ + 0, /* min_res */ mils(common->wcmResolX)); /* max_res */ InitValuatorAxisStruct(pWcm, 1, - 0, /* min val */ + 0, /* min val */ priv->bottomY - priv->topY, /* max val */ mils(common->wcmResolY), /* resolution */ - 0, /* min_res */ + 0, /* min_res */ mils(common->wcmResolY)); /* max_res */ InitValuatorAxisStruct(pWcm, 2, - - common->wcmMaxZ / 2, /* min val */ - (common->wcmMaxZ / 2) - 1, /* max val */ + 0, /* min val */ + common->wcmMaxZ, /* max val */ mils(common->wcmResolZ), /* resolution */ - 0, /* min_res */ + 0, /* min_res */ mils(common->wcmResolZ)); /* max_res */ InitValuatorAxisStruct(pWcm, 3, @@ -2857,24 +3187,33 @@ xf86WcmAllocate(char * name, int flag) { + LocalDevicePtr local; + WacomDevicePtr priv; + WacomCommonPtr common; + + priv = (WacomDevicePtr) xalloc(sizeof(WacomDeviceRec)); + if (!priv) + return NULL; + + common = (WacomCommonPtr) xalloc(sizeof(WacomCommonRec)); + if (!common) { + xfree(priv); + return NULL; + } + #ifdef XFREE86_V4 - LocalDevicePtr local = xf86AllocateInput(wcmDrv, 0); + local = xf86AllocateInput(wcmDrv, 0); #else - LocalDevicePtr local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); + local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); #endif - WacomDevicePtr priv = (WacomDevicePtr) xalloc(sizeof(WacomDeviceRec)); - WacomCommonPtr common = (WacomCommonPtr) xalloc(sizeof(WacomCommonRec)); -#if defined(sun) && !defined(i386) - char *dev_name = (char *) getenv("WACOM_DEV"); -#endif + if (!local) { + xfree(priv); + xfree(common); + return NULL; + } local->name = name; local->flags = 0; -#ifndef XFREE86_V4 -#if !defined(sun) || defined(i386) - local->device_config = xf86WcmConfig; -#endif -#endif local->device_control = xf86WcmProc; local->read_input = xf86WcmReadInput; local->control_proc = xf86WcmChangeControl; @@ -2911,13 +3250,6 @@ priv->initNumber = 0; /* magic number for the init phasis */ common->wcmDevice = ""; /* device file name */ -#if defined(sun) && !defined(i386) - if (dev_name) { - common->wcmDevice = (char*) xalloc(strlen(dev_name)+1); - strcpy(common->wcmDevice, dev_name); - ErrorF("xf86WcmOpen port changed to '%s'\n", common->wcmDevice); - } -#endif common->wcmSuppress = -1; /* transmit position if increment is superior */ common->wcmFlags = 0; /* various flags */ common->wcmDevices = (LocalDevicePtr*) xalloc(sizeof(LocalDevicePtr)); @@ -2927,7 +3259,7 @@ common->wcmPktLength = 7; /* length of a packet */ common->wcmMaxX = 0; /* max X value */ common->wcmMaxY = 0; /* max Y value */ - common->wcmMaxZ = 240; /* max Z value */ + common->wcmMaxZ = DEFAULT_MAXZ; /* max Z value */ common->wcmResolX = 0; /* X resolution in points/inch */ common->wcmResolY = 0; /* Y resolution in points/inch */ common->wcmResolZ = 1270; /* Z resolution in points/inch */ @@ -2937,6 +3269,9 @@ common->wcmProtocolLevel = 4; /* protocol level */ common->wcmThreshold = INVALID_THRESHOLD; /* button 1 threshold for some tablet models */ common->wcmInitNumber = 0; /* magic number for the init phasis */ + common->wcmLinkSpeed = 9600; /* serial link speed */ + common->wcmOpen = xf86WcmOpen; /* function used to open the line (serial or USB) */ + common->wcmLastSerial = 0; /* last device (used by the USB part) */ return local; } @@ -2952,7 +3287,8 @@ { LocalDevicePtr local = xf86WcmAllocate(XI_STYLUS, STYLUS_ID); - local->type_name = "Wacom Stylus"; + if (local) + local->type_name = "Wacom Stylus"; return local; } @@ -2968,7 +3304,8 @@ { LocalDevicePtr local = xf86WcmAllocate(XI_CURSOR, CURSOR_ID); - local->type_name = "Wacom Cursor"; + if (local) + local->type_name = "Wacom Cursor"; return local; } @@ -2984,7 +3321,8 @@ { LocalDevicePtr local = xf86WcmAllocate(XI_ERASER, ABSOLUTE_FLAG|ERASER_ID); - local->type_name = "Wacom Eraser"; + if (local) + local->type_name = "Wacom Eraser"; return local; } @@ -3098,6 +3436,9 @@ wcmDrv = drv; fakeLocal = (LocalDevicePtr) xcalloc(1, sizeof(LocalDeviceRec)); + if (!fakeLocal) + return NULL; + fakeLocal->conf_idev = dev; /* Force default serial port options to exist because the serial init @@ -3124,15 +3465,14 @@ goto SetupProc_fail; } - if (local) - priv = (WacomDevicePtr) local->private; - if (priv) - common = priv->common; - - if (!local || !priv || !common) { - goto SetupProc_fail; + if (!local) { + xfree(fakeLocal); + return NULL; } - + + priv = (WacomDevicePtr) local->private; + common = priv->common; + local->options = fakeLocal->options; local->conf_idev = fakeLocal->conf_idev; local->name = dev->identifier; @@ -3210,6 +3550,16 @@ common->wcmFlags |= TILT_FLAG; } + if (xf86SetBoolOption(local->options, "USB", 0)) { +#ifdef LINUX_INPUT + local->read_input=xf86WcmReadUSBInput; + common->wcmOpen=xf86WcmUSBOpen; + xf86Msg(X_CONFIG, "%s: reading USB link\n", dev->identifier); +#else + ErrorF("The USB version of the driver isn't available for your platform\n"); +#endif + } + if (xf86SetBoolOption(local->options, "KeepShape", 0)) { priv->flags |= KEEP_SHAPE_FLAG; xf86Msg(X_CONFIG, "%s: keeps shape\n", dev->identifier); @@ -3253,8 +3603,8 @@ xf86Msg(X_CONFIG, "%s: max x = %d\n", dev->identifier, common->wcmMaxY); } - common->wcmMaxZ = xf86SetIntOption(local->options, "MaxZ", 0); - if (common->wcmMaxZ != 0) { + common->wcmMaxZ = xf86SetIntOption(local->options, "MaxZ", DEFAULT_MAXZ); + if (common->wcmMaxZ != DEFAULT_MAXZ) { xf86Msg(X_CONFIG, "%s: max x = %d\n", dev->identifier, common->wcmMaxZ); } @@ -3279,14 +3629,17 @@ val = xf86SetIntOption(local->options, "BaudRate", 0); switch(val) { + case 38400: + common->wcmLinkSpeed = 38400; + break; case 19200: - common->wcmFlags = common->wcmFlags | BAUD_19200_FLAG; + common->wcmLinkSpeed = 19200; break; case 9600: - common->wcmFlags = common->wcmFlags & ~BAUD_19200_FLAG; + common->wcmLinkSpeed = 9600; break; default: - xf86Msg(X_ERROR, "%s: Illegal speed value (must be 9600 or 19200).", dev->identifier); + xf86Msg(X_ERROR, "%s: Illegal speed value (must be 9600 or 19200 or 38400).", dev->identifier); break; } if (xf86Verbose) Index: xc/programs/Xserver/hw/xfree86/int10/Imakefile diff -u xc/programs/Xserver/hw/xfree86/int10/Imakefile:1.9 xc/programs/Xserver/hw/xfree86/int10/Imakefile:1.13 --- xc/programs/Xserver/hw/xfree86/int10/Imakefile:1.9 Mon Apr 17 12:30:11 2000 +++ xc/programs/Xserver/hw/xfree86/int10/Imakefile Thu Dec 7 10:43:45 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/int10/Imakefile,v 1.9 2000/04/17 16:30:11 eich Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/int10/Imakefile,v 1.13 2000/12/07 15:43:45 tsi Exp $ /* An OS-independent INT10 module/library */ @@ -8,7 +8,7 @@ #if !UseX86Emu || (XF86INT10_BUILD == X86INT10_STUB) SRCS = xf86int10module.c stub.c -OBJS = xf86int10module.c stub.o +OBJS = xf86int10module.o stub.o #else @@ -37,6 +37,8 @@ # if defined(i386Architecture) ARCHDEFINES = -D_PC +# elif defined(ia64Architecture) +ARCHDEFINES = -D_PC_IO -D_PC_PCI # endif INT10DEFINES = -D_X86EMU $(ARCHDEFINES) Index: xc/programs/Xserver/hw/xfree86/int10/generic.c diff -u xc/programs/Xserver/hw/xfree86/int10/generic.c:1.9 xc/programs/Xserver/hw/xfree86/int10/generic.c:1.13 --- xc/programs/Xserver/hw/xfree86/int10/generic.c:1.9 Wed Jun 7 18:03:10 2000 +++ xc/programs/Xserver/hw/xfree86/int10/generic.c Tue Nov 21 18:10:38 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/generic.c,v 1.9 2000/06/07 22:03:10 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/generic.c,v 1.13 2000/11/21 23:10:38 tsi Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -57,7 +57,7 @@ xf86InitInt10(int entityIndex) { xf86Int10InfoPtr pInt; - int screen; + int screen, cs; void* base = 0; void* vbiosMem = 0; legacyVGARec vga; @@ -74,15 +74,14 @@ pInt->mem = &genericMem; pInt->private = (pointer)xnfcalloc(1,sizeof(genericInt10Priv)); INTPriv(pInt)->alloc = - (pointer)xnfcalloc(1,sizeof(ALLOC_ENTRIES(getpagesize()))); + (pointer)xnfcalloc(1,ALLOC_ENTRIES(getpagesize())); pInt->scrnIndex = screen; - base = INTPriv(pInt)->base = xnfalloc(0xf0000); + base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); /* * we need to map video RAM MMIO as some chipsets map mmio * registers into this range. */ - MapVRam(pInt); #ifdef _PC if (!sysMem) @@ -93,17 +92,30 @@ xf86DrvMsg(screen,X_ERROR,"Cannot read int vect\n"); goto error1; } + + /* + * Retrieve everything between V_BIOS and SYS_BIOS as some system BIOSes + * have executable code there. Note that xf86ReadBIOS() can only read in + * 64kB at a time. + */ + (void)memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS); + for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) + if (xf86ReadBIOS(cs, 0, (unsigned char *)base + cs, V_BIOS_SIZE) < + V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%06X.\n", cs); + if (xf86IsEntityPrimary(entityIndex)) { - int cs = MEM_RW(pInt,((0x10<<2)+2)); + cs = MEM_RW(pInt,((0x10<<2)+2)); vbiosMem = (unsigned char *)base + (cs << 4); - if (!int10_read_bios(screen,cs,vbiosMem)) { + if (!int10_check_bios(screen, cs, vbiosMem)) { cs = MEM_RW(pInt,((0x42<<2)+2)); vbiosMem = (unsigned char *)base + (cs << 4); - if (!int10_read_bios(screen,cs,vbiosMem)) { + if (!int10_check_bios(screen, cs, vbiosMem)) { cs = V_BIOS >> 4; vbiosMem = (unsigned char *)base + (cs << 4); - if (!int10_read_bios(screen,cs,vbiosMem)) { + if (!int10_check_bios(screen, cs, vbiosMem)) { xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n"); goto error1; } @@ -114,7 +126,7 @@ set_return_trap(pInt); pInt->BIOSseg = cs; } else { - reset_int_vect(pInt); + reset_int_vect(pInt); set_return_trap(pInt); vbiosMem = (unsigned char *)base + V_BIOS; if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) { @@ -136,9 +148,28 @@ setup_int_vect(pInt); set_return_trap(pInt); vbiosMem = (unsigned char *)base + V_BIOS; - if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) { - xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n"); - goto error1; + { + EntityInfoPtr pEnt = xf86GetEntityInfo(pInt->entityIndex); + switch (pEnt->location.type) { + case BUS_PCI: + if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n"); + goto error1; + } + break; + case BUS_ISA: + (void)memset(vbiosMem, 0, V_BIOS_SIZE); + if (xf86ReadBIOS(V_BIOS, 0, vbiosMem, V_BIOS_SIZE) < V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x0C0000.\n"); + if (!int10_check_bios(screen, V_BIOS >> 4, vbiosMem)) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (5)\n"); + goto error1; + } + break; + default: + goto error1; + } } pInt->BIOSseg = V_BIOS >> 4; pInt->num = 0xe6; Index: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c diff -u xc/programs/Xserver/hw/xfree86/int10/helper_exec.c:1.4 xc/programs/Xserver/hw/xfree86/int10/helper_exec.c:1.11 --- xc/programs/Xserver/hw/xfree86/int10/helper_exec.c:1.4 Wed May 31 03:15:06 2000 +++ xc/programs/Xserver/hw/xfree86/int10/helper_exec.c Wed Dec 6 10:35:26 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.4 2000/05/31 07:15:06 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.11 2000/12/06 15:35:26 eich Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -16,6 +16,7 @@ */ #include "xf86.h" #include "xf86str.h" +#include "xf86_OSproc.h" #include "xf86_ansic.h" #include "compiler.h" #include "xf86Pci.h" @@ -23,14 +24,14 @@ #include "int10Defines.h" #include "xf86int10.h" -#ifndef _PC +#if !defined (_PC) && !defined (_PC_PCI) static int pciCfg1in(CARD16 addr, CARD32 *val); static int pciCfg1out(CARD16 addr, CARD32 val); #endif #define REG pInt -void +int setup_int(xf86Int10InfoPtr pInt) { if (pInt != Int10Current) { @@ -44,7 +45,7 @@ X86_ESI = (CARD32) pInt->si; X86_EDI = (CARD32) pInt->di; X86_ES = (CARD32) pInt->es; - X86_EBP = 0; + X86_EBP = (CARD32) pInt->bp; X86_EIP = 0; X86_CS = 0x60; /* address of 'hlt' */ X86_ESP = 0x100; @@ -53,18 +54,21 @@ X86_FS = 0; X86_GS = 0; X86_EFLAGS = (X86_IF_MASK | X86_IOPL_MASK); - + + return xf86BlockSIGIO(); } void -finish_int(xf86Int10InfoPtr pInt) +finish_int(xf86Int10InfoPtr pInt, int sig) { + xf86UnblockSIGIO(sig); pInt->ax = (CARD16) X86_EAX; pInt->bx = (CARD16) X86_EBX; pInt->cx = (CARD16) X86_ECX; pInt->dx = (CARD16) X86_EDX; pInt->si = (CARD16) X86_ESI; pInt->di = (CARD16) X86_EDI; + pInt->bp = (CARD16) X86_EBP; pInt->flags = (CARD16) X86_FLAGS; } @@ -254,7 +258,7 @@ CARD32 eflags; #ifndef _PC /* check if bios vector is initialized */ - if (MEM_RW(pInt,(num<<2)+2) == 0xF000) { /* SYS_BIOS_SEG ?*/ + if (MEM_RW(pInt,(num<<2)+2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/ #ifdef PRINT_INT ErrorF("card BIOS not loaded\n"); #endif @@ -301,22 +305,24 @@ void dump_registers(xf86Int10InfoPtr pInt) { - PRINT(X86_IP); PRINT(X86_AX); PRINT(X86_BX); PRINT(X86_CX); PRINT(X86_DX); + ErrorF("\n"); + PRINT(X86_IP); PRINT(X86_SI); PRINT(X86_DI); PRINT(X86_BP); - ErrorF("\n"); PRINT(X86_SP); + ErrorF("\n"); PRINT(X86_CS); PRINT(X86_SS); PRINT(X86_ES); PRINT(X86_DS); PRINT(X86_FS); PRINT(X86_GS); + ErrorF("\n"); PRINT_FLAGS(X86_EFLAGS); ErrorF("\n"); } @@ -435,7 +441,7 @@ return (dst-base); } -#if defined(PRINT_PORT) || !defined(_PC) +#if defined(PRINT_PORT) || (!defined(_PC) && !defined(_PC_IO)) CARD8 x_inb(CARD16 port) { @@ -483,7 +489,7 @@ { CARD32 val; -#ifndef _PC +#if !defined (_PC) && !defined (_PC_PCI) if (!pciCfg1in(port,&val)) #endif val = inl(port); @@ -500,7 +506,7 @@ #ifdef PRINT_PORT ErrorF(" outl(%#x, %8.8x)\n",port,val); #endif -#ifndef _PC +#if !defined (_PC) && !defined (_PC_PCI) if (!pciCfg1out(port,val)) #endif outl(port,val); @@ -543,7 +549,7 @@ Int10Current->mem->wl(Int10Current,addr,val); } -#ifndef _PC +#if !defined (_PC) && !defined (_PC_PCI) static CARD32 PciCfg1Addr = 0; #define TAG(Cfg1Addr) (Cfg1Addr & 0xffff00) @@ -581,12 +587,11 @@ CARD8 bios_checksum(CARD8 *start, int size) { - int i; - CARD8 val = 0; - - for (i = 0; i < size; i++) - val += *start++; - return val; + CARD8 sum = 0; + + while (size-- > 0) + sum += *start++; + return sum; } /* Index: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c diff -u xc/programs/Xserver/hw/xfree86/int10/helper_mem.c:1.6 xc/programs/Xserver/hw/xfree86/int10/helper_mem.c:1.14 --- xc/programs/Xserver/hw/xfree86/int10/helper_mem.c:1.6 Mon Jun 12 22:28:35 2000 +++ xc/programs/Xserver/hw/xfree86/int10/helper_mem.c Sat Dec 2 10:31:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.6 2000/06/13 02:28:35 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.14 2000/12/02 15:31:01 tsi Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -59,7 +59,7 @@ void setup_int_vect(xf86Int10InfoPtr pInt) { - const CARD16 cs = 0xF000; + const CARD16 cs = (SYS_BIOS >> 4); const CARD16 ip = 0x0; int i; @@ -127,11 +127,11 @@ reset_int_vect(xf86Int10InfoPtr pInt) { MEM_WW(pInt,(0x10<<2),0xf065); - MEM_WW(pInt,((0x10<<2)+2),0xf000); + MEM_WW(pInt,((0x10<<2)+2),(SYS_BIOS >> 4)); MEM_WW(pInt,(0x42<<2),0xf065); - MEM_WW(pInt,((0x42<<2)+2),0xf000); + MEM_WW(pInt,((0x42<<2)+2),(SYS_BIOS >> 4)); MEM_WW(pInt,(0x6D<<2),0xf065); - MEM_WW(pInt,((0x6D<<2)+2),0xf000); + MEM_WW(pInt,((0x6D<<2)+2),(SYS_BIOS >> 4)); } void @@ -165,35 +165,28 @@ Bool -int10_read_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem) +int10_check_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem) { int size; + if ((codeSeg & 0x1f) || /* Not 512-byte aligned otherwise */ + ((codeSeg << 4) < V_BIOS) || + ((codeSeg << 4) >= SYS_SIZE)) + return FALSE; + if (xf86IsPc98()) return FALSE; - if (xf86ReadBIOS(codeSeg << 4,0,(unsigned char *)vbiosMem, 0x10) < 0) { - xf86DrvMsg(scrnIndex,X_WARNING,"Cannot read V_BIOS (1)\n"); + if ((*vbiosMem != 0x55) || (*(vbiosMem+1) != 0xAA) || !*(vbiosMem+2)) return FALSE; - } - - if (!((*(CARD8*)vbiosMem == 0x55) && (*((CARD8*)vbiosMem+1) == 0xAA))) - return FALSE; - size = *((CARD8*)vbiosMem + 2) * 512; + size = *(vbiosMem + 2) * 512; - if ((size + (codeSeg << 4)) > SYS_BIOS) - return FALSE; - - if (xf86ReadBIOS(codeSeg << 4,0,vbiosMem, size) < 0) { - xf86DrvMsg(scrnIndex,X_ERROR,"Cannot read V_BIOS (2)\n"); + if ((size + (codeSeg << 4)) > SYS_SIZE) return FALSE; - } - if (bios_checksum(vbiosMem,size)) { - xf86DrvMsg(scrnIndex,X_ERROR,"Bad checksum of V_BIOS \n"); - return FALSE; - } + + if (bios_checksum(vbiosMem, size)) + xf86DrvMsg(scrnIndex, X_WARNING, "Bad V_BIOS checksum\n"); + return TRUE; } - - Index: xc/programs/Xserver/hw/xfree86/int10/pci.c diff -u xc/programs/Xserver/hw/xfree86/int10/pci.c:1.2 xc/programs/Xserver/hw/xfree86/int10/pci.c:1.5 --- xc/programs/Xserver/hw/xfree86/int10/pci.c:1.2 Tue Feb 8 08:13:26 2000 +++ xc/programs/Xserver/hw/xfree86/int10/pci.c Sat Dec 2 10:31:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/pci.c,v 1.2 2000/02/08 13:13:26 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/pci.c,v 1.5 2000/12/02 15:31:01 tsi Exp $ */ /* * XFree86 int10 module @@ -18,93 +18,85 @@ PCITAG tag; unsigned long offset = 0; unsigned char *mem, *ptr; - unsigned char *scratch = NULL; - int length = 0; + int length, rlength, blength; pciVideoPtr pvp = xf86GetPciInfoForEntity(pInt->entityIndex); - + if (pvp == NULL) { #ifdef DEBUG - ErrorF("mapPciRom: no PCI info\n"); + ErrorF("mapPciRom: no PCI info\n"); #endif return 0; } - + tag = pciTag(pvp->bus,pvp->device,pvp->func); - - mem = ptr = xnfcalloc(0x10000, 1); - if (! xf86ReadPciBIOS(0,tag,offset,mem,0xFFFF) < 0) { - xfree(mem); + rlength = blength = 1 << pvp->biosSize; + + /* Read in entire PCI ROM in 64kB chunks */ + mem = ptr = xnfcalloc(blength, 1); + while ((length = rlength) > 0) { + if (length > 0x10000) length = 0x10000; + if (xf86ReadPciBIOS(offset, tag, -1, ptr, length) < length) { + xfree(mem); #ifdef DEBUG - ErrorF("mapPciRom: cannot read BIOS\n"); + ErrorF("mapPciRom: cannot read BIOS\n"); #endif - return 0; + return 0; + } + offset += length; + rlength -= length; + ptr += length; } - while ( *ptr == 0x55 && *(ptr+1) == 0xAA) { - unsigned short data_off = *(ptr+0x18) | (*(ptr+0x19)<< 8); + ptr = mem; + while ((ptr[0] == 0x55) && (ptr[1] == 0xAA)) { + unsigned short data_off = ptr[0x18] | (ptr[0x19] << 8); unsigned char *data = ptr + data_off; unsigned char type; - - if (*data!='P' || *(data+1)!='C' || *(data+2)!='I' || *(data+3)!='R') + + if ((data[0] != 'P') || + (data[1] != 'C') || + (data[2] != 'I') || + (data[3] != 'R')) break; - type = *(data + 0x14); + type = data[0x14]; #ifdef PRINT_PCI - ErrorF("data segment in BIOS: 0x%x, type: 0x%x ",data_off,type); + ErrorF("data segment in BIOS: 0x%x, type: 0x%x\n", data_off, type); #endif - if (type != 0) { /* not PC-AT image: find next one */ + if (type) { /* not PC-AT image: find next one */ unsigned int image_length; - unsigned char indicator = *(data + 0x15); + unsigned char indicator = data[0x15]; if (indicator & 0x80) /* last image */ break; - image_length = (*(data + 0x10) - | (*(data + 0x11) << 8)) << 9; + image_length = (data[0x10] | (data[0x11] << 8)) << 9; #ifdef PRINT_PCI ErrorF("data image length: 0x%x, ind: 0x%x\n", - image_length,indicator); + image_length, indicator); #endif - offset = offset + image_length; - if (xf86ReadPciBIOS(0,tag,offset,mem,0xFFFF) < 0) { - xfree(mem); -#ifdef DEBUG - ErrorF("mapPciRom: cannot read BIOS\n"); -#endif - return 0; - } - continue; + ptr += image_length; + continue; } /* OK, we have a PC Image */ - length = (*(ptr + 2) << 9); + length = ptr[2] << 9; #ifdef PRINT_PCI - ErrorF("BIOS length: 0x%x\n",length); + ErrorF("BIOS length: 0x%x\n", length); #endif - scratch = (unsigned char *)xnfalloc(length); - - if (xf86ReadPciBIOS(0,tag,offset,scratch,length) < 0) { - xfree(mem); - xfree(scratch); -#ifdef DEBUG - ErrorF("mapPciRom: cannot read BIOS\n"); -#endif - return 0; - } break; } + + if (length > 0) + memcpy(address, ptr, length); /* unmap/close/disable PCI bios mem */ xfree(mem); - if (scratch && length) { - memcpy(address, scratch, length); - xfree(scratch); - } #ifdef DEBUG if (!length) ErrorF("mapPciRom: no BIOS found\n"); -#endif #ifdef PRINT_PCI - if (length) + else dprint(address,0x20); #endif +#endif + return length; } - Index: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h diff -u xc/programs/Xserver/hw/xfree86/int10/xf86int10.h:1.5 xc/programs/Xserver/hw/xfree86/int10/xf86int10.h:1.15 --- xc/programs/Xserver/hw/xfree86/int10/xf86int10.h:1.5 Mon Apr 17 12:30:11 2000 +++ xc/programs/Xserver/hw/xfree86/int10/xf86int10.h Wed Dec 6 13:08:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.5 2000/04/17 16:30:11 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.15 2000/12/06 18:08:55 eich Exp $ */ /* * XFree86 int10 module @@ -31,6 +31,7 @@ int si; int di; int es; + int bp; int flags; } xf86Int10InfoRec, *xf86Int10InfoPtr; @@ -65,7 +66,11 @@ #define I_S_DEFAULT_INT_VECT 0xFF065 #define SYS_SIZE 0x100000 #define SYS_BIOS 0xF0000 +#if 1 #define BIOS_SIZE 0x10000 +#else /* a bug in DGUX requires this - let's try it */ +#define BIOS_SIZE (0x10000 - 1) +#endif #define LOW_PAGE_SIZE 0x600 #define V_RAM 0xA0000 #define VRAM_SIZE 0x20000 @@ -101,8 +106,8 @@ int int_handler(xf86Int10InfoPtr pInt); /* helper_exec.c */ -void setup_int(xf86Int10InfoPtr pInt); -void finish_int(xf86Int10InfoPtr); +int setup_int(xf86Int10InfoPtr pInt); +void finish_int(xf86Int10InfoPtr, int sig); CARD32 getIntVect(xf86Int10InfoPtr pInt,int num); int vm86_GP_fault(xf86Int10InfoPtr pInt); void pushw(xf86Int10InfoPtr pInt, CARD16 val); @@ -111,6 +116,7 @@ void dump_registers(xf86Int10InfoPtr pInt); void stack_trace(xf86Int10InfoPtr pInt); xf86Int10InfoPtr getInt10Rec(int entityIndex); +CARD8 bios_checksum(CARD8 *start, int size); void LockLegacyVGA(int screenIndex,legacyVGAPtr vga); void UnlockLegacyVGA(int screenIndex, legacyVGAPtr vga); int port_rep_inb(xf86Int10InfoPtr pInt, @@ -125,7 +131,6 @@ CARD16 port, CARD32 base, int d_f, CARD32 count); int port_rep_outl(xf86Int10InfoPtr pInt, CARD16 port, CARD32 base, int d_f, CARD32 count); -CARD8 bios_checksum(CARD8 *start, int size); CARD8 x_inb(CARD16 port); CARD16 x_inw(CARD16 port); @@ -135,7 +140,7 @@ void x_outl(CARD16 port, CARD32 val); #ifndef _INT10_NO_INOUT_MACROS -#if defined(PRINT_PORT) || !defined(_PC) +#if defined(PRINT_PORT) || (!defined(_PC) && !defined(_PC_IO)) # define p_inb x_inb # define p_inw x_inw # define p_outb x_outb @@ -165,7 +170,7 @@ void reset_int_vect(xf86Int10InfoPtr pInt); void set_return_trap(xf86Int10InfoPtr pInt); Bool int10skip(ScrnInfoPtr pScrn, int entityIndex); -Bool int10_read_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem); +Bool int10_check_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem); #ifdef DEBUG void dprint(unsigned long start, unsigned long size); Index: xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c diff -u xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c:1.7 xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c:1.9 --- xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c:1.7 Tue Apr 4 15:25:18 2000 +++ xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c Wed Dec 6 10:35:26 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c,v 1.7 2000/04/04 19:25:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c,v 1.9 2000/12/06 15:35:26 eich Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -19,7 +19,7 @@ #define M _X86EMU_env -#if defined(PRINT_PORT) || !defined(_PC) +#if defined(PRINT_PORT) || (!defined(_PC) && !defined(_PC_IO)) # define p_inb x_inb # define p_inw x_inw # define p_outb x_outb @@ -93,13 +93,13 @@ void xf86ExecX86int10(xf86Int10InfoPtr pInt) { - setup_int(pInt); + int sig = setup_int(pInt); if (int_handler(pInt)) { X86EMU_exec(); } - finish_int(pInt); + finish_int(pInt, sig); } Bool Index: xc/programs/Xserver/hw/xfree86/loader/Imakefile diff -u xc/programs/Xserver/hw/xfree86/loader/Imakefile:1.22 xc/programs/Xserver/hw/xfree86/loader/Imakefile:1.26 --- xc/programs/Xserver/hw/xfree86/loader/Imakefile:1.22 Wed Feb 23 14:21:16 2000 +++ xc/programs/Xserver/hw/xfree86/loader/Imakefile Thu Nov 2 14:10:53 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/loader/Imakefile,v 1.22 2000/02/23 19:21:16 alanh Exp $ */ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/loader/Imakefile,v 1.26 2000/11/02 19:10:53 dawes Exp $ */ @@ -22,10 +22,6 @@ DLOBJ=dlloader.o #endif -#if defined(SunArchitecture) && defined(SVR4Architecture) && OSMinorVersion >= 8 -OSDEFINES = -DSOL8 -#endif - DEFINES = $(DBMALLOCDEFINE) $(DLOPENDEFINES) $(OSDEFINES) MODULEDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\" @@ -35,27 +31,40 @@ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \ -I$(SERVERSRC)/os -I$(XINCLUDESRC) -I$(FONTINCSRC) \ -I$(FONTLIBSRC)/include -I$(FONTLIBSRC)/fontcache \ - -I$(EXTINCSRC) -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c + -I$(EXTINCSRC) -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \ + -I$(SERVERSRC)/render #ifdef OS2Architecture SRCS1 = os2funcs.c OBJS1 = os2funcs.o #endif +#ifdef SparcArchitecture +SRCS1 = SparcMulDiv.S +OBJS1 = SparcMulDiv.o +#endif + SRCS = aoutloader.c coffloader.c $(DLSRC) elfloader.c hash.c loader.c \ loadmod.c loadfont.c loadext.c os.c dixsym.c misym.c xf86sym.c \ fontsym.c extsym.c $(SRCS1) OBJS = aoutloader.o coffloader.o $(DLOBJ) elfloader.o hash.o loader.o \ loadmod.o loadfont.o loadext.o os.o dixsym.o misym.o xf86sym.o \ fontsym.o extsym.o $(OBJS1) +XOBJS = aoutloader.o coffloader.o $(DLOBJ) elfloader.o hash.o loader.o \ + loadmod.o loadfont.o loadext.o os.o $(OBJS1) NormalAsmObjectRule() NormalLibraryObjectRule() -NormalLibraryTarget(loader,$(OBJS)) +NormalLibraryTarget(loader,$(OBJS) ) +NormalLibraryTarget(xloader,$(XOBJS) ) SpecialCObjectRule(loadmod,NullParameter,$(MODULEDEFINES) $(EXT_DEFINES)) SpecialCObjectRule(xf86sym,NullParameter,$(EXT_DEFINES)) SpecialCObjectRule(dixsym,NullParameter,$(EXT_DEFINES)) + +#ifdef SparcArchitecture +ObjectFromAsmSource(SparcMulDiv,NullParameter) +#endif DependTarget() Index: xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S diff -u /dev/null xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S:1.1 --- /dev/null Mon Dec 18 14:31:41 2000 +++ xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S Thu Nov 2 14:10:54 2000 @@ -0,0 +1,87 @@ +/* + * Hardware integer division and multiplication routines for SPARC v8 and higher. + * + * Copyright (C) 1996 David S. Miller (davem@redhat.com) + * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/SparcMulDiv.S,v 1.1 2000/11/02 19:10:54 dawes Exp $ */ + + .globl urem_sparcv89, umul_sparcv89, udiv_sparcv89 + .globl rem_sparcv89, mul_sparcv89, div_sparcv89 + + .align 32 +urem_sparcv89: + wr %g0, 0x0, %y + nop + nop + nop + udiv %o0, %o1, %o2 + umul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +umul_sparcv89: + umul %o0, %o1, %o0 + retl + rd %y, %o1 + + .align 32 +udiv_sparcv89: + wr %g0, 0x0, %y + nop + nop + retl + udiv %o0, %o1, %o0 + + .align 32 +rem_sparcv89: + sra %o0, 0x1f, %o4 + wr %o4, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o2 + bvs,a 1f + xnor %o2, %g0, %o2 +1: smul %o2, %o1, %o2 + retl + sub %o0, %o2, %o0 + + .align 32 +mul_sparcv89: + smul %o0, %o1, %o0 + retl + rd %y, %o1 + nop + + .align 32 +div_sparcv89: + sra %o0, 0x1f, %o2 + wr %o2, 0x0, %y + nop + nop + nop + sdivcc %o0, %o1, %o0 + bvs,a 1f + xnor %o0, %g0, %o0 +1: retl + nop Index: xc/programs/Xserver/hw/xfree86/loader/coffloader.c diff -u xc/programs/Xserver/hw/xfree86/loader/coffloader.c:1.11 xc/programs/Xserver/hw/xfree86/loader/coffloader.c:1.14 --- xc/programs/Xserver/hw/xfree86/loader/coffloader.c:1.11 Sun Mar 14 06:18:05 1999 +++ xc/programs/Xserver/hw/xfree86/loader/coffloader.c Wed Dec 13 11:52:00 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.c,v 1.11 1999/03/14 11:18:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.c,v 1.14 2000/12/13 16:52:00 tsi Exp $ */ /* * @@ -47,6 +47,8 @@ #include "loader.h" #include "coffloader.h" +#define NO_COMPILER_H_EXTRAS +#include "compiler.h" /* #ifndef LDTEST #define COFFDEBUG ErrorF @@ -1140,6 +1142,11 @@ /* .stabstr */ if( strcmp(cofffile->sections[i].s_name, ".stabstr" ) == 0 ) { + continue; + } + /* .stab.* */ + if( strncmp(cofffile->sections[i].s_name, + ".stab.", strlen(".stab.") ) == 0 ) { continue; } ErrorF("Not loading %s\n", cofffile->sections[i].s_name ); Index: xc/programs/Xserver/hw/xfree86/loader/dixsym.c diff -u xc/programs/Xserver/hw/xfree86/loader/dixsym.c:1.32 xc/programs/Xserver/hw/xfree86/loader/dixsym.c:1.35 --- xc/programs/Xserver/hw/xfree86/loader/dixsym.c:1.32 Sun Apr 23 20:19:16 2000 +++ xc/programs/Xserver/hw/xfree86/loader/dixsym.c Wed Nov 22 02:19:44 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.32 2000/04/24 00:19:16 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.35 2000/11/22 07:19:44 keithp Exp $ */ /* @@ -52,10 +52,17 @@ #ifdef XFreeXDGA #include "dgaproc.h" #endif +#ifdef RENDER +#include "picturestr.h" +#include "mipict.h" +#endif /* XXX This should be in a header somewhere */ extern void ClientSleepUntil(ClientPtr, TimeStamp, void(*)(ClientPtr, pointer), pointer); +extern int ShmCompletionCode; +extern int BadShmSegCode; +extern RESTYPE ShmSegType; /* DIX things */ @@ -307,7 +314,19 @@ /* libXext.a */ SYMFUNC(ClientSleepUntil) - + SYMVAR(ShmCompletionCode) + SYMVAR(BadShmSegCode) + SYMVAR(ShmSegType) + + /* librender.a */ +#ifdef RENDER + SYMFUNC(PictureInit) + SYMFUNC(miPictureInit) + SYMFUNC(miComputeCompositeRegion) + SYMFUNC(miGlyphs) + SYMFUNC(miCompositeRects) + SYMVAR(PictureScreenPrivateIndex) +#endif { 0, 0 }, Index: xc/programs/Xserver/hw/xfree86/loader/dlloader.c diff -u xc/programs/Xserver/hw/xfree86/loader/dlloader.c:1.10 xc/programs/Xserver/hw/xfree86/loader/dlloader.c:1.11 --- xc/programs/Xserver/hw/xfree86/loader/dlloader.c:1.10 Thu Jan 14 08:04:54 1999 +++ xc/programs/Xserver/hw/xfree86/loader/dlloader.c Wed Aug 23 18:10:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.c,v 1.10 1999/01/14 13:04:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.c,v 1.11 2000/08/23 22:10:14 tsi Exp $ */ /* @@ -101,13 +101,14 @@ sprintf(n, "_%s", name); #endif + (void)dlerror(); /* Clear out any previous error */ for (l = dlModuleList; l != NULL; l = l->next) { #ifdef NEED_UNDERSCORE_FOR_DLLSYM p = dlsym(l->module->dlhandle, n); #else p = dlsym(l->module->dlhandle, name); #endif - if (p != NULL) { + if (dlerror() == NULL) { #ifdef NEED_UNDERSCORE_FOR_DLLSYM xf86loaderfree(n); #endif Index: xc/programs/Xserver/hw/xfree86/loader/elf.h diff -u xc/programs/Xserver/hw/xfree86/loader/elf.h:1.8 xc/programs/Xserver/hw/xfree86/loader/elf.h:1.9 --- xc/programs/Xserver/hw/xfree86/loader/elf.h:1.8 Thu Jan 20 21:30:03 2000 +++ xc/programs/Xserver/hw/xfree86/loader/elf.h Thu Sep 7 15:06:52 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elf.h,v 1.8 2000/01/21 02:30:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elf.h,v 1.9 2000/09/07 19:06:52 anderson Exp $ */ typedef unsigned long Elf32_Addr; @@ -50,6 +50,7 @@ #define EM_SPARC32PLUS 18 #define EM_PPC 20 #define EM_SPARCV9 43 +#define EM_IA_64 50 #define EM_ALPHA 0x9026 /* This is the info that is needed to parse the dynamic section of the file */ @@ -233,6 +234,63 @@ #define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ #define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ #define R_ALPHA_RELATIVE 27 /* Adjust by program base */ + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x70 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x71 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x72 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x73 /* symbol + addend, data8 LSB */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ + +#define R_IA64_TYPE(R) ((R) & -8) +#define R_IA64_FORMAT(R) ((R) & 7) /* * Apparantly, Linux and PowerMAXOS use different version of ELF as the Index: xc/programs/Xserver/hw/xfree86/loader/elfloader.c diff -u xc/programs/Xserver/hw/xfree86/loader/elfloader.c:1.24 xc/programs/Xserver/hw/xfree86/loader/elfloader.c:1.31 --- xc/programs/Xserver/hw/xfree86/loader/elfloader.c:1.24 Wed May 17 20:33:19 2000 +++ xc/programs/Xserver/hw/xfree86/loader/elfloader.c Wed Dec 13 11:52:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.24 2000/05/18 00:33:19 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.31 2000/12/13 16:52:01 tsi Exp $ */ /* * @@ -46,13 +46,22 @@ #include "sym.h" #include "loader.h" +#define NO_COMPILER_H_EXTRAS +#include "compiler.h" + /* #ifndef LDTEST #define ELFDEBUG ErrorF #endif */ + +#ifndef UseMMAP +#if defined (__ia64__) || defined (__sparc__) +#define MergeSectionAlloc +#endif +#endif -#if defined (__alpha__) +#if defined (__alpha__) || defined (__ia64__) || (defined (__sparc__) && (defined (__arch64__) || defined (__sparcv9))) typedef Elf64_Ehdr Elf_Ehdr; typedef Elf64_Shdr Elf_Shdr; typedef Elf64_Sym Elf_Sym; @@ -63,17 +72,56 @@ #define ELF_ST_TYPE ELF64_ST_TYPE #define ELF_R_SYM ELF64_R_SYM #define ELF_R_TYPE ELF64_R_TYPE + +#if defined (__alpha__) || defined (__ia64__) /* * The GOT is allocated dynamically. We need to keep a list of entries that * have already been added to the GOT. * */ -typedef struct _elf_GOT { +typedef struct _elf_GOT_Entry { Elf_Rela *rel; int offset; - struct _elf_GOT *next; + struct _elf_GOT_Entry *next; +} ELFGotEntryRec, *ELFGotEntryPtr; + +typedef struct _elf_GOT { + unsigned int size; + unsigned int nuses; + unsigned char *freeptr; + struct _elf_GOT *next; + unsigned char section[1]; } ELFGotRec, *ELFGotPtr; +#ifdef MergeSectionAlloc +static ELFGotPtr ELFSharedGOTs; +#endif +#endif + +#if defined (__ia64__) +/* + * The PLT is allocated dynamically. We need to keep a list of entries that + * have already been added to the PLT. + */ +typedef struct _elf_PLT_Entry { + Elf_Rela *rel; + int offset; + int gotoffset; + struct _elf_PLT_Entry *next; +} ELFPltEntryRec, *ELFPltEntryPtr; + +/* + * The OPD is allocated dynamically within the GOT. We need to keep a list + * of entries that have already been added to the OPD. + */ +typedef struct _elf_OPD { + LOOKUP *l; + int index; + int offset; + struct _elf_OPD *next; +} ELFOpdRec, *ELFOpdPtr; +#endif + #else typedef Elf32_Ehdr Elf_Ehdr; typedef Elf32_Shdr Elf_Shdr; @@ -132,11 +180,19 @@ unsigned char *rodata1; /* Start address of the .rodata section */ int rodat1ndx; /* index of the .rodata section */ int rodat1size; /* size of the .rodata section */ -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) unsigned char *got; /* Start address of the .got section */ - ELFGotPtr got_entries; /* List of entries in the .got section */ + ELFGotEntryPtr got_entries; /* List of entries in the .got section */ int gotndx; /* index of the .got section */ - int gotsize; /* size of the .got section */ + int gotsize; /* actual size of the .got section */ + ELFGotPtr shared_got; /* Pointer to ELFGotRec if shared */ +#endif +#if defined(__ia64__) + ELFOpdPtr opd_entries; /* List of entries in the .opd section */ + unsigned char *plt; /* Start address of the .plt section */ + ELFPltEntryPtr plt_entries; /* List of entries in the .plt section */ + int pltndx; /* index of the .plt section */ + int pltsize; /* size of the .plt section */ #endif Elf_Sym *symtab; /* Start address of the .symtab section */ int symndx; /* index of the .symtab section */ @@ -155,6 +211,10 @@ int relrodatsize; /* size of the .rel.rodata section */ unsigned char *common; /* Start address of the SHN_COMMON space */ int comsize; /* size of the SHN_COMMON space */ + + unsigned char *base; /* Alloced address of section block */ + unsigned long baseptr; /* Pointer to next free space in base */ + int basesize; /* Size of that allocation */ } ELFModuleRec, *ELFModulePtr; /* @@ -165,7 +225,7 @@ #if defined(i386) Elf_Rel *rel; #endif -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) Elf_Rela *rel; #endif ELFModulePtr file; @@ -191,27 +251,75 @@ static char *ElfGetStringIndex(ELFModulePtr, int, int); static char *ElfGetString(ELFModulePtr, int); static char *ElfGetSectionName(ELFModulePtr, int); -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) static ELFRelocPtr ElfDelayRelocation(ELFModulePtr, unsigned char *, Elf_Rela *); #else static ELFRelocPtr ElfDelayRelocation(ELFModulePtr, unsigned char *, Elf_Rel *); #endif static ELFCommonPtr ElfAddCOMMON(Elf_Sym *); -static LOOKUP *ElfCreateCOMMON(ELFModulePtr); +static int ElfCOMMONSize(void); +static int ElfCreateCOMMON(ELFModulePtr,LOOKUP *); static char *ElfGetSymbolNameIndex(ELFModulePtr, int, int); static char *ElfGetSymbolName(ELFModulePtr, int); static Elf_Addr ElfGetSymbolValue(ELFModulePtr, int); -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) static ELFRelocPtr Elf_RelocateEntry(ELFModulePtr, unsigned char *, Elf_Rela *, int); #else static ELFRelocPtr Elf_RelocateEntry(ELFModulePtr, unsigned char *, Elf_Rel *, int); #endif static ELFRelocPtr ELFCollectRelocations(ELFModulePtr, int); -static LOOKUP *ELF_GetSymbols(ELFModulePtr); -static void ELFCollectSections(ELFModulePtr); -#if defined(__alpha__) +static LOOKUP *ELF_GetSymbols(ELFModulePtr, unsigned short **); +static void ELFCollectSections(ELFModulePtr, int, int *, int *); +#if defined(__alpha__) || defined(__ia64__) static void ElfAddGOT(ELFModulePtr, Elf_Rela *); -void ELFCreateGOT(ELFModulePtr); +static int ELFCreateGOT(ELFModulePtr, int); +#endif +#if defined(__ia64__) +static void ElfAddOPD(ELFModulePtr, int, LOOKUP *); +static void ELFCreateOPD(ELFModulePtr); +static void ElfAddPLT(ELFModulePtr, Elf_Rela *); +static void ELFCreatePLT(ELFModulePtr); +enum ia64_operand { + IA64_OPND_IMM22, + IA64_OPND_TGT25C +}; +static void IA64InstallReloc(unsigned long *, int, enum ia64_operand, long); +#endif + +#ifdef MergeSectionAlloc +static void * +ELFLoaderSectToMem(elffile, align, offset, size, label) +ELFModulePtr elffile; +int align; +unsigned long offset; +int size; +char *label; +{ + void *ret; + elffile->baseptr = (elffile->baseptr + align - 1) & ~(align - 1); + ret = (void *)elffile->baseptr; + _LoaderFileRead(elffile->fd, offset, ret, size); + elffile->baseptr += size; + return ret; +} + +static void * +ELFLoaderSectCalloc(elffile, align, size) +ELFModulePtr elffile; +int align; +int size; +{ + void *ret; + elffile->baseptr = (elffile->baseptr + align - 1) & ~(align - 1); + ret = (void *)elffile->baseptr; + elffile->baseptr += size; + memset(ret, 0, size); + return ret; +} +#else +#define ELFLoaderSectToMem(elffile,align,offset,size,label) \ +_LoaderFileToMem((elffile)->fd,offset,size,label) +#define ELFLoaderSectCalloc(elffile,align,size) xf86loadercalloc(1,size) #endif /* @@ -238,7 +346,7 @@ #if defined(i386) Elf_Rel *rel; #endif -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) Elf_Rela *rel; #endif { @@ -254,7 +362,7 @@ reloc->next=0; #ifdef ELFDEBUG ELFDEBUG("ElfDelayRelocation %lx: file %lx, sec %lx, r_offset 0x%x, r_info 0x%x", reloc, elffile, secp, rel->r_offset, rel->r_info); -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) ELFDEBUG(", r_addend 0x%x", rel->r_addend); #endif ELFDEBUG("\n" ); @@ -280,21 +388,36 @@ return common; } -static LOOKUP * -ElfCreateCOMMON(elffile) +static int +ElfCOMMONSize(void) +{ + int size=0; + ELFCommonPtr common; + + for (common = listCOMMON; common; common = common->next) { + size+=common->sym->st_size; +#if defined(__alpha__) || defined(__ia64__) || (defined(__sparc__) && (defined(__arch64__) || defined(__sparcv9))) + size = (size+7)&~0x7; +#endif + } + return size; +} + +static int +ElfCreateCOMMON(elffile,pLookup) ELFModulePtr elffile; +LOOKUP *pLookup; { int numsyms=0,size=0,l=0; - int offset=0; - LOOKUP *lookup; + int offset=0,firstcommon=0; ELFCommonPtr common; if (listCOMMON == NULL) - return NULL; + return TRUE; for (common = listCOMMON; common; common = common->next) { size+=common->sym->st_size; -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) || (defined(__sparc__) && (defined(__arch64__) || defined(__sparcv9))) size = (size+7)&~0x7; #endif numsyms++; @@ -305,15 +428,10 @@ numsyms, size ); #endif - if((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) { - ErrorF( "ElfCreateCOMMON() Unable to allocate memory!!!!\n" ); - return 0; - } - elffile->comsize=size; - if((elffile->common = xf86loadercalloc(1,size)) == NULL) { + if((elffile->common = ELFLoaderSectCalloc(elffile,8,size)) == NULL) { ErrorF( "ElfCreateCOMMON() Unable to allocate memory!!!!\n" ); - return 0; + return FALSE; } if (DebuggerPresent) @@ -321,6 +439,11 @@ ldrCommons = xf86loadermalloc(numsyms*sizeof(LDRCommon)); nCommons = numsyms; } + + for (l = 0; pLookup[l].symName; l++) + ; + firstcommon=l; + /* Traverse the common list and create a lookup table with all the * common symbols. Destroy the common list in the process. * See also ResolveSymbols. @@ -330,30 +453,30 @@ /* this is xstrdup because is should be more efficient. it is freed * with xf86loaderfree */ - lookup[l].symName = xf86loaderstrdup(ElfGetString(elffile,common->sym->st_name)); - lookup[l].offset = (funcptr)(elffile->common + offset); + pLookup[l].symName = xf86loaderstrdup(ElfGetString(elffile,common->sym->st_name)); + pLookup[l].offset = (funcptr)(elffile->common + offset); #ifdef ELFDEBUG - ELFDEBUG("Adding common %lx %s\n", lookup[l].offset, lookup[l].symName ); + ELFDEBUG("Adding common %lx %s\n", pLookup[l].offset, pLookup[l].symName ); #endif /* Record the symbol address for gdb */ if (DebuggerPresent && ldrCommons) { - ldrCommons[l].addr = (void *)lookup[l].offset; - ldrCommons[l].name = lookup[l].symName; - ldrCommons[l].namelen = strlen(lookup[l].symName); + ldrCommons[l-firstcommon].addr = (void *)pLookup[l].offset; + ldrCommons[l-firstcommon].name = pLookup[l].symName; + ldrCommons[l-firstcommon].namelen = strlen(pLookup[l].symName); } listCOMMON=common->next; offset+=common->sym->st_size; -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) || (defined(__sparc__) && (defined(__arch64__) || defined(__sparcv9))) offset = (offset+7)&~0x7; #endif xf86loaderfree(common); l++; } /* listCOMMON == 0 */ - lookup[l].symName=NULL; /* Terminate the list. */ - return lookup; + pLookup[l].symName=NULL; /* Terminate the list. */ + return TRUE; } @@ -463,6 +586,19 @@ symval=(Elf_Addr)( elffile->saddr[syms[index].st_shndx]+ syms[index].st_value); +#ifdef __ia64__ + if( ELF_ST_TYPE(syms[index].st_info) == STT_FUNC ) { + ELFOpdPtr opdent; + for (opdent = elffile->opd_entries; opdent; opdent = opdent->next) + if (opdent->index == index) + break; + if(opdent) { + ((unsigned long *)(elffile->got+opdent->offset))[0] = symval; + ((unsigned long *)(elffile->got+opdent->offset))[1] = (long)elffile->got; + symval = (Elf_Addr)(elffile->got+opdent->offset); + } + } +#endif break; case STB_GLOBAL: case STB_WEAK: /* STB_WEAK seems like a hack to cover for @@ -595,7 +731,7 @@ } #endif /* __powerpc__ */ -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) /* * Manage GOT Entries */ @@ -604,7 +740,7 @@ ELFModulePtr elffile; Elf_Rela *rel; { - ELFGotPtr gotent; + ELFGotEntryPtr gotent; #ifdef ELFDEBUG { @@ -636,7 +772,7 @@ return; } - if ((gotent = xf86loadermalloc(sizeof(ELFGotRec))) == NULL) { + if ((gotent = xf86loadermalloc(sizeof(ELFGotEntryRec))) == NULL) { ErrorF( "ElfAddGOT() Unable to allocate memory!!!!\n" ); return; } @@ -649,18 +785,23 @@ gotent->next=elffile->got_entries; elffile->got_entries=gotent; elffile->gotsize+=8; - return ; + return; } -void -ELFCreateGOT(elffile) +static int +ELFCreateGOT(elffile, maxalign) ELFModulePtr elffile; +int maxalign; { +#ifdef MergeSectionAlloc + ELFGotPtr gots; +#endif + int gotsize; #ifdef ELFDEBUG ELFDEBUG( "ELFCreateGOT: %x entries in the GOT\n", elffile->gotsize/8 ); #endif -#if ELFDEBUG +#ifdef ELFDEBUG /* * Hmmm. Someone is getting here without any got entries, but they * may still have R_ALPHA_GPDISP relocations against the got. @@ -670,18 +811,274 @@ _LoaderModuleToName(elffile->module) ); #endif if( elffile->gotsize == 0 ) elffile->gotsize=8; + elffile->sections[elffile->gotndx].sh_size=elffile->gotsize; + gotsize = elffile->gotsize; + +#ifdef MergeSectionAlloc +#ifdef __alpha__ +#define GOTDistance 0x100000 +#endif +#ifdef __ia64__ +#define GOTDistance 0x200000 +#endif + for (gots = ELFSharedGOTs; gots; gots = gots->next) { + if (gots->freeptr + elffile->gotsize > gots->section + gots->size) + continue; + if (gots->section > elffile->base) { + if (gots->section + gots->size - elffile->base >= GOTDistance) + continue; + } else { + if (elffile->base + elffile->basesize - gots->section >= GOTDistance) + continue; + } + elffile->got = gots->freeptr; + elffile->shared_got = gots; + gots->freeptr = gots->freeptr + elffile->gotsize; + gots->nuses++; +#ifdef ELFDEBUG + ELFDEBUG( "ELFCreateGOT: GOT address %lx in shared GOT, nuses %d\n", elffile->got, gots->nuses ); +#endif + return TRUE; + } - if ((elffile->got = xf86loadermalloc(elffile->gotsize)) == NULL) { + gotsize += 16383 + sizeof(ELFGotRec); +#endif + + if ((elffile->got = xf86loadermalloc(gotsize)) == NULL) { ErrorF( "ELFCreateGOT() Unable to allocate memory!!!!\n" ); - return; + return FALSE; } - elffile->sections[elffile->gotndx].sh_size=elffile->gotsize; + +#ifdef MergeSectionAlloc + if (elffile->got > elffile->base) { + if (elffile->got + elffile->gotsize - elffile->base >= GOTDistance) + gotsize = 0; + } else { + if (elffile->base + elffile->basesize - elffile->got >= GOTDistance) + gotsize = 0; + } + + if (!gotsize) { + xf86loaderfree(elffile->got); + elffile->basesize += 8 + elffile->gotsize; + elffile->base = xf86loaderrealloc(elffile->base, elffile->basesize); + if (elffile->base == NULL) { + ErrorF( "ELFCreateGOT() Unable to reallocate memory!!!!\n" ); + return FALSE; + } + elffile->baseptr = ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); + elffile->got = (unsigned char *)((long)(elffile->base + elffile->basesize - elffile->gotsize) & ~7); + } else { + gots = (ELFGotPtr)elffile->got; + elffile->got = gots->section; + gots->size = gotsize - sizeof(ELFGotRec) + 1; + gots->nuses = 1; + gots->freeptr = gots->section + elffile->gotsize; + gots->next = ELFSharedGOTs; + ELFSharedGOTs = gots; + elffile->shared_got = gots; #ifdef ELFDEBUG + ELFDEBUG( "ELFCreateGOT: Created a shareable GOT with size %d\n", gots->size); +#endif + } +#endif + +#ifdef ELFDEBUG ELFDEBUG( "ELFCreateGOT: GOT address %lx\n", elffile->got ); #endif + return TRUE; +} +#endif + +#if defined(__ia64__) +/* + * Manage OPD Entries + */ +static void +ElfAddOPD(elffile,index,l) +ELFModulePtr elffile; +int index; +LOOKUP *l; +{ + ELFOpdPtr opdent; + + if (index != -1) { + for (opdent = elffile->opd_entries; opdent; opdent = opdent->next) + if (opdent->index == index) + return; + } + + if ((opdent = xf86loadermalloc(sizeof(ELFOpdRec))) == NULL) { + ErrorF( "ElfAddOPD() Unable to allocate memory!!!!\n" ); + return; + } + +#ifdef ELFDEBUG + ELFDEBUG("OPD Entry %d added with offset %x\n",index,elffile->gotsize); +#endif + opdent->l=l; + opdent->index=index; + opdent->offset=elffile->gotsize; + opdent->next=elffile->opd_entries; + elffile->opd_entries=opdent; + elffile->gotsize+=16; + return ; +} + +static void +ELFCreateOPD(elffile) +ELFModulePtr elffile; +{ + ELFOpdPtr opdent, last = NULL; + + if (elffile->got == NULL) + ErrorF( "ELFCreateOPD() Unallocated GOT!!!!\n" ); + + for (opdent = elffile->opd_entries; opdent; last = opdent, opdent = opdent->next) { + if (last && last->index == -1) + xf86loaderfree(last); + if (opdent->index != -1) + continue; + ((unsigned long *)(elffile->got+opdent->offset))[0] = (long)opdent->l->offset; + ((unsigned long *)(elffile->got+opdent->offset))[1] = (long)elffile->got; + opdent->l->offset = (funcptr)(elffile->got+opdent->offset); + } + if (last && last->index == -1) + xf86loaderfree(last); +} + +/* + * Manage PLT Entries + */ +static void +ElfAddPLT(elffile,rel) +ELFModulePtr elffile; +Elf_Rela *rel; +{ + ELFPltEntryPtr pltent; + +#ifdef ELFDEBUG + { + Elf_Sym *sym; + char *namestr; + + sym=(Elf_Sym *)&(elffile->symtab[ELF_R_SYM(rel->r_info)]); + if( sym->st_name) { + ELFDEBUG("ElfAddPLT: Adding PLT entry for %s\n", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + } + else + ErrorF("ElfAddPLT: Add PLT entry for section??\n"); + } +#endif + + if (rel->r_addend) + ErrorF("ElfAddPLT: Add PLT entry with non-zero addend??\n"); + + for (pltent=elffile->plt_entries;pltent;pltent=pltent->next) { + if ( ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info) ) + break; + } + + if( pltent ) { +#ifdef ELFDEBUG + ELFDEBUG("Entry already present in PLT\n"); +#endif + return; + } + + if ((pltent = xf86loadermalloc(sizeof(ELFPltEntryRec))) == NULL) { + ErrorF( "ElfAddPLT() Unable to allocate memory!!!!\n" ); + return; + } + +#ifdef ELFDEBUG + ELFDEBUG("Entry added with offset %x\n",elffile->pltsize); +#endif + pltent->rel=rel; + pltent->offset=elffile->pltsize; + pltent->gotoffset=elffile->gotsize; + pltent->next=elffile->plt_entries; + elffile->plt_entries=pltent; + elffile->pltsize+=32; + elffile->gotsize+=16; + return ; +} + +static void +ELFCreatePLT(elffile) +ELFModulePtr elffile; +{ +#ifdef ELFDEBUG + ELFDEBUG( "ELFCreatePLT: %x entries in the PLT\n", elffile->pltsize/8 ); +#endif + + if( elffile->pltsize == 0 ) return; + + if ((elffile->plt = ELFLoaderSectCalloc(elffile,32,elffile->pltsize)) == NULL) { + ErrorF( "ELFCreatePLT() Unable to allocate memory!!!!\n" ); + return; + } + elffile->sections[elffile->pltndx].sh_size=elffile->pltsize; +#ifdef ELFDEBUG + ELFDEBUG( "ELFCreatePLT: PLT address %lx\n", elffile->plt ); +#endif + return; } + +static void +IA64InstallReloc(data128, slot, opnd, value) +unsigned long *data128; +int slot; +enum ia64_operand opnd; +long value; +{ + unsigned long data = 0; + +#ifdef ELFDEBUG + ELFDEBUG( "\nIA64InstallReloc %p %d %d %016lx\n", data128, slot, opnd, value); + ELFDEBUG( "Before [%016lx%016lx]\n", data128[1], data128[0]); +#endif + switch (slot) { + case 0: data = *data128; break; + case 1: memcpy(&data, (char *)data128 + 5, 8); break; + case 2: memcpy(&data, (char *)data128 + 10, 6); break; + default: FatalError("Unexpected slot in nIA64InstallReloc()\n"); + } + switch (opnd) { + case IA64_OPND_IMM22: + data &= ~(0x3fff9fc0000UL << slot); + data |= (value & 0x7f) << (18 + slot); /* [13:19] + 5 + slot */ + data |= (value & 0xff80) << (25 + slot); /* [27:35] + 5 + slot */ + data |= (value & 0x1f0000) << (11 + slot); /* [22:26] + 5 + slot */ + data |= (value & 0x200000) << (20 + slot); /* [36:36] + 5 + slot */ + if (value << 42 >> 42 != value) + ErrorF("Relocation %016lx truncated to fit into IMM22\n", value); + break; + case IA64_OPND_TGT25C: + data &= ~(0x23ffffc0000UL << slot); + data |= (value & 0xfffff0) << (14 + slot); /* [13:32] + 5 + slot */ + data |= (value & 0x1000000) << (17 + slot); /* [36:36] + 5 + slot */ + if (value << 39 >> 39 != value || (value & 0xf)) + ErrorF("Relocation %016lx truncated to fit into TGT25C\n", value); + break; + default: + FatalError("Unhandled operand in IA64InstallReloc()\n"); + } + switch (slot) { + case 0: *data128 = data; break; + case 1: memcpy((char *)data128 + 5, &data, 8); break; + case 2: memcpy((char *)data128 + 10, &data, 6); break; + default: FatalError("Unexpected slot in nIA64InstallReloc()\n"); + } +#ifdef ELFDEBUG + ELFDEBUG( "After [%016lx%016lx]\n", data128[1], data128[0]); +#endif +} + #endif /* @@ -697,7 +1094,7 @@ #if defined(i386) Elf_Rel *rel; #endif -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) Elf_Rela *rel; #endif int force; @@ -717,14 +1114,18 @@ * location of the got table */ #endif #endif - Elf_Addr symval; /* value of the indicated symbol */ +#if defined(__ia64__) + unsigned long *dest64; + unsigned long *dest128; +#endif + Elf_Addr symval = 0; /* value of the indicated symbol */ #ifdef ELFDEBUG #if defined(i386) ELFDEBUG( "%lx %d %d\n", rel->r_offset, ELF_R_SYM(rel->r_info),ELF_R_TYPE(rel->r_info) ); #endif -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) ELFDEBUG( "%x %d %d %x\n", rel->r_offset, ELF_R_SYM(rel->r_info),ELF_R_TYPE(rel->r_info), rel->r_addend ); @@ -845,7 +1246,7 @@ } case R_ALPHA_LITERAL: { - ELFGotPtr gotent; + ELFGotEntryPtr gotent; dest32=(unsigned int *)(secp+rel->r_offset); #ifdef ELFDEBUG { @@ -1491,12 +1892,182 @@ ErrorF("Elf_RelocateEntry() Copy relocs not supported on Sparc.\n"); break; #endif +#ifdef __ia64__ + case R_IA64_NONE: + break; + + case R_IA64_LTOFF_FPTR22: + if (rel->r_addend) + FatalError("\nAddend for R_IA64_LTOFF_FPTR22 not supported\n"); +#ifdef ELFDEBUG + ELFDEBUG( "opd=%016lx.%016lx\n", ((long *)symval)[0], ((long *)symval)[1] ); +#endif + /* FALLTHROUGH */ + case R_IA64_LTOFF22: + { + ELFGotEntryPtr gotent; + dest128=(unsigned long *)(secp+(rel->r_offset&~3)); +#ifdef ELFDEBUG + { + char *namestr; + ELFDEBUG( "%s %s\t", ELF_R_TYPE(rel->r_info) == R_IA64_LTOFF22 ? + "R_IA64_LTOFF22" : "R_IA64_LTOFF_FPTR22", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + ELFDEBUG( "secp=%lx\t", secp ); + ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG( "dest128=%lx\t", dest128 ); + ELFDEBUG( "slot=%ld\t", rel->r_offset & 3); + ELFDEBUG( "*dest128=[%016lx%016lx]\t", dest128[1], dest128[0]); + } +#endif + + for (gotent=elffile->got_entries;gotent;gotent=gotent->next) { + if ( ELF_R_SYM(gotent->rel->r_info) == ELF_R_SYM(rel->r_info) && + gotent->rel->r_addend == rel->r_addend ) + break; + } + + /* Set the address in the GOT */ + if( gotent ) { + *(unsigned long *)(elffile->got+gotent->offset) = + symval+rel->r_addend; +#ifdef ELFDEBUG + ELFDEBUG("Setting gotent[%x]=%lx\t", + gotent->offset, symval+rel->r_addend); +#endif + if ((gotent->offset & 0xffe00000) != 0) + FatalError("\nR_IA64_LTOFF22 offset %x too large\n", + gotent->offset); + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, gotent->offset); + } + else + FatalError("\nCould not find GOT entry\n"); + } + break; + + case R_IA64_PCREL21B: + { + ELFPltEntryPtr pltent; + dest128=(unsigned long *)(secp+(rel->r_offset&~3)); +#ifdef ELFDEBUG + { + char *namestr; + ELFDEBUG( "R_IA64_PCREL21B %s\t", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + ELFDEBUG( "secp=%lx\t", secp ); + ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG( "opd=%lx.%lx\t", ((long *)symval)[0], ((long *)symval)[1]); + ELFDEBUG( "dest128=%lx\t", dest128 ); + ELFDEBUG( "slot=%ld\t", rel->r_offset & 3); + ELFDEBUG( "*dest128=[%016lx%016lx]\t", dest128[1], dest128[0]); + } +#endif + if (rel->r_addend) + FatalError("\nAddend for PCREL21B not supported\n"); + if (((long *)symval)[1] == (long)elffile->got + && (((unsigned long)dest128 - ((unsigned long *)symval)[0]) + 0x2000000 < 0x4000000)) { + /* We can save the travel through PLT */ + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_TGT25C, + ((unsigned long *)symval)[0] - (unsigned long)dest128); + break; + } + for (pltent=elffile->plt_entries;pltent;pltent=pltent->next) { + if ( ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info) && + pltent->rel->r_addend == rel->r_addend ) + break; + } + + /* Set the address in the PLT */ + if (pltent == NULL) + FatalError("\nCould not find PLT entry\n"); + else { + unsigned long *p = (unsigned long *)(elffile->plt+pltent->offset); + unsigned long r = (unsigned long)symval - (unsigned long)elffile->got; + + if (r + 0x200000 >= 0x400000) { + /* Too far from gp to use the official function descriptor, + * so we have to make a local one. + */ + r = pltent->gotoffset; + memcpy(elffile->got+r, (char *)symval, 16); + } + + /* [MMI] addl r15=NNN,r1;; ld8 r16=[r15],8; mov r14=r1;; */ + p[0] = 0x410024000200780bUL; + p[1] = 0x84000801c028303cUL; + /* [MIB] ld8 r1=[r15]; mov b6=r16; br.few b6;; */ + p[2] = 0x806010181e000811UL; + p[3] = 0x0080006000038004UL; + IA64InstallReloc(p, 0, IA64_OPND_IMM22, r); + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_TGT25C, + (unsigned long)p - (unsigned long)dest128); + } + } + break; + + case R_IA64_FPTR64LSB: + dest64=(unsigned long *)(secp+rel->r_offset); +#ifdef ELFDEBUG + { + char *namestr; + ELFDEBUG( "R_IA64_FPTR64LSB %s\t", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + ELFDEBUG( "secp=%lx\t", secp ); + ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG( "dest64=%lx\t", dest64 ); + ELFDEBUG( "opd=%016lx.%016lx\n", ((long *)symval)[0], ((long *)symval)[1] ); + } +#endif + + if (rel->r_addend) + FatalError("\nAddend not supported for R_IA64_FPTR64LSB\n"); + *dest64 = symval; + break; + + case R_IA64_DIR64LSB: + dest64=(unsigned long *)(secp+rel->r_offset); +#ifdef ELFDEBUG + { + char *namestr; + ELFDEBUG( "R_IA64_DIR64LSB %s\t", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + ELFDEBUG( "secp=%lx\t", secp ); + ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG( "dest64=%lx\t", dest64 ); + } +#endif + *dest64 = symval + rel->r_addend; + break; + + case R_IA64_GPREL22: + dest128=(unsigned long *)(secp+(rel->r_offset&~3)); +#ifdef ELFDEBUG + { + char *namestr; + ELFDEBUG( "R_IA64_GPREL22 %s\t", + namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + xf86loaderfree(namestr); + ELFDEBUG( "secp=%lx\t", secp ); + ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG( "dest128=%lx\t", dest128 ); + ELFDEBUG( "slot=%ld\t", rel->r_offset & 3); + ELFDEBUG( "*dest128=[%016lx%016lx]\t", dest128[1], dest128[0]); + } +#endif + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, symval + rel->r_addend - (long)elffile->got); + break; + +#endif default: ErrorF( "Elf_RelocateEntry() Unsupported relocation type %d\n", ELF_R_TYPE(rel->r_info) ); break; - } + } return 0; } @@ -1510,7 +2081,7 @@ #if defined(i386) Elf_Rel *rel=(Elf_Rel *)elffile->saddr[index]; #endif -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__sparc__) || defined(__ia64__) Elf_Rela *rel=(Elf_Rela *)elffile->saddr[index]; #endif Elf_Sym *syms; @@ -1519,6 +2090,9 @@ ELFRelocPtr tmp; secp=(unsigned char *)elffile->saddr[sect->sh_info]; + if (secp == NULL) { + secp=(unsigned char *)(long)sect->sh_info; + } syms = (Elf_Sym *) elffile->saddr[elffile->symndx]; numrel=sect->sh_size/sect->sh_entsize; @@ -1529,6 +2103,21 @@ ElfAddGOT(elffile,&rel[i]); } #endif +#if defined(__ia64__) + if (ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF22 + || ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF_FPTR22) { + ElfAddGOT(elffile,&rel[i]); + } + if (ELF_R_TYPE(rel[i].r_info) == R_IA64_PCREL21B) { + ElfAddPLT(elffile,&rel[i]); + } + if (ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF_FPTR22 + || ELF_R_TYPE(rel[i].r_info) == R_IA64_FPTR64LSB) { + if (ELF_ST_BIND(syms[ELF_R_SYM(rel[i].r_info)].st_info) == STB_LOCAL) { + ElfAddOPD(elffile, ELF_R_SYM(rel[i].r_info), NULL); + } + } +#endif tmp = ElfDelayRelocation(elffile,secp,&(rel[i])); tmp->next = reloc_head; reloc_head = tmp; @@ -1544,14 +2133,16 @@ */ static LOOKUP * -ELF_GetSymbols(elffile) +ELF_GetSymbols(elffile, psecttable) ELFModulePtr elffile; +unsigned short **psecttable; { Elf_Sym *syms; Elf_Shdr *sect; int i, l, numsyms; - LOOKUP *lookup, *lookup_common, *p; + LOOKUP *lookup, *p; ELFCommonPtr tmp; + unsigned short *secttable; syms=elffile->symtab; sect=&(elffile->sections[elffile->symndx]); @@ -1560,6 +2151,12 @@ if ((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) return 0; + if ((secttable = xf86loadercalloc(sizeof(unsigned short),(numsyms+1))) == NULL) { + xf86loaderfree(lookup); + return 0; + } + *psecttable = secttable; + for(i=0,l=0; i<numsyms; i++) { #ifdef ELFDEBUG @@ -1607,13 +2204,17 @@ break; default: lookup[l].symName=xf86loaderstrdup(ElfGetString(elffile,syms[i].st_name)); - lookup[l].offset=(funcptr) - (elffile->saddr[syms[i].st_shndx]+ - syms[i].st_value); + lookup[l].offset=(funcptr)syms[i].st_value; + secttable[l] = syms[i].st_shndx; #ifdef ELFDEBUG - ELFDEBUG("Adding symbol %lx %s\n", - lookup[l].offset, lookup[l].symName ); + ELFDEBUG("Adding symbol %lx(%d) %s\n", + lookup[l].offset, secttable[l], lookup[l].symName ); #endif +#ifdef __ia64__ + if ( ELF_ST_TYPE(syms[i].st_info) == STT_FUNC ) { + ElfAddOPD(elffile, -1, &lookup[l]); + } +#endif l++; break; } @@ -1637,18 +2238,6 @@ lookup[l].symName=NULL; /* Terminate the list */ - lookup_common = ElfCreateCOMMON(elffile); - if (lookup_common) { - for (i = 0, p = lookup_common; p->symName; i++, p++) - ; - memcpy(&(lookup[l]), lookup_common, i * sizeof (LOOKUP)); - - xf86loaderfree(lookup_common); - l += i; - lookup[l].symName = NULL; - } - - /* * Remove the ELF symbols that will show up in every object module. */ @@ -1667,6 +2256,17 @@ #define SecOffset(index) elffile->sections[index].sh_offset #define SecSize(index) elffile->sections[index].sh_size +#define SecAlign(index) elffile->sections[index].sh_addralign + +#define AdjustSize(i) \ + if (!pass) { \ + if (SecAlign(i) > *maxalign) \ + *maxalign = SecAlign(i); \ + *totalsize += (SecAlign(i) - 1); \ + *totalsize &= ~(SecAlign(i) - 1); \ + *totalsize += SecSize(i); \ + continue; \ + } do { } while (0) /* * ELFCollectSections @@ -1674,8 +2274,11 @@ * Do the work required to load each section into memory. */ static void -ELFCollectSections(elffile) +ELFCollectSections(elffile,pass,totalsize,maxalign) ELFModulePtr elffile; +int pass; +int *totalsize; +int *maxalign; { int i; @@ -1694,114 +2297,132 @@ /* .text */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".text" ) == 0 ) { - elffile->text=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".text"); + AdjustSize(i); + elffile->text=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".text"); elffile->saddr[i]=elffile->text; elffile->txtndx=i; - elffile->txtsize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".text starts at %lx\n", elffile->text ); #endif + elffile->txtsize=SecSize(i); continue; } /* .data */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".data" ) == 0 ) { - elffile->data=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".data"); + AdjustSize(i); + elffile->data=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".data"); elffile->saddr[i]=elffile->data; elffile->datndx=i; - elffile->datsize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".data starts at %lx\n", elffile->data ); #endif - continue; - } + elffile->datsize=SecSize(i); + continue; + } if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".data1" ) == 0 ) { - elffile->data1=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".data1"); - elffile->saddr[i]=elffile->data1; - elffile->dat1ndx=i; - elffile->dat1size=SecSize(i); + AdjustSize(i); + elffile->data1=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".data1"); + elffile->saddr[i]=elffile->data1; + elffile->dat1ndx=i; #ifdef ELFDEBUG -ELFDEBUG(".data1 starts at %lx\n", elffile->data1 ); + ELFDEBUG(".data1 starts at %lx\n", elffile->data1 ); #endif - continue; - } + elffile->dat1size=SecSize(i); + continue; + } /* .sdata */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".sdata" ) == 0 ) { - elffile->sdata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".sdata"); + AdjustSize(i); + elffile->sdata=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".sdata"); elffile->saddr[i]=elffile->sdata; elffile->sdatndx=i; - elffile->sdatsize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".sdata starts at %lx\n", elffile->sdata ); #endif - continue; - } + elffile->sdatsize=SecSize(i); + AdjustSize(i); + continue; + } /* .bss */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".bss" ) == 0 ) { + AdjustSize(i); if( SecSize(i) ) - elffile->bss = xf86loadercalloc(1, SecSize(i)); + elffile->bss = ELFLoaderSectCalloc(elffile,SecAlign(i), + SecSize(i)); else elffile->bss=NULL; elffile->saddr[i]=elffile->bss; elffile->bssndx=i; - elffile->bsssize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".bss starts at %lx\n", elffile->bss ); #endif + elffile->bsssize=SecSize(i); continue; } /* .sbss */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".sbss" ) == 0 ) { + AdjustSize(i); if( SecSize(i) ) - elffile->sbss = xf86loadercalloc(1, SecSize(i)); + elffile->sbss = ELFLoaderSectCalloc(elffile,SecAlign(i), + SecSize(i)); else elffile->sbss=NULL; elffile->saddr[i]=elffile->sbss; elffile->sbssndx=i; - elffile->sbsssize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".sbss starts at %lx\n", elffile->sbss ); #endif + elffile->sbsssize=SecSize(i); continue; } /* .rodata */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rodata" ) == 0 ) { - elffile->rodata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rodata"); + AdjustSize(i); + elffile->rodata=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".rodata"); elffile->saddr[i]=elffile->rodata; elffile->rodatndx=i; - elffile->rodatsize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".rodata starts at %lx\n", elffile->rodata ); #endif - continue; - } + elffile->rodatsize=SecSize(i); + continue; + } if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rodata1" ) == 0 ) { - elffile->rodata1=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rodata1"); - elffile->saddr[i]=elffile->rodata1; - elffile->rodat1ndx=i; - elffile->rodat1size=SecSize(i); + AdjustSize(i); + elffile->rodata1=ELFLoaderSectToMem(elffile,SecAlign(i), + SecOffset(i),SecSize(i), + ".rodata1"); + elffile->saddr[i]=elffile->rodata1; + elffile->rodat1ndx=i; #ifdef ELFDEBUG -ELFDEBUG(".rodata1 starts at %lx\n", elffile->rodata1 ); + ELFDEBUG(".rodata1 starts at %lx\n", elffile->rodata1 ); #endif - continue; - } + elffile->rodat1size=SecSize(i); + continue; + } /* .symtab */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".symtab" ) == 0 ) { - elffile->symtab=(Elf_Sym *)_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".symtab"); + if (pass) continue; + elffile->symtab=(Elf_Sym *)_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".symtab"); elffile->saddr[i]=(unsigned char *)elffile->symtab; elffile->symndx=i; elffile->symsize=SecSize(i); @@ -1813,8 +2434,9 @@ /* .strtab */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".strtab" ) == 0 ) { - elffile->straddr=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".strtab"); + if (pass) continue; + elffile->straddr=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".strtab"); elffile->saddr[i]=(unsigned char *)elffile->straddr; elffile->strndx=i; elffile->strsize=SecSize(i); @@ -1823,12 +2445,13 @@ #endif continue; } -#if defined(i386) || defined(__alpha__) +#if defined(i386) || defined(__alpha__) || defined(__ia64__) /* .rel.text */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rel.text" ) == 0 ) { - elffile->reltext=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rel.text"); + if (pass) continue; + elffile->reltext=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rel.text"); elffile->saddr[i]=(unsigned char *)elffile->reltext; elffile->reltxtndx=i; elffile->reltxtsize=SecSize(i); @@ -1840,8 +2463,9 @@ /* .rel.data */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rel.data" ) == 0 ) { - elffile->reldata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rel.data"); + if (pass) continue; + elffile->reldata=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rel.data"); elffile->saddr[i]=(unsigned char *)elffile->reldata; elffile->reldatndx=i; elffile->reldatsize=SecSize(i); @@ -1853,23 +2477,25 @@ /* .rel.rodata */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rel.rodata" ) == 0 ) { - elffile->relrodata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rel.rodata"); + if (pass) continue; + elffile->relrodata=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rel.rodata"); elffile->saddr[i]=(unsigned char *)elffile->relrodata; elffile->relrodatndx=i; elffile->relrodatsize=SecSize(i); #ifdef ELFDEBUG ELFDEBUG(".rel.rodata starts at %lx\n", elffile->relrodata ); #endif - continue; - } + continue; + } #endif /* i386/alpha */ -#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__mc68000__) || defined(__alpha__) || defined(__sparc__) || defined(__ia64__) /* .rela.text */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rela.text" ) == 0 ) { - elffile->reltext=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rela.text"); + if (pass) continue; + elffile->reltext=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rela.text"); elffile->saddr[i]=(unsigned char *)elffile->reltext; elffile->reltxtndx=i; elffile->reltxtsize=SecSize(i); @@ -1881,8 +2507,9 @@ /* .rela.data */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rela.data" ) == 0 ) { - elffile->reldata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rela.data"); + if (pass) continue; + elffile->reldata=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rela.data"); elffile->saddr[i]=(unsigned char *)elffile->reldata; elffile->reldatndx=i; elffile->reldatsize=SecSize(i); @@ -1894,8 +2521,9 @@ /* .rela.sdata */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rela.sdata" ) == 0 ) { - elffile->relsdata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rela.sdata"); + if (pass) continue; + elffile->relsdata=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rela.sdata"); elffile->saddr[i]=(unsigned char *)elffile->relsdata; elffile->relsdatndx=i; elffile->relsdatsize=SecSize(i); @@ -1907,8 +2535,9 @@ /* .rela.rodata */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".rela.rodata" ) == 0 ) { - elffile->relrodata=_LoaderFileToMem(elffile->fd, - SecOffset(i),SecSize(i),".rela.rodata"); + if (pass) continue; + elffile->relrodata=_LoaderFileToMem(elffile->fd,SecOffset(i), + SecSize(i),".rela.rodata"); elffile->saddr[i]=(unsigned char *)elffile->relrodata; elffile->relrodatndx=i; elffile->relrodatsize=SecSize(i); @@ -1973,6 +2602,11 @@ ".stabstr" ) == 0 ) { continue; } + /* .stab.* */ + if( strncmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".stab.", strlen(".stab.") ) == 0 ) { + continue; + } #if defined(__powerpc__) || defined(__mc68000__) /* .rela.tdesc */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), @@ -2000,23 +2634,59 @@ continue; } #endif -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) /* .got */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".got" ) == 0 ) { continue; - elffile->got=NULL; - elffile->gotsize=0; - elffile->got_entries=NULL; } +#endif +#if defined(__alpha__) /* .mdebug */ if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), ".mdebug" ) == 0 ) { continue; } +#endif +#if defined(__ia64__) + /* .plt */ + if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".plt" ) == 0 ) { + continue; + } + /* .IA_64.unwind, .IA_64.unwind_info and .rela.IA_64.unwind */ + /* FIXME I believe we don't need these */ + if( strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".IA_64.unwind" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".rela.IA_64.unwind" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".IA_64.unwind_info" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".debug_abbrev" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".debug_info" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".rela.debug_info" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".debug_line" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".rela.debug_line" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".debug_pubnames" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".rela.debug_pubnames" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".debug_aranges" ) == 0 + || strcmp(ElfGetSectionName(elffile, elffile->sections[i].sh_name), + ".rela.debug_aranges" ) == 0 + ) { + continue; + } #endif - ErrorF("Not loading %s\n", - ElfGetSectionName(elffile, elffile->sections[i].sh_name) ); + if (pass) + ErrorF("Not loading %s\n", + ElfGetSectionName(elffile, elffile->sections[i].sh_name) ); } } @@ -2034,6 +2704,9 @@ ELFRelocPtr elf_reloc, tail; void *v; LDRModulePtr elfmod; + int totalsize, maxalign, i; + unsigned short *secttable; + LOOKUP *pLookup; ldrCommons = 0; nCommons = 0; @@ -2061,20 +2734,24 @@ elffile->secsize=(header->e_shentsize*header->e_shnum); elffile->sections=(Elf_Shdr *)_LoaderFileToMem(elffd,header->e_shoff, elffile->secsize, "sections"); -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) /* * Need to allocate space for the .got section which will be * fabricated later */ elffile->gotndx=header->e_shnum; header->e_shnum++; +#if defined(__ia64__) + elffile->pltndx=header->e_shnum; + header->e_shnum++; +#endif elffile->numsh=header->e_shnum; elffile->secsize=(header->e_shentsize*header->e_shnum); elffile->sections=xf86loaderrealloc(elffile->sections,elffile->secsize); #endif elffile->saddr=xf86loadercalloc(elffile->numsh, sizeof(unsigned char *)); -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) /* * Manually fill in the entry for the .got section so ELFCollectSections() * will be able to find it. @@ -2087,6 +2764,19 @@ /* Add room to copy ".got", and maintain alignment */ SecSize(header->e_shstrndx)+=8; #endif +#if defined(__ia64__) + /* + * Manually fill in the entry for the .plt section so ELFCollectSections() + * will be able to find it. + */ + elffile->sections[elffile->pltndx].sh_name=SecSize(header->e_shstrndx)+1; + elffile->sections[elffile->pltndx].sh_type=SHT_PROGBITS; + elffile->sections[elffile->pltndx].sh_flags=SHF_EXECINSTR|SHF_ALLOC; + elffile->sections[elffile->pltndx].sh_size=0; + elffile->sections[elffile->pltndx].sh_addralign=32; + /* Add room to copy ".plt", and maintain alignment */ + SecSize(header->e_shstrndx)+=32; +#endif /* * Get the section header string table @@ -2095,18 +2785,27 @@ elffile->shstraddr = _LoaderFileToMem(elffd,SecOffset(header->e_shstrndx), SecSize(header->e_shstrndx),".shstrtab"); elffile->shstrndx = header->e_shstrndx; -#if defined(__alpha__) +#if defined(__alpha__) || defined(__ia64__) /* * Add the string for the .got section */ strcpy((char*)(elffile->shstraddr+elffile->sections[elffile->gotndx].sh_name), ".got"); #endif +#if defined(__ia64__) + /* + * Add the string for the .plt section + */ + strcpy((char*)(elffile->shstraddr+elffile->sections[elffile->pltndx].sh_name), + ".plt"); +#endif /* - * Load the rest of the desired sections + * Load some desired sections, compute size of the remaining ones */ - ELFCollectSections(elffile); + totalsize = 0; + maxalign = 0; + ELFCollectSections(elffile, 0, &totalsize, &maxalign); if( elffile->straddr == NULL || elffile->strsize == 0 ) { ErrorF("No symbols found in this module\n"); @@ -2117,7 +2816,7 @@ /* * add symbols */ - *ppLookup = ELF_GetSymbols(elffile); + *ppLookup = pLookup = ELF_GetSymbols(elffile, §table); /* * Do relocations @@ -2159,10 +2858,60 @@ } } -#if defined(__alpha__) - ELFCreateGOT(elffile); +#if defined(__ia64__) + totalsize += (elffile->sections[elffile->pltndx].sh_addralign - 1); + totalsize &= ~(elffile->sections[elffile->pltndx].sh_addralign - 1); + totalsize += elffile->pltsize; + if (maxalign < elffile->sections[elffile->pltndx].sh_addralign) + maxalign = elffile->sections[elffile->pltndx].sh_addralign; +#endif + + /* Space for COMMON */ + totalsize = (totalsize + 7) & ~7; + totalsize += ElfCOMMONSize(); + +#ifdef MergeSectionAlloc + elffile->basesize = totalsize + maxalign; + elffile->base = xf86loadermalloc(elffile->basesize); + if (elffile->base == NULL) { + ErrorF( "Unable to allocate ELF sections\n" ); + return NULL; + } + elffile->baseptr = ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); +#endif + +#if defined(__alpha__) || defined(__ia64__) + if (! ELFCreateGOT(elffile, maxalign)) + return NULL; +#endif +#if defined(__ia64__) + ELFCreatePLT(elffile); +#endif + + ELFCollectSections(elffile, 1, NULL, NULL); + + for (i = 0; pLookup[i].symName; i++) + if (secttable[i]) { + pLookup[i].offset = (funcptr)((long)pLookup[i].offset + (long)elffile->saddr[secttable[i]]); +#ifdef ELFDEBUG + ELFDEBUG("Finalizing symbol %lx %s\n", + pLookup[i].offset, pLookup[i].symName); +#endif + } + xf86loaderfree(secttable); + + for (elf_reloc = _LoaderGetRelocations(v)->elf_reloc; + elf_reloc; elf_reloc = elf_reloc->next) + if ((unsigned long)elf_reloc->secp < elffile->numsh) + elf_reloc->secp = (unsigned char *)elffile->saddr[(unsigned long)elf_reloc->secp]; + +#if defined(__ia64__) + ELFCreateOPD(elffile); #endif + if (! ElfCreateCOMMON(elffile, *ppLookup)) + return NULL; + /* Record info for gdb - if we can't allocate the loader record fail silently (the user will find out soon enough that there's no VM left */ if ((elfmod = xf86loadercalloc(1, sizeof(LDRModuleRec))) != NULL) { @@ -2272,25 +3021,41 @@ /* * Free the sections that were allocated. */ -#define CheckandFree(ptr,size) if(ptr) _LoaderFreeFileMem((ptr),(size)) +#define CheckandFree(ptr,size) if(ptr) xf86loaderfree(ptr) +#define CheckandFreeFile(ptr,size) if(ptr) _LoaderFreeFileMem((ptr),(size)) - CheckandFree(elffile->straddr,elffile->strsize); - CheckandFree(elffile->symtab,elffile->symsize); - CheckandFree(elffile->text,elffile->txtsize); - CheckandFree(elffile->data,elffile->datsize); - CheckandFree(elffile->data1,elffile->dat1size); - CheckandFree(elffile->sdata,elffile->sdatsize); + CheckandFreeFile(elffile->straddr,elffile->strsize); + CheckandFreeFile(elffile->symtab,elffile->symsize); +#ifdef MergeSectionAlloc + CheckandFree(elffile->base,elffile->basesize); +#if defined(__alpha__) || defined(__ia64__) + if (elffile->shared_got) { + elffile->shared_got->nuses--; + if (!elffile->shared_got->nuses) + xf86loaderfree(elffile->shared_got); + } +#endif +#else + CheckandFreeFile(elffile->text,elffile->txtsize); + CheckandFreeFile(elffile->data,elffile->datsize); + CheckandFreeFile(elffile->data1,elffile->dat1size); + CheckandFreeFile(elffile->sdata,elffile->sdatsize); CheckandFree(elffile->bss,elffile->bsssize); - CheckandFree(elffile->rodata,elffile->rodatsize); - CheckandFree(elffile->reltext,elffile->reltxtsize); - CheckandFree(elffile->reldata,elffile->reldatsize); - CheckandFree(elffile->relrodata,elffile->relrodatsize); - CheckandFree(elffile->relsdata,elffile->relsdatsize); -#if defined(__alpha__) + CheckandFree(elffile->sbss,elffile->sbsssize); + CheckandFreeFile(elffile->rodata,elffile->rodatsize); + CheckandFreeFile(elffile->rodata1,elffile->rodat1size); + CheckandFree(elffile->common,elffile->comsize); +#if defined(__ia64__) + CheckandFree(elffile->plt,elffile->pltsize); +#endif +#if defined(__alpha__) || defined(__ia64__) CheckandFree(elffile->got,elffile->gotsize); +#endif #endif - if( elffile->common ) - xf86loaderfree(elffile->common); + CheckandFreeFile(elffile->reltext,elffile->reltxtsize); + CheckandFreeFile(elffile->reldata,elffile->reldatsize); + CheckandFreeFile(elffile->relrodata,elffile->relrodatsize); + CheckandFreeFile(elffile->relsdata,elffile->relsdatsize); /* * Free the section table, section pointer array, and section names */ @@ -2319,6 +3084,6 @@ return ElfGetSectionName(elffile, elffile->sections[i].sh_name); } } -return NULL; + return NULL; } Index: xc/programs/Xserver/hw/xfree86/loader/extsym.c diff -u xc/programs/Xserver/hw/xfree86/loader/extsym.c:1.4 xc/programs/Xserver/hw/xfree86/loader/extsym.c:1.5 --- xc/programs/Xserver/hw/xfree86/loader/extsym.c:1.4 Thu Mar 30 13:20:58 2000 +++ xc/programs/Xserver/hw/xfree86/loader/extsym.c Wed Nov 1 17:50:04 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.4 2000/03/30 18:20:58 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.5 2000/11/01 22:50:04 anderson Exp $ */ /* * @@ -31,9 +31,11 @@ #include "panoramiX.h" #endif +#ifdef HAS_SHM extern int ShmCompletionCode; extern int BadShmSegCode; extern RESTYPE ShmSegType, ShmPixType; +#endif #ifdef PANORAMIX extern Bool noPanoramiXExtension; @@ -50,9 +52,11 @@ LOOKUP extLookupTab[] = { +#ifdef HAS_SHM SYMVAR(ShmCompletionCode) SYMVAR(BadShmSegCode) SYMVAR(ShmSegType) +#endif #ifdef PANORAMIX SYMFUNC(XineramaRegisterConnectionBlockCallback) Index: xc/programs/Xserver/hw/xfree86/loader/hash.c diff -u xc/programs/Xserver/hw/xfree86/loader/hash.c:1.12 xc/programs/Xserver/hw/xfree86/loader/hash.c:1.13 --- xc/programs/Xserver/hw/xfree86/loader/hash.c:1.12 Sat Mar 13 22:22:13 1999 +++ xc/programs/Xserver/hw/xfree86/loader/hash.c Tue Sep 26 11:57:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.12 1999/03/14 03:22:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.13 2000/09/26 15:57:18 tsi Exp $ */ /* * @@ -258,7 +258,7 @@ entry=LoaderHashFindNearest(address); if (entry) { const char *module, *section; -#ifdef __alpha__ +#if defined(__alpha__) || defined(__ia64__) ErrorF("0x%016lx %s+%lx\n", entry->address, entry->name, address - (unsigned long) entry->address); #else @@ -278,7 +278,7 @@ { if (pItem) { const char *module, *section; -#ifdef __alpha__ +#if defined(__alpha__) || defined(__ia64__) ErrorF("0x%016lx %s\n", pItem->address, pItem->name); #else ErrorF("0x%lx %s\n", pItem->address, pItem->name); Index: xc/programs/Xserver/hw/xfree86/loader/loader.c diff -u xc/programs/Xserver/hw/xfree86/loader/loader.c:1.41 xc/programs/Xserver/hw/xfree86/loader/loader.c:1.49 --- xc/programs/Xserver/hw/xfree86/loader/loader.c:1.41 Mon Apr 17 12:30:12 2000 +++ xc/programs/Xserver/hw/xfree86/loader/loader.c Wed Dec 13 11:52:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.41 2000/04/17 16:30:12 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.49 2000/12/13 16:52:01 tsi Exp $ */ /* * @@ -26,14 +26,15 @@ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> -#ifdef UseMMAP +#if defined(UseMMAP) || (defined(linux) && defined(__ia64__)) #include <sys/mman.h> #endif #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> -#if defined(linux) && (defined(__alpha__) || defined(__powerpc__)) +#if defined(linux) && \ + (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__)) #include <malloc.h> #endif #include <stdarg.h> @@ -48,6 +49,9 @@ #include "xf86.h" #include "xf86Priv.h" +#define NO_COMPILER_H_EXTRAS +#include "compiler.h" + extern LOOKUP miLookupTab[]; extern LOOKUP xfree86LookupTab[]; extern LOOKUP dixLookupTab[]; @@ -84,12 +88,76 @@ static int refCount[MAX_HANDLE] ; #endif -#ifdef __sparc__ -extern LOOKUP SparcLookupTab[]; +#if defined(__sparc__) && defined(__GNUC__) +# define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func }, +# define SYMFUNCDOT89(func) { "." #func, (funcptr)&func ## _sparcv89 }, +# define DEFFUNCDOT(func) \ +extern void __sparc_dot_ ## func (void) __asm__ ("." #func); \ +extern void func ## _sparcv89 (void); +DEFFUNCDOT(rem) +DEFFUNCDOT(urem) +DEFFUNCDOT(mul) +DEFFUNCDOT(umul) +DEFFUNCDOT(div) +DEFFUNCDOT(udiv) +static LOOKUP SparcV89LookupTab[] = { + SYMFUNCDOT89(rem) + SYMFUNCDOT89(urem) + SYMFUNCDOT89(mul) + SYMFUNCDOT89(umul) + SYMFUNCDOT89(div) + SYMFUNCDOT89(udiv) + { 0, 0 } +}; +static LOOKUP SparcLookupTab[] = { + SYMFUNCDOT(rem) + SYMFUNCDOT(urem) + SYMFUNCDOT(mul) + SYMFUNCDOT(umul) + SYMFUNCDOT(div) + SYMFUNCDOT(udiv) + { 0, 0 } +}; #ifdef linux -extern int sparcUseHWMulDiv(void); -extern LOOKUP SparcV89LookupTab[]; +#if defined(__GNUC__) && defined(__GLIBC__) +#define HWCAP_SPARC_MULDIV 8 +extern unsigned long int _dl_hwcap; #endif + +static int +sparcUseHWMulDiv(void) +{ + FILE *f; + char buffer[1024]; + char *p; +#if defined(__GNUC__) && defined(__GLIBC__) + unsigned long *hwcap; + __asm(".weak _dl_hwcap"); + + hwcap = &_dl_hwcap; + __asm("" : "=r" (hwcap) : "0" (hwcap)); + if (hwcap) { + if (*hwcap & HWCAP_SPARC_MULDIV) + return 1; + else + return 0; + } +#endif + f = fopen("/proc/cpuinfo","r"); + if (!f) return 0; + while (fgets(buffer, 1024, f) != NULL) { + if (!strncmp (buffer, "type", 4)) { + p = strstr (buffer, "sun4"); + if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { + fclose(f); + return 1; + } + } + } + fclose(f); + return 0; +} +#endif #endif /* @@ -252,7 +320,8 @@ if (osname) xf86MsgVerb(X_INFO, 2, "Loader running on %s\n", osname); -#if defined(linux) && (defined(__alpha__) || defined(__powerpc__)) +#if defined(linux) && \ + (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__)) /* * The glibc malloc uses mmap for large allocations anyway. This breaks * some relocation types because the offset overflow. See loader.h for more @@ -384,7 +453,17 @@ if( (ptr=os2ldcalloc(size,1)) == NULL ) FatalError("_LoaderFileToMem() malloc failed\n" ); #endif +#if defined(linux) && defined(__ia64__) + { + unsigned long page_size = getpagesize(); + unsigned long round; + round = (unsigned long)ptr & (page_size-1); + mprotect(ptr - round, (size+round+page_size-1) & ~(page_size-1), + PROT_READ|PROT_WRITE|PROT_EXEC); + } +#endif + if(lseek(fd,offset+offsetbias,SEEK_SET)<0) FatalError("\n_LoaderFileToMem() lseek() failed: %s\n",strerror(errno)); @@ -392,6 +471,10 @@ FatalError("\n_LoaderFileToMem() read() failed: %s\n",strerror(errno)); #if defined(linux) && defined(__powerpc__) + /* + * Keep the instruction cache in sync with changes in the + * main memory. + */ { int i; for (i = 0; i < size; i += 16) @@ -1229,3 +1312,24 @@ void _loader_debug_state() { } + +unsigned long LoaderOptions = 0; + +void +LoaderResetOptions(void) +{ + LoaderOptions = 0; +} + +void +LoaderSetOptions(unsigned long opts) +{ + LoaderOptions |= opts; +} + +void +LoaderClearOptions(unsigned long opts) +{ + LoaderOptions &= ~opts; +} + Index: xc/programs/Xserver/hw/xfree86/loader/loader.h diff -u xc/programs/Xserver/hw/xfree86/loader/loader.h:1.21 xc/programs/Xserver/hw/xfree86/loader/loader.h:1.23 --- xc/programs/Xserver/hw/xfree86/loader/loader.h:1.21 Mon Jun 14 03:31:55 1999 +++ xc/programs/Xserver/hw/xfree86/loader/loader.h Mon Nov 13 18:09:56 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.h,v 1.21 1999/06/14 07:31:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.h,v 1.23 2000/11/13 23:09:56 dawes Exp $ */ /* * @@ -136,7 +136,7 @@ * are mapped to either to the regular Xserver functions, or in a couple * of special cases, mapped to the C library functions. */ -#if !defined(PowerMAX_OS) && !(defined(linux) && (defined(__alpha__) || defined(__powerpc__))) && 0 +#if !defined(PowerMAX_OS) && !(defined(linux) && (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__))) && 0 #define xf86loadermalloc(size) xalloc(size) #define xf86loaderrealloc(ptr,size) xrealloc(ptr,size) #define xf86loadercalloc(num,size) xcalloc(num,size) @@ -155,6 +155,7 @@ * PowerMAX_OS/PPC * Linux/Alpha * Linux/PPC + * Linux/IA-64 */ #define xf86loadermalloc(size) malloc(size) #define xf86loaderrealloc(ptr,size) realloc(ptr,size) @@ -206,6 +207,8 @@ INT32 fontVersion; } ModuleVersions; extern ModuleVersions LoaderVersionInfo; + +extern unsigned long LoaderOptions; /* Internal Functions */ Index: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h diff -u xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h:1.16 xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h:1.17 --- xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h:1.16 Sat Jan 29 12:17:05 2000 +++ xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h Mon Nov 13 18:09:57 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h,v 1.16 2000/01/29 17:17:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h,v 1.17 2000/11/13 23:09:57 dawes Exp $ */ /* * @@ -80,5 +80,13 @@ void LoaderShowStack(void); void *LoaderSymbolHandle(const char *, int); int LoaderUnload(int); + +void LoaderResetOptions(void); +void LoaderSetOptions(unsigned long); +void LoaderClearOptions(unsigned long); + +/* Options for LoaderSetOptions */ +#define LDR_OPT_ABI_MISMATCH_NONFATAL 0x0001 + #endif /* _LOADERPROCS_H */ Index: xc/programs/Xserver/hw/xfree86/loader/loadmod.c diff -u xc/programs/Xserver/hw/xfree86/loader/loadmod.c:1.53 xc/programs/Xserver/hw/xfree86/loader/loadmod.c:1.58 --- xc/programs/Xserver/hw/xfree86/loader/loadmod.c:1.53 Tue Jun 6 22:13:03 2000 +++ xc/programs/Xserver/hw/xfree86/loader/loadmod.c Wed Dec 13 11:52:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.53 2000/06/07 02:13:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.58 2000/12/13 16:52:01 tsi Exp $ */ /* * @@ -28,7 +28,7 @@ #include "os.h" /* For stat() and related stuff */ #define NO_OSLIB_PROTOTYPES -#define NO_COMPILER_H +#define NO_COMPILER_H_EXTRAS #include "xf86_OSlib.h" #if defined(SVR4) #include <sys/stat.h> @@ -545,6 +545,7 @@ int vercode[3]; char verstr[4]; long ver = data->xf86version; + int errtype = 0; xf86Msg (X_INFO, "Module %s: vendor=\"%s\"\n", data->modname ? data->modname : "UNKNOWN!", @@ -593,17 +594,27 @@ vermaj = GET_ABI_MAJOR(ver); vermin = GET_ABI_MINOR(ver); if (abimaj != vermaj) { - /* XXX This should be an error condition */ - xf86MsgVerb(X_WARNING, 0, + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, "module ABI major version (%d) doesn't" " match the server's version (%d)\n", abimaj, vermaj); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; } else if (abimin > vermin) { - /* XXX This should be an error condition */ - xf86MsgVerb(X_WARNING, 0, + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, "module ABI minor version (%d) is " "newer than the server's version " "(%d)\n", abimin, vermin); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; } } } @@ -994,6 +1005,16 @@ TestFree (found); TestFree (name); TestFree (p); + + /* + * If you need to do something to keep the + * instruction cache in sync with the main + * memory before jumping to that code, you may + * do it here. + */ +#ifdef __alpha__ + istream_mem_barrier(); +#endif return ret; } @@ -1035,6 +1056,9 @@ TestFree (mod->name); TestFree (mod->filename); xfree (mod); +#ifdef __alpha__ + istream_mem_barrier(); +#endif } void Index: xc/programs/Xserver/hw/xfree86/loader/misym.c diff -u xc/programs/Xserver/hw/xfree86/loader/misym.c:1.31 xc/programs/Xserver/hw/xfree86/loader/misym.c:1.32 --- xc/programs/Xserver/hw/xfree86/loader/misym.c:1.31 Thu May 18 19:21:41 2000 +++ xc/programs/Xserver/hw/xfree86/loader/misym.c Tue Sep 19 22:05:11 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.31 2000/05/18 23:21:41 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.32 2000/09/20 02:05:11 keithp Exp $ */ /* * @@ -148,6 +148,7 @@ SYMFUNC(miSetVisualTypes) SYMFUNC(miSetVisualTypesAndMasks) SYMFUNC(miGetDefaultVisualMask) + SYMFUNC(miSetPixmapDepths) SYMFUNC(miInitVisuals) SYMFUNC(miWindowExposures) SYMFUNC(miSegregateChildren) Index: xc/programs/Xserver/hw/xfree86/loader/sym.h diff -u xc/programs/Xserver/hw/xfree86/loader/sym.h:1.4 xc/programs/Xserver/hw/xfree86/loader/sym.h:1.6 --- xc/programs/Xserver/hw/xfree86/loader/sym.h:1.4 Sun Mar 14 06:18:06 1999 +++ xc/programs/Xserver/hw/xfree86/loader/sym.h Mon Oct 23 20:06:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/sym.h,v 1.4 1999/03/14 11:18:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/sym.h,v 1.6 2000/10/24 00:06:55 anderson Exp $ */ /* * @@ -39,6 +39,8 @@ } LOOKUP; #define SYMFUNC( func ) { #func, (funcptr)&func }, +#define SYMFUNCALIAS( name, func ) { name, (funcptr)&func }, #define SYMVAR( var ) { #var, (funcptr)&var }, +#define SYMVARALIAS( name, var ) { name, (funcptr)&var }, #endif /* _SYM_H */ Index: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c diff -u xc/programs/Xserver/hw/xfree86/loader/xf86sym.c:1.155 xc/programs/Xserver/hw/xfree86/loader/xf86sym.c:1.178 --- xc/programs/Xserver/hw/xfree86/loader/xf86sym.c:1.155 Fri Jun 30 15:06:58 2000 +++ xc/programs/Xserver/hw/xfree86/loader/xf86sym.c Fri Dec 8 17:31:52 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.155 2000/06/30 19:06:58 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.178 2000/12/08 22:31:52 dawes Exp $ */ /* * @@ -38,7 +38,7 @@ #include "xf86Parser.h" #include "xf86Config.h" #ifdef XINPUT -#include "xf86Xinput.h" +# include "xf86Xinput.h" #endif #include "xf86OSmouse.h" #include "xf86xv.h" @@ -54,6 +54,10 @@ #include "xf86Priv.h" #include "vbe.h" #include "xf86sbusBus.h" +#ifdef __alpha__ +/* MMIO function prototypes */ +#include "compiler.h" +#endif #ifdef __FreeBSD__ /* XXX used in drmOpen(). This should change to use a less os-specific @@ -62,13 +66,13 @@ #endif /* XXX Should get all of these from elsewhere */ -#if defined (PowerMAX_OS) -#undef inb -#undef inw -#undef inl -#undef outb -#undef outw -#undef outl +#if defined(PowerMAX_OS) || (defined(sun) && defined(SVR4)) +# undef inb +# undef inw +# undef inl +# undef outb +# undef outw +# undef outl extern void outb(unsigned int a, unsigned char b); extern void outw(unsigned int a, unsigned short w); @@ -79,7 +83,7 @@ #endif #if defined(__alpha__) -#ifdef linux +# ifdef linux extern unsigned long _bus_base(void); extern void _outb(char val, unsigned short port); extern void _outw(short val, unsigned short port); @@ -87,17 +91,17 @@ extern unsigned int _inb(unsigned short port); extern unsigned int _inw(unsigned short port); extern unsigned int _inl(unsigned short port); -#endif +# endif -#ifdef __FreeBSD__ -#include <sys/types.h> +# ifdef __FreeBSD__ +# include <sys/types.h> extern void outb(u_int32_t port, u_int8_t val); extern void outw(u_int32_t port, u_int16_t val); extern void outl(u_int32_t port, u_int32_t val); extern u_int8_t inb(u_int32_t port); extern u_int16_t inw(u_int32_t port); extern u_int32_t inl(u_int32_t port); -#endif +# endif extern void* __divl(long, long); extern void* __reml(long, long); @@ -109,36 +113,19 @@ extern void* __remqu(long, long); #endif -#if defined(__sparc__) && defined(__GNUC__) -#define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func }, -#define SYMFUNCDOT89(func) { "." #func, (funcptr)&func ## _sparcv89 }, -#define DEFFUNCDOT(func) \ -extern void __sparc_dot_ ## func (void) __asm__ ("." #func); \ -extern void func ## _sparcv89 (void); -DEFFUNCDOT(rem) -DEFFUNCDOT(urem) -DEFFUNCDOT(mul) -DEFFUNCDOT(umul) -DEFFUNCDOT(div) -DEFFUNCDOT(udiv) -LOOKUP SparcV89LookupTab[] = { - SYMFUNCDOT89(rem) - SYMFUNCDOT89(urem) - SYMFUNCDOT89(mul) - SYMFUNCDOT89(umul) - SYMFUNCDOT89(div) - SYMFUNCDOT89(udiv) - { 0, 0 } -}; -LOOKUP SparcLookupTab[] = { - SYMFUNCDOT(rem) - SYMFUNCDOT(urem) - SYMFUNCDOT(mul) - SYMFUNCDOT(umul) - SYMFUNCDOT(div) - SYMFUNCDOT(udiv) - { 0, 0 } -}; +#if defined(__ia64__) +extern long __divdf3(long, long); +extern long __divdi3(long, long); +extern long __divsf3(long, long); +extern long __moddi3(long, long); +extern long __udivdi3(long, long); +extern long __umoddi3(long, long); +extern void _outb(char val, unsigned short port); +extern void _outw(short val, unsigned short port); +extern void _outl(int val, unsigned short port); +extern unsigned int _inb(unsigned short port); +extern unsigned int _inw(unsigned short port); +extern unsigned int _inl(unsigned short port); #endif #if defined(__powerpc__) && (defined(Lynx) || defined(linux)) @@ -225,6 +212,7 @@ SYMFUNC(xf86MapVidMem) SYMFUNC(xf86UnMapVidMem) SYMFUNC(xf86MapReadSideEffects) + SYMFUNC(xf86UDelay) SYMFUNC(xf86IODelay) SYMFUNC(xf86SlowBcopy) #ifdef __alpha__ @@ -249,7 +237,16 @@ SYMFUNC(xf86SerialModemClearBits) SYMFUNC(xf86LoadKernelModule) SYMFUNC(xf86OSMouseInit) - + SYMFUNC(xf86AgpGARTSupported) + SYMFUNC(xf86GetAGPInfo) + SYMFUNC(xf86AcquireGART) + SYMFUNC(xf86ReleaseGART) + SYMFUNC(xf86AllocateGARTMemory) + SYMFUNC(xf86BindGARTMemory) + SYMFUNC(xf86UnbindGARTMemory) + SYMFUNC(xf86EnableAGP) + SYMFUNC(xf86SoundKbdBell) + #ifdef XINPUT /* XISB routines (Merged from Metrolink tree) */ SYMFUNC(XisbNew) @@ -268,6 +265,7 @@ SYMFUNC(xf86GetPciConfigInfo) SYMFUNC(xf86SetPciVideo) SYMFUNC(xf86ClaimIsaSlot) + SYMFUNC(xf86ClaimFbSlot) SYMFUNC(xf86ParsePciBusString) SYMFUNC(xf86ComparePciBusString) SYMFUNC(xf86ParseIsaBusString) @@ -370,6 +368,8 @@ SYMFUNC(xf86EnableInputHandler) SYMFUNC(xf86AddEnabledDevice) SYMFUNC(xf86RemoveEnabledDevice) + SYMFUNC(xf86InterceptSignals) + SYMFUNC(xf86EnableVTSwitch) /* xf86Helper.c */ SYMFUNC(xf86AddDriver) @@ -412,6 +412,7 @@ SYMFUNC(xf86GetFlipPixels) SYMFUNC(xf86GetServerName) SYMFUNC(xf86ServerIsExiting) + SYMFUNC(xf86ServerIsOnlyDetecting) SYMFUNC(xf86ServerIsOnlyProbing) SYMFUNC(xf86ServerIsResetting) SYMFUNC(xf86CaughtSignal) @@ -422,15 +423,14 @@ SYMFUNC(xf86GetAllowMouseOpenFail) SYMFUNC(xf86IsPc98) SYMFUNC(xf86GetClocks) + SYMFUNC(xf86SetPriority) SYMFUNC(xf86LoadDrvSubModule) SYMFUNC(xf86LoadSubModule) + SYMFUNC(xf86LoadOneModule) SYMFUNC(xf86UnloadSubModule) SYMFUNC(xf86LoaderCheckSymbol) SYMFUNC(xf86LoaderReqSymLists) SYMFUNC(xf86LoaderReqSymbols) - SYMFUNC(xf86Break1) - SYMFUNC(xf86Break2) - SYMFUNC(xf86Break3) SYMFUNC(xf86SetBackingStore) SYMFUNC(xf86SetSilkenMouse) /* SYMFUNC(xf86NewSerialNumber) */ @@ -438,6 +438,7 @@ SYMFUNC(xf86GetOS) SYMFUNC(xf86ConfigPciEntity) SYMFUNC(xf86ConfigIsaEntity) + SYMFUNC(xf86ConfigFbEntity) SYMFUNC(xf86ConfigActivePciEntity) SYMFUNC(xf86ConfigActiveIsaEntity) SYMFUNC(xf86ConfigPciEntityInactive) @@ -497,6 +498,9 @@ SYMFUNC(xf86OptionListReport) SYMFUNC(xf86SetIntOption) SYMFUNC(xf86SetStrOption) + SYMFUNC(xf86ReplaceIntOption) + SYMFUNC(xf86ReplaceStrOption) + SYMFUNC(xf86ReplaceBoolOption) SYMFUNC(xf86FindOption) SYMFUNC(xf86FindOptionValue) SYMFUNC(xf86MarkOptionUsed) @@ -532,7 +536,12 @@ SYMFUNC(xf86QueryLargestOffscreenArea) SYMFUNC(xf86PurgeUnlockedOffscreenAreas) SYMFUNC(xf86RegisterOffscreenManager) + SYMFUNC(xf86AllocateOffscreenLinear) + SYMFUNC(xf86ResizeOffscreenLinear) + SYMFUNC(xf86QueryLargestOffscreenLinear) + SYMFUNC(xf86FreeOffscreenLinear) + /* xf86cmap.c */ SYMFUNC(xf86HandleColormaps) @@ -611,7 +620,15 @@ #ifdef DPMSExtension SYMFUNC(DPMSSet) #endif - +/* xf86Debug.c */ +#ifdef BUILDDEBUG + SYMFUNC(xf86Break1) + SYMFUNC(xf86Break2) + SYMFUNC(xf86Break3) + SYMFUNC(xf86SPTimestamp) + SYMFUNC(xf86STimestamp) +#endif + #if 0 /* we want to move the hw stuff in a module */ SYMFUNC(xf86dactopel) SYMFUNC(xf86dactocomm) @@ -759,16 +776,16 @@ SYMFUNC(xf86memchr) SYMFUNC(xf86memcmp) SYMFUNC(xf86memcpy) -#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) +#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__ia64__) /* - * These PPC and SPARC compilers generate calls to memcpy to handle + * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle * structure copies. This causes a problem both here and in shared * libraries as there is no way to map the name of the call to the * correct function. */ SYMFUNC(memcpy) /* - * Thes PPC and SPARC compilers generate calls to memset to handle + * Some PPC, SPARC, and IA64 compilers generate calls to memset to handle * aggregate initializations. */ SYMFUNC(memset) @@ -822,6 +839,7 @@ SYMFUNC(xf86vfprintf) SYMFUNC(xf86vsnprintf) SYMFUNC(xf86vsprintf) + SYMFUNC(xf86write) /* non-ANSI C functions */ SYMFUNC(xf86opendir) @@ -853,6 +871,8 @@ SYMFUNC(xf86shmat) SYMFUNC(xf86shmdt) SYMFUNC(xf86shmctl) + SYMFUNC(xf86setjmp) + SYMFUNC(xf86longjmp) #ifdef XF86DRI /* These may have more general uses, but for now, they are only used by the DRI. @@ -861,10 +881,10 @@ of the X server) easier. */ SYMFUNC(xf86InstallSIGIOHandler) SYMFUNC(xf86RemoveSIGIOHandler) -#ifdef __alpha__ +# if defined(__alpha__) && defined(linux) SYMFUNC(_bus_base) +# endif #endif -#endif SYMFUNC(xf86BlockSIGIO) SYMFUNC(xf86UnblockSIGIO) @@ -878,21 +898,21 @@ SYMFUNC(__remq) SYMFUNC(__remqu) -#ifdef linux +# ifdef linux SYMFUNC(_outw) SYMFUNC(_outb) SYMFUNC(_outl) SYMFUNC(_inb) SYMFUNC(_inw) SYMFUNC(_inl) -#else +# else SYMFUNC(outw) SYMFUNC(outb) SYMFUNC(outl) SYMFUNC(inb) SYMFUNC(inw) SYMFUNC(inl) -#endif +# endif SYMFUNC(xf86ReadMmio32) SYMFUNC(xf86ReadMmio16) SYMFUNC(xf86ReadMmio8) @@ -903,15 +923,23 @@ SYMFUNC(xf86WriteMmioNB16) SYMFUNC(xf86WriteMmioNB8) SYMFUNC(memcpy) +#endif +#if defined(sun) && defined(SVR4) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) + SYMFUNC(outb) + SYMFUNC(outw) + SYMFUNC(outl) #endif -#if defined(__powerpc__) +#if defined(__powerpc__) && !defined(__OpenBSD__) SYMFUNC(inb) SYMFUNC(inw) SYMFUNC(inl) SYMFUNC(outb) SYMFUNC(outw) SYMFUNC(outl) -#if defined(NO_INLINE) || defined(Lynx) +# if defined(NO_INLINE) || defined(Lynx) SYMFUNC(mem_barrier) SYMFUNC(ldl_u) SYMFUNC(eieio) @@ -925,14 +953,14 @@ SYMFUNC(stq_u) SYMFUNC(stw_u) SYMFUNC(write_mem_barrier) -#endif +# endif SYMFUNC(rdinx) SYMFUNC(wrinx) SYMFUNC(modinx) SYMFUNC(testrg) SYMFUNC(testinx2) SYMFUNC(testinx) -#if defined(Lynx) +# if defined(Lynx) SYMFUNC(_restf14) SYMFUNC(_restf17) SYMFUNC(_restf18) @@ -959,15 +987,29 @@ SYMFUNC(_savef27) SYMFUNC(_savef28) SYMFUNC(_savef29) -#endif -#if PPCIO_DEBUG +# endif +# if PPCIO_DEBUG SYMFUNC(debug_inb) SYMFUNC(debug_inw) SYMFUNC(debug_inl) SYMFUNC(debug_outb) SYMFUNC(debug_outw) SYMFUNC(debug_outl) +# endif #endif +#if defined(__ia64__) + SYMFUNC(__divdf3) + SYMFUNC(__divdi3) + SYMFUNC(__divsf3) + SYMFUNC(__moddi3) + SYMFUNC(__udivdi3) + SYMFUNC(__umoddi3) + SYMFUNC(_outw) + SYMFUNC(_outb) + SYMFUNC(_outl) + SYMFUNC(_inb) + SYMFUNC(_inw) + SYMFUNC(_inl) #endif #ifdef __FreeBSD__ @@ -1014,7 +1056,7 @@ SYMVAR(res8514Shared) SYMVAR(PciAvoid) -#if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) +#if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) && !defined(__OpenBSD__) SYMVAR(ioBase) #endif Index: xc/programs/Xserver/hw/xfree86/os-support/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/Imakefile:3.41 xc/programs/Xserver/hw/xfree86/os-support/Imakefile:3.43 --- xc/programs/Xserver/hw/xfree86/os-support/Imakefile:3.41 Fri Jun 30 13:15:17 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/Imakefile Mon Nov 6 14:24:08 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.41 2000/06/30 17:15:17 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.43 2000/11/06 19:24:08 dawes Exp $ @@ -26,10 +26,6 @@ OS_SUBDIR = nto #endif -#if defined(ArcArchitecture) -OS_SUBDIR = bsd -#endif - #if defined(SVR3Architecture) # if defined(i386ScoArchitecture) OS_SUBDIR = sco @@ -38,6 +34,10 @@ # endif #endif +#if defined(cygwinArchitecture) +OS_SUBDIR = cygwin +#endif + #if defined(SVR4Architecture) # if defined(SunArchitecture) # if OSMinorVersion < 8 @@ -62,16 +62,13 @@ OS_SUBDIR = lynxos #endif -#if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) -# if defined(BSDOSArchitecture) -OS_SUBDIR = bsdi -# else +#if defined(FreeBSDArchitecture) || defined(NetBSDArchitecture) || \ + defined(OpenBSDArchitecture) OS_SUBDIR = bsd -# endif #endif -#if defined(NetBSDArchitecture) && defined(Arm32Architecture) -OS_SUBDIR = bsd +#if defined(BSDOSArchitecture) +OS_SUBDIR = bsdi #endif #if defined(i386MachArchitecture) || defined(OsfArchitecture) Index: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib diff -u xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib:3.6 xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib:3.7 --- xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib:3.6 Tue Aug 26 06:01:33 1997 +++ xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib Fri Dec 8 22:31:38 2000 @@ -134,8 +134,7 @@ */ } -void xf86UnMapVidMem(int ScreenNum, int Region, pointer Base, - unsigned long Size) +void xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) { /* * Handle unmapping the video memory. This should undo what @@ -502,7 +501,7 @@ -$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.6 1997/08/26 10:01:33 hohndel Exp $ +$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.7 2000/12/09 03:31:38 dawes Exp $ Index: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h:1.9 xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h:1.12 --- xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h:1.9 Mon Apr 17 12:30:12 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h Mon Dec 18 10:52:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.9 2000/04/17 16:30:12 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.12 2000/12/18 15:52:25 dawes Exp $ */ /* * Copyright (c) 1997-1999 by The XFree86 Project, Inc. @@ -99,6 +99,7 @@ const char * mseDevice; const char * protocol; int protocolID; + int oldProtocolID; /* hack */ int class; int mseModel; int baudRate; @@ -134,6 +135,8 @@ unsigned char inSync; /* driver in sync with datastream */ pointer mousePriv; /* private area */ InputInfoPtr pInfo; + int origProtocolID; + const char * origProtocol; } MouseDevRec, *MouseDevPtr; /* Z axis mapping */ Index: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h:1.4 xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h:1.4 Mon Feb 14 21:00:14 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h Fri Oct 27 21:42:24 2000 @@ -1,9 +1,9 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h,v 1.4 2000/02/15 02:00:14 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h,v 1.5 2000/10/28 01:42:24 mvojkovi Exp $ */ #ifndef _XF86OSPRIV_H #define _XF86OSPRIV_H -typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long); +typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int); typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long); typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool, MessageType); Index: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h:3.72 xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h:3.76 --- xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h:3.72 Fri Jun 23 18:42:06 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h Tue Nov 14 16:59:23 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.72 2000/06/23 22:42:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.76 2000/11/14 21:59:23 dawes Exp $ */ /* * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany * Copyright 1992 by David Dawes <dawes@XFree86.org> @@ -112,7 +112,7 @@ /**************************************************************************/ /* SYSV386 (SVR3, SVR4) - But not Solaris8 */ /**************************************************************************/ -#if (defined(SYSV) || defined(SVR4)) && !defined(DGUX) && !defined(SOL8) +#if (defined(SYSV) || defined(SVR4)) && !defined(DGUX) && !defined(__SOL8__) # ifdef SCO325 # ifndef _SVID3 # define _SVID3 @@ -266,7 +266,7 @@ * Good ol' Solaris8, and its lack of VT support ***********/ -#ifdef SOL8 +#ifdef __SOL8__ #include <sys/mman.h> #include <errno.h> #include <sys/sysi86.h> @@ -282,7 +282,7 @@ #include <signal.h> -#endif /* SOL8 */ +#endif /* __SOL8__ */ @@ -362,6 +362,9 @@ # include <sys/ioctl.h> # include <signal.h> # include <termio.h> +# ifdef __sparc__ +# include <sys/param.h> +# endif # include <errno.h> #ifndef __errno_location @@ -383,6 +386,10 @@ # define POSIX_TTY +# ifdef __sparc__ +# define DEV_MEM "/dev/fb" +# endif + #endif /* linux */ /**************************************************************************/ @@ -773,6 +780,49 @@ #endif /* __GNU__ */ /**************************************************************************/ +/* Cygwin */ +/**************************************************************************/ +#if defined(__CYGWIN__) +#include <signal.h> +#include <errno.h> +#include <sys/stat.h> +#include <termios.h> +#include <sys/ioctl.h> +#include <sys/param.h> + +/* Warning: by default, the fd_set size is 32 in QNX! */ +#define FD_SETSIZE 256 +#include <sys/select.h> + + /* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + + /* LEDs */ +# define LED_CAP 0x04 +# define LED_NUM 0x02 +# define LED_SCR 0x01 + +# define POSIX_TTY +# define OSMOUSE_ONLY +# define MOUSE_PROTOCOL_IN_KERNEL + +#define TIOCM_DTR 0x0001 /* data terminal ready */ +#define TIOCM_RTS 0x0002 /* request to send */ +#define TIOCM_CTS 0x1000 /* clear to send */ +#define TIOCM_DSR 0x2000 /* data set ready */ +#define TIOCM_RI 0x4000 /* ring */ +#define TIOCM_RNG TIOCM_RI +#define TIOCM_CD 0x8000 /* carrier detect */ +#define TIOCM_CAR TIOCM_CD +#define TIOCM_LE 0x0100 /* line enable */ +#define TIOCM_ST 0x0200 /* secondary transmit */ +#define TIOCM_SR 0x0400 /* secondary receive */ +#endif /* __CYGWIN__ */ + + +/**************************************************************************/ /* Generic */ /**************************************************************************/ @@ -838,6 +888,8 @@ # define MOUSE_PROTOCOL_IN_KERNEL # endif #endif + +#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) #define XF86_OS_PRIVS #include "xf86_OSproc.h" Index: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h:3.42 xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h:3.49 --- xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h:3.42 Sat Jun 24 13:23:57 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h Thu Dec 7 10:43:45 2000 @@ -64,11 +64,15 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.42 2000/06/24 17:23:57 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.49 2000/12/07 15:43:45 tsi Exp $ */ #ifndef _XF86_OSPROC_H #define _XF86_OSPROC_H +#ifdef XF86_OS_PRIVS +#include "xf86Pci.h" +#endif + /* * The actual prototypes have been pulled into this seperate file so * that they can can be used without pulling in all of the OS specific @@ -143,6 +147,7 @@ extern void xf86EnableInterrupts(void); extern void xf86SetTVOut(int); extern void xf86SetRGBOut(void); +extern void xf86SoundKbdBell(int, int, int); #if defined(QNX4) #pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi]; #pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi]; @@ -150,6 +155,7 @@ extern void xf86BusToMem(unsigned char *, unsigned char *, int); extern void xf86MemToBus(unsigned char *, unsigned char *, int); extern void xf86IODelay(void); +extern void xf86UDelay(long usec); extern void xf86SlowBcopy(unsigned char *, unsigned char *, int); extern int xf86OpenSerial(pointer options); extern int xf86SetSerial(int fd, pointer options); @@ -166,17 +172,29 @@ extern int xf86SerialModemClearBits(int fd, int bits); extern int xf86LoadKernelModule(const char *pathname); +/* AGP GART interface */ + +typedef struct _AgpInfo { + CARD32 bridgeId; + CARD32 agpMode; + unsigned long base; + unsigned long size; + unsigned long totalPages; + unsigned long systemPages; + unsigned long usedPages; +} AgpInfo, *AgpInfoPtr; + +extern Bool xf86AgpGARTSupported(void); +extern AgpInfoPtr xf86GetAGPInfo(int screenNum); +extern Bool xf86AcquireGART(int screenNum); +extern Bool xf86ReleaseGART(int screenNum); +extern int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical); +extern Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset); +extern Bool xf86UnbindGARTMemory(int screenNum, int key); +extern Bool xf86EnableAGP(int screenNum, CARD32 mode); + #if defined(__alpha__) -/* entry points for Mmio memory access routines */ -extern int (*xf86ReadMmio8)(pointer, unsigned long); -extern int (*xf86ReadMmio16)(pointer, unsigned long); -extern int (*xf86ReadMmio32)(pointer, unsigned long); -extern void (*xf86WriteMmio8)(int, pointer, unsigned long); -extern void (*xf86WriteMmio16)(int, pointer, unsigned long); -extern void (*xf86WriteMmio32)(int, pointer, unsigned long); -extern void (*xf86WriteMmioNB8)(int, pointer, unsigned long); -extern void (*xf86WriteMmioNB16)(int, pointer, unsigned long); -extern void (*xf86WriteMmioNB32)(int, pointer, unsigned long); extern void xf86JensenMemToBus(char *, long, long, int); extern void xf86JensenBusToMem(char *, char *, unsigned long, int); extern void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int); @@ -206,7 +224,6 @@ extern void xf86VTRequest(int sig); extern int xf86ProcessArgument(int, char **, int); extern void xf86UseMsg(void); -extern void xf86SoundKbdBell(int, int, int); extern void xf86SetKbdLeds(int); extern int xf86GetKbdLeds(void); extern void xf86SetKbdRepeat(char); @@ -214,8 +231,10 @@ extern int xf86KbdOn(void); extern int xf86KbdOff(void); extern void xf86KbdEvents(void); +#ifdef XQUEUE extern int xf86XqueKbdProc(DeviceIntPtr, int); extern void xf86XqueEvents(void); +#endif extern PMClose xf86OSPMOpen(void); #ifdef NEED_OS_RAC_PROTOS @@ -232,6 +251,7 @@ resPtr xf86IsaBusAccWindowsFromOS(void); resPtr xf86AccResFromOS(resPtr ret); #endif /* NEED_OS_RAC_PROTOS */ + Bool xf86GetPciSizeFromOS(PCITAG tag, int index, int* bits); #endif /* XF86_OS_PRIVS */ Index: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h:3.40 xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h:3.44 --- xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h:3.40 Fri Jun 16 20:03:26 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h Wed Dec 6 15:39:53 2000 @@ -22,7 +22,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.40 2000/06/17 00:03:26 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.44 2000/12/06 20:39:53 dawes Exp $ */ #ifndef _XF86_ANSIC_H #define _XF86_ANSIC_H @@ -62,7 +62,11 @@ #endif #ifndef NULL +#if (defined(SVR4) || defined(SYSV)) && !defined(__GNUC__) #define NULL 0 +#else +#define NULL ((void *)0) +#endif #endif #ifndef EOF #define EOF (-1) @@ -129,6 +133,9 @@ #define MAXLONG LONG_MAX #endif +#endif /* XFree86LOADER || NEED_XF86_TYPES */ + +#if defined(XFree86LOADER) || defined(NEED_XF86_PROTOTYPES) /* * ANSI C compilers only. */ @@ -297,8 +304,10 @@ extern char * xf86shmat(int id, char *addr, int xf86shmflg); extern int xf86shmdt(char *addr); extern int xf86shmctl(int id, int xf86cmd, pointer *buf); +extern int xf86setjmp(xf86jmp_buf env); +extern void xf86longjmp(xf86jmp_buf env, int val); -#else /* XFree86LOADER || NEED_XF86_TYPES */ +#else /* XFree86LOADER || NEED_XF86_PROTOTYPES */ #include <unistd.h> #include <stdio.h> #include <sys/ioctl.h> @@ -309,7 +318,7 @@ #include <sys/ipc.h> #include <sys/shm.h> #endif -#endif /* XFree86LOADER NEED_XF86_TYPES */ +#endif /* XFree86LOADER || NEED_XF86_PROTOTYPES */ /* * These things are always required by drivers (but not by libc_wrapper.c), Index: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h:3.48 xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h:3.49 --- xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h:3.48 Fri Jun 16 20:03:26 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h Tue Sep 19 08:46:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.48 2000/06/17 00:03:26 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.49 2000/09/19 12:46:21 eich Exp $ */ @@ -70,6 +70,9 @@ /* sysv IPC */ typedef int xf86key_t; +/* setjmp/longjmp */ +typedef int xf86jmp_buf[20]; + /* for setvbuf */ #define XF86_IONBF 1 #define XF86_IOFBF 2 @@ -437,6 +440,8 @@ #define shmat(a,b,c) xf86shmat(a,b,c) #define shmdt(a) xf86shmdt(a) #define shmctl(a,b,c) xf86shmctl(a,b,c) +#define setjmp(a) xf86setjmp(a) +#define longjmp(a,b) xf86longjmp(a,b) #undef S_ISUID #define S_ISUID XF86_S_ISUID @@ -492,6 +497,8 @@ #define uid_t xf86uid_t #undef gid_t #define gid_t xf86gid_t +#undef jmp_buf +#define jmp_buf xf86jmp_buf /* * There should be no need to #undef any of these. If they are already Index: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h:1.9 xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h:1.12 --- xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h:1.9 Tue Jun 20 01:08:48 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h Sun Sep 24 09:51:32 2000 @@ -26,7 +26,7 @@ * * Author: Rickard E. (Rik) Faith <faith@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.9 2000/06/20 05:08:48 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.12 2000/09/24 13:51:32 alanh Exp $ * */ @@ -187,7 +187,8 @@ #define DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */ #define DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */ -#if __GNUC__ >= 2 && defined(__i386) +#if __GNUC__ >= 2 +# if defined(__i386) /* Reflect changes here to drmP.h */ #define DRM_CAS(lock,old,new,__ret) \ do { \ @@ -201,9 +202,34 @@ : "2" (old), \ "r" (new)); \ } while (0) -#endif + +#elif defined(__alpha__) -#ifdef __sparc__ +#define DRM_CAS(lock, old, new, ret) \ + do { \ + int old32; \ + int cur32; \ + __asm__ __volatile__( \ + " mb\n" \ + " zap %4, 0xF0, %0\n" \ + " ldl_l %1, %2\n" \ + " zap %1, 0xF0, %1\n" \ + " cmpeq %0, %1, %1\n" \ + " beq %1, 1f\n" \ + " bis %5, %5, %1\n" \ + " stl_c %1, %2\n" \ + "1: xor %1, 1, %1\n" \ + " stl %1, %3" \ + : "+r" (old32), \ + "+&r" (cur32), \ + "=m" (__drm_dummy_lock(lock)),\ + "=m" (ret) \ + : "r" (old), \ + "r" (new)); \ + } while(0) + +#elif defined(__sparc__) + #define DRM_CAS(lock,old,new,__ret) \ do { register unsigned int __old __asm("o0"); \ register unsigned int __new __asm("o1"); \ @@ -223,15 +249,52 @@ : "memory"); \ __ret = (__new != __old); \ } while(0) + +#elif defined(__ia64__) + +#if 0 +/* this currently generates bad code (missing stop bits)... */ +#include <ia64intrin.h> + +#define DRM_CAS(lock,old,new,__ret) \ + do { \ + __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \ + (old), (new)) \ + != (old)); \ + } while (0) + +#else +#define DRM_CAS(lock,old,new,__ret) \ + do { \ + unsigned int __result, __old = (old); \ + __asm__ __volatile__( \ + "mf\n" \ + "mov ar.ccv=%2\n" \ + ";;\n" \ + "cmpxchg4.acq %0=%1,%3,ar.ccv" \ + : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \ + : "r" (__old), "r" (new) \ + : "memory"); \ + __ret = (__result) != (__old); \ + } while (0) + #endif +#endif /* architecture */ +#endif /* __GNUC__ >= 2 */ #ifndef DRM_CAS #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */ #endif +#ifdef __alpha__ +#define DRM_CAS_RESULT(_result) int _result +#else +#define DRM_CAS_RESULT(_result) char _result +#endif + #define DRM_LIGHT_LOCK(fd,lock,context) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ if (__ret) drmGetLock(fd,context,0); \ } while(0) @@ -240,7 +303,7 @@ benchmarking only. */ #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ if (__ret) drmGetLock(fd,context,0); \ else ++count; \ @@ -254,7 +317,7 @@ #define DRM_UNLOCK(fd,lock,context) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \ if (__ret) drmUnlock(fd,context); \ } while(0) @@ -262,7 +325,7 @@ /* Simple spin locks */ #define DRM_SPINLOCK(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ do { \ DRM_CAS(spin,0,val,__ret); \ if (__ret) while ((spin)->lock); \ @@ -271,7 +334,7 @@ #define DRM_SPINLOCK_TAKE(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ int cur; \ do { \ cur = (*spin).lock; \ @@ -291,7 +354,7 @@ #define DRM_SPINUNLOCK(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ if ((*spin).lock == val) { /* else server stole lock */ \ do { \ DRM_CAS(spin,val,0,__ret); \ Index: xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h:3.1 xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h:3.3 --- xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h:3.1 Fri Jun 16 20:03:26 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h Tue Sep 26 11:57:19 2000 @@ -1,5 +1,7 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h,v 3.3 2000/09/26 15:57:19 tsi Exp $ */ -/* WARNING: If you change any of these defines, make sure to change +/* + * WARNING: If you change any of these defines, make sure to change * the kernel include file as well (mga_drm.h) */ @@ -52,7 +54,9 @@ #define MGA_CTXREG_TDUAL0 7 #define MGA_CTXREG_TDUAL1 8 #define MGA_CTXREG_FCOL 9 -#define MGA_CTX_SETUP_SIZE 10 +#define MGA_CTXREG_STENCIL 10 +#define MGA_CTXREG_STENCILCTL 11 +#define MGA_CTX_SETUP_SIZE 12 /* 2d state */ Index: xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h diff -u xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h:3.1 xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h:3.5 --- xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h:3.1 Fri Jun 16 20:03:26 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h Tue Dec 12 12:17:13 2000 @@ -25,56 +25,86 @@ * * Author: Kevin E. Martin <kevin@precisioninsight.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h,v 3.1 2000/06/17 00:03:26 martin Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h,v 3.5 2000/12/12 17:17:13 dawes Exp $ * */ #ifndef _XF86DRI_R128_H_ #define _XF86DRI_R128_H_ -/* WARNING: If you change any of these defines, make sure to change +#include "X11/Xmd.h" + +/* + * WARNING: If you change any of these defines, make sure to change * the kernel include file as well (r128_drm.h) */ -typedef struct _drmR128Init { - int sarea_priv_offset; - int is_pci; - int cce_mode; - int cce_fifo_size; - int cce_secure; - int ring_size; - int usec_timeout; - - int fb_offset; - int agp_ring_offset; - int agp_read_ptr_offset; - int agp_vertbufs_offset; - int agp_indbufs_offset; - int agp_textures_offset; - int mmio_offset; +#define DRM_R128_FRONT 0x1 +#define DRM_R128_BACK 0x2 +#define DRM_R128_DEPTH 0x4 + +typedef struct { + int sarea_priv_offset; + int is_pci; + int cce_mode; + int cce_secure; + int ring_size; + int usec_timeout; + + unsigned int fb_bpp; + unsigned int front_offset, front_pitch; + unsigned int back_offset, back_pitch; + unsigned int depth_bpp; + unsigned int depth_offset, depth_pitch; + unsigned int span_offset; + + unsigned int fb_offset; + unsigned int mmio_offset; + unsigned int ring_offset; + unsigned int ring_rptr_offset; + unsigned int buffers_offset; + unsigned int agp_textures_offset; } drmR128Init; + +extern int drmR128InitCCE( int fd, drmR128Init *info ); +extern int drmR128CleanupCCE( int fd ); + +extern int drmR128StartCCE( int fd ); +extern int drmR128StopCCE( int fd ); +extern int drmR128ResetCCE( int fd ); +extern int drmR128WaitForIdleCCE( int fd ); + +extern int drmR128EngineReset( int fd ); + +extern int drmR128SwapBuffers( int fd ); +extern int drmR128Clear( int fd, unsigned int flags, + int x, int y, int w, int h, + unsigned int clear_color, + unsigned int clear_depth ); + +extern int drmR128FlushVertexBuffer( int fd, int prim, int indx, + int count, int discard ); +extern int drmR128FlushIndices( int fd, int prim, int indx, + int start, int end, int discard ); + +extern int drmR128TextureBlit( int fd, int indx, + int offset, int pitch, int format, + int x, int y, int width, int height ); + +extern int drmR128WriteDepthSpan( int fd, int n, int x, int y, + const unsigned int depth[], + const unsigned char mask[] ); +extern int drmR128WriteDepthPixels( int fd, int n, + const int x[], const int y[], + const unsigned int depth[], + const unsigned char mask[] ); +extern int drmR128ReadDepthSpan( int fd, int n, int x, int y ); +extern int drmR128ReadDepthPixels( int fd, int n, + const int x[], const int y[] ); + +extern int drmR128PolygonStipple( int fd, unsigned int *mask ); -typedef enum { - DRM_R128_PRIM_NONE = 0x0001, - DRM_R128_PRIM_POINT = 0x0002, - DRM_R128_PRIM_LINE = 0x0004, - DRM_R128_PRIM_POLY_LINE = 0x0008, - DRM_R128_PRIM_TRI_LIST = 0x0010, - DRM_R128_PRIM_TRI_FAN = 0x0020, - DRM_R128_PRIM_TRI_STRIP = 0x0040, - DRM_R128_PRIM_TRI_TYPE2 = 0x0080 -} drmR128PrimType; - - -extern int drmR128InitCCE(int fd, drmR128Init *info); -extern int drmR128CleanupCCE(int fd); -extern int drmR128EngineReset(int fd); -extern int drmR128EngineFlush(int fd); -extern int drmR128WaitForIdle(int fd); -extern int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags); -extern int drmR128GetVertexBuffers(int fd, int count, int *indices, - int *sizes); -extern int drmR128FlushVertexBuffers(int fd, int count, int *indices, - int *sizes, drmR128PrimType prim); +extern int drmR128SubmitPacket( int fd, void *buffer, + int *count, int flags ); #endif Index: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile:3.4 xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile:removed --- xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile:3.4 Tue Jun 27 10:27:29 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile Mon Dec 18 14:31:44 2000 @@ -1,35 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile,v 3.4 2000/06/27 14:27:29 tsi Exp $ - - - - -XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:26 rws $ - -#include <Server.tmpl> - -#if AckToolset -IOSRC = inout.S -IOOBJ = inout.o -#endif - -SRCS = am_init.c am_video.c am_io.c ioperm_noop.c \ - VTsw_noop.c $(IOSRC) kmod_noop.c -OBJS = am_init.o am_video.o am_io.o ioperm_noop.o \ - VTsw_noop.o $(IOOBJ) kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() -NormalAsmObjectRule() - -ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/) -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) -#if AckToolset -ObjectFromSpecialAsmSource(inout,../shared/inout,/**/) -#endif - -DependTarget() - Index: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c:3.6 xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c:3.6 Sat Jul 25 12:56:31 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c Mon Dec 18 14:31:44 2000 @@ -1,105 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_init.c,v 3.6 1998/07/25 16:56:31 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the Vrije Universiteit and David - * Wexelblat not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Wexelblat make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: am_init.c /main/5 1996/02/21 17:50:35 kaleb $ */ - -#include "X.h" -#include "Xmd.h" -#include "input.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static capability vgaMemCap; - -void xf86OpenConsole() -{ - char *findhole(); - segid seg; - int nbytes; - errstat err; - - if (serverGeneration == 1) - { - /* - * Get segment capability for video memory, and map it in. - * We do it this early since a side effect is that the I/O - * space is also mapped in. - */ - if ((err = iop_map_mem(&iopcap, &vgaMemCap)) != STD_OK) - { - FatalError("xf86OpenConsole: iop_map_mem failed (%s)\n", - err_why(err)); - } - - /* Map in aligned screen memory */ - nbytes = 0x10000; /* 64 Kb */ - xf86Info.screenPtr = - (pointer)(((unsigned) findhole(2 * nbytes) & ~0xFFF) + 0x1000); - if ((seg = seg_map(&vgaMemCap,xf86Info.screenPtr, nbytes, - MAP_TYPEDATA|MAP_READWRITE|MAP_INPLACE)) < 0) - { - FatalError("xf86OpenConsole: Map segment failed: %s\n", - err_why(ERR_CONVERT(seg))); - } - } - return; -} - -void xf86CloseConsole() -{ - static am_port_t nullport; - errstat err; - - if (!NULLPORT(&vgaMemCap.cap_port)) { - /* Unmap video's memory segment */ - if ((err = iop_unmap_mem(&iopcap, &vgaMemCap)) != STD_OK) - { - xf86FatalError("xf86CloseConsole: iop_map_mem failed (%s)\n", - err_why(err)); - } - vgaMemCap.cap_port = nullport; - } - return; -} - -/* ARGSUSED */ -int xf86ProcessArgument (argc, argv, i) -int argc; -char *argv[]; -int i; -{ - return(0); -} - -void xf86UseMsg() -{ - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c:3.11 xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c:3.11 Thu May 6 22:56:18 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c Mon Dec 18 14:31:44 2000 @@ -1,192 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_io.c,v 3.11 1999/05/07 02:56:18 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Dawes <dawes@xfree86.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the Vrije Universiteit and David - * Dawes not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Dawes make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID DAWES BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: am_io.c /main/9 1996/10/19 18:05:55 kaleb $ */ - -#define NEED_EVENTS -#include "X.h" -#include "Xproto.h" -#include "inputstr.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86Config.h" - -Bool xf86SupportedMouseTypes[] = -{ - TRUE, /* Microsoft */ - TRUE, /* MouseSystems */ - TRUE, /* MMSeries */ - TRUE, /* Logitech */ - TRUE, /* BusMouse */ - TRUE, /* MouseMan */ - TRUE, /* PS/2 */ - FALSE, /* Hitachi Tablet */ -}; - -int xf86NumMouseTypes = sizeof(xf86SupportedMouseTypes) / - sizeof(xf86SupportedMouseTypes[0]); - -void xf86SoundKbdBell(loudness, pitch, duration) -int loudness; -int pitch; -int duration; -{ - if (loudness) - { - errstat err; - - if ((err = iop_ringbell(&iopcap, loudness, pitch, duration)) - != STD_OK) - { - FatalError("iop_ringbell failed (%s)\n", err_why(err)); - } - } -} - -void xf86SetKbdLeds(leds) -int leds; -{ - errstat err; - - if ((err = iop_setleds(&iopcap, (int)leds)) != STD_OK) - { - FatalError("iop_set_leds failed (%s)\n", err_why(err)); - } -} - -int xf86GetKbdLeds() -{ - int cur_leds; - errstat err; - - err = iop_getleds(&iopcap, &cur_leds); - if (err != STD_OK) - { - FatalError("iop_get_leds failed (%s)\n", err_why(err)); - } - return cur_leds; -} - -#if NeedFunctionPrototypes -void xf86SetKbdRepeat(char rad) -#else -void xf86SetKbdRepeat(rad) -char rad; -#endif -{ - return; -} - -void xf86KbdInit() -{ - return; -} - -int xf86KbdOn() -{ - return(-1); -} - -int xf86KbdOff() -{ - return(-1); -} - -/* Amoeba doesn't use this */ -void xf86KbdEvents() -{ - return; -} - -void xf86SetMouseSpeed(mouse, old, new, cflag) -MouseDevPtr mouse; -int old; -int new; -unsigned cflag; -{ - return; -} - -void xf86MouseInit(mouse) -MouseDevPtr mouse; -{ - return; -} - -/* Xserver/iopsvr mouse type translation table: */ -static int mtypes[] = { - IOP_MOUSE_MS, /* P_MS */ - IOP_MOUSE_MM, /* P_MSC */ - IOP_MOUSE_MMS, /* P_MM */ - IOP_MOUSE_LOGI, /* P_LOGI */ - IOP_MOUSE_LB, /* P_BM */ - IOP_MOUSE_LOGIMAN, /* P_LOGIMAN */ - IOP_MOUSE_PS2 /* P_PS2 */ -}; - -int xf86MouseOn(mouse) -MouseDevPtr mouse; -{ - int msetype; - errstat err; - - msetype = mouse->mseType; - if (msetype >= 0 && msetype < (sizeof(mtypes) / sizeof(mtypes[0]))) { - /* translate */ - msetype = mtypes[msetype]; - } - - if ((err = iop_mousecontrol(&iopcap, msetype, mouse->baudRate, - mouse->sampleRate)) != STD_OK) - { - if (xf86Info.allowMouseOpenFail) { - ErrorF("iop_mousecontrol failed (%s) - Continuing...\n", - err_why(err)); - return(-2); - } - FatalError("iop_mousecontrol failed (%s)\n", err_why(err)); - } - return(-1); -} - -int xf86MouseOff(mouse, doclose) -MouseDevPtr mouse; -Bool doclose; -{ - return -1; -} - -/* Amoeba doesn't use this */ -void xf86MouseEvents(device) -DeviceIntPtr device; -{ - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c:3.1 xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c:3.1 Mon Dec 23 01:49:13 1996 +++ xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c Mon Dec 18 14:31:44 2000 @@ -1,102 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/am_video.c,v 3.1 1996/12/23 06:49:13 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Wexelblat <dwex@XFree86.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the Vrije Universiteit and David - * Wexelblat not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Wexelblat make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: am_video.c /main/3 1996/02/21 17:50:46 kaleb $ */ - -#include "X.h" -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -/* ARGSUSED */ -pointer xf86MapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - return((pointer)xf86Info.screenPtr); -} - -/* ARGSUSED */ -void xf86UnMapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - return; -} - -Bool xf86LinearVidMem() -{ - return(FALSE); -} - -/***************************************************************************/ -/* BIOS Reading section */ -/***************************************************************************/ - -/* - * Amoeba does not support reading the BIOS - */ - -/* ARGSUSED */ -int xf86ReadBIOS(Base, Offset, Buf, Len) -unsigned long Base; -unsigned long Offset; -unsigned char *Buf; -int Len; -{ - return(-1); -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -Bool xf86DisableInterrupts() -{ - extern void iop_intr_disable(); - - iop_intr_disable(&iopcap); - return(TRUE); -} - -void xf86EnableInterrupts() -{ - extern void iop_intr_enable(); - - iop_intr_enable(&iopcap); - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile:3.43 xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile:3.46 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile:3.43 Fri Jun 23 15:51:01 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile Mon Nov 6 14:24:08 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.43 2000/06/23 19:51:01 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.46 2000/11/06 19:24:08 dawes Exp $ #include <Server.tmpl> @@ -29,6 +29,9 @@ IOPERMDEFINES = -DUSE_ARC_MMAP # elif defined(Arm32Architecture) IOPERMDEFINES = -DUSE_ARM32_MMAP +# elif defined(PpcArchitecture) + IOPERM_SRC = ioperm_noop.c + IOPERM_OBJ = ioperm_noop.o # else IOPERMDEFINES = -DUSE_I386_IOPL # endif @@ -65,7 +68,8 @@ #endif -#if defined(NetBSDArchitecture) || defined(OpenBSDArchitecture) +#if (defined(NetBSDArchitecture) || defined(OpenBSDArchitecture)) \ + && defined(i386Architecture) APMSRC = bsd_apm.c APMOBJ = bsd_apm.o #else @@ -94,18 +98,26 @@ AXP_OBJ=bsd_ev56.o #endif +#if defined(FreeBSDArchitecture) && HasAgpGart +AGP_SRC=lnx_agp.c +AGP_OBJ=lnx_agp.o +#else +AGP_SRC=agp_noop.c +AGP_OBJ=agp_noop.o +#endif + SRCS = bsd_init.c bsd_video.c bsd_io.c bsd_VTsw.c \ libc_wrapper.c $(IOPERM_SRC) std_kbdEv.c posix_tty.c $(MOUSESRC) \ $(RES_SRC) stdPci.c vidmem.c $(JOYSTICK_SRC) sigio.c $(APMSRC) \ - $(AXP_SRC) $(KMODSRC) + $(AXP_SRC) $(KMODSRC) $(AGP_SRC) OBJS = bsd_init.o bsd_video.o bsd_io.o bsd_VTsw.o \ libc_wrapper.o $(IOPERM_OBJ) std_kbdEv.o posix_tty.o $(MOUSEOBJ) \ $(RES_OBJ) stdPci.o vidmem.o $(JOYSTICK_OBJ) sigio.o $(APMOBJ) \ - $(AXP_OBJ) $(KMODOBJ) + $(AXP_OBJ) $(KMODOBJ) $(AGP_OBJ) INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi -I$(APINCLUDES) \ + -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi $(APINCLUDES) \ $(LIBUSBINCLUDES) CONSDEFINES = XFree86ConsoleDefines @@ -114,7 +126,7 @@ #if HasNetBSDApertureDriver APDIR = NetBSDApertureDir APDEFINES = -DHAS_APERTURE_DRV -APINCLUDES = $(APDIR)/include +APINCLUDES = -I$(APDIR)/include #endif DEFINES = $(CONSDEFINES) $(APDEFINES) $(IOPERMDEFINES) $(RESDEFINES) \ @@ -146,7 +158,8 @@ # endif #endif -#if !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture) +#if !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture) || \ + !defined(i386Architecture) LinkSourceFile(pm_noop.c,../shared) #endif LinkSourceFile(ioperm_noop.c,../shared) @@ -158,6 +171,11 @@ LinkSourceFile(vidmem.c,../shared) LinkSourceFile(sigio.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +#if defined(FreeBSDArchitecture) && HasAgpGart +LinkSourceFile(lnx_agp.c,../linux) +#else +LinkSourceFile(agp_noop.c,../shared) +#endif DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c:1.2 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c:1.1 Sun Mar 5 11:59:17 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c Mon Nov 6 14:24:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c,v 1.1 2000/03/05 16:59:17 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c,v 1.2 2000/11/06 19:24:08 dawes Exp $ */ /* Resource information code */ @@ -86,6 +86,44 @@ RANGE(range,0,0x1ff,ResExcIoBlock | ResEstimated); ret = xf86AddResToList(ret, &range, -1); /* XXX add others */ + return ret; +} + +#elif defined(__powerpc__) + +resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END}; + +resPtr +xf86BusAccWindowsFromOS(void) +{ + resPtr ret = NULL; + resRange range; + + RANGE(range, 0, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + RANGE(range, 0, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + return ret; +} + +resPtr +xf86PciBusAccWindowsFromOS(void) +{ + resPtr ret = NULL; + resRange range; + + RANGE(range, 0, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + RANGE(range, 0, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + return ret; +} + +resPtr +xf86AccResFromOS(resPtr ret) +{ return ret; } Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c:3.13 xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c:3.15 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c:3.13 Wed Apr 28 01:36:16 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c Tue Nov 14 16:59:24 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.13 1999/04/28 05:36:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.15 2000/11/14 21:59:24 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -84,6 +84,9 @@ #ifdef PCVT_SUPPORT "pcvt", #endif +#ifdef WSCONS_SUPPORT + "wscons", +#endif }; @@ -109,6 +112,10 @@ static int xf86OpenPcvt(void); #endif /* PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT +static int xf86OpenWScons(void); +#endif + /* * The sequence of the driver probes is important; start with the * driver that is best distinguishable, and end with the most generic @@ -125,6 +132,9 @@ #ifdef PCCONS_SUPPORT xf86OpenPccons, #endif +#ifdef WSCONS_SUPPORT + xf86OpenWScons, +#endif (xf86ConsOpen_t)NULL }; @@ -133,6 +143,7 @@ xf86OpenConsole() { int i, fd = -1; + int result; xf86ConsOpen_t *driver; #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) vtmode_t vtmode; @@ -233,11 +244,15 @@ /* * now get the VT */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); } @@ -265,6 +280,12 @@ } break; #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + fprintf(stderr, "xf86OpenConsole\n"); + /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ + break; +#endif } } else @@ -549,6 +570,35 @@ #endif /* PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + +static int +xf86OpenWScons() +{ + int fd = -1; + int mode = WSDISPLAYIO_MODE_MAPPED; + int i; + char ttyname[16]; + + /* XXX Is this ok? */ + for (i = 0; i < 8; i++) { + sprintf(ttyname, "/dev/ttyE%d", i); + if ((fd = open(ttyname, 2)) != -1) + break; + } + if (fd != -1) { + if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { + FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s\n", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + xf86Info.consType = WSCONS; + xf86Msg(X_PROBED, "Using wscons driver\n"); + } + return fd; +} + +#endif /* WSCONS_SUPPORT */ void xf86CloseConsole() @@ -584,6 +634,14 @@ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); break; #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + { + int mode = WSDISPLAYIO_MODE_EMUL; + ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); + break; + } +#endif } if (xf86Info.screenFd != xf86Info.consoleFd) Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c:3.17 xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c:3.18 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c:3.17 Sat Sep 4 09:04:42 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c Mon Nov 6 14:24:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.17 1999/09/04 13:04:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.18 2000/11/06 19:24:08 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Dawes <dawes@xfree86.org> @@ -158,6 +158,10 @@ ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW); #endif break; +#endif +#ifdef WSCONS_SUPPORT + case WSCONS: + return xf86Info.kbdFd; #endif } return(xf86Info.consoleFd); Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c:1.15 xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c:1.17 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c:1.15 Sat Feb 12 15:45:41 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c Mon Dec 18 10:52:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c,v 1.15 2000/02/12 20:45:41 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c,v 1.17 2000/12/18 15:52:25 dawes Exp $ */ /* * Copyright 1999 by The XFree86 Project, Inc. @@ -161,11 +161,26 @@ SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) { mousemode_t mode; + MouseDevPtr pMse; + pMse = pInfo->private; + mode.rate = rate > 0 ? rate : -1; mode.resolution = res > 0 ? res : -1; mode.accelfactor = -1; +#if defined(__FreeBSD__) + if (xf86NameCmp(pMse->origProtocol, "Auto") == 0) { + /* + * As the FreeBSD sysmouse driver defaults to protocol level 0 + * everytime it is opened we enforce protocol level 1 again at + * this point. + */ + mode.level = 1; + } else + mode.level = -1; +#else mode.level = -1; +#endif ioctl(pInfo->fd, MOUSE_SETMODE, &mode); } #endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c:3.34 xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c:3.40 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c:3.34 Sun Mar 5 11:59:17 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c Wed Dec 13 02:02:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c,v 3.34 2000/03/05 16:59:17 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_video.c,v 3.40 2000/12/13 07:02:45 herrb Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -113,6 +113,16 @@ #define MAP_FAILED ((caddr_t)-1) #endif +#ifdef __OpenBSD__ +#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details\n" +#define SECURELEVEL_MSG \ + "A card in your system needs more than the aperture driver\n" \ + "\tYou need to rebuild a kernel with \"Option INSECURE\"\n" \ + "\tand set securelevel=-1 in /etc/rc.securelevel\n" +#endif + #ifdef __alpha__ extern unsigned long dense_base(void); @@ -167,18 +177,23 @@ #endif #define DEV_MEM "/dev/mem" -static pointer mapVidMem(int, unsigned long, unsigned long); +static pointer mapVidMem(int, unsigned long, unsigned long, int); static void unmapVidMem(int, pointer, unsigned long); #ifdef __alpha__ -static pointer mapVidMemSparse(int, unsigned long, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); static void unmapVidMemSparse(int, pointer, unsigned long); #endif +#ifdef __powerpc__ +static pointer ppcMapVidMem(int, unsigned long, unsigned long); +static void ppcUnmapVidMem(int, pointer, unsigned long); +#endif #ifdef HAS_MTRR_SUPPORT static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); static void undoWC(int, pointer); static Bool cleanMTRR(void); #endif +#if !defined(__powerpc__) /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. @@ -253,8 +268,14 @@ } else { if (warn) { +#ifndef __OpenBSD__ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno)); +#else /* __OpenBSD__ */ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno), + SYSCTL_MSG); +#endif /* __OpenBSD__ */ } } @@ -267,12 +288,17 @@ #endif } +#endif /* !__powerpc__ */ void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { +#if defined(__powerpc__) + pVidMem->linearSupported = TRUE; +#else checkDevMem(TRUE); pVidMem->linearSupported = useDevMem; +#endif #if defined(__alpha__) if (has_bwx()) { xf86Msg(X_INFO,"Machine type has 8/16 bit access\n"); @@ -286,6 +312,9 @@ #elif defined(__arm32__) pVidMem->mapMem = armMapVidMem; pVidMem->unmapVidMem = armUnmapVidMem; +#elif defined(__powerpc__) + pVidMem->mapMem = ppcMapVidMem; + pVidMem->unmapMem = ppcUnmapVidMem; #else pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; @@ -302,8 +331,9 @@ pVidMem->initialised = TRUE; } +#if !defined(__powerpc__) static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; @@ -332,11 +362,7 @@ } /* else, mmap /dev/vga */ -#ifndef PC98 if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) -#else - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xE8000) -#endif { FatalError("%s: Address 0x%x outside allowable range\n", "xf86MapVidMem", Base); @@ -383,14 +409,21 @@ } psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); - /* Base is assumed to be page-aligned. */ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); if ((long)ptr == -1) { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", - DEV_MEM, strerror(errno)); + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); +#ifdef __OpenBSD__ + if (Base < 0xa0000) { + xf86Msg(X_WARNING, SECURELEVEL_MSG); + } +#endif return(-1); } #ifdef DEBUG @@ -399,9 +432,14 @@ #endif (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap((caddr_t)ptr, mlen); + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); return(Len); } +#endif /* !__powerpc__ */ + #ifdef __arm32__ /* XXX This needs to be updated for the ND */ @@ -534,7 +572,7 @@ } static pointer -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { struct memAccess *memInfoP; @@ -562,7 +600,7 @@ base = xf86MapInfoMap(memInfoP, Base, Size); return (base); } - return mapVidMem(ScreenNum, Base, Size); + return mapVidMem(ScreenNum, Base, Size, flags); } static void @@ -578,6 +616,63 @@ } #endif /* __arm32__ */ +#if defined(__powerpc__) + +volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +{ + int fd = xf86Info.screenFd; + pointer base; + + fprintf(stderr, "mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd); + + base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + +static void +ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int rv; + int kmem; + + kmem = open("/dev/kmem", 2); + if (kmem == -1) { + FatalError("xf86ReadBIOS: open /dev/kmem\n"); + } + + + fprintf(stderr, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); + + if (Base < 0x80000000) { + fprintf(stderr, "No VGA\n"); + return 0; + } + + + lseek(kmem, Base + Offset, 0); + rv = read(kmem, Buf, Len); + close(kmem); + + return rv; +} + + +#endif /* __powerpc__ */ + #ifdef USE_I386_IOPL /***************************************************************************/ /* I/O Permissions section */ @@ -593,8 +688,13 @@ if (i386_iopl(TRUE) < 0) { +#ifndef __OpenBSD__ FatalError("%s: Failed to set IOPL for extended I/O\n", "xf86EnableIO"); +#else + FatalError("%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif } ExtendedEnabled = TRUE; @@ -714,7 +814,8 @@ xf86DisableInterrupts() { -#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) +#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) && \ + !defined(__powerpc__) #ifdef __GNUC__ __asm__ __volatile__("cli"); #else @@ -729,7 +830,8 @@ xf86EnableInterrupts() { -#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) +#if !defined(__mips__) && !defined(__arm32__) && !defined(__alpha__) && \ + !defined(__powerpc__) #ifdef __GNUC__ __asm__ __volatile__("sti"); #else @@ -740,6 +842,7 @@ return; } + #ifdef __NetBSD__ /***************************************************************************/ /* Set TV output mode */ @@ -1349,7 +1452,7 @@ } static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { static Bool was_here = FALSE; Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile Fri Oct 27 17:14:55 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile,v 1.1 2000/06/17 00:03:27 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile,v 1.3 2000/10/27 21:14:55 dawes Exp $ XCOMM $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.7 1999/09/14 19:55:15 faith Exp $ #define IHaveModules @@ -14,8 +14,8 @@ MTRR_DEFINES = -DHAS_MTRR_SUPPORT #endif -SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c $(MSRC) -OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o $(MOBJ) +SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c xf86drmSiS.c $(MSRC) +OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o xf86drmSiS.o $(MOBJ) INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ @@ -37,5 +37,15 @@ #endif +#if DoLoadableServer +LinkSourceFile(drmmodule.c,$(XF86OSSRC)/linux/drm) +#endif +LinkSourceFile(xf86drmHash.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmI810.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmMga.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmR128.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmRandom.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmSL.c,$(XF86OSSRC)/linux/drm) +LinkSourceFile(xf86drmSiS.c,$(XF86OSSRC)/linux/drm) InstallDriverSDKLibraryModule(drm,$(DRIVERSDKMODULEDIR),freebsd) Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c Mon Dec 18 14:31:45 2000 @@ -1,56 +0,0 @@ -/* drmmodule.c -- Module initialization - * Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com - * Revised: Fri Jun 4 09:09:22 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.1 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - */ - -#include "xf86Module.h" - -static MODULESETUPPROTO(drmSetup); - -static XF86ModuleVersionInfo VersRec = -{ - "drm", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XF86_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_EXTENSION, - ABI_EXTENSION_VERSION, - MOD_CLASS_NONE, - {0,0,0,0} -}; - -XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL }; - -static pointer -drmSetup(pointer module, pointer opts, int *errmaj, int *errmin) -{ - return (void *)1; -} Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c Mon Dec 18 14:31:45 2000 @@ -1,435 +0,0 @@ -/* xf86drmHash.c -- Small hash table support for integer -> integer mapping - * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com - * Revised: Thu Jun 3 16:11:06 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - * DESCRIPTION - * - * This file contains a straightforward implementation of a fixed-sized - * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for - * collision resolution. There are two potentially interesting things - * about this implementation: - * - * 1) The table is power-of-two sized. Prime sized tables are more - * traditional, but do not have a significant advantage over power-of-two - * sized table, especially when double hashing is not used for collision - * resolution. - * - * 2) The hash computation uses a table of random integers [Hanson97, - * pp. 39-41]. - * - * FUTURE ENHANCEMENTS - * - * With a table size of 512, the current implementation is sufficient for a - * few hundred keys. Since this is well above the expected size of the - * tables for which this implementation was designed, the implementation of - * dynamic hash tables was postponed until the need arises. A common (and - * naive) approach to dynamic hash table implementation simply creates a - * new hash table when necessary, rehashes all the data into the new table, - * and destroys the old table. The approach in [Larson88] is superior in - * two ways: 1) only a portion of the table is expanded when needed, - * distributing the expansion cost over several insertions, and 2) portions - * of the table can be locked, enabling a scalable thread-safe - * implementation. - * - * REFERENCES - * - * [Hanson97] David R. Hanson. C Interfaces and Implementations: - * Techniques for Creating Reusable Software. Reading, Massachusetts: - * Addison-Wesley, 1997. - * - * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3: - * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973. - * - * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April - * 1988, pp. 446-457. - * - */ - -#define HASH_MAIN 0 - -#if HASH_MAIN -# include <stdio.h> -# include <stdlib.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define HASH_MAGIC 0xdeadbeef -#define HASH_DEBUG 0 -#define HASH_SIZE 512 /* Good for about 100 entries */ - /* If you change this value, you probably - have to change the HashHash hashing - function! */ - -#if HASH_MAIN -#define HASH_ALLOC malloc -#define HASH_FREE free -#define HASH_RANDOM_DECL -#define HASH_RANDOM_INIT(seed) srandom(seed) -#define HASH_RANDOM random() -#else -#define HASH_ALLOC drmMalloc -#define HASH_FREE drmFree -#define HASH_RANDOM_DECL void *state -#define HASH_RANDOM_INIT(seed) state = drmRandomCreate(seed) -#define HASH_RANDOM drmRandom(state) - -#endif - -typedef struct HashBucket { - unsigned long key; - void *value; - struct HashBucket *next; -} HashBucket, *HashBucketPtr; - -typedef struct HashTable { - unsigned long magic; - unsigned long entries; - unsigned long hits; /* At top of linked list */ - unsigned long partials; /* Not at top of linked list */ - unsigned long misses; /* Not in table */ - HashBucketPtr buckets[HASH_SIZE]; - int p0; - HashBucketPtr p1; -} HashTable, *HashTablePtr; - -#if HASH_MAIN -extern void *N(HashCreate)(void); -extern int N(HashDestroy)(void *t); -extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value); -extern int N(HashInsert)(void *t, unsigned long key, unsigned long value); -extern int N(HashDelete)(void *t, unsigned long key); -#endif - -static unsigned long HashHash(unsigned long key) -{ - unsigned long hash = 0; - unsigned long tmp = key; - static int init = 0; - static unsigned long scatter[256]; - int i; - - if (!init) { - HASH_RANDOM_DECL; - HASH_RANDOM_INIT(37); - for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM; - ++init; - } - - while (tmp) { - hash = (hash << 1) + scatter[tmp & 0xff]; - tmp >>= 8; - } - - hash %= HASH_SIZE; -#if HASH_DEBUG - printf( "Hash(%d) = %d\n", key, hash); -#endif - return hash; -} - -void *N(HashCreate)(void) -{ - HashTablePtr table; - int i; - - table = HASH_ALLOC(sizeof(*table)); - if (!table) return NULL; - table->magic = HASH_MAGIC; - table->entries = 0; - table->hits = 0; - table->partials = 0; - table->misses = 0; - - for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL; - return table; -} - -int N(HashDestroy)(void *t) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - HashBucketPtr next; - int i; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - for (i = 0; i < HASH_SIZE; i++) { - for (bucket = table->buckets[i]; bucket;) { - next = bucket->next; - HASH_FREE(bucket); - bucket = next; - } - } - HASH_FREE(table); - return 0; -} - -/* Find the bucket and organize the list so that this bucket is at the - top. */ - -static HashBucketPtr HashFind(HashTablePtr table, - unsigned long key, unsigned long *h) -{ - unsigned long hash = HashHash(key); - HashBucketPtr prev = NULL; - HashBucketPtr bucket; - - if (h) *h = hash; - - for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) { - if (bucket->key == key) { - if (prev) { - /* Organize */ - prev->next = bucket->next; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; - ++table->partials; - } else { - ++table->hits; - } - return bucket; - } - prev = bucket; - } - ++table->misses; - return NULL; -} - -int N(HashLookup)(void *t, unsigned long key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - bucket = HashFind(table, key, NULL); - if (!bucket) return 1; /* Not found */ - *value = bucket->value; - return 0; /* Found */ -} - -int N(HashInsert)(void *t, unsigned long key, void *value) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - unsigned long hash; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - if (HashFind(table, key, &hash)) return 1; /* Already in table */ - - bucket = HASH_ALLOC(sizeof(*bucket)); - if (!bucket) return -1; /* Error */ - bucket->key = key; - bucket->value = value; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; -#if HASH_DEBUG - printf("Inserted %d at %d/%p\n", key, hash, bucket); -#endif - return 0; /* Added to table */ -} - -int N(HashDelete)(void *t, unsigned long key) -{ - HashTablePtr table = (HashTablePtr)t; - unsigned long hash; - HashBucketPtr bucket; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - bucket = HashFind(table, key, &hash); - - if (!bucket) return 1; /* Not found */ - - table->buckets[hash] = bucket->next; - HASH_FREE(bucket); - return 0; -} - -int N(HashNext)(void *t, unsigned long *key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - - for (; table->p0 < HASH_SIZE; - ++table->p0, table->p1 = table->buckets[table->p0]) { - if (table->p1) { - *key = table->p1->key; - *value = table->p1->value; - table->p1 = table->p1->next; - return 1; - } - } - return 0; -} - -int N(HashFirst)(void *t, unsigned long *key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - table->p0 = 0; - table->p1 = table->buckets[0]; - return N(HashNext)(table, key, value); -} - -#if HASH_MAIN -#define DIST_LIMIT 10 -static int dist[DIST_LIMIT]; - -static void clear_dist(void) { - int i; - - for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0; -} - -static int count_entries(HashBucketPtr bucket) -{ - int count = 0; - - for (; bucket; bucket = bucket->next) ++count; - return count; -} - -static void update_dist(int count) -{ - if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1]; - else ++dist[count]; -} - -static void compute_dist(HashTablePtr table) -{ - int i; - HashBucketPtr bucket; - - printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n", - table->entries, table->hits, table->partials, table->misses); - clear_dist(); - for (i = 0; i < HASH_SIZE; i++) { - bucket = table->buckets[i]; - update_dist(count_entries(bucket)); - } - for (i = 0; i < DIST_LIMIT; i++) { - if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]); - else printf("other %10d\n", dist[i]); - } -} - -static void check_table(HashTablePtr table, - unsigned long key, unsigned long value) -{ - unsigned long retval = 0; - int retcode = N(HashLookup)(table, key, &retval); - - switch (retcode) { - case -1: - printf("Bad magic = 0x%08lx:" - " key = %lu, expected = %lu, returned = %lu\n", - table->magic, key, value, retval); - break; - case 1: - printf("Not found: key = %lu, expected = %lu returned = %lu\n", - key, value, retval); - break; - case 0: - if (value != retval) - printf("Bad value: key = %lu, expected = %lu, returned = %lu\n", - key, value, retval); - break; - default: - printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n", - retcode, key, value, retval); - break; - } -} - -int main(void) -{ - HashTablePtr table; - int i; - - printf("\n***** 256 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 256; i++) N(HashInsert)(table, i, i); - for (i = 0; i < 256; i++) check_table(table, i, i); - for (i = 256; i >= 0; i--) check_table(table, i, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); - for (i = 0; i < 1024; i++) check_table(table, i, i); - for (i = 1024; i >= 0; i--) check_table(table, i, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); - for (i = 0; i < 1024; i++) check_table(table, i*4096, i); - for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 random integers ****\n"); - table = N(HashCreate)(); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) check_table(table, random(), i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 5000 random integers ****\n"); - table = N(HashCreate)(); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) check_table(table, random(), i); - compute_dist(table); - N(HashDestroy)(table); - - return 0; -} -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c Mon Dec 18 14:31:45 2000 @@ -1,86 +0,0 @@ -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmI810.h" -#include "drm.h" - -Bool drmI810CleanupDma(int driSubFD) -{ - drm_i810_init_t init; - - memset(&init, 0, sizeof(drm_i810_init_t)); - init.func = I810_CLEANUP_DMA; - - if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) { - return FALSE; - } - - return TRUE; -} - -Bool drmI810InitDma(int driSubFD, drmI810Init *info) -{ - drm_i810_init_t init; - - memset(&init, 0, sizeof(drm_i810_init_t)); - - init.func = I810_INIT_DMA; - init.ring_map_idx = info->ring_map_idx; - init.buffer_map_idx = info->buffer_map_idx; - init.ring_start = info->start; - init.ring_end = info->end; - init.ring_size = info->size; - init.sarea_priv_offset = info->sarea_off; - init.front_offset = info->front_offset; - init.back_offset = info->back_offset; - init.depth_offset = info->depth_offset; - init.w = info->w; - init.h = info->h; - init.pitch = info->pitch; - init.pitch_bits = info->pitch_bits; - - if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) { - return FALSE; - } - return TRUE; -} Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c Mon Dec 18 14:31:45 2000 @@ -1,116 +0,0 @@ -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmMga.h" -#include "drm.h" - -Bool drmMgaCleanupDma(int driSubFD) -{ - drm_mga_init_t init; - memset(&init, 0, sizeof(drm_mga_init_t)); - init.func = MGA_CLEANUP_DMA; - if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) { - return FALSE; - } - - return TRUE; -} - -Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags) -{ - drm_lock_t lock; - - memset(&lock, 0, sizeof(drm_lock_t)); - - if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT; - if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH; - if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL; - - if(ioctl(driSubFD, DRM_IOCTL_MGA_FLUSH, &lock)) { - return FALSE; - } - - return TRUE; -} - -Bool drmMgaInitDma(int driSubFD, drmMgaInit *info) -{ - drm_mga_init_t init; - int i; - - memset(&init, 0, sizeof(drm_mga_init_t)); - init.func = MGA_INIT_DMA; - init.reserved_map_agpstart = info->reserved_map_agpstart; - init.reserved_map_idx = info->reserved_map_idx; - init.buffer_map_idx = info->buffer_map_idx; - init.sarea_priv_offset = info->sarea_priv_offset; - init.primary_size = info->primary_size; - init.warp_ucode_size = info->warp_ucode_size; - init.frontOffset = info->frontOffset; - init.backOffset = info->backOffset; - init.depthOffset = info->depthOffset; - init.textureOffset = info->textureOffset; - init.textureSize = info->textureSize; - init.agpTextureSize = info->agpTextureSize; - init.agpTextureOffset = info->agpTextureOffset; - init.cpp = info->cpp; - init.stride = info->stride; - init.sgram = info->sgram; - init.chipset = info->chipset; - - for(i = 0; i < MGA_MAX_WARP_PIPES; i++) { - init.WarpIndex[i].installed = info->WarpIndex[i].installed; - init.WarpIndex[i].phys_addr = info->WarpIndex[i].phys_addr; - init.WarpIndex[i].size = info->WarpIndex[i].size; - } - - init.mAccess = info->mAccess; - - - - if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) { - return FALSE; - } - return TRUE; -} - Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c:1.1 Fri Jun 16 20:03:27 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c Mon Dec 18 14:31:45 2000 @@ -1,198 +0,0 @@ -/* xf86drmR128.c -- User-level interface to Rage 128 DRM device - * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com - * - * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: Kevin E. Martin <kevin@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - */ - -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmR128.h" -#include "drm.h" - -int drmR128InitCCE(int fd, drmR128Init *info) -{ - drm_r128_init_t init; - - memset(&init, 0, sizeof(drm_r128_init_t)); - - init.func = R128_INIT_CCE; - init.sarea_priv_offset = info->sarea_priv_offset; - init.is_pci = info->is_pci; - init.cce_mode = info->cce_mode; - init.cce_fifo_size = info->cce_fifo_size; - init.cce_secure = info->cce_secure; - init.ring_size = info->ring_size; - init.usec_timeout = info->usec_timeout; - - init.fb_offset = info->fb_offset; - init.agp_ring_offset = info->agp_ring_offset; - init.agp_read_ptr_offset = info->agp_read_ptr_offset; - init.agp_vertbufs_offset = info->agp_vertbufs_offset; - init.agp_indbufs_offset = info->agp_indbufs_offset; - init.agp_textures_offset = info->agp_textures_offset; - init.mmio_offset = info->mmio_offset; - - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; - - return 0; -} - -int drmR128CleanupCCE(int fd) -{ - drm_r128_init_t init; - - memset(&init, 0, sizeof(drm_r128_init_t)); - - init.func = R128_CLEANUP_CCE; - - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; - - return 0; -} - -int drmR128EngineReset(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno; - - return 0; -} - -int drmR128EngineFlush(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno; - - return 0; -} - -int drmR128CCEWaitForIdle(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno; - - return 0; -} - -int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags) -{ - drm_r128_packet_t packet; - int ret; - - memset(&packet, 0, sizeof(drm_r128_packet_t)); - - packet.count = *count; - packet.flags = flags; - - while (packet.count > 0) { - packet.buffer = buffer + (*count - packet.count); - ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet); - if (ret < 0 && ret != -EAGAIN) { - *count = packet.count; - return -errno; - } - } - - *count = 0; - return 0; -} - -int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes) -{ - drm_r128_vertex_t v; - - v.send_count = 0; - v.send_indices = NULL; - v.send_sizes = NULL; - v.prim = DRM_R128_PRIM_NONE; - v.request_count = count; - v.request_indices = indices; - v.request_sizes = sizes; - v.granted_count = 0; - - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno; - - return v.granted_count; -} - -int drmR128FlushVertexBuffers(int fd, int count, int *indices, - int *sizes, drmR128PrimType prim) -{ - drm_r128_vertex_t v; - - v.send_count = count; - v.send_indices = indices; - v.send_sizes = sizes; - v.prim = prim; - v.request_count = 0; - v.request_indices = NULL; - v.request_sizes = NULL; - v.granted_count = 0; - - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno; - - return 0; -} Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c Mon Dec 18 14:31:45 2000 @@ -1,219 +0,0 @@ -/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation - * Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com - * Revised: Thu Jun 24 14:53:45 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 1999/06/24 18:54:55 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c,v 1.1 2000/06/17 00:03:28 martin Exp $ - * - * DESCRIPTION - * - * This file contains a simple, straightforward implementation of the Park - * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer - * multiplicative linear congruential generator (MLCG) with a period of - * 2^31-1. - * - * This implementation is intended to provide a reliable, portable PRNG - * that is suitable for testing a hash table implementation and for - * implementing skip lists. - * - * FUTURE ENHANCEMENTS - * - * If initial seeds are not selected randomly, two instances of the PRNG - * can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique - * that can eliminate this problem. - * - * If PRNGs are used for simulation, the period of the current - * implementation may be too short. [LE88] discusses methods of combining - * MLCGs to produce much longer periods, and suggests some alternative - * values for A and M. [LE90 and Sch92] also provide information on - * long-period PRNGs. - * - * REFERENCES - * - * [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2: - * Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981. - * - * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number - * Generators". CACM 31(6), June 1988, pp. 742-774. - * - * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10, - * October 1990, pp. 85-97. - * - * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators: - * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201. - * - * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit - * CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40. - * - * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In - * "Technical Correspondence: Remarks on Choosing and Implementing Random - * Number Generators". CACM 36(7), July 1993, pp. 105-110. - * - */ - -#define RANDOM_MAIN 0 - -#if RANDOM_MAIN -# include <stdio.h> -# include <stdlib.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define RANDOM_MAGIC 0xfeedbeef -#define RANDOM_DEBUG 0 - -#if RANDOM_MAIN -#define RANDOM_ALLOC malloc -#define RANDOM_FREE free -#else -#define RANDOM_ALLOC drmMalloc -#define RANDOM_FREE drmFree -#endif - -typedef struct RandomState { - unsigned long magic; - unsigned long a; - unsigned long m; - unsigned long q; /* m div a */ - unsigned long r; /* m mod a */ - unsigned long check; - long seed; -} RandomState; - -#if RANDOM_MAIN -extern void *N(RandomCreate)(unsigned long seed); -extern int N(RandomDestroy)(void *state); -extern unsigned long N(Random)(void *state); -extern double N(RandomDouble)(void *state); -#endif - -void *N(RandomCreate)(unsigned long seed) -{ - RandomState *state; - - state = RANDOM_ALLOC(sizeof(*state)); - if (!state) return NULL; - state->magic = RANDOM_MAGIC; -#if 0 - /* Park & Miller, October 1988 */ - state->a = 16807; - state->m = 2147483647; - state->check = 1043618065; /* After 10000 iterations */ -#else - /* Park, Miller, and Stockmeyer, July 1993 */ - state->a = 48271; - state->m = 2147483647; - state->check = 399268537; /* After 10000 iterations */ -#endif - state->q = state->m / state->a; - state->r = state->m % state->a; - - state->seed = seed; - /* Check for illegal boundary conditions, - and choose closest legal value. */ - if (state->seed <= 0) state->seed = 1; - if (state->seed >= state->m) state->seed = state->m - 1; - - return state; -} - -int N(RandomDestroy)(void *state) -{ - RANDOM_FREE(state); - return 0; -} - -unsigned long N(Random)(void *state) -{ - RandomState *s = (RandomState *)state; - long hi; - long lo; - - hi = s->seed / s->q; - lo = s->seed % s->q; - s->seed = s->a * lo - s->r * hi; - if (s->seed <= 0) s->seed += s->m; - - return s->seed; -} - -double N(RandomDouble)(void *state) -{ - RandomState *s = (RandomState *)state; - - return (double)N(Random)(state)/(double)s->m; -} - -#if RANDOM_MAIN -static void check_period(long seed) -{ - unsigned long count = 0; - unsigned long initial; - void *state; - - state = N(RandomCreate)(seed); - initial = N(Random)(state); - ++count; - while (initial != N(Random)(state)) { - if (!++count) break; - } - printf("With seed of %10ld, period = %10lu (0x%08lx)\n", - seed, count, count); - N(RandomDestroy)(state); -} - -int main(void) -{ - RandomState *state; - int i; - unsigned long rand; - - state = N(RandomCreate)(1); - for (i = 0; i < 10000; i++) { - rand = N(Random)(state); - } - printf("After 10000 iterations: %lu (%lu expected): %s\n", - rand, state->check, - rand - state->check ? "*INCORRECT*" : "CORRECT"); - N(RandomDestroy)(state); - - printf("Checking periods...\n"); - check_period(1); - check_period(2); - check_period(31415926); - - return 0; -} -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c Mon Dec 18 14:31:45 2000 @@ -1,490 +0,0 @@ -/* xf86drmSL.c -- Skip list support - * Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com - * Revised: Thu Jun 3 16:13:01 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.2 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c,v 1.1 2000/06/17 00:03:28 martin Exp $ - * - * DESCRIPTION - * - * This file contains a straightforward skip list implementation.n - * - * FUTURE ENHANCEMENTS - * - * REFERENCES - * - * [Pugh90] William Pugh. Skip Lists: A Probabilistic Alternative to - * Balanced Trees. CACM 33(6), June 1990, pp. 668-676. - * - */ - -#define SL_MAIN 0 - -#if SL_MAIN -# include <stdio.h> -# include <stdlib.h> -# include <sys/time.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define SL_LIST_MAGIC 0xfacade00LU -#define SL_ENTRY_MAGIC 0x00fab1edLU -#define SL_FREED_MAGIC 0xdecea5edLU -#define SL_MAX_LEVEL 16 -#define SL_DEBUG 0 -#define SL_RANDOM_SEED 0xc01055a1LU - -#if SL_MAIN -#define SL_ALLOC malloc -#define SL_FREE free -#define SL_RANDOM_DECL static int state = 0; -#define SL_RANDOM_INIT(seed) if (!state) { srandom(seed); ++state; } -#define SL_RANDOM random() -#else -#define SL_ALLOC drmMalloc -#define SL_FREE drmFree -#define SL_RANDOM_DECL static void *state = NULL -#define SL_RANDOM_INIT(seed) if (!state) state = drmRandomCreate(seed) -#define SL_RANDOM drmRandom(state) - -#endif - -typedef struct SLEntry { - unsigned long magic; /* SL_ENTRY_MAGIC */ - unsigned long key; - void *value; - int levels; - struct SLEntry *forward[1]; /* variable sized array */ -} SLEntry, *SLEntryPtr; - -typedef struct SkipList { - unsigned long magic; /* SL_LIST_MAGIC */ - int level; - int count; - SLEntryPtr head; - SLEntryPtr p0; /* Position for iteration */ -} SkipList, *SkipListPtr; - -#if SL_MAIN -extern void *N(SLCreate)(void); -extern int N(SLDestroy)(void *l); -extern int N(SLLookup)(void *l, unsigned long key, void **value); -extern int N(SLInsert)(void *l, unsigned long key, void *value); -extern int N(SLDelete)(void *l, unsigned long key); -extern int N(SLNext)(void *l, unsigned long *key, void **value); -extern int N(SLFirst)(void *l, unsigned long *key, void **value); -extern void N(SLDump)(void *l); -extern int N(SLLookupNeighbors)(void *l, unsigned long key, - unsigned long *prev_key, void **prev_value, - unsigned long *next_key, void **next_value); -#endif - -static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value) -{ - SLEntryPtr entry; - - if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL; - - entry = SL_ALLOC(sizeof(*entry) - + (max_level + 1) * sizeof(entry->forward[0])); - if (!entry) return NULL; - entry->magic = SL_ENTRY_MAGIC; - entry->key = key; - entry->value = value; - entry->levels = max_level + 1; - - return entry; -} - -static int SLRandomLevel(void) -{ - int level = 1; - SL_RANDOM_DECL; - - SL_RANDOM_INIT(SL_RANDOM_SEED); - - while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level; - return level; -} - -void *N(SLCreate)(void) -{ - SkipListPtr list; - int i; - - list = SL_ALLOC(sizeof(*list)); - if (!list) return NULL; - list->magic = SL_LIST_MAGIC; - list->level = 0; - list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL); - list->count = 0; - - for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL; - - return list; -} - -int N(SLDestroy)(void *l) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - SLEntryPtr next; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - for (entry = list->head; entry; entry = next) { - if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */ - next = entry->forward[0]; - entry->magic = SL_FREED_MAGIC; - SL_FREE(entry); - } - - list->magic = SL_FREED_MAGIC; - SL_FREE(list); - return 0; -} - -static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) return NULL; - - for (i = list->level, entry = list->head; i >= 0; i--) { - while (entry->forward[i] && entry->forward[i]->key < key) - entry = entry->forward[i]; - update[i] = entry; - } - - return entry->forward[0]; -} - -int N(SLInsert)(void *l, unsigned long key, void *value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - int level; - int i; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = SLLocate(list, key, update); - - if (entry && entry->key == key) return 1; /* Already in list */ - - - level = SLRandomLevel(); - if (level > list->level) { - level = ++list->level; - update[level] = list->head; - } - - entry = SLCreateEntry(level, key, value); - - /* Fix up forward pointers */ - for (i = 0; i <= level; i++) { - entry->forward[i] = update[i]->forward[i]; - update[i]->forward[i] = entry; - } - - ++list->count; - return 0; /* Added to table */ -} - -int N(SLDelete)(void *l, unsigned long key) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = SLLocate(list, key, update); - - if (!entry || entry->key != key) return 1; /* Not found */ - - /* Fix up forward pointers */ - for (i = 0; i <= list->level; i++) { - if (update[i]->forward[i] == entry) - update[i]->forward[i] = entry->forward[i]; - } - - entry->magic = SL_FREED_MAGIC; - SL_FREE(entry); - - while (list->level && !list->head->forward[list->level]) --list->level; - --list->count; - return 0; -} - -int N(SLLookup)(void *l, unsigned long key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - - entry = SLLocate(list, key, update); - - if (entry && entry->key == key) { - *value = entry; - return 0; - } - *value = NULL; - return -1; -} - -int N(SLLookupNeighbors)(void *l, unsigned long key, - unsigned long *prev_key, void **prev_value, - unsigned long *next_key, void **next_value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - int retcode = 0; - - entry = SLLocate(list, key, update); - - *prev_key = *next_key = key; - *prev_value = *next_value = NULL; - - if (update[0]) { - *prev_key = update[0]->key; - *prev_value = update[0]->value; - ++retcode; - if (update[0]->forward[0]) { - *next_key = update[0]->forward[0]->key; - *next_value = update[0]->forward[0]->value; - ++retcode; - } - } - return retcode; -} - -int N(SLNext)(void *l, unsigned long *key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = list->p0; - - if (entry) { - list->p0 = entry->forward[0]; - *key = entry->key; - *value = entry->value; - return 1; - } - list->p0 = NULL; - return 0; -} - -int N(SLFirst)(void *l, unsigned long *key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - list->p0 = list->head->forward[0]; - return N(SLNext)(list, key, value); -} - -/* Dump internal data structures for debugging. */ -void N(SLDump)(void *l) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) { - printf("Bad magic: 0x%08lx (expected 0x%08lx)\n", - list->magic, SL_LIST_MAGIC); - return; - } - - printf("Level = %d, count = %d\n", list->level, list->count); - for (entry = list->head; entry; entry = entry->forward[0]) { - if (entry->magic != SL_ENTRY_MAGIC) { - printf("Bad magic: 0x%08lx (expected 0x%08lx)\n", - list->magic, SL_ENTRY_MAGIC); - } - printf("\nEntry %p <0x%08lx, %p> has %2d levels\n", - entry, entry->key, entry->value, entry->levels); - for (i = 0; i < entry->levels; i++) { - if (entry->forward[i]) { - printf(" %2d: %p <0x%08lx, %p>\n", - i, - entry->forward[i], - entry->forward[i]->key, - entry->forward[i]->value); - } else { - printf(" %2d: %p\n", i, entry->forward[i]); - } - } - } -} - -#if SL_MAIN -static void print(SkipListPtr list) -{ - unsigned long key; - void *value; - - if (N(SLFirst)(list, &key, &value)) { - do { - printf("key = %5lu, value = %p\n", key, value); - } while (N(SLNext)(list, &key, &value)); - } -} - -static double do_time(int size, int iter) -{ - SkipListPtr list; - int i, j; - unsigned long keys[1000000]; - unsigned long previous; - unsigned long key; - void *value; - struct timeval start, stop; - double usec; - SL_RANDOM_DECL; - - SL_RANDOM_INIT(12345); - - list = N(SLCreate)(); - - for (i = 0; i < size; i++) { - keys[i] = SL_RANDOM; - N(SLInsert)(list, keys[i], NULL); - } - - previous = 0; - if (N(SLFirst)(list, &key, &value)) { - do { - if (key <= previous) { - printf( "%lu !< %lu\n", previous, key); - } - previous = key; - } while (N(SLNext)(list, &key, &value)); - } - - gettimeofday(&start, NULL); - for (j = 0; j < iter; j++) { - for (i = 0; i < size; i++) { - if (N(SLLookup)(list, keys[i], &value)) - printf("Error %lu %d\n", keys[i], i); - } - } - gettimeofday(&stop, NULL); - - usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec - - start.tv_sec * 1000000 - start.tv_usec) / (size * iter); - - printf("%0.2f microseconds for list length %d\n", usec, size); - - N(SLDestroy)(list); - - return usec; -} - -static void print_neighbors(void *list, unsigned long key) -{ - unsigned long prev_key = 0; - unsigned long next_key = 0; - void *prev_value; - void *next_value; - int retval; - - retval = drmSLLookupNeighbors(list, key, - &prev_key, &prev_value, - &next_key, &next_value); - printf("Neighbors of %5lu: %d %5lu %5lu\n", - key, retval, prev_key, next_key); -} - -int main(void) -{ - SkipListPtr list; - double usec, usec2, usec3, usec4; - - list = N(SLCreate)(); - printf( "list at %p\n", list); - - print(list); - printf("\n==============================\n\n"); - - N(SLInsert)(list, 123, NULL); - N(SLInsert)(list, 213, NULL); - N(SLInsert)(list, 50, NULL); - print(list); - printf("\n==============================\n\n"); - - print_neighbors(list, 0); - print_neighbors(list, 50); - print_neighbors(list, 51); - print_neighbors(list, 123); - print_neighbors(list, 200); - print_neighbors(list, 213); - print_neighbors(list, 256); - printf("\n==============================\n\n"); - - N(SLDelete)(list, 50); - print(list); - printf("\n==============================\n\n"); - - N(SLDump)(list); - N(SLDestroy)(list); - printf("\n==============================\n\n"); - - usec = do_time(100, 10000); - usec2 = do_time(1000, 500); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 1000.0/100.0, usec2 / usec); - - usec3 = do_time(10000, 50); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 10000.0/100.0, usec3 / usec); - - usec4 = do_time(100000, 4); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 100000.0/100.0, usec4 / usec); - - return 0; -} -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile Fri Oct 27 12:59:40 2000 @@ -1,5 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile,v 1.1 2000/06/17 00:03:28 martin Exp $ -XCOMM $PI$ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile,v 1.3 2000/10/27 16:59:40 dawes Exp $ #include <Server.tmpl> @@ -10,6 +9,17 @@ LinkSourceFile(xf86drm.h,$(XF86OSSRC)) LinkSourceFile(xf86_OSproc.h,$(XF86OSSRC)) LinkSourceFile(sigio.c,$(XF86OSSRC)/shared) + +XCOMM Try to use the Linux version of the DRM headers. This avoids skew +XCOMM and missing headers. If there's a need to break them out, they +XCOMM can be re-added later. If not, they can be moved to somewhere more +XCOMM OS-independent and referenced from there. +LinkSourceFile(drm.h,$(XF86OSSRC)/linux/drm/kernel) +LinkSourceFile(i810_drm.h,$(XF86OSSRC)/linux/drm/kernel) +LinkSourceFile(mga_drm.h,$(XF86OSSRC)/linux/drm/kernel) +LinkSourceFile(r128_drm.h,$(XF86OSSRC)/linux/drm/kernel) +LinkSourceFile(sis_drm.h,$(XF86OSSRC)/linux/drm/kernel) + XCOMM This is a kludge until we determine how best to build the XCOMM kernel-specific device driver. This allows us to continue Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h Mon Dec 18 14:31:46 2000 @@ -1,362 +0,0 @@ -/* drm.h -- Header for Direct Rendering Manager -*- c -*- - * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Rickard E. (Rik) Faith <faith@valinux.com> - * - * Acknowledgements: - * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg. - * - */ - -#ifndef _DRM_H_ -#define _DRM_H_ - -#include <sys/ioccom.h> /* For _IO* macros */ - -#define DRM_DEV_DRM "/dev/drm" -#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) -#define DRM_DEV_UID 0 -#define DRM_DEV_GID 0 - - -#define DRM_NAME "drm" /* Name in kernel, /dev */ -#define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */ -#define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */ -#define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */ - -#define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */ -#define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */ -#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD) -#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT) -#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT)) - -typedef unsigned long drm_handle_t; -typedef unsigned int drm_context_t; -typedef unsigned int drm_drawable_t; -typedef unsigned int drm_magic_t; - -/* Warning: If you change this structure, make sure you change - * XF86DRIClipRectRec in the server as well */ - -typedef struct drm_clip_rect { - unsigned short x1; - unsigned short y1; - unsigned short x2; - unsigned short y2; -} drm_clip_rect_t; - -/* Seperate include files for the i810/mga/r128 specific structures */ -#include "mga_drm.h" -#include "i810_drm.h" -#include "r128_drm.h" - -typedef struct drm_version { - int version_major; /* Major version */ - int version_minor; /* Minor version */ - int version_patchlevel;/* Patch level */ - size_t name_len; /* Length of name buffer */ - char *name; /* Name of driver */ - size_t date_len; /* Length of date buffer */ - char *date; /* User-space buffer to hold date */ - size_t desc_len; /* Length of desc buffer */ - char *desc; /* User-space buffer to hold desc */ -} drm_version_t; - -typedef struct drm_unique { - size_t unique_len; /* Length of unique */ - char *unique; /* Unique name for driver instantiation */ -} drm_unique_t; - -typedef struct drm_list { - int count; /* Length of user-space structures */ - drm_version_t *version; -} drm_list_t; - -typedef struct drm_block { - int unused; -} drm_block_t; - -typedef struct drm_control { - enum { - DRM_ADD_COMMAND, - DRM_RM_COMMAND, - DRM_INST_HANDLER, - DRM_UNINST_HANDLER - } func; - int irq; -} drm_control_t; - -typedef enum drm_map_type { - _DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */ - _DRM_REGISTERS = 1, /* no caching, no core dump */ - _DRM_SHM = 2, /* shared, cached */ - _DRM_AGP = 3 /* AGP/GART */ -} drm_map_type_t; - -typedef enum drm_map_flags { - _DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */ - _DRM_READ_ONLY = 0x02, - _DRM_LOCKED = 0x04, /* shared, cached, locked */ - _DRM_KERNEL = 0x08, /* kernel requires access */ - _DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */ - _DRM_CONTAINS_LOCK = 0x20 /* SHM page that contains lock */ -} drm_map_flags_t; - -typedef struct drm_map { - unsigned long offset; /* Requested physical address (0 for SAREA)*/ - unsigned long size; /* Requested physical size (bytes) */ - drm_map_type_t type; /* Type of memory to map */ - drm_map_flags_t flags; /* Flags */ - void *handle; /* User-space: "Handle" to pass to mmap */ - /* Kernel-space: kernel-virtual address */ - int mtrr; /* MTRR slot used */ - /* Private data */ -} drm_map_t; - -typedef enum drm_lock_flags { - _DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */ - _DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */ - _DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */ - _DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */ - /* These *HALT* flags aren't supported yet - -- they will be used to support the - full-screen DGA-like mode. */ - _DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */ - _DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */ -} drm_lock_flags_t; - -typedef struct drm_lock { - int context; - drm_lock_flags_t flags; -} drm_lock_t; - -typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */ - /* Flags for DMA buffer dispatch */ - _DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched. - Note, the buffer may not yet have - been processed by the hardware -- - getting a hardware lock with the - hardware quiescent will ensure - that the buffer has been - processed. */ - _DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */ - _DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */ - - /* Flags for DMA buffer request */ - _DRM_DMA_WAIT = 0x10, /* Wait for free buffers */ - _DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */ - _DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */ -} drm_dma_flags_t; - -typedef struct drm_buf_desc { - int count; /* Number of buffers of this size */ - int size; /* Size in bytes */ - int low_mark; /* Low water mark */ - int high_mark; /* High water mark */ - enum { - _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */ - _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */ - } flags; - unsigned long agp_start; /* Start address of where the agp buffers - * are in the agp aperture */ -} drm_buf_desc_t; - -typedef struct drm_buf_info { - int count; /* Entries in list */ - drm_buf_desc_t *list; -} drm_buf_info_t; - -typedef struct drm_buf_free { - int count; - int *list; -} drm_buf_free_t; - -typedef struct drm_buf_pub { - int idx; /* Index into master buflist */ - int total; /* Buffer size */ - int used; /* Amount of buffer in use (for DMA) */ - void *address; /* Address of buffer */ -} drm_buf_pub_t; - -typedef struct drm_buf_map { - int count; /* Length of buflist */ - void *virtual; /* Mmaped area in user-virtual */ - drm_buf_pub_t *list; /* Buffer information */ -} drm_buf_map_t; - -typedef struct drm_dma { - /* Indices here refer to the offset into - buflist in drm_buf_get_t. */ - int context; /* Context handle */ - int send_count; /* Number of buffers to send */ - int *send_indices; /* List of handles to buffers */ - int *send_sizes; /* Lengths of data to send */ - drm_dma_flags_t flags; /* Flags */ - int request_count; /* Number of buffers requested */ - int request_size; /* Desired size for buffers */ - int *request_indices; /* Buffer information */ - int *request_sizes; - int granted_count; /* Number of buffers granted */ -} drm_dma_t; - -typedef enum { - _DRM_CONTEXT_PRESERVED = 0x01, - _DRM_CONTEXT_2DONLY = 0x02 -} drm_ctx_flags_t; - -typedef struct drm_ctx { - drm_context_t handle; - drm_ctx_flags_t flags; -} drm_ctx_t; - -typedef struct drm_ctx_res { - int count; - drm_ctx_t *contexts; -} drm_ctx_res_t; - -typedef struct drm_draw { - drm_drawable_t handle; -} drm_draw_t; - -typedef struct drm_auth { - drm_magic_t magic; -} drm_auth_t; - -typedef struct drm_irq_busid { - int irq; - int busnum; - int devnum; - int funcnum; -} drm_irq_busid_t; - -typedef struct drm_agp_mode { - unsigned long mode; -} drm_agp_mode_t; - - /* For drm_agp_alloc -- allocated a buffer */ -typedef struct drm_agp_buffer { - unsigned long size; /* In bytes -- will round to page boundary */ - unsigned long handle; /* Used for BIND/UNBIND ioctls */ - unsigned long type; /* Type of memory to allocate */ - unsigned long physical; /* Physical used by i810 */ -} drm_agp_buffer_t; - - /* For drm_agp_bind */ -typedef struct drm_agp_binding { - unsigned long handle; /* From drm_agp_buffer */ - unsigned long offset; /* In bytes -- will round to page boundary */ -} drm_agp_binding_t; - -typedef struct drm_agp_info { - int agp_version_major; - int agp_version_minor; - unsigned long mode; - unsigned long aperture_base; /* physical address */ - unsigned long aperture_size; /* bytes */ - unsigned long memory_allowed; /* bytes */ - unsigned long memory_used; - - /* PCI information */ - unsigned short id_vendor; - unsigned short id_device; -} drm_agp_info_t; - -#define DRM_IOCTL_BASE 'd' -#define DRM_IOCTL_NR(n) ((n) & 0xff) -#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) -#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size) -#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size) -#define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size) - - -#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t) -#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t) -#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t) -#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t) - -#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t) -#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t) -#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t) -#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t) -#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t) -#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t) -#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t) -#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t) -#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t) -#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t) -#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t) - -#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t) -#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t) -#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t) -#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t) -#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t) -#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t) -#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t) -#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t) -#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t) -#define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t) -#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t) -#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t) -#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t) - -#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30) -#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31) -#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t) -#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t) -#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t) -#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t) -#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t) -#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t) - -/* Mga specific ioctls */ -#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) -#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t) -#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t) -#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t) -#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t) -#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t ) -#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t) - -/* I810 specific ioctls */ -#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t) -#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t) -#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t) -#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43) -#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44) -#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t) -#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46) - -/* Rage 128 specific ioctls */ -#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) -#define DRM_IOCTL_R128_RESET DRM_IO( 0x41) -#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) -#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) -#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) - -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h Mon Dec 18 14:31:46 2000 @@ -1,188 +0,0 @@ -#ifndef _I810_DRM_H_ -#define _I810_DRM_H_ - -/* WARNING: These defines must be the same as what the Xserver uses. - * if you change them, you must change the defines in the Xserver. - */ - -#ifndef _I810_DEFINES_ -#define _I810_DEFINES_ - -#define I810_DMA_BUF_ORDER 12 -#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER) -#define I810_DMA_BUF_NR 256 -#define I810_NR_SAREA_CLIPRECTS 8 - -/* Each region is a minimum of 64k, and there are at most 64 of them. - */ -#define I810_NR_TEX_REGIONS 64 -#define I810_LOG_MIN_TEX_REGION_SIZE 16 -#endif - -#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */ -#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */ -#define I810_UPLOAD_CTX 0x4 -#define I810_UPLOAD_BUFFERS 0x8 -#define I810_UPLOAD_TEX0 0x10 -#define I810_UPLOAD_TEX1 0x20 -#define I810_UPLOAD_CLIPRECTS 0x40 - - -/* Indices into buf.Setup where various bits of state are mirrored per - * context and per buffer. These can be fired at the card as a unit, - * or in a piecewise fashion as required. - */ - -/* Destbuffer state - * - backbuffer linear offset and pitch -- invarient in the current dri - * - zbuffer linear offset and pitch -- also invarient - * - drawing origin in back and depth buffers. - * - * Keep the depth/back buffer state here to acommodate private buffers - * in the future. - */ -#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */ -#define I810_DESTREG_DI1 1 -#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */ -#define I810_DESTREG_DV1 3 -#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */ -#define I810_DESTREG_DR1 5 -#define I810_DESTREG_DR2 6 -#define I810_DESTREG_DR3 7 -#define I810_DESTREG_DR4 8 -#define I810_DEST_SETUP_SIZE 10 - -/* Context state - */ -#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */ -#define I810_CTXREG_CF1 1 -#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */ -#define I810_CTXREG_ST1 3 -#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */ -#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */ -#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */ -#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */ -#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */ -#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */ -#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */ -#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */ -#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */ -#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */ -#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */ -#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */ -#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */ -#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */ -#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */ -#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */ -#define I810_CTX_SETUP_SIZE 20 - -/* Texture state (per tex unit) - */ -#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */ -#define I810_TEXREG_MI1 1 -#define I810_TEXREG_MI2 2 -#define I810_TEXREG_MI3 3 -#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */ -#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */ -#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */ -#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */ -#define I810_TEX_SETUP_SIZE 8 - -#define I810_FRONT 0x1 -#define I810_BACK 0x2 -#define I810_DEPTH 0x4 - - -typedef struct _drm_i810_init { - enum { - I810_INIT_DMA = 0x01, - I810_CLEANUP_DMA = 0x02 - } func; - int ring_map_idx; - int buffer_map_idx; - int sarea_priv_offset; - unsigned int ring_start; - unsigned int ring_end; - unsigned int ring_size; - unsigned int front_offset; - unsigned int back_offset; - unsigned int depth_offset; - unsigned int w; - unsigned int h; - unsigned int pitch; - unsigned int pitch_bits; -} drm_i810_init_t; - -/* Warning: If you change the SAREA structure you must change the Xserver - * structure as well */ - -typedef struct _drm_i810_tex_region { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} drm_i810_tex_region_t; - -typedef struct _drm_i810_sarea { - unsigned int ContextState[I810_CTX_SETUP_SIZE]; - unsigned int BufferState[I810_DEST_SETUP_SIZE]; - unsigned int TexState[2][I810_TEX_SETUP_SIZE]; - unsigned int dirty; - - unsigned int nbox; - drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS]; - - /* Maintain an LRU of contiguous regions of texture space. If - * you think you own a region of texture memory, and it has an - * age different to the one you set, then you are mistaken and - * it has been stolen by another client. If global texAge - * hasn't changed, there is no need to walk the list. - * - * These regions can be used as a proxy for the fine-grained - * texture information of other clients - by maintaining them - * in the same lru which is used to age their own textures, - * clients have an approximate lru for the whole of global - * texture space, and can make informed decisions as to which - * areas to kick out. There is no need to choose whether to - * kick out your own texture or someone else's - simply eject - * them all in LRU order. - */ - - drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1]; - /* Last elt is sentinal */ - int texAge; /* last time texture was uploaded */ - int last_enqueue; /* last time a buffer was enqueued */ - int last_dispatch; /* age of the most recently dispatched buffer */ - int last_quiescent; /* */ - int ctxOwner; /* last context to upload state */ - - int vertex_prim; - -} drm_i810_sarea_t; - -typedef struct _drm_i810_clear { - int clear_color; - int clear_depth; - int flags; -} drm_i810_clear_t; - - - -/* These may be placeholders if we have more cliprects than - * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to - * false, indicating that the buffer will be dispatched again with a - * new set of cliprects. - */ -typedef struct _drm_i810_vertex { - int idx; /* buffer index */ - int used; /* nr bytes in use */ - int discard; /* client is finished with the buffer? */ -} drm_i810_vertex_t; - -typedef struct drm_i810_dma { - void *virtual; - int request_idx; - int request_size; - int granted; -} drm_i810_dma_t; - -#endif /* _I810_DRM_H_ */ Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h:1.1 Fri Jun 16 20:03:28 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h Mon Dec 18 14:31:46 2000 @@ -1,269 +0,0 @@ -/* mga_drm.h -- Public header for the Matrox g200/g400 driver - * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Jeff Hartmann <jhartmann@valinux.com> - * Keith Whitwell <keithw@valinux.com> - * - */ - -#ifndef _MGA_DRM_H_ -#define _MGA_DRM_H_ - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (xf86drmMga.h) - */ -#ifndef _MGA_DEFINES_ -#define _MGA_DEFINES_ - -#define MGA_F 0x1 /* fog */ -#define MGA_A 0x2 /* alpha */ -#define MGA_S 0x4 /* specular */ -#define MGA_T2 0x8 /* multitexture */ - -#define MGA_WARP_TGZ 0 -#define MGA_WARP_TGZF (MGA_F) -#define MGA_WARP_TGZA (MGA_A) -#define MGA_WARP_TGZAF (MGA_F|MGA_A) -#define MGA_WARP_TGZS (MGA_S) -#define MGA_WARP_TGZSF (MGA_S|MGA_F) -#define MGA_WARP_TGZSA (MGA_S|MGA_A) -#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A) -#define MGA_WARP_T2GZ (MGA_T2) -#define MGA_WARP_T2GZF (MGA_T2|MGA_F) -#define MGA_WARP_T2GZA (MGA_T2|MGA_A) -#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F) -#define MGA_WARP_T2GZS (MGA_T2|MGA_S) -#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F) -#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A) -#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A) - -#define MGA_MAX_G400_PIPES 16 -#define MGA_MAX_G200_PIPES 8 /* no multitex */ -#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES - -#define MGA_CARD_TYPE_G200 1 -#define MGA_CARD_TYPE_G400 2 - -#define MGA_FRONT 0x1 -#define MGA_BACK 0x2 -#define MGA_DEPTH 0x4 - -/* 3d state excluding texture units: - */ -#define MGA_CTXREG_DSTORG 0 /* validated */ -#define MGA_CTXREG_MACCESS 1 -#define MGA_CTXREG_PLNWT 2 -#define MGA_CTXREG_DWGCTL 3 -#define MGA_CTXREG_ALPHACTRL 4 -#define MGA_CTXREG_FOGCOLOR 5 -#define MGA_CTXREG_WFLAG 6 -#define MGA_CTXREG_TDUAL0 7 -#define MGA_CTXREG_TDUAL1 8 -#define MGA_CTXREG_FCOL 9 -#define MGA_CTX_SETUP_SIZE 10 - -/* 2d state - */ -#define MGA_2DREG_PITCH 0 -#define MGA_2D_SETUP_SIZE 1 - -/* Each texture unit has a state: - */ -#define MGA_TEXREG_CTL 0 -#define MGA_TEXREG_CTL2 1 -#define MGA_TEXREG_FILTER 2 -#define MGA_TEXREG_BORDERCOL 3 -#define MGA_TEXREG_ORG 4 /* validated */ -#define MGA_TEXREG_ORG1 5 -#define MGA_TEXREG_ORG2 6 -#define MGA_TEXREG_ORG3 7 -#define MGA_TEXREG_ORG4 8 -#define MGA_TEXREG_WIDTH 9 -#define MGA_TEXREG_HEIGHT 10 -#define MGA_TEX_SETUP_SIZE 11 - -/* What needs to be changed for the current vertex dma buffer? - */ -#define MGA_UPLOAD_CTX 0x1 -#define MGA_UPLOAD_TEX0 0x2 -#define MGA_UPLOAD_TEX1 0x4 -#define MGA_UPLOAD_PIPE 0x8 -#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */ -#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */ -#define MGA_UPLOAD_2D 0x40 -#define MGA_WAIT_AGE 0x80 /* handled client-side */ -#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */ -#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock - quiescent */ - -/* 32 buffers of 64k each, total 2 meg. - */ -#define MGA_DMA_BUF_ORDER 16 -#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER) -#define MGA_DMA_BUF_NR 31 - -/* Keep these small for testing. - */ -#define MGA_NR_SAREA_CLIPRECTS 8 - -/* 2 heaps (1 for card, 1 for agp), each divided into upto 128 - * regions, subject to a minimum region size of (1<<16) == 64k. - * - * Clients may subdivide regions internally, but when sharing between - * clients, the region size is the minimum granularity. - */ - -#define MGA_CARD_HEAP 0 -#define MGA_AGP_HEAP 1 -#define MGA_NR_TEX_HEAPS 2 -#define MGA_NR_TEX_REGIONS 16 -#define MGA_LOG_MIN_TEX_REGION_SIZE 16 -#endif - -typedef struct _drm_mga_warp_index { - int installed; - unsigned long phys_addr; - int size; -} drm_mga_warp_index_t; - -typedef struct drm_mga_init { - enum { - MGA_INIT_DMA = 0x01, - MGA_CLEANUP_DMA = 0x02 - } func; - int reserved_map_agpstart; - int reserved_map_idx; - int buffer_map_idx; - int sarea_priv_offset; - int primary_size; - int warp_ucode_size; - unsigned int frontOffset; - unsigned int backOffset; - unsigned int depthOffset; - unsigned int textureOffset; - unsigned int textureSize; - unsigned int agpTextureOffset; - unsigned int agpTextureSize; - unsigned int cpp; - unsigned int stride; - int sgram; - int chipset; - drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES]; - unsigned int mAccess; -} drm_mga_init_t; - -/* Warning: if you change the sarea structure, you must change the Xserver - * structures as well */ - -typedef struct _drm_mga_tex_region { - unsigned char next, prev; - unsigned char in_use; - unsigned int age; -} drm_mga_tex_region_t; - -typedef struct _drm_mga_sarea { - /* The channel for communication of state information to the kernel - * on firing a vertex dma buffer. - */ - unsigned int ContextState[MGA_CTX_SETUP_SIZE]; - unsigned int ServerState[MGA_2D_SETUP_SIZE]; - unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; - unsigned int WarpPipe; - unsigned int dirty; - - unsigned int nbox; - drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS]; - - - /* Information about the most recently used 3d drawable. The - * client fills in the req_* fields, the server fills in the - * exported_ fields and puts the cliprects into boxes, above. - * - * The client clears the exported_drawable field before - * clobbering the boxes data. - */ - unsigned int req_drawable; /* the X drawable id */ - unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */ - - unsigned int exported_drawable; - unsigned int exported_index; - unsigned int exported_stamp; - unsigned int exported_buffers; - unsigned int exported_nfront; - unsigned int exported_nback; - int exported_back_x, exported_front_x, exported_w; - int exported_back_y, exported_front_y, exported_h; - drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS]; - - /* Counters for aging textures and for client-side throttling. - */ - unsigned int last_enqueue; /* last time a buffer was enqueued */ - unsigned int last_dispatch; /* age of the most recently dispatched buffer */ - unsigned int last_quiescent; /* */ - - - /* LRU lists for texture memory in agp space and on the card - */ - drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1]; - unsigned int texAge[MGA_NR_TEX_HEAPS]; - - /* Mechanism to validate card state. - */ - int ctxOwner; -} drm_mga_sarea_t; - -/* Device specific ioctls: - */ -typedef struct _drm_mga_clear { - unsigned int clear_color; - unsigned int clear_depth; - unsigned int flags; -} drm_mga_clear_t; - -typedef struct _drm_mga_swap { - int dummy; -} drm_mga_swap_t; - -typedef struct _drm_mga_iload { - int idx; - int length; - unsigned int destOrg; -} drm_mga_iload_t; - -typedef struct _drm_mga_vertex { - int idx; /* buffer to queue */ - int used; /* bytes in use */ - int discard; /* client finished with buffer? */ -} drm_mga_vertex_t; - -typedef struct _drm_mga_indices { - int idx; /* buffer to queue */ - unsigned int start; - unsigned int end; - int discard; /* client finished with buffer? */ -} drm_mga_indices_t; - -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h:removed --- xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h:1.1 Fri Jun 16 20:03:29 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h Mon Dec 18 14:31:46 2000 @@ -1,111 +0,0 @@ -/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*- - * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com - * - * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Kevin E. Martin <kevin@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h,v 1.1 2000/06/17 00:03:29 martin Exp $ - */ - -#ifndef _R128_DRM_H_ -#define _R128_DRM_H_ - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (xf86drmR128.h) - */ -typedef struct drm_r128_init { - enum { - R128_INIT_CCE = 0x01, - R128_CLEANUP_CCE = 0x02 - } func; - int sarea_priv_offset; - int is_pci; - int cce_mode; - int cce_fifo_size; - int cce_secure; - int ring_size; - int usec_timeout; - - int fb_offset; - int agp_ring_offset; - int agp_read_ptr_offset; - int agp_vertbufs_offset; - int agp_indbufs_offset; - int agp_textures_offset; - int mmio_offset; -} drm_r128_init_t; - -typedef struct drm_r128_packet { - unsigned long *buffer; - int count; - int flags; -} drm_r128_packet_t; - -typedef enum drm_r128_prim { - _DRM_R128_PRIM_NONE = 0x0001, - _DRM_R128_PRIM_POINT = 0x0002, - _DRM_R128_PRIM_LINE = 0x0004, - _DRM_R128_PRIM_POLY_LINE = 0x0008, - _DRM_R128_PRIM_TRI_LIST = 0x0010, - _DRM_R128_PRIM_TRI_FAN = 0x0020, - _DRM_R128_PRIM_TRI_STRIP = 0x0040, - _DRM_R128_PRIM_TRI_TYPE2 = 0x0080 -} drm_r128_prim_t; - -typedef struct drm_r128_vertex { - /* Indices here refer to the offset into - buflist in drm_buf_get_t. */ - int send_count; /* Number of buffers to send */ - int *send_indices; /* List of handles to buffers */ - int *send_sizes; /* Lengths of data to send */ - drm_r128_prim_t prim; /* Primitive type */ - int request_count; /* Number of buffers requested */ - int *request_indices; /* Buffer information */ - int *request_sizes; - int granted_count; /* Number of buffers granted */ -} drm_r128_vertex_t; - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (r128_sarea.h) - */ -#define R128_LOCAL_TEX_HEAP 0 -#define R128_AGP_TEX_HEAP 1 -#define R128_NR_TEX_HEAPS 2 -#define R128_NR_TEX_REGIONS 64 -#define R128_LOG_TEX_GRANULARITY 16 - -typedef struct drm_tex_region { - unsigned char next, prev; - unsigned char in_use; - int age; -} drm_tex_region_t; - -typedef struct drm_r128_sarea { - drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; - int tex_age[R128_NR_TEX_HEAPS]; - int ctx_owner; - int ring_write; -} drm_r128_sarea_t; - -#endif Index: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile:3.12 xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile:3.13 --- xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile:3.12 Tue Jun 27 10:27:29 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile Tue Aug 15 12:05:37 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile,v 3.12 2000/06/27 14:27:29 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile,v 3.13 2000/08/15 16:05:37 dawes Exp $ @@ -13,12 +13,12 @@ SRCS = bsdi_init.c bsdi_video.c bsdi_io.c bios_devmem.c \ VTsw_noop.c std_kbdEv.c posix_tty.c $(MOUSESRC) \ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = bsdi_init.o bsdi_video.o bsdi_io.o bios_devmem.o \ VTsw_noop.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) @@ -40,6 +40,7 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c:3.8 xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c:3.9 --- xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c:3.8 Thu Apr 29 08:24:51 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c Tue Oct 24 18:45:10 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c,v 3.8 1999/04/29 12:24:51 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c,v 3.9 2000/10/24 22:45:10 dawes Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -32,6 +32,7 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" +#include "xf86OSpriv.h" #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) @@ -166,10 +167,15 @@ return; } - void xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, unsigned long Size) { +} + +Bool +xf86CheckMTRR(int ScreenNum) +{ + return FALSE; } Index: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile:1.13 xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile:1.15 --- xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile:1.13 Mon Jun 12 22:28:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile Thu Nov 30 19:24:35 2000 @@ -3,7 +3,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.13 2000/06/13 02:28:36 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.15 2000/12/01 00:24:35 dawes Exp $ #include <Server.tmpl> @@ -23,13 +23,20 @@ SBUSDRVSRC = linuxSbus.c SBUSDRVOBJ = linuxSbus.o -#elif defined(LinuxArchitecture) && (defined(PpcArchitecture) || defined(MipsArchitecture)) +#elif defined(LinuxArchitecture) && (defined(PpcArchitecture) || defined(MipsArchitecture) || defined(ia64Architecture)) XCOMM generic linux PCI driver (using /proc/bus/pci, requires kernel 2.2) PCIDRVRSRC = linuxPci.c PCIDRVROBJ = linuxPci.o +#elif defined(OpenBSDArchitecture) && defined(PpcArchitecture) + +XCOMM OpenBSD/powerpc + +PCIDRVRSRC = freebsdPci.c +PCIDRVROBJ = freebsdPci.o + #elif defined(PpcArchitecture) XCOMM PowerPC PCI drivers @@ -37,7 +44,7 @@ PCIDRVRSRC = ppcPci.c PCIDRVROBJ = ppcPci.o -#elif defined(LinuxArchitecture) && ( defined(i386Architecture) || defined(ia64Architecture)) +#elif defined(LinuxArchitecture) && (defined(i386Architecture)) XCOMM ix86 PCI driver with OS fallback for Linux Index: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c:1.32 xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c:1.42 --- xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c:1.32 Tue Jun 20 15:40:31 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c Thu Dec 7 10:43:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.32 2000/06/20 19:40:31 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.42 2000/12/07 15:43:45 tsi Exp $ */ /* * Pci.c - New server PCI access functions * @@ -568,7 +568,7 @@ mask1 >>= 1; } /* I/O maps can be no larger than 8 bits */ - if (PCI_MAP_IS_IO(addr1) && bits > 8) + if ((index < 6) && PCI_MAP_IS_IO(addr1) && bits > 8) bits = 8; /* ROM maps can be no larger than 24 bits */ if (index == 6 && bits > 24) @@ -1006,13 +1006,20 @@ return pci_devp; } +CARD32 +pciCheckForBrokenBase(PCITAG Tag,int basereg) +{ + pciWriteLong(Tag, PCI_MAP_REG_START + (basereg << 2), 0xffffffff); + return pciReadLong(Tag, PCI_MAP_REG_START + (basereg << 2)); +} + #if defined(INCLUDE_XF86_MAP_PCI_MEM) pointer -xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, unsigned long Base, +xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, ADDRESS Base, unsigned long Size) { - unsigned long hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM,Base); + ADDRESS hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM,Base); pointer base; CARD32 save = 0; @@ -1059,24 +1066,37 @@ */ romsave = pciReadLong(Tag, PCI_MAP_ROM_REG); romaddr = PCIGETROM(romsave); - if ((newbase = getValidBIOSBase(Tag,basereg)) != romaddr) { + if ((newbase = getValidBIOSBase(Tag, &basereg)) != romaddr) { romaddr = PCIGETROM(newbase); if (romaddr != 0 && romaddr == newbase) { #if 1 - savebase = pciReadLong(Tag, PCI_MAP_REG_START + (basereg << 2)); - if (PCIGETROM(savebase) == romaddr) + /* move mem base out of the way if in conflict with ROM */ + if ((basereg >= 0) && (basereg <= 5)) { + savebase = pciReadLong(Tag, PCI_MAP_REG_START + (basereg << 2)); + if (PCIGETROM(savebase) == romaddr) { + xf86MsgVerb(X_INFO,5,"xf86ReadPciBios: modifying membase[%i]" + " for device %i:%i:%i\n", basereg, + PCI_BUS_FROM_TAG(Tag), PCI_DEV_FROM_TAG(Tag), + PCI_FUNC_FROM_TAG(Tag)); pciWriteLong(Tag, PCI_MAP_REG_START + (basereg << 2), 0); - else - savebase = 0; + } + } #endif pciWriteLong(Tag, PCI_MAP_ROM_REG, romaddr); } else romaddr = 0; } + + if (romaddr == 0) { xf86Msg(X_WARNING, "xf86ReadPciBIOS: cannot locate a BIOS address\n"); return -1; - } + } + else + xf86MsgVerb(X_INFO,5,"xf86ReadPciBIOS: found ValidBIOSBase for %i:%i:%i:" + " %x\n", PCI_BUS_FROM_TAG(Tag), PCI_DEV_FROM_TAG(Tag), + PCI_FUNC_FROM_TAG(Tag),newbase); + hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM, PCIGETROM(romaddr)); #ifdef DEBUG ErrorF("ReadPciBIOS: base = 0x%x\n",romaddr); @@ -1109,7 +1129,7 @@ size = readPciBIOS(Offset,Tag,basereg,Buf,Len); - if (Buf[0] == 0x55 && Buf[1] == 0xaa) + if (size != -1 && Buf[0] == 0x55 && Buf[1] == 0xaa) return size; num = pciTestMultiDeviceCard(PCI_BUS_FROM_TAG(Tag), @@ -1129,30 +1149,12 @@ PCI_CMD_STAT_REG,(Acc2 | PCI_ENA)); size = readPciBIOS(Offset,pTag[i],0,Buf,Len); ((WriteProcPtr)(pciLongFunc(pTag[i],WRITE)))(pTag[i],PCI_CMD_STAT_REG,Acc2); - if (((CARD8*)Buf)[0] == 0x55 && ((CARD8*)Buf)[1] == 0xaa) + if (size != -1 && ((CARD8*)Buf)[0] == 0x55 && ((CARD8*)Buf)[1] == 0xaa) break; } ((WriteProcPtr)(pciLongFunc(Tag,WRITE)))(Tag,PCI_CMD_STAT_REG,Acc1); return size; } - -#elif defined(__sparc__) - -pointer -xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, unsigned long Base, - unsigned long Size) -{ - FatalError("xf86MapPciMem: Unsupported on SPARC\n"); - return((pointer)-1); -} - -int -xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg, - unsigned char *Buf, int Len) -{ - FatalError("xf86ReadPciBIOS: Unsupported on SPARC\n"); - return -1; -} #endif /* INCLUDE_XF86_MAP_PCI_MEM */ Index: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h:1.12 xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h:1.16 --- xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h:1.12 Tue Jun 20 17:19:11 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h Thu Nov 30 19:24:35 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.12 2000/06/20 21:19:11 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.16 2000/12/01 00:24:35 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -85,7 +85,7 @@ */ #define MAX_PCI_DEVICES 64 /* Max number of devices accomodated */ /* by xf86scanpci */ -#define MAX_PCI_BUSES 32 /* Max number of PCI buses */ +#define MAX_PCI_BUSES 256 /* Max number of PCI buses */ #define PCI_NOT_FOUND 0xffffffff @@ -139,6 +139,9 @@ #if (defined(__powerpc__) || defined(__mips__)) && defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM +#elif defined(__powerpc__) && defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM #elif defined(__powerpc__) # define ARCH_PCI_INIT ppcPciInit # if !defined(PowerMAX_OS) @@ -146,6 +149,7 @@ # endif #elif defined(__sparc__) && defined(linux) # define ARCH_PCI_INIT sparcPciInit +# define INCLUDE_XF86_MAP_PCI_MEM #elif defined(__alpha__) && defined(linux) # define ARCH_PCI_INIT axpPciInit # define INCLUDE_XF86_MAP_PCI_MEM @@ -154,8 +158,7 @@ # define ARCH_PCI_OS_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM #elif defined(__ia64__) && defined(linux) -# define ARCH_PCI_INIT ix86PciInit -# define ARCH_PCI_OS_INIT linuxPciInit +# define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM #elif defined(__alpha__) && defined(__FreeBSD__) # define ARCH_PCI_INIT freebsdPciInit Index: xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c:1.9 --- xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c:1.7 Fri Dec 3 14:17:40 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c Mon Aug 28 12:04:51 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c,v 1.7 1999/12/03 19:17:40 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c,v 1.9 2000/08/28 16:04:51 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -61,6 +61,7 @@ void axpPciCfgWrite(PCITAG, int off, CARD32 val); void axpPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits); +#if 0 pciBusInfo_t axpPci0 = { /* configMech */ PCI_CFG_MECH_OTHER, /* numDevices */ 32, @@ -77,12 +78,32 @@ }, /* pciBusPriv */ NULL }; +#else +pciBusInfo_t axpPci[MAX_PCI_BUSES]; +#endif void axpPciInit() { +#if 0 pciNumBuses = 1; pciBusInfo[0] = &axpPci0; +#else + int i; + + pciNumBuses = MAX_PCI_BUSES; + memset(&axpPci, 0, sizeof(axpPci)); + for (i = 0; i < MAX_PCI_BUSES; ++i) { + axpPci[i].configMech = PCI_CFG_MECH_OTHER; + axpPci[i].numDevices = 32; + axpPci[i].funcs.pciReadLong = axpPciCfgRead; + axpPci[i].funcs.pciWriteLong = axpPciCfgWrite; + axpPci[i].funcs.pciSetBitsLong = axpPciCfgSetBits; + axpPci[i].funcs.pciAddrHostToBus = pciAddrNOOP; + axpPci[i].funcs.pciAddrBusToHost = pciAddrNOOP; + pciBusInfo[i] = axpPci + i; + } +#endif pciFindFirstFP = pciGenFindFirst; pciFindNextFP = pciGenFindNext; } @@ -101,8 +122,14 @@ CARD32 val = 0xffffffff; bus = PCI_BUS_FROM_TAG(tag); + /* + * Workaround for kernel bug + * triggered when probing for PCI devices + */ + if (bus >= pciNumBuses) + return (val); dfn = PCI_DFN_FROM_TAG(tag); - + syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val); return(val); } Index: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c:1.2 --- xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c:1.1 Sat Feb 12 15:45:42 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c Mon Nov 6 14:24:09 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.1 2000/02/12 20:45:42 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.2 2000/11/06 19:24:09 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -79,6 +79,7 @@ /* pciBusPriv */ NULL }; +#if !defined(__OpenBSD__) #if X_BYTE_ORDER == X_BIG_ENDIAN #ifdef __sparc__ #ifndef ASI_PL @@ -96,6 +97,11 @@ ((val << 24) & 0xff000000)) #endif #else +#define PCI_CPU(val) (val) +#endif +#else /* ! OpenBSD */ +/* OpenBSD has already the bytes in the right order + for all architectures */ #define PCI_CPU(val) (val) #endif Index: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c:1.3 Fri Jun 30 13:15:18 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c Tue Oct 17 12:53:19 2000 @@ -20,7 +20,7 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c,v 1.3 2000/06/30 17:15:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c,v 1.4 2000/10/17 16:53:19 tsi Exp $ */ #include <fcntl.h> #include <stdio.h> @@ -550,8 +550,8 @@ fbcursor.cmap.red = zeros; fbcursor.cmap.green = zeros; fbcursor.cmap.blue = zeros; - fbcursor.image = zeros; - fbcursor.mask = zeros; + fbcursor.image = (char *)zeros; + fbcursor.mask = (char *)zeros; fbcursor.size.x = 32; fbcursor.size.y = 1; fbcursor.set = FB_CUR_SETALL; Index: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c:1.2 Tue Apr 4 15:25:19 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c Thu Nov 2 14:10:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.2 2000/04/04 19:25:19 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.3 2000/11/02 19:10:55 dawes Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -134,46 +134,5 @@ syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val); val = (val & ~mask) | (bits & mask); syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val); -} - -int sparcUseHWMulDiv(void); - -#if defined(__GNUC__) && defined(__GLIBC__) -#define HWCAP_SPARC_MULDIV 8 -extern unsigned long int _dl_hwcap; -#endif - -int -sparcUseHWMulDiv(void) -{ - FILE *f; - char buffer[1024]; - char *p; -#if defined(__GNUC__) && defined(__GLIBC__) - unsigned long *hwcap; - __asm(".weak _dl_hwcap"); - - hwcap = &_dl_hwcap; - __asm("" : "=r" (hwcap) : "0" (hwcap)); - if (hwcap) { - if (*hwcap & HWCAP_SPARC_MULDIV) - return 1; - else - return 0; - } -#endif - f = fopen("/proc/cpuinfo","r"); - if (!f) return 0; - while (fgets(buffer, 1024, f) != NULL) { - if (!strncmp (buffer, "type", 4)) { - p = strstr (buffer, "sun4"); - if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { - fclose(f); - return 1; - } - } - } - fclose(f); - return 0; } #endif /* Linux */ Index: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h diff -u xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h:1.24 xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h:1.26 --- xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h:1.24 Mon Mar 27 00:10:03 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h Tue Sep 19 08:46:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.24 2000/03/27 05:10:03 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.26 2000/09/19 12:46:21 eich Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -180,6 +180,7 @@ #define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 #define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 #define PCI_SUBCLASS_BRIDGE_MISC 0x80 +#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01 /* 0x07 communications controller subclasses */ #define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00 @@ -641,8 +642,9 @@ ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr); PCITAG pciTag(int busnum, int devnum, int funcnum); int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min); +CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg); pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, - unsigned long Base, unsigned long Size); + ADDRESS Base, unsigned long Size); int xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg, unsigned char *Buf, int Len); pciConfigPtr *xf86scanpci(int flags); Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/Imakefile:1.2 --- /dev/null Mon Dec 18 14:31:47 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/Imakefile Tue Aug 15 12:05:37 2000 @@ -0,0 +1,48 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/Imakefile,v 1.2 2000/08/15 16:05:37 dawes Exp $ + + + + +XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:58 rws $ + +#include <Server.tmpl> + +BIOS_MOD = bios_mmap + + +SRCS = cygwin_init.c ioperm_noop.c cygwin_io.c libc_wrapper.c cygwin_video.c \ + posix_tty.c stdPci.c $(BIOS_MOD).c VTsw_noop.c \ + stdResource.c sigiostubs.c std_kbdEv.c vidmem.c \ + stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c + +OBJS = cygwin_init.o ioperm_noop.o cygwin_io.o libc_wrapper.o cygwin_video.o \ + posix_tty.o stdPci.o $(BIOS_MOD).o VTsw_noop.o \ + stdResource.o sigiostubs.o std_kbdEv.o vidmem.o \ + stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o + +INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ + -I$(XINCLUDESRC) + +RESDEFINES = -DUSESTDRES +DEFINE = $(RESDEFINES) + +SubdirLibraryRule($(OBJS)) +NormalLibraryObjectRule() +NormalAsmObjectRule() + +LinkSourceFile(VTsw_noop.c,../shared) +LinkSourceFile(posix_tty.c,../shared) +LinkSourceFile(ioperm_noop.c,../shared) +LinkSourceFile(stdPci.c,../shared) +LinkSourceFile(libc_wrapper.c,../shared) +LinkSourceFile(sigiostubs.c,../shared) +LinkSourceFile(std_kbdEv.c,../shared) +LinkSourceFile(vidmem.c,../shared) +LinkSourceFile(stdResource.c,../shared) +LinkSourceFile(pm_noop.c,../shared) +LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) + + +DependTarget() + Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/bios_mmap.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/bios_mmap.c:1.1 --- /dev/null Mon Dec 18 14:31:47 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/bios_mmap.c Thu Aug 10 13:40:35 2000 @@ -0,0 +1,76 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/bios_mmap.c,v 1.1 2000/08/10 17:40:35 dawes Exp $ */ +/* + * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Robert Baron and David Wexelblat not + * be used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. Robert Baron and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * ROBERT BARON AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL ROBERT BARON OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: bios_mmap.c /main/4 1996/02/21 17:51:47 kaleb $ */ + +#include "X.h" +#include "misc.h" + +#define DevicePtr int +#include "xf86_OSlib.h" + +#define BIOS_SIZE 0x20000 +#define KERN_SUCCESS 0 + +int xf86ReadBIOS(Base, Offset, Buf, Len) +unsigned long Base; +unsigned long Offset; +unsigned char *Buf; +int Len; +{ + /*int fd; + int screen_addr; + int ret; + + if ((fd = open("/dev/zero", O_RDWR, 0)) < 0) + { + ErrorF("xf86ReadBIOS: Failed to open /dev/zero\n"); + return(-1); + } + if (KERN_SUCCESS != vm_allocate(task_self(), &screen_addr, + BIOS_SIZE, TRUE)) + { + ErrorF("xf86ReadBIOS: Failed vmallocate %x\n", BIOS_SIZE); + close(fd); + return(-1); + } + if (mmap(screen_addr, BIOS_SIZE, 3, 1, fd, Base) < 0) + { + ErrorF("xf86ReadBIOS: Failed to mmap %x at %x\n", + BIOS_SIZE, Base); + vm_deallocate(task_self(), screen_addr, BIOS_SIZE); + close(fd); + return(-1); + } + memcpy(Buf, (unsigned char *)(screen_addr + Offset), Len); + if (KERN_SUCCESS != vm_deallocate(task_self(), screen_addr, BIOS_SIZE)) + { + ErrorF("xf86ReadBIOS: Failed vmdeallocate %x\n", BIOS_SIZE); + close(fd); + return(-1); + } + close(fd);*/ + return(Len); +} Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_init.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_init.c:1.2 --- /dev/null Mon Dec 18 14:31:47 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_init.c Fri Aug 11 19:59:48 2000 @@ -0,0 +1,167 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_init.c,v 1.2 2000/08/11 23:59:48 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1999 by David Holland <davidh@iquest.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID HOLLAND, THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + * DAVID HOLLAND, THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: cygwin_init.c /main/4 1996/02/21 17:54:10 kaleb $ */ + +#include <signal.h> +#include <sys/time.h> +#include <unistd.h> + +#include "X.h" +#include "Xmd.h" + +#include "scrnintstr.h" +#include <errno.h> +#include <sys/mman.h> +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; + +static Bool Protect0 = FALSE; + + +char fb_dev[PATH_MAX] = "/dev/conin"; + +#define MAX_SECONDS 60 +#define USEC_IN_SEC (unsigned long)1000000 + + +void +xf86OpenConsole() +{ + int fd; + int i; + MessageType from = X_PROBED; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root\n"); + } + + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) + { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } + else + { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + } + close(fd); + } + } + + if (!KeepTty) + { + setpgrp(); + } + + if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0)) + { + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + fb_dev, strerror(errno)); + } + + } + return; +} + +void xf86CloseConsole() +{ + + int tmp; + + close(xf86Info.consoleFd); + + return; +} + +int xf86ProcessArgument(argc, argv, i) +int argc; +char *argv[]; +int i; +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } + /* + * Undocumented flag to protect page 0 from read/write to help + * catch NULL pointer dereferences. This is purely a debugging + * flag. + */ + if (!strcmp(argv[i], "-protect0")) + { + Protect0 = TRUE; + return(1); + } + if (!strcmp(argv[i], "-dev") && i+1 < argc) { + strncpy(fb_dev, argv[i+1], PATH_MAX); + fb_dev[PATH_MAX-1] = '\0'; + return(2); + } + + + return(0); +} + +void xf86UseMsg() +{ + ErrorF("-ar1 <float> Set autorepeat initiate time (sec)\n"); + ErrorF(" (If not using XKB)\n"); + ErrorF("-ar2 <float> Set autorepeat interval time (sec)\n"); + ErrorF(" (If not using XKB)\n"); + ErrorF("-dev <fb> FrameBuffer device\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} + Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_io.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_io.c:1.2 --- /dev/null Mon Dec 18 14:31:47 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_io.c Wed Aug 23 17:06:21 2000 @@ -0,0 +1,105 @@ +/* + * (c) Copyright 1998 by Sebastien Marineau + * <sebastien@qnx.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * SEBASTIEN MARINEAU BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Sebastien Marineau shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Sebastien Marineau. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_io.c,v 1.2 2000/08/23 21:06:21 dawes Exp $ + */ + +/* This module contains the qnx-specific functions to access the keyboard + * and the console. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> + +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <errno.h> + +#include <X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + + + +void +xf86SoundKbdBell(loudness, pitch, duration) +int loudness, pitch, duration; +{ + +/* Come back and fix! */ +ErrorF("xf86SoundKbdBell: to implement\n"); +} + +void +xf86SetKbdLeds(leds) +int leds; +{ +/* This just a dumb thing*/ + return; +} + +int +xf86GetKbdLeds() +{ + return; +} + +/* This is a no-op for now */ +void +xf86SetKbdRepeat(rad) +char rad; +{ + return; +} + + +/* This is a no-op for now */ +void +xf86KbdInit() +{ + + return; +} + + +void xf86MouseInit() +{ + return; +} + + +void xf86ProtocolIDToName() +{ + return FALSE; +} + +void OsVendorErrorFProc() +{ + return FALSE; +} + Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_video.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_video.c:1.1 --- /dev/null Mon Dec 18 14:31:48 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_video.c Thu Aug 10 13:40:36 2000 @@ -0,0 +1,165 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/cygwin_video.c,v 1.1 2000/08/10 17:40:36 dawes Exp $ */ +/* + * Copyright 1993-1999 by The XFree86 Project, Inc + * + */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" +#include <sys/mman.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" +#include "xf86_OSproc.h" + +/* + * This file contains the common part of the video memory mapping functions + */ + +/* + * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold + * the MTRR option information, but it is likely to be expanded if we do + * auto unmapping of memory at VT switch. + * + */ + +typedef struct { + unsigned long physBase; + unsigned long size; + pointer virtBase; + pointer mtrrInfo; + int flags; +} MappingRec, *MappingPtr; + +typedef struct { + int numMappings; + MappingPtr * mappings; + Bool mtrrEnabled; + MessageType mtrrFrom; + Bool mtrrOptChecked; + ScrnInfoPtr pScrn; +} VidMapRec, *VidMapPtr; + +static int vidMapIndex = -1; + +#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) + +static VidMemInfo vidMemInfo = {FALSE, }; + +static VidMapPtr +getVidMapRec(int scrnIndex) +{ + VidMapPtr vp; + + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + if (vidMapIndex < 0) + vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); + + if (VIDMAPPTR(pScrn) != NULL) + return VIDMAPPTR(pScrn); + + vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1); + vp->mtrrEnabled = TRUE; /* default to enabled */ + vp->mtrrFrom = X_DEFAULT; + vp->mtrrOptChecked = FALSE; + vp->pScrn = pScrn; + return vp; +} + +static MappingPtr +newMapping(VidMapPtr vp) +{ + vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) * + (vp->numMappings + 1)); + vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1); + return vp->mappings[vp->numMappings++]; +} + +static MappingPtr +findMapping(VidMapPtr vp, pointer vbase, unsigned long size) +{ + int i; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i]->virtBase == vbase && + vp->mappings[i]->size == size) + return vp->mappings[i]; + } + return NULL; +} + +static void +removeMapping(VidMapPtr vp, MappingPtr mp) +{ + int i, found = 0; + + for (i = 0; i < vp->numMappings; i++) { + if (vp->mappings[i] == mp) { + found = 1; + xfree(vp->mappings[i]); + } else if (found) { + vp->mappings[i - 1] = vp->mappings[i]; + } + } + vp->numMappings--; + vp->mappings[vp->numMappings] = NULL; +} + +enum { OPTION_MTRR }; +static OptionInfoRec opts[] = +{ + { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +static void +checkMtrrOption(VidMapPtr vp) +{ + if (!vp->mtrrOptChecked && vp->pScrn->options != NULL) { + /* + * We get called once for each screen, so reset + * the OptionInfoRecs. + */ + opts[0].found = FALSE; + + xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, + opts); + if (xf86GetOptValBool(opts, OPTION_MTRR, &vp->mtrrEnabled)) + vp->mtrrFrom = X_CONFIG; + vp->mtrrOptChecked = TRUE; + } +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ + /* allow interrupt disabling but check for side-effects. + * Not a good policy ... + */ + __asm__ __volatile__("sti"); + return TRUE; +} + +void xf86EnableInterrupts() +{ + /*Reenable*/ + __asm__ __volatile__ ("sti"); +} + + + +/***************************************************************************/ +/* Initialize video memory */ +/***************************************************************************/ + +void xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + return 0; +} Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/Imakefile diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/Imakefile:1.1 --- /dev/null Mon Dec 18 14:31:48 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/Imakefile Thu Aug 10 13:40:36 2000 @@ -0,0 +1,110 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/Imakefile,v 1.1 2000/08/10 17:40:36 dawes Exp $ + +#define IHaveModules + +#include <Server.tmpl> + +SRCS1 = pci.c xf86int10module.c helper_exec.c helper_mem.c xf86int10.c +OBJS1 = pci.o xf86int10module.o helper_exec.o helper_mem.o xf86int10.o + +LinkSourceFile(helper_mem.c,$(XF86SRC)/int10) +LinkSourceFile(helper_exec.c,$(XF86SRC)/int10) +LinkSourceFile(xf86int10.c,$(XF86SRC)/int10) +LinkSourceFile(pci.c,$(XF86SRC)/int10) +LinkSourceFile(xf86int10module.c,$(XF86SRC)/int10) +LinkSourceFile(xf86x86emu.c,$(XF86SRC)/int10) +LinkSourceFile(generic.c,$(XF86SRC)/int10) + +INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \ + -I$(XF86OSSRC) \ + -I$(SERVERSRC)/include -I$(XINCLUDESRC) + +DEFINES=-DHAVE_SYSV_IPC + +#if 0 +/* debugging stuff */ +#DEFINES =-D_PC +#undef XF86INT10_BUILD +#define XF86INT10_BUILD X86EMU_GENERIC +#define X86EMU_LIBPATH /usr/local/lib +#endif + +#if defined(i386Architecture) +DEFINES =-D_PC +#endif + +/* XXX keep this temporarily for reference */ +#if 0 +#if (XF86INT10_BUILD == X86EMU_GENERIC) + +SRCS = $(SRCS1) xf86x86emu.c generic.c +OBJS = $(OBJS1) xf86x86emu.o generic.o x86emu.o +SpecialObjectRule(pci.o, pci.c, -D_X86EMU) +SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU) +SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES) +SpecialObjectRule(generic.o, generic.c, -D_X86EMU) +SpecialObjectRule(xf86x86emu.o, xf86x86emu.c, -D_X86EMU) +BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu) +#endif +#endif + +#if defined(XF86INT10_BUILD) && (XF86INT10_BUILD == X86VM) + +SRCS = $(SRCS1) linux.c +OBJS = $(OBJS1) linux.o +SpecialObjectRule(pci.o, pci.c, -D_VM86_LINUX) +SpecialObjectRule(helper_exec.o, helper_exec.c, -D_VM86_LINUX) +SpecialObjectRule(xf86int10.o, xf86int10.c, -D_VM86_LINUX -DSHOW_ALL_DEVICES) +SpecialObjectRule(linux.o, linux.c, -D_VM86_LINUX -DHAVE_SYSV_IPC) + +#elif (XF86INT10_BUILD == X86EMU_OS) + +SpecialObjectRule(pci.o, pci.c, -D_X86EMU) +SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU) +SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES) +SpecialObjectRule(linux.o, linux.c, -D_X86EMU -DHAVE_SYSV_IPC) + +X86TOPDIR = $(TOP)/extras/x86emu +X86SRCDIR = $(X86TOPDIR)/src/x86emu +X86EMUINCLUDES = -I$(X86TOPDIR)/include -I$(X86SRCDIR) + +# if !defined(X86EMU_LIBPATH) +X86EMUSRCS = debug.c decode.c fpu.c ops.c ops2.c prim_ops.c sys.c +X86EMUOBJS = debug.o decode.o fpu.o ops.o ops2.o prim_ops.o sys.o + +LinkSourceFile(debug.c,$(X86SRCDIR)) +LinkSourceFile(decode.c,$(X86SRCDIR)) +LinkSourceFile(fpu.c,$(X86SRCDIR)) +LinkSourceFile(ops.c,$(X86SRCDIR)) +LinkSourceFile(ops2.c,$(X86SRCDIR)) +LinkSourceFile(prim_ops.c,$(X86SRCDIR)) +LinkSourceFile(sys.c,$(X86SRCDIR)) +# else +BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu) +X86EMUOBJS = x86emu.o +# endif + +SRCS = $(SRCS1) xf86x86emu.c linux.c $(X86EMUSRCS) +OBJS = $(OBJS1) xf86x86emu.o linux.o $(X86EMUOBJS) + +#endif + +#if defined(XF86INT10_BUILD) && XF86INT10_BUILD > X86EMU_GENERIC + +LibraryModuleTarget(int10, $(OBJS)) + +InstallLibraryModule(int10,$(MODULEDIR),linux) + +all:: + (set -x; cd ../..; \ + RemoveFile(LibraryTargetName(int10)); \ + $(LN) linux/int10/LibraryTargetName(int10) . ) + +InstallDriverSDKLibraryModule(int10,$(DRIVERSDKMODULEDIR),.) + +InstallDriverSDKNonExecFile(../../int10/xf86int10.h,$(DRIVERSDKINCLUDEDIR)) + +#endif + +DependTarget() + Index: xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/os2.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/os2.c:1.1 --- /dev/null Mon Dec 18 14:31:48 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/os2.c Thu Aug 10 13:40:36 2000 @@ -0,0 +1,451 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/cygwin/int10/os2.c,v 1.1 2000/08/10 17:40:36 dawes Exp $ */ +/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + */ +#include "xf86.h" +#include "xf86str.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "xf86int10.h" +#include "int10Defines.h" + +static CARD8 read_b(xf86Int10InfoPtr pInt,int addr); +static CARD16 read_w(xf86Int10InfoPtr pInt,int addr); +static CARD32 read_l(xf86Int10InfoPtr pInt,int addr); +static void write_b(xf86Int10InfoPtr pInt,int addr, CARD8 val); +static void write_w(xf86Int10InfoPtr pInt,int addr, CARD16 val); +static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val); + +/* + * the emulator cannot pass a pointer to the current xf86Int10InfoRec + * to the memory access functions therefore store it here. + */ + +typedef struct { + int shift; + int pagesize_1; + int entries; + void* vRam; + memType *alloc_rec; +} genericInt10Priv; + +#define INTPriv(x) ((genericInt10Priv*)x->private) + +int10MemRec genericMem = { + read_b, + read_w, + read_l, + write_b, + write_w, + write_l +}; + +static void MapVRam(xf86Int10InfoPtr pInt); +static void UnmapVRam(xf86Int10InfoPtr pInt); +static void setupTable(xf86Int10InfoPtr pInt, memType address, + int loc,int size); + +static void *sysMem = NULL; + +xf86Int10InfoPtr +xf86InitInt10(int entityIndex) +{ + xf86Int10InfoPtr pInt; + int screen; + void* intMem; + void* vbiosMem; + int pagesize; + int entries; + int shift; + legacyVGARec vga; + + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; + + if (int10skip(xf86Screens[screen],entityIndex)) + return NULL; + + pInt = (xf86Int10InfoPtr)xnfcalloc(1,sizeof(xf86Int10InfoRec)); + pInt->entityIndex = entityIndex; + if (!xf86Int10ExecSetup(pInt)) + goto error0; + pInt->mem = &genericMem; + pagesize = xf86getpagesize(); + pInt->private = (pointer)xnfcalloc(1,sizeof(genericInt10Priv)); + entries = SYS_SIZE / pagesize; + + pInt->scrnIndex = screen; + INTPriv(pInt)->pagesize_1 = pagesize - 1; + INTPriv(pInt)->entries = entries; + INTPriv(pInt)->alloc_rec = + xnfcalloc(1,sizeof(memType) * entries); + for (shift = 0 ; (pagesize >> shift) ; shift++) {}; + shift -= 1; + INTPriv(pInt)->shift = shift; + + /* + * we need to map video RAM MMIO as some chipsets map mmio + * registers into this range. + */ + + MapVRam(pInt); + intMem = xnfalloc(pagesize); + setupTable(pInt,(memType)intMem,0,pagesize); + vbiosMem = xnfalloc(V_BIOS_SIZE); + +#ifdef _PC + if (!sysMem) + sysMem = xf86MapVidMem(screen,VIDMEM_FRAMEBUFFER,SYS_BIOS,BIOS_SIZE); + setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE); + if (xf86ReadBIOS(0,0,(unsigned char *)intMem,LOW_PAGE_SIZE) < 0) { + xf86DrvMsg(screen,X_ERROR,"Cannot read int vect\n"); + goto error1; + } + if (xf86IsEntityPrimary(entityIndex)) { + int size; + int cs = MEM_RW(pInt,((0x10<<2)+2)); + +int i,k,m; +char buf[100], hx[10]; +for (i=0; i<0x100; i+=16) { +sprintf(buf,"%04x: ",i); +for (k=0; k<16; k++) { + m = MEM_RB(pInt,i+k); + sprintf(hx,"%02x ",((unsigned)m)&0xff); + strcat(buf,hx); +} +xf86DrvMsg(screen,X_INFO,"%s\n",buf); +} + + + + xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segmant is: 0x%x\n",cs); + if (xf86ReadBIOS(cs << 4,0,(unsigned char *)vbiosMem, + 0x10) < 0) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (1)\n"); + goto error1; + } + if (!((*(CARD8*)vbiosMem == 0x55) + && (*((CARD8*)vbiosMem + 1) == 0xAA))) { + xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n"); + goto error1; + } + + size = *((CARD8*)vbiosMem + 2) * 512; + if (xf86ReadBIOS(cs << 4,0,vbiosMem, size) < 0) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (2)\n"); + goto error1; + } + if (bios_checksum(vbiosMem,size)) { + xf86DrvMsg(screen,X_ERROR,"Bad checksum of V_BIOS \n"); + goto error1; + } + + setupTable(pInt,(memType)vbiosMem,cs<<4,size); + set_return_trap(pInt); + pInt->BIOSseg = cs; + } else { + reset_int_vect(pInt); + set_return_trap(pInt); + if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3)\n"); + goto error1; + } + setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE); + pInt->BIOSseg = V_BIOS >> 4; + pInt->num = 0xe6; + LockLegacyVGA(screen, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(screen, &vga); + } +#else + if (!sysMem) { + sysMem = xnfalloc(BIOS_SIZE); + setup_system_bios((memType)sysMem); + } + setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE); + setup_int_vect(pInt); + set_return_trap(pInt); + if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) { + xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n"); + goto error1; + } + setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE); + pInt->BIOSseg = V_BIOS >> 4; + pInt->num = 0xe6; + LockLegacyVGA(screen, &vga); + xf86ExecX86int10(pInt); + UnlockLegacyVGA(screen, &vga); +#endif + return pInt; + + error1: + xfree(vbiosMem); + xfree(intMem); + UnmapVRam(pInt); + xfree(INTPriv(pInt)->alloc_rec); + xfree(pInt->private); + error0: + xfree(pInt); + + return NULL; +} + +static void +MapVRam(xf86Int10InfoPtr pInt) +{ + int screen = pInt->scrnIndex; + int pagesize = INTPriv(pInt)->pagesize_1 + 1; + int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; + INTPriv(pInt)->vRam = xf86MapVidMem(screen,VIDMEM_MMIO,V_RAM,size); +} + +static void +UnmapVRam(xf86Int10InfoPtr pInt) +{ + int screen = pInt->scrnIndex; + int pagesize = INTPriv(pInt)->pagesize_1 + 1; + int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize; + + xf86UnMapVidMem(screen,INTPriv(pInt)->vRam,size); +} + +void +MapCurrentInt10(xf86Int10InfoPtr pInt) +{ + /* nothing to do here */ +} + +void +xf86FreeInt10(xf86Int10InfoPtr pInt) +{ + int pagesize; + + if (!pInt) + return; + pagesize = INTPriv(pInt)->pagesize_1 + 1; + if (Int10Current == pInt) + Int10Current = NULL; + xfree(INTPriv(pInt)->alloc_rec[V_BIOS/pagesize]); + xfree(INTPriv(pInt)->alloc_rec[0]); + UnmapVRam(pInt); + xfree(INTPriv(pInt)->alloc_rec); + xfree(pInt->private); + xfree(pInt); +} + +void * +xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off) +{ + void* addr; + int pagesize = INTPriv(pInt)->pagesize_1 + 1; + int num_pages = INTPriv(pInt)->entries; + int i,j; + + for (i=0;i<num_pages - num;i++) { + if (INTPriv(pInt)->alloc_rec[i] == 0) { + for (j=i;j < num + i;j++) + if ((INTPriv(pInt)->alloc_rec[j] != 0)) + break; + if (j == num + i) + break; + else + i = i + num; + } + } + if (i == num_pages - num) + return NULL; + + *off = i * pagesize; + addr = xnfalloc(pagesize * num); + setupTable(pInt,(memType)addr,*off,pagesize * num); + + return addr; +} + +void +xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) +{ + int num_pages = INTPriv(pInt)->entries; + int i,j; + for (i = 0;i<num_pages - num; i++) + if (INTPriv(pInt)->alloc_rec[i]==(memType)pbase) { + for (j = 0; j < num; j++) + INTPriv(pInt)->alloc_rec[i] = 0; + break; + } + xfree(pbase); + return; +} + +static void +setupTable(xf86Int10InfoPtr pInt, memType address,int loc,int size) +{ + int pagesize = INTPriv(pInt)->pagesize_1 + 1; + int i,j,num; + + i = loc / pagesize; + num = (size + pagesize - 1)/ pagesize; /* round up to the nearest page */ + /* boudary if size is not */ + /* multiple of pagesize */ + for (j = 0; j<num; j++) { + INTPriv(pInt)->alloc_rec[i+j] = address; + address += pagesize; + } +} + +#define OFF(addr) \ + ((addr) & (INTPriv(pInt)->pagesize_1)) +#define SHIFT \ + (INTPriv(pInt)->shift) +#define BASE(addr,shift) \ + (INTPriv(pInt)->alloc_rec[addr >> shift]) +#define V_ADDR(addr,shift,off) \ + (BASE(addr,shift) + (off)) +#define VRAM_ADDR(addr) (addr - 0xA0000) +#define VRAM_BASE (INTPriv(pInt)->vRam) + +#define VRAM(addr) ((addr >= 0xA0000) && (addr <= 0xBFFFF)) +#define V_ADDR_RB(addr,shift,off) \ + (VRAM(addr)) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR(addr)) \ + : *(CARD8*) V_ADDR(addr,shift,off) +#define V_ADDR_RW(addr,shift,off) \ + (VRAM(addr)) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR(addr)) \ + : ldw_u((pointer)V_ADDR(addr,shift,off)) +#define V_ADDR_RL(addr,shift,off) \ + (VRAM(addr)) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR(addr)) \ + : ldl_u((pointer)V_ADDR(addr,shift,off)) + +#define V_ADDR_WB(addr,shift,off,val) \ + if(VRAM(addr)) \ + MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + *(CARD8*) V_ADDR(addr,shift,off) = val; +#define V_ADDR_WW(addr,shift,off,val) \ + if(VRAM(addr)) \ + MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + stw_u((val),(pointer)(V_ADDR(addr,shift,off))); + +#define V_ADDR_WL(addr,shift,off,val) \ + if (VRAM(addr)) \ + MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR(addr),val); \ + else \ + stl_u(val,(pointer)(V_ADDR(addr,shift,off))); + +static CARD8 +read_b(xf86Int10InfoPtr pInt, int addr) +{ + if (!BASE(addr,SHIFT)) return 0xff; + + return V_ADDR_RB(addr,SHIFT,OFF(addr)); +} + +static CARD16 +read_w(xf86Int10InfoPtr pInt, int addr) +{ + int shift = SHIFT; + int off = OFF(addr); + + if (!BASE(addr,shift)) return 0xffff; + +#if X_BYTE_ORDER == X_BIG_ENDIAN + return ((V_ADDR_RB(addr,shift,off)) + || ((V_ADDR_RB(addr,shift,off + 1)) << 8)); +#else + if (OFF(addr + 1) > 0) { + return V_ADDR_RW(addr,SHIFT,OFF(addr)); + } else { + return ((V_ADDR_RB(addr,shift,off + 1)) + || ((V_ADDR_RB(addr,shift,off)) << 8)); + } +#endif +} + +static CARD32 +read_l(xf86Int10InfoPtr pInt, int addr) +{ + int shift = SHIFT; + int off = OFF(addr); + + if (!BASE(addr,shift)) return 0xffffffff; + +#if X_BYTE_ORDER == X_BIG_ENDIAN + return ((V_ADDR_RB(addr,shift,off)) + || ((V_ADDR_RB(addr,shift,off + 1)) << 8) + || ((V_ADDR_RB(addr,shift,off + 2)) << 16) + || ((V_ADDR_RB(addr,shift,off + 3)) << 24)); +#else + if (OFF(addr + 3) > 2) { + return V_ADDR_RL(addr,SHIFT,OFF(addr)); + } else { + return ((V_ADDR_RB(addr,shift,off + 3)) + || ((V_ADDR_RB(addr,shift,off + 2)) << 8) + || ((V_ADDR_RB(addr,shift,off + 1)) << 16) + || ((V_ADDR_RB(addr,shift,off)) << 24)); + } +#endif +} + +static void +write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val) +{ + if (!BASE(addr,SHIFT)) return; + + V_ADDR_WB(addr,SHIFT,OFF(addr),val); +} + +static void +write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val) +{ + int shift = SHIFT; + int off = OFF(addr); + + if (!BASE(addr,shift)) return; + +#if X_BYTE_ORDER == X_BIG_ENDIAN + V_ADDR_WB(addr,shift,off,val); + V_ADDR_WB(addr,shift,off + 1,val >> 8); +#else + if (OFF(addr + 1) > 0) { + V_ADDR_WW(addr,shift,OFF(addr),val); + } else { + V_ADDR_WB(addr,shift,off + 1,val); + V_ADDR_WB(addr,shift,off,val >> 8); + } +#endif +} + +static void +write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val) +{ + int shift = SHIFT; + int off = OFF(addr); + if (!BASE(addr,shift)) return; + +#if X_BYTE_ORDER == X_BIG_ENDIAN + V_ADDR_WB(addr,shift,off,val); + V_ADDR_WB(addr,shift,off + 1, val >> 8); + V_ADDR_WB(addr,shift,off + 2, val >> 16); + V_ADDR_WB(addr,shift,off + 3, val >> 24); +#else + if (OFF(addr + 3) > 2) { + V_ADDR_WL(addr,shift,OFF(addr),val); + } else { + V_ADDR_WB(addr,shift,off + 3, val); + V_ADDR_WB(addr,shift,off + 2, val >> 8); + V_ADDR_WB(addr,shift,off + 1, val >> 16); + V_ADDR_WB(addr,shift,off, val >> 24); + } +#endif +} + +pointer +xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) +{ + return (pointer) V_ADDR(addr,SHIFT,OFF(addr)); +} Index: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile:1.6 xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile:1.6 Fri Jun 16 20:03:33 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile Tue Aug 15 12:05:37 2000 @@ -1,15 +1,15 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile,v 1.6 2000/06/17 00:03:33 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile,v 1.7 2000/08/15 16:05:37 dawes Exp $ #include <Server.tmpl> BIOS_MOD = bios_DGmmap SRCS = dgux_init.c dgux_video.c IO_utils.c dgux_io.c $(BIOS_MOD).c VTsw_noop.c \ dgux_kbd.c dgux_kbdEv.c dgux_tty.c std_mouse.c std_mseEv.c \ - stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c + stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c OBJS = dgux_init.o dgux_video.o IO_utils.o dgux_io.o $(BIOS_MOD).o VTsw_noop.o \ dgux_kbd.o dgux_kbdEv.o dgux_tty.o std_mouse.o std_mseEv.o \ - stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o + stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) @@ -30,5 +30,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c diff -u xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c:1.3 Fri Feb 11 17:36:02 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c Sun Nov 19 11:38:06 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c,v 1.3 2000/02/11 22:36:02 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c,v 1.4 2000/11/19 16:38:06 tsi Exp $ */ /* * INTEL DG/UX RELEASE 4.20 MU03 * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK @@ -48,8 +48,9 @@ return(-1); } psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); - /* Base is assumed to be page-aligned. */ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, fd, (off_t)Base); if ((int)ptr == -1) Index: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c:1.5 xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c:1.5 Tue Jun 27 10:27:29 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c Mon Jul 10 21:46:37 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c,v 1.5 2000/06/27 14:27:29 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c,v 1.6 2000/07/11 01:46:37 tsi Exp $ */ /* * INTEL DG/UX RELEASE 4.20 MU03 * Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK @@ -82,32 +82,12 @@ return(TRUE); } - - -pointer AllocAddress[MAXSCREENS][NUM_REGIONS]; -#ifndef SVR4 -static int mmapFd = -2; -#endif - - - -#if 0 -/* For DGA support?? */ -static struct xf86memMap { - int offset; - int memSize; -} xf86memMaps[MAXSCREENS]; -#endif - - - pointer xf86MapVidMem(int ScreenNum, int Region, unsigned long Base, unsigned long Size) { pointer base; int fd; -#if defined(DGUX) if ((fd = open(DEV_MEM, O_RDWR)) < 0) { FatalError("xf86MapVidMem: failed to open %s (%s)\n", @@ -121,76 +101,9 @@ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", "xf86MapVidMem", Size, Base, strerror(errno)); } -#else /* HAS SVR#_MMAPDRV */ -#ifdef HAS_SVR3_MMAPDRV - if (mmapFd == -2) - { - mmapFd = open("/dev/mmap", O_RDWR); - } -#endif - if (mmapFd >= 0) - { - /* To force the MMAP driver to provide the address */ - base = (pointer)0; - } - else - { - AllocAddress[ScreenNum][Region] = xalloc(Size + 0x1000); - if (AllocAddress[ScreenNum][Region] == (pointer)0) - { - FatalError("xf86MapVidMem: can't alloc framebuffer space\n"); - /* NOTREACHED */ - } - base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region] - & ~0xFFF) + 0x1000); - } - - -#ifdef HAS_SVR3_MMAPDRV - if(mmapFd >= 0) - { - if((base = (pointer)ioctl(mmapFd, MAP, - &(MapDSC[ScreenNum][Region]))) == MAP_FAILED) - { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - /* NOTREACHED */ - } -#if 0 -/* inserted for DGA support */ - xf86memMaps[ScreenNum].offset = Base; - xf86memMaps[ScreenNum].memSize = Size; -#endif - return((pointer)base); - } -#endif -#endif /* DGUX */ -#if 0 - xf86memMaps[ScreenNum].offset = Base; - xf86memMaps[ScreenNum].memSize = Size; -#endif return(base); } - - - - - - -#if 0 -void xf86GetVidMemData(ScreenNum, Base, Size) -int ScreenNum; -int *Base; -int *Size; -{ - *Base = xf86memMaps[ScreenNum].offset; - *Size = xf86memMaps[ScreenNum].memSize; -} -#endif - - - void xf86UnMapVidMem(ScreenNum, Region, Base, Size) int ScreenNum; Index: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile:1.11 xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile:1.13 --- xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile:1.11 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile Tue Nov 14 13:20:37 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile,v 1.11 2000/06/27 14:27:30 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile,v 1.13 2000/11/14 18:20:37 dawes Exp $ #include <Server.tmpl> @@ -8,12 +8,12 @@ MOUSEOBJ = hurd_mouse.o SRCS = hurd_init.c hurd_video.c hurd_io.c libc_wrapper.c $(BIOS_MOD).c \ - VTsw_noop.c posix_tty.c std_kbdEv.c $(MOUSESRC) \ - stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c + VTsw_noop.c posix_tty.c $(MOUSESRC) \ + stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c OBJS = hurd_init.o hurd_video.o hurd_io.o libc_wrapper.o $(BIOS_MOD).o \ - VTsw_noop.o posix_tty.o std_kbdEv.o $(MOUSEOBJ) \ - stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o + VTsw_noop.o posix_tty.o $(MOUSEOBJ) \ + stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi @@ -28,13 +28,13 @@ LinkSourceFile(VTsw_noop.c,../shared) LinkSourceFile(posix_tty.c,../shared) -LinkSourceFile(std_kbdEv.c,../shared) LinkSourceFile(libc_wrapper.c,../shared) LinkSourceFile(stdResource.c,../shared) LinkSourceFile(stdPci.c,../shared) LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c:1.6 Sat Sep 4 09:04:43 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c Tue Nov 14 13:20:37 2000 @@ -20,7 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c,v 1.6 1999/09/04 13:04:43 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c,v 1.7 2000/11/14 18:20:37 dawes Exp $ */ #define NEED_EVENTS #include "X.h" @@ -116,4 +116,12 @@ int data = 2; if( ioctl( xf86Info.consoleFd, _IOW('k', 1, int),&data) < 0) FatalError("can't reset keyboard mode (%s)\n",strerror(errno)); +} + +void +xf86KbdEvents() +{ + kd_event ke; + while( read(xf86Info.consoleFd, &ke, sizeof(ke)) == sizeof(ke) ) + xf86PostKbdEvent(ke.value.sc); } Index: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c diff -u xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c:1.7 Thu Feb 10 17:33:44 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c Tue Nov 14 13:20:37 2000 @@ -20,7 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c,v 1.7 2000/02/10 22:33:44 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c,v 1.8 2000/11/14 18:20:37 dawes Exp $ */ #define NEED_EVENTS #include "X.h" @@ -168,7 +168,7 @@ pBuf = (unsigned char *)eventList; n = 0; while ((c = XisbRead(pMse->buffer)) >= 0 && n < sizeof(eventList)) - pBuf[n] = (unsigned char)c; + pBuf[n++] = (unsigned char)c; if (n == 0) return; @@ -289,7 +289,7 @@ p->BuiltinNames = BuiltinNames; p->DefaultProtocol = DefaultProtocol; p->CheckProtocol = CheckProtocol; - p->PreInit = OSMousePreInit; + p->PreInit = OsMousePreInit; return p; } Index: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c:1.3 Thu Apr 29 08:24:52 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c Tue Nov 14 13:20:37 2000 @@ -20,7 +20,7 @@ * PERFORMANCE OF THIS SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c,v 1.3 1999/04/29 12:24:52 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c,v 1.4 2000/11/14 18:20:37 dawes Exp $ */ #include <mach.h> #include <device/device.h> @@ -167,5 +167,11 @@ xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, unsigned long Size) { +} + +Bool +xf86CheckMTRR(int s) +{ + return FALSE; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile:3.41 xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile:3.43 --- xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile:3.41 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile Thu Nov 16 14:45:03 2000 @@ -1,5 +1,5 @@ XCOMM $XConsortium: Imakefile /main/10 1996/10/19 18:06:19 kaleb $ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v 3.41 2000/06/27 14:27:30 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v 3.43 2000/11/16 19:45:03 eich Exp $ #include <Server.tmpl> @@ -35,22 +35,22 @@ #endif #if defined(AlphaArchitecture) -AXP_SRC=lnx_ev56.c -AXP_OBJ=lnx_ev56.o +AXP_SRC=lnx_ev56.c xf86Axp.c lnx_axp.c +AXP_OBJ=lnx_ev56.o xf86Axp.o lnx_axp.o #endif SRCS = lnx_init.c lnx_video.c lnx_io.c libc_wrapper.c bios_mmap.c \ VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \ lnx_pci.c vidmem.c lnx_apm.c $(JOYSTICK_SRC) $(DRI_SRC) $(RES_SRCS) \ - $(AXP_SRC) lnx_kmod.c + $(AXP_SRC) lnx_kmod.c lnx_agp.c OBJS = lnx_init.o lnx_video.o lnx_io.o libc_wrapper.o bios_mmap.o \ VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \ lnx_pci.o vidmem.o lnx_apm.o $(JOYSTICK_OBJ) $(DRI_OBJ) $(RES_OBJS) \ - $(AXP_OBJ) lnx_kmod.o + $(AXP_OBJ) lnx_kmod.o lnx_agp.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) -I$(EXTINCSRC) + -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(XF86OSSRC)/shared RESDEFINES = -DUSESTDRES @@ -106,7 +106,9 @@ #if defined(i386Architecture) || defined(ia64Architecture) LinkSourceFile(stdResource.c,../shared) #endif - +#if defined(AlphaArchitecture) +LinkSourceFile(xf86Axp.c,../shared) +#endif DependTarget() InstallDriverSDKNonExecFile(agpgart.h,$(DRIVERSDKINCLUDEDIR)/linux) Index: xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h:1.3 Fri Jun 16 20:03:33 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h Sat Aug 26 00:30:56 2000 @@ -23,7 +23,7 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h,v 1.3 2000/06/17 00:03:33 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h,v 1.4 2000/08/26 04:30:56 dawes Exp $ */ #ifndef _AGP_H #define _AGP_H 1 @@ -53,6 +53,7 @@ #ifndef __KERNEL__ #include <linux/types.h> #include <asm/types.h> +#include <sys/types.h> typedef struct _agp_version { __u16 major; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c:3.9 xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c:3.11 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c:3.9 Mon Jun 12 22:28:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c Tue Oct 17 12:53:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.9 2000/06/13 02:28:36 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.11 2000/10/17 16:53:20 tsi Exp $ */ /* Resource information code */ @@ -104,10 +104,10 @@ RANGE(range,0xF9000000,0xffffffff,ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); } else { - RANGE(range,0,0xffffffff,ResExcMemBlock); + /* Some drivers choke if a PCI base address is set to 0 */ + RANGE(range,1,0xffffffff,ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); } - RANGE(range,0,0xffffffff,ResExcIoBlock); ret = xf86AddResToList(ret, &range, -1); return ret; @@ -156,7 +156,11 @@ * for now until we get something better. */ +#ifdef __sparc__ +resRange PciAvoid[] = {_END}; +#else resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END}; +#endif resPtr xf86BusAccWindowsFromOS(void) @@ -167,7 +171,11 @@ RANGE(range,0,0xffffffff,ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); +#ifdef __sparc__ + RANGE(range,0,0x00ffffff,ResExcIoBlock); +#else RANGE(range,0,0x0000ffff,ResExcIoBlock); +#endif ret = xf86AddResToList(ret, &range, -1); return ret; } @@ -181,7 +189,11 @@ RANGE(range,0,0xffffffff,ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); +#ifdef __sparc__ + RANGE(range,0,0x00ffffff,ResExcIoBlock); +#else RANGE(range,0,0x0000ffff,ResExcIoBlock); +#endif ret = xf86AddResToList(ret, &range, -1); return ret; } @@ -195,7 +207,11 @@ RANGE(range,0,0xffffffff,ResExcMemBlock); ret = xf86AddResToList(ret, &range, -1); +#ifdef __sparc__ + RANGE(range,0,0x00ffffff,ResExcIoBlock); +#else RANGE(range,0,0x0000ffff,ResExcIoBlock); +#endif ret = xf86AddResToList(ret, &range, -1); return ret; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c:3.4 --- /dev/null Mon Dec 18 14:31:49 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c Mon Aug 28 14:12:56 2000 @@ -0,0 +1,300 @@ +/* + * Abstraction of the AGP GART interface. + * + * This version is for both Linux and FreeBSD. + * + * Copyright © 2000 VA Linux Systems, Inc. + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.4 2000/08/28 18:12:56 dawes Exp $ */ + +#include "X.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(linux) +#include <asm/ioctl.h> +#include <linux/agpgart.h> +#elif defined(__FreeBSD__) +#include <sys/ioctl.h> +#include <sys/agpio.h> +#endif + +#ifndef AGP_DEVICE +#define AGP_DEVICE "/dev/agpgart" +#endif +/* AGP page size is independent of the host page size. */ +#ifndef AGP_PAGE_SIZE +#define AGP_PAGE_SIZE 4096 +#endif +#define AGPGART_MAJOR_VERSION 0 +#define AGPGART_MINOR_VERSION 99 + +static int gartFd = -1; +static int acquiredScreen = -1; + +/* + * Open /dev/agpgart. Keep it open until server exit. + */ + +static Bool +GARTInit() +{ + static Bool initDone = FALSE; + struct _agp_info agpinf; + + if (initDone) + return (gartFd != -1); + + initDone = TRUE; + + if (gartFd == -1) + gartFd = open(AGP_DEVICE, O_RDWR, 0); + else + return FALSE; + + if (gartFd == -1) { + xf86Msg(X_ERROR, "Unable to open " AGP_DEVICE " (%s)\n", + strerror(errno)); + return FALSE; + } + + xf86AcquireGART(-1); + /* Check the kernel driver version. */ + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86Msg(X_ERROR, "GARTInit: AGPIOC_INFO failed (%s)\n", + strerror(errno)); + close(gartFd); + gartFd = -1; + return FALSE; + } + xf86ReleaseGART(-1); + +#if defined(linux) + /* Should this look for version >= rather than version == ? */ + if (agpinf.version.major != AGPGART_MAJOR_VERSION && + agpinf.version.minor != AGPGART_MINOR_VERSION) { + xf86Msg(X_ERROR, + "Kernel agpgart driver version is not current" + " (%d.%d vs %d.%d)\n", + agpinf.version.major, agpinf.version.minor, + AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION); + close(gartFd); + gartFd = -1; + return FALSE; + } +#endif + + return TRUE; +} + +Bool +xf86AgpGARTSupported() +{ + return GARTInit(); +} + +AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + struct _agp_info agpinf; + AgpInfoPtr info; + + if (!GARTInit()) + return NULL; + + + if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { + xf86DrvMsg(screenNum, X_ERROR, "Failed to allocate AgpInfo\n"); + return NULL; + } + + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", + strerror(errno)); + return NULL; + } + + info->bridgeId = agpinf.bridge_id; + info->agpMode = agpinf.agp_mode; + info->base = agpinf.aper_base; + info->size = agpinf.aper_size; + info->totalPages = agpinf.pg_total; + info->systemPages = agpinf.pg_system; + info->usedPages = agpinf.pg_used; + + return info; +} + +/* + * XXX If multiple screens can acquire the GART, should we have a reference + * count instead of using acquiredScreen? + */ + +Bool +xf86AcquireGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit()) + return FALSE; + + if (screenNum == -1 || acquiredScreen != screenNum) { + if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "AGPIOC_ACQUIRE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = screenNum; + } + return TRUE; +} + +Bool +xf86ReleaseGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit()) + return FALSE; + + if (acquiredScreen == screenNum) { + if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "AGPIOC_RELEASE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = -1; + return TRUE; + } + return FALSE; +} + +int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + struct _agp_allocate alloc; + int pages; + + /* + * Allocates "size" bytes of GART memory (rounds up to the next + * page multiple) or type "type". A handle (key) for the allocated + * memory is returned. On error, the return value is -1. + */ + + if (!GARTInit() || acquiredScreen != screenNum) + return -1; + + pages = (size / AGP_PAGE_SIZE); + if (size % AGP_PAGE_SIZE != 0) + pages++; + + /* XXX check for pages == 0? */ + + alloc.pg_count = pages; + alloc.type = type; + + if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " + "allocation of %d pages failed\n\t(%s)\n", pages, + strerror(errno)); + return -1; + } + + if (physical) + *physical = alloc.physical; + + return alloc.key; +} + + +/* Bind GART memory with "key" at "offset" */ +Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + struct _agp_bind bind; + int pageOffset; + + if (!GARTInit() || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "AGP not acquired by this screen\n"); + return FALSE; + } + + if (offset % AGP_PAGE_SIZE != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "offset (0x%x) is not page-aligned (%d)\n", + offset, AGP_PAGE_SIZE); + return FALSE; + } + pageOffset = offset / AGP_PAGE_SIZE; + + bind.pg_start = pageOffset; + bind.key = key; + + if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "binding of gart memory with key %d\n" + "\tat offset 0x%x failed (%s)\n", + key, offset, strerror(errno)); + return FALSE; + } + + return TRUE; +} + + +/* Unbind GART memory with "key" */ +Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + struct _agp_unbind unbind; + + if (!GARTInit() || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "AGP not acquired by this screen\n"); + return FALSE; + } + + unbind.priority = 0; + unbind.key = key; + + if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " + "unbinding of gart memory with key %d " + "failed (%s)\n", key, strerror(errno)); + return FALSE; + } + + return TRUE; +} + + +/* XXX Interface may change. */ +Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + agp_setup setup; + + if (!GARTInit() || acquiredScreen != screenNum) + return FALSE; + + setup.agp_mode = mode; + if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " + "AGPIOC_SETUP with mode %d failed (%s)\n", + mode, strerror(errno)); + return FALSE; + } + + return TRUE; +} + Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c:3.6 xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c:3.9 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c:3.6 Fri Mar 31 17:55:52 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c Fri Dec 8 15:13:37 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.6 2000/03/31 22:55:52 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.9 2000/12/08 20:13:37 eich Exp $ */ #include "X.h" #include "os.h" @@ -66,15 +66,7 @@ { int i,j,n; apm_event_t linuxEvents[8]; -#if 0 - if (wait) { - FD_ZERO( &fds ); - FD_SET( fd, &fds ); - ret = select( fd + 1, &fds, NULL, NULL, NULL ); - if (ret <= 0) - return 0; - } -#endif + if ((n = read( fd, linuxEvents, num * sizeof(apm_event_t) )) == -1) return 0; n /= sizeof(apm_event_t); @@ -98,13 +90,15 @@ switch (event) { case XF86_APM_SYS_STANDBY: case XF86_APM_USER_STANDBY: - ioctl( fd, APM_IOC_STANDBY, NULL ); - return PM_CONTINUE; + (void) ioctl( fd, APM_IOC_STANDBY, NULL ); + return PM_NONE; case XF86_APM_SYS_SUSPEND: case XF86_APM_CRITICAL_SUSPEND: case XF86_APM_USER_SUSPEND: - ioctl( fd, APM_IOC_SUSPEND, NULL ); - return PM_CONTINUE; + if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_WAIT; + else + return PM_NONE; case XF86_APM_STANDBY_RESUME: case XF86_APM_NORMAL_RESUME: case XF86_APM_CRITICAL_RESUME: @@ -121,19 +115,28 @@ { int fd; +#ifdef DEBUG + ErrorF("APM: OSPMOpen called\n"); +#endif if (APMihPtr || !xf86Info.pmFlag) return NULL; - if (access( APM_PROC, R_OK ) || ((fd = open( APM_PROC, O_RDONLY)) == -1)) + if (access( APM_PROC, R_OK ) || ((fd = open( APM_PROC, O_RDONLY)) == -1)) { + xf86MsgVerb(X_WARNING,3,"Cannot open APM\n"); return NULL; + } close( fd ); - +#ifdef DEBUG + ErrorF("APM: Opening device\n"); +#endif if ((fd = open( APM_DEVICE, O_RDWR )) > -1) { xf86PMGetEventFromOs = lnxPMGetEventFromOs; xf86PMConfirmEventToOs = lnxPMConfirmEventToOs; APMihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); + xf86MsgVerb(X_INFO,3,"Open APM successful\n"); return lnxCloseAPM; } + xf86MsgVerb(X_WARNING,3,"Open APM failed\n"); return NULL; } @@ -142,6 +145,9 @@ { int fd; +#ifdef DEBUG + ErrorF("APM: Closing device\n"); +#endif if (APMihPtr) { fd = xf86RemoveInputHandler(APMihPtr); close(fd); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c:1.2 --- /dev/null Mon Dec 18 14:31:50 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c Mon Nov 6 16:57:11 2000 @@ -0,0 +1,98 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#include <stdio.h> +#include "X.h" +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Axp.h" + +axpDevice lnxGetAXP(void); + +static AXP axpList[] = { + { "Tsunami", NULL, NULL, TSUNAMI }, + { "Eiger", NULL, NULL, TSUNAMI }, + {"Noname", NULL, NULL, LCA }, + { "AlphaBook1", NULL, NULL, LCA }, + {"EB66", NULL, NULL, LCA}, + {"EB64+",NULL,NULL, APECS}, + {"Noritake",NULL,NULL,APECS}, + {"XL",NULL,NULL,APECS}, + {"Avanti",NULL,NULL,APECS}, + {"Mikasa",NULL,"EV5",CIA}, + {"Mikasa",NULL,"EV56",CIA}, + {"Mikasa",NULL,NULL,APECS}, + {"EB164","EB164",NULL,APECS}, + {"EB164","PC164", NULL,CIA}, + {"EB164","RX164",NULL, POLARIS}, + {"EB164","LX164",NULL, PYXIS}, + {"Alcor",NULL,NULL,CIA}, + {"Takara",NULL,NULL,CIA}, + {"Sable",NULL, "EV5",T2_GAMMA}, + {"Sable",NULL,"EV56",T2_GAMMA}, + {"Sable",NULL,NULL,T2}, + {"Rawhide",NULL,NULL,MCPCIA}, + {"Jensen",NULL,NULL,JENSEN}, + {"Miata",NULL,NULL,PYXIS_CIA}, + {"Ruffian",NULL,NULL,PYXIS_CIA}, + {"Nautilus",NULL,NULL,IRONGATE}, + {NULL,NULL,NULL,NONE} +}; + + +axpDevice +lnxGetAXP(void) +{ + FILE *file; + int count = 0; + char res[256]; + char cpu[255]; + char systype[255]; + char sysvari[255]; + if (!(file = fopen("/proc/cpuinfo","r"))) + return SYS_NONE; + do { + if (!fgets(res,0xff,file)) return SYS_NONE; + switch (count) { + case 1: + sscanf(res, "cpu model : %s",cpu); +#ifdef DEBUG + ErrorF("CPU %s\n",cpu); +#endif + break; + case 5: + sscanf(res, "system type : %s",systype); +#ifdef DEBUG + ErrorF("system type : %s\n",systype); +#endif + break; + case 6: + sscanf(res, "system variation : %s",sysvari); +#ifdef DEBUG + ErrorF("system variation: %s\n",sysvari); +#endif + break; + } + count++; + } while (count < 8); + + fclose(file); + + count = 0; + + do { + if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) { + if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) { + count++; + continue; + }; + if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) { + count++; + continue; + } + return axpList[count].sys; + } + count++; + } while (1); +} + Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c:3.12 xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c:3.13 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c:3.12 Fri Feb 25 13:28:11 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c Tue Nov 14 16:59:24 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.12 2000/02/25 18:28:11 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.13 2000/11/14 21:59:24 dawes Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -49,6 +49,7 @@ xf86OpenConsole(void) { int i, fd; + int result; struct vt_mode VT; char vtname[11]; struct vt_stat vts; @@ -158,15 +159,19 @@ /* * now get the VT */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); } - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); + if (result < 0) { FatalError("xf86OpenConsole: VT_GETMODE failed\n"); } @@ -203,11 +208,14 @@ /* * now get the VT */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); + if (result != 0) { xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c:3.17 xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c:3.18 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c:3.17 Fri Jun 9 03:53:25 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c Thu Aug 31 15:03:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.17 2000/06/09 07:53:25 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.18 2000/08/31 19:03:59 tsi Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Dawes <dawes@xfree86.org> @@ -176,7 +176,8 @@ if (xf86IsPc98()) return; -#if defined(__alpha__) || defined (__i386__) /* only these arches have an ISA bus */ +#if defined(__alpha__) || defined (__i386__) || defined(__ia64__) + /* The ioport way */ for (i = 0; i < RATE_COUNT; i++) @@ -199,7 +200,6 @@ usleep(10000); outb(0x60, value); - return; #endif /* __alpha__ || __i386__ */ } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c:3.4 xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c:3.5 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c:3.4 Tue Feb 8 12:19:22 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c Tue Oct 17 12:53:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c,v 3.4 2000/02/08 17:19:22 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c,v 3.5 2000/10/17 16:53:20 tsi Exp $ */ #include <stdio.h> #include "X.h" @@ -28,14 +28,9 @@ do { res = fgets(c,0xff,file); if (res) { -#if defined WORD64 || defined LONG64 -#define ILF "\t%*16x\t%*16x\t%*16x\t%*16x\t%*16x\t%*16x\t%*16x" -#define LF "\t%16x\t%16x\t%16x\t%16x\t%16x\t%16x\t%16x" -#else -#define ILF "\t%*08x\t%*08x\t%*08x\t%*08x\t%*08x\t%*08x\t%*08x" -#define LF "\t%08x\t%08x\t%08x\t%08x\t%08x\t%08x\t%08x" -#endif - num = sscanf(res,"%02x%02x\t%*04x%*04x\t%*x"ILF LF, + num = sscanf(res,"%02x%02x\t%*04x%*04x\t%*x" + "\t%*x\t%*x\t%*x\t%*x\t%*x\t%*x\t%*x" + "\t%x\t%x\t%x\t%x\t%x\t%x\t%x", &bus,&devfn,&size[0],&size[1],&size[2],&size[3], &size[4],&size[5],&size[6]); if (num != 9) { /* apparantly not 2.3 style */ Index: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c:3.36 xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c:3.44 --- xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c:3.36 Tue Jun 27 17:41:37 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c Wed Dec 6 13:08:55 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.36 2000/06/27 21:41:37 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.44 2000/12/06 18:08:55 eich Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -34,6 +34,9 @@ #include "xf86_OSlib.h" #include "xf86OSpriv.h" #include "lnx.h" +#ifdef __alpha__ +#include "xf86Axp.h" +#endif #ifdef HAS_MTRR_SUPPORT #include <asm/mtrr.h> @@ -63,12 +66,10 @@ # ifdef TEST_JENSEN_CODE # define isJensen (1) # else -# define isJensen (!_bus_base()) +# define isJensen (axpSystem == JENSEN) # endif - -# define needSparse (_bus_base_sparse() != 0) -# define BUS_BASE _bus_base() +# define BUS_BASE bus_base #else @@ -80,15 +81,22 @@ /* Video Memory Mapping section */ /***************************************************************************/ -static pointer mapVidMem(int, unsigned long, unsigned long); +static pointer mapVidMem(int, unsigned long, unsigned long, int); static void unmapVidMem(int, pointer, unsigned long); #if defined (__alpha__) -static pointer mapVidMemSparse(int, unsigned long, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); +extern axpDevice lnxGetAXP(void); static void unmapVidMemSparse(int, pointer, unsigned long); # if defined(JENSEN_SUPPORT) -static pointer mapVidMemJensen(int, unsigned long, unsigned long); +static pointer mapVidMemJensen(int, unsigned long, unsigned long, int); static void unmapVidMemJensen(int, pointer, unsigned long); # endif +static axpDevice axpSystem = -1; +static Bool needSparse; +static unsigned long hae_thresh; +static unsigned long hae_mask; +static unsigned long bus_base; +static unsigned long sparse_size; #endif #ifdef HAS_MTRR_SUPPORT @@ -295,10 +303,19 @@ { pVidMem->linearSupported = TRUE; #ifdef __alpha__ + if (axpSystem == -1) { + axpSystem = lnxGetAXP(); + if (needSparse = (_bus_base_sparse() > 0)) { + hae_thresh = xf86AXPParams[axpSystem].hae_thresh; + hae_mask = xf86AXPParams[axpSystem].hae_mask; + sparse_size = xf86AXPParams[axpSystem].size; + } + bus_base = _bus_base(); + } if (isJensen) { # ifndef JENSEN_SUPPORT FatalError("Jensen is not supported any more\n" - "If you are interesetd in fixing Jensen support\n" + "If you are intereseted in fixing Jensen support\n" "please contact xfree86@xfree86.org\n"); # else xf86Msg(X_INFO,"Machine type is Jensen\n"); @@ -329,37 +346,70 @@ static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { - pointer base; - int fd; + pointer base; + int fd; + int mapflags = MAP_SHARED; + memType realBase, alignOff; + + realBase = Base & ~(getpagesize() - 1); + alignOff = Base - realBase; +#ifdef DEBUG + ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n", + Base,realBase,alignOff); +#endif + +#if defined(__ia64__) +#ifndef MAP_WRITECOMBINED +#define MAP_WRITECOMBINED 0x00010000 +#endif +#ifndef MAP_NONCACHED +#define MAP_NONCACHED 0x00020000 +#endif + if(flags & VIDMEM_FRAMEBUFFER) + mapflags |= MAP_WRITECOMBINED; + else + mapflags |= MAP_NONCACHED; +#endif #if defined(__ia64__) - if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) { + /* this will disappear when people upgrade their kernels */ + if ((fd = open(DEV_MEM, O_RDWR|O_SYNC)) < 0) #else - if ((fd = open("/dev/mem", O_RDWR)) < 0) { + if ((fd = open(DEV_MEM, O_RDWR)) < 0) #endif - FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", - strerror(errno)); + { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", + strerror(errno)); } /* This requires linux-0.99.pl10 or above */ - base = mmap((caddr_t)0, Size, - PROT_READ|PROT_WRITE, - MAP_SHARED, fd, - (off_t)(off_t)Base + BUS_BASE); + base = mmap((caddr_t)0, Size + alignOff, + PROT_READ|PROT_WRITE, + mapflags, fd, + (off_t)(off_t)realBase + BUS_BASE); close(fd); if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer" - " (0x%08x,0x%x) (%s)\n", Base, Size, - strerror(errno)); + FatalError("xf86MapVidMem: Could not mmap framebuffer" + " (0x%08x,0x%x) (%s)\n", Base, Size, + strerror(errno)); } - return base; +#ifdef DEBUG + ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff); +#endif + return (char *)base + alignOff; } - + static void unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) { - munmap((caddr_t)Base, Size); + memType alignOff = (memType)Base + - ((memType)Base & ~(getpagesize() - 1)); + +#ifdef DEBUG + ErrorF("alignment offset: %lx\n",alignOff); +#endif + munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff)); } @@ -371,17 +421,6 @@ /* FIXME: init this... */ volatile unsigned char *ioBase = MAP_FAILED; -void -ppc_flush_icache(char *addr) -{ - __asm__ volatile ( - "dcbf 0,%0;" - "sync;" - "icbi 0,%0;" - "sync;" - "isync;" - : : "r"(addr) : "memory"); -} #endif void @@ -520,7 +559,7 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset); static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { int fd; static Bool was_here = FALSE; @@ -538,16 +577,16 @@ xf86ReadMmio16 = readSparse16; xf86ReadMmio32 = readSparse32; - if ((fd = open("/dev/mem", O_RDWR)) < 0) { - FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", + if ((fd = open(DEV_MEM, O_RDWR)) < 0) { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", strerror(errno)); } /* This requirers linux-0.99.pl10 or above */ lnxBase = mmap((caddr_t)0, 0x100000000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, - (off_t) _bus_base()); - lnxSBase = mmap((caddr_t)0, 0x100000000, + (off_t) bus_base); + lnxSBase = mmap((caddr_t)0, 0x400000000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) _bus_base_sparse()); @@ -575,8 +614,8 @@ Offset += (unsigned long)Base - (unsigned long)lnxBase; shift = (Offset & 0x3) << 3; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000UL; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { sethae(msb); @@ -597,8 +636,8 @@ Offset += (unsigned long)Base - (unsigned long)lnxBase; shift = (Offset & 0x2) << 3; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000UL; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { sethae(msb); @@ -623,11 +662,11 @@ register unsigned int b = Value & 0xffU; Offset += (unsigned long)Base - (unsigned long)lnxBase; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { - sethae(msb); + sethae(msb); msb_set = msb; } } @@ -642,8 +681,8 @@ register unsigned int w = Value & 0xffffU; Offset += (unsigned long)Base - (unsigned long)lnxBase; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { sethae(msb); @@ -671,8 +710,8 @@ register unsigned int b = Value & 0xffU; Offset += (unsigned long)Base - (unsigned long)lnxBase; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { sethae(msb); @@ -689,8 +728,8 @@ register unsigned int w = Value & 0xffffU; Offset += (unsigned long)Base - (unsigned long)lnxBase; - if (Offset >= (1UL << 24)) { - msb = Offset & 0xf8000000; + if (Offset >= hae_thresh) { + msb = Offset & hae_mask; Offset -= msb; if (msb_set != msb) { sethae(msb); @@ -764,7 +803,7 @@ #define JENSEN_SHIFT(x) ((long)x<<SPARSE) static pointer -mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; @@ -779,8 +818,8 @@ xf86ReadMmio16 = readSparseJensen16; xf86ReadMmio32 = readSparseJensen32; - if ((fd = open("/dev/mem", O_RDWR)) < 0) { - FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", + if ((fd = open(DEV_MEM, O_RDWR)) < 0) { + FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", strerror(errno)); } /* This requires linux-0.99.pl10 or above */ Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile:1.6 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile Tue Oct 10 12:38:43 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.6 2000/06/17 00:03:34 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.7 2000/10/10 16:38:43 alanh Exp $ #define IHaveModules #include <Server.tmpl> @@ -13,8 +13,8 @@ MTRR_DEFINES = -DHAS_MTRR_SUPPORT #endif -SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c $(MSRC) -OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o $(MOBJ) +SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c xf86drmSiS.c $(MSRC) +OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o xf86drmSiS.o $(MOBJ) INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -Ikernel Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c:1.14 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c:1.17 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c:1.14 Tue Jun 27 12:42:07 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c Sun Sep 24 09:51:32 2000 @@ -27,7 +27,7 @@ * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * Kevin E. Martin <martin@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.14 2000/06/27 16:42:07 alanh Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.17 2000/09/24 13:51:32 alanh Exp $ * */ @@ -71,8 +71,6 @@ #ifdef __alpha__ extern unsigned long _bus_base(void); #define BUS_BASE _bus_base() -#else -#define BUS_BASE (0) #endif /* Not all systems have MAP_FAILED defined */ @@ -504,7 +502,8 @@ map.offset = offset; #ifdef __alpha__ - if (!(type & DRM_SHM)) + /* Make sure we add the bus_base to all but shm */ + if (type != DRM_SHM) map.offset += BUS_BASE; #endif map.size = size; @@ -598,7 +597,15 @@ drmSize size, drmAddressPtr address) { + static unsigned long pagesize_mask = 0; + if (fd < 0) return -EINVAL; + + if (!pagesize_mask) + pagesize_mask = getpagesize() - 1; + + size = (size + pagesize_mask) & ~pagesize_mask; + *address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle); if (*address == MAP_FAILED) return -errno; return 0; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c:1.1 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c Thu Aug 24 18:20:17 2000 @@ -1,3 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c,v 1.3 2000/08/24 22:20:17 tsi Exp $ */ + #ifdef XFree86Server # include "xf86.h" # include "xf86_OSproc.h" @@ -40,7 +42,9 @@ #define MAP_FAILED ((void *)-1) #endif +#ifdef __linux__ #include <sys/sysmacros.h> /* for makedev() */ +#endif #include "xf86drm.h" #include "xf86drmI810.h" #include "drm.h" Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c:1.1 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c Thu Aug 24 18:20:17 2000 @@ -1,3 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c,v 1.3 2000/08/24 22:20:17 tsi Exp $ */ + #ifdef XFree86Server # include "xf86.h" # include "xf86_OSproc.h" @@ -40,7 +42,9 @@ #define MAP_FAILED ((void *)-1) #endif +#ifdef __linux__ #include <sys/sysmacros.h> /* for makedev() */ +#endif #include "xf86drm.h" #include "xf86drmMga.h" #include "drm.h" Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c:1.1 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c Tue Dec 12 12:17:14 2000 @@ -22,10 +22,11 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Author: Kevin E. Martin <martin@valinux.com> - * + * */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c,v 1.6 2000/12/12 17:17:14 dawes Exp $ */ #ifdef XFree86Server # include "xf86.h" @@ -69,129 +70,342 @@ #define MAP_FAILED ((void *)-1) #endif +#ifdef __linux__ #include <sys/sysmacros.h> /* for makedev() */ +#endif #include "xf86drm.h" #include "xf86drmR128.h" #include "drm.h" + +#define R128_BUFFER_RETRY 32 +#define R128_IDLE_RETRY 16 + -int drmR128InitCCE(int fd, drmR128Init *info) +int drmR128InitCCE( int fd, drmR128Init *info ) { - drm_r128_init_t init; + drm_r128_init_t init; + + memset( &init, 0, sizeof(drm_r128_init_t) ); + + init.func = R128_INIT_CCE; + init.sarea_priv_offset = info->sarea_priv_offset; + init.is_pci = info->is_pci; + init.cce_mode = info->cce_mode; + init.cce_secure = info->cce_secure; + init.ring_size = info->ring_size; + init.usec_timeout = info->usec_timeout; + + init.fb_bpp = info->fb_bpp; + init.front_offset = info->front_offset; + init.front_pitch = info->front_pitch; + init.back_offset = info->back_offset; + init.back_pitch = info->back_pitch; + + init.depth_bpp = info->depth_bpp; + init.depth_offset = info->depth_offset; + init.depth_pitch = info->depth_pitch; + init.span_offset = info->span_offset; + + init.fb_offset = info->fb_offset; + init.mmio_offset = info->mmio_offset; + init.ring_offset = info->ring_offset; + init.ring_rptr_offset = info->ring_rptr_offset; + init.buffers_offset = info->buffers_offset; + init.agp_textures_offset = info->agp_textures_offset; + + if ( ioctl( fd, DRM_IOCTL_R128_INIT, &init ) ) { + return -errno; + } else { + return 0; + } +} - memset(&init, 0, sizeof(drm_r128_init_t)); +int drmR128CleanupCCE( int fd ) +{ + drm_r128_init_t init; - init.func = R128_INIT_CCE; - init.sarea_priv_offset = info->sarea_priv_offset; - init.is_pci = info->is_pci; - init.cce_mode = info->cce_mode; - init.cce_fifo_size = info->cce_fifo_size; - init.cce_secure = info->cce_secure; - init.ring_size = info->ring_size; - init.usec_timeout = info->usec_timeout; + memset( &init, 0, sizeof(drm_r128_init_t) ); - init.fb_offset = info->fb_offset; - init.agp_ring_offset = info->agp_ring_offset; - init.agp_read_ptr_offset = info->agp_read_ptr_offset; - init.agp_vertbufs_offset = info->agp_vertbufs_offset; - init.agp_indbufs_offset = info->agp_indbufs_offset; - init.agp_textures_offset = info->agp_textures_offset; - init.mmio_offset = info->mmio_offset; + init.func = R128_CLEANUP_CCE; - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; + if ( ioctl( fd, DRM_IOCTL_R128_INIT, &init ) ) { + return -errno; + } else { + return 0; + } +} - return 0; +int drmR128StartCCE( int fd ) +{ + if ( ioctl( fd, DRM_IOCTL_R128_CCE_START, NULL ) ) { + return -errno; + } else { + return 0; + } } -int drmR128CleanupCCE(int fd) +int drmR128StopCCE( int fd ) { - drm_r128_init_t init; + drm_r128_cce_stop_t stop; + int ret, i = 0; + + stop.flush = 1; + stop.idle = 1; - memset(&init, 0, sizeof(drm_r128_init_t)); + ret = ioctl( fd, DRM_IOCTL_R128_CCE_STOP, &stop ); - init.func = R128_CLEANUP_CCE; + if ( ret && errno != EBUSY ) + return -errno; - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; + stop.flush = 0; - return 0; + do { + ret = ioctl( fd, DRM_IOCTL_R128_CCE_STOP, &stop ); + } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY ); + + if ( ret && errno != EBUSY ) + return -errno; + + stop.idle = 0; + + if ( ioctl( fd, DRM_IOCTL_R128_CCE_STOP, &stop ) ) { + return -errno; + } else { + return 0; + } +} + +int drmR128ResetCCE( int fd ) +{ + if ( ioctl( fd, DRM_IOCTL_R128_CCE_RESET, NULL ) ) { + return -errno; + } else { + return 0; + } } -int drmR128EngineReset(int fd) +int drmR128WaitForIdleCCE( int fd ) { - if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno; + int ret, i = 0; - return 0; + do { + ret = ioctl( fd, DRM_IOCTL_R128_CCE_IDLE, NULL ); + } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY ); + + if ( ret == 0 ) { + return 0; + } else { + return -errno; + } } -int drmR128EngineFlush(int fd) +int drmR128EngineReset( int fd ) { - if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno; + if ( ioctl( fd, DRM_IOCTL_R128_RESET, NULL ) ) { + return -errno; + } else { + return 0; + } +} - return 0; +int drmR128SwapBuffers( int fd ) +{ + if ( ioctl( fd, DRM_IOCTL_R128_SWAP, NULL ) ) { + return -errno; + } else { + return 0; + } } -int drmR128WaitForIdle(int fd) +int drmR128Clear( int fd, unsigned int flags, + int x, int y, int w, int h, + unsigned int clear_color, + unsigned int clear_depth ) { - if (ioctl(fd, DRM_IOCTL_R128_IDLE, NULL)) return -errno; + drm_r128_clear_t clear; - return 0; + clear.flags = flags; + clear.x = x; + clear.y = y; + clear.w = w; + clear.h = h; + clear.clear_color = clear_color; + clear.clear_depth = clear_depth; + + if ( ioctl( fd, DRM_IOCTL_R128_CLEAR, &clear ) < 0 ) { + return -errno; + } else { + return 0; + } } -int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags) +int drmR128FlushVertexBuffer( int fd, int prim, int index, + int count, int discard ) { - drm_r128_packet_t packet; - int ret; + drm_r128_vertex_t v; - memset(&packet, 0, sizeof(drm_r128_packet_t)); + v.prim = prim; + v.idx = index; + v.count = count; + v.discard = discard; + + if ( ioctl( fd, DRM_IOCTL_R128_VERTEX, &v ) < 0 ) { + return -errno; + } else { + return 0; + } +} - packet.count = *count; - packet.flags = flags; +int drmR128FlushIndices( int fd, int prim, int index, + int start, int end, int discard ) +{ + drm_r128_indices_t elts; - while (packet.count > 0) { - packet.buffer = buffer + (*count - packet.count); - ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet); - if (ret < 0 && ret != -EAGAIN) { - *count = packet.count; - return -errno; - } - } + elts.prim = prim; + elts.idx = index; + elts.start = start; + elts.end = end; + elts.discard = discard; + + if ( ioctl( fd, DRM_IOCTL_R128_INDICES, &elts ) < 0 ) { + return -errno; + } else { + return 0; + } +} + +int drmR128TextureBlit( int fd, int index, + int offset, int pitch, int format, + int x, int y, int width, int height ) +{ + drm_r128_blit_t blit; + + blit.idx = index; + blit.offset = offset; + blit.pitch = pitch; + blit.format = format; + blit.x = x; + blit.y = y; + blit.width = width; + blit.height = height; + + if ( ioctl( fd, DRM_IOCTL_R128_BLIT, &blit ) < 0 ) { + return -errno; + } else { + return 0; + } +} - *count = 0; - return 0; +int drmR128WriteDepthSpan( int fd, int n, int x, int y, + const unsigned int depth[], + const unsigned char mask[] ) +{ + drm_r128_depth_t d; + + d.func = R128_WRITE_SPAN; + d.n = n; + d.x = &x; + d.y = &y; + d.buffer = (unsigned int *)depth; + d.mask = (unsigned char *)mask; + + if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) { + return -errno; + } else { + return 0; + } } -int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes) +int drmR128WriteDepthPixels( int fd, int n, + const int x[], const int y[], + const unsigned int depth[], + const unsigned char mask[] ) { - drm_r128_vertex_t v; + drm_r128_depth_t d; - v.send_count = 0; - v.send_indices = NULL; - v.send_sizes = NULL; - v.prim = DRM_R128_PRIM_NONE; - v.request_count = count; - v.request_indices = indices; - v.request_sizes = sizes; - v.granted_count = 0; + d.func = R128_WRITE_PIXELS; + d.n = n; + d.x = (int *)x; + d.y = (int *)y; + d.buffer = (unsigned int *)depth; + d.mask = (unsigned char *)mask; + + if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) { + return -errno; + } else { + return 0; + } +} - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno; +int drmR128ReadDepthSpan( int fd, int n, int x, int y ) +{ + drm_r128_depth_t d; - return v.granted_count; + d.func = R128_READ_SPAN; + d.n = n; + d.x = &x; + d.y = &y; + d.buffer = NULL; + d.mask = NULL; + + if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) { + return -errno; + } else { + return 0; + } } -int drmR128FlushVertexBuffers(int fd, int count, int *indices, - int *sizes, drmR128PrimType prim) +int drmR128ReadDepthPixels( int fd, int n, + const int x[], const int y[] ) { - drm_r128_vertex_t v; + drm_r128_depth_t d; + + d.func = R128_READ_PIXELS; + d.n = n; + d.x = (int *)x; + d.y = (int *)y; + d.buffer = NULL; + d.mask = NULL; + + if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) { + return -errno; + } else { + return 0; + } +} + +int drmR128PolygonStipple( int fd, unsigned int *mask ) +{ + drm_r128_stipple_t stipple; + + stipple.mask = mask; + + if ( ioctl( fd, DRM_IOCTL_R128_STIPPLE, &stipple ) < 0 ) { + return -errno; + } else { + return 0; + } +} + +int drmR128SubmitPacket( int fd, void *buffer, int *count, int flags ) +{ + drm_r128_packet_t packet; + int ret; + + memset( &packet, 0, sizeof(drm_r128_packet_t) ); - v.send_count = count; - v.send_indices = indices; - v.send_sizes = sizes; - v.prim = prim; - v.request_count = 0; - v.request_indices = NULL; - v.request_sizes = NULL; - v.granted_count = 0; + packet.count = *count; + packet.flags = flags; - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno; + while (packet.count > 0) { + packet.buffer = (unsigned int *)buffer + (*count - packet.count); + ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet); + if (ret < 0 && ret != -EAGAIN) { + *count = packet.count; + return -errno; + } + } - return 0; + *count = 0; + return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c:1.3 --- /dev/null Mon Dec 18 14:31:51 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c Tue Oct 10 15:35:30 2000 @@ -0,0 +1,60 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSiS.c,v 1.3 2000/10/10 19:35:30 alanh Exp $ */ + +#ifdef XFree86Server +# include "xf86.h" +# include "xf86_OSproc.h" +# include "xf86_ansic.h" +# include "xf86Priv.h" +# define _DRM_MALLOC xalloc +# define _DRM_FREE xfree +# ifndef XFree86LOADER +# include <sys/stat.h> +# include <sys/mman.h> +# endif +#else +# include <stdio.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <ctype.h> +# include <fcntl.h> +# include <errno.h> +# include <signal.h> +# include <sys/types.h> +# include <sys/stat.h> +# include <sys/ioctl.h> +# include <sys/mman.h> +# include <sys/time.h> +# ifdef DRM_USE_MALLOC +# define _DRM_MALLOC malloc +# define _DRM_FREE free +extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); +extern int xf86RemoveSIGIOHandler(int fd); +# else +# include <Xlibint.h> +# define _DRM_MALLOC Xmalloc +# define _DRM_FREE Xfree +# endif +#endif + +/* Not all systems have MAP_FAILED defined */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +#ifdef __linux__ +#include <sys/sysmacros.h> /* for makedev() */ +#endif +#include "xf86drm.h" +#include "drm.h" + +Bool drmSiSAgpInit(int driSubFD, int offset, int size) +{ + drm_sis_agp_t agp; + + agp.offset = offset; + agp.size = size; + xf86ioctl(driSubFD, SIS_IOCTL_AGP_INIT, &agp); + + return TRUE; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile:1.2 Tue Feb 22 23:47:24 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile Wed Nov 8 00:03:06 2000 @@ -1,14 +1,6 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile,v 1.2 2000/02/23 04:47:24 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile,v 1.3 2000/11/08 05:03:06 dawes Exp $ #include <Server.tmpl> - -LinkSourceFile(xf86drm.c,..) -LinkSourceFile(xf86drmHash.c,..) -LinkSourceFile(xf86drmRandom.c,..) -LinkSourceFile(xf86drmSL.c,..) -LinkSourceFile(xf86drm.h,$(XF86OSSRC)) -LinkSourceFile(xf86_OSproc.h,$(XF86OSSRC)) -LinkSourceFile(sigio.c,$(XF86OSSRC)/shared) XCOMM This is a kludge until we determine how best to build the XCOMM kernel-specific device driver. This allows us to continue Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel:1.6 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel Mon Dec 4 14:21:55 2000 @@ -2,52 +2,88 @@ # Makefile for the drm device driver. This driver provides support for # the Direct Rendering Infrastructure (DRI) in XFree86 4.x. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are now inherited from the -# parent makes.. -# -# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel,v 1.6 2000/06/17 00:03:34 martin Exp $ - -L_TARGET := libdrm.a -L_OBJS := init.o memory.o proc.o auth.o context.o drawable.o bufs.o \ - lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o \ - agpsupport.o +# drm.o is a fake target -- it is never built +# The real targets are in the module-list +O_TARGET := drm.o +module-list := gamma.o tdfx.o r128.o ffb.o mga.o i810.o +export-objs := $(patsubst %.o,%_drv.o,$(module-list)) -M_OBJS := +# libs-objs are included in every module so that radical changes to the +# architecture of the DRM support library can be made at a later time. +# +# The downside is that each module is larger, and a system that uses +# more than one module (i.e., a dual-head system) will use more memory +# (but a system that uses exactly one module will use the same amount of +# memory). +# +# The upside is that if the DRM support library ever becomes insufficient +# for new families of cards, a new library can be implemented for those new +# cards without impacting the drivers for the old cards. This is significant, +# because testing architectural changes to old cards may be impossible, and +# may delay the implementation of a better architecture. We've traded slight +# memory waste (in the dual-head case) for greatly improved long-term +# maintainability. +# +lib-objs := init.o memory.o proc.o auth.o context.o drawable.o bufs.o +lib-objs += lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o -ifdef CONFIG_DRM_GAMMA -M_OBJS += gamma.o +ifeq ($(CONFIG_AGP),y) + lib-objs += agpsupport.o +else + ifeq ($(CONFIG_AGP),m) + lib-objs += agpsupport.o + endif endif -ifdef CONFIG_DRM_TDFX -M_OBJS += tdfx.o +gamma-objs := $(lib-objs) gamma_drv.o gamma_dma.o +tdfx-objs := $(lib-objs) tdfx_drv.o tdfx_context.o +r128-objs := $(lib-objs) r128_drv.o r128_cce.o r128_context.o r128_bufs.o\ + r128_state.o +ffb-objs := $(lib-objs) ffb_drv.o ffb_context.o +mga-objs := $(lib-objs) mga_drv.o mga_dma.o mga_context.o mga_bufs.o \ + mga_state.o +i810-objs := $(lib-objs) i810_drv.o i810_dma.o i810_context.o i810_bufs.o + +obj-$(CONFIG_DRM_GAMMA) += gamma.o $(gamma-objs) +obj-$(CONFIG_DRM_TDFX) += tdfx.o $(tdfx-objs) +obj-$(CONFIG_DRM_R128) += r128.o $(r128-objs) +obj-$(CONFIG_DRM_FFB) += ffb.o $(ffb-objs) + +ifneq ($CONFIG_AGP),) +obj-$(CONFIG_DRM_MGA) += mga.o $(mga-objs) +obj-$(CONFIG_DRM_I810) += i810.o $(i810-objs) endif -ifdef CONFIG_DRM_MGA -M_OBJS += mga.o -endif +# Take module names out of obj-y and int-m -ifdef CONFIG_DRM_R128 -M_OBJS += r128.o -endif +obj-y := $(filter-out $(module-list), $(obj-y)) +int-m := $(filter-out $(module-list), $(obj-m)) + +# Translate to Rules.make lists. +O_OBJS := $(filter-out $(export-objs), $(obj-y)) +OX_OBJS := $(filter $(export-objs), $(obj-y)) +M_OBJS := $(sort $(filter $(module-list), $(obj-m))) +MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m))) +MIX_OBJS := $(sort $(filter $(export-objs), $(int-m))) + include $(TOPDIR)/Rules.make + +gamma.o: $(gamma-objs) + $(LD) -r -o $@ $(gamma-objs) -gamma.o: gamma_drv.o gamma_dma.o $(L_TARGET) - $(LD) $(LD_RFLAG) -r -o $@ gamma_drv.o gamma_dma.o -L. -ldrm +tdfx.o: $(tdfx-objs) + $(LD) -r -o $@ $(tdfx-objs) -tdfx.o: tdfx_drv.o tdfx_context.o $(L_TARGET) - $(LD) $(LD_RFLAG) -r -o $@ tdfx_drv.o tdfx_context.o -L. -ldrm +mga.o: $(mga-objs) + $(LD) -r -o $@ $(mga-objs) -i810.o: i810_drv.o i810_context.o $(L_TARGET) - $(LD) $(LD_RFLAG) -r -o $@ i810_drv.o i810_bufs.o i810_dma.o i810_context.o -L. -ldrm +i810.o: $(i810-objs) + $(LD) -r -o $@ $(i810-objs) -mga.o: mga_drv.o mga_context.o mga_dma.o mga_bufs.o $(L_TARGET) - $(LD) $(LD_RFLAG) -r -o $@ mga_drv.o mga_bufs.o mga_dma.o mga_context.o mga_state.o -L. -ldrm +r128.o: $(r128-objs) + $(LD) -r -o $@ $(r128-objs) -r128.o: r128_drv.o r128_context.o $(L_TARGET) - $(LD) $(LD_RFLAG) -r -o $@ r128_drv.o r128_context.o -L. -ldrm +ffb.o: $(ffb-objs) + $(LD) -r -o $@ $(ffb-objs) Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux:1.7 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux:1.15 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux:1.7 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux Mon Dec 4 14:21:57 2000 @@ -11,11 +11,11 @@ # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice (including the next # paragraph) shall be included in all copies or substantial portions of the # Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -49,11 +49,10 @@ MODS= gamma.o tdfx.o r128.o LIBS= libdrm.a -PROGS= drmstat DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \ lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o -DRMHEADERS= drm.h drmP.h +DRMHEADERS= drm.h drmP.h compat-pre24.h GAMMAOBJS= gamma_drv.o gamma_dma.o GAMMAHEADERS= gamma_drv.h $(DRMHEADERS) @@ -61,18 +60,16 @@ TDFXOBJS= tdfx_drv.o tdfx_context.o TDFXHEADERS= tdfx_drv.h $(DRMHEADERS) -R128OBJS= r128_drv.o r128_dma.o r128_bufs.o r128_context.o +R128OBJS= r128_drv.o r128_cce.o r128_bufs.o r128_state.o r128_context.o R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS) -PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po -PROGHEADERS= xf86drm.h $(DRMHEADERS) - INC= /usr/include CFLAGS= -O2 $(WARNINGS) WARNINGS= -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \ - -Wstrict-prototypes -Wshadow -Wnested-externs \ - -Winline -Wpointer-arith + -Wstrict-prototypes -Wnested-externs \ + -Wpointer-arith +# -Wshadow -Winline -- make output too noisy MODCFLAGS= $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer PRGCFLAGS= $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ @@ -116,21 +113,30 @@ else SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'SMP = ' | cut -d' ' -f3) -MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \ +MODULES := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ + | grep -s 'MODULES = ' | cut -d' ' -f3) +MODVERSIONS := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'MODVERSIONS = ' | cut -d' ' -f3) AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'AGP = ' | cut -d' ' -f3) -PARAMS := $(shell if fgrep kill_fasync $(TREE)/linux/fs.h \ - | fgrep -q band; then echo 3; else echo 2; fi) +SIS := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ + | grep -s 'SIS = ' | cut -d' ' -f3) +PARAMS := $(shell if fgrep kill_fasync $(TREE)/linux/fs.h 2>/dev/null \ + | egrep -q '(band|int, int)'; then echo 3; else echo 2; fi) +MACHINE := $(shell echo `uname -m`) ifeq ($(AGP),0) AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'AGP_MODULE = ' | cut -d' ' -f3) endif ifeq ($(AGP),1) -MODCFLAGS += -DDRM_AGP +MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE DRMOBJS += agpsupport.o -MODS += mga.o i810.o +MODS += mga.o +ifeq ($(MACHINE),i386) +MODS += i810.o +endif + MGAOBJS= mga_drv.o mga_dma.o mga_bufs.o mga_state.o mga_context.o MGAHEADERS= mga_drv.h $(DRMHEADERS) @@ -139,12 +145,34 @@ I810HEADERS= i810_drv.h $(DRMHEADERS) endif +ifeq ($(SIS),1) +# It appears that the SiS driver makes calls to sis_malloc and sis_free, and +# that these calls are only defined if CONFIG_FB_SIS is selected. So, key +# off that to determine if we should attempt to build the SiS driver. +# +# A better way would be to detect the appropriate definitions in the header +# file to see if we can, at least, compile the driver. +MODS += sis.o + +SISOBJS= sis_drv.o sis_context.o sis_ds.o sis_mm.o +SISHEADERS= sis_drv.h sis_ds.h sis_drm.h $(DRMHEADERS) +endif + all::;@echo === KERNEL HEADERS IN $(TREE) -all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP} +all::;@echo === SMP=${SMP} MODULES=${MODULES} MODVERSIONS=${MODVERSIONS} AGP=${AGP} all::;@echo === kill_fasync has $(PARAMS) parameters +all::;@echo === Compiling for machine $(MACHINE) + +ifeq ($(MODULES),0) +all::;@echo +all::;@echo "*** Kernel modules must be configured. Build aborted." +all::;@echo +else all:: $(LIBS) $(MODS) $(PROGS) endif +endif + # **** End of SMP/MODVERSIONS detection # **** Handle SMP/MODVERSIONS @@ -164,41 +192,49 @@ -$(RM) -f $@ $(AR) rcs $@ $(DRMOBJS) +gamma_drv.o: gamma_drv.c + $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@ gamma.o: $(GAMMAOBJS) $(LIBS) $(LD) -r $^ -o $@ +tdfx_drv.o: tdfx_drv.c + $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@ tdfx.o: $(TDFXOBJS) $(LIBS) $(LD) -r $^ -o $@ +r128_drv.o: r128_drv.c + $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@ r128.o: $(R128OBJS) $(LIBS) $(LD) -r $^ -o $@ +sis.o: $(SISOBJS) $(LIBS) + $(LD) -r $^ -o $@ + ifeq ($(AGP),1) +mga_drv.o: mga_drv.c + $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@ mga.o: $(MGAOBJS) $(LIBS) $(LD) -r $^ -o $@ +i810_drv.o: i810_drv.c + $(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I$(TREE) -c $< -o $@ i810.o: $(I810OBJS) $(LIBS) $(LD) -r $^ -o $@ endif -drmstat: $(PROGOBJS) - $(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@ - .PHONY: ChangeLog ChangeLog: @rm -f Changelog @rcs2log -i 2 -r -l \ - | sed 's,@.*alephnull.com,@precisioninsight.com,' > ChangeLog + | sed 's,@.*light,,' \ + | sed 's,/cvsroot/.*/drm/kernel/,,g' \ + > ChangeLog # .o files are used for modules %.o: %.c $(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@ -%.po: %.c - $(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@ - - $(DRMOBJS): $(DRMHEADERS) $(GAMMAOBJS): $(GAMMAHEADERS) $(TDFXOBJS): $(TDFXHEADERS) @@ -207,7 +243,6 @@ $(MGAOBJS): $(MGAHEADERS) $(I810OBJS): $(I810HEADERS) endif -$(PROGOBJS): $(PROGHEADERS) clean: - rm -f *.o *.a *.po *~ core $(PROGS) + rm -f *.o *.a *~ core Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm:1.2 Mon Sep 27 10:59:24 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm Wed Nov 8 00:03:06 2000 @@ -1,3 +1,7 @@ +************************************************************ +* For the very latest on DRI development, please see: * +* http://dri.sourceforge.net/ * +************************************************************ The Direct Rendering Manager (drm) is a device-independent kernel-level device driver that provides support for the XFree86 Direct Rendering @@ -36,6 +40,7 @@ A Security Analysis of the Direct Rendering Infrastructure http://precisioninsight.com/dr/security.html - - -$XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/README.drm,v 1.2 1999/09/27 14:59:24 dawes Exp $ +************************************************************ +* For the very latest on DRI development, please see: * +* http://dri.sourceforge.net/ * +************************************************************ Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport-pre24.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport-pre24.h:1.1 --- /dev/null Mon Dec 18 14:31:51 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport-pre24.h Fri Dec 1 09:29:00 2000 @@ -0,0 +1,115 @@ +/* agpsupport-pre24.h -- Support for pre-2.4.0 kernels -*- linux-c -*- + * Created: Mon Nov 13 10:54:15 2000 by faith@valinux.com + * + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Rickard E. (Rik) Faith <faith@valinux.com> + * + */ + +#ifndef _AGPSUPPORT_PRE24_H_ +#define _AGPSUPPORT_PRE24_H_ +typedef struct { + void (*free_memory)(agp_memory *); + agp_memory *(*allocate_memory)(size_t, u32); + int (*bind_memory)(agp_memory *, off_t); + int (*unbind_memory)(agp_memory *); + void (*enable)(u32); + int (*acquire)(void); + void (*release)(void); + void (*copy_info)(agp_kern_info *); +} drm_agp_t; + +static drm_agp_t drm_agp_struct = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + +/* The C standard says that 'void *' is not guaranteed to hold a function + pointer, so we use this union to define a generic pointer that is + guaranteed to hold any of the function pointers we care about. */ +typedef union { + void (*free_memory)(agp_memory *); + agp_memory *(*allocate_memory)(size_t, u32); + int (*bind_memory)(agp_memory *, off_t); + int (*unbind_memory)(agp_memory *); + void (*enable)(u32); + int (*acquire)(void); + void (*release)(void); + void (*copy_info)(agp_kern_info *); + unsigned long address; +} drm_agp_func_u; + +typedef struct drm_agp_fill { + const char *name; + drm_agp_func_u *f; +} drm_agp_fill_t; + +static drm_agp_fill_t drm_agp_fill[] = { + { __MODULE_STRING(agp_free_memory), + (drm_agp_func_u *)&drm_agp_struct.free_memory }, + { __MODULE_STRING(agp_allocate_memory), + (drm_agp_func_u *)&drm_agp_struct.allocate_memory }, + { __MODULE_STRING(agp_bind_memory), + (drm_agp_func_u *)&drm_agp_struct.bind_memory }, + { __MODULE_STRING(agp_unbind_memory), + (drm_agp_func_u *)&drm_agp_struct.unbind_memory }, + { __MODULE_STRING(agp_enable), + (drm_agp_func_u *)&drm_agp_struct.enable }, + { __MODULE_STRING(agp_backend_acquire), + (drm_agp_func_u *)&drm_agp_struct.acquire }, + { __MODULE_STRING(agp_backend_release), + (drm_agp_func_u *)&drm_agp_struct.release }, + { __MODULE_STRING(agp_copy_info), + (drm_agp_func_u *)&drm_agp_struct.copy_info }, + { NULL, NULL } +}; + +#define DRM_AGP_GET _drm_agp_get() +#define DRM_AGP_PUT _drm_agp_put() + +static drm_agp_t *_drm_agp_get(void) +{ + drm_agp_fill_t *fill; + int agp_available = 1; + + for (fill = &drm_agp_fill[0]; fill->name; fill++) { + char *n = (char *)fill->name; + *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); + DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address); + if (!(*fill->f).address) agp_available = 0; + } + return &drm_agp_struct; +} + +static void _drm_agp_put(void) +{ + drm_agp_fill_t *fill; + + for (fill = &drm_agp_fill[0]; fill->name; fill++) { +#if LINUX_VERSION_CODE >= 0x020400 + if ((*fill->f).address) put_module_symbol((*fill->f).address); +#endif + (*fill->f).address = 0; + } +} +#endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c:1.2 Fri Jun 16 20:03:34 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c Fri Dec 1 09:29:01 2000 @@ -30,49 +30,16 @@ #define __NO_VERSION__ #include "drmP.h" +#include <linux/module.h> +#if LINUX_VERSION_CODE < 0x020400 +#include "agpsupport-pre24.h" +#else +#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp") +#define DRM_AGP_PUT inter_module_put("drm_agp") +#endif -drm_agp_func_t drm_agp = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static const drm_agp_t *drm_agp = NULL; -/* The C standard says that 'void *' is not guaranteed to hold a function - pointer, so we use this union to define a generic pointer that is - guaranteed to hold any of the function pointers we care about. */ -typedef union { - void (*free_memory)(agp_memory *); - agp_memory *(*allocate_memory)(size_t, u32); - int (*bind_memory)(agp_memory *, off_t); - int (*unbind_memory)(agp_memory *); - void (*enable)(u32); - int (*acquire)(void); - void (*release)(void); - void (*copy_info)(agp_kern_info *); - unsigned long address; -} drm_agp_func_u; - -typedef struct drm_agp_fill { - const char *name; - drm_agp_func_u *f; -} drm_agp_fill_t; - -static drm_agp_fill_t drm_agp_fill[] = { - { __MODULE_STRING(agp_free_memory), - (drm_agp_func_u *)&drm_agp.free_memory }, - { __MODULE_STRING(agp_allocate_memory), - (drm_agp_func_u *)&drm_agp.allocate_memory }, - { __MODULE_STRING(agp_bind_memory), - (drm_agp_func_u *)&drm_agp.bind_memory }, - { __MODULE_STRING(agp_unbind_memory), - (drm_agp_func_u *)&drm_agp.unbind_memory }, - { __MODULE_STRING(agp_enable), - (drm_agp_func_u *)&drm_agp.enable }, - { __MODULE_STRING(agp_backend_acquire), - (drm_agp_func_u *)&drm_agp.acquire }, - { __MODULE_STRING(agp_backend_release), - (drm_agp_func_u *)&drm_agp.release }, - { __MODULE_STRING(agp_copy_info), - (drm_agp_func_u *)&drm_agp.copy_info }, - { NULL, NULL } -}; - int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -81,7 +48,7 @@ agp_kern_info *kern; drm_agp_info_t info; - if (!dev->agp->acquired || !drm_agp.copy_info) return -EINVAL; + if (!dev->agp->acquired || !drm_agp->copy_info) return -EINVAL; kern = &dev->agp->agp_info; info.agp_version_major = kern->version.major; @@ -94,7 +61,8 @@ info.id_vendor = kern->device->vendor; info.id_device = kern->device->device; - copy_to_user_ret((drm_agp_info_t *)arg, &info, sizeof(info), -EFAULT); + if (copy_to_user((drm_agp_info_t *)arg, &info, sizeof(info))) + return -EFAULT; return 0; } @@ -105,8 +73,8 @@ drm_device_t *dev = priv->dev; int retcode; - if (dev->agp->acquired || !drm_agp.acquire) return -EINVAL; - if ((retcode = (*drm_agp.acquire)())) return retcode; + if (dev->agp->acquired || !drm_agp->acquire) return -EINVAL; + if ((retcode = drm_agp->acquire())) return retcode; dev->agp->acquired = 1; return 0; } @@ -117,13 +85,18 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; - if (!dev->agp->acquired || !drm_agp.release) return -EINVAL; - (*drm_agp.release)(); + if (!dev->agp->acquired || !drm_agp->release) return -EINVAL; + drm_agp->release(); dev->agp->acquired = 0; return 0; } +void _drm_agp_release(void) +{ + if (drm_agp->release) drm_agp->release(); +} + int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -131,13 +104,13 @@ drm_device_t *dev = priv->dev; drm_agp_mode_t mode; - if (!dev->agp->acquired || !drm_agp.enable) return -EINVAL; + if (!dev->agp->acquired || !drm_agp->enable) return -EINVAL; - copy_from_user_ret(&mode, (drm_agp_mode_t *)arg, sizeof(mode), - -EFAULT); + if (copy_from_user(&mode, (drm_agp_mode_t *)arg, sizeof(mode))) + return -EFAULT; dev->agp->mode = mode.mode; - (*drm_agp.enable)(mode.mode); + drm_agp->enable(mode.mode); dev->agp->base = dev->agp->agp_info.aper_base; dev->agp->enabled = 1; return 0; @@ -154,8 +127,8 @@ unsigned long pages; u32 type; if (!dev->agp->acquired) return -EINVAL; - copy_from_user_ret(&request, (drm_agp_buffer_t *)arg, sizeof(request), - -EFAULT); + if (copy_from_user(&request, (drm_agp_buffer_t *)arg, sizeof(request))) + return -EFAULT; if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) return -ENOMEM; @@ -211,8 +184,8 @@ drm_agp_mem_t *entry; if (!dev->agp->acquired) return -EINVAL; - copy_from_user_ret(&request, (drm_agp_binding_t *)arg, sizeof(request), - -EFAULT); + if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request))) + return -EFAULT; if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (!entry->bound) return -EINVAL; @@ -229,9 +202,9 @@ int retcode; int page; - if (!dev->agp->acquired || !drm_agp.bind_memory) return -EINVAL; - copy_from_user_ret(&request, (drm_agp_binding_t *)arg, sizeof(request), - -EFAULT); + if (!dev->agp->acquired || !drm_agp->bind_memory) return -EINVAL; + if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request))) + return -EFAULT; if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (entry->bound) return -EINVAL; @@ -252,8 +225,8 @@ drm_agp_mem_t *entry; if (!dev->agp->acquired) return -EINVAL; - copy_from_user_ret(&request, (drm_agp_buffer_t *)arg, sizeof(request), - -EFAULT); + if (copy_from_user(&request, (drm_agp_buffer_t *)arg, sizeof(request))) + return -EFAULT; if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (entry->bound) drm_unbind_agp(entry->memory); @@ -268,43 +241,52 @@ drm_agp_head_t *drm_agp_init(void) { - drm_agp_fill_t *fill; drm_agp_head_t *head = NULL; - int agp_available = 1; - for (fill = &drm_agp_fill[0]; fill->name; fill++) { - char *n = (char *)fill->name; - *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); - DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address); - if (!(*fill->f).address) agp_available = 0; - } - - DRM_DEBUG("agp_available = %d\n", agp_available); - - if (agp_available) { + drm_agp = DRM_AGP_GET; + if (drm_agp) { if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) return NULL; memset((void *)head, 0, sizeof(*head)); - (*drm_agp.copy_info)(&head->agp_info); + drm_agp->copy_info(&head->agp_info); + if (head->agp_info.chipset == NOT_SUPPORTED) { + drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); + return NULL; + } head->memory = NULL; switch (head->agp_info.chipset) { - case INTEL_GENERIC: head->chipset = "Intel"; break; - case INTEL_LX: head->chipset = "Intel 440LX"; break; - case INTEL_BX: head->chipset = "Intel 440BX"; break; - case INTEL_GX: head->chipset = "Intel 440GX"; break; - case INTEL_I810: head->chipset = "Intel i810"; break; - case VIA_GENERIC: head->chipset = "VIA"; break; - case VIA_VP3: head->chipset = "VIA VP3"; break; - case VIA_MVP3: head->chipset = "VIA MVP3"; break; - case VIA_APOLLO_PRO: head->chipset = "VIA Apollo Pro"; break; - case SIS_GENERIC: head->chipset = "SiS"; break; - case AMD_GENERIC: head->chipset = "AMD"; break; - case AMD_IRONGATE: head->chipset = "AMD Irongate"; break; - case ALI_GENERIC: head->chipset = "ALi"; break; - case ALI_M1541: head->chipset = "ALi M1541"; break; - default: + case INTEL_GENERIC: head->chipset = "Intel"; break; + case INTEL_LX: head->chipset = "Intel 440LX"; break; + case INTEL_BX: head->chipset = "Intel 440BX"; break; + case INTEL_GX: head->chipset = "Intel 440GX"; break; + case INTEL_I810: head->chipset = "Intel i810"; break; + +#if LINUX_VERSION_CODE >= 0x020400 + case INTEL_I840: head->chipset = "Intel i840"; break; +#endif + + case VIA_GENERIC: head->chipset = "VIA"; break; + case VIA_VP3: head->chipset = "VIA VP3"; break; + case VIA_MVP3: head->chipset = "VIA MVP3"; break; + +#if LINUX_VERSION_CODE >= 0x020400 + case VIA_MVP4: head->chipset = "VIA MVP4"; break; + case VIA_APOLLO_KX133: head->chipset = "VIA Apollo KX133"; + break; + case VIA_APOLLO_KT133: head->chipset = "VIA Apollo KT133"; + break; +#endif + + case VIA_APOLLO_PRO: head->chipset = "VIA Apollo Pro"; + break; + case SIS_GENERIC: head->chipset = "SiS"; break; + case AMD_GENERIC: head->chipset = "AMD"; break; + case AMD_IRONGATE: head->chipset = "AMD Irongate"; break; + case ALI_GENERIC: head->chipset = "ALi"; break; + case ALI_M1541: head->chipset = "ALi M1541"; break; + default: head->chipset = "Unknown"; break; } - DRM_INFO("AGP %d.%d on %s @ 0x%08lx %dMB\n", + DRM_INFO("AGP %d.%d on %s @ 0x%08lx %ZuMB\n", head->agp_info.version.major, head->agp_info.version.minor, head->chipset, @@ -312,4 +294,35 @@ head->agp_info.aper_size); } return head; +} + +void drm_agp_uninit(void) +{ + DRM_AGP_PUT; + drm_agp = NULL; +} + +agp_memory *drm_agp_allocate_memory(size_t pages, u32 type) +{ + if (!drm_agp->allocate_memory) return NULL; + return drm_agp->allocate_memory(pages, type); +} + +int drm_agp_free_memory(agp_memory *handle) +{ + if (!handle || !drm_agp->free_memory) return 0; + drm_agp->free_memory(handle); + return 1; +} + +int drm_agp_bind_memory(agp_memory *handle, off_t start) +{ + if (!handle || !drm_agp->bind_memory) return -EINVAL; + return drm_agp->bind_memory(handle, start); +} + +int drm_agp_unbind_memory(agp_memory *handle) +{ + if (!handle || !drm_agp->unbind_memory) return -EINVAL; + return drm_agp->unbind_memory(handle); } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c:1.3 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c Tue Sep 26 12:21:23 2000 @@ -126,18 +126,19 @@ if (priv->magic) { auth.magic = priv->magic; } else { - spin_lock(&lock); do { + spin_lock(&lock); if (!sequence) ++sequence; /* reserve 0 */ auth.magic = sequence++; + spin_unlock(&lock); } while (drm_find_file(dev, auth.magic)); - spin_unlock(&lock); priv->magic = auth.magic; drm_add_magic(dev, priv, auth.magic); } DRM_DEBUG("%u\n", auth.magic); - copy_to_user_ret((drm_auth_t *)arg, &auth, sizeof(auth), -EFAULT); + if (copy_to_user((drm_auth_t *)arg, &auth, sizeof(auth))) + return -EFAULT; return 0; } @@ -149,7 +150,8 @@ drm_auth_t auth; drm_file_t *file; - copy_from_user_ret(&auth, (drm_auth_t *)arg, sizeof(auth), -EFAULT); + if (copy_from_user(&auth, (drm_auth_t *)arg, sizeof(auth))) + return -EFAULT; DRM_DEBUG("%u\n", auth.magic); if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c:1.6 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c Tue Sep 26 12:21:23 2000 @@ -72,12 +72,14 @@ switch (map->type) { case _DRM_REGISTERS: - case _DRM_FRAME_BUFFER: + case _DRM_FRAME_BUFFER: +#ifndef __sparc__ if (map->offset + map->size < map->offset || map->offset < virt_to_phys(high_memory)) { drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } +#endif #ifdef CONFIG_MTRR if (map->type == _DRM_FRAME_BUFFER || (map->flags & _DRM_WRITE_COMBINING)) { @@ -104,7 +106,7 @@ dev->lock.hw_lock = map->handle; /* Pointer to lock */ } break; -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) case _DRM_AGP: map->offset = map->offset + dev->agp->base; break; @@ -131,12 +133,13 @@ dev->maplist[dev->map_count-1] = map; up(&dev->struct_sem); - copy_to_user_ret((drm_map_t *)arg, map, sizeof(*map), -EFAULT); + if (copy_to_user((drm_map_t *)arg, map, sizeof(*map))) + return -EFAULT; if (map->type != _DRM_SHM) { - copy_to_user_ret(&((drm_map_t *)arg)->handle, + if (copy_to_user(&((drm_map_t *)arg)->handle, &map->offset, - sizeof(map->offset), - -EFAULT); + sizeof(map->offset))) + return -EFAULT; } return 0; } @@ -164,10 +167,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); @@ -293,10 +296,10 @@ request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); return 0; @@ -322,10 +325,10 @@ ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_info_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) ++count; @@ -336,28 +339,26 @@ if (request.count >= count) { for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) { - copy_to_user_ret(&request.list[count].count, + if (copy_to_user(&request.list[count].count, &dma->bufs[i].buf_count, sizeof(dma->bufs[0] - .buf_count), - -EFAULT); - copy_to_user_ret(&request.list[count].size, + .buf_count)) || + copy_to_user(&request.list[count].size, &dma->bufs[i].buf_size, - sizeof(dma->bufs[0].buf_size), - -EFAULT); - copy_to_user_ret(&request.list[count].low_mark, + sizeof(dma->bufs[0].buf_size)) || + copy_to_user(&request.list[count].low_mark, &dma->bufs[i] .freelist.low_mark, sizeof(dma->bufs[0] - .freelist.low_mark), - -EFAULT); - copy_to_user_ret(&request.list[count] + .freelist.low_mark)) || + copy_to_user(&request.list[count] .high_mark, &dma->bufs[i] .freelist.high_mark, sizeof(dma->bufs[0] - .freelist.high_mark), - -EFAULT); + .freelist.high_mark))) + return -EFAULT; + DRM_DEBUG("%d %d %d %d %d\n", i, dma->bufs[i].buf_count, @@ -370,10 +371,10 @@ } request.count = count; - copy_to_user_ret((drm_buf_info_t *)arg, + if (copy_to_user((drm_buf_info_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return 0; } @@ -390,10 +391,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("%d, %d, %d\n", request.size, request.low_mark, request.high_mark); @@ -425,17 +426,17 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_free_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("%d\n", request.count); for (i = 0; i < request.count; i++) { - copy_from_user_ret(&idx, + if (copy_from_user(&idx, &request.list[i], - sizeof(idx), - -EFAULT); + sizeof(idx))) + return -EFAULT; if (idx < 0 || idx >= dma->buf_count) { DRM_ERROR("Index %d (of %d max)\n", idx, dma->buf_count - 1); @@ -478,14 +479,16 @@ ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_map_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; if (request.count >= dma->buf_count) { + down(¤t->mm->mmap_sem); virtual = do_mmap(filp, 0, dma->byte_count, PROT_READ|PROT_WRITE, MAP_SHARED, 0); + up(¤t->mm->mmap_sem); if (virtual > -1024UL) { /* Real error */ retcode = (signed long)virtual; @@ -525,10 +528,10 @@ request.count = dma->buf_count; DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - copy_to_user_ret((drm_buf_map_t *)arg, + if (copy_to_user((drm_buf_map_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return retcode; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/compat-pre24.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/compat-pre24.h:1.4 --- /dev/null Mon Dec 18 14:31:51 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/compat-pre24.h Fri Dec 1 09:29:01 2000 @@ -0,0 +1,45 @@ +/* compat-pre24.h -- Linux pre-2.4.0 compatibility + * Created: Mon Aug 28 15:31:43 2000 by faith@acm.org + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * + */ + +#ifndef _COMPAT_PRE24_H_ +#define _COMPAT_PRE24_H_ + + /* virt_to_page added in 2.4.0-test6 */ +#if LINUX_VERSION_CODE < 0x020400 +#define virt_to_page(kaddr) (mem_map + MAP_NR(kaddr)) +#endif + +#define block_all_signals(a,b,c) +#define unblock_all_signals() + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) +#define __exit +#endif + +#endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c:1.3 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c Tue Sep 26 12:21:23 2000 @@ -129,19 +129,21 @@ int i; DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -153,7 +155,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = drm_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Init kernel's context and get a new one. */ drm_init_queue(dev, dev->queuelist[ctx.handle], &ctx); @@ -161,7 +164,8 @@ } drm_init_queue(dev, dev->queuelist[ctx.handle], &ctx); DRM_DEBUG("%d\n", ctx.handle); - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -173,7 +177,8 @@ drm_ctx_t ctx; drm_queue_t *q; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); @@ -206,7 +211,8 @@ drm_ctx_t ctx; drm_queue_t *q; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); @@ -223,7 +229,8 @@ ctx.flags = q->flags; atomic_dec(&q->use_count); - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -235,7 +242,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return drm_context_switch(dev, dev->last_context, ctx.handle); } @@ -247,7 +255,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); drm_context_switch_complete(dev, ctx.handle); @@ -263,7 +272,8 @@ drm_queue_t *q; drm_buf_t *buf; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); if (ctx.handle >= dev->queue_count) return -EINVAL; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c:1.11 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c:1.6 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c Fri Dec 1 09:29:01 2000 @@ -397,14 +397,15 @@ atomic_inc(&q->use_count); if (atomic_read(&q->block_write)) { - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&q->write_queue, &entry); atomic_inc(&q->block_count); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!atomic_read(&q->block_write)) break; schedule(); if (signal_pending(current)) { atomic_dec(&q->use_count); + remove_wait_queue(&q->write_queue, &entry); return -EINTR; } } @@ -486,14 +487,16 @@ buf->pending); } buf->pid = current->pid; - copy_to_user_ret(&d->request_indices[i], + if (copy_to_user(&d->request_indices[i], &buf->idx, - sizeof(buf->idx), - -EFAULT); - copy_to_user_ret(&d->request_sizes[i], + sizeof(buf->idx))) + return -EFAULT; + + if (copy_to_user(&d->request_sizes[i], &buf->total, - sizeof(buf->total), - -EFAULT); + sizeof(buf->total))) + return -EFAULT; + ++d->granted_count; } return 0; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c:1.3 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c Tue Sep 26 12:21:23 2000 @@ -39,7 +39,8 @@ draw.handle = 0; /* NOOP */ DRM_DEBUG("%d\n", draw.handle); - copy_to_user_ret((drm_draw_t *)arg, &draw, sizeof(draw), -EFAULT); + if (copy_to_user((drm_draw_t *)arg, &draw, sizeof(draw))) + return -EFAULT; return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h:1.13 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h:1.6 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h Mon Dec 4 14:21:58 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * @@ -35,7 +35,13 @@ #ifndef _DRM_H_ #define _DRM_H_ +#if defined(__linux__) #include <asm/ioctl.h> /* For _IO* macros */ +#define DRM_IOCTL_NR(n) _IOC_NR(n) +#elif defined(__FreeBSD__) +#include <sys/ioccom.h> +#define DRM_IOCTL_NR(n) ((n) & 0xff) +#endif #define DRM_PROC_DEVICES "/proc/devices" #define DRM_PROC_MISC "/proc/misc" @@ -76,6 +82,7 @@ #include "mga_drm.h" #include "i810_drm.h" #include "r128_drm.h" +#include "sis_drm.h" typedef struct drm_version { int version_major; /* Major version */ @@ -289,7 +296,6 @@ } drm_agp_info_t; #define DRM_IOCTL_BASE 'd' -#define DRM_IOCTL_NR(n) _IOC_NR(n) #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) #define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size) #define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size) @@ -353,13 +359,33 @@ #define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44) #define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t) #define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46) +#define DRM_IOCTL_I810_COPY DRM_IOW( 0x47, drm_i810_copy_t) +#define DRM_IOCTL_I810_DOCOPY DRM_IO ( 0x48) /* Rage 128 specific ioctls */ -#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) -#define DRM_IOCTL_R128_RESET DRM_IO( 0x41) -#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43) -#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) -#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) +#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) +#define DRM_IOCTL_R128_CCE_START DRM_IO( 0x41) +#define DRM_IOCTL_R128_CCE_STOP DRM_IOW( 0x42, drm_r128_cce_stop_t) +#define DRM_IOCTL_R128_CCE_RESET DRM_IO( 0x43) +#define DRM_IOCTL_R128_CCE_IDLE DRM_IO( 0x44) +#define DRM_IOCTL_R128_RESET DRM_IO( 0x46) +#define DRM_IOCTL_R128_SWAP DRM_IO( 0x47) +#define DRM_IOCTL_R128_CLEAR DRM_IOW( 0x48, drm_r128_clear_t) +#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x49, drm_r128_vertex_t) +#define DRM_IOCTL_R128_INDICES DRM_IOW( 0x4a, drm_r128_indices_t) +#define DRM_IOCTL_R128_BLIT DRM_IOW( 0x4b, drm_r128_blit_t) +#define DRM_IOCTL_R128_DEPTH DRM_IOW( 0x4c, drm_r128_depth_t) +#define DRM_IOCTL_R128_STIPPLE DRM_IOW( 0x4d, drm_r128_stipple_t) +#define DRM_IOCTL_R128_PACKET DRM_IOWR(0x4e, drm_r128_packet_t) + +/* SiS specific ioctls */ +#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t) +#define SIS_IOCTL_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t) +#define SIS_IOCTL_AGP_INIT DRM_IOWR( 0x53, drm_sis_agp_t) +#define SIS_IOCTL_AGP_ALLOC DRM_IOWR( 0x54, drm_sis_mem_t) +#define SIS_IOCTL_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t) +#define SIS_IOCTL_FLIP DRM_IOW( 0x48, drm_sis_flip_t) +#define SIS_IOCTL_FLIP_INIT DRM_IO( 0x49) +#define SIS_IOCTL_FLIP_FINAL DRM_IO( 0x50) #endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h:1.7 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h:1.14 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h:1.7 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h Fri Dec 1 09:29:01 2000 @@ -33,6 +33,12 @@ #define _DRM_P_H_ #ifdef __KERNEL__ +#ifdef __alpha__ +/* add include of current.h so that "current" is defined + * before static inline funcs in wait.h. Doing this so we + * can build the DRM (part of PI DRI). 4/21/2000 S + B */ +#include <asm/current.h> +#endif /* __alpha__ */ #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -44,20 +50,29 @@ #include <linux/pci.h> #include <linux/wrapper.h> #include <linux/version.h> +#include <linux/sched.h> +#include <linux/smp_lock.h> /* For (un)lock_kernel */ +#include <linux/mm.h> +#ifdef __alpha__ +#include <asm/pgtable.h> /* For pte_wrprotect */ +#endif #include <asm/io.h> #include <asm/mman.h> #include <asm/uaccess.h> #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) #include <linux/types.h> #include <linux/agp_backend.h> #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) +#if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */ #include <linux/tqueue.h> #include <linux/poll.h> #endif +#if LINUX_VERSION_CODE < 0x020400 +#include "compat-pre24.h" +#endif #include "drm.h" #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then @@ -129,10 +144,83 @@ #define NOPAGE_OOM 0 #endif + /* module_init/module_exit added in 2.3.13 */ +#ifndef module_init +#define module_init(x) int init_module(void) { return x(); } +#endif +#ifndef module_exit +#define module_exit(x) void cleanup_module(void) { x(); } +#endif + /* Generic cmpxchg added in 2.3.x */ #ifndef __HAVE_ARCH_CMPXCHG /* Include this here so that driver can be used with older kernels. */ +#if defined(__alpha__) +static __inline__ unsigned long +__cmpxchg_u32(volatile int *m, int old, int new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldl_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stl_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldq_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stq_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) +{ + switch (size) { + case 4: + return __cmpxchg_u32(ptr, old, new); + case 8: + return __cmpxchg_u64(ptr, old, new); + } + return old; +} +#define cmpxchg(ptr,o,n) \ + ({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ + (unsigned long)_n_, sizeof(*(ptr))); \ + }) + +#elif __i386__ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { @@ -163,6 +251,7 @@ #define cmpxchg(ptr,o,n) \ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ (unsigned long)(n),sizeof(*(ptr)))) +#endif /* i386 & alpha */ #endif /* Macros to make printk easier */ @@ -312,6 +401,7 @@ int low_mark; /* Low water mark */ int high_mark; /* High water mark */ atomic_t wfh; /* If waiting for high mark */ + spinlock_t lock; } drm_freelist_t; typedef struct drm_buf_entry { @@ -340,6 +430,7 @@ struct drm_file *next; struct drm_file *prev; struct drm_device *dev; + int remove_auth_on_close; } drm_file_t; @@ -399,7 +490,7 @@ wait_queue_head_t waiting; /* Processes waiting on free bufs */ } drm_device_dma_t; -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) typedef struct drm_agp_mem { unsigned long handle; agp_memory *memory; @@ -419,21 +510,13 @@ unsigned long base; int agp_mtrr; } drm_agp_head_t; - -typedef struct { - void (*free_memory)(agp_memory *); - agp_memory *(*allocate_memory)(size_t, u32); - int (*bind_memory)(agp_memory *, off_t); - int (*unbind_memory)(agp_memory *); - void (*enable)(u32); - int (*acquire)(void); - void (*release)(void); - void (*copy_info)(agp_kern_info *); -} drm_agp_func_t; - -extern drm_agp_func_t drm_agp; #endif +typedef struct drm_sigdata { + int context; + drm_hw_lock_t *lock; +} drm_sigdata_t; + typedef struct drm_device { const char *name; /* Simple driver name */ char *unique; /* Unique identifier: e.g., busid */ @@ -488,9 +571,9 @@ /* Context support */ int irq; /* Interrupt used by board */ - __volatile__ int context_flag; /* Context swapping flag */ - __volatile__ int interrupt_flag;/* Interruption handler flag */ - __volatile__ int dma_flag; /* DMA dispatch flag */ + __volatile__ long context_flag; /* Context swapping flag */ + __volatile__ long interrupt_flag; /* Interruption handler flag */ + __volatile__ long dma_flag; /* DMA dispatch flag */ struct timer_list timer; /* Timer for delaying ctx switch */ wait_queue_head_t context_wait; /* Processes waiting on ctx switch */ int last_checked; /* Last context checked for DMA */ @@ -513,11 +596,13 @@ wait_queue_head_t buf_readers; /* Processes waiting to read */ wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */ -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) drm_agp_head_t *agp; #endif unsigned long *ctx_bitmap; void *dev_private; + drm_sigdata_t sigdata; /* For block_all_signals */ + sigset_t sigmask; } drm_device_t; @@ -548,6 +633,9 @@ extern unsigned long drm_vm_shm_nopage(struct vm_area_struct *vma, unsigned long address, int write_access); +extern unsigned long drm_vm_shm_nopage_lock(struct vm_area_struct *vma, + unsigned long address, + int write_access); extern unsigned long drm_vm_dma_nopage(struct vm_area_struct *vma, unsigned long address, int write_access); @@ -559,6 +647,9 @@ extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma, unsigned long address, int write_access); +extern struct page *drm_vm_shm_nopage_lock(struct vm_area_struct *vma, + unsigned long address, + int write_access); extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma, unsigned long address, int write_access); @@ -590,7 +681,7 @@ extern void *drm_ioremap(unsigned long offset, unsigned long size); extern void drm_ioremapfree(void *pt, unsigned long size); -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) extern agp_memory *drm_alloc_agp(int pages, u32 type); extern int drm_free_agp(agp_memory *handle, int pages); extern int drm_bind_agp(agp_memory *handle, unsigned int start); @@ -633,7 +724,6 @@ extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid); extern int drm_context_switch(drm_device_t *dev, int old, int new); extern int drm_context_switch_complete(drm_device_t *dev, int new); -extern void drm_wakeup(drm_device_t *dev, drm_buf_t *buf); extern void drm_clear_next_buffer(drm_device_t *dev); extern int drm_select_queue(drm_device_t *dev, void (*wrapper)(unsigned long)); @@ -707,6 +797,7 @@ drm_lock_flags_t flags); extern int drm_flush_block_and_flush(drm_device_t *dev, int context, drm_lock_flags_t flags); +extern int drm_notifier(void *priv); /* Context Bitmap support (ctxbitmap.c) */ extern int drm_ctxbitmap_init(drm_device_t *dev); @@ -714,11 +805,13 @@ extern int drm_ctxbitmap_next(drm_device_t *dev); extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle); -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) /* AGP/GART support (agpsupport.c) */ extern drm_agp_head_t *drm_agp_init(void); +extern void drm_agp_uninit(void); extern int drm_agp_acquire(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern void _drm_agp_release(void); extern int drm_agp_release(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int drm_agp_enable(struct inode *inode, struct file *filp, @@ -733,6 +826,10 @@ unsigned int cmd, unsigned long arg); extern int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern agp_memory *drm_agp_allocate_memory(size_t pages, u32 type); +extern int drm_agp_free_memory(agp_memory *handle); +extern int drm_agp_bind_memory(agp_memory *handle, off_t start); +extern int drm_agp_unbind_memory(agp_memory *handle); #endif #endif #endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c:1.11 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c:1.7 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c Tue Sep 26 12:21:23 2000 @@ -94,7 +94,8 @@ DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n", current->pid, dev->device, dev->open_count); - if (_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) + if (dev->lock.hw_lock + && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && dev->lock.pid == current->pid) { DRM_ERROR("Process %d dead, freeing lock for context %d\n", current->pid, @@ -175,7 +176,8 @@ } else { cur = DRM_MIN(send, dev->buf_end - dev->buf_rp); } - copy_to_user_ret(buf, dev->buf_rp, cur, -EINVAL); + if (copy_to_user(buf, dev->buf_rp, cur)) + return -EFAULT; dev->buf_rp += cur; if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf; send -= cur; @@ -222,8 +224,15 @@ KILLFASYNCHASTHREEPARAMETERS if three parameters are found. */ if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO); #else - /* Parameter added in 2.3.21 */ + + /* Parameter added in 2.3.21. */ +#if LINUX_VERSION_CODE < 0x020400 if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO, POLL_IN); +#else + /* Type of first parameter changed in + Linux 2.4.0-test2... */ + if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN); +#endif #endif DRM_DEBUG("waking\n"); wake_up_interruptible(&dev->buf_readers); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c:1.4 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c:1.4 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c Wed Nov 8 00:03:06 2000 @@ -542,10 +542,9 @@ if (d->flags & _DRM_DMA_BLOCK) { DRM_DEBUG("%d waiting\n", current->pid); - current->state = TASK_INTERRUPTIBLE; for (;;) { - if (!last_buf->waiting - && !last_buf->pending) + current->state = TASK_INTERRUPTIBLE; + if (!last_buf->waiting && !last_buf->pending) break; /* finished */ schedule(); if (signal_pending(current)) { @@ -586,7 +585,8 @@ int retcode = 0; drm_dma_t d; - copy_from_user_ret(&d, (drm_dma_t *)arg, sizeof(d), -EFAULT); + if (copy_from_user(&d, (drm_dma_t *)arg, sizeof(d))) + return -EFAULT; DRM_DEBUG("%d %d: %d send, %d req\n", current->pid, d.context, d.send_count, d.request_count); @@ -621,7 +621,8 @@ DRM_DEBUG("%d returning, granted = %d\n", current->pid, d.granted_count); - copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d))) + return -EFAULT; return retcode; } @@ -710,7 +711,8 @@ drm_control_t ctl; int retcode; - copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) + return -EFAULT; switch (ctl.func) { case DRM_INST_HANDLER: @@ -742,7 +744,8 @@ dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -774,6 +777,7 @@ } add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -790,7 +794,6 @@ /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -804,6 +807,15 @@ drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */ if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_READY) gamma_dma_ready(dev); if (lock.flags & _DRM_LOCK_QUIESCENT) { Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c:1.11 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c:1.6 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c Fri Dec 1 09:29:01 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,19 +23,15 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * */ #include <linux/config.h> -#define EXPORT_SYMTAB #include "drmP.h" #include "gamma_drv.h" -#include <linux/pci.h> -EXPORT_SYMBOL(gamma_init); -EXPORT_SYMBOL(gamma_cleanup); #ifndef PCI_DEVICE_ID_3DLABS_GAMMA #define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008 @@ -46,7 +42,7 @@ #define GAMMA_NAME "gamma" #define GAMMA_DESC "3dlabs GMX 2000" -#define GAMMA_DATE "20000606" +#define GAMMA_DATE "20000910" #define GAMMA_MAJOR 1 #define GAMMA_MINOR 0 #define GAMMA_PATCHLEVEL 0 @@ -54,6 +50,10 @@ static drm_device_t gamma_device; static struct file_operations gamma_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif open: gamma_open, flush: drm_flush, release: gamma_release, @@ -87,7 +87,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, - + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 }, @@ -105,55 +105,36 @@ #define GAMMA_IOCTL_COUNT DRM_ARRAY_SIZE(gamma_ioctls) #ifdef MODULE -int init_module(void); -void cleanup_module(void); static char *gamma = NULL; +#endif static int devices = 0; -MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); +MODULE_AUTHOR("VA Linux Systems, Inc."); MODULE_DESCRIPTION("3dlabs GMX 2000"); MODULE_PARM(gamma, "s"); MODULE_PARM(devices, "i"); -MODULE_PARM_DESC(devices, "devices=x, where x is the number of MX chips on your card\n"); - -/* init_module is called when insmod is used to load the module */ - -int init_module(void) -{ - return gamma_init(); -} +MODULE_PARM_DESC(devices, + "devices=x, where x is the number of MX chips on card\n"); +#ifndef MODULE +/* gamma_options is called by the kernel to parse command-line options + * passed via the boot-loader (e.g., LILO). It calls the insmod option + * routine, drm_parse_options. + */ -/* cleanup_module is called when rmmod is used to unload the module */ -void cleanup_module(void) +static int __init gamma_options(char *str) { - gamma_cleanup(); -} -#endif - -#ifndef MODULE -/* gamma_setup is called by the kernel to parse command-line options passed - * via the boot-loader (e.g., LILO). It calls the insmod option routine, - * drm_parse_options. - * - * This is not currently supported, since it requires changes to - * linux/init/main.c. */ - - -void __init gamma_setup(char *str, int *ints) -{ - if (ints[0] != 0) { - DRM_ERROR("Illegal command line format, ignored\n"); - return; - } drm_parse_options(str); + return 1; } + +__setup("gamma=", gamma_options); #endif static int gamma_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -198,22 +179,22 @@ #endif dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -228,15 +209,15 @@ DRM_DEBUG("\n"); if (dev->irq) gamma_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -250,7 +231,7 @@ } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } - + /* Clear vma list (only built for debugging) */ if (dev->vmalist) { for (vma = dev->vmalist; vma; vma = vma_next) { @@ -259,7 +240,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -284,12 +265,10 @@ - PAGE_SHIFT, DRM_MEM_SAREA); break; -#ifdef DRM_AGP case _DRM_AGP: /* Do nothing here, because this is all handled in the AGP/GART driver. */ break; -#endif } drm_free(map, sizeof(*map), DRM_MEM_MAPS); } @@ -299,7 +278,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -325,7 +304,7 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -360,7 +339,7 @@ /* gamma_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ -int gamma_init(void) +static int __init gamma_init(void) { int retcode; drm_device_t *dev = &gamma_device; @@ -370,7 +349,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(gamma); #endif @@ -395,18 +374,18 @@ GAMMA_DATE, gamma_misc.minor, devices); - + return 0; } /* gamma_cleanup is called via cleanup_module at module unload time. */ -void gamma_cleanup(void) +static void __exit gamma_cleanup(void) { drm_device_t *dev = &gamma_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&gamma_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -416,23 +395,28 @@ gamma_takedown(dev); } +module_init(gamma_init); +module_exit(gamma_cleanup); + + int gamma_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = GAMMA_MAJOR; @@ -443,10 +427,10 @@ DRM_COPY(version.date, GAMMA_DATE); DRM_COPY(version.desc, GAMMA_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -454,10 +438,12 @@ { drm_device_t *dev = &gamma_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_open); spin_lock(&dev->count_lock); if (!dev->open_count++) { @@ -472,12 +458,17 @@ int gamma_release(struct inode *inode, struct file *filp) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_device_t *dev; int retcode = 0; + lock_kernel(); + dev = priv->dev; + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_release(inode, filp))) { - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_close); spin_lock(&dev->count_lock); if (!--dev->open_count) { @@ -486,13 +477,16 @@ atomic_read(&dev->ioctl_count), dev->blocked); spin_unlock(&dev->count_lock); + unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); + unlock_kernel(); return gamma_takedown(dev); } spin_unlock(&dev->count_lock); } + unlock_kernel(); return retcode; } @@ -511,7 +505,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -531,7 +525,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -544,8 +538,9 @@ drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -570,6 +565,7 @@ atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() - dev->lck_start)]); #endif - + + unblock_all_signals(); return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h:1.4 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h:1.4 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h Tue Sep 26 12:21:24 2000 @@ -25,7 +25,7 @@ * DEALINGS IN THE SOFTWARE. * * Authors: - * Rickard E. (Rik) Faith <faith@precisioninsight.com> + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -33,8 +33,6 @@ #define _GAMMA_DRV_H_ /* gamma_drv.c */ -extern int gamma_init(void); -extern void gamma_cleanup(void); extern int gamma_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int gamma_open(struct inode *inode, struct file *filp); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c:1.2 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c Tue Sep 26 12:21:24 2000 @@ -56,10 +56,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); @@ -155,10 +155,10 @@ request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); dma->flags = _DRM_DMA_USE_AGP; @@ -170,10 +170,10 @@ { drm_buf_desc_t request; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; if(request.flags & _DRM_AGP_BUFFER) return i810_addbufs_agp(inode, filp, cmd, arg); @@ -201,10 +201,10 @@ ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_info_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) ++count; @@ -215,28 +215,26 @@ if (request.count >= count) { for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) { - copy_to_user_ret(&request.list[count].count, + if (copy_to_user(&request.list[count].count, &dma->bufs[i].buf_count, sizeof(dma->bufs[0] - .buf_count), - -EFAULT); - copy_to_user_ret(&request.list[count].size, + .buf_count)) || + copy_to_user(&request.list[count].size, &dma->bufs[i].buf_size, - sizeof(dma->bufs[0].buf_size), - -EFAULT); - copy_to_user_ret(&request.list[count].low_mark, + sizeof(dma->bufs[0].buf_size)) || + copy_to_user(&request.list[count].low_mark, &dma->bufs[i] .freelist.low_mark, sizeof(dma->bufs[0] - .freelist.low_mark), - -EFAULT); - copy_to_user_ret(&request.list[count] + .freelist.low_mark)) || + copy_to_user(&request.list[count] .high_mark, &dma->bufs[i] .freelist.high_mark, sizeof(dma->bufs[0] - .freelist.high_mark), - -EFAULT); + .freelist.high_mark))) + return -EFAULT; + DRM_DEBUG("%d %d %d %d %d\n", i, dma->bufs[i].buf_count, @@ -249,10 +247,10 @@ } request.count = count; - copy_to_user_ret((drm_buf_info_t *)arg, + if (copy_to_user((drm_buf_info_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return 0; } @@ -269,10 +267,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("%d, %d, %d\n", request.size, request.low_mark, request.high_mark); @@ -304,17 +302,17 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_free_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("%d\n", request.count); for (i = 0; i < request.count; i++) { - copy_from_user_ret(&idx, + if (copy_from_user(&idx, &request.list[i], - sizeof(idx), - -EFAULT); + sizeof(idx))) + return -EFAULT; if (idx < 0 || idx >= dma->buf_count) { DRM_ERROR("Index %d (of %d max)\n", idx, dma->buf_count - 1); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c:1.1 Fri Jun 16 20:03:35 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c Tue Sep 26 12:21:24 2000 @@ -29,8 +29,6 @@ * */ -#include <linux/sched.h> - #define __NO_VERSION__ #include "drmP.h" #include "i810_drv.h" @@ -105,19 +103,21 @@ int i; DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -128,7 +128,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = i810_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Skip kernel's context and get a new one. */ ctx.handle = i810_alloc_queue(dev); @@ -139,7 +140,8 @@ return -ENOMEM; } DRM_DEBUG("%d\n", ctx.handle); - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -155,10 +157,12 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; /* This is 0, because we don't hanlde any context flags */ ctx.flags = 0; - copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -169,7 +173,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return i810_context_switch(dev, dev->last_context, ctx.handle); } @@ -181,7 +186,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); i810_context_switch_complete(dev, ctx.handle); @@ -195,7 +201,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); if(ctx.handle != DRM_KERNEL_CONTEXT) { drm_ctxbitmap_free(dev, ctx.handle); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c:1.9 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c:1.3 Thu Jun 22 10:26:19 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c Wed Nov 8 00:03:06 2000 @@ -33,7 +33,6 @@ #define __NO_VERSION__ #include "drmP.h" #include "i810_drv.h" - #include <linux/interrupt.h> /* For task queue support */ /* in case we don't have a 2.3.99-pre6 kernel or later: */ @@ -156,16 +155,23 @@ int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_i810_private_t *dev_priv = dev->dev_private; - drm_buf_t *buf = dev_priv->mmap_buffer; - drm_i810_buf_priv_t *buf_priv = buf->dev_private; + drm_file_t *priv = filp->private_data; + drm_device_t *dev; + drm_i810_private_t *dev_priv; + drm_buf_t *buf; + drm_i810_buf_priv_t *buf_priv; + + lock_kernel(); + dev = priv->dev; + dev_priv = dev->dev_private; + buf = dev_priv->mmap_buffer; + buf_priv = buf->dev_private; vma->vm_flags |= (VM_IO | VM_DONTCOPY); vma->vm_file = filp; buf_priv->currently_mapped = I810_BUF_MAPPED; + unlock_kernel(); if (remap_page_range(vma->vm_start, VM_OFFSET(vma), @@ -184,23 +190,29 @@ int retcode = 0; if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL; - down(¤t->mm->mmap_sem); - old_fops = filp->f_op; - filp->f_op = &i810_buffer_fops; - dev_priv->mmap_buffer = buf; - buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, - PROT_READ|PROT_WRITE, - MAP_SHARED, - buf->bus_address); - dev_priv->mmap_buffer = NULL; - filp->f_op = old_fops; - if ((unsigned long)buf_priv->virtual > -1024UL) { - /* Real error */ - DRM_DEBUG("mmap error\n"); - retcode = (signed int)buf_priv->virtual; - buf_priv->virtual = 0; + + if(VM_DONTCOPY != 0) { + down(¤t->mm->mmap_sem); + old_fops = filp->f_op; + filp->f_op = &i810_buffer_fops; + dev_priv->mmap_buffer = buf; + buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, + PROT_READ|PROT_WRITE, + MAP_SHARED, + buf->bus_address); + dev_priv->mmap_buffer = NULL; + filp->f_op = old_fops; + if ((unsigned long)buf_priv->virtual > -1024UL) { + /* Real error */ + DRM_DEBUG("mmap error\n"); + retcode = (signed int)buf_priv->virtual; + buf_priv->virtual = 0; + } + up(¤t->mm->mmap_sem); + } else { + buf_priv->virtual = buf_priv->kernel_virtual; + buf_priv->currently_mapped = I810_BUF_MAPPED; } - up(¤t->mm->mmap_sem); return retcode; } @@ -209,13 +221,22 @@ drm_i810_buf_priv_t *buf_priv = buf->dev_private; int retcode = 0; - if(buf_priv->currently_mapped != I810_BUF_MAPPED) return -EINVAL; - down(¤t->mm->mmap_sem); - retcode = do_munmap(current->mm, (unsigned long)buf_priv->virtual, - (size_t) buf->total); + if(VM_DONTCOPY != 0) { + if(buf_priv->currently_mapped != I810_BUF_MAPPED) + return -EINVAL; + down(¤t->mm->mmap_sem); +#if LINUX_VERSION_CODE < 0x020399 + retcode = do_munmap((unsigned long)buf_priv->virtual, + (size_t) buf->total); +#else + retcode = do_munmap(current->mm, + (unsigned long)buf_priv->virtual, + (size_t) buf->total); +#endif + up(¤t->mm->mmap_sem); + } buf_priv->currently_mapped = I810_BUF_UNMAPPED; buf_priv->virtual = 0; - up(¤t->mm->mmap_sem); return retcode; } @@ -231,16 +252,15 @@ buf = i810_freelist_get(dev); if (!buf) { retcode = -ENOMEM; - DRM_DEBUG("%s retcode %d\n", __FUNCTION__, retcode); - goto out_get_buf; + DRM_DEBUG("retcode=%d\n", retcode); + return retcode; } retcode = i810_map_buffer(buf, filp); if(retcode) { i810_freelist_put(dev, buf); - DRM_DEBUG("mapbuf failed in %s retcode %d\n", - __FUNCTION__, retcode); - goto out_get_buf; + DRM_DEBUG("mapbuf failed, retcode %d\n", retcode); + return retcode; } buf->pid = priv->pid; buf_priv = buf->dev_private; @@ -249,7 +269,6 @@ d->request_size = buf->total; d->virtual = buf_priv->virtual; -out_get_buf: return retcode; } @@ -261,8 +280,8 @@ if(address == 0UL) return 0; - atomic_inc(&mem_map[MAP_NR((void *) address)].count); - set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags); + atomic_inc(&virt_to_page(address)->count); + set_bit(PG_locked, &virt_to_page(address)->flags); return address; } @@ -272,9 +291,9 @@ if(page == 0UL) return; - atomic_dec(&mem_map[MAP_NR((void *) page)].count); - clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags); - wake_up(&mem_map[MAP_NR((void *) page)].wait); + atomic_dec(&virt_to_page(page)->count); + clear_bit(PG_locked, &virt_to_page(page)->flags); + wake_up(&virt_to_page(page)->wait); free_page(page); return; } @@ -469,8 +488,8 @@ drm_i810_init_t init; int retcode = 0; - copy_from_user_ret(&init, (drm_i810_init_t *)arg, - sizeof(init), -EFAULT); + if (copy_from_user(&init, (drm_i810_init_t *)arg, sizeof(init))) + return -EFAULT; switch(init.func) { case I810_INIT_DMA: @@ -984,7 +1003,8 @@ DRM_DEBUG( "i810_control\n"); - copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) + return -EFAULT; switch (ctl.func) { case DRM_INST_HANDLER: @@ -1047,11 +1067,11 @@ return; } atomic_set(&dev_priv->flush_done, 0); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); end = jiffies + (HZ*3); for (;;) { + current->state = TASK_INTERRUPTIBLE; i810_dma_quiescent_emit(dev); if (atomic_read(&dev_priv->flush_done) == 1) break; if((signed)(end - jiffies) <= 0) { @@ -1082,10 +1102,10 @@ return 0; } atomic_set(&dev_priv->flush_done, 0); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); end = jiffies + (HZ*3); for (;;) { + current->state = TASK_INTERRUPTIBLE; i810_dma_emit_flush(dev); if (atomic_read(&dev_priv->flush_done) == 1) break; if((signed)(end - jiffies) <= 0) { @@ -1157,7 +1177,8 @@ int ret = 0; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -1178,6 +1199,7 @@ if (!ret) { add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -1193,7 +1215,6 @@ /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; DRM_DEBUG("Calling lock schedule\n"); schedule(); if (signal_pending(current)) { @@ -1206,6 +1227,15 @@ } if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_QUIESCENT) { DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); DRM_DEBUG("fred\n"); @@ -1245,8 +1275,8 @@ dev_priv->sarea_priv; drm_i810_vertex_t vertex; - copy_from_user_ret(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex), - -EFAULT); + if (copy_from_user(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma_vertex called without lock held\n"); @@ -1277,8 +1307,8 @@ drm_device_t *dev = priv->dev; drm_i810_clear_t clear; - copy_from_user_ret(&clear, (drm_i810_clear_t *)arg, sizeof(clear), - -EFAULT); + if (copy_from_user(&clear, (drm_i810_clear_t *)arg, sizeof(clear))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_clear_bufs called without lock held\n"); @@ -1335,7 +1365,8 @@ dev_priv->sarea_priv; DRM_DEBUG("getbuf\n"); - copy_from_user_ret(&d, (drm_i810_dma_t *)arg, sizeof(d), -EFAULT); + if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma called without lock held\n"); @@ -1349,8 +1380,51 @@ DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", current->pid, retcode, d.granted); - copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d))) + return -EFAULT; sarea_priv->last_dispatch = (int) hw_status[5]; return retcode; +} + +int i810_copybuf(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_copy_t d; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = (u32 *)dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; + drm_buf_t *buf; + drm_i810_buf_priv_t *buf_priv; + drm_device_dma_t *dma = dev->dma; + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_dma called without lock held\n"); + return -EINVAL; + } + + if (copy_from_user(&d, (drm_i810_copy_t *)arg, sizeof(d))) + return -EFAULT; + + if(d.idx > dma->buf_count) return -EINVAL; + buf = dma->buflist[ d.idx ]; + buf_priv = buf->dev_private; + if (buf_priv->currently_mapped != I810_BUF_MAPPED) return -EPERM; + + if (copy_from_user(buf_priv->virtual, d.address, d.used)) + return -EFAULT; + + sarea_priv->last_dispatch = (int) hw_status[5]; + + return 0; +} + +int i810_docopy(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + if(VM_DONTCOPY == 0) return 1; + return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h:1.2 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h:1.1 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h Wed Aug 2 22:30:26 2000 @@ -178,6 +178,12 @@ int discard; /* client is finished with the buffer? */ } drm_i810_vertex_t; +typedef struct _drm_i810_copy_t { + int idx; /* buffer index */ + int used; /* nr bytes in use */ + void *address; /* Address to copy from */ +} drm_i810_copy_t; + typedef struct drm_i810_dma { void *virtual; int request_idx; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c:1.9 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c:1.2 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c Fri Dec 1 09:29:01 2000 @@ -1,6 +1,6 @@ /* i810_drv.c -- I810 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -30,25 +30,24 @@ */ #include <linux/config.h> -#define EXPORT_SYMTAB #include "drmP.h" #include "i810_drv.h" - -EXPORT_SYMBOL(i810_init); -EXPORT_SYMBOL(i810_cleanup); - #define I810_NAME "i810" #define I810_DESC "Intel I810" -#define I810_DATE "19991213" +#define I810_DATE "20000928" #define I810_MAJOR 1 -#define I810_MINOR 0 +#define I810_MINOR 1 #define I810_PATCHLEVEL 0 static drm_device_t i810_device; drm_ctx_t i810_res_ctx; static struct file_operations i810_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif open: i810_open, flush: drm_flush, release: i810_release, @@ -112,58 +111,39 @@ [DRM_IOCTL_NR(DRM_IOCTL_I810_GETAGE)] = { i810_getage, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_I810_GETBUF)] = { i810_getbuf, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_I810_SWAP)] = { i810_swap_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_COPY)] = { i810_copybuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_DOCOPY)] = { i810_docopy, 1, 0 }, }; #define I810_IOCTL_COUNT DRM_ARRAY_SIZE(i810_ioctls) #ifdef MODULE -int init_module(void); -void cleanup_module(void); static char *i810 = NULL; +#endif -MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); +MODULE_AUTHOR("VA Linux Systems, Inc."); MODULE_DESCRIPTION("Intel I810"); MODULE_PARM(i810, "s"); -/* init_module is called when insmod is used to load the module */ - -int init_module(void) -{ - DRM_DEBUG("doing i810_init()\n"); - return i810_init(); -} - -/* cleanup_module is called when rmmod is used to unload the module */ - -void cleanup_module(void) -{ - i810_cleanup(); -} -#endif - #ifndef MODULE -/* i810_setup is called by the kernel to parse command-line options passed - * via the boot-loader (e.g., LILO). It calls the insmod option routine, - * drm_parse_drm. - * - * This is not currently supported, since it requires changes to - * linux/init/main.c. */ - +/* i810_options is called by the kernel to parse command-line options + * passed via the boot-loader (e.g., LILO). It calls the insmod option + * routine, drm_parse_drm. + */ -void __init i810_setup(char *str, int *ints) +static int __init i810_options(char *str) { - if (ints[0] != 0) { - DRM_ERROR("Illegal command line format, ignored\n"); - return; - } drm_parse_options(str); + return 1; } + +__setup("i810=", i810_options); #endif static int i810_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -208,22 +188,22 @@ #endif dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -238,15 +218,15 @@ DRM_DEBUG("\n"); if (dev->irq) i810_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -264,7 +244,7 @@ if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until r128_cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -274,10 +254,9 @@ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - - if (dev->agp->acquired && drm_agp.release) - (*drm_agp.release)(); - + + if (dev->agp->acquired) _drm_agp_release(); + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -289,7 +268,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -325,7 +304,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -351,14 +330,14 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } /* i810_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ -int i810_init(void) +static int __init i810_init(void) { int retcode; drm_device_t *dev = &i810_device; @@ -368,7 +347,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(i810); #endif @@ -417,12 +396,12 @@ /* i810_cleanup is called via cleanup_module at module unload time. */ -void i810_cleanup(void) +static void __exit i810_cleanup(void) { drm_device_t *dev = &i810_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&i810_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -432,28 +411,34 @@ drm_ctxbitmap_cleanup(dev); i810_takedown(dev); if (dev->agp) { + drm_agp_uninit(); drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); dev->agp = NULL; } } +module_init(i810_init); +module_exit(i810_cleanup); + + int i810_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = I810_MAJOR; @@ -464,10 +449,10 @@ DRM_COPY(version.date, I810_DATE); DRM_COPY(version.desc, I810_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -475,10 +460,12 @@ { drm_device_t *dev = &i810_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_open); spin_lock(&dev->count_lock); if (!dev->open_count++) { @@ -493,9 +480,11 @@ int i810_release(struct inode *inode, struct file *filp) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_device_t *dev; int retcode = 0; + lock_kernel(); + dev = priv->dev; DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n", current->pid, dev->device, dev->open_count); @@ -508,7 +497,7 @@ drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - + /* FIXME: may require heavy-handed reset of hardware at this point, possibly processed via a callback to the X @@ -518,6 +507,7 @@ DECLARE_WAITQUEUE(entry, current); add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ retcode = -EINTR; @@ -529,10 +519,9 @@ dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { retcode = -ERESTARTSYS; @@ -555,9 +544,11 @@ if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_close); spin_lock(&dev->count_lock); if (!--dev->open_count) { @@ -566,12 +557,15 @@ atomic_read(&dev->ioctl_count), dev->blocked); spin_unlock(&dev->count_lock); + unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); - return i810_takedown(dev); + unlock_kernel(); + return i810_takedown(dev); } - spin_unlock(&dev->count_lock); + spin_unlock(&dev->count_lock); + unlock_kernel(); return retcode; } @@ -590,7 +584,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -610,7 +604,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -621,9 +615,10 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_lock_t lock; + + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -647,6 +642,7 @@ atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() - dev->lck_start)]); #endif - + + unblock_all_signals(); return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h:1.2 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h Tue Sep 26 12:21:24 2000 @@ -77,8 +77,6 @@ } drm_i810_private_t; /* i810_drv.c */ -extern int i810_init(void); -extern void i810_cleanup(void); extern int i810_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int i810_open(struct inode *inode, struct file *filp); @@ -106,7 +104,10 @@ extern int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma); - +extern int i810_copybuf(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_docopy(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); /* i810_bufs.c */ extern int i810_addbufs(struct inode *inode, struct file *filp, Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c:1.3 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c Tue Sep 26 12:21:24 2000 @@ -97,10 +97,17 @@ } } +/* drm_cpu_valid returns non-zero if the DRI will run on this CPU, and 0 + * otherwise. */ + int drm_cpu_valid(void) { #if defined(__i386__) if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ +#endif +#if defined(__sparc__) && !defined(__sparc_v9__) + if (1) + return 0; /* No cmpxchg before v9 sparc. */ #endif return 1; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c:1.3 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c Tue Sep 26 12:21:24 2000 @@ -38,13 +38,15 @@ drm_irq_busid_t p; struct pci_dev *dev; - copy_from_user_ret(&p, (drm_irq_busid_t *)arg, sizeof(p), -EFAULT); + if (copy_from_user(&p, (drm_irq_busid_t *)arg, sizeof(p))) + return -EFAULT; dev = pci_find_slot(p.busnum, PCI_DEVFN(p.devnum, p.funcnum)); if (dev) p.irq = dev->irq; else p.irq = 0; DRM_DEBUG("%d:%d:%d => IRQ %d\n", p.busnum, p.devnum, p.funcnum, p.irq); - copy_to_user_ret((drm_irq_busid_t *)arg, &p, sizeof(p), -EFAULT); + if (copy_to_user((drm_irq_busid_t *)arg, &p, sizeof(p))) + return -EFAULT; return 0; } @@ -55,13 +57,15 @@ drm_device_t *dev = priv->dev; drm_unique_t u; - copy_from_user_ret(&u, (drm_unique_t *)arg, sizeof(u), -EFAULT); + if (copy_from_user(&u, (drm_unique_t *)arg, sizeof(u))) + return -EFAULT; if (u.unique_len >= dev->unique_len) { - copy_to_user_ret(u.unique, dev->unique, dev->unique_len, - -EFAULT); + if (copy_to_user(u.unique, dev->unique, dev->unique_len)) + return -EFAULT; } u.unique_len = dev->unique_len; - copy_to_user_ret((drm_unique_t *)arg, &u, sizeof(u), -EFAULT); + if (copy_to_user((drm_unique_t *)arg, &u, sizeof(u))) + return -EFAULT; return 0; } @@ -72,15 +76,19 @@ drm_device_t *dev = priv->dev; drm_unique_t u; - if (dev->unique_len || dev->unique) return -EBUSY; + if (dev->unique_len || dev->unique) + return -EBUSY; - copy_from_user_ret(&u, (drm_unique_t *)arg, sizeof(u), -EFAULT); - if (!u.unique_len) return -EINVAL; + if (copy_from_user(&u, (drm_unique_t *)arg, sizeof(u))) + return -EFAULT; + + if (!u.unique_len) + return -EINVAL; dev->unique_len = u.unique_len; dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER); - copy_from_user_ret(dev->unique, u.unique, dev->unique_len, - -EFAULT); + if (copy_from_user(dev->unique, u.unique, dev->unique_len)) + return -EFAULT; dev->unique[dev->unique_len] = '\0'; dev->devname = drm_alloc(strlen(dev->name) + strlen(dev->unique) + 2, Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c:1.11 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c:1.7 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c Wed Nov 8 00:03:06 2000 @@ -34,7 +34,6 @@ int drm_waitlist_create(drm_waitlist_t *bl, int count) { - DRM_DEBUG("%d\n", count); if (bl->count) return -EINVAL; bl->count = count; @@ -50,7 +49,6 @@ int drm_waitlist_destroy(drm_waitlist_t *bl) { - DRM_DEBUG("\n"); if (bl->rp != bl->wp) return -EINVAL; if (bl->bufs) drm_free(bl->bufs, (bl->count + 2) * sizeof(*bl->bufs), @@ -69,8 +67,6 @@ unsigned long flags; left = DRM_LEFTCOUNT(bl); - DRM_DEBUG("put %d (%d left, rp = %p, wp = %p)\n", - buf->idx, left, bl->rp, bl->wp); if (!left) { DRM_ERROR("Overflow while adding buffer %d from pid %d\n", buf->idx, buf->pid); @@ -103,26 +99,24 @@ if (++bl->rp >= bl->end) bl->rp = bl->bufs; spin_unlock_irqrestore(&bl->read_lock, flags); - DRM_DEBUG("get %d\n", buf->idx); return buf; } int drm_freelist_create(drm_freelist_t *bl, int count) { - DRM_DEBUG("\n"); atomic_set(&bl->count, 0); bl->next = NULL; init_waitqueue_head(&bl->waiting); bl->low_mark = 0; bl->high_mark = 0; atomic_set(&bl->wfh, 0); + bl->lock = SPIN_LOCK_UNLOCKED; ++bl->initialized; return 0; } int drm_freelist_destroy(drm_freelist_t *bl) { - DRM_DEBUG("\n"); atomic_set(&bl->count, 0); bl->next = NULL; return 0; @@ -130,8 +124,6 @@ int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) { - drm_buf_t *old, *prev; - int count = 0; drm_device_dma_t *dma = dev->dma; if (!dma) { @@ -143,24 +135,18 @@ DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n", buf->idx, buf->waiting, buf->pending, buf->list); } - DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n", - buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh), - buf->waiting, buf->pending); if (!bl) return 1; #if DRM_DMA_HISTOGRAM buf->time_freed = get_cycles(); drm_histogram_compute(dev, buf); #endif buf->list = DRM_LIST_FREE; - do { - old = bl->next; - buf->next = old; - prev = cmpxchg(&bl->next, old, buf); - if (++count > DRM_LOOPING_LIMIT) { - DRM_ERROR("Looping\n"); - return 1; - } - } while (prev != old); + + spin_lock(&bl->lock); + buf->next = bl->next; + bl->next = buf; + spin_unlock(&bl->lock); + atomic_inc(&bl->count); if (atomic_read(&bl->count) > dma->buf_count) { DRM_ERROR("%d of %d buffers free after addition of %d\n", @@ -177,31 +163,23 @@ static drm_buf_t *drm_freelist_try(drm_freelist_t *bl) { - drm_buf_t *old, *new, *prev; drm_buf_t *buf; - int count = 0; if (!bl) return NULL; /* Get buffer */ - do { - old = bl->next; - if (!old) return NULL; - new = bl->next->next; - prev = cmpxchg(&bl->next, old, new); - if (++count > DRM_LOOPING_LIMIT) { - DRM_ERROR("Looping\n"); - return NULL; - } - } while (prev != old); - atomic_dec(&bl->count); + spin_lock(&bl->lock); + if (!bl->next) { + spin_unlock(&bl->lock); + return NULL; + } + buf = bl->next; + bl->next = bl->next->next; + spin_unlock(&bl->lock); - buf = old; + atomic_dec(&bl->count); buf->next = NULL; buf->list = DRM_LIST_NONE; - DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n", - buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh), - buf->waiting, buf->pending); if (buf->waiting || buf->pending) { DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n", buf->idx, buf->waiting, buf->pending, buf->list); @@ -221,13 +199,10 @@ if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */ atomic_set(&bl->wfh, 1); if (atomic_read(&bl->wfh)) { - DRM_DEBUG("Block = %d, count = %d, wfh = %d\n", - block, atomic_read(&bl->count), - atomic_read(&bl->wfh)); if (block) { add_wait_queue(&bl->waiting, &entry); - current->state = TASK_INTERRUPTIBLE; for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!atomic_read(&bl->wfh) && (buf = drm_freelist_try(bl))) break; schedule(); @@ -239,7 +214,5 @@ return buf; } - DRM_DEBUG("Count = %d, wfh = %d\n", - atomic_read(&bl->count), atomic_read(&bl->wfh)); return drm_freelist_try(bl); } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c:1.6 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c Wed Nov 8 00:03:07 2000 @@ -50,7 +50,6 @@ { unsigned int old, new, prev; - DRM_DEBUG("%d attempts\n", context); do { old = *lock; if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT; @@ -68,11 +67,8 @@ } if (new == (context | _DRM_LOCK_HELD)) { /* Have lock */ - DRM_DEBUG("%d\n", context); return 1; } - DRM_DEBUG("%d unable to get lock held by %d\n", - context, _DRM_LOCKING_CONTEXT(old)); return 0; } @@ -89,7 +85,6 @@ new = context | _DRM_LOCK_HELD; prev = cmpxchg(lock, old, new); } while (prev != old); - DRM_DEBUG("%d => %d\n", _DRM_LOCKING_CONTEXT(old), context); return 1; } @@ -99,7 +94,6 @@ unsigned int old, new, prev; pid_t pid = dev->lock.pid; - DRM_DEBUG("%d\n", context); dev->lock.pid = 0; do { old = *lock; @@ -128,10 +122,10 @@ atomic_inc(&q->use_count); if (atomic_read(&q->use_count) > 1) { atomic_inc(&q->block_write); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&q->flush_queue, &entry); atomic_inc(&q->block_count); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!DRM_BUFCOUNT(&q->waitlist)) break; schedule(); if (signal_pending(current)) { @@ -218,8 +212,41 @@ DRM_DEBUG("\n"); - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; ret = drm_flush_block_and_flush(dev, lock.context, lock.flags); drm_flush_unblock(dev, lock.context, lock.flags); return ret; +} + +/* If we get here, it means that the process has called DRM_IOCTL_LOCK + without calling DRM_IOCTL_UNLOCK. + + If the lock is not held, then let the signal proceed as usual. + + If the lock is held, then set the contended flag and keep the signal + blocked. + + + Return 1 if the signal should be delivered normally. + Return 0 if the signal should be blocked. */ + +int drm_notifier(void *priv) +{ + drm_sigdata_t *s = (drm_sigdata_t *)priv; + unsigned int old, new, prev; + + + /* Allow signal delivery if lock isn't held */ + if (!_DRM_LOCK_IS_HELD(s->lock->lock) + || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) return 1; + + /* Otherwise, set flag to force call to + drmUnlock */ + do { + old = s->lock->lock; + new = old | _DRM_LOCK_CONT; + prev = cmpxchg(&s->lock->lock, old, new); + } while (prev != old); + return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c:1.6 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c Fri Dec 1 09:29:02 2000 @@ -30,7 +30,9 @@ */ #define __NO_VERSION__ +#include <linux/config.h> #include "drmP.h" +#include <linux/wrapper.h> typedef struct drm_mem_stats { const char *name; @@ -197,7 +199,7 @@ int free_count; if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n"); - else kfree_s(pt, size); + else kfree(pt); spin_lock(&drm_mem_lock); drm_mem_stats[area].bytes_freed += size; free_count = ++drm_mem_stats[area].free_count; @@ -245,7 +247,12 @@ for (addr = address, sz = bytes; sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { +#if LINUX_VERSION_CODE >= 0x020400 + /* Argument type changed in 2.4.0-test6/pre8 */ + mem_map_reserve(virt_to_page(addr)); +#else mem_map_reserve(MAP_NR(addr)); +#endif } return address; @@ -266,7 +273,12 @@ for (addr = address, sz = bytes; sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { +#if LINUX_VERSION_CODE >= 0x020400 + /* Argument type changed in 2.4.0-test6/pre8 */ + mem_map_unreserve(virt_to_page(addr)); +#else mem_map_unreserve(MAP_NR(addr)); +#endif } free_pages(address, order); } @@ -330,7 +342,7 @@ } } -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) agp_memory *drm_alloc_agp(int pages, u32 type) { agp_memory *handle; @@ -340,16 +352,13 @@ return NULL; } - if (drm_agp.allocate_memory) { - if ((handle = (*drm_agp.allocate_memory)(pages, - type))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; - drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated - += pages << PAGE_SHIFT; - spin_unlock(&drm_mem_lock); - return handle; - } + if ((handle = drm_agp_allocate_memory(pages, type))) { + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; + drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated + += pages << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + return handle; } spin_lock(&drm_mem_lock); ++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count; @@ -369,8 +378,7 @@ return retval;; } - if (drm_agp.free_memory) { - (*drm_agp.free_memory)(handle); + if (drm_agp_free_memory(handle)) { spin_lock(&drm_mem_lock); free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count; alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; @@ -391,24 +399,19 @@ { int retcode = -EINVAL; - DRM_DEBUG("drm_bind_agp called\n"); if (!handle) { DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, "Attempt to bind NULL AGP handle\n"); return retcode; } - DRM_DEBUG("drm_agp.bind_memory : %p\n", drm_agp.bind_memory); - if (drm_agp.bind_memory) { - if (!(retcode = (*drm_agp.bind_memory)(handle, start))) { - spin_lock(&drm_mem_lock); - ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; - drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated - += handle->page_count << PAGE_SHIFT; - spin_unlock(&drm_mem_lock); - DRM_DEBUG("drm_agp.bind_memory: retcode %d\n", retcode); - return retcode; - } + if (!(retcode = drm_agp_bind_memory(handle, start))) { + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; + drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated + += handle->page_count << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + return retcode; } spin_lock(&drm_mem_lock); ++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count; @@ -428,20 +431,17 @@ return retcode; } - if (drm_agp.unbind_memory) { - int c = handle->page_count; - if ((retcode = (*drm_agp.unbind_memory)(handle))) - return retcode; - spin_lock(&drm_mem_lock); - free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count; - alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; - drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed += c << PAGE_SHIFT; - spin_unlock(&drm_mem_lock); - if (free_count > alloc_count) { - DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, - "Excess frees: %d frees, %d allocs\n", - free_count, alloc_count); - } + if ((retcode = drm_agp_unbind_memory(handle))) return retcode; + spin_lock(&drm_mem_lock); + free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count; + alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; + drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed + += handle->page_count << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + if (free_count > alloc_count) { + DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, + "Excess frees: %d frees, %d allocs\n", + free_count, alloc_count); } return retcode; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c:1.2 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c Fri Dec 1 09:29:02 2000 @@ -57,16 +57,16 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); size = 1 << order; agp_offset = request.agp_start; - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; byte_count = 0; @@ -119,8 +119,6 @@ buf->order = order; buf->used = 0; - DRM_DEBUG("offset : %ld\n", offset); - buf->offset = offset; /* Hrm */ buf->bus_address = dev->agp->base + agp_offset + offset; buf->address = (void *)(agp_offset + offset + dev->agp->base); @@ -130,7 +128,8 @@ init_waitqueue_head(&buf->dma_wait); buf->pid = 0; - buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS); + buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), + DRM_MEM_BUFS); buf->dev_priv_size = sizeof(drm_mga_buf_priv_t); #if DRM_DMA_HISTOGRAM @@ -142,9 +141,6 @@ offset = offset + alignment; entry->buf_count++; byte_count += PAGE_SIZE << page_order; - - DRM_DEBUG("buffer %d @ %p\n", - entry->buf_count, buf->address); } dma->buflist = drm_realloc(dma->buflist, @@ -173,10 +169,10 @@ request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); @@ -219,10 +215,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); @@ -234,7 +230,7 @@ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; if (dev->queue_count) return -EBUSY; /* Not while in use */ - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; @@ -348,10 +344,10 @@ request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); return 0; @@ -362,10 +358,10 @@ { drm_buf_desc_t request; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; if(request.flags & _DRM_AGP_BUFFER) return mga_addbufs_agp(inode, filp, cmd, arg); @@ -393,58 +389,47 @@ ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_info_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) ++count; } - DRM_DEBUG("count = %d\n", count); - if (request.count >= count) { for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) { - copy_to_user_ret(&request.list[count].count, + if (copy_to_user(&request.list[count].count, &dma->bufs[i].buf_count, sizeof(dma->bufs[0] - .buf_count), - -EFAULT); - copy_to_user_ret(&request.list[count].size, + .buf_count)) || + copy_to_user(&request.list[count].size, &dma->bufs[i].buf_size, - sizeof(dma->bufs[0].buf_size), - -EFAULT); - copy_to_user_ret(&request.list[count].low_mark, + sizeof(dma->bufs[0].buf_size)) || + copy_to_user(&request.list[count].low_mark, &dma->bufs[i] .freelist.low_mark, sizeof(dma->bufs[0] - .freelist.low_mark), - -EFAULT); - copy_to_user_ret(&request.list[count] + .freelist.low_mark)) || + copy_to_user(&request.list[count] .high_mark, &dma->bufs[i] .freelist.high_mark, sizeof(dma->bufs[0] - .freelist.high_mark), - -EFAULT); - DRM_DEBUG("%d %d %d %d %d\n", - i, - dma->bufs[i].buf_count, - dma->bufs[i].buf_size, - dma->bufs[i].freelist.low_mark, - dma->bufs[i].freelist.high_mark); + .freelist.high_mark))) + return -EFAULT; ++count; } } } request.count = count; - copy_to_user_ret((drm_buf_info_t *)arg, + if (copy_to_user((drm_buf_info_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return 0; } @@ -461,13 +446,9 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + if (copy_from_user(&request, (drm_buf_desc_t *)arg, sizeof(request))) + return -EFAULT; - DRM_DEBUG("%d, %d, %d\n", - request.size, request.low_mark, request.high_mark); order = drm_order(request.size); if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; entry = &dma->bufs[order]; @@ -496,17 +477,16 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_free_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; - DRM_DEBUG("%d\n", request.count); for (i = 0; i < request.count; i++) { - copy_from_user_ret(&idx, + if (copy_from_user(&idx, &request.list[i], - sizeof(idx), - -EFAULT); + sizeof(idx))) + return -EFAULT; if (idx < 0 || idx >= dma->buf_count) { DRM_ERROR("Index %d (of %d max)\n", idx, dma->buf_count - 1); @@ -539,25 +519,19 @@ if (!dma) return -EINVAL; - DRM_DEBUG("\n"); - spin_lock(&dev->count_lock); if (atomic_read(&dev->buf_alloc)) { spin_unlock(&dev->count_lock); - DRM_DEBUG("Busy\n"); return -EBUSY; } ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_map_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; - DRM_DEBUG("mga_mapbufs\n"); - DRM_DEBUG("dma->flags : %x\n", dma->flags); - if (request.count >= dma->buf_count) { if(dma->flags & _DRM_DMA_USE_AGP) { drm_mga_private_t *dev_priv = dev->dev_private; @@ -565,7 +539,6 @@ map = dev->maplist[dev_priv->buffer_map_idx]; if (!map) { - DRM_DEBUG("map is null\n"); retcode = -EINVAL; goto done; } @@ -628,10 +601,10 @@ request.count = dma->buf_count; DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - copy_to_user_ret((drm_buf_map_t *)arg, + if (copy_to_user((drm_buf_map_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("retcode : %d\n", retcode); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c:1.2 Fri Jun 16 20:03:36 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c Wed Nov 8 00:03:07 2000 @@ -29,17 +29,13 @@ * */ -#include <linux/sched.h> - #define __NO_VERSION__ #include "drmP.h" #include "mga_drv.h" static int mga_alloc_queue(drm_device_t *dev) { - int temp = drm_ctxbitmap_next(dev); - DRM_DEBUG("mga_alloc_queue: %d\n", temp); - return temp; + return drm_ctxbitmap_next(dev); } int mga_context_switch(drm_device_t *dev, int old, int new) @@ -104,20 +100,21 @@ drm_ctx_t ctx; int i; - DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -128,18 +125,18 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = mga_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Skip kernel's context and get a new one. */ ctx.handle = mga_alloc_queue(dev); } if (ctx.handle == -1) { - DRM_DEBUG("Not enough free contexts.\n"); - /* Should this return -EBUSY instead? */ return -ENOMEM; } DRM_DEBUG("%d\n", ctx.handle); - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -155,10 +152,12 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; /* This is 0, because we don't hanlde any context flags */ ctx.flags = 0; - copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -169,7 +168,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return mga_context_switch(dev, dev->last_context, ctx.handle); } @@ -181,7 +181,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); mga_context_switch_complete(dev, ctx.handle); @@ -195,8 +196,11 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); + if(ctx.handle == DRM_KERNEL_CONTEXT+1) priv->remove_auth_on_close = 1; + if(ctx.handle != DRM_KERNEL_CONTEXT) { drm_ctxbitmap_free(dev, ctx.handle); } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c:1.3 Fri Jun 30 13:15:18 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c Wed Nov 8 00:03:07 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -51,46 +51,29 @@ static unsigned long mga_alloc_page(drm_device_t *dev) { unsigned long address; - - DRM_DEBUG("%s\n", __FUNCTION__); + address = __get_free_page(GFP_KERNEL); if(address == 0UL) { return 0; } - atomic_inc(&mem_map[MAP_NR((void *) address)].count); - set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags); - + atomic_inc(&virt_to_page(address)->count); + set_bit(PG_reserved, &virt_to_page(address)->flags); + return address; } static void mga_free_page(drm_device_t *dev, unsigned long page) { - DRM_DEBUG("%s\n", __FUNCTION__); - - if(page == 0UL) { - return; - } - atomic_dec(&mem_map[MAP_NR((void *) page)].count); - clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags); - wake_up(&mem_map[MAP_NR((void *) page)].wait); + if(!page) return; + atomic_dec(&virt_to_page(page)->count); + clear_bit(PG_reserved, &virt_to_page(page)->flags); free_page(page); return; } static void mga_delay(void) { - return; -} - -void mga_flush_write_combine(void) -{ - int xchangeDummy; - DRM_DEBUG("%s\n", __FUNCTION__); - - __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); - __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" - " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" - " pop %%eax" : /* no outputs */ : /* no inputs */ ); + return; } /* These are two age tags that will never be sent to @@ -107,13 +90,11 @@ drm_mga_freelist_t *item; int i; - DRM_DEBUG("%s\n", __FUNCTION__); - dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); if(dev_priv->head == NULL) return -ENOMEM; memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t)); dev_priv->head->age = MGA_BUF_USED; - + for (i = 0; i < dma->buf_count; i++) { buf = dma->buflist[ i ]; buf_priv = buf->dev_private; @@ -133,7 +114,7 @@ buf_priv->dispatched = 0; dev_priv->head->next = item; } - + return 0; } @@ -143,15 +124,13 @@ drm_mga_freelist_t *item; drm_mga_freelist_t *prev; - DRM_DEBUG("%s\n", __FUNCTION__); - item = dev_priv->head; while(item) { prev = item; item = item->next; drm_free(prev, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); } - + dev_priv->head = dev_priv->tail = NULL; } @@ -164,19 +143,21 @@ unsigned long end; int i; - DRM_DEBUG("%s\n", __FUNCTION__); + DRM_DEBUG("dispatch_status = 0x%02x\n", dev_priv->dispatch_status); end = jiffies + (HZ*3); while(1) { - if(!test_and_set_bit(MGA_IN_DISPATCH, + if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) { break; } if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup\n"); - goto out_nolock; + DRM_ERROR("lockup: dispatch_status = 0x%02x," + " jiffies = %lu, end = %lu\n", + dev_priv->dispatch_status, jiffies, end); + return; } for (i = 0 ; i < 2000 ; i++) mga_delay(); } @@ -184,19 +165,20 @@ DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS)); while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup\n"); - goto out_status; + DRM_ERROR("lockup\n"); + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); + return; } - for (i = 0 ; i < 2000 ; i++) mga_delay(); + for (i = 0 ; i < 2000 ; i++) mga_delay(); } sarea_priv->dirty |= MGA_DMA_FLUSH; -out_status: clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); -out_nolock: + DRM_DEBUG("exit, dispatch_status = 0x%02x\n", + dev_priv->dispatch_status); } static void mga_reset_freelist(drm_device_t *dev) @@ -214,44 +196,44 @@ } /* Least recently used : - * These operations are not atomic b/c they are protected by the + * These operations are not atomic b/c they are protected by the * hardware lock */ drm_buf_t *mga_freelist_get(drm_device_t *dev) { DECLARE_WAITQUEUE(entry, current); - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_freelist_t *prev; drm_mga_freelist_t *next; static int failed = 0; + int return_null = 0; - DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__, - dev_priv->tail->age, dev_priv->last_prim_age); - if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) { - DRM_DEBUG("I'm waiting on the freelist!!! %d\n", - dev_priv->last_prim_age); - set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); - current->state = TASK_INTERRUPTIBLE; + DRM_DEBUG("Waiting on freelist," + " tail->age = %d, last_prim_age= %d\n", + dev_priv->tail->age, + dev_priv->last_prim_age); add_wait_queue(&dev_priv->buf_queue, &entry); + set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); for (;;) { + current->state = TASK_INTERRUPTIBLE; mga_dma_schedule(dev, 0); - if(!test_bit(MGA_IN_GETBUF, - &dev_priv->dispatch_status)) + if(dev_priv->tail->age < dev_priv->last_prim_age) break; atomic_inc(&dev->total_sleeps); schedule(); if (signal_pending(current)) { - clear_bit(MGA_IN_GETBUF, - &dev_priv->dispatch_status); - goto failed_getbuf; + ++return_null; + break; } } - current->state = TASK_RUNNING; + clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); + current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->buf_queue, &entry); + if (return_null) return NULL; } - + if(dev_priv->tail->age < dev_priv->last_prim_age) { prev = dev_priv->tail->prev; next = dev_priv->tail; @@ -263,22 +245,19 @@ return next->buf; } -failed_getbuf: failed++; return NULL; } int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf) { - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_buf_priv_t *buf_priv = buf->dev_private; drm_mga_freelist_t *prev; drm_mga_freelist_t *head; drm_mga_freelist_t *next; - DRM_DEBUG("%s\n", __FUNCTION__); - if(buf_priv->my_freelist->age == MGA_BUF_USED) { /* Discarded buffer, put it on the tail */ next = buf_priv->my_freelist; @@ -288,7 +267,6 @@ next->prev = prev; next->next = NULL; dev_priv->tail = next; - DRM_DEBUG("Discarded\n"); } else { /* Normally aged buffer, put it on the head + 1, * as the real head is a sentinal element @@ -301,7 +279,7 @@ next->prev = head; next->next = prev; } - + return 0; } @@ -312,42 +290,41 @@ int i, temp, size_of_buf; int offset = init->reserved_map_agpstart; - DRM_DEBUG("%s\n", __FUNCTION__); - dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / + dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS; dev_priv->warp_ucode_size = init->warp_ucode_size; - dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) * - (MGA_NUM_PRIM_BUFS + 1), + dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) * + (MGA_NUM_PRIM_BUFS + 1), DRM_MEM_DRIVER); if(dev_priv->prim_bufs == NULL) { DRM_ERROR("Unable to allocate memory for prim_buf\n"); return -ENOMEM; } - memset(dev_priv->prim_bufs, + memset(dev_priv->prim_bufs, 0, sizeof(drm_mga_prim_buf_t *) * (MGA_NUM_PRIM_BUFS + 1)); - + temp = init->warp_ucode_size + dev_priv->primary_size; temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - - dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, + + dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, temp); if(dev_priv->ioremap == NULL) { - DRM_DEBUG("Ioremap failed\n"); + DRM_ERROR("Ioremap failed\n"); return -ENOMEM; } init_waitqueue_head(&dev_priv->wait_queue); - + for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) { - prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t), + prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t), DRM_MEM_DRIVER); if(prim_buffer == NULL) return -ENOMEM; memset(prim_buffer, 0, sizeof(drm_mga_prim_buf_t)); prim_buffer->phys_head = offset + dev->agp->base; - prim_buffer->current_dma_ptr = - prim_buffer->head = - (u32 *) (dev_priv->ioremap + - offset - + prim_buffer->current_dma_ptr = + prim_buffer->head = + (u32 *) (dev_priv->ioremap + + offset - init->reserved_map_agpstart); prim_buffer->num_dwords = 0; prim_buffer->max_dwords = size_of_buf / sizeof(u32); @@ -359,11 +336,11 @@ dev_priv->prim_bufs[i] = prim_buffer; } dev_priv->current_prim_idx = 0; - dev_priv->next_prim = - dev_priv->last_prim = + dev_priv->next_prim = + dev_priv->last_prim = dev_priv->current_prim = dev_priv->prim_bufs[0]; - dev_priv->next_prim_age = 2; + dev_priv->next_prim_age = 2; dev_priv->last_prim_age = 1; set_bit(MGA_BUF_IN_USE, &dev_priv->current_prim->buffer_status); return 0; @@ -380,13 +357,12 @@ int next_idx; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); dev_priv->last_prim = prim; - + /* We never check for overflow, b/c there is always room */ PRIMPTR(prim); if(num_dwords <= 0) { - DRM_DEBUG("num_dwords == 0 when dispatched\n"); + DRM_ERROR("num_dwords == 0 when dispatched\n"); goto out_prim_wait; } PRIMOUTREG( MGAREG_DMAPAD, 0); @@ -397,32 +373,28 @@ end = jiffies + (HZ*3); if(sarea_priv->dirty & MGA_DMA_FLUSH) { - DRM_DEBUG("Dma top flush\n"); while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup in fire primary " - "(Dma Top Flush)\n"); + DRM_ERROR("lockup (flush)\n"); goto out_prim_wait; } - + for (i = 0 ; i < 4096 ; i++) mga_delay(); } sarea_priv->dirty &= ~(MGA_DMA_FLUSH); } else { - DRM_DEBUG("Status wait\n"); while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { - DRM_ERROR("irqs: %d wanted %d\n", - atomic_read(&dev->total_irq), + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup in fire primary " - "(Status Wait)\n"); + DRM_ERROR("lockup (wait)\n"); goto out_prim_wait; } - + for (i = 0 ; i < 4096 ; i++) mga_delay(); } } @@ -433,9 +405,9 @@ MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); prim->num_dwords = 0; sarea_priv->last_enqueue = prim->prim_age; - + next_idx = prim->idx + 1; - if(next_idx >= MGA_NUM_PRIM_BUFS) + if(next_idx >= MGA_NUM_PRIM_BUFS) next_idx = 0; dev_priv->next_prim = dev_priv->prim_bufs[next_idx]; @@ -458,28 +430,26 @@ drm_device_dma_t *dma = dev->dma; int next_prim_idx; int ret = 0; - + /* This needs to reset the primary buffer if available, * we should collect stats on how many times it bites * it's tail */ - DRM_DEBUG("%s\n", __FUNCTION__); - + next_prim_idx = dev_priv->current_prim_idx + 1; if(next_prim_idx >= MGA_NUM_PRIM_BUFS) next_prim_idx = 0; prim_buffer = dev_priv->prim_bufs[next_prim_idx]; set_bit(MGA_IN_WAIT, &dev_priv->dispatch_status); - + /* In use is cleared in interrupt handler */ - + if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) { add_wait_queue(&dev_priv->wait_queue, &entry); - current->state = TASK_INTERRUPTIBLE; - for (;;) { + current->state = TASK_INTERRUPTIBLE; mga_dma_schedule(dev, 0); - if(!test_and_set_bit(MGA_BUF_IN_USE, - &prim_buffer->buffer_status)) + if(!test_and_set_bit(MGA_BUF_IN_USE, + &prim_buffer->buffer_status)) break; atomic_inc(&dev->total_sleeps); atomic_inc(&dma->total_missed_sched); @@ -489,7 +459,7 @@ break; } } - current->state = TASK_RUNNING; + current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->wait_queue, &entry); if(ret) return ret; } @@ -501,10 +471,10 @@ prim_buffer->sec_used = 0; prim_buffer->prim_age = dev_priv->next_prim_age++; if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) { - mga_flush_queue(dev); - mga_dma_quiescent(dev); - mga_reset_freelist(dev); - prim_buffer->prim_age = (dev_priv->next_prim_age += 2); + mga_flush_queue(dev); + mga_dma_quiescent(dev); + mga_reset_freelist(dev); + prim_buffer->prim_age = (dev_priv->next_prim_age += 2); } /* Reset all buffer status stuff */ @@ -521,88 +491,72 @@ static inline int mga_decide_to_fire(drm_device_t *dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - drm_device_dma_t *dma = dev->dma; - - DRM_DEBUG("%s\n", __FUNCTION__); if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) { - atomic_inc(&dma->total_prio); return 1; } if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && dev_priv->next_prim->num_dwords) { - atomic_inc(&dma->total_prio); return 1; } if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && dev_priv->next_prim->num_dwords) { - atomic_inc(&dma->total_prio); return 1; } - + if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) { - if(test_bit(MGA_BUF_SWAP_PENDING, + if(test_bit(MGA_BUF_SWAP_PENDING, &dev_priv->next_prim->buffer_status)) { - atomic_inc(&dma->total_dmas); return 1; } } if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) { if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) { - atomic_inc(&dma->total_hit); return 1; } } if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) { if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) { - atomic_inc(&dma->total_missed_free); return 1; } } - atomic_inc(&dma->total_tried); return 0; } int mga_dma_schedule(drm_device_t *dev, int locked) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - drm_device_dma_t *dma = dev->dma; - int retval = 0; + int retval = 0; - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_dma); + if (!dev_priv) return -EBUSY; + + if (test_and_set_bit(0, &dev->dma_flag)) { retval = -EBUSY; goto sch_out_wakeup; } - - DRM_DEBUG("%s\n", __FUNCTION__); - if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || + if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) || test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { locked = 1; } - - if (!locked && + + if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { - atomic_inc(&dma->total_missed_lock); clear_bit(0, &dev->dma_flag); - DRM_DEBUG("Not locked\n"); retval = -EBUSY; goto sch_out_wakeup; } - DRM_DEBUG("I'm locked\n"); if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) { /* Fire dma buffer */ if(mga_decide_to_fire(dev)) { - DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx); - clear_bit(MGA_BUF_FORCE_FIRE, + clear_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status); if(dev_priv->current_prim == dev_priv->next_prim) { /* Schedule overflow for a later time */ @@ -613,10 +567,8 @@ } else { clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); } - } else { - DRM_DEBUG("I can't get the dispatch lock\n"); } - + if (!locked) { if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { @@ -624,6 +576,8 @@ } } + clear_bit(0, &dev->dma_flag); + sch_out_wakeup: if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && atomic_read(&dev_priv->pending_bufs) == 0) { @@ -632,18 +586,10 @@ wake_up_interruptible(&dev_priv->flush_queue); } - if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && - dev_priv->tail->age < dev_priv->last_prim_age) { - clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); - DRM_DEBUG("Waking up buf queue\n"); + if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) + && dev_priv->tail->age < dev_priv->last_prim_age) wake_up_interruptible(&dev_priv->buf_queue); - } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { - DRM_DEBUG("Not waking buf_queue on %d %d\n", - atomic_read(&dev->total_irq), - dev_priv->last_prim_age); - } - clear_bit(0, &dev->dma_flag); return retval; } @@ -653,41 +599,40 @@ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; drm_mga_prim_buf_t *last_prim_buffer; - DRM_DEBUG("%s\n", __FUNCTION__); atomic_inc(&dev->total_irq); if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return; MGA_WRITE(MGAREG_ICLEAR, 0x00000001); last_prim_buffer = dev_priv->last_prim; last_prim_buffer->num_dwords = 0; last_prim_buffer->sec_used = 0; - dev_priv->sarea_priv->last_dispatch = + dev_priv->sarea_priv->last_dispatch = dev_priv->last_prim_age = last_prim_buffer->prim_age; clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status); - wake_up_interruptible(&dev_priv->wait_queue); clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status); clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); atomic_dec(&dev_priv->pending_bufs); queue_task(&dev->tq, &tq_immediate); mark_bh(IMMEDIATE_BH); + wake_up_interruptible(&dev_priv->wait_queue); } static void mga_dma_task_queue(void *device) { - DRM_DEBUG("%s\n", __FUNCTION__); mga_dma_schedule((drm_device_t *)device, 0); } int mga_dma_cleanup(drm_device_t *dev) { - DRM_DEBUG("%s\n", __FUNCTION__); - if(dev->dev_private) { - drm_mga_private_t *dev_priv = + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - + + if (dev->irq) mga_flush_queue(dev); + mga_dma_quiescent(dev); + if(dev_priv->ioremap) { - int temp = (dev_priv->warp_ucode_size + - dev_priv->primary_size + + int temp = (dev_priv->warp_ucode_size + + dev_priv->primary_size + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE; drm_ioremapfree((void *) dev_priv->ioremap, temp); @@ -708,7 +653,7 @@ } } drm_free(dev_priv->prim_bufs, sizeof(void *) * - (MGA_NUM_PRIM_BUFS + 1), + (MGA_NUM_PRIM_BUFS + 1), DRM_MEM_DRIVER); } if(dev_priv->head != NULL) { @@ -716,7 +661,7 @@ } - drm_free(dev->dev_private, sizeof(drm_mga_private_t), + drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER); dev->dev_private = NULL; } @@ -727,10 +672,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { drm_mga_private_t *dev_priv; drm_map_t *sarea_map = NULL; - int i; - DRM_DEBUG("%s\n", __FUNCTION__); - dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); if(dev_priv == NULL) return -ENOMEM; dev->dev_private = (void *) dev_priv; @@ -740,15 +682,14 @@ if((init->reserved_map_idx >= dev->map_count) || (init->buffer_map_idx >= dev->map_count)) { mga_dma_cleanup(dev); - DRM_DEBUG("reserved_map or buffer_map are invalid\n"); return -EINVAL; } - + dev_priv->reserved_map_idx = init->reserved_map_idx; dev_priv->buffer_map_idx = init->buffer_map_idx; sarea_map = dev->maplist[0]; - dev_priv->sarea_priv = (drm_mga_sarea_t *) - ((u8 *)sarea_map->handle + + dev_priv->sarea_priv = (drm_mga_sarea_t *) + ((u8 *)sarea_map->handle + init->sarea_priv_offset); /* Scale primary size to the next page */ @@ -765,24 +706,18 @@ dev_priv->mAccess = init->mAccess; init_waitqueue_head(&dev_priv->flush_queue); init_waitqueue_head(&dev_priv->buf_queue); - dev_priv->WarpPipe = -1; + dev_priv->WarpPipe = 0xff000000; + dev_priv->vertexsize = 0; - DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n", - dev_priv->chipset, dev_priv->warp_ucode_size, + DRM_DEBUG("chipset=%d ucode_size=%d backOffset=%x depthOffset=%x\n", + dev_priv->chipset, dev_priv->warp_ucode_size, dev_priv->backOffset, dev_priv->depthOffset); DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n", - dev_priv->cpp, dev_priv->sgram, dev_priv->stride, + dev_priv->cpp, dev_priv->sgram, dev_priv->stride, dev_priv->mAccess); - - memcpy(&dev_priv->WarpIndex, &init->WarpIndex, - sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES); - for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++) - DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n", - i, - dev_priv->WarpIndex[i].installed, - dev_priv->WarpIndex[i].phys_addr, - dev_priv->WarpIndex[i].size); + memcpy(&dev_priv->WarpIndex, &init->WarpIndex, + sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES); if(mga_init_primary_bufs(dev, init) != 0) { DRM_ERROR("Can not initialize primary buffers\n"); @@ -796,7 +731,7 @@ return -ENOMEM; } - dev_priv->status_page = + dev_priv->status_page = ioremap_nocache(virt_to_bus((void *)dev_priv->real_status_page), PAGE_SIZE); @@ -807,15 +742,15 @@ } /* Write status page when secend or softrap occurs */ - MGA_WRITE(MGAREG_PRIMPTR, + MGA_WRITE(MGAREG_PRIMPTR, virt_to_bus((void *)dev_priv->real_status_page) | 0x00000003); - + /* Private is now filled in, initialize the hardware */ { PRIMLOCALS; PRIMGETPTR( dev_priv ); - + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DWGSYNC, 0x0100); @@ -823,13 +758,13 @@ /* Poll for the first buffer to insure that * the status register will be correct */ - + mga_flush_write_combine(); MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | + MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | PDEA_pagpxfer_enable)); - + while(MGA_READ(MGAREG_DWGSYNC) != 0x0100) ; } @@ -847,11 +782,10 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_mga_init_t init; - - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&init, (drm_mga_init_t *)arg, sizeof(init), -EFAULT); - + if (copy_from_user(&init, (drm_mga_init_t *)arg, sizeof(init))) + return -EFAULT; + switch(init.func) { case MGA_INIT_DMA: return mga_dma_initialize(dev, &init); @@ -867,7 +801,7 @@ int retcode; if (!irq) return -EINVAL; - + down(&dev->struct_sem); if (dev->irq) { up(&dev->struct_sem); @@ -875,7 +809,7 @@ } dev->irq = irq; up(&dev->struct_sem); - + DRM_DEBUG("install irq handler %d\n", irq); dev->context_flag = 0; @@ -916,7 +850,7 @@ irq = dev->irq; dev->irq = 0; up(&dev->struct_sem); - + if (!irq) return -EINVAL; DRM_DEBUG("remove irq handler %d\n", irq); MGA_WRITE(MGAREG_ICLEAR, 0x00000001); @@ -931,10 +865,9 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_control_t ctl; - - copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); - DRM_DEBUG("%s\n", __FUNCTION__); + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) + return -EFAULT; switch (ctl.func) { case DRM_INST_HANDLER: @@ -952,31 +885,29 @@ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; int ret = 0; - DRM_DEBUG("%s\n", __FUNCTION__); + if(!dev_priv) return 0; - if(dev_priv == NULL) { - return 0; - } - if(dev_priv->next_prim->num_dwords != 0) { - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); + if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status)) + DRM_ERROR("Incorrect mga_flush_queue logic\n"); set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); mga_dma_schedule(dev, 0); for (;;) { - if (!test_bit(MGA_IN_FLUSH, - &dev_priv->dispatch_status)) + current->state = TASK_INTERRUPTIBLE; + if (!test_bit(MGA_IN_FLUSH, + &dev_priv->dispatch_status)) break; atomic_inc(&dev->total_sleeps); schedule(); if (signal_pending(current)) { ret = -EINTR; /* Can't restart */ - clear_bit(MGA_IN_FLUSH, + clear_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); break; } } - current->state = TASK_RUNNING; + current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->flush_queue, &entry); } return ret; @@ -992,18 +923,19 @@ if(dev->dev_private == NULL) return; if(dma->buflist == NULL) return; - DRM_DEBUG("%s\n", __FUNCTION__); + DRM_DEBUG("buf_count=%d\n", dma->buf_count); + mga_flush_queue(dev); for (i = 0; i < dma->buf_count; i++) { drm_buf_t *buf = dma->buflist[ i ]; drm_mga_buf_priv_t *buf_priv = buf->dev_private; - /* Only buffers that need to get reclaimed ever - * get set to free + /* Only buffers that need to get reclaimed ever + * get set to free */ if (buf->pid == pid && buf_priv) { - if(buf_priv->my_freelist->age == MGA_BUF_USED) + if(buf_priv->my_freelist->age == MGA_BUF_USED) buf_priv->my_freelist->age = MGA_BUF_FREE; } } @@ -1018,29 +950,24 @@ int ret = 0; drm_lock_t lock; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); return -EINVAL; } - - DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock.context, current->pid, dev->lock.hw_lock->lock, - lock.flags); - if (lock.context < 0) { - return -EINVAL; - } - + if (lock.context < 0) return -EINVAL; + /* Only one queue: */ if (!ret) { add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -1053,10 +980,9 @@ atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -1066,20 +992,30 @@ current->state = TASK_RUNNING; remove_wait_queue(&dev->lock.lock_queue, &entry); } - + if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_QUIESCENT) { DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); mga_flush_queue(dev); mga_dma_quiescent(dev); } } - - DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + + if (ret) DRM_DEBUG("%d %s\n", lock.context, + ret ? "interrupted" : "has lock"); return ret; } - -int mga_flush_ioctl(struct inode *inode, struct file *filp, + +int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -1087,11 +1023,11 @@ drm_lock_t lock; drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { - DRM_ERROR("mga_flush_ioctl called without lock held\n"); + DRM_ERROR("lock not held\n"); return -EINVAL; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h:1.1 Fri Jun 16 20:03:37 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h Tue Sep 26 12:21:24 2000 @@ -73,17 +73,19 @@ /* 3d state excluding texture units: */ -#define MGA_CTXREG_DSTORG 0 /* validated */ -#define MGA_CTXREG_MACCESS 1 -#define MGA_CTXREG_PLNWT 2 -#define MGA_CTXREG_DWGCTL 3 -#define MGA_CTXREG_ALPHACTRL 4 -#define MGA_CTXREG_FOGCOLOR 5 -#define MGA_CTXREG_WFLAG 6 -#define MGA_CTXREG_TDUAL0 7 -#define MGA_CTXREG_TDUAL1 8 -#define MGA_CTXREG_FCOL 9 -#define MGA_CTX_SETUP_SIZE 10 +#define MGA_CTXREG_DSTORG 0 /* validated */ +#define MGA_CTXREG_MACCESS 1 +#define MGA_CTXREG_PLNWT 2 +#define MGA_CTXREG_DWGCTL 3 +#define MGA_CTXREG_ALPHACTRL 4 +#define MGA_CTXREG_FOGCOLOR 5 +#define MGA_CTXREG_WFLAG 6 +#define MGA_CTXREG_TDUAL0 7 +#define MGA_CTXREG_TDUAL1 8 +#define MGA_CTXREG_FCOL 9 +#define MGA_CTXREG_STENCIL 10 +#define MGA_CTXREG_STENCILCTL 11 +#define MGA_CTX_SETUP_SIZE 12 /* 2d state */ @@ -233,6 +235,7 @@ /* Mechanism to validate card state. */ int ctxOwner; + int vertexsize; } drm_mga_sarea_t; /* Device specific ioctls: @@ -241,6 +244,8 @@ unsigned int clear_color; unsigned int clear_depth; unsigned int flags; + unsigned int clear_depth_mask; + unsigned int clear_color_mask; } drm_mga_clear_t; typedef struct _drm_mga_swap { Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c:1.2 Fri Jun 16 20:03:37 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c Fri Dec 1 09:29:02 2000 @@ -1,6 +1,6 @@ /* mga_drv.c -- Matrox g200/g400 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -31,23 +31,24 @@ */ #include <linux/config.h> -#define EXPORT_SYMTAB #include "drmP.h" #include "mga_drv.h" -EXPORT_SYMBOL(mga_init); -EXPORT_SYMBOL(mga_cleanup); #define MGA_NAME "mga" -#define MGA_DESC "Matrox g200/g400" -#define MGA_DATE "19991213" -#define MGA_MAJOR 1 +#define MGA_DESC "Matrox G200/G400" +#define MGA_DATE "20000928" +#define MGA_MAJOR 2 #define MGA_MINOR 0 -#define MGA_PATCHLEVEL 0 +#define MGA_PATCHLEVEL 1 static drm_device_t mga_device; drm_ctx_t mga_res_ctx; static struct file_operations mga_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif open: mga_open, flush: drm_flush, release: mga_release, @@ -118,53 +119,32 @@ #define MGA_IOCTL_COUNT DRM_ARRAY_SIZE(mga_ioctls) #ifdef MODULE -int init_module(void); -void cleanup_module(void); static char *mga = NULL; +#endif -MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); -MODULE_DESCRIPTION("Matrox g200/g400"); +MODULE_AUTHOR("VA Linux Systems, Inc."); +MODULE_DESCRIPTION("Matrox G200/G400"); MODULE_PARM(mga, "s"); -/* init_module is called when insmod is used to load the module */ - -int init_module(void) -{ - DRM_DEBUG("doing mga_init()\n"); - return mga_init(); -} - -/* cleanup_module is called when rmmod is used to unload the module */ - -void cleanup_module(void) -{ - mga_cleanup(); -} -#endif - #ifndef MODULE -/* mga_setup is called by the kernel to parse command-line options passed +/* mga_options is called by the kernel to parse command-line options passed * via the boot-loader (e.g., LILO). It calls the insmod option routine, * drm_parse_drm. - * - * This is not currently supported, since it requires changes to - * linux/init/main.c. */ - + */ -void __init mga_setup(char *str, int *ints) +static int __init mga_options(char *str) { - if (ints[0] != 0) { - DRM_ERROR("Illegal command line format, ignored\n"); - return; - } drm_parse_options(str); + return 1; } + +__setup("mga=", mga_options); #endif static int mga_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -207,22 +187,22 @@ dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -236,16 +216,17 @@ DRM_DEBUG("\n"); + if (dev->dev_private) mga_dma_cleanup(dev); if (dev->irq) mga_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -263,7 +244,7 @@ if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -273,10 +254,9 @@ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - - if (dev->agp->acquired && drm_agp.release) - (*drm_agp.release)(); - + + if (dev->agp->acquired) _drm_agp_release(); + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -288,7 +268,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -324,7 +304,7 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -350,14 +330,14 @@ wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } /* mga_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ -int mga_init(void) +static int __init mga_init(void) { int retcode; drm_device_t *dev = &mga_device; @@ -367,11 +347,10 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(mga); #endif - DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&mga_misc))) { DRM_ERROR("Cannot register \"%s\"\n", MGA_NAME); return retcode; @@ -379,11 +358,8 @@ dev->device = MKDEV(MISC_MAJOR, mga_misc.minor); dev->name = MGA_NAME; - DRM_DEBUG("doing mem init\n"); drm_mem_init(); - DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); - DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); if(dev->agp == NULL) { DRM_INFO("The mga drm module requires the agpgart module" @@ -400,7 +376,6 @@ MTRR_TYPE_WRCOMB, 1); #endif - DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); @@ -422,12 +397,12 @@ /* mga_cleanup is called via cleanup_module at module unload time. */ -void mga_cleanup(void) +static void __exit mga_cleanup(void) { drm_device_t *dev = &mga_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&mga_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -435,11 +410,10 @@ DRM_INFO("Module unloaded\n"); } drm_ctxbitmap_cleanup(dev); - mga_dma_cleanup(dev); #ifdef CONFIG_MTRR if(dev->agp && dev->agp->agp_mtrr) { int retval; - retval = mtrr_del(dev->agp->agp_mtrr, + retval = mtrr_del(dev->agp->agp_mtrr, dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_size * 1024*1024); DRM_DEBUG("mtrr_del = %d\n", retval); @@ -448,28 +422,34 @@ mga_takedown(dev); if (dev->agp) { + drm_agp_uninit(); drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); dev->agp = NULL; } } +module_init(mga_init); +module_exit(mga_cleanup); + + int mga_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = MGA_MAJOR; @@ -480,10 +460,10 @@ DRM_COPY(version.date, MGA_DATE); DRM_COPY(version.desc, MGA_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -491,10 +471,12 @@ { drm_device_t *dev = &mga_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_open); spin_lock(&dev->count_lock); if (!dev->open_count++) { @@ -509,31 +491,38 @@ int mga_release(struct inode *inode, struct file *filp) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_device_t *dev; int retcode = 0; + lock_kernel(); + dev = priv->dev; DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n", current->pid, dev->device, dev->open_count); if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && dev->lock.pid == current->pid) { mga_reclaim_buffers(dev, priv->pid); - DRM_ERROR("Process %d dead, freeing lock for context %d\n", - current->pid, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + DRM_INFO("Process %d dead (ctx %d, d_s = 0x%02x)\n", + current->pid, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock), + dev->dev_private ? + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status + : 0); + + if (dev->dev_private) + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status &= MGA_IN_DISPATCH; + drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - - /* FIXME: may require heavy-handed reset of - hardware at this point, possibly - processed via a callback to the X - server. */ } else if (dev->lock.hw_lock) { /* The lock is required to reclaim buffers */ DECLARE_WAITQUEUE(entry, current); add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ retcode = -EINTR; @@ -545,10 +534,9 @@ dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { retcode = -ERESTARTSYS; @@ -559,6 +547,9 @@ remove_wait_queue(&dev->lock.lock_queue, &entry); if(!retcode) { mga_reclaim_buffers(dev, priv->pid); + if (dev->dev_private) + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status &= MGA_IN_DISPATCH; drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); } @@ -566,14 +557,23 @@ drm_fasync(-1, filp, 0); down(&dev->struct_sem); + if (priv->remove_auth_on_close == 1) { + drm_file_t *temp = dev->file_first; + while(temp) { + temp->authenticated = 0; + temp = temp->next; + } + } if (priv->prev) priv->prev->next = priv->next; else dev->file_first = priv->next; if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_close); spin_lock(&dev->count_lock); if (!--dev->open_count) { @@ -582,12 +582,15 @@ atomic_read(&dev->ioctl_count), dev->blocked); spin_unlock(&dev->count_lock); + unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); + unlock_kernel(); return mga_takedown(dev); } - spin_unlock(&dev->count_lock); + spin_unlock(&dev->count_lock); + unlock_kernel(); return retcode; } @@ -607,9 +610,6 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - - DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", - current->pid, cmd, nr, dev->device, priv->authenticated); if (nr >= MGA_IOCTL_COUNT) { retcode = -EINVAL; @@ -618,7 +618,10 @@ func = ioctl->func; if (!func) { - DRM_DEBUG("no function\n"); + DRM_DEBUG("no function: pid = %d, cmd = 0x%02x," + " nr = 0x%02x, dev 0x%x, auth = %d\n", + current->pid, cmd, nr, dev->device, + priv->authenticated); retcode = -EINVAL; } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) || (ioctl->auth_needed && !priv->authenticated)) { @@ -627,7 +630,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -638,18 +641,16 @@ drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_lock_t lock; + + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); return -EINVAL; } - DRM_DEBUG("%d frees lock (%d holds)\n", - lock.context, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); atomic_inc(&dev->total_unlocks); if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) atomic_inc(&dev->total_contends); @@ -657,9 +658,8 @@ mga_dma_schedule(dev, 1); if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - DRM_ERROR("\n"); - } + DRM_KERNEL_CONTEXT)) DRM_ERROR("\n"); + unblock_all_signals(); return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h:1.2 Fri Jun 16 20:03:37 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h Wed Nov 8 00:03:07 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -39,8 +39,8 @@ typedef struct { u32 buffer_status; - unsigned int num_dwords; - unsigned int max_dwords; + int num_dwords; + int max_dwords; u32 *current_dma_ptr; u32 *head; u32 phys_head; @@ -50,7 +50,7 @@ } drm_mga_prim_buf_t; typedef struct _drm_mga_freelist { - unsigned int age; + __volatile__ unsigned int age; drm_buf_t *buf; struct _drm_mga_freelist *next; struct _drm_mga_freelist *prev; @@ -82,6 +82,7 @@ int use_agp; drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES]; unsigned int WarpPipe; + unsigned int vertexsize; atomic_t pending_bufs; void *status_page; unsigned long real_status_page; @@ -97,13 +98,11 @@ wait_queue_head_t wait_queue; /* Processes waiting until interrupt */ wait_queue_head_t buf_queue; /* Processes waiting for a free buf */ /* Some validated register values: - */ + */ u32 mAccess; } drm_mga_private_t; /* mga_drv.c */ -extern int mga_init(void); -extern void mga_cleanup(void); extern int mga_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_open(struct inode *inode, struct file *filp); @@ -130,7 +129,6 @@ extern int mga_dma_cleanup(drm_device_t *dev); extern int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern void mga_flush_write_combine(void); extern unsigned int mga_create_sync_tag(drm_device_t *dev); extern drm_buf_t *mga_freelist_get(drm_device_t *dev); extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf); @@ -139,9 +137,9 @@ /* mga_bufs.c */ -extern int mga_addbufs(struct inode *inode, struct file *filp, +extern int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int mga_infobufs(struct inode *inode, struct file *filp, +extern int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); @@ -181,6 +179,7 @@ extern int mga_context_switch(drm_device_t *dev, int old, int new); extern int mga_context_switch_complete(drm_device_t *dev, int new); +#define mga_flush_write_combine() mb() typedef enum { TT_GENERAL, @@ -203,7 +202,7 @@ #define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END) #define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2) #define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80) -#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) +#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) #define MGA_VERBOSE 0 #define MGA_NUM_PRIM_BUFS 8 @@ -211,19 +210,26 @@ #define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ int outcount, num_dwords -#define PRIM_OVERFLOW(dev, dev_priv, length) do { \ - drm_mga_prim_buf_t *tmp_buf = \ - dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ - if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \ - &tmp_buf->buffer_status)) { \ - mga_advance_primary(dev); \ - mga_dma_schedule(dev, 1); \ - } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length ||\ - tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ - set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ - mga_advance_primary(dev); \ - mga_dma_schedule(dev, 1); \ - } \ +#define PRIM_OVERFLOW(dev, dev_priv, length) do { \ + drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + if( test_bit(MGA_BUF_NEEDS_OVERFLOW, &tmp_buf->buffer_status)) { \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ + tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \ + tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ + set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ + tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + } \ + if(MGA_VERBOSE) \ + DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \ + dma_ptr = tmp_buf->current_dma_ptr; \ + num_dwords = tmp_buf->num_dwords; \ + phys_head = tmp_buf->phys_head; \ + outcount = 0; \ } while(0) #define PRIMGETPTR(dev_priv) do { \ @@ -289,7 +295,7 @@ num_dwords + 1 + outcount, ADRINDEX(reg), val); \ if( ++outcount == 4) { \ outcount = 0; \ - dma_ptr[0] = *(u32 *)tempIndex; \ + dma_ptr[0] = *(unsigned long *)tempIndex; \ dma_ptr+=5; \ num_dwords += 5; \ } \ @@ -371,6 +377,72 @@ #define MGAREG_YTOP 0x1c98 #define MGAREG_ZORG 0x1c0c +/* Warp registers */ +#define MGAREG_WR0 0x2d00 +#define MGAREG_WR1 0x2d04 +#define MGAREG_WR2 0x2d08 +#define MGAREG_WR3 0x2d0c +#define MGAREG_WR4 0x2d10 +#define MGAREG_WR5 0x2d14 +#define MGAREG_WR6 0x2d18 +#define MGAREG_WR7 0x2d1c +#define MGAREG_WR8 0x2d20 +#define MGAREG_WR9 0x2d24 +#define MGAREG_WR10 0x2d28 +#define MGAREG_WR11 0x2d2c +#define MGAREG_WR12 0x2d30 +#define MGAREG_WR13 0x2d34 +#define MGAREG_WR14 0x2d38 +#define MGAREG_WR15 0x2d3c +#define MGAREG_WR16 0x2d40 +#define MGAREG_WR17 0x2d44 +#define MGAREG_WR18 0x2d48 +#define MGAREG_WR19 0x2d4c +#define MGAREG_WR20 0x2d50 +#define MGAREG_WR21 0x2d54 +#define MGAREG_WR22 0x2d58 +#define MGAREG_WR23 0x2d5c +#define MGAREG_WR24 0x2d60 +#define MGAREG_WR25 0x2d64 +#define MGAREG_WR26 0x2d68 +#define MGAREG_WR27 0x2d6c +#define MGAREG_WR28 0x2d70 +#define MGAREG_WR29 0x2d74 +#define MGAREG_WR30 0x2d78 +#define MGAREG_WR31 0x2d7c +#define MGAREG_WR32 0x2d80 +#define MGAREG_WR33 0x2d84 +#define MGAREG_WR34 0x2d88 +#define MGAREG_WR35 0x2d8c +#define MGAREG_WR36 0x2d90 +#define MGAREG_WR37 0x2d94 +#define MGAREG_WR38 0x2d98 +#define MGAREG_WR39 0x2d9c +#define MGAREG_WR40 0x2da0 +#define MGAREG_WR41 0x2da4 +#define MGAREG_WR42 0x2da8 +#define MGAREG_WR43 0x2dac +#define MGAREG_WR44 0x2db0 +#define MGAREG_WR45 0x2db4 +#define MGAREG_WR46 0x2db8 +#define MGAREG_WR47 0x2dbc +#define MGAREG_WR48 0x2dc0 +#define MGAREG_WR49 0x2dc4 +#define MGAREG_WR50 0x2dc8 +#define MGAREG_WR51 0x2dcc +#define MGAREG_WR52 0x2dd0 +#define MGAREG_WR53 0x2dd4 +#define MGAREG_WR54 0x2dd8 +#define MGAREG_WR55 0x2ddc +#define MGAREG_WR56 0x2de0 +#define MGAREG_WR57 0x2de4 +#define MGAREG_WR58 0x2de8 +#define MGAREG_WR59 0x2dec +#define MGAREG_WR60 0x2df0 +#define MGAREG_WR61 0x2df4 +#define MGAREG_WR62 0x2df8 +#define MGAREG_WR63 0x2dfc + #define PDEA_pagpxfer_enable 0x2 #define WIA_wmode_suspend 0x0 @@ -390,8 +462,8 @@ #define DC_atype_zi 0x30 #define DC_atype_blk 0x40 #define DC_atype_i 0x70 -#define DC_linear_xy 0x0 -#define DC_linear_linear 0x80 +#define DC_linear_xy 0x0 +#define DC_linear_linear 0x80 #define DC_zmode_nozcmp 0x0 #define DC_zmode_ze 0x200 #define DC_zmode_zne 0x300 @@ -399,16 +471,16 @@ #define DC_zmode_zlte 0x500 #define DC_zmode_zgt 0x600 #define DC_zmode_zgte 0x700 -#define DC_solid_disable 0x0 -#define DC_solid_enable 0x800 -#define DC_arzero_disable 0x0 -#define DC_arzero_enable 0x1000 -#define DC_sgnzero_disable 0x0 -#define DC_sgnzero_enable 0x2000 -#define DC_shftzero_disable 0x0 -#define DC_shftzero_enable 0x4000 -#define DC_bop_SHIFT 16 -#define DC_trans_SHIFT 20 +#define DC_solid_disable 0x0 +#define DC_solid_enable 0x800 +#define DC_arzero_disable 0x0 +#define DC_arzero_enable 0x1000 +#define DC_sgnzero_disable 0x0 +#define DC_sgnzero_enable 0x2000 +#define DC_shftzero_disable 0x0 +#define DC_shftzero_enable 0x4000 +#define DC_bop_SHIFT 16 +#define DC_trans_SHIFT 20 #define DC_bltmod_bmonolef 0x0 #define DC_bltmod_bmonowf 0x8000000 #define DC_bltmod_bplan 0x2000000 @@ -417,21 +489,22 @@ #define DC_bltmod_bu32rgb 0xe000000 #define DC_bltmod_bu24bgr 0x16000000 #define DC_bltmod_bu24rgb 0x1e000000 -#define DC_pattern_disable 0x0 -#define DC_pattern_enable 0x20000000 -#define DC_transc_disable 0x0 -#define DC_transc_enable 0x40000000 -#define DC_clipdis_disable 0x0 -#define DC_clipdis_enable 0x80000000 +#define DC_pattern_disable 0x0 +#define DC_pattern_enable 0x20000000 +#define DC_transc_disable 0x0 +#define DC_transc_enable 0x40000000 +#define DC_clipdis_disable 0x0 +#define DC_clipdis_enable 0x80000000 + -#define SETADD_mode_vertlist 0x0 +#define SETADD_mode_vertlist 0x0 #define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \ DC_sgnzero_enable | DC_shftzero_enable | \ (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \ DC_solid_enable | DC_transc_enable) - + #define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \ DC_solid_disable | DC_arzero_disable | \ Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c:1.3 Fri Jun 30 13:15:18 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c Wed Nov 8 00:03:07 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -34,34 +34,50 @@ #include "mga_drv.h" #include "drm.h" +/* If you change the functions to set state, PLEASE + * change these values + */ + +#define MGAEMITCLIP_SIZE 10 +#define MGAEMITCTX_SIZE 20 +#define MGAG200EMITTEX_SIZE 20 +#define MGAG400EMITTEX0_SIZE 30 +#define MGAG400EMITTEX1_SIZE 25 +#define MGAG400EMITPIPE_SIZE 50 +#define MGAG200EMITPIPE_SIZE 15 + +#define MAX_STATE_SIZE ((MGAEMITCLIP_SIZE * MGA_NR_SAREA_CLIPRECTS) + \ + MGAEMITCTX_SIZE + MGAG400EMITTEX0_SIZE + \ + MGAG400EMITTEX1_SIZE + MGAG400EMITPIPE_SIZE) + static void mgaEmitClipRect(drm_mga_private_t * dev_priv, drm_clip_rect_t * box) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); /* This takes 10 dwords */ PRIMGETPTR(dev_priv); - /* Force reset of dwgctl (eliminates clip disable) */ + /* Force reset of dwgctl on G400 (eliminates clip disable bit) */ + if (dev_priv->chipset == MGA_CARD_TYPE_G400) { #if 0 - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); #else - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); #endif - + } PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1)); - PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / 2); - PRIMOUTREG(MGAREG_YBOT, box->y2 * dev_priv->stride / 2); + PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / dev_priv->cpp); + PRIMOUTREG(MGAREG_YBOT, box->y2 * dev_priv->stride / dev_priv->cpp); PRIMADVANCE(dev_priv); } @@ -71,9 +87,8 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - /* This takes a max of 15 dwords */ + /* This takes a max of 20 dwords */ PRIMGETPTR(dev_priv); PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]); @@ -91,6 +106,11 @@ PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]); PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]); PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); + + PRIMOUTREG(MGAREG_STENCIL, regs[MGA_CTXREG_STENCIL]); + PRIMOUTREG(MGAREG_STENCILCTL, regs[MGA_CTXREG_STENCILCTL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); } else { PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -106,7 +126,6 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[0]; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -125,9 +144,9 @@ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]); + PRIMOUTREG(MGAREG_WR24, regs[MGA_TEXREG_WIDTH]); - PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(MGAREG_WR34, regs[MGA_TEXREG_HEIGHT]); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -135,17 +154,17 @@ PRIMADVANCE(dev_priv); } +#define TMC_dualtex_enable 0x80 + static void mgaG400EmitTex0(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[0]; - int multitex = sarea_priv->WarpPipe & MGA_T2; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); - /* This takes a max of 30 dwords */ + /* This takes 30 dwords */ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]); @@ -160,22 +179,20 @@ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 49 * 4, 0); + PRIMOUTREG(MGAREG_WR49, 0); - PRIMOUTREG(0x2d00 + 57 * 4, 0); - PRIMOUTREG(0x2d00 + 53 * 4, 0); - PRIMOUTREG(0x2d00 + 61 * 4, 0); + PRIMOUTREG(MGAREG_WR57, 0); + PRIMOUTREG(MGAREG_WR53, 0); + PRIMOUTREG(MGAREG_WR61, 0); + PRIMOUTREG(MGAREG_WR52, 0x40); + + PRIMOUTREG(MGAREG_WR60, 0x40); + PRIMOUTREG(MGAREG_WR54, regs[MGA_TEXREG_WIDTH] | 0x40); + PRIMOUTREG(MGAREG_WR62, regs[MGA_TEXREG_HEIGHT] | 0x40); PRIMOUTREG(MGAREG_DMAPAD, 0); - - if (!multitex) { - PRIMOUTREG(0x2d00 + 52 * 4, 0x40); - PRIMOUTREG(0x2d00 + 60 * 4, 0x40); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - } - PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); - PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); @@ -189,7 +206,6 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[1]; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -209,14 +225,14 @@ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 49 * 4, 0); + PRIMOUTREG(MGAREG_WR49, 0); - PRIMOUTREG(0x2d00 + 57 * 4, 0); - PRIMOUTREG(0x2d00 + 53 * 4, 0); - PRIMOUTREG(0x2d00 + 61 * 4, 0); - PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); + PRIMOUTREG(MGAREG_WR57, 0); + PRIMOUTREG(MGAREG_WR53, 0); + PRIMOUTREG(MGAREG_WR61, 0); + PRIMOUTREG(MGAREG_WR52, regs[MGA_TEXREG_WIDTH] | 0x40); - PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_WR60, regs[MGA_TEXREG_HEIGHT] | 0x40); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); @@ -224,14 +240,16 @@ PRIMADVANCE(dev_priv); } -#define EMIT_PIPE 50 +#define MAGIC_FPARAM_HEX_VALUE 0x46480000 +/* This is the hex value of 12800.0f which is a magic value we must + * set in wr56. + */ + static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; - float fParam = 12800.0f; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -263,14 +281,14 @@ PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); - PRIMOUTREG(MGAREG_DMAPAD, 0); - - PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_TEXCTL2, 0x00008000); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0x00008000); + PRIMOUTREG(MGAREG_DMAPAD, 0); } PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807); @@ -286,18 +304,18 @@ PRIMOUTREG(MGAREG_WFLAG, 0); PRIMOUTREG(MGAREG_WFLAG1, 0); - PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam))); + PRIMOUTREG(MGAREG_WR56, MAGIC_FPARAM_HEX_VALUE); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */ - PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */ - - PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */ - PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */ - PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */ - PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */ + PRIMOUTREG(MGAREG_WR49, 0); /* Tex stage 0 */ + PRIMOUTREG(MGAREG_WR57, 0); /* Tex stage 0 */ + PRIMOUTREG(MGAREG_WR53, 0); /* Tex stage 1 */ + PRIMOUTREG(MGAREG_WR61, 0); /* Tex stage 1 */ + + PRIMOUTREG(MGAREG_WR54, 0x40); /* Tex stage 0 : w */ + PRIMOUTREG(MGAREG_WR62, 0x40); /* Tex stage 0 : h */ + PRIMOUTREG(MGAREG_WR52, 0x40); /* Tex stage 1 : w */ + PRIMOUTREG(MGAREG_WR60, 0x40); /* Tex stage 1 : h */ /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); @@ -314,7 +332,6 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -323,12 +340,12 @@ PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend); PRIMOUTREG(MGAREG_WVRTXSZ, 7); PRIMOUTREG(MGAREG_WFLAG, 0); - PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */ + PRIMOUTREG(MGAREG_WR24, 0); /* tex w/h */ - PRIMOUTREG(0x2d00 + 25 * 4, 0x100); - PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */ - PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF); - PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF); + PRIMOUTREG(MGAREG_WR25, 0x100); + PRIMOUTREG(MGAREG_WR34, 0); /* tex w/h */ + PRIMOUTREG(MGAREG_WR42, 0xFFFF); + PRIMOUTREG(MGAREG_WR60, 0xFFFF); /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); @@ -345,7 +362,6 @@ { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int dirty = sarea_priv->dirty; - DRM_DEBUG("%s\n", __FUNCTION__); if (dev_priv->chipset == MGA_CARD_TYPE_G400) { int multitex = sarea_priv->WarpPipe & MGA_T2; @@ -387,7 +403,6 @@ } } - /* Disallow all write destinations except the front and backbuffer. */ static int mgaVerifyContext(drm_mga_private_t * dev_priv) @@ -395,8 +410,6 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; - DRM_DEBUG("%s\n", __FUNCTION__); - if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset && regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) { DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n", @@ -415,8 +428,6 @@ { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - DRM_DEBUG("%s\n", __FUNCTION__); - if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) { DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n", sarea_priv->TexState[unit][MGA_TEXREG_ORG], @@ -434,8 +445,6 @@ unsigned int dirty = sarea_priv->dirty; int rv = 0; - DRM_DEBUG("%s\n", __FUNCTION__); - if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; @@ -463,8 +472,6 @@ unsigned long bus_address, unsigned int dstOrg, int length) { - DRM_DEBUG("%s\n", __FUNCTION__); - if (dstOrg < dev_priv->textureOffset || dstOrg + length > (dev_priv->textureOffset + dev_priv->textureSize)) { @@ -487,16 +494,13 @@ int use_agp = PDEA_pagpxfer_enable | 0x00000001; u16 y2; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); y2 = length / 64; PRIM_OVERFLOW(dev, dev_priv, 30); - PRIMGETPTR(dev_priv); PRIMOUTREG(MGAREG_DSTORG, destOrg); PRIMOUTREG(MGAREG_MACCESS, 0x00000000); - DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp); PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp); PRIMOUTREG(MGAREG_AR5, 64); @@ -510,10 +514,10 @@ PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16)); PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2); + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_SRCORG, 0); PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); PRIMADVANCE(dev_priv); } @@ -526,37 +530,23 @@ int length = buf->used; int use_agp = PDEA_pagpxfer_enable; int i = 0; - int primary_needed; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - - DRM_DEBUG("dispatch vertex %d addr 0x%lx, " - "length 0x%x nbox %d dirty %x\n", - buf->idx, address, length, - sarea_priv->nbox, sarea_priv->dirty); - - DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total); if (buf->used) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; - primary_needed = (50 + 15 + 15 + 30 + 25 + - 10 + 15 * MGA_NR_SAREA_CLIPRECTS); - PRIM_OVERFLOW(dev, dev_priv, primary_needed); + PRIM_OVERFLOW(dev, dev_priv, + (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS))); mgaEmitState(dev_priv); + +#if 0 + length = dev_priv->vertexsize * 3 * 4; +#endif + do { if (i < sarea_priv->nbox) { - DRM_DEBUG("idx %d Emit box %d/%d:" - "%d,%d - %d,%d\n", - buf->idx, - i, sarea_priv->nbox, - sarea_priv->boxes[i].x1, - sarea_priv->boxes[i].y1, - sarea_priv->boxes[i].x2, - sarea_priv->boxes[i].y2); - mgaEmitClipRect(dev_priv, &sarea_priv->boxes[i]); } @@ -592,36 +582,19 @@ unsigned int address = (unsigned int) buf->bus_address; int use_agp = PDEA_pagpxfer_enable; int i = 0; - int primary_needed; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - DRM_DEBUG("dispatch indices %d addr 0x%x, " - "start 0x%x end 0x%x nbox %d dirty %x\n", - buf->idx, address, start, end, - sarea_priv->nbox, sarea_priv->dirty); - if (start != end) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; - primary_needed = (50 + 15 + 15 + 30 + 25 + - 10 + 15 * MGA_NR_SAREA_CLIPRECTS); - PRIM_OVERFLOW(dev, dev_priv, primary_needed); + PRIM_OVERFLOW(dev, dev_priv, + (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS))); mgaEmitState(dev_priv); do { if (i < sarea_priv->nbox) { - DRM_DEBUG("idx %d Emit box %d/%d:" - "%d,%d - %d,%d\n", - buf->idx, - i, sarea_priv->nbox, - sarea_priv->boxes[i].x1, - sarea_priv->boxes[i].y1, - sarea_priv->boxes[i].x2, - sarea_priv->boxes[i].y2); - mgaEmitClipRect(dev_priv, &sarea_priv->boxes[i]); } @@ -634,6 +607,7 @@ SETADD_mode_vertlist)); PRIMOUTREG(MGAREG_SETUPEND, ((address + end) | use_agp)); +/* ((address + start + 12) | use_agp)); */ PRIMADVANCE(dev_priv); } while (++i < sarea_priv->nbox); } @@ -648,7 +622,9 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, unsigned int clear_color, - unsigned int clear_zval) + unsigned int clear_zval, + unsigned int clear_colormask, + unsigned int clear_depthmask) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -657,32 +633,21 @@ drm_clip_rect_t *pbox = sarea_priv->boxes; unsigned int cmd; int i; - int primary_needed; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); if (dev_priv->sgram) cmd = MGA_CLEAR_CMD | DC_atype_blk; else cmd = MGA_CLEAR_CMD | DC_atype_rstr; - primary_needed = nbox * 70; - if (primary_needed == 0) - primary_needed = 70; - PRIM_OVERFLOW(dev, dev_priv, primary_needed); - PRIMGETPTR(dev_priv); + PRIM_OVERFLOW(dev, dev_priv, 35 * MGA_NR_SAREA_CLIPRECTS); for (i = 0; i < nbox; i++) { unsigned int height = pbox[i].y2 - pbox[i].y1; - DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n", - pbox[i].x1, pbox[i].y1, pbox[i].x2, - pbox[i].y2, flags); - if (flags & MGA_FRONT) { - DRM_DEBUG("clear front\n"); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -695,9 +660,8 @@ } if (flags & MGA_BACK) { - DRM_DEBUG("clear back\n"); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -710,9 +674,8 @@ } if (flags & MGA_DEPTH) { - DRM_DEBUG("clear depth\n"); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_depthmask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -741,14 +704,11 @@ int nbox = sarea_priv->nbox; drm_clip_rect_t *pbox = sarea_priv->boxes; int i; - int primary_needed; + int pixel_stride = dev_priv->stride / dev_priv->cpp; + PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - primary_needed = nbox * 5; - primary_needed += 65; - PRIM_OVERFLOW(dev, dev_priv, primary_needed); - PRIMGETPTR(dev_priv); + PRIM_OVERFLOW(dev, dev_priv, (MGA_NR_SAREA_CLIPRECTS * 5) + 20); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -758,7 +718,7 @@ PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset); PRIMOUTREG(MGAREG_MACCESS, dev_priv->mAccess); PRIMOUTREG(MGAREG_SRCORG, dev_priv->backOffset); - PRIMOUTREG(MGAREG_AR5, dev_priv->stride / 2); + PRIMOUTREG(MGAREG_AR5, pixel_stride); PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -767,11 +727,8 @@ for (i = 0; i < nbox; i++) { unsigned int h = pbox[i].y2 - pbox[i].y1; - unsigned int start = pbox[i].y1 * dev_priv->stride / 2; + unsigned int start = pbox[i].y1 * pixel_stride; - DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n", - pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2); - PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1); PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1); PRIMOUTREG(MGAREG_FXBNDRY, @@ -799,9 +756,8 @@ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_mga_clear_t clear; - copy_from_user_ret(&clear, (drm_mga_clear_t *) arg, sizeof(clear), - -EFAULT); - DRM_DEBUG("%s\n", __FUNCTION__); + if (copy_from_user(&clear, (drm_mga_clear_t *) arg, sizeof(clear))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_clear_bufs called without lock held\n"); @@ -815,7 +771,10 @@ */ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX; mga_dma_dispatch_clear(dev, clear.flags, - clear.clear_color, clear.clear_depth); + clear.clear_color, + clear.clear_depth, + clear.clear_color_mask, + clear.clear_depth_mask); PRIMUPDATE(dev_priv); mga_flush_write_combine(); mga_dma_schedule(dev, 1); @@ -830,7 +789,6 @@ drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - DRM_DEBUG("%s\n", __FUNCTION__); if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_swap_bufs called without lock held\n"); @@ -865,11 +823,9 @@ drm_mga_buf_priv_t *buf_priv; drm_mga_iload_t iload; unsigned long bus_address; - DRM_DEBUG("%s\n", __FUNCTION__); - DRM_DEBUG("Starting Iload\n"); - copy_from_user_ret(&iload, (drm_mga_iload_t *) arg, sizeof(iload), - -EFAULT); + if (copy_from_user(&iload, (drm_mga_iload_t *) arg, sizeof(iload))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_iload called without lock held\n"); @@ -879,8 +835,6 @@ buf = dma->buflist[iload.idx]; buf_priv = buf->dev_private; bus_address = buf->bus_address; - DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n", - bus_address, iload.length, iload.destOrg); if (mgaVerifyIload(dev_priv, bus_address, iload.destOrg, iload.length)) { @@ -911,18 +865,15 @@ drm_buf_t *buf; drm_mga_buf_priv_t *buf_priv; drm_mga_vertex_t vertex; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&vertex, (drm_mga_vertex_t *) arg, - sizeof(vertex), -EFAULT); + if (copy_from_user(&vertex, (drm_mga_vertex_t *) arg, sizeof(vertex))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_vertex called without lock held\n"); return -EINVAL; } - DRM_DEBUG("mga_vertex\n"); - buf = dma->buflist[vertex.idx]; buf_priv = buf->dev_private; @@ -936,7 +887,6 @@ buf_priv->dispatched = 0; mga_freelist_put(dev, buf); } - DRM_DEBUG("bad state\n"); return -EINVAL; } @@ -960,18 +910,16 @@ drm_buf_t *buf; drm_mga_buf_priv_t *buf_priv; drm_mga_indices_t indices; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&indices, (drm_mga_indices_t *) arg, - sizeof(indices), -EFAULT); + if (copy_from_user(&indices, + (drm_mga_indices_t *)arg, sizeof(indices))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_indices called without lock held\n"); return -EINVAL; } - DRM_DEBUG("mga_indices\n"); - buf = dma->buflist[indices.idx]; buf_priv = buf->dev_private; @@ -1001,17 +949,18 @@ { int i; drm_buf_t *buf; - DRM_DEBUG("%s\n", __FUNCTION__); for (i = d->granted_count; i < d->request_count; i++) { buf = mga_freelist_get(dev); if (!buf) break; buf->pid = current->pid; - copy_to_user_ret(&d->request_indices[i], - &buf->idx, sizeof(buf->idx), -EFAULT); - copy_to_user_ret(&d->request_sizes[i], - &buf->total, sizeof(buf->total), -EFAULT); + if (copy_to_user(&d->request_indices[i], + &buf->idx, sizeof(buf->idx))) + return -EFAULT; + if (copy_to_user(&d->request_sizes[i], + &buf->total, sizeof(buf->total))) + return -EFAULT; ++d->granted_count; } return 0; @@ -1025,11 +974,9 @@ drm_device_dma_t *dma = dev->dma; int retcode = 0; drm_dma_t d; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&d, (drm_dma_t *) arg, sizeof(d), -EFAULT); - DRM_DEBUG("%d %d: %d send, %d req\n", - current->pid, d.context, d.send_count, d.request_count); + if (copy_from_user(&d, (drm_dma_t *) arg, sizeof(d))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_dma called without lock held\n"); @@ -1060,8 +1007,7 @@ retcode = mga_dma_get_buffers(dev, &d); } - DRM_DEBUG("%d returning, granted = %d\n", - current->pid, d.granted_count); - copy_to_user_ret((drm_dma_t *) arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *) arg, &d, sizeof(d))) + return -EFAULT; return retcode; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c:1.2 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c Wed Nov 8 00:03:07 2000 @@ -1,10 +1,15 @@ -#include <linux/autoconf.h> + +#include <linux/config.h> #include <linux/version.h> #ifndef CONFIG_SMP #define CONFIG_SMP 0 #endif +#ifndef CONFIG_MODULES +#define CONFIG_MODULES 0 +#endif + #ifndef CONFIG_MODVERSIONS #define CONFIG_MODVERSIONS 0 #endif @@ -17,8 +22,14 @@ #define CONFIG_AGP 0 #endif +#ifndef CONFIG_FB_SIS +#define CONFIG_FB_SIS 0 +#endif + SMP = CONFIG_SMP +MODULES = CONFIG_MODULES MODVERSIONS = CONFIG_MODVERSIONS AGP = CONFIG_AGP AGP_MODULE = CONFIG_AGP_MODULE RELEASE = UTS_RELEASE +SIS = CONFIG_FB_SIS Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c:1.7 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c Tue Sep 26 12:21:25 2000 @@ -228,7 +228,7 @@ atomic_inc(&q->use_count); DRM_PROC_PRINT_RET(atomic_dec(&q->use_count), "%5d/0x%03x %5d %5d" - " %5d/%c%c/%c%c%c %5d %10d %10d %10d\n", + " %5d/%c%c/%c%c%c %5Zd %10d %10d %10d\n", i, q->flags, atomic_read(&q->use_count), @@ -351,17 +351,21 @@ #if DRM_DEBUG_CODE +#define DRM_VMA_VERBOSE 0 + static int _drm_vma_info(char *buf, char **start, off_t offset, int len, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; drm_vma_entry_t *pt; + struct vm_area_struct *vma; +#if DRM_VMA_VERBOSE + unsigned long i; + unsigned long address; pgd_t *pgd; pmd_t *pmd; pte_t *pte; - unsigned long i; - struct vm_area_struct *vma; - unsigned long address; +#endif #if defined(__i386__) unsigned int pgprot; #endif @@ -517,9 +521,9 @@ } else { DRM_PROC_PRINT("lock none\n"); } - DRM_PROC_PRINT("context_flag 0x%08x\n", dev->context_flag); - DRM_PROC_PRINT("interrupt_flag 0x%08x\n", dev->interrupt_flag); - DRM_PROC_PRINT("dma_flag 0x%08x\n", dev->dma_flag); + DRM_PROC_PRINT("context_flag 0x%08lx\n", dev->context_flag); + DRM_PROC_PRINT("interrupt_flag 0x%08lx\n", dev->interrupt_flag); + DRM_PROC_PRINT("dma_flag 0x%08lx\n", dev->dma_flag); DRM_PROC_PRINT("queue_count %10d\n", dev->queue_count); DRM_PROC_PRINT("last_context %10d\n", dev->last_context); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c:1.1 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c Mon Dec 4 14:21:58 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,20 +23,21 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: Kevin E. Martin <martin@valinux.com> * Rickard E. (Rik) Faith <faith@valinux.com> * Jeff Hartmann <jhartmann@valinux.com> - * + * */ #define __NO_VERSION__ +#include <linux/config.h> #include "drmP.h" #include "r128_drv.h" #include "linux/un.h" -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) int r128_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -59,10 +60,10 @@ if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); @@ -93,7 +94,7 @@ } atomic_inc(&dev->buf_alloc); spin_unlock(&dev->count_lock); - + down(&dev->struct_sem); entry = &dma->bufs[order]; if (entry->buf_count) { @@ -101,7 +102,7 @@ atomic_dec(&dev->buf_alloc); return -ENOMEM; /* May only call once for each order */ } - + entry->buflist = drm_alloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS); if (!entry->buflist) { @@ -110,7 +111,7 @@ return -ENOMEM; } memset(entry->buflist, 0, count * sizeof(*entry->buflist)); - + entry->buf_size = size; entry->page_order = page_order; offset = 0; @@ -172,10 +173,10 @@ request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; dma->flags = _DRM_DMA_USE_AGP; @@ -194,12 +195,12 @@ if (!dev_priv || dev_priv->is_pci) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) if (request.flags & _DRM_AGP_BUFFER) return r128_addbufs_agp(inode, filp, cmd, arg); else @@ -233,25 +234,25 @@ ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_map_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; if (request.count >= dma->buf_count) { if (dma->flags & _DRM_DMA_USE_AGP) { drm_map_t *map; - map = dev_priv->agp_vertbufs; + map = dev_priv->buffers; if (!map) { retcode = -EINVAL; goto done; } down(¤t->mm->mmap_sem); - virtual = do_mmap(filp, 0, map->size, + virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE, - MAP_SHARED, + MAP_SHARED, (unsigned long)map->offset); up(¤t->mm->mmap_sem); } else { @@ -299,10 +300,10 @@ request.count = dma->buf_count; DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - copy_to_user_ret((drm_buf_map_t *)arg, + if (copy_to_user((drm_buf_map_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return retcode; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c:1.2 --- /dev/null Mon Dec 18 14:31:54 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c Tue Dec 12 12:17:14 2000 @@ -0,0 +1,1253 @@ +/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- + * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com + * + * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Gareth Hughes <gareth@valinux.com> + * + */ + +#define __NO_VERSION__ +#include "drmP.h" +#include "r128_drv.h" + +#include <linux/interrupt.h> /* For task queue support */ +#include <linux/delay.h> + + +/* FIXME: Temporary CCE packet buffer */ +u32 r128_cce_buffer[(1 << 14)] __attribute__ ((aligned (32))); + +/* CCE microcode (from ATI) */ +static u32 r128_cce_microcode[] = { + 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, + 1617039951, 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, + 599558925, 0, 589505315, 0, 596487092, 0, 589505315, 1, + 11544576, 1, 206848, 1, 311296, 1, 198656, 2, 912273422, 11, + 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, 28, + 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, + 30, 1, 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, + 1, 15630, 1, 51200, 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, + 15717, 1, 15718, 2, 43, 1, 15936948, 1, 570480831, 1, 14715071, + 12, 322123831, 1, 33953125, 12, 55, 1, 33559908, 1, 15718, 2, + 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, 509952, 1, + 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1, + 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, + 15975928, 1, 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, + 268449859, 2, 10307, 12, 176, 1, 15734, 1, 15735, 1, 15630, 1, + 15631, 1, 5253120, 6, 3145810, 16, 2150645232U, 1, 15864, 2, 82, + 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, 1, 7817, 1, 15729, + 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, 1, 16008, + 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0, + 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, + 180224, 1, 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, + 114880, 14, 125, 12, 206975, 1, 33559995, 12, 198784, 0, + 33570236, 1, 15803, 0, 15804, 3, 294912, 1, 294912, 3, 442370, + 1, 11544576, 0, 811612160, 1, 12593152, 1, 11536384, 1, + 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, 14793, + 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1, + 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, + 114880, 14, 159, 12, 198784, 1, 1109409213, 12, 198783, 1, + 1107312059, 12, 198784, 1, 1109409212, 2, 162, 1, 1075854781, 1, + 1073757627, 1, 1075854780, 1, 540672, 1, 10485760, 6, 3145894, + 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, 0, 0, 256, 14, + 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, 1, + 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, + 33560360, 1, 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, + 409611, 9, 188, 0, 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + + +#define DO_REMAP(_m) (_m)->handle = drm_ioremap((_m)->offset, (_m)->size) + +#define DO_REMAPFREE(_m) \ + do { \ + if ((_m)->handle && (_m)->size) \ + drm_ioremapfree((_m)->handle, (_m)->size); \ + } while (0) + +#define DO_FIND_MAP(_m, _o) \ + do { \ + int _i; \ + for (_i = 0; _i < dev->map_count; _i++) { \ + if (dev->maplist[_i]->offset == _o) { \ + _m = dev->maplist[_i]; \ + break; \ + } \ + } \ + } while (0) + + +int R128_READ_PLL(drm_device_t *dev, int addr) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + + R128_WRITE8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); + return R128_READ(R128_CLOCK_CNTL_DATA); +} + +#if 0 +static void r128_status( drm_r128_private_t *dev_priv ) +{ + printk( "GUI_STAT = 0x%08x\n", + (unsigned int)R128_READ( R128_GUI_STAT ) ); + printk( "PM4_STAT = 0x%08x\n", + (unsigned int)R128_READ( R128_PM4_STAT ) ); + printk( "PM4_BUFFER_DL_WPTR = 0x%08x\n", + (unsigned int)R128_READ( R128_PM4_BUFFER_DL_WPTR ) ); + printk( "PM4_BUFFER_DL_RPTR = 0x%08x\n", + (unsigned int)R128_READ( R128_PM4_BUFFER_DL_RPTR ) ); + printk( "PM4_MICRO_CNTL = 0x%08x\n", + (unsigned int)R128_READ( R128_PM4_MICRO_CNTL ) ); + printk( "PM4_BUFFER_CNTL = 0x%08x\n", + (unsigned int)R128_READ( R128_PM4_BUFFER_CNTL ) ); +} +#endif + + +/* ================================================================ + * Engine, FIFO control + */ + +static int r128_do_pixcache_flush( drm_r128_private_t *dev_priv ) +{ + u32 tmp; + int i; + + tmp = R128_READ( R128_PC_NGUI_CTLSTAT ) | R128_PC_FLUSH_ALL; + R128_WRITE( R128_PC_NGUI_CTLSTAT, tmp ); + + for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { + if ( !(R128_READ( R128_PC_NGUI_CTLSTAT ) & R128_PC_BUSY) ) { + return 0; + } + udelay( 1 ); + } + + DRM_ERROR( "%s failed!\n", __FUNCTION__ ); + return -EBUSY; +} + +static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries ) +{ + int i; + + for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { + int slots = R128_READ( R128_GUI_STAT ) & R128_GUI_FIFOCNT_MASK; + if ( slots >= entries ) return 0; + udelay( 1 ); + } + + DRM_ERROR( "%s failed!\n", __FUNCTION__ ); + return -EBUSY; +} + +static int r128_do_wait_for_idle( drm_r128_private_t *dev_priv ) +{ + int i, ret; + + ret = r128_do_wait_for_fifo( dev_priv, 64 ); + if ( !ret ) return ret; + + for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { + if ( !(R128_READ( R128_GUI_STAT ) & R128_GUI_ACTIVE) ) { + r128_do_pixcache_flush( dev_priv ); + return 0; + } + udelay( 1 ); + } + + DRM_ERROR( "%s failed!\n", __FUNCTION__ ); + return -EBUSY; +} + + +/* ================================================================ + * CCE control, initialization + */ + +/* Load the microcode for the CCE */ +static void r128_cce_load_microcode( drm_r128_private_t *dev_priv ) +{ + int i; + + r128_do_wait_for_idle( dev_priv ); + + R128_WRITE( R128_PM4_MICROCODE_ADDR, 0 ); + for ( i = 0 ; i < 256 ; i++ ) { + R128_WRITE( R128_PM4_MICROCODE_DATAH, + r128_cce_microcode[i * 2] ); + R128_WRITE( R128_PM4_MICROCODE_DATAL, + r128_cce_microcode[i * 2 + 1] ); + } +} + +/* Flush any pending commands to the CCE. This should only be used just + * prior to a wait for idle, as it informs the engine that the command + * stream is ending. + */ +static void r128_do_cce_flush( drm_r128_private_t *dev_priv ) +{ + u32 tmp; + + tmp = R128_READ( R128_PM4_BUFFER_DL_WPTR ) | R128_PM4_BUFFER_DL_DONE; + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, tmp ); +} + +/* Wait for the CCE to go idle. + */ +static int r128_do_cce_idle( drm_r128_private_t *dev_priv ) +{ + int i; + + for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { + if ( *dev_priv->ring.head == dev_priv->ring.tail ) { + int pm4stat = R128_READ( R128_PM4_STAT ); + if ( ( (pm4stat & R128_PM4_FIFOCNT_MASK) >= + dev_priv->cce_fifo_size ) && + !(pm4stat & (R128_PM4_BUSY | + R128_PM4_GUI_ACTIVE)) ) { + return r128_do_pixcache_flush( dev_priv ); + } + } + udelay( 1 ); + } + +#if 0 + DRM_ERROR( "failed!\n" ); + r128_status( dev_priv ); +#endif + return -EBUSY; +} + +/* Start the Concurrent Command Engine. + */ +static void r128_do_cce_start( drm_r128_private_t *dev_priv ) +{ + r128_do_wait_for_idle( dev_priv ); + + R128_WRITE( R128_PM4_BUFFER_CNTL, + dev_priv->cce_mode | dev_priv->ring.size_l2qw ); + R128_READ( R128_PM4_BUFFER_ADDR ); /* as per the sample code */ + R128_WRITE( R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN ); + + dev_priv->cce_running = 1; +} + +/* Reset the Concurrent Command Engine. This will not flush any pending + * commangs, so you must wait for the CCE command stream to complete + * before calling this routine. + */ +static void r128_do_cce_reset( drm_r128_private_t *dev_priv ) +{ + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); + R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); + *dev_priv->ring.head = 0; + dev_priv->ring.tail = 0; +} + +/* Stop the Concurrent Command Engine. This will not flush any pending + * commangs, so you must flush the command stream and wait for the CCE + * to go idle before calling this routine. + */ +static void r128_do_cce_stop( drm_r128_private_t *dev_priv ) +{ + R128_WRITE( R128_PM4_MICRO_CNTL, 0 ); + R128_WRITE( R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4 ); + + dev_priv->cce_running = 0; +} + +/* Reset the engine. This will stop the CCE if it is running. + */ +static int r128_do_engine_reset( drm_device_t *dev ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 clock_cntl_index, mclk_cntl, gen_reset_cntl; + + r128_do_pixcache_flush( dev_priv ); + + clock_cntl_index = R128_READ( R128_CLOCK_CNTL_INDEX ); + mclk_cntl = R128_READ_PLL( dev, R128_MCLK_CNTL ); + + R128_WRITE_PLL( R128_MCLK_CNTL, + mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP ); + + gen_reset_cntl = R128_READ( R128_GEN_RESET_CNTL ); + + /* Taken from the sample code - do not change */ + R128_WRITE( R128_GEN_RESET_CNTL, + gen_reset_cntl | R128_SOFT_RESET_GUI ); + R128_READ( R128_GEN_RESET_CNTL ); + R128_WRITE( R128_GEN_RESET_CNTL, + gen_reset_cntl & ~R128_SOFT_RESET_GUI ); + R128_READ( R128_GEN_RESET_CNTL ); + + R128_WRITE_PLL( R128_MCLK_CNTL, mclk_cntl ); + R128_WRITE( R128_CLOCK_CNTL_INDEX, clock_cntl_index ); + R128_WRITE( R128_GEN_RESET_CNTL, gen_reset_cntl ); + + /* Reset the CCE ring */ + r128_do_cce_reset( dev_priv ); + + /* The CCE is no longer running after an engine reset */ + dev_priv->cce_running = 0; + + /* Reset any pending vertex, indirect buffers */ + r128_freelist_reset( dev ); + + return 0; +} + +static void r128_cce_init_ring_buffer( drm_device_t *dev ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 ring_start; + u32 tmp; + + /* The manual (p. 2) says this address is in "VM space". This + * means it's an offset from the start of AGP space. + */ + ring_start = dev_priv->cce_ring->offset - dev->agp->base; + R128_WRITE( R128_PM4_BUFFER_OFFSET, ring_start | R128_AGP_OFFSET ); + + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); + R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); + + /* DL_RPTR_ADDR is a physical address in AGP space. */ + *dev_priv->ring.head = 0; + R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR, + dev_priv->ring_rptr->offset ); + + /* Set watermark control */ + R128_WRITE( R128_PM4_BUFFER_WM_CNTL, + ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) + | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) + | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) + | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT) ); + + /* Force read. Why? Because it's in the examples... */ + R128_READ( R128_PM4_BUFFER_ADDR ); + + /* Turn on bus mastering */ + tmp = R128_READ( R128_BUS_CNTL ) & ~R128_BUS_MASTER_DIS; + R128_WRITE( R128_BUS_CNTL, tmp ); +} + +static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) +{ + drm_r128_private_t *dev_priv; + int i; + + dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER ); + if ( dev_priv == NULL ) + return -ENOMEM; + dev->dev_private = (void *)dev_priv; + + memset( dev_priv, 0, sizeof(drm_r128_private_t) ); + + dev_priv->is_pci = init->is_pci; + + /* GH: We don't support PCI cards until PCI GART is implemented. + * Fail here so we can remove all checks for PCI cards around + * the CCE ring code. + */ + if ( dev_priv->is_pci ) { + drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); + dev->dev_private = NULL; + return -EINVAL; + } + + dev_priv->usec_timeout = init->usec_timeout; + if ( dev_priv->usec_timeout < 1 || + dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT ) { + drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); + dev->dev_private = NULL; + return -EINVAL; + } + + dev_priv->cce_mode = init->cce_mode; + dev_priv->cce_secure = init->cce_secure; + + /* GH: Simple idle check. + */ + atomic_set( &dev_priv->idle_count, 0 ); + + /* We don't support anything other than bus-mastering ring mode, + * but the ring can be in either AGP or PCI space for the ring + * read pointer. + */ + if ( ( init->cce_mode != R128_PM4_192BM ) && + ( init->cce_mode != R128_PM4_128BM_64INDBM ) && + ( init->cce_mode != R128_PM4_64BM_128INDBM ) && + ( init->cce_mode != R128_PM4_64BM_64VCBM_64INDBM ) ) { + drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); + dev->dev_private = NULL; + return -EINVAL; + } + + switch ( init->cce_mode ) { + case R128_PM4_NONPM4: + dev_priv->cce_fifo_size = 0; + break; + case R128_PM4_192PIO: + case R128_PM4_192BM: + dev_priv->cce_fifo_size = 192; + break; + case R128_PM4_128PIO_64INDBM: + case R128_PM4_128BM_64INDBM: + dev_priv->cce_fifo_size = 128; + break; + case R128_PM4_64PIO_128INDBM: + case R128_PM4_64BM_128INDBM: + case R128_PM4_64PIO_64VCBM_64INDBM: + case R128_PM4_64BM_64VCBM_64INDBM: + case R128_PM4_64PIO_64VCPIO_64INDPIO: + dev_priv->cce_fifo_size = 64; + break; + } + + dev_priv->fb_bpp = init->fb_bpp; + dev_priv->front_offset = init->front_offset; + dev_priv->front_pitch = init->front_pitch; + dev_priv->back_offset = init->back_offset; + dev_priv->back_pitch = init->back_pitch; + + dev_priv->depth_bpp = init->depth_bpp; + dev_priv->depth_offset = init->depth_offset; + dev_priv->depth_pitch = init->depth_pitch; + dev_priv->span_offset = init->span_offset; + + dev_priv->front_pitch_offset_c = (((dev_priv->front_pitch/8) << 21) | + (dev_priv->front_offset >> 5)); + dev_priv->back_pitch_offset_c = (((dev_priv->back_pitch/8) << 21) | + (dev_priv->back_offset >> 5)); + dev_priv->depth_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) | + (dev_priv->depth_offset >> 5) | + R128_DST_TILE); + dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) | + (dev_priv->span_offset >> 5)); + + /* FIXME: We want multiple shared areas, including one shared + * only by the X Server and kernel module. + */ + for ( i = 0 ; i < dev->map_count ; i++ ) { + if ( dev->maplist[i]->type == _DRM_SHM ) { + dev_priv->sarea = dev->maplist[i]; + break; + } + } + + DO_FIND_MAP( dev_priv->fb, init->fb_offset ); + DO_FIND_MAP( dev_priv->mmio, init->mmio_offset ); + DO_FIND_MAP( dev_priv->cce_ring, init->ring_offset ); + DO_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset ); + DO_FIND_MAP( dev_priv->buffers, init->buffers_offset ); + + if ( !dev_priv->is_pci ) { + DO_FIND_MAP( dev_priv->agp_textures, + init->agp_textures_offset ); + } + + dev_priv->sarea_priv = + (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + + init->sarea_priv_offset); + + DO_REMAP( dev_priv->cce_ring ); + DO_REMAP( dev_priv->ring_rptr ); + DO_REMAP( dev_priv->buffers ); +#if 0 + if ( !dev_priv->is_pci ) { + DO_REMAP( dev_priv->agp_textures ); + } +#endif + + dev_priv->ring.head = ((__volatile__ u32 *) + dev_priv->ring_rptr->handle); + + dev_priv->ring.start = (u32 *)dev_priv->cce_ring->handle; + dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle + + init->ring_size / sizeof(u32)); + dev_priv->ring.size = init->ring_size; + dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 ); + + dev_priv->ring.tail_mask = + (dev_priv->ring.size / sizeof(u32)) - 1; + + dev_priv->sarea_priv->last_frame = 0; + R128_WRITE( R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame ); + + dev_priv->sarea_priv->last_dispatch = 0; + R128_WRITE( R128_LAST_DISPATCH_REG, + dev_priv->sarea_priv->last_dispatch ); + + r128_cce_init_ring_buffer( dev ); + r128_cce_load_microcode( dev_priv ); + r128_do_engine_reset( dev ); + + return 0; +} + +static int r128_do_cleanup_cce( drm_device_t *dev ) +{ + if ( dev->dev_private ) { + drm_r128_private_t *dev_priv = dev->dev_private; + + DO_REMAPFREE( dev_priv->cce_ring ); + DO_REMAPFREE( dev_priv->ring_rptr ); + DO_REMAPFREE( dev_priv->buffers ); +#if 0 + if ( !dev_priv->is_pci ) { + DO_REMAPFREE( dev_priv->agp_textures ); + } +#endif + + drm_free( dev->dev_private, sizeof(drm_r128_private_t), + DRM_MEM_DRIVER ); + dev->dev_private = NULL; + } + + return 0; +} + +int r128_cce_init( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_init_t init; + + if ( copy_from_user( &init, (drm_r128_init_t *)arg, sizeof(init) ) ) + return -EFAULT; + + switch ( init.func ) { + case R128_INIT_CCE: + return r128_do_init_cce( dev, &init ); + case R128_CLEANUP_CCE: + return r128_do_cleanup_cce( dev ); + } + + return -EINVAL; +} + +int r128_cce_start( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + if ( dev_priv->cce_running || dev_priv->cce_mode == R128_PM4_NONPM4 ) { + DRM_DEBUG( "%s while CCE running\n", __FUNCTION__ ); + return 0; + } + + r128_do_cce_start( dev_priv ); + + return 0; +} + +/* Stop the CCE. The engine must have been idled before calling this + * routine. + */ +int r128_cce_stop( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_cce_stop_t stop; + int ret; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &stop, (drm_r128_init_t *)arg, sizeof(stop) ) ) + return -EFAULT; + + /* Flush any pending CCE commands. This ensures any outstanding + * commands are exectuted by the engine before we turn it off. + */ + if ( stop.flush ) { + r128_do_cce_flush( dev_priv ); + } + + /* If we fail to make the engine go idle, we return an error + * code so that the DRM ioctl wrapper can try again. + */ + if ( stop.idle ) { + ret = r128_do_cce_idle( dev_priv ); + if ( ret < 0 ) return ret; + } + + /* Finally, we can turn off the CCE. If the engine isn't idle, + * we will get some dropped triangles as they won't be fully + * rendered before the CCE is shut down. + */ + r128_do_cce_stop( dev_priv ); + + /* Reset the engine */ + r128_do_engine_reset( dev ); + + return 0; +} + +/* Just reset the CCE ring. Called as part of an X Server engine reset. + */ +int r128_cce_reset( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + if ( !dev_priv ) { + DRM_DEBUG( "%s called before init done\n", __FUNCTION__ ); + return -EINVAL; + } + + r128_do_cce_reset( dev_priv ); + + /* The CCE is no longer running after an engine reset */ + dev_priv->cce_running = 0; + + return 0; +} + +int r128_cce_idle( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( dev_priv->cce_running ) { + r128_do_cce_flush( dev_priv ); + } + + return r128_do_cce_idle( dev_priv ); +} + +int r128_engine_reset( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + return r128_do_engine_reset( dev ); +} + + +/* ================================================================ + * Freelist management + */ +#define R128_BUFFER_USED 0xffffffff +#define R128_BUFFER_FREE 0 + +#if 0 +static int r128_freelist_init( drm_device_t *dev ) +{ + drm_device_dma_t *dma = dev->dma; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_buf_t *buf; + drm_r128_buf_priv_t *buf_priv; + drm_r128_freelist_t *entry; + int i; + + dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t), + DRM_MEM_DRIVER ); + if ( dev_priv->head == NULL ) + return -ENOMEM; + + memset( dev_priv->head, 0, sizeof(drm_r128_freelist_t) ); + dev_priv->head->age = R128_BUFFER_USED; + + for ( i = 0 ; i < dma->buf_count ; i++ ) { + buf = dma->buflist[i]; + buf_priv = buf->dev_private; + + entry = drm_alloc( sizeof(drm_r128_freelist_t), + DRM_MEM_DRIVER ); + if ( !entry ) return -ENOMEM; + + entry->age = R128_BUFFER_FREE; + entry->buf = buf; + entry->prev = dev_priv->head; + entry->next = dev_priv->head->next; + if ( !entry->next ) + dev_priv->tail = entry; + + buf_priv->discard = 0; + buf_priv->dispatched = 0; + buf_priv->list_entry = entry; + + dev_priv->head->next = entry; + + if ( dev_priv->head->next ) + dev_priv->head->next->prev = entry; + } + + return 0; + +} +#endif + +drm_buf_t *r128_freelist_get( drm_device_t *dev ) +{ + drm_device_dma_t *dma = dev->dma; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv; + drm_buf_t *buf; + int i, t; + + /* FIXME: Optimize -- use freelist code */ + + for ( i = 0 ; i < dma->buf_count ; i++ ) { + buf = dma->buflist[i]; + buf_priv = buf->dev_private; + if ( buf->pid == 0 ) + return buf; + } + + for ( t = 0 ; t < dev_priv->usec_timeout ; t++ ) { + u32 done_age = R128_READ( R128_LAST_DISPATCH_REG ); + + for ( i = 0 ; i < dma->buf_count ; i++ ) { + buf = dma->buflist[i]; + buf_priv = buf->dev_private; + if ( buf->pending && buf_priv->age <= done_age ) { + /* The buffer has been processed, so it + * can now be used. + */ + buf->pending = 0; + return buf; + } + } + udelay( 1 ); + } + + DRM_ERROR( "returning NULL!\n" ); + return NULL; +} + +void r128_freelist_reset( drm_device_t *dev ) +{ + drm_device_dma_t *dma = dev->dma; + int i; + + for ( i = 0 ; i < dma->buf_count ; i++ ) { + drm_buf_t *buf = dma->buflist[i]; + drm_r128_buf_priv_t *buf_priv = buf->dev_private; + buf_priv->age = 0; + } +} + + +/* ================================================================ + * CCE packet submission + */ + +int r128_wait_ring( drm_r128_private_t *dev_priv, int n ) +{ + drm_r128_ring_buffer_t *ring = &dev_priv->ring; + int i; + + for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { + ring->space = *ring->head - ring->tail; + if ( ring->space <= 0 ) + ring->space += ring->size; + + if ( ring->space >= n ) + return 0; + + udelay( 1 ); + } + + return -EBUSY; +} + +void r128_update_ring_snapshot( drm_r128_private_t *dev_priv ) +{ + drm_r128_ring_buffer_t *ring = &dev_priv->ring; + + ring->space = *ring->head - ring->tail; +#if R128_PERFORMANCE_BOXES + if ( ring->space == 0 ) + atomic_inc( &dev_priv->idle_count ); +#endif + if ( ring->space <= 0 ) + ring->space += ring->size; +} + +#if 0 +static int r128_verify_command( drm_r128_private_t *dev_priv, + u32 cmd, int *size ) +{ + int writing = 1; + + *size = 0; + + switch ( cmd & R128_CCE_PACKET_MASK ) { + case R128_CCE_PACKET0: + if ( (cmd & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2) && + (cmd & R128_CCE_PACKET0_REG_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2) ) { + writing = 0; + } + *size = ((cmd & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + break; + + case R128_CCE_PACKET1: + if ( (cmd & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2) && + (cmd & R128_CCE_PACKET1_REG0_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2) ) { + writing = 0; + } + if ( (cmd & R128_CCE_PACKET1_REG1_MASK) <= (0x1004 << 9) && + (cmd & R128_CCE_PACKET1_REG1_MASK) != + (R128_PM4_VC_FPU_SETUP << 9) ) { + writing = 0; + } + *size = 3; + break; + + case R128_CCE_PACKET2: + break; + + case R128_CCE_PACKET3: + *size = ((cmd & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + break; + + } + + return writing; +} + +static int r128_submit_packet_ring_secure( drm_r128_private_t *dev_priv, + u32 *commands, int *count ) +{ +#if 0 + int write = dev_priv->sarea_priv->ring_write; + int *write_ptr = dev_priv->ring_start + write; + int c = *count; + u32 tmp = 0; + int psize = 0; + int writing = 1; + int timeout; + + while ( c > 0 ) { + tmp = *commands++; + if ( !psize ) { + writing = r128_verify_command( dev_priv, tmp, &psize ); + } + psize--; + + if ( writing ) { + write++; + *write_ptr++ = tmp; + } + if ( write >= dev_priv->ring_entries ) { + write = 0; + write_ptr = dev_priv->ring_start; + } + timeout = 0; + while ( write == *dev_priv->ring_read_ptr ) { + R128_READ( R128_PM4_BUFFER_DL_RPTR ); + if ( timeout++ >= dev_priv->usec_timeout ) + return -EBUSY; + udelay( 1 ); + } + c--; + } + + if ( write < 32 ) { + memcpy( dev_priv->ring_end, + dev_priv->ring_start, + write * sizeof(u32) ); + } + + /* Make sure WC cache has been flushed */ + r128_flush_write_combine(); + + dev_priv->sarea_priv->ring_write = write; + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); + + *count = 0; +#endif + return 0; +} + +static int r128_submit_packet_ring_insecure( drm_r128_private_t *dev_priv, + u32 *commands, int *count ) +{ +#if 0 + int write = dev_priv->sarea_priv->ring_write; + int *write_ptr = dev_priv->ring_start + write; + int c = *count; + int timeout; + + while ( c > 0 ) { + write++; + *write_ptr++ = *commands++; + if ( write >= dev_priv->ring_entries ) { + write = 0; + write_ptr = dev_priv->ring_start; + } + + timeout = 0; + while ( write == *dev_priv->ring_read_ptr ) { + R128_READ( R128_PM4_BUFFER_DL_RPTR ); + if ( timeout++ >= dev_priv->usec_timeout ) + return -EBUSY; + udelay( 1 ); + } + c--; + } + + if ( write < 32 ) { + memcpy( dev_priv->ring_end, + dev_priv->ring_start, + write * sizeof(u32) ); + } + + /* Make sure WC cache has been flushed */ + r128_flush_write_combine(); + + dev_priv->sarea_priv->ring_write = write; + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); + + *count = 0; +#endif + return 0; +} +#endif + +/* Internal packet submission routine. This uses the insecure versions + * of the packet submission functions, and thus should only be used for + * packets generated inside the kernel module. + */ +int r128_do_submit_packet( drm_r128_private_t *dev_priv, + u32 *buffer, int count ) +{ + int c = count; + int ret = 0; + +#if 0 + int left = 0; + + if ( c >= dev_priv->ring_entries ) { + c = dev_priv->ring_entries - 1; + left = count - c; + } + + /* Since this is only used by the kernel we can use the + * insecure ring buffer submit packet routine. + */ + ret = r128_submit_packet_ring_insecure( dev_priv, buffer, &c ); + c += left; +#endif + + return ( ret < 0 ) ? ret : c; +} + +/* External packet submission routine. This uses the secure versions + * by default, and can thus submit packets received from user space. + */ +int r128_cce_packet( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_packet_t packet; + u32 *buffer; + int c; + int size; + int ret = 0; + +#if 0 + /* GH: Disable packet submission for now. + */ + return -EINVAL; +#endif + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "r128_submit_packet called without lock held\n" ); + return -EINVAL; + } + + if ( copy_from_user( &packet, (drm_r128_packet_t *)arg, + sizeof(packet) ) ) + return -EFAULT; + +#if 0 + c = packet.count; + size = c * sizeof(*buffer); + + { + int left = 0; + + if ( c >= dev_priv->ring_entries ) { + c = dev_priv->ring_entries - 1; + size = c * sizeof(*buffer); + left = packet.count - c; + } + + buffer = kmalloc( size, 0 ); + if ( buffer == NULL) + return -ENOMEM; + if ( copy_from_user( buffer, packet.buffer, size ) ) + return -EFAULT; + + if ( dev_priv->cce_secure ) { + ret = r128_submit_packet_ring_secure( dev_priv, + buffer, &c ); + } else { + ret = r128_submit_packet_ring_insecure( dev_priv, + buffer, &c ); + } + c += left; + } + + kfree( buffer ); +#else + c = 0; +#endif + + packet.count = c; + if ( copy_to_user( (drm_r128_packet_t *)arg, &packet, + sizeof(packet) ) ) + return -EFAULT; + + if ( ret ) { + return ret; + } else if ( c > 0 ) { + return -EAGAIN; + } + return 0; +} + +#if 0 +static int r128_send_vertbufs( drm_device_t *dev, drm_r128_vertex_t *v ) +{ + drm_device_dma_t *dma = dev->dma; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv; + drm_buf_t *buf; + int i, ret; + RING_LOCALS; + + /* Make sure we have valid data */ + for (i = 0; i < v->send_count; i++) { + int idx = v->send_indices[i]; + + if (idx < 0 || idx >= dma->buf_count) { + DRM_ERROR("Index %d (of %d max)\n", + idx, dma->buf_count - 1); + return -EINVAL; + } + buf = dma->buflist[idx]; + if (buf->pid != current->pid) { + DRM_ERROR("Process %d using buffer owned by %d\n", + current->pid, buf->pid); + return -EINVAL; + } + if (buf->pending) { + DRM_ERROR("Sending pending buffer:" + " buffer %d, offset %d\n", + v->send_indices[i], i); + return -EINVAL; + } + } + + /* Wait for idle, if we've wrapped to make sure that all pending + buffers have been processed */ + if (dev_priv->submit_age == R128_MAX_VBUF_AGE) { + if ((ret = r128_do_cce_idle(dev)) < 0) return ret; + dev_priv->submit_age = 0; + r128_freelist_reset(dev); + } + + /* Make sure WC cache has been flushed (if in PIO mode) */ + if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine(); + + /* FIXME: Add support for sending vertex buffer to the CCE here + instead of in client code. The v->prim holds the primitive + type that should be drawn. Loop over the list buffers in + send_indices[] and submit a packet for each VB. + + This will require us to loop over the clip rects here as + well, which implies that we extend the kernel driver to allow + cliprects to be stored here. Note that the cliprects could + possibly come from the X server instead of the client, but + this will require additional changes to the DRI to allow for + this optimization. */ + + /* Submit a CCE packet that writes submit_age to R128_VB_AGE_REG */ +#if 0 + cce_buffer[0] = R128CCE0(R128_CCE_PACKET0, R128_VB_AGE_REG, 0); + cce_buffer[1] = dev_priv->submit_age; + + if ((ret = r128_do_submit_packet(dev, cce_buffer, 2)) < 0) { + /* Until we add support for sending VBs to the CCE in + this routine, we can recover from this error. After + we add that support, we won't be able to easily + recover, so we will probably have to implement + another mechanism for handling timeouts from packets + submitted directly by the kernel. */ + return ret; + } +#else + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_VB_AGE_REG, 0 ) ); + OUT_RING( dev_priv->submit_age ); + + ADVANCE_RING(); +#endif + /* Now that the submit packet request has succeeded, we can mark + the buffers as pending */ + for (i = 0; i < v->send_count; i++) { + buf = dma->buflist[v->send_indices[i]]; + buf->pending = 1; + + buf_priv = buf->dev_private; + buf_priv->age = dev_priv->submit_age; + } + + dev_priv->submit_age++; + + return 0; +} +#endif + + + + +static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d ) +{ + int i; + drm_buf_t *buf; + + for ( i = d->granted_count ; i < d->request_count ; i++ ) { + buf = r128_freelist_get( dev ); + if ( !buf ) return -EAGAIN; + + buf->pid = current->pid; + + if ( copy_to_user( &d->request_indices[i], &buf->idx, + sizeof(buf->idx) ) ) + return -EFAULT; + if ( copy_to_user( &d->request_sizes[i], &buf->total, + sizeof(buf->total) ) ) + return -EFAULT; + + d->granted_count++; + } + return 0; +} + +int r128_cce_buffers( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + int ret = 0; + drm_dma_t d; + + if ( copy_from_user( &d, (drm_dma_t *) arg, sizeof(d) ) ) + return -EFAULT; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + /* Please don't send us buffers. + */ + if ( d.send_count != 0 ) { + DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n", + current->pid, d.send_count ); + return -EINVAL; + } + + /* We'll send you buffers. + */ + if ( d.request_count < 0 || d.request_count > dma->buf_count ) { + DRM_ERROR( "Process %d trying to get %d buffers (of %d max)\n", + current->pid, d.request_count, dma->buf_count ); + return -EINVAL; + } + + d.granted_count = 0; + + if ( d.request_count ) { + ret = r128_cce_get_buffers( dev, &d ); + } + + if ( copy_to_user( (drm_dma_t *) arg, &d, sizeof(d) ) ) + return -EFAULT; + + return ret; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c:1.1 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c Mon Dec 4 14:21:59 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,13 +23,11 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Author: Rickard E. (Rik) Faith <faith@valinux.com> * */ -#include <linux/sched.h> - #define __NO_VERSION__ #include "drmP.h" #include "r128_drv.h" @@ -38,10 +36,6 @@ static int r128_alloc_queue(drm_device_t *dev) { -#if 0 - static int context = 0; -#endif - return drm_ctxbitmap_next(dev); } @@ -59,21 +53,21 @@ #if DRM_DMA_HISTOGRAM dev->ctx_start = get_cycles(); #endif - + DRM_DEBUG("Context switch from %d to %d\n", old, new); if (new == dev->last_context) { clear_bit(0, &dev->context_flag); return 0; } - + if (drm_flags & DRM_FLAG_NOCTX) { r128_context_switch_complete(dev, new); } else { sprintf(buf, "C %d %d\n", old, new); drm_write_string(dev, buf); } - + return 0; } @@ -81,7 +75,7 @@ { dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ dev->last_switch = jiffies; - + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("Lock isn't held after context switch\n"); } @@ -92,11 +86,11 @@ #if DRM_DMA_HISTOGRAM atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles() - dev->ctx_start)]); - + #endif clear_bit(0, &dev->context_flag); wake_up(&dev->context_wait); - + return 0; } @@ -109,19 +103,21 @@ int i; DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -133,7 +129,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = r128_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Skip kernel's context and get a new one. */ ctx.handle = r128_alloc_queue(dev); @@ -145,7 +142,8 @@ return -ENOMEM; } - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -154,7 +152,8 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; if (ctx.flags==_DRM_CONTEXT_PRESERVED) r128_res_ctx.handle=ctx.handle; return 0; @@ -165,10 +164,12 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; /* This is 0, because we don't hanlde any context flags */ ctx.flags = 0; - copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -179,7 +180,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return r128_context_switch(dev, dev->last_context, ctx.handle); } @@ -191,7 +193,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); r128_context_switch_complete(dev, ctx.handle); @@ -205,7 +208,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); drm_ctxbitmap_free(dev, ctx.handle); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c:1.2 Mon Jun 26 01:41:33 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c Mon Dec 18 14:31:54 2000 @@ -1,922 +0,0 @@ -/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*- - * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com - * - * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Kevin E. Martin <martin@valinux.com> - * - */ - -#define __NO_VERSION__ -#include "drmP.h" -#include "r128_drv.h" - -#include <linux/interrupt.h> /* For task queue support */ -#include <linux/delay.h> - - - -#define DO_REMAP(_m) (_m)->handle = drm_ioremap((_m)->offset, (_m)->size) - -#define DO_REMAPFREE(_m) \ - do { \ - if ((_m)->handle && (_m)->size) \ - drm_ioremapfree((_m)->handle, (_m)->size); \ - } while (0) - -#define DO_FIND_MAP(_m, _o) \ - do { \ - int _i; \ - for (_i = 0; _i < dev->map_count; _i++) { \ - if (dev->maplist[_i]->offset == _o) { \ - _m = dev->maplist[_i]; \ - break; \ - } \ - } \ - } while (0) - - -#define R128_MAX_VBUF_AGE 0x10000000 -#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0 - -int R128_READ_PLL(drm_device_t *dev, int addr) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - - R128_WRITE8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); - return R128_READ(R128_CLOCK_CNTL_DATA); -} - -static void r128_flush_write_combine(void) -{ - int xchangeDummy; - - __asm__ volatile("push %%eax ;" - "xchg %%eax, %0 ;" - "pop %%eax" : : "m" (xchangeDummy)); - __asm__ volatile("push %%eax ;" - "push %%ebx ;" - "push %%ecx ;" - "push %%edx ;" - "movl $0,%%eax ;" - "cpuid ;" - "pop %%edx ;" - "pop %%ecx ;" - "pop %%ebx ;" - "pop %%eax" : /* no outputs */ : /* no inputs */ ); -} - -static void r128_status(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - - printk("GUI_STAT = 0x%08x\n", - (unsigned int)R128_READ(R128_GUI_STAT)); - printk("PM4_STAT = 0x%08x\n", - (unsigned int)R128_READ(R128_PM4_STAT)); - printk("PM4_BUFFER_DL_WPTR = 0x%08x\n", - (unsigned int)R128_READ(R128_PM4_BUFFER_DL_WPTR)); - printk("PM4_BUFFER_DL_RPTR = 0x%08x\n", - (unsigned int)R128_READ(R128_PM4_BUFFER_DL_RPTR)); -} - -static int r128_do_cleanup_cce(drm_device_t *dev) -{ - if (dev->dev_private) { - drm_r128_private_t *dev_priv = dev->dev_private; - - if (!dev_priv->is_pci) { - DO_REMAPFREE(dev_priv->agp_ring); - DO_REMAPFREE(dev_priv->agp_read_ptr); - DO_REMAPFREE(dev_priv->agp_vertbufs); - DO_REMAPFREE(dev_priv->agp_indbufs); - DO_REMAPFREE(dev_priv->agp_textures); - } - - drm_free(dev->dev_private, sizeof(drm_r128_private_t), - DRM_MEM_DRIVER); - dev->dev_private = NULL; - } - - return 0; -} - -static int r128_do_init_cce(drm_device_t *dev, drm_r128_init_t *init) -{ - drm_r128_private_t *dev_priv; - int i; - - dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER); - if (dev_priv == NULL) return -ENOMEM; - dev->dev_private = (void *)dev_priv; - - memset(dev_priv, 0, sizeof(drm_r128_private_t)); - - dev_priv->is_pci = init->is_pci; - - dev_priv->usec_timeout = init->usec_timeout; - if (dev_priv->usec_timeout < 1 || - dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT) { - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; - return -EINVAL; - } - - dev_priv->cce_mode = init->cce_mode; - dev_priv->cce_fifo_size = init->cce_fifo_size; - dev_priv->cce_is_bm_mode = - ((init->cce_mode == R128_PM4_192BM) || - (init->cce_mode == R128_PM4_128BM_64INDBM) || - (init->cce_mode == R128_PM4_64BM_128INDBM) || - (init->cce_mode == R128_PM4_64BM_64VCBM_64INDBM)); - dev_priv->cce_secure = init->cce_secure; - - if (dev_priv->cce_is_bm_mode && dev_priv->is_pci) { - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; - return -EINVAL; - } - - for (i = 0; i < dev->map_count; i++) { - if (dev->maplist[i]->type == _DRM_SHM) { - dev_priv->sarea = dev->maplist[i]; - break; - } - } - - DO_FIND_MAP(dev_priv->fb, init->fb_offset); - if (!dev_priv->is_pci) { - DO_FIND_MAP(dev_priv->agp_ring, init->agp_ring_offset); - DO_FIND_MAP(dev_priv->agp_read_ptr, init->agp_read_ptr_offset); - DO_FIND_MAP(dev_priv->agp_vertbufs, init->agp_vertbufs_offset); - DO_FIND_MAP(dev_priv->agp_indbufs, init->agp_indbufs_offset); - DO_FIND_MAP(dev_priv->agp_textures, init->agp_textures_offset); - } - DO_FIND_MAP(dev_priv->mmio, init->mmio_offset); - - dev_priv->sarea_priv = - (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + - init->sarea_priv_offset); - - if (!dev_priv->is_pci) { - DO_REMAP(dev_priv->agp_ring); - DO_REMAP(dev_priv->agp_read_ptr); - DO_REMAP(dev_priv->agp_vertbufs); -#if 0 - DO_REMAP(dev_priv->agp_indirectbufs); - DO_REMAP(dev_priv->agp_textures); -#endif - - dev_priv->ring_size = init->ring_size; - dev_priv->ring_sizel2qw = drm_order(init->ring_size/8); - dev_priv->ring_entries = init->ring_size/sizeof(u32); - dev_priv->ring_read_ptr = ((__volatile__ u32 *) - dev_priv->agp_read_ptr->handle); - dev_priv->ring_start = (u32 *)dev_priv->agp_ring->handle; - dev_priv->ring_end = ((u32 *)dev_priv->agp_ring->handle - + dev_priv->ring_entries); - } - - dev_priv->submit_age = 0; - R128_WRITE(R128_VB_AGE_REG, dev_priv->submit_age); - - return 0; -} - -int r128_init_cce(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_r128_init_t init; - - copy_from_user_ret(&init, (drm_r128_init_t *)arg, sizeof(init), - -EFAULT); - - switch (init.func) { - case R128_INIT_CCE: - return r128_do_init_cce(dev, &init); - case R128_CLEANUP_CCE: - return r128_do_cleanup_cce(dev); - } - - return -EINVAL; -} - -static void r128_mark_vertbufs_done(drm_device_t *dev) -{ - drm_device_dma_t *dma = dev->dma; - int i; - - for (i = 0; i < dma->buf_count; i++) { - drm_buf_t *buf = dma->buflist[i]; - drm_r128_buf_priv_t *buf_priv = buf->dev_private; - buf_priv->age = 0; - } -} - -static int r128_do_pixcache_flush(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - u32 tmp; - int i; - - tmp = R128_READ(R128_PC_NGUI_CTLSTAT) | R128_PC_FLUSH_ALL; - R128_WRITE(R128_PC_NGUI_CTLSTAT, tmp); - - for (i = 0; i < dev_priv->usec_timeout; i++) { - if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) - return 0; - udelay(1); - } - - return -EBUSY; -} - -static int r128_do_wait_for_fifo(drm_device_t *dev, int entries) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int i; - - for (i = 0; i < dev_priv->usec_timeout; i++) { - int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; - if (slots >= entries) return 0; - udelay(1); - } - return -EBUSY; -} - -static int r128_do_wait_for_idle(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int i, ret; - - if (!(ret = r128_do_wait_for_fifo(dev, 64))) return ret; - - for (i = 0; i < dev_priv->usec_timeout; i++) { - if (!(R128_READ(R128_GUI_STAT) & R128_GUI_ACTIVE)) { - (void)r128_do_pixcache_flush(dev); - return 0; - } - udelay(1); - } - return -EBUSY; -} - -int r128_do_engine_reset(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - u32 clock_cntl_index, mclk_cntl, gen_reset_cntl; - - (void)r128_do_pixcache_flush(dev); - - clock_cntl_index = R128_READ(R128_CLOCK_CNTL_INDEX); - mclk_cntl = R128_READ_PLL(dev, R128_MCLK_CNTL); - - R128_WRITE_PLL(R128_MCLK_CNTL, - mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP); - - gen_reset_cntl = R128_READ(R128_GEN_RESET_CNTL); - - R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); - (void)R128_READ(R128_GEN_RESET_CNTL); - R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); - (void)R128_READ(R128_GEN_RESET_CNTL); - - R128_WRITE_PLL(R128_MCLK_CNTL, mclk_cntl); - R128_WRITE(R128_CLOCK_CNTL_INDEX, clock_cntl_index); - R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl); - - /* For CCE ring buffer only */ - if (dev_priv->cce_is_bm_mode) { - R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0); - R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0); - *dev_priv->ring_read_ptr = 0; - dev_priv->sarea_priv->ring_write = 0; - } - - /* Reset the CCE mode */ - (void)r128_do_wait_for_idle(dev); - R128_WRITE(R128_PM4_BUFFER_CNTL, - dev_priv->cce_mode | dev_priv->ring_sizel2qw); - (void)R128_READ(R128_PM4_BUFFER_ADDR); /* as per the sample code */ - R128_WRITE(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); - - r128_mark_vertbufs_done(dev); - return 0; -} - -int r128_eng_reset(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || - dev->lock.pid != current->pid) { - DRM_ERROR("r128_eng_reset called without holding the lock\n"); - return -EINVAL; - } - - return r128_do_engine_reset(dev); -} - -static int r128_do_engine_flush(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - u32 tmp; - - tmp = R128_READ(R128_PM4_BUFFER_DL_WPTR); - R128_WRITE(R128_PM4_BUFFER_DL_WPTR, tmp | R128_PM4_BUFFER_DL_DONE); - - return 0; -} - -int r128_eng_flush(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || - dev->lock.pid != current->pid) { - DRM_ERROR("r128_eng_flush called without holding the lock\n"); - return -EINVAL; - } - - return r128_do_engine_flush(dev); -} - -static int r128_do_cce_wait_for_fifo(drm_device_t *dev, int entries) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int i; - - for (i = 0; i < dev_priv->usec_timeout; i++) { - int slots = R128_READ(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; - if (slots >= entries) return 0; - udelay(1); - } - return -EBUSY; -} - -int r128_do_cce_wait_for_idle(drm_device_t *dev) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int i; - - if (dev_priv->cce_is_bm_mode) { - for (i = 0; i < dev_priv->usec_timeout; i++) { - if (*dev_priv->ring_read_ptr == dev_priv->sarea_priv->ring_write) { - int pm4stat = R128_READ(R128_PM4_STAT); - if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size && - !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { - return r128_do_pixcache_flush(dev); - } - } - udelay(1); - } - return -EBUSY; - } else { - int ret = r128_do_cce_wait_for_fifo(dev, dev_priv->cce_fifo_size); - if (ret < 0) return ret; - - for (i = 0; i < dev_priv->usec_timeout; i++) { - int pm4stat = R128_READ(R128_PM4_STAT); - if (!(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { - return r128_do_pixcache_flush(dev); - } - udelay(1); - } - return -EBUSY; - } -} - -int r128_cce_idle(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || - dev->lock.pid != current->pid) { - DRM_ERROR("r128_wait_idle called without holding the lock\n"); - return -EINVAL; - } - - return r128_do_cce_wait_for_idle(dev); -} - -static int r128_submit_packets_ring_secure(drm_device_t *dev, - u32 *commands, int *count) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int write = dev_priv->sarea_priv->ring_write; - int *write_ptr = dev_priv->ring_start + write; - int c = *count; - u32 tmp = 0; - int psize = 0; - int writing = 1; - int timeout; - - while (c > 0) { - tmp = *commands++; - if (!psize) { - writing = 1; - - if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= - (0x1004 << 9)) { - if ((tmp & R128_CCE_PACKET1_REG1_MASK) != - (R128_PM4_VC_FPU_SETUP << 9)) { - writing = 0; - } - } - psize = 3; - } else { - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } - } - psize--; - - if (writing) { - write++; - *write_ptr++ = tmp; - } - if (write >= dev_priv->ring_entries) { - write = 0; - write_ptr = dev_priv->ring_start; - } - timeout = 0; - while (write == *dev_priv->ring_read_ptr) { - (void)R128_READ(R128_PM4_BUFFER_DL_RPTR); - if (timeout++ >= dev_priv->usec_timeout) - return -EBUSY; - udelay(1); - } - c--; - } - - if (write < 32) - memcpy(dev_priv->ring_end, - dev_priv->ring_start, - write * sizeof(u32)); - - /* Make sure WC cache has been flushed */ - r128_flush_write_combine(); - - dev_priv->sarea_priv->ring_write = write; - R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write); - - *count = 0; - - return 0; -} - -static int r128_submit_packets_pio_secure(drm_device_t *dev, - u32 *commands, int *count) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - u32 tmp = 0; - int psize = 0; - int writing = 1; - int addr = R128_PM4_FIFO_DATA_EVEN; - int ret; - - while (*count > 0) { - tmp = *commands++; - if (!psize) { - writing = 1; - - if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= - (0x1004 << 9)) { - if ((tmp & R128_CCE_PACKET1_REG1_MASK) != - (R128_PM4_VC_FPU_SETUP << 9)) { - writing = 0; - } - } - psize = 3; - } else { - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } - } - psize--; - - if (writing) { - if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) - return ret; - R128_WRITE(addr, tmp); - addr ^= 0x0004; - } - - *count -= 1; - } - - if (addr == R128_PM4_FIFO_DATA_ODD) { - if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) return ret; - R128_WRITE(addr, R128_CCE_PACKET2); - } - - return 0; -} - -static int r128_submit_packets_ring(drm_device_t *dev, - u32 *commands, int *count) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int write = dev_priv->sarea_priv->ring_write; - int *write_ptr = dev_priv->ring_start + write; - int c = *count; - int timeout; - - while (c > 0) { - write++; - *write_ptr++ = *commands++; - if (write >= dev_priv->ring_entries) { - write = 0; - write_ptr = dev_priv->ring_start; - } - timeout = 0; - while (write == *dev_priv->ring_read_ptr) { - (void)R128_READ(R128_PM4_BUFFER_DL_RPTR); - if (timeout++ >= dev_priv->usec_timeout) - return -EBUSY; - udelay(1); - } - c--; - } - - if (write < 32) - memcpy(dev_priv->ring_end, - dev_priv->ring_start, - write * sizeof(u32)); - - /* Make sure WC cache has been flushed */ - r128_flush_write_combine(); - - dev_priv->sarea_priv->ring_write = write; - R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write); - - *count = 0; - - return 0; -} - -static int r128_submit_packets_pio(drm_device_t *dev, - u32 *commands, int *count) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int ret; - - while (*count > 1) { - if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret; - R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++); - R128_WRITE(R128_PM4_FIFO_DATA_ODD, *commands++); - *count -= 2; - } - - if (*count) { - if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret; - R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++); - R128_WRITE(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2); - *count = 0; - } - - return 0; -} - -static int r128_do_submit_packets(drm_device_t *dev, u32 *buffer, int count) -{ - drm_r128_private_t *dev_priv = dev->dev_private; - int c = count; - int ret; - - if (dev_priv->cce_is_bm_mode) { - int left = 0; - - if (c >= dev_priv->ring_entries) { - c = dev_priv->ring_entries-1; - left = count - c; - } - - /* Since this is only used by the kernel we can use the - insecure ring buffer submit packet routine */ - ret = r128_submit_packets_ring(dev, buffer, &c); - - c += left; - } else { - /* Since this is only used by the kernel we can use the - insecure PIO submit packet routine */ - ret = r128_submit_packets_pio(dev, buffer, &c); - } - - if (ret < 0) return ret; - else return c; -} - -int r128_submit_pkt(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_r128_private_t *dev_priv = dev->dev_private; - drm_r128_packet_t packet; - u32 *buffer; - int c; - int size; - int ret = 0; - - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || - dev->lock.pid != current->pid) { - DRM_ERROR("r128_submit_pkt called without holding the lock\n"); - return -EINVAL; - } - - copy_from_user_ret(&packet, (drm_r128_packet_t *)arg, sizeof(packet), - -EFAULT); - - c = packet.count; - size = c * sizeof(*buffer); - - if (dev_priv->cce_is_bm_mode) { - int left = 0; - - if (c >= dev_priv->ring_entries) { - c = dev_priv->ring_entries-1; - size = c * sizeof(*buffer); - left = packet.count - c; - } - - if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM; - copy_from_user_ret(buffer, packet.buffer, size, -EFAULT); - - if (dev_priv->cce_secure) - ret = r128_submit_packets_ring_secure(dev, buffer, &c); - else - ret = r128_submit_packets_ring(dev, buffer, &c); - - c += left; - } else { - if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM; - copy_from_user_ret(buffer, packet.buffer, size, -EFAULT); - - if (dev_priv->cce_secure) - ret = r128_submit_packets_pio_secure(dev, buffer, &c); - else - ret = r128_submit_packets_pio(dev, buffer, &c); - } - - kfree(buffer); - - packet.count = c; - copy_to_user_ret((drm_r128_packet_t *)arg, &packet, sizeof(packet), - -EFAULT); - - if (ret) return ret; - else if (c > 0) return -EAGAIN; - - return 0; -} - -static int r128_send_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v) -{ - drm_device_dma_t *dma = dev->dma; - drm_r128_private_t *dev_priv = dev->dev_private; - drm_r128_buf_priv_t *buf_priv; - drm_buf_t *buf; - int i, ret; - u32 cce[2]; - - /* Make sure we have valid data */ - for (i = 0; i < v->send_count; i++) { - int idx = v->send_indices[i]; - - if (idx < 0 || idx >= dma->buf_count) { - DRM_ERROR("Index %d (of %d max)\n", - idx, dma->buf_count - 1); - return -EINVAL; - } - buf = dma->buflist[idx]; - if (buf->pid != current->pid) { - DRM_ERROR("Process %d using buffer owned by %d\n", - current->pid, buf->pid); - return -EINVAL; - } - if (buf->pending) { - DRM_ERROR("Sending pending buffer:" - " buffer %d, offset %d\n", - v->send_indices[i], i); - return -EINVAL; - } - } - - /* Wait for idle, if we've wrapped to make sure that all pending - buffers have been processed */ - if (dev_priv->submit_age == R128_MAX_VBUF_AGE) { - if ((ret = r128_do_cce_wait_for_idle(dev)) < 0) return ret; - dev_priv->submit_age = 0; - r128_mark_vertbufs_done(dev); - } - - /* Make sure WC cache has been flushed (if in PIO mode) */ - if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine(); - - /* FIXME: Add support for sending vertex buffer to the CCE here - instead of in client code. The v->prim holds the primitive - type that should be drawn. Loop over the list buffers in - send_indices[] and submit a packet for each VB. - - This will require us to loop over the clip rects here as - well, which implies that we extend the kernel driver to allow - cliprects to be stored here. Note that the cliprects could - possibly come from the X server instead of the client, but - this will require additional changes to the DRI to allow for - this optimization. */ - - /* Submit a CCE packet that writes submit_age to R128_VB_AGE_REG */ - cce[0] = R128CCE0(R128_CCE_PACKET0, R128_VB_AGE_REG, 0); - cce[1] = dev_priv->submit_age; - if ((ret = r128_do_submit_packets(dev, cce, 2)) < 0) { - /* Until we add support for sending VBs to the CCE in - this routine, we can recover from this error. After - we add that support, we won't be able to easily - recover, so we will probably have to implement - another mechanism for handling timeouts from packets - submitted directly by the kernel. */ - return ret; - } - - /* Now that the submit packet request has succeeded, we can mark - the buffers as pending */ - for (i = 0; i < v->send_count; i++) { - buf = dma->buflist[v->send_indices[i]]; - buf->pending = 1; - - buf_priv = buf->dev_private; - buf_priv->age = dev_priv->submit_age; - } - - dev_priv->submit_age++; - - return 0; -} - -static drm_buf_t *r128_freelist_get(drm_device_t *dev) -{ - drm_device_dma_t *dma = dev->dma; - drm_r128_private_t *dev_priv = dev->dev_private; - drm_r128_buf_priv_t *buf_priv; - drm_buf_t *buf; - int i, t; - - /* FIXME: Optimize -- use freelist code */ - - for (i = 0; i < dma->buf_count; i++) { - buf = dma->buflist[i]; - buf_priv = buf->dev_private; - if (buf->pid == 0) return buf; - } - - for (t = 0; t < dev_priv->usec_timeout; t++) { - u32 done_age = R128_READ(R128_VB_AGE_REG); - - for (i = 0; i < dma->buf_count; i++) { - buf = dma->buflist[i]; - buf_priv = buf->dev_private; - if (buf->pending && buf_priv->age <= done_age) { - /* The buffer has been processed, so it - can now be used */ - buf->pending = 0; - return buf; - } - } - udelay(1); - } - - r128_status(dev); - return NULL; -} - - -static int r128_get_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v) -{ - drm_buf_t *buf; - int i; - - for (i = v->granted_count; i < v->request_count; i++) { - buf = r128_freelist_get(dev); - if (!buf) break; - buf->pid = current->pid; - copy_to_user_ret(&v->request_indices[i], - &buf->idx, - sizeof(buf->idx), - -EFAULT); - copy_to_user_ret(&v->request_sizes[i], - &buf->total, - sizeof(buf->total), - -EFAULT); - ++v->granted_count; - } - return 0; -} - -int r128_vertex_buf(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_r128_private_t *dev_priv = dev->dev_private; - drm_device_dma_t *dma = dev->dma; - int retcode = 0; - drm_r128_vertex_t v; - - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || - dev->lock.pid != current->pid) { - DRM_ERROR("r128_vertex_buf called without holding the lock\n"); - return -EINVAL; - } - - if (!dev_priv || dev_priv->is_pci) { - DRM_ERROR("r128_vertex_buf called with a PCI card\n"); - return -EINVAL; - } - - copy_from_user_ret(&v, (drm_r128_vertex_t *)arg, sizeof(v), -EFAULT); - DRM_DEBUG("%d: %d send, %d req\n", - current->pid, v.send_count, v.request_count); - - if (v.send_count < 0 || v.send_count > dma->buf_count) { - DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n", - current->pid, v.send_count, dma->buf_count); - return -EINVAL; - } - if (v.request_count < 0 || v.request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - current->pid, v.request_count, dma->buf_count); - return -EINVAL; - } - - if (v.send_count) { - retcode = r128_send_vertbufs(dev, &v); - } - - v.granted_count = 0; - - if (!retcode && v.request_count) { - retcode = r128_get_vertbufs(dev, &v); - } - - DRM_DEBUG("%d returning, granted = %d\n", - current->pid, v.granted_count); - copy_to_user_ret((drm_r128_vertex_t *)arg, &v, sizeof(v), -EFAULT); - - return retcode; -} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h:1.1 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h Tue Dec 12 12:17:14 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -24,7 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Kevin E. Martin <martin@valinux.com> + * Authors: + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> * */ @@ -32,80 +34,239 @@ #define _R128_DRM_H_ /* WARNING: If you change any of these defines, make sure to change the + * defines in the X server file (r128_sarea.h) + */ +#ifndef __R128_SAREA_DEFINES__ +#define __R128_SAREA_DEFINES__ + +/* What needs to be changed for the current vertex buffer? + */ +#define R128_UPLOAD_CONTEXT 0x001 +#define R128_UPLOAD_SETUP 0x002 +#define R128_UPLOAD_TEX0 0x004 +#define R128_UPLOAD_TEX1 0x008 +#define R128_UPLOAD_TEX0IMAGES 0x010 +#define R128_UPLOAD_TEX1IMAGES 0x020 +#define R128_UPLOAD_CORE 0x040 +#define R128_UPLOAD_MASKS 0x080 +#define R128_UPLOAD_WINDOW 0x100 +#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */ +#define R128_REQUIRE_QUIESCENCE 0x400 +#define R128_UPLOAD_ALL 0x7ff + +#define R128_FRONT 0x1 +#define R128_BACK 0x2 +#define R128_DEPTH 0x4 + +/* Primitive types + */ +#define R128_POINTS 0x1 +#define R128_LINES 0x2 +#define R128_LINE_STRIP 0x3 +#define R128_TRIANGLES 0x4 +#define R128_TRIANGLE_FAN 0x5 +#define R128_TRIANGLE_STRIP 0x6 + +/* Vertex/indirect buffer size + */ +#if 1 +#define R128_BUFFER_SIZE 16384 +#else +#define R128_BUFFER_SIZE (128 * 1024) +#endif + +/* Byte offsets for indirect buffer data + */ +#define R128_INDEX_PRIM_OFFSET 20 +#define R128_HOSTDATA_BLIT_OFFSET 32 + +/* 2048x2048 @ 32bpp texture requires this many indirect buffers + */ +#define R128_MAX_BLIT_BUFFERS ((2048 * 2048 * 4) / R128_BUFFER_SIZE) + +/* Keep these small for testing. + */ +#define R128_NR_SAREA_CLIPRECTS 12 + +/* There are 2 heaps (local/AGP). Each region within a heap is a + * minimum of 64k, and there are at most 64 of them per heap. + */ +#define R128_LOCAL_TEX_HEAP 0 +#define R128_AGP_TEX_HEAP 1 +#define R128_NR_TEX_HEAPS 2 +#define R128_NR_TEX_REGIONS 64 +#define R128_LOG_TEX_GRANULARITY 16 + +#define R128_NR_CONTEXT_REGS 12 +#define R128_TEX_MAXLEVELS 11 + +#endif /* __R128_SAREA_DEFINES__ */ + +typedef struct { + /* Context state - can be written in one large chunk */ + unsigned int dst_pitch_offset_c; + unsigned int dp_gui_master_cntl_c; + unsigned int sc_top_left_c; + unsigned int sc_bottom_right_c; + unsigned int z_offset_c; + unsigned int z_pitch_c; + unsigned int z_sten_cntl_c; + unsigned int tex_cntl_c; + unsigned int misc_3d_state_cntl_reg; + unsigned int texture_clr_cmp_clr_c; + unsigned int texture_clr_cmp_msk_c; + unsigned int fog_color_c; + + /* Texture state */ + unsigned int tex_size_pitch_c; + unsigned int constant_color_c; + + /* Setup state */ + unsigned int pm4_vc_fpu_setup; + unsigned int setup_cntl; + + /* Mask state */ + unsigned int dp_write_mask; + unsigned int sten_ref_mask_c; + unsigned int plane_3d_mask_c; + + /* Window state */ + unsigned int window_xy_offset; + + /* Core state */ + unsigned int scale_3d_cntl; +} drm_r128_context_regs_t; + +/* Setup registers for each texture unit */ +typedef struct { + unsigned int tex_cntl; + unsigned int tex_combine_cntl; + unsigned int tex_size_pitch; + unsigned int tex_offset[R128_TEX_MAXLEVELS]; + unsigned int tex_border_color; +} drm_r128_texture_regs_t; + + +typedef struct drm_tex_region { + unsigned char next, prev; + unsigned char in_use; + int age; +} drm_tex_region_t; + +typedef struct drm_r128_sarea { + /* The channel for communication of state information to the kernel + * on firing a vertex buffer. + */ + drm_r128_context_regs_t context_state; + drm_r128_texture_regs_t tex_state[R128_NR_TEX_HEAPS]; + unsigned int dirty; + unsigned int vertsize; + unsigned int vc_format; + + /* The current cliprects, or a subset thereof. + */ + drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS]; + unsigned int nbox; + + /* Counters for client-side throttling of rendering clients. + */ + unsigned int last_frame; + unsigned int last_dispatch; + + drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; + int tex_age[R128_NR_TEX_HEAPS]; + int ctx_owner; +} drm_r128_sarea_t; + + +/* WARNING: If you change any of these defines, make sure to change the * defines in the Xserver file (xf86drmR128.h) */ typedef struct drm_r128_init { - enum { + enum { R128_INIT_CCE = 0x01, R128_CLEANUP_CCE = 0x02 } func; int sarea_priv_offset; int is_pci; int cce_mode; - int cce_fifo_size; int cce_secure; int ring_size; int usec_timeout; + + unsigned int fb_bpp; + unsigned int front_offset, front_pitch; + unsigned int back_offset, back_pitch; + unsigned int depth_bpp; + unsigned int depth_offset, depth_pitch; + unsigned int span_offset; - int fb_offset; - int agp_ring_offset; - int agp_read_ptr_offset; - int agp_vertbufs_offset; - int agp_indbufs_offset; - int agp_textures_offset; - int mmio_offset; + unsigned int fb_offset; + unsigned int mmio_offset; + unsigned int ring_offset; + unsigned int ring_rptr_offset; + unsigned int buffers_offset; + unsigned int agp_textures_offset; } drm_r128_init_t; -typedef struct drm_r128_packet { - unsigned long *buffer; - int count; - int flags; -} drm_r128_packet_t; +typedef struct drm_r128_cce_stop { + int flush; + int idle; +} drm_r128_cce_stop_t; -typedef enum drm_r128_prim { - _DRM_R128_PRIM_NONE = 0x0001, - _DRM_R128_PRIM_POINT = 0x0002, - _DRM_R128_PRIM_LINE = 0x0004, - _DRM_R128_PRIM_POLY_LINE = 0x0008, - _DRM_R128_PRIM_TRI_LIST = 0x0010, - _DRM_R128_PRIM_TRI_FAN = 0x0020, - _DRM_R128_PRIM_TRI_STRIP = 0x0040, - _DRM_R128_PRIM_TRI_TYPE2 = 0x0080 -} drm_r128_prim_t; +typedef struct drm_r128_clear { + unsigned int flags; + int x, y, w, h; + unsigned int clear_color; + unsigned int clear_depth; +} drm_r128_clear_t; typedef struct drm_r128_vertex { - /* Indices here refer to the offset into - buflist in drm_buf_get_t. */ - int send_count; /* Number of buffers to send */ - int *send_indices; /* List of handles to buffers */ - int *send_sizes; /* Lengths of data to send */ - drm_r128_prim_t prim; /* Primitive type */ - int request_count; /* Number of buffers requested */ - int *request_indices; /* Buffer information */ - int *request_sizes; - int granted_count; /* Number of buffers granted */ + int prim; + int idx; /* Index of vertex buffer */ + int count; /* Number of vertices in buffer */ + int discard; /* Client finished with buffer? */ } drm_r128_vertex_t; -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (r128_sarea.h) - */ -#define R128_LOCAL_TEX_HEAP 0 -#define R128_AGP_TEX_HEAP 1 -#define R128_NR_TEX_HEAPS 2 -#define R128_NR_TEX_REGIONS 64 -#define R128_LOG_TEX_GRANULARITY 16 +typedef struct drm_r128_indices { + int prim; + int idx; + int start; + int end; + int discard; /* Client finished with buffer? */ +} drm_r128_indices_t; -typedef struct drm_tex_region { - unsigned char next, prev; - unsigned char in_use; - int age; -} drm_tex_region_t; +typedef struct drm_r128_blit { + int idx; + int pitch; + int offset; + int format; + unsigned short x, y; + unsigned short width, height; +} drm_r128_blit_t; -typedef struct drm_r128_sarea { - drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; - int tex_age[R128_NR_TEX_HEAPS]; - int ctx_owner; - int ring_write; -} drm_r128_sarea_t; +typedef struct drm_r128_depth { + enum { + R128_WRITE_SPAN = 0x01, + R128_WRITE_PIXELS = 0x02, + R128_READ_SPAN = 0x03, + R128_READ_PIXELS = 0x04 + } func; + int n; + int *x; + int *y; + unsigned int *buffer; + unsigned char *mask; +} drm_r128_depth_t; + +typedef struct drm_r128_stipple { + unsigned int *mask; +} drm_r128_stipple_t; + +typedef struct drm_r128_packet { + unsigned int *buffer; + int count; + int flags; +} drm_r128_packet_t; #endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c:1.1 Fri Jun 16 20:03:38 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c Fri Dec 15 17:48:43 2000 @@ -24,29 +24,32 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@valinux.com> - * Kevin E. Martin <martin@valinux.com> + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> * */ #include <linux/config.h> -#define EXPORT_SYMTAB #include "drmP.h" #include "r128_drv.h" -EXPORT_SYMBOL(r128_init); -EXPORT_SYMBOL(r128_cleanup); -#define R128_NAME "r128" -#define R128_DESC "r128" -#define R128_DATE "20000607" -#define R128_MAJOR 1 -#define R128_MINOR 0 -#define R128_PATCHLEVEL 0 +#define R128_NAME "r128" +#define R128_DESC "ATI Rage 128" +#define R128_DATE "20001215" +#define R128_MAJOR 2 +#define R128_MINOR 1 +#define R128_PATCHLEVEL 2 -static drm_device_t r128_device; -drm_ctx_t r128_res_ctx; +static drm_device_t r128_device; +drm_ctx_t r128_res_ctx; static struct file_operations r128_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif open: r128_open, flush: drm_flush, release: r128_release, @@ -64,96 +67,85 @@ }; static drm_ioctl_desc_t r128_ioctls[] = { - [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { r128_version, 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { r128_addbufs, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { r128_mapbufs, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, - - [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { r128_addctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { r128_rmctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { r128_modctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { r128_getctx, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { r128_switchctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { r128_newctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { r128_resctx, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { r128_lock, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, - -#ifdef DRM_AGP - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, -#endif - - [DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_init_cce, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_eng_reset, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_FLUSH)] = { r128_eng_flush, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_submit_pkt, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_IDLE)] = { r128_cce_idle, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_vertex_buf, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { r128_version, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { r128_addbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { r128_mapbufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { r128_addctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { r128_rmctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { r128_modctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { r128_getctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { r128_switchctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { r128_newctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { r128_resctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { r128_cce_buffers, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { r128_lock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, + +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, +#endif + + [DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_cce_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_START)] = { r128_cce_start, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_STOP)] = { r128_cce_stop, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_RESET)] = { r128_cce_reset, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_CCE_IDLE)] = { r128_cce_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_engine_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_SWAP)] = { r128_cce_swap, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_CLEAR)] = { r128_cce_clear, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_cce_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_INDICES)] = { r128_cce_indices, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_BLIT)] = { r128_cce_blit, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_DEPTH)] = { r128_cce_depth, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_STIPPLE)] = { r128_cce_stipple, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_cce_packet, 1, 0 }, }; #define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls) #ifdef MODULE -int init_module(void); -void cleanup_module(void); static char *r128 = NULL; +#endif -MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); +MODULE_AUTHOR("VA Linux Systems, Inc."); MODULE_DESCRIPTION("r128"); MODULE_PARM(r128, "s"); -/* init_module is called when insmod is used to load the module */ - -int init_module(void) -{ - return r128_init(); -} - -/* cleanup_module is called when rmmod is used to unload the module */ - -void cleanup_module(void) -{ - r128_cleanup(); -} -#endif - #ifndef MODULE -/* r128_setup is called by the kernel to parse command-line options passed - * via the boot-loader (e.g., LILO). It calls the insmod option routine, - * drm_parse_drm. - * - * This is not currently supported, since it requires changes to - * linux/init/main.c. */ - +/* r128_options is called by the kernel to parse command-line options + * passed via the boot-loader (e.g., LILO). It calls the insmod option + * routine, drm_parse_drm. + */ -void __init r128_setup(char *str, int *ints) +static int __init r128_options(char *str) { - if (ints[0] != 0) { - DRM_ERROR("Illegal command line format, ignored\n"); - return; - } drm_parse_options(str); + return 1; } + +__setup("r128=", r128_options); #endif static int r128_setup(drm_device_t *dev) @@ -255,7 +247,7 @@ dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) /* Clear AGP information */ if (dev->agp) { drm_agp_mem_t *entry; @@ -271,8 +263,7 @@ } dev->agp->memory = NULL; - if (dev->agp->acquired && drm_agp.release) - (*drm_agp.release)(); + if (dev->agp->acquired) _drm_agp_release(); dev->agp->acquired = 0; dev->agp->enabled = 0; @@ -342,7 +333,7 @@ /* r128_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ -int r128_init(void) +static int __init r128_init(void) { int retcode; drm_device_t *dev = &r128_device; @@ -367,8 +358,15 @@ drm_mem_init(); drm_proc_init(dev); -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) dev->agp = drm_agp_init(); + if (dev->agp == NULL) { + DRM_ERROR("Cannot initialize agpgart module.\n"); + drm_proc_cleanup(); + misc_deregister(&r128_misc); + r128_takedown(dev); + return -ENOMEM; + } #ifdef CONFIG_MTRR dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, @@ -399,7 +397,7 @@ /* r128_cleanup is called via cleanup_module at module unload time. */ -void r128_cleanup(void) +static void __exit r128_cleanup(void) { drm_device_t *dev = &r128_device; @@ -413,32 +411,37 @@ } drm_ctxbitmap_cleanup(dev); r128_takedown(dev); -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) if (dev->agp) { - /* FIXME -- free other information, too */ + drm_agp_uninit(); drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); dev->agp = NULL; } #endif } -int r128_version(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +module_init(r128_init); +module_exit(r128_cleanup); + + +int r128_version(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) { drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; -#define DRM_COPY(name,value) \ - len = strlen(value); \ - if (len > name##_len) len = name##_len; \ - name##_len = strlen(value); \ - if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ +#define DRM_COPY(name,value) \ + len = strlen(value); \ + if (len > name##_len) len = name##_len; \ + name##_len = strlen(value); \ + if (len && name) { \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = R128_MAJOR; @@ -449,10 +452,10 @@ DRM_COPY(version.date, R128_DATE); DRM_COPY(version.desc, R128_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -463,7 +466,9 @@ DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_open); spin_lock(&dev->count_lock); if (!dev->open_count++) { @@ -472,18 +477,23 @@ } spin_unlock(&dev->count_lock); } + return retcode; } int r128_release(struct inode *inode, struct file *filp) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_device_t *dev; int retcode = 0; + lock_kernel(); + dev = priv->dev; DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_release(inode, filp))) { - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_close); spin_lock(&dev->count_lock); if (!--dev->open_count) { @@ -492,20 +502,23 @@ atomic_read(&dev->ioctl_count), dev->blocked); spin_unlock(&dev->count_lock); + unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); + unlock_kernel(); return r128_takedown(dev); } spin_unlock(&dev->count_lock); } + + unlock_kernel(); return retcode; } /* r128_ioctl is called whenever a process performs an ioctl on /dev/drm. */ - -int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +int r128_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) { int nr = DRM_IOCTL_NR(cmd); drm_file_t *priv = filp->private_data; @@ -531,19 +544,25 @@ DRM_DEBUG("no function\n"); retcode = -EINVAL; } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) - || (ioctl->auth_needed && !priv->authenticated)) { + || (ioctl->auth_needed && !priv->authenticated)) { retcode = -EACCES; } else { retcode = (func)(inode, filp, cmd, arg); } } +#if 0 + if ( retcode ) { + DRM_INFO( "%s 0x%x ret = %d\n", __FUNCTION__, nr, retcode ); + } +#endif + atomic_dec(&dev->ioctl_count); return retcode; } -int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +int r128_lock(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -556,7 +575,8 @@ dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -568,35 +588,13 @@ lock.context, current->pid, dev->lock.hw_lock->lock, lock.flags); -#if 0 - /* dev->queue_count == 0 right now for - r128. FIXME? */ - if (lock.context < 0 || lock.context >= dev->queue_count) + if (lock.context < 0) return -EINVAL; -#endif if (!ret) { -#if 0 - if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) - != lock.context) { - long j = jiffies - dev->lock.lock_time; - - if (lock.context == r128_res_ctx.handle && - j >= 0 && j < DRM_LOCK_SLICE) { - /* Can't take lock if we just had it and - there is contention. */ - DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", - lock.context, current->pid, j, - dev->lock.lock_time, jiffies); - current->state = TASK_INTERRUPTIBLE; - current->policy |= SCHED_YIELD; - schedule_timeout(DRM_LOCK_SLICE-j); - DRM_DEBUG("jiffies=%d\n", jiffies); - } - } -#endif add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -612,10 +610,6 @@ /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; -#if 1 - current->policy |= SCHED_YIELD; -#endif schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -626,57 +620,32 @@ remove_wait_queue(&dev->lock.lock_queue, &entry); } -#if 0 - if (!ret && dev->last_context != lock.context && - lock.context != r128_res_ctx.handle && - dev->last_context != r128_res_ctx.handle) { - add_wait_queue(&dev->context_wait, &entry); - current->state = TASK_INTERRUPTIBLE; - /* PRE: dev->last_context != lock.context */ - r128_context_switch(dev, dev->last_context, lock.context); - /* POST: we will wait for the context - switch and will dispatch on a later call - when dev->last_context == lock.context - NOTE WE HOLD THE LOCK THROUGHOUT THIS - TIME! */ - current->policy |= SCHED_YIELD; - schedule(); - current->state = TASK_RUNNING; - remove_wait_queue(&dev->context_wait, &entry); - if (signal_pending(current)) { - ret = -EINTR; - } else if (dev->last_context != lock.context) { - DRM_ERROR("Context mismatch: %d %d\n", - dev->last_context, lock.context); - } - } -#endif - if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); if (lock.flags & _DRM_LOCK_READY) { /* Wait for space in DMA/FIFO */ } if (lock.flags & _DRM_LOCK_QUIESCENT) { /* Make hardware quiescent */ + DRM_DEBUG( "not quiescent!\n" ); #if 0 r128_quiescent(dev); #endif } } -#if 0 - DRM_ERROR("pid = %5d, old counter = %5ld\n", - current->pid, current->counter); -#endif +#if LINUX_VERSION_CODE < 0x020400 if (lock.context != r128_res_ctx.handle) { current->counter = 5; current->priority = DEF_PRIORITY/4; } -#if 0 - while (current->counter > 25) - current->counter >>= 1; /* decrease time slice */ - DRM_ERROR("pid = %5d, new counter = %5ld\n", - current->pid, current->counter); #endif DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); @@ -688,14 +657,15 @@ } -int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +int r128_unlock(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -717,21 +687,13 @@ DRM_ERROR("\n"); } } - -#if 0 - current->policy |= SCHED_YIELD; - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1000); -#endif +#if LINUX_VERSION_CODE < 0x020400 if (lock.context != r128_res_ctx.handle) { current->counter = 5; current->priority = DEF_PRIORITY; } -#if 0 - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(10); #endif - + unblock_all_signals(); return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h:1.2 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h:1.2 Mon Jun 26 01:41:33 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h Mon Dec 4 14:22:00 2000 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,78 +23,137 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * - * Authors: Rickard E. (Rik) Faith <faith@valinux.com> - * Kevin E. Martin <martin@valinux.com> * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * Gareth Hughes <gareth@valinux.com> + * */ - -#ifndef _R128_DRV_H_ -#define _R128_DRV_H_ -typedef struct drm_r128_private { - int is_pci; +#ifndef __R128_DRV_H__ +#define __R128_DRV_H__ - int cce_mode; - int cce_fifo_size; - int cce_is_bm_mode; - int cce_secure; +typedef struct drm_r128_freelist { + unsigned int age; + drm_buf_t *buf; + struct drm_r128_freelist *next; + struct drm_r128_freelist *prev; +} drm_r128_freelist_t; + +typedef struct drm_r128_ring_buffer { + u32 *start; + u32 *end; + int size; + int size_l2qw; + + volatile u32 *head; + u32 tail; + u32 tail_mask; + int space; +} drm_r128_ring_buffer_t; +typedef struct drm_r128_private { + drm_r128_ring_buffer_t ring; drm_r128_sarea_t *sarea_priv; - __volatile__ u32 *ring_read_ptr; - - u32 *ring_start; - u32 *ring_end; - int ring_size; - int ring_sizel2qw; - int ring_entries; - - int submit_age; - - int usec_timeout; - - drm_map_t *sarea; - drm_map_t *fb; - drm_map_t *agp_ring; - drm_map_t *agp_read_ptr; - drm_map_t *agp_vertbufs; - drm_map_t *agp_indbufs; - drm_map_t *agp_textures; - drm_map_t *mmio; + int cce_mode; + int cce_fifo_size; + int cce_secure; + int cce_running; + + drm_r128_freelist_t *head; + drm_r128_freelist_t *tail; + + int usec_timeout; + int is_pci; + + atomic_t idle_count; + + unsigned int fb_bpp; + unsigned int front_offset; + unsigned int front_pitch; + unsigned int back_offset; + unsigned int back_pitch; + + unsigned int depth_bpp; + unsigned int depth_offset; + unsigned int depth_pitch; + unsigned int span_offset; + + u32 front_pitch_offset_c; + u32 back_pitch_offset_c; + u32 depth_pitch_offset_c; + u32 span_pitch_offset_c; + + drm_map_t *sarea; + drm_map_t *fb; + drm_map_t *mmio; + drm_map_t *cce_ring; + drm_map_t *ring_rptr; + drm_map_t *buffers; + drm_map_t *agp_textures; } drm_r128_private_t; typedef struct drm_r128_buf_priv { - u32 age; + u32 age; + int prim; + int discard; + int dispatched; + drm_r128_freelist_t *list_entry; } drm_r128_buf_priv_t; /* r128_drv.c */ -extern int r128_init(void); -extern void r128_cleanup(void); -extern int r128_version(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_open(struct inode *inode, struct file *filp); -extern int r128_release(struct inode *inode, struct file *filp); -extern int r128_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_lock(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_unlock(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); - - /* r128_dma.c */ -extern int r128_init_cce(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_eng_reset(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_eng_flush(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_submit_pkt(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_cce_idle(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); -extern int r128_vertex_buf(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); +extern int r128_version( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_open( struct inode *inode, struct file *filp ); +extern int r128_release( struct inode *inode, struct file *filp ); +extern int r128_ioctl( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_lock( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_unlock( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); + + /* r128_cce.c */ +extern int r128_cce_init( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_start( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_stop( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_reset( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_idle( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_engine_reset( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_packet( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_buffers( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); + +extern void r128_freelist_reset( drm_device_t *dev ); +extern drm_buf_t *r128_freelist_get( drm_device_t *dev ); + +extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n ); +extern void r128_update_ring_snapshot( drm_r128_private_t *dev_priv ); + + /* r128_state.c */ +extern int r128_cce_clear( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_swap( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_vertex( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_indices( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_blit( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_depth( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); +extern int r128_cce_stipple( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ); /* r128_bufs.c */ extern int r128_addbufs(struct inode *inode, struct file *filp, @@ -125,80 +184,207 @@ /* Register definitions, register access macros and drmAddMap constants * for Rage 128 kernel driver. */ + +#define R128_AUX_SC_CNTL 0x1660 +# define R128_AUX1_SC_EN (1 << 0) +# define R128_AUX1_SC_MODE_OR (0 << 1) +# define R128_AUX1_SC_MODE_NAND (1 << 1) +# define R128_AUX2_SC_EN (1 << 2) +# define R128_AUX2_SC_MODE_OR (0 << 3) +# define R128_AUX2_SC_MODE_NAND (1 << 3) +# define R128_AUX3_SC_EN (1 << 4) +# define R128_AUX3_SC_MODE_OR (0 << 5) +# define R128_AUX3_SC_MODE_NAND (1 << 5) +#define R128_AUX1_SC_LEFT 0x1664 +#define R128_AUX1_SC_RIGHT 0x1668 +#define R128_AUX1_SC_TOP 0x166c +#define R128_AUX1_SC_BOTTOM 0x1670 +#define R128_AUX2_SC_LEFT 0x1674 +#define R128_AUX2_SC_RIGHT 0x1678 +#define R128_AUX2_SC_TOP 0x167c +#define R128_AUX2_SC_BOTTOM 0x1680 +#define R128_AUX3_SC_LEFT 0x1684 +#define R128_AUX3_SC_RIGHT 0x1688 +#define R128_AUX3_SC_TOP 0x168c +#define R128_AUX3_SC_BOTTOM 0x1690 + +#define R128_BRUSH_DATA0 0x1480 +#define R128_BUS_CNTL 0x0030 +# define R128_BUS_MASTER_DIS (1 << 6) + +#define R128_CLOCK_CNTL_INDEX 0x0008 +#define R128_CLOCK_CNTL_DATA 0x000c +# define R128_PLL_WR_EN (1 << 7) + +#define R128_CONSTANT_COLOR_C 0x1d34 + +#define R128_DP_GUI_MASTER_CNTL 0x146c +# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) +# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) +# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define R128_GMC_BRUSH_NONE (15 << 4) +# define R128_GMC_DST_16BPP (4 << 8) +# define R128_GMC_DST_24BPP (5 << 8) +# define R128_GMC_DST_32BPP (6 << 8) +# define R128_GMC_DST_DATATYPE_SHIFT 8 +# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) +# define R128_DP_SRC_SOURCE_MEMORY (2 << 24) +# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24) +# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) +# define R128_GMC_AUX_CLIP_DIS (1 << 29) +# define R128_GMC_WR_MSK_DIS (1 << 30) +# define R128_ROP3_S 0x00cc0000 +# define R128_ROP3_P 0x00f00000 +#define R128_DP_WRITE_MASK 0x16cc +#define R128_DST_PITCH_OFFSET_C 0x1c80 +# define R128_DST_TILE (1 << 31) + +#define R128_GEN_RESET_CNTL 0x00f0 +# define R128_SOFT_RESET_GUI (1 << 0) + +#define R128_GUI_SCRATCH_REG0 0x15e0 +#define R128_GUI_SCRATCH_REG1 0x15e4 +#define R128_GUI_SCRATCH_REG2 0x15e8 +#define R128_GUI_SCRATCH_REG3 0x15ec +#define R128_GUI_SCRATCH_REG4 0x15f0 +#define R128_GUI_SCRATCH_REG5 0x15f4 + +#define R128_GUI_STAT 0x1740 +# define R128_GUI_FIFOCNT_MASK 0x0fff +# define R128_GUI_ACTIVE (1 << 31) + +#define R128_MCLK_CNTL 0x000f +# define R128_FORCE_GCP (1 << 16) +# define R128_FORCE_PIPE3D_CP (1 << 17) +# define R128_FORCE_RCP (1 << 18) + +#define R128_PC_GUI_CTLSTAT 0x1748 +#define R128_PC_NGUI_CTLSTAT 0x0184 +# define R128_PC_FLUSH_GUI (3 << 0) +# define R128_PC_RI_GUI (1 << 2) +# define R128_PC_FLUSH_ALL 0x00ff +# define R128_PC_BUSY (1 << 31) + +#define R128_PRIM_TEX_CNTL_C 0x1cb0 + +#define R128_SCALE_3D_CNTL 0x1a00 +#define R128_SEC_TEX_CNTL_C 0x1d00 +#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +#define R128_SETUP_CNTL 0x1bc4 +#define R128_STEN_REF_MASK_C 0x1d40 + +#define R128_TEX_CNTL_C 0x1c9c +# define R128_TEX_CACHE_FLUSH (1 << 23) + +#define R128_WINDOW_XY_OFFSET 0x1bcc + + +/* CCE registers + */ +#define R128_PM4_BUFFER_OFFSET 0x0700 +#define R128_PM4_BUFFER_CNTL 0x0704 +# define R128_PM4_MASK (15 << 28) +# define R128_PM4_NONPM4 (0 << 28) +# define R128_PM4_192PIO (1 << 28) +# define R128_PM4_192BM (2 << 28) +# define R128_PM4_128PIO_64INDBM (3 << 28) +# define R128_PM4_128BM_64INDBM (4 << 28) +# define R128_PM4_64PIO_128INDBM (5 << 28) +# define R128_PM4_64BM_128INDBM (6 << 28) +# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) +# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) +# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) + +#define R128_PM4_BUFFER_WM_CNTL 0x0708 +# define R128_WMA_SHIFT 0 +# define R128_WMB_SHIFT 8 +# define R128_WMC_SHIFT 16 +# define R128_WB_WM_SHIFT 24 + +#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c +#define R128_PM4_BUFFER_DL_RPTR 0x0710 +#define R128_PM4_BUFFER_DL_WPTR 0x0714 +# define R128_PM4_BUFFER_DL_DONE (1 << 31) + +#define R128_PM4_VC_FPU_SETUP 0x071c + +#define R128_PM4_IW_INDOFF 0x0738 +#define R128_PM4_IW_INDSIZE 0x073c + +#define R128_PM4_STAT 0x07b8 +# define R128_PM4_FIFOCNT_MASK 0x0fff +# define R128_PM4_BUSY (1 << 16) +# define R128_PM4_GUI_ACTIVE (1 << 31) + +#define R128_PM4_MICROCODE_ADDR 0x07d4 +#define R128_PM4_MICROCODE_RADDR 0x07d8 +#define R128_PM4_MICROCODE_DATAH 0x07dc +#define R128_PM4_MICROCODE_DATAL 0x07e0 + +#define R128_PM4_BUFFER_ADDR 0x07f0 +#define R128_PM4_MICRO_CNTL 0x07fc +# define R128_PM4_MICRO_FREERUN (1 << 30) -#define R128_PC_NGUI_CTLSTAT 0x0184 -# define R128_PC_FLUSH_ALL 0x00ff -# define R128_PC_BUSY (1 << 31) - -#define R128_CLOCK_CNTL_INDEX 0x0008 -#define R128_CLOCK_CNTL_DATA 0x000c -# define R128_PLL_WR_EN (1 << 7) - -#define R128_MCLK_CNTL 0x000f -# define R128_FORCE_GCP (1 << 16) -# define R128_FORCE_PIPE3D_CP (1 << 17) -# define R128_FORCE_RCP (1 << 18) - -#define R128_GEN_RESET_CNTL 0x00f0 -# define R128_SOFT_RESET_GUI (1 << 0) - -#define R128_PM4_BUFFER_CNTL 0x0704 -# define R128_PM4_NONPM4 (0 << 28) -# define R128_PM4_192PIO (1 << 28) -# define R128_PM4_192BM (2 << 28) -# define R128_PM4_128PIO_64INDBM (3 << 28) -# define R128_PM4_128BM_64INDBM (4 << 28) -# define R128_PM4_64PIO_128INDBM (5 << 28) -# define R128_PM4_64BM_128INDBM (6 << 28) -# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) -# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) -# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) - - -#define R128_PM4_BUFFER_DL_RPTR 0x0710 -#define R128_PM4_BUFFER_DL_WPTR 0x0714 -# define R128_PM4_BUFFER_DL_DONE (1 << 31) - -#define R128_PM4_VC_FPU_SETUP 0x071c - -#define R128_PM4_STAT 0x07b8 -# define R128_PM4_FIFOCNT_MASK 0x0fff -# define R128_PM4_BUSY (1 << 16) -# define R128_PM4_GUI_ACTIVE (1 << 31) - -#define R128_PM4_BUFFER_ADDR 0x07f0 -#define R128_PM4_MICRO_CNTL 0x07fc -# define R128_PM4_MICRO_FREERUN (1 << 30) - -#define R128_PM4_FIFO_DATA_EVEN 0x1000 -#define R128_PM4_FIFO_DATA_ODD 0x1004 - -#define R128_GUI_SCRATCH_REG0 0x15e0 -#define R128_GUI_SCRATCH_REG1 0x15e4 -#define R128_GUI_SCRATCH_REG2 0x15e8 -#define R128_GUI_SCRATCH_REG3 0x15ec -#define R128_GUI_SCRATCH_REG4 0x15f0 -#define R128_GUI_SCRATCH_REG5 0x15f4 - -#define R128_GUI_STAT 0x1740 -# define R128_GUI_FIFOCNT_MASK 0x0fff -# define R128_GUI_ACTIVE (1 << 31) - - -/* CCE command packets */ -#define R128_CCE_PACKET0 0x00000000 -#define R128_CCE_PACKET1 0x40000000 -#define R128_CCE_PACKET2 0x80000000 -# define R128_CCE_PACKET_MASK 0xC0000000 -# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 -# define R128_CCE_PACKET0_REG_MASK 0x000007ff -# define R128_CCE_PACKET1_REG0_MASK 0x000007ff -# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 +#define R128_PM4_FIFO_DATA_EVEN 0x1000 +#define R128_PM4_FIFO_DATA_ODD 0x1004 +/* CCE command packets + */ +#define R128_CCE_PACKET0 0x00000000 +#define R128_CCE_PACKET1 0x40000000 +#define R128_CCE_PACKET2 0x80000000 +#define R128_CCE_PACKET3 0xC0000000 +# define R128_CNTL_HOSTDATA_BLT 0x00009400 +# define R128_CNTL_PAINT_MULTI 0x00009A00 +# define R128_CNTL_BITBLT_MULTI 0x00009B00 +# define R128_3D_RNDR_GEN_INDX_PRIM 0x00002300 + +#define R128_CCE_PACKET_MASK 0xC0000000 +#define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 +#define R128_CCE_PACKET0_REG_MASK 0x000007ff +#define R128_CCE_PACKET1_REG0_MASK 0x000007ff +#define R128_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define R128_CCE_VC_CNTL_NUM_SHIFT 16 + +#define R128_DATATYPE_CI8 2 +#define R128_DATATYPE_ARGB1555 3 +#define R128_DATATYPE_RGB565 4 +#define R128_DATATYPE_RGB888 5 +#define R128_DATATYPE_ARGB8888 6 +#define R128_DATATYPE_RGB332 7 +#define R128_DATATYPE_RGB8 9 +#define R128_DATATYPE_ARGB4444 15 + +/* Constants */ +#define R128_AGP_OFFSET 0x02000000 + +#define R128_WATERMARK_L 16 +#define R128_WATERMARK_M 8 +#define R128_WATERMARK_N 8 +#define R128_WATERMARK_K 128 + #define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */ +#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0 +#define R128_LAST_DISPATCH_REG R128_GUI_SCRATCH_REG1 +#define R128_MAX_VB_AGE 0xffffffff +#define R128_MAX_VB_VERTS (0xffff) + + #define R128_BASE(reg) ((u32)(dev_priv->mmio->handle)) #define R128_ADDR(reg) (R128_BASE(reg) + reg) @@ -222,5 +408,59 @@ #define R128CCE1(p,r1,r2) ((p) | (((r2) >> 2) << 11) | ((r1) >> 2)) #define R128CCE2(p) ((p)) #define R128CCE3(p,n) ((p) | ((n) << 16)) + + + + +#define CCE_PACKET0( reg, n ) (R128_CCE_PACKET0 | \ + ((n) << 16) | ((reg) >> 2)) +#define CCE_PACKET1( reg0, reg1 ) (R128_CCE_PACKET1 | \ + (((reg1) >> 2) << 11) | ((reg0) >> 2)) +#define CCE_PACKET2() (R128_CCE_PACKET2) +#define CCE_PACKET3( pkt, n ) (R128_CCE_PACKET3 | \ + (pkt) | ((n) << 16)) + + +#define r128_flush_write_combine() mb() + + +#define R128_VERBOSE 0 + +#define RING_LOCALS int write; unsigned int tail_mask; volatile u32 *ring; + +#define BEGIN_RING( n ) do { \ + if ( R128_VERBOSE ) { \ + DRM_INFO( "BEGIN_RING( %d ) in %s\n", \ + n, __FUNCTION__ ); \ + } \ + if ( dev_priv->ring.space < n * sizeof(u32) ) { \ + r128_wait_ring( dev_priv, n * sizeof(u32) ); \ + } \ + dev_priv->ring.space -= n * sizeof(u32); \ + ring = dev_priv->ring.start; \ + write = dev_priv->ring.tail; \ + tail_mask = dev_priv->ring.tail_mask; \ +} while (0) + +#define ADVANCE_RING() do { \ + if ( R128_VERBOSE ) { \ + DRM_INFO( "ADVANCE_RING() tail=0x%06x wr=0x%06x\n", \ + write, dev_priv->ring.tail ); \ + } \ + r128_flush_write_combine(); \ + dev_priv->ring.tail = write; \ + R128_WRITE( R128_PM4_BUFFER_DL_WPTR, write ); \ +} while (0) + +#define OUT_RING( x ) do { \ + if ( R128_VERBOSE ) { \ + DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \ + (unsigned int)(x), write ); \ + } \ + ring[write++] = x; \ + write &= tail_mask; \ +} while (0) + +#define R128_PERFORMANCE_BOXES 0 -#endif +#endif /* __R128_DRV_H__ */ Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c:1.2 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c Tue Dec 12 12:17:14 2000 @@ -0,0 +1,1605 @@ +/* r128_state.c -- State support for r128 -*- linux-c -*- + * Created: Thu Jan 27 02:53:43 2000 by gareth@valinux.com + * + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Gareth Hughes <gareth@valinux.com> + * + */ + +#define __NO_VERSION__ +#include "drmP.h" +#include "r128_drv.h" +#include "drm.h" + + +/* ================================================================ + * CCE hardware state programming functions + */ + +static void r128_emit_clip_rects( drm_r128_private_t *dev_priv, + drm_clip_rect_t *boxes, int count ) +{ + u32 aux_sc_cntl = 0x00000000; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 17 ); + + if ( count >= 1 ) { + OUT_RING( CCE_PACKET0( R128_AUX1_SC_LEFT, 3 ) ); + OUT_RING( boxes[0].x1 ); + OUT_RING( boxes[0].x2 - 1 ); + OUT_RING( boxes[0].y1 ); + OUT_RING( boxes[0].y2 - 1 ); + + aux_sc_cntl |= (R128_AUX1_SC_EN | R128_AUX1_SC_MODE_OR); + } + if ( count >= 2 ) { + OUT_RING( CCE_PACKET0( R128_AUX2_SC_LEFT, 3 ) ); + OUT_RING( boxes[1].x1 ); + OUT_RING( boxes[1].x2 - 1 ); + OUT_RING( boxes[1].y1 ); + OUT_RING( boxes[1].y2 - 1 ); + + aux_sc_cntl |= (R128_AUX2_SC_EN | R128_AUX2_SC_MODE_OR); + } + if ( count >= 3 ) { + OUT_RING( CCE_PACKET0( R128_AUX3_SC_LEFT, 3 ) ); + OUT_RING( boxes[2].x1 ); + OUT_RING( boxes[2].x2 - 1 ); + OUT_RING( boxes[2].y1 ); + OUT_RING( boxes[2].y2 - 1 ); + + aux_sc_cntl |= (R128_AUX3_SC_EN | R128_AUX3_SC_MODE_OR); + } + + OUT_RING( CCE_PACKET0( R128_AUX_SC_CNTL, 0 ) ); + OUT_RING( aux_sc_cntl ); + + ADVANCE_RING(); +} + +static inline void r128_emit_core( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_SCALE_3D_CNTL, 0 ) ); + OUT_RING( ctx->scale_3d_cntl ); + + ADVANCE_RING(); +} + +static inline void r128_emit_context( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 13 ); + + OUT_RING( CCE_PACKET0( R128_DST_PITCH_OFFSET_C, 11 ) ); + OUT_RING( ctx->dst_pitch_offset_c ); + OUT_RING( ctx->dp_gui_master_cntl_c ); + OUT_RING( ctx->sc_top_left_c ); + OUT_RING( ctx->sc_bottom_right_c ); + OUT_RING( ctx->z_offset_c ); + OUT_RING( ctx->z_pitch_c ); + OUT_RING( ctx->z_sten_cntl_c ); + OUT_RING( ctx->tex_cntl_c ); + OUT_RING( ctx->misc_3d_state_cntl_reg ); + OUT_RING( ctx->texture_clr_cmp_clr_c ); + OUT_RING( ctx->texture_clr_cmp_msk_c ); + OUT_RING( ctx->fog_color_c ); + + ADVANCE_RING(); +} + +static inline void r128_emit_setup( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 3 ); + + OUT_RING( CCE_PACKET1( R128_SETUP_CNTL, R128_PM4_VC_FPU_SETUP ) ); + OUT_RING( ctx->setup_cntl ); + OUT_RING( ctx->pm4_vc_fpu_setup ); + + ADVANCE_RING(); +} + +static inline void r128_emit_masks( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 5 ); + + OUT_RING( CCE_PACKET0( R128_DP_WRITE_MASK, 0 ) ); + OUT_RING( ctx->dp_write_mask ); + + OUT_RING( CCE_PACKET0( R128_STEN_REF_MASK_C, 1 ) ); + OUT_RING( ctx->sten_ref_mask_c ); + OUT_RING( ctx->plane_3d_mask_c ); + + ADVANCE_RING(); +} + +static inline void r128_emit_window( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_WINDOW_XY_OFFSET, 0 ) ); + OUT_RING( ctx->window_xy_offset ); + + ADVANCE_RING(); +} + +static inline void r128_emit_tex0( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_context_regs_t *ctx = &sarea_priv->context_state; + drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[0]; + int i; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 7 + R128_TEX_MAXLEVELS ); + + OUT_RING( CCE_PACKET0( R128_PRIM_TEX_CNTL_C, + 2 + R128_TEX_MAXLEVELS ) ); + OUT_RING( tex->tex_cntl ); + OUT_RING( tex->tex_combine_cntl ); + OUT_RING( ctx->tex_size_pitch_c ); + for ( i = 0 ; i < R128_TEX_MAXLEVELS ; i++ ) { + OUT_RING( tex->tex_offset[i] ); + } + + OUT_RING( CCE_PACKET0( R128_CONSTANT_COLOR_C, 1 ) ); + OUT_RING( ctx->constant_color_c ); + OUT_RING( tex->tex_border_color ); + + ADVANCE_RING(); +} + +static inline void r128_emit_tex1( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_texture_regs_t *tex = &sarea_priv->tex_state[1]; + int i; + RING_LOCALS; + DRM_DEBUG( " %s\n", __FUNCTION__ ); + + BEGIN_RING( 5 + R128_TEX_MAXLEVELS ); + + OUT_RING( CCE_PACKET0( R128_SEC_TEX_CNTL_C, + 1 + R128_TEX_MAXLEVELS ) ); + OUT_RING( tex->tex_cntl ); + OUT_RING( tex->tex_combine_cntl ); + for ( i = 0 ; i < R128_TEX_MAXLEVELS ; i++ ) { + OUT_RING( tex->tex_offset[i] ); + } + + OUT_RING( CCE_PACKET0( R128_SEC_TEXTURE_BORDER_COLOR_C, 0 ) ); + OUT_RING( tex->tex_border_color ); + + ADVANCE_RING(); +} + +static inline void r128_emit_state( drm_r128_private_t *dev_priv ) +{ + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int dirty = sarea_priv->dirty; + + DRM_DEBUG( "%s: dirty=0x%08x\n", __FUNCTION__, dirty ); + + if ( dirty & R128_UPLOAD_CORE ) { + r128_emit_core( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_CORE; + } + + if ( dirty & R128_UPLOAD_CONTEXT ) { + r128_emit_context( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_CONTEXT; + } + + if ( dirty & R128_UPLOAD_SETUP ) { + r128_emit_setup( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_SETUP; + } + + if ( dirty & R128_UPLOAD_MASKS ) { + r128_emit_masks( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_MASKS; + } + + if ( dirty & R128_UPLOAD_WINDOW ) { + r128_emit_window( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_WINDOW; + } + + if ( dirty & R128_UPLOAD_TEX0 ) { + r128_emit_tex0( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_TEX0; + } + + if ( dirty & R128_UPLOAD_TEX1 ) { + r128_emit_tex1( dev_priv ); + sarea_priv->dirty &= ~R128_UPLOAD_TEX1; + } + + /* Turn off the texture cache flushing */ + sarea_priv->context_state.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH; + + sarea_priv->dirty &= ~R128_REQUIRE_QUIESCENCE; +} + + +#if R128_PERFORMANCE_BOXES +/* ================================================================ + * Performance monitoring functions + */ + +static void r128_clear_box( drm_r128_private_t *dev_priv, + int x, int y, int w, int h, + int r, int g, int b ) +{ + u32 pitch, offset; + u32 fb_bpp, color; + RING_LOCALS; + + switch ( dev_priv->fb_bpp ) { + case 16: + fb_bpp = R128_GMC_DST_16BPP; + color = (((r & 0xf8) << 8) | + ((g & 0xfc) << 3) | + ((b & 0xf8) >> 3)); + break; + case 24: + fb_bpp = R128_GMC_DST_24BPP; + color = ((r << 16) | (g << 8) | b); + break; + case 32: + fb_bpp = R128_GMC_DST_32BPP; + color = (((0xff) << 24) | (r << 16) | (g << 8) | b); + break; + default: + return; + } + + offset = dev_priv->back_offset; + pitch = dev_priv->back_pitch >> 3; + + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | fb_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS ); + + OUT_RING( (pitch << 21) | (offset >> 5) ); + OUT_RING( color ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (w << 16) | h ); + + ADVANCE_RING(); +} + +static void r128_cce_performance_boxes( drm_r128_private_t *dev_priv ) +{ + if ( atomic_read( &dev_priv->idle_count ) == 0 ) { + r128_clear_box( dev_priv, 64, 4, 8, 8, 0, 255, 0 ); + } else { + atomic_set( &dev_priv->idle_count, 0 ); + } +} + +#endif + + +/* ================================================================ + * CCE command dispatch functions + */ + +static void r128_print_dirty( const char *msg, unsigned int flags ) +{ + DRM_INFO( "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n", + msg, + flags, + (flags & R128_UPLOAD_CORE) ? "core, " : "", + (flags & R128_UPLOAD_CONTEXT) ? "context, " : "", + (flags & R128_UPLOAD_SETUP) ? "setup, " : "", + (flags & R128_UPLOAD_TEX0) ? "tex0, " : "", + (flags & R128_UPLOAD_TEX1) ? "tex1, " : "", + (flags & R128_UPLOAD_MASKS) ? "masks, " : "", + (flags & R128_UPLOAD_WINDOW) ? "window, " : "", + (flags & R128_UPLOAD_CLIPRECTS) ? "cliprects, " : "", + (flags & R128_REQUIRE_QUIESCENCE) ? "quiescence, " : "" ); +} + +static void r128_cce_dispatch_clear( drm_device_t *dev, + unsigned int flags, + int cx, int cy, int cw, int ch, + unsigned int clear_color, + unsigned int clear_depth ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + u32 fb_bpp, depth_bpp; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + switch ( dev_priv->fb_bpp ) { + case 16: + fb_bpp = R128_GMC_DST_16BPP; + break; + case 32: + fb_bpp = R128_GMC_DST_32BPP; + break; + default: + return; + } + switch ( dev_priv->depth_bpp ) { + case 16: + depth_bpp = R128_GMC_DST_16BPP; + break; + case 24: + case 32: + depth_bpp = R128_GMC_DST_32BPP; + break; + default: + return; + } + + for ( i = 0 ; i < nbox ; i++ ) { + int x = pbox[i].x1; + int y = pbox[i].y1; + int w = pbox[i].x2 - x; + int h = pbox[i].y2 - y; + + DRM_DEBUG( "dispatch clear %d,%d-%d,%d flags 0x%x\n", + pbox[i].x1, pbox[i].y1, pbox[i].x2, + pbox[i].y2, flags ); + + if ( flags & (R128_FRONT | R128_BACK) ) { + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_DP_WRITE_MASK, 0 ) ); + OUT_RING( sarea_priv->context_state.plane_3d_mask_c ); + + ADVANCE_RING(); + } + + if ( flags & R128_FRONT ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | fb_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS ); + + OUT_RING( dev_priv->front_pitch_offset_c ); + OUT_RING( clear_color ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (w << 16) | h ); + + ADVANCE_RING(); + } + + if ( flags & R128_BACK ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | fb_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS ); + + OUT_RING( dev_priv->back_pitch_offset_c ); + OUT_RING( clear_color ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (w << 16) | h ); + + ADVANCE_RING(); + } + + if ( flags & R128_DEPTH ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( clear_depth ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (w << 16) | h ); + + ADVANCE_RING(); + } + } +} + +static void r128_cce_dispatch_swap( drm_device_t *dev ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + u32 fb_bpp; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + +#if R128_PERFORMANCE_BOXES + /* Do some trivial performance monitoring... + */ + r128_cce_performance_boxes( dev_priv ); +#endif + + switch ( dev_priv->fb_bpp ) { + case 16: + fb_bpp = R128_GMC_DST_16BPP; + break; + case 32: + default: + fb_bpp = R128_GMC_DST_32BPP; + break; + } + + for ( i = 0 ; i < nbox ; i++ ) { + int x = pbox[i].x1; + int y = pbox[i].y1; + int w = pbox[i].x2 - x; + int h = pbox[i].y2 - y; + + BEGIN_RING( 7 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_BITBLT_MULTI, 5 ) ); + OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL + | R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_NONE + | fb_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_S + | R128_DP_SRC_SOURCE_MEMORY + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->back_pitch_offset_c ); + OUT_RING( dev_priv->front_pitch_offset_c ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (x << 16) | y ); + OUT_RING( (w << 16) | h ); + + ADVANCE_RING(); + } + + /* Increment the frame counter. The client-side 3D driver must + * throttle the framerate by waiting for this value before + * performing the swapbuffer ioctl. + */ + dev_priv->sarea_priv->last_frame++; + + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_LAST_FRAME_REG, 0 ) ); + OUT_RING( dev_priv->sarea_priv->last_frame ); + + ADVANCE_RING(); +} + +static void r128_cce_dispatch_vertex( drm_device_t *dev, + drm_buf_t *buf ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv = buf->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + int format = sarea_priv->vc_format; + int offset = dev_priv->buffers->offset + buf->offset - dev->agp->base; + int size = buf->used; + int prim = buf_priv->prim; + int i = 0; + RING_LOCALS; + DRM_DEBUG( "%s: buf=%d nbox=%d\n", + __FUNCTION__, buf->idx, sarea_priv->nbox ); + + r128_update_ring_snapshot( dev_priv ); + + if ( 0 ) + r128_print_dirty( "dispatch_vertex", sarea_priv->dirty ); + + if ( buf->used ) { + buf_priv->dispatched = 1; + + if ( sarea_priv->dirty & ~R128_UPLOAD_CLIPRECTS ) { + r128_emit_state( dev_priv ); + } + + do { + /* Emit the next set of up to three cliprects */ + if ( i < sarea_priv->nbox ) { + r128_emit_clip_rects( dev_priv, + &sarea_priv->boxes[i], + sarea_priv->nbox - i ); + } + + /* Emit the vertex buffer rendering commands */ + BEGIN_RING( 5 ); + + OUT_RING( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, 3 ) ); + OUT_RING( offset ); + OUT_RING( size ); + OUT_RING( format ); + OUT_RING( prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + ADVANCE_RING(); + + i += 3; + } while ( i < sarea_priv->nbox ); + } + + if ( buf_priv->discard ) { + buf_priv->age = dev_priv->sarea_priv->last_dispatch; + + /* Emit the vertex buffer age */ + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_LAST_DISPATCH_REG, 0 ) ); + OUT_RING( buf_priv->age ); + + ADVANCE_RING(); + + buf->pending = 1; + buf->used = 0; + /* FIXME: Check dispatched field */ + buf_priv->dispatched = 0; + } + + dev_priv->sarea_priv->last_dispatch++; + +#if 0 + if ( dev_priv->submit_age == R128_MAX_VB_AGE ) { + ret = r128_do_cce_idle( dev_priv ); + if ( ret < 0 ) return ret; + dev_priv->submit_age = 0; + r128_freelist_reset( dev ); + } +#endif + + sarea_priv->dirty &= ~R128_UPLOAD_CLIPRECTS; + sarea_priv->nbox = 0; +} + + + + +static void r128_cce_dispatch_indirect( drm_device_t *dev, + drm_buf_t *buf, + int start, int end ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv = buf->dev_private; + RING_LOCALS; + DRM_DEBUG( "indirect: buf=%d s=0x%x e=0x%x\n", + buf->idx, start, end ); + + r128_update_ring_snapshot( dev_priv ); + + if ( start != end ) { + int offset = (dev_priv->buffers->offset - dev->agp->base + + buf->offset + start); + int dwords = (end - start + 3) / sizeof(u32); + + /* Indirect buffer data must be an even number of + * dwords, so if we've been given an odd number we must + * pad the data with a Type-2 CCE packet. + */ + if ( dwords & 1 ) { + u32 *data = (u32 *) + ((char *)dev_priv->buffers->handle + + buf->offset + start); + data[dwords++] = R128_CCE_PACKET2; + } + + buf_priv->dispatched = 1; + + /* Fire off the indirect buffer */ + BEGIN_RING( 3 ); + + OUT_RING( CCE_PACKET0( R128_PM4_IW_INDOFF, 1 ) ); + OUT_RING( offset ); + OUT_RING( dwords ); + + ADVANCE_RING(); + } + + if ( buf_priv->discard ) { + buf_priv->age = dev_priv->sarea_priv->last_dispatch; + + /* Emit the indirect buffer age */ + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_LAST_DISPATCH_REG, 0 ) ); + OUT_RING( buf_priv->age ); + + ADVANCE_RING(); + + buf->pending = 1; + buf->used = 0; + /* FIXME: Check dispatched field */ + buf_priv->dispatched = 0; + } + + dev_priv->sarea_priv->last_dispatch++; + +#if 0 + if ( dev_priv->submit_age == R128_MAX_VB_AGE ) { + ret = r128_do_cce_idle( dev_priv ); + if ( ret < 0 ) return ret; + dev_priv->submit_age = 0; + r128_freelist_reset( dev ); + } +#endif +} + +static void r128_cce_dispatch_indices( drm_device_t *dev, + drm_buf_t *buf, + int start, int end, + int count ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv = buf->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + int format = sarea_priv->vc_format; + int offset = dev_priv->buffers->offset - dev->agp->base; + int prim = buf_priv->prim; + u32 *data; + int dwords; + int i = 0; + RING_LOCALS; + DRM_DEBUG( "indices: s=%d e=%d c=%d\n", start, end, count ); + + r128_update_ring_snapshot( dev_priv ); + + if ( 0 ) + r128_print_dirty( "dispatch_indices", sarea_priv->dirty ); + + if ( start != end ) { + buf_priv->dispatched = 1; + + if ( sarea_priv->dirty & ~R128_UPLOAD_CLIPRECTS ) { + r128_emit_state( dev_priv ); + } + + dwords = (end - start + 3) / sizeof(u32); + + data = (u32 *)((char *)dev_priv->buffers->handle + + buf->offset + start); + + data[0] = CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, dwords-2 ); + + data[1] = offset; + data[2] = R128_MAX_VB_VERTS; + data[3] = format; + data[4] = (prim | R128_CCE_VC_CNTL_PRIM_WALK_IND | + (count << 16)); + + if ( count & 0x1 ) { + data[dwords-1] &= 0x0000ffff; + } + + do { + /* Emit the next set of up to three cliprects */ + if ( i < sarea_priv->nbox ) { + r128_emit_clip_rects( dev_priv, + &sarea_priv->boxes[i], + sarea_priv->nbox - i ); + } + + r128_cce_dispatch_indirect( dev, buf, start, end ); + + i += 3; + } while ( i < sarea_priv->nbox ); + } + + if ( buf_priv->discard ) { + buf_priv->age = dev_priv->sarea_priv->last_dispatch; + + /* Emit the vertex buffer age */ + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_LAST_DISPATCH_REG, 0 ) ); + OUT_RING( buf_priv->age ); + + ADVANCE_RING(); + + buf->pending = 1; + /* FIXME: Check dispatched field */ + buf_priv->dispatched = 0; + } + + dev_priv->sarea_priv->last_dispatch++; + +#if 0 + if ( dev_priv->submit_age == R128_MAX_VB_AGE ) { + ret = r128_do_cce_idle( dev_priv ); + if ( ret < 0 ) return ret; + dev_priv->submit_age = 0; + r128_freelist_reset( dev ); + } +#endif + + sarea_priv->dirty &= ~R128_UPLOAD_CLIPRECTS; + sarea_priv->nbox = 0; +} + +static int r128_cce_dispatch_blit( drm_device_t *dev, + drm_r128_blit_t *blit ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_r128_buf_priv_t *buf_priv; + u32 *data; + int dword_shift, dwords; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + /* The compiler won't optimize away a division by a variable, + * even if the only legal values are powers of two. Thus, we'll + * use a shift instead. + */ + switch ( blit->format ) { + case R128_DATATYPE_ARGB1555: + case R128_DATATYPE_RGB565: + case R128_DATATYPE_ARGB4444: + dword_shift = 1; + break; + case R128_DATATYPE_ARGB8888: + dword_shift = 0; + break; + default: + DRM_ERROR( "invalid blit format %d\n", blit->format ); + return -EINVAL; + } + + /* Flush the pixel cache, and mark the contents as Read Invalid. + * This ensures no pixel data gets mixed up with the texture + * data from the host data blit, otherwise part of the texture + * image may be corrupted. + */ + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_PC_GUI_CTLSTAT, 0 ) ); + OUT_RING( R128_PC_RI_GUI | R128_PC_FLUSH_GUI ); + + ADVANCE_RING(); + + /* Dispatch the indirect buffer. + */ + buf = dma->buflist[blit->idx]; + buf_priv = buf->dev_private; + + if ( buf->pid != current->pid ) { + DRM_ERROR( "process %d using buffer owned by %d\n", + current->pid, buf->pid ); + return -EINVAL; + } + if ( buf->pending ) { + DRM_ERROR( "sending pending buffer %d\n", blit->idx ); + return -EINVAL; + } + + buf_priv->discard = 1; + + dwords = (blit->width * blit->height) >> dword_shift; + + data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset); + + data[0] = CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ); + data[1] = ( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_NONE + | (blit->format << 8) + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_S + | R128_DP_SRC_SOURCE_HOST_DATA + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_AUX_CLIP_DIS + | R128_GMC_WR_MSK_DIS ); + + data[2] = (blit->pitch << 21) | (blit->offset >> 5); + data[3] = 0xffffffff; + data[4] = 0xffffffff; + data[5] = (blit->y << 16) | blit->x; + data[6] = (blit->height << 16) | blit->width; + data[7] = dwords; + + buf->used = (dwords + 8) * sizeof(u32); + + r128_cce_dispatch_indirect( dev, buf, 0, buf->used ); + + /* Flush the pixel cache after the blit completes. This ensures + * the texture data is written out to memory before rendering + * continues. + */ + BEGIN_RING( 2 ); + + OUT_RING( CCE_PACKET0( R128_PC_GUI_CTLSTAT, 0 ) ); + OUT_RING( R128_PC_FLUSH_GUI ); + + ADVANCE_RING(); + + return 0; +} + + +/* ================================================================ + * Tiled depth buffer management + * + * FIXME: These should all set the destination write mask for when we + * have hardware stencil support. + */ + +static int r128_cce_dispatch_write_span( drm_device_t *dev, + drm_r128_depth_t *depth ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int count, x, y; + u32 *buffer; + u8 *mask; + u32 depth_bpp; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + switch ( dev_priv->depth_bpp ) { + case 16: + depth_bpp = R128_GMC_DST_16BPP; + break; + case 24: + case 32: + depth_bpp = R128_GMC_DST_32BPP; + break; + default: + return -EINVAL; + } + + count = depth->n; + if ( copy_from_user( &x, depth->x, sizeof(x) ) ) { + return -EFAULT; + } + if ( copy_from_user( &y, depth->y, sizeof(y) ) ) { + return -EFAULT; + } + + buffer = kmalloc( depth->n * sizeof(u32), 0 ); + if ( buffer == NULL ) + return -ENOMEM; + if ( copy_from_user( buffer, depth->buffer, + depth->n * sizeof(u32) ) ) { + kfree( buffer ); + return -EFAULT; + } + + if ( depth->mask ) { + mask = kmalloc( depth->n * sizeof(u8), 0 ); + if ( mask == NULL ) { + kfree( buffer ); + return -ENOMEM; + } + if ( copy_from_user( mask, depth->mask, + depth->n * sizeof(u8) ) ) { + kfree( buffer ); + kfree( mask ); + return -EFAULT; + } + + for ( i = 0 ; i < count ; i++, x++ ) { + if ( mask[i] ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, + 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( buffer[i] ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (1 << 16) | 1 ); + + ADVANCE_RING(); + } + } + + kfree( mask ); + } else { + for ( i = 0 ; i < count ; i++, x++ ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( buffer[i] ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (1 << 16) | 1 ); + + ADVANCE_RING(); + } + } + + kfree( buffer ); + + return 0; +} + +static int r128_cce_dispatch_write_pixels( drm_device_t *dev, + drm_r128_depth_t *depth ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int count, *x, *y; + u32 *buffer; + u8 *mask; + u32 depth_bpp; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + switch ( dev_priv->depth_bpp ) { + case 16: + depth_bpp = R128_GMC_DST_16BPP; + break; + case 24: + case 32: + depth_bpp = R128_GMC_DST_32BPP; + break; + default: + return -EINVAL; + } + + count = depth->n; + + x = kmalloc( count * sizeof(*x), 0 ); + if ( x == NULL ) { + return -ENOMEM; + } + y = kmalloc( count * sizeof(*y), 0 ); + if ( y == NULL ) { + kfree( x ); + return -ENOMEM; + } + if ( copy_from_user( x, depth->x, count * sizeof(int) ) ) { + kfree( x ); + kfree( y ); + return -EFAULT; + } + if ( copy_from_user( y, depth->y, count * sizeof(int) ) ) { + kfree( x ); + kfree( y ); + return -EFAULT; + } + + buffer = kmalloc( depth->n * sizeof(u32), 0 ); + if ( buffer == NULL ) { + kfree( x ); + kfree( y ); + return -ENOMEM; + } + if ( copy_from_user( buffer, depth->buffer, + depth->n * sizeof(u32) ) ) { + kfree( x ); + kfree( y ); + kfree( buffer ); + return -EFAULT; + } + + if ( depth->mask ) { + mask = kmalloc( depth->n * sizeof(u8), 0 ); + if ( mask == NULL ) { + kfree( x ); + kfree( y ); + kfree( buffer ); + return -ENOMEM; + } + if ( copy_from_user( mask, depth->mask, + depth->n * sizeof(u8) ) ) { + kfree( x ); + kfree( y ); + kfree( buffer ); + kfree( mask ); + return -EFAULT; + } + + for ( i = 0 ; i < count ; i++ ) { + if ( mask[i] ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, + 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( buffer[i] ); + + OUT_RING( (x[i] << 16) | y[i] ); + OUT_RING( (1 << 16) | 1 ); + + ADVANCE_RING(); + } + } + + kfree( mask ); + } else { + for ( i = 0 ; i < count ; i++ ) { + BEGIN_RING( 6 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) ); + OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_SOLID_COLOR + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( buffer[i] ); + + OUT_RING( (x[i] << 16) | y[i] ); + OUT_RING( (1 << 16) | 1 ); + + ADVANCE_RING(); + } + } + + kfree( x ); + kfree( y ); + kfree( buffer ); + + return 0; +} + +static int r128_cce_dispatch_read_span( drm_device_t *dev, + drm_r128_depth_t *depth ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int count, x, y; + u32 depth_bpp; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + switch ( dev_priv->depth_bpp ) { + case 16: + depth_bpp = R128_GMC_DST_16BPP; + break; + case 24: + case 32: + depth_bpp = R128_GMC_DST_32BPP; + break; + default: + return -EINVAL; + } + + count = depth->n; + if ( copy_from_user( &x, depth->x, sizeof(x) ) ) { + return -EFAULT; + } + if ( copy_from_user( &y, depth->y, sizeof(y) ) ) { + return -EFAULT; + } + + BEGIN_RING( 7 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_BITBLT_MULTI, 5 ) ); + OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL + | R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_NONE + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_S + | R128_DP_SRC_SOURCE_MEMORY + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( dev_priv->span_pitch_offset_c ); + + OUT_RING( (x << 16) | y ); + OUT_RING( (0 << 16) | 0 ); + OUT_RING( (count << 16) | 1 ); + + ADVANCE_RING(); + + return 0; +} + +static int r128_cce_dispatch_read_pixels( drm_device_t *dev, + drm_r128_depth_t *depth ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int count, *x, *y; + u32 depth_bpp; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + switch ( dev_priv->depth_bpp ) { + case 16: + depth_bpp = R128_GMC_DST_16BPP; + break; + case 24: + case 32: + depth_bpp = R128_GMC_DST_32BPP; + break; + default: + return -EINVAL; + } + + count = depth->n; + if ( count > dev_priv->depth_pitch ) { + count = dev_priv->depth_pitch; + } + + x = kmalloc( count * sizeof(*x), 0 ); + if ( x == NULL ) { + return -ENOMEM; + } + y = kmalloc( count * sizeof(*y), 0 ); + if ( y == NULL ) { + kfree( x ); + return -ENOMEM; + } + if ( copy_from_user( x, depth->x, count * sizeof(int) ) ) { + kfree( x ); + kfree( y ); + return -EFAULT; + } + if ( copy_from_user( y, depth->y, count * sizeof(int) ) ) { + kfree( x ); + kfree( y ); + return -EFAULT; + } + + for ( i = 0 ; i < count ; i++ ) { + BEGIN_RING( 7 ); + + OUT_RING( CCE_PACKET3( R128_CNTL_BITBLT_MULTI, 5 ) ); + OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL + | R128_GMC_DST_PITCH_OFFSET_CNTL + | R128_GMC_BRUSH_NONE + | depth_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_S + | R128_DP_SRC_SOURCE_MEMORY + | R128_GMC_CLR_CMP_CNTL_DIS + | R128_GMC_WR_MSK_DIS ); + + OUT_RING( dev_priv->depth_pitch_offset_c ); + OUT_RING( dev_priv->span_pitch_offset_c ); + + OUT_RING( (x[i] << 16) | y[i] ); + OUT_RING( (i << 16) | 0 ); + OUT_RING( (1 << 16) | 1 ); + + ADVANCE_RING(); + } + + kfree( x ); + kfree( y ); + + return 0; +} + + +/* ================================================================ + * Polygon stipple + */ + +static void r128_cce_dispatch_stipple( drm_device_t *dev, u32 *stipple ) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int i; + RING_LOCALS; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + r128_update_ring_snapshot( dev_priv ); + + BEGIN_RING( 33 ); + + OUT_RING( CCE_PACKET0( R128_BRUSH_DATA0, 31 ) ); + for ( i = 0 ; i < 32 ; i++ ) { + OUT_RING( stipple[i] ); + } + + ADVANCE_RING(); +} + + +/* ================================================================ + * IOCTL functions + */ + +int r128_cce_clear( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_r128_clear_t clear; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "r128_cce_clear called without lock held\n" ); + return -EINVAL; + } + + if ( copy_from_user( &clear, (drm_r128_clear_t *) arg, + sizeof(clear) ) ) + return -EFAULT; + + if ( sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS ) + sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS; + + r128_cce_dispatch_clear( dev, clear.flags, + clear.x, clear.y, clear.w, clear.h, + clear.clear_color, clear.clear_depth ); + + /* Make sure we restore the 3D state next time. + */ + dev_priv->sarea_priv->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS; + + return 0; +} + +int r128_cce_swap( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv; + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "r128_cce_swap called without lock held\n" ); + return -EINVAL; + } + + if ( sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS ) + sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS; + + r128_cce_dispatch_swap( dev ); + + /* Make sure we restore the 3D state next time. + */ + dev_priv->sarea_priv->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS; + + return 0; +} + +int r128_cce_vertex( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_r128_buf_priv_t *buf_priv; + drm_r128_vertex_t vertex; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + if ( !dev_priv || dev_priv->is_pci ) { + DRM_ERROR( "%s called with a PCI card\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &vertex, (drm_r128_vertex_t *)arg, + sizeof(vertex) ) ) + return -EFAULT; + + DRM_DEBUG( "%s: pid=%d index=%d count=%d discard=%d\n", + __FUNCTION__, current->pid, + vertex.idx, vertex.count, vertex.discard ); + + if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) { + DRM_ERROR( "buffer index %d (of %d max)\n", + vertex.idx, dma->buf_count - 1 ); + return -EINVAL; + } + if ( vertex.prim < 0 || + vertex.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) { + DRM_ERROR( "buffer prim %d\n", vertex.prim ); + return -EINVAL; + } + + buf = dma->buflist[vertex.idx]; + buf_priv = buf->dev_private; + + if ( buf->pid != current->pid ) { + DRM_ERROR( "process %d using buffer owned by %d\n", + current->pid, buf->pid ); + return -EINVAL; + } + if ( buf->pending ) { + DRM_ERROR( "sending pending buffer %d\n", vertex.idx ); + return -EINVAL; + } + + buf->used = vertex.count; + buf_priv->prim = vertex.prim; + buf_priv->discard = vertex.discard; + + r128_cce_dispatch_vertex( dev, buf ); + + return 0; +} + +int r128_cce_indices( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_r128_buf_priv_t *buf_priv; + drm_r128_indices_t elts; + int count; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + if ( !dev_priv || dev_priv->is_pci ) { + DRM_ERROR( "%s called with a PCI card\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &elts, (drm_r128_indices_t *)arg, + sizeof(elts) ) ) + return -EFAULT; + + DRM_DEBUG( "%s: pid=%d buf=%d s=%d e=%d d=%d\n", + __FUNCTION__, current->pid, + elts.idx, elts.start, elts.end, elts.discard ); + + if ( elts.idx < 0 || elts.idx >= dma->buf_count ) { + DRM_ERROR( "buffer index %d (of %d max)\n", + elts.idx, dma->buf_count - 1 ); + return -EINVAL; + } + if ( elts.prim < 0 || + elts.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) { + DRM_ERROR( "buffer prim %d\n", elts.prim ); + return -EINVAL; + } + + buf = dma->buflist[elts.idx]; + buf_priv = buf->dev_private; + + if ( buf->pid != current->pid ) { + DRM_ERROR( "process %d using buffer owned by %d\n", + current->pid, buf->pid ); + return -EINVAL; + } + if ( buf->pending ) { + DRM_ERROR( "sending pending buffer %d\n", elts.idx ); + return -EINVAL; + } + + count = (elts.end - elts.start) / sizeof(u16); + elts.start -= R128_INDEX_PRIM_OFFSET; + + if ( elts.start & 0x7 ) { + DRM_ERROR( "misaligned buffer 0x%x\n", elts.start ); + return -EINVAL; + } + if ( elts.start < buf->used ) { + DRM_ERROR( "no header 0x%x - 0x%x\n", elts.start, buf->used ); + return -EINVAL; + } + + buf->used = elts.end; + buf_priv->prim = elts.prim; + buf_priv->discard = elts.discard; + + r128_cce_dispatch_indices( dev, buf, elts.start, elts.end, count ); + + return 0; +} + +int r128_cce_blit( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + drm_r128_blit_t blit; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &blit, (drm_r128_blit_t *)arg, + sizeof(blit) ) ) + return -EFAULT; + + DRM_DEBUG( "%s: pid=%d index=%d\n", + __FUNCTION__, current->pid, blit.idx ); + + if ( blit.idx < 0 || blit.idx >= dma->buf_count ) { + DRM_ERROR( "buffer index %d (of %d max)\n", + blit.idx, dma->buf_count - 1 ); + return -EINVAL; + } + + return r128_cce_dispatch_blit( dev, &blit ); +} + +int r128_cce_depth( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_depth_t depth; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &depth, (drm_r128_depth_t *)arg, + sizeof(depth) ) ) + return -EFAULT; + + switch ( depth.func ) { + case R128_WRITE_SPAN: + return r128_cce_dispatch_write_span( dev, &depth ); + case R128_WRITE_PIXELS: + return r128_cce_dispatch_write_pixels( dev, &depth ); + case R128_READ_SPAN: + return r128_cce_dispatch_read_span( dev, &depth ); + case R128_READ_PIXELS: + return r128_cce_dispatch_read_pixels( dev, &depth ); + } + + return -EINVAL; +} + +int r128_cce_stipple( struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg ) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_stipple_t stipple; + u32 mask[32]; + + if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || + dev->lock.pid != current->pid ) { + DRM_ERROR( "%s called without lock held\n", __FUNCTION__ ); + return -EINVAL; + } + + if ( copy_from_user( &stipple, (drm_r128_stipple_t *)arg, + sizeof(stipple) ) ) + return -EFAULT; + + if ( copy_from_user( &mask, stipple.mask, + 32 * sizeof(u32) ) ) + return -EFAULT; + + r128_cce_dispatch_stipple( dev, mask ); + + return 0; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c:1.5 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c Fri Dec 1 09:29:02 2000 @@ -0,0 +1,221 @@ +/* sis_context.c -- IOCTLs for sis contexts -*- linux-c -*- + * Created: Thu Oct 7 10:50:22 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#define __NO_VERSION__ +#include "drmP.h" +#include "sis_drv.h" + +extern drm_ctx_t sis_res_ctx; + +static int sis_alloc_queue(drm_device_t *dev) +{ + return drm_ctxbitmap_next(dev); +} + +int sis_context_switch(drm_device_t *dev, int old, int new) +{ + char buf[64]; + + atomic_inc(&dev->total_ctx); + + if (test_and_set_bit(0, &dev->context_flag)) { + DRM_ERROR("Reentering -- FIXME\n"); + return -EBUSY; + } + +#if DRM_DMA_HISTOGRAM + dev->ctx_start = get_cycles(); +#endif + + DRM_DEBUG("Context switch from %d to %d\n", old, new); + + if (new == dev->last_context) { + clear_bit(0, &dev->context_flag); + return 0; + } + + if (drm_flags & DRM_FLAG_NOCTX) { + sis_context_switch_complete(dev, new); + } else { + sprintf(buf, "C %d %d\n", old, new); + drm_write_string(dev, buf); + } + + return 0; +} + +int sis_context_switch_complete(drm_device_t *dev, int new) +{ + dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ + dev->last_switch = jiffies; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("Lock isn't held after context switch\n"); + } + + /* If a context switch is ever initiated + when the kernel holds the lock, release + that lock here. */ +#if DRM_DMA_HISTOGRAM + atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles() + - dev->ctx_start)]); + +#endif + clear_bit(0, &dev->context_flag); + wake_up(&dev->context_wait); + + return 0; +} + + +int sis_resctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_ctx_res_t res; + drm_ctx_t ctx; + int i; + + DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; + if (res.count >= DRM_RESERVED_CONTEXTS) { + memset(&ctx, 0, sizeof(ctx)); + for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { + ctx.handle = i; + if (copy_to_user(&res.contexts[i], &i, sizeof(i))) + return -EFAULT; + } + } + res.count = DRM_RESERVED_CONTEXTS; + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; + return 0; +} + + +int sis_addctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + if ((ctx.handle = sis_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { + /* Skip kernel's context and get a new one. */ + ctx.handle = sis_alloc_queue(dev); + } + DRM_DEBUG("%d\n", ctx.handle); + if (ctx.handle == -1) { + DRM_DEBUG("Not enough free contexts.\n"); + /* Should this return -EBUSY instead? */ + return -ENOMEM; + } + + /* new added */ + sis_init_context(ctx.handle); + + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; + return 0; +} + +int sis_modctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; + if (ctx.flags==_DRM_CONTEXT_PRESERVED) + sis_res_ctx.handle=ctx.handle; + return 0; +} + +int sis_getctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; + /* This is 0, because we don't hanlde any context flags */ + ctx.flags = 0; + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; + return 0; +} + +int sis_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + return sis_context_switch(dev, dev->last_context, ctx.handle); +} + +int sis_newctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + sis_context_switch_complete(dev, ctx.handle); + + return 0; +} + +int sis_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; + DRM_DEBUG("%d\n", ctx.handle); + drm_ctxbitmap_free(dev, ctx.handle); + + return 0; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h:1.5 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h Wed Nov 8 00:03:07 2000 @@ -0,0 +1,31 @@ + +#ifndef _sis_drm_public_h_ +#define _sis_drm_public_h_ + +typedef struct { + int context; + unsigned int offset; + unsigned int size; + unsigned int free; +} drm_sis_mem_t; + +typedef struct { + unsigned int offset, size; +} drm_sis_agp_t; + +typedef struct { + unsigned int left, right; +} drm_sis_flip_t; + +#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t) +#define SIS_IOCTL_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t) + +#define SIS_IOCTL_AGP_INIT DRM_IOWR( 0x53, drm_sis_agp_t) +#define SIS_IOCTL_AGP_ALLOC DRM_IOWR( 0x54, drm_sis_mem_t) +#define SIS_IOCTL_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t) + +#define SIS_IOCTL_FLIP DRM_IOW( 0x48, drm_sis_flip_t) +#define SIS_IOCTL_FLIP_INIT DRM_IO( 0x49) +#define SIS_IOCTL_FLIP_FINAL DRM_IO( 0x50) + +#endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c:1.9 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c Fri Dec 1 09:29:03 2000 @@ -0,0 +1,694 @@ +/* sis.c -- sis driver -*- linux-c -*- + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#include <linux/config.h> +#include "drmP.h" +#include "sis_drm.h" +#include "sis_drv.h" + +#define SIS_NAME "sis" +#define SIS_DESC "SIS 300/630/540" +#define SIS_DATE "20000831" +#define SIS_MAJOR 1 +#define SIS_MINOR 0 +#define SIS_PATCHLEVEL 0 + +static drm_device_t sis_device; +drm_ctx_t sis_res_ctx; + +static struct file_operations sis_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif + open: sis_open, + flush: drm_flush, + release: sis_release, + ioctl: sis_ioctl, + mmap: drm_mmap, + read: drm_read, + fasync: drm_fasync, + poll: drm_poll, +}; + +static struct miscdevice sis_misc = { + minor: MISC_DYNAMIC_MINOR, + name: SIS_NAME, + fops: &sis_fops, +}; + +static drm_ioctl_desc_t sis_ioctls[] = { + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { sis_version, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { sis_addctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { sis_rmctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { sis_modctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { sis_getctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { sis_switchctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { sis_newctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { sis_resctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { sis_lock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { sis_unlock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind, 1, 1}, +#endif + /* FB Memory Management */ + [DRM_IOCTL_NR(SIS_IOCTL_FB_ALLOC)] = { sis_fb_alloc, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FB_FREE)] = { sis_fb_free, 1, 1 }, + + /* AGP Memory Management */ + [DRM_IOCTL_NR(SIS_IOCTL_AGP_INIT)] = { sis_agp_init, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_AGP_ALLOC)] = { sis_agp_alloc, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_AGP_FREE)] = { sis_agp_free, 1, 1 }, + +#if defined(SIS_STEREO) + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { sis_control, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP)] = { sis_flip, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP_INIT)] = { sis_flip_init, 1, 1 }, + [DRM_IOCTL_NR(SIS_IOCTL_FLIP_FINAL)] = { sis_flip_final, 1, 1 }, +#endif +}; +#define SIS_IOCTL_COUNT DRM_ARRAY_SIZE(sis_ioctls) + +#ifdef MODULE +static char *sis = NULL; +#endif + +MODULE_AUTHOR("VA Linux Systems, Inc."); +MODULE_DESCRIPTION("sis"); +MODULE_PARM(sis, "s"); + +#ifndef MODULE +/* sis_options is called by the kernel to parse command-line options + * passed via the boot-loader (e.g., LILO). It calls the insmod option + * routine, drm_parse_drm. + */ + +static int __init sis_options(char *str) +{ + drm_parse_options(str); + return 1; +} + +__setup("sis=", sis_options); +#endif + +static int sis_setup(drm_device_t *dev) +{ + int i; + + atomic_set(&dev->ioctl_count, 0); + atomic_set(&dev->vma_count, 0); + dev->buf_use = 0; + atomic_set(&dev->buf_alloc, 0); + + atomic_set(&dev->total_open, 0); + atomic_set(&dev->total_close, 0); + atomic_set(&dev->total_ioctl, 0); + atomic_set(&dev->total_irq, 0); + atomic_set(&dev->total_ctx, 0); + atomic_set(&dev->total_locks, 0); + atomic_set(&dev->total_unlocks, 0); + atomic_set(&dev->total_contends, 0); + atomic_set(&dev->total_sleeps, 0); + + for (i = 0; i < DRM_HASH_SIZE; i++) { + dev->magiclist[i].head = NULL; + dev->magiclist[i].tail = NULL; + } + dev->maplist = NULL; + dev->map_count = 0; + dev->vmalist = NULL; + dev->lock.hw_lock = NULL; + init_waitqueue_head(&dev->lock.lock_queue); + dev->queue_count = 0; + dev->queue_reserved = 0; + dev->queue_slots = 0; + dev->queuelist = NULL; + dev->irq = 0; + dev->context_flag = 0; + dev->interrupt_flag = 0; + dev->dma = 0; + dev->dma_flag = 0; + dev->last_context = 0; + dev->last_switch = 0; + dev->last_checked = 0; + init_timer(&dev->timer); + init_waitqueue_head(&dev->context_wait); + + dev->ctx_start = 0; + dev->lck_start = 0; + + dev->buf_rp = dev->buf; + dev->buf_wp = dev->buf; + dev->buf_end = dev->buf + DRM_BSZ; + dev->buf_async = NULL; + init_waitqueue_head(&dev->buf_readers); + init_waitqueue_head(&dev->buf_writers); + + sis_res_ctx.handle=-1; + + DRM_DEBUG("\n"); + + /* The kernel's context could be created here, but is now created + in drm_dma_enqueue. This is more resource-efficient for + hardware that does not do DMA, but may mean that + drm_select_queue fails between the time the interrupt is + initialized and the time the queues are initialized. */ + + return 0; +} + + +static int sis_takedown(drm_device_t *dev) +{ + int i; + drm_magic_entry_t *pt, *next; + drm_map_t *map; + drm_vma_entry_t *vma, *vma_next; + + DRM_DEBUG("\n"); + +#if defined(SIS_STEREO) + if (dev->irq) sis_irq_uninstall(dev); +#endif + + down(&dev->struct_sem); + del_timer(&dev->timer); + + if (dev->devname) { + drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); + dev->devname = NULL; + } + + if (dev->unique) { + drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); + dev->unique = NULL; + dev->unique_len = 0; + } + /* Clear pid list */ + for (i = 0; i < DRM_HASH_SIZE; i++) { + for (pt = dev->magiclist[i].head; pt; pt = next) { + next = pt->next; + drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); + } + dev->magiclist[i].head = dev->magiclist[i].tail = NULL; + } +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + /* Clear AGP information */ + if (dev->agp) { + drm_agp_mem_t *temp; + drm_agp_mem_t *temp_next; + + temp = dev->agp->memory; + while(temp != NULL) { + temp_next = temp->next; + drm_free_agp(temp->memory, temp->pages); + drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); + temp = temp_next; + } + if (dev->agp->acquired) _drm_agp_release(); + } +#endif + /* Clear vma list (only built for debugging) */ + if (dev->vmalist) { + for (vma = dev->vmalist; vma; vma = vma_next) { + vma_next = vma->next; + drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); + } + dev->vmalist = NULL; + } + + /* Clear map area and mtrr information */ + if (dev->maplist) { + for (i = 0; i < dev->map_count; i++) { + map = dev->maplist[i]; + switch (map->type) { + case _DRM_REGISTERS: + case _DRM_FRAME_BUFFER: +#ifdef CONFIG_MTRR + if (map->mtrr >= 0) { + int retcode; + retcode = mtrr_del(map->mtrr, + map->offset, + map->size); + DRM_DEBUG("mtrr_del = %d\n", retcode); + } +#endif + drm_ioremapfree(map->handle, map->size); + break; + case _DRM_SHM: + drm_free_pages((unsigned long)map->handle, + drm_order(map->size) + - PAGE_SHIFT, + DRM_MEM_SAREA); + break; + case _DRM_AGP: + /* Do nothing here, because this is all + handled in the AGP/GART driver. */ + break; + } + drm_free(map, sizeof(*map), DRM_MEM_MAPS); + } + drm_free(dev->maplist, + dev->map_count * sizeof(*dev->maplist), + DRM_MEM_MAPS); + dev->maplist = NULL; + dev->map_count = 0; + } + + if (dev->lock.hw_lock) { + dev->lock.hw_lock = NULL; /* SHM removed */ + dev->lock.pid = 0; + wake_up_interruptible(&dev->lock.lock_queue); + } + up(&dev->struct_sem); + + return 0; +} + +/* sis_init is called via init_module at module load time, or via + * linux/init/main.c (this is not currently supported). */ + +static int sis_init(void) +{ + int retcode; + drm_device_t *dev = &sis_device; + + DRM_DEBUG("\n"); + + memset((void *)dev, 0, sizeof(*dev)); + dev->count_lock = SPIN_LOCK_UNLOCKED; + sema_init(&dev->struct_sem, 1); + +#ifdef MODULE + drm_parse_options(sis); +#endif + + if ((retcode = misc_register(&sis_misc))) { + DRM_ERROR("Cannot register \"%s\"\n", SIS_NAME); + return retcode; + } + dev->device = MKDEV(MISC_MAJOR, sis_misc.minor); + dev->name = SIS_NAME; + + drm_mem_init(); + drm_proc_init(dev); +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + dev->agp = drm_agp_init(); +#endif + if((retcode = drm_ctxbitmap_init(dev))) { + DRM_ERROR("Cannot allocate memory for context bitmap.\n"); + drm_proc_cleanup(); + misc_deregister(&sis_misc); + sis_takedown(dev); + return retcode; + } + + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + SIS_NAME, + SIS_MAJOR, + SIS_MINOR, + SIS_PATCHLEVEL, + SIS_DATE, + sis_misc.minor); + + return 0; +} + +/* sis_cleanup is called via cleanup_module at module unload time. */ + +static void sis_cleanup(void) +{ + drm_device_t *dev = &sis_device; + + DRM_DEBUG("\n"); + + drm_proc_cleanup(); + if (misc_deregister(&sis_misc)) { + DRM_ERROR("Cannot unload module\n"); + } else { + DRM_INFO("Module unloaded\n"); + } + drm_ctxbitmap_cleanup(dev); + sis_takedown(dev); +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + if (dev->agp) { + drm_agp_uninit(); + drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); + dev->agp = NULL; + } +#endif +} + +module_init(sis_init); +module_exit(sis_cleanup); + + +int sis_version(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_version_t version; + int len; + + if (copy_from_user(&version, (drm_version_t *)arg, sizeof(version))) + return -EFAULT; + +#define DRM_COPY(name,value) \ + len = strlen(value); \ + if (len > name##_len) len = name##_len; \ + name##_len = strlen(value); \ + if (len && name) { \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ + } + + version.version_major = SIS_MAJOR; + version.version_minor = SIS_MINOR; + version.version_patchlevel = SIS_PATCHLEVEL; + + DRM_COPY(version.name, SIS_NAME); + DRM_COPY(version.date, SIS_DATE); + DRM_COPY(version.desc, SIS_DESC); + + if (copy_to_user((drm_version_t *)arg, &version, sizeof(version))) + return -EFAULT; + return 0; +} + +int sis_open(struct inode *inode, struct file *filp) +{ + drm_device_t *dev = &sis_device; + int retcode = 0; + + DRM_DEBUG("open_count = %d\n", dev->open_count); + if (!(retcode = drm_open_helper(inode, filp, dev))) { +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif + atomic_inc(&dev->total_open); + spin_lock(&dev->count_lock); + if (!dev->open_count++) { + spin_unlock(&dev->count_lock); + return sis_setup(dev); + } + spin_unlock(&dev->count_lock); + } + return retcode; +} + +int sis_release(struct inode *inode, struct file *filp) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev; + int retcode = 0; + + lock_kernel(); + dev = priv->dev; + + DRM_DEBUG("open_count = %d\n", dev->open_count); + if (!(retcode = drm_release(inode, filp))) { +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif + atomic_inc(&dev->total_close); + spin_lock(&dev->count_lock); + if (!--dev->open_count) { + if (atomic_read(&dev->ioctl_count) || dev->blocked) { + DRM_ERROR("Device busy: %d %d\n", + atomic_read(&dev->ioctl_count), + dev->blocked); + spin_unlock(&dev->count_lock); + unlock_kernel(); + return -EBUSY; + } + spin_unlock(&dev->count_lock); + unlock_kernel(); + return sis_takedown(dev); + } + spin_unlock(&dev->count_lock); + } + + unlock_kernel(); + return retcode; +} + +/* sis_ioctl is called whenever a process performs an ioctl on /dev/drm. */ + +int sis_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + int nr = DRM_IOCTL_NR(cmd); + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int retcode = 0; + drm_ioctl_desc_t *ioctl; + drm_ioctl_t *func; + + atomic_inc(&dev->ioctl_count); + atomic_inc(&dev->total_ioctl); + ++priv->ioctl_count; + + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", + current->pid, cmd, nr, dev->device, priv->authenticated); + + if (nr >= SIS_IOCTL_COUNT) { + retcode = -EINVAL; + } else { + ioctl = &sis_ioctls[nr]; + func = ioctl->func; + + if (!func) { + DRM_DEBUG("no function\n"); + retcode = -EINVAL; + } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) + || (ioctl->auth_needed && !priv->authenticated)) { + retcode = -EACCES; + } else { + retcode = (func)(inode, filp, cmd, arg); + } + } + + atomic_dec(&dev->ioctl_count); + return retcode; +} + +int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + DECLARE_WAITQUEUE(entry, current); + int ret = 0; + drm_lock_t lock; +#if DRM_DMA_HISTOGRAM + cycles_t start; + + dev->lck_start = start = get_cycles(); +#endif + + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + + if (lock.context == DRM_KERNEL_CONTEXT) { + DRM_ERROR("Process %d using kernel context %d\n", + current->pid, lock.context); + return -EINVAL; + } + + DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", + lock.context, current->pid, dev->lock.hw_lock->lock, + lock.flags); + +#if 0 + /* dev->queue_count == 0 right now for + sis. FIXME? */ + if (lock.context < 0 || lock.context >= dev->queue_count) + return -EINVAL; +#endif + + if (!ret) { +#if 0 + if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) + != lock.context) { + long j = jiffies - dev->lock.lock_time; + + if (lock.context == sis_res_ctx.handle && + j >= 0 && j < DRM_LOCK_SLICE) { + /* Can't take lock if we just had it and + there is contention. */ + DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", + lock.context, current->pid, j, + dev->lock.lock_time, jiffies); + current->state = TASK_INTERRUPTIBLE; + current->policy |= SCHED_YIELD; + schedule_timeout(DRM_LOCK_SLICE-j); + DRM_DEBUG("jiffies=%d\n", jiffies); + } + } +#endif + add_wait_queue(&dev->lock.lock_queue, &entry); + for (;;) { + current->state = TASK_INTERRUPTIBLE; + if (!dev->lock.hw_lock) { + /* Device has been unregistered */ + ret = -EINTR; + break; + } + if (drm_lock_take(&dev->lock.hw_lock->lock, + lock.context)) { + dev->lock.pid = current->pid; + dev->lock.lock_time = jiffies; + atomic_inc(&dev->total_locks); + break; /* Got lock */ + } + + /* Contention */ + atomic_inc(&dev->total_sleeps); +#if 1 + current->policy |= SCHED_YIELD; +#endif + schedule(); + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + } + current->state = TASK_RUNNING; + remove_wait_queue(&dev->lock.lock_queue, &entry); + } + +#if 0 + if (!ret && dev->last_context != lock.context && + lock.context != sis_res_ctx.handle && + dev->last_context != sis_res_ctx.handle) { + add_wait_queue(&dev->context_wait, &entry); + current->state = TASK_INTERRUPTIBLE; + /* PRE: dev->last_context != lock.context */ + sis_context_switch(dev, dev->last_context, lock.context); + /* POST: we will wait for the context + switch and will dispatch on a later call + when dev->last_context == lock.context + NOTE WE HOLD THE LOCK THROUGHOUT THIS + TIME! */ + current->policy |= SCHED_YIELD; + schedule(); + current->state = TASK_RUNNING; + remove_wait_queue(&dev->context_wait, &entry); + if (signal_pending(current)) { + ret = -EINTR; + } else if (dev->last_context != lock.context) { + DRM_ERROR("Context mismatch: %d %d\n", + dev->last_context, lock.context); + } + } +#endif + + if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + + if (lock.flags & _DRM_LOCK_READY) { + /* Wait for space in DMA/FIFO */ + } + if (lock.flags & _DRM_LOCK_QUIESCENT) { + /* Make hardware quiescent */ +#if 0 + sis_quiescent(dev); +#endif + } + } + + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + +#if DRM_DMA_HISTOGRAM + atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); +#endif + + return ret; +} + + +int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_lock_t lock; + + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + + if (lock.context == DRM_KERNEL_CONTEXT) { + DRM_ERROR("Process %d using kernel context %d\n", + current->pid, lock.context); + return -EINVAL; + } + + DRM_DEBUG("%d frees lock (%d holds)\n", + lock.context, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + atomic_inc(&dev->total_unlocks); + if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) + atomic_inc(&dev->total_contends); + drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); + /* FIXME: Try to send data to card here */ + if (!dev->context_flag) { + if (drm_lock_free(dev, &dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT)) { + DRM_ERROR("\n"); + } + } + + unblock_all_signals(); + return 0; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h:1.5 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h Tue Sep 26 12:21:25 2000 @@ -0,0 +1,90 @@ +/* sis_drv.h -- Private header for sis driver -*- linux-c -*- + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef _SIS_DRV_H_ +#define _SIS_DRV_H_ + + /* sis_drv.c */ +extern int sis_version(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_open(struct inode *inode, struct file *filp); +extern int sis_release(struct inode *inode, struct file *filp); +extern int sis_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_irq_install(drm_device_t *dev, int irq); +extern int sis_irq_uninstall(drm_device_t *dev); +extern int sis_control(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_lock(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_unlock(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + + /* sis_context.c */ + +extern int sis_resctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_addctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_modctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_getctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_switchctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_newctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int sis_rmctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + +extern int sis_context_switch(drm_device_t *dev, int old, int new); +extern int sis_context_switch_complete(drm_device_t *dev, int new); + +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); + +int sis_agp_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); + +int sis_flip(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_flip_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +int sis_flip_final(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +void flip_final(void); + +int sis_init_context(int contexy); +int sis_final_context(int context); + +#endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c:1.3 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c Tue Sep 26 12:21:25 2000 @@ -0,0 +1,406 @@ +/* sis_ds.c -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#define __NO_VERSION__ +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/malloc.h> +#include <linux/poll.h> +#include <asm/io.h> +#include <linux/pci.h> + +#include "sis_ds.h" + +/* Set Data Structure, not check repeated value + * temporarily used + */ + +set_t *setInit(void) +{ + int i; + set_t *set; + + set = (set_t *)MALLOC(sizeof(set_t)); + for(i = 0; i < SET_SIZE; i++){ + set->list[i].free_next = i+1; + set->list[i].alloc_next = -1; + } + set->list[SET_SIZE-1].free_next = -1; + set->free = 0; + set->alloc = -1; + set->trace = -1; + + return set; +} + +int setAdd(set_t *set, ITEM_TYPE item) +{ + int free = set->free; + + if(free != -1){ + set->list[free].val = item; + set->free = set->list[free].free_next; + } + else{ + return 0; + } + + set->list[free].alloc_next = set->alloc; + set->alloc = free; + set->list[free].free_next = -1; + + return 1; +} + +int setDel(set_t *set, ITEM_TYPE item) +{ + int alloc = set->alloc; + int prev = -1; + + while(alloc != -1){ + if(set->list[alloc].val == item){ + if(prev != -1) + set->list[prev].alloc_next = set->list[alloc].alloc_next; + else + set->alloc = set->list[alloc].alloc_next; + break; + } + prev = alloc; + alloc = set->list[alloc].alloc_next; + } + + if(alloc == -1) + return 0; + + set->list[alloc].free_next = set->free; + set->free = alloc; + set->list[alloc].alloc_next = -1; + + return 1; +} + +/* setFirst -> setAdd -> setNext is wrong */ + +int setFirst(set_t *set, ITEM_TYPE *item) +{ + if(set->alloc == -1) + return 0; + + *item = set->list[set->alloc].val; + set->trace = set->list[set->alloc].alloc_next; + + return 1; +} + +int setNext(set_t *set, ITEM_TYPE *item) +{ + if(set->trace == -1) + return 0; + + *item = set->list[set->trace].val; + set->trace = set->list[set->trace].alloc_next; + + return 1; +} + +int setDestroy(set_t *set) +{ + FREE(set); + + return 1; +} + +/* + * GLX Hardware Device Driver common code + * Copyright (C) 1999 Keith Whitwell + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#define ISFREE(bptr) ((bptr)->free) + +#define PRINTF(fmt, arg...) do{}while(0) +#define fprintf(fmt, arg...) do{}while(0) + +static void *calloc(size_t nmemb, size_t size) +{ + void *addr; + addr = kmalloc(nmemb*size, GFP_KERNEL); + memset(addr, 0, nmemb*size); + return addr; +} +#define free(n) kfree(n) + +void mmDumpMemInfo( memHeap_t *heap ) +{ + TMemBlock *p; + + PRINTF ("Memory heap %p:\n", heap); + if (heap == 0) { + PRINTF (" heap == 0\n"); + } else { + p = (TMemBlock *)heap; + while (p) { + PRINTF (" Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size, + p->free ? '.':'U', + p->reserved ? 'R':'.'); + p = p->next; + } + } + PRINTF ("End of memory blocks\n"); +} + +memHeap_t *mmInit(int ofs, + int size) +{ + PMemBlock blocks; + + if (size <= 0) { + return 0; + } + blocks = (TMemBlock *) calloc(1,sizeof(TMemBlock)); + if (blocks) { + blocks->ofs = ofs; + blocks->size = size; + blocks->free = 1; + return (memHeap_t *)blocks; + } else + return 0; +} + +/* Kludgey workaround for existing i810 server. Remove soon. + */ +memHeap_t *mmAddRange( memHeap_t *heap, + int ofs, + int size ) +{ + PMemBlock blocks; + blocks = (TMemBlock *) calloc(2,sizeof(TMemBlock)); + if (blocks) { + blocks[0].size = size; + blocks[0].free = 1; + blocks[0].ofs = ofs; + blocks[0].next = &blocks[1]; + + /* Discontinuity - stops JoinBlock from trying to join non-adjacent + * ranges. + */ + blocks[1].size = 0; + blocks[1].free = 0; + blocks[1].ofs = ofs+size; + blocks[1].next = (PMemBlock) heap; + return (memHeap_t *)blocks; + } + else + return heap; +} + +static TMemBlock* SliceBlock(TMemBlock *p, + int startofs, int size, + int reserved, int alignment) +{ + TMemBlock *newblock; + + /* break left */ + if (startofs > p->ofs) { + newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock)); + newblock->ofs = startofs; + newblock->size = p->size - (startofs - p->ofs); + newblock->free = 1; + newblock->next = p->next; + p->size -= newblock->size; + p->next = newblock; + p = newblock; + } + + /* break right */ + if (size < p->size) { + newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock)); + newblock->ofs = startofs + size; + newblock->size = p->size - size; + newblock->free = 1; + newblock->next = p->next; + p->size = size; + p->next = newblock; + } + + /* p = middle block */ + p->align = alignment; + p->free = 0; + p->reserved = reserved; + return p; +} + +PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch) +{ + int mask,startofs,endofs; + TMemBlock *p; + + if (!heap || align2 < 0 || size <= 0) + return NULL; + mask = (1 << align2)-1; + startofs = 0; + p = (TMemBlock *)heap; + while (p) { + if (ISFREE(p)) { + startofs = (p->ofs + mask) & ~mask; + if ( startofs < startSearch ) { + startofs = startSearch; + } + endofs = startofs+size; + if (endofs <= (p->ofs+p->size)) + break; + } + p = p->next; + } + if (!p) + return NULL; + p = SliceBlock(p,startofs,size,0,mask+1); + p->heap = heap; + return p; +} + +static __inline__ int Join2Blocks(TMemBlock *p) +{ + if (p->free && p->next && p->next->free) { + TMemBlock *q = p->next; + p->size += q->size; + p->next = q->next; + free(q); + return 1; + } + return 0; +} + +int mmFreeMem(PMemBlock b) +{ + TMemBlock *p,*prev; + + if (!b) + return 0; + if (!b->heap) { + fprintf(stderr, "no heap\n"); + return -1; + } + p = b->heap; + prev = NULL; + while (p && p != b) { + prev = p; + p = p->next; + } + if (!p || p->free || p->reserved) { + if (!p) + fprintf(stderr, "block not found in heap\n"); + else if (p->free) + fprintf(stderr, "block already free\n"); + else + fprintf(stderr, "block is reserved\n"); + return -1; + } + p->free = 1; + Join2Blocks(p); + if (prev) + Join2Blocks(prev); + return 0; +} + +int mmReserveMem(memHeap_t *heap, int offset,int size) +{ + int endofs; + TMemBlock *p; + + if (!heap || size <= 0) + return -1; + endofs = offset+size; + p = (TMemBlock *)heap; + while (p && p->ofs <= offset) { + if (ISFREE(p) && endofs <= (p->ofs+p->size)) { + SliceBlock(p,offset,size,1,1); + return 0; + } + p = p->next; + } + return -1; +} + +int mmFreeReserved(memHeap_t *heap, int offset) +{ + TMemBlock *p,*prev; + + if (!heap) + return -1; + p = (TMemBlock *)heap; + prev = NULL; + while (p && p->ofs != offset) { + prev = p; + p = p->next; + } + if (!p || !p->reserved) + return -1; + p->free = 1; + p->reserved = 0; + Join2Blocks(p); + if (prev) + Join2Blocks(prev); + return 0; +} + +void mmDestroy(memHeap_t *heap) +{ + TMemBlock *p,*q; + + if (!heap) + return; + p = (TMemBlock *)heap; + while (p) { + q = p->next; + free(p); + p = q; + } +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h:1.4 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h Tue Sep 26 12:21:25 2000 @@ -0,0 +1,163 @@ +/* sis_ds.h -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#ifndef _sis_ds_h_ +#define _sis_ds_h_ + +/* Set Data Structure */ + +#define SET_SIZE 5000 +#define MALLOC(s) kmalloc(s, GFP_KERNEL) +#define FREE(s) kfree(s) + +typedef unsigned int ITEM_TYPE; + +typedef struct { + ITEM_TYPE val; + int alloc_next, free_next; +} list_item_t; + +typedef struct { + int alloc; + int free; + int trace; + list_item_t list[SET_SIZE]; +} set_t; + +set_t *setInit(void); +int setAdd(set_t *set, ITEM_TYPE item); +int setDel(set_t *set, ITEM_TYPE item); +int setFirst(set_t *set, ITEM_TYPE *item); +int setNext(set_t *set, ITEM_TYPE *item); +int setDestroy(set_t *set); + +#endif + +/* + * GLX Hardware Device Driver common code + * Copyright (C) 1999 Keith Whitwell + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef MM_INC +#define MM_INC + +struct mem_block_t { + struct mem_block_t *next; + struct mem_block_t *heap; + int ofs,size; + int align; + int free:1; + int reserved:1; +}; +typedef struct mem_block_t TMemBlock; +typedef struct mem_block_t *PMemBlock; + +/* a heap is just the first block in a chain */ +typedef struct mem_block_t memHeap_t; + +static __inline__ int mmBlockSize(PMemBlock b) +{ return b->size; } + +static __inline__ int mmOffset(PMemBlock b) +{ return b->ofs; } + +static __inline__ void mmMarkReserved(PMemBlock b) +{ b->reserved = 1; } + +/* + * input: total size in bytes + * return: a heap pointer if OK, NULL if error + */ +memHeap_t *mmInit( int ofs, int size ); + + + +memHeap_t *mmAddRange( memHeap_t *heap, + int ofs, + int size ); + + +/* + * Allocate 'size' bytes with 2^align2 bytes alignment, + * restrict the search to free memory after 'startSearch' + * depth and back buffers should be in different 4mb banks + * to get better page hits if possible + * input: size = size of block + * align2 = 2^align2 bytes alignment + * startSearch = linear offset from start of heap to begin search + * return: pointer to the allocated block, 0 if error + */ +PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch ); + +/* + * Free block starts at offset + * input: pointer to a block + * return: 0 if OK, -1 if error + */ +int mmFreeMem( PMemBlock b ); + +/* + * Reserve 'size' bytes block start at offset + * This is used to prevent allocation of memory already used + * by the X server for the front buffer, pixmaps, and cursor + * input: size, offset + * output: 0 if OK, -1 if error + */ +int mmReserveMem( memHeap_t *heap, int offset,int size ); +int mmFreeReserved( memHeap_t *heap, int offset ); + +/* + * destroy MM + */ +void mmDestroy( memHeap_t *mmInit ); + +/* For debuging purpose. */ +void mmDumpMemInfo( memHeap_t *mmInit ); + +#endif Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c:1.8 --- /dev/null Mon Dec 18 14:31:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c Fri Dec 1 09:29:03 2000 @@ -0,0 +1,305 @@ +/* sis_mm.c -- Private header for Direct Rendering Manager -*- linux-c -*- + * Created: Mon Jan 4 10:05:05 1999 by sclin@sis.com.tw + * + * Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Sung-Ching Lin <sclin@sis.com.tw> + * + */ + +#define __NO_VERSION__ +#include "drmP.h" +#include "sis_drm.h" +#include "sis_ds.h" +#include "sis_drv.h" + +#define MAX_CONTEXT 100 +#define VIDEO_TYPE 0 +#define AGP_TYPE 1 + +typedef struct { + int used; + int context; + set_t *sets[2]; /* 0 for video, 1 for AGP */ +} sis_context_t; + +static sis_context_t global_ppriv[MAX_CONTEXT]; + +static int add_alloc_set(int context, int type, unsigned int val) +{ + int i, retval = 0; + + for(i = 0; i < MAX_CONTEXT; i++) + if(global_ppriv[i].used && global_ppriv[i].context == context){ + retval = setAdd(global_ppriv[i].sets[type], val); + break; + } + return retval; +} + +static int del_alloc_set(int context, int type, unsigned int val) +{ + int i, retval = 0; + for(i = 0; i < MAX_CONTEXT; i++) + if(global_ppriv[i].used && global_ppriv[i].context == context){ + retval = setDel(global_ppriv[i].sets[type], val); + break; + } + return retval; +} + +/* fb management via fb device */ +#if 0 +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t fb; + struct sis_memreq req; + int retval = 0; + + if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb))) + return -EFAULT; + + req.size = fb.size; + sis_malloc(&req); + if(req.offset){ + /* TODO */ + fb.offset = req.offset; + fb.free = req.offset; + if(!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)){ + DRM_DEBUG("adding to allocation set fails"); + sis_free(req.offset); + retval = -1; + } + } + else{ + fb.offset = 0; + fb.size = 0; + fb.free = 0; + } + + if (copy_to_user((drm_sis_mem_t *)arg, &fb, sizeof(fb))) return -EFAULT; + + DRM_DEBUG("alloc fb, size = %d, offset = %ld\n", fb.size, req.offset); + + return retval; +} + +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t fb; + int retval = 0; + + if (copy_from_user(&fb, (drm_sis_mem_t *)arg, sizeof(fb))) + return -EFAULT; + + if(!fb.free){ + return -1; + } + + sis_free(fb.free); + if(!del_alloc_set(fb.context, VIDEO_TYPE, fb.free)) + retval = -1; + + DRM_DEBUG("free fb, offset = %d\n", fb.free); + + return retval; +} + +#else + +int sis_fb_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + return -1; +} + +int sis_fb_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + return 0; +} + +#endif + +/* agp memory management */ +#if 1 + +static memHeap_t *AgpHeap = NULL; + +int sis_agp_init(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_agp_t agp; + + if (copy_from_user(&agp, (drm_sis_agp_t *)arg, sizeof(agp))) + return -EFAULT; + + AgpHeap = mmInit(agp.offset, agp.size); + + DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size); + + return 0; +} + +int sis_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t agp; + PMemBlock block; + int retval = 0; + + if(!AgpHeap) + return -1; + + if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp))) + return -EFAULT; + + block = mmAllocMem(AgpHeap, agp.size, 0, 0); + if(block){ + /* TODO */ + agp.offset = block->ofs; + agp.free = (unsigned int)block; + if(!add_alloc_set(agp.context, AGP_TYPE, agp.free)){ + DRM_DEBUG("adding to allocation set fails"); + mmFreeMem((PMemBlock)agp.free); + retval = -1; + } + } + else{ + agp.offset = 0; + agp.size = 0; + agp.free = 0; + } + + if (copy_to_user((drm_sis_mem_t *)arg, &agp, sizeof(agp))) return -EFAULT; + + DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset); + + return retval; +} + +int sis_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_sis_mem_t agp; + int retval = 0; + + if(!AgpHeap) + return -1; + + if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp))) + return -EFAULT; + + if(!agp.free){ + return -1; + } + + mmFreeMem((PMemBlock)agp.free); + if(!del_alloc_set(agp.context, AGP_TYPE, agp.free)) + retval = -1; + + DRM_DEBUG("free agp, free = %d\n", agp.free); + + return retval; +} + +#endif + +int sis_init_context(int context) +{ + int i; + + for(i = 0; i < MAX_CONTEXT ; i++) + if(global_ppriv[i].used && (global_ppriv[i].context == context)) + break; + + if(i >= MAX_CONTEXT){ + for(i = 0; i < MAX_CONTEXT ; i++){ + if(!global_ppriv[i].used){ + global_ppriv[i].context = context; + global_ppriv[i].used = 1; + global_ppriv[i].sets[0] = setInit(); + global_ppriv[i].sets[1] = setInit(); + DRM_DEBUG("init allocation set, socket=%d, context = %d\n", + i, context); + break; + } + } + if((i >= MAX_CONTEXT) || (global_ppriv[i].sets[0] == NULL) || + (global_ppriv[i].sets[1] == NULL)){ + return 0; + } + } + + return 1; +} + +int sis_final_context(int context) +{ + int i; + + for(i=0; i<MAX_CONTEXT; i++) + if(global_ppriv[i].used && (global_ppriv[i].context == context)) + break; + + if(i < MAX_CONTEXT){ + set_t *set; + unsigned int item; + int retval; + + DRM_DEBUG("find socket %d, context = %d\n", i, context); + + /* Video Memory */ + set = global_ppriv[i].sets[0]; + retval = setFirst(set, &item); + while(retval){ + DRM_DEBUG("free video memory 0x%x\n", item); + sis_free(item); + retval = setNext(set, &item); + } + setDestroy(set); + + /* AGP Memory */ + set = global_ppriv[i].sets[1]; + retval = setFirst(set, &item); + while(retval){ + DRM_DEBUG("free agp memory 0x%x\n", item); + mmFreeMem((PMemBlock)item); + retval = setNext(set, &item); + } + setDestroy(set); + + global_ppriv[i].used = 0; + } + + /* turn-off auto-flip */ + /* TODO */ +#if defined(SIS_STEREO) + flip_final(); +#endif + + return 1; +} Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c:1.3 Fri Jun 16 20:03:39 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c Tue Sep 26 12:21:25 2000 @@ -30,8 +30,6 @@ * */ -#include <linux/sched.h> - #define __NO_VERSION__ #include "drmP.h" #include "tdfx_drv.h" @@ -107,19 +105,21 @@ int i; DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -131,7 +131,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = tdfx_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Skip kernel's context and get a new one. */ ctx.handle = tdfx_alloc_queue(dev); @@ -143,7 +144,8 @@ return -ENOMEM; } - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -152,7 +154,8 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; if (ctx.flags==_DRM_CONTEXT_PRESERVED) tdfx_res_ctx.handle=ctx.handle; return 0; @@ -163,10 +166,12 @@ { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); - /* This is 0, because we don't hanlde any context flags */ + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; + /* This is 0, because we don't handle any context flags */ ctx.flags = 0; - copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -177,7 +182,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return tdfx_context_switch(dev, dev->last_context, ctx.handle); } @@ -189,7 +195,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); tdfx_context_switch_complete(dev, ctx.handle); @@ -203,7 +210,8 @@ drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); drm_ctxbitmap_free(dev, ctx.handle); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c:1.4 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c:1.4 Fri Jun 16 20:03:39 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c Fri Dec 1 09:29:03 2000 @@ -1,4 +1,4 @@ -/* tdfx.c -- tdfx driver -*- linux-c -*- +/* tdfx_drv.c -- tdfx driver -*- linux-c -*- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: * Rickard E. (Rik) Faith <faith@valinux.com> * Daryll Strauss <daryll@valinux.com> @@ -31,15 +31,12 @@ */ #include <linux/config.h> -#define EXPORT_SYMTAB #include "drmP.h" #include "tdfx_drv.h" -EXPORT_SYMBOL(tdfx_init); -EXPORT_SYMBOL(tdfx_cleanup); #define TDFX_NAME "tdfx" -#define TDFX_DESC "tdfx" -#define TDFX_DATE "19991009" +#define TDFX_DESC "3dfx Banshee/Voodoo3+" +#define TDFX_DATE "20000928" #define TDFX_MAJOR 1 #define TDFX_MINOR 0 #define TDFX_PATCHLEVEL 0 @@ -48,6 +45,10 @@ drm_ctx_t tdfx_res_ctx; static struct file_operations tdfx_fops = { +#if LINUX_VERSION_CODE >= 0x020400 + /* This started being used during 2.4.0-test */ + owner: THIS_MODULE, +#endif open: tdfx_open, flush: drm_flush, release: tdfx_release, @@ -75,7 +76,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, - + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { tdfx_addctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { tdfx_rmctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { tdfx_modctx, 1, 1 }, @@ -88,7 +89,7 @@ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { tdfx_lock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { tdfx_unlock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1}, @@ -102,52 +103,32 @@ #define TDFX_IOCTL_COUNT DRM_ARRAY_SIZE(tdfx_ioctls) #ifdef MODULE -int init_module(void); -void cleanup_module(void); static char *tdfx = NULL; +#endif -MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); +MODULE_AUTHOR("VA Linux Systems, Inc."); MODULE_DESCRIPTION("tdfx"); MODULE_PARM(tdfx, "s"); - -/* init_module is called when insmod is used to load the module */ - -int init_module(void) -{ - return tdfx_init(); -} -/* cleanup_module is called when rmmod is used to unload the module */ +#ifndef MODULE +/* tdfx_options is called by the kernel to parse command-line options + * passed via the boot-loader (e.g., LILO). It calls the insmod option + * routine, drm_parse_drm. + */ -void cleanup_module(void) +static int __init tdfx_options(char *str) { - tdfx_cleanup(); -} -#endif - -#ifndef MODULE -/* tdfx_setup is called by the kernel to parse command-line options passed - * via the boot-loader (e.g., LILO). It calls the insmod option routine, - * drm_parse_drm. - * - * This is not currently supported, since it requires changes to - * linux/init/main.c. */ - - -void __init tdfx_setup(char *str, int *ints) -{ - if (ints[0] != 0) { - DRM_ERROR("Illegal command line format, ignored\n"); - return; - } drm_parse_options(str); + return 1; } + +__setup("tdfx=", tdfx_options); #endif static int tdfx_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -189,7 +170,7 @@ dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; @@ -198,15 +179,15 @@ init_waitqueue_head(&dev->buf_writers); tdfx_res_ctx.handle=-1; - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -222,12 +203,12 @@ down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -241,12 +222,12 @@ } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) /* Clear AGP information */ if (dev->agp) { drm_agp_mem_t *temp; drm_agp_mem_t *temp_next; - + temp = dev->agp->memory; while(temp != NULL) { temp_next = temp->next; @@ -254,9 +235,7 @@ drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); temp = temp_next; } - if(dev->agp->acquired) (*drm_agp.release)(); - drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); - dev->agp = NULL; + if (dev->agp->acquired) _drm_agp_release(); } #endif /* Clear vma list (only built for debugging) */ @@ -267,7 +246,7 @@ } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -305,21 +284,21 @@ dev->maplist = NULL; dev->map_count = 0; } - + if (dev->lock.hw_lock) { dev->lock.hw_lock = NULL; /* SHM removed */ dev->lock.pid = 0; wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } /* tdfx_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ -int tdfx_init(void) +static int __init tdfx_init(void) { int retcode; drm_device_t *dev = &tdfx_device; @@ -329,7 +308,7 @@ memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(tdfx); #endif @@ -343,7 +322,7 @@ drm_mem_init(); drm_proc_init(dev); -#ifdef DRM_AGP +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) dev->agp = drm_agp_init(); #endif if((retcode = drm_ctxbitmap_init(dev))) { @@ -361,18 +340,18 @@ TDFX_PATCHLEVEL, TDFX_DATE, tdfx_misc.minor); - + return 0; } /* tdfx_cleanup is called via cleanup_module at module unload time. */ -void tdfx_cleanup(void) +static void __exit tdfx_cleanup(void) { drm_device_t *dev = &tdfx_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&tdfx_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -381,25 +360,37 @@ } drm_ctxbitmap_cleanup(dev); tdfx_takedown(dev); +#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) + if (dev->agp) { + drm_agp_uninit(); + drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); + dev->agp = NULL; + } +#endif } +module_init(tdfx_init); +module_exit(tdfx_cleanup); + + int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = TDFX_MAJOR; @@ -410,10 +401,10 @@ DRM_COPY(version.date, TDFX_DATE); DRM_COPY(version.desc, TDFX_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -421,10 +412,12 @@ { drm_device_t *dev = &tdfx_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_open); spin_lock(&dev->count_lock); if (!dev->open_count++) { @@ -439,12 +432,17 @@ int tdfx_release(struct inode *inode, struct file *filp) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; + drm_device_t *dev; int retcode = 0; + lock_kernel(); + dev = priv->dev; + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_release(inode, filp))) { - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_inc(&dev->total_close); spin_lock(&dev->count_lock); if (!--dev->open_count) { @@ -453,13 +451,17 @@ atomic_read(&dev->ioctl_count), dev->blocked); spin_unlock(&dev->count_lock); + unlock_kernel(); return -EBUSY; } spin_unlock(&dev->count_lock); + unlock_kernel(); return tdfx_takedown(dev); } spin_unlock(&dev->count_lock); } + + unlock_kernel(); return retcode; } @@ -478,7 +480,7 @@ atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -498,7 +500,7 @@ retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -517,7 +519,8 @@ dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -535,7 +538,7 @@ if (lock.context < 0 || lock.context >= dev->queue_count) return -EINVAL; #endif - + if (!ret) { #if 0 if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) @@ -547,7 +550,7 @@ /* Can't take lock if we just had it and there is contention. */ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", - lock.context, current->pid, j, + lock.context, current->pid, j, dev->lock.lock_time, jiffies); current->state = TASK_INTERRUPTIBLE; current->policy |= SCHED_YIELD; @@ -558,6 +561,7 @@ #endif add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -570,10 +574,9 @@ atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; #if 1 current->policy |= SCHED_YIELD; #endif @@ -614,6 +617,15 @@ #endif if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_READY) { /* Wait for space in DMA/FIFO */ } @@ -625,26 +637,18 @@ } } -#if 0 - DRM_ERROR("pid = %5d, old counter = %5ld\n", - current->pid, current->counter); -#endif +#if LINUX_VERSION_CODE < 0x020400 if (lock.context != tdfx_res_ctx.handle) { current->counter = 5; current->priority = DEF_PRIORITY/4; } -#if 0 - while (current->counter > 25) - current->counter >>= 1; /* decrease time slice */ - DRM_ERROR("pid = %5d, new counter = %5ld\n", - current->pid, current->counter); #endif DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); #if DRM_DMA_HISTOGRAM atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); #endif - + return ret; } @@ -656,8 +660,9 @@ drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -678,21 +683,14 @@ DRM_ERROR("\n"); } } - -#if 0 - current->policy |= SCHED_YIELD; - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1000); -#endif +#if LINUX_VERSION_CODE < 0x020400 if (lock.context != tdfx_res_ctx.handle) { current->counter = 5; current->priority = DEF_PRIORITY; } -#if 0 - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(10); #endif - + + unblock_all_signals(); return 0; } Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h:1.3 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h:1.3 Fri Jun 16 20:03:39 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h Tue Sep 26 12:21:26 2000 @@ -25,8 +25,8 @@ * DEALINGS IN THE SOFTWARE. * * Authors: - * Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Daryll Strauss <daryll@precisioninsight.com> + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> * */ @@ -34,8 +34,6 @@ #define _TDFX_DRV_H_ /* tdfx_drv.c */ -extern int tdfx_init(void); -extern void tdfx_cleanup(void); extern int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int tdfx_open(struct inode *inode, struct file *filp); Index: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c:1.6 xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c:1.6 Fri Jun 16 20:03:39 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c Wed Nov 8 00:03:07 2000 @@ -44,6 +44,12 @@ close: drm_vm_close, }; +struct vm_operations_struct drm_vm_shm_lock_ops = { + nopage: drm_vm_shm_nopage_lock, + open: drm_vm_open, + close: drm_vm_close, +}; + struct vm_operations_struct drm_vm_dma_ops = { nopage: drm_vm_dma_nopage, open: drm_vm_open, @@ -61,8 +67,6 @@ int write_access) #endif { - DRM_DEBUG("0x%08lx, %d\n", address, write_access); - return NOPAGE_SIGBUS; /* Disallow mremap */ } @@ -77,6 +81,40 @@ int write_access) #endif { +#if LINUX_VERSION_CODE >= 0x020300 + drm_map_t *map = (drm_map_t *)vma->vm_private_data; +#else + drm_map_t *map = (drm_map_t *)vma->vm_pte; +#endif + unsigned long physical; + unsigned long offset; + + if (address > vma->vm_end) return NOPAGE_SIGBUS; /* Disallow mremap */ + if (!map) return NOPAGE_OOM; /* Nothing allocated */ + + offset = address - vma->vm_start; + physical = (unsigned long)map->handle + offset; + atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */ + + DRM_DEBUG("0x%08lx => 0x%08lx\n", address, physical); +#if LINUX_VERSION_CODE < 0x020317 + return physical; +#else + return virt_to_page(physical); +#endif +} + +#if LINUX_VERSION_CODE < 0x020317 +unsigned long drm_vm_shm_nopage_lock(struct vm_area_struct *vma, + unsigned long address, + int write_access) +#else + /* Return type changed in 2.3.23 */ +struct page *drm_vm_shm_nopage_lock(struct vm_area_struct *vma, + unsigned long address, + int write_access) +#endif +{ drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->dev; unsigned long physical; @@ -88,14 +126,14 @@ offset = address - vma->vm_start; page = offset >> PAGE_SHIFT; - physical = (unsigned long)dev->lock.hw_lock + (offset & (~PAGE_MASK)); - atomic_inc(&mem_map[MAP_NR(physical)].count); /* Dec. by kernel */ + physical = (unsigned long)dev->lock.hw_lock + offset; + atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */ DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical); #if LINUX_VERSION_CODE < 0x020317 return physical; #else - return mem_map + MAP_NR(physical); + return virt_to_page(physical); #endif } @@ -124,13 +162,13 @@ offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ page = offset >> PAGE_SHIFT; physical = dma->pagelist[page] + (offset & (~PAGE_MASK)); - atomic_inc(&mem_map[MAP_NR(physical)].count); /* Dec. by kernel */ + atomic_inc(&virt_to_page(physical)->count); /* Dec. by kernel */ DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", address, page, physical); #if LINUX_VERSION_CODE < 0x020317 return physical; #else - return mem_map + MAP_NR(physical); + return virt_to_page(physical); #endif } @@ -145,7 +183,11 @@ DRM_DEBUG("0x%08lx,0x%08lx\n", vma->vm_start, vma->vm_end - vma->vm_start); atomic_inc(&dev->vma_count); - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + /* The map can exist after the fd is closed. */ + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif + #if DRM_DEBUG_CODE vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); @@ -170,7 +212,9 @@ DRM_DEBUG("0x%08lx,0x%08lx\n", vma->vm_start, vma->vm_end - vma->vm_start); - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_dec(&dev->vma_count); #if DRM_DEBUG_CODE @@ -193,15 +237,22 @@ int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; + drm_device_t *dev; + drm_device_dma_t *dma; unsigned long length = vma->vm_end - vma->vm_start; + lock_kernel(); + dev = priv->dev; + dma = dev->dma; DRM_DEBUG("start = 0x%lx, end = 0x%lx, offset = 0x%lx\n", vma->vm_start, vma->vm_end, VM_OFFSET(vma)); /* Length must match exact page count */ - if ((length >> PAGE_SHIFT) != dma->page_count) return -EINVAL; + if (!dma || (length >> PAGE_SHIFT) != dma->page_count) { + unlock_kernel(); + return -EINVAL; + } + unlock_kernel(); vma->vm_ops = &drm_vm_dma_ops; vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */ @@ -270,6 +321,9 @@ pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT; } +#elif defined(__ia64__) + if (map->type != _DRM_AGP) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); #endif vma->vm_flags |= VM_IO; /* not in core dump */ } @@ -285,7 +339,17 @@ vma->vm_ops = &drm_vm_ops; break; case _DRM_SHM: - vma->vm_ops = &drm_vm_shm_ops; + if (map->flags & _DRM_CONTAINS_LOCK) + vma->vm_ops = &drm_vm_shm_lock_ops; + else { + vma->vm_ops = &drm_vm_shm_ops; +#if LINUX_VERSION_CODE >= 0x020300 + vma->vm_private_data = (void *)map; +#else + vma->vm_pte = (unsigned long)map; +#endif + } + /* Don't let this area swap. Change when DRM_KERNEL advisory is supported. */ vma->vm_flags |= VM_LOCKED; Index: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile:1.10 xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile:1.12 --- xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile:1.10 Fri Mar 31 17:55:54 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile Sat Dec 2 10:31:01 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile,v 1.10 2000/03/31 22:55:54 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile,v 1.12 2000/12/02 15:31:01 tsi Exp $ #define IHaveModules @@ -29,7 +29,7 @@ #define X86EMU_LIBPATH /usr/local/lib #endif -#if defined(i386Architecture) +#if defined(i386Architecture) || defined(ia64Architecture) DEFINES =-D_PC #endif @@ -91,6 +91,7 @@ #if defined(XF86INT10_BUILD) && XF86INT10_BUILD > X86EMU_GENERIC +ModuleObjectRule() LibraryModuleTarget(int10, $(OBJS)) InstallLibraryModule(int10,$(MODULEDIR),linux) Index: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c diff -u xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c:1.11 xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c:1.19 --- xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c:1.11 Wed May 31 03:15:10 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c Wed Dec 6 10:35:31 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.11 2000/05/31 07:15:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.19 2000/12/06 15:35:31 eich Exp $ */ /* * linux specific part of the int10 module * Copyright 1999 Egbert Eich @@ -12,7 +12,11 @@ #define _INT10_PRIVATE #include "xf86int10.h" #include "int10Defines.h" +#ifdef __sparc__ +#define DEV_MEM "/dev/fb" +#else #define DEV_MEM "/dev/mem" +#endif #ifndef XFree86LOADER #include <sys/mman.h> #ifndef MAP_FAILED @@ -53,6 +57,7 @@ xf86InitInt10(int entityIndex) { xf86Int10InfoPtr pInt = NULL; + CARD8 *bios_base; int screen; int fd; static void* vidMem = NULL; @@ -61,9 +66,9 @@ int high_mem; char *base; char *base_high; - int pagesize; + int pagesize, cs; legacyVGARec vga; - + screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; if (int10skip(xf86Screens[screen],entityIndex)) return NULL; @@ -113,14 +118,18 @@ pInt->private = (pointer)xnfcalloc(1,sizeof(linuxInt10Priv)); ((linuxInt10Priv*)pInt->private)->screen = screen; ((linuxInt10Priv*)pInt->private)->alloc = - (pointer)xnfcalloc(1,sizeof(ALLOC_ENTRIES(pagesize))); + (pointer)xnfcalloc(1,ALLOC_ENTRIES(pagesize)); #ifdef DEBUG ErrorF("Mapping high memory area\n"); #endif if ((high_mem = shmget(counter++, HIGH_MEM_SIZE, - IPC_CREAT | SHM_R | SHM_W)) == -1) + IPC_CREAT | SHM_R | SHM_W)) == -1) { + if (errno == ENOSYS) + xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure" + " your kernel to include System V IPC support\n"); goto error1; + } ((linuxInt10Priv*)pInt->private)->highMem = high_mem; #ifdef DEBUG ErrorF("Mapping 640kB area\n"); @@ -146,24 +155,28 @@ goto error3; } -#ifdef DEBUG - dprint(0,0x20); - dprint(0xa0000,0x20); - dprint(0xf0000,0x20); -#endif + /* + * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes + * have executable code there. Note that xf86ReadBIOS() can only bring in + * 64K bytes at a time. + */ + (void)memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS); + for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) + if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE) + xf86DrvMsg(screen, X_WARNING, + "Unable to retrieve all of segment 0x%06X.\n", cs); if (xf86IsEntityPrimary(entityIndex)) { - int size; - int cs = ((CARD16*)0)[(0x10<<1)+1]; - CARD8 *bios_base = (unsigned char *)(cs << 4); + cs = ((CARD16*)0)[(0x10<<1)+1]; + bios_base = (unsigned char *)(cs << 4); - if (!int10_read_bios(screen,cs,bios_base)) { - int cs = ((CARD16*)0)[(0x42<<1)+1]; + if (!int10_check_bios(screen, cs, bios_base)) { + cs = ((CARD16*)0)[(0x42<<1)+1]; bios_base = (unsigned char *)(cs << 4); - if (!int10_read_bios(screen,cs,bios_base)) { + if (!int10_check_bios(screen, cs, bios_base)) { cs = V_BIOS >> 4; bios_base = (unsigned char *)(cs << 4); - if (!int10_read_bios(screen,cs,bios_base)) { + if (!int10_check_bios(screen, cs, bios_base)) { xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n"); goto error3; } @@ -354,9 +367,19 @@ static int do_vm86(xf86Int10InfoPtr pInt) { - int retval; + int retval, signo; + xf86InterceptSignals(&signo); retval = vm86_rep(VM86S); + xf86InterceptSignals(NULL); + + if (signo >= 0) { + xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86() syscall generated signal %d.\n", signo); + dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); + return 0; + } switch (VM86_TYPE(retval)) { case VM86_UNKNOWN: @@ -364,8 +387,9 @@ break; case VM86_STI: xf86DrvMsg(pInt->scrnIndex,X_ERROR,"vm86_sti :-((\n"); - stack_trace(pInt); + dump_registers(pInt); dump_code(pInt); + stack_trace(pInt); return 0; case VM86_INTx: pInt->num = VM86_ARG(retval); @@ -373,6 +397,8 @@ xf86DrvMsg(pInt->scrnIndex, X_ERROR,"Unknown vm86_int: 0x%X\n\n",VM86_ARG(retval)); dump_registers(pInt); + dump_code(pInt); + stack_trace(pInt); return 0; } /* I'm not sure yet what to do if we can handle ints */ @@ -400,12 +426,12 @@ void xf86ExecX86int10(xf86Int10InfoPtr pInt) { - setup_int(pInt); + int sig = setup_int(pInt); if (int_handler(pInt)) while(do_vm86(pInt)) {}; - finish_int(pInt); + finish_int(pInt,sig); } static int Index: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile:3.20 xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile:3.21 --- xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile:3.20 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile Tue Aug 15 12:05:38 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v 3.20 2000/06/27 14:27:30 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v 3.21 2000/08/15 16:05:38 dawes Exp $ #include <Server.tmpl> #if !defined(PpcArchitecture) @@ -20,12 +20,12 @@ SRCS = lynx_init.c lynx_video.c lynx_io.c lynx_mmap.c \ VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \ $(IOPERM_SRCS) $(PPC_SRCS) libc_wrapper.c stdResource.c stdPci.c \ - vidmem.c sigio.c pm_noop.c kmod_noop.c + vidmem.c sigio.c pm_noop.c kmod_noop.c agp_noop.c OBJS = lynx_init.o lynx_video.o lynx_io.o lynx_mmap.o \ VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \ $(IOPERM_OBJS) $(PPC_OBJS) libc_wrapper.o stdResource.o stdPci.o \ - vidmem.o sigio.o pm_noop.o kmod_noop.o + vidmem.o sigio.o pm_noop.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) @@ -50,5 +50,6 @@ LinkSourceFile(sigio.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c diff -u xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c:3.4 xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c:3.5 --- xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c:3.4 Sat Aug 29 01:43:58 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c Mon Jul 31 19:25:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c,v 3.4 1998/08/29 05:43:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c,v 3.5 2000/07/31 23:25:18 tsi Exp $ */ /* * Copyright 1998 by Metro Link Incorporated * @@ -79,7 +79,7 @@ } void -outl(unsigned short port, unsigned long value) +outl(unsigned short port, unsigned int value) { stl_brx(value, ioBase, port); eieio(); } @@ -102,10 +102,10 @@ return(val); } -unsigned long +unsigned int inl(unsigned short port) { - unsigned long val; + unsigned int val; val = ldl_brx(ioBase, port); eieio(); return(val); Index: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c:3.16 xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c:3.17 --- xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c:3.16 Mon Apr 17 12:30:13 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c Fri Oct 27 21:42:27 2000 @@ -21,7 +21,7 @@ * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.16 2000/04/17 16:30:13 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.17 2000/10/28 01:42:27 mvojkovi Exp $ */ #include "X.h" #include "input.h" @@ -91,7 +91,7 @@ } static pointer -MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { static int once; int free_slot = -1; Index: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile:3.3 xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile:removed --- xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile:3.3 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile Mon Dec 18 14:31:56 2000 @@ -1,35 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile,v 3.3 2000/06/27 14:27:30 tsi Exp $ - - - - -XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:58 rws $ - -#include <Server.tmpl> - -#if defined(OsfArchitecture) -BIOS_MOD = bios_devmem -#else -BIOS_MOD = bios_mmap -#endif - -SRCS = mach_init.c mach_video.c mach_io.c $(BIOS_MOD).c \ - VTsw_noop.c kmod_noop.c - -OBJS = mach_init.o mach_video.o mach_io.o $(BIOS_MOD).o \ - VTsw_noop.o kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() - -#if defined(OsfArchitecture) -ObjectFromSpecialSource(bios_devmem,../shared/bios_devmem,/**/) -#endif -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) - -DependTarget() - Index: xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c diff -u xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c:3.4 xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c:3.4 Mon Dec 23 01:50:10 1996 +++ xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c Mon Dec 18 14:31:56 2000 @@ -1,76 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/bios_mmap.c,v 3.4 1996/12/23 06:50:10 dawes Exp $ */ -/* - * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Robert Baron and David Wexelblat not - * be used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Robert Baron and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * ROBERT BARON AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL ROBERT BARON OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: bios_mmap.c /main/4 1996/02/21 17:51:47 kaleb $ */ - -#include "X.h" -#include "misc.h" - -#define DevicePtr int -#include "xf86_OSlib.h" - -#define BIOS_SIZE 0x20000 -#define KERN_SUCCESS 0 - -int xf86ReadBIOS(Base, Offset, Buf, Len) -unsigned long Base; -unsigned long Offset; -unsigned char *Buf; -int Len; -{ - int fd; - int screen_addr; - int ret; - - if ((fd = open("/dev/iopl", O_RDWR, 0)) < 0) - { - ErrorF("xf86ReadBIOS: Failed to open /dev/iopl\n"); - return(-1); - } - if (KERN_SUCCESS != vm_allocate(task_self(), &screen_addr, - BIOS_SIZE, TRUE)) - { - ErrorF("xf86ReadBIOS: Failed vmallocate %x\n", BIOS_SIZE); - close(fd); - return(-1); - } - if (mmap(screen_addr, BIOS_SIZE, 3, 1, fd, Base) < 0) - { - ErrorF("xf86ReadBIOS: Failed to mmap %x at %x\n", - BIOS_SIZE, Base); - vm_deallocate(task_self(), screen_addr, BIOS_SIZE); - close(fd); - return(-1); - } - memcpy(Buf, (unsigned char *)(screen_addr + Offset), Len); - if (KERN_SUCCESS != vm_deallocate(task_self(), screen_addr, BIOS_SIZE)) - { - ErrorF("xf86ReadBIOS: Failed vmdeallocate %x\n", BIOS_SIZE); - close(fd); - return(-1); - } - close(fd); - return(Len); -} Index: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c:3.5 xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c:3.5 Sat Jul 25 12:56:46 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c Mon Dec 18 14:31:56 2000 @@ -1,70 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_init.c,v 3.5 1998/07/25 16:56:46 dawes Exp $ */ -/* - * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Robert Baron and David Wexelblat not - * be used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Robert Baron and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * ROBERT BARON AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL ROBERT BARON OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mach_init.c /main/4 1996/02/21 17:51:50 kaleb $ */ - -#include "X.h" -#include "Xmd.h" -#include "input.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -void xf86OpenConsole() -{ - if (serverGeneration == 1) - { - if ((xf86Info.consoleFd = open("/dev/console",O_RDWR,0)) < 0) - { - FatalError("xf86OpenConsole: Can't open /dev/console (%s)\n", - strerror(errno)); - } - return; - } -} - -void xf86CloseConsole() -{ - close(xf86Info.consoleFd); - return; -} - -/* ARGSUSED */ -int xf86ProcessArgument (argc, argv, i) -int argc; -char *argv[]; -int i; -{ - return(0); -} - -void xf86UseMsg() -{ - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c:3.7 xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c:3.7 Thu May 6 22:56:21 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c Mon Dec 18 14:31:56 2000 @@ -1,289 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_io.c,v 3.7 1999/05/07 02:56:21 dawes Exp $ */ -/* - * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> - * Copyright 1993 by David Dawes <dawes@xfree86.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Robert Baron and David Dawes not - * be used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Robert Baron and - * David Dawes make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * ROBERT BARON AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL ROBERT BARON OR DAVID DAWES BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mach_io.c /main/8 1996/10/19 18:06:45 kaleb $ */ - -#define NEED_EVENTS -#include "X.h" -#include "Xproto.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -Bool xf86SupportedMouseTypes[] = -{ - TRUE, /* Microsoft */ - FALSE, /* MouseSystems */ - FALSE, /* MMSeries */ - TRUE, /* Logitech */ - FALSE, /* BusMouse */ - FALSE, /* MouseMan */ - TRUE, /* PS/2 */ - FALSE, /* Hitachi Tablet */ -}; - -int xf86NumMouseTypes = sizeof(xf86SupportedMouseTypes) / - sizeof(xf86SupportedMouseTypes[0]); - -unsigned short xf86MouseCflags[] = -{ - /* - * MicroSoft mouse needs 7bit characters. - * See special seven_bit_hack code in com.c:comparam() - * in the kernel code. Basically we use the - * special code RAW | PASS8 to mean the mythical - * "PASS7". - */ - -1, /* MicroSoft */ - RAW, /* MouseSystems */ - RAW, /* MMSeries */ - RAW | EVENP | ODDP, /* Logitech */ - 0, /* BusMouse */ - -1, /* ??? MouseMan [CHRIS-211092] */ - 0, /* PS/2 */ - RAW, /* Hitachi Tablet */ -}; - -void xf86SoundKbdBell(loudness, pitch, duration) -int loudness; -int pitch; -int duration; -{ - if (loudness) - { -#ifdef __OSF__ - ioctl(xf86Info.consoleFd, KIOCSOUND, 1); - usleep(duration * loudness * 20); - ioctl(xf86Info.consoleFd, KIOCSOUND, 0); -#else - int i = KD_BELLON; - ioctl(xf86Info.consoleFd, KDSETBELL, &i); - usleep(duration * loudness * 20); - i = KD_BELLOFF; - ioctl(xf86Info.consoleFd, KDSETBELL, &i); -#endif - } -} - -void xf86SetKbdLeds(leds) -int leds; -{ -#ifdef __OSF__ - ioctl(xf86Info.kbdFd, KDSETLED, &leds); -#endif -} - -int xf86GetKbdLeds() -{ -#ifdef __OSF__ - int leds; - - ioctl(xf86Info.kbdFd, KDGETLED, &leds); - return(leds); -#else - return(0); -#endif -} - -#if NeedFunctionPrototypes -void xf86SetKbdRepeat(char rad) -#else -void xf86SetKbdRepeat(rad) -char rad; -#endif -{ - return; -} - -void xf86KbdInit() -{ - return; -} - -int xf86KbdOn() -{ - int data = KB_EVENT; - - if ((xf86Info.kbdFd = open ("/dev/kbd", O_RDONLY)) < 0) - FatalError("can't open /dev/kbd (%s)", strerror(errno)); - - /* Set the keyboard into non-blocking event mode. */ - if (ioctl(xf86Info.kbdFd, KDSKBDMODE, &data) < 0) - FatalError("Cannot set event mode on keyboard (%s)\n", - strerror(errno)); - data = 1; - if (ioctl (xf86Info.kbdFd, FIONBIO, &data) < 0) - FatalError("Cannot keyboard non-blocking (%s)\n", - strerror(errno)); - return(xf86Info.kbdFd); -} - -int xf86KbdOff() -{ - int data = KB_ASCII; - - if (ioctl(xf86Info.kbdFd, KDSKBDMODE, &data) < 0) - FatalError("can't reset keyboard mode (%s)\n", - strerror(errno)); - return(xf86Info.kbdFd); -} - -void xf86KbdEvents() -{ - kd_event ke; - - /* This loop assumes non-blocking keyboard IO. */ - while (read (xf86Info.kbdFd, &ke, sizeof(ke)) == sizeof(ke)) - { - xf86PostKbdEvent(ke.value.sc); - } -} - -void xf86SetMouseSpeed(mouse, old, new, cflag) -MouseDevPtr mouse; -int old; -int new; -unsigned cflag; -{ - return; -} - -void xf86MouseInit(mouse) -MouseDevPtr mouse; -{ - return; -} - -int xf86MouseOn(mouse) -MouseDevPtr mouse; -{ - if ((mouse->mseFd = open(mouse->mseDevice, O_RDONLY, 0)) < 0) - { - if (xf86Info.allowMouseOpenFail) { - ErrorF("Cannot open mouse (%s) - Continuing...\n", - strerror(errno)); - return(-2); - } - FatalError("Cannot open mouse (%s)\n", strerror(errno)); - } - if (fcntl(mouse->mseFd, F_SETFL, FNDELAY | FASYNC) < 0) - { - if (xf86AllowMouseOpenFail) { - ErrorF("Cannot set up mouse (%s) - Continuing...\n", - strerror(errno)); - return(-2); - } - FatalError("Cannot set up mouse (%s)\n", strerror(errno)); - } - - xf86SetupMouse(mouse); - - { - int data = 1; - - if (ioctl (mouse->mseFd, FIONBIO, &data) < 0) - { - if (xf86AllowMouseOpenFail) { - ErrorF("Cannot set mouse non-blocking (%s) - Continuing...\n", - strerror(errno)); - return(-2); - } - FatalError( - "Cannot set mouse non-blocking (%s)\n", - strerror(errno)); - } - } - return(mouse->mseFd); -} - -int xf86MouseOff(mouse, doclose) -MouseDevPtr mouse; -Bool doclose; -{ - close(mouse->mseFd); - return(mouse->mseFd); -} - -#define EVENT_LIST_SIZE 32 - -void xf86MouseEvents(device) -DeviceIntPtr device; -{ - int total, buttons, dx, dy; - static kd_event eventList[EVENT_LIST_SIZE]; - kd_event *event; - - total = read(mouse->mseFd, eventList, sizeof(eventList)); - if (total < 0) - { - if (errno != EWOULDBLOCK) - { - if (xf86AllowMouseOpenFail) { - ErrorF("Cannot read from mouse (%s) - Continuing...\n", - strerror(errno)); - return(-2); - } - FatalError("Cannot read from mouse (%s)\n", - strerror(errno)); - } - return; - } - - total /= sizeof(kd_event); - event = eventList; - while (total--) - { - buttons = mouse->lastButtons; - dx = dy = 0; - - switch (event->type) - { - case MOUSE_RIGHT: - buttons = mouse->lastButtons & 6 | - (event->value.up ? 0 : 1); - break; - case MOUSE_MIDDLE: - buttons = mouse->lastButtons & 5 | - (event->value.up ? 0 : 2); - break; - case MOUSE_LEFT: - buttons = mouse->lastButtons & 3 | - (event->value.up ? 0 : 4); - break; - case MOUSE_MOTION: - dx = event->value.m_deltaX; - dy = - event->value.m_deltaY; - break; - default: - ErrorF("Bad mouse event\n"); - break; - } - xf86PostMseEvent(device, buttons, dx, dy); - ++event; - } -} Index: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c:3.2 xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c:3.2 Tue Aug 26 06:01:37 1997 +++ xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c Mon Dec 18 14:31:56 2000 @@ -1,195 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/mach_video.c,v 3.2 1997/08/26 10:01:37 hohndel Exp $ */ -/* - * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> - * Copyright 1993 by David Wexelblat <dwex@XFree86.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Robert Baron and David Wexelblat not - * be used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Robert Baron and - * David Wexelblat make no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * ROBERT BARON AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL ROBERT BARON OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mach_video.c /main/3 1996/02/21 17:51:57 kaleb $ */ - -#include "X.h" -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -#define KERN_SUCCESS 0 - -pointer xf86MapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - pointer base; - int fd; - - if ((fd = open("/dev/iopl", O_RDWR, 0)) < 0) - { - FatalError("xf86MapVidMem: Failed to get IOPL\n"); - } - if (KERN_SUCCESS != vm_allocate(task_self(), &base, Size, TRUE)) - { - FatalError("xf86MapVidMem: can't alloc framebuffer space\n"); - } - - if (mmap(base, Size, 3, 1, fd, Base) < 0) - { - vm_deallocate(task_self(), base, Size); - close(fd); - FatalError("xf86MapVidMem: Could not mmap frambuffer\n"); - } - close(fd); - return(base); -} - -void xf86UnMapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - if (KERN_SUCCESS != vm_deallocate(task_self(), Base, Size)) - { - ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space\n"); - } -} - -Bool xf86LinearVidMem() -{ - return(TRUE); -} - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -/* - * Mach disables I/O permissions completely, and OSF/1 doesn't bother - * with I/O permissions right now. - */ - -#ifdef MACH386 -static int ioplfd = -1; -static Bool ScreenEnabled[MAXSCREENS]; -static Bool IOEnabled = FALSE; -static Bool InitDone = FALSE; -#endif - - -void xf86EnableIOPorts(ScreenNum) -int ScreenNum; -{ -#ifdef MACH386 - int i; - - if (!InitDone) - { - for (i = 0; i < MAXSCREENS; i++) - ScreenEnabled[i] = FALSE; - InitDone = TRUE; - } - ScreenEnabled[ScreenNum] = TRUE; - - if (IOEnabled) - return; - - if ((ioplfd = open("/dev/iopl", 0)) < 0) - FatalError("xf86EnablePortIO: Failed to get IOPL for I/O\n"); - IOEnabled = TRUE; -#endif /* MACH386 */ - return; -} - -void xf86DisableIOPorts(ScreenNum) -int ScreenNum; -{ -#ifdef MACH386 - int i; - - ScreenEnabled[ScreenNum] = FALSE; - - if (!IOEnabled) - return; - - for (i = 0; i < MAXSCREENS; i++) - if (ScreenEnabled[i]) - return; - close(ioplfd); - ioplfd = -1; - IOEnabled = FALSE; -#endif /* MACH386 */ - return; -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -static Bool Mach30() -{ -#ifdef MACH386 - if (syscall(-27) != 4) - { - return(TRUE); - } - else - { - return(FALSE); - } -#else /* MACH386 */ - return(FALSE); -#endif /* MACH386 */ -} - -Bool xf86DisableInterrupts() -{ - if (Mach30()) - { - ErrorF("Mach 3.0 does not allow interrupts to be disabled\n"); - return(FALSE); - } -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - return(TRUE); -} - -void xf86EnableInterrupts() -{ -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - return; -} - Index: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile:3.6 xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile:3.6 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile Mon Dec 18 14:31:57 2000 @@ -1,29 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile,v 3.6 2000/06/27 14:27:30 tsi Exp $ - - - - - -XCOMM $XConsortium: Imakefile /main/5 1996/09/28 17:24:04 rws $ - -#include <Server.tmpl> - -SRCS = mnx_init.c mnx_video.c mnx_io.c bios_devmem.c \ - ioperm_noop.c VTsw_noop.c std_mouse.c posix_tty.c kmod_noop.c - -OBJS = mnx_init.o mnx_video.o mnx_io.o bios_devmem.o \ - ioperm_noop.o VTsw_noop.o posix_tty.o kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() -NormalAsmObjectRule() - -ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/) -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) - -DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c:3.2 xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c:3.2 Mon Dec 23 01:50:16 1996 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c Mon Dec 18 14:31:57 2000 @@ -1,78 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/bios_devmem.c,v 3.2 1996/12/23 06:50:16 dawes Exp $ */ -/* - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of David Wexelblat not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. David Wexelblat makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: bios_devmem.c /main/4 1996/02/21 17:52:05 kaleb $ */ - -#include "X.h" -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* - * Read BIOS via /dev/mem. - */ - -#ifndef DEV_MEM -# define DEV_MEM "/dev/mem" -#endif - -int xf86ReadBIOS(Base, Offset, Buf, Len) -unsigned long Base; -unsigned long Offset; -unsigned char *Buf; -int Len; -{ - int fd; - uid_t real_uid; - - real_uid= getuid(); - - setuid(0); - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) - { - ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM, - strerror(errno)); - setuid(real_uid); - return(-1); - } - setuid(real_uid); - if (lseek(fd, (Base+Offset), SEEK_SET) < 0) - { - ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM, - strerror(errno)); - close(fd); - return(-1); - } - if (read(fd, Buf, Len) != Len) - { - ErrorF("xf86ReadBios: %s read failed (%s)\n", DEV_MEM, - strerror(errno)); - close(fd); - return(-1); - } - close(fd); - return(Len); -} Index: xc/programs/Xserver/hw/xfree86/os-support/minix/local.h diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/local.h:3.2 xc/programs/Xserver/hw/xfree86/os-support/minix/local.h:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/local.h:3.2 Mon Dec 23 01:50:17 1996 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/local.h Mon Dec 18 14:31:57 2000 @@ -1,13 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/local.h,v 3.2 1996/12/23 06:50:17 dawes Exp $ */ - -/* -local.h - -Local definitions for the minix os libary - -Created: 19 April, 1994 by Philip Homburg <philip@cs.vu.nl> -*/ -/* $XConsortium: local.h /main/4 1996/02/21 17:52:08 kaleb $ */ - -extern char *xf86VideoBaseRaw; -extern char *xf86VideoBase; Index: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c:3.7 xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c:3.7 Sat Jul 25 12:56:47 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c Mon Dec 18 14:31:57 2000 @@ -1,110 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_init.c,v 3.7 1998/07/25 16:56:47 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of The Vrije Universiteit and David - * Wexelblat not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Wexelblat make no representations about - * the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mnx_init.c /main/5 1996/02/21 17:52:12 kaleb $ */ - -#include "X.h" -#include "Xmd.h" -#include "input.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "local.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#define VIDEO_SIZE 0x20000 -#define VIDEO_ALIGN 0x1000 - -char *xf86VideoBaseRaw= NULL; -char *xf86VideoBase= NULL; - -void xf86OpenConsole() -{ - int fd, r, align_diff; - struct mio_map mio_map; - uid_t real_uid; - - if (serverGeneration == 1) - { - real_uid= getuid(); - - /* check if we're run with euid==0 */ - if (setuid(0) != 0) - { - FatalError("xf86OpenConsole: Server must be suid root\n"); - } - fd = open("/dev/vga", O_RDWR); - if (fd == -1) - { - FatalError("xf86OpenConsole: Can't open /dev/vga: %s\n", - strerror(errno)); - } - setuid(real_uid); - - xf86VideoBaseRaw = (char *)xalloc(VIDEO_SIZE+VIDEO_ALIGN); - if (xf86VideoBaseRaw == 0) - { - FatalError("xf86OpenConsole: Out of memory\n"); - } - align_diff = (int)xf86VideoBaseRaw; - align_diff = VIDEO_ALIGN-(((align_diff-1) & (VIDEO_ALIGN-1))+1); - assert(align_diff >= 0 && align_diff < VIDEO_ALIGN); - xf86VideoBase = xf86VideoBaseRaw + align_diff; - mio_map.mm_base = (u32_t)xf86VideoBase; - mio_map.mm_size = VIDEO_SIZE; - r = ioctl(fd, MIOCMAP, &mio_map); - if (r == -1) - { - FatalError("xf86OpenConsole: MIOCMAP failed: %s\n", - strerror(errno)); - } - } - return; -} - -void xf86CloseConsole() -{ - xfree(xf86VideoBaseRaw); - xf86VideoBaseRaw = NULL; /* not needed? */ - return; -} - -/* ARGSUSED */ -int xf86ProcessArgument (argc, argv, i) -int argc; -char *argv[]; -int i; -{ - return(0); -} - -void xf86UseMsg() -{ - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c:3.12 xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c:3.12 Thu May 6 22:56:21 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c Mon Dec 18 14:31:57 2000 @@ -1,277 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_io.c,v 3.12 1999/05/07 02:56:21 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Dawes <dawes@xfree86.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the Vrije Universiteit and David - * Dawes not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Dawes make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID DAWES BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mnx_io.c /main/10 1996/10/19 18:07:03 kaleb $ */ - -#define NEED_EVENTS -#include "X.h" -#include "Xproto.h" -#include "inputstr.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86Config.h" - -#include <sys/nbio.h> - -void xf86SoundKbdBell(loudness, pitch, duration) -int loudness; -int pitch; -int duration; -{ - kio_bell_t kio_bell; - int r; - - kio_bell.kb_pitch = pitch; - kio_bell.kb_volume = 1000000 / 100 * loudness; - kio_bell.kb_duration.tv_sec = duration / 1000; - kio_bell.kb_duration.tv_usec = (duration % 1000) * 1000; - r = ioctl(xf86Info.kbdFd, KIOCBELL, &kio_bell); - if (r != 0) - { - ErrorF("(warning) unable to ring keyboard bell: %s\n", - strerror(errno)); - } -} - -void xf86SetKbdLeds(leds) -int leds; -{ - kio_leds_t kio_leds; - int r; - - kio_leds.kl_bits= leds; - r = ioctl(xf86Info.kbdFd, KIOCSLEDS, &kio_leds); - if (r != 0) - { - ErrorF("(warning) unable to set keyboard leds: %s\n", - strerror(errno)); - } -} - -int xf86GetKbdLeds() -{ - return(0); -} - -#if NeedFunctionPrototypes -void xf86SetKbdRepeat(char rad) -#else -void xf86SetKbdRepeat(rad) -char rad; -#endif -{ - return; -} - -void xf86KbdInit() -{ - static int kbd_fd = -1; - int flags, r; - uid_t real_uid; - - real_uid= getuid(); - - /* Open the keyboard device if not already done so */ - if (kbd_fd < 0) - { - setuid(0); - kbd_fd = open("/dev/kbd", O_RDONLY); - if (kbd_fd == -1) - FatalError("Unable to open keyboard\n"); - else - xf86Info.kbdFd = kbd_fd; - setuid(real_uid); - - /* Mark the keyboard as asynchronous */ - flags= fcntl(xf86Info.kbdFd, F_GETFD); - if (flags == -1) - FatalError("Unable to get keyboard flags\n"); - r = fcntl(xf86Info.kbdFd, F_SETFD, flags | FD_ASYNCHIO); - if (r == -1) - FatalError("Unable to set keyboard flags\n"); - - nbio_register(kbd_fd); - } -} - -int xf86KbdOn() -{ - char waste[16]; - int r; - - /* Get rid of old data */ - for (;;) - { - r = nbio_read(xf86Info.kbdFd, waste, sizeof(waste)); - if (r > 0) - continue; - if (r == -1 && errno == EAGAIN) - break; - FatalError("unable to read from keyboard (%s)\n", - strerror(errno)); - } - return(xf86Info.kbdFd); -} - -int xf86KbdOff() -{ - /* Should RemoveEnabledDevice() be done for Minix?? */ - /* If it shouldn't be done, we should return -1 here */ - return(xf86Info.kbdFd); -} - -void xf86KbdEvents() -{ - unsigned char rBuf[64]; - int nBytes, i; - - while ((nBytes = nbio_read(xf86Info.kbdFd, (char *)rBuf, - sizeof(rBuf))) > 0) - { - for (i = 0; i < nBytes; i++) - xf86PostKbdEvent(rBuf[i]); - } - if (nBytes == 0) - ErrorF("xf86KbdEvents: nbio_read returns EOF"); - else if (errno != EAGAIN) - { - ErrorF("xf86KbdEvents: nbio_read error: %s", - strerror(errno)); - } -} - -void xf86MouseInit(mouse) -MouseDevPtr mouse; -{ - static int mseFd= -1; - int r, flags; - uid_t real_uid; - - if (mseFd < 0) - { - real_uid= getuid(); - - setuid(0); - if ((mseFd = mouse->mseFd = - open(mouse->mseDevice, O_RDWR)) < 0) - { - if (xf86Info.allowMouseOpenFail) { - ErrorF("Cannot open mouse (%s) - Continuing...\n", - strerror(errno)); - return; - } - FatalError("Cannot open mouse (%s)\n", - strerror(errno)); - } - setuid(real_uid); - - xf86SetupMouse(mouse); - - /* Mark the mouse as asynchronous */ - flags = fcntl(mouse->mseFd, F_GETFD); - if (flags == -1) - { - if (xf86AllowMouseOpenFail) { - ErrorF("Unable to get mouse flags (%s) - Continuing...\n", - strerror(errno)); - return; - } - FatalError("Unable to get mouse flags (%s)\n", - strerror(errno)); - } - r = fcntl(mouse->mseFd, F_SETFD, flags | FD_ASYNCHIO); - if (r == -1) - { - if (xf86AllowMouseOpenFail) { - ErrorF("Unable to set mouse flags (%s) - Continuing...\n", - strerror(errno)); - return; - } - FatalError("Unable to set mouse flags (%s)\n", - strerror(errno)); - } - nbio_register(mouse->mseFd); - } -} - -int xf86MouseOn(mouse) -MouseDevPtr mouse; -{ - char waste[16]; - int r; - - /* Get rid of old data */ - for (;;) - { - r = nbio_read(mouse->mseFd, waste, sizeof(waste)); - if (r > 0) - continue; - if ((r == -1 && errno == EAGAIN) || xf86AllowMouseOpenFail) - { - break; - } - if (xf86AllowMouseOpenFail) { - ErrorF("Unable to read from mouse (%s) - Continuing...\n", - strerror(errno)); - return -2; - } - FatalError("unable to read from mouse (%s)\n", - strerror(errno)); - } - return(mouse->mseFd); -} - -void xf86MouseEvents(device) -DeviceIntPtr device; -{ - unsigned char rBuf[64]; - int nBytes; - - while ((nBytes = nbio_read(mouse->mseFd, (char *)rBuf, - sizeof(rBuf))) > 0) - { - xf86MouseProtocol(device, rBuf, nBytes); - } - if (nBytes == 0) - ErrorF("xf86MouseEvents: nbio_read returns EOF"); - else if (errno != EAGAIN) - { - ErrorF("xf86MouseEvents: nbio_read error: %s", - strerror(errno)); - } -} - -int xf86MouseOff(mouse, doclose) -MouseDevPtr mouse; -Bool doclose; -{ - return(mouse->mseFd); -} Index: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c:3.4 xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c:removed --- xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c:3.4 Mon Dec 23 01:50:20 1996 +++ xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c Mon Dec 18 14:31:57 2000 @@ -1,98 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/mnx_video.c,v 3.4 1996/12/23 06:50:20 dawes Exp $ */ -/* - * Copyright 1993 by Vrije Universiteit, The Netherlands - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of The Vrije Universiteit and David - * Wexelblat not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The Vrije Universiteit and David Wexelblat make no representations about - * the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE VRIJE UNIVERSITEIT AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE VRIJE UNIVERSITEIT OR - * DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: mnx_video.c /main/5 1996/02/21 17:52:19 kaleb $ */ - -#include "X.h" -#include "input.h" -#include "scrnintstr.h" - -#include "local.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -/* ARGSUSED */ -pointer xf86MapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - ErrorF("xf86MapVidMem(ScreenNum= %d, Base= %p, Size= 0x%x\n", - ScreenNum, Base, Size); - return((pointer)xf86VideoBase + ((unsigned)Base-0xA0000)); -} - -/* ARGSUSED */ -void xf86UnMapVidMem(ScreenNum, Region, Base, Size) -int ScreenNum; -int Region; -pointer Base; -unsigned long Size; -{ - ErrorF("(warning) xf86UnmapVidMem is not implemented\n"); - return; -} - -Bool xf86LinearVidMem() -{ - return(FALSE); -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -Bool xf86DisableInterrupts() -{ -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - extern void intr_disable(); - - intr_disable(); -#endif /* __GNUC__ */ - - return(TRUE); -} - -void xf86EnableInterrupts() -{ -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - extern void intr_enable(); - - intr_enable(); -#endif /* __GNUC__ */ - - return; -} Index: xc/programs/Xserver/hw/xfree86/os-support/misc/Delay.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/misc/Delay.c:3.3 --- /dev/null Mon Dec 18 14:31:57 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/misc/Delay.c Fri Dec 8 15:13:38 2000 @@ -0,0 +1,37 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Delay.c,v 3.3 2000/12/08 20:13:38 eich Exp $ */ + +#include "X.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <time.h> + +void +xf86UDelay(long usec) +{ +#if 0 + struct timeval start, interrupt; +#else + int sigio; + + sigio = xf86BlockSIGIO(); + xf86usleep(usec); + xf86UnblockSIGIO(sigio); +#endif + +#if 0 + gettimeofday(&start,NULL); + + do { + usleep(usec); + gettimeofday(&interrupt,NULL); + + if ((usec = usec - (interrupt.tv_sec - start.tv_sec) * 1000000 + - (interrupt.tv_usec - start.tv_usec)) < 0) + break; + start = interrupt; + } while (1); +#endif +} + Index: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c diff -u xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c:1.2 Sat Jul 25 12:56:49 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c Fri Aug 4 12:13:41 2000 @@ -4,7 +4,7 @@ Stub for Alpha Linux *******************************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c,v 1.2 1998/07/25 16:56:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c,v 1.3 2000/08/04 16:13:41 eich Exp $ */ #include "X.h" #include "xf86.h" @@ -19,5 +19,6 @@ void xf86IODelay() { - usleep(1); + xf86UDelay(1); } + Index: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile:3.7 xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile:3.10 --- xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile:3.7 Tue Feb 15 18:44:58 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile Thu Nov 2 14:10:56 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 3.7 2000/02/15 23:44:58 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/Imakefile,v 3.10 2000/11/02 19:10:56 dawes Exp $ @@ -8,12 +8,12 @@ #include <Server.tmpl> -#if defined(i386Architecture) +#if defined(i386Architecture) && !defined(cygwinArchitecture) XSRCS = BUSmemcpy.S IODelay.S SlowBcopy.S XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o #elif defined(SparcArchitecture) -XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c SparcMulDiv.S -XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o SparcMulDiv.o +XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c +XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o #else XSRCS = BUSmemcpy.c IODelay.c SlowBcopy.c XOBJS = BUSmemcpy.o IODelay.o SlowBcopy.o @@ -24,9 +24,9 @@ ILHACKOBJS = xf86_IlHack.o #endif -SRCS = xf86_Util.c $(ILHACKSRCS) $(XSRCS) +SRCS = xf86_Util.c Delay.c $(ILHACKSRCS) $(XSRCS) -OBJS = xf86_Util.o $(ILHACKOBJS) $(XOBJS) +OBJS = xf86_Util.o Delay.o $(ILHACKOBJS) $(XOBJS) INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) @@ -34,13 +34,10 @@ SubdirLibraryRule($(OBJS)) NormalLibraryObjectRule() -#if defined(i386Architecture) +#if defined(i386Architecture) && !defined(cygwinArchitecture) ObjectFromAsmSource(BUSmemcpy,NullParameter) ObjectFromAsmSource(IODelay,NullParameter) ObjectFromAsmSource(SlowBcopy,NullParameter) -#endif -#if defined(SparcArchitecture) -ObjectFromAsmSource(SparcMulDiv,NullParameter) #endif DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S diff -u xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S:1.1 xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S:removed --- xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S:1.1 Sat Jul 10 03:24:51 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S Mon Dec 18 14:31:57 2000 @@ -1,87 +0,0 @@ -/* - * Hardware integer division and multiplication routines for SPARC v8 and higher. - * - * Copyright (C) 1996 David S. Miller (davem@redhat.com) - * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SparcMulDiv.S,v 1.1 1999/07/10 07:24:51 dawes Exp $ */ - - .globl urem_sparcv89, umul_sparcv89, udiv_sparcv89 - .globl rem_sparcv89, mul_sparcv89, div_sparcv89 - - .align 32 -urem_sparcv89: - wr %g0, 0x0, %y - nop - nop - nop - udiv %o0, %o1, %o2 - umul %o2, %o1, %o2 - retl - sub %o0, %o2, %o0 - - .align 32 -umul_sparcv89: - umul %o0, %o1, %o0 - retl - rd %y, %o1 - - .align 32 -udiv_sparcv89: - wr %g0, 0x0, %y - nop - nop - retl - udiv %o0, %o1, %o0 - - .align 32 -rem_sparcv89: - sra %o0, 0x1f, %o4 - wr %o4, 0x0, %y - nop - nop - nop - sdivcc %o0, %o1, %o2 - bvs,a 1f - xnor %o2, %g0, %o2 -1: smul %o2, %o1, %o2 - retl - sub %o0, %o2, %o0 - - .align 32 -mul_sparcv89: - smul %o0, %o1, %o0 - retl - rd %y, %o1 - nop - - .align 32 -div_sparcv89: - sra %o0, 0x1f, %o2 - wr %o2, 0x0, %y - nop - nop - nop - sdivcc %o0, %o1, %o0 - bvs,a 1f - xnor %o0, %g0, %o0 -1: retl - nop Index: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile:1.4 xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile:1.4 Tue Jun 27 10:27:30 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile Tue Aug 15 12:05:38 2000 @@ -1,14 +1,14 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.4 2000/06/27 14:27:30 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.5 2000/08/15 16:05:38 dawes Exp $ XCOMM #include <Server.tmpl> SRCS = nto_io.c nto_init.c nto_kbdEv.c nto_ioperm.c nto_video.c \ - VTsw_noop.c posix_tty.c std_mseEv.c std_mouse.c kmod_noop.c + VTsw_noop.c posix_tty.c std_mseEv.c std_mouse.c kmod_noop.c agp_noop.c OBJS = nto_io.o nto_init.o nto_kbdEv.o nto_ioperm.o nto_video.o \ - VTsw_noop.o posix_tty.o std_mseEv.o std_mouse.o kmod_noop.o + VTsw_noop.o posix_tty.o std_mseEv.o std_mouse.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) @@ -17,11 +17,12 @@ NormalLibraryObjectRule() -ObjectFromSpecialSource(IO_utils,../shared/IO_utils,/**/) -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/) -ObjectFromSpecialSource(std_mseEv,../shared/std_mseEv,/**/) -ObjectFromSpecialSource(std_mouse,../shared/std_mouse,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) +LinkSourceFile(IO_utils.c,../shared) +LinkSourceFile(VTsw_noop.c,../shared) +LinkSourceFile(posix_tty.c,../shared) +LinkSourceFile(std_mseEv.c,../shared) +LinkSourceFile(std_mouse.c,../shared) +LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile:3.16 xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile:3.17 --- xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile:3.16 Tue Jun 27 10:27:31 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile Tue Aug 15 12:05:38 2000 @@ -4,7 +4,7 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v 3.16 2000/06/27 14:27:31 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v 3.17 2000/08/15 16:05:38 dawes Exp $ #include <Server.tmpl> BIOS_MOD = os2_bios @@ -12,12 +12,12 @@ SRCS = os2_init.c os2_video.c os2_io.c $(BIOS_MOD).c \ os2_ioperm.c os2_VTsw.c os2_mouse.c os2_KbdEv.c os2_stubs.c \ os2_select.c os2_diag.c libc_wrapper.c stdResource.c stdPci.c \ - vidmem.c sigiostubs.c pm_noop.c kmod_noop.c + vidmem.c sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c OBJS = os2_init.o os2_video.o os2_io.o $(BIOS_MOD).o \ os2_ioperm.o os2_VTsw.o os2_mouse.o os2_kbdEv.o os2_stubs.o \ os2_select.o os2_diag.o libc_wrapper.o stdResource.o stdPci.o \ - vidmem.o sigiostubs.o pm_noop.o kmod_noop.o + vidmem.o sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) @@ -38,5 +38,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c:3.13 xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c:3.14 --- xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c:3.13 Wed Apr 5 14:13:54 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c Fri Oct 27 21:42:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.13 2000/04/05 18:13:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.14 2000/10/28 01:42:28 mvojkovi Exp $ */ /* * (c) Copyright 1994,1999 by Holger Veit * <Holger.Veit@gmd.de> @@ -102,7 +102,7 @@ /* ARGSUSED */ static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { DIOParPkt par; ULONG plen; Index: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c diff -u xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c:1.1 xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c:1.2 --- xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c:1.1 Wed Apr 5 14:13:55 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c Thu Jul 13 17:31:40 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c,v 1.1 2000/04/05 18:13:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c,v 1.2 2000/07/13 21:31:40 tsi Exp $ */ /* * XFree86 int10 module * execute BIOS int 10h calls in x86 real mode environment @@ -138,10 +138,6 @@ size = *((CARD8*)vbiosMem + 2) * 512; if (xf86ReadBIOS(cs << 4,0,vbiosMem, size) < 0) { xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (2)\n"); - goto error1; - } - if (bios_checksum(vbiosMem,size)) { - xf86DrvMsg(screen,X_ERROR,"Bad checksum of V_BIOS \n"); goto error1; } Index: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile:1.9 xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile:1.10 --- xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile:1.9 Fri Jun 16 20:03:41 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile Tue Aug 15 12:05:39 2000 @@ -1,5 +1,5 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v 1.9 2000/06/17 00:03:41 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v 1.10 2000/08/15 16:05:39 dawes Exp $ #include <Server.tmpl> @@ -10,13 +10,13 @@ bios_V4mmap.c VTsw_usl.c sysv_kbd.c std_kbdEv.c \ posix_tty.c $(MOUSESRC) xqueue.c ioperm_noop.c \ libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = pmax_devs.o pmax_init.o pmax_map.o pmax_pci.o pmax_ppc.o \ bios_V4mmap.o VTsw_usl.o sysv_kbd.o std_kbdEv.o \ posix_tty.o $(MOUSESRC) xqueue.o ioperm_noop.o \ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86OSSRC)/bus -I. \ @@ -40,6 +40,7 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) LinkSourceFile(bios_V4mmap.c,../sysv) LinkSourceFile(xqueue.c,../sysv) Index: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c diff -u xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c:1.7 Tue Jun 27 10:27:31 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c Sun Nov 19 11:38:06 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c,v 1.7 2000/06/27 14:27:31 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c,v 1.8 2000/11/19 16:38:06 tsi Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -170,6 +170,8 @@ int mlen; psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); base = pmax_iomap((unsigned long)hostbase, mlen); if (base == MAP_FAILED) { Index: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c diff -u xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c:1.4 xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c:1.5 --- xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c:1.4 Thu Jan 14 08:05:08 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c Mon Jul 31 19:24:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c,v 1.4 1999/01/14 13:05:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c,v 1.5 2000/07/31 23:24:32 tsi Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -538,15 +538,12 @@ "nh6400PciReadLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n", cfgaddr, base, infop->cfgPhysBase); + /* There may not be any OS interaction while interrupts are disabled */ xf86DisableInterrupts(); *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */ eieio(); - xf86MsgVerb(X_INFO, 3, - "nh6400PciReadLong: About to read from 0x%x (phys=0x%x)\n", - base + data_reg_offset, infop->cfgPhysBase + data_reg_offset); - if (!badaddr(base + data_reg_offset, 4, 0)) { tmp = *((unsigned long *)(base + data_reg_offset)); eieio(); @@ -554,8 +551,8 @@ xf86EnableInterrupts(); - xf86MsgVerb(X_INFO, 3, "nh6400PciReadLong: Read value=0x%x\n", - pciByteSwap(tmp)); + xf86MsgVerb(X_INFO, 3, "nh6400PciReadLong: Read value=0x%x from 0x%x (phys=0x%x)\n", + pciByteSwap(tmp), base + data_reg_offset, infop->cfgPhysBase + data_reg_offset); return(pciByteSwap(tmp)); } @@ -645,20 +642,21 @@ "nh6400PciWriteLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n", cfgaddr, base, infop->cfgPhysBase); + /* There may not be any OS interaction while interrupts are disabled */ xf86DisableInterrupts(); *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */ eieio(); - xf86MsgVerb(X_INFO, 3, - "nh6400PciWriteLong: Writing value=0x%x to 0x%x (phys=0x%x)\n", - val, base + data_reg_offset, - infop->cfgPhysBase + data_reg_offset); - *((unsigned long *)(base + data_reg_offset)) = pciByteSwap(val); eieio(); xf86EnableInterrupts(); + + xf86MsgVerb(X_INFO, 3, + "nh6400PciWriteLong: Wrote value=0x%x to 0x%x (phys=0x%x)\n", + val, base + data_reg_offset, + infop->cfgPhysBase + data_reg_offset); } /* @@ -844,16 +842,12 @@ "nh6408PciReadLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n", cfgaddr, base, infop->cfgPhysBase); + /* There may not be any OS interaction while interrupts are disabled */ xf86DisableInterrupts(); *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */ eieio(); - xf86MsgVerb(X_INFO, 3, - "nh6408PciReadLong: About to read from 0x%x (phys=0x%x)\n", - base + NH6408_PCI_CFG_DATA_REG_OFF, - infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF); - if (!badaddr(base + NH6408_PCI_CFG_DATA_REG_OFF, 4, 0)) { tmp = *((unsigned long *)(base + NH6408_PCI_CFG_DATA_REG_OFF)); eieio(); @@ -861,8 +855,10 @@ xf86EnableInterrupts(); - xf86MsgVerb(X_INFO, 3, "nh6408PciReadLong: Read value=0x%x\n", - pciByteSwap(tmp)); + xf86MsgVerb(X_INFO, 3, "nh6408PciReadLong: Read value=0x%x from 0x%x (phys=0x%x)\n", + pciByteSwap(tmp), + base + NH6408_PCI_CFG_DATA_REG_OFF, + infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF); return(pciByteSwap(tmp)); } @@ -951,21 +947,21 @@ "nh6408PciWriteLong: Writing cfgaddr=0x%x to 0x%x (phys=0x%x)\n", cfgaddr, base, infop->cfgPhysBase); + /* There may not be any OS interaction while interrupts are disabled */ xf86DisableInterrupts(); *((unsigned long *)(base)) = pciByteSwap(cfgaddr); /* Set cfg address */ eieio(); - xf86MsgVerb(X_INFO, 3, - "nh6408PciWriteLong: Writing value=0x%x to 0x%x (phys=0x%x)\n", - val, base + NH6408_PCI_CFG_DATA_REG_OFF, - infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF); - - *((unsigned long *)(base + NH6408_PCI_CFG_DATA_REG_OFF)) = pciByteSwap(val); eieio(); xf86EnableInterrupts(); + + xf86MsgVerb(X_INFO, 3, + "nh6408PciWriteLong: Wrote value=0x%x to 0x%x (phys=0x%x)\n", + val, base + NH6408_PCI_CFG_DATA_REG_OFF, + infop->cfgPhysBase + NH6408_PCI_CFG_DATA_REG_OFF); } Index: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c diff -u xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c:1.3 xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c:1.4 --- xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c:1.3 Sat Jul 25 12:56:56 1998 +++ xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c Mon Jul 31 19:25:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c,v 1.3 1998/07/25 16:56:56 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c,v 1.4 2000/07/31 23:25:18 tsi Exp $ */ /* * Copyright 1998 by Concurrent Computer Corporation * @@ -90,7 +90,7 @@ } void -outl(unsigned int a, unsigned long l) +outl(unsigned int a, unsigned int l) { if (ioBase == MAP_FAILED) { ErrorF("outl(0x%04X, 0x%08X) fails. Unitialized ioBase\n", a, l); @@ -129,10 +129,10 @@ return(w); } -unsigned long +unsigned int inl(unsigned int a) { - unsigned long l; + unsigned int l; if (ioBase == MAP_FAILED) { FatalError("%s(0x%04X) fails. Unitialized ioBase\n", "inl", a); @@ -164,7 +164,7 @@ } void -debug_outl(unsigned int a, unsigned long l, int line, char *file) +debug_outl(unsigned int a, unsigned int l, int line, char *file) { if (xf86Verbose > 3) ErrorF("outl(0x%04X, 0x%08X) at line %d, file \"%s\"\n", a, l, line, file); @@ -205,10 +205,10 @@ return(w); } -unsigned long +unsigned int debug_inl(unsigned int a, int line, char *file) { - unsigned long l; + unsigned int l; if (xf86Verbose > 4) ErrorF("Calling %s(0x%04x) at line %d, file \"%s\" ...\n", "inl", a, line, file); Index: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile:1.5 xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile:1.5 Tue Jun 27 10:27:31 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile Tue Aug 15 12:05:39 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v 1.5 2000/06/27 14:27:31 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v 1.6 2000/08/15 16:05:39 dawes Exp $ #include <Server.tmpl> @@ -6,12 +6,12 @@ SRCS = qnx_io.c qnx_init.c qnx_utils.c ioperm_noop.c qnx_video.c \ qnx_VTsw.c qnx_kbd.c posix_tty.c qnx_mouse.c qnx_select.c \ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = qnx_io.o qnx_init.o qnx_utils.o ioperm_noop.o qnx_video.o \ qnx_VTsw.o qnx_kbd.o posix_tty.o qnx_mouse.o qnx_select.o \ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) @@ -32,5 +32,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile:3.9 xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile:3.11 --- xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile:3.9 Tue Jun 27 10:27:31 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile Wed Dec 13 13:38:05 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v 3.9 2000/06/27 14:27:31 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v 3.11 2000/12/13 18:38:05 robin Exp $ @@ -8,14 +8,14 @@ #include <Server.tmpl> SRCS = sco_init.c sco_video.c sco_io.c bios_devmem.c VTsw_sco.c \ - sysv_kbd.c std_kbdEv.c sysv_tty.c std_mseEv.c sco_mouse.c \ + sysv_kbd.c std_kbdEv.c sysv_tty.c sco_mouse.c \ libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = sco_init.o sco_video.o sco_io.o bios_devmem.o VTsw_sco.o \ - sysv_kbd.o std_kbdEv.o sysv_tty.o std_mseEv.o sco_mouse.o \ + sysv_kbd.o std_kbdEv.o sysv_tty.o sco_mouse.o \ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) @@ -31,13 +31,13 @@ LinkSourceFile(sysv_kbd.c,../shared) LinkSourceFile(std_kbdEv.c,../shared) LinkSourceFile(sysv_tty.c,../shared) -LinkSourceFile(std_mseEv.c,../shared) LinkSourceFile(libc_wrapper.c,../shared) LinkSourceFile(stdResource.c,../shared) LinkSourceFile(stdPci.c,../shared) LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c:1.2 --- /dev/null Mon Dec 18 14:31:59 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c Thu Aug 24 21:19:17 2000 @@ -0,0 +1,63 @@ +/* + * Abstraction of the AGP GART interface. Stubs for platforms without + * AGP GART support. + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c,v 1.2 2000/08/25 01:19:17 dawes Exp $ */ + +#include "X.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +Bool +xf86AgpGARTSupported() +{ + return FALSE; +} + +AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + return NULL; +} + +Bool +xf86AcquireGART(int screenNum) +{ + return FALSE; +} + +Bool +xf86ReleaseGART(int screenNum) +{ + return FALSE; +} + +int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + return -1; +} + + +Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + return FALSE; +} + + +Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + return FALSE; +} + +Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + return FALSE; +} Index: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c:3.6 xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c:3.7 --- xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c:3.6 Sun Jul 18 04:14:36 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c Tue Sep 19 08:46:22 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.6 1999/07/18 08:14:36 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.7 2000/09/19 12:46:22 eich Exp $ */ /* * Copyright 1993 by David Wexelblat <dwex@goblin.org> * @@ -43,7 +43,11 @@ { int fd; - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) +#ifdef __ia64__ + if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) +#else + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) +#endif { xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", DEV_MEM, strerror(errno)); Index: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c:1.7 xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c:1.7 Sat Feb 12 15:45:45 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c Sun Nov 19 11:38:06 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c,v 1.7 2000/02/12 20:45:45 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c,v 1.8 2000/11/19 16:38:06 tsi Exp $ */ /* * Copyright 1993 by David Wexelblat <dwex@goblin.org> * @@ -54,8 +54,9 @@ return(-1); } psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); - /* Base is assumed to be page-aligned. */ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, fd, (off_t)Base); if (ptr == MAP_FAILED) @@ -135,8 +136,9 @@ } psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); - /* Base is assumed to be page-aligned. */ base = mmap((caddr_t)0, JENSEN_SHIFT(mlen), PROT_READ, MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE)); Index: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c:1.65 xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c:1.71 --- xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c:1.65 Fri Jun 16 20:03:42 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c Wed Dec 6 15:39:54 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.65 2000/06/17 00:03:42 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.71 2000/12/06 20:39:54 dawes Exp $ */ /* * Copyright 1997 by The XFree86 Project, Inc. * @@ -76,7 +76,13 @@ #include <stdlib.h> #endif +#ifdef __CYGWIN__ +#define vsscanf sscanf +#define vfscanf fscanf +#endif + #define NEED_XF86_TYPES +#define NEED_XF86_PROTOTYPES #define DONT_DEFINE_WRAPPERS #include "xf86_ansic.h" @@ -140,7 +146,6 @@ /* For xf86getpagesize() */ #if defined(linux) -#include <asm/page.h> #define HAS_SC_PAGESIZE #define HAS_GETPAGESIZE #elif defined(CSRG_BASED) @@ -157,6 +162,7 @@ #include <sys/ipc.h> #include <sys/shm.h> #endif +#include <setjmp.h> #if 0 #define SETBUF_RETURNS_INT @@ -391,7 +397,7 @@ va_start(ap, flags); flags = xfToOsOpenFlags(flags); - if (flags & XF86_O_CREAT) { + if (flags & O_CREAT) { mode_t mode = va_arg(ap, mode_t); fd = open(path, flags, mode); } else { @@ -1879,3 +1885,16 @@ return -1; } #endif /* HAVE_SYSV_IPC */ + +int +xf86setjmp(xf86jmp_buf xf86env) +{ + return setjmp((void *)xf86env); +} + +void +xf86longjmp(xf86jmp_buf xf86env, int val) +{ + longjmp((void *)xf86env, val); +} + Index: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c:3.24 xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c:3.25 --- xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c:3.24 Fri Nov 19 08:55:02 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c Tue Nov 14 16:59:24 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.24 1999/11/19 13:55:02 hohndel Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.25 2000/11/14 21:59:24 dawes Exp $ */ /* * Copyright 1993-1999 by The XFree86 Project, Inc. * @@ -59,8 +59,6 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" - -#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) static int GetBaud (int baudrate) Index: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c:1.11 xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c:1.12 --- xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c:1.11 Fri Jun 16 20:03:43 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c Tue Nov 14 16:59:24 2000 @@ -25,7 +25,7 @@ * * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.11 2000/06/17 00:03:43 martin Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.12 2000/11/14 21:59:24 dawes Exp $ * */ @@ -46,6 +46,7 @@ # include <errno.h> # include <stdio.h> # include <string.h> +# define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) #endif /* @@ -75,8 +76,6 @@ static int xf86SigIOMax; static int xf86SigIOMaxFd; static fd_set xf86SigIOMask; - -#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) /* * SIGIO gives no way of discovering which fd signalled, select Index: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c diff -u xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c:1.11 xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c:1.13 --- xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c:1.11 Tue May 2 20:44:20 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c Fri Oct 27 21:42:28 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.11 2000/05/03 00:44:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.13 2000/10/28 01:42:28 mvojkovi Exp $ */ /* * Copyright 1993-1999 by The XFree86 Project, Inc * @@ -46,13 +46,18 @@ #define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) static VidMemInfo vidMemInfo = {FALSE, }; +static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL}; static VidMapPtr getVidMapRec(int scrnIndex) { VidMapPtr vp; + ScrnInfoPtr pScrn; - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + if ((scrnIndex < 0) || + !(pScrn = xf86Screens[scrnIndex])) + return &vidMapRec; + if (vidMapIndex < 0) vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); @@ -118,7 +123,7 @@ static void checkMtrrOption(VidMapPtr vp) { - if (!vp->mtrrOptChecked && vp->pScrn->options != NULL) { + if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { OptionInfoRec options[nopts]; (void)memcpy(options, opts, sizeof(opts)); @@ -139,7 +144,7 @@ if (((Flags & VIDMEM_FRAMEBUFFER) && (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)))) - FatalError("Mapping memory with more than one type"); + FatalError("Mapping memory with more than one type\n"); if (!vidMemInfo.initialised) { memset(&vidMemInfo, 0, sizeof(VidMemInfo)); @@ -148,7 +153,7 @@ if (!vidMemInfo.initialised || !vidMemInfo.mapMem) return NULL; - vbase = vidMemInfo.mapMem(ScreenNum, Base, Size); + vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); if (!vbase || vbase == (pointer)-1) return NULL; Index: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c:1.2 --- /dev/null Mon Dec 18 14:32:00 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c Mon Nov 6 16:57:11 2000 @@ -0,0 +1,20 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#include "xf86Axp.h" + +axpParams xf86AXPParams[] = { + {SYS_NONE, 0, 0, 0}, + {TSUNAMI, 0, 0, 0}, + {LCA, 1<<24,0xf8000000, 1UL << 32}, + {APECS, 1<<24,0xf8000000, 1UL << 32}, + {T2, 0,0xFC000000, 1UL << 31}, + {T2_GAMMA, 0,0xFC000000, 1UL << 31}, + {CIA, 0,0xE0000000, 1UL << 34}, + {MCPCIA, 0,0xf8000000, 1UL << 31}, + {JENSEN, 0, 0xE000000, 1UL << 32}, + {POLARIS, 0, 0, 0}, + {PYXIS, 0, 0, 0}, + {PYXIS_CIA, 0,0xE0000000, 1UL << 34}, + {IRONGATE, 0, 0, 0} +}; + Index: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h:1.2 --- /dev/null Mon Dec 18 14:32:00 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h Mon Nov 6 16:57:11 2000 @@ -0,0 +1,39 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h,v 1.2 2000/11/06 21:57:11 dawes Exp $ */ + +#ifndef _XF86_AXP_H_ +#define _XF86_AXP_H_ + +typedef enum { + SYS_NONE, + TSUNAMI, + LCA, + APECS, + T2, + T2_GAMMA, + CIA, + MCPCIA, + JENSEN, + POLARIS, + PYXIS, + PYXIS_CIA, + IRONGATE +} axpDevice; + +typedef struct + { char* sysName; + char* sysVari; + char* cpu; + axpDevice sys; } +AXP; + +typedef struct { + axpDevice id; + unsigned long hae_thresh; + unsigned long hae_mask; + unsigned long size; +} axpParams; + +extern axpParams xf86AXPParams[]; + +#endif + Index: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile:1.5 xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile:1.7 --- xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile:1.5 Fri Jun 16 20:03:43 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile Tue Aug 15 12:05:40 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile,v 1.5 2000/06/17 00:03:43 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile,v 1.7 2000/08/15 16:05:40 dawes Exp $ @@ -20,20 +20,20 @@ VTsw_noop.c sol8_kbd.c sol8_kbdEv.c posix_tty.c $(MOUSESRC) \ libc_wrapper.c $(PROWORKS_INOUT_SRC) stdResource.c stdPci.c \ sol8_kbdgetmapping.c sol8_postkbdevents.c sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = sol8_init.o sol8_vid.o sol8_bios.o sol8_kbd.o sol8_io.o \ VTsw_noop.o sol8_kbd.o sol8_kbdEv.o posix_tty.o $(MOUSEOBJ) \ libc_wrapper.o $(PROWORKS_INOUT_OBJ) stdResource.o stdPci.o \ sol8_kbdgetmapping.o sol8_postkbdevents.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) RESDEFINES = -DUSESTDRES -DEFINES = $(RESDEFINES) -DSOL8 +DEFINES = $(RESDEFINES) SubdirLibraryRule($(OBJS)) NormalLibraryObjectRule() @@ -47,5 +47,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c diff -u xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c:1.2 Fri Feb 11 17:36:04 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c Sun Nov 19 11:38:07 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c,v 1.2 2000/02/11 22:36:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_bios.c,v 1.3 2000/11/19 16:38:07 tsi Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -75,8 +75,9 @@ return(-1); } psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); - /* Base is assumed to be page-aligned. */ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, fd, (off_t)Base); if (ptr == MAP_FAILED) Index: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c diff -u xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c:1.2 Wed Oct 13 00:21:35 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c Fri Aug 11 15:51:04 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c,v 1.2 1999/10/13 04:21:35 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_init.c,v 1.3 2000/08/11 19:51:04 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -50,7 +50,7 @@ #define MAX_SECONDS 60 #define USEC_IN_SEC (unsigned long)1000000 -#ifndef SOL8 +#ifndef __SOL8__ int xf86_sol8usleep(unsigned long); static void xf86_sol8sleep(int); #endif Index: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h diff -u xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h:1.2 xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h:1.8 --- xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h:1.2 Wed Oct 13 00:21:36 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h Sun Dec 17 21:25:58 2000 @@ -1,184 +1,150 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h,v 1.2 1999/10/13 04:21:36 dawes Exp $ */ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Thomas Roell not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Thomas Roell makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_keynames.h,v 1.8 2000/12/18 02:25:58 dawes Exp $ */ #ifndef _SOL8KEYNAMES_H #define _SOL8KEYNAMES_H -#define XK_TECHNICAL -#define XK_KATAKANA -#include "keysym.h" +#include "atKeynames.h" -#define GLYPHS_PER_KEY 4 -#define NUM_KEYCODES 127 -#define MIN_KEYCODE 8 -#define MAX_KEYCODE 135 - -#define AltMask Mod1Mask -#define NumLockMask Mod2Mask -#define AltLangMask Mod3Mask -#define KanaMask Mod4Mask -#define ScrollLockMask Mod5Mask - -#define ModifierDown(k) ((keyc->state & (k)) == (k)) - -/* - * definition of the Solaris Keyboard. - * ============================================================ - * Defined Key Cap Glyphs Pressed value - * Key Name Main Also (hex) (dec) - * ---------------- ---------- ------- ------ ------ - */ - -#define KEY_Escape /* Escape 0x01 */ 110 -#define KEY_1 /* 1 ! 0x02 */ 2 -#define KEY_2 /* 2 @ 0x03 */ 3 -#define KEY_3 /* 3 # 0x04 */ 4 -#define KEY_4 /* 4 $ 0x05 */ 5 -#define KEY_5 /* 5 % 0x06 */ 6 -#define KEY_6 /* 6 ^ 0x07 */ 7 -#define KEY_7 /* 7 & 0x08 */ 8 -#define KEY_8 /* 8 * 0x09 */ 9 -#define KEY_9 /* 9 ( 0x0a */ 10 -#define KEY_0 /* 0 ) 0x0b */ 11 -#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12 -#define KEY_Equal /* = (Equal) + 0x0d */ 13 -#define KEY_BackSpace /* Back Space 0x0e */ 15 -#define KEY_Tab /* Tab 0x0f */ 16 -#define KEY_Q /* Q 0x10 */ 17 -#define KEY_W /* W 0x11 */ 18 -#define KEY_E /* E 0x12 */ 19 -#define KEY_R /* R 0x13 */ 20 -#define KEY_T /* T 0x14 */ 21 -#define KEY_Y /* Y 0x15 */ 22 -#define KEY_U /* U 0x16 */ 23 -#define KEY_I /* I 0x17 */ 24 -#define KEY_O /* O 0x18 */ 25 -#define KEY_P /* P 0x19 */ 26 -#define KEY_LBrace /* [ { 0x1a */ 27 -#define KEY_RBrace /* ] } 0x1b */ 28 -#define KEY_Enter /* Enter 0x1c */ 43 -#define KEY_LCtrl /* Ctrl(left) 0x1d */ 58 -#define KEY_A /* A 0x1e */ 31 -#define KEY_S /* S 0x1f */ 32 -#define KEY_D /* D 0x20 */ 33 -#define KEY_F /* F 0x21 */ 34 -#define KEY_G /* G 0x22 */ 35 -#define KEY_H /* H 0x23 */ 36 -#define KEY_J /* J 0x24 */ 37 -#define KEY_K /* K 0x25 */ 38 -#define KEY_L /* L 0x26 */ 39 -#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 40 -#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 41 -#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 1 -#define KEY_ShiftL /* Shift(left) 0x2a */ 44 -#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 29 -#define KEY_Z /* Z 0x2c */ 46 -#define KEY_X /* X 0x2d */ 47 -#define KEY_C /* C 0x2e */ 48 -#define KEY_V /* V 0x2f */ 49 -#define KEY_B /* B 0x30 */ 50 -#define KEY_N /* N 0x31 */ 51 -#define KEY_M /* M 0x32 */ 52 -#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 53 -#define KEY_Period /* . (Period) >(Greater)0x34 */ 54 -#define KEY_Slash /* / (Slash) ? 0x35 */ 55 -#define KEY_ShiftR /* Shift(right) 0x36 */ 57 -#define KEY_KP_Multiply /* * 0x37 */ 100 -#define KEY_Alt /* Alt(left) 0x38 */ 60 -#define KEY_Space /* (SpaceBar) 0x39 */ 61 -#define KEY_CapsLock /* CapsLock 0x3a */ 30 -#define KEY_F1 /* F1 0x3b */ 112 -#define KEY_F2 /* F2 0x3c */ 113 -#define KEY_F3 /* F3 0x3d */ 114 -#define KEY_F4 /* F4 0x3e */ 115 -#define KEY_F5 /* F5 0x3f */ 116 -#define KEY_F6 /* F6 0x40 */ 117 -#define KEY_F7 /* F7 0x41 */ 118 -#define KEY_F8 /* F8 0x42 */ 119 -#define KEY_F9 /* F9 0x43 */ 120 -#define KEY_F10 /* F10 0x44 */ 121 -#define KEY_NumLock /* NumLock 0x45 */ 122 -#define KEY_ScrollLock /* ScrollLock 0x46 */ 125 -#define KEY_KP_7 /* 7 Home 0x47 */ 91 -#define KEY_KP_8 /* 8 Up 0x48 */ 96 -#define KEY_KP_9 /* 9 PgUp 0x49 */ 101 -#define KEY_KP_Minus /* - (Minus) 0x4a */ 105 -#define KEY_KP_4 /* 4 Left 0x4b */ 92 -#define KEY_KP_5 /* 5 0x4c */ 97 -#define KEY_KP_6 /* 6 Right 0x4d */ 102 -#define KEY_KP_Plus /* + (Plus) 0x4e */ 106 -#define KEY_KP_1 /* 1 End 0x4f */ 93 -#define KEY_KP_2 /* 2 Down 0x50 */ 98 -#define KEY_KP_3 /* 3 PgDown 0x51 */ 103 -#define KEY_KP_0 /* 0 Insert 0x52 */ 99 -#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 104 -#define KEY_SysReqest /* SysReqest 0x54 */ 124 - /* NOTUSED 0x55 */ -#define KEY_F11 /* F11 0x57 */ 122 -#define KEY_F12 /* F12 0x58 */ 123 - -#ifdef _notdef_ /* these keys appear not to exist on a US English keyboard */ -#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86 -#define KEY_Prefix0 /* special 0x60 */ 96 -#define KEY_Prefix1 /* specail 0x61 */ 97 -#endif - -/* - * The 'scancodes' below are generated by the server, because the MF101/102 - * keyboard sends them as sequence of other scancodes - */ -#define KEY_Home /* Home 0x59 */ 80 -#define KEY_Up /* Up 0x5a */ 83 -#define KEY_PgUp /* PgUp 0x5b */ 85 -#define KEY_Left /* Left 0x5c */ 79 -#ifdef _notdef_ -#define KEY_Begin /* Begin 0x5d */ 93 -#endif -#define KEY_Right /* Right 0x5e */ 89 -#define KEY_End /* End 0x5f */ 81 -#define KEY_Down /* Down 0x60 */ 84 -#define KEY_PgDown /* PgDown 0x61 */ 86 -#define KEY_Insert /* Insert 0x62 */ 75 -#define KEY_Delete /* Delete 0x63 */ 76 -#define KEY_KP_Enter /* Enter 0x64 */ 106 -#define KEY_RCtrl /* Ctrl(right) 0x65 */ 64 -#define KEY_Pause /* Pause 0x66 */ 126 -#define KEY_Print /* Print 0x67 */ 124 -#define KEY_KP_Divide /* Divide 0x68 */ 95 -#define KEY_AltLang /* AtlLang(right) 0x69 */ 62 -#define KEY_Break /* Break 0x6a */ 126 -#ifdef _notdef_ -#define KEY_LMeta /* Left Meta 0x6b */ 60 -#define KEY_RMeta /* Right Meta 0x6c */ 62 -#define KEY_Menu /* Menu 0x6d */ 109 -#define KEY_F13 /* F13 0x6e */ 110 -#define KEY_F14 /* F14 0x6f */ 111 -#define KEY_F15 /* F15 0x70 */ 112 -#define KEY_F16 /* F16 0x71 */ 113 -#define KEY_F17 /* F17 0x72 */ 114 -#define KEY_KP_DEC /* KP_DEC 0x73 */ 115 +#ifdef DEFINE_SOL8_MAP +/* Map the Solaris 8 keycodes to the "XFree86" keycodes. */ +unsigned char sol8map[256] = { + KEY_NOTUSED, /* 0 */ + KEY_Tilde, /* 1 */ + KEY_1, /* 2 */ + KEY_2, /* 3 */ + KEY_3, /* 4 */ + KEY_4, /* 5 */ + KEY_5, /* 6 */ + KEY_6, /* 7 */ + KEY_7, /* 8 */ + KEY_8, /* 9 */ + KEY_9, /* 10 */ + KEY_0, /* 11 */ + KEY_Minus, /* 12 */ + KEY_Equal, /* 13 */ + 0x7D, /*KEY_P_YEN*/ /* 14 */ + KEY_BackSpace, /* 15 */ + KEY_Tab, /* 16 */ + KEY_Q, /* 17 */ + KEY_W, /* 18 */ + KEY_E, /* 19 */ + KEY_R, /* 20 */ + KEY_T, /* 21 */ + KEY_Y, /* 22 */ + KEY_U, /* 23 */ + KEY_I, /* 24 */ + KEY_O, /* 25 */ + KEY_P, /* 26 */ + KEY_LBrace, /* 27 */ + KEY_RBrace, /* 28 */ + KEY_BSlash, /* 29 */ + KEY_CapsLock, /* 30 */ + KEY_A, /* 31 */ + KEY_S, /* 32 */ + KEY_D, /* 33 */ + KEY_F, /* 34 */ + KEY_G, /* 35 */ + KEY_H, /* 36 */ + KEY_J, /* 37 */ + KEY_K, /* 38 */ + KEY_L, /* 39 */ + KEY_SemiColon, /* 40 */ + KEY_Quote, /* 41 */ + KEY_UNKNOWN, /* 42 */ + KEY_Enter, /* 43 */ + KEY_ShiftL, /* 44 */ + KEY_Less, /* 45 */ + KEY_Z, /* 46 */ + KEY_X, /* 47 */ + KEY_C, /* 48 */ + KEY_V, /* 49 */ + KEY_B, /* 50 */ + KEY_N, /* 51 */ + KEY_M, /* 52 */ + KEY_Comma, /* 53 */ + KEY_Period, /* 54 */ + KEY_Slash, /* 55 */ + 0x73, /*KEY_P_BKSL*/ /* 56 */ + KEY_ShiftR, /* 57 */ + KEY_LCtrl, /* 58 */ + KEY_LMeta, /* 59 */ + KEY_Alt, /* 60 */ + KEY_Space, /* 61 */ + KEY_AltLang, /* 62 */ + KEY_RMeta, /* 63 */ + KEY_RCtrl, /* 64 */ + KEY_Menu, /* 65 */ + KEY_UNKNOWN, /* 66 */ + KEY_UNKNOWN, /* 67 */ + KEY_UNKNOWN, /* 68 */ + KEY_UNKNOWN, /* 69 */ + KEY_UNKNOWN, /* 70 */ + KEY_UNKNOWN, /* 71 */ + KEY_UNKNOWN, /* 72 */ + KEY_UNKNOWN, /* 73 */ + KEY_UNKNOWN, /* 74 */ + KEY_Insert, /* 75 */ + KEY_Delete, /* 76 */ + KEY_UNKNOWN, /* 77 */ + KEY_UNKNOWN, /* 78 */ + KEY_Left, /* 79 */ + KEY_Home, /* 80 */ + KEY_End, /* 81 */ + KEY_UNKNOWN, /* 82 */ + KEY_Up, /* 83 */ + KEY_Down, /* 84 */ + KEY_PgUp, /* 85 */ + KEY_PgDown, /* 86 */ + KEY_UNKNOWN, /* 87 */ + KEY_UNKNOWN, /* 88 */ + KEY_Right, /* 89 */ + KEY_NumLock, /* 90 */ + KEY_KP_7, /* 91 */ + KEY_KP_4, /* 92 */ + KEY_KP_1, /* 93 */ + KEY_UNKNOWN, /* 94 */ + KEY_KP_Divide, /* 95 */ + KEY_KP_8, /* 96 */ + KEY_KP_5, /* 97 */ + KEY_KP_2, /* 98 */ + KEY_KP_0, /* 99 */ + KEY_KP_Multiply, /* 100 */ + KEY_KP_9, /* 101 */ + KEY_KP_6, /* 102 */ + KEY_KP_3, /* 103 */ + KEY_KP_Decimal, /* 104 */ + KEY_KP_Minus, /* 105 */ + KEY_KP_Plus, /* 106 */ + KEY_UNKNOWN, /* 107 */ + KEY_KP_Enter, /* 108 */ + KEY_UNKNOWN, /* 109 */ + KEY_Escape, /* 110 */ + KEY_UNKNOWN, /* 111 */ + KEY_F1, /* 112 */ + KEY_F2, /* 113 */ + KEY_F3, /* 114 */ + KEY_F4, /* 115 */ + KEY_F5, /* 116 */ + KEY_F6, /* 117 */ + KEY_F7, /* 118 */ + KEY_F8, /* 119 */ + KEY_F9, /* 120 */ + KEY_F10, /* 121 */ + KEY_F11, /* 122 */ + KEY_F12, /* 123 */ + KEY_Print, /* 124 */ + KEY_ScrollLock, /* 125 */ + KEY_Pause, /* 126 */ + KEY_UNKNOWN, /* 127 */ + KEY_UNKNOWN, /* 128 */ + KEY_UNKNOWN, /* 129 */ + KEY_UNKNOWN, /* 130 */ + 0x7B, /*KEY_P_NFER*/ /* 131 */ + 0x79, /*KEY_P_XFER*/ /* 132 */ + 0x70, /*KEY_HKTG*/ /* 133 */ + KEY_UNKNOWN, /* 134 */ + /* The rest default to KEY_UNKNOWN */ +}; #endif #endif /* _SOL8KEYNAMES_H */ Index: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c diff -u xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c:1.2 xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c:1.3 --- xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c:1.2 Wed Oct 13 00:21:36 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c Mon Aug 14 13:47:08 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c,v 1.2 1999/10/13 04:21:36 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/sol8_postkbdevents.c,v 1.3 2000/08/14 17:47:08 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -47,6 +47,7 @@ #endif #include <sys/vuid_event.h> +#define DEFINE_SOL8_MAP #include "sol8_keynames.h" #ifdef XKB @@ -162,7 +163,7 @@ * and now get some special keysequences */ - specialkey = event->id; + specialkey = sol8map[event->id]; if ((ModifierDown(ControlMask | AltMask)) || (ModifierDown(ControlMask | AltLangMask))) @@ -204,7 +205,17 @@ /* * Now map the scancodes to real X-keycodes ... */ - keycode = event->id + MIN_KEYCODE; + keycode = sol8map[event->id]; + if (keycode == KEY_NOTUSED) { + xf86MsgVerb(X_INFO, 0, + "raw code %d mapped to KEY_NOTUSED -- please report\n", event->id); + return; + } else if (keycode == KEY_UNKNOWN) { + xf86MsgVerb(X_INFO, 0, + "raw code %d mapped to KEY_UNKNOWN -- please report\n", event->id); + return; + } + keycode += MIN_KEYCODE; keysym = (keyc->curKeySyms.map + keyc->curKeySyms.mapWidth * (keycode - keyc->curKeySyms.minKeyCode)); Index: xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile:3.17 xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile:3.18 --- xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile:3.17 Fri Jun 16 20:03:43 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile Tue Aug 15 12:05:40 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile,v 3.17 2000/06/17 00:03:43 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile,v 3.18 2000/08/15 16:05:40 dawes Exp $ @@ -19,12 +19,12 @@ SRCS = solx86_init.c solx86_vid.c solx86_bios.c sysv_io.c \ VTsw_usl.c sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) \ libc_wrapper.c $(PROWORKS_INOUT_SRC) stdResource.c stdPci.c \ - sigiostubs.c pm_noop.c kmod_noop.c + sigiostubs.c pm_noop.c kmod_noop.c agp_noop.c OBJS = solx86_init.o solx86_vid.o solx86_bios.o sysv_io.o \ VTsw_usl.o sysv_kbd.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \ libc_wrapper.o $(PROWORKS_INOUT_OBJ) stdResource.o stdPci.o \ - sigiostubs.o pm_noop.o kmod_noop.o + sigiostubs.o pm_noop.o kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) @@ -48,5 +48,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c diff -u xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c:1.5 xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c:1.6 --- xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c:1.5 Fri Feb 11 17:36:04 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c Sun Nov 19 11:38:07 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c,v 1.5 2000/02/11 22:36:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/solx86_bios.c,v 1.6 2000/11/19 16:38:07 tsi Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -58,6 +58,8 @@ * is considered the "default" file to open. */ psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0) sprintf(solx86_vtname,"/dev/vt%02d",xf86Info.vtno); @@ -76,7 +78,6 @@ solx86_vtname, strerror(errno)); return(-1); } - /* Base is assumed to be page-aligned. */ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, fd, (off_t)Base); if (ptr == MAP_FAILED) Index: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile diff -u xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile:3.22 xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile:3.23 --- xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile:3.22 Fri Jun 16 20:03:43 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile Tue Aug 15 12:05:40 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v 3.22 2000/06/17 00:03:43 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v 3.23 2000/08/15 16:05:40 dawes Exp $ @@ -20,12 +20,12 @@ SRCS = sysv_init.c sysv_video.c sysv_io.c $(BIOS_MOD).c VTsw_usl.c \ sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) xqueue.c \ libc_wrapper.c stdResource.c stdPci.c vidmem.c sigiostubs.c pm_noop.c \ - kmod_noop.c + kmod_noop.c agp_noop.c OBJS = sysv_init.o sysv_video.o sysv_io.o $(BIOS_MOD).o VTsw_usl.o \ sysv_kbd.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) xqueue.o \ libc_wrapper.o stdResource.o stdPci.o vidmem.o sigiostubs.o pm_noop.o \ - kmod_noop.o + kmod_noop.o agp_noop.o INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi @@ -53,5 +53,6 @@ LinkSourceFile(sigiostubs.c,../shared) LinkSourceFile(pm_noop.c,../shared) LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) DependTarget() Index: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c diff -u xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c:3.19 xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c:3.20 --- xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c:3.19 Sat May 15 10:31:23 1999 +++ xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c Fri Oct 27 21:42:29 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.19 1999/05/15 14:31:23 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.20 2000/10/28 01:42:29 mvojkovi Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -138,7 +138,7 @@ } static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size) +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { pointer base; int fd; Index: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c diff -u xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c:1.9 xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c:1.14 --- xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c:1.9 Wed May 31 05:39:45 2000 +++ xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c Wed Dec 6 10:35:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c,v 1.9 2000/05/31 09:39:45 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c,v 1.14 2000/12/06 15:35:32 eich Exp $ */ #include "xf86.h" #include "xf86_ansic.h" @@ -38,13 +38,14 @@ int screen = pScrn->scrnIndex; if (!pInt) { - if (xf86LoadSubModule(pScrn, "int10")) { - xf86DrvMsg(screen,X_INFO,"initializing int10\n"); - pInt = xf86InitInt10(entityIndex); - if (!pInt) - goto error; - init_int10 = TRUE; - } + if (!xf86LoadSubModule(pScrn, "int10")) + goto error; + + xf86DrvMsg(screen,X_INFO,"initializing int10\n"); + pInt = xf86InitInt10(entityIndex); + if (!pInt) + goto error; + init_int10 = TRUE; } page = xf86Int10AllocPages(pInt,1,&RealOff); @@ -59,20 +60,23 @@ xf86ExecX86int10(pInt); - if ((pInt->ax & 0xff) != 0x4f) goto error; + if ((pInt->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n"); + goto error; + } switch (pInt->ax & 0xff00) { case 0: - xf86DrvMsg(screen,X_INFO,"VESA Bios detected\n"); + xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n"); break; case 0x100: - xf86DrvMsg(screen,X_INFO,"VESA Bios function failed\n"); + xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n"); goto error; case 0x200: - xf86DrvMsg(screen,X_INFO,"VESA Bios not supported\n"); + xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n"); goto error; case 0x300: - xf86DrvMsg(screen,X_INFO,"VESA Bios not supported in current mode\n"); + xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n"); goto error; default: xf86DrvMsg(screen,X_INFO,"Invalid\n"); @@ -118,6 +122,9 @@ void vbeFree(vbeInfoPtr pVbe) { + if (!pVbe) + return; + xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages); /* If we have initalized int10 we ought to free it, too */ if (pVbe->init_int10) @@ -156,19 +163,19 @@ xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n"); switch (pVbe->pInt10->bx & 0x3) { case 0: - ddc_level = "none"; + ddc_level = " none"; pVbe->ddc = DDC_NONE; break; case 1: - ddc_level = " 1 "; + ddc_level = " 1"; pVbe->ddc = DDC_1; break; case 2: - ddc_level = " 2 "; + ddc_level = " 2"; pVbe->ddc = DDC_2; break; case 3: - ddc_level = " 1 + 2 "; + ddc_level = " 1 + 2"; pVbe->ddc = DDC_1_2; break; default: @@ -176,7 +183,7 @@ pVbe->ddc = DDC_NONE; break; } - xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level %s\n",ddc_level); + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level); if (pVbe->pInt10->bx & 0x4) { xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked" "for data transfer\n"); @@ -231,18 +238,22 @@ xf86ExecX86int10(pVbe->pInt10); - if ((pVbe->pInt10->ax & 0xff) != 0x4f) + if ((pVbe->pInt10->ax & 0xff) != 0x4f) { + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n"); goto error; + } switch (pVbe->pInt10->ax & 0xff00) { - case 0: + case 0x0: xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n"); tmp = (unsigned char *)xnfalloc(128); memcpy(tmp,page,128); break; - case 1: + case 0x100: xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n"); break; default: + xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n", + pVbe->pInt10->ax & 0xff00); break; } @@ -281,3 +292,20 @@ xf86UnloadSubModule(pModule); return pMonitor; } + + +Bool +vbeModeInit(vbeInfoPtr pVbe, int mode) +{ + pVbe->pInt10->ax = 0x4F02; + pVbe->pInt10->bx = mode | (1 << 14); + xf86ExecX86int10(pVbe->pInt10); + + if ((pVbe->pInt10->ax & 0xff) != 0x4f) + return FALSE; + + return TRUE; + +} + + Index: xc/programs/Xserver/hw/xfree86/parser/Configint.h diff -u xc/programs/Xserver/hw/xfree86/parser/Configint.h:1.15 xc/programs/Xserver/hw/xfree86/parser/Configint.h:1.16 --- xc/programs/Xserver/hw/xfree86/parser/Configint.h:1.15 Tue Apr 4 15:25:20 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Configint.h Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.15 2000/04/04 19:25:20 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.16 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -94,11 +94,11 @@ }\ else\ {\ - ptr->field = (type) addListItem ((glp) ptr->field, (glp) p);\ + ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\ }\ } -#define Error(a,b) { xf86ParseError (a, b); CLEANUP (ptr); return NULL; } +#define Error(a,b) { xf86parseError (a, b); CLEANUP (ptr); return NULL; } /* * These are defines for error messages to promote consistency. Index: xc/programs/Xserver/hw/xfree86/parser/DRI.c diff -u xc/programs/Xserver/hw/xfree86/parser/DRI.c:1.6 xc/programs/Xserver/hw/xfree86/parser/DRI.c:1.8 --- xc/programs/Xserver/hw/xfree86/parser/DRI.c:1.6 Wed May 17 20:37:30 2000 +++ xc/programs/Xserver/hw/xfree86/parser/DRI.c Thu Nov 30 15:45:33 2000 @@ -24,7 +24,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/parser/DRI.c,v 1.6 2000/05/18 00:37:30 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/parser/DRI.c,v 1.8 2000/11/30 20:45:33 paulo Exp $ * */ @@ -43,26 +43,26 @@ {-1, ""}, }; -#define CLEANUP freeBuffersList +#define CLEANUP xf86freeBuffersList XF86ConfBuffersPtr -parseBuffers (void) +xf86parseBuffers (void) { parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec) - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("Buffers count expected", NULL); ptr->buf_count = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("Buffers size expected", NULL); ptr->buf_size = val.num; - if ((token = xf86GetToken (NULL)) == STRING) { + if ((token = xf86getToken (NULL)) == STRING) { ptr->buf_flags = val.str; } else { ptr->buf_flags = NULL; - xf86UnGetToken (token); + xf86unGetToken (token); } #ifdef DEBUG @@ -74,20 +74,20 @@ #undef CLEANUP -#define CLEANUP freeDRI +#define CLEANUP xf86freeDRI XF86ConfDRIPtr -parseDRISection (void) +xf86parseDRISection (void) { parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec); /* Zero is a valid value for this. */ ptr->dri_group = -1; - while ((token = xf86GetToken (DRITab)) != ENDSECTION) { + while ((token = xf86getToken (DRITab)) != ENDSECTION) { switch (token) { case GROUP: - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) ptr->dri_group_name = val.str; else if (token == NUMBER) ptr->dri_group = val.num; @@ -95,19 +95,19 @@ Error (GROUP_MSG, NULL); break; case MODE: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Mode"); ptr->dri_mode = val.num; break; case BUFFERS: - HANDLE_LIST (dri_buffers_lst, parseBuffers, + HANDLE_LIST (dri_buffers_lst, xf86parseBuffers, XF86ConfBuffersPtr); break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -122,7 +122,7 @@ #undef CLEANUP void -printDRISection (FILE * cf, XF86ConfDRIPtr ptr) +xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr) { XF86ConfBuffersPtr bufs; @@ -133,6 +133,8 @@ fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name); else if (ptr->dri_group >= 0) fprintf (cf, "\tGroup %d\n", ptr->dri_group); + if (ptr->dri_mode) + fprintf (cf, "\tMode 0%o\n", ptr->dri_mode); for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) { fprintf (cf, "\tBuffers %d %d", bufs->buf_count, bufs->buf_size); @@ -142,16 +144,17 @@ } void -freeDRI (XF86ConfDRIPtr ptr) +xf86freeDRI (XF86ConfDRIPtr ptr) { if (ptr == NULL) return; + xf86freeBuffersList (ptr->dri_buffers_lst); xf86conffree (ptr); } void -freeBuffersList (XF86ConfBuffersPtr ptr) +xf86freeBuffersList (XF86ConfBuffersPtr ptr) { XF86ConfBuffersPtr prev; Index: xc/programs/Xserver/hw/xfree86/parser/Device.c diff -u xc/programs/Xserver/hw/xfree86/parser/Device.c:1.15 xc/programs/Xserver/hw/xfree86/parser/Device.c:1.17 --- xc/programs/Xserver/hw/xfree86/parser/Device.c:1.15 Tue Jun 20 01:08:48 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Device.c Thu Nov 30 15:45:33 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.15 2000/06/20 05:08:48 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.17 2000/11/30 20:45:33 paulo Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -64,10 +64,10 @@ {-1, ""}, }; -#define CLEANUP freeDeviceList +#define CLEANUP xf86freeDeviceList XF86ConfDevicePtr -parseDeviceSection (void) +xf86parseDeviceSection (void) { int i; int has_ident = FALSE; @@ -77,55 +77,55 @@ ptr->dev_chipid = -1; ptr->dev_chiprev = -1; ptr->dev_irq = -1; - while ((token = xf86GetToken (DeviceTab)) != ENDSECTION) + while ((token = xf86getToken (DeviceTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->dev_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->dev_identifier = val.str; has_ident = TRUE; break; case VENDOR: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Vendor"); ptr->dev_vendor = val.str; break; case BOARD: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Board"); ptr->dev_board = val.str; break; case CHIPSET: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Chipset"); ptr->dev_chipset = val.str; break; case CARD: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Card"); ptr->dev_card = val.str; break; case DRIVER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Driver"); ptr->dev_driver = val.str; break; case RAMDAC: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Ramdac"); ptr->dev_ramdac = val.str; break; case DACSPEED: for (i = 0; i < CONF_MAXDACSPEEDS; i++) ptr->dev_dacSpeeds[i] = 0; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) { Error (DACSPEED_MSG, CONF_MAXDACSPEEDS); } @@ -134,99 +134,99 @@ ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5); for (i = 1; i < CONF_MAXDACSPEEDS; i++) { - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->dev_dacSpeeds[i] = (int) (val.realnum * 1000.0 + 0.5); else { - xf86UnGetToken (token); + xf86unGetToken (token); break; } } } break; case VIDEORAM: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "VideoRam"); ptr->dev_videoram = val.num; break; case BIOSBASE: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "BIOSBase"); ptr->dev_bios_base = val.num; break; case MEMBASE: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "MemBase"); ptr->dev_mem_base = val.num; break; case IOBASE: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "IOBase"); ptr->dev_io_base = val.num; break; case CLOCKCHIP: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "ClockChip"); ptr->dev_clockchip = val.str; break; case CHIPID: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "ChipID"); ptr->dev_chipid = val.num; break; case CHIPREV: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "ChipRev"); ptr->dev_chiprev = val.num; break; case CLOCKS: - token = xf86GetToken(NULL); + token = xf86getToken(NULL); for( i = ptr->dev_clocks; token == NUMBER && i < CONF_MAXCLOCKS; i++ ) { ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5); - token = xf86GetToken(NULL); + token = xf86getToken(NULL); } ptr->dev_clocks = i; - xf86UnGetToken (token); + xf86unGetToken (token); break; case TEXTCLOCKFRQ: - if ((token = xf86GetToken(NULL)) != NUMBER) + if ((token = xf86getToken(NULL)) != NUMBER) Error (NUMBER_MSG, "TextClockFreq"); ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5); break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->dev_option_lst = addNewOption (ptr->dev_option_lst, + ptr->dev_option_lst = xf86addNewOption (ptr->dev_option_lst, name, val.str); } else { - ptr->dev_option_lst = addNewOption (ptr->dev_option_lst, + ptr->dev_option_lst = xf86addNewOption (ptr->dev_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; case BUSID: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "BusID"); ptr->dev_busid = val.str; break; case IRQ: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (QUOTE_MSG, "IRQ"); ptr->dev_irq = val.num; break; case SCREEN: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Screen"); ptr->dev_screen = val.num; break; @@ -234,7 +234,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -252,7 +252,7 @@ #undef CLEANUP void -printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr) +xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr) { XF86OptionPtr optr; int i; @@ -318,7 +318,7 @@ if (ptr->dev_busid) fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid); if (ptr->dev_screen > 0) - fprintf (cf, "\tScreen \"%d\"\n", ptr->dev_screen); + fprintf (cf, "\tScreen %d\n", ptr->dev_screen); if (ptr->dev_irq >= 0) fprintf (cf, "\tIRQ %d\n", ptr->dev_irq); fprintf (cf, "EndSection\n\n"); @@ -327,7 +327,7 @@ } void -freeDeviceList (XF86ConfDevicePtr ptr) +xf86freeDeviceList (XF86ConfDevicePtr ptr) { XF86ConfDevicePtr prev; @@ -341,7 +341,7 @@ TestFree (ptr->dev_driver); TestFree (ptr->dev_ramdac); TestFree (ptr->dev_clockchip); - OptionListFree (ptr->dev_option_lst); + xf86optionListFree (ptr->dev_option_lst); prev = ptr; ptr = ptr->list.next; @@ -350,18 +350,18 @@ } int -validateDevice (XF86ConfigPtr p) +xf86validateDevice (XF86ConfigPtr p) { XF86ConfDevicePtr device = p->conf_device_lst; if (!device) { - xf86ValidationError ("At least one Device section is required."); + xf86validationError ("At least one Device section is required."); return (FALSE); } while (device) { if (!device->dev_driver) { - xf86ValidationError (UNDEFINED_DRIVER_MSG, device->dev_identifier); + xf86validationError (UNDEFINED_DRIVER_MSG, device->dev_identifier); return (FALSE); } device = device->list.next; @@ -370,11 +370,11 @@ } XF86ConfDevicePtr -xf86FindDevice (const char *ident, XF86ConfDevicePtr p) +xf86findDevice (const char *ident, XF86ConfDevicePtr p) { while (p) { - if (NameCompare (ident, p->dev_identifier) == 0) + if (xf86nameCompare (ident, p->dev_identifier) == 0) return (p); p = p->list.next; @@ -383,7 +383,7 @@ } char * -ConfigStrdup (const char *s) +xf86configStrdup (const char *s) { char *tmp = xf86confmalloc (sizeof (char) * (strlen (s) + 1)); if (tmp) Index: xc/programs/Xserver/hw/xfree86/parser/Files.c diff -u xc/programs/Xserver/hw/xfree86/parser/Files.c:1.7 xc/programs/Xserver/hw/xfree86/parser/Files.c:1.8 --- xc/programs/Xserver/hw/xfree86/parser/Files.c:1.7 Tue Jan 25 21:00:51 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Files.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Files.c,v 1.7 2000/01/26 02:00:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Files.c,v 1.8 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -58,27 +58,27 @@ #endif } -#define CLEANUP freeFiles +#define CLEANUP xf86freeFiles XF86ConfFilesPtr -parseFilesSection (void) +xf86parseFilesSection (void) { int i, j; int k, l; char *str; parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) - while ((token = xf86GetToken (FilesTab)) != ENDSECTION) + while ((token = xf86getToken (FilesTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->file_comment = val.str; break; case FONTPATH: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "FontPath"); j = FALSE; str = prependRoot (val.str); @@ -106,12 +106,12 @@ xf86conffree (val.str); break; case RGBPATH: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "RGBPath"); ptr->file_rgbpath = val.str; break; case MODULEPATH: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "ModulePath"); l = FALSE; str = prependRoot (val.str); @@ -138,7 +138,7 @@ xf86conffree (val.str); break; case LOGFILEPATH: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "LogFile"); ptr->file_logfile = val.str; break; @@ -146,7 +146,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -161,7 +161,7 @@ #undef CLEANUP void -printFileSection (FILE * cf, XF86ConfFilesPtr ptr) +xf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr) { char *p, *s; @@ -207,7 +207,7 @@ } void -freeFiles (XF86ConfFilesPtr p) +xf86freeFiles (XF86ConfFilesPtr p) { if (p == NULL) return; Index: xc/programs/Xserver/hw/xfree86/parser/Flags.c diff -u xc/programs/Xserver/hw/xfree86/parser/Flags.c:1.12 xc/programs/Xserver/hw/xfree86/parser/Flags.c:1.14 --- xc/programs/Xserver/hw/xfree86/parser/Flags.c:1.12 Tue Apr 4 18:36:53 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Flags.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.12 2000/04/04 22:36:53 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.14 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -57,14 +57,14 @@ {-1, ""}, }; -#define CLEANUP freeFlags +#define CLEANUP xf86freeFlags XF86ConfFlagsPtr -parseFlagsSection (void) +xf86parseFlagsSection (void) { parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) - while ((token = xf86GetToken (ServerFlagsTab)) != ENDSECTION) + while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION) { int hasvalue = FALSE; int strvalue = FALSE; @@ -72,7 +72,7 @@ switch (token) { case COMMENT: - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (QUOTE_MSG, "###"); break; /* @@ -104,10 +104,10 @@ { char *valstr = NULL; /* can't use strdup because it calls malloc */ - tmp = ConfigStrdup (ServerFlagsTab[i].name); + tmp = xf86configStrdup (ServerFlagsTab[i].name); if (hasvalue) { - tokentype = xf86GetToken(NULL); + tokentype = xf86getToken(NULL); if (strvalue) { if (tokentype != STRING) Error (QUOTE_MSG, tmp); @@ -120,7 +120,7 @@ sprintf(valstr, "%d", val.num); } } - ptr->flg_option_lst = addNewOption + ptr->flg_option_lst = xf86addNewOption (ptr->flg_option_lst, tmp, valstr); } i++; @@ -130,23 +130,23 @@ case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) { Error (BAD_OPTION_MSG, NULL); break; } name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->flg_option_lst = addNewOption (ptr->flg_option_lst, + ptr->flg_option_lst = xf86addNewOption (ptr->flg_option_lst, name, val.str); } else { - ptr->flg_option_lst = addNewOption (ptr->flg_option_lst, + ptr->flg_option_lst = xf86addNewOption (ptr->flg_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -155,7 +155,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -170,7 +170,7 @@ #undef CLEANUP void -printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags) +xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags) { XF86OptionPtr p; @@ -194,47 +194,49 @@ static XF86OptionPtr addNewOption2 (XF86OptionPtr head, char *name, char *val, int used) { - XF86OptionPtr new, old = NULL; + XF86OptionPtr new, old = NULL; /* Don't allow duplicates */ - if (head != NULL && (old = FindOption(head, name)) != NULL) - new = old; - else - new = xf86confcalloc (1, sizeof (XF86OptionRec)); - new->opt_name = name; - new->opt_val = val; - new->opt_used = used; - new->list.next = NULL; - - if (old == NULL) - return ((XF86OptionPtr) addListItem ((glp) head, (glp) new)); - else - return head; + if (head != NULL && (old = xf86findOption(head, name)) != NULL) + new = old; + else { + new = xf86confcalloc (1, sizeof (XF86OptionRec)); + new->list.next = NULL; + } + + new->opt_name = name; + new->opt_val = val; + new->opt_used = used; + + if (old == NULL) + return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new)); + else + return head; } XF86OptionPtr -addNewOption (XF86OptionPtr head, char *name, char *val) +xf86addNewOption (XF86OptionPtr head, char *name, char *val) { return addNewOption2(head, name, val, 0); } void -freeFlags (XF86ConfFlagsPtr flags) +xf86freeFlags (XF86ConfFlagsPtr flags) { if (flags == NULL) return; - OptionListFree (flags->flg_option_lst); + xf86optionListFree (flags->flg_option_lst); xf86conffree (flags); } XF86OptionPtr -OptionListDup (XF86OptionPtr opt) +xf86optionListDup (XF86OptionPtr opt) { XF86OptionPtr newopt = NULL; while (opt) { - newopt = addNewOption(newopt, opt->opt_name, opt->opt_val); + newopt = xf86addNewOption(newopt, opt->opt_name, opt->opt_val); newopt->opt_used = opt->opt_used; opt = opt->list.next; } @@ -242,7 +244,7 @@ } void -OptionListFree (XF86OptionPtr opt) +xf86optionListFree (XF86OptionPtr opt) { XF86OptionPtr prev; @@ -257,7 +259,7 @@ } char * -OptionName(XF86OptionPtr opt) +xf86optionName(XF86OptionPtr opt) { if (opt) return opt->opt_name; @@ -265,7 +267,7 @@ } char * -OptionValue(XF86OptionPtr opt) +xf86optionValue(XF86OptionPtr opt) { if (opt) return opt->opt_val; @@ -273,7 +275,7 @@ } XF86OptionPtr -NewOption(char *name, char *value) +xf86newOption(char *name, char *value) { XF86OptionPtr opt; @@ -290,7 +292,7 @@ } XF86OptionPtr -NextOption(XF86OptionPtr list) +xf86nextOption(XF86OptionPtr list) { if (!list) return NULL; @@ -304,11 +306,11 @@ */ XF86OptionPtr -FindOption (XF86OptionPtr list, const char *name) +xf86findOption (XF86OptionPtr list, const char *name) { while (list) { - if (NameCompare (list->opt_name, name) == 0) + if (xf86nameCompare (list->opt_name, name) == 0) return (list); list = list->list.next; } @@ -323,9 +325,9 @@ */ char * -FindOptionValue (XF86OptionPtr list, const char *name) +xf86findOptionValue (XF86OptionPtr list, const char *name) { - XF86OptionPtr p = FindOption (list, name); + XF86OptionPtr p = xf86findOption (list, name); if (p) { @@ -338,7 +340,7 @@ } XF86OptionPtr -OptionListCreate( const char **options, int count, int used ) +xf86optionListCreate( const char **options, int count, int used ) { XF86OptionPtr p = NULL; char *t1, *t2; @@ -351,7 +353,7 @@ } if( (count % 2) != 0 ) { - fprintf( stderr, "OptionListCreate: count must be an even number.\n" ); + fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" ); return (NULL); } for (i = 0; i < count; i += 2) @@ -375,7 +377,7 @@ * longer guaranteed to be complete. */ XF86OptionPtr -OptionListMerge (XF86OptionPtr head, XF86OptionPtr tail) +xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail) { XF86OptionPtr a, b, ap = NULL, bp = NULL, f = NULL; @@ -386,7 +388,7 @@ b = tail; while (b) { - if (NameCompare (a->opt_name, b->opt_name) == 0) + if (xf86nameCompare (a->opt_name, b->opt_name) == 0) { if ((a == head) && (b == tail)) { @@ -429,12 +431,12 @@ ap->list.next = tail; - OptionListFree (f); + xf86optionListFree (f); return (head); } char * -ULongToString(unsigned long i) +xf86uLongToString(unsigned long i) { char *s; int l; @@ -445,5 +447,14 @@ return NULL; sprintf(s, "%lu", i); return s; +} + +void +xf86debugListOptions(XF86OptionPtr Options) +{ + while (Options) { + ErrorF("Option: %s Value: %s\n",Options->opt_name,Options->opt_val); + Options = Options->list.next; + } } Index: xc/programs/Xserver/hw/xfree86/parser/Input.c diff -u xc/programs/Xserver/hw/xfree86/parser/Input.c:1.4 xc/programs/Xserver/hw/xfree86/parser/Input.c:1.5 --- xc/programs/Xserver/hw/xfree86/parser/Input.c:1.4 Tue Jan 25 21:00:51 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Input.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Input.c,v 1.4 2000/01/26 02:00:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Input.c,v 1.5 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -46,50 +46,50 @@ {-1, ""}, }; -#define CLEANUP freeInputList +#define CLEANUP xf86freeInputList XF86ConfInputPtr -parseInputSection (void) +xf86parseInputSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) - while ((token = xf86GetToken (InputTab)) != ENDSECTION) + while ((token = xf86getToken (InputTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->inp_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->inp_identifier = val.str; has_ident = TRUE; break; case DRIVER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Driver"); ptr->inp_driver = val.str; break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->inp_option_lst = addNewOption (ptr->inp_option_lst, + ptr->inp_option_lst = xf86addNewOption (ptr->inp_option_lst, name, val.str); } else { - ptr->inp_option_lst = addNewOption (ptr->inp_option_lst, + ptr->inp_option_lst = xf86addNewOption (ptr->inp_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -97,7 +97,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -115,7 +115,7 @@ #undef CLEANUP void -printInputSection (FILE * cf, XF86ConfInputPtr ptr) +xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr) { XF86OptionPtr optr; @@ -141,7 +141,7 @@ } void -freeInputList (XF86ConfInputPtr ptr) +xf86freeInputList (XF86ConfInputPtr ptr) { XF86ConfInputPtr prev; @@ -149,7 +149,7 @@ { TestFree (ptr->inp_identifier); TestFree (ptr->inp_driver); - OptionListFree (ptr->inp_option_lst); + xf86optionListFree (ptr->inp_option_lst); prev = ptr; ptr = ptr->list.next; @@ -158,20 +158,20 @@ } int -validateInput (XF86ConfigPtr p) +xf86validateInput (XF86ConfigPtr p) { XF86ConfInputPtr input = p->conf_input_lst; #if 0 /* Enable this later */ if (!input) { - xf86ValidationError ("At least one InputDevice section is required."); + xf86validationError ("At least one InputDevice section is required."); return (FALSE); } #endif while (input) { if (!input->inp_driver) { - xf86ValidationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier); + xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier); return (FALSE); } input = input->list.next; @@ -180,11 +180,11 @@ } XF86ConfInputPtr -xf86FindInput (const char *ident, XF86ConfInputPtr p) +xf86findInput (const char *ident, XF86ConfInputPtr p) { while (p) { - if (NameCompare (ident, p->inp_identifier) == 0) + if (xf86nameCompare (ident, p->inp_identifier) == 0) return (p); p = p->list.next; @@ -193,11 +193,11 @@ } XF86ConfInputPtr -xf86FindInputByDriver (const char *driver, XF86ConfInputPtr p) +xf86findInputByDriver (const char *driver, XF86ConfInputPtr p) { while (p) { - if (NameCompare (driver, p->inp_driver) == 0) + if (xf86nameCompare (driver, p->inp_driver) == 0) return (p); p = p->list.next; Index: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c diff -u xc/programs/Xserver/hw/xfree86/parser/Keyboard.c:1.9 xc/programs/Xserver/hw/xfree86/parser/Keyboard.c:1.10 --- xc/programs/Xserver/hw/xfree86/parser/Keyboard.c:1.9 Sat Sep 4 09:04:53 1999 +++ xc/programs/Xserver/hw/xfree86/parser/Keyboard.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c,v 1.9 1999/09/04 13:04:53 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c,v 1.10 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -80,188 +80,188 @@ {-1, ""}, }; -#define CLEANUP freeInputList +#define CLEANUP xf86freeInputList XF86ConfInputPtr -parseKeyboardSection (void) +xf86parseKeyboardSection (void) { char *s, *s1, *s2; int l; int ntoken; parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) - while ((token = xf86GetToken (KeyboardTab)) != ENDSECTION) + while ((token = xf86getToken (KeyboardTab)) != ENDSECTION) { switch (token) { case KPROTOCOL: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Protocol"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Protocol"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Protocol"), val.str); break; case AUTOREPEAT: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (AUTOREPEAT_MSG, NULL); - s1 = ULongToString(val.num); - if (xf86GetToken (NULL) != NUMBER) + s1 = xf86uLongToString(val.num); + if (xf86getToken (NULL) != NUMBER) Error (AUTOREPEAT_MSG, NULL); - s2 = ULongToString(val.num); + s2 = xf86uLongToString(val.num); l = strlen(s1) + 1 + strlen(s2) + 1; s = xf86confmalloc(l); sprintf(s, "%s %s", s1, s2); xf86conffree(s1); xf86conffree(s2); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("AutoRepeat"), s); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("AutoRepeat"), s); break; case XLEDS: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (XLEDS_MSG, NULL); - s = ULongToString(val.num); + s = xf86uLongToString(val.num); l = strlen(s) + 1; - while ((token = xf86GetToken (NULL)) == NUMBER) + while ((token = xf86getToken (NULL)) == NUMBER) { - s1 = ULongToString(val.num); + s1 = xf86uLongToString(val.num); l += (1 + strlen(s1)); s = xf86confrealloc(s, l); strcat(s, " "); strcat(s, s1); xf86conffree(s1); } - xf86UnGetToken (token); + xf86unGetToken (token); break; case SERVERNUM: - xf86ParseWarning(OBSOLETE_MSG, xf86TokenString()); + xf86parseWarning(OBSOLETE_MSG, xf86tokenString()); break; case LEFTALT: case RIGHTALT: case SCROLLLOCK_TOK: case RIGHTCTL: - xf86ParseWarning(OBSOLETE_MSG, xf86TokenString()); + xf86parseWarning(OBSOLETE_MSG, xf86tokenString()); break; - ntoken = xf86GetToken (KeyMapTab); + ntoken = xf86getToken (KeyMapTab); switch (ntoken) { case EOF_TOKEN: - xf86ParseError (UNEXPECTED_EOF_MSG); + xf86parseError (UNEXPECTED_EOF_MSG); CLEANUP (ptr); return (NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } break; case VTINIT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "VTInit"); - xf86ParseWarning(MOVED_TO_FLAGS_MSG, "VTInit"); + xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit"); break; case VTSYSREQ: - xf86ParseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq"); + xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq"); break; case XKBDISABLE: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbDisable"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbDisable"), NULL); break; case XKBKEYMAP: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBKeymap"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbKeymap"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbKeymap"), val.str); break; case XKBCOMPAT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBCompat"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbCompat"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbCompat"), val.str); break; case XKBTYPES: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBTypes"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbTypes"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbTypes"), val.str); break; case XKBKEYCODES: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBKeycodes"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbKeycodes"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbKeycodes"), val.str); break; case XKBGEOMETRY: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBGeometry"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbGeometry"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbGeometry"), val.str); break; case XKBSYMBOLS: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBSymbols"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbSymbols"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbSymbols"), val.str); break; case XKBRULES: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBRules"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbRules"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbRules"), val.str); break; case XKBMODEL: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBModel"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbModel"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbModel"), val.str); break; case XKBLAYOUT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBLayout"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbLayout"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbLayout"), val.str); break; case XKBVARIANT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBVariant"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbVariant"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbVariant"), val.str); break; case XKBOPTIONS: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "XKBOptions"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("XkbOptions"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("XkbOptions"), val.str); break; case PANIX106: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Panix106"), NULL); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Panix106"), NULL); break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } - ptr->inp_identifier = ConfigStrdup(CONF_IMPLICIT_KEYBOARD); - ptr->inp_driver = ConfigStrdup("keyboard"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("CoreKeyboard"), NULL); + ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD); + ptr->inp_driver = xf86configStrdup("keyboard"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("CoreKeyboard"), NULL); #ifdef DEBUG printf ("Keyboard section parsed\n"); Index: xc/programs/Xserver/hw/xfree86/parser/Layout.c diff -u xc/programs/Xserver/hw/xfree86/parser/Layout.c:1.12 xc/programs/Xserver/hw/xfree86/parser/Layout.c:1.13 --- xc/programs/Xserver/hw/xfree86/parser/Layout.c:1.12 Tue Apr 4 18:36:54 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Layout.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.12 2000/04/04 22:36:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.13 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -58,25 +58,25 @@ {-1, ""}, }; -#define CLEANUP freeLayoutList +#define CLEANUP xf86freeLayoutList XF86ConfLayoutPtr -parseLayoutSection (void) +xf86parseLayoutSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) - while ((token = xf86GetToken (LayoutTab)) != ENDSECTION) + while ((token = xf86getToken (LayoutTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->lay_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->lay_identifier = val.str; has_ident = TRUE; @@ -87,11 +87,11 @@ iptr = xf86confcalloc (1, sizeof (XF86ConfInactiveRec)); iptr->list.next = NULL; - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (INACTIVE_MSG, NULL); iptr->inactive_device_str = val.str; ptr->lay_inactive_lst = (XF86ConfInactivePtr) - addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr); + xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr); } break; case SCREEN: @@ -105,16 +105,16 @@ aptr->adj_x = 0; aptr->adj_y = 0; aptr->adj_refscreen = NULL; - if ((token = xf86GetToken (NULL)) == NUMBER) + if ((token = xf86getToken (NULL)) == NUMBER) aptr->adj_scrnum = val.num; else - xf86UnGetToken (token); - token = xf86GetToken(NULL); + xf86unGetToken (token); + token = xf86getToken(NULL); if (token != STRING) Error (SCREEN_MSG, NULL); aptr->adj_screen_str = val.str; - token = xf86GetToken(AdjTab); + token = xf86getToken(AdjTab); switch (token) { case RIGHTOF: @@ -136,8 +136,8 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - xf86UnGetToken (token); - token = xf86GetToken(NULL); + xf86unGetToken (token); + token = xf86getToken(NULL); if (token == STRING) aptr->adj_where = CONF_ADJ_OBSOLETE; else @@ -149,29 +149,29 @@ if (token == NUMBER) { aptr->adj_x = val.num; - token = xf86GetToken(NULL); + token = xf86getToken(NULL); if (token != NUMBER) Error(INVALID_SCR_MSG, NULL); aptr->adj_y = val.num; } else - xf86UnGetToken (token); + xf86unGetToken (token); break; case CONF_ADJ_RIGHTOF: case CONF_ADJ_LEFTOF: case CONF_ADJ_ABOVE: case CONF_ADJ_BELOW: case CONF_ADJ_RELATIVE: - token = xf86GetToken(NULL); + token = xf86getToken(NULL); if (token != STRING) Error(INVALID_SCR_MSG, NULL); aptr->adj_refscreen = val.str; if (aptr->adj_where == CONF_ADJ_RELATIVE) { - token = xf86GetToken(NULL); + token = xf86getToken(NULL); if (token != NUMBER) Error(INVALID_SCR_MSG, NULL); aptr->adj_x = val.num; - token = xf86GetToken(NULL); + token = xf86getToken(NULL); if (token != NUMBER) Error(INVALID_SCR_MSG, NULL); aptr->adj_y = val.num; @@ -182,23 +182,23 @@ aptr->adj_top_str = val.str; /* bottom */ - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (SCREEN_MSG, NULL); aptr->adj_bottom_str = val.str; /* left */ - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (SCREEN_MSG, NULL); aptr->adj_left_str = val.str; /* right */ - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (SCREEN_MSG, NULL); aptr->adj_right_str = val.str; } ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr) - addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr); + xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr); } break; case INPUTDEVICE: @@ -208,37 +208,37 @@ iptr = xf86confcalloc (1, sizeof (XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (INPUTDEV_MSG, NULL); iptr->iref_inputdev_str = val.str; - while ((token = xf86GetToken (NULL)) == STRING) + while ((token = xf86getToken (NULL)) == STRING) { iptr->iref_option_lst = - addNewOption (iptr->iref_option_lst, val.str, NULL); + xf86addNewOption (iptr->iref_option_lst, val.str, NULL); } - xf86UnGetToken (token); + xf86unGetToken (token); ptr->lay_input_lst = (XF86ConfInputrefPtr) - addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); } break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { ptr->lay_option_lst = - addNewOption (ptr->lay_option_lst, + xf86addNewOption (ptr->lay_option_lst, name, val.str); } else { ptr->lay_option_lst = - addNewOption (ptr->lay_option_lst, + xf86addNewOption (ptr->lay_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -246,7 +246,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -264,7 +264,7 @@ #undef CLEANUP void -printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr) +xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr) { XF86ConfAdjacencyPtr aptr; XF86ConfInactivePtr iptr; @@ -343,15 +343,15 @@ } void -freeLayoutList (XF86ConfLayoutPtr ptr) +xf86freeLayoutList (XF86ConfLayoutPtr ptr) { XF86ConfLayoutPtr prev; while (ptr) { TestFree (ptr->lay_identifier); - freeAdjacencyList (ptr->lay_adjacency_lst); - freeInputrefList (ptr->lay_input_lst); + xf86freeAdjacencyList (ptr->lay_adjacency_lst); + xf86freeInputrefList (ptr->lay_input_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -359,7 +359,7 @@ } void -freeAdjacencyList (XF86ConfAdjacencyPtr ptr) +xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr) { XF86ConfAdjacencyPtr prev; @@ -379,14 +379,14 @@ } void -freeInputrefList (XF86ConfInputrefPtr ptr) +xf86freeInputrefList (XF86ConfInputrefPtr ptr) { XF86ConfInputrefPtr prev; while (ptr) { TestFree (ptr->iref_inputdev_str); - OptionListFree (ptr->iref_option_lst); + xf86optionListFree (ptr->iref_option_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -397,10 +397,10 @@ #define CheckScreen(str, ptr)\ if (str[0] != '\0') \ { \ -screen = xf86FindScreen (str, p->conf_screen_lst); \ +screen = xf86findScreen (str, p->conf_screen_lst); \ if (!screen) \ { \ - xf86ValidationError (UNDEFINED_SCREEN_MSG, \ + xf86validationError (UNDEFINED_SCREEN_MSG, \ str, layout->lay_identifier); \ return (FALSE); \ } \ @@ -409,7 +409,7 @@ } int -validateLayout (XF86ConfigPtr p) +xf86validateLayout (XF86ConfigPtr p) { XF86ConfLayoutPtr layout = p->conf_layout_lst; XF86ConfAdjacencyPtr adj; @@ -425,10 +425,10 @@ while (adj) { /* the first one can't be "" but all others can */ - screen = xf86FindScreen (adj->adj_screen_str, p->conf_screen_lst); + screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst); if (!screen) { - xf86ValidationError (UNDEFINED_SCREEN_MSG, + xf86validationError (UNDEFINED_SCREEN_MSG, adj->adj_screen_str, layout->lay_identifier); return (FALSE); } @@ -447,11 +447,11 @@ iptr = layout->lay_inactive_lst; while (iptr) { - device = xf86FindDevice (iptr->inactive_device_str, + device = xf86findDevice (iptr->inactive_device_str, p->conf_device_lst); if (!device) { - xf86ValidationError (UNDEFINED_DEVICE_LAY_MSG, + xf86validationError (UNDEFINED_DEVICE_LAY_MSG, iptr->inactive_device_str, layout->lay_identifier); return (FALSE); } @@ -462,11 +462,11 @@ inptr = layout->lay_input_lst; while (inptr) { - input = xf86FindInput (inptr->iref_inputdev_str, + input = xf86findInput (inptr->iref_inputdev_str, p->conf_input_lst); if (!input) { - xf86ValidationError (UNDEFINED_INPUT_MSG, + xf86validationError (UNDEFINED_INPUT_MSG, inptr->iref_inputdev_str, layout->lay_identifier); return (FALSE); } @@ -480,11 +480,11 @@ } XF86ConfLayoutPtr -xf86FindLayout (const char *name, XF86ConfLayoutPtr list) +xf86findLayout (const char *name, XF86ConfLayoutPtr list) { while (list) { - if (NameCompare (list->lay_identifier, name) == 0) + if (xf86nameCompare (list->lay_identifier, name) == 0) return (list); list = list->list.next; } Index: xc/programs/Xserver/hw/xfree86/parser/Module.c diff -u xc/programs/Xserver/hw/xfree86/parser/Module.c:1.5 xc/programs/Xserver/hw/xfree86/parser/Module.c:1.6 --- xc/programs/Xserver/hw/xfree86/parser/Module.c:1.5 Tue Apr 4 18:36:54 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Module.c Fri Oct 20 10:59:02 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.5 2000/04/04 22:36:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.6 2000/10/20 14:59:02 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -51,10 +51,10 @@ {-1, ""}, }; -#define CLEANUP freeModules +#define CLEANUP xf86freeModules XF86LoadPtr -parseModuleSubSection (XF86LoadPtr head, char *name) +xf86parseModuleSubSection (XF86LoadPtr head, char *name) { parsePrologue (XF86LoadPtr, XF86LoadRec) @@ -63,40 +63,40 @@ ptr->load_opt = NULL; ptr->list.next = NULL; - while ((token = xf86GetToken (SubModuleTab)) != ENDSUBSECTION) + while ((token = xf86getToken (SubModuleTab)) != ENDSUBSECTION) { switch (token) { case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) { - xf86ParseError (BAD_OPTION_MSG, NULL); + xf86parseError (BAD_OPTION_MSG, NULL); xf86conffree(ptr); return NULL; } name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->load_opt = addNewOption (ptr->load_opt, + ptr->load_opt = xf86addNewOption (ptr->load_opt, name, val.str); } else { - ptr->load_opt = addNewOption (ptr->load_opt, + ptr->load_opt = xf86addNewOption (ptr->load_opt, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; case EOF_TOKEN: - xf86ParseError (UNEXPECTED_EOF_MSG, NULL); + xf86parseError (UNEXPECTED_EOF_MSG, NULL); xf86conffree(ptr); return NULL; break; default: - xf86ParseError (INVALID_KEYWORD_MSG, xf86TokenString ()); + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); xf86conffree(ptr); return NULL; break; @@ -104,43 +104,43 @@ } - return ((XF86LoadPtr) addListItem ((glp) head, (glp) ptr)); + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) ptr)); } XF86ConfModulePtr -parseModuleSection (void) +xf86parseModuleSection (void) { parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec) - while ((token = xf86GetToken (ModuleTab)) != ENDSECTION) + while ((token = xf86getToken (ModuleTab)) != ENDSECTION) { switch (token) { case LOAD: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Load"); ptr->mod_load_lst = - addNewLoadDirective (ptr->mod_load_lst, val.str, + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, XF86_LOAD_MODULE, NULL); break; case LOAD_DRIVER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "LoadDriver"); ptr->mod_load_lst = - addNewLoadDirective (ptr->mod_load_lst, val.str, + xf86addNewLoadDirective (ptr->mod_load_lst, val.str, XF86_LOAD_DRIVER, NULL); break; case SUBSECTION: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "SubSection"); ptr->mod_load_lst = - parseModuleSubSection (ptr->mod_load_lst, val.str); + xf86parseModuleSubSection (ptr->mod_load_lst, val.str); break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -155,7 +155,7 @@ #undef CLEANUP void -printModuleSection (FILE * cf, XF86ConfModulePtr ptr) +xf86printModuleSection (FILE * cf, XF86ConfModulePtr ptr) { XF86LoadPtr lptr; @@ -194,7 +194,7 @@ } XF86LoadPtr -addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts) +xf86addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts) { XF86LoadPtr new; @@ -204,11 +204,11 @@ new->load_opt = opts; new->list.next = NULL; - return ((XF86LoadPtr) addListItem ((glp) head, (glp) new)); + return ((XF86LoadPtr) xf86addListItem ((glp) head, (glp) new)); } void -freeModules (XF86ConfModulePtr ptr) +xf86freeModules (XF86ConfModulePtr ptr) { XF86LoadPtr lptr; XF86LoadPtr prev; Index: xc/programs/Xserver/hw/xfree86/parser/Monitor.c diff -u xc/programs/Xserver/hw/xfree86/parser/Monitor.c:1.13 xc/programs/Xserver/hw/xfree86/parser/Monitor.c:1.18 --- xc/programs/Xserver/hw/xfree86/parser/Monitor.c:1.13 Tue Apr 4 18:36:54 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Monitor.c Tue Dec 5 14:06:53 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.13 2000/04/04 22:36:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.18 2000/12/05 19:06:53 paulo Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -74,6 +74,7 @@ {TT_NCSYNC, "-csync"}, {TT_DBLSCAN, "doublescan"}, {TT_HSKEW, "hskew"}, + {TT_BCAST, "bcast"}, {TT_VSCAN, "vscan"}, {TT_CUSTOM, "CUSTOM"}, {-1, ""}, @@ -86,75 +87,76 @@ {VTIMINGS, "vtimings"}, {FLAGS, "flags"}, {HSKEW, "hskew"}, + {BCAST, "bcast"}, {VSCAN, "vscan"}, {ENDMODE, "endmode"}, {-1, ""}, }; -#define CLEANUP freeModeLineList +#define CLEANUP xf86freeModeLineList XF86ConfModeLinePtr -parseModeLine (void) +xf86parseModeLine (void) { parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) /* Identifier */ - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error ("ModeLine identifier expected", NULL); ptr->ml_identifier = val.str; /* DotClock */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine dotclock expected", NULL); ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); /* HDisplay */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine Hdisplay expected", NULL); ptr->ml_hdisplay = val.num; /* HSyncStart */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine HSyncStart expected", NULL); ptr->ml_hsyncstart = val.num; /* HSyncEnd */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine HSyncEnd expected", NULL); ptr->ml_hsyncend = val.num; /* HTotal */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine HTotal expected", NULL); ptr->ml_htotal = val.num; /* VDisplay */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine Vdisplay expected", NULL); ptr->ml_vdisplay = val.num; /* VSyncStart */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine VSyncStart expected", NULL); ptr->ml_vsyncstart = val.num; /* VSyncEnd */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine VSyncEnd expected", NULL); ptr->ml_vsyncend = val.num; /* VTotal */ - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("ModeLine VTotal expected", NULL); ptr->ml_vtotal = val.num; - token = xf86GetToken (TimingTab); + token = xf86getToken (TimingTab); while ((token == TT_INTERLACE) || (token == TT_PHSYNC) || (token == TT_NHSYNC) || (token == TT_PVSYNC) || (token == TT_NVSYNC) || (token == TT_CSYNC) || (token == TT_PCSYNC) || (token == TT_NCSYNC) || (token == TT_DBLSCAN) || (token == TT_HSKEW) || - (token == TT_VSCAN)) + (token == TT_VSCAN) || (token == TT_BCAST)) { switch (token) { @@ -187,15 +189,19 @@ ptr->ml_flags |= XF86CONF_DBLSCAN; break; case TT_HSKEW: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Hskew"); ptr->ml_hskew = val.num; ptr->ml_flags |= XF86CONF_HSKEW; break; + case TT_BCAST: + ptr->ml_flags |= XF86CONF_BCAST; + break; case TT_VSCAN: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Vscan"); ptr->ml_vscan = val.num; + ptr->ml_flags |= XF86CONF_VSCAN; break; case TT_CUSTOM: ptr->ml_flags |= XF86CONF_CUSTOM; @@ -204,12 +210,12 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } - token = xf86GetToken (TimingTab); + token = xf86getToken (TimingTab); } - xf86UnGetToken (token); + xf86unGetToken (token); #ifdef DEBUG printf ("ModeLine parsed\n"); @@ -218,76 +224,76 @@ } XF86ConfModeLinePtr -parseVerboseMode (void) +xf86parseVerboseMode (void) { int token2; int had_dotclock = 0, had_htimings = 0, had_vtimings = 0; parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec) - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error ("Mode name expected", NULL); ptr->ml_identifier = val.str; - while ((token = xf86GetToken (ModeTab)) != ENDMODE) + while ((token = xf86getToken (ModeTab)) != ENDMODE) { switch (token) { case DOTCLOCK: - if ((token = xf86GetToken (NULL)) != NUMBER) + if ((token = xf86getToken (NULL)) != NUMBER) Error (NUMBER_MSG, "DotClock"); ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5); had_dotclock = 1; break; case HTIMINGS: - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_hdisplay = val.num; else Error ("Horizontal display expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_hsyncstart = val.num; else Error ("Horizontal sync start expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_hsyncend = val.num; else Error ("Horizontal sync end expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_htotal = val.num; else Error ("Horizontal total expected", NULL); had_htimings = 1; break; case VTIMINGS: - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_vdisplay = val.num; else Error ("Vertical display expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_vsyncstart = val.num; else Error ("Vertical sync start expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_vsyncend = val.num; else Error ("Vertical sync end expected", NULL); - if (xf86GetToken (NULL) == NUMBER) + if (xf86getToken (NULL) == NUMBER) ptr->ml_vtotal = val.num; else Error ("Vertical total expected", NULL); had_vtimings = 1; break; case FLAGS: - token = xf86GetToken (NULL); + token = xf86getToken (NULL); if (token != STRING) Error (QUOTE_MSG, "Flags"); while (token == STRING) { - token2 = getStringToken (TimingTab); + token2 = xf86getStringToken (TimingTab); switch (token2) { case TT_INTERLACE: @@ -327,19 +333,20 @@ Error ("Unknown flag string", NULL); break; } - token = xf86GetToken (NULL); + token = xf86getToken (NULL); } - xf86UnGetToken (token); + xf86unGetToken (token); break; case HSKEW: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("Horizontal skew expected", NULL); ptr->ml_flags |= XF86CONF_HSKEW; ptr->ml_hskew = val.num; break; case VSCAN: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error ("Vertical scan count expected", NULL); + ptr->ml_flags |= XF86CONF_VSCAN; ptr->ml_vscan = val.num; break; case EOF_TOKEN: @@ -364,138 +371,126 @@ #undef CLEANUP -#define CLEANUP freeMonitorList +#define CLEANUP xf86freeMonitorList XF86ConfMonitorPtr -parseMonitorSection (void) +xf86parseMonitorSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) - while ((token = xf86GetToken (MonitorTab)) != ENDSECTION) + while ((token = xf86getToken (MonitorTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->mon_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->mon_identifier = val.str; has_ident = TRUE; break; case VENDOR: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Vendor"); ptr->mon_vendor = val.str; break; case MODEL: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "ModelName"); ptr->mon_modelname = val.str; break; case MODE: - HANDLE_LIST (mon_modeline_lst, parseVerboseMode, + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, XF86ConfModeLinePtr); break; case MODELINE: - HANDLE_LIST (mon_modeline_lst, parseModeLine, + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, XF86ConfModeLinePtr); break; case DISPLAYSIZE: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (DISPLAYSIZE_MSG, NULL); ptr->mon_width = val.realnum; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (DISPLAYSIZE_MSG, NULL); ptr->mon_height = val.realnum; break; case HORIZSYNC: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (HORIZSYNC_MSG, NULL); - ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum; - if (xf86GetToken (NULL) == DASH) - { - if (xf86GetToken (NULL) != NUMBER) - Error (HORIZSYNC_MSG, NULL); - ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; - } - else - { - xf86UnGetToken (token); - ptr->mon_hsync[ptr->mon_n_hsync].hi = - ptr->mon_hsync[ptr->mon_n_hsync].lo; - } - ptr->mon_n_hsync++; - while ((token = xf86GetToken (NULL)) == COMMA) - { - if (ptr->mon_n_hsync == CONF_MAX_HSYNC) - Error ("Sorry. Too many horizontal sync intervals.", NULL); - if (xf86GetToken (NULL) != NUMBER) - Error (HORIZSYNC_MSG, NULL); + do { ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum; - if (xf86GetToken (NULL) == DASH) - { - if (xf86GetToken (NULL) != NUMBER) - Error (HORIZSYNC_MSG, NULL); - ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; - } - else + switch (token = xf86getToken (NULL)) { - xf86UnGetToken (token); - ptr->mon_hsync[ptr->mon_n_hsync].hi = + case COMMA: + ptr->mon_hsync[ptr->mon_n_hsync].hi = ptr->mon_hsync[ptr->mon_n_hsync].lo; + break; + case DASH: + if (xf86getToken (NULL) != NUMBER || + val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo) + Error (HORIZSYNC_MSG, NULL); + ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum; + break; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_hsync[ptr->mon_n_hsync].hi = + ptr->mon_hsync[ptr->mon_n_hsync].lo; + ptr->mon_n_hsync++; + goto HorizDone; } + if (ptr->mon_n_hsync == CONF_MAX_HSYNC) + Error ("Sorry. Too many horizontal sync intervals.", NULL); ptr->mon_n_hsync++; - } - xf86UnGetToken (token); + } while ((token = xf86getToken (NULL)) == NUMBER); +HorizDone: + xf86unGetToken (token); break; + case VERTREFRESH: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (VERTREFRESH_MSG, NULL); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum; - if (xf86GetToken (NULL) == DASH) - { - if (xf86GetToken (NULL) != NUMBER) - Error (VERTREFRESH_MSG, NULL); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; - } - else - { - xf86UnGetToken (token); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = - ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; - } - ptr->mon_n_vrefresh++; - while ((token = xf86GetToken (NULL)) == COMMA) - { - if (ptr->mon_n_vrefresh == CONF_MAX_HSYNC) - Error ("Sorry. Too many vertical refresh intervals.", NULL); - if (xf86GetToken (NULL) != NUMBER) - Error (VERTREFRESH_MSG, NULL); + do { ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum; - if (xf86GetToken (NULL) == DASH) + switch (token = xf86getToken (NULL)) { - if (xf86GetToken (NULL) != NUMBER) - Error (VERTREFRESH_MSG, NULL); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; - } - else - { - xf86UnGetToken (token); - ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + case COMMA: + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = + ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + break; + case DASH: + if (xf86getToken (NULL) != NUMBER || + val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo) + Error (VERTREFRESH_MSG, NULL); + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum; + break; + default: + /* We cannot currently know if a '\n' was found, + * or this is a real error + */ + ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo; + ptr->mon_n_vrefresh++; + goto VertDone; } + if (ptr->mon_n_vrefresh == CONF_MAX_VREFRESH) + Error ("Sorry. Too many vertical refresh intervals.", NULL); ptr->mon_n_vrefresh++; - } - xf86UnGetToken (token); + } while ((token = xf86getToken (NULL)) == NUMBER); +VertDone: + xf86unGetToken (token); break; + case GAMMA: - if( xf86GetToken (NULL) != NUMBER ) + if( xf86getToken (NULL) != NUMBER ) { Error (INVALID_GAMMA_MSG, NULL); } @@ -503,10 +498,10 @@ { ptr->mon_gamma_red = ptr->mon_gamma_green = ptr->mon_gamma_blue = val.realnum; - if( xf86GetToken (NULL) == NUMBER ) + if( xf86getToken (NULL) == NUMBER ) { ptr->mon_gamma_green = val.realnum; - if( xf86GetToken (NULL) == NUMBER ) + if( xf86getToken (NULL) == NUMBER ) { ptr->mon_gamma_blue = val.realnum; } @@ -516,27 +511,27 @@ } } else - xf86UnGetToken (token); + xf86unGetToken (token); } break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { ptr->mon_option_lst = - addNewOption (ptr->mon_option_lst, + xf86addNewOption (ptr->mon_option_lst, name, val.str); } else { ptr->mon_option_lst = - addNewOption (ptr->mon_option_lst, + xf86addNewOption (ptr->mon_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -544,7 +539,7 @@ { XF86ConfModesLinkPtr mptr; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (QUOTE_MSG, "UseModes"); /* add to the end of the list of modes sections @@ -554,7 +549,7 @@ mptr->ml_modes_str = val.str; mptr->ml_modes = NULL; ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr) - addListItem((GenericListPtr)ptr->mon_modes_sect_lst, + xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst, (GenericListPtr)mptr); } break; @@ -562,7 +557,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - xf86ParseError (INVALID_KEYWORD_MSG, xf86TokenString ()); + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); CLEANUP (ptr); return NULL; break; @@ -579,34 +574,34 @@ } #undef CLEANUP -#define CLEANUP freeModesList +#define CLEANUP xf86freeModesList XF86ConfModesPtr -parseModesSection (void) +xf86parseModesSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfModesPtr, XF86ConfModesRec) - while ((token = xf86GetToken (ModesTab)) != ENDSECTION) + while ((token = xf86getToken (ModesTab)) != ENDSECTION) { switch (token) { case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->modes_identifier = val.str; has_ident = TRUE; break; case MODE: - HANDLE_LIST (mon_modeline_lst, parseVerboseMode, + HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode, XF86ConfModeLinePtr); break; case MODELINE: - HANDLE_LIST (mon_modeline_lst, parseModeLine, + HANDLE_LIST (mon_modeline_lst, xf86parseModeLine, XF86ConfModeLinePtr); break; default: - xf86ParseError (INVALID_KEYWORD_MSG, xf86TokenString ()); + xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ()); CLEANUP (ptr); return NULL; break; @@ -625,14 +620,16 @@ #undef CLEANUP void -printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr) +xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr) { int i; XF86ConfModeLinePtr mlptr; + XF86ConfModesLinkPtr mptr; XF86OptionPtr optr; while (ptr) { + mptr = ptr->mon_modes_sect_lst; fprintf (cf, "Section \"Monitor\"\n"); if (ptr->mon_comment) fprintf (cf, "\t### \"%s\"\n", ptr->mon_comment); @@ -642,6 +639,10 @@ fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor); if (ptr->mon_modelname) fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname); + while (mptr) { + fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str); + mptr = mptr->list.next; + } if (ptr->mon_width) fprintf (cf, "\tDisplaySize %d\t%d\n", ptr->mon_width, @@ -700,6 +701,8 @@ fprintf (cf, " doublescan"); if (mlptr->ml_flags & XF86CONF_HSKEW) fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); fprintf (cf, "\n"); } for (optr = ptr->mon_option_lst; optr; optr = optr->list.next) @@ -715,7 +718,7 @@ } void -printModesSection (FILE * cf, XF86ConfModesPtr ptr) +xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr) { XF86ConfModeLinePtr mlptr; @@ -753,6 +756,10 @@ fprintf (cf, " doublescan"); if (mlptr->ml_flags & XF86CONF_HSKEW) fprintf (cf, " hskew %d", mlptr->ml_hskew); + if (mlptr->ml_flags & XF86CONF_VSCAN) + fprintf (cf, " vscan %d", mlptr->ml_vscan); + if (mlptr->ml_flags & XF86CONF_BCAST) + fprintf (cf, " bcast"); fprintf (cf, "\n"); } fprintf (cf, "EndSection\n\n"); @@ -761,7 +768,7 @@ } void -freeMonitorList (XF86ConfMonitorPtr ptr) +xf86freeMonitorList (XF86ConfMonitorPtr ptr) { XF86ConfMonitorPtr prev; @@ -770,8 +777,8 @@ TestFree (ptr->mon_identifier); TestFree (ptr->mon_vendor); TestFree (ptr->mon_modelname); - OptionListFree (ptr->mon_option_lst); - freeModeLineList (ptr->mon_modeline_lst); + xf86optionListFree (ptr->mon_option_lst); + xf86freeModeLineList (ptr->mon_modeline_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -779,14 +786,14 @@ } void -freeModesList (XF86ConfModesPtr ptr) +xf86freeModesList (XF86ConfModesPtr ptr) { XF86ConfModesPtr prev; while (ptr) { TestFree (ptr->modes_identifier); - freeModeLineList (ptr->mon_modeline_lst); + xf86freeModeLineList (ptr->mon_modeline_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -794,7 +801,7 @@ } void -freeModeLineList (XF86ConfModeLinePtr ptr) +xf86freeModeLineList (XF86ConfModeLinePtr ptr) { XF86ConfModeLinePtr prev; while (ptr) @@ -807,11 +814,11 @@ } XF86ConfMonitorPtr -xf86FindMonitor (const char *ident, XF86ConfMonitorPtr p) +xf86findMonitor (const char *ident, XF86ConfMonitorPtr p) { while (p) { - if (NameCompare (ident, p->mon_identifier) == 0) + if (xf86nameCompare (ident, p->mon_identifier) == 0) return (p); p = p->list.next; @@ -820,11 +827,11 @@ } XF86ConfModesPtr -xf86FindModes (const char *ident, XF86ConfModesPtr p) +xf86findModes (const char *ident, XF86ConfModesPtr p) { while (p) { - if (NameCompare (ident, p->modes_identifier) == 0) + if (xf86nameCompare (ident, p->modes_identifier) == 0) return (p); p = p->list.next; @@ -833,11 +840,11 @@ } XF86ConfModeLinePtr -xf86FindModeLine (const char *ident, XF86ConfModeLinePtr p) +xf86findModeLine (const char *ident, XF86ConfModeLinePtr p) { while (p) { - if (NameCompare (ident, p->ml_identifier) == 0) + if (xf86nameCompare (ident, p->ml_identifier) == 0) return (p); p = p->list.next; @@ -846,21 +853,22 @@ } int -validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen) +xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen) { XF86ConfMonitorPtr monitor = screen->scrn_monitor; XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst; XF86ConfModesPtr modes; while(modeslnk) { - modes = xf86FindModes (modeslnk->ml_modes_str, p->conf_modes_lst); + modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst); if (!modes) { - xf86ValidationError (UNDEFINED_MODES_MSG, + xf86validationError (UNDEFINED_MODES_MSG, modeslnk->ml_modes_str, screen->scrn_identifier); return (FALSE); } + modeslnk->ml_modes = modes; modeslnk = modeslnk->list.next; } return (TRUE); Index: xc/programs/Xserver/hw/xfree86/parser/Pointer.c diff -u xc/programs/Xserver/hw/xfree86/parser/Pointer.c:1.7 xc/programs/Xserver/hw/xfree86/parser/Pointer.c:1.8 --- xc/programs/Xserver/hw/xfree86/parser/Pointer.c:1.7 Sat Sep 4 09:04:54 1999 +++ xc/programs/Xserver/hw/xfree86/parser/Pointer.c Fri Oct 20 10:59:03 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Pointer.c,v 1.7 1999/09/04 13:04:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Pointer.c,v 1.8 2000/10/20 14:59:03 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -64,96 +64,96 @@ {-1, ""}, }; -#define CLEANUP freeInputList +#define CLEANUP xf86freeInputList XF86ConfInputPtr -parsePointerSection (void) +xf86parsePointerSection (void) { char *s, *s1, *s2; int l; parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) - while ((token = xf86GetToken (PointerTab)) != ENDSECTION) + while ((token = xf86getToken (PointerTab)) != ENDSECTION) { switch (token) { case PROTOCOL: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Protocol"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Protocol"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Protocol"), val.str); break; case PDEVICE: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Device"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Device"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Device"), val.str); break; case EMULATE3: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Emulate3Buttons"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Buttons"), NULL); break; case EM3TIMEOUT: - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Emulate3Timeout"); - s = ULongToString(val.num); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Emulate3Timeout"), + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Emulate3Timeout"), s); break; case CHORDMIDDLE: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("ChordMiddle"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ChordMiddle"), NULL); break; case PBUTTONS: - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Buttons"); - s = ULongToString(val.num); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Buttons"), s); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Buttons"), s); break; case BAUDRATE: - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "BaudRate"); - s = ULongToString(val.num); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("BaudRate"), s); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("BaudRate"), s); break; case SAMPLERATE: - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "SampleRate"); - s = ULongToString(val.num); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("SampleRate"), s); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("SampleRate"), s); break; case PRESOLUTION: - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Resolution"); - s = ULongToString(val.num); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("Resolution"), s); + s = xf86uLongToString(val.num); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("Resolution"), s); break; case CLEARDTR: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("ClearDTR"), NULL); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearDTR"), NULL); break; case CLEARRTS: - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("ClearRTS"), NULL); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ClearRTS"), NULL); break; case ZAXISMAPPING: - switch (xf86GetToken(ZMapTab)) { + switch (xf86getToken(ZMapTab)) { case NUMBER: if (val.num < 0) Error (ZAXISMAPPING_MSG, NULL); - s1 = ULongToString(val.num); - if (xf86GetToken (NULL) != NUMBER || val.num < 0) + s1 = xf86uLongToString(val.num); + if (xf86getToken (NULL) != NUMBER || val.num < 0) Error (ZAXISMAPPING_MSG, NULL); - s2 = ULongToString(val.num); + s2 = xf86uLongToString(val.num); l = strlen(s1) + 1 + strlen(s2) + 1; s = xf86confmalloc(l); sprintf(s, "%s %s", s1, s2); @@ -161,17 +161,17 @@ xf86conffree(s2); break; case XAXIS: - s = ConfigStrdup("x"); + s = xf86configStrdup("x"); break; case YAXIS: - s = ConfigStrdup("y"); + s = xf86configStrdup("y"); break; default: Error (ZAXISMAPPING_MSG, NULL); break; } - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("ZAxisMapping"), + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("ZAxisMapping"), s); break; case ALWAYSCORE: @@ -180,15 +180,15 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } - ptr->inp_identifier = ConfigStrdup(CONF_IMPLICIT_POINTER); - ptr->inp_driver = ConfigStrdup("mouse"); - ptr->inp_option_lst = addNewOption(ptr->inp_option_lst, - ConfigStrdup("CorePointer"), NULL); + ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_POINTER); + ptr->inp_driver = xf86configStrdup("mouse"); + ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst, + xf86configStrdup("CorePointer"), NULL); #ifdef DEBUG printf ("Pointer section parsed\n"); Index: xc/programs/Xserver/hw/xfree86/parser/Screen.c diff -u xc/programs/Xserver/hw/xfree86/parser/Screen.c:1.12 xc/programs/Xserver/hw/xfree86/parser/Screen.c:1.16 --- xc/programs/Xserver/hw/xfree86/parser/Screen.c:1.12 Tue Apr 4 18:36:55 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Screen.c Fri Dec 1 11:10:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.12 2000/04/04 22:36:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.16 2000/12/01 16:10:01 paulo Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -52,83 +52,85 @@ {-1, ""}, }; -#define CLEANUP freeDisplayList +#define CLEANUP xf86freeDisplayList XF86ConfDisplayPtr -parseDisplaySubSection (void) +xf86parseDisplaySubSection (void) { parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec) - while ((token = xf86GetToken (DisplayTab)) != ENDSUBSECTION) + ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1; + ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1; + while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->disp_comment = val.str; break; case VIEWPORT: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (VIEWPORT_MSG, NULL); ptr->disp_frameX0 = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (VIEWPORT_MSG, NULL); ptr->disp_frameY0 = val.num; break; case VIRTUAL: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (VIRTUAL_MSG, NULL); ptr->disp_virtualX = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (VIRTUAL_MSG, NULL); ptr->disp_virtualY = val.num; break; case DEPTH: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Display"); ptr->disp_depth = val.num; break; case BPP: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "Display"); ptr->disp_bpp = val.num; break; case VISUAL: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Display"); ptr->disp_visual = val.str; break; case WEIGHT: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WEIGHT_MSG, NULL); ptr->disp_weight.red = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WEIGHT_MSG, NULL); ptr->disp_weight.green = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WEIGHT_MSG, NULL); ptr->disp_weight.blue = val.num; break; case BLACK_TOK: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (BLACK_MSG, NULL); ptr->disp_black.red = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (BLACK_MSG, NULL); ptr->disp_black.green = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (BLACK_MSG, NULL); ptr->disp_black.blue = val.num; break; case WHITE_TOK: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WHITE_MSG, NULL); ptr->disp_white.red = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WHITE_MSG, NULL); ptr->disp_white.green = val.num; - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (WHITE_MSG, NULL); ptr->disp_white.blue = val.num; break; @@ -136,35 +138,35 @@ { XF86ModePtr mptr; - while ((token = xf86GetToken (DisplayTab)) == STRING) + while ((token = xf86getToken (DisplayTab)) == STRING) { mptr = xf86confcalloc (1, sizeof (XF86ModeRec)); mptr->mode_name = val.str; mptr->list.next = NULL; ptr->disp_mode_lst = (XF86ModePtr) - addListItem ((glp) ptr->disp_mode_lst, (glp) mptr); + xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr); } - xf86UnGetToken (token); + xf86unGetToken (token); } break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { ptr->disp_option_lst = - addNewOption (ptr->disp_option_lst, + xf86addNewOption (ptr->disp_option_lst, name, val.str); } else { ptr->disp_option_lst = - addNewOption (ptr->disp_option_lst, + xf86addNewOption (ptr->disp_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -173,7 +175,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -206,26 +208,26 @@ {-1, ""}, }; -#define CLEANUP freeScreenList +#define CLEANUP xf86freeScreenList XF86ConfScreenPtr -parseScreenSection (void) +xf86parseScreenSection (void) { int has_ident = FALSE; int has_driver= FALSE; parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) - while ((token = xf86GetToken (ScreenTab)) != ENDSECTION) + while ((token = xf86getToken (ScreenTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->scrn_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->scrn_identifier = val.str; if (has_ident || has_driver) @@ -233,7 +235,7 @@ has_ident = TRUE; break; case OBSDRIVER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Driver"); ptr->scrn_obso_driver = val.str; if (has_ident || has_driver) @@ -241,27 +243,27 @@ has_driver = TRUE; break; case DEFAULTDEPTH: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "DefaultDepth"); ptr->scrn_defaultdepth = val.num; break; case DEFAULTBPP: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "DefaultBPP"); ptr->scrn_defaultbpp = val.num; break; case DEFAULTFBBPP: - if (xf86GetToken (NULL) != NUMBER) + if (xf86getToken (NULL) != NUMBER) Error (NUMBER_MSG, "DefaultFbBPP"); ptr->scrn_defaultfbbpp = val.num; break; case MDEVICE: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Device"); ptr->scrn_device_str = val.str; break; case MONITOR: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Monitor"); ptr->scrn_monitor_str = val.str; break; @@ -269,13 +271,13 @@ { XF86ConfAdaptorLinkPtr aptr; - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "VideoAdaptor"); /* Don't allow duplicates */ for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next) - if (NameCompare (val.str, aptr->al_adaptor_str) == 0) + if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0) break; if (aptr == NULL) @@ -284,36 +286,36 @@ aptr->list.next = NULL; aptr->al_adaptor_str = val.str; ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr) - addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr); + xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr); } } break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { ptr->scrn_option_lst = - addNewOption (ptr->scrn_option_lst, + xf86addNewOption (ptr->scrn_option_lst, name, val.str); } else { ptr->scrn_option_lst = - addNewOption (ptr->scrn_option_lst, + xf86addNewOption (ptr->scrn_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; case SUBSECTION: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "SubSection"); { - HANDLE_LIST (scrn_display_lst, parseDisplaySubSection, + HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection, XF86ConfDisplayPtr); } break; @@ -321,7 +323,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -337,7 +339,7 @@ } void -printScreenSection (FILE * cf, XF86ConfScreenPtr ptr) +xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr) { XF86ConfAdaptorLinkPtr aptr; XF86ConfDisplayPtr dptr; @@ -405,9 +407,24 @@ { fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual); } + if (dptr->disp_weight.red != 0) + { + fprintf (cf, "\t\tWeight %d %d %d\n", + dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue); + } + if (dptr->disp_black.red != -1) + { + fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n", + dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue); + } + if (dptr->disp_white.red != -1) + { + fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n", + dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue); + } if (dptr->disp_mode_lst) { - fprintf (cf, "\t\tModes"); + fprintf (cf, "\t\tModes "); } for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next) { @@ -433,7 +450,7 @@ } void -freeScreenList (XF86ConfScreenPtr ptr) +xf86freeScreenList (XF86ConfScreenPtr ptr) { XF86ConfScreenPtr prev; @@ -442,9 +459,9 @@ TestFree (ptr->scrn_identifier); TestFree (ptr->scrn_monitor_str); TestFree (ptr->scrn_device_str); - OptionListFree (ptr->scrn_option_lst); - freeAdaptorLinkList (ptr->scrn_adaptor_lst); - freeDisplayList (ptr->scrn_display_lst); + xf86optionListFree (ptr->scrn_option_lst); + xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst); + xf86freeDisplayList (ptr->scrn_display_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -452,7 +469,7 @@ } void -freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr) +xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr) { XF86ConfAdaptorLinkPtr prev; @@ -466,14 +483,14 @@ } void -freeDisplayList (XF86ConfDisplayPtr ptr) +xf86freeDisplayList (XF86ConfDisplayPtr ptr) { XF86ConfDisplayPtr prev; while (ptr) { - freeModeList (ptr->disp_mode_lst); - OptionListFree (ptr->disp_option_lst); + xf86freeModeList (ptr->disp_mode_lst); + xf86optionListFree (ptr->disp_option_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -481,7 +498,7 @@ } void -freeModeList (XF86ModePtr ptr) +xf86freeModeList (XF86ModePtr ptr) { XF86ModePtr prev; @@ -495,7 +512,7 @@ } int -validateScreen (XF86ConfigPtr p) +xf86validateScreen (XF86ConfigPtr p) { XF86ConfScreenPtr screen = p->conf_screen_lst; XF86ConfMonitorPtr monitor; @@ -504,7 +521,7 @@ if (!screen) { - xf86ValidationError ("At least one Screen section is required."); + xf86validationError ("At least one Screen section is required."); return (FALSE); } @@ -513,24 +530,24 @@ if (screen->scrn_obso_driver && !screen->scrn_identifier) screen->scrn_identifier = screen->scrn_obso_driver; - monitor = xf86FindMonitor (screen->scrn_monitor_str, p->conf_monitor_lst); + monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst); if (!monitor) { - xf86ValidationError (UNDEFINED_MONITOR_MSG, + xf86validationError (UNDEFINED_MONITOR_MSG, screen->scrn_monitor_str, screen->scrn_identifier); return (FALSE); } else { screen->scrn_monitor = monitor; - if (!validateMonitor(p, screen)) + if (!xf86validateMonitor(p, screen)) return (FALSE); } - device = xf86FindDevice (screen->scrn_device_str, p->conf_device_lst); + device = xf86findDevice (screen->scrn_device_str, p->conf_device_lst); if (!device) { - xf86ValidationError (UNDEFINED_DEVICE_MSG, + xf86validationError (UNDEFINED_DEVICE_MSG, screen->scrn_device_str, screen->scrn_identifier); return (FALSE); } @@ -540,20 +557,20 @@ adaptor = screen->scrn_adaptor_lst; while (adaptor) { - adaptor->al_adaptor = xf86FindVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst); + adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst); if (!adaptor->al_adaptor) { - xf86ValidationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier); + xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier); return (FALSE); } else if (adaptor->al_adaptor->va_fwdref) { - xf86ValidationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str, + xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str, adaptor->al_adaptor->va_fwdref); return (FALSE); } - adaptor->al_adaptor->va_fwdref = screen->scrn_identifier; + adaptor->al_adaptor->va_fwdref = xf86configStrdup(screen->scrn_identifier); adaptor = adaptor->list.next; } @@ -564,11 +581,11 @@ } XF86ConfScreenPtr -xf86FindScreen (const char *ident, XF86ConfScreenPtr p) +xf86findScreen (const char *ident, XF86ConfScreenPtr p) { while (p) { - if (NameCompare (ident, p->scrn_identifier) == 0) + if (xf86nameCompare (ident, p->scrn_identifier) == 0) return (p); p = p->list.next; @@ -577,7 +594,7 @@ } XF86ConfDisplayPtr -xf86FindDisplay (int depth, XF86ConfDisplayPtr p) +xf86findDisplay (int depth, XF86ConfDisplayPtr p) { while (p) { Index: xc/programs/Xserver/hw/xfree86/parser/Vendor.c diff -u xc/programs/Xserver/hw/xfree86/parser/Vendor.c:1.5 xc/programs/Xserver/hw/xfree86/parser/Vendor.c:1.8 --- xc/programs/Xserver/hw/xfree86/parser/Vendor.c:1.5 Tue Jan 25 21:00:51 2000 +++ xc/programs/Xserver/hw/xfree86/parser/Vendor.c Thu Nov 30 15:45:34 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.5 2000/01/26 02:00:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Vendor.c,v 1.8 2000/11/30 20:45:34 paulo Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -35,34 +35,99 @@ extern LexRec val; +static xf86ConfigSymTabRec VendorSubTab[] = +{ + {ENDSUBSECTION, "endsubsection"}, + {IDENTIFIER, "identifier"}, + {OPTION, "option"}, + {-1, ""}, +}; + +#define CLEANUP xf86freeVendorSubList + +XF86ConfVendSubPtr +xf86parseVendorSubSection (void) +{ + parsePrologue (XF86ConfVendSubPtr, XF86ConfVendSubRec) + + while ((token = xf86getToken (VendorSubTab)) != ENDSUBSECTION) + { + switch (token) + { + case IDENTIFIER: + if (xf86getToken (NULL) != STRING) + Error (QUOTE_MSG, "Identifier"); + ptr->vs_identifier = val.str; + break; + case OPTION: + { + char *name; + if ((token = xf86getToken (NULL)) != STRING) + Error (BAD_OPTION_MSG, NULL); + name = val.str; + if ((token = xf86getToken (NULL)) == STRING) + { + ptr->vs_option_lst = + xf86addNewOption (ptr->vs_option_lst, + name, val.str); + } + else + { + ptr->vs_option_lst = + xf86addNewOption (ptr->vs_option_lst, + name, NULL); + xf86unGetToken (token); + } + } + break; + + case EOF_TOKEN: + Error (UNEXPECTED_EOF_MSG, NULL); + break; + default: + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); + break; + } + } + +#ifdef DEBUG + printf ("Vendor subsection parsed\n"); +#endif + + return ptr; +} + +#undef CLEANUP + static xf86ConfigSymTabRec VendorTab[] = { {COMMENT, "###"}, {ENDSECTION, "endsection"}, {IDENTIFIER, "identifier"}, {OPTION, "option"}, + {SUBSECTION, "subsection"}, {-1, ""}, }; -#define CLEANUP freeVendorList +#define CLEANUP xf86freeVendorList XF86ConfVendorPtr -parseVendorSection (void) +xf86parseVendorSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfVendorPtr, XF86ConfVendorRec) - while ((token = xf86GetToken (VendorTab)) != ENDSECTION) + while ((token = xf86getToken (VendorTab)) != ENDSECTION) { switch (token) { case COMMENT: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "###"); ptr->vnd_comment = val.str; break; case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->vnd_identifier = val.str; has_ident = TRUE; @@ -70,27 +135,35 @@ case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->vnd_option_lst = addNewOption (ptr->vnd_option_lst, + ptr->vnd_option_lst = xf86addNewOption (ptr->vnd_option_lst, name, val.str); } else { - ptr->vnd_option_lst = addNewOption (ptr->vnd_option_lst, + ptr->vnd_option_lst = xf86addNewOption (ptr->vnd_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; + case SUBSECTION: + if (xf86getToken (NULL) != STRING) + Error (QUOTE_MSG, "SubSection"); + { + HANDLE_LIST (vnd_sub_lst, xf86parseVendorSubSection, + XF86ConfVendSubPtr); + } + break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } @@ -109,8 +182,9 @@ #undef CLEANUP void -printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) +xf86printVendorSection (FILE * cf, XF86ConfVendorPtr ptr) { + XF86ConfVendSubPtr pptr; XF86OptionPtr optr; while (ptr) @@ -128,27 +202,58 @@ fprintf (cf, " \"%s\"", optr->opt_val); fprintf (cf, "\n"); } + for (pptr = ptr->vnd_sub_lst; pptr; pptr = pptr->list.next) + { + fprintf (cf, "\tSubSection \"Vendor\"\n"); + if (pptr->vs_identifier) + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vs_identifier); + for (optr = pptr->vs_option_lst; optr; optr = optr->list.next) + { + fprintf (cf, "\t\tOption \"%s\"", optr->opt_name); + if (optr->opt_val) + fprintf (cf, " \"%s\"", optr->opt_val); + fprintf (cf, "\n"); + } + fprintf (cf, "\tEndSubSection\n"); + } fprintf (cf, "EndSection\n\n"); ptr = ptr->list.next; } } void -freeVendorList (XF86ConfVendorPtr p) +xf86freeVendorList (XF86ConfVendorPtr p) { if (p == NULL) return; + xf86freeVendorSubList (p->vnd_sub_lst); TestFree (p->vnd_identifier); - OptionListFree (p->vnd_option_lst); + xf86optionListFree (p->vnd_option_lst); xf86conffree (p); } +void +xf86freeVendorSubList (XF86ConfVendSubPtr ptr) +{ + XF86ConfVendSubPtr prev; + + while (ptr) + { + TestFree (ptr->vs_identifier); + TestFree (ptr->vs_name); + xf86optionListFree (ptr->vs_option_lst); + prev = ptr; + ptr = ptr->list.next; + xf86conffree (prev); + } +} + XF86ConfVendorPtr -xf86FindVendor (const char *name, XF86ConfVendorPtr list) +xf86findVendor (const char *name, XF86ConfVendorPtr list) { while (list) { - if (NameCompare (list->vnd_identifier, name) == 0) + if (xf86nameCompare (list->vnd_identifier, name) == 0) return (list); list = list->list.next; } Index: xc/programs/Xserver/hw/xfree86/parser/Video.c diff -u xc/programs/Xserver/hw/xfree86/parser/Video.c:1.3 xc/programs/Xserver/hw/xfree86/parser/Video.c:1.6 --- xc/programs/Xserver/hw/xfree86/parser/Video.c:1.3 Sun May 30 10:04:26 1999 +++ xc/programs/Xserver/hw/xfree86/parser/Video.c Thu Nov 30 15:45:34 2000 @@ -25,7 +25,7 @@ * in this Software without prior written authorization from Metro Link. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Video.c,v 1.3 1999/05/30 14:04:26 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Video.c,v 1.6 2000/11/30 20:45:34 paulo Exp $ */ /* View/edit this file with tab stops set to 4 */ @@ -43,40 +43,40 @@ {-1, ""}, }; -#define CLEANUP freeVideoPortList +#define CLEANUP xf86freeVideoPortList XF86ConfVideoPortPtr -parseVideoPortSubSection (void) +xf86parseVideoPortSubSection (void) { parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec) - while ((token = xf86GetToken (VideoPortTab)) != ENDSUBSECTION) + while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION) { switch (token) { case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->vp_identifier = val.str; break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { ptr->vp_option_lst = - addNewOption (ptr->vp_option_lst, + xf86addNewOption (ptr->vp_option_lst, name, val.str); } else { ptr->vp_option_lst = - addNewOption (ptr->vp_option_lst, + xf86addNewOption (ptr->vp_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; @@ -85,7 +85,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -112,69 +112,69 @@ {-1, ""}, }; -#define CLEANUP freeVideoAdaptorList +#define CLEANUP xf86freeVideoAdaptorList XF86ConfVideoAdaptorPtr -parseVideoAdaptorSection (void) +xf86parseVideoAdaptorSection (void) { int has_ident = FALSE; parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec) - while ((token = xf86GetToken (VideoAdaptorTab)) != ENDSECTION) + while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION) { switch (token) { case IDENTIFIER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Identifier"); ptr->va_identifier = val.str; has_ident = TRUE; break; case VENDOR: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Vendor"); ptr->va_vendor = val.str; break; case BOARD: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Board"); ptr->va_board = val.str; break; case BUSID: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "BusID"); ptr->va_busid = val.str; break; case DRIVER: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "Driver"); ptr->va_driver = val.str; break; case OPTION: { char *name; - if ((token = xf86GetToken (NULL)) != STRING) + if ((token = xf86getToken (NULL)) != STRING) Error (BAD_OPTION_MSG, NULL); name = val.str; - if ((token = xf86GetToken (NULL)) == STRING) + if ((token = xf86getToken (NULL)) == STRING) { - ptr->va_option_lst = addNewOption (ptr->va_option_lst, + ptr->va_option_lst = xf86addNewOption (ptr->va_option_lst, name, val.str); } else { - ptr->va_option_lst = addNewOption (ptr->va_option_lst, + ptr->va_option_lst = xf86addNewOption (ptr->va_option_lst, name, NULL); - xf86UnGetToken (token); + xf86unGetToken (token); } } break; case SUBSECTION: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) Error (QUOTE_MSG, "SubSection"); { - HANDLE_LIST (va_port_lst, parseVideoPortSubSection, + HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection, XF86ConfVideoPortPtr); } break; @@ -183,7 +183,7 @@ Error (UNEXPECTED_EOF_MSG, NULL); break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); break; } } @@ -199,7 +199,7 @@ } void -printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr) +xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr) { XF86ConfVideoPortPtr pptr; XF86OptionPtr optr; @@ -228,10 +228,10 @@ { fprintf (cf, "\tSubSection \"VideoPort\"\n"); if (pptr->vp_identifier) - fprintf (cf, "\tIdentifier \"%s\"\n", pptr->vp_identifier); + fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier); for (optr = pptr->vp_option_lst; optr; optr = optr->list.next) { - fprintf (cf, "\tOption \"%s\"", optr->opt_name); + fprintf (cf, "\t\tOption \"%s\"", optr->opt_name); if (optr->opt_val) fprintf (cf, " \"%s\"", optr->opt_val); fprintf (cf, "\n"); @@ -245,7 +245,7 @@ } void -freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr) +xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr) { XF86ConfVideoAdaptorPtr prev; @@ -256,8 +256,9 @@ TestFree (ptr->va_board); TestFree (ptr->va_busid); TestFree (ptr->va_driver); - freeVideoPortList (ptr->va_port_lst); - OptionListFree (ptr->va_option_lst); + TestFree (ptr->va_fwdref); + xf86freeVideoPortList (ptr->va_port_lst); + xf86optionListFree (ptr->va_option_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -265,14 +266,14 @@ } void -freeVideoPortList (XF86ConfVideoPortPtr ptr) +xf86freeVideoPortList (XF86ConfVideoPortPtr ptr) { XF86ConfVideoPortPtr prev; while (ptr) { TestFree (ptr->vp_identifier); - OptionListFree (ptr->vp_option_lst); + xf86optionListFree (ptr->vp_option_lst); prev = ptr; ptr = ptr->list.next; xf86conffree (prev); @@ -280,11 +281,11 @@ } XF86ConfVideoAdaptorPtr -xf86FindVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p) +xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p) { while (p) { - if (NameCompare (ident, p->va_identifier) == 0) + if (xf86nameCompare (ident, p->va_identifier) == 0) return (p); p = p->list.next; Index: xc/programs/Xserver/hw/xfree86/parser/configProcs.h diff -u xc/programs/Xserver/hw/xfree86/parser/configProcs.h:1.12 xc/programs/Xserver/hw/xfree86/parser/configProcs.h:1.14 --- xc/programs/Xserver/hw/xfree86/parser/configProcs.h:1.12 Sat Sep 4 09:04:54 1999 +++ xc/programs/Xserver/hw/xfree86/parser/configProcs.h Thu Nov 2 14:58:20 2000 @@ -1,90 +1,93 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.12 1999/09/04 13:04:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/configProcs.h,v 1.14 2000/11/02 19:58:20 anderson Exp $ */ /* Private procs. Public procs are in xf86Parser.h and xf86Optrec.h */ /* Device.c */ -XF86ConfDevicePtr parseDeviceSection(void); -void printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr); -void freeDeviceList(XF86ConfDevicePtr ptr); -int validateDevice(XF86ConfigPtr p); +XF86ConfDevicePtr xf86parseDeviceSection(void); +void xf86printDeviceSection(FILE *cf, XF86ConfDevicePtr ptr); +void xf86freeDeviceList(XF86ConfDevicePtr ptr); +int xf86validateDevice(XF86ConfigPtr p); /* Files.c */ -XF86ConfFilesPtr parseFilesSection(void); -void printFileSection(FILE *cf, XF86ConfFilesPtr ptr); -void freeFiles(XF86ConfFilesPtr p); +XF86ConfFilesPtr xf86parseFilesSection(void); +void xf86printFileSection(FILE *cf, XF86ConfFilesPtr ptr); +void xf86freeFiles(XF86ConfFilesPtr p); /* Flags.c */ -XF86ConfFlagsPtr parseFlagsSection(void); -void printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags); -void freeFlags(XF86ConfFlagsPtr flags); +XF86ConfFlagsPtr xf86parseFlagsSection(void); +void xf86printServerFlagsSection(FILE *f, XF86ConfFlagsPtr flags); +void xf86freeFlags(XF86ConfFlagsPtr flags); /* Input.c */ -XF86ConfInputPtr parseInputSection(void); -void printInputSection(FILE *f, XF86ConfInputPtr ptr); -void freeInputList(XF86ConfInputPtr ptr); -int validateInput (XF86ConfigPtr p); +XF86ConfInputPtr xf86parseInputSection(void); +void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr); +void xf86freeInputList(XF86ConfInputPtr ptr); +int xf86validateInput (XF86ConfigPtr p); /* Keyboard.c */ -XF86ConfInputPtr parseKeyboardSection(void); +XF86ConfInputPtr xf86parseKeyboardSection(void); /* Layout.c */ -XF86ConfLayoutPtr parseLayoutSection(void); -void printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr); -void freeLayoutList(XF86ConfLayoutPtr ptr); -void freeAdjacencyList(XF86ConfAdjacencyPtr ptr); -void freeInputrefList(XF86ConfInputrefPtr ptr); -int validateLayout(XF86ConfigPtr p); +XF86ConfLayoutPtr xf86parseLayoutSection(void); +void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr); +void xf86freeLayoutList(XF86ConfLayoutPtr ptr); +void xf86freeAdjacencyList(XF86ConfAdjacencyPtr ptr); +void xf86freeInputrefList(XF86ConfInputrefPtr ptr); +int xf86validateLayout(XF86ConfigPtr p); /* Module.c */ -XF86LoadPtr parseModuleSubSection(XF86LoadPtr head, char *name); -XF86ConfModulePtr parseModuleSection(void); -void printModuleSection(FILE *cf, XF86ConfModulePtr ptr); -XF86LoadPtr addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts); -void freeModules(XF86ConfModulePtr ptr); +XF86LoadPtr xf86parseModuleSubSection(XF86LoadPtr head, char *name); +XF86ConfModulePtr xf86parseModuleSection(void); +void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr); +XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts); +void xf86freeModules(XF86ConfModulePtr ptr); /* Monitor.c */ -XF86ConfModeLinePtr parseModeLine(void); -XF86ConfModeLinePtr parseVerboseMode(void); -XF86ConfMonitorPtr parseMonitorSection(void); -XF86ConfModesPtr parseModesSection(void); -void printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr); -void printModesSection(FILE *cf, XF86ConfModesPtr ptr); -void freeMonitorList(XF86ConfMonitorPtr ptr); -void freeModesList(XF86ConfModesPtr ptr); -void freeModeLineList(XF86ConfModeLinePtr ptr); -int validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen); +XF86ConfModeLinePtr xf86parseModeLine(void); +XF86ConfModeLinePtr xf86parseVerboseMode(void); +XF86ConfMonitorPtr xf86parseMonitorSection(void); +XF86ConfModesPtr xf86parseModesSection(void); +void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr); +void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr); +void xf86freeMonitorList(XF86ConfMonitorPtr ptr); +void xf86freeModesList(XF86ConfModesPtr ptr); +void xf86freeModeLineList(XF86ConfModeLinePtr ptr); +int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen); /* Pointer.c */ -XF86ConfInputPtr parsePointerSection(void); +XF86ConfInputPtr xf86parsePointerSection(void); /* Screen.c */ -XF86ConfDisplayPtr parseDisplaySubSection(void); -XF86ConfScreenPtr parseScreenSection(void); -void printScreenSection(FILE *cf, XF86ConfScreenPtr ptr); -void freeScreenList(XF86ConfScreenPtr ptr); -void freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr); -void freeDisplayList(XF86ConfDisplayPtr ptr); -void freeModeList(XF86ModePtr ptr); -int validateScreen(XF86ConfigPtr p); +XF86ConfDisplayPtr xf86parseDisplaySubSection(void); +XF86ConfScreenPtr xf86parseScreenSection(void); +void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr); +void xf86freeScreenList(XF86ConfScreenPtr ptr); +void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr ptr); +void xf86freeDisplayList(XF86ConfDisplayPtr ptr); +void xf86freeModeList(XF86ModePtr ptr); +int xf86validateScreen(XF86ConfigPtr p); /* Vendor.c */ -XF86ConfVendorPtr parseVendorSection(void); -void freeVendorList(XF86ConfVendorPtr p); -void printVendorSection(FILE * cf, XF86ConfVendorPtr ptr); +XF86ConfVendorPtr xf86parseVendorSection(void); +XF86ConfVendSubPtr xf86parseVendorSubSection (void); +void xf86freeVendorList(XF86ConfVendorPtr p); +void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr); +void xf86freeVendorSubList (XF86ConfVendSubPtr ptr); /* Video.c */ -XF86ConfVideoPortPtr parseVideoPortSubSection(void); -XF86ConfVideoAdaptorPtr parseVideoAdaptorSection(void); -void printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr); -void freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr); -void freeVideoPortList(XF86ConfVideoPortPtr ptr); -int validateConfig(XF86ConfigPtr p); +XF86ConfVideoPortPtr xf86parseVideoPortSubSection(void); +XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void); +void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr); +void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr); +void xf86freeVideoPortList(XF86ConfVideoPortPtr ptr); +/* read.c */ +int xf86validateConfig(XF86ConfigPtr p); /* scan.c */ -unsigned int StrToUL(char *str); -int xf86GetToken(xf86ConfigSymTabRec *tab); -void xf86UnGetToken(int token); -char *xf86TokenString(void); -void xf86ParseError(char *format, ...); -void xf86ParseWarning(char *format, ...); -void xf86ValidationError(char *format, ...); -void SetSection(char *section); -int getStringToken(xf86ConfigSymTabRec *tab); +unsigned int xf86strToUL(char *str); +int xf86getToken(xf86ConfigSymTabRec *tab); +void xf86unGetToken(int token); +char *xf86tokenString(void); +void xf86parseError(char *format, ...); +void xf86parseWarning(char *format, ...); +void xf86validationError(char *format, ...); +void xf86setSection(char *section); +int xf86getStringToken(xf86ConfigSymTabRec *tab); /* write.c */ /* DRI.c */ -XF86ConfBuffersPtr parseBuffers (void); -void freeBuffersList (XF86ConfBuffersPtr ptr); -XF86ConfDRIPtr parseDRISection (void); -void printDRISection (FILE * cf, XF86ConfDRIPtr ptr); -void freeDRI (XF86ConfDRIPtr ptr); +XF86ConfBuffersPtr xf86parseBuffers (void); +void xf86freeBuffersList (XF86ConfBuffersPtr ptr); +XF86ConfDRIPtr xf86parseDRISection (void); +void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr); +void xf86freeDRI (XF86ConfDRIPtr ptr); /* Externally provided functions */ void ErrorF(const char *f, ...); Index: xc/programs/Xserver/hw/xfree86/parser/cpconfig.c diff -u xc/programs/Xserver/hw/xfree86/parser/cpconfig.c:1.5 xc/programs/Xserver/hw/xfree86/parser/cpconfig.c:1.6 --- xc/programs/Xserver/hw/xfree86/parser/cpconfig.c:1.5 Sun Jun 6 11:23:04 1999 +++ xc/programs/Xserver/hw/xfree86/parser/cpconfig.c Fri Oct 20 10:59:03 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/cpconfig.c,v 1.5 1999/06/06 15:23:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/cpconfig.c,v 1.6 2000/10/20 14:59:03 alanh Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -72,7 +72,7 @@ { cmdline = argv[1]; } - if ((filename = xf86OpenConfigFile (CONFPATH, cmdline, NULL))) + if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL))) { fprintf (stderr, "Opened %s for the config file\n", filename); } @@ -82,7 +82,7 @@ exit (1); } - if ((conf = xf86ReadConfigFile ()) == NULL) + if ((conf = xf86readConfigFile ()) == NULL) { fprintf (stderr, "Problem when parsing config file\n"); } @@ -90,11 +90,11 @@ { fprintf (stderr, "Config file parsed OK\n"); } - xf86CloseConfigFile (); + xf86closeConfigFile (); if (argc > 2) { fprintf(stderr, "Writing config file to `%s'\n", argv[2]); - xf86WriteConfigFile (argv[2], conf); + xf86writeConfigFile (argv[2], conf); } exit(0); } Index: xc/programs/Xserver/hw/xfree86/parser/read.c diff -u xc/programs/Xserver/hw/xfree86/parser/read.c:1.12 xc/programs/Xserver/hw/xfree86/parser/read.c:1.17 --- xc/programs/Xserver/hw/xfree86/parser/read.c:1.12 Tue Apr 4 18:36:55 2000 +++ xc/programs/Xserver/hw/xfree86/parser/read.c Wed Dec 6 10:35:32 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.12 2000/04/04 22:36:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.17 2000/12/06 15:35:32 eich Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -41,10 +41,10 @@ {-1, ""}, }; -#define CLEANUP XF86FreeConfig +#define CLEANUP xf86freeConfig XF86ConfigPtr -xf86ReadConfigFile (void) +xf86readConfigFile (void) { int token; XF86ConfigPtr ptr = NULL; @@ -55,95 +55,95 @@ } memset (ptr, 0, sizeof (XF86ConfigRec)); - while ((token = xf86GetToken (TopLevelTab)) != EOF_TOKEN) + while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN) { switch (token) { case SECTION: - if (xf86GetToken (NULL) != STRING) + if (xf86getToken (NULL) != STRING) { - xf86ParseError (QUOTE_MSG, "Section"); + xf86parseError (QUOTE_MSG, "Section"); CLEANUP (ptr); return (NULL); } - SetSection (val.str); - if (NameCompare (val.str, "files") == 0) + xf86setSection (val.str); + if (xf86nameCompare (val.str, "files") == 0) { - HANDLE_RETURN (conf_files, parseFilesSection ()); + HANDLE_RETURN (conf_files, xf86parseFilesSection ()); } - else if (NameCompare (val.str, "serverflags") == 0) + else if (xf86nameCompare (val.str, "serverflags") == 0) { - HANDLE_RETURN (conf_flags, parseFlagsSection ()); + HANDLE_RETURN (conf_flags, xf86parseFlagsSection ()); } - else if (NameCompare (val.str, "keyboard") == 0) + else if (xf86nameCompare (val.str, "keyboard") == 0) { - HANDLE_LIST (conf_input_lst, parseKeyboardSection, + HANDLE_LIST (conf_input_lst, xf86parseKeyboardSection, XF86ConfInputPtr); } - else if (NameCompare (val.str, "pointer") == 0) + else if (xf86nameCompare (val.str, "pointer") == 0) { - HANDLE_LIST (conf_input_lst, parsePointerSection, + HANDLE_LIST (conf_input_lst, xf86parsePointerSection, XF86ConfInputPtr); } - else if (NameCompare (val.str, "videoadaptor") == 0) + else if (xf86nameCompare (val.str, "videoadaptor") == 0) { - HANDLE_LIST (conf_videoadaptor_lst, parseVideoAdaptorSection, + HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection, XF86ConfVideoAdaptorPtr); } - else if (NameCompare (val.str, "device") == 0) + else if (xf86nameCompare (val.str, "device") == 0) { - HANDLE_LIST (conf_device_lst, parseDeviceSection, + HANDLE_LIST (conf_device_lst, xf86parseDeviceSection, XF86ConfDevicePtr); } - else if (NameCompare (val.str, "monitor") == 0) + else if (xf86nameCompare (val.str, "monitor") == 0) { - HANDLE_LIST (conf_monitor_lst, parseMonitorSection, + HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection, XF86ConfMonitorPtr); } - else if (NameCompare (val.str, "modes") == 0) + else if (xf86nameCompare (val.str, "modes") == 0) { - HANDLE_LIST (conf_modes_lst, parseModesSection, + HANDLE_LIST (conf_modes_lst, xf86parseModesSection, XF86ConfModesPtr); } - else if (NameCompare (val.str, "screen") == 0) + else if (xf86nameCompare (val.str, "screen") == 0) { - HANDLE_LIST (conf_screen_lst, parseScreenSection, + HANDLE_LIST (conf_screen_lst, xf86parseScreenSection, XF86ConfScreenPtr); } - else if (NameCompare(val.str, "inputdevice") == 0) + else if (xf86nameCompare(val.str, "inputdevice") == 0) { - HANDLE_LIST (conf_input_lst, parseInputSection, + HANDLE_LIST (conf_input_lst, xf86parseInputSection, XF86ConfInputPtr); } - else if (NameCompare (val.str, "module") == 0) + else if (xf86nameCompare (val.str, "module") == 0) { - HANDLE_RETURN (conf_modules, parseModuleSection ()); + HANDLE_RETURN (conf_modules, xf86parseModuleSection ()); } - else if (NameCompare (val.str, "serverlayout") == 0) + else if (xf86nameCompare (val.str, "serverlayout") == 0) { - HANDLE_LIST (conf_layout_lst, parseLayoutSection, + HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection, XF86ConfLayoutPtr); } - else if (NameCompare (val.str, "vendor") == 0) + else if (xf86nameCompare (val.str, "vendor") == 0) { - HANDLE_LIST (conf_vendor_lst, parseVendorSection, + HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection, XF86ConfVendorPtr); } - else if (NameCompare (val.str, "dri") == 0) + else if (xf86nameCompare (val.str, "dri") == 0) { - HANDLE_RETURN (conf_dri, parseDRISection ()); + HANDLE_RETURN (conf_dri, xf86parseDRISection ()); } else { - Error (INVALID_SECTION_MSG, xf86TokenString ()); + Error (INVALID_SECTION_MSG, xf86tokenString ()); } break; default: - Error (INVALID_KEYWORD_MSG, xf86TokenString ()); + Error (INVALID_KEYWORD_MSG, xf86tokenString ()); } } - if (validateConfig (ptr)) + if (xf86validateConfig (ptr)) return (ptr); else { @@ -159,15 +159,15 @@ * objects cannot be found. */ int -validateConfig (XF86ConfigPtr p) +xf86validateConfig (XF86ConfigPtr p) { - if (!validateDevice (p)) + if (!xf86validateDevice (p)) return FALSE; - if (!validateScreen (p)) + if (!xf86validateScreen (p)) return FALSE; - if (!validateInput (p)) + if (!xf86validateInput (p)) return FALSE; - if (!validateLayout (p)) + if (!xf86validateLayout (p)) return FALSE; return (TRUE); @@ -180,7 +180,7 @@ * the first item. */ GenericListPtr -addListItem (GenericListPtr head, GenericListPtr new) +xf86addListItem (GenericListPtr head, GenericListPtr new) { GenericListPtr p = head; GenericListPtr last = NULL; @@ -200,21 +200,48 @@ return (new); } +/* + * Test if one chained list contains the other. + * In this case both list have the same endpoint (provided they don't loop) + */ +int +xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2) +{ + GenericListPtr p = list_1; + GenericListPtr last_1 = NULL, last_2 = NULL; + + while (p) { + last_1 = p; + p = p->next; + } + + p = list_2; + while (p) { + last_2 = p; + p = p->next; + } + + return (!(last_1 == last_2)); +} + void -XF86FreeConfig (XF86ConfigPtr p) +xf86freeConfig (XF86ConfigPtr p) { if (p == NULL) return; - freeFiles (p->conf_files); - freeModules (p->conf_modules); - freeFlags (p->conf_flags); - freeMonitorList (p->conf_monitor_lst); - freeVideoAdaptorList (p->conf_videoadaptor_lst); - freeDeviceList (p->conf_device_lst); - freeScreenList (p->conf_screen_lst); - freeLayoutList (p->conf_layout_lst); - freeInputList (p->conf_input_lst); + xf86freeFiles (p->conf_files); + xf86freeModules (p->conf_modules); + xf86freeFlags (p->conf_flags); + xf86freeMonitorList (p->conf_monitor_lst); + xf86freeModesList (p->conf_modes_lst); + xf86freeVideoAdaptorList (p->conf_videoadaptor_lst); + xf86freeDeviceList (p->conf_device_lst); + xf86freeScreenList (p->conf_screen_lst); + xf86freeLayoutList (p->conf_layout_lst); + xf86freeInputList (p->conf_input_lst); + xf86freeVendorList (p->conf_vendor_lst); + xf86freeDRI (p->conf_dri); xf86conffree (p); } Index: xc/programs/Xserver/hw/xfree86/parser/scan.c diff -u xc/programs/Xserver/hw/xfree86/parser/scan.c:1.12 xc/programs/Xserver/hw/xfree86/parser/scan.c:1.14 --- xc/programs/Xserver/hw/xfree86/parser/scan.c:1.12 Wed Apr 5 14:13:57 2000 +++ xc/programs/Xserver/hw/xfree86/parser/scan.c Thu Nov 2 14:58:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.12 2000/04/05 18:13:57 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.14 2000/11/02 19:58:20 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -79,13 +79,13 @@ #endif /* - * StrToUL -- + * xf86strToUL -- * * A portable, but restricted, version of strtoul(). It only understands * hex, octal, and decimal. But it's good enough for our needs. */ unsigned int -StrToUL (char *str) +xf86strToUL (char *str) { int base = 10; char *p = str; @@ -126,12 +126,12 @@ } /* - * xf86GetToken -- + * xf86getToken -- * Read next Token form the config file. Handle the global variable * pushToken. */ int -xf86GetToken (xf86ConfigSymTabRec * tab) +xf86getToken (xf86ConfigSymTabRec * tab) { int c, i; @@ -211,7 +211,7 @@ configRBuf[i++] = c; configPos--; /* GJA -- one too far */ configRBuf[i] = '\0'; - val.num = StrToUL (configRBuf); + val.num = xf86strToUL (configRBuf); val.realnum = atof (configRBuf); return (NUMBER); } @@ -284,7 +284,7 @@ { i = 0; while (tab[i].token != -1) - if (NameCompare (configRBuf, tab[i].name) == 0) + if (xf86nameCompare (configRBuf, tab[i].name) == 0) return (tab[i].token); else i++; @@ -294,20 +294,20 @@ } void -xf86UnGetToken (int token) +xf86unGetToken (int token) { pushToken = token; } char * -xf86TokenString (void) +xf86tokenString (void) { return configRBuf; } #if 1 int -PathIsAbsolute(const char *path) +xf86pathIsAbsolute(const char *path) { if (path && path[0] == '/') return 1; @@ -320,9 +320,9 @@ /* A path is "safe" if it is relative and if it contains no ".." elements. */ int -PathIsSafe(const char *path) +xf86pathIsSafe(const char *path) { - if (PathIsAbsolute(path)) + if (xf86pathIsAbsolute(path)) return 0; /* Compare with ".." */ @@ -429,7 +429,7 @@ } else { switch (template[++i]) { case 'A': - if (cmdline && PathIsAbsolute(cmdline)) { + if (cmdline && xf86pathIsAbsolute(cmdline)) { APPEND_STR(cmdline); if (cmdlineUsed) *cmdlineUsed = 1; @@ -437,7 +437,7 @@ BAIL_OUT; break; case 'R': - if (cmdline && !PathIsAbsolute(cmdline)) { + if (cmdline && !xf86pathIsAbsolute(cmdline)) { APPEND_STR(cmdline); if (cmdlineUsed) *cmdlineUsed = 1; @@ -445,7 +445,7 @@ BAIL_OUT; break; case 'S': - if (cmdline && PathIsSafe(cmdline)) { + if (cmdline && xf86pathIsSafe(cmdline)) { APPEND_STR(cmdline); if (cmdlineUsed) *cmdlineUsed = 1; @@ -472,7 +472,7 @@ case 'E': if (!env) env = getenv(XCONFENV); - if (env && PathIsAbsolute(env)) { + if (env && xf86pathIsAbsolute(env)) { APPEND_STR(env); if (envUsed) *envUsed = 1; @@ -482,7 +482,7 @@ case 'F': if (!env) env = getenv(XCONFENV); - if (env && !PathIsAbsolute(env)) { + if (env && !xf86pathIsAbsolute(env)) { APPEND_STR(env); if (envUsed) *envUsed = 1; @@ -492,7 +492,7 @@ case 'G': if (!env) env = getenv(XCONFENV); - if (env && PathIsSafe(env)) { + if (env && xf86pathIsSafe(env)) { APPEND_STR(env); if (envUsed) *envUsed = 1; @@ -502,13 +502,13 @@ case 'D': if (!home) home = getenv("HOME"); - if (home && PathIsAbsolute(home)) + if (home && xf86pathIsAbsolute(home)) APPEND_STR(home); else BAIL_OUT; break; case 'P': - if (projroot && PathIsAbsolute(projroot)) + if (projroot && xf86pathIsAbsolute(projroot)) APPEND_STR(projroot); else BAIL_OUT; @@ -552,7 +552,7 @@ } /* - * xf86OpenConfigFile -- + * xf86openConfigFile -- * * This function take a config file search path (optional), a command-line * specified file name (optional) and the ProjectRoot path (optional) and @@ -584,7 +584,7 @@ #endif const char * -xf86OpenConfigFile(const char *path, const char *cmdline, const char *projroot) +xf86openConfigFile(const char *path, const char *cmdline, const char *projroot) { char *pathcopy; const char *template; @@ -634,7 +634,7 @@ } #else /* - * xf86OpenConfigFile -- + * xf86openConfigFile -- * * Formerly findConfigFile(). This function take a pointer to a location * in which to place the actual name of the file that was opened. @@ -647,7 +647,7 @@ */ int -xf86OpenConfigFile (char *filename) +xf86openConfigFile (char *filename) { #define MAXPTRIES 6 char *home = NULL; @@ -814,7 +814,7 @@ #endif void -xf86CloseConfigFile (void) +xf86closeConfigFile (void) { xf86conffree (configPath); xf86conffree (configRBuf); @@ -824,7 +824,7 @@ } void -xf86ParseError (char *format,...) +xf86parseError (char *format,...) { va_list ap; @@ -850,7 +850,7 @@ } void -xf86ParseWarning (char *format,...) +xf86parseWarning (char *format,...) { va_list ap; @@ -875,7 +875,7 @@ } void -xf86ValidationError (char *format,...) +xf86validationError (char *format,...) { va_list ap; @@ -899,17 +899,17 @@ } void -SetSection (char *section) +xf86setSection (char *section) { configSection = section; } /* - * xf86GetToken -- + * xf86getToken -- * Lookup a string if it is actually a token in disguise. */ int -getStringToken (xf86ConfigSymTabRec * tab) +xf86getStringToken (xf86ConfigSymTabRec * tab) { return StringToToken (val.str, tab); } @@ -921,7 +921,7 @@ for (i = 0; tab[i].token != -1; i++) { - if (!NameCompare (tab[i].name, str)) + if (!xf86nameCompare (tab[i].name, str)) return tab[i].token; } return (ERROR_TOKEN); @@ -933,15 +933,16 @@ * in the comparison. */ int -NameCompare (const char *s1, const char *s2) +xf86nameCompare (const char *s1, const char *s2) { char c1, c2; - if (!s1 || *s1 == 0) + if (!s1 || *s1 == 0) { if (!s2 || *s2 == 0) return (0); else return (1); + } while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') s1++; Index: xc/programs/Xserver/hw/xfree86/parser/write.c diff -u xc/programs/Xserver/hw/xfree86/parser/write.c:1.10 xc/programs/Xserver/hw/xfree86/parser/write.c:1.12 --- xc/programs/Xserver/hw/xfree86/parser/write.c:1.10 Mon Mar 6 17:59:34 2000 +++ xc/programs/Xserver/hw/xfree86/parser/write.c Tue Nov 14 12:33:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/write.c,v 1.10 2000/03/06 22:59:34 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/write.c,v 1.12 2000/11/14 17:33:01 dawes Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -56,7 +56,7 @@ #endif #ifdef HAS_NO_UIDS -#define doWriteConfigFile xf86WriteConfigFile +#define doWriteConfigFile xf86writeConfigFile #define Local /**/ #else #define Local static @@ -72,32 +72,34 @@ return 0; } - printLayoutSection (cf, cptr->conf_layout_lst); + xf86printLayoutSection (cf, cptr->conf_layout_lst); fprintf (cf, "Section \"Files\"\n"); - printFileSection (cf, cptr->conf_files); + xf86printFileSection (cf, cptr->conf_files); fprintf (cf, "EndSection\n\n"); fprintf (cf, "Section \"Module\"\n"); - printModuleSection (cf, cptr->conf_modules); + xf86printModuleSection (cf, cptr->conf_modules); fprintf (cf, "EndSection\n\n"); - printVendorSection (cf, cptr->conf_vendor_lst); + xf86printVendorSection (cf, cptr->conf_vendor_lst); - printServerFlagsSection (cf, cptr->conf_flags); + xf86printServerFlagsSection (cf, cptr->conf_flags); - printInputSection (cf, cptr->conf_input_lst); + xf86printInputSection (cf, cptr->conf_input_lst); - printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst); + xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst); - printMonitorSection (cf, cptr->conf_monitor_lst); + xf86printModesSection (cf, cptr->conf_modes_lst); - printDeviceSection (cf, cptr->conf_device_lst); + xf86printMonitorSection (cf, cptr->conf_monitor_lst); - printScreenSection (cf, cptr->conf_screen_lst); + xf86printDeviceSection (cf, cptr->conf_device_lst); + xf86printScreenSection (cf, cptr->conf_screen_lst); + fprintf (cf, "Section \"DRI\"\n"); - printDRISection (cf, cptr->conf_dri); + xf86printDRISection (cf, cptr->conf_dri); fprintf (cf, "EndSection\n\n"); fclose(cf); @@ -107,7 +109,7 @@ #ifndef HAS_NO_UIDS int -xf86WriteConfigFile (const char *filename, XF86ConfigPtr cptr) +xf86writeConfigFile (const char *filename, XF86ConfigPtr cptr) { int ret; @@ -130,7 +132,7 @@ switch ((pid = fork())) { case -1: - ErrorF("xf86WriteConfigFile(): fork failed (%s)\n", + ErrorF("xf86writeConfigFile(): fork failed (%s)\n", strerror(errno)); return 0; case 0: /* child */ @@ -159,7 +161,7 @@ if (seteuid(ruid) == -1) { - ErrorF("xf86WriteConfigFile(): seteuid(%d) failed (%s)\n", + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", ruid, strerror(errno)); return 0; } @@ -167,7 +169,7 @@ if (seteuid(euid) == -1) { - ErrorF("xf86WriteConfigFile(): seteuid(%d) failed (%s)\n", + ErrorF("xf86writeConfigFile(): seteuid(%d) failed (%s)\n", euid, strerror(errno)); } return ret; Index: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h diff -u xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h:1.7 xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h:1.9 --- xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h:1.7 Tue Jan 25 21:00:51 2000 +++ xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h Thu Nov 2 14:58:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.7 2000/01/26 02:00:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Optrec.h,v 1.9 2000/11/02 19:58:21 anderson Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -58,21 +58,23 @@ XF86OptionRec, *XF86OptionPtr; -XF86OptionPtr addNewOption(XF86OptionPtr head, char *name, char *val); -XF86OptionPtr OptionListDup(XF86OptionPtr opt); -void OptionListFree(XF86OptionPtr opt); -char *OptionName(XF86OptionPtr opt); -char *OptionValue(XF86OptionPtr opt); -XF86OptionPtr NewOption(char *name, char *value); -XF86OptionPtr NextOption(XF86OptionPtr list); -XF86OptionPtr FindOption(XF86OptionPtr list, const char *name); -char *FindOptionValue(XF86OptionPtr list, const char *name); -XF86OptionPtr OptionListCreate(const char **options, int count, int used); -XF86OptionPtr OptionListMerge(XF86OptionPtr head, XF86OptionPtr tail); -int FindOptionBoolean(XF86OptionPtr list, char *name, int default_val); -char *ConfigStrdup (const char *s); -int NameCompare (const char *s1, const char *s2); -char *ULongToString(unsigned long i); +XF86OptionPtr xf86addNewOption(XF86OptionPtr head, char *name, char *val); +XF86OptionPtr xf86optionListDup(XF86OptionPtr opt); +void xf86optionListFree(XF86OptionPtr opt); +char *xf86optionName(XF86OptionPtr opt); +char *xf86optionValue(XF86OptionPtr opt); +XF86OptionPtr xf86newOption(char *name, char *value); +XF86OptionPtr xf86nextOption(XF86OptionPtr list); +XF86OptionPtr xf86findOption(XF86OptionPtr list, const char *name); +char *xf86findOptionValue(XF86OptionPtr list, const char *name); +int xf86findOptionBoolean (XF86OptionPtr, const char *, int); +XF86OptionPtr xf86optionListCreate(const char **options, int count, int used); +XF86OptionPtr xf86optionListMerge(XF86OptionPtr head, XF86OptionPtr tail); +char *xf86configStrdup (const char *s); +int xf86nameCompare (const char *s1, const char *s2); +char *xf86uLongToString(unsigned long i); +void xf86debugListOptions(XF86OptionPtr); + Index: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h diff -u xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h:1.21 xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h:1.27 --- xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h:1.21 Tue Jun 20 01:08:49 2000 +++ xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h Wed Dec 6 10:35:33 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.21 2000/06/20 05:08:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.27 2000/12/06 15:35:33 eich Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -81,7 +81,9 @@ #define XF86CONF_PCSYNC 0x0080 #define XF86CONF_NCSYNC 0x0100 #define XF86CONF_HSKEW 0x0200 /* hskew provided */ -#define XF86CONF_CUSTOM 0x0400 /* timing numbers customized by editor */ +#define XF86CONF_BCAST 0x0400 +#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */ +#define XF86CONF_VSCAN 0x1000 typedef struct { @@ -337,11 +339,21 @@ } XF86ConfLayoutRec, *XF86ConfLayoutPtr; +typedef struct +{ + GenericListRec list; + char *vs_name; + char *vs_identifier; + XF86OptionPtr vs_option_lst; +} +XF86ConfVendSubRec, *XF86ConfVendSubPtr; + typedef struct { GenericListRec list; char *vnd_identifier; XF86OptionPtr vnd_option_lst; + XF86ConfVendSubPtr vnd_sub_lst; char *vnd_comment; } XF86ConfVendorRec, *XF86ConfVendorPtr; @@ -391,28 +403,29 @@ /* * prototypes for public functions */ -extern const char *xf86OpenConfigFile (const char *, const char *, +extern const char *xf86openConfigFile (const char *, const char *, const char *); -extern XF86ConfigPtr xf86ReadConfigFile (void); -extern void xf86CloseConfigFile (void); -extern void XF86FreeConfig (XF86ConfigPtr p); -extern int xf86WriteConfigFile (const char *, XF86ConfigPtr); -XF86ConfDevicePtr xf86FindDevice(const char *ident, XF86ConfDevicePtr p); -XF86ConfLayoutPtr xf86FindLayout(const char *name, XF86ConfLayoutPtr list); -XF86ConfMonitorPtr xf86FindMonitor(const char *ident, XF86ConfMonitorPtr p); -XF86ConfModesPtr xf86FindModes(const char *ident, XF86ConfModesPtr p); -XF86ConfModeLinePtr xf86FindModeLine(const char *ident, XF86ConfModeLinePtr p); -XF86ConfScreenPtr xf86FindScreen(const char *ident, XF86ConfScreenPtr p); -XF86ConfDisplayPtr xf86FindDisplay(int depth, XF86ConfDisplayPtr p); -XF86ConfInputPtr xf86FindInput(const char *ident, XF86ConfInputPtr p); -XF86ConfInputPtr xf86FindInputByDriver(const char *driver, XF86ConfInputPtr p); -XF86ConfVendorPtr xf86FindVendor(const char *name, XF86ConfVendorPtr list); -XF86ConfVideoAdaptorPtr xf86FindVideoAdaptor(const char *ident, +extern XF86ConfigPtr xf86readConfigFile (void); +extern void xf86closeConfigFile (void); +extern void xf86freeConfig (XF86ConfigPtr p); +extern int xf86writeConfigFile (const char *, XF86ConfigPtr); +XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p); +XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list); +XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p); +XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p); +XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p); +XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p); +XF86ConfDisplayPtr xf86findDisplay(int depth, XF86ConfDisplayPtr p); +XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p); +XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p); +XF86ConfVendorPtr xf86findVendor(const char *name, XF86ConfVendorPtr list); +XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, XF86ConfVideoAdaptorPtr p); -GenericListPtr addListItem(GenericListPtr head, GenericListPtr new); +GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new); +int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2); -int PathIsAbsolute(const char *path); -int PathIsSafe(const char *path); +int xf86pathIsAbsolute(const char *path); +int xf86pathIsSafe(const char *path); #endif /* _xf86Parser_h_ */ Index: xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h diff -u xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h:1.14 xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h:1.15 --- xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h:1.14 Tue Jan 25 21:00:52 2000 +++ xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h Tue Oct 24 18:45:10 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h,v 1.14 2000/01/26 02:00:52 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86tokens.h,v 1.15 2000/10/24 22:45:10 dawes Exp $ */ /* * * Copyright (c) 1997 Metro Link Incorporated @@ -105,6 +105,7 @@ VTIMINGS, FLAGS, HSKEW, + BCAST, VSCAN, ENDMODE, @@ -131,6 +132,7 @@ TT_NCSYNC, TT_DBLSCAN, TT_HSKEW, + TT_BCAST, TT_VSCAN, TT_CUSTOM, Index: xc/programs/Xserver/hw/xfree86/ramdac/BT.c diff -u xc/programs/Xserver/hw/xfree86/ramdac/BT.c:1.6 xc/programs/Xserver/hw/xfree86/ramdac/BT.c:1.7 --- xc/programs/Xserver/hw/xfree86/ramdac/BT.c:1.6 Sun Jan 17 05:54:13 1999 +++ xc/programs/Xserver/hw/xfree86/ramdac/BT.c Fri Oct 20 08:57:27 2000 @@ -23,7 +23,7 @@ * * BT RAMDAC routines. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/BT.c,v 1.6 1999/01/17 10:54:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/BT.c,v 1.7 2000/10/20 12:57:27 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -85,6 +85,10 @@ case 0xD0: BTramdac_ID = ATT20C505_RAMDAC; break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Unknown BT RAMDAC type (0x%x), assuming BT485\n", + status); case 0x80: case 0x90: case 0xA0: Index: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c diff -u xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c:1.5 xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c:1.6 --- xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c:1.5 Thu Jan 14 08:05:21 1999 +++ xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c Tue Sep 26 11:57:21 2000 @@ -23,7 +23,7 @@ * * Generic RAMDAC access routines. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c,v 1.5 1999/01/14 13:05:21 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.c,v 1.6 2000/09/26 15:57:21 tsi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -57,46 +57,12 @@ void RamDacDestroyInfoRec(RamDacRecPtr infoRec) { - if(!infoRec) return; - - if(infoRec->ReadDAC) - xfree(infoRec->ReadDAC); - - if(infoRec->WriteDAC) - xfree(infoRec->WriteDAC); - - if(infoRec->WriteAddress) - xfree(infoRec->WriteAddress); - - if(infoRec->WriteData) - xfree(infoRec->WriteData); - - if(infoRec->ReadAddress) - xfree(infoRec->ReadAddress); - - if(infoRec->ReadData) - xfree(infoRec->ReadData); - xfree(infoRec); } void RamDacHelperDestroyInfoRec(RamDacHelperRecPtr infoRec) { - if(!infoRec) return; - - if(infoRec->RamDacType) - xfree(infoRec->RamDacType); - - if(infoRec->Save) - xfree(infoRec->Save); - - if(infoRec->Restore) - xfree(infoRec->Restore); - - if(infoRec->SetBpp) - xfree(infoRec->SetBpp); - xfree(infoRec); } Index: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c diff -u xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c:1.6 xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c:1.7 --- xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c:1.6 Tue Mar 21 16:15:28 2000 +++ xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c Tue Jul 25 21:52:24 2000 @@ -23,17 +23,17 @@ * * Generic RAMDAC access to colormaps. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c,v 1.6 2000/03/21 21:15:28 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c,v 1.7 2000/07/26 01:52:24 tsi Exp $ */ #include "X.h" #include "Xproto.h" #include "windowstr.h" -#include "compiler.h" #include "mipointer.h" #include "micmap.h" #include "xf86.h" #include "xf86_ansic.h" +#include "compiler.h" #include "colormapst.h" #include "xf86RamDacPriv.h" Index: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c diff -u xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c:1.36 xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c:1.42 --- xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c:1.36 Mon Feb 21 14:23:15 2000 +++ xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c Tue Nov 14 13:20:38 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c,v 1.36 2000/02/21 19:23:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.c,v 1.42 2000/11/14 18:20:38 dawes Exp $ */ /* * @@ -17,28 +17,20 @@ #include "X.h" #include "misc.h" -#include "compiler.h" - #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" #include "vgaHW.h" - -#include "xf86cmap.h" -/* - * XXX The PC98 bits have been removed for now. The structure of the - * code here has been reorganised to the point where they need to be - * redone anyway. In the meantime the older version can be found in - * xfree86/olddrivers/vgahw/. - */ +#include "compiler.h" +#include "xf86cmap.h" #ifndef SAVE_FONT1 #define SAVE_FONT1 #endif -#if defined(Lynx) || defined(CSRG_BASED) || defined(MACH386) || defined(linux) || defined(AMOEBA) || defined(MINIX) || defined(__QNX__) +#if defined(Lynx) || defined(CSRG_BASED) || defined(MACH386) || defined(linux) || defined(AMOEBA) || defined(MINIX) || defined(__QNX__) || defined(sun) || defined(__GNU__) #ifndef NEED_SAVED_CMAP #define NEED_SAVED_CMAP #endif @@ -1078,11 +1070,12 @@ #endif hwp->writeDacMask(hwp, 0xFF); + /* * check if we can read the lookup table */ hwp->writeDacReadAddr(hwp, 0x00); - for (i = 0; i < 3; i++) { + for (i = 0; i < 6; i++) { save->DAC[i] = hwp->readDacData(hwp); #ifdef DEBUG switch (i % 3) { @@ -1097,15 +1090,23 @@ } #endif } - hwp->writeDacWriteAddr(hwp, 0x00); - for (i = 0; i < 3; i++) + + /* + * Check if we can read the palette - + * use foreground color to prevent flashing. + */ + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) hwp->writeDacData(hwp, ~save->DAC[i] & DAC_TEST_MASK); - hwp->writeDacReadAddr(hwp, 0x00); - for (i = 0; i < 3; i++) { + hwp->writeDacReadAddr(hwp, 0x01); + for (i = 3; i < 6; i++) { if (hwp->readDacData(hwp) != (~save->DAC[i] & DAC_TEST_MASK)) readError = TRUE; } - + hwp->writeDacWriteAddr(hwp, 0x01); + for (i = 3; i < 6; i++) + hwp->writeDacData(hwp, save->DAC[i]); + if (readError) { /* * save the default lookup table @@ -1115,7 +1116,7 @@ "Cannot read colourmap from VGA. Will restore with default\n"); } else { /* save the colourmap */ - hwp->writeDacReadAddr(hwp, 0x01); + hwp->writeDacReadAddr(hwp, 0x02); for (i = 3; i < 768; i++) { save->DAC[i] = hwp->readDacData(hwp); DACDelay(hwp); @@ -1133,6 +1134,7 @@ #endif } } + hwp->disablePalette(hwp); hwp->cmapSaved = TRUE; #endif @@ -1695,6 +1697,9 @@ * XXX This is not correct but we do it * for now. */ +#ifdef DEBUG + ErrorF("Mapping VGAMem\n"); +#endif hwp->Base = xf86MapVidMem(scr_index, VIDMEM_MMIO_32BIT, hwp->MapPhys, hwp->MapSize); return hwp->Base != NULL; @@ -1709,7 +1714,10 @@ if (hwp->Base == NULL) return; - + +#ifdef DEBUG + ErrorF("Unmapping VGAMem\n"); +#endif xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize); hwp->Base = NULL; } Index: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h diff -u xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h:1.23 xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h:1.24 --- xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h:1.23 Tue Feb 15 13:01:21 2000 +++ xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h Thu Nov 2 11:33:27 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h,v 1.23 2000/02/15 18:01:21 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/vgahw/vgaHW.h,v 1.24 2000/11/02 16:33:27 tsi Exp $ */ /* @@ -97,8 +97,8 @@ typedef struct _vgaHWRec *vgaHWPtr; -typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 index, CARD8 value); -typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 index); +typedef void (*vgaHWWriteIndexProcPtr)(vgaHWPtr hwp, CARD8 indx, CARD8 value); +typedef CARD8 (*vgaHWReadIndexProcPtr)(vgaHWPtr hwp, CARD8 indx); typedef void (*vgaHWWriteProcPtr)(vgaHWPtr hwp, CARD8 value); typedef CARD8 (*vgaHWReadProcPtr)(vgaHWPtr hwp); typedef void (*vgaHWMiscProcPtr)(vgaHWPtr hwp); Index: xc/programs/Xserver/hw/xfree86/xaa/Imakefile diff -u xc/programs/Xserver/hw/xfree86/xaa/Imakefile:3.41 xc/programs/Xserver/hw/xfree86/xaa/Imakefile:3.42 --- xc/programs/Xserver/hw/xfree86/xaa/Imakefile:3.41 Tue Jun 20 01:08:49 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/Imakefile Tue Sep 19 22:05:41 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile,v 3.41 2000/06/20 05:08:49 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile,v 3.42 2000/09/20 02:05:41 keithp Exp $ #define IHaveModules #include <Server.tmpl> @@ -10,13 +10,18 @@ EXPOBJS = lsb_first/lsb_first.o msb_first/msb_first.o \ lsb_fixed/lsb_fixed.o msb_fixed/msb_fixed.o +#if BuildRender +PICTSRCS = xaaPict.c +PICTOBJS = xaaPict.o +#endif + GENSRCS = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c xaaBitBlt.c \ xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c xaaCpyPlane.c xaaFillRect.c \ xaaTEText.c xaaNonTEText.c xaaPCache.c xaaSpans.c xaaROP.c \ xaaImage.c xaaPaintWin.c xaaRect.c xaaLineMisc.c xaaBitOrder.c \ xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c xaaLine.c \ xaaSeg.c xaaDashLine.c xaaDashSeg.c xaaOverlay.c xaaOffscreen.c \ - xaaOverlayDF.c xaaStateChange.c + xaaOverlayDF.c xaaStateChange.c $(PICTSRCS) GENOBJS = xaaInit.o xaaGC.o xaaInitAccel.o xaaFallback.o xaaBitBlt.o \ xaaCpyArea.o xaaGCmisc.o xaaCpyWin.o xaaCpyPlane.o xaaFillRect.o \ @@ -24,7 +29,7 @@ xaaImage.o xaaPaintWin.o xaaRect.o xaaLineMisc.o xaaBitOrder.o \ xaaFillPoly.o xaaWideLine.o xaaTables.o xaaFillArc.o xaaLine.o \ xaaSeg.o xaaDashLine.o xaaDashSeg.o xaaOverlay.o xaaOffscreen.o \ - xaaOverlayDF.o xaaStateChange.o + xaaOverlayDF.o xaaStateChange.o $(PICTOBJS) SRCS = $(GENSRCS) OBJS = $(GENOBJS) @@ -36,7 +41,7 @@ INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(EXTINCSRC) \ -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ - -I$(SERVERSRC)/Xext + -I$(SERVERSRC)/Xext -I$(SERVERSRC)/render ModuleObjectRule() Index: xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP diff -u xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP:1.6 xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP:1.7 --- xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP:1.6 Tue May 2 20:44:21 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP Tue Sep 19 22:05:41 2000 @@ -1,11 +1,12 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP,v 1.6 2000/05/03 00:44:21 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP,v 1.7 2000/09/20 02:05:41 keithp Exp $ #define IHaveModules #include <Server.tmpl> INCLUDES = -I.. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86HWSRC) \ -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ - -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) + -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \ + -I$(SERVERSRC)/render -I$(EXTINCSRC) DEFINES = EXPDEFINES Index: xc/programs/Xserver/hw/xfree86/xaa/xaa.h diff -u xc/programs/Xserver/hw/xfree86/xaa/xaa.h:1.30 xc/programs/Xserver/hw/xfree86/xaa/xaa.h:1.35 --- xc/programs/Xserver/hw/xfree86/xaa/xaa.h:1.30 Tue Jun 20 01:08:49 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaa.h Sat Nov 18 14:37:24 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaa.h,v 1.30 2000/06/20 05:08:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaa.h,v 1.35 2000/11/18 19:37:24 tsi Exp $ */ #ifndef _XAA_H #define _XAA_H @@ -105,6 +105,10 @@ #include "regionstr.h" #include "xf86fbman.h" +#ifdef RENDER +#include "picturestr.h" +#endif + /* Flags */ #define PIXMAP_CACHE 0x00000001 #define MICROSOFT_ZERO_LINE_BIAS 0x00000002 @@ -190,6 +194,12 @@ #define OMIT_LAST 1 +/* render flags */ + +#define XAA_RENDER_NO_SRC_ALPHA 0x00000004 +#define XAA_RENDER_IMPRECISE_ONLY 0x00000002 +#define XAA_RENDER_NO_TILE 0x00000001 + typedef void (* ValidateGCProcPtr)( GCPtr pGC, @@ -1208,7 +1218,7 @@ CharInfoPtr CharInfo[255]; NonTEGlyphInfo GlyphInfo[255]; - unsigned int FullPlanemask; + unsigned int FullPlanemask; /* deprecated */ PixmapLinkPtr OffscreenPixmaps; int maxOffPixWidth; @@ -1232,7 +1242,93 @@ BackingStoreSaveAreasProcPtr SaveAreas; BackingStoreRestoreAreasProcPtr RestoreAreas; + unsigned int offscreenDepths; + Bool offscreenDepthsInitialized; + + CARD32 FullPlanemasks[32]; + +#ifdef RENDER + Bool (*Composite) ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height + ); + + Bool (*Glyphs) ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs + ); + + Bool (*SetupForCPUToScreenAlphaTexture) ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + int alphaType, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags + ); + void (*SubsequentCPUToScreenAlphaTexture) ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height + ); + int CPUToScreenAlphaTextureFlags; + CARD32 * CPUToScreenAlphaTextureFormats; + + Bool (*SetupForCPUToScreenTexture) ( + ScrnInfoPtr pScrn, + int op, + int texType, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags + ); + void (*SubsequentCPUToScreenTexture) ( + ScrnInfoPtr pScrn, + int dstx, + int dsty, + int srcx, + int srcy, + int width, + int height + ); + int CPUToScreenTextureFlags; + CARD32 * CPUToScreenTextureFormats; + + +#endif + } XAAInfoRec, *XAAInfoRecPtr; + +#define SET_SYNC_FLAG(infoRec) (infoRec)->NeedToSync = TRUE Bool Index: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c:1.9 xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c:1.10 --- xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c:1.9 Thu Jun 29 06:55:41 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c Fri Sep 1 01:49:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c,v 1.9 2000/06/29 10:55:41 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c,v 1.10 2000/09/01 05:49:45 mvojkovi Exp $ */ #include "xaa.h" @@ -190,8 +190,9 @@ int count, int skipleft ) { while(count--) { - WRITE_BITS(SHIFT_R(*bits,skipleft) | - SHIFT_L(*(bits + 1),(32 - skipleft))); + register CARD32 tmp = SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); bits++; } return base; @@ -203,8 +204,9 @@ int count, int skipleft ) { while(count--) { - WRITE_BITS(~(SHIFT_R(*bits,skipleft) | - SHIFT_L(*(bits + 1),(32 - skipleft)))); + register CARD32 tmp = ~(SHIFT_R(*bits,skipleft) | + SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); bits++; } return base; @@ -215,12 +217,14 @@ CARD32 *bits, CARD32 *base, int count, int skipleft ) { + register CARD32 tmp; while(--count) { - WRITE_BITS(SHIFT_R(*bits,skipleft) | - SHIFT_L(*(bits + 1),(32 - skipleft))); + tmp = SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft)); + WRITE_BITS(tmp); bits++; } - WRITE_BITS(SHIFT_R(*bits,skipleft)); + tmp = SHIFT_R(*bits,skipleft); + WRITE_BITS(tmp); return base; } @@ -230,12 +234,14 @@ CARD32 *bits, CARD32 *base, int count, int skipleft ) { + register CARD32 tmp; while(--count) { - WRITE_BITS(~(SHIFT_R(*bits,skipleft) | - SHIFT_L(*(bits + 1),(32 - skipleft)))); + tmp = ~(SHIFT_R(*bits,skipleft) | SHIFT_L(*(bits + 1),(32 - skipleft))); + WRITE_BITS(tmp); bits++; } - WRITE_BITS(~(SHIFT_R(*bits,skipleft))); + tmp = ~(SHIFT_R(*bits,skipleft)); + WRITE_BITS(tmp); return base; } Index: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c:1.11 xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c:1.12 --- xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c:1.11 Sat Apr 1 17:42:04 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c Thu Sep 28 16:47:59 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c,v 1.11 2000/04/01 22:42:04 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c,v 1.12 2000/09/28 20:47:59 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -69,7 +69,8 @@ IS_OFFSCREEN_PIXMAP(pSrcDrawable)) { if(infoRec->ReadPixmap && (pGC->alu == GXcopy) && (pSrcDrawable->bitsPerPixel == pDstDrawable->bitsPerPixel) && - ((pGC->planemask & infoRec->FullPlanemask) == infoRec->FullPlanemask)) + ((pGC->planemask & infoRec->FullPlanemasks[pSrcDrawable->depth - 1]) + == infoRec->FullPlanemasks[pSrcDrawable->depth - 1])) { return (XAABitBlt( pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height, dstx, dsty, Index: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c:1.10 xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c:1.11 --- xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c:1.10 Mon Jun 12 22:51:24 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c Mon Sep 25 19:56:13 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c,v 1.10 2000/06/13 02:51:24 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c,v 1.11 2000/09/25 23:56:13 mvojkovi Exp $ */ /* A CopyPlane function that handles bitmap->screen copies and @@ -45,7 +45,7 @@ int dstx, int dsty, unsigned long bitPlane ){ - if(pSrc->type == DRAWABLE_PIXMAP) { + if((pSrc->type == DRAWABLE_PIXMAP) && !XAA_DEPTH_BUG(pGC)) { if(pSrc->bitsPerPixel == 1) { return(XAABitBlt(pSrc, pDst, pGC, srcx, srcy, width, height, dstx, dsty, Index: xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c:1.15 xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c:1.18 --- xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c:1.15 Sun Jun 20 04:41:38 1999 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c Thu Sep 28 16:48:00 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c,v 1.15 1999/06/20 08:41:38 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGC.c,v 1.18 2000/09/28 20:48:00 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -68,10 +68,19 @@ (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); - if(pGC->bgPixel == -1) /* -1 is reserved for transparency */ - pGC->bgPixel = 0x7fffffff; - if(pGC->fgPixel == -1) /* -1 is reserved for transparency */ - pGC->fgPixel = 0x7fffffff; + if((changes & GCPlaneMask) && + ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == + infoRec->FullPlanemasks[pGC->depth - 1])) + { + pGC->planemask = ~0; + } + + if(pGC->depth != 32) { + if(pGC->bgPixel == -1) /* -1 is reserved for transparency */ + pGC->bgPixel = 0x7fffffff; + if(pGC->fgPixel == -1) /* -1 is reserved for transparency */ + pGC->fgPixel = 0x7fffffff; + } if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){ pGCPriv->flags = OPS_ARE_PIXMAP; Index: xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c:1.14 xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c:1.15 --- xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c:1.14 Tue May 2 20:44:23 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c Mon Sep 25 19:56:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c,v 1.14 2000/05/03 00:44:23 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c,v 1.15 2000/09/25 23:56:14 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -261,7 +261,7 @@ /* Check for TE Fonts */ - if(!TERMINALFONT(pGC->font) || BigFont) { + if(!TERMINALFONT(pGC->font) || BigFont || (pGC->depth == 32)) { if(infoRec->ImageGlyphBltNonTE && CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltNonTEFlags) && CHECK_FG(pGC,infoRec->ImageGlyphBltNonTEFlags) && @@ -383,9 +383,9 @@ if(pGC->ops->Polylines != XAAFallbackOps.Polylines) pGC->ops->PolyRectangle = miPolyRectangle; - - } else if(pGCPriv->DashPattern) { /* LineDoubleDash */ + } else if(pGCPriv->DashPattern && (pGC->depth != 32)) { + /* LineDoubleDash */ if(infoRec->PolySegmentThinDashed && !(infoRec->PolySegmentThinDashedFlags & TRANSPARENCY_ONLY) && CHECK_PLANEMASK(pGC,infoRec->PolySegmentThinDashedFlags) && Index: xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c:1.19 xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c:1.20 --- xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c:1.19 Sat Apr 1 17:42:04 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c Mon Sep 25 19:56:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c,v 1.19 2000/04/01 22:42:04 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c,v 1.20 2000/09/25 23:56:14 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -401,11 +401,14 @@ ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); int bpp = BitsPerPixel(depth); + Bool depthBug = FALSE; if(!w || !h) return; if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; + depthBug = XAA_DEPTH_BUG(pGC); + if(((format == ZPixmap) && infoRec->WritePixmap && ((pDraw->bitsPerPixel == bpp) || ((pDraw->bitsPerPixel == 24) && (bpp == 32) && @@ -414,13 +417,13 @@ CHECK_ROPSRC(pGC,infoRec->WritePixmapFlags) && CHECK_PLANEMASK(pGC,infoRec->WritePixmapFlags) && CHECK_NO_GXCOPY(pGC,infoRec->WritePixmapFlags)) || - ((format == XYBitmap) && infoRec->WriteBitmap && + ((format == XYBitmap) && !depthBug && infoRec->WriteBitmap && CHECK_ROP(pGC,infoRec->WriteBitmapFlags) && CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) && CHECK_PLANEMASK(pGC,infoRec->WriteBitmapFlags) && CHECK_COLORS(pGC,infoRec->WriteBitmapFlags) && !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) || - ((format == XYPixmap) && infoRec->WriteBitmap && + ((format == XYPixmap) && !depthBug && infoRec->WriteBitmap && CHECK_ROP(pGC,infoRec->WriteBitmapFlags) && CHECK_ROPSRC(pGC,infoRec->WriteBitmapFlags) && !(infoRec->WriteBitmapFlags & NO_PLANEMASK) && Index: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c:1.28 xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c:1.32 --- xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c:1.28 Sat Apr 22 17:47:08 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c Thu Nov 16 14:45:05 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.28 2000/04/22 21:47:08 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.32 2000/11/16 19:45:05 eich Exp $ */ #include "misc.h" #include "xf86.h" @@ -106,7 +106,11 @@ { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAScreenPtr pScreenPriv; - + int i; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + if (XAAGeneration != serverGeneration) { if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) || ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) || @@ -131,11 +135,17 @@ infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); if(!(infoRec->Flags & LINEAR_FRAMEBUFFER)) infoRec->Flags &= ~OFFSCREEN_PIXMAPS; -#if 0 - if(pScreen->backingStoreSupport || pScreen->saveUnderSupport) - infoRec->Flags &= ~OFFSCREEN_PIXMAPS; -#endif + + if(!infoRec->FullPlanemask) { /* for backwards compatibility */ + infoRec->FullPlanemask = (1 << pScrn->depth) - 1; + infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask; + } + for(i = 0; i < 32; i++) { + if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */ + infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1; + } + if(!XAAInitAccel(pScreen, infoRec)) return FALSE; pScreenPriv->AccelInfoRec = infoRec; infoRec->ScratchGC.pScreen = pScreen; @@ -193,6 +203,15 @@ pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess; pScreenPriv->WindowExposures = pScreen->WindowExposures; +#ifdef RENDER + if (ps) + { + pScreenPriv->Composite = ps->Composite; + ps->Composite = XAAComposite; + pScreenPriv->Glyphs = ps->Glyphs; + ps->Glyphs = XAAGlyphs; + } +#endif if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) XAASetupOverlay8_32Planar(pScreen); @@ -263,7 +282,8 @@ ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) { if(infoRec->ReadPixmap && (format == ZPixmap) && - ((planemask & infoRec->FullPlanemask) == infoRec->FullPlanemask) && + ((planemask & infoRec->FullPlanemasks[pDraw->depth - 1]) == + infoRec->FullPlanemasks[pDraw->depth - 1]) && (pDraw->bitsPerPixel == BitsPerPixel(pDraw->depth))) { (*infoRec->ReadPixmap)(pScrn, @@ -433,6 +453,43 @@ XAARestoreAreas); } +static int +XAAPixmapBPP (ScreenPtr pScreen, int depth) +{ + PixmapPtr pPix; + int bpp; + DestroyPixmapProcPtr destroyPixmap; + + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); + pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth); + XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); + if (!pPix) + return 0; + bpp = pPix->drawable.bitsPerPixel; + destroyPixmap = pScreen->DestroyPixmap; + XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap); + (*pScreen->DestroyPixmap) (pPix); + XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap); + return bpp; +} + +static void +XAAInitializeOffscreenDepths (ScreenPtr pScreen) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int d, dep; + + infoRec->offscreenDepthsInitialized = TRUE; + infoRec->offscreenDepths = 0; + if (infoRec->Flags & OFFSCREEN_PIXMAPS) { + for (d = 0; d < pScreen->numDepths; d++) { + dep = pScreen->allowedDepths[d].depth; + if (XAAPixmapBPP (pScreen, dep) == pScrn->bitsPerPixel) + infoRec->offscreenDepths |= (1 << (dep - 1)); + } + } +} static PixmapPtr XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth) @@ -443,9 +500,10 @@ PixmapPtr pPix = NULL; int size = w * h; - if((infoRec->Flags & OFFSCREEN_PIXMAPS) && pScrn->vtSema && (depth != 1) && - ((BitsPerPixel(depth) == pScrn->bitsPerPixel) || - !(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)) && + if (!infoRec->offscreenDepthsInitialized) + XAAInitializeOffscreenDepths (pScreen); + + if(pScrn->vtSema && (infoRec->offscreenDepths & (1 << (depth - 1))) && (size >= MIN_OFFPIX_SIZE) && !SwitchedOut && (!infoRec->maxOffPixWidth || (w <= infoRec->maxOffPixWidth)) && (!infoRec->maxOffPixHeight || (h <= infoRec->maxOffPixHeight)) ) @@ -455,7 +513,7 @@ FBAreaPtr area; int gran = 0; - switch(pScrn->bitsPerPixel) { + switch(pScrn->bitsPerPixel) { case 24: case 8: gran = 4; break; case 16: gran = 2; break; @@ -466,57 +524,57 @@ if(BITMAP_SCANLINE_PAD == 64) gran *= 2; - if(!(pLink = xalloc(sizeof(PixmapLink)))) - goto BAILOUT; - if(!(area = xf86AllocateOffscreenArea(pScreen, w, h, gran, 0, XAARemoveAreaCallback, NULL))) { - xfree(pLink); goto BAILOUT; } + if(!(pLink = xalloc(sizeof(PixmapLink)))) { + xf86FreeOffscreenArea(area); + goto BAILOUT; + } + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); pPix = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth); XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); - - if(pPix) { - pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); - pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); - pPix->drawable.x = area->box.x1; - pPix->drawable.y = area->box.y1; - pPix->drawable.width = w; - pPix->drawable.height = h; - pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel; - pPix->devKind = pScreenPix->devKind; - pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr; - area->devPrivate.ptr = pPix; - - pPriv->flags = OFFSCREEN; - pPriv->offscreenArea = area; - - pLink->next = infoRec->OffscreenPixmaps; - pLink->pPix = pPix; - infoRec->OffscreenPixmaps = pLink; - } else { - xfree(pLink); + if (!pPix) { + xfree (pLink); xf86FreeOffscreenArea(area); - } + goto BAILOUT; + } + + pScreenPix = (*pScreen->GetScreenPixmap)(pScreen); + + pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + pPix->drawable.x = area->box.x1; + pPix->drawable.y = area->box.y1; + pPix->drawable.width = w; + pPix->drawable.height = h; + pPix->drawable.bitsPerPixel = pScrn->bitsPerPixel; + pPix->devKind = pScreenPix->devKind; + pPix->devPrivate.ptr = pScreenPix->devPrivate.ptr; + area->devPrivate.ptr = pPix; + + pPriv->flags = OFFSCREEN; + pPriv->offscreenArea = area; + + pLink->next = infoRec->OffscreenPixmaps; + pLink->pPix = pPix; + infoRec->OffscreenPixmaps = pLink; + return pPix; } BAILOUT: - - if(!pPix) { - XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); - pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth); - XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); - - if(pPix) { - pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); - pPriv->flags = 0; - pPriv->offscreenArea = NULL; - if(!w || !h) /* either scratch or shared memory */ - pPriv->flags |= SHARED_PIXMAP; - } + XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); + pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth); + XAA_SCREEN_EPILOGUE (pScreen, CreatePixmap, XAACreatePixmap); + + if(pPix) { + pPriv = XAA_GET_PIXMAP_PRIVATE(pPix); + pPriv->flags = 0; + pPriv->offscreenArea = NULL; + if(!w || !h) /* either scratch or shared memory */ + pPriv->flags |= SHARED_PIXMAP; } return pPix; Index: xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c:1.24 xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c:1.27 --- xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c:1.24 Tue Jun 20 01:08:49 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c Sat Oct 21 18:26:20 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c,v 1.24 2000/06/20 05:08:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c,v 1.27 2000/10/21 22:26:20 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -13,6 +13,7 @@ #include "xf86fbman.h" #include "servermd.h" + /* * XAA Config options */ @@ -131,9 +132,6 @@ if(!XAAInitStateWrap(pScreen, infoRec)) return FALSE; } - if(!infoRec->FullPlanemask) - infoRec->FullPlanemask = (1 << pScrn->depth) - 1; - if (serverGeneration == 1) xf86DrvMsg(index, X_INFO, "Using XFree86 Acceleration Architecture (XAA)\n"); @@ -431,6 +429,20 @@ infoRec->SubsequentImageWriteScanline = NULL; } +#ifndef __i386__ + /* XAA makes some unaligned accesses when clipping is not available */ + #define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X) + if(HaveImageWriteRect && + ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) + { + HaveImageWriteRect = FALSE; + } + if(HaveScanlineImageWriteRect && + ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS)) + { + HaveScanlineImageWriteRect = FALSE; + } +#endif if (serverGeneration == 1) { if(HaveScreenToScreenCopy) @@ -1190,6 +1202,16 @@ infoRec->ComputeDash = XAAComputeDash; } +#ifdef RENDER + /* Render stuff */ + if(!infoRec->Composite && + infoRec->SetupForCPUToScreenAlphaTexture && + infoRec->SubsequentCPUToScreenAlphaTexture) + { + infoRec->Composite = XAADoComposite; + } + +#endif /************ Validation Functions **************/ @@ -1321,9 +1343,8 @@ infoRec->PolylinesMask = infoRec->FillSpansMask | GCLineStyle | GCLineWidth; - if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed) + if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed) infoRec->PolylinesMask |= GCDashList; - if(compositeFlags & NO_PLANEMASK) infoRec->PolylinesMask |= GCPlaneMask; if((compositeFlags & GXCOPY_ONLY) || Index: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c:1.11 xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c:1.12 --- xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c:1.11 Mon Mar 27 20:21:04 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c Thu Sep 28 16:48:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.11 2000/03/28 01:21:04 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.12 2000/09/28 20:48:01 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -293,6 +293,7 @@ XAASetupOverlay8_32Planar(ScreenPtr pScreen) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + int i; pScreen->PaintWindowBackground = XAAPaintWindow8_32; pScreen->PaintWindowBorder = XAAPaintWindow8_32; @@ -302,4 +303,6 @@ miOverlaySetTransFunction(pScreen, XAASetColorKey8_32); infoRec->FullPlanemask = ~0; + for(i = 0; i < 32; i++) /* haven't thought about this much */ + infoRec->FullPlanemasks[i] = ~0; } Index: xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c:1.29 xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c:1.30 --- xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c:1.29 Mon Jun 12 22:51:24 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c Mon Sep 25 19:56:14 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c,v 1.29 2000/06/13 02:51:24 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c,v 1.30 2000/09/25 23:56:14 mvojkovi Exp $ */ #include "misc.h" #include "xf86.h" @@ -2171,12 +2171,13 @@ PixmapPtr pPixmap = pGC->stipple; XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPixmap); + if(XAA_DEPTH_BUG(pGC)) + return 0; if(!(pPriv->flags & REDUCIBILITY_CHECKED) && (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) { XAACheckStippleReducibility(pPixmap); } - if(pPriv->flags & REDUCIBLE_TO_8x8) { if(infoRec->CanDoMono8x8 && Index: xc/programs/Xserver/hw/xfree86/xaa/xaaPict.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/xaa/xaaPict.c:1.5 --- /dev/null Mon Dec 18 14:32:23 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaPict.c Sun Oct 22 16:54:30 2000 @@ -0,0 +1,353 @@ +/* + * $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPict.c,v 1.5 2000/10/22 20:54:30 mvojkovi Exp $ + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "misc.h" +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" + +#include "X.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "windowstr.h" +#include "xf86str.h" +#include "mi.h" +#include "picturestr.h" +#include "glyphstr.h" +#include "picture.h" +#include "mipict.h" +#include "xaa.h" +#include "xaalocal.h" +#include "xaawrap.h" +#include "xf86fbman.h" +#include "servermd.h" + +static Bool +XAAGetRGBAFromPixel( + CARD32 pixel, + CARD16 *red, + CARD16 *green, + CARD16 *blue, + CARD16 *alpha, + CARD32 format +){ + + *alpha = 0xffff; + + switch(PICT_FORMAT_BPP(format)) { + case 32: + switch(format) { + case PICT_a8r8g8b8: + *alpha = (pixel >> 24) & 0x000000ff; + *alpha |= *alpha << 8; + case PICT_x8r8g8b8: + *blue = pixel & 0x000000ff; + *blue |= *blue << 8; + *green = pixel & 0x0000ff00; + *green |= *green >> 8; + *red = (pixel >> 16) & 0x000000ff; + *red |= *red << 8; + return TRUE; + case PICT_a8b8g8r8: + *alpha = (pixel >> 24) & 0x000000ff; + *alpha |= *alpha << 8; + case PICT_x8b8g8r8: + *red = pixel & 0x000000ff; + *red |= *red << 8; + *green = pixel & 0x0000ff00; + *green |= *green >> 8; + *blue = (pixel >> 16) & 0x000000ff; + *blue |= *blue << 8; + return TRUE; + default: + break; + } + break; + case 24: + switch(format) { + case PICT_r8g8b8: + *blue = pixel & 0x000000ff; + *blue |= *blue << 8; + *green = pixel & 0x0000ff00; + *green |= *green >> 8; + *red = (pixel >> 16) & 0x000000ff; + *red |= *red << 8; + return TRUE; + case PICT_b8g8r8: + *red = pixel & 0x000000ff; + *red |= *red << 8; + *green = pixel & 0x0000ff00; + *green |= *green >> 8; + *blue = (pixel >> 16) & 0x000000ff; + *blue |= *blue << 8; + return TRUE; + default: + break; + } + break; + case 16: + case 8: + case 4: + default: + return FALSE; + } + + return FALSE; +} + +/* 8:8:8 + PICT_a8 -> 8:8:8:8 texture */ + +void +XAA_888_plus_PICT_a8_to_8888 ( + CARD32 color, + CARD8 *alphaPtr, /* in bytes */ + int alphaPitch, + CARD32 *dstPtr, + int dstPitch, /* in dwords */ + int width, + int height +){ + int x; + + color &= 0x00ffffff; + + while(height--) { + for(x = 0; x < width; x++) + dstPtr[x] = color | (alphaPtr[x] << 24); + dstPtr += dstPitch; + alphaPtr += alphaPitch; + } +} + + +Bool +XAADoComposite ( + CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height +){ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + RegionRec region; + CARD32 *formats; + BoxPtr pbox; + int nbox; + + if(!infoRec->pScrn->vtSema || + ((pDst->pDrawable->type != DRAWABLE_WINDOW) && + !IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) + return FALSE; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + if(pMask) { + /* for now we only do it if there is a 1x1 (solid) source */ + + if((pSrc->pDrawable->width == 1) && (pSrc->pDrawable->height == 1)) { + CARD16 red, green, blue, alpha; + CARD32 pixel = + *((CARD32*)(((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr)); + + if(!XAAGetRGBAFromPixel(pixel,&red,&green,&blue,&alpha,pSrc->format)) + return FALSE; + + if((alpha != 0xffff) && + (infoRec->CPUToScreenAlphaTextureFlags & XAA_RENDER_NO_SRC_ALPHA)) + return FALSE; + + formats = infoRec->CPUToScreenAlphaTextureFormats; + + while(*formats != pMask->format) { + if(!(*formats)) return FALSE; + formats++; + } + + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + return TRUE; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) + return TRUE; + + if(!(infoRec->SetupForCPUToScreenAlphaTexture)(infoRec->pScrn, + op, red, green, blue, alpha, pMask->format, + ((PixmapPtr)(pMask->pDrawable))->devPrivate.ptr, + ((PixmapPtr)(pMask->pDrawable))->devKind, + pMask->pDrawable->width, pMask->pDrawable->height, 0)) + return FALSE; + + xMask -= xDst; + yMask -= yDst; + + while(nbox--) { + (*infoRec->SubsequentCPUToScreenAlphaTexture)(infoRec->pScrn, + pbox->x1, pbox->y1, + pbox->x1 + xMask, pbox->y1 + yMask, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + pbox++; + } + + SET_SYNC_FLAG(infoRec); + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + } else { + formats = infoRec->CPUToScreenTextureFormats; + + while(*formats != pSrc->format) { + if(!(*formats)) return FALSE; + formats++; + } + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + return TRUE; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) + return TRUE; + + if(!(infoRec->SetupForCPUToScreenTexture)(infoRec->pScrn, + op, pSrc->format, + ((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr, + ((PixmapPtr)(pSrc->pDrawable))->devKind, + pSrc->pDrawable->width, pSrc->pDrawable->height, 0)) + return FALSE; + + xSrc -= xDst; + ySrc -= yDst; + + while(nbox--) { + (*infoRec->SubsequentCPUToScreenTexture)(infoRec->pScrn, + pbox->x1, pbox->y1, + pbox->x1 + xSrc, pbox->y1 + ySrc, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + pbox++; + } + + SET_SYNC_FLAG(infoRec); + REGION_UNINIT(pScreen, ®ion); + return TRUE; + } + + + return FALSE; +} + + +void +XAAComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAA_RENDER_PROLOGUE(pScreen, Composite); + + if(!infoRec->Composite || + !(*infoRec->Composite)(op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height)) + { + SYNC_CHECK(pDst->pDrawable); + (*GetPictureScreen(pScreen)->Composite) (op, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height); + } + + if(pDst->pDrawable->type == DRAWABLE_PIXMAP) + (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY; + + XAA_RENDER_EPILOGUE(pScreen, Composite, XAAComposite); +} + +void +XAAGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + XAA_RENDER_PROLOGUE(pScreen, Glyphs); + + if(!infoRec->Glyphs || + !(*infoRec->Glyphs)(op, pSrc, pDst, maskFormat, + xSrc, ySrc, nlist, list, glyphs)) + { + SYNC_CHECK(pDst->pDrawable); + (*GetPictureScreen(pScreen)->Glyphs) (op, pSrc, pDst, maskFormat, + xSrc, ySrc, nlist, list, glyphs); + } + + if(pDst->pDrawable->type == DRAWABLE_PIXMAP) + (XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDst->pDrawable)))->flags |= DIRTY; + + XAA_RENDER_EPILOGUE(pScreen, Glyphs, XAAGlyphs); +} Index: xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c:1.1 xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c:1.2 --- xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c:1.1 Sun Mar 21 02:35:31 1999 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c Thu Sep 28 16:48:01 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c,v 1.1 1999/03/21 07:35:31 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaROP.c,v 1.2 2000/09/28 20:48:01 mvojkovi Exp $ */ #include "X.h" #include "misc.h" @@ -101,9 +101,9 @@ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); int ret = 0; - pm &= infoRec->FullPlanemask; + pm &= infoRec->FullPlanemasks[pScrn->depth - 1]; - if(pm == infoRec->FullPlanemask) { + if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) { if(!NO_SRC_ROP(*rop)) ret |= ROP_PAT; *rop = XAAPatternROP[*rop]; @@ -136,9 +136,9 @@ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); int ret = 0; - pm &= infoRec->FullPlanemask; + pm &= infoRec->FullPlanemasks[pScrn->depth - 1]; - if(pm == infoRec->FullPlanemask) { + if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) { if(!NO_SRC_ROP(*rop)) ret |= ROP_PAT; *rop = XAAPatternROP[*rop]; Index: xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c:1.9 xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c:1.10 --- xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c:1.9 Mon Jun 12 22:51:25 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c Fri Sep 1 01:49:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c,v 1.9 2000/06/13 02:51:25 mvojkovi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c,v 1.10 2000/09/01 05:49:45 mvojkovi Exp $ */ #include "xaa.h" #include "xaalocal.h" @@ -697,9 +697,8 @@ pat |= SHIFT_L(pat,width); while(dwords--) { -#ifdef TRIPLE_BITS CARD32 bits = SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift); - +#ifdef TRIPLE_BITS if(dwords >= 2) { WRITE_BITS3(bits); dwords -= 2; @@ -710,7 +709,7 @@ WRITE_BITS1(bits); } #else - WRITE_BITS(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift)); + WRITE_BITS(bits); #endif shift += 32; @@ -734,9 +733,8 @@ pat |= SHIFT_L(pat,width); while(dwords--) { -#ifdef TRIPLE_BITS CARD32 bits = ~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift)); - +#ifdef TRIPLE_BITS if(dwords >= 2) { WRITE_BITS3(bits); dwords -= 2; @@ -747,7 +745,7 @@ WRITE_BITS1(bits); } #else - WRITE_BITS(~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift))); + WRITE_BITS(bits); #endif shift += 32; Index: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c diff -u xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c:1.8 xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c:1.9 --- xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c:1.8 Tue May 2 20:44:24 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c Fri Sep 1 01:49:45 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c,v 1.8 2000/05/03 00:44:24 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c,v 1.9 2000/09/01 05:49:45 mvojkovi Exp $ */ #include "xaa.h" @@ -176,8 +176,9 @@ base = (CARD32*)infoRec->ColorExpandBase; - while(count--) { - WRITE_BITS(SHIFT_R(glyphs[0][line++],skipleft)); + while(count--) { + register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft); + WRITE_BITS(tmp); } w -= width; @@ -373,8 +374,9 @@ bufferNo = 0; while(count--) { + register CARD32 tmp = SHIFT_R(glyphs[0][line++],skipleft); base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; - WRITE_BITS(SHIFT_R(glyphs[0][line++],skipleft)); + WRITE_BITS(tmp); (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) bufferNo = 0; Index: xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h diff -u xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h:1.26 xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h:1.32 --- xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h:1.26 Tue Jun 20 01:08:49 2000 +++ xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h Sat Nov 18 14:37:25 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h,v 1.26 2000/06/20 05:08:49 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h,v 1.32 2000/11/18 19:37:25 tsi Exp $ */ #ifndef _XAALOCAL_H #define _XAALOCAL_H @@ -11,6 +11,9 @@ #include "xf86fbman.h" #include "xaa.h" #include "mi.h" +#ifdef RENDER +#include "picturestr.h" +#endif #define GCWhenForced (GCArcMode << 1) @@ -56,6 +59,10 @@ void (*LeaveVT)(int, int); int (*SetDGAMode)(int, int, DGADevicePtr); void (*EnableDisableFBAccess)(int, Bool); +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; +#endif } XAAScreenRec, *XAAScreenPtr; #define OPS_ARE_PIXMAP 0x00000001 @@ -1520,6 +1527,63 @@ void XAAMoveOutOffscreenPixmap(PixmapPtr pPix); Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec); +#ifdef RENDER +void +XAAComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + +void +XAAGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs); + + +Bool +XAADoComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + + +/* helpers */ +void +XAA_888_plus_PICT_a8_to_8888 ( + CARD32 color, + CARD8 *alphaPtr, /* in bytes */ + int alphaPitch, + CARD32 *dstPtr, + int dstPitch, /* in dwords */ + int width, + int height +); + +#endif + + extern GCOps XAAFallbackOps; extern GCFuncs XAAGCFuncs; extern int XAAScreenIndex; @@ -1556,8 +1620,6 @@ #define XAA_GET_PIXMAP_PRIVATE(pix)\ (XAAPixmapPtr)((pix)->devPrivates[XAAPixmapIndex].ptr) -#define SET_SYNC_FLAG(infoRec) infoRec->NeedToSync = TRUE - #define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) #define CHECK_FG(pGC, flags) \ @@ -1576,7 +1638,8 @@ #define CHECK_PLANEMASK(pGC, flags) \ (!(flags & NO_PLANEMASK) || \ - ((pGC->planemask & infoRec->FullPlanemask) == infoRec->FullPlanemask)) + ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == \ + infoRec->FullPlanemasks[pGC->depth - 1])) #define CHECK_COLORS(pGC, flags) \ (!(flags & RGB_EQUAL) || \ @@ -1594,6 +1657,9 @@ #define OFFSCREEN_PIXMAP_LOCKED(pPix)\ ((XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pPix)))->flags & LOCKED_PIXMAP) + +#define XAA_DEPTH_BUG(pGC) \ + ((pGC->depth == 32) && (pGC->bgPixel == 0xffffffff)) #define DELIST_OFFSCREEN_PIXMAP(pPix) { \ PixmapLinkPtr _pLink, _prev; \ Index: xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h diff -u xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h:1.4 xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h:1.5 --- xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h:1.4 Sat May 29 23:03:34 1999 +++ xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h Tue Sep 19 22:05:42 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h,v 1.4 1999/05/30 03:03:34 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaawrap.h,v 1.5 2000/09/20 02:05:42 keithp Exp $ */ #define XAA_SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ @@ -58,7 +58,14 @@ pGC->ops = &XAAPixmapOps;\ pixPriv->flags |= DIRTY - +#ifdef RENDER +#define XAA_RENDER_PROLOGUE(pScreen,field)\ + (GetPictureScreen(pScreen)->field = \ + ((XAAScreenPtr) (pScreen)->devPrivates[XAAScreenIndex].ptr)->field) + +#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ + (GetPictureScreen(pScreen)->field = wrapper) +#endif /* This also works fine for drawables */ Index: xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h:1.3 xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h:1.4 --- xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h:1.3 Sun Jan 31 07:22:15 1999 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h Tue Jul 25 21:52:26 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h,v 1.3 1999/01/31 12:22:15 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/OScompiler.h,v 1.4 2000/07/26 01:52:26 tsi Exp $ */ /* * Copyright IBM Corporation 1987,1988,1989 * @@ -32,9 +32,7 @@ #define ABS(x) (((x)>0)?(x):-(x)) #include "misc.h" -#ifdef XFree86LOADER #include "xf86_ansic.h" -#endif #include "compiler.h" #ifdef lint Index: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c:1.4 xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c:1.5 --- xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c:1.4 Sat Sep 25 10:38:16 1999 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c Tue Sep 26 11:57:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c,v 1.4 1999/09/25 14:38:16 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcCpArea.c,v 1.5 2000/09/26 15:57:21 tsi Exp $ */ /* * Copyright IBM Corporation 1987,1988,1989 * @@ -71,7 +71,7 @@ unsigned long planemask ) { - unsigned long *psrcBase, *pdstBase; + CARD32 *psrcBase, *pdstBase; /* start of src and dst bitmaps */ int widthSrc, widthDst; /* add to get to same position in next line */ Index: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c:1.5 xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c:1.6 --- xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c:1.5 Sat Sep 25 10:38:17 1999 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c Tue Sep 26 11:57:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c,v 1.5 1999/09/25 14:38:17 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcGC.c,v 1.6 2000/09/26 15:57:21 tsi Exp $ */ /* Copyright (c) 1987 X Consortium @@ -295,9 +295,9 @@ void xf4bppValidateGC( pGC, changes, pDrawable ) - register GCPtr pGC ; - register Mask changes ; - DrawablePtr pDrawable ; + GCPtr pGC; + unsigned long changes; + DrawablePtr pDrawable; { register ppcPrivGCPtr devPriv ; WindowPtr pWin ; Index: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c:1.3 xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c:1.3 Sun Jun 6 04:49:00 1999 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c Tue Sep 26 11:57:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c,v 1.3 1999/06/06 08:49:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcImg.c,v 1.4 2000/09/26 15:57:21 tsi Exp $ */ /* * Copyright IBM Corporation 1987,1988,1989 * @@ -76,7 +76,7 @@ int depth, i, linelength, width ; DDXPointRec pt ; char *pbits ; - unsigned long int gcv[2] ; + XID gcv[2] ; PixmapPtr pPixmap = (PixmapPtr) NULL ; GCPtr pGC ; char *pDst = pdstLine ; Index: xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h:1.2 xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h:1.3 --- xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h:1.2 Sat Jul 25 12:59:46 1998 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h Tue Sep 26 11:57:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h,v 1.2 1998/07/25 16:59:46 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/wm3.h,v 1.3 2000/09/26 15:57:21 tsi Exp $ */ @@ -63,7 +63,7 @@ #else #define UPDRW(destp,src) \ { volatile char *_dtmp = (volatile char *)(destp); \ - int _stmp = (src); \ + unsigned int _stmp = (src); \ volatile int dummy; /* Bit bucket. */ \ _stmp = ldl_u(&_stmp); \ dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \ Index: xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h diff -u xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h:1.4 xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h:1.5 --- xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h:1.4 Sun Jun 6 04:49:08 1999 +++ xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h Tue Sep 26 11:57:21 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h,v 1.4 1999/06/06 08:49:08 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/xf4bpp.h,v 1.5 2000/09/26 15:57:21 tsi Exp $ */ #ifndef __XF4BPP_H__ @@ -195,7 +195,7 @@ void xf4bppValidateGC( #if NeedFunctionPrototypes GCPtr, - Mask, + unsigned long, DrawablePtr #endif ); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile:1.6 xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile:1.13 --- xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile:1.6 Tue Jun 13 19:15:51 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile Wed Dec 13 20:21:57 2000 @@ -1,21 +1,35 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile,v 1.6 2000/06/13 23:15:51 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile,v 1.13 2000/12/14 01:21:57 dawes Exp $ XCOMM CDEBUGFLAGS=-g -Wall -ansi -pedantic +#if DoLoadableServer +LDSRCS = libc_wrapper.c loader.c +LDOBJS = libc_wrapper.o loader.o +#endif + +#if HasNCurses +TEXTSRC = text-mode.c +TEXTOBJ = text-mode.o +#endif + SRCS =\ accessx.c\ card-cfg.c\ cards.c\ config.c\ + expert.c\ help.c\ interface.c\ keyboard-cfg.c\ + $(LDSRCS) \ monitor-cfg.c\ mouse-cfg.c\ options.c\ screen-cfg.c\ screen.c\ startx.c\ + stubs.c\ + $(TEXTSRC)\ vidmode.c\ xf86config.c @@ -24,15 +38,19 @@ cards.o\ config.o\ card-cfg.o\ + expert.o\ help.o\ interface.o\ keyboard-cfg.o\ + $(LDOBJS) \ monitor-cfg.o\ mouse-cfg.o\ options.o\ screen-cfg.o\ screen.o\ startx.o\ + stubs.o\ + $(TEXTOBJ)\ vidmode.o\ xf86config.o @@ -61,16 +79,48 @@ AllTarget(ProgramTargetName($(PROG))) +#if DoLoadableServer +LOADERLIB = -L../loader -lxloader -L../dummylib -ldummy +MODULEDEFINES = -DUSE_MODULES +INCLUDES = -I../common -I../loader -I$(XF86OSSRC) \ + -I$(SERVERSRC)/include -I$(XINCLUDESRC) +#if !HasSnprintf +SNPRINTF_DEFS = -DNEED_SNPRINTF +#endif +WRAPPERDEFINES = -DSELF_CONTAINED_WRAPPER $(SNPRINTF_DEFS) +#endif + +#if HasNCurses +CURSESLIB = NCursesLibName +CURSESDEFINES = -DHAS_NCURSES +#endif + +DEFINES = -DXF86CONFIG=\"XConfigFile\" $(MODULEDEFINES) \ + $(CURSESDEFINES) + +#if HasDlopen +DLLIB = DlLibrary +#endif + LOCAL_LIBRARIES = $(XKBUILIB) $(XKBFILELIB) -lxf86config $(XXF86MISCLIB) \ $(XXF86VMLIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) \ - $(XPMLIB) $(XLIB) -lm + $(XPMLIB) $(LOADERLIB) $(DLLIB) $(XLIB) $(CURSESLIB) \ + RegexLibrary -lm NormalProgramTarget($(PROG),$(OBJS),,$(LOCAL_LIBRARIES),) InstallProgramWithFlags($(PROG),$(BINDIR),NullParameter) InstallMultipleFlags($(XBMPICS),$(INCDIR)/X11/bitmaps,$(INSTINCFLAGS)) InstallMultipleFlags($(XPMPICS),$(INCDIR)/X11/pixmaps,$(INSTINCFLAGS)) InstallAppDefaults(XF86Cfg) + +CppManTarget(xf86cfg,) InstallManPage(xf86cfg,$(MANDIR)) NormalLibraryObjectRule() + +#if DoLoadableServer +LinkSourceFile(libc_wrapper.c, $(XF86OSSRC)/shared) +SpecialCObjectRule(libc_wrapper,NullParameter,$(WRAPPERDEFINES) $(EXT_DEFINES)) +#endif + DependTarget() Index: xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad:1.3 xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad:1.6 --- xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad:1.3 Tue Jun 13 19:15:51 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad Thu Nov 30 15:55:16 2000 @@ -26,7 +26,7 @@ !! !! Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> !! -!! $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad,v 1.3 2000/06/13 23:15:51 dawes Exp $ +!! $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad,v 1.6 2000/11/30 20:55:16 paulo Exp $ !! *Form.background: gray85 @@ -178,7 +178,6 @@ *card.label: Card *monitor.label: Monitor -!*commands.background: black *commands.borderWidth: 0 *commands.defaultDistance: 2 *commands.?.bottom: chainTop @@ -193,6 +192,11 @@ *commands.card.tip: Add video card *commands.monitor.tip: Add monitor +*hpane.showGrip: False +*hpane.expert.label: Expert Mode +*topM.min: 200 +*topM.max: 200 +*topM.justify: left *topM.label: Configure Layout *topM*layout.label: Configure Layout *topM*screen.label: Configure Screen @@ -201,6 +205,9 @@ *topM.showGrip: False *work.showGrip: False +*MenuButton.leftBitmap: menu10 +*SmeBSB.HorizontalMargins: 18 + *back.label: << Back *next.label: Next >> *ok.label: Ok @@ -359,12 +366,26 @@ *cardModel.filter.fromHoriz: label *cardModel.filter.width: 171 *cardModel.viewport.width: 302 -*cardModel.viewport.height: 244 +*cardModel.viewport.height: 212 +*cardModel.driver.justify: left +*cardModel.driverL.label: Driver +*cardModel.driverL.fromVert: viewport +*cardModel.driverL.width: 50 +*cardModel.driverL.justify: right +*cardModel.driver.fromVert: viewport +*cardModel.driver.fromHoriz: driverL +*cardModel.driver.width: 250 +*cardModel.driver.left: chainRight +*cardModel.driver.right: chainRight *cardModel.busidL.label: BusID -*cardModel.busidL.fromVert: viewport -*cardModel.busid.fromVert: viewport +*cardModel.busidL.fromVert: driver +*cardModel.busidL.width: 50 +*cardModel.busidL.justify: right +*cardModel.busid.fromVert: driver *cardModel.busid.fromHoriz: busidL -*cardModel.busid.width: 255 +*cardModel.busid.width: 250 +*cardModel.busid.left: chainRight +*cardModel.busid.right: chainRight *cardModel.viewport.forceBars: True *cardModel.viewport.allowVert: True *cardModel.viewport.useRight: True @@ -398,18 +419,18 @@ .xf86cfg.pane.work.Simple.borderWidth: 1 .xf86cfg.pane.work.Simple.translations:\ -<Btn1Down>: select-device()\n\ -<Btn1Motion>: move-device()\n\ -<Btn1Up>: unselect-device()\n\ -<Btn3Down>: device-popup()\n\ -<Btn3Up>: device-popdown() +Any<Btn1Down>: select-device()\n\ +Any<Btn1Motion>: move-device()\n\ +Any<Btn1Up>: unselect-device()\n\ +Any<Btn3Down>: device-popup()\n\ +Any<Btn3Up>: device-popdown() .xf86cfg.pane.work.screen.translations:\ -<Btn1Down>: select-device()\n\ -<Btn1Motion>: move-device()\n\ -<Btn1Up>: unselect-device()\n\ -<Btn3Down>: device-popup()\n\ -<Btn3Up>: device-popdown() +Any<Btn1Down>: select-device()\n\ +Any<Btn1Motion>: move-device()\n\ +Any<Btn1Up>: unselect-device()\n\ +Any<Btn3Down>: device-popup()\n\ +Any<Btn3Up>: device-popdown() XF86Cfg.translations: #override \ <Message>WM_PROTOCOLS: quit() @@ -427,6 +448,9 @@ <Message>WM_PROTOCOLS: accessx-close() .xf86cfg.test.translations: #override \ <Message>WM_PROTOCOLS: testmode-cancel() +.xf86cfg.Expert.translations: #override \ +<Message>WM_PROTOCOLS: expert-close() + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! Options @@ -473,6 +497,14 @@ *options*viewport.right: chainRight *options*list.longest: 376 +*options*driverOpts.label: Options for driver\ +*options*driverOpts.justify: left +*options*driverOpts.width: 278 +*options*popdown.label: Popdown dialog +*options*driverOpts.tip: This menu shows:\n\ + o option name\n\ + o option type + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! monitor !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -760,10 +792,16 @@ *screenD*unselect.fromHoriz: viewL *screenD*select.fromVert: modeL *screenD*unselect.fromVert: select +*screenD*up.fromHoriz: viewL +*screenD*down.fromHoriz: viewL +*screenD*up.fromVert: unselect +*screenD*down.fromVert: up *screenD*viewR.fromHoriz: select *screenD*viewR.fromVert: modeL -*screenD*select.label: -> -*screenD*unselect.label: <- +*screenD*select.bitmap: right.xbm +*screenD*unselect.bitmap: left.xbm +*screenD*up.bitmap: up.xbm +*screenD*down.bitmap: down.xbm *screenD*viewL.width: 133 *screenD*viewR.width: 133 *screenD*viewL.height: 184 @@ -815,6 +853,8 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! accessx !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +*Accessx*Label.font: -*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1 +*Accessx.Form.Toggle.font: -*-fixed-medium-r-*-*-13-*-*-*-*-*-iso8859-1 *Accessx*Label.background: white *Accessx*Label.justify: left *Accessx*Label.internalHeight: 0 @@ -837,7 +877,7 @@ <Enter>: set-values(1, displayList, "foreground white;points 0,0,-1,0;fill-poly 0,1,10,6,0,-2;foreground rgb:7/7/f;fill-poly 0,2,0,-3,8,6")\n\ <Leave>: set-values(1, displayList, "foreground white;points 0,0,-1,0;foreground rgb:f/7/7;fill-poly 0,2,0,-3,8,6") *Accessx.Form.borderWidth: 1 -*Accessx.Form.borderColor: rgb:f/7/7 +*Accessx.Form.borderColor: rgb:f/a/a *Accessx.Form.vertDistance: 0 *Accessx.Form.defaultDistance: 2 *Accessx.borderWidth: 0 @@ -894,7 +934,7 @@ *Accessx*Scrollbar.height: 8 *Accessx*Scrollbar.minimumThumb: 5 *Accessx*Scrollbar.borderWidth: 1 -*Accessx*Scrollbar.borderColor: gray70 +*Accessx*Scrollbar.borderColor: white *Accessx*Scrollbar.foreground: rgb:f/7/7 *Accessx*Scrollbar.background: gray95 *Accessx*Scrollbar.displayList:\ @@ -938,6 +978,9 @@ *Accessx.mouseForm.timeScroller.horizDistance: 37 *Accessx.mouseForm.delayLabel.fromVert: timeScroller *Accessx.mouseForm.delayLabel.label: Motion delay (sec) +*Accessx.mouseForm.delayLabel.tip:\ +Time between the initial key press\n\ +and the first repeated motion event *Accessx.mouseForm.delayLabel.vertDistance: 7 *Accessx.mouseForm.delayNumber.label: ??? *Accessx.mouseForm.delayNumber.fromVert: timeScroller @@ -981,6 +1024,7 @@ *Accessx.slowForm.Toggle.internalWidth: 4 *Accessx.slowForm.Toggle.internalHeight: 1 *Accessx.slowForm.beep.label: Beep when key is +*Accessx.slowForm.beep.vertDistance: 3 *Accessx.slowForm.pressed.fromHoriz: beep *Accessx.slowForm.pressed.label: pressed *Accessx.slowForm.accepted.fromHoriz: pressed @@ -1210,6 +1254,9 @@ draw-string 12,21, "Button";\ draw-string 9,30, "Release" +*panner.width: 100 +*panner.height: 100 + *help*text.properties:\ default?family=Times&weight=Medium&slant=R&pixelsize=12®istry=ISO8859&encoding=1,\ b?weight=Bold,\ @@ -1289,3 +1336,434 @@ <p>\ <font color=red>Note</font>: currently, if you press the \ <tt><b>Apply changes</b></tt> button there is no way to undo your changes.</font> + + +*Expert.geometry: 800x600 +*Expert*vpane.min: 64 +*Expert*vpane.max: 64 +*Expert*vpane.showGrip: False +*Expert*vpane.close.showGrip: False +*Expert*vpane.close.min: 26 +*Expert*vpane.close.max: 26 +*panner.internalSpace: 1 +*panner.shadowThickness: 0 +*panner.shadowColor: gray60 +*panner.backgroundStipple: black +*panner.borderColor: gray40 + +*expert*tree.hSpace: 12 +*expert*tree*Box.hSpace: 4 +*expert*tree*vSpace: 4 +*expert*tree*LogFile.Text.width: 192 +*expert*tree*RgbPath.Text.width: 192 +*expert*tree*ModulePath.Text.width: 192 + +*expert*tree*Form.defaultDistance: 4 + +*expert*tree.backgroundPixmap: xlogo64?foreground=gray90&background=gray92 +*expert*tree.foreground: gray45 + +*expert*tree*Label.backgroundPixmap: ParentRelative + +*expert*tree*Box.backgroundPixmap: gradient:vertical?dimension=3&start=gray85&end=gray95 +*expert*tree*Box.borderWidth: 0 +*expert*tree*Box.background: gray85 +*expert*Box.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 + +*expert*tree*Form.backgroundPixmap: gradient:vertical?dimension=3&start=gray85&end=gray95 +*expert*tree*Form.borderWidth: 0 +*expert*tree*Form.background: gray85 +*expert*Form.displayList:\ +foreground gray40;\ +lines 1,-1,-1,-1,-1,1;\ +foreground white;\ +lines -1,0,0,0,0,-1 + +*expert*tree*Text.width: 160 + +*expert*tree*fontpath.Text.width: 228 +*expert*tree*fontpath.value.fromVert: remove +*expert*tree*fontpath.valueNew.fromVert: new + +*expert*tree*modulepath.Text.width: 228 +*expert*tree*modulepath.value.fromVert: remove +*expert*tree*modulepath.valueNew.fromVert: new + +*expert*tree*module.options.fromHoriz: remove +*expert*tree*module.label.fromVert: remove +*expert*tree*module.value.fromHoriz: new +*expert*tree*module.value.width: 78 + +*expert*tree*video*Label.justify: left +*expert*tree*video.options.fromHoriz: remove +*expert*tree*video.adaptor.fromHoriz: options +*expert*tree*video.vendorL.width: 78 +*expert*tree*video.vendorL.label: VendorName +*expert*tree*video.vendorL.fromVert: remove +*expert*tree*video.vendor.fromVert: remove +*expert*tree*video.vendor.fromHoriz: vendorL +*expert*tree*video.boardL.width: 78 +*expert*tree*video.boardL.label: BoardName +*expert*tree*video.boardL.fromVert: vendor +*expert*tree*video.board.fromVert: vendor +*expert*tree*video.board.fromHoriz: boardL +*expert*tree*video.busidL.width: 78 +*expert*tree*video.busidL.label: BusID +*expert*tree*video.busidL.fromVert: board +*expert*tree*video.busid.fromVert: board +*expert*tree*video.busid.fromHoriz: busidL +*expert*tree*video.driverL.width: 78 +*expert*tree*video.driverL.label: Driver +*expert*tree*video.driverL.fromVert: busid +*expert*tree*video.driver.fromVert: busid +*expert*tree*video.driver.fromHoriz: driverL +*expert*tree*video.value.fromHoriz: new +*expert*tree*video.value.width: 78 +*expert*tree*VideoPort.fromVert: driver +*expert*tree*VideoPort.horizDistance: 120 +*expert*tree*video.value.width: 149 + +*expert*tree*port.value.fromHoriz: new +*expert*tree*port.options.fromHoriz: remove +*expert*tree*port.label.fromVert: remove +*expert*tree*port.value.width: 78 + +*expert*tree*modes.mode.fromHoriz: remove +*expert*tree*modes.value.fromHoriz: new +*expert*tree*modes.value.width: 78 + +*expert*tree*modeline.label.fromHoriz: remove +*expert*tree*modeline.modeline.fromVert: remove +*expert*tree*modeline.modeline.width: 480 +*expert*tree*modeline.value.fromHoriz: new +*expert*tree*modeline.value.width: 120 +*expert*tree*modeline.modelineNew.fromVert: value +*expert*tree*modeline.modelineNew.width: 480 + +*expert*tree*monitor.options.fromHoriz: remove +*expert*tree*monitor.label.fromHoriz: options + +*expert*tree*monitor.Label.justify: left +*expert*tree*monitor.Text.width: 120 +*expert*tree*monitor.vendorL.width: 100 +*expert*tree*monitor.vendorL.label: VendorName +*expert*tree*monitor.vendorL.fromVert: remove +*expert*tree*monitor.vendor.fromVert: remove +*expert*tree*monitor.vendor.fromHoriz: vendorL +*expert*tree*monitor.modelnameL.width: 100 +*expert*tree*monitor.modelnameL.label: ModelName +*expert*tree*monitor.modelnameL.fromVert: vendor +*expert*tree*monitor.modelname.fromVert: vendor +*expert*tree*monitor.modelname.fromHoriz: modelnameL +*expert*tree*monitor.widthL.width: 100 +*expert*tree*monitor.widthL.label: Width (mm) +*expert*tree*monitor.widthL.fromVert: modelname +*expert*tree*monitor.width.fromVert: modelname +*expert*tree*monitor.width.fromHoriz: widthL +*expert*tree*monitor.heightL.width: 100 +*expert*tree*monitor.heightL.label: Height (mm) +*expert*tree*monitor.heightL.fromVert: width +*expert*tree*monitor.height.fromVert: width +*expert*tree*monitor.height.fromHoriz: heightL +*expert*tree*monitor.hsyncL.width: 100 +*expert*tree*monitor.hsyncL.label: Hsync +*expert*tree*monitor.hsyncL.fromVert: heightL +*expert*tree*monitor.hsync.fromVert: height +*expert*tree*monitor.hsync.fromHoriz: hsyncL +*expert*tree*monitor.vrefreshL.width: 100 +*expert*tree*monitor.vrefreshL.label: Vrefresh +*expert*tree*monitor.vrefreshL.fromVert: hsync +*expert*tree*monitor.vrefresh.fromVert: hsync +*expert*tree*monitor.vrefresh.fromHoriz: vrefreshL +*expert*tree*monitor.gammaRedL.width: 100 +*expert*tree*monitor.gammaRedL.label: Gamma (red) +*expert*tree*monitor.gammaRedL.fromVert: vrefresh +*expert*tree*monitor.gammaRed.fromVert: vrefresh +*expert*tree*monitor.gammaRed.fromHoriz: gammaRedL +*expert*tree*monitor.gammaGreenL.width: 100 +*expert*tree*monitor.gammaGreenL.label: Gamma (green) +*expert*tree*monitor.gammaGreenL.fromVert: gammaRed +*expert*tree*monitor.gammaGreen.fromVert: gammaRed +*expert*tree*monitor.gammaGreen.fromHoriz: gammaGreenL +*expert*tree*monitor.gammaBlueL.width: 100 +*expert*tree*monitor.gammaBlueL.label: Gamma (blue) +*expert*tree*monitor.gammaBlueL.fromVert: gammaGreen +*expert*tree*monitor.gammaBlue.fromVert: gammaGreen +*expert*tree*monitor.gammaBlue.fromHoriz: gammaBlueL +*expert*tree*monitor.value.width: 191 +*expert*tree*monitor.value.fromHoriz: new + +*expert*tree*device.Label.justify: left +*expert*tree*device.options.fromHoriz: remove +*expert*tree*device.label.fromHoriz: options +*expert*tree*device.vendorL.label: VendorName +*expert*tree*device.vendorL.width: 100 +*expert*tree*device.vendorL.fromVert: remove +*expert*tree*device.vendor.fromVert: remove +*expert*tree*device.vendor.fromHoriz: vendorL +*expert*tree*device.boardL.label: BoardName +*expert*tree*device.boardL.width: 100 +*expert*tree*device.boardL.fromVert: vendor +*expert*tree*device.board.fromVert: vendor +*expert*tree*device.board.fromHoriz: boardL +*expert*tree*device.chipsetL.label: Chipset +*expert*tree*device.chipsetL.width: 100 +*expert*tree*device.chipsetL.fromVert: board +*expert*tree*device.chipset.fromVert: board +*expert*tree*device.chipset.fromHoriz: chipsetL +*expert*tree*device.busidL.label: BusID +*expert*tree*device.busidL.width: 100 +*expert*tree*device.busidL.fromVert: chipset +*expert*tree*device.busid.fromVert: chipset +*expert*tree*device.busid.fromHoriz: chipsetL +*expert*tree*device.cardL.label: Card +*expert*tree*device.cardL.width: 100 +*expert*tree*device.cardL.fromVert: busid +*expert*tree*device.card.fromVert: busid +*expert*tree*device.card.fromHoriz: cardL +*expert*tree*device.driverL.label: Driver +*expert*tree*device.driverL.width: 100 +*expert*tree*device.driverL.fromVert: card +*expert*tree*device.driver.fromVert: card +*expert*tree*device.driver.fromHoriz: driverL +*expert*tree*device.ramdacL.label: Ramdac +*expert*tree*device.ramdacL.width: 100 +*expert*tree*device.ramdacL.fromVert: driverL +*expert*tree*device.ramdac.fromVert: driver +*expert*tree*device.ramdac.fromHoriz: ramdacL +*expert*tree*device.dacSpeedL.label: DacSpeed +*expert*tree*device.dacSpeedL.width: 100 +*expert*tree*device.dacSpeedL.fromVert: ramdac +*expert*tree*device.dacSpeed.fromVert: ramdac +*expert*tree*device.dacSpeed.fromHoriz: dacSpeedL +*expert*tree*device.videoRamL.label: VideoRam +*expert*tree*device.videoRamL.width: 100 +*expert*tree*device.videoRamL.fromVert: dacSpeed +*expert*tree*device.videoRam.fromVert: dacSpeed +*expert*tree*device.videoRam.fromHoriz: videoRamL +*expert*tree*device.textClockFreqL.label: TextClockFreq +*expert*tree*device.textClockFreqL.width: 100 +*expert*tree*device.textClockFreqL.fromVert: videoRam +*expert*tree*device.textClockFreq.fromVert: videoRam +*expert*tree*device.textClockFreq.fromHoriz: textClockFreqL +*expert*tree*device.biosBaseL.label: BiosBase +*expert*tree*device.biosBaseL.width: 100 +*expert*tree*device.biosBaseL.fromVert: textClockFreq +*expert*tree*device.biosBase.fromVert: textClockFreq +*expert*tree*device.biosBase.fromHoriz: biosBaseL +*expert*tree*device.memBaseL.label: MemBase +*expert*tree*device.memBaseL.width: 100 +*expert*tree*device.memBaseL.fromVert: biosBase +*expert*tree*device.memBase.fromVert: biosBase +*expert*tree*device.memBase.fromHoriz: memBaseL +*expert*tree*device.ioBaseL.label: IOBase +*expert*tree*device.ioBaseL.width: 100 +*expert*tree*device.ioBaseL.fromVert: memBase +*expert*tree*device.ioBase.fromVert: memBase +*expert*tree*device.ioBase.fromHoriz: ioBaseL +*expert*tree*device.clockChipL.label: ClockChip +*expert*tree*device.clockChipL.width: 100 +*expert*tree*device.clockChipL.fromVert: ioBase +*expert*tree*device.clockChip.fromVert: ioBase +*expert*tree*device.clockChip.fromHoriz: clockChipL +*expert*tree*device.devClockL.label: Clocks +*expert*tree*device.devClockL.width: 100 +*expert*tree*device.devClockL.fromVert: clockChip +*expert*tree*device.devClock.fromVert: clockChip +*expert*tree*device.devClock.fromHoriz: devClockL +*expert*tree*device.chipIdL.label: ChipId +*expert*tree*device.chipIdL.width: 100 +*expert*tree*device.chipIdL.fromVert: devClock +*expert*tree*device.chipId.fromVert: devClock +*expert*tree*device.chipId.fromHoriz: chipIdL +*expert*tree*device.chipRevL.label: ChipRev +*expert*tree*device.chipRevL.width: 100 +*expert*tree*device.chipRevL.fromVert: chipId +*expert*tree*device.chipRev.fromVert: chipId +*expert*tree*device.chipRev.fromHoriz: chipRevL +*expert*tree*device.irqL.label: IRQ +*expert*tree*device.irqL.width: 100 +*expert*tree*device.irqL.fromVert: chipRev +*expert*tree*device.irq.fromVert: chipRev +*expert*tree*device.irq.fromHoriz: irqL +*expert*tree*device.screenL.label: Screen +*expert*tree*device.screenL.width: 100 +*expert*tree*device.screenL.fromVert: irq +*expert*tree*device.screen.fromVert: irq +*expert*tree*device.screen.fromHoriz: screenL +*expert*tree*device.value.fromHoriz: new + +*expert*tree*screen.Label.justify: left +*expert*tree*screen.options.fromHoriz: remove +*expert*tree*screen.label.fromHoriz: options +*expert*tree*screen.defaultDepthL.label: DefaultDepth +*expert*tree*screen.defaultDepthL.width: 92 +*expert*tree*screen.defaultDepthL.fromVert: remove +*expert*tree*screen.defaultDepth.fromVert: remove +*expert*tree*screen.defaultDepth.fromHoriz: defaultDepthL +*expert*tree*screen.defaultBppL.label: DefaultBpp +*expert*tree*screen.defaultBppL.width: 92 +*expert*tree*screen.defaultBppL.fromVert: defaultDepth +*expert*tree*screen.defaultBpp.fromVert: defaultDepth +*expert*tree*screen.defaultBpp.fromHoriz: defaultBppL +*expert*tree*screen.defaultFbBppL.label: DefaultFbBpp +*expert*tree*screen.defaultFbBppL.width: 92 +*expert*tree*screen.defaultFbBppL.fromVert: defaultBpp +*expert*tree*screen.defaultFbBpp.fromVert: defaultBpp +*expert*tree*screen.defaultFbBpp.fromHoriz: defaultFbBppL +*expert*tree*screen.monitorL.label: Monitor +*expert*tree*screen.monitorL.width: 92 +*expert*tree*screen.monitorL.fromVert: defaultFbBpp +*expert*tree*screen.monitor.fromVert: defaultFbBpp +*expert*tree*screen.monitor.fromHoriz: monitorL +*expert*tree*screen.deviceL.label: Device +*expert*tree*screen.deviceL.width: 92 +*expert*tree*screen.deviceL.fromVert: monitor +*expert*tree*screen.device.fromVert: monitor +*expert*tree*screen.device.fromHoriz: deviceL +*expert*tree*screen.value.fromHoriz: new + +*expert*tree*adaptor.label.fromHoriz: remove + +*expert*tree*display.Label.width: 64 +*expert*tree*display.Label.justify: left +*expert*tree*display.options.fromHoriz: remove +*expert*tree*display.viewportL.label: Viewport +*expert*tree*display.viewportL.fromVert: remove +*expert*tree*display.viewport.fromVert: remove +*expert*tree*display.viewport.fromHoriz: viewportL +*expert*tree*display.virtualL.label: Virtual +*expert*tree*display.virtualL.fromVert: viewport +*expert*tree*display.virtual.fromVert: viewport +*expert*tree*display.virtual.fromHoriz: virtualL +*expert*tree*display.depthL.label: Depth +*expert*tree*display.depthL.fromVert: virtual +*expert*tree*display.depth.fromVert: virtual +*expert*tree*display.depth.fromHoriz: depthL +*expert*tree*display.bppL.label: FbBPP +*expert*tree*display.bppL.fromVert: depth +*expert*tree*display.bpp.fromVert: depth +*expert*tree*display.bpp.fromHoriz: bppL +*expert*tree*display.visualL.label: Visual +*expert*tree*display.visualL.fromVert: bpp +*expert*tree*display.visual.fromVert: bpp +*expert*tree*display.visual.fromHoriz: visualL +*expert*tree*display.weightL.label: Weight +*expert*tree*display.weightL.fromVert: visual +*expert*tree*display.weight.fromVert: visual +*expert*tree*display.weight.fromHoriz: weightL +*expert*tree*display.blackL.label: Black +*expert*tree*display.blackL.fromVert: weight +*expert*tree*display.black.fromVert: weight +*expert*tree*display.black.fromHoriz: blackL +*expert*tree*display.whiteL.label: White +*expert*tree*display.whiteL.fromVert: black +*expert*tree*display.white.fromVert: black +*expert*tree*display.white.fromHoriz: whiteL + +*expert*tree*mode.label.fromHoriz: remove +*expert*tree*mode.value.fromHoriz: new +*expert*tree*mode.value.width: 100 + +*expert*tree*input.options.fromHoriz: remove +*expert*tree*input.label.fromHoriz: options +*expert*tree*input.driverL.label: Driver +*expert*tree*input.driverL.fromVert: remove +*expert*tree*input.driver.fromVert: remove +*expert*tree*input.driver.fromHoriz: driverL +*expert*tree*input.value.fromHoriz: new + +*expert*tree*layout.options.fromHoriz: remove +*expert*tree*layout.label.fromHoriz: options +*expert*tree*layout.value.fromHoriz: new + +*expert*tree*adjacency.Text.width: 46 +*expert*tree*adjacency.MenuButton.width: 122 +*expert*tree*adjacency.label.fromHoriz: remove +*expert*tree*adjacency.scrnumL.label: Screen number +*expert*tree*adjacency.scrnumL.horizDistance: 50 +*expert*tree*adjacency.scrnum.width: 32 +*expert*tree*adjacency.scrnumL.fromVert: remove +*expert*tree*adjacency.scrnum.fromVert: remove +*expert*tree*adjacency.scrnum.fromHoriz: scrnumL +*expert*tree*adjacency.above.label: Above +*expert*tree*adjacency.above.fromVert: scrnumL +*expert*tree*adjacency.above.vertDistance: 20 +*expert*tree*adjacency.above.horizDistance: 96 +*expert*tree*adjacency.below.label: Below +*expert*tree*adjacency.below.horizDistance: 96 +*expert*tree*adjacency.leftOf.label: LeftOf +*expert*tree*adjacency.leftOf.fromVert: above +*expert*tree*adjacency.screen.fromVert: above +*expert*tree*adjacency.screen.fromHoriz: leftOf +*expert*tree*adjacency.rightOf.label: RightOf +*expert*tree*adjacency.rightOf.fromVert: above +*expert*tree*adjacency.rightOf.fromHoriz: screen +*expert*tree*adjacency.below.fromVert: screen +*expert*tree*adjacency.relative.label: Relative +*expert*tree*adjacency.relative.horizDistance: 53 +*expert*tree*adjacency.relative.fromVert: below +*expert*tree*adjacency.absolute.fromVert: below +*expert*tree*adjacency*absolute.label: Absolute +*expert*tree*adjacency*absolute.fromHoriz: relative +*expert*tree*adjacency*adjxL.label: X +*expert*tree*adjacency*adjxL.horizDistance: 42 +*expert*tree*adjacency*adjxL.fromVert: absolute +*expert*tree*adjacency*adjx.fromVert: absolute +*expert*tree*adjacency*adjx.fromHoriz: adjxL +*expert*tree*adjacency*adjyL.label: Y +*expert*tree*adjacency*adjyL.horizDistance: 12 +*expert*tree*adjacency*adjyL.fromVert: absolute +*expert*tree*adjacency*adjyL.fromHoriz: adjx +*expert*tree*adjacency*adjy.fromVert: absolute +*expert*tree*adjacency*adjy.fromHoriz: adjyL + +*expert*tree*inputref.options.fromHoriz: remove +*expert*tree*inputref.label.fromHoriz: options + +*expert*tree*vendor.Text.width: 100 +*expert*tree*vendor.options.fromHoriz: remove +*expert*tree*vendor.label.fromHoriz: options +*expert*tree*vendor.value.fromHoriz: new + +*expert*tree*vendorSub.Text.width: 140 +*expert*tree*vendorSub.options.fromHoriz: remove +*expert*tree*vendorSub.label.fromHoriz: options +*expert*tree*vendorSub.nameL.label: Name +*expert*tree*vendorSub.nameL.fromVert: remove +*expert*tree*vendorSub.name.fromVert: remove +*expert*tree*vendorSub.name.fromHoriz: nameL +*expert*tree*vendorSub.value.fromHoriz: new + +*expert*tree*dri.Text.width: 100 +*expert*tree*dri.Label.width: 78 +*expert*tree*dri.Label.justify: left +*expert*tree*dri.nameL.label: Group name +*expert*tree*dri.name.fromHoriz: nameL +*expert*tree*dri.groupL.label: Group +*expert*tree*dri.groupL.fromVert: name +*expert*tree*dri.group.fromVert: name +*expert*tree*dri.group.fromHoriz: groupL +*expert*tree*dri.modeL.label: Mode +*expert*tree*dri.modeL.fromVert: group +*expert*tree*dri.mode.fromVert: group +*expert*tree*dri.mode.fromHoriz: modeL + +*expert*tree*buffers.Label.width: 50 +*expert*tree*buffers.Text.width: 100 +*expert*tree*buffers.countL.label: Count +*expert*tree*buffers.countL.fromVert: remove +*expert*tree*buffers.count.fromVert: remove +*expert*tree*buffers.count.fromHoriz: countL +*expert*tree*buffers.sizeL.label: Size +*expert*tree*buffers.sizeL.fromVert: count +*expert*tree*buffers.size.fromVert: count +*expert*tree*buffers.size.fromHoriz: sizeL +*expert*tree*buffers.flagsL.label: Flags +*expert*tree*buffers.flagsL.fromVert: size +*expert*tree*buffers.flags.fromVert: size +*expert*tree*buffers.flags.fromHoriz: flagsL Index: xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c:1.4 xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c:1.7 --- xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c:1.4 Tue Jun 20 01:08:50 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c Fri Oct 20 10:59:05 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c,v 1.4 2000/06/20 05:08:50 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c,v 1.7 2000/10/20 14:59:05 alanh Exp $ */ #include "config.h" @@ -82,7 +82,12 @@ static void ScaleJumpCallback(Widget, XtPointer, XtPointer); static void ApplyCallback(Widget, XtPointer, XtPointer); +static void AccessXInitialize(void); +void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*); +void AccessXConfigureStart(void); +void AccessXConfigureEnd(void); + /* * Implementation */ @@ -90,10 +95,12 @@ startaccessx(void) { InitializeKeyboard(); + XkbGetControls(DPY, XkbAllControlsMask, xkb_info->xkb); if (xkb_info->xkb->ctrls == NULL) xkb_info->xkb->ctrls = (XkbControlsPtr) XtCalloc(1, sizeof(XkbControlsRec)); + xkb_info->xkb->ctrls->enabled_ctrls |= XkbMouseKeysMask | XkbMouseKeysAccelMask; xkb_info->xkb->ctrls->mk_delay = 40; @@ -153,7 +160,7 @@ Arg args[1]; Boolean state; Widget stickyForm, mouseForm, repeatForm, slowForm, bounceForm; - float val; + float val, tmp; if (!first) return; @@ -365,7 +372,7 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(timeoutToggle, args, 1); - ScaleEnableCallback(enable, (XtPointer)timeout, (XtPointer)(int)state); + ScaleEnableCallback(enable, (XtPointer)timeout, (XtPointer)(long)state); if (xkb_info->xkb->ctrls->ax_timeout > 60) val = (float)(xkb_info->xkb->ctrls->ax_timeout - 60) / (float)(MAX_TIMEOUT * 60); @@ -375,25 +382,26 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(sticky, args, 1); - EnableCallback(sticky, (XtPointer)stickyForm, (XtPointer)(int)state); + EnableCallback(sticky, (XtPointer)stickyForm, (XtPointer)(long)state); XtSetArg(args[0], XtNstate, &state); XtGetValues(mouse, args, 1); - EnableCallback(mouse, (XtPointer)mouseForm, (XtPointer)(int)state); - if (xkb_info->xkb->ctrls->mk_interval > 10) - val = (float)(xkb_info->xkb->ctrls->mk_interval - 10) / - (float)MAX_MOUSE_SPEED; - else - val = 10.0 / (float)MAX_MOUSE_SPEED; - ScaleJumpCallback(mouseSpeed->scroller, (XtPointer)mouseSpeed, - (XtPointer)&val); + EnableCallback(mouse, (XtPointer)mouseForm, (XtPointer)(long)state); if (xkb_info->xkb->ctrls->mk_time_to_max > 10) - val = (float)(xkb_info->xkb->ctrls->mk_time_to_max - 10) / + val = (float)((xkb_info->xkb->ctrls->mk_time_to_max * (40. / 10.))) / (float)(MAX_MOUSE_TIME * 100); else val = 10.0 / (float)(MAX_MOUSE_TIME * 100); ScaleJumpCallback(mouseTime->scroller, (XtPointer)mouseTime, (XtPointer)&val); + tmp = mouseTime->value; + if (xkb_info->xkb->ctrls->mk_max_speed != 0) + val = (float)(xkb_info->xkb->ctrls->mk_max_speed / tmp - 10) / + (float)MAX_MOUSE_SPEED; + else + val = 10.0 / (float)MAX_MOUSE_SPEED; + ScaleJumpCallback(mouseSpeed->scroller, (XtPointer)mouseSpeed, + (XtPointer)&val); if (xkb_info->xkb->ctrls->mk_delay > 10) val = (float)(xkb_info->xkb->ctrls->mk_delay - 10) / (float)(MAX_MOUSE_DELAY * 100); @@ -404,7 +412,7 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(repeat, args, 1); - EnableCallback(repeat, (XtPointer)repeatForm, (XtPointer)(int)state); + EnableCallback(repeat, (XtPointer)repeatForm, (XtPointer)(long)state); if (xkb_info->xkb->ctrls->repeat_interval > 5) val = (float)(xkb_info->xkb->ctrls->repeat_interval - 5) / (float)(MAX_REPEAT_RATE * 1000); @@ -422,7 +430,7 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(slowToggle, args, 1); - EnableCallback(slowToggle, (XtPointer)slowForm, (XtPointer)(int)state); + EnableCallback(slowToggle, (XtPointer)slowForm, (XtPointer)(long)state); if (xkb_info->xkb->ctrls->slow_keys_delay > 10) val = (float)(xkb_info->xkb->ctrls->repeat_delay - 10) / (float)(MAX_SLOW_TIME * 1000); @@ -432,7 +440,7 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(bounceToggle, args, 1); - EnableCallback(bounceToggle, (XtPointer)bounceForm, (XtPointer)(int)state); + EnableCallback(bounceToggle, (XtPointer)bounceForm, (XtPointer)(long)state); if (xkb_info->xkb->ctrls->debounce_delay > 10) val = (float)(xkb_info->xkb->ctrls->debounce_delay - 10) / (float)(MAX_BOUNCE_TIME * 1000); @@ -442,7 +450,7 @@ XtSetArg(args[0], XtNstate, &state); XtGetValues(enable, args, 1); - EnableCallback(enable, (XtPointer)form, (XtPointer)(int)state); + EnableCallback(enable, (XtPointer)form, (XtPointer)(long)state); } void @@ -463,7 +471,7 @@ static void EnableCallback(Widget w, XtPointer user_data, XtPointer call_data) { - XtSetSensitive((XtPointer)user_data, (int)call_data); + XtSetSensitive(user_data, (long)call_data); } /*ARGSUSED*/ @@ -472,9 +480,9 @@ { Scale *scale = (Scale*)user_data; - XtSetSensitive(scale->label, (int)call_data); - XtSetSensitive(scale->number, (int)call_data); - XtSetSensitive(scale->scroller, (int)call_data); + XtSetSensitive(scale->label, (long)call_data); + XtSetSensitive(scale->number, (long)call_data); + XtSetSensitive(scale->scroller, (long)call_data); } static void @@ -584,13 +592,16 @@ xkb_info->xkb->ctrls->enabled_ctrls |= XkbMouseKeysMask | XkbMouseKeysAccelMask; xkb_info->config.mk_delay = - xkb_info->xkb->ctrls->mk_delay = mouseDelay->value * 100; + xkb_info->xkb->ctrls->mk_delay = mouseDelay->value * 100; xkb_info->config.mk_interval = - xkb_info->xkb->ctrls->mk_interval = mouseSpeed->value; + xkb_info->xkb->ctrls->mk_interval = 40; xkb_info->config.mk_time_to_max = - xkb_info->xkb->ctrls->mk_time_to_max = mouseTime->value * 100; -/* xkb_info->xkb->ctrls->mk_max_speed = 500; - xkb_info->xkb->ctrls->mk_curve = 0;*/ + xkb_info->xkb->ctrls->mk_time_to_max = + (mouseTime->value * 1000) / xkb_info->xkb->ctrls->mk_interval; + xkb_info->config.mk_max_speed = + xkb_info->xkb->ctrls->mk_max_speed = + mouseSpeed->value * mouseTime->value; + xkb_info->config.mk_curve = xkb_info->xkb->ctrls->mk_curve = 0; } else { xkb_info->config.initial_ctrls &= ~(XkbMouseKeysMask | Index: xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c:1.2 Tue Jun 13 19:15:51 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c Fri Dec 1 18:27:54 2000 @@ -26,34 +26,46 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c,v 1.2 2000/06/13 23:15:51 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c,v 1.4 2000/12/01 23:27:54 paulo Exp $ */ #include "xf86config.h" #include "mouse-cfg.h" #include "cards.h" +#include "card-cfg.h" #include <X11/Xaw/AsciiText.h> #include <X11/Xaw/Form.h> #include <X11/Xaw/Label.h> #include <X11/Xaw/List.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/SimpleMenu.h> #include <X11/Xaw/Viewport.h> +#ifdef USE_MODULES +#include "loader.h" +#endif /* * Prototypes */ static Bool CardConfigCheck(void); static void CardModelCallback(Widget, XtPointer, XtPointer); +#ifdef USE_MODULES +static void DriverCallback(Widget, XtPointer, XtPointer); +#endif /* * Initialization */ static CardsEntry *card_entry; static XF86ConfDevicePtr current_device; -static Widget filter, list, busid; +static Widget filter, list, driver, busid; static char **cards = NULL; static int ncards; +#ifdef USE_MODULES +static char *driver_str; +#endif - /* * Implementation */ @@ -65,7 +77,7 @@ /* XF86OptionPtr option;*/ char card_name[32]; Arg args[1]; - char *bus; + char *bus, *drv_nam; xf86info.cur_list = CARD; XtSetSensitive(back, xf86info.lists[CARD].cur_function > 0); @@ -98,6 +110,12 @@ XtSetValues(ident_widget, args, 1); XtSetArg(args[0], XtNstring, card->dev_busid); XtSetValues(busid, args, 1); +#ifdef USE_MODULES + XtSetArg(args[0], XtNlabel, driver_str = XtNewString(card->dev_driver)); +#else + XtSetArg(args[0], XtNstring, card->dev_driver); +#endif + XtSetValues(driver, args, 1); } else { XF86ConfDevicePtr device = XF86Config->conf_device_lst; @@ -110,13 +128,19 @@ do { ++ndevices; XmuSnprintf(card_name, sizeof(card_name), "Card%d", ndevices); - } while (xf86FindDevice(card_name, + } while (xf86findDevice(card_name, XF86Config->conf_device_lst)); XtSetArg(args[0], XtNstring, card_name); XtSetValues(ident_widget, args, 1); XtSetArg(args[0], XtNstring, ""); XtSetValues(busid, args, 1); +#ifdef USE_MODULES + XtSetArg(args[0], XtNlabel, driver_str = XtNewString("vga")); +#else + XtSetArg(args[0], XtNstring, "vga"); +#endif + XtSetValues(driver, args, 1); } if (ConfigLoop(CardConfigCheck) == True) { @@ -154,14 +178,31 @@ } } if (strcasecmp(card->dev_identifier, ident_string)) - xf86RenameDevice(XF86Config, card, ident_string); + xf86renameDevice(XF86Config, card, ident_string); XtSetArg(args[0], XtNstring, &bus); XtGetValues(busid, args, 1); XtFree(card->dev_busid); card->dev_busid = XtNewString(bus); +#ifdef USE_MODULES + drv_nam = driver_str; +#else + XtSetArg(args[0], XtNstring, &drv_nam); + XtGetValues(driver, args, 1); +#endif + + XtFree(card->dev_driver); + card->dev_driver = XtNewString(drv_nam); + +#ifdef USE_MODULES + XtFree(driver_str); +#endif + return ((XtPointer)card); } +#ifdef USE_MODULES + XtFree(driver_str); +#endif return (NULL); } @@ -170,9 +211,19 @@ CardConfigCheck(void) { XF86ConfDevicePtr device = XF86Config->conf_device_lst; + char *drv_nam; +#ifdef USE_MODULES + drv_nam = driver_str; +#else + Arg args[1]; + + XtSetArg(args[0], XtNstring, &drv_nam); + XtGetValues(driver, args, 1); +#endif if (ident_string == NULL || strlen(ident_string) == 0 || - (current_device == NULL && card_entry == NULL)) + (current_device == NULL && card_entry == NULL) || + drv_nam == NULL || *drv_nam == '\0') return (False); while (device != NULL) { @@ -205,9 +256,15 @@ if (card_entry->chipset != NULL) len += XmuSnprintf(tip + len, sizeof(tip) - len, "Chipset: %s\n", card_entry->chipset); - if (card_entry->driver != NULL) + if (card_entry->driver != NULL) { +#ifdef USE_MODULES + XtFree(driver_str); + driver_str = XtNewString(card_entry->driver); + XtVaSetValues(driver, XtNlabel, driver_str, NULL, 0); +#endif len += XmuSnprintf(tip + len, sizeof(tip) - len, "Driver: %s\n", card_entry->driver); + } if (card_entry->ramdac != NULL) len += XmuSnprintf(tip + len, sizeof(tip), "Ramdac: %s\n", card_entry->ramdac); @@ -230,6 +287,11 @@ else first = 0; +#ifndef USE_MODULES + XtSetArg(args[0], XtNstring, card_entry->driver ? card_entry->driver : "vga"); + XtSetValues(driver, args, 1); +#endif + str = XtNewString(tip); XtSetArg(args[0], XtNtip, str); XtSetValues(filter, args, 1); @@ -273,6 +335,20 @@ XtManageChild(list); } +#ifdef USE_MODULES +/*ARGSUSED*/ +static void +DriverCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + + XtFree(driver_str); + driver_str = XtNewString(XtName(w)); + XtSetArg(args[0], XtNlabel, driver_str); + XtSetValues(driver, args, 1); +} +#endif + void CardModel(XF86SetupInfo *info) { @@ -303,6 +379,31 @@ NULL, 0); XtAddCallback(list, XtNcallback, CardModelCallback, (XtPointer)info); + XtCreateManagedWidget("driverL", labelWidgetClass, model, NULL, 0); +#ifdef USE_MODULES + driver = XtVaCreateManagedWidget("driver", menuButtonWidgetClass, + model, + XtNmenuName, "driverM", + NULL, 0); + { + Widget menu, sme; + xf86cfgDriverOptions *opts = video_driver_info; + + menu = XtCreatePopupShell("driverM", simpleMenuWidgetClass, + driver, NULL, 0); + while (opts) { + sme = XtCreateManagedWidget(opts->name, smeBSBObjectClass, + menu, NULL, 0); + XtAddCallback(sme, XtNcallback, DriverCallback, NULL); + opts = opts->next; + } + } +#else + driver = XtVaCreateManagedWidget("driver", asciiTextWidgetClass, + model, + XtNeditType, XawtextEdit, + NULL, 0); +#endif XtCreateManagedWidget("busidL", labelWidgetClass, model, NULL, 0); busid = XtVaCreateManagedWidget("busid", asciiTextWidgetClass, model, Index: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/config.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/config.c:1.6 --- xc/programs/Xserver/hw/xfree86/xf86cfg/config.c:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/config.c Fri Dec 8 16:51:04 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.c,v 1.6 2000/12/08 21:51:04 paulo Exp $ */ #include "config.h" @@ -42,10 +42,6 @@ #include <X11/Xaw/Command.h> #include <X11/Shell.h> -#define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \ - "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \ - "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X" - /* * Prototypes */ @@ -118,11 +114,13 @@ first = 0; /* Read initial configuration */ - if ((filename = xf86OpenConfigFile(CONFPATH, XF86Config_path, NULL)) == NULL) { + if ((filename = xf86openConfigFile(getuid() == 0 ? CONFPATH : USER_CONFPATH, + XF86Config_path, NULL)) == NULL) { fprintf(stderr, "Cannot to open config file.\n"); exit(1); } - if ((XF86Config = xf86ReadConfigFile()) == NULL) { + XF86Config_path = (char *)filename; + if ((XF86Config = xf86readConfigFile()) == NULL) { fprintf(stderr, "Problem when parsing config file\n"); exit(1); } Index: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/config.h:1.4 xc/programs/Xserver/hw/xfree86/xf86cfg/config.h:1.9 --- xc/programs/Xserver/hw/xfree86/xf86cfg/config.h:1.4 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/config.h Fri Dec 8 16:51:05 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h,v 1.4 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/config.h,v 1.9 2000/12/08 21:51:05 paulo Exp $ */ #include <X11/IntrinsicP.h> @@ -94,6 +94,23 @@ #define UNUSED 0 #define USED 1 +#define CONFPATH "%A," "%R," \ + "/etc/X11/%R," "%P/etc/X11/%R," \ + "%E," "%F," \ + "/etc/X11/%F," "%P/etc/X11/%F," \ + "%D/%X," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#define USER_CONFPATH "/etc/X11/%S," "%P/etc/X11/%S," \ + "/etc/X11/%G," "%P/etc/X11/%G," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" + /* * Types */ @@ -112,7 +129,7 @@ XF86SetupFunctionList *lists; }; -typedef Bool (*ConfigCheckFunction)(); +typedef Bool (*ConfigCheckFunction)(void); typedef struct _xf86cfgDevice xf86cfgDevice; @@ -176,6 +193,10 @@ void endx(void); void startaccessx(void); void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*); +void ExpertConfigureStart(void); +void ExpertConfigureEnd(void); +void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*); +void ExpertCallback(Widget, XtPointer, XtPointer); /* * Initialization @@ -187,6 +208,10 @@ extern char *ident_string; extern XF86ConfigPtr XF86Config; extern char *XF86Config_path; +extern char *XF86Module_path; +extern char *XFree86_path; +extern char *XF86Font_path; +extern char *XF86RGB_path; extern char *XFree86Dir; extern xf86cfgComputer computer; extern Atom wm_delete_window; Index: xc/programs/Xserver/hw/xfree86/xf86cfg/expert.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/expert.c:1.5 --- /dev/null Mon Dec 18 14:32:28 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/expert.c Sat Dec 2 10:31:02 2000 @@ -0,0 +1,4707 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/expert.c,v 1.5 2000/12/02 15:31:02 tsi Exp $ + */ + +#include "config.h" +#include "xf86config.h" +#include "options.h" +#include "screen.h" +#include "monitor-cfg.h" +#include <X11/Shell.h> +#include <X11/Xaw/AsciiText.h> +#include <X11/Xaw/Box.h> +#include <X11/Xaw/Command.h> +#include <X11/Xaw/Form.h> +#include <X11/Xaw/Label.h> +#include <X11/Xaw/MenuButton.h> +#include <X11/Xaw/Paned.h> +#include <X11/Xaw/Panner.h> +#include <X11/Xaw/Porthole.h> +#include <X11/Xaw/SimpleMenu.h> +#include <X11/Xaw/SmeBSB.h> +#include <X11/Xaw/Toggle.h> +#include <X11/Xaw/Tree.h> +#include <ctype.h> + +/* + * Types + */ +typedef struct _TreeNode TreeNode; +typedef union _TreeData TreeData; +typedef void (*NodeDeleteFunc)(TreeNode*); +typedef void (*NodeUpdateFunc)(TreeNode*); + +union _TreeData { + struct { + Widget text; + } files; + struct { + Widget text; + XF86LoadPtr load; + } module; + struct { + Widget text; + XF86ConfModesPtr modes; + } modes; + struct { + Widget text, value; + XF86ConfModeLinePtr modeline; + } modeline; + struct { + Widget text, vendor, board, busid, driver; + XF86ConfVideoAdaptorPtr video; + } video; + struct { + Widget text; + XF86ConfVideoPortPtr port; + } port; + struct { + Widget text, vendor, model, width, height, hsync, vrefresh, + gammaRed, gammaGreen, gammaBlue; + XF86ConfMonitorPtr monitor; + } monitor; + struct { + Widget menu; + XF86ConfModesLinkPtr modeslink; + } modeslink; + struct { + Widget text, vendor, board, chipset, busid, card, driver, ramdac, + dacSpeed, videoRam, textClockFreq, biosBase, memBase, ioBase, + clockChip, devClock, chipId, chipRev, irq, screen; + XF86ConfDevicePtr device; + } device; + struct { + Widget text, defaultDepth, defaultBpp, defaultFbBpp, + monitor, device; + XF86ConfScreenPtr screen; + } screen; + struct { + Widget menu; + XF86ConfAdaptorLinkPtr adaptorlink; + } adaptorlink; + struct { + Widget viewport, c_virtual, depth, bpp, visual, weight, black, white; + XF86ConfDisplayPtr display; + } display; + struct { + Widget text; + XF86ModePtr mode; + } mode; + struct { + Widget text; + XF86ConfInputPtr input; + } input; + struct { + Widget text; + XF86ConfLayoutPtr layout; + } layout; + struct { + Widget menu, button, scrnum, adjx, adjy; + XF86ConfAdjacencyPtr adjacency; + } adjacency; + struct { + Widget menu; + XF86ConfInputrefPtr inputref; + } inputref; + struct { + Widget text; + XF86ConfVendorPtr vendor; + } vendor; + struct { + Widget text; + XF86ConfVendSubPtr vendsub; + } vendsub; + struct { + Widget name, group, mode; + XF86ConfDRIPtr dri; + } dri; + struct { + Widget count, size, flags; + XF86ConfBuffersPtr buffers; + } buffers; +}; + +struct _TreeNode { + Widget node, toggle, treeParent; + TreeNode *parent, *child, *next; + TreeData *data; + NodeDeleteFunc destroy; + NodeUpdateFunc update; +}; + +/* + * Prototypes + */ +static Bool ExpertInitialize(void); +static TreeNode *NewNode(TreeNode*, Widget, Widget, Widget, TreeData*); +static void DeleteNode(TreeNode*); +static void DestroyCallback(Widget, XtPointer, XtPointer); +static void PannerCallback(Widget, XtPointer, XtPointer); +static void PortholeCallback(Widget, XtPointer, XtPointer); +static void ToggleCallback(Widget, XtPointer, XtPointer); +static void ToggleNode(TreeNode*, Bool); +static void ToggleNodeRecursive(TreeNode*); +static void OptionsCallback(Widget, XtPointer, XtPointer); +static void RelayoutTree(void); +static void PopdownCallback(Widget, XtPointer, XtPointer); +static void UpdateConfig(TreeNode*); +static void DestroyTree(TreeNode*); + +static void CreateFiles(TreeNode*); +static void CreateFilesField(TreeNode*, char*, char*); +static void UpdateFiles(TreeNode*); + +static void CreateFontPath(TreeNode*, char*); +static Widget CreateFontPathField(TreeNode*, char*, Bool); +static void FontPathChanged(TreeNode*); +static void NewFontPathCallback(Widget, XtPointer, XtPointer); + +static void CreateModulePath(TreeNode*, char*); +static Widget CreateModulePathField(TreeNode*, char*, Bool); +static void ModulePathChanged(TreeNode*); +static void NewModulePathCallback(Widget, XtPointer, XtPointer); + +static void CreateModule(TreeNode*, XF86LoadPtr); +static void CreateModuleField(TreeNode*, Bool); +static void ModuleDestroy(TreeNode*); +static void NewModuleCallback(Widget, XtPointer, XtPointer); + +static void CreateModes(TreeNode*, XF86ConfModesPtr); +static void CreateModesField(TreeNode*, Bool); +static void ModesDestroy(TreeNode*); +static void NewModesCallback(Widget, XtPointer, XtPointer); +static void CreateModesModeLine(TreeNode*, XF86ConfModeLinePtr); +static void ModesModeLineDestroy(TreeNode*); +static void NewModesModeLineCallback(Widget, XtPointer, XtPointer); + +static void CreateModeLineField(TreeNode*, Bool, Bool); +static XF86ConfModeLinePtr ParseModeLine(char*, char*); + +static void CreateVideoAdaptor(TreeNode*, XF86ConfVideoAdaptorPtr); +static void CreateVideoAdaptorField(TreeNode*, Bool); +static void VideoAdaptorDestroy(TreeNode*); +static void NewVideoAdaptorCallback(Widget, XtPointer, XtPointer); +static void VideoAdaptorUpdate(TreeNode*); +static void CreateVideoPort(TreeNode*, XF86ConfVideoPortPtr); +static void CreateVideoPortField(TreeNode*, Bool); +static void VideoPortDestroy(TreeNode*); +static void NewVideoPortCallback(Widget, XtPointer, XtPointer); + +static void CreateMonitor(TreeNode*, XF86ConfMonitorPtr); +static void CreateMonitorField(TreeNode*, Bool); +static void MonitorDestroy(TreeNode*); +static void NewMonitorCallback(Widget, XtPointer, XtPointer); +static void MonitorUpdate(TreeNode*); +static void CreateMonitorModeLine(TreeNode*, XF86ConfModeLinePtr); +static void MonitorModeLineDestroy(TreeNode*); +static void NewMonitorModeLineCallback(Widget, XtPointer, XtPointer); +static void CreateMonitorModes(TreeNode*, XF86ConfModesLinkPtr); +static void CreateMonitorModesField(TreeNode*, Bool); +static void MonitorModesLinkDestroy(TreeNode*); +static void NewMonitorModesCallback(Widget, XtPointer, XtPointer); + +static void CreateDevice(TreeNode*, XF86ConfDevicePtr); +static void CreateDeviceField(TreeNode*, Bool); +static void NewDeviceCallback(Widget, XtPointer, XtPointer); +static void DeviceDestroy(TreeNode*); +static void DeviceUpdate(TreeNode*); + +static void CreateScreen(TreeNode*, XF86ConfScreenPtr); +static void CreateScreenField(TreeNode*, Bool); +static void NewScreenCallback(Widget, XtPointer, XtPointer); +static void ScreenDestroy(TreeNode*); +static void ScreenUpdate(TreeNode*); +static void CreateScreenAdaptor(TreeNode*, XF86ConfAdaptorLinkPtr); +static void CreateScreenAdaptorField(TreeNode*, Bool); +static void NewScreenAdaptorCallback(Widget, XtPointer, XtPointer); +static void ScreenAdaptorDestroy(TreeNode*); +static void CreateScreenDisplay(TreeNode*, XF86ConfDisplayPtr); +static void CreateScreenDisplayField(TreeNode*, Bool); +static void NewScreenDisplayCallback(Widget, XtPointer, XtPointer); +static void ScreenDisplayDestroy(TreeNode*); +static void ScreenDisplayUpdate(TreeNode*); +static void CreateDisplayMode(TreeNode*, XF86ModePtr); +static void CreateDisplayModeField(TreeNode*, Bool); +static void NewDisplayModeCallback(Widget, XtPointer, XtPointer); +static void DisplayModeDestroy(TreeNode*); + +static void CreateInput(TreeNode*, XF86ConfInputPtr); +static void CreateInputField(TreeNode*, Bool); +static void InputDestroy(TreeNode*); +static void NewInputCallback(Widget, XtPointer, XtPointer); + +static void CreateLayout(TreeNode*, XF86ConfLayoutPtr); +static void CreateLayoutField(TreeNode*, Bool); +static void LayoutDestroy(TreeNode*); +static void NewLayoutCallback(Widget, XtPointer, XtPointer); +static void CreateAdjacency(TreeNode*, XF86ConfAdjacencyPtr); +static void CreateAdjacencyField(TreeNode*, Bool); +static void AdjacencyDestroy(TreeNode*); +static void NewAdjacencyCallback(Widget, XtPointer, XtPointer); +static void AdjacencyMenuCallback(Widget, XtPointer, XtPointer); +static void AdjacencyToggleCallback(Widget, XtPointer, XtPointer); +static void CreateInputref(TreeNode*, XF86ConfInputrefPtr); +static void CreateInputrefField(TreeNode*, Bool); +static void InputrefDestroy(TreeNode*); +static void NewInputrefCallback(Widget, XtPointer, XtPointer); + +static void CreateVendor(TreeNode*, XF86ConfVendorPtr); +static void CreateVendorField(TreeNode*, Bool); +static void VendorDestroy(TreeNode*); +static void NewVendorCallback(Widget, XtPointer, XtPointer); +static void CreateVendorSub(TreeNode*, XF86ConfVendSubPtr); +static void CreateVendorSubField(TreeNode*, Bool); +static void NewVendorSubCallback(Widget, XtPointer, XtPointer); +static void VendorSubDestroy(TreeNode*); +static void VendorSubUpdate(TreeNode*); + +static void CreateDRI(TreeNode*, XF86ConfDRIPtr); +static void CreateDRIField(TreeNode*); +static void DRIUpdate(TreeNode*); + +static void CreateBuffers(TreeNode*, XF86ConfBuffersPtr); +static void CreateBuffersField(TreeNode*, Bool); +static void BuffersDestroy(TreeNode*); +static void NewBuffersCallback(Widget, XtPointer, XtPointer); +static void BuffersUpdate(TreeNode*); + +extern void CreateOptionsShell(void); +extern void RemoveDeviceCallback(Widget, XtPointer, XtPointer); + +/* + * Initialization + */ +static Widget shell, expert, tree, panner; +extern Widget work, optionsShell, config; +extern xf86cfgDevice cpu_device; +static TreeNode *mainNode, *monitorTree, *screenTree, *layoutTree; + +/* + * Implementation + */ +void +ExpertConfigureStart(void) +{ + ExpertInitialize(); + + XtPopup(shell, XtGrabExclusive); + if (optionsShell == NULL) + CreateOptionsShell(); + XtVaSetValues(optionsShell, XtNtransientFor, shell, NULL, 0); +} + +void +ExpertConfigureEnd(void) +{ + int i; + + XtVaSetValues(optionsShell, XtNtransientFor, toplevel, NULL, 0); + XtPopdown(shell); + + for (i = 0; i < computer.num_screens; i++) { + XF86OptionPtr option, options; + int rotate; + + options = computer.screens[i]->screen->scrn_option_lst; + if ((option = xf86findOption(options, "Rotate")) != NULL) { + if (option->opt_val != NULL) + rotate = strcasecmp(option->opt_val, "CW") == 0 ? 1 : + strcasecmp(option->opt_val, "CCW") == 0 ? -1 : 0; + XtFree(option->opt_val); + option->opt_val = XtNewString(rotate > 0 ? "CW" : "CCW"); + computer.screens[i]->rotate = rotate; + } + else + computer.screens[i]->rotate = 0; + UpdateScreenUI(); + AdjustScreenUI(); + SetTip((xf86cfgDevice*)computer.screens[i]); + } + if (XF86Config->conf_flags && XF86Config->conf_flags->flg_option_lst) + SetTip(&cpu_device); + for (i = 0; i < computer.num_devices; i++) + SetTip(computer.devices[i]); + + /* Need to do this to avoid all code elsewhere needing to update the + * "expert" widget tree + */ + UpdateConfig(mainNode); + DestroyTree(mainNode); + XtDestroyWidget(shell); + expert = NULL; +} + +/*ARGSUSED*/ +void +ExpertCloseAction(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + ExpertConfigureEnd(); +} + +/*ARGSUSED*/ +void +ExpertCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + ExpertConfigureStart(); +} + +/*ARGSUSED*/ +static void +PopdownCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + ExpertConfigureEnd(); +} + +/* Files */ +static void +CreateFiles(TreeNode *files) +{ + XF86ConfFilesPtr file = XF86Config->conf_files; + TreeNode *node, *fontpath, *modulepath; + Widget w; + char *value; + + value = file->file_logfile ? file->file_logfile : ""; + node = NewNode(files, NULL, NULL, files->node, + (TreeData*)XtCalloc(1, sizeof(TreeData))); + CreateFilesField(node, "LogFile", value); + files->child = node; + files->update = UpdateFiles; + + if (XF86RGB_path) + value = XF86RGB_path; + else + value = file->file_rgbpath ? file->file_rgbpath : ""; + node->next = NewNode(files, NULL, NULL, files->node, + (TreeData*)XtCalloc(1, sizeof(TreeData))); + node = node->next; + CreateFilesField(node, "RgbPath", value); + + w = XtVaCreateManagedWidget("ModulePath", toggleWidgetClass, tree, + XtNtreeParent, files->node, NULL, 0); + node->next = modulepath = NewNode(files, w, w, files->node, NULL); + node = node->next; + CreateModulePath(modulepath, NULL); + + w = XtVaCreateManagedWidget("FontPath", toggleWidgetClass, tree, + XtNtreeParent, files->node, NULL, 0); + node->next = fontpath = NewNode(files, w, w, files->node, NULL); + node = node->next; + CreateFontPath(fontpath, NULL); +} + +static void +CreateFilesField(TreeNode *node, char *name, char *value) +{ + Widget box, label, text; + + box = XtVaCreateManagedWidget(name, boxWidgetClass, tree, + XtNtreeParent, node->node, NULL, 0); + node->node = box; + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, name, NULL, 0); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, value, + NULL, 0); + node->data->files.text = text; +} + +static void +UpdateFiles(TreeNode *files) +{ + char *str; + + /* LogFile */ + files = files->child; + XtVaGetValues(files->data->files.text, XtNstring, &str, NULL, 0); + XtFree(XF86Config->conf_files->file_logfile); + if (*str) + XF86Config->conf_files->file_logfile = XtNewString(str); + else + XF86Config->conf_files->file_logfile = NULL; + + /* LogFile */ + files = files->next; + XtVaGetValues(files->data->files.text, XtNstring, &str, NULL, 0); + XtFree(XF86Config->conf_files->file_rgbpath); + if (*str) + XF86Config->conf_files->file_rgbpath = XtNewString(str); + else + XF86Config->conf_files->file_rgbpath = NULL; +} + +/* FontPath */ +/* Don't need to set the update tree field, as it is already set + * as the destroy field */ +static void +CreateFontPath(TreeNode *fontpath, char *path) +{ + TreeNode *prev, *node; + Widget w; + + if (path == NULL) { + if (XF86Font_path) { + path = XtNewString(XF86Font_path); + if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) { + XtFree(XF86Config->conf_files->file_fontpath); + XF86Config->conf_files->file_fontpath = XtNewString(path); + } + } + else if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) + path = XtNewString(XF86Config->conf_files->file_fontpath); + } + else { + path = XtNewString(path); + if ((prev = fontpath->child) != NULL) + while (prev->next) + prev = prev->next; + } + + if (path) { + char *s; + + for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) { + node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL); + node->destroy = FontPathChanged; + w = CreateFontPathField(node, s, False); + if (fontpath->child == NULL) + fontpath->child = node; + else + prev->next = node; + prev = node; + } + XtFree(path); + } + + node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL); + w = CreateFontPathField(node, "", True); + if (fontpath->child == NULL) + fontpath->child = node; + else + prev->next = node; +} + +static Widget +CreateFontPathField(TreeNode *fontpath, char *value, Bool addnew) +{ + Widget box, command, text; + TreeData *data; + + box = XtVaCreateWidget("fontpath", formWidgetClass, tree, + XtNtreeParent, fontpath->treeParent, NULL, 0); + fontpath->node = box; + if (!addnew) { + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)fontpath); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewFontPathCallback, + (XtPointer)fontpath); + text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL, 0); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->files.text = text; + fontpath->data = data; + + if (fontpath->treeParent && XtIsRealized(fontpath->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); + + return (box); +} + +static void +FontPathChanged(TreeNode *node) +{ + TreeNode *parent = node->parent; + char *fontpath = NULL, *str; + Arg args[1]; + int pos = 0, len; + + /* last node is the "new" */ + for (node = parent->child; node->next != NULL; node = node->next) { + if (pos) + fontpath[pos++] = ','; + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + len = strlen(str) + 2; + fontpath = XtRealloc(fontpath, pos + len); + strcpy(fontpath + pos, str); + pos += len - 2; + } + + if (XF86Config->conf_files->file_fontpath) + XtFree(XF86Config->conf_files->file_fontpath); + XF86Config->conf_files->file_fontpath = fontpath; +} + +static void +NewFontPathCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *fontpath, *node = (TreeNode*)user_data; + Arg args[1]; + char *str; + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + if (*str == '\0') + return; + + fontpath = node->parent; + DeleteNode(node); + CreateFontPath(fontpath, str); + + FontPathChanged(fontpath->child); + RelayoutTree(); +} + +/* ModulePath */ +/* Don't need to set the update tree field, as it is already set + * as the destroy field */ +static void +CreateModulePath(TreeNode *modulepath, char *path) +{ + TreeNode *prev, *node; + Widget w; + + if (path == NULL) { + if (XF86Module_path) { + path = XtNewString(XF86Module_path); + if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) { + XtFree(XF86Config->conf_files->file_modulepath); + XF86Config->conf_files->file_modulepath = XtNewString(path); + } + } + else if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) + path = XtNewString(XF86Config->conf_files->file_modulepath); + } + else { + path = XtNewString(path); + if ((prev = modulepath->child) != NULL) + while (prev->next) + prev = prev->next; + } + + if (path) { + char *s; + + for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) { + node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL); + node->destroy = ModulePathChanged; + w = CreateModulePathField(node, s, False); + if (modulepath->child == NULL) + modulepath->child = node; + else + prev->next = node; + prev = node; + } + XtFree(path); + } + + node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL); + w = CreateModulePathField(node, "", True); + if (modulepath->child == NULL) + modulepath->child = node; + else + prev->next = node; +} + +static Widget +CreateModulePathField(TreeNode *modulepath, char *value, Bool addnew) +{ + Widget box, command, text; + TreeData *data; + + box = XtVaCreateWidget("modulepath", formWidgetClass, tree, + XtNtreeParent, modulepath->treeParent, NULL, 0); + modulepath->node = box; + if (!addnew) { + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)modulepath); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewModulePathCallback, + (XtPointer)modulepath); + text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, value, NULL, 0); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->files.text = text; + modulepath->data = data; + + if (modulepath->treeParent && XtIsRealized(modulepath->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); + + return (box); +} + +static void +ModulePathChanged(TreeNode *node) +{ + TreeNode *parent = node->parent; + char *modulepath = NULL, *str; + Arg args[1]; + int pos = 0, len; + + /* last node is the "new" */ + for (node = parent->child; node->next != NULL; node = node->next) { + if (pos) + modulepath[pos++] = ','; + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + len = strlen(str) + 2; + modulepath = XtRealloc(modulepath, pos + len); + strcpy(modulepath + pos, str); + pos += len - 2; + } + + if (XF86Config->conf_files->file_modulepath) + XtFree(XF86Config->conf_files->file_modulepath); + XF86Config->conf_files->file_modulepath = modulepath; +} + +static void +NewModulePathCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *modulepath, *node = (TreeNode*)user_data; + Arg args[1]; + char *str; + + XtSetArg(args[0], XtNstring, &str); + XtGetValues(node->data->files.text, args, 1); + if (*str == '\0') + return; + + modulepath = node->parent; + DeleteNode(node); + CreateModulePath(modulepath, str); + + ModulePathChanged(modulepath->child); + RelayoutTree(); +} + +/* Module */ +static void +CreateModule(TreeNode *module, XF86LoadPtr load) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = module->child) != NULL) + while (prev->next) + prev = prev->next; + + while (load) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->module.load = load; + node = NewNode(module, NULL, NULL, module->node, data); + node->destroy = ModuleDestroy; + CreateModuleField(node, False); + if (module->child == NULL) + module->child = node; + else + prev->next = node; + prev = node; + load = (XF86LoadPtr)(load->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(module, NULL, NULL, module->node, data); + CreateModuleField(node, True); + if (module->child == NULL) + module->child = node; + else + prev->next = node; +} + +static void +CreateModuleField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("module", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86LoadPtr load = node->data->module.load; + + options = &(load->load_opt); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, load->load_name, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewModuleCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->module.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModuleDestroy(TreeNode *node) +{ + if (node->data->module.load) + xf86removeModule(XF86Config, node->data->module.load); +} + +/*ARGSUSED*/ +static void +NewModuleCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *module, *node = (TreeNode*)user_data; + XF86LoadPtr load; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->module.text, args, 1); + if (*label == '\0') + return; + + module = node->parent; + DeleteNode(node); + load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec)); + load->load_name = XtNewString(label); + XF86Config->conf_modules->mod_load_lst = + xf86addModule(XF86Config->conf_modules->mod_load_lst, load); + + CreateModule(module, load); + RelayoutTree(); +} + +/* Modes */ +static void +CreateModes(TreeNode *parent, XF86ConfModesPtr modes) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modes) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modes.modes = modes; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ModesDestroy; + CreateModesField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + modes = (XF86ConfModesPtr)(modes->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateModesField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateModesField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("modes", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86ConfModesPtr modes = node->data->modes.modes; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("mode", toggleWidgetClass, box, + XtNlabel, modes->modes_identifier, + XtNstate, True, + NULL, 0); + node->toggle = label; + XtAddCallback(label, XtNcallback, ToggleCallback, (XtPointer)node); + CreateModesModeLine(node, node->data->modes.modes->mon_modeline_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewModesCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->modes.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModesDestroy(TreeNode *node) +{ + if (node->data->modes.modes) { + int i; + TreeNode *mon = monitorTree->child; + + /* last one is the "new" entry */ + while (mon && mon->next) { + /* UseModes is the second entry */ + TreeNode *mod = mon->child->next->child; + CompositeWidget composite; + + while (mod && mod->next) { + TreeNode *next = mod->next; + + if (mod && strcmp(mod->data->modeslink.modeslink->ml_modes_str, + node->data->modes.modes->modes_identifier) == 0) + /* Needs to do string comparison because may be deleting + * a "test" Modes section, with no Modelines. + */ + DeleteNode(mod); + mod = next; + } + composite = (CompositeWidget)mod->data->modeslink.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->modes.modes->modes_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + mon = mon->next; + } + + xf86removeModes(XF86Config, node->data->modes.modes); + } +} + +/*ARGSUSED*/ +static void +NewModesCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModesPtr modes; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->modes.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modes = (XF86ConfModesPtr)XtCalloc(1, sizeof(XF86ConfModesRec)); + modes->modes_identifier = XtNewString(label); + XF86Config->conf_modes_lst = + xf86addModes(XF86Config->conf_modes_lst, modes); + + { + TreeNode *mon = monitorTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (mon && mon->next) { + /* UseModes is the second entry */ + TreeNode *mod = mon->child->next->child; + + while (mod && mod->next) + mod = mod->next; + + sme = XtCreateManagedWidget(modes->modes_identifier, + smeBSBObjectClass, + mod->data->modeslink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewMonitorModesCallback, + (XtPointer)mod); + + mon = mon->next; + } + } + + CreateModes(parent, modes); + RelayoutTree(); +} + +static void +CreateModesModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modeline) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeline.modeline = modeline; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ModesModeLineDestroy; + CreateModeLineField(node, False, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modeline = (XF86ConfModeLinePtr)(modeline->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateModeLineField(node, True, False); +} + +/* This function should allow creating modelines for the + Mode and Monitor section */ +static void +CreateModeLineField(TreeNode *node, Bool addnew, Bool monitor) +{ + Widget box, command; + char buf[512], tmp[32]; + + box = XtVaCreateWidget("modeline", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86ConfModeLinePtr mod = node->data->modeline.modeline; + + command = XtCreateManagedWidget("remove", commandWidgetClass, + box, NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mod->ml_identifier, NULL, 0); + + XmuSnprintf(buf, sizeof(buf), "%g %d %d %d %d %d %d %d %d", + mod->ml_clock / 1000., mod->ml_hdisplay, mod->ml_hsyncstart, + mod->ml_hsyncend, mod->ml_htotal, mod->ml_vdisplay, + mod->ml_vsyncstart, mod->ml_vsyncend, mod->ml_vtotal); + if (mod->ml_flags & XF86CONF_INTERLACE) + strcat(buf, " interlace"); + if (mod->ml_flags & XF86CONF_PHSYNC) + strcat(buf, " +hsync"); + if (mod->ml_flags & XF86CONF_NHSYNC) + strcat(buf, " -hsync"); + if (mod->ml_flags & XF86CONF_PVSYNC) + strcat(buf, " +vsync"); + if (mod->ml_flags & XF86CONF_NVSYNC) + strcat(buf, " -vsync"); + if (mod->ml_flags & XF86CONF_CSYNC) + strcat(buf, " composite"); + if (mod->ml_flags & XF86CONF_PCSYNC) + strcat(buf, " +csync"); + if (mod->ml_flags & XF86CONF_NCSYNC) + strcat(buf, " -csync"); + if (mod->ml_flags & XF86CONF_DBLSCAN) + strcat(buf, " doublescan"); + if (mod->ml_flags & XF86CONF_BCAST) + strcat(buf, " bcast"); + if (mod->ml_flags & XF86CONF_HSKEW) { + XmuSnprintf(tmp, sizeof(tmp), " hskew %d", mod->ml_hskew); + strcat(buf, tmp); + } + if (mod->ml_flags & XF86CONF_VSCAN) { + XmuSnprintf(tmp, sizeof(tmp), " vscan %d", mod->ml_vscan); + strcat(buf, tmp); + } + if (mod->ml_flags & XF86CONF_CUSTOM) + strcat(buf, " custom"); + node->data->modeline.value = + XtVaCreateManagedWidget("modeline", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + } + else { + *buf = '\0'; + command = XtCreateManagedWidget("new", commandWidgetClass, + box, NULL, 0); + XtAddCallback(command, XtNcallback, monitor ? + NewMonitorModeLineCallback : NewModesModeLineCallback, + (XtPointer)node); + node->data->modeline.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + node->data->modeline.value = + XtVaCreateManagedWidget("modelineNew", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +ModesModeLineDestroy(TreeNode *node) +{ + if (node->data->modeline.modeline) + xf86removeModesModeLine(node->parent->data->modes.modes, + node->data->modeline.modeline); +} + +/*ARGSUSED*/ +static void +NewModesModeLineCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModeLinePtr modeline; + Arg args[1]; + char *ident, *value; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->modeline.text, args, 1); + XtSetArg(args[0], XtNstring, &value); + XtGetValues(node->data->modeline.value, args, 1); + if (*ident == '\0' || *value == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modeline = ParseModeLine(ident, value); + parent->data->modes.modes->mon_modeline_lst = + xf86addModeLine(parent->data->modes.modes->mon_modeline_lst, modeline); + + CreateModesModeLine(parent, modeline); + RelayoutTree(); +} + +static XF86ConfModeLinePtr +ParseModeLine(char *identifier, char *modeline) +{ + XF86ConfModeLinePtr ml = (XF86ConfModeLinePtr) + XtCalloc(1, sizeof(XF86ConfModeLineRec)); + char *s, *ptr = modeline; + + /* Identifier */ + ml->ml_identifier = XtNewString(identifier); + + ml->ml_clock = (int)(strtod(ptr, &ptr) * 1000.0 + 0.5); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hdisplay = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hsyncstart = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_hsyncend = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_htotal = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vdisplay = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vsyncstart = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vsyncend = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + ml->ml_vtotal = strtol(ptr, &ptr, 10); + while (*ptr && isspace(*ptr)) ++ptr; + + s = ptr; + while (*s) { + *s = tolower(*s); + ++s; + } + s = ptr; + + while (*ptr) { + while (*s && isspace(*s)) + s++; + ptr = s; + while (*s && !isspace(*s)) + s++; + + if (s != ptr) { + Bool done = *s == '\0'; + + *s = '\0'; + if (strcmp(ptr, "interlace") == 0) + ml->ml_flags |= XF86CONF_INTERLACE; + else if (strcmp(ptr, "+hsync") == 0) + ml->ml_flags |= XF86CONF_PHSYNC; + else if (strcmp(ptr, "-hsync") == 0) + ml->ml_flags |= XF86CONF_NHSYNC; + else if (strcmp(ptr, "+vsync") == 0) + ml->ml_flags |= XF86CONF_PVSYNC; + else if (strcmp(ptr, "-vsync") == 0) + ml->ml_flags |= XF86CONF_NVSYNC; + else if (strcmp(ptr, "composite") == 0) + ml->ml_flags |= XF86CONF_CSYNC; + else if (strcmp(ptr, "+csync") == 0) + ml->ml_flags |= XF86CONF_PCSYNC; + else if (strcmp(ptr, "-csync") == 0) + ml->ml_flags |= XF86CONF_NCSYNC; + else if (strcmp(ptr, "doublescan") == 0) + ml->ml_flags |= XF86CONF_DBLSCAN; + else if (strcmp(ptr, "bcast") == 0) + ml->ml_flags |= XF86CONF_BCAST; + else if (strcmp(ptr, "hskew") == 0) { + ++s; + while (*s && isspace(*s)) + ++s; + ptr = s; + while (*s && !isspace(*s)) + ++s; + if (ptr != s) { + ml->ml_hskew = strtol(ptr, &s, 10); + ml->ml_flags |= XF86CONF_HSKEW; + --s; + } + } + else if (strcmp(ptr, "vscan") == 0) { + ++s; + while (*s && isspace(*s)) + ++s; + ptr = s; + while (*s && !isspace(*s)) + ++s; + if (ptr != s) { + ml->ml_vscan = strtol(ptr, &s, 10); + ml->ml_flags |= XF86CONF_VSCAN; + --s; + } + } + else if (strcmp(ptr, "custom") == 0) + ml->ml_flags |= XF86CONF_CUSTOM; + ++s; + if (done) + break; + ptr = s; + } + } + + return (ml); +} + +/* VideoAdpator */ +static void +CreateVideoAdaptor(TreeNode *parent, XF86ConfVideoAdaptorPtr video) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (video) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->video.video = video; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VideoAdaptorDestroy; + node->update = VideoAdaptorUpdate; + CreateVideoAdaptorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + video = (XF86ConfVideoAdaptorPtr)(video->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVideoAdaptorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVideoAdaptorField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("video", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char *str; + TreeNode *port; + XF86ConfVideoAdaptorPtr video = node->data->video.video; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, + (XtPointer)&(video->va_option_lst)); + label = XtVaCreateManagedWidget("adaptor", labelWidgetClass, box, + XtNlabel, video->va_identifier, + NULL, 0); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = video->va_vendor ? video->va_vendor : ""; + node->data->video.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0); + str = video->va_board ? video->va_board : ""; + node->data->video.board = + XtVaCreateManagedWidget("board", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0); + str = video->va_busid ? video->va_busid : ""; + node->data->video.busid = + XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = video->va_driver ? video->va_driver : ""; + node->data->video.driver = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + label = XtVaCreateManagedWidget("VideoPort", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, + NULL, 0); + port = NewNode(node, label, label, node->node, NULL); + node->child = port; + CreateVideoPort(port, video->va_port_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVideoAdaptorCallback, + (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->video.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +VideoAdaptorDestroy(TreeNode *node) +{ + if (node->data->video.video) { + int i; + TreeNode *scrn = screenTree->child; + + /* last one is the "new" entry */ + while (scrn && scrn->next) { + /* VideoAdator is the first entry */ + TreeNode *ad = scrn->child->child; + CompositeWidget composite; + + while (ad && ad->next) { + TreeNode *next = ad->next; + + if (ad && strcmp(ad->data->adaptorlink.adaptorlink->al_adaptor_str, + node->data->video.video->va_identifier) == 0) + DeleteNode(ad); + ad = next; + } + composite = (CompositeWidget)ad->data->adaptorlink.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->video.video->va_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + scrn = scrn->next; + } + + xf86removeVideoAdaptor(XF86Config, node->data->video.video); + } +} + +/*ARGSUSED*/ +static void +NewVideoAdaptorCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVideoAdaptorPtr video; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->video.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + video = (XF86ConfVideoAdaptorPtr) + XtCalloc(1, sizeof(XF86ConfVideoAdaptorRec)); + video->va_identifier = XtNewString(label); + XF86Config->conf_videoadaptor_lst = + xf86addVideoAdaptor(XF86Config->conf_videoadaptor_lst, video); + + { + TreeNode *scrn = screenTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (scrn && scrn->next) { + /* VideoAdaptor is the first entry */ + TreeNode *ad = scrn->child->child; + + while (ad && ad->next) + ad = ad->next; + + sme = XtCreateManagedWidget(video->va_identifier, + smeBSBObjectClass, + ad->data->adaptorlink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback, + (XtPointer)ad); + + scrn = scrn->next; + } + } + + CreateVideoAdaptor(parent, video); + RelayoutTree(); +} + +static void +VideoAdaptorUpdate(TreeNode *node) +{ + char *str; + + /* vendor */ + XtVaGetValues(node->data->video.vendor, XtNstring, &str, NULL, 0); + XtFree(node->data->video.video->va_vendor); + if (*str) + node->data->video.video->va_vendor = XtNewString(str); + else + node->data->video.video->va_vendor = NULL; + + /* board */ + XtVaGetValues(node->data->video.board, XtNstring, &str, NULL, 0); + XtFree(node->data->video.video->va_board); + if (*str) + node->data->video.video->va_board = XtNewString(str); + else + node->data->video.video->va_board = NULL; + + /* busid */ + XtVaGetValues(node->data->video.busid, XtNstring, &str, NULL, 0); + XtFree(node->data->video.video->va_busid); + if (*str) + node->data->video.video->va_busid = XtNewString(str); + else + node->data->video.video->va_busid = NULL; + + /* driver */ + XtVaGetValues(node->data->video.driver, XtNstring, &str, NULL, 0); + XtFree(node->data->video.video->va_driver); + if (*str) + node->data->video.video->va_driver = XtNewString(str); + else + node->data->video.video->va_driver = NULL; +} + +static void +CreateVideoPort(TreeNode *parent, XF86ConfVideoPortPtr port) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (port) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->port.port = port; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VideoPortDestroy; + CreateVideoPortField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + port = (XF86ConfVideoPortPtr)(port->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVideoPortField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVideoPortField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("port", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfVideoPortPtr port = node->data->port.port; + + options = &(port->vp_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, port->vp_identifier, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVideoPortCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->port.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +VideoPortDestroy(TreeNode *node) +{ + if (node->data->port.port) + xf86removeVideoPort(node->parent->parent->data->video.video, + node->data->port.port); +} + +/*ARGSUSED*/ +static void +NewVideoPortCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *video, *node = (TreeNode*)user_data; + XF86ConfVideoPortPtr port; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->port.text, args, 1); + if (*label == '\0') + return; + + video = node->parent->parent; + DeleteNode(node); + port = (XF86ConfVideoPortPtr)XtCalloc(1, sizeof(XF86ConfVideoPortRec)); + port->vp_identifier = XtNewString(label); + video->data->video.video->va_port_lst = + xf86addVideoPort(video->data->video.video->va_port_lst, port); + + CreateVideoPort(video, port); + RelayoutTree(); +} + +/* Monitor */ +static void +CreateMonitor(TreeNode *parent, XF86ConfMonitorPtr mon) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (mon) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->monitor.monitor = mon; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorDestroy; + node->update = MonitorUpdate; + CreateMonitorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateMonitorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateMonitorField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("monitor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char *str, buf[256]; + XF86OptionPtr *options; + XF86ConfMonitorPtr mon = node->data->monitor.monitor; + Widget useModes; + TreeNode *modeline, *modes, *prev; + + options = &(mon->mon_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mon->mon_identifier, NULL, 0); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = mon->mon_vendor ? mon->mon_vendor : ""; + node->data->monitor.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("modelnameL", labelWidgetClass, box, NULL, 0); + str = mon->mon_modelname ? mon->mon_modelname : ""; + node->data->monitor.model = + XtVaCreateManagedWidget("modelname", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("widthL", labelWidgetClass, box, NULL, 0); + if (mon->mon_width) + XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_width); + else + *buf = '\0'; + node->data->monitor.width = + XtVaCreateManagedWidget("width", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("heightL", labelWidgetClass, box, NULL, 0); + if (mon->mon_height) + XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_height); + else + *buf = '\0'; + node->data->monitor.height = + XtVaCreateManagedWidget("height", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("hsyncL", labelWidgetClass, box, NULL, 0); + if (mon->mon_n_hsync > 0) + parser_range_to_string(buf, &(mon->mon_hsync[0]), + mon->mon_n_hsync); + else + *buf = '\0'; + node->data->monitor.hsync = + XtVaCreateManagedWidget("hsync", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("vrefreshL", labelWidgetClass, box, NULL, 0); + if (mon->mon_n_vrefresh > 0) + parser_range_to_string(buf, &(mon->mon_vrefresh[0]), + mon->mon_n_vrefresh); + else + *buf = '\0'; + node->data->monitor.vrefresh = + XtVaCreateManagedWidget("vrefresh", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("gammaRedL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_red) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_red); + else + *buf = '\0'; + node->data->monitor.gammaRed = + XtVaCreateManagedWidget("gammaRed", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("gammaGreenL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_green) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_green); + else + *buf = '\0'; + node->data->monitor.gammaGreen = + XtVaCreateManagedWidget("gammaGreen", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("gammaBlueL", labelWidgetClass, box, NULL, 0); + if (mon->mon_gamma_blue) + XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_blue); + else + *buf = '\0'; + node->data->monitor.gammaBlue = + XtVaCreateManagedWidget("gammaBlue", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + if ((prev = node->child) != NULL) + while (prev->next) + prev = prev->next; + command = XtVaCreateManagedWidget("ModeLine", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, NULL, 0); + modeline = NewNode(node, command, command, node->node, NULL); + CreateMonitorModeLine(modeline, + node->data->monitor.monitor->mon_modeline_lst); + if (prev == NULL) + prev = node->child = modeline; + else { + prev->next = modeline; + prev = prev->next; + } + + useModes = XtVaCreateManagedWidget("UseModes", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, NULL, 0); + prev->next = modes = NewNode(node, useModes, useModes, node->node, NULL); + CreateMonitorModes(modes, + node->data->monitor.monitor->mon_modes_sect_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewMonitorCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->monitor.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +MonitorDestroy(TreeNode *node) +{ + int i; + TreeNode *sc = screenTree; + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfMonitorPtr)(computer.devices[i]->config) == + node->data->monitor.monitor) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + + if (sc) { + TreeNode *prev; + + sc = prev = sc->child; + while (sc->next) { + TreeNode *next = sc->next; + + if (sc->data->screen.screen->scrn_monitor == + node->data->monitor.monitor) { + XtDestroyWidget(sc->node); + + if (sc->child) + DestroyTree(sc->child); + if (sc->data) + XtFree((XtPointer)sc->data); + XtFree((XtPointer)sc); + + if (sc == screenTree->child) + sc = prev = next = screenTree->child = next; + else + prev->next = sc = next; + continue; + } + prev = sc; + sc = next; + } + } +} + +static void +NewMonitorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfMonitorPtr mon; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->monitor.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + mon = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec)); + mon->mon_identifier = XtNewString(label); + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, mon); + + CreateMonitor(parent, mon); + + RelayoutTree(); +} + +static void +MonitorUpdate(TreeNode *node) +{ + char *str; + + /* vendor */ + XtVaGetValues(node->data->monitor.vendor, XtNstring, &str, NULL, 0); + XtFree(node->data->monitor.monitor->mon_vendor); + if (*str) + node->data->monitor.monitor->mon_vendor = XtNewString(str); + else + node->data->monitor.monitor->mon_vendor = NULL; + + /* model */ + XtVaGetValues(node->data->monitor.model, XtNstring, &str, NULL, 0); + XtFree(node->data->monitor.monitor->mon_modelname); + if (*str) + node->data->monitor.monitor->mon_modelname = XtNewString(str); + else + node->data->monitor.monitor->mon_modelname = NULL; + + /* width */ + XtVaGetValues(node->data->monitor.width, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_width = atoi(str); + + /* height */ + XtVaGetValues(node->data->monitor.height, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_height = atoi(str); + + /* hsync */ + XtVaGetValues(node->data->monitor.hsync, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_n_hsync = + string_to_parser_range(str, + &(node->data->monitor.monitor->mon_hsync[0]), + CONF_MAX_HSYNC); + + /* vrefresh */ + XtVaGetValues(node->data->monitor.vrefresh, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_n_vrefresh = + string_to_parser_range(str, + &(node->data->monitor.monitor->mon_vrefresh[0]), + CONF_MAX_VREFRESH); + + /* gammaRed */ + XtVaGetValues(node->data->monitor.gammaRed, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_gamma_red = strtod(str, NULL); + + /* gammaGreen */ + XtVaGetValues(node->data->monitor.gammaGreen, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_gamma_green = strtod(str, NULL); + + /* gammaBlue */ + XtVaGetValues(node->data->monitor.gammaBlue, XtNstring, &str, NULL, 0); + node->data->monitor.monitor->mon_gamma_blue = strtod(str, NULL); +} + +static void +CreateMonitorModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modeline) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeline.modeline = modeline; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorModeLineDestroy; + CreateModeLineField(node, False, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modeline = (XF86ConfModeLinePtr)(modeline->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateModeLineField(node, True, True); +} + +/*ARGUSED*/ +static void +MonitorModeLineDestroy(TreeNode *node) +{ + if (node->data->modeline.modeline) + xf86removeMonitorModeLine(node->parent->parent->data->monitor.monitor, + node->data->modeline.modeline); +} + +/*ARGSUSED*/ +static void +NewMonitorModeLineCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModeLinePtr modeline; + Arg args[1]; + char *ident, *value; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->modeline.text, args, 1); + XtSetArg(args[0], XtNstring, &value); + XtGetValues(node->data->modeline.value, args, 1); + if (*ident == '\0' || *value == '\0') + return; + + parent = node->parent; + DeleteNode(node); + modeline = ParseModeLine(ident, value); + parent->parent->data->monitor.monitor->mon_modeline_lst = + xf86addModeLine(parent->parent->data->monitor.monitor->mon_modeline_lst, + modeline); + + CreateMonitorModeLine(parent, modeline); + RelayoutTree(); +} + +static void +CreateMonitorModes(TreeNode *parent, XF86ConfModesLinkPtr lnk) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lnk) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->modeslink.modeslink = lnk; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = MonitorModesLinkDestroy; + CreateMonitorModesField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lnk = (XF86ConfModesLinkPtr)(lnk->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateMonitorModesField(node, True); +} + +static void +CreateMonitorModesField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("modes", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86ConfModesLinkPtr lnk = node->data->modeslink.modeslink; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("mode", labelWidgetClass, box, + XtNlabel, lnk->ml_modes_str, NULL, 0); + } + else { + Widget sme; + XF86ConfModesPtr ptr = XF86Config->conf_modes_lst; + + command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "modesMenu", NULL, 0); + node->data->modeslink.menu = + XtVaCreatePopupShell("modesMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL, 0); + while (ptr) { + sme = XtCreateManagedWidget(ptr->modes_identifier, smeBSBObjectClass, + node->data->modeslink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewMonitorModesCallback, + (XtPointer)node); + ptr = (XF86ConfModesPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +MonitorModesLinkDestroy(TreeNode *node) +{ + if (node->data->modeslink.modeslink) + xf86removeMonitorModesLink(node->parent->parent->data->monitor.monitor, + node->data->modeslink.modeslink); +} + +/*ARGSUSED*/ +static void +NewMonitorModesCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfModesLinkPtr link; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + link = (XF86ConfModesLinkPtr)XtCalloc(1, sizeof(XF86ConfModesLinkRec)); + link->ml_modes_str = XtNewString(ident); + parent->parent->data->monitor.monitor->mon_modes_sect_lst = + xf86addModesLink(parent->parent->data->monitor.monitor->mon_modes_sect_lst, + link); + + CreateMonitorModes(parent, link); + RelayoutTree(); +} + +/* Device */ +static void +CreateDevice(TreeNode *parent, XF86ConfDevicePtr dev) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (dev) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->device.device = dev; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = DeviceDestroy; + node->update = DeviceUpdate; + CreateDeviceField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + dev = (XF86ConfDevicePtr)(dev->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateDeviceField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateDeviceField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("device", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + int i, tmp, len; + char buf[1024], *str; + XF86OptionPtr *options; + XF86ConfDevicePtr dev = node->data->device.device; + + options = &(dev->dev_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, dev->dev_identifier, NULL, 0); + + XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0); + str = dev->dev_vendor ? dev->dev_vendor : ""; + node->data->device.vendor = + XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0); + str = dev->dev_board ? dev->dev_board : ""; + node->data->device.board = + XtVaCreateManagedWidget("board", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("chipsetL", labelWidgetClass, box, NULL, 0); + str = dev->dev_chipset ? dev->dev_chipset : ""; + node->data->device.chipset = + XtVaCreateManagedWidget("chipset", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0); + str = dev->dev_busid ? dev->dev_busid : ""; + node->data->device.busid = + XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("cardL", labelWidgetClass, box, NULL, 0); + str = dev->dev_card ? dev->dev_card : ""; + node->data->device.card = + XtVaCreateManagedWidget("card", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = dev->dev_driver ? dev->dev_driver : ""; + node->data->device.driver = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("ramdacL", labelWidgetClass, box, NULL, 0); + str = dev->dev_ramdac ? dev->dev_ramdac : ""; + node->data->device.ramdac = + XtVaCreateManagedWidget("ramdac", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("dacSpeedL", labelWidgetClass, box, NULL, 0); + if (dev->dev_dacSpeeds[0] > 0) { + for (i = len = 0; i < CONF_MAXDACSPEEDS && + dev->dev_dacSpeeds[i] > 0; i++) { + tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%g ", + dev->dev_dacSpeeds[i] / 1000.); + len += tmp; + } + } + else + *buf = '\0'; + node->data->device.dacSpeed = + XtVaCreateManagedWidget("dacSpeed", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("videoRamL", labelWidgetClass, box, NULL, 0); + if (dev->dev_videoram) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_videoram); + else + *buf = '\0'; + node->data->device.videoRam = + XtVaCreateManagedWidget("videoRam", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("textClockFreqL", labelWidgetClass, box, NULL, 0); + if (dev->dev_textclockfreq) + XmuSnprintf(buf, sizeof(buf), "%.1f", + (double)dev->dev_textclockfreq / 1000.0); + else + *buf = '\0'; + node->data->device.textClockFreq = + XtVaCreateManagedWidget("textClockFreq", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("biosBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_bios_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_bios_base); + else + *buf = '\0'; + node->data->device.biosBase = + XtVaCreateManagedWidget("biosBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("memBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_mem_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_mem_base); + else + *buf = '\0'; + node->data->device.memBase = + XtVaCreateManagedWidget("memBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("ioBaseL", labelWidgetClass, box, NULL, 0); + if (dev->dev_io_base) + XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_io_base); + else + *buf = '\0'; + node->data->device.ioBase = + XtVaCreateManagedWidget("ioBase", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("clockChipL", labelWidgetClass, box, NULL, 0); + str = dev->dev_clockchip ? dev->dev_clockchip : ""; + node->data->device.clockChip = + XtVaCreateManagedWidget("clockChip", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + *buf = '\0'; + for (i = len = 0; i < dev->dev_clocks; i++) { + tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%.1f ", + (double)dev->dev_clock[i] / 1000.0); + len += tmp; + } + XtCreateManagedWidget("devClockL", labelWidgetClass, box, NULL, 0); + node->data->device.devClock = + XtVaCreateManagedWidget("devClock", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("chipIdL", labelWidgetClass, box, NULL, 0); + if (dev->dev_chipid != -1) + XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chipid); + else + *buf = '\0'; + node->data->device.chipId = + XtVaCreateManagedWidget("chipId", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("chipRevL", labelWidgetClass, box, NULL, 0); + if (dev->dev_chiprev != -1) + XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chiprev); + else + *buf = '\0'; + node->data->device.chipRev = + XtVaCreateManagedWidget("chipRev", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("irqL", labelWidgetClass, box, NULL, 0); + if (dev->dev_irq != -1) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_irq); + else + *buf = '\0'; + node->data->device.irq = + XtVaCreateManagedWidget("irq", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("screenL", labelWidgetClass, box, NULL, 0); + if (dev->dev_screen > 0) + XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_screen); + else + *buf = '\0'; + node->data->device.screen = + XtVaCreateManagedWidget("screen", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewDeviceCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->device.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +NewDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfDevicePtr dev; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->device.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + dev = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec)); + dev->dev_identifier = XtNewString(label); + XF86Config->conf_device_lst = + xf86addDevice(XF86Config->conf_device_lst, dev); + + CreateDevice(parent, dev); + + RelayoutTree(); +} + +static void +DeviceDestroy(TreeNode *node) +{ + int i; + TreeNode *sc = screenTree; + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfDevicePtr)(computer.devices[i]->config) == + node->data->device.device) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + + if (sc) { + TreeNode *prev; + + sc = prev = sc->child; + while (sc->next) { + TreeNode *next = sc->next; + + if (sc->data->screen.screen->scrn_monitor == + node->data->monitor.monitor) { + XtDestroyWidget(sc->node); + + if (sc->child) + DestroyTree(sc->child); + if (sc->data) + XtFree((XtPointer)sc->data); + XtFree((XtPointer)sc); + + if (sc == screenTree->child) + sc = prev = next = screenTree->child = next; + else + prev->next = sc = next; + continue; + } + prev = sc; + sc = next; + } + } +} + +static void +DeviceUpdate(TreeNode *node) +{ + int i; + char *str, *tmp; + + /* vendor */ + XtVaGetValues(node->data->device.vendor, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_vendor); + if (*str) + node->data->device.device->dev_vendor = XtNewString(str); + else + node->data->device.device->dev_vendor = NULL; + + /* board */ + XtVaGetValues(node->data->device.board, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_board); + if (*str) + node->data->device.device->dev_board = XtNewString(str); + else + node->data->device.device->dev_board = NULL; + + /* chipset */ + XtVaGetValues(node->data->device.chipset, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_chipset); + if (*str) + node->data->device.device->dev_chipset = XtNewString(str); + else + node->data->device.device->dev_chipset = NULL; + + /* busid */ + XtVaGetValues(node->data->device.busid, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_busid); + if (*str) + node->data->device.device->dev_busid = XtNewString(str); + else + node->data->device.device->dev_busid = NULL; + + /* card */ + XtVaGetValues(node->data->device.card, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_card); + if (*str) + node->data->device.device->dev_card = XtNewString(str); + else + node->data->device.device->dev_card = NULL; + + /* driver */ + XtVaGetValues(node->data->device.driver, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_driver); + if (*str) + node->data->device.device->dev_driver = XtNewString(str); + else + node->data->device.device->dev_driver = NULL; + + /* ramdac */ + XtVaGetValues(node->data->device.ramdac, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_ramdac); + if (*str) + node->data->device.device->dev_ramdac = XtNewString(str); + else + node->data->device.device->dev_ramdac = NULL; + + /* dacSpeed */ + tmp = NULL; + XtVaGetValues(node->data->device.dacSpeed, XtNstring, &str, NULL, 0); + for (i = 0; i < CONF_MAXDACSPEEDS && str != tmp; i++) { + if ((node->data->device.device->dev_dacSpeeds[i] = + (strtod(str, &tmp) * 1000. + .5)) == 0) + break; + str = tmp; + while (isspace(*str)) + ++str; + } + + /* videoRam */ + XtVaGetValues(node->data->device.videoRam, XtNstring, &str, NULL, 0); + node->data->device.device->dev_videoram = atoi(str); + + /* textClockFreq */ + XtVaGetValues(node->data->device.textClockFreq, XtNstring, &str, NULL, 0); + node->data->device.device->dev_textclockfreq = + strtod(str, NULL) * 1000. + .5; + + /* biosBase */ + XtVaGetValues(node->data->device.biosBase, XtNstring, &str, NULL, 0); + node->data->device.device->dev_bios_base = strtoul(str, NULL, 0); + + /* memBase */ + XtVaGetValues(node->data->device.memBase, XtNstring, &str, NULL, 0); + node->data->device.device->dev_mem_base = strtoul(str, NULL, 0); + + /* ioBase */ + XtVaGetValues(node->data->device.ioBase, XtNstring, &str, NULL, 0); + node->data->device.device->dev_io_base = strtoul(str, NULL, 0); + + /* clockChip */ + XtVaGetValues(node->data->device.clockChip, XtNstring, &str, NULL, 0); + XtFree(node->data->device.device->dev_clockchip); + if (*str) + node->data->device.device->dev_clockchip = XtNewString(str); + else + node->data->device.device->dev_clockchip = NULL; + + /* devSpeed */ + tmp = NULL; + XtVaGetValues(node->data->device.devClock, XtNstring, &str, NULL, 0); + for (i = 0; i < CONF_MAXCLOCKS && str != tmp; i++) { + if ((node->data->device.device->dev_clock[i] = + (strtod(str, &tmp) * 1000. + .5)) == 0) + break; + str = tmp; + while (isspace(*str)) + ++str; + } + node->data->device.device->dev_clocks = i; + + /* chipId */ + XtVaGetValues(node->data->device.chipId, XtNstring, &str, NULL, 0); + if (*str) + node->data->device.device->dev_chipid = atoi(str); + else + node->data->device.device->dev_chipid = -1; + + /* chipRev */ + XtVaGetValues(node->data->device.chipRev, XtNstring, &str, NULL, 0); + if (*str) + node->data->device.device->dev_chiprev = atoi(str); + else + node->data->device.device->dev_chiprev = -1; + + /* irq */ + XtVaGetValues(node->data->device.irq, XtNstring, &str, NULL, 0); + if (*str) + node->data->device.device->dev_irq = atoi(str); + else + node->data->device.device->dev_irq = -1; + + /* screen */ + XtVaGetValues(node->data->device.screen, XtNstring, &str, NULL, 0); + if (*str) + node->data->device.device->dev_screen = atoi(str); + else + node->data->device.device->dev_screen = -1; +} + +/* Screen */ +static void +CreateScreen(TreeNode *parent, XF86ConfScreenPtr scrn) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (scrn) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->screen.screen = scrn; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenDestroy; + node->update = ScreenUpdate; + CreateScreenField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + scrn = (XF86ConfScreenPtr)(scrn->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateScreenField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateScreenField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("screen", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char buf[256], *str; + XF86OptionPtr *options; + TreeNode *adaptor, *display; + XF86ConfScreenPtr scrn = node->data->screen.screen; + + options = &(scrn->scrn_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, scrn->scrn_identifier, NULL, 0); + + XtCreateManagedWidget("defaultDepthL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultdepth) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultdepth); + else + *buf = '\0'; + node->data->screen.defaultDepth = + XtVaCreateManagedWidget("defaultDepth", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("defaultBppL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultbpp) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultbpp); + else + *buf = '\0'; + node->data->screen.defaultBpp = + XtVaCreateManagedWidget("defaultBpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("defaultFbBppL", labelWidgetClass, box, NULL, 0); + if (scrn->scrn_defaultfbbpp) + XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultfbbpp); + else + *buf = '\0'; + node->data->screen.defaultFbBpp = + XtVaCreateManagedWidget("defaultFbBpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("monitorL", labelWidgetClass, box, NULL, 0); + str = scrn->scrn_monitor_str ? scrn->scrn_monitor_str : ""; + node->data->screen.monitor = + XtVaCreateManagedWidget("monitor", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("deviceL", labelWidgetClass, box, NULL, 0); + str = scrn->scrn_device_str ? scrn->scrn_device_str : ""; + node->data->screen.device = + XtVaCreateManagedWidget("device", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, + NULL, 0); + + command = XtVaCreateManagedWidget("videoAdaptor", toggleWidgetClass, + tree, XtNstate, True, + XtNtreeParent, box, NULL, 0); + adaptor = NewNode(node, command, command, node->node, NULL); + CreateScreenAdaptor(adaptor, scrn->scrn_adaptor_lst); + node->child = adaptor; + + command = XtVaCreateManagedWidget("Display", toggleWidgetClass, + tree, XtNstate, True, + XtNtreeParent, box, NULL, 0); + display = NewNode(node, command, command, node->node, NULL); + CreateScreenDisplay(display, scrn->scrn_display_lst); + adaptor->next = display; + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewScreenCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->screen.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +NewScreenCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfScreenPtr scrn; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->screen.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + scrn = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); + scrn->scrn_identifier = XtNewString(label); + XF86Config->conf_screen_lst = + xf86addScreen(XF86Config->conf_screen_lst, scrn); + + { + TreeNode *lay = layoutTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (lay && lay->next != NULL) { + /* Adjacency is the first entry */ + TreeNode *adj = lay->child->child; + + while (adj != NULL) { + sme = XtCreateManagedWidget(label, smeBSBObjectClass, + adj->data->adjacency.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, adj->next != NULL ? + AdjacencyMenuCallback : NewAdjacencyCallback, + (XtPointer)adj); + adj = adj->next; + } + lay = lay->next; + } + } + + CreateScreen(parent, scrn); + + RelayoutTree(); +} + +static void +ScreenDestroy(TreeNode *node) +{ + if (node->data->screen.screen) { + int i; + TreeNode *lay = layoutTree->child; + + /* last one is the "new" entry */ + while (lay && lay->next) { + /* Adjacency is the first entry */ + TreeNode *adj = lay->child->child; + CompositeWidget composite; + + while (adj) { + TreeNode *next = adj->next; + + composite = (CompositeWidget)adj->data->adjacency.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->screen.screen->scrn_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + if (adj && adj->data->adjacency.adjacency && + strcmp(adj->data->adjacency.adjacency->adj_screen_str, + node->data->screen.screen->scrn_identifier) == 0) + DeleteNode(adj); + adj = next; + } + + lay = lay->next; + } + + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->screen == node->data->screen.screen) { + config = computer.screens[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + } +} + +static void +ScreenUpdate(TreeNode *node) +{ + char *str; + + /* defautDepth */ + XtVaGetValues(node->data->screen.defaultDepth, XtNstring, &str, NULL, 0); + node->data->screen.screen->scrn_defaultdepth = atoi(str); + + /* defautBpp */ + XtVaGetValues(node->data->screen.defaultBpp, XtNstring, &str, NULL, 0); + node->data->screen.screen->scrn_defaultbpp = atoi(str); + + /* defautFbBpp */ + XtVaGetValues(node->data->screen.defaultFbBpp, XtNstring, &str, NULL, 0); + node->data->screen.screen->scrn_defaultfbbpp = atoi(str); + + + /* XXX Monitor and Device should be changed to a menu interface */ + /* monitor */ + XtVaGetValues(node->data->screen.monitor, XtNstring, &str, NULL, 0); + XtFree(node->data->screen.screen->scrn_monitor_str); + if (*str) + node->data->screen.screen->scrn_monitor_str = XtNewString(str); + else + node->data->screen.screen->scrn_monitor_str = NULL; + + /* XXX Monitor and Device should be changed to a menu interface */ + /* device */ + XtVaGetValues(node->data->screen.device, XtNstring, &str, NULL, 0); + XtFree(node->data->screen.screen->scrn_device_str); + if (*str) + node->data->screen.screen->scrn_device_str = XtNewString(str); + else + node->data->screen.screen->scrn_device_str = NULL; +} + +static void +CreateScreenAdaptor(TreeNode *parent, XF86ConfAdaptorLinkPtr lnk) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lnk) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->adaptorlink.adaptorlink = lnk; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenAdaptorDestroy; + CreateScreenAdaptorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lnk = (XF86ConfAdaptorLinkPtr)(lnk->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateScreenAdaptorField(node, True); +} + +static void +CreateScreenAdaptorField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("adaptor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86ConfAdaptorLinkPtr lnk = node->data->adaptorlink.adaptorlink; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, lnk->al_adaptor_str, NULL, 0); + } + else { + Widget sme; + XF86ConfVideoAdaptorPtr ptr = XF86Config->conf_videoadaptor_lst; + + command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "adaptorMenu", NULL, 0); + node->data->adaptorlink.menu = + XtVaCreatePopupShell("adaptorMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL, 0); + while (ptr) { + sme = XtCreateManagedWidget(ptr->va_identifier, smeBSBObjectClass, + node->data->adaptorlink.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback, + (XtPointer)node); + ptr = (XF86ConfVideoAdaptorPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewScreenAdaptorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfAdaptorLinkPtr link; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + link = (XF86ConfAdaptorLinkPtr)XtCalloc(1, sizeof(XF86ConfAdaptorLinkRec)); + link->al_adaptor_str = XtNewString(ident); + parent->parent->data->screen.screen->scrn_adaptor_lst = + xf86addScreenAdaptor(parent->parent->data->screen.screen->scrn_adaptor_lst, + link); + + CreateScreenAdaptor(parent, link); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +ScreenAdaptorDestroy(TreeNode *node) +{ + if (node->data->adaptorlink.adaptorlink) + xf86removeScreenAdaptorLink(node->parent->parent->data->screen.screen, + node->data->adaptorlink.adaptorlink); +} + +static void +CreateScreenDisplay(TreeNode *parent, XF86ConfDisplayPtr dsp) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (dsp) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->display.display = dsp; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = ScreenDisplayDestroy; + node->update = ScreenDisplayUpdate; + CreateScreenDisplayField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + dsp = (XF86ConfDisplayPtr)(dsp->list.next); + } + node = NewNode(parent, NULL, NULL, parent->node, NULL); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateScreenDisplayField(node, True); +} + +static void +CreateScreenDisplayField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("display", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char *str, buf[256]; + XF86OptionPtr *options; + XF86ConfDisplayPtr dsp = node->data->display.display; + TreeNode *modes; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(dsp->disp_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + + XtCreateManagedWidget("viewportL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_frameX0 != 0 || dsp->disp_frameY0 != 0) + XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_frameX0, dsp->disp_frameY0); + else + *buf = '\0'; + node->data->display.viewport = + XtVaCreateManagedWidget("viewport", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("virtualL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_virtualX != 0 || dsp->disp_virtualY != 0) + XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_virtualX, dsp->disp_virtualY); + else + *buf = '\0'; + node->data->display.c_virtual = + XtVaCreateManagedWidget("virtual", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("depthL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_depth != 0) + XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_depth); + else + *buf = '\0'; + node->data->display.depth = + XtVaCreateManagedWidget("depth", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("bppL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_bpp != 0) + XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_bpp); + else + *buf = '\0'; + node->data->display.bpp = + XtVaCreateManagedWidget("bpp", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("visualL", labelWidgetClass, box, NULL, 0); + str = dsp->disp_visual != NULL ? dsp->disp_visual : ""; + node->data->display.visual = + XtVaCreateManagedWidget("visual", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, NULL, 0); + + XtCreateManagedWidget("weightL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_weight.red > 0) + XmuSnprintf(buf, sizeof(buf), "%d %d %d", + dsp->disp_weight.red, dsp->disp_weight.green, dsp->disp_weight.blue); + else + *buf = '\0'; + node->data->display.weight = + XtVaCreateManagedWidget("weight", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("blackL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_black.red >= 0) + XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x", + dsp->disp_black.red, dsp->disp_black.green, dsp->disp_black.blue); + else + *buf = '\0'; + node->data->display.black = + XtVaCreateManagedWidget("black", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("whiteL", labelWidgetClass, box, NULL, 0); + if (dsp->disp_white.red >= 0) + XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x", + dsp->disp_white.red, dsp->disp_white.green, dsp->disp_white.blue); + else + *buf = '\0'; + node->data->display.white = + XtVaCreateManagedWidget("white", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + command = XtVaCreateManagedWidget("Modes", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL, 0); + modes = NewNode(node, command, command, node->node, NULL); + node->child = modes; + CreateDisplayMode(modes, dsp->disp_mode_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewScreenDisplayCallback, + (XtPointer)node); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewScreenDisplayCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfDisplayPtr dsp; + + parent = node->parent; + DeleteNode(node); + dsp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); + parent->parent->data->screen.screen->scrn_display_lst = + xf86addScreenDisplay(parent->parent->data->screen.screen->scrn_display_lst, + dsp); + + CreateScreenDisplay(parent, dsp); + RelayoutTree(); +} + +static void +ScreenDisplayDestroy(TreeNode *node) +{ + if (node->data->display.display) + xf86removeScreenDisplay(node->parent->parent->data->screen.screen, + node->data->display.display); +} + +static void +ScreenDisplayUpdate(TreeNode *node) +{ + char *str, *tmp; + int x, y; + + /* viewport */ + XtVaGetValues(node->data->display.viewport, XtNstring, &str, NULL, 0); + if (sscanf(str, "%d %d", &x, &y) == 2) { + node->data->display.display->disp_frameX0 = x; + node->data->display.display->disp_frameY0 = y; + } + + /* virtual */ + XtVaGetValues(node->data->display.c_virtual, XtNstring, &str, NULL, 0); + if (sscanf(str, "%d %d", &x, &y) == 2) { + node->data->display.display->disp_virtualX = x; + node->data->display.display->disp_virtualY = y; + } + + /* depth */ + XtVaGetValues(node->data->display.depth, XtNstring, &str, NULL, 0); + node->data->display.display->disp_depth = atoi(str); + + /* bpp */ + XtVaGetValues(node->data->display.bpp, XtNstring, &str, NULL, 0); + node->data->display.display->disp_bpp = atoi(str); + + /* visual */ + XtVaGetValues(node->data->display.visual, XtNstring, &str, NULL, 0); + XtFree(node->data->display.display->disp_visual); + if (*str) + node->data->display.display->disp_visual = XtNewString(str); + else + node->data->display.display->disp_visual = NULL; + + /* weight */ + XtVaGetValues(node->data->display.weight, XtNstring, &str, NULL, 0); + node->data->display.display->disp_weight.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_weight.red = 0; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_weight.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_weight.blue = strtoul(str, &tmp, 0); + } + } + + /* black */ + XtVaGetValues(node->data->display.black, XtNstring, &str, NULL, 0); + node->data->display.display->disp_black.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_black.red = -1; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_black.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_black.blue = strtoul(str, &tmp, 0); + } + } + + /* white */ + XtVaGetValues(node->data->display.white, XtNstring, &str, NULL, 0); + node->data->display.display->disp_white.red = strtoul(str, &tmp, 0); + if (str == tmp) + node->data->display.display->disp_white.red = -1; + else { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_white.green = strtoul(str, &tmp, 0); + if (str != tmp) { + str = tmp; + while (isspace(*str)) + ++str; + node->data->display.display->disp_white.blue = strtoul(str, &tmp, 0); + } + } +} + +static void +CreateDisplayMode(TreeNode *parent, XF86ModePtr modes) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (modes) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->mode.mode = modes; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = DisplayModeDestroy; + CreateDisplayModeField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + modes = (XF86ModePtr)(modes->list.next); + } + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + CreateDisplayModeField(node, True); +} + +static void +CreateDisplayModeField(TreeNode *node, Bool addnew) +{ + Widget box, command, text; + + box = XtVaCreateWidget("mode", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + if (!addnew) { + XF86ModePtr mode = node->data->mode.mode; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, + (XtPointer)node); + text = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, mode->mode_name, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewDisplayModeCallback, + (XtPointer)node); + text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + } + node->data->mode.text = text; + if (node->treeParent && XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewDisplayModeCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ModePtr mode; + Arg args[1]; + char *ident; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->mode.text, args, 1); + if (*ident == '\0') + return; + + parent = node->parent; + DeleteNode(node); + mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec)); + mode->mode_name = XtNewString(ident); + parent->parent->data->display.display->disp_mode_lst = + xf86addDisplayMode(parent->parent->data->display.display->disp_mode_lst, + mode); + + CreateDisplayMode(parent, mode); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +DisplayModeDestroy(TreeNode *node) +{ + if (node->data->mode.mode) + xf86removeDisplayMode(node->parent->parent->data->display.display, + node->data->mode.mode); +} + +/* Input */ +static void +CreateInput(TreeNode *parent, XF86ConfInputPtr input) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (input) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->input.input = input; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = InputDestroy; + CreateInputField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + input = (XF86ConfInputPtr)(input->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateInputField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateInputField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("input", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char *str; + XF86OptionPtr *options; + XF86ConfInputPtr inp = node->data->input.input; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(inp->inp_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, inp->inp_identifier, NULL, 0); + + XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0); + str = inp->inp_driver != NULL ? inp->inp_driver : ""; + node->data->input.text = + XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, str, NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0); + XtAddCallback(command, XtNcallback, NewInputCallback, + (XtPointer)node); + node->data->input.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewInputCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfInputPtr input; + Arg args[1]; + char *ident; + + XtSetArg(args[0], XtNstring, &ident); + XtGetValues(node->data->input.text, args, 1); + if (*ident == '\0') + return; + + parent = node->parent; + DeleteNode(node); + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + input->inp_identifier = XtNewString(ident); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + + { + TreeNode *lay = layoutTree->child; + Widget sme; + + /* last one is the "new" entry */ + while (lay && lay->next != NULL) { + /* Inputref is the second entry */ + TreeNode *iref = lay->child->next->child; + + while (iref && iref->next) + iref = iref->next; + sme = XtCreateManagedWidget(ident, smeBSBObjectClass, + iref->data->inputref.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewInputrefCallback, + (XtPointer)iref); + lay = lay->next; + } + } + + CreateInput(parent, input); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +InputDestroy(TreeNode *node) +{ + if (node->data->input.input) { + int i; + TreeNode *lay = layoutTree->child; + + /* last one is the "new" entry */ + while (lay && lay->next) { + /* Inputref is the second entry */ + TreeNode *iref = lay->child->next->child; + CompositeWidget composite; + + while (iref && iref->next) { + TreeNode *next = iref->next; + + if (iref && strcmp(iref->data->inputref.inputref->iref_inputdev_str, + node->data->input.input->inp_identifier) == 0) + DeleteNode(iref); + iref = next; + } + + composite = (CompositeWidget)iref->data->inputref.menu; + + for (i = 0; i < composite->composite.num_children; ++i) + if (strcmp(XtName(composite->composite.children[i]), + node->data->input.input->inp_identifier) == 0) + XtDestroyWidget(composite->composite.children[i]); + + lay = lay->next; + } + + for (i = 0; i < computer.num_devices; i++) + if ((XF86ConfInputPtr)(computer.devices[i]->config) == + node->data->input.input) { + config = computer.devices[i]->widget; + RemoveDeviceCallback(NULL, NULL, NULL); + } + } +} + +/* Layout */ +static void +CreateLayout(TreeNode *parent, XF86ConfLayoutPtr lay) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (lay) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->layout.layout = lay; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = LayoutDestroy; + CreateLayoutField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + lay = (XF86ConfLayoutPtr)(lay->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateLayoutField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateLayoutField(TreeNode *node, Bool addnew) +{ + Widget box, command, label; + + box = XtVaCreateWidget("layout", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + TreeNode *adjacency, *inputref; + XF86OptionPtr *options; + XF86ConfLayoutPtr lay = node->data->layout.layout; + + options = &(lay->lay_option_lst); + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, lay->lay_identifier, NULL, 0); + + command = XtVaCreateManagedWidget("Adjacency", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL, 0); + adjacency = NewNode(node, command, command, box, NULL); + node->child = adjacency; + CreateAdjacency(adjacency, lay->lay_adjacency_lst); + + command = XtVaCreateManagedWidget("Inputref", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL, 0); + inputref = NewNode(node, command, command, box, NULL); + adjacency->next = inputref; + CreateInputref(inputref, lay->lay_input_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewLayoutCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + NULL, 0); + node->data->layout.text = label; + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +LayoutDestroy(TreeNode *node) +{ + if (node->data->layout.layout) + xf86removeLayout(XF86Config, node->data->layout.layout); +} + +/*ARGSUSED*/ +static void +NewLayoutCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfLayoutPtr lay; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->layout.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + lay = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); + lay->lay_identifier = XtNewString(label); + XF86Config->conf_layout_lst = xf86addLayout(XF86Config->conf_layout_lst, lay); + + CreateLayout(parent, lay); + RelayoutTree(); +} + +static void +CreateAdjacency(TreeNode *parent, XF86ConfAdjacencyPtr adj) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (adj) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->adjacency.adjacency = adj; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = AdjacencyDestroy; + CreateAdjacencyField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateAdjacencyField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateAdjacencyField(TreeNode *node, Bool addnew) +{ + Widget box, command, label, sme; + XF86ConfScreenPtr ptr = XF86Config->conf_screen_lst; + + box = XtVaCreateWidget("adjacency", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + node->data->adjacency.menu = + XtVaCreatePopupShell("screenMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL, 0); + while (ptr) { + sme = XtCreateManagedWidget(ptr->scrn_identifier, smeBSBObjectClass, + node->data->adjacency.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, !addnew ? + AdjacencyMenuCallback : NewAdjacencyCallback, + (XtPointer)node); + ptr = (XF86ConfScreenPtr)(ptr->list.next); + } + + if (!addnew) { + char buf[32]; + Cardinal width, height; + Widget left, right, above, below, relative, absolute; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + label = XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, adj->adj_screen->scrn_identifier, + NULL, 0); + + XtCreateManagedWidget("scrnumL", labelWidgetClass, box, NULL, 0); + if (adj->adj_scrnum >= 0) + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_scrnum); + else + *buf = 0; + node->data->adjacency.scrnum = + XtVaCreateManagedWidget("scrnum", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + above = XtVaCreateManagedWidget("above", toggleWidgetClass, box, + XtNstate, adj->adj_where == CONF_ADJ_ABOVE ? + True : False, NULL, 0); + XtAddCallback(above, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + left = XtVaCreateManagedWidget("leftOf", toggleWidgetClass, box, + XtNradioGroup, above, + XtNstate, adj->adj_where == CONF_ADJ_LEFTOF ? + True : False, NULL, 0); + XtAddCallback(left, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + + node->data->adjacency.button = + XtVaCreateManagedWidget("screen", menuButtonWidgetClass, box, + XtNmenuName, "screenMenu", NULL, 0); + + right = XtVaCreateManagedWidget("rightOf", toggleWidgetClass, box, + XtNradioGroup, left, + XtNstate, adj->adj_where == CONF_ADJ_RIGHTOF ? + True : False, NULL, 0); + XtAddCallback(right, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + below = XtVaCreateManagedWidget("below", toggleWidgetClass, box, + XtNradioGroup, right, + XtNstate, adj->adj_where == CONF_ADJ_BELOW ? + True : False, NULL, 0); + XtAddCallback(below, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + relative = XtVaCreateManagedWidget("relative", toggleWidgetClass, box, + XtNradioGroup, below, + XtNstate, adj->adj_where == CONF_ADJ_RELATIVE ? + True : False, NULL, 0); + XtAddCallback(relative, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + absolute = XtVaCreateManagedWidget("absolute", toggleWidgetClass, box, + XtNradioGroup, relative, + XtNstate, adj->adj_where == CONF_ADJ_ABSOLUTE ? + True : False, NULL, 0); + XtAddCallback(absolute, XtNcallback, AdjacencyToggleCallback, (XtPointer)node); + + XtCreateManagedWidget("adjxL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_x); + node->data->adjacency.adjx = + XtVaCreateManagedWidget("adjx", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtCreateManagedWidget("adjyL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_y); + node->data->adjacency.adjy = + XtVaCreateManagedWidget("adjy", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, + XtNstring, buf, NULL, 0); + + XtVaGetValues(node->data->adjacency.button, XtNwidth, &width, + XtNheight, &height, NULL, 0); + if (adj->adj_where > CONF_ADJ_ABSOLUTE && + adj->adj_where <= CONF_ADJ_RELATIVE) + XtVaSetValues(node->data->adjacency.button, XtNlabel, + adj->adj_refscreen, XtNwidth, width, + XtNheight, height, NULL, 0); + else + XtVaSetValues(node->data->adjacency.button, XtNlabel, "", + XtNwidth, width, XtNheight, height, NULL, 0); + } + else + XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "screenMenu", NULL, 0); + + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +AdjacencyDestroy(TreeNode *node) +{ + if (node->data->adjacency.adjacency) + xf86removeAdjacency(node->parent->parent->data->layout.layout, + node->data->adjacency.adjacency); +} + +/*ARGSUSED*/ +static void +NewAdjacencyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = xf86findScreen(ident, XF86Config->conf_screen_lst); + parent->parent->data->layout.layout->lay_adjacency_lst = + xf86addAdjacency(parent->parent->data->layout.layout->lay_adjacency_lst, + adj); + + CreateAdjacency(parent, adj); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +AdjacencyMenuCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + + XtFree(adj->adj_refscreen); + adj->adj_refscreen = XtNewString(XtName(w)); + XtVaSetValues(node->data->adjacency.button, XtNlabel, XtName(w), NULL, 0); +} + +static void +AdjacencyToggleCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency; + char *x, *y; + + if ((Bool)call_data == False) + return; + + XtVaGetValues(node->data->adjacency.adjx, XtNstring, &x, NULL, 0); + XtVaGetValues(node->data->adjacency.adjy, XtNstring, &y, NULL, 0); + + adj->adj_x = atoi(x); + adj->adj_y = atoi(y); + + if (strcmp(XtName(w), "absolute") == 0) { + XtVaSetValues(node->data->adjacency.button, XtNlabel, "", NULL, 0); + adj->adj_where = CONF_ADJ_ABSOLUTE; + return; + } + if (strcmp(XtName(w), "relative") == 0) + adj->adj_where = CONF_ADJ_RELATIVE; + else if (strcmp(XtName(w), "leftOf") == 0) + adj->adj_where = CONF_ADJ_LEFTOF; + else if (strcmp(XtName(w), "rightOf") == 0) + adj->adj_where = CONF_ADJ_RIGHTOF; + else if (strcmp(XtName(w), "above") == 0) + adj->adj_where = CONF_ADJ_ABOVE; + else if (strcmp(XtName(w), "below") == 0) + adj->adj_where = CONF_ADJ_BELOW; +} + +/* Inputref */ +static void +CreateInputref(TreeNode *parent, XF86ConfInputrefPtr input) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (input) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->inputref.inputref = input; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = InputrefDestroy; + CreateInputrefField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + input = (XF86ConfInputrefPtr)(input->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateInputrefField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateInputrefField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("inputref", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfInputrefPtr inp = node->data->inputref.inputref; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(inp->iref_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, inp->iref_inputdev_str, NULL, 0); + } + else { + Widget sme; + XF86ConfInputPtr ptr = XF86Config->conf_input_lst; + + XtVaCreateManagedWidget("new", menuButtonWidgetClass, box, + XtNmenuName, "inputMenu", NULL, 0); + node->data->inputref.menu = + XtVaCreatePopupShell("inputMenu", simpleMenuWidgetClass, box, + XtNleftMargin, 1, XtNrightMargin, 1, + XtNtopMargin, 1, XtNbottomMargin, 1, + NULL, 0); + + while (ptr) { + sme = XtCreateManagedWidget(ptr->inp_identifier, smeBSBObjectClass, + node->data->inputref.menu, NULL, 0); + XtAddCallback(sme, XtNcallback, NewInputrefCallback, + (XtPointer)node); + ptr = (XF86ConfInputPtr)(ptr->list.next); + } + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGSUSED*/ +static void +NewInputrefCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfInputrefPtr input; + char *ident = XtName(w); + + parent = node->parent; + DeleteNode(node); + input = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + input->iref_inputdev_str = XtNewString(ident); + parent->parent->data->layout.layout->lay_input_lst = + xf86addInputref(parent->parent->data->layout.layout->lay_input_lst, input); + + CreateInputref(parent, input); + RelayoutTree(); +} + +/*ARGUSED*/ +static void +InputrefDestroy(TreeNode *node) +{ + if (node->data->inputref.inputref) + xf86removeInputRef(node->parent->parent->data->layout.layout, node->data->inputref.inputref->iref_inputdev); +} + +/* Vendor */ +static void +CreateVendor(TreeNode *parent, XF86ConfVendorPtr vendor) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (vendor) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->vendor.vendor = vendor; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VendorDestroy; + CreateVendorField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + vendor = (XF86ConfVendorPtr)(vendor->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVendorField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVendorField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("vendor", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + TreeNode *sub; + XF86OptionPtr *options; + XF86ConfVendorPtr vendor = node->data->vendor.vendor; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(vendor->vnd_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, vendor->vnd_identifier, NULL, 0); + + command = XtVaCreateManagedWidget("VendSub", toggleWidgetClass, tree, + XtNstate, True, + XtNtreeParent, box, + NULL, 0); + sub = NewNode(node, command, command, box, NULL); + node->child = sub; + CreateVendorSub(sub, vendor->vnd_sub_lst); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVendorCallback, (XtPointer)node); + node->data->vendor.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +VendorDestroy(TreeNode *node) +{ + if (node->data->vendor.vendor) + xf86removeVendor(XF86Config, node->data->vendor.vendor); +} + +static void +NewVendorCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVendorPtr vnd; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->vendor.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + vnd = (XF86ConfVendorPtr)XtCalloc(1, sizeof(XF86ConfVendorRec)); + vnd->vnd_identifier = XtNewString(label); + XF86Config->conf_vendor_lst = xf86addVendor(XF86Config->conf_vendor_lst, vnd); + + CreateVendor(parent, vnd); + RelayoutTree(); +} + +/* VendorSub */ +static void +CreateVendorSub(TreeNode *parent, XF86ConfVendSubPtr vendor) +{ + TreeNode *prev, *node; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (vendor) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->vendsub.vendsub = vendor; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = VendorSubDestroy; + node->update = VendorSubUpdate; + CreateVendorSubField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + vendor = (XF86ConfVendSubPtr)(vendor->list.next); + } + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + node = NewNode(parent, NULL, NULL, parent->node, data); + CreateVendorSubField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateVendorSubField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("vendorSub", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + XF86OptionPtr *options; + XF86ConfVendSubPtr vendor = node->data->vendsub.vendsub; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + options = &(vendor->vs_option_lst); + command = XtCreateManagedWidget("options", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options); + XtVaCreateManagedWidget("label", labelWidgetClass, box, + XtNlabel, vendor->vs_identifier, NULL, 0); + + XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0); + node->data->vendsub.text = + XtVaCreateManagedWidget("name", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + vendor->vs_name ? vendor->vs_name : "", + NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewVendorSubCallback, (XtPointer)node); + node->data->vendsub.text = + XtVaCreateManagedWidget("value", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, NULL, 0); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +VendorSubDestroy(TreeNode *node) +{ + if (node->data->vendsub.vendsub) + xf86removeVendorSub(node->parent->parent->data->vendor.vendor, + node->data->vendsub.vendsub); +} + +static void +VendorSubUpdate(TreeNode *node) +{ + char *str; + + XtVaGetValues(node->data->vendsub.text, XtNstring, &str, NULL, 0); + XtFree(node->data->vendsub.vendsub->vs_name); + if (*str) + node->data->vendsub.vendsub->vs_name = XtNewString(str); + else + node->data->vendsub.vendsub->vs_name = NULL; +} + +static void +NewVendorSubCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfVendSubPtr vnd; + Arg args[1]; + char *label; + + XtSetArg(args[0], XtNstring, &label); + XtGetValues(node->data->vendsub.text, args, 1); + if (*label == '\0') + return; + + parent = node->parent; + DeleteNode(node); + vnd = (XF86ConfVendSubPtr)XtCalloc(1, sizeof(XF86ConfVendSubRec)); + vnd->vs_identifier = XtNewString(label); + parent->parent->data->vendor.vendor->vnd_sub_lst = + xf86addVendorSub(parent->parent->data->vendor.vendor->vnd_sub_lst, vnd); + + CreateVendorSub(parent, vnd); + RelayoutTree(); +} + +/* DRI */ +static void +CreateDRI(TreeNode *parent, XF86ConfDRIPtr dri) +{ + TreeNode *node; + TreeData *data; + + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->dri.dri = dri; + node = NewNode(parent, NULL, NULL, parent->node, data); + parent->child = node; + node->update = DRIUpdate; + CreateDRIField(node); +} + +static void +CreateDRIField(TreeNode *node) +{ + Widget box, toggle; + XF86ConfDRIPtr dri = node->data->dri.dri; + TreeNode *buffers; + char buf[32]; + + box = XtVaCreateWidget("dri", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0); + node->data->dri.name = + XtVaCreateManagedWidget("name", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + dri->dri_group_name ? dri->dri_group_name : "", + NULL, 0); + + XtCreateManagedWidget("groupL", labelWidgetClass, box, NULL, 0); + if (dri->dri_group >= 0) + XmuSnprintf(buf, sizeof(buf), "%d", dri->dri_group); + else + *buf = '\0'; + node->data->dri.group = + XtVaCreateManagedWidget("group", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, buf, + NULL, 0); + + XtCreateManagedWidget("modeL", labelWidgetClass, box, NULL, 0); + if (dri->dri_mode > 0) + XmuSnprintf(buf, sizeof(buf), "0%o", dri->dri_mode); + else + *buf = '\0'; + node->data->dri.mode = + XtVaCreateManagedWidget("mode", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, buf, + NULL, 0); + + toggle = XtVaCreateManagedWidget("Buffers", toggleWidgetClass, tree, + XtNstate, True, XtNtreeParent, box, + NULL, 0); + buffers = NewNode(node, toggle, toggle, box, NULL); + node->child = buffers; + CreateBuffers(buffers, dri->dri_buffers_lst); + + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +static void +DRIUpdate(TreeNode *node) +{ + char *str; + + /* name */ + XtVaGetValues(node->data->dri.name, XtNstring, &str, NULL, 0); + XtFree(node->data->dri.dri->dri_group_name); + if (*str) + node->data->dri.dri->dri_group_name = XtNewString(str); + else + node->data->dri.dri->dri_group_name = NULL; + + /* group */ + XtVaGetValues(node->data->dri.group, XtNstring, &str, NULL, 0); + if (*str) + node->data->dri.dri->dri_group = atoi(str); + else + node->data->dri.dri->dri_group = -1; + + /* mode */ + XtVaGetValues(node->data->dri.mode, XtNstring, &str, NULL, 0); + node->data->dri.dri->dri_mode = strtoul(str, NULL, 0); +} + +/* Buffers */ +static void +CreateBuffers(TreeNode *parent, XF86ConfBuffersPtr buf) +{ + TreeNode *node, *prev; + TreeData *data; + + if ((prev = parent->child) != NULL) + while (prev->next) + prev = prev->next; + + while (buf) { + data = (TreeData*)XtCalloc(1, sizeof(TreeData)); + data->buffers.buffers = buf; + node = NewNode(parent, NULL, NULL, parent->node, data); + node->destroy = BuffersDestroy; + node->update = BuffersUpdate; + CreateBuffersField(node, False); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; + prev = node; + + buf = (XF86ConfBuffersPtr)(buf->list.next); + } + node = NewNode(parent, NULL, NULL, parent->node, NULL); + CreateBuffersField(node, True); + if (parent->child == NULL) + parent->child = node; + else + prev->next = node; +} + +static void +CreateBuffersField(TreeNode *node, Bool addnew) +{ + Widget box, command; + + box = XtVaCreateWidget("buffers", formWidgetClass, tree, + XtNtreeParent, node->treeParent, NULL, 0); + node->node = box; + + if (!addnew) { + char str[32]; + XF86ConfBuffersPtr buf = node->data->buffers.buffers; + + command = XtCreateManagedWidget("remove", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node); + + XtCreateManagedWidget("countL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(str, sizeof(str), "%d", buf->buf_count); + node->data->buffers.count = + XtVaCreateManagedWidget("count", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("sizeL", labelWidgetClass, box, NULL, 0); + XmuSnprintf(str, sizeof(str), "%d", buf->buf_size); + node->data->buffers.size = + XtVaCreateManagedWidget("size", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, str, + NULL, 0); + + XtCreateManagedWidget("flagsL", labelWidgetClass, box, NULL, 0); + node->data->buffers.flags = + XtVaCreateManagedWidget("flags", asciiTextWidgetClass, box, + XtNeditType, XawtextEdit, XtNstring, + buf->buf_flags ? buf->buf_flags : "", + NULL, 0); + } + else { + command = XtCreateManagedWidget("new", commandWidgetClass, box, + NULL, 0); + XtAddCallback(command, XtNcallback, NewBuffersCallback, (XtPointer)node); + } + if (XtIsRealized(node->treeParent)) + XtRealizeWidget(box); + XtManageChild(box); +} + +/*ARGUSED*/ +static void +BuffersDestroy(TreeNode *node) +{ + if (node->data->buffers.buffers) + xf86removeBuffers(XF86Config->conf_dri, node->data->buffers.buffers); +} + +/*ARGSUSED*/ +static void +NewBuffersCallback(Widget unused, XtPointer user_data, XtPointer call_data) +{ + TreeNode *parent, *node = (TreeNode*)user_data; + XF86ConfBuffersPtr buf; + + parent = node->parent; + DeleteNode(node); + buf = (XF86ConfBuffersPtr)XtCalloc(1, sizeof(XF86ConfBuffersRec)); + XF86Config->conf_dri->dri_buffers_lst = + xf86addBuffers(XF86Config->conf_dri->dri_buffers_lst, buf); + + CreateBuffers(parent, buf); + RelayoutTree(); +} + +static void +BuffersUpdate(TreeNode *node) +{ + char *str; + + /* count */ + XtVaGetValues(node->data->buffers.count, XtNstring, &str, NULL, 0); + node->data->buffers.buffers->buf_count = atoi(str); + + /* size */ + XtVaGetValues(node->data->buffers.size, XtNstring, &str, NULL, 0); + node->data->buffers.buffers->buf_size = atoi(str); + + /* flags */ + XtVaGetValues(node->data->buffers.flags, XtNstring, &str, NULL, 0); + if (*str) + node->data->buffers.buffers->buf_flags = XtNewString(str); + else + node->data->buffers.buffers->buf_flags = NULL; +} + +static TreeNode * +NewNode(TreeNode *parent, Widget node, Widget toggle, Widget treeParent, + TreeData *data) +{ + TreeNode *tree = (TreeNode*)XtCalloc(1, sizeof(TreeNode)); + + tree->parent = parent; + tree->node = node; + if ((tree->toggle = toggle) != NULL) + XtAddCallback(toggle, XtNcallback, ToggleCallback, (XtPointer)tree); + tree->treeParent = treeParent; + tree->data = data; + + return (tree); +} + +static void +DeleteNode(TreeNode *node) +{ + TreeNode *ptr = node->child; + + while (ptr != NULL) { + TreeNode *next = ptr->next; + + DeleteNode(ptr); + ptr = next; + } + + if (node->parent && node->parent->child == node) + node->parent->child = node->next; + else if (node->parent) { + for (ptr = node->parent->child; ptr && ptr->next != node; + ptr = ptr->next) + ; + if (ptr) + ptr->next = node->next; + } + + if (node->destroy) + (node->destroy)(node); + if (node->data) + XtFree((XtPointer)node->data); + + /* sets treeParent to NULL so that RelayoutTree works correctly, + * as the tree will properly calculate it's new size. + */ + XtVaSetValues(node->node, XtNtreeParent, NULL, NULL, 0); + + XtDestroyWidget(node->node); + XtFree((XtPointer)node); +} + +/*ARGUSED*/ +static void +DestroyCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *node = (TreeNode*)user_data; + + DeleteNode(node); + RelayoutTree(); +} + +static void +ToggleNodeRecursive(TreeNode *node) +{ + while (node) { + if (!XtIsRealized(node->node)) + XtRealizeWidget(node->node); + XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL, 0); + XtManageChild(node->node); + + if (node->child && !node->toggle) + ToggleNodeRecursive(node->child); + + node = node->next; + } +} + +static void +ToggleNode(TreeNode *node, Bool toggle) +{ + while (node) { + if (toggle) { + if (!XtIsRealized(node->node)) + XtRealizeWidget(node->node); + XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL, 0); + XtManageChild(node->node); + + if (node->child && !node->toggle) + ToggleNodeRecursive(node->child); + } + else { + if (node->child) + ToggleNode(node->child, False); + XtVaSetValues(node->node, XtNtreeParent, NULL, NULL, 0); + XtUnmanageChild(node->node); + if (node->toggle) + XtVaSetValues(node->toggle, XtNstate, False, NULL, 0); + } + node = node->next; + } +} + +/* + * XXX This callback can show side effects in the way it is called. If + * the structure holding the XF86OptionPtr is reallocated, a bogus pointer + * will be passed to this callback. + */ +static void +OptionsCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XF86OptionPtr *options = (XF86OptionPtr*)user_data; + +#ifdef USE_MODULES + OptionsPopup(options, NULL, NULL); +#else + OptionsPopup(options); +#endif +} + +static void +RelayoutTree(void) +{ + Arg args[4]; + Dimension sliderWidth, sliderHeight, canvasWidth, canvasHeight; + + XtSetArg(args[0], XtNwidth, &sliderWidth); + XtSetArg(args[1], XtNheight, &sliderHeight); + XtGetValues(shell, args, 2); + + XtSetArg(args[2], XtNwidth, &canvasWidth); + XtSetArg(args[3], XtNheight, &canvasHeight); + XtGetValues(tree, args + 2, 2); + + XtSetArg(args[0], XtNsliderWidth, sliderWidth); + XtSetArg(args[1], XtNsliderHeight, sliderHeight); + XtSetArg(args[2], XtNcanvasWidth, canvasWidth); + XtSetArg(args[3], XtNcanvasHeight, canvasHeight); + XtSetValues(panner, args, 4); +} + +static void +ToggleCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + TreeNode *nodeParent = (TreeNode*)user_data; + + if (nodeParent->child) { + if (XtIsRealized(tree)) + XtUnmapWidget(tree); + ToggleNode(nodeParent->child, (Bool)call_data); + RelayoutTree(); + if (XtIsRealized(tree)) + XtMapWidget(tree); + } +} + +/*ARGSUSED*/ +static void +PannerCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[2]; + XawPannerReport *rep = (XawPannerReport *)call_data; + + XtSetArg (args[0], XtNx, -rep->slider_x); + XtSetArg (args[1], XtNy, -rep->slider_y); + XtSetValues(tree, args, 2); +} + +/*ARGSUSED*/ +static void +PortholeCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + XawPannerReport *rep = (XawPannerReport*)call_data; + Arg args[6]; + Cardinal n = 2; + + XtSetArg (args[0], XtNsliderX, rep->slider_x); + XtSetArg (args[1], XtNsliderY, rep->slider_y); + if (rep->changed != (XawPRSliderX | XawPRSliderY)) { + XtSetArg (args[2], XtNsliderWidth, rep->slider_width); + XtSetArg (args[3], XtNsliderHeight, rep->slider_height); + XtSetArg (args[4], XtNcanvasWidth, rep->canvas_width); + XtSetArg (args[5], XtNcanvasHeight, rep->canvas_height); + n = 6; + } + XtSetValues(panner, args, n); +} + +static void +DestroyTree(TreeNode *node) +{ + while (node) { + TreeNode *next = node->next; + if (node->child) + DestroyTree(node->child); + + if (node->data) + XtFree((XtPointer)node->data); + XtFree((XtPointer)node); + + node = next; + } +} + +static void +UpdateConfig(TreeNode *node) +{ + while (node) { + if (node->child) + UpdateConfig(node->child); + if (node->update) + (node->update)(node); + node = node->next; + } +} + +static Bool +ExpertInitialize(void) +{ + Widget paned, vpane, close, config, files, modules, flags, video, modes, + monitor, device, screen, input, layout, vendor, dri; + Arg args[4]; + Dimension width, height, canvasWidth, canvasHeight; + TreeNode *node; + + if (expert != NULL) + return (False); + + shell = XtCreatePopupShell("Expert", transientShellWidgetClass, + toplevel, NULL, 0); + paned = XtVaCreateManagedWidget("paned", panedWidgetClass, shell, + XtNorientation, XtorientHorizontal, NULL, 0); + vpane = XtCreateManagedWidget("vpane", panedWidgetClass, paned, NULL, 0); + panner = XtCreateManagedWidget ("panner", pannerWidgetClass, vpane, NULL, 0); + close = XtCreateManagedWidget("close", commandWidgetClass, vpane, NULL, 0); + XtAddCallback(close, XtNcallback, PopdownCallback, NULL); + + expert = XtCreateManagedWidget("expert", portholeWidgetClass, paned, NULL, 0); + XtAddCallback(expert, XtNreportCallback, PortholeCallback, NULL); + XtAddCallback(panner, XtNreportCallback, PannerCallback, NULL); + tree = XtCreateManagedWidget("tree", treeWidgetClass, expert, NULL, 0); + + config = XtVaCreateManagedWidget("XF86Config", toggleWidgetClass, tree, + XtNstate, True, NULL, 0); + mainNode = NewNode(NULL, config, config, NULL, NULL); + + files = XtVaCreateManagedWidget("Files", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node = NewNode(mainNode, files, files, config, NULL); + mainNode->child = node; + CreateFiles(node); + + modules = XtVaCreateManagedWidget("Module", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, modules, modules, config, NULL); + node = node->next; + CreateModule(node, XF86Config->conf_modules ? + XF86Config->conf_modules->mod_load_lst : NULL); + + flags = XtVaCreateManagedWidget("ServerFlags", commandWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, flags, NULL, config, NULL); + node = node->next; + XtAddCallback(flags, XtNcallback, OptionsCallback, + (XtPointer)&(XF86Config->conf_flags->flg_option_lst)); + + video = XtVaCreateManagedWidget("VideoAdaptor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, video, video, config, NULL); + node = node->next; + CreateVideoAdaptor(node, XF86Config->conf_videoadaptor_lst); + + modes = XtVaCreateManagedWidget("Mode", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, modes, modes, config, NULL); + node = node->next; + CreateModes(node, XF86Config->conf_modes_lst); + + monitor = XtVaCreateManagedWidget("Monitor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, monitor, monitor, config, NULL); + node = node->next; + CreateMonitor(monitorTree = node, XF86Config->conf_monitor_lst); + + device = XtVaCreateManagedWidget("Device", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, device, device, config, NULL); + node = node->next; + CreateDevice(node, XF86Config->conf_device_lst); + + screen = XtVaCreateManagedWidget("Screen", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, screen, screen, config, NULL); + node = node->next; + CreateScreen(screenTree = node, XF86Config->conf_screen_lst); + + input = XtVaCreateManagedWidget("Input", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, input, input, config, NULL); + node = node->next; + CreateInput(node, XF86Config->conf_input_lst); + + layout = XtVaCreateManagedWidget("Layout", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, layout, layout, config, NULL); + node = node->next; + CreateLayout(layoutTree = node, XF86Config->conf_layout_lst); + + vendor = XtVaCreateManagedWidget("Vendor", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, vendor, vendor, config, NULL); + node = node->next; + CreateVendor(node, XF86Config->conf_vendor_lst); + + dri = XtVaCreateManagedWidget("DRI", toggleWidgetClass, tree, + XtNtreeParent, config, NULL, 0); + node->next = NewNode(mainNode, dri, dri, config, NULL); + node = node->next; + if (XF86Config->conf_dri == NULL) + XF86Config->conf_dri = (XF86ConfDRIPtr) + XtCalloc(1, sizeof(XF86ConfDRIRec)); + CreateDRI(node, XF86Config->conf_dri); + + XtRealizeWidget(shell); + + XtSetArg(args[0], XtNwidth, &width); + XtSetArg(args[1], XtNheight, &height); + XtGetValues(shell, args, 2); + XtSetArg(args[0], XtNwidth, width); + XtSetArg(args[1], XtNheight, height); + XtSetValues(expert, args, 2); + + XtSetArg(args[0], XtNsliderWidth, width); + XtSetArg(args[1], XtNsliderHeight, height); + XtSetArg(args[2], XtNwidth, &canvasWidth); + XtSetArg(args[3], XtNheight, &canvasHeight); + XtGetValues(tree, args + 2, 2); + XtSetArg(args[2], XtNcanvasWidth, canvasWidth); + XtSetArg(args[3], XtNcanvasHeight, canvasHeight); + XtSetValues(panner, args, 4); + + /* needs to do the apparently NOP code bellow to correctly layout the + * tree widget */ + + /* close all open entries */ + ToggleCallback(config, mainNode, (XtPointer)0); + /* open first level */ + ToggleCallback(config, mainNode, (XtPointer)1); + + XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); + + return (True); +} Index: xc/programs/Xserver/hw/xfree86/xf86cfg/help.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/help.c:1.1 xc/programs/Xserver/hw/xfree86/xf86cfg/help.c:1.3 --- xc/programs/Xserver/hw/xfree86/xf86cfg/help.c:1.1 Tue Jun 13 19:15:51 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/help.c Fri Oct 20 10:59:05 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/help.c,v 1.1 2000/06/13 23:15:51 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/help.c,v 1.3 2000/10/20 14:59:05 alanh Exp $ */ #include <X11/IntrinsicP.h> @@ -39,11 +39,13 @@ #include <X11/Xaw/Text.h> #include <X11/Xaw/TextSinkP.h> #include <X11/Xaw/TextSrcP.h> +#include <X11/Xmu/SysUtil.h> #include <X11/Xmu/Xmu.h> #ifndef X_NOT_STDC_ENV #include <stdlib.h> /* for bsearch() */ #endif #include <ctype.h> +#include "help.h" /* * Prototypes @@ -64,7 +66,7 @@ /* * Implementation */ -Bool +void Help(char *topic) { Widget source; @@ -256,7 +258,6 @@ /* * Proptotypes */ -void Html_ModeStart(Widget); void Html_ModeEnd(Widget); static void Html_ModeInit(void); static void Html_ParseCallback(Widget, XtPointer, XtPointer); @@ -269,7 +270,7 @@ static void Html_AddEntities(Html_Parser*, Html_Item*); static int Html_Put(Html_Parser*, int); -static char *Html_Puts(Html_Parser*, char*); +static void Html_Puts(Html_Parser*, char*); static int Html_Format1(Html_Parser*); static int Html_Format2(Html_Parser*); static int Html_Format3(Html_Parser*); @@ -737,7 +738,8 @@ position, length, Qli); else XawTextSourceAddEntity(parser->source, 0, /*XAW_TENT_LITEM,*/ - XAW_TENTF_HIDE, (XtPointer)head->li++, + XAW_TENTF_HIDE, + (XtPointer)(long)head->li++, position, length, Qli); } else if (quark == Qhide) @@ -1219,7 +1221,7 @@ return (ch); } -static char * +static void Html_Puts(Html_Parser *parser, char *str) { int len = strlen(str); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c:1.4 xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c:1.13 --- xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c:1.4 Wed Jun 14 17:57:57 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c Fri Dec 8 21:23:26 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c,v 1.4 2000/06/14 21:57:57 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c,v 1.13 2000/12/09 02:23:26 dawes Exp $ */ #include <X11/IntrinsicP.h> @@ -58,6 +58,7 @@ #include "options.h" #include "vidmode.h" #include "help.h" +#include "stubs.h" #define randomize() srand((unsigned)time((time_t*)NULL)) #define DefaultXFree86Dir "/usr/X11R6" @@ -91,6 +92,7 @@ void WriteConfigAction(Widget, XEvent*, String*, Cardinal*); static void ScreenSetup(Bool); void QuitAction(Widget, XEvent*, String*, Cardinal*); +void PopdownErrorCallback(Widget, XtPointer, XtPointer); static void ErrorCancelAction(Widget, XEvent*, String*, Cardinal*); static void QuitCancelAction(Widget, XEvent*, String*, Cardinal*); static void HelpCallback(Widget, XtPointer, XtPointer); @@ -99,6 +101,10 @@ extern void AccessXConfigureEnd(void); extern void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*); +#ifdef HAS_NCURSES +extern void TextMode(void); +#endif + /* * Initialization */ @@ -106,9 +112,18 @@ XtAppContext appcon; char *XF86Config_path = NULL; +char *XF86Module_path = NULL; +char *XFree86_path = NULL; +char *XF86Font_path = NULL; +char *XF86RGB_path = NULL; +char *XkbConfig_path = NULL; char *XFree86Dir; +static char XF86Config_path_static[1024]; +static char XkbConfig_path_static[1024]; Bool xf86config_set = False; +Bool textmode = False; + xf86cfgComputer computer; xf86cfgDevice cpu_device; Cursor no_cursor; @@ -144,6 +159,7 @@ {"accessx-close", CloseAccessXAction}, {"testmode-cancel", CancelTestModeAction}, {"help-close", HelpCancelAction}, + {"expert-close", ExpertCloseAction}, }; static char *device_names[] = { @@ -176,7 +192,7 @@ int main(int argc, char *argv[]) { - Widget pane, popup, mouse, keyboard, card, monitor; + Widget pane, hpane, expert, popup, mouse, keyboard, card, monitor; Widget bottom, sme, smemodeline, help, quit, layopt; XColor color, tmp; Pixmap pixmap; @@ -184,21 +200,50 @@ XF86ConfLayoutPtr lay; int i, startedx; +#ifdef USE_MODULES + xf86Verbose = 1; +#endif + if ((XFree86Dir = getenv("XWINHOME")) == NULL) XFree86Dir = DefaultXFree86Dir; chdir(XFree86Dir); - for (i = 1; i < argc; i++) + for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-xf86config") == 0) { if (i + 1 < argc) - XF86Config_path = argv[i + 1]; - break; + XF86Config_path = argv[++i]; + } else if (strcmp(argv[i], "-modulepath") == 0) { + if (i + 1 < argc) + XF86Module_path = argv[++i]; + } else if (strcmp(argv[i], "-serverpath") == 0) { + if (i + 1 < argc) + XFree86_path = argv[++i]; + } else if (strcmp(argv[i], "-fontpath") == 0) { + if (i + 1 < argc) + XF86Font_path = argv[++i]; + } else if (strcmp(argv[i], "-rgbpath") == 0) { + if (i + 1 < argc) + XF86RGB_path = argv[++i]; } +#ifdef HAS_NCURSES + else if (strcmp(argv[i], "-textmode") == 0) + textmode = True; +#endif + } +#ifdef HAS_NCURSES + if (textmode) { + TextMode(); + exit(0); + } +#endif + startedx = startx(); - if (XF86Config_path == NULL) - XF86Config_path = "/etc/X11/XF86Config"; +/* if (XF86Config_path == NULL) + XF86Config_path = "/etc/X11/XF86Config-4";*/ + if (XkbConfig_path == NULL) + XkbConfig_path = XkbConfigDir XkbConfigFile; toplevel = XtAppInitialize(&appcon, "XF86Cfg", /* optionDescList, XtNumber(optionDescList),*/ NULL, 0, @@ -221,8 +266,12 @@ pane = XtCreateManagedWidget("pane", panedWidgetClass, toplevel, NULL, 0); + hpane = XtVaCreateManagedWidget("hpane", panedWidgetClass, pane, + XtNorientation, XtorientHorizontal, NULL, 0); menu = XtCreateManagedWidget("topM", menuButtonWidgetClass, - pane, NULL, 0); + hpane, NULL, 0); + expert = XtCreateManagedWidget("expert", commandWidgetClass, hpane, NULL, 0); + XtAddCallback(expert, XtNcallback, ExpertCallback, NULL); popup = XtCreatePopupShell("menu", simpleMenuWidgetClass, menu, NULL, 0); sme = XtCreateManagedWidget("layout", smeBSBObjectClass, @@ -364,6 +413,10 @@ } } +#ifdef USE_MODULES + LoaderInitializeOptions(); +#endif + XtAppMainLoop(appcon); if (startedx) endx(); @@ -385,7 +438,7 @@ { asking_cf = 0; XtPopdown(shell_cf); - write_cf = (int)user_data; + write_cf = (long)user_data; } /*ARGSUSED*/ @@ -411,6 +464,7 @@ if (shell_cf == NULL) { Arg args[1]; char *l, *label; + int len; shell_cf = XtCreatePopupShell("quit", transientShellWidgetClass, toplevel, NULL, 0); @@ -423,8 +477,8 @@ XSetWMProtocols(DPY, XtWindow(shell_cf), &wm_delete_window, 1); XtSetArg(args[0], XtNlabel, &l); XtGetValues(dialog, args, 1); - label = XtMalloc(strlen(l) + 12); - strcpy(label, "XF86Config\n"); + label = XtMalloc(len = (strlen(l) + strlen(XF86CONFIG) + 1)); + XmuSnprintf(label, len, "%s\n", XF86CONFIG); strcat(label, l); XtSetArg(args[0], XtNlabel, label); XtSetValues(dialog, args, 1); @@ -439,13 +493,13 @@ XtGetValues(dialog, args, 1); switch (cf_state) { case CF_XF86Config: - str = "XF86Config"; + str = XF86CONFIG; XtSetArg(args[num_args], XtNvalue, XF86Config_path); ++num_args; break; case CF_XKBConfig: str = "XKB"; - XtSetArg(args[num_args], XtNvalue, XkbConfigDir XkbConfigFile); + XtSetArg(args[num_args], XtNvalue, XkbConfig_path); ++num_args; break; } @@ -468,8 +522,24 @@ while (asking_cf) XtAppProcessEvent(XtWidgetToApplicationContext(shell_cf), XtIMAll); - if (write_cf > 0) - XF86Config_path = XawDialogGetValueString(dialog); + if (write_cf > 0) { + switch (cf_state) { + case CF_XF86Config: + XF86Config_path = XawDialogGetValueString(dialog); + XmuSnprintf(XF86Config_path_static, + sizeof(XF86Config_path_static), + "%s", XF86Config_path); + XF86Config_path = XF86Config_path_static; + break; + case CF_XKBConfig: + XkbConfig_path = XawDialogGetValueString(dialog); + XmuSnprintf(XkbConfig_path_static, + sizeof(XkbConfig_path_static), + "%s", XkbConfig_path); + XkbConfig_path = XkbConfig_path_static; + break; + } + } return (write_cf); } @@ -508,9 +578,9 @@ break; case 1: if ((cf_state == CF_XF86Config && - !xf86WriteConfigFile(XF86Config_path, XF86Config)) || + !xf86writeConfigFile(XF86Config_path, XF86Config)) || (cf_state == CF_XKBConfig && - !WriteXKBConfiguration(XkbConfigDir XkbConfigFile, + !WriteXKBConfiguration(XkbConfig_path, &xkb_info->config))) { static Widget shell; @@ -846,13 +916,13 @@ do { ++num_layouts; XmuSnprintf(name, sizeof(name), "Layout%d", num_layouts); - } while (xf86FindLayout(name, + } while (xf86findLayout(name, XF86Config->conf_layout_lst) != NULL); l = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); l->lay_identifier = XtNewString(name); XF86Config->conf_layout_lst = - xf86AddLayout(XF86Config->conf_layout_lst, l); + xf86addLayout(XF86Config->conf_layout_lst, l); layoutsme = XtVaCreateManagedWidget("sme", smeBSBObjectClass, layoutp, XtNlabel, name, @@ -933,7 +1003,7 @@ XtGetValues(sme, args, 1); prev = XF86Config->conf_layout_lst; - lay = xf86FindLayout(str, prev); + lay = xf86findLayout(str, prev); if (prev == lay) return; @@ -982,7 +1052,7 @@ XtSetArg(args[0], XtNlabel, &str); XtGetValues(sme, args, 1); prev = XF86Config->conf_layout_lst; - lay = xf86FindLayout(str, prev); + lay = xf86findLayout(str, prev); tmp = prev; while (tmp != NULL) { if (tmp == lay) @@ -1024,7 +1094,7 @@ DrawCables(); } - xf86RemoveLayout(XF86Config, rem); + xf86removeLayout(XF86Config, rem); XtDestroyWidget(sme); } @@ -1136,7 +1206,7 @@ void AddDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) { - AddDevice((int)user_data, NULL, 6, 6); + AddDevice((long)user_data, NULL, 6, 6); } void @@ -1154,7 +1224,7 @@ if (mouse != NULL && computer.devices[i]->config == NULL) { XF86Config->conf_input_lst = - xf86AddInput(XF86Config->conf_input_lst, + xf86addInput(XF86Config->conf_input_lst, mouse); computer.devices[i]->config = (XtPointer)mouse; } @@ -1166,7 +1236,7 @@ if (keyboard != NULL && computer.devices[i]->config == NULL) { XF86Config->conf_input_lst = - xf86AddInput(XF86Config->conf_input_lst, + xf86addInput(XF86Config->conf_input_lst, keyboard); computer.devices[i]->config = (XtPointer)keyboard; } @@ -1178,7 +1248,7 @@ if (card != NULL && computer.devices[i]->config == NULL) { XF86Config->conf_device_lst = - xf86AddDevice(XF86Config->conf_device_lst, + xf86addDevice(XF86Config->conf_device_lst, card); computer.devices[i]->config = (XtPointer)card; } @@ -1193,7 +1263,7 @@ if (monitor != NULL && computer.devices[i]->config == NULL) { XF86Config->conf_monitor_lst = - xf86AddMonitor(XF86Config->conf_monitor_lst, + xf86addMonitor(XF86Config->conf_monitor_lst, monitor); computer.devices[i]->config = (XtPointer)monitor; } @@ -1221,6 +1291,9 @@ { int i; XF86OptionPtr *options; +#ifdef USE_MODULES + xf86cfgDriverOptions *drv_opts = NULL; +#endif if (config_mode == CONFIG_SCREEN) { for (i = 0; i < computer.num_screens; i++) @@ -1250,6 +1323,21 @@ case CARD: options = (XF86OptionPtr*)&(((XF86ConfDevicePtr) (computer.devices[i]->config))->dev_option_lst); +#ifdef USE_MODULES + { + char *drv = ((XF86ConfDevicePtr) + (computer.devices[i]->config))->dev_driver; + + if (drv) { + drv_opts = video_driver_info; + while (drv_opts) { + if (strcmp(drv_opts->name, drv) == 0) + break; + drv_opts = drv_opts->next; + } + } + } +#endif break; case MONITOR: options = (XF86OptionPtr*)&(((XF86ConfMonitorPtr) @@ -1259,13 +1347,18 @@ } } +#ifdef USE_MODULES + OptionsPopup(options, drv_opts ? drv_opts->name : NULL, + drv_opts ? drv_opts->option : NULL); +#else OptionsPopup(options); +#endif if (config_mode == CONFIG_SCREEN) { XF86OptionPtr option, options; int rotate; options = computer.screens[i]->screen->scrn_option_lst; - if ((option = xf86FindOption(options, "Rotate")) != NULL) { + if ((option = xf86findOption(options, "Rotate")) != NULL) { if (option->opt_val != NULL) rotate = strcasecmp(option->opt_val, "CW") == 0 ? 1 : strcasecmp(option->opt_val, "CCW") == 0 ? -1 : 0; @@ -1336,14 +1429,14 @@ nex->iref_inputdev = input; nex->iref_inputdev_str = XtNewString(input->inp_identifier); if (nmouses == 0 && computer.devices[i]->type == MOUSE) - option = xf86NewOption(XtNewString("CorePointer"), NULL); + option = xf86newOption(XtNewString("CorePointer"), NULL); else if (nkeyboards == 0 && computer.devices[i]->type == KEYBOARD) - option = xf86NewOption(XtNewString("CoreKeyboard"), NULL); + option = xf86newOption(XtNewString("CoreKeyboard"), NULL); else - option = xf86NewOption(XtNewString("SendCoreEvents"), NULL); + option = xf86newOption(XtNewString("SendCoreEvents"), NULL); nex->iref_option_lst = option; computer.layout->lay_input_lst = - xf86AddInputref(computer.layout->lay_input_lst, nex); + xf86addInputref(computer.layout->lay_input_lst, nex); } break; case CARD: for (i = 0; i < computer.num_screens; i++) { @@ -1357,7 +1450,7 @@ adj->adj_screen_str = XtNewString(computer.screens[i]-> screen->scrn_identifier); computer.layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr) - addListItem((GenericListPtr)computer.layout-> + xf86addListItem((GenericListPtr)computer.layout-> lay_adjacency_lst, (GenericListPtr)adj); computer.screens[i]->state = USED; } @@ -1396,7 +1489,7 @@ switch (computer.devices[i]->type) { case MOUSE: case KEYBOARD: - xf86RemoveInputRef(computer.layout, + xf86removeInputRef(computer.layout, (XF86ConfInputPtr)(computer.devices[i]->config)); break; case CARD: { @@ -1410,7 +1503,7 @@ adj = computer.layout->lay_adjacency_lst; while (adj != NULL) { if (adj->adj_screen == computer.screens[j]->screen) { - xf86RemoveAdjacency(computer.layout, adj); + xf86removeAdjacency(computer.layout, adj); break; } adj = (XF86ConfAdjacencyPtr)(adj->list.next); @@ -1424,48 +1517,26 @@ } } +/* ARGSUSED */ void RemoveDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data) { int i, j; - - if (config_mode == CONFIG_SCREEN) { - for (i = 0; i < computer.num_screens; i++) - if (computer.screens[i]->widget == config) { - xf86cfgDevice *mon, *dev; - - RemoveScreen(mon = computer.screens[i]->monitor, - dev = computer.screens[i]->card); - -/* - for (j = 0; j < computer.num_devices; j++) { - if (computer.devices[j] == mon || - computer.devices[j] == dev) { - if (--computer.devices[j]->refcount <= 0) { - XtDestroyWidget(computer.devices[j]->widget); - XtFree((XtPointer)computer.devices[j]); - if (--computer.num_devices > j) - memmove(&computer.devices[j], - &computer.devices[j + 1], - (computer.num_devices - j) * - sizeof(xf86cfgDevice*)); - --j; - } - } - } -*/ - ScreenSetup(False); - } - return; - } + for (i = 0; i < computer.num_screens; i++) + if (computer.screens[i]->widget == config) { + RemoveScreen(computer.screens[i]->monitor, + computer.screens[i]->card); + ScreenSetup(False); + return; + } for (i = 0; i < computer.num_devices; i++) { if (computer.devices[i]->widget == config) { switch (computer.devices[i]->type) { case MOUSE: case KEYBOARD: - xf86RemoveInput(XF86Config, + xf86removeInput(XF86Config, (XF86ConfInputPtr)(computer.devices[i]->config)); break; case CARD: @@ -1481,7 +1552,7 @@ --j; } if (computer.devices[i]->refcount <= 0) - xf86RemoveDevice(XF86Config, + xf86removeDevice(XF86Config, (XF86ConfDevicePtr)(computer.devices[i]->config)); } else if (computer.devices[i]->type == MONITOR) { @@ -1492,7 +1563,7 @@ --j; } if (computer.devices[i]->refcount <= 0) - xf86RemoveMonitor(XF86Config, + xf86removeMonitor(XF86Config, (XF86ConfMonitorPtr)(computer.devices[i]->config)); } @@ -1702,7 +1773,7 @@ XtSetArg(args[0], XtNlabel, name); XtSetValues(layoutsme, args, 1); - xf86RenameLayout(XF86Config, computer.layout, name); + xf86renameLayout(XF86Config, computer.layout, name); } /*ARGSUSED*/ @@ -1770,7 +1841,7 @@ void SetConfigModeCallback(Widget w, XtPointer user_data, XtPointer call_data) { - int i, mode = (int)user_data; + int i, mode = (long)user_data; Arg args[3]; char *ptr; static Dimension height; Index: xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c:1.5 xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c:1.10 --- xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c:1.5 Tue Jun 20 01:08:50 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c Mon Dec 11 13:47:46 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c,v 1.5 2000/06/20 05:08:50 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c,v 1.10 2000/12/11 18:47:46 paulo Exp $ */ #include "xf86config.h" @@ -54,7 +54,11 @@ static XF86XkbDescInfo xkb_layout; static XF86XkbDescInfo xkb_variant; static XF86XkbDescInfo xkb_option; +#ifdef XFREE98_XKB +static char *XkbRulesFile = "lib/X11/xkb/rules/xfree98"; +#else static char *XkbRulesFile = "lib/X11/xkb/rules/xfree86"; +#endif static XF86ConfInputPtr current_input; static char *model, *layout; @@ -144,11 +148,11 @@ current_input = keyboard; if (keyboard != NULL) { - if ((option = xf86FindOption(keyboard->inp_option_lst, XkbModel)) != NULL) + if ((option = xf86findOption(keyboard->inp_option_lst, XkbModel)) != NULL) xkb_info->defs.model = model = option->opt_val; else xkb_info->defs.model = model = xkb_model.name[0]; - if ((option = xf86FindOption(keyboard->inp_option_lst, XkbLayout)) != NULL) + if ((option = xf86findOption(keyboard->inp_option_lst, XkbLayout)) != NULL) xkb_info->defs.layout = layout = option->opt_val; else xkb_info->defs.layout = layout = xkb_layout.name[0]; @@ -172,7 +176,7 @@ ++nkeyboards; XmuSnprintf(keyboard_name, sizeof(keyboard_name), "Keyboard%d", nkeyboards); - } while (xf86FindInput(keyboard_name, + } while (xf86findInput(keyboard_name, XF86Config->conf_input_lst)); model = xkb_model.name[0]; @@ -194,7 +198,7 @@ keyboard->list.next = NULL; keyboard->inp_identifier = XtNewString(ident_string); keyboard->inp_driver = XtNewString("keyboard"); - keyboard->inp_option_lst = xf86NewOption(XtNewString(XkbModel), + keyboard->inp_option_lst = xf86newOption(XtNewString(XkbModel), XtNewString(model)); xf86addNewOption(keyboard->inp_option_lst, XtNewString(XkbLayout), XtNewString(layout)); @@ -220,37 +224,37 @@ break; } - if ((option = xf86FindOption(keyboard->inp_option_lst, XkbModel)) + if ((option = xf86findOption(keyboard->inp_option_lst, XkbModel)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(model); XtFree(option->opt_comment); } -/* else { + else { if (keyboard->inp_option_lst == NULL) - keyboard->inp_option_lst = xf86NewOption(XtNewString(XkbModel), + keyboard->inp_option_lst = xf86newOption(XtNewString(XkbModel), XtNewString(model)); else xf86addNewOption(keyboard->inp_option_lst, XtNewString(XkbModel), XtNewString(model)); - }*/ + } XtFree(xkb_info->config.model); xkb_info->config.model = XtNewString(model); - if ((option = xf86FindOption(keyboard->inp_option_lst, XkbLayout)) + if ((option = xf86findOption(keyboard->inp_option_lst, XkbLayout)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(layout); XtFree(option->opt_comment); } - /*else + else xf86addNewOption(keyboard->inp_option_lst, - XtNewString(XkbLayout), XtNewString(layout));*/ + XtNewString(XkbLayout), XtNewString(layout)); XtFree(xkb_info->config.layout); xkb_info->config.layout = XtNewString(layout); } if (strcasecmp(keyboard->inp_identifier, ident_string)) - xf86RenameInput(XF86Config, keyboard, ident_string); + xf86renameInput(XF86Config, keyboard, ident_string); xkb_info->conf = keyboard; return ((XtPointer)keyboard); @@ -326,7 +330,7 @@ exit(1); } - xkb_info = XtNew(XkbInfo); + xkb_info = (XkbInfo *)XtCalloc(1, sizeof(XkbInfo)); xkb_info->conf = NULL; xkb_infos = (XkbInfo**)XtCalloc(1, sizeof(XkbInfo*)); num_xkb_infos = 1; @@ -434,7 +438,7 @@ if (xkb_info->config.model != NULL) xkb_info->defs.model = xkb_info->config.model; - else if ((option = xf86FindOption(keyboard->inp_option_lst, "XkbModel")) + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbModel")) != NULL) xkb_info->defs.model = option->opt_val; else @@ -442,7 +446,7 @@ if (xkb_info->config.layout != NULL) xkb_info->defs.layout = xkb_info->config.layout; - else if ((option = xf86FindOption(keyboard->inp_option_lst, "XkbLayout")) + else if ((option = xf86findOption(keyboard->inp_option_lst, "XkbLayout")) != NULL) xkb_info->defs.layout = option->opt_val; else @@ -498,10 +502,10 @@ fprintf(fp, "Rules = %s\n", conf->rules_file); if (conf->model != NULL) - fprintf(fp, "Model = %s\n", + fprintf(fp, "Model = \"%s\"\n", conf->model); if (conf->layout != NULL) - fprintf(fp, "Layout = %s\n", + fprintf(fp, "Layout = \"%s\"\n", conf->layout); if (conf->variant != NULL) fprintf(fp, "Variant = %s\n", @@ -568,6 +572,9 @@ if (conf->mk_time_to_max > 0) fprintf(fp, "MouseKeysTimeToMax = %d\n", conf->mk_time_to_max); + if (conf->mk_max_speed > 0) + fprintf(fp, "MouseKeysMaxSpeed = %d\n", + conf->mk_max_speed); fprintf(fp, "MouseKeysCurve = %d\n", conf->mk_curve); fprintf(fp, "AccessXTimeout = %d\n", conf->ax_timeout); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c:1.3 --- /dev/null Mon Dec 18 14:32:29 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c Fri Dec 1 13:31:07 2000 @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.3 2000/12/01 18:31:07 paulo Exp $ + */ +#define LOADER_PRIVATE +#include "loader.h" + +/* XXX beware (or fix it) libc functions called here are the xf86 ones */ + +#ifdef USE_MODULES +void xf86AddDriver(DriverPtr, void*, int); +Bool xf86ServerIsOnlyDetecting(void); + +xf86cfgDriverOptions *video_driver_info; + +int xf86ShowUnresolved = 1; + +LOOKUP miLookupTab[] = {{0,0}}; +LOOKUP dixLookupTab[] = {{0,0}}; +LOOKUP fontLookupTab[] = {{0,0}}; +LOOKUP extLookupTab[] = {{0,0}}; +LOOKUP xfree86LookupTab[] = { + /* Loader functions */ + SYMFUNC(LoaderDefaultFunc) + SYMFUNC(LoadSubModule) + SYMFUNC(DuplicateModule) + SYMFUNC(LoaderErrorMsg) + SYMFUNC(LoaderCheckUnresolved) + SYMFUNC(LoadExtension) + SYMFUNC(LoadFont) + SYMFUNC(LoaderReqSymbols) + SYMFUNC(LoaderReqSymLists) + SYMFUNC(LoaderRefSymbols) + SYMFUNC(LoaderRefSymLists) + SYMFUNC(UnloadSubModule) + SYMFUNC(LoaderSymbol) + SYMFUNC(LoaderListDirs) + SYMFUNC(LoaderFreeDirList) + SYMFUNC(LoaderGetOS) + + /* + * these here are our own interfaces to libc functions + */ + SYMFUNC(xf86abort) + SYMFUNC(xf86abs) + SYMFUNC(xf86acos) + SYMFUNC(xf86asin) + SYMFUNC(xf86atan) + SYMFUNC(xf86atan2) + SYMFUNC(xf86atof) + SYMFUNC(xf86atoi) + SYMFUNC(xf86atol) + SYMFUNC(xf86bsearch) + SYMFUNC(xf86ceil) + SYMFUNC(xf86calloc) + SYMFUNC(xf86clearerr) + SYMFUNC(xf86close) + SYMFUNC(xf86cos) + SYMFUNC(xf86exit) + SYMFUNC(xf86exp) + SYMFUNC(xf86fabs) + SYMFUNC(xf86fclose) + SYMFUNC(xf86feof) + SYMFUNC(xf86ferror) + SYMFUNC(xf86fflush) + SYMFUNC(xf86fgetc) + SYMFUNC(xf86fgetpos) + SYMFUNC(xf86fgets) + SYMFUNC(xf86floor) + SYMFUNC(xf86fmod) + SYMFUNC(xf86fopen) + SYMFUNC(xf86fprintf) + SYMFUNC(xf86fputc) + SYMFUNC(xf86fputs) + SYMFUNC(xf86fread) + SYMFUNC(xf86free) + SYMFUNC(xf86freopen) + SYMFUNC(xf86frexp) + SYMFUNC(xf86fscanf) + SYMFUNC(xf86fseek) + SYMFUNC(xf86fsetpos) + SYMFUNC(xf86ftell) + SYMFUNC(xf86fwrite) + SYMFUNC(xf86getc) + SYMFUNC(xf86getenv) + SYMFUNC(xf86getpagesize) + SYMFUNC(xf86hypot) + SYMFUNC(xf86ioctl) + SYMFUNC(xf86isalnum) + SYMFUNC(xf86isalpha) + SYMFUNC(xf86iscntrl) + SYMFUNC(xf86isdigit) + SYMFUNC(xf86isgraph) + SYMFUNC(xf86islower) + SYMFUNC(xf86isprint) + SYMFUNC(xf86ispunct) + SYMFUNC(xf86isspace) + SYMFUNC(xf86isupper) + SYMFUNC(xf86isxdigit) + SYMFUNC(xf86labs) + SYMFUNC(xf86ldexp) + SYMFUNC(xf86log) + SYMFUNC(xf86log10) + SYMFUNC(xf86lseek) + SYMFUNC(xf86malloc) + SYMFUNC(xf86memchr) + SYMFUNC(xf86memcmp) + SYMFUNC(xf86memcpy) +#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__ia64__) + /* + * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle + * structure copies. This causes a problem both here and in shared + * libraries as there is no way to map the name of the call to the + * correct function. + */ + SYMFUNC(memcpy) + /* + * Some PPC, SPARC, and IA64 compilers generate calls to memset to handle + * aggregate initializations. + */ + SYMFUNC(memset) +#endif + SYMFUNC(xf86memmove) + SYMFUNC(xf86memset) + SYMFUNC(xf86mmap) + SYMFUNC(xf86modf) + SYMFUNC(xf86munmap) + SYMFUNC(xf86open) + SYMFUNC(xf86perror) + SYMFUNC(xf86pow) + SYMFUNC(xf86printf) + SYMFUNC(xf86qsort) + SYMFUNC(xf86read) + SYMFUNC(xf86realloc) + SYMFUNC(xf86remove) + SYMFUNC(xf86rename) + SYMFUNC(xf86rewind) + SYMFUNC(xf86setbuf) + SYMFUNC(xf86setvbuf) + SYMFUNC(xf86sin) + SYMFUNC(xf86snprintf) + SYMFUNC(xf86sprintf) + SYMFUNC(xf86sqrt) + SYMFUNC(xf86sscanf) + SYMFUNC(xf86strcat) + SYMFUNC(xf86strcmp) + SYMFUNC(xf86strcasecmp) + SYMFUNC(xf86strcpy) + SYMFUNC(xf86strcspn) + SYMFUNC(xf86strerror) + SYMFUNC(xf86strlen) + SYMFUNC(xf86strncmp) + SYMFUNC(xf86strncasecmp) + SYMFUNC(xf86strncpy) + SYMFUNC(xf86strpbrk) + SYMFUNC(xf86strchr) + SYMFUNC(xf86strrchr) + SYMFUNC(xf86strspn) + SYMFUNC(xf86strstr) + SYMFUNC(xf86strtod) + SYMFUNC(xf86strtok) + SYMFUNC(xf86strtol) + SYMFUNC(xf86strtoul) + SYMFUNC(xf86tan) + SYMFUNC(xf86tmpfile) + SYMFUNC(xf86tolower) + SYMFUNC(xf86toupper) + SYMFUNC(xf86ungetc) + SYMFUNC(xf86vfprintf) + SYMFUNC(xf86vsnprintf) + SYMFUNC(xf86vsprintf) + SYMFUNC(xf86write) + +/* non-ANSI C functions */ + SYMFUNC(xf86opendir) + SYMFUNC(xf86closedir) + SYMFUNC(xf86readdir) + SYMFUNC(xf86rewinddir) + SYMFUNC(xf86ffs) + SYMFUNC(xf86strdup) + SYMFUNC(xf86bzero) + SYMFUNC(xf86usleep) + SYMFUNC(xf86execl) + + SYMFUNC(xf86getsecs) + SYMFUNC(xf86fpossize) /* for returning sizeof(fpos_t) */ + + SYMFUNC(xf86stat) + SYMFUNC(xf86fstat) + SYMFUNC(xf86access) + SYMFUNC(xf86geteuid) + SYMFUNC(xf86getegid) + SYMFUNC(xf86getpid) + SYMFUNC(xf86mknod) + SYMFUNC(xf86chmod) + SYMFUNC(xf86chown) + SYMFUNC(xf86sleep) + SYMFUNC(xf86mkdir) + SYMFUNC(xf86shmget) + SYMFUNC(xf86shmat) + SYMFUNC(xf86shmdt) + SYMFUNC(xf86shmctl) + SYMFUNC(xf86setjmp) + SYMFUNC(xf86longjmp) + + SYMFUNC(xf86AddDriver) + SYMFUNC(xf86ServerIsOnlyDetecting) + {0,0} +}; + +static DriverPtr driver; + +Bool +LoaderInitializeOptions(void) +{ + static int first = 1; + static char *path = NULL, *modules = "lib/modules"; + int saveVerbose = xf86Verbose; + + if (first) { + xf86Verbose = 10; + LoaderInit(); + first = 0; + } + xf86Verbose = saveVerbose; + + if (XF86Module_path == NULL) { + XF86Module_path = XtMalloc(strlen(XFree86Dir) + strlen(modules) + 2); + sprintf(XF86Module_path, "%s/%s", XFree86Dir, modules); + } + if (path == NULL || strcmp(XF86Module_path, path)) { + char **list, **l; + const char *subdirs[] = { + "drivers", + NULL + }; + int errmaj, errmin; + ModuleDescPtr module; + + path = strdup(XF86Module_path); + LoaderSetPath(path); + + list = LoaderListDirs(subdirs, NULL); + if (list) { + xf86cfgDriverOptions *prev, *ptr = video_driver_info; + + if (ptr) { + while (video_driver_info) { + video_driver_info = video_driver_info->next; + XtFree(ptr->name); + XtFree((XtPointer)ptr->option); + XtFree((XtPointer)ptr); + ptr = video_driver_info; + } + } + + for (l = list; *l; l++) { + driver = NULL; + xf86Verbose = 0; + if ((module = LoadModule(*l, NULL, NULL, NULL, NULL, + NULL, &errmaj, &errmin)) == NULL) + LoaderErrorMsg(NULL, *l, errmaj, errmin); + else if (driver && driver->AvailableOptions) { + OptionInfoPtr tmp, + option = (*driver->AvailableOptions)(-1, -1); + + ptr = XtNew(xf86cfgDriverOptions); + ptr->name = XtNewString(*l); + if (option) { + int count; + + for (count = 0, tmp = option; tmp->name != NULL; tmp++, count++) + ; + ++count; + ptr->option = (XtPointer)XtCalloc(1, count * + sizeof(OptionInfoRec)); + for (count = 0, tmp = option; tmp->name != NULL; + count++, tmp++) { + memcpy(&ptr->option[count], tmp, + sizeof(OptionInfoRec)); + ptr->option[count].name = + XtNewString(tmp->name); + if (tmp->type == OPTV_STRING || + tmp->type == OPTV_ANYSTR) + ptr->option[count].value.str = + XtNewString(tmp->value.str); + } + } + else + ptr->option = NULL; + ptr->next = NULL; + if (video_driver_info == NULL) + video_driver_info = ptr; + else + prev->next = ptr; + prev = ptr; + + UnloadModule(module); + } + xf86Verbose = saveVerbose; + } + LoaderFreeDirList(list); + } + else { + xf86Verbose = saveVerbose; + return (False); + } + } + + xf86Verbose = saveVerbose; + + return (True); +} + +void +xf86AddDriver(DriverPtr drv, void *module, int flags) +{ + driver = drv; +} + +Bool +xf86ServerIsOnlyDetecting(void) +{ + return (True); +} +#endif Index: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h:1.1 --- /dev/null Mon Dec 18 14:32:29 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h Fri Oct 20 10:59:05 2000 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.h,v 1.1 2000/10/20 14:59:05 alanh Exp $ + */ +#ifdef USE_MODULES +#include "config.h" +#include "stubs.h" + +#ifndef _xf86cfg_loader_h +#define _xf86cfg_loader_h + +#ifdef LOADER_PRIVATE +#include <sym.h> + +#define XFree86LOADER /* not really */ +#include <xf86_ansic.h> + +/* common/xf86Module.h */ +pointer LoadModule(const char *, const char *, const char **, + const char **, pointer, const pointer *, + int *, int *); +pointer LoadSubModule(pointer, const char *, const char **, + const char **, pointer, const pointer *, + int *, int *); +void UnloadSubModule(pointer); +void LoadFont(pointer); +void UnloadModule (pointer); +pointer LoaderSymbol(const char *); +char **LoaderListDirs(const char **, const char **); +void LoaderFreeDirList(char **); +void LoaderErrorMsg(const char *, const char *, int, int); +void LoadExtension(pointer, Bool); +void LoaderRefSymLists(const char **, ...); +void LoaderRefSymbols(const char *, ...); +void LoaderReqSymLists(const char **, ...); +void LoaderReqSymbols(const char *, ...); +int LoaderCheckUnresolved(int); +void LoaderGetOS(const char **name, int *major, int *minor, int *teeny); + +typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *); +typedef void (*ModuleTearDownProc)(pointer); + +/* loader/loader.h */ +void LoaderDefaultFunc(void); + +/* loader/loaderProcs.h */ +typedef struct module_desc { + struct module_desc *child; + struct module_desc *sib; + struct module_desc *parent; + struct module_desc *demand_next; + char *name; + char *filename; + char *identifier; + XID client_id; + int in_use; + int handle; + ModuleSetupProc SetupProc; + ModuleTearDownProc TearDownProc; + void *TearDownData; /* returned from SetupProc */ + const char *path; +} ModuleDesc, *ModuleDescPtr; + +void LoaderInit(void); + +ModuleDescPtr LoadDriver(const char *, const char *, int, pointer, int *, + int *); +ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent); +void UnloadDriver (ModuleDescPtr); +void FreeModuleDesc (ModuleDescPtr mod); +ModuleDescPtr NewModuleDesc (const char *); +ModuleDescPtr AddSibling (ModuleDescPtr head, ModuleDescPtr new); +void LoaderSetPath(const char *path); +void LoaderSortExtensions(void); +#endif /* LOADER_PRIVATE */ + +/* common/xf86Opt.h */ +typedef struct { + double freq; + int units; +} OptFrequency; + +typedef union { + unsigned long num; + char * str; + double realnum; + Bool bool; + OptFrequency freq; +} ValueUnion; + +typedef enum { + OPTV_NONE = 0, + OPTV_INTEGER, + OPTV_STRING, /* a non-empty string */ + OPTV_ANYSTR, /* Any string, including an empty one */ + OPTV_REAL, + OPTV_BOOLEAN, + OPTV_FREQ +} OptionValueType; + +typedef enum { + OPTUNITS_HZ = 1, + OPTUNITS_KHZ, + OPTUNITS_MHZ +} OptFreqUnits; + +typedef struct { + int token; + const char* name; + OptionValueType type; + ValueUnion value; + Bool found; +} OptionInfoRec, *OptionInfoPtr; + +#ifdef LOADER_PRIVATE +/* common/xf86str.h */ +typedef struct _DriverRec { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + OptionInfoPtr (*AvailableOptions)(int chipid, int bustype); + void * module; + int refCount; +} DriverRec, *DriverPtr; +#endif /* LOADER_PRIVATE */ + +typedef struct _xf86cfgDriverOptions { + char *name; + OptionInfoPtr option; + struct _xf86cfgDriverOptions *next; +} xf86cfgDriverOptions; + +extern xf86cfgDriverOptions *video_driver_info; + +Bool LoaderInitializeOptions(void); +#endif /* USE_MODULES */ + +#endif /* _xf86cfg_loader_h */ Index: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c Thu Nov 30 15:55:18 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c,v 1.4 2000/11/30 20:55:18 paulo Exp $ */ #include "xf86config.h" @@ -52,10 +52,6 @@ static void MonitorHsyncCallback(Widget, XtPointer, XtPointer); static void MonitorVsyncCallback(Widget, XtPointer, XtPointer); static void MonitorSelectCardCallback(Widget, XtPointer, XtPointer); -static int string_to_parser_range(char*, parser_range*, int); -#define PARSER_RANGE_SIZE 256 -/* string must have at least 256 bytes */ -static int parser_range_to_string(char*, parser_range*, int); extern void DrawCables(void); @@ -173,7 +169,7 @@ ++nmonitors; XmuSnprintf(monitor_name, sizeof(monitor_name), "Monitor%d", nmonitors); - } while (xf86FindMonitor(monitor_name, + } while (xf86findMonitor(monitor_name, XF86Config->conf_monitor_lst)); XtSetArg(args[0], XtNstring, monitor_name); @@ -200,7 +196,7 @@ (monitor->mon_n_vrefresh = mon_n_vrefresh)); if (strcasecmp(monitor->mon_identifier, ident_string)) - xf86RenameMonitor(XF86Config, monitor, ident_string); + xf86renameMonitor(XF86Config, monitor, ident_string); if (oldcard != card) { int i; @@ -210,7 +206,7 @@ break; if (computer.devices[i]->config == NULL) XF86Config->conf_monitor_lst = - xf86AddMonitor(XF86Config->conf_monitor_lst, + xf86addMonitor(XF86Config->conf_monitor_lst, monitor); computer.devices[i]->config = (XtPointer)monitor; ChangeScreen(monitor, monitor, card, oldcard); @@ -258,7 +254,7 @@ return (True); } -static int +int string_to_parser_range(char *str, parser_range *range, int nrange) { double val; @@ -295,7 +291,7 @@ return (i); } -static int +int parser_range_to_string(char *str, parser_range *range, int nrange) { int i, len; Index: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h:1.3 --- xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h Thu Nov 30 15:55:18 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h,v 1.3 2000/11/30 20:55:18 paulo Exp $ */ #include "config.h" @@ -40,5 +40,9 @@ XtPointer MonitorConfig(XtPointer); void MonitorLayout(XF86SetupInfo*); void MonitorVidtune(XF86SetupInfo*); +int string_to_parser_range(char*, parser_range*, int); +#define PARSER_RANGE_SIZE 256 +/* string must have at least 256 bytes */ +int parser_range_to_string(char*, parser_range*, int); #endif /* _xf86cfg_monitor_h */ Index: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c:1.5 --- xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c Fri Oct 20 10:59:06 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c,v 1.5 2000/10/20 14:59:06 alanh Exp $ */ #include "xf86config.h" @@ -40,7 +40,7 @@ #include <X11/extensions/xf86misc.h> /* - * Prootypes + * Prototypes */ static void MouseDeviceCallback(Widget, XtPointer, XtPointer); static void MouseProtocolCallback(Widget, XtPointer, XtPointer); @@ -91,13 +91,13 @@ current_input = mouse; if (mouse != NULL) { - emulate = xf86FindOption(mouse->inp_option_lst, + emulate = xf86findOption(mouse->inp_option_lst, Emulate3Buttons) != NULL; - if ((option = xf86FindOption(mouse->inp_option_lst, Device)) != NULL) + if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) device = option->opt_val; else device = NULL; - if ((option = xf86FindOption(mouse->inp_option_lst, Protocol)) != NULL) + if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) protocol = option->opt_val; else protocol = NULL; @@ -117,7 +117,7 @@ do { ++nmouses; XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", nmouses); - } while (xf86FindInput(mouse_name, + } while (xf86findInput(mouse_name, XF86Config->conf_input_lst)); XtSetArg(args[0], XtNstring, mouse_name); @@ -143,7 +143,7 @@ mouse->list.next = NULL; mouse->inp_identifier = XtNewString(ident_string); mouse->inp_driver = XtNewString("mouse"); - mouse->inp_option_lst = xf86NewOption(XtNewString(Device), + mouse->inp_option_lst = xf86newOption(XtNewString(Device), XtNewString(device)); xf86addNewOption(mouse->inp_option_lst, XtNewString(Protocol), XtNewString(protocol)); @@ -157,32 +157,32 @@ mouse->inp_comment = NULL; } else { - if ((option = xf86FindOption(mouse->inp_option_lst, Device)) != NULL) { + if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(device); -/* XtFree(option->opt_comment);*/ + XtFree(option->opt_comment); } else { if (mouse->inp_option_lst == NULL) - mouse->inp_option_lst = xf86NewOption(XtNewString(Device), + mouse->inp_option_lst = xf86newOption(XtNewString(Device), XtNewString(device)); else xf86addNewOption(mouse->inp_option_lst, XtNewString(Device), XtNewString(device)); } - if ((option = xf86FindOption(mouse->inp_option_lst, Protocol)) != NULL) { + if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(protocol); -/* XtFree(option->opt_comment);*/ + XtFree(option->opt_comment); } else xf86addNewOption(mouse->inp_option_lst, XtNewString(Protocol), XtNewString(protocol)); if (emulate == False) { - xf86RemoveOption(&(mouse->inp_option_lst), Emulate3Buttons); - xf86RemoveOption(&(mouse->inp_option_lst), Emulate3Timeout); + xf86removeOption(&(mouse->inp_option_lst), Emulate3Buttons); + xf86removeOption(&(mouse->inp_option_lst), Emulate3Timeout); } else if (emulate) { xf86addNewOption(mouse->inp_option_lst, @@ -192,7 +192,7 @@ } } if (strcasecmp(mouse->inp_identifier, ident_string)) - xf86RenameInput(XF86Config, mouse, ident_string); + xf86renameInput(XF86Config, mouse, ident_string); return ((XtPointer)mouse); } @@ -244,10 +244,9 @@ static void MouseEmulateCallback(Widget w, XtPointer user_data, XtPointer call_data) { - emulate = (Bool)call_data; + emulate = (Bool)(long)call_data; } -/* This function does not yet work in 4.0 */ static void MouseApplyCallback(Widget w, XtPointer user_data, XtPointer call_data) { @@ -256,6 +255,10 @@ XF86MiscGetMouseSettings(XtDisplay(w), &mouse); XtFree(mouse.device); + if (mouse.baudrate == 0 || mouse.baudrate < 0 || mouse.baudrate > 9600 || + mouse.baudrate % 1200) + mouse.baudrate = 1200; + if (strcmp(protocol, "BusMouse") == 0) mouse.type = MTYPE_BUSMOUSE; else if (strcmp(protocol, "GlidePoint") == 0) @@ -286,7 +289,6 @@ mouse.emulate3buttons = emulate; mouse.flags |= MF_REOPEN; - /* This was not working in 3.3 */ mouse.device = device; XFlush(XtDisplay(w)); @@ -373,8 +375,8 @@ NULL, 0); XtAddCallback(listP, XtNcallback, MouseProtocolCallback, NULL); - emul3 = XtCreateManagedWidget("emulate3", toggleWidgetClass, - mouse_dp, NULL, 0); + emul3 = XtVaCreateManagedWidget("emulate3", toggleWidgetClass, + mouse_dp, XtNstate, True, NULL, 0); XtAddCallback(emul3, XtNcallback, MouseEmulateCallback, NULL); apply = XtCreateManagedWidget("apply", commandWidgetClass, mouse_dp, NULL, 0); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/options.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/options.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/options.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/options.c:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/options.c Thu Nov 30 15:55:18 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/options.c,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/options.c,v 1.4 2000/11/30 20:55:18 paulo Exp $ */ #include "options.h" @@ -35,7 +35,10 @@ #include <X11/Xaw/AsciiText.h> #include <X11/Xaw/List.h> #include <X11/Xaw/Command.h> +#include <X11/Xaw/MenuButton.h> #include <X11/Xaw/Paned.h> +#include <X11/Xaw/SimpleMenP.h> +#include <X11/Xaw/SmeBSB.h> #include <X11/Xaw/Viewport.h> /* @@ -47,12 +50,16 @@ static void RemoveOption(Widget, XtPointer, XtPointer); static void UpdateOption(Widget, XtPointer, XtPointer); static void UpdateOptionList(void); +#ifdef USE_MODULES +static void AddDriverOption(Widget, XtPointer, XtPointer); +#endif /* * Initialization */ +Widget optionsShell; static XF86OptionPtr *options; -static Widget shell, add, remov, update, list, name, value; +static Widget add, remov, update, list, name, value; static char *option_str; static int option_index, popped = False; @@ -60,9 +67,30 @@ * Implementation */ void +CreateOptionsShell(void) +{ + optionsShell = XtCreatePopupShell("options", transientShellWidgetClass, + toplevel, NULL, 0); +} + +#ifdef USE_MODULES +void +OptionsPopup(XF86OptionPtr *opts, char *driver, OptionInfoPtr drv_opts) +#else +void OptionsPopup(XF86OptionPtr *opts) +#endif { static int first = 1; +#ifdef USE_MODULES + static Widget button, menu; + static char label[256], menuName[16]; + Widget sme; + char buf[256]; + int i = 0; + Arg args[1]; + static int menuN; +#endif option_str = NULL; options = opts; @@ -71,10 +99,10 @@ first = 0; - shell = XtCreatePopupShell("options", transientShellWidgetClass, - toplevel, NULL, 0); + if (optionsShell == NULL) + CreateOptionsShell(); pane = XtCreateManagedWidget("pane", panedWidgetClass, - shell, NULL, 0); + optionsShell, NULL, 0); form = XtCreateManagedWidget("commands", formWidgetClass, pane, NULL, 0); add = XtCreateManagedWidget("add", commandWidgetClass, @@ -111,19 +139,83 @@ XtAddCallback(list, XtNcallback, SelectOptionCallback, NULL); bottom = XtCreateManagedWidget("bottom", formWidgetClass, pane, NULL, 0); - popdown = XtCreateManagedWidget("popdown", commandWidgetClass, +#ifdef USE_MODULES + button = XtCreateManagedWidget("driverOpts", menuButtonWidgetClass, bottom, NULL, 0); +#endif + popdown = XtVaCreateManagedWidget("popdown", commandWidgetClass, + bottom, NULL, 0); +#ifdef USE_MODULES + XtVaSetValues(popdown, XtNfromHoriz, button, NULL, 0); +#endif + XtAddCallback(popdown, XtNcallback, PopdownCallback, NULL); - XtRealizeWidget(shell); - XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1); + XtRealizeWidget(optionsShell); + XSetWMProtocols(DPY, XtWindow(optionsShell), &wm_delete_window, 1); + +#ifdef USE_MODULES + { + char *str; + + XtSetArg(args[0], XtNlabel, &str); + XtGetValues(button, args, 1); + XmuSnprintf(label, sizeof(label), "%s", str); + } +#endif + } + +#ifdef USE_MODULES + if (menu) + XtDestroyWidget(menu); + XmuSnprintf(menuName, sizeof(buf), "optionM%d", menuN); + menuN = !menuN; + menu = XtCreatePopupShell(menuName, simpleMenuWidgetClass, button, + NULL, 0); + XtVaSetValues(button, XtNmenuName, menuName, NULL, 0); + if (drv_opts) { + int len, longest = 0; + char fmt[32]; + static char *types[] = { + "none", "integer", "(non null) string", "string", "real", + "boolean", "frequency", + }; + + for (i = 0; drv_opts[i].name != NULL; i++) { + len = strlen(drv_opts[i].name); + if (len > longest) + longest = len; + } + XmuSnprintf(fmt, sizeof(fmt), "%c-%ds %%s", '%', longest); + for (; drv_opts->name != NULL; drv_opts++) { + char *type; + + if (drv_opts->type >= OPTV_NONE && drv_opts->type <= OPTV_FREQ) + type = types[drv_opts->type]; + else + type = "UNKNOWN"; + + XmuSnprintf(buf, sizeof(buf), fmt, drv_opts->name, type); + sme = XtVaCreateManagedWidget(drv_opts->name, smeBSBObjectClass, + menu, XtNlabel, buf, NULL, 0); + XtAddCallback(sme, XtNcallback, AddDriverOption, (XtPointer)drv_opts); + } } + if (i) { + XmuSnprintf(buf, sizeof(buf), "%s%s", label, driver); + XtSetArg(args[0], XtNlabel, buf); + XtSetValues(button, args, 1); + XtMapWidget(button); + } + else + XtUnmapWidget(button); +#endif UpdateOptionList(); popped = True; - XtPopup(shell, XtGrabExclusive); + XtPopup(optionsShell, XtGrabExclusive); while (popped) - XtAppProcessEvent(XtWidgetToApplicationContext(shell), XtIMAll); + XtAppProcessEvent(XtWidgetToApplicationContext(optionsShell), XtIMAll); } static void @@ -179,7 +271,7 @@ static void PopdownCallback(Widget w, XtPointer user_data, XtPointer call_data) { - XtPopdown(shell); + XtPopdown(optionsShell); popped = False; } @@ -201,7 +293,7 @@ option_str = info->string; option_index = info->list_index; - if ((option = xf86FindOption(*options, info->string)) != NULL) { + if ((option = xf86findOption(*options, info->string)) != NULL) { XtSetArg(args[0], XtNstring, option->opt_name); XtSetValues(name, args, 1); XtSetArg(args[0], XtNstring, @@ -223,7 +315,7 @@ XtGetValues(name, args, 1); XtSetArg(args[0], XtNstring, &val); XtGetValues(value, args, 1); - if (xf86FindOption(*options, nam) != NULL || strlen(nam) == 0) + if (xf86findOption(*options, nam) != NULL || strlen(nam) == 0) /* XXX xf86addNewOption will trash the option linked list if * the options being added already exists. */ @@ -233,6 +325,25 @@ UpdateOptionList(); } +#ifdef USE_MODULES +/*ARGSUSED*/ +static void +AddDriverOption(Widget w, XtPointer user_data, XtPointer call_data) +{ + Arg args[1]; + OptionInfoPtr opt = (OptionInfoPtr)user_data; + XF86OptionPtr option; + + XtSetArg(args[0], XtNstring, opt->name); + XtSetValues(name, args, 1); + if ((option = xf86findOption(*options, opt->name)) == NULL) + XtSetArg(args[0], XtNstring, ""); + else + XtSetArg(args[0], XtNstring, option->opt_val); + XtSetValues(value, args, 1); +} +#endif + /*ARGSUSED*/ static void RemoveOption(Widget w, XtPointer user_data, XtPointer call_data) @@ -242,7 +353,7 @@ XtSetArg(args[0], XtNstring, &str); XtGetValues(name, args, 1); - xf86RemoveOption(options, str); + xf86removeOption(options, str); UpdateOptionList(); } @@ -250,7 +361,7 @@ static void UpdateOption(Widget w, XtPointer user_data, XtPointer call_data) { -/* xf86RemoveOption(options, option_str); +/* xf86removeOption(options, option_str); AddOption(w, user_data, call_data); UpdateOptionList();*/ @@ -262,7 +373,7 @@ XtGetValues(name, args, 1); XtSetArg(args[0], XtNstring, &val); XtGetValues(value, args, 1); - if ((option = xf86FindOption(*options, option_str)) == NULL) + if ((option = xf86findOption(*options, option_str)) == NULL) return; XtFree(option->opt_name); option->opt_name = option_str = XtNewString(nam); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/options.h diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/options.h:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/options.h:1.3 --- xc/programs/Xserver/hw/xfree86/xf86cfg/options.h:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/options.h Fri Oct 20 10:59:07 2000 @@ -26,13 +26,20 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/options.h,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/options.h,v 1.3 2000/10/20 14:59:07 alanh Exp $ */ #include "config.h" +#ifdef USE_MODULES +#include "loader.h" +#endif /* * Prototypes */ +#ifdef USE_MODULES +void OptionsPopup(XF86OptionPtr*, char*, OptionInfoPtr); +#else void OptionsPopup(XF86OptionPtr*); +#endif void OptionsCancelAction(Widget, XEvent*, String*, Cardinal*); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c:1.6 --- xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c:1.2 Thu May 18 12:29:59 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c Fri Dec 8 16:51:06 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c,v 1.6 2000/12/08 21:51:06 paulo Exp $ */ #include "xf86config.h" @@ -37,6 +37,9 @@ #include <X11/Xaw/List.h> #include <X11/Xaw/Toggle.h> #include <X11/Xaw/Viewport.h> +#ifdef USE_MODULES +#include "loader.h" +#endif #define CW 1 #define CCW -1 @@ -49,6 +52,7 @@ static void UnselectIndexCallback(Widget, XtPointer, XtPointer); static void SelectCallback(Widget, XtPointer, XtPointer); static void UnselectCallback(Widget, XtPointer, XtPointer); +static void MoveCallback(Widget, XtPointer, XtPointer); static void RotateCallback(Widget, XtPointer, XtPointer); /* @@ -59,6 +63,7 @@ "640x480", "800x600", "1024x768", + "1280x960", "1280x1024", "320x200", "320x240", @@ -98,8 +103,10 @@ default_depth = 8; sel_index = unsel_index = -1; for (i = 0; i < computer.num_screens; i++) - if (computer.screens[i]->screen == screen) + if (computer.screens[i]->screen == screen) { + SetScreenRotate(computer.screens[i]); rotate = computer.screens[i]->rotate; + } oldrotate = rotate; ndefmodes = 0; @@ -152,13 +159,13 @@ if (disp == NULL) { disp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); screen->scrn_display_lst = (XF86ConfDisplayPtr) - addListItem((GenericListPtr)(screen->scrn_display_lst), + xf86addListItem((GenericListPtr)(screen->scrn_display_lst), (GenericListPtr)(disp)); disp->disp_depth = default_depth; } if (strcasecmp(screen->scrn_identifier, ident_string)) - xf86RenameScreen(XF86Config, screen, ident_string); + xf86renameScreen(XF86Config, screen, ident_string); screen->scrn_defaultdepth = default_depth; @@ -203,11 +210,10 @@ computer.screens[i]->rotate = rotate; if (oldrotate != rotate) { - XF86OptionPtr option; static char *Rotate = "Rotate"; if (screen->scrn_option_lst != NULL) - xf86RemoveOption(&screen->scrn_option_lst, Rotate); + xf86removeOption(&screen->scrn_option_lst, Rotate); if (rotate) screen->scrn_option_lst = xf86addNewOption(screen->scrn_option_lst, @@ -242,7 +248,7 @@ DepthCallback(Widget w, XtPointer user_data, XtPointer call_data) { if (call_data != NULL) - default_depth = (int)user_data; + default_depth = (long)user_data; } /*ARGSUSED*/ @@ -289,7 +295,19 @@ XtSetArg(args[0], XtNlist, defmodes); XtSetArg(args[1], XtNnumberStrings, ndefmodes); XtSetValues(listR, args, 2); - unsel_index = -1; + + XawListUnhighlight(listR); + if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) { + if (unsel_index >= ndefmodes) + unsel_index = ndefmodes - 1; + XawListHighlight(listR, unsel_index = ndefmodes - 1); + } + else + unsel_index = -1; + + /* force realyout */ + XtUnmanageChild(listR); + XtManageChild(listR); } /*ARGSUSED*/ @@ -297,10 +315,26 @@ UnselectCallback(Widget w, XtPointer user_data, XtPointer call_data) { Arg args[2]; + char **modes; + Cardinal num_modes; if (unsel_index < 0 || unsel_index >= ndefmodes) return; + XawListUnhighlight(listL); + XtSetArg(args[0], XtNlist, &modes); + XtSetArg(args[1], XtNnumberStrings, &num_modes); + XtGetValues(listL, args, 2); + if (modes) { + for (sel_index = 0; sel_index < num_modes; sel_index++) + if (strcmp(defmodes[unsel_index], modes[sel_index]) == 0) + break; + if (sel_index < num_modes) + XawListHighlight(listL, sel_index); + else + sel_index = -1; + } + XtFree(defmodes[unsel_index]); if (--ndefmodes > unsel_index) memmove(&defmodes[unsel_index], &defmodes[unsel_index + 1], @@ -317,7 +351,40 @@ XtSetArg(args[0], XtNlist, defmodes); XtSetArg(args[1], XtNnumberStrings, ndefmodes); XtSetValues(listR, args, 2); - unsel_index = -1; + + XawListUnhighlight(listR); + if (ndefmodes > 1 || (ndefmodes == 1 && *defmodes[0] != '\0')) { + if (unsel_index >= ndefmodes) + unsel_index = ndefmodes - 1; + XawListHighlight(listR, unsel_index); + } + else + unsel_index = -1; +} + +/*ARGSUSED*/ +static void +MoveCallback(Widget w, XtPointer user_data, XtPointer call_data) +{ + char *tmp; + Bool down = (Bool)user_data; + + if (unsel_index < 0 || unsel_index >= ndefmodes) + return; + + if ((down && unsel_index + 1 >= ndefmodes) || + (!down && unsel_index - 1 < 0)) + return; + + tmp = defmodes[unsel_index]; + if (down) + defmodes[unsel_index] = defmodes[++unsel_index]; + else + defmodes[unsel_index] = defmodes[--unsel_index]; + defmodes[unsel_index] = tmp; + + XawListUnhighlight(listR); + XawListHighlight(listR, unsel_index); } /*ARGSUSED*/ @@ -325,7 +392,7 @@ RotateCallback(Widget w, XtPointer user_data, XtPointer call_data) { if (call_data != NULL) - rotate = (int)user_data; + rotate = (long)user_data; else rotate = 0; } @@ -333,11 +400,15 @@ void ScreenDialog(XF86SetupInfo *info) { - static Widget dialog, d1, d4, d8, d16, d24, cw, ccw; + static Widget dialog, d1, d4, d8, d16, d24, labelRotate, cw, ccw; Arg args[2]; XF86ConfMonitorPtr mon = screen->scrn_monitor; XF86ConfModeLinePtr mline = mon != NULL ? mon->mon_modeline_lst : NULL; int i; +#ifdef USE_MODULES + xf86cfgDriverOptions *drv_opts = video_driver_info; + Bool foundRotate = False; +#endif while (nmodes > 0) XtFree(modes[--nmodes]); @@ -391,13 +462,20 @@ command = XtCreateManagedWidget("unselect", commandWidgetClass, dialog, NULL, 0); XtAddCallback(command, XtNcallback, UnselectCallback, NULL); + command = XtCreateManagedWidget("up", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)False); + command = XtCreateManagedWidget("down", commandWidgetClass, + dialog, NULL, 0); + XtAddCallback(command, XtNcallback, MoveCallback, (XtPointer)True); viewport = XtCreateManagedWidget("viewR", viewportWidgetClass, dialog, NULL, 0); listR = XtCreateManagedWidget("listRight", listWidgetClass, viewport, NULL, 0); XtAddCallback(listR, XtNcallback, UnselectIndexCallback, NULL); - XtCreateManagedWidget("rotate", labelWidgetClass, dialog, NULL, 0); + labelRotate = XtCreateManagedWidget("rotate", labelWidgetClass, + dialog, NULL, 0); cw = XtCreateManagedWidget("CW", toggleWidgetClass, dialog, NULL, 0); XtAddCallback(cw, XtNcallback, RotateCallback, (XtPointer)CW); ccw = XtVaCreateManagedWidget("CCW", toggleWidgetClass, dialog, @@ -407,6 +485,34 @@ XtRealizeWidget(dialog); } +#ifdef USE_MODULES + while (drv_opts) { + if (strcmp(drv_opts->name, screen->scrn_device->dev_driver) == 0) { + OptionInfoPtr opts = drv_opts->option; + + while (opts->name) { + if (xf86nameCompare(opts->name, "Rotate") == 0) { + foundRotate = True; + break; + } + opts++; + } + break; + } + drv_opts = drv_opts->next; + } + + if (!foundRotate) { + XtUnmapWidget(labelRotate); + XtUnmapWidget(cw); + XtUnmapWidget(ccw); + } + else { + XtMapWidget(labelRotate); + XtMapWidget(cw); + XtMapWidget(ccw); + } +#endif if (rotate == CW) { XtVaSetValues(cw, XtNstate, True, NULL, 0); XtVaSetValues(ccw, XtNstate, False, NULL, 0); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c:1.3 xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c:1.5 --- xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c:1.3 Tue Jun 13 19:15:52 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c Fri Dec 1 13:31:07 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c,v 1.3 2000/06/13 23:15:52 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c,v 1.5 2000/12/01 18:31:07 paulo Exp $ */ #include <X11/IntrinsicP.h> @@ -56,49 +56,43 @@ * Implementation */ void -CreateScreenWidget(xf86cfgScreen *screen) +SetScreenRotate(xf86cfgScreen *screen) { static char *Rotate = "Rotate", *_CW = "CW", *_CCW = "CCW"; int rotate = 0; XF86OptionPtr option, options; - Widget w = XtCreateWidget("screen", simpleWidgetClass, - XtParent(computer.cpu), NULL, 0); - /* When this function is called, the monitor and card fields should have - * been already set. - */ - /* This is the only place where xf86cfg is intrusive, and deletes options * added by the user directly in the config file. The "Rotate" option * will be kept in the screen section. */ if (screen->monitor != NULL) { options = ((XF86ConfMonitorPtr)(screen->monitor->config))->mon_option_lst; - if ((option = xf86FindOption(options, Rotate)) != NULL) { + if ((option = xf86findOption(options, Rotate)) != NULL) { if (option->opt_val != NULL) rotate = strcasecmp(option->opt_val, _CW) == 0 ? CW : strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; - xf86RemoveOption(&((XF86ConfMonitorPtr)(screen->monitor->config)) + xf86removeOption(&((XF86ConfMonitorPtr)(screen->monitor->config)) ->mon_option_lst, Rotate); } } if (screen->card != NULL) { options = ((XF86ConfDevicePtr)(screen->card->config))->dev_option_lst; - if ((option = xf86FindOption(options, Rotate)) != NULL) { + if ((option = xf86findOption(options, Rotate)) != NULL) { if (option->opt_val != NULL) rotate += strcasecmp(option->opt_val, _CW) == 0 ? CW : strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; - xf86RemoveOption(&((XF86ConfDevicePtr)(screen->card->config)) + xf86removeOption(&((XF86ConfDevicePtr)(screen->card->config)) ->dev_option_lst, Rotate); } } options = screen->screen->scrn_option_lst; - if ((option = xf86FindOption(options, Rotate)) != NULL) { + if ((option = xf86findOption(options, Rotate)) != NULL) { if (option->opt_val != NULL) rotate += strcasecmp(option->opt_val, _CW) == 0 ? CW : strcasecmp(option->opt_val, _CCW) == 0 ? CCW : 0; - xf86RemoveOption(&screen->screen->scrn_option_lst, Rotate); + xf86removeOption(&screen->screen->scrn_option_lst, Rotate); } rotate = rotate > 0 ? CW : rotate < 0 ? CCW : 0; @@ -108,7 +102,15 @@ XtNewString(Rotate), XtNewString(rotate > 0 ? _CW : _CCW)); screen->rotate = rotate; +} +void +CreateScreenWidget(xf86cfgScreen *screen) +{ + Widget w = XtCreateWidget("screen", simpleWidgetClass, + XtParent(computer.cpu), NULL, 0); + + SetScreenRotate(screen); XtRealizeWidget(w); screen->widget = w; screen->column = screen->row = -1; @@ -195,7 +197,7 @@ ++nscreens; XmuSnprintf(screen_name, sizeof(screen_name), "Screen%d", nscreens); - } while (xf86FindScreen(screen_name, + } while (xf86findScreen(screen_name, XF86Config->conf_screen_lst) != NULL); screen = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); @@ -205,7 +207,7 @@ screen->scrn_monitor_str = XtNewString(((XF86ConfMonitorPtr)(mon->config))->mon_identifier); screen->scrn_monitor = (XF86ConfMonitorPtr)(mon->config); XF86Config->conf_screen_lst = - xf86AddScreen(XF86Config->conf_screen_lst, screen); + xf86addScreen(XF86Config->conf_screen_lst, screen); adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); adj->adj_screen = screen; @@ -214,7 +216,7 @@ computer.layout = XF86Config->conf_layout_lst = (XF86ConfLayoutPtr) XtCalloc(1, sizeof(XF86ConfLayoutRec)); computer.layout->lay_adjacency_lst = (XF86ConfAdjacencyPtr) - addListItem((GenericListPtr)computer.layout->lay_adjacency_lst, + xf86addListItem((GenericListPtr)computer.layout->lay_adjacency_lst, (GenericListPtr)adj); computer.screens = (xf86cfgScreen**) @@ -263,7 +265,7 @@ } } - xf86RemoveScreen(XF86Config, screen); + xf86removeScreen(XF86Config, screen); } void @@ -695,7 +697,7 @@ XF86ConfScreenPtr s; if (adj->adj_where >= CONF_ADJ_RIGHTOF < adj->adj_where <= CONF_ADJ_BELOW) { - s = xf86FindScreen(adj->adj_refscreen, XF86Config->conf_screen_lst); + s = xf86findScreen(adj->adj_refscreen, XF86Config->conf_screen_lst); for (i = 0; i < computer.num_screens; i++) if (computer.screens[i]->screen == s) break; @@ -793,6 +795,9 @@ for (i = 0; i < computer.num_screens; i++) if (computer.screens[i]->state == USED1) computer.screens[i]->state = USED; + else + XLowerWindow(XtDisplay(computer.screens[i]->widget), + XtWindow(computer.screens[i]->widget)); w = work->core.width / (columns + 1) - 5; h = work->core.height / (rows + 1) - 5; Index: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h:1.3 --- xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h:1.2 Thu May 18 12:30:00 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h Fri Dec 1 13:31:07 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h,v 1.2 2000/05/18 16:30:00 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h,v 1.3 2000/12/01 18:31:07 paulo Exp $ */ #include "xf86config.h" @@ -44,6 +44,7 @@ void DrawScreen(Display*, Drawable, int, int, int, int, Bool, int); void DrawScreenMask(Display*, Drawable, GC, int, int, int, int, int); void CreateScreenWidget(xf86cfgScreen*); +void SetScreenRotate(xf86cfgScreen*); void AdjustScreenUI(void); void UpdateScreenUI(void); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c:1.6 --- xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c:1.2 Thu May 18 12:30:00 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c Wed Dec 6 10:35:34 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c,v 1.2 2000/05/18 16:30:00 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c,v 1.6 2000/12/06 15:35:34 eich Exp $ */ #include "config.h" @@ -54,9 +54,32 @@ if (XF86Config_path == NULL) { char *home, filename[PATH_MAX]; - - if (system("XFree86 :8 -configure") != 0) { - fprintf(stderr, "Failed to run \"XFree86 -configure\".\n"); + char commandline[PATH_MAX * 4]; + int c_pos; + int len; + /* + * The name of the 4.0 binary is XFree86. X might also + * be the name of the 3.3 binary. Therefore don't change + * name to 'X'. + */ + if (XFree86_path) + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/XFree86 :8 -configure ",XFree86_path); + else + c_pos = XmuSnprintf(commandline, sizeof(commandline), + "%s/bin/XFree86 :8 -configure ", XFree86Dir); + if (XF86Module_path && ((len = sizeof(commandline) - c_pos) > 0)) + c_pos += XmuSnprintf(commandline + c_pos,len, + " -modulepath %s",XF86Module_path); + if (XF86Font_path && ((len = sizeof(commandline) - c_pos) > 0)) + c_pos += XmuSnprintf(commandline + c_pos,len, + " -fontpath %s",XF86Font_path); + if (XF86RGB_path && ((len = sizeof(commandline) - c_pos) > 0)) + c_pos += XmuSnprintf(commandline + c_pos,len, + " -rgbpath %s",XF86RGB_path); + + if (system(commandline) != 0) { + fprintf(stderr, "Failed to run \"X -configure\".\n"); exit(1); } @@ -76,8 +99,11 @@ switch (xpid = fork()) { case 0: { char path[PATH_MAX]; - - XmuSnprintf(path, sizeof(path), "%s/bin/XFree86", XFree86Dir); + /* Don't change to X! see above */ + if (XFree86_path) + XmuSnprintf(path, sizeof(path), "%s/XFree86", XFree86_path); + else + XmuSnprintf(path, sizeof(path), "%s/bin/XFree86", XFree86Dir); execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail", "-xf86config", XF86Config_path, NULL); exit(-127); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c:1.2 --- /dev/null Mon Dec 18 14:32:32 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c Mon Oct 23 17:16:52 2000 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.c,v 1.2 2000/10/23 21:16:52 tsi Exp $ + */ + +#include <stdio.h> +#include <string.h> +#include "stubs.h" + +/* + * Implementation + */ +#if !defined(USE_MODULES) +/* these are defined in libdummy.a */ +int +ErrorF(const char *fmt, ...) +{ + int retval; + va_list ap; + + va_start(ap, fmt); + retval = vfprintf(stderr, fmt, ap); + + va_end(ap); + + return (retval); +} + +int +VErrorF(const char *fmt, va_list ap) +{ + int retval; + + retval = vfprintf(stderr, fmt, ap); + + return (retval); +} + +#else +char *Xstrdup(const char*); + +char * +Xstrdup(const char *s) +{ + return (strdup(s)); +} +#endif /* !defined(USE_MODULES) */ Index: xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h:1.2 --- /dev/null Mon Dec 18 14:32:33 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h Mon Oct 23 17:16:52 2000 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/stubs.h,v 1.2 2000/10/23 21:16:52 tsi Exp $ + */ + +#ifndef _xf86cfg_stubs_h +#define _xf86cfg_stubs_h + +#include <stdarg.h> + +#if !defined(USE_MODULES) +int ErrorF(const char*, ...); +int VErrorF(const char*, va_list); +#else +extern int xf86Verbose; +#endif + +#endif /* _xf86cfg_stubs_h */ Index: xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c:1.7 --- /dev/null Mon Dec 18 14:32:34 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c Wed Dec 13 07:58:20 2000 @@ -0,0 +1,3252 @@ +/* + * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Except as contained in this notice, the name of Conectiva Linux shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from + * Conectiva Linux. + * + * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> + * + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/text-mode.c,v 1.7 2000/12/13 12:58:20 tsi Exp $ + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ncurses.h> +#include <ctype.h> +#include <X11/Xlib.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBrules.h> +#include "cards.h" +#include "config.h" +#include "xf86config.h" + +#define XKB_RULES_DIR "/usr/X11R6/lib/X11/xkb/rules" + +#define TAB 9 +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + +void TextMode(void); + +static void ClearScreen(void); +static void PaintWindow(WINDOW*, char*, int, int, int, int); +static void PaintBox(WINDOW*, int, int, int, int); +static void PaintButton(WINDOW*, char*, int, int, int); +static void PrintWrap(WINDOW*, char*, int, int, int); +static int Dialog(char*, char*, int, int, char*, char*, int); +static void PaintItem(WINDOW*, char*, int, int); +static int DialogMenu(char*, char*, int, int, int, int, char**, char*, char*, int); +static void PaintCheckItem(WINDOW*, char*, int, int, int); +static int DialogCheckBox(char*, char*, int, int, int, int, char**, char*, char*, char*); +static char *DialogInput(char*, char*, int, int, char*, char*, char*, int); +static void PaintScroller(WINDOW*, int, int, int); + +static int MouseConfig(void); +static int KeyboardConfig(void); +static int MonitorConfig(void); +static int CardConfig(void); +static int ScreenConfig(void); +static int LayoutConfig(void); +static int WriteXF86Config(void); + +static XF86ConfLayoutPtr CopyLayout(XF86ConfLayoutPtr); +static XF86ConfAdjacencyPtr CopyAdjacency(XF86ConfAdjacencyPtr); +static XF86ConfInputrefPtr CopyInputref(XF86ConfInputrefPtr); +static XF86ConfInactivePtr CopyInactive(XF86ConfInactivePtr); +static void FreeLayout(XF86ConfLayoutPtr); + +#ifdef USE_MODULES +extern void LoaderInit(void); +extern void LoaderSetPath(char*); +extern char **LoaderListDirs(char**, char**); + +extern int xf86Verbose; +#endif + +extern int string_to_parser_range(char*, parser_range*, int); +#define PARSER_RANGE_SIZE 256 +/* string must have at least 256 bytes */ +extern int parser_range_to_string(char*, parser_range*, int); + +static Bool newconfig; + +static chtype screen_attr = A_NORMAL; +static chtype dialog_attr = A_REVERSE; +static chtype highlight_border_attr = A_REVERSE; +static chtype shadow_border_attr = A_REVERSE; +static chtype title_attr = A_NORMAL; +static chtype button_active_attr = A_NORMAL; +static chtype button_inactive_attr = A_NORMAL; +static int menu_width, item_x; +static char Edit[] = "Edit "; + +static char *main_menu[] = { +#define CONF_MOUSE 0 + "Configure mouse", +#define CONF_KEYBOARD 1 + "Configure keyboard", +#define CONF_MONITOR 2 + "Configure monitor", +#define CONF_CARD 3 + "Configure card", +#define CONF_SCREEN 4 + "Configure screen", +#define CONF_LAYOUT 5 + "Configure layout", +#define CONF_FINISH 6 + "Write XF86Config and quit", +#define CONF_QUIT 7 + "Quit", +}; + +void +TextMode(void) +{ + static int first = 1; + int i, choice = CONF_MOUSE; + + initscr(); + noecho(); + nonl(); + keypad(stdscr, TRUE); + + if (first) { + const char *filename; + + first = 0; + + if (has_colors()) { + start_color(); + init_pair(1, COLOR_BLACK, COLOR_BLACK); + screen_attr = A_BOLD | COLOR_PAIR(1); + + init_pair(2, COLOR_BLACK, COLOR_WHITE); + dialog_attr = COLOR_PAIR(2); + + init_pair(3, COLOR_BLACK, COLOR_WHITE); + shadow_border_attr = A_BOLD | COLOR_PAIR(3); + + init_pair(4, COLOR_WHITE, COLOR_WHITE); + highlight_border_attr = A_BOLD | COLOR_PAIR(4); + + init_pair(5, COLOR_WHITE, COLOR_BLUE); + title_attr = A_BOLD | COLOR_PAIR(5); + button_active_attr = title_attr; + + init_pair(6, COLOR_WHITE, COLOR_BLACK); + button_inactive_attr = A_BOLD | COLOR_PAIR(6); + } + + if ((filename = xf86openConfigFile(getuid() == 0 ? + CONFPATH : USER_CONFPATH, + XF86Config_path, NULL)) != NULL) { + XF86Config_path = (char *)filename; + if ((XF86Config = xf86readConfigFile()) == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "Error parsing configuration file.", + 7, 50, " Ok ", NULL, 0); + } + } + if (XF86Config == NULL) { + XF86Config = (XF86ConfigPtr)XtCalloc(1, sizeof(XF86ConfigRec)); + newconfig = True; + } + else + newconfig = False; + } + + ClearScreen(); + refresh(); + + /*CONSTCOND*/ + while (1) { + int cancel = FALSE; + + ClearScreen(); + refresh(); + if (Dialog("XFree86 Configuration", + "This program will create the XF86Config file, based on " + "menu selections you make.\n" + "\n" + "The XF86Config file usually resides in /usr/X11R6/etc/X11 " + "or /etc/X11. A sample XF86Config file is supplied with " + "XFree86; it is configured for a standard VGA card and " + "monitor with 640x480 resolution. This program will ask for " + "a pathname when it is ready to write the file.\n" + "\n" + "You can either take the sample XF86Config as a base and " + "edit it for your configuration, or let this program " + "produce a base XF86Config file for your configuration and " + "fine-tune it.", + 20, 60, " Ok ", " Cancel ", 0) != 0) + break; + + while (!cancel) { + ClearScreen(); + refresh(); + switch (DialogMenu("Main menu", + "Choose one of the options:", + 17, 60, 8, sizeof(main_menu) / + sizeof(main_menu[0]), main_menu, + " Ok ", " Cancel ", choice)) { + case CONF_MOUSE: + i = MouseConfig(); + if (i > 0 && choice == CONF_MOUSE) + choice = CONF_KEYBOARD; + else if (i == 0) + choice = CONF_MOUSE; + break; + case CONF_KEYBOARD: + i = KeyboardConfig(); + if (i > 0 && choice <= CONF_KEYBOARD) + choice = CONF_MONITOR; + else if (i == 0) + choice = CONF_KEYBOARD; + break; + case CONF_MONITOR: + i = MonitorConfig(); + if (i > 0 && choice <= CONF_MONITOR) + choice = CONF_CARD; + else if (i == 0) + choice = CONF_MONITOR; + break; + case CONF_CARD: + i = CardConfig(); + if (i > 0 && choice <= CONF_CARD) + choice = CONF_SCREEN; + else if (i == 0) + choice = CONF_CARD; + break; + case CONF_SCREEN: + i = ScreenConfig(); + if (i > 0 && choice <= CONF_SCREEN) + choice = CONF_LAYOUT; + else if (i == 0) + choice = CONF_SCREEN; + break; + case CONF_LAYOUT: + i = LayoutConfig(); + if (i > 0 && choice <= CONF_LAYOUT) + choice = CONF_FINISH; + else if (i == 0) + choice = CONF_LAYOUT; + break; + case CONF_FINISH: + if (WriteXF86Config() < 0) + break; + /*FALLTROUGH*/ + case CONF_QUIT: + endwin(); + exit(0); + default: + cancel = TRUE; + break; + } + } + } + + endwin(); +} + +static int +WriteXF86Config(void) +{ + char *xf86config; + + ClearScreen(); + refresh(); + xf86config = DialogInput("Write XF86Config", "Write configuration to file:", + 10, 60, XF86Config_path ? XF86Config_path : + "/etc/X11/XF86Config", " Ok ", " Cancel ", 0); + + if (xf86config == NULL) + return (-1); + + if (newconfig) { + if (XF86Config->conf_modules == NULL) { + static char *modules[] = {"xie", "pex5", "glx", "dri", "dbe", + "record", "extmod", "type1"}; + XF86LoadPtr load; + int i; + + XF86Config->conf_modules = (XF86ConfModulePtr) + XtCalloc(1, sizeof(XF86ConfModuleRec)); + + for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++) { + load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec)); + load->load_name = XtNewString(modules[i]); + XF86Config->conf_modules->mod_load_lst = + xf86addModule(XF86Config->conf_modules->mod_load_lst, load); + } + } + } + + if (!xf86writeConfigFile(xf86config, XF86Config)) { + char msg[1024]; + + XmuSnprintf(msg, sizeof(msg), "Failed to write configuration file %s.", + xf86config); + ClearScreen(); + refresh(); + (void)Dialog("Write failed!", msg, 8, 60, " Ok ", NULL, 0); + XtFree(xf86config); + return (-1); + } + XtFree(xf86config); + + return (1); +} + +static char *protocols[] = { + "Auto", + "Microsoft", + "PS/2", + "BusMouse", + "GlidePoint", + "IntelliMouse", + "Logitech", + "MMHitTab", + "MMSeries", + "MouseMan", + "MouseSystems", + "SysMouse", + "ThinkingMouse", +}; + +static int +MouseConfig(void) +{ + int i, nlist, def, proto, emul; + char **list = NULL, *device, *str; + XF86ConfInputPtr *inputs = NULL; + XF86ConfInputPtr input = XF86Config->conf_input_lst; + XF86OptionPtr option; + + nlist = 0; + while (input) { + if (strcmp(input->inp_driver, "mouse") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(input->inp_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, input->inp_identifier); + inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) * + sizeof(XF86ConfInputPtr)); + inputs[nlist] = input; + ++nlist; + } + input = (XF86ConfInputPtr)(input->list.next); + } + + input = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new mouse"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove mouse"); + ClearScreen(); + refresh(); + i = DialogMenu("Mouse configuration", + "You can edit or remove a previously configured mouse, " + "or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove mouse", + "Select which mouse to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + input = inputs[i]; + } + else + input = inputs[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + xf86removeInput(XF86Config, input); + return (0); + } + if (i < nlist - 2) + input = inputs[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + + if (input == NULL) { + char label[32]; + + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + XmuSnprintf(label, sizeof(label), "Mouse%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + input->inp_identifier = + DialogInput("Mouse identifier", + "Enter an identifier for your mouse definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (input->inp_identifier == NULL) { + XtFree((XtPointer)input); + return (-1); + } + } + + def = 0; + option = xf86findOption(input->inp_option_lst, "Protocol"); + if (option) + for (i = 0; i < sizeof(protocols)/sizeof(protocols[0]); i++) + if (strcasecmp(option->opt_val, protocols[i]) == 0) { + def = i; + break; + } + + ClearScreen(); + refresh(); + i = DialogMenu("Select mouse protocol", + "If you have a serial mouse, it probably will work with " + "the \"Auto\" protocol. But, if it is an old serial " + "mouse probably it is not PNP; in that case, most serial " + "mouses understand the \"Microsoft\" protocol.", + 19, 60, 7, sizeof(protocols) / + sizeof(protocols[0]), protocols, " Next >>", " Cancel ", def); + if (i < 0) { + if (input->inp_driver == NULL) { + XtFree(input->inp_driver); + XtFree((XtPointer)input); + } + return (i); + } + proto = i; + + def = 0; + if (input->inp_driver) { + option = xf86findOption(input->inp_option_lst, "Emulate3Buttons"); + def = option ? 0 : 1; + } + ClearScreen(); + refresh(); + i = Dialog("Mouse 3 buttons emulation", + "If your mouse has only two buttons, it is recommended that " + "you enable Emulate3Buttons.\n" + "\n" + "Do you want to enable Emulate3Buttons?", + 10, 60, " Yes ", " No ", def); + if (i < 0) + return (i); + emul = !i; + + str = NULL; + option = xf86findOption(input->inp_option_lst, "Device"); + if (option) + str = option->opt_val; + if (str == NULL) + str = "/dev/mouse"; + + ClearScreen(); + refresh(); + device = DialogInput("Select mouse device", + "Enter mouse device:", 10, 40, str, + " Finish ", " Cancel ", 0); + if (device == NULL) { + if (input->inp_driver == NULL) { + XtFree(input->inp_driver); + XtFree((XtPointer)input); + } + return (-1); + } + + /* Finish mouse configuration */ + option = xf86findOption(input->inp_option_lst, "Protocol"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(protocols[proto]); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Protocol"), XtNewString(protocols[proto])); + + option = xf86findOption(input->inp_option_lst, "Emulate3Buttons"); + if (option && !emul) { + xf86removeOption(&input->inp_option_lst, "Emulate3Buttons"); + } + else if (option == NULL && emul) + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Emulate3Buttons"), NULL); + + option = xf86findOption(input->inp_option_lst, "Device"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = device; + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("Device"), device); + + if (input->inp_driver == NULL) { + input->inp_driver = XtNewString("mouse"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + } + + return (1); +} + +static int +KeyboardConfig(void) +{ + int i; + char *rulesfile; + static int first = 1; + static XkbRF_RulesPtr rules; + static char **models, **layouts; + XF86ConfInputPtr *inputs = NULL, input = XF86Config->conf_input_lst; + char **list = NULL, *model, *layout; + int nlist, def; + XF86OptionPtr option; + + nlist = 0; + while (input) { + if (strcmp(input->inp_driver, "keyboard") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(input->inp_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, input->inp_identifier); + inputs = (XF86ConfInputPtr*)XtRealloc((XtPointer)inputs, (nlist + 1) * + sizeof(XF86ConfInputPtr)); + inputs[nlist] = input; + ++nlist; + } + input = (XF86ConfInputPtr)(input->list.next); + } + + input = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new keyboard"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(inputs[0]->inp_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", inputs[0]->inp_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove keyboard"); + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard configuration", + "You can edit or remove a previously configured " + "keyboard, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove keyboard", + "Select which keyboard to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + return (-1); + } + input = inputs[i]; + } + else + input = inputs[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + xf86removeInput(XF86Config, input); + return (0); + } + if (i < nlist - 2) + input = inputs[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)inputs); + + if (input == NULL) { + char label[32]; + + input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec)); + XmuSnprintf(label, sizeof(label), "Keyboard%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + input->inp_identifier = + DialogInput("Keyboard identifier", + "Enter an identifier for your mouse definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (input->inp_identifier == NULL) { + XtFree((XtPointer)input); + return (-1); + } + } + + if (first) { + first = 0; +#ifdef XFREE98_XKB + rulesfile = XKB_RULES_DIR "/xfree98"; +#else + rulesfile = XKB_RULES_DIR "/xfree86"; +#endif + rules = XkbRF_Load(rulesfile, "", True, False); + if (rules == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "XKB rules file not found.\n" + "\n" + "Keyboard XKB options will be set to default values.", + 10, 50, " Ok ", NULL, 0); + if (input->inp_driver == NULL) { + input->inp_option_lst = + xf86addNewOption(input->inp_option_lst, + XtNewString("XkbModel"), XtNewString("pc101")); + input->inp_option_lst = + xf86addNewOption(input->inp_option_lst, + XtNewString("XkbLayout"), XtNewString("us")); + input->inp_driver = XtNewString("keyboard"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config, input); + } + return (0); + } + models = (char**)XtMalloc(sizeof(char*) * rules->models.num_desc); + for (i = 0; i < rules->models.num_desc; i++) + models[i] = XtNewString(rules->models.desc[i].desc); + layouts = (char**)XtMalloc(sizeof(char*) * rules->layouts.num_desc); + for (i = 0; i < rules->layouts.num_desc; i++) + layouts[i] = XtNewString(rules->layouts.desc[i].desc); + } + else if (rules == NULL) + return (-1); + + def = 0; + option = xf86findOption(input->inp_option_lst, "XkbModel"); + if (option) { + for (i = 0; i < rules->models.num_desc; i++) + if (strcasecmp(option->opt_val, rules->models.desc[i].name) == 0) { + def = i; + break; + } + } + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard model", + "Please select one of the following keyboard types that is " + "the better description of your keyboard. If nothing really " + "matches, choose \"Generic 101-key PC\".\n", + 20, 60, 9, rules->models.num_desc, + models, " Next >>", " Cancel ", def); + if (i < 0) + return (i); + model = rules->models.desc[i].name; + + def = 0; + option = xf86findOption(input->inp_option_lst, "XkbLayout"); + if (option) { + for (i = 0; i < rules->layouts.num_desc; i++) + if (strcasecmp(option->opt_val, rules->layouts.desc[i].name) == 0) { + def = i; + break; + } + } + ClearScreen(); + refresh(); + i = DialogMenu("Keyboard layout", + "Select keyboard layout:", + 20, 60, 11, rules->layouts.num_desc, + layouts, " Finish ", " Cancel ", def); + if (i < 0) + return (i); + layout = rules->layouts.desc[i].name; + + /* Finish keyboard configuration */ + option = xf86findOption(input->inp_option_lst, "XkbModel"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(model); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("XkbModel"), XtNewString(model)); + + option = xf86findOption(input->inp_option_lst, "XkbLayout"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString(layout); + } + else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("XkbLayout"), XtNewString(layout)); + + if (input->inp_driver == NULL) { + input->inp_driver = XtNewString("keyboard"); + XF86Config->conf_input_lst = + xf86addInput(XF86Config->conf_input_lst, input); + } + + return (1); +} + +static char *hsync[] = { +#define CONF_MONITOR_HSYNC 0 + "Enter your own horizontal sync range", + "31.5; Standard VGA, 640x480 @ 60 Hz", + "31.5 - 35.1; Super VGA, 800x600 @ 56 Hz", + "31.5, 35.5; 8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)", + "31.5, 35.15, 35.5; Super VGA, 1024x768 @ 87 Hz int., 800x600 @ 56 Hz", + "31.5 - 37.9; Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz", + "31.5 - 48.5; Non-Interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz", + "31.5 - 57.0; High Frequency SVGA, 1024x768 @ 70 Hz", + "31.5 - 64.3; Monitor that can do 1280x1024 @ 60 Hz", + "31.5 - 79.0; Monitor that can do 1280x1024 @ 74 Hz", + "31.5 - 82.0; Monitor that can do 1280x1024 @ 76 Hz", +}; + +static char *vrefresh[] = { +#define CONF_MONITOR_VREFRESH 0 + "Enter your own vertical sync range", + "50 - 70", + "50 - 90", + "50 - 100", + "40 - 150", +}; + +static int +MonitorConfig(void) +{ + int i; + XF86ConfMonitorPtr *monitors = NULL, monitor = XF86Config->conf_monitor_lst; + char **list = NULL, *identifier = NULL, *tmp; + int nlist, def; + char hsync_str[256], vrefresh_str[256]; + + nlist = 0; + while (monitor) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(monitor->mon_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, monitor->mon_identifier); + monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) * + sizeof(XF86ConfMonitorPtr)); + monitors[nlist] = monitor; + ++nlist; + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + + monitor = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new monitor"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(monitors[0]->mon_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", monitors[0]->mon_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove monitor"); + ClearScreen(); + refresh(); + i = DialogMenu("Monitor configuration", + "You can edit or remove a previously configured " + "monitor, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove monitor", + "Select which monitor to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + return (-1); + } + monitor = monitors[i]; + } + else + monitor = monitors[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + xf86removeMonitor(XF86Config, monitor); + return (0); + } + if (i < nlist - 2) + monitor = monitors[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)monitors); + + if (monitor == NULL) { + char label[32]; + + monitor = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec)); + XmuSnprintf(label, sizeof(label), "Monitor%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Monitor identifier", + "Enter an identifier for your monitor definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)monitor); + return (-1); + } + } + + if (monitor->mon_identifier == NULL) { + ClearScreen(); + refresh(); + i = Dialog("Monitor configuration", + "Now we want to set the specifications of the monitor. The " + "two critical parameters are the vertical refresh rate, which " + "is the rate at which the whole screen is refreshed, and most " + "importantly the horizontal sync rate, which is the rate at " + "which scanlines are displayed.\n" + "\n" + "The valid range for horizontal sync and vertical sync should " + "be documented in the manual of your monitor.", + 15, 60, " Next >>", " Cancel ", 0); + if (i != 0) { + XtFree(identifier); + XtFree((XtPointer)monitor); + return (-1); + } + } + + def = 0; + if (monitor->mon_identifier) { + int len; + + parser_range_to_string(hsync_str, &(monitor->mon_hsync[0]), + monitor->mon_n_hsync); + len = strlen(hsync_str); + for (i = 1; i < sizeof(hsync) / sizeof(hsync[0]); i++) { + tmp = strchr(hsync[i], ';'); + if (strncmp(hsync_str, hsync[i], len) == 0) { + def = i; + break; + } + } + } + else + strcpy(hsync_str, "31.5"); + + ClearScreen(); + refresh(); + i = DialogMenu("Monitor HorizSync", + "You must indicate the horizontal sync range of your " + "monitor. You can either select one of the predefined " + "ranges below that correspond to industry-standard monitor " + "types, or give a specific range.", + 22, 78, 11, sizeof(hsync) / + sizeof(hsync[0]), hsync, " Next >>", " Cancel ", def); + if (i < 0) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + if (i == CONF_MONITOR_HSYNC) { + ClearScreen(); + refresh(); + tmp = DialogInput("Monitor HorizSync", + "Please enter the horizontal sync range of your " + "monitor, in the format used in the table of monitor " + "types above. You can either specify one or more " + "continuous ranges (e.g. 15-25, 30-50), or one or more " + "fixed sync frequencies.\n" + "\n" + "Horizontal sync range:", 16, 62, hsync_str, + " Ok ", " Cancel ", def); + if (tmp == NULL) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + XmuSnprintf(hsync_str, sizeof(hsync_str), "%s", tmp); + XtFree(tmp); + } + else { + tmp = strchr(hsync[i], ';'); + strncpy(hsync_str, hsync[i], tmp - hsync[i]); + hsync_str[tmp - hsync[i]] = '\0'; + } + + def = 0; + if (monitor->mon_identifier) { + parser_range_to_string(vrefresh_str, &(monitor->mon_vrefresh[0]), + monitor->mon_n_vrefresh); + for (i = 1; i < sizeof(vrefresh) / sizeof(vrefresh[0]); i++) { + if (strcmp(vrefresh_str, vrefresh[i]) == 0) { + def = i; + break; + } + } + } + else + strcpy(vrefresh_str, "50 - 70"); + ClearScreen(); + refresh(); + i = DialogMenu("Monitor VertRefresh", + "You must indicate the vertical sync range of your monitor. " + "You can either select one of the predefined ranges below " + "that correspond to industry-standard monitor types, or " + "give a specific range. For interlaced modes, the number " + "that counts is the high one (e.g. 87 Hz rather than 43 Hz).", + 19, 60, 5, sizeof(vrefresh) / + sizeof(vrefresh[0]), vrefresh, " Finish ", " Cancel ", def); + if (i < 0) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (i); + } + if (i == CONF_MONITOR_VREFRESH) { + ClearScreen(); + refresh(); + tmp = DialogInput("Monitor VertRefresh", + "Vertical sync range:", 10, 50, vrefresh_str, + " Done ", " Cancel ", 0); + if (tmp == NULL) { + if (monitor->mon_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)monitor); + } + return (-1); + } + XmuSnprintf(vrefresh_str, sizeof(vrefresh_str), "%s", tmp); + XtFree(tmp); + } + else + strcpy(vrefresh_str, vrefresh[i]); + + /* Finish monitor configuration */ + monitor->mon_n_hsync = string_to_parser_range(hsync_str, + &(monitor->mon_hsync[0]), CONF_MAX_HSYNC); + monitor->mon_n_vrefresh = string_to_parser_range(vrefresh_str, + &(monitor->mon_vrefresh[0]), CONF_MAX_VREFRESH); + if (monitor->mon_identifier == NULL) { + monitor->mon_identifier = identifier; + XF86Config->conf_monitor_lst = + xf86addMonitor(XF86Config->conf_monitor_lst, monitor); + } + + return (1); +} + +static int +CardConfig(void) +{ + int i; + XF86ConfDevicePtr *devices = NULL, device = XF86Config->conf_device_lst; + char **list = NULL, *identifier = NULL, *driver, *busid, *tmp; + int nlist, def; + CardsEntry *entry = NULL; +#ifdef USE_MODULES + static char **drivers; + static int ndrivers; + static char *path = NULL, *modules = "lib/modules"; + const char *subdirs[] = { + "drivers", + NULL + }; + + if (XF86Module_path == NULL) { + XF86Module_path = XtMalloc(strlen(XFree86Dir) + strlen(modules) + 2); + sprintf(XF86Module_path, "%s/%s", XFree86Dir, modules); + } + + if (drivers == NULL) { + xf86Verbose = 0; + LoaderInit(); + path = XtNewString(XF86Module_path); + LoaderSetPath(path); + drivers = LoaderListDirs((char**)subdirs, NULL); + for (; drivers[ndrivers]; ndrivers++) + ; + } +#else + static char *drivers[] = { + "apm", + "ark", + "ati", + "chips", + "cirrus", + "cyrix", + "fbdev", + "glint", + "i128", + "i740", + "i810", + "imstt", + "mga", + "neomagic", + "r128", + "radeon", + "rendition", + "s3virge", + "siliconmotion", + "sis", + "tdfx", + "tga", + "trident", + "tseng", + "vga", + "vesa", + }; + static int ndrivers = sizeof(drivers) / sizeof(drivers[0]); +#endif + + nlist = 0; + while (device) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(device->dev_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, device->dev_identifier); + devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) * + sizeof(XF86ConfDevicePtr)); + devices[nlist] = device; + ++nlist; + device = (XF86ConfDevicePtr)(device->list.next); + } + + device = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new card"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(devices[0]->dev_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", devices[0]->dev_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove device"); + ClearScreen(); + refresh(); + i = DialogMenu("Card configuration", + "You can edit or remove a previously configured " + "card, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove card", + "Select which card to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + return (-1); + } + device = devices[i]; + } + else + device = devices[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + xf86removeDevice(XF86Config, device); + return (0); + } + if (i < nlist - 2) + device = devices[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)devices); + + if (device == NULL) { + char label[32]; + + device = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec)); + device->dev_chipid = device->dev_chiprev = device->dev_irq = -1; + XmuSnprintf(label, sizeof(label), "Card%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Card identifier", + "Enter an identifier for your card definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)device); + return (-1); + } + } + + ClearScreen(); + refresh(); + if (Dialog("Card configuration", + "Now we must configure video card specific settings. At this " + "point you can choose to make a selection out of a database of " + "video card definitions.\n" + "\n" + "The database entries include information about the chipset, " + "what driver to run, the Ramdac and ClockChip, and comments " + "that will be included in the Device section. However, a lot " + "of definitions only hint about what driver to run (based on " + "the chipset the card uses) and are untested.\n" + "\n" + "Do you want to look at the card database?", + 18, 60, " Yes ", " No ", device->dev_identifier != NULL) == 0) { + static char **cards; + static int ncards; + + if (cards == NULL) { + ReadCardsDatabase(); + cards = GetCardNames(&ncards); + cards = (char**)XtRealloc((XtPointer)cards, + (ncards + 1) * sizeof(char*)); + for (i = ncards; i > 0; i--) + cards[i] = cards[i - 1]; + cards[0] = "** Unlisted card **"; + } + if (device->dev_card) + entry = LookupCard(device->dev_card); + def = 0; + if (entry) { + for (i = 0; i < NumCardsEntry; i++) + if (strcasecmp(CardsDB[i]->name, entry->name) == 0) { + def = i + 1; + break; + } + /* make sure entry is set to null again */ + entry = NULL; + } + + i = DialogMenu("Card database", + "Select name that better matches your card:", + 20, 70, 11, ncards, cards, "Next >>", " Cancel ", def); + if (i > 0) + entry = LookupCard(cards[i]); + } + + def = 0; + tmp = device->dev_driver ? device->dev_driver : entry && entry->driver ? + entry->driver : "vga"; + for (i = 0; i < ndrivers; i++) + if (strcmp(drivers[i], tmp) == 0) { + def = i; + break; + } + + ClearScreen(); + refresh(); + i = DialogMenu("Card driver", + "You can select the driver for your card here, or just press " + "Enter to use the default/current:", 20, 50, 9, + ndrivers, drivers, " Ok ", " Cancel ", def); + if (i < 0) { + if (device->dev_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)device); + } + return (-1); + } + driver = ndrivers ? drivers[i] : "vga"; + + ClearScreen(); + refresh(); + tmp = device->dev_busid ? device->dev_busid : ""; + busid = DialogInput("Card BusID", + "You normally does not need to fill this field " + "if you have only one video card:", 11, 50, tmp, + " Finish ", " Cancel ", 0); + + /* Finish card configuration */ + if (entry) { + XtFree(device->dev_card); + device->dev_card = XtNewString(entry->name); + if (entry->chipset) { + XtFree(device->dev_chipset); + device->dev_chipset = XtNewString(entry->chipset); + } + if (entry->ramdac) { + XtFree(device->dev_ramdac); + device->dev_ramdac = XtNewString(entry->ramdac); + } + if (entry->clockchip) { + XtFree(entry->clockchip); + device->dev_clockchip = XtNewString(entry->clockchip); + } + } + if (busid) { + XtFree(device->dev_busid); + if (*busid) + device->dev_busid = busid; + else { + device->dev_busid = NULL; + XtFree(busid); + } + } + XtFree(device->dev_driver); + device->dev_driver = XtNewString(driver); + if (device->dev_identifier == NULL) { + device->dev_identifier = identifier; + XF86Config->conf_device_lst = + xf86addDevice(XF86Config->conf_device_lst, device); + } + + return (1); +} + +static char *depths[] = { + "1 bit, monochrome", + "4 bit, 16 colors", + "8 bit, 256 colors", + "15 bits, 32Kb colors", + "16 bits, 65Kb colors", + "24 bits, 16Mb colors", +}; + +static char *modes[] = { + "1600x1200", + "1280x1024", + "1280x960", + "1152x864", + "1024x768", + "800x600", + "640x480", + "640x400", + "512x384", + "400x300", + "320x240", + "320x200", +}; + +static int +ScreenConfig(void) +{ + int i, disp_allocated; + XF86ConfScreenPtr *screens = NULL, screen = XF86Config->conf_screen_lst; + char **list = NULL, *identifier = NULL; + int nlist, def; + XF86ConfDevicePtr device; + XF86ConfMonitorPtr monitor; + XF86ConfDisplayPtr display; + XF86ModePtr mode, ptr; + char *checks; + + nlist = 0; + while (screen) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(screen->scrn_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, screen->scrn_identifier); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, (nlist + 1) * + sizeof(XF86ConfScreenPtr)); + screens[nlist] = screen; + ++nlist; + screen = (XF86ConfScreenPtr)(screen->list.next); + } + + screen = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new screen"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(screens[0]->scrn_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", screens[0]->scrn_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove screen"); + ClearScreen(); + refresh(); + i = DialogMenu("Screen configuration", + "You can edit or remove a previously configured " + "screen, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove screen", + "Select which screen to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + return (-1); + } + screen = screens[i]; + } + else + screen = screens[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + xf86removeScreen(XF86Config, screen); + return (0); + } + if (i < nlist - 2) + screen = screens[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + + if (screen == NULL) { + char label[256]; + XF86ConfDevicePtr *devices = NULL; + XF86ConfMonitorPtr *monitors = NULL; + + device = XF86Config->conf_device_lst; + monitor = XF86Config->conf_monitor_lst; + + if (device == NULL || monitor == NULL) { + ClearScreen(); + refresh(); + Dialog("Configuration error", + "You need to configure (at least) one card and one " + "monitor before creating a screen definition.", + 9, 50, " Ok ", NULL, 0); + + return (-1); + } + + XmuSnprintf(label, sizeof(label), "Screen%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Screen identifier", + "Enter an identifier for your screen definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) + return (-1); + + nlist = 0; + list = NULL; + while (device) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtNewString(device->dev_identifier); + devices = (XF86ConfDevicePtr*)XtRealloc((XtPointer)devices, (nlist + 1) * + sizeof(XF86ConfDevicePtr)); + devices[nlist] = device; + ++nlist; + device = (XF86ConfDevicePtr)(device->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Screen card", "Please select a video card:", + 13, 60, 4, nlist, list, " Next >>", " Cancel ", 0); + for (def = 0; def < nlist; def++) + XtFree(list[def]); + XtFree((XtPointer)list); + if (i < 0) { + XtFree(identifier); + XtFree((XtPointer)devices); + return (-1); + } + device = devices[i]; + XtFree((XtPointer)devices); + + nlist = 0; + list = NULL; + while (monitor) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtNewString(monitor->mon_identifier); + monitors = (XF86ConfMonitorPtr*)XtRealloc((XtPointer)monitors, (nlist + 1) * + sizeof(XF86ConfMonitorPtr)); + monitors[nlist] = monitor; + ++nlist; + monitor = (XF86ConfMonitorPtr)(monitor->list.next); + } + XmuSnprintf(label, sizeof(label), + "Select the monitor connected to \"%s\":", + device->dev_identifier); + ClearScreen(); + refresh(); + i = DialogMenu("Screen monitor", label, + 13, 60, 4, nlist, list, " Next >>", " Cancel ", 0); + for (def = 0; def < nlist; def++) + XtFree(list[def]); + XtFree((XtPointer)list); + if (i < 0) { + XtFree(identifier); + XtFree((XtPointer)monitors); + return (-1); + } + monitor = monitors[i]; + XtFree((XtPointer)monitors); + + screen = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec)); + screen->scrn_device = device; + screen->scrn_monitor = monitor; + } + + if (screen->scrn_defaultdepth == 1) + def = 0; + else if (screen->scrn_defaultdepth == 4) + def = 1; + else if (screen->scrn_defaultdepth == 8) + def = 2; + else if (screen->scrn_defaultdepth == 15) + def = 3; + else if (screen->scrn_defaultdepth == 16) + def = 4; + else if (screen->scrn_defaultdepth == 24) + def = 5; + else + def = 2; + ClearScreen(); + refresh(); + i = DialogMenu("Screen depth", + "Please specify which color depth you want to use by default:", + 15, 60, 6, sizeof(depths) / sizeof(depths[0]), depths, + " Next >>", " Cancel ", def); + if (i < 0) { + if (screen->scrn_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)screen); + } + return (-1); + } + else + /* XXX depths must begin with the depth number */ + screen->scrn_defaultdepth = atoi(depths[i]); + + def = 0; /* use def to count how many modes are selected*/ + nlist = 0; + list = NULL; + checks = XtMalloc(sizeof(modes) / sizeof(modes[0])); + /* XXX list fields in the code below are not allocated */ + disp_allocated = 0; + display = screen->scrn_display_lst; + while (display && display->disp_depth != screen->scrn_defaultdepth) + display = (XF86ConfDisplayPtr)(display->list.next); + if (display == NULL) { + display = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); + display->disp_white.red = display->disp_black.red = -1; + display->disp_depth = screen->scrn_defaultdepth; + disp_allocated = 1; + } + else { + mode = display->disp_mode_lst; + while (mode) { + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + if (strcmp(modes[i], mode->mode_name) == 0) { + break; + } + + if (i == sizeof(modes) / sizeof(modes[0])) { + list = (char**)XtRealloc((XtPointer)list, + (nlist + 1) * sizeof(char*)); + list[nlist] = mode->mode_name; + checks = XtRealloc(checks, sizeof(modes) / sizeof(modes[0]) + + nlist + 1); + checks[nlist] = 1; + ++def; + nlist++; + break; + } + mode = (XF86ModePtr)(mode->list.next); + } + } + + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + checks[i + nlist] = 0; + + mode = display->disp_mode_lst; + while (mode) { + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + if (strcmp(modes[i], mode->mode_name) == 0) { + ++def; + checks[i + nlist] = 1; + break; + } + mode = (XF86ModePtr)(mode->list.next); + } + + if (nlist == 0 && def == 0) + checks[6] = 1; /* 640x480 */ + list = (char**)XtRealloc((XtPointer)list, (nlist + sizeof(modes) / + sizeof(modes[0])) * sizeof(char*)); + for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) + list[i + nlist] = modes[i]; + nlist += sizeof(modes) / sizeof(modes[0]); + + ClearScreen(); + refresh(); + i = DialogCheckBox("Screen modes", + "Select the video modes for this screen:", + 17, 60, 8, sizeof(modes) / sizeof(modes[0]), modes, + " Finish ", " Cancel ", checks); + if (i < 0) { + if (screen->scrn_identifier == NULL) { + XtFree(identifier); + XtFree((XtPointer)screen); + XtFree((XtPointer)list); + if (disp_allocated) + XtFree((XtPointer)display); + } + return (-1); + } + + mode = display->disp_mode_lst; + while (mode) { + ptr = (XF86ModePtr)(mode->list.next); + XtFree(mode->mode_name); + XtFree((XtPointer)mode); + mode = ptr; + } + display->disp_mode_lst = NULL; + + for (i = 0; i < nlist; i++) { + if (checks[i]) { + mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec)); + mode->mode_name = XtNewString(list[i]); + if (display->disp_mode_lst == NULL) + display->disp_mode_lst = ptr = mode; + else { + ptr->list.next = mode; + ptr = mode; + } + } + } + XtFree((XtPointer)list); + + if (disp_allocated) { + display->list.next = screen->scrn_display_lst; + if (screen->scrn_display_lst == NULL) + screen->scrn_display_lst = display; + else + screen->scrn_display_lst->list.next = display; + } + + if (screen->scrn_identifier == NULL) { + screen->scrn_identifier = identifier; + screen->scrn_monitor_str = XtNewString(monitor->mon_identifier); + screen->scrn_device_str = XtNewString(device->dev_identifier); + XF86Config->conf_screen_lst = + xf86addScreen(XF86Config->conf_screen_lst, screen); + } + + return (1); +} + +static XF86ConfAdjacencyPtr +CopyAdjacency(XF86ConfAdjacencyPtr ptr) +{ + XF86ConfAdjacencyPtr adj = (XF86ConfAdjacencyPtr) + XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + + adj->adj_scrnum = ptr->adj_scrnum; + adj->adj_screen = ptr->adj_screen; + adj->adj_screen_str = XtNewString(adj->adj_screen_str); + adj->adj_top = ptr->adj_top; + if (ptr->adj_top_str) + adj->adj_top_str = XtNewString(ptr->adj_top_str); + adj->adj_bottom = ptr->adj_bottom; + if (ptr->adj_bottom_str) + adj->adj_bottom_str = XtNewString(ptr->adj_bottom_str); + adj->adj_left = ptr->adj_left; + if (ptr->adj_left_str) + adj->adj_left_str = XtNewString(ptr->adj_left_str); + adj->adj_right = ptr->adj_right; + if (ptr->adj_right_str) + adj->adj_right_str = XtNewString(ptr->adj_right_str); + adj->adj_where = ptr->adj_where; + adj->adj_x = ptr->adj_x; + adj->adj_y = ptr->adj_y; + if (ptr->adj_refscreen) + adj->adj_refscreen = XtNewString(ptr->adj_refscreen); + + return (adj); +} + +static XF86ConfInactivePtr +CopyInactive(XF86ConfInactivePtr ptr) +{ + XF86ConfInactivePtr inac = (XF86ConfInactivePtr) + XtCalloc(1, sizeof(XF86ConfInactiveRec)); + + inac->inactive_device = ptr->inactive_device; + if (ptr->inactive_device_str) + inac->inactive_device_str = XtNewString(ptr->inactive_device_str); + + return (inac); +} + +static XF86ConfInputrefPtr +CopyInputref(XF86ConfInputrefPtr ptr) +{ + XF86ConfInputrefPtr iref = (XF86ConfInputrefPtr) + XtCalloc(1, sizeof(XF86ConfInputrefRec)); + XF86OptionPtr opt = ptr->iref_option_lst; + + iref->iref_inputdev = ptr->iref_inputdev; + if (ptr->iref_inputdev_str) + iref->iref_inputdev_str = XtNewString(ptr->iref_inputdev_str); + while (opt) { + iref->iref_option_lst = xf86addNewOption(iref->iref_option_lst, + XtNewString(opt->opt_name), + opt->opt_val ? XtNewString(opt->opt_val) : NULL); + opt = (XF86OptionPtr)(opt->list.next); + } + + return (iref); +} + +static XF86ConfLayoutPtr +CopyLayout(XF86ConfLayoutPtr ptr) +{ + XF86ConfLayoutPtr lay = (XF86ConfLayoutPtr) + XtCalloc(1, sizeof(XF86ConfLayoutRec)); + XF86ConfAdjacencyPtr adj = ptr->lay_adjacency_lst, padj; + XF86ConfInactivePtr inac = ptr->lay_inactive_lst, pinac; + XF86ConfInputrefPtr iref = ptr->lay_input_lst, piref; + XF86OptionPtr opt = ptr->lay_option_lst; + + if (ptr->lay_identifier) + lay->lay_identifier = XtNewString(ptr->lay_identifier); + if (adj) { + padj = lay->lay_adjacency_lst = CopyAdjacency(adj); + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + while (adj) { + padj->list.next = CopyAdjacency(adj); + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + } + if (inac) { + pinac = lay->lay_inactive_lst = CopyInactive(inac); + inac = (XF86ConfInactivePtr)(inac->list.next); + while (inac) { + pinac->list.next = CopyInactive(inac); + pinac = (XF86ConfInactivePtr)(pinac->list.next); + inac = (XF86ConfInactivePtr)(inac->list.next); + } + } + if (iref) { + piref = lay->lay_input_lst = CopyInputref(iref); + iref = (XF86ConfInputrefPtr)(iref->list.next); + while (iref) { + piref->list.next = CopyInputref(iref); + piref = (XF86ConfInputrefPtr)(piref->list.next); + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + while (opt) { + lay->lay_option_lst = xf86addNewOption(lay->lay_option_lst, + XtNewString(opt->opt_name), + opt->opt_val ? XtNewString(opt->opt_val) : NULL); + opt = (XF86OptionPtr)(opt->list.next); + } + + return (lay); +} + +static void +FreeLayout(XF86ConfLayoutPtr lay) +{ + static XF86ConfigRec xf86config; + + xf86config.conf_layout_lst = lay; + xf86removeLayout(&xf86config, lay); +} + +static int +LayoutConfig(void) +{ + int i; + XF86ConfLayoutPtr *layouts = NULL, rlayout = NULL, + layout = XF86Config->conf_layout_lst; + XF86ConfInputPtr input = XF86Config->conf_input_lst; + char **list = NULL, *identifier = NULL; + XF86ConfInputPtr *mouses = NULL, *keyboards = NULL, mouse, keyboard; + XF86ConfInputrefPtr iref, piref, mref, kref; + XF86ConfAdjacencyPtr adj, padj; + int nmouses, nkeyboards; + int nlist; + XF86OptionPtr option; + XF86ConfScreenPtr screen, *screens; + + nmouses = nkeyboards = 0; + while (input) { + if (strcmp(input->inp_driver, "mouse") == 0) { + mouses = (XF86ConfInputPtr*)XtRealloc((XtPointer)mouses, + (nmouses + 1) * sizeof(XF86ConfInputPtr)); + mouses[nmouses] = input; + ++nmouses; + } + else if (strcmp(input->inp_driver, "keyboard") == 0) { + keyboards = (XF86ConfInputPtr*)XtRealloc((XtPointer)keyboards, + (nkeyboards + 1) * sizeof(XF86ConfInputPtr)); + keyboards[nkeyboards] = input; + ++nkeyboards; + } + input = (XF86ConfInputPtr)(input->list.next); + } + if (XF86Config->conf_screen_lst == NULL || + nmouses == 0 || nkeyboards == 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + ClearScreen(); + refresh(); + Dialog("Configuration error", + "You need to configure (at least) one screen, mouse " + "and keyboard before creating a layout definition.", + 9, 50, " Ok ", NULL, 0); + return (-1); + } + + nlist = 0; + while (layout) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist] = XtMalloc(sizeof(Edit) + + strlen(layout->lay_identifier) + 1); + sprintf(list[nlist], "%s%s", Edit, layout->lay_identifier); + layouts = (XF86ConfLayoutPtr*)XtRealloc((XtPointer)layouts, (nlist + 1) * + sizeof(XF86ConfLayoutPtr)); + layouts[nlist] = layout; + ++nlist; + layout = (XF86ConfLayoutPtr)(layout->list.next); + } + + layout = NULL; + + if (nlist) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 2) * sizeof(char*)); + list[nlist++] = XtNewString("Add new layout"); + if (nlist == 2) { + i = strlen("Remove ") + strlen(layouts[0]->lay_identifier) + 1; + list[nlist] = XtMalloc(i); + XmuSnprintf(list[nlist], i, "Remove %s", layouts[0]->lay_identifier); + ++nlist; + } + else + list[nlist++] = XtNewString("Remove layout"); + ClearScreen(); + refresh(); + i = DialogMenu("Layout configuration", + "You can edit or remove a previously configured " + "layout, or add a new one.", 14, 60, 4, nlist, list, + " Ok ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + if (nlist > 2 && i == nlist - 1) { + if (nlist > 3) { + for (i = 0; i < nlist - 2; i++) { + /* XXX Remove the "Edit " from list entries */ + memmove(list[i], list[i] + sizeof(Edit) - 1, + strlen(list[i]) - sizeof(Edit) + 2); + } + ClearScreen(); + refresh(); + i = DialogMenu("Remove layout", + "Select which layout to remove", + 13, 60, 4, nlist - 2, list, + " Remove ", " Cancel ", 0); + if (i < 0) { + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + layout = layouts[i]; + } + else + layout = layouts[0]; + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + xf86removeLayout(XF86Config, layout); + return (0); + } + if (i < nlist - 2) + layout = layouts[i]; + } + for (i = 0; i < nlist; i++) + XtFree(list[i]); + XtFree((XtPointer)list); + XtFree((XtPointer)layouts); + + if (layout == NULL) { + char label[32]; + + layout = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec)); + XmuSnprintf(label, sizeof(label), "Layout%d", nlist ? nlist - 2 : 0); + ClearScreen(); + refresh(); + identifier = + DialogInput("Layout identifier", + "Enter an identifier for your layout definition:", + 11, 40, label, + " Next >>", " Cancel ", 0); + if (identifier == NULL) { + XtFree((XtPointer)layout); + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + return (-1); + } + } + else { + /* So that we can safely change it */ + rlayout = layout; + layout = CopyLayout(rlayout); + } + + + mouse = keyboard = NULL; + + /* Mouse */ + piref = NULL; + iref = layout->lay_input_lst; + while (iref) { + if (strcmp(iref->iref_inputdev->inp_driver, "mouse") == 0) { + if (mouse == NULL) + piref = iref; + if (xf86findOption(iref->iref_option_lst, "CorePointer")) { + mouse = iref->iref_inputdev; + piref = iref; + break; + } + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + if (mouse == NULL) { + if (piref) { + mref = piref; + mouse = piref->iref_inputdev; + piref->iref_option_lst = + xf86addNewOption(piref->iref_option_lst, + XtNewString("CorePointer"), NULL); + } + else { + mouse = mouses[0]; + mref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + iref->iref_inputdev_str = XtNewString(mouse->inp_identifier); + iref->iref_inputdev = mouse; + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CorePointer"), NULL); + iref->list.next = layout->lay_input_lst; + if (layout->lay_input_lst == NULL) + layout->lay_input_lst = iref; + else { + iref->list.next = layout->lay_input_lst; + layout->lay_input_lst = iref; + } + } + } + else + mref = piref; + + /* XXX list fields are not allocated */ + if (nmouses > 1) { + nlist = 0; + list = (char**)XtMalloc(sizeof(char*)); + list[nlist++] = mouse->inp_identifier; + input = XF86Config->conf_input_lst; + while (input) { + if (input != mouse && strcmp(input->inp_driver, "mouse") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist++] = input->inp_identifier; + } + input = (XF86ConfInputPtr)(input->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Select Core Pointer", + "Select the mouse connected to you computer", + 12, 60, 4, nlist, list, " Ok ", " Cancel ", 0); + if (i < 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + XtFree((XtPointer)list); + if (layout->lay_identifier == NULL) + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + if (i > 0) { + /* Did not select the default one */ + iref = layout->lay_input_lst; + while (iref) { + if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) { + if ((option = xf86findOption(iref->iref_option_lst, + "SendCoreEvents")) != NULL) { + XtFree(option->opt_name); + option->opt_name = XtNewString("CorePointer"); + } + else + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + "CorePointer", NULL); + option = xf86findOption(mref->iref_option_lst, + "CorePointer"); + XtFree(option->opt_name); + option->opt_name = XtNewString("SendCoreEvents"); + break; + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + /* XXX Write code to add/remove more mouses here */ + } + + + /* Keyboard */ + piref = NULL; + iref = layout->lay_input_lst; + while (iref) { + if (strcmp(iref->iref_inputdev->inp_driver, "keyboard") == 0) { + if (keyboard == NULL) + piref = iref; + if (xf86findOption(iref->iref_option_lst, "CoreKeyboard")) { + keyboard = iref->iref_inputdev; + piref = iref; + break; + } + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + if (keyboard == NULL) { + if (piref) { + kref = piref; + keyboard = piref->iref_inputdev; + piref->iref_option_lst = + xf86addNewOption(piref->iref_option_lst, + XtNewString("CoreKeyboard"), NULL); + } + else { + keyboard = keyboards[0]; + kref = iref = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec)); + iref->iref_inputdev_str = XtNewString(keyboard->inp_identifier); + iref->iref_inputdev = keyboard; + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + XtNewString("CoreKeyboard"), NULL); + iref->list.next = layout->lay_input_lst; + if (layout->lay_input_lst == NULL) + layout->lay_input_lst = iref; + else { + iref->list.next = layout->lay_input_lst; + layout->lay_input_lst = iref; + } + } + } + else + kref = piref; + + /* XXX list fields are not allocated */ + if (nkeyboards > 1) { + nlist = 0; + list = (char**)XtMalloc(sizeof(char*)); + list[nlist++] = keyboard->inp_identifier; + input = XF86Config->conf_input_lst; + while (input) { + if (input != keyboard && strcmp(input->inp_driver, "keyboard") == 0) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + list[nlist++] = input->inp_identifier; + } + input = (XF86ConfInputPtr)(input->list.next); + } + ClearScreen(); + refresh(); + i = DialogMenu("Select Core Keyboard", + "Select the keyboard connected to you computer", + 12, 60, 4, nlist, list, " Ok ", " Cancel ", 0); + if (i < 0) { + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + XtFree((XtPointer)list); + if (layout->lay_identifier == NULL) + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + if (i > 0) { + /* Did not select the default one */ + iref = layout->lay_input_lst; + while (iref) { + if (strcasecmp(iref->iref_inputdev_str, list[i]) == 0) { + if ((option = xf86findOption(iref->iref_option_lst, + "SendCoreEvents")) != NULL) { + XtFree(option->opt_name); + option->opt_name = XtNewString("CoreKeyboard"); + } + else + iref->iref_option_lst = + xf86addNewOption(iref->iref_option_lst, + "CoreKeyboard", NULL); + option = xf86findOption(kref->iref_option_lst, + "CoreKeyboard"); + XtFree(option->opt_name); + option->opt_name = XtNewString("SendCoreEvents"); + break; + } + iref = (XF86ConfInputrefPtr)(iref->list.next); + } + } + + /* XXX Write code to add/remove more keyboards here */ + } + + XtFree((XtPointer)mouses); + XtFree((XtPointer)keyboards); + + /* Just one screen */ + if (XF86Config->conf_screen_lst->list.next == NULL) { + ClearScreen(); + refresh(); + Dialog("Layout configuration", + (nmouses > 1 && nkeyboards > 1) ? + "As you have only one screen configured, I can now finish " + "creating this Layout configuration." + : + "As you have only one screen, mouse and keyboard configured, " + "I can now finish creating this Layout configuration.", + 12, 60, " Finish ", NULL, 0); + + goto LayoutFinish; + } + + + /* The code below just adds a screen to the right of the last + * one, or allows removing a screen. + * Needs some review, and adding more options. + */ + + /*CONSTCOND*/ + while (1) { + static char *screen_opts[] = { + "Add a new screen to layout", + "Remove screen from layout", + "Finish layout configuration", + }; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout configuration", "Please choose one option:", + 12, 60, 3, sizeof(screen_opts) / sizeof(screen_opts[0]), + screen_opts, " Done ", " Cancel all changes ", 2); + + /* cancel */ + if (i < 0) { + XtFree(identifier); + FreeLayout(layout); + return (-1); + } + + /* add new screen */ + else if (i == 0) { + nlist = 0; + list = NULL; + screens = NULL; + screen = XF86Config->conf_screen_lst; + while (screen) { + adj = layout->lay_adjacency_lst; + while (adj) { + if (adj->adj_screen == screen) + break; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + if (adj == NULL) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, + (nlist + 1) * sizeof(XF86ConfScreenPtr)); + /* NOT duplicated */ + list[nlist] = screen->scrn_identifier; + screens[nlist] = screen; + ++nlist; + } + screen = (XF86ConfScreenPtr)(screen->list.next); + } + + if (nlist == 0) + continue; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout add screen", "Choose screen to add:", + 12, 60, 3, nlist, list, + " Add ", " Cancel ", 0); + if (i >= 0) { + padj = layout->lay_adjacency_lst; + adj = (XF86ConfAdjacencyPtr) + XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = screens[i]; + if (padj == NULL) { + adj->adj_where = CONF_ADJ_ABSOLUTE; + layout->lay_adjacency_lst = adj; + } + else { + while (padj->list.next) + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + padj->list.next = adj; + adj->adj_where = CONF_ADJ_RIGHTOF; + adj->adj_refscreen = + XtNewString(padj->adj_screen->scrn_identifier); + } + } + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + } + + /* remove a screen */ + else if (i == 1) { + nlist = 0; + list = NULL; + screens = NULL; + adj = layout->lay_adjacency_lst; + + while (adj) { + list = (char**)XtRealloc((XtPointer)list, (nlist + 1) * sizeof(char*)); + screens = (XF86ConfScreenPtr*)XtRealloc((XtPointer)screens, + (nlist + 1) * sizeof(XF86ConfScreenPtr)); + list[nlist] = adj->adj_screen->scrn_identifier; + screens[nlist] = adj->adj_screen; + ++nlist; + adj = (XF86ConfAdjacencyPtr)(adj->list.next); + } + + if (nlist == 0) + continue; + + ClearScreen(); + refresh(); + i = DialogMenu("Layout remove screen", "Choose screen to remove:", + 12, 60, 3, nlist, list, + " Remove ", " Cancel ", 0); + + adj = padj = layout->lay_adjacency_lst; + while (adj) { + if (adj->adj_screen == screens[i]) { + padj = (XF86ConfAdjacencyPtr)(padj->list.next); + if (padj && adj->adj_where == CONF_ADJ_RIGHTOF && + padj->adj_where == CONF_ADJ_RIGHTOF) { + XtFree(padj->adj_refscreen); + padj->adj_refscreen = XtNewString(adj->adj_refscreen); + } + xf86removeAdjacency(layout, adj); + break; + } + padj = adj; + adj = (XF86ConfAdjacencyPtr)(padj->list.next); + } + XtFree((XtPointer)list); + XtFree((XtPointer)screens); + } + + /* finish screen configuration */ + else + break; + } + +LayoutFinish: + if (layout->lay_adjacency_lst == NULL) { + adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec)); + adj->adj_screen = XF86Config->conf_screen_lst; + adj->adj_screen_str = XtNewString(XF86Config->conf_screen_lst->scrn_identifier); + adj->adj_where = CONF_ADJ_ABSOLUTE; + layout->lay_adjacency_lst = adj; + } + if (rlayout) { + /* just edited this layout */ + if (nmouses > 1 || nkeyboards > 1) { + XF86ConfAdjacencyPtr tadj = rlayout->lay_adjacency_lst; + XF86ConfInactivePtr tinac = rlayout->lay_inactive_lst; + XF86ConfInputrefPtr tinp = rlayout->lay_input_lst; + + rlayout->lay_adjacency_lst = layout->lay_adjacency_lst; + rlayout->lay_inactive_lst = layout->lay_inactive_lst; + rlayout->lay_input_lst = layout->lay_input_lst; + + layout->lay_adjacency_lst = tadj; + layout->lay_inactive_lst = tinac; + layout->lay_input_lst = tinp; + FreeLayout(layout); + } + return (0); + } + else { + layout->lay_identifier = identifier; + XF86Config->conf_layout_lst = + xf86addLayout(XF86Config->conf_layout_lst, layout); + } + + return (1); +} + +static void +ClearScreen(void) +{ + int i, j; + + wattrset(stdscr, screen_attr); + for (i = 0; i < LINES; i++) { + wmove(stdscr, i, 0); + for (j = 0; j < COLS; j++) + waddch(stdscr, ACS_PLUS); + } + touchwin(stdscr); +} + +static int +Dialog(char *title, char * prompt, int height, int width, + char *label1, char *label2, int button) +{ + int x, x1, x2, y, key, l1len, l2len; + WINDOW *dialog; + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + if (label2) + l2len = strlen(label2); + else { + l2len = button = 0; + } + + x1 = (width - (l1len + l2len)) / (label2 ? 3 : 2); + x2 = x1 + x1 + l1len; + y = height - 3; + if (!button) { + if (label2) + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + else { + PaintButton(dialog, label1, y, x1, FALSE); + if (label2) + PaintButton(dialog, label2, y, x2, TRUE); + } + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + key = wgetch(dialog); + switch (key) { + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + if (label2) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + + } + else { + if (label2) { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + } + wrefresh(dialog); + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return button; + } + } + /*NOTREACHED*/ +} + +static void +PaintWindow(WINDOW *win, char *title_str, int y, int x, int height, int width) +{ + int i, j; + + if (title_str != NULL) { + j = (width - strlen(title_str)) / 2 - 1; + + wattrset(win, title_attr); + wmove(win, x, y); + for (i = 0; i < j; i++) + waddch(win, ' '); + waddstr(win, title_str); + for (; i < width; i++) + waddch(win, ' '); + } + + wattrset(win, 0); + + for (i = 1; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (i == height - 1 && !j) + waddch(win, highlight_border_attr | ACS_LLCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, shadow_border_attr | ACS_LRCORNER); + else if (i == height - 1) + waddch(win, shadow_border_attr | ACS_HLINE); + else if (!j) + waddch(win, highlight_border_attr | ACS_VLINE); + else if (j == width - 1) + waddch(win, shadow_border_attr | ACS_VLINE); + else + waddch(win, dialog_attr | ' '); + } + +} + +static void +PaintBox(WINDOW *win, int y, int x, int height, int width) +{ + int i, j; + + wattrset(win, 0); + + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, shadow_border_attr | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, shadow_border_attr | ACS_LLCORNER); + else if (!i && j == width-1) + waddch(win, highlight_border_attr | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, highlight_border_attr | ACS_LRCORNER); + else if (!i) + waddch(win, shadow_border_attr | ACS_HLINE); + else if (i == height - 1) + waddch(win, highlight_border_attr | ACS_HLINE); + else if (!j) + waddch(win, shadow_border_attr | ACS_VLINE); + else if (j == width - 1) + waddch(win, highlight_border_attr | ACS_VLINE); + else + waddch(win, dialog_attr | ' '); + } + +} + +static void +PaintButton(WINDOW *win, char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, selected ? "[" : " "); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? button_active_attr : button_inactive_attr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddch(win, label[0]); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, label + 1); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, selected ? "]" : " "); + wmove(win, y, x + temp + 1); +} + +static void +PrintWrap(WINDOW *win, char *prompt, int width, int y, int x) +{ + int cur_x, cur_y, len, yinc; + char *word, *tempstr = XtMalloc(strlen(prompt) + 1); + + cur_x = x; + cur_y = y; + + while (*prompt == '\n') { + ++cur_y; + ++prompt; + } + + strcpy(tempstr, prompt); + + for (word = strtok(tempstr, " \n"); word != NULL; word = strtok(NULL, " \n")) { + yinc = 0; + len = strlen(word); + while (prompt[word - tempstr + len + yinc] == '\n') + ++yinc; + if (cur_x + strlen(word) > width) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + if (yinc) { + cur_y += yinc; + cur_x = x; + } + else + cur_x++; + } + + free(tempstr); +} + +static int +DialogMenu(char *title, char *prompt, int height, int width, int menu_height, + int item_no, char **items, char *label1, char *label2, int choice) +{ + int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, + scroll = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len; + WINDOW *dialog, *menu; + + max_choice = MIN(menu_height, item_no); + max_scroll = MAX(0, item_no - max_choice); + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + menu_width = width - 6; + getyx(dialog, cur_y, cur_x); + box_y = cur_y + 1; + box_x = (width - menu_width) / 2 - 1; + + menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2); + + item_x = 3; + + if (choice > menu_height) { + scroll = MIN(max_scroll, choice); + choice -= scroll; + } + + for (i = 0; i < max_choice; i++) + PaintItem(menu, items[i + scroll], i, i == choice); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + i = choice; + key = wgetch(dialog); + + if (menu_height > 1 && key == KEY_PPAGE) { + if (!choice) { + if (scroll) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + + nscroll = max_choice > scroll ? -scroll : -max_choice; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + PaintItem(menu, items[i = scroll + nscroll], 0, TRUE); + for (++i; i <= scroll; i++) + PaintItem(menu, items[i], i - (scroll + nscroll), FALSE); + scroll += nscroll; + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = 0; + } + else if (menu_height > 1 && key == KEY_NPAGE) { + if (choice == max_choice - 1) { + if (scroll < max_scroll) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + + nscroll = (scroll + max_choice > max_scroll ? + max_scroll : scroll + max_choice) - scroll; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + scroll += nscroll; + for (i = 0; i < max_choice - 1; i++) + PaintItem(menu, items[i + scroll], i, FALSE); + PaintItem(menu, items[i + scroll], max_choice - 1, TRUE); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = max_choice - 1; + } + else if (key == KEY_UP) { + if (!choice) { + if (scroll) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintItem(menu, items[scroll], 0, FALSE); + scrollok(menu, TRUE); + wscrl(menu, - 1); + scrollok(menu, FALSE); + } + scroll--; + PaintItem(menu, items[scroll], 0, TRUE); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = choice - 1; + } + else if (key == KEY_DOWN) { + if (choice == max_choice - 1) { + if (scroll + choice < item_no - 1) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintItem(menu, items[scroll + max_choice - 1], max_choice - 1, FALSE); + scrollok(menu, TRUE); + scroll(menu); + scrollok(menu, FALSE); + } + scroll++; + PaintItem(menu, items[scroll + max_choice - 1], max_choice - 1, TRUE); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = MIN(choice + 1, item_no - 1); + } + + if (i != choice) { + getyx(dialog, cur_y, cur_x); + PaintItem(menu, items[scroll + choice], choice, FALSE); + + choice = i; + PaintItem(menu, items[scroll + choice], choice, TRUE); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + continue; + } + + switch (key) { + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + else { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + wrefresh(dialog); + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return (!button ? scroll + choice : -1); + default: + for (i = scroll + choice + 1; i < item_no; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + if (i == item_no) { + for (i = 0; i < scroll + choice; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + } + getyx(dialog, cur_y, cur_x); + if (i < item_no && i != scroll + choice) { + if (i >= scroll && i < scroll + max_choice) { + /* it is already visible */ + PaintItem(menu, items[scroll + choice], choice, FALSE); + choice = i - scroll; + } + else { + scroll = MIN(i, max_scroll); + choice = i - scroll; + for (i = 0; i < max_choice; i++) + if (i != choice) + PaintItem(menu, items[scroll + i], i, FALSE); + } + PaintItem(menu, items[scroll + choice], choice, TRUE); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + } + break; + } + } + /*NOTREACHED*/ +} + +static void +PaintItem(WINDOW *win, char *item, int choice, int selected) +{ + int i; + + wattrset(win, selected ? title_attr : dialog_attr); + wmove(win, choice, 1); + for (i = 1; i < menu_width; i++) + waddch(win, ' '); + wmove(win, choice, item_x); + wattrset(win, selected ? title_attr : dialog_attr); + waddstr(win, item); +} + +static void +PaintScroller(WINDOW *win, int offset, int lenght, int visible) +{ + int i, pos; + + if (lenght > visible) + pos = (visible / (double)lenght) * offset; + else + pos = offset; + wattrset(win, shadow_border_attr); + for (i = 0; i < visible; i++) { + wmove(win, i, 0); + waddch(win, i == pos ? ACS_BLOCK : ACS_VLINE); + } +} + +static int +DialogCheckBox(char *title, char *prompt, int height, int width, int menu_height, + int item_no, char **items, char *label1, char *label2, char *checks) +{ + int i, x, y, cur_x, cur_y, box_x, box_y, key = 0, button = 0, choice = 0, + scroll = 0, max_choice, nscroll, max_scroll, x1, x2, l1len, l2len; + WINDOW *dialog, *menu; + + max_choice = MIN(menu_height, item_no); + max_scroll = MAX(0, item_no - max_choice); + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + menu_width = width - 6; + getyx(dialog, cur_y, cur_x); + box_y = cur_y + 1; + box_x = (width - menu_width) / 2 - 1; + + menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + PaintBox(dialog, box_y, box_x, menu_height + 2, menu_width + 2); + + item_x = 3; + + for (i = 0; i < max_choice; i++) + PaintCheckItem(menu, items[i + scroll], i, i == 0, checks[i + scroll]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + + /*CONSTCOND*/ + while (1) { + i = choice; + key = wgetch(dialog); + + if (menu_height > 1 && key == KEY_PPAGE) { + if (!choice) { + if (scroll) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + + nscroll = max_choice > scroll ? -scroll : -max_choice; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + i = scroll + nscroll; + PaintCheckItem(menu, items[i], 0, TRUE, checks[i]); + for (++i; i <= scroll; i++) + PaintCheckItem(menu, items[i], i - (scroll + nscroll), FALSE, checks[i]); + scroll += nscroll; + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = 0; + } + else if (menu_height > 1 && key == KEY_NPAGE) { + if (choice == max_choice - 1) { + if (scroll < max_scroll) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + + nscroll = (scroll + max_choice > max_scroll ? + max_scroll : scroll + max_choice) - scroll; + scrollok(menu, TRUE); + wscrl(menu, nscroll); + scrollok(menu, FALSE); + + scroll += nscroll; + for (i = 0; i < max_choice - 1; i++) + PaintCheckItem(menu, items[i + scroll], i, FALSE, checks[i + scroll]); + PaintCheckItem(menu, items[i + scroll], max_choice - 1, TRUE, checks[i + scroll]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + i = max_choice - 1; + } + else if (key == KEY_UP) { + if (!choice) { + if (scroll) { + /* Scroll menu down */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintCheckItem(menu, items[scroll], 0, FALSE, checks[scroll]); + scrollok(menu, TRUE); + wscrl(menu, - 1); + scrollok(menu, FALSE); + } + scroll--; + PaintCheckItem(menu, items[scroll], 0, TRUE, checks[scroll]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = choice - 1; + } + else if (key == KEY_DOWN) { + if (choice == max_choice - 1) { + if (scroll + choice < item_no - 1) { + /* Scroll menu up */ + getyx(dialog, cur_y, cur_x); + if (menu_height > 1) { + PaintCheckItem(menu, items[scroll + max_choice - 1], max_choice - 1, FALSE, checks[scroll + max_choice - 1]); + scrollok(menu, TRUE); + scroll(menu); + scrollok(menu, FALSE); + } + scroll++; + PaintCheckItem(menu, items[scroll + max_choice - 1], max_choice - 1, TRUE, checks[scroll + max_choice - 1]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wrefresh(dialog); + continue; + } + } + else + i = MIN(choice + 1, item_no - 1); + } + + if (i != choice) { + getyx(dialog, cur_y, cur_x); + PaintCheckItem(menu, items[scroll + choice], choice, FALSE, checks[scroll + choice]); + + choice = i; + PaintCheckItem(menu, items[scroll + choice], choice, TRUE, checks[scroll + choice]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + continue; + } + + switch (key) { + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + if (!button) { + button = 1; + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + } + else { + button = 0; + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + } + wrefresh(dialog); + break; + case ' ': + getyx(dialog, cur_y, cur_x); + checks[scroll + choice] = !checks[scroll + choice]; + PaintCheckItem(menu, items[scroll + choice], choice, TRUE, checks[scroll + choice]); + wmove(dialog, cur_y, cur_x); + wnoutrefresh(menu); + wrefresh(dialog); + break; + case '\r': + case '\n': + delwin(dialog); + return (!button ? 0 : -1); + default: + for (i = scroll + choice + 1; i < item_no; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + if (i == item_no) { + for (i = 0; i < scroll + choice; i++) + if (toupper(items[i][0]) == toupper(key)) + break; + } + getyx(dialog, cur_y, cur_x); + if (i < item_no && i != scroll + choice) { + if (i >= scroll && i < scroll + max_choice) { + /* it is already visible */ + PaintCheckItem(menu, items[scroll + choice], choice, FALSE, checks[scroll + choice]); + choice = i - scroll; + } + else { + scroll = MIN(i, max_scroll); + choice = i - scroll; + for (i = 0; i < max_choice; i++) + if (i != choice) + PaintCheckItem(menu, items[scroll + i], i, FALSE, checks[scroll + i]); + } + PaintCheckItem(menu, items[scroll + choice], choice, TRUE, checks[scroll + choice]); + PaintScroller(menu, scroll + choice, item_no, menu_height); + wnoutrefresh(menu); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + } + break; + } + } + /*NOTREACHED*/ +} + +static void +PaintCheckItem(WINDOW *win, char *item, int choice, int selected, int checked) +{ + int i; + + wattrset(win, selected ? title_attr : dialog_attr); + wmove(win, choice, 1); + for (i = 1; i < menu_width; i++) + waddch(win, ' '); + wmove(win, choice, item_x); + wattrset(win, selected ? title_attr : dialog_attr); + wprintw(win, "[%c] ", checked ? 'X' : ' '); + waddstr(win, item); +} + +static char * +DialogInput(char *title, char *prompt, int height, int width, char *init, + char *label1, char *label2, int def_button) +{ + int i, x, y, box_y, box_x, box_width, len, + input_x = 0, scroll = 0, key = 0, button = -1, x1, x2, l1len, l2len; + char instr[1024 + 1]; + WINDOW *dialog; + + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + PaintWindow(dialog, title, 0, 0, height, width); + + wattrset(dialog, dialog_attr); + PrintWrap(dialog, prompt, width - 3, 2, 3); + + l1len = strlen(label1); + l2len = strlen(label2); + + x1 = (width - (l1len + l2len)) / 3; + x2 = x1 + x1 + l1len; + + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + PaintBox(dialog, y + 1, box_x - 1, 3, box_width + 2); + + x = width / 2 - 11; + y = height - 3; + PaintButton(dialog, label2, y, x2, def_button == 1); + PaintButton(dialog, label1, y, x1, def_button == 0); + + memset(instr, '\0', sizeof(instr)); + wmove(dialog, box_y, box_x); + wattrset(dialog, dialog_attr); + if (init) + strncpy(instr, init, sizeof(instr) - 2); + + input_x = len = strlen(instr); + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } + else + waddstr(dialog, instr); + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (1) { + key = wgetch(dialog); + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + if (scroll && !input_x) { + --scroll; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, instr[scroll + input_x + i] ? instr[scroll + input_x + i] : ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + else if (input_x) { + wmove(dialog, box_y, --input_x + box_x); + wrefresh(dialog); + } + continue; + case KEY_RIGHT: + if (input_x == box_width - 1) { + ++scroll; + wmove(dialog, box_y, box_x); + for (i = scroll; i < scroll + box_width; i++) + waddch(dialog, instr[scroll + i] ? instr[scroll + i] : ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + else if (input_x + scroll < len) { + wmove(dialog, box_y, ++input_x + box_x); + wrefresh(dialog); + } + continue; + case KEY_BACKSPACE: + case 0177: + if (input_x || scroll) { + wattrset(dialog, dialog_attr); + + if (scroll + input_x < len) + memmove(instr + scroll + input_x - 1, + instr + scroll + input_x, + len - (scroll + input_x)); + instr[--len] = '\0'; + + if (!input_x) { + scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, instr[scroll + input_x + i] ? instr[scroll + input_x + i] : ' '); + input_x = len - scroll; + } + else { + wmove(dialog, box_y, --input_x + box_x); + for (i = scroll + input_x; i < len && + i < scroll + box_width; i++) + waddch(dialog, instr[i]); + waddch(dialog, ' '); + } + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (scroll + input_x < sizeof(instr) - 1) { + wattrset(dialog, dialog_attr); + if (scroll + input_x < len) { + memmove(instr + scroll + input_x + 1, + instr + scroll + input_x, + len - (scroll + input_x)); + } + instr[scroll + input_x] = key; + instr[++len] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } + else { + wmove(dialog, box_y, input_x++ + box_x); + for (i = scroll + input_x - 1; i < len && + i < scroll + box_width; i++) + waddch(dialog, instr[i]); + wmove(dialog, box_y, input_x + box_x); + } + wrefresh(dialog); + } + else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + + switch (key) { + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + wrefresh(dialog); + break; + case 0: + button = -1; /* Indicates input box is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wrefresh(dialog); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + PaintButton(dialog, label1, y, x1, FALSE); + PaintButton(dialog, label2, y, x2, TRUE); + wrefresh(dialog); + break; + case 1: + button = -1; /* Indicates input box is selected */ + PaintButton(dialog, label2, y, x2, FALSE); + PaintButton(dialog, label1, y, x1, TRUE); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\r': + case '\n': + delwin(dialog); + return (button == -1 ? XtNewString(instr) : NULL); + } + } +} Index: xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c:1.1 xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c:1.1 Thu May 18 12:30:00 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c Tue Nov 14 16:59:24 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c,v 1.1 2000/05/18 16:30:00 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c,v 1.4 2000/11/14 21:59:24 dawes Exp $ */ /* @@ -34,7 +34,6 @@ */ #include "vidmode.h" -#include <X11/extensions/Xinerama.h> #include <X11/Xaw/Command.h> #include <X11/Xaw/Form.h> #include <X11/Xaw/Label.h> @@ -474,7 +473,6 @@ rep = XtCreateManagedWidget("prev", commandWidgetClass, vtune, NULL, 0); XtAddCallback(rep, XtNcallback, SwitchCallback, (XtPointer)-1); mode = XtCreateManagedWidget("mode", menuButtonWidgetClass, vtune, NULL, 0); - menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, vtune, NULL, 0); rep = XtCreateManagedWidget("next", commandWidgetClass, vtune, NULL, 0); XtAddCallback(rep, XtNcallback, SwitchCallback, (XtPointer)1); @@ -494,7 +492,8 @@ XmuSnprintf(name, sizeof(name), "%s.%d", dispstr, i); rep = XtCreateManagedWidget(name, smeBSBObjectClass, screenp, NULL, 0); - XtAddCallback(rep, XtNcallback, ChangeScreenCallback, (XtPointer)i); + XtAddCallback(rep, XtNcallback, ChangeScreenCallback, + (XtPointer)(long)i); if (i == 0) { screenb = XtVaCreateManagedWidget("screenB", menuButtonWidgetClass, vtune, @@ -504,8 +503,6 @@ } } XtRealizeWidget(screenp); - monitor = XtCreatePopupShell("monitorP", simpleMenuWidgetClass, - vtune, NULL, 0); rep = XtCreateManagedWidget("up", repeaterWidgetClass, vtune, NULL, 0); @@ -579,8 +576,8 @@ add = XtCreateManagedWidget("add", commandWidgetClass, vtune, NULL, 0); XtAddCallback(add, XtNcallback, AddModeCallback, NULL); XtCreateManagedWidget("addto", labelWidgetClass, vtune, NULL, 0); - monitorb = XtVaCreateManagedWidget("ident", menuButtonWidgetClass, vtune, - XtNmenuName, "monitorP", NULL, 0); + monitorb = XtCreateManagedWidget("ident", menuButtonWidgetClass, vtune, + NULL, 0); XtCreateManagedWidget("as", labelWidgetClass, vtune, NULL, 0); text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, vtune, XtNeditType, XawtextEdit, NULL, 0); @@ -601,10 +598,11 @@ else XtMapWidget(vtune); if (vidtune != NULL) { - int i; Arg args[1]; Boolean state; XF86ConfMonitorPtr mon; + static char menuName[16]; + static int menuN; XtErrorFunc = XSetErrorHandler(VidmodeError); XF86VidModeLockModeSwitch(XtDisplay(toplevel), vidtune->screen, True); @@ -616,9 +614,15 @@ XtGetValues(automatic, args, 1); XtSetSensitive(apply, !state); autoflag = state; + + if (monitor) + XtDestroyWidget(monitor); + XmuSnprintf(menuName, sizeof(menuName), "menuP%d", menuN); + menuN = !menuN; + monitor = XtCreatePopupShell(menuName, simpleMenuWidgetClass, + vtune, NULL, 0); + XtVaSetValues(monitorb, XtNmenuName, menuName, NULL, 0); - for (i = 0; i < ((CompositeWidget)monitor)->composite.num_children; i++) - XtDestroyWidget(((CompositeWidget)monitor)->composite.children[i]); mon = XF86Config->conf_monitor_lst; while (mon != NULL) { Widget sme = XtCreateManagedWidget(mon->mon_identifier, @@ -782,7 +786,7 @@ { if (repeater != w) return; - switch ((int)client_data) { + switch ((long)client_data) { case LEFT: if (modeline.hsyncend + 4 < modeline.htotal) { modeline.hsyncstart += 4; @@ -936,7 +940,7 @@ static void AutoCallback(Widget w, XtPointer call_data, XtPointer client_data) { - autoflag = (Bool)client_data; + autoflag = (Bool)(long)client_data; XtSetSensitive(apply, !autoflag); } @@ -970,7 +974,7 @@ static void SwitchCallback(Widget w, XtPointer call_data, XtPointer client_data) { - int direction = (int)call_data; + int direction = (long)call_data; Arg args[1]; Bool result; char label[32]; @@ -1021,7 +1025,7 @@ { Arg args[1]; - screenno = (int)call_data; + screenno = (long)call_data; if (screenno > computer.num_vidmodes || screenno < 0 || vidtune == computer.vidmodes[screenno]) return; @@ -1069,13 +1073,19 @@ int i; char label[32]; Arg args[1]; + static char menuName[16]; + static int menuN; XFree(vidtune->infos); XF86VidModeGetAllModeLines(XtDisplay(toplevel), vidtune->screen, &vidtune->num_infos, &vidtune->infos); - for (i = 0; i < ((CompositeWidget)menu)->composite.num_children; i++) - XtDestroyWidget(((CompositeWidget)menu)->composite.children[i]); + XmuSnprintf(menuName, sizeof(menuName), "menu%d", menuN); + menuN = !menuN; + if (menu) + XtDestroyWidget(menu); + menu = XtCreatePopupShell(menuName, simpleMenuWidgetClass, vtune, NULL, 0); + XtVaSetValues(mode, XtNmenuName, menuName, NULL, 0); for (i = 0; i < vidtune->num_infos; i++) { Widget sme; @@ -1105,7 +1115,7 @@ { asking_force = 0; XtPopdown(forceshell); - do_force = (int)user_data; + do_force = (long)user_data; } void @@ -1155,7 +1165,7 @@ XBell(XtDisplay(w), 80); return; } - if (xf86FindModeLine(label, vidtune->monitor->mon_modeline_lst) + if (xf86findModeLine(label, vidtune->monitor->mon_modeline_lst) != NULL && !ForceAddMode()) return; @@ -1174,7 +1184,7 @@ mode->ml_flags = modeline.flags; mode->ml_hskew = modeline.hskew; vidtune->monitor->mon_modeline_lst = - xf86AddModeLine(vidtune->monitor->mon_modeline_lst, mode); + xf86addModeLine(vidtune->monitor->mon_modeline_lst, mode); } else XBell(XtDisplay(w), 80); Index: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.cpp:1.1 --- /dev/null Mon Dec 18 14:32:35 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.cpp Mon Dec 11 15:48:56 2000 @@ -0,0 +1,148 @@ +.\" +.\" Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) +.\" +.\" Permission is hereby granted, free of charge, to any person obtaining a +.\" copy of this software and associated documentation files (the "Software"), +.\" to deal in the Software without restriction, including without limitation +.\" the rights to use, copy, modify, merge, publish, distribute, sublicense, +.\" and/or sell copies of the Software, and to permit persons to whom the +.\" Software is furnished to do so, subject to the following conditions: +.\" +.\" The above copyright notice and this permission notice shall be included in +.\" all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +.\" CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +.\" SOFTWARE. +.\" +.\" Except as contained in this notice, the name of Conectiva Linux shall +.\" not be used in advertising or otherwise to promote the sale, use or other +.\" dealings in this Software without prior written authorization from +.\" Conectiva Linux. +.\" +.\" Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.cpp,v 1.1 2000/12/11 20:48:56 dawes Exp $ +.\" +.TH xf86cfg 1 "Version 4.0.2" "XFree86" +.SH NAME +xf86cfg - Graphical configuration tool for XFree86 4.0 +.SH SYNOPSIS +.B xf86cfg +[-xf86config \fIXF86Config\fP] [-modulepath \fImoduledir\fP] +[-fontpath \fIfontsdir\fP] [-toolkitoption ...] +.SH DESCRITPION +.I Xf86cfg +is a tool to configure \fIXFree86 4.0\fP, and can be used to either write the +initial configuration file or make customizations to the current configuration. +.PP +When the \fBDISPLAY\fP environment variable is not set, xf86cfg will run +the command \fIXFree86 -configure\fP to allow the xserver detect the +hardware in the computer, and write an initial \fIXF86Config\fP file +in the user's home directory. Then, it will start XFree86 and allow +customizations. +.br +If the \fBDISPLAY\fP environment variable is set, xf86cfg will read the +default \fIXF86Config\fP, that may not be the same being used by the current +server, and allow customizations. +.PP +To use an alternative location for modules or fonts the respective search +paths may be specified. +.PP +Unless there is an \fBApply\fP button in the current xf86cfg dialog, the +changes made will take place the next time \fIXFree86\fP is started. + +.PP +Xf86cfg allows addition and configuration of new devices, such as video cards, +monitors, keyboards and mouses. +.PP +Screen layout configuration for xinerama or traditional multi-head is also +available. +.PP +Modelines can be configured or optimized. +.PP +AccessX basic configurations can be made in the xf86cfg's accessx section. + +.SH OPTIONS +.TP 8 +.I -xf86config +Specifies an alternate XF86Config file for configuration. +.TP 8 +.I -modulepath +Specifies where xf86cfg, and the server it may start, should look for +XFree86 modules. +.TP 8 +.I -serverpath +Specifies the complete path, not including the binary name, of the +XFree86 binary. +.TP 8 +.I -fontpath +Specifies the path to the fonts that should be used by the server started +by xf86cfg. +.TP 8 +.I -rgbpath +Specifies the path to the rgb.txt file that should be used by the server +started by xf86cfg, if any. +.TP 8 +.I -textmode +If xf86cfg was compiled with support to ncurses, this option makes xf86cfg +enters a text mode interface. + +.SH ENVIRONMENT +.TP 8 +.I DISPLAY +Default host and display number +.TP 8 +.I XWINHOME +Directory where XFree86 was installed, defaults to /usr/X11R6. +.TP 8 +.I XENVIRONMENT +Name of a resource file that overrides the global resources +stored in the RESOURCE_MANAGER property + +.SH FILES +.TP 8 +.I /etc/XF86Config +Server configuration file +.TP 8 +.I /etc/X11/XF86Config +Server configuration file +.TP 8 +.I /usr/X11R6/etc/XF86Config +Server configuration file +.TP 8 +.I <XRoot>/lib/X11/XF86Config.\fIhostname\fP +Server configuration file +.TP 8 +.I <XRoot>/lib/X11/XF86Config +Server configuration file +.TP 8 +.I <XRoot>/lib/X11/app-default/XF86Cfg +Specifies xf86cfg resources +.TP 8 +.I <Xroot>/lib/X11/xkb/X0-config.keyboard +Keyboard specific configuration + +.SH "SEE ALSO" +.IR XFree86 (1) +.IR XF86Config (__filemansuffix__) + +.SH COPYRIGHT +.TP 8 +Copyright 2000, Conectiva Linux S.A. +\fIhttp://www.conectiva.com\fP +.TP 8 +Copyright 2000, The XFree86 Project +\fIhttp://www.XFree86.org\fP + +.SH AUTHORS +.TP 8 +Paulo César Pereira de Andrade \fI<pcpa@conectiva.com.br>\fP +The XFree86 Project + +.SH BUGS +Probably. Index: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man:1.1 xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man:removed --- xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man:1.1 Tue Jun 13 19:15:52 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man Mon Dec 18 14:32:35 2000 @@ -1,121 +0,0 @@ -.\" -.\" Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) -.\" -.\" Permission is hereby granted, free of charge, to any person obtaining a -.\" copy of this software and associated documentation files (the "Software"), -.\" to deal in the Software without restriction, including without limitation -.\" the rights to use, copy, modify, merge, publish, distribute, sublicense, -.\" and/or sell copies of the Software, and to permit persons to whom the -.\" Software is furnished to do so, subject to the following conditions: -.\" -.\" The above copyright notice and this permission notice shall be included in -.\" all copies or substantial portions of the Software. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -.\" CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -.\" SOFTWARE. -.\" -.\" Except as contained in this notice, the name of Conectiva Linux shall -.\" not be used in advertising or otherwise to promote the sale, use or other -.\" dealings in this Software without prior written authorization from -.\" Conectiva Linux. -.\" -.\" Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> -.\" -.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man,v 1.1 2000/06/13 23:15:52 dawes Exp $ -.\" -.TH xf86cfg 1 "Version 4.0" "XFree86" -.SH NAME -xf86cfg - Graphical configuration tool for XFree86 4.0 -.SH SYNOPSIS -.B xf86cfg -[-xf86config \fIXF86Config\fP] [-toolkitoption ...] -.SH DESCRITPION -.I Xf86cfg -is a tool to configure \fIXFree86 4.0\fP, and can be used to either write the -initial configuration file or make customizations to the current configuration. -.PP -When the \fBDISPLAY\fP environment variable is not set, xf86cfg will run -the command \fIXFree86 -configure\fP to allow the xserver detect the -hardware in the computer, and write an initial \fIXF86Config\fP file -in the user's home directory. Then, it will start XFree86 and allow -customizations. -.br -If the \fBDISPLAY\fP environment variable is set, xf86cfg will read the -default \fIXF86Config\fP, that may not be the same being used by the current -server, and allow customizations. -.PP -Unless there is an \fBApply\fP button in the current xf86cfg dialog, the -changes made will take place the next time \fIXFree86\fP is started. - -.PP -Xf86cfg allows addition and configuration of new devices, such as video cards, -monitors, keyboards and mouses. -.PP -Screen layout configuration for xinerama or traditional multi-head is also -available. -.PP -Modelines can be configured or optimized. -.PP -AccessX basic configurations can be made in the xf86cfg's accessx section. - -.SH ENVIRONMENT -.TP 8 -.I DISPLAY -Default host and display number -.TP 8 -.I XENVIRONMENT -Name of a resource file that overrides the global resources -stored in the RESOURCE_MANAGER property - -.SH FILES -.TP 8 -.I /etc/XF86Config -Server configuration file -.TP 8 -.I /etc/X11/XF86Config -Server configuration file -.TP 8 -.I /usr/X11R6/etc/XF86Config -Server configuration file -.TP 8 -.I <XRoot>/lib/X11/XF86Config.\fIhostname\fP -Server configuration file -.TP 8 -.I <XRoot>/lib/X11/XF86Config -Server configuration file -.TP 8 -.I <XRoot>/lib/X11/app-default/XF86Cfg -Specifies xf86cfg resources -.TP 8 -.I <Xroot>/lib/X11/xkb/X0-config.keyboard -Keyboard specific configuration - -.SH "SEE ALSO" -.IR XFree86 (1) -.IR XF86Config (5x) - -.SH RESTRICTIONS -Not all customizable options are available. -.br -A protocol for external modules is in the plans. - -.SH COPYRIGHT -.TP 8 -Copyright 2000, Conectiva Linux S.A. -\fIhttp://www.conectiva.com\fP -.TP 8 -Copyright 2000, The XFree86 Project -\fIhttp://www.XFree86.org\fP - -.SH AUTHORS -.TP 8 -Paulo César Pereira de Andrade \fI<pcpa@conectiva.com.br>\fP -The XFree86 Project - -.SH BUGS -Probably. Index: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c:1.2 Thu May 18 12:30:01 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c Thu Nov 30 15:55:18 2000 @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c,v 1.2 2000/05/18 16:30:01 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c,v 1.4 2000/11/30 20:55:18 paulo Exp $ */ #include "xf86config.h" @@ -35,32 +35,8 @@ * Implementation */ int -ErrorF(const char *fmt, ...) +xf86removeOption(XF86OptionPtr *options, char *name) { - int retval; - va_list ap; - - Va_start(ap, fmt); - retval = vfprintf(stderr, fmt, ap); - - va_end(ap); - - return (retval); -} - -int -VErrorF(const char *fmt, va_list ap) -{ - int retval; - - retval = vfprintf(stderr, fmt, ap); - - return (retval); -} - -int -xf86RemoveOption(XF86OptionPtr *options, char *name) -{ XF86OptionPtr opt = *options, prev = opt; while (opt) { @@ -85,7 +61,7 @@ } int -xf86RemoveInput(XF86ConfigPtr config, XF86ConfInputPtr input) +xf86removeInput(XF86ConfigPtr config, XF86ConfInputPtr input) { XF86ConfInputPtr prev, inp = config->conf_input_lst; XF86ConfLayoutPtr lay = config->conf_layout_lst; @@ -109,21 +85,21 @@ /* remove references */ while (lay != NULL) { - xf86RemoveInputRef(lay, inp); + xf86removeInputRef(lay, inp); lay = (XF86ConfLayoutPtr)(lay->list.next); } XtFree(inp->inp_identifier); XtFree(inp->inp_driver); XtFree(inp->inp_comment); - xf86OptionListFree(inp->inp_option_lst); + xf86optionListFree(inp->inp_option_lst); XtFree((XtPointer)inp); return (True); } int -xf86RemoveInputRef(XF86ConfLayoutPtr layout, XF86ConfInputPtr input) +xf86removeInputRef(XF86ConfLayoutPtr layout, XF86ConfInputPtr input) { XF86ConfInputrefPtr prev, iref = layout->lay_input_lst; @@ -131,7 +107,7 @@ while (iref != NULL) { if (iref->iref_inputdev == input) { XtFree(iref->iref_inputdev_str); - xf86OptionListFree(iref->iref_option_lst); + xf86optionListFree(iref->iref_option_lst); if (prev == iref) layout->lay_input_lst = (XF86ConfInputrefPtr)(iref->list.next); @@ -149,7 +125,7 @@ } int -xf86RemoveDevice(XF86ConfigPtr config, XF86ConfDevicePtr device) +xf86removeDevice(XF86ConfigPtr config, XF86ConfDevicePtr device) { XF86ConfDevicePtr prev, dev = config->conf_device_lst; XF86ConfScreenPtr psc, scr = config->conf_screen_lst; @@ -175,9 +151,9 @@ psc = scr; while (scr != NULL) { if (scr->scrn_device == device) { - xf86RemoveScreen(config, scr); + xf86removeScreen(config, scr); if (scr == psc) - scr = config->conf_screen_lst; + scr = psc = config->conf_screen_lst; else scr = psc; continue; @@ -196,14 +172,14 @@ XtFree(dev->dev_ramdac); XtFree(dev->dev_clockchip); XtFree(dev->dev_comment); - xf86OptionListFree(dev->dev_option_lst); + xf86optionListFree(dev->dev_option_lst); XtFree((XtPointer)dev); return (True); } int -xf86RemoveMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr monitor) +xf86removeMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr monitor) { XF86ConfMonitorPtr prev, mon = config->conf_monitor_lst; XF86ConfScreenPtr psc, scr = config->conf_screen_lst; @@ -229,11 +205,8 @@ psc = scr; while (scr != NULL) { if (scr->scrn_monitor == monitor) { - xf86RemoveScreen(config, scr); - if (scr == psc) - scr = config->conf_screen_lst; - else - scr = psc; + xf86removeScreen(config, scr); + scr = psc = config->conf_screen_lst; continue; } psc = scr; @@ -244,14 +217,14 @@ XtFree(mon->mon_vendor); XtFree(mon->mon_modelname); XtFree(mon->mon_comment); - xf86OptionListFree(mon->mon_option_lst); + xf86optionListFree(mon->mon_option_lst); XtFree((XtPointer)mon); return (True); } int -xf86RemoveScreen(XF86ConfigPtr config, XF86ConfScreenPtr screen) +xf86removeScreen(XF86ConfigPtr config, XF86ConfScreenPtr screen) { XF86ConfScreenPtr prev, scrn; XF86ConfLayoutPtr lay; @@ -334,18 +307,20 @@ lay = (XF86ConfLayoutPtr)(lay->list.next); } + xf86freeAdaptorLinkList(screen->scrn_adaptor_lst); + xf86freeDisplayList(screen->scrn_display_lst); + XtFree(screen->scrn_identifier); - XtFree(screen->scrn_obso_driver); XtFree(screen->scrn_monitor_str); XtFree(screen->scrn_device_str); - xf86OptionListFree(screen->scrn_option_lst); + xf86optionListFree(screen->scrn_option_lst); XtFree((XtPointer)screen); return (True); } int -xf86RemoveAdjacency(XF86ConfLayoutPtr layout, XF86ConfAdjacencyPtr adjacency) +xf86removeAdjacency(XF86ConfLayoutPtr layout, XF86ConfAdjacencyPtr adjacency) { XF86ConfAdjacencyPtr prev, adj = layout->lay_adjacency_lst; @@ -378,7 +353,7 @@ } int -xf86RemoveInactive(XF86ConfLayoutPtr layout, XF86ConfInactivePtr inactive) +xf86removeInactive(XF86ConfLayoutPtr layout, XF86ConfInactivePtr inactive) { XF86ConfInactivePtr prev, inac = layout->lay_inactive_lst; @@ -406,7 +381,7 @@ } int -xf86RemoveLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout) +xf86removeLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout) { XF86ConfLayoutPtr prev, lay = config->conf_layout_lst; XF86ConfAdjacencyPtr adj, nadj; @@ -430,25 +405,25 @@ adj = lay->lay_adjacency_lst; while (adj != NULL) { nadj = (XF86ConfAdjacencyPtr)(adj->list.next); - xf86RemoveAdjacency(lay, adj); + xf86removeAdjacency(lay, adj); adj = nadj; } inac = lay->lay_inactive_lst; while (inac != NULL) { ninac = (XF86ConfInactivePtr)(inac->list.next); - xf86RemoveInactive(lay, inac); + xf86removeInactive(lay, inac); inac = ninac; } iref = lay->lay_input_lst; while (iref != NULL) { niref = (XF86ConfInputrefPtr)(iref->list.next); - xf86RemoveInputRef(lay, iref->iref_inputdev); + xf86removeInputRef(lay, iref->iref_inputdev); iref = niref; } - xf86OptionListFree(lay->lay_option_lst); + xf86optionListFree(lay->lay_option_lst); if (prev == lay) config->conf_layout_lst = (XF86ConfLayoutPtr)(lay->list.next); @@ -460,8 +435,416 @@ return (True); } +int +xf86removeModule(XF86ConfigPtr config, XF86LoadPtr load) +{ + XF86LoadPtr prev, mod; + + if (config == NULL || config->conf_modules == NULL || + config->conf_modules->mod_load_lst == NULL) + return (False); + + for (mod = prev = config->conf_modules->mod_load_lst; + mod != NULL; prev = mod, mod = (XF86LoadPtr)(mod->list.next)) + if (load == mod) { + if (mod == prev) + config->conf_modules->mod_load_lst = + (XF86LoadPtr)(mod->list.next); + else + prev->list.next = mod->list.next; + XtFree(mod->load_name); + xf86optionListFree(mod->load_opt); + + return (True); + } + + return (False); +} + +int +xf86removeModes(XF86ConfigPtr config, XF86ConfModesPtr modes) +{ + XF86ConfModesPtr mod; + XF86ConfModeLinePtr ml, next; + XF86ConfMonitorPtr mon; + + if (config == NULL || modes == NULL) + return (False); + + /* check if modes is in config */ + if ((mod = config->conf_modes_lst) == modes) + config->conf_modes_lst = (XF86ConfModesPtr)(mod->list.next); + else + for (; mod != NULL; mod = (XF86ConfModesPtr)(mod->list.next)) + if ((XF86ConfModesPtr)(mod->list.next) == modes) { + mod->list.next = modes->list.next; + break; + } + + if (mod == NULL) + return (False); + + /* remove references in monitor sections */ + mon = config->conf_monitor_lst; + while (mon) { + XF86ConfModesLinkPtr m, p; + + m = p = mon->mon_modes_sect_lst; + while (m) { + if (m->ml_modes == modes) { + XtFree(m->ml_modes_str); + if (m == mon->mon_modes_sect_lst) + p = mon->mon_modes_sect_lst = + (XF86ConfModesLinkPtr)(m->list.next); + else { + p->list.next = m->list.next; + p = p->list.next; + } + XtFree((XtPointer)m); + m = p; + continue; + } + p = m; + m = (XF86ConfModesLinkPtr)(m->list.next); + } + mon = (XF86ConfMonitorPtr)(mon->list.next); + } + + /* free modelines */ + ml = modes->mon_modeline_lst; + while (ml) { + next = (XF86ConfModeLinePtr)(ml->list.next); + XtFree(ml->ml_identifier); + XtFree((XtPointer)ml); + ml = next; + } + + /* free mode */ + XtFree(modes->modes_identifier); + XtFree((XtPointer)modes); + + return (True); +} + +int +xf86removeModesModeLine(XF86ConfModesPtr modes, XF86ConfModeLinePtr modeline) +{ + XF86ConfModeLinePtr ml, prev; + + if (modes == NULL || modeline == NULL || modes->mon_modeline_lst == NULL) + return (False); + + for (ml = prev = modes->mon_modeline_lst; ml; + prev = ml, ml = (XF86ConfModeLinePtr)(ml->list.next)) + if (ml == modeline) { + if (prev == ml) + modes->mon_modeline_lst = (XF86ConfModeLinePtr)(ml->list.next); + else + prev->list.next = ml->list.next; + XtFree(modeline->ml_identifier); + XtFree((XtPointer)modeline); + return (True); + } + + return (False); +} + +int +xf86removeMonitorModeLine(XF86ConfMonitorPtr monitor, XF86ConfModeLinePtr modeline) +{ + XF86ConfModeLinePtr ml, prev; + + if (monitor == NULL || modeline == NULL || monitor->mon_modeline_lst == NULL) + return (False); + + for (ml = prev = monitor->mon_modeline_lst; ml; + prev = ml, ml = (XF86ConfModeLinePtr)(ml->list.next)) + if (ml == modeline) { + if (prev == ml) + monitor->mon_modeline_lst = (XF86ConfModeLinePtr)(ml->list.next); + else + prev->list.next = ml->list.next; + XtFree(modeline->ml_identifier); + XtFree((XtPointer)modeline); + return (True); + } + + return (False); +} + +int +xf86removeMonitorModesLink(XF86ConfMonitorPtr monitor, XF86ConfModesLinkPtr link) +{ + XF86ConfModesLinkPtr lnk, prev; + + if (monitor == NULL || link == NULL || monitor->mon_modes_sect_lst == NULL) + return (False); + + for (lnk = prev = monitor->mon_modes_sect_lst; lnk != NULL; + prev = lnk, lnk = (XF86ConfModesLinkPtr)(lnk->list.next)) + if (lnk == link) { + if (prev == lnk) + monitor->mon_modes_sect_lst = (XF86ConfModesLinkPtr)(lnk->list.next); + else + prev->list.next = lnk->list.next; + XtFree(link->ml_modes_str); + XtFree((XtPointer)link); + + return (True); + } + + return (False); +} + +int +xf86removeScreenAdaptorLink(XF86ConfScreenPtr scrn, XF86ConfAdaptorLinkPtr link) +{ + XF86ConfAdaptorLinkPtr lnk, prev; + + if (scrn == NULL || link == NULL || scrn->scrn_adaptor_lst == NULL) + return (False); + + for (lnk = prev = scrn->scrn_adaptor_lst; lnk != NULL; + prev = lnk, lnk = (XF86ConfAdaptorLinkPtr)(lnk->list.next)) + if (lnk == link) { + if (prev == lnk) + scrn->scrn_adaptor_lst = + (XF86ConfAdaptorLinkPtr)(lnk->list.next); + else + prev->list.next = lnk->list.next; + XtFree(link->al_adaptor_str); + XtFree((XtPointer)link); + + return (True); + } + + return (False); +} + +int +xf86removeScreenDisplay(XF86ConfScreenPtr scrn, XF86ConfDisplayPtr display) +{ + XF86ConfDisplayPtr dsp, prev; + + if (scrn == NULL || display == NULL || scrn->scrn_display_lst == NULL) + return (False); + + for (dsp = prev = scrn->scrn_display_lst; dsp != NULL; + prev = dsp, dsp = (XF86ConfDisplayPtr)(dsp->list.next)) + if (dsp == display) { + if (prev == dsp) + scrn->scrn_display_lst = + (XF86ConfDisplayPtr)(dsp->list.next); + else + prev->list.next = dsp->list.next; + xf86optionListFree(display->disp_option_lst); + XtFree((XtPointer)display->disp_visual); + xf86freeModeList(display->disp_mode_lst); + XtFree((XtPointer)display); + + return (True); + } + + return (False); +} + +int +xf86removeVideoAdaptor(XF86ConfigPtr config, XF86ConfVideoAdaptorPtr video) +{ + XF86ConfVideoAdaptorPtr vid; + XF86ConfScreenPtr scrn; + XF86ConfVideoPortPtr vp, next; + + if (config == NULL || video == NULL) + return (False); + + /* check if video is in config and update videoadaptor list */ + if ((vid = config->conf_videoadaptor_lst) == video) + config->conf_videoadaptor_lst = (XF86ConfVideoAdaptorPtr)(vid->list.next); + else + for (; vid != NULL; vid = (XF86ConfVideoAdaptorPtr)(vid->list.next)) + if ((XF86ConfVideoAdaptorPtr)(vid->list.next) == video) { + vid->list.next = video->list.next; + break; + } + + if (vid == NULL) + return (False); + + /* remove references in screen sections */ + scrn = config->conf_screen_lst; + while (scrn) { + XF86ConfAdaptorLinkPtr v, p; + + v = p = scrn->scrn_adaptor_lst; + while (v) { + if (v->al_adaptor == video) { + XtFree(v->al_adaptor_str); + if (v == scrn->scrn_adaptor_lst) + p = scrn->scrn_adaptor_lst = + (XF86ConfAdaptorLinkPtr)(v->list.next); + else { + p->list.next = v->list.next; + p = p->list.next; + } + XtFree((XtPointer)v); + v = p; + continue; + } + p = v; + v = (XF86ConfAdaptorLinkPtr)(v->list.next); + } + scrn = (XF86ConfScreenPtr)(scrn->list.next); + } + + /* free videoports */ + vp = video->va_port_lst; + while (vp) { + next = (XF86ConfVideoPortPtr)(vp->list.next); + XtFree(vp->vp_identifier); + xf86optionListFree(vp->vp_option_lst); + XtFree((XtPointer)vp); + vp = next; + } + + /* free videoadaptor */ + XtFree(video->va_identifier); + XtFree(video->va_vendor); + XtFree(video->va_board); + XtFree(video->va_busid); + XtFree(video->va_driver); + XtFree(video->va_fwdref); + xf86optionListFree(video->va_option_lst); + XtFree((XtPointer)video); + + return (True); +} + +int +xf86removeVideoPort(XF86ConfVideoAdaptorPtr va, XF86ConfVideoPortPtr vp) +{ + XF86ConfVideoPortPtr prev; + + if (va == NULL || vp == NULL) + return (False); + + if ((prev = va->va_port_lst) == vp) + va->va_port_lst = (XF86ConfVideoPortPtr)(va->va_port_lst->list.next); + else { + while (prev && (XF86ConfVideoPortPtr)(prev->list.next) != vp) + prev = (XF86ConfVideoPortPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = vp->list.next; + } + + xf86optionListFree(vp->vp_option_lst); + XtFree((XtPointer)vp); + + return (True); +} + +int +xf86removeDisplayMode(XF86ConfDisplayPtr display, XF86ModePtr mode) +{ + XF86ModePtr prev; + + if (display == NULL || mode == NULL) + return (False); + + if ((prev = display->disp_mode_lst) == mode) + display->disp_mode_lst = (XF86ModePtr)(display->disp_mode_lst->list.next); + else { + while (prev && (XF86ModePtr)(prev->list.next) != mode) + prev = (XF86ModePtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = mode->list.next; + } + + XtFree((XtPointer)mode); + + return (True); +} + +int +xf86removeVendor(XF86ConfigPtr config, XF86ConfVendorPtr vendor) +{ + XF86ConfVendorPtr prev; + + if (config == NULL || vendor == NULL) + return (False); + + if ((prev = config->conf_vendor_lst) == vendor) + config->conf_vendor_lst = (XF86ConfVendorPtr)(config->conf_vendor_lst->list.next); + else { + while (prev && (XF86ConfVendorPtr)(prev->list.next) != vendor) + prev = (XF86ConfVendorPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = vendor->list.next; + } + + xf86optionListFree(vendor->vnd_option_lst); + xf86freeVendorSubList(vendor->vnd_sub_lst); + XtFree(vendor->vnd_identifier); + XtFree((XtPointer)vendor); + + return (True); +} + +int +xf86removeVendorSub(XF86ConfVendorPtr vendor, XF86ConfVendSubPtr sub) +{ + XF86ConfVendSubPtr prev; + + if (vendor == NULL || sub == NULL) + return (False); + + if ((prev = vendor->vnd_sub_lst) == sub) + vendor->vnd_sub_lst = (XF86ConfVendSubPtr)(vendor->vnd_sub_lst->list.next); + else { + while (prev && (XF86ConfVendSubPtr)(prev->list.next) != sub) + prev = (XF86ConfVendSubPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = sub->list.next; + } + + xf86optionListFree(sub->vs_option_lst); + XtFree(sub->vs_name); + XtFree(sub->vs_identifier); + XtFree((XtPointer)sub); + + return (True); +} + +int +xf86removeBuffers(XF86ConfDRIPtr dri, XF86ConfBuffersPtr buf) +{ + XF86ConfBuffersPtr prev; + + if (dri == NULL || buf == NULL) + return (False); + + if ((prev = dri->dri_buffers_lst) == buf) + dri->dri_buffers_lst = (XF86ConfBuffersPtr)(dri->dri_buffers_lst->list.next); + else { + while (prev && (XF86ConfBuffersPtr)(prev->list.next) != buf) + prev = (XF86ConfBuffersPtr)(prev->list.next); + if (prev == NULL) + return (False); + prev->list.next = buf->list.next; + } + + XtFree(buf->buf_flags); + XtFree((XtPointer)buf); + + return (True); +} + int -xf86RenameInput(XF86ConfigPtr config, XF86ConfInputPtr input, char *name) +xf86renameInput(XF86ConfigPtr config, XF86ConfInputPtr input, char *name) { XF86ConfLayoutPtr lay = config->conf_layout_lst; @@ -488,7 +871,7 @@ } int -xf86RenameDevice(XF86ConfigPtr config, XF86ConfDevicePtr dev, char *name) +xf86renameDevice(XF86ConfigPtr config, XF86ConfDevicePtr dev, char *name) { XF86ConfScreenPtr scr = config->conf_screen_lst; @@ -511,7 +894,7 @@ } int -xf86RenameMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr mon, char *name) +xf86renameMonitor(XF86ConfigPtr config, XF86ConfMonitorPtr mon, char *name) { XF86ConfScreenPtr scr = config->conf_screen_lst; @@ -534,7 +917,7 @@ } int -xf86RenameLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout, char *name) +xf86renameLayout(XF86ConfigPtr config, XF86ConfLayoutPtr layout, char *name) { if (config == NULL || layout == NULL || name == NULL || *name == '\0') return (False); @@ -546,7 +929,7 @@ } int -xf86RenameScreen(XF86ConfigPtr config, XF86ConfScreenPtr scrn, char *name) +xf86renameScreen(XF86ConfigPtr config, XF86ConfScreenPtr scrn, char *name) { XF86ConfLayoutPtr lay = config->conf_layout_lst; Index: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h diff -u xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h:1.2 xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h:1.4 --- xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h:1.2 Thu May 18 12:30:01 2000 +++ xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h Thu Nov 30 15:55:18 2000 @@ -26,44 +26,86 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h,v 1.2 2000/05/18 16:30:01 dawes Exp $ + * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h,v 1.4 2000/11/30 20:55:18 paulo Exp $ */ #include "config.h" -#define xf86OptionListFree OptionListFree -#define xf86AddInput(head, ptr) \ - (XF86ConfInputPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddInputref(head, ptr) \ - (XF86ConfInputrefPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddDevice(head, ptr) \ - (XF86ConfDevicePtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddMonitor(head, ptr) \ - (XF86ConfMonitorPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddScreen(head, ptr) \ - (XF86ConfScreenPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddLayout(head, ptr) \ - (XF86ConfLayoutPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86AddModeLine(head, ptr) \ - (XF86ConfModeLinePtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) -#define xf86NewOption NewOption -#define xf86addNewOption addNewOption -#define xf86FindOption FindOption - -int ErrorF(const char*, ...); -int VErrorF(const char*, va_list); -int xf86RemoveOption(XF86OptionPtr*, char*); -int xf86RemoveInput(XF86ConfigPtr, XF86ConfInputPtr); -int xf86RemoveInputRef(XF86ConfLayoutPtr, XF86ConfInputPtr); -int xf86RemoveDevice(XF86ConfigPtr, XF86ConfDevicePtr); -int xf86RemoveMonitor(XF86ConfigPtr, XF86ConfMonitorPtr); -int xf86RemoveScreen(XF86ConfigPtr, XF86ConfScreenPtr); -int xf86RemoveAdjacency(XF86ConfLayoutPtr, XF86ConfAdjacencyPtr); -int xf86RemoveInactive(XF86ConfLayoutPtr, XF86ConfInactivePtr); -int xf86RemoveLayout(XF86ConfigPtr, XF86ConfLayoutPtr); - -int xf86RenameInput(XF86ConfigPtr, XF86ConfInputPtr, char*); -int xf86RenameDevice(XF86ConfigPtr, XF86ConfDevicePtr, char*); -int xf86RenameMonitor(XF86ConfigPtr, XF86ConfMonitorPtr, char*); -int xf86RenameLayout(XF86ConfigPtr, XF86ConfLayoutPtr, char*); -int xf86RenameScreen(XF86ConfigPtr, XF86ConfScreenPtr, char*); +#ifndef _xf86cfg_xf86config_h +#define _xf86cfg_xf86config_h + +#define xf86addInput(head, ptr) \ + (XF86ConfInputPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addInputref(head, ptr) \ + (XF86ConfInputrefPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addDevice(head, ptr) \ + (XF86ConfDevicePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addDisplayMode(head, ptr) \ + (XF86ModePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addMonitor(head, ptr) \ + (XF86ConfMonitorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreen(head, ptr) \ + (XF86ConfScreenPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addLayout(head, ptr) \ + (XF86ConfLayoutPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModeLine(head, ptr) \ + (XF86ConfModeLinePtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModes(head, ptr) \ + (XF86ConfModesPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModesLink(head, ptr) \ + (XF86ConfModesLinkPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addModule(head, ptr) \ + (XF86LoadPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreenAdaptor(head, ptr) \ + (XF86ConfAdaptorLinkPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addScreenDisplay(head, ptr) \ + (XF86ConfDisplayPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVideoAdaptor(head, ptr) \ + (XF86ConfVideoAdaptorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVideoPort(head, ptr) \ + (XF86ConfVideoPortPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addAdjacency(head, ptr) \ + (XF86ConfAdjacencyPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVendor(head, ptr) \ + (XF86ConfVendorPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addVendorSub(head, ptr) \ + (XF86ConfVendSubPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) +#define xf86addBuffers(head, ptr) \ + (XF86ConfBuffersPtr)xf86addListItem((GenericListPtr)(head), (GenericListPtr)(ptr)) + + +int xf86removeOption(XF86OptionPtr*, char*); +int xf86removeInput(XF86ConfigPtr, XF86ConfInputPtr); +int xf86removeInputRef(XF86ConfLayoutPtr, XF86ConfInputPtr); +int xf86removeDevice(XF86ConfigPtr, XF86ConfDevicePtr); +int xf86removeDisplayMode(XF86ConfDisplayPtr, XF86ModePtr); +int xf86removeMonitor(XF86ConfigPtr, XF86ConfMonitorPtr); +int xf86removeScreen(XF86ConfigPtr, XF86ConfScreenPtr); +int xf86removeAdjacency(XF86ConfLayoutPtr, XF86ConfAdjacencyPtr); +int xf86removeInactive(XF86ConfLayoutPtr, XF86ConfInactivePtr); +int xf86removeLayout(XF86ConfigPtr, XF86ConfLayoutPtr); +int xf86removeModule(XF86ConfigPtr, XF86LoadPtr); +int xf86removeModes(XF86ConfigPtr, XF86ConfModesPtr); +int xf86removeModesModeLine(XF86ConfModesPtr, XF86ConfModeLinePtr); +int xf86removeMonitorModeLine(XF86ConfMonitorPtr, XF86ConfModeLinePtr); +int xf86removeMonitorModesLink(XF86ConfMonitorPtr, XF86ConfModesLinkPtr); +int xf86removeScreenAdaptorLink(XF86ConfScreenPtr, XF86ConfAdaptorLinkPtr); +int xf86removeScreenDisplay(XF86ConfScreenPtr, XF86ConfDisplayPtr); +int xf86removeVideoAdaptor(XF86ConfigPtr, XF86ConfVideoAdaptorPtr); +int xf86removeVideoPort(XF86ConfVideoAdaptorPtr, XF86ConfVideoPortPtr); +int xf86removeVendor(XF86ConfigPtr, XF86ConfVendorPtr); +int xf86removeVendorSub(XF86ConfVendorPtr, XF86ConfVendSubPtr); +int xf86removeBuffers(XF86ConfDRIPtr, XF86ConfBuffersPtr); + +int xf86renameInput(XF86ConfigPtr, XF86ConfInputPtr, char*); +int xf86renameDevice(XF86ConfigPtr, XF86ConfDevicePtr, char*); +int xf86renameMonitor(XF86ConfigPtr, XF86ConfMonitorPtr, char*); +int xf86renameLayout(XF86ConfigPtr, XF86ConfLayoutPtr, char*); +int xf86renameScreen(XF86ConfigPtr, XF86ConfScreenPtr, char*); + +extern void xf86freeAdaptorLinkList(XF86ConfAdaptorLinkPtr); +extern void xf86freeDisplayList(XF86ConfDisplayPtr); +extern void xf86freeModeList(XF86ModePtr); +extern void xf86freeVendorSubList(XF86ConfVendSubPtr); + +#endif /* _xf86cfg_xf86config_h */ Index: xc/programs/Xserver/hw/xfree86/xf86config/Cards diff -u xc/programs/Xserver/hw/xfree86/xf86config/Cards:3.69 xc/programs/Xserver/hw/xfree86/xf86config/Cards:3.75 --- xc/programs/Xserver/hw/xfree86/xf86config/Cards:3.69 Fri Mar 31 15:13:40 2000 +++ xc/programs/Xserver/hw/xfree86/xf86config/Cards Tue Dec 12 12:01:40 2000 @@ -18,7 +18,7 @@ # The majority of entries are just a binding of a model name to a # chipset/server and untested. # -# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.69 2000/03/31 20:13:40 dawes Exp $ +# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.75 2000/12/12 17:01:40 dawes Exp $ # VGA @@ -1437,7 +1437,10 @@ NAME S3 Savage3D SEE Unsupported VGA compatible - +NAME S3 Savage4 +SERVER SVGA +DRIVER vga +UNSUPPORTED # ET4000/ET6000 @@ -1462,7 +1465,7 @@ NAME ET4000 W32i, W32p (generic) CHIPSET ET4000/W32(i/p) SERVER SVGA -DRIVER tsemg +DRIVER tseng LINE #Option "linear" # for linear mode at 8bpp LINE #Option "noaccel" # when problems with accelerator LINE #Option "power_saver" # enable VESA DPMS @@ -1639,39 +1642,44 @@ # ATI +NAME ATI Rage 128 +CHIPSET ati +SERVER SVGA +DRIVER r128 + NAME ATI 8514 Ultra (no VGA) -CHIPSET ATI-Mach8 +CHIPSET ati SERVER Mach8 DRIVER vga UNSUPPORTED NAME ATI Graphics Ultra -CHIPSET ATI-Mach8 +CHIPSET ati SERVER Mach8 DRIVER ati NAME ATI Graphics Ultra Pro -CHIPSET ATI-Mach32 +CHIPSET ati SERVER Mach32 DRIVER ati NAME ATI Wonder SVGA -CHIPSET ATI vgawonder +CHIPSET ati SERVER SVGA DRIVER ati NAME ATI Ultra Plus -CHIPSET ATI-Mach32 +CHIPSET ati SERVER Mach32 DRIVER ati NAME ATI Mach32 -CHIPSET ATI-Mach32 +CHIPSET ati SERVER Mach32 DRIVER ati NAME ATI Mach64 -CHIPSET ATI-Mach64 +CHIPSET ati SERVER Mach64 DRIVER ati NOCLOCKPROBE @@ -2278,14 +2286,28 @@ NAME Trident TVGA 8800CS SEE Generic VGA compatible +NAME Trident CyberBlade (generic) +CHIPSET CyberBlade +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + +NAME Trident Blade3D (generic) +CHIPSET Blade3D +SERVER SVGA +DRIVER trident +NOCLOCKPROBE + # SiS NAME SiS 530 CHIPSET SIS520 +SERVER SVGA DRIVER sis NAME SiS 620 CHIPSET SIS620 +SERVER SVGA DRIVER sis NAME SiS SG86C201 @@ -2403,36 +2425,30 @@ UNSUPPORTED # Number 9 I128 - -NAME Number Nine Imagine I-128 (2-8MB) -CHIPSET I128 -SERVER I128 -DRIVER vga -UNSUPPORTED -NAME Number Nine Imagine I-128 Series 2 (2-4MB) +NAME Number Nine Imagine I-128 CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Revolution 3D (T2R) +NAME Number Nine Imagine I-128 Series 2 CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Number Nine Revolution 3D AGP (4-8MB SGRAM) +NAME Number Nine Revolution 3D (T2R) CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE -NAME Number Nine Imagine-128-T2R +NAME Number Nine Imagine-128 Revolution IV (T2R4) CHIPSET I128 SERVER I128 -DRIVER vga -UNSUPPORTED +DRIVER i128 +NOCLOCKPROBE # Matrox @@ -2543,6 +2559,12 @@ LINE VideoRam 8192 NOCLOCKPROBE +NAME Matrox Millennium G400 +CHIPSET mgag400 +SERVER SVGA +DRIVER mga +NOCLOCKPROBE + NAME Matrox Mystique G200 16MB CHIPSET mgag200 SERVER SVGA @@ -2639,6 +2661,29 @@ NAME Creative Graphics Blaster TNT2 SEE RIVA TNT2 +# 3Dfx +NAME Voodoo Banshee (generic) +SERVER SVGA +CHIPSET Voodo Banshee +DRIVER tdfx + +NAME Voodoo3 (generic) +SERVER SVGA +CHIPSET Voodoo3 +DRIVER tdfx + +NAME Elsa Victory II +SEE Voodoo Banshee (generic) + +NAME Diamond Monster Fusion +SEE Voodoo Banshee (generic) + +NAME AOpen PA2010 +SEE Voodoo Banshee (generic) + +NAME Chaintech Desperado 3F10 +SEE Voodoo Banshee (generic) + # 3DLabs NAME ELSA GLoria-L/MX @@ -2731,6 +2776,12 @@ LINE #Option "no_accel" NOCLOCKPROBE +NAME Appian Jeronimo 2000 +CHIPSET PERMEDIA 3 +SERVER XFree86 +DRIVER glint +NOCLOCKPROBE + # Alliance Semiconductor NAME Diamond Stealth Video 2500 @@ -2757,8 +2808,7 @@ NAME NeoMagic (laptop/notebook) CHIPSET MagicGraph 128 series SERVER SVGA -DRIVER vga -UNSUPPORTED +DRIVER neomagic LINE # Chipset "NM2160" LINE # IOBase 0xfea00000 LINE # MemBase 0xfd000000 @@ -2792,6 +2842,14 @@ LINE # Option "fifo_moderate" LINE # Option "fifo_conservative" +# Silicon Motion, Inc. + +NAME Silicon Motion Lynx family +CHIPSET Lynx +SERVER SVGA +DRIVER siliconmotion +NOCLOCKPROBE + # Rendition NAME Rendition Verite 1000 @@ -2853,6 +2911,18 @@ SERVER TGA DRIVER tga RAMDAC Bt463 + +# i810 + +NAME Intel 810 +SERVER SVGA +DRIVER i810 + +# i740 + +NAME Intel 740 (generic) +SERVER SVGA +DRIVER i740 # Misc Index: xc/programs/Xserver/hw/xfree86/xf86config/Imakefile diff -u xc/programs/Xserver/hw/xfree86/xf86config/Imakefile:3.7 xc/programs/Xserver/hw/xfree86/xf86config/Imakefile:3.9 --- xc/programs/Xserver/hw/xfree86/xf86config/Imakefile:3.7 Wed Apr 5 14:14:00 2000 +++ xc/programs/Xserver/hw/xfree86/xf86config/Imakefile Mon Dec 11 15:49:01 2000 @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Imakefile,v 3.7 2000/04/05 18:14:00 dawes Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Imakefile,v 3.9 2000/12/11 20:49:01 dawes Exp $ @@ -8,10 +8,11 @@ SRCS = xf86config.c cards.c OBJS = xf86config.o cards.o - LOCAL_LIBRARIES = + LOCAL_LIBRARIES = $(XKBFILELIB) $(XLIB) DEPLIBS = CARDDBFILE = $(LIBDIR)/Cards - DEFINES = -DCARD_DATABASE_FILE='"$(CARDDBFILE)"' + DEFINES = -DCARD_DATABASE_FILE='"$(CARDDBFILE)"' \ + -DXKB_RULES_DIR=\"$(LIBDIR)/xkb/rules\" #if !defined(OS2Architecture) AllTarget(ProgramTargetName(xf86config)) @@ -26,4 +27,6 @@ DependTarget() InstallNonExecFile(Cards,$(LIBDIR)) -InstallManPageLong(xf86conf,$(MANDIR),xf86config) + +CppManTarget(xf86config,) +InstallManPage(xf86config,$(MANDIR)) Index: xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man diff -u xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man:3.7 xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man:removed --- xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man:3.7 Sat Apr 4 21:28:43 1998 +++ xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man Mon Dec 18 14:32:36 2000 @@ -1,16 +0,0 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86conf.man,v 3.7 1998/04/05 02:28:43 dawes Exp $ -.TH xf86config 1 "Version 3.2" "XFree86" -.SH NAME -xf86config \- generate an XF86Config file -.SH SYNOPSIS -.B xf86config -.SH DESCRIPTION -\fIxf86config\fP is an interactive program for generating an XF86Config file -for use with XFree86 X servers. -.SH FILES -<xroot>/lib/X11/Cards Video cards database -.SH "SEE ALSO" -XFree86(1), XF86Config(4/5), reconfig(1) -.SH AUTHOR -Harm Hanemaayer. -.\" $TOG: xf86conf.man /main/9 1997/07/19 10:53:08 kaleb $ Index: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c diff -u xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c:3.53 xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c:3.55 --- xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c:3.53 Tue Jun 13 20:16:13 2000 +++ xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c Sun Dec 3 14:46:18 2000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c,v 3.53 2000/06/14 00:16:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c,v 3.55 2000/12/03 19:46:18 herrb Exp $ */ /* * This is a configuration program that will create a base XF86Config @@ -72,6 +72,10 @@ * - The card database. * */ +/* Oct2000 + * New 'Configuration of XKB' section. + * Author: Ivan Pascal The XFree86 Project. + */ /* $XConsortium: xf86config.c /main/21 1996/10/28 05:43:57 kaleb $ */ #include <stdlib.h> @@ -83,6 +87,11 @@ #include <sys/types.h> #include <sys/stat.h> +#include <X11/Xlib.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBrules.h> +#define MAX_XKBOPTIONS 5 + #include "cards.h" @@ -178,9 +187,10 @@ char *config_clockchip; int config_xkbdisable = 0; char *config_xkbrules; -char *config_xkbmodel; -char *config_xkblayout; -char *config_xkbcompat; +char *config_xkbmodel = "pc101"; +char *config_xkblayout = "us"; +char *config_xkbvariant = (char *) 0; +char *config_xkboptions = (char *) 0; char *config_depth; char *temp_dir = ""; @@ -513,7 +523,6 @@ * Keyboard configuration. */ - /* * Configuration of XKB */ @@ -522,130 +531,140 @@ "description of your keyboard. If nothing really matches,\n" "choose 1 (Generic 101-key PC)\n\n"; -static struct xkb_model_str { - char *model; - char *desc; -} xkb_model_list[] = { - { "pc101", "Generic 101-key PC" }, - { "pc102", "Generic 102-key (Intl) PC" }, - { "pc104", "Generic 104-key PC" }, - { "pc105", "Generic 105-key (Intl) PC" }, - { "dell101", "Dell 101-key PC" }, - { "everex", "Everex STEPnote" }, - { "flexpro", "Keytronic FlexPro" }, - { "microsoft", "Microsoft Natural" }, - { "omnikey101", "Northgate OmniKey 101" }, - { "winbook", "Winbook Model XP5" }, - { "jp106", "Japanese 106-key" }, - { "pc98", "PC-98xx Series" }, -}; -static int nmodels = sizeof(xkb_model_list)/sizeof(struct xkb_model_str); - static char *xkblayouttext = "Please select the layout corresponding to your keyboard\n"; -static struct xkb_layout_str { - char *layout; - char *desc; - char *compat; -} xkb_layout_list[] = { - { "us", "U.S. English", ""}, - { "en_US", "U.S. English w/ISO9995-3", "" }, - { "be", "Belgian", "" }, - { "bg", "Bulgarian", "" }, - { "ca", "Canadian", "" }, - { "czsk(cz_us_qwertz)", "Czech", "group_led" }, - { "de", "German", "" }, - { "de_CH", "Swiss German", "" }, - { "dk", "Danish", "" }, - { "es", "Spanish", "" }, - { "fi", "Finnish", "" }, - { "fr", "French", "" }, - { "fr_CH", "Swiss French", "" }, - { "gb", "United Kingdom", "" }, - { "hu", "Hungarian", "" }, - { "it", "Italian", "" }, - { "jp", "Japanese", "" }, - { "no", "Norwegian", "" }, - { "pl", "Polish", "" }, - { "pt", "Portugese", "" }, - { "ru", "Russian", "" }, - { "czsk(sk_us_qwertz)", "Slovak", "group_led" }, - { "se", "Swedish", "" }, - { "th", "Thai", "" }, - { "nec/jp", "PC-98xx Series", "" }, -}; -static int nlayouts = sizeof(xkb_layout_list)/sizeof(struct xkb_layout_str); +static char *xkbvarianttext = +"Please enter a variant name for '%s' layout. Or just press enter\n" +"for default variant\n\n"; + +static char *xkboptionstext = +"Please answer the following question with either 'y' or 'n'.\n" +"Do you want to select additional XKB options (group switcher,\n" +"group indicator, etc.)? "; static void keyboard_configuration(void) { - int i; + int i, j; char s[80]; - int xkbmodel,xkblayout; + char *rulesfile; + int number, options[MAX_XKBOPTIONS], num_options; + XkbRF_RulesPtr rules; - /* this is entered when the user did not find a preconfigured - * XkbKeymap - */ +#ifdef XFREE98_XKB + config_xkbrules = "xfree98"; /* static */ + rulesfile = XKB_RULES_DIR "/xfree98"; +#else + config_xkbrules = "xfree86"; /* static */ + rulesfile = XKB_RULES_DIR "/xfree86"; +#endif + + rules = XkbRF_Load(rulesfile, "", True, False); emptylines(); + + if (!rules) { + printf("XKB rules file '%s' not found\n", rulesfile); + printf("Keyboard XKB options will be set to default values.\n"); + keypress(); + return; + } + printf(xkbmodeltext); - for (i=0; i<nmodels; i++) { - printf("%3d %-50s\n",i+1,xkb_model_list[i].desc); + for (i=0; i < rules->models.num_desc; i++) { + printf("%3d %-50s\n", i+1, rules->models.desc[i].desc); } printf("\nEnter a number to choose the keyboard.\n\n"); getstring(s); if (strlen(s) == 0) - xkbmodel = 0; + number = 0; else { i = atoi(s)-1; - xkbmodel = (i < 0 || i > nmodels) ? 0 : i; + number = (i < 0 || i > rules->models.num_desc) ? 0 : i; } + i = strlen(rules->models.desc[number].name) + 1; + config_xkbmodel = Malloc(i); + sprintf(config_xkbmodel,"%s", rules->models.desc[number].name); + emptylines(); printf(xkblayouttext); - xkblayout = -1; + number = -1; for (i=0;;) { - int j; emptylines(); - for (j = i; j < i + 18 && j < nlayouts; j++) + for (j = i; j < i + 18 && j < rules->layouts.num_desc; j++) printf("%3d %-50s\n", j+1, - xkb_layout_list[j].desc); + rules->layouts.desc[j].desc); printf("\n"); printf("Enter a number to choose the country.\n"); - if (nlayouts >= 18) + if (rules->layouts.num_desc >= 18) printf("Press enter for the next page\n"); printf("\n"); getstring(s); if (strlen(s) == 0) { i += 18; - if (i > nlayouts) + if (i > rules->layouts.num_desc) i = 0; continue; } - xkblayout = atoi(s) - 1; - if (xkblayout >= 0 && xkblayout < nlayouts) + number = atoi(s) - 1; + if (number >= 0 && number < rules->layouts.num_desc) break; } + config_xkblayout = Malloc(strlen(rules->layouts.desc[number].name)+1); + sprintf(config_xkblayout,"%s", rules->layouts.desc[number].name); - - /* compose the lines */ -#ifdef XFREE98_XKB - config_xkbrules = "xfree98"; /* static */ -#else - config_xkbrules = "xfree86"; /* static */ -#endif - - i = strlen(xkb_model_list[xkbmodel].model) + 1; - config_xkbmodel = Malloc(i); - sprintf(config_xkbmodel,"%s", xkb_model_list[xkbmodel].model); - - config_xkblayout = Malloc(strlen(xkb_layout_list[xkblayout].layout)+1); - sprintf(config_xkblayout,"%s", xkb_layout_list[xkblayout].layout); + emptylines(); + printf(xkbvarianttext, config_xkblayout); + getstring(s); + if (strlen(s) != 0) { + config_xkbvariant = Malloc(strlen(s) + 1); + strcpy(config_xkbvariant, s); + } - config_xkbcompat = Malloc(strlen(xkb_layout_list[xkblayout].compat)+1); - sprintf(config_xkbcompat,"%s", xkb_layout_list[xkblayout].compat); + emptylines(); + printf(xkboptionstext); + getstring(s); + if (!answerisyes(s)) + return; + num_options = 0; + for (j=0,i=0;;) { + if (!strchr(rules->options.desc[i].name, ':')) { + emptylines(); + printf(" %s\n\n", rules->options.desc[i].desc); + j = i; + } else { + printf("%3d %-50s\n", i - j, rules->options.desc[i].desc); + } + i++; + if ( i == rules->options.num_desc || + !strchr(rules->options.desc[i].name, ':')) { + printf("\nPlease select the option or just press enter if none\n"); + getstring(s); + if (strlen(s) != 0) { + number = atoi(s); + if (number && (num_options < MAX_XKBOPTIONS)) { + options[num_options++] = number + j; + } + } + } + if (i == rules->options.num_desc) + break; + } + + if (!num_options) + return; + + for (j=0,i=0; i<num_options; i++) { + j += strlen(rules->options.desc[options[i]].name); + } + config_xkboptions = Malloc(j + num_options); + for (j=0,i=0; i<num_options; i++) { + j += sprintf(config_xkboptions+j,"%s%s", + i == 0 ? "": "," ,rules->options.desc[options[i]].name); + } return; } @@ -2301,8 +2320,12 @@ config_xkbmodel); fprintf(f, " Option \"XkbLayout\" \"%s\"\n", config_xkblayout); - fprintf(f, " Option \"XkbCompat\" \"%s\"\n", - config_xkbcompat); + if (config_xkbvariant) + fprintf(f, " Option \"XkbVariant\" \"%s\"\n", + config_xkbvariant); + if (config_xkboptions) + fprintf(f, " Option \"XkbOptions\" \"%s\"\n", + config_xkboptions); fprintf(f, "%s",keyboardlastchunk_text); Index: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cpp diff -u /dev/null xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cpp:1.1 --- /dev/null Mon Dec 18 14:32:36 2000 +++ xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cpp Mon Dec 11 15:49:07 2000 @@ -0,0 +1,16 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cpp,v 1.1 2000/12/11 20:49:07 dawes Exp $ +.TH xf86config 1 "Version 4.0.2" "XFree86" +.SH NAME +xf86config \- generate an XF86Config file +.SH SYNOPSIS +.B xf86config +.SH DESCRIPTION +\fIxf86config\fP is an interactive program for generating an XF86Config file +for use with XFree86 X servers. +.SH FILES +<xroot>/lib/X11/Cards Video cards database +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), reconfig(1) +.SH AUTHOR +Harm Hanemaayer. +.\" $TOG: xf86conf.man /main/9 1997/07/19 10:53:08 kaleb $